:root {
  --bg: #08131c; --bg2: #0c1b27; --panel: #112636; --panel2: #16313f; --line: #1f3a4b;
  --text: #d9e7ef; --muted: #8aa4b4; --accent: #5eead4; --accent-dim: #2a8f83; --warn: #f5b971; --bad: #f08a8a;
  --r: 12px; --shadow: 0 8px 28px rgba(0,0,0,.35);
  font-family: ui-sans-serif, "Segoe UI", Inter, "Helvetica Neue", Arial, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.45; }
a { color: var(--accent); }
h1 { font-size: 1.35rem; font-weight: 600; margin: 0 0 .25rem; letter-spacing: .01em; }
h2 { font-size: 1.05rem; font-weight: 600; margin: 1.6rem 0 .6rem; color: var(--text); }
h3 { font-size: .98rem; margin: 0; font-weight: 600; }
.muted { color: var(--muted); } .small { font-size: .82rem; }
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.shell { display: grid; grid-template-columns: 76px 1fr; height: 100vh; }
.rail { background: linear-gradient(180deg, #0a1a26, #07111a); border-right: 1px solid var(--line); display: flex; flex-direction: column; align-items: center; padding: 14px 0; gap: 6px; }
.brand { color: var(--accent); margin-bottom: 14px; }
.rail-link { position: relative; width: 62px; padding: 9px 0 7px; border-radius: 10px; text-decoration: none; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: .72rem; }
.rail-link svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.rail-link:hover { color: var(--text); background: var(--bg2); }
.rail-link.active { color: var(--accent); background: var(--panel); box-shadow: inset 3px 0 0 var(--accent); }
.badge { position: absolute; top: 4px; right: 8px; background: var(--accent); color: #04211d; font-size: .68rem; padding: 0 5px; border-radius: 9px; }
.rail-foot { margin-top: auto; text-align: center; color: var(--muted); font-size: .66rem; padding: 0 4px; }
.pulse { display: block; width: 8px; height: 8px; border-radius: 50%; background: var(--line); margin: 0 auto 4px; transition: background .4s, box-shadow .4s; }
.pulse.on { background: var(--accent); box-shadow: 0 0 10px var(--accent); }
.stage { min-width: 0; min-height: 0; overflow: auto; }

.toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 50; max-width: 360px; }
.toast { background: var(--panel2); border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: 10px; padding: 9px 12px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 2px; animation: rise .35s ease; }
.toast b { font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--accent); }
.toast span { font-size: .88rem; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* map page */
.mapview { display: grid; grid-template-columns: 1fr 400px; height: 100vh; }
.mapcol { position: relative; min-width: 0; background: radial-gradient(120% 90% at 30% 20%, #10293a 0%, #08131c 70%); overflow: hidden; }
.map { position: absolute; inset: 0; }
.panel { background: rgba(14, 33, 46, .86); backdrop-filter: blur(6px); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); }
.maptools { position: absolute; top: 14px; left: 14px; right: 14px; display: flex; gap: 10px; flex-wrap: wrap; pointer-events: none; }
.maptools .panel { pointer-events: auto; padding: 8px 10px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.field { display: flex; flex-direction: column; font-size: .74rem; color: var(--muted); gap: 2px; min-width: 130px; }
.field b { color: var(--text); font-weight: 600; }
input[type=range] { accent-color: var(--accent); width: 100%; }
.chip { display: inline-flex; align-items: center; gap: 6px; background: var(--bg2); border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; font-size: .84rem; color: var(--text); }
.chip svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.chip:hover { border-color: var(--accent-dim); }
.chip.on { background: rgba(94, 234, 212, .14); border-color: var(--accent); color: var(--accent); }
.chip.ghost { background: transparent; color: var(--muted); }
.mapzoom { position: absolute; right: 14px; bottom: 54px; display: flex; flex-direction: column; overflow: hidden; }
.mapzoom button { width: 38px; height: 38px; background: transparent; border: 0; font-size: 1.2rem; }
.mapzoom button + button { border-top: 1px solid var(--line); }
.mapzoom button:hover { background: var(--panel2); }
.maplegend { position: absolute; left: 14px; bottom: 14px; padding: 6px 12px; font-size: .8rem; color: var(--muted); }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin: 0 5px 0 10px; vertical-align: baseline; }
.dot:first-child { margin-left: 0; }
.dot.me { background: #fff; box-shadow: 0 0 0 3px rgba(255,255,255,.25); } .dot.lodge { background: var(--accent); }

.llmap { display: block; touch-action: none; cursor: grab; user-select: none; }
.llmap.drawing { cursor: crosshair; }
.llmap .grat { stroke: #14303f; stroke-width: 1; }
.llmap .gratlabel { fill: #3f6275; font-size: 10px; }
.llmap .town { fill: #547b90; } .llmap .townlabel { fill: #6f93a8; font-size: 11px; letter-spacing: .04em; }
.llmap .area { fill: rgba(94, 234, 212, .12); stroke: var(--accent); stroke-width: 1.6; stroke-dasharray: 6 4; }
.llmap .areax circle { fill: var(--panel2); stroke: var(--accent); } .llmap .areax text { fill: var(--accent); font-size: 14px; } .llmap .areax { cursor: pointer; }
.llmap .draft { fill: rgba(94,234,212,.08); stroke: var(--accent); stroke-width: 1.6; } .llmap .draftpt { fill: var(--accent); }
.llmap .pin circle { fill: var(--accent); stroke: #04211d; stroke-width: 2; } .llmap .pin { cursor: pointer; }
.llmap .pin.sel circle { fill: #fff; stroke: var(--accent); stroke-width: 4; }
.llmap .pinlabel { fill: var(--text); font-size: 12px; paint-order: stroke; stroke: #08131c; stroke-width: 3px; }
.llmap .cell { cursor: pointer; } .llmap .cell circle { fill: rgba(94, 234, 212, .22); stroke: var(--accent); stroke-width: 1.5; }
.llmap .cell text { fill: var(--text); font-weight: 600; font-size: 14px; }
.llmap .me circle { fill: #fff; } .llmap .me .halo { fill: rgba(255,255,255,.14); }

.side { display: flex; flex-direction: column; min-height: 0; background: var(--bg2); border-left: 1px solid var(--line); }
.side-head { padding: 16px 18px 10px; border-bottom: 1px solid var(--line); }
.side-head p { margin: .2rem 0; }
.count { color: var(--text); font-size: .9rem; margin-top: .5rem !important; }
.check { display: flex; gap: 8px; align-items: center; font-size: .86rem; color: var(--muted); margin-top: .5rem; }
.check input { accent-color: var(--accent); }
.link { background: none; border: 0; color: var(--accent); padding: 0; text-decoration: underline; }
.note { color: var(--warn); font-size: .84rem; }
.cards { flex: 1; overflow: auto; padding: 12px 14px; display: flex; flex-direction: column; gap: 10px; }
.cards.flat { overflow: visible; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 11px 13px; cursor: pointer; transition: border-color .15s, transform .15s; }
.card:hover { border-color: var(--accent-dim); }
.card.sel { border-color: var(--accent); background: var(--panel2); }
.card-top { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.km { color: var(--accent); font-weight: 600; font-size: 1.05rem; white-space: nowrap; } .km small { font-weight: 400; color: var(--muted); }
.where { margin: 2px 0 7px; color: var(--muted); font-size: .84rem; }
.meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-size: .82rem; color: var(--muted); }
.rating { color: var(--warn); font-weight: 600; }
.tag { background: rgba(94,234,212,.1); color: var(--accent); border-radius: 6px; padding: 1px 7px; font-size: .75rem; }
.empty { border: 1px dashed var(--line); border-radius: var(--r); padding: 16px; display: flex; flex-direction: column; gap: 4px; color: var(--muted); }
.empty b { color: var(--text); }
.alert { margin: 10px 14px; background: rgba(240,138,138,.1); border: 1px solid var(--bad); color: var(--bad); border-radius: 10px; padding: 8px 12px; font-size: .88rem; }
.savebar { border-top: 1px solid var(--line); padding: 12px 16px 14px; background: var(--bg); }
.savebar form { display: flex; gap: 8px; }
.savebar p { margin: .45rem 0 0; font-size: .82rem; }
input[type=text] { flex: 1; min-width: 0; background: var(--bg2); border: 1px solid var(--line); border-radius: 8px; color: var(--text); padding: 8px 10px; font: inherit; }
.primary { background: var(--accent); color: #04211d; border: 0; border-radius: 8px; padding: 8px 14px; font-weight: 600; }
.primary:disabled { opacity: .4; cursor: default; }

/* other pages */
.page { padding: 26px 32px 48px; max-width: 1240px; }
.page-head { margin-bottom: 18px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 18px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 16px; display: flex; flex-direction: column; }
.kpi span { color: var(--muted); font-size: .8rem; } .kpi b { font-size: 1.7rem; font-weight: 600; color: var(--accent); }
.charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); gap: 14px; }
.chart { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px 12px; }
.chart h3 { margin-bottom: 10px; }
.bars { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 7px; }
.bars li { display: grid; grid-template-columns: 110px 1fr 84px; gap: 10px; align-items: center; font-size: .86rem; }
.bars .lbl { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .bars .val { text-align: right; }
.track { background: var(--bg2); border-radius: 5px; height: 12px; overflow: hidden; } .fill { display: block; height: 100%; background: linear-gradient(90deg, var(--accent-dim), var(--accent)); border-radius: 5px; }
.cols { width: 100%; height: auto; } .cols .axis { stroke: var(--line); } .cols .col { fill: var(--accent); opacity: .85; } .cols .colval { fill: var(--text); font-size: 10px; } .cols .collbl { fill: var(--muted); font-size: 9.5px; }
.caption { margin: 8px 0 0; color: var(--muted); font-size: .78rem; }
.match { margin-bottom: 16px; } .match h3 { margin-bottom: 8px; } .match small { color: var(--muted); font-weight: 400; margin-left: 8px; }
.saved { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.saved-row { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 16px; display: flex; justify-content: space-between; gap: 16px; align-items: center; }
.saved-row > div:first-child { display: flex; flex-direction: column; gap: 2px; }
.paused { color: var(--warn); font-size: .85rem; }
.row-actions { display: flex; gap: 8px; }
#blazor-error-ui { display: none; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 56px 1fr; } .rail-link { width: 50px; } .rail-link span { display: none; }
  .mapview { grid-template-columns: 1fr; grid-template-rows: 55vh auto; height: auto; min-height: 100vh; }
  .mapcol { min-height: 55vh; } .side { border-left: 0; }
  .page { padding: 18px; }
}
