/* Layout: repair-bench console. Ticket list on the left, work pane (new / scan / detail) on the right at PC width; on a phone one pane at a time with a bottom tab bar. */
:root {
  --bg: #eef1f4;
  --surface: #ffffff;
  --surface-2: #e4e9ee;
  --fg: #14202b;
  --muted: #5a6b7a;
  --line: #cfd7df;
  --accent: #d9480f;
  --accent-fg: #ffffff;
  --focus: #1c6ed5;
  --st-received: #52667a;
  --st-diagnosing: #1c6ed5;
  --st-parts: #b25e00;
  --st-repairing: #7a4bd1;
  --st-ready: #1b8a4b;
  --st-delivered: #6b7885;
  --bad: #c92a2a;
  --font-display: "Barlow Condensed", "Arial Narrow", sans-serif;
  --font-body: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f151b; --surface: #17202a; --surface-2: #202c38; --fg: #e6edf3; --muted: #93a4b4;
    --line: #2b3946; --accent: #ffa94d; --accent-fg: #1a1205; --focus: #6ea8fe;
    --st-received: #9fb2c4; --st-diagnosing: #6ea8fe; --st-parts: #ffb454; --st-repairing: #b79bff;
    --st-ready: #5ad28a; --st-delivered: #8a99a8; --bad: #ff8787;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f151b; --surface: #17202a; --surface-2: #202c38; --fg: #e6edf3; --muted: #93a4b4;
  --line: #2b3946; --accent: #ffa94d; --accent-fg: #1a1205; --focus: #6ea8fe;
  --st-received: #9fb2c4; --st-diagnosing: #6ea8fe; --st-parts: #ffb454; --st-repairing: #b79bff;
  --st-ready: #5ad28a; --st-delivered: #8a99a8; --bad: #ff8787;
  color-scheme: dark;
}
* { box-sizing: border-box; }
body {
  background: var(--bg); color: var(--fg); font-family: var(--font-body); font-size: 15px; line-height: 1.45;
  padding-block: 0 84px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

.top { display: flex; align-items: center; gap: 12px; padding-block: 16px 14px; max-width: 1240px; margin: 0 auto; }
.mark { width: 34px; height: 34px; flex: none; color: var(--accent); }
.top h1 { font-family: var(--font-display); font-weight: 700; font-size: 28px; letter-spacing: .02em; text-transform: uppercase; margin: 0; line-height: 1; }
.top .sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.sync { margin-left: auto; font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.dot.on { background: var(--st-ready); }

.banner { max-width: 1240px; margin: 0 auto 12px; padding: 10px 12px; border: 1px solid var(--bad); border-radius: 6px; color: var(--bad); background: var(--surface); }

.app { max-width: 1240px; margin: 0 auto; display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; align-items: start; }
.pane { min-width: 0; }
body[data-pane="list"] .work-pane { display: none; }
body[data-pane="work"] .list-pane { display: none; }
@media (min-width: 900px) {
  .app { grid-template-columns: minmax(300px, 380px) minmax(0, 1fr); }
  body[data-pane] .work-pane, body[data-pane] .list-pane { display: block; }
  .nav { display: none !important; }
  body { padding-bottom: 32px; }
  .list-pane { position: sticky; top: 12px; max-height: calc(100vh - 24px); display: flex !important; flex-direction: column; }
  .list { overflow-y: auto; }
  .desk-actions { display: flex !important; }
  .back { display: none !important; }
}

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 16px; }
.panel + .panel { margin-top: 12px; }
h2 { font-family: var(--font-display); font-weight: 700; font-size: 24px; letter-spacing: .02em; text-transform: uppercase; margin: 0 0 12px; line-height: 1.1; }
h3 { font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 0 0 8px; font-weight: 600; }

.search { width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); font-size: 16px; }
.chips { display: flex; gap: 6px; overflow-x: auto; padding: 10px 0 6px; }
.chip { flex: none; border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 5px 11px; font-size: 13px; color: var(--muted); }
.chip[aria-pressed="true"] { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.chip b { font-family: var(--font-mono); font-weight: 600; margin-left: 4px; }
.list { display: flex; flex-direction: column; gap: 8px; margin-top: 6px; min-height: 0; }
.item { text-align: left; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 11px 12px; display: grid; gap: 3px; width: 100%; }
.item[aria-current="true"] { border-color: var(--accent); box-shadow: inset 3px 0 0 var(--accent); }
.item .row { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-width: 0; }
.item .code { font-family: var(--font-mono); font-weight: 600; font-size: 14px; }
.item .who { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .meta { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pill { --c: var(--st-received); display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; color: var(--c); background: color-mix(in srgb, var(--c) 15%, transparent); border: 1px solid color-mix(in srgb, var(--c) 40%, transparent); white-space: nowrap; }
.tag-ex { font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); border: 1px dashed var(--line); border-radius: 4px; padding: 0 5px; margin-left: 6px; }
.empty { border: 1px dashed var(--line); border-radius: 8px; padding: 22px 16px; color: var(--muted); text-align: center; }
.empty b { color: var(--fg); display: block; margin-bottom: 4px; }

.btn { border: 1px solid var(--line); background: var(--surface); border-radius: 6px; padding: 10px 14px; font-weight: 600; min-height: 42px; }
.btn.primary { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.btn.danger { color: var(--bad); border-color: var(--bad); }
.btn.sm { min-height: 34px; padding: 6px 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btns { display: flex; flex-wrap: wrap; gap: 8px; }
.desk-actions { display: none; gap: 8px; margin-bottom: 12px; }

form .grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 560px) { form .grid { grid-template-columns: minmax(0, 1fr); } }
.field { display: grid; gap: 4px; min-width: 0; }
.field.full { grid-column: 1 / -1; }
label { font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
input[type="text"], input[type="tel"], input[type="number"], textarea, select {
  width: 100%; padding: 10px 11px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); font-size: 16px; min-width: 0;
}
textarea { min-height: 84px; resize: vertical; }
.fault-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.fault-chips button { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 4px 10px; font-size: 13px; }

.scanbox { display: grid; gap: 12px; }
.snap { display: grid; place-items: center; gap: 6px; text-align: center; border: 2px dashed var(--accent); border-radius: 10px; padding: 26px 16px; cursor: pointer; }
.snap b { font-family: var(--font-display); font-size: 22px; letter-spacing: .03em; text-transform: uppercase; }
.snap span { color: var(--muted); font-size: 13px; }
.snap input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.snap:focus-within { outline: 2px solid var(--focus); outline-offset: 2px; }
.codeform { display: flex; gap: 8px; }
.codeform input { flex: 1; font-family: var(--font-mono); text-transform: uppercase; }
.msg { min-height: 20px; font-size: 14px; }
.msg.bad { color: var(--bad); }
.msg.ok { color: var(--st-ready); }
.note { color: var(--muted); font-size: 13px; }

.dhead { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.dhead .code { font-family: var(--font-mono); font-weight: 600; font-size: 22px; }
.back { display: inline-flex; margin-bottom: 10px; }
.kv { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; margin: 0; }
@media (max-width: 560px) { .kv { grid-template-columns: minmax(0, 1fr); } }
.kv div { min-width: 0; }
.kv dt { font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.kv dd { margin: 2px 0 0; overflow-wrap: anywhere; }
.kv .full { grid-column: 1 / -1; }
.status-row { display: flex; flex-wrap: wrap; gap: 6px; }
.status-row button { --c: var(--st-received); border: 1px solid color-mix(in srgb, var(--c) 45%, transparent); background: var(--surface); color: var(--c); border-radius: 6px; padding: 8px 11px; font-weight: 600; font-size: 14px; }
.status-row button[aria-pressed="true"] { background: var(--c); color: var(--bg); border-color: var(--c); }
.label-wrap { overflow-x: auto; }
.label-wrap canvas { max-width: 100%; height: auto; border: 1px solid var(--line); border-radius: 6px; background: #fff; display: block; }
.timeline { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.timeline li { display: flex; justify-content: space-between; gap: 10px; font-size: 14px; }
.timeline time { color: var(--muted); font-family: var(--font-mono); font-size: 12px; white-space: nowrap; }

.nav { position: fixed; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: repeat(3, 1fr); background: var(--surface); border-top: 1px solid var(--line); padding: 6px max(12px, env(safe-area-inset-right, 0px)) calc(6px + env(safe-area-inset-bottom, 0px)) max(12px, env(safe-area-inset-left, 0px)); gap: 6px; z-index: 5; }
.nav button { border: 0; background: transparent; padding: 8px 4px; border-radius: 6px; font-weight: 600; font-size: 13px; color: var(--muted); display: grid; gap: 2px; justify-items: center; }
.nav button svg { width: 22px; height: 22px; }
.nav button[aria-current="true"] { color: var(--accent); background: var(--surface-2); }
.toast { position: fixed; left: 50%; bottom: calc(86px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); background: var(--fg); color: var(--bg); padding: 9px 14px; border-radius: 6px; font-size: 14px; z-index: 9; max-width: 90vw; }
@media (min-width: 900px) { .toast { bottom: 24px; } }
@media (prefers-reduced-motion: no-preference) { .item, .btn, .chip { transition: border-color .15s, background-color .15s; } }

.userbar { display: flex; align-items: center; gap: 8px; margin-left: 12px; font-size: 13px; white-space: nowrap; }
.userbar a, .userbar button { color: var(--fg); text-decoration: none; border: 1px solid var(--line); background: var(--surface); border-radius: 6px; padding: 5px 9px; font-size: 13px; }
.userbar form { margin: 0; }
.top { flex-wrap: wrap; }
.authwrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.authcard { width: 100%; max-width: 380px; }
.authcard .brand { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.authcard .brand h1 { font-family: var(--font-display); font-size: 26px; text-transform: uppercase; margin: 0; letter-spacing: .02em; }
.authcard form { display: grid; gap: 12px; }
.flash { padding: 10px 12px; border-radius: 6px; margin-bottom: 12px; border: 1px solid var(--st-ready); color: var(--st-ready); background: var(--surface); }
.flash.bad { border-color: var(--bad); color: var(--bad); }
.page { max-width: 900px; margin: 0 auto; padding: 16px 0 32px; }
table.users { width: 100%; border-collapse: collapse; }
table.users th, table.users td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.users th { font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
table.users form { display: flex; gap: 6px; flex-wrap: wrap; margin: 0; }
table.users input[type="password"] { width: 150px; }
input[type="password"], input.plain, select { width: 100%; padding: 10px 11px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); font-size: 16px; }
