/* Fahrzeugverwaltung – Oberfläche */
:root {
  color-scheme: light;
  --bg: #f3f3f0;
  --surface: #fcfcfb;
  --surface-2: #efefeb;
  --line: #e1e0da;
  --text: #1b1b19;
  --text-2: #55544f;
  --muted: #74736d;
  --accent: #0e4f63;
  --accent-2: #136a83;
  --accent-soft: #e2eef1;
  --on-accent: #ffffff;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --warn: #8a5a00;
  --warn-soft: #fdf3dc;
  --ok: #1e6b3a;
  --ok-soft: #e5f3e9;
  --shadow: 0 1px 2px rgba(20, 20, 15, .06), 0 2px 8px rgba(20, 20, 15, .04);
  --radius: 12px;
  --c1: #2a78d6; --c2: #eb6834; --c3: #1baf7a; --c4: #eda100; --c5: #e87ba4; --c6: #008300; --c7: #6250d6; --c8: #e34948;
  --safe-b: env(safe-area-inset-bottom, 0px);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.45;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #121211;
    --surface: #1b1b1a;
    --surface-2: #252523;
    --line: #34342f;
    --text: #f0efec;
    --text-2: #c3c2b7;
    --muted: #9b9a91;
    --accent: #5fb3c9;
    --accent-2: #7cc3d6;
    --accent-soft: #19343c;
    --on-accent: #0b1f25;
    --danger: #f08a80;
    --danger-soft: #3a1c19;
    --warn: #f1c25b;
    --warn-soft: #362a10;
    --ok: #7fcf98;
    --ok-soft: #173020;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
    --c1: #3987e5; --c2: #d95926; --c3: #199e70; --c4: #c98500; --c5: #d55181; --c6: #008300; --c7: #9085e9; --c8: #e66767;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); min-height: 100vh; -webkit-tap-highlight-color: transparent; }
a { color: var(--accent); }
h1 { font-size: 1.55rem; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 1.05rem; margin: 0 0 .75rem; display: flex; align-items: center; gap: .45rem; }
h3 { font-size: .95rem; }
p { margin: .4rem 0; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }
[hidden] { display: none !important; }
.icon { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
code { background: var(--surface-2); padding: 1px 6px; border-radius: 4px; }

/* Splash */
.splash { display: grid; place-items: center; min-height: 100vh; }
.spinner { width: 34px; height: 34px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; min-height: 40px; padding: 0 14px; border-radius: 9px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text); font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--surface-2); }
.btn:focus-visible, .icon-btn:focus-visible, a:focus-visible, select:focus-visible, input:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { background: var(--accent-2); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger.ghost { color: var(--danger); background: transparent; }
.btn.small { min-height: 34px; padding: 0 11px; font-size: .88rem; }
.btn.block { width: 100%; margin-top: .6rem; }
.btn:disabled { opacity: .55; cursor: default; }
.btn-group { display: inline-flex; gap: .4rem; flex-wrap: wrap; }
.btn-group.wrap { margin-top: .8rem; }
.icon-btn { display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 9px; border: 0; background: transparent; color: var(--text-2); cursor: pointer; }
.icon-btn:hover { background: var(--surface-2); }
.linklike { background: none; border: 0; padding: 0 .3rem; color: var(--accent); font: inherit; cursor: pointer; text-decoration: underline; }

/* Layout */
#app { min-height: 100vh; }
.sidebar { display: none; }
.content { min-height: 100vh; padding-bottom: calc(76px + var(--safe-b)); }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: .5rem; padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--line); }
.topbar b { flex: 1; }
.logo { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; background: var(--accent); color: var(--on-accent); }
main { padding: 16px; max-width: 1100px; margin: 0 auto; outline: none; }
.view > * + * { margin-top: 14px; }
.bottomnav { position: fixed; z-index: 30; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: repeat(5, 1fr); background: var(--surface);
  border-top: 1px solid var(--line); padding-bottom: var(--safe-b); }
.bot-link { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0 7px; color: var(--muted); text-decoration: none; font-size: .72rem; border: 0; background: none; font-family: inherit; cursor: pointer; }
.bot-link.active { color: var(--accent); font-weight: 600; }
.bot-link.nav-add .icon { background: var(--accent); color: var(--on-accent); border-radius: 50%; width: 38px; height: 38px; padding: 7px; margin-top: -14px; box-shadow: var(--shadow); }
.bot-link.nav-add { color: var(--text-2); }

@media (min-width: 900px) {
  #app { display: grid; grid-template-columns: 232px 1fr; }
  .sidebar { display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; padding: 18px 12px; background: var(--surface); border-right: 1px solid var(--line); }
  .sidebar .brand { display: flex; align-items: center; gap: .6rem; padding: 0 8px 18px; }
  .sidebar nav { display: flex; flex-direction: column; gap: 2px; }
  .side-link { display: flex; align-items: center; gap: .7rem; padding: 10px 12px; border-radius: 9px; color: var(--text-2); text-decoration: none; font-weight: 500; border: 0; background: none; font: inherit; cursor: pointer; text-align: left; }
  .side-link:hover { background: var(--surface-2); }
  .side-link.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
  .side-link.nav-add { background: var(--accent); color: var(--on-accent); margin: 8px 0; font-weight: 600; }
  .side-foot { margin-top: auto; }
  .topbar, .bottomnav { display: none; }
  .content { padding-bottom: 24px; }
  main { padding: 28px 32px; }
}

/* Sync-Anzeige */
.sync-ind { display: inline-flex; align-items: center; gap: .35rem; border: 1px solid var(--line); background: var(--surface); color: var(--ok); border-radius: 99px; padding: 4px 10px; font: inherit; font-size: .78rem; cursor: pointer; }
.sync-ind.pending { color: var(--warn); }
.sync-ind.off { color: var(--muted); }
.sync-ind.err { color: var(--danger); }
.sync-ind.busy .icon { animation: spin 1s linear infinite; }
.banner { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; padding: 10px 16px; background: var(--warn-soft); color: var(--warn); font-weight: 500; }
.banner span { flex: 1; }

/* Seitenkopf */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.filters select { min-height: 40px; width: auto; max-width: 100%; }
.back { display: inline-flex; align-items: center; gap: .25rem; color: var(--muted); text-decoration: none; font-size: .9rem; }

/* Karten */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: .6rem; }
.card-head h2 { margin: 0; }
.list-card { padding: 6px 0; }
.list-card .card-head { padding: 10px 16px 4px; }
.empty { text-align: center; padding: 36px 16px; color: var(--muted); background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius); }
.empty .btn { margin-top: .8rem; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.ro-tag { display: inline-block; font-size: .72rem; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: var(--surface-2); color: var(--muted); margin-left: .4rem; vertical-align: middle; }

.vehicle-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); }
.vehicle-card { position: relative; display: block; text-decoration: none; color: inherit; transition: border-color .15s; }
.vehicle-card:hover { border-color: var(--accent); }
.vehicle-card.inactive { opacity: .6; }
.vehicle-card .ro-tag { position: absolute; top: 14px; right: 14px; }
.vc-head { display: flex; gap: .7rem; align-items: center; margin-bottom: .8rem; }
.vc-icon { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); }
.vc-facts { display: grid; grid-template-columns: auto 1fr; gap: 5px 12px; margin: 0; font-size: .9rem; }
.vc-facts dt { color: var(--muted); }
.vc-facts dd { margin: 0; text-align: right; display: flex; justify-content: flex-end; align-items: center; gap: .3rem; flex-wrap: wrap; }

/* Status */
.badge { display: inline-flex; align-items: center; gap: 3px; font-size: .74rem; font-weight: 700; padding: 2px 8px 2px 6px; border-radius: 99px; white-space: nowrap; }
.badge.due { background: var(--danger-soft); color: var(--danger); }
.badge.soon { background: var(--warn-soft); color: var(--warn); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.unknown { background: var(--surface-2); color: var(--muted); }
.due-list { list-style: none; margin: 0; padding: 0; }
.due-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); }
.due-row:first-child { border-top: 0; }
.due-main { flex: 1; min-width: 0; }
.due-title { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.due-title a { font-size: .88rem; text-decoration: none; }
.row-actions { display: flex; gap: 4px; align-items: center; }

/* Kennzahlen */
.kpis { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; gap: 2px; box-shadow: var(--shadow); }
.kpi-label { font-size: .82rem; color: var(--muted); }
.kpi-value { font-size: 1.35rem; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }

/* Tabs */
.tabs { display: flex; gap: 4px; overflow-x: auto; border-bottom: 1px solid var(--line); scrollbar-width: none; }
.tabs a { padding: 10px 14px; text-decoration: none; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-body > * + * { margin-top: 14px; }

/* Listen */
.entry-list { list-style: none; margin: 0; padding: 0; }
.entry-list li { display: flex; gap: 12px; align-items: flex-start; padding: 11px 16px; border-top: 1px solid var(--line); }
.entry-list li:first-child { border-top: 0; }
.entry-list li.clickable { cursor: pointer; }
.entry-list li.clickable:hover { background: var(--surface-2); }
.entry-date { flex: none; width: 82px; color: var(--muted); font-size: .88rem; font-variant-numeric: tabular-nums; padding-top: 1px; }
.entry-main { flex: 1; min-width: 0; }
.entry-main b { display: inline-flex; align-items: center; gap: .3rem; }
.entry-amount { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.pending { color: var(--warn); display: inline-flex; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.chip { display: inline-flex; align-items: center; gap: 4px; border: 1px solid var(--line); background: var(--surface-2); color: var(--text-2); border-radius: 99px; padding: 3px 10px; font: inherit; font-size: .78rem; cursor: pointer; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; margin: 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
.notes { white-space: pre-wrap; background: var(--surface-2); padding: 10px 12px; border-radius: 8px; }
@media (max-width: 520px) { .entry-date { width: 70px; font-size: .8rem; } .entry-list li { padding: 10px 12px; } }

/* Tabellen */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th, .table td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; }
.table thead th { color: var(--muted); font-weight: 600; font-size: .82rem; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table.access td { min-width: 140px; }
.table.access select { width: 100%; }
select.lvl-write { background: var(--ok-soft); }
select.lvl-read { background: var(--accent-soft); }

/* Formulare */
.form { display: flex; flex-wrap: wrap; gap: 12px 14px; }
.field { display: flex; flex-direction: column; gap: 5px; flex: 1 1 100%; min-width: 0; }
.field.half { flex: 1 1 calc(50% - 7px); }
@media (max-width: 420px) { .field.half { flex-basis: 100%; } }
.field > span { font-size: .86rem; font-weight: 600; color: var(--text-2); }
.field .req { color: var(--danger); }
.field.check { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 10px; }
.field.check > span { font-weight: 500; color: var(--text); font-size: .95rem; flex: 1; }
.field.check .help { flex-basis: 100%; padding-left: 30px; margin-top: -4px; }
.help { color: var(--muted); font-size: .8rem; }
input, select, textarea { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 9px; padding: 9px 11px; min-height: 42px; width: 100%; }
textarea { resize: vertical; }
input[type=checkbox] { width: 20px; height: 20px; min-height: 0; accent-color: var(--accent); margin: 0; }
input[type=file] { padding: 7px; }
input.invalid, select.invalid { border-color: var(--danger); box-shadow: 0 0 0 1px var(--danger); }
input:disabled, select:disabled { opacity: .7; }
.with-suffix { position: relative; display: flex; }
.with-suffix input { padding-right: 62px; }
.with-suffix .suffix { position: absolute; right: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: .88rem; pointer-events: none; }
.form-heading { flex-basis: 100%; margin: 6px 0 -4px; font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.form-error { flex-basis: 100%; background: var(--danger-soft); color: var(--danger); padding: 10px 12px; border-radius: 9px; font-weight: 500; }
.inline-form { display: flex; gap: 8px; flex-wrap: wrap; }
.inline-form input { flex: 1; min-width: 200px; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 0; border-top: 1px solid var(--line); }
.set-row:first-of-type { border-top: 0; }
.set-row > div { min-width: 0; }

/* Dialoge */
.overlay { position: fixed; inset: 0; z-index: 100; background: rgba(15, 15, 12, .45); display: flex; align-items: flex-end; justify-content: center; animation: fade .15s; }
.overlay.closing { opacity: 0; transition: opacity .18s; }
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(24px); } }
.sheet { background: var(--surface); width: 100%; max-height: 92vh; border-radius: 16px 16px 0 0; display: flex; flex-direction: column; animation: up .2s; padding-bottom: var(--safe-b); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 14px 12px 8px 18px; }
.sheet-head h2 { margin: 0; font-size: 1.12rem; }
.sheet-body { overflow-y: auto; padding: 4px 18px 16px; }
.sheet-foot { display: flex; gap: 8px; justify-content: flex-end; padding: 12px 18px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.sheet-foot .left { margin-right: auto; }
@media (min-width: 700px) {
  .overlay { align-items: center; padding: 24px; }
  .sheet { max-width: 560px; border-radius: 16px; max-height: 88vh; }
  .sheet.wide { max-width: 900px; }
}
.preview-img { max-width: 100%; border-radius: 8px; display: block; margin: 0 auto; }
.preview-pdf { width: 100%; height: 70vh; border: 1px solid var(--line); border-radius: 8px; }
.quick-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.quick { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; text-align: left; padding: 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); color: var(--text); font: inherit; cursor: pointer; }
.quick:hover { border-color: var(--accent); background: var(--accent-soft); }
.quick .icon { color: var(--accent); margin-bottom: 4px; }
.quick small { color: var(--muted); }
.totp ol { padding-left: 1.2rem; }
.qr { display: flex; justify-content: center; margin: 10px 0; }
.qr svg { max-width: 220px; height: auto; border-radius: 8px; }
.secret { word-break: break-all; font-size: .9rem; }
pre.log { background: var(--surface-2); padding: 10px; border-radius: 8px; white-space: pre-wrap; }

/* Toasts */
#toasts { position: fixed; z-index: 200; left: 50%; transform: translateX(-50%); bottom: calc(86px + var(--safe-b)); display: flex; flex-direction: column; gap: 8px; width: min(92vw, 420px); pointer-events: none; }
@media (min-width: 900px) { #toasts { bottom: 24px; } }
.toast { background: #22221f; color: #fff; padding: 11px 14px; border-radius: 10px; box-shadow: 0 4px 16px rgba(0,0,0,.25); font-weight: 500; transition: opacity .3s, transform .3s; }
.toast.ok { background: #1e5b34; }
.toast.warn { background: #7a5200; }
.toast.error { background: #9b2016; }
.toast:nth-last-child(n+4) { display: none; }
.toast.out { opacity: 0; transform: translateY(8px); }

/* Anmeldung */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.auth-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 26px 24px; box-shadow: var(--shadow); }
.auth-card .brand { display: flex; align-items: center; gap: .7rem; margin-bottom: 22px; }
.auth-card .brand .logo { width: 46px; height: 46px; border-radius: 12px; }
.auth-card .brand small { display: block; color: var(--muted); }
.auth-card h1 { font-size: 1.3rem; margin-bottom: .6rem; }
.auth-card form > * + * { margin-top: 12px; }

/* Diagramme */
.chart-box { position: relative; }
.chart { width: 100%; height: auto; display: block; touch-action: pan-y; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .axis { stroke: var(--muted); stroke-width: 1; }
.chart .tick { fill: var(--muted); font-size: 11px; font-family: inherit; }
.chart .line { fill: none; stroke-width: 2; }
.chart .dot { stroke: var(--surface); stroke-width: 2; }
.chart .crosshair { stroke: var(--muted); stroke-dasharray: 3 3; }
.chart .hover-col { fill: var(--surface-2); }
.chart-tip { position: absolute; pointer-events: none; background: var(--surface); border: 1px solid var(--line); box-shadow: 0 4px 14px rgba(0,0,0,.12); border-radius: 8px; padding: 8px 10px; font-size: .8rem; min-width: 140px; z-index: 5; }
.tip-title { font-weight: 700; margin-bottom: 4px; }
.tip-row { display: flex; align-items: center; gap: 6px; }
.tip-row span { flex: 1; color: var(--text-2); }
.tip-row i, .legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: .82rem; color: var(--text-2); margin-top: 8px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.barlist { display: flex; flex-direction: column; gap: 8px; }
.barrow { display: grid; grid-template-columns: minmax(90px, 160px) 1fr auto; gap: 10px; align-items: center; font-size: .9rem; }
.barlabel { color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bartrack { height: 14px; }
.bar { display: block; height: 100%; background: var(--c1); border-radius: 0 4px 4px 0; }
.barvalue { font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; min-width: 80px; }
.form-info { flex-basis: 100%; margin: -4px 0 0; }
