:root {
  color-scheme: dark;
  --bg: #0f172a;
  --panel: #111827;
  --panel-soft: #1f2937;
  --text: #e5e7eb;
  --muted: #94a3b8;
  --border: #334155;
  --green: #10b981;
  --yellow: #f59e0b;
  --red: #ef4444;
  --blue: #38bdf8;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}

h1,
h2,
h3,
p {
  margin: 0;
}

.app-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  background: #0b1222;
}

.app-header h1 {
  font-size: 1.35rem;
}

.app-header p {
  margin-top: 0.25rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.status-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  align-items: flex-end;
}

.pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.25rem 0.7rem;
  font-size: 0.78rem;
  font-weight: 600;
}

.pill-ok {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(52, 211, 153, 0.35);
}

.pill-warn {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
  border: 1px solid rgba(251, 191, 36, 0.35);
}

.pill-error {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border: 1px solid rgba(248, 113, 113, 0.35);
}

.timestamp {
  color: var(--muted);
  font-size: 0.76rem;
}

.dashboard-grid {
  padding: 1rem 1.25rem 1.25rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  height: calc(100vh - 80px);
  overflow: hidden;
}

.right-column {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  overflow-y: auto;
  min-height: 0;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 0.8rem;
  padding: 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  min-height: 200px;
  flex-shrink: 0;
}

.map-panel {
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.panel-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
}

.panel-header h2 {
  font-size: 1rem;
}

.panel-meta {
  color: var(--muted);
  font-size: 0.8rem;
}

.map {
  width: 100%;
  flex: 1;
  min-height: 300px;
  border-radius: 0.65rem;
  border: 1px solid var(--border);
  overflow: hidden;
}

.legend {
  display: flex;
  gap: 1rem;
  color: var(--muted);
  font-size: 0.8rem;
}

.dot {
  width: 0.62rem;
  height: 0.62rem;
  display: inline-block;
  border-radius: 999px;
  margin-right: 0.35rem;
}

.dot-green { background: var(--green); }
.dot-yellow { background: var(--yellow); }
.dot-red { background: var(--red); }

.table-wrap {
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 0.65rem;
}

#delay-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
}

#delay-table th,
#delay-table td {
  padding: 0.55rem 0.65rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

#delay-table thead {
  background: var(--panel-soft);
}

#delay-table tbody tr:nth-child(even) {
  background: rgba(31, 41, 55, 0.55);
}

#delay-table tbody tr.high-delay {
  background: rgba(239, 68, 68, 0.14);
}

.alerts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 0.75rem;
}

.chart-wrap {
  position: relative;
  height: 260px;
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 0.65rem;
  padding: 0.45rem;
  background: rgba(15, 23, 42, 0.35);
}

#route-chart {
  width: 100% !important;
  height: 100% !important;
}

.alert-card {
  border: 1px solid var(--border);
  border-radius: 0.65rem;
  padding: 0.7rem;
  background: var(--panel-soft);
  display: grid;
  gap: 0.4rem;
}

.alert-new {
  animation: pulse-in 0.8s ease-out;
}

@keyframes pulse-in {
  from {
    transform: scale(0.98);
    box-shadow: 0 0 0 0 rgba(56, 189, 248, 0.35);
  }
  to {
    transform: scale(1);
    box-shadow: 0 0 0 10px rgba(56, 189, 248, 0);
  }
}

.alert-badge {
  display: inline-flex;
  width: fit-content;
  border-radius: 999px;
  padding: 0.2rem 0.5rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.03em;
}

.severity-severe .alert-badge {
  background: rgba(239, 68, 68, 0.18);
  color: #fca5a5;
}

.severity-warning .alert-badge {
  background: rgba(245, 158, 11, 0.18);
  color: #fcd34d;
}

.severity-info .alert-badge,
.severity-unknown .alert-badge {
  background: rgba(59, 130, 246, 0.18);
  color: #93c5fd;
}

.alert-meta {
  color: var(--muted);
  font-size: 0.78rem;
}

.alert-text {
  font-size: 0.86rem;
  line-height: 1.35;
}

.badge-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.badge {
  padding: 0.17rem 0.45rem;
  border-radius: 0.4rem;
  border: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.7);
  font-size: 0.72rem;
  color: var(--muted);
}

.empty {
  color: var(--muted);
  font-size: 0.84rem;
  padding: 0.4rem 0.1rem;
}

@media (max-width: 1100px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
    height: auto;
  }

  .map-panel {
    min-height: 400px;
  }

  .map {
    min-height: 320px;
  }
}
