:root {
  color-scheme: light;
  --ink: #14231f;
  --muted: #66746f;
  --paper: #f6f7f3;
  --panel: #ffffff;
  --line: #dfe5df;
  --accent: #16624d;
  --accent-soft: #dcece5;
  --filters-surface: color-mix(in srgb, var(--accent) 4%, var(--panel));
  --simulator-surface: color-mix(in srgb, var(--shp) 4%, var(--panel));
  --legend-surface: color-mix(in srgb, var(--im) 3%, var(--panel));
  --shadow: 0 18px 50px rgba(18, 43, 35, 0.12);
  --led: #65a30d;
  --shp: #e88b0c;
  --im: #0891b2;
  --tf: #7c3aed;
  --bf: #64748b;
  --hal: #dc2626;
  --other: #475569;
  --cabinet: #c24188;
}

* {
  box-sizing: border-box;
}

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

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

button,
select,
input {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(280px, 340px) 1fr;
  width: 100%;
  height: 100%;
}

.sidebar {
  position: relative;
  z-index: 500;
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 28px 26px 18px;
  overflow-y: auto;
  background: color-mix(in srgb, var(--panel) 96%, transparent);
  border-right: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.brand {
  display: flex;
  align-items: center;
  gap: 13px;
}

.brand-mark {
  display: grid;
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  place-items: center;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 14px;
}

.brand-mark svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.eyebrow,
.brand h1,
.summary,
.filters h2,
.simulator h2,
.legend h2,
footer {
  margin: 0;
}

.eyebrow {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.brand h1 {
  margin-top: 2px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.7rem;
  font-weight: 600;
  letter-spacing: -0.025em;
}

.summary {
  display: flex;
  align-items: baseline;
  gap: 9px;
  margin-top: 22px;
  padding: 16px;
  background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 12%, var(--line));
  border-radius: 14px;
}

.summary strong {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 2.25rem;
  font-weight: 600;
  letter-spacing: -0.04em;
}

.summary span {
  color: var(--muted);
  font-size: 0.85rem;
}

.summary small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.68rem;
}

.filters,
.simulator,
.legend {
  margin-top: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
}

.filters {
  background: var(--filters-surface);
}

.simulator {
  background: var(--simulator-surface);
}

.legend {
  background: var(--legend-surface);
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 17px;
}

.filters h2,
.simulator h2,
.legend h2 {
  font-size: 0.8rem;
  font-weight: 750;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

#active-filter-label {
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 700;
}

#simulation-scope {
  color: var(--accent);
  font-size: 0.68rem;
  font-weight: 700;
  text-align: right;
}

.filters label {
  display: block;
  margin: 13px 0 7px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 650;
}

.filter-field {
  min-width: 0;
}

.filters select {
  width: 100%;
  min-width: 0;
  min-height: 42px;
  padding: 0 34px 0 12px;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: none;
}

.filters select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.duration-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 650;
}

.duration-label output {
  color: var(--ink);
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
}

#lighting-duration {
  width: 100%;
  margin: 0;
  accent-color: var(--accent);
}

.price-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 650;
}

.price-input {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--ink);
  font-size: 0.72rem;
  font-weight: 650;
  white-space: nowrap;
}

#energy-price,
#low-consumption-power {
  width: 64px;
  min-height: 34px;
  padding: 0 6px;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
  font-variant-numeric: tabular-nums;
}

#energy-price:focus,
#low-consumption-power:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.low-consumption-control {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 12px;
}

.low-consumption-toggle,
.power-input {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 650;
}

.low-consumption-toggle {
  min-width: 0;
  cursor: pointer;
}

#low-consumption-mode {
  flex: 0 0 auto;
  margin: 0;
  accent-color: var(--accent);
}

.power-input {
  color: var(--ink);
  white-space: nowrap;
}

#low-consumption-power:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.energy-metrics {
  display: grid;
  grid-template-columns: 1fr;
  margin-top: 14px;
  border-top: 1px solid var(--line);
}

.energy-metrics div {
  display: grid;
  grid-template-columns: minmax(70px, 0.7fr) minmax(0, 1.3fr);
  gap: 2px 12px;
  align-items: baseline;
  min-width: 0;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}

.energy-metrics span,
.energy-metrics strong,
.energy-metrics small {
  display: block;
}

.energy-metrics span {
  color: var(--muted);
  font-size: 0.7rem;
}

.energy-metrics strong {
  min-width: 0;
  text-align: right;
  font-size: 0.86rem;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.energy-metrics small {
  grid-column: 2;
  color: var(--muted);
  font-size: 0.64rem;
  font-variant-numeric: tabular-nums;
  text-align: right;
  overflow-wrap: anywhere;
}

.simulation-note {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.67rem;
  line-height: 1.4;
}

.legend h2 {
  margin-bottom: 15px;
}

.legend-items {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  gap: 9px 13px;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 0.73rem;
}

.legend-info {
  appearance: none;
  padding: 0;
  font: inherit;
  background: transparent;
  border: 0;
  cursor: help;
}

.legend-tooltip {
  position: absolute;
  top: calc(100% + 9px);
  right: 0;
  left: 0;
  z-index: 20;
  padding: 10px 11px;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 10px 28px rgba(18, 43, 35, 0.16);
  font-size: 0.7rem;
  font-weight: 500;
  line-height: 1.4;
  text-align: left;
  white-space: pre-line;
  visibility: hidden;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 140ms ease, transform 140ms ease, visibility 140ms ease;
}

.legend-tooltip strong {
  display: block;
  margin-bottom: 5px;
  font-size: 0.74rem;
  font-weight: 750;
}

.legend-tooltip > span {
  display: block;
}

.legend-info:hover .legend-tooltip,
.legend-info:focus-visible .legend-tooltip,
.legend-info:focus .legend-tooltip {
  visibility: visible;
  opacity: 1;
  transform: translateY(0);
}

.legend-help {
  display: inline-grid;
  width: 14px;
  height: 14px;
  place-items: center;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 28%, var(--line));
  border-radius: 50%;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 0.64rem;
  font-weight: 700;
  line-height: 1;
}

.legend-dot,
.map-key-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  background: var(--dot-color, var(--other));
  border: 2px solid color-mix(in srgb, var(--panel) 75%, transparent);
  border-radius: 50%;
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--dot-color, var(--other)) 65%, transparent);
}

.legend-cabinet {
  display: inline-grid;
  width: 11px;
  height: 11px;
  place-items: center;
  color: #fff;
  background: var(--cabinet);
  border: 1px solid color-mix(in srgb, var(--cabinet) 75%, var(--ink));
  border-radius: 3px;
  font-size: 7px;
  font-weight: 800;
}

.detail-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 17px;
}

.detail-kicker {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.detail-head h2 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.35rem;
  font-weight: 600;
}

.source-badge {
  padding: 5px 8px;
  color: var(--ink);
  background: color-mix(in srgb, var(--badge-color) 16%, var(--panel));
  border: 1px solid color-mix(in srgb, var(--badge-color) 40%, var(--line));
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 750;
}

.cabinet-badge {
  --badge-color: var(--cabinet);
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 18px;
  margin: 0;
}

.detail-grid div {
  min-width: 0;
}

.detail-grid dt {
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.detail-grid dd {
  margin: 0;
  overflow-wrap: anywhere;
  font-size: 0.8rem;
  line-height: 1.35;
}

.poi-popup .leaflet-popup-content-wrapper {
  overflow: hidden;
  color: var(--ink);
  background: color-mix(in srgb, var(--panel) 97%, var(--accent-soft));
  border: 1px solid color-mix(in srgb, var(--accent) 12%, var(--line));
  border-radius: 16px;
  box-shadow: 0 16px 42px rgba(18, 43, 35, 0.2);
}

.poi-popup .leaflet-popup-content {
  max-height: min(520px, 64vh);
  margin: 0;
  padding: 18px;
  overflow-y: auto;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.poi-popup .leaflet-popup-tip {
  background: var(--panel);
  box-shadow: 2px 2px 4px rgba(18, 43, 35, 0.12);
}

.poi-popup .leaflet-popup-close-button {
  top: 8px;
  right: 8px;
  z-index: 2;
  width: 28px;
  height: 28px;
  color: var(--muted);
  font-size: 24px;
}

.poi-popup .detail-head {
  padding-right: 22px;
}

footer {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: auto;
  padding-top: 16px;
  color: var(--muted);
  font-size: 0.66rem;
}

.map-region,
#map {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 420px;
}

.map-region {
  min-width: 0;
  background: #dde4dd;
}

.map-key {
  position: absolute;
  z-index: 500;
  right: 16px;
  bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  color: var(--ink);
  background: color-mix(in srgb, var(--panel) 92%, transparent);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(18, 43, 35, 0.12);
  font-size: 0.72rem;
  backdrop-filter: blur(10px);
}

.map-key-dot {
  --dot-color: var(--accent);
}

.leaflet-container {
  font-family: inherit;
  background: #dce3dc;
}

.leaflet-control-zoom,
.leaflet-control-attribution {
  border: 0 !important;
  box-shadow: 0 8px 24px rgba(18, 43, 35, 0.14) !important;
}

.leaflet-control-zoom a {
  color: var(--ink) !important;
  background: var(--panel) !important;
}

.leaflet-tooltip.luminaire-tooltip {
  padding: 7px 9px;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(18, 43, 35, 0.13);
  font-size: 0.72rem;
}

.leaflet-tooltip.luminaire-tooltip::before {
  display: none;
}

.cabinet-marker-wrapper {
  background: transparent;
  border: 0;
}

.cabinet-marker {
  position: relative;
  display: grid;
  width: 25px;
  height: 25px;
  place-items: center;
  color: #fff;
  background: var(--cabinet);
  border: 2px solid #fff;
  border-radius: 7px;
  box-shadow: 0 3px 10px rgba(63, 24, 49, 0.32);
  font-size: 0.58rem;
  font-weight: 800;
  transition: transform 120ms ease, opacity 120ms ease;
}

.cabinet-marker::after {
  position: absolute;
  right: -3px;
  bottom: -3px;
  width: 6px;
  height: 6px;
  content: "";
  background: var(--panel);
  border: 2px solid var(--cabinet);
  border-radius: 50%;
}

.cabinet-marker.is-active {
  transform: scale(1.2);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--cabinet) 24%, transparent), 0 4px 14px rgba(63, 24, 49, 0.38);
}

.cabinet-marker.is-muted {
  opacity: 0.42;
}

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

  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(520px, 68vh);
    height: auto;
    min-height: 100%;
  }

  .sidebar {
    padding: 18px 18px 12px;
    overflow: visible;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .summary {
    margin-top: 16px;
    padding: 14px;
  }

  .summary strong {
    font-size: 1.8rem;
  }

  .filters {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 0 12px;
    padding: 14px;
  }

  .filter-field {
    min-width: 0;
  }

  .filter-field:last-child {
    grid-column: 1 / -1;
  }

  .section-heading {
    grid-column: 1 / -1;
    margin-bottom: 2px;
  }

  .legend {
    padding: 14px;
  }

  .simulator {
    padding: 14px;
  }

  footer {
    display: none;
  }

  .map-key {
    display: none;
  }
}

@media (max-width: 440px) {
  .filters {
    grid-template-columns: 1fr;
  }

  .section-heading {
    grid-column: auto;
  }

  .filter-field:last-child {
    grid-column: auto;
  }
}
