* { box-sizing: border-box; }

:root {
    /* Radny Farbschema (aktuell):
       var(--bg) Background | #27548A Main Light | var(--text) Main Dark | #DDA853 Contrast */
    --bg: #F3F3E0;
    --surface: #ffffff;
    --surface-alt: #ECECD8;
    --border: rgba(24, 59, 78, 0.10);
    --border-strong: rgba(24, 59, 78, 0.22);
    --text: #183B4E;
    --text-muted: #41576A;
    --main-dark: #183B4E;
    --main-dark-soft: #234B63;
    --accent: #27548A;
    --accent-hover: #1E4370;
    --accent-strong: #27548A;
    --accent-soft: #E4EAF2;
    --contrast: #DDA853;
    --contrast-hover: #C9922F;
    --contrast-soft: #F8EDD6;
    --success: #2f7d4f;
    --success-soft: #e7f2ea;
    --danger: #B5432F;
    --danger-soft: #F6E5E0;
    --save: #B07E2E;
    --save-soft: #F8EDD6;
    --radius: 16px;
    --radius-sm: 8px;
    --shadow-sm: 0 1px 2px rgba(24, 59, 78, 0.07);
    --shadow-md: 0 18px 54px rgba(20, 47, 62, 0.25);
    --font-sans: "Montserrat", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* --- Dark Mode --- */
html[data-theme="dark"] {
    --bg: #10212B;
    --surface: #17303D;
    --surface-alt: #1E3B4A;
    --border: rgba(243, 243, 224, 0.12);
    --border-strong: rgba(243, 243, 224, 0.26);
    --text: #EDF2F6;
    --text-muted: #A3B6C4;
    --main-dark: #0B1820;
    --main-dark-soft: #1E3B4A;
    --accent: #5B8FCB;
    --accent-hover: #7BA7DA;
    --accent-strong: #8FB6E0;
    --accent-soft: #1D3A52;
    --contrast: #DDA853;
    --contrast-hover: #EBBD72;
    --contrast-soft: #3A2F1B;
    --success: #5FBE87;
    --success-soft: #1B3527;
    --danger: #E0755C;
    --danger-soft: #3A241F;
    --save: #D9A854;
    --save-soft: #3A2F1B;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
    --shadow-md: 0 18px 54px rgba(0, 0, 0, 0.55);
}



html, body {
    margin: 0;
    font-family: var(--font-sans);
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

.page {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* --- Topbar --- */

.topbar {
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 0 28px;
    background: var(--bg);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    min-height: 64px;
    flex-wrap: wrap;
}

.topnav-brand {
    display: flex;
    align-items: center;
    gap: 11px;
    text-decoration: none;
    white-space: nowrap;
}

.brand-logo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    flex: none;
}

.brand-logo svg { width: 28px; height: 28px; }

.brand-text { display: flex; flex-direction: column; align-items: flex-start; }
.brand-text .zeile1 {
    font-size: 15px;
    font-weight: 800;
    letter-spacing: 0.14em;
    color: var(--text);
}
.brand-text .zeile2 {
    font-size: 6.5px;
    font-weight: 600;
    letter-spacing: 0.36em;
    color: #DDA853;
    margin-top: 2px;
    text-transform: uppercase;
}

.topnav-links {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
    flex: 1;
}

.nav-link {
    display: inline-flex;
    align-items: center;
    padding: 20px 10px 18px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 13.5px;
    font-weight: 600;
    letter-spacing: 0.02em;
    white-space: nowrap;
    border-bottom: 2px solid transparent;
    transition: color 0.12s ease, border-color 0.12s ease;
}

.nav-link:hover {
    color: var(--text);
}

.nav-link.active {
    color: var(--text);
    border-bottom-color: #DDA853;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-left: auto;
}

.build-tag {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    background: var(--surface-alt);
    border-radius: 999px;
    padding: 4px 10px;
    margin-right: 6px;
}

.toolbar-label {
    font-size: 11px;
    font-weight: 700;
    color: #DDA853;
    text-transform: uppercase;
    letter-spacing: 0.3em;
}

.year-picker {
    display: inline-flex;
    align-items: center;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--surface);
}

.year-step {
    background: transparent;
    border: none;
    padding: 5px 11px;
    font-size: 15px;
    line-height: 1;
    color: var(--text-muted);
    border-radius: 0;
    cursor: pointer;
}

.year-step:hover { background: var(--surface-alt); color: var(--text); }

.year-value {
    padding: 5px 12px;
    font-size: 13.5px;
    font-weight: 700;
    color: var(--main-dark);
    min-width: 50px;
    text-align: center;
}

.year-reset {
    background: var(--main-dark);
    color: var(--bg);
    border: none;
    padding: 8px 16px;
    font-size: 12.5px;
    font-weight: 700;
    border-radius: 999px;
    cursor: pointer;
}

.year-reset:hover { background: var(--main-dark-soft); }

.user-tag {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
}

.logout-btn {
    background: transparent;
    border: 1px solid var(--border-strong);
    color: var(--text-muted);
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 600;
    border-radius: 999px;
    cursor: pointer;
}
.logout-btn:hover { background: var(--surface-alt); color: var(--text); }

.theme-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    background: transparent;
    border: 1px solid var(--border-strong);
    border-radius: 999px;
    color: var(--text-muted);
    cursor: pointer;
}
.theme-btn svg { width: 15px; height: 15px; }
.theme-btn:hover { background: var(--surface-alt); color: var(--text); }


.readonly-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 32px;
    background: var(--contrast-soft);
    border-bottom: 1px solid var(--contrast);
    font-size: 13px;
    color: #6b5219;
}

.plain-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    gap: 6px;
    font-size: 14px;
}

/* --- Content --- */

main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.content {
    padding: 28px 32px 40px;
    width: 100%;
    max-width: 1600px;
    margin: 0 auto;
}

h3 {
    margin: 2rem 0 1rem;
    font-family: var(--font-sans);
    font-size: 17px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: 0.01em;
}
h3:first-child { margin-top: 0; }

h4 {
    font-size: 11.5px;
    font-weight: 700;
    color: #DDA853;
    text-transform: uppercase;
    letter-spacing: 0.28em;
    margin: 1.5rem 0 0.75rem;
}

.muted { color: var(--text-muted); font-size: 13.5px; line-height: 1.65; }
.bold { font-weight: 600; }
.pos { color: var(--success); }
.neg { color: var(--danger); }
.saved { color: var(--save); }

.hint { color: var(--danger); font-size: 13.5px; margin-top: -4px; }

/* --- Cards --- */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 18px 22px;
    margin-bottom: 12px;
}

.card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 4px;
}

.card h4 {
    margin: 0 0 2px;
    font-family: var(--font-sans);
    font-size: 15.5px;
    font-weight: 700;
    color: var(--text);
    text-transform: none;
    letter-spacing: normal;
}

.form-card { max-width: 680px; }

/* --- Forms --- */

.form-grid { display: grid; gap: 14px; }
.form-row { display: flex; flex-direction: column; gap: 5px; }
.form-row.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-row label { font-size: 12.5px; color: var(--text-muted); font-weight: 500; }

input[type=text], input[type=password], input[type=number], input[type=date], input[type=month], select, textarea {
    padding: 9px 11px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    font-size: 14px;
    background: var(--surface);
    color: var(--text);
    width: 100%;
    font-family: inherit;
    box-sizing: border-box;
}

textarea { resize: vertical; }

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.check-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    cursor: pointer;
}

.check-row input[type=checkbox] {
    width: 16px;
    height: 16px;
    accent-color: var(--accent);
}


/* --- Passwort-Stärkeindikator --- */
.pw-meter {
    height: 5px;
    border-radius: 999px;
    background: var(--surface-alt);
    overflow: hidden;
    margin-top: 6px;
}

.pw-meter-fill {
    height: 100%;
    width: 0%;
    border-radius: 999px;
    transition: width 0.15s ease, background 0.15s ease;
}

.pw-label {
    display: block;
    font-size: 11.5px;
    font-weight: 600;
    margin-top: 4px;
    min-height: 14px;
}

input[type=range] {
    width: 100%;
    accent-color: var(--accent);
}

.btn-row {
    display: flex;
    gap: 10px;
    margin-top: 4px;
}

button, .btn-primary, .btn-secondary, .btn-danger {
    cursor: pointer;
    border: none;
    border-radius: var(--radius-sm);
    padding: 9px 16px;
    font-size: 13.5px;
    font-weight: 600;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    transition: background 0.12s ease, transform 0.05s ease;
}

button:active { transform: scale(0.98); }

.btn-primary { background: var(--contrast); color: var(--text); width: fit-content; border-radius: 999px; padding: 11px 24px; font-weight: 700; }
.btn-primary:hover { background: var(--contrast-hover); }

.btn-secondary { background: transparent; color: var(--text); border: 2px solid var(--text); width: fit-content; border-radius: 999px; padding: 9px 22px; font-weight: 700; }
.btn-secondary:hover { background: var(--surface-alt); }

.btn-danger { background: var(--danger-soft); color: var(--danger); width: fit-content; }
.btn-danger:hover { background: #f2d9d1; }

.btn-sm { padding: 5px 10px; font-size: 12px; }

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border: 1px solid var(--border-strong);
    background: var(--surface);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    text-decoration: none;
    cursor: pointer;
}

.icon-btn svg { width: 15px; height: 15px; }

.icon-btn:hover { background: var(--surface-alt); color: var(--text); }

.icon-btn.delete { color: var(--danger); border-color: var(--danger-soft); }
.icon-btn.delete:hover { background: var(--danger-soft); border-color: var(--danger); }

hr { border: none; border-top: 1px solid var(--border); margin: 1.6rem 0; }

/* --- Tables --- */

.table-card, .mini-table-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    overflow-x: auto;
}

.mini-table-card {
    border-radius: var(--radius-sm);
    box-shadow: none;
    margin-top: 10px;
}

.tbl {
    border-collapse: collapse;
    width: 100%;
    font-size: 13.5px;
}

.tbl th, .tbl td {
    text-align: left;
    padding: 11px 16px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.tbl th {
    color: var(--text-muted);
    font-weight: 600;
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    background: var(--surface-alt);
}

.tbl tbody tr:last-child td { border-bottom: none; }
.tbl tbody tr:hover { background: var(--surface-alt); }

.tbl th.sortable { cursor: pointer; user-select: none; }
.tbl th.sortable:hover { color: var(--text); }

.mini-table-card .tbl { font-size: 12.5px; }
.mini-table-card .tbl th, .mini-table-card .tbl td { padding: 7px 12px; }

.row-actions { display: flex; gap: 6px; }

/* --- Modal --- */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(38, 37, 35, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    padding: 20px;
}

.modal-card {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    padding: 24px 28px;
    width: 100%;
    max-width: 640px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.modal-header h3 { font-weight: 700; }

.modal-close {
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    width: 30px;
    height: 30px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
}
.modal-close svg { width: 16px; height: 16px; }
.modal-close:hover { background: var(--surface-alt); color: var(--text); }

/* --- Badges / kleine Elemente --- */

.badge {
    font-family: var(--font-sans);
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--surface-alt);
    border: 1px solid var(--border);
    font-size: 11.5px;
    font-weight: 500;
    color: var(--text-muted);
}

.badge.accent { background: var(--accent-soft); border-color: var(--accent-soft); color: var(--accent-strong); }
.badge.success { background: var(--success-soft); border-color: var(--success-soft); color: var(--success); }

.status-select {
    padding: 5px 8px;
    font-size: 12.5px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-strong);
    background: var(--surface);
    color: var(--text);
    width: auto;
}

.shop-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: var(--accent-strong);
    text-decoration: none;
    font-size: 12.5px;
}
.shop-link:hover { text-decoration: underline; }
.shop-link svg { width: 12px; height: 12px; }

/* --- Summary cards --- */

.summary-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    max-width: 760px;
    margin-bottom: 1rem;
}

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

/* --- Bar chart (Prognose) --- */

.chart-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 16px 18px 10px;
}

.chart-period {
    font-size: 11.5px;
    font-weight: 600;
    color: var(--text-muted);
    background: var(--surface-alt);
    display: inline-block;
    padding: 4px 10px;
    border-radius: 999px;
    margin: 0 0 12px;
}

.range-btns {
    display: flex;
    gap: 6px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}

.range-btn {
    border-radius: 999px;
    background: var(--surface-alt);
    border: 1px solid var(--border-strong);
    color: var(--text-muted);
    padding: 6px 14px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
}

.range-btn:hover { background: var(--border); color: var(--text); }

.range-btn.active {
    background: var(--main-dark);
    border-color: var(--main-dark);
    color: #fff;
}

.chart-wrap {
    position: relative;
}

.chart {
    display: flex;
    align-items: flex-end;
    height: 285px;
    padding-bottom: 4px;
    overflow-x: auto;
}

.chart-overlay {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 245px;
    pointer-events: none;
}

.chart-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    height: 100%;
    flex: 1 1 0;
    min-width: 22px;
    padding: 0 3px;
    box-sizing: border-box;
}

.bar-pair {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 3px;
    height: 245px;
    width: 100%;
}

.chart-label-zone {
    height: 36px;
    overflow: hidden;
    margin-top: 4px;
}

.bar { flex: 1 1 0; max-width: 24px; border-radius: 3px 3px 0 0; }

.bar-stack {
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    height: 100%;
    flex: 1 1 0;
    max-width: 24px;
}

.bar-stack .seg { width: 100%; flex: none; }
.bar-stack .bar-neg { box-shadow: inset 0 2px 0 var(--surface); }
.bar-stack .seg:first-child { border-radius: 3px 3px 0 0; }

.bar-pos { background: var(--success); }
.bar-neg { background: var(--danger); }
.bar-save { background: var(--contrast); }

.chart-label {
    font-family: var(--font-sans);
    font-size: 9px;
    color: var(--text-muted);
    writing-mode: vertical-rl;
}

.legend { display: flex; align-items: center; gap: 4px; margin-top: 8px; flex-wrap: wrap; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 3px; }
.dot-pos { background: var(--success); }
.dot-neg { background: var(--danger); margin-left: 10px; }
.dot-save { background: var(--contrast); margin-left: 10px; }

/* --- SVG-Liniencharts (Kontostand, Sparen, 10 Jahre) --- */

.konto-chart {
    width: 100%;
    height: auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 10px;
}
