/* ===================================================================
   älg // DASH — design tokens
   Palette: graphite night + glacier ice + oak amber (sparingly)
   Type: Manrope (display/body) + IBM Plex Mono (data/telemetry)
   Signature: instrument-cluster gauges with a needle-sweep reveal
=================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;600;700;800&family=IBM+Plex+Mono:wght@400;500;600&display=swap');

:root {
  --bg: #0F1319;
  --surface: #161C24;
  --surface-raised: #1D2530;
  --line: #29323D;
  --line-soft: #1F2731;

  --ice: #8FD3E8;
  --ice-dim: rgba(143, 211, 232, 0.14);
  --oak: #D98A4A;
  --oak-dim: rgba(217, 138, 74, 0.16);

  --text: #EDEFF2;
  --text-muted: #8792A1;
  --text-faint: #576373;

  --good: #7FD9A6;
  --warn: #E0B23D;
  --danger: #E2685F;
  --danger-dark: #932E28;

  /* Pastel text colors used on top of low-opacity tinted panels
     (error banners, alert pills, service notices) — split out as their
     own variables specifically so the light theme can swap them for
     darker equivalents; the pale versions below read fine on this
     dark background but would be nearly invisible on a light one. */
  --danger-text: #F3B4AE;
  --warn-text: #EFD9A0;
  --service-warn-text: #FCE58A;

  --radius: 16px;
  --radius-sm: 10px;
  --font-display: 'Manrope', system-ui, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, monospace;
}

/*
 * Light theme — same semantic variable names, redesigned values, not
 * a mechanical inversion. Every accent color that worked as a bright
 * pop against near-black needed re-checking for contrast against a
 * light background instead; several needed to go noticeably darker
 * and more saturated to stay legible (e.g. --ice went from a pale sky
 * blue to a real teal, since the original would practically vanish on
 * white). Applied via a data-theme attribute on <html>, set server-side
 * from the logged-in user's saved preference — no flash of the wrong
 * theme on load.
 */
[data-theme="light"] {
  --bg: #F1F4F7;
  --surface: #FFFFFF;
  --surface-raised: #F1F3F6;
  --line: #D7DEE5;
  --line-soft: #E8ECF0;

  --ice: #0E7FA3;
  --ice-dim: rgba(14, 127, 163, 0.10);
  --oak: #B8611F;
  --oak-dim: rgba(184, 97, 31, 0.12);

  --text: #1A2027;
  --text-muted: #5B6572;
  --text-faint: #7C8794;

  --good: #1E9E5C;
  --warn: #A9760A;
  --danger: #C93B31;
  --danger-dark: #7A2019;

  --danger-text: #93261C;
  --warn-text: #7A5A0A;
  --service-warn-text: #6B5500;
}

/*
 * Swedish theme — navy base with real blue in it (not neutral gray),
 * white text, and the flag's blue/gold reimagined as the accent pair
 * rather than used as literal surface colors — flat flag-yellow as a
 * background or running text turns out harsh and low-contrast at any
 * real size, so gold here is a softer, warmer variant that still
 * reads unmistakably "the flag" without being uncomfortable to look
 * at. Status colors (good/warn/danger) deliberately stay the same
 * semantic colors as the other themes — green still means OK, red
 * still means trouble — the Swedish identity lives in the base
 * surfaces, text, and primary accent, not in overriding what a status
 * color means.
 */
[data-theme="swedish"] {
  --bg: #0A1428;
  --surface: #0F1D38;
  --surface-raised: #16274A;
  --line: #2A3F66;
  --line-soft: #1C2D50;

  --ice: #E0AE3E;
  --ice-dim: rgba(224, 174, 62, 0.14);
  --oak: #7EC4E8;
  --oak-dim: rgba(126, 196, 232, 0.16);

  --text: #F5F8FC;
  --text-muted: #9FB4D6;
  --text-faint: #64789E;

  --good: #7FD9A6;
  --warn: #E0B23D;
  --danger: #E2685F;
  --danger-dark: #932E28;

  --danger-text: #F3B4AE;
  --warn-text: #EFD9A0;
  --service-warn-text: #FCE58A;
}
[data-theme="swedish"] body {
  background-image:
    radial-gradient(circle at 15% -10%, rgba(224,174,62,0.07), transparent 45%),
    radial-gradient(circle at 100% 10%, rgba(126,196,232,0.06), transparent 40%);
}

/*
 * Fuel gauge and lease gauge tiers, Swedish theme only — deliberately
 * NOT routed through --good/--oak, since those are already repurposed
 * as this theme's general accent pair (gold/sky-blue) and using them
 * here would mean the gauge's "warning" tier renders as blue instead
 * of a warning color. These tiers get their own explicit colors:
 * flag-yellow for "fine", a genuine orange for "watch it", and the
 * same red used everywhere else for "trouble" — the red tier doesn't
 * need to change, red already means the same thing in every theme.
 */
[data-theme="swedish"] .gauge.tier-green .value-ring { stroke: #FECC02; }
[data-theme="swedish"] .gauge.tier-orange .value-ring { stroke: #E8821E; }
[data-theme="swedish"] .lease-gauge .value-ring { stroke: #FECC02; }
[data-theme="swedish"] .lease-gauge.time-warn .value-ring { stroke: #E8821E; }
/* Driving-history bars unified to the same flag-yellow as the gauges
   above, instead of the softer general accent gold (--ice) — those
   were two visibly different yellows sitting side by side. */
[data-theme="swedish"] .month-box-bar { background: #FECC02; }

* { box-sizing: border-box; }

/* Always reserves scrollbar-gutter space, whether or not a given page
   is actually tall enough to need one — without this, a short page
   (Profile) and a tall one (Dashboard) have slightly different
   *available* widths, so the centered .main/.topbar/.site-footer
   content shifts a few pixels left or right depending on which page
   you're on. This is what made navigating between pages feel like
   things were subtly moving around. */
html {
  overflow-y: scroll;
  scrollbar-gutter: stable;
}

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-display);
}

body {
  background-image:
    radial-gradient(circle at 15% -10%, rgba(143,211,232,0.06), transparent 45%),
    radial-gradient(circle at 100% 10%, rgba(217,138,74,0.05), transparent 40%);
}
/* Same idea, much subtler — the dark theme's gradient wash reads as
   moody atmosphere; at full strength on a light background it just
   looks like a smudge. */
[data-theme="light"] body {
  background-image:
    radial-gradient(circle at 15% -10%, rgba(14,127,163,0.05), transparent 45%),
    radial-gradient(circle at 100% 10%, rgba(184,97,31,0.04), transparent 40%);
}

a { color: inherit; }

button, input {
  font-family: inherit;
}

::selection { background: var(--ice-dim); color: var(--text); }

/* ---------- Topographic backdrop (login) ---------- */
.contour-field {
  position: fixed;
  inset: 0;
  z-index: 0;
  opacity: 0.5;
  pointer-events: none;
}

/* ---------- Login ---------- */
.login-page-wrap {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.login-shell {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 40px 32px 32px;
  box-shadow: 0 30px 60px -20px rgba(0,0,0,0.55);
  position: relative;
}

.login-mark {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  margin-bottom: 28px;
}

/* Same clean flag-patch style, but hanging off the bottom edge of a
   vehicle card instead of sitting flush in a seam — positioned at 75%
   across, not centered, per your placement request. Lives on the
   OUTER .car-card (overflow: visible) so it can actually spill past
   the card's own bottom border; .car-card-inner still clips
   everything else (photo bleed, corner glow) as before.
   Landscape, matching the real Swedish flag's actual proportions
   (roughly 8:5 width:height) rather than the arbitrary portrait shape
   this had before — straddles the bottom border line symmetrically. */
.car-card-flag-tag {
  position: absolute;
  bottom: -21px;
  left: 85%;
  transform: translateX(-50%);
  width: 30px;
  height: 19px;
  background: #006AA7;
  box-shadow: 0 2px 5px rgba(0,0,0,0.45);
  z-index: 2;
}
.car-card-flag-tag::before {
  content: '';
  position: absolute;
  left: 10px; top: 0;
  width: 4px; height: 100%;
  background: #FECC02;
}
.car-card-flag-tag::after {
  content: '';
  position: absolute;
  left: 0; top: 7.5px;
  width: 100%; height: 4px;
  background: #FECC02;
}

.login-logo {
  height: 44px;
  width: auto;
  display: block;
}

.login-mark .dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--ice);
  box-shadow: 0 0 12px var(--ice);
}

.login-mark span {
  font-size: 13px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 600;
}

.login-card h1 {
  font-size: 22px;
  font-weight: 700;
  margin: 0 0 20px;
}

#loginLoadingView {
  text-align: center;
  padding: 20px 0;
}
.login-spinner {
  width: 32px;
  height: 32px;
  margin: 0 auto 16px;
  border: 3px solid var(--line);
  border-top-color: var(--ice);
  border-radius: 50%;
  animation: login-spin 0.8s linear infinite;
}
@keyframes login-spin {
  to { transform: rotate(360deg); }
}
.login-loading-text {
  color: var(--text-muted);
  font-size: 14px;
  margin: 0;
}

.login-card p.sub {
  font-size: 14px;
  color: var(--text-muted);
  margin: 0 0 28px;
}

.field {
  margin-bottom: 16px;
}

.field label {
  display: block;
  font-size: 12px;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.field input {
  width: 100%;
  padding: 12px 14px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s ease;
}

.field input:focus {
  border-color: var(--ice);
}

/*
 * Same dark styling as .field input above, but NOT scoped to a .field
 * wrapper — this is the actual root cause of most look-inconsistent
 * form controls in Admin: any input/select/textarea sitting in a plain
 * div instead of .field (the Driver dropdown, custom-greetings
 * textarea, several others) fell through to the browser's stock
 * light-mode appearance with no styling at all. One general rule here
 * closes that gap everywhere at once, rather than chasing individual
 * missed spots one at a time.
 */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="search"],
select,
textarea {
  padding: 12px 14px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s ease;
}
input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="number"]:focus,
input[type="date"]:focus,
input[type="search"]:focus,
select:focus,
textarea:focus {
  border-color: var(--ice);
}
select { cursor: pointer; }
/* For selects that also carry a fixed inline height (Driver, Access
   level) — the general select rule's padding (12px top+bottom, 24px
   total) barely leaves room for the text inside a 38px box, which is
   what was actually making that text look cramped/hard to read, not
   a font or color issue this time. Less vertical padding here so the
   text has proper breathing room within that fixed height. */
.select-compact {
  padding: 6px 10px;
}
/* Native <select> controls render custom web fonts unreliably across
   browsers — a well-known category of quirk since the browser's own
   widget-rendering path for a select's displayed value doesn't always
   handle an arbitrary @font-face the same way ordinary page text does.
   Using a plain system-font stack here instead of the site's Manrope
   avoids that whole class of rendering risk for this one element. */
select { font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif; }

/*
 * Tells the browser to render its own native controls (the file-picker
 * button, date-picker popup calendar, scrollbars in supporting
 * browsers) in a palette appropriate to the current theme, instead of
 * always defaulting to stock OS light mode regardless of what theme
 * the rest of the app is in — this is what actually fixes "Choose
 * File" looking like a foreign light-gray button next to otherwise
 * dark-styled controls.
 */
:root, [data-theme="dark"], [data-theme="swedish"] { color-scheme: dark; }
[data-theme="light"] { color-scheme: light; }
/* Selects specifically excluded from the dark scheme above — some
   browsers layer their own native dark-mode text rendering on top of
   a custom-colored select's displayed value, producing a doubled/
   ghosted look. We already fully hand-style select's colors, so we
   don't need (or want) the browser's own dark-native assistance here;
   forcing it back to light-scheme for this one element keeps the
   file-picker/date-picker fix everywhere else intact. */
select { color-scheme: light; }

input[type="file"] {
  color: var(--text-muted);
  font-size: 13px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.1s ease, filter 0.15s ease;
}

.btn:active { transform: translateY(1px); }

.btn-primary {
  background: var(--ice);
  color: #0B1116;
}
.btn-primary:hover { filter: brightness(1.08); }

.btn-ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--text-muted);
}
.btn-ghost:hover { border-color: var(--ice); color: var(--text); }

.error-banner {
  background: rgba(226,104,95,0.12);
  border: 1px solid rgba(226,104,95,0.35);
  color: var(--danger-text);
  font-size: 13px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
}

/* ---------- App shell ---------- */
.topbar-outer {
  border-bottom: 1px solid var(--line-soft);
}
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1100px;
  margin: 0 auto;
  padding: 20px 24px;
}

.brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.brand-logo {
  height: 40px;
  width: auto;
  display: block;
}
/* Two logo files, swapped per theme — the wordmark's text color is
   baked into the PNG's pixels, not styled via CSS, so it can't adapt
   to the theme the way everything else does. White text is invisible
   on Light's near-white background; a separate dark-text variant
   (generated by inverting only the grayscale pixels, leaving the
   flag's actual blue/yellow untouched) fixes that. */
.brand-logo-light { display: none; }
[data-theme="light"] .brand-logo-dark { display: none; }
[data-theme="light"] .brand-logo-light { display: block; }

.brand-divider {
  width: 100%;
  height: 1px;
  background: var(--line-soft);
  margin: 5px 0;
}

.brand-tagline {
  font-family: var(--font-display);
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.18em;
  color: var(--text-faint);
  text-transform: uppercase;
  white-space: nowrap;
  text-align: center;
  width: 100%;
}

.brand .dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--ice);
  box-shadow: 0 0 10px var(--ice);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 13px;
  color: var(--text-muted);
}

.topbar-user-menu { position: relative; }

.topbar-menu-trigger {
  display: flex;
  align-items: center;
  gap: 10px;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font-display);
  transition: background 0.15s ease;
}
.topbar-menu-trigger:hover { background: var(--surface-raised); }

.topbar-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--surface-raised);
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--ice);
  overflow: hidden;
  flex-shrink: 0;
}
.topbar-avatar img { width: 100%; height: 100%; object-fit: cover; }

.topbar-username {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.topbar-hamburger {
  width: 16px;
  height: 16px;
  color: var(--text-faint);
  flex-shrink: 0;
}

.topbar-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 160px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  box-shadow: 0 12px 28px -8px rgba(0,0,0,0.5);
  padding: 6px;
  z-index: 20;
  flex-direction: column;
}
.topbar-dropdown.open { display: flex; }
.topbar-dropdown a {
  display: block;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--text);
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
}
.topbar-dropdown a:hover { background: var(--surface-raised); }

.topbar-dropdown-divider {
  height: 1px;
  background: var(--line-soft);
  margin: 6px 4px;
}
.topbar-theme-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
  padding: 4px 12px 2px;
}
.topbar-theme-row {
  display: flex;
  gap: 4px;
  padding: 0 4px;
  margin-bottom: 2px;
}
.topbar-theme-row .topbar-theme-option {
  flex: 1;
  justify-content: center;
  padding: 8px 6px !important;
  font-size: 12px !important;
  border-radius: var(--radius-sm);
}
.topbar-theme-option {
  display: flex !important;
  align-items: center;
  gap: 6px;
}
.topbar-theme-option.active {
  background: var(--surface-raised);
  color: var(--ice) !important;
}
.theme-flag-icon {
  display: inline-block;
  width: 14px;
  height: 10px;
  background: #006AA7;
  position: relative;
  flex-shrink: 0;
}
.theme-flag-icon::before {
  content: '';
  position: absolute;
  left: 4.5px; top: 0;
  width: 2px; height: 100%;
  background: #FECC02;
}
.theme-flag-icon::after {
  content: '';
  position: absolute;
  left: 0; top: 4px;
  width: 100%; height: 2px;
  background: #FECC02;
}

.main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 36px 24px 80px;
  position: relative;
  z-index: 1;
}

.site-footer {
  max-width: 1100px;
  margin: 0 auto;
  padding: 20px 24px 32px;
  border-top: 1px solid var(--line-soft);
  text-align: center;
  font-size: 12px;
  color: var(--text-faint);
}
.site-footer p { margin: 4px 0; }
.footer-pocketdc a {
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 600;
}
.footer-pocketdc a:hover { color: var(--ice); text-decoration: underline; }
.footer-divider { margin: 0 4px; color: var(--line); }

.page-head {
  margin-bottom: 28px;
}

.fleet-summary-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-bottom: 28px;
}
.fleet-summary-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
}
.fleet-stat {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 160px;
}
.fleet-stat .stat-icon {
  width: 26px;
  height: 26px;
  color: var(--ice);
  flex-shrink: 0;
}
.fleet-stat-value {
  font-family: var(--font-mono);
  font-size: 19px;
  font-weight: 600;
  color: var(--text);
}
.fleet-errors {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line-soft);
}
.fleet-error-line {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--danger-text);
  margin-bottom: 4px;
}
.fleet-error-line .stat-icon {
  width: 16px;
  height: 16px;
  color: var(--danger);
  flex-shrink: 0;
}

.page-head h1 {
  font-size: 26px;
  margin: 0 0 4px;
}

.page-head p {
  color: var(--text-muted);
  margin: 0;
  font-size: 14px;
}

.empty-state {
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 48px 32px;
  text-align: center;
  color: var(--text-muted);
}

.empty-state a { color: var(--ice); font-weight: 600; }

/* ---------- Vehicle grid ---------- */
.garage-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 20px;
}

.car-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  position: relative;
  overflow: visible; /* lets the hanging flag tag spill past the bottom edge */
}

.car-card-inner {
  padding: 24px;
  border-radius: inherit;
  overflow: hidden; /* everything else (photo bleed, corner glow) still clips normally */
  position: relative;
}

.car-card-inner::before {
  content: '';
  position: absolute;
  top: -60px; right: -60px;
  width: 180px; height: 180px;
  background: radial-gradient(circle, var(--ice-dim), transparent 70%);
  pointer-events: none;
}

.car-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 18px;
}

.car-head h2 {
  font-size: 18px;
  margin: 0 0 4px;
}

.car-head .vin {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-faint);
  letter-spacing: 0.03em;
}

.sync-pill {
  font-size: 11px;
  color: var(--text-muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 10px;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  background: transparent;
}
.sync-pill:hover { border-color: var(--ice); color: var(--text); }
.sync-pill svg { width: 12px; height: 12px; }

/* Gauge cluster */
.gauge-row {
  display: flex;
  align-items: center;
  gap: 22px;
  margin-bottom: 20px;
}

.gauge {
  position: relative;
  width: 108px;
  height: 108px;
  flex-shrink: 0;
}

.gauge svg { width: 100%; height: 100%; transform: rotate(-90deg); }

.gauge .track {
  fill: none;
  stroke: var(--line-soft);
  stroke-width: 8;
}

.gauge .value-ring {
  fill: none;
  stroke: var(--ice);
  stroke-width: 8;
  stroke-linecap: round;
  stroke-dasharray: 264;
  stroke-dashoffset: 264;
  transition: stroke-dashoffset 1.1s cubic-bezier(0.16, 1, 0.3, 1);
}

.gauge.tier-green .value-ring { stroke: var(--good); }
.gauge.tier-orange .value-ring { stroke: var(--oak); }
.gauge.tier-red .value-ring { stroke: var(--danger); }
.gauge.tier-darkred .value-ring { stroke: var(--danger-dark); }
.value-ring.estimated { opacity: 0.7; } /* visually distinct from a real API reading */

.gauge-label {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.gauge-value-row {
  display: flex;
  align-items: center;
  gap: 4px;
}

.gauge-label .num {
  font-family: var(--font-mono);
  font-size: 22px;
  font-weight: 600;
}
.gauge-label .unit {
  font-size: 10px;
  color: var(--text-muted);
  letter-spacing: 0.05em;
}

.gauge-meta {
  flex: 1;
}

.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 16px;
}

.stat-cell { min-width: 0; }

.stat-label {
  font-size: 12px;
  color: var(--text-muted);
}

.stat-value {
  font-family: var(--font-mono);
  font-size: 20px;
  font-weight: 600;
  color: var(--text);
  margin-top: 2px;
}

/*
 * Shared "smaller unit suffix" class — used everywhere a number is
 * followed by a unit that should read as half-size (fuel gauge "%",
 * range/odometer "km", fuel "L", lease "km", driving-stats
 * "km"/"L/100km"/"km/h"). One class, one place to tune — change this
 * single rule to adjust all of them at once rather than hunting down
 * every individual spot.
 */
.unit-sm {
  font-size: 0.5em;
  font-weight: 600;
}

.stat-icon {
  width: 20px;
  height: 20px;
  color: var(--text-faint);
  flex-shrink: 0;
  display: inline-block;
  vertical-align: -4px;
}
/* Overrides the broad ".gauge svg { width:100%; height:100%;
   transform: rotate(-90deg); }" rule (meant for the ring/track SVG)
   which would otherwise also stretch and rotate this icon, since it's
   nested inside .gauge too. */
.gauge .stat-icon {
  width: 20px !important;
  height: 20px !important;
  transform: none !important;
}

.info-grid-2col {
  display: flex;
  gap: 20px;
}
.info-col-left {
  flex: 2;
  min-width: 0;
}
.info-col-right {
  flex: 3;
  min-width: 0;
  padding-left: 20px;
  border-left: 1px solid var(--line-soft);
}

.gauge-meta .odo {
  margin-top: 14px;
  font-size: 14px;
  color: var(--text-muted);
}

.gauge-meta .odo b {
  font-family: var(--font-mono);
  color: var(--text);
  font-weight: 600;
  font-size: 15px;
}

/* Status pills */
.status-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 6px;
}
.status-row .pill {
  justify-content: center;
  width: 100%;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--surface-raised);
  border: 1px solid var(--line);
  color: var(--text-muted);
}

.pill .led {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--text-faint);
}

.pill.ok .led { background: var(--good); box-shadow: 0 0 6px var(--good); }
.pill.ok { color: var(--text); }

.pill.alert .led { background: var(--danger); box-shadow: 0 0 6px var(--danger); }
.pill.alert { color: var(--danger-text); border-color: rgba(226,104,95,0.35); }

.pill.warn .led { background: var(--warn); box-shadow: 0 0 6px var(--warn); }
.pill.warn { color: var(--warn-text); border-color: rgba(224,178,61,0.35); }

/* Swedish flag yellow — distinct from the amber .warn above, used
   specifically for the service-due "approaching" tier. */
.pill.service-warn .led { background: #FECC02; box-shadow: 0 0 6px #FECC02; }
.pill.service-warn { color: var(--service-warn-text); border-color: rgba(254,204,2,0.35); }

.service-due-notice {
  margin-top: 10px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  background: rgba(226,104,95,0.1);
  border: 1px solid rgba(226,104,95,0.25);
  color: var(--danger-text);
}

/* ---------- "Car in motion" cue (shown only while engine is running) ---------- */

/* Pulsing glow on the engine pill — Swedish flag yellow (#FECC02) */
@keyframes pill-pulse-glow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(254,204,2,0.55); }
  50% { box-shadow: 0 0 0 5px rgba(254,204,2,0); }
}
.pill-pulse { animation: pill-pulse-glow 1.8s ease-in-out infinite; }

/* Pulsing glow on the whole card — same yellow, same rhythm as the
   engine pill above so the two breathe in sync. Box-shadow rather than
   an animated gradient position, which renders far more smoothly. */
@keyframes card-pulse-glow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(254,204,2,0.4); }
  50% { box-shadow: 0 0 0 8px rgba(254,204,2,0); }
}
.car-card.is-driving {
  border-color: rgba(254,204,2,0.45);
  animation: card-pulse-glow 1.8s ease-in-out infinite;
}

/* ---------- "Door/window open" cue — red, and deliberately takes
   visual priority over the ice-blue "driving" cue above if both were
   ever true at once (an open door matters more than the engine state). ---------- */
@keyframes pill-pulse-glow-alert {
  0%, 100% { box-shadow: 0 0 0 0 rgba(226,104,95,0.55); }
  50% { box-shadow: 0 0 0 5px rgba(226,104,95,0); }
}
.pill-pulse-alert { animation: pill-pulse-glow-alert 1.4s ease-in-out infinite; }

@keyframes card-pulse-glow-alert {
  0%, 100% { box-shadow: 0 0 0 0 rgba(226,104,95,0.4); }
  50% { box-shadow: 0 0 0 8px rgba(226,104,95,0); }
}
.car-card.is-open {
  border-color: rgba(226,104,95,0.45);
  animation: card-pulse-glow-alert 1.4s ease-in-out infinite;
}

/* ---------- Leasing contract tracker ---------- */
.lease-info {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line-soft);
}
.lease-top {
  display: flex;
  align-items: stretch;
  gap: 18px;
  margin-bottom: 14px;
}
.lease-left {
  flex: 3;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.lease-left-row {
  display: flex;
  align-items: flex-start;
  gap: 18px;
}
.lease-gauge { width: 76px; height: 76px; flex-shrink: 0; margin-top: 4px; }
.lease-gauge .value-ring { stroke: var(--ice); }
.lease-gauge.time-warn .value-ring { stroke: var(--oak); }
.lease-gauge.time-critical .value-ring { stroke: var(--danger); }
.lease-gauge .num { font-size: 17px; }
.lease-gauge-extra { margin-top: auto; padding-top: 10px; }
.lease-gauge-extra .service-line { margin-bottom: 4px; }
.lease-dates { flex: 1; min-width: 0; }

.lease-km-row {
  display: flex;
  gap: 14px;
  margin-bottom: 8px;
}
.lease-km-block { flex: 1; }

.lease-diff {
  font-size: 13px;
  font-weight: 600;
  padding: 6px 0;
}
.lease-diff.km-ok { color: var(--good); }
.lease-diff.km-warn { color: var(--warn); }
.lease-diff.km-critical { color: var(--danger); }

.lease-status {
  flex: 2;
  min-width: 0;
  padding-left: 20px;
  border-left: 1px solid var(--line-soft);
  display: flex;
  flex-direction: column;
}
.lease-status .lease-diff {
  margin-top: auto;
}

.lease-settlement {
  margin-top: 8px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  text-align: center;
}
.lease-settlement.settle-owe {
  background: rgba(226,104,95,0.1);
  border: 1px solid rgba(226,104,95,0.25);
  color: var(--danger-text);
}
.lease-settlement.settle-refund {
  background: rgba(127,217,166,0.1);
  border: 1px solid rgba(127,217,166,0.25);
  color: var(--good);
}
.lease-settlement b { font-family: var(--font-mono); }

/* ---------- Driving Stats (trip meters + monthly fuel/driving) ---------- */
.monthly-stats {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line-soft);
}

.location-section {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line-soft);
}
.vehicle-map {
  width: 100%;
  height: 160px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--surface-raised);
}
.location-meta {
  margin-top: 10px;
}
.location-meta .service-line { margin-bottom: 4px; }

.trip-stats-row {
  display: flex;
  gap: 20px;
  margin-bottom: 4px;
}
.trip-stats-col {
  flex: 1;
  min-width: 0;
}
.stat-block-sm {
  margin-bottom: 8px;
}
.fuel-usage-info {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line-soft);
}
.month-history {
  margin-top: 18px;
}
.month-history-row {
  display: flex;
  gap: 6px;
  align-items: flex-end;
}
.month-box {
  flex: 1;
  text-align: center;
  background: var(--surface-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 8px 4px 6px;
}
.month-box-bar-wrap {
  height: 44px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  margin-bottom: 6px;
}
.month-box-bar {
  width: 10px;
  background: var(--ice);
  border-radius: 3px 3px 0 0;
}
.month-box-km {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}
.month-box-label {
  font-size: 10px;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 2px;
}

.no-data {
  font-size: 12px;
  color: var(--text-faint);
  font-style: italic;
}

/* ---------- Active warnings detail list ---------- */
.warning-list {
  margin-top: 10px;
  padding: 10px 12px;
  background: rgba(226,104,95,0.06);
  border: 1px solid rgba(226,104,95,0.2);
  border-radius: var(--radius-sm);
}
.warning-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 12px;
  padding: 4px 0;
  color: var(--text);
}
.warning-item .warning-status {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--danger-text);
  white-space: nowrap;
}

/* ---------- Connectivity dot ---------- */
.conn-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-left: 8px;
  vertical-align: middle;
}
.conn-online { background: var(--good); box-shadow: 0 0 6px var(--good); }
.conn-offline { background: var(--text-faint); }

/* ---------- Service info ---------- */
.service-info {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line-soft);
}
.service-line {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 5px;
}
.service-line b {
  font-family: var(--font-mono);
  color: var(--text);
  font-weight: 600;
  font-size: 15px;
}
.service-line b.nowrap-value {
  white-space: nowrap;
  display: inline-block;
}

/* ---------- Vehicle photo ---------- */
.car-photo {
  margin: -24px -24px 18px;
  height: 210px;
  overflow: hidden;
  background: var(--surface-raised);
}
.car-photo img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
  image-rendering: -webkit-optimize-contrast; /* sharper downscale in Chrome/Safari */
}

/* ---------- Command buttons ---------- */
.command-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line-soft);
}
.command-row-left {
  display: flex;
  align-items: center;
}
/* Matches .cmd-btn's vertical padding (8px, vs the pill's normal 6px)
   so the Locked/Unlocked pill sits at the same height as the buttons
   it's next to, instead of looking shorter by direct comparison. */
.command-row-left .pill {
  padding: 8px 10px;
}
.command-buttons-group {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.cmd-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-display);
  font-size: 12.5px;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface-raised);
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.1s ease;
}
.cmd-btn:hover { border-color: var(--ice); }
.cmd-btn:active { transform: translateY(1px); }
.cmd-btn:disabled { opacity: 0.6; cursor: default; }

.cmd-icon {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

.cmd-btn-pin {
  border-color: rgba(217,138,74,0.4);
  color: var(--oak);
}
.cmd-btn-pin:hover { border-color: var(--oak); }

.lock-unknown {
  font-size: 11px;
  color: var(--text-faint);
  font-style: italic;
  align-self: center;
  margin-right: 4px;
}

/* ---------- PIN confirmation modal ---------- */
.pin-modal {
  position: fixed;
  inset: 0;
  background: rgba(6,9,13,0.7);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 20px;
}
.pin-modal.open { display: flex; }

.pin-modal-card {
  width: 100%;
  max-width: 320px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
}
.pin-modal-card h3 { margin: 0 0 6px; font-size: 17px; }
.pin-modal-card .panel-sub { margin: 0 0 16px; }

.pin-modal-card input {
  width: 100%;
  text-align: center;
  letter-spacing: 0.4em;
  font-size: 22px;
  font-family: var(--font-mono);
  padding: 12px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--text);
  outline: none;
}
.pin-modal-card input:focus { border-color: var(--oak); }

.pin-modal-error {
  min-height: 18px;
  font-size: 12px;
  color: var(--danger);
  margin-top: 8px;
}

.pin-modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}
.pin-modal-actions .btn { flex: 1; width: auto !important; }

/* ---------- Admin page ---------- */
.notice-banner {
  background: rgba(127,217,166,0.12);
  border: 1px solid rgba(127,217,166,0.35);
  color: var(--good);
  font-size: 13px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  margin-bottom: 20px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
}
.panel h2 { margin: 0 0 6px; font-size: 17px; }
.panel-sub { color: var(--text-muted); font-size: 13px; margin: 0 0 16px; }

.check-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
}
.check-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg);
  cursor: pointer;
}
.check-item input { accent-color: var(--ice); }
.pin-badge {
  margin-left: auto;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--oak);
  border: 1px solid rgba(217,138,74,0.4);
  border-radius: 999px;
  padding: 2px 6px;
}

.status-ok { color: var(--good); }
.status-warn { color: var(--warn); }

.vehicle-edit-row {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 20px 0;
  border-top: 1px solid var(--line-soft);
}
.vehicle-edit-row:first-of-type { border-top: none; }

.vehicle-box {
  background: var(--surface-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 16px;
}
.vehicle-box:has(.thumb) {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

.thumb {
  width: 96px; height: 72px;
  flex-shrink: 0;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
}
.thumb-lg { width: 120px; height: 90px; }
/* Dedicated square avatar size — .thumb-lg above is 120x90 (built for
   rectangular vehicle photos); forcing border-radius:50% onto a
   non-square box produces an oval, not a circle, which is exactly
   what was happening where this got reused for user avatars. */
.thumb-avatar { width: 96px; height: 96px; border-radius: 50%; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb-placeholder {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; color: var(--text-faint);
}

.vehicle-box-layout {
  display: flex;
  gap: 20px;
  align-items: flex-start;
}
.vehicle-box-columns {
  display: flex;
  flex: 1;
  min-width: 0;
}
.vehicle-col { padding: 0 20px; min-width: 0; }
.vehicle-col:first-child { padding-left: 0; }
.vehicle-col-1 { flex: 0 0 40%; }
.vehicle-col-2 { flex: 0 0 30%; border-left: 1px solid var(--line-soft); }
.vehicle-col-3 { flex: 0 0 30%; border-left: 1px solid var(--line-soft); }
.vehicle-col-3 .panel-sub { font-size: 11px; margin-bottom: 8px; }

.form-actions-right {
  display: flex;
  justify-content: flex-end;
  margin-top: 16px;
}

.field-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.field-row input[type="file"] { font-size: 12px; color: var(--text-muted); max-width: 220px; }
.vin { font-family: var(--font-mono); font-size: 11px; color: var(--text-faint); margin-bottom: 8px; }

.lease-admin-columns {
  display: flex;
  gap: 24px;
}
.lease-admin-col { flex: 1; min-width: 0; }
.lease-admin-col + .lease-admin-col {
  padding-left: 24px;
  border-left: 1px solid var(--line-soft);
}

.log-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}
.log-table th, .log-table td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line-soft);
  color: var(--text-muted);
}
.log-table th { color: var(--text-faint); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; }
.log-table .mono { font-family: var(--font-mono); }

.log-status {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
}
.log-sent { color: var(--good); background: rgba(127,217,166,0.12); }
.log-failed, .log-pin_rejected, .log-not_permitted { color: var(--danger); background: rgba(226,104,95,0.12); }

/* ---------- Admin tabs ---------- */
.admin-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--line-soft);
  padding-bottom: 0;
}
.admin-tab-btn {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 10px 14px;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.admin-tab-btn:hover { color: var(--text); }
.admin-tab-btn.active {
  color: var(--ice);
  border-bottom-color: var(--ice);
}

.discover-row {
  padding: 14px 0;
  border-top: 1px solid var(--line-soft);
}
.discover-row:first-of-type { border-top: none; }
.discover-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.discover-head .vin { font-weight: 600; font-size: 14px; }

/* ---------- Weather widget ---------- */
.weather-widget {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line-soft);
}

.weather-alerts {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}
.weather-alert {
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
}
.weather-alert-warn {
  color: var(--warn);
  background: rgba(224,178,61,0.12);
  border: 1px solid rgba(224,178,61,0.35);
}
.weather-alert-alert {
  color: var(--danger-text);
  background: rgba(226,104,95,0.12);
  border: 1px solid rgba(226,104,95,0.35);
}

.weather-now {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}
.weather-icon { display: inline-flex; width: 34px; height: 34px; color: var(--ice); }
.weather-icon svg { width: 100%; height: 100%; }
.weather-icon-sun { color: var(--oak); }
.weather-icon-thunder { color: var(--warn); }
.weather-temp { font-family: var(--font-mono); font-size: 26px; font-weight: 600; }
.weather-label { font-size: 14px; color: var(--text-muted); }

.weather-hourly-row {
  display: flex;
  gap: 8px;
  flex: 1;
  justify-content: flex-end;
  overflow-x: auto;
  min-width: 0;
}
.weather-hour-chip {
  flex: 0 0 auto;
  text-align: center;
  min-width: 30px;
}
.weather-hour-chip .hour-label {
  font-size: 9px;
  color: var(--text-faint);
  text-transform: uppercase;
}
.weather-hour-chip .hour-icon {
  display: block;
  width: 16px;
  height: 16px;
  margin: 3px auto;
  color: var(--ice);
}
.weather-hour-chip .hour-icon svg { width: 100%; height: 100%; }
.weather-hour-chip .hour-icon.weather-icon-sun { color: var(--oak); }
.weather-hour-chip .hour-icon.weather-icon-thunder { color: var(--warn); }
.weather-hour-chip .hour-temp {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text);
}

.weather-days {
  display: flex;
  gap: 8px;
}
.weather-day {
  flex: 1;
  text-align: center;
  background: var(--surface-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 6px;
}
.weather-day-name {
  font-size: 13px;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}
.weather-day-icon { display: flex; justify-content: center; width: 28px; height: 28px; margin: 0 auto 6px; color: var(--ice); }
.weather-day-icon svg { width: 100%; height: 100%; }
.weather-day-icon.weather-icon-sun { color: var(--oak); }
.weather-day-icon.weather-icon-thunder { color: var(--warn); }
.weather-day-temps { font-family: var(--font-mono); font-size: 16px; }
.weather-day-temps b { color: var(--text); }
.weather-day-temps span { color: var(--text-faint); margin-left: 5px; }

@media (max-width: 640px) {
  .topbar, .main { padding-left: 16px; padding-right: 16px; }
  .gauge-row { flex-wrap: wrap; }
}

@media (prefers-reduced-motion: reduce) {
  .gauge .value-ring { transition: none; }
}
