:root {
  --bg: #081016;
  --surface: #111922;
  --surface-2: #151f2a;
  --surface-3: #1b2733;
  --border: #2b3440;
  --text: #eef3f8;
  --muted: #95a1af;
  --muted-2: #6f7b88;
  --danger: #ff5a5f;
  --danger-2: #f04449;
  --warn: #f6c85f;
  --info: #5cc8ff;
  --ok: #6bd38f;
  --archive: #7a8a99;
  --shadow: 0 18px 60px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(92, 200, 255, 0.09), transparent 260px),
    var(--bg);
  color: var(--text);
  font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

a {
  color: var(--info);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

button,
input {
  font: inherit;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  background: rgba(8, 16, 22, 0.88);
  backdrop-filter: blur(16px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 240px;
}

.signal {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--danger);
  box-shadow: 0 0 0 7px rgba(255, 90, 95, 0.14), 0 0 28px rgba(255, 90, 95, 0.7);
}

.brand h1,
.pane-head h2,
.situation h2 {
  margin: 0;
  letter-spacing: 0;
}

.brand h1 {
  font-size: clamp(20px, 3vw, 28px);
  line-height: 1.05;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.source-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.source-nav a,
.segmented button,
.count-pill,
.status-chip {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
  font-family: "JetBrains Mono", monospace;
  font-size: 12px;
  line-height: 1;
}

.source-nav a {
  padding: 9px 11px;
}

.dashboard {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(320px, 0.75fr);
  grid-template-areas:
    "status status"
    "map timeline"
    "chart news"
    "table table";
  gap: 16px;
  width: min(1500px, calc(100% - 32px));
  margin: 16px auto 0;
}

.status-band,
.panel {
  background: rgba(17, 25, 34, 0.94);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.status-band {
  grid-area: status;
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(420px, 0.9fr);
  gap: 1px;
  border-radius: 12px;
  overflow: hidden;
}

.situation {
  padding: 22px;
  background: linear-gradient(135deg, rgba(92, 200, 255, 0.1), rgba(255, 90, 95, 0.06));
}

.situation h2 {
  font-size: clamp(24px, 4vw, 42px);
  line-height: 1.03;
}

.summary-note {
  max-width: 900px;
  margin: 14px 0 0;
  color: #c6d0dc;
}

.risk-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
}

.risk-strip span {
  padding: 7px 10px;
  border: 1px solid rgba(246, 200, 95, 0.26);
  border-radius: 8px;
  background: rgba(246, 200, 95, 0.09);
  color: #f9df9c;
  font-family: "JetBrains Mono", monospace;
  font-size: 12px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  background: var(--border);
}

.metric {
  min-height: 124px;
  padding: 18px;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.metric-label {
  color: var(--muted);
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.metric strong {
  font-family: "JetBrains Mono", monospace;
  font-size: clamp(28px, 6vw, 54px);
  line-height: 0.95;
}

.metric-danger strong {
  color: var(--danger);
}

.map-pane {
  grid-area: map;
}

.timeline-pane {
  grid-area: timeline;
}

.chart-pane {
  grid-area: chart;
}

.news-pane {
  grid-area: news;
}

.table-pane {
  grid-area: table;
}

.panel {
  border-radius: 12px;
  overflow: hidden;
}

.pane-head {
  min-height: 66px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  background: rgba(21, 31, 42, 0.86);
}

.pane-head h2 {
  font-size: 18px;
  line-height: 1.15;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.legend-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  display: inline-block;
}

.legend-dot.severe {
  background: var(--danger);
}

.legend-dot.watched {
  background: var(--info);
}

.legend-dot.archive {
  background: var(--archive);
}

.controls {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto auto;
  align-items: end;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.search-field {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.search-field input {
  min-width: 0;
  height: 38px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-3);
  color: var(--text);
  padding: 0 12px;
  outline: none;
}

.search-field input:focus {
  border-color: var(--info);
  box-shadow: 0 0 0 3px rgba(92, 200, 255, 0.13);
}

.segmented {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.segmented button {
  height: 38px;
  padding: 0 10px;
  cursor: pointer;
}

.segmented button.active,
.segmented button:hover {
  border-color: rgba(92, 200, 255, 0.65);
  background: rgba(92, 200, 255, 0.15);
  color: #d8f3ff;
}

.toggle {
  height: 38px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--muted);
  font-family: "JetBrains Mono", monospace;
  font-size: 12px;
  white-space: nowrap;
}

.toggle input {
  accent-color: var(--info);
}

#map {
  height: clamp(430px, 54vh, 660px);
  min-height: 430px;
  background: #0b1218;
}

.leaflet-container {
  background: #0b1218;
  font-family: "Inter", sans-serif;
}

.leaflet-popup-content-wrapper,
.leaflet-popup-tip {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}

.leaflet-popup-content {
  margin: 12px;
}

.map-popup {
  display: grid;
  gap: 7px;
  min-width: 220px;
}

.map-popup strong {
  font-size: 14px;
}

.map-popup span,
.map-popup p {
  margin: 0;
  color: #c6d0dc;
}

.map-popup dl {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 3px 8px;
  margin: 0;
}

.map-popup dt {
  color: var(--muted);
  font-family: "JetBrains Mono", monospace;
  font-size: 10px;
}

.map-popup dd {
  margin: 0;
  font-weight: 700;
}

.count-pill {
  min-width: 34px;
  padding: 8px 10px;
  text-align: center;
}

.timeline {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 642px;
  overflow: auto;
}

.timeline li {
  border-bottom: 1px solid var(--border);
}

.timeline li.selected {
  background: rgba(92, 200, 255, 0.1);
}

.timeline button {
  width: 100%;
  display: grid;
  gap: 5px;
  border: 0;
  background: transparent;
  color: inherit;
  padding: 14px 16px;
  text-align: left;
  cursor: pointer;
}

.timeline button:hover {
  background: rgba(255, 255, 255, 0.035);
}

.tl-date,
.tl-meta {
  color: var(--muted);
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
}

.tl-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tl-meta span {
  padding: 3px 6px;
  border-radius: 6px;
  background: var(--surface-3);
}

.empty {
  padding: 18px 16px;
  color: var(--muted);
}

#monthly-chart {
  display: block;
  width: 100%;
  height: 260px;
  padding: 16px;
  background: var(--surface);
}

.news-list {
  display: grid;
}

.news-item {
  display: grid;
  gap: 7px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

.news-item:last-child {
  border-bottom: 0;
}

.news-item div {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
}

.news-item a {
  font-weight: 700;
  line-height: 1.25;
}

.news-item p {
  margin: 0;
  color: #c6d0dc;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  min-width: 940px;
  border-collapse: collapse;
}

th,
td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  text-align: left;
}

th {
  background: var(--surface-3);
  color: var(--muted);
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
  white-space: nowrap;
}

td {
  color: #dce5ee;
}

td strong,
td span {
  display: block;
}

td span {
  color: var(--muted);
  margin-top: 3px;
}

.selected-row {
  background: rgba(92, 200, 255, 0.08);
}

.status-chip {
  display: inline-flex;
  width: max-content;
  margin-top: 0;
  padding: 6px 8px;
}

.status-active {
  border-color: rgba(246, 200, 95, 0.38);
  color: #ffe1a0;
}

.status-watch {
  border-color: rgba(92, 200, 255, 0.38);
  color: #caedff;
}

.status-archived {
  border-color: rgba(122, 138, 153, 0.5);
  color: #c3ccd5;
}

.danger-text {
  color: var(--danger);
  font-weight: 800;
}

.empty-cell,
.empty-source {
  padding: 18px 16px;
  color: var(--muted);
}

.footer {
  width: min(1500px, calc(100% - 32px));
  margin: 16px auto 28px;
  color: var(--muted);
  font-size: 12px;
}

.footer p {
  margin: 0;
}

.footer p + p {
  margin-top: 6px;
}

@media (max-width: 1120px) {
  .dashboard {
    grid-template-columns: 1fr;
    grid-template-areas:
      "status"
      "map"
      "timeline"
      "chart"
      "news"
      "table";
  }

  .status-band {
    grid-template-columns: 1fr;
  }

  .timeline {
    max-height: 420px;
  }
}

@media (max-width: 760px) {
  .topbar {
    position: static;
    align-items: flex-start;
    padding: 16px;
  }

  .topbar,
  .source-nav,
  .controls {
    flex-direction: column;
  }

  .source-nav {
    width: 100%;
    justify-content: flex-start;
  }

  .dashboard,
  .footer {
    width: calc(100% - 20px);
    margin-top: 10px;
  }

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

  .metric {
    min-height: 96px;
  }

  .pane-head,
  .controls {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .legend {
    justify-content: flex-start;
  }

  .segmented,
  .toggle {
    width: 100%;
  }

  .segmented button {
    flex: 1 1 auto;
  }

  #map {
    min-height: 360px;
    height: 420px;
  }
}
