/* hidden gilt immer, auch wenn eine Klasse display setzt (etwa .button) */
[hidden] {
  display: none !important;
}

/* ============= TOKENS ============= */
:root {
  color-scheme: light;
  --page: #f4f4f1;
  --surface: #fcfcfb;
  --surface-2: #f0efec;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --ink-3: #6f6d68;
  --line: #e1e0d9;
  --line-strong: #c3c2b7;
  --accent: #2a78d6;
  --accent-ink: #1c5cab;
  --accent-wash: #cde2fb;
  --on-accent: #ffffff;
  --good: #006300;
  --bad: #d03b3b;
  --warn-bg: #fdf1d6;
  --warn-ink: #6b4a00;
  --error-bg: #fbe4e4;
  --error-ink: #8f2020;
  --shadow: 0 1px 2px rgba(11, 11, 11, 0.05), 0 6px 20px rgba(11, 11, 11, 0.05);
  --radius: 14px;
  --radius-s: 9px;
  --nav-h: 62px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --surface-2: #262624;
    --ink: #f0efec;
    --ink-2: #c3c2b7;
    --ink-3: #a3a198;
    --line: #2c2c2a;
    --line-strong: #454541;
    --accent: #3987e5;
    --accent-ink: #86b6ef;
    --accent-wash: #184f95;
    --on-accent: #ffffff;
    --good: #2fc22f;
    --bad: #e66767;
    --warn-bg: #3a2e10;
    --warn-ink: #f4cf7a;
    --error-bg: #3f1d1d;
    --error-ink: #f3a9a9;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
  }
}

:root[data-theme='dark'] {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface: #1a1a19;
  --surface-2: #262624;
  --ink: #f0efec;
  --ink-2: #c3c2b7;
  --ink-3: #a3a198;
  --line: #2c2c2a;
  --line-strong: #454541;
  --accent: #3987e5;
  --accent-ink: #86b6ef;
  --accent-wash: #184f95;
  --on-accent: #ffffff;
  --good: #2fc22f;
  --bad: #e66767;
  --warn-bg: #3a2e10;
  --warn-ink: #f4cf7a;
  --error-bg: #3f1d1d;
  --error-ink: #f3a9a9;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

/* ============= GRUNDLAGEN ============= */
* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  /* Dieselbe Schriftangabe wie in der ersten Version der App */
  font:
    16px/1.45 'Inter',
    sans-serif;
}

h1,
h2,
h3,
p {
  margin: 0;
}
h1 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  outline: none;
}
h2 {
  font-size: 1.05rem;
  font-weight: 650;
}

a {
  color: inherit;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ============= LAYOUT ============= */
.shell {
  display: flex;
  min-height: 100dvh;
}

.main {
  flex: 1;
  min-width: 0;
  padding: 16px 16px calc(var(--nav-h) + 88px + env(safe-area-inset-bottom));
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

#view {
  max-width: 1500px;
}

/* Navigation: unten auf dem Handy, links auf dem Desktop */
.nav {
  position: fixed;
  z-index: 20;
  inset: auto 0 0 0;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface);
  border-top: 1px solid var(--line);
}

.nav__brand,
.nav__theme {
  display: none;
}

.nav__item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 0.68rem;
  font-weight: 550;
  color: var(--ink-3);
  text-decoration: none;
  min-width: 0;
}

.nav__icon {
  font-size: 1.15rem;
  line-height: 1.2;
}

.nav__item[aria-current='page'] {
  color: var(--accent-ink);
}

@media (min-width: 900px) {
  .nav {
    position: sticky;
    top: 0;
    inset: 0 auto auto 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 0 0 212px;
    height: 100dvh;
    padding: 20px 12px;
    border-top: 0;
    border-right: 1px solid var(--line);
  }
  .nav__brand {
    display: block;
    font-weight: 750;
    font-size: 1.1rem;
    padding: 0 12px 16px;
    letter-spacing: -0.01em;
  }
  .nav__theme {
    display: block;
    margin-top: auto;
    padding: 0 4px;
  }
  .nav__item {
    flex-direction: row;
    justify-content: flex-start;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-s);
    font-size: 0.95rem;
  }
  .nav__item:hover {
    background: var(--surface-2);
  }
  .nav__item[aria-current='page'] {
    background: var(--surface-2);
    color: var(--ink);
  }
  .nav__icon {
    width: 1.3em;
    text-align: center;
  }
  .main {
    padding: 24px 28px 96px;
  }
  #topbar-theme {
    display: none;
  }
}

/* ============= BEDIENELEMENTE ============= */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 8px 16px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-s);
  background: var(--surface);
  font-weight: 600;
  cursor: pointer;
}
.button:hover {
  background: var(--surface-2);
}
.button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.button--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}
/* Immer die gleiche dunklere Stufe: Das Weiß der Schrift bleibt so auch im Dark Mode lesbar */
.button--primary:hover {
  background: #1c5cab;
  border-color: #1c5cab;
}
.button--danger {
  background: var(--bad);
  border-color: var(--bad);
  color: #fff;
}
.button--danger:hover {
  background: var(--bad);
  filter: brightness(0.92);
}
.button--small {
  min-height: 36px;
  padding: 4px 12px;
  font-size: 0.88rem;
}

.icon-button {
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: var(--radius-s);
  background: transparent;
  color: var(--ink-2);
  cursor: pointer;
}
.icon-button:hover {
  background: var(--surface-2);
  color: var(--ink);
}

.segmented {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  max-width: 100%;
  overflow-x: auto;
  background: var(--surface-2);
  border-radius: 10px;
  scrollbar-width: none;
}
.segmented button {
  flex: none;
  min-height: 36px;
  padding: 4px 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink-2);
  font-size: 0.9rem;
  font-weight: 550;
  white-space: nowrap;
  cursor: pointer;
}
.segmented button[aria-pressed='true'] {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(11, 11, 11, 0.14);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  font-size: 0.86rem;
  font-weight: 550;
  color: var(--ink-2);
}

input[type='date'],
input[type='time'],
input[type='number'],
input[type='text'],
input[type='password'],
input[type='url'],
input[type='search'],
select,
textarea {
  width: 100%;
  min-height: 44px;
  padding: 8px 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-s);
  background: var(--surface);
  color: var(--ink);
  font-size: 16px; /* verhindert das Einzoomen unter iOS */
  font-weight: 400;
}
textarea {
  min-height: 72px;
  resize: vertical;
}

.check {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  font-weight: 550;
  cursor: pointer;
}
.check input {
  width: 20px;
  height: 20px;
  accent-color: var(--accent);
}

/* ============= FILTERLEISTE ============= */
.sr-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.filter {
  z-index: 10;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 8px 12px;
  margin: 0 -16px 16px;
  padding: 8px 16px;
  background: var(--page);
  border-bottom: 1px solid var(--line);
}
.filter .field {
  flex-direction: row;
  align-items: center;
  gap: 6px;
  max-width: 100%;
}
/* Lange Fahrzeugnamen dürfen die Auswahl nicht über den Rand schieben */
.filter select,
.filter input {
  min-height: 38px;
  padding: 4px 8px;
  width: auto;
  min-width: 0;
  max-width: 100%;
  flex: 0 1 auto;
}
.filter__range {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.filter__info {
  flex-basis: 100%;
  font-size: 0.8rem;
  color: var(--ink-3);
}

@media (min-width: 900px) {
  .filter {
    position: sticky;
    top: 0;
    margin: 0 -28px 20px;
    padding: 10px 28px;
  }
}

/* ============= KARTEN UND DASHBOARD ============= */
.grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr));
}
.grid + .grid,
.grid + .card,
.card + .grid,
.kpis + .grid,
.stack > * + * {
  margin-top: 14px;
}

.card {
  container-type: inline-size;
  min-width: 0;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card__head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px 12px;
  margin-bottom: 8px;
}
/* Sonst schieben breite Umschalter die ganze Seite auf */
.card__head > * {
  min-width: 0;
  max-width: 100%;
}
.card__sub {
  margin-top: 2px;
  font-size: 0.85rem;
  color: var(--ink-3);
}
.card__sub--spaced {
  margin-top: 10px;
}
/* Breite Tabellen belegen die ganze Reihe des Rasters */
.card--wide {
  grid-column: 1 / -1;
}
.scroll-x {
  overflow-x: auto;
}

.dash-section {
  margin-top: 28px;
}
.dash-section__title {
  margin-bottom: 10px;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.facts {
  display: grid;
  gap: 14px 16px;
  margin: 0;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.facts--compact {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
@container (min-width: 520px) {
  .facts:not(.facts--compact) {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
.fact {
  min-width: 0;
}
.fact dt {
  font-size: 0.8rem;
  font-weight: 550;
  color: var(--ink-2);
}
.fact dd {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.fact .fact__note {
  font-size: 0.78rem;
  font-weight: 400;
  color: var(--ink-3);
  letter-spacing: 0;
}
.facts--compact .fact dd {
  font-size: 0.98rem;
}

/* Kennzahlen passen sich ihrem eigenen Container an, nicht dem Fenster */
.kpis {
  container-type: inline-size;
  margin-bottom: 14px;
}
.kpis__grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
@container (min-width: 620px) {
  .kpis__grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
@container (min-width: 1100px) {
  .kpis__grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }
}

.kpi {
  padding: 14px;
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.kpi__label {
  font-size: 0.82rem;
  color: var(--ink-2);
  font-weight: 550;
}
.kpi__value {
  margin-top: 2px;
  font-size: clamp(1.35rem, 5.4cqi, 1.8rem);
  font-weight: 720;
  letter-spacing: -0.02em;
  line-height: 1.2;
}
.kpi__unit {
  font-size: 0.55em;
  font-weight: 550;
  color: var(--ink-2);
  letter-spacing: 0;
}
.kpi__delta {
  margin-top: 4px;
  font-size: 0.78rem;
  color: var(--ink-3);
}
.delta--good {
  color: var(--good);
  font-weight: 600;
}
.delta--bad {
  color: var(--bad);
  font-weight: 600;
}

.insight {
  font-size: 1.02rem;
  line-height: 1.5;
}
.effects {
  display: grid;
  gap: 8px;
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
  grid-template-columns: 1fr;
}
.effects li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 10px;
  background: var(--surface-2);
  border-radius: var(--radius-s);
  font-size: 0.9rem;
}
.effects b {
  font-variant-numeric: tabular-nums;
}
@container (min-width: 480px) {
  .effects {
    grid-template-columns: repeat(3, 1fr);
  }
}

.forecast {
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr;
}
@container (min-width: 420px) {
  .forecast {
    grid-template-columns: 1fr 1fr;
  }
}
.forecast__label {
  font-size: 0.82rem;
  font-weight: 550;
  color: var(--ink-2);
}
.forecast__value {
  font-size: 1.5rem;
  font-weight: 720;
  letter-spacing: -0.02em;
}
.forecast__note {
  font-size: 0.82rem;
  color: var(--ink-3);
}

.empty {
  padding: 28px 12px;
  text-align: center;
  color: var(--ink-3);
}

/* ============= CHARTS ============= */
.chart {
  width: 100%;
  height: 320px;
}
@container (max-width: 480px) {
  .chart {
    height: 270px;
  }
}

.chart-table {
  max-height: 260px;
  overflow: auto;
  margin-top: 10px;
  font-size: 0.85rem;
}
.effects-table {
  margin-top: 12px;
}

/* ============= TABELLE UND KARTENLISTE ============= */
.history {
  container-type: inline-size;
}
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}
.toolbar__group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.columns {
  position: relative;
}
.columns > summary {
  list-style: none;
}
.columns > summary::-webkit-details-marker {
  display: none;
}
.columns__menu {
  position: absolute;
  z-index: 6;
  right: 0;
  margin-top: 4px;
  min-width: 190px;
  padding: 8px 12px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-s);
  box-shadow: var(--shadow);
}
.columns__menu .check {
  min-height: 34px;
  font-weight: 450;
  font-size: 0.9rem;
}

.table-wrap {
  display: none;
  max-height: calc(100dvh - 300px);
  min-height: 280px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.entry-cards {
  display: grid;
  gap: 10px;
}
@container (min-width: 760px) {
  .table-wrap {
    display: block;
  }
  .entry-cards {
    display: none;
  }
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.9rem;
}
th,
td {
  padding: 8px 10px;
  text-align: right;
  white-space: nowrap;
  border-bottom: 1px solid var(--line);
  font-variant-numeric: tabular-nums;
}
th.text,
td.text {
  text-align: left;
}
td.wrap {
  white-space: normal;
  min-width: 160px;
}
thead th {
  position: sticky;
  top: 0;
  z-index: 3;
  background: var(--surface-2);
  font-weight: 650;
}
thead th button {
  all: unset;
  cursor: pointer;
}
thead th button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
tbody th,
tbody td:first-child {
  position: sticky;
  left: 0;
  background: var(--surface);
}
thead th:first-child {
  left: 0;
  z-index: 4;
}
tbody tr:hover td {
  background: var(--surface-2);
}
tbody tr:last-child td {
  border-bottom: 0;
}

.entry-card {
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.entry-card__top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
}
.entry-card__date {
  font-weight: 650;
}
.entry-card__main {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.entry-card__facts {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px 10px;
  margin: 8px 0 0;
}
.entry-card__facts div {
  min-width: 0;
}
.entry-card__facts dt {
  font-size: 0.74rem;
  color: var(--ink-3);
}
.entry-card__facts dd {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 550;
  font-variant-numeric: tabular-nums;
}
.entry-card__meta {
  margin-top: 8px;
  font-size: 0.85rem;
  color: var(--ink-2);
  overflow-wrap: anywhere;
}
/* Links ausgerichtet, damit der "+"-Button die Aktionen nicht verdeckt */
.entry-card__actions {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}

.badge {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 99px;
  background: var(--surface-2);
  color: var(--ink-2);
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
}

/* ============= FORMULAR ============= */
.form-layout {
  container-type: inline-size;
}
.entry-form {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.entry-form .span-full {
  grid-column: 1 / -1;
}
.entry-form .span-2 {
  grid-column: span 2;
}
@container (min-width: 680px) {
  .entry-form {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

.topbar {
  flex-wrap: wrap;
}
/* Auf schmalen Bildschirmen rutschen die Aktionen in eine eigene Zeile statt über den Rand */
.topbar__actions {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  max-width: 100%;
  margin-left: auto;
}
a.button {
  text-decoration: none;
}
label.button {
  font-weight: 600;
}
.tabs {
  margin-bottom: 14px;
}

/* Suche und Sammelzuordnung im Verlauf */
.search {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}
.search select,
.search input {
  width: auto;
  min-height: 38px;
  padding: 4px 8px;
  max-width: 100%;
  flex: 0 1 auto;
}
.search .search__text {
  flex: 1 1 240px;
}
.search__count {
  margin-bottom: 8px;
}
.bulk {
  position: sticky;
  top: 8px;
  z-index: 7;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--accent);
  border-radius: var(--radius-s);
  box-shadow: var(--shadow);
}
.bulk select {
  width: auto;
  min-height: 36px;
  padding: 4px 8px;
  max-width: 100%;
}
/* Auf dem Desktop scrollt die Tabelle selbst und die Filterleiste klebt schon oben */
@media (min-width: 900px) {
  .bulk {
    position: static;
  }
}
.select-box {
  width: 18px;
  height: 18px;
  vertical-align: -3px;
  accent-color: var(--accent);
}

/* Listen, die unabhängig von der Breite Karten bleiben */
.entry-cards--always {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr));
}

/* Fälligkeiten: Status steht immer auch als Text und Symbol da */
.due__state {
  flex: none;
  font-size: 0.82rem;
  font-weight: 650;
}
.due--overdue {
  border-color: var(--bad);
}
.due--overdue .due__state,
.due-banner__row.due--overdue b {
  color: var(--bad);
}
.due--soon .due__state,
.due-banner__row.due--soon b {
  color: var(--warn-ink);
}
.due-banner {
  display: grid;
  gap: 6px;
  justify-items: start;
  margin-bottom: 14px;
  padding: 12px 14px;
  background: var(--warn-bg);
  border-radius: var(--radius);
}
.due-banner__row {
  font-size: 0.92rem;
  color: var(--ink);
  overflow-wrap: anywhere;
}

/* Bearbeiten und Löschen bleiben sichtbar, auch wenn die Tabelle seitlich scrollt */
.table-wrap td.actions {
  position: sticky;
  right: 0;
  z-index: 2;
  background: var(--surface);
}
.table-wrap th.actions {
  position: sticky;
  right: 0;
  z-index: 4;
}
.table-wrap tbody tr:hover td.actions {
  background: var(--surface-2);
}

/* Belege aus Paperless */
.receipt[hidden] {
  display: none;
}
.receipt {
  gap: 6px;
}
.receipt__current {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  min-height: 36px;
  font-weight: 400;
}
.receipt__inputs {
  display: flex;
  gap: 8px;
}
.receipt__inputs .receipt__search {
  flex: 1 1 auto;
  min-width: 0;
}
.receipt__inputs .receipt__number {
  flex: 0 0 96px;
  width: 96px;
}
.receipt__results {
  display: grid;
  gap: 4px;
  max-height: 220px;
  overflow: auto;
}
.receipt__results:empty {
  display: none;
}
.receipt__result {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 2px 10px;
  width: 100%;
  min-height: 44px;
  padding: 6px 10px;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  cursor: pointer;
}
.receipt__result:hover {
  background: var(--surface-2);
}
.receipt__title {
  font-weight: 550;
  overflow-wrap: anywhere;
}
.receipt-link {
  color: var(--accent-ink);
  font-weight: 600;
  font-size: 0.9rem;
  align-self: center;
}
.entry-card__actions .receipt-link {
  margin-right: auto;
}

/* Kennzeichen: Teile in der Breite ihrer Zeichenzahl, damit es nach einem Nummernschild aussieht */
.plate {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.plate input {
  min-width: 0;
  padding: 8px 6px;
  text-align: center;
  font-weight: 650;
  letter-spacing: 0.04em;
}
.plate__ort {
  flex: 3 1 0;
}
.plate__buchstaben {
  flex: 2.4 1 0;
}
.plate__zahl {
  flex: 4 1 0;
}
.plate select.plate__suffix {
  flex: 0 0 62px;
  width: 62px;
  padding: 8px 4px;
}
.plate__dash {
  flex: none;
  font-weight: 700;
  color: var(--ink-2);
}

.chooser {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  margin-bottom: 12px;
}
.chooser--inline {
  margin-bottom: 0;
  gap: 0 12px;
}
.chooser--inline .check,
.check--compact {
  min-height: 38px;
  font-size: 0.9rem;
  font-weight: 500;
  gap: 6px;
}
.badge--good {
  color: var(--good);
}

.entry-form .span-ort {
  grid-column: span 1;
}
@container (min-width: 680px) {
  .entry-form .span-ort {
    grid-column: span 3;
  }
}

.vehicle-card .entry-card__actions {
  flex-wrap: wrap;
  margin-top: 12px;
}

.preview {
  padding: 12px;
  background: var(--surface-2);
  border-radius: var(--radius-s);
}
.preview__facts {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
.preview__facts dt {
  font-size: 0.74rem;
  color: var(--ink-2);
}
.preview__facts dd {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
}
.preview dl {
  margin: 0;
}
.preview__note {
  margin-top: 8px;
  font-size: 0.84rem;
  color: var(--ink-2);
}

.alert {
  padding: 8px 12px;
  border-radius: var(--radius-s);
  font-size: 0.88rem;
}
.alert--warn {
  background: var(--warn-bg);
  color: var(--warn-ink);
}
.alert--error {
  background: var(--error-bg);
  color: var(--error-ink);
}
.alerts {
  display: grid;
  gap: 6px;
}
.alerts:empty {
  display: none;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.form-actions .button--primary {
  flex: 1 1 200px;
}

/* ============= DIALOGE ============= */
.fab {
  position: fixed;
  z-index: 15;
  right: 16px;
  bottom: calc(var(--nav-h) + 16px + env(safe-area-inset-bottom));
  width: 56px;
  height: 56px;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 1.5rem;
  box-shadow: 0 4px 14px rgba(11, 11, 11, 0.28);
  cursor: pointer;
}
.fab[hidden] {
  display: none;
}
@media (min-width: 900px) {
  .fab {
    bottom: 24px;
    right: 28px;
  }
}

dialog {
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
}
dialog::backdrop {
  background: rgba(11, 11, 11, 0.5);
}

.sheet {
  width: 100%;
  max-width: 100%;
  max-height: 92dvh;
  margin: auto 0 0;
  padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
  border-radius: 18px 18px 0 0;
  overflow: auto;
}
.sheet__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
@media (min-width: 720px) {
  .sheet {
    width: 680px;
    max-width: calc(100vw - 48px);
    margin: auto;
    border-radius: 18px;
    padding: 20px;
  }
}

.confirm {
  max-width: min(420px, calc(100vw - 32px));
  padding: 20px;
  border-radius: var(--radius);
}
.confirm__actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}

.toast {
  position: fixed;
  z-index: 40;
  left: 50%;
  bottom: calc(var(--nav-h) + 86px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  max-width: calc(100vw - 32px);
  padding: 10px 16px;
  background: var(--ink);
  color: var(--surface);
  border-radius: var(--radius-s);
  font-size: 0.9rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.toast--show {
  opacity: 1;
}
@media (min-width: 900px) {
  .toast {
    bottom: 24px;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
  }
}

.nav__item > span:last-child {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ============= ANMELDUNG ============= */
.login {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 16px;
}
.login__card {
  width: min(420px, 100%);
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.login__card h1 {
  margin: 0;
  font-size: 1.4rem;
  letter-spacing: -0.01em;
}
.login__card form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.login__card input:not([type='checkbox']) {
  width: 100%;
}
.login__divider {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink-3);
  font-size: 0.82rem;
}
.login__divider::before,
.login__divider::after {
  content: '';
  flex: 1;
  border-top: 1px solid var(--line);
}
.button--block {
  width: 100%;
  justify-content: center;
}

/* ============= EINSTELLUNGEN ============= */
.settings-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 8px 0;
}
.settings-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  background: var(--surface);
}
.settings-row__main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.settings-row__actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.facts {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 4px 14px;
  margin: 8px 0;
  font-size: 0.9rem;
}
.facts dt {
  color: var(--ink-3);
}
.facts dd {
  margin: 0;
  overflow-wrap: anywhere;
}

/* Auswahl mehrerer Tags als Schaltflächen */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.chip {
  min-height: 32px;
  padding: 3px 10px;
  border-radius: 99px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink-2);
  font-size: 0.82rem;
  cursor: pointer;
}
.chip[aria-pressed='true'] {
  background: var(--accent-wash);
  border-color: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
}
.chips__filter {
  width: 100%;
  margin-bottom: 4px;
}
.chips__box {
  max-height: 180px;
  overflow: auto;
  padding: 2px;
}
.field-map {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 6px;
  align-items: center;
}
.receipt__upload {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-s);
}

/* ============= OFFLINE (PWA) ============= */
.badge--pending {
  background: var(--warn-bg);
  color: var(--warn-ink);
}
.badge--error {
  background: var(--error-bg);
  color: var(--error-ink);
  white-space: normal;
}
.offline-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  margin: 0 0 12px;
  padding: 8px 12px;
  border-radius: 10px;
  background: var(--warn-bg);
  color: var(--warn-ink);
  font-size: 0.85rem;
}
.offline-bar[hidden] {
  display: none;
}
.offline-bar .button {
  margin-left: auto;
}
