:root {
  --bg: #f3f6fb;
  --surface: #ffffff;
  --surface-2: #eef3f9;
  --ink: #14213d;
  --muted: #667085;
  --line: #e4e9f1;
  --primary: #0b6e69;
  --primary-dark: #07524f;
  --accent: #ffb000;
  --positive: #15803d;
  --danger: #c2413b;
  --sidebar: #0d1b2a;
  --shadow: 0 14px 36px rgba(23, 37, 61, .08);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Inter", sans-serif;
  color: var(--ink);
  background: var(--bg);
}
button, input, select { font: inherit; }
button { cursor: pointer; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 260px 1fr; }
.sidebar {
  position: sticky; top: 0; height: 100vh; padding: 26px 20px;
  background: var(--sidebar); color: white; display: flex; flex-direction: column;
}
.brand { display: flex; gap: 12px; align-items: center; margin-bottom: 36px; }
.brand-mark {
  width: 44px; height: 44px; display: grid; place-items: center; border-radius: 13px;
  background: linear-gradient(135deg, #23b5aa, #0b6e69); font-weight: 800;
}
.brand h1 { margin: 0; font-size: 20px; }
.brand p { margin: 3px 0 0; color: #9fb0c2; font-size: 12px; }
nav { display: grid; gap: 8px; }
.nav-item {
  border: 0; border-radius: 10px; padding: 12px 14px; text-align: left;
  background: transparent; color: #aab9c9;
}
.nav-item.active, .nav-item:hover { color: white; background: rgba(255,255,255,.09); }
.data-panel {
  margin-top: auto; padding: 16px; border: 1px solid rgba(255,255,255,.1);
  border-radius: 14px; background: rgba(255,255,255,.045);
}
.eyebrow { margin: 0 0 6px; text-transform: uppercase; letter-spacing: .11em; font-size: 11px; font-weight: 700; color: var(--muted); }
.eyebrow.light { color: rgba(255,255,255,.72); }
.upload-btn, .secondary-btn {
  width: 100%; display: block; padding: 10px 12px; border-radius: 9px; text-align: center;
}
.upload-btn { background: var(--primary); margin: 10px 0 8px; font-size: 13px; font-weight: 700; }
.secondary-btn { border: 1px solid rgba(255,255,255,.17); background: transparent; color: white; font-size: 12px; }
#dataStatus { min-height: 30px; margin: 10px 0 0; color: #9fb0c2; font-size: 11px; line-height: 1.4; }
.live-card { display: flex; align-items: center; gap: 10px; margin-top: 16px; font-size: 12px; }
.live-card small { display: block; color: #8fa0b2; margin-top: 2px; }
.live-dot { width: 9px; height: 9px; border-radius: 50%; background: #45d483; box-shadow: 0 0 0 5px rgba(69,212,131,.12); }

main { min-width: 0; padding: 28px 30px 18px; }
.topbar { display: flex; align-items: end; justify-content: space-between; gap: 24px; margin-bottom: 22px; }
.topbar h2 { margin: 0; font-size: clamp(24px, 3vw, 34px); letter-spacing: -.03em; }
.filters { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; }
.filters label { display: grid; gap: 5px; color: var(--muted); font-size: 11px; font-weight: 600; }
.filters input, .filters select {
  min-width: 135px; border: 1px solid var(--line); border-radius: 9px; padding: 9px 10px; background: white; color: var(--ink);
}
.filters button { border: 0; border-radius: 9px; padding: 10px 18px; background: var(--ink); color: white; font-weight: 700; }

.reward-hero {
  display: grid; grid-template-columns: 1.2fr 1px .8fr 1px .8fr 1.1fr; align-items: center; gap: 26px;
  padding: 26px 28px; border-radius: 20px; color: white;
  background: radial-gradient(circle at 92% 10%, rgba(255,176,0,.35), transparent 30%), linear-gradient(130deg, #07524f, #0b6e69 58%, #128178);
  box-shadow: var(--shadow); overflow: hidden;
}
.reward-hero h3 { margin: 0 0 6px; font-size: clamp(32px, 4vw, 48px); letter-spacing: -.04em; }
.reward-hero p { margin: 0; color: rgba(255,255,255,.78); font-size: 13px; }
.reward-divider { width: 1px; height: 64px; background: rgba(255,255,255,.22); }
.reward-label { margin-bottom: 8px !important; }
.reward-hero strong { display: block; font-size: 23px; }
.reward-hero span { display: block; margin-top: 5px; color: rgba(255,255,255,.7); font-size: 12px; }
.progress-copy { display: flex; justify-content: space-between; margin-bottom: 9px; }
.progress-copy span, .progress-copy strong { font-size: 12px; margin: 0; }
.progress-track { height: 10px; border-radius: 999px; background: rgba(255,255,255,.18); overflow: hidden; }
.progress-track div { height: 100%; width: 0; border-radius: inherit; background: #ffd166; transition: width .5s ease; }

.kpi-grid { display: grid; grid-template-columns: repeat(5, minmax(150px, 1fr)); gap: 14px; margin: 18px 0; }
.kpi-card { padding: 18px; border-radius: 15px; background: var(--surface); box-shadow: var(--shadow); border: 1px solid rgba(228,233,241,.85); }
.kpi-card span { display: block; color: var(--muted); font-size: 12px; }
.kpi-card strong { display: inline-block; margin-top: 12px; font-size: 25px; letter-spacing: -.03em; }
.kpi-card small { margin-left: 5px; color: var(--muted); font-size: 11px; }
.rating-card { background: linear-gradient(145deg, #fff9e8, #fff); }

.chart-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.chart-card { min-width: 0; padding: 20px; border-radius: 17px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); }
.chart-card.wide { grid-column: 1 / -1; }
.chart-heading { min-height: 44px; display: flex; justify-content: space-between; align-items: start; gap: 12px; margin-bottom: 12px; }
.chart-heading h3 { margin: 0; font-size: 17px; }
.insight-pill { padding: 7px 10px; border-radius: 99px; background: #e8f6f4; color: var(--primary-dark); font-size: 11px; font-weight: 700; }
.chart-wrap { position: relative; height: 290px; }
.doughnut-wrap { height: 290px; max-width: 440px; margin: auto; }
footer { display: flex; justify-content: space-between; padding: 22px 2px 0; color: var(--muted); font-size: 11px; }
.toast { display: none; position: fixed; right: 24px; bottom: 24px; z-index: 20; padding: 13px 16px; border-radius: 10px; background: var(--ink); color: white; box-shadow: var(--shadow); font-size: 13px; }

.fleet-summary {
  margin-bottom: 22px; padding: 22px 24px; border-radius: 20px;
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow);
}
.fleet-summary-heading { display: flex; justify-content: space-between; align-items: start; gap: 12px; margin-bottom: 16px; }
.fleet-summary-heading h3 { margin: 0; font-size: 18px; }
.fleet-totals { display: grid; grid-template-columns: repeat(6, minmax(120px, 1fr)); gap: 12px; margin-bottom: 18px; }
.fleet-total-card {
  padding: 14px 16px; border-radius: 13px; background: var(--surface-2); border: 1px solid var(--line);
}
.fleet-total-card span { display: block; color: var(--muted); font-size: 11px; margin-bottom: 6px; }
.fleet-total-card strong { display: block; font-size: 19px; letter-spacing: -.02em; }
.fleet-total-card.highlight { background: linear-gradient(145deg, #e8f6f4, #fff); border-color: rgba(11,110,105,.25); }
.fleet-table-wrap { overflow-x: auto; }
.fleet-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.fleet-table th {
  text-align: left; padding: 10px 12px; color: var(--muted); font-size: 11px; text-transform: uppercase;
  letter-spacing: .06em; border-bottom: 1px solid var(--line); white-space: nowrap;
}
.fleet-table td { padding: 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.fleet-table td small { color: var(--muted); }
.fleet-table tbody tr[data-vehicle] { cursor: pointer; transition: background .15s ease; }
.fleet-table tbody tr[data-vehicle]:hover { background: var(--surface-2); }
.fleet-empty { text-align: center; color: var(--muted); padding: 22px !important; white-space: normal !important; }
.rating-pill { padding: 5px 10px; border-radius: 99px; background: #e8f6f4; color: var(--primary-dark); font-size: 11px; font-weight: 700; }
.driver-detail-empty {
  display: flex; align-items: center; justify-content: center; min-height: 140px; margin-bottom: 22px;
  border-radius: 17px; border: 1px dashed var(--line); background: var(--surface-2); color: var(--muted);
  font-size: 14px; text-align: center; padding: 24px;
}

@media (max-width: 1180px) {
  .fleet-totals { grid-template-columns: repeat(3, 1fr); }
  .kpi-grid { grid-template-columns: repeat(3, 1fr); }
  .reward-hero { grid-template-columns: 1fr 1fr; }
  .reward-divider { display: none; }
}
@media (max-width: 850px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: relative; height: auto; }
  nav { display: none; }
  .data-panel { margin-top: 10px; }
  .topbar { align-items: start; flex-direction: column; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .chart-grid { grid-template-columns: 1fr; }
  .chart-card.wide { grid-column: auto; }
  .fleet-totals { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 520px) {
  main { padding: 20px 14px; }
  .reward-hero { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: 1fr; }
  .filters { width: 100%; }
  .filters label, .filters input, .filters select, .filters button { width: 100%; }
}
