/* Hudson Wilder – KDS
   Matches hudsonwilder.com: Instrument Sans throughout, white / black / navy (#000B3B),
   light grey rules, uppercase letter-spaced labels, square corners. */

@font-face { font-family: "Instrument Sans"; font-weight: 400; font-style: normal; font-display: swap; src: url("/fonts/InstrumentSans-Regular.woff2") format("woff2"); }
@font-face { font-family: "Instrument Sans"; font-weight: 500; font-style: normal; font-display: swap; src: url("/fonts/InstrumentSans-Medium.woff2") format("woff2"); }
@font-face { font-family: "Instrument Sans"; font-weight: 700; font-style: normal; font-display: swap; src: url("/fonts/InstrumentSans-Bold.woff2") format("woff2"); }
@font-face { font-family: "Instrument Sans"; font-weight: 400; font-style: italic; font-display: swap; src: url("/fonts/InstrumentSans-Italic.woff2") format("woff2"); }

:root {
  color-scheme: light dark;
  --font-sans: "Instrument Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;

  /* hudsonwilder.com light scheme */
  --bg: #FFFFFF;
  --surface: #FFFFFF;
  --surface-2: #F5F5F5;
  --ink: #000000;
  --muted: #4D4D4D;
  --muted-2: #999999;
  --rule: #E1E1E1;
  --rule-strong: #000000;
  --navy: #000B3B;
  --navy-text: #F9F9F9;
  --navy-hover: #282828;
  --secondary: #EBEBEB;

  /* functional */
  --ok: #000B3B;
  --warn: #C8870E;
  --late: #D94C4C;
  --new: #000B3B;
  --note-bg: #F5F5F5;

  --radius: 0px;
  --topbar-h: 56px;
}

:root[data-theme="dark"] {
  --bg: #000620;
  --surface: #050B2B;
  --surface-2: #0E1538;
  --ink: #FFFFFF;
  --muted: #B3B8CC;
  --muted-2: #7D839E;
  --rule: #1E2650;
  --rule-strong: #FFFFFF;
  --navy: #FFFFFF;
  --navy-text: #000620;
  --navy-hover: #E6E6E6;
  --secondary: #141C45;
  --ok: #8FA0FF;
  --warn: #E0A030;
  --late: #FF6B61;
  --new: #FFFFFF;
  --note-bg: #0E1538;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #000620;
    --surface: #050B2B;
    --surface-2: #0E1538;
    --ink: #FFFFFF;
    --muted: #B3B8CC;
    --muted-2: #7D839E;
    --rule: #1E2650;
    --rule-strong: #FFFFFF;
    --navy: #FFFFFF;
    --navy-text: #000620;
    --navy-hover: #E6E6E6;
    --secondary: #141C45;
    --ok: #8FA0FF;
    --warn: #E0A030;
    --late: #FF6B61;
    --new: #FFFFFF;
    --note-bg: #0E1538;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.4;
  overscroll-behavior-y: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
  touch-action: manipulation;
}
button { font: inherit; color: inherit; cursor: pointer; }

/* site-style label: small caps, wide tracking */
.label { font-size: 11px; font-weight: 400; letter-spacing: 0.2em; text-transform: uppercase; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 18px;
  min-height: var(--topbar-h);
  padding: calc(8px + env(safe-area-inset-top)) calc(16px + env(safe-area-inset-right)) 0 calc(16px + env(safe-area-inset-left));
  background: var(--bg);
  border-bottom: 1px solid var(--rule-strong);
}
.brand { display: flex; align-items: center; gap: 10px; white-space: nowrap; padding-bottom: 10px; }
.brand-logo { display: block; height: 12px; width: auto; color: var(--ink); }
.brand-sep { font-size: 12px; color: var(--muted-2); line-height: 1; }
.brand-kds { font-size: 11px; font-weight: 500; letter-spacing: 0.3em; text-transform: uppercase; }

.tabs { display: flex; gap: 2px; margin-left: 8px; align-self: stretch; }
.tab {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 0 14px 8px;
  background: none; border: 0; border-bottom: 2px solid transparent;
  color: var(--muted); font-size: 12px; font-weight: 400; letter-spacing: 0.2em; text-transform: uppercase;
  margin-bottom: -1px;
}
.tab.is-active { color: var(--ink); border-bottom-color: var(--ink); }
.count {
  display: inline-block; min-width: 22px; padding: 2px 6px;
  background: var(--secondary); color: var(--ink);
  font-size: 11px; font-weight: 500; letter-spacing: 0; text-align: center; font-variant-numeric: tabular-nums;
}
.tab.is-active .count { background: var(--navy); color: var(--navy-text); }

.tools { margin-left: auto; display: flex; align-items: center; gap: 6px; padding-bottom: 10px; }
.status { display: flex; align-items: center; gap: 8px; margin-right: 8px; font-size: 11px; letter-spacing: 0.2em; text-transform: uppercase; color: var(--muted); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #2E7D4F; }
.status.is-stale .dot { background: var(--warn); }
.status.is-down .dot { background: var(--late); }
.icon-btn {
  width: 40px; height: 40px; border-radius: var(--radius);
  border: 1px solid var(--rule); background: var(--surface);
  display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn:active { background: var(--surface-2); }
.ico { width: 20px; height: 20px; }
#sound-btn .ico-off { display: none; }
#sound-btn[aria-pressed="false"] .ico-on { display: none; }
#sound-btn[aria-pressed="false"] .ico-off { display: block; }
#sound-btn[aria-pressed="false"] { color: var(--muted-2); }
.icon-btn[hidden] { display: none; }
.icon-btn.is-armed { background: var(--navy); border-color: var(--navy); color: var(--navy-text); }

.banner {
  position: sticky; top: calc(var(--topbar-h) + env(safe-area-inset-top)); z-index: 9;
  padding: 10px 16px; text-align: center; font-size: 12px; letter-spacing: 0.1em; text-transform: uppercase;
  background: var(--late); color: #fff;
}
.banner.is-info { background: var(--navy); color: var(--navy-text); }

/* ---------- views ---------- */
main { padding-bottom: calc(24px + env(safe-area-inset-bottom)); }
.view[hidden] { display: none; }
.grid {
  display: grid;
  gap: 12px;
  padding: 12px calc(12px + env(safe-area-inset-right)) 12px calc(12px + env(safe-area-inset-left));
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr));
  align-items: start;
}
.empty { padding: 80px 24px; text-align: center; color: var(--muted); }
.empty-title { font-size: 22px; font-weight: 400; letter-spacing: -0.02em; color: var(--ink); margin-bottom: 8px; }
.empty-sub { font-size: 13px; }

/* ---------- order card ---------- */
.card {
  position: relative;
  display: flex; flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  overflow: hidden;
  transition: opacity .22s ease, transform .22s ease;
}
.card-stripe { height: 5px; background: var(--ok); }
.card.is-warn .card-stripe { background: var(--warn); }
.card.is-late .card-stripe { background: var(--late); }
.card.is-cancelled .card-stripe { background: var(--late); }
.card.is-leaving { opacity: 0; transform: scale(.98); }
.card.is-new { animation: pulse 1.1s ease-out 3; }
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 color-mix(in srgb, var(--new) 45%, transparent); }
  100% { box-shadow: 0 0 0 14px transparent; }
}

.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 14px 16px 2px; }
.card-num { font-size: 30px; font-weight: 500; line-height: 1; letter-spacing: -0.04em; }
.card-num.is-long { font-size: 24px; letter-spacing: -0.03em; }
.card-meta { text-align: right; }
.timer { display: block; font-size: 22px; font-weight: 500; line-height: 1; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.card.is-warn .timer { color: var(--warn); }
.card.is-late .timer { color: var(--late); }
.placed { display: block; margin-top: 5px; font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted-2); }

.card-tags { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; padding: 8px 16px 12px; }
.badge {
  display: inline-block; padding: 6px 10px 5px; border-radius: var(--radius);
  border: 1px solid var(--ink);
  font-size: 10px; font-weight: 500; letter-spacing: 0.2em; text-transform: uppercase; line-height: 1;
}
.badge-togo { background: var(--navy); color: var(--navy-text); border-color: var(--navy); }
.badge-here { background: transparent; color: var(--ink); }
.badge-alert { background: var(--late); border-color: var(--late); color: #fff; }
.badge-unset { border-style: dashed; border-color: var(--muted-2); color: var(--muted-2); font-weight: 400; letter-spacing: 0.08em; text-transform: none; }
.badge-sm { padding: 3px 7px; font-size: 9px; }
.customer { font-size: 17px; font-weight: 700; letter-spacing: -0.01em; }
.customer.is-missing { font-weight: 400; font-style: italic; color: var(--muted-2); }
.staff { font-size: 12px; color: var(--muted-2); }

.items { list-style: none; margin: 0; padding: 0; }
.item {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 12px 16px;
  border-top: 1px solid var(--rule);
  font-size: 18px; line-height: 1.25;
  user-select: none; -webkit-user-select: none;
}
.item:active { background: var(--surface-2); }
.qty { min-width: 2.1ch; font-weight: 700; font-variant-numeric: tabular-nums; }
.qty::after { content: "×"; font-weight: 400; color: var(--muted-2); margin-left: 1px; }
.item-body { flex: 1; min-width: 0; }
.item-title { font-weight: 500; }
.item-sub { margin-top: 3px; font-size: 13px; color: var(--muted); }
.item.is-done .item-title, .item.is-done .qty { text-decoration: line-through; text-decoration-thickness: 2px; opacity: .35; }
.item.is-done .item-sub { opacity: .35; }
.check {
  flex: none; width: 26px; height: 26px; margin-top: -1px; border-radius: 50%;
  border: 1.5px solid var(--rule-strong); position: relative; opacity: .5;
}
.item.is-done .check { background: var(--navy); border-color: var(--navy); opacity: 1; }
.item.is-done .check::after {
  content: ""; position: absolute; left: 9px; top: 4px; width: 5px; height: 11px;
  border: solid var(--navy-text); border-width: 0 2px 2px 0; transform: rotate(45deg);
}
.item-muted { font-size: 12px; letter-spacing: 0.05em; color: var(--muted-2); padding-top: 9px; padding-bottom: 9px; }
.item-muted:active { background: transparent; }

.note {
  margin: 12px 16px 2px; padding: 10px 12px;
  background: var(--note-bg); border-left: 2px solid var(--navy);
  font-style: italic; font-size: 16px; line-height: 1.35;
  overflow-wrap: anywhere;
}
.attrs { margin: 10px 16px 0; font-size: 12px; color: var(--muted); }
.attrs span { display: inline-block; margin-right: 10px; }

.card-foot { padding: 12px 12px 12px; }
.progress { padding: 0 2px 8px; font-size: 11px; letter-spacing: 0.15em; text-transform: uppercase; color: var(--muted); text-align: center; }
.done-btn {
  width: 100%; height: 54px; border: 0; border-radius: var(--radius);
  background: var(--navy); color: var(--navy-text);
  font-size: 12px; font-weight: 500; letter-spacing: 0.3em; text-transform: uppercase;
  transition: transform .08s ease, background .08s ease;
}
.done-btn:active { transform: scale(.985); background: var(--navy-hover); }
.done-btn:disabled { opacity: .5; }

/* ---------- done list ---------- */
.list { padding: 8px calc(12px + env(safe-area-inset-right)) 8px calc(12px + env(safe-area-inset-left)); }
.row {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 16px; margin-bottom: 8px;
  background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius);
}
.row-num { font-size: 20px; font-weight: 500; min-width: 68px; letter-spacing: -0.03em; }
.row-num.is-long { font-size: 16px; min-width: 100px; }
.row-main { flex: 1; min-width: 0; }
.row-top { display: flex; gap: 8px; align-items: center; font-size: 14px; font-weight: 500; }
.row-sum { margin-top: 3px; font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-time { font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted-2); font-variant-numeric: tabular-nums; }
.undo-btn, .clear-btn {
  height: 40px; padding: 0 16px; border-radius: var(--radius);
  border: 1px solid var(--rule-strong); background: transparent; color: var(--ink);
  font-size: 11px; font-weight: 500; letter-spacing: 0.2em; text-transform: uppercase;
}
.undo-btn:active, .clear-btn:active { background: var(--secondary); }
.clear-btn:disabled { opacity: .35; }
.clear-btn.is-armed { background: var(--late); border-color: var(--late); color: #fff; }
.list-tools {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px;
  padding: 12px calc(12px + env(safe-area-inset-right)) 4px calc(12px + env(safe-area-inset-left));
}
.list-hint { font-size: 12px; color: var(--muted-2); }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  z-index: 20; max-width: min(92vw, 480px);
  display: flex; align-items: center; gap: 14px;
  padding: 12px 16px; border-radius: var(--radius);
  background: var(--navy); color: var(--navy-text); font-size: 13px; font-weight: 500;
  box-shadow: 0 8px 24px rgba(0,0,0,.25);
}
.toast[hidden] { display: none; }
.toast-btn {
  height: 32px; padding: 0 12px; border-radius: var(--radius); border: 1px solid var(--navy-text);
  background: transparent; color: var(--navy-text); font-size: 11px; font-weight: 500; letter-spacing: 0.15em; text-transform: uppercase;
}

/* ---------- login ---------- */
.login-body { display: grid; place-items: center; padding: 24px; }
.login { width: min(100%, 360px); display: flex; flex-direction: column; gap: 12px; }
.login .brand { margin-bottom: 12px; }
.login .brand-logo { height: 16px; }
.login label { font-size: 11px; letter-spacing: 0.2em; text-transform: uppercase; color: var(--muted); }
.login input { height: 50px; padding: 0 14px; border: 1px solid #CCCCCC; border-radius: var(--radius); background: var(--surface); color: var(--ink); font: inherit; font-size: 17px; }
.login-error { margin: 0; color: var(--late); font-size: 13px; }
.login-hint { margin: 4px 0 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.login-notice { margin: 0 0 8px; padding: 12px 14px; background: var(--secondary); color: var(--ink); font-size: 13px; line-height: 1.5; }

/* ---------- phones ---------- */
@media (max-width: 640px) {
  .topbar { flex-wrap: wrap; row-gap: 0; column-gap: 10px; padding-top: calc(10px + env(safe-area-inset-top)); }
  .topbar .brand { order: 1; }
  .tools { order: 2; }
  .tabs { order: 3; width: 100%; margin-left: 0; margin-top: 2px; }
  .tab { flex: 1; justify-content: center; padding-bottom: 10px; }
  .status-text { display: none; }
  .topbar .brand-logo { height: 11px; }
  .grid { grid-template-columns: 1fr; }
  .card-num { font-size: 28px; }
  .card-num.is-long { font-size: 22px; }
  .card-head { gap: 8px; }
  .timer { font-size: 20px; }
  :root { --topbar-h: 96px; }
}
@media (min-width: 1100px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
}
@media (prefers-reduced-motion: reduce) {
  .card, .done-btn { transition: none; }
  .card.is-new { animation: none; outline: 2px solid var(--new); }
}

/* ---------- guest access (pop-ups) ---------- */
[hidden] { display: none !important; }
.guest-bar {
  position: sticky; top: calc(var(--topbar-h) + env(safe-area-inset-top)); z-index: 9;
  padding: 8px 16px; text-align: center; font-size: 11px; letter-spacing: 0.15em; text-transform: uppercase;
  background: var(--secondary); color: var(--ink); border-bottom: 1px solid var(--rule);
}
.is-guest .list-tools { display: none; }
.sheet {
  position: fixed; inset: 0; z-index: 30; background: rgba(0, 6, 32, 0.55);
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet-panel {
  width: min(100%, 520px); max-height: 92vh; overflow: auto;
  background: var(--bg); color: var(--ink);
  padding: 14px 20px calc(20px + env(safe-area-inset-bottom)); border-top: 1px solid var(--rule-strong);
}
.sheet-head { display: flex; align-items: center; justify-content: space-between; }
.sheet-title { margin: 0; font-size: 12px; font-weight: 500; letter-spacing: 0.3em; text-transform: uppercase; }
.sheet-sub { margin: 6px 0 16px; font-size: 13px; color: var(--muted); line-height: 1.5; }
.share-form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; border: 0; padding: 0; margin: 0; min-width: 0; }
.field .label { font-size: 11px; letter-spacing: 0.2em; text-transform: uppercase; color: var(--muted); }
.field input[type="text"], .field select, .field input[type="datetime-local"] {
  height: 46px; padding: 0 12px; border: 1px solid #CCCCCC; border-radius: var(--radius);
  background: var(--surface); color: var(--ink); font: inherit; font-size: 16px;
}
.choice { display: flex; align-items: center; gap: 10px; padding: 8px 0; font-size: 15px; }
.choice input { width: 20px; height: 20px; margin: 0; accent-color: var(--navy); }
.choice-group { margin-left: auto; font-size: 10px; letter-spacing: 0.15em; text-transform: uppercase; color: var(--muted-2); }
.scope-list { max-height: 220px; overflow: auto; border: 1px solid var(--rule); padding: 2px 12px; }
.share-result { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.qr svg { display: block; width: min(100%, 320px); height: auto; border: 1px solid var(--rule); }
.share-meta { margin: 0; font-size: 13px; color: var(--muted); text-align: center; }
.share-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.sheet-foot { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--rule); display: flex; justify-content: center; }
.revoke-btn {
  height: 40px; padding: 0 16px; border-radius: var(--radius);
  border: 1px solid var(--late); background: transparent; color: var(--late);
  font-size: 11px; font-weight: 500; letter-spacing: 0.2em; text-transform: uppercase;
}
.revoke-btn.is-armed { background: var(--late); color: #fff; }
@media (min-width: 640px) {
  .sheet { align-items: center; }
  .sheet-panel { border: 1px solid var(--rule-strong); }
}
