/* Palette tokens: light + dark, both selected (not an auto flip). */
:root {
  color-scheme: light;
  --surface-1: #fcfcfb;
  --plane: #f9f9f7;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #898781;
  --grid: #e1e0d9;
  --baseline: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --good: #0ca30c;
  --good-text: #006300;
  --warning: #fab219;
  --critical: #d03b3b;
  --radius: 10px;
  --font: system-ui, -apple-system, "Segoe UI", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --surface-1: #1a1a19;
    --plane: #0d0d0d;
    --text-primary: #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted: #898781;
    --grid: #2c2c2a;
    --baseline: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --series-1: #3987e5;
    --series-2: #d95926;
    --good-text: #0ca30c;
  }
}

* { box-sizing: border-box; }

/* The hidden attribute must win over any class that sets a display value —
   several panels below are shown/hidden by toggling `hidden` in script. */
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--plane);
  color: var(--text-primary);
  font-size: 15px;
  line-height: 1.45;
}

/* ---------- chrome ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 28px;
  padding: 0 24px;
  background: var(--surface-1);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
  flex-wrap: wrap;
}
.brand {
  font-weight: 700;
  font-size: 17px;
  text-decoration: none;
  color: var(--text-primary);
  padding: 14px 0;
  letter-spacing: -0.01em;
}
.brand span { color: var(--series-1); }
.topbar nav { display: flex; gap: 4px; flex-wrap: wrap; }
.topbar nav a {
  padding: 16px 12px;
  text-decoration: none;
  color: var(--text-secondary);
  border-bottom: 2px solid transparent;
  font-size: 14px;
}
.topbar nav a:hover { color: var(--text-primary); }
.topbar nav a.active { color: var(--text-primary); border-bottom-color: var(--series-1); font-weight: 600; }

main { max-width: 1180px; margin: 0 auto; padding: 24px 24px 64px; }
.foot { text-align: center; color: var(--text-muted); font-size: 13px; padding: 0 24px 32px; }

h1 { font-size: 22px; margin: 0 0 4px; letter-spacing: -0.01em; }
h2 { font-size: 16px; margin: 0 0 14px; }
h3 { font-size: 14px; margin: 0 0 10px; color: var(--text-secondary); }
.sub { color: var(--text-secondary); margin: 0 0 20px; font-size: 14px; }

.page-head {
  display: flex; justify-content: space-between; align-items: flex-end;
  gap: 16px; flex-wrap: wrap; margin-bottom: 18px;
}

/* ---------- cards ---------- */
.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 18px;
}
.card.pad0 { padding: 0; overflow: hidden; }
.card.highlight { border-color: var(--series-1); box-shadow: 0 0 0 3px rgba(42, 120, 214, 0.12); }
.card-head {
  display: flex; justify-content: space-between; align-items: center;
  gap: 12px; flex-wrap: wrap; padding: 16px 18px; border-bottom: 1px solid var(--border);
}
.card-head h2 { margin: 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 860px) { .grid2 { grid-template-columns: 1fr; } }

/* ---------- stat tiles ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 18px; }
.tile {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.tile .label { color: var(--text-secondary); font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; }
.tile .value { font-size: 26px; font-weight: 650; margin-top: 4px; letter-spacing: -0.02em; }
.tile .hint { color: var(--text-muted); font-size: 12px; margin-top: 2px; }
.tile .value.good { color: var(--good-text); }
.tile .value.bad { color: var(--critical); }

/* ---------- tables ---------- */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead th {
  text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--text-muted); font-weight: 600; padding: 10px 12px;
  border-bottom: 1px solid var(--grid); white-space: nowrap;
}
tbody td { padding: 9px 12px; border-bottom: 1px solid var(--grid); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--plane); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tfoot td { padding: 11px 12px; border-top: 2px solid var(--baseline); font-weight: 650; }
.table-wrap { overflow-x: auto; }
.muted { color: var(--text-muted); }
.secondary { color: var(--text-secondary); }
.strong { font-weight: 650; }
.pos { color: var(--good-text); }
.neg { color: var(--critical); }

/* ---------- forms ---------- */
input[type="text"], input[type="number"], input[type="date"], input[type="search"], select {
  font: inherit;
  padding: 7px 9px;
  border: 1px solid var(--baseline);
  border-radius: 7px;
  background: var(--surface-1);
  color: var(--text-primary);
  max-width: 100%;
}
input:focus, select:focus { outline: 2px solid var(--series-1); outline-offset: 1px; border-color: var(--series-1); }
input.num { text-align: right; font-variant-numeric: tabular-nums; }
label { font-size: 13px; color: var(--text-secondary); display: block; margin-bottom: 4px; }
.field { display: flex; flex-direction: column; }
.form-row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.form-row .field { flex: 1 1 130px; }
.check { display: flex; align-items: center; gap: 6px; font-size: 14px; color: var(--text-secondary); }

.btn {
  font: inherit; font-size: 14px; font-weight: 600;
  padding: 8px 14px; border-radius: 7px; border: 1px solid var(--series-1);
  background: var(--series-1); color: #fff; cursor: pointer; text-decoration: none;
  display: inline-block; white-space: nowrap;
}
.btn:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; color: var(--text-primary); border-color: var(--baseline); }
.btn.ghost:hover { background: var(--plane); filter: none; }
.btn.danger { background: transparent; color: var(--critical); border-color: var(--border); }
.btn.danger:hover { background: rgba(208, 59, 59, 0.08); filter: none; }
.btn.sm { padding: 5px 9px; font-size: 13px; font-weight: 500; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.inline { display: inline; }

/* preset filter row */
.filters { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 18px; }
.presets { display: flex; gap: 4px; flex-wrap: wrap; }
.presets a {
  font-size: 13px; padding: 7px 11px; border-radius: 999px; text-decoration: none;
  color: var(--text-secondary); border: 1px solid var(--border); background: var(--surface-1);
}
.presets a:hover { color: var(--text-primary); }
.presets a.on { background: var(--series-1); border-color: var(--series-1); color: #fff; font-weight: 600; }

/* ---------- flashes ---------- */
.flashes { margin-bottom: 16px; display: flex; flex-direction: column; gap: 8px; }
.flash {
  padding: 10px 14px; border-radius: 8px; font-size: 14px;
  background: var(--surface-1); border: 1px solid var(--border);
  border-left: 3px solid var(--baseline);
}
.flash-ok { border-left-color: var(--good); }
.flash-error { border-left-color: var(--critical); }
.flash-warn { border-left-color: var(--warning); }

/* ---------- badges ---------- */
.badge {
  display: inline-block; font-size: 11px; font-weight: 600; padding: 2px 7px;
  border-radius: 999px; border: 1px solid var(--border); color: var(--text-secondary);
  background: var(--plane); text-transform: uppercase; letter-spacing: 0.03em;
}
.badge.warn { color: #8a5a00; border-color: rgba(250, 178, 25, 0.5); background: rgba(250, 178, 25, 0.14); }
.badge.off { color: var(--text-muted); }
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) .badge.warn { color: var(--warning); }
}

/* ---------- bar chart (single series) ---------- */
.chart { padding: 4px 2px 0; }
/* One honest reference line at the peak value; no decorative gridlines. */
.chart-scale {
  display: flex; align-items: center; gap: 8px;
  font-size: 11px; color: var(--text-muted); font-variant-numeric: tabular-nums;
}
.chart-scale::after { content: ""; flex: 1; height: 1px; background: var(--grid); }
.bars {
  display: flex; align-items: flex-end; gap: 2px; height: 180px;
  border-bottom: 1px solid var(--baseline); padding-bottom: 0;
}
.bar-col { flex: 1 1 0; height: 100%; display: flex; align-items: flex-end; position: relative; min-width: 8px; }
.bar {
  width: 100%;
  background: var(--series-1);
  border-radius: 4px 4px 0 0;
  min-height: 2px;
  transition: filter 0.12s ease;
}
.bar.zero { background: var(--grid); }
.bar-col:hover .bar { filter: brightness(1.12); }
.bar-col .tip {
  position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%);
  background: var(--text-primary); color: var(--surface-1);
  font-size: 12px; line-height: 1.35; padding: 6px 9px; border-radius: 6px;
  white-space: nowrap; opacity: 0; pointer-events: none; transition: opacity 0.1s ease; z-index: 5;
  font-variant-numeric: tabular-nums;
}
.bar-col:hover .tip { opacity: 1; }
/* Loss days: a marker under the bar, always paired with the count in the note. */
.loss-strip { display: flex; gap: 2px; margin-top: 2px; height: 3px; }
.loss-strip span { flex: 1 1 0; min-width: 8px; border-radius: 2px; }
.loss-strip span.loss { background: var(--critical); }
.loss-key {
  display: inline-block; width: 14px; height: 3px; border-radius: 2px;
  background: var(--critical); vertical-align: middle; margin: 0 3px 0 6px;
}

.xaxis { display: flex; gap: 2px; margin-top: 6px; }
.xaxis span {
  flex: 1 1 0; min-width: 8px; text-align: center; font-size: 11px;
  color: var(--text-muted); font-variant-numeric: tabular-nums;
  overflow: hidden; white-space: nowrap;
}
.chart-note { color: var(--text-muted); font-size: 12px; margin-top: 8px; }

/* cost share meter in the meal breakdown */
.meter { height: 6px; background: var(--grid); border-radius: 3px; overflow: hidden; min-width: 60px; }
.meter > span { display: block; height: 100%; background: var(--series-1); border-radius: 3px; }

.empty { text-align: center; color: var(--text-muted); padding: 28px 12px; font-size: 14px; }

/* ---------- till (POS) ----------
   Named .till-layout, not .pos: `.pos` is the positive-money text colour used
   on table cells, and a second .pos rule here turned every one of those cells
   into a grid container. */
.till-layout {
  display: grid; grid-template-columns: 1fr 340px;
  gap: 18px; margin-bottom: 18px; align-items: start;
}
@media (max-width: 900px) { .till-layout { grid-template-columns: 1fr; } }

.keypad {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 12px; padding: 16px 18px;
}
.key {
  font: inherit; text-align: left; cursor: pointer;
  display: flex; flex-direction: column; gap: 0;
  padding: 0; overflow: hidden;
  background: var(--plane); color: var(--text-primary);
  border: 1px solid var(--border); border-radius: var(--radius);
  transition: transform 0.06s ease, border-color 0.12s ease;
}
.key:hover { border-color: var(--series-1); }
.key:active { transform: scale(0.98); }
.key:focus-visible { outline: 2px solid var(--series-1); outline-offset: 2px; }

/* Meal picture: fixed band so every tile is the same height. */
.key-img {
  display: block; width: 100%; height: 104px; object-fit: cover;
  background: var(--surface-1); border-bottom: 1px solid var(--border);
}
.key-img-blank {
  display: flex; align-items: center; justify-content: center;
  font-size: 30px; font-weight: 650; color: var(--text-muted);
}
.key-text { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px 12px; }
.key-name { font-weight: 600; font-size: 14px; line-height: 1.25; }
.key-price { color: var(--text-secondary); font-size: 13px; font-variant-numeric: tabular-nums; }
.key-left { font-size: 11px; margin-top: 2px; }
.stock-note {
  margin: 0; padding: 7px 10px; font-size: 13px;
  color: var(--warning); background: rgba(250, 178, 25, 0.12);
  border-top: 1px solid rgba(250, 178, 25, 0.35);
}

.ticket { position: sticky; top: 74px; }
.order-lines { padding: 8px 12px; max-height: 46vh; overflow-y: auto; }
.order-line {
  display: grid; grid-template-columns: 1fr auto 70px 72px 22px;
  gap: 8px; align-items: center; padding: 8px 4px;
  border-bottom: 1px solid var(--grid);
}
.order-line:last-child { border-bottom: none; }
.ol-name { font-size: 14px; font-weight: 550; line-height: 1.2; }
.ol-qty { display: flex; align-items: center; gap: 2px; }
.ol-qty input { width: 46px; padding: 5px 4px; text-align: center; }
.step {
  font: inherit; font-size: 15px; line-height: 1; width: 26px; height: 28px;
  border: 1px solid var(--baseline); background: var(--surface-1); color: var(--text-primary);
  border-radius: 6px; cursor: pointer;
}
.step:hover { border-color: var(--series-1); color: var(--series-1); }
.ol-price { width: 100%; padding: 5px 6px; }
.ol-total { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; font-size: 14px; }
.ol-remove {
  font: inherit; font-size: 17px; line-height: 1; width: 22px; height: 22px; padding: 0;
  border: none; background: none; color: var(--text-muted); cursor: pointer; border-radius: 4px;
}
.ol-remove:hover { color: var(--critical); }

.order-heads {
  display: grid; grid-template-columns: 1fr auto 70px 72px 22px;
  gap: 8px; padding: 8px 16px 6px;
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--text-muted); border-bottom: 1px solid var(--grid);
}
.order-heads .ta-r { text-align: right; }

.customer-box { border-top: 1px solid var(--border); padding: 12px 18px 4px; }
.customer-box select { width: 100%; }
.walkin-check { margin-bottom: 8px; font-weight: 550; color: var(--text-primary); }
.lookup-row { display: flex; gap: 6px; }
.lookup-row input { flex: 1 1 auto; min-width: 0; }
.lookup-status { font-size: 12px; margin: 6px 0 0; color: var(--text-secondary); }
.lookup-status.found { color: var(--good-text); }
.lookup-status.missing { color: var(--critical); }
.link-toggle {
  font: inherit; font-size: 12px; background: none; border: none; padding: 0;
  color: var(--series-1); cursor: pointer;
}
.link-toggle:hover { text-decoration: underline; }
.new-customer { display: flex; flex-direction: column; gap: 6px; padding: 8px 0 2px; }

.matched-card {
  margin-top: 8px; padding: 9px 11px; border-radius: 8px;
  background: var(--plane); border: 1px solid var(--border);
  border-left: 3px solid var(--good);
}
.matched-card .mc-head { display: flex; justify-content: space-between; align-items: center; }
.matched-card .mc-tag {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted);
}
.matched-card .mc-name { font-weight: 650; font-size: 14px; line-height: 1.3; }
.matched-card .mc-line { font-size: 13px; color: var(--text-secondary); line-height: 1.35; }
.matched-card .mc-line.faint { color: var(--text-muted); font-style: italic; }
.matched-card .mc-pick { margin-top: 5px; }
.matched-card .mc-pick-head { font-size: 12px; color: var(--text-muted); margin-bottom: 3px; }
.matched-card .pick-addr {
  display: flex; gap: 6px; align-items: flex-start; font-size: 13px;
  padding: 4px 6px; margin-bottom: 4px; cursor: pointer;
  border: 1px solid var(--border); border-radius: 6px;
}
.matched-card .pick-addr input { flex: none; margin: 2px 0 0; }
.matched-card .pick-addr:has(input:checked) {
  border-color: var(--primary); background: color-mix(in srgb, var(--primary) 10%, transparent);
}
.matched-card .mc-points { margin-top: 5px; font-size: 12px; }
.matched-card .mc-earn { color: var(--good-text); }

/* Loyalty points */
.points {
  display: inline-block; font-weight: 650; font-variant-numeric: tabular-nums;
  padding: 1px 7px; border-radius: 999px;
  background: rgba(42, 120, 214, 0.14); color: var(--series-1);
}

.ticket-customer { margin-top: 8px; font-size: 12px; white-space: normal; max-width: 150px; }
.ticket-customer select.mini { font-size: 12px; padding: 3px 4px; width: 100%; margin: 4px 0 4px; }

.discount-box { border-top: 1px solid var(--border); padding: 12px 18px 4px; }
.discount-box label { margin-bottom: 5px; }
.discount-row { display: flex; gap: 6px; }
.discount-row select { flex: 0 0 96px; }
.discount-row input { flex: 1 1 auto; min-width: 0; }
.order-total .row.discount-line { color: var(--critical); }

.order-total { border-top: 1px solid var(--border); padding: 14px 18px 18px; }
.order-total .row { display: flex; justify-content: space-between; align-items: baseline; padding: 3px 0; font-size: 14px; }
.order-total .row.big { font-size: 17px; padding: 6px 0 10px; }
.order-total .row.big strong { font-size: 24px; font-weight: 650; letter-spacing: -0.02em; }
.order-total .row.muted { color: var(--text-muted); font-size: 13px; }
.order-total .row span, .order-total .row strong { font-variant-numeric: tabular-nums; }
.btn.wide { width: 100%; text-align: center; margin-top: 12px; padding: 11px; font-size: 15px; }

.ticket-cell { vertical-align: top; white-space: nowrap; border-right: 1px solid var(--grid); }
.ticket-cell .btn { margin-top: 6px; display: block; text-align: center; }

/* ---------- invoice / receipt ---------- */
.receipt {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 26px 24px 22px;
  max-width: 420px;
  margin: 0 auto;
  font-variant-numeric: tabular-nums;
}
.receipt-head { text-align: center; padding-bottom: 14px; border-bottom: 1px dashed var(--baseline); }
.receipt-head h2 { font-size: 20px; margin: 0 0 4px; letter-spacing: -0.01em; }
.receipt-head p { margin: 1px 0; font-size: 13px; color: var(--text-secondary); }

.receipt-meta { padding: 12px 0; border-bottom: 1px dashed var(--baseline); }
.receipt-meta div { display: flex; justify-content: space-between; font-size: 13px; padding: 2px 0; }
.receipt-meta span { color: var(--text-secondary); }

.receipt-customer { padding: 10px 0; border-bottom: 1px dashed var(--baseline); font-size: 13px; }
.receipt-customer .rc-label {
  color: var(--text-secondary); font-size: 11px; text-transform: uppercase;
  letter-spacing: 0.04em; margin-bottom: 2px;
}
.receipt-customer .faint { color: var(--text-muted); font-style: italic; }

.receipt-points {
  margin-top: 12px; padding: 10px 0 0; border-top: 1px dashed var(--baseline);
  display: flex; justify-content: space-between; align-items: baseline;
  flex-wrap: wrap; font-size: 13px;
}
.receipt-points strong { font-size: 15px; }
.receipt-points .rp-total { flex: 1 1 100%; color: var(--text-secondary); font-size: 12px; margin-top: 2px; }

.receipt-items { margin: 6px 0 0; }
.receipt-items thead th { border-bottom: 1px solid var(--grid); padding: 8px 4px; }
.receipt-items tbody td { padding: 7px 4px; border-bottom: 1px dotted var(--grid); }
.receipt-items tbody tr:hover { background: none; }

.receipt-total { border-top: 1px dashed var(--baseline); margin-top: 6px; padding-top: 10px; }
.receipt-total .row { display: flex; justify-content: space-between; align-items: baseline; padding: 2px 0; font-size: 13px; color: var(--text-secondary); }
.receipt-total .row.grand { font-size: 16px; color: var(--text-primary); padding-top: 6px; }
.receipt-total .row.grand strong { font-size: 22px; font-weight: 650; letter-spacing: -0.02em; }
.receipt-foot { text-align: center; font-size: 13px; color: var(--text-secondary); margin: 16px 0 0; padding-top: 12px; border-top: 1px dashed var(--baseline); }

/* ---------- print ---------- */
@media print {
  .no-print, .topbar, .foot, .flashes { display: none !important; }
  /* Print on white regardless of the screen theme. */
  :root {
    --surface-1: #ffffff; --plane: #ffffff; --text-primary: #000000;
    --text-secondary: #333333; --text-muted: #555555;
    --grid: #cccccc; --baseline: #999999; --border: #cccccc;
  }
  body { background: #fff; color: #000; font-size: 12pt; }
  main { max-width: none; margin: 0; padding: 0; }
  .card, .receipt { border: none; border-radius: 0; padding: 0; margin: 0; max-width: none; box-shadow: none; }
  .receipt-head h2 { font-size: 16pt; }
  .receipt-items thead th { color: #000; }
  a { color: #000; text-decoration: none; }
  table { page-break-inside: auto; }
  tr { page-break-inside: avoid; }
  thead { display: table-header-group; }
  @page { margin: 12mm; }
}

/* A customer waiting on a person, not just an unread message */
.pill-count.alert { background: #d08a00; color: #1b1204; }

/* The arrivals bell, on the orders board and in Chats. Muted look when off,
   and a nudge when the browser is holding sound back until someone clicks. */
.bell { border: 1px solid rgba(128,128,128,.45); background: transparent;
        border-radius: 999px; cursor: pointer; font-size: 12px; line-height: 1;
        padding: 3px 7px; margin-inline-start: 6px; vertical-align: middle; }
.bell.off { opacity: .4; filter: grayscale(1); }
.bell.blocked { border-color: #d08a00; background: #fff6e0;
                animation: bell-nudge 1.4s ease-in-out infinite; }
@keyframes bell-nudge { 0%, 100% { transform: none; } 50% { transform: scale(1.12); } }
