:root {
  --paper: #f4f5f2;
  --panel: #ffffff;
  --ink: #17211d;
  --muted: #66716b;
  --line: #d9ded9;
  --accent: #176b52;
  --red: #c63c36;
  --orange: #df7c22;
  --green: #2b8a61;
  --shadow: 0 16px 44px rgba(23, 33, 29, .15);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; }
button, input, select { font: inherit; letter-spacing: 0; }
button { color: inherit; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.app-shell { height: 100%; display: grid; grid-template: 58px 1fr / 344px 1fr; }
.topbar { grid-column: 1 / -1; display: flex; align-items: center; padding: 0 14px 0 18px; background: rgba(255,255,255,.96); border-bottom: 1px solid var(--line); z-index: 1100; }
.brand { display: inline-flex; align-items: center; gap: 10px; border: 0; background: none; font-weight: 760; font-size: 18px; cursor: pointer; }
.brand-mark { width: 19px; height: 19px; border: 2px solid var(--accent); position: relative; transform: rotate(45deg); }
.brand-mark::after { content: ""; position: absolute; width: 5px; height: 5px; background: var(--orange); top: 5px; left: 5px; }
.dataset-note { margin-left: 26px; display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; font-weight: 650; }
.pulse-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); }
.top-actions { margin-left: auto; display: flex; gap: 6px; }
.icon-button, .tool-button { width: 38px; height: 38px; display: grid; place-items: center; border: 1px solid transparent; background: transparent; cursor: pointer; }
.icon-button:hover, .tool-button:hover { background: #edf0ec; border-color: var(--line); }

.sidebar { grid-row: 2; background: var(--panel); border-right: 1px solid var(--line); padding: 22px 18px 0; overflow: auto; z-index: 800; }
.sidebar-head { display: flex; justify-content: space-between; align-items: start; }
.eyebrow { margin: 0 0 6px; font-size: 11px; line-height: 1.2; text-transform: uppercase; color: var(--accent); font-weight: 800; }
h1 { margin: 0; font-size: 22px; line-height: 1.18; letter-spacing: 0; }
h2 { margin: 0 0 12px; font-size: 25px; line-height: 1.15; letter-spacing: 0; }
.search-box { height: 44px; margin: 20px 0 18px; display: flex; align-items: center; gap: 9px; padding: 0 12px; border: 1px solid var(--line); background: #fafbf9; }
.search-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(23,107,82,.1); }
.search-box svg { color: var(--muted); flex: 0 0 auto; }
.search-box input { width: 100%; border: 0; outline: 0; background: transparent; color: var(--ink); }
.filter-section { margin: 0 0 18px; }
.filter-label { display: block; margin-bottom: 8px; color: var(--muted); font-size: 11px; font-weight: 750; text-transform: uppercase; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { height: 32px; padding: 0 11px; border: 1px solid var(--line); background: white; cursor: pointer; font-size: 12px; font-weight: 650; }
.chip:hover { border-color: #aeb7b1; }
.chip.active { background: var(--ink); border-color: var(--ink); color: white; }
.compact-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
select { width: 100%; height: 38px; padding: 0 9px; border: 1px solid var(--line); background: #fafbf9; color: var(--ink); font-size: 12px; outline: none; }
.legend { margin: 2px 0 18px; padding: 13px 0; display: grid; grid-template-columns: repeat(3, 1fr); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.legend > div { display: grid; grid-template: auto auto / 13px 1fr; align-items: center; column-gap: 5px; }
.legend-dot { width: 8px; height: 8px; border-radius: 50%; }
.legend-dot.stopped { background: var(--red); }
.legend-dot.limited { background: var(--orange); }
.legend-dot.working { background: var(--green); }
.legend b { font-size: 17px; }
.legend small { grid-column: 1 / -1; color: var(--muted); font-size: 10px; margin-top: 3px; }
.list-header { display: flex; justify-content: space-between; align-items: center; padding-bottom: 9px; font-size: 12px; font-weight: 750; }
.text-button { border: 0; padding: 4px; background: none; color: var(--accent); cursor: pointer; font-size: 12px; }
.object-list { padding-bottom: 24px; }
.object-item { width: 100%; display: grid; grid-template-columns: 12px 1fr auto; gap: 10px; align-items: start; text-align: left; border: 0; border-top: 1px solid #eaede9; background: white; padding: 14px 2px; cursor: pointer; }
.object-item:hover { background: #f7f8f5; }
.object-item .status-mark { width: 9px; height: 9px; border-radius: 50%; margin-top: 5px; }
.object-item strong { display: block; font-size: 13px; line-height: 1.35; }
.object-item small { display: block; margin-top: 4px; color: var(--muted); font-size: 11px; line-height: 1.35; }
.object-item .arrow { color: #9ca59f; margin-top: 1px; }
.empty-state { color: var(--muted); font-size: 13px; padding: 20px 0; line-height: 1.5; }

.map-wrap { grid-row: 2; position: relative; min-width: 0; }
#map { width: 100%; height: 100%; background: #dce2dd; }
.leaflet-control-zoom { border: 0 !important; box-shadow: var(--shadow) !important; }
.leaflet-control-zoom a { border: 0 !important; color: var(--ink) !important; }
.leaflet-control-attribution { font-size: 9px; }
.map-tools { position: absolute; top: 14px; right: 14px; display: flex; flex-direction: column; gap: 6px; z-index: 700; }
.tool-button { background: white; border-color: var(--line); box-shadow: 0 5px 16px rgba(23,33,29,.11); }
.tool-button.active { color: white; background: var(--accent); border-color: var(--accent); }
.map-caption { position: absolute; left: 50%; bottom: 22px; transform: translateX(-50%); z-index: 700; padding: 7px 11px; background: rgba(255,255,255,.92); border: 1px solid var(--line); color: var(--muted); font-size: 10px; white-space: nowrap; box-shadow: 0 5px 16px rgba(23,33,29,.08); }
.measure-panel { position: absolute; z-index: 700; top: 14px; left: 50%; transform: translateX(-50%); min-width: 270px; padding: 10px 40px 10px 12px; background: white; border: 1px solid var(--line); box-shadow: var(--shadow); }
.measure-panel b, .measure-panel span { display: block; font-size: 12px; }
.measure-panel span { color: var(--muted); margin-top: 3px; }
.measure-panel button { position: absolute; top: 5px; right: 7px; border: 0; background: none; font-size: 23px; cursor: pointer; color: var(--muted); }
.area-marker { border-radius: 50%; border: 2px solid white; box-shadow: 0 2px 8px rgba(0,0,0,.32); }

.detail-panel { position: fixed; z-index: 1200; right: 18px; top: 76px; bottom: 18px; width: min(410px, calc(100vw - 36px)); background: white; border: 1px solid var(--line); box-shadow: var(--shadow); padding: 28px; overflow: auto; transform: translateX(calc(100% + 40px)); transition: transform .24s ease; }
.detail-panel.open { transform: translateX(0); }
.panel-close { position: absolute; right: 14px; top: 14px; width: 34px; height: 34px; display: grid; place-items: center; border: 0; background: transparent; cursor: pointer; }
.panel-close:hover { background: #edf0ec; }
.detail-status { display: inline-flex; align-items: center; gap: 7px; margin: 14px 0 18px; padding: 6px 9px; background: #f3f5f2; font-size: 11px; font-weight: 750; }
.detail-status i { width: 8px; height: 8px; border-radius: 50%; }
.detail-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding: 15px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.detail-meta span, .fact-label { display: block; margin-bottom: 4px; color: var(--muted); font-size: 10px; text-transform: uppercase; font-weight: 750; }
.detail-meta strong { font-size: 12px; }
.detail-body { font-size: 13px; line-height: 1.55; color: #39433e; }
.detail-body h3 { margin: 22px 0 8px; color: var(--ink); font-size: 13px; }
.source-link { display: block; margin-top: 8px; padding: 10px 12px; border: 1px solid var(--line); color: var(--accent); text-decoration: none; font-size: 12px; font-weight: 650; }
.source-link:hover { background: #f3f6f3; }
.safety-note { margin-top: 22px; padding: 12px; border-left: 3px solid var(--accent); background: #f1f5f2; color: var(--muted); font-size: 11px; line-height: 1.5; }

dialog { width: min(480px, calc(100vw - 32px)); border: 1px solid var(--line); padding: 30px; box-shadow: var(--shadow); color: var(--ink); }
dialog::backdrop { background: rgba(23,33,29,.45); }
dialog p:not(.eyebrow) { color: #4e5a53; font-size: 14px; line-height: 1.6; }
.primary-button { height: 40px; margin-top: 8px; padding: 0 18px; border: 0; background: var(--ink); color: white; font-weight: 700; cursor: pointer; }
.mobile-only { display: none; }

@media (max-width: 760px) {
  .app-shell { grid-template: 52px 1fr / 1fr; }
  .topbar { padding-left: 14px; }
  .dataset-note { margin-left: 14px; font-size: 10px; }
  .top-actions .icon-button:last-child { display: none; }
  .mobile-only { display: flex; }
  .sidebar { position: fixed; top: 52px; bottom: 0; left: 0; width: min(350px, 92vw); transform: translateX(-105%); transition: transform .22s ease; box-shadow: var(--shadow); }
  .sidebar.open { transform: translateX(0); }
  .map-wrap { grid-column: 1; grid-row: 2; }
  .map-menu { position: absolute; z-index: 700; top: 12px; left: 12px; height: 40px; align-items: center; gap: 7px; padding: 0 13px; border: 1px solid var(--line); background: white; box-shadow: 0 5px 16px rgba(23,33,29,.12); font-weight: 700; }
  .map-menu svg { width: 17px; }
  .map-tools { top: 12px; }
  .map-caption { left: 10px; right: 10px; bottom: 24px; transform: none; white-space: normal; text-align: center; line-height: 1.35; }
  .detail-panel { top: auto; left: 0; right: 0; bottom: 0; width: 100%; max-height: 78vh; transform: translateY(105%); padding: 26px 22px; }
  .detail-panel.open { transform: translateY(0); }
  .measure-panel { top: 61px; width: calc(100% - 24px); min-width: 0; }
  .leaflet-control-zoom { margin-top: 64px !important; }
}

@media (prefers-reduced-motion: reduce) {
  .sidebar, .detail-panel { transition: none; }
}
