/*
 * Basisstile der privaten Homepage.
 * Aufbau und Maße aus dem TOLERANT-KYC-Template (Seitenmenü 274 px, Kopfzeile 72 px),
 * Farben aus dem persönlichen Farbset. Alle Farben laufen über die Variablen unten.
 */

/* IBM Plex Sans liegt lokal unter assets/fonts (SIL Open Font License, siehe OFL.txt dort) */
@font-face { font-family: "IBM Plex Sans"; font-style: normal; font-weight: 400; font-display: swap; src: url("../fonts/ibm-plex-sans/IBMPlexSans-Regular.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-style: italic; font-weight: 400; font-display: swap; src: url("../fonts/ibm-plex-sans/IBMPlexSans-Italic.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-style: normal; font-weight: 500; font-display: swap; src: url("../fonts/ibm-plex-sans/IBMPlexSans-Medium.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-style: normal; font-weight: 600; font-display: swap; src: url("../fonts/ibm-plex-sans/IBMPlexSans-SemiBold.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-style: normal; font-weight: 700; font-display: swap; src: url("../fonts/ibm-plex-sans/IBMPlexSans-Bold.woff2") format("woff2"); }

:root {
    color-scheme: light;

    /* Farbset */
    --brand: #b83232;          /* Leitfarbe: Kopfzeile, Buttons, aktive Navigation */
    --brand-hover: #922828;    /* Hover */
    --background: #faf7f2;     /* Hintergrund Inhaltsbereich */
    --accent: #f3deda;         /* Akzentfläche */
    --ink: #292524;            /* Text */

    /* Abgeleitete Töne */
    --accent-soft: #fbf1ef;    /* Hover im Seitenmenü */
    --accent-strong: #ecccc6;  /* Hover auf Akzentflächen */
    --accent-line: #ead0cb;    /* Rahmen auf Akzentflächen */
    --muted: #6b635d;
    --line: #ebe5dd;
    --line-strong: #d9d0c6;
    --surface: #ffffff;
    --surface-muted: #fcfaf7;
    --success: #2f7a4f;
    --success-bg: #ebf5ef;
    --success-line: #cfe6d8;
    --focus: #922828;
    --shadow: 0 1px 2px rgba(41, 37, 36, .06);

    /* Schrift */
    --font-sans: "IBM Plex Sans", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --font-display: var(--font-sans); /* Seitentitel und große Zahlen; z. B. Georgia, serif für Serifen */

    /* Maße */
    --sidebar-width: 274px;
    --topbar-height: 72px;
    --card-radius: 11px;

    /* Kopfzeile und Seitenmenü (Settings → Erscheinungsbild überschreibt diese Werte) */
    --topbar-bg: var(--brand);
    --topbar-text: #ffffff;
    --nav-bg: var(--surface);
    --logo-text: var(--ink);
    --nav-text: var(--muted);
    --nav-hover-bg: var(--accent-soft);
    --nav-hover-text: var(--brand);
    --nav-active-bg: var(--accent);
    --nav-active-text: var(--brand-hover);
    --nav-font-size: 14px;
    --nav-weight: 500;
    --nav-active-weight: 700;
    --nav-min-height: 43px;
    --nav-radius: 7px;
    --nav-section-color: var(--ink);
    --nav-section-size: 12px;
    --nav-section-weight: 700;
    --nav-section-gap: 24px;

    --bs-body-font-family: var(--font-sans);
    --bs-body-color: var(--ink);
    --bs-body-bg: var(--background);
    --bs-primary: var(--brand);
    --bs-primary-rgb: 184, 50, 50;
    --bs-link-color: var(--brand);
    --bs-link-hover-color: var(--brand-hover);
    font-family: var(--font-sans);
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body { margin: 0; color: var(--ink); background: var(--background); font-family: var(--font-sans); font-size: 16px; line-height: 1.5; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: inherit; }

/* Rahmen */
.app-shell { min-height: 100vh; display: flex; }
.page-shell { width: calc(100% - var(--sidebar-width)); min-width: 0; min-height: 100vh; margin-left: var(--sidebar-width); }

/* Seitenmenü */
.sidebar { position: fixed; inset: 0 auto 0 0; z-index: 30; width: var(--sidebar-width); display: flex; flex-direction: column; color: var(--nav-text); background: var(--nav-bg); border-right: 1px solid var(--line); }
.brand { min-height: 92px; display: flex; flex-direction: column; justify-content: center; gap: 6px; padding: 16px 24px; overflow: hidden; text-decoration: none; border-bottom: 1px solid var(--line); }
.brand-logo { display: block; width: 168px; max-width: 100%; height: auto; margin: 0; }
/* Logo im Seitenmenü: Foto plus Schriftzug als Text, damit die Farbe zum Menü passt (Settings → Erscheinungsbild) */
.brand-lockup { display: flex; align-items: center; gap: 8px; }
.brand-mark { display: block; width: 50px; height: 50px; flex-shrink: 0; }
.brand-word { color: var(--logo-text); font-family: Georgia, "Times New Roman", serif; font-size: 27px; line-height: 1; letter-spacing: -.02em; }
.brand-dot { color: var(--brand); }
.brand-subtext { color: var(--nav-text); font-size: .75rem; font-weight: 600; letter-spacing: .04em; }

.main-nav { flex: 1; padding: 18px 14px 24px; overflow-y: auto; font-size: var(--nav-font-size); }
.nav-link { width: 100%; min-height: var(--nav-min-height); display: flex; align-items: center; gap: 13px; padding: 0 14px; border: 0; border-radius: var(--nav-radius); color: var(--nav-text); background: transparent; font-size: var(--nav-font-size); font-weight: var(--nav-weight); text-decoration: none; text-align: left; transition: color .16s, background .16s; }
.nav-link i { width: 21px; text-align: center; flex-shrink: 0; }
.nav-link + .nav-link { margin-top: 4px; }
.nav-link:hover { color: var(--nav-hover-text); background: var(--nav-hover-bg); }
.nav-link.is-active { color: var(--nav-active-text); background: var(--nav-active-bg); font-weight: var(--nav-active-weight); }
.nav-section { margin-top: var(--nav-section-gap); }
.nav-section-title { display: block; margin: 0; letter-spacing: 0; padding: 0 14px 9px; color: var(--nav-section-color); font-size: var(--nav-section-size); font-weight: var(--nav-section-weight); line-height: 1.3; text-transform: uppercase; text-decoration: none; }
a.nav-section-title:hover { color: var(--nav-hover-text); }
.nav-sub-link { padding-left: 14px; }

.sidebar-footer { display: grid; gap: 8px; padding: 21px 26px 25px; color: color-mix(in srgb, var(--nav-text) 75%, var(--nav-bg)); font-size: .7rem; letter-spacing: .08em; border-top: 1px solid var(--line); }
.version-badge { width: max-content; padding: 4px 8px; color: var(--brand-hover); background: var(--accent-soft); border: 1px solid var(--accent-line); border-radius: 5px; letter-spacing: .03em; }

/* Kopfzeile */
.topbar { height: var(--topbar-height); display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 0 36px; color: var(--topbar-text); background: var(--topbar-bg); box-shadow: 0 2px 5px color-mix(in srgb, var(--topbar-bg) 25%, transparent); }
.breadcrumb { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; min-width: 0; margin: 0; color: var(--topbar-text); font-size: .95rem; font-weight: 700; }
.breadcrumb span, .breadcrumb b, .breadcrumb a { color: color-mix(in srgb, var(--topbar-text) 78%, transparent); font-weight: 500; text-decoration: none; }
.breadcrumb a:hover { color: var(--topbar-text); }
.breadcrumb .breadcrumb-current { color: var(--topbar-text); font-weight: 700; }
.mobile-menu { display: none; width: 42px; height: 42px; padding: 10px; border: 1px solid color-mix(in srgb, var(--topbar-text) 40%, transparent); border-radius: 8px; background: color-mix(in srgb, var(--topbar-text) 10%, transparent); }
.mobile-menu span { display: block; height: 2px; margin: 4px 0; background: var(--topbar-text); }

/* Inhalt */
.content { max-width: 1480px; margin: 0 auto; padding: 36px; }
.page-heading { margin-bottom: 27px; }
.eyebrow, .panel-kicker { display: block; color: var(--brand); font-size: .72rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }
h1 { margin: 4px 0 0; font-family: var(--font-display); font-size: clamp(1.75rem, 2.6vw, 2.3rem); font-weight: 400; line-height: 1.15; letter-spacing: -.01em; }
h2 { margin: 3px 0 0; font-size: 1.15rem; font-weight: 600; letter-spacing: -.015em; }
.muted { color: var(--muted); font-size: .82rem; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--card-radius); box-shadow: var(--shadow); }
.panel-header { min-height: 78px; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 18px 23px; border-bottom: 1px solid var(--line); }
.panel-body { margin: 0; padding: 23px; }
.panel-accent { background: var(--accent); border-color: var(--accent-line); box-shadow: none; }
.workspace-panel { min-height: 520px; }
.component-stack { display: grid; gap: 22px; }
.component-stack > .alert { margin: 0; }
.component-row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }

/* Tabellen */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .86rem; }
th { padding: 13px 22px; color: var(--muted); background: var(--surface-muted); font-size: .7rem; letter-spacing: .08em; text-align: left; text-transform: uppercase; }
td { padding: 16px 22px; border-top: 1px solid var(--line); }
td strong, td small { display: block; }
td small { margin-top: 2px; color: var(--muted); }

/* Status */
.status-pill { display: inline-flex; align-items: center; min-height: 26px; padding: 3px 9px; color: var(--success); background: var(--success-bg); border: 1px solid var(--success-line); border-radius: 999px; font-size: .7rem; font-weight: 700; white-space: nowrap; }
.status-neutral { color: var(--muted); background: #f3efea; border-color: var(--line); }
.status-brand { color: var(--brand-hover); background: var(--accent); border-color: var(--accent-line); }

/* Formulare */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; padding: 25px; }
label > span { display: block; margin-bottom: 7px; color: var(--muted); font-size: .78rem; font-weight: 600; }
input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="search"], input[type="date"], select, textarea { width: 100%; min-height: 44px; padding: 9px 12px; color: var(--ink); background: #fff; border: 1px solid var(--line-strong); border-radius: 8px; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(184, 50, 50, .14); }
textarea { resize: vertical; }
.field-wide { grid-column: 1 / -1; }
.checkbox-label { display: flex; gap: 10px; align-items: center; }
.checkbox-label span { margin: 0; }
.checkbox-label input { accent-color: var(--brand); }
.form-actions { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 19px 25px; background: var(--surface-muted); border-top: 1px solid var(--line); border-radius: 0 0 var(--card-radius) var(--card-radius); }
.form-actions p { margin: 0; color: var(--muted); font-size: .8rem; }

/* Schaltflächen */
.button-primary, .button-secondary, .button-danger { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; padding: 9px 17px; border-radius: 8px; font-size: .82rem; font-weight: 700; text-decoration: none; transition: background .16s, border-color .16s; }
.button-primary { color: #fff; background: var(--brand); border: 1px solid var(--brand); }
.button-primary:hover { color: #fff; background: var(--brand-hover); border-color: var(--brand-hover); }
.button-secondary { color: var(--ink); background: #fff; border: 1px solid var(--line-strong); }
.button-secondary:hover { background: var(--accent-soft); border-color: var(--accent-line); }
.button-danger { color: #fff; background: #8f1d1d; border: 1px solid #8f1d1d; }
.button-danger:hover { background: #6f1616; border-color: #6f1616; }
.button-primary:disabled, .button-secondary:disabled, .button-danger:disabled { opacity: .46; cursor: not-allowed; }

/* Leerzustand */
.empty-state { padding: 45px 25px; text-align: center; }
.empty-state strong, .empty-state p { display: block; }
.empty-state p { max-width: 520px; margin: 6px auto 16px; color: var(--muted); font-size: .82rem; }
.empty-symbol { display: block; margin: 0 auto 12px; color: var(--brand); font-size: 24px; }

/* Bootstrap-Hinweise an das Farbset anpassen */
.alert-primary { color: var(--brand-hover); background: var(--accent); border-color: var(--accent-line); }

/* Bedienhilfen */
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
.topbar :focus-visible { outline-color: var(--topbar-text); }
.skip-link { position: fixed; top: -100px; left: 16px; z-index: 1100; padding: 12px; background: #fff; color: var(--brand); }
.skip-link:focus { top: 12px; }
.sidebar-backdrop { display: none; }
body.menu-open { overflow: hidden; }

@media (max-width: 760px) {
    .sidebar { transform: translateX(-100%); visibility: hidden; z-index: 1040; }
    .menu-open .sidebar { transform: none; visibility: visible; }
    .page-shell { width: 100%; margin-left: 0; }
    .topbar { height: auto; min-height: var(--topbar-height); padding: 12px 18px; gap: 14px; justify-content: flex-start; }
    .mobile-menu { display: block; flex-shrink: 0; }
    .breadcrumb { font-size: .8rem; gap: 6px; }
    .content { padding: 24px 18px; }
    .form-grid { grid-template-columns: 1fr; padding: 20px; }
    .form-actions { align-items: flex-start; flex-direction: column; }
    .workspace-panel { min-height: 60vh; }
    .menu-open .sidebar-backdrop { display: block; position: fixed; inset: 0; z-index: 1030; background: rgb(41 37 36 / 45%); }
}
@media print { .sidebar, .topbar, .skip-link { display: none; } .page-shell { width: 100%; margin: 0; } }

/* Gemeinsamer Bestätigungsdialog */
.confirmation-dialog .modal-dialog { max-width: 520px; }
.confirmation-dialog .modal-content { border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 24px 80px rgba(41, 37, 36, .2); overflow: hidden; }
.confirmation-dialog .modal-header { padding: 24px 24px 0; border: 0; align-items: center; gap: 14px; }
.confirmation-dialog .modal-title { font-size: 1.1rem; font-weight: 700; }
.confirmation-dialog .btn-close { align-self: start; margin-left: auto; }
.confirmation-icon { display: inline-flex; align-items: center; justify-content: center; width: 46px; height: 46px; border-radius: 12px; flex-shrink: 0; color: var(--brand); background: var(--accent-soft); }
.confirmation-dialog.is-destructive .confirmation-icon { color: #8f1d1d; background: var(--accent); }
.confirmation-dialog .modal-body { padding: 20px 24px; font-size: .9rem; line-height: 1.65; }
.confirmation-dialog .modal-body p { margin: 0; }
.confirmation-dialog .confirmation-hint { margin-top: 14px !important; color: var(--muted); font-size: .8rem; }
.confirmation-dialog .modal-footer { padding: 16px 24px; gap: 8px; background: var(--surface-muted); border-color: var(--line); }
code { color: var(--brand-hover); }

/* Benutzerbereich in der Kopfzeile */
.topbar-user { display: flex; align-items: center; gap: 16px; margin-left: auto; flex-shrink: 0; }
.topbar-user form { margin: 0; }
.topbar-user-name { display: inline-flex; align-items: center; gap: 8px; color: color-mix(in srgb, var(--topbar-text) 90%, transparent); font-size: .88rem; font-weight: 500; }
.topbar-logout { display: inline-flex; align-items: center; gap: 8px; min-height: 36px; padding: 6px 12px; color: var(--topbar-text); background: color-mix(in srgb, var(--topbar-text) 10%, transparent); border: 1px solid color-mix(in srgb, var(--topbar-text) 40%, transparent); border-radius: 8px; font-size: .82rem; font-weight: 600; }
.topbar-logout:hover { background: color-mix(in srgb, var(--topbar-text) 20%, transparent); }
@media (max-width: 760px) {
    .topbar-user-name > span, .topbar-logout > span { display: none; }
    .topbar-user { gap: 10px; }
}

/* Anmeldeseite */
.auth-body { min-height: 100vh; display: flex; flex-direction: column; }
.auth-topbar { height: var(--topbar-height); display: flex; align-items: center; padding: 0 36px; color: var(--topbar-text); background: var(--topbar-bg); font-size: .95rem; font-weight: 700; box-shadow: 0 2px 5px rgba(146, 40, 40, .18); }
.auth-main { flex: 1; display: flex; align-items: flex-start; justify-content: center; padding: 64px 18px; }
.auth-card { width: 100%; max-width: 420px; overflow: hidden; }
.auth-brand { display: flex; flex-direction: column; gap: 6px; padding: 22px 28px; border-bottom: 1px solid var(--line); }
.auth-body-inner { padding: 26px 28px 30px; }
.auth-body-inner h1 { margin-bottom: 20px; }
.auth-body-inner p + p { margin-top: 10px; }
.auth-form { display: grid; gap: 16px; }
.auth-submit { width: 100%; margin-top: 6px; }
.auth-alert { margin-bottom: 18px; padding: 10px 14px; font-size: .84rem; }
.auth-hint { margin: -6px 0 18px; color: var(--muted); font-size: .9rem; }
.mfa-code-input { font-size: 1.4rem; font-weight: 700; letter-spacing: .3em; text-align: center; font-variant-numeric: tabular-nums; }
.auth-form .checkbox-label { align-items: flex-start; font-size: .86rem; }
.auth-form .checkbox-label input { margin-top: 3px; }
.auth-help { margin-top: 20px; font-size: .86rem; }
.auth-help summary { color: var(--brand-hover); font-weight: 600; cursor: pointer; }
.auth-help p { margin: 8px 0 0; color: var(--muted); }
.auth-cancel { margin-top: 14px; }
.button-link { padding: 0; color: var(--muted); background: none; border: 0; font-size: .84rem; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.button-link:hover { color: var(--ink); }
.alert-danger { color: #7d1d1d; background: #fbe9e7; border-color: #f0c9c3; }
@media (max-width: 760px) { .auth-topbar { padding: 0 18px; } .auth-main { padding: 32px 16px; } }

/* Formularbausteine */
.field-stack { display: grid; gap: 10px; align-content: center; }
.input-with-action { display: flex; gap: 6px; margin: 0 !important; }
.input-with-action input { flex: 1; min-width: 0; }
.input-with-action .button-secondary { flex-shrink: 0; min-width: 44px; padding: 9px 12px; }
.button-small { min-height: 34px; padding: 6px 12px; font-size: .78rem; white-space: nowrap; }
.icon-button { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; padding: 0; color: var(--muted); background: transparent; border: 1px solid transparent; border-radius: 6px; flex-shrink: 0; }
.icon-button:hover { color: var(--brand); background: var(--accent-soft); border-color: var(--accent-line); }
.icon-button.is-success { color: var(--success); background: var(--success-bg); }
.icon-button.is-error { color: #8f1d1d; background: var(--accent); }
.status-list { display: flex; flex-wrap: wrap; gap: 6px; }
.panel-danger { border-color: var(--accent-line); }
.panel-danger .panel-header { border-bottom: 0; }
.flash-message { margin: 0 0 22px; }
.alert-success { color: var(--success); background: var(--success-bg); border-color: var(--success-line); }
td { vertical-align: middle; }
a.topbar-user-name { text-decoration: none; }
a.topbar-user-name:hover, a.topbar-user-name[aria-current="page"] { color: var(--topbar-text); text-decoration: underline; text-underline-offset: 3px; }
@media (max-width: 760px) {
    .panel-header { flex-wrap: wrap; }
    .panel-header > .component-row { width: 100%; }
}
.dashboard-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 18px; }
.dashboard-tile { display: flex; align-items: center; gap: 16px; padding: 20px 22px; text-decoration: none; transition: border-color .16s, box-shadow .16s; }
.dashboard-tile:hover { border-color: var(--accent-line); box-shadow: 0 4px 14px rgba(146, 40, 40, .08); }
.dashboard-tile > i { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; color: var(--brand); background: var(--accent-soft); border-radius: 10px; font-size: 18px; flex-shrink: 0; }
.dashboard-tile strong, .dashboard-tile small { display: block; }
.dashboard-tile small { color: var(--muted); font-size: .8rem; }
.component-stack > * { min-width: 0; } /* Grid-Kinder dürfen schmaler als ihr Inhalt werden, Tabellen scrollen dann */

/* Tabellen mit class="table-cards" werden auf dem Handy zu Karten; Zellen tragen data-label */
@media (max-width: 760px) {
    .table-cards thead { display: none; }
    .table-cards, .table-cards tbody, .table-cards tr, .table-cards td { display: block; width: 100%; }
    .table-cards tr { padding: 14px 18px; border-top: 1px solid var(--line); }
    .table-cards td { padding: 4px 0; border: 0; }
    .table-cards td[data-label]::before { content: attr(data-label); display: block; color: var(--muted); font-size: .68rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
    .table-cards td.text-end { text-align: left !important; padding-top: 10px; }
    .table-cards .row-actions { justify-content: flex-start; }
    .table-cards tr[hidden] { display: none; }
}

/* Reiter innerhalb einer Seite (Links mit aria-current) */
.page-tabs { display: flex; gap: 24px; flex-wrap: wrap; margin: -6px 0 24px; border-bottom: 1px solid var(--line); }
.page-tabs a { display: inline-flex; align-items: center; gap: 8px; padding: 12px 0; margin-bottom: -1px; color: var(--muted); border-bottom: 3px solid transparent; font-size: .88rem; font-weight: 500; text-decoration: none; }
.page-tabs a:hover { color: var(--brand); }
.page-tabs a[aria-current="page"] { color: var(--brand-hover); border-bottom-color: var(--brand); font-weight: 700; }
.tab-count { min-width: 22px; padding: 1px 7px; color: var(--muted); background: #f3efea; border-radius: 999px; font-size: .72rem; font-weight: 700; text-align: center; }
.page-tabs a[aria-current="page"] .tab-count { color: var(--brand-hover); background: var(--accent); }

/* Kennzahlen */
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.stat { padding: 14px 16px; background: var(--surface-muted); border: 1px solid var(--line); border-radius: 9px; }
.stat strong { display: block; font-size: 1.5rem; line-height: 1.2; }
.stat span { color: var(--muted); font-size: .78rem; }
fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
legend { float: none; width: auto; margin-bottom: 10px; color: var(--muted); font-size: .78rem; font-weight: 600; }
.setup-sql { margin: 14px 0; padding: 12px 14px; white-space: pre-wrap; overflow-wrap: anywhere; background: var(--surface-muted); border: 1px solid var(--line); border-radius: 8px; font-size: .78rem; }
.setup-sql code { color: var(--ink); }

/* Dashboard-Kennzahlen */
.stat-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 18px; }
.stat-card { display: flex; align-items: center; gap: 16px; padding: 20px 22px; text-decoration: none; transition: border-color .16s, box-shadow .16s; }
.stat-card:hover { border-color: var(--accent-line); box-shadow: 0 4px 14px rgba(146, 40, 40, .08); }
.stat-card > i { display: inline-flex; align-items: center; justify-content: center; width: 48px; height: 48px; color: var(--brand); background: var(--accent-soft); border-radius: 12px; font-size: 20px; flex-shrink: 0; }
.stat-card strong { display: block; font-family: var(--font-display); font-size: 2rem; font-weight: 400; line-height: 1.1; }
.stat-card small { color: var(--muted); font-size: .82rem; }
.db-figure { color: var(--muted); font-size: .9rem; white-space: nowrap; }
.db-figure strong { color: var(--ink); }
.db-meter { height: 14px; overflow: hidden; background: #efe9e2; border-radius: 999px; }
.db-meter span { display: block; width: 0; height: 100%; border-radius: 999px; background: var(--success); transition: width .4s; }
.db-meter.is-warn span { background: #c98a1b; }
.db-meter.is-full span { background: var(--brand); }
.db-caption { display: flex; justify-content: space-between; margin: 8px 0 18px; color: var(--muted); font-size: .8rem; }
.db-table th, .db-table td { padding: 10px 14px; }
.db-subtitle { margin: 22px 0 8px; font-size: .9rem; font-weight: 700; }
.db-warn { color: var(--brand-hover); font-weight: 600; }

/* Rollen und Dokumenten-Datenbank (Users) */
.role-badge { display: inline-flex; align-items: center; min-height: 24px; padding: 3px 10px; color: #fff; background: var(--brand); border-radius: 999px; font-size: .66rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; white-space: nowrap; }
.role-badge.role-superuser { color: var(--brand-hover); background: var(--accent); border: 1px solid var(--accent-line); }
.role-badge.role-user { color: var(--muted); background: #f3efea; border: 1px solid var(--line); }
.docdb-counts { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 16px; }
.docdb-counts > div { padding: 14px 16px; background: var(--surface-muted); border: 1px solid var(--line); border-radius: 9px; }
.docdb-counts strong { display: block; font-size: 1.4rem; line-height: 1.1; }
.docdb-counts small { color: var(--muted); font-size: .76rem; }
.docdb-actions { margin-bottom: 10px; }
.docdb-actions form { margin: 0; }

/* Löschknopf in Listenzeilen */
.row-actions { display: inline-flex; align-items: center; justify-content: flex-end; gap: 6px; }
.row-delete { position: relative; display: inline-flex; margin: 0; }
.row-delete-placeholder { display: inline-block; width: 30px; }
.icon-button-danger:hover, .icon-button-danger:focus-visible { color: #fff; background: var(--brand); border-color: var(--brand); }

/* Listen (Password Manager, Document Manager, Notizen): Filter-Knopf, Chips, Blättern, Filter-Popup */
.list-toolbar { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px 20px; padding: 14px 23px; background: var(--surface-muted); border-bottom: 1px solid var(--line); }
.list-toolbar-filters { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; min-width: 0; flex: 1 1 320px; }
.list-filter-button { min-height: 36px; padding: 6px 14px; }
.filter-badge { display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px; margin-left: 2px; padding: 0 6px; color: #fff; background: var(--brand); border-radius: 999px; font-size: .7rem; font-weight: 700; }
.list-toolbar .app-filter-chip { display: inline-flex; align-items: center; gap: 5px; text-decoration: none; }
.list-toolbar .app-filter-chip .chip-label { color: var(--muted); font-weight: 600; }
.list-toolbar .app-filter-chip i { font-size: .7rem; }
.list-clear { color: var(--muted); font-size: .78rem; text-decoration: underline; text-underline-offset: 3px; }
.list-clear:hover { color: var(--brand); }
[data-list-area][aria-busy="true"] { opacity: .55; transition: opacity .15s; }

.pager { display: flex; align-items: center; flex-wrap: wrap; gap: 10px 16px; margin-left: auto; }
.pager-info { color: var(--muted); font-size: .82rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.pager-pages { display: flex; align-items: center; gap: 4px; margin: 0; padding: 0; list-style: none; }
.pager-link { display: inline-flex; align-items: center; justify-content: center; min-width: 34px; height: 34px; padding: 0 9px; color: var(--ink); background: var(--surface); border: 1px solid var(--line-strong); border-radius: 8px; font-size: .84rem; font-weight: 600; text-decoration: none; font-variant-numeric: tabular-nums; }
a.pager-link:hover { color: var(--brand); background: var(--accent-soft); border-color: var(--accent-line); }
.pager-link.is-current { color: #fff; background: var(--brand); border-color: var(--brand); }
.pager-link.is-disabled { color: var(--line-strong); background: transparent; }
.pager-gap { padding: 0 3px; color: var(--muted); }
.pager-size { display: flex; align-items: center; gap: 8px; margin: 0; }
.pager-size label { color: var(--muted); font-size: .78rem; font-weight: 600; white-space: nowrap; }
.pager-size select { width: auto; min-height: 34px; padding: 4px 28px 4px 10px; font-size: .84rem; }

/* Filter-Popup: Anfangsbuchstabe 0–Z */
.letter-filter { margin: 0; padding: 0; border: 0; min-width: 0; }
.letter-filter legend { float: none; margin: 0 0 6px; color: var(--muted); font-size: .8rem; }
.letter-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(38px, 1fr)); gap: 5px; }
.letter-option { position: relative; display: block; margin: 0; cursor: pointer; }
.letter-option input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.letter-option span { display: flex; align-items: center; justify-content: center; height: 34px; color: var(--ink); background: #fff; border: 1px solid var(--line-strong); border-radius: 7px; font-size: .8rem; font-weight: 600; }
.letter-wide { grid-column: span 2; }
.letter-option:hover span { color: var(--brand); background: var(--accent-soft); border-color: var(--accent-line); }
.letter-option input:checked + span { color: #fff; background: var(--brand); border-color: var(--brand); }
.letter-option input:focus-visible + span { outline: 2px solid var(--brand); outline-offset: 2px; }
.letter-option.is-empty span { color: var(--line-strong); background: transparent; border-style: dashed; }
.letter-option.is-empty input:disabled { cursor: not-allowed; }

@media (max-width: 760px) {
    .list-toolbar { padding: 12px 16px; }
    .pager { width: 100%; justify-content: space-between; margin-left: 0; }
    .pager-info { width: auto; }
    .swipe-hint { flex: 1 1 auto; justify-content: flex-end; }
}
.app-filter-fields .letter-option input { width: 100%; height: 100%; margin: 0; padding: 0; } /* filters.css setzt Höhe und Rand für alle Eingaben */

/* Wischen zum Blättern (Touch): Liste folgt dem Finger, neue Seite gleitet herein */
[data-list-area] { --swipe-x: 0px; }
[data-list-area].is-dragging { transform: translateX(var(--swipe-x)); transition: none; }
[data-list-area]:not(.is-dragging) { transition: transform .2s ease-out; }
[data-list-area].swipe-in-next { animation: swipe-in-next .28s ease-out; }
[data-list-area].swipe-in-prev { animation: swipe-in-prev .28s ease-out; }
@keyframes swipe-in-next { from { transform: translateX(48px); opacity: .3; } to { transform: none; opacity: 1; } }
@keyframes swipe-in-prev { from { transform: translateX(-48px); opacity: .3; } to { transform: none; opacity: 1; } }
.swipe-hint { display: none; color: var(--muted); font-size: .74rem; white-space: nowrap; }
@media (hover: none) and (pointer: coarse) { .swipe-hint { display: inline-flex; align-items: center; gap: 5px; } }
@media (prefers-reduced-motion: reduce) { [data-list-area].swipe-in-next, [data-list-area].swipe-in-prev { animation: none; } }
[data-list] { overflow-x: hidden; overflow-x: clip; } /* beim Mitziehen nicht seitlich scrollen */

/* Zeilen zum Aufklappen (table-cards is-collapsible): am Handy nur Name und Aktionen, Tipp auf den Namen zeigt den Rest */
.row-toggle { display: block; margin: 0; padding: 0; color: inherit; background: none; border: 0; font: inherit; text-align: left; cursor: default; }
.row-toggle-icon { display: none; }
.row-extra { display: block; }
.row-extra > small { display: block; }
@media (max-width: 760px) {
    .table-cards.is-collapsible tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 12px; align-items: center; }
    .table-cards.is-collapsible td { grid-column: 1 / -1; }
    .table-cards.is-collapsible td.row-main { grid-column: 1; grid-row: 1; padding: 2px 0; }
    .table-cards.is-collapsible td.text-end { grid-column: 2; grid-row: 1; padding: 0; text-align: right !important; }
    .table-cards.is-collapsible .row-actions { justify-content: flex-end; }
    .table-cards.is-collapsible tr:not(.is-open) > td:not(.row-main):not(.text-end),
    .table-cards.is-collapsible tr:not(.is-open) .row-extra { display: none; }
    .table-cards.is-collapsible tr.is-open > td.row-main { padding-bottom: 6px; }
    .table-cards.is-collapsible tr.is-open { background: var(--surface-muted); }
    .row-toggle { display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; min-height: 40px; cursor: pointer; -webkit-tap-highlight-color: transparent; }
    .row-toggle strong { min-width: 0; overflow-wrap: anywhere; }
    .row-toggle-icon { display: inline-block; flex-shrink: 0; color: var(--muted); font-size: .72rem; transition: transform .2s; }
    tr.is-open .row-toggle-icon { transform: rotate(180deg); }
    .row-toggle:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 4px; }
}
.stat-alert { color: var(--brand); font-weight: 700; }
@media (max-width: 760px) {
    /* Reiter am Handy in einer Zeile, waagerecht wischbar */
    .page-tabs { flex-wrap: nowrap; gap: 20px; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
    .page-tabs::-webkit-scrollbar { display: none; }
    .page-tabs a { flex-shrink: 0; white-space: nowrap; }
}
.mfa-code-input::placeholder { color: var(--line-strong); font-weight: 400; }
.form-actions > button, .form-actions > .component-row { flex-shrink: 0; }

/* Laufende Stoppuhr (Aufgaben Manager) oben auf jeder Seite */
.timer-dot { display: inline-block; width: 9px; height: 9px; background: currentColor; border-radius: 50%; flex-shrink: 0; }
[data-timer-live] .timer-dot { animation: timer-pulse 1.6s ease-in-out infinite; }
@keyframes timer-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .25; } }
@media (prefers-reduced-motion: reduce) { [data-timer-live] .timer-dot { animation: none; } }
.topbar-timer { display: inline-flex; align-items: center; gap: 8px; min-height: 36px; max-width: 320px; padding: 6px 12px; color: var(--topbar-text); background: color-mix(in srgb, var(--topbar-text) 16%, transparent); border: 1px solid color-mix(in srgb, var(--topbar-text) 45%, transparent); border-radius: 999px; font-size: .82rem; font-weight: 600; text-decoration: none; }
.topbar-timer:hover { color: var(--topbar-text); background: color-mix(in srgb, var(--topbar-text) 26%, transparent); }
.topbar-timer-clock { font-variant-numeric: tabular-nums; font-weight: 700; }
.topbar-timer-name { min-width: 0; overflow: hidden; color: color-mix(in srgb, var(--topbar-text) 85%, transparent); font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 900px) { .topbar-timer-name { display: none; } }

/* Sprachschalter in der Kopfzeile */
.lang-switch { display: inline-flex; padding: 2px; background: color-mix(in srgb, var(--topbar-text) 10%, transparent); border: 1px solid color-mix(in srgb, var(--topbar-text) 40%, transparent); border-radius: 8px; }
.lang-switch button { min-width: 34px; min-height: 30px; padding: 3px 8px; color: color-mix(in srgb, var(--topbar-text) 88%, transparent); background: transparent; border: 0; border-radius: 6px; font-size: .74rem; font-weight: 700; letter-spacing: .06em; }
.lang-switch button:hover { color: var(--topbar-text); background: color-mix(in srgb, var(--topbar-text) 16%, transparent); }
.lang-switch button.is-active { color: var(--topbar-bg); background: var(--topbar-text); }
.auth-topbar { justify-content: space-between; }

/* Formular im Popup (views/partials/form-modal.php) */
.form-modal .modal-content { border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 24px 80px rgba(41, 37, 36, .2); overflow: hidden; }
.form-modal .modal-header { padding: 18px 25px; border-color: var(--line); }
.form-modal .modal-title { display: flex; align-items: center; gap: 10px; font-size: 1.15rem; font-weight: 700; }
.form-modal .modal-title i { color: var(--brand); font-size: .9em; }
.form-modal .modal-body { padding: 0; }
.form-modal-error { margin: 20px 25px 0; }
.form-modal .modal-footer { gap: 10px; padding: 16px 25px; background: var(--surface-muted); border-color: var(--line); }
.form-modal .modal-footer p { flex: 1 1 200px; margin: 0; color: var(--muted); font-size: .8rem; }
.form-modal .modal-footer > * { margin: 0; }
@media (max-width: 640px) {
    .form-modal .modal-header, .form-modal .modal-footer { padding-left: 20px; padding-right: 20px; }
    .form-modal .modal-footer p { flex-basis: 100%; }
    .form-modal .modal-footer button { flex: 1 1 0; justify-content: center; }
    .form-modal-error { margin: 16px 20px 0; }
}
