:root {
  --bg: #ffffff;
  --fg: #14202c;
  --muted: #5d6b7a;
  --line: rgba(20, 32, 44, .12);
  --accent: #1f6feb;
  --chip: #eef2f6;
  --shadow: 0 2px 10px rgba(0, 0, 0, .18);
  --radius: 14px;
  --scale: linear-gradient(90deg, #f20019 0%, #f3411b 10%, #f18f23 20%, #f4db2a 30%, #9ff82b 40%, #28f827 50%,
                                  #28f865 60%, #30ecb2 70%, #33b6e4 80%, #3259f3 90%, #3000f3 100%);
  --top: max(10px, env(safe-area-inset-top));
  --bottom: max(12px, env(safe-area-inset-bottom));
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #18222d; --fg: #e8eef4; --muted: #9aa9b8; --line: rgba(255, 255, 255, .14);
    --accent: #5aa2ff; --chip: #243241; --shadow: 0 2px 12px rgba(0, 0, 0, .5);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--fg);
  font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-text-size-adjust: 100%; }
#map { position: fixed; inset: 0; background: #dfe5ea; }
a { color: var(--accent); }
[hidden] { display: none !important; }

.ico { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.icon-btn { border: 0; background: none; color: var(--muted); padding: 8px; border-radius: 10px; cursor: pointer; display: grid; place-items: center; }

/* search */
.bar { position: fixed; z-index: 1000; top: var(--top); left: 12px; right: 12px; max-width: 520px; margin: 0 auto; }
.search { display: flex; align-items: center; gap: 6px; background: var(--bg); color: var(--fg); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 4px 4px 4px 14px; }
.search .ico { color: var(--muted); }
.search input { flex: 1; min-width: 0; border: 0; outline: 0; background: none; color: inherit; font: inherit; font-size: 16px; padding: 10px 0; }
.search input::-webkit-search-cancel-button { display: none; }
.sugg { list-style: none; margin: 6px 0 0; padding: 4px; background: var(--bg); border-radius: var(--radius); box-shadow: var(--shadow);
  max-height: min(55vh, 420px); overflow: auto; }
.sugg li { padding: 11px 12px; border-radius: 10px; cursor: pointer; display: flex; justify-content: space-between; gap: 10px; }
.sugg li small { color: var(--muted); }
.sugg li[aria-selected="true"], .sugg li:active { background: var(--chip); }
.toast { margin: 8px auto 0; width: fit-content; max-width: 100%; background: var(--fg); color: var(--bg); padding: 8px 14px;
  border-radius: 999px; font-size: 14px; box-shadow: var(--shadow); text-align: center; }

/* buttons */
.fabs { position: fixed; z-index: 900; right: 12px; top: calc(var(--top) + 64px); display: flex; flex-direction: column; gap: 10px; }
.fab { width: 46px; height: 46px; border-radius: 50%; border: 0; background: var(--bg); color: var(--fg); box-shadow: var(--shadow);
  display: grid; place-items: center; cursor: pointer; }
.fab.busy { color: var(--accent); }

/* legend */
.legend { position: fixed; z-index: 800; left: 12px; bottom: calc(var(--bottom) + 18px); width: 190px; background: var(--bg);
  border-radius: 12px; box-shadow: var(--shadow); padding: 8px 10px 6px; font-size: 12px; }
.legend-bar { height: 10px; border-radius: 5px; background: var(--scale); }
.legend-labels { display: flex; justify-content: space-between; margin-top: 4px; font-variant-numeric: tabular-nums; }
.legend-labels.sub { color: var(--muted); margin-top: 0; }
.legend-period { margin-top: 3px; padding-top: 4px; border-top: 1px solid var(--line); font-weight: 600; text-align: center; }

/* sheets */
.sheet { position: fixed; z-index: 1100; left: 0; right: 0; bottom: 0; max-width: 560px; margin: 0 auto; background: var(--bg);
  border-radius: 18px 18px 0 0; box-shadow: 0 -4px 24px rgba(0, 0, 0, .25); padding: 18px 18px var(--bottom);
  max-height: 78vh; overflow: auto; animation: up .18s ease-out; }
@keyframes up { from { transform: translateY(24px); opacity: 0; } }
.sheet-x { position: absolute; top: 8px; right: 8px; }
.sheet h2 { font-size: 16px; margin: 4px 0 8px; }
.sheet h2 + .chips, .sheet p + .chips { margin-bottom: 14px; }
.sheet p { margin: 0 0 10px; }
.muted { color: var(--muted); font-size: 13px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border: 1px solid var(--line); background: var(--chip); color: var(--fg); border-radius: 999px; padding: 8px 14px; font: inherit; cursor: pointer; }
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.checks { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.check { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--chip); cursor: pointer; user-select: none; }
.check input { width: 20px; height: 20px; margin: 0; accent-color: var(--accent); flex: none; }
.check:has(input:checked) { border-color: var(--accent); }
.pt-tracks { margin: 0 36px 10px 0; }
.pt-tracks .chip { padding: 6px 12px; font-size: 13px; }
.btn { display: block; width: 100%; margin-top: 8px; border: 0; border-radius: 12px; padding: 13px; background: var(--accent); color: #fff; font: inherit; font-weight: 600; cursor: pointer; }

/* point details */
.pt-kicker { color: var(--muted); font-size: 13px; padding-right: 36px; }
.pt-head { display: flex; align-items: center; gap: 12px; margin: 6px 0 4px; }
.pt-dot { width: 18px; height: 18px; border-radius: 50%; border: 2px solid rgba(0, 0, 0, .25); flex: none; }
.pt-rate { font-size: 28px; font-weight: 700; font-variant-numeric: tabular-nums; }
.pt-rate small { font-size: 15px; font-weight: 500; color: var(--muted); }
.pt-meta { display: flex; flex-wrap: wrap; gap: 4px 14px; color: var(--muted); font-size: 13px; margin-bottom: 8px; }
.chart { width: 100%; height: auto; display: block; margin: 6px 0 4px; }
.chart text { fill: var(--muted); font-size: 11px; }
.chart .grid { stroke: var(--line); }
.chart .zero { stroke: var(--muted); stroke-dasharray: 3 3; }
.chart .pts { fill: var(--accent); }
.chart .trend { stroke: #e5484d; stroke-width: 2; }
.note { background: var(--chip); border-radius: 10px; padding: 8px 10px; font-size: 13px; margin-top: 8px; }

/* leaflet tweaks */
.leaflet-control-attribution { font-size: 10px; max-width: 70vw; }
.leaflet-bottom.leaflet-right { margin-bottom: env(safe-area-inset-bottom); }
.addr-pin { width: 22px; height: 22px; border-radius: 50% 50% 50% 0; background: #e5484d; border: 3px solid #fff;
  transform: rotate(-45deg); box-shadow: 0 2px 6px rgba(0, 0, 0, .4); }
.me-dot { width: 16px; height: 16px; border-radius: 50%; background: #1f6feb; border: 3px solid #fff; box-shadow: 0 0 0 6px rgba(31, 111, 235, .25); }
