/* Control-room layer: dark glass, glow, HUD. Loaded after app.css; colours only from tokens. */
[data-theme="dark"] body {
  background-color: var(--surface);
  background-image:
    radial-gradient(900px 500px at 12% -10%, color-mix(in srgb, var(--brand) 14%, transparent), transparent 70%),
    radial-gradient(700px 500px at 100% 0%, color-mix(in srgb, var(--info) 12%, transparent), transparent 70%),
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: auto, auto, 32px 32px, 32px 32px;
  background-attachment: fixed;
}
[data-theme="dark"] ::selection { background: var(--brand); color: var(--brand-ink); }
[data-theme="dark"] h1 { font-size: 26px; letter-spacing: -.02em;
  background: linear-gradient(180deg, var(--ink), color-mix(in srgb, var(--ink) 60%, var(--brand))); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* glass surfaces */
[data-theme="dark"] .card, [data-theme="dark"] .stat, [data-theme="dark"] .step, [data-theme="dark"] .wt {
  background: var(--glass); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-color: var(--line); position: relative;
  box-shadow: inset 0 1px 0 color-mix(in srgb, var(--ink) 7%, transparent), 0 20px 40px -30px #000;
}
[data-theme="dark"] .card::before, [data-theme="dark"] .wt::before {
  content: ""; position: absolute; inset: -1px; border-radius: inherit; padding: 1px; pointer-events: none;
  background: linear-gradient(140deg, color-mix(in srgb, var(--brand) 40%, transparent), transparent 35%, transparent 70%, color-mix(in srgb, var(--info) 30%, transparent));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor; mask-composite: exclude; opacity: .55;
}
[data-theme="dark"] .wt:hover { border-color: color-mix(in srgb, var(--brand) 50%, var(--line)); box-shadow: 0 0 0 1px color-mix(in srgb, var(--brand) 25%, transparent), 0 18px 40px -20px color-mix(in srgb, var(--brand) 45%, transparent); }
[data-theme="dark"] .wt.live { border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand), 0 0 32px -6px color-mix(in srgb, var(--brand) 60%, transparent); }

/* shell */
[data-theme="dark"] .side { background: color-mix(in srgb, var(--shell) 88%, transparent); backdrop-filter: blur(16px); border-right: 1px solid var(--line); }
[data-theme="dark"] .mark-sp { background: linear-gradient(135deg, var(--brand), var(--info)); box-shadow: 0 0 18px -2px color-mix(in srgb, var(--brand) 70%, transparent); }
[data-theme="dark"] .side nav a { position: relative; }
[data-theme="dark"] .side nav a.on { background: linear-gradient(90deg, color-mix(in srgb, var(--brand) 16%, transparent), transparent); }
[data-theme="dark"] .side nav a.on::before { content: ""; position: absolute; left: -14px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--brand); box-shadow: 0 0 12px var(--brand); }
[data-theme="dark"] .top { background: color-mix(in srgb, var(--surface) 70%, transparent); }
.sys { display: flex; gap: 16px; margin-left: 14px; font-size: 12px; color: var(--ink-muted); font-weight: 500; }
.sys span { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.sys span::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--brand); box-shadow: 0 0 8px var(--brand); }
.sys b { color: var(--ink); font-weight: 600; }

/* buttons */
[data-theme="dark"] .btn { background: color-mix(in srgb, var(--surface-2) 80%, transparent); }
[data-theme="dark"] .btn.primary { background: linear-gradient(135deg, var(--brand), color-mix(in srgb, var(--brand) 60%, var(--info))); border-color: transparent; color: var(--brand-ink);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--brand) 40%, transparent), 0 8px 24px -8px color-mix(in srgb, var(--brand) 70%, transparent); }
[data-theme="dark"] .btn.primary:hover { box-shadow: 0 0 0 1px var(--brand), 0 10px 30px -6px var(--brand); }

/* flow strip */
[data-theme="dark"] .step.hot { background: linear-gradient(135deg, color-mix(in srgb, var(--brand) 30%, var(--surface-2)), var(--surface-2)); color: var(--ink); border-color: var(--brand);
  box-shadow: 0 0 0 1px var(--brand), 0 0 40px -8px color-mix(in srgb, var(--brand) 70%, transparent); }
[data-theme="dark"] .step.hot .lbl, [data-theme="dark"] .step.hot .lbl i { color: var(--brand); opacity: 1; }
[data-theme="dark"] .step .fig { font-family: "JetBrains Mono", monospace; font-weight: 600; letter-spacing: -.04em; }

/* tables and chips */
[data-theme="dark"] .tbl th { background: transparent; text-transform: uppercase; letter-spacing: .08em; font-size: 11px; border-bottom-color: var(--line); }
[data-theme="dark"] .tbl tr.click:hover td { background: color-mix(in srgb, var(--brand) 6%, transparent); }
[data-theme="dark"] .chip.done { box-shadow: 0 0 12px -2px var(--brand); }
[data-theme="dark"] .plate { background: var(--shell); box-shadow: inset 0 0 0 1px var(--line); }

/* inputs */
[data-theme="dark"] .search input, [data-theme="dark"] .select2-container--default .select2-selection--single, [data-theme="dark"] .select2-container--default .select2-selection--multiple { background: color-mix(in srgb, var(--surface) 70%, transparent); color: var(--ink); }
[data-theme="dark"] .select2-dropdown { background: var(--surface-2); color: var(--ink); }
[data-theme="dark"] .select2-search--dropdown .select2-search__field { background: var(--surface); color: var(--ink); border-color: var(--line); }
[data-theme="dark"] .select2-results__option[aria-selected=true] { background: var(--brand-tint); }
[data-theme="dark"] .select2-container--default .select2-results__option--highlighted[aria-selected] { color: var(--brand-ink); }
[data-theme="dark"] .swal2-popup { background: var(--surface-2) !important; color: var(--ink) !important; border: 1px solid var(--line); }
[data-theme="dark"] .swal2-html-container { color: var(--ink-muted) !important; }
[data-theme="dark"] .modal .box, [data-theme="dark"] .drawer { background: var(--surface-2); border: 1px solid var(--line); }
[data-theme="dark"] .seg { background: color-mix(in srgb, var(--surface) 70%, transparent); }
[data-theme="dark"] .seg button.on { background: var(--brand-tint); color: var(--brand); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--brand) 45%, transparent); }

/* count-up numbers */
.fig, .wt-fig, .hq-sum b { font-variant-numeric: tabular-nums; }

/* KPI strip with sparklines */
.hq-sum > div { position: relative; }
.hq-sum svg.spark { display: block; width: 100%; height: 30px; margin-top: 6px; overflow: visible; }
.spark path.l { fill: none; stroke: var(--brand); stroke-width: 1.6; }
.spark path.a { fill: url(#gSpark); }
.spark.down path.l { stroke: var(--info); }
.spark circle { fill: var(--brand); filter: drop-shadow(0 0 4px var(--brand)); }
.draw { stroke-dasharray: 600; stroke-dashoffset: 600; animation: draw 1.6s ease forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }

/* warehouse gauge tiles */
.wt { align-items: stretch; }
.wt-g { display: flex; align-items: center; gap: 12px; margin-top: 4px; }
.gauge { width: 64px; height: 64px; flex: none; }
.gauge .bg { fill: none; stroke: var(--line); stroke-width: 7; }
.gauge .seg-a { fill: none; stroke-width: 7; stroke-linecap: butt; transition: stroke-dasharray 1.4s cubic-bezier(.2,.8,.2,1); }
.gauge text { fill: var(--ink); font-size: 15px; font-weight: 700; font-family: "JetBrains Mono", monospace; }
.gauge text.s { fill: var(--ink-muted); font-size: 8px; font-weight: 600; font-family: var(--font-body); letter-spacing: .08em; }
.wt-g .wt-fig { margin: 0; font-size: 17px; }
.wt-g .wt-fig small { display: block; }
.wt .bars { display: flex; align-items: flex-end; gap: 2px; height: 22px; margin-top: 4px; }
.wt .bars i { flex: 1; border-radius: 2px 2px 0 0; background: color-mix(in srgb, var(--brand) 55%, transparent); min-height: 2px; }
.wt .bars i.o { background: color-mix(in srgb, var(--info) 55%, transparent); }

/* map, control-room style */
[data-theme="dark"] .map-wrap { background: var(--surface); }
[data-theme="dark"] .map .land { fill: color-mix(in srgb, var(--surface-2) 85%, var(--info)); }
[data-theme="dark"] .map .water { fill: var(--surface); }
[data-theme="dark"] .map .road { stroke: color-mix(in srgb, var(--line) 80%, var(--info)); stroke-width: 3; }
[data-theme="dark"] .map .route { stroke: var(--brand); stroke-width: 2.2; stroke-dasharray: 3 7; opacity: .9; animation: flow 1.2s linear infinite; filter: drop-shadow(0 0 3px var(--brand)); }
@keyframes flow { to { stroke-dashoffset: -20; } }
[data-theme="dark"] .map .port rect { fill: var(--surface-2); stroke: var(--info); stroke-width: 1.2; }
[data-theme="dark"] .map .port text { fill: var(--info); }
[data-theme="dark"] .map .wh rect { fill: var(--surface-2); stroke: color-mix(in srgb, var(--ink) 40%, transparent); }
[data-theme="dark"] .map .wh text { fill: var(--ink); }
[data-theme="dark"] .map .wh.on rect { fill: var(--brand); stroke: var(--brand); filter: drop-shadow(0 0 8px var(--brand)); }
[data-theme="dark"] .map .lorry circle.dot { fill: var(--ink); filter: drop-shadow(0 0 4px var(--ink)); }
[data-theme="dark"] .map .lorry circle.ring { stroke: var(--ink); }
[data-theme="dark"] .map .lorry text { fill: var(--ink); stroke: var(--surface); }
[data-theme="dark"] .map .lorry.me circle.dot { fill: var(--brand); filter: drop-shadow(0 0 8px var(--brand)); }
.map .gridl { stroke: var(--grid); stroke-width: 1; }
.map .wring { fill: none; stroke-width: 3; transform-box: fill-box; }
.sweep { position: absolute; inset: 0; pointer-events: none; border-radius: 10px; overflow: hidden; }
.sweep::before { content: ""; position: absolute; left: 50%; top: 50%; width: 160%; aspect-ratio: 1; translate: -50% -50%;
  background: conic-gradient(from 0deg, transparent 0 300deg, color-mix(in srgb, var(--brand) 14%, transparent) 350deg, transparent 360deg); animation: sweep 6s linear infinite; }
@keyframes sweep { to { rotate: 360deg; } }
.map-hud { position: absolute; left: 12px; top: 12px; display: flex; gap: 8px; font-family: "JetBrains Mono", monospace; font-size: 11px; color: var(--ink-muted); }
.map-hud span { background: color-mix(in srgb, var(--surface) 75%, transparent); border: 1px solid var(--line); border-radius: 6px; padding: 3px 7px; }
[data-theme="dark"] .eta { background: var(--glass); backdrop-filter: blur(10px); border-color: color-mix(in srgb, var(--brand) 40%, var(--line)); box-shadow: 0 0 30px -10px var(--brand); }

/* forecast */
.ai { position: relative; overflow: hidden; }
.ai .ai-h { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--brand); margin-bottom: 10px; }
.ai .ai-h i { font-size: 16px; filter: drop-shadow(0 0 6px var(--brand)); }
.ai p { margin: 0 0 12px; font-size: 14.5px; line-height: 1.5; }
.ai p b { color: var(--brand); }
.ai .acts { display: flex; gap: 8px; }
.ai .btn { height: 34px; font-size: 13px; }
.ai::after { content: ""; position: absolute; right: -60px; top: -60px; width: 180px; height: 180px; border-radius: 50%;
  background: radial-gradient(circle, color-mix(in srgb, var(--brand) 22%, transparent), transparent 70%); pointer-events: none; }
.typing-txt::after { content: "▍"; color: var(--brand); animation: blink .8s infinite; }

/* weighbridge HUD */
.hud .corner { position: absolute; width: 22px; height: 22px; border: 2px solid var(--brand); opacity: .85; }
.hud .c1 { left: 10px; top: 36px; border-right: 0; border-bottom: 0; } .hud .c2 { right: 10px; top: 36px; border-left: 0; border-bottom: 0; }
.hud .c3 { left: 10px; bottom: 10px; border-right: 0; border-top: 0; } .hud .c4 { right: 10px; bottom: 10px; border-left: 0; border-top: 0; }
.det { position: absolute; border: 1.5px solid var(--info); border-radius: 4px; opacity: 0; transition: opacity .4s, transform .5s cubic-bezier(.2,.9,.3,1.2); transform: scale(1.08); }
.det.on { opacity: 1; transform: none; }
.det .tag { position: absolute; left: -1.5px; bottom: calc(100% + 4px); background: var(--info); color: var(--surface); font-size: 11.5px; font-weight: 700; padding: 3px 7px; border-radius: 5px; white-space: nowrap; }
.det::before, .det::after { content: ""; position: absolute; width: 10px; height: 10px; border: 2px solid var(--info); }
.det::before { left: -3px; top: -3px; border-right: 0; border-bottom: 0; } .det::after { right: -3px; bottom: -3px; border-left: 0; border-top: 0; }
.anpr { border-color: var(--brand); box-shadow: 0 0 0 9999px rgba(0,0,0,0), 0 0 16px var(--brand); }
.anpr.on { box-shadow: 0 0 0 9999px rgba(2,8,14,.35), 0 0 18px var(--brand); }
.hud .bl { position: absolute; left: 14px; bottom: 14px; display: flex; gap: 8px; }
.hud .bl span { background: rgba(2,8,14,.6); backdrop-filter: blur(6px); border: 1px solid rgba(255,255,255,.12); border-radius: 6px; padding: 4px 8px; }
.wchart { margin-top: 12px; height: 70px; width: 100%; display: block; overflow: visible; }
.wchart .band { fill: color-mix(in srgb, var(--brand) 10%, transparent); }
.wchart path { fill: none; stroke: var(--brand); stroke-width: 2; filter: drop-shadow(0 0 4px var(--brand)); }
.wchart line { stroke: color-mix(in srgb, var(--shell-muted) 40%, transparent); stroke-dasharray: 3 4; }
[data-theme="dark"] .scale { background: linear-gradient(160deg, color-mix(in srgb, var(--brand) 10%, var(--shell)), var(--shell)); border: 1px solid var(--line); position: relative; overflow: hidden; }
[data-theme="dark"] .scale .kg { text-shadow: 0 0 24px color-mix(in srgb, var(--brand) 45%, transparent); }
.checks { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 8px; }
.checks li { display: flex; align-items: center; gap: 10px; font-size: 13px; opacity: .35; transition: opacity .3s; }
.checks li i { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; font-size: 13px; background: var(--surface); color: var(--ink-muted); border: 1px solid var(--line); }
.checks li.ok { opacity: 1; } .checks li.ok i { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); box-shadow: 0 0 10px -2px var(--brand); }
.checks li small { margin-left: auto; color: var(--ink-muted); font-family: "JetBrains Mono", monospace; font-size: 11.5px; }

/* isometric floor */
.iso-wrap { position: relative; }
.iso { display: block; width: 100%; height: auto; overflow: visible; }
.iso .tile { fill: color-mix(in srgb, var(--surface) 70%, var(--line)); stroke: var(--line); stroke-width: 1; }
.iso .slab { fill: color-mix(in srgb, var(--surface-2) 90%, var(--info)); stroke: var(--line); }
.iso g.bay { cursor: pointer; }
.iso g.bay .top { transition: filter .2s; }
.iso g.bay:hover .top { filter: brightness(1.25); }
.iso g.bay.sel .tile { stroke: var(--brand); stroke-width: 1.5; stroke-linejoin: miter; fill: color-mix(in srgb, var(--brand) 22%, var(--surface)); filter: drop-shadow(0 0 6px var(--brand)); }
.iso g.bay.sel .top { filter: brightness(1.3) drop-shadow(0 0 6px var(--brand)); }
.iso g.bay.sel text { fill: var(--brand); }
.iso g.bay.incoming .tile { stroke: var(--brand); stroke-width: 2.5; filter: drop-shadow(0 0 8px var(--brand)); animation: blink 1.1s infinite; }
.iso text { font-size: 10.5px; font-weight: 700; fill: var(--ink); pointer-events: none; paint-order: stroke; stroke: var(--surface); stroke-width: 3px; }
.iso text.door { fill: var(--ink-muted); font-weight: 600; font-size: 10.5px; }
.iso .grow { transition: transform 1.2s cubic-bezier(.3,.8,.3,1); }
.layer-key { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--ink-muted); margin-top: 10px; }
.layer-key .ramp { width: 140px; height: 8px; border-radius: 4px; }

/* boot */
.boot { position: fixed; inset: 0; z-index: 100; background: var(--surface); display: grid; place-items: center; transition: opacity .6s, visibility .6s; }
.boot.out { opacity: 0; visibility: hidden; }
.boot-in { width: min(440px, 90vw); font-family: "JetBrains Mono", monospace; font-size: 13px; }
.boot-logo { display: flex; align-items: center; gap: 12px; font-family: var(--font-body); font-size: 22px; font-weight: 700; margin-bottom: 26px; color: var(--ink); }
.boot-line { display: flex; justify-content: space-between; color: var(--ink-muted); padding: 5px 0; opacity: 0; transform: translateY(4px); transition: all .3s; }
.boot-line.on { opacity: 1; transform: none; }
.boot-line b { color: var(--brand); font-weight: 600; }
.boot-bar { height: 2px; background: var(--line); margin-top: 18px; border-radius: 2px; overflow: hidden; }
.boot-bar i { display: block; height: 100%; width: 0; background: var(--brand); box-shadow: 0 0 12px var(--brand); transition: width 1.6s cubic-bezier(.3,.7,.2,1); }

@media (max-width: 1280px) { .sys { display: none; } }
@media (max-width: 860px) { .gauge { width: 54px; height: 54px; } .map-hud { display: none; } }
.iso .pile { transform-box: fill-box; transform-origin: 50% 100%; animation: rise .9s cubic-bezier(.2,.8,.2,1) both; }
@keyframes rise { from { transform: scaleY(0); opacity: 0; } }
.iso g.bay.sel, .iso g.bay:focus { outline: none; }
@media (max-width: 1900px) { body.docked .sys { display: none; } body.docked .hud .bl { display: none; } }
@media (max-width: 860px) { .hud .bl { display: none; } .det .tag { font-size: 10px; padding: 2px 5px; } .anpr .tag { font-size: 11px; } }
