:root {
  --ink: #16352d;
  --muted: #667b74;
  --paper: #f5f1e8;
  --card: #fffdf8;
  --green: #0d5c46;
  --green-2: #e1efe9;
  --orange: #d85c2c;
  --red: #b63232;
  --line: #d9ded9;
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  color: var(--ink);
  background: var(--paper);
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; padding-bottom: 78px; }
button, input { font: inherit; }
button { cursor: pointer; }
.topbar {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between;
  padding: 14px max(18px, env(safe-area-inset-left)); color: white;
  background: linear-gradient(135deg, #094936, #14725a); box-shadow: 0 3px 16px #123a2c35;
}
.eyebrow { font-size: 12px; letter-spacing: .18em; opacity: .78; }
h1 { margin: 2px 0 0; font-size: 24px; }
.icon-btn { width: 42px; height: 42px; border: 1px solid #ffffff55; border-radius: 50%; color: white; background: #ffffff16; font-size: 25px; }
main { width: min(860px, 100%); margin: auto; padding: 16px; }
.project-picker { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 9px; margin-bottom: 12px; font-weight: 700; }.project-picker select,.project-admin select { min-width: 0; padding: 10px; border: 1px solid #aebdb7; border-radius: 9px; color: var(--ink); background: white; font: inherit; }
.summary { display: grid; grid-template-columns: repeat(4, 1fr); overflow: hidden; border-radius: 16px; background: var(--card); box-shadow: 0 5px 24px #263c3320; }
.summary div { display: flex; flex-direction: column; align-items: center; padding: 14px 5px; border-right: 1px solid var(--line); }
.summary div:last-child { border: 0; }
.summary strong { font-size: clamp(20px, 6vw, 25px); color: var(--green); }
.summary span { margin-top: 2px; font-size: 12px; color: var(--muted); }
.search-panel { margin-top: 16px; }
.search-panel > label { display: block; margin: 0 2px 8px; font-weight: 700; }
.search-box { display: grid; grid-template-columns: 35px 1fr 38px; align-items: center; padding: 0 8px; border: 2px solid #aac4b9; border-radius: 15px; background: white; }
.search-box:focus-within { border-color: var(--green); box-shadow: 0 0 0 4px #0d5c4618; }
.search-box span { font-size: 27px; color: var(--green); transform: rotate(-15deg); }
.search-box input { min-width: 0; height: 54px; border: 0; outline: 0; background: transparent; font-size: 18px; }
#clearBtn { display: none; border: 0; background: transparent; color: #82928d; font-size: 28px; }
.filters { display: flex; gap: 7px; overflow-x: auto; padding: 11px 0 2px; }
.filters button { flex: 0 0 auto; padding: 7px 12px; border: 1px solid #b8c5c0; border-radius: 999px; color: #53675f; background: transparent; }
.filters button.active { border-color: var(--green); color: white; background: var(--green); }
.result-head { display: flex; justify-content: space-between; align-items: center; margin: 18px 2px 8px; color: var(--muted); font-size: 14px; }
.result-head button { border: 0; color: var(--green); background: transparent; font-weight: 700; }
.result-head > div { display: flex; gap: 7px; }
.results { display: grid; gap: 10px; }
.customer-card { position: relative; overflow: hidden; padding: 15px; border: 1px solid #d9ded9; border-radius: 15px; background: var(--card); box-shadow: 0 2px 8px #29433710; }
.customer-card.claimed { opacity: .78; background: #eff2ef; }
.customer-card.claimed::after { content: "已领"; position: absolute; top: 13px; right: -29px; width: 100px; padding: 4px 0; text-align: center; color: white; background: #668078; transform: rotate(42deg); font-size: 12px; font-weight: 700; }
.card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.identity { min-width: 0; }
.identity h2 { display: inline; margin: 0; font-size: 21px; }
.code { display: inline-block; margin-left: 7px; padding: 2px 7px; border-radius: 5px; color: var(--green); background: var(--green-2); font-size: 12px; font-weight: 700; vertical-align: 2px; }
.phone { margin-top: 5px; color: var(--muted); font-size: 15px; }
.phone a, .dialog-identity a { color: var(--green); font-weight: 700; text-decoration: none; }
.quantity { flex: 0 0 auto; min-width: 82px; padding-right: 10px; text-align: right; }
.quantity strong { display: block; color: var(--orange); font-size: 29px; line-height: 1; }
.quantity span { font-size: 12px; color: var(--muted); }
.breakdown { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 12px; }
.pill { padding: 5px 9px; border-radius: 8px; background: #f0eee6; font-size: 14px; }
.pill.double { color: #8b4d00; background: #fff0cf; }
.pill.amount { color: #a64613; background: #ffe8d7; font-weight: 700; }
.purchase-history { margin-top: 11px; border: 1px solid #d6e4de; border-radius: 10px; background: #f5faf7; }
.purchase-history summary { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; padding: 9px 10px; cursor: pointer; list-style: none; }
.purchase-history summary::-webkit-details-marker { display: none; }
.purchase-history summary b { color: var(--green); font-size: 13px; }
.purchase-history summary em { margin-left: auto; color: var(--muted); font-size: 12px; font-style: normal; }
.customer-level { padding: 3px 7px; border-radius: 999px; color: #52665f; background: #e3ebe7; font-size: 11px; font-weight: 800; }
.customer-level.vip { color: #7e4600; background: #ffe4aa; }
.purchase-history ul { display: grid; gap: 0; margin: 0; padding: 0 10px 9px; list-style: none; }
.purchase-history li { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; padding: 8px 2px; border-top: 1px solid #dce7e2; font-size: 12px; }
.purchase-history li span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.purchase-history li b { color: var(--orange); }
.purchase-history li small { grid-column: 1/-1; color: var(--muted); }
.remark, .warning { margin: 10px 0 0; padding: 8px 10px; border-radius: 8px; font-size: 14px; }
.remark { color: #735319; background: #fff5d9; }
.warning { color: var(--red); background: #ffebeb; font-weight: 700; }
.card-actions { display: flex; align-items: center; justify-content: flex-end; gap: 12px; margin-top: 13px; }
.redeem-btn { min-width: 126px; padding: 10px 16px; border: 0; border-radius: 10px; color: white; background: var(--green); font-weight: 700; }
.call-btn { min-width: 126px; padding: 10px 16px; border-radius: 10px; color: white; background: #216bc1; text-align: center; text-decoration: none; font-weight: 700; }
.undo-btn { border: 0; color: var(--red); background: transparent; }
.redeem-meta { margin-right: auto; color: var(--muted); font-size: 12px; }
.empty { padding: 45px 20px; text-align: center; color: var(--muted); border: 1px dashed #aab7b2; border-radius: 15px; }
.bottom-actions { position: fixed; z-index: 6; left: 0; right: 0; bottom: 0; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px max(14px, env(safe-area-inset-right)) calc(10px + env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left)); border-top: 1px solid #ccd4d0; background: #fffdf8f2; backdrop-filter: blur(12px); }
.bottom-actions label { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 13px; }
.bottom-actions input { width: 92px; padding: 7px 8px; border: 1px solid #bdc8c3; border-radius: 8px; }
.bottom-actions > div { display: flex; gap: 13px; }
.bottom-actions a { color: var(--green); font-size: 13px; font-weight: 700; text-decoration: none; }
.toast { position: fixed; z-index: 20; left: 50%; bottom: 88px; max-width: calc(100vw - 32px); padding: 11px 17px; border-radius: 10px; color: white; background: #183b31; box-shadow: 0 5px 20px #0004; transform: translate(-50%, 20px); opacity: 0; pointer-events: none; transition: .2s; }
.toast.show { transform: translate(-50%, 0); opacity: 1; }
.toast.error { background: #a52e2e; }
dialog { width: min(460px, calc(100% - 28px)); padding: 0; border: 0; border-radius: 19px; color: var(--ink); background: var(--card); box-shadow: 0 18px 70px #0006; }
dialog::backdrop { background: #10281f99; backdrop-filter: blur(2px); }
dialog form { position: relative; padding: 24px; }
.dialog-close { position: absolute; top: 8px; right: 9px; border: 0; background: transparent; color: #75847f; font-size: 28px; }
.dialog-kicker { margin: 0; color: var(--orange); font-weight: 700; }
dialog h2 { margin: 6px 0 2px; font-size: 27px; }
.dialog-identity { margin: 0; color: var(--muted); }
.dialog-qty { display: flex; gap: 10px; margin: 18px 0; }
.dialog-qty div { flex: 1; padding: 13px 8px; border-radius: 12px; text-align: center; background: #e9f2ee; }
.dialog-qty .double { background: #fff0cf; }
.dialog-qty .amount { color: #a64613; background: #ffe8d7; }
.dialog-qty strong { display: block; font-size: 28px; }
.dialog-remark, .dialog-warning { padding: 9px; border-radius: 8px; }
.dialog-remark { background: #fff5d9; }
.dialog-warning { color: var(--red); background: #ffebeb; font-weight: 700; }
.dialog-buttons { display: grid; grid-template-columns: 1fr 1.5fr; gap: 9px; margin-top: 18px; }
.dialog-buttons button { padding: 12px 8px; border-radius: 10px; font-weight: 700; }
.cancel-btn { border: 1px solid #aebbb6; color: var(--muted); background: transparent; }
.confirm-btn { border: 0; color: white; background: var(--green); }
.form-field { display: grid; gap: 7px; margin-top: 16px; font-weight: 700; }
.form-field input { width: 100%; min-height: 45px; padding: 9px 10px; border: 1px solid #aebbb6; border-radius: 9px; background: white; }
.template-link { color: var(--green); font-weight: 700; }
.app-tabs { position: fixed; z-index: 7; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: repeat(3, 1fr); padding: 6px max(6px, env(safe-area-inset-right)) calc(5px + env(safe-area-inset-bottom)) max(6px, env(safe-area-inset-left)); border-top: 1px solid #cad5d0; background: #fffdf9f5; box-shadow: 0 -4px 18px #18372c18; backdrop-filter: blur(12px); }
.app-tabs button { display: grid; justify-items: center; gap: 2px; padding: 3px; border: 0; color: #71847c; background: transparent; font-size: 12px; }
.app-tabs button span { display: grid; place-items: center; width: 29px; height: 25px; border-radius: 10px; font-size: 17px; font-weight: 800; }
.app-tabs button.active { color: var(--green); font-weight: 800; }
.app-tabs button.active span { color: white; background: var(--green); }
.phase-group { display: grid; gap: 9px; margin-bottom: 20px; }
.phase-group > header { position: sticky; top: 76px; z-index: 3; display: flex; justify-content: space-between; align-items: center; gap: 9px; padding: 10px 12px; border-radius: 10px; color: white; background: #2e5549f2; box-shadow: 0 3px 10px #0002; }
.phase-group > header span { text-align: right; font-size: 12px; }
.empty.prominent { padding: 65px 22px; color: var(--ink); background: #fffdf8; font-size: 16px; line-height: 1.9; }
.load-error strong { display: block; font-size: 20px; margin-bottom: 8px; }
.load-error p { margin: 0 0 18px; color: var(--muted); font-size: 14px; }
.loading-spinner { display: inline-block; width: 24px; height: 24px; margin-bottom: 12px; border: 3px solid #c9d7d0; border-top-color: var(--green); border-radius: 50%; animation: spin .8s linear infinite; vertical-align: middle; }
.sync-warning { margin: 0 0 10px; padding: 9px 12px; border-radius: 10px; color: #7d5200; background: #fff4cf; font-size: 13px; line-height: 1.5; }
@keyframes spin { to { transform: rotate(360deg); } }
.admin-page { padding-bottom: 30px; }
.admin-main { width: min(1100px, calc(100% - 32px)); padding-top: 25px; }
.admin-grid { display: grid; grid-template-columns: 1.25fr .75fr; gap: 18px; margin-bottom: 18px; }
.admin-card { padding: 24px; border: 1px solid #d4ded9; border-radius: 17px; background: var(--card); box-shadow: 0 5px 22px #263c3317; }
.admin-login { width: min(460px,100%); margin: 35px auto; }
.admin-card h2 { margin: 0 0 8px; }
.admin-card p { color: var(--muted); }
.primary-wide { width: 100%; margin: 18px 0 15px; padding: 13px; border: 0; border-radius: 10px; color: white; background: var(--green); font-weight: 800; }
.project-admin { display: grid; grid-template-columns: 1fr auto; gap: 8px; margin: 15px 0; }.project-admin button { border: 1px solid var(--green); border-radius: 9px; color: var(--green); background: white; font-weight: 700; }#projectForm { margin: 12px 0; padding: 13px; border-radius: 10px; background: #edf4f1; }#projectForm .export-btn { margin-top: 10px; border: 0; }
.import-target { margin-top: 14px; padding: 11px 12px; border-left: 4px solid var(--green); border-radius: 6px; color: var(--green); background: #e8f2ee; font-weight: 800; }
.import-preview { margin-top: 12px; padding: 10px 12px; border-radius: 8px; font-size: 14px; font-weight: 700; }
.import-preview.ok { color: #174f3f; background: #e4f2eb; }
.import-preview.error { color: var(--red); background: #ffebeb; }
.phone-connect { display: grid; justify-items: center; text-align: center; }
.phone-connect img { width: 190px; height: 190px; margin: 8px; object-fit: contain; }
.phone-connect strong { color: var(--green); font-size: 18px; }
.admin-title-row { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.admin-title-row > div:last-child { display: flex; gap: 9px; }
.export-btn { padding: 10px 13px; border-radius: 9px; color: white; background: var(--green); text-decoration: none; font-weight: 700; }
.export-btn.secondary { color: var(--green); background: var(--green-2); }
.phase-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px; margin-top: 14px; }
.phase-stats > div { display: grid; gap: 4px; padding: 14px; border-radius: 11px; background: #edf4f1; }
.phase-stats strong { color: var(--green); font-size: 20px; }.phase-stats small { color: var(--muted); }
.batch-money-card { margin-top: 18px; }.batch-money-stats { display: grid; gap: 8px; }.batch-money-stats > div { display: flex; justify-content: space-between; align-items: center; gap: 15px; padding: 12px; border-radius: 10px; background: #f3f6f3; }.batch-money-stats span { display: grid; gap: 3px; }.batch-money-stats small { color: var(--muted); }.batch-money-stats > div > b { flex: 0 0 auto; color: var(--orange); font-size: 22px; }.batch-stat > button { flex: 0 0 auto; padding: 7px 9px; border-radius: 8px; font: inherit; font-size: 13px; font-weight: 700; cursor: pointer; }.batch-redeem-btn { border: 1px solid var(--orange); color: #995a00; background: #fff8e6; }.batch-detail-btn { border: 1px solid var(--green); color: var(--green); background: white; }.batch-delete-btn { border: 1px solid #d6a0a0; color: var(--red); background: #fff6f6; }.batch-stat > button:hover { filter: brightness(.96); }
.install-help { margin-top: 18px; }.install-help > div { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }
@media (min-width: 700px) { .results { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 720px) { .admin-grid { grid-template-columns: 1fr; }.admin-title-row { align-items: flex-start; flex-direction: column; }.install-help > div { grid-template-columns: 1fr; } }
@media print {
  body { padding: 0; background: white; }
  .topbar, .summary, .search-panel, .bottom-actions, .result-head button, .card-actions, .toast { display: none !important; }
  main { width: 100%; padding: 0; }
  .result-head { margin: 0 0 8px; font-size: 16px; font-weight: 700; }
  .results { display: grid; grid-template-columns: repeat(2, 1fr); gap: 5px; }
  .customer-card { break-inside: avoid; padding: 7px 9px; border-radius: 0; box-shadow: none; }
  .identity h2 { font-size: 15px; }
  .phone, .breakdown, .remark, .warning { margin-top: 3px; font-size: 11px; }
  .quantity strong { font-size: 21px; }
}
