@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=Manrope:wght@600;700;800&display=swap');

:root {
  --ink: #10221e;
  --muted: #6b7e78;
  --line: #dfe8e4;
  --panel: #f8fbf9;
  --green: #0b5f4e;
  --green-dark: #073d34;
  --yellow: #f5c842;
  --white: #fff;
  font-family: "DM Sans", system-ui, sans-serif;
  color: var(--ink);
}

* { box-sizing: border-box; }
html, body, .app-shell { height: 100%; margin: 0; }
body { overflow: hidden; background: #e9efec; }
button, input { font: inherit; }
button { cursor: pointer; }

.skip-link { position: fixed; z-index: 9999; left: 1rem; top: -5rem; padding: .75rem 1rem; background: #fff; color: var(--green); border-radius: .5rem; }
.skip-link:focus { top: 1rem; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

.app-shell { display: grid; grid-template-columns: 390px 1fr; }
.sidebar { position: relative; z-index: 700; display: flex; flex-direction: column; min-width: 0; background: rgba(249,252,250,.98); border-right: 1px solid rgba(9,69,57,.12); box-shadow: 18px 0 50px rgba(9,45,38,.08); }
.brand { display: flex; align-items: center; gap: 13px; padding: 27px 26px 21px; border-bottom: 1px solid var(--line); }
.brand-mark { width: 42px; height: 42px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 13px; background: var(--green); transform: rotate(45deg); box-shadow: 0 8px 18px rgba(11,95,78,.24); }
.brand-mark span { width: 16px; height: 16px; border: 4px solid var(--yellow); border-left-width: 0; border-bottom-width: 0; }
.brand h1 { margin: 3px 0 0; font-family: Manrope, sans-serif; font-size: 1.22rem; line-height: 1.2; letter-spacing: -.025em; }
.eyebrow { margin: 0; color: var(--green); font-size: .67rem; font-weight: 700; letter-spacing: .115em; text-transform: uppercase; }
.close-panel { display: none; margin-left: auto; }

.summary { display: grid; grid-template-columns: repeat(3, 1fr); margin: 20px 24px 16px; padding: 15px 8px; background: #edf5f1; border: 1px solid #dcebe5; border-radius: 14px; }
.summary div { display: flex; flex-direction: column; align-items: center; gap: 2px; border-right: 1px solid #d2e3dc; }
.summary div:last-child { border: 0; }
.summary strong { font-family: Manrope, sans-serif; font-size: 1.05rem; }
.summary span { color: var(--muted); font-size: .67rem; }

.search-wrap { position: relative; margin: 0 24px 18px; }
.search-wrap svg { position: absolute; width: 18px; left: 13px; top: 50%; transform: translateY(-50%); fill: none; stroke: #7d8e89; stroke-width: 2; stroke-linecap: round; }
.search-wrap input { width: 100%; height: 44px; padding: 0 44px 0 41px; color: var(--ink); background: white; border: 1px solid #d7e2de; border-radius: 11px; outline: 0; transition: .2s; }
.search-wrap input:focus { border-color: #7eb2a6; box-shadow: 0 0 0 4px rgba(11,95,78,.1); }
.search-wrap kbd { position: absolute; right: 10px; top: 10px; padding: 3px 7px; color: #80918c; background: #f1f5f3; border: 1px solid #dfe7e4; border-bottom-width: 2px; border-radius: 5px; font: 500 .7rem inherit; }
.list-head { display: flex; align-items: center; justify-content: space-between; padding: 0 25px 10px; color: #40554f; font-size: .74rem; font-weight: 700; letter-spacing: .055em; text-transform: uppercase; }
.list-head button { padding: 0; color: var(--green); background: none; border: 0; font-size: .68rem; font-weight: 600; text-transform: none; letter-spacing: 0; }
.polygon-list { flex: 1; min-height: 0; overflow: auto; padding: 0 14px 12px; scrollbar-width: thin; scrollbar-color: #bdd0c9 transparent; }
.polygon-item { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 4px; width: 100%; margin: 2px 0; padding: 4px 7px 4px 5px; color: inherit; text-align: left; background: transparent; border: 1px solid transparent; border-radius: 11px; transition: .18s ease; }
.polygon-item:hover, .polygon-item:focus-within { background: white; border-color: #dbe7e2; outline: 0; }
.polygon-item.active { background: white; border-color: #bed7ce; box-shadow: 0 7px 20px rgba(18,71,60,.08); }
.item-main { display: grid; grid-template-columns: 20px 1fr; align-items: center; gap: 10px; min-width: 0; padding: 8px 6px; color: inherit; text-align: left; background: none; border: 0; border-radius: 8px; }
.item-main:focus-visible, .eye:focus-visible { outline: 2px solid #76a99d; outline-offset: 1px; }
.swatch { width: 13px; height: 13px; border: 3px solid var(--swatch); border-radius: 4px; background: color-mix(in srgb, var(--swatch) 22%, white); }
.item-copy { min-width: 0; }
.item-copy strong { display: block; overflow: hidden; font-size: .82rem; white-space: nowrap; text-overflow: ellipsis; }
.item-copy small { display: block; margin-top: 3px; color: var(--muted); font-size: .69rem; }
.eye { width: 30px; height: 30px; display: grid; place-items: center; padding: 0; color: #587069; background: transparent; border: 0; border-radius: 7px; }
.eye svg { width: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.polygon-item.hidden-layer { opacity: .48; }

.data-note { display: flex; gap: 10px; margin: 8px 24px 14px; padding: 11px 12px; color: #657771; background: #f1f5f3; border-radius: 10px; font-size: .68rem; line-height: 1.45; }
.data-note p { margin: 0; }
.data-note strong { color: #40534d; }
.note-icon { display: grid; place-items: center; width: 18px; height: 18px; flex: 0 0 auto; color: white; background: #82958e; border-radius: 50%; font-size: .7rem; font-weight: 700; }
footer { padding: 0 25px 17px; color: #8c9b96; font-size: .65rem; }

.map-stage { position: relative; min-width: 0; }
#map { width: 100%; height: 100%; background: #d9e2dd; }
.leaflet-container { font: 12px "DM Sans", sans-serif; }
.leaflet-control-zoom { margin: 0 18px 34px 0 !important; border: 0 !important; box-shadow: 0 7px 24px rgba(9,43,36,.18) !important; }
.leaflet-control-zoom a { width: 38px !important; height: 38px !important; line-height: 36px !important; color: var(--green-dark) !important; border-color: #e1e8e5 !important; }
.leaflet-popup-content-wrapper { border-radius: 14px; box-shadow: 0 12px 32px rgba(5,38,31,.22); }
.leaflet-popup-content { margin: 16px 18px; }
.popup-title { margin: 0 0 9px; max-width: 220px; font: 700 .9rem Manrope, sans-serif; color: var(--green-dark); }
.popup-stats { display: flex; gap: 18px; color: #687b75; }
.popup-stats strong { display: block; color: var(--ink); font-size: .86rem; }
.popup-stats span { font-size: .65rem; }

.topbar { position: absolute; z-index: 600; top: 18px; left: 18px; right: 18px; display: flex; align-items: center; gap: 10px; pointer-events: none; }
.topbar > * { pointer-events: auto; }
.location-pill, .map-button, .icon-button, .basemap-control { min-height: 42px; border: 1px solid rgba(9,62,51,.13); box-shadow: 0 7px 25px rgba(6,40,34,.13); }
.location-pill { display: flex; align-items: center; gap: 8px; padding: 0 15px; color: #23423a; background: rgba(255,255,255,.94); border-radius: 10px; font-size: .76rem; font-weight: 600; backdrop-filter: blur(9px); }
.location-pill span { width: 8px; height: 8px; background: var(--green); border: 2px solid #bfe0d5; border-radius: 50%; }
.basemap-control { position: relative; display: flex; align-items: center; gap: 8px; padding: 0 9px 0 12px; color: #23423a; background: rgba(255,255,255,.94); border-radius: 10px; font-size: .72rem; font-weight: 600; backdrop-filter: blur(9px); }
.basemap-control svg { width: 17px; flex: 0 0 auto; fill: none; stroke: var(--green); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.basemap-control select { height: 30px; max-width: 118px; padding: 0 24px 0 8px; color: var(--green-dark); background: #edf5f1; border: 0; border-radius: 7px; outline: 0; font-size: .7rem; font-weight: 700; cursor: pointer; }
.basemap-control select:focus-visible { box-shadow: 0 0 0 3px rgba(11,95,78,.16); }
.map-button { display: flex; align-items: center; gap: 8px; margin-left: auto; padding: 0 14px; color: white; background: rgba(7,61,52,.94); border-radius: 10px; font-size: .73rem; font-weight: 600; }
.map-button svg, .icon-button svg { width: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.icon-button { width: 42px; display: grid; place-items: center; padding: 0; color: var(--green-dark); background: rgba(255,255,255,.96); border-radius: 10px; font-size: 1.6rem; }
.menu-button { display: none; }
.legend { position: absolute; z-index: 500; left: 20px; bottom: 24px; display: flex; align-items: center; gap: 8px; padding: 9px 12px; color: #40544e; background: rgba(255,255,255,.92); border: 1px solid rgba(10,61,51,.12); border-radius: 9px; box-shadow: 0 6px 20px rgba(8,42,35,.1); font-size: .68rem; backdrop-filter: blur(8px); }
.legend span { width: 14px; height: 11px; background: rgba(11,95,78,.2); border: 2px solid var(--green); border-radius: 3px; }
.loading { position: absolute; z-index: 800; inset: 0; display: grid; place-content: center; gap: 12px; color: #38554d; background: #e8efeb; text-align: center; transition: opacity .35s, visibility .35s; }
.loading.hidden { opacity: 0; visibility: hidden; }
.loading div { width: 38px; height: 38px; margin: auto; border: 3px solid #bed1ca; border-top-color: var(--green); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.toast { position: absolute; z-index: 800; left: 50%; bottom: 26px; transform: translate(-50%, 20px); padding: 9px 13px; color: white; background: rgba(15,40,34,.92); border-radius: 8px; opacity: 0; pointer-events: none; transition: .25s; font-size: .72rem; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 820px) {
  .app-shell { display: block; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: min(88vw, 380px); transform: translateX(-105%); transition: transform .25s ease; }
  .sidebar.open { transform: translateX(0); }
  .sidebar.open::after { content: ""; position: fixed; inset: 0 0 0 100%; width: 100vw; background: rgba(3,26,21,.35); }
  .close-panel, .menu-button { display: grid; }
  .map-stage { height: 100%; }
  .location-pill { display: none; }
  .basemap-control { margin-left: auto; }
  .basemap-control > span { display: none; }
  .basemap-control select { max-width: 102px; }
  .map-button span { display: none; }
  .map-button { margin-left: 0; }
  .topbar { top: 12px; left: 12px; right: 12px; }
  .legend { left: 12px; bottom: 18px; }
}

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