:root {
  /* Farbschema „Schilf im Herbst“: gedecktes Schilf-/Salbeigrün, warme Stroh- und Ockertöne */
  --bg: #f4f3ec;
  --bg-2: #ebe9df;
  --card: #fffef9;
  --text: #262a21;
  --muted: #6d7062;
  --line: #e2dfd2;
  --line-strong: #cfcbb9;
  --accent: #5e7150;
  --accent-2: #a88d55;
  --accent-ink: #ffffff;
  --accent-soft: #e7ebde;
  --danger: #a5452f;
  --danger-soft: #f7e7e1;
  --warn: #946716;
  --warn-soft: #f6ecd4;
  --ok: #4d7a3c;
  --ok-soft: #e4eedb;
  --violet-soft: #f1ead7;
  --violet: #8c7038;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(45, 45, 25, .05), 0 2px 8px rgba(45, 45, 25, .05);
  --shadow-hover: 0 4px 10px rgba(45, 45, 25, .07), 0 14px 32px rgba(45, 45, 25, .10);
  --shadow-pop: 0 24px 60px rgba(30, 32, 18, .28);
  --topbar: rgba(244, 243, 236, .84);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #151712;
    --bg-2: #1b1e17;
    --card: #1f231b;
    --text: #e8e8de;
    --muted: #a2a593;
    --line: #2e3329;
    --line-strong: #3c4335;
    --accent: #a9bc8e;
    --accent-2: #c8a86c;
    --accent-ink: #172012;
    --accent-soft: #283020;
    --danger: #e6927e;
    --danger-soft: #3a231d;
    --warn: #ddb262;
    --warn-soft: #352c17;
    --ok: #92c27c;
    --ok-soft: #1f2e1a;
    --violet-soft: #302a1b;
    --violet: #d3b77e;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow-hover: 0 8px 28px rgba(0, 0, 0, .45);
    --shadow-pop: 0 24px 60px rgba(0, 0, 0, .6);
    --topbar: rgba(21, 23, 18, .82);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 80px; }
body {
  margin: 0; min-height: 100dvh; color: var(--text);
  background: var(--bg) radial-gradient(1200px 400px at 50% -200px, var(--accent-soft), transparent) no-repeat;
  font: 15px/1.55 "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased; font-feature-settings: "cv11", "ss01";
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5rem; letter-spacing: -.015em; }
h1 { font-size: 1.65rem; font-weight: 750; letter-spacing: -.025em; }
h2 { font-size: 1.1rem; font-weight: 700; }
h3 { font-size: 1rem; font-weight: 650; }
mark { background: var(--warn-soft); color: inherit; border-radius: 3px; padding: 0 2px; }
.muted { color: var(--muted); }
.center { text-align: center; }
.small { font-size: .85rem; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* Kopfzeile */
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: var(--topbar); border-bottom: 1px solid var(--line);
  -webkit-backdrop-filter: saturate(1.6) blur(14px); backdrop-filter: saturate(1.6) blur(14px);
  padding-top: env(safe-area-inset-top);
}
.topbar-inner {
  max-width: 1140px; margin: 0 auto; padding: 10px 20px;
  display: flex; align-items: center; gap: 16px;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 750; font-size: 1.08rem; white-space: nowrap; letter-spacing: -.02em; }
.brand:hover { text-decoration: none; }
.logo {
  width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 4px 12px color-mix(in srgb, var(--accent) 35%, transparent);
}
@media (prefers-color-scheme: dark) { .logo { background: linear-gradient(135deg, #6f8660, #b0955c); } }
.logo svg { width: 20px; height: 20px; }
.search { flex: 1; max-width: 520px; margin-left: auto; position: relative; }
.search-ico { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--muted); pointer-events: none; }
.search input {
  width: 100%; padding: 9px 14px 9px 38px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--card); color: var(--text); font: inherit; transition: border-color .15s, box-shadow .15s;
}
.search input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.usernav { display: flex; align-items: center; gap: 4px; white-space: nowrap; }
.navlink {
  display: inline-flex; align-items: center; gap: 7px; padding: 7px 11px; border-radius: 999px;
  color: var(--muted); font: inherit; font-size: .9rem; font-weight: 600; border: 0; background: transparent; cursor: pointer;
  transition: background .15s, color .15s;
}
.navlink:hover { background: var(--bg-2); color: var(--text); text-decoration: none; }
.navlink.active { background: var(--accent-soft); color: var(--accent); }
.navlink svg { width: 18px; height: 18px; }
.navlink.account { padding: 4px 12px 4px 4px; }
.avatar {
  width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-size: .75rem; font-weight: 700;
  color: #fff; background: linear-gradient(135deg, var(--accent), var(--accent-2)); letter-spacing: 0;
}
@media (max-width: 960px) { .usernav .lbl:not(#userName) { display: none; } .navlink { padding: 8px; } }
@media (max-width: 640px) {
  .topbar-inner { flex-wrap: wrap; padding: 8px 14px 10px; gap: 8px 10px; }
  .search { order: 3; flex-basis: 100%; max-width: none; }
  .usernav { margin-left: auto; gap: 2px; }
  .usernav .lbl { display: none; }
  .navlink.account { padding: 4px; }
}

/* Leser: Bearbeiten-Elemente ausblenden (der Server lehnt Änderungen ohnehin ab) */
body.readonly #addVehicle, body.readonly #editVehicle, body.readonly [data-quick], body.readonly #addEntry,
body.readonly [data-edit], body.readonly #drop, body.readonly #addAccessory, body.readonly #addContract, body.readonly [data-upload] { display: none !important; }
body.readonly .vhead .photo { pointer-events: none; }
body.readonly .vhead .photo::after { display: none; }

main { max-width: 1140px; margin: 0 auto; padding: 24px 20px 72px; }
@media (max-width: 640px) { main { padding: 16px 14px 64px; } }
main > * { animation: fadein .25s ease-out; }
@keyframes fadein { from { opacity: 0; transform: translateY(4px); } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* Seitenkopf */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.page-head h1 { margin: 0; }
.eyebrow { margin: 0 0 2px; color: var(--muted); font-size: .85rem; font-weight: 600; }
.section-title { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.section-title h2 { margin: 0; }
.back { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-weight: 600; font-size: .9rem; }
.back:hover { color: var(--accent); text-decoration: none; }

/* Bausteine */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px;
}
.card > h2:first-child { margin-bottom: 12px; }
.stack > * + * { margin-top: 18px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grid { display: grid; gap: 18px; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px; border-radius: var(--radius-sm); border: 1px solid transparent;
  background: var(--accent); color: var(--accent-ink); font: inherit; font-weight: 650; cursor: pointer;
  text-decoration: none; white-space: nowrap; line-height: 1.3;
  box-shadow: 0 1px 2px rgba(45, 45, 25, .12), inset 0 1px 0 rgba(255, 255, 255, .12);
  transition: filter .15s, background .15s, border-color .15s, transform .05s;
}
.btn:hover { filter: brightness(1.07); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn.ghost { background: var(--card); color: var(--text); border-color: var(--line-strong); box-shadow: 0 1px 2px rgba(45, 45, 25, .05); }
.btn.ghost:hover { background: var(--bg-2); filter: none; }
.btn.danger { background: var(--card); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent); box-shadow: none; }
.btn.danger:hover { background: var(--danger-soft); filter: none; }
.btn.small { padding: 6px 12px; font-size: .85rem; border-radius: 9px; }
.btn:disabled { opacity: .5; cursor: default; }
.icon-btn {
  border: 0; background: transparent; color: var(--muted); cursor: pointer; display: inline-grid; place-items: center;
  width: 34px; height: 34px; border-radius: 9px; font-size: .95rem; line-height: 1; transition: background .15s;
}
.icon-btn:hover { background: var(--bg-2); color: var(--text); text-decoration: none; }

.chip {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px; font-size: .76rem; font-weight: 650;
  background: var(--accent-soft); color: var(--accent); white-space: nowrap; line-height: 1.5;
}
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.danger { background: var(--danger-soft); color: var(--danger); }
.chip.ok { background: var(--ok-soft); color: var(--ok); }
.chip.grey { background: var(--bg-2); color: var(--muted); }

.plate {
  display: inline-block; padding: 1px 9px 1px 16px; border: 2px solid #1b1b1b; border-radius: 5px;
  background: #fff linear-gradient(90deg, #003399 0 9px, #fff 9px); color: #111;
  font: 700 .9rem/1.35 "DIN Alternate", "Arial Narrow", sans-serif; letter-spacing: .6px; white-space: nowrap;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .18);
}

/* Kennzahlen */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.kpi { display: flex; align-items: center; gap: 14px; padding: 16px 18px; }
.kpi .v { font-size: 1.45rem; font-weight: 750; letter-spacing: -.02em; line-height: 1.2; font-variant-numeric: tabular-nums; }
.kpi .l { color: var(--muted); font-size: .84rem; }
.kpi-ico {
  width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; font-size: 1.3rem; flex: none;
  background: var(--accent-soft);
}
.kpi-ico.ok { background: var(--ok-soft); }
.kpi-ico.violet { background: var(--violet-soft); }
.kpi-ico.warn { background: var(--warn-soft); }
.kpi.alert { border-color: color-mix(in srgb, var(--warn) 45%, var(--line)); }
@media (max-width: 640px) {
  .kpis { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi { flex-direction: column; align-items: flex-start; gap: 8px; padding: 14px; }
  .kpi-ico { width: 36px; height: 36px; font-size: 1.05rem; border-radius: 10px; }
  .kpi .v { font-size: 1.2rem; }
}

/* Fahrzeugkarten */
.vcard { display: flex; flex-direction: column; padding: 0; overflow: hidden; color: inherit; transition: transform .2s, box-shadow .2s, border-color .2s; }
.vcard:hover { text-decoration: none; transform: translateY(-3px); box-shadow: var(--shadow-hover); border-color: var(--line-strong); }
.vcard .photo { height: 168px; }
.vcard .photo.has-img::before {
  content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, transparent 55%, rgba(0, 0, 0, .35));
}
.vcard .photo .plate { position: absolute; left: 14px; bottom: 12px; }
.vcard .photo .chip { position: absolute; right: 12px; top: 12px; background: rgba(255, 255, 255, .92); color: #3b4352; }
.vcard .body { padding: 14px 18px 18px; }
.vcard h3 { margin: 0; font-size: 1.05rem; }
.vcard.inactive .photo { filter: grayscale(.7); opacity: .75; }
.photo {
  position: relative; background: linear-gradient(135deg, var(--accent-soft), var(--violet-soft)) center/cover no-repeat;
  display: flex; align-items: center; justify-content: center; font-size: 3.2rem;
}
.photo.has-img { background-size: cover; background-position: center; }
.stats { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 12px; font-size: .8rem; color: var(--muted); }
.stats span { background: var(--bg-2); padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
.add-card {
  display: flex; flex-direction: column; gap: 8px; align-items: center; justify-content: center; min-height: 250px;
  border: 2px dashed var(--line-strong); border-radius: var(--radius); color: var(--muted);
  font: inherit; font-weight: 650; cursor: pointer; background: transparent; transition: border-color .15s, color .15s, background .15s;
}
.add-card .plus {
  width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; font-size: 1.5rem; font-weight: 500;
  background: var(--bg-2); transition: background .15s, color .15s;
}
.add-card:hover { border-color: var(--accent); color: var(--accent); background: color-mix(in srgb, var(--accent-soft) 45%, transparent); }
.add-card:hover .plus { background: var(--accent); color: var(--accent-ink); }

/* Listen */
.list { list-style: none; margin: 0; padding: 0; }
.list > li { padding: 12px 0; border-top: 1px solid var(--line); }
.list > li:first-child { border-top: 0; padding-top: 4px; }
.list > li:last-child { padding-bottom: 0; }
.deadline { display: flex; gap: 12px; align-items: center; }
.deadline .when { min-width: 92px; text-align: right; }
.deadline .dot {
  width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; flex: none; background: var(--bg-2); font-size: 1rem;
}
.deadline .dot.warn { background: var(--warn-soft); }
.deadline .dot.danger { background: var(--danger-soft); }
.deadline .dot.ok { background: var(--ok-soft); }
.recent > li { display: flex; align-items: center; gap: 12px; }
.recent .ico { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; flex: none; background: var(--bg-2); }
.recent .txt { flex: 1; min-width: 0; }
@media (max-width: 560px) {
  .deadline, .recent > li { display: grid; grid-template-columns: 36px 1fr; gap: 4px 12px; align-items: start; }
  .deadline .dot, .recent .ico { grid-row: span 2; }
  .deadline .when { min-width: 0; text-align: left; grid-column: 2; }
  .recent > li > .small { grid-column: 2; }
  .add-card { min-height: 120px; }
}

/* Fahrzeugkopf */
.vhead { display: grid; grid-template-columns: 300px 1fr; gap: 0; padding: 0; overflow: hidden; }
.vhead .photo { min-height: 200px; cursor: pointer; }
.vhead .photo::after {
  content: "📷 Foto ändern"; position: absolute; bottom: 10px; right: 10px; font-size: .75rem;
  background: rgba(0, 0, 0, .6); color: #fff; padding: 3px 10px; border-radius: 999px; opacity: 0; transition: opacity .2s;
}
.vhead .photo:hover::after { opacity: 1; }
.vhead .info { padding: 22px 24px; }
.vhead h1 { font-size: 1.75rem; }
@media (max-width: 700px) {
  .vhead { grid-template-columns: 1fr; }
  .vhead .photo { min-height: 190px; }
  .vhead .photo::after { opacity: 1; }
  .vhead .info { padding: 16px 18px 18px; }
  .vhead h1 { font-size: 1.45rem; }
}

.tabs {
  display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; padding: 4px;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 13px; width: fit-content; max-width: 100%;
}
.tabs::-webkit-scrollbar { display: none; }
.tabs a {
  padding: 7px 14px; color: var(--muted); font-weight: 650; font-size: .92rem; white-space: nowrap; border-radius: 9px;
  transition: background .15s, color .15s;
}
.tabs a:hover { text-decoration: none; color: var(--text); }
.tabs a.active { color: var(--text); background: var(--card); box-shadow: 0 1px 3px rgba(45, 45, 25, .12); }
.tabs .count {
  font-weight: 650; font-size: .72rem; margin-left: 6px; padding: 0 6px; border-radius: 999px;
  background: var(--line); color: var(--muted);
}
.main-switch { gap: 10px; flex-wrap: wrap; }
.main-switch .tabs { flex-wrap: wrap; }
.doc-files { margin-top: 10px; display: grid; gap: 4px; }
.doc-files .list li { padding: 6px 0; gap: 10px; }
.main-switch .tabs { width: auto; }
.mail-text { display: grid; gap: 8px; }
.mail-text > summary { margin-bottom: 2px; }
.mail-tabs { margin-top: 6px; }
.mailbody { white-space: pre-wrap; overflow-wrap: anywhere; font-size: .95rem; line-height: 1.5; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 10px 12px; max-height: 60vh; overflow: auto; }
.mailbody { white-space: normal; }
.mailbody > div { white-space: pre-wrap; min-height: 1.5em; }
.mailtable { overflow-x: auto; margin: 6px 0; }
.mailtable table { border-collapse: collapse; font-size: .88rem; min-width: 100%; }
.mailtable th, .mailtable td { border: 1px solid var(--line); padding: 4px 8px; text-align: left; vertical-align: top;
  overflow-wrap: normal; word-break: normal; hyphens: manual; }
.mailtable th { background: var(--bg-2); font-weight: 650; min-width: 5.5em; }
.mailtable td.num { text-align: right; white-space: nowrap; }
.mailframe { width: 100%; height: 70vh; border: 1px solid var(--line); border-radius: var(--radius-sm); background: #fff; }
.main-switch-box { display: grid; gap: 6px; padding: 8px 12px; background: var(--accent-soft); border-radius: var(--radius-sm); }
.tabs a.active .count { background: var(--accent-soft); color: var(--accent); }
@media (max-width: 640px) { .tabs { width: 100%; } }

dl.facts { display: grid; grid-template-columns: minmax(130px, max-content) 1fr; gap: 8px 18px; margin: 0; }
dl.facts dt { color: var(--muted); }
dl.facts dd { margin: 0; word-break: break-word; font-weight: 500; }
@media (max-width: 420px) { dl.facts { grid-template-columns: 1fr; gap: 0; } dl.facts dd { margin-bottom: 8px; } }

/* Chronik */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline > li { display: grid; grid-template-columns: 96px 1fr auto; gap: 14px; padding: 14px 0; border-top: 1px solid var(--line); }
.timeline > li:first-child { border-top: 0; }
.timeline .date { color: var(--muted); font-size: .85rem; padding-top: 2px; font-variant-numeric: tabular-nums; font-weight: 600; }
.timeline .meta { display: flex; gap: 6px 14px; flex-wrap: wrap; font-size: .84rem; color: var(--muted); margin-top: 4px; }
.timeline .notes { white-space: pre-wrap; margin-top: 6px; font-size: .9rem; color: var(--muted); }
.attachments { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.attachments a {
  font-size: .82rem; background: var(--bg-2); border: 1px solid var(--line); color: var(--text);
  padding: 3px 10px; border-radius: 999px; transition: border-color .15s, color .15s;
}
.attachments a:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
@media (max-width: 560px) {
  .timeline > li { grid-template-columns: 1fr auto; gap: 4px 12px; }
  .timeline .date { grid-column: 1 / -1; padding: 0; }
}

/* Dokumente */
.folder { padding: 0; overflow: hidden; }
.folder > summary {
  display: flex; align-items: center; gap: 10px; padding: 14px 18px; cursor: pointer; font-weight: 650; list-style: none;
}
.folder > summary::-webkit-details-marker { display: none; }
.folder > summary::before { content: "📁"; }
.folder[open] > summary::before { content: "📂"; }
.folder > summary::after { content: "›"; font-size: 1.3rem; line-height: 1; color: var(--muted); transition: transform .2s; }
.folder[open] > summary::after { transform: rotate(90deg); }
.folder > summary:hover { background: var(--bg-2); }
.folder > summary .count { margin-left: auto; }
.docs { list-style: none; margin: 0; padding: 0 18px 8px; }
.doc { display: grid; grid-template-columns: 52px 1fr auto; gap: 14px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); }
.doc .thumb {
  width: 52px; height: 52px; border-radius: 11px; background: var(--bg-2) center/cover no-repeat; border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center; font-size: 1.4rem; overflow: hidden;
}
.doc .thumb:hover { text-decoration: none; border-color: var(--accent); }
.doc .title { font-weight: 650; word-break: break-word; color: var(--text); }
.doc .title:hover { color: var(--accent); }
.doc .actions { display: flex; gap: 2px; }
.dropzone {
  border: 2px dashed var(--line-strong); border-radius: var(--radius); padding: 26px 20px; text-align: center; color: var(--muted);
  cursor: pointer; transition: border-color .2s, background .2s, color .2s; background: color-mix(in srgb, var(--card) 60%, transparent);
}
.dropzone:hover { border-color: var(--accent); color: var(--text); }
.dropzone.over { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.dropzone progress { margin-top: 10px; }

/* Tabellen */
table.data { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.data th {
  text-align: left; padding: 8px 10px; font-size: .76rem; text-transform: uppercase; letter-spacing: .05em;
  color: var(--muted); font-weight: 650; border-bottom: 1px solid var(--line);
}
table.data td { text-align: left; padding: 10px; border-bottom: 1px solid var(--line); }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover td { background: color-mix(in srgb, var(--bg-2) 60%, transparent); }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data tfoot td { font-weight: 750; border-top: 1px solid var(--line-strong); border-bottom: 0; }
.bar { height: 8px; border-radius: 999px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); min-width: 3px; }
.table-wrap { overflow-x: auto; }
.card.table-wrap { padding: 8px 10px; }
table.data select { width: auto; padding: 5px 8px; }
tr.me td { background: color-mix(in srgb, var(--accent-soft) 60%, transparent); }

/* Dialog & Formulare */
dialog {
  border: 1px solid var(--line); border-radius: 20px; padding: 0; width: min(660px, calc(100vw - 24px));
  max-height: calc(100dvh - 32px); background: var(--card); color: var(--text); box-shadow: var(--shadow-pop);
}
dialog[open] { animation: pop .2s cubic-bezier(.2, .9, .3, 1.2); }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.98); } }
dialog::backdrop { background: rgba(25, 28, 15, .45); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
dialog form { display: flex; flex-direction: column; max-height: calc(100dvh - 32px); }
dialog header, dialog footer { padding: 16px 22px; display: flex; align-items: center; gap: 8px; }
dialog header { border-bottom: 1px solid var(--line); }
dialog header h2 { margin: 0; flex: 1; font-size: 1.15rem; }
dialog footer { border-top: 1px solid var(--line); justify-content: flex-end; background: color-mix(in srgb, var(--bg-2) 50%, var(--card)); }
dialog .content { padding: 20px 22px; overflow-y: auto; }
@media (max-width: 560px) {
  dialog { width: 100%; max-width: 100%; margin: auto 0 0; border-radius: 22px 22px 0 0; max-height: 94dvh; border-bottom: 0; }
  dialog form { max-height: 94dvh; }
  dialog[open] { animation: sheet .25s cubic-bezier(.2, .9, .3, 1); }
  dialog footer { padding-bottom: max(16px, env(safe-area-inset-bottom)); }
  @keyframes sheet { from { transform: translateY(40px); opacity: .4; } }
}
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.fields .full, .fields h3 { grid-column: 1 / -1; }
.fields h3 {
  margin: 10px 0 -2px; font-size: .74rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted);
  display: flex; align-items: center; gap: 10px;
}
.fields h3::after { content: ""; flex: 1; height: 1px; background: var(--line); }
@media (max-width: 520px) { .fields { grid-template-columns: 1fr; } }
label.field { display: flex; flex-direction: column; gap: 6px; font-size: .84rem; font-weight: 600; color: var(--muted); }
label.field.check { flex-direction: row; align-items: center; gap: 10px; color: var(--text); font-size: .95rem; font-weight: 500; }
input, select, textarea {
  font: inherit; font-weight: 400; color: var(--text); background: var(--card); border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm); padding: 9px 12px; width: 100%; transition: border-color .15s, box-shadow .15s;
}
select {
  appearance: none; -webkit-appearance: none; padding-right: 34px; cursor: pointer;
  background: var(--card) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236d7062' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 10px center / 16px;
}
input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--accent); flex: none; padding: 0; }
input[type=file] { padding: 8px; background: var(--bg-2); border-style: dashed; cursor: pointer; }
input[type=file]::file-selector-button {
  font: inherit; font-weight: 600; font-size: .85rem; border: 1px solid var(--line-strong); background: var(--card); color: var(--text);
  border-radius: 8px; padding: 5px 12px; margin-right: 10px; cursor: pointer;
}
textarea { min-height: 90px; resize: vertical; }
input:hover, select:hover, textarea:hover { border-color: color-mix(in srgb, var(--accent) 35%, var(--line-strong)); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.error { color: var(--danger); font-size: .9rem; }
progress { width: 100%; height: 6px; appearance: none; border: 0; border-radius: 999px; background: var(--bg-2); overflow: hidden; accent-color: var(--accent); }
progress::-webkit-progress-bar { background: var(--bg-2); }
progress::-webkit-progress-value { background: var(--accent); border-radius: 999px; }
progress::-moz-progress-bar { background: var(--accent); }

#toast {
  position: fixed; left: 50%; bottom: max(24px, env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(120px);
  background: #262a21; color: #fff; padding: 11px 20px; border-radius: 999px; transition: transform .3s cubic-bezier(.2, .9, .3, 1.2);
  z-index: 100; max-width: calc(100vw - 32px); box-shadow: 0 10px 30px rgba(0, 0, 0, .25); font-weight: 550; font-size: .92rem;
}
@media (prefers-color-scheme: dark) { #toast { background: #e8e8de; color: #262a21; } }
#toast.show { transform: translateX(-50%) translateY(0); }
#toast:not(.show) { visibility: hidden; }
#toast.err { background: var(--danger); color: #fff; }

/* Anmeldung & öffentliche Seiten */
body.guest .topbar { display: none; }
body.guest {
  background:
    radial-gradient(900px 500px at 10% -10%, color-mix(in srgb, var(--accent) 22%, transparent), transparent 70%),
    radial-gradient(800px 500px at 100% 110%, color-mix(in srgb, var(--accent-2) 20%, transparent), transparent 70%),
    var(--bg);
}
body.guest main { min-height: 100dvh; display: flex; flex-direction: column; justify-content: center; padding-top: 32px; }
.login { width: 100%; max-width: 420px; margin: 0 auto; padding: 32px 30px; border-radius: 22px; box-shadow: var(--shadow-pop); }
.login h1 { margin: 0; text-align: center; }
.login > .muted { text-align: center; }
.login .auth-logo { width: 56px; height: 56px; border-radius: 16px; margin: 0 auto 6px; }
.login .auth-logo svg { width: 30px; height: 30px; }
.login .links { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; font-size: .9rem; padding-top: 16px; border-top: 1px solid var(--line); }
.login .btn { padding: 11px 16px; }
@media (max-width: 480px) { .login { padding: 26px 20px; } }

.notice { background: var(--accent-soft); color: var(--text); border-radius: var(--radius-sm); padding: 12px 14px; border: 1px solid color-mix(in srgb, var(--accent) 18%, transparent); }
.notice.ok { background: var(--ok-soft); border-color: color-mix(in srgb, var(--ok) 20%, transparent); }
.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty .big {
  font-size: 2rem; width: 72px; height: 72px; margin: 0 auto 12px; border-radius: 50%;
  display: grid; place-items: center; background: var(--bg-2);
}

/* Import */
.textpreview { white-space: pre-wrap; font-size: .8rem; background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 10px 12px; max-height: 240px; overflow: auto; margin: 8px 0 0; }
.import-item .field .small { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; color: var(--muted); font-weight: 400; }
.file-ico { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: var(--bg-2); font-size: 1.35rem; flex: none; }

/* Fahrzeugfoto (Aktendeckel) */
.photo-field { display: flex; flex-direction: column; gap: 6px; font-size: .84rem; font-weight: 600; color: var(--muted); }
.photo-pick { display: flex; gap: 14px; align-items: center; }
.photo-prev {
  width: 132px; height: 88px; border-radius: 12px; flex: none; display: grid; place-items: center; font-size: 1.8rem;
  background: linear-gradient(135deg, var(--accent-soft), var(--violet-soft)) center/cover no-repeat; border: 1px solid var(--line);
}
.photo-prev.has-img { background-size: cover; background-position: center; }
.photo-ctl { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.photo-ctl .muted { font-weight: 400; }
@media (max-width: 420px) { .photo-pick { flex-direction: column; align-items: stretch; } .photo-prev { width: 100%; height: 140px; } }
.photo-empty { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.photo-empty > span { font-size: .8rem; font-weight: 650; color: var(--accent); background: var(--card); padding: 3px 12px; border-radius: 999px; box-shadow: var(--shadow); }
.vhead .photo:not(.has-img)::after { display: none; }

/* Import: neue Akte */
.newv {
  border: 1px solid color-mix(in srgb, var(--ok) 35%, var(--line)); background: color-mix(in srgb, var(--ok-soft) 55%, var(--card));
  border-radius: 14px; padding: 14px 16px; display: flex; flex-direction: column; gap: 12px;
}
.newv-head { display: flex; gap: 12px; align-items: center; color: var(--text); font-weight: 400; }
.newv-ico { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; background: var(--card); font-size: 1.3rem; flex: none; box-shadow: var(--shadow); }
.vhead .info > .row:not(:has(*)) { display: none; }

/* Vorschläge aus Dokumenten */
.suggest { border-color: color-mix(in srgb, var(--violet) 35%, var(--line)); background: linear-gradient(135deg, color-mix(in srgb, var(--violet-soft) 70%, var(--card)), var(--card) 60%); }
.sug-row { display: flex; align-items: center; gap: 12px; cursor: pointer; }
.sug-row input { width: 18px; height: 18px; accent-color: var(--accent); flex: none; }
.sug-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.sug-src { max-width: 45%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
@media (max-width: 560px) { .sug-row { flex-wrap: wrap; } .sug-src { max-width: 100%; margin-left: 30px; } }
.facts-box { border: 1px solid color-mix(in srgb, var(--violet) 35%, var(--line)); background: color-mix(in srgb, var(--violet-soft) 55%, var(--card));
  border-radius: 14px; padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
body.readonly #factSuggest { display: none !important; }

.suggest .list { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); column-gap: 28px; }
.suggest .list > li, .suggest .list > li:first-child { border-top: 1px solid var(--line); padding: 10px 0; }

/* Import: Dokumentvorschau neben den Vorschlägen */
.imp-body { display: grid; grid-template-columns: minmax(260px, 40%) 1fr; gap: 22px; align-items: start; }
.imp-main { min-width: 0; }
.imp-preview { position: sticky; top: 84px; min-width: 0; }
.imp-pages {
  display: flex; flex-direction: column; gap: 10px; max-height: 74vh; overflow: auto; padding: 10px;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 14px; cursor: zoom-in;
}
.imp-pages img { width: 100%; height: auto; display: block; border-radius: 6px; background: #fff; box-shadow: var(--shadow); }
.imp-pages .muted { padding: 30px 10px; }
.imp-preview-bar { display: flex; justify-content: space-between; gap: 8px; margin-top: 6px; }
.swipe-hint { display: none; }
@media (max-width: 760px) {
  .imp-body { grid-template-columns: 1fr; gap: 16px; }
  .imp-preview { position: static; }
  /* Handy: Seiten nebeneinander zum Wischen */
  .imp-pages { flex-direction: row; max-height: none; overflow-x: auto; scroll-snap-type: x mandatory; }
  .imp-pages img { flex: 0 0 100%; scroll-snap-align: center; }
  .swipe-hint { display: inline; }
}
.import-item.flash { animation: flash 1.6s ease-out; }
@keyframes flash { 0%, 30% { box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 55%, transparent); } }
.more-imports { width: 100%; }

/* Hilfe */
.help-search { margin: 0; max-width: 560px; }
.help-layout { display: grid; grid-template-columns: 240px 1fr; gap: 22px; align-items: start; }
.help-toc { position: sticky; top: 84px; display: flex; flex-direction: column; gap: 2px; max-height: calc(100dvh - 110px); overflow: auto; }
.help-toc a { padding: 6px 10px; border-radius: 9px; color: var(--muted); font-size: .9rem; font-weight: 550; }
.help-toc a:hover { background: var(--bg-2); color: var(--text); text-decoration: none; }
.help-toc a.active { background: var(--accent-soft); color: var(--accent); }
.help-toc a.dim { opacity: .35; }
.help-sections > * + * { margin-top: 18px; }
.help-sec { scroll-margin-top: 84px; }
.help-sec.flash { animation: flash 1.6s ease-out; }
.help-sec p, .help-sec ul, .help-sec ol { margin: 0 0 10px; }
.help-sec ul { padding-left: 20px; }
.help-sec li + li { margin-top: 4px; }
.help-sec h3 { margin: 16px 0 6px; }
.help-sec table.data { margin: 4px 0 10px; }
.help-tip, .help-note { border-radius: var(--radius-sm); padding: 10px 14px; margin-top: 12px; font-size: .92rem; }
.help-tip { background: var(--ok-soft); border: 1px solid color-mix(in srgb, var(--ok) 22%, transparent); }
.help-note { background: var(--warn-soft); border: 1px solid color-mix(in srgb, var(--warn) 22%, transparent); }
.help-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; font-size: .88rem; color: var(--muted); margin: 6px 0 12px; }
.help-legend .chip { margin-left: 6px; }
.help-legend .chip:first-child { margin-left: 0; }
ol.steps { list-style: none; padding: 0; counter-reset: st; }
ol.steps li { counter-increment: st; position: relative; padding: 2px 0 2px 38px; min-height: 28px; }
ol.steps li + li { margin-top: 10px; }
ol.steps li::before {
  content: counter(st); position: absolute; left: 0; top: 0; width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center; font-size: .8rem; font-weight: 700; background: var(--accent); color: var(--accent-ink);
}
.help-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin: 12px 0; }
.help-card { background: var(--bg-2); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; }
.help-card p { color: var(--muted); font-size: .9rem; flex: 1; }
.help-card .n {
  width: 28px; height: 28px; border-radius: 9px; display: grid; place-items: center; font-weight: 750; margin-bottom: 4px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff;
}
details.faq { border-top: 1px solid var(--line); padding: 10px 0; }
details.faq:first-of-type { border-top: 0; padding-top: 0; }
details.faq summary { cursor: pointer; font-weight: 650; list-style: none; display: flex; gap: 8px; }
details.faq summary::before { content: "›"; color: var(--muted); transition: transform .2s; display: inline-block; width: 10px; }
details.faq[open] summary::before { transform: rotate(90deg); }
details.faq summary::-webkit-details-marker { display: none; }
details.faq p { margin: 6px 0 0 18px; color: var(--muted); }
.help-link {
  display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; font-size: .78rem; font-weight: 700;
  background: var(--bg-2); color: var(--muted); vertical-align: middle; margin-left: 4px; border: 1px solid var(--line);
}
.help-link:hover { background: var(--accent-soft); color: var(--accent); text-decoration: none; }
@media (max-width: 820px) {
  .help-layout { grid-template-columns: 1fr; }
  /* Handy: Inhaltsverzeichnis als wischbare Leiste */
  .help-toc { position: static; flex-direction: row; overflow-x: auto; max-height: none; scrollbar-width: none;
    background: var(--bg); padding: 6px 0; margin: 0 -14px; padding-inline: 14px; }
  .help-toc::-webkit-scrollbar { display: none; }
  .help-toc a { white-space: nowrap; background: var(--card); border: 1px solid var(--line); border-radius: 999px; font-size: .84rem; }
}

/* Import: Dubletten */
.dup-box { border: 1px solid color-mix(in srgb, var(--danger) 35%, var(--line)); background: color-mix(in srgb, var(--danger-soft) 60%, var(--card));
  border-radius: 14px; padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.dup-box.soft { border-color: color-mix(in srgb, var(--warn) 35%, var(--line)); background: color-mix(in srgb, var(--warn-soft) 60%, var(--card)); }
.dup-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; font-size: .9rem; }
.dup-list .chip { margin-right: 6px; }

/* Fahrzeugformular: Bezeichnungen für Fahrrad/E-Bike */
.l-bike { display: none; }
form.is-bike .l-bike { display: inline; }
form.is-bike .l-std { display: none; }

/* Zubehör */
table.acc td.ean { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: .84rem; letter-spacing: .03em; white-space: nowrap; }
table.acc tfoot td { font-size: 1rem; }
.ean-info { border-radius: var(--radius-sm); padding: 10px 12px; font-size: .9rem; background: var(--bg-2); border: 1px solid var(--line); margin-top: -4px; }
.ean-info.ok { background: var(--ok-soft); border-color: color-mix(in srgb, var(--ok) 25%, transparent); }
.ean-info.err { background: var(--danger-soft); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 25%, transparent); }
.ean-info.muted { color: var(--muted); }
table.acc tfoot tr.saved td { font-size: .9rem; font-weight: 600; color: var(--ok); border-top: 0; }
/* Handy: Zubehör als Karten statt breiter Tabelle */
@media (max-width: 600px) {
  table.acc thead { display: none; }
  table.acc, table.acc tbody, table.acc tfoot { display: block; }
  table.acc tr { display: grid; grid-template-columns: 1fr auto 34px; gap: 2px 10px; padding: 10px 0; border-bottom: 1px solid var(--line); align-items: start; }
  table.acc td { border: 0 !important; padding: 0 !important; background: none !important; }
  table.acc td:empty { display: none; }
  table.acc td.name { grid-column: 1; grid-row: 1; }
  table.acc td.cost { grid-column: 2; grid-row: 1; font-weight: 650; }
  table.acc td.act { grid-column: 3; grid-row: 1 / span 2; }
  table.acc td.ean { grid-column: 1; grid-row: 2; }
  table.acc td.uvp { grid-column: 2; grid-row: 2; font-size: .8rem; }
  table.acc td.uvp::before { content: "UVP "; }
  table.acc td.notes { grid-column: 1 / 3; grid-row: 3; }
  table.acc tfoot tr { grid-template-columns: 1fr auto; border-bottom: 0; }
  table.acc tfoot td[colspan] { grid-column: 1; grid-row: 1 / span 2; }
  table.acc tfoot td.cost { grid-column: 2; grid-row: 1; }
  table.acc tfoot td.uvp { grid-column: 2; grid-row: 2; }
  table.acc tfoot tr.saved td.cost { grid-row: 1; }
}

/* iPhone/iPad: Safari zoomt beim Antippen von Feldern unter 16 px hinein und bleibt vergrößert → auf Touch-Geräten 16 px */
input, select, textarea { font-size: .95rem; }
@media (pointer: coarse), (max-width: 760px) {
  input, select, textarea, .search input { font-size: 16px; }
}
/* iOS-Eigenheiten: Datumsfelder sprengen sonst die Spalte, Suchfelder bekommen sonst den Safari-Stil */
input[type=date], input[type=month] {
  -webkit-appearance: none; appearance: none; display: block; min-height: 2.75em; min-width: 0; max-width: 100%; text-align: left;
}
input[type=date]::-webkit-date-and-time-value, input[type=month]::-webkit-date-and-time-value { text-align: left; }
input[type=search] { -webkit-appearance: none; appearance: none; }
.fields > *, .imp-main, .help-sections { min-width: 0; }
/* Querformat mit Notch/Dynamic Island: Inhalt nicht unter die Aussparung */
.topbar-inner, main { padding-left: max(14px, env(safe-area-inset-left)); padding-right: max(14px, env(safe-area-inset-right)); }
@media (min-width: 641px) { .topbar-inner, main { padding-left: max(20px, env(safe-area-inset-left)); padding-right: max(20px, env(safe-area-inset-right)); } }
dialog .content, dialog header, dialog footer { padding-left: max(18px, env(safe-area-inset-left)); padding-right: max(18px, env(safe-area-inset-right)); }
/* Handy: Logo, Name und alle Symbole in einer Zeile */
@media (max-width: 640px) {
  .brand { font-size: 1rem; gap: 8px; }
  .logo { width: 32px; height: 32px; }
  .usernav { gap: 0; }
  .navlink { padding: 6px; }
  .navlink.account { padding: 3px; }
}
@media (max-width: 380px) { .brand-name { display: none; } }
/* Handy: alle Reiter sichtbar (Umbruch statt verstecktem Scrollen) */
@media (max-width: 640px) {
  .tabs { flex-wrap: wrap; overflow: visible; gap: 2px; }
  .tabs a { padding: 6px 10px; font-size: .88rem; }
}
.mail-howto summary { cursor: pointer; font-weight: 600; color: var(--accent); }
.mail-howto[open] summary { margin-bottom: 10px; }
code { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: .86em; background: var(--bg-2); padding: 1px 5px; border-radius: 5px; }

/* ===== DMS ===== */
.doc-list { display: flex; flex-direction: column; gap: 10px; }
/* Archiv: Markieren, Summe, Sammeldruck */
.sel-row { display: flex; gap: 8px; align-items: center; }
.sel-row > .doc-item { flex: 1; min-width: 0; }
.sel-check { display: grid; place-items: center; width: 34px; align-self: stretch; cursor: pointer; }
.sel-check input { width: 22px; height: 22px; accent-color: var(--accent); cursor: pointer; }
.sel-bar { display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: center; justify-content: space-between; padding: 8px 12px;
  position: sticky; bottom: max(12px, env(safe-area-inset-bottom)); z-index: 10; box-shadow: var(--shadow-hover); }
.sel-bar.active { border-color: var(--accent); background: color-mix(in srgb, var(--accent-soft) 60%, var(--card)); }
.sel-info { min-width: 0; }
.sel-actions { gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.sel-actions .btn { white-space: nowrap; }
.sel-att { display: inline-flex; gap: 6px; align-items: center; cursor: pointer; }
.sel-att input { width: 18px; height: 18px; accent-color: var(--accent); }
@media (max-width: 640px) {
  .sel-bar { bottom: calc(max(18px, env(safe-area-inset-bottom)) + 68px); }   /* über dem ＋-Knopf */
  .sel-check { width: 28px; }
}
.doc-item { display: flex; gap: 14px; padding: 12px 14px; color: inherit; align-items: flex-start; transition: border-color .15s, box-shadow .15s; }
.doc-item:hover { text-decoration: none; border-color: var(--line-strong); box-shadow: var(--shadow-hover); }
.doc-thumb { width: 54px; height: 72px; flex: none; border-radius: 8px; overflow: hidden; background: var(--bg-2); border: 1px solid var(--line);
  display: grid; place-items: center; font-size: 1.5rem; }
.doc-thumb img { width: 100%; height: 100%; object-fit: cover; object-position: top; background: #fff; }
.doc-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.doc-title { font-weight: 650; word-break: break-word; }
.doc-chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 3px; }
.snippet { color: var(--muted); }
.folders { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.folder-tile { display: flex; flex-direction: column; gap: 2px; padding: 14px; color: inherit; transition: border-color .15s, transform .15s; }
.folder-tile:hover { text-decoration: none; border-color: var(--accent); transform: translateY(-2px); }
.folder-tile.empty-folder { opacity: .55; }
.folder-ico { font-size: 1.5rem; }
.folder-name { font-weight: 650; }
.kpi:hover { text-decoration: none; border-color: var(--line-strong); }
a.kpi { color: inherit; }
.filter-bar { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
.person-pick, .tag-cloud, .vehicle-row { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-check { display: inline-flex; cursor: pointer; }
.chip-check input { position: absolute; opacity: 0; pointer-events: none; }
.chip-check span { padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--card); color: var(--text); font-weight: 550; font-size: .9rem; }
.chip-check input:checked + span { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.chip-check input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.dl-pick { display: flex; flex-direction: column; gap: 6px; }
.dl-row { display: grid; grid-template-columns: auto auto 1fr 150px; gap: 8px; align-items: center; }
.dl-row input[type=checkbox] { width: 18px; height: 18px; }
@media (max-width: 560px) { .dl-row { grid-template-columns: auto auto 1fr; } .dl-row input[type=date] { grid-column: 2 / -1; } }
.corr-new { margin-top: 6px; }
.deadline .dl-done { width: 20px; height: 20px; flex: none; accent-color: var(--accent); }
button.chip { border: 0; cursor: pointer; font: inherit; font-size: .8rem; }
.doc-view .imp-preview { top: 84px; }
.more-docs { width: 100%; }
/* DMS: viele Menüpunkte – Beschriftungen erst ab breiten Bildschirmen, damit das Suchfeld Platz behält */
@media (max-width: 1280px) { .usernav .lbl:not(#userName) { display: none; } .navlink { padding: 8px; } }
@media (max-width: 1100px) { .usernav #userName { display: none; } .navlink.account { padding: 4px; } }
.search { min-width: 180px; }
@media (max-width: 640px) { .search { min-width: 0; } }
@media (max-width: 640px) { #usersLink { display: none !important; } }
/* Handy: Fristen mit Abhak-Kästchen – drei Spalten (Kästchen, Symbol, Text/Fälligkeit) */
@media (max-width: 560px) {
  .deadline:has(.dl-done) { grid-template-columns: auto 36px 1fr; }
  .deadline:has(.dl-done) .dl-done { grid-row: span 2; align-self: center; }
  .deadline:has(.dl-done) > div:not(.when), .deadline:has(.dl-done) .when { grid-column: 3; }
}
.person-tabs { margin-top: -4px; }
.both-parents { background: var(--bg-2); color: var(--text); padding: 6px 12px; font-size: .88rem; }
/* ＋-Knopf zum Importieren – nur auf dem Handy */
.fab { display: none; }
@media (max-width: 640px) {
  .fab:not([hidden]) {
    display: grid; place-items: center; position: fixed; right: 18px; bottom: max(18px, env(safe-area-inset-bottom)); z-index: 20;
    width: 58px; height: 58px; border-radius: 50%; border: 0; font-size: 1.9rem; line-height: 1; cursor: pointer;
    background: var(--accent); color: var(--accent-ink); box-shadow: 0 8px 24px rgba(0, 0, 0, .28);
  }
  .page-head .quick-import { display: none; }
  main { padding-bottom: 96px; }
}
/* Handy: Archiv-Filter zweispaltig, damit die Treffer schneller sichtbar sind */
@media (max-width: 640px) {
  .filter-bar { grid-template-columns: 1fr 1fr !important; gap: 10px; padding: 14px; }
  .filter-bar .full { grid-column: 1 / -1; }
  .filter-bar label.field { font-size: .78rem; }
}

/* Seitenleiste mit Ordnern und Familie (nur auf großen Bildschirmen) */
.sidenav { display: none; }
@media (min-width: 1280px) {
  body.has-sidenav .sidenav {
    display: block; position: fixed; left: 0; top: var(--topbar-h, 64px); bottom: 0; width: 250px; overflow-y: auto; z-index: 5;
    padding: 18px 12px 30px; border-right: 1px solid var(--line); background: var(--bg);
  }
  body.has-sidenav main { margin-left: calc(250px + max(0px, (100vw - 250px - 1140px) / 2)); margin-right: auto; }
  .sidenav h4 { margin: 18px 10px 6px; font-size: .74rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
  .sidenav a { display: flex; align-items: center; gap: 10px; padding: 6px 10px; border-radius: 12px; color: var(--text); text-decoration: none; }
  .sidenav a:hover { background: var(--bg-2); }
  .sidenav a.active { background: var(--accent-soft); color: var(--accent); }
  .sn-home { font-weight: 600; }
  .sn-ico { flex: none; width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; font-size: 1rem; background: var(--bg-2); }
  .sn-txt { flex: 1; min-width: 0; font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .sn-n { color: var(--muted); font-size: .78rem; font-variant-numeric: tabular-nums; }
  .sidenav a.active .sn-n { color: inherit; }
  .sidenav a.sn-sub { padding: 3px 10px 3px 48px; }
  .sidenav a.sn-sub .sn-ico { display: none; }
  .sidenav a.sn-sub .sn-txt { font-size: .84rem; }
  .sn-empty { margin: 4px 10px; }
  .sidenav a.zero:not(.active) { opacity: .45; }
  .sidenav a.sn-reset { padding: 4px 10px 4px 48px; font-size: .84rem; color: var(--muted); }
}

/* Übersicht: Archiv mit Filtern oben, darunter aufklappbare Blöcke (Aufgaben, Fristen, Fuhrpark, zuletzt abgelegt) */
.dash-archive .filter-bar { margin: 0; }
.dash-block > summary { list-style: none; cursor: pointer; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; }
.dash-block > summary::-webkit-details-marker { display: none; }
.dash-block > summary::after { content: "▸"; margin-left: auto; color: var(--muted); transition: transform .15s; }
.dash-block[open] > summary::after { transform: rotate(90deg); }
.dash-block-t { font-weight: 650; font-size: 1.1rem; }
.dash-block-i { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.dash-block-body { margin-top: 12px; }
.agenda-h { margin: 14px 0 4px; font-size: .82rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.agenda-h.danger { color: var(--danger); }
.agenda-h.warn { color: var(--warn); }
.agenda-foot { margin: 12px 0 0; }
.dash-actions { margin-top: 10px; }
.dash-vehicles { margin-top: 12px; }
.dash-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.dash-chips .chip { padding: 6px 12px; font-size: .88rem; text-decoration: none; }
.dash-chips .chip b { font-weight: 600; margin-left: 4px; color: var(--text); }

/* Filter als Combobox: auswählen oder tippen */
.combo { position: relative; }
.combo > label { display: block; }
.combo-box { position: relative; }
.combo-input { width: 100%; padding-right: 36px; }
.combo-btn { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); border: 0; background: none; color: var(--muted);
  font-size: 1rem; padding: 6px 8px; cursor: pointer; }
.combo-list { position: absolute; z-index: 80; left: 0; right: 0; min-width: min(280px, calc(100vw - 32px)); top: 100%; margin: 4px 0 0; padding: 4px; list-style: none;
  max-height: 280px; overflow-y: auto; background: var(--card); border: 1px solid var(--line-strong); border-radius: 12px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, .14); }
.combo-list li { display: flex; justify-content: space-between; gap: 10px; padding: 8px 10px; border-radius: 8px; cursor: pointer; font-size: .95rem; }
.combo-list li:hover, .combo-list li.active { background: var(--accent-soft); color: var(--accent); }
.combo-list li[aria-selected] { font-weight: 600; }
.combo-list .combo-all { color: var(--muted); }
.combo-n { color: var(--muted); font-size: .82rem; font-variant-numeric: tabular-nums; }
.field.combo { display: flex; flex-direction: column; gap: 6px; font-size: .84rem; font-weight: 600; color: var(--muted); }
.field.combo .combo-input, .combo-list li { font-weight: 400; color: var(--text); }
@media (max-width: 640px) { .filter-bar .field.combo { font-size: .78rem; } }
.combo-list.to-left { left: auto; right: 0; }
body.combo-open .sel-bar, body.combo-open .fab { visibility: hidden; }   /* offene Liste nicht von Markierleiste und ＋-Knopf verdecken */
div.field { display: flex; flex-direction: column; gap: 6px; font-size: .84rem; font-weight: 600; color: var(--muted); }
.corr-combo .combo-list li small { font-weight: 400; }
.combo-list .combo-new { color: var(--accent); font-weight: 600; }
.corr-new-hint { font-weight: 400; margin-top: 4px; }

/* Claude: Chat und Briefentwürfe */
.ai-chats { display: flex; flex-wrap: wrap; gap: 6px; }
.ai-chats .chip { text-decoration: none; max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ai-chat { display: flex; flex-direction: column; gap: 12px; }
.ai-log { display: flex; flex-direction: column; gap: 10px; max-height: 62vh; overflow-y: auto; padding: 2px; }
.ai-msg { max-width: 88%; padding: 10px 14px; border-radius: 16px; line-height: 1.5; overflow-wrap: anywhere; }
.ai-msg p { margin: 0 0 6px; } .ai-msg p:last-child { margin: 0; } .ai-msg ul { margin: 4px 0 6px; padding-left: 20px; }
.ai-msg.me { align-self: flex-end; background: var(--accent); color: #fff; border-bottom-right-radius: 4px; }
.ai-msg.bot { align-self: flex-start; background: var(--bg-2); border-bottom-left-radius: 4px; }
.ai-wait { color: var(--muted); font-style: italic; }
.ai-tool { align-self: flex-start; font-size: .8rem; color: var(--muted); padding: 0 6px; }
.ai-empty { padding: 8px 4px; }
.ai-prompts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.ai-prompts .chip { cursor: pointer; border: 0; font: inherit; font-size: .88rem; padding: 7px 12px; }
.ai-form { display: flex; gap: 10px; align-items: flex-end; }
.ai-form textarea { flex: 1; min-height: 52px; resize: vertical; }
.ai-note { margin: 0; }
.ai-letter, .ai-task { align-self: stretch; border: 1px solid var(--line-strong); }
.ai-letter textarea[name=body] { font-family: inherit; line-height: 1.5; }
.ai-letter-actions { flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.ai-task { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
@media (max-width: 640px) { .ai-msg { max-width: 96%; } .ai-form { flex-direction: column; align-items: stretch; } }

/* ---------- Haushaltsbuch ---------- */
:root { --series-out: #eb6834; --series-in: #2a78d6; }
@media (prefers-color-scheme: dark) { :root { --series-out: #d95926; --series-in: #3987e5; } }
.budget-filters { display: flex; flex-wrap: wrap; gap: 10px; }
.budget-filters label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); flex: 1 1 150px; min-width: 0; }
.budget-filters select, .budget .tx-cat, .budget input[type=search] { font-size: 16px; }
.stat-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.stat { display: flex; flex-direction: column; gap: 2px; padding: 14px 16px; }
.stat b { font-size: 22px; font-variant-numeric: tabular-nums; }
.budget .pos { color: var(--ok); } .budget .neg { color: var(--danger); }
.hbars { display: flex; flex-direction: column; gap: 6px; }
.hbar { display: grid; grid-template-columns: minmax(110px, 190px) 1fr auto; gap: 10px; align-items: center; color: var(--text); padding: 4px 0; }
.hbar:hover { text-decoration: none; background: var(--bg-2); border-radius: 6px; }
.hbar-l { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 14px; }
.hbar-track { height: 12px; }
.hbar-fill { display: block; height: 100%; min-width: 2px; background: var(--series-out); border-radius: 0 4px 4px 0; }
.hbar-v { font-variant-numeric: tabular-nums; font-size: 14px; text-align: right; white-space: nowrap; }
.vbars { display: flex; gap: 2px; align-items: stretch; height: 190px; border-bottom: 1px solid var(--line-strong); padding-top: 6px; }
.vbar-col { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; cursor: default; }
.vbar-col:hover .vbar-plot { background: var(--bg-2); }
.vbar-plot { flex: 1; display: flex; align-items: flex-end; justify-content: center; gap: 2px; border-radius: 4px 4px 0 0; }
.vbar { width: 40%; max-width: 18px; border-radius: 4px 4px 0 0; min-height: 0; }
.vbar.out { background: var(--series-out); } .vbar.in { background: var(--series-in); }
.vbar-x { font-size: 11px; color: var(--muted); text-align: center; white-space: nowrap; overflow: hidden; padding-top: 4px; }
.legend { display: flex; gap: 12px; color: var(--muted); }
.legend .sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.sw-out { background: var(--series-out); } .sw-in { background: var(--series-in); }
.chart-tip { position: absolute; z-index: 50; pointer-events: none; background: var(--card); color: var(--text); border: 1px solid var(--line-strong);
  box-shadow: var(--shadow-hover); border-radius: 8px; padding: 6px 10px; font-size: 13px; line-height: 1.4; max-width: 260px; }
.budget .table { width: 100%; border-collapse: collapse; }
.budget .table td, .budget .table th { padding: 6px 4px; border-bottom: 1px solid var(--line); vertical-align: top; text-align: left; }
.budget .table .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.tx { gap: 6px; padding: 12px 14px; }
.tx-head { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.tx-head b { overflow-wrap: anywhere; }
.tx-amt { white-space: nowrap; font-variant-numeric: tabular-nums; }
.tx-purpose { cursor: pointer; overflow-wrap: anywhere; }
.tx-foot { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.tx-foot .chip { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tx-foot button.chip { border: 0; cursor: pointer; font: inherit; }
.pick-list .pick { display: flex; flex-direction: column; align-items: flex-start; text-align: left; width: 100%; }
.row.wrap { flex-wrap: wrap; }
@media (max-width: 640px) {
  .hbar { grid-template-columns: 1fr auto; } .hbar-track { grid-column: 1 / -1; grid-row: 2; }
  .vbars { height: 150px; } .vbar-x { font-size: 10px; }
}

/* Filter im Posteingang */
.import-filter { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.import-filter input[type=search] { flex: 1 1 220px; min-width: 0; font-size: 16px; }
.import-filter select { flex: 0 1 200px; min-width: 0; font-size: 16px; }

/* Import: Umschalter Karten/Liste und kompakte Liste */
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 999px; overflow: hidden; flex: 0 0 auto; }
.seg button { border: 0; background: transparent; color: var(--muted); font: inherit; font-size: 14px; padding: 7px 12px; cursor: pointer; }
.seg button.active { background: var(--accent); color: var(--accent-ink); }
.imp-table { padding: 6px 10px; gap: 0; }
.imp-rows { display: flex; flex-direction: column; }
.imp-row { display: grid; grid-template-columns: auto auto 1fr auto; gap: 10px; align-items: center; padding: 9px 4px; border-bottom: 1px solid var(--line); cursor: pointer; min-width: 0; }
.imp-row:last-child { border-bottom: 0; }
.imp-row:hover { background: var(--bg-2); }
.imp-row input[type=checkbox] { width: 20px; height: 20px; margin: 0; }
.imp-row-main { display: flex; flex-direction: column; min-width: 0; }
.imp-row-main b, .imp-row-main .muted { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.imp-row-q { color: var(--warn); overflow-wrap: anywhere; }
.imp-selbar input[type=checkbox] { width: 20px; height: 20px; }
@media (max-width: 640px) {
  .imp-row { grid-template-columns: auto 1fr auto; gap: 8px; }
  .imp-row input[type=checkbox] { grid-column: 1; grid-row: 1 / span 2; }
  .imp-row .chip { grid-column: 2; grid-row: 2; justify-self: start; }
  .imp-row-main { grid-column: 2; grid-row: 1; }
  .imp-row [data-open] { grid-column: 3; grid-row: 1 / span 2; }
  .imp-row-lbl { display: none; }
  .import-filter .seg { order: -1; }
}
.kred-in { display: flex; gap: 4px; align-items: center; }
.kred-in input { flex: 1; min-width: 0; font-size: 16px; }
.budget #kredSort { font-size: 16px; }
.kred-table td:first-child { overflow-wrap: anywhere; }
@media (max-width: 640px) { .kred-doc { display: none; } }
