:root {
  --bg: #0f1216; --panel: #181c22; --panel2: #1f242c; --line: #2b323c; --text: #e9ecf1; --mute: #98a2b3;
  --gold: #d4af37; --gold-ink: #17130a; --good: #3fb37f; --warn: #e0a341; --bad: #e5604f; --info: #5aa2e6;
  --r: 12px; --tap: 48px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
:root.light {
  --bg: #f3f1ea; --panel: #ffffff; --panel2: #f7f5ee; --line: #ddd8cc; --text: #1b1a17; --mute: #6b665c;
  --gold: #a8841f; --gold-ink: #ffffff; --good: #1f8a56; --warn: #b26a0b; --bad: #c0392b; --info: #2e6fb0;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 16px/1.4 var(--font); -webkit-text-size-adjust: 100%; }
body { overscroll-behavior-y: none; }
h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -0.01em; }
h1 { font-size: 26px; } h2 { font-size: 19px; } h3 { font-size: 17px; }
p { margin: 0 0 10px; }
a { color: var(--gold); text-decoration: none; }
.boot { display: grid; place-items: center; height: 100vh; color: var(--gold); font-size: 28px; font-weight: 700; letter-spacing: .08em; }
.mute { color: var(--mute); } .small { font-size: 13px; } .mono { font-family: ui-monospace, Menlo, Consolas, monospace; }
.r { text-align: right; } .good { color: var(--good); } .bad { color: var(--bad); } .warn { color: var(--warn); } .gold { color: var(--gold); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; } .grow { flex: 1 1 auto; min-width: 0; } .spacer { flex: 1; }
.stack { display: flex; flex-direction: column; gap: 14px; }

/* shell */
.shell { display: grid; grid-template-columns: 208px 1fr; height: 100vh; height: 100dvh; }
.side { background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; padding: 14px 10px calc(10px + env(safe-area-inset-bottom)); gap: 4px; overflow-y: auto; }
.brand { color: var(--gold); font-weight: 800; letter-spacing: .12em; font-size: 18px; padding: 6px 10px 14px; }
.brand .biz { color: var(--mute); font-weight: 500; letter-spacing: 0; font-size: 12px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav a { display: flex; align-items: center; gap: 10px; min-height: var(--tap); padding: 0 12px; border-radius: 10px; color: var(--text); font-weight: 550; }
.nav a .ico { width: 22px; text-align: center; font-size: 18px; }
.nav a.on { background: var(--gold); color: var(--gold-ink); }
.nav a .badge { margin-left: auto; background: var(--bad); color: #fff; border-radius: 99px; font-size: 12px; padding: 1px 7px; }
.nav a.on .badge { background: var(--gold-ink); color: var(--gold); }
.who { margin-top: auto; padding: 10px; font-size: 13px; color: var(--mute); border-top: 1px solid var(--line); }
.who b { color: var(--text); display: block; font-size: 14px; }
.main { display: flex; flex-direction: column; min-width: 0; height: 100vh; height: 100dvh; }
.spotbar { display: flex; gap: 18px; align-items: center; padding: calc(8px + env(safe-area-inset-top)) 18px 8px; border-bottom: 1px solid var(--line); background: var(--panel); font-size: 14px; overflow-x: auto; white-space: nowrap; }
.spotbar .m b { font-variant-numeric: tabular-nums; }
.spotbar .stale { color: var(--warn); }
.spotbar .m.up b { color: var(--good); } .spotbar .m.down b { color: var(--bad); } .spotbar .m b { transition: color .8s; }
.view { flex: 1; overflow-y: auto; padding: 18px; -webkit-overflow-scrolling: touch; }
.view > .stack { max-width: 1180px; margin: 0 auto; }
.head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

/* pieces */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; }
.card h2 { margin-bottom: 10px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); gap: 12px; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; cursor: pointer; }
.tile .n { font-size: 28px; font-weight: 700; font-variant-numeric: tabular-nums; }
.tile .l { color: var(--mute); font-size: 13px; }
.tile.alert .n { color: var(--warn); }
.btn { min-height: var(--tap); padding: 0 18px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel2); color: var(--text); font: inherit; font-weight: 600; cursor: pointer; touch-action: manipulation; }
.btn:disabled { opacity: .5; }
.btn.primary { background: var(--gold); border-color: var(--gold); color: var(--gold-ink); }
.btn.danger { background: transparent; border-color: var(--bad); color: var(--bad); }
.btn.ghost { background: transparent; }
.btn.big { min-height: 64px; font-size: 19px; padding: 0 26px; }
.btn.sm { min-height: 36px; padding: 0 12px; font-size: 14px; }
.btn.on { outline: 2px solid var(--gold); }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field .lbl { font-size: 13px; color: var(--mute); font-weight: 600; }
.field .hint { font-size: 12px; color: var(--mute); }
input, select, textarea { min-height: var(--tap); width: 100%; padding: 8px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--text); font: inherit; }
textarea { min-height: 72px; }
input:focus, select:focus, textarea:focus, .btn:focus-visible { outline: 2px solid var(--gold); outline-offset: 1px; }
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.grid .wide { grid-column: 1 / -1; }
.scanbox { font-size: 20px; min-height: 58px; border: 2px solid var(--gold); }
.pill { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 650; background: var(--panel2); color: var(--mute); white-space: nowrap; }
.pill.good { background: rgba(63,179,127,.16); color: var(--good); } .pill.warn { background: rgba(224,163,65,.16); color: var(--warn); }
.pill.bad { background: rgba(229,96,79,.16); color: var(--bad); } .pill.mute { opacity: .7; } .pill.gold { background: rgba(212,175,55,.18); color: var(--gold); }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r); background: var(--panel); }
.tbl { width: 100%; border-collapse: collapse; font-size: 15px; }
.tbl th { text-align: left; font-size: 12px; color: var(--mute); text-transform: uppercase; letter-spacing: .04em; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; position: sticky; top: 0; background: var(--panel); }
.tbl td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl th.r, .tbl td.r { text-align: right; font-variant-numeric: tabular-nums; }
.tbl tr.click { cursor: pointer; } .tbl tr.click:active { background: var(--panel2); }
.tbl tr.dim td { opacity: .55; }
.empty { padding: 26px; text-align: center; color: var(--mute); border: 1px dashed var(--line); border-radius: var(--r); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; font-size: 15px; } .kv dt { color: var(--mute); } .kv dd { margin: 0; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.tabs .btn { min-height: 40px; }

/* tags on screen */
.tag-preview { background: #cfd3d8; padding: 14px; border-radius: var(--r); display: inline-block; }
.tag-preview svg { display: block; width: 288px; height: 144px; box-shadow: 0 1px 4px rgba(0,0,0,.4); }
.tag-choices { display: flex; gap: 12px; flex-wrap: wrap; }
.tag-choice { cursor: pointer; border: 2px solid transparent; border-radius: 10px; padding: 6px; background: #cfd3d8; }
.tag-choice.on { border-color: var(--gold); }
.tag-choice svg { display: block; width: 192px; height: 96px; }
.tag-choice span { display: block; text-align: center; font-size: 12px; color: #222; font-weight: 650; padding-top: 4px; }

/* live show */
.block { background: var(--panel); border: 2px solid var(--gold); border-radius: 16px; padding: 22px; min-height: 190px; }
.block .lot { color: var(--gold); font-weight: 700; letter-spacing: .06em; text-transform: uppercase; font-size: 14px; }
.block .title { font-size: clamp(24px, 4vw, 40px); font-weight: 750; line-height: 1.12; margin: 6px 0; }
.block .meta { color: var(--mute); font-size: 17px; }
.block.idle { border-color: var(--line); display: grid; place-items: center; color: var(--mute); font-size: 20px; text-align: center; }
.block .nums { display: flex; gap: 26px; margin-top: 12px; flex-wrap: wrap; } .block .nums div b { display: block; font-size: 24px; font-variant-numeric: tabular-nums; }
.block .nums div span { color: var(--mute); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
.showgrid { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.outcomes { display: grid; grid-template-columns: 1.4fr 1fr 1fr 1fr; gap: 10px; margin-top: 12px; } .outcomes .btn { padding: 0 8px; }
.flash { animation: flash .6s ease-out; } @keyframes flash { from { background: rgba(212,175,55,.35); } to { background: var(--panel); } }

/* packing */
.buyer-list { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.buyer { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; cursor: pointer; }
.buyer .u { font-weight: 700; font-size: 17px; overflow-wrap: anywhere; } .buyer .p { color: var(--gold); font-weight: 700; }
.bar { height: 8px; background: var(--panel2); border-radius: 9px; overflow: hidden; margin-top: 8px; } .bar i { display: block; height: 100%; background: var(--good); }
.packrow { display: flex; gap: 12px; align-items: center; padding: 12px; border-bottom: 1px solid var(--line); }
.packrow:last-child { border-bottom: 0; }
.packrow .tick { width: 34px; height: 34px; border-radius: 50%; border: 2px solid var(--line); display: grid; place-items: center; font-weight: 800; flex: none; }
.packrow.done .tick { background: var(--good); border-color: var(--good); color: #06281a; } .packrow.done .t { color: var(--mute); text-decoration: line-through; }

/* sign in */
.signin { max-width: 380px; margin: 12vh auto 0; padding: 0 18px; }

/* pop-ups and messages */
.modal-back { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: grid; place-items: center; padding: 16px; z-index: 50; }
.modal { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 18px; width: min(560px, 100%); max-height: 92vh; display: flex; flex-direction: column; gap: 12px; }
.modal-body { overflow-y: auto; display: flex; flex-direction: column; gap: 12px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.modal-back.alarm { background: rgba(170, 28, 16, .93); }
.alarm-box { text-align: center; color: #fff; display: flex; flex-direction: column; gap: 18px; align-items: center; max-width: 720px; }
.alarm-title { font-size: clamp(40px, 9vw, 84px); font-weight: 850; letter-spacing: .02em; }
.alarm-text { font-size: clamp(18px, 3vw, 26px); }
.alarm-box .btn { background: #fff; color: #7a1208; border-color: #fff; }
#toasts { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(84px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 8px; z-index: 60; width: min(520px, 92vw); }
.toast { background: var(--panel2); border: 1px solid var(--line); border-left: 5px solid var(--good); padding: 12px 14px; border-radius: 10px; box-shadow: 0 6px 22px rgba(0,0,0,.45); }
.toast.bad { border-left-color: var(--bad); } .toast.warn { border-left-color: var(--warn); }

/* phone and narrow iPad: tabs along the bottom */
@media (max-width: 820px) {
  /* pinned to the visible screen so only .view scrolls (iOS otherwise lets the whole page
     scroll under the address bar and the bottom tabs drift away) */
  .shell { position: fixed; inset: 0; height: auto; overflow: hidden; grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr) auto; }
  .side { order: 2; flex-direction: row; padding: 4px 4px calc(4px + env(safe-area-inset-bottom)); border-right: 0; border-top: 1px solid var(--line); overflow-x: auto; gap: 2px; }
  .brand, .who { display: none; }
  .nav { display: flex; flex: 1; gap: 2px; }
  .nav a { flex: 1 0 62px; flex-direction: column; gap: 0; font-size: 11px; justify-content: center; padding: 4px 2px; min-height: 52px; position: relative; }
  .nav a .badge { position: absolute; top: 2px; right: 8px; margin: 0; }
  .main { height: 100%; min-height: 0; }
  .side { flex: none; }
  .view { padding: 12px; }
  .showgrid { grid-template-columns: 1fr; }
  .tbl { font-size: 14px; } .tbl td, .tbl th { padding: 9px 8px; } .tbl td.mono { white-space: nowrap; }
  .table-wrap .tbl { min-width: 520px; }
  h1 { font-size: 22px; }
}

/* printing: only the tags, one per 2x1 page */
#print-area { display: none; }
@media print {
  @page { size: 2in 1in; margin: 0; }
  html, body { background: #fff; height: auto; }
  body > *:not(#print-area) { display: none !important; }
  #print-area { display: block; }
  .tag-page { width: 2in; height: 1in; page-break-after: always; break-after: page; overflow: hidden; }
  .tag-page:last-child { page-break-after: auto; break-after: auto; }
  .tag-page svg { display: block; width: 2in; height: 1in; }
}

/* reports: month bars */
.bars { display: flex; align-items: flex-end; gap: 6px; height: 160px; padding: 6px 0 0; overflow-x: auto; }
.bar-col { flex: 1 1 0; min-width: 34px; display: flex; flex-direction: column; align-items: stretch; height: 100%; }
.bar-stack { flex: 1; position: relative; }
.bar { position: absolute; bottom: 0; left: 0; right: 0; border-radius: 4px 4px 0 0; }
.bar.sales { background: rgba(212,175,55,.35); }
.bar.profit { background: var(--good); width: 50%; left: 25%; }
.bar-l { color: var(--mute); font-size: 11px; text-align: center; padding-top: 4px; white-space: nowrap; }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 2px; vertical-align: middle; }
.swatch.sales { background: rgba(212,175,55,.5); } .swatch.profit { background: var(--good); }

.help { padding-left: 18px; display: flex; flex-direction: column; gap: 8px; line-height: 1.45; max-width: 70ch; }
.buyer-tag { cursor: pointer; border-bottom: 1px dotted var(--mute); }
.scanrow { flex-wrap: nowrap; } .scanrow .btn.cam { min-height: 58px; font-size: 22px; padding: 0 14px; }

/* Home: needs attention */
ul.attn { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
ul.attn li { cursor: pointer; padding: 6px 8px; border-radius: 8px; }
ul.attn li:hover, ul.attn li:focus { background: var(--line); outline: none; }
ul.attn li b { display: inline-block; min-width: 2.2em; text-align: right; color: var(--warn); }

/* item photos */
.photos { display: flex; flex-wrap: wrap; gap: 8px; }
.photos img { width: 110px; height: 110px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); cursor: zoom-in; background: var(--panel2); }

/* ---------- home dashboard ---------- */
.kpis { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 1100px) { .kpis { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 520px) { .kpis { grid-template-columns: repeat(2, 1fr); gap: 8px; } .tile.kpi .n { font-size: 22px; } }
.tile.kpi { display: flex; flex-direction: column; gap: 2px; }
.tile.kpi .n { font-size: 26px; line-height: 1.15; }
.tile.kpi .sub { font-size: 13px; }
.tile.kpi .spark { align-self: flex-end; margin-top: 4px; opacity: .9; }
.meter { height: 8px; background: var(--panel2); border-radius: 9px; overflow: hidden; margin-top: 8px; position: static; }
.meter i { display: block; height: 100%; background: var(--gold); border-radius: 9px; }
.dash { display: grid; grid-template-columns: minmax(0, 3fr) minmax(280px, 2fr); gap: 12px; align-items: start; margin-top: 12px; }
@media (max-width: 980px) { .dash { grid-template-columns: 1fr; } }
.spark .line { fill: none; stroke: var(--gold); stroke-width: 1.6; stroke-linejoin: round; stroke-linecap: round; }
.spark .area { fill: var(--gold); opacity: .12; stroke: none; }
.spark .dot { fill: var(--gold); }
ul.feed { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
ul.feed li { display: flex; gap: 10px; align-items: center; padding: 7px 8px; border-radius: 8px; cursor: pointer; border-top: 1px solid var(--line); }
ul.feed li:first-child { border-top: 0; }
ul.feed li:hover, ul.feed li:focus { background: var(--line); outline: none; }
ul.feed .ico { width: 22px; text-align: center; flex: none; opacity: .85; }
ul.feed .when { flex: none; min-width: 64px; text-align: right; }
ol.top { margin: 0; padding-left: 22px; display: flex; flex-direction: column; gap: 5px; }
ol.top li { display: flex; gap: 10px; align-items: baseline; }
ol.top li::marker { color: var(--mute); }
.spots { display: flex; flex-direction: column; gap: 6px; }
.spot-row { display: flex; gap: 12px; align-items: center; padding: 4px 0; border-top: 1px solid var(--line); }
.spot-row:first-child { border-top: 0; }
.card.insights { padding: 8px 12px; }
.hbars { display: flex; flex-direction: column; gap: 6px; }
.hbar { display: grid; grid-template-columns: minmax(90px, 150px) 1fr auto; gap: 10px; align-items: center; font-size: 13px; }
.hbar-l { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hbar-t { height: 10px; background: var(--panel2); border-radius: 6px; overflow: hidden; }
.hbar-t i { display: block; height: 100%; background: var(--gold); border-radius: 6px; }
.hbar-t i.good { background: var(--good); } .hbar-t i.bad { background: var(--bad); }
.hbar-v { color: var(--mute); white-space: nowrap; font-variant-numeric: tabular-nums; }
.heat { display: grid; grid-template-columns: auto repeat(7, 1fr); gap: 3px; font-size: 11px; }
.heat-h { color: var(--mute); padding: 2px 6px 2px 0; white-space: nowrap; align-self: center; text-align: center; }
.heat-c { height: 26px; border-radius: 4px; background: var(--panel2); display: flex; align-items: center; justify-content: center; color: var(--text); position: relative; overflow: hidden; }
.heat-c::before { content: ''; position: absolute; inset: 0; background: var(--gold); opacity: var(--a, 0); }
.heat-c span { position: relative; font-variant-numeric: tabular-nums; }
.heat-c.future { opacity: .35; }
.heat-c.hi span { color: var(--gold-ink); font-weight: 600; }
.note { white-space: pre-wrap; line-height: 1.45; }
@media (max-width: 520px) { .hbar { grid-template-columns: 80px 1fr; } .hbar-v { grid-column: 2; font-size: 11px; } .heat-c span { font-size: 9px; } }

.offline-strip { padding: 6px 18px; font-size: 13px; font-weight: 600; text-align: center; }
.offline-strip.bad { background: var(--bad); color: #fff; } .offline-strip.warn { background: var(--warn); color: var(--gold-ink); }
