:root {
    --bg: #eef3f8;
    --card: #ffffff;
    --text: #14283d;
    --text-muted: #5e7088;
    --border: #e2e9f1;
    --border-soft: #eef3f8;
    /* Primär: modernes Blau */
    --accent: #2563eb;
    --accent-soft: #e1ecfd;
    --accent-dark: #1d4ed8;
    /* Sekundär: Grün-/Türkistöne */
    --green: #10b981;
    --green-dark: #059669;
    --green-soft: #d6f5e8;
    --teal: #0ea5a0;
    /* Dunkle Flächen */
    --navy: #122a43;
    --navy-soft: #1f3b59;
    --blue: #3b82f6;
    /* Verläufe (Blau -> Türkis -> Grün) */
    --grad-brand: linear-gradient(135deg, #2563eb 0%, #0ea5a0 100%);
    --grad-hero: linear-gradient(120deg, #1d4ed8 0%, #0ea5a0 58%, #10b981 100%);
    --shadow-card: 0 1px 3px rgba(15, 40, 70, 0.06), 0 8px 24px rgba(15, 40, 70, 0.05);
    --shadow-pop: 0 12px 34px rgba(15, 40, 70, 0.16);
    --radius: 14px;
    color-scheme: light;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
    margin: 0;
    font: 14px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    position: relative;
    overflow-x: hidden;
}

/* dekorative Dreiecke im Hintergrund */
body::before, body::after {
    content: '';
    position: fixed;
    width: 380px; height: 380px;
    background: var(--grad-hero);
    z-index: 0; opacity: 0.14;
    pointer-events: none;
}
body::before {
    top: -190px; right: -130px;
    clip-path: polygon(0 100%, 100% 0, 100% 100%);
}
body::after {
    bottom: -190px; left: -130px;
    clip-path: polygon(0 0, 100% 100%, 0 100%);
}

a { color: var(--accent); }
a:hover { color: var(--accent-dark); }

/* --- Top-Bar ------------------------------------------------- */
.topbar {
    position: relative; z-index: 10;
    background: var(--card);
    padding: 14px 28px;
    display: flex; align-items: center; gap: 32px;
    box-shadow: var(--shadow-card);
    border-radius: 0 0 8px 8px;
    margin: 0 16px;
}
.brand {
    display: flex; align-items: center; gap: 10px;
    font-weight: 700; font-size: 16px;
    color: var(--text); text-decoration: none;
}
.brand-mark {
    width: 34px; height: 34px;
    background: var(--grad-brand);
    border-radius: 7px;
    display: grid; place-items: center;
    color: white; font-size: 13px; font-weight: 700;
    letter-spacing: 0.04em;
}

.nav {
    display: flex; gap: 28px;
    flex: 1; justify-content: center;
}
.nav a {
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 600; font-size: 14px;
    display: flex; align-items: center; gap: 8px;
    padding: 8px 4px;
    border-bottom: 2px solid transparent;
    transition: color 0.15s, border-color 0.15s;
}
.nav a:hover { color: var(--text); }
.nav a.active { color: var(--text); border-bottom-color: var(--accent); }
.nav a .icon { width: 18px; height: 18px; color: var(--accent); }

/* User-Menü (Avatar) */
.user-menu { position: relative; }
.user-menu summary {
    list-style: none;
    cursor: pointer; outline: none;
    display: inline-block;
}
.user-menu summary::-webkit-details-marker { display: none; }
.avatar {
    width: 40px; height: 40px;
    border-radius: 50%;
    display: grid; place-items: center;
    color: white; font-weight: 700; font-size: 13px;
    letter-spacing: 0.02em;
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
    user-select: none;
}
.user-menu[open] > summary .avatar {
    box-shadow: 0 0 0 3px var(--accent-soft);
}
.dropdown {
    position: absolute;
    top: calc(100% + 8px); right: 0;
    background: var(--card);
    border-radius: 8px;
    box-shadow: var(--shadow-pop);
    min-width: 220px;
    padding: 6px 0;
    z-index: 100;
}
.dropdown-head {
    padding: 12px 16px 10px;
    border-bottom: 1px solid var(--border-soft);
    margin-bottom: 4px;
}
.dropdown-head strong { display: block; font-size: 14px; }
.dropdown-head .muted { font-size: 12px; }
.dropdown a {
    display: block;
    padding: 9px 16px;
    color: var(--text);
    text-decoration: none;
    font-size: 14px;
}
.dropdown a:hover { background: var(--bg); }
.dropdown .sep { height: 1px; background: var(--border-soft); margin: 4px 0; }
.dropdown-btn {
    display: block; width: 100%;
    padding: 9px 16px;
    border: 0; background: transparent;
    text-align: left; font: inherit; font-size: 14px;
    color: var(--text); cursor: pointer;
}
.dropdown-btn:hover { background: var(--bg); }
.dropdown-btn.danger { color: #b91c1c; }
.dropdown-btn.danger:hover { background: #fef2f2; }
.user-menu summary.btn { display: inline-flex; }

/* --- Main Layout --------------------------------------------- */
.container {
    position: relative; z-index: 1;
    max-width: 1280px;
    margin: 0 auto;
    padding: 24px 28px 48px;
}

.page-head {
    display: flex; align-items: baseline; justify-content: space-between;
    margin: 4px 4px 18px;
}
.page-head h1 { margin: 0; font-size: 22px; font-weight: 700; }
.page-head .crumb { color: var(--text-muted); font-size: 13px; }

.grid { display: grid; gap: 22px; }
.grid-2 { grid-template-columns: 2fr 1fr; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-60-40 { grid-template-columns: 3fr 2fr; }
.col-stack > * + * { margin-top: 22px; }
@media (max-width: 980px) {
    .grid-2, .grid-3, .grid-60-40 { grid-template-columns: 1fr; }
}

/* --- Karten -------------------------------------------------- */
.card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
    padding: 22px 24px;
}
.card.flush { padding: 0; }
.card.accent { background: var(--accent); color: white; }
.card.accent .card-head h2 { color: rgba(255,255,255,0.85); }
.card.navy { background: var(--navy); color: white; }

.card-head {
    display: flex; align-items: baseline; justify-content: space-between;
    margin-bottom: 16px;
}
.card-head h2 {
    margin: 0;
    font-size: 13px; font-weight: 600;
    color: var(--text-muted);
    letter-spacing: 0.04em; text-transform: uppercase;
}
.card-head .more {
    color: var(--text-muted);
    font-size: 12px; text-decoration: none;
    font-weight: 600;
}
.card-head .more:hover { color: var(--accent); }

/* Datums-Karte (Navy) */
.date-card { padding: 28px 24px; text-align: center; }
.date-card .weekday {
    font-size: 13px; letter-spacing: 0.18em; text-transform: uppercase;
    opacity: 0.7;
}
.date-card .day {
    font-size: 64px; font-weight: 800; line-height: 1;
    margin: 6px 0 4px;
}
.date-card .month { font-size: 12px; letter-spacing: 0.1em; text-transform: uppercase; opacity: 0.7; }

/* --- Profil-Übersicht ---------------------------------------- */
.profile-hero {
    display: flex; align-items: center; gap: 18px;
}
.profile-hero .avatar { width: 64px; height: 64px; font-size: 22px; }
.profile-hero .info h3 { margin: 0; font-size: 19px; }
.profile-hero .info .muted { margin-top: 2px; font-size: 13px; }

.kv {
    list-style: none; padding: 0; margin: 18px 0 0;
}
.kv li {
    display: flex; gap: 16px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-soft);
    font-size: 14px;
}
.kv li:last-child { border-bottom: 0; }
.kv .k { color: var(--text-muted); flex: 0 0 160px; font-size: 13px; }
.kv .v { font-weight: 500; }

/* --- Formulare ----------------------------------------------- */
.form-row { margin-bottom: 18px; }
.form-row label {
    display: block;
    font-weight: 600; color: var(--text);
    font-size: 13px; letter-spacing: 0;
    text-transform: none;
    margin-bottom: 7px;
}

/* --- Einheitliche, moderne Form-Controls -------------------- */
input[type=text],
input[type=password],
input[type=email],
input[type=number],
input[type=date],
input[type=time],
input[type=datetime-local],
input[type=month],
input[type=search],
input[type=tel],
input[type=url],
select,
textarea {
    display: block; width: 100%;
    padding: 11px 14px;
    font: inherit; font-size: 14px; line-height: 1.4;
    color: var(--text);
    background: var(--card);
    border: 1.5px solid var(--border);
    border-radius: 9px;
    transition: border-color .15s ease, box-shadow .15s ease;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}
textarea { min-height: 90px; resize: vertical; }
input::placeholder, textarea::placeholder { color: #aab2bd; }

input:hover:not(:disabled):not(:focus),
select:hover:not(:disabled):not(:focus),
textarea:hover:not(:disabled):not(:focus) {
    border-color: #cdd5df;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}
input:disabled, select:disabled, textarea:disabled {
    background: var(--bg);
    color: var(--text-muted);
    cursor: not-allowed;
}

/* Custom-Pfeil für Selects */
select {
    cursor: pointer;
    padding-right: 40px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%237f8c8d' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 13px center;
    background-size: 16px;
}

/* Checkbox / Radio: native, aber mit Akzentfarbe */
input[type=checkbox], input[type=radio] {
    width: 18px; height: 18px;
    accent-color: var(--accent);
    cursor: pointer;
    vertical-align: middle;
}

/* Color-Picker */
input[type=color] {
    width: 48px; height: 40px;
    padding: 4px;
    border: 1.5px solid var(--border);
    border-radius: 9px;
    background: var(--card);
    cursor: pointer;
}
input[type=color]:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* File-Upload */
input[type=file] {
    display: block; width: 100%;
    font: inherit; font-size: 14px;
    color: var(--text-muted);
    border: 1.5px dashed var(--border);
    border-radius: 9px;
    padding: 10px 12px;
    background: var(--bg);
    cursor: pointer;
    transition: border-color .15s ease, background .15s ease;
}
input[type=file]:hover { border-color: var(--accent); background: var(--accent-soft); }
input[type=file]::file-selector-button {
    font: inherit; font-weight: 600; font-size: 13px;
    margin-right: 12px;
    padding: 7px 14px;
    border: 0; border-radius: 7px;
    background: var(--navy); color: #fff;
    cursor: pointer;
    transition: background .15s ease;
}
input[type=file]:hover::file-selector-button { background: var(--accent); }

.form-actions { margin-top: 20px; display: flex; gap: 10px; align-items: center; }
.form-help { font-size: 12px; color: var(--text-muted); margin: 6px 0 0; }

/* --- Buttons ------------------------------------------------- */
button.btn, a.btn {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 11px 22px;
    background: var(--accent); color: white;
    border: 0; border-radius: 9px;
    font: inherit; font-weight: 600; font-size: 14px;
    cursor: pointer; text-decoration: none;
    box-shadow: 0 1px 2px rgba(31,41,55,0.08);
    transition: background .15s ease, box-shadow .15s ease, transform .05s ease;
}
button.btn:hover, a.btn:hover { background: var(--accent-dark); color: white; box-shadow: 0 4px 12px rgba(37,99,235,0.28); }
button.btn:active, a.btn:active { transform: translateY(1px); }
button.btn:focus-visible, a.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.btn.secondary { background: var(--bg); color: var(--text); box-shadow: none; }
.btn.secondary:hover { background: var(--border); color: var(--text); box-shadow: none; }
.btn.ghost { background: transparent; color: var(--text-muted); box-shadow: none; }
.btn.ghost:hover { background: var(--bg); color: var(--text); box-shadow: none; }

/* --- Alerts -------------------------------------------------- */
.alert {
    padding: 11px 14px;
    border-radius: 7px;
    margin-bottom: 14px;
    font-size: 13px;
    border: 1px solid transparent;
}
.alert.error   { background: #fef2f2; color: #991b1b; border-color: #fecaca; }
.alert.success { background: #ecfdf5; color: #065f46; border-color: #a7f3d0; }
.alert.info    { background: #eff6ff; color: #1e40af; border-color: #bfdbfe; }

/* --- Hilfsklassen -------------------------------------------- */
.muted { color: var(--text-muted); }
.mono  { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; }
.spacer { flex: 1; }
.section + .section { margin-top: 22px; }
h2.section-title {
    font-size: 16px; font-weight: 700;
    margin: 0 0 14px;
}

/* --- Login-Shell --------------------------------------------- */
body.login-shell {
    display: grid; place-items: center;
    padding: 24px;
}
.login-card {
    position: relative; z-index: 1;
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow-pop);
    padding: 38px 34px;
    width: 100%; max-width: 380px;
}
.login-brand {
    display: flex; align-items: center; gap: 12px;
    justify-content: center;
    margin-bottom: 26px;
}
.login-brand .brand-mark { width: 42px; height: 42px; font-size: 16px; }
.login-brand h1 { margin: 0; font-size: 18px; font-weight: 700; }
.login-card .form-actions button { width: 100%; }

/* --- Quick-Links / einfache Listen --------------------------- */
.quick-list { list-style: none; padding: 0; margin: 0; }
.quick-list li + li { border-top: 1px solid var(--border-soft); }
.quick-list a {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 4px;
    color: var(--text); text-decoration: none;
    font-weight: 500; font-size: 14px;
}
.quick-list a:hover { color: var(--accent); }
.quick-list .icon-tile {
    width: 32px; height: 32px;
    border-radius: 7px;
    background: var(--accent-soft); color: var(--accent);
    display: grid; place-items: center;
    flex: 0 0 32px;
}
.quick-list .icon-tile.navy   { background: #e4e7eb; color: var(--navy); }
.quick-list .icon-tile.green  { background: #d1fae5; color: #065f46; }
.quick-list .icon-tile.blue   { background: #dbeafe; color: #1e40af; }

/* --- Welcome-Hero -------------------------------------------- */
.hero {
    padding: 26px 28px;
    background: var(--grad-hero);
    color: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
}
.hero h1 { margin: 0; font-size: 22px; }
.hero p { margin: 8px 0 0; opacity: 0.85; font-size: 14px; }
.hero .row { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.hero .row > div { flex: 1; min-width: 0; }

/* SVG icon util */
.icon { width: 18px; height: 18px; flex: 0 0 18px; }
.icon-lg { width: 22px; height: 22px; }

/* --- Modul-Icon-Kachel (im App-Grid) ------------------------- */
.module-icon {
    width: 48px; height: 48px;
    border-radius: 11px;
    display: grid; place-items: center;
    background: var(--accent-soft); color: var(--accent);
}
.module-icon .icon { width: 26px; height: 26px; }
.module-icon.green { background: #d1fae5; color: #065f46; }
.module-icon.blue  { background: #dbeafe; color: #1e40af; }

/* --- App-Kacheln --------------------------------------------- */
.app-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 14px;
}
.app-tile-wrap { position: relative; }
.app-tile {
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 10px;
    padding: 18px 12px;
    background: var(--bg);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
    text-decoration: none;
    color: var(--text);
    transition: transform 0.12s ease, box-shadow 0.12s ease, border-color 0.12s ease;
    min-height: 112px;
}
.app-tile:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-card);
    border-color: var(--accent);
}
.app-name {
    font-size: 13px; font-weight: 600;
    color: var(--text);
    text-align: center;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    width: 100%;
}
.app-icon {
    width: 48px; height: 48px;
    object-fit: contain;
    border-radius: 8px;
    background: var(--card);
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    padding: 4px;
}
.app-icon.placeholder {
    color: white;
    display: grid; place-items: center;
    font-weight: 700;
    padding: 0;
    background: var(--accent);  /* wird inline überschrieben */
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}
.app-icon.plus {
    background: var(--accent-soft);
    color: var(--accent);
    display: grid; place-items: center;
    box-shadow: none;
}
.app-icon.plus .icon { width: 22px; height: 22px; }

/* Edit-Button überlagernd, nur bei Hover sichtbar */
.app-tile-edit {
    position: absolute;
    top: 8px; right: 8px;
    width: 28px; height: 28px;
    border-radius: 50%;
    background: var(--card);
    color: var(--text-muted);
    display: grid; place-items: center;
    text-decoration: none;
    box-shadow: var(--shadow-card);
    opacity: 0;
    transform: translateY(-4px);
    transition: opacity 0.12s ease, transform 0.12s ease, color 0.12s ease;
}
.app-tile-wrap:hover .app-tile-edit,
.app-tile-edit:focus {
    opacity: 1;
    transform: translateY(0);
}
.app-tile-edit:hover { color: var(--accent); }
.app-tile-edit .icon { width: 14px; height: 14px; }

.app-tile.add-tile {
    border: 2px dashed var(--border);
    background: transparent;
    color: var(--text-muted);
}
.app-tile.add-tile:hover {
    border-color: var(--accent);
    color: var(--accent);
}

/* --- App-Tabelle auf /apps.php ------------------------------- */
.apps-table {
    width: 100%;
    border-collapse: collapse;
}
.apps-table th, .apps-table td {
    padding: 12px 10px;
    text-align: left;
    border-bottom: 1px solid var(--border-soft);
    vertical-align: middle;
}
.apps-table th {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 600;
}
.apps-table tr:last-child td { border-bottom: 0; }
.apps-table .app-icon-cell { width: 48px; }
.apps-table .app-icon-cell .app-icon { width: 32px; height: 32px; }
.apps-table .app-url-cell {
    max-width: 360px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.apps-table .app-url-cell a { color: var(--text-muted); text-decoration: none; }
.apps-table .app-url-cell a:hover { color: var(--accent); }
.apps-table .app-actions-cell {
    text-align: right;
    white-space: nowrap;
}
.apps-table .app-actions-cell .btn { padding: 6px 12px; font-size: 13px; }
.btn.ghost.danger { color: #b91c1c; }
.btn.ghost.danger:hover { background: #fef2f2; color: #991b1b; }

/* --- Finanzen-Modul ----------------------------------------- */
.fin-subnav {
    display: flex; flex-wrap: wrap; gap: 2px;
    margin: 0 0 20px;
    padding: 3px;
    background: var(--card);
    border-radius: 12px;
    box-shadow: var(--shadow-card);
}
.fin-subnav a {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 6px 11px;
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 500; font-size: 12.5px;
    border-radius: 8px;
    white-space: nowrap;
    transition: background 0.12s, color 0.12s;
}
.fin-subnav a .icon { width: 15px; height: 15px; flex: none; opacity: .85; }
.fin-subnav a:hover { background: var(--bg); color: var(--text); }
.fin-subnav a:hover .icon { opacity: 1; }
.fin-subnav a.active { background: var(--grad-brand); color: white; font-weight: 600; box-shadow: 0 2px 6px rgba(37,99,235,0.22); }
.fin-subnav a.active .icon { color: #fff; opacity: 1; }

/* Schmale Screens: Icons-only-Modus wäre zu kryptisch — Umbruch reicht.
   Auf sehr schmalen Geräten kompakter umbrechen. */
@media (max-width: 560px) {
    .fin-subnav a { padding: 6px 9px; font-size: 12px; }
    .fin-subnav a .icon { width: 14px; height: 14px; }
}

.fin-amount { font-variant-numeric: tabular-nums; font-weight: 600; }
.fin-amount.pos { color: #047857; }
.fin-amount.neg { color: #b91c1c; }

.fin-balance-hero {
    background: var(--grad-hero);
    color: white;
    padding: 28px 32px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
    display: flex; align-items: center; justify-content: space-between; gap: 24px;
    flex-wrap: wrap;
}
.fin-balance-hero .label {
    font-size: 13px; letter-spacing: 0.08em; text-transform: uppercase; opacity: 0.7;
}
.fin-balance-hero .value {
    font-size: 38px; font-weight: 800; line-height: 1; margin-top: 6px;
    font-variant-numeric: tabular-nums;
}
.fin-balance-hero form { display: flex; gap: 8px; align-items: center; }
.fin-balance-hero select, .fin-balance-hero input[type=month] {
    padding: 8px 12px;
    border-radius: 6px;
    border: 0;
    background: rgba(255,255,255,0.18);
    color: white;
    font: inherit;
}
.fin-balance-hero select option { color: var(--text); }
.fin-balance-hero .btn { background: rgba(255,255,255,0.2); }
.fin-balance-hero .btn:hover { background: rgba(255,255,255,0.3); }

.fin-cat-dot {
    display: inline-block;
    width: 10px; height: 10px;
    border-radius: 50%;
    margin-right: 8px;
    vertical-align: -1px;
    background: var(--border);
}

.fin-table { width: 100%; border-collapse: collapse; }
.fin-table th, .fin-table td {
    padding: 10px 8px;
    text-align: left;
    border-bottom: 1px solid var(--border-soft);
    vertical-align: middle;
}
.fin-table th {
    font-size: 12px; color: var(--text-muted); text-transform: uppercase;
    letter-spacing: 0.04em; font-weight: 600;
}
.fin-table td.num, .fin-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.fin-table tr:last-child td { border-bottom: 0; }
.fin-table .actions { text-align: right; white-space: nowrap; }
.fin-table .actions .btn { padding: 5px 10px; font-size: 12px; }
.fin-table input.inline {
    padding: 4px 8px;
    border: 1px solid transparent;
    background: transparent;
    border-radius: 4px;
    font: inherit;
    width: 100%;
    max-width: 140px;
}
.fin-table input.inline:focus {
    background: var(--card);
    border-color: var(--accent);
    outline: none;
}
.fin-table input.inline.save-saving {
    background: #fef9c3;
    border-color: #facc15;
}
.fin-table input.inline.save-saved {
    background: #d1fae5;
    border-color: #34d399;
    transition: background 0.8s ease, border-color 0.8s ease;
}
.fin-table input.inline.save-error {
    background: #fee2e2;
    border-color: #f87171;
    color: #991b1b;
}

/* --- Konto-Typ-Badges --------------------------------------- */
.acct-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 11px; font-weight: 700;
    letter-spacing: 0.02em;
    vertical-align: middle;
}
.acct-giro    { background: #dbeafe; color: #1e40af; }
.acct-credit  { background: #fef3c7; color: #92400e; }
.acct-savings { background: #d1fae5; color: #065f46; }
.acct-cash    { background: #e5e7eb; color: #374151; }

/* --- Transfer-Marker ---------------------------------------- */
.transfer-marker {
    display: inline-block;
    color: var(--blue);
    font-weight: 700;
    margin-right: 2px;
}

/* --- Budget-Hero-Karten ------------------------------------- */
.card.hero-budget {
    color: white;
    padding: 26px 28px;
}
.card.hero-budget.pos { background: linear-gradient(135deg, #0f766e, #14b8a6); }
.card.hero-budget.neg { background: linear-gradient(135deg, #b91c1c, #ef4444); }
.hero-budget .hero-label { font-size: 13px; letter-spacing: 0.06em; text-transform: uppercase; opacity: 0.85; }
.hero-budget .hero-value { font-size: 40px; font-weight: 800; line-height: 1; margin: 8px 0 12px; font-variant-numeric: tabular-nums; }
.hero-budget .hero-sub { font-size: 12px; opacity: 0.85; line-height: 1.6; }

/* --- Zyklus-Picker ------------------------------------------ */
.cycle-picker {
    display: inline-flex; align-items: center; gap: 8px;
    margin: 0;
}
.cycle-picker .cycle-label {
    font-weight: 700; font-size: 14px;
    font-variant-numeric: tabular-nums;
    min-width: 180px; text-align: center;
}
.cycle-picker .btn.ghost { padding: 6px 12px; }

/* --- Personen-Aufteilung ------------------------------------ */
.split-shares { display: flex; flex-direction: column; gap: 14px; justify-content: center; }
.split-card {
    background: var(--bg);
    border-radius: var(--radius);
    padding: 16px 18px;
    border: 1px solid var(--border-soft);
}
.split-card .split-name { font-size: 14px; font-weight: 700; }
.split-card .split-value { font-size: 28px; font-weight: 800; margin: 4px 0; font-variant-numeric: tabular-nums; }
.split-card .split-sub { font-size: 12px; color: var(--text-muted); line-height: 1.5; }

.fin-preview {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: 6px;
    margin: 12px 0;
}
.fin-preview table { border-collapse: collapse; width: 100%; font-size: 12px; }
.fin-preview th, .fin-preview td { padding: 6px 10px; border-right: 1px solid var(--border-soft); border-bottom: 1px solid var(--border-soft); }
.fin-preview th { background: var(--bg); font-weight: 600; }
.fin-preview td.bad { background: #fef2f2; color: #991b1b; }
.fin-preview td.good { color: var(--text); }
.fin-preview select { font-size: 12px; padding: 2px 4px; max-width: 100%; }


/* --- Mobile / Handy (≤ 640px) -------------------------------- */
@media (max-width: 640px) {
    .topbar {
        margin: 0 8px;
        padding: 10px 14px;
        gap: 12px;
        flex-wrap: wrap;
    }
    .brand { font-size: 15px; }
    .nav {
        order: 3;
        width: 100%;
        justify-content: flex-start;
        gap: 16px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 2px;
    }
    .nav a { font-size: 13px; padding: 6px 2px; white-space: nowrap; }

    .container { padding: 16px 14px 40px; }

    .page-head {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
        margin: 4px 2px 16px;
    }
    .page-head h1 { font-size: 19px; }

    .cycle-picker { width: 100%; justify-content: space-between; }
    .cycle-picker .cycle-label { min-width: 0; flex: 1; }

    /* Breite Tabellen innerhalb der Karte horizontal scrollbar machen */
    .card { padding: 18px 16px; overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .fin-table, .apps-table { font-size: 13px; }
    .fin-table th, .fin-table td { padding: 8px 6px; }

    /* Hero-/Budget-Werte etwas kompakter */
    .hero-budget { padding: 22px 20px; }
    .hero-budget .hero-value { font-size: 30px; }
    .hero .row { flex-direction: column; align-items: flex-start; }
    .fin-balance-hero { padding: 22px 20px; }
    .fin-balance-hero .value { font-size: 30px; }

    .split-card .split-value { font-size: 24px; }

    /* Dropdown-Menü volle Breite nutzbar */
    .dropdown { right: -4px; min-width: 200px; }

    /* Karten-Aktionen umbrechen statt überlaufen */
    .fin-table .actions, .apps-table .app-actions-cell { white-space: normal; }
}

/* Touch-Geräte: größere Mindesthöhe für Buttons/Felder */
@media (pointer: coarse) {
    button.btn, a.btn { min-height: 44px; }
    input, select, textarea { font-size: 16px; }   /* verhindert iOS-Zoom beim Fokus */
}

/* =============================================================
   Kalender-Modul (Google-Kalender-Stil)
   ============================================================= */
/* hidden-Attribut muss Author-display-Regeln (z.B. .btn, .cal-modal-backdrop)
   schlagen — sonst bleiben als hidden markierte Elemente sichtbar. */
[hidden] { display: none !important; }

.cal-app {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
    overflow: hidden;
    position: relative; z-index: 1;
}

/* Toolbar */
.cal-toolbar {
    display: flex; align-items: center; justify-content: space-between;
    gap: 14px; padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}
.cal-toolbar-left, .cal-toolbar-right { display: flex; align-items: center; gap: 10px; }
.cal-toolbar h2 { margin: 0; font-size: 19px; font-weight: 700; white-space: nowrap; }
.cal-nav { display: flex; gap: 2px; }
.cal-navbtn {
    border: 1px solid var(--border); background: var(--card);
    width: 32px; height: 32px; border-radius: 50%;
    font-size: 18px; line-height: 1; color: var(--text-muted);
    cursor: pointer; display: grid; place-items: center;
}
.cal-navbtn:hover { background: var(--bg); color: var(--text); }

.cal-viewswitch { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.cal-viewswitch button {
    border: none; background: var(--card); color: var(--text-muted);
    padding: 7px 14px; font-size: 13px; font-weight: 600; cursor: pointer;
    border-right: 1px solid var(--border);
}
.cal-viewswitch button:last-child { border-right: none; }
.cal-viewswitch button.active { background: var(--accent); color: #fff; }
.cal-viewswitch button:hover:not(.active) { background: var(--bg); color: var(--text); }

#cal-sync.spin { opacity: 0.6; pointer-events: none; }

/* Icon-Buttons / Mobile-Komponenten (Desktop: teils ausgeblendet) */
.cal-iconbtn {
    border: 1px solid var(--border); background: var(--card); color: var(--text-muted);
    width: 40px; height: 40px; border-radius: 9px; display: grid; place-items: center;
    cursor: pointer; font-size: 22px; line-height: 1;
}
.cal-iconbtn:hover { background: var(--bg); color: var(--text); }
.cal-menu-btn { display: none; }
.cal-sidebar-head { display: none; }
.cal-drawer-backdrop { display: none; }
.cal-fab { display: none; }

/* Body: Sidebar + Hauptbereich */
.cal-body { display: grid; grid-template-columns: 232px 1fr; min-height: 600px; }
.cal-sidebar { border-right: 1px solid var(--border); padding: 14px; }
.cal-main { min-width: 0; padding: 0; }

/* Mini-Kalender */
.cal-mini { margin-bottom: 18px; user-select: none; }
.cal-mini-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.cal-mini-title { font-weight: 700; font-size: 13px; }
.cal-mini-nav { border: none; background: none; cursor: pointer; color: var(--text-muted); font-size: 16px; width: 24px; height: 24px; border-radius: 50%; }
.cal-mini-nav:hover { background: var(--bg); color: var(--text); }
.cal-mini-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px; }
.cal-mini-wd { text-align: center; font-size: 10px; color: var(--text-muted); padding: 2px 0; font-weight: 600; }
.cal-mini-day {
    border: none; background: none; cursor: pointer;
    aspect-ratio: 1; border-radius: 50%; font-size: 11px; color: var(--text);
    display: grid; place-items: center;
}
.cal-mini-day:hover { background: var(--bg); }
.cal-mini-day.other { color: #c5ccd6; }
.cal-mini-day.today { background: var(--accent); color: #fff; font-weight: 700; }
.cal-mini-day.sel:not(.today) { box-shadow: inset 0 0 0 1.5px var(--accent); }

/* Kalenderliste */
.cal-cals-head { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); margin-bottom: 8px; }
.cal-cals-list { display: flex; flex-direction: column; gap: 2px; }
.cal-citem { display: flex; align-items: center; gap: 8px; font-size: 13px; padding: 4px 2px; cursor: pointer; }
.cal-citem input { width: auto; margin: 0; }
.cal-cdot { width: 12px; height: 12px; border-radius: 3px; flex: none; }
.cal-cals-manage { display: inline-block; margin-top: 12px; font-size: 12px; }

/* ---- Monatsansicht ---- */
.cal-month { display: flex; flex-direction: column; height: 100%; }
.cal-month-head { display: grid; grid-template-columns: repeat(7, 1fr); border-bottom: 1px solid var(--border); }
.cal-month-hcell { text-align: right; padding: 8px 10px; font-size: 11px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; }
.cal-month-grid { display: grid; grid-template-columns: repeat(7, 1fr); grid-auto-rows: 1fr; flex: 1; min-height: 560px; }
.cal-mcell {
    border-right: 1px solid var(--border-soft); border-bottom: 1px solid var(--border-soft);
    padding: 4px 4px 6px; min-height: 96px; cursor: pointer; overflow: hidden;
    display: flex; flex-direction: column;
}
.cal-mcell:nth-child(7n) { border-right: none; }
.cal-mcell.other { background: #fafbfc; }
.cal-mcell-num { text-align: right; font-size: 12px; color: var(--text-muted); padding: 2px 4px; }
.cal-mcell.other .cal-mcell-num { color: #c5ccd6; }
.cal-mcell.today .cal-mcell-num span {
    background: var(--accent); color: #fff; border-radius: 50%;
    display: inline-grid; place-items: center; width: 22px; height: 22px; font-weight: 700;
}
.cal-mcell-body { display: flex; flex-direction: column; gap: 2px; flex: 1; }

.cal-chip {
    display: flex; align-items: center; gap: 5px;
    border: none; background: none; cursor: pointer; text-align: left;
    padding: 1px 5px; border-radius: 4px; font-size: 12px; color: var(--text);
    width: 100%; overflow: hidden; white-space: nowrap; line-height: 1.5;
}
.cal-chip:hover { background: var(--bg); }
.cal-chip.allday { color: #fff; }
.cal-chip.allday:hover { filter: brightness(0.94); background: inherit; }
.cal-chip-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.cal-chip-time { color: var(--text-muted); font-variant-numeric: tabular-nums; flex: none; }
.cal-chip.allday .cal-chip-time { color: rgba(255,255,255,0.85); }
.cal-chip-label { overflow: hidden; text-overflow: ellipsis; }
.cal-more { border: none; background: none; cursor: pointer; font-size: 11px; color: var(--text-muted); text-align: left; padding: 1px 5px; font-weight: 600; }
.cal-more:hover { color: var(--accent); }

/* ---- Zeitraster (Woche/Tag) ---- */
.cal-tg { display: flex; flex-direction: column; height: 720px; }
.cal-tg-gutter { width: 56px; flex: none; font-size: 10px; color: var(--text-muted); text-align: right; padding-right: 6px; }
.cal-tg-head { display: flex; border-bottom: 1px solid var(--border); }
.cal-tg-hcell { flex: 1; text-align: center; padding: 6px 0; border-left: 1px solid var(--border-soft); }
.cal-tg-wd { display: block; font-size: 11px; color: var(--text-muted); text-transform: uppercase; font-weight: 600; }
.cal-tg-daynum { border: none; background: none; cursor: pointer; font-size: 20px; font-weight: 600; color: var(--text); width: 36px; height: 36px; border-radius: 50%; margin-top: 2px; }
.cal-tg-daynum:hover { background: var(--bg); }
.cal-tg-hcell.today .cal-tg-daynum { background: var(--accent); color: #fff; }

.cal-tg-allday { display: flex; border-bottom: 1px solid var(--border); min-height: 26px; max-height: 90px; overflow-y: auto; }
.cal-tg-allday .cal-tg-gutter { padding-top: 4px; }
.cal-tg-allcell { flex: 1; border-left: 1px solid var(--border-soft); padding: 2px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }

.cal-tg-scroll { flex: 1; overflow-y: auto; }
.cal-tg-body { display: flex; position: relative; }
.cal-tg-times { width: 56px; flex: none; }
.cal-tg-time { position: relative; border-bottom: 1px solid var(--border-soft); }
.cal-tg-time span { position: absolute; top: -7px; right: 6px; font-size: 10px; color: var(--text-muted); background: var(--card); padding: 0 2px; }
.cal-tg-cols { display: flex; flex: 1; }
.cal-tg-col { flex: 1; position: relative; border-left: 1px solid var(--border-soft); }
.cal-tg-hour { border-bottom: 1px solid var(--border-soft); cursor: pointer; }
.cal-tg-hour:hover { background: var(--bg); }

.cal-ev {
    position: absolute; border: none; cursor: pointer; text-align: left;
    border-radius: 5px; padding: 2px 6px; color: #fff; overflow: hidden;
    box-shadow: 0 1px 2px rgba(0,0,0,0.18); font-size: 11px; line-height: 1.3;
    border-left: 3px solid rgba(0,0,0,0.18);
}
.cal-ev-time { display: block; font-variant-numeric: tabular-nums; opacity: 0.9; font-size: 10px; }
.cal-ev-title { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-now { position: absolute; left: 0; right: 0; height: 2px; background: var(--accent); z-index: 5; }
.cal-now::before { content: ''; position: absolute; left: -4px; top: -3px; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }

/* ---- Termin-Dialog ---- */
.cal-modal-backdrop {
    position: fixed; inset: 0; background: rgba(31,41,55,0.45);
    display: grid; place-items: center; z-index: 1000; padding: 16px;
}
.cal-modal {
    background: var(--card); border-radius: 12px; box-shadow: var(--shadow-pop);
    width: 100%; max-width: 520px; max-height: 92vh; overflow-y: auto;
}
.cal-modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border-soft); }
.cal-modal-head h3 { margin: 0; font-size: 17px; }
.cal-modal-close { border: none; background: none; font-size: 26px; line-height: 1; color: var(--text-muted); cursor: pointer; }
.cal-modal-close:hover { color: var(--text); }
#cal-form { padding: 16px 20px 20px; }
.cal-form-row { margin-bottom: 14px; }
.cal-form-row > label { display: block; font-size: 12px; font-weight: 600; color: var(--text-muted); margin-bottom: 5px; }
.cal-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.cal-form-grid > .cal-form-row { min-width: 0; }
.cal-form-inline { display: flex; gap: 8px; align-items: center; min-width: 0; }
.cal-form-inline input[type=date] { flex: 3 1 0; min-width: 0; padding-left: 12px; padding-right: 10px; }
.cal-form-inline input[type=time] { flex: 2 1 0; min-width: 0; padding-left: 12px; padding-right: 8px; }
#cal-f-summary { font-size: 18px; font-weight: 600; padding: 8px 0; border: none; border-bottom: 2px solid var(--border); border-radius: 0; }
#cal-f-summary:focus { border-bottom-color: var(--accent); box-shadow: none; }
.cal-check { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 500; color: var(--text); cursor: pointer; }
.cal-check input { width: auto; margin: 0; }
.cal-modal-error { margin: 4px 0 12px; }
.cal-modal-foot { display: flex; align-items: center; gap: 10px; margin-top: 18px; }

/* Toast */
.cal-toast {
    position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px);
    background: var(--navy); color: #fff; padding: 11px 18px; border-radius: 8px;
    font-size: 13px; box-shadow: var(--shadow-pop); opacity: 0; pointer-events: none;
    transition: opacity 0.2s, transform 0.2s; z-index: 2000; max-width: 90vw;
}
.cal-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.cal-toast.err { background: var(--accent-dark); }

@media (max-width: 860px) {
    /* Toolbar kompakt, umbrechend */
    .cal-toolbar { gap: 8px; padding: 10px 12px; }
    .cal-toolbar-left, .cal-toolbar-right { gap: 8px; flex-wrap: wrap; }
    .cal-toolbar h2 { font-size: 17px; width: 100%; order: 5; text-align: left; }
    .cal-menu-btn { display: grid; }
    #cal-new { display: none; }
    #cal-sync { padding: 9px 12px; }
    .cal-toolbar-right { flex: 1; }
    .cal-viewswitch { flex: 1; }
    .cal-viewswitch button { flex: 1; padding: 9px 4px; }
    .cal-navbtn { width: 38px; height: 38px; }

    /* Body einspaltig */
    .cal-body { grid-template-columns: 1fr; }

    /* Sidebar als Slide-in-Drawer */
    .cal-sidebar {
        display: block; position: fixed; top: 0; left: 0; bottom: 0;
        width: 84vw; max-width: 320px; z-index: 1600;
        background: var(--card); border-right: 1px solid var(--border);
        box-shadow: var(--shadow-pop);
        transform: translateX(-100%); transition: transform 0.25s ease;
        overflow-y: auto; padding: 12px 14px 24px;
    }
    .cal-sidebar.open { transform: none; }
    .cal-sidebar-head { display: flex; align-items: center; justify-content: space-between; font-weight: 700; font-size: 15px; margin-bottom: 12px; }
    .cal-drawer-backdrop { display: block; position: fixed; inset: 0; background: rgba(31,41,55,0.45); z-index: 1550; }

    /* Monatsansicht kompakter */
    .cal-mcell { min-height: 0; padding: 2px 2px 4px; }
    .cal-mcell-num { font-size: 11px; padding: 1px 3px; }
    .cal-mcell.today .cal-mcell-num span { width: 19px; height: 19px; }
    .cal-chip { font-size: 11px; padding: 1px 3px; gap: 3px; }
    .cal-chip-time { display: none; }
    .cal-month-hcell { padding: 6px 4px; font-size: 10px; }

    /* Wochenansicht: 7 Spalten horizontal scrollbar (Kopf + Body synchron) */
    .cal-tg-week { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .cal-tg-week .cal-tg-head,
    .cal-tg-week .cal-tg-allday,
    .cal-tg-week .cal-tg-scroll { min-width: 680px; }
    .cal-tg-gutter, .cal-tg-times { width: 44px; }
    .cal-tg-daynum { font-size: 17px; width: 32px; height: 32px; }

    /* Schwebender Aktionsbutton statt "+ Termin" */
    .cal-fab {
        display: grid; place-items: center;
        position: fixed; right: 18px; bottom: 18px;
        width: 56px; height: 56px; border-radius: 50%;
        background: var(--accent); color: #fff; border: none;
        box-shadow: var(--shadow-pop); z-index: 1400; cursor: pointer;
    }
    .cal-fab:active { transform: translateY(1px); }

    /* Termin-Dialog als Bottom-Sheet */
    .cal-modal-backdrop { align-items: flex-end; padding: 0; }
    .cal-modal { max-width: none; width: 100%; border-radius: 16px 16px 0 0; max-height: 92dvh; }
    .cal-form-grid { grid-template-columns: 1fr; }
}

/* ---- Feiertage & Schulferien (SH) hervorheben ---- */
.cal-chip.readonly { cursor: default; }
.cal-mcell.is-feiertag { background: #fdecea; }
.cal-mcell.is-feiertag.other { background: #f8ddd9; }
.cal-mcell.is-ferien { background: #fff7e6; }
.cal-mcell.is-ferien.other { background: #fbeccb; }
.cal-tg-hcell.is-feiertag { background: #fdecea; }
.cal-tg-hcell.is-ferien { background: #fff7e6; }
.cal-citem .cal-cdot { box-shadow: inset 0 0 0 1px rgba(0,0,0,0.08); }

/* ---- Kalender füllt ~98% des sichtbaren Bildschirms ---- */
.container:has(.cal-app) {
    max-width: none;
    width: 98vw;
    margin-left: calc(50% - 49vw);
    margin-right: calc(50% - 49vw);
    padding: 12px 1vw 1vh;
}
.cal-app {
    display: flex; flex-direction: column;
    height: calc(98vh - 132px);   /* abzgl. Topbar + Subnav + Abstände */
    min-height: 460px;
}
.cal-body { min-height: 0; flex: 1; }
.cal-main { display: flex; min-height: 0; }
.cal-grid-host { flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.cal-month { flex: 1; min-height: 0; }
.cal-month-grid { min-height: 0; }
.cal-tg { flex: 1; height: auto; min-height: 0; }

@media (max-width: 860px) {
    .container:has(.cal-app) { width: 100%; margin-left: 0; margin-right: 0; padding: 10px 8px 14px; }
    .cal-app { height: calc(100dvh - 172px); min-height: 380px; }
}

/* ============================================================
   Dokumente-Modul (Paperless)
   ============================================================ */
.pl-filter {
    display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
    margin-bottom: 18px;
}
.pl-search {
    position: relative; flex: 1 1 280px; min-width: 220px;
}
.pl-search .icon {
    position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
    width: 18px; height: 18px; color: var(--text-muted); pointer-events: none;
}
.pl-search input {
    width: 100%; padding: 9px 12px 9px 38px;
    border: 1px solid var(--border); border-radius: 10px; background: var(--card);
    color: var(--text); font: inherit;
}
.pl-filter select {
    padding: 9px 12px; border: 1px solid var(--border); border-radius: 10px;
    background: var(--card); color: var(--text); font: inherit; max-width: 220px;
}
.pl-search input:focus, .pl-filter select:focus {
    outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}

.doc-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 16px;
}
.doc-card {
    display: flex; flex-direction: column; text-decoration: none; color: inherit;
    background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
    overflow: hidden; box-shadow: var(--shadow-card);
    transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease;
}
.doc-card:hover {
    transform: translateY(-2px); box-shadow: var(--shadow-pop); border-color: var(--accent-soft);
}
.doc-thumb {
    display: block; aspect-ratio: 3 / 4; background: var(--border-soft);
    overflow: hidden; border-bottom: 1px solid var(--border);
}
.doc-thumb img { width: 100%; height: 100%; object-fit: cover; object-position: top center; display: block; }
.doc-body { display: flex; flex-direction: column; gap: 5px; padding: 11px 12px 13px; }
.doc-title {
    font-weight: 600; font-size: 13.5px; line-height: 1.35; color: var(--text);
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.doc-sub { font-size: 12px; color: var(--text-muted); }
.doc-corr { color: var(--accent-dark); font-weight: 500; }
.doc-tags { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 3px; }
.pl-chip {
    display: inline-block; padding: 2px 8px; border-radius: 999px;
    font-size: 11px; font-weight: 600; line-height: 1.5; text-decoration: none;
    background: var(--accent); color: #fff;
}

.empty-state {
    display: flex; flex-direction: column; align-items: center; gap: 12px;
    padding: 60px 20px; color: var(--text-muted); text-align: center;
}
.empty-state .icon { width: 44px; height: 44px; opacity: .5; }
.empty-state p { margin: 0; font-size: 15px; }

.pl-pager {
    display: flex; align-items: center; justify-content: center; gap: 16px;
    margin-top: 24px;
}
.pl-pageinfo { color: var(--text-muted); font-size: 13px; }
.btn.disabled { opacity: .45; pointer-events: none; }

.doc-detail .doc-preview-card { display: flex; flex-direction: column; }
.doc-preview {
    width: 100%; height: 70vh; min-height: 460px; border: 1px solid var(--border);
    border-radius: 10px; background: var(--border-soft);
}
.doc-ocr-text {
    max-height: 320px; overflow: auto; white-space: pre-wrap; word-break: break-word;
    background: var(--border-soft); border: 1px solid var(--border); border-radius: 10px;
    padding: 12px; margin: 10px 0 0; font-size: 12.5px; line-height: 1.5;
}
.doc-ocr summary { cursor: pointer; color: var(--accent-dark); font-weight: 500; }

@media (max-width: 860px) {
    .doc-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
    .doc-preview { height: 56vh; min-height: 320px; }
    .pl-filter select { flex: 1 1 140px; max-width: none; }
}

/* ============================================================
   Offene Forderungen (Finanzen)
   ============================================================ */
.btn.small { padding: 6px 10px; font-size: 12.5px; gap: 5px; border-radius: 8px; }
.btn.small .icon { width: 15px; height: 15px; }
.recv-actions { white-space: nowrap; }
.recv-actions form { display: inline; }
.recv-actions > * { vertical-align: middle; }
.recv-badge { display: inline-block; padding: 1px 7px; border-radius: 999px; font-size: 11px; font-weight: 600; margin-left: 4px; }
.recv-badge.overdue { background: #fef2f2; color: #991b1b; }
.recv-settled td { color: var(--text-muted); }
.recv-summary { cursor: pointer; color: var(--accent-dark); font-weight: 500; }

/* =============================================================
   Haushalts-Module: Aufgaben, Einkauf, Essen
   ============================================================= */

/* Modul-Icon- & Quick-Link-Farben (Ergänzung) */
.module-icon.purple { background: #ede9fe; color: #6d28d9; }
.module-icon.amber  { background: #fef3c7; color: #b45309; }
.module-icon.teal   { background: #ccfbf1; color: #0f766e; }
.quick-list .icon-tile.purple { background: #ede9fe; color: #6d28d9; }
.quick-list .icon-tile.amber  { background: #fef3c7; color: #b45309; }
.quick-list .icon-tile.teal   { background: #ccfbf1; color: #0f766e; }

/* User-Chip (Initialen + Name) */
.hh-chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text); }
.hh-chip-dot {
    display: inline-flex; align-items: center; justify-content: center;
    width: 20px; height: 20px; border-radius: 50%;
    color: #fff; font-size: 10px; font-weight: 700; flex: none;
}

/* Filter-Chips */
.hh-filter { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
    display: inline-flex; align-items: center; padding: 5px 12px;
    background: var(--bg); color: var(--text-muted); border: 1px solid var(--border);
    border-radius: 999px; font-size: 12.5px; font-weight: 600; text-decoration: none;
    transition: background .12s, color .12s, border-color .12s;
}
.chip:hover { color: var(--text); border-color: #cdd5df; }
.chip.active { background: var(--grad-brand); color: #fff; border-color: transparent; }
.chip .chip-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 7px; flex: none; }

/* Projekt-Gruppen in der Aufgaben-Liste */
.task-group { margin-top: 18px; }
.task-group:first-of-type { margin-top: 4px; }
.task-group-head {
    margin: 0 0 4px; padding: 0;
    display: flex; align-items: center; gap: 8px;
    font-size: 13px; font-weight: 700; color: var(--text);
}
.task-group-head .chip-dot { width: 10px; height: 10px; margin: 0; }
.task-group-head .muted { font-weight: 400; font-size: 12px; }

/* Checklisten (Aufgaben, Einkauf) */
.check-list { list-style: none; margin: 0; padding: 0; }
.check-row {
    display: flex; align-items: flex-start; gap: 12px;
    padding: 11px 2px; border-bottom: 1px solid var(--border-soft);
}
.check-list .check-row:last-child { border-bottom: 0; }
.check-row .check-toggle { margin-top: 2px; flex: none; }
.check-main { flex: 1; min-width: 0; }
.check-title { font-weight: 600; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.check-note { font-size: 12.5px; color: var(--text-muted); margin-top: 3px; }
.check-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; margin-top: 6px; font-size: 12px; }
.check-due { display: inline-flex; align-items: center; gap: 4px; color: var(--text-muted); }
.check-due .icon { width: 13px; height: 13px; }
.check-due.overdue { color: #b91c1c; font-weight: 600; }
.check-actions { display: flex; align-items: center; gap: 4px; flex: none; }
.check-actions form { display: inline; margin: 0; }
.check-row.is-done .check-title { text-decoration: line-through; color: var(--text-muted); font-weight: 500; }
.check-row.is-done .shop-qty { text-decoration: line-through; }

/* Prioritäts-Punkt */
.prio-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; background: var(--text-muted); }
.prio-dot.prio-high   { background: #dc2626; }
.prio-dot.prio-normal { background: #2563eb; }
.prio-dot.prio-low    { background: #94a3b8; }

/* Einkauf */
.shop-add-grid { display: grid; grid-template-columns: 2fr 1fr 1.3fr; gap: 14px; }
.shop-cat { margin-top: 16px; }
.shop-cat:first-child { margin-top: 4px; }
.shop-cat-head {
    margin: 0 0 2px; font-size: 12px; font-weight: 700; letter-spacing: .04em;
    text-transform: uppercase; color: var(--text-muted);
}
.shop-qty {
    font-size: 12px; font-weight: 600; color: var(--accent-dark);
    background: var(--accent-soft); padding: 1px 8px; border-radius: 999px;
}

/* Rezepte */
.recipe-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.recipe-card {
    display: flex; align-items: stretch; justify-content: space-between;
    border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden;
    transition: box-shadow .15s, border-color .15s;
}
.recipe-card:hover { box-shadow: var(--shadow-card); border-color: #cdd5df; }
.recipe-card-main { display: flex; align-items: center; gap: 12px; padding: 14px; text-decoration: none; color: var(--text); flex: 1; min-width: 0; }
.recipe-card-ico { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: 10px; background: #ccfbf1; color: #0f766e; flex: none; }
.recipe-card-ico .icon { width: 22px; height: 22px; }
.recipe-card-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.recipe-card-body strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.recipe-card-body .muted { font-size: 12px; }
.recipe-card-actions { display: flex; flex-direction: column; gap: 4px; padding: 10px; border-left: 1px solid var(--border-soft); justify-content: center; }
.recipe-card-actions form { margin: 0; }
.ing-add-grid { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 12px; }

/* Wochenplan */
.meal-toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; margin-bottom: 16px; }
.meal-nav { display: flex; gap: 6px; }
.meal-range { font-weight: 700; color: var(--text); }
.meal-toolbar > a.btn.small:last-child { margin-left: auto; }
.meal-grid-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.meal-grid { width: 100%; border-collapse: collapse; min-width: 760px; }
.meal-grid th, .meal-grid td { border: 1px solid var(--border); vertical-align: top; }
.meal-grid thead th {
    background: var(--bg); padding: 8px 6px; text-align: center; font-size: 12px;
}
.meal-grid thead th.is-today { background: var(--accent-soft); }
.meal-dow { display: block; font-weight: 700; color: var(--text); }
.meal-date { display: block; font-size: 11px; color: var(--text-muted); }
.meal-slot-col {
    width: 96px; background: var(--bg); font-size: 12px; font-weight: 700;
    color: var(--text-muted); text-align: left; padding: 8px; white-space: nowrap;
}
.meal-cell { padding: 5px; min-width: 92px; }
.meal-cell.is-today { background: #f5f9ff; }
.meal-entry {
    display: block; background: var(--card); border: 1px solid var(--border);
    border-left: 3px solid var(--accent); border-radius: 7px;
    padding: 6px 8px; margin-bottom: 5px; text-decoration: none; color: var(--text);
    transition: box-shadow .12s, border-color .12s;
}
.meal-entry:hover { box-shadow: 0 2px 8px rgba(15,40,70,.08); }
.meal-entry-title { display: block; font-size: 12.5px; font-weight: 600; line-height: 1.25; }
.meal-entry-cook { display: inline-flex; align-items: center; gap: 3px; font-size: 11px; color: var(--text-muted); margin-top: 3px; }
.meal-entry-cook .icon { width: 11px; height: 11px; }
.meal-entry-note { display: block; font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.meal-add {
    display: flex; align-items: center; justify-content: center;
    width: 100%; padding: 3px; border: 1px dashed var(--border);
    border-radius: 7px; color: var(--text-muted); text-decoration: none;
    transition: background .12s, color .12s, border-color .12s;
}
.meal-add:hover { background: var(--accent-soft); color: var(--accent-dark); border-color: var(--accent); }
.meal-add .icon { width: 15px; height: 15px; }
.meal-form-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }

@media (max-width: 720px) {
    .shop-add-grid, .ing-add-grid, .meal-form-grid { grid-template-columns: 1fr; }
    .meal-toolbar > a.btn.small:last-child { margin-left: 0; }
}

/* =============================================================
   Dark Mode — umschaltbar über <html data-theme="dark|light">
   (Cookie-gesteuert, serverseitig gesetzt → kein Flackern;
    Erstbesuch ohne Cookie folgt der Systemvorliebe, siehe app.js)
   ============================================================= */
:root[data-theme="dark"] {
    --bg: #0e1621;
    --card: #18222f;
    --text: #e7eef6;
    --text-muted: #9bb0c6;
    --border: #2a3744;
    --border-soft: #212c39;
    --accent: #4b8bf5;
    --accent-soft: #1d3354;
    --accent-dark: #7eb0fa;
    --green: #34d399;
    --green-dark: #10b981;
    --green-soft: #11362b;
    --teal: #2dd4bf;
    --navy: #0b1521;
    --navy-soft: #16263a;
    --blue: #60a5fa;
    --shadow-card: 0 1px 3px rgba(0,0,0,0.5), 0 8px 24px rgba(0,0,0,0.42);
    --shadow-pop: 0 12px 34px rgba(0,0,0,0.6);
    color-scheme: dark;
}
:root[data-theme="dark"] body::before,
:root[data-theme="dark"] body::after { opacity: 0.08; }

:root[data-theme="dark"] input::placeholder,
:root[data-theme="dark"] textarea::placeholder { color: #647688; }
:root[data-theme="dark"] input:hover:not(:disabled):not(:focus),
:root[data-theme="dark"] select:hover:not(:disabled):not(:focus),
:root[data-theme="dark"] textarea:hover:not(:disabled):not(:focus) { border-color: #3a4a5b; }

/* Alerts */
:root[data-theme="dark"] .alert.error   { background:#3a1d1d; color:#fecaca; border-color:#7f1d1d; }
:root[data-theme="dark"] .alert.success { background:#12321f; color:#a7f3d0; border-color:#14532d; }
:root[data-theme="dark"] .alert.info    { background:#152a45; color:#bfdbfe; border-color:#1e3a8a; }

/* Betrags-/Status-Farben mit Kontrast */
:root[data-theme="dark"] .fin-amount.pos { color:#34d399; }
:root[data-theme="dark"] .fin-amount.neg,
:root[data-theme="dark"] .check-due.overdue { color:#f87171; }

/* Danger-Buttons */
:root[data-theme="dark"] .btn.ghost.danger,
:root[data-theme="dark"] .dropdown-btn.danger { color:#f87171; }
:root[data-theme="dark"] .btn.ghost.danger:hover,
:root[data-theme="dark"] .dropdown-btn.danger:hover { background:#3a1d1d; color:#fecaca; }

/* Konto-Badges */
:root[data-theme="dark"] .acct-giro    { background:#16314f; color:#bfdbfe; }
:root[data-theme="dark"] .acct-credit  { background:#3a2e12; color:#fde68a; }
:root[data-theme="dark"] .acct-savings { background:#11362b; color:#a7f3d0; }
:root[data-theme="dark"] .acct-cash    { background:#2a2f37; color:#d1d5db; }

/* Modul-Icons + Quick-Link-Kacheln + Rezept-Icon */
:root[data-theme="dark"] .module-icon.green,
:root[data-theme="dark"] .quick-list .icon-tile.green  { background:#11362b; color:#6ee7b7; }
:root[data-theme="dark"] .module-icon.blue,
:root[data-theme="dark"] .quick-list .icon-tile.blue   { background:#16314f; color:#93c5fd; }
:root[data-theme="dark"] .module-icon.purple,
:root[data-theme="dark"] .quick-list .icon-tile.purple { background:#2c2150; color:#c4b5fd; }
:root[data-theme="dark"] .module-icon.amber,
:root[data-theme="dark"] .quick-list .icon-tile.amber  { background:#3a2e12; color:#fcd34d; }
:root[data-theme="dark"] .module-icon.teal,
:root[data-theme="dark"] .quick-list .icon-tile.teal,
:root[data-theme="dark"] .recipe-card-ico              { background:#11362b; color:#5eead4; }
:root[data-theme="dark"] .quick-list .icon-tile.navy   { background:#222f3e; color:#cbd5e1; }

/* Inline-Save-Feedback (Buchungen) */
:root[data-theme="dark"] .fin-table input.inline.save-saving { background:#3a3413; border-color:#a16207; }
:root[data-theme="dark"] .fin-table input.inline.save-saved  { background:#12321f; border-color:#15803d; }
:root[data-theme="dark"] .fin-table input.inline.save-error  { background:#3a1d1d; border-color:#b91c1c; color:#fecaca; }

/* Kalender-Tönungen */
:root[data-theme="dark"] .cal-mcell.other { background:#121b26; }
:root[data-theme="dark"] .cal-mcell.other .cal-mcell-num,
:root[data-theme="dark"] .cal-mini-day.other { color:#56697d; }
:root[data-theme="dark"] .cal-mcell.is-feiertag,
:root[data-theme="dark"] .cal-tg-hcell.is-feiertag { background:#371d1a; }
:root[data-theme="dark"] .cal-mcell.is-feiertag.other { background:#2a1714; }
:root[data-theme="dark"] .cal-mcell.is-ferien,
:root[data-theme="dark"] .cal-tg-hcell.is-ferien { background:#332a12; }
:root[data-theme="dark"] .cal-mcell.is-ferien.other { background:#241d0e; }

/* Mahlzeitenplan + Verbindlichkeiten/Preview */
:root[data-theme="dark"] .meal-cell.is-today { background:#13233a; }
:root[data-theme="dark"] .recv-badge.overdue { background:#3a1d1d; color:#fecaca; }
:root[data-theme="dark"] .fin-preview td.bad { background:#3a1d1d; color:#fecaca; }

/* ---- Theme-Umschalter (Button in der Topbar) ---- */
.theme-toggle {
    display: inline-grid; place-items: center;
    width: 40px; height: 40px; flex: none;
    border-radius: 50%;
    background: transparent; border: 1.5px solid var(--border);
    color: var(--text-muted); cursor: pointer;
    transition: background .15s, color .15s, border-color .15s;
}
.theme-toggle:hover { color: var(--text); border-color: var(--accent); background: var(--accent-soft); }
.theme-toggle .icon { width: 18px; height: 18px; }
.theme-toggle .ti { display: grid; place-items: center; }
.theme-toggle .ti-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .ti-moon { display: none; }
:root[data-theme="dark"] .theme-toggle .ti-sun { display: grid; }

/* ========================================================================
   APP SHELL — 3-Säulen-Layout (Topbar oben, Sidebar links, Content, RightPanel)
   Inspiriert vom "Alameda One"-Vorbild. Ersetzt die alte Topnav-Struktur.
   ======================================================================== */

/* Dekorative Hintergrund-Dreiecke nur noch im Login-Shell, nicht im App-Shell */
body:not(.login-shell)::before,
body:not(.login-shell)::after { display: none; }
body:not(.login-shell) { background: var(--bg); overflow-x: hidden; min-height: 100vh; }

.app-shell {
    display: grid;
    grid-template-columns: 260px 1fr 320px;
    grid-template-rows: 60px 1fr;
    grid-template-areas:
        "topbar topbar topbar"
        "sidebar content rightpanel";
    min-height: 100vh;
}
.app-shell.no-right {
    grid-template-columns: 260px 1fr;
    grid-template-areas:
        "topbar topbar"
        "sidebar content";
}

/* ---- Topbar (überschreibt alte Definition) ---- */
.app-shell .topbar {
    grid-area: topbar;
    position: sticky; top: 0; z-index: 50;
    background: var(--card);
    border-bottom: 1px solid var(--border-soft);
    border-radius: 0;
    margin: 0;
    padding: 0 16px;
    height: 60px;
    display: flex; align-items: center; gap: 12px;
    box-shadow: none;
}
.app-shell .topbar .brand { font-size: 15px; }
.app-shell .topbar .brand-mark { width: 32px; height: 32px; border-radius: 8px; }
.app-shell .topbar .brand-mark .icon { width: 18px; height: 18px; }

.menu-toggle {
    display: none;
    width: 40px; height: 40px;
    border: 0; background: transparent;
    color: var(--text-muted); cursor: pointer;
    border-radius: 8px;
}
.menu-toggle:hover { background: var(--bg); color: var(--text); }
.menu-toggle .icon { width: 22px; height: 22px; }

.topbar-search {
    flex: 1;
    max-width: 560px;
    margin: 0 auto;
    position: relative;
    display: flex; align-items: center;
}
.topbar-search .icon {
    position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
    width: 16px; height: 16px;
    color: var(--text-muted);
    pointer-events: none;
}
.topbar-search input {
    width: 100%; height: 40px;
    padding: 0 14px 0 38px;
    background: var(--bg);
    border: 1px solid var(--border-soft);
    border-radius: 999px;
    font-size: 13.5px; color: var(--text);
}
.topbar-search input::placeholder { color: var(--text-muted); }
.topbar-search input:focus { outline: none; background: var(--card); border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.topbar-search input:disabled { cursor: not-allowed; opacity: 0.7; }

.app-shell .topbar .theme-toggle { width: 36px; height: 36px; border-width: 1px; }
.app-shell .topbar .theme-toggle .icon { width: 16px; height: 16px; }
.app-shell .topbar .user-menu .avatar { width: 36px; height: 36px; font-size: 12px; box-shadow: none; }

/* ---- Sidebar ---- */
.sidebar {
    grid-area: sidebar;
    background: var(--card);
    border-right: 1px solid var(--border-soft);
    position: sticky; top: 60px;
    height: calc(100vh - 60px);
    overflow-y: auto;
    padding: 12px 8px 28px;
    scrollbar-width: thin;
}
.side-nav { display: flex; flex-direction: column; gap: 1px; }
.side-item {
    display: flex; align-items: center; gap: 12px;
    padding: 9px 12px;
    color: var(--text); text-decoration: none;
    font-size: 14px; font-weight: 500;
    border-radius: 8px; cursor: pointer;
    transition: background .12s, color .12s;
    user-select: none;
}
.side-item:hover { background: var(--bg); color: var(--text); }
.side-item.active { background: var(--accent-soft); color: var(--accent-dark); font-weight: 600; }
.side-item .side-icon { display: grid; place-items: center; width: 22px; height: 22px; color: var(--text-muted); flex: none; }
.side-item.active .side-icon { color: var(--accent-dark); }
.side-item .side-icon .icon { width: 18px; height: 18px; }
.side-item .side-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-item .side-chevron { color: var(--text-muted); display: grid; place-items: center; transition: transform .15s ease; }
.side-item .side-chevron .icon { width: 16px; height: 16px; }

.side-section { padding: 0; }
.side-section > summary { list-style: none; }
.side-section > summary::-webkit-details-marker { display: none; }
.side-section[open] > summary .side-chevron { transform: rotate(90deg); }

.side-sub {
    display: flex; flex-direction: column; gap: 1px;
    margin: 2px 0 4px 32px;
    padding-left: 6px;
    border-left: 1.5px solid var(--border-soft);
}
.side-subitem {
    display: block; padding: 6px 10px;
    color: var(--text-muted); text-decoration: none;
    font-size: 13px; font-weight: 500;
    border-radius: 6px;
}
.side-subitem:hover { background: var(--bg); color: var(--text); }
.side-subitem.active { color: var(--accent-dark); font-weight: 600; background: var(--accent-soft); }
.side-sep { height: 1px; background: var(--border-soft); margin: 10px 8px; }

.sidebar-backdrop {
    display: none;
    position: fixed; inset: 0;
    background: rgba(15, 40, 70, 0.5);
    z-index: 90;
}

/* ---- Content ---- */
.content {
    grid-area: content;
    padding: 22px clamp(16px, 3vw, 32px) 60px;
    min-width: 0;
    background: transparent;
}

/* ---- Right Panel (z. B. Home: Quick Actions / Schnellzugriff) ---- */
.rightpanel {
    grid-area: rightpanel;
    background: var(--card);
    border-left: 1px solid var(--border-soft);
    padding: 22px 18px;
    position: sticky; top: 60px;
    height: calc(100vh - 60px);
    overflow-y: auto;
}
.rightpanel h3 {
    margin: 18px 0 8px;
    font-size: 11px; font-weight: 700;
    letter-spacing: 0.08em; text-transform: uppercase;
    color: var(--text-muted);
}
.rightpanel h3:first-of-type { margin-top: 14px; }
.quick-actions-btn {
    width: 100%; padding: 12px 14px;
    background: var(--grad-brand); color: #fff;
    border: 0; border-radius: 10px;
    font-weight: 700; font-size: 14px; cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    box-shadow: 0 4px 12px rgba(37,99,235,0.22);
    text-decoration: none;
}
.quick-actions-btn .icon { width: 18px; height: 18px; }
.rp-greet { display: flex; align-items: center; gap: 12px; margin-top: 22px; }
.rp-greet .avatar { width: 44px; height: 44px; font-size: 15px; }
.rp-greet .who { font-size: 14px; font-weight: 700; line-height: 1.2; }
.rp-greet .muted { font-size: 12px; }
.rp-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.rp-list a { display: flex; align-items: center; gap: 10px; padding: 7px 6px; border-radius: 7px; color: var(--text); text-decoration: none; font-size: 13.5px; }
.rp-list a:hover { background: var(--bg); }
.rp-list .icon-tile { width: 26px; height: 26px; border-radius: 6px; display: grid; place-items: center; flex: none; background: var(--accent-soft); color: var(--accent); }
.rp-list .icon-tile .icon { width: 15px; height: 15px; }
.rp-more { display: inline-block; margin-top: 6px; font-size: 12px; color: var(--accent); text-decoration: none; padding: 4px 6px; }

/* Subnav-Chips (.fin-subnav) ablösen — Sidebar zeigt jetzt aktive Unterseite */
.fin-subnav { display: none !important; }

/* ---- Bento-Dashboard ---- */
.section-cap {
    font-size: 11px; font-weight: 700;
    letter-spacing: 0.08em; text-transform: uppercase;
    color: var(--accent); margin: 22px 4px 6px;
}
.section-cap:first-child { margin-top: 4px; }
.section-title { margin: 0 0 14px; font-size: 22px; font-weight: 700; color: var(--text); }

.bento { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.bento-tile {
    background: var(--card);
    border-radius: var(--radius);
    padding: 18px;
    text-decoration: none; color: var(--text);
    border: 1px solid var(--border-soft);
    display: flex; flex-direction: column; gap: 10px;
    transition: box-shadow .15s, border-color .15s, transform .05s;
    min-height: 130px;
    position: relative;
}
.bento-tile:hover { box-shadow: var(--shadow-card); border-color: var(--border); }
.bento-tile:active { transform: translateY(1px); }
.bento-tile.span-2 { grid-column: span 2; }
.bento-tile.span-2-rows { grid-row: span 2; }
.bento-tile.accent { background: var(--grad-brand); color: #fff; border-color: transparent; }
.bento-tile.accent .bento-meta, .bento-tile.accent .bento-cta { color: rgba(255,255,255,0.92); }
.bento-tile.accent .bento-icon { background: rgba(255,255,255,0.2); color: #fff; }
.bento-tile .bento-icon { width: 40px; height: 40px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; flex: none; }
.bento-tile .bento-icon .icon { width: 22px; height: 22px; }
.bento-tile .bento-title { font-size: 15px; font-weight: 700; line-height: 1.25; }
.bento-tile .bento-value { font-size: 28px; font-weight: 700; line-height: 1.1; }
.bento-tile .bento-meta { font-size: 12px; color: var(--text-muted); }
.bento-tile .bento-cta { margin-top: auto; font-size: 12.5px; color: var(--accent); display: inline-flex; align-items: center; gap: 5px; font-weight: 600; }
.bento-tile.accent .bento-cta { color: #fff; }
.bento-tile.compact { min-height: 0; padding: 14px; }

@media (max-width: 1200px) { .bento { grid-template-columns: repeat(3, 1fr); } .bento-tile.span-2 { grid-column: span 2; } }
@media (max-width: 900px)  { .bento { grid-template-columns: repeat(2, 1fr); } .bento-tile.span-2 { grid-column: span 2; } }
@media (max-width: 500px)  { .bento { grid-template-columns: 1fr; } .bento-tile.span-2 { grid-column: span 1; } }

/* ---- Mobile (≤ 1100px: RightPanel weg; ≤ 760px: Sidebar als Drawer) ---- */
@media (max-width: 1100px) {
    .app-shell, .app-shell.no-right {
        grid-template-columns: 260px 1fr;
        grid-template-areas:
            "topbar topbar"
            "sidebar content";
    }
    .rightpanel { display: none; }
}
@media (max-width: 760px) {
    .app-shell, .app-shell.no-right {
        grid-template-columns: 1fr;
        grid-template-rows: 60px 1fr;
        grid-template-areas:
            "topbar"
            "content";
    }
    .sidebar {
        position: fixed; top: 0; left: 0;
        width: 280px; height: 100dvh;
        z-index: 100;
        transform: translateX(-100%);
        transition: transform .18s ease;
        box-shadow: 0 0 24px rgba(15,40,70,0.18);
        padding-top: 14px;
    }
    .sidebar.open { transform: translateX(0); }
    body.sidebar-open .sidebar-backdrop { display: block; }
    .menu-toggle { display: grid; place-items: center; }
    .app-shell .topbar { padding: 0 10px; gap: 8px; }
    .topbar-search { display: none; }
    .content { padding: 16px 14px 40px; }
    .app-shell .topbar .brand-name { font-size: 14px; }
}

/* ---- Dark-Mode-Feinheiten für neue Komponenten ---- */
:root[data-theme="dark"] .topbar-search input { background: var(--bg); }
:root[data-theme="dark"] .topbar-search input:focus { background: var(--card); }
:root[data-theme="dark"] .quick-actions-btn { box-shadow: 0 4px 12px rgba(75,139,245,0.32); }
:root[data-theme="dark"] .side-item.active { background: var(--accent-soft); color: #cfe1ff; }
:root[data-theme="dark"] .side-item.active .side-icon { color: #cfe1ff; }
:root[data-theme="dark"] .side-subitem.active { color: #cfe1ff; }
:root[data-theme="dark"] .sidebar-backdrop { background: rgba(0,0,0,0.6); }

/* ChurchTools-Import-Button + „Im Kalender"-Marker */
.ct-import-btn { white-space: nowrap; }
.ct-import-btn[disabled] { opacity: .7; cursor: wait; }
.ct-import-btn.save-saving { background: #fef9c3; color: #854d0e; border-color: #fde047; }
.ct-import-btn.save-error  { background: #fef2f2; color: #b91c1c !important; border-color: #fecaca; }
:root[data-theme="dark"] .ct-import-btn.save-saving { background: #3a3413; color: #fde68a; border-color: #a16207; }
:root[data-theme="dark"] .ct-import-btn.save-error  { background: #3a1d1d; color: #fecaca !important; border-color: #7f1d1d; }
.ct-import-pill {
    display: inline-flex; align-items: center; gap: 5px;
    font-size: 12.5px; font-weight: 600;
    color: var(--accent-dark);
    background: var(--accent-soft);
    padding: 5px 10px; border-radius: 999px;
    white-space: nowrap;
}
.ct-import-pill .icon { width: 14px; height: 14px; }
@media (max-width: 540px) {
    .ct-import-btn-label { display: none; }
    .ct-import-btn { padding: 6px 8px; }
}
:root[data-theme="dark"] .ct-import-pill { color: #cfe1ff; }
:root[data-theme="dark"] .ct-import-btn.save-error { color: #fecaca; }

/* Anwesenheits-Strip auf der Startseite */
.presence-strip {
    display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
    margin: 0 0 22px;
    padding: 10px 14px;
    background: var(--card);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
    text-decoration: none; color: var(--text);
    transition: border-color .12s, box-shadow .12s;
}
.presence-strip:hover { border-color: var(--border); box-shadow: var(--shadow-card); }
.presence-strip-label {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: 11px; font-weight: 700;
    letter-spacing: 0.08em; text-transform: uppercase;
    color: var(--text-muted);
    margin-right: 4px;
}
.presence-strip-label .icon { width: 14px; height: 14px; }
.presence-strip-more {
    margin-left: auto;
    font-size: 12px; font-weight: 600; color: var(--accent);
    white-space: nowrap;
}

.presence-chip {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 3px 12px 3px 3px;
    background: var(--bg);
    border-radius: 999px;
    font-size: 13px; font-weight: 500;
    border: 1.5px solid transparent;
    transition: background .12s, border-color .12s, color .12s;
}
.presence-chip .avatar {
    width: 26px; height: 26px;
    font-size: 10px; box-shadow: none;
    border: 2px solid var(--card);
}
.presence-chip-name { line-height: 1; }
.presence-chip-dot {
    width: 8px; height: 8px; border-radius: 50%;
    background: #94a3b8;
    flex: none;
}
.presence-chip.online {
    background: #d1fae5; color: #065f46;
    border-color: #6ee7b7;
}
.presence-chip.online .presence-chip-dot {
    background: #10b981;
    box-shadow: 0 0 0 3px rgba(16,185,129,0.22);
}
.presence-chip.offline { color: var(--text-muted); }

@media (max-width: 540px) {
    .presence-strip-more { display: none; }
    .presence-chip { padding: 3px 10px 3px 3px; }
    .presence-chip .avatar { width: 22px; height: 22px; font-size: 9px; }
}

/* Dark Mode */
:root[data-theme="dark"] .presence-chip { background: #1b2532; }
:root[data-theme="dark"] .presence-chip.online {
    background: #11362b; color: #6ee7b7; border-color: #14533b;
}
:root[data-theme="dark"] .presence-chip.online .presence-chip-dot {
    background: #34d399; box-shadow: 0 0 0 3px rgba(52,211,153,0.22);
}

/* Tür-Status-Punkt (Sicherheits-Modul-Events) */
.door-list { list-style: none; margin: 0; padding: 0; }
.door-list li {
    display: flex; align-items: center; justify-content: space-between;
    gap: 10px; padding: 9px 2px;
    border-bottom: 1px solid var(--border);
}
.door-list li:last-child { border-bottom: none; }
.door-list .door-who { font-weight: 600; }
.door-list .door-meta { color: var(--text-muted); font-size: 12.5px; }
.door-list .door-when { color: var(--text-muted); font-size: 12px; white-space: nowrap; }
.door-dot {
    display: inline-block;
    width: 8px; height: 8px;
    border-radius: 50%;
    margin-right: 8px;
    vertical-align: middle;
    background: var(--text-muted);
    flex-shrink: 0;
}
.door-dot.ok   { background: var(--green); }
.door-dot.warn { background: #d97706; }
.door-dot.deny { background: #dc2626; }
:root[data-theme="dark"] .door-dot.warn { background: #f59e0b; }
:root[data-theme="dark"] .door-dot.deny { background: #ef4444; }

/* NVR-Alarmbild-Galerie */
.nvr-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 10px;
}
.nvr-tile {
    display: block;
    position: relative;
    aspect-ratio: 16 / 9;
    border-radius: 8px;
    overflow: hidden;
    background: var(--bg);
    border: 1px solid var(--border);
    text-decoration: none;
    color: inherit;
    transition: transform .12s ease, box-shadow .12s ease;
}
.nvr-tile:hover { transform: scale(1.02); box-shadow: 0 4px 14px rgba(0,0,0,.1); }
.nvr-tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.nvr-tile-meta {
    position: absolute; left: 0; right: 0; bottom: 0;
    padding: 6px 8px;
    display: flex; justify-content: space-between; align-items: baseline;
    font-size: 11.5px;
    color: #fff;
    background: linear-gradient(to top, rgba(0,0,0,.7), rgba(0,0,0,0));
}
.nvr-tile-time { font-weight: 600; }
.nvr-tile-cam  { opacity: .85; }

.nvr-viewer-head {
    display: flex; justify-content: space-between; align-items: center;
    flex-wrap: wrap; gap: 10px; margin-bottom: 12px;
}
.nvr-viewer-nav { display: flex; gap: 6px; }
.nvr-viewer-img {
    background: #000;
    border-radius: 8px;
    overflow: hidden;
    display: flex; justify-content: center;
}
.nvr-viewer-img img {
    max-width: 100%; max-height: 70vh;
    height: auto; width: auto;
    object-fit: contain;
}

/* Kalender-Tag-Block auf der Startseite (kompakt) */
.cal-day + .cal-day { margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--border); }
.cal-day-head {
    margin: 0 0 2px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.4px;
}
.cal-day-list { list-style: none; margin: 0; padding: 0; }
.cal-day-list li {
    display: flex; align-items: center; gap: 8px;
    padding: 2px 0;
    font-size: 13px;
    line-height: 1.35;
}
.cal-dot {
    display: inline-block;
    width: 8px; height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}
.cal-time { color: var(--text-muted); font-size: 12px; min-width: 78px; }
.cal-summary { font-weight: 500; }
.cal-loc { font-size: 12px; }

/* Anwesenheits-Chip-Reihe auf der Startseite */
.presence-chip-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

/* Login-Versuche */
.login-list { list-style: none; margin: 0; padding: 0; }
.login-list li {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 2px;
    font-size: 13.5px;
    border-bottom: 1px solid var(--border);
}
.login-list li:last-child { border-bottom: none; }
.login-dot {
    display: inline-block;
    width: 8px; height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}
.login-dot.ok   { background: var(--green); }
.login-dot.fail { background: #dc2626; }
:root[data-theme="dark"] .login-dot.fail { background: #ef4444; }
.login-when { margin-left: auto; font-size: 12px; white-space: nowrap; }

/* Generisches Modal (verwendet aktuell vom Aufgaben-Modul) */
.modal-backdrop {
    position: fixed; inset: 0; background: rgba(31,41,55,0.45);
    display: grid; place-items: center; z-index: 1000; padding: 16px;
}
.modal {
    background: var(--card); border-radius: 12px; box-shadow: var(--shadow-pop);
    width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto;
}
.modal-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 20px; border-bottom: 1px solid var(--border-soft);
}
.modal-head h2 { margin: 0; font-size: 17px; }
.modal-close {
    border: none; background: none; font-size: 26px; line-height: 1;
    color: var(--text-muted); cursor: pointer;
}
.modal-close:hover { color: var(--text); }
.modal-body { padding: 16px 20px 20px; }
.modal-foot { display: flex; align-items: center; gap: 10px; margin-top: 18px; }

@media (max-width: 640px) {
    .modal-backdrop { align-items: flex-end; padding: 0; }
    .modal { max-width: none; width: 100%; border-radius: 16px 16px 0 0; max-height: 92dvh; }
}
