:root {
  --bg: #f3f5f8;
  --panel: #ffffff;
  --panel-2: #eef2f7;
  --text: #1f2937;
  --muted: #6b7280;
  --line: #e2e8f0;
  --accent: #3b82f6;
  --ok: #16a34a;
  --warn: #d97706;
  --bad: #dc2626;
  --new: #dbeafe;
  --gold:   #d4a017;
  --silver: #94a3b8;
  --bronze: #b46c3a;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-feature-settings: "tnum"; overflow-x: hidden; }

header { display: flex; align-items: center; justify-content: space-between;
  padding: 18px 28px; background: var(--panel); border-bottom: 1px solid var(--line); gap: 16px; }
header h1 { margin: 0; font-size: 20px; font-weight: 600; letter-spacing: 0.2px; }
header nav { display: flex; gap: 8px; flex: 1; margin-left: 24px; align-items: center; }
header nav a { color: var(--muted); text-decoration: none; font-size: 13px; font-weight: 500;
  padding: 6px 12px; border-radius: 6px; }
header nav a:hover { background: var(--panel-2); color: var(--text); }
header nav a.active { background: var(--panel-2); color: var(--text); }
header nav a.nav-fb { display: inline-flex; align-items: center; padding: 6px 10px; color: #1877f2; }
header nav a.nav-fb:hover { background: var(--panel-2); color: #1877f2; }
header nav a.nav-fb svg { display: block; }

/* "INTE" protest stamp over the word "Säkra" in the title */
.title-neg { position: relative; display: inline-block; }
.title-stamp {
  position: absolute;
  left: 38%; top: 50%;
  transform: translate(-50%, -52%) rotate(-13deg);
  font-size: 0.52em;
  font-weight: 800;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: #dc2626;
  background: rgba(250, 204, 21, 0.55);
  border: 2.5px solid #dc2626;
  border-radius: 5px;
  padding: 0 4px;
  line-height: 1.2;
  white-space: nowrap;
  pointer-events: none;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.6);
}
.status { font-size: 12px; color: var(--muted); white-space: nowrap; }
.status.err { color: var(--bad); }

.auth { font-size: 12px; color: var(--muted); white-space: nowrap; }
.auth a { color: var(--muted); text-decoration: none; }
.auth a:hover { color: var(--text); text-decoration: underline; }
.auth .badge { background: var(--accent); color: #ffffff; padding: 2px 8px; border-radius: 4px;
  font-weight: 600; font-size: 11px; margin-right: 6px; }

main { padding: 20px 28px; max-width: 1180px; margin: 0 auto; }
@media (max-width: 720px) { main { padding: 14px 12px; } }

/* DS-Digital — 7-segment LED font used for the "Last measured speed" display.
   Shareware (Dusit Supasawat) bundled in /fonts/. See DIGITAL.TXT. */
@font-face {
  font-family: 'DS-Digital';
  src: url('fonts/DS-DIGIB.TTF') format('truetype');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

/* === Intro grid (live page top) === */
.intro-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 22px;
  margin-bottom: 22px;
  align-items: stretch;
}
@media (max-width: 900px) { .intro-grid { grid-template-columns: 1fr; } }

/* "Last measured speed" — light card with an embedded dark LED screen.
   Matches the right intro-text card visually; the dark inset is the "device". */
.last-pass-card {
  --led-on:   #fbbf24;
  --led-off:  rgba(255, 255, 255, 0.075);
  --led-glow: rgba(251, 191, 36, 0.55);
  background: var(--panel);
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  padding: 16px 18px;
  display: flex; flex-direction: column; gap: 12px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08), 0 6px 16px rgba(15, 23, 42, 0.04);
}
.last-pass-card.lo  { --led-on: #4ade80; --led-glow: rgba(74, 222, 128, 0.55);  }
.last-pass-card.mid { --led-on: #fbbf24; --led-glow: rgba(251, 191, 36, 0.55);  }
.last-pass-card.hi  { --led-on: #f87171; --led-glow: rgba(248, 113, 113, 0.6);  }

.lp-top-bar {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 1.6px;
}
.lp-live { display: inline-flex; align-items: center; gap: 6px; color: #dc2626; }
.lp-live-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: #dc2626;
  box-shadow: 0 0 6px rgba(220, 38, 38, 0.6);
  animation: lp-live-pulse 1.4s ease-in-out infinite;
}
@keyframes lp-live-pulse {
  0%, 100% { opacity: 1;   transform: scale(1); }
  50%      { opacity: 0.35; transform: scale(0.85); }
}
.lp-label { color: var(--muted); }

/* The dark "device screen" containing the LED digits. */
.lp-screen {
  position: relative;
  flex: 1;
  display: flex; align-items: center; justify-content: center;
  gap: 14px;
  background:
    radial-gradient(ellipse at top, rgba(255,255,255,0.04) 0%, transparent 60%),
    linear-gradient(180deg, #0a0e16 0%, #141a24 100%);
  border: 1px solid #0f172a;
  border-radius: 8px;
  padding: 10px 14px;
  overflow: hidden;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04), inset 0 0 18px rgba(0, 0, 0, 0.45);
  min-height: 110px;
}
.lp-screen::before {
  content: '';
  position: absolute; inset: 0;
  background: repeating-linear-gradient(0deg, rgba(255,255,255,0.02) 0 1px, transparent 1px 3px);
  pointer-events: none;
}
.lp-digits-wrap {
  position: relative;
  font-family: 'DS-Digital', 'Courier New', monospace;
  font-weight: 700;
  font-size: 84px;
  line-height: 0.9;
  font-variant-numeric: tabular-nums;
  letter-spacing: 2px;
  white-space: nowrap;
}
.lp-digits-ghost { color: var(--led-off); }
.lp-digits-on {
  position: absolute; inset: 0;
  text-align: right;
  color: var(--led-on);
  text-shadow: 0 0 3px var(--led-on), 0 0 14px var(--led-glow);
}
.lp-unit {
  font-size: 16px; font-weight: 700;
  letter-spacing: 2.5px; text-transform: uppercase;
  color: var(--led-on);
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  text-shadow: 0 0 6px var(--led-glow);
  position: relative;
  align-self: flex-end;
  padding-bottom: 6px;
}

.lp-footer {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  font-size: 12px;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}
.lp-footer .lp-dir { font-weight: 700; letter-spacing: 0.8px; text-transform: uppercase; color: var(--text); }
.lp-footer .lp-dir.N { color: #2563eb; }
.lp-footer .lp-dir.S { color: #db2777; }
.lp-footer .lp-when { text-align: right; }

.intro-text {
  background: var(--panel);
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  padding: 22px 24px;
  display: flex; flex-direction: column; justify-content: center;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08), 0 6px 16px rgba(15, 23, 42, 0.04);
}
.intro-title {
  margin: 0 0 12px;
  font-size: 17px; font-weight: 700;
  color: var(--text);
  text-transform: none; letter-spacing: 0;
}
.intro-text p {
  margin: 0 0 16px;
  font-size: 14px; line-height: 1.6;
  color: #374151;
}
.intro-text p strong { color: var(--text); font-weight: 700; }
.intro-cta {
  align-self: flex-start;
  background: var(--accent); color: #ffffff;
  text-decoration: none;
  padding: 9px 18px;
  border-radius: 8px;
  font-size: 13px; font-weight: 600;
  transition: background 0.15s ease;
}
.intro-cta:hover { background: #2563eb; }

/* === FAQ placeholder === */
.faq-section {
  margin-top: 32px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 22px 24px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  scroll-margin-top: 16px;
}
.faq-title {
  margin: 0 0 12px;
  font-size: 17px; font-weight: 700;
  color: var(--text);
  text-transform: none; letter-spacing: 0;
}
.faq-empty {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.faq-list { display: flex; flex-direction: column; gap: 8px; }
.faq-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  overflow: hidden;
}
.faq-item + .faq-item { margin-top: 0; }
.faq-item summary {
  list-style: none;
  cursor: pointer;
  padding: 12px 14px 12px 40px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  position: relative;
  user-select: none;
  line-height: 1.4;
  transition: background-color 0.12s ease;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::before {
  content: '+';
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  text-align: center;
  font-size: 18px;
  font-weight: 500;
  color: var(--accent);
  line-height: 1;
}
.faq-item[open] summary::before { content: '−'; }
.faq-item summary:hover { background: var(--panel-2); }
.faq-item summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
.faq-a {
  padding: 4px 14px 14px 40px;
  font-size: 13px;
  line-height: 1.6;
  color: #374151;
  background: var(--panel);
  border-top: 1px solid var(--line);
}
.faq-a p { margin: 0 0 10px; }
.faq-a p:last-child { margin-bottom: 0; }
.faq-a ol, .faq-a ul { margin: 4px 0 10px; padding-left: 20px; }
.faq-a ol li, .faq-a ul li { margin-bottom: 6px; }
.faq-a ol li:last-child, .faq-a ul li:last-child { margin-bottom: 0; }
.faq-a a { color: var(--accent); text-decoration: none; }
.faq-a a:hover { text-decoration: underline; }

@media (max-width: 720px) {
  .faq-item summary { padding: 10px 12px 10px 34px; font-size: 13px; }
  .faq-item summary::before { left: 12px; font-size: 16px; }
  .faq-a { padding: 4px 12px 12px 34px; font-size: 12.5px; }
}

@media (max-width: 720px) {
  .last-pass-card { padding: 12px 14px; gap: 10px; }
  .lp-screen { min-height: 84px; padding: 8px 12px; gap: 10px; }
  .lp-digits-wrap { font-size: 60px; letter-spacing: 1.5px; }
  .lp-unit  { font-size: 13px; letter-spacing: 2px; padding-bottom: 4px; }
  .lp-top-bar { font-size: 9px; letter-spacing: 1.2px; }
  .lp-footer  { font-size: 11px; }
  .intro-text { padding: 14px 16px; }
  .intro-title, .faq-title { font-size: 15px; }
  .intro-text p { font-size: 13px; }
}

/* === Road animation (side-view perspective) === */
/* Full-bleed: escapes main's max-width / padding to span the whole viewport. */
.road-section {
  margin-bottom: 22px;
  width: 100vw;
  margin-left: calc(50% - 50vw);
  margin-right: calc(50% - 50vw);
}
.road {
  position: relative;
  width: 100%;
  height: 30vh;
  background: linear-gradient(to bottom,
    #cae5ed 0%,            /* sky */
    #b9d8e3 26%,
    #7caa84 32%,           /* distant treeline / hills */
    #9bca8a 39%,           /* mid-distance grass */
    #9bca8a 40%,
    #9ad17f 90%,           /* foreground grass */
    #86c171 100%);
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.asphalt {
  position: absolute; left: 0; right: 0; top: 40%; bottom: 10%;
  background: #3f4854;
  box-shadow: 0 -3px 8px rgba(0,0,0,0.22), 0 3px 6px rgba(0,0,0,0.2);
}
.road-edge { position: absolute; left: 0; right: 0; height: 4px;
  background: repeating-linear-gradient(to right, #e5e7eb 0 14px, #4b5563 14px 28px); }
.road-edge.top    { top: 0; height: 2.8px; }
.road-edge.bottom { bottom: 0; }
/* Median: S lane gets 45% of the asphalt, N lane gets 55% */
.lane-divider {
  position: absolute; left: 0; right: 0; top: 45%; height: 3px; margin-top: -1.5px;
  background: repeating-linear-gradient(to right, #facc15 0 26px, transparent 26px 52px);
  opacity: 0.9;
}
.radar-marker {
  position: absolute; left: 50%; top: 40%; bottom: 10%; width: 2px;
  transform: translateX(-50%);
  background: linear-gradient(to bottom, rgba(255,255,255,0.55), rgba(255,255,255,0.15));
}
.radar-marker::after {
  content: ''; position: absolute; left: 50%; top: -12px; transform: translateX(-50%);
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 8px var(--accent);
}
.compass { position: absolute; color: #1f2937; font-size: 12px; font-weight: 700;
  letter-spacing: 1px; text-transform: uppercase;
  background: rgba(255,255,255,0.78); padding: 2px 7px; border-radius: 4px; }
.compass.left  { left: 12px; top: 51%; transform: translateY(-50%); }
.compass.right { right: 12px; top: 76%; transform: translateY(-50%); }

/* Side-view scenery sprites */
.scenery { position: absolute; inset: 0; pointer-events: none; }
.prop { position: absolute; transform-origin: bottom center; }
.prop.spruce { width: 42px;  height: 112px; transform: scale(var(--scale, 1)); }
.prop.pine   { width: 50px;  height: 100px; transform: scale(var(--scale, 1)); }
.prop.birch  { width: 50px;  height: 100px; transform: scale(var(--scale, 1)); }
.prop.house  { width: 130px; height: 100px; transform: scale(var(--scale, 1));
  filter: drop-shadow(0 3px 3px rgba(0,0,0,0.18)); }
.prop.sign   { width: 28px;  height: 56px;
  filter: drop-shadow(0 2px 2px rgba(0,0,0,0.22)); }

/* Pedestrians (walking on the upper verge) */
.pedestrian {
  position: absolute;
  bottom: 60%;
  left: 0;
  pointer-events: none;
  will-change: transform;
  z-index: 1;
}
/* Small reaction bubble that pops above a pedestrian when a speeder passes */
.ped-bubble {
  position: absolute;
  left: 50%; bottom: 100%;
  margin-bottom: 6px;
  transform: translateX(-50%) scale(0);
  transform-origin: bottom center;
  background: #ffffff;
  border: 1.5px solid #1f2937;
  border-radius: 8px;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 700;
  color: #1f2937;
  white-space: nowrap;
  letter-spacing: 0.3px;
  opacity: 0;
  pointer-events: none;
  box-shadow: 0 2px 4px rgba(0,0,0,0.18);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
.ped-bubble::after {
  content: ''; position: absolute;
  left: 50%; bottom: -7px;
  transform: translateX(-50%);
  width: 0; height: 0;
  border: 5px solid transparent;
  border-top-color: #1f2937;
}
.ped-bubble::before {
  content: ''; position: absolute;
  left: 50%; bottom: -4px;
  transform: translateX(-50%);
  width: 0; height: 0;
  border: 3.5px solid transparent;
  border-top-color: #ffffff;
  z-index: 1;
}
.ped-bubble.visible { animation: bubble-in 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards; }
.ped-bubble.hiding  { animation: bubble-out 0.3s ease-in forwards; }
.pedestrian-inner {
  display: block;
  animation: ped-walk 0.8s ease-in-out infinite;
  transform-origin: bottom center;
}
.pedestrian-inner svg { display: block; }
.pedestrian.dir-left .pedestrian-inner svg { transform: scaleX(-1); }
@keyframes ped-walk {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-1px); }
}
.ped-old-lady     .pedestrian-inner svg { width: 12px; height: 24px; }
.ped-old-man      .pedestrian-inner svg { width: 12px; height: 24px; }
.ped-mom-stroller .pedestrian-inner svg { width: 25px; height: 25px; }
.ped-two-kids     .pedestrian-inner svg { width: 21px; height: 25px; }
.ped-dog          .pedestrian-inner svg { width: 18px; height: 11px; }
.ped-dog       .pedestrian-inner { animation-duration: 0.5s; }
.ped-old-lady  .pedestrian-inner,
.ped-old-man   .pedestrian-inner { animation-duration: 1s; }

/* Cars */
.car-track {
  position: absolute;
  left: 50%; top: 50%;
  pointer-events: none;
  opacity: 0;
  animation: car-enter 0.45s ease-out 0.05s forwards;
  transform: translateX(0);
  will-change: transform, opacity;
  z-index: 2;
}
@keyframes car-enter { to { opacity: 1; } }
/* Lane positions: lane-S is the far (upper) lane, lane-N is the near (lower) lane */
.car-track.lane-S { top: 51%; }
.car-track.lane-N { top: 76%; }
/* Far-lane cars are smaller to imply depth */
.car-track.lane-S .car-inner { transform: translate(-50%, -50%) scale(0.82); }

/* Per-car speech bubble */
.bubble {
  position: absolute;
  left: 50%; bottom: 100%;
  margin-bottom: 56px;
  transform: translateX(-50%) scale(0);
  transform-origin: bottom center;
  background: #ffffff;
  border: 2px solid #1f2937;
  border-radius: 50%;
  padding: 10px 24px;
  font-size: 15px;
  font-weight: 700;
  color: #1f2937;
  white-space: nowrap;
  letter-spacing: 0.4px;
  opacity: 0;
  pointer-events: none;
  box-shadow: 0 3px 7px rgba(0,0,0,0.18);
}
/* Trailing "thought" dots descending from the bubble toward the car */
.bubble::before {
  content: ''; position: absolute;
  left: 50%; bottom: -14px;
  transform: translateX(-50%);
  width: 13px; height: 13px;
  background: #ffffff; border: 1.8px solid #1f2937;
  border-radius: 50%;
  box-shadow: 0 2px 3px rgba(0,0,0,0.15);
}
.bubble::after {
  content: ''; position: absolute;
  left: 50%; bottom: -32px;
  transform: translateX(-50%);
  width: 7px; height: 7px;
  background: #ffffff; border: 1.8px solid #1f2937;
  border-radius: 50%;
  box-shadow: 0 1px 2px rgba(0,0,0,0.15);
}
.bubble.visible { animation: bubble-in 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards; }
.bubble.hiding  { animation: bubble-out 0.3s ease-in forwards; }
@keyframes bubble-in {
  0%   { opacity: 0; transform: translateX(-50%) scale(0.3); }
  100% { opacity: 1; transform: translateX(-50%) scale(1); }
}
@keyframes bubble-out {
  0%   { opacity: 1; transform: translateX(-50%) scale(1); }
  100% { opacity: 0; transform: translateX(-50%) scale(0.7); }
}
.car-inner { position: relative; transform: translate(-50%, -50%); display: block; }
.car-inner svg { display: block; }
.car-track.dir-S .car-inner svg { transform: scaleX(-1); }
.car-track.lo  { --car-color: #22c55e; }
.car-track.mid { --car-color: #f59e0b; }
.car-track.hi  { --car-color: #ef4444; }
.car-tag {
  position: absolute; left: 50%; top: 100%; transform: translateX(-50%);
  margin-top: 3px; font-size: 13px; font-weight: 600; color: #f8fafc;
  background: rgba(15, 23, 42, 0.78); padding: 2px 8px; border-radius: 999px;
  white-space: nowrap; font-variant-numeric: tabular-nums;
}

.kpis { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin-bottom: 24px; }
.live-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 28px; align-items: start; }
.live-left .kpis { grid-template-columns: repeat(2, 1fr); }
.live-left .podium, .live-left .podium-base { max-width: none; }
@media (max-width: 1000px) { .live-grid { grid-template-columns: 1fr; } }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04); }
.kpi .label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.6px; }
.kpi .value { font-size: 22px; font-weight: 600; margin-top: 4px; }
.kpi .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
@media (max-width: 720px) { .kpis { grid-template-columns: repeat(2, 1fr); } }

h2 { font-size: 13px; font-weight: 600; color: var(--muted); text-transform: uppercase;
  letter-spacing: 0.8px; margin: 0 0 10px 2px; }

/* === Podium "Idiots of the day" === */
.podium-section { margin-bottom: 28px; }
.podium { display: grid; grid-template-columns: 1fr 1.2fr 1fr; gap: 12px; align-items: end;
  max-width: 720px; margin: 0 auto; }
.step { background: var(--panel); border: 1px solid var(--line); border-radius: 12px 12px 0 0;
  padding: 18px 14px 22px; text-align: center; position: relative; border-bottom: none;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04); }
.step.empty { opacity: 0.45; }
.step.s1 { min-height: 210px; border-color: var(--gold); }
.step.s2 { min-height: 165px; border-color: var(--silver); }
.step.s3 { min-height: 140px; border-color: var(--bronze); }
.step.s1::before, .step.s2::before, .step.s3::before {
  content: ''; position: absolute; left: 0; right: 0; top: 0; height: 4px;
  border-radius: 12px 12px 0 0;
}
.step.s1::before { background: var(--gold); }
.step.s2::before { background: var(--silver); }
.step.s3::before { background: var(--bronze); }
.step .rank { font-size: 28px; font-weight: 800; line-height: 1; margin-bottom: 6px; }
.step.s1 .rank { color: var(--gold); font-size: 34px; }
.step.s2 .rank { color: var(--silver); }
.step.s3 .rank { color: var(--bronze); }
.step .speed-big { font-size: 26px; font-weight: 700; line-height: 1.1; }
.step.s1 .speed-big { font-size: 32px; }
.step .speed-big .unit { font-size: 0.55em; font-weight: 500; color: var(--muted); margin-left: 4px; }
.step .meta { font-size: 12px; color: var(--muted); margin-top: 6px; }
.step .meta .arrow { font-weight: 700; margin: 0 4px; }
.step .meta .arrow.N { color: #2563eb; }
.step .meta .arrow.S { color: #db2777; }
.podium-base { background: var(--panel-2); border: 1px solid var(--line); border-top: none;
  border-radius: 0 0 12px 12px; height: 14px; max-width: 720px; margin: 0 auto; }

/* === Charts === */
.charts { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 24px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 16px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04); }
.card h3 { margin: 0 0 8px 0; font-size: 13px; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.6px; }
.chart-wrap { position: relative; height: 240px; }
@media (max-width: 900px) { .charts { grid-template-columns: 1fr; } }

/* === Enforcement-window heatmaps === */
.ew-section { margin-bottom: 28px; }
.ew-reco {
  background:
    radial-gradient(ellipse at top right, rgba(255,255,255,0.5) 0%, transparent 55%),
    linear-gradient(135deg, #dcfce7 0%, #bbf7d0 100%);
  border: 1px solid #16a34a;
  border-radius: 12px;
  padding: 16px 20px;
  margin-bottom: 18px;
}
.ew-reco-label {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px;
  color: #15803d; margin-bottom: 4px;
}
.ew-reco-main { font-size: 20px; font-weight: 700; color: #14532d; line-height: 1.25; }
.ew-reco-main strong { color: #166534; }
.ew-reco-sub { font-size: 13px; color: #15803d; margin-top: 6px; line-height: 1.5; }
.ew-reco-sub strong { color: #14532d; }

.ew-heatmaps { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 760px) { .ew-heatmaps { grid-template-columns: 1fr; } }
.ew-heatmap {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px 16px 16px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}
.ew-heatmap-title {
  display: flex; align-items: center; gap: 7px;
  font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.6px;
  color: var(--muted); margin-bottom: 10px;
}
.ew-dir-dot { width: 9px; height: 9px; border-radius: 50%; }
.ew-dir-dot.N { background: #2563eb; }
.ew-dir-dot.S { background: #db2777; }

.ew-grid {
  display: grid;
  grid-template-columns: auto repeat(6, 1fr);
  gap: 3px;
}
.ew-corner { }
.ew-colhead {
  font-size: 9.5px; font-weight: 600; color: var(--muted);
  text-align: center; padding-bottom: 2px;
  font-variant-numeric: tabular-nums;
}
.ew-rowhead {
  font-size: 11px; font-weight: 600; color: var(--muted);
  display: flex; align-items: center; padding-right: 6px;
}
.ew-cell {
  aspect-ratio: 1 / 1;
  display: flex; align-items: center; justify-content: center;
  border-radius: 4px;
  font-size: 12px; font-weight: 700;
  font-variant-numeric: tabular-nums;
  cursor: default;
}
.ew-cell.best {
  outline: 2.5px solid #15803d;
  outline-offset: -2.5px;
  box-shadow: 0 0 0 2px rgba(21, 128, 61, 0.25);
}

.ew-legend {
  display: flex; align-items: center; gap: 10px;
  margin-top: 14px;
  font-size: 11px; color: var(--muted);
}
.ew-legend-ramp {
  flex: 0 0 140px; height: 10px; border-radius: 5px;
  background: linear-gradient(90deg, rgba(220,38,38,0.06) 0%, rgba(220,38,38,0.92) 100%);
  border: 1px solid var(--line);
}
.ew-note {
  margin: 14px 0 0;
  font-size: 12px; line-height: 1.6; color: var(--muted);
}
.ew-note strong { color: var(--text); }
.ew-note em { font-style: italic; }

@media (max-width: 720px) {
  .ew-reco-main { font-size: 17px; }
  .ew-cell { font-size: 11px; }
  .ew-colhead { font-size: 8.5px; }
}

/* === Table === */
.table-wrap { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; overflow: hidden;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead th { text-align: left; font-weight: 500; color: var(--muted); font-size: 11px;
  text-transform: uppercase; letter-spacing: 0.6px; padding: 10px 16px;
  background: var(--panel-2); border-bottom: 1px solid var(--line); }
tbody td { padding: 10px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr.row { transition: background-color 1.4s ease-out; }
tbody tr.row.is-new { background-color: var(--new); }
tbody tr.detail td { background: var(--panel-2); padding: 14px 18px; }

td.t      { color: var(--muted); font-variant-numeric: tabular-nums; }
td.dir    { font-weight: 600; }
td.dir.N  { color: #2563eb; }
td.dir.S  { color: #db2777; }
td.speed  { font-variant-numeric: tabular-nums; font-weight: 600; }
td.speed.lo  { color: var(--ok); }
td.speed.mid { color: var(--warn); }
td.speed.hi  { color: var(--bad); }
td.num    { font-variant-numeric: tabular-nums; color: var(--muted); }
td.acc    { font-variant-numeric: tabular-nums; color: var(--muted); }
td.label  { color: var(--text); }

/* admin column visibility */
body:not(.is-admin) .admin-only { display: none !important; }

/* expand toggle */
td.expand-cell { width: 28px; padding-left: 16px; padding-right: 0; }
.expand-btn { background: transparent; border: none; color: var(--muted); cursor: pointer;
  font-size: 14px; line-height: 1; padding: 4px 6px; border-radius: 4px; }
.expand-btn:hover { background: var(--line); color: var(--text); }
.expand-btn.open { color: var(--accent); transform: rotate(90deg); }

/* detail row */
.detail-block { display: flex; gap: 18px; flex-wrap: wrap; }
.detail-block .raw {
  flex: 1 1 480px;
  max-height: 240px; overflow: auto;
  background: var(--panel); border: 1px solid var(--line); border-radius: 6px;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 12px;
  white-space: pre; padding: 10px 12px; color: var(--text);
}
.detail-block .label-edit { flex: 0 0 280px; display: flex; flex-direction: column; gap: 6px; }
.detail-block .label-edit label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.6px; }
.detail-block .label-edit input { background: var(--panel); border: 1px solid var(--line); color: var(--text);
  border-radius: 6px; padding: 8px 10px; font-size: 13px; }
.detail-block .label-edit input:focus { outline: none; border-color: var(--accent); }
.detail-block .label-edit .row { display: flex; gap: 6px; align-items: center; }
.detail-block .label-edit button { background: var(--accent); color: #ffffff; border: none;
  border-radius: 6px; padding: 8px 14px; font-size: 13px; font-weight: 600; cursor: pointer; }
.detail-block .label-edit button:disabled { opacity: 0.5; cursor: default; }
.detail-block .label-edit .saved { color: var(--ok); font-size: 12px; }

/* === Login form === */
.login-main { max-width: 380px; margin: 0 auto; }
.login-card { margin-top: 60px; }
.login-card h3 { margin: 0 0 14px 0; font-size: 14px; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.6px; font-weight: 600; }
.login-input { width: 100%; background: var(--panel); border: 1px solid var(--line);
  color: var(--text); border-radius: 6px; padding: 10px 12px; font-size: 14px; margin-bottom: 10px; }
.login-input:focus { outline: none; border-color: var(--accent); }
.login-btn { width: 100%; background: var(--accent); color: #ffffff; border: none;
  border-radius: 6px; padding: 10px; font-size: 14px; font-weight: 600; cursor: pointer; }
.login-err { color: var(--bad); font-size: 12px; margin-top: 10px; }

/* === Stats view header (date-range title + view tabs + day picker) === */
.stats-head { margin-bottom: 12px; }
.stats-kicker {
  font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 1px;
  color: var(--muted); margin-bottom: 3px;
}
.stats-daterange {
  margin: 0; font-size: 28px; font-weight: 800; letter-spacing: -0.4px;
  color: var(--text); line-height: 1.1;
}
@media (max-width: 720px) { .stats-daterange { font-size: 21px; } }

.view-nav {
  display: inline-flex; gap: 2px;
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 9px; padding: 4px; margin-bottom: 18px;
  max-width: 100%; overflow-x: auto;
}
.view-nav a {
  text-decoration: none; white-space: nowrap;
  padding: 7px 16px; border-radius: 6px;
  font-size: 13px; font-weight: 500; color: var(--muted);
  transition: background 0.15s ease, color 0.15s ease;
}
.view-nav a:hover { color: var(--text); }
.view-nav a.active {
  background: var(--panel); color: var(--text); font-weight: 600;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.1);
}

.day-picker, .week-picker { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }
.day-picker button, .week-picker button {
  background: var(--panel-2); border: 1px solid var(--line); color: var(--muted);
  border-radius: 7px; padding: 7px 14px; font-size: 13px; font-weight: 500;
  font-family: inherit; cursor: pointer; transition: background 0.15s ease, color 0.15s ease;
}
.day-picker button:hover, .week-picker button:hover { color: var(--text); }
.day-picker button.active, .week-picker button.active { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.week-picker button[data-week="prev"], .week-picker button[data-week="next"] {
  font-size: 18px; line-height: 1; padding: 5px 13px; font-weight: 700;
}
.week-picker button:disabled { opacity: 0.4; cursor: default; color: var(--muted); }
.week-picker button:disabled:hover { color: var(--muted); }
.day-input {
  background: var(--panel); border: 1px solid var(--line); color: var(--text);
  border-radius: 7px; padding: 6px 10px; font-size: 13px; font-family: inherit;
}
.day-input:focus { outline: none; border-color: var(--accent); }

/* === Range filter (Stats page) === */
.range-filter {
  display: inline-flex;
  gap: 2px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 4px;
  margin-bottom: 22px;
  max-width: 100%;
  overflow-x: auto;
  scrollbar-width: thin;
}
.range-filter button {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  padding: 7px 14px;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
  font-family: inherit;
  transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}
.range-filter button:hover { color: var(--text); }
.range-filter button.active {
  background: var(--panel);
  color: var(--text);
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.1);
}

/* === Fines dashboard === */
.fines-card { margin-bottom: 28px; }
.fines-headline {
  position: relative;
  background:
    radial-gradient(ellipse at top right, rgba(255,255,255,0.55) 0%, transparent 55%),
    linear-gradient(135deg, #fef3c7 0%, #fcd34d 100%);
  border: 1px solid #d97706;
  border-radius: 12px;
  padding: 22px 24px;
  margin: 8px 0 18px 0;
  text-align: center;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.55), 0 1px 3px rgba(146, 64, 14, 0.12);
  overflow: hidden;
}
.fines-headline::before {
  content: '';
  position: absolute;
  top: -32px; right: -32px;
  width: 140px; height: 140px;
  background: radial-gradient(circle, rgba(255,255,255,0.55) 0%, transparent 65%);
  pointer-events: none;
}
.fines-total {
  font-size: 48px; font-weight: 800;
  color: #78350f;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.5px;
  line-height: 1.05;
  text-shadow: 0 1px 0 rgba(255,255,255,0.5);
  position: relative;
}
.fines-sub { font-size: 13px; color: #92400e; margin-top: 6px; position: relative; }

.fines-table {
  width: 100%; border-collapse: collapse;
  margin-bottom: 12px;
}
.fines-table thead th {
  text-align: left; font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.6px;
  color: var(--muted); padding: 9px 12px;
  background: var(--panel-2);
  border-bottom: 1px solid var(--line);
}
.fines-table th.num, .fines-table td.num { text-align: right; }
.fines-table tbody td {
  padding: 10px 12px; font-size: 13px;
  color: var(--text);
  border-bottom: 1px solid var(--line);
  font-variant-numeric: tabular-nums;
}
.fines-table tbody tr.zero td { color: var(--muted); opacity: 0.6; }
.fines-table td.strong { font-weight: 700; }

.fines-total-row td {
  padding: 12px;
  background: linear-gradient(180deg, rgba(254, 243, 199, 0.7) 0%, rgba(252, 211, 77, 0.6) 100%);
  border-top: 2px solid #d97706;
  border-bottom: none !important;
  font-weight: 700;
  font-size: 13px;
  color: #78350f;
  text-transform: uppercase;
  letter-spacing: 0.6px;
}
.fines-total-row td.num.strong {
  font-size: 15px;
  letter-spacing: 0;
  text-transform: none;
}

.fines-note {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.5;
  padding: 4px 2px 10px 2px;
  margin-bottom: 4px;
}
.fines-note strong { color: var(--text); font-weight: 700; }

.fines-court {
  background: rgba(220, 38, 38, 0.10);
  border: 1px solid rgba(220, 38, 38, 0.32);
  color: #991b1b;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
}
.fines-court strong { font-weight: 700; }

/* === GC-väg cost comparison (lives inside .charts grid as a half-width card) === */
.gcvag-card { display: flex; flex-direction: column; }
.gcvag-title {
  margin: 0 0 6px;
  font-size: 15px; font-weight: 700;
  color: var(--text);
  text-transform: none; letter-spacing: 0;
  line-height: 1.3;
}
.gcvag-sub {
  margin: 0 0 14px;
  font-size: 12px; line-height: 1.5;
  color: var(--muted);
}
.gcvag-sub strong { color: var(--text); font-weight: 700; }

.gcvag-bar-block {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px 10px;
  margin-bottom: 12px;
}
.gcvag-amount { display: flex; align-items: baseline; gap: 6px; margin-bottom: 10px; flex-wrap: wrap; }
.gcvag-current {
  font-size: 22px; font-weight: 800;
  color: #16a34a;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.3px;
}
.gcvag-of { font-size: 12px; color: var(--muted); }
.gcvag-of strong { color: var(--text); font-weight: 700; }

.gcvag-bar {
  position: relative;
  height: 24px;
  background: linear-gradient(180deg, rgba(15,23,42,0.06) 0%, rgba(15,23,42,0.10) 100%);
  border: 1px solid #cbd5e1;
  border-radius: 5px;
  overflow: hidden;
}
.gcvag-fill {
  position: absolute; top: 0; bottom: 0; left: 0;
  width: 0;
  background: linear-gradient(90deg, #4ade80 0%, #16a34a 100%);
  transition: width 0.7s cubic-bezier(0.22, 1, 0.36, 1);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.35);
}
.gcvag-tick {
  position: absolute; top: -4px; bottom: -4px;
  width: 0;
  border-left: 2px dashed rgba(15, 23, 42, 0.45);
  pointer-events: none;
}

.gcvag-axis {
  position: relative;
  display: flex; justify-content: space-between;
  font-size: 11px; font-weight: 600;
  color: var(--muted);
  margin-top: 8px;
  font-variant-numeric: tabular-nums;
}
.gcvag-axis small { display: block; font-size: 10px; font-weight: 500; opacity: 0.85; }
.gcvag-axis-mid {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
}
.gcvag-axis-end { text-align: right; }

.gcvag-pct {
  margin-top: 10px;
  font-size: 12px;
  color: #374151;
  padding-top: 10px;
  border-top: 1px dashed var(--line);
  line-height: 1.5;
}
.gcvag-pct strong { color: var(--text); font-weight: 700; }

.gcvag-context p {
  margin: 0 0 8px;
  font-size: 12px; line-height: 1.55;
  color: #374151;
}
.gcvag-context p:last-child { margin-bottom: 0; }
.gcvag-context strong { color: var(--text); font-weight: 700; }
.gcvag-tip { font-style: italic; color: var(--muted) !important; }

@media (max-width: 720px) {
  .gcvag-title { font-size: 14px; }
  .gcvag-current { font-size: 20px; }
  .gcvag-axis { font-size: 10px; }
  .gcvag-axis small { font-size: 9px; }
}

/* === Mobile responsive cleanup === */
@media (max-width: 720px) {
  /* Header — wrap, shrink title, no more pushing nav off-screen */
  header {
    flex-wrap: wrap;
    padding: 10px 14px;
    gap: 6px 12px;
    row-gap: 6px;
  }
  header h1 {
    font-size: 14px;
    flex-basis: 100%;
    line-height: 1.25;
  }
  header nav { margin-left: 0; flex: 0 1 auto; gap: 4px; }
  header nav a { padding: 4px 8px; font-size: 12px; }
  .status { font-size: 11px; }
  .auth   { font-size: 11px; }

  /* KPIs — let cells shrink, tighter padding, smaller type */
  .kpis { gap: 8px; }
  .kpi { padding: 10px 10px; min-width: 0; }
  .kpi .label { font-size: 10px; letter-spacing: 0.4px; line-height: 1.15; }
  .kpi .value { font-size: 18px; }
  .kpi .sub   { font-size: 11px; }

  /* Podium / Idiots — compress so it fits */
  .podium { gap: 6px; }
  .step { padding: 12px 6px 16px; min-width: 0; }
  .step .rank { font-size: 22px; }
  .step.s1 .rank { font-size: 28px; }
  .step .speed-big { font-size: 20px; }
  .step.s1 .speed-big { font-size: 24px; }
  .step .meta { font-size: 11px; }

  /* Recent passes table — tighter cells, allow horizontal scroll as a safety */
  .table-wrap { overflow-x: auto; }
  thead th { padding: 8px 10px; font-size: 10px; }
  tbody td { padding: 8px 10px; font-size: 13px; }
  td.expand-cell { width: 22px; padding-left: 10px; }

  /* Detail row contents — stack vertically on narrow widths */
  .detail-block .raw { flex: 1 1 100%; max-height: 180px; }
  .detail-block .label-edit { flex: 1 1 100%; }

  /* Fines card */
  .fines-headline { padding: 16px 14px; }
  .fines-total { font-size: 32px; }
  .fines-sub   { font-size: 11px; }
  .fines-table thead th,
  .fines-table tbody td { padding: 7px 8px; font-size: 11px; }
  .fines-table thead th { letter-spacing: 0.4px; }
  .fines-total-row td { padding: 9px 8px; font-size: 11px; }
  .fines-total-row td.num.strong { font-size: 13px; }
}
