/* passenger · routes panel — production CSS
 * NB: Google Fonts CDN removed (blocked by CSP default-src 'self').
 * System fallbacks are used; design-tokens (Plus Jakarta Sans / JetBrains Mono)
 * can be vendored locally later when typography pack arrives.
 */

:root {
  /* Sidebar */
  --sb-bg: #0e1117;
  --sb-text: rgba(255,255,255,0.75);
  --sb-text-active: #ffffff;
  --sb-active-bg: rgba(255,255,255,0.08);
  --sb-hover-bg: rgba(255,255,255,0.05);
  --sb-border: rgba(255,255,255,0.08);
  --sb-section: rgba(255,255,255,0.3);
  --sb-width: 232px;

  /* Surfaces */
  --bg: #f5f6fa;
  --surface: #ffffff;
  --surface-2: #f8f9fc;
  --surface-3: #f0f2f7;

  /* Text */
  --text-1: #0f172a;
  --text-2: #475569;
  --text-3: #94a3b8;

  /* Borders */
  --border: #e2e8f0;
  --border-2: #cbd5e1;

  /* Brand */
  --accent: #4f6ef7;
  --accent-hover: #3d5af1;
  --accent-soft: #eef0fe;

  /* Status */
  --ok: #16a34a;
  --ok-bg: #f0fdf4;
  --ok-border: #bbf7d0;
  --warn: #d97706;
  --warn-bg: #fffbeb;
  --warn-border: #fde68a;
  --bad: #dc2626;
  --bad-bg: #fef2f2;
  --bad-border: #fecaca;

  /* UI */
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 4px 12px rgba(0,0,0,0.04);
  --shadow-lg: 0 4px 16px rgba(0,0,0,0.1), 0 1px 3px rgba(0,0,0,0.08);
}

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

html, body, #root {
  height: 100%;
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-1);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

/* ── App layout ──────────────────────────────────────────────── */
.app-layout {
  display: grid;
  grid-template-columns: var(--sb-width) 1fr;
  min-height: 100vh;
}

/* ── Sidebar ─────────────────────────────────────────────────── */
.sidebar {
  background: var(--sb-bg);
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: sticky;
  top: 0;
  overflow: hidden;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 16px 16px;
  border-bottom: 1px solid var(--sb-border);
}

.sidebar-logo-mark {
  width: 28px; height: 28px;
  background: var(--accent);
  border-radius: 7px;
  display: grid;
  place-items: center;
  font-size: 14px;
  color: white;
  font-weight: 700;
  flex-shrink: 0;
}

.sidebar-logo-name {
  color: white;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.2px;
}

.sidebar-logo-sub {
  color: var(--sb-text);
  font-size: 11px;
  margin-top: 1px;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 8px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-section-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--sb-section);
  padding: 12px 8px 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--sb-text);
  font-size: 13.5px;
  font-weight: 500;
  text-decoration: none;
  transition: background 0.1s, color 0.1s;
  border: none;
  background: transparent;
  font-family: inherit;
  width: 100%;
  text-align: left;
}

.nav-item:hover { background: var(--sb-hover-bg); color: var(--sb-text-active); }
.nav-item.active { background: var(--sb-active-bg); color: var(--sb-text-active); }

.nav-item-icon {
  width: 18px;
  text-align: center;
  font-size: 15px;
  flex-shrink: 0;
  opacity: 0.8;
}

.nav-badge {
  margin-left: auto;
  font-size: 11px;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 999px;
  background: rgba(255,255,255,0.12);
  color: white;
}
.nav-badge.bad { background: var(--bad); }

.sidebar-user {
  padding: 12px 12px;
  border-top: 1px solid var(--sb-border);
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--accent);
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
}

.user-name { color: white; font-size: 13px; font-weight: 500; }
.user-role { color: var(--sb-text); font-size: 11px; }

/* ── Main area ───────────────────────────────────────────────── */
.main-area {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  overflow: hidden;
}

/* ── Topbar ──────────────────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: 56px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar-title { font-size: 15px; font-weight: 600; }
.topbar-sub { font-size: 12px; color: var(--text-3); }

.topbar-actions { display: flex; align-items: center; gap: 8px; }

.topbar-scope {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  color: var(--text-2);
  cursor: pointer;
  background: var(--surface);
}

/* ── Page ────────────────────────────────────────────────────── */
.page {
  padding: 24px;
  flex: 1;
  overflow-y: auto;
}

.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 16px;
}

.page-title {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.page-subtitle {
  font-size: 13px;
  color: var(--text-3);
  margin-top: 2px;
}

/* ── Cards ───────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.card-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.card-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-1);
}

.card-body { padding: 16px; }

/* ── KPI cards ───────────────────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 20px;
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
}

.kpi-card.alert-card {
  border-color: var(--bad-border);
  background: var(--bad-bg);
}

.kpi-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.kpi-value {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -1px;
  line-height: 1.1;
  margin: 6px 0 4px;
}

.kpi-trend {
  font-size: 12px;
  color: var(--text-3);
  display: flex;
  align-items: center;
  gap: 4px;
}

.kpi-trend.up { color: var(--ok); }
.kpi-trend.down { color: var(--bad); }

/* ── Badges / chips ──────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
}

.badge-ok { background: var(--ok-bg); color: var(--ok); border: 1px solid var(--ok-border); }
.badge-warn { background: var(--warn-bg); color: var(--warn); border: 1px solid var(--warn-border); }
.badge-bad { background: var(--bad-bg); color: var(--bad); border: 1px solid var(--bad-border); }
.badge-neutral { background: var(--surface-3); color: var(--text-2); border: 1px solid var(--border); }

/* ── Dot indicator ───────────────────────────────────────────── */
.dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}
.dot-ok { background: var(--ok); }
.dot-warn { background: var(--warn); }
.dot-bad { background: var(--bad); animation: pulse 2s infinite; }
.dot-muted { background: var(--text-3); }

/* ── Alert banner ────────────────────────────────────────────── */
.alert-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius);
  border: 1px solid;
  margin-bottom: 20px;
  font-size: 13.5px;
}

.alert-banner.bad {
  background: var(--bad-bg);
  border-color: var(--bad-border);
  color: var(--bad);
}

.alert-banner.warn {
  background: var(--warn-bg);
  border-color: var(--warn-border);
  color: var(--warn);
}

/* ── Buttons ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.12s;
  border: 1px solid transparent;
  white-space: nowrap;
  text-decoration: none;
}

.btn-primary {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}
.btn-primary:hover { background: var(--accent-hover); }

.btn-secondary {
  background: var(--surface);
  color: var(--text-1);
  border-color: var(--border);
  box-shadow: var(--shadow-sm);
}
.btn-secondary:hover { background: var(--surface-2); border-color: var(--border-2); }

.btn-ghost {
  background: transparent;
  color: var(--text-2);
  border-color: transparent;
}
.btn-ghost:hover { background: var(--surface-3); color: var(--text-1); }

.btn-danger {
  background: var(--bad);
  color: white;
  border-color: var(--bad);
}
.btn-danger:hover { background: #b91c1c; }

.btn-sm { padding: 4px 10px; font-size: 12.5px; }
.btn-xs { padding: 2px 8px; font-size: 12px; }

/* ── Inputs ──────────────────────────────────────────────────── */
.input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 14px;
  color: var(--text-1);
  background: var(--surface);
  transition: border-color 0.12s, box-shadow 0.12s;
  outline: none;
}

.input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79,110,247,0.12);
}

.input.error {
  border-color: var(--bad);
}

.input.error:focus {
  box-shadow: 0 0 0 3px rgba(220,38,38,0.12);
}

.field-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-1);
  margin-bottom: 5px;
  display: block;
}

.field-error {
  font-size: 12px;
  color: var(--bad);
  margin-top: 4px;
}

/* ── Table ───────────────────────────────────────────────────── */
.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left;
  padding: 10px 14px;
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-3);
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}
.table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 13.5px;
  vertical-align: middle;
}
.table tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: var(--surface-2); }
.mono { font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; }

/* ── Toast ───────────────────────────────────────────────────── */
.toast-stack {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 1000;
  display: flex;
  flex-direction: column-reverse;
  gap: 8px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: space-between;
  padding: 12px 16px;
  border-radius: var(--radius);
  background: var(--text-1);
  color: white;
  font-size: 13.5px;
  box-shadow: var(--shadow-lg);
  min-width: 280px;
  max-width: 400px;
  pointer-events: all;
  animation: slideUp 0.2s ease;
}

.toast-ok { background: #15803d; }
.toast-bad { background: #b91c1c; }
.toast-warn { background: #b45309; }

/* ── Utilities ───────────────────────────────────────────────── */
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.text-muted { color: var(--text-3); }
.text-sm { font-size: 12.5px; }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.w-full { width: 100%; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
.divider { height: 1px; background: var(--border); }

/* ── Login page ──────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  background: var(--bg);
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.login-left {
  background: var(--sb-bg);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 48px;
}

.login-right {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px;
}

.login-form-wrap {
  width: 100%;
  max-width: 360px;
}

.login-headline {
  color: white;
  font-size: 36px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.5px;
}

.login-tagline {
  color: var(--sb-text);
  font-size: 15px;
  margin-top: 12px;
  line-height: 1.6;
}

/* ── Animations ──────────────────────────────────────────────── */
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

@keyframes slideUp {
  from { transform: translateY(12px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ── Sparkline ───────────────────────────────────────────────── */
.spark { display: block; }

/* ── Map placeholder ─────────────────────────────────────────── */
.map-stub {
  background: #e8eef3;
  border-radius: var(--radius-sm);
  position: relative;
  overflow: hidden;
}

.map-stub::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    repeating-linear-gradient(0deg, transparent 0, transparent 39px, rgba(0,0,0,0.04) 39px, rgba(0,0,0,0.04) 40px),
    repeating-linear-gradient(90deg, transparent 0, transparent 39px, rgba(0,0,0,0.04) 39px, rgba(0,0,0,0.04) 40px);
}

/* ── Segmented control ───────────────────────────────────────── */
.segmented {
  display: inline-flex;
  background: var(--surface-3);
  border-radius: var(--radius-sm);
  padding: 3px;
  gap: 2px;
}

.segmented button {
  border: none;
  background: transparent;
  padding: 5px 12px;
  border-radius: 5px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  color: var(--text-2);
  transition: all 0.12s;
}

.segmented button.active {
  background: var(--surface);
  color: var(--text-1);
  box-shadow: var(--shadow-sm);
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 3px; }
