:root {
  --bg: #0b0c10;
  --bg-panel: #12141a;
  --bg-panel-2: #171a22;
  --border: #1e2430;
  --text: #e6edf3;
  --muted: #8b949e;
  --cyan: #3dd6c6;
  --amber: #f0b429;
  --red: #f85149;
  --green: #3fb950;
  --blue: #58a6ff;
  --font: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
  --mono: "IBM Plex Mono", "JetBrains Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.small { font-size: 0.75rem; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.55rem 1rem;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, #10131a 0%, #0b0c10 100%);
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.logo { color: var(--cyan); font-size: 1.2rem; }
.title {
  font-weight: 700;
  letter-spacing: 0.08em;
  font-size: 0.95rem;
}
.topbar-right {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}
.user-label { font-size: 0.85rem; max-width: 12rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.chip {
  display: inline-flex;
  align-items: center;
  padding: 0.12rem 0.5rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-family: var(--mono);
  border: 1px solid var(--border);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.chip-ok { color: var(--green); border-color: #23863655; background: #23863622; }
.chip-degraded, .chip-warn, .chip-stale { color: var(--amber); border-color: #9e6a0355; background: #9e6a0322; }
.chip-error, .chip-unavailable { color: var(--red); border-color: #da363355; background: #da363322; }
.chip-unknown, .chip-empty { color: var(--muted); }

.btn {
  font: inherit;
  font-size: 0.8rem;
  padding: 0.3rem 0.7rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  cursor: pointer;
  text-decoration: none;
  color: var(--text);
  background: var(--bg-panel-2);
}
.btn-primary {
  background: #0d3d3a;
  border-color: #1f6f6a;
  color: var(--cyan);
}
.btn-ghost { background: transparent; }
.btn:hover { filter: brightness(1.15); }

.grid {
  flex: 1;
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  grid-template-rows: minmax(280px, 1.2fr) minmax(180px, 1fr) minmax(160px, 0.9fr);
  grid-template-areas:
    "map fleet"
    "map news"
    "geo fresh";
  gap: 0.6rem;
  padding: 0.6rem;
  min-height: 0;
}
.map-panel { grid-area: map; }
#panel-fleet { grid-area: fleet; }
#panel-news { grid-area: news; }
#panel-geo { grid-area: geo; }
#panel-fresh { grid-area: fresh; }

.panel {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.45rem 0.7rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-panel-2);
}
.panel-head h2 {
  margin: 0;
  font-size: 0.78rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--cyan);
  font-weight: 600;
}
.panel-body { padding: 0.5rem 0.7rem; flex: 1; min-height: 0; }
.scroll { overflow: auto; }

#map {
  flex: 1;
  min-height: 220px;
  background: #0a0e14;
}

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}
table.data th, table.data td {
  text-align: left;
  padding: 0.28rem 0.35rem;
  border-bottom: 1px solid #1a1f2a;
  vertical-align: top;
}
table.data th {
  color: var(--muted);
  font-weight: 500;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.news-item {
  padding: 0.4rem 0;
  border-bottom: 1px solid #1a1f2a;
}
.news-item a {
  color: var(--text);
  text-decoration: none;
}
.news-item a:hover { color: var(--cyan); }
.news-meta {
  display: flex;
  gap: 0.5rem;
  font-size: 0.7rem;
  color: var(--muted);
  margin-top: 0.15rem;
}
.source-badge {
  color: var(--blue);
  font-family: var(--mono);
}

.geo-item {
  padding: 0.4rem 0.35rem;
  border-bottom: 1px solid #1a1f2a;
  cursor: pointer;
  border-radius: 4px;
}
.geo-item:hover, .geo-item.active {
  background: #1a2230;
}
.geo-item .sev {
  font-family: var(--mono);
  font-size: 0.68rem;
  text-transform: uppercase;
}
.sev-high { color: var(--red); }
.sev-medium { color: var(--amber); }
.sev-low { color: var(--green); }

.fresh-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 0.5rem;
  align-items: center;
  padding: 0.35rem 0;
  border-bottom: 1px solid #1a1f2a;
  font-size: 0.8rem;
}
.fresh-row .id { font-family: var(--mono); font-size: 0.72rem; color: var(--muted); }

.leaflet-container { background: #0a0e14; font: inherit; }
.leaflet-control-attribution {
  background: rgba(11,12,16,0.75) !important;
  color: var(--muted) !important;
  font-size: 0.65rem !important;
}
.leaflet-control-attribution a { color: var(--blue) !important; }

@media (max-width: 900px) {
  .grid {
    grid-template-columns: 1fr;
    grid-template-rows: auto;
    grid-template-areas:
      "map"
      "fleet"
      "news"
      "geo"
      "fresh";
  }
  #map { min-height: 260px; height: 260px; }
  .panel { max-height: 360px; }
}
