:root {
  color-scheme: dark;
  --green: #041615;
  --cream: #f7f5f2;
  --gold: #d6c3a3;
  --muted: rgba(247, 245, 242, 0.62);
  --muted-soft: rgba(247, 245, 242, 0.42);
  --line: rgba(214, 195, 163, 0.2);
  --line-strong: rgba(214, 195, 163, 0.42);
  --surface: rgba(247, 245, 242, 0.035);
  --surface-strong: rgba(0, 0, 0, 0.18);
  --route: #d6c3a3;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--green);
  color: var(--cream);
  font-family: Inter, sans-serif;
}

button,
input {
  font: inherit;
}

.cv-dashboard {
  min-height: 100vh;
  padding: clamp(1.4rem, 3vw, 3rem) 2.4vw;
  background:
    radial-gradient(circle at 78% 8%, rgba(214, 195, 163, 0.11), transparent 34%),
    var(--green);
}

.cv-db-shell {
  max-width: 1560px;
  margin: 0 auto;
}

.cv-db-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 460px);
  gap: 2rem;
  align-items: end;
  margin-bottom: 1.35rem;
}

.cv-db-kicker {
  margin-bottom: 1rem;
  color: var(--gold);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.28em;
  text-transform: uppercase;
}

.cv-db-title {
  margin: 0;
  font-size: clamp(3rem, 7vw, 6.8rem);
  font-weight: 300;
  line-height: 0.9;
  letter-spacing: -0.065em;
}

.cv-db-title em {
  font-family: "Didot", "Bodoni Moda", serif;
  font-style: italic;
  font-weight: 500;
}

.cv-db-subtitle {
  margin: 0;
  color: var(--muted);
  font-size: clamp(0.95rem, 1.15vw, 1.08rem);
  font-weight: 300;
  line-height: 1.7;
}

.cv-map-section {
  display: grid;
  grid-template-columns: minmax(285px, 340px) minmax(0, 1fr);
  gap: 1rem;
  align-items: stretch;
  margin-bottom: 1rem;
}

.cv-control-card,
.cv-map-card,
.cv-db-section {
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--surface);
  box-shadow: 0 14px 38px rgba(0, 0, 0, 0.14), inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.cv-control-card {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1rem;
}

.cv-map-card {
  position: relative;
  min-height: min(820px, 78vh);
  overflow: hidden;
}

#map {
  width: 100%;
  height: 100%;
  min-height: min(820px, 78vh);
  background: #0c2321;
}

.cv-map-badge {
  position: absolute;
  right: 1rem;
  bottom: 1rem;
  z-index: 450;
  max-width: min(320px, calc(100% - 2rem));
  padding: 0.62rem 0.72rem;
  border: 1px solid rgba(247, 245, 242, 0.18);
  border-radius: 12px;
  background: rgba(4, 22, 21, 0.88);
  backdrop-filter: blur(14px);
  color: rgba(247, 245, 242, 0.76);
  font-size: 0.72rem;
}

.cv-scale-readout {
  position: absolute;
  left: 1rem;
  bottom: 2.75rem;
  z-index: 450;
  padding: 0.46rem 0.62rem;
  border: 1px solid rgba(247, 245, 242, 0.18);
  border-radius: 10px;
  background: rgba(4, 22, 21, 0.88);
  color: rgba(247, 245, 242, 0.76);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.cv-weather-overlay {
  position: fixed;
  top: 1rem;
  right: 2.4vw;
  bottom: 1rem;
  left: min(390px, calc(2.4vw + 356px));
  z-index: 470;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  overflow: hidden;
  border: 1px solid rgba(247, 245, 242, 0.18);
  border-radius: 18px;
  background: rgba(4, 22, 21, 0.92);
  box-shadow: 0 18px 52px rgba(0, 0, 0, 0.36);
}

.cv-weather-overlay[hidden] {
  display: none;
}

.cv-weather-head {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) 34px;
  gap: 0.75rem;
  align-items: center;
  padding: 0.75rem;
  border-bottom: 1px solid var(--line);
}

.cv-weather-head strong {
  color: var(--gold);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.cv-weather-tabs {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

.cv-weather-tabs button,
.cv-weather-close,
.cv-weather-tab {
  border: 1px solid rgba(214, 195, 163, 0.15);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.14);
  color: rgba(247, 245, 242, 0.76);
  cursor: pointer;
}

.cv-weather-tabs button {
  min-height: 34px;
  padding: 0 0.7rem;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.cv-weather-tabs button.is-active,
.cv-weather-tab.is-active {
  border-color: var(--line-strong);
  background: rgba(214, 195, 163, 0.14);
  color: var(--gold);
}

.cv-weather-close {
  width: 34px;
  height: 34px;
  color: var(--gold);
  font-size: 1.2rem;
}

.cv-weather-overlay iframe {
  width: 100%;
  height: 100%;
  border: 0;
  background: #0c2321;
}

.cv-weather-link {
  padding: 0.48rem 0.75rem;
  border-bottom: 1px solid rgba(214, 195, 163, 0.12);
  color: rgba(247, 245, 242, 0.52);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-align: right;
  text-decoration: none;
  text-transform: uppercase;
}

.cv-weather-link:hover {
  color: var(--gold);
}

.cv-db-section {
  margin-top: 1rem;
  padding: 1rem;
}

.cv-db-section-title {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  padding: 0.4rem 0.35rem 1rem;
}

.cv-db-section-title.compact {
  padding-bottom: 0.35rem;
}

.cv-db-section-title h2 {
  margin: 0;
  color: var(--gold);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.cv-db-section-title span {
  color: var(--muted-soft);
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.cv-search {
  display: grid;
  gap: 0.55rem;
}

.cv-search label,
.cv-layer-list h2,
.cv-mode-panel h2 {
  color: var(--muted-soft);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.cv-mode-panel {
  display: grid;
  gap: 0.65rem;
}

.cv-mode-panel h2 {
  margin: 0;
}

.cv-mode-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.55rem;
}

.cv-mode-button {
  display: flex;
  gap: 0.45rem;
  align-items: center;
  justify-content: center;
  min-width: 0;
  height: 42px;
  border: 1px solid rgba(214, 195, 163, 0.15);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.14);
  color: rgba(247, 245, 242, 0.76);
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 750;
  transition: transform 0.25s ease, border-color 0.25s ease, background 0.25s ease, color 0.25s ease;
}

.cv-mode-button:hover,
.cv-mode-button.is-active {
  transform: translateY(-2px);
  border-color: var(--line-strong);
  background: rgba(214, 195, 163, 0.14);
  color: var(--gold);
}

.cv-mode-icon {
  width: 22px;
  height: 22px;
  object-fit: contain;
  opacity: 0.92;
}

.cv-weather-tab {
  display: flex;
  gap: 0.55rem;
  align-items: center;
  justify-content: flex-start;
  min-height: 42px;
  padding: 0 0.75rem;
  color: var(--gold);
  font-weight: 750;
}

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

.cv-search input,
.cv-search button,
.cv-action-button {
  height: 44px;
  border: 1px solid rgba(214, 195, 163, 0.15);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.14);
  color: var(--cream);
}

.cv-search input {
  min-width: 0;
  padding: 0 0.8rem;
}

.cv-search input::placeholder {
  color: rgba(247, 245, 242, 0.38);
}

.cv-search button,
.cv-action-button {
  cursor: pointer;
  transition: transform 0.25s ease, border-color 0.25s ease, background 0.25s ease;
}

.cv-search button:hover,
.cv-action-button:hover {
  transform: translateY(-2px);
  border-color: var(--line-strong);
  background: rgba(247, 245, 242, 0.045);
}

.cv-actions {
  display: grid;
  gap: 0.65rem;
}

.cv-action-button {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  justify-content: flex-start;
  padding: 0 0.85rem;
  font-weight: 700;
}

.primary-action {
  border-color: rgba(214, 195, 163, 0.45);
  background: rgba(214, 195, 163, 0.16);
  color: var(--gold);
}

.cv-layer-list {
  display: grid;
  gap: 0.65rem;
  padding-top: 0.9rem;
  border-top: 1px solid var(--line);
}

.cv-layer-list h2 {
  margin: 0;
}

.cv-switch-row {
  display: flex;
  gap: 0.65rem;
  align-items: center;
  min-height: 30px;
  color: rgba(247, 245, 242, 0.76);
  font-size: 0.9rem;
}

.cv-switch-row input {
  width: 18px;
  height: 18px;
  accent-color: var(--gold);
}

.cv-metrics-card {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.7rem;
}

.cv-metric {
  min-height: 92px;
  border: 1px solid rgba(214, 195, 163, 0.12);
  border-radius: 16px;
  padding: 0.85rem;
  background: rgba(0, 0, 0, 0.12);
}

.cv-metric strong {
  display: block;
  color: var(--gold);
  font-size: clamp(1.45rem, 2vw, 2.2rem);
  font-weight: 650;
  line-height: 0.95;
  letter-spacing: -0.055em;
}

.cv-metric span {
  display: block;
  margin-top: 0.55rem;
  color: rgba(247, 245, 242, 0.46);
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.cv-status {
  margin: auto 0 0;
  color: rgba(247, 245, 242, 0.56);
  font-size: 0.78rem;
  font-weight: 300;
  line-height: 1.55;
}

.cv-route-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.75rem;
}

.cv-route-card {
  border: 1px solid rgba(214, 195, 163, 0.15);
  border-radius: 18px;
  background: rgba(0, 0, 0, 0.12);
  transition: transform 0.28s ease, border-color 0.28s ease, background 0.28s ease;
}

.cv-route-card {
  min-height: 190px;
  padding: 1rem;
  text-align: left;
  color: inherit;
  cursor: pointer;
}

.cv-route-card:hover,
.cv-route-card.is-active {
  transform: translateY(-4px);
  border-color: var(--line-strong);
  background: rgba(247, 245, 242, 0.045);
}

.cv-route-card.is-active {
  box-shadow: inset 0 0 0 1px rgba(214, 195, 163, 0.3);
}

.cv-route-card small {
  color: var(--gold);
  font-size: 0.58rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.cv-route-card h3 {
  margin: 0.8rem 0 0.85rem;
  font-family: "Didot", "Bodoni Moda", serif;
  font-size: 1.55rem;
  font-weight: 500;
  line-height: 1;
}

.cv-route-card p {
  margin: 0;
  color: rgba(247, 245, 242, 0.5);
  font-size: 0.76rem;
  line-height: 1.45;
}

.cv-route-data {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  margin-top: 1rem;
  border-top: 1px solid rgba(214, 195, 163, 0.13);
  padding-top: 0.65rem;
  color: rgba(247, 245, 242, 0.5);
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.cv-route-data strong {
  color: var(--gold);
  letter-spacing: 0;
  text-transform: none;
  white-space: nowrap;
}

.marker-popup {
  display: grid;
  gap: 0.5rem;
  min-width: 190px;
}

.marker-popup button {
  height: 34px;
  border: 0;
  border-radius: 10px;
  background: var(--green);
  color: var(--gold);
  cursor: pointer;
}

.leaflet-popup-content-wrapper,
.leaflet-popup-tip {
  background: rgba(4, 22, 21, 0.95);
  color: var(--cream);
}

.leaflet-popup-content-wrapper {
  border: 1px solid rgba(247, 245, 242, 0.18);
  border-radius: 14px;
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.28);
}

.leaflet-control-zoom a,
.leaflet-control-attribution {
  color: var(--green);
}

.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: 1080px) {
  .cv-db-head,
  .cv-map-section {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 760px) {
  .cv-dashboard {
    padding: 3.2rem 1rem;
  }

  .cv-db-title {
    font-size: clamp(3rem, 15vw, 5rem);
  }

  .cv-control-card,
  .cv-map-card,
  .cv-db-section {
    border-radius: 20px;
  }

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

  .cv-action-button {
    justify-content: center;
    gap: 0.35rem;
    padding: 0 0.5rem;
    font-size: 0.82rem;
  }

  .cv-map-card,
  #map {
    min-height: 62vh;
  }

  .cv-weather-overlay {
    inset: 1rem;
  }

  .cv-db-section-title {
    display: block;
  }

  .cv-db-section-title span {
    display: block;
    margin-top: 0.4rem;
  }

  .cv-route-grid {
    display: flex;
    gap: 0.75rem;
    overflow-x: auto;
    padding-bottom: 0.35rem;
    scroll-snap-type: x mandatory;
  }

  .cv-route-card {
    flex: 0 0 74%;
    scroll-snap-align: start;
  }
}

@media (max-width: 420px) {
  .cv-metrics-card {
    grid-template-columns: 1fr;
  }

  .cv-route-card {
    flex-basis: 84%;
  }
}
