:root {
  color-scheme: light;
  --ink: #14211d;
  --muted: #65716d;
  --panel: rgba(250, 252, 248, 0.94);
  --panel-strong: #ffffff;
  --line: rgba(35, 52, 45, 0.16);
  --shadow: 0 18px 60px rgba(21, 35, 29, 0.18);
  --green: #2fb15d;
  --lime: #c9d84a;
  --amber: #f4b63f;
  --red: #d73535;
  --blue: #2c6f91;
}

* {
  box-sizing: border-box;
}

html,
body,
.app-shell,
.map-stage,
#map {
  width: 100%;
  height: 100%;
  margin: 0;
}

body {
  min-width: 320px;
  overflow: hidden;
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.map-stage {
  position: relative;
  background: #dde8e2;
}

.interface-stack {
  position: absolute;
  top: 18px;
  left: 18px;
  z-index: 510;
  display: grid;
  gap: 10px;
  width: min(520px, calc(100vw - 36px));
  pointer-events: none;
}

.interface-stack > * {
  pointer-events: auto;
}

.site-sign {
  width: min(430px, 100%);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 14px;
  background: rgba(20, 33, 29, 0.96);
  box-shadow: var(--shadow);
  color: #fff;
  backdrop-filter: blur(16px);
}

.site-sign__intro {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 16px;
}

.site-sign__mark {
  position: relative;
  display: grid;
  flex: 0 0 52px;
  width: 52px;
  height: 52px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 12px;
  background: linear-gradient(145deg, rgba(47, 177, 93, 0.9), rgba(44, 111, 145, 0.92));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.22);
}

.site-sign__mark svg {
  width: 27px;
  height: 27px;
  stroke-width: 2;
}

.site-sign__signal {
  position: absolute;
  top: 7px;
  right: 7px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--lime);
  box-shadow: 0 0 0 4px rgba(201, 216, 74, 0.18);
}

.site-sign__copy {
  min-width: 0;
}

.site-sign__eyebrow {
  margin: 0 0 4px;
  color: #a8d8b8;
  font-size: 0.69rem;
  font-weight: 780;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.site-sign h1 {
  margin: 0;
  font-size: clamp(1.35rem, 2.5vw, 1.65rem);
  line-height: 1.05;
  letter-spacing: -0.03em;
}

.site-sign__copy > p:last-child {
  margin: 7px 0 0;
  color: #d6dfdb;
  font-size: 0.82rem;
  line-height: 1.45;
}

.legal-notice {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 5px 12px;
  padding: 9px 16px 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.11);
  background: rgba(255, 255, 255, 0.035);
  color: #acbab4;
  font-size: 0.72rem;
  line-height: 1.3;
}

.legal-notice a {
  color: #d5e780;
  font-weight: 760;
}

.legal-notice a:focus-visible {
  border-radius: 3px;
  outline: 3px solid rgba(44, 111, 145, 0.18);
  outline-offset: 2px;
}

#map {
  z-index: 0;
}

.analysis-actions {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto;
  width: 100%;
  gap: 6px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  box-shadow: 0 10px 32px rgba(21, 35, 29, 0.16);
  backdrop-filter: blur(14px);
}

.control-panel {
  display: grid;
  width: min(376px, calc(100vw - 36px));
  max-height: calc(100dvh - 266px);
  overflow: auto;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.control-panel[hidden] {
  display: none;
}

.search-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px;
}

.panel-toolbar {
  display: flex;
  justify-content: flex-end;
}

.search-row input,
.language-select,
.field select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
  color: var(--ink);
  outline: none;
}

.search-row input {
  min-width: 0;
  padding: 0 14px;
}

.language-select,
.field select {
  padding: 0 12px;
}

.language-select {
  min-width: 94px;
  max-width: 160px;
}

.search-row input:focus,
.language-select:focus,
.field select:focus,
.icon-button:focus-visible {
  border-color: rgba(44, 111, 145, 0.64);
  box-shadow: 0 0 0 3px rgba(44, 111, 145, 0.18);
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 8px;
  color: #fff;
  background: var(--blue);
}

.icon-button:disabled {
  cursor: wait;
  opacity: 0.72;
}

.control-toggle.is-active {
  background: #1f566f;
}

.icon-button {
  width: 44px;
  height: 44px;
}

.action-button {
  width: auto;
  min-width: 44px;
  gap: 7px;
  padding: 0 14px;
  font-size: 0.82rem;
  font-weight: 760;
}

.analysis-actions .control-toggle {
  min-width: 116px;
}

.icon-button svg {
  width: 19px;
  height: 19px;
  stroke-width: 2.3;
}

.panel-section {
  display: grid;
  gap: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.panel-section:first-of-type {
  padding-top: 0;
  border-top: 0;
}

.metric-row,
.stats-grid {
  display: grid;
  gap: 10px;
  align-items: center;
}

.metric-row {
  grid-template-columns: 1fr auto;
}

.stats-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.stats-grid > div,
.metric-row > div:first-child {
  min-width: 0;
}

.eyebrow {
  display: block;
  margin-bottom: 2px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 760;
  letter-spacing: 0;
  text-transform: uppercase;
}

strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: 1.4rem;
  line-height: 1.1;
}

.status-pill {
  min-width: 84px;
  max-width: 150px;
  padding: 8px 10px;
  border: 1px solid rgba(44, 111, 145, 0.24);
  border-radius: 8px;
  background: rgba(44, 111, 145, 0.1);
  color: #24566d;
  font-size: 0.82rem;
  font-weight: 760;
  text-align: center;
}

.status-pill.is-warn {
  border-color: rgba(215, 53, 53, 0.26);
  background: rgba(215, 53, 53, 0.1);
  color: #a32929;
}

.settings-grid {
  grid-template-columns: 1fr 1fr;
}

.field,
.toggle-field {
  display: grid;
  gap: 8px;
  min-width: 0;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 700;
}

.field output {
  color: var(--ink);
  font-size: 0.9rem;
}

.field input[type="range"] {
  width: 100%;
  accent-color: var(--blue);
}

.field input[type="range"]:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.select-field,
.toggle-field {
  grid-column: span 2;
}

.toggle-field {
  grid-template-columns: 18px 1fr;
  align-items: center;
}

.toggle-field input {
  width: 18px;
  height: 18px;
  accent-color: var(--blue);
}

.model-note {
  grid-column: span 2;
  margin: 0;
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.4;
}

.legend {
  display: grid;
  gap: 7px;
}

.legend-bar {
  height: 12px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--green), var(--lime), var(--amber), var(--red));
}

.legend-labels {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 760;
}

.building-popup {
  min-width: 184px;
}

.building-popup strong {
  margin-bottom: 6px;
  font-size: 1rem;
}

.popup-grid {
  display: grid;
  grid-template-columns: auto auto;
  gap: 4px 12px;
  align-items: baseline;
}

.popup-grid span:nth-child(odd) {
  color: #63706b;
}

.leaflet-popup-content-wrapper,
.leaflet-popup-tip {
  color: var(--ink);
  border-radius: 8px;
}

.leaflet-control-attribution {
  font-size: 10px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 720px) {
  body {
    overflow: auto;
  }

  .map-stage {
    min-height: 100dvh;
  }

  .interface-stack {
    top: 12px;
    left: 12px;
    width: calc(100vw - 24px);
  }

  .site-sign {
    width: min(430px, 100%);
  }

  .analysis-actions {
    position: fixed;
    bottom: 12px;
    left: 12px;
    width: calc(100vw - 24px);
  }

  .control-panel {
    position: fixed;
    bottom: 72px;
    left: 12px;
    width: calc(100vw - 24px);
    max-height: min(calc(100dvh - 96px), 520px);
    overflow: auto;
    padding: 12px;
  }

  .settings-grid {
    grid-template-columns: 1fr;
  }

  .select-field,
  .toggle-field,
  .model-note {
    grid-column: span 1;
  }

  .stats-grid {
    grid-template-columns: repeat(3, minmax(70px, 1fr));
  }

  strong {
    font-size: 1.22rem;
  }

  .leaflet-bottom {
    bottom: 72px;
  }
}

@media (max-width: 480px) {
  .analysis-actions {
    grid-template-columns: minmax(0, 1fr) 44px;
  }

  .search-row {
    grid-template-columns: minmax(0, 1fr) 44px;
  }

  .action-button {
    width: 44px;
    padding: 0;
  }

  .analysis-actions .control-toggle {
    min-width: 44px;
  }

  .button-label {
    display: none;
  }

  .search-row input {
    padding: 0 10px;
  }

  .site-sign__intro {
    gap: 11px;
    padding: 13px;
  }

  .site-sign__mark {
    flex-basis: 44px;
    width: 44px;
    height: 44px;
  }

  .legal-notice {
    padding-right: 13px;
    padding-left: 13px;
  }
}
