/* Layout: dark workshop rail on the left, light work surface on the right; collapses to a top bar + drawer on phones. */
:root {
  --bg: #eff1f3;
  --surface: #ffffff;
  --surface-2: #f6f7f8;
  --ink: #171a1e;
  --muted: #5a6370;
  --line: #d8dce1;
  --accent: #a3600f;          /* brass terminal */
  --accent-soft: #f6ead9;
  --accent-ink: #ffffff;
  --rail: #1b2026;
  --rail-ink: #c9d0d8;
  --rail-active: #2a313a;
  --ok: #1d7a4b;  --ok-soft: #e1f2e8;
  --warn: #8a5d00; --warn-soft: #fbf0d4;
  --bad: #b42318;  --bad-soft: #fde4e1;
  --info: #285e9c; --info-soft: #e2ecf8;
  --font-display: "Barlow Semi Condensed", "Arial Narrow", system-ui, sans-serif;
  --font-body: "Source Sans 3", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  --r: 6px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111417; --surface: #181c21; --surface-2: #1e2329; --ink: #e6e9ed; --muted: #9aa3ae; --line: #2b323a;
    --accent: #e2a04c; --accent-soft: #3a2a14; --accent-ink: #1b1206;
    --rail: #0b0d10; --rail-ink: #b8c0ca; --rail-active: #1d232a;
    --ok: #52c58f; --ok-soft: #12301f; --warn: #e6b54a; --warn-soft: #34290f; --bad: #f2786c; --bad-soft: #3a1714; --info: #79a9e6; --info-soft: #14243a;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #111417; --surface: #181c21; --surface-2: #1e2329; --ink: #e6e9ed; --muted: #9aa3ae; --line: #2b323a;
  --accent: #e2a04c; --accent-soft: #3a2a14; --accent-ink: #1b1206;
  --rail: #0b0d10; --rail-ink: #b8c0ca; --rail-active: #1d232a;
  --ok: #52c58f; --ok-soft: #12301f; --warn: #e6b54a; --warn-soft: #34290f; --bad: #f2786c; --bad-soft: #3a1714; --info: #79a9e6; --info-soft: #14243a;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font-body); font-size: 15px; line-height: 1.45; }
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 50; background: var(--rail); }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.boot { padding: 40px max(16px, env(safe-area-inset-right, 0px)) 40px max(16px, env(safe-area-inset-left, 0px)); color: var(--muted); }

/* Shell */
.shell { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100%; }
.rail { background: var(--rail); color: var(--rail-ink); padding-block: 18px; position: sticky; top: env(safe-area-inset-top, 0px); height: calc(100vh - env(safe-area-inset-top, 0px)); overflow-y: auto; display: flex; flex-direction: column; gap: 14px; padding-left: max(14px, env(safe-area-inset-left, 0px)); padding-right: 14px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 6px; }
.brand-mark { width: 30px; height: 22px; border: 2px solid var(--accent); border-radius: 4px; position: relative; flex: none; }
.brand-mark::before, .brand-mark::after { content: ""; position: absolute; top: -6px; width: 6px; height: 4px; background: var(--accent); border-radius: 1px 1px 0 0; }
.brand-mark::before { left: 4px; } .brand-mark::after { right: 4px; }
.brand-name { font-family: var(--font-display); font-weight: 700; font-size: 19px; letter-spacing: .02em; color: #fff; line-height: 1.05; }
.brand-name small { display: block; font-weight: 500; font-size: 12px; letter-spacing: .14em; text-transform: uppercase; color: var(--rail-ink); opacity: .75; }
.nav-group { display: flex; flex-direction: column; gap: 1px; }
.nav-label { font-family: var(--font-display); font-size: 11.5px; letter-spacing: .16em; text-transform: uppercase; opacity: .55; padding: 6px 8px 4px; }
.nav a { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 7px 10px; border-radius: var(--r); color: var(--rail-ink); text-decoration: none; font-weight: 500; }
.nav a:hover { background: var(--rail-active); color: #fff; }
.nav a.on { background: var(--rail-active); color: #fff; box-shadow: inset 3px 0 0 var(--accent); }
.nav .count { font-family: var(--font-mono); font-size: 11.5px; background: var(--accent); color: var(--accent-ink); border-radius: 10px; padding: 0 7px; }
.rail-foot { margin-top: auto; font-size: 12.5px; opacity: .7; padding: 0 8px; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20; background: var(--bg); border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 12px; padding-block: 10px; padding-left: 24px; padding-right: max(24px, env(safe-area-inset-right, 0px)); }
.topbar h1 { font-family: var(--font-display); font-weight: 700; font-size: 24px; margin: 0; letter-spacing: .01em; text-wrap: balance; }
.topbar .spacer { flex: 1; }
.topbar .menu-btn { display: none; }
.store-switch { display: inline-flex; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; background: var(--surface); }
.store-switch button { border: 0; background: none; padding: 6px 12px; cursor: pointer; font-weight: 600; color: var(--muted); }
.store-switch button.on { background: var(--ink); color: var(--bg); }
.who { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13.5px; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-family: var(--font-display); font-weight: 700; display: grid; place-items: center; font-size: 13px; }
.content { padding-block: 22px 60px; padding-left: 24px; padding-right: max(24px, env(safe-area-inset-right, 0px)); display: flex; flex-direction: column; gap: 20px; max-width: 1280px; width: 100%; }
.demo-band { background: var(--warn-soft); color: var(--warn); border: 1px solid color-mix(in srgb, var(--warn) 30%, transparent); border-radius: var(--r); padding: 8px 12px; font-size: 13.5px; }

/* Blocks */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.panel-head h2 { font-family: var(--font-display); font-weight: 600; font-size: 18px; margin: 0; letter-spacing: .01em; }
.panel-body { padding: 16px; }
.panel-body.flush { padding: 0; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono, .part { font-family: var(--font-mono); font-size: 13px; }
.part { font-weight: 500; letter-spacing: -.01em; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.empty { padding: 28px 16px; text-align: center; color: var(--muted); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 10px; }

/* Stat tiles */
.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; text-decoration: none; color: inherit; display: flex; flex-direction: column; gap: 2px; }
a.tile:hover { border-color: var(--accent); }
.tile .label { font-family: var(--font-display); font-size: 12.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.tile .value { font-family: var(--font-display); font-weight: 700; font-size: 30px; font-variant-numeric: tabular-nums; line-height: 1.1; }
.tile .sub { font-size: 12.5px; color: var(--muted); }
.tile.alert .value { color: var(--bad); }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-family: var(--font-display); font-weight: 600; font-size: 12.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--line); background: var(--surface-2); white-space: nowrap; position: sticky; top: 0; }
td { padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--surface-2); }
tr.sel td { background: var(--accent-soft); }
tr.day td { background: var(--surface-2); font-family: var(--font-display); font-weight: 600; letter-spacing: .04em; color: var(--muted); padding-block: 5px; }
td.notes { color: var(--muted); max-width: 380px; }

/* Pills */
.pill { display: inline-block; font-size: 12px; font-weight: 600; padding: 1px 8px; border-radius: 10px; white-space: nowrap; background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }
.pill.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.pill.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.pill.bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.pill.info { background: var(--info-soft); color: var(--info); border-color: transparent; }
.pill.accent { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.initials { font-family: var(--font-mono); font-size: 12px; color: var(--muted); }

/* Forms */
form.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px 12px; align-items: end; }
form.grid .wide { grid-column: span 2; }
form.grid .full { grid-column: 1 / -1; }
label.f { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; font-weight: 600; color: var(--muted); min-width: 0; }
input, select, textarea { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 7px 9px; min-width: 0; width: 100%; }
textarea { resize: vertical; min-height: 60px; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
input.search { max-width: 360px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line); background: var(--surface); padding: 7px 13px; border-radius: var(--r); cursor: pointer; font-weight: 600; white-space: nowrap; text-decoration: none; color: var(--ink); }
.btn:hover { border-color: var(--ink); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.sm { padding: 3px 9px; font-size: 13px; }
.btn.ghost { background: none; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--ink); border-color: var(--line); }
.btn.danger { color: var(--bad); }
.btn:disabled { opacity: .5; cursor: default; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; background: var(--surface); flex-wrap: wrap; }
.seg button { border: 0; background: none; padding: 5px 11px; cursor: pointer; font-weight: 600; color: var(--muted); font-size: 13.5px; }
.seg button.on { background: var(--accent-soft); color: var(--accent); }
.hint { font-size: 13px; color: var(--muted); }
.price-hint { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; background: var(--accent-soft); border-radius: var(--r); padding: 8px 12px; font-size: 14px; }
.price-hint strong { font-variant-numeric: tabular-nums; }

/* Product detail */
.split { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(300px, 1fr); gap: 20px; align-items: start; }
.detail { position: sticky; top: 72px; }
.kv { display: grid; grid-template-columns: auto 1fr auto; gap: 6px 14px; align-items: baseline; }
.kv .k { color: var(--muted); font-size: 13.5px; }
.xref-list { display: flex; flex-direction: column; gap: 8px; }
.xref-item { border: 1px solid var(--line); border-radius: var(--r); padding: 8px 10px; display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 13px; }
.xref-item b { font-weight: 600; color: var(--muted); font-size: 12px; margin-right: 4px; }
mark { background: var(--accent-soft); color: var(--accent); border-radius: 2px; padding: 0 1px; }

/* Cash count */
.cash { display: grid; grid-template-columns: minmax(0, 1fr) minmax(260px, 340px); gap: 20px; align-items: start; }
.cash table input { width: 80px; text-align: right; padding: 4px 6px; }
.recon { display: grid; grid-template-columns: 1fr auto; gap: 8px 12px; font-size: 15px; }
.recon .total { font-family: var(--font-display); font-size: 22px; font-weight: 700; }
.bulletin-item { display: flex; gap: 10px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid var(--line); }
.bulletin-item:last-child { border-bottom: 0; }
.bulletin-item p { margin: 0; flex: 1; text-wrap: pretty; }

.toast { position: fixed; right: max(20px, env(safe-area-inset-right, 0px)); bottom: calc(20px + env(safe-area-inset-bottom, 0px)); background: var(--ink); color: var(--bg); padding: 10px 14px; border-radius: var(--r); font-weight: 600; z-index: 100; box-shadow: 0 6px 20px rgb(0 0 0 / .25); }
.confirm { display: inline-flex; gap: 6px; align-items: center; }

/* Sign in */
.login { min-height: 100%; display: grid; place-items: center; padding-block: 40px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.login .panel { width: 100%; max-width: 380px; }

/* Bar chart */
.bars { display: flex; align-items: flex-end; gap: 6px; height: 120px; padding-top: 8px; }
.bars .b { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 0; height: 100%; justify-content: flex-end; }
.bars .b i { display: block; width: 100%; max-width: 38px; background: var(--accent); border-radius: 3px 3px 0 0; }
.bars .b span { font-size: 11px; color: var(--muted); white-space: nowrap; }

@media (max-width: 1000px) {
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .split, .cash, .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); }
  .detail { position: static; }
}
@media (max-width: 760px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .rail { position: fixed; inset: 0 auto 0 0; width: 260px; height: 100%; z-index: 40; transform: translateX(-100%); transition: transform .2s; padding-top: calc(18px + env(safe-area-inset-top, 0px)); }
  .shell.open .rail { transform: none; box-shadow: 0 0 0 100vmax rgb(0 0 0 / .35); }
  .topbar .menu-btn { display: inline-flex; }
  .topbar { padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); flex-wrap: wrap; }
  .topbar h1 { font-size: 20px; }
  .who .name { display: none; }
  .content { padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
  form.grid .wide { grid-column: 1 / -1; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
