:root {
  --ink: #173a5e;          /* same navy as the Picking List header row */
  --ink-strong: #0f2740;
  --accent: #f4b183;       /* same orange as "สาขาอื่น" rows */
  --accent-ink: #7a3a10;
  --bg: #f4f2ee;
  --paper: #ffffff;
  --n-50: #f8f7f5;
  --n-100: #eceae5;
  --n-300: #c9c5bc;
  --n-500: #7d786e;
  --n-700: #45413a;
  --n-900: #1f1d1a;
  --ok: #1d6b3a;
  --ok-bg: #e3f1e7;
  --warn: #8a5a00;
  --warn-bg: #fdf0d5;
  --err: #a3231f;
  --err-bg: #fbe5e3;
  --focus: #2f6fd6;
  --radius: 10px;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.06), 0 4px 12px rgb(0 0 0 / 0.06);
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px;
  --font: "IBM Plex Sans Thai", "Leelawadee UI", sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --ink: #9cc1e8; --ink-strong: #d6e6f7; --accent: #f4b183; --accent-ink: #f4b183;
    --bg: #14171b; --paper: #1d2126; --n-50: #23282e; --n-100: #2c3238; --n-300: #4a525b;
    --n-500: #9aa2ab; --n-700: #cfd4da; --n-900: #eef1f4;
    --ok: #7fd49c; --ok-bg: #1d3426; --warn: #f0c46b; --warn-bg: #3a2f16; --err: #f29b95; --err-bg: #3d1f1d;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.4);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--n-900); font: 16px/1.55 var(--font); }
h1, h2, h3, p { margin: 0; }
[hidden] { display: none !important; }

.topbar { display: flex; justify-content: space-between; align-items: center; gap: var(--s4);
  padding: var(--s3) var(--s5); background: var(--ink-strong); color: #fff; }
@media (prefers-color-scheme: dark) { .topbar { background: #0b1117; } }
.brand { font-weight: 700; letter-spacing: 0.02em; }
.brand-sub { font-weight: 400; opacity: 0.7; margin-left: var(--s2); }
.user { font-size: 14px; opacity: 0.85; overflow-wrap: anywhere; text-align: right; }

.page { max-width: 880px; margin: 0 auto; padding: var(--s5) var(--s4) var(--s7); display: grid; gap: var(--s4); }

.sku-strip { display: flex; justify-content: space-between; align-items: center; gap: var(--s4); flex-wrap: wrap;
  padding: var(--s3) var(--s4); border: 1px solid var(--n-100); border-radius: var(--radius); background: var(--paper); }
.strip-title { font-size: 14px; font-weight: 600; color: var(--n-700); }
.strip-meta { font-size: 14px; color: var(--n-500); }
.strip-meta strong { color: var(--n-900); font-weight: 600; }

.ticket { background: var(--paper); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.ticket-head { background: var(--ink); color: #fff; padding: var(--s5) var(--s5) var(--s4);
  border-bottom: 3px dashed rgb(255 255 255 / 0.35); display: grid; gap: var(--s2); }
@media (prefers-color-scheme: dark) { .ticket-head { background: #173a5e; } }
.ticket-label { font-size: 14px; letter-spacing: 0.08em; text-transform: uppercase; opacity: 0.8; }
.ticket-date { font-size: 32px; font-weight: 700; line-height: 1.2; font-variant-numeric: tabular-nums; }
.login { padding: var(--s6); display: grid; gap: var(--s3); }
.login .ticket-date { color: var(--n-900); }

.day-pickers { display: flex; gap: var(--s3); flex-wrap: wrap; margin-top: var(--s2); }
.field { display: grid; gap: var(--s1); font-size: 14px; }
.field span { opacity: 0.85; }
.field input, .field select { font: inherit; min-height: 44px; padding: 0 var(--s3); border-radius: 8px;
  border: 1px solid rgb(255 255 255 / 0.35); background: rgb(255 255 255 / 0.12); color: #fff; }
.field select option { color: #111; }
.field input::-webkit-calendar-picker-indicator { filter: invert(1); }

.steps { list-style: none; margin: 0; padding: var(--s2) var(--s5) var(--s5); }
.step { display: grid; grid-template-columns: 36px 1fr; gap: var(--s4); padding: var(--s4) 0; border-bottom: 1px solid var(--n-100); }
.step:last-child { border-bottom: 0; }
.step-num { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center;
  background: var(--n-100); color: var(--n-700); font-weight: 700; }
.step-body { display: grid; gap: var(--s2); min-width: 0; justify-items: start; }
.step-title { font-size: 20px; font-weight: 600; }
.hint { font-size: 14px; color: var(--n-500); }

.btn { font: inherit; font-weight: 600; min-height: 44px; padding: 0 var(--s5); border-radius: 8px; border: 1px solid transparent;
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2); cursor: pointer;
  transition: transform 120ms ease-out, background-color 150ms ease-out, opacity 150ms ease-out; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn:focus-visible, .file-btn:focus-within, .field input:focus-visible, .field select:focus-visible, a:focus-visible {
  outline: 3px solid var(--focus); outline-offset: 2px; }
.btn-primary { background: var(--accent); color: #3d1d06; font-size: 18px; min-height: 52px; padding: 0 var(--s6); }
.btn-primary:hover:not(:disabled) { background: #f09e64; }
.btn-outline { background: transparent; border-color: var(--ink); color: var(--ink); }
.btn-outline:hover { background: var(--n-50); }
.btn-quiet { background: var(--n-50); border-color: var(--n-100); color: var(--n-700); font-size: 14px; }
.btn-quiet:hover { background: var(--n-100); }
.file-btn { position: relative; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.is-busy { pointer-events: none; opacity: 0.6; }

.file-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s2); width: 100%; }
.file-list li { display: flex; justify-content: space-between; align-items: center; gap: var(--s3); flex-wrap: wrap;
  padding: var(--s2) var(--s3); border-radius: 8px; background: var(--n-50); font-size: 14px; }
.file-list li.latest { background: var(--n-100); }
.file-list li.latest .file-name { font-weight: 700; }
.file-name { font-weight: 500; overflow-wrap: anywhere; }
.file-meta { color: var(--n-500); }
.file-list a { color: var(--ink); font-weight: 600; min-height: 44px; display: inline-flex; align-items: center; }
.empty { color: var(--n-500); font-size: 14px; }

.result:empty { display: none; }
.result { width: 100%; border-radius: 8px; padding: var(--s3) var(--s4); font-size: 14px; display: grid; gap: var(--s2); }
.result.ok { background: var(--ok-bg); color: var(--ok); }
.result.err { background: var(--err-bg); color: var(--err); }
.result ul { margin: 0; padding-left: var(--s5); max-height: 280px; overflow: auto; color: var(--n-900); }
.result strong { font-size: 16px; }
.notice { padding: var(--s3) var(--s4); border-radius: 8px; font-size: 14px; }
.notice.ok { background: var(--ok-bg); color: var(--ok); }
.notice.err { background: var(--err-bg); color: var(--err); }
.notice.warn { background: var(--warn-bg); color: var(--warn); }

@media (max-width: 480px) {
  .topbar { padding: var(--s3) var(--s4); }
  .ticket-head { padding: var(--s4); }
  .ticket-date { font-size: 24px; }
  .steps { padding: var(--s1) var(--s4) var(--s4); }
  .step { grid-template-columns: 28px 1fr; gap: var(--s3); }
  .step-num { width: 28px; height: 28px; font-size: 14px; }
  .btn-primary { width: 100%; }
  .user { font-size: 12px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* phase 2: navigation, print panel, status page */
.topbar { flex-wrap: wrap; }
.nav { display: flex; gap: var(--s1); flex-wrap: wrap; flex: 1; }
.nav-link { color: #fff; text-decoration: none; font-size: 14px; padding: var(--s2) var(--s3); border-radius: 8px;
  min-height: 44px; display: inline-flex; align-items: center; opacity: 0.8; }
.nav-link:hover { opacity: 1; background: rgb(255 255 255 / 0.08); }
.nav-link[aria-current="page"] { opacity: 1; background: rgb(255 255 255 / 0.14); font-weight: 600; }
.nav-link:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.links { display: flex; gap: var(--s4); }
.print-controls { display: flex; gap: var(--s3); align-items: flex-end; flex-wrap: wrap; width: 100%; }
.field-light span { color: var(--n-700); opacity: 1; }
.field-light select { color: var(--n-900); background: var(--paper); border: 1px solid var(--n-300); }
.field-grow { flex: 1; min-width: 200px; }
.field-grow select { width: 100%; }
.file-error { color: var(--err); font-size: 14px; }

.chip { display: inline-flex; align-items: center; font-size: 12px; font-weight: 600; padding: 2px var(--s2); border-radius: 999px; }
.chip-queued { background: var(--warn-bg); color: var(--warn); }
.chip-claimed { background: var(--n-100); color: var(--n-700); }
.chip-printed { background: var(--ok-bg); color: var(--ok); }
.chip-failed { background: var(--err-bg); color: var(--err); }

.ticket-sub { font-size: 14px; opacity: 0.8; }
.panel { padding: var(--s4) var(--s5); display: grid; gap: var(--s3); border-bottom: 1px solid var(--n-100); }
.panel:last-child { border-bottom: 0; }
.card-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s3); grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.card { border: 1px solid var(--n-100); border-radius: var(--radius); padding: var(--s3) var(--s4); display: grid; gap: var(--s2); background: var(--n-50); }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: var(--s2); }
.printer-list { margin: 0; padding-left: var(--s5); font-size: 14px; color: var(--n-700); }
@media (max-width: 480px) { .panel { padding: var(--s4); } .print-controls .btn { width: 100%; } }
@media (max-width: 640px) {
  .nav { order: 3; flex-basis: 100%; margin: 0 calc(-1 * var(--s2)); }
  .nav-link { white-space: nowrap; }
}

/* login: who is signed in + sign out */
.user { display: flex; align-items: center; justify-content: flex-end; gap: var(--s2); flex-wrap: wrap; }
.user .btn { min-height: 44px; padding-block: 0; }
