/* Shared · base: design tokens, light/dark themes, layout, shared components */
/* Page reset (the hosted artifact supplied this; standalone pages need it) */
:root { box-sizing: border-box; padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); }
body { margin: 0; }
img { max-width: 100%; }
/* Layout: one-screen operations console. 3D hall on the left, a tabbed rail on the right; stacks on phones.
   Default palette "Steel"; JS swaps palettes (Steel / Harbour / Graphite) and light/dark at runtime. */
:root {
  --bg: #eaeef2; --surface: #ffffff; --surface-2: #f4f6f9; --ink: #16202a; --muted: #5a6775; --line: #d2d9e1;
  --accent: #e5a01a; --accent-ink: #2a1d03;
  --scene-bg: #dde4eb; --floor: #ccd5df; --floor-grid: #bcc7d3; --rack: #3d5c82; --pallet: #b08d5b;
  --ok: #23977a; --warn: #c97612; --crit: #d23f3f; --over: #4a78cc;
  --ramp-0: #d7e3f0; --ramp-1: #1f4f8f; --heat-0: #f3e6cf; --heat-1: #c2361f;
  --f-display: "Barlow Condensed", "Arial Narrow", "Roboto Condensed", sans-serif;
  --f-body: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --f-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f151c; --surface: #16202a; --surface-2: #1b2632; --ink: #e4ebf2; --muted: #92a0af; --line: #293644;
    --accent: #f0b23a; --accent-ink: #231802; --scene-bg: #0d1319; --floor: #18222c; --floor-grid: #223040;
    --rack: #5b7ea8; --pallet: #8a6d45; --ok: #38b791; --warn: #ee9c36; --crit: #ec5858; --over: #6e98e2;
    --ramp-0: #22344a; --ramp-1: #8fc0f5; --heat-0: #2e2a24; --heat-1: #ff6a3d;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f151c; --surface: #16202a; --surface-2: #1b2632; --ink: #e4ebf2; --muted: #92a0af; --line: #293644;
  --accent: #f0b23a; --accent-ink: #231802; --scene-bg: #0d1319; --floor: #18222c; --floor-grid: #223040;
  --rack: #5b7ea8; --pallet: #8a6d45; --ok: #38b791; --warn: #ee9c36; --crit: #ec5858; --over: #6e98e2;
  --ramp-0: #22344a; --ramp-1: #8fc0f5; --heat-0: #2e2a24; --heat-1: #ff6a3d;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { background: var(--bg); color: var(--ink); font-family: var(--f-body); font-size: 14px; line-height: 1.45; }
button, input, select { font: inherit; color: inherit; }
button:focus-visible, canvas:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.app {
  height: 100%; display: flex; flex-direction: column; gap: 12px;
  padding-block: 12px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}

header { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; }
.brand { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; min-width: 0; }
.brand h1 { margin: 0; font-family: var(--f-display); font-weight: 700; font-size: 30px; letter-spacing: 0.01em; line-height: 1; }
.brand h1 span { color: var(--accent); }
.site { font-family: var(--f-mono); font-size: 12px; color: var(--muted); letter-spacing: 0.04em; text-transform: uppercase; }
.meta { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 10px; font-family: var(--f-mono); font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.demo { border: 1px dashed var(--muted); border-radius: 4px; padding: 1px 6px; text-transform: uppercase; letter-spacing: 0.06em; font-size: 11px; }

.main { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 12px; }

.stage { position: relative; min-height: 0; min-width: 0; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--scene-bg); }
.stage canvas { display: block; width: 100%; height: 100%; touch-action: none; cursor: grab; }
.stage canvas.dragging { cursor: grabbing; }
.stage canvas.pointing { cursor: pointer; }
.stage.moving canvas { cursor: crosshair; }

.overlay { position: absolute; display: flex; gap: 8px; align-items: center; pointer-events: none; }
.overlay > * { pointer-events: auto; }
.ov-tl { top: 10px; left: 10px; right: 10px; flex-wrap: wrap; justify-content: space-between; }
.ov-bl { bottom: 10px; left: 10px; right: 10px; }
.ov-br { bottom: 10px; right: 10px; }

.seg { display: inline-flex; background: var(--surface); border: 1px solid var(--line); border-radius: 7px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: transparent; padding: 5px 10px; border-radius: 5px; font-size: 12.5px; font-weight: 500; color: var(--muted); cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--surface); }
.seg button:hover:not([aria-pressed="true"]) { color: var(--ink); }
.seg.small button { padding: 3px 8px; font-size: 12px; }

.tools { display: inline-flex; gap: 6px; }
.btn { border: 1px solid var(--line); background: var(--surface); border-radius: 7px; padding: 6px 10px; font-size: 12.5px; font-weight: 500; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.btn:hover { border-color: var(--muted); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); }
.btn[aria-pressed="false"] .dot { background: var(--muted); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.ghost { background: transparent; }

select.sel, input.num { background: var(--surface-2); border: 1px solid var(--line); border-radius: 7px; padding: 6px 8px; font-size: 13px; min-width: 0; }
select.sel { max-width: 100%; }
input.num { width: 84px; font-family: var(--f-mono); font-variant-numeric: tabular-nums; }
.meta select.sel { padding: 4px 6px; font-size: 12px; background: var(--surface); }

.legend { background: var(--surface); border: 1px solid var(--line); border-radius: 7px; padding: 7px 10px; font-size: 12px; display: flex; flex-direction: column; gap: 5px; min-width: 0; max-width: 100%; }
.legend .lt { font-family: var(--f-mono); font-size: 10.5px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.legend .items { display: flex; flex-wrap: wrap; gap: 4px 12px; }
.legend .sw { display: inline-flex; align-items: center; gap: 5px; }
.legend .sw i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.legend .ramp { width: 160px; max-width: 40vw; height: 8px; border-radius: 2px; }
.legend .ends { display: flex; justify-content: space-between; font-family: var(--f-mono); font-size: 10.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.hint { font-family: var(--f-mono); font-size: 11px; color: var(--muted); background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 4px 8px; }

.banner { position: absolute; top: 56px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--surface); border-radius: 8px; padding: 8px 8px 8px 12px; display: flex; align-items: center; gap: 10px; font-size: 13px; max-width: calc(100% - 20px); z-index: 4; }
.banner b { font-family: var(--f-mono); font-weight: 500; }
.banner .btn { background: transparent; color: var(--surface); border-color: var(--muted); }

.tip { position: absolute; pointer-events: none; background: var(--ink); color: var(--surface); font-size: 12px; padding: 6px 8px; border-radius: 6px; white-space: nowrap; transform: translate(12px, 12px); font-variant-numeric: tabular-nums; z-index: 3; }
.tip b { font-family: var(--f-mono); font-weight: 500; }

/* Rail */
.panel { min-height: 0; min-width: 0; display: flex; flex-direction: column; gap: 12px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; min-width: 0; }
.card h2, .sub { margin: 0 0 10px; font-family: var(--f-mono); font-weight: 500; font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.sub { margin: 14px 0 8px; padding-top: 12px; border-top: 1px solid var(--line); }

.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; }
.kpi .v { font-family: var(--f-display); font-weight: 600; font-size: 26px; line-height: 1; font-variant-numeric: tabular-nums; }
.kpi .v small { font-size: 15px; color: var(--muted); font-weight: 600; margin-left: 1px; }
.kpi .l { font-size: 12px; color: var(--muted); margin-top: 3px; }
.kpi.alert .v { color: var(--crit); }

.tabcard { flex: 1; min-height: 0; display: flex; flex-direction: column; padding: 0; overflow: hidden; }
.tabs { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); border-bottom: 1px solid var(--line); }
.tabs button { border: 0; background: transparent; padding: 10px 0 9px; font-size: 12px; min-width: 0; font-weight: 500; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; display: inline-flex; justify-content: center; align-items: center; gap: 4px; }
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); }
.tabs .badge { font-family: var(--f-mono); font-size: 10.5px; background: var(--crit); color: var(--surface); border-radius: 999px; padding: 0 5px; line-height: 16px; }
.pane { flex: 1; min-height: 0; overflow-y: auto; padding: 12px 14px 14px; }

.chip { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 600; padding: 2px 7px 2px 6px; border-radius: 999px; border: 1px solid currentColor; white-space: nowrap; }
.chip::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.crit { color: var(--crit); } .low { color: var(--warn); } .ok { color: var(--ok); } .over { color: var(--over); } .mut { color: var(--muted); }

.empty-note { color: var(--muted); font-size: 13px; margin: 0; }
.sel-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.sel-code { font-family: var(--f-display); font-weight: 700; font-size: 34px; line-height: 0.95; letter-spacing: 0.02em; font-variant-numeric: tabular-nums; }
.sel-sku { margin: 4px 0 10px; font-weight: 500; }
.sel-sku span { display: block; font-family: var(--f-mono); font-size: 11.5px; color: var(--muted); font-weight: 400; }
.bar { position: relative; height: 8px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 4px; overflow: hidden; margin: 4px 0 10px; }
.bar i { display: block; height: 100%; background: var(--ink); transition: width .4s ease; }
.bar u { position: absolute; top: -1px; bottom: -1px; width: 2px; background: var(--crit); }
dl.facts { display: grid; grid-template-columns: auto 1fr; gap: 5px 12px; margin: 0; font-size: 13px; }
dl.facts dt { color: var(--muted); }
dl.facts dd { margin: 0; text-align: right; font-family: var(--f-mono); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.field { display: grid; gap: 4px; font-size: 12.5px; color: var(--muted); }
.field select { width: 100%; color: var(--ink); }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--ink); }
.note { font-size: 12px; color: var(--muted); margin: 6px 0 0; }
.callout { border: 1px solid currentColor; border-left-width: 4px; border-radius: 6px; padding: 7px 9px; font-size: 12.5px; margin-top: 8px; display: grid; gap: 6px; }
.callout p { margin: 0; color: var(--ink); }
.callout b { color: inherit; }
.xfer { margin-top: 10px; padding: 10px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; display: grid; gap: 8px; }

ul.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
ul.list > li + li { border-top: 1px solid var(--line); }
.prod { width: 100%; border: 0; background: transparent; text-align: left; padding: 8px 4px; cursor: pointer; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 10px; align-items: center; border-radius: 6px; }
.prod:hover, .prod[aria-pressed="true"] { background: var(--surface-2); }
.prod .n { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.prod .q { font-family: var(--f-mono); font-size: 12px; font-variant-numeric: tabular-nums; text-align: right; }
.prod .bar { grid-column: 1 / -1; margin: 3px 0 0; height: 6px; }
.prod .flag { font-size: 11px; margin-left: 6px; font-weight: 600; }

.po { padding: 9px 0; display: grid; gap: 3px; font-size: 12.5px; }
.po .top { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.po .id { font-family: var(--f-mono); font-weight: 500; }
.po .m { color: var(--muted); }
.po .amt { font-family: var(--f-mono); font-variant-numeric: tabular-nums; }

.al { padding: 9px 0; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 3px 10px; font-size: 12.5px; align-items: start; }
.al .k { font-family: var(--f-mono); font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; font-weight: 500; }
.al .t { font-family: var(--f-mono); font-size: 11px; color: var(--muted); }
.al p { margin: 0; grid-column: 1 / -1; }
.al.unread p { font-weight: 500; }

.log li { display: grid; grid-template-columns: 58px 58px minmax(0, 1fr); gap: 8px; padding: 6px 0; font-size: 12px; align-items: baseline; }
.log .t { font-family: var(--f-mono); font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.log .k { font-family: var(--f-mono); font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.log .k-api { color: var(--over); } .log .k-recv { color: var(--ok); } .log .k-supp { color: var(--warn); } .log .k-move { color: var(--ink); }
.log .m { min-width: 0; overflow-wrap: anywhere; }
.log .m code { font-family: var(--f-mono); font-size: 11.5px; }

.notices { display: flex; align-items: center; gap: 10px; min-height: 36px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 4px 6px 4px 12px; font-size: 13px; min-width: 0; }
.notices .lbl { font-family: var(--f-mono); font-size: 10.5px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); white-space: nowrap; }
.notice { flex: 1; min-width: 0; display: flex; align-items: baseline; gap: 8px; white-space: nowrap; overflow: hidden; }
.notice b { font-family: var(--f-mono); font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; flex: none; }
.notice span { color: var(--ink); overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.notice.idle span { color: var(--muted); }
.notice.fresh { animation: noticeIn .35s ease; }
@keyframes noticeIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .notice.fresh { animation: none; } }
.speed { display: inline-flex; align-items: center; gap: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: 7px; padding: 2px 4px 2px 9px; font-size: 12.5px; color: var(--muted); }
.speed select { border: 0; background: transparent; font-size: 12.5px; font-weight: 500; color: var(--ink); padding: 4px 2px; font-variant-numeric: tabular-nums; }
.fallback { position: absolute; inset: 0; display: grid; place-items: center; padding: 24px; text-align: center; color: var(--muted); }

