:root {
  --bg: #0b0e12; --panel: #131820; --panel2: #1a2029; --line: #273040;
  --text: #e6ebf2; --dim: #8a95a6; --accent: #3b9cff; --ok: #22c55e; --warn: #f59e0b; --bad: #ef4444;
  --mono: ui-monospace, "Cascadia Mono", Consolas, "SFMono-Regular", Menlo, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 13px/1.4 system-ui, "Segoe UI", Roboto, sans-serif; overflow: hidden; }
button, select, input { font: inherit; color: inherit; }
button, .btn { background: var(--panel2); border: 1px solid var(--line); border-radius: 6px; padding: 5px 10px; cursor: pointer; white-space: nowrap; }
button:hover, .btn:hover { border-color: #3d4a60; background: #222a35; }
button.active { background: var(--accent); border-color: var(--accent); color: #fff; }
button.icon { width: 30px; padding: 5px 0; }
select { background: var(--panel2); border: 1px solid var(--line); border-radius: 6px; padding: 5px 8px; max-width: 460px; }
code, kbd { font-family: var(--mono); font-size: 12px; background: #1f2631; padding: 1px 5px; border-radius: 4px; }
.mono { font-family: var(--mono); }
.dim { color: var(--dim); }

body { display: grid; grid-template-rows: auto 1fr auto; }
.top { display: flex; align-items: center; gap: 14px; padding: 8px 12px; background: var(--panel); border-bottom: 1px solid var(--line); min-width: 0; }
.brand { font-weight: 700; font-size: 15px; white-space: nowrap; }
.brand .logo { color: var(--accent); }
.brand .sub { color: var(--dim); font-weight: 400; font-size: 12px; margin-left: 6px; }
.loader { display: flex; gap: 6px; align-items: center; min-width: 0; }
.runinfo { flex: 1; display: flex; gap: 6px; flex-wrap: nowrap; min-width: 0; overflow: hidden; }
.chip { background: var(--panel2); border: 1px solid var(--line); border-radius: 12px; padding: 2px 9px; font-size: 12px; white-space: nowrap; }
.chip.ok { border-color: #1f6f3f; color: #7ee2a8; }
.chip.bad { border-color: #7a2a2a; color: #ff9b9b; }
.chip.warn { border-color: #7a5a1a; color: #ffd27a; }

.layout { display: grid; grid-template-columns: 1fr 400px; min-height: 0; }
.mapwrap { position: relative; min-width: 0; min-height: 0; overflow: hidden; background: #0c0f13; }
.mapwrap canvas { position: absolute; inset: 0; }
.mapwrap canvas.dyn { cursor: grab; touch-action: none; }
.mapwrap canvas.dyn:active { cursor: grabbing; }
.maptools { position: absolute; top: 8px; left: 8px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  background: rgba(19,24,32,0.88); border: 1px solid var(--line); border-radius: 8px; padding: 5px 9px; }
.maptools label { display: flex; gap: 4px; align-items: center; cursor: pointer; white-space: nowrap; font-size: 12px; }
.legend { position: absolute; right: 8px; bottom: 8px; background: rgba(19,24,32,0.88); border: 1px solid var(--line); border-radius: 8px;
  padding: 6px 10px; font-size: 11px; color: #c3cbd8; display: grid; grid-template-columns: auto auto; gap: 2px 14px; }
.sw { display: inline-block; width: 12px; height: 10px; margin-right: 5px; vertical-align: -1px; border-radius: 2px; }
.sw.truth { background: #4ade80; } .sw.est { border: 2px dashed #f472b6; }
.sw.ped { background: #38bdf8; border-radius: 50%; width: 10px; } .sw.pednear { background: #ffb020; border-radius: 50%; width: 10px; margin-left: 6px; }
.sw.shadow { background: rgba(167,120,255,0.45); border: 1px dashed #a778ff; } .sw.speed { background: rgba(250,190,60,0.2); border: 1px dashed #fabe3c; }
.sw.forbidden { background: rgba(255,80,80,0.45); } .sw.people { background: rgba(70,200,255,0.15); border: 1px dashed #46c8ff; }
.sw.patch { background: rgba(255,140,30,0.6); border: 1px dashed #ff8c1a; } .sw.ref { border-top: 2px dashed #78e6a0; height: 0; }
.hovercoord { position: absolute; left: 110px; bottom: 8px; font: 11px var(--mono); color: var(--dim); pointer-events: none; }
.empty { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 40px; pointer-events: none; }
.empty h2 { margin: 0 0 8px; font-weight: 600; }
.empty p { max-width: 520px; margin: 4px 0; color: #c3cbd8; }
.empty.hidden { display: none; }

.side { display: flex; flex-direction: column; min-height: 0; border-left: 1px solid var(--line); background: var(--panel); }
.panel { padding: 10px 12px; border-bottom: 1px solid var(--line); }
.status .row { display: flex; gap: 6px 10px; align-items: center; margin-bottom: 6px; flex-wrap: wrap; }
.status .row.big > div { display: flex; flex-direction: column; margin-right: 18px; }
.status .row.big .val { font-size: 18px; font-weight: 600; white-space: nowrap; }
.lbl { color: var(--dim); font-size: 11px; }
.status .grid { display: grid; grid-template-columns: 58px 1fr 58px 1fr; gap: 2px 6px; font-size: 12px; }
.status .grid .span3 { grid-column: span 3; }
.status .grid .lbl { cursor: help; line-height: 18px; }
.status .grid .val { text-align: left; }
.stbadge { padding: 3px 10px; border-radius: 6px; font-weight: 700; color: #0b0e12; background: #555; white-space: nowrap; }
.note { color: #ffd27a; font-size: 12px; min-height: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1 1 140px; min-width: 0; }
.flags { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 8px; }
.flag { font-size: 11px; padding: 1px 7px; border-radius: 10px; border: 1px solid var(--line); color: var(--dim); }
.flag.on { color: #fff; background: var(--bad); border-color: var(--bad); }
.flag.okf { color: #7ee2a8; border-color: #1f6f3f; }
.val.bad { color: #ff7b7b; } .val.warn { color: #ffd27a; } .val.ok { color: #7ee2a8; }
.tabs { flex: 1; display: flex; flex-direction: column; min-height: 0; padding: 0; border-bottom: 0; }
.tabbar { display: flex; gap: 2px; padding: 6px 8px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.tabbar button { border-radius: 6px 6px 0 0; border-bottom: 0; padding: 4px 6px; font-size: 12px; background: transparent; }
.tabbar { flex-wrap: wrap; row-gap: 2px; }
.tabbar button.active { background: var(--panel2); color: var(--text); border-color: var(--line); }
.tabbody { flex: 1; overflow: auto; padding: 8px 10px; }

.bottom { background: var(--panel); border-top: 1px solid var(--line); padding: 6px 12px 8px; }
.controls { display: flex; gap: 6px; align-items: center; margin-bottom: 6px; }
.controls .play { width: 44px; font-size: 15px; background: var(--accent); border-color: var(--accent); color: #fff; }
.speeds { display: flex; margin-left: 10px; }
.speeds button { border-radius: 0; margin-left: -1px; }
.speeds button:first-child { border-radius: 6px 0 0 6px; } .speeds button:last-child { border-radius: 0 6px 6px 0; }
.clock { margin-left: 12px; font-size: 14px; }
.spacer { flex: 1; }
.stlegend { display: flex; gap: 10px; font-size: 11px; color: var(--dim); }
.stlegend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 4px; vertical-align: -1px; }
canvas.timeline { width: 100%; height: 94px; display: block; border-radius: 6px; cursor: pointer; touch-action: none; }
.charts { display: grid; grid-template-columns: 1fr; gap: 4px; margin-top: 4px; }
canvas.chart { width: 100%; height: 66px; display: block; border-radius: 6px; cursor: pointer; touch-action: none; }

.dropzone { position: fixed; inset: 0; background: rgba(59,156,255,0.18); border: 3px dashed var(--accent); display: none;
  align-items: center; justify-content: center; font-size: 20px; z-index: 50; pointer-events: none; }
.dropzone.on { display: flex; }
.dropzone > div { background: var(--panel); padding: 18px 26px; border-radius: 10px; }
.toast { position: fixed; left: 50%; top: 56px; transform: translateX(-50%); background: #2a1b1b; border: 1px solid #7a2a2a; color: #ffd0d0;
  padding: 8px 14px; border-radius: 8px; display: none; z-index: 60; max-width: 70vw; }
.toast.info { background: #16251c; border-color: #1f6f3f; color: #c9f5da; }
.toast.on { display: block; }
.modal { position: fixed; inset: 0; background: rgba(0,0,0,0.55); display: flex; align-items: center; justify-content: center; z-index: 70; }
.modal[hidden] { display: none; }
.modal .card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 16px 20px; min-width: 360px; max-width: 90vw; max-height: 90vh; overflow: auto; }
.modal h3 { margin: 0 0 10px; }
.modal td { padding: 3px 12px 3px 0; }
.modal .card > button { margin-top: 12px; }

@media (max-width: 1100px) {
  .layout { grid-template-columns: 1fr 320px; }
  .legend { display: none; }
}
table.kv { border-collapse: collapse; width: 100%; }
table.kv td { padding: 3px 6px 3px 0; vertical-align: top; border-bottom: 1px solid #1c232d; word-break: break-word; }
table.kv td.lbl { width: 140px; }
.small { font-size: 11px; }
.tbl { border-collapse: collapse; width: 100%; font-size: 12px; margin-top: 6px; }
.tbl th { position: sticky; top: -8px; background: var(--panel); text-align: left; font-weight: 500; color: var(--dim); font-size: 11px; padding: 4px 5px; border-bottom: 1px solid var(--line); }
.tbl td { padding: 4px 5px; border-bottom: 1px solid #1c232d; vertical-align: top; }
.tbl tr.click { cursor: pointer; }
.tbl tr.click:hover td { background: #1c2430; }
.tbl tr.now td { background: #1e2d44; }
.tbl tr.fatal td { background: #3a1414; }
.tbl a.jump { color: #7cc0ff; text-decoration: underline dotted; cursor: pointer; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; }
.summary { margin: 2px 0 6px; }
.summary .big { font-size: 20px; font-weight: 700; margin-right: 4px; }
.ok { color: #7ee2a8; } .bad { color: #ff7b7b; } .warn { color: #ffd27a; }
.bars, .blocks { display: flex; flex-direction: column; gap: 4px; margin: 6px 0 10px; }
.bar { display: grid; grid-template-columns: 130px 1fr 92px; gap: 8px; align-items: center; font-size: 12px; }
.bar .bl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar .bt { height: 10px; background: #1f2631; border-radius: 3px; overflow: hidden; }
.bar .bt i { display: block; height: 100%; }
.bar .bv { text-align: right; font-family: var(--mono); font-size: 11px; }
.bar.nc { opacity: 0.45; } .bar.sum { border-top: 1px solid var(--line); padding-top: 4px; font-weight: 600; }
.scorebig { font-size: 40px; font-weight: 700; line-height: 1.1; }
.scorebig .dim { font-size: 16px; font-weight: 400; }
.chips { display: flex; gap: 5px; flex-wrap: wrap; margin: 6px 0; }
pre.stderr { background: #0d1117; border: 1px solid var(--line); padding: 6px; font-size: 11px; max-height: 160px; overflow: auto; white-space: pre-wrap; }
.tltip { position: fixed; z-index: 40; background: #0d1117; border: 1px solid var(--line); padding: 3px 8px; border-radius: 5px; font-size: 12px; pointer-events: none; display: none; white-space: nowrap; }
.tltip.on { display: block; }

@media (max-height: 820px) {
  canvas.chart { height: 46px; }
  .panel { padding: 7px 10px; }
  .status .row.big .val { font-size: 16px; }
  .flags { margin-top: 4px; }
}
.legend { cursor: pointer; }
.legend .lhead { grid-column: 1 / -1; color: var(--dim); font-size: 10px; text-transform: uppercase; letter-spacing: 0.05em; }
.legend .lhead::after { content: ' ▾'; }
.legend.collapsed > div:not(.lhead) { display: none; }
.legend.collapsed .lhead::after { content: ' ▸'; }

button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover { background: #2f8ae8; }
button:disabled { opacity: 0.45; cursor: not-allowed; }
#cmpSelect { max-width: 170px; }
.modal .card.wide { width: 640px; }
.modal h4 { margin: 16px 0 6px; }
.runform { display: flex; flex-direction: column; gap: 8px; }
.runform label { display: flex; flex-direction: column; gap: 3px; color: var(--dim); font-size: 12px; }
.runform label.chk { flex-direction: row; align-items: center; gap: 6px; color: var(--text); }
.runform select, .runform input[type=number] { color: var(--text); background: var(--panel2); border: 1px solid var(--line); border-radius: 6px; padding: 5px 8px; max-width: none; }
.rfrow { display: flex; gap: 12px; }
.rfrow label { flex: 1; }
.joblist { display: flex; flex-direction: column; gap: 6px; max-height: 300px; overflow: auto; }
.job { border: 1px solid var(--line); border-radius: 8px; padding: 6px 9px; background: var(--panel2); }
.job .jh { display: flex; gap: 8px; align-items: center; }
.job .jn { flex: 1; font-weight: 600; }
.job pre { margin: 6px 0 0; font-size: 11px; max-height: 150px; overflow: auto; white-space: pre-wrap; background: #0d1117; padding: 6px; border-radius: 5px; }
.badge { font-size: 11px; padding: 1px 8px; border-radius: 10px; }
.badge.running { background: #1d3a5c; color: #9cd0ff; } .badge.done { background: #173d27; color: #7ee2a8; }
.badge.failed { background: #4a1c1c; color: #ffb3b3; } .badge.cancelled { background: #333; color: #bbb; }
.spin { display: inline-block; width: 10px; height: 10px; border: 2px solid #9cd0ff; border-right-color: transparent; border-radius: 50%; animation: spin 0.8s linear infinite; vertical-align: -1px; margin-right: 4px; }
@keyframes spin { to { transform: rotate(360deg); } }
.progress { height: 4px; background: #1f2631; border-radius: 2px; overflow: hidden; margin-top: 5px; }
.progress i { display: block; height: 100%; background: var(--accent); transition: width 0.5s; }
.csvbar { display: flex; justify-content: flex-end; gap: 6px; margin-bottom: 4px; }
.csvbar button { font-size: 11px; padding: 2px 8px; }
.chip.cmp { border-color: #22d3ee; color: #22d3ee; cursor: pointer; }
table.cmp td, table.cmp th { text-align: right; } table.cmp td:first-child, table.cmp th:first-child { text-align: left; }
@media (max-width: 1750px) { .brand .sub { display: none; } }
.alarm { display: none; max-width: 100%; overflow: hidden; text-overflow: ellipsis; padding: 3px 9px; border-radius: 6px; font-weight: 700; color: #0b0e12; white-space: nowrap; font-size: 12px; animation: blink 1s ease-in-out infinite alternate; }
.alarm.on { display: inline-block; }
@keyframes blink { from { opacity: 1; } to { opacity: 0.65; } }
.tabcount { display: inline-block; min-width: 16px; padding: 0 4px; border-radius: 8px; background: #3a4250; color: #e6ebf2; font-size: 10px; line-height: 15px; text-align: center; margin-left: 2px; }
.tabcount.crit { background: #ef4444; color: #fff; }
.chip.alarmchip { cursor: pointer; }
.chip.alarmchip.off { opacity: 0.4; }
.chip .dot { vertical-align: 0; }
.summary-panel { position: fixed; left: 0; right: 0; top: 49px; bottom: 0; z-index: 30; background: var(--bg); overflow: auto; padding: 10px 16px 24px; }
.summary-panel[hidden] { display: none; }
.sumhead { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; position: sticky; top: -10px; background: var(--bg); padding: 8px 0; z-index: 2; border-bottom: 1px solid var(--line); }
.sumhead .sumtitle { font-size: 15px; }
.sumhead label { display: flex; gap: 6px; align-items: center; color: var(--dim); font-size: 12px; }
.sumhead input[type=search] { background: var(--panel2); border: 1px solid var(--line); border-radius: 6px; padding: 5px 8px; color: var(--text); width: 220px; }
.sumhead .spacer { flex: 1; }
.smstats { display: flex; gap: 22px; flex-wrap: wrap; margin: 10px 0; font-size: 12px; color: #c3cbd8; }
.smmatrix { width: auto; min-width: 50%; }
.smmatrix td, .smmatrix th { text-align: center; padding: 4px 10px; }
.smmatrix td.scn { text-align: left; font-weight: 600; white-space: nowrap; }
.smmatrix td.cell { cursor: pointer; border-radius: 4px; }
.smmatrix td.cell:hover { outline: 1px solid var(--accent); }
.smmatrix td.empty { color: #444c5a; }
td.good { background: rgba(34,197,94,0.14); } td.mid { background: rgba(250,190,60,0.16); } td.poor { background: rgba(239,68,68,0.2); }
.goodt { color: #7ee2a8; } .midt { color: #ffd27a; } .poort { color: #ff7b7b; }
.smtable td, .smtable th { text-align: right; white-space: nowrap; } .smtable td:first-child, .smtable th:first-child { text-align: left; }
.smtable th[data-sort] { cursor: pointer; user-select: none; } .smtable th[data-sort]:hover { color: var(--text); }
.smdetail { margin: 10px 0; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); max-width: 640px; }
#summaryBtn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.storybar { position: absolute; left: 8px; right: 8px; bottom: 8px; z-index: 5; background: rgba(12,16,22,0.94); border: 1px solid var(--accent); border-radius: 10px; padding: 8px 12px 10px; box-shadow: 0 6px 24px rgba(0,0,0,0.45); }
.storybar[hidden] { display: none; }
.storybar .sthead { display: flex; align-items: center; gap: 10px; }
.storybar .stnum { font: 700 14px var(--mono); color: var(--accent); white-space: nowrap; }
.storybar .sttime { font: 13px var(--mono); color: var(--dim); white-space: nowrap; }
.storybar .sttitle { font-size: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.storybar .spacer { flex: 1; }
.storybar .stsay { font-size: 17px; line-height: 1.35; margin-top: 6px; color: #eef2f7; }
body.story .legend, body.story .hovercoord { display: none; }
body.story .mapwrap canvas.dyn { cursor: default; }
#storyBtn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
@media (max-height: 820px) { .storybar .stsay { font-size: 15px; } .storybar .sttitle { font-size: 15px; } }
