/* Hopa Warehouse. Tokens first; light and dark follow the device setting. */
:root {
  color-scheme: light;
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --hover: #eef1f5;
  --border: #e2e5ea;
  --border-strong: #cdd2da;
  --text: #15181d;
  --text-2: #4a5462;
  --muted: #6b7584;
  --accent: #1d5fbf;
  --accent-ink: #ffffff;
  --accent-weak: #e7effb;
  --ok: #17803f;
  --ok-weak: #e5f4ea;
  --warn: #9a5b00;
  --warn-weak: #fdf1dc;
  --bad: #c2312f;
  --bad-weak: #fdeaea;
  --info: #1d5fbf;
  --info-weak: #e7effb;
  --viewer-bg: #e6e8ec;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .07);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .18);
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100; --s5: #e87ba4; --s6: #008300; --s7: #4a3aa7; --s8: #e34948;
  --grid: #e8e9ec; --axis: #c3c6cc;
  --radius: 10px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --rail: 252px;
  --list: 372px;
  --panel: 360px;
  --tabbar: 58px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0f1216;
    --surface: #171b21;
    --surface-2: #1c2128;
    --hover: #222831;
    --border: #2a313b;
    --border-strong: #39424e;
    --text: #e8ebef;
    --text-2: #b9c1cc;
    --muted: #8f99a6;
    --accent: #6ea4ff;
    --accent-ink: #0b1220;
    --accent-weak: #1b2a42;
    --ok: #4cc27a;
    --ok-weak: #15291e;
    --warn: #f0b04a;
    --warn-weak: #2e2414;
    --bad: #ff6b66;
    --bad-weak: #351a1a;
    --info: #6ea4ff;
    --info-weak: #1b2a42;
    --viewer-bg: #0b0d10;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, .6);
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767;
    --grid: #252b33; --axis: #3a424c;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 14px/1.45 var(--font); -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }
h1 { font-size: 20px; line-height: 1.25; margin: 0; font-weight: 650; letter-spacing: -.01em; }
h2 { font-size: 15px; margin: 18px 0 8px; font-weight: 650; }
h3 { font-size: 13px; margin: 0 0 8px; font-weight: 650; display: flex; align-items: center; gap: 6px; }
p { margin: 8px 0; }
input, select, textarea, button { font: inherit; color: inherit; }
input, select, textarea {
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: 8px; padding: 8px 10px; width: 100%; min-height: 38px;
}
textarea { resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.icon { flex: none; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.danger { color: var(--bad); }
.hint { color: var(--muted); font-size: 12.5px; padding: 6px 0; }
.row-gap { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.link { color: var(--accent); background: none; border: 0; padding: 0; cursor: pointer; }
.link:hover { text-decoration: underline; }
.link.danger { color: var(--bad); }
.phone-only { display: none; }

/* ---- buttons, chips ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 36px; padding: 0 12px;
  border-radius: 8px; border: 1px solid var(--border-strong); background: var(--surface); cursor: pointer; white-space: nowrap;
  font-weight: 550; transition: background .12s, border-color .12s;
}
.btn:hover { background: var(--hover); }
.btn:disabled { opacity: .55; cursor: default; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent); filter: brightness(1.08); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-sm { min-height: 30px; padding: 0 9px; font-size: 13px; border-radius: 7px; }
.btn-icon { padding: 0; width: 36px; }
.btn-sm.btn-icon { width: 30px; }
.chip {
  display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px; border-radius: 999px; font-size: 12px;
  font-weight: 600; white-space: nowrap; background: var(--hover); color: var(--text-2);
}
.chip-ok { background: var(--ok-weak); color: var(--ok); }
.chip-warn { background: var(--warn-weak); color: var(--warn); }
.chip-bad { background: var(--bad-weak); color: var(--bad); }
.chip-info { background: var(--info-weak); color: var(--info); }
.count { display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; font-size: 11.5px; font-weight: 700; background: var(--hover); color: var(--text-2); }
.count-bad { background: var(--bad); color: #fff; }
.count-info { background: var(--info-weak); color: var(--info); }
.count-warn { background: var(--warn-weak); color: var(--warn); }
.count-muted { background: var(--hover); color: var(--text-2); }
.spin { width: 16px; height: 16px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; display: inline-block; animation: spin .7s linear infinite; opacity: .7; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 40px 16px; color: var(--muted); }
.boot { height: 100vh; display: grid; place-items: center; }
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px; padding: 40px 20px; color: var(--muted); }
.empty-title { color: var(--text); font-weight: 600; }
.empty-text { max-width: 300px; font-size: 13px; }
.errorbox { display: flex; gap: 10px; margin: 16px; padding: 12px 14px; border-radius: var(--radius); background: var(--bad-weak); color: var(--bad); }
.seg { display: inline-flex; background: var(--hover); border-radius: 9px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; padding: 5px 11px; border-radius: 7px; cursor: pointer; font-weight: 550; color: var(--text-2); font-size: 13px; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.seg-n { color: var(--muted); font-weight: 500; }
.select-sm { width: auto; min-height: 30px; padding: 3px 8px; font-size: 13px; }

/* ---- shell ---- */
.app { display: grid; grid-template-columns: var(--rail) minmax(0, 1fr); height: 100vh; height: 100dvh; }
.rail { background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; height: 100vh; height: 100dvh; overflow: hidden; padding: 12px 10px; gap: 6px; }
.rail > * { flex: none; }
.app.rail-is-mini { --rail: 64px; }
.brand-row { display: flex; align-items: center; justify-content: space-between; gap: 4px; padding-bottom: 6px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 15px; padding: 4px 6px; min-width: 0; }
.brand span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rail-toggle { border: 0; background: none; width: 28px; height: 28px; border-radius: 7px; color: var(--muted); cursor: pointer; display: grid; place-items: center; flex: none; }
.rail-toggle:hover { background: var(--hover); color: var(--text); }
.tree-scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; margin: 0 -6px; padding: 0 6px; }
.rail.mini { padding: 12px 8px; }
.rail.mini .brand-row { flex-direction: column; }
.rail.mini .brand { padding: 4px 0; }
.rail.mini .nav { justify-content: center; padding: 9px 0; }
.nav-icon { position: relative; display: inline-flex; }
.dot-count { position: absolute; top: -7px; right: -11px; min-width: 17px; height: 17px; border-radius: 999px; font-size: 10px; font-weight: 700; display: grid; place-items: center; padding: 0 4px; border: 2px solid var(--surface); }
.dot-bad { background: var(--bad); color: #fff; }
.dot-muted { background: var(--text-2); color: var(--surface); }
button.nav { border: 0; background: none; width: 100%; cursor: pointer; font: inherit; color: var(--text-2); }
.nav-list { display: flex; flex-direction: column; gap: 1px; }
.nav { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--text-2); font-weight: 550; }
.nav:hover { background: var(--hover); }
.nav.active { background: var(--accent-weak); color: var(--accent); }
.nav .count { margin-left: auto; }
.nav-bottom { margin-top: auto; padding-top: 8px; border-top: 1px solid var(--border); }
.me-mail { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-weight: 700; flex: none; }
.avatar.sm { width: 24px; height: 24px; font-size: 12px; }
.rail-label { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; padding: 12px 10px 4px; }
.search { display: flex; align-items: center; gap: 8px; background: var(--hover); border-radius: 8px; padding: 0 10px; color: var(--muted); }
.search input { border: 0; background: transparent; padding: 8px 0; min-height: 36px; }
.search input:focus { outline: none; }
.search:focus-within { outline: 2px solid var(--accent); }
.tree { display: flex; flex-direction: column; }
.tree-row { display: flex; align-items: center; gap: 4px; padding: 5px 8px; border-radius: 7px; color: var(--text-2); }
.tree-row:hover { background: var(--hover); }
.tree-row.active { background: var(--accent-weak); color: var(--accent); font-weight: 600; }
.tree-row.dim { opacity: .55; }
.tree-caret { width: 18px; height: 18px; display: grid; place-items: center; border-radius: 4px; flex: none; }
.tree-caret:hover { background: var(--border); }
.tree-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.main { min-width: 0; min-height: 0; overflow: hidden; }
.tabbar { display: none; }

/* ---- list + detail ---- */
.split { display: grid; grid-template-columns: var(--list) minmax(0, 1fr); height: 100%; }
.col-list { overflow-y: auto; border-right: 1px solid var(--border); background: var(--bg); }
.col-detail { min-width: 0; min-height: 0; overflow: hidden; background: var(--surface); }
.col-page { height: 100%; overflow-y: auto; }
.list { padding: 16px 14px 40px; display: flex; flex-direction: column; gap: 10px; }
.list-head { display: flex; flex-direction: column; gap: 6px; }
.list-actions, .folder-chips { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.crumbs { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; color: var(--muted); font-size: 12.5px; }
.crumbs a:hover { color: var(--accent); }
.list-tabs { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: space-between; }
.engine-line { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 12.5px; color: var(--text-2); padding: 8px 10px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.engine-line .running { display: inline-flex; gap: 6px; align-items: center; color: var(--accent); font-weight: 600; }
.engine-line .spin { width: 12px; height: 12px; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot-ok { background: var(--ok); } .dot-warn { background: var(--warn); } .dot-bad { background: var(--bad); }
.section { display: flex; flex-direction: column; gap: 8px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 6px; }
.section-toggle { display: flex; align-items: center; gap: 6px; border: 0; background: none; padding: 4px 0; cursor: pointer; font-weight: 650; font-size: 13.5px; }
.section-body, .cards, .files { display: flex; flex-direction: column; gap: 8px; }
.files { gap: 2px; }
.card {
  display: block; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px;
  box-shadow: var(--shadow); border-left: 3px solid var(--border-strong); transition: border-color .12s, background .12s;
}
.card:hover { border-color: var(--border-strong); }
.card.active { outline: 2px solid var(--accent); outline-offset: -1px; }
.tone-ok { border-left-color: var(--ok); } .tone-warn { border-left-color: var(--warn); } .tone-bad { border-left-color: var(--bad); }
.card-top, .card-bot { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.card-mid { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin: 6px 0 4px; }
.card-date { color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.card-issue { font-size: 12.5px; color: var(--text-2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin-bottom: 4px; }
.card-bot { font-size: 12.5px; color: var(--text-2); }
.docs { font-size: 11.5px; color: var(--muted); }
.plates { display: inline-flex; align-items: baseline; gap: 6px; font-family: var(--mono); letter-spacing: .02em; }
.plates b { font-size: 15px; }
.plates .trailer { color: var(--muted); font-size: 13px; }
.plates.big b { font-size: 19px; }
.plates.big .trailer { font-size: 15px; }
.file-row { display: flex; align-items: center; gap: 8px; border-radius: 8px; padding-left: 6px; }
.file-row:hover { background: var(--surface); }
.file-row.active { background: var(--accent-weak); }
.file-row.dim { opacity: .6; }
.file-row .pick { width: 16px; height: 16px; min-height: 0; flex: none; accent-color: var(--accent); }
.file-link { display: flex; align-items: center; gap: 8px; padding: 7px 8px 7px 2px; flex: 1; min-width: 0; color: var(--text-2); }
.file-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.file-meta { font-size: 12px; color: var(--muted); white-space: nowrap; }
.subfolders { display: grid; grid-template-columns: 1fr; gap: 6px; }
.subfolder { display: flex; align-items: center; gap: 8px; padding: 9px 12px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.subfolder:hover { border-color: var(--border-strong); }
.sf-name { flex: 1; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sf-n { display: flex; gap: 6px; align-items: center; font-size: 12.5px; }

/* ---- detail: viewer + panel ---- */
.detail { display: grid; grid-template-columns: minmax(0, 1fr) var(--panel); grid-template-rows: minmax(0, 1fr); height: 100%; }
.detail > .loading, .detail > .errorbox { grid-column: 1 / -1; }
.detail-top { display: none; }
.detail-view { min-width: 0; min-height: 0; background: var(--viewer-bg); }
.detail-empty { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; color: var(--muted); background: var(--viewer-bg); padding: 20px; text-align: center; }
.panel { border-left: 1px solid var(--border); background: var(--surface); min-height: 0; display: flex; flex-direction: column; }
.panel-scroll { overflow-y: auto; padding: 16px 16px 40px; display: flex; flex-direction: column; gap: 12px; }
.sheet-handle { display: none; }
.panel-head { display: flex; flex-direction: column; gap: 4px; }
.ph-plates { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.fname { font-weight: 650; word-break: break-all; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.note-line { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--ok); }
.block { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; background: var(--surface); }
.block-bad { background: var(--bad-weak); border-color: transparent; }
.block-warn { background: var(--warn-weak); border-color: transparent; }
.block-ok { background: var(--ok-weak); border-color: transparent; }
.block-ok h3 { color: var(--ok); }
.finding { padding: 8px 0; border-top: 1px solid rgba(0, 0, 0, .06); }
.block .finding:first-of-type { border-top: 0; padding-top: 0; }
.finding-text { font-weight: 550; }
.finding-n { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 5px; margin-right: 7px; border-radius: 999px; border: 0; background: #e8833a; color: #fff; font: 700 11px var(--font); cursor: pointer; vertical-align: 1px; }
.sev-minor .finding-n { background: #c99700; }
.finding-n + * { display: inline; }
.sev-critical .finding-text:not(:has(.finding-n))::before { content: ''; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--bad); margin-right: 7px; vertical-align: 2px; }
.sev-minor .finding-text:not(:has(.finding-n))::before { content: ''; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--warn); margin-right: 7px; vertical-align: 2px; }
.finding-actions { display: flex; gap: 14px; align-items: center; margin-top: 4px; }
.fvalues, .values { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; margin: 6px 0 0; font-size: 13px; }
.values dt, .fvalues dt { color: var(--muted); }
.values dd, .fvalues dd { margin: 0; font-variant-numeric: tabular-nums; word-break: break-word; }
.values.wide { grid-template-columns: 130px 1fr; }
.accepted { padding: 8px 0; border-top: 1px solid var(--border); color: var(--text-2); font-size: 13px; }
.accepted:first-of-type { border-top: 0; padding-top: 0; }
.acc-rule { font-size: 11.5px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.docs-list { display: flex; flex-direction: column; gap: 4px; }
.doc { display: grid; grid-template-columns: 1fr auto; gap: 0 10px; text-align: left; border: 0; background: var(--surface-2); border-radius: 8px; padding: 7px 10px; cursor: pointer; }
.doc:hover { background: var(--hover); }
.doc-name { font-weight: 600; }
.doc-no { grid-column: 1; font-size: 12.5px; color: var(--text-2); font-family: var(--mono); word-break: break-all; }
.doc-pages { grid-column: 2; grid-row: 1 / span 2; align-self: center; font-size: 12px; color: var(--muted); }
.comment { white-space: pre-wrap; font-size: 12.5px; color: var(--text-2); background: var(--surface-2); border-radius: 8px; padding: 8px 10px; margin-top: 8px; }
.mini-file { display: flex; gap: 8px; align-items: center; width: 100%; border: 0; background: none; padding: 6px 4px; border-radius: 6px; cursor: pointer; text-align: left; color: inherit; text-decoration: none; }
.mini-file span:nth-child(2) { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-file.on, .mini-file:hover { background: var(--hover); }
.menu { position: relative; }
.menu-list { position: absolute; right: 0; top: calc(100% + 4px); z-index: 40; min-width: 220px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-lg); padding: 4px; display: flex; flex-direction: column; }
.menu-list a, .menu-list button { display: flex; gap: 10px; align-items: center; padding: 9px 10px; border-radius: 7px; border: 0; background: none; text-align: left; cursor: pointer; }
.menu-list a:hover, .menu-list button:hover { background: var(--hover); }

/* the viewer */
.viewer-wrap { height: 100%; display: flex; flex-direction: column; min-height: 0; }
.file-tabs { display: flex; gap: 4px; padding: 6px 8px 0; overflow-x: auto; background: var(--surface); border-bottom: 1px solid var(--border); }
.file-tabs button { border: 0; background: none; padding: 6px 10px; border-radius: 7px 7px 0 0; cursor: pointer; white-space: nowrap; color: var(--muted); font-size: 12.5px; border-bottom: 2px solid transparent; }
.file-tabs button.on { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
.viewer { flex: 1; display: flex; flex-direction: column; min-height: 0; height: 100%; }
.viewer-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 8px; background: var(--surface); border-bottom: 1px solid var(--border); }
.viewer-name { display: flex; align-items: center; gap: 6px; min-width: 0; color: var(--text-2); font-size: 13px; }
.viewer-name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.viewer-tools { display: flex; align-items: center; gap: 4px; flex: none; }
.viewer-page { font-size: 12.5px; color: var(--muted); padding: 0 6px; font-variant-numeric: tabular-nums; }
.viewer-pct { border: 0; background: none; min-width: 48px; font-size: 12.5px; font-variant-numeric: tabular-nums; cursor: pointer; color: var(--text-2); border-radius: 6px; padding: 5px 4px; }
.viewer-pct:hover { background: var(--hover); }
.viewer-scroll { flex: 1; overflow: auto; position: relative; touch-action: pan-x pan-y; background: var(--viewer-bg); overscroll-behavior: contain; }
.viewer-inner { width: max-content; min-width: 100%; display: flex; flex-direction: column; align-items: center; will-change: transform; }
.viewer .pdf-page { background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); position: relative; flex: none; overflow: hidden; }
.viewer .pdf-page canvas { display: block; }
.viewer .pdf-page img { position: absolute; left: 50%; top: 50%; user-select: none; -webkit-user-drag: none; }
.viewer .mark { position: absolute; border: 2px solid #e8833a; background: rgba(242, 153, 74, .22); border-radius: 3px; pointer-events: none; box-shadow: 0 0 0 1px rgba(255, 255, 255, .6); }
.viewer .mark-warn { border-color: #d9a400; background: rgba(250, 200, 40, .2); }
.viewer .mark-ok { border-color: #8a94a3; background: rgba(138, 148, 163, .14); border-style: dashed; }
.viewer .mark-n { position: absolute; top: -10px; left: -10px; min-width: 18px; height: 18px; border-radius: 999px; background: #e8833a; color: #fff; font: 700 11px/18px var(--font); text-align: center; padding: 0 4px; box-shadow: 0 1px 2px rgba(0, 0, 0, .3); }
.viewer .mark-warn .mark-n { background: #c99700; }
.viewer .mark-ok .mark-n { background: #8a94a3; }
.viewer .mark.pulse { animation: markpulse 1.6s ease-out 1; }
@keyframes markpulse { 0% { box-shadow: 0 0 0 0 rgba(232, 131, 58, .8); } 70% { box-shadow: 0 0 0 14px rgba(232, 131, 58, 0); } 100% { box-shadow: 0 0 0 0 rgba(232, 131, 58, 0); } }
.viewer-msg { padding: 40px; text-align: center; color: var(--bad); display: flex; gap: 8px; justify-content: center; }

/* ---- pages ---- */
.page { padding: 22px 26px 60px; max-width: 1280px; }
.page.narrow { max-width: 860px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 6px; }
.card-block { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin: 14px 0; }
.card-block h2 { margin-top: 0; }
.table-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 4px 0; overflow-x: auto; }
.table-card h2 { padding: 10px 14px 0; margin: 0 0 4px; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12px; padding: 8px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.tbl td { padding: 8px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl tr.total td { font-weight: 650; border-top: 1px solid var(--border-strong); }
.tbl tr.dim td { opacity: .55; }
.tbl td.row-gap { display: table-cell; }
.tbl td.row-gap > * + * { margin-left: 12px; }
.folders-tbl td:first-child { white-space: nowrap; }
.form-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px 16px; margin-bottom: 12px; }
.form-row { display: flex; gap: 8px; align-items: center; }
.form-row input[type=number] { width: 90px; }
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.field-label { font-weight: 600; font-size: 13px; }
.field-hint { font-size: 12px; color: var(--muted); }
.check-line { display: flex; gap: 8px; align-items: center; margin: 4px 0 12px; cursor: pointer; }
.check-line input { width: 16px; height: 16px; min-height: 0; accent-color: var(--accent); }
.rule-form { border-left: 3px solid var(--accent-weak); padding-left: 12px; }
.instructions { font-family: var(--mono); font-size: 13px; min-height: 320px; margin: 8px 0 10px; }
.layers { font-size: 12.5px; color: var(--muted); display: flex; gap: 8px; flex-wrap: wrap; }
.rule { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 8px; }
.rule.off { opacity: .65; }
.rule-top { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.rule-name { font-weight: 650; }
.rule-chips { display: flex; gap: 4px; flex: none; }
.rule-text { color: var(--text-2); margin: 6px 0; white-space: pre-wrap; font-size: 13px; }
.rule-actions { display: flex; gap: 12px; align-items: center; margin-top: 8px; }
.activity { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.act-row { display: grid; grid-template-columns: 130px 120px 1fr; gap: 10px; padding: 8px 14px; border-bottom: 1px solid var(--border); font-size: 13px; align-items: baseline; }
.act-row:last-child { border-bottom: 0; }
.act-when { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.act-who { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-line { display: flex; gap: 12px; align-items: center; }
.more-list { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-top: 12px; }
.more-row { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.more-row:last-child { border-bottom: 0; }
.more-row span { flex: 1; font-weight: 550; }
.browse .search { margin: 12px 0; background: var(--surface); border: 1px solid var(--border); }
.browse .tree-row { padding: 10px 8px; }

/* statistics */
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin: 12px 0 16px; }
.range { display: inline-flex; gap: 6px; align-items: center; }
.range input { width: 150px; min-height: 30px; padding: 3px 8px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.tile-label { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.tile-value { font-size: 28px; font-weight: 650; margin: 4px 0 2px; letter-spacing: -.01em; }
.tile-unit { font-size: 14px; font-weight: 550; color: var(--text-2); }
.tile-sub { font-size: 12.5px; color: var(--text-2); }
.chart-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 16px; }
.chart-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.chart-head h2 { margin: 0; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--text-2); }
.key { display: inline-flex; align-items: center; gap: 6px; }
.swatch { width: 10px; height: 10px; border-radius: 3px; display: inline-block; margin-right: 6px; vertical-align: -1px; }
.key .swatch { margin-right: 0; }
.chart { position: relative; overflow-x: auto; margin-top: 8px; }
.chart svg { display: block; width: 100%; min-width: 520px; height: auto; }
.chart .grid { stroke: var(--grid); stroke-width: 1; }
.chart .axis { stroke: var(--axis); stroke-width: 1; }
.chart .tick { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .val { fill: var(--text-2); font-size: 11px; font-weight: 600; }
.tooltip { position: absolute; top: 4px; transform: translateX(-50%); background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-lg); border-radius: 8px; padding: 8px 10px; font-size: 12.5px; pointer-events: none; min-width: 150px; z-index: 5; }
.tt-title { font-weight: 650; margin-bottom: 4px; }
.tt-row { display: flex; align-items: center; gap: 2px; }
.tt-row b { margin-left: auto; padding-left: 12px; font-variant-numeric: tabular-nums; }
.tables { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 16px; }

/* on the way */
.h-count { font-size: 15px; color: var(--muted); font-weight: 600; margin-left: 6px; }
.otw-facts { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 4px 0 0; }
.otw-search { width: 200px; min-height: 30px; padding: 4px 10px; }
.otw-group { margin-bottom: 14px; }
.otw-group-head { font-size: 13px; padding: 4px 2px 6px; }
.otw-list { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.otw-row { display: grid; grid-template-columns: 200px minmax(0, 1.3fr) minmax(0, 1fr) minmax(0, 1fr) 90px 40px; gap: 12px; align-items: center; padding: 9px 12px; border-bottom: 1px solid var(--border); }
.otw-row:last-child { border-bottom: 0; }
.otw-row.late { background: var(--bad-weak); }
.otw-row.dim { opacity: .7; grid-template-columns: 200px 1fr auto; }
.otw-who > div, .otw-what > div { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.otw-src { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; }
.otw-days { font-variant-numeric: tabular-nums; text-align: right; }
.otw-fold .table-card { margin-top: 4px; }

/* stock and departures */
.test-banner { display: flex; gap: 8px; align-items: center; background: var(--warn-weak); color: var(--warn); border-radius: 8px; padding: 8px 12px; margin: 8px 0; font-weight: 600; font-size: 13px; }
.stock-groups { display: flex; flex-direction: column; gap: 8px; margin: 12px 0 8px; }
.stock-group .table-card { margin-top: 6px; }
.stock-head { width: 100%; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; text-align: left; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; cursor: pointer; }
.stock-head:hover { border-color: var(--border-strong); }
.sg-name { font-weight: 650; flex: 1 1 200px; }
.sg-fig { font-variant-numeric: tabular-nums; white-space: nowrap; }
.deps { display: flex; flex-direction: column; gap: 8px; }
.dep { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; }
.dep.dim { opacity: .6; }
.dep-head { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; align-items: center; }
.dep-title { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.dep-line { display: flex; gap: 6px 14px; flex-wrap: wrap; font-size: 13px; }
.dl-cargo { font-weight: 600; }
.dep-loads { margin-top: 4px; }
.dep-head-form { margin-top: 12px; }
.dep-form-line { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; margin: 10px 0; background: var(--surface-2); }
.dfl-title { font-weight: 650; font-size: 13px; margin-bottom: 6px; }
.dfl-top { display: grid; grid-template-columns: minmax(0, 2fr) repeat(3, minmax(0, 1fr)) auto; gap: 10px; align-items: start; }
.dfl-top .btn { margin-top: 24px; }
.alloc .take { width: 90px; min-height: 30px; padding: 3px 8px; text-align: right; }
.alloc td { padding-top: 5px; padding-bottom: 5px; }
.alloc input[type=checkbox] { width: 16px; height: 16px; min-height: 0; accent-color: var(--accent); }
.dfl-sum { display: flex; gap: 6px 16px; flex-wrap: wrap; align-items: center; font-size: 13px; margin-top: 8px; font-variant-numeric: tabular-nums; }
/* Stock: the whole warehouse at a glance */
/* Stock: the whole warehouse at a glance -- one band tinted with the accent, set apart from the neutral sections
   below. The 1px gaps over the band's border colour draw the dividers, in 4 columns or 2 on a phone. */
.stock-total { --st-line: color-mix(in srgb, var(--accent) 22%, var(--accent-weak)); display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1px;
  margin: 14px 0 8px; background: var(--st-line); border: 1px solid var(--st-line); border-radius: calc(var(--radius) + 2px); overflow: hidden; }
.st-tile { display: flex; flex-direction: column; gap: 3px; background: var(--accent-weak); padding: 13px 16px; min-width: 0; }
.st-label { font-size: 12.5px; font-weight: 600; color: var(--accent); }
.st-value { font-size: 24px; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; line-height: 1.15; white-space: nowrap; }
.st-value.st-places { white-space: normal; }
.st-sub { font-size: 12.5px; color: color-mix(in srgb, var(--text) 68%, var(--accent-weak)); }
@media (max-width: 640px) { .stock-total { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 480px) { .st-value { font-size: 19px; } .st-tile { padding: 11px 12px; } }
.hint-line { display: flex; align-items: center; gap: 8px 12px; flex-wrap: wrap; font-size: 13.5px; margin: 8px 0 2px; color: var(--muted); }
.hint-line > span { flex: 1 1 260px; }
.picked { flex: 1 1 420px; display: flex; flex-direction: column; gap: 2px; min-width: 0; font-variant-numeric: tabular-nums; }
.pk-line { display: grid; grid-template-columns: minmax(120px, 1.4fr) repeat(4, minmax(70px, auto)); gap: 4px 14px; font-size: 13.5px; align-items: baseline; }
.pk-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pk-total { border-top: 1px solid var(--border); padding-top: 4px; margin-top: 2px; font-weight: 650; }
.sel-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.dfl-top input.auto { color: var(--muted); font-style: italic; }
@media (max-width: 760px) { .pk-line { grid-template-columns: 1fr 1fr; } .pk-name { grid-column: 1 / -1; } }
.dfl-book { display: flex; gap: 4px 16px; flex-wrap: wrap; align-items: baseline; font-size: 13.5px; margin: 2px 0 8px; padding: 8px 12px; background: var(--surface-2, var(--bg)); border: 1px solid var(--border); border-radius: 8px; font-variant-numeric: tabular-nums; }
.dfl-book .bad { color: var(--bad); font-weight: 600; }
.stock-tbl .ck, .stock-tbl th.ck { width: 34px; padding-right: 0; }
.stock-tbl input[type=checkbox], .pick-row input[type=checkbox] { width: 16px; height: 16px; min-height: 0; accent-color: var(--accent); }
.stock-tbl tr.on td { background: var(--accent-weak, rgba(37, 99, 235, 0.08)); }
.sg-actions { display: flex; justify-content: flex-end; margin: 4px 2px 0; }
.sel-bar { position: sticky; bottom: 12px; z-index: 20; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 12px 0; padding: 10px 14px; background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius); box-shadow: var(--shadow-lg); }
.sel-bar > span { flex: 1 1 200px; }
.pick-list { max-height: 320px; overflow-y: auto; border: 1px solid var(--border); border-radius: 8px; padding: 4px 0; margin-bottom: 10px; }
.pick-head { font-weight: 650; font-size: 13px; padding: 8px 12px 4px; color: var(--muted); }
.pick-row { display: flex; align-items: center; gap: 10px; padding: 5px 12px; cursor: pointer; }
.pick-row:hover { background: var(--bg); }
@media (max-width: 760px) { .sel-bar { bottom: calc(var(--tabbar) + 10px + env(safe-area-inset-bottom)); } }
.dfl-sum .ok { color: var(--ok); font-weight: 600; }
.dfl-sum .bad { color: var(--bad); font-weight: 600; }
.add-line { display: inline-flex; gap: 6px; align-items: center; margin: 4px 0; }
.foot-note { margin-right: auto; }
.confirm-line { border-top: 1px solid var(--border); padding: 10px 0; }
.confirm-line ul { margin: 6px 0; padding-left: 18px; }

/* sign-in */
.signin { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.signin-card { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow); padding: 32px 28px; width: min(400px, 100%); display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px; }
.signin-card h1 { margin-top: 8px; }
.gbtn { margin: 16px 0 4px; min-height: 44px; }
.dev-login { display: flex; flex-direction: column; gap: 6px; width: 100%; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border); }
.dev-login .btn { justify-content: space-between; }

/* modal, toasts */
.modal-back { position: fixed; inset: 0; background: rgba(10, 14, 20, .45); display: grid; grid-template-columns: minmax(0, 1fr); place-items: center; z-index: 100; padding: 16px; }
.modal { background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-lg); width: min(520px, 100%); min-width: 0; max-height: calc(100vh - 32px); display: flex; flex-direction: column; }
.modal-wide { width: min(760px, 100%); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 6px 20px; }
.modal-head h2 { margin: 0; font-size: 17px; }
.modal-body { padding: 6px 20px 12px; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px 16px; border-top: 1px solid var(--border); }
.toasts { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 200; width: min(460px, calc(100vw - 32px)); pointer-events: none; }
.toast { background: var(--text); color: var(--bg); padding: 10px 14px; border-radius: 10px; box-shadow: var(--shadow-lg); font-weight: 550; }
.toast-bad { background: var(--bad); color: #fff; }
.toast-ok { background: var(--ok); color: #fff; }
.toast-warn { background: var(--warn); color: var(--bg); }
.offline { position: fixed; top: 0; left: 0; right: 0; background: var(--warn); color: #fff; text-align: center; padding: 4px; font-size: 12.5px; z-index: 150; }

/* ---- medium screens: the list makes room for an open item ---- */
@media (max-width: 1279px) {
  :root { --rail: 232px; --list: 340px; --panel: 320px; }
}
@media (max-width: 1179px) and (min-width: 768px) {
  .split.has-item { grid-template-columns: minmax(0, 1fr); }
  .split.has-item .col-list { display: none; }
  .detail { grid-template-rows: auto minmax(0, 1fr); }
  .detail-top { display: flex; grid-column: 1 / -1; align-items: center; gap: 6px; padding: 6px 10px; border-bottom: 1px solid var(--border); background: var(--surface); }
  .detail-title { min-width: 0; }
  .dt-sub { font-size: 12px; color: var(--muted); }
}
@media (max-width: 1023px) and (min-width: 768px) {
  :root { --rail: 200px; --list: 300px; }
}

/* ---- phones ---- */
@media (max-width: 767px) {
  .phone-only { display: block; }
  .app { display: block; height: auto; min-height: 100vh; padding-bottom: calc(var(--tabbar) + env(safe-area-inset-bottom)); }
  .rail { display: none; }
  .main { overflow: visible; }
  .tabbar {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: var(--surface); border-top: 1px solid var(--border);
    height: calc(var(--tabbar) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  }
  .tab { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 11px; color: var(--muted); font-weight: 600; }
  .tab.active { color: var(--accent); }
  .tab-icon { position: relative; }
  .badge { position: absolute; top: -4px; right: -10px; background: var(--bad); color: #fff; border-radius: 999px; font-size: 10px; min-width: 16px; height: 16px; display: grid; place-items: center; padding: 0 4px; }
  .badge-muted { background: var(--text-2); color: var(--surface); }
  .split { display: block; height: auto; }
  .col-list { border-right: 0; overflow: visible; }
  .col-detail { display: none; }
  .has-item .col-detail { display: block; position: fixed; inset: 0; z-index: 60; }
  .col-page { height: auto; overflow: visible; }
  .list { padding: 12px 12px 24px; }
  .phone-search { padding: 12px 12px 0; }
  .phone-search .search { background: var(--surface); border: 1px solid var(--border); }
  .page { padding: 16px 14px 32px; }
  .detail { display: flex; flex-direction: column; height: 100%; }
  .detail-top { display: flex; align-items: center; gap: 6px; padding: 6px 8px; padding-top: max(6px, env(safe-area-inset-top)); border-bottom: 1px solid var(--border); background: var(--surface); }
  .detail-title { min-width: 0; }
  .dt-main { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 650; }
  .dt-sub { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .detail-view { flex: 1; min-height: 0; }
  .panel { border-left: 0; border-top: 1px solid var(--border); box-shadow: 0 -6px 18px rgba(0, 0, 0, .08); border-radius: 14px 14px 0 0; height: 34vh; transition: height .2s ease; padding-bottom: env(safe-area-inset-bottom); }
  .sheet-open .panel { height: 78vh; }
  .sheet-handle { display: grid; place-items: center; border: 0; background: none; height: 22px; flex: none; cursor: pointer; }
  .sheet-handle span { width: 40px; height: 5px; border-radius: 3px; background: var(--border-strong); }
  .panel-scroll { padding-top: 2px; }
  .panel-head .ph-plates .plates.big b { font-size: 17px; }
  .viewer-name { display: none; }
  .viewer-bar { justify-content: flex-end; }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .act-row { grid-template-columns: 1fr; gap: 2px; }
  .tables { grid-template-columns: 1fr; }
  .tile-value { font-size: 24px; }
  .modal-back { align-items: end; padding: 0; }
  .modal { width: 100%; border-radius: 16px 16px 0 0; max-height: 92vh; padding-bottom: env(safe-area-inset-bottom); }
  .toasts { bottom: calc(var(--tabbar) + 14px + env(safe-area-inset-bottom)); }
  .otw-row { grid-template-columns: 1fr auto 36px; grid-template-areas: "plates days act" "who who who" "what src src"; gap: 4px 10px; }
  .otw-plates { grid-area: plates; } .otw-days { grid-area: days; } .otw-act { grid-area: act; }
  .otw-who { grid-area: who; } .otw-what { grid-area: what; } .otw-src { grid-area: src; align-items: flex-end; }
  .otw-row.dim { grid-template-columns: 1fr auto; }
  .otw-search { width: 100%; }
  .dfl-top { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .dfl-top .btn { margin-top: 0; }
  .modal-body { overflow-x: hidden; }
  .dep-form-line { padding: 10px; margin-left: -4px; margin-right: -4px; }
  .dfl-top > .field:first-child { grid-column: 1 / -1; }
  .alloc th:nth-child(2), .alloc td:nth-child(2) { display: none; }
  .alloc th, .alloc td { padding-left: 6px; padding-right: 6px; }
  .alloc .trailer { display: none; }
  .alloc .take { width: 64px; }
  .alloc-st .chip { padding: 0 6px; }
  .folders-tbl th:nth-child(5), .folders-tbl td:nth-child(5), .folders-tbl th:nth-child(7), .folders-tbl td:nth-child(7) { display: none; }
}
