/* BookEventOct2026Stock dashboard — tokens and layout from DESIGN.md.
   Source of truth for colours: DESIGN.md brand CI palette.
   Mobile target: 375px. No horizontal overflow at any width. */

:root {
  color-scheme: light;
  --ink: #24231e;
  --muted: #59584f;
  --line: #d4d1c7;
  --ground: #f4f3ef;
  --paper: #fff;
  --deep: #272721;
  --brand: #d4b104;
  --brand-tint: #f3eed0;
  --brand-ink: #655200;
  --teal: var(--brand-ink); /* legacy navigation token */
  --red: #a12b28;
  --redbg: #fff0ee;
  --amber: #873e22; /* warning is rust, never brand yellow */
  --amberbg: #fbece5;
  --green: #176345;
  --greenbg: #e6f5eb;
  --focus: #655200;
  font-family: system-ui, -apple-system, "Noto Sans Thai", sans-serif;
  font-size: 16px;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  line-height: 1.55;
  overflow-x: hidden;
}
button, input, select {
  font: inherit;
  transition: background-color 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
}
button, select { cursor: pointer; }
button:active { transform: scale(0.98); }
button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}
a { color: inherit; text-underline-offset: 3px; }
.skip {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--paper);
  padding: 10px 14px;
  z-index: 10;
}
.skip:focus { left: 8px; top: 8px; }
.shell { max-width: 1480px; margin: auto; padding: 0 26px 60px; }
.top { background: var(--deep); color: #fff; }
.top-inner {
  max-width: 1480px;
  margin: auto;
  padding: 14px 26px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
  flex-wrap: wrap;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.brand { display: flex; gap: 12px; align-items: center; }
.brand-logo {
  width: 38px;
  height: 38px;
  border-radius: 6px;
  object-fit: cover;
  display: block;
}
.mark {
  width: 34px; height: 34px; border: 2px solid #e1c955; border-radius: 4px;
  display: grid; place-items: center; font-weight: 900; color: #e1c955;
}
.brand strong { font-size: 1.05rem; }
.top small { color: #e6e2d5; }
.top .event { font-variant-numeric: tabular-nums; text-align: right; }
h1, h2, h3, p { margin-top: 0; }
.heading {
  padding: 28px 0 20px;
  display: flex; align-items: end; justify-content: space-between; gap: 20px;
}
h1 { font-size: clamp(1.65rem, 3vw, 2.55rem); letter-spacing: -.035em; line-height: 1.15; margin-bottom: 6px; }
h2 { font-size: 1.25rem; letter-spacing: -.02em; margin-bottom: 4px; }
.subtle { color: var(--muted); }
.heading p { margin: 0; }
.clock { font-variant-numeric: tabular-nums; font-size: 1.1rem; font-weight: 750; white-space: nowrap; }

/* ---- bands ---------------------------------------------------------- */
.live-band, .warn-band, .error-banner {
  border-radius: 6px;
  padding: 12px 16px;
  margin-bottom: 16px;
  display: grid;
  gap: 3px;
  font-size: .86rem;
  border: 1px solid;
}
.live-band { background: var(--deep); color: #f5f2e7; border-color: #555247; }
.live-band strong { color: #e1c955; letter-spacing: .01em; }
/* Successful sync retains a green semantic state distinct from brand/action. */
.live-band.synced { background: #e8f4ef; color: #17403a; border-color: #7fbfa9; }
.live-band.synced strong { color: #0f5c4c; }
/* Synced, but the last success is old or the latest attempt failed. */
.live-band.stale { background: var(--amberbg); color: var(--amber); border-color: #d7a489; }
.live-band.stale strong { color: var(--amber); }
.live-warn {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px dashed currentColor;
  font-weight: 700;
}

/* ---- live sync scope (baseline/sold/current provenance) --------------- */
.panel.scope {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px 16px;
  margin-bottom: 16px;
}
.panel.scope h2 { font-size: 1.05rem; }
.panel.scope p { margin: 4px 0 0; }
.unmatched { margin-top: 10px; }
.unmatched h3 { font-size: .95rem; margin: 0 0 6px; }
.unmatched ul {
  margin: 0;
  padding-left: 1.1rem;
  display: grid;
  gap: 2px;
  font-size: .84rem;
}
.unmatched code { font-size: .82rem; }

.warn-band { background: var(--amberbg); color: var(--amber); border-color: #d7a489; }
.error-banner { background: var(--redbg); color: var(--red); border-color: #d49490; }

/* ---- freshness ------------------------------------------------------ */
.freshness {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  grid-template-columns: minmax(220px, 1fr) repeat(2, minmax(150px, .72fr));
  align-items: center;
  margin-bottom: 16px;
  overflow: hidden;
}
.freshness > div { padding: 14px 18px; min-width: 0; }
.freshness > div + div { border-left: 1px solid var(--line); }
.label { display: block; color: var(--muted); font-size: .78rem; font-weight: 700; margin-bottom: 3px; }
.freshness strong { font-variant-numeric: tabular-nums; }
.state {
  background: var(--greenbg); color: var(--green);
  font-weight: 800; display: flex; align-items: center; gap: 10px;
}
.state .dot { width: 9px; height: 9px; border-radius: 50%; background: currentColor; flex: none; }
.state.warn { background: var(--amberbg); color: var(--amber); }
.state.bad { background: var(--redbg); color: var(--red); }
.state.idle { background: #efeee9; color: var(--muted); }
.mock-note { font-size: .77rem; color: var(--muted); margin: 0 0 16px; }

/* ---- KPIs ----------------------------------------------------------- */
.kpis {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  border: 1px solid var(--line);
  background: var(--paper);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 24px;
}
/* The caveat must span the whole grid, otherwise it lands inside one KPI cell. */
.kpi-caveat {
  grid-column: 1 / -1;
  margin: 0;
  padding: 10px 18px;
  border-top: 1px solid var(--line);
  background: var(--brand-tint);
  color: var(--muted);
  font-size: .78rem;
  line-height: 1.5;
}
.kpi { padding: 17px 18px; min-width: 0; }
.kpi + .kpi { border-left: 1px solid var(--line); }
.kpi strong {
  display: block; font-size: clamp(1.55rem, 2.2vw, 2.25rem);
  font-variant-numeric: tabular-nums; line-height: 1.1; letter-spacing: -.04em;
}
.kpi.alert strong { color: var(--amber); }
.kpi.danger strong { color: var(--red); }
.kpi .label { margin: 7px 0 0; }

/* ---- layout --------------------------------------------------------- */
.workgrid {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(310px, .9fr);
  gap: 18px;
  align-items: start;
}
.panel {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  min-width: 0;
}
.panel-head {
  display: flex; justify-content: space-between; align-items: start;
  gap: 14px; padding: 20px 20px 14px;
}
.panel-head p { margin: 0; font-size: .86rem; color: var(--muted); }
.text-link { color: var(--teal); font-weight: 750; font-size: .86rem; white-space: nowrap; }
.alerts { margin-bottom: 18px; }
.alert-list { padding: 0 20px 18px; display: grid; gap: 8px; }
.alert-row {
  background: #faf9f6; border: 1px solid var(--line); border-radius: 5px;
  padding: 11px 13px; display: grid;
  grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; align-items: center;
}
.alert-row[hidden], .alert-list [data-alert-empty][hidden] { display: none; }
.alert-row h3 { font-size: .94rem; margin: 0; overflow-wrap: anywhere; }
.alert-row p { font-size: .78rem; color: var(--muted); margin: 0; }
.alert-row .titleline { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 2px; }
.qty { font-weight: 850; font-size: 1.1rem; font-variant-numeric: tabular-nums; text-align: right; }
.action { color: var(--teal); font-size: .78rem; font-weight: 700; text-align: right; }

.badge {
  display: inline-block; font-size: .8125rem; font-weight: 800;
  border-radius: 4px; padding: 3px 8px; white-space: nowrap; line-height: 1.25;
}
.badge.critical, .badge.out, .badge.unknown { background: var(--redbg); color: var(--red); }
.badge.low { background: var(--amberbg); color: var(--amber); }
.badge.ok { background: var(--greenbg); color: var(--green); }

/* ---- remaining-number state tones (replace the status column/badges) ----
   Existing brand palette tokens; all pass WCAG AA on white/card backgrounds
   (--red 7.3:1, --amber 7.7:1, --green 7.2:1 against #fff). */
.rem-tone.out, .rem-tone.critical { color: var(--red); }
.rem-tone.low { color: var(--amber); }
.rem-tone.ok { color: var(--green); }
.rem-tone.unknown { color: var(--muted); }
/* Tiny colour legend in the toolbar. */
.stock-legend {
  display: flex; align-items: center; flex-wrap: wrap;
  gap: 4px 12px; font-size: .8125rem; color: var(--muted);
  align-self: center; white-space: nowrap;
}
.stock-legend .lg { display: inline-flex; align-items: center; gap: 5px; }
.lg-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.lg-dot.out { background: var(--red); }
.lg-dot.low { background: var(--amber); }
.lg-dot.ok { background: var(--green); }

.inventory { grid-column: 1; }
.tools { padding: 0 20px 16px; display: flex; gap: 8px; align-items: center; }
.toolbar-controls { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; }
.search-box { position: relative; flex: 1; min-width: 160px; }
.search-box input { width: 100%; }
.sort-box { display: flex; align-items: center; gap: 6px; }
.btn-add-product {
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid var(--brand);
  border-radius: 6px;
  background: var(--brand);
  color: var(--ink);
  font-weight: 750;
  font-size: .88rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  white-space: nowrap;
  cursor: pointer;
  box-sizing: border-box;
  transition: background-color 140ms ease, border-color 140ms ease, transform 100ms ease;
}
.btn-add-product:active { transform: scale(0.98); }
.btn-add-product:hover { background: #c2a100; }
.header-meta { display: flex; align-items: center; gap: 10px; margin-left: auto; }

.tag-new-product {
  display: inline-block;
  font-size: .75rem;
  font-weight: 700;
  line-height: 1.25;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--brand-tint);
  color: var(--brand-ink);
  border: 1px solid var(--brand);
  margin-left: 6px;
  vertical-align: middle;
}
.tools input, .tools select {
  border: 1px solid #9d9a8f; border-radius: 6px; background: #fff;
  color: var(--ink); height: 44px; min-height: 44px; padding: 0 12px; min-width: 0;
}
.tools input { flex: 1; }
.tools select { width: 180px; }
.table-scroll-hint { display: none; }
.table-wrap:focus-visible { outline: 3px solid var(--focus); outline-offset: -3px; }
.table-wrap { overflow-x: auto; max-width: 100%; overscroll-behavior-inline: contain; }
.inventory .table-wrap table { min-width: 760px; table-layout: fixed; }
.inventory .table-wrap th:first-child { width: 38%; }
.inventory .table-wrap th:nth-child(2),
.inventory .table-wrap th:nth-child(3),
.inventory .table-wrap th:nth-child(4) { width: 13%; }
.inventory .table-wrap th:nth-child(5) { width: 23%; }
.inventory .table-wrap th { position: sticky; top: 0; z-index: 2; }
.inventory .table-wrap td { height: 52px; }
.inventory .table-wrap td.title { max-width: none; }
.inventory .table-wrap td.num { white-space: nowrap; }
.inventory .table-wrap button { min-height: 44px; min-width: 44px; padding: 0 8px; border: 1px solid var(--line); border-radius: 5px; background: var(--paper); color: var(--ink); font-weight: 700; }
.inventory .table-wrap button:hover { background: var(--brand-tint); }
table { width: 100%; border-collapse: collapse; text-align: left; font-size: .87rem; }
th { font-size: .8125rem; color: var(--muted); font-weight: 800; background: #f5f4f0; }
th, td { padding: 11px 15px; border-top: 1px solid var(--line); }
th:first-child, td:first-child { padding-left: 20px; }
th:last-child, td:last-child { padding-right: 20px; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.title { font-weight: 750; max-width: 280px; overflow-wrap: anywhere; }
td.title small { display: block; color: var(--muted); font-weight: 500; margin-top: 2px; }
tbody tr { transition: background-color 140ms ease; }
tbody tr:hover { background: #f9f7ed; }
.empty { padding: 30px 20px; text-align: center; color: var(--muted); }
.empty.ok { color: var(--green); font-weight: 700; }
.mobile-items { display: none; }

.history { grid-column: 2; grid-row: 1 / span 2; }
.runs { padding: 0 20px 20px; }
.run {
  display: grid; grid-template-columns: 54px minmax(0, 1fr) auto;
  align-items: center; gap: 10px; padding: 12px 0;
  border-top: 1px solid var(--line); font-size: .84rem;
}
.run time { font-variant-numeric: tabular-nums; font-weight: 800; }
.run small { display: block; color: var(--muted); }
.run strong { font-variant-numeric: tabular-nums; }
.run.failed { color: var(--red); }
.history-foot { background: #f5f4f0; padding: 13px 20px; color: var(--muted); font-size: .79rem; }
.footer { margin-top: 24px; color: var(--muted); font-size: .78rem; }

/* ---- ≤980px: ledger and history stack ------------------------------- */
@media (max-width: 980px) {
  .workgrid { grid-template-columns: 1fr; }
  .inventory, .history { grid-column: 1; grid-row: auto; }
  .history { order: 3; }
  .kpis { grid-template-columns: repeat(3, 1fr); }
  .kpi:nth-child(4) { border-left: 0; border-top: 1px solid var(--line); }
  .kpi:nth-child(5) { border-top: 1px solid var(--line); }
}

/* ---- ≤600px: 375px booth phone -------------------------------------- */
@media (max-width: 600px) {
  .shell { padding: 0 16px 36px; }
  .top-inner { padding: 12px 16px; }
  .top .event { font-size: .8125rem; }
  .brand strong { font-size: .91rem; }
  .heading { padding: 24px 0 16px; align-items: start; display: block; }
  .heading .clock { font-size: .84rem; margin-top: 10px; }
  .freshness { grid-template-columns: 1fr 1fr; }
  .freshness .state { grid-column: 1 / -1; }
  .freshness > div { padding: 12px; }
  .freshness > div + div { border-left: 0; border-top: 1px solid var(--line); }
  .freshness > div:nth-child(3) { border-left: 1px solid var(--line); }
  .freshness strong { font-size: .86rem; overflow-wrap: anywhere; }
  .kpis { grid-template-columns: repeat(2, 1fr); margin-bottom: 16px; }
  .kpi { padding: 12px; }
  .kpi:nth-child(odd) { border-left: 0; }
  .kpi:nth-child(n + 3) { border-top: 1px solid var(--line); }
  .kpi strong { font-size: 1.55rem; }
  .kpi .label { font-size: .8125rem; }
  .workgrid { gap: 14px; }
  .panel-head { padding: 16px 14px 12px; }
  .panel-head p { font-size: .78rem; }
  .alert-list { padding: 0 14px 14px; }
  .alert-row { padding: 10px; }
  .tools { padding: 0 14px 12px; display: grid; grid-template-columns: 1fr; gap: 8px; }
  .toolbar-controls { display: grid; grid-template-columns: 1fr; gap: 8px; width: 100%; }
  .toolbar-controls .search-box, .toolbar-controls .sort-box { width: 100%; }
  .toolbar-controls select { width: 100%; }
  .toolbar-controls .btn-add-product { width: 100%; min-height: 44px; }
  /* Mobile: Card-Table hybrid view for clean legibility without horizontal scrolling */
  .table-scroll-hint { display: none; }
  .inventory .table-wrap { display: none; }
  .mobile-items { display: flex; flex-direction: column; gap: 8px; padding: 0 14px 14px; }
  .stock-card {
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--paper);
    content-visibility: auto;
    contain-intrinsic-size: auto 110px;
  }
  .stock-card.is-hidden-row { opacity: 0.6; }
  .stock-card-row1 {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
  }
  .stock-card-titleline { min-width: 0; flex: 1; }
  .stock-card-titleline strong {
    display: block;
    font-size: 0.94rem;
    font-weight: 800;
    line-height: 1.35;
    color: var(--ink);
    overflow-wrap: anywhere;
  }
  .stock-card-titleline .barcode {
    display: block;
    font-size: 0.77rem;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
    margin-top: 2px;
  }
  .stock-card-ctrls {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
  }
  .stock-card-ctrls button {
    min-height: 44px;
    min-width: 44px;
    padding: 0 8px;
    border: 1px solid var(--line);
    border-radius: 4px;
    background: var(--paper);
    font-weight: 700;
    font-size: 0.82rem;
    color: var(--ink);
  }
  .stock-card-row2 {
    display: grid;
    grid-template-columns: 1fr 1fr 1.2fr;
    gap: 6px;
    background: #f7f6f2;
    border: 1px solid var(--line);
    border-radius: 5px;
    padding: 8px 10px;
  }
  .card-fig {
    display: flex;
    flex-direction: column;
    justify-content: center;
  }
  .card-fig + .card-fig {
    border-left: 1px solid var(--line);
    padding-left: 8px;
  }
  .card-fig .fig-lbl {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--muted);
    margin-bottom: 2px;
  }
  .card-fig .fig-val {
    font-size: 1.02rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    color: var(--ink);
  }
  .card-fig.fig-highlight .fig-val {
    font-size: 1.18rem;
    font-weight: 900;
    color: var(--brand-ink);
  }
  .card-fig.fig-highlight .fig-val small {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--muted);
  }
  /* State tones beat the highlight colour on the remaining figure. */
  .card-fig .fig-val.rem-tone.out, .card-fig .fig-val.rem-tone.critical { color: var(--red); }
  .card-fig .fig-val.rem-tone.low { color: var(--amber); }
  .card-fig .fig-val.rem-tone.ok { color: var(--green); }
  .card-fig .fig-val.rem-tone.unknown { color: var(--muted); }
  .runs { padding: 0 14px 14px; }
  .history-foot { padding: 12px 14px; }
  .run { grid-template-columns: 48px minmax(0, 1fr) auto; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  button:active, .btn-add-product:active { transform: none; }
  .modal-backdrop { animation: none; }
  .modal { animation: modal-fade 100ms ease; }
}
@keyframes modal-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ---- credential prompt (shown while the auth gate is closed) ----------- */
.unlock-page {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 24px;
}
.unlock {
  background: var(--paper); border: 1px solid var(--line);
  border-radius: 8px; padding: 28px; max-width: 420px; width: 100%;
}
.unlock h1 { font-size: 1.25rem; margin: 0 0 6px; }
.unlock p { margin: 0 0 18px; }
.unlock form { display: flex; flex-direction: column; gap: 14px; }
.unlock button {
  min-height: 44px; border: 1px solid transparent; border-radius: 6px;
  background: var(--brand); color: var(--ink); font-weight: 750;
}
#u-status { font-size: .85rem; color: var(--red); font-weight: 700; }

/* ---- add / adjust stock form -------------------------------------------
   Touch-sized controls (min 44px) because this is the one panel that gets
   used on a phone, standing at a booth, one-handed. */
.adjust { margin-bottom: 16px; }
.adjust .panel-head p { margin: 4px 0 0; }
.adjust form { padding: 4px 20px 20px; }
.fields {
  display: grid; gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
}
.field { display: block; min-width: 0; }
.field > span {
  display: block; margin-bottom: 4px;
  font-size: .78rem; font-weight: 700; color: var(--muted);
}
.field input, .field select {
  width: 100%; height: 44px; padding: 0 12px;
  border: 1px solid #9d9a8f; border-radius: 5px;
  background: #fff; color: var(--ink);
}
.field input[type="number"] { font-variant-numeric: tabular-nums; }
.overrides {
  margin: 14px 0 0; padding: 12px 14px; border: 1px dashed var(--line);
  border-radius: 6px; display: flex; flex-wrap: wrap; gap: 10px 18px;
}
.overrides legend {
  padding: 0 6px; font-size: .74rem; font-weight: 800; color: var(--muted);
}
.check {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: .85rem; min-height: 44px;
}
.check input { width: 20px; height: 20px; }
.title-field { margin-top: 12px; }
.actions {
  display: flex; align-items: center; gap: 12px;
  flex-wrap: wrap; margin-top: 16px;
}
.actions button {
  min-height: 44px; padding: 0 22px;
  border: 1px solid transparent; border-radius: 6px;
  background: var(--brand); color: var(--ink); font-weight: 750; font-size: .92rem;
}
.actions button:disabled { background: #d5d3ca; color: #494840; cursor: progress; }
#f-status { font-size: .85rem; color: var(--muted); }
#f-status.bad { color: var(--red); font-weight: 700; }
@media (max-width: 560px) {
  .adjust form { padding: 4px 14px 16px; }
  .fields { grid-template-columns: 1fr; }
  .actions button { width: 100%; }
}

/* ---- access-log panel: card fallback for the <=600px table hiding ------ */
.audit-mobile { display: none; }
@media (max-width: 600px) {
  .audit-mobile { display: block; padding: 0 14px 14px; }
  .audit-card { border-top: 1px solid var(--line); padding: 11px 0; }
  .audit-card:first-child { border-top: 0; }
  .audit-card-top {
    display: flex; justify-content: space-between;
    align-items: start; gap: 8px;
  }
  .audit-card-top strong { font-size: .91rem; overflow-wrap: anywhere; }
  .audit-card small { display: block; color: var(--muted); margin-top: 3px; }
  .audit-card-detail {
    margin-top: 6px; font-size: .85rem;
    font-variant-numeric: tabular-nums;
  }
}

/* ---- edit-stock modal ---- */
.btn-edit-stock { background: var(--brand-tint) !important; border-color: var(--brand) !important; }
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(36,35,30,.55);
  display: flex; align-items: center; justify-content: center; padding: 12px; z-index: 100;
  animation: backdrop-fade 180ms cubic-bezier(0.16, 1, 0.3, 1);
}
.modal-backdrop[hidden] { display: none; }
.modal {
  background: var(--paper); border-radius: 10px; width: 100%; max-width: 420px;
  max-height: 92vh; overflow-y: auto; padding: 16px; display: grid; gap: 12px;
  animation: modal-enter 220ms cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes backdrop-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes modal-enter {
  from { opacity: 0; transform: translateY(8px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.modal-head { display: flex; justify-content: space-between; align-items: center; }
.modal-head h2 { margin: 0; font-size: 1.15rem; }
.modal .modal-close { min-height: 44px; min-width: 44px; border: 1px solid var(--line); border-radius: 6px; background: var(--paper); font-size: 1.5rem; line-height: 1; }
.modal-product { margin: 0; display: grid; gap: 2px; }
.modal-product small { color: var(--muted); }
.modal-figs { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.modal-figs div { background: var(--ground); border-radius: 6px; padding: 8px 10px; display: grid; }
.modal-figs span { font-size: .78rem; color: var(--muted); }
.modal-figs strong { font-size: 1.25rem; font-variant-numeric: tabular-nums; }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.modal .seg-btn, .modal .modal-actions button { min-height: 44px; border: 1px solid var(--line); border-radius: 6px; background: var(--paper); font-weight: 700; color: var(--ink); }
.modal .seg-btn.on { background: var(--brand-tint); border-color: var(--brand); box-shadow: inset 0 0 0 1px var(--brand); }
.modal .field input, .modal .field select { min-height: 44px; width: 100%; }
.modal-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.modal .modal-actions .primary { background: var(--deep); color: #fff; border-color: var(--deep); }
.modal .modal-actions button:disabled { opacity: .6; cursor: progress; }
#sm-status.bad { color: var(--red); }

.top-inner{flex-wrap:nowrap}
.brand{min-width:0}
.subbar{background:rgba(0,0,0,.18);color:#e8e6da}
.subbar-inner{max-width:1480px;margin:auto;padding:6px 26px;font-size:13px;line-height:1.4}
@media (max-width:640px){.subbar-inner{padding:6px 16px}}
