:root {
  --bg: #02040a; --panel: rgba(10, 16, 26, 0.82); --panel-solid: #0b111b; --line: rgba(160, 190, 230, 0.16); --text: #e8eef6; --dim: #9aa8ba; --faint: #6b7a8e;
  --accent: #3fb6ff; --hot: #ff6b3d; --ok: #3ddc84; --warn: #ffb020; --bad: #ff4d4f; --truck: #ffb04a; --train: #c890ff; --ship: #46d0ff; --plane: #ffffff;
  --r: 12px; --font: Inter, system-ui, -apple-system, "Segoe UI", sans-serif; --mono: "JetBrains Mono", ui-monospace, monospace;
  color-scheme: dark;
}
/* The twin is drawn against space, so the page stays dark in both schemes; the light theme only lifts the panels. */
@media (prefers-color-scheme: light) { :root:not([data-theme="dark"]) { --panel: rgba(12, 19, 31, 0.86); } }
:root[data-theme="light"] { --panel: rgba(12, 19, 31, 0.86); }
:root[data-theme="dark"] { --panel: rgba(10, 16, 26, 0.82); }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--text); font: 13px/1.4 var(--font); -webkit-font-smoothing: antialiased; }
canvas#view { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; touch-action: none; cursor: grab; }
canvas#view:active { cursor: grabbing; }
button { font: inherit; color: inherit; background: rgba(255, 255, 255, 0.06); border: 1px solid var(--line); border-radius: 8px; padding: 5px 10px; cursor: pointer; }
button:hover { background: rgba(255, 255, 255, 0.12); }
button.on, button.primary { background: var(--accent); color: #031220; border-color: transparent; font-weight: 600; }
.mono { font-family: var(--mono); }
.hidden { display: none !important; }
.panel { position: fixed; background: var(--panel); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border: 1px solid var(--line); border-radius: var(--r); box-shadow: 0 10px 40px rgba(0, 0, 0, 0.45); z-index: 5; display: flex; flex-direction: column; max-height: calc(100vh - 86px); }
.ph { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px 6px 14px; gap: 8px; }
.ph h2 { margin: 0; font-size: 14px; font-weight: 600; letter-spacing: 0.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ph button { padding: 1px 8px; border: none; background: none; font-size: 18px; line-height: 1; color: var(--dim); }
.pb { padding: 2px 14px 14px; overflow-y: auto; }
.pb h3 { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--faint); margin: 14px 0 6px; font-weight: 600; }
#bar { position: fixed; top: 10px; left: 10px; right: 10px; display: flex; align-items: center; gap: 14px; z-index: 6; pointer-events: none; flex-wrap: wrap; }
#bar > * { pointer-events: auto; }
.brand { font-size: 16px; letter-spacing: 0.02em; display: flex; align-items: center; gap: 7px; background: var(--panel); padding: 7px 12px; border-radius: 10px; border: 1px solid var(--line); }
.brand.big { font-size: 26px; background: none; border: none; justify-content: center; }
.logo { width: 16px; height: 16px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #7fd3ff, #1667a8 60%, #0b1a2e); box-shadow: 0 0 10px #3fb6ff88; display: inline-block; }
.brand.big .logo { width: 26px; height: 26px; }
.clock { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 7px 12px; display: flex; gap: 8px; align-items: baseline; }
.clock #time { font-size: 15px; font-weight: 600; }
.clock .utc, .clock #date { color: var(--dim); }
.speed { display: flex; gap: 2px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
.speed button { border: none; background: none; padding: 4px 8px; border-radius: 7px; color: var(--dim); white-space: nowrap; }
.speed button.on { background: var(--accent); color: #031220; }
.find { margin-left: auto; }
.find input { background: var(--panel); border: 1px solid var(--line); color: var(--text); border-radius: 10px; padding: 8px 12px; width: 260px; font: inherit; outline: none; }
.find input:focus { border-color: var(--accent); }
#chain { left: 10px; top: 64px; width: 330px; }
#detail { right: 10px; top: 64px; width: 380px; }
.modes { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 4px 0 8px; }
.mode { background: rgba(255, 255, 255, 0.04); border-radius: 9px; padding: 7px 8px; border-top: 2px solid var(--c); }
.mode b { display: block; font-size: 17px; font-family: var(--mono); font-weight: 600; }
.mode span { color: var(--dim); font-size: 11px; }
.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; }
.kpi span { color: var(--dim); font-size: 11px; display: block; }
.kpi b { font-family: var(--mono); font-size: 14px; font-weight: 600; }
.kpi b.bad { color: var(--bad); } .kpi b.ok { color: var(--ok); }
table { width: 100%; border-collapse: collapse; }
td, th { padding: 4px 4px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--faint); font-weight: 500; font-size: 11px; }
td.n, th.n { text-align: right; font-family: var(--mono); white-space: nowrap; }
tr.click { cursor: pointer; } tr.click:hover td { background: rgba(255, 255, 255, 0.05); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--c); margin-right: 6px; vertical-align: 1px; }
.tabs { display: flex; gap: 4px; margin: 14px 0 6px; }
.tabs button { padding: 3px 9px; font-size: 12px; }
ul.ships { list-style: none; margin: 0; padding: 0; }
ul.ships li { padding: 7px 4px; border-bottom: 1px solid var(--line); cursor: pointer; display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; }
ul.ships li:hover { background: rgba(255, 255, 255, 0.05); }
ul.ships .c { font-weight: 600; } ul.ships .r { color: var(--dim); font-size: 12px; grid-column: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
ul.ships .e { text-align: right; font-family: var(--mono); font-size: 12px; } ul.ships .m { text-align: right; color: var(--dim); font-size: 11px; }
.late { color: var(--bad); } .ontime { color: var(--ok); }
.tag { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 99px; background: rgba(255, 255, 255, 0.08); color: var(--dim); margin-right: 4px; }
.tag.run { background: #3ddc8422; color: var(--ok); } .tag.wait { background: #ff4d4f22; color: var(--bad); } .tag.hold { background: #ffb02022; color: var(--warn); }
.route { display: flex; align-items: center; gap: 8px; margin: 6px 0 10px; font-size: 14px; }
.route .arrow { color: var(--faint); }
.prog { height: 6px; border-radius: 3px; background: rgba(255, 255, 255, 0.08); overflow: hidden; margin: 6px 0 4px; }
.prog i { display: block; height: 100%; background: var(--c, var(--accent)); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px; margin: 8px 0; }
.grid2 span { color: var(--dim); font-size: 11px; display: block; }
.grid2 b { font-family: var(--mono); font-weight: 600; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; margin: 10px 0 4px; }
a.link, span.link { color: var(--accent); cursor: pointer; text-decoration: none; }
a.link:hover, span.link:hover { text-decoration: underline; }
canvas.spark { width: 100%; height: 54px; display: block; margin-top: 4px; }
.legs { list-style: none; padding: 0; margin: 4px 0; }
.legs li { padding: 6px 0 6px 18px; border-left: 2px solid var(--c); margin-left: 4px; position: relative; }
.legs li.now { background: rgba(255, 255, 255, 0.05); }
.legs li::before { content: ""; position: absolute; left: -6px; top: 10px; width: 10px; height: 10px; border-radius: 50%; background: var(--c); }
.order { display: grid; grid-template-columns: 1fr 90px auto; gap: 6px; margin-top: 6px; }
.order select, .order input { background: rgba(255, 255, 255, 0.06); border: 1px solid var(--line); color: var(--text); border-radius: 8px; padding: 5px 8px; font: inherit; min-width: 0; }
.note { color: var(--faint); font-size: 12px; margin: 8px 0 0; }
.chips { position: fixed; left: 10px; bottom: 30px; display: flex; gap: 6px; z-index: 5; flex-wrap: wrap; }
.chips label { background: var(--panel); border: 1px solid var(--line); border-radius: 99px; padding: 4px 10px 4px 8px; display: flex; gap: 6px; align-items: center; cursor: pointer; user-select: none; font-size: 12px; }
.chips input { display: none; }
.chips i { width: 9px; height: 9px; border-radius: 50%; background: var(--c); display: inline-block; }
.chips label:has(input:not(:checked)) { opacity: 0.45; }
#localbar { position: fixed; top: 64px; left: 50%; transform: translateX(-50%); z-index: 6; display: flex; gap: 12px; align-items: center; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 6px 8px 6px 6px; backdrop-filter: blur(12px); }
#localbar b { font-size: 14px; } #localbar span { color: var(--dim); margin-left: 8px; }
#hint { position: fixed; bottom: 70px; left: 50%; transform: translateX(-50%); z-index: 6; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 8px 10px 8px 14px; display: flex; gap: 10px; align-items: center; }
#zoombtns { position: fixed; right: 10px; bottom: 30px; display: flex; flex-direction: column; gap: 4px; z-index: 5; }
#zoombtns button { width: 34px; height: 34px; font-size: 18px; padding: 0; background: var(--panel); }
#labels { position: fixed; inset: 0; pointer-events: none; z-index: 2; overflow: hidden; }
#labels div { position: absolute; transform: translate(8px, -50%); font-size: 11px; color: #e8eef6; text-shadow: 0 1px 3px #000, 0 0 6px #000; white-space: nowrap; font-weight: 500; }
#labels div.f { color: #ffd2c2; } #labels div.p { color: #bfe6ff; } #labels div.sel { font-size: 13px; font-weight: 700; color: #fff; }
#loading { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; background: radial-gradient(ellipse at center, rgba(4, 10, 22, 0.55), rgba(2, 4, 10, 0.92)); transition: opacity 0.6s; }
#loading.done { opacity: 0; pointer-events: none; }
.lbox { width: min(420px, calc(100vw - 32px)); text-align: center; }
.lbox .bar { height: 4px; background: rgba(255, 255, 255, 0.1); border-radius: 2px; overflow: hidden; margin: 14px 0; }
.lbox .bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width 0.2s; }
.lbox .small { color: var(--faint); font-size: 12px; }
#credits { position: fixed; bottom: 6px; left: 12px; right: 12px; font-size: 10px; color: var(--faint); z-index: 4; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; pointer-events: none; }
.machine { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; margin: 8px 0; }
.machine div { background: rgba(255, 255, 255, 0.04); border-radius: 8px; padding: 6px 8px; }
.machine span { display: block; color: var(--dim); font-size: 11px; } .machine b { font-family: var(--mono); }
@media (max-width: 760px) {
  #bar { top: 8px; left: 8px; right: 8px; gap: 6px; }
  .clock { padding: 5px 8px; } .brand { padding: 5px 9px; font-size: 14px; }
  .speed { order: 3; width: 100%; justify-content: space-between; overflow-x: auto; }
  .find { order: 4; width: 100%; margin: 0; } .find input { width: 100%; }
  #chain { left: 8px; right: 8px; width: auto; top: auto; bottom: 64px; max-height: 38vh; }
  #chain.folded .pb { display: none; }
  #detail { left: 8px; right: 8px; width: auto; top: auto; bottom: 64px; max-height: 52vh; z-index: 7; }
  .chips { bottom: 26px; left: 8px; right: 54px; overflow-x: auto; flex-wrap: nowrap; }
  #localbar { top: auto; bottom: 64px; }
  #credits { font-size: 9px; }
}
#chain.folded .pb { display: none; }
