:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --text: #1c2330;
  --muted: #667085;
  --line: #e3e6eb;
  --accent: #2563eb;
  --red: #e11d1d;
  --c0: #f59e0b;
  --c1: #7c3aed;
  --c2: #16a34a;
  --c3: #2563eb;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12161d;
    --surface: #1b212b;
    --text: #e8ebf0;
    --muted: #98a2b3;
    --line: #2d3542;
    --accent: #6ea0ff;
    --c0: #fbbf24;
    --c1: #a78bfa;
    --c2: #4ade80;
    --c3: #60a5fa;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "Segoe UI", "Malgun Gothic", "Apple SD Gothic Neo", sans-serif;
  font-size: 15px;
  line-height: 1.5;
}
h1 { margin: 0; font-size: 22px; }
h2 { margin: 0 0 8px; font-size: 17px; }
h3 { margin: 0 0 6px; font-size: 15px; }
.topbar { padding: 16px; }
.sub { margin: 2px 0 0; color: var(--muted); font-size: 13px; }

.layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 12px;
  padding: 0 16px;
}
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
}
.result { margin: 12px 16px; }
.hint { color: var(--muted); font-size: 13px; margin: 0 0 10px; }
.hint.small { font-size: 12px; margin-top: 6px; }

.map-wrap { min-width: 0; }
#map {
  height: 620px;
  border-radius: 10px;
  border: 1px solid var(--line);
  z-index: 0;
}

/* sliders */
.slider-row { margin-bottom: 12px; }
.slider-top { display: flex; align-items: center; gap: 6px; font-size: 14px; }
.dot { width: 12px; height: 12px; border-radius: 50%; flex: none; }
.slider-top .nm { flex: 1; }
.slider-top .cnt { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.slider-row input[type=range] { width: 100%; margin: 4px 0 0; }
.total-row { display: flex; gap: 6px; align-items: baseline; margin: 6px 0 10px; font-size: 14px; }
.total-row strong { font-size: 20px; }
.btn-row { display: flex; gap: 8px; margin-bottom: 10px; }
.btn {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 14px;
  cursor: pointer;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; flex: 1; }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn.dirty { box-shadow: 0 0 0 3px rgba(37, 99, 235, .3); }
.check { display: block; font-size: 14px; margin: 8px 0; }
.legend { border-top: 1px solid var(--line); margin-top: 10px; padding-top: 10px; font-size: 13px; }
.legend .item { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; }
.legend .desc { color: var(--muted); }
.swatch-red {
  display: inline-block; width: 12px; height: 12px; border-radius: 50%;
  border: 3px solid var(--red); vertical-align: middle;
}

/* cards */
.cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 14px; }
.card { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
.card .k { color: var(--muted); font-size: 12px; }
.card .v { font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; }

.two-col { display: grid; grid-template-columns: minmax(260px, 1fr) 2fr; gap: 18px; }
.top-summary { margin: 0 16px 12px; }
.tbl-scroll.short { max-height: 280px; }
#topTable tfoot td { position: sticky; bottom: 0; background: var(--surface); border-top: 2px solid var(--line); }
.two-col > div { min-width: 0; }
.tbl-head { display: flex; justify-content: space-between; align-items: end; flex-wrap: wrap; gap: 6px; }
.tbl-tools { display: flex; gap: 10px; align-items: center; font-size: 13px; }
.tbl-tools select { padding: 5px 8px; border-radius: 6px; border: 1px solid var(--line); background: var(--surface); color: var(--text); }
.tbl-scroll { max-height: 460px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; }

.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th, .tbl td { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
.tbl th { position: sticky; top: 0; background: var(--surface); font-weight: 600; cursor: pointer; user-select: none; }
#guTable th { cursor: default; position: static; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl tbody tr { cursor: pointer; }
.tbl tbody tr:hover { background: color-mix(in srgb, var(--accent) 10%, transparent); }
.tbl tbody tr.active { background: color-mix(in srgb, var(--accent) 18%, transparent); }
.chip { display: inline-block; padding: 1px 8px; border-radius: 10px; color: #fff; font-size: 12px; }
.stack { display: flex; height: 12px; min-width: 120px; border-radius: 6px; overflow: hidden; background: var(--line); }
.stack span { display: block; height: 100%; }

.foot { color: var(--muted); font-size: 12px; padding: 4px 16px 20px; }

.leaflet-popup-content { font-family: inherit; font-size: 13px; line-height: 1.5; }
.leaflet-popup-content b { font-size: 14px; }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  #map { height: 480px; }
  .cards { grid-template-columns: repeat(2, 1fr); }
  .two-col { grid-template-columns: 1fr; }
}
