:root {
  color-scheme: light dark;
  --bg: #010409;
  --panel-bg: rgba(1, 4, 9, 0.92);
  --accent: #2f81f7;
  --accent-soft: rgba(47, 129, 247, 0.15);
  --text: #f0f6fc;
  --muted: #8b949e;
  --border: rgba(240, 246, 252, 0.08);
  --ok: #3fb950;
  --missing: #d29922;
  --issue: #f85149;
  --font-sans: "Inter", "Segoe UI", Roboto, sans-serif;
  background-color: var(--bg);
  color: var(--text);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-sans);
  background: radial-gradient(circle at top left, rgba(47, 129, 247, 0.18), transparent 60%),
    radial-gradient(circle at bottom right, rgba(120, 82, 255, 0.15), transparent 55%),
    var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
}

a {
  color: inherit;
  text-decoration: none;
}

a:hover,
button:hover,
select:hover,
input:hover {
  opacity: 0.85;
}

.page-header,
.page-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 2.5rem;
  gap: 1.5rem;
}

.page-header {
  backdrop-filter: blur(14px);
  background: linear-gradient(135deg, rgba(1, 4, 9, 0.92), rgba(13, 17, 23, 0.92));
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 18px 40px -32px rgba(0, 0, 0, 0.65);
}

.branding {
  display: flex;
  align-items: center;
  gap: 1.75rem;
}

.branding__identity h1 {
  margin: 0;
  font-size: 1.8rem;
  letter-spacing: 0.04em;
}

.branding__identity .tagline {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.branding__logos {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.branding__logos img {
  height: 52px;
  width: auto;
  filter: drop-shadow(0 6px 12px rgba(0, 0, 0, 0.4));
  border-radius: 0.6rem;
  background: rgba(255, 255, 255, 0.05);
  padding: 0.35rem 0.55rem;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

.filter-item {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.filter-item select,
.filter-item input {
  background: rgba(22, 27, 34, 0.92);
  border: 1px solid rgba(110, 118, 129, 0.4);
  border-radius: 0.6rem;
  color: var(--text);
  padding: 0.45rem 0.75rem;
  min-width: 10ch;
}

select option {
  background-color: rgba(13, 17, 23, 0.95);
  color: var(--text);
}

.layout {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr);
  grid-auto-rows: minmax(0, 1fr);
  gap: 1.5rem;
  padding: 1.5rem 2.5rem 2rem;
}

.panel {
  background: var(--panel-bg);
  border: 1px solid rgba(110, 118, 129, 0.4);
  border-radius: 1rem;
  display: flex;
  flex-direction: column;
  min-height: 0;
  box-shadow: 0 25px 60px -35px rgba(0, 0, 0, 0.65);
}

.panel__header {
  padding: 1.2rem 1.4rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  background: rgba(255, 255, 255, 0.08);
}

.badge span {
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
}

.badge.status-1 span { background: var(--ok); }
.badge.status-2 span { background: var(--missing); }
.badge.status-3 span { background: var(--issue); }

.map-panel {
  position: relative;
  grid-column: 1;
  grid-row: 1;
}

.detail-panel {
  grid-column: 2;
  grid-row: 1;
  overflow: hidden;
}

.map-placeholder {
  flex: 1;
  background: rgba(6, 8, 10, 0.75);
  border-bottom: 1px solid var(--border);
  border-top: 1px solid rgba(255, 255, 255, 0.04);
  min-height: 360px;
  border-radius: 0;
  position: relative;
  z-index: 0;
}

#map,
.leaflet-container {
  width: 100%;
  height: 100%;
  min-height: 360px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  border-top: 1px solid rgba(255, 255, 255, 0.04);
  border-radius: 0;
  position: relative;
  z-index: 0;
}

.leaflet-control-container .leaflet-top.leaflet-left,
.leaflet-control-container .leaflet-top.leaflet-right {
  margin-top: 120px;
  z-index: 1200;
}

.leaflet-control-container .leaflet-top.leaflet-left {
  margin-left: 14px;
}

.leaflet-control-container .leaflet-top.leaflet-right {
  margin-right: 14px;
}

.legend {
  border-top: 1px solid rgba(110, 118, 129, 0.4);
  padding: 0.75rem 1.4rem 1.1rem;
}


.map-summary {
  display: none;
}

.preload-status {
  min-width: 140px;
  font-size: 0.8rem;
  color: var(--muted);
}

.legend__gradient {
  margin-top: 0.65rem;
  height: 0.85rem;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--issue) 0%, var(--missing) 50%, var(--ok) 100%);
  box-shadow: inset 0 0 0 1px rgba(240, 246, 252, 0.08);
}

.legend__labels {
  display: flex;
  justify-content: space-between;
  margin-top: 0.45rem;
  font-size: 0.75rem;
  color: var(--muted);
}

.legend__labels span {
  letter-spacing: 0.05em;
}

.detail-panel {
  overflow: hidden;
  grid-column: 2;
  grid-row: 1;
}

.detail-section {
  padding: 1.4rem 1.6rem;
  border-bottom: 1px solid rgba(110, 118, 129, 0.25);
}

.detail-section:last-of-type {
  border-bottom: none;
}

.key-value {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 0.35rem 1rem;
  margin: 0;
}

.key-value dt {
  font-size: 0.8rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.key-value dd {
  margin: 0;
  font-size: 0.95rem;
}


.metric-grid {
  list-style: none;
  margin: 0;
  padding: 0 1.2rem 0;
  display: grid;
  gap: 0.8rem;
}

.metric-label {
  display: block;
  font-size: 0.78rem;
  text-transform: uppercase;
  color: var(--muted);
  letter-spacing: 0.08em;
}

.metric-value {
  display: block;
  font-size: 1.15rem;
  font-weight: 600;
}

.info-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: 0.4rem;
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 50%;
  border: 1px solid var(--border);
  font-size: 0.72rem;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  cursor: pointer;
  position: relative;
  transition: background 0.2s ease, color 0.2s ease;
}

.info-icon:hover,
.info-icon:focus-visible {
  background: var(--accent-soft);
  color: var(--accent);
  outline: none;
}

.info-icon::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 0.65rem);
  left: 50%;
  transform: translateX(-50%);
  min-width: 240px;
  max-width: 320px;
  padding: 0.75rem 0.9rem;
  border-radius: 0.75rem;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(10, 12, 15, 0.95);
  color: var(--text);
  font-size: 0.78rem;
  line-height: 1.35;
  white-space: pre-line;
  box-shadow: 0 22px 45px -30px rgba(0, 0, 0, 0.9);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
  z-index: 12;
}

.info-icon::before {
  content: '';
  position: absolute;
  bottom: calc(100% + 0.3rem);
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-top: 8px solid rgba(10, 12, 15, 0.95);
  opacity: 0;
  transition: opacity 0.15s ease;
  z-index: 12;
}

.info-icon:hover::after,
.info-icon:hover::before,
.info-icon:focus-visible::after,
.info-icon:focus-visible::before {
  opacity: 1;
}

.metrics-section {
  padding-bottom: 1.4rem;
}

.page-footer {
  border-top: 1px solid var(--border);
  background: linear-gradient(135deg, rgba(18, 21, 25, 0.92), rgba(10, 12, 15, 0.92));
}

.page-footer p {
  margin: 0;
  color: var(--muted);
}

.footer-actions {
  display: flex;
  gap: 0.8rem;
}

.figure-section {
  padding-bottom: 1.4rem;
}

.figure-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  padding: 0 0 0.5rem;
}

.figure-grid figure {
  margin: 0;
  background: rgba(13, 17, 23, 0.75);
  border: 1px solid rgba(110, 118, 129, 0.35);
  border-radius: 0.75rem;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.figure-grid img {
  width: 100%;
  height: 180px;
  object-fit: cover;
  background: rgba(0, 0, 0, 0.25);
  cursor: pointer;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.figure-grid img:hover {
  transform: scale(1.02);
  opacity: 0.95;
}

.figure-grid img.figure-missing {
  opacity: 0.4;
  cursor: default;
  filter: grayscale(40%);
}

.figure-grid figcaption {
  padding: 0.6rem 0.9rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.figure-note {
  margin: 0.8rem 0 0;
  font-size: 0.75rem;
  color: var(--muted);
}

.modal-open {
  overflow: hidden;
}

.figure-modal,
.faq-modal,
.doc-modal,
.chart-modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.figure-modal.is-open,
.faq-modal.is-open,
.doc-modal.is-open,
.chart-modal.is-open {
  display: flex;
}

.figure-modal__backdrop,
.faq-modal__backdrop,
.doc-modal__backdrop,
.chart-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(6px);
}

.figure-modal__content,
.faq-modal__content,
.doc-modal__content,
.chart-modal__content {
  position: relative;
  background: rgba(14, 17, 20, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 1rem;
  padding: 1.4rem;
  max-width: 92vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  box-shadow: 0 55px 120px -40px rgba(0, 0, 0, 0.7);
  z-index: 1;
}

.figure-modal__content img {
  width: 100%;
  max-height: 60vh;
  object-fit: contain;
  border-radius: 0.75rem;
  background: rgba(0, 0, 0, 0.25);
}

.figure-modal__close,
.faq-modal__close,
.doc-modal__close,
.chart-modal__close {
  position: absolute;
  top: 0.6rem;
  right: 0.6rem;
  background: rgba(22, 27, 34, 0.85);
  border: 1px solid rgba(110, 118, 129, 0.4);
  border-radius: 999px;
  color: var(--text);
  width: 2.1rem;
  height: 2.1rem;
  display: grid;
  place-items: center;
  font-size: 1.2rem;
  cursor: pointer;
}

.figure-modal__close:hover,
.faq-modal__close:hover,
.doc-modal__close:hover,
.chart-modal__close:hover {
  opacity: 0.85;
}

.faq-modal__content {
  max-width: 720px;
  max-height: 85vh;
  overflow-y: auto;
  padding: 2rem;
  gap: 1.2rem;
}

.doc-modal__content {
  max-width: 1200px;
  width: min(1200px, 95vw);
  height: 95vh;
  max-height: 95vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
  padding: 1rem 2.2rem 1.8rem;
}

.doc-modal__iframe-container {
  flex: 1;
  background: rgba(13, 17, 23, 0.85);
  border: 1px solid rgba(110, 118, 129, 0.35);
  border-radius: 0.9rem;
  overflow: hidden;
}

.doc-modal__iframe-container iframe {
  width: 100%;
  height: 100%;
  border: none;
}

.chart-modal__content {
  max-width: 900px;
  width: min(900px, 95vw);
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
  padding: 2rem 2.2rem 1.8rem;
}

.faq-modal__content h2 {
  margin: 0 0 0.75rem;
}

.faq-modal__content h3 {
  margin: 1.2rem 0 0.45rem;
  font-size: 1.05rem;
}

.faq-modal__content p {
  margin: 0.4rem 0;
  line-height: 1.6;
}

.faq-definitions {
  margin: 0;
  padding: 0;
}

.faq-definitions dt {
  margin-top: 1rem;
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.82rem;
  color: var(--muted);
  letter-spacing: 0.08em;
}

.faq-definitions dd {
  margin: 0.35rem 0 0;
  font-size: 0.92rem;
  line-height: 1.6;
}

.chart-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 1.2rem;
  align-items: flex-end;
}

.chart-controls label {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.chart-controls select {
  background: rgba(22, 27, 34, 0.9);
  border: 1px solid rgba(110, 118, 129, 0.4);
  border-radius: 0.6rem;
  color: var(--text);
  padding: 0.45rem 0.75rem;
}

.chart-controls input[type="date"] {
  background: rgba(22, 27, 34, 0.9);
  border: 1px solid rgba(110, 118, 129, 0.4);
  border-radius: 0.6rem;
  color: var(--text);
  padding: 0.45rem 0.75rem;
}

.chart-variables {
  display: flex;
  gap: 1rem;
  margin: 0;
  padding: 0.6rem 0.9rem;
  border: 1px solid rgba(110, 118, 129, 0.4);
  border-radius: 0.75rem;
  background: rgba(13, 17, 23, 0.85);
  font-size: 0.85rem;
}

.chart-variables legend {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.chart-canvas-wrap {
  position: relative;
  width: 100%;
  min-height: 360px;
  background: rgba(13, 17, 23, 0.85);
  border: 1px solid rgba(110, 118, 129, 0.35);
  border-radius: 0.9rem;
  padding: 1rem 1.2rem;
}

.chart-canvas-wrap canvas {
  width: 100%;
  height: 320px;
}

.chart-note {
  margin: 0;
  font-size: 0.8rem;
  color: var(--muted);
}

button,
.ghost-button {
  background: rgba(22, 27, 34, 0.85);
  color: var(--text);
  border: 1px solid rgba(110, 118, 129, 0.4);
  border-radius: 999px;
  padding: 0.45rem 1.2rem;
  font-size: 0.85rem;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease;
}

#openCharts,
#openDailyChart {
  background: rgba(47, 129, 247, 0.22);
  color: #f0f6fc;
  border: 1px solid rgba(47, 129, 247, 0.5);
}

#openCharts:hover,
#openDailyChart:hover {
  background: rgba(47, 129, 247, 0.35);
}

button:active,
.ghost-button:active {
  transform: scale(0.98);
  background: rgba(35, 41, 49, 0.95);
}

@media (max-width: 900px) {
  .page-header,
  .page-footer {
    padding: 1.25rem;
  }
  .layout {
    padding: 1rem 1.25rem 1.5rem;
    gap: 1rem;
  }
  .filters {
    width: 100%;
  }
  .layout {
    grid-template-columns: 1fr;
    grid-auto-rows: auto;
  }
  
  .branding {
    flex-direction: column;
    align-items: flex-start;
  }

  .map-panel,
  .detail-panel {
    grid-column: 1;
  }
}
