/* ============================================================
   Font — Google Sans (system on Pixel/Android), Roboto fallback
   ============================================================ */
@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,400;0,9..40,500;0,9..40,700;1,9..40,400&display=swap');

/* ============================================================
   M3 Color Tokens — Light
   ============================================================ */
html.light {
  color-scheme: light;
  --md-sys-color-primary:                   rgb(130 85 19);
  --md-sys-color-on-primary:                rgb(255 255 255);
  --md-sys-color-primary-container:         rgb(255 221 184);
  --md-sys-color-on-primary-container:      rgb(101 62 0);
  --md-sys-color-secondary:                 rgb(113 90 65);
  --md-sys-color-on-secondary:              rgb(255 255 255);
  --md-sys-color-secondary-container:       rgb(252 221 189);
  --md-sys-color-on-secondary-container:    rgb(87 67 43);
  --md-sys-color-tertiary:                  rgb(84 100 61);
  --md-sys-color-on-tertiary:               rgb(255 255 255);
  --md-sys-color-tertiary-container:        rgb(215 233 185);
  --md-sys-color-on-tertiary-container:     rgb(61 76 40);
  --md-sys-color-error:                     rgb(186 26 26);
  --md-sys-color-on-error:                  rgb(255 255 255);
  --md-sys-color-error-container:           rgb(255 218 214);
  --md-sys-color-on-error-container:        rgb(147 0 10);
  --md-sys-color-background:                rgb(255 248 244);
  --md-sys-color-on-background:             rgb(33 26 19);
  --md-sys-color-surface:                   rgb(255 248 244);
  --md-sys-color-on-surface:                rgb(33 26 19);
  --md-sys-color-surface-variant:           rgb(241 224 208);
  --md-sys-color-on-surface-variant:        rgb(80 69 57);
  --md-sys-color-outline:                   rgb(130 117 104);
  --md-sys-color-outline-variant:           rgb(212 196 181);
  --md-sys-color-inverse-surface:           rgb(55 47 39);
  --md-sys-color-inverse-on-surface:        rgb(252 238 226);
  --md-sys-color-inverse-primary:           rgb(248 187 113);
  --md-sys-color-scrim:                     rgb(0 0 0);
  --md-sys-color-surface-container-lowest:  rgb(255 255 255);
  --md-sys-color-surface-container-low:     rgb(255 241 229);
  --md-sys-color-surface-container:         rgb(249 236 224);
  --md-sys-color-surface-container-high:    rgb(243 230 218);
  --md-sys-color-surface-container-highest: rgb(238 224 212);
}

/* ============================================================
   M3 Color Tokens — Dark
   ============================================================ */
html.dark {
  color-scheme: dark;
  --md-sys-color-primary:                   rgb(248 187 113);
  --md-sys-color-on-primary:                rgb(71 42 0);
  --md-sys-color-primary-container:         rgb(101 62 0);
  --md-sys-color-on-primary-container:      rgb(255 221 184);
  --md-sys-color-secondary:                 rgb(223 194 162);
  --md-sys-color-on-secondary:              rgb(63 45 23);
  --md-sys-color-secondary-container:       rgb(87 67 43);
  --md-sys-color-on-secondary-container:    rgb(252 221 189);
  --md-sys-color-tertiary:                  rgb(187 205 158);
  --md-sys-color-on-tertiary:               rgb(39 53 19);
  --md-sys-color-tertiary-container:        rgb(61 76 40);
  --md-sys-color-on-tertiary-container:     rgb(215 233 185);
  --md-sys-color-error:                     rgb(255 180 171);
  --md-sys-color-on-error:                  rgb(105 0 5);
  --md-sys-color-error-container:           rgb(147 0 10);
  --md-sys-color-on-error-container:        rgb(255 218 214);
  --md-sys-color-background:                rgb(24 18 12);
  --md-sys-color-on-background:             rgb(238 224 212);
  --md-sys-color-surface:                   rgb(24 18 12);
  --md-sys-color-on-surface:                rgb(238 224 212);
  --md-sys-color-surface-variant:           rgb(80 69 57);
  --md-sys-color-on-surface-variant:        rgb(212 196 181);
  --md-sys-color-outline:                   rgb(156 142 128);
  --md-sys-color-outline-variant:           rgb(80 69 57);
  --md-sys-color-inverse-surface:           rgb(238 224 212);
  --md-sys-color-inverse-on-surface:        rgb(55 47 39);
  --md-sys-color-inverse-primary:           rgb(130 85 19);
  --md-sys-color-scrim:                     rgb(0 0 0);
  --md-sys-color-surface-container-lowest:  rgb(19 13 7);
  --md-sys-color-surface-container-low:     rgb(33 26 19);
  --md-sys-color-surface-container:         rgb(37 30 23);
  --md-sys-color-surface-container-high:    rgb(48 41 33);
  --md-sys-color-surface-container-highest: rgb(59 51 43);
}

/* ============================================================
   App Variable Bridge (keeps existing JS inline styles working)
   ============================================================ */
:root {
  /* Surfaces */
  --bg:             var(--md-sys-color-background);
  --surface:        var(--md-sys-color-surface-container);
  --surface-raised: var(--md-sys-color-surface-container-lowest);
  --surface-high:   var(--md-sys-color-surface-container-high);

  /* Borders */
  --border:         var(--md-sys-color-outline);
  --border-light:   var(--md-sys-color-outline-variant);

  /* Brand */
  --primary:               var(--md-sys-color-primary);
  --primary-dark:          var(--md-sys-color-primary);
  --primary-darker:        var(--md-sys-color-on-primary-container);
  --accent:                var(--md-sys-color-primary);
  --accent-light:          var(--md-sys-color-primary-container);

  /* Text */
  --text:           var(--md-sys-color-on-surface);
  --text-secondary: var(--md-sys-color-on-surface-variant);
  --text-muted:     var(--md-sys-color-outline);

  /* Status */
  --green:    var(--md-sys-color-tertiary);
  --amber:    var(--md-sys-color-secondary);
  --red:      var(--md-sys-color-error);
  --green-bg: var(--md-sys-color-tertiary-container);
  --amber-bg: var(--md-sys-color-secondary-container);
  --red-bg:   var(--md-sys-color-error-container);

  /* Layout */
  --header-h: 64px;
  --nav-h:    80px;

  /* Spacing */
  --sp-xs:  4px;
  --sp-sm:  8px;
  --sp-md:  16px;
  --sp-lg:  24px;
  --sp-xl:  32px;

  /* M3 Shape Scale */
  --r-xs:   4px;
  --r-sm:   8px;
  --r-md:   12px;
  --r-lg:   16px;
  --r-xl:   28px;
  --r-full: 9999px;

  /* Shadows — subtle tonal */
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.08);
  --shadow-md: 0 2px 8px rgba(0,0,0,0.10);
  --shadow-lg: 0 4px 16px rgba(0,0,0,0.14);
}

/* ============================================================
   Reset & Base
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: 'DM Sans', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  transition: background 0.2s, color 0.2s;
}

button  { font-family: inherit; cursor: pointer; border: none; background: none; }
input, select, textarea { font-family: inherit; font-size: inherit; }
a { color: var(--accent); text-decoration: none; }
img { display: block; max-width: 100%; }

/* ============================================================
   App Shell Layout
   ============================================================ */
.app-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-h);
  background: var(--md-sys-color-surface-container);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--sp-sm) 0 var(--sp-xs);
  z-index: 100;
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
}

.app-main {
  margin-top: var(--header-h);
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + var(--sp-md));
  min-height: calc(100dvh - var(--header-h));
}

.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--md-sys-color-surface-container);
  border-top: 1px solid var(--md-sys-color-outline-variant);
  display: flex;
  align-items: center;
  z-index: 100;
}

/* Pre-auth (login) state — full-bleed screen, no header/nav chrome.
   Overrides the desktop side-nav margins too since these class selectors
   are more specific than the plain .app-main rules they compete with. */
body.pre-auth .app-header,
body.pre-auth .bottom-nav   { display: none; }
body.pre-auth .app-main     { margin: 0; padding: 0; min-height: 100dvh; }
body.pre-auth .no-car-screen { min-height: 100dvh; }

/* ============================================================
   Header Components
   ============================================================ */
.header-left  { display: flex; align-items: center; flex: 1; min-width: 0; }
.header-right { display: flex; align-items: center; gap: var(--sp-xs); flex-shrink: 0; }

.car-switcher {
  display: flex;
  align-items: center;
  gap: var(--sp-xs);
  color: var(--md-sys-color-on-surface);
  font-weight: 500;
  font-size: 1.1rem;
  padding: 8px var(--sp-sm);
  border-radius: var(--r-full);
  transition: background 0.15s;
  max-width: calc(100vw - 100px);
}
.car-switcher:active,
.car-switcher:hover { background: var(--md-sys-color-surface-container-high); }

#current-car-name {
  color: var(--md-sys-color-on-surface);
  font-weight: 600;
  font-size: 1.1rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chevron {
  flex-shrink: 0;
  color: var(--md-sys-color-on-surface-variant);
  display: flex;
  align-items: center;
}
.chevron svg { width: 18px; height: 18px; stroke-width: 2; }

/* Theme toggle button */
.theme-toggle-btn {
  width: 40px; height: 40px;
  border-radius: var(--r-full);
  display: flex; align-items: center; justify-content: center;
  color: var(--md-sys-color-on-surface-variant);
  flex-shrink: 0;
  transition: background 0.15s;
}
.theme-toggle-btn:hover,
.theme-toggle-btn:active { background: var(--md-sys-color-surface-container-high); }
.theme-toggle-btn svg { width: 20px; height: 20px; stroke-width: 1.75; }

/* ── Car Switcher Dropdown ── */
.car-dropdown {
  position: fixed;
  top: var(--header-h);
  left: var(--sp-md);
  min-width: 200px;
  max-width: 280px;
  width: max-content;
  background: var(--md-sys-color-surface-container-highest);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg);
  z-index: 99;
  overflow: hidden;
  border: 1px solid var(--md-sys-color-outline-variant);
}

.car-dropdown-row {
  display: flex;
  align-items: stretch;
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
}
.car-dropdown-row:last-child { border-bottom: none; }

.car-dropdown-item {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: var(--sp-sm);
  flex: 1;
  padding: var(--sp-sm) var(--sp-md);
  transition: background 0.12s;
  text-align: left;
}
.car-item-info { display: flex; flex-direction: column; }
.car-dropdown-item:active,
.car-dropdown-item:hover { background: var(--md-sys-color-surface-container); }
.car-dropdown-item.active { background: var(--md-sys-color-secondary-container); }
.car-dropdown-item.active .car-item-nick,
.car-dropdown-item.active .car-item-detail { color: var(--md-sys-color-on-secondary-container); }

.car-dropdown-edit {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 var(--sp-md);
  color: var(--md-sys-color-on-surface-variant);
  transition: background 0.12s, color 0.12s;
  border-left: 1px solid var(--md-sys-color-outline-variant);
}
.car-dropdown-edit:active,
.car-dropdown-edit:hover {
  background: var(--md-sys-color-surface-container);
  color: var(--md-sys-color-primary);
}
.car-dropdown-edit svg { width: 16px; height: 16px; }

.car-item-nick   { font-weight: 600; font-size: 0.95rem; color: var(--md-sys-color-on-surface); }
.car-item-detail { font-size: 0.78rem; color: var(--md-sys-color-on-surface-variant); margin-top: 1px; }

/* ── Car Avatar ── */
.car-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  background: var(--md-sys-color-surface-container-high);
  display: flex;
  align-items: center;
  justify-content: center;
}
.car-avatar--md { width: 34px; height: 34px; }
.car-avatar-img { width: 100%; height: 100%; object-fit: cover; object-position: center; display: block; }
.car-avatar-fallback { font-size: 0.9rem; line-height: 1; }
.car-avatar--md .car-avatar-fallback { font-size: 1.1rem; }

/* ── Car Photo Upload (in form) ── */
.car-photo-upload {
  position: relative;
  width: 88px;
  height: 88px;
  border-radius: 50%;
  margin: 0 auto var(--sp-md);
  cursor: pointer;
  overflow: hidden;
  border: 2px dashed var(--md-sys-color-outline-variant);
  background: var(--md-sys-color-surface-container);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s;
}
.car-photo-upload:hover,
.car-photo-upload:focus-visible { border-color: var(--md-sys-color-primary); outline: none; }
.car-photo-upload.has-photo { border-style: solid; border-color: transparent; }

.car-photo-preview {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}

.car-photo-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  color: var(--md-sys-color-on-surface-variant);
  font-size: 0.72rem;
  pointer-events: none;
}
.car-photo-placeholder svg { width: 22px; height: 22px; }

/* Hover overlay when photo already set */
.car-photo-change-hint {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: #fff;
  font-size: 0.7rem;
  font-weight: 600;
  opacity: 0;
  transition: opacity 0.15s;
  pointer-events: none;
}
.car-photo-change-hint svg { width: 18px; height: 18px; }
.car-photo-upload:hover .car-photo-change-hint { opacity: 1; }

.car-dropdown-add {
  display: block;
  width: 100%;
  padding: var(--sp-md);
  color: var(--md-sys-color-primary);
  font-weight: 600;
  font-size: 0.9rem;
  text-align: left;
  border-top: 1px solid var(--md-sys-color-outline-variant);
  transition: background 0.12s;
}
.car-dropdown-add:active,
.car-dropdown-add:hover { background: var(--md-sys-color-surface-container); }

/* ============================================================
   Bottom Navigation Bar (M3)
   ============================================================ */
.nav-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: var(--sp-sm) 0;
  color: var(--md-sys-color-on-surface-variant);
  transition: color 0.15s;
}
.nav-tab:active { opacity: 0.7; }

/* Active indicator pill behind icon */
.nav-icon {
  position: relative;
  width: 64px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-full);
  transition: background 0.2s;
}
.nav-icon svg { width: 22px; height: 22px; stroke-width: 1.75; position: relative; z-index: 1; }

.nav-tab.active .nav-icon { background: var(--md-sys-color-secondary-container); }
.nav-tab.active .nav-icon svg { color: var(--md-sys-color-on-secondary-container); stroke-width: 2.25; }
.nav-tab.active { color: var(--md-sys-color-on-secondary-container); }

.nav-label {
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.01em;
}
.nav-tab.active .nav-label { font-weight: 700; }

/* Add FAB — elevated center button */
.nav-tab--add { margin-top: -18px; }

.nav-tab--add .nav-icon {
  width: 56px;
  height: 56px;
  border-radius: var(--r-xl);
  background: var(--md-sys-color-primary-container);
  box-shadow: var(--shadow-md);
  transition: background 0.15s, transform 0.15s, box-shadow 0.15s;
}
.nav-tab--add .nav-icon svg {
  width: 24px; height: 24px;
  color: var(--md-sys-color-on-primary-container);
  stroke-width: 2.5;
}
.nav-tab--add:active .nav-icon {
  background: var(--md-sys-color-primary);
  transform: scale(0.96);
  box-shadow: var(--shadow-sm);
}
.nav-tab--add:active .nav-icon svg { color: var(--md-sys-color-on-primary); }
.nav-tab--add.active .nav-icon { background: var(--md-sys-color-primary-container); }
.nav-tab--add .nav-label { color: var(--md-sys-color-on-surface-variant); font-weight: 500; }

/* ============================================================
   View Content Wrapper
   ============================================================ */
.view-content {
  padding: var(--sp-md);
  max-width: 640px;
  margin: 0 auto;
}

/* ── Car banner (dashboard hero image) ── */
.car-banner {
  width: 100%;
  height: clamp(200px, 35vw, 360px);
  border-radius: var(--r-xl);
  overflow: hidden;
  margin-bottom: var(--sp-md);
  position: relative;
}
.car-banner-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
}
.car-banner::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, transparent 40%, var(--bg) 100%);
  border-radius: inherit;
  pointer-events: none;
}

.view-header { margin-bottom: var(--sp-md); }

.view-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-sm);
}

.btn-add-entry {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--r-full);
  background: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
  flex-shrink: 0;
  transition: background 0.15s, transform 0.1s;
}
.btn-add-entry:active,
.btn-add-entry:hover { background: var(--md-sys-color-primary); color: var(--md-sys-color-on-primary); }
.btn-add-entry:active { transform: scale(0.93); }
.btn-add-entry svg { width: 18px; height: 18px; stroke-width: 2.5; }

.view-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--md-sys-color-on-surface);
  line-height: 1.2;
}

.view-subtitle {
  font-size: 0.85rem;
  color: var(--md-sys-color-on-surface-variant);
  margin-top: 3px;
}

/* ============================================================
   Cards
   ============================================================ */
.card {
  background: var(--md-sys-color-surface-container-low);
  border-radius: var(--r-xl);
  overflow: hidden;
}
.card + .card { margin-top: var(--sp-md); }

.card-header {
  padding: var(--sp-md);
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-sm);
}

.card-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--md-sys-color-on-surface-variant);
}

.card-body { padding: var(--sp-md); }

/* ============================================================
   Stats Grid
   ============================================================ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--sp-sm);
  margin-bottom: var(--sp-md);
}

.stat-card {
  background: var(--md-sys-color-surface-container-low);
  border-radius: var(--r-xl);
  padding: var(--sp-md) var(--sp-sm);
  text-align: center;
}

.stat-value {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--md-sys-color-primary);
  line-height: 1.2;
}

.stat-label {
  font-size: 0.67rem;
  font-weight: 600;
  color: var(--md-sys-color-on-surface-variant);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 2px;
}

/* ============================================================
   Badges / Tonal Chips
   ============================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 3px 10px;
  border-radius: var(--r-full);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.badge--verified {
  background: var(--md-sys-color-tertiary-container);
  color: var(--md-sys-color-on-tertiary-container);
}
.badge--assumed {
  background: var(--md-sys-color-secondary-container);
  color: var(--md-sys-color-on-secondary-container);
}
.badge--unknown {
  background: var(--md-sys-color-error-container);
  color: var(--md-sys-color-on-error-container);
}

/* ============================================================
   Status Indicators
   ============================================================ */
.status-dot {
  width: 10px; height: 10px;
  border-radius: var(--r-full);
  flex-shrink: 0;
}
.status-dot--green { background: var(--md-sys-color-tertiary); }
.status-dot--amber { background: var(--md-sys-color-secondary); }
.status-dot--red   { background: var(--md-sys-color-error); }

.status-bar {
  height: 6px;
  border-radius: var(--r-full);
  background: var(--md-sys-color-outline-variant);
  overflow: hidden;
}
.status-bar-fill {
  height: 100%;
  border-radius: var(--r-full);
  transition: width 0.4s ease;
}
.status-bar-fill--green { background: var(--md-sys-color-tertiary); }
.status-bar-fill--amber { background: var(--md-sys-color-secondary); }
.status-bar-fill--red   { background: var(--md-sys-color-error); }

/* ============================================================
   Section Headers
   ============================================================ */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: var(--sp-lg) 0 var(--sp-sm);
}

.section-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--md-sys-color-on-surface-variant);
}

.section-link {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--md-sys-color-primary);
}
.section-link:active { opacity: 0.7; }

/* ============================================================
   Log Entry
   ============================================================ */
.log-entry {
  background: var(--md-sys-color-surface-container-low);
  border-radius: var(--r-xl);
  padding: var(--sp-md);
  margin-bottom: var(--sp-sm);
}

.log-entry-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--sp-sm);
  margin-bottom: var(--sp-sm);
}

.log-entry-meta { flex: 1; min-width: 0; }

.log-entry-date {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--md-sys-color-on-surface);
}

.log-entry-odo {
  font-size: 0.78rem;
  color: var(--md-sys-color-on-surface-variant);
  margin-top: 1px;
}

.log-entry-work { list-style: none; margin-bottom: var(--sp-sm); }
.log-entry-work li {
  font-size: 0.875rem;
  color: var(--md-sys-color-on-surface);
  padding: 2px 0 2px var(--sp-md);
  position: relative;
}
.log-entry-work li::before {
  content: '•';
  position: absolute;
  left: 0;
  color: var(--md-sys-color-primary);
  font-weight: 900;
}

.log-entry-footer {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--sp-sm);
  margin-top: var(--sp-sm);
  padding-top: var(--sp-sm);
  border-top: 1px solid var(--md-sys-color-outline-variant);
}

.log-entry-cost     { font-size: 0.8rem; font-weight: 700; color: var(--md-sys-color-primary); }
.log-entry-mechanic { font-size: 0.78rem; color: var(--md-sys-color-on-surface-variant); }

/* Log action buttons (edit/delete) */
.log-action-btn {
  width: 32px; height: 32px;
  border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
  color: var(--md-sys-color-on-surface-variant);
  transition: background 0.12s, color 0.12s;
  flex-shrink: 0;
}
.log-action-btn svg { width: 15px; height: 15px; stroke-width: 2; }
.log-action-btn:hover,
.log-action-btn:active { background: var(--md-sys-color-surface-container-high); color: var(--md-sys-color-on-surface); }
.delete-btn:hover { color: var(--md-sys-color-error); }

.delete-confirm {
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
  flex-wrap: wrap;
  margin-top: var(--sp-sm);
  padding-top: var(--sp-sm);
  border-top: 1px solid var(--md-sys-color-outline-variant);
}
.delete-confirm-msg {
  font-size: 0.82rem;
  color: var(--md-sys-color-on-surface-variant);
  flex: 1;
}

/* ============================================================
   Checklist Item
   ============================================================ */
.checklist-item {
  background: var(--md-sys-color-surface-container-low);
  border-radius: var(--r-xl);
  padding: var(--sp-md);
  margin-bottom: var(--sp-sm);
  transition: background 0.15s;
}
.checklist-item--ok      { background: var(--md-sys-color-tertiary-container); }
.checklist-item--warning { background: var(--md-sys-color-secondary-container); }
.checklist-item--urgent  { background: var(--md-sys-color-error-container); }

.checklist-item-header {
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
  margin-bottom: 6px;
}
.checklist-item-name {
  font-weight: 600;
  color: var(--md-sys-color-on-surface);
  flex: 1;
  font-size: 0.95rem;
}
.checklist-item--ok      .checklist-item-name { color: var(--md-sys-color-on-tertiary-container); }
.checklist-item--warning .checklist-item-name { color: var(--md-sys-color-on-secondary-container); }
.checklist-item--urgent  .checklist-item-name { color: var(--md-sys-color-on-error-container); }

.checklist-item-detail {
  font-size: 0.78rem;
  color: var(--md-sys-color-on-surface-variant);
  margin-left: 20px;
}
.checklist-item--ok      .checklist-item-detail { color: var(--md-sys-color-on-tertiary-container); opacity: 0.8; }
.checklist-item--warning .checklist-item-detail { color: var(--md-sys-color-on-secondary-container); opacity: 0.85; }
.checklist-item--urgent  .checklist-item-detail { color: var(--md-sys-color-on-error-container); opacity: 0.85; }

.checklist-item-actions { margin-top: var(--sp-sm); margin-left: 20px; }

/* ============================================================
   Alert Items (dashboard)
   ============================================================ */
.alert-item {
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
  padding: var(--sp-md);
  border-radius: var(--r-xl);
  margin-bottom: var(--sp-sm);
}
.alert-item--urgent { background: var(--md-sys-color-error-container); }
.alert-item--red    { background: var(--md-sys-color-error-container); }

.alert-dot {
  width: 10px; height: 10px;
  border-radius: var(--r-full);
  background: var(--md-sys-color-error);
  flex-shrink: 0;
}

.alert-body { flex: 1; min-width: 0; }
.alert-name   { font-weight: 600; font-size: 0.9rem; color: var(--md-sys-color-on-error-container); display: block; }
.alert-detail { font-size: 0.78rem; color: var(--md-sys-color-on-error-container); opacity: 0.8; display: block; margin-top: 1px; }

.all-good-banner {
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
  padding: var(--sp-md);
  background: var(--md-sys-color-tertiary-container);
  border-radius: var(--r-xl);
  color: var(--md-sys-color-on-tertiary-container);
  font-weight: 600;
  font-size: 0.9rem;
}

/* ============================================================
   Segmented Control
   ============================================================ */
.segmented-control {
  display: flex;
  background: var(--md-sys-color-surface-container-high);
  border-radius: var(--r-full);
  padding: 3px;
  margin-bottom: var(--sp-md);
}

.segment-btn {
  flex: 1;
  padding: var(--sp-sm) var(--sp-md);
  border-radius: var(--r-full);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--md-sys-color-on-surface-variant);
  transition: all 0.15s;
  text-align: center;
}
.segment-btn.active {
  background: var(--md-sys-color-secondary-container);
  color: var(--md-sys-color-on-secondary-container);
  font-weight: 700;
}

/* ============================================================
   Forms
   ============================================================ */
.form-group { margin-bottom: var(--sp-md); }

.form-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--md-sys-color-on-surface-variant);
  margin-bottom: var(--sp-xs);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 12px var(--sp-md);
  border: 2px solid var(--md-sys-color-outline-variant);
  border-radius: var(--r-lg);
  background: var(--md-sys-color-surface-container-lowest);
  color: var(--md-sys-color-on-surface);
  font-size: 1rem;
  transition: border-color 0.15s, background 0.15s;
  -webkit-appearance: none;
  appearance: none;
}
.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--md-sys-color-primary);
  background: var(--md-sys-color-surface-container-lowest);
}
.form-textarea { resize: vertical; min-height: 110px; }

.form-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23808069' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 40px;
}

.form-hint  { font-size: 0.75rem; color: var(--md-sys-color-on-surface-variant); margin-top: var(--sp-xs); }
.form-error { font-size: 0.75rem; color: var(--md-sys-color-error); margin-top: var(--sp-xs); display: none; }
.form-group.has-error .form-error                  { display: block; }
.form-group.has-error .form-input,
.form-group.has-error .form-textarea               { border-color: var(--md-sys-color-error); }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-sm);
}

.req { color: var(--md-sys-color-primary); font-weight: 700; }
.form-actions { margin-top: var(--sp-lg); padding-bottom: var(--sp-sm); }

/* Confidence toggle */
.confidence-toggle { display: flex; gap: var(--sp-sm); }

.confidence-option {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: var(--sp-sm) var(--sp-md);
  border: 2px solid var(--md-sys-color-outline-variant);
  border-radius: var(--r-full);
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--md-sys-color-on-surface-variant);
  transition: all 0.15s;
}
.confidence-option input[type="radio"] { display: none; }
.confidence-option.selected-verified {
  border-color: var(--md-sys-color-tertiary);
  background: var(--md-sys-color-tertiary-container);
  color: var(--md-sys-color-on-tertiary-container);
  font-weight: 600;
}
.confidence-option.selected-assumed {
  border-color: var(--md-sys-color-secondary);
  background: var(--md-sys-color-secondary-container);
  color: var(--md-sys-color-on-secondary-container);
  font-weight: 600;
}

/* ============================================================
   Buttons (M3)
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-sm);
  padding: 12px var(--sp-lg);
  border-radius: var(--r-full);
  font-size: 0.9rem;
  font-weight: 600;
  transition: all 0.15s;
  cursor: pointer;
  border: none;
  line-height: 1;
  letter-spacing: 0.01em;
}

.btn--primary {
  background: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
}
.btn--primary:active,
.btn--primary:hover { opacity: 0.88; }

.btn--secondary {
  background: var(--md-sys-color-secondary-container);
  color: var(--md-sys-color-on-secondary-container);
}
.btn--secondary:active,
.btn--secondary:hover { opacity: 0.88; }

.btn--ghost {
  background: transparent;
  color: var(--md-sys-color-primary);
}
.btn--ghost:active,
.btn--ghost:hover { background: var(--md-sys-color-primary-container); }

.btn--danger {
  background: var(--md-sys-color-error-container);
  color: var(--md-sys-color-on-error-container);
}
.btn--danger:active,
.btn--danger:hover { opacity: 0.88; }

.btn--full   { width: 100%; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; pointer-events: none; }

.btn-spinner {
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,0.35);
  border-top-color: rgba(255,255,255,0.9);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  flex-shrink: 0;
}

/* ============================================================
   Modal
   ============================================================ */
/* ── Drawer overlay backdrop ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 200;
  display: flex;
  justify-content: flex-end;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
.modal-overlay.is-open {
  opacity: 1;
  pointer-events: all;
}

/* ── Drawer panel ── */
.modal {
  background: var(--md-sys-color-surface-container-low);
  border-radius: var(--r-xl) 0 0 var(--r-xl);
  width: 420px;
  max-width: 100vw;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.modal-overlay.is-open .modal {
  transform: translateX(0);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-lg) var(--sp-md) var(--sp-md);
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
  flex-shrink: 0;
  background: var(--md-sys-color-surface-container-low);
}
.modal-header h2 { font-size: 1.2rem; font-weight: 700; color: var(--md-sys-color-on-surface); }

.modal-close {
  width: 36px; height: 36px;
  border-radius: var(--r-full);
  background: var(--md-sys-color-surface-container);
  color: var(--md-sys-color-on-surface-variant);
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s;
}
.modal-close:active,
.modal-close:hover { background: var(--md-sys-color-surface-container-high); }

.modal-body {
  padding: var(--sp-md);
  overflow-y: auto;
  overscroll-behavior: contain;
  flex: 1;
}

/* ============================================================
   Toast Notifications
   ============================================================ */
.toast {
  position: fixed;
  bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + var(--sp-md));
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  background: var(--md-sys-color-inverse-surface);
  color: var(--md-sys-color-inverse-on-surface);
  padding: var(--sp-sm) var(--sp-lg);
  border-radius: var(--r-full);
  font-size: 0.875rem;
  font-weight: 500;
  z-index: 300;
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  white-space: nowrap;
  max-width: calc(100vw - var(--sp-xl) * 2);
  pointer-events: none;
}
.toast--visible   { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast--success   { background: var(--md-sys-color-tertiary-container); color: var(--md-sys-color-on-tertiary-container); }
.toast--error     { background: var(--md-sys-color-error-container); color: var(--md-sys-color-on-error-container); }
.toast--warning   { background: var(--md-sys-color-secondary-container); color: var(--md-sys-color-on-secondary-container); }

/* ============================================================
   Loading, Empty & Error States
   ============================================================ */
.loading-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: calc(100dvh - var(--header-h) - var(--nav-h));
  gap: var(--sp-md);
  color: var(--md-sys-color-on-surface-variant);
}

.loading-spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--md-sys-color-outline-variant);
  border-top-color: var(--md-sys-color-primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: var(--sp-sm);
  padding: var(--sp-xl) 0;
  color: var(--md-sys-color-on-surface-variant);
}
.empty-state-icon { font-size: 2.5rem; line-height: 1; }
.empty-state-title { font-weight: 700; font-size: 1.1rem; color: var(--md-sys-color-on-surface); }

.error-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 50vh;
  gap: var(--sp-sm);
  text-align: center;
  padding: var(--sp-lg);
}
.error-title { font-weight: 700; font-size: 1rem; color: var(--md-sys-color-error); }
.error-msg   { font-size: 0.85rem; color: var(--md-sys-color-on-surface-variant); }

/* ============================================================
   No-car Screen
   ============================================================ */
.no-car-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: calc(100dvh - var(--header-h));
  text-align: center;
  gap: var(--sp-md);
  padding: var(--sp-xl);
}
.no-car-icon { font-size: 3rem; line-height: 1; }
.no-car-screen h2 { font-weight: 700; font-size: 1.3rem; color: var(--md-sys-color-on-surface); }
.no-car-screen p  { color: var(--md-sys-color-on-surface-variant); font-size: 0.9rem; }

.login-error {
  display: inline-block;
  background: var(--md-sys-color-error-container);
  color: var(--md-sys-color-on-error-container);
  font-size: 0.85rem;
  font-weight: 600;
  line-height: 1.4;
  padding: 10px 16px;
  border-radius: var(--r-md);
}

/* ============================================================
   Animations
   ============================================================ */
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ============================================================
   Dark mode overrides — tone down harsh colored card fills
   ============================================================ */
html.dark .checklist-item--urgent {
  background: var(--md-sys-color-surface-container-high);
  border-left: 3px solid var(--md-sys-color-error);
}
html.dark .checklist-item--urgent .checklist-item-name {
  color: var(--md-sys-color-error);
}
html.dark .checklist-item--urgent .checklist-item-detail {
  color: var(--md-sys-color-on-surface-variant);
  opacity: 1;
}
html.dark .checklist-item--ok {
  background: var(--md-sys-color-surface-container-high);
  border-left: 3px solid var(--md-sys-color-tertiary);
}
html.dark .checklist-item--ok .checklist-item-name {
  color: var(--md-sys-color-tertiary);
}
html.dark .checklist-item--ok .checklist-item-detail {
  color: var(--md-sys-color-on-surface-variant);
  opacity: 1;
}
html.dark .checklist-item--urgent .badge--unknown,
html.dark .checklist-item--urgent .badge--assumed,
html.dark .checklist-item--urgent .badge--verified {
  background: var(--md-sys-color-surface-container-highest);
}
html.dark .alert-item--urgent,
html.dark .alert-item--red {
  background: var(--md-sys-color-surface-container-high);
  border-left: 3px solid var(--md-sys-color-error);
}
html.dark .alert-name,
html.dark .alert-detail  { color: var(--md-sys-color-on-surface-variant); }
html.dark .alert-name    { color: var(--md-sys-color-error); }

/* ============================================================
   Desktop — Side Navigation (≥768px)
   ============================================================ */
.side-nav-brand { display: none; }

@media (min-width: 768px) {
  :root { --side-nav-w: 220px; }

  /* ── Layout offsets ── */
  .app-header {
    left: var(--side-nav-w);
  }
  .app-main {
    margin-left: var(--side-nav-w);
    padding-bottom: var(--sp-xl);
  }
  .car-dropdown {
    left: calc(var(--side-nav-w) + var(--sp-md));
  }
  .loading-screen {
    min-height: calc(100dvh - var(--header-h));
  }

  /* ── Side nav container ── */
  .bottom-nav {
    top: 0;
    bottom: 0;
    left: 0;
    right: auto;
    width: var(--side-nav-w);
    height: 100dvh;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    border-top: none;
    border-right: 1px solid var(--md-sys-color-outline-variant);
    padding: var(--sp-md) var(--sp-sm);
    gap: 2px;
    overflow-y: auto;
  }

  /* ── Brand header inside side nav ── */
  .side-nav-brand {
    display: flex;
    align-items: center;
    gap: var(--sp-sm);
    padding: var(--sp-xs) var(--sp-sm) var(--sp-lg);
    color: var(--md-sys-color-on-surface);
  }
  .side-nav-logo { font-size: 1.4rem; line-height: 1; }
  .side-nav-title { font-size: 1.2rem; font-weight: 700; letter-spacing: -0.02em; }

  /* ── Nav tabs as vertical rows ── */
  .nav-tab {
    flex-direction: row;
    flex: none;
    width: 100%;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
    padding: 10px var(--sp-sm);
    border-radius: var(--r-lg);
    transition: background 0.12s, color 0.12s;
  }
  .nav-tab:hover { background: var(--md-sys-color-surface-container); }

  /* Toast: no bottom nav offset */
  .toast {
    bottom: var(--sp-xl);
    left: calc(50% + var(--side-nav-w) / 2);
  }

  /* Active: highlight full row */
  .nav-tab.active {
    background: var(--md-sys-color-secondary-container);
    color: var(--md-sys-color-on-secondary-container);
  }
  .nav-tab.active .nav-label { font-weight: 700; }

  /* Icon: no pill background, just the icon itself */
  .nav-icon {
    width: 24px;
    height: 24px;
    border-radius: 0;
    background: none !important;
    flex-shrink: 0;
  }
  .nav-icon svg { width: 20px; height: 20px; position: static; }

  .nav-label {
    font-size: 0.9rem;
    font-weight: 500;
  }

  /* Remove FAB treatment for Add button */
  .nav-tab--add { margin-top: 0; }
  .nav-tab--add .nav-icon {
    width: 24px;
    height: 24px;
    box-shadow: none;
    background: none !important;
  }
  .nav-tab--add .nav-icon svg {
    width: 20px;
    height: 20px;
    color: inherit;
    stroke-width: 2;
  }
  .nav-tab--add.active .nav-icon svg,
  .nav-tab--add:active .nav-icon,
  .nav-tab--add:active .nav-icon svg { background: none; transform: none; box-shadow: none; }
  .nav-tab--add .nav-label { color: inherit; }
}
