:root {
  color-scheme: light;
  --green: #217258;
  --green-dark: #19583f;
  --green-light: #eaf4ef;
  --blue: #326fbc;
  --blue-light: #edf3fc;
  --coral: #b84c43;
  --coral-light: #fff0ed;
  --ink: #24322d;
  --muted: #63716a;
  --line: #e1e8e3;
  --surface: #fff;
  --page: #f5f7f6;
  --radius: 8px;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 15px;
}
* { box-sizing: border-box; letter-spacing: 0; }
body { margin: 0; color: var(--ink); background: var(--page); line-height: 1.5; }
button, input, select, textarea { font: inherit; color: inherit; }
button, a, input, select, textarea { -webkit-tap-highlight-color: transparent; }
button, a { touch-action: manipulation; }
button { cursor: pointer; }
a { color: var(--green); text-decoration: none; }
button:disabled { cursor: default; opacity: .55; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible { outline: 3px solid #79aaf0; outline-offset: 3px; }
[hidden] { display: none !important; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 23px; line-height: 1.3; }
h2 { font-size: 18px; }
h3 { font-size: 16px; }
small { font-size: 12px; }
svg { width: 20px; height: 20px; flex-shrink: 0; stroke-width: 1.8; }
.app-shell { max-width: 980px; min-height: 100dvh; margin: 0 auto; background: var(--surface); }
.app-header { min-height: 87px; padding: 18px 20px 14px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; color: var(--green); min-width: 0; }
.brand strong { display: block; font-size: 23px; font-weight: 750; white-space: nowrap; }
.brand small { display: block; color: var(--muted); font-size: 12px; }
.brand-mark { width: 36px; height: 42px; display: grid; place-items: center; border-left: 3px solid var(--green); }
.brand-mark svg { width: 27px; height: 27px; }
.header-account { display: flex; align-items: center; gap: 4px; min-width: 0; }
.account-name { max-width: 100px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.icon-button { border: 0; background: transparent; min-width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center; color: var(--muted); border-radius: var(--radius); flex-shrink: 0; }
.icon-button:hover { background: var(--page); color: var(--green); }
.scope-bar { padding: 12px 20px 0; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.scope-caption { font-size: 12px; color: var(--muted); }
.segmented { display: inline-flex; padding: 3px; background: var(--page); border-radius: var(--radius); max-width: 100%; }
.segmented button { min-height: 44px; padding: 8px 15px; border: 0; background: transparent; border-radius: 5px; color: var(--muted); white-space: nowrap; }
.segmented button[aria-pressed="true"] { background: var(--surface); color: var(--green); box-shadow: 0 1px 3px #24322d12; font-weight: 600; }
main { padding: 22px 20px calc(100px + env(safe-area-inset-bottom)); min-height: 65vh; }
.page-heading, .section-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 16px; }
.page-heading h1, .section-heading h2 { min-width: 0; overflow-wrap: anywhere; }
.page-heading .subline { font-size: 13px; color: var(--muted); margin-top: 4px; }
.heading-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.section { padding-top: 24px; margin-top: 24px; border-top: 1px solid var(--line); }
.section-heading { margin-bottom: 12px; }
.text-button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 0; min-height: 44px; padding: 8px; background: transparent; color: var(--green); flex-shrink: 0; }
.button { min-height: 44px; border: 1px solid var(--line); border-radius: var(--radius); background: white; padding: 10px 16px; display: inline-flex; gap: 8px; align-items: center; justify-content: center; font-weight: 600; text-align: center; overflow-wrap: anywhere; }
.button.primary { background: var(--green); color: #fff; border-color: var(--green); }
.button.primary:hover { background: var(--green-dark); }
.button.danger { color: var(--coral); border-color: #efd4d0; }
.button.full { width: 100%; }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.stats.admin-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.stat { padding: 16px 12px; background: var(--green-light); border-radius: var(--radius); min-width: 0; }
.stat:nth-child(2) { background: var(--blue-light); }
.stat:nth-child(3) { background: var(--coral-light); }
.stat .stat-label { font-size: 12px; color: var(--muted); }
.stat strong { display: block; color: var(--green); font-size: 28px; margin-top: 5px; overflow-wrap: anywhere; line-height: 1.25; }
.stat:nth-child(2) strong { color: var(--blue); }
.stat:nth-child(3) strong { color: var(--coral); }
.stat.sales-stat strong { font-size: 20px; }
.stat .stat-label { display: block; overflow-wrap: anywhere; }
.quick-actions { margin-top: 18px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.quick-action { min-height: 76px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; display: flex; flex-direction: column; gap: 7px; align-items: center; justify-content: center; font-size: 13px; }
.quick-action svg { color: var(--green); width: 23px; height: 23px; }
.quick-action:nth-child(2) svg { color: var(--blue); }
.quick-action:nth-child(3) svg { color: var(--coral); }
.work-tabs, .detail-tabs, .data-tabs { display: flex; gap: 0; border-bottom: 1px solid var(--line); margin: 20px 0 8px; }
.work-tabs button, .detail-tabs button, .data-tabs button { flex: 1; min-width: 0; min-height: 46px; border: 0; border-bottom: 2px solid transparent; background: transparent; color: var(--muted); padding: 9px 4px; font-size: 14px; }
.work-tabs button[aria-selected="true"], .detail-tabs button[aria-selected="true"], .data-tabs button[aria-selected="true"] { color: var(--green); border-color: var(--green); font-weight: 600; }
.count-dot { color: var(--coral); margin-left: 4px; font-size: 12px; }
.customer-row { border-bottom: 1px solid var(--line); padding: 14px 0; display: flex; align-items: center; gap: 10px; min-width: 0; }
.avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--green-light); color: var(--green); display: grid; place-items: center; font-weight: 600; flex-shrink: 0; }
.row-main { flex: 1; min-width: 0; }
.row-main button.customer-name { background: transparent; border: 0; text-align: left; padding: 0; min-height: 44px; max-width: 100%; font-size: 16px; font-weight: 600; overflow-wrap: anywhere; }
.row-top { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.row-meta { font-size: 12px; color: var(--muted); overflow-wrap: anywhere; margin-top: 2px; }
.row-side { text-align: right; max-width: 30%; font-size: 13px; overflow-wrap: anywhere; flex-shrink: 0; }
.row-side strong { color: var(--green); display: block; }
.badge { display: inline-flex; align-items: center; min-height: 22px; padding: 2px 7px; border-radius: 4px; background: var(--page); color: var(--muted); font-size: 11px; vertical-align: middle; overflow-wrap: anywhere; }
.badge.green { color: var(--green); background: var(--green-light); }
.badge.blue { color: var(--blue); background: var(--blue-light); }
.badge.coral { color: var(--coral); background: var(--coral-light); }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.search-form { display: flex; align-items: center; gap: 6px; background: var(--page); border: 1px solid var(--line); border-radius: var(--radius); padding-left: 12px; margin-bottom: 12px; }
.search-form > svg { color: var(--muted); }
.search-form input { flex: 1; min-width: 0; background: transparent; border: 0; min-height: 46px; padding: 10px 0; }
.search-form button { color: var(--green); }
.toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.toolbar select { min-height: 44px; max-width: 100%; border: 1px solid var(--line); background: white; border-radius: var(--radius); padding: 8px 10px; font-size: 13px; }
.toolbar .segmented { margin-right: auto; }
.period-filter { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.period-filter .field input { font-size: 14px; }
.period-actions { grid-column: 1 / -1; display: flex; justify-content: flex-end; gap: 8px; }
.period-filter .form-error { grid-column: 1 / -1; }
.filter-summary { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 8px 0; font-size: 12px; color: var(--muted); }
.pagination { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin: 18px 0; font-size: 13px; color: var(--muted); }
.empty { padding: 32px 12px; text-align: center; color: var(--muted); font-size: 14px; }
.state-block { padding: 52px 12px; text-align: center; color: var(--muted); }
.state-block p { margin: 10px 0 16px; overflow-wrap: anywhere; }
.spinner { display: inline-block; width: 24px; height: 24px; border: 2px solid var(--line); border-top-color: var(--green); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.bottom-nav { position: fixed; bottom: 0; left: 50%; transform: translateX(-50%); width: min(100%, 980px); background: #fffffff5; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); padding: 7px 8px calc(7px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); z-index: 10; }
.bottom-nav a { min-height: 53px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; color: var(--muted); font-size: 12px; }
.bottom-nav a[aria-current="page"] { color: var(--green); font-weight: 600; }
.bottom-nav svg { width: 22px; height: 22px; }
.connection { padding: 8px 20px; color: var(--coral); background: var(--coral-light); font-size: 13px; }
.auth { max-width: 380px; margin: 24px auto; }
.auth h1 { margin-bottom: 24px; font-size: 22px; }
.auth .button { margin-top: 10px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 12px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; font-size: 13px; }
.field.full { grid-column: 1 / -1; }
.field > span, .field > label { font-weight: 500; }
.field input, .field select, .field textarea { width: 100%; min-width: 0; min-height: 44px; border: 1px solid #ced9d1; border-radius: 6px; padding: 10px; background: white; font-size: 16px; }
.field textarea { min-height: 84px; resize: vertical; }
.field input:disabled, .field select:disabled, .field textarea:disabled { background: var(--page); color: var(--muted); }
.checkbox { display: flex; align-items: center; gap: 9px; min-height: 44px; font-size: 14px; cursor: pointer; }
.checkbox input { width: 20px; height: 20px; accent-color: var(--green); flex-shrink: 0; }
.form-section { border: 0; padding: 20px 0 0; margin: 20px 0 0; border-top: 1px solid var(--line); min-width: 0; }
.form-section legend { font-size: 15px; font-weight: 600; padding: 0 8px 0 0; }
.form-section > .form-grid { margin-top: 4px; }
.consumption-categories, .consumption-scenes { display: flex; gap: 12px 24px; flex-wrap: wrap; padding: 12px 0; }
.consumption-categories { border-bottom: 1px solid var(--line); margin-top: 8px; }
.room-choice { color: var(--muted); font-size: 12px; }
.room-toggle:has(input:checked) .room-choice { color: var(--green); }
.consumption-category { padding-top: 16px; min-width: 0; }
.consumption-category > h3 { display: flex; align-items: center; gap: 8px; color: var(--green); }
[data-scene-items] { padding: 12px 0; border-top: 1px solid var(--line); }
[data-scene-items] > h3 { font-size: 14px; color: var(--muted); }
.consumption-item { padding: 8px 0; min-width: 0; }
.consumption-subtotal, .consumption-total, .consumption-record-total { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: 8px; min-width: 0; padding: 12px 0; font-size: 13px; }
.consumption-subtotal output, .consumption-total output, .consumption-record-total strong { color: var(--green); font-weight: 600; overflow-wrap: anywhere; }
.consumption-total { border-top: 1px solid var(--line); margin: 16px 0 8px; font-size: 16px; }
.consumption-total .field { width: 100%; }
.form-error { padding: 10px 12px; color: var(--coral); background: var(--coral-light); border-radius: 6px; margin: 16px 0; font-size: 13px; overflow-wrap: anywhere; }
.form-hint { font-size: 12px; color: var(--muted); margin: 8px 0; overflow-wrap: anywhere; }
.form-footer { position: sticky; bottom: -20px; display: flex; justify-content: flex-end; gap: 10px; padding: 15px 0 calc(15px + env(safe-area-inset-bottom)); margin-top: 20px; background: white; border-top: 1px solid var(--line); z-index: 1; }
.form-footer .primary { flex: 1; }
.sheet { position: fixed; inset: auto 0 0; margin: 0 auto; width: min(100%, 620px); max-width: 100%; max-height: 92dvh; padding: 0; border: 0; border-radius: 12px 12px 0 0; background: white; box-shadow: 0 -10px 40px #152a2520; overflow: auto; overscroll-behavior: contain; }
.sheet::backdrop { background: #132c2659; }
body:has(dialog[open]) { overflow: hidden; }
.sheet-header { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 20px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: #fff; z-index: 2; }
.sheet-header h2 { min-width: 0; overflow-wrap: anywhere; }
#sheet-content { padding: 18px 20px 20px; }
.detail-heading { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; }
.detail-heading .avatar { width: 48px; height: 48px; font-size: 19px; }
.detail-heading h1 { overflow-wrap: anywhere; }
.value-total { padding: 20px 0; }
.value-total span { color: var(--muted); font-size: 13px; }
.value-total strong { display: block; font-size: 32px; color: var(--green); overflow-wrap: anywhere; }
.facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin: 14px 0 20px; }
.fact { min-width: 0; }
.fact dt { font-size: 12px; color: var(--muted); }
.fact dd { margin: 4px 0 0; overflow-wrap: anywhere; white-space: pre-wrap; font-size: 14px; }
.business-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: start; gap: 6px 16px; padding: 13px 0; border-bottom: 1px solid var(--line); }
.business-row strong { font-size: 15px; font-weight: 500; overflow-wrap: anywhere; }
.business-row .amount { font-weight: 600; color: var(--green); text-align: right; overflow-wrap: anywhere; }
.business-row .units { grid-column: 1 / -1; color: var(--muted); font-size: 12px; display: flex; flex-wrap: wrap; gap: 14px; }
.business-items { grid-column: 1 / -1; min-width: 0; padding-left: 12px; border-left: 2px solid var(--green-light); }
.business-items .business-row strong { font-size: 13px; }
.business-items .business-row:last-child { border-bottom: 0; }
.record { padding: 16px 0; border-bottom: 1px solid var(--line); }
.record-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.record p { margin-top: 8px; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px; }
.record .next-step { font-size: 12px; color: var(--green); }
.detail-actions { display: flex; gap: 10px; padding-top: 16px; margin-bottom: 8px; position: sticky; top: 0; background: white; z-index: 9; }
.detail-actions .button { flex: 1; }
.segment-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: center; border-bottom: 1px solid var(--line); padding: 17px 0; }
.segment-row h3 { font-size: 15px; }
.segment-row p { color: var(--muted); font-size: 12px; margin-top: 5px; overflow-wrap: anywhere; }
.segment-side { text-align: right; }
.segment-side strong { color: var(--green); display: block; font-size: 21px; }
.segment-side .text-button { font-size: 12px; padding: 0; }
.setting-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; border: 0; border-bottom: 1px solid var(--line); padding: 12px 0; width: 100%; min-height: 59px; background: white; text-align: left; }
.setting-row > span { display: flex; align-items: center; gap: 12px; }
.setting-row > span svg { color: var(--green); }
.setting-row > svg { color: var(--muted); }
.account-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 15px 0; border-bottom: 1px solid var(--line); }
.account-row .row-main strong { display: block; overflow-wrap: anywhere; }
.account-actions { display: flex; gap: 2px; }
.table-wrap { max-width: 100%; overflow-x: auto; border: 1px solid var(--line); border-radius: 6px; margin: 14px 0; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th, td { text-align: left; border-bottom: 1px solid var(--line); padding: 9px 10px; max-width: 220px; min-width: 90px; overflow-wrap: anywhere; }
th { background: var(--page); font-weight: 600; }
.import-result { padding: 12px 0; }
.import-result p { margin: 8px 0; overflow-wrap: anywhere; }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(90px + env(safe-area-inset-bottom)); max-width: calc(100% - 32px); width: max-content; background: var(--ink); color: white; padding: 11px 16px; border-radius: var(--radius); z-index: 30; font-size: 13px; overflow-wrap: anywhere; }
.skip-link { position: fixed; top: -100px; left: 12px; z-index: 50; background: white; padding: 12px; }
.skip-link:focus { top: 12px; }
.noscript { padding: 24px; }
details > summary { min-height: 44px; padding: 10px 0; color: var(--green); font-size: 14px; cursor: pointer; }
.record-list { min-width: 0; }
@media (min-width: 720px) {
  .period-filter { grid-template-columns: repeat(2, minmax(0, 220px)) auto; align-items: end; }
  .period-actions { grid-column: auto; }
  .app-header { padding: 20px 32px; }
  .scope-bar { padding: 16px 32px 0; }
  main { padding: 26px 32px 110px; }
  .quick-actions { max-width: 560px; }
  .stat { padding: 20px; }
  .stat strong { font-size: 32px; }
  .stats.admin-stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .stat.sales-stat strong { font-size: 24px; }
  .facts { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .sheet { bottom: 20px; border-radius: 8px; max-height: calc(100dvh - 40px); }
  .form-footer { padding-bottom: 15px; }
}
@media (max-width: 374px) {
  .app-header { padding-left: 14px; padding-right: 14px; }
  .brand strong { font-size: 21px; }
  .brand-mark { width: 28px; }
  .account-name { max-width: 48px; }
  main { padding-left: 14px; padding-right: 14px; }
  .scope-bar { padding-left: 14px; padding-right: 14px; }
  .stat { padding: 14px 9px; }
  .stat strong { font-size: 25px; }
  .stat.sales-stat strong { font-size: 18px; }
  #sheet-content { padding-left: 14px; padding-right: 14px; }
  .form-grid { gap: 12px 8px; }
}
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }
