:root {
    --df-accent: #1f3a60;
    --df-accent-soft: #e8eef7;
    --df-bg: #f4f6f9;
    --df-card: #ffffff;
    --df-line: #dde3ec;
    --df-text: #1c2430;
    --df-muted: #6a7280;
    --df-check: #eaf3ec;
    --df-check-line: #9ccaa6;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    background: var(--df-bg);
    color: var(--df-text);
    font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
    font-size: 14px;
}

/* ── Rahmen ───────────────────────────────────────── */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
    width: 232px;
    flex-shrink: 0;
    background: var(--df-accent);
    color: #dfe7f3;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}

.brand { display: flex; gap: 12px; align-items: center; padding: 22px 20px 26px; }
.brand-mark {
    width: 40px; height: 40px; border-radius: 10px;
    background: #fff; color: var(--df-accent);
    display: grid; place-items: center; font-weight: 800; letter-spacing: .5px;
}
.brand strong { display: block; color: #fff; font-size: 16px; }
.brand small { color: #a9b8cf; font-size: 12px; }

.nav { display: flex; flex-direction: column; gap: 2px; padding: 0 10px; }
.nav a {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 12px; border-radius: 8px;
    color: #dfe7f3; text-decoration: none;
}
.nav a:hover { background: rgba(255,255,255,.08); }
.nav a.active { background: rgba(255,255,255,.16); color: #fff; font-weight: 600; }
.nav .e-icons { font-size: 15px; }

.sidebar-foot { margin-top: auto; padding: 16px 20px; font-size: 11px; color: #8fa1bd; }

.content { flex: 1; padding: 24px 32px 48px; min-width: 0; }

/* ── Seitenkopf ───────────────────────────────────── */
.page-head {
    display: flex; justify-content: space-between; align-items: flex-end; gap: 16px;
    margin-bottom: 18px; flex-wrap: wrap;
}
.page-head.sticky {
    position: sticky; top: 0; z-index: 20;
    background: var(--df-bg); padding: 14px 0 12px; margin-top: -14px;
    border-bottom: 1px solid var(--df-line);
}
.page-head h1 { margin: 0; font-size: 24px; color: var(--df-accent); }
.lead { margin: 4px 0 0; color: var(--df-muted); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.actions a.e-btn { text-decoration: none; }

/* ── Karten ───────────────────────────────────────── */
.card {
    background: var(--df-card);
    border: 1px solid var(--df-line);
    border-radius: 10px;
    padding: 18px 20px;
    margin-bottom: 16px;
}
.loading, .empty, .muted { color: var(--df-muted); padding: 24px; }

.badge {
    display: inline-block; min-width: 22px; padding: 1px 8px;
    border-radius: 999px; background: var(--df-accent); color: #fff;
    font-size: 12px; font-weight: 600; text-align: center;
}
.badge.soft { background: var(--df-accent-soft); color: var(--df-accent); font-weight: 500; vertical-align: middle; }

/* ── Kopfdaten ────────────────────────────────────── */
.patient-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(160px, 1fr));
    gap: 14px 18px;
}
.field label, .field-label {
    display: block; font-size: 12px; font-weight: 600;
    color: var(--df-muted); margin-bottom: 4px;
}
.span-2 { grid-column: span 2; }

/* ── Formular ─────────────────────────────────────── */
.section-head {
    display: flex; align-items: baseline; gap: 12px;
    padding-bottom: 10px; margin-bottom: 8px;
    border-bottom: 2px solid var(--df-accent);
}
.section-head h2 { margin: 0; font-size: 17px; color: var(--df-accent); }
.section-sub { color: var(--df-muted); font-size: 13px; }
.section-head .badge { margin-left: auto; }

.section-note {
    margin: 6px 0 10px; padding: 8px 12px; border-radius: 6px;
    background: #fff7e6; color: #8a5a00; font-size: 13px;
}

.group-label {
    margin: 12px 0 2px; font-weight: 700; font-size: 13px; color: var(--df-accent);
}

.form-row {
    display: grid;
    grid-template-columns: 56px 230px 1fr;
    gap: 10px;
    align-items: start;
    padding: 8px 6px;
    border-bottom: 1px dashed var(--df-line);
    border-radius: 6px;
}
.form-row:last-child { border-bottom: none; }
.form-row.in-group .row-label { padding-left: 14px; }
.form-row.active { background: #fafcfe; }

.row-code { color: var(--df-muted); font-variant-numeric: tabular-nums; padding-top: 4px; font-size: 12px; }
.row-label { padding-top: 3px; }
.row-title { font-weight: 600; }
.row-check .e-label { font-weight: 600; }
.row-hint { display: block; color: var(--df-muted); font-size: 12px; margin-top: 2px; }

.row-options { display: flex; flex-wrap: wrap; gap: 6px 8px; }

.opt {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 3px 10px 3px 8px;
    border: 1px solid var(--df-line); border-radius: 18px;
    background: #fff; min-height: 32px;
    transition: background .12s, border-color .12s;
}
.opt.checked { background: var(--df-check); border-color: var(--df-check-line); }
.opt .opt-input { margin: 0; }
.opt .unit { color: var(--df-muted); font-size: 12px; }

.bottom-actions { display: flex; justify-content: flex-end; gap: 8px; }

/* ── Vorschau ─────────────────────────────────────── */
.viewer { height: calc(100vh - 150px); padding: 0; overflow: hidden; }

/* ── Textbausteine ────────────────────────────────── */
.tb-layout { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(340px, 1fr); gap: 16px; align-items: start; }
.tb-list { padding: 0; overflow: hidden; }
.tb-editor { position: sticky; top: 16px; }
.tb-editor h2 { margin: 4px 0 14px; font-size: 18px; color: var(--df-accent); }
.tb-meta { color: var(--df-muted); font-size: 12px; }
.tb-default { margin: 14px 0; padding: 10px 12px; background: var(--df-bg); border-radius: 6px; }
.tb-default div { color: var(--df-muted); }
.help { margin-top: 8px; font-size: 12px; color: var(--df-muted); line-height: 1.6; }
.help code { background: var(--df-accent-soft); color: var(--df-accent); padding: 0 4px; border-radius: 3px; }
.text-changed { color: var(--df-text); font-weight: 500; }
.text-default { color: var(--df-muted); }

.grid-actions { display: flex; justify-content: flex-end; gap: 2px; }

@media (max-width: 1100px) {
    .patient-grid { grid-template-columns: repeat(2, 1fr); }
    .form-row { grid-template-columns: 44px 1fr; }
    .form-row .row-options { grid-column: 1 / -1; }
    .tb-layout { grid-template-columns: 1fr; }
}
