/* =========================================================
   BILANZ — style.css
   Design: privates Bankhaus / Ledger-Ästhetik
   Palette: tiefes Tinten-Schwarz + gebürstetes Messing

   Die Optik der ersten Fassung ist unverändert. Neu hinzugekommen
   sind nur die Bausteine, die es vorher nicht gab:
   Buchkreis-Umschalter, Ausgabenbuch, Einstellungen, Meldungen.
========================================================= */

:root {
    --ink-1: #0a0c10;
    --ink-2: #12151b;
    --ink-3: #1a1e26;
    --ink-4: #22262f;

    --line: rgba(214, 188, 140, 0.14);
    --line-strong: rgba(214, 188, 140, 0.26);

    --text: #ede8dc;
    --text-soft: #b9b3a4;
    --text-muted: #7d7669;

    --brass: #b6903f;
    --brass-light: #e3caa0;
    --brass-dim: rgba(182, 144, 63, 0.35);

    --income: #9db98c;
    --income-soft: #cfe0c2;
    --cost: #a9645a;
    --cost-soft: #dcb3ab;
    --loan: #7c93ab;
    --loan-soft: #c3d0dd;

    --radius: 3px;
    --radius-md: 6px;

    --serif: "Cormorant Garamond", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
    --sans: "Inter", "Segoe UI", Roboto, Arial, sans-serif;

    --transition: 220ms cubic-bezier(.22,.61,.36,1);
}

/* =========================================================
   THEME: ELFENBEIN & EBENHOLZ (helles Kontor-Papier)
========================================================= */
:root[data-theme="ivory"] {
    --ink-1: #f6f1e5;
    --ink-2: #efe7d4;
    --ink-3: #e6dbc0;
    --ink-4: #dccdaa;

    --line: rgba(35, 28, 15, 0.14);
    --line-strong: rgba(35, 28, 15, 0.26);

    --text: #211c12;
    --text-soft: #4d4432;
    --text-muted: #857a61;

    --brass: #8a6423;
    --brass-light: #6b4c19;
    --brass-dim: rgba(138, 100, 35, 0.30);

    --income: #4d7a44;
    --income-soft: #3c6234;
    --cost: #963f34;
    --cost-soft: #7d332a;
    --loan: #38607e;
    --loan-soft: #2c4c64;
}

/* =========================================================
   THEME: SAPHIR & PLATIN (kühles Nacht-Kontor)
========================================================= */
:root[data-theme="sapphire"] {
    --ink-1: #070b14;
    --ink-2: #0d1420;
    --ink-3: #16202f;
    --ink-4: #1e2b3d;

    --line: rgba(198, 209, 224, 0.14);
    --line-strong: rgba(198, 209, 224, 0.26);

    --text: #edf1f7;
    --text-soft: #c3ccd9;
    --text-muted: #7c8798;

    --brass: #9fb4c9;
    --brass-light: #d7e2ee;
    --brass-dim: rgba(159, 180, 201, 0.35);

    --income: #8fae8e;
    --income-soft: #c6d9c4;
    --cost: #b3766a;
    --cost-soft: #e0b8ab;
    --loan: #c19a63;
    --loan-soft: #e6cd9e;
}

* , *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    margin: 0;
    min-height: 100vh;
    background: var(--ink-1);
    color: var(--text);
    font-family: var(--sans);
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    transition: background var(--transition), color var(--transition);
}

/* subtle vignette / paper-grain feel without images */
.seal-noise {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background:
        radial-gradient(circle at 18% 10%, rgba(182,144,63,0.05), transparent 40%),
        radial-gradient(circle at 85% 90%, rgba(124,147,171,0.04), transparent 45%),
        radial-gradient(ellipse at center, transparent 55%, rgba(0,0,0,0.55) 130%);
}

button, input, select, textarea { font: inherit; color: inherit; }

input, select, textarea {
    background: var(--ink-2);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 11px 12px;
    outline: none;
    min-width: 0;
}

input::placeholder { color: var(--text-muted); }

input:focus, select:focus, textarea:focus {
    border-color: var(--brass-dim);
    box-shadow: 0 0 0 3px rgba(182,144,63,0.10);
}

/* Sichtbar für Tastaturnutzer — sonst ist die App nur mit Maus bedienbar */
button:focus-visible, a:focus-visible {
    outline: 2px solid var(--brass);
    outline-offset: 2px;
}

button { cursor: pointer; border: none; }

::selection { background: rgba(182,144,63,0.30); color: #fff; }

.frame {
    position: relative;
    z-index: 1;
    max-width: 1180px;
    margin: 0 auto;
    padding: 40px 28px 60px;
}

/* =========================================================
   MASTHEAD
========================================================= */
.masthead {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 18px;
    padding-bottom: 22px;
    margin-bottom: 18px;
    border-bottom: 1px solid var(--line-strong);
}

.masthead-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.seal { color: var(--brass); flex-shrink: 0; }

.masthead-title h1 {
    margin: 0;
    font-family: var(--serif);
    font-weight: 600;
    font-size: 2.6rem;
    letter-spacing: 0.03em;
    color: var(--text);
}

.masthead-sub {
    margin: 2px 0 0;
    font-size: 0.72rem;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--brass-light);
}

.masthead-date {
    font-family: var(--serif);
    font-style: italic;
    font-size: 1rem;
    color: var(--text-muted);
}

.masthead-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 10px;
}

.theme-switch {
    display: flex;
    gap: 8px;
    padding: 4px;
    border: 1px solid var(--line);
    border-radius: 999px;
}

.theme-swatch {
    width: 20px;
    height: 20px;
    border-radius: 999px;
    border: 1px solid var(--line-strong);
    padding: 0;
    transition: transform var(--transition), box-shadow var(--transition);
}

.theme-swatch[data-theme="brass"] { background: linear-gradient(135deg, #0a0c10 50%, #b6903f 50%); }
.theme-swatch[data-theme="ivory"] { background: linear-gradient(135deg, #f6f1e5 50%, #8a6423 50%); }
.theme-swatch[data-theme="sapphire"] { background: linear-gradient(135deg, #070b14 50%, #9fb4c9 50%); }

.theme-swatch:hover { transform: translateY(-1px); }

.theme-swatch.active {
    box-shadow: 0 0 0 2px var(--ink-1), 0 0 0 3px var(--brass);
}

/* ---- Abgleich-Anzeige ---- */
.sync-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: transparent;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 5px 12px;
    font-size: 0.74rem;
    color: var(--text-muted);
    transition: color var(--transition), border-color var(--transition);
}

.sync-chip:hover { color: var(--text-soft); border-color: var(--line-strong); }

.sync-dot {
    width: 7px;
    height: 7px;
    border-radius: 999px;
    background: var(--text-muted);
    flex-shrink: 0;
}

.sync-chip[data-status="ok"] .sync-dot     { background: var(--income); }
.sync-chip[data-status="laeuft"] .sync-dot { background: var(--brass); animation: pulsieren 1s ease-in-out infinite; }
.sync-chip[data-status="fehler"] .sync-dot { background: var(--cost); }
.sync-chip[data-status="offen"] .sync-dot  { background: var(--loan); }

@keyframes pulsieren { 0%,100% { opacity: 1; } 50% { opacity: 0.25; } }

/* =========================================================
   BUCHKREIS — Privat / Geschäft / Beides
========================================================= */
.scope-bar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 22px;
}

.scope-label {
    font-size: 0.7rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.scope-switch {
    display: flex;
    border: 1px solid var(--line);
    border-radius: 999px;
    overflow: hidden;
}

.scope-switch button {
    background: transparent;
    padding: 7px 18px;
    font-size: 0.8rem;
    color: var(--text-muted);
    transition: color var(--transition), background var(--transition);
}

.scope-switch button + button { border-left: 1px solid var(--line); }
.scope-switch button:hover { color: var(--text-soft); }

.scope-switch button.active {
    color: var(--ink-1);
    background: linear-gradient(160deg, var(--brass-light), var(--brass));
    font-weight: 600;
}

:root[data-theme="ivory"] .scope-switch button.active { color: #f6f1e5; }

.scope-hint {
    font-family: var(--serif);
    font-style: italic;
    font-size: 0.92rem;
    color: var(--text-muted);
}

/* Kennzeichnung am einzelnen Eintrag */
.scope-tag {
    display: inline-block;
    font-size: 0.62rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    padding: 2px 7px;
    border-radius: 999px;
    border: 1px solid var(--line-strong);
    color: var(--text-muted);
    white-space: nowrap;
}

.scope-tag.geschaeft {
    color: var(--brass-light);
    border-color: var(--brass-dim);
    background: rgba(182,144,63,0.08);
}

/* =========================================================
   TABS
========================================================= */
.tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 34px;
    border-bottom: 1px solid var(--line);
}

.tab {
    background: transparent;
    padding: 12px 18px 14px;
    font-size: 0.86rem;
    letter-spacing: 0.03em;
    color: var(--text-muted);
    border-bottom: 2px solid transparent;
    transform: translateY(1px);
    transition: color var(--transition), border-color var(--transition);
}

.tab:hover { color: var(--text-soft); }

.tab.active {
    color: var(--brass-light);
    border-bottom-color: var(--brass);
}

/* =========================================================
   PANELS
========================================================= */
.panel { display: none; animation: fadeIn 380ms ease; }
.panel.active { display: block; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

.panel-head { margin-bottom: 26px; }

.panel-head h2 {
    margin: 0 0 6px;
    font-family: var(--serif);
    font-weight: 600;
    font-size: 1.9rem;
    color: var(--text);
}

.panel-hint {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.88rem;
}

.panel-hint strong { color: var(--text-soft); font-weight: 600; }

/* =========================================================
   ÜBERSICHT — LEDGER SUMMARY
========================================================= */
.ledger-summary {
    display: flex;
    align-items: stretch;
    gap: 18px;
    padding: 28px 8px;
    margin-bottom: 28px;
    border-top: 1px solid var(--line-strong);
    border-bottom: 1px solid var(--line-strong);
}

.sum-block {
    flex: 1 1 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 0;
}

.sum-label {
    font-size: 0.7rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.sum-value {
    font-family: var(--serif);
    font-size: clamp(1.5rem, 2.4vw, 2.1rem);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.sum-value.income { color: var(--income-soft); }
.sum-value.cost { color: var(--cost-soft); }
.sum-value.loan { color: var(--loan-soft); }
.sum-value.net-value { color: var(--brass-light); }

.sum-divider {
    align-self: center;
    font-family: var(--serif);
    font-size: 1.6rem;
    color: var(--text-muted);
    padding-bottom: 4px;
}

.sum-divider.equals { color: var(--brass); }

.sum-block.net {
    border-left: 1px solid var(--line-strong);
    padding-left: 18px;
}

/* balance bar */
.balance-bar-wrap { margin-bottom: 34px; }

.balance-bar {
    display: flex;
    width: 100%;
    height: 8px;
    border-radius: 999px;
    overflow: hidden;
    background: var(--ink-3);
    border: 1px solid var(--line);
}

.bb-seg { height: 100%; transition: width var(--transition-slow, 420ms) ease; }
.bb-cost { background: var(--cost); }
.bb-loan { background: var(--loan); }
.bb-free { background: var(--brass); }

.balance-legend {
    display: flex;
    gap: 22px;
    margin-top: 10px;
    font-size: 0.78rem;
    color: var(--text-muted);
}

.dot { width: 8px; height: 8px; border-radius: 999px; display: inline-block; margin-right: 6px; }
.dot-cost { background: var(--cost); }
.dot-loan { background: var(--loan); }
.dot-free { background: var(--brass); }

/* ---- Plan gegen Ist ---- */
.plan-ist {
    padding: 22px 20px 18px;
    margin-bottom: 34px;
    background: var(--ink-2);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
}

.plan-ist .col-heading { border-bottom: none; margin-bottom: 4px; padding-bottom: 0; }

.plan-ist-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 18px;
    margin: 14px 0 12px;
}

.pi-block { display: flex; flex-direction: column; gap: 6px; min-width: 0; }

.pi-value {
    font-family: var(--serif);
    font-size: 1.5rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    color: var(--text-soft);
    white-space: nowrap;
}

.pi-value.unter { color: var(--income-soft); }
.pi-value.ueber { color: var(--cost-soft); }

/* overview columns */
.overview-columns {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 28px;
}

.col-heading {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin: 0 0 12px;
    font-family: var(--serif);
    font-weight: 600;
    font-size: 1.15rem;
    color: var(--text-soft);
    padding-bottom: 8px;
    border-bottom: 1px solid var(--line);
}

.count {
    font-family: var(--sans);
    font-size: 0.72rem;
    color: var(--text-muted);
}

.mini-ledger { list-style: none; margin: 0; padding: 0; }

.mini-ledger li {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    padding: 9px 0;
    border-bottom: 1px dashed var(--line);
    font-size: 0.86rem;
}

.mini-ledger li:last-child { border-bottom: none; }

.mini-ledger .m-name { color: var(--text-soft); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-ledger .m-amount { font-variant-numeric: tabular-nums; color: var(--text); flex-shrink: 0; }

.overview-col:empty::after,
.mini-ledger:empty::after { content: none; }

/* =========================================================
   FORMS
========================================================= */
.entry-form {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 0.9fr auto;
    gap: 10px;
    margin-bottom: 26px;
    padding: 18px;
    background: var(--ink-2);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
}

.cost-form    { grid-template-columns: 1.8fr 1fr 0.9fr 0.9fr 0.9fr auto; }
.loan-form    { grid-template-columns: 1.6fr 1fr 1fr 0.8fr 1fr 0.9fr auto; }
.payment-form { grid-template-columns: 0.9fr 1.8fr 0.8fr 1fr 1fr 0.9fr auto; }

.btn-add {
    background: linear-gradient(160deg, var(--brass-light), var(--brass));
    color: #211705;
    font-weight: 700;
    letter-spacing: 0.02em;
    border-radius: var(--radius);
    padding: 11px 18px;
    white-space: nowrap;
    transition: filter var(--transition), transform var(--transition);
}

:root[data-theme="ivory"] .btn-add { color: #f6f1e5; }

.btn-add:hover { filter: brightness(1.08); transform: translateY(-1px); }
.btn-add:active { transform: translateY(0); }

.btn-ghost {
    background: transparent;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    padding: 10px 16px;
    font-size: 0.84rem;
    color: var(--text-soft);
    white-space: nowrap;
    transition: color var(--transition), border-color var(--transition), background var(--transition);
}

.btn-ghost:hover { color: var(--brass-light); border-color: var(--brass-dim); background: rgba(182,144,63,0.06); }

.btn-ghost.danger { color: var(--cost-soft); }
.btn-ghost.danger:hover { color: var(--cost-soft); border-color: var(--cost); background: rgba(169,100,90,0.10); }

/* Abbrechen erscheint nur, während ein Eintrag bearbeitet wird */
.btn-cancel {
    display: none;
    background: transparent;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    padding: 10px 16px;
    font-size: 0.84rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.btn-cancel:hover { color: var(--text-soft); }
.entry-form.editing .btn-cancel { display: block; }

/* =========================================================
   SORT BAR
========================================================= */
.sort-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.sort-label {
    font-size: 0.7rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-right: 4px;
}

.sort-bar button {
    background: transparent;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 6px 14px;
    font-size: 0.78rem;
    color: var(--text-muted);
    transition: color var(--transition), border-color var(--transition), background var(--transition);
}

.sort-bar button:hover { color: var(--text-soft); border-color: var(--line-strong); }

.sort-bar button.active {
    color: var(--brass-light);
    border-color: var(--brass-dim);
    background: rgba(182,144,63,0.08);
}

.sort-bar button.active::after {
    content: "↑";
    margin-left: 6px;
}

.sort-bar button.active.desc::after { content: "↓"; }

/* =========================================================
   LEDGER LIST (Einnahmen / Kosten)
========================================================= */
.ledger-list { list-style: none; margin: 0; padding: 0; }

/*
   Flex statt Grid: Die Zeile hat je nach Buchkreis-Ansicht eine
   unterschiedliche Anzahl Felder (die Kennzeichnung Privat/Geschäft
   kommt nur bei "Beides" dazu). Eine feste Spaltenzahl würde dann
   umbrechen — mit Flex wächst nur die Bezeichnung.
*/
.ledger-list li {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 14px 4px;
    border-bottom: 1px solid var(--line);
}

.ledger-list li:first-child { border-top: 1px solid var(--line-strong); }

.entry-name {
    flex: 1 1 auto;
    min-width: 0;
    font-size: 0.95rem;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.entry-meta { font-size: 0.74rem; color: var(--text-muted); letter-spacing: 0.04em; }

.entry-amount {
    font-family: var(--serif);
    font-size: 1.15rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.entry-amount.income { color: var(--income-soft); }
.entry-amount.cost { color: var(--cost-soft); }

.entry-remove {
    background: transparent;
    color: var(--text-muted);
    font-size: 1.1rem;
    line-height: 1;
    padding: 6px 8px;
    border-radius: var(--radius);
    transition: color var(--transition), background var(--transition);
}

.entry-remove:hover { color: var(--cost-soft); background: rgba(169,100,90,0.10); }

.entry-edit {
    background: transparent;
    color: var(--text-muted);
    font-size: 0.95rem;
    line-height: 1;
    padding: 6px 8px;
    border-radius: var(--radius);
    transition: color var(--transition), background var(--transition);
}

.entry-edit:hover { color: var(--brass-light); background: rgba(182,144,63,0.10); }

.entry-form.editing {
    border-color: var(--brass-dim);
    box-shadow: 0 0 0 3px rgba(182,144,63,0.08);
}

.empty-hint {
    display: none;
    padding: 30px 4px;
    text-align: center;
    color: var(--text-muted);
    font-style: italic;
    font-family: var(--serif);
    font-size: 1.05rem;
    border-top: 1px dashed var(--line);
}

/* =========================================================
   AUSGABENBUCH
========================================================= */
.period-bar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 14px;
    padding: 14px 4px;
    margin-bottom: 22px;
    border-top: 1px solid var(--line-strong);
    border-bottom: 1px solid var(--line);
}

.period-nav {
    display: flex;
    align-items: center;
    gap: 6px;
}

.period-nav button {
    background: transparent;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    width: 32px;
    height: 32px;
    font-size: 1.1rem;
    line-height: 1;
    color: var(--text-muted);
    transition: color var(--transition), border-color var(--transition);
}

.period-nav button:hover { color: var(--brass-light); border-color: var(--brass-dim); }
.period-nav button:disabled { opacity: 0.3; cursor: default; }

.period-label {
    font-family: var(--serif);
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text);
    min-width: 12ch;
    text-align: center;
}

.period-modes {
    display: flex;
    border: 1px solid var(--line);
    border-radius: 999px;
    overflow: hidden;
}

.period-modes button {
    background: transparent;
    padding: 6px 14px;
    font-size: 0.76rem;
    color: var(--text-muted);
    transition: color var(--transition), background var(--transition);
}

.period-modes button + button { border-left: 1px solid var(--line); }
.period-modes button:hover { color: var(--text-soft); }

.period-modes button.active {
    color: var(--brass-light);
    background: rgba(182,144,63,0.10);
}

.period-bar .btn-ghost { margin-left: auto; }

.pay-summary {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 18px;
    padding: 22px 8px;
    margin-bottom: 28px;
    border-bottom: 1px solid var(--line);
}

.pay-summary .sum-value { font-size: clamp(1.3rem, 2vw, 1.8rem); color: var(--text-soft); }

.cat-block { margin-bottom: 30px; }

.cat-bars { list-style: none; margin: 0; padding: 0; }

.cat-bars li {
    display: grid;
    grid-template-columns: minmax(9ch, 1.4fr) 3fr auto auto;
    align-items: center;
    gap: 14px;
    padding: 8px 0;
    font-size: 0.85rem;
}

.cat-name { color: var(--text-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.cat-track {
    display: block;
    height: 8px;
    border-radius: 999px;
    background: var(--ink-3);
    border: 1px solid var(--line);
    overflow: hidden;
}

/* display:block ist hier Pflicht, nicht Geschmack: Ein <span> ist von
   Haus aus inline, und dann greift die Breitenangabe nicht — der
   Balken bliebe unsichtbar. */
.cat-fill {
    display: block;
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--cost), var(--brass));
    transition: width 420ms ease;
}

.cat-amount {
    font-variant-numeric: tabular-nums;
    color: var(--text);
    white-space: nowrap;
}

.cat-share {
    font-size: 0.74rem;
    color: var(--text-muted);
    min-width: 4ch;
    text-align: right;
}

.pay-date {
    font-variant-numeric: tabular-nums;
    font-size: 0.82rem;
    color: var(--text-muted);
    white-space: nowrap;
    min-width: 9ch;
}

/* =========================================================
   EINSTELLUNGEN
========================================================= */
.settings-card {
    padding: 24px 22px;
    margin-bottom: 22px;
    background: var(--ink-2);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
}

.settings-card h3 {
    margin: 0 0 10px;
    font-family: var(--serif);
    font-weight: 600;
    font-size: 1.3rem;
    color: var(--text);
}

.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 14px;
    margin: 18px 0 14px;
}

.settings-grid label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 0.72rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.settings-grid input { text-transform: none; letter-spacing: normal; font-size: 0.95rem; }

.check-row {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 16px;
    font-size: 0.82rem;
    color: var(--text-muted);
    line-height: 1.45;
}

.check-row input { margin-top: 3px; flex-shrink: 0; padding: 0; width: 16px; height: 16px; }

.button-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.fact-list {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 8px 20px;
    margin: 0 0 18px;
    font-size: 0.88rem;
}

.fact-list dt { color: var(--text-muted); }
.fact-list dd { margin: 0; color: var(--text-soft); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }

.device-list {
    list-style: none;
    margin: 18px 0 0;
    padding: 0;
    border-top: 1px solid var(--line);
}

.device-list li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 12px 2px;
    border-bottom: 1px solid var(--line);
    font-size: 0.86rem;
}

.device-name { color: var(--text-soft); }
.device-meta { font-size: 0.74rem; color: var(--text-muted); }

/* =========================================================
   RÜCKZAHLUNGSPLANER
========================================================= */
.loan-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 18px;
}

.loan-card {
    position: relative;
    padding: 20px 20px 18px;
    background: var(--ink-2);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
}

.loan-card::before {
    content: "";
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 3px;
    background: var(--loan);
    border-radius: var(--radius-md) 0 0 var(--radius-md);
}

.loan-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 14px;
}

.loan-name {
    font-family: var(--serif);
    font-weight: 600;
    font-size: 1.2rem;
    color: var(--text);
}

.loan-title { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; min-width: 0; }

.loan-actions { display: flex; gap: 4px; }

.loan-remove, .loan-edit {
    background: transparent;
    color: var(--text-muted);
    font-size: 0.95rem;
    padding: 2px 6px;
    border-radius: var(--radius);
    transition: color var(--transition);
}
.loan-remove:hover { color: var(--cost-soft); }
.loan-edit:hover { color: var(--brass-light); }

.loan-figures {
    display: flex;
    justify-content: space-between;
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.loan-figures strong {
    display: block;
    font-family: var(--serif);
    font-size: 1rem;
    color: var(--text-soft);
    font-variant-numeric: tabular-nums;
}

.loan-progress-track {
    height: 6px;
    border-radius: 999px;
    background: var(--ink-4);
    overflow: hidden;
    margin: 10px 0 8px;
}

.loan-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--brass), var(--loan));
    border-radius: 999px;
    transition: width 500ms ease;
}

.loan-meta-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.76rem;
    color: var(--text-muted);
}

.loan-meta-row span strong { color: var(--brass-light); font-weight: 600; }

/* =========================================================
   MELDUNGEN & RÜCKFRAGE
========================================================= */
.toast-stack {
    position: fixed;
    left: 50%;
    bottom: 24px;
    transform: translateX(-50%);
    z-index: 60;
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: min(420px, calc(100vw - 32px));
    pointer-events: none;
}

.toast {
    padding: 12px 16px;
    background: var(--ink-3);
    border: 1px solid var(--line-strong);
    border-left: 3px solid var(--brass);
    border-radius: var(--radius-md);
    color: var(--text);
    font-size: 0.88rem;
    box-shadow: 0 14px 32px rgba(0,0,0,0.35);
    animation: toastRein 260ms ease;
}

.toast.fehler { border-left-color: var(--cost); }
.toast.gut { border-left-color: var(--income); }

@keyframes toastRein {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.ask {
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-md);
    background: var(--ink-2);
    color: var(--text);
    padding: 24px;
    max-width: 420px;
    width: calc(100vw - 32px);
}

.ask::backdrop { background: rgba(0,0,0,0.6); }

.ask h3 {
    margin: 0 0 10px;
    font-family: var(--serif);
    font-size: 1.4rem;
    font-weight: 600;
}

.ask p { margin: 0 0 20px; color: var(--text-soft); font-size: 0.9rem; }
.ask .button-row { justify-content: flex-end; }

/* =========================================================
   FOOTER
========================================================= */
.footer {
    margin-top: 50px;
    padding-top: 18px;
    border-top: 1px solid var(--line);
    text-align: center;
    color: var(--text-muted);
}

/* =========================================================
   RESPONSIVE
========================================================= */
@media (max-width: 1080px) {
    .overview-columns { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 900px) {
    .overview-columns { grid-template-columns: 1fr; }
    .ledger-summary { flex-wrap: wrap; }
    .sum-block.net { border-left: none; padding-left: 0; border-top: 1px solid var(--line-strong); padding-top: 14px; margin-top: 4px; width: 100%; }
    .entry-form, .loan-form, .cost-form, .payment-form { grid-template-columns: 1fr 1fr; }
    .btn-add, .btn-cancel { grid-column: 1 / -1; }
    .plan-ist-grid { grid-template-columns: 1fr; }
    .pay-summary { grid-template-columns: 1fr 1fr; }
    .masthead { flex-direction: column; align-items: flex-start; }
    .masthead-right { align-items: flex-start; }
}

@media (max-width: 560px) {
    .frame { padding: 26px 16px 40px; }
    .masthead-title h1 { font-size: 2rem; }
    .entry-form, .loan-form, .cost-form, .payment-form { grid-template-columns: 1fr; }
    /* Auf dem Handy bricht die Zeile um: Datum, dann Bezeichnung und
       Betrag, dann die Nebenangaben mit den Knöpfen rechts. Die
       Reihenfolge steht hier ausdrücklich, damit nichts nach Zufall
       umbricht. */
    .ledger-list li { flex-wrap: wrap; gap: 4px 10px; }
    .pay-date { flex: 1 0 100%; order: 1; }
    .ledger-list .entry-name { flex: 1 1 auto; order: 2; white-space: normal; }
    .entry-amount { order: 3; margin-left: auto; }
    .scope-tag { order: 4; }
    .entry-meta { order: 5; }
    .entry-edit { order: 6; margin-left: auto; }
    .entry-remove { order: 7; }

    .pay-summary { grid-template-columns: 1fr; }
    .cat-bars li { grid-template-columns: 1fr auto; }
    .cat-track { grid-column: 1 / -1; order: 3; }
    /* Der Balken sagt dasselbe wie die Prozentzahl — auf schmalem
       Schirm reicht einer von beiden. */
    .cat-share { display: none; }
    .period-bar .btn-ghost { margin-left: 0; }
    .period-label { min-width: 0; flex: 1; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}
