:root {
  --bg: #f6f1ea;
  --panel: #ffffff;
  --ink: #23180f;
  --muted: #7a6b5d;
  --line: #e4dbd0;
  --brand: #2b1d14;
  --accent: #9e5430;
  --cash: #2f7d4f;
  --card: #2f5c8f;
  --danger: #b3412e;
  --on: #fbe9dc;
  --radius: 14px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); }
body { overscroll-behavior: none; -webkit-tap-highlight-color: transparent; user-select: none; }
button { font: inherit; color: inherit; border: 1px solid var(--line); background: var(--panel); border-radius: 10px; cursor: pointer; touch-action: manipulation; }
button:disabled { opacity: .45; cursor: default; }
/* A big button that isn't ready yet still has to be read: it says what is missing. */
.big:disabled { opacity: 1; background: var(--panel) !important; color: var(--ink) !important; border: 2px dashed var(--accent); }
button:active:not(:disabled) { filter: brightness(.92); }
button.on { background: var(--on); border-color: var(--accent); }
small { display: block; color: var(--muted); font-size: .8rem; }
.muted { color: var(--muted); }
.loading, .fatal { padding: 32px; }
.fatal code { background: #fff; padding: 2px 6px; border-radius: 6px; }

#app { display: flex; flex-direction: column; height: 100dvh; }
.bar { display: flex; align-items: center; gap: 16px; padding: 10px 16px; background: var(--brand); color: #fff; }
.bar nav { display: flex; gap: 6px; }
.bar nav button { background: transparent; color: #fff; border-color: #5a4637; padding: 8px 18px; min-height: 48px; }
.bar nav button.on { background: #fff; color: var(--brand); }
.net { margin-left: auto; font-size: .85rem; }
.net::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; background: #6cc28c; }
.net.off::before { background: #f0a04b; }

main { flex: 1; min-height: 0; }
main.sell { display: grid; grid-template-columns: 1fr minmax(300px, 34%); }
.menu { display: flex; flex-direction: column; min-height: 0; padding: 12px; gap: 12px; }
.cats { display: flex; gap: 8px; overflow-x: auto; flex: none; scrollbar-width: none; }
.cats button { padding: 0 22px; min-height: 56px; font-weight: 700; font-size: 1.05rem; white-space: nowrap; }
.cats button.on { background: var(--brand); color: #fff; border-color: var(--brand); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); grid-auto-rows: minmax(120px, auto); gap: 10px; overflow-y: auto; align-content: start; flex: 1; padding-bottom: 8px; }
.tile { padding: 14px; text-align: left; display: flex; flex-direction: column; justify-content: space-between; gap: 8px;
  font-weight: 700; font-size: 1.08rem; line-height: 1.25; border-width: 1.5px; box-shadow: 0 1px 0 rgba(43, 29, 20, .06); }
.tile small { font-size: 1rem; font-weight: 600; color: var(--accent); }
.tile:active:not(:disabled) { transform: scale(.98); background: var(--on); }
.tile:disabled small { color: var(--danger); }

.ticket { background: var(--panel); border-left: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; padding: 14px; gap: 10px; }
.ticket .empty { margin: auto; text-align: center; color: var(--muted); }
.ticket .empty p { font-size: 1.2rem; margin: 0 0 4px; }
.head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.head b { font-size: 1.1rem; }
.head small { display: inline; margin-left: 8px; }
.head .link.danger { min-height: 44px; padding: 0 12px; border: 1px solid #ecd2cc; border-radius: 10px; font-weight: 600; }
.lines { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; }
.lines li { display: flex; justify-content: space-between; gap: 12px; padding: 12px 4px; border-bottom: 1px solid var(--line); font-size: 1.02rem; min-height: 52px; }
.ticket .lines li { cursor: pointer; }
.lines li b span { font-weight: 400; color: var(--muted); }
.lines li em { display: block; font-size: .78rem; font-style: normal; color: var(--accent); }
.lines li.voided { opacity: .55; }
.lines li.voided > span { text-decoration: line-through; }
em.void { color: var(--danger) !important; font-style: normal; }
.sum div { display: flex; justify-content: space-between; padding: 3px 0; }
.sum b { font-size: 1.25rem; }
.pay, .row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.big { padding: 18px; min-height: 64px; font-size: 1.15rem; font-weight: 700; border: none; color: #fff; background: var(--brand); width: 100%; }
.pay .big { min-height: 76px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 1.25rem; }
.pay .big span { font-size: 1rem; font-weight: 600; opacity: .9; }
.big.cash { background: var(--cash); }
.big.card { background: var(--card); }
.big.add { background: var(--accent); }
.big.danger { background: var(--danger); }
.row .big:first-child:not(.card) { background: #ddd2c6; color: var(--ink); }
.link { border: none; background: none; padding: 6px; }
.link.danger { color: var(--danger); }

#layer .scrim { position: fixed; inset: 0; background: rgba(35, 24, 15, .45); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 10; }
.sheet, .dialog { background: var(--panel); border-radius: var(--radius); width: min(640px, 100%); max-height: 92dvh; display: flex; flex-direction: column; overflow: hidden; }
.dialog { padding: 0 18px 18px; gap: 12px; overflow-y: auto; width: min(460px, 100%); }
.dialog.wide { width: min(620px, 100%); }
.top { display: flex; justify-content: space-between; align-items: center; padding: 14px 0; gap: 12px; }
.sheet .top { padding: 14px 18px; border-bottom: 1px solid var(--line); }
.top h2 { margin: 0; font-size: 1.2rem; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.x { border: none; font-size: 1.8rem; line-height: 1; width: 56px; height: 56px; background: none; }
.sheet .body { overflow-y: auto; padding: 8px 18px; }
fieldset { border: none; padding: 8px 0; margin: 0; }
legend { font-weight: 700; padding: 0 0 8px; display: flex; gap: 8px; align-items: baseline; }
legend small { display: inline; }
legend small.req { color: var(--danger); font-weight: 600; }
.opts { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; }
.opts button { padding: 12px 14px; min-height: 64px; text-align: left; font-weight: 600; font-size: 1.02rem; position: relative; border-width: 1.5px; }
.opts button.on { background: var(--on); border: 2px solid var(--accent); }
.opts button.on::after { content: "✓"; position: absolute; top: 6px; right: 10px; color: var(--accent); font-weight: 800; }
.sheet .foot { display: grid; grid-template-columns: auto 1fr; gap: 12px; padding: 12px 18px; border-top: 1px solid var(--line); }
.qty { display: flex; align-items: center; gap: 12px; }
.qty button { width: 52px; height: 52px; font-size: 1.5rem; }
.qty b { min-width: 2ch; text-align: center; font-size: 1.3rem; }
.qty.center { justify-content: center; }
.step { font-size: 1.15rem; }

.cash .quick { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.cash .quick button { padding: 14px 4px; font-weight: 700; }
.handed, .change { display: flex; justify-content: space-between; align-items: baseline; font-size: 1.1rem; }
.handed b, .change b { font-size: 1.6rem; }
.change { background: #eaf4ee; color: var(--cash); padding: 10px 14px; border-radius: 10px; }
.change.short { background: #f8e6e2; color: var(--danger); }
.keys { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.keys button { padding: 14px; font-size: 1.3rem; font-weight: 600; }
.reasons { grid-template-columns: 1fr 1fr; }
#reason { font: inherit; padding: 14px; border: 1px solid var(--line); border-radius: 10px; width: 100%; user-select: text; }

.receipt .paper { background: #fffdf8; border: 1px dashed var(--line); border-radius: 10px; padding: 12px 16px; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .9rem; }
.receipt .paper h3 { margin: 0; text-align: center; }
.receipt .paper p { margin: 4px 0; text-align: center; }
.receipt .lines { flex: none; }

main.today { overflow-y: auto; padding: 16px; }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.stat b { display: block; font-size: 1.5rem; margin: 2px 0; }
.stat span { color: var(--muted); font-size: .8rem; }
h2.day { font-size: 1rem; margin: 18px 0 8px; }
table.orders { width: 100%; border-collapse: collapse; background: var(--panel); border-radius: var(--radius); overflow: hidden; }
.orders th, .orders td { text-align: left; padding: 12px; border-bottom: 1px solid var(--line); }
.orders th { font-size: .8rem; color: var(--muted); font-weight: 600; }
.orders tbody tr { cursor: pointer; }
.orders .r { text-align: right; }
.orders em { font-style: normal; color: var(--accent); }
.events { font-size: .85rem; color: var(--muted); padding-left: 18px; }

#toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 140%); background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 10px; transition: transform .2s; z-index: 20; max-width: 90vw; }
#toast.show { transform: translate(-50%, 0); }

@media (max-width: 760px) {
  main.sell { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  .ticket { border-left: none; border-top: 1px solid var(--line); max-height: 45dvh; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
  .cash .quick { grid-template-columns: repeat(3, 1fr); }
}

/* sync status, sign-in, day close */
button.net { background: transparent; border: 1px solid #5a4637; color: #fff; padding: 6px 12px; min-height: 48px; }
.net.warn::before { background: #f0a04b; }
.dialog input[type=email], .dialog #code, #close-note, #app-ref { font: inherit; padding: 14px; border: 1px solid var(--line); border-radius: 10px; width: 100%; user-select: text; }
.close-row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-top: 14px; }
.close-row .big { width: auto; padding: 14px 20px; }
.closed { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; font-size: .9rem; }

/* who is at the till */
#clerk { border: 1px solid #5a4637; border-radius: 999px; padding: 8px 14px; min-height: 48px; color: #fff; font-weight: 600; }
#clerk::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #f0c24b; margin-right: 8px; }

/* ---- review round 1 ---- */
.stack { display: grid; gap: 28px; }
.big.quiet { background: #ddd2c6; color: var(--ink); min-height: 56px; }
.opts button.on small { color: #6b5d50; }
.head .link.danger { min-height: 48px; padding: 0 12px; }
.bar :focus-visible { outline-color: #fff; }

/* ================= Round 2 look: category colour, rail, themes (20/11/2026) ================= */
:root {
  --tile: #ffffff;
  --field: #ffffff;
  --quiet: #ddd2c6;
  --ok-bg: #eaf4ee; --ok-ink: #2f7d4f;
  --bad-bg: #f8e6e2; --bad-ink: #b3412e;
  --paper: #fffdf8;
  --shadow: 0 1px 2px rgba(43, 29, 20, .08), 0 2px 8px rgba(43, 29, 20, .05);
}
html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #15110e;
  --panel: #201a16;
  --tile: #2a221c;
  --field: #2a221c;
  --ink: #f4ede5;
  --muted: #b9aa9b;
  --line: #3b3029;
  --brand: #0e0b09;
  --accent: #d9773f;
  --cash: #2e8b57;
  --card: #3b6fb3;
  --danger: #d0533c;
  --on: #3d2b20;
  --quiet: #3a302a;
  --ok-bg: #16301f; --ok-ink: #6fd39a;
  --bad-bg: #3a1c17; --bad-ink: #ff8a73;
  --paper: #2a231d;
  --shadow: none;
}
html[data-theme="dark"] .bar { border-bottom: 1px solid var(--line); }
html[data-theme="dark"] #layer .scrim { background: rgba(0, 0, 0, .6); }
html[data-theme="dark"] .opts button.on small { color: var(--muted); }
input, select, textarea { background: var(--field); color: var(--ink); }
.row .big:first-child:not(.card), .big.quiet { background: var(--quiet); color: var(--ink); }
.change { background: var(--ok-bg); color: var(--ok-ink); }
.change.short { background: var(--bad-bg); color: var(--bad-ink); }
.receipt .paper { background: var(--paper); }
#toast { background: var(--ink); color: var(--bg); }
.head .link.danger { border-color: var(--line); }

/* header */
.bar .brand { font-size: 1.1rem; letter-spacing: .01em; }
.clock { margin-left: auto; font-weight: 700; font-size: 1.15rem; font-variant-numeric: tabular-nums; color: #fff; }
.net { margin-left: 0; }
.icon-btn { width: 48px; height: 48px; background: transparent; border: 1px solid #5a4637; color: #fff; font-size: 1.3rem; border-radius: 999px; }

/* sell screen: rail | items | ticket */
main.sell { grid-template-columns: 156px 1fr minmax(320px, 32%); }
.cats { flex-direction: column; overflow-x: hidden; overflow-y: auto; padding: 12px 0 12px 12px; gap: 8px; }
.cats button { --c: var(--accent); display: flex; flex-direction: column; align-items: flex-start; justify-content: center; gap: 2px;
  text-align: left; min-height: 76px; padding: 10px 12px; border: 1px solid var(--line); border-left: 6px solid var(--c);
  background: var(--panel); color: var(--ink); white-space: normal; font-size: 1.02rem; }
.cats button small { font-weight: 500; font-size: .78rem; }
.cats button.on { background: color-mix(in srgb, var(--c) 18%, var(--panel)); color: var(--ink); border-color: var(--c); border-left-width: 6px; }
.menu-head { display: flex; align-items: baseline; gap: 10px; }
.menu-head h2 { margin: 0; font-size: 1.35rem; display: flex; align-items: center; gap: 10px; }
.menu-head h2::before { content: ""; width: 14px; height: 14px; border-radius: 50%; background: var(--c); }
.menu-head small { display: inline; }

.grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); grid-auto-rows: minmax(124px, auto); gap: 12px; }
.tile { position: relative; background: var(--tile); border: 1px solid var(--line); border-top: 6px solid var(--c);
  box-shadow: var(--shadow); font-size: 1.1rem; padding: 14px 14px 12px; }
.tile small { color: var(--muted); font-size: 1.02rem; font-weight: 700; }
.tile:active:not(:disabled) { background: color-mix(in srgb, var(--c) 16%, var(--tile)); }
html[data-theme="dark"] .tile { background: color-mix(in srgb, var(--c) 20%, var(--tile)); border-color: color-mix(in srgb, var(--c) 40%, var(--tile)); border-top-color: var(--c); }
html[data-theme="dark"] .tile small { color: color-mix(in srgb, var(--ink) 78%, var(--c)); }
html[data-theme="dark"] .tile:active:not(:disabled) { background: color-mix(in srgb, var(--c) 34%, var(--tile)); }
.tile:disabled { border-top-color: var(--line); }
.tile .count { position: absolute; top: 8px; right: 8px; min-width: 32px; height: 32px; padding: 0 8px; border-radius: 999px;
  background: var(--ink); color: var(--bg); box-shadow: 0 0 0 3px var(--c); font-size: 1rem; display: grid; place-items: center; }
.tile span { padding-right: 36px; }

/* ticket */
.ticket { box-shadow: -1px 0 0 var(--line); }
.ticket .empty { display: grid; justify-items: center; gap: 6px; }
.empty-mark { width: 76px; height: 76px; border-radius: 50%; border: 2px dashed var(--line); display: grid; place-items: center; font-size: 2.4rem; color: var(--muted); margin-bottom: 6px; }
.head b { font-size: 1.25rem; }
.head small { display: block; margin: 2px 0 0; }
.ticket .q { font-style: normal; display: inline-block; min-width: 2.2em; text-align: center; padding: 2px 6px; margin-right: 6px; border-radius: 8px; background: var(--on); }
.receipt .q { font-style: normal; }
.sum { border-top: 2px solid var(--line); padding-top: 6px; }
.sum div:first-child b { font-size: 1.7rem; }

@media (max-width: 760px) {
  main.sell { grid-template-columns: 1fr; grid-template-rows: auto 1fr auto; }
  .cats { flex-direction: row; overflow-x: auto; overflow-y: hidden; padding: 8px 8px 0; }
  .cats button { min-height: 56px; flex: none; }
  .cats button small { display: none; }
  .clock { display: none; }
}
html:not([data-theme="dark"]) .tile:not(:disabled) { background: color-mix(in srgb, var(--c) 9%, #fff); border-color: color-mix(in srgb, var(--c) 30%, #fff); border-top-color: var(--c); }
html:not([data-theme="dark"]) .tile:not(:disabled) small { color: color-mix(in srgb, var(--ink) 75%, var(--c)); }
.sheet { border-top: 6px solid var(--c, var(--accent)); }

/* ---- review of the round 2 look ---- */
html[data-theme="dark"] { --danger: #e0644c; --cash: #2a7d4f; }
html[data-theme="dark"] .big.danger, html[data-theme="dark"] .bo button.danger { background: #c0412b; }
html[data-theme="dark"] .tile:disabled small { color: var(--danger); }
.fatal code { background: var(--panel); }
@media (max-width: 760px) {
  .bar { flex-wrap: wrap; gap: 8px; padding: 8px 10px; }
  .bar .logo { height: 32px; }
  .net { max-width: 46vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}
.orders .ready { display: inline-block; margin-left: 6px; padding: 2px 8px; border-radius: 999px; background: var(--ok-bg); color: var(--ok-ink); font-size: .8rem; }

/* Delivery app orders: keyed in from the app's tablet, sent to the kitchen with no money taken. */
.ticket .deliver { min-height: 52px; font-size: 1.02rem; }
.dialog.delivery label { font-weight: 700; }
#app-ref { font-size: 1.3rem; letter-spacing: .06em; }

/* Phone orders and notes: sent now, paid at pickup; the note goes to the kitchen, not the receipt. */
:root { --note-bg: #fff3b0; --note-ink: #3b2f00; --pickup: #2f5c8f; }
html[data-theme="dark"] { --note-bg: #3a3210; --note-ink: #ffe68a; --pickup: #7fb0ec; }
.later-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.later-row:has(> :only-child) { grid-template-columns: 1fr; }
.ticket .pickup { margin: 0; padding: 8px 12px; border-radius: 10px; border: 1.5px solid var(--pickup); color: var(--pickup); font-weight: 600; }
.note-btn { text-align: left; padding: 10px 12px; min-height: 48px; border-style: dashed; color: var(--muted); overflow-wrap: anywhere; }
.note-btn.has { border-style: solid; background: var(--note-bg); color: var(--note-ink); border-color: transparent; font-weight: 600; }
.note-btn b { margin-right: 6px; }
.ticket .waiting { width: 100%; }
.waiting h3 { margin: 0 0 8px; font-size: 1rem; }
.waiting ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; max-height: 40dvh; overflow-y: auto; }
.waiting button { width: 100%; min-height: 56px; padding: 8px 12px; text-align: left; display: grid; grid-template-columns: auto 1fr; column-gap: 12px; align-items: center; }
.waiting button > b { font-size: 1.25rem; color: var(--pickup); }
.waiting button small { grid-column: 2; color: var(--note-ink); background: var(--note-bg); border-radius: 6px; padding: 2px 6px; justify-self: start; overflow-wrap: anywhere; }
.waiting .ready, .ticket .ready { display: inline-block; margin-left: 6px; padding: 2px 8px; border-radius: 999px; background: var(--ok-bg); color: var(--ok-ink); font-size: .8rem; }
.dialog.phone label { font-weight: 700; }
.opts.mins { grid-template-columns: repeat(5, 1fr); }
.opts.mins button { min-height: 56px; text-align: center; padding: 8px 4px; }
.opts.mins button.on::after { content: none; }
#pickup-time, #order-note { font: inherit; padding: 14px; border: 1px solid var(--line); border-radius: 10px; width: 100%; user-select: text; background: var(--field); color: var(--ink); }
#pickup-time { font-size: 1.3rem; }
p.warn { margin: 0; padding: 10px 12px; border-radius: 10px; background: var(--note-bg); color: var(--note-ink); font-weight: 600; }
