:root {
  --bg: #121010;
  --panel: #1d1a19;
  --panel-2: #272322;
  --line: #3a3432;
  --text: #f6efe6;
  --muted: #b3a79d;
  --saffron: #f0ac45;
  --green: #4fbf6a;
  --green-bg: #173622;
  --amber: #f0ac45;
  --amber-bg: #3d2c12;
  --red: #ff5d52;
  --red-bg: #461915;
  --blue: #6aa8ff;
  --radius: 14px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 17px/1.4 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; cursor: pointer; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--saffron); outline-offset: 2px; }
.kds-loading { padding: 48px 16px; text-align: center; color: var(--muted); }

/* ---- Sign in ---- */
.signin { max-width: 760px; margin: 0 auto; padding: 32px 16px; }
.signin h1 { font-size: 1.8rem; margin: 0 0 4px; }
.signin h1 span { color: var(--saffron); }
.signin p { color: var(--muted); margin: 0 0 24px; }
.screen-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
.screen-tile {
  background: var(--panel);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  padding: 22px 16px;
  font-size: 1.15rem;
  font-weight: 700;
  text-align: left;
  min-height: 96px;
}
.screen-tile small { display: block; font-weight: 500; color: var(--muted); font-size: .85rem; margin-top: 4px; text-transform: capitalize; }
.screen-tile:hover { border-color: var(--saffron); }
.screen-tile[disabled] { opacity: .4; cursor: not-allowed; }
.pinpad { max-width: 340px; margin: 0 auto; text-align: center; }
.pin-dots { display: flex; justify-content: center; gap: 14px; margin: 20px 0; min-height: 24px; }
.pin-dots span { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--muted); }
.pin-dots span.on { background: var(--saffron); border-color: var(--saffron); }
.keys { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.keys button { background: var(--panel-2); border: 0; border-radius: var(--radius); font-size: 1.6rem; font-weight: 700; padding: 18px 0; }
.keys button:active { background: var(--line); }
.keys .ok { background: var(--saffron); color: #1b1410; }
.pin-error { color: var(--red); min-height: 1.4em; margin: 10px 0 0; font-weight: 600; }
.link-btn { background: none; border: 0; color: var(--muted); text-decoration: underline; margin-top: 18px; }

/* ---- Top bar ---- */
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 10px 16px;
  background: #0b0909;
  border-bottom: 1px solid var(--line);
}
.topbar .where { font-weight: 800; font-size: 1.25rem; }
.topbar .where small { color: var(--saffron); font-weight: 700; margin-right: 8px; font-size: .9rem; letter-spacing: .04em; text-transform: uppercase; }
.topbar .spacer { flex: 1; }
.clock { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 1.2rem; }
.live { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: .85rem; }
.live::before { content: ''; width: 10px; height: 10px; border-radius: 50%; background: var(--red); }
.live.on::before { background: var(--green); }
.tabs { display: flex; gap: 6px; padding: 10px 16px 0; flex-wrap: wrap; }
.tab { background: var(--panel); border: 2px solid var(--line); border-radius: 999px; padding: 8px 16px; font-weight: 700; }
.tab[aria-pressed='true'] { background: var(--text); color: var(--bg); border-color: var(--text); }
.tab .count { display: inline-block; min-width: 1.6em; margin-left: 6px; padding: 0 6px; border-radius: 999px; background: var(--saffron); color: #1b1410; font-size: .85rem; }
.signout { background: none; border: 1px solid var(--line); border-radius: 999px; padding: 6px 14px; color: var(--muted); }

/* ---- Tickets ---- */
.board { padding: 14px 16px 40px; display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); align-items: start; }
.empty { grid-column: 1 / -1; text-align: center; color: var(--muted); padding: 60px 16px; font-size: 1.15rem; }
.ticket { background: var(--panel); border-radius: var(--radius); overflow: hidden; border: 2px solid var(--line); }
.ticket.flash { animation: flash 1s ease-in-out 3; }
@keyframes flash { 50% { border-color: var(--saffron); box-shadow: 0 0 0 4px rgb(240 172 69 / 45%); } }
.t-head { display: flex; align-items: baseline; gap: 10px; padding: 10px 14px; background: var(--green-bg); border-bottom: 3px solid var(--green); }
.ticket.amber .t-head { background: var(--amber-bg); border-color: var(--amber); }
.ticket.red .t-head { background: var(--red-bg); border-color: var(--red); }
.t-label { font-weight: 800; font-size: 1.2rem; flex: 1; overflow-wrap: anywhere; }
.t-timer { font-variant-numeric: tabular-nums; font-weight: 800; font-size: 1.2rem; }
.t-meta { display: flex; gap: 8px; flex-wrap: wrap; padding: 8px 14px 0; color: var(--muted); font-size: .9rem; }
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .8rem; font-weight: 700; background: var(--panel-2); color: var(--text); }
.badge.due { background: #24324a; color: #cfe0ff; }
.badge.id { background: #3b2a4a; color: #e8d4ff; }
.allergy { margin: 10px 14px 0; padding: 8px 10px; border-radius: 10px; background: var(--red); color: #fff; font-weight: 800; }
.allergy::before { content: '⚠ ALLERGY: '; }
.notes { margin: 10px 14px 0; padding: 8px 10px; border-radius: 10px; background: var(--panel-2); }
.items { list-style: none; margin: 10px 0 0; padding: 0; }
.item {
  display: flex; align-items: center; gap: 10px;
  width: 100%;
  padding: 11px 14px;
  border: 0; border-top: 1px solid var(--line);
  background: none; text-align: left;
  font-size: 1.12rem;
}
.item .qty { font-weight: 800; min-width: 2.2em; }
.item .name { flex: 1; font-weight: 600; }
.item .stn { font-size: .75rem; color: var(--muted); font-weight: 600; text-transform: uppercase; }
.item .state { font-size: .8rem; font-weight: 800; padding: 3px 9px; border-radius: 999px; background: var(--panel-2); color: var(--muted); text-transform: uppercase; }
.item.cooking .state { background: var(--amber); color: #1b1410; }
.item.ready .state { background: var(--green); color: #0d1f12; }
.item.ready .name { text-decoration: line-through; color: var(--muted); }
button.item:hover { background: var(--panel-2); }
.item[disabled] { cursor: default; }
.t-actions { display: flex; gap: 8px; padding: 12px 14px 14px; flex-wrap: wrap; }
.btn { flex: 1; border: 0; border-radius: 12px; padding: 14px 12px; font-weight: 800; font-size: 1.05rem; background: var(--panel-2); min-height: 52px; }
.btn.go { background: var(--green); color: #0d1f12; }
.btn.warm { background: var(--saffron); color: #1b1410; }
.btn.quiet { background: none; border: 2px solid var(--line); color: var(--muted); flex: 0 1 auto; }
.btn[disabled] { opacity: .35; cursor: not-allowed; }
.t-extra { padding: 8px 14px 0; font-size: .95rem; }
.t-extra a { color: var(--blue); }
.error-toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%);
  background: var(--red); color: #fff; font-weight: 700;
  padding: 12px 18px; border-radius: 12px; z-index: 20; max-width: calc(100vw - 32px);
}

/* ---- Front of house: new table order ---- */
.foh { padding: 14px 16px 40px; display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr) 340px; align-items: start; }
.foh h2 { font-size: 1.1rem; margin: 0 0 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.table-grid { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); margin-bottom: 20px; }
.table-btn { background: var(--panel); border: 2px solid var(--line); border-radius: 12px; padding: 10px; text-align: left; }
.table-btn strong { font-size: 1.2rem; display: block; }
.table-btn small { color: var(--muted); display: block; font-size: .78rem; }
.table-btn[aria-pressed='true'] { border-color: var(--saffron); background: var(--amber-bg); }
.menu-group { margin-bottom: 16px; }
.menu-group h3 { margin: 0 0 8px; font-size: 1rem; }
.menu-btns { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
.menu-btn { background: var(--panel); border: 2px solid var(--line); border-radius: 12px; padding: 10px 12px; text-align: left; min-height: 64px; }
.menu-btn span { display: block; color: var(--muted); font-size: .85rem; }
.menu-btn.added { border-color: var(--green); }
.order-pad { position: sticky; top: 76px; background: var(--panel); border: 2px solid var(--line); border-radius: var(--radius); padding: 14px; }
.order-pad ul { list-style: none; margin: 0 0 10px; padding: 0; }
.order-pad li { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.order-pad li span { flex: 1; }
.step { width: 38px; height: 38px; border-radius: 50%; border: 0; background: var(--panel-2); font-weight: 800; font-size: 1.2rem; }
.order-pad textarea, .order-pad input {
  width: 100%; margin: 6px 0 10px; padding: 10px; border-radius: 10px; border: 2px solid var(--line);
  background: var(--bg); color: var(--text); font: inherit;
}
.order-pad label { font-weight: 700; font-size: .9rem; color: var(--muted); }
.order-pad .total { display: flex; justify-content: space-between; font-weight: 800; margin: 6px 0 12px; }
@media (max-width: 820px) {
  .foh { grid-template-columns: minmax(0, 1fr); }
  .order-pad { position: static; }
}
@media (prefers-reduced-motion: reduce) { .ticket.flash { animation: none; border-color: var(--saffron); } }
