:root {
  color-scheme: light;
  --ink: #17212b;
  --muted: #66737f;
  --line: #dce3e8;
  --surface: #ffffff;
  --surface-soft: #f3f6f7;
  --green: #0a6b58;
  --green-dark: #075346;
  --shadow: 0 12px 35px rgba(21, 35, 46, 0.13);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { height: 100%; margin: 0; }

body {
  overflow: hidden;
  color: var(--ink);
  background: #e7ecee;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button, input, select { font: inherit; }
button { color: inherit; }

.topbar {
  height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 0 24px;
  background: rgba(255, 255, 255, 0.97);
  border-bottom: 1px solid var(--line);
  position: relative;
  z-index: 1001;
}

.brand, .topbar-actions, .summary, .filter-row, .panel-heading { display: flex; align-items: center; }
.brand { gap: 12px; }
.brand-mark {
  width: 42px; height: 42px; border-radius: 13px; display: grid; place-items: center;
  color: white; background: var(--green); font-size: 13px; font-weight: 800; letter-spacing: .06em;
  box-shadow: 0 7px 18px rgba(10, 107, 88, .23);
}
.eyebrow { margin: 0 0 2px; color: var(--green); font-size: 10px; font-weight: 800; letter-spacing: .14em; }
h1 { margin: 0; font-size: 20px; line-height: 1.15; letter-spacing: -.02em; }
.topbar-actions { gap: 14px; }
.source-status { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 13px; }
.source-status i { width: 8px; height: 8px; border-radius: 50%; background: #27a679; box-shadow: 0 0 0 4px rgba(39, 166, 121, .12); }

.button { border: 0; border-radius: 9px; padding: 9px 13px; cursor: pointer; font-weight: 700; font-size: 13px; }
.button-secondary { background: var(--surface-soft); border: 1px solid var(--line); }
.button:hover { filter: brightness(.97); }

.app-shell { height: calc(100vh - 76px); display: grid; grid-template-columns: 380px minmax(0, 1fr); }
.sidebar { overflow-y: auto; background: var(--surface-soft); border-right: 1px solid var(--line); padding: 16px; position: relative; z-index: 500; }
.summary { justify-content: space-between; gap: 8px; padding: 12px 14px; margin-bottom: 12px; border-radius: 12px; color: white; background: linear-gradient(120deg, var(--green-dark), #0d8069); }
.summary > div { min-width: 0; }
.summary-label { display: block; margin-bottom: 3px; color: rgba(255,255,255,.69); font-size: 10px; text-transform: uppercase; letter-spacing: .08em; }
.summary strong { font-size: 16px; }

.panel { margin-bottom: 12px; padding: 15px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.search-panel label { display: block; margin-bottom: 8px; font-size: 12px; font-weight: 750; }
.search-wrap { display: flex; align-items: center; gap: 8px; height: 42px; padding: 0 11px; border: 1px solid #cfd8de; border-radius: 9px; background: white; }
.search-wrap:focus-within { border-color: var(--green); box-shadow: 0 0 0 3px rgba(10, 107, 88, .1); }
.search-wrap span { color: #73808b; font-size: 22px; transform: rotate(-20deg); }
.search-wrap input { min-width: 0; flex: 1; border: 0; outline: 0; color: var(--ink); }
.filter-row { gap: 8px; margin-top: 9px; }
.filter-row select { min-width: 0; flex: 1; height: 38px; padding: 0 30px 0 10px; border: 1px solid #cfd8de; border-radius: 8px; background: white; color: #36434e; }
.icon-button { width: 38px; height: 38px; border: 1px solid #cfd8de; border-radius: 8px; background: white; cursor: pointer; font-size: 21px; color: #596670; }
.result-summary { margin: 10px 0 0; color: var(--muted); font-size: 12px; }

.panel-heading { justify-content: space-between; gap: 10px; margin-bottom: 11px; }
.panel-heading h2, .detail-panel h2 { margin: 0; font-size: 14px; }
.text-button { padding: 0; border: 0; background: none; color: var(--green); cursor: pointer; font-size: 12px; font-weight: 700; }
.legend-list { display: grid; gap: 7px; max-height: 205px; overflow: auto; padding-right: 4px; }
.legend-item { display: grid; grid-template-columns: 14px 1fr auto; align-items: center; gap: 8px; font-size: 12px; color: #35424d; }
.legend-swatch { width: 14px; height: 14px; border-radius: 3px; border: 1px solid rgba(0,0,0,.17); }
.legend-count { color: #84909a; font-variant-numeric: tabular-nums; }

.detail-panel { min-height: 165px; }
.empty-state { text-align: center; padding: 10px 8px 5px; }
.empty-icon { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; margin: 0 auto 8px; background: #e7f2ef; color: var(--green); font-size: 21px; }
.empty-state p { max-width: 235px; margin: 7px auto 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.detail-title { display: flex; align-items: flex-start; gap: 10px; padding-bottom: 12px; margin-bottom: 8px; border-bottom: 1px solid var(--line); }
.detail-title .legend-swatch { flex: 0 0 auto; width: 20px; height: 20px; margin-top: 1px; }
.detail-title h2 { line-height: 1.35; }
.detail-code { margin-top: 2px; color: var(--muted); font-size: 11px; }
.detail-grid { display: grid; gap: 0; }
.detail-row { display: grid; grid-template-columns: 116px minmax(0, 1fr); gap: 10px; padding: 7px 0; border-bottom: 1px solid #eef1f3; font-size: 12px; }
.detail-row:last-child { border-bottom: 0; }
.detail-row span { color: var(--muted); }
.detail-row strong { overflow-wrap: anywhere; font-weight: 650; text-align: right; }

.sidebar-footer { padding: 3px 3px 16px; font-size: 11px; color: var(--muted); line-height: 1.45; }
.sidebar-footer p { margin: 0 0 3px; }
.sidebar-footer a { color: var(--green); font-weight: 700; text-decoration: none; }

.map-stage { position: relative; min-width: 0; }
#map { width: 100%; height: 100%; background: #dbe1e3; }
.map-note, .loading-card, .error-card { position: absolute; z-index: 700; background: rgba(255,255,255,.95); box-shadow: var(--shadow); backdrop-filter: blur(8px); }
.map-note { top: 16px; left: 16px; display: grid; gap: 2px; padding: 10px 13px; border-radius: 10px; border: 1px solid rgba(213,222,226,.9); }
.map-note strong { font-size: 12px; }
.map-note span { color: var(--muted); font-size: 10px; }
.locate-button { position: absolute; z-index: 700; right: 15px; top: 15px; width: 40px; height: 40px; border: 1px solid #cad4da; border-radius: 10px; background: rgba(255,255,255,.96); box-shadow: 0 6px 20px rgba(27,42,51,.14); cursor: pointer; color: var(--green); font-size: 23px; }
.loading-card, .error-card { top: 50%; left: 50%; transform: translate(-50%, -50%); border-radius: 12px; padding: 14px 18px; font-size: 13px; }
.loading-card { display: flex; align-items: center; gap: 10px; }
.loading-card span { width: 17px; height: 17px; border: 2px solid #c9d9d5; border-top-color: var(--green); border-radius: 50%; animation: spin .75s linear infinite; }
.error-card { display: grid; gap: 4px; color: #862c2c; text-align: center; }
.error-card span { color: #7d6666; font-size: 11px; }
@keyframes spin { to { transform: rotate(360deg); } }

.parcel-label { background: transparent; border: 0; box-shadow: none; color: rgba(31,42,47,.82); font-size: 9px; font-weight: 800; text-shadow: 0 1px 2px white, 1px 0 2px white, -1px 0 2px white; }
.leaflet-control-zoom { border: 0 !important; box-shadow: 0 5px 20px rgba(25,39,48,.16) !important; }
.leaflet-control-zoom a { color: #34424c !important; border-color: #e0e6e9 !important; }
.leaflet-control-attribution { font-size: 9px; }

@media (max-width: 820px) {
  body { overflow: auto; }
  .topbar { height: 68px; padding: 0 14px; }
  .source-status { display: none; }
  h1 { font-size: 17px; }
  .app-shell { height: auto; min-height: calc(100vh - 68px); display: flex; flex-direction: column-reverse; }
  .map-stage { height: 57vh; min-height: 420px; }
  .sidebar { overflow: visible; border-right: 0; border-top: 1px solid var(--line); }
  .legend-list { max-height: none; }
}
