:root{
  --brand:#0ea5e9;
  --brand-700:#0284c7;
  --bg:#f8fafc;
  --panel:#ffffff;
  --ink:#0f172a;
  --muted:#64748b;
  --border:#e2e8f0;
  --bad:#b91c1c;
  --ok:#15803d;
  --warn:#b45309;
}
*{box-sizing:border-box}
html{background:var(--bg);min-height:100%}
body{
  font-family:system-ui,-apple-system,Segoe UI,Roboto,Arial,sans-serif;
  margin:0 auto;
  max-width:1600px;
  padding:32px;
  min-height:100vh;
  background:var(--bg);
  color:var(--ink);
}
@media (max-width:768px){
  body{padding:24px}
}
a{color:var(--brand-700);font-weight:600;text-decoration:none}
a:hover{text-decoration:underline}
h1,h2,h3,h4{color:var(--ink);margin:0 0 14px}
p{margin:0 0 10px;line-height:1.5}
.eyebrow{
  text-transform:uppercase;
  letter-spacing:.32em;
  font-size:11px;
  font-weight:700;
  color:var(--muted);
  margin-bottom:6px;
}
.hero-card .eyebrow{color:rgba(255,255,255,.8)}
.timestamp{
  font-size:13px;
  color:var(--muted);
  margin-top:6px;
}
.hero-card .timestamp{color:rgba(255,255,255,.85)}
.hero-card{
  background:linear-gradient(135deg,var(--brand),var(--brand-700));
  color:#fff;
  border-radius:24px;
  padding:24px;
  display:flex;
  flex-wrap:nowrap;
  gap:16px;
  align-items:flex-start;
  box-shadow:0 35px 80px rgba(8,47,73,.25);
  margin-bottom:20px;
}
.hero-card h1,
.hero-card h2,
.hero-card .hello{color:#fff;margin:0}
.hero-card .timestamp,
.hero-card .muted,
.hero-card small{color:rgba(255,255,255,.85)}
.hero-stack{flex:1 1 320px;min-width:220px}
.hero-actions{display:flex;gap:10px;flex-wrap:wrap;justify-content:flex-end}
.hero-actions > *{flex:0 0 auto}
.row{display:flex;gap:10px;align-items:center;flex-wrap:wrap}
.row.stretch{align-items:stretch}
.right{margin-left:auto}
.card,
section,
.panel{
  background:var(--panel);
  border:1px solid var(--border);
  border-radius:16px;
  padding:16px;
  box-shadow:0 20px 45px rgba(15,23,42,.08);
  margin-bottom:14px;
}
.panel{display:none}
.panel.active{display:block}
.tabs,
.tabbar{
  display:flex;
  gap:8px;
  flex-wrap:nowrap;
  overflow-x:auto;
  margin:16px 0;
  background:#fff;
  border:1px solid var(--border);
  border-radius:999px;
  padding:6px 8px;
  box-shadow:0 10px 24px rgba(15,23,42,.08);
}
.tab,
.tabbar .tab{
  border:none;
  background:transparent;
  color:var(--muted);
  border-radius:999px;
  padding:8px 18px;
  cursor:pointer;
  font-weight:600;
  transition:.15s ease;
}
.tab.active,
.tabbar .tab.active{
  background:var(--brand);
  color:#fff;
  box-shadow:0 10px 20px rgba(14,165,233,.35);
}
button,
.btn{
  border:none;
  border-radius:10px;
  padding:10px 16px;
  font-weight:600;
  cursor:pointer;
  background:var(--brand);
  color:#fff;
  box-shadow:0 10px 20px rgba(14,165,233,.2);
}
button.ghost,
.btn.ghost{
  background:#fff;
  color:var(--brand);
  border:1px solid var(--brand);
  box-shadow:none;
}
button.danger,
.btn.danger{
  background:#fff;
  color:var(--bad);
  border:1px solid var(--bad);
  box-shadow:none;
}
button.bad,
.btn.bad{background:var(--bad);color:#fff}
button.ok,
.btn.ok{background:var(--ok)}
button.warn,
.btn.warn{background:var(--warn)}
button.small{padding:6px 10px;font-size:12px}
button:disabled{opacity:.6;cursor:not-allowed}
input,select,textarea{
  padding:10px;
  border:1px solid var(--border);
  border-radius:10px;
  font:inherit;
  background:#fff;
  min-width:0;
}
textarea{resize:vertical;min-height:80px}
label{font-size:12px;font-weight:600;color:var(--muted);display:flex;flex-direction:column;gap:6px}
.field{display:flex;flex-direction:column;gap:6px;flex:1 1 220px}
.field.hidden{display:none}
.badge,
.pill{
  display:inline-flex;
  align-items:center;
  padding:6px 14px;
  border-radius:999px;
  border:1px solid var(--border);
  font-size:13px;
  font-weight:600;
  background:#fff;
  color:var(--muted);
  max-width:60vw;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}
.hero-card .pill,
.hero-card .badge{
  background:rgba(255,255,255,.15);
  color:#fff;
  border-color:rgba(255,255,255,.35);
}
.muted{color:var(--muted)}
.hint{font-size:12px;color:var(--muted)}
.note{
  background:#fef3c7;
  color:#92400e;
  border:1px solid #fde68a;
  border-radius:10px;
  padding:10px 12px;
  font-size:13px;
}
.status{font-weight:600;font-size:13px}
.status.ok{color:var(--ok)}
.status.err{color:var(--bad)}
.grid{display:grid;gap:12px}
.grid.metrics{grid-template-columns:repeat(auto-fit,minmax(180px,1fr))}
.grid.g2,
.form-grid{grid-template-columns:repeat(auto-fit,minmax(220px,1fr))}
.form-grid-4{grid-template-columns:repeat(auto-fit,minmax(160px,1fr));gap:10px}
.w-2{grid-column:span 2;min-width:200px}
.stack{display:grid;gap:12px}
.stack .card{margin:0}
.stacked{display:flex;flex-direction:column;gap:8px}
.stacked .item{padding:6px 0;border-bottom:1px solid var(--border);font-size:13px}
.route-tiles-row{
  display:flex;
  flex-wrap:wrap;
  gap:8px;
}
.route-tile{
  flex:1 1 150px;
  min-width:140px;
  max-width:220px;
  border:1px solid var(--border);
  border-radius:12px;
  padding:8px;
  font-size:12px;
  cursor:pointer;
  background:#f9fafb;
}
.route-tile.selected{
  border-color:var(--brand);
  box-shadow:0 0 0 1px var(--brand);
  background:#eff6ff;
}
.modal-backdrop{
  position:fixed;
  inset:0;
  background:rgba(0,0,0,0.3);
  z-index:90;
}
.modal{
  position:fixed;
  inset:0;
  display:flex;
  align-items:center;
  justify-content:center;
  z-index:100;
}
.modal-card{
  max-width:640px;
  width:100%;
}
.modal-backdrop{
  position:fixed;
  inset:0;
  background:rgba(0,0,0,0.3);
  z-index:90;
}
.modal{
  position:fixed;
  inset:0;
  display:flex;
  align-items:center;
  justify-content:center;
  z-index:100;
}
.modal-card{
  max-width:640px;
  width:100%;
}
.route-tile .title{
  font-weight:600;
  margin-bottom:4px;
}
.route-tile .meta{
  color:var(--muted);
  font-size:11px;
}
.route-tile .mini-line{
  height:4px;
  border-radius:999px;
  background:linear-gradient(to right,#2563eb,#1d4ed8);
  margin:4px 0;
}
.rt-dot{
  display:inline-block;
  width:6px;
  height:6px;
  border-radius:999px;
  margin-right:4px;
  background:var(--muted);
}
.rt-status-live .rt-dot{
  background:var(--ok);
}
.rt-status-offline .rt-dot{
  background:var(--muted);
}
.stacked .item:last-child{border-bottom:none}
.sacco-matatu-list{font-size:13px}
.section-title{display:flex;align-items:center;justify-content:space-between;margin-bottom:12px}
.section{margin-top:16px}
.metric,
.kpi,
.kv,
.stat{
  border:1px solid var(--border);
  border-radius:14px;
  padding:14px;
  background:#fff;
  box-shadow:0 12px 30px rgba(15,23,42,.06);
}
.metric .k,
.kpi .l,
.kv .k,
.stat .stat-label,
.k{font-size:12px;color:var(--muted);text-transform:uppercase;letter-spacing:.05em}
.metric .v,
.kpi .v,
.kv .v,
.stat .stat-value,
.v{font-size:22px;font-weight:700;margin-top:6px;color:var(--ink)}
.kpi{text-align:center}
.kpis{display:grid;grid-template-columns:repeat(auto-fit,minmax(160px,1fr));gap:12px}
.stat-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(180px,1fr));gap:12px}
.table-wrap{
  border:1px solid var(--border);
  border-radius:14px;
  overflow:auto;
  max-height:420px;
  background:#fff;
}
table{width:100%;border-collapse:collapse;font-size:14px}
th,td{padding:10px;border-bottom:1px solid var(--border);text-align:left;vertical-align:top}
th{background:#e0f2fe;color:#0f172a;font-weight:700}
.list{list-style:none;padding:0;margin:0;display:flex;flex-direction:column;gap:8px}
.list li{padding:8px 10px;border:1px solid var(--border);border-radius:10px;background:#f8fafc}
.bar{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
  align-items:flex-end;
  background:#fff;
  border:1px solid var(--border);
  border-radius:16px;
  padding:12px;
  box-shadow:0 10px 24px rgba(15,23,42,.04);
  margin-bottom:16px;
}
.amount{max-width:160px}
.mono{font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace}
#toast{
  position:fixed;
  bottom:16px;
  right:16px;
  background:#0f172a;
  color:#fff;
  padding:12px 14px;
  border-radius:12px;
  opacity:0;
  pointer-events:none;
  transition:.2s;
  box-shadow:0 25px 45px rgba(2,6,23,.35);
  z-index:1000;
}
#toast.show{opacity:1}
.link{color:var(--brand-700);font-weight:600;text-decoration:none}
.link:hover{text-decoration:underline}
.nav a{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  padding:10px 16px;
  background:rgba(14,165,233,.15);
  border:1px solid rgba(14,165,233,.35);
  border-radius:12px;
  font-weight:600;
  color:var(--brand-700);
}
.brand{font-size:20px;font-weight:800;color:#fff}
.flex{display:flex;gap:12px;flex-wrap:wrap}
.grid-2{display:grid;grid-template-columns:repeat(auto-fit,minmax(240px,1fr));gap:12px}
.grid-3{display:grid;grid-template-columns:repeat(auto-fit,minmax(200px,1fr));gap:12px}
.grid-4{display:grid;grid-template-columns:repeat(auto-fit,minmax(150px,1fr));gap:12px}
form{display:contents}
@media (max-width:640px){
  .hero-card{
    padding:10px 12px;
    margin-bottom:10px;
    border-radius:18px;
    flex-direction:column;
    align-items:stretch;
  }
  .hero-card h1,
  .hero-card h2{
    font-size:18px;
  }
  .hero-card .hello{
    font-size:16px;
  }
  .hero-actions{
    width:100%;
    justify-content:flex-start;
  }
  button,.btn{
    width:100%;
  }
  .tabs,.tabbar{
    border-radius:20px;
  }
  .bar,
  .row{
    flex-direction:column;
    align-items:stretch;
  }
  .table-wrap{
    max-height:none;
  }
}
