/* ══ Design-Tokens (V3 Topbar-Shell) ══ */
:root {
    --zero: #F3F3F3;
    --primary: #CAF3AB;
    --secondary: #FFB7C3;
    --third: #2D1E2F;
    --fourth: #fdffff;
    --fifth: #3F452A;
    --sixth: #9AE3A6;
    --seventh: #6EAD3D;
    --eight: #F3F3F3;
    --nine: #83857D;
    --tint-income: oklch(0.95 0.05 135);
    --tint-expense: oklch(0.95 0.04 10);
    --ink-income: oklch(0.45 0.11 135);
    --ink-expense: oklch(0.48 0.13 15);
    --tint-warning: oklch(0.95 0.05 85);
    --ink-warning: oklch(0.5 0.1 75);
    --tint-info: oklch(0.96 0.03 135);
    --border-soft: #e5e7e0;
    /* Layout: Container skaliert mit dem Monitor */
    --page-max: clamp(960px, 94vw, 1600px);
    --page-pad: clamp(1rem, 2.5vw, 2rem);
    /* Legacy-Aliase (content.css / ältere Screens) */
    --text-primary: var(--fifth);
    --content-primary: var(--zero);
    --shadow-primary: var(--secondary);
    --text-secondary: var(--fifth);
    --content-secondary: var(--fourth);
    --shadow-secondary: var(--fifth);
    --text-third: var(--primary);
    --content-third: var(--third);
    --shadow-third: var(--third);
    --text-fourth: var(--third);
    --content-fourth: var(--primary);
    --shadow-fourth: var(--secondary);
    --btn-bg-primary: var(--primary);
    --btn-txt-primary: var(--third);
    --btn-bg-secondary: var(--third);
    --btn-txt-secondary: var(--primary);
    --navbar-bg-primary: var(--third);
    --navbar-txt-primary: var(--primary);
    --navbar-bg-secondary: var(--primary);
    --navbar-txt-secondary: var(--third);
    --header-primary: var(--fourth);
    --navbar-primary: var(--fourth);
    --main-bg: var(--zero);
    --text-delete: var(--third);
    --background-delete: var(--secondary);
    --header-size: 60px;
    --footer-size: 40px;
    --max-content-width: var(--page-max);
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
    margin: 0;
    min-height: 100vh;
    height: auto !important;
    background: var(--zero) !important;
    background-color: var(--zero) !important;
}

body {
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    font-size: 1rem;
    line-height: 1.5;
    color: var(--fifth);
    display: flex;
    flex-direction: column;
}

a { color: var(--fifth); }
a:hover { color: var(--third); }

h1, h2, h3, h4, h5, h6 {
    margin: 0 0 .5rem;
    font-weight: 600;
    line-height: 1.2;
}
h2 { font-size: 1.6rem; color: var(--third); }
h4 { font-size: 1.15rem; color: var(--third); }
h5 { font-size: 1.05rem; color: var(--third); }
h6 { font-size: 1rem; }
p { margin: 0 0 .5rem; }
label { display: inline-block; }
hr { border: 0; border-top: 1px solid var(--border-soft); margin: .75rem 0; }

/* ══ Topbar (V3) ══ */
.topbar { background: var(--third); color: var(--zero); }
.topbar-inner {
    max-width: var(--page-max);
    margin: 0 auto;
    padding: 0 var(--page-pad);
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: .25rem 1.5rem;
    min-height: 60px;
}
.brand { display: flex; align-items: center; gap: .55rem; text-decoration: none; }
.brand-mark {
    width: 32px;
    height: 32px;
    flex: 0 0 32px;
    border-radius: .45rem;
    background: var(--primary);
    color: var(--third);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: .85rem;
    overflow: hidden;
}
.brand-mark img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}
img.brand-mark {
    width: 32px;
    height: 32px;
    object-fit: contain;
    background: transparent;
    border-radius: 50%;
    padding: 0;
    display: block;
    filter: drop-shadow(0 0 5px rgba(202, 243, 171, .4));
}
.brand-name { font-weight: 600; color: var(--fourth); font-size: .95rem; }
.top-nav {
    display: flex;
    gap: .25rem;
    align-self: stretch;
    align-items: stretch;
    min-width: 0;
    overflow-x: auto;
}
.top-link {
    display: flex;
    align-items: center;
    padding: 0 .9rem;
    color: var(--zero);
    text-decoration: none;
    font-size: .92rem;
    border-bottom: 3px solid transparent;
    border-top: 3px solid transparent;
    white-space: nowrap;
}
.top-link:hover { color: var(--primary); }
.top-link.active {
    color: var(--primary);
    font-weight: 600;
    border-bottom-color: var(--primary);
}
.top-user-wrap { margin-left: auto; }
.top-user {
    display: flex;
    align-items: center;
    gap: .5rem;
    cursor: pointer;
    padding: .3rem .55rem;
    border-radius: .5rem;
}
.top-user:hover { background: rgba(255, 255, 255, .08); }
.top-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--secondary);
    color: var(--third);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: .8rem;
}
.top-user-name { font-size: .88rem; color: var(--fourth); }
.top-user-name::after { content: " ▾"; font-size: .75em; color: var(--nine); }
.top-user-wrap .dropdown-menu {
    background: var(--fourth);
    border: 1px solid var(--border-soft);
    border-radius: .5rem;
    padding: .35rem;
    min-width: 10rem;
}
.top-user-wrap .dropdown-item {
    border-radius: .35rem;
    font-size: .9rem;
    color: var(--fifth);
}
.top-user-wrap .dropdown-item:hover {
    background: var(--tint-info);
    color: var(--third);
}
.nav-toggle, .nav-burger { display: none; }

@media (max-width: 1024px) {
    .topbar-inner { flex-wrap: wrap; }
    .top-nav { display: none; }
    .nav-burger {
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        color: var(--zero);
        font-size: 1.25rem;
        padding: .25rem .55rem;
        border-radius: .45rem;
        user-select: none;
    }
    .nav-burger:hover { background: rgba(255, 255, 255, .08); }
    .nav-toggle:checked ~ .top-nav {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        order: 4;
        flex-basis: 100%;
        padding-bottom: .5rem;
        overflow: visible;
    }
    .nav-toggle:checked ~ .top-nav .top-link {
        padding: .6rem .5rem;
        border: 0;
        border-radius: .45rem;
    }
    .nav-toggle:checked ~ .top-nav .top-link.active {
        background: rgba(202, 243, 171, .12);
    }
    .nav-toggle:checked ~ .nav-burger { background: rgba(255, 255, 255, .08); }
}

.page {
    max-width: var(--page-max);
    width: 100%;
    margin: 0 auto;
    padding: 1.75rem var(--page-pad) 1rem;
    flex: 1;
}

/* Alte Screen-Klassen: kein festes Viewport-Scrolling mehr in der Shell */
.main-content,
.content.main-content,
.main-inner {
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
    padding: 0;
}

.footer {
    padding: .75rem var(--page-pad) 1.25rem;
    font-size: .82rem;
    color: var(--nine);
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}
.footer a { color: var(--nine); text-decoration: none; }
.footer a:hover { color: var(--third); }

@media (max-width: 480px) {
    .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; }
    .brand-name { display: none; }
    .top-user-name { display: none; }
    h2 { font-size: 1.35rem; }
}

/* ══ Utilities ══ */
.small { font-size: .875em; }
.fs-4 { font-size: 1.5rem; }
.text-muted { color: var(--nine); }
.fw-semibold { font-weight: 600; }
.fw-bold { font-weight: 700; }
.text-success { color: var(--ink-income); }
.text-danger { color: var(--ink-expense); }
.text-end { text-align: right; }
.text-center { text-align: center; }
.d-flex { display: flex; }
.d-inline-flex { display: inline-flex; }
.d-none { display: none !important; }
.flex-wrap { flex-wrap: wrap; }
.flex-column { flex-direction: column; }
.gap-1 { gap: .25rem; }
.gap-2 { gap: .5rem; }
.gap-3 { gap: 1rem; }
.align-items-center { align-items: center; }
.align-items-end { align-items: flex-end; }
.justify-content-between { justify-content: space-between; }
.justify-content-end { justify-content: flex-end; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: .25rem; }
.mb-2 { margin-bottom: .5rem; }
.mb-3 { margin-bottom: 1rem; }
.mb-4 { margin-bottom: 1.5rem; }
.mt-1 { margin-top: .25rem; }
.mt-2 { margin-top: .5rem; }
.mt-3 { margin-top: 1rem; }
.ms-1 { margin-left: .25rem; }
.me-1 { margin-right: .25rem; }
.ms-auto { margin-left: auto; }
.p-3 { padding: 1rem; }
.px-2 { padding-left: .5rem; padding-right: .5rem; }
.rounded-3 { border-radius: .5rem; }
.rounded-4 { border-radius: .75rem; }
.w-100 { width: 100%; }
.cursor-pointer { cursor: pointer; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; }
@media (max-width: 700px) {
    .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr 1fr; }
}
.content-secondary {
    background-color: var(--fourth);
    color: var(--fifth);
    border: 1px solid var(--border-soft);
}
.content-secondary-neg { background-color: var(--zero); }

/* ══ Buttons ══ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .35rem;
    border: 1px solid transparent;
    border-radius: .5rem;
    padding: .45rem .9rem;
    font-size: .9rem;
    font-family: inherit;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: background .15s ease, color .15s ease, border-color .15s ease;
    white-space: nowrap;
    background: transparent;
    color: inherit;
}
.btn-sm { padding: .25rem .6rem; font-size: .85rem; }
.btn-primary { background: var(--primary); color: var(--third); border-color: var(--primary); }
.btn-primary:hover,
.btn-primary:focus,
.btn-primary:active {
    background: var(--sixth) !important;
    color: var(--third) !important;
    border-color: var(--sixth) !important;
}
.btn-second,
.btn-ghost,
.btn-outline-secondary {
    color: var(--third);
    background: var(--fourth);
    border-color: #dfe2da;
}
.btn-second:hover,
.btn-ghost:hover,
.btn-outline-secondary:hover {
    border-color: var(--third);
    background: var(--fourth);
    color: var(--third);
}
.btn-delete,
.btn-outline-danger {
    color: var(--ink-expense);
    border-color: var(--secondary);
    background: var(--fourth);
}
.btn-delete:hover,
.btn-outline-danger:hover {
    background: var(--secondary);
    color: var(--third);
}
.btn-warning,
.btn-outline-warning {
    color: var(--ink-warning);
    background: var(--fourth);
    border-color: var(--ink-warning);
}
.btn-warning:hover,
.btn-outline-warning:hover {
    background: oklch(0.9 0.07 85);
    border-color: var(--ink-warning);
    color: var(--ink-warning);
}
.btn-outline-success {
    color: var(--ink-income);
    border-color: var(--sixth);
    background: var(--fourth);
}
.btn-outline-success:hover {
    background: var(--tint-income);
    color: var(--ink-income);
}

/* ══ Badges ══ */
.badge {
    display: inline-block;
    padding: .32em .7em;
    font-size: .75em;
    font-weight: 600;
    line-height: 1.2;
    border-radius: 999px;
    font-family: inherit;
}
.bg-secondary { background: #e7e9e2; color: var(--fifth); }
.bg-success { background: var(--tint-income); color: var(--ink-income); }
.bg-warning { background: var(--tint-warning); color: var(--ink-warning); }
.bg-info { background: var(--tint-info); color: var(--fifth); }
.badge.text-dark, .text-dark { color: inherit; }
.badge--expense { background: var(--tint-expense); color: var(--ink-expense); }

/* ══ Alerts ══ */
.alert {
    padding: .75rem 1rem;
    border: 1px solid transparent;
    border-radius: .65rem;
    margin-bottom: 1rem;
}
.alert-info {
    background: var(--tint-info);
    color: var(--fifth);
    border-color: oklch(0.9 0.05 135);
}
.alert-success {
    background: var(--tint-income);
    color: var(--ink-income);
    border-color: oklch(0.88 0.07 135);
}
.alert-warning {
    background: var(--tint-warning);
    color: var(--ink-warning);
    border-color: oklch(0.88 0.07 85);
}
.alert-danger {
    background: var(--tint-expense);
    color: var(--ink-expense);
    border-color: oklch(0.88 0.06 10);
}

/* ══ Tabellen ══ */
table { width: 100%; border-collapse: collapse; font-size: .95rem; }
.table th, .table td {
    padding: .55rem .65rem;
    border-bottom: 1px solid #eceee7;
    text-align: left;
    vertical-align: middle;
}
.table thead th {
    font-weight: 600;
    font-size: .85rem;
    color: var(--nine);
    background: var(--fourth);
}
.table-hover tbody tr:hover td { background: #f6f7f3; }
.table tfoot td { background: #f6f7f3; font-weight: 600; }
.table tbody tr.selected > td { background: oklch(0.96 0.04 135); }
.table tbody tr.selected > td:first-child {
    box-shadow: inset 3px 0 0 var(--seventh);
}
.selectable-row { cursor: pointer; user-select: none; }

/* ══ Zeilenlisten ══ */
.list-row {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .55rem .75rem;
    border-radius: .5rem;
    margin-bottom: .35rem;
    text-decoration: none;
    color: var(--fifth);
}
.list-row:nth-child(even) { background: var(--zero); }
.list-row:hover { background: var(--primary); cursor: pointer; }
.list-row > div { flex: 1; text-align: center; }
.list-head {
    display: flex;
    gap: .75rem;
    padding: .35rem .75rem;
    font-weight: 600;
    font-size: .85rem;
    color: var(--nine);
}
.list-head > div { flex: 1; text-align: center; }

/* ══ Formulare ══ */
.form-label { display: block; margin-bottom: .25rem; }
.form-control,
.form-select {
    display: block;
    width: 100%;
    padding: .42rem .75rem;
    font-size: .95rem;
    font-family: inherit;
    border: 1px solid #dfe2da;
    border-radius: .5rem;
    background: #fff;
    color: var(--fifth);
}
.form-control-sm,
.form-select-sm { padding: .25rem .5rem; font-size: .875rem; }
.form-control:focus,
.form-select:focus {
    outline: 0;
    border-color: var(--seventh);
    box-shadow: 0 0 0 .2rem oklch(0.75 0.13 135 / .25);
}

/* ══ Panels / Karten ══ */
.token-section,
.panel {
    background: var(--fourth);
    border: 1px solid var(--border-soft);
    border-radius: .75rem;
    padding: 1.1rem;
    margin-bottom: 1rem;
}
.chip {
    display: inline-block;
    padding: .3rem .7rem;
    border-radius: 999px;
    background: var(--zero);
    border: 1px solid #e0e2db;
    font-size: .82rem;
    color: var(--fifth);
}
.chip-more {
    font-size: .82rem;
    text-decoration: none;
    font-weight: 600;
    color: var(--seventh);
}
.chip-more:hover { color: var(--fifth); }

/* ══ KPI ══ */
.kpi-card {
    border-radius: .75rem;
    padding: .9rem 1rem;
    border: 1px solid var(--border-soft);
    background: var(--fourth);
    min-width: 0;
}
.kpi-label { font-size: .8rem; color: var(--nine); margin-bottom: .3rem; }
.kpi-value {
    font-size: clamp(1.1rem, 1.6vw, 1.45rem);
    font-weight: 700;
    color: var(--third);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.kpi-note { font-size: .78rem; color: var(--nine); margin-top: .25rem; }

/* ══ Modals (statisch / Design-System) ══ */
.modal-static {
    background: var(--fourth);
    border: 1px solid var(--border-soft);
    border-radius: .75rem;
    box-shadow: 0 8px 32px rgba(45, 30, 47, .14);
    max-width: 480px;
    width: 100%;
}
.modal-static--wide { max-width: 720px; }
.modal-static .modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: .9rem 1.1rem;
    border-bottom: 1px solid var(--border-soft);
}
.modal-static .modal-body { padding: 1.1rem; }
.modal-static .modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: .5rem;
    padding: .75rem 1.1rem;
    border-top: 1px solid var(--border-soft);
}
.btn-close-x {
    border: 0;
    background: transparent;
    font-size: 1.1rem;
    cursor: pointer;
    color: var(--nine);
}

/* ══ Untertabs ══ */
.finance-slider {
    display: flex;
    flex-wrap: wrap;
    gap: .25rem;
    border-bottom: 2px solid #e2e4dd;
    margin-bottom: 1.25rem;
}
.finance-slider .nav-link {
    display: inline-flex;
    color: var(--nine);
    font-size: .95rem;
    text-decoration: none;
    padding: .5rem .85rem;
    margin-bottom: -2px;
    border-bottom: 2px solid transparent;
}
.finance-slider .nav-link:hover { color: var(--third); }
.finance-slider .nav-link.active {
    color: var(--third);
    font-weight: 600;
    border-bottom-color: var(--seventh);
}

img.app-logo,
img.mail-mark {
    background: transparent;
    border-radius: 50%;
    object-fit: contain;
    padding: 0;
    display: block;
    filter: drop-shadow(0 0 5px rgba(202, 243, 171, .4));
}

.signature-canvas {
    border: 1px solid #000;
    border-radius: 4px;
    background-color: #fff;
}

/* ══ Schnellerfassung / Zeit-Einträge (ÜL Phase 2) ══ */
.quick-entry {
    background: var(--fourth);
    border: 1px solid var(--border-soft);
    border-radius: .75rem;
    padding: 1.1rem;
}
.quick-entry .time-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
    border: 1px solid var(--border-soft);
    border-radius: .5rem;
    padding: .45rem .6rem;
    margin: 0;
    background: var(--zero);
    font-size: .9rem;
}

/* ══ Einstellungen (VS-06) ══ */
.subnav {
    display: inline-flex;
    gap: .2rem;
    background: var(--zero);
    border: 1px solid var(--border-soft);
    border-radius: .55rem;
    padding: .2rem;
    margin-bottom: 1.1rem;
}
.subnav a {
    padding: .3rem .85rem;
    border-radius: .4rem;
    text-decoration: none;
    color: var(--nine);
    font-size: .88rem;
    font-weight: 600;
}
.subnav a:hover { color: var(--third); }
.subnav a.active {
    background: var(--fourth);
    color: var(--third);
    box-shadow: 0 1px 2px rgba(45, 30, 47, .08);
}
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem 1.5rem;
}
@media (max-width: 720px) {
    .form-grid { grid-template-columns: 1fr; }
}
.field { display: flex; flex-direction: column; gap: .3rem; }
.field label { font-size: .85rem; font-weight: 600; color: var(--third); }
.field .hint { font-size: .8rem; color: var(--nine); }
.field-full { grid-column: 1 / -1; }
.switch-row { display: flex; align-items: flex-start; gap: .75rem; }
.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    flex: 0 0 auto;
    margin-top: .15rem;
}
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
    position: absolute;
    inset: 0;
    background: #d5d8cf;
    border-radius: 999px;
    transition: background .15s;
    cursor: pointer;
}
.switch .slider::before {
    content: "";
    position: absolute;
    height: 18px;
    width: 18px;
    left: 3px;
    top: 3px;
    background: var(--fourth);
    border-radius: 50%;
    transition: transform .15s;
    box-shadow: 0 1px 2px rgba(45, 30, 47, .25);
}
.switch input:checked + .slider { background: var(--seventh); }
.switch input:checked + .slider::before { transform: translateX(20px); }
.mail-preview {
    border: 1px dashed #d5d8cf;
    border-radius: .55rem;
    padding: .8rem 1rem;
    font-size: .88rem;
    background: #fafbf8;
}
.mail-preview .mp-row { display: flex; gap: .5rem; }
.mail-preview .mp-key { color: var(--nine); min-width: 72px; font-weight: 600; }
.callout {
    display: flex;
    gap: .6rem;
    background: var(--tint-info);
    border-radius: .55rem;
    padding: .7rem .9rem;
    font-size: .85rem;
    margin-bottom: 1rem;
}
.check-row {
    display: flex;
    align-items: center;
    gap: .45rem;
    margin-bottom: .35rem;
    font-size: .92rem;
}
.check-hint { color: var(--nine); font-size: .82rem; }
.badge--admin {
    background: var(--third);
    color: var(--primary);
}
.tenant-note {
    font-size: .85rem;
    color: var(--nine);
    margin-top: .5rem;
}

/* ══ Fortschrittsbalken (Abrechnungsläufe) ══ */
.progress {
    display: flex;
    height: .55rem;
    overflow: hidden;
    background: #e8eae3;
    border-radius: 999px;
}
.progress-bar {
    display: flex;
    flex-direction: column;
    justify-content: center;
    background: var(--seventh);
    transition: width .25s ease;
}
