:root {
  color-scheme: light;
  --ink: #17140f;
  --ink-soft: #27221b;
  --paper: #fffdf8;
  --canvas: #f2eee5;
  --canvas-deep: #e9e2d5;
  --muted: #746d62;
  --muted-light: #aaa296;
  --line: #ded7cb;
  --line-strong: #c6bcae;
  --amber: #ffb000;
  --amber-bright: #ffc433;
  --amber-soft: #fff0bd;
  --red: #e8483f;
  --green: #37a458;
  --radius: 22px;
  --radius-small: 15px;
  --shadow: 0 16px 45px rgba(42, 32, 19, .07);
  --font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }
html { min-width: 320px; scroll-behavior: smooth; touch-action: pan-x pan-y; }
body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background: radial-gradient(circle at 8% 3%, rgba(255, 176, 0, .08), transparent 24rem), var(--canvas);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .45; }
a { color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid rgba(255, 176, 0, .42); outline-offset: 2px; }

.skip-link {
  position: fixed;
  z-index: 999;
  top: 10px;
  left: 10px;
  padding: 10px 14px;
  border-radius: 10px;
  background: #fff;
  color: #111;
  font-size: .8rem;
  font-weight: 800;
  text-decoration: none;
  transform: translateY(-150%);
}
.skip-link:focus { transform: translateY(0); }
.eyebrow { margin: 0 0 6px; color: #8c8274; font-family: var(--mono); font-size: .68rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; }
.brand-number { color: var(--amber); font-size: 2.35rem; font-weight: 950; letter-spacing: -.1em; line-height: .82; }
.brand > span:last-child { display: grid; line-height: 1; }
.brand strong { font-size: .92rem; letter-spacing: .1em; }
.brand small { margin-top: 4px; color: #8e877c; font-family: var(--mono); font-size: .52rem; letter-spacing: .1em; }

input, textarea, select {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 13px;
  outline: 0;
  background: #fff;
  color: var(--ink);
  padding: 11px 13px;
  transition: border-color .16s ease, box-shadow .16s ease, background .16s ease;
}
textarea { min-height: 112px; resize: vertical; line-height: 1.55; }
input:focus, textarea:focus, select:focus { border-color: var(--amber); box-shadow: 0 0 0 3px rgba(255, 176, 0, .15); }
.button {
  display: inline-flex;
  min-height: 46px;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: 13px;
  color: var(--ink);
  font-size: .78rem;
  font-weight: 850;
  text-decoration: none;
  transition: transform .15s ease, border-color .15s ease, background .15s ease;
}
.button:hover:not(:disabled) { transform: translateY(-1px); }
.button:active:not(:disabled) { transform: translateY(1px) scale(.99); }
.button-wide { width: 100%; }
.button-primary { background: var(--amber); color: var(--ink); }
.button-primary:hover:not(:disabled) { background: var(--amber-bright); }
.button-secondary { border-color: var(--line); background: rgba(255, 255, 255, .7); }
.button-secondary:hover:not(:disabled) { border-color: var(--line-strong); background: #fff; }
.button-danger { background: var(--red); color: #fff; }
.button-small { min-height: 40px; padding: 0 13px; font-size: .73rem; }
.text-button { border: 0; background: transparent; color: #918a7e; font-size: .72rem; font-weight: 800; }
.text-button:hover { color: var(--amber); }

/* 登录 */
.login-gate { position: relative; display: grid; min-height: 100svh; overflow: hidden; place-items: center; padding: 24px; background: #11100e; color: #fff; }
.login-gate::before {
  position: absolute;
  inset: 0;
  background: linear-gradient(rgba(255, 255, 255, .026) 1px, transparent 1px), linear-gradient(90deg, rgba(255, 255, 255, .026) 1px, transparent 1px);
  background-size: 44px 44px;
  content: "";
  mask-image: linear-gradient(to bottom, #000, transparent 92%);
}
.login-ambient { position: fixed; inset: 0; overflow: hidden; pointer-events: none; }
.login-ambient span {
  position: absolute;
  right: -.08em;
  bottom: -.22em;
  color: transparent;
  font-size: min(54vw, 700px);
  font-weight: 950;
  letter-spacing: -.13em;
  line-height: 1;
  -webkit-text-stroke: 1px rgba(255, 176, 0, .14);
}
.login-ambient i { position: absolute; width: 7px; height: 7px; border-radius: 50%; background: var(--amber); box-shadow: 0 0 40px 13px rgba(255, 176, 0, .3); }
.login-ambient i:nth-child(2) { top: 18%; left: 12%; }
.login-ambient i:nth-child(3) { top: 42%; right: 18%; width: 4px; height: 4px; opacity: .65; }
.login-ambient i:nth-child(4) { bottom: 17%; left: 28%; width: 5px; height: 5px; opacity: .45; }
.login-card {
  position: relative;
  z-index: 1;
  width: min(100%, 470px);
  padding: clamp(28px, 6vw, 50px);
  border: 1px solid rgba(255, 255, 255, .11);
  border-radius: 28px;
  background: rgba(28, 25, 21, .9);
  box-shadow: 0 40px 120px rgba(0, 0, 0, .38);
  backdrop-filter: blur(16px);
}
.login-card .brand { margin-bottom: 48px; }
.login-card h1 { margin: 0; font-size: clamp(3rem, 10vw, 5rem); font-weight: 950; letter-spacing: -.075em; line-height: .88; }
.login-intro { margin: 22px 0 28px; color: #aaa296; font-size: .86rem; line-height: 1.75; }
.login-form, .stack-form { display: grid; gap: 12px; }
.login-form label, .stack-form > label, .stack-form fieldset > legend { color: #8e867a; font-size: .73rem; font-weight: 800; }
.login-form input { border-color: rgba(255, 255, 255, .14); background: #0c0b0a; color: #fff; }
.login-form label { margin-top: 4px; }
.login-form .button { margin-top: 8px; }
.form-message { min-height: 20px; margin: 12px 0 0; color: #aaa296; font-size: .75rem; }
.form-message[data-tone="error"] { color: #ff817a; }
.back-link { display: inline-block; margin-top: 26px; color: #91897e; font-size: .72rem; text-decoration: none; }
.back-link:hover { color: var(--amber); }

/* 应用框架 */
.app-shell { min-height: 100vh; padding-bottom: 96px; }
.app-header {
  position: sticky;
  z-index: 40;
  top: 0;
  display: flex;
  min-height: 70px;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 10px max(22px, calc((100vw - 1360px) / 2));
  border-bottom: 1px solid rgba(255, 255, 255, .08);
  background: rgba(23, 20, 15, .96);
  color: #fff;
  backdrop-filter: blur(15px);
}
.header-primary { display: flex; min-width: 0; flex: 1; align-items: center; gap: clamp(22px, 4vw, 58px); }
.brand-compact { flex: 0 0 auto; }
.brand-compact .brand-number { font-size: 1.7rem; }
.brand-compact strong { font-size: .76rem; }
.brand-compact small { font-size: .46rem; }
.session-switcher { display: grid; width: min(100%, 560px); grid-template-columns: auto minmax(0, 1fr) 42px; align-items: center; gap: 9px; }
.session-switcher label { color: #948d82; font-size: .68rem; font-weight: 780; }
.session-switcher select { min-height: 42px; border-color: rgba(255, 255, 255, .11); background: #29251f; color: #fff; }
.icon-button { display: grid; width: 42px; height: 42px; place-content: center; border: 0; border-radius: 13px; background: var(--amber); color: var(--ink); font-size: 1.3rem; font-weight: 850; }
.header-meta { display: flex; flex: 0 0 auto; align-items: center; justify-content: flex-end; gap: 11px; }
.connection { display: inline-flex; align-items: center; gap: 6px; color: #aaa397; font-size: .68rem; }
.connection i { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 12px rgba(55, 164, 88, .6); }
.connection[data-connected="false"] i { background: var(--red); box-shadow: none; }
.operator-badge { max-width: 120px; overflow: hidden; padding: 7px 10px; border: 1px solid rgba(255, 255, 255, .1); border-radius: 999px; color: #d5cfc5; font-size: .68rem; font-weight: 750; text-overflow: ellipsis; white-space: nowrap; }

.app-main { width: min(1360px, calc(100% - 40px)); margin: 0 auto; }
.empty-state { display: grid; min-height: calc(100vh - 150px); max-width: 590px; margin: auto; place-content: center; justify-items: start; }
.empty-mark { display: grid; width: 72px; height: 72px; margin-bottom: 26px; place-content: center; border: 1px solid var(--line); border-radius: 22px; background: var(--paper); color: #b47700; font-size: 2.2rem; }
.empty-state h1 { margin: 0; font-size: clamp(2.5rem, 6vw, 5rem); letter-spacing: -.07em; line-height: .95; }
.empty-state p:not(.eyebrow) { max-width: 480px; margin: 19px 0 27px; color: var(--muted); line-height: 1.7; }
.workspace { padding: 28px 0 32px; }
.ledger-hero { display: flex; align-items: flex-end; justify-content: space-between; gap: 28px; margin-bottom: 20px; }
.ledger-heading { min-width: 0; }
.ledger-kicker { display: flex; align-items: center; gap: 10px; margin-bottom: 11px; }
.ledger-kicker code { color: #766e62; font-family: var(--mono); font-size: .7rem; letter-spacing: .08em; }
.sync-mobile { color: #9b9285; font-size: .68rem; }
.status-pill { display: inline-flex; min-height: 25px; align-items: center; padding: 0 10px; border-radius: 999px; background: rgba(55, 164, 88, .13); color: #267b3e; font-size: .68rem; font-weight: 850; }
.status-pill[data-status="closed"] { background: rgba(23, 20, 15, .08); color: #777065; }
.ledger-heading h1 { overflow: hidden; margin: 0; font-size: clamp(2rem, 4vw, 3.55rem); letter-spacing: -.06em; line-height: .96; text-overflow: ellipsis; }
.ledger-heading > p { margin: 10px 0 0; color: #82796d; font-size: .76rem; }
.ledger-actions { display: flex; flex: 0 0 auto; gap: 8px; }

.metrics { display: grid; grid-template-columns: 1.18fr repeat(3, 1fr); overflow: hidden; margin-bottom: 18px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); box-shadow: var(--shadow); }
.metric { display: grid; min-height: 116px; align-content: space-between; padding: 19px 21px; border-right: 1px solid var(--line); }
.metric:last-child { border-right: 0; }
.metric > span { color: #756e63; font-size: .72rem; font-weight: 800; }
.metric strong { display: flex; align-items: baseline; gap: 4px; font-size: clamp(1.65rem, 3vw, 2.75rem); letter-spacing: -.055em; line-height: 1; }
.metric strong small { font-size: .78rem; letter-spacing: 0; }
.metric em { overflow: hidden; color: #9c9488; font-size: .66rem; font-style: normal; text-overflow: ellipsis; white-space: nowrap; }
.metric-outstanding { background: var(--ink); color: #fff; }
.metric-outstanding > span, .metric-outstanding em { color: #aaa296; }
.metric-outstanding strong { color: var(--amber); }

.mobile-view-tabs { display: none; }
.working-grid { display: grid; grid-template-columns: minmax(330px, .78fr) minmax(560px, 1.4fr); gap: 18px; align-items: start; }
.panel { border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); box-shadow: var(--shadow); }
.participant-panel, .product-panel, .activity-panel { padding: 22px; }
.panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 17px; }
.panel-heading h2 { margin: 0; font-size: clamp(1.35rem, 2.3vw, 1.9rem); letter-spacing: -.045em; }
.panel-heading > p { max-width: 330px; margin: 3px 0 0; color: #8b8377; font-size: .71rem; line-height: 1.5; text-align: right; }
.tap-hint { align-self: center; color: #938a7d; font-size: .68rem; white-space: nowrap; }
.selection-tools { display: flex; gap: 7px; margin-bottom: 14px; }
.search-box { position: relative; display: block; min-width: 0; flex: 1; }
.search-box span { position: absolute; z-index: 1; top: 50%; left: 13px; color: #847b6e; font-size: 1rem; transform: translateY(-52%); pointer-events: none; }
.search-box input { min-height: 42px; padding: 8px 11px 8px 35px; border-radius: 12px; background: #f4f0e8; }
.chip-button { flex: 0 0 auto; min-height: 42px; padding: 0 11px; border: 1px solid var(--line); border-radius: 12px; background: transparent; color: #70685d; font-size: .69rem; font-weight: 800; }
.chip-button:hover:not(:disabled) { border-color: var(--amber); color: var(--ink); }

.participant-grid { display: grid; gap: 8px; max-height: 590px; overflow: auto; padding-right: 2px; scrollbar-width: thin; }
.participant-card { position: relative; display: grid; min-height: 70px; grid-template-columns: minmax(0, 1fr) 38px; overflow: hidden; border: 1px solid var(--line); border-radius: 15px; background: #f6f2ea; transition: border-color .15s ease, background .15s ease, transform .15s ease; }
.participant-card:hover { border-color: var(--line-strong); transform: translateY(-1px); }
.participant-card[data-selected="true"] { border-color: var(--ink); background: var(--amber-soft); box-shadow: inset 4px 0 0 var(--amber); }
.participant-card.is-settled:not([data-selected="true"]) { background: #fbfaf7; }
.participant-card-main { display: grid; min-width: 0; grid-template-columns: 40px minmax(0, 1fr) auto 21px; align-items: center; gap: 10px; padding: 10px 8px 10px 11px; border: 0; background: transparent; color: inherit; text-align: left; }
.participant-avatar { display: grid; width: 40px; height: 40px; place-content: center; border-radius: 12px; background: var(--ink); color: var(--amber); font-size: .9rem; font-weight: 900; }
.participant-card[data-selected="true"] .participant-avatar { background: var(--amber); color: var(--ink); }
.participant-card-copy, .participant-card-balance { display: grid; min-width: 0; }
.participant-card-copy strong { overflow: hidden; font-size: .82rem; text-overflow: ellipsis; white-space: nowrap; }
.participant-card-copy small, .participant-card-balance small { margin-top: 4px; color: #91897d; font-size: .62rem; }
.participant-card-balance { text-align: right; }
.participant-card-balance b { font-size: .86rem; letter-spacing: -.03em; }
.participant-card.is-settled .participant-card-balance b { color: #7f786d; }
.selection-check { display: grid; width: 20px; height: 20px; place-content: center; border: 1px solid #c7bfb3; border-radius: 50%; color: transparent; font-size: .65rem; font-style: normal; }
.participant-card[data-selected="true"] .selection-check { border-color: var(--ink); background: var(--ink); color: #fff; }
.participant-detail { display: grid; width: 38px; min-height: 100%; place-content: center; border: 0; border-left: 1px solid rgba(118, 108, 94, .12); background: transparent; color: #8b8377; font-size: .9rem; letter-spacing: .03em; }
.participant-detail:hover { background: rgba(255, 255, 255, .62); color: var(--ink); }
.mobile-done-button { display: none; }

.round-people { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 13px; margin-bottom: 15px; padding: 13px; border: 1px solid #e4c46e; border-radius: 16px; background: #fff7dc; }
.round-people-heading { display: grid; gap: 3px; }
.round-people-heading span { color: #7d725f; font-size: .65rem; }
.round-people-heading strong { font-size: .82rem; }
.selected-people-strip { display: flex; min-width: 0; gap: 6px; overflow-x: auto; padding: 2px 0; scrollbar-width: none; }
.selected-people-strip::-webkit-scrollbar { display: none; }
.selected-people-strip button { display: inline-flex; min-height: 32px; flex: 0 0 auto; align-items: center; gap: 6px; padding: 0 9px; border: 0; border-radius: 999px; background: var(--ink); color: #fff; font-size: .68rem; font-weight: 800; }
.selected-people-strip button i { color: var(--amber); font-size: .8rem; font-style: normal; }
.strip-empty { overflow: hidden; color: #8c806e; font-size: .69rem; text-overflow: ellipsis; white-space: nowrap; }
.round-people-button { min-height: 38px; padding: 0 13px; border: 1px solid var(--ink); border-radius: 11px; background: transparent; color: var(--ink); font-size: .7rem; font-weight: 850; }
.round-people-button:hover { background: var(--ink); color: #fff; }
.product-toolbar { display: flex; gap: 8px; margin-bottom: 11px; }
.catalog-button { display: none; width: 44px; min-height: 44px; flex: 0 0 auto; border: 1px solid var(--line); border-radius: 12px; background: #fff; color: var(--ink); }
.category-tabs { display: flex; gap: 7px; overflow-x: auto; margin: 0 0 14px; padding: 1px 0 3px; scrollbar-width: none; }
.category-tabs::-webkit-scrollbar { display: none; }
.category-tabs button { min-height: 38px; flex: 0 0 auto; padding: 0 14px; border: 1px solid var(--line); border-radius: 999px; background: transparent; color: #746c60; font-size: .7rem; font-weight: 820; }
.category-tabs button[aria-pressed="true"] { border-color: var(--ink); background: var(--ink); color: #fff; }

.product-grid { display: grid; min-height: 212px; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 9px; }
.product-card { position: relative; display: grid; min-width: 0; min-height: 108px; grid-template-columns: 40px minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; gap: 9px; padding: 12px; overflow: hidden; border: 1px solid var(--line); border-radius: 16px; background: #f6f2ea; color: var(--ink); text-align: left; transition: border-color .15s ease, background .15s ease, transform .15s ease, box-shadow .15s ease; }
.product-card:hover:not(:disabled) { border-color: var(--line-strong); transform: translateY(-1px); }
.product-card[aria-pressed="true"] { border-color: var(--ink); background: var(--amber); box-shadow: 0 8px 22px rgba(184, 118, 0, .18), inset 0 0 0 1px var(--ink); }
.product-glyph { display: grid; width: 40px; height: 40px; place-content: center; border-radius: 12px; background: var(--ink); color: var(--amber); font-size: .9rem; font-weight: 900; }
.product-card[aria-pressed="true"] .product-glyph { background: #fff; color: var(--ink); }
.product-copy { display: grid; min-width: 0; align-content: center; }
.product-copy strong { display: -webkit-box; overflow: hidden; font-size: .82rem; line-height: 1.25; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.product-copy small { margin-top: 4px; color: #8b8377; font-size: .61rem; }
.product-card[aria-pressed="true"] .product-copy small { color: rgba(23, 20, 15, .62); }
.product-price { display: flex; grid-column: 1 / -1; align-items: center; justify-content: space-between; gap: 8px; }
.product-price b { font-size: 1rem; letter-spacing: -.04em; }
.product-price i { display: grid; width: 26px; height: 26px; place-content: center; border-radius: 9px; background: #fff; color: var(--ink); font-size: .78rem; font-style: normal; font-weight: 950; }
.product-card:not([aria-pressed="true"]) .product-price i { border: 1px solid var(--line); background: transparent; color: #7a7266; }

.quick-actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 9px; margin-top: 15px; }
.quick-actions > button { display: grid; min-height: 66px; grid-template-columns: 32px minmax(0, 1fr); grid-template-rows: auto auto; align-content: center; gap: 2px 9px; padding: 10px 11px; border: 1px solid var(--line); border-radius: 15px; background: transparent; color: var(--ink); text-align: left; }
.quick-actions > button > span { display: grid; width: 32px; height: 32px; grid-row: 1 / 3; place-content: center; border-radius: 10px; background: #eee8dc; color: #665e53; font-size: 1rem; }
.quick-actions strong { font-size: .72rem; }
.quick-actions small { overflow: hidden; color: #91897d; font-size: .6rem; text-overflow: ellipsis; white-space: nowrap; }
.quick-actions > button:hover:not(:disabled) { border-color: var(--amber); background: #fffbf1; }
.quick-actions .quick-settle { border-color: var(--ink); background: var(--ink); color: #fff; }
.quick-actions .quick-settle > span { background: var(--amber); color: var(--ink); }
.quick-actions .quick-settle small { color: #a9a195; }

.activity-panel { margin-top: 18px; }
.activity-list { border-top: 1px solid var(--line); }
.activity-row { display: grid; min-height: 72px; grid-template-columns: 43px minmax(0, 1fr) auto auto; align-items: center; gap: 13px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.activity-icon { display: grid; width: 39px; height: 39px; place-content: center; border-radius: 12px; background: #ece6db; color: #6f675b; font-family: var(--mono); font-size: .66rem; font-weight: 900; }
.activity-row[data-type="settlement"] .activity-icon, .activity-row[data-type="aa_settlement"] .activity-icon { background: rgba(55, 164, 88, .15); color: #24793d; }
.activity-row.is-voided { opacity: .46; }
.activity-copy { min-width: 0; }
.activity-copy strong { display: block; overflow: hidden; font-size: .8rem; text-overflow: ellipsis; white-space: nowrap; }
.activity-copy small { display: block; margin-top: 5px; color: #8d8579; font-size: .64rem; line-height: 1.4; }
.activity-amount { text-align: right; }
.activity-amount strong { display: block; font-size: .9rem; }
.activity-amount small { display: block; margin-top: 4px; color: #91897d; font-size: .61rem; }
.void-button { min-height: 34px; padding: 0 11px; border: 1px solid var(--line); border-radius: 10px; background: transparent; color: #877f73; font-size: .64rem; font-weight: 800; }
.void-button:hover { border-color: var(--red); color: var(--red); }
.void-label { color: var(--red); font-size: .66rem; font-weight: 850; }
.panel-empty { display: grid; min-height: 130px; grid-column: 1 / -1; place-content: center; padding: 20px; color: #8f877b; text-align: center; }
.panel-empty strong { margin-bottom: 6px; color: #6f685d; font-size: .8rem; }
.panel-empty span { font-size: .68rem; line-height: 1.5; }

/* 固定确认区 */
.commit-bar { position: fixed; z-index: 35; right: 24px; bottom: 20px; left: 24px; display: flex; width: min(860px, calc(100% - 48px)); min-height: 76px; align-items: center; gap: 14px; margin: auto; padding: 11px 12px; border: 1px solid rgba(255, 255, 255, .12); border-radius: 22px; background: rgba(23, 20, 15, .96); color: #fff; box-shadow: 0 20px 70px rgba(0, 0, 0, .3); backdrop-filter: blur(15px); }
.commit-clear { display: grid; width: 38px; height: 38px; flex: 0 0 auto; place-content: center; border: 1px solid rgba(255, 255, 255, .13); border-radius: 11px; background: transparent; color: #aaa296; font-size: 1.1rem; }
.commit-copy { min-width: 0; flex: 1; }
.commit-copy span { display: block; overflow: hidden; margin-bottom: 5px; color: #aaa296; font-size: .66rem; text-overflow: ellipsis; white-space: nowrap; }
.commit-copy strong { display: block; overflow: hidden; font-size: .84rem; text-overflow: ellipsis; white-space: nowrap; }
.quantity-control { display: grid; grid-template-columns: 36px 34px 36px; align-items: center; overflow: hidden; border: 1px solid rgba(255, 255, 255, .15); border-radius: 12px; }
.quantity-control button { width: 36px; height: 42px; border: 0; background: transparent; color: #fff; font-size: 1rem; }
.quantity-control button:hover { background: rgba(255, 255, 255, .07); }
.quantity-control output { color: var(--amber); font-size: .82rem; font-weight: 900; text-align: center; }
.commit-bar .button { min-width: 205px; flex: 0 0 auto; }
.tool-footer { padding: 24px 20px 110px; color: #898175; font-size: .66rem; text-align: center; }
.tool-footer a { margin-left: 10px; text-decoration: none; }
.tool-footer a:hover { color: var(--ink); }

/* 弹窗与表单 */
.modal { width: min(92vw, 520px); max-height: min(88dvh, 900px); overflow: auto; padding: 28px; border: 1px solid rgba(255, 255, 255, .13); border-radius: 24px; background: var(--paper); color: var(--ink); box-shadow: 0 30px 120px rgba(0, 0, 0, .38); }
.modal::backdrop { background: rgba(10, 9, 8, .72); backdrop-filter: blur(5px); }
.modal-wide { width: min(94vw, 900px); }
.modal h2 { margin: 0 40px 8px 0; font-size: clamp(1.7rem, 4vw, 2.55rem); letter-spacing: -.055em; }
.modal > p:not(.eyebrow):not(.dialog-selection) { margin: 0 38px 22px 0; color: #7c7468; font-size: .76rem; line-height: 1.65; }
.modal-close { position: absolute; top: 18px; right: 18px; }
.modal-close button { display: grid; width: 36px; height: 36px; place-content: center; border: 1px solid var(--line); border-radius: 11px; background: transparent; color: #797165; font-size: 1.15rem; }
.stack-form { margin-top: 20px; }
.stack-form > label { display: grid; gap: 7px; }
.stack-form .button { margin-top: 6px; }
.dialog-selection { display: inline-flex; margin: 4px 0; padding: 7px 11px; border-radius: 999px; background: #eee8dd; color: #675f54; font-size: .69rem; font-weight: 800; }
.hidden-participants { display: flex; flex-wrap: wrap; gap: 7px; margin: 17px 0 4px; padding: 13px; border-radius: 13px; background: #f0ece3; }
.hidden-participants::before { width: 100%; color: #81796d; content: "已隐藏人员 · 点击恢复"; font-size: .65rem; font-weight: 800; }
.hidden-participants button { min-height: 34px; padding: 0 10px; border: 1px solid var(--line); border-radius: 999px; background: var(--paper); color: #655e54; font-size: .68rem; font-weight: 800; }
.calculation-note { margin: 0; padding: 11px 13px; border-radius: 11px; background: #f0ece3; color: #6f685d; font-size: .69rem; line-height: 1.55; }
.field-grid { display: grid; gap: 9px; }
.field-grid-three { grid-template-columns: 1fr .65fr .8fr; }
.field-grid label { display: grid; gap: 7px; color: #8e867a; font-size: .72rem; font-weight: 800; }
.product-manager-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(280px, .8fr); gap: 24px; margin-top: 23px; }
.manager-list { max-height: 470px; overflow: auto; border-top: 1px solid var(--line); }
.manager-product { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); }
.manager-product.is-inactive { opacity: .5; }
.manager-product strong, .manager-product small { display: block; }
.manager-product strong { font-size: .78rem; }
.manager-product small { margin-top: 4px; color: #8b8377; font-size: .64rem; }
.manager-actions { display: flex; gap: 5px; }
.manager-actions button { min-height: 32px; padding: 0 9px; border: 1px solid var(--line); border-radius: 10px; background: transparent; color: #70685d; font-size: .63rem; font-weight: 800; }
.manager-form { margin: 0; padding: 18px; border-radius: 16px; background: #f1ede4; }
.settle-summary { display: flex; align-items: baseline; justify-content: space-between; gap: 15px; margin: 18px 0 4px; padding: 15px; border-radius: 14px; background: var(--ink); color: #fff; }
.settle-summary span { color: #aaa397; font-size: .7rem; }
.settle-summary strong { color: var(--amber); font-size: 1.15rem; }
.segmented-field { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 0; padding: 0; border: 0; }
.segmented-field legend { grid-column: 1 / -1; margin-bottom: 7px; }
.segmented-field label { position: relative; }
.segmented-field input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.segmented-field span { display: grid; min-height: 76px; align-content: center; padding: 12px; border: 1px solid var(--line); border-radius: 13px; }
.segmented-field strong { font-size: .74rem; }
.segmented-field small { margin-top: 5px; color: #857d71; font-size: .62rem; line-height: 1.4; }
.segmented-field input:checked + span { border-color: var(--amber); background: var(--amber-soft); box-shadow: inset 0 0 0 1px var(--amber); }

.statement-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 20px; }
.statement-header h2 { margin: 0; }
.statement-balance { text-align: right; }
.statement-balance span { display: block; color: #81796d; font-size: .66rem; }
.statement-balance strong { color: var(--red); font-size: 1.7rem; letter-spacing: -.05em; }
.statement-metrics { display: grid; grid-template-columns: repeat(3, 1fr); overflow: hidden; margin-bottom: 18px; border: 1px solid var(--line); border-radius: 14px; }
.statement-metrics div { padding: 12px; border-right: 1px solid var(--line); }
.statement-metrics div:last-child { border-right: 0; }
.statement-metrics span, .statement-metrics strong { display: block; }
.statement-metrics span { color: #857d71; font-size: .63rem; }
.statement-metrics strong { margin-top: 4px; font-size: .86rem; }
.statement-controls { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 18px; }
.statement-list { border-top: 1px solid var(--line); }
.statement-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; padding: 13px 0; border-bottom: 1px solid var(--line); }
.statement-row.is-voided { opacity: .45; text-decoration: line-through; }
.statement-row strong, .statement-row small { display: block; }
.statement-row strong { font-size: .75rem; }
.statement-row small { margin-top: 5px; color: #837b6f; font-size: .63rem; line-height: 1.45; }
.statement-row > b { font-size: .82rem; }
.statement-row > b.credit { color: #298345; }
.toast { position: fixed; z-index: 200; left: 50%; bottom: 30px; max-width: calc(100% - 32px); padding: 12px 18px; border: 1px solid rgba(255, 176, 0, .4); border-radius: 999px; background: var(--ink); color: #fff; box-shadow: 0 18px 60px rgba(0, 0, 0, .28); font-size: .73rem; font-weight: 780; opacity: 0; pointer-events: none; transform: translate(-50%, 18px); transition: opacity .18s ease, transform .18s ease; }
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }
.toast[data-tone="error"] { border-color: rgba(232, 72, 63, .65); }

@media (max-width: 1100px) {
  .connection { display: none; }
  .working-grid { grid-template-columns: 1fr; }
  .participant-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); max-height: 380px; }
  .product-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (max-width: 820px) {
  .app-header { gap: 12px; padding: 10px 15px; }
  .header-primary { gap: 14px; }
  .session-switcher label { display: none; }
  .session-switcher { grid-template-columns: minmax(0, 1fr) 42px; }
  .operator-badge { display: none; }
  .app-main { width: min(100% - 24px, 1360px); }
  .ledger-heading h1 { font-size: 2.25rem; }
  .metrics { grid-template-columns: 1.15fr repeat(3, 1fr); }
  .metric { min-height: 106px; padding: 16px; }
  .metric strong { font-size: 1.65rem; }
  .product-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .product-manager-grid { grid-template-columns: 1fr; }
  .manager-list { max-height: 280px; }
}

/* 手机：一个屏幕只处理一件事 */
@media (max-width: 760px) {
  body { background: var(--canvas); }
  .app-shell { padding-bottom: 154px; }
  .app-header { position: sticky; display: grid; min-height: auto; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 6px 10px; padding: max(8px, env(safe-area-inset-top)) 12px 8px; }
  .header-primary { display: grid; min-width: 0; grid-column: 1 / -1; grid-template-columns: auto minmax(0, 1fr); gap: 12px; }
  .brand-compact > span:last-child { display: none; }
  .brand-compact .brand-number { font-size: 1.55rem; }
  .session-switcher { width: 100%; grid-template-columns: minmax(0, 1fr) 42px; gap: 7px; }
  .session-switcher select { min-height: 42px; padding-top: 8px; padding-bottom: 8px; font-size: .76rem; }
  .header-meta { grid-column: 1 / -1; min-height: 20px; justify-content: flex-end; }
  .header-meta .connection { display: inline-flex; margin-right: auto; }
  .header-meta .text-button { min-height: 28px; padding: 0 4px; }
  .app-main { width: 100%; }
  .workspace { padding: 15px 12px 24px; }
  .ledger-hero { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: start; gap: 12px; margin-bottom: 13px; }
  .ledger-kicker { gap: 7px; margin-bottom: 8px; }
  .status-pill { min-height: 23px; padding: 0 8px; font-size: .62rem; }
  .ledger-kicker code, .sync-mobile { font-size: .62rem; }
  .ledger-heading h1 { font-size: clamp(1.55rem, 7vw, 2rem); white-space: nowrap; }
  .ledger-heading > p { display: none; }
  .ledger-actions { display: flex; gap: 6px; }
  .ledger-actions .button { min-height: 38px; padding: 0 10px; border-radius: 11px; font-size: .68rem; }
  #manageProductsButton { display: none; }
  .metrics { display: flex; gap: 8px; overflow-x: auto; margin: 0 -12px 13px; padding: 0 12px 2px; border: 0; border-radius: 0; background: transparent; box-shadow: none; scroll-snap-type: x proximity; scrollbar-width: none; }
  .metrics::-webkit-scrollbar { display: none; }
  .metric { min-height: 91px; flex: 0 0 130px; padding: 13px 14px; border: 1px solid var(--line); border-radius: 17px; background: var(--paper); scroll-snap-align: start; }
  .metric-outstanding { flex-basis: 168px; border-color: var(--ink); background: var(--ink); }
  .metric > span { font-size: .66rem; }
  .metric strong { font-size: 1.42rem; }
  .metric em { font-size: .59rem; }
  .mobile-view-tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; margin-bottom: 10px; padding: 5px; scroll-margin-top: 94px; border: 1px solid var(--line); border-radius: 16px; background: rgba(255, 253, 248, .86); }
  .mobile-view-tabs button { display: flex; min-height: 44px; align-items: center; justify-content: center; gap: 6px; padding: 0 7px; border: 0; border-radius: 11px; background: transparent; color: #786f63; font-size: .72rem; font-weight: 850; }
  .mobile-view-tabs button span { color: #a49b8e; font-family: var(--mono); font-size: .55rem; }
  .mobile-view-tabs button[aria-pressed="true"] { background: var(--ink); color: #fff; box-shadow: 0 7px 18px rgba(23, 20, 15, .16); }
  .mobile-view-tabs button[aria-pressed="true"] span { color: var(--amber); }
  .working-grid { display: grid; grid-template-columns: 1fr; gap: 0; }
  .workspace[data-mobile-view="drink"] .participant-panel, .workspace[data-mobile-view="drink"] .activity-panel { display: none; }
  .workspace[data-mobile-view="people"] .product-panel, .workspace[data-mobile-view="people"] .activity-panel { display: none; }
  .workspace[data-mobile-view="activity"] .working-grid { display: none; }
  .workspace[data-mobile-view="activity"] .activity-panel { display: block; }
  .panel { border-radius: 19px; box-shadow: 0 10px 28px rgba(42, 32, 19, .055); }
  .participant-panel, .product-panel, .activity-panel { padding: 15px; }
  .panel-heading { align-items: center; gap: 10px; margin-bottom: 14px; }
  .panel-heading h2 { font-size: 1.32rem; }
  .panel-heading > p { display: none; }
  .tap-hint { max-width: 126px; font-size: .6rem; line-height: 1.35; text-align: right; white-space: normal; }
  .round-people { grid-template-columns: minmax(0, 1fr) auto; gap: 8px; margin-bottom: 12px; padding: 11px; border-radius: 14px; }
  .round-people-heading { display: flex; grid-column: 1 / -1; align-items: center; justify-content: space-between; }
  .round-people-heading span { font-size: .64rem; }
  .round-people-heading strong { font-size: .72rem; }
  .selected-people-strip { min-height: 34px; align-items: center; }
  .round-people-button { min-height: 40px; padding: 0 12px; }
  .strip-empty { font-size: .65rem; }
  .product-toolbar { margin-bottom: 9px; }
  .catalog-button { display: grid; place-content: center; }
  .product-search input { min-height: 44px; }
  .category-tabs { margin-bottom: 11px; }
  .category-tabs button { min-height: 40px; }
  .product-grid { min-height: 210px; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .product-card { min-height: 112px; padding: 11px; }
  .product-copy strong { font-size: .79rem; }
  .product-price b { font-size: .96rem; }
  .quick-actions { grid-template-columns: 1fr 1fr; gap: 8px; }
  .quick-actions > button { min-height: 62px; }
  .quick-actions .quick-settle { grid-column: 1 / -1; min-height: 58px; }
  .selection-tools { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; }
  .selection-tools .search-box { grid-column: 1 / -1; }
  .chip-button { min-width: 0; padding: 0 6px; }
  .participant-grid { grid-template-columns: 1fr; max-height: none; overflow: visible; padding: 0 0 72px; }
  .participant-card { min-height: 72px; }
  .participant-card-main { grid-template-columns: 42px minmax(0, 1fr) auto 21px; min-height: 70px; }
  .participant-avatar { width: 42px; height: 42px; }
  .mobile-done-button { position: sticky; z-index: 4; bottom: max(10px, env(safe-area-inset-bottom)); display: flex; width: 100%; min-height: 54px; align-items: center; justify-content: space-between; gap: 12px; margin-top: -56px; padding: 0 16px; border: 1px solid rgba(255, 255, 255, .12); border-radius: 15px; background: var(--ink); color: #fff; box-shadow: 0 12px 35px rgba(0, 0, 0, .24); font-size: .73rem; }
  .mobile-done-button span { color: #aaa296; }
  .mobile-done-button b { color: var(--amber); }
  .activity-panel { margin-top: 0; }
  .activity-row { grid-template-columns: 39px minmax(0, 1fr) auto; gap: 10px; }
  .activity-icon { width: 37px; height: 37px; }
  .activity-copy strong { white-space: normal; }
  .activity-copy small { font-size: .6rem; }
  .activity-row .void-button, .activity-row .void-label { grid-column: 2 / -1; justify-self: end; }
  .commit-bar { right: 9px; bottom: max(9px, env(safe-area-inset-bottom)); left: 9px; display: grid; width: auto; min-height: 112px; grid-template-columns: 36px minmax(0, 1fr) 108px; gap: 8px 9px; padding: 9px; border-radius: 19px; }
  .commit-clear { width: 36px; height: 42px; }
  .commit-copy span { margin-bottom: 4px; font-size: .61rem; }
  .commit-copy strong { font-size: .78rem; }
  .quantity-control { grid-template-columns: 35px 36px 35px; }
  .quantity-control button { width: 35px; height: 42px; }
  .commit-bar .button { width: 100%; min-width: 0; min-height: 48px; grid-column: 1 / -1; border-radius: 13px; }
  .commit-bar .button b { display: none; }
  .tool-footer { padding: 20px 18px 110px; font-size: .61rem; line-height: 1.6; }
  .empty-state { min-height: calc(100svh - 112px); padding: 28px 20px; }
  .empty-state h1 { font-size: 2.4rem; }
  .modal { inset: auto 0 0; width: 100%; max-width: none; max-height: 92dvh; margin: 0; padding: 24px 17px calc(20px + env(safe-area-inset-bottom)); border: 0; border-radius: 24px 24px 0 0; }
  .modal::backdrop { background: rgba(10, 9, 8, .65); }
  .modal h2 { font-size: 1.8rem; }
  .modal-close { top: 16px; right: 16px; }
  .product-manager-grid { gap: 16px; margin-top: 18px; }
  .manager-list { max-height: 240px; }
  .manager-form { padding: 14px; }
  .field-grid-three { grid-template-columns: 1fr 1fr; }
  .field-grid-three label:first-child { grid-column: 1 / -1; }
  .segmented-field { grid-template-columns: 1fr; }
  .statement-header { align-items: flex-start; }
  .statement-metrics { grid-template-columns: repeat(3, 1fr); }
  .statement-metrics div { padding: 10px 8px; }
  .toast { bottom: calc(132px + env(safe-area-inset-bottom)); text-align: center; }
}

@media (max-width: 380px) {
  .workspace { padding-right: 9px; padding-left: 9px; }
  .ledger-actions .button { padding: 0 8px; }
  .sync-mobile { display: none; }
  .product-card { grid-template-columns: 36px minmax(0, 1fr); }
  .product-glyph { width: 36px; height: 36px; }
  .participant-card-main { grid-template-columns: 40px minmax(0, 1fr) auto 20px; gap: 7px; }
  .participant-card-balance small { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
