:root {
  color-scheme: light;
  --navy: #14213d;
  --ink: #24324b;
  --blue: #1e40af;
  --blue-bright: #3b82f6;
  --amber: #d97706;
  --line: #dbe3ee;
  --line-soft: #edf1f6;
  --muted: #59677c;
  --surface: #ffffff;
  --soft: #f6f8fb;
  --background: #eef2f7;
  --focus: #1e40af;
  font-family: "Avenir Next", Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--background); color: var(--ink); overflow: hidden; }
button, input, select, textarea { font: inherit; }
button, input, summary { touch-action: manipulation; }
button { color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

.skip-link {
  background: var(--navy);
  color: white;
  left: 8px;
  padding: 8px 12px;
  position: fixed;
  top: -48px;
  z-index: 20;
}
.skip-link:focus { top: 8px; }

.topbar {
  align-items: center;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex;
  height: 64px;
  justify-content: space-between;
  left: 0;
  padding: 0 20px;
  position: fixed;
  right: 0;
  top: 0;
  z-index: 10;
}
.brand { align-items: center; display: flex; gap: 10px; }
.brand-mark {
  align-items: center;
  background: var(--navy);
  border-radius: 6px;
  color: white;
  display: flex;
  font-size: 16px;
  font-weight: 750;
  height: 34px;
  justify-content: center;
  letter-spacing: -.04em;
  width: 34px;
}
.brand strong, .brand small { display: block; }
.brand strong { color: var(--navy); font-size: 15px; line-height: 17px; }
.brand small { color: var(--muted); font-size: 11px; }
.topbar-meta { align-items: center; display: flex; gap: 18px; }
.snapshot-label, .status { color: var(--muted); font-size: 11px; }
.status { border-left: 1px solid var(--line); padding-left: 18px; }
.status.error { color: #a61b1b; }

.app-shell, .workspace {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr) 380px;
  height: 100vh;
  padding-top: 64px;
}
.sidebar {
  background: var(--surface);
  min-width: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-color: #c8d2e1 transparent;
  scrollbar-width: thin;
}
.sidebar-left { border-right: 1px solid var(--line); }
.sidebar-right { border-left: 1px solid var(--line); padding: 20px 18px 32px; }
.sidebar-heading { border-bottom: 1px solid var(--line); padding: 20px 16px 17px; }
.sidebar-heading h1, .detail-header h1 { color: var(--navy); font-size: 19px; letter-spacing: -.02em; margin: 3px 0 4px; }
.sidebar-heading p, .detail-header p { color: var(--muted); font-size: 12px; line-height: 1.45; margin: 0; }
.eyebrow { color: var(--blue); display: block; font-size: 10px; font-weight: 750; letter-spacing: .1em; text-transform: uppercase; }
.sidebar-scroll { padding-bottom: 12px; }

.control-section { border-bottom: 1px solid var(--line); }
.control-section summary, .sources summary {
  align-items: center;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  list-style: none;
  min-height: 48px;
  padding: 0 16px;
}
.control-section summary::-webkit-details-marker, .sources summary::-webkit-details-marker, .map-legend summary::-webkit-details-marker { display: none; }
.control-section summary::after, .sources summary::after, .map-legend summary::after {
  border-bottom: 1.5px solid currentColor;
  border-right: 1.5px solid currentColor;
  content: "";
  height: 6px;
  margin-left: 12px;
  transform: rotate(45deg) translateY(-2px);
  transition: transform 150ms ease;
  width: 6px;
}
.control-section[open] summary::after, .sources[open] summary::after, .map-legend[open] summary::after { transform: rotate(225deg) translate(-1px, -1px); }
.control-section summary:hover, .sources summary:hover { background: var(--soft); }
.control-section summary > span, .sources summary { color: var(--navy); font-size: 12px; font-weight: 700; }
.control-section summary small { color: var(--muted); font-size: 10px; font-weight: 500; margin-left: auto; padding-left: 8px; }
.control-section-body { padding: 0 16px 16px; }
.field-label { color: var(--navy); display: block; font-size: 11px; font-weight: 700; margin-bottom: 6px; }
#station-search {
  background: var(--surface);
  border: 1px solid #bcc8d8;
  border-radius: 4px;
  color: var(--navy);
  height: 42px;
  padding: 0 11px;
  width: 100%;
}
#station-search::placeholder { color: #7b8799; }
#station-search:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgb(30 64 175 / 12%); outline: 0; }
.field-help { color: var(--muted); font-size: 10px; line-height: 1.45; margin: 7px 0 14px; }
.list-heading, .section-heading { align-items: baseline; display: flex; justify-content: space-between; }
.list-heading { border-top: 1px solid var(--line-soft); color: var(--navy); font-size: 11px; font-weight: 700; padding-top: 12px; }
.list-heading small, .section-heading > span { color: var(--muted); font-size: 9px; font-weight: 500; }

.station-list { list-style: none; margin: 7px -6px 0; padding: 0; }
.station-list li { border-bottom: 1px solid var(--line-soft); }
.station-list button {
  align-items: center;
  background: transparent;
  border: 0;
  border-left: 3px solid transparent;
  cursor: pointer;
  display: grid;
  gap: 8px;
  grid-template-columns: 22px minmax(0, 1fr) auto;
  min-height: 50px;
  padding: 7px 6px 7px 3px;
  text-align: left;
  width: 100%;
}
.station-list button:hover { background: var(--soft); }
.station-list button.is-selected { background: #edf3ff; border-left-color: var(--blue); }
.station-list button .rank { color: var(--muted); font-size: 10px; text-align: center; }
.station-list button .name { color: var(--navy); font-size: 11px; font-weight: 700; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.station-list button .sample { color: var(--muted); display: block; font-size: 9px; font-weight: 500; margin-top: 3px; }
.station-list button .score { color: var(--blue); font-size: 11px; font-weight: 750; }
.station-list .empty { color: var(--muted); font-size: 11px; padding: 12px 6px; }

.layer-options { display: grid; gap: 2px; }
.control-row {
  align-items: center;
  border-radius: 4px;
  cursor: pointer;
  display: grid;
  gap: 9px;
  grid-template-columns: 18px minmax(0, 1fr);
  min-height: 45px;
  padding: 5px 4px;
}
.control-row:hover { background: var(--soft); }
.control-row input { accent-color: var(--blue); height: 18px; margin: 0; width: 18px; }
.control-row > span { display: grid; gap: 2px; }
.control-row strong { color: var(--navy); font-size: 11px; line-height: 1.25; }
.control-row small { color: var(--muted); font-size: 9px; line-height: 1.3; }
.control-row:has(input:disabled) { cursor: not-allowed; opacity: .48; }
.control-row:has(input:disabled):hover { background: transparent; }

.sources { border-top: 1px solid var(--line); color: var(--muted); font-size: 10px; margin-top: 7px; }
.sources summary { min-height: 44px; padding: 0 16px; }
.source-row { border-top: 1px solid var(--line-soft); display: flex; justify-content: space-between; padding: 8px 16px; }
.source-row strong { color: var(--navy); }

.map-panel { min-width: 0; position: relative; }
#map { height: 100%; width: 100%; }
.map-legend {
  background: rgb(255 255 255 / 96%);
  border: 1px solid var(--line);
  border-radius: 4px;
  bottom: 18px;
  box-shadow: 0 2px 9px rgb(20 33 61 / 12%);
  font-size: 10px;
  left: 16px;
  max-width: min(252px, calc(100% - 32px));
  position: absolute;
  z-index: 2;
}
.map-legend summary { align-items: center; cursor: pointer; display: flex; font-size: 11px; font-weight: 750; justify-content: space-between; min-height: 38px; padding: 0 10px; }
.legend-content { border-top: 1px solid var(--line); display: grid; gap: 8px; padding: 9px 10px 10px; }
.legend-row { align-items: center; display: flex; gap: 7px; }
.legend-block { display: grid; gap: 4px; }
.legend-block strong { font-size: 10px; }
.scale { background: linear-gradient(90deg, #e9b949, #e46c38, #a61b1b); border-radius: 5px; height: 7px; width: 90px; }
.kde-scale { background: linear-gradient(90deg, #f7fbff, #9ecae1, #2171b5, #08306b); }
.hotspot-legend { display: grid; gap: 4px 8px; grid-template-columns: 1fr 1fr; }
.hotspot-legend span { align-items: center; display: flex; gap: 4px; white-space: nowrap; }
.swatch { border-radius: 2px; display: inline-block; height: 9px; width: 9px; }
.hotspot-90 { background: #fdae6b; }
.hotspot-95 { background: #e6550d; }
.hotspot-99 { background: #a63603; }
.coldspot-90 { background: #9ecae1; }
.coldspot-99 { background: #2171b5; }
.not-significant { background: #cbd5e1; }
.land-low { background: #a7f3d0; }
.land-mid { background: #fcd34d; }
.land-high { background: #f97316; }
.admin-district { background: #475569; border-radius: 0; height: 2px; width: 24px; }
.admin-village { background: repeating-linear-gradient(to right, #64748b 0 5px, transparent 5px 9px); border-radius: 0; height: 2px; width: 24px; }
.scope-jakarta-pusat { background: #bfdbfe; border: 1px solid #1e40af; }
.railway { background: linear-gradient(180deg, #155e9a 0 28%, #4ea1d3 28% 72%, #155e9a 72%); border: 1px solid #155e9a; }

.detail-header { border-bottom: 1px solid var(--line); padding-bottom: 17px; }
.detail-header p { color: var(--blue); font-weight: 650; }
.detail-tabs { border-bottom: 1px solid var(--line); display: flex; gap: 4px; margin: 0 -18px; padding: 0 18px; }
.tab {
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 11px;
  font-weight: 700;
  min-height: 46px;
  padding: 0 7px;
}
.tab:hover { color: var(--navy); }
.tab.is-active { border-bottom-color: var(--blue); color: var(--blue); }
.tab-panel { padding-top: 17px; }
.score-card {
  align-items: center;
  background: linear-gradient(135deg, var(--navy), #1e3a8a);
  border-radius: 5px;
  color: white;
  display: flex;
  justify-content: space-between;
  min-height: 84px;
  padding: 15px;
}
.card-label { color: #c7d7ff; display: block; font-size: 10px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.score-card strong { display: block; font-size: 32px; letter-spacing: -.06em; line-height: 1; margin-top: 7px; }
.score-source { align-self: flex-start; border: 1px solid rgb(255 255 255 / 30%); border-radius: 3px; color: #dbeafe; font-size: 9px; padding: 4px 6px; }
.selected-summary { color: var(--muted); font-size: 11px; line-height: 1.5; margin: 11px 0 0; }
.tags { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 9px; }
.tags span { background: #f0f4fb; border: 1px solid #d8e2f2; border-radius: 3px; color: var(--blue); font-size: 10px; font-weight: 650; padding: 4px 6px; }
.metric-section, .profile-section, .distance-decay-section { border-top: 1px solid var(--line); margin-top: 17px; padding-top: 14px; }
.section-heading h2 { color: var(--navy); font-size: 12px; margin: 0; }
.metric-grid { display: grid; gap: 7px; grid-template-columns: repeat(3, 1fr); margin-top: 9px; }
.metric-card { background: var(--soft); border: 1px solid var(--line); border-radius: 4px; min-width: 0; padding: 10px 9px; }
.metric-card span, .metric-card small { color: var(--muted); display: block; font-size: 9px; }
.metric-card strong { color: var(--navy); display: block; font-size: 17px; letter-spacing: -.03em; margin: 6px 0 3px; overflow: hidden; text-overflow: ellipsis; }
.profile-list { display: grid; gap: 0 10px; grid-template-columns: minmax(0, 1fr) auto; margin: 11px 0 0; }
.profile-list dt, .profile-list dd { border-bottom: 1px solid var(--line-soft); padding: 6px 0; }
.profile-list dt { color: var(--muted); display: grid; font-size: 10px; gap: 2px; }
.profile-list dt small { color: #7b8799; font-size: 9px; }
.profile-list dd { color: var(--navy); font-size: 10px; font-weight: 700; margin: 0; max-width: 150px; text-align: right; }
.distance-decay-chart { margin: 0; }
.distance-decay-chart svg { display: block; height: auto; width: 100%; }
.chart-grid { stroke: var(--line-soft); stroke-width: 1; }
.chart-axis { stroke: #9dacbf; stroke-width: 1; }
.chart-trend { fill: none; stroke: var(--amber); stroke-linecap: round; stroke-linejoin: round; stroke-width: 2; }
.chart-point { fill: var(--blue); fill-opacity: .72; stroke: white; stroke-width: 1; }
.chart-label, .chart-title { fill: var(--muted); font: 9px Avenir Next, Inter, sans-serif; }
.chart-title { fill: var(--navy); font-weight: 700; }

.empty-state { align-items: flex-start; background: var(--soft); border: 1px dashed #bdc9d9; border-radius: 5px; display: flex; flex-direction: column; padding: 24px 17px; }
.empty-state[hidden] { display: none; }
.empty-rule { background: var(--amber); display: block; height: 3px; margin-bottom: 17px; width: 32px; }
.empty-state h2 { color: var(--navy); font-size: 14px; line-height: 1.35; margin: 0 0 7px; }
.empty-state p { color: var(--muted); font-size: 11px; line-height: 1.55; margin: 0; }
.placeholder-state { margin-top: 0; }
.assistant-panel { margin: 0; }
.assistant-messages { display: grid; gap: 8px; margin-bottom: 12px; }
.assistant-message { border-radius: 4px; font-size: 11px; line-height: 1.55; padding: 10px; }
.assistant-message.bot { background: var(--soft); color: var(--navy); }
.assistant-message.user { background: var(--blue); color: white; margin-left: 24px; }
.assistant-source { color: var(--muted); display: block; font-size: 10px; margin-top: 6px; }
.assistant-questions { display: grid; gap: 7px; }
.assistant-question { background: white; border: 1px solid #bdc9d9; border-radius: 4px; color: var(--navy); cursor: pointer; font: inherit; font-size: 11px; font-weight: 700; line-height: 1.4; min-height: 44px; padding: 9px 11px; text-align: left; }
.assistant-question:hover { border-color: var(--blue); color: var(--blue); }
.assistant-question:disabled { cursor: default; opacity: .6; }
.assistant-status { color: var(--muted); font-size: 11px; line-height: 1.5; margin: 9px 0 0; min-height: 17px; }

.maplibregl-popup-content { border-radius: 4px; color: var(--navy); font: 12px/1.5 "Avenir Next", Inter, sans-serif; padding: 10px 12px; }

@media (max-width: 1100px) {
  .app-shell, .workspace { grid-template-columns: 248px minmax(0, 1fr) 332px; }
  .snapshot-label { display: none; }
  .status { border-left: 0; padding-left: 0; }
}

@media (max-width: 900px) {
  body { overflow: auto; }
  .topbar { position: sticky; }
  .app-shell, .workspace { display: block; height: auto; padding-top: 0; }
  .sidebar { border: 0; overflow: visible; }
  .sidebar-left { border-bottom: 1px solid var(--line); }
  .sidebar-right { border-top: 1px solid var(--line); padding: 18px 16px 28px; }
  .sidebar-heading { padding: 18px 16px 15px; }
  .map-panel { height: 58vh; min-height: 390px; }
  .detail-tabs { margin: 0 -16px; padding: 0 16px; }
}

@media (max-width: 520px) {
  .topbar { height: 58px; padding: 0 14px; }
  .app-shell, .workspace { padding-top: 0; }
  .map-panel { height: 52vh; min-height: 330px; }
  .map-legend { bottom: 12px; left: 12px; }
  .control-section summary, .sources summary { padding: 0 14px; }
  .control-section-body { padding-left: 14px; padding-right: 14px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
