:root {
  --bg: #080808;
  --panel: #141414;
  --panel-2: #1d1d1d;
  --line: #2a2a2a;
  --text: #f2f2f2;
  --muted: #9a9a9a;
  --brand: #ed5e2a;
  --brand-ink: #ffffff;
  --go: #2fbf71;
  --warn: #f2b33d;
  --bad: #e5484d;
  --radius: 14px;
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { min-height: 100dvh; -webkit-font-smoothing: antialiased; }
a { color: var(--brand); }
button, input, select, textarea { font: inherit; color: inherit; }
.wrap { max-width: 480px; margin: 0 auto; padding: 16px; }
.wide { max-width: 1180px; }

.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 4px 0 16px; }
.logo { font-weight: 800; letter-spacing: .02em; font-size: 18px; }
.logo b { color: var(--brand); }
.chip { font-size: 13px; color: var(--muted); background: var(--panel); border: 1px solid var(--line); padding: 6px 10px; border-radius: 999px; }
.linkbtn { background: none; border: 0; color: var(--muted); text-decoration: underline; cursor: pointer; padding: 6px; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.card + .card { margin-top: 12px; }
h1 { font-size: 26px; margin: 0 0 4px; }
h2 { font-size: 17px; margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

.btn { display: block; width: 100%; border: 0; border-radius: var(--radius); padding: 18px; font-size: 20px; font-weight: 800; cursor: pointer; letter-spacing: .02em; }
.btn:disabled { opacity: .45; cursor: default; }
.btn-start { background: var(--go); color: #06210f; }
.btn-finish { background: var(--brand); color: var(--brand-ink); }
.btn-ghost { background: var(--panel-2); color: var(--text); font-size: 16px; padding: 14px; font-weight: 600; }
.btn-sm { display: inline-block; width: auto; font-size: 14px; padding: 9px 14px; border-radius: 10px; font-weight: 700; }
.btn-brand { background: var(--brand); color: var(--brand-ink); }

/* PIN pad */
.dots { display: flex; justify-content: center; gap: 14px; margin: 18px 0 22px; }
.dots span { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--muted); }
.dots span.on { background: var(--brand); border-color: var(--brand); }
.pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.pad button { background: var(--panel-2); border: 1px solid var(--line); border-radius: 16px; font-size: 28px; font-weight: 700; padding: 18px 0; cursor: pointer; }
.pad button:active { background: var(--brand); }
.pad .fn { font-size: 16px; color: var(--muted); }

.status { display: inline-block; font-size: 12px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; padding: 5px 9px; border-radius: 6px; }
.s-new { background: #2a2a2a; color: #ddd; }
.s-in_progress { background: rgba(242,179,61,.16); color: var(--warn); }
.s-hold { background: rgba(229,72,77,.18); color: #ff8a8e; }
.hold { border-color: var(--bad); background: rgba(229,72,77,.10); }
.hold-t { color: #ff8a8e; font-weight: 800; letter-spacing: .04em; margin-bottom: 6px; }
.hold .small { color: var(--muted); margin-top: 6px; }
.s-packed { background: rgba(80,140,255,.16); color: #8fb4ff; }
.s-done { background: rgba(47,191,113,.16); color: var(--go); }

.items { list-style: none; margin: 0; padding: 0; }
.items li { padding: 10px 0; border-top: 1px solid var(--line); }
.items li:first-child { border-top: 0; }
.qty { display: inline-block; min-width: 28px; font-weight: 800; color: var(--brand); }
.opt { font-size: 13px; color: var(--muted); margin-left: 28px; }
.note { white-space: pre-wrap; background: var(--panel-2); border-radius: 10px; padding: 10px 12px; font-size: 14px; }
.timer { font-variant-numeric: tabular-nums; font-size: 34px; font-weight: 800; text-align: center; margin: 6px 0 12px; }

.msg { margin-top: 12px; padding: 12px; border-radius: 10px; font-size: 15px; display: none; }
.msg.show { display: block; }
.msg.err { background: rgba(229,72,77,.14); color: #ff9b9e; }
.msg.ok { background: rgba(47,191,113,.14); color: #8be3b2; }

input[type=text], input[type=password], input[type=number], input[type=date], select, textarea {
  width: 100%; background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--brand); }
label { display: block; font-size: 13px; color: var(--muted); margin: 0 0 6px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; }
.row > * { flex: 1 1 140px; }

/* admin */
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.tabs button { background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 8px 14px; cursor: pointer; font-weight: 600; }
.tabs button.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 12px; }
.kpis .card { margin-top: 0; }
.kpi .v { font-size: 30px; font-weight: 800; font-variant-numeric: tabular-nums; }
.kpi .k { font-size: 13px; color: var(--muted); }
.tablewrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.bar { height: 8px; background: var(--brand); border-radius: 4px; }
.chart { display: flex; align-items: flex-end; gap: 4px; height: 140px; padding-top: 10px; }
.chart div { flex: 1; background: var(--brand); border-radius: 4px 4px 0 0; position: relative; min-height: 2px; }
.chart div span { position: absolute; top: -18px; left: 0; right: 0; text-align: center; font-size: 11px; color: var(--muted); }
.chart-x { display: flex; gap: 4px; font-size: 10px; color: var(--muted); }
.chart-x span { flex: 1; text-align: center; overflow: hidden; }
.hidden { display: none !important; }

/* printable QR labels */
.labels { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; margin-top: 12px; }
.label { background: #fff; color: #000; border-radius: 10px; padding: 12px; text-align: center; }
.label .ref { font-weight: 800; font-size: 16px; margin-top: 6px; }
.label .t { font-size: 12px; }
@media print {
  body { background: #fff; }
  body * { visibility: hidden; }
  #printArea, #printArea * { visibility: visible; }
  #printArea { position: absolute; left: 0; top: 0; width: 100%; }
  .label { border: 1px dashed #999; break-inside: avoid; }
}

/* order detail dialog */
dialog { width: min(640px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); background: var(--bg); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
dialog::backdrop { background: rgba(0,0,0,.7); }
.dlg-head { display: flex; justify-content: space-between; align-items: start; gap: 12px; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
td.clip { max-width: 260px; overflow: hidden; text-overflow: ellipsis; }

.scan-card { display: flex; gap: 16px; align-items: center; }
.scan-card img { background: #fff; border-radius: 10px; padding: 6px; flex: 0 0 auto; }
.badge img { width: 100%; max-width: 150px; }
@media print {
  body.printing-badges #printArea, body.printing-badges #printArea * { visibility: hidden !important; }
  body.printing-badges #badgeArea { display: block !important; }
  body.printing-badges #badgeArea, body.printing-badges #badgeArea * { visibility: visible; }
  body.printing-badges #badgeArea { position: absolute; left: 0; top: 0; width: 100%; }
  .badge { border: 2px solid #000; }
}

.eff { font-weight: 800; font-variant-numeric: tabular-nums; }
.eff-good { color: var(--go); } .eff-ok { color: var(--text); } .eff-low { color: var(--warn); }
.score-total { font-size: 18px; font-weight: 800; margin-bottom: 8px; }
.rules input { padding: 7px 9px; font-size: 13px; }
code { background: var(--panel-2); padding: 1px 5px; border-radius: 4px; font-size: 12px; }

.items li.extras { font-size: 13px; color: var(--muted); }
@media (max-width: 560px) {
  .wide .top { flex-wrap: wrap; row-gap: 8px; }
  .wide .top .logo { font-size: 16px; }
  .wide .top .chip { font-size: 12px; padding: 4px 8px; }
  .scan-card { flex-direction: column; align-items: flex-start; }
}

/* ON HOLD — can't assign (big red sign + small pill) */
.holdsign { background: #c62828; color: #fff; border-radius: var(--radius); padding: 16px 18px; margin: 0 0 12px; box-shadow: 0 0 0 3px rgba(229,72,77,.35); }
.holdsign .big { font-size: 26px; font-weight: 900; letter-spacing: .03em; line-height: 1.1; }
.holdsign .ord { font-size: 18px; font-weight: 800; margin-top: 8px; }
.holdsign .why { font-size: 15px; margin-top: 4px; background: rgba(0,0,0,.18); border-radius: 8px; padding: 8px 10px; white-space: pre-wrap; }
.holdsign .who { font-size: 13px; opacity: .92; margin-top: 8px; }
.holdpill { display: inline-block; background: #c62828; color: #fff; font-weight: 900; font-size: 12px; letter-spacing: .06em; padding: 6px 10px; border-radius: 6px; }
tr.held td { background: rgba(198,40,40,.10); }

/* Important notes (overdue orders) */
.notes { background: rgba(242,179,61,.08); border: 1px solid rgba(242,179,61,.55); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 14px; }
.notes.calm { background: var(--panel); border-color: var(--line); }
.notes h2 { margin: 0; font-size: 16px; color: var(--warn); }
.notes.calm h2 { color: var(--text); }
.notes-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.notes-head .small { color: var(--muted); margin-top: 2px; }
.od-form { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.od-form label { margin: 0; font-size: 13px; }
.od-ctl { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }
.od-form input { width: 70px; padding: 7px 9px; text-align: center; }
.notes-list { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 6px; }
.notes.calm .notes-list:empty { display: none; }
.note-row { width: 100%; display: grid; grid-template-columns: 80px minmax(0, 1fr) auto; gap: 12px; align-items: center; text-align: left;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; cursor: pointer; }
.note-row:hover, .note-row:focus-visible { border-color: var(--warn); outline: none; }
.note-days { font-weight: 800; color: var(--warn); font-variant-numeric: tabular-nums; }
.note-days.very { color: #ff8a8e; }
.note-main { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.note-who { color: var(--muted); font-size: 13px; white-space: nowrap; }
.notes-foot { margin-top: 8px; }
.notes-foot:empty { display: none; }
.s-late { background: rgba(242,179,61,.16); color: var(--warn); }
@media (max-width: 640px) {
  .note-row { grid-template-columns: 64px minmax(0, 1fr); }
  .note-who { grid-column: 2; white-space: normal; }
}
