:root{
  color-scheme:dark;
  --bg:#0d1117;--panel:#151a22;--panel2:#0f141b;--line:#303846;
  --text:#f4f1e9;--muted:#a7b0bd;--gold:#f2c66d;--green:#78d596;
  --red:#ff7d7d;--orange:#ffb76b;--blue:#8cb9ff
}
*{box-sizing:border-box}
html,body,#app{height:100%;margin:0}
body{font-family:Inter,system-ui,-apple-system,Segoe UI,Roboto,sans-serif;background:var(--bg);color:var(--text);overflow:hidden}
button,input,select{font:inherit}
button{cursor:pointer}
button:focus-visible,input:focus-visible,select:focus-visible,summary:focus-visible{outline:2px solid var(--gold);outline-offset:3px}
.topbar{height:54px;display:flex;align-items:center;justify-content:space-between;padding:0 14px;background:#0f141b;border-bottom:1px solid #242c36;position:relative;z-index:10}
.brand{display:flex;align-items:center;gap:8px}.brand strong{font-size:18px}.dragon{font-size:21px}
.badge{font-size:10px;font-weight:900;background:var(--gold);color:#21180a;padding:4px 7px;border-radius:999px}
.ghost{border:1px solid #384452;background:#141a22;color:var(--text);border-radius:10px}.tiny-btn{padding:7px 9px;font-size:12px}
.stage{position:relative;height:calc(100% - 54px);background:#121820}
.map{position:absolute;inset:0;background:#161d26}
.fallback-map{position:absolute;inset:0;background:radial-gradient(circle at 50% 42%,#25303c,#18202a 58%,#11171e)}
#routeViz{width:100%;height:100%}.gridline{stroke:#ffffff0c;stroke-width:1}
.route-glow{fill:none;stroke:#f2c66d2e;stroke-width:14;stroke-linecap:round;stroke-linejoin:round}
.route-line{fill:none;stroke:var(--gold);stroke-width:4;stroke-linecap:round;stroke-linejoin:round}
.station-dot{fill:var(--blue);stroke:#0d1117;stroke-width:2}.station-best{fill:var(--gold);stroke:#fff1bc;stroke-width:3}
.endpoint{fill:#fff;stroke:#0d1117;stroke-width:4}
.map-label{position:absolute;top:12px;left:12px;max-width:74vw;background:#0e141bd9;border:1px solid #303a47;border-radius:10px;padding:7px 9px;color:var(--muted);font-size:11px;z-index:400}
.leaflet-container{font-family:inherit;background:#171e27}
.leaflet-control-attribution{font-size:9px!important;background:#10151cdd!important;color:#9da7b4!important}
.leaflet-control-attribution a{color:#cbd5e1!important}
.sheet{position:absolute;left:10px;right:10px;bottom:10px;z-index:500;max-width:900px;margin:auto;background:#151a22f5;border:1px solid #303946;border-radius:19px;padding:10px;box-shadow:0 20px 70px #000b;max-height:76vh;overflow:auto;backdrop-filter:blur(12px)}
.grabber{display:none;width:46px;height:4px;border-radius:99px;background:#596473;margin:0 auto 9px}
.route-fields{display:grid;grid-template-columns:1fr 1fr;gap:8px}
label>span{display:block;color:var(--muted);font-size:10px;margin:0 0 4px 3px}
.field-row{display:flex;gap:5px}.field-row input{flex:1}
input,select,.icon-btn{width:100%;min-width:0;border:1px solid #35404e;border-radius:11px;background:#0e141b;color:var(--text);padding:10px 11px;outline:none}
input:focus,select:focus{border-color:#796642;box-shadow:0 0 0 2px #f2c66d16}
.icon-btn{width:45px;flex:0 0 45px;background:#242c37}
.settings{display:grid;grid-template-columns:repeat(4,1fr);gap:7px;margin-top:8px}
.primary{width:100%;margin-top:9px;border:1px solid #dfb35a;border-radius:12px;padding:12px;background:var(--gold);color:#21180a;font-weight:900}
.primary:disabled{opacity:.55;cursor:wait}
.status-row{display:flex;gap:8px;align-items:flex-start;padding:9px 3px 3px;color:var(--muted);font-size:12px;line-height:1.4}
.status-dot{width:9px;height:9px;border-radius:50%;background:#626c79;flex:none;margin-top:4px}
.status-dot.busy{background:var(--orange);animation:pulse .7s infinite alternate}.status-dot.ok{background:var(--green)}.status-dot.err{background:var(--red)}
@keyframes pulse{to{opacity:.28}}
@media(prefers-reduced-motion:reduce){.status-dot.busy{animation:none}}
.health{display:flex;gap:6px;flex-wrap:wrap;margin-top:2px}
.pill{font-size:10px;border:1px solid #313b48;border-radius:999px;color:var(--muted);padding:4px 7px;background:#10151c}
.pill.ok{border-color:#315a3d;color:#9ae5ac}.pill.busy{border-color:#674e2f;color:#ffc27a}.pill.err{border-color:#653737;color:#ff9c9c}
.summary{display:grid;grid-template-columns:repeat(4,1fr);gap:7px;margin-top:8px}
.metric{background:var(--panel2);border:1px solid #2c3541;border-radius:10px;padding:7px 9px}
.metric b{display:block;font-size:15px}.metric small{font-size:10px;color:var(--muted)}
.cards{display:grid;grid-template-columns:repeat(3,1fr);gap:8px;margin-top:8px}
.result-card{background:var(--panel2);border:1px solid #303947;border-radius:13px;padding:9px;min-height:112px}
.result-card.winner{border-color:#8b713c;box-shadow:inset 0 0 0 1px #55472c}
.result-card h3{font-size:11px;margin:0 0 6px}.result-card p{font-size:10.5px;line-height:1.4;color:var(--muted);margin:0}
.price{font-size:18px;font-weight:900}.price-note{font-size:9px;color:var(--muted);font-weight:500}
.result-line{font-size:11.5px;margin-top:4px}.result-small{font-size:10px;color:var(--muted);line-height:1.42;margin-top:4px}
details{margin-top:8px;background:#0e1319;border:1px solid #29333e;border-radius:10px;overflow:hidden}
summary{font-size:11px;color:#b9c2ce;padding:7px 9px;cursor:pointer}
pre{margin:0;padding:8px 10px;max-height:145px;overflow:auto;border-top:1px solid #25303a;color:#aab4c0;font:9.5px/1.45 ui-monospace,SFMono-Regular,Menlo,monospace;white-space:pre-wrap}
footer{text-align:center;color:#76808d;font-size:9px;margin-top:7px}
[data-preview] footer a{color:var(--gold)}
@media(max-width:720px){
  .topbar{height:48px}.stage{height:calc(100% - 48px)}
  .sheet{left:6px;right:6px;bottom:6px;max-height:69vh;padding:8px}.grabber{display:block}
  .route-fields,.settings{grid-template-columns:1fr 1fr}.cards{grid-template-columns:1fr}.result-card{min-height:auto}
  .summary{grid-template-columns:1fr 1fr}
}
