:root {
  color-scheme: dark;
  --bg: #120b0d;
  --surface: #1d1214;
  --surface-2: #28191a;
  --border: #422a26;
  --text: #f6ebdd;
  --muted: #b39a86;
  --accent: #ff7a1a;
  --accent-ink: #2b1100;
  --new: #f2c14e;
  --preparing: #b583ff;
  --ready: #ff7a1a;
  --danger: #ff5a5a;
  --radius: 14px;
}

* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
button { font: inherit; color: inherit; cursor: pointer; }
h1, h2, p { margin: 0; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-box { width: 100%; max-width: 360px; display: grid; gap: 14px; }
.login-box h1 { font-size: 28px; }
.key {
  width: 100%; min-height: 56px; padding: 0 16px; font-size: 18px; letter-spacing: 2px;
  background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: var(--radius);
  -webkit-text-security: disc;
}
.key:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.primary {
  min-height: 56px; border: 0; border-radius: var(--radius);
  background: var(--accent); color: var(--accent-ink); font-weight: 700; font-size: 17px;
}
.primary:disabled { opacity: 0.6; }
.error { color: var(--danger); }

/* Top */
.bar-top {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; background: rgba(18, 11, 13, 0.95); border-bottom: 1px solid var(--border);
}
.bar-top h1 { font-size: 20px; }
.conn { color: var(--accent); font-size: 12px; }
.conn.off { color: var(--danger); }
.bar-actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.pill {
  min-height: 40px; padding: 0 14px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--border); font-size: 14px;
}

/* Column tabs (phones) */
.col-tabs { display: none; }
@media (max-width: 899px) {
  .col-tabs {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px;
    padding: 10px 16px; position: sticky; top: 65px; z-index: 4; background: var(--bg);
  }
  .col-tabs button {
    min-height: 48px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); font-size: 14px;
  }
  .col-tabs button b { display: inline-block; margin-left: 4px; font-variant-numeric: tabular-nums; }
  .col-tabs button.active { border-color: var(--accent); color: var(--accent); }
  .col-tabs button.pending b { color: var(--new); }
  .board .col { display: none; }
  .board[data-show="new"] .col[data-col="new"],
  .board[data-show="preparing"] .col[data-col="preparing"],
  .board[data-show="ready"] .col[data-col="ready"] { display: block; }
  .col h2 { display: none; }
}

/* Board */
.board { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; padding: 16px; align-items: start; }
@media (max-width: 899px) { .board { grid-template-columns: 1fr; padding-top: 6px; } }
.col h2 {
  font-size: 13px; text-transform: uppercase; letter-spacing: 1.5px; color: var(--muted);
  margin-bottom: 10px; padding-left: 4px;
}
.col[data-col="new"] h2 { color: var(--new); }
.col[data-col="preparing"] h2 { color: var(--preparing); }
.col[data-col="ready"] h2 { color: var(--ready); }
.list { display: grid; gap: 12px; }
.empty { color: var(--muted); text-align: center; padding: 28px 0; border: 1px dashed var(--border); border-radius: var(--radius); }

.ticket {
  background: var(--surface); border: 1px solid var(--border); border-left: 5px solid var(--muted);
  border-radius: var(--radius); padding: 14px;
}
.ticket.new { border-left-color: var(--new); }
.ticket.preparing { border-left-color: var(--preparing); }
.ticket.ready { border-left-color: var(--ready); }
.ticket.flash { animation: flash 1s ease-in-out 3; }
@keyframes flash { 50% { background: rgba(242, 193, 78, 0.18); } }
.t-head { display: flex; align-items: baseline; gap: 10px; }
.t-table { font-size: 26px; font-weight: 800; }
.t-code { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; color: var(--muted); }
.t-age { margin-left: auto; font-variant-numeric: tabular-nums; color: var(--muted); }
.t-age.late { color: var(--danger); font-weight: 700; }
.t-items { list-style: none; padding: 0; margin: 10px 0 0; }
.t-items li { padding: 8px 0; border-top: 1px solid var(--border); }
.t-items li:first-child { border-top: 0; }
.t-qty { font-weight: 800; margin-right: 6px; }
.t-name { font-weight: 600; font-size: 17px; }
.t-opts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.t-opt { font-size: 13px; padding: 2px 8px; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--border); }
.t-note {
  margin-top: 10px; padding: 8px 10px; border-radius: 8px;
  background: rgba(242, 193, 78, 0.12); color: var(--new); font-weight: 600;
}
.t-actions { display: flex; gap: 8px; margin-top: 12px; }
.t-actions button { min-height: 52px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface-2); font-weight: 600; }
.t-actions .go { flex: 1; border: 0; color: #1a0c06; }
.ticket.new .go { background: var(--new); }
.ticket.preparing .go { background: var(--preparing); }
.ticket.ready .go { background: var(--ready); }
.t-actions .side { padding: 0 14px; color: var(--muted); }
.t-actions .reject { color: var(--danger); }

/* Sold-out panel */
.panel { position: fixed; inset: 0; z-index: 20; display: flex; justify-content: flex-end; }
.panel-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.6); }
.panel-box {
  position: relative; width: 100%; max-width: 440px; height: 100%; overflow-y: auto;
  background: var(--surface); border-left: 1px solid var(--border); padding: 22px 18px 40px;
}
.panel-box h2 { font-size: 22px; padding-right: 48px; margin-bottom: 4px; }
.panel-close {
  position: absolute; top: 14px; right: 14px; width: 44px; height: 44px; border-radius: 50%;
  border: 1px solid var(--border); background: var(--surface-2);
}
.stock-group { margin-top: 20px; }
.stock-group h3 { font-size: 13px; text-transform: uppercase; letter-spacing: 1.5px; color: var(--muted); margin: 0 0 6px; }
.stock-row {
  width: 100%; display: flex; justify-content: space-between; align-items: center; gap: 12px;
  min-height: 52px; padding: 0 4px; background: none; border: 0; border-bottom: 1px solid var(--border); text-align: left;
}
.switch { width: 52px; height: 30px; border-radius: 15px; background: var(--border); position: relative; flex: none; transition: background 0.15s; }
.switch::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%;
  background: #fff; transition: transform 0.15s;
}
.stock-row[aria-pressed="true"] .switch { background: var(--accent); }
.stock-row[aria-pressed="true"] .switch::after { transform: translateX(22px); }
.stock-row[aria-pressed="false"] span:first-child { color: var(--muted); text-decoration: line-through; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 40;
  max-width: calc(100% - 32px); background: #f6ebdd; color: #2b1100; border-radius: 12px; padding: 12px 16px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}
.toast.error { background: var(--danger); color: #fff; }

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
