:root {
  color-scheme: light;
  --ink: #17211c;
  --muted: #647069;
  --line: #d9dfdb;
  --paper: #f7f8f6;
  --panel: #ffffff;
  --forest: #0d5a3c;
  --forest-dark: #073d2a;
  --lime: #b8df55;
  --amber: #e9a42b;
  --danger: #a64032;
  --shadow: 0 18px 50px rgba(11, 37, 25, 0.13);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
}

* { box-sizing: border-box; }

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

body { color: var(--ink); background: var(--paper); font-size: 16px; }

button, input { font: inherit; }

button { cursor: pointer; }

.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;
}

.topbar {
  height: 68px;
  display: grid;
  grid-template-columns: auto auto minmax(240px, 480px) auto auto;
  align-items: center;
  gap: 28px;
  padding: 0 24px;
  background: var(--forest-dark);
  color: white;
  border-bottom: 3px solid var(--lime);
}

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: white;
  text-decoration: none;
  font-size: 1.55rem;
  line-height: 1;
  font-weight: 800;
  letter-spacing: -0.045em;
}

.wordmark-icon { width: 36px; height: 36px; flex: 0 0 36px; border-radius: 9px; }
.wordmark-text { color: white; }
.wordmark-text span { color: var(--lime); }

.mode-switch {
  display: flex;
  padding: 3px;
  border: 1px solid rgba(255,255,255,.24);
  border-radius: 9px;
  background: rgba(0,0,0,.16);
}

.mode-switch button {
  min-height: 34px;
  border: 0;
  border-radius: 6px;
  padding: 5px 11px;
  background: transparent;
  color: #dbe8e0;
  font-size: .82rem;
  font-weight: 800;
}

.mode-switch button.active { background: var(--lime); color: var(--forest-dark); }

.cadastre-search {
  width: min(100%, 520px);
  height: 42px;
  display: flex;
  background: white;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 1px 0 rgba(255,255,255,.15);
}

.cadastre-search input {
  min-width: 0;
  flex: 1;
  border: 0;
  padding: 0 14px;
  color: var(--ink);
  outline: 0;
}

.cadastre-search input:focus { box-shadow: inset 0 0 0 3px rgba(184, 223, 85, .55); }

.cadastre-search button {
  border: 0;
  padding: 0 18px;
  background: var(--lime);
  color: var(--forest-dark);
  font-weight: 800;
}

.account-link {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255,255,255,.28);
  border-radius: 8px;
  padding: 7px 11px;
  color: white;
  font-size: .78rem;
  font-weight: 850;
  text-decoration: none;
  white-space: nowrap;
}
.account-link:hover { border-color: var(--lime); color: var(--lime); }

.live-status {
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: .88rem;
  color: #dbe8e0;
  white-space: nowrap;
}

.live-status > span {
  width: 9px;
  height: 9px;
  flex: 0 0 9px;
  border-radius: 50%;
  background: var(--lime);
  box-shadow: 0 0 0 4px rgba(184, 223, 85, .17);
}
.live-status div { display: grid; gap: 1px; }
.live-status strong { color: white; font-size: .78rem; }
.live-status small { color: #b9d0c1; font-size: .67rem; }
.live-status.offline > span { background: #f1ad35; box-shadow: 0 0 0 4px rgba(241,173,53,.18); }
.live-status.offline small { color: #f6d9a8; }

.workspace {
  height: calc(100% - 68px);
  display: grid;
  grid-template-columns: minmax(0, 1fr) 410px;
}

.map-shell { position: relative; min-height: 420px; }

#map { position: absolute; inset: 0; background: #dbe4dd; }

.map-hint,
.locate-button,
.saved-button,
.saved-panel,
.work-panel,
.measure-tools,
.coordinates,
.basemap-switch,
.map-selection-mode,
.map-legend,
.map-layers,
.map-toast {
  position: absolute;
  z-index: 500;
  background: rgba(255,255,255,.96);
  box-shadow: var(--shadow);
}

.basemap-switch {
  right: 14px;
  bottom: 30px;
  display: flex;
  gap: 3px;
  padding: 4px;
  border: 1px solid rgba(7,61,42,.2);
  border-radius: 9px;
}

.basemap-switch button {
  min-height: 38px;
  border: 0;
  border-radius: 6px;
  padding: 7px 12px;
  background: transparent;
  color: var(--forest-dark);
  font-size: .8rem;
  font-weight: 800;
}

.basemap-switch button[data-basemap="satellite"] { display: inline-flex; align-items: center; gap: 7px; }
.basemap-label-short,
.saved-label-short { display: none; }
.basemap-loading { width: 12px; height: 12px; flex: 0 0 12px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: basemap-spin .7s linear infinite; }
.basemap-loading[hidden] { display: none; }

@keyframes basemap-spin { to { transform: rotate(360deg); } }

.basemap-switch button:hover { background: #eef2ef; }
.basemap-switch button.active { background: var(--forest); color: white; }

.map-selection-mode {
  top: 70px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 3px;
  padding: 4px;
  border: 1px solid rgba(7,61,42,.2);
  border-radius: 9px;
  white-space: nowrap;
}

.map-selection-mode button {
  min-height: 38px;
  display: flex;
  align-items: center;
  gap: 7px;
  border: 0;
  border-radius: 6px;
  padding: 7px 12px;
  background: transparent;
  color: var(--forest-dark);
  font-size: .8rem;
  font-weight: 800;
}

.map-selection-mode button:hover { background: #eef2ef; }
.map-selection-mode button.active { background: var(--forest); color: white; }
.map-selection-mode button[data-map-selection-mode="permits"].active { background: var(--danger); }
.map-selection-mode button span {
  min-width: 20px;
  min-height: 20px;
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  background: var(--danger);
  color: white;
  font-size: .7rem;
}
.map-selection-mode button.active span { background: white; color: var(--danger); }
.map-selection-mode button span[hidden] { display: none; }
.map-selection-mode button .permit-mode-count {
  min-height: 20px;
  padding: 3px 7px;
  border-radius: 999px;
  white-space: nowrap;
  line-height: 1.15;
}

.map-legend {
  top: 84px;
  left: 14px;
  width: min(280px, calc(100% - 28px));
  border: 1px solid rgba(7,61,42,.2);
  border-radius: 9px;
  overflow: hidden;
}

.map-layers {
  top: 136px;
  left: 14px;
  width: min(280px, calc(100% - 28px));
  border: 1px solid rgba(7,61,42,.2);
  border-radius: 9px;
  overflow: hidden;
}

.map-legend.is-open,
.map-layers.is-open { z-index: 620; }

.map-legend-toggle {
  width: 100%;
  min-height: 42px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 8px;
  border: 0;
  padding: 8px 11px;
  background: transparent;
  color: var(--forest-dark);
  font-size: .84rem;
  font-weight: 800;
  text-align: left;
}

.map-legend-toggle:hover { background: #eef2ef; }
.map-legend-toggle:focus-visible { outline: 3px solid rgba(184,223,85,.72); outline-offset: -3px; }
.map-legend-chevron { font-size: 1.15rem; line-height: 1; transition: transform .16s ease; }
.map-legend-toggle[aria-expanded="true"] .map-legend-chevron { transform: rotate(180deg); }

.map-layers-toggle {
  width: 100%;
  min-height: 42px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 8px;
  border: 0;
  padding: 8px 11px;
  background: transparent;
  color: var(--forest-dark);
  font-size: .84rem;
  font-weight: 800;
  text-align: left;
}

.map-layers-toggle:hover { background: #eef2ef; }
.map-layers-toggle:focus-visible { outline: 3px solid rgba(184,223,85,.72); outline-offset: -3px; }
.map-layers-chevron { font-size: 1.15rem; line-height: 1; transition: transform .16s ease; }
.map-layers-toggle[aria-expanded="true"] .map-layers-chevron { transform: rotate(180deg); }

.map-legend-panel {
  max-height: min(450px, calc(100vh - 220px));
  overflow-y: auto;
  padding: 12px 13px 13px;
  border-top: 1px solid var(--line);
  background: rgba(255,255,255,.98);
}

.map-legend-panel[hidden] { display: none; }
.map-legend-panel > strong { display: block; margin-bottom: 10px; font-size: .9rem; }
.map-legend-panel ul { display: grid; gap: 9px; margin: 0; padding: 0; list-style: none; }
.map-legend-panel li { display: grid; grid-template-columns: 28px 1fr; align-items: center; gap: 9px; color: #344239; font-size: .8rem; line-height: 1.25; }
.map-legend-panel small { display: block; margin-top: 11px; color: var(--muted); font-size: .7rem; line-height: 1.35; }

.map-layers-panel {
  max-height: min(510px, calc(100vh - 240px));
  overflow-y: auto;
  padding: 12px 13px 13px;
  border-top: 1px solid var(--line);
  background: rgba(255,255,255,.98);
}

.map-layers-panel[hidden] { display: none; }
.map-layers-panel > strong { display: block; margin: 13px 0 8px; font-size: .78rem; letter-spacing: .04em; text-transform: uppercase; }
.map-layers-panel > strong:first-child { margin-top: 0; }
.map-layers-panel label { display: grid; grid-template-columns: 18px 28px 1fr; align-items: center; gap: 8px; min-height: 36px; color: #344239; font-size: .79rem; line-height: 1.25; cursor: pointer; }
.map-layers-panel input { width: 17px; height: 17px; margin: 0; accent-color: var(--forest); }
.map-layers-panel small { display: block; margin-top: 11px; color: var(--muted); font-size: .7rem; line-height: 1.35; }
.map-layers-panel label span small { margin-top: 2px; font-size: .66rem; }
.map-layer-source-link {
  display: grid;
  grid-template-columns: 28px 1fr;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  margin-top: 4px;
  padding-left: 26px;
  color: var(--forest);
  font-size: .77rem;
  font-weight: 800;
  line-height: 1.25;
  text-decoration: none;
}
.map-layer-source-link:hover { text-decoration: underline; }
.layer-symbol.labels { width: 28px; color: #fff; font-size: .72rem; font-weight: 900; text-align: center; text-shadow: -1px -1px 1px #132019, 1px 1px 1px #132019, 0 0 3px #132019; }
.layer-symbol.external { width: 28px; color: #414b91; font-size: 1rem; font-weight: 900; text-align: center; }

.legend-swatch {
  width: 28px;
  height: 15px;
  display: block;
  border-radius: 3px;
  background: transparent;
}

.legend-swatch.selected-forest { border: 3px solid #084c31; background: rgba(66,184,115,.38); }
.legend-swatch.forest-boundary { border: 2px dashed #0d5a3c; }
.legend-swatch.parcel-boundary { border: 2px dashed #1d3429; background: rgba(207,225,213,.12); }
.legend-swatch.permit-area { border: 2px solid #a64032; background: rgba(216,104,86,.3); }
.legend-swatch.past-area { border: 2px solid #7253a6; background: rgba(157,130,200,.2); }
.legend-swatch.bast-area { border: 2px solid #2f6c9d; background: rgba(99,168,213,.2); }
.legend-swatch.eu-habitat-area { border: 2px solid #bd387d; background: rgba(221,91,157,.2); }
.legend-swatch.kmb-area { border: 2px solid #bf6b19; background: rgba(239,173,85,.22); }
.legend-swatch.forest-group-area { border: 2px dashed #185f76; background: rgba(76,164,189,.18); }
.legend-swatch.protected-area { border: 2px dashed #6c4b2a; background: rgba(194,154,104,.14); }
body[data-basemap="satellite"] .legend-swatch.selected-forest { border-color: #fff45c; background: rgba(147,216,94,.28); }
body[data-basemap="satellite"] .legend-swatch.forest-boundary { border-color: #d9ff68; }
body[data-basemap="satellite"] .legend-swatch.parcel-boundary { border-color: #fff; background: #71827a; box-shadow: 0 0 0 1px rgba(7,61,42,.42); }

.satellite-reference-label {
  background: transparent;
  border: 0;
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
  pointer-events: none;
  text-shadow: -1px -1px 1px #132019, 1px -1px 1px #132019, -1px 1px 1px #132019, 1px 1px 1px #132019, 0 0 3px #132019;
}

.satellite-reference-label span {
  position: absolute;
  transform: translate(-50%, -50%);
  width: max-content;
  max-width: 180px;
  text-align: center;
  white-space: normal;
}

.satellite-reference-label.place-name { font-size: 13px; }
.satellite-reference-label.road { color: #fff4b0; font-size: 10px; }
.satellite-reference-label.waterway { color: #b9ebff; font-size: 10px; font-style: italic; }

body:not([data-basemap="satellite"]) .satellite-reference-label { display: none; }

.forest-map-label {
  min-width: 54px;
  max-width: 128px;
  padding: 5px 7px;
  border: 1px solid rgba(7,61,42,.28);
  border-radius: 6px;
  background: rgba(255,255,255,.9);
  box-shadow: 0 1px 4px rgba(7,34,24,.2);
  color: var(--forest-dark);
  font-size: .68rem;
  line-height: 1.15;
  text-align: center;
  pointer-events: none;
}

.forest-map-label::before { display: none; }
.forest-map-label strong,
.forest-map-label span,
.forest-map-label small { display: block; }
.forest-map-label strong { font-size: .7rem; white-space: nowrap; }
.forest-map-label span { margin-top: 2px; font-weight: 800; }
.forest-map-label small { margin-top: 2px; color: var(--muted); font-size: .62rem; }
body[data-basemap="satellite"] .forest-map-label { border-color: rgba(255,244,92,.82); background: rgba(15,39,29,.82); color: #fff; text-shadow: 0 1px 2px #000; }
body[data-basemap="satellite"] .forest-map-label small { color: #edf7e9; }

.legend-dot {
  width: 14px;
  height: 14px;
  display: block;
  justify-self: center;
  border: 3px solid white;
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(7,61,42,.22);
}
.legend-dot.selected-point { background: #e9a42b; }
.legend-dot.gps-point { background: #1675a9; }

.map-toast {
  left: 50%;
  bottom: 86px;
  z-index: 650;
  transform: translateX(-50%);
  padding: 10px 14px;
  border-radius: 8px;
  background: var(--forest-dark);
  color: white;
  font-size: .86rem;
  font-weight: 800;
  white-space: nowrap;
  pointer-events: none;
  animation: toast-in .18s ease-out;
}

.map-toast[hidden] { display: none; }
.map-toast.error { background: var(--danger); }

@keyframes toast-in {
  from { opacity: .82; transform: translate(-50%, 5px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

.map-hint {
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 10px 15px;
  border-left: 4px solid var(--lime);
  border-radius: 7px;
  white-space: nowrap;
  pointer-events: none;
}

.map-hint strong { color: var(--forest-dark); }
.map-hint span { color: var(--muted); font-size: .9rem; }

.locate-button {
  left: 14px;
  bottom: 30px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 10px 13px;
  color: var(--forest-dark);
  font-weight: 750;
}

.locate-button:hover { border-color: var(--forest); }

.saved-button {
  top: 18px;
  right: 14px;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 8px 12px;
  color: var(--forest-dark);
  font-weight: 750;
}

.saved-button #saved-count {
  display: inline-grid;
  min-width: 22px;
  min-height: 22px;
  margin-left: 4px;
  place-items: center;
  border-radius: 50%;
  background: var(--forest);
  color: white;
  font-size: .74rem;
}

.saved-panel {
  top: 66px;
  right: 14px;
  width: min(340px, calc(100% - 28px));
  max-height: 55%;
  overflow: auto;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
}

.saved-panel h2 { margin: 2px 4px 10px; font-size: 1rem; }
.saved-empty { margin: 7px 4px; font-size: .84rem; }
.saved-item { display: grid; grid-template-columns: 1fr auto; gap: 7px; padding: 10px 4px; border-top: 1px solid var(--line); }
.saved-item button { border: 0; background: none; color: var(--forest); font-weight: 800; text-align: left; }
.saved-item .delete-saved { color: var(--danger); font-size: .78rem; }
.saved-item small { grid-column: 1 / -1; color: var(--muted); }
.saved-item .offline-age { color: #2d6547; font-weight: 700; }
.saved-item .offline-age.stale,
.saved-item .offline-age.unknown { color: var(--danger); }
.saved-item.integrity-failed { border-left: 3px solid var(--danger); padding-left: 9px; }
.saved-item.integrity-failed > button:first-child { color: var(--muted); cursor: not-allowed; }
.saved-item .offline-integrity-error { color: var(--danger); font-weight: 800; line-height: 1.35; }
.saved-item .offline-contents { color: #3e5849; line-height: 1.35; }
.offline-panel-status {
  display: grid;
  gap: 2px;
  margin: 0 0 10px;
  padding: 9px 10px;
  border-radius: 7px;
  background: #fff2d8;
  color: #654817;
  font-size: .78rem;
}
.offline-panel-status.online { background: #eaf5ed; color: var(--forest); }
.offline-panel-status span { font-size: .72rem; }
.device-data-actions {
  display: grid;
  gap: 5px;
  margin-top: 13px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}
.device-data-actions strong { color: var(--forest-dark); font-size: .82rem; }
.device-data-actions span { color: var(--muted); font-size: .73rem; line-height: 1.4; }
.clear-device-data {
  min-height: 42px;
  margin-top: 3px;
  border: 1px solid #d7aaa4;
  border-radius: 7px;
  background: #fff7f5;
  color: var(--danger);
  font-weight: 800;
}

.measure-tools {
  left: 14px;
  bottom: 82px;
  display: grid;
  gap: 6px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.measure-actions { display: flex; gap: 4px; }
.measure-actions button {
  min-height: 38px;
  border: 0;
  border-radius: 6px;
  padding: 7px 10px;
  background: #eef2ef;
  color: var(--forest-dark);
  font-size: .8rem;
  font-weight: 750;
}
.measure-actions button[aria-pressed="true"] { background: var(--forest); color: white; }
.measure-output {
  display: none;
  padding: 2px 5px;
  color: var(--forest-dark);
  font-size: .78rem;
  font-weight: 750;
}
.measure-output:not(:empty) { display: block; }

.coordinates {
  right: 12px;
  bottom: 82px;
  min-height: 28px;
  padding: 6px 10px;
  border-radius: 5px;
  color: var(--muted);
  font: 13px/1.2 ui-monospace, SFMono-Regular, Consolas, monospace;
}

.work-panel {
  top: 18px;
  left: 18px;
  width: min(380px, calc(100% - 36px));
  padding: 0;
  overflow: hidden;
  border: 1px solid rgba(7,61,42,.18);
  border-radius: 16px;
  background: rgba(255,255,255,.97);
  box-shadow: 0 14px 42px rgba(4,35,23,.18);
  backdrop-filter: blur(12px);
  transition: border-color .18s ease, box-shadow .18s ease, background-color .18s ease;
}
.work-panel[data-state="warning"] { border-color: #d99b22; box-shadow: 0 8px 28px rgba(124,82,0,.16); }
.work-panel[data-state="danger"] { border: 3px solid var(--danger); background: #fff8f6; box-shadow: 0 10px 34px rgba(166,64,50,.24); }

.work-panel-head { padding: 16px 18px 14px; border-bottom: 1px solid rgba(7,61,42,.11); background: linear-gradient(135deg, #f1f7f3, #fff); }
.work-panel[data-state="warning"] .work-panel-head { background: linear-gradient(135deg, #fff3d3, #fffaf0); }
.work-panel[data-state="danger"] .work-panel-head { background: linear-gradient(135deg, #fae2de, #fff5f2); }
.work-kicker { display: block; margin-bottom: 7px; color: var(--muted); font-size: .67rem; font-weight: 900; letter-spacing: .12em; text-transform: uppercase; }
.work-panel h2 { margin: 10px 0 0; color: var(--forest-dark); font-size: 1.1rem; line-height: 1.2; }
.work-panel-body { padding: 14px 18px 18px; }
.work-panel p { margin: 10px 0 0; font-size: .85rem; }
.work-state { display: inline-flex; align-items: center; gap: 7px; padding: 6px 10px; border-radius: 999px; font-size: .79rem; font-weight: 850; }
.work-state::before { content: ""; width: 9px; height: 9px; flex: 0 0 auto; border-radius: 50%; background: currentColor; box-shadow: 0 0 0 4px rgba(93,109,100,.12); }
.work-state.safe { background: #e8f5eb; color: var(--forest); }
.work-state.warning { background: #fff1c8; color: #694400; }
.work-state.danger { background: #fae2de; color: var(--danger); }
.work-state.uncertain { background: #eef0ef; color: var(--muted); }
.work-readings { display: grid; grid-template-columns: 1.2fr .8fr; gap: 8px; }
.work-reading { min-width: 0; padding: 11px 12px; border: 1px solid #e2e9e4; border-radius: 11px; background: #f2f6f3; }
.work-reading span { display: block; margin-bottom: 5px; color: var(--muted); font-size: .76rem; }
.work-reading strong { display: block; overflow-wrap: anywhere; color: var(--forest-dark); font-size: 1.38rem; line-height: 1.05; }
.work-reading.distance strong { font-size: 1.9rem; }
.work-reading strong[data-quality="excellent"] { color: var(--forest); }
.work-reading strong[data-quality="fair"] { color: #8a5b00; }
.work-reading strong[data-quality="poor"] { color: var(--danger); }
.work-position { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 10px; }
.work-position strong { color: var(--forest-dark); font-size: .84rem; }
.work-position span { color: var(--muted); font-size: .73rem; white-space: nowrap; }
.work-gps-message { color: #45564c; line-height: 1.4; }
.work-safety-note { padding: 9px 10px; border-radius: 8px; background: #f1f3f2; color: var(--muted); line-height: 1.35; }
.work-panel[data-state="danger"] .work-safety-note { background: #f9e4df; color: #6d241c; }
.work-actions .action.active { background: var(--danger); }
.work-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 13px; }
.work-actions .action { min-height: 50px; padding-inline: 10px; }

body[data-mode="work"] .workspace { grid-template-columns: 1fr; }
body[data-mode="work"] .results,
body[data-mode="work"] .map-hint,
body[data-mode="work"] .saved-button,
body[data-mode="work"] .saved-panel,
body[data-mode="work"] .measure-tools,
body[data-mode="work"] .coordinates,
body[data-mode="work"] .map-selection-mode,
body[data-mode="work"] .map-legend,
body[data-mode="work"] .map-layers { display: none !important; }
body[data-mode="work"] .work-panel:not([hidden]) { display: block; }
body[data-mode="work"] .leaflet-control-zoom { display: none; }

.disclaimer,
.navigation-dialog,
.device-clear-dialog {
  width: min(500px, calc(100% - 28px));
  border: 0;
  border-radius: 14px;
  padding: 0;
  box-shadow: 0 28px 80px rgba(2,20,12,.35);
}
.disclaimer::backdrop,
.navigation-dialog::backdrop,
.device-clear-dialog::backdrop { background: rgba(2,20,12,.68); }
.disclaimer form,
.navigation-dialog form,
.device-clear-dialog form { padding: 26px; }
.dialog-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 20px; }
.navigation-dialog h2,
.device-clear-dialog h2 { margin: 8px 0 16px; color: var(--forest-dark); }
.action.danger { border-color: var(--danger); background: var(--danger); color: white; }
.device-clear-warning { margin: 14px 0 0; padding: 11px 12px; border-left: 4px solid var(--amber); border-radius: 7px; background: #fff7df; color: #5f480f; font-size: .84rem; line-height: 1.45; }
.device-clear-error { margin: 12px 0 0; color: var(--danger); font-size: .84rem; font-weight: 750; }
.navigation-coordinate { padding: 13px 14px; border: 1px solid var(--line); border-radius: 10px; background: #f5f8f6; }
.navigation-coordinate span { display: block; margin-bottom: 4px; color: var(--muted); font-size: .76rem; }
.navigation-coordinate strong { color: var(--forest-dark); font: 700 1rem/1.25 ui-monospace, SFMono-Regular, Consolas, monospace; }
.navigation-warning { margin: 14px 0; padding: 11px 12px; border-left: 4px solid #d99b22; border-radius: 7px; background: #fff7df; color: #5f480f; font-size: .84rem; line-height: 1.45; }
.navigation-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.navigation-actions button { min-height: 48px; }
.dialog-close { width: 100%; margin-top: 12px; padding: 10px; border: 0; background: transparent; color: var(--muted); font-weight: 800; cursor: pointer; }

.results {
  overflow-y: auto;
  background: var(--panel);
  border-left: 1px solid var(--line);
}

.mobile-status-strip { display: none; }

.empty-state,
.loading-state,
.error-state,
.candidate-state { padding: 42px 32px; }

.eyebrow {
  margin-bottom: 10px;
  color: var(--forest);
  font-size: .78rem;
  font-weight: 850;
  letter-spacing: .12em;
  text-transform: uppercase;
}

h1, h2, h3, p { margin-top: 0; }
h1 { font-size: clamp(1.7rem, 2.5vw, 2.15rem); line-height: 1.08; letter-spacing: -.035em; }
h2 { font-size: 1.35rem; line-height: 1.2; letter-spacing: -.02em; }
h3 { font-size: 1rem; }
p { color: var(--muted); line-height: 1.55; }

.empty-steps { display: grid; gap: 10px; margin-top: 28px; }
.empty-steps span { display: flex; align-items: center; gap: 10px; color: #344239; }
.empty-steps b {
  width: 28px;
  height: 28px;
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  background: #eef4e5;
  color: var(--forest);
}

.loading-state { text-align: center; }
.spinner {
  width: 34px;
  height: 34px;
  margin: 4px auto 20px;
  border: 4px solid #e4ebe6;
  border-top-color: var(--forest);
  border-radius: 50%;
  animation: spin .85s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.skeleton {
  height: 78px;
  margin: 12px 0;
  border-radius: 8px;
  background: linear-gradient(90deg, #edf0ee 20%, #f7f8f7 50%, #edf0ee 80%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
}
.skeleton.short { height: 46px; }
@keyframes shimmer { to { background-position: -200% 0; } }

.result-head {
  padding: 24px 24px 20px;
  color: white;
  background: var(--forest-dark);
}

.result-head .eyebrow { color: var(--lime); }
.result-head h1 { margin-bottom: 8px; font-size: 1.65rem; }
.result-head p { margin: 0; color: #cfe0d6; }
.result-head.permit-result-head { background: linear-gradient(135deg, #762c23, #9d3d31); }
.result-head.permit-result-head .eyebrow { color: #ffd1ca; }
.result-head.permit-result-head p { color: #f4d9d5; }

.result-body { padding: 20px 24px 34px; background: #f5f7f5; }
.offline-banner {
  display: grid;
  gap: 4px;
  margin-bottom: 16px;
  padding: 13px 14px;
  border: 1px solid #e0af50;
  border-radius: 8px;
  background: #fff4dc;
  color: #654817;
  font-size: .84rem;
  line-height: 1.42;
}
.offline-banner strong { font-size: .9rem; }
.offline-banner.stale,
.offline-banner.unknown {
  border-color: #d7877c;
  background: #fff0ed;
  color: #7a3028;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}

.result-tabs {
  position: sticky;
  top: 0;
  z-index: 15;
  display: grid;
  grid-template-columns: repeat(4, max-content);
  gap: 4px;
  overflow-x: auto;
  margin: -6px -8px 16px;
  padding: 6px 8px;
  border: 1px solid #dfe7e1;
  border-radius: 11px;
  background: rgba(255,255,255,.96);
  box-shadow: 0 5px 18px rgba(7,45,30,.08);
  scrollbar-width: none;
}
.result-tabs::-webkit-scrollbar { display: none; }
.result-tabs a {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  padding: 8px 10px;
  color: #506057;
  font-size: .76rem;
  font-weight: 800;
  text-decoration: none;
  white-space: nowrap;
}
.result-tabs a[aria-current="location"] { background: var(--forest); color: white; }
.result-tabs a:hover { background: #eaf3ed; color: var(--forest-dark); }
.result-tabs a[aria-current="location"]:hover { background: var(--forest-dark); color: white; }
.result-tabs a:focus-visible { outline: 3px solid rgba(184,223,85,.62); outline-offset: 1px; }

#result-summary,
.result-section-group { scroll-margin-top: 72px; }
.result-section-group { display: grid; gap: 12px; margin: 0 0 12px; }
.result-section-group > .section {
  padding: 16px;
  border: 1px solid #dfe5e1;
  border-radius: 12px;
  background: white;
  box-shadow: 0 5px 18px rgba(7,45,30,.045);
}

.metric {
  min-width: 0;
  padding: 12px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
}

.metric span { display: block; color: var(--muted); font-size: .75rem; }
.metric strong { display: block; margin-top: 5px; font-size: 1rem; overflow-wrap: anywhere; }

.notice {
  margin: 14px 0;
  padding: 12px 14px;
  border-left: 4px solid var(--amber);
  border-radius: 5px;
  background: #fff7e7;
  color: #654817;
  font-size: .9rem;
  line-height: 1.45;
}
.forest-list { display: grid; gap: 12px; }
.forest-list .forest-main { margin: 0; }

.section { padding: 17px 0; border-top: 1px solid var(--line); }
.section h2 { margin-bottom: 12px; font-size: 1.05rem; }

.fact-list { display: grid; gap: 9px; }
.fact {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  color: var(--muted);
  font-size: .9rem;
}
.fact strong { color: var(--ink); text-align: right; }

.stand {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 12px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px dashed var(--line);
  font-size: .88rem;
}
.stand:last-child { border-bottom: 0; }
.stand small { color: var(--muted); }

.forest-main {
  padding: 15px;
  border: 1px solid #b7d2c2;
  border-radius: 10px;
  background: #f1f8f3;
}
.forest-main h3 { margin-bottom: 4px; font-size: 1.18rem; color: var(--forest-dark); }
.forest-main > p { margin-bottom: 13px; }
.forest-facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.forest-fact { padding: 9px; border-radius: 7px; background: white; }
.forest-fact span { display: block; color: var(--muted); font-size: .72rem; }
.forest-fact strong { display: block; margin-top: 4px; }

.volume-estimate {
  overflow: hidden;
  border: 1px solid #b8d5c4;
  border-radius: 9px;
  background: #f7fbf8;
}
.volume-main,
.volume-range { display: grid; gap: 4px; padding: 15px 16px; }
.volume-main { background: var(--forest-dark); color: white; }
.volume-main span,
.volume-range span { font-size: .76rem; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; }
.volume-main strong { font-size: 2rem; line-height: 1.05; }
.volume-main small { color: #d7eee2; }
.volume-range { border-bottom: 1px solid var(--line); }
.volume-range strong { color: var(--forest-dark); font-size: 1.35rem; }
.volume-range small { color: var(--muted); }
.volume-warning { margin: 14px 16px 0; padding: 11px 12px; border-left: 4px solid var(--orange); background: #fff5e4; color: #60430e; font-size: .84rem; line-height: 1.45; }
.volume-estimate .technical-details { margin: 12px 16px 16px; }
.volume-estimate .technical-details p { color: var(--muted); font-size: .82rem; line-height: 1.55; }
.volume-estimate .technical-details a { color: var(--forest); font-size: .82rem; font-weight: 800; }
.volume-missing { margin-bottom: 0; }
.technical-details { margin-top: 12px; border-top: 1px solid #cadbd1; padding-top: 10px; }
.technical-details summary { cursor: pointer; color: var(--forest); font-weight: 800; }
.technical-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px 12px; margin-top: 10px; font-size: .8rem; }
.technical-grid span { color: var(--muted); }

.permit-card { margin: 8px 0; padding: 11px 12px; border: 1px solid var(--line); border-radius: 8px; background: #fafcfb; }
.permit-card strong { display: block; }
.permit-card small { color: var(--muted); }
.permit-card.possible { border-color: #e4bd6f; background: #fff8e9; }
.permit-choice-list { display: grid; gap: 10px; }
.permit-choice {
  width: 100%;
  min-height: 62px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border: 1px solid #d9a49c;
  border-radius: 9px;
  padding: 12px 13px;
  background: #fff8f6;
  color: var(--ink);
  text-align: left;
}
.permit-choice:hover { border-color: var(--danger); background: #fff0ed; }
.permit-choice:focus-visible { outline: 3px solid rgba(166,64,50,.28); outline-offset: 2px; }
.permit-choice strong { display: block; color: #762c23; }
.permit-choice small { display: block; margin-top: 4px; color: var(--muted); line-height: 1.4; }
.permit-choice-action { flex: 0 0 auto; color: var(--danger); font-size: .8rem; font-weight: 850; }

.permit-summary-state {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 15px;
  color: var(--muted);
  font-size: .84rem;
}
.permit-summary-state .chip { flex: 0 0 auto; }
.section-intro { margin-bottom: 12px; font-size: .84rem; }
.source-link { display: inline-block; margin-top: 13px; color: var(--forest); font-size: .82rem; font-weight: 800; }
.permit-stand-list { display: grid; gap: 9px; }
.permit-stand {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid #cbd8d0;
  border-radius: 8px;
  background: #f8fbf9;
}
.permit-stand-title { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.permit-stand-title strong { color: var(--forest-dark); }
.permit-stand-title small { color: var(--muted); text-align: right; }
.permit-stand-facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; }
.permit-stand-facts span { min-width: 0; padding: 8px; border-radius: 6px; background: white; }
.permit-stand-facts small { display: block; color: var(--muted); font-size: .68rem; }
.permit-stand-facts strong { display: block; margin-top: 3px; font-size: .84rem; overflow-wrap: anywhere; }
.permit-official-volume {
  display: grid;
  gap: 5px;
  margin-bottom: 16px;
  padding: 15px 16px;
  border: 1px solid #dba59d;
  border-radius: 9px;
  background: #fff5f3;
}
.permit-official-volume span { color: #762c23; font-size: .76rem; font-weight: 850; letter-spacing: .04em; text-transform: uppercase; }
.permit-official-volume strong { color: #762c23; font-size: 2rem; line-height: 1.05; }
.permit-official-volume small { color: var(--muted); }
.permit-estimate-heading { margin: 18px 0 9px; }
.permit-constraint-warning { border-left-color: var(--danger); background: #fff0ed; color: #6f2b23; }
.permit-constraint-clear { border-left-color: var(--forest); background: #eef7f1; color: var(--forest-dark); }

.source-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 7px 0;
  font-size: .84rem;
}
.source-label { display: grid; gap: 2px; }
.source-label small { color: var(--muted); font-size: .72rem; }
.source-item + .source-item { border-top: 1px dashed #e1e6e3; }
.source-explanation { margin: -1px 0 8px; color: var(--muted); font-size: .75rem; line-height: 1.45; }
.source-explanation summary { width: max-content; cursor: pointer; color: var(--forest); font-weight: 800; }
.source-explanation p { margin: 7px 0 4px; }
.source-explanation a { color: var(--forest); font-weight: 800; }

.forest-group-list { display: grid; gap: 8px; margin-top: 9px; }
.forest-group-card {
  display: grid;
  gap: 4px;
  padding: 12px 13px;
  border: 1px solid #9ac1ce;
  border-left: 5px solid #185f76;
  border-radius: 8px;
  background: #f0f8fa;
}
.forest-group-card strong { color: #124c5e; }
.forest-group-card span { font-size: .85rem; }
.forest-group-card small { color: var(--muted); font-size: .72rem; line-height: 1.35; }

.project-list { display: grid; gap: 8px; margin: 5px 0 12px; }
.project-card {
  display: grid;
  gap: 5px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7faf7;
  font-size: .82rem;
}
.project-card div { display: flex; justify-content: space-between; gap: 12px; }
.project-card span, .project-card p { color: var(--muted); }
.project-card a { color: var(--forest); font-weight: 750; }

.candidate-list { display: grid; gap: 10px; margin: 22px 0; }
.candidate {
  display: grid;
  gap: 5px;
  width: 100%;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
  text-align: left;
}
.candidate:hover, .candidate:focus-visible { border-color: var(--forest); outline: 2px solid rgba(13, 90, 60, .15); }
.candidate span { color: var(--muted); font-size: .84rem; }

.chip {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  background: #edf5ef;
  color: var(--forest);
  font-size: .75rem;
  font-weight: 750;
}
.chip.bad { background: #faebe8; color: var(--danger); }
.chip.muted { background: #eef0ef; color: var(--muted); }
.chip.view { background: #edf0fb; color: #414b91; }

.action-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 18px; }
.action {
  min-height: 44px;
  border: 1px solid var(--forest);
  border-radius: 7px;
  padding: 9px 12px;
  background: var(--forest);
  color: white;
  font-weight: 750;
}
.action.secondary { background: white; color: var(--forest); }
.action.tertiary { grid-column: 1 / -1; border-color: var(--line); background: #eef2ef; color: var(--forest-dark); }
.action:disabled { cursor: not-allowed; border-color: #bcc8c0; background: #e8ece9; color: #69756d; opacity: .85; }
#save-action { grid-column: 1 / -1; }

.legal-note { margin-top: 16px; color: var(--muted); font-size: .76rem; line-height: 1.45; }
.error-state h2 { color: var(--danger); }

.leaflet-control-zoom a { color: var(--forest-dark) !important; }

@media (max-width: 820px) {
  .topbar {
    height: auto;
    min-height: 66px;
    grid-template-columns: auto 1fr auto;
    gap: 10px;
    padding: max(10px, env(safe-area-inset-top)) 12px 10px;
  }
  .wordmark { gap: 7px; font-size: 1.42rem; }
  .wordmark-icon { width: 32px; height: 32px; flex-basis: 32px; border-radius: 8px; }
  .mode-switch { justify-self: end; }
  .mode-switch button { min-height: 44px; }
  .account-link { justify-self: end; }
  .cadastre-search { grid-column: 1 / -1; grid-row: 2; height: 48px; }
  .cadastre-search button { min-width: 86px; }
  .live-status { display: none; }
  .workspace { height: calc(100% - 112px); grid-template-columns: 1fr; grid-template-rows: 55vh auto; overflow-y: auto; }
  .map-shell { min-height: 55vh; }
  .results {
    position: relative;
    z-index: 700;
    overflow: visible;
    margin-top: -16px;
    border: 0;
    border-radius: 20px 20px 0 0;
    box-shadow: 0 -10px 30px rgba(7, 45, 30, .12);
  }
  .results::before {
    content: "";
    display: block;
    width: 38px;
    height: 4px;
    margin: 10px auto 0;
    border-radius: 999px;
    background: #c9d2cc;
  }
  .mobile-status-strip {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    gap: 7px;
    overflow-x: auto;
    padding: 9px 12px 10px;
    border-bottom: 1px solid #e3e8e4;
    background: rgba(255,255,255,.96);
    scrollbar-width: none;
  }
  .mobile-status-strip::-webkit-scrollbar { display: none; }
  .mobile-status-chip {
    min-height: 34px;
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 1px solid #dfe7e1;
    border-radius: 999px;
    padding: 6px 10px;
    background: #f3f7f4;
    color: var(--forest-dark);
    font-size: .73rem;
    white-space: nowrap;
  }
  .mobile-status-icon {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--lime);
    box-shadow: 0 0 0 3px rgba(184,223,85,.18);
  }
  .mobile-status-chip.connection[data-state="offline"] { border-color: #edcf98; background: #fff5df; color: #6d4a0d; }
  .mobile-status-chip.connection[data-state="offline"] .mobile-status-icon { background: var(--amber); box-shadow: 0 0 0 3px rgba(233,164,43,.16); }
  .mobile-status-chip.gps[data-state="active"] { border-color: #b7d8c3; background: #edf8f0; color: var(--forest); }
  .mobile-status-chip.gps[data-state="searching"] { border-color: #ead29f; background: #fff8e8; color: #6d4a0d; }
  .result-tabs { top: 54px; }
  #result-summary,
  .result-section-group { scroll-margin-top: 118px; }
  .map-hint {
    top: 12px;
    left: 54px;
    min-height: 44px;
    max-width: 150px;
    transform: none;
    align-items: center;
    padding: 8px 11px;
    white-space: normal;
  }
  .map-hint span { display: none; }
  .saved-button { top: 12px; right: 12px; min-height: 44px; }
  .saved-button .saved-label-full { display: none; }
  .saved-button .saved-label-short { display: inline; font-size: .8rem; }
  .coordinates { display: none; }
  .map-selection-mode { top: 64px; }
  .map-selection-mode button { min-height: 44px; }
  .map-legend,
  .map-layers { top: 116px; width: calc(50% - 18px); }
  .map-legend { left: 12px; }
  .map-layers { right: 12px; left: auto; }
  .map-legend.is-open,
  .map-layers.is-open { right: 12px; left: 12px; width: calc(100% - 24px); }
  .map-legend-toggle,
  .map-layers-toggle { min-height: 46px; }
  .map-legend-panel { max-height: 34vh; }
  .map-layers-panel { max-height: 42vh; }
  .measure-tools { left: 12px; bottom: 84px; }
  .measure-actions button { min-height: 44px; }
  .locate-button { left: 12px; bottom: 28px; min-height: 46px; }
  .basemap-switch { right: 12px; bottom: 28px; }
  .basemap-switch button { min-height: 42px; }
  .basemap-label-full { display: none; }
  .basemap-label-short { display: inline; }
  .map-toast { bottom: 84px; max-width: calc(100% - 28px); white-space: normal; text-align: center; }
  body[data-mode="work"] .workspace { height: calc(100% - 66px); grid-template-rows: 1fr; overflow: hidden; }
  body[data-mode="work"] .topbar { min-height: 66px; }
  body[data-mode="work"] .cadastre-search { display: none; }
  body[data-mode="work"] .map-shell { min-height: 100%; }
  body[data-mode="work"] .locate-button { display: none; }
  .work-panel { top: 12px; left: 12px; width: calc(100% - 24px); max-height: calc(100% - 98px); overflow-y: auto; }
  .navigation-actions { grid-template-columns: 1fr; }
}

@media (max-width: 440px) {
  .account-link { width: 40px; min-width: 40px; padding-inline: 0; font-size: 0; }
  .account-link::before { content: "Aš"; font-size: .78rem; }
  .basemap-switch button { padding-inline: 10px; font-size: .76rem; }
  .map-selection-mode button { padding-inline: 9px; font-size: .76rem; }
  .empty-state,
  .loading-state,
  .error-state,
  .candidate-state { padding-top: 24px; padding-bottom: 30px; }
  .empty-state h1 { font-size: 1.72rem; }
  .result-tabs { margin-inline: -6px; padding-inline: 6px; }
  .result-tabs a { min-height: 40px; padding-inline: 8px; font-size: .72rem; }
  .result-section-group > .section { padding: 14px; }
  .work-panel-head { padding: 14px 16px 12px; }
  .work-panel-body { padding: 12px 16px 16px; }
  .work-actions .action { font-size: .82rem; }
  .metrics { grid-template-columns: 1fr 1fr; }
  .metric:last-child { grid-column: 1 / -1; }
  .result-body, .result-head, .empty-state, .loading-state, .error-state, .candidate-state { padding-left: 18px; padding-right: 18px; }
  .forest-facts { grid-template-columns: 1fr 1fr; }
  .forest-fact:last-child { grid-column: 1 / -1; }
  .permit-stand-facts { grid-template-columns: 1fr 1fr; }
  .permit-stand-facts span:first-child { grid-column: 1 / -1; }
}

@media (max-width: 370px) {
  .topbar { gap: 6px; padding-inline: 8px; }
  .wordmark { font-size: 1.22rem; }
  .wordmark-icon { width: 28px; height: 28px; flex-basis: 28px; border-radius: 7px; }
  .mode-switch button { padding-inline: 7px; font-size: .75rem; }
  .map-hint { left: 50px; max-width: 132px; }
  .map-hint strong { font-size: .86rem; }
  .saved-button { padding-inline: 9px; }
  .locate-button { padding-inline: 10px; }
  .basemap-switch button { padding-inline: 7px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
