/* Medoplan – Gestaltung
   Marke: Anthropic-Palette (Dunkel #141413, Hell #faf9f5, Akzent Orange #d97757, Blau, Grün), Poppins für Überschriften,
   Lora für Lesetext. Bedienelemente und Tabellen in der Systemschrift (Apple HIG: Lesbarkeit dichter Daten).
   Bewegung: Produktivwerkzeug → kurz und zurückhaltend (≤ 240 ms, ease-out), nichts bei Tastaturbefehlen,
   alles hinter prefers-reduced-motion abgesichert. */

@font-face { font-family: 'Poppins'; src: url(/fonts/poppins/poppins-latin-500-normal.woff2) format('woff2'); font-weight: 500; font-display: swap; }
@font-face { font-family: 'Poppins'; src: url(/fonts/poppins/poppins-latin-600-normal.woff2) format('woff2'); font-weight: 600; font-display: swap; }
@font-face { font-family: 'Lora'; src: url(/fonts/lora/lora-latin-400-normal.woff2) format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Lora'; src: url(/fonts/lora/lora-latin-500-normal.woff2) format('woff2'); font-weight: 500; font-display: swap; }
@font-face { font-family: 'Lora'; src: url(/fonts/lora/lora-latin-400-italic.woff2) format('woff2'); font-weight: 400; font-style: italic; font-display: swap; }

:root {
  color-scheme: light;
  --bg: #faf9f5; --surface: #ffffff; --surface-2: #f3f1ea; --surface-3: #e8e6dc;
  --line: #e2dfd3; --line-strong: #c9c6ba;
  --text: #141413; --text-2: #5e5d58; --text-3: #6f6d66;   /* 6,3:1 bzw. 5,0:1 auf --bg */
  --accent: #d97757; --accent-ink: #141413; --accent-text: #a8502f; --accent-soft: color-mix(in srgb, var(--accent) 14%, var(--surface));
  --ok: #4f6136; --ok-soft: #e6ecdc; --warn: #8a5a00; --warn-soft: #f6ead0; --bad: #a3321f; --bad-soft: #f7e1db; --info: #3d6a96; --info-soft: #e1eaf3;
  --shadow-1: 0 1px 2px rgb(20 20 19 / .06), 0 1px 1px rgb(20 20 19 / .04);
  --shadow-2: 0 8px 28px rgb(20 20 19 / .12), 0 2px 6px rgb(20 20 19 / .06);
  --r: 12px; --r-sm: 8px; --r-lg: 18px;
  --pad: 16px; --row: 44px; --gap: 12px;
  --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI Variable", "Segoe UI", system-ui, "Helvetica Neue", Arial, sans-serif;
  --font-head: 'Poppins', var(--font-ui);
  --font-read: 'Lora', Georgia, serif;
  --ease-out: cubic-bezier(.23, 1, .32, 1);
  --ease-drawer: cubic-bezier(.32, .72, 0, 1);
  --sidebar: 252px;
}
:root[data-font="system"] { --font-head: var(--font-ui); --font-read: var(--font-ui); }
:root[data-radius="eckig"] { --r: 4px; --r-sm: 3px; --r-lg: 6px; }
:root[data-radius="rund"] { --r: 18px; --r-sm: 12px; --r-lg: 26px; }
:root[data-density="kompakt"] { --pad: 12px; --row: 36px; --gap: 8px; }
:root[data-density="luftig"] { --pad: 22px; --row: 52px; --gap: 16px; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #141413; --surface: #1d1c1a; --surface-2: #262522; --surface-3: #33322e;
    --line: #34332f; --line-strong: #4a4943;
    --text: #faf9f5; --text-2: #b0aea5; --text-3: #9c9a92;
    --accent-soft: color-mix(in srgb, var(--accent) 22%, var(--surface));
    --ok: #a9c08a; --ok-soft: #2a3220; --warn: #e2b35a; --warn-soft: #3a2f17; --bad: #f09a86; --bad-soft: #3d221c; --info: #9cc0e6; --info-soft: #1e2a37;
    --shadow-1: 0 1px 2px rgb(0 0 0 / .4); --shadow-2: 0 10px 30px rgb(0 0 0 / .5);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #141413; --surface: #1d1c1a; --surface-2: #262522; --surface-3: #33322e;
  --line: #34332f; --line-strong: #4a4943;
  --text: #faf9f5; --text-2: #b0aea5; --text-3: #9c9a92;
  --accent-soft: color-mix(in srgb, var(--accent) 22%, var(--surface));
  --ok: #a9c08a; --ok-soft: #2a3220; --warn: #e2b35a; --warn-soft: #3a2f17; --bad: #f09a86; --bad-soft: #3d221c; --info: #9cc0e6; --info-soft: #1e2a37;
  --shadow-1: 0 1px 2px rgb(0 0 0 / .4); --shadow-2: 0 10px 30px rgb(0 0 0 / .5);
}
@media (prefers-contrast: more) {
  :root { --text-2: #3e3d39; --text-3: #3e3d39; --line: #9c9a92; --line-strong: #6f6d66; }
  :root[data-theme="dark"] { --text-2: #e4e2da; --text-3: #e4e2da; --line: #77756d; }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
body { font: 15px/1.45 var(--font-ui); -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
h1, h2, h3 { font-family: var(--font-head); font-weight: 600; letter-spacing: -.01em; margin: 0; text-wrap: balance; }
h1 { font-size: 1.6rem; line-height: 1.2; } h2 { font-size: 1.15rem; } h3 { font-size: 1rem; font-weight: 500; }
p { text-wrap: pretty; }
a { color: var(--accent-text); }
button, input, select, textarea { font: inherit; color: inherit; }
.ic { flex: none; display: block; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; border-radius: var(--r-sm); z-index: 100; }
.skip:focus { left: 8px; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 70%, var(--text)); outline-offset: 2px; border-radius: 6px; }
.muted { color: var(--text-2); } .small { font-size: .85rem; } .read { font-family: var(--font-read); font-size: 1rem; line-height: 1.6; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.row { display: flex; align-items: center; gap: var(--gap); } .wrap { flex-wrap: wrap; } .grow { flex: 1; min-width: 0; } .end { margin-left: auto; }
.stack > * + * { margin-top: var(--gap); }

/* ---------- Grundgerüst ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar) 1fr; height: 100dvh; }
.shell.ai-open { grid-template-columns: var(--sidebar) 1fr min(420px, 34vw); }
.sidebar { background: var(--surface-2); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; padding: max(12px, env(safe-area-inset-top)) 10px 10px max(10px, env(safe-area-inset-left)); }
.brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px 14px; }
.brand-mark { width: 30px; height: 30px; border-radius: 8px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font: 600 15px var(--font-head); }
.brand-name { font: 600 1.05rem var(--font-head); } .brand-sub { font-size: .78rem; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav { overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 1px; }
.nav-group { font-size: .74rem; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .04em; padding: 14px 10px 4px; }
.nav a { display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 0 10px; border-radius: var(--r-sm); color: var(--text); text-decoration: none; font-size: .94rem; }
.nav a:hover { background: var(--surface-3); }
.nav a[aria-current="page"] { background: var(--surface); box-shadow: var(--shadow-1); font-weight: 600; }
.nav a[aria-current="page"] .ic { color: var(--accent-text); }
.nav .badge { margin-left: auto; }
.side-foot { border-top: 1px solid var(--line); padding-top: 8px; display: flex; flex-direction: column; gap: 2px; }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 6px 8px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--surface-3); display: grid; place-items: center; font-weight: 600; font-size: .8rem; flex: none; }

.main { min-width: 0; display: flex; flex-direction: column; min-height: 0; }
.topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: var(--gap); padding: 14px max(24px, env(safe-area-inset-right)) 12px 24px; background: color-mix(in srgb, var(--bg) 86%, transparent); backdrop-filter: saturate(1.4) blur(14px); -webkit-backdrop-filter: saturate(1.4) blur(14px); border-bottom: 1px solid transparent; }
.topbar.scrolled { border-bottom-color: var(--line); }
.topbar .title { min-width: 0; } .topbar .title p { margin: 2px 0 0; color: var(--text-2); font-size: .88rem; }
.content { flex: 1; overflow-y: auto; padding: 8px 24px 40px; overscroll-behavior: contain; }
.menu-btn { display: none; }

/* ---------- Bedienelemente ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 36px; padding: 0 14px; border-radius: var(--r-sm); border: 1px solid var(--line-strong); background: var(--surface); cursor: pointer; font-weight: 500; font-size: .92rem; white-space: nowrap; text-decoration: none; color: var(--text); transition: transform 100ms var(--ease-out), background-color 120ms; }
.btn:hover { background: var(--surface-2); }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn.primary:hover { background: color-mix(in srgb, var(--accent) 88%, var(--text)); }
.btn.plain { border-color: transparent; background: transparent; }
.btn.plain:hover { background: var(--surface-2); }
.btn.danger { color: var(--bad); }
.btn.icon { padding: 0; width: 36px; }
.btn.lg { min-height: 44px; padding: 0 18px; font-size: 1rem; }
.btn[disabled] { opacity: .5; cursor: default; transform: none; }
@media (pointer: coarse) { .btn { min-height: 44px; } .btn.icon { width: 44px; } }

.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > label, .label { font-size: .82rem; font-weight: 500; color: var(--text-2); }
.input, select.input, textarea.input { width: 100%; min-height: 40px; padding: 8px 12px; border-radius: var(--r-sm); border: 1px solid var(--line-strong); background: var(--surface); font-size: 16px; }
textarea.input { min-height: 96px; resize: vertical; line-height: 1.5; }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 28%, transparent); }
.input[aria-invalid="true"] { border-color: var(--bad); }
.err { color: var(--bad); font-size: .85rem; display: flex; gap: 6px; align-items: center; }
.check { display: flex; align-items: center; gap: 10px; min-height: 40px; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); }
.search { position: relative; } .search .ic { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--text-3); pointer-events: none; }
.search .input { padding-left: 36px; }

.seg { display: inline-flex; background: var(--surface-3); padding: 3px; border-radius: calc(var(--r-sm) + 3px); gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; min-height: 32px; padding: 0 12px; border-radius: var(--r-sm); cursor: pointer; font-size: .88rem; font-weight: 500; color: var(--text-2); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-1); }

.chip { display: inline-flex; align-items: center; gap: 6px; min-height: 30px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--surface); cursor: pointer; font-size: .86rem; }
.chip[aria-pressed="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 999px; font-size: .78rem; font-weight: 600; background: var(--surface-3); color: var(--text-2); white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); } .badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); } .badge.info { background: var(--info-soft); color: var(--info); }
.badge.accent { background: var(--accent); color: var(--accent-ink); }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }

/* ---------- Karten, Listen, Tabellen ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: var(--pad); }
.card > h2, .card > header h2 { font-size: 1rem; }
.card > header { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.grid { display: grid; gap: var(--gap); }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } .g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: var(--gap); }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px var(--pad); text-decoration: none; color: inherit; display: block; }
.tile .k { font-size: .82rem; color: var(--text-2); } .tile .v { font: 600 1.6rem/1.2 var(--font-head); margin-top: 4px; font-variant-numeric: tabular-nums; } .tile .s { font-size: .82rem; color: var(--text-2); margin-top: 2px; }
a.tile:hover { border-color: var(--line-strong); }

.table-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); overflow: auto; }
table.t { width: 100%; border-collapse: collapse; font-size: .92rem; }
.t th { text-align: left; font-weight: 600; font-size: .78rem; color: var(--text-2); padding: 10px 12px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--surface); white-space: nowrap; }
.t td { padding: 0 12px; height: var(--row); border-bottom: 1px solid var(--line); white-space: nowrap; max-width: 280px; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }
.t tbody tr { cursor: pointer; } .t tbody tr:hover { background: var(--surface-2); } .t tbody tr:last-child td { border-bottom: 0; }
.t .num { text-align: right; }
.cards { display: none; }

.ilist { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.ilist > .item { display: flex; align-items: center; gap: 12px; min-height: var(--row); padding: 8px var(--pad); border-bottom: 1px solid var(--line); text-decoration: none; color: inherit; }
.ilist > .item:last-child { border-bottom: 0; }
.ilist > a.item:hover, .ilist > button.item:hover { background: var(--surface-2); }
.ilist > button.item { width: 100%; border: 0; border-bottom: 1px solid var(--line); background: none; text-align: left; cursor: pointer; }
.kv { display: grid; grid-template-columns: minmax(120px, 34%) 1fr; gap: 0; }
.kv > div { padding: 10px var(--pad); border-bottom: 1px solid var(--line); min-width: 0; overflow-wrap: anywhere; }
.kv > div:nth-child(odd) { color: var(--text-2); font-size: .88rem; }
.kv > div:nth-last-child(-n+2) { border-bottom: 0; }
.section-title { font-size: .78rem; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .04em; margin: 22px 4px 8px; }
.empty { text-align: center; padding: 48px 20px; color: var(--text-2); }
.empty h3 { color: var(--text); margin-bottom: 6px; } .empty p { font-family: var(--font-read); max-width: 46ch; margin: 0 auto 14px; }
.notice { display: flex; gap: 10px; padding: 12px 14px; border-radius: var(--r-sm); background: var(--info-soft); color: var(--text); }
.notice.warn { background: var(--warn-soft); } .notice.bad { background: var(--bad-soft); } .notice.ok { background: var(--ok-soft); }
.notice .ic { color: var(--info); } .notice.warn .ic { color: var(--warn); } .notice.bad .ic { color: var(--bad); } .notice.ok .ic { color: var(--ok); }
code, pre { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: .86rem; }
pre.code { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 12px; overflow: auto; white-space: pre-wrap; word-break: break-all; }
.skeleton { background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2)); border-radius: var(--r-sm); min-height: 18px; }

/* ---------- Sheets (modale Fenster) ---------- */
.backdrop { position: fixed; inset: 0; background: rgb(20 20 19 / .32); z-index: 40; opacity: 0; transition: opacity 200ms var(--ease-out); }
.sheet { position: fixed; z-index: 41; left: 50%; top: 6vh; width: min(640px, calc(100vw - 32px)); max-height: 88dvh; display: flex; flex-direction: column; background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow-2);
  opacity: 0; transform: translate(-50%, 8px) scale(.985); filter: blur(2px); transition: opacity 200ms var(--ease-out), transform 220ms var(--ease-out), filter 200ms var(--ease-out); }
.sheet.wide { width: min(900px, calc(100vw - 32px)); }
.open > .backdrop { opacity: 1; } .open > .sheet { opacity: 1; transform: translate(-50%, 0) scale(1); filter: none; }
.closing > .backdrop { opacity: 0; transition-duration: 150ms; } .closing > .sheet { opacity: 0; transform: translate(-50%, 4px); filter: none; transition-duration: 150ms; }
.sheet header { display: flex; align-items: center; gap: 10px; padding: 14px 16px 12px 20px; border-bottom: 1px solid var(--line); }
.sheet header h2 { flex: 1; font-size: 1.08rem; }
.sheet .body { padding: 16px 20px 20px; overflow-y: auto; }
.sheet footer { display: flex; gap: 10px; justify-content: flex-end; padding: 12px 20px max(14px, env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
.form-group { margin-bottom: 18px; } .form-group > .label { display: block; margin: 0 0 8px; text-transform: uppercase; letter-spacing: .04em; font-size: .74rem; color: var(--text-3); font-weight: 600; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 14px; }
.form-grid .full { grid-column: 1 / -1; }

/* Auswahlfeld mit Suche (Referenzen) */
.combo { position: relative; }
.combo-list { position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 50; background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r-sm); box-shadow: var(--shadow-2); max-height: 260px; overflow: auto; padding: 4px; transform-origin: top center; }
.combo-list button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 9px 10px; border-radius: 6px; cursor: pointer; }
.combo-list button:hover, .combo-list button[aria-selected="true"] { background: var(--surface-2); }

/* ---------- Befehlspalette (⌘K) – öffnet sofort, ohne Animation (Tastaturbefehl) ---------- */
.palette { position: fixed; z-index: 60; left: 50%; top: 12vh; transform: translateX(-50%); width: min(620px, calc(100vw - 24px)); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-2); overflow: hidden; }
.palette input { width: 100%; border: 0; border-bottom: 1px solid var(--line); background: transparent; padding: 16px 18px; font-size: 18px; outline: none; }
.palette .results { max-height: 52vh; overflow: auto; padding: 6px; }
.palette .res { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--r-sm); cursor: pointer; }
.palette .res[aria-selected="true"] { background: var(--accent-soft); }
.palette .res small { margin-left: auto; color: var(--text-3); }
.palette-backdrop { position: fixed; inset: 0; z-index: 59; background: rgb(20 20 19 / .2); }
kbd { font: 500 .75rem var(--font-ui); padding: 1px 6px; border: 1px solid var(--line-strong); border-radius: 5px; color: var(--text-2); background: var(--surface); }

/* ---------- KI-Assistent ---------- */
.ai { border-left: 1px solid var(--line); background: var(--surface); display: flex; flex-direction: column; min-height: 0; }
.ai header { display: flex; align-items: center; gap: 8px; padding: 14px 12px 10px 16px; border-bottom: 1px solid var(--line); }
.ai header h2 { flex: 1; font-size: 1rem; display: flex; align-items: center; gap: 8px; }
.ai .msgs { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 14px; }
.msg { max-width: 92%; } .msg.user { align-self: flex-end; background: var(--accent-soft); padding: 10px 14px; border-radius: 16px 16px 4px 16px; }
.msg.bot { font-family: var(--font-read); font-size: .98rem; line-height: 1.6; }
.msg.bot table { border-collapse: collapse; font-family: var(--font-ui); font-size: .85rem; margin: 6px 0; display: block; overflow-x: auto; }
.msg.bot td, .msg.bot th { border: 1px solid var(--line); padding: 4px 8px; text-align: left; }
.msg.bot p { margin: 0 0 8px; } .msg.bot ul, .msg.bot ol { margin: 0 0 8px; padding-left: 20px; }
.msg.err { color: var(--bad); font-size: .92rem; }
.steps { font-family: var(--font-ui); font-size: .8rem; color: var(--text-2); margin-top: 6px; }
.steps summary { cursor: pointer; } .steps li { list-style: none; display: flex; gap: 6px; align-items: center; }
.ai .compose { border-top: 1px solid var(--line); padding: 10px 12px max(12px, env(safe-area-inset-bottom)); }
.ai .compose form { display: flex; gap: 8px; align-items: flex-end; }
.ai .compose textarea { flex: 1; resize: none; min-height: 44px; max-height: 160px; border-radius: 14px; }
.ai .suggest { display: flex; gap: 6px; flex-wrap: wrap; padding: 0 16px 10px; }
.thinking { display: flex; gap: 8px; align-items: center; color: var(--text-2); font-size: .9rem; }
.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--line-strong); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Toasts ---------- */
#toast-root { position: fixed; z-index: 80; left: 50%; bottom: max(20px, env(safe-area-inset-bottom)); transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { pointer-events: auto; background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 999px; box-shadow: var(--shadow-2); font-size: .92rem; display: flex; gap: 8px; align-items: center;
  opacity: 0; transform: translateY(8px); transition: opacity 180ms var(--ease-out), transform 200ms var(--ease-out); }
.toast.in { opacity: 1; transform: none; } .toast.bad { background: var(--bad); color: #fff; }

/* ---------- Kalender ---------- */
.cal-toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.cal { --hour: 64px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); overflow: auto; max-height: calc(100dvh - 190px); position: relative; touch-action: pan-x pan-y; }
.cal-head { display: grid; position: sticky; top: 0; z-index: 3; background: var(--surface); border-bottom: 1px solid var(--line); }
.cal-head > div { padding: 10px 8px; font-weight: 600; font-size: .9rem; display: flex; align-items: center; gap: 8px; min-width: 0; border-left: 1px solid var(--line); }
.cal-head > div span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-body { display: grid; position: relative; }
.cal-times { position: sticky; left: 0; z-index: 2; background: var(--surface); }
.cal-times div { height: var(--hour); font-size: .75rem; color: var(--text-3); text-align: right; padding: 0 8px; transform: translateY(-7px); font-variant-numeric: tabular-nums; }
.cal-col { position: relative; border-left: 1px solid var(--line); background-image: linear-gradient(var(--line) 1px, transparent 1px), linear-gradient(color-mix(in srgb, var(--line) 50%, transparent) 1px, transparent 1px); background-size: 100% var(--hour), 100% calc(var(--hour) / 2); }
.cal-col.off { background-color: var(--surface-2); }
.cal-off { position: absolute; left: 0; right: 0; background: repeating-linear-gradient(135deg, transparent 0 6px, color-mix(in srgb, var(--line) 70%, transparent) 6px 7px); pointer-events: none; }
.appt { position: absolute; left: 3px; right: 3px; border-radius: 7px; padding: 4px 8px 4px 10px; font-size: .8rem; line-height: 1.3; overflow: hidden; cursor: grab; user-select: none; -webkit-user-select: none; touch-action: none;
  background: color-mix(in srgb, var(--c) 16%, var(--surface)); border: 1px solid color-mix(in srgb, var(--c) 40%, var(--surface)); box-shadow: inset 3px 0 0 var(--c); color: var(--text); }
.appt b { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.appt .meta { color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.appt.st-abgesagt, .appt.st-ausgefallen { opacity: .55; text-decoration: line-through; }
.appt.st-angefragt { border-style: dashed; }
.appt.st-erschienen::after { content: '✓'; position: absolute; right: 6px; bottom: 3px; font-weight: 700; color: var(--ok); }
/* Zusatzsymbole am Termin */
.ticons { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 3px; }
.appt.short .ticons { position: absolute; right: 4px; top: 3px; margin: 0; flex-wrap: nowrap; background: inherit; padding-left: 4px; }
.ti { font-style: normal; font-size: .68rem; font-weight: 600; line-height: 1; padding: 2px 4px; border-radius: 4px; display: inline-flex; align-items: center; gap: 2px;
  background: color-mix(in srgb, var(--text) 8%, transparent); color: var(--text-2); font-variant-numeric: tabular-nums; }
.ti.g-w { color: #b0306a; background: color-mix(in srgb, #b0306a 12%, transparent); }
.ti.g-m { color: #2b6cb0; background: color-mix(in srgb, #2b6cb0 12%, transparent); }
.ti.n.last { color: var(--bad); background: color-mix(in srgb, var(--bad) 12%, transparent); }
.ti.new { color: var(--ok); background: color-mix(in srgb, var(--ok) 14%, transparent); }
/* Arbeitszeit-Kacheln im Kalenderhintergrund */
.cal-block { position: absolute; left: 0; right: 0; pointer-events: none; background: color-mix(in srgb, var(--bc) 7%, transparent); border-left: 3px solid color-mix(in srgb, var(--bc) 55%, transparent); }
.cal-block span { position: absolute; right: 4px; bottom: 2px; font-size: .62rem; color: color-mix(in srgb, var(--bc) 80%, var(--text)); opacity: .8; }
.cal-block.closed { background: repeating-linear-gradient(135deg, color-mix(in srgb, var(--bc) 14%, transparent) 0 6px, transparent 6px 12px); }
/* Wochenplan Arbeitszeiten */
.az-legend { gap: 14px; }
.az-swatch { width: 14px; height: 14px; border-radius: 4px; background: color-mix(in srgb, var(--bc) 30%, var(--surface)); border: 2px solid var(--bc); }
.az-swatch.closed, .az-tile.closed { background: repeating-linear-gradient(135deg, color-mix(in srgb, var(--bc) 22%, var(--surface)) 0 6px, var(--surface) 6px 12px); }
.az-grid { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); overflow: auto; max-height: calc(100dvh - 300px); }
.az-head, .az-body { display: grid; grid-template-columns: 52px repeat(7, minmax(96px, 1fr)); }
.az-head { position: sticky; top: 0; z-index: 2; background: var(--surface); border-bottom: 1px solid var(--line); }
.az-head > div { padding: 8px; font-weight: 600; text-align: center; border-left: 1px solid var(--line); }
.az-times div { font-size: .72rem; color: var(--text-3); text-align: right; padding: 0 6px; transform: translateY(-6px); font-variant-numeric: tabular-nums; }
.az-col { position: relative; border-left: 1px solid var(--line); cursor: copy; background-image: linear-gradient(var(--line) 1px, transparent 1px); background-size: 100% 54px; }
.az-tile { position: absolute; left: 4px; right: 4px; border-radius: 8px; padding: 5px 7px; text-align: left; display: flex; flex-direction: column; gap: 1px; overflow: hidden; cursor: pointer;
  background: color-mix(in srgb, var(--bc) 18%, var(--surface)); border: 1px solid color-mix(in srgb, var(--bc) 50%, var(--surface)); box-shadow: inset 3px 0 0 var(--bc); color: var(--text); font: inherit; font-size: .76rem; line-height: 1.25;
  transition: transform .12s ease-out, box-shadow .12s ease-out; }
.az-tile:hover { box-shadow: inset 3px 0 0 var(--bc), var(--shadow-1); }
.az-tile:active { transform: scale(.985); }
.az-tile.alt { border-style: dashed; }
.az-tile b { font-weight: 600; } .az-tile span { color: var(--text-2); font-variant-numeric: tabular-nums; display: inline-flex; align-items: center; gap: 3px; }
@media (prefers-reduced-motion: reduce) { .az-tile { transition: none; } }
/* Rezeptscan */
.scan-stage { position: relative; background: #111; border-radius: var(--r-sm, 10px); overflow: hidden; min-height: 220px; display: grid; place-items: center; }
.scan-stage video { width: 100%; max-height: 52vh; object-fit: contain; display: block; }
.scan-frame { position: absolute; inset: 8% 6%; border: 2px dashed rgba(255,255,255,.75); border-radius: 10px; pointer-events: none; }
.scan-empty { position: absolute; inset: 0; display: grid; place-content: center; gap: 8px; text-align: center; color: #ddd; }
.scan-empty[hidden] { display: none; }
details.kasse { border-top: 1px solid var(--line); padding-top: 10px; } details.kasse summary { cursor: pointer; list-style: none; gap: 10px; } details.kasse summary::-webkit-details-marker { display: none; }
.appt.dragging { cursor: grabbing; box-shadow: var(--shadow-2), inset 3px 0 0 var(--c); z-index: 4; opacity: .92; }
.appt .resize { position: absolute; left: 0; right: 0; bottom: 0; height: 8px; cursor: ns-resize; }
.now-line { position: absolute; left: 0; right: 0; height: 2px; background: var(--bad); z-index: 2; pointer-events: none; }
.now-line::before { content: ''; position: absolute; left: -4px; top: -4px; width: 10px; height: 10px; border-radius: 50%; background: var(--bad); }

/* ---------- Diagramme ---------- */
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart .bar { fill: var(--accent); } .chart .bar:hover { fill: color-mix(in srgb, var(--accent) 80%, var(--text)); }
.chart .axis { fill: var(--text-3); font-size: 11px; font-family: var(--font-ui); }
.chart .grid-line { stroke: var(--line); stroke-width: 1; }
.chart-tip { position: fixed; z-index: 90; pointer-events: none; background: var(--text); color: var(--bg); font-size: .82rem; padding: 6px 10px; border-radius: 8px; box-shadow: var(--shadow-2); }
.hbar { display: grid; grid-template-columns: minmax(90px, 34%) 1fr auto; gap: 8px 10px; align-items: center; font-size: .9rem; }
.hbar .track { height: 10px; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.hbar .fill { height: 100%; border-radius: 999px; background: var(--c, var(--accent)); }
.hbar .val { font-variant-numeric: tabular-nums; color: var(--text-2); }

/* ---------- Login ---------- */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.login .card { width: min(400px, 100%); padding: 28px; }
.login h1 { font-size: 1.5rem; margin: 18px 0 4px; }

/* ---------- Tablet & Telefon ---------- */
@media (max-width: 1180px) {
  .shell { --sidebar: 72px; }
  .shell.ai-open { grid-template-columns: var(--sidebar) 1fr; }
  .shell.ai-open .ai { position: fixed; right: 0; top: 0; bottom: 0; width: min(420px, 100vw); z-index: 30; box-shadow: var(--shadow-2); }
  .sidebar .brand-name, .sidebar .brand-sub, .nav a span, .nav-group, .user-chip .who, .nav .badge { display: none; }
  .nav a { justify-content: center; padding: 0; min-height: 44px; } .brand { justify-content: center; }
  .side-foot .btn { justify-content: center; } .side-foot .btn span { display: none; }
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 280px; z-index: 35; transform: translateX(-102%); transition: transform 260ms var(--ease-drawer); box-shadow: var(--shadow-2); }
  .shell.nav-open .sidebar { transform: none; }
  .shell.nav-open::after { content: ''; position: fixed; inset: 0; background: rgb(20 20 19 / .3); z-index: 34; }
  .sidebar .brand-name, .sidebar .brand-sub, .nav a span, .nav-group, .user-chip .who, .nav .badge { display: revert; }
  .nav a { justify-content: flex-start; padding: 0 10px; } .side-foot .btn span { display: inline; }
  .menu-btn { display: inline-flex; }
  .topbar { padding: max(10px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 10px max(16px, env(safe-area-inset-left)); flex-wrap: wrap; }
  .content { padding: 8px max(16px, env(safe-area-inset-right)) 32px max(16px, env(safe-area-inset-left)); }
  .g2, .g3, .g4, .form-grid { grid-template-columns: 1fr; }
  .table-wrap.responsive { display: none; } .cards { display: block; }
  .kv { grid-template-columns: 1fr; } .kv > div:nth-child(odd) { border-bottom: 0; padding-bottom: 0; } .kv > div:nth-last-child(2) { border-bottom: 0; }
  h1 { font-size: 1.35rem; }
  .sheet { top: auto; bottom: 0; width: 100vw; max-height: 92dvh; border-radius: var(--r-lg) var(--r-lg) 0 0; transform: translate(-50%, 24px); }
  .open > .sheet { transform: translate(-50%, 0); } .closing > .sheet { transform: translate(-50%, 16px); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 1ms !important; animation-duration: 1ms !important; animation-iteration-count: 1 !important; }
  .sheet, .open > .sheet, .closing > .sheet, .toast { transform: translate(-50%, 0) !important; filter: none !important; }
  .toast { transform: none !important; }
  .btn:active { transform: none; }
  .spinner { animation: none; border-top-color: var(--line-strong); }
}
@media (forced-colors: active) { .appt { border: 1px solid CanvasText; } .btn.primary { border: 1px solid ButtonText; } }

.now-line.plain::before { display: none; }
.appt b { font-size: .8rem; }

@media (max-width: 1180px) and (min-width: 761px) {
  .sidebar [data-palette] { justify-content: center; padding: 0; min-height: 44px; }
  .sidebar [data-palette] span, .sidebar [data-palette] kbd { display: none; }
}
.shell:not(.ai-open) > .ai { display: none; }
@media (max-width: 760px) {
  .content > .row.wrap > .search { flex: 1 1 100%; max-width: none !important; }
  .content > .row.wrap > [role="group"] { flex-wrap: nowrap; overflow-x: auto; max-width: 100%; padding-bottom: 2px; }
  .shell.ai-open .ai { width: 100vw; }
}
/* Wiederherstellungscodes */
.codes { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; }
.codes code { font-size: 1rem; padding: 8px 10px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--line); text-align: center; user-select: all; font-variant-numeric: tabular-nums; }

/* ---------- Patientenakte ---------- */
.akte { display: flex; flex-direction: column; gap: var(--gap); max-width: 1280px; }
.akte-kopf { display: flex; gap: 18px; align-items: flex-start; flex-wrap: wrap; }
.avatar.xl { width: 64px; height: 64px; font-size: 1.3rem; background: color-mix(in srgb, var(--accent) 18%, var(--surface)); color: var(--text); }
.akte-zeile { display: flex; flex-wrap: wrap; gap: 4px 16px; color: var(--text-2); line-height: 1.6; }
.akte-zeile strong { color: var(--text); }
.kv-link { display: inline-flex; align-items: center; gap: 5px; min-height: 28px; color: var(--accent-text, var(--text)); }
.akte-zahlen { display: flex; gap: 8px; }
.akte-zahlen > div { min-width: 84px; padding: 8px 12px; border-radius: var(--r-sm); background: var(--surface-2); display: flex; flex-direction: column; align-items: center; }
.akte-zahlen b { font-size: 1.15rem; font-variant-numeric: tabular-nums; } .akte-zahlen span { font-size: .76rem; color: var(--text-2); }
.akte-hinweise { display: flex; flex-wrap: wrap; gap: 8px; }
.hint { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 999px; font-size: .86rem; background: var(--info-soft); color: var(--info); }
.hint.ok { background: var(--ok-soft); color: var(--ok); } .hint.warn { background: var(--warn-soft); color: var(--warn); } .hint.bad { background: var(--bad-soft); color: var(--bad); font-weight: 600; }
.akte-grid { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: var(--gap); align-items: start; }
@media (max-width: 1100px) { .akte-grid { grid-template-columns: 1fr; } }
h2.sec { font-size: 1rem; margin: 0; }
.vo-karte { display: flex; flex-direction: column; gap: 6px; padding: 12px; border: 1px solid var(--line); border-radius: var(--r-sm); }
.vo-karte a { color: inherit; text-decoration: none; }
.fortschritt { display: flex; height: 8px; border-radius: 4px; background: var(--surface-3); overflow: hidden; }
.fortschritt .e { background: var(--ok); } .fortschritt .g { background: repeating-linear-gradient(135deg, var(--info) 0 4px, color-mix(in srgb, var(--info) 55%, transparent) 4px 8px); }
.zeitstrahl { list-style: none; margin: 0; padding: 0; position: relative; }
.zeitstrahl::before { content: ''; position: absolute; left: 15px; top: 6px; bottom: 6px; width: 2px; background: var(--line); }
.zeitstrahl li { display: flex; gap: 12px; padding: 6px 0; position: relative; }
.zs-ico { width: 32px; height: 32px; border-radius: 50%; background: var(--surface-2); border: 2px solid var(--surface); display: grid; place-items: center; flex: none; z-index: 1; color: var(--text-2); }
.zs-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; color: inherit; text-decoration: none; padding: 4px 8px; border-radius: var(--r-sm); flex: 1; min-height: 44px; justify-content: center; }
.zs-text:hover { background: var(--surface-2); }
.zs-info { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Mein Tag (Tablet) ---------- */
.tag-kopf { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.tag-liste { display: flex; flex-direction: column; gap: 12px; max-width: 980px; }
.tag-karte { display: grid; grid-template-columns: 72px minmax(0, 1fr); gap: 4px 16px; padding: 14px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); }
.tag-karte.aus { opacity: .6; }
.tk-zeit { display: flex; flex-direction: column; } .tk-zeit b { font-size: 1.25rem; font-variant-numeric: tabular-nums; } .tk-zeit span { font-size: .8rem; color: var(--text-2); }
.tk-inhalt { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.tk-name { font-size: 1.08rem; }
.tk-letzte { font-size: .9rem; padding: 6px 10px; border-radius: var(--r-sm); background: var(--surface-2); }
.tk-status { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 2px; }
.tk-aktionen { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; padding-top: 10px; border-top: 1px solid var(--line); }
.tk-aktionen .btn { min-height: 44px; }
@media (max-width: 560px) { .tag-karte { grid-template-columns: 1fr; } .tk-zeit { flex-direction: row; gap: 8px; align-items: baseline; } }
.doku-form textarea { font-size: 16px; }
.nrs { display: grid; grid-template-columns: repeat(11, minmax(36px, 1fr)); gap: 6px; }
.nrs button { min-height: 44px; border-radius: var(--r-sm); border: 1px solid var(--line-strong); background: var(--surface); font: inherit; font-weight: 600; cursor: pointer; color: var(--text); }
.nrs button[aria-checked="true"] { background: var(--accent); color: var(--accent-ink, #fff); border-color: var(--accent); }
.sig-feld { position: relative; height: 220px; border: 1.5px dashed var(--line-strong); border-radius: var(--r); background: #fff; }
.sig-feld canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; cursor: crosshair; border-radius: inherit; }
.sig-linie { position: absolute; left: 24px; right: 24px; bottom: 44px; border-top: 1px solid #b0aea5; padding-top: 4px; font-size: .8rem; color: #6f6d66; pointer-events: none; }

/* ---------- Check-in-Kiosk ---------- */
html.kiosk, html.kiosk body { background: var(--bg); }
.kiosk-main { min-height: 100dvh; display: flex; flex-direction: column; align-items: center; gap: 18px; padding: max(20px, env(safe-area-inset-top)) max(24px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(24px, env(safe-area-inset-left)); }
.kiosk-kopf { width: 100%; max-width: 1100px; display: flex; justify-content: space-between; align-items: center; }
.kiosk-praxis { font-weight: 600; font-size: 1.1rem; } .kiosk-uhr { color: var(--text-2); font-variant-numeric: tabular-nums; }
.kiosk-titel { font-size: clamp(1.7rem, 4vw, 2.6rem); margin: 8px 0 0; text-align: center; }
.kiosk-text { font-size: 1.3rem; color: var(--text-2); text-align: center; margin: 0; line-height: 1.5; }
.kiosk-liste { width: 100%; max-width: 1100px; display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.kiosk-termin { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; min-height: 96px; padding: 16px 20px; border-radius: var(--r-lg); border: 1px solid var(--line); background: var(--surface); font: inherit; color: var(--text); cursor: pointer; text-align: left; box-shadow: var(--shadow-1); transition: transform 120ms var(--ease-out); }
.kiosk-termin:active { transform: scale(.98); }
.kiosk-termin b { font-size: 1.5rem; font-variant-numeric: tabular-nums; } .kiosk-termin span { font-size: 1.25rem; font-weight: 600; } .kiosk-termin small { color: var(--text-2); font-size: 1rem; }
.kiosk-mitte { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px; width: 100%; }
.kiosk-geb { display: flex; align-items: flex-end; gap: 10px; font-size: 2rem; }
.kiosk-geb label { display: flex; flex-direction: column; gap: 6px; font-size: 1rem; color: var(--text-2); }
.kiosk-geb input { width: 96px; height: 76px; font-size: 2.2rem; text-align: center; border-radius: var(--r); border: 1.5px solid var(--line-strong); background: var(--surface); color: var(--text); font-variant-numeric: tabular-nums; }
.kiosk-geb input:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.kiosk-fehler { color: var(--bad); font-size: 1.15rem; display: flex; align-items: center; gap: 8px; margin: 0; }
.kiosk-hinweis { display: flex; align-items: center; gap: 10px; font-size: 1.2rem; padding: 12px 18px; border-radius: var(--r); background: var(--warn-soft); color: var(--warn); margin: 0; }
.kiosk-haken { width: 104px; height: 104px; border-radius: 50%; display: grid; place-items: center; background: var(--ok-soft); color: var(--ok); animation: kiosk-pop 320ms var(--ease-out); }
@keyframes kiosk-pop { from { transform: scale(.85); opacity: 0; } to { transform: none; opacity: 1; } }
.kiosk-fuss { color: var(--text-2); margin-top: auto; font-size: 1rem; text-align: center; }
.kiosk-main .btn.lg { min-height: 56px; padding: 0 28px; font-size: 1.1rem; }
@media (prefers-reduced-motion: reduce) { .kiosk-haken { animation: none; } .kiosk-termin { transition: none; } }

/* ---------- Postfach: Ordner · Liste · Lesebereich ---------- */
.pf { display: grid; grid-template-columns: 220px minmax(280px, 380px) 1fr; height: calc(100dvh - 120px); min-height: 480px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); overflow: hidden; }
.pf-ordner { border-right: 1px solid var(--line); overflow-y: auto; padding: 8px 6px; background: var(--surface-2); }
.pf-ordner-kopf { display: flex; align-items: center; padding: 2px 6px 6px; }
.pf-o { display: flex; align-items: center; gap: 8px; min-height: 36px; padding: 0 6px 0 calc(8px + var(--ebene, 0) * 14px); border-radius: var(--r-sm); cursor: pointer; color: var(--text); }
.pf-o:hover { background: var(--surface-3); } .pf-o.aktiv { background: var(--accent-soft); color: var(--accent-text); font-weight: 600; }
.pf-o.tot { cursor: default; color: var(--text-3); } .pf-o.ziel { outline: 2px dashed var(--accent); outline-offset: -2px; }
.pf-o:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.pf-o-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pf-o-mehr { opacity: 0; } .pf-o:hover .pf-o-mehr, .pf-o:focus-within .pf-o-mehr { opacity: 1; }
.pf-zahl { min-width: 22px; padding: 0 6px; border-radius: 999px; background: var(--accent); color: var(--accent-ink); font-size: .75rem; font-weight: 600; text-align: center; line-height: 20px; }
.pf-liste { display: flex; flex-direction: column; border-right: 1px solid var(--line); min-width: 0; }
.pf-suche { padding: 8px; border-bottom: 1px solid var(--line); }
.pf-items { overflow-y: auto; flex: 1; }
.pf-kopf { display: flex; align-items: center; gap: 4px; padding: 6px 12px; border-bottom: 1px solid var(--line); }
.pf-m { display: flex; flex-direction: column; gap: 2px; width: 100%; padding: 10px 12px; border: 0; border-bottom: 1px solid var(--line); background: none; text-align: left; cursor: pointer; color: var(--text); font: inherit; }
.pf-m:hover { background: var(--surface-2); } .pf-m.aktiv { background: var(--accent-soft); }
.pf-m-zeile { display: flex; align-items: center; gap: 6px; min-width: 0; }
.pf-m-von, .pf-m-betreff { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pf-m-betreff { color: var(--text-2); font-size: .9rem; } .pf-m-datum { color: var(--text-2); font-size: .8rem; flex: none; }
.pf-m.neu .pf-m-von, .pf-m.neu .pf-m-betreff { font-weight: 600; color: var(--text); }
.pf-punkt { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); margin-right: 6px; vertical-align: middle; }
.pf-lesen { display: flex; flex-direction: column; min-width: 0; overflow-y: auto; }
.pf-werkzeug { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; padding: 8px 12px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--surface); z-index: 1; }
.pf-zurueck { display: none; }
.pf-kopfdaten { padding: 14px 16px 8px; display: flex; flex-direction: column; gap: 3px; }
.pf-kopfdaten h2 { font-size: 1.15rem; margin: 0 0 6px; overflow-wrap: anywhere; }
.pf-akte { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.pf-anhaenge { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 16px 8px; }
.pf-inhalt { flex: 1; display: flex; flex-direction: column; min-height: 320px; border-top: 1px solid var(--line); }
.pf-html { flex: 1; width: 100%; min-height: 420px; border: 0; background: #fff; }
.pf-text { white-space: pre-wrap; overflow-wrap: anywhere; font-family: var(--font-read); font-size: .95rem; line-height: 1.55; margin: 0; padding: 16px; }
.pf-schreibtext { min-height: 260px; font-family: var(--font-read); line-height: 1.5; }
.pf-sigvorschau { white-space: pre-wrap; margin: 0; }
@media (max-width: 1200px) { .pf { grid-template-columns: minmax(240px, 300px) 1fr; grid-template-rows: auto 1fr; grid-template-areas: "ordner lesen" "liste lesen"; } .pf-ordner { grid-area: ordner; max-height: 190px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); } .pf-liste { grid-area: liste; min-height: 0; } .pf-lesen { grid-area: lesen; } }
@media (max-width: 820px) {
  .pf { grid-template-columns: 1fr; grid-template-areas: none; grid-template-rows: none; height: auto; min-height: 0; } .pf-ordner, .pf-liste, .pf-lesen { grid-area: auto; }
  .pf-ordner { border-right: 0; border-bottom: 1px solid var(--line); max-height: 180px; }
  .pf[data-mobil="lesen"] .pf-ordner, .pf[data-mobil="lesen"] .pf-liste { display: none; }
  .pf[data-mobil="liste"] .pf-lesen { display: none; }
  .pf-liste { border-right: 0; } .pf-items { max-height: none; } .pf-zurueck { display: inline-flex; }
}

/* Praxis-Logo (hochgeladen): Seitenleiste/Anmeldung und Vorschau in Einstellungen → Design */
.brand-logo { height: 30px; width: auto; max-width: min(132px, 100%); object-fit: contain; border-radius: 6px; flex: none; }
.logo-vorschau { width: 140px; height: 76px; display: flex; align-items: center; justify-content: center; border: 1px dashed var(--line-strong); border-radius: var(--r-sm); background: var(--surface-2); padding: 6px; }
.logo-vorschau img { max-width: 100%; max-height: 100%; object-fit: contain; }

/* ---------- Leiste einklappen (mehr Platz für Kalender und Listen) ---------- */
.nav-sep { height: 1px; background: var(--line); margin: 8px 10px; flex: none; }
.nav { gap: 2px; }
.shell.nav-klein { --sidebar: 72px; }
.shell.nav-klein .sidebar .brand-name, .shell.nav-klein .sidebar .brand-sub, .shell.nav-klein .nav a span, .shell.nav-klein .user-chip .who, .shell.nav-klein .nav .badge { display: none; }
.shell.nav-klein .nav a { justify-content: center; padding: 0; min-height: 44px; } .shell.nav-klein .brand { justify-content: center; }
.shell.nav-klein .side-foot .btn { justify-content: center !important; } .shell.nav-klein .side-foot .btn span { display: none; }
.shell.nav-klein .sidebar [data-palette] { justify-content: center; padding: 0; min-height: 44px; }
.shell.nav-klein .sidebar [data-palette] span, .shell.nav-klein .sidebar [data-palette] kbd { display: none; }
.shell.nav-klein .user-chip { flex-direction: column; gap: 6px; }
@media (max-width: 1180px) { .nav-toggle { display: none !important; } }
@media (max-width: 760px) { .shell.nav-klein { --sidebar: 280px; } .shell.nav-klein .nav a span, .shell.nav-klein .sidebar .brand-name, .shell.nav-klein .sidebar .brand-sub, .shell.nav-klein .user-chip .who { display: revert; } .shell.nav-klein .nav a { justify-content: flex-start; padding: 0 10px; } }

/* ---------- Kalender füllt die ganze Höhe ---------- */
.content:has(> .cal-page) { display: flex; flex-direction: column; padding-bottom: 12px; }
.cal-page { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.cal-page .cal { flex: 1; min-height: 320px; max-height: none; }
.cal-toolbar { margin-bottom: 10px; }
.appt.mini { padding: 1px 6px 1px 9px; line-height: 1.2; }
.appt.mini b { font-size: .74rem; } .appt.mini .meta, .appt.mini .ticons { display: none; }

/* ---------- Kommunikation (Postfach · Postausgang · Vorlagen) ---------- */
.komm-tabs { margin-bottom: 14px; }
.komm .pf { height: calc(100dvh - 176px); }

/* ---------- Verwaltung (Kacheln unter Einstellungen) ---------- */
.verw { display: grid; gap: 22px; max-width: 1100px; }
.verw h2 { font-size: .8rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--text-2); margin: 0 0 8px; }
.verw-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.verw-kachel { display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 10px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); color: var(--text); text-decoration: none; font-weight: 500; transition: box-shadow .15s ease-out, border-color .15s ease-out; }
.verw-kachel:hover { border-color: var(--line-strong); box-shadow: var(--shadow-1); }
.verw-kachel:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.verw-kachel .ic { color: var(--accent-text); flex: none; }
.verw-kachel small { display: block; color: var(--text-2); font-weight: 400; font-size: .8rem; }

/* Ausgeblendetes bleibt ausgeblendet (auch bei .btn mit display:flex) */
[hidden] { display: none !important; }
.topbar .menu-btn { display: none; }
@media (max-width: 760px) { .topbar .menu-btn { display: inline-flex; } }

.komm-tabs button { display: inline-flex; align-items: center; gap: 6px; }
.komm-tabs { width: fit-content; }

/* ---------- Druck: Terminliste (und alles mit #druckbereich) ---------- */
#druckbereich { display: none; }
@media print {
  @page { size: A4; margin: 12mm; }
  body:has(#druckbereich) > *:not(#druckbereich) { display: none !important; }
  body:has(#druckbereich) { background: #fff !important; }
  #druckbereich { display: block; color: #000; font: 10pt/1.35 -apple-system, "Helvetica Neue", Arial, sans-serif; }
  #druckbereich header { display: flex; justify-content: space-between; align-items: baseline; border-bottom: 1.5pt solid #000; padding-bottom: 4pt; margin-bottom: 8pt; }
  #druckbereich header span { font-size: 9pt; color: #444; }
  #druckbereich section { break-inside: avoid-page; margin-bottom: 12pt; }
  #druckbereich h2 { font-size: 11.5pt; margin: 0 0 4pt; }
  #druckbereich table { width: 100%; border-collapse: collapse; }
  #druckbereich th { text-align: left; font-size: 8.5pt; color: #333; border-bottom: 1pt solid #000; padding: 2pt 4pt; }
  #druckbereich td { border-bottom: .5pt solid #bbb; padding: 4pt; vertical-align: top; }
  #druckbereich td:first-child { white-space: nowrap; font-weight: 600; width: 13mm; }
  #druckbereich td:nth-child(2) { width: 9mm; } #druckbereich .haken { width: 7mm; border-left: .5pt solid #bbb; }
  #druckbereich tr { break-inside: avoid; }
}
@media print { #druckbereich table { table-layout: fixed; } #druckbereich th:nth-child(1) { width: 13mm; } #druckbereich th:nth-child(2) { width: 9mm; } #druckbereich th:nth-child(3) { width: 34%; } #druckbereich th:nth-child(4) { width: 26%; } #druckbereich th:nth-child(6) { width: 7mm; } }

/* ---------- Hilfe (Benutzerhandbuch) ---------- */
.hilfe { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 28px; align-items: start; max-width: 1180px; }
.hilfe-toc { position: sticky; top: 8px; display: flex; flex-direction: column; gap: 2px; max-height: calc(100dvh - 120px); overflow-y: auto; }
.hilfe-toc a { padding: 6px 10px; border-radius: var(--r-sm); color: var(--text); text-decoration: none; font-size: .9rem; }
.hilfe-toc a:hover { background: var(--surface-3); }
.hilfe-text { max-width: 820px; line-height: 1.6; }
.hilfe-text h2 { font-size: 1.5rem; margin: 0 0 8px; } .hilfe-text h3 { font-size: 1.2rem; margin: 28px 0 8px; scroll-margin-top: 12px; } .hilfe-text h4 { font-size: 1rem; margin: 20px 0 6px; }
.hilfe-text p, .hilfe-text ul, .hilfe-text ol { margin: 0 0 10px; } .hilfe-text li { margin-bottom: 4px; }
.hilfe-text .table-wrap { margin: 6px 0 14px; }
@media (max-width: 900px) { .hilfe { grid-template-columns: 1fr; } .hilfe-toc { position: static; max-height: none; } }

/* ---------- Hinweis vor automatischer Abmeldung ---------- */
.abmelde-hinweis { position: fixed; z-index: 90; left: 50%; top: max(16px, env(safe-area-inset-top)); transform: translateX(-50%); display: flex; align-items: center; gap: 12px; padding: 10px 12px 10px 16px;
  background: var(--surface); color: var(--text); border: 1px solid var(--line-strong); border-radius: var(--r-lg); box-shadow: var(--shadow-2); max-width: calc(100vw - 32px); }
.abmelde-hinweis .ic { color: var(--warn); flex: none; }
.user-chip [data-dunkel] .ic { color: var(--text-2); }
.shell.nav-klein .user-chip [data-dunkel] { order: -1; }

/* Auswahlknöpfe mit Symbol: Symbol neben dem Text */
.seg button:has(.ic) { display: inline-flex; align-items: center; gap: 6px; }
.seg:has(button .ic) { width: fit-content; max-width: 100%; }
