/* Trucking Dispatch Simulator — dark logistics dashboard.
   Desktop: map + right panel. ≤860px: map with a collapsible bottom sheet. */

:root {
  --bg: #0b1220;
  --bg-2: #0f1828;
  --surface: #131d2f;
  --surface-2: #19253b;
  --surface-3: #22314b;
  --line: #26344d;
  --line-2: #33445f;
  --text: #e6edf7;
  --text-2: #a9b6c9;
  --muted: #7d8ca3;
  --accent: #4f8cff;
  --accent-2: #7aa8ff;
  --pos: #34d399;
  --neg: #f87171;
  --warn: #fbbf24;
  --hot: #fb7185;
  --gold: #c9a227;

  --s-available: #22c55e;
  --s-pickup: #f59e0b;
  --s-loading: #a78bfa;
  --s-bol: #f472b6;
  --s-delivery: #38bdf8;
  --s-unloading: #2dd4bf;
  --s-returning: #8ea3c4;
  --s-offduty: #5b6b83;

  --radius: 10px;
  --radius-sm: 7px;
  --panel-w: 430px;
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 14px/1.45 var(--font); -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
button, input, select { font: inherit; color: inherit; }
a { color: var(--accent-2); }
.mono { font-family: var(--mono); font-feature-settings: 'zero' 1; letter-spacing: -.01em; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.pos { color: var(--pos); } .neg { color: var(--neg); } .warn { color: var(--warn); }
:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; }
[hidden] { display: none !important; }

/* ── Shell ─────────────────────────────────────────────────────────────── */
.app { display: grid; grid-template-rows: auto auto minmax(0, 1fr) auto; height: 100vh; height: 100dvh; }

.topbar {
  position: relative; z-index: 1200;
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 8px 14px; background: var(--bg-2); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); min-width: 0; }
.brand-mark { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; background: linear-gradient(135deg, #2457c5, #4f8cff); color: #fff; flex: none; }
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-title { font-weight: 700; letter-spacing: -.01em; font-size: 15px; }
.brand-sub { font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.clock { display: flex; flex-direction: column; align-items: flex-start; padding: 2px 12px; border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
.clock-time { font-size: 18px; font-weight: 600; letter-spacing: .01em; }
.clock-sub { font-size: 11px; color: var(--muted); }
.timectl { display: flex; gap: 4px; align-items: center; }
.tools { display: flex; gap: 6px; align-items: center; margin-left: auto; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 36px; padding: 0 12px; border-radius: var(--radius-sm);
  background: var(--surface-2); border: 1px solid var(--line-2); color: var(--text);
  cursor: pointer; font-weight: 500; white-space: nowrap; transition: background .15s, border-color .15s;
}
.btn:hover { background: var(--surface-3); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: #3d7af0; }
.btn-danger { background: #3b1620; border-color: #7f1d2d; color: #fecdd3; }
.btn-danger:hover { background: #561d2b; }
.btn-ghost { background: transparent; }
.btn-icon { width: 38px; padding: 0; position: relative; }
.btn-seg { min-width: 42px; padding: 0 8px; font-family: var(--mono); font-size: 13px; }
.btn-seg[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
#btn-pause { width: auto; padding: 0 12px; gap: 6px; }
#btn-pause .ic-play { display: none; }
#btn-pause.is-paused { background: #3a2a07; border-color: var(--warn); color: var(--warn); }
#btn-pause.is-paused .ic-play { display: block; }
#btn-pause.is-paused .ic-pause { display: none; }
#btn-sound[aria-pressed="false"] { color: var(--muted); }
#btn-sound[aria-pressed="false"]::after { content: ''; position: absolute; width: 22px; height: 2px; background: currentColor; transform: rotate(-40deg); }
.count { position: absolute; top: -5px; right: -5px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--s-returning); color: #0b1220; font-size: 11px; font-weight: 700; display: grid; place-items: center; }
.count.is-urgent { background: var(--warn); }
.btn-pulse { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(244, 114, 182, .5); } 50% { box-shadow: 0 0 0 6px rgba(244, 114, 182, 0); } }

/* KPI strip */
.kpis { background: var(--bg-2); border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.kpis::-webkit-scrollbar { display: none; }
.kpis dl { display: flex; margin: 0; min-width: max-content; }
.kpi { padding: 7px 16px; border-right: 1px solid var(--line); }
.kpi dt { font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); white-space: nowrap; }
.kpi dd { margin: 1px 0 0; font: 600 15px/1.2 var(--mono); white-space: nowrap; }
.kpi dd[data-tone="pos"] { color: var(--pos); } .kpi dd[data-tone="neg"] { color: var(--neg); }
.kpi-hero { background: rgba(79, 140, 255, .07); }
.kpi-hero dd { font-size: 17px; }

/* Main area */
.main { display: grid; grid-template-columns: minmax(0, 1fr) var(--panel-w); min-height: 0; }
.map-wrap { position: relative; min-height: 0; background: #0d1626; }
.map { position: absolute; inset: 0; background: #0d1626; }

/* Tile styles */
.map.tiles-dark .leaflet-tile-pane { filter: invert(1) hue-rotate(185deg) brightness(.92) contrast(.88) saturate(.55); }
.map.tiles-muted .leaflet-tile-pane { filter: grayscale(.55) brightness(.78) contrast(1.05); }
.leaflet-container { background: #0d1626; font-family: var(--font); }
.leaflet-control-attribution { background: rgba(11, 18, 32, .82) !important; color: var(--text-2) !important; font-size: 11px; }
.leaflet-control-attribution a { color: var(--accent-2) !important; }
.leaflet-bar a, .leaflet-bar a:hover { background: var(--surface-2); color: var(--text); border-bottom-color: var(--line-2); }
.leaflet-bar { border: 1px solid var(--line-2) !important; box-shadow: 0 4px 14px rgba(0, 0, 0, .35) !important; }
.map-fit a { width: auto !important; padding: 0 9px; font-size: 12px; font-weight: 600; line-height: 30px !important; height: 30px !important; }
.leaflet-touch .map-fit a { line-height: 32px !important; height: 32px !important; }

/* Hubs */
.hub-label { background: rgba(11, 18, 32, .86); border: 1px solid var(--line-2); color: var(--text); border-radius: 6px; padding: 2px 7px; font-size: 11.5px; box-shadow: none; }
.hub-label::before { display: none; }
.hub-label b { font-weight: 600; }
.hub-gw { display: block; color: var(--gold); font-size: 10.5px; }
.map.z-far .hub-label:not(.hub-label-gw) { display: none; }

/* Truck markers */
.tk-wrap { background: none; border: 0; }
.tk {
  position: relative; width: 30px; height: 30px; border-radius: 9px;
  display: grid; place-items: center; background: var(--c, var(--s-available));
  border: 2px solid #0b1220; box-shadow: 0 2px 8px rgba(0, 0, 0, .55);
  transition: transform .35s ease, opacity .2s; cursor: pointer;
}
.tk-num { font: 700 12px/1 var(--mono); color: #07101d; position: relative; z-index: 1; }
.tk-arrow { position: absolute; inset: -9px; pointer-events: none; opacity: 0; transition: opacity .2s; }
.tk-arrow::before { content: ''; position: absolute; left: 50%; top: 0; transform: translateX(-50%); border: 5px solid transparent; border-bottom: 7px solid var(--c); border-top: 0; filter: drop-shadow(0 0 1px #0b1220); }
.tk.is-moving .tk-arrow { opacity: 1; }
.tk-dest { position: absolute; left: 30px; top: 50%; transform: translateY(-50%); font: 600 10.5px/1 var(--mono); font-style: normal; color: var(--gold); background: rgba(11, 18, 32, .9); border-radius: 4px; padding: 3px 5px; white-space: nowrap; pointer-events: none; }
.tk-dest:empty { display: none; }
.tk.is-off { opacity: .8; border-style: dashed; }
.tk.is-sel { border-color: #fff; box-shadow: 0 0 0 3px rgba(255, 255, 255, .35), 0 2px 10px rgba(0, 0, 0, .6); }
.tk.is-rec { box-shadow: 0 0 0 3px var(--s-available), 0 0 16px rgba(34, 197, 94, .7); }
.tk.is-cand { box-shadow: 0 0 0 2px rgba(34, 197, 94, .6); }
.tk.is-dim { opacity: .35; }
.s-available { --c: var(--s-available); } .s-pickup { --c: var(--s-pickup); } .s-loading { --c: var(--s-loading); }
.s-bol { --c: var(--s-bol); } .s-delivery { --c: var(--s-delivery); } .s-unloading { --c: var(--s-unloading); }
.s-returning { --c: var(--s-returning); } .s-offduty { --c: var(--s-offduty); }
.tk.s-bol { animation: pulse 1.6s ease-in-out infinite; }

/* Pins & routes */
.pin-wrap { background: none; border: 0; }
.pin { width: 26px; height: 26px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg); display: grid; place-items: center; border: 2px solid #0b1220; box-shadow: 0 3px 8px rgba(0, 0, 0, .5); }
.pin span { transform: rotate(45deg); font: 700 12px/1 var(--font); color: #07101d; }
.pin-pu { background: var(--s-pickup); }
.pin-dl { background: var(--s-delivery); }
path.rt { fill: none; stroke-linecap: round; stroke-linejoin: round; }
path.rt-loaded { stroke: var(--s-delivery); stroke-width: 5; stroke-opacity: .95; }
path.rt-plan { stroke-opacity: .75; }
path.rt-dh { stroke: var(--s-pickup); stroke-width: 4; stroke-dasharray: 2 9; }
path.rt-rec { stroke-opacity: .95; }
path.rt-alt { stroke-opacity: .35; stroke-width: 3; }

/* Map overlays */
.map-notice { position: absolute; z-index: 900; left: 50%; top: 14px; transform: translateX(-50%); max-width: min(520px, calc(100% - 120px)); background: rgba(19, 29, 47, .96); border: 1px solid var(--warn); border-radius: var(--radius); padding: 10px 14px; display: flex; flex-direction: column; gap: 2px; font-size: 13px; color: var(--text-2); box-shadow: 0 8px 24px rgba(0, 0, 0, .4); }
.map-notice b { color: var(--warn); padding-right: 22px; }
.notice-x { position: absolute; top: 6px; right: 6px; width: 26px; height: 26px; border: 0; border-radius: 6px; background: transparent; color: var(--text-2); cursor: pointer; }
.notice-x:hover { background: var(--surface-3); }
.alerts-float { position: absolute; z-index: 800; top: 12px; right: 12px; display: flex; flex-direction: column; gap: 6px; max-width: min(380px, calc(100% - 140px)); }
.legend { position: absolute; z-index: 700; left: 12px; bottom: 26px; display: flex; flex-wrap: wrap; gap: 4px 10px; max-width: 420px; padding: 6px 10px; border-radius: var(--radius-sm); background: rgba(11, 18, 32, .82); border: 1px solid var(--line); font-size: 11px; color: var(--text-2); }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; background: var(--c); }
.paused-flag { position: absolute; z-index: 700; left: 50%; bottom: 26px; transform: translateX(-50%); padding: 4px 12px; border-radius: 999px; background: rgba(58, 42, 7, .92); color: var(--warn); border: 1px solid var(--warn); font-weight: 600; font-size: 12px; letter-spacing: .08em; text-transform: uppercase; display: none; }
.app.is-paused .paused-flag { display: block; }

/* Alerts */
.al { display: flex; align-items: flex-start; gap: 8px; width: 100%; text-align: left; padding: 7px 10px; border-radius: var(--radius-sm); border: 1px solid var(--line-2); background: rgba(19, 29, 47, .95); color: var(--text); font-size: 12.5px; cursor: pointer; box-shadow: 0 4px 14px rgba(0, 0, 0, .35); }
.al:hover { background: var(--surface-3); }
.al i { flex: none; width: 8px; height: 8px; border-radius: 50%; margin-top: 5px; background: var(--s-returning); }
.al.lv-action { border-color: rgba(244, 114, 182, .6); } .al.lv-action i { background: var(--s-bol); }
.al.lv-warn { border-color: rgba(251, 191, 36, .5); } .al.lv-warn i { background: var(--warn); }
.al-more { justify-content: center; color: var(--text-2); }
.alerts-pop { position: absolute; z-index: 1300; top: calc(100% + 6px); right: 12px; width: min(420px, calc(100vw - 24px)); max-height: min(70vh, 640px); overflow: auto; background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--radius); padding: 12px; box-shadow: 0 18px 40px rgba(0, 0, 0, .5); }
.alerts-pop h2 { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 4px 2px 8px; }
.al-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.al-list .al { box-shadow: none; }
.activity { list-style: none; margin: 0; padding: 0; font-size: 12.5px; color: var(--text-2); }
.activity li { padding: 5px 2px; border-top: 1px solid var(--line); }
.activity time { font-family: var(--mono); color: var(--muted); margin-right: 6px; }
.activity .lv-good { color: #b7f0d6; } .activity .lv-warn { color: #fde3a1; } .activity .lv-action { color: #fbcfe8; }

/* Panel */
.panel { position: relative; display: flex; flex-direction: column; min-height: 0; background: var(--surface); border-left: 1px solid var(--line); }
.panel-handle { display: none; }
.tabs { display: flex; border-bottom: 1px solid var(--line); background: var(--bg-2); }
.tabs [role="tab"] { flex: 1; padding: 11px 8px; background: none; border: 0; border-bottom: 2px solid transparent; color: var(--text-2); font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.tabs [role="tab"][aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }
.pill { font: 600 11px/1 var(--mono); padding: 3px 6px; border-radius: 999px; background: var(--surface-3); color: var(--text-2); }
.panel-body { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; }
.list { padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.hint { margin: 0; color: var(--muted); font-size: 12.5px; }
.foot { margin: 8px 0 0; color: var(--muted); font-size: 11.5px; }
.empty { color: var(--muted); text-align: center; padding: 24px 12px; margin: 0; }

.tag { display: inline-block; font-size: 10.5px; font-weight: 600; letter-spacing: .02em; padding: 2px 6px; border-radius: 5px; background: var(--surface-3); color: var(--text-2); white-space: nowrap; }
.tag-hot { background: rgba(251, 113, 133, .16); color: var(--hot); }
.tag-eq { background: rgba(79, 140, 255, .14); color: var(--accent-2); }
.tag-off { background: rgba(201, 162, 39, .15); color: var(--gold); }
.tag-rec { background: rgba(34, 197, 94, .16); color: #6ee7a0; }
.tag-close { background: rgba(245, 158, 11, .15); color: #fcd34d; }

/* Load rows */
.lrow { display: flex; flex-direction: column; gap: 4px; width: 100%; text-align: left; padding: 10px 12px; border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--line); cursor: pointer; color: var(--text); }
.lrow:hover { border-color: var(--line-2); background: #1c2a42; }
.lrow.is-urgent { border-color: rgba(251, 191, 36, .45); }
.lr-top { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.lid { font-weight: 600; font-size: 12.5px; }
.exp { margin-left: auto; font-size: 11.5px; color: var(--muted); }
.exp.warn { color: var(--warn); font-weight: 600; }
.lr-route { font-weight: 600; font-size: 15px; }
.arrow { color: var(--muted); font-weight: 400; }
.lr-meta { font-size: 12px; color: var(--text-2); }
.lr-money { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; font-size: 12.5px; }
.rev { font: 600 15px var(--mono); }
.contrib { font-family: var(--mono); font-weight: 600; }
.fits { margin-left: auto; color: var(--text-2); font-size: 11.5px; }
.fits.none { color: var(--muted); }

/* Fleet rows */
.frow { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center; width: 100%; text-align: left; padding: 9px 10px; border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--line); cursor: pointer; color: var(--text); }
.frow:hover { border-color: var(--line-2); background: #1c2a42; }
.frow.is-action { border-color: rgba(244, 114, 182, .55); }
.tbadge { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 8px; background: var(--c); color: #07101d; font: 700 13px/1 var(--mono); flex: none; }
.fr-main { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.fr-top { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.fr-top small { color: var(--muted); }
.fr-status { color: var(--c); font-weight: 600; font-size: 12.5px; }
.fr-meta { font-size: 12px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fr-duty { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; width: 58px; }
.fr-duty small { font: 500 11px var(--mono); color: var(--text-2); }
.bar { width: 100%; height: 5px; border-radius: 3px; background: var(--surface-3); overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--s-available); }
.bar i.low { background: var(--warn); }

/* Detail views */
.detail { padding: 12px; }
.dhead { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.dhead h2 { flex: 1; font-size: 17px; margin: 0; display: flex; align-items: center; gap: 8px; }
.dhead .btn { min-height: 32px; padding: 0 10px; font-size: 13px; }
.route-big { font-size: 18px; font-weight: 600; margin: 4px 0 10px; }
.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; margin: 0 0 12px; }
.facts > div { background: var(--surface-2); padding: 8px 10px; min-width: 0; }
.facts dt { font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.facts dd { margin: 2px 0 0; font-size: 13px; overflow-wrap: anywhere; }
.facts dd small { display: block; color: var(--muted); font-size: 11.5px; }
.facts-3 { grid-template-columns: repeat(3, 1fr); }
.sec { font-size: 12px; text-transform: uppercase; letter-spacing: .07em; color: var(--text-2); margin: 16px 0 8px; display: flex; gap: 8px; align-items: baseline; }
.sec small { text-transform: none; letter-spacing: 0; color: var(--muted); font-weight: 400; }
.callout { padding: 10px 12px; border-radius: var(--radius); background: rgba(79, 140, 255, .1); border: 1px solid rgba(79, 140, 255, .3); margin-bottom: 12px; font-size: 13px; }
.link { background: none; border: 0; padding: 0; color: var(--accent-2); cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.cands { display: flex; flex-direction: column; gap: 6px; }
.cand { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center; padding: 10px; border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--line); }
.cand.is-rec { border-color: rgba(34, 197, 94, .6); background: rgba(34, 197, 94, .06); }
.cand.is-no { grid-template-columns: auto 1fr; opacity: .78; padding: 7px 10px; }
.cand.is-no .tbadge { width: 26px; height: 26px; font-size: 11px; opacity: .8; }
.cand-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; font-size: 13px; }
.cand-main small { color: var(--muted); font-size: 11.5px; }
.cand-nums { display: flex; gap: 10px; flex-wrap: wrap; font-size: 12px; color: var(--text-2); }
.cand-econ { font-size: 12.5px; }
.cand-econ b { font-family: var(--mono); }
.why { font-size: 12px; color: var(--text-2); }
.why.warn { color: var(--warn); }
.steps { display: flex; list-style: none; padding: 0; margin: 4px 0 12px; gap: 3px; counter-reset: s; }
.steps li { flex: 1; font-size: 10.5px; text-align: center; color: var(--muted); padding-top: 9px; border-top: 3px solid var(--surface-3); }
.steps li.done { border-top-color: var(--accent); color: var(--text-2); }
.steps li.cur { border-top-color: var(--s-bol); color: var(--text); font-weight: 600; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; padding: 10px; border-radius: var(--radius); background: var(--bg-2); border: 1px solid var(--line); }
.actions .hint { width: 100%; }
.repo { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.repo label { font-size: 12.5px; color: var(--text-2); }
select, input[type="number"] { background: var(--bg); border: 1px solid var(--line-2); border-radius: var(--radius-sm); min-height: 36px; padding: 0 8px; }
.grade { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 6px; font: 700 12px/1 var(--mono); }
.g-A { background: rgba(34, 197, 94, .2); color: #6ee7a0; } .g-B { background: rgba(56, 189, 248, .18); color: #7dd3fc; }
.g-C { background: rgba(251, 191, 36, .18); color: #fcd34d; } .g-D { background: rgba(248, 113, 113, .2); color: #fca5a5; }
.grades { font-size: 12.5px; color: var(--text-2); margin: 0 0 10px; }
.tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }
.hist { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.hist th { text-align: left; font-size: 10.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 7px 8px; background: var(--bg-2); position: sticky; top: 0; }
.hist td { padding: 7px 8px; border-top: 1px solid var(--line); white-space: nowrap; }
.hist tr.is-exp td { color: var(--muted); }

.disclaimer { padding: 5px 14px; font-size: 11.5px; color: var(--muted); background: var(--bg-2); border-top: 1px solid var(--line); }

/* Toasts */
.toasts { position: fixed; z-index: 1500; left: 50%; bottom: 46px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 6px; width: min(460px, calc(100vw - 24px)); pointer-events: none; }
.toast { pointer-events: auto; padding: 9px 12px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--line-2); border-left: 4px solid var(--s-returning); font-size: 13px; box-shadow: 0 10px 28px rgba(0, 0, 0, .45); animation: tin .25s ease; transition: opacity .35s, transform .35s; }
.toast.is-click { cursor: pointer; }
.toast.lv-good { border-left-color: var(--pos); } .toast.lv-warn { border-left-color: var(--warn); } .toast.lv-action { border-left-color: var(--s-bol); }
.toast.out { opacity: 0; transform: translateY(6px); }
@keyframes tin { from { opacity: 0; transform: translateY(8px); } }

/* Dialogs */
.dlg { width: min(640px, calc(100vw - 24px)); max-height: calc(100dvh - 32px); padding: 0; border: 1px solid var(--line-2); border-radius: 14px; background: var(--surface); color: var(--text); box-shadow: 0 30px 70px rgba(0, 0, 0, .6); }
.dlg::backdrop { background: rgba(3, 7, 15, .6); }
.dlg > form, .dlg > div { padding: 16px 18px; }
.dlg-small { width: min(440px, calc(100vw - 24px)); }
.dlg-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.dlg-head h2 { margin: 0; font-size: 18px; }
.dlg-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; flex-wrap: wrap; }
.lede { color: var(--text-2); font-size: 13.5px; margin: 0 0 12px; }
.check { display: flex; gap: 10px; align-items: flex-start; padding: 6px 0; cursor: pointer; font-size: 13.5px; }
.check input { width: 18px; height: 18px; margin: 1px 0 0; accent-color: var(--accent); flex: none; }
.grid-fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; margin-bottom: 8px; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--text-2); }
.field small { color: var(--muted); }
.field-inline { flex-direction: row; align-items: center; gap: 10px; padding-top: 6px; }
.toggles { border: 1px solid var(--line); border-radius: var(--radius); padding: 6px 12px 8px; margin: 12px 0 0; }
.toggles legend { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); padding: 0 6px; }
.howto { padding-left: 20px; margin: 0 0 12px; display: flex; flex-direction: column; gap: 8px; font-size: 14px; color: var(--text-2); }
.howto b { color: var(--text); }
.keys { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 4px 12px; margin: 0; font-size: 12.5px; }
.keys div { display: flex; gap: 8px; }
.keys dt { font-family: var(--mono); color: var(--accent-2); min-width: 64px; }
.keys dd { margin: 0; color: var(--text-2); }

/* BOL document */
.bol { background: #f4f1e8; color: #1d2430; border-radius: 8px; padding: 14px 16px; font-size: 13px; }
.bol-head { display: flex; justify-content: space-between; gap: 10px; border-bottom: 2px solid #1d2430; padding-bottom: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.bol-kicker { font-size: 10.5px; text-transform: uppercase; letter-spacing: .1em; color: #5b6472; }
.bol-head h3 { margin: 2px 0 0; font-size: 20px; }
.bol-ids { display: flex; flex-direction: column; align-items: flex-end; font-size: 12.5px; }
.bol-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; }
.bol-grid h4 { margin: 0 0 2px; font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; color: #5b6472; }
.bol-grid p { margin: 0; }
.bol-table { width: 100%; border-collapse: collapse; margin-top: 12px; }
.bol-table th, .bol-table td { border: 1px solid #b9b3a3; padding: 6px 8px; text-align: left; }
.bol-table th { font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; background: #e7e2d4; }
.dlg-bol .check { margin-top: 10px; }
.noscript { padding: 24px; text-align: center; }

/* ── Tablet / phone ─────────────────────────────────────────────────────── */
@media (max-width: 1280px) {
  .kpi { padding: 7px 11px; }
  .kpi dd { font-size: 14px; }
  .kpi-hero dd { font-size: 15px; }
}
@media (max-width: 1180px) {
  :root { --panel-w: 380px; }
  .brand-sub { display: none; }
}
@media (max-width: 860px) {
  body { font-size: 14px; }
  .topbar { gap: 8px; padding: 6px 10px; }
  .brand-text { display: none; }
  .brand-mark { width: 32px; height: 32px; }
  .clock { padding: 0 8px; border: 0; }
  .clock-time { font-size: 16px; }
  #btn-pause .lbl { display: none; }
  #btn-pause { width: 38px; padding: 0; }
  #btn-newload span { display: none; }
  #btn-newload { width: 38px; padding: 0; }
  .tools { gap: 4px; }
  .timectl { order: 3; }
  .tools { order: 2; }
  .btn { min-height: 38px; }
  .btn-seg { min-width: 38px; }
  .kpi { padding: 5px 12px; }
  .kpi dd { font-size: 14px; }

  .main { position: relative; display: block; }
  .map-wrap { position: absolute; inset: 0; }
  .panel {
    position: absolute; left: 0; right: 0; bottom: 0; z-index: 1000;
    height: min(54%, 520px); border-left: 0; border-top: 1px solid var(--line-2);
    border-radius: 16px 16px 0 0; box-shadow: 0 -12px 30px rgba(0, 0, 0, .45);
    transition: height .25s ease;
  }
  .app.panel-collapsed .panel { height: 76px; }
  .app.panel-collapsed .panel-body { visibility: hidden; }
  .panel-handle { display: flex; justify-content: center; align-items: center; height: 22px; width: 100%; border: 0; background: none; cursor: pointer; padding: 0; flex: none; }
  .grip { width: 44px; height: 5px; border-radius: 3px; background: var(--line-2); }
  .tabs [role="tab"] { padding: 9px 4px 11px; }
  .legend { display: none; }
  .alerts-float { top: 8px; right: 8px; left: 56px; max-width: none; }
  .map-notice { top: auto; bottom: calc(min(54%, 520px) + 12px); max-width: calc(100% - 24px); font-size: 12px; padding: 8px 12px; }
  .app.panel-collapsed .map-notice { bottom: 90px; }
  .paused-flag { bottom: auto; top: 54px; }
  .toasts { bottom: auto; top: 118px; }
  .al-more { display: none; }
  .disclaimer .long { display: none; }
  .facts-3 { grid-template-columns: 1fr 1fr; }
  .disclaimer { font-size: 10.5px; padding: 4px 10px; }
  .cand { grid-template-columns: auto 1fr; }
  .cand > .btn { grid-column: 1 / -1; width: 100%; }
  .bol-grid { grid-template-columns: 1fr; }
  .leaflet-control-attribution { font-size: 10px; }
  .app:not(.panel-collapsed) .leaflet-bottom { bottom: min(54%, 520px); }
  .app.panel-collapsed .leaflet-bottom { bottom: 76px; }
}
@media (max-width: 420px) {
  .clock-sub { display: none; }
  .btn-icon { width: 34px; }
  #btn-reset { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
