/* =========================================================================
   BestBestatter – Design-System
   Ruhig, modern, gut lesbar. Systemschriften (keine externen Fonts → DSGVO).
   ========================================================================= */
:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --surface-3: #eef0f3;
  --ink: #0f172a;
  --ink-2: #334155;
  --muted: #64748b;
  --line: #e4e7ec;
  --line-2: #d0d5dd;
  --primary: #0e5a68;
  --primary-hover: #0b4a56;
  --primary-ink: #ffffff;
  --primary-50: #eaf5f6;
  --primary-100: #cfe8eb;
  --accent: #b7802f;
  --accent-50: #fbf3e6;
  --success: #15803d;
  --success-50: #e9f7ee;
  --danger: #c0262d;
  --danger-50: #fdeceb;
  --warn: #a15c07;
  --warn-50: #fff5e0;
  --info: #2563eb;
  --info-50: #ebf2ff;
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 18px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow: 0 1px 3px rgba(16, 24, 40, .06), 0 1px 2px rgba(16, 24, 40, .04);
  --shadow-lg: 0 12px 32px -8px rgba(16, 24, 40, .18);
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --sidebar-w: 256px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1117; --surface: #151b23; --surface-2: #1a212b; --surface-3: #222b36;
    --ink: #e6edf3; --ink-2: #c9d1d9; --muted: #8b98a8; --line: #2a333e; --line-2: #3a4552;
    --primary: #3aa5b5; --primary-hover: #52b6c5; --primary-ink: #04161a; --primary-50: #12303a; --primary-100: #1b4652;
    --accent: #e0aa5c; --accent-50: #33281a;
    --success: #4ade80; --success-50: #13291b; --danger: #f87171; --danger-50: #3a1717;
    --warn: #fbbf24; --warn-50: #33270f; --info: #60a5fa; --info-50: #172a45;
    --shadow-sm: none; --shadow: 0 0 0 1px rgba(255,255,255,.02); --shadow-lg: 0 12px 32px -8px rgba(0,0,0,.6);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font-family: var(--font); font-size: 15px; line-height: 1.55; color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 .5em; font-weight: 680; letter-spacing: -.01em; }
h1 { font-size: 1.65rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 .8em; }
small, .muted { color: var(--muted); }
.small { font-size: .85rem; }
hr { border: 0; border-top: 1px solid var(--line); margin: 1.25rem 0; }
code { background: var(--surface-3); border-radius: 5px; padding: 1px 5px; font-family: var(--mono); font-size: .84em; }
.icon { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; vertical-align: -3px; }
.icon.lg { width: 22px; height: 22px; }
.icon.xl { width: 30px; height: 30px; }
.sr-only { position: absolute !important; width: 1px !important; height: 1px !important; min-height: 0 !important; padding: 0 !important; margin: -1px !important; border: 0 !important; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- App-Layout ---------- */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }
.sidebar { background: var(--surface); border-right: 1px solid var(--line); padding: 18px 14px; position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; }
.brand { display: flex; align-items: center; gap: 11px; color: var(--ink); padding: 6px 8px 20px; text-decoration: none !important; }
.brand-mark { width: 36px; height: 36px; border-radius: 10px; background: linear-gradient(140deg, var(--primary), #1d8597); display: grid; place-items: center; color: #fff; flex: none; box-shadow: var(--shadow); }
.brand strong { display: block; font-size: 1rem; letter-spacing: -.01em; }
.brand small { display: block; font-size: .76rem; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 11px; color: var(--ink-2); padding: 9px 11px; border-radius: 10px; font-size: .93rem; font-weight: 520; text-decoration: none; position: relative; }
.nav a .icon { color: var(--muted); }
.nav a:hover { background: var(--surface-2); color: var(--ink); }
.nav a.active { background: var(--primary-50); color: var(--primary); font-weight: 640; }
.nav a.active .icon { color: var(--primary); }
.nav .count { margin-left: auto; background: var(--accent); color: #fff; border-radius: 999px; font-size: .72rem; padding: 1px 8px; font-weight: 650; }
.nav .section { color: var(--muted); font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; padding: 18px 11px 6px; font-weight: 650; }
.nav-group { display: flex; flex-direction: column; gap: 2px; }
.nav-group > summary { list-style: none; cursor: pointer; display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; padding: 12px 11px 6px; font-weight: 650; border-radius: 8px; }
.nav-group > summary::-webkit-details-marker { display: none; }
.nav-group > summary:hover { color: var(--ink); }
.nav-group > summary .icon { width: 14px; height: 14px; transition: transform .15s; }
.nav-group[open] > summary .icon { transform: rotate(90deg); }
.feature-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.feature-grid .card h2 { font-size: 1rem; margin-bottom: 10px; }
.feature-grid ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.feature-grid li a { display: flex; align-items: center; gap: 9px; padding: 8px 10px; border-radius: 9px; color: var(--ink-2); text-decoration: none; }
.feature-grid li a:hover { background: var(--surface-2); color: var(--ink); }
.sidebar-foot { margin-top: auto; padding-top: 16px; border-top: 1px solid var(--line); }
.me { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 10px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--primary-100); color: var(--primary); display: grid; place-items: center; font-weight: 700; font-size: .85rem; flex: none; }
.me .who { min-width: 0; flex: 1; }
.me .who strong { display: block; font-size: .88rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me .who small { font-size: .76rem; }
.icon-btn { background: none; border: 0; color: var(--muted); padding: 7px; border-radius: 8px; cursor: pointer; display: inline-grid; place-items: center; }
.icon-btn:hover { background: var(--surface-3); color: var(--ink); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 14px; padding: 12px 32px; background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid transparent; }
.search { flex: 1; max-width: 520px; position: relative; }
.search .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search input { padding-left: 38px !important; background: var(--surface) !important; }
.topbar .spacer { flex: 1; }
.content { padding: 8px 32px 64px; max-width: 1440px; width: 100%; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin: 12px 0 20px; }
.page-head h1 { margin: 0 0 2px; }
.page-head .sub { color: var(--muted); }
.crumbs { font-size: .84rem; color: var(--muted); margin-bottom: 4px; }
.crumbs a { color: var(--muted); }
.pill { display: inline-flex; align-items: center; gap: 6px; border-radius: 999px; padding: 4px 12px; font-size: .8rem; font-weight: 600; background: var(--accent-50); color: var(--accent); }

/* ---------- Karten & Raster ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow); padding: 20px 22px; margin-bottom: 20px; }
.card.flat { box-shadow: none; }
.card.soft { background: var(--surface-2); box-shadow: none; }
.card.highlight { border-color: var(--primary-100); background: linear-gradient(180deg, var(--primary-50), var(--surface) 70%); }
.card.warn { border-color: #f1d49a; background: linear-gradient(180deg, var(--warn-50), var(--surface) 70%); }
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.card-head h2, .card-head h3 { margin: 0; display: flex; align-items: center; gap: 8px; }
.card-head .sub { color: var(--muted); font-size: .86rem; }
.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.split { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 20px; align-items: start; }
.split-wide { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 20px; align-items: start; }
.stack > * + * { margin-top: 12px; }

.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 18px 20px; box-shadow: var(--shadow); color: inherit; display: flex; gap: 14px; align-items: flex-start; text-decoration: none !important; transition: border-color .15s, transform .15s; }
.stat:hover { border-color: var(--primary-100); transform: translateY(-1px); }
.stat .chip { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; background: var(--primary-50); color: var(--primary); flex: none; }
.stat .chip.gold { background: var(--accent-50); color: var(--accent); }
.stat .chip.red { background: var(--danger-50); color: var(--danger); }
.stat .chip.green { background: var(--success-50); color: var(--success); }
.stat .value { font-size: 1.65rem; font-weight: 720; letter-spacing: -.02em; line-height: 1.1; }
.stat .label { color: var(--muted); font-size: .85rem; }

/* ---------- Tabellen & Listen ---------- */
.table-wrap { overflow-x: auto; margin: 0 -22px; padding: 0 22px; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 650; background: var(--surface-2); }
th:first-child { border-top-left-radius: 10px; } th:last-child { border-top-right-radius: 10px; }
tbody tr:hover td { background: var(--surface-2); }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
tr.done td { color: var(--muted); }
tr.done .task-title { text-decoration: line-through; }
.list { list-style: none; padding: 0; margin: 0; }
.list > li { display: flex; gap: 12px; align-items: center; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid var(--line); }
.list > li:last-child { border-bottom: 0; }
.list-plain { list-style: none; padding: 0; margin: 0; }
.list-plain li { padding: 10px 0; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.list-plain li:last-child { border-bottom: 0; }
.row-link { display: flex; gap: 12px; align-items: center; padding: 12px; border-radius: 12px; color: inherit; text-decoration: none !important; }
.row-link:hover { background: var(--surface-2); }
.empty { text-align: center; padding: 34px 20px; color: var(--muted); }
.empty .icon { width: 40px; height: 40px; color: var(--line-2); margin-bottom: 8px; }

/* ---------- Formulare ---------- */
label { display: block; font-size: .83rem; font-weight: 600; color: var(--ink-2); margin-bottom: 5px; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=time], input[type=number], input[type=tel], input[type=search], input[type=url], select, textarea {
  width: 100%; padding: 9px 12px; border: 1px solid var(--line-2); border-radius: 10px; font: inherit; background: var(--surface); color: var(--ink); min-height: 42px; transition: border-color .15s, box-shadow .15s;
}
textarea { min-height: 96px; resize: vertical; line-height: 1.5; }
textarea.letter { min-height: 440px; font-family: var(--mono); font-size: .88rem; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-50); }
input[type=file] { font: inherit; color: var(--muted); }
fieldset { border: 0; padding: 0; margin: 0 0 6px; min-width: 0; }
legend { font-weight: 680; font-size: 1rem; margin-bottom: 12px; color: var(--ink); display: flex; align-items: center; gap: 8px; }
.field { margin-bottom: 14px; }
.form-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 0 16px; }
.col-2 { grid-column: span 2; } .col-3 { grid-column: span 3; } .col-4 { grid-column: span 4; } .col-5 { grid-column: span 5; }
.col-6 { grid-column: span 6; } .col-8 { grid-column: span 8; } .col-12 { grid-column: span 12; }
.check { display: flex; align-items: center; gap: 9px; font-weight: 500; cursor: pointer; }
.check input { width: 18px; height: 18px; margin: 0; accent-color: var(--primary); }
.inline-form { display: inline; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.row.between { justify-content: space-between; }
.hint { font-size: .8rem; color: var(--muted); margin-top: 4px; }
.section-title { display: flex; align-items: center; gap: 10px; margin: 26px 0 12px; font-size: .78rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 680; }
.section-title::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* Ja/Nein-Segmente */
.yesno { display: inline-flex; border: 1px solid var(--line-2); border-radius: 10px; overflow: hidden; }
.yesno input { position: absolute; opacity: 0; pointer-events: none; }
.yesno label { margin: 0; padding: 8px 14px; font-weight: 600; font-size: .86rem; cursor: pointer; color: var(--ink-2); border-right: 1px solid var(--line-2); }
.yesno label:last-of-type { border-right: 0; }
.yesno input:checked + label { background: var(--primary); color: var(--primary-ink); }
.yesno input:focus-visible + label { box-shadow: inset 0 0 0 2px var(--primary-100); }
.question { display: flex; gap: 14px; align-items: center; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid var(--line); }
.question:last-child { border-bottom: 0; }
.question .q { font-weight: 560; }
.question .q small { display: block; font-weight: 400; }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 9px 16px; min-height: 40px; border-radius: 10px; border: 1px solid var(--primary); background: var(--primary); color: var(--primary-ink); font: inherit; font-weight: 620; font-size: .9rem; cursor: pointer; text-decoration: none !important; white-space: nowrap; transition: background .15s, border-color .15s, transform .05s; }
.btn:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn:active { transform: translateY(1px); }
.btn.secondary { background: var(--surface); color: var(--ink); border-color: var(--line-2); }
.btn.secondary:hover { background: var(--surface-2); border-color: var(--muted); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--primary); }
.btn.ghost:hover { background: var(--primary-50); }
.btn.danger { background: var(--surface); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, transparent); }
.btn.danger:hover { background: var(--danger-50); }
.btn.accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.accent:hover { filter: brightness(.95); }
.btn.ai { background: linear-gradient(135deg, #6d4bd8, #2a7fd4); border-color: transparent; color: #fff; }
.btn.ai:hover { filter: brightness(1.08); }
.btn.small { padding: 5px 11px; min-height: 32px; font-size: .82rem; border-radius: 8px; }
.btn.big { padding: 12px 22px; min-height: 48px; font-size: 1rem; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.link-btn { background: none; border: 0; color: var(--primary); cursor: pointer; font: inherit; padding: 0; }
.link-btn:hover { text-decoration: underline; }

/* ---------- Badges & Hinweise ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 10px; border-radius: 999px; font-size: .75rem; font-weight: 640; background: var(--primary-50); color: var(--primary); white-space: nowrap; }
.badge.gray { background: var(--surface-3); color: var(--ink-2); }
.badge.green { background: var(--success-50); color: var(--success); }
.badge.red { background: var(--danger-50); color: var(--danger); }
.badge.yellow { background: var(--warn-50); color: var(--warn); }
.badge.gold { background: var(--accent-50); color: var(--accent); }
.badge.blue { background: var(--info-50); color: var(--info); }
.badge.ai { background: linear-gradient(135deg, #efe9ff, #e3efff); color: #5b3cc4; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; display: inline-block; }
.alert { display: flex; gap: 12px; align-items: flex-start; padding: 12px 16px; border-radius: 12px; margin-bottom: 16px; border: 1px solid transparent; font-size: .93rem; }
.alert .icon { margin-top: 2px; }
.alert.success { background: var(--success-50); color: var(--success); border-color: color-mix(in srgb, var(--success) 20%, transparent); }
.alert.error { background: var(--danger-50); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 20%, transparent); }
.alert.info { background: var(--info-50); color: var(--info); border-color: color-mix(in srgb, var(--info) 18%, transparent); }
.alert.warn { background: var(--warn-50); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 22%, transparent); }
.alert a { color: inherit; text-decoration: underline; }
.pin-box { background: var(--accent-50); border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent); border-radius: var(--radius-lg); padding: 18px 20px; margin-bottom: 18px; }
.pin-box .pin { font-size: 2.1rem; letter-spacing: .28em; font-weight: 750; color: var(--accent); font-family: var(--mono); }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 4px; padding: 4px; background: var(--surface-3); border-radius: 12px; margin-bottom: 20px; overflow-x: auto; scrollbar-width: none; }
.tabs a { display: inline-flex; align-items: center; gap: 7px; padding: 8px 14px; color: var(--ink-2); border-radius: 9px; white-space: nowrap; font-weight: 560; font-size: .9rem; text-decoration: none !important; }
.tabs a:hover { color: var(--ink); }
.tabs a.active { background: var(--surface); color: var(--ink); font-weight: 660; box-shadow: var(--shadow); }
.tabs .count { background: var(--accent); color: #fff; border-radius: 999px; font-size: .7rem; padding: 0 7px; font-weight: 700; }

/* ---------- Fortschritt ---------- */
.progress { height: 6px; background: var(--surface-3); border-radius: 99px; overflow: hidden; min-width: 70px; }
.progress > span { display: block; height: 100%; background: linear-gradient(90deg, var(--primary), #1d8597); border-radius: 99px; }
.progress.lg { height: 10px; }
.ring { --p: 0; width: 54px; height: 54px; border-radius: 50%; background: conic-gradient(var(--primary) calc(var(--p) * 1%), var(--surface-3) 0); display: grid; place-items: center; flex: none; }
.ring::before { content: attr(data-label); width: 42px; height: 42px; border-radius: 50%; background: var(--surface); display: grid; place-items: center; font-size: .78rem; font-weight: 700; }

/* ---------- Sterbefall-Kopf ---------- */
.case-hero { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; }
.case-hero .avatar-xl { width: 56px; height: 56px; border-radius: 16px; background: var(--primary-50); color: var(--primary); display: grid; place-items: center; flex: none; }
.case-hero h1 { margin: 0; font-size: 1.5rem; }
.case-hero .meta { color: var(--muted); font-size: .9rem; display: flex; gap: 6px 14px; flex-wrap: wrap; margin-top: 4px; }
.case-hero .meta span { display: inline-flex; align-items: center; gap: 5px; }
.next-steps { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.next-step { display: flex; gap: 12px; align-items: flex-start; padding: 14px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); color: inherit; text-decoration: none !important; transition: border-color .15s, box-shadow .15s; }
.next-step:hover { border-color: var(--primary-100); box-shadow: var(--shadow); }
.next-step .chip { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; flex: none; background: var(--primary-50); color: var(--primary); }
.next-step.warn .chip { background: var(--warn-50); color: var(--warn); }
.next-step.done .chip { background: var(--success-50); color: var(--success); }
.next-step strong { display: block; font-size: .92rem; }
.next-step small { font-size: .82rem; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; font-size: .92rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }

/* ---------- Meldestellen ---------- */
.party { display: grid; grid-template-columns: 40px 1fr auto; gap: 14px; align-items: start; padding: 14px 0; border-bottom: 1px solid var(--line); }
.party:last-child { border-bottom: 0; }
.party .chip { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--surface-3); color: var(--ink-2); }
.party.st-gemeldet .chip, .party.st-erledigt .chip { background: var(--success-50); color: var(--success); }
.party.st-vorbereitet .chip { background: var(--info-50); color: var(--info); }
.party.st-offen .chip { background: var(--warn-50); color: var(--warn); }
.party details summary { cursor: pointer; color: var(--primary); font-size: .85rem; font-weight: 600; list-style: none; }
.party details summary::-webkit-details-marker { display: none; }
.party details[open] { margin-top: 10px; padding: 14px; background: var(--surface-2); border-radius: 12px; }

/* ---------- Schreiben ---------- */
.proposal { display: grid; grid-template-columns: 28px 1fr auto; gap: 12px; padding: 13px 4px; border-bottom: 1px solid var(--line); align-items: start; }
.proposal:last-child { border-bottom: 0; }
.proposal input[type=checkbox] { width: 19px; height: 19px; margin-top: 2px; accent-color: var(--primary); }
.proposal .title { font-weight: 620; }
.proposal .warn { color: var(--warn); font-size: .83rem; }
.preview-frame { width: 100%; height: 780px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.messages { display: flex; flex-direction: column; gap: 10px; max-height: 440px; overflow-y: auto; padding: 4px; }
.msg { max-width: 82%; padding: 10px 14px; border-radius: 16px; background: var(--surface-3); }
.msg.mine { align-self: flex-end; background: var(--primary); color: var(--primary-ink); }
.msg.mine .who { color: color-mix(in srgb, var(--primary-ink) 75%, transparent); }
.msg .who { font-size: .74rem; color: var(--muted); margin-bottom: 2px; }
.msg p { margin: 0; white-space: pre-wrap; }

/* ---------- KI ---------- */
.ai-card { border: 1px solid #ddd3fb; background: linear-gradient(180deg, #f7f4ff, var(--surface) 60%); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .ai-card { border-color: #3b3266; background: linear-gradient(180deg, #1e1a33, var(--surface) 60%); } }
.ai-title { display: flex; align-items: center; gap: 8px; color: #6d4bd8; }
.ai-output { white-space: pre-wrap; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 14px; font-size: .93rem; }
.suggestion { display: grid; grid-template-columns: 24px 160px 1fr; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px dashed var(--line); }
.suggestion:last-child { border-bottom: 0; }

/* ---------- Kalender ---------- */
.day { display: grid; grid-template-columns: 130px 1fr; gap: 16px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.day:last-child { border-bottom: 0; }
.day .date { font-weight: 680; }
.day .date small { display: block; font-weight: 500; }
.event { display: flex; gap: 12px; align-items: center; padding: 6px 0; }
.event .time { font-variant-numeric: tabular-nums; color: var(--muted); width: 48px; flex: none; font-weight: 600; }

/* ---------- Anmeldung ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth .hero { background: radial-gradient(1200px 600px at 10% 0%, #1d8597 0%, var(--primary) 40%, #08333b 100%); color: #e3f1f3; padding: 64px; display: flex; flex-direction: column; justify-content: center; }
.auth .hero h1 { color: #fff; font-size: 2.2rem; max-width: 560px; }
.auth .hero .feat { display: flex; gap: 12px; align-items: flex-start; margin: 14px 0; max-width: 520px; }
.auth .hero .feat .chip { width: 34px; height: 34px; border-radius: 10px; background: rgba(255,255,255,.12); display: grid; place-items: center; flex: none; }
.auth .panel { display: flex; align-items: center; justify-content: center; padding: 40px 24px; }
.auth .panel .card { width: 100%; max-width: 440px; padding: 30px; }

/* ---------- Portal (Angehörige) ---------- */
.portal-body { background: var(--bg); }
.portal { max-width: 720px; margin: 0 auto; padding: 18px 16px 80px; }
.portal-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 18px; }
.portal-head .brand-p { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--ink); }
.portal .card { padding: 22px; border-radius: 20px; }
.portal h1 { font-size: 1.5rem; }
.btn-xl { display: flex; align-items: center; gap: 14px; width: 100%; min-height: 68px; padding: 14px 20px; border-radius: 16px; font-size: 1.08rem; font-weight: 680; border: 2px solid var(--primary); background: var(--primary); color: var(--primary-ink); cursor: pointer; text-align: left; text-decoration: none !important; font-family: inherit; }
.btn-xl:hover { background: var(--primary-hover); }
.btn-xl .icon { width: 28px; height: 28px; }
.btn-xl small { display: block; font-weight: 500; font-size: .84rem; opacity: .85; }
.btn-xl.secondary { background: var(--surface); color: var(--ink); border-color: var(--line-2); }
.btn-xl.secondary:hover { border-color: var(--primary); background: var(--primary-50); }
.btn-xl.quiet { background: transparent; border-color: transparent; color: var(--muted); min-height: 52px; justify-content: center; font-size: .98rem; }
.btn-xl.quiet:hover { color: var(--ink); background: var(--surface-3); }
.btn-xl + .btn-xl { margin-top: 12px; }
.wizard-top { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.wizard-top .progress { flex: 1; height: 8px; }
.wizard-top .step-count { color: var(--muted); font-size: .85rem; font-weight: 600; white-space: nowrap; }
.doc-tile { display: flex; gap: 14px; align-items: center; padding: 14px; border-radius: 16px; border: 1px solid var(--line); background: var(--surface); color: inherit; text-decoration: none !important; margin-bottom: 10px; min-height: 72px; }
.doc-tile:hover { border-color: var(--primary); }
.doc-tile .chip { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; flex: none; }
.doc-tile.open .chip { background: var(--warn-50); color: var(--warn); }
.doc-tile.ok .chip { background: var(--success-50); color: var(--success); }
.doc-tile .t { flex: 1; min-width: 0; }
.doc-tile .t strong { display: block; }
.sample { background: var(--surface-2); border: 1px solid var(--line); border-radius: 16px; padding: 18px; display: grid; place-items: center; margin: 14px 0; position: relative; }
.sample svg { width: 100%; max-width: 340px; height: auto; }
.sample .tag { position: absolute; top: 10px; left: 12px; font-size: .72rem; font-weight: 700; letter-spacing: .08em; color: var(--muted); text-transform: uppercase; }
.pages { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; margin: 14px 0; }
.pages .page { position: relative; aspect-ratio: 3/4; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); background: var(--surface-2); display: grid; place-items: center; font-size: .78rem; color: var(--muted); text-align: center; padding: 4px; }
.pages .page img { width: 100%; height: 100%; object-fit: cover; }
.pages .page .rm { position: absolute; top: 4px; right: 4px; width: 26px; height: 26px; border-radius: 50%; border: 0; background: rgba(15,23,42,.75); color: #fff; cursor: pointer; display: grid; place-items: center; }
.pages .page .no { position: absolute; bottom: 4px; left: 6px; background: rgba(15,23,42,.75); color: #fff; border-radius: 6px; padding: 0 6px; font-size: .72rem; }
.big-q { padding: 18px 0; border-bottom: 1px solid var(--line); }
.big-q:last-child { border-bottom: 0; }
.big-q .qtext { font-weight: 620; font-size: 1.04rem; margin-bottom: 4px; }
.big-q .qhint { color: var(--muted); font-size: .88rem; margin-bottom: 10px; }
.choice { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice label { margin: 0; display: grid; place-items: center; min-height: 52px; border-radius: 14px; border: 2px solid var(--line-2); font-weight: 650; font-size: 1rem; cursor: pointer; color: var(--ink-2); background: var(--surface); }
.choice input:checked + label { border-color: var(--primary); background: var(--primary-50); color: var(--primary); }
.choice input:focus-visible + label { box-shadow: 0 0 0 4px var(--primary-100); }
.sticky-actions { position: sticky; bottom: 0; padding: 14px 0 6px; background: linear-gradient(180deg, transparent, var(--bg) 30%); }

/* Kamera-Scanner */
.scanner { position: fixed; inset: 0; z-index: 100; background: #000; display: none; flex-direction: column; }
.scanner.open { display: flex; }
.scanner video { flex: 1; width: 100%; object-fit: cover; min-height: 0; }
.scanner .frame { position: absolute; inset: 9% 7% 22%; border: 3px solid rgba(255,255,255,.9); border-radius: 18px; box-shadow: 0 0 0 9999px rgba(0,0,0,.35); pointer-events: none; }
.scanner .hint-top { position: absolute; top: 18px; left: 0; right: 0; text-align: center; color: #fff; font-weight: 600; text-shadow: 0 1px 3px rgba(0,0,0,.6); padding: 0 16px; }
.scanner .bar { display: flex; align-items: center; justify-content: space-between; padding: 18px 24px 28px; background: #000; }
.scanner .shutter { width: 76px; height: 76px; border-radius: 50%; border: 5px solid #fff; background: rgba(255,255,255,.25); cursor: pointer; }
.scanner .shutter:active { background: #fff; }
.scanner .side { color: #fff; background: rgba(255,255,255,.14); border: 0; border-radius: 12px; padding: 12px 16px; font: inherit; font-weight: 600; cursor: pointer; min-width: 92px; }
.scanner .flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; transition: opacity .25s; }
.scanner .flash.on { opacity: .8; transition: none; }
.upload-progress { height: 8px; background: var(--surface-3); border-radius: 99px; overflow: hidden; display: none; margin: 12px 0; }
.upload-progress span { display: block; height: 100%; width: 0; background: var(--primary); transition: width .2s; }

/* ---------- Admin-Konsole ---------- */
.admin-bar { background: #111827; color: #e5e7eb; padding: 8px 32px; font-size: .84rem; display: flex; gap: 14px; align-items: center; }
.admin-bar a { color: #fbbf24; font-weight: 600; }
.plan-card { border: 2px solid var(--line); border-radius: var(--radius-lg); padding: 20px; background: var(--surface); position: relative; }
.plan-card.current { border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-50); }
.plan-card .price { font-size: 1.9rem; font-weight: 760; letter-spacing: -.02em; }
.plan-card ul { padding-left: 1.1em; color: var(--ink-2); font-size: .92rem; line-height: 1.9; }
.bar-chart { display: flex; align-items: flex-end; gap: 6px; height: 140px; padding-top: 10px; }
.bar-chart .bar { flex: 1; background: var(--primary-100); border-radius: 6px 6px 0 0; position: relative; min-height: 2px; }
.bar-chart .bar:hover { background: var(--primary); }
.bar-chart .bar span { position: absolute; bottom: -20px; left: 0; right: 0; text-align: center; font-size: .7rem; color: var(--muted); }

/* ---------- Responsive ---------- */
@media (max-width: 1200px) { .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .split { grid-template-columns: 1fr; } }
@media (max-width: 960px) {
  .grid-3 { grid-template-columns: 1fr 1fr; }
  .split-wide { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px 12px; gap: 6px; }
  .brand { padding: 4px 6px; }
  .nav { flex-direction: row; flex-wrap: nowrap; overflow-x: auto; width: 100%; order: 3; }
  .nav a { flex: none; }
  .nav .section, .sidebar-foot { display: none; }
  .nav-group { display: none; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .form-grid > * { grid-column: span 12; }
  .content, .topbar { padding-left: 16px; padding-right: 16px; }
  .auth { grid-template-columns: 1fr; }
  .auth .hero { padding: 32px 20px; }
  .day { grid-template-columns: 1fr; gap: 4px; }
  .table-wrap { margin: 0 -16px; padding: 0 16px; }
  .suggestion { grid-template-columns: 24px 1fr; }
  .suggestion > :last-child { grid-column: 2; }
}
@media print {
  .sidebar, .topbar, .tabs, .btn, form, .admin-bar { display: none !important; }
  .app { display: block; }
  .card { box-shadow: none; }
}

/* ---------- Feinschliff ---------- */
.btn small, .btn-xl small { color: inherit; }
.btn-xl.secondary small { color: var(--muted); }
.sample { padding-top: 36px; }
.question { flex-wrap: wrap; }
.question .q { flex: 1 1 180px; }
.yesno { flex: none; }
.split .question .q, .split-wide .question .q { flex-basis: 100%; }
.split > :last-child .question { gap: 6px; }
.tabs a { padding: 8px 12px; font-size: .88rem; }
body { overflow-x: hidden; }
.list > li .row { flex-wrap: nowrap; }

/* ---------- Cockpit (Startseite) ---------- */
.cockpit-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.cockpit-head h1 { margin: 0 0 4px; }
.cockpit-head .sub { color: var(--muted); display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.view-toggle { display: inline-flex; background: var(--surface-3); border-radius: 12px; padding: 4px; gap: 2px; }
.view-toggle a { padding: 8px 16px; border-radius: 9px; color: var(--ink-2); font-weight: 600; font-size: .9rem; text-decoration: none; }
.view-toggle a.on { background: var(--surface); color: var(--primary); box-shadow: var(--shadow); }
.quick-actions { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.qa { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; min-height: 92px; padding: 14px 10px; border-radius: var(--radius-lg); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); color: var(--ink); font-weight: 620; font-size: .92rem; text-align: center; text-decoration: none !important; transition: transform .15s, border-color .15s; }
.qa .icon { width: 26px; height: 26px; color: var(--primary); }
.qa:hover { transform: translateY(-2px); border-color: var(--primary-100); }
.qa.primary { background: linear-gradient(140deg, var(--primary), #1d8597); color: #fff; border-color: transparent; }
.qa.primary .icon { color: #fff; }
.qa-count { background: var(--accent); color: #fff; border-radius: 999px; padding: 0 7px; font-size: .75rem; }
.cockpit-grid { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.cockpit-main, .cockpit-side { display: flex; flex-direction: column; gap: 0; min-width: 0; }
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline::before { content: ""; position: absolute; left: 66px; top: 6px; bottom: 6px; width: 2px; background: var(--line); }
.tl-item, .tl-now { display: grid; grid-template-columns: 56px 1fr; gap: 22px; align-items: start; padding: 5px 0; position: relative; }
.tl-time { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; font-size: .92rem; padding-top: 10px; }
.tl-time small { display: block; color: var(--muted); font-weight: 500; }
.tl-item::before { content: ""; position: absolute; left: 62px; top: 17px; width: 10px; height: 10px; border-radius: 50%; background: var(--surface); border: 2px solid var(--primary); }
.tl-card { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); color: inherit; text-decoration: none !important; min-width: 0; }
.tl-card:hover { border-color: var(--primary-100); }
.tl-body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.tl-body strong { font-size: .95rem; }
.tl-body small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tl-icon { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--primary-50); color: var(--primary); flex: none; }
.tl-aufgabe .tl-icon { background: var(--accent-50); color: var(--accent); }
.tl-aufgabe::before { border-color: var(--accent); }
.tl-dienst .tl-card, .tl-bereitschaft .tl-card { background: transparent; border-style: dashed; }
.tl-item.past { opacity: .55; }
.tl-now .tl-time { color: var(--danger); padding-top: 0; }
.tl-now .tl-line { color: var(--danger); font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; border-top: 2px solid var(--danger); padding-top: 2px; }
.avatar.sm { width: 28px; height: 28px; font-size: .7rem; }
.task-list { list-style: none; margin: 0; padding: 0; }
.task-list li { display: flex; align-items: flex-start; gap: 12px; padding: 10px 4px; border-bottom: 1px solid var(--line); }
.task-list li:last-child { border-bottom: 0; }
.task-list li.overdue .task-title { color: var(--danger); }
.task-list form { margin: 0; }
.check-btn { width: 34px; height: 34px; border-radius: 50%; border: 2px solid var(--line-2); background: var(--surface); color: transparent; display: grid; place-items: center; cursor: pointer; flex: none; transition: all .15s; }
.check-btn:hover { border-color: var(--success); color: var(--success); background: var(--success-50); }
.task-body { display: flex; flex-direction: column; min-width: 0; }
.task-title { font-weight: 560; }
.week-strip { display: grid; grid-template-columns: repeat(7, minmax(110px, 1fr)); gap: 8px; overflow-x: auto; padding-bottom: 4px; }
.wk-day { background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 8px; min-height: 120px; display: flex; flex-direction: column; gap: 5px; }
.wk-day.today { border-color: var(--primary); box-shadow: inset 0 0 0 1px var(--primary); }
.wk-head { display: flex; justify-content: space-between; align-items: baseline; color: var(--muted); }
.wk-head strong { color: var(--ink); font-size: .9rem; }
.wk-empty { color: var(--line-2); text-align: center; margin-top: 18px; }
.wk-ev { display: block; font-size: .78rem; line-height: 1.3; padding: 5px 7px; border-radius: 8px; background: var(--primary-50); color: var(--ink); border-left: 3px solid var(--primary); text-decoration: none !important; overflow: hidden; }
.wk-ev b { font-variant-numeric: tabular-nums; }
.wk-ev.ev-beisetzung, .wk-ev.ev-trauerfeier { background: var(--accent-50); border-left-color: var(--accent); }
.wk-staff { display: flex; gap: 2px; margin-top: 3px; }
.wk-staff i { font-style: normal; color: #fff; font-size: .62rem; font-weight: 700; width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center; }
.team-list { list-style: none; margin: 0; padding: 0; }
.team-list li { display: flex; align-items: center; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.team-list li:last-child { border-bottom: 0; }
.team-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.dot.green { color: var(--success); }
.hint-list { display: flex; flex-direction: column; gap: 6px; }
.hint { display: flex; gap: 10px; align-items: flex-start; padding: 10px; border-radius: 10px; color: inherit; text-decoration: none !important; background: var(--surface-2); }
.hint.warn .icon { color: var(--danger); }
.hint span { display: flex; flex-direction: column; min-width: 0; }
.hint strong { font-size: .88rem; }
.hint small { font-size: .8rem; }
@media (max-width: 1180px) { .quick-actions { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 960px) { .cockpit-grid { grid-template-columns: 1fr; } }
@media (max-width: 560px) {
  .quick-actions { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .qa { min-height: 76px; }
  .timeline::before { left: 50px; }
  .tl-item, .tl-now { grid-template-columns: 44px 1fr; gap: 16px; }
  .tl-item::before { left: 46px; }
  .week-strip { grid-template-columns: repeat(7, 132px); }
}
@media (max-width: 560px) {
  .topbar { gap: 8px; }
  .topbar .pill { display: none; }
  .topbar .btn { padding-left: 12px; padding-right: 12px; }
  .grid-4.kpis { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpis .stat { padding: 12px; gap: 10px; flex-direction: column; }
  .kpis .stat .value { font-size: 1.35rem; }
}
