:root {
    --bg: #eef2f7;
    --surface: #ffffff;
    --surface-soft: #f6f8fb;
    --text: #172033;
    --muted: #6d778b;
    --line: #e2e8f0;
    --primary: #1f5eff;
    --primary-dark: #1749c6;
    --navy: #0f1b2d;
    --success: #159a66;
    --danger: #c94b5d;
    --shadow: 0 24px 60px rgba(15, 27, 45, 0.10);
    --radius: 18px;
}

* { box-sizing: border-box; }

html { min-height: 100%; }

body {
    margin: 0;
    min-height: 100vh;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--text);
    background: var(--bg);
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, p { margin-top: 0; }

button, input { font: inherit; }

label {
    display: block;
    margin: 18px 0 8px;
    font-size: 0.9rem;
    font-weight: 700;
}

input {
    width: 100%;
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--text);
    border-radius: 12px;
    padding: 13px 14px;
    outline: none;
    transition: border-color .2s, box-shadow .2s;
}

input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(31, 94, 255, .12);
}

.card {
    background: var(--surface);
    border: 1px solid rgba(226, 232, 240, .9);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.btn {
    border: 0;
    border-radius: 12px;
    padding: 13px 16px;
    font-weight: 800;
    cursor: pointer;
    transition: transform .15s ease, background .15s ease;
}

.btn:hover { transform: translateY(-1px); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-full { width: 100%; margin-top: 22px; }

.eyebrow {
    display: inline-block;
    margin-bottom: 8px;
    color: var(--primary);
    font-size: .74rem;
    font-weight: 900;
    letter-spacing: .12em;
    text-transform: uppercase;
}

.logo-mark {
    display: inline-grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border-radius: 13px;
    background: var(--primary);
    color: white;
    font-weight: 900;
}

.alert {
    margin: 18px 0;
    padding: 12px 14px;
    border-radius: 12px;
    font-size: .92rem;
}

.alert-error { background: #fff0f2; color: #9f3344; border: 1px solid #ffd6dc; }
.alert-success { background: #effcf6; color: #0f7650; border: 1px solid #c9f1df; }

.helper-text { margin: 18px 0 0; color: var(--muted); font-size: .88rem; line-height: 1.55; }
.text-link { display: inline-block; margin-top: 18px; font-weight: 700; }

.login-page {
    background:
        radial-gradient(circle at 12% 18%, rgba(31, 94, 255, .18), transparent 34%),
        linear-gradient(135deg, #0d1728 0%, #12233d 45%, #eef2f7 45%, #eef2f7 100%);
}

.login-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(420px, .75fr);
}

.login-brand-panel {
    min-height: 100vh;
    padding: clamp(40px, 7vw, 90px);
    color: #fff;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.login-brand-panel .eyebrow { color: #82a7ff; }
.login-brand-panel h1 { font-size: clamp(3rem, 7vw, 6.5rem); margin-bottom: 24px; letter-spacing: -.05em; }
.login-brand-panel p { max-width: 700px; font-size: clamp(1.05rem, 2vw, 1.35rem); color: #c5d2e8; line-height: 1.7; }
.brand-note { color: #8fa1bf; font-size: .95rem; }

.login-card-wrap {
    display: grid;
    place-items: center;
    padding: 30px;
}

.login-card { width: min(460px, 100%); padding: 34px; }

.card-heading {
    display: flex;
    gap: 14px;
    align-items: center;
    margin-bottom: 22px;
}
.card-heading h1, .card-heading h2 { margin-bottom: 4px; }
.card-heading p { color: var(--muted); margin: 0; }

.center-page { display: grid; place-items: center; padding: 30px; }
.setup-container { width: min(560px, 100%); }
.setup-card { padding: 34px; }

@media (max-width: 820px) {
    .login-page { background: #eef2f7; }
    .login-shell { grid-template-columns: 1fr; }
    .login-brand-panel { min-height: auto; background: linear-gradient(135deg, #0f1b2d, #15345e); padding: 38px 24px; }
    .login-brand-panel h1 { font-size: 3rem; }
    .login-card-wrap { padding: 24px; }
}

@media (max-width: 560px) {
    .login-card, .setup-card { padding: 24px 20px; }
}

/* Registrierung und E-Mail-Bestätigung */
.auth-links {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 18px;
    align-items: center;
    margin-top: 4px;
}

.auth-links .text-link {
    margin-top: 18px;
}

.field-hint {
    margin: 7px 0 0;
    color: var(--muted);
    font-size: .82rem;
}


/* Admin: Benutzer Konten */
.home-sidebar .home-nav {
    display: grid;
    gap: 7px;
}

.home-sidebar .home-nav a {
    margin: 0;
}

.home-sidebar .home-nav a:not([aria-current="page"]) {
    background: transparent;
    box-shadow: none;
    color: var(--muted);
}

.home-sidebar .home-nav a:not([aria-current="page"]):hover {
    background: var(--surface-soft);
    color: var(--text);
}

.home-sidebar .home-nav .home-nav-section-label {
    display: block;
    margin: 14px 10px 2px;
    color: var(--muted);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: .13em;
    line-height: 1.2;
    text-transform: uppercase;
}

.home-account-card {
    margin-top: 18px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface-soft);
}

.home-account-card span,
.home-account-card small {
    display: block;
    color: var(--muted);
    font-size: 12px;
}

.home-account-card strong {
    display: block;
    margin: 4px 0;
    font-size: 14px;
    overflow-wrap: anywhere;
}

.home-account-card small {
    text-transform: lowercase;
}

.admin-users-main {
    max-width: 1500px;
}

.admin-page-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 22px;
    margin-bottom: 22px;
}

.admin-page-heading .home-intro {
    margin-bottom: 0;
}

.data-badge {
    display: inline-flex;
    align-items: center;
    width: fit-content;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: var(--surface-soft);
    color: var(--text);
    font-size: 12px;
    font-weight: 800;
    white-space: nowrap;
}


.account-stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    margin: 18px 0;
}

.account-stat {
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface);
}

.account-stat span {
    display: block;
    color: var(--muted);
    font-size: 13px;
}

.account-stat strong {
    display: block;
    margin-top: 7px;
    font-size: 26px;
    font-weight: 650;
}

.admin-card {
    margin-top: 18px;
    padding: 22px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface);
}

.admin-card-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 18px;
}

.admin-card-heading h2 {
    margin: 3px 0 5px;
    font-size: 20px;
}

.admin-card-heading p {
    margin: 0;
    color: var(--muted);
    font-size: 14px;
}

.small-action-link {
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--text);
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
}

.small-action-link:hover {
    background: var(--surface-soft);
    text-decoration: none;
}

textarea {
    width: 100%;
    min-height: 150px;
    resize: vertical;
    border: 1px solid var(--line);
    background: var(--bg);
    color: var(--text);
    border-radius: 12px;
    padding: 13px 14px;
    outline: none;
    font: inherit;
    line-height: 1.55;
    transition: border-color .2s, box-shadow .2s;
}

textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(31, 94, 255, .12);
}

.mail-compose .btn {
    margin-top: 18px;
}

.users-table-wrap {
    width: 100%;
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: 10px;
}

.users-table {
    width: 100%;
    min-width: 1080px;
    border-collapse: collapse;
    font-size: 13px;
}

.users-table th,
.users-table td {
    padding: 14px 13px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
}

.users-table th {
    background: var(--surface-soft);
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .045em;
    text-transform: uppercase;
    white-space: nowrap;
}

.users-table tbody tr:last-child td {
    border-bottom: 0;
}

.users-table tbody tr:hover td {
    background: var(--surface-soft);
}

.users-table td strong,
.users-table td small {
    display: block;
}

.users-table td small {
    margin-top: 5px;
    color: var(--muted);
    font-size: 11px;
    white-space: nowrap;
}

.email-value {
    overflow-wrap: anywhere;
}

.data-badge {
    padding: 5px 8px;
    font-size: 11px;
}

.role-badge {
    text-transform: lowercase;
}

.status-ok {
    border-color: rgba(21, 154, 102, .35);
    background: rgba(21, 154, 102, .1);
    color: var(--success);
}

.status-warn {
    border-color: rgba(207, 137, 37, .35);
    background: rgba(207, 137, 37, .1);
    color: #c68120;
}

.status-blocked {
    border-color: rgba(201, 75, 93, .35);
    background: rgba(201, 75, 93, .1);
    color: var(--danger);
}

.account-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    min-width: 190px;
}

.account-actions form {
    margin: 0;
}

.table-action {
    display: inline-flex;
    align-items: center;
    min-height: 32px;
    padding: 6px 9px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-size: 12px;
    font-weight: 750;
    cursor: pointer;
    text-decoration: none;
}

.table-action:hover {
    background: var(--surface-soft);
    text-decoration: none;
}

.danger-action {
    border-color: rgba(201, 75, 93, .4);
    color: var(--danger);
}

.success-action {
    border-color: rgba(21, 154, 102, .4);
    color: var(--success);
}

.disabled-action {
    cursor: default;
    color: var(--muted);
    opacity: .7;
}

.empty-table {
    padding: 28px !important;
    color: var(--muted);
    text-align: center !important;
}

@media (max-width: 900px) {
    .account-stats {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 560px) {
    .admin-page-heading,
    .admin-card-heading {
        display: block;
    }

    .small-action-link {
        margin-top: 12px;
    }

    .account-stats {
        grid-template-columns: 1fr 1fr;
    }

    .admin-card {
        padding: 16px;
    }
}


/* Sidebar-Abschluss: angemeldetes Konto steht als letztes Element ganz unten. */
.sidebar-account-bottom {
    margin-top: 12px;
}

/* Passwort-Zurücksetzung */
.password-link-row {
    display: flex;
    justify-content: flex-end;
    margin-top: 8px;
}

.password-link-row .text-link {
    margin-top: 0;
    font-size: 13px;
}

/* Admin: E-Mail-Verlauf */
.history-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-end;
    margin-bottom: 18px;
}

.history-filters > div {
    min-width: 180px;
}

.history-filters label {
    margin-top: 0;
}

select {
    width: 100%;
    border: 1px solid var(--line);
    background: var(--bg);
    color: var(--text);
    border-radius: 12px;
    padding: 13px 38px 13px 14px;
    outline: none;
    font: inherit;
}

select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(31, 94, 255, .12);
}

.history-filters .btn,
.history-filters .small-action-link {
    min-height: 46px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}


.delete-action {
    border-color: rgba(201, 75, 93, .55);
    background: rgba(201, 75, 93, .06);
}

@media (max-width: 560px) {
    .history-filters {
        display: grid;
        grid-template-columns: 1fr;
    }

    .history-filters > div {
        min-width: 0;
    }
}

/* E-Mail-Verlauf als echte Nachrichtenansicht */
.email-history-main { max-width: 1220px; }
.email-history-toolbar { margin-bottom: 18px; }
.mail-log-list { display: grid; gap: 16px; }
.mail-log-card {
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--surface);
    overflow: hidden;
    box-shadow: 0 8px 30px rgba(15, 23, 42, .04);
}
.mail-log-header {
    display: flex;
    gap: 14px;
    align-items: flex-start;
    padding: 20px 22px 16px;
    border-bottom: 1px solid var(--line);
}
.mail-log-type-icon {
    display: grid;
    place-items: center;
    flex: 0 0 42px;
    width: 42px;
    height: 42px;
    border-radius: 11px;
    background: var(--surface-soft);
    border: 1px solid var(--line);
    font-size: 18px;
    font-weight: 800;
}
.mail-log-heading { min-width: 0; flex: 1; }
.mail-log-heading h2 {
    margin: 8px 0 4px;
    font-size: 19px;
    line-height: 1.3;
    overflow-wrap: anywhere;
}
.mail-log-heading time { color: var(--muted); font-size: 12px; }
.mail-log-badges { display: flex; flex-wrap: wrap; gap: 7px; }
.mail-log-envelope {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    padding: 16px 22px;
    background: var(--surface-soft);
    border-bottom: 1px solid var(--line);
}
.mail-log-envelope > div {
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr);
    column-gap: 8px;
    align-items: baseline;
}
.mail-log-envelope span { color: var(--muted); font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; }
.mail-log-envelope strong { overflow-wrap: anywhere; }
.mail-log-envelope small { grid-column: 2; margin-top: 3px; color: var(--muted); overflow-wrap: anywhere; }
.mail-log-paper {
    margin: 20px 22px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--bg);
    overflow: hidden;
}
.mail-log-paper-subject {
    display: grid;
    grid-template-columns: 68px minmax(0, 1fr);
    gap: 10px;
    padding: 13px 16px;
    border-bottom: 1px solid var(--line);
    background: var(--surface-soft);
}
.mail-log-paper-subject span { color: var(--muted); font-size: 12px; font-weight: 800; text-transform: uppercase; }
.mail-log-paper-subject strong { overflow-wrap: anywhere; }
.mail-log-body {
    padding: 22px 20px 26px;
    min-height: 100px;
    line-height: 1.75;
    font-size: 14px;
    white-space: normal;
    overflow-wrap: anywhere;
}
.mail-log-error {
    margin: 0 22px 20px;
    padding: 13px 15px;
    border: 1px solid rgba(201, 75, 93, .35);
    border-radius: 10px;
    background: rgba(201, 75, 93, .07);
    color: var(--danger);
}
.mail-log-error strong, .mail-log-error span { display: block; }
.mail-log-error span { margin-top: 5px; font-size: 13px; overflow-wrap: anywhere; }
.mail-log-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 22px;
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-size: 12px;
}
.empty-mail-history { text-align: center; color: var(--muted); }

@media (max-width: 760px) {
    .mail-log-envelope { grid-template-columns: 1fr; }
    .mail-log-footer { align-items: flex-start; flex-direction: column; }
}

/* Benutzerkonten: Konto-erstellen-Modal */
.create-account-button {
    flex: 0 0 auto;
    min-height: 44px;
    white-space: nowrap;
}

body.modal-open {
    overflow: hidden;
}

.account-modal {
    position: fixed;
    inset: 0;
    z-index: 1200;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.account-modal.is-open {
    display: flex;
}

.account-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(2, 6, 23, .62);
    backdrop-filter: blur(4px);
}

.account-modal-dialog {
    position: relative;
    z-index: 1;
    width: min(100%, 560px);
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    padding: 24px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: var(--surface);
    box-shadow: 0 28px 80px rgba(2, 6, 23, .28);
}

.account-modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
}

.account-modal-header h2 {
    margin: 4px 0 0;
    font-size: 24px;
}

.account-modal-close {
    width: 38px;
    height: 38px;
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface-soft);
    color: var(--text);
    font-size: 25px;
    line-height: 1;
    cursor: pointer;
}

.account-modal-close:hover {
    background: var(--bg);
}

.account-modal-intro {
    margin: 14px 0 20px;
    color: var(--muted);
    line-height: 1.6;
}

.account-modal-form label {
    margin-top: 15px;
}

.account-modal-form label:first-of-type {
    margin-top: 0;
}

.account-modal-form .field-hint {
    margin: 7px 0 0;
}

.account-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 24px;
}

.modal-secondary-button {
    border: 1px solid var(--line);
    background: var(--surface-soft);
    color: var(--text);
}

.modal-secondary-button:hover {
    background: var(--bg);
}

@media (max-width: 680px) {
    .admin-page-heading {
        align-items: stretch;
    }

    .create-account-button {
        width: 100%;
    }

    .account-modal {
        padding: 10px;
        align-items: flex-end;
    }

    .account-modal-dialog {
        width: 100%;
        max-height: calc(100vh - 20px);
        border-radius: 16px 16px 10px 10px;
        padding: 20px;
    }

    .account-modal-actions {
        display: grid;
        grid-template-columns: 1fr;
    }

    .account-modal-actions .btn {
        width: 100%;
    }
}

/* Einnahmen: ruhige Verwaltungsansicht mit Kennzahlen, Filtern und Bearbeitungsmodal */
.income-redesign {
    max-width: 1500px;
    padding-right: clamp(22px, 4vw, 56px);
}
.income-page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 26px;
}
.income-page-header h1 { margin-bottom: 6px; }
.income-page-header .home-intro { margin-bottom: 0; }
.income-create-button {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    white-space: nowrap;
}
.income-summary-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}
.income-summary-card {
    min-width: 0;
    padding: 18px 19px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--surface);
}
.income-summary-card strong {
    display: block;
    margin: 8px 0 5px;
    font-size: clamp(20px, 2vw, 26px);
    line-height: 1.05;
    letter-spacing: -.025em;
}
.income-summary-card small,
.income-summary-label { color: var(--muted); }
.income-summary-label { font-size: 12px; font-weight: 700; }
.income-summary-card small { font-size: 12px; }
.income-summary-primary {
    border-color: color-mix(in srgb, var(--primary) 40%, var(--line));
    background: linear-gradient(145deg, color-mix(in srgb, var(--primary) 8%, var(--surface)), var(--surface));
}
.income-summary-primary strong { color: var(--primary); }
.income-list-card {
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--surface);
}
.income-toolbar {
    min-height: 68px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 12px 14px 12px 18px;
    border-bottom: 1px solid var(--line);
}
.income-toolbar-title {
    display: flex;
    align-items: center;
    gap: 11px;
    min-width: 0;
}
.income-toolbar-title strong,
.income-toolbar-title span { display: block; }
.income-toolbar-title strong { font-size: 14px; }
.income-toolbar-title div > span { margin-top: 3px; color: var(--muted); font-size: 11px; }
.income-toolbar-controls {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 9px;
}
.income-search-field {
    width: min(290px, 30vw);
    min-height: 38px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 11px;
    border: 1px solid var(--line);
    border-radius: 9px;
    background: var(--bg);
    color: var(--muted);
}
.income-search-field input {
    width: 100%;
    height: 36px;
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
}
.income-search-field input:focus { outline: 0; box-shadow: none; }
.income-filter-select {
    min-width: 130px;
    min-height: 38px;
    padding: 0 34px 0 11px;
    border: 1px solid var(--line);
    border-radius: 9px;
    background: var(--bg);
    color: var(--text);
    font: inherit;
    font-size: 13px;
}
.income-table-wrap { width: 100%; overflow-x: auto; }
.income-record-table {
    width: 100%;
    min-width: 1360px;
    border-collapse: collapse;
    table-layout: fixed;
    font-size: 13px;
}
.income-record-table th {
    height: 42px;
    padding: 0 14px;
    border-bottom: 1px solid var(--line);
    background: var(--surface-soft);
    color: var(--muted);
    text-align: left;
    font-size: 11px;
    font-weight: 750;
    letter-spacing: .025em;
    text-transform: uppercase;
}
.income-record-table th:nth-child(1) { width: 135px; }
.income-record-table th:nth-child(2) { width: 230px; }
.income-record-table th:nth-child(3) { width: 115px; }
.income-record-table th:nth-child(4) { width: 175px; }
.income-record-table th:nth-child(5) { width: 95px; }
.income-record-table th:nth-child(6) { width: 135px; }
.income-record-table th:nth-child(7) { width: 100px; }
.income-record-table th:nth-child(8) { width: 140px; }
.income-record-table th:nth-child(9) { width: 155px; }
.income-record-table th:nth-child(10) { width: 115px; }
.income-record-table td {
    min-height: 64px;
    padding: 13px 14px;
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
    background: var(--surface);
}
.income-record-table tbody tr:last-child td { border-bottom: 0; }
.income-record-table tbody tr[data-income-row] { transition: background .15s ease; }
.income-record-table tbody tr[data-income-row]:hover td { background: color-mix(in srgb, var(--surface-soft) 58%, var(--surface)); }
.income-primary-cell,
.income-secondary-cell { min-width: 0; }
.income-primary-cell strong,
.income-primary-cell span,
.income-secondary-cell strong,
.income-secondary-cell span { display: block; }
.income-primary-cell strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.income-primary-cell span,
.income-secondary-cell span {
    margin-top: 4px;
    overflow: hidden;
    color: var(--muted);
    font-size: 11px;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.income-secondary-cell strong { font-size: 12px; font-weight: 700; }
.income-muted-value { color: var(--muted); }
.income-align-right,
.income-amount-cell { text-align: right !important; }
.income-amount-cell { font-weight: 800; font-variant-numeric: tabular-nums; }

.income-amount-stack {
    display: grid;
    justify-items: end;
    gap: 3px;
}
.income-amount-stack strong {
    color: var(--text);
    font-size: 13px;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}
.income-amount-stack span,
.income-amount-stack small {
    color: var(--muted);
    font-size: 10px;
    font-weight: 600;
    line-height: 1.25;
    white-space: nowrap;
}

.income-percent-cell,
.income-deductible-cell {
    text-align: right !important;
    font-variant-numeric: tabular-nums;
}
.income-percent-cell strong,
.income-deductible-cell strong {
    color: var(--text);
    font-size: 12px;
    font-weight: 800;
    white-space: nowrap;
}
.income-calculated-output {
    min-height: 42px;
    margin-top: 7px;
    display: flex;
    align-items: center;
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: 9px;
    background: var(--surface-soft);
    color: var(--text);
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}
.income-modal-form label.is-disabled {
    opacity: .55;
}
.income-modal-form label.is-disabled input {
    cursor: not-allowed;
}

.income-status-badge {
    width: max-content;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 6px 9px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--surface-soft);
    font-size: 11px;
    font-weight: 750;
}
.income-status-badge > span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: currentColor;
}
.income-status-badge.is-paid {
    border-color: rgba(55, 166, 116, .26);
    background: rgba(55, 166, 116, .09);
    color: #4fbe88;
}
.income-status-badge.is-open {
    border-color: rgba(214, 152, 56, .27);
    background: rgba(214, 152, 56, .09);
    color: #d7a453;
}
.income-note-preview {
    display: block;
    overflow: hidden;
    color: var(--muted);
    text-overflow: ellipsis;
    white-space: nowrap;
}
.income-actions-heading { text-align: right !important; }
.income-table-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
}
.income-delete-form { margin: 0; }
.income-action-button {
    min-height: 32px;
    padding: 0 9px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface-soft);
    color: var(--text);
    font: inherit;
    font-size: 11px;
    font-weight: 750;
    cursor: pointer;
}
.income-action-button:hover { background: var(--bg); }
.income-remove-button {
    width: 32px;
    padding: 0;
    color: var(--danger);
    font-size: 17px;
}
.income-filter-empty td,
.income-empty-row td {
    padding: 36px 20px;
    color: var(--muted);
    text-align: center;
}
.income-empty-row div { display: grid; justify-items: center; gap: 7px; }
.income-empty-row div > span {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    border: 1px solid var(--line);
    border-radius: 11px;
    background: var(--surface-soft);
    color: var(--primary);
    font-size: 20px;
}
.income-empty-row strong { color: var(--text); }
.income-empty-row p { margin: 0; }
.income-modal-dialog { width: min(100%, 780px); }
.income-modal-form input,
.income-modal-form select,
.income-modal-form textarea {
    width: 100%;
    margin-top: 7px;
    border: 1px solid var(--line);
    border-radius: 9px;
    background: var(--bg);
    color: var(--text);
    font: inherit;
}
.income-modal-form input,
.income-modal-form select { min-height: 42px; padding: 8px 10px; }
.income-modal-form textarea { min-height: 92px; padding: 10px; resize: vertical; }
.income-form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 15px 16px;
}
.income-modal-form .income-form-grid label {
    min-width: 0;
    margin: 0;
    color: var(--text);
    font-size: 13px;
    font-weight: 700;
}
.income-form-wide { grid-column: 1 / -1; }
.income-form-help {
    margin-top: 15px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 9px;
    background: var(--surface-soft);
    color: var(--muted);
    font-size: 12px;
}

@media (max-width: 1100px) {
    .income-summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
    .income-page-header { flex-direction: column; align-items: stretch; }
    .income-create-button { justify-content: center; }
    .income-summary-grid { grid-template-columns: 1fr 1fr; }
    .income-toolbar { align-items: stretch; flex-direction: column; }
    .income-toolbar-controls { justify-content: stretch; }
    .income-search-field { width: 100%; }
    .income-filter-select { flex: 0 0 130px; }
    .income-form-grid { grid-template-columns: 1fr; }
    .income-form-wide { grid-column: auto; }
}
@media (max-width: 560px) {
    .income-summary-grid { grid-template-columns: 1fr; }
    .income-toolbar-controls { flex-direction: column; align-items: stretch; }
    .income-filter-select { width: 100%; flex: none; }
    .income-record-table { min-width: 0; }
    .income-record-table thead { display: none; }
    .income-record-table,
    .income-record-table tbody,
    .income-record-table tr,
    .income-record-table td { display: block; width: 100%; }
    .income-record-table tbody { padding: 10px; }
    .income-record-table tr[data-income-row] {
        margin-bottom: 10px;
        overflow: hidden;
        border: 1px solid var(--line);
        border-radius: 11px;
        background: var(--surface);
    }
    .income-record-table td {
        min-height: 0;
        display: grid;
        grid-template-columns: 105px minmax(0, 1fr);
        gap: 12px;
        padding: 10px 12px;
        border-bottom: 1px solid var(--line);
        text-align: left !important;
    }
    .income-record-table td::before {
        content: attr(data-label);
        color: var(--muted);
        font-size: 10px;
        font-weight: 750;
        letter-spacing: .03em;
        text-transform: uppercase;
    }
    .income-record-table td:last-child { border-bottom: 0; }
    .income-amount-cell,
    .income-percent-cell,
    .income-deductible-cell { justify-items: start; }
    .income-amount-stack { justify-items: start; }
    .income-table-actions { justify-content: flex-start; }
    .income-filter-empty,
    .income-empty-row { display: table-row !important; }
    .income-filter-empty td,
    .income-empty-row td { display: block; }
    .income-filter-empty td::before,
    .income-empty-row td::before { display: none; }
}

/* Rollenverwaltung */
.account-stats {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

.role-badge {
    text-transform: none;
}

.role-change-form {
    display: grid;
    grid-template-columns: minmax(190px, 1fr) auto;
    gap: 7px;
    align-items: center;
    min-width: 285px;
}

.role-change-form .role-select {
    min-height: 34px;
    padding: 6px 34px 6px 9px;
    border-radius: 8px;
    font-size: 12px;
}

.role-change-form .table-action {
    min-height: 34px;
}

/* E-Mails: freie Nachricht + separater Verlauf */
.email-page-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.email-page-actions .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    text-decoration: none;
}

.email-compose-card {
    max-width: 980px;
}

.email-compose-form {
    display: block;
}

.email-compose-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.email-compose-grid label {
    margin-top: 0;
}

.email-compose-form textarea {
    min-height: 330px;
    font-family: inherit;
    line-height: 1.65;
}

.optional-label {
    color: var(--muted);
    font-size: 11px;
    font-weight: 600;
}

.email-compose-submit {
    display: flex;
    justify-content: flex-end;
    margin-top: 20px;
}

.email-compose-submit .btn {
    min-width: 150px;
}

.field-hint kbd {
    display: inline-block;
    padding: 2px 6px;
    border: 1px solid var(--line);
    border-bottom-width: 2px;
    border-radius: 5px;
    background: var(--surface-soft);
    color: var(--text);
    font: inherit;
    font-size: .78rem;
    font-weight: 800;
}

@media (max-width: 760px) {
    .email-compose-grid {
        grid-template-columns: 1fr;
    }

    .email-page-actions,
    .email-page-actions .btn,
    .email-compose-submit,
    .email-compose-submit .btn {
        width: 100%;
    }

    .role-change-form {
        min-width: 240px;
    }
}
