:root {
  --bg: #E9EDEA; --surface: #FFFFFF; --surface-2: #F2F5F3; --ink: #1D2B36; --muted: #5E6B74; --line: #D3D9D6;
  --primary: #2C56A0; --primary-ink: #FFFFFF; --danger: #B3412F; --note: #FFF6DE; --note-line: #E7CF8C;
  --s-new: #2C56A0; --s-assembly: #B0741A; --s-ready: #7A4FA3; --s-packing: #8A6134; --s-shipped: #2F7A55;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121A20; --surface: #1A242C; --surface-2: #212D36; --ink: #E6ECEF; --muted: #97A6B0; --line: #2E3C46;
    --primary: #86A9EA; --primary-ink: #0D1A30; --danger: #E58A77; --note: #33301F; --note-line: #6B5E2E;
    --s-new: #86A9EA; --s-assembly: #E1AA55; --s-ready: #B996DE; --s-packing: #CFA071; --s-shipped: #6BC096;
  }
}
.st-new { --c: var(--s-new); }
.st-assembly { --c: var(--s-assembly); }
.st-ready { --c: var(--s-ready); }
.st-packing { --c: var(--s-packing); }
.st-shipped { --c: var(--s-shipped); }

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 16px; line-height: 1.45; }
body { padding: calc(20px + env(safe-area-inset-top)) 14px 90px; -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.wrap { max-width: 760px; margin: 0 auto; }
.mt { margin-top: 10px; }
.mt-l { margin-top: 20px; }
.pt { padding-top: 18px; }

h1 { font-weight: 800; font-size: clamp(23px, 5.6vw, 31px); line-height: 1.1; letter-spacing: -0.02em; margin: 0; }
.sub { margin: 6px 0 0; color: var(--muted); font-size: 14px; }
.top { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.top-actions { display: flex; gap: 8px; }

.login { min-height: 80vh; display: grid; place-items: center; }
.login-card { width: min(380px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 24px 20px; }
.login-card .btn { margin-top: 8px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 10px 18px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); font-weight: 600; font-size: 15px; cursor: pointer; white-space: nowrap; text-decoration: none; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn.quiet { background: transparent; border-color: transparent; color: var(--muted); }
.btn.danger { color: var(--danger); }
.btn.small { min-height: 34px; padding: 6px 12px; font-size: 14px; }
.btn.icon { min-width: 40px; padding: 6px 10px; font-size: 22px; line-height: 1; }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .5; cursor: default; }

.tabs { display: flex; gap: 6px; overflow-x: auto; margin: 20px -14px 12px; padding: 2px 14px 6px; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { flex: none; display: inline-flex; align-items: center; gap: 8px; padding: 7px 14px 7px 7px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); font-weight: 600; font-size: 14px; cursor: pointer; }
.tab-n { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; border: 1.5px solid var(--c);
  color: var(--c); font-size: 12px; font-weight: 800; }
.tab-count { color: var(--muted); font-variant-numeric: tabular-nums; font-weight: 500; }
.tab[aria-selected="true"] { background: var(--c); border-color: var(--c); color: var(--surface); }
.tab[aria-selected="true"] .tab-n { background: var(--surface); border-color: var(--surface); }
.tab[aria-selected="true"] .tab-count { color: var(--surface); opacity: .85; }

.search { width: 100%; padding: 11px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); font-size: 16px; margin-bottom: 14px; }

.ticket { display: grid; grid-template-columns: 54px 1fr; width: 100%; padding: 0; margin: 0 0 10px; text-align: left; cursor: pointer;
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.stub { position: relative; display: grid; place-items: center; background: var(--c); color: var(--surface); }
.stub::after { content: ""; position: absolute; top: 0; bottom: 0; right: -5px; width: 10px;
  background: radial-gradient(circle at 5px 7px, var(--surface) 3.2px, transparent 3.8px) 0 0 / 10px 14px repeat-y; }
.stub-n { font-size: 24px; font-weight: 800; }
.t-body { display: block; padding: 12px 14px 13px 18px; min-width: 0; }
.t-top { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.t-num { font-weight: 800; font-size: 17px; letter-spacing: -0.01em; }
.t-age { color: var(--muted); font-size: 13px; white-space: nowrap; }
.t-set { display: block; margin-top: 4px; font-weight: 600; }
.t-meta, .t-client { display: block; color: var(--muted); font-size: 14px; margin-top: 2px; }
.t-client { color: var(--ink); }
.t-stage { color: var(--c); font-weight: 700; font-size: 13px; }
.t-note { display: block; margin-top: 6px; font-size: 13.5px; padding: 4px 8px; border-radius: 6px; background: var(--note); border: 1px solid var(--note-line);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty { color: var(--muted); padding: 22px 4px; margin: 0; }
.banner { padding: 12px 14px; border-radius: 8px; background: var(--note); border: 1px solid var(--note-line); margin: 0 0 14px; font-size: 14.5px; }

.tools { margin-top: 34px; padding-top: 16px; border-top: 1px dashed var(--line); }
.tools h2 { font-size: 16px; margin: 0 0 6px; }
.tools p { margin: 0 0 10px; max-width: 62ch; color: var(--muted); font-size: 14px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 22px; }
.input.narrow { width: auto; min-width: 200px; }

dialog { border: none; padding: 0; background: var(--surface); color: var(--ink); border-radius: 12px; width: min(680px, calc(100% - 24px)); max-height: calc(100dvh - 32px); }
dialog::backdrop { background: rgba(8, 16, 22, .5); }
dialog[open] { animation: rise .18s ease-out; }
@keyframes rise { from { transform: translateY(12px); opacity: .6; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { dialog[open] { animation: none; } }
@media (max-width: 600px) {
  dialog.full { width: 100%; max-width: 100%; height: 100dvh; max-height: 100dvh; margin: 0; border-radius: 0; }
}
#askDlg, #menuDlg, #passDlg { width: min(420px, calc(100% - 24px)); }
.dlg { display: flex; flex-direction: column; max-height: inherit; height: 100%; }
.dlg-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: calc(12px + env(safe-area-inset-top)) 16px 12px; border-bottom: 1px solid var(--line); }
dialog:not(.full) .dlg-head { padding-top: 14px; }
.dlg-head h2 { font-size: 20px; font-weight: 800; margin: 0; letter-spacing: -0.01em; }
.dlg-body { padding: 4px 16px 20px; overflow-y: auto; flex: 1; }
.dlg-foot { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--surface); }
.dlg-foot .btn.primary { flex: 1 1 200px; }
.menu-list { display: grid; gap: 8px; padding-top: 14px; }
.pill { display: inline-block; padding: 3px 10px; border-radius: 999px; background: var(--c); color: var(--surface); font-size: 13px; font-weight: 600; margin-left: 8px; vertical-align: middle; letter-spacing: 0; }
.ask-text { margin: 0; }
.copy-box { margin-top: 10px; min-height: 96px; }

.progress { list-style: none; display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; padding: 0; margin: 14px 0 4px; }
.progress li { font-size: 11.5px; color: var(--muted); }
.progress .bar { display: block; height: 5px; border-radius: 3px; background: var(--line); margin-bottom: 5px; }
.progress li.done .bar, .progress li.cur .bar { background: var(--c); }
.progress li.cur { color: var(--ink); font-weight: 600; }

h3 { font-size: 14px; font-weight: 600; color: var(--muted); margin: 20px 0 8px; }
.note { background: var(--note); border: 1px solid var(--note-line); border-radius: 8px; padding: 10px 12px; margin-top: 14px; white-space: pre-wrap; }
.items { list-style: none; padding: 0; margin: 0; border: 1px solid var(--line); border-radius: 8px; }
.item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-top: 1px solid var(--line); }
.item:first-child { border-top: none; }
.item input[type="checkbox"] { width: 24px; height: 24px; accent-color: var(--s-shipped); flex: none; }
.item label, .item .lbl { flex: 1; display: flex; justify-content: space-between; align-items: baseline; gap: 10px; cursor: pointer; }
.item.is-done .i-name { text-decoration: line-through; color: var(--muted); }
.flags .item.is-done .i-name { text-decoration: none; color: var(--ink); }
.i-qty { font-variant-numeric: tabular-nums; font-weight: 700; white-space: nowrap; }
.i-when { color: var(--muted); font-size: 13px; text-align: right; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--line); flex: none; margin: 0 8px; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.kv a { color: var(--primary); }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: 13px; margin: 6px 0 0; }
.btn-row { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.btn-row.spaced { margin-top: 22px; }

.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px; }
.ph { position: relative; }
.ph .view { display: block; width: 100%; padding: 0; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--surface-2); cursor: zoom-in; aspect-ratio: 1; }
.ph img { display: block; width: 100%; height: 100%; object-fit: cover; }
.ph .del { position: absolute; top: 4px; right: 4px; width: 32px; height: 32px; padding: 0; border-radius: 50%; background: var(--surface); border: 1px solid var(--line); color: var(--danger); font-size: 18px; cursor: pointer; }
.upload { position: relative; overflow: hidden; }
.upload input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.upload:focus-within { outline: 2px solid var(--primary); outline-offset: 2px; }

.history { list-style: none; padding: 0; margin: 0; font-size: 14px; }
.history li { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-bottom: 1px dashed var(--line); }
.history time { color: var(--muted); white-space: nowrap; }
.track { font-size: 19px; font-weight: 800; letter-spacing: 0.02em; overflow-wrap: anywhere; }
.track-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 10px; }

.field { margin-top: 12px; }
.field label { display: block; font-size: 13.5px; color: var(--muted); margin-bottom: 5px; }
.input { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); font-size: 16px; }
textarea.input { min-height: 70px; resize: vertical; }
fieldset { border: none; padding: 0; margin: 20px 0 0; }
legend { font-weight: 700; font-size: 16px; padding: 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
@media (max-width: 480px) { .grid2 { grid-template-columns: 1fr; } }
.seg { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.seg label { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border: 1px solid var(--line); border-radius: 999px; cursor: pointer; font-weight: 600; }
.seg input { accent-color: var(--primary); }
.seg label:has(input:checked) { border-color: var(--primary); background: var(--surface-2); }
.check { display: inline-flex; align-items: center; gap: 8px; margin-top: 12px; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--primary); }
.check:has(input:disabled) { color: var(--muted); cursor: default; }
.toy-row { display: grid; grid-template-columns: 1fr 76px 40px; gap: 8px; margin-top: 8px; align-items: center; }
.form-msg { color: var(--danger); font-size: 14px; margin: 12px 0 0; min-height: 1em; }

.users { list-style: none; padding: 0; margin: 12px 0 0; border: 1px solid var(--line); border-radius: 8px; }
.users li { padding: 12px; border-top: 1px solid var(--line); }
.users li:first-child { border-top: none; }
.users .u-top { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.users .u-name { font-weight: 700; }
.users .off .u-name { color: var(--muted); text-decoration: line-through; }

#lightbox { width: auto; max-width: calc(100% - 16px); background: transparent; border-radius: 8px; }
#lightbox img { display: block; max-width: 100%; max-height: calc(100dvh - 32px); border-radius: 8px; }
.toast { position: fixed; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--ink); color: var(--surface);
  padding: 10px 16px; border-radius: 999px; font-size: 14.5px; font-weight: 500; max-width: calc(100% - 28px); z-index: 50; box-shadow: 0 6px 20px rgba(0,0,0,.2); }

.late { color: var(--danger) !important; font-weight: 600; }
.pickbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 4px; }
.pickbar .check { margin-top: 0; font-weight: 600; }
.pick-hint { margin: 0 0 12px; }
.pick-row { display: grid; grid-template-columns: 34px 1fr; align-items: center; gap: 4px; }
.pick-row .pick { width: 24px; height: 24px; accent-color: var(--primary); margin: 0 0 10px; }
.wide-hint { flex: 1 1 100%; margin: 0; }
