/* ============================================================
   Apple HIG — flat, opaque, fast.
   No backdrop-filter, no ambient effects, no transforms.
   iOS Inset Grouped List aesthetic.
   ============================================================ */

:root {
  color-scheme: dark light;

  /* Surfaces (dark default) */
  --bg:           #000000;
  --bg-grouped:   #000000;
  --surface:      #1c1c1e;
  --surface-2:    #2c2c2e;
  --surface-3:    #3a3a3c;

  /* Hairlines */
  --separator:           rgba(84, 84, 88, 0.65);
  --separator-opaque:    #38383a;

  /* Text */
  --label:           rgba(255, 255, 255, 1);
  --label-secondary: rgba(235, 235, 245, 0.60);
  --label-tertiary:  rgba(235, 235, 245, 0.30);
  --label-quaternary:rgba(235, 235, 245, 0.18);

  /* System colors (iOS — vivid in dark, standard in light) */
  --systemBlue:   #0a84ff;
  --systemGreen:  #30d158;
  --systemOrange: #ff9f0a;
  --systemRed:    #ff453a;
  --systemYellow: #ffd60a;

  /* Tinted fills for status pills (system colors w/ low alpha) */
  --tint-blue:   rgba(10, 132, 255, 0.16);
  --tint-green:  rgba(48, 209, 88, 0.18);
  --tint-orange: rgba(255, 159, 10, 0.20);
  --tint-red:    rgba(255, 69, 58, 0.20);

  /* Continuous corners */
  --r-card:    16px;
  --r-control: 12px;
  --r-pill:    999px;
  --r-icon:    11px;

  /* Type — SF stack */
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro",
          "Helvetica Neue", system-ui, sans-serif;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg:         #ffffff;
    --bg-grouped: #f2f2f7;
    --surface:    #ffffff;
    --surface-2:  #f2f2f7;
    --surface-3:  #e5e5ea;

    --separator:        rgba(60, 60, 67, 0.29);
    --separator-opaque: #c6c6c8;

    --label:           rgba(0, 0, 0, 0.92);
    --label-secondary: rgba(60, 60, 67, 0.60);
    --label-tertiary:  rgba(60, 60, 67, 0.30);
    --label-quaternary:rgba(60, 60, 67, 0.18);

    --systemBlue:   #007aff;
    --systemGreen:  #34c759;
    --systemOrange: #ff9500;
    --systemRed:    #ff3b30;
    --systemYellow: #ffcc00;

    --tint-blue:   rgba(0, 122, 255, 0.12);
    --tint-green:  rgba(52, 199, 89, 0.14);
    --tint-orange: rgba(255, 149, 0, 0.16);
    --tint-red:    rgba(255, 59, 48, 0.16);
  }
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }

body {
  background: var(--bg-grouped);
  color: var(--label);
  font-family: var(--font);
  font-size: 17px;          /* iOS body */
  line-height: 1.35;
  letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
}

.container {
  max-width: 980px;
  margin: 0 auto;
  padding: 32px 20px max(56px, env(safe-area-inset-bottom)) 20px;
}

/* ============ Header ============ */
header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 22px;
}

.title h1 {
  font-size: 34px;          /* iOS Large Title */
  font-weight: 700;
  letter-spacing: -0.022em;
  line-height: 1.05;
}
.title .sub {
  margin-top: 6px;
  color: var(--label-secondary);
  font-size: 15px;          /* iOS Subheadline */
  letter-spacing: -0.005em;
}

.km-card {
  appearance: none;
  background: var(--surface);
  border: 0;
  border-radius: var(--r-control);
  padding: 12px 16px;
  text-align: right;
  cursor: pointer;
  font-family: inherit;
  color: inherit;
  min-width: 200px;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 0.12s linear;
}
.km-card:hover  { background: var(--surface-2); }
.km-card:active { background: var(--surface-3); }
.km-card .label {
  font-size: 11px;
  font-weight: 600;
  color: var(--label-tertiary);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.km-card .value {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.025em;
  font-variant-numeric: tabular-nums;
  margin-top: 1px;
}
.km-card .value::after {
  content: ' km';
  font-size: 13px;
  font-weight: 500;
  color: var(--label-tertiary);
}
.km-card .date {
  font-size: 12px;
  color: var(--label-tertiary);
  margin-top: 1px;
}

/* ============ Summary (sinds aankoop / gemiddeld) ============ */
.summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2px;
  background: var(--separator-opaque);
  border-radius: var(--r-control);
  overflow: hidden;
  margin-bottom: 24px;
}
.summary-item {
  appearance: none;
  background: var(--surface);
  border: 0;
  padding: 12px 14px;
  text-align: left;
  font-family: inherit;
  color: inherit;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 0.12s linear;
}
button.summary-item { cursor: pointer; }
button.summary-item:hover  { background: var(--surface-2); }
button.summary-item:active { background: var(--surface-3); }
.summary-item .label {
  font-size: 11px;
  font-weight: 600;
  color: var(--label-tertiary);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.summary-item .value {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  margin-top: 2px;
}
.summary-item .unit {
  font-size: 12px;
  font-weight: 500;
  color: var(--label-tertiary);
  margin-left: 2px;
}
@media (max-width: 600px) {
  .summary { grid-template-columns: 1fr; }
}

/* Modal section heading (e.g. Aankoop in km-modal) */
.modal-section {
  font-size: 11px;
  font-weight: 700;
  color: var(--label-tertiary);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin: 18px 0 8px;
  padding-top: 14px;
  border-top: 0.5px solid var(--separator);
}
.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
@media (max-width: 480px) {
  .field-row { grid-template-columns: 1fr; }
}

/* ============ Toolbar (segmented control style) ============ */
.toolbar {
  background: var(--surface);
  border-radius: var(--r-pill);
  padding: 4px;
  display: inline-flex;
  gap: 2px;
  margin-bottom: 24px;
}
.toolbar .icon-btn {
  appearance: none;
  background: transparent;
  border: 0;
  color: var(--label);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 7px 14px;
  border-radius: var(--r-pill);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  -webkit-tap-highlight-color: transparent;
  letter-spacing: -0.005em;
  transition: background-color 0.12s linear, color 0.12s linear;
}
.toolbar .icon-btn:hover  { background: var(--surface-2); }
.toolbar .icon-btn:active { background: var(--surface-3); }
.toolbar .icon-btn.danger { color: var(--label-secondary); }
.toolbar .icon-btn.danger:hover  { color: var(--systemRed); background: var(--tint-red); }
.toolbar .icon-btn .glyph {
  font-size: 13px;
  line-height: 1;
  color: var(--label-tertiary);
}
.toolbar .icon-btn.danger:hover .glyph { color: var(--systemRed); }

/* ============ Stats (filter chips) ============ */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  margin-bottom: 28px;
}
.stat {
  appearance: none;
  background: var(--surface);
  border: 1px solid transparent;
  border-radius: var(--r-control);
  padding: 12px 14px;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  color: var(--label);
  -webkit-tap-highlight-color: transparent;
  transition: background-color 0.12s linear, border-color 0.12s linear;
}
.stat:hover  { background: var(--surface-2); }
.stat:active { background: var(--surface-3); }
.stat .label {
  font-size: 13px;          /* iOS Footnote-ish, slightly larger */
  font-weight: 600;
  color: var(--label-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
  letter-spacing: -0.005em;
}
.stat .dot {
  width: 8px;
  height: 8px;
  border-radius: 99px;
  background: var(--label-quaternary);
  display: inline-block;
}
.stat.green  .dot { background: var(--systemGreen); }
.stat.orange .dot { background: var(--systemOrange); }
.stat.red    .dot { background: var(--systemRed); }
.stat .value {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.025em;
  font-variant-numeric: tabular-nums;
  margin-top: 2px;
}
.stat.green  .value { color: var(--systemGreen); }
.stat.orange .value { color: var(--systemOrange); }
.stat.red    .value { color: var(--systemRed); }

.stat.active.green  { background: var(--tint-green);  border-color: var(--systemGreen); }
.stat.active.orange { background: var(--tint-orange); border-color: var(--systemOrange); }
.stat.active.red    { background: var(--tint-red);    border-color: var(--systemRed); }
.stat.active.gray   { background: var(--surface-2);   border-color: var(--separator); }

/* ============ Section title ============ */
h2.section {
  font-size: 22px;          /* iOS Title 2 */
  font-weight: 700;
  letter-spacing: -0.018em;
  margin: 32px 0 12px;
  padding-left: 4px;
}
h2.section .section-sub {
  font-weight: 500;
  font-size: 13px;
  color: var(--label-tertiary);
  letter-spacing: -0.005em;
  margin-left: 8px;
}

/* ============ Aankomende (overview) ============ */
.upcoming-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 8px;
  margin-bottom: 8px;
}
.upcoming-row {
  appearance: none;
  background: var(--surface);
  border: 1px solid transparent;
  border-radius: var(--r-control);
  padding: 11px 14px;
  display: flex;
  gap: 12px;
  align-items: center;
  cursor: pointer;
  font-family: inherit;
  color: var(--label);
  text-align: left;
  width: 100%;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 0.12s linear, border-color 0.12s linear;
}
.upcoming-row:hover  { background: var(--surface-2); }
.upcoming-row:active { background: var(--surface-3); }
.upcoming-row.overdue { border-color: var(--systemRed); }
.upcoming-row.soon    { border-color: var(--systemOrange); }
@media (prefers-color-scheme: light) {
  .upcoming-row.overdue { border-color: rgba(255, 59, 48, 0.5); }
  .upcoming-row.soon    { border-color: rgba(255, 149, 0, 0.5); }
}
.upcoming-ic {
  width: 30px;
  height: 30px;
  border-radius: var(--r-icon);
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}
.upcoming-body { min-width: 0; flex: 1; }
.upcoming-name {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.005em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.upcoming-when {
  font-size: 12px;
  color: var(--label-secondary);
  margin-top: 2px;
  letter-spacing: -0.005em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.upcoming-when.overdue { color: var(--systemRed);    font-weight: 600; }
.upcoming-when.soon    { color: var(--systemOrange); font-weight: 600; }

/* ============ Logboek ============ */
.logbook-list {
  display: grid;
  gap: 4px;
  margin-bottom: 8px;
}
.log-row {
  appearance: none;
  background: var(--surface);
  border: 0;
  border-radius: var(--r-control);
  padding: 11px 14px;
  display: grid;
  grid-template-columns: 120px 24px 1fr auto;
  gap: 12px;
  align-items: center;
  cursor: pointer;
  font-family: inherit;
  color: var(--label);
  text-align: left;
  width: 100%;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 0.12s linear;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.005em;
}
.log-row:hover  { background: var(--surface-2); }
.log-row:active { background: var(--surface-3); }
.log-row.undated .log-date { color: var(--label-tertiary); font-style: italic; }
.log-date {
  color: var(--label-secondary);
  font-weight: 500;
}
.log-icon {
  font-size: 16px;
  text-align: center;
  line-height: 1;
}
.log-name {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.log-km {
  color: var(--label-secondary);
  font-weight: 500;
}
@media (max-width: 600px) {
  .log-row {
    grid-template-columns: 24px 1fr auto;
    grid-template-areas:
      "icon name km"
      ".    date date";
    row-gap: 2px;
  }
  .log-icon { grid-area: icon; }
  .log-name { grid-area: name; }
  .log-km   { grid-area: km; font-size: 12px; }
  .log-date { grid-area: date; font-size: 12px; }
}

/* ============ Grid + card ============ */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 12px;
}

.card {
  background: var(--surface);
  border: 1px solid transparent;
  border-radius: var(--r-card);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  position: relative;
  container-type: inline-size;
  transition: border-color 0.12s linear;
}
.card.overdue { border-color: var(--systemRed); }
.card.soon    { border-color: var(--systemOrange); }
.card.flash   { animation: cardFlash 0.9s ease; }
@keyframes cardFlash {
  0%, 100% { background: var(--surface); }
  30%      { background: var(--surface-3); }
}

@media (prefers-color-scheme: light) {
  .card.overdue { border-color: rgba(255, 59, 48, 0.5); }
  .card.soon    { border-color: rgba(255, 149, 0, 0.5); }
}

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}
.card-title {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  min-width: 0;
}
.card-title .icon {
  width: 36px;
  height: 36px;
  border-radius: var(--r-icon);
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}
.card-title .name {
  font-size: 17px;          /* iOS Headline */
  font-weight: 600;
  letter-spacing: -0.01em;
}
.card-title .desc {
  font-size: 13px;
  color: var(--label-secondary);
  margin-top: 2px;
  letter-spacing: -0.005em;
}
.card-title .interval {
  margin-top: 8px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--tint-blue);
  color: var(--systemBlue);
  padding: 3px 9px;
  border-radius: var(--r-pill);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: -0.005em;
  font-variant-numeric: tabular-nums;
}
.card-title .interval::before { content: '↻'; font-weight: 700; }

/* Status pill */
.status-pill {
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: var(--r-pill);
  letter-spacing: 0.02em;
  text-transform: uppercase;
  white-space: nowrap;
  flex-shrink: 0;
}
.status-pill.ok      { background: var(--tint-green);  color: var(--systemGreen); }
.status-pill.soon    { background: var(--tint-orange); color: var(--systemOrange); }
.status-pill.overdue { background: var(--tint-red);    color: var(--systemRed); }
.status-pill.unknown { background: var(--surface-2);   color: var(--label-secondary); }

/* Bars */
.bars { display: flex; flex-direction: column; gap: 10px; }
.bar-row { display: flex; flex-direction: column; gap: 5px; }
.bar-label {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.005em;
  gap: 8px;
}
.bar-label .key {
  color: var(--label-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bar-label .val { color: var(--label); font-weight: 600; white-space: nowrap; }
.bar-label .val.over { color: var(--systemRed); }

.bar {
  height: 6px;
  background: var(--surface-2);
  border-radius: var(--r-pill);
  overflow: hidden;
  position: relative;
}
.bar-fill {
  height: 100%;
  background: var(--systemGreen);
  border-radius: inherit;
  /* No transition: avoid layout work on first paint; only updates on user action */
}
.bar-fill.soon    { background: var(--systemOrange); }
.bar-fill.overdue { background: var(--systemRed); }
.bar-fill.unknown { background: var(--label-quaternary); width: 100% !important; }
.bar-mid {
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--surface);
  transform: translateX(-50%);
  pointer-events: none;
}

/* Includes */
.includes {
  border-top: 0.5px solid var(--separator);
  padding-top: 12px;
}
.includes-head {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--label-tertiary);
  margin-bottom: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  align-items: center;
}
.includes-head .legend {
  font-weight: 500;
  text-transform: none;
  letter-spacing: -0.005em;
  color: var(--label-tertiary);
  font-size: 11px;
}
.includes-head .legend .ic { color: var(--systemBlue); font-weight: 700; }

.includes ul {
  list-style: none;
  display: grid;
  grid-template-columns: 1fr;
  gap: 4px 16px;
  font-size: 13px;
  color: var(--label-secondary);
  letter-spacing: -0.005em;
}
@container (min-width: 540px) {
  .includes ul { grid-template-columns: 1fr 1fr; }
}
.includes li {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  line-height: 1.4;
}
.includes li .marker {
  flex-shrink: 0;
  width: 14px;
  text-align: center;
  font-weight: 700;
  color: var(--label-tertiary);
}
.includes li.replace { color: var(--label); }
.includes li.replace .marker { color: var(--systemBlue); }

/* Card footer */
.card-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding-top: 12px;
  border-top: 0.5px solid var(--separator);
}
.last {
  font-size: 13px;
  color: var(--label-secondary);
  flex: 1;
  min-width: 0;
  letter-spacing: -0.005em;
}
.last strong { color: var(--label); font-weight: 600; }
button.last {
  appearance: none;
  background: transparent;
  border: 0;
  padding: 0;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: color 0.12s linear;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
button.last:hover strong { color: var(--systemBlue); }
button.last::after {
  content: '›';
  color: var(--label-tertiary);
  font-weight: 700;
  font-size: 14px;
  line-height: 1;
}
button.last:hover::after { color: var(--systemBlue); }

/* History modal list */
.history-list {
  display: grid;
  gap: 4px;
  margin: 14px 0 4px;
  max-height: 50vh;
  overflow-y: auto;
}
.history-list .log-row { background: var(--surface-2); }
.history-list .log-row:hover { background: var(--surface-3); }

/* Buttons */
.btn {
  appearance: none;
  background: var(--surface-2);
  border: 0;
  color: var(--label);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: var(--r-pill);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  letter-spacing: -0.005em;
  white-space: nowrap;
  transition: background-color 0.12s linear, opacity 0.12s linear;
}
.btn:hover  { background: var(--surface-3); }
.btn:active { opacity: 0.7; }

.btn.primary {
  background: var(--systemBlue);
  color: white;
}
.btn.primary:hover { background: var(--systemBlue); filter: brightness(1.08); }

.btn.ghost {
  background: transparent;
  color: var(--label-secondary);
}
.btn.ghost:hover { background: var(--surface-2); color: var(--label); }

/* Empty state */
.empty-section {
  color: var(--label-tertiary);
  font-size: 13px;
  padding: 12px 4px;
}

/* ============ Modal ============ */
.modal-bg {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s linear;
}
@media (prefers-color-scheme: light) {
  .modal-bg { background: rgba(0, 0, 0, 0.25); }
}
.modal-bg.show {
  opacity: 1;
  pointer-events: auto;
}
.modal {
  background: var(--surface);
  border-radius: 18px;
  padding: 22px;
  max-width: 460px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
}
.modal h3 {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.018em;
  margin-bottom: 4px;
}
.modal-sub {
  color: var(--label-secondary);
  font-size: 14px;
  margin-bottom: 18px;
}
.field { margin-bottom: 12px; }
.field label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--label-tertiary);
  margin-bottom: 5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.field input {
  width: 100%;
  background: var(--surface-2);
  border: 0;
  color: var(--label);
  padding: 11px 13px;
  border-radius: var(--r-control);
  font-size: 16px;
  font-family: inherit;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
  transition: background-color 0.12s linear, box-shadow 0.12s linear;
}
.field input:focus {
  outline: none;
  box-shadow: 0 0 0 2px var(--systemBlue);
}
.modal-actions {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 22px;
}
.modal-actions .right { display: flex; gap: 8px; }

/* Footer */
.foot {
  margin-top: 36px;
  text-align: center;
  color: var(--label-tertiary);
  font-size: 13px;
}
.foot strong { color: var(--label-secondary); font-weight: 600; }

/* ============ Tab navigation (iOS segmented control style) ============ */
.tabs {
  background: var(--surface);
  border-radius: var(--r-control);
  padding: 4px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2px;
  margin-bottom: 22px;
}
.tabs .tab {
  appearance: none;
  background: transparent;
  border: 0;
  color: var(--label-secondary);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 9px 12px;
  border-radius: 9px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  -webkit-tap-highlight-color: transparent;
  letter-spacing: -0.005em;
  transition: background-color 0.12s linear, color 0.12s linear;
}
.tabs .tab:hover { color: var(--label); }
.tabs .tab.active {
  background: var(--surface-3);
  color: var(--label);
}
@media (prefers-color-scheme: light) {
  .tabs .tab.active { background: var(--surface); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
  .tabs { background: var(--surface-3); }
}
.tab-section { display: none; }
.tab-section.active { display: block; }

/* ============ Kosten / Brandstof shared list styles ============ */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 2px;
  background: var(--separator-opaque);
  border-radius: var(--r-control);
  overflow: hidden;
  margin-bottom: 24px;
}
.kpi {
  background: var(--surface);
  padding: 12px 14px;
}
.kpi .label {
  font-size: 11px;
  font-weight: 600;
  color: var(--label-tertiary);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.kpi .value {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.022em;
  font-variant-numeric: tabular-nums;
  margin-top: 2px;
}
.kpi .unit {
  font-size: 12px;
  font-weight: 500;
  color: var(--label-tertiary);
  margin-left: 2px;
}
.kpi .sub {
  font-size: 11px;
  color: var(--label-tertiary);
  margin-top: 1px;
  letter-spacing: -0.005em;
}

/* Action row above lists */
.action-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 4px 0 12px;
  flex-wrap: wrap;
}
.action-row .filters {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.action-row .chip {
  appearance: none;
  background: var(--surface);
  border: 1px solid transparent;
  color: var(--label);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: var(--r-pill);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  letter-spacing: -0.005em;
  transition: background-color 0.12s linear, border-color 0.12s linear, color 0.12s linear;
}
.action-row .chip:hover { background: var(--surface-2); }
.action-row .chip.active {
  background: var(--tint-blue);
  border-color: var(--systemBlue);
  color: var(--systemBlue);
}

/* Cost / fueling rows */
.item-list {
  display: grid;
  gap: 4px;
  margin-bottom: 12px;
}
.item-row {
  appearance: none;
  background: var(--surface);
  border: 0;
  border-radius: var(--r-control);
  padding: 12px 14px;
  display: grid;
  grid-template-columns: 36px 1fr auto;
  gap: 12px;
  align-items: center;
  cursor: pointer;
  font-family: inherit;
  color: var(--label);
  text-align: left;
  width: 100%;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 0.12s linear;
}
.item-row:hover  { background: var(--surface-2); }
.item-row:active { background: var(--surface-3); }
.item-row.readonly { cursor: default; }
.item-row.readonly:hover { background: var(--surface); }
.item-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--r-icon);
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}
.item-body { min-width: 0; }
.item-title {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.005em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.item-sub {
  font-size: 12px;
  color: var(--label-secondary);
  margin-top: 2px;
  letter-spacing: -0.005em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.item-amount {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}
.item-amount .unit {
  font-size: 11px;
  color: var(--label-tertiary);
  font-weight: 500;
  margin-left: 2px;
}
.item-amount .sub {
  font-size: 11px;
  color: var(--label-tertiary);
  font-weight: 500;
  margin-top: 2px;
}
.cat-pill {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: var(--r-pill);
  letter-spacing: 0.02em;
  text-transform: uppercase;
  margin-right: 6px;
  vertical-align: 1px;
}
.cat-pill.brandstof  { background: var(--tint-blue);   color: var(--systemBlue); }
.cat-pill.onderhoud  { background: var(--tint-orange); color: var(--systemOrange); }
.cat-pill.verzekering{ background: var(--tint-green);  color: var(--systemGreen); }
.cat-pill.mrb        { background: var(--tint-red);    color: var(--systemRed); }
.cat-pill.overig     { background: var(--surface-2);   color: var(--label-secondary); }

/* Add button (big, primary, inline) */
.add-btn {
  appearance: none;
  background: var(--systemBlue);
  border: 0;
  color: white;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 9px 16px;
  border-radius: var(--r-pill);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  -webkit-tap-highlight-color: transparent;
  letter-spacing: -0.005em;
  transition: filter 0.12s linear;
}
.add-btn:hover { filter: brightness(1.08); }
.add-btn::before { content: '+'; font-size: 17px; font-weight: 700; line-height: 1; }

/* Form select */
.field select {
  width: 100%;
  background: var(--surface-2);
  border: 0;
  color: var(--label);
  padding: 11px 13px;
  border-radius: var(--r-control);
  font-size: 16px;
  font-family: inherit;
  letter-spacing: -0.01em;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='%238e8e93' d='M5 6 0 0h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
  transition: background-color 0.12s linear, box-shadow 0.12s linear;
}
.field select:focus { outline: none; box-shadow: 0 0 0 2px var(--systemBlue); }
.field-note {
  font-size: 12px;
  color: var(--label-tertiary);
  margin-top: 4px;
  letter-spacing: -0.005em;
}

/* Toggle switch (iOS style) */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface-2);
  border-radius: var(--r-control);
  padding: 11px 13px;
  margin-bottom: 12px;
}
.toggle-row .toggle-label {
  font-size: 14px;
  font-weight: 500;
  letter-spacing: -0.005em;
}
.toggle-row .toggle-sub {
  font-size: 12px;
  color: var(--label-secondary);
  margin-top: 2px;
}
.toggle {
  position: relative;
  width: 44px;
  height: 26px;
  background: var(--surface-3);
  border-radius: 999px;
  cursor: pointer;
  transition: background-color 0.18s linear;
  flex-shrink: 0;
}
.toggle::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 22px;
  height: 22px;
  background: white;
  border-radius: 99px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
  transition: left 0.18s linear;
}
.toggle.on { background: var(--systemGreen); }
.toggle.on::after { left: 20px; }

/* ============ Service chips (selector in event modal) ============ */
.svc-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  background: var(--surface-2);
  padding: 10px 12px;
  border-radius: var(--r-control);
}
.svc-chip {
  appearance: none;
  background: var(--surface);
  border: 1px solid transparent;
  color: var(--label-secondary);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  padding: 6px 11px;
  border-radius: var(--r-pill);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  -webkit-tap-highlight-color: transparent;
  letter-spacing: -0.005em;
  transition: background-color 0.12s linear, color 0.12s linear, border-color 0.12s linear;
}
.svc-chip:hover { background: var(--surface-3); color: var(--label); }
.svc-chip.active {
  background: var(--tint-blue);
  border-color: var(--systemBlue);
  color: var(--systemBlue);
  font-weight: 600;
}
.svc-chip .ic { font-size: 14px; line-height: 1; }
@media (prefers-color-scheme: light) {
  .svc-chips { background: var(--surface-2); }
}

@media (max-width: 600px) {
  .tabs .tab { font-size: 13px; padding: 8px 6px; }
  .item-amount { font-size: 14px; }
}

@media (max-width: 600px) {
  .container { padding: 20px 16px max(48px, env(safe-area-inset-bottom)) 16px; }
  .title h1 { font-size: 28px; }
  .km-card { width: 100%; text-align: left; }
  h2.section { font-size: 19px; }
  .toolbar { width: 100%; justify-content: stretch; }
  .toolbar .icon-btn { flex: 1; justify-content: center; }
}

/* ============================================================
   Login screen + car switcher additions (CarDB)
   ============================================================ */

.login-bg {
  position: fixed;
  inset: 0;
  background: var(--bg-grouped);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 200;
}
.login-card {
  background: var(--surface);
  border-radius: 18px;
  padding: 28px 24px;
  max-width: 360px;
  width: 100%;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.15);
}
.login-card h1 {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.022em;
  margin-bottom: 6px;
}
.login-card .sub {
  color: var(--label-secondary);
  font-size: 14px;
  margin-bottom: 18px;
}
.login-card input {
  width: 100%;
  background: var(--surface-2);
  border: 0;
  color: var(--label);
  padding: 12px 14px;
  border-radius: var(--r-control);
  font-size: 16px;
  font-family: inherit;
  margin-bottom: 10px;
}
.login-card input:focus { outline: none; box-shadow: 0 0 0 2px var(--systemBlue); }
.login-card .login-error {
  font-size: 13px;
  color: var(--systemRed);
  min-height: 18px;
  margin-bottom: 6px;
}

/* Car switcher (header) */
.car-switcher {
  appearance: none;
  background: var(--surface);
  border: 0;
  color: var(--label);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 6px 30px 6px 12px;
  border-radius: var(--r-pill);
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='%238e8e93' d='M5 6 0 0h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  appearance: none;
  -webkit-appearance: none;
}

/* Loading + sync indicator */
.sync-indicator {
  font-size: 11px;
  color: var(--label-tertiary);
  text-align: center;
  margin: 8px 0;
  min-height: 14px;
  letter-spacing: -0.005em;
}
.sync-indicator.error { color: var(--systemRed); }
.sync-indicator.ok    { color: var(--systemGreen); }

.app-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  color: var(--label-tertiary);
  font-size: 14px;
}
.app-loading::before {
  content: '';
  width: 20px;
  height: 20px;
  border: 2px solid var(--surface-3);
  border-top-color: var(--systemBlue);
  border-radius: 99px;
  animation: spin 0.8s linear infinite;
  margin-right: 10px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Add-car CTA when no cars exist */
.empty-cars {
  text-align: center;
  padding: 60px 20px;
}
.empty-cars h2 { font-size: 22px; margin-bottom: 8px; }
.empty-cars p { color: var(--label-secondary); margin-bottom: 18px; }

/* ============================================================
   Attachments (bijlagen)
   ============================================================ */
.attachments-section {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 0.5px solid var(--separator);
}
.attachments-section .modal-section { margin: 0 0 8px; padding-top: 0; border-top: 0; }
.attachment-list { display: grid; gap: 4px; margin-bottom: 8px; }
.attachment-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: var(--surface-2);
  border-radius: var(--r-control);
  font-size: 13px;
}
.attachment-row .att-icon { font-size: 18px; line-height: 1; }
.attachment-row a {
  flex: 1;
  min-width: 0;
  color: var(--systemBlue);
  text-decoration: none;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.attachment-row .att-size {
  font-size: 11px;
  color: var(--label-tertiary);
  white-space: nowrap;
}
.attachment-row .att-delete {
  appearance: none;
  background: none;
  border: 0;
  color: var(--label-tertiary);
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 14px;
}
.attachment-row .att-delete:hover { color: var(--systemRed); background: var(--tint-red); }
.attachment-add-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: var(--surface-2);
  border: 1px dashed var(--separator-opaque);
  border-radius: var(--r-pill);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  color: var(--label-secondary);
  font-family: inherit;
}
.attachment-add-btn:hover { color: var(--label); background: var(--surface-3); }
.attachment-empty {
  font-size: 12px;
  color: var(--label-tertiary);
  padding: 4px 0;
}

/* ============================================================
   Chart cards (Kosten tab)
   ============================================================ */
.chart-card {
  background: var(--surface);
  border-radius: var(--r-card);
  padding: 14px 16px;
  margin-bottom: 18px;
  height: 220px;
  position: relative;
}
.chart-card canvas { width: 100% !important; height: 100% !important; }
