/* ============================================================
   Vereinsverwaltung – Gestaltung
   Drei Designs zum Thema Umwelt & Naturschutz:
     hell   „Birkenhain“   – Leinen, Birkenrinde, Waldgrün
     mittel „Salbeiwiese“  – Salbei, Moos, Lehm
     dunkel „Waldnacht“    – Tannengrün, Moosglanz, Bernstein
   Alle Farben laufen über CSS-Variablen.
   ============================================================ */

:root,
[data-design="hell"] {
    --chart-ein:     #2f7d45; /* Diagrammfarben, geprüft auf Farbsehschwäche */
    --chart-aus:     #b9852a;
    --bg:            #f3efe4;
    --bg-pattern:    #ebe5d4;
    --surface:       #fffdf7;
    --surface-2:     #f7f3e8;
    --sidebar:       #1f3a26;
    --sidebar-text:  #e6efdc;
    --sidebar-muted: #9cb497;
    --sidebar-hover: rgba(230, 239, 220, .08);
    --sidebar-active:#2f5a39;
    --text:          #22301f;
    --muted:         #66735f;
    --border:        #e0d8c4;
    --border-strong: #c9bea4;
    --accent:        #2f6b3a;
    --accent-hover:  #255830;
    --accent-text:   #ffffff;
    --accent-soft:   #e3eed9;
    --earth:         #a8672a;
    --earth-soft:    #f6e6d1;
    --danger:        #a63d2f;
    --danger-soft:   #f8e1dc;
    --focus:         rgba(47, 107, 58, .35);
    --shadow:        0 1px 2px rgba(45, 52, 30, .06), 0 4px 16px rgba(45, 52, 30, .06);
    --badge-aktiv-bg:#dcecd2; --badge-aktiv-fg:#25562e;
    --badge-passiv-bg:#f3e5c8; --badge-passiv-fg:#7a5216;
    --badge-aus-bg:  #e7e2d8; --badge-aus-fg:  #5f5a50;
    color-scheme: light;
}

[data-design="mittel"] {
    --chart-ein:     #2a6f3d; /* Diagrammfarben, geprüft auf Farbsehschwäche */
    --chart-aus:     #a8771f;
    --bg:            #a8b79c;
    --bg-pattern:    #9fae92;
    --surface:       #e4eadb;
    --surface-2:     #d7dfcc;
    --sidebar:       #3c5a3c;
    --sidebar-text:  #eef3e6;
    --sidebar-muted: #b7c8ac;
    --sidebar-hover: rgba(238, 243, 230, .10);
    --sidebar-active:#2d4a2e;
    --text:          #1c291b;
    --muted:         #4b5c45;
    --border:        #c2ceb4;
    --border-strong: #9fb08f;
    --accent:        #2c5c34;
    --accent-hover:  #224a29;
    --accent-text:   #f3f7ec;
    --accent-soft:   #cfdcc0;
    --earth:         #8c5524;
    --earth-soft:    #e9d6bd;
    --danger:        #8f2f23;
    --danger-soft:   #ecd0c8;
    --focus:         rgba(44, 92, 52, .40);
    --shadow:        0 1px 2px rgba(30, 45, 25, .10), 0 6px 18px rgba(30, 45, 25, .12);
    --badge-aktiv-bg:#c4d8b4; --badge-aktiv-fg:#1f4a26;
    --badge-passiv-bg:#e8d6b0; --badge-passiv-fg:#6a4512;
    --badge-aus-bg:  #d0d0c4; --badge-aus-fg:  #4c4b42;
    color-scheme: light;
}

[data-design="dunkel"] {
    --chart-ein:     #34864a; /* Diagrammfarben, geprüft auf Farbsehschwäche */
    --chart-aus:     #bb8a33;
    --bg:            #111915;
    --bg-pattern:    #141e18;
    --surface:       #19241d;
    --surface-2:     #1f2c23;
    --sidebar:       #0c130f;
    --sidebar-text:  #dfe9d6;
    --sidebar-muted: #7f9479;
    --sidebar-hover: rgba(223, 233, 214, .06);
    --sidebar-active:#1d3022;
    --text:          #e1eadb;
    --muted:         #93a68c;
    --border:        #2a3a2e;
    --border-strong: #3a4f3f;
    --accent:        #86c48f;
    --accent-hover:  #9dd3a5;
    --accent-text:   #0f1a12;
    --accent-soft:   #22382a;
    --earth:         #e0aa5c;
    --earth-soft:    #3a2e1c;
    --danger:        #e98a7a;
    --danger-soft:   #3b211d;
    --focus:         rgba(134, 196, 143, .35);
    --shadow:        0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
    --badge-aktiv-bg:#21402a; --badge-aktiv-fg:#9fdaa8;
    --badge-passiv-bg:#3d3220; --badge-passiv-fg:#e6c27f;
    --badge-aus-bg:  #2a2f2b; --badge-aus-fg:  #a3aca2;
    color-scheme: dark;
}

/* ---------- Grundlagen ---------- */

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font: 15px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: var(--text);
    background-color: var(--bg);
    /* dezentes Blattadern-Muster */
    background-image:
        radial-gradient(circle at 20% 0%, var(--bg-pattern) 0, transparent 40%),
        radial-gradient(circle at 100% 100%, var(--bg-pattern) 0, transparent 35%);
    background-attachment: fixed;
    transition: background-color .25s, color .25s;
}

h1, h2, h3 {
    font-family: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
    font-weight: 600;
    letter-spacing: -.01em;
    line-height: 1.2;
    margin: 0;
}
h1 { font-size: 1.85rem; }
h2 { font-size: 1.15rem; }

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--accent-hover); }

.muted { color: var(--muted); }
.mono { font-family: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace; font-size: .92em; letter-spacing: .01em; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
code { font-family: ui-monospace, Menlo, Consolas, monospace; background: var(--surface-2); padding: .1em .35em; border-radius: 4px; }

.icon { flex: none; vertical-align: -3px; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

/* ---------- Grundgerüst ---------- */

.shell { display: flex; min-height: 100vh; }

.sidebar {
    width: 252px;
    flex: none;
    background: var(--sidebar);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    padding: 20px 14px;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.brand {
    display: flex; align-items: center; gap: 12px;
    color: inherit; text-decoration: none;
    padding: 4px 8px 22px;
    border-bottom: 1px solid var(--sidebar-hover);
    margin-bottom: 18px;
}
.brand:hover { color: inherit; }
.brand-mark {
    display: grid; place-items: center;
    width: 40px; height: 40px; border-radius: 12px;
    background: var(--accent); color: var(--accent-text);
    flex: none;
}
.sidebar .brand-mark { background: var(--sidebar-active); color: #a7d9a3; box-shadow: inset 0 0 0 1px var(--sidebar-hover); }
/* Hochgeladenes Vereinslogo: helle Kachel, damit auch dunkle Logos auf der Seitenleiste gut sichtbar sind */
.brand-logo {
    display: grid; place-items: center; flex: none;
    height: 44px; min-width: 44px; max-width: 76px;
    padding: 4px;
    border-radius: 12px;
    background: #fbf9f2;
    box-shadow: 0 1px 2px rgba(0,0,0,.15);
}
.brand-logo img { display: block; max-height: 36px; max-width: 68px; width: auto; height: auto; object-fit: contain; }
.auth-brand .brand-logo { height: 52px; min-width: 52px; max-width: 110px; box-shadow: 0 0 0 1px var(--border); }
.auth-brand .brand-logo img { max-height: 44px; max-width: 102px; }
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-text strong { font-family: "Iowan Old Style", Palatino, Georgia, serif; font-size: 1.08rem; font-weight: 600; line-height: 1.2; hyphens: auto; -webkit-hyphens: auto; overflow-wrap: break-word; }
.brand:has(.brand-logo) .brand-text strong { font-size: 1rem; }
.brand-text small { color: var(--sidebar-muted); font-size: .78rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav .nav-label:not(:first-child) { margin-top: 18px; }
.nav-label {
    display: block;
    font-size: .7rem; text-transform: uppercase; letter-spacing: .1em;
    color: var(--sidebar-muted);
    padding: 0 10px 8px;
}
.nav-link {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 10px; border-radius: 9px;
    color: var(--sidebar-text); text-decoration: none;
    opacity: .85;
}
.nav-link:hover { background: var(--sidebar-hover); color: var(--sidebar-text); opacity: 1; }
.nav-link.is-active { background: var(--sidebar-active); opacity: 1; font-weight: 600; }

.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 18px; padding-top: 20px; }

.swatches { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.swatch {
    display: flex; flex-direction: column; align-items: center; gap: 6px;
    padding: 9px 4px 7px;
    border: 1px solid var(--sidebar-hover); border-radius: 10px;
    background: transparent; color: var(--sidebar-muted);
    font: inherit; font-size: .72rem; cursor: pointer;
}
.swatch:hover { background: var(--sidebar-hover); color: var(--sidebar-text); }
.swatch.is-active { border-color: #a7d9a3; color: var(--sidebar-text); background: var(--sidebar-hover); }
.swatch-dot {
    width: 26px; height: 26px; border-radius: 50%;
    box-shadow: 0 0 0 2px rgba(255,255,255,.12);
}
.swatch-hell   .swatch-dot { background: linear-gradient(135deg, #f3efe4 50%, #2f6b3a 50%); }
.swatch-mittel .swatch-dot { background: linear-gradient(135deg, #a8b79c 50%, #3c5a3c 50%); }
.swatch-dunkel .swatch-dot { background: linear-gradient(135deg, #19241d 50%, #86c48f 50%); }

.user-box {
    display: flex; align-items: center; gap: 10px;
    padding: 10px; border-radius: 12px;
    background: var(--sidebar-hover);
}
.user-link { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; border-radius: 8px; }
.user-link:hover { color: inherit; }
.user-link:hover .user-name { text-decoration: underline; text-underline-offset: 2px; }
.user-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.user-name { font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: .72rem; color: var(--sidebar-muted); }
.user-box.is-active { box-shadow: inset 0 0 0 1px #a7d9a3; }
.user-box form { margin: 0; }
.user-box .icon-btn { color: var(--sidebar-muted); }
.user-box .icon-btn:hover { color: var(--sidebar-text); background: var(--sidebar-hover); }

.avatar {
    display: grid; place-items: center; flex: none;
    width: 32px; height: 32px; border-radius: 50%;
    background: var(--earth-soft); color: var(--earth);
    font-weight: 700; font-size: .85rem;
}
.sidebar .avatar { background: #c99a5b; color: #2a1d0c; }
.avatar-lg { width: 56px; height: 56px; font-size: 1.15rem; font-family: "Iowan Old Style", Palatino, Georgia, serif; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: none; }
.content { padding: 32px clamp(16px, 4vw, 48px) 56px; max-width: 1280px; width: 100%; }

/* ---------- Seitenkopf ---------- */

.page-head {
    display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap;
    margin-bottom: 24px;
}
.page-head p { margin: 4px 0 0; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.back {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: .88rem; text-decoration: none; color: var(--muted);
    margin-bottom: 10px;
}
.back:hover { color: var(--accent); }
.title-row { display: flex; align-items: center; gap: 16px; }

/* ---------- Schaltflächen ---------- */

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 9px 16px; min-height: 40px;
    border: 1px solid var(--border-strong); border-radius: 10px;
    background: var(--surface); color: var(--text);
    font: inherit; font-weight: 550; text-decoration: none; cursor: pointer;
    transition: background-color .15s, border-color .15s, color .15s;
}
.btn:hover { background: var(--surface-2); color: var(--text); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--accent-text); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger-ghost { background: transparent; border-color: transparent; color: var(--danger); }
.btn-danger-ghost:hover { background: var(--danger-soft); color: var(--danger); }
.btn-block { width: 100%; }

.icon-btn {
    display: inline-grid; place-items: center;
    width: 34px; height: 34px; border-radius: 8px;
    border: 0; background: transparent; color: var(--muted); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); color: var(--accent); }

/* ---------- Karten & Kennzahlen ---------- */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: var(--shadow);
}

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat {
    display: flex; flex-direction: column; gap: 2px;
    padding: 14px 18px;
    background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
    text-decoration: none; color: var(--text);
    position: relative; overflow: hidden;
}
.stat::before {
    content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
    background: var(--border-strong);
}
.stat-aktiv::before { background: var(--accent); }
.stat-passiv::before { background: var(--earth); }
.stat:hover { border-color: var(--border-strong); color: var(--text); }
.stat.is-active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.stat-num { font-family: "Iowan Old Style", Palatino, Georgia, serif; font-size: 1.7rem; font-weight: 600; line-height: 1.1; }
.stat-label { color: var(--muted); font-size: .85rem; }

/* ---------- Suche & Filter ---------- */

.toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.search {
    flex: 1 1 280px;
    display: flex; align-items: center; gap: 8px;
    padding: 0 12px;
    background: var(--surface); border: 1px solid var(--border-strong); border-radius: 10px;
    color: var(--muted);
}
.search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus); }
.search input { border: 0; background: transparent; outline: none; box-shadow: none; padding: 9px 0; min-height: 40px; flex: 1; }
.search input:focus { box-shadow: none; }

/* ---------- Formularelemente ---------- */

input, select, textarea {
    font: inherit; color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: 9px;
    padding: 8px 11px; min-height: 40px;
    width: 100%;
    transition: border-color .15s, box-shadow .15s;
}
select { width: auto; padding-right: 30px; }
.field select, .grid select { width: 100%; }
textarea { resize: vertical; min-height: 100px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus); }
input[aria-invalid="true"], select[aria-invalid="true"] { border-color: var(--danger); background: var(--danger-soft); }
::placeholder { color: var(--muted); opacity: .7; }
input[type="date"] { min-width: 0; }

.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > span:first-child { font-size: .84rem; font-weight: 600; color: var(--muted); }
.field small { font-weight: 400; }
.field-error { color: var(--danger); font-size: .82rem; }

.form { display: flex; flex-direction: column; gap: 16px; }
.section { padding: 20px 22px 22px; margin: 0; min-width: 0; }
fieldset.section { border: 1px solid var(--border); }
.section legend, .section > h2 {
    font-family: "Iowan Old Style", Palatino, Georgia, serif;
    font-size: 1.08rem; font-weight: 600;
    padding: 0; margin-bottom: 14px; float: left; width: 100%;
    display: flex; align-items: center; gap: 10px;
}
.section legend::before, .section > h2::before {
    content: ""; width: 8px; height: 8px; border-radius: 2px 8px;
    background: var(--accent); transform: rotate(-20deg);
}
.section legend + * { clear: both; }

.grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 14px 16px; }
.span-1 { grid-column: span 1; } .span-2 { grid-column: span 2; } .span-3 { grid-column: span 3; }
.span-6 { grid-column: span 6; }

.checks { display: grid; gap: 12px; }
.check {
    display: flex; align-items: flex-start; gap: 12px;
    padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px;
    background: var(--surface-2); cursor: pointer;
}
.check:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.check input { width: 18px; height: 18px; min-height: 0; margin: 2px 0 0; accent-color: var(--accent); flex: none; }
.check strong { display: block; font-weight: 600; }
.check small { display: block; color: var(--muted); }
.check-date { max-width: 240px; margin-left: 44px; }

.form-actions {
    display: flex; justify-content: flex-end; gap: 10px;
    position: sticky; bottom: 0;
    padding: 14px 0;
    background: linear-gradient(to top, var(--bg) 70%, transparent);
}

/* ---------- Tabelle ---------- */

.table-card { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 11px 14px; text-align: left; vertical-align: middle; }
.table thead th {
    font-size: .76rem; text-transform: uppercase; letter-spacing: .06em;
    color: var(--muted); font-weight: 600;
    border-bottom: 1px solid var(--border);
    background: var(--surface-2);
    white-space: nowrap;
}
.table thead th:first-child { border-top-left-radius: 14px; }
.table thead th:last-child { border-top-right-radius: 14px; }
.table tbody tr + tr td { border-top: 1px solid var(--border); }
.table tbody tr:hover td { background: var(--surface-2); }
.table .sort { color: inherit; text-decoration: none; }
.table .sort:hover, .table .sort.is-active { color: var(--accent); }
.col-nr { width: 70px; color: var(--muted); }
.col-nummer { width: 110px; }
.list-count { margin: 10px 4px 0; font-size: .85rem; }
.col-actions { width: 50px; text-align: right; }
.row-link { color: var(--text); font-weight: 600; text-decoration: none; }
.row-link:hover { color: var(--accent); text-decoration: underline; }
.sub { display: block; color: var(--muted); font-size: .84rem; }
.sub-link { display: block; font-size: .88rem; text-decoration: none; }

.badge {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 3px 10px; border-radius: 999px;
    font-size: .78rem; font-weight: 600; white-space: nowrap;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-aktiv       { background: var(--badge-aktiv-bg);  color: var(--badge-aktiv-fg); }
.badge-passiv      { background: var(--badge-passiv-bg); color: var(--badge-passiv-fg); }
.badge-ausgetreten { background: var(--badge-aus-bg);    color: var(--badge-aus-fg); }

.pager { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding: 14px 4px; font-size: .9rem; }
.pager-links { display: flex; gap: 4px; flex-wrap: wrap; }
.pager-links a {
    min-width: 34px; height: 34px; padding: 0 8px;
    display: inline-grid; place-items: center;
    border-radius: 8px; text-decoration: none; color: var(--text);
    border: 1px solid var(--border);
    background: var(--surface);
}
.pager-links a:hover { border-color: var(--accent); }
.pager-links a.is-active { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }

/* ---------- Detailansicht ---------- */

.detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.span-all { grid-column: 1 / -1; }
.dl { margin: 0; clear: both; }
.dl-row { display: grid; grid-template-columns: 150px 1fr; gap: 12px; padding: 8px 0; border-top: 1px dashed var(--border); }
.dl-row:first-child { border-top: 0; }
.dl dt { color: var(--muted); font-size: .9rem; }
.dl dd { margin: 0; word-break: break-word; }
.consents { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; clear: both; }
.consents li { display: flex; align-items: center; gap: 10px; }
.consents li .icon { width: 26px; height: 26px; padding: 5px; border-radius: 50%; }
.consents .yes .icon { background: var(--badge-aktiv-bg); color: var(--badge-aktiv-fg); }
.consents .no .icon { background: var(--surface-2); color: var(--muted); }
.notes { margin: 0; clear: both; white-space: normal; }
.meta-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 20px; font-size: .88rem; }
.meta-row form { margin: 0; }

/* ---------- Einstellungen ---------- */

.settings-card { max-width: 900px; }
.settings-card > h2 + * { clear: both; }
.small { font-size: .84rem; }
.field-label { display: block; font-size: .84rem; font-weight: 600; color: var(--muted); margin-bottom: 8px; }
.logo-setting { display: grid; grid-template-columns: minmax(0, 300px) minmax(0, 1fr); gap: 28px; align-items: start; }
.logo-preview {
    display: flex; align-items: center; gap: 12px;
    padding: 18px 16px; border-radius: 14px;
    background: var(--sidebar); color: var(--sidebar-text);
}
.logo-preview .brand-mark { background: var(--sidebar-active); color: #a7d9a3; }
.logo-preview .brand-text small { color: var(--sidebar-muted); }
.logo-preview-wrap p { margin: 10px 0 0; }
.logo-actions { display: flex; flex-direction: column; gap: 12px; }
.logo-actions form { margin: 0; }
.logo-actions .btn-danger-ghost { align-self: flex-start; padding-left: 0; padding-right: 0; }
.logo-actions .btn-danger-ghost:hover { background: transparent; text-decoration: underline; }

.dropzone {
    position: relative;
    display: flex; align-items: center; gap: 14px;
    padding: 18px;
    border: 2px dashed var(--border-strong); border-radius: 12px;
    background: var(--surface-2);
    cursor: pointer;
    transition: border-color .15s, background-color .15s;
}
.dropzone:hover, .dropzone.is-dragover, .dropzone:focus-within { border-color: var(--accent); background: var(--accent-soft); }
.dropzone input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }
.dropzone-icon {
    display: grid; place-items: center; flex: none;
    width: 48px; height: 48px; border-radius: 12px;
    background: var(--surface); color: var(--accent);
}
.dropzone-text strong { display: block; word-break: break-all; }
.dropzone-text small { display: block; color: var(--muted); font-size: .82rem; }
.form-row-end { display: flex; justify-content: flex-end; }

/* Reiter */
.tabs {
    display: flex; gap: 4px; flex-wrap: wrap;
    border-bottom: 1px solid var(--border-strong);
    margin-bottom: 20px;
}
.tab {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 10px 14px;
    margin-bottom: -1px;
    border: 1px solid transparent; border-bottom: 0;
    border-radius: 10px 10px 0 0;
    color: var(--muted); text-decoration: none; font-weight: 550;
}
.tab:hover { color: var(--text); background: var(--surface-2); }
.tab.is-active {
    color: var(--accent);
    background: var(--surface);
    border-color: var(--border-strong);
    box-shadow: inset 0 3px 0 var(--accent);
}

.settings-form { max-width: 960px; }
.settings-form .form-actions { background: linear-gradient(to top, var(--bg) 70%, transparent); }
.span-4 { grid-column: span 4; }
.hint { color: var(--muted); font-size: .8rem; font-weight: 400; }
.hint .icon { vertical-align: -2px; }
.hint-box { margin: 0; align-self: end; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); }
.section-intro { margin: -4px 0 16px; clear: both; font-size: .86rem; }
.section-actions { display: flex; justify-content: flex-end; margin-top: 16px; padding-top: 14px; border-top: 1px dashed var(--border); }
.field > label:first-child { font-size: .84rem; font-weight: 600; color: var(--muted); }
.field-wrap { min-width: 0; }

.inline-check { display: flex; align-items: flex-start; gap: 8px; font-size: .88rem; cursor: pointer; }
.inline-check input { width: 16px; height: 16px; min-height: 0; margin: 2px 0 0; padding: 0; accent-color: var(--accent); flex: none; }
.inline-check label { cursor: pointer; }
.field .inline-check { margin-top: 2px; font-size: .82rem; color: var(--muted); }

.testmail { max-width: 960px; margin-top: 8px; }
.testmail > h2 + * { clear: both; }
.testmail-form { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.testmail-form .field { flex: 1 1 260px; }
.testmail p { margin: 10px 0 0; }
.test-result { max-width: 960px; }

/* ---------- Benutzer ---------- */

.person { display: flex; align-items: center; gap: 12px; }
.tag {
    display: inline-block; margin-left: 6px; padding: 1px 7px; border-radius: 6px;
    font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
    background: var(--accent-soft); color: var(--accent); vertical-align: 1px;
}
.table tr.is-inactive td { opacity: .6; }
.inline-form { display: inline; margin: 0 0 0 6px; }
.link-btn {
    border: 0; background: none; padding: 0; font: inherit; font-size: .82rem;
    color: var(--accent); cursor: pointer; text-decoration: underline; text-underline-offset: 2px;
}
.badge-rolle-admin      { background: var(--earth-soft);  color: var(--earth); }
.badge-rolle-bearbeiter { background: var(--accent-soft); color: var(--accent); }
.badge-rolle-leser      { background: var(--surface-2);   color: var(--muted); box-shadow: inset 0 0 0 1px var(--border); }
.badge-gesperrt         { background: var(--danger-soft); color: var(--danger); }

.roles { margin-top: 28px; }
.roles h2 { margin-bottom: 12px; }
.roles-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.role-card { padding: 14px 16px; border: 1px dashed var(--border-strong); border-radius: 12px; }
.role-card p { margin: 8px 0 0; color: var(--muted); font-size: .88rem; }

.role-choice { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; clear: both; }
.role-option {
    display: flex; gap: 10px; align-items: flex-start;
    padding: 12px 14px; border: 1px solid var(--border); border-radius: 12px;
    background: var(--surface-2); cursor: pointer;
}
.role-option:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 1px var(--accent); }
.role-option input { width: 16px; height: 16px; min-height: 0; margin: 3px 0 0; accent-color: var(--accent); flex: none; }
.role-option strong { display: block; }
.role-option small { display: block; color: var(--muted); font-size: .8rem; line-height: 1.4; margin-top: 2px; }
.role-option.is-disabled, .inline-check.is-disabled { opacity: .6; cursor: not-allowed; }
.status-check { margin-top: 16px; }

.pw-wrap { position: relative; display: block; }
.pw-wrap input { padding-right: 42px; }
.pw-toggle {
    position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
    width: 34px; height: 32px; border: 0; border-radius: 7px; background: transparent;
    color: var(--muted); cursor: pointer; display: grid; place-items: center;
}
.pw-toggle:hover, .pw-toggle.is-on { color: var(--accent); background: var(--surface-2); }
.pw-actions { display: flex; gap: 10px; align-items: center; }
.btn-small { min-height: 32px; padding: 5px 12px; font-size: .86rem; }

/* Mein Konto */
.profile-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; max-width: 960px; align-items: start; }
.profile-grid .stack { clear: both; }
.profile-grid .hint { margin: 0; }
.card.is-highlight { border-color: var(--accent); box-shadow: 0 0 0 2px var(--focus), var(--shadow); }
.notice-strong { max-width: 960px; }
.dl.compact .dl-row { grid-template-columns: 120px 1fr; padding: 6px 0; font-size: .9rem; }

/* ---------- Meldungen & Leerzustände ---------- */

.flash {
    display: flex; align-items: center; gap: 10px;
    padding: 11px 14px; border-radius: 10px; margin-bottom: 16px;
    border: 1px solid transparent;
}
.flash-ok    { background: var(--accent-soft); color: var(--text); border-color: var(--accent); }
.flash-ok .icon { color: var(--accent); }
.flash-error { background: var(--danger-soft); color: var(--text); border-color: var(--danger); }
.flash-error .icon { color: var(--danger); }

.empty { text-align: center; padding: 56px 20px; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.empty p { margin: 0 0 8px; }
.empty-icon {
    display: grid; place-items: center;
    width: 76px; height: 76px; border-radius: 50%;
    background: var(--accent-soft); color: var(--accent); margin-bottom: 6px;
}

/* ---------- Anmeldung ---------- */

.auth-body { display: grid; place-items: center; min-height: 100vh; padding: 20px; }
.auth-wrap { width: 100%; max-width: 400px; }
.auth-card {
    background: var(--surface); border: 1px solid var(--border); border-radius: 18px;
    box-shadow: var(--shadow); padding: 30px 28px;
}
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 26px; }
.auth-brand strong { display: block; font-family: "Iowan Old Style", Palatino, Georgia, serif; font-size: 1.15rem; }
.auth-brand small { color: var(--muted); }
.auth-title { font-size: 1.45rem; margin-bottom: 14px; }
.stack { display: flex; flex-direction: column; gap: 14px; }

/* ---------- Responsiv ---------- */

/* ---------- Buchungsarten ---------- */
.badge-art-einnahmen { background: var(--badge-aktiv-bg); color: var(--badge-aktiv-fg); }
.badge-art-ausgaben  { background: var(--danger-soft); color: var(--danger); }
.col-flag, .table th.col-flag { width: 110px; text-align: center; color: var(--accent); }
.table th.col-flag { color: inherit; }
.col-flag .icon { vertical-align: -3px; }

/* ---------- Buchungen ---------- */
.flash-info { background: var(--surface-2); color: var(--text); border-color: var(--border-strong); }
.flash-info .icon { color: var(--accent); }
.flash-info a { color: var(--accent); font-weight: 600; }
.stats-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stats-3 .stat-num { font-size: 1.35rem; }
.section-title { font-size: 1.05rem; margin: 6px 0 10px; }
.betrag { white-space: nowrap; font-variant-numeric: tabular-nums; font-weight: 600; }
.betrag-plus { color: var(--badge-aktiv-fg); }
.betrag-minus { color: var(--danger); }
.col-betrag, .table th.col-betrag { text-align: right; white-space: nowrap; width: 130px; }
.table-buchungen .col-datum { width: 105px; }
.table-buchungen .col-text { max-width: 420px; }
.table-buchungen .col-text .sub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.table-buchungen .col-text .field-error { display: block; }
.table-buchungen .tag { margin-left: 4px; }
.toolbar-buchungen .search { flex: 1 1 220px; }
.date-filter { display: flex; align-items: center; gap: 6px; font-size: .85rem; color: var(--muted); }
.date-filter input { width: auto; }
.switch-list-spaced { margin-top: 12px; border-top: 1px solid var(--border); }
.field-check { justify-content: flex-end; padding-bottom: 10px; }
.input-betrag { text-align: right; }
.import-hilfe h2, .import-fehler h2 { font-size: 1rem; margin: 0 0 8px; display: flex; align-items: center; gap: 6px; }
.import-hilfe ul, .import-fehler ul { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; font-size: .9rem; }
.import-fehler { margin-top: 16px; }
.pager-gap { padding: 6px 4px; color: var(--muted); }
.col-gepr, .table th.col-gepr { width: 80px; text-align: center; }
.col-gepr .inline-form { margin: 0; }
.only-sm { display: none; }
/* kleiner iOS-Schalter in der Liste (Klick schaltet „Geprüft“ um) */
.mini-switch {
    position: relative; width: 38px; height: 23px; padding: 0; border: 0; border-radius: 999px; cursor: pointer;
    background: var(--border-strong); transition: background-color .2s ease; vertical-align: middle;
}
.mini-switch .switch-thumb { top: 2px; left: 2px; width: 19px; height: 19px; }
.mini-switch.is-on { background: var(--accent); }
.mini-switch.is-on .switch-thumb { transform: translateX(15px); }
.mini-switch:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Sollbuchungen ---------- */
.radio-row { display: flex; flex-direction: column; gap: 8px; margin-top: 2px; }
.laeufe { margin-top: 28px; }
.zahlungen { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; font-size: .92rem; }
.zahlungen li { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.zahlungen li .betrag { margin-left: auto; }
.zahlungen-summe { margin: 12px 0 0; padding-top: 10px; border-top: 1px solid var(--border); display: flex; gap: 10px; align-items: center; font-weight: 600; }
a.tag-link { text-decoration: none; }
a.tag-link:hover { text-decoration: underline; }

/* ---------- Konten ---------- */
.col-datum { width: 130px; white-space: nowrap; }

/* iOS-Schalter: <label class="switch-row"> … <span class="switch"><input type="checkbox"> … */
.switch-list { display: flex; flex-direction: column; }
.switch-row {
    display: flex; align-items: center; justify-content: space-between; gap: 16px;
    padding: 12px 0; cursor: pointer;
}
.switch-row + .switch-row { border-top: 1px solid var(--border); }
.switch-text { display: flex; flex-direction: column; gap: 2px; }
.switch-text small { font-size: .82rem; }
.switch { position: relative; flex: none; width: 51px; height: 31px; }
.switch input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; z-index: 1; }
.switch-track {
    position: absolute; inset: 0; border-radius: 999px;
    background: var(--border-strong); transition: background-color .2s ease;
}
.switch-thumb {
    position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%;
    background: #fff; box-shadow: 0 2px 4px rgba(0, 0, 0, .25), 0 0 1px rgba(0, 0, 0, .2);
    transition: transform .2s cubic-bezier(.3, .7, .4, 1);
}
.switch input:checked + .switch-track { background: var(--accent); }
.switch input:checked + .switch-track .switch-thumb { transform: translateX(20px); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--accent); outline-offset: 2px; }

@media (max-width: 1100px) {
    .hide-md { display: none; }
}

@media (max-width: 860px) {
    .sidebar {
        position: fixed; z-index: 40; left: 0; top: 0;
        transform: translateX(-100%);
        transition: transform .2s ease;
        box-shadow: 0 0 40px rgba(0,0,0,.3);
    }
    .sidebar-open .sidebar { transform: none; }
    .scrim { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 30; display: none; }
    .sidebar-open .scrim { display: block; }
    .topbar {
        display: flex; align-items: center; gap: 10px;
        position: sticky; top: 0; z-index: 20;
        padding: 10px 16px;
        background: var(--sidebar); color: var(--sidebar-text);
    }
    .topbar .icon-btn { color: var(--sidebar-text); }
    .topbar-title { font-weight: 600; }
    .content { padding-top: 22px; }
    .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .detail-grid { grid-template-columns: 1fr; }
    .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .span-1, .span-2, .span-3 { grid-column: span 1; }
    .span-6 { grid-column: span 2; }
    .grid .span-3 { grid-column: span 2; }
    .logo-setting { grid-template-columns: 1fr; gap: 20px; }
    .roles-grid, .role-choice, .profile-grid { grid-template-columns: 1fr; }
    .span-4 { grid-column: span 2; }
    .tab span { display: none; }
    .tab.is-active span { display: inline; }
}

@media (max-width: 560px) {
    .date-filter { flex: 1 1 140px; min-width: 0; }
    .date-filter input { width: 100%; min-width: 0; }
    .table-buchungen .col-text .sub { white-space: normal; }
    .table-buchungen .col-datum { width: auto; white-space: nowrap; }
    .table-buchungen .col-betrag { width: auto; }
    .table-buchungen .col-gepr { width: auto; padding-left: 4px; padding-right: 10px; }
    .table.table-buchungen th, .table.table-buchungen td { padding: 10px 6px; }
    .table.table-buchungen td.col-datum { font-size: .82rem; }
    .table.table-buchungen .col-gepr { padding-left: 2px; }
    .only-sm { display: inline; }
    .table-buchungen .col-actions { display: none; } /* Name ist selbst der Link zum Bearbeiten */
    .stats-3 { grid-template-columns: 1fr; }
    .col-nummer { width: auto; }
    h1 { font-size: 1.5rem; }
    .hide-sm { display: none; }
    .grid { grid-template-columns: 1fr; }
    .grid > * { grid-column: span 1 !important; }
    .dl-row { grid-template-columns: 1fr; gap: 2px; }
    .page-actions, .page-actions .btn { width: 100%; }
    .toolbar select { flex: 1 1 140px; }
    .row-link { white-space: normal; }
    .check-date { margin-left: 0; max-width: none; }
    .table th, .table td { padding: 10px; }
}

@media (min-width: 861px) {
    .scrim { display: none; }
}

@media print {
    .sidebar, .topbar, .page-actions, .meta-row form, .form-actions { display: none !important; }
    body { background: #fff; color: #000; }
    .card { box-shadow: none; }
}

/* ---------- Mitglied: Reiter & Mitgliedskonto ---------- */
.tab-count {
    min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--badge-passiv-bg); color: var(--badge-passiv-fg);
    font-size: .75rem; font-weight: 700;
}
.konto-kopf { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 4px 0 12px; }
.konto-kopf h2 { margin: 0; font-size: 1.1rem; }
.konto-liste { display: flex; flex-direction: column; gap: 12px; }
.konto-soll { padding: 16px 18px; }
.konto-soll-kopf { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.konto-soll-titel { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.konto-soll-titel a { text-decoration: none; color: var(--text); }
.konto-soll-titel a:hover { color: var(--accent); }
.konto-soll-titel .muted { font-size: .86rem; }
.konto-soll-betrag { display: flex; align-items: center; gap: 10px; }
.konto-zahlungen { margin-top: 12px; padding: 10px 0 0 14px; border-top: 1px solid var(--border); border-left: 3px solid var(--accent-soft, var(--border)); }
.konto-zahlungen .tag .icon { vertical-align: -2px; }
.konto-rest { margin: 10px 0 0; font-size: .86rem; }
@media (max-width: 640px) {
    .konto-soll { padding: 14px; }
    .konto-soll-betrag { width: 100%; justify-content: space-between; }
}

/* ---------- Dashboard ---------- */
.dash-stats { margin-bottom: 16px; }
.dash-stats + .dash-grid { margin-top: 4px; }
.dash-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.dash-card { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.dash-card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.dash-card-head h2 { margin: 0; }
.dash-sub { margin: 2px 0 0; font-size: .85rem; }
.dash-link { font-size: .88rem; font-weight: 550; }
.dash-more { margin: 0; font-size: .85rem; }
.dash-ok { display: flex; align-items: center; gap: 8px; margin: 0; color: var(--accent); font-weight: 550; }

/* Legende */
.legend { list-style: none; margin: 0; padding: 0; display: flex; gap: 16px; font-size: .85rem; color: var(--muted); }
.legend li { display: flex; align-items: center; gap: 6px; }
.swatch { width: 12px; height: 12px; border-radius: 3px; }
.swatch-ein { background: var(--chart-ein); }
.swatch-aus { background: var(--chart-aus); }

/* Monatsdiagramm: Einnahmen nach oben, Ausgaben nach unten */
.mchart { display: grid; grid-template-columns: auto 1fr; gap: 8px; height: 240px; }
.mchart-axis { display: flex; flex-direction: column; justify-content: space-between; padding-bottom: 22px;
    font-size: .75rem; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
.mchart-axis span:nth-child(2) { transform: translateY(0); }
.mchart-plot { position: relative; display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 2px; }
.mchart-plot::before, .mchart-plot::after { content: ""; position: absolute; left: 0; right: 0; height: 1px; background: var(--border); pointer-events: none; }
.mchart-plot::before { top: 0; }
.mchart-plot::after { top: calc((100% - 22px) / 2); background: var(--border-strong); }
.mchart-col { display: grid; grid-template-rows: 1fr 1fr 22px; min-width: 0; border-radius: 6px; outline: none; cursor: default; }
.mchart-col:hover, .mchart-col.is-hover, .mchart-col:focus-visible { background: var(--surface-2); }
.mchart-col:focus-visible { box-shadow: 0 0 0 2px var(--focus); }
.mchart-up, .mchart-down { position: relative; display: flex; justify-content: center; }
.mchart-up { align-items: flex-end; }
.mchart-down { align-items: flex-start; }
.mbar { display: block; width: min(60%, 26px); }
.mbar-ein { background: var(--chart-ein); border-radius: 4px 4px 0 0; }
.mbar-aus { background: var(--chart-aus); border-radius: 0 0 4px 4px; }
.mchart-label { align-self: end; text-align: center; font-size: .75rem; color: var(--muted); }
.dash-table summary { cursor: pointer; color: var(--muted); font-size: .85rem; }
.dash-table .table { margin-top: 10px; font-size: .88rem; }
.dash-table .table th, .dash-table .table td { padding: 7px 10px; }

/* Säulen: Mitgliederentwicklung */
.vchart { display: grid; grid-template-columns: auto 1fr; gap: 8px; height: 210px; }
.vchart-axis { display: flex; flex-direction: column; justify-content: space-between; padding-bottom: 22px;
    font-size: .75rem; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
.vchart-axis span { line-height: 1; }
.vchart-plot { position: relative; display: flex; gap: 2px; padding-top: 0;
    background: linear-gradient(var(--border), var(--border)) 0 0 / 100% 1px no-repeat,
                linear-gradient(var(--border), var(--border)) 0 calc((100% - 22px) / 2) / 100% 1px no-repeat; }
.vchart-plot::after { content: ""; position: absolute; left: 0; right: 0; bottom: 22px; height: 1px; background: var(--border-strong); }
.vchart-col { flex: 1 1 0; min-width: 0; display: grid; grid-template-rows: 1fr 22px; border-radius: 6px; outline: none; }
.vchart-col:hover, .vchart-col.is-hover, .vchart-col:focus-visible { background: var(--surface-2); }
.vchart-col:focus-visible { box-shadow: 0 0 0 2px var(--focus); }
.vchart-col > .vbar { align-self: end; justify-self: center; position: relative; width: min(64%, 34px);
    background: var(--chart-ein); border-radius: 4px 4px 0 0; opacity: .55; }
.vchart-col > .vbar.is-last { opacity: 1; }
.vchart-col:hover > .vbar, .vchart-col.is-hover > .vbar { opacity: 1; }
.vbar-wert { position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); padding-bottom: 4px;
    font-size: .8rem; font-weight: 700; color: var(--text); white-space: nowrap; }
.vchart-label { align-self: end; text-align: center; font-size: .75rem; color: var(--muted); }

/* Waagrechte Balken */
.hbars { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.hbars li { display: grid; grid-template-columns: minmax(90px, 38%) 1fr auto; align-items: center; gap: 10px; font-size: .9rem; border-radius: 6px; }
.hbars li.is-hover { background: var(--surface-2); }
.hbar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar-label a { color: var(--text); text-decoration: none; }
.hbar-label a:hover { color: var(--accent); text-decoration: underline; }
.hbar-track { height: 10px; }
.hbar { display: block; height: 100%; border-radius: 0 4px 4px 0; background: var(--chart-ein); }
.hbars-aus .hbar { background: var(--chart-aus); }
.hbar-wert { font-variant-numeric: tabular-nums; font-weight: 600; text-align: right; white-space: nowrap; }

/* Listen */
.dash-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.dash-list li { display: flex; align-items: center; gap: 10px; padding: 9px 0; font-size: .92rem; min-width: 0; }
.dash-list li + li { border-top: 1px solid var(--border); }
.dash-list li.is-inactive { opacity: .6; }
.dash-list a { color: var(--text); font-weight: 550; text-decoration: none; }
.dash-list a:hover { color: var(--accent); text-decoration: underline; }
.dash-list .muted { font-size: .85rem; }
.dash-list-sub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.dash-list-end { margin-left: auto; white-space: nowrap; font-variant-numeric: tabular-nums; padding-left: 8px; }
.dash-list-date { color: var(--muted); font-size: .85rem; font-variant-numeric: tabular-nums; width: 84px; flex: 0 0 auto; }
.dash-list-icon { flex: 0 0 auto; width: 28px; height: 28px; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center;
    background: var(--accent-soft); color: var(--accent); }
.dash-list-icon-earth { background: var(--earth-soft); color: var(--earth); }

/* Beitragseingang */
.dash-hero { margin: 0; font-family: "Iowan Old Style", Palatino, Georgia, serif; font-size: 2.2rem; font-weight: 600; line-height: 1; }
.dash-hero .muted { font-family: inherit; font-size: 1rem; font-weight: 400; }
.meter { height: 12px; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--border); overflow: hidden; }
.meter span { display: block; height: 100%; background: var(--chart-ein); border-radius: 0 4px 4px 0; }
.dash-meter-text { margin: 0; font-size: .86rem; }

/* Tooltip */
.chart-tip { position: absolute; z-index: 50; pointer-events: none; padding: 8px 10px; border-radius: 10px;
    background: var(--text); color: var(--surface); font-size: .82rem; line-height: 1.45; box-shadow: var(--shadow); max-width: 260px; }
.chart-tip strong { display: block; margin-bottom: 2px; }

@media (max-width: 900px) {
    .dash-grid { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
    .dash-stats .stat-num { font-size: 1.35rem; }
    .mchart { height: 200px; }
    .mchart-label { font-size: .68rem; }
    .mchart-col:nth-child(even) .mchart-label { visibility: hidden; } /* jedes zweite Monatskürzel */
    .mchart-axis span { white-space: nowrap; }
    .mchart-axis, .vchart-axis { font-size: .68rem; }
    .dash-list-sub { display: none; }
    .dash-list-date { width: auto; }
    .legend { gap: 10px; }
}

/* ---------- Kontakte ---------- */
.stats-kontakte { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.stats-kontakte .stat-num { font-size: 1.4rem; }
.tags { display: flex; flex-wrap: wrap; gap: 4px; }
.table-kontakte .tag { font-size: .72rem; }
.kontakt-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 4px 0 0; }
.adresse { font-style: normal; line-height: 1.6; }
.chip-checks { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-check { position: relative; cursor: pointer; }
.chip-check input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.chip-check span {
    display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 999px;
    border: 1px solid var(--border-strong); background: var(--surface); color: var(--muted); font-weight: 550; font-size: .92rem;
}
.chip-check span .icon { display: none; }
.chip-check input:checked + span { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.chip-check input:checked + span .icon { display: inline-block; }
.chip-check input:focus-visible + span { box-shadow: 0 0 0 3px var(--focus); }
.chip-check:hover span { border-color: var(--accent); }
@media (max-width: 1100px) {
    .stats-kontakte { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
    .stats-kontakte { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.tags .tag, .kontakt-meta .tag { margin-left: 0; }
@media (max-width: 640px) {
    .table-kontakte .sub.only-sm { display: block; }
}
.chip-hint { margin-top: 10px; }
.chip-checks + .field-error { display: block; margin-top: 8px; }

/* ---------- Rechnungen ---------- */
.badge-entwurf { background: var(--surface-2); color: var(--muted); border: 1px dashed var(--border-strong); }
.badge-ueberfaellig { background: var(--danger-soft); color: var(--danger); }
.stat-ueber::before { background: var(--danger); }
.table-rechnungen .col-renr { width: 110px; white-space: nowrap; }
.table-rechnungen .col-renr .row-link { font-weight: 600; }
.table-rechnungen .col-status { width: 120px; }
.table-rechnungen .tag { margin-left: 0; }
.re-kopfzeile { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.page-actions .inline-form { margin: 0; }

/* Positionen im Formular */
.pos-liste { display: flex; flex-direction: column; gap: 10px; }
.pos-row {
    display: grid; align-items: start; gap: 10px;
    grid-template-columns: 28px minmax(0, 1fr) 80px 90px 120px 96px 110px auto;
    padding: 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2);
}
.pos-nr { padding-top: 32px; color: var(--muted); font-weight: 600; font-variant-numeric: tabular-nums; }
.pos-text { display: flex; flex-direction: column; gap: 6px; }
.pos-text textarea { min-height: 38px; resize: vertical; font-size: .9rem; }
.pos-row .field input, .pos-row .field select { min-width: 0; }
.pos-menge input, .pos-preis input { text-align: right; font-variant-numeric: tabular-nums; }
.pos-betrag { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; padding-top: 4px; }
.pos-betrag strong { padding-top: 10px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.pos-label { font-size: .82rem; font-weight: 600; color: var(--muted); }
.pos-aktionen { display: flex; gap: 2px; padding-top: 26px; }
.pos-aktionen .icon-btn { width: 32px; height: 32px; font-weight: 700; }
.pos-aktionen .icon-btn:disabled { opacity: .3; cursor: default; }
.icon-btn-danger:hover { color: var(--danger); background: var(--danger-soft); }
.pos-fehler { display: block; margin: 0 0 12px; }
.pos-fuss { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-top: 14px; }
.pos-summen { margin: 0; min-width: 240px; display: flex; flex-direction: column; gap: 4px; font-variant-numeric: tabular-nums; }
.pos-summen div { display: flex; justify-content: space-between; gap: 24px; }
.pos-summen dt { color: var(--muted); }
.pos-summen dd { margin: 0; }
.pos-summe-gesamt { border-top: 1px solid var(--border-strong); padding-top: 6px; font-weight: 700; font-size: 1.05rem; }
.pos-summe-gesamt dt { color: var(--text); }
.field-stack { display: flex; flex-direction: column; gap: 14px; }

/* Detailansicht */
.re-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 20px; align-items: start; }
.re-seite { display: flex; flex-direction: column; gap: 16px; }
.re-box h2 { margin-top: 0; }
.re-box > form, .re-box > p, .re-box > dl { clear: both; }
.re-box p { margin: 0 0 10px; }
.re-box-storno { border-color: var(--danger); }
.re-form { display: flex; flex-direction: column; gap: 12px; }
.re-form .switch-row { padding: 0; }
.re-hinweis-ueber { display: flex; align-items: center; gap: 6px; color: var(--danger); font-weight: 600; }
.dl-kompakt .dl-row { padding: 6px 0; }
.re-papier { overflow-x: auto; border-radius: 14px; box-shadow: var(--shadow); }

/* Das Dokument selbst – immer „Papier“, auch im dunklen Design */
.beleg {
    --b-text: #1d241c; --b-muted: #5f675c; --b-line: #d9d5ca; --b-akzent: #2f6b3a;
    position: relative; overflow: hidden;
    background: #fff; color: var(--b-text); min-width: 600px;
    padding: 48px 56px 36px; font-size: 13.5px; line-height: 1.5; border-radius: 14px;
}
.beleg-wasserzeichen {
    position: absolute; top: 40%; left: 50%; transform: translate(-50%, -50%) rotate(-28deg);
    font-size: 110px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase;
    color: rgba(166, 61, 47, .08); pointer-events: none; white-space: nowrap;
}
.beleg-kopf { display: flex; justify-content: flex-end; margin-bottom: 28px; }
.beleg-absender { display: flex; align-items: center; gap: 14px; text-align: right; }
.beleg-absender div { display: flex; flex-direction: column; }
.beleg-absender strong { font-family: "Iowan Old Style", Palatino, Georgia, serif; font-size: 17px; color: var(--b-akzent); }
.beleg-absender span { color: var(--b-muted); font-size: 12px; }
.beleg-logo { max-height: 64px; max-width: 160px; object-fit: contain; order: 2; }
.beleg-adressen { display: flex; justify-content: space-between; gap: 32px; margin-bottom: 30px; }
.beleg-empfaenger { min-height: 120px; }
.beleg-ruecksendung { display: block; font-size: 9.5px; color: var(--b-muted); border-bottom: 1px solid var(--b-line); padding-bottom: 2px; margin-bottom: 8px; }
.beleg-empfaenger address { font-style: normal; font-size: 14px; }
.beleg-uid { display: block; margin-top: 6px; font-size: 12px; color: var(--b-muted); }
.beleg-meta { margin: 0; min-width: 220px; display: flex; flex-direction: column; gap: 3px; font-size: 13px; }
.beleg-meta div { display: flex; justify-content: space-between; gap: 18px; }
.beleg-meta dt { color: var(--b-muted); }
.beleg-meta dd { margin: 0; font-weight: 600; text-align: right; }
.beleg-titel { font-family: "Iowan Old Style", Palatino, Georgia, serif; font-size: 24px; margin: 0 0 4px; color: var(--b-text); }
.beleg-titel::before { display: none; }
.beleg-betreff { margin: 0 0 12px; }
.beleg-text { margin: 0 0 16px; }
.beleg-tabelle { width: 100%; border-collapse: collapse; margin: 6px 0 12px; }
.beleg-tabelle th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--b-muted);
    border-bottom: 1.5px solid var(--b-text); padding: 6px 8px; }
.beleg-tabelle td { padding: 8px; border-bottom: 1px solid var(--b-line); vertical-align: top; }
.beleg-tabelle .b-zahl { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.beleg-tabelle .b-pos { width: 36px; color: var(--b-muted); }
.b-beschreibung { display: block; color: var(--b-muted); font-size: 12.5px; }
.beleg-summen { margin: 0 0 20px auto; width: min(100%, 340px); display: flex; flex-direction: column; gap: 4px; font-variant-numeric: tabular-nums; }
.beleg-summen div { display: flex; justify-content: space-between; gap: 18px; }
.beleg-summen dt { color: var(--b-muted); }
.beleg-summen dd { margin: 0; }
.beleg-gesamt { border-top: 1.5px solid var(--b-text); padding-top: 6px; font-size: 15px; font-weight: 700; }
.beleg-gesamt dt { color: var(--b-text); }
.beleg-fuss { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-top: 36px; padding-top: 12px;
    border-top: 1px solid var(--b-line); font-size: 10.5px; color: var(--b-muted); }
.beleg-fuss div { display: flex; flex-direction: column; }
.beleg-fuss strong { color: var(--b-text); }

/* Druckansicht */
.druck-body { background: #e9e6dd; min-height: 100vh; padding: 0 0 40px; }
.druck-body .beleg { width: 210mm; min-height: 297mm; margin: 24px auto 0; padding: 20mm 20mm 16mm; border-radius: 0;
    box-shadow: 0 4px 24px rgba(0, 0, 0, .15); display: flex; flex-direction: column; }
.druck-body .beleg-fuss { margin-top: auto; }
.druck-body .beleg-summen + .beleg-text { margin-bottom: 24px; }
.druck-leiste { position: sticky; top: 0; z-index: 5; display: flex; justify-content: space-between; align-items: center; gap: 12px;
    padding: 10px 20px; background: #1f3a26; color: #e6efdc; font-weight: 600; }
@page { size: A4; margin: 0; }
@media print {
    .druck-body { background: #fff; padding: 0; }
    .druck-leiste { display: none; }
    .druck-body .beleg { margin: 0; box-shadow: none; width: auto; min-height: 297mm; }
    .beleg-tabelle tr { break-inside: avoid; }
}

@media (max-width: 1100px) {
    .re-layout { grid-template-columns: minmax(0, 1fr); }
    .pos-row { grid-template-columns: 24px minmax(0, 1fr) 80px 90px; }
    .pos-text { grid-column: 2 / -1; }
    .pos-menge { grid-column: 2; }
    .pos-nr { grid-row: 1; }
    .pos-betrag { grid-column: 2 / 4; flex-direction: row; align-items: center; justify-content: flex-start; padding-top: 0; }
    .pos-betrag strong { padding-top: 0; }
    .pos-aktionen { grid-column: 4; padding-top: 0; justify-content: flex-end; }
}
@media (max-width: 640px) {
    .pos-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); padding: 10px; }
    .pos-nr { display: none; }
    .pos-text, .pos-preis, .pos-ust { grid-column: auto; }
    .pos-text { grid-column: 1 / -1; }
    .pos-menge, .pos-einheit, .pos-preis, .pos-ust { grid-column: auto; }
    .pos-betrag { grid-column: 1; }
    .pos-aktionen { grid-column: 2; }
    .pos-summen { width: 100%; }
    .druck-body .beleg { width: auto; min-height: 0; margin: 0; padding: 24px 18px; min-width: 0; }
    .druck-leiste { font-size: .85rem; }
    .druck-leiste span { display: none; }
}
@media (max-width: 640px) {
    [data-rechnung-form] .form-actions { flex-wrap: wrap; }
    [data-rechnung-form] .form-actions .btn-ghost { display: none; } /* „Zurück“ steht oben */
    [data-rechnung-form] .form-actions .btn { flex: 1 1 auto; white-space: nowrap; }
}

/* ---------- Projekte ---------- */

.only-md { display: none; }
.nowrap { white-space: nowrap; }
.col-zahl { text-align: right; font-variant-numeric: tabular-nums; width: 90px; }
.table tfoot td { border-top: 2px solid var(--border-strong); background: var(--surface-2); font-weight: 600; }
.table-scroll { overflow-x: auto; }
.pj-kopfzeile { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pj-beschreibung { line-height: 1.6; clear: both; }
.pj-hinweis { display: flex; align-items: center; gap: 6px; color: var(--danger); margin: 10px 0 0; }
.pj-buchungen .table { margin-top: 8px; }
.tag-projekt { display: inline-flex; align-items: center; gap: 3px; text-transform: none; letter-spacing: 0; font-weight: 600; }
.tag-projekt svg { flex: none; }
@media (max-width: 1100px) {
    .only-md { display: block; }
}

/* Projektstatistik als Dokument (Druck/PDF) – mehrseitig, mit Seitenrand oben und unten */
.bericht { page: bericht; }
.bericht-kopf { display: flex; justify-content: space-between; align-items: flex-start; gap: 24px; flex-wrap: wrap;
    padding-bottom: 14px; margin-bottom: 18px; border-bottom: 2px solid var(--b-akzent); }
.bericht-kopf .beleg-titel { margin: 0; }
.bericht-art { margin: 0 0 2px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--b-akzent); }
.bericht-unter { margin: 2px 0 0; color: var(--b-muted); }
.bericht-kennzahlen { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 20px; }
.bericht-kennzahlen div { display: flex; flex-direction: column; gap: 1px; padding: 9px 12px; border: 1px solid var(--b-line); border-radius: 8px; }
.bericht-kennzahlen span { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--b-muted); }
.bericht-kennzahlen strong { font-size: 16px; font-variant-numeric: tabular-nums; }
.bericht-kennzahlen small { font-size: 11px; color: var(--b-muted); }
.bericht-saldo strong { color: var(--b-akzent); }
.bericht-saldo.is-minus strong { color: #a63d2f; }
.bericht-block { margin-bottom: 16px; }
.bericht-block h2 { margin: 0 0 4px; font-size: 14px; color: var(--b-akzent); break-after: avoid; }
.bericht-block h2::before { display: none; }
.bericht-text { margin: 0 0 10px; }
.bericht-tabelle { font-size: 12px; margin-bottom: 10px; }
.bericht-tabelle td { padding: 5px 8px; }
.bericht-tabelle thead { display: table-header-group; }
.bericht-tabelle tr { break-inside: avoid; }
.bericht-balken-sp { width: 30%; }
.bericht-balken-breit { width: 62%; }
.bericht-projekt { width: 38%; }
.bericht-balken { display: block; height: 8px; border-radius: 0 3px 3px 0; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.bericht-balken + .bericht-balken { margin-top: 3px; }
.bericht-balken-ein { background: #2f7d45; }
.bericht-balken-aus { background: #b9852a; }
.bericht-summe td { font-weight: 700; border-top: 1.5px solid var(--b-text); border-bottom: 0; }
.bericht-legende { display: flex; align-items: center; gap: 6px; margin: 0; font-size: 11px; color: var(--b-muted); }
.bericht-legende .bericht-balken { display: inline-block; width: 14px; margin: 0 0 0 8px; }
.bericht-legende .bericht-balken:first-child { margin-left: 0; }
.bericht-fuss { display: flex; justify-content: space-between; gap: 16px; margin-top: auto; padding-top: 10px;
    border-top: 1px solid var(--b-line); font-size: 10.5px; color: var(--b-muted); }
.druck-body .bericht { min-height: 0; padding-top: 16mm; padding-bottom: 14mm; }
@page bericht { size: A4; margin: 14mm 0 12mm; }
@media print {
    .druck-body .bericht { min-height: 0; padding-top: 0; padding-bottom: 0; }
}
@media (max-width: 640px) {
    .bericht-kennzahlen { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .bericht-balken-sp { width: 22%; }
    .bericht-fuss { flex-direction: column; gap: 2px; }
}
.table-projekte .col-zahl { width: 64px; }
.pj-kurz { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.pj-badge-sm { margin-top: 6px; }
.bericht-arten { table-layout: fixed; }
.bericht-arten th:nth-child(1) { width: 40%; }
.bericht-arten th:nth-child(2) { width: 30%; }
.bericht-arten th:nth-child(3) { width: 12%; }
@media (max-width: 640px) {
    .pj-badge-sm { display: block; }
}
.tag-projekt { vertical-align: -3px; }
.tag-projekt span { overflow-wrap: anywhere; }
.toolbar select { max-width: 100%; }
@media (max-width: 640px) {
    .table.pj-tabelle th, .table.pj-tabelle td { padding: 9px 5px; }
    .table.pj-tabelle td.col-datum { font-size: .8rem; }
    .table.pj-tabelle .col-betrag { width: auto; white-space: nowrap; }
    .pj-buchungen.section { padding-left: 12px; padding-right: 12px; }
}

/* ---------- Statistiken ---------- */

.st-toolbar { align-items: flex-end; }
.st-feld { display: flex; flex-direction: column; gap: 4px; font-size: .8rem; color: var(--muted); flex: 0 1 auto; min-width: 0; }
.st-feld select { min-width: 150px; max-width: 280px; }
.st-check { display: inline-flex; align-items: center; gap: 6px; font-size: .9rem; min-height: 42px; padding: 0 4px; }
.st-check input { width: 18px; height: 18px; margin: 0; accent-color: var(--accent); }
.st-block { margin-bottom: 16px; }
.st-block .table { margin-top: 10px; }
.st-grid { margin-bottom: 16px; }
.st-tabelle .st-nr { width: 64px; }
.st-tabelle .st-anz { width: 56px; }
.st-tabelle .st-anteil { width: 190px; }
.st-tabelle .col-betrag { white-space: nowrap; }
.st-tabelle .st-gesamt { font-weight: 600; }
.table.st-tabelle th.st-gesamt, .table.st-tabelle td.st-gesamt { background: var(--surface-2); }
.st-anteil-zelle { display: grid; grid-template-columns: 1fr 48px; align-items: center; gap: 8px; }
.st-bar-track { display: block; height: 10px; }
.st-bar { display: block; height: 100%; border-radius: 0 4px 4px 0; }
.st-bar-ein { background: var(--chart-ein); }
.st-bar-aus { background: var(--chart-aus); }
.st-anteil-text { text-align: right; font-variant-numeric: tabular-nums; font-size: .85rem; color: var(--muted); }
.st-trend { white-space: nowrap; font-weight: 600; }
.st-trend-gut { color: var(--accent); }
.st-trend-schlecht { color: var(--danger); }
.st-ohne td { font-style: italic; }
.table.st-tabelle tr.st-klasse td { border-top: 1.5px solid var(--border-strong); }
.table.st-tabelle tr.st-unter td { padding-top: 5px; padding-bottom: 5px; border-top: 0; font-size: .86rem; color: var(--muted); }
.table.st-tabelle tr.st-unter td.col-text { padding-left: 26px; }
.st-hinweis { max-width: 820px; }
.stat-label .st-trend { font-weight: 600; }

/* Druck */
.beleg .st-tabelle .tag { font-size: 9px; padding: 0 5px; }
.beleg .st-tabelle tr.st-unter td { padding-top: 2px; padding-bottom: 2px; border-bottom: 0; color: var(--b-muted); font-size: 11px; }
.beleg .st-tabelle tr.st-unter td.col-text { padding-left: 22px; }
.beleg .st-tabelle tr.st-klasse td { border-top: 1px solid var(--b-line); border-bottom: 0; }
.beleg .st-tabelle tbody.st-gruppe { break-inside: avoid; }
.beleg .st-tabelle .st-anteil { width: 25%; }
.beleg .st-tabelle .st-nr { width: 44px; }
.beleg .st-tabelle .st-anz { width: 40px; }
.beleg .st-trend-gut { color: #2f6b3a; }
.beleg .st-trend-schlecht { color: #a63d2f; }
.beleg .st-bar-track { height: 8px; }
.beleg .st-anteil-text { color: var(--b-muted); font-size: 11px; }
.beleg .st-anteil-zelle { grid-template-columns: 1fr 42px; gap: 6px; }
.beleg .st-gesamt { background: #f3f1ea; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.bericht-breit .st-tabelle { font-size: 10.5px; }
.bericht-breit .st-tabelle td, .bericht-breit .st-tabelle th { padding-left: 5px; padding-right: 5px; }
.bericht-legende + .bericht-fuss, .bericht-block + .bericht-legende { margin-top: 6px; }
@media (max-width: 640px) {
    .st-feld { flex: 1 1 140px; }
    .st-feld select { min-width: 0; max-width: none; width: 100%; }
    .st-tabelle .st-anteil { width: 120px; }
    .table.st-tabelle .st-vj, .table.st-tabelle .st-anz { display: none; }
}
.table.st-tabelle td.col-betrag { text-align: right; }
.beleg .st-tabelle .st-anteil { width: 19%; }
.beleg .st-tabelle td.col-text { width: auto; }
.st-feld select { flex: none; height: auto; }
@media (max-width: 640px) {
    .table.st-tabelle .st-anteil, .table.st-tabelle .st-nr { display: none; }
    .table.st-tabelle th, .table.st-tabelle td { padding-left: 6px; padding-right: 6px; }
    .table.st-tabelle tr.st-unter td.col-text { padding-left: 16px; }
}
@media (max-width: 640px) {
    .st-block.section { padding-left: 12px; padding-right: 12px; }
    .table.st-tabelle .col-betrag { width: auto; }
}

/* ---------- E-Mail-Vorlagen: Editor ---------- */

.editor { border: 1px solid var(--border-strong); border-radius: 12px; background: var(--surface); overflow: hidden; }
.editor:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus); }
.editor.is-invalid { border-color: var(--danger); }
.editor:not(.is-aktiv) { border: 0; background: none; overflow: visible; }
.editor:not(.is-aktiv):focus-within { box-shadow: none; }
.ed-leiste { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; padding: 6px 8px;
    border-bottom: 1px solid var(--border); background: var(--surface-2); }
.ed-gruppe { display: flex; gap: 2px; padding-right: 6px; border-right: 1px solid var(--border); }
.ed-gruppe-verlauf { border-right: 0; }
.ed-btn { display: inline-grid; place-items: center; width: 34px; height: 32px; padding: 0; border: 1px solid transparent; border-radius: 7px;
    background: none; color: var(--text); font: inherit; font-size: 15px; cursor: pointer; }
.ed-btn:hover { background: var(--surface); border-color: var(--border); }
.ed-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.ed-btn.is-an { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.ed-btn b, .ed-btn i, .ed-btn u, .ed-h { font-family: Georgia, serif; font-size: 16px; line-height: 1; }
.ed-h { font-weight: 700; }
.ed-platzhalter { margin-left: auto; width: auto; max-width: 100%; min-height: 32px; padding: 4px 30px 4px 10px; font-size: .86rem; }
.ed-linkleiste { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.ed-linkleiste[hidden], .ed-leiste[hidden], .ed-flaeche[hidden], .ed-quelle[hidden] { display: none; }
.ed-linkleiste input { flex: 1 1 auto; min-width: 0; min-height: 34px; }
.ed-linkleiste svg { flex: none; color: var(--muted); }
.ed-flaeche { min-height: 280px; max-height: 70vh; overflow-y: auto; padding: 16px 18px; outline: none; line-height: 1.6; }
.ed-quelle { width: 100%; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .85rem; }

/* Formatierter Text (Editor und Vorschau) */
.beleg-text-email > :first-child { margin-top: 0; }
.beleg-text-email > :last-child { margin-bottom: 0; }
.beleg-text-email p { margin: 0 0 .85em; }
.beleg-text-email h2 { font-size: 1.2rem; margin: 1.1em 0 .45em; }
.beleg-text-email h2::before, .beleg-text-email h3::before { display: none; }
.beleg-text-email h3 { font-size: 1.05rem; margin: 1em 0 .4em; }
.beleg-text-email ul, .beleg-text-email ol { margin: 0 0 .85em; padding-left: 1.5em; }
.beleg-text-email li { margin: .15em 0; }
.beleg-text-email blockquote { margin: 0 0 .85em; padding: 8px 14px; border-left: 3px solid var(--accent); background: var(--surface-2); border-radius: 0 8px 8px 0; }
.beleg-text-email a { color: var(--accent); }

/* Liste und Vorschau */
.ev-ph { display: inline-block; margin: 2px 4px 2px 0; padding: 1px 6px; border-radius: 5px; background: var(--surface-2);
    border: 1px solid var(--border); font-size: .78rem; color: var(--text); }
.ev-auszug { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; max-width: 760px; }
.ev-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; align-items: start; }
.ev-seite { display: flex; flex-direction: column; gap: 16px; }
.ev-seite .section { margin: 0; }
.ev-mail { padding: 0; overflow: hidden; }
.ev-mail-kopf { padding: 14px 22px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.ev-mail-kopf dl { margin: 0; display: grid; gap: 4px; font-size: .9rem; }
.ev-mail-kopf dl div { display: grid; grid-template-columns: 70px 1fr; gap: 10px; }
.ev-mail-kopf dt { color: var(--muted); }
.ev-mail-kopf dd { margin: 0; overflow-wrap: anywhere; }
.ev-mail-text { padding: 22px 24px 26px; line-height: 1.6; }
.ev-test { display: flex; flex-direction: column; gap: 10px; }
.ev-test .btn { align-self: flex-start; }
.ev-ph-liste { margin: 8px 0 0; }
.ev-klartext summary { cursor: pointer; font-weight: 600; }
.ev-klartext pre { white-space: pre-wrap; font-size: .82rem; margin: 10px 0 0; max-height: 360px; overflow: auto; }
@media (max-width: 1100px) {
    .ev-layout { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 640px) {
    .ed-platzhalter { margin-left: 0; width: 100%; }
    .ed-gruppe { padding-right: 4px; }
    .ed-btn { width: 32px; }
    .ed-flaeche { padding: 12px; min-height: 220px; }
    .ev-mail-text { padding: 16px; }
    .ev-mail-kopf { padding: 12px 16px; }
}
.editor .ed-platzhalter { width: auto; flex: 0 1 auto; }
@media (max-width: 640px) {
    .editor .ed-platzhalter { width: 100%; flex: 1 1 100%; }
}

/* ---------- Seitenleiste: aufklappbare Abschnitte, kompakte Designauswahl ---------- */

.nav { gap: 0; }
.nav-gruppe { display: flex; flex-direction: column; }
.nav-gruppe + .nav-gruppe { margin-top: 10px; }
.nav-items { display: flex; flex-direction: column; gap: 2px; }
.nav-items[hidden] { display: none; }
.nav-toggle {
    display: flex; align-items: center; gap: 6px; width: 100%;
    padding: 6px 10px; margin-bottom: 2px; border: 0; border-radius: 8px;
    background: none; color: var(--sidebar-muted); cursor: pointer;
    font: inherit; font-size: .7rem; text-transform: uppercase; letter-spacing: .1em; text-align: left;
}
.nav-toggle:hover { color: var(--sidebar-text); background: var(--sidebar-hover); }
.nav-toggle:focus-visible { outline: 2px solid #a7d9a3; outline-offset: -2px; }
.nav-toggle > span:first-child { flex: 1; }
.nav-toggle svg { flex: none; transition: transform .15s ease; }
.nav-toggle[aria-expanded="true"] svg { transform: rotate(90deg); }
.nav-zahl { font-size: .68rem; letter-spacing: 0; padding: 0 6px; border-radius: 999px; background: var(--sidebar-hover); line-height: 1.6; }
.nav-toggle[aria-expanded="true"] .nav-zahl { visibility: hidden; }
.nav-link { padding: 8px 10px; }

.sidebar-foot { gap: 12px; padding-top: 16px; }
.design-switch { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.design-switch .nav-label { padding: 0 0 0 10px; }
.swatches { display: flex; gap: 6px; }
.design-switch .swatch { flex-direction: row; padding: 4px; border-radius: 50%; }
.design-switch .swatch-dot { width: 22px; height: 22px; }
.design-switch .swatch-name { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
@media (prefers-reduced-motion: reduce) {
    .nav-toggle svg { transition: none; }
}
.design-switch .swatch { position: relative; flex: none; display: grid; place-items: center; width: 32px; height: 32px; padding: 0; }
.design-switch .swatch-dot { flex: none; display: block; }

/* ---------- Mitgliederstatistik ---------- */

.ms-von-bis { display: flex; align-items: center; gap: 6px; }
.ms-von-bis input { width: 76px; }
.ms-toolbar input[type="date"] { min-width: 150px; }
.ms-plus { color: var(--accent); }
.ms-minus { color: var(--danger); }
.ms-trenner { border: 0; border-top: 1px solid var(--border); margin: 14px 0; }
.ms-bars .hbar-wert { white-space: nowrap; font-variant-numeric: tabular-nums; }
.ms-bars .hbar-wert small { display: inline-block; min-width: 3.6em; text-align: right; }
.ms-kennwerte { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 0 0 14px; }
.ms-kennwerte div { padding: 8px 12px; border-radius: 8px; background: var(--surface-2); }
.ms-kennwerte dt { font-size: .78rem; color: var(--muted); }
.ms-kennwerte dd { margin: 0; font-weight: 700; font-variant-numeric: tabular-nums; }
.ms-funktionen td:first-child { font-weight: 600; }

/* Druck */
.ms-druck-raster { display: grid; grid-template-columns: 1fr 1fr; column-gap: 22px; }
.ms-druck-raster .bericht-block { break-inside: avoid; }
.ms-tabelle { table-layout: fixed; margin-bottom: 4px; }
.ms-tabelle td { padding: 3px 6px; }
.ms-tabelle td:first-child { overflow-wrap: break-word; hyphens: manual; }
.ms-tabelle .ms-balken-sp { width: 27%; }
.ms-tabelle .b-zahl { width: 34px; }
.ms-tabelle .ms-anteil { width: 46px; color: var(--b-muted); }
.ms-entwicklung-druck th:first-child { width: 22%; }
.ms-entwicklung-druck .ms-balken-sp { width: 38%; }
.ms-entwicklung-druck .b-zahl { width: 13%; }
.ms-beitrag { font-size: 11.5px; margin-top: 6px; }
@media (max-width: 640px) {
    .ms-druck-raster { grid-template-columns: 1fr; }
    .ms-alter { flex: 1 1 140px; }
    .ms-von-bis input { width: 100%; flex: 1; }
    .ms-toolbar input[type="date"] { min-width: 0; width: 100%; }
    .ms-kennwerte { grid-template-columns: 1fr; }
}

/* ---------- E-Mail ---------- */

.em-standard { position: absolute; width: 1px; height: 1px; padding: 0; border: 0; overflow: hidden; clip: rect(0 0 0 0); }
.em-vorlage label { display: block; margin-bottom: 6px; font-weight: 600; font-size: .9rem; }
.em-vorlage-zeile { display: flex; gap: 8px; }
.em-vorlage-zeile select { flex: 1; min-width: 0; }
.em-spalten { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.em-panel { display: flex; flex-direction: column; gap: 10px; min-width: 0; padding: 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); }
.em-panel-kopf { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.em-panel-kopf h3 { display: flex; align-items: center; gap: 6px; margin: 0; font-size: 1rem; }
.em-panel-kopf .muted { font-size: .85rem; }
.em-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; cursor: pointer;
    border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font: inherit; font-size: .85rem; font-weight: 550; }
.chip:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.chip:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--focus); }
.chip:disabled { opacity: .5; cursor: default; }
.chip-zahl { min-width: 20px; padding: 0 6px; border-radius: 999px; background: var(--surface-2); color: var(--muted); font-size: .75rem; text-align: center; font-variant-numeric: tabular-nums; }
.chip-leer { color: var(--muted); border-style: dashed; }
.em-suche { width: 100%; }
.em-liste { max-height: 360px; overflow-y: auto; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.em-zeile { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 8px 12px; cursor: pointer; border-bottom: 1px solid var(--border); }
.em-zeile:last-child { border-bottom: 0; }
.em-zeile:hover { background: var(--surface-2); }
.em-zeile[hidden] { display: none; }
.em-zeile input { width: 18px; height: 18px; margin: 0; accent-color: var(--accent); }
.em-zeile.is-ohne { cursor: default; opacity: .6; }
.em-name { min-width: 0; font-weight: 550; overflow-wrap: anywhere; }
.em-name small { display: block; font-weight: 400; color: var(--muted); font-size: .8rem; }
.em-tags { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 4px; }
.em-tags .tag { font-size: .7rem; margin: 0; }
.tag-offen { background: var(--danger-soft); color: var(--danger); }
.em-leer { padding: 12px; margin: 0; }
.em-hinweis { margin: 12px 0 0; }
.em-empfaenger.is-invalid .em-panel { border-color: var(--danger); }
.em-empfaenger > .field-error { display: block; margin-bottom: 10px; }
.em-test summary { cursor: pointer; font-weight: 600; }
.em-test-zeile { display: flex; align-items: flex-end; gap: 10px; margin-top: 12px; flex-wrap: wrap; }
.em-test-zeile .field { flex: 1 1 240px; margin: 0; }
.em-test .hint { margin: 8px 0 0; }
.em-aktionen { align-items: center; }
.em-summe { margin-right: auto; color: var(--muted); }
.em-summe strong { color: var(--text); font-size: 1.1rem; }
.em-vorschau { margin-bottom: 16px; }

.em-status { margin-bottom: 16px; }
.em-status-kopf { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.em-status-kopf h2 { margin: 0; }
.em-fortschritt { display: flex; height: 10px; border-radius: 999px; overflow: hidden; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--border); }
.em-fortschritt-ok { background: var(--accent); transition: width .3s; }
.em-fortschritt-fehler { background: var(--danger); transition: width .3s; }
.em-weiter { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 14px; }
.em-weiter .hint { margin: 0; }
.em-meldung { margin: 12px 0 0; color: var(--danger); font-weight: 550; }
.em-ablage { display: flex; gap: 6px; align-items: flex-start; margin: 12px 0 0; }
.em-ablage .icon { flex: none; margin-top: 2px; }
.em-layout { grid-template-columns: minmax(0, 1fr) minmax(0, 380px); }
.em-protokoll h2 .muted { font-weight: 400; }
.table-empfaenger .sub { display: block; }
.em-fehler { color: var(--danger) !important; }
.table-emails .col-zahl { width: 90px; text-align: right; }
@media (max-width: 1100px) {
    .em-layout { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 760px) {
    .em-spalten { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 640px) {
    .em-panel { padding: 10px; }
    .em-zeile { grid-template-columns: auto minmax(0, 1fr); }
    .em-tags { grid-column: 2; justify-content: flex-start; }
    .em-aktionen .em-summe { width: 100%; text-align: center; }
    .em-weiter .btn { width: 100%; }
}
.em-protokoll .table-scroll { clear: both; }
.table-empfaenger td { vertical-align: top; }
@media (max-width: 640px) {
    .page-actions .inline-form { width: 100%; }
}
.section > h2 + * { clear: both; }
