:root {
  --bg: #0b0e14; --panel: #12161f; --panel2: #171c27; --line: #232a38;
  --fg: #e8ecf4; --muted: #8a93a6; --accent: #5b8cff; --accent-weak: #23304f;
  --up: #ff6b6b; --down: #35c98b; --radius: 12px;
  --shadow: 0 10px 40px rgba(0,0,0,.45);
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font-family: Inter, -apple-system, Segoe UI, Roboto, sans-serif;
  font-size: 13.5px; line-height: 1.5; -webkit-font-smoothing: antialiased;
}
.muted { color: var(--muted); font-weight: 400; }

.topbar {
  height: 56px; display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px; border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, var(--panel2), var(--panel));
}
.brand { font-weight: 600; font-size: 15px; letter-spacing: .2px; }
.brand .logo { color: var(--accent); margin-right: 4px; }
.brand .muted { font-weight: 400; }
.summary { font-size: 13px; }
.topright { display: flex; align-items: center; gap: 14px; }
.bell { position: relative; background: var(--panel2); border: 1px solid var(--line); color: var(--fg); width: 36px; height: 36px; border-radius: 10px; cursor: pointer; font-size: 16px; }
.bell:hover { border-color: #33405a; }
.bellcount { position: absolute; top: -6px; right: -6px; min-width: 18px; height: 18px; padding: 0 5px; background: var(--accent); color: #fff; border-radius: 10px; font-size: 11px; font-weight: 700; line-height: 18px; text-align: center; }
.notifpanel { position: fixed; top: 60px; right: 16px; width: 360px; max-width: 92vw; max-height: 70vh; overflow: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); padding: 16px; z-index: 1200; }
.notifpanel h3 { margin: 0 0 12px; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
.notif { padding: 10px 0; border-bottom: 1px solid var(--line); }
.notif:last-child { border-bottom: none; }
.notif .ntime { font-size: 11.5px; }

.app {
  display: grid;
  grid-template-columns: 264px minmax(440px, 1fr) minmax(360px, 42%);
  height: calc(100vh - 56px);
}

/* filters */
.filters { padding: 18px; border-right: 1px solid var(--line); overflow: auto; background: var(--panel); }
.field { margin-bottom: 16px; }
.field label, .checkbox { display: block; color: var(--muted); font-size: 12px; margin-bottom: 7px; font-weight: 500; }
.row { display: flex; gap: 8px; }
input, select {
  width: 100%; padding: 8px 11px; background: var(--bg); color: var(--fg);
  border: 1px solid var(--line); border-radius: 9px; font: inherit; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-weak); }
.chips { display: flex; gap: 6px; }
.chips button {
  flex: 1; padding: 8px 0; background: var(--bg); color: var(--fg);
  border: 1px solid var(--line); border-radius: 9px; cursor: pointer; font: inherit;
  transition: all .12s;
}
.chips button:hover { border-color: #33405a; }
.chips button.on { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.checkbox { display: flex; align-items: center; gap: 8px; }
.checkbox input { width: auto; }
.actions { display: flex; gap: 8px; margin-top: 20px; }
button.primary, button.ghost { flex: 1; padding: 10px; border-radius: 10px; cursor: pointer; font: inherit; font-weight: 600; border: 1px solid var(--line); transition: filter .12s, background .12s; }
button.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
button.primary:hover { filter: brightness(1.08); }
button.ghost { background: transparent; color: var(--muted); font-weight: 500; }
button.ghost:hover { color: var(--fg); }

/* center: list + detail overlay (map stays visible) */
.center { position: relative; overflow: hidden; border-right: 1px solid var(--line); }
.list { height: 100%; overflow: auto; }
table.listings { width: 100%; border-collapse: collapse; }
.listings th, .listings td { padding: 11px 16px; text-align: left; }
.listings thead th { position: sticky; top: 0; z-index: 1; background: var(--panel); color: var(--muted); font-weight: 500; font-size: 11.5px; text-transform: uppercase; letter-spacing: .4px; border-bottom: 1px solid var(--line); }
.listings tbody tr { cursor: pointer; border-bottom: 1px solid var(--line); transition: background .1s; }
.listings tbody tr:hover { background: var(--panel2); }
.listings tbody tr.sel { background: var(--accent-weak); box-shadow: inset 3px 0 0 var(--accent); }
.price { font-weight: 600; }
.ppm { color: var(--muted); }
.empty { text-align: center; color: var(--muted); padding: 40px 0; }

/* detail panel — overlays the center column only */
.detail { position: absolute; inset: 0; background: var(--panel); overflow: auto; padding: 22px; animation: slide .18s ease; }
@keyframes slide { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
.detail-top { position: sticky; top: 0; z-index: 3; margin: -22px -22px 14px; padding: 12px 18px; background: var(--panel); border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; }
.detail .back { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); cursor: pointer; font-weight: 500; }
.detail .back:hover { color: var(--fg); }
.detail .close { width: 32px; height: 32px; display: grid; place-items: center; background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; color: var(--muted); cursor: pointer; font-size: 15px; line-height: 1; transition: all .12s; }
.detail .close:hover { color: var(--fg); border-color: #3a4560; background: #1e2430; }
.detail h2 { margin: 0 0 2px; font-size: 24px; font-weight: 700; }
.detail .sub { color: var(--muted); margin-bottom: 18px; }
.badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; vertical-align: middle; margin-left: 8px; }
.badge.up { background: rgba(255,107,107,.15); color: var(--up); }
.badge.down { background: rgba(53,201,139,.15); color: var(--down); }
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin: 6px 0 20px; }
.stat { background: var(--panel2); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.stat .k { color: var(--muted); font-size: 11.5px; margin-bottom: 3px; }
.stat .v { font-size: 16px; font-weight: 600; }
.detail h3 { font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; margin: 18px 0 10px; }
.chart { width: 100%; height: 130px; background: var(--panel2); border: 1px solid var(--line); border-radius: var(--radius); }
.cta { display: inline-block; margin-top: 18px; padding: 10px 16px; background: var(--accent); color: #fff; border-radius: 10px; text-decoration: none; font-weight: 600; }
.cta:hover { filter: brightness(1.08); }

/* map */
.mapcol { position: relative; }
#map { position: absolute; inset: 0; background: #0a0c11; }
/* darken the free OSM tiles to match the dark theme (no API key needed);
   only the tile layer is filtered, markers stay bright */
#map .leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(0.94) contrast(0.9) saturate(0.8); }
.leaflet-tooltip.pin { background: #0f1420; color: var(--fg); border: 1px solid var(--line); box-shadow: var(--shadow); font-weight: 600; font-size: 12.5px; padding: 5px 9px; border-radius: 8px; }
.leaflet-tooltip.pin::before { display: none; }

/* commute rows (card) */
.commute { display: flex; flex-direction: column; gap: 6px; margin-bottom: 6px; }
.crow { display: grid; grid-template-columns: 26px 1fr auto; align-items: center; gap: 8px 10px; padding: 9px 12px; background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; }
.crow .cico { font-size: 16px; }
.crow .cname { font-weight: 600; }
.crow .ctime { font-weight: 700; color: var(--accent); }
.crow .cdet { grid-column: 2 / 4; font-size: 12px; }

/* score pill (table) + breakdown (card) */
.scorepill { display: inline-block; min-width: 30px; text-align: center; padding: 3px 8px; border-radius: 7px; font-weight: 700; font-size: 12.5px; }
.sc-hi { background: rgba(53,201,139,.18); color: var(--down); }
.sc-mid { background: rgba(91,140,255,.18); color: var(--accent); }
.sc-lo { background: rgba(138,147,166,.15); color: var(--muted); }
.scorebd { display: flex; flex-direction: column; gap: 8px; margin-bottom: 6px; }
.scorerow { display: grid; grid-template-columns: 108px 1fr 40px; align-items: center; gap: 10px; }
.scorerow .sk { color: var(--muted); font-size: 12.5px; }
.scorerow .sbar { height: 8px; background: var(--panel2); border-radius: 6px; overflow: hidden; }
.scorerow .sbar i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), #7aa2ff); border-radius: 6px; }
.scorerow .sv { text-align: right; color: var(--fg); font-size: 12.5px; font-weight: 600; }

/* analytics view */
.analytics { position: fixed; top: 56px; left: 0; right: 0; bottom: 0; background: var(--bg); overflow: auto; padding: 22px 26px; z-index: 1100; }
.ana-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.ana-head h2 { margin: 0; font-size: 22px; }
.ana-head .close { width: 34px; height: 34px; display: grid; place-items: center; background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; color: var(--muted); cursor: pointer; }
.ana-stats { grid-template-columns: repeat(5, 1fr); max-width: 900px; }
.analytics h3 { font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; margin: 22px 0 12px; }
.analytics .scorebd { max-width: 760px; }
.ana-table { max-width: 1000px; }
.ana-table td, .ana-table th { padding: 8px 12px; border-bottom: 1px solid var(--line); }

/* settings panel */
.setgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 18px; max-width: 1100px; }
.setgrid section { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px; }
.setgrid section h3 { margin: 0 0 12px; }
.setlist { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.setrow { display: grid; grid-template-columns: 1fr auto 24px; align-items: center; gap: 8px; padding: 8px 10px; background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; font-size: 13px; }
.setrow .muted { font-size: 11.5px; }
.setrow .del { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 13px; }
.setrow .del:hover { color: var(--danger, #ff6b6b); }
.setform { display: flex; flex-direction: column; gap: 8px; }
.setform .row { display: flex; gap: 8px; }
.setcheck { display: flex; align-items: center; gap: 8px; color: var(--fg); font-size: 13px; margin: 0; }
.setcheck input { width: auto; }
.setform .primary { border: 1px solid var(--accent); background: var(--accent); color: #fff; padding: 9px; border-radius: 9px; font-weight: 600; cursor: pointer; }

.hidden { display: none; }
a { color: var(--accent); }
@media (max-width: 1080px) {
  .app { grid-template-columns: 1fr; grid-auto-rows: minmax(min-content, max-content); height: auto; }
  .center { height: 70vh; } .mapcol { height: 46vh; }
}
