@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap");

:root {
  --bg: #0b0d12; --panel: #12151c; --panel2: #191d26; --panel3: #21262f; --line: #262b36; --line2: #2f3542;
  --text: #eceff4; --muted: #8e97ab; --muted2: #5f687a;
  --accent: #d4ff00; --accent-dim: rgba(212,255,0,.14);
  --hot: #ff5a5a; --medium: #ffb52e; --cold: #4f8cff; --uncovered: #6b7280;
  --prime: #d4ff00; --warm: #ffb52e; --cool: #7fb0ff; --coldl: #6b7280;
  --r: 10px; --shadow: 0 10px 30px rgba(0,0,0,.45);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font: 13.5px/1.45 "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; display: flex; flex-direction: column; -webkit-font-smoothing: antialiased; }
h1 { margin: 0 0 4px; font-size: 22px; font-weight: 700; letter-spacing: -.01em; }
h2 { margin: 0 0 10px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--line2); border-radius: 8px; }

button, .btn { background: var(--panel3); color: var(--text); border: 1px solid var(--line2); border-radius: 8px; padding: 8px 13px; font: inherit; font-weight: 500; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; transition: background .15s, border-color .15s, transform .05s; }
button:hover, .btn:hover { background: #2a303b; border-color: #3a414f; text-decoration: none; }
button:active { transform: translateY(1px); }
button.primary { background: var(--accent); color: #0b0d12; border-color: var(--accent); font-weight: 600; }
button.primary:hover { background: #e2ff4d; }
button.ghost, .btn.ghost { background: transparent; }
button.sm, .btn.sm, label.sm { padding: 5px 9px; font-size: 12px; border-radius: 7px; }
button:disabled { opacity: .45; cursor: default; transform: none; }
input, select, textarea { background: var(--panel2); color: var(--text); border: 1px solid var(--line2); border-radius: 8px; padding: 8px 10px; font: inherit; width: 100%; transition: border-color .15s, box-shadow .15s; }
input:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }
select { appearance: none; -webkit-appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 16px) 55%, calc(100% - 11px) 55%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 28px; }
input[type=checkbox], input[type=radio] { width: auto; margin: 0 6px 0 0; accent-color: var(--accent); }
input[type=range] { padding: 0; accent-color: var(--accent); }
input[type=file] { padding: 6px; font-size: 12px; }
label { display: block; margin: 8px 0; color: var(--muted); font-size: 12px; font-weight: 500; }
label > input, label > select { margin-top: 4px; }
label.inline { display: flex; align-items: center; gap: 4px; }
.row { display: flex; gap: 8px; }
.row > label { flex: 1; }
.hint { color: var(--muted); font-size: 12px; margin: 4px 0; line-height: 1.4; }
.err { color: var(--hot); font-size: 12px; margin-top: 6px; white-space: pre-wrap; }
.ok { color: var(--accent); font-size: 12px; }

header { display: flex; align-items: center; gap: 18px; padding: 10px 18px; background: linear-gradient(180deg, #151923, #12151c); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.brand { font-weight: 700; font-size: 17px; letter-spacing: -.01em; display: flex; align-items: center; gap: 8px; }
.brand::before { content: ""; width: 10px; height: 10px; border-radius: 3px; background: var(--accent); box-shadow: 0 0 12px var(--accent); }
.brand span { color: var(--accent); }
nav { display: flex; gap: 2px; background: var(--panel2); padding: 3px; border-radius: 10px; border: 1px solid var(--line); }
nav button { background: transparent; border-color: transparent; color: var(--muted); padding: 6px 14px; border-radius: 8px; }
nav button:hover { background: var(--panel3); color: var(--text); }
nav button.on { background: var(--panel3); color: var(--text); box-shadow: inset 0 0 0 1px var(--line2); }
.me { margin-left: auto; display: flex; gap: 10px; align-items: center; }
.me label { margin: 0; display: flex; align-items: center; gap: 8px; }
.me select { width: auto; min-width: 150px; margin: 0; }

main { flex: 1; min-height: 0; position: relative; }
.tab { display: none; height: 100%; }
.tab.on { display: flex; }
.tab.single { flex-direction: column; padding: 14px 18px; gap: 12px; }
.tab.scroll { overflow: auto; }
.panel { width: 300px; flex: none; background: var(--panel); border-right: 1px solid var(--line); padding: 14px; overflow: auto; }
.panel.wide { width: 400px; border-right: 0; border-left: 1px solid var(--line); }
.mapwrap { flex: 1; min-width: 0; position: relative; }
.map { position: absolute; inset: 0; background: #0b0d12; }

.leaflet-container { font: inherit; background: #0b0d12; }
.leaflet-bar { border: 1px solid var(--line2) !important; box-shadow: var(--shadow) !important; border-radius: 8px !important; overflow: hidden; }
.leaflet-bar a { background: var(--panel2) !important; color: var(--text) !important; border-bottom-color: var(--line) !important; }
.leaflet-bar a:hover { background: var(--panel3) !important; }
.leaflet-control-attribution { background: rgba(11,13,18,.7) !important; color: var(--muted2) !important; font-size: 10px; }
.leaflet-control-attribution a { color: var(--muted) !important; }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--panel2); color: var(--text); box-shadow: var(--shadow); border: 1px solid var(--line2); }
.leaflet-popup-content-wrapper { border-radius: 10px; }
.leaflet-popup-content { margin: 12px 14px; font-size: 12.5px; line-height: 1.5; }
.leaflet-popup-content b { font-size: 13.5px; }
.leaflet-popup-close-button { color: var(--muted) !important; }
.leaflet-tooltip { background: var(--panel2); color: var(--text); border: 1px solid var(--line2); border-radius: 8px; box-shadow: var(--shadow); font-size: 12px; padding: 6px 9px; }
.leaflet-tooltip-top:before, .leaflet-tooltip-right:before, .leaflet-tooltip-left:before { display: none; }
.corp-label { background: rgba(18,21,28,.9); border-color: var(--line2); padding: 2px 6px; line-height: 1.2; box-shadow: none; }
.corp-label b { display: block; font-size: 11px; font-weight: 600; max-width: 180px; overflow: hidden; text-overflow: ellipsis; }
.corp-label .lm { display: block; color: var(--accent); font-size: 10px; font-weight: 500; }
.corp-label.churned b { color: var(--muted); }
.corp-label.churned .lm { color: var(--muted2); }
.numpin { background: var(--accent); color: #0b0d12; border-radius: 50%; width: 26px; height: 26px; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 12px; border: 2px solid #0b0d12; box-shadow: 0 2px 8px rgba(0,0,0,.5); }
.numpin.done { background: var(--muted); }
.startpin { background: #fff; color: #0b0d12; border-radius: 5px; padding: 2px 5px; font-size: 10px; font-weight: 700; box-shadow: 0 2px 8px rgba(0,0,0,.5); }

.group { margin: 10px 0; }
.gt { color: var(--muted); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; margin-bottom: 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chips label { margin: 0; display: flex; align-items: center; background: var(--panel2); border: 1px solid var(--line2); border-radius: 999px; padding: 4px 10px; font-size: 12px; color: var(--text); cursor: pointer; transition: all .15s; font-weight: 500; }
.chips label:hover { border-color: #3a414f; }
.chips label:has(input:checked) { border-color: var(--accent); color: var(--accent); background: var(--accent-dim); }
.chips label input { margin-right: 6px; }
.ind-group { margin: 6px 0 10px; }
.ind-group .gt { font-size: 10.5px; }

.totals { margin-top: 14px; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.totals div { background: var(--panel2); border: 1px solid var(--line); border-radius: var(--r); padding: 10px 12px; }
.totals b { display: block; font-size: 18px; font-weight: 700; letter-spacing: -.01em; }
.totals small { color: var(--muted); font-size: 11px; }
.legend { margin-top: 12px; display: flex; flex-wrap: wrap; gap: 6px 12px; font-size: 12px; color: var(--muted); }
.legend span { display: flex; align-items: center; }
.legend span::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; background: var(--c); box-shadow: 0 0 8px var(--c); }
.ph { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.ph h2 { margin: 0; }

.tablewrap { overflow: auto; border: 1px solid var(--line); border-radius: var(--r); background: var(--panel); }
.tablewrap.grow { flex: 1; min-height: 0; }
table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; vertical-align: middle; }
th { color: var(--muted); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; cursor: pointer; position: sticky; top: 0; background: var(--panel2); z-index: 1; }
tbody tr:last-child td { border-bottom: 0; }
tr.clickable { cursor: pointer; }
tr.clickable:hover, tbody tr:hover { background: var(--panel2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td small { color: var(--muted); font-size: 11px; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 10.5px; font-weight: 700; letter-spacing: .04em; color: #0b0d12; background: var(--muted); text-transform: uppercase; }
.badge.hot { background: var(--hot); color: #fff; }
.badge.medium { background: var(--medium); }
.badge.cold { background: var(--cold); color: #fff; }
.badge.uncovered { background: var(--uncovered); color: #fff; }
.badge.PRIME { background: var(--prime); }
.badge.HOT { background: var(--hot); color: #fff; }
.badge.WARM { background: var(--warm); }
.badge.COOL { background: var(--cool); color: #0b0d12; }
.badge.COLD { background: var(--coldl); color: #fff; }

.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.toolbar input, .toolbar select { width: auto; min-width: 150px; }
.toolbar input { flex: 1; }

.progress { margin-top: 12px; }
.bar { height: 6px; background: var(--panel3); border-radius: 4px; overflow: hidden; }
.bar div { height: 100%; width: 0; background: linear-gradient(90deg, #9ccf00, var(--accent)); transition: width .3s; }

.list .item { padding: 10px 12px; border: 1px solid var(--line); background: var(--panel2); border-radius: var(--r); margin-bottom: 8px; cursor: pointer; transition: border-color .15s; }
.list .item:hover { border-color: var(--line2); }
.list .item.on { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }
.list .item b { display: block; font-weight: 600; }
.list .item small { color: var(--muted); }

.stops { list-style: none; padding: 0; margin: 0; }
.stop { border: 1px solid var(--line); background: var(--panel2); border-radius: var(--r); padding: 10px 12px; margin-bottom: 10px; }
.stop.done { opacity: .55; }
.stop .n { display: inline-flex; width: 22px; height: 22px; border-radius: 50%; background: var(--accent); color: #0b0d12; align-items: center; justify-content: center; font-weight: 700; font-size: 11px; margin-right: 8px; }
.stop b { font-weight: 600; }
.stop .meta { color: var(--muted); font-size: 12px; margin: 3px 0; }
.stop .acts { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.stop .acts button { padding: 5px 9px; font-size: 12px; }
.stop .acts button.on { background: var(--accent); color: #0b0d12; border-color: var(--accent); }
.links { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 12px; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 12px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px; }
.card p { margin: 4px 0; }
.card .totals { margin-top: 0; margin-bottom: 12px; }

#gate { position: fixed; inset: 0; background: radial-gradient(900px 600px at 50% 30%, #161a24, var(--bg)); z-index: 1000; display: flex; align-items: center; justify-content: center; }
#gate form { width: 320px; background: var(--panel); padding: 28px; border-radius: 14px; border: 1px solid var(--line2); box-shadow: var(--shadow); }
#gate p { color: var(--muted); margin: 0 0 12px; }
#gate input { margin: 6px 0 12px; font-size: 20px; text-align: center; letter-spacing: .3em; }
#gate button { width: 100%; justify-content: center; background: var(--accent); color: #0b0d12; font-weight: 600; border-color: var(--accent); }

.modal { position: fixed; inset: 0; background: rgba(0,0,0,.65); backdrop-filter: blur(3px); z-index: 900; display: flex; align-items: center; justify-content: center; padding: 12px; }
.modal .box { background: var(--panel); border: 1px solid var(--line2); border-radius: 14px; padding: 16px; width: 100%; max-width: 540px; max-height: 90vh; overflow: auto; box-shadow: var(--shadow); }
.modal .map { position: relative; height: 240px; margin: 10px 0; border-radius: 10px; border: 1px solid var(--line); }
.cand { padding: 8px 10px; border: 1px solid var(--line); background: var(--panel2); border-radius: 8px; margin: 5px 0; cursor: pointer; }
.cand:hover { border-color: var(--accent); }
.spark { display: block; margin-top: 6px; }

@media (max-width: 900px) {
  header { gap: 8px; padding: 8px 12px; }
  nav { order: 3; width: 100%; overflow-x: auto; }
  .tab.on { flex-direction: column; overflow: auto; }
  .panel, .panel.wide { width: 100%; border: 0; border-bottom: 1px solid var(--line); max-height: none; overflow: visible; flex: none; }
  .mapwrap { flex: none; height: 55vh; }
  #tab-routes .mapwrap { height: 40vh; }
  .me { margin-left: 0; }
  .me select { min-width: 120px; }
}
