/*
  Despatch: back office for Fenna Stoneware (Screenery template)
  1. Tokens first: white paper, black ink, one grey hairline, one cobalt that only ever marks an action or a choice.
  2. Shell: sidebar + main on desktop, a bottom bar on phones. Every panel is cut from a 1px hairline grid
     (grid gap over a rule-coloured ground), flush left, ragged right, numbers in Ubuntu Sans Mono.
  3. Then the views (status strip, tables, chart, totals), the drawers, forms, states and the phone layout.
*/

:root {
  /* colour */
  --paper: #ffffff;
  --wash: #f5f5f3;          /* hover and quiet fills */
  --ink: #111111;
  --ink-2: #4f4f4f;         /* secondary text, 8.1:1 on paper */
  --ink-3: #686868;         /* tertiary text, 5.6:1 on paper */
  --rule: #e2e2df;          /* the hairline */
  --rule-2: #c9c9c5;        /* inputs and stronger rules */
  --cobalt: #0b45c8;        /* actions and selection only, 7.2:1 on paper */
  --cobalt-ink: #08339a;    /* pressed */
  --cobalt-wash: #edf2fd;
  --warn: #b3261e;          /* low stock, errors */
  --warn-wash: #fcf0ee;
  --ok: #1c6b3a;            /* success messages */
  --ok-wash: #eef6f0;
  --scrim: rgb(17 17 17 / 0.28);

  /* type */
  --sans: "DM Sans", system-ui, sans-serif;
  --mono: "Ubuntu Sans Mono", ui-monospace, monospace;
  --t-xs: 0.75rem;   /* 12px labels */
  --t-s: 0.8125rem;  /* 13px body and cells */
  --t-m: 0.9375rem;  /* 15px panel heads */
  --t-l: 1.625rem;   /* 26px view titles */
  --t-xl: 2.5rem;    /* 40px strip numerals */

  /* space and size */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px;
  --side: 232px;
  --hair: 1px;
  --radius: 0;       /* Swiss: square corners throughout */
  --row: 44px;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

* { box-sizing: border-box; }
html { color-scheme: light; -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: 400 var(--t-s)/1.5 var(--sans); font-optical-sizing: auto;
  accent-color: var(--cobalt); caret-color: var(--cobalt);
  scrollbar-color: var(--rule-2) transparent;
}
::selection { background: var(--cobalt); color: #fff; }
:focus-visible { outline: 2px solid var(--cobalt); outline-offset: 2px; }
h1, h2, h3, p, dl, dd { margin: 0; }
h1, h2 { text-wrap: balance; font-weight: 500; }
a { color: var(--cobalt); text-underline-offset: 3px; text-decoration-thickness: 1px; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
kbd { font: 500 11px/1 var(--mono); border: var(--hair) solid var(--rule-2); padding: 2px 4px; color: var(--ink-2); }
[hidden] { display: none !important; }
.defs { position: absolute; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip { position: fixed; left: var(--s3); top: -60px; z-index: 50; background: var(--cobalt); color: #fff; padding: var(--s2) var(--s3); }
.skip:focus { top: var(--s3); }
.i { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: square; stroke-linejoin: miter; }
.mono, .num, td.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }

/* ---------- shell ---------- */
.app { display: grid; grid-template-columns: var(--side) minmax(0, 1fr); height: 100dvh; }
.side { display: flex; flex-direction: column; border-right: var(--hair) solid var(--rule); background: var(--paper); min-height: 0; }
.shop { display: flex; gap: var(--s3); align-items: center; padding: var(--s5) var(--s5) var(--s5); border-bottom: var(--hair) solid var(--rule); }
.shop-mark { width: 28px; height: 28px; fill: none; stroke: var(--ink); stroke-width: 2; flex: none; }
.shop-mark .fill { fill: var(--cobalt); stroke: var(--ink); }
.shop-name { font-weight: 700; font-size: var(--t-m); line-height: 1.2; }
.shop-tool { color: var(--ink-3); font-family: var(--mono); font-size: var(--t-xs); }
.nav { display: flex; flex-direction: column; padding: var(--s3) 0; }
.nav-item { display: flex; align-items: center; gap: var(--s3); min-height: 40px; padding: 0 var(--s5); color: var(--ink-2); text-decoration: none; font-weight: 500; }
.nav-item:hover { background: var(--wash); color: var(--ink); }
.nav-item[aria-current="page"] { color: var(--cobalt); background: var(--cobalt-wash); }
.nav-count { margin-left: auto; font: 500 var(--t-xs)/1 var(--mono); color: var(--ink-3); }
.nav-count.warn:not(:empty) { color: var(--warn); }
.side-foot { margin-top: auto; border-top: var(--hair) solid var(--rule); padding: var(--s4) var(--s5); display: grid; gap: var(--s3); }
.side-foot dt { font-size: var(--t-xs); color: var(--ink-3); }
.side-foot dd { font-size: var(--t-s); line-height: 1.4; }
.side-keys { padding: var(--s3) var(--s5) var(--s5); color: var(--ink-3); font-size: var(--t-xs); line-height: 2; }

.main { overflow: auto; min-width: 0; outline: none; padding-bottom: var(--s7); }
.top { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--s4) var(--s6); align-items: end; padding: var(--s6) var(--s6) var(--s5); border-bottom: var(--hair) solid var(--rule); position: sticky; top: 0; z-index: 5; background: var(--paper); }
.top h1 { font-size: var(--t-l); line-height: 1.1; letter-spacing: -0.02em; }
.summary { margin-top: var(--s2); color: var(--ink-2); max-width: 70ch; font-size: var(--t-m); }
.summary b { color: var(--ink); font-weight: 500; }
.top-tools { display: flex; gap: var(--s3); align-items: center; }
.range { display: inline-grid; grid-auto-flow: column; gap: var(--hair); background: var(--rule-2); border: var(--hair) solid var(--rule-2); }
.range button { border: 0; background: var(--paper); padding: 0 var(--s3); height: 34px; font-weight: 500; color: var(--ink-2); white-space: nowrap; }
.range button:hover { color: var(--ink); background: var(--wash); }
.range button[aria-checked="true"] { background: var(--cobalt); color: #fff; }
.search { display: flex; align-items: center; gap: var(--s2); border: var(--hair) solid var(--rule-2); height: 36px; padding: 0 var(--s3); width: 240px; color: var(--ink-3); }
.search:focus-within { border-color: var(--cobalt); color: var(--cobalt); }
.search input[type="search"] { border: 0; outline: none; background: none; width: 100%; min-width: 0; height: 100%; padding: 0; box-shadow: none !important; color: var(--ink); }
.search input::placeholder { color: var(--ink-3); }

.view { padding: var(--s5) var(--s6) 0; }
.banner { margin: var(--s4) var(--s6) 0; padding: var(--s3) var(--s4); border: var(--hair) solid var(--warn); background: var(--warn-wash); color: var(--warn); display: flex; gap: var(--s3); align-items: center; flex-wrap: wrap; }
.banner p { flex: 1 1 280px; }
.banner b { font-weight: 500; }

/* ---------- status strip: six hairline cells, the shop's pipeline at a glance ---------- */
.strip { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: var(--hair); background: var(--rule); border: var(--hair) solid var(--rule); }
.cell { background: var(--paper); border: 0; text-align: left; padding: var(--s3) var(--s4) var(--s4); display: grid; gap: var(--s3); align-content: space-between; min-height: 112px; color: var(--ink); }
.cell:hover { background: var(--wash); }
.cell[aria-pressed="true"] { box-shadow: inset 0 0 0 2px var(--cobalt); color: var(--cobalt); }
.cell-name { display: flex; align-items: center; gap: var(--s2); font-weight: 500; font-size: var(--t-s); }
.cell-num { font: 400 var(--t-xl)/1 var(--mono); font-variant-numeric: tabular-nums; letter-spacing: -0.03em; }
.cell-sub { font-size: var(--t-xs); color: var(--ink-3); }
.cell[aria-pressed="true"] .cell-sub { color: var(--cobalt); }

/* status glyph: a square filling from the bottom, step by step, like the shop mark */
.glyph { width: 11px; height: 11px; flex: none; display: inline-block; vertical-align: -1px; }
.glyph rect.o { fill: none; stroke: currentColor; stroke-width: 1.25; }
.glyph rect.f { fill: currentColor; }
.glyph path { stroke: currentColor; stroke-width: 1.25; fill: none; }

.tablebar { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); padding: var(--s4) 0 var(--s3); flex-wrap: wrap; }
.count { color: var(--ink-2); }
.count b { color: var(--ink); font-weight: 500; }
.sortsel { display: flex; align-items: center; gap: var(--s2); color: var(--ink-3); }
select, input[type="text"], input[type="date"], input[type="search"], textarea {
  border: var(--hair) solid var(--rule-2); background: var(--paper); border-radius: var(--radius); height: 36px; padding: 0 var(--s3);
}
select { padding-right: var(--s5); }
select:focus, input:focus, textarea:focus { outline: none; border-color: var(--cobalt); box-shadow: 0 0 0 1px var(--cobalt); }

/* ---------- tables ---------- */
.frame { border-top: var(--hair) solid var(--ink); overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.tbl th { text-align: left; font-weight: 500; font-size: var(--t-xs); color: var(--ink-2); padding: var(--s2) var(--s3); height: 36px; border-bottom: var(--hair) solid var(--rule); white-space: nowrap; }
.tbl td { padding: var(--s2) var(--s3); height: var(--row); border-bottom: var(--hair) solid var(--rule); vertical-align: middle; }
.tbl th:first-child, .tbl td:first-child { padding-left: 0; }
.tbl th:last-child, .tbl td:last-child { padding-right: 0; }
.tbl .num { text-align: right; }
.tbl th.num { font-family: var(--sans); }
.tbl tbody tr:hover { background: var(--wash); }
.tbl tfoot td { font-weight: 500; border-bottom: 0; border-top: var(--hair) solid var(--ink); }
.sorth { border: 0; background: none; padding: 0; font: inherit; color: inherit; display: inline-flex; gap: 2px; align-items: center; }
.sorth .i { width: 12px; height: 12px; opacity: 0.5; }
.sorth[aria-sort] { color: var(--cobalt); }
.sorth[aria-sort] .i { opacity: 1; }
th[aria-sort] .sorth { color: var(--cobalt); }

.orders td:first-child { font-family: var(--mono); }
.rowlink { color: var(--ink); text-decoration: none; font-weight: 500; display: inline-flex; min-height: 28px; align-items: center; }
.rowlink:hover { color: var(--cobalt); text-decoration: underline; }
.orders tbody tr { cursor: pointer; }
.placed { font-family: var(--mono); color: var(--ink-2); white-space: nowrap; }
.cust b { font-weight: 500; }
.cust span, .items span { color: var(--ink-3); }
.items { max-width: 34ch; }
.items .clip { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.status { display: inline-flex; gap: var(--s2); align-items: center; white-space: nowrap; }
.status.refund, .status.cancel { color: var(--ink-3); }
.tag { font: 500 11px/1 var(--mono); border: var(--hair) solid var(--rule-2); padding: 3px 5px; color: var(--ink-2); white-space: nowrap; }
.strike { text-decoration: line-through; color: var(--ink-3); }
.more { padding: var(--s4) 0; }
.empty-row td { height: auto; padding: var(--s7) 0; color: var(--ink-2); }
.empty-row b { display: block; color: var(--ink); font-weight: 500; font-size: var(--t-m); margin-bottom: var(--s1); }

/* stock */
.level { display: inline-flex; gap: var(--s2); align-items: center; white-space: nowrap; }
.bars { display: inline-grid; grid-template-columns: repeat(10, 5px); gap: 2px; height: 12px; }
.bars i { background: var(--rule); }
.bars i.on { background: var(--ink); }
.level.low { color: var(--warn); }
.level.low .bars i.on { background: var(--warn); }
.level.out { color: var(--warn); font-weight: 500; }
tr.low-row td.avail { color: var(--warn); font-weight: 500; }
.recount { display: inline-flex; align-items: center; gap: var(--s1); }
.recount input { width: 56px; height: 30px; text-align: right; font-family: var(--mono); padding: 0 var(--s2); }
.recount .msg { margin: 0; }
.note { color: var(--ink-3); max-width: 72ch; padding: var(--s4) 0; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; gap: var(--s2); height: 36px; padding: 0 var(--s4); border: var(--hair) solid var(--rule-2); background: var(--paper); font-weight: 500; white-space: nowrap; border-radius: var(--radius); }
.btn:hover { border-color: var(--ink); }
.btn.primary { background: var(--cobalt); border-color: var(--cobalt); color: #fff; }
.btn.primary:hover { background: var(--cobalt-ink); border-color: var(--cobalt-ink); }
.btn.ghost { color: var(--cobalt); border-color: var(--rule-2); }
.btn.danger { color: var(--warn); }
.btn.sm { height: 30px; padding: 0 var(--s3); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: 0.55; cursor: not-allowed; }
.btn[aria-busy="true"] { cursor: progress; }
.btn[aria-busy="true"]::after { content: ""; width: 12px; height: 12px; border: 1.5px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin 0.7s linear infinite; }
.icon-btn { width: 36px; height: 36px; display: grid; place-items: center; border: var(--hair) solid var(--rule-2); background: var(--paper); }
.icon-btn:hover { border-color: var(--ink); }
@keyframes spin { to { transform: rotate(1turn); } }

.chips { display: flex; gap: var(--hair); background: var(--rule-2); border: var(--hair) solid var(--rule-2); }
.chip { border: 0; background: var(--paper); height: 32px; padding: 0 var(--s3); font-weight: 500; color: var(--ink-2); }
.chip[aria-pressed="true"] { background: var(--cobalt); color: #fff; }

/* ---------- sales ---------- */
.totals { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: var(--hair); background: var(--rule); border: var(--hair) solid var(--rule); }
.totals > div { background: var(--paper); padding: var(--s3) var(--s4) var(--s4); display: grid; gap: var(--s2); }
.totals dt { font-size: var(--t-xs); color: var(--ink-2); font-weight: 500; }
.totals dd { font: 400 1.5rem/1.1 var(--mono); font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.totals dd small { display: block; font: 400 var(--t-xs)/1.4 var(--sans); color: var(--ink-3); letter-spacing: 0; margin-top: var(--s1); }
.panel { margin-top: var(--s6); }
.panel-head { display: flex; justify-content: space-between; align-items: baseline; gap: var(--s4); flex-wrap: wrap; padding-bottom: var(--s3); border-bottom: var(--hair) solid var(--ink); }
.panel-head h2 { font-size: var(--t-m); font-weight: 700; }
.readout { color: var(--ink-2); font-family: var(--mono); font-size: var(--t-xs); }
.readout b { color: var(--ink); font-weight: 500; }
.chart-wrap { position: relative; padding-top: var(--s3); }
.chart { display: block; width: 100%; height: 280px; overflow: visible; }
.chart:focus-visible { outline-offset: 4px; }
.chart .grid line { stroke: var(--rule); }
.chart .axis line { stroke: var(--ink); }
.chart text { font: 400 11px var(--mono); fill: var(--ink-3); }
.chart .bar { fill: var(--ink); }
.chart .bar.neg { fill: var(--warn); }
.chart .bar.dim { fill: #9d9d99; }
.chart .bar.on { fill: var(--cobalt); }
.chart .hit { fill: transparent; }
.chart .cursor { stroke: var(--cobalt); stroke-width: 1; }
.chart .annot { fill: var(--ink-2); }
.chart .annot-line { stroke: var(--ink-3); stroke-dasharray: 2 3; }
.hint { color: var(--ink-3); font-size: var(--t-xs); margin-top: var(--s2); }
.alt { margin-top: var(--s3); }
.alt summary { cursor: pointer; color: var(--cobalt); font-weight: 500; min-height: 32px; display: inline-flex; align-items: center; }
.alt .frame { max-height: 360px; overflow: auto; margin-top: var(--s2); }
.days th, .days td { height: 32px; }
.share { display: flex; align-items: center; gap: var(--s3); }
.share .bar { height: 8px; background: var(--ink); min-width: 1px; }
.share .lane { flex: 1; min-width: 60px; max-width: 220px; background: var(--wash); height: 8px; }
.products td.prod b { font-weight: 500; }

/* discounts */
.code { font: 500 var(--t-s)/1 var(--mono); letter-spacing: 0.04em; }
.pill { display: inline-flex; align-items: center; gap: var(--s2); white-space: nowrap; }
.pill::before { content: ""; width: 7px; height: 7px; border: 1.25px solid currentColor; }
.pill.active::before { background: currentColor; }
.pill.scheduled { color: var(--ink-2); }
.pill.expired { color: var(--ink-3); }
.disc-new { animation: flash 1.6s var(--ease); }
@keyframes flash { from { background: var(--cobalt-wash); } to { background: transparent; } }

/* ---------- drawers ---------- */
dialog.drawer { margin: 0 0 0 auto; padding: 0; border: 0; border-left: var(--hair) solid var(--ink); width: min(560px, 100vw); max-width: 100vw; height: 100dvh; max-height: 100dvh; background: var(--paper); color: var(--ink); }
dialog.drawer::backdrop { background: var(--scrim); }
.drawer-in { display: flex; flex-direction: column; height: 100%; }
.d-head { display: flex; justify-content: space-between; gap: var(--s4); align-items: flex-start; padding: var(--s5) var(--s5) var(--s4); border-bottom: var(--hair) solid var(--rule); }
.d-head h2 { font-size: 1.25rem; line-height: 1.2; font-family: var(--mono); font-weight: 500; }
.dform .d-head h2 { font-family: var(--sans); }
.d-sub { color: var(--ink-2); margin-top: var(--s1); }
.d-body:focus { outline: none; }
.d-body { flex: 1; overflow: auto; padding: 0 var(--s5) var(--s5); }
.d-foot { display: flex; justify-content: flex-end; gap: var(--s2); padding: var(--s3) var(--s5); border-top: var(--hair) solid var(--rule); flex-wrap: wrap; }
.d-sec { padding: var(--s4) 0; border-bottom: var(--hair) solid var(--rule); }
.d-sec:last-child { border-bottom: 0; }
.d-sec h3 { font-size: var(--t-s); font-weight: 700; margin: 0 0 var(--s3); }
.kv { display: grid; grid-template-columns: 9rem minmax(0, 1fr); gap: var(--s2) var(--s4); }
.kv dt { color: var(--ink-3); }
.kv dd { overflow-wrap: anywhere; }
.lines { width: 100%; border-collapse: collapse; }
.lines td { padding: var(--s2) 0; border-bottom: var(--hair) solid var(--rule); vertical-align: top; }
.lines td + td { padding-left: var(--s3); }
.lines .num { text-align: right; white-space: nowrap; }
.lines tr.sum td { border-bottom: 0; padding-top: var(--s1); padding-bottom: var(--s1); color: var(--ink-2); }
.lines tr.grand td { border-top: var(--hair) solid var(--ink); color: var(--ink); font-weight: 500; padding-top: var(--s2); }
.lines .sku { display: block; font: 400 var(--t-xs)/1.4 var(--mono); color: var(--ink-3); }

/* fulfilment: four steps on a hairline grid, each fills its square when done */
.steps { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--hair); background: var(--rule); border: var(--hair) solid var(--rule); margin-bottom: var(--s4); }
.step { background: var(--paper); padding: var(--s3); display: grid; gap: var(--s1); align-content: start; }
.step .glyph { width: 14px; height: 14px; }
.step b { font-weight: 500; }
.step span { color: var(--ink-3); font-size: var(--t-xs); font-family: var(--mono); }
.step.done { color: var(--ink); }
.step.now { box-shadow: inset 0 0 0 2px var(--cobalt); color: var(--cobalt); }
.step.now span { color: var(--cobalt); }
.step.todo { color: var(--ink-3); }
.task { display: grid; gap: var(--s3); }
.task .row { display: flex; gap: var(--s2); flex-wrap: wrap; align-items: flex-end; }
.picklist { list-style: none; margin: 0; padding: 0; border-top: var(--hair) solid var(--rule); }
.picklist li { border-bottom: var(--hair) solid var(--rule); }
.picklist label { display: flex; gap: var(--s3); align-items: center; min-height: 40px; cursor: pointer; }
.picklist input { width: 16px; height: 16px; }
.picklist .sku { margin-left: auto; font: 400 var(--t-xs) var(--mono); color: var(--ink-3); }
.timeline { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s2); }
.timeline li { display: grid; grid-template-columns: 8.5rem 1fr; gap: var(--s3); }
.timeline time { font: 400 var(--t-xs)/1.6 var(--mono); color: var(--ink-3); }
.track { font-family: var(--mono); }
.done-line { color: var(--ok); display: flex; gap: var(--s2); align-items: center; }

/* forms */
.field { display: grid; gap: var(--s1); padding-top: var(--s4); border: 0; margin: 0; min-width: 0; }
fieldset.field { padding: 0; margin-top: var(--s4); }
.field label, .field legend { font-weight: 500; padding: 0; }
.field.two { grid-template-columns: 1fr 1fr; gap: var(--s3); }
.field.two > div { display: grid; gap: var(--s1); min-width: 0; }
.field input[type="date"] { width: 100%; }
.opt { color: var(--ink-3); font-weight: 400; }
.help { color: var(--ink-3); font-size: var(--t-xs); }
.msg { font-size: var(--t-xs); color: var(--warn); min-height: 0; }
.msg:empty { display: none; }
[aria-invalid="true"] { border-color: var(--warn) !important; box-shadow: 0 0 0 1px var(--warn) !important; }
.codeline { display: flex; gap: var(--s2); }
.codeline input { flex: 1; min-width: 0; font-family: var(--mono); text-transform: uppercase; letter-spacing: 0.06em; }
.unit { display: flex; align-items: center; border: var(--hair) solid var(--rule-2); height: 36px; max-width: 200px; }
.unit:focus-within { border-color: var(--cobalt); box-shadow: 0 0 0 1px var(--cobalt); }
.unit:has([aria-invalid="true"]) { border-color: var(--warn); box-shadow: 0 0 0 1px var(--warn); }
.unit input { border: 0 !important; box-shadow: none !important; height: 34px; flex: 1; min-width: 0; font-family: var(--mono); }
.unit .pre, .unit .post { padding: 0 var(--s3); color: var(--ink-3); font-family: var(--mono); }
.unit .pre { padding-right: 0; }
.seg { display: flex; flex-wrap: wrap; gap: var(--hair); background: var(--rule-2); border: var(--hair) solid var(--rule-2); width: fit-content; max-width: 100%; margin-top: var(--s1); }
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.seg span { display: flex; align-items: center; height: 34px; padding: 0 var(--s3); background: var(--paper); font-weight: 500; color: var(--ink-2); }
.seg input:checked + span { background: var(--cobalt); color: #fff; }
.seg input:focus-visible + span { outline: 2px solid var(--cobalt); outline-offset: 2px; position: relative; z-index: 1; }
.check { display: inline-flex; align-items: center; gap: var(--s2); min-height: 32px; font-weight: 400 !important; cursor: pointer; }
.check input { width: 16px; height: 16px; margin: 0; }
.picks { display: grid; grid-template-columns: 1fr 1fr; gap: 0 var(--s4); margin-top: var(--s2); border-top: var(--hair) solid var(--rule); }
.picks .check { border-bottom: var(--hair) solid var(--rule); }
.preview { margin-top: var(--s5); border: var(--hair) solid var(--rule); padding: var(--s3) var(--s4); background: var(--wash); }
.pv-label { font-size: var(--t-xs); color: var(--ink-3); margin-bottom: var(--s1); }
.formerr { color: var(--warn); margin-top: var(--s3); }
.formerr:empty { display: none; }
textarea { width: 100%; height: 72px; padding: var(--s2) var(--s3); resize: vertical; }

/* refund */
.rlines { width: 100%; border-collapse: collapse; }
.rlines td { padding: var(--s2) 0; border-bottom: var(--hair) solid var(--rule); vertical-align: middle; }
.rlines td + td { padding-left: var(--s3); }
.stepper { display: inline-flex; border: var(--hair) solid var(--rule-2); height: 32px; }
.stepper button { width: 32px; border: 0; background: var(--paper); display: grid; place-items: center; color: var(--cobalt); }
.stepper button:disabled { color: var(--rule-2); cursor: not-allowed; }
.stepper output { width: 32px; display: grid; place-items: center; font-family: var(--mono); border-left: var(--hair) solid var(--rule); border-right: var(--hair) solid var(--rule); }
.rsum { display: grid; grid-template-columns: 1fr auto; row-gap: var(--s1); margin-top: var(--s3); }
.rsum dd { padding-left: var(--s4); }
.rsum dt { color: var(--ink-2); }
.rsum dd { font-family: var(--mono); text-align: right; }
.rsum .big { font-weight: 500; color: var(--ink); border-top: var(--hair) solid var(--ink); padding-top: var(--s2); }
.ok-box { border: var(--hair) solid var(--ok); background: var(--ok-wash); color: var(--ok); padding: var(--s3) var(--s4); margin-top: var(--s4); }
.err-box { border: var(--hair) solid var(--warn); background: var(--warn-wash); color: var(--warn); padding: var(--s3) var(--s4); margin-top: var(--s4); }

/* ---------- states: skeleton, empty, error ---------- */
.state { padding: var(--s5) var(--s6); }
.sk { background: var(--wash); position: relative; overflow: hidden; }
.sk-strip { display: grid; grid-template-columns: repeat(7, 1fr); gap: var(--hair); background: var(--rule); border: var(--hair) solid var(--rule); }
.sk-strip > div { background: var(--paper); height: 112px; padding: var(--s3) var(--s4); display: grid; align-content: space-between; }
.sk-line { height: 10px; background: var(--wash); }
.sk-num { height: 34px; width: 50%; background: var(--wash); }
.sk-rows { margin-top: var(--s7); border-top: var(--hair) solid var(--ink); }
.sk-rows > div { height: var(--row); border-bottom: var(--hair) solid var(--rule); display: grid; grid-template-columns: 1fr 1fr 2fr 3fr 1fr 1fr; gap: var(--s4); align-items: center; }
@media (prefers-reduced-motion: no-preference) {
  .sk-line, .sk-num { animation: pulse 1.4s ease-in-out infinite; }
  @keyframes pulse { 50% { opacity: 0.45; } }
}
.blank { border-top: var(--hair) solid var(--ink); padding: var(--s7) 0; display: grid; grid-template-columns: 96px minmax(0, 60ch); gap: var(--s5); align-items: start; }
.blank > svg { width: 96px; height: 96px; fill: none; stroke: var(--ink); stroke-width: 1.25; }
.blank h2 { font-size: 1.25rem; margin-bottom: var(--s2); }
.blank p { color: var(--ink-2); margin-bottom: var(--s4); font-size: var(--t-m); }
.blank .btns { display: flex; gap: var(--s2); flex-wrap: wrap; }
.nojs { margin: var(--s5) var(--s6); border-top: var(--hair) solid var(--ink); padding-top: var(--s5); max-width: 64ch; }
.nojs h2 { font-size: 1.25rem; margin-bottom: var(--s2); }
.nojs p { color: var(--ink-2); }

/* toasts */
.toasts { position: fixed; right: var(--s5); bottom: var(--s5); display: grid; gap: var(--s2); z-index: 60; }
.toast { background: var(--ink); color: #fff; padding: var(--s3) var(--s4); display: flex; gap: var(--s3); align-items: center; max-width: 380px; box-shadow: 0 6px 24px rgb(0 0 0 / 0.18); }
.toast button { background: none; border: 0; color: #a9c1ff; font-weight: 500; padding: 0; min-height: 24px; }

/* motion: the drawer slides in from the right edge of the grid; steps fill their square */
@media (prefers-reduced-motion: no-preference) {
  dialog.drawer[open] { animation: slide 0.36s var(--ease); }
  dialog.drawer[open]::backdrop { animation: fade 0.3s var(--ease); }
  .step.just .glyph rect.f { animation: fill 0.5s var(--ease); transform-origin: 50% 100%; transform-box: fill-box; }
  .toast { animation: rise 0.3s var(--ease); }
  .view, .state { animation: fade 0.24s var(--ease); }
}
@keyframes slide { from { transform: translateX(48px); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }
@keyframes fill { from { transform: scaleY(0); } }
@keyframes rise { from { transform: translateY(8px); opacity: 0; } }

/* ---------- medium screens ---------- */
@media (max-width: 1240px) {
  .top { grid-template-columns: 1fr; align-items: start; }
  .strip { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .strip .cell:last-child { grid-column: span 2; }
  .totals { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .sk-strip { grid-template-columns: repeat(4, 1fr); }
}
@media (max-width: 1100px) {
  .orders th:nth-child(4), .orders td:nth-child(4) { display: none; }
  .stock th:nth-child(6), .stock td:nth-child(6) { display: none; }
}
@media (max-width: 960px) {
  :root { --side: 196px; }
  .top, .view, .state { padding-left: var(--s5); padding-right: var(--s5); }
  .banner { margin-left: var(--s5); margin-right: var(--s5); }
  .side-keys { display: none; }
  .stock th:nth-child(2), .stock td:nth-child(2) { display: none; }
}

/* ---------- phones: bottom bar, stacked rows, full-sheet drawers ---------- */
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; height: auto; min-height: 100dvh; }
  .main { overflow: visible; padding-bottom: 96px; }
  .side { position: fixed; z-index: 20; left: 0; right: 0; bottom: 0; border-right: 0; border-top: var(--hair) solid var(--ink); padding-bottom: env(safe-area-inset-bottom); }
  .shop, .side-foot, .side-keys { display: none; }
  .nav { flex-direction: row; padding: 0; }
  .nav-item { flex: 1; flex-direction: column; gap: 2px; justify-content: center; min-height: 60px; padding: 0 var(--s1); font-size: var(--t-xs); position: relative; }
  .nav-count { position: absolute; top: 8px; left: calc(50% + 10px); margin: 0; }
  .top { padding: var(--s5) var(--s4) var(--s4); gap: var(--s3); }
  .top h1 { font-size: 1.375rem; }
  .summary { font-size: var(--t-s); }
  .top-tools { flex-wrap: wrap; }
  .range { flex: 1 1 100%; grid-auto-columns: 1fr; }
  .range button { height: 40px; }
  .search { width: 100%; height: 40px; }
  .view, .state { padding: var(--s4) var(--s4) 0; }
  .banner { margin: var(--s3) var(--s4) 0; }
  .strip { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .strip .cell:last-child { grid-column: 1 / -1; grid-template-columns: 1fr auto; align-items: center; min-height: 52px; }
  .cell { min-height: 76px; padding: var(--s2) var(--s3) var(--s3); gap: var(--s2); }
  .cell-name { font-size: var(--t-xs); }
  .cell-num { font-size: 1.75rem; }
  .cell-sub { display: none; }
  .totals { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .totals dd { font-size: 1.25rem; }
  .chart { height: 220px; }
  .sk-strip { grid-template-columns: repeat(2, 1fr); }
  .sk-rows > div { grid-template-columns: 1fr 2fr 1fr; }
  .sk-rows > div > :nth-child(n+4) { display: none; }

  /* orders and stock become stacked rows */
  .orders thead, .stock thead, .discounts thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .orders tbody tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "id total" "cust cust" "items items" "status placed"; gap: 2px var(--s3); padding: var(--s3) 0; border-bottom: var(--hair) solid var(--rule); }
  .orders td { display: block; height: auto; padding: 0; border: 0; }
  .orders td:nth-child(1) { grid-area: id; }
  .orders td:nth-child(2) { grid-area: placed; text-align: right; font-size: var(--t-xs); }
  .orders td:nth-child(3) { grid-area: cust; }
  .orders .items { display: block; grid-area: items; max-width: none; font-size: var(--t-xs); }
  .orders td:nth-child(5) { grid-area: status; }
  .orders td:nth-child(6) { grid-area: total; font-weight: 500; }
  .orders .empty-row { display: block; }

  .stock tbody tr { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); grid-template-areas: "name name level" "a b c" "rc rc rc"; gap: var(--s2) var(--s3); padding: var(--s3) 0; border-bottom: var(--hair) solid var(--rule); }
  .stock td { display: block; height: auto; padding: 0 !important; border: 0; }
  .stock td:nth-child(1) { grid-area: name; }
  .stock td:nth-child(2), .stock td:nth-child(6) { display: none; }
  .stock td:nth-child(3), .stock td:nth-child(4), .stock td:nth-child(5) { text-align: left; font-size: var(--t-xs); }
  .stock td:nth-child(3)::before { content: "On hand "; font-family: var(--sans); color: var(--ink-3); }
  .stock td:nth-child(4)::before { content: "Committed "; font-family: var(--sans); color: var(--ink-3); }
  .stock td:nth-child(5)::before { content: "Available "; font-family: var(--sans); color: var(--ink-3); }
  .stock td:nth-child(3) { grid-area: a; }
  .stock td:nth-child(4) { grid-area: b; }
  .stock td:nth-child(5) { grid-area: c; }
  .stock td:nth-child(7) { grid-area: level; justify-self: end; }
  .stock .level .bars { display: none; }
  .stock td:nth-child(8) { grid-area: rc; }

  .discounts tbody tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px var(--s3); padding: var(--s3) 0; border-bottom: var(--hair) solid var(--rule); }
  .discounts td { display: block; height: auto; padding: 0 !important; border: 0; text-align: left !important; }
  .discounts td:nth-child(1) { order: 1; }
  .discounts td:nth-child(6) { order: 2; text-align: right !important; }
  .discounts td:nth-child(2) { order: 3; grid-column: 1 / -1; }
  .discounts td:nth-child(3) { order: 4; grid-column: 1 / -1; color: var(--ink-3); font-size: var(--t-xs); }
  .discounts td:nth-child(4) { order: 5; font-size: var(--t-xs); }
  .discounts td:nth-child(4)::after { content: " uses"; font-family: var(--sans); color: var(--ink-3); }
  .discounts td:nth-child(5) { order: 6; text-align: right !important; font-size: var(--t-xs); }

  .products th:nth-child(4), .products td:nth-child(4) { display: none; }
  .days th:first-child, .days td:first-child { position: sticky; left: 0; background: var(--paper); }

  dialog.drawer { width: 100vw; border-left: 0; }
  .d-head, .d-foot { padding-left: var(--s4); padding-right: var(--s4); }
  .d-body { padding: 0 var(--s4) var(--s5); }
  .kv { grid-template-columns: 7rem minmax(0, 1fr); }
  .steps { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .timeline li { grid-template-columns: 1fr; gap: 0; }
  .field.two, .picks { grid-template-columns: 1fr; }
  .blank { grid-template-columns: 1fr; }
  .blank > svg { width: 64px; height: 64px; }
  .toasts { left: var(--s4); right: var(--s4); bottom: 76px; }
  .d-foot .btn { height: 44px; }
}
.no-js .view { display: none; }
