:root {
  --bg: #0f1419;
  --text: #e7ecf1;
  --muted: #8b9aab;
  --accent: #3d9be9;
  --panel: #1a222c;
}

* { box-sizing: border-box; }

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

.truck-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid #2a3544;
}

.truck-header h1 { margin: 0 0 0.25rem; font-size: 1.35rem; }
.hint { color: var(--muted); font-size: 0.9rem; margin: 0; }
.empty { padding: 1.25rem; color: var(--muted); }

.drive-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.drive-list a {
  display: block;
  padding: 0.85rem 1.25rem;
  border-bottom: 1px solid #2a3544;
  color: var(--text);
  text-decoration: none;
}

.drive-list a:hover { background: var(--panel); }
.drive-list span { color: var(--muted); font-size: 0.85rem; margin-left: 0.5rem; }

.drive-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem 1.25rem;
}

.drive-main {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: min(100%, 16rem);
  flex: 1;
}

.drive-purpose {
  font-size: 1.05rem;
  font-weight: 600;
}

.drive-when,
.drive-route {
  margin-left: 0 !important;
  color: var(--muted);
  font-size: 0.85rem;
}

.drive-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem 1rem;
  align-items: stretch;
}

.drive-stat {
  display: flex;
  flex-direction: column;
  min-width: 4.25rem;
  margin-left: 0 !important;
}

.drive-stat-label {
  color: var(--muted);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-left: 0 !important;
}

.drive-stat-value {
  color: var(--text) !important;
  font-size: 1rem !important;
  font-variant-numeric: tabular-nums;
  margin-left: 0 !important;
  font-weight: 600;
}

.drive-detail-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  margin: 0.5rem 0 0;
  color: var(--text);
  font-size: 0.95rem;
}

.drive-detail-stats span {
  color: var(--muted);
}

.drive-detail-stats span::before {
  content: "";
}

.drive-map {
  height: 55vh;
  min-height: 280px;
  width: 100%;
}

.heatmap-page {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.heatmap-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 0.5rem 1.5rem;
  flex-shrink: 0;
}

.heatmap-header .nav-links {
  margin: 0;
}

.heat-map {
  flex: 1;
  width: 100%;
  min-height: 70vh;
  background: #0a0e12;
}

.heat-map .leaflet-container {
  background: #0a0e12;
  font: inherit;
}

.charts {
  padding: 1rem 1.25rem 2rem;
  display: grid;
  gap: 1rem;
}

.charts canvas {
  background: var(--panel);
  border-radius: 8px;
  width: 100%;
}

.analytics-section {
  margin: 0 1.25rem 1.5rem;
  position: relative;
}

.analytics-section h2 {
  font-size: 1rem;
  color: var(--muted);
  margin: 0 0 0.75rem;
}

.chart-wrap {
  margin: 0.5rem 0 1rem;
}

.chart-wrap canvas {
  background: var(--panel);
  border-radius: 8px;
  width: 100%;
}

.energy-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1rem;
  margin: 1rem 1.25rem;
}

.energy-summary-six {
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
}

.charge-progress-wrap {
  margin: 0 1.25rem 0.75rem;
}

.charge-progress-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.charge-progress-bar {
  height: 10px;
  background: #2a3544;
  border-radius: 999px;
  overflow: hidden;
}

.charge-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #22c55e, #38bdf8);
  transition: width 0.4s ease;
}

.energy-stat {
  background: var(--panel);
  border-radius: 8px;
  padding: 0.75rem 1rem;
}

.energy-stat .label {
  color: var(--muted);
  font-size: 0.8rem;
}

.energy-stat .value {
  font-size: 1.35rem;
  font-weight: 600;
}

.energy-stat .meta {
  font-size: 0.8rem;
  color: var(--muted, #8b9aab);
}

.energy-stat .meta.rate-ref {
  color: #94a3b8;
  font-size: 0.75rem;
}

.status-table .rate-ref {
  color: #94a3b8;
}

.cell-meta {
  font-size: 0.72rem;
  color: #94a3b8;
  margin-top: 0.15rem;
}

.stale-badge {
  font-size: 0.65rem;
  color: #f97316;
  margin-left: 0.25rem;
}

.status-charts {
  margin: 0 1.25rem 1rem;
}

.chart-foot {
  margin: 0;
  font-size: 0.8rem;
}

.legend-swatch { margin-right: 0.15rem; }
.legend-cool { color: #38bdf8; }
.legend-heat { color: #f87171; }
.legend-off { color: #8b9aab; }
.legend-ref { color: #38bdf8; }
.legend-bill { color: #22c55e; }
.legend-roll { color: #f59e0b; }
.spend-legend .legend-swatch { margin-left: 0.75rem; }
.spend-legend .legend-swatch:first-child { margin-left: 0; }

.spend-chart-tooltip {
  position: absolute;
  z-index: 20;
  min-width: 12rem;
  max-width: 22rem;
  padding: 0.55rem 0.7rem;
  background: #0f1419;
  border: 1px solid #3d4f63;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  color: var(--text);
  font-size: 0.82rem;
  line-height: 1.35;
  pointer-events: auto;
}

.spend-chart-tooltip .tip-date {
  font-weight: 600;
  margin-bottom: 0.2rem;
}

.spend-chart-tooltip .tip-meta {
  color: var(--muted);
  font-size: 0.75rem;
  margin-bottom: 0.45rem;
}

.spend-chart-tooltip .tip-empty {
  color: var(--muted);
}

.spend-chart-tooltip .tip-item {
  display: block;
  color: var(--text);
  text-decoration: none;
  padding: 0.2rem 0;
  border-top: 1px solid #2a3544;
}

.spend-chart-tooltip a.tip-item:hover {
  color: var(--accent);
}

.insight-list {
  margin: 0 0 1rem;
  padding-left: 1.2rem;
  color: var(--text);
  font-size: 0.92rem;
}

.insight-list li {
  margin: 0.35rem 0;
  color: #c5d0db;
}

.report-subhead {
  font-size: 0.9rem;
  color: var(--muted);
  font-weight: 600;
  margin: 1rem 0 0.5rem;
}

.report-table {
  margin: 0 0 1rem !important;
  width: 100%;
}

.report-columns {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem 1.5rem;
}

.rank-list {
  list-style: decimal;
  margin: 0;
  padding-left: 1.25rem;
}

.rank-list li {
  margin: 0.45rem 0;
}

.rank-list a {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  text-decoration: none;
  color: var(--text);
}

.rank-list a:hover strong {
  color: var(--accent);
}

.rank-list span {
  color: var(--muted);
  font-size: 0.82rem;
}
.chart-foot .legend-swatch + span,
.chart-foot .legend-cool,
.chart-foot .legend-heat,
.chart-foot .legend-off { margin-right: 0.75rem; }

.table-foot {
  margin: 0.5rem 1.25rem 1rem;
  font-size: 0.8rem;
}

.status-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  margin: 0 1.25rem 1rem;
}

.status-table th,
.status-table td {
  padding: 0.45rem 0.6rem;
  border-bottom: 1px solid #2a3544;
  text-align: left;
}

.status-table th { color: var(--muted); font-weight: 500; }

.ac-cell.ac-on { color: #38bdf8; }
.ac-cell.ac-heat { color: #f59e0b; }
.ac-cell.ac-defrost { color: #f97316; }

.nav-links {
  margin: 0.5rem 0 0;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem 1rem;
}
.nav-links a { margin-right: 0; }
.nav-logout {
  margin-left: auto;
  color: var(--muted);
  font-size: 0.85rem;
}

.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1.5rem;
}
.login-card {
  width: min(380px, 100%);
  background: var(--panel);
  border: 1px solid #2a3544;
  border-radius: 16px;
  padding: 2.25rem 1.75rem;
  text-align: center;
}
.login-title { margin: 0 0 0.35rem; font-size: 1.5rem; }
.login-sub { color: var(--muted); margin: 0 0 1.75rem; }
.login-hint {
  margin: 1.25rem 0 0;
  font-size: 0.75rem;
  color: var(--muted);
}
.btn-google {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  width: 100%;
  padding: 0.85rem 1.25rem;
  background: #fff;
  color: #3c4043;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 500;
  text-decoration: none;
  box-sizing: border-box;
}
.btn-google:hover { filter: brightness(0.97); }
.nav-links a.nav-current {
  color: var(--text);
  font-weight: 600;
  text-decoration: none;
  border-bottom: 2px solid var(--accent);
  padding-bottom: 0.1rem;
}

.free-badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  color: #86efac;
  background: rgba(34, 197, 94, 0.15);
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
}

.overview-section .energy-summary {
  margin: 0.5rem 0 0.75rem;
}

a { color: var(--accent); }
