/* =====================================================================
   Rehluchs Finance – Basis-Styles
   Farben NIE direkt hier eintragen, sondern immer var(--token) aus
   css/themes/*.css verwenden. So bleibt der Design-Wechsel trivial.
   ===================================================================== */

/* ------------------------------ Schriften ------------------------------ */
/* Selbst gehostet über npm (@fontsource). Fehlen die Dateien, greifen
   die System-Fallbacks – die App funktioniert trotzdem. */
@font-face {
    font-family: "Space Grotesk";
    src: url("/fonts/space-grotesk/space-grotesk-latin-400-normal.woff2") format("woff2");
    font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
    font-family: "Space Grotesk";
    src: url("/fonts/space-grotesk/space-grotesk-latin-500-normal.woff2") format("woff2");
    font-weight: 500; font-style: normal; font-display: swap;
}
@font-face {
    font-family: "Space Grotesk";
    src: url("/fonts/space-grotesk/space-grotesk-latin-700-normal.woff2") format("woff2");
    font-weight: 700; font-style: normal; font-display: swap;
}
@font-face {
    font-family: "ABeeZee";
    src: url("/fonts/abeezee/abeezee-latin-400-normal.woff2") format("woff2");
    font-weight: 400; font-style: normal; font-display: swap;
}

:root {
    --font-display: "Space Grotesk", ui-sans-serif, system-ui, "Segoe UI", Roboto, sans-serif;
    --font-body: "ABeeZee", ui-sans-serif, system-ui, "Segoe UI", Roboto, sans-serif;
    --font-num: "Space Grotesk", ui-sans-serif, system-ui, sans-serif;
    --radius-s: 6px;
    --radius: 10px;
    --radius-l: 16px;
    --header-h: 88px;
    --nav-w: 272px;
    --nav-w-collapsed: 76px;
    --gap: 24px;
    --ease: cubic-bezier(.2, .7, .2, 1);
}

/* ------------------------------- Reset -------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    min-height: 100vh;
    min-height: 100dvh;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-body);
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 500; line-height: 1.2; margin: 0; }
p { margin: 0; }
a { color: var(--brand); }
img, svg { display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.num { font-family: var(--font-num); font-variant-numeric: tabular-nums; }
.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }
[hidden] { display: none !important; }

.icon {
    width: 1.25em; height: 1.25em; flex: none;
    fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}

/* ============================== Shell ============================== */
.app-header {
    position: fixed; inset: 0 0 auto 0; z-index: 30;
    height: var(--header-h);
    display: flex; align-items: center; gap: 16px;
    padding: 0 20px 0 8px;
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 22px; text-decoration: none; min-width: 0; }
.brand-logo {
    width: 80px; height: 80px; border-radius: 50%;
    border: 1px solid var(--brand); padding: 6px;
}
.brand-text { height: 26px; width: auto; }
.header-spacer { flex: 1; }
.header-tools { display: flex; align-items: center; gap: 10px; }
.vault-switcher { display: flex; align-items: center; gap: 8px; color: var(--nav-text); }
.vault-select {
    background: var(--surface-3); border: 1px solid var(--border); border-radius: var(--radius-s);
    padding: 6px 10px; max-width: 200px;
}
.badge {
    display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px;
    border-radius: 99px; background: var(--brand); color: var(--brand-contrast); font-size: 12px; text-decoration: none;
}
.icon-btn {
    display: inline-grid; place-items: center; width: 40px; height: 40px;
    border: 0; border-radius: var(--radius-s); background: transparent; color: var(--nav-text);
}
.icon-btn:hover { background: var(--nav-hover-bg); }
.icon-btn .icon { width: 22px; height: 22px; }
.nav-open-btn { display: none; }

.app-nav {
    position: fixed; z-index: 20;
    top: var(--header-h); left: 0; bottom: 0;
    width: var(--nav-w);
    display: flex; flex-direction: column;
    background: var(--bg-elevated);
    padding: 22px 14px 12px 18px;
    transition: width .25s var(--ease), transform .25s var(--ease);
    overflow-y: auto; overflow-x: hidden;
}
.nav-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 22px; }
.nav-link {
    display: flex; align-items: center; gap: 10px;
    padding: 6px 8px;
    color: var(--nav-text); text-decoration: none;
    border-radius: var(--radius-s);
    font-size: 14.5px;
    line-height: 1.3;
}
/* Lange Bezeichnungen (z.B. „Sparpläne & Investitionen“, andere Sprachen) brechen
   innerhalb der Markierung um, statt aus ihr herauszuragen */
.nav-label { min-width: 0; overflow-wrap: anywhere; }
.nav-link:hover { background: var(--nav-hover-bg); }
.nav-link[aria-current="page"] { background: var(--nav-active-bg); }
.nav-icon { width: 30px; height: 26px; object-fit: contain; flex: none; }
.nav-foot {
    margin-top: auto; padding-top: 24px;
    display: flex; align-items: center; gap: 18px; font-size: 11.5px;
}
.nav-foot a { color: var(--text); text-decoration: none; }
.nav-foot a:hover { text-decoration: underline; }
.nav-foot .nav-collapse { margin-left: auto; width: 32px; height: 32px; }
.nav-logout { margin-top: 22px; }
.nav-logout .icon { width: 26px; height: 22px; margin: 0 2px; }

body.nav-collapsed .app-nav { width: var(--nav-w-collapsed); padding-left: 14px; padding-right: 10px; }
body.nav-collapsed .nav-label,
body.nav-collapsed .nav-foot a { display: none; }
body.nav-collapsed .nav-collapse .icon { transform: rotate(180deg); }
body.nav-collapsed .nav-foot { justify-content: center; }
body.nav-collapsed .nav-foot .nav-collapse { margin-left: 0; }

.app-main {
    padding: calc(var(--header-h) + 22px) 32px 48px calc(var(--nav-w) + 34px);
    min-height: 100vh;
    transition: padding-left .25s var(--ease);
}
body.nav-collapsed .app-main { padding-left: calc(var(--nav-w-collapsed) + 34px); }
.page { max-width: 1240px; margin: 0 auto; }
.nav-backdrop { display: none; }

/* Ladezustand der App-Seiten */
.page-loading { display: grid; place-items: center; min-height: 40vh; color: var(--text-muted); gap: 12px; }
.spinner {
    width: 32px; height: 32px; border-radius: 50%;
    border: 3px solid var(--surface-3); border-top-color: var(--brand);
    animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================ Komponenten ============================ */
.page-title {
    color: var(--heading);
    font-size: clamp(1.4rem, 2.2vw, 1.7rem);
    margin: 4px 0 26px;
}
.title-box {
    display: block; width: fit-content; max-width: 100%; margin: 0 auto 22px;
    padding: 16px 64px; border-radius: var(--radius-s);
    background: var(--title-box-bg); color: var(--text);
    font-size: clamp(1.15rem, 2vw, 1.6rem); text-align: center;
}
.section-title { font-size: 1.1rem; color: var(--text); margin-bottom: 14px; display: flex; align-items: center; gap: 10px; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--gap); }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--gap); }
.grid-auto { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 18px; }

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-l);
    padding: 20px 22px;
}
.card-2 { background: var(--surface-2); border-radius: var(--radius); padding: 28px 36px; border: 1px solid var(--border); }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.card-head h2, .card-head h3 { font-size: 1.02rem; color: var(--text); }
.kpi-label { font-size: 12.5px; color: var(--text-muted); }
.kpi-value { font-family: var(--font-num); font-size: 1.55rem; font-weight: 500; margin-top: 4px; }
.kpi-sub { font-size: 12px; color: var(--text-faint); margin-top: 2px; }
.pos { color: var(--income); }
.neg { color: var(--expense); }

/* Buttons */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    min-height: 42px; padding: 0 18px;
    border: 1px solid transparent; border-radius: var(--radius-s);
    font-family: var(--font-display); font-weight: 500; font-size: 15px;
    text-decoration: none; white-space: nowrap;
    transition: filter .15s, transform .08s, background .15s;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn .icon { width: 18px; height: 18px; }
.btn-primary { background: var(--btn-primary-bg); color: var(--btn-primary-text); }
.btn-secondary { background: var(--btn-secondary-bg); color: var(--btn-secondary-text); }
.btn-brand { background: var(--brand); color: var(--brand-contrast); }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--line); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-link { background: none; border: 0; color: var(--brand); padding: 0; min-height: 0; text-decoration: underline; font-family: var(--font-body); font-weight: 400; }
.btn:hover:not(:disabled) { filter: brightness(1.08); }
.btn-lg { min-height: 70px; padding: 0 70px; font-size: 1.6rem; font-weight: 700; text-shadow: 0 3px 4px rgba(0,0,0,.25); }
.btn-block { width: 100%; }
.is-busy { position: relative; color: transparent !important; }
.is-busy::after {
    content: ""; position: absolute; width: 18px; height: 18px; border-radius: 50%;
    border: 2px solid var(--btn-primary-text); border-top-color: transparent; animation: spin .8s linear infinite;
}
.tool-btn {
    display: inline-grid; place-items: center; width: 34px; height: 34px;
    border-radius: 50%; border: 0; background: transparent; color: var(--text-muted);
}
.tool-btn:hover { background: var(--surface-3); color: var(--text); }
.tool-btn .icon { width: 18px; height: 18px; }
.plus-btn {
    display: inline-grid; place-items: center; width: 28px; height: 28px; border: 0; padding: 0;
    background: none; color: var(--text); border-radius: 50%;
}
.plus-btn .icon { width: 24px; height: 24px; stroke-width: 1.6; }
.plus-btn:hover { color: var(--brand); }

.seg {
    display: inline-flex; background: var(--surface-3); border-radius: 99px; padding: 3px; gap: 2px;
}
.seg button {
    border: 0; background: transparent; padding: 6px 14px; border-radius: 99px; color: var(--text-muted); font-size: 13px;
}
.seg button[aria-pressed="true"] { background: var(--brand); color: var(--brand-contrast); }

/* Formulare im Stil der Mockups: Label links groß, Eingabe rechts, Linie darunter */
.form-card { background: var(--surface-2); border-radius: var(--radius); padding: 34px 22px 26px; border: 1px solid var(--border); }
.field {
    display: grid; grid-template-columns: minmax(140px, 1fr) minmax(0, 1.4fr); align-items: end; gap: 16px;
    padding: 18px 28px 6px 50px; border-bottom: 2px solid var(--line);
}
.field + .field { margin-top: 16px; }
.field-label { font-family: var(--font-display); font-size: 1.35rem; color: var(--text); padding-bottom: 4px; }
.field-control { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; min-width: 0; }
.field-hint { color: var(--text-faint); font-size: 12px; }
.input, .field-control > input, .field-control > select, .field-control > textarea {
    width: 100%; min-width: 0;
    background: transparent; border: 0; border-bottom: 1px solid transparent;
    color: var(--text); text-align: right;
    font-family: var(--font-num); font-size: 1.02rem; padding: 6px 2px;
}
.field-control > input:focus, .field-control > select:focus { outline: none; border-bottom-color: var(--brand); }
.field-control > select { text-align-last: right; }
.field-control > select option { background: var(--surface-2); color: var(--text); }
.input-box {
    width: 100%; background: var(--surface-3); border: 1px solid var(--border); border-radius: var(--radius-s);
    padding: 11px 13px; color: var(--text); font-size: 15px;
}
.input-box:focus { outline: 2px solid var(--focus); outline-offset: 0; }
.label { display: block; font-size: 13px; color: var(--text-muted); margin-bottom: 6px; }
.form-error { color: var(--danger); font-size: 13.5px; min-height: 1.2em; }

/* Kategorie-Chips */
.chips { display: flex; flex-wrap: wrap; gap: 4px; justify-content: flex-end; max-width: 320px; }
.chip {
    border: 0; border-radius: 99px; padding: 4px 12px; font-size: 11px; line-height: 1.3;
    color: #111; background: var(--chip, #ccc); box-shadow: 0 2px 4px rgba(0,0,0,.3);
    opacity: .9; font-family: var(--font-display); font-weight: 500;
}
.chip[aria-pressed="true"] { outline: 2px solid var(--text); outline-offset: 1px; opacity: 1; transform: translateY(-1px); }
.chip-add { background: transparent; color: var(--text-muted); box-shadow: none; border: 1px dashed var(--line); }

/* Schalter */
.toggles { margin-top: 56px; }
.toggle-row {
    display: flex; justify-content: space-between; align-items: center;
    padding: 6px 30px 6px 44px; font-size: 14px; border-bottom: 2px solid var(--line);
}
.toggle-row + .toggle-row { border-bottom: 0; }
.switch { position: relative; width: 30px; height: 16px; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.switch span {
    position: absolute; inset: 0; border-radius: 99px; border: 2px solid var(--toggle-off); pointer-events: none;
    transition: border-color .15s;
}
.switch span::after {
    content: ""; position: absolute; top: 2px; left: 2px; width: 8px; height: 8px; border-radius: 50%;
    background: var(--toggle-off); transition: transform .15s, background .15s;
}
.switch input:checked + span { border-color: var(--toggle-on); }
.switch input:checked + span::after { transform: translateX(14px); background: var(--toggle-on); }
.switch input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 2px; }

.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 26px; flex-wrap: wrap; }

/* Übersichts-Blatt (Mockup „Übersicht der Einnahmen & Ausgaben") */
.sheet {
    background: var(--sheet-bg); color: var(--sheet-text);
    border-radius: var(--radius-s); padding: 28px 32px 18px 44px;
    max-width: 872px; margin: 0 auto; position: relative;
}
.sheet-row {
    display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: end; gap: 10px;
    padding: 14px 0 0 6px; border-bottom: 1px solid var(--sheet-line);
    text-shadow: var(--text-shadow-sheet);
}
.sheet-label { display: flex; align-items: center; gap: 8px; min-width: 0; }
.sheet-label .t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sheet-label .icon { width: 15px; height: 15px; opacity: .75; }
.sheet-sub { font-size: 12px; opacity: .75; margin-left: 4px; white-space: nowrap; }
.sheet-amount { font-family: var(--font-num); min-width: 80px; text-align: right; }
.sheet-amount.in { color: var(--income-on-sheet); }
.sheet-amount.out { color: var(--expense-on-sheet); }
.sheet-tools { display: flex; gap: 0; opacity: 0; transition: opacity .15s; }
.sheet-row:hover .sheet-tools, .sheet-row:focus-within .sheet-tools { opacity: 1; }
.sheet-tools .tool-btn { color: var(--sheet-text); width: 30px; height: 30px; }
.sheet-tools .tool-btn:hover { background: rgba(255,255,255,.25); }
.sheet-foot { display: flex; justify-content: space-between; align-items: flex-end; margin-top: 22px; gap: 12px; flex-wrap: wrap; }
.sheet-date { font-size: 14px; }
.pill { background: var(--pill-bg); color: var(--pill-text); border-radius: var(--radius); padding: 8px 12px; font-family: var(--font-num); }
.sheet-section { font-family: var(--font-display); font-size: 12px; text-transform: uppercase; letter-spacing: .08em; opacity: .7; margin-top: 18px; }

/* Budget-Box oben rechts (Mockup „Neue Ausgabe") */
.budget-box {
    background: var(--btn-secondary-bg); color: var(--btn-secondary-text);
    padding: 4px 10px 4px 10px; min-width: 220px;
}
.budget-box small { display: block; font-family: var(--font-display); font-size: 14px; opacity: .85; }
.budget-box strong { font-family: var(--font-num); font-weight: 400; font-size: 19px; color: var(--btn-secondary-text); }

/* Fortschritt */
.progress { height: 10px; border-radius: 99px; background: var(--progress-bg); overflow: hidden; }
.progress-fill { height: 100%; background: var(--progress-fill); border-radius: inherit; transition: width .6s var(--ease); }

/* Diagramme */
.chart { width: 100%; height: auto; overflow: visible; }
.chart-wrap { width: 100%; }
.chart-box { width: 100%; min-width: 0; }
.chart-bars, .chart-line { display: block; width: 100%; height: auto; }
.chart .grid { stroke: var(--chart-grid); stroke-width: 1; }
.chart .grid.zero { stroke: var(--text-faint); stroke-dasharray: 4 4; }
.chart .axis { fill: var(--text-muted); font-family: var(--font-body); }
.bar.income, .swatch.income { fill: var(--chart-income); background: var(--chart-income); }
.bar.expense, .swatch.expense { fill: var(--chart-expense); background: var(--chart-expense); }
.bar.brand, .swatch.brand { fill: var(--chart-brand); background: var(--chart-brand); }
.chart .stroke { stroke-width: 2.5; }
.chart .stroke.line-brand { stroke: var(--chart-brand); }
.chart .area.line-brand { fill: var(--chart-brand); opacity: .12; }
.chart .dot.line-brand { fill: var(--chart-brand); }
.swatch.line-brand { background: var(--chart-brand); }
.legend { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 10px; font-size: 13px; color: var(--text-muted); }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.swatch { width: 10px; height: 10px; border-radius: 3px; display: inline-block; background: var(--swatch, currentColor); }
.chart-donut { max-width: 360px; margin: 0 auto; }
.donut-seg { transition: opacity .15s; stroke: var(--donut-gap, var(--surface)); stroke-width: 2.5; stroke-linejoin: round; }
.donut-seg:hover { opacity: .85; }
.donut-center { fill: var(--donut-center); }
.donut-empty { stroke: var(--donut-empty); }
.donut-label { fill: var(--donut-center-text); font-size: 15px; font-family: var(--font-display); }
.donut-value { fill: var(--donut-center-text); font-size: 22px; font-family: var(--font-num); font-weight: 500; }

/* Listen */
.list { list-style: none; margin: 0; padding: 0; }
.list-row {
    display: flex; align-items: center; gap: 14px; padding: 12px 4px;
    border-bottom: 1px solid var(--border);
}
.list-row:last-child { border-bottom: 0; }
.list-main { flex: 1; min-width: 0; }
.list-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-sub { font-size: 12.5px; color: var(--text-faint); overflow: hidden; text-overflow: ellipsis; }
.list-main .list-sub { white-space: nowrap; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--swatch); flex: none; }
.cat-icon { color: var(--swatch); }
.cat-icon .icon { width: 40px; height: 40px; stroke-width: 1.8; }
.cat-badge {
    display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 12px; flex: none;
    background: color-mix(in srgb, var(--swatch) 18%, transparent); color: var(--swatch);
}
.cat-badge .icon { width: 22px; height: 22px; }

/* Hinweise */
.alert {
    display: flex; gap: 10px; align-items: flex-start;
    padding: 12px 16px; border-radius: var(--radius); margin-bottom: 16px;
    background: var(--surface-3); color: var(--text); border: 1px solid var(--border);
}
.alert .icon { margin-top: 2px; }
.alert-error { background: var(--danger-bg); border-color: var(--danger); }
.alert-warn { background: var(--warn-bg); border-color: var(--warn); }
.empty { text-align: center; padding: 34px 16px; color: var(--text-muted); display: grid; justify-items: center; gap: 12px; }
.empty-icon { width: 34px; height: 34px; color: var(--brand); }

/* Toasts */
.toasts { position: fixed; z-index: 100; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; max-width: calc(100vw - 36px); }
.toast {
    display: flex; gap: 10px; align-items: center; padding: 12px 16px; border-radius: var(--radius);
    background: var(--surface-2); color: var(--text); box-shadow: var(--shadow); border: 1px solid var(--border);
    animation: toast-in .25s var(--ease);
}
.toast-error { border-color: var(--danger); }
.toast-error .icon { color: var(--danger); }
.toast-info .icon, .toast-success .icon { color: var(--success); }
.toast.out { opacity: 0; transform: translateY(8px); transition: all .3s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* Dialoge */
.dialog {
    border: 1px solid var(--border); border-radius: var(--radius-l); padding: 0;
    background: var(--surface-2); color: var(--text); box-shadow: var(--shadow);
    width: min(560px, calc(100vw - 24px)); max-height: calc(100dvh - 24px);
}
.dialog-wide { width: min(760px, calc(100vw - 24px)); }
.dialog::backdrop { background: var(--overlay); backdrop-filter: blur(2px); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px 0 22px; }
.dialog-head h2 { font-size: 1.2rem; }
.dialog-head .icon-btn { color: var(--text-muted); }
.dialog-body { padding: 14px 22px 22px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; flex-wrap: wrap; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.form-grid .span-2 { grid-column: span 2; }

.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch-btn {
    width: 28px; height: 28px; border-radius: 50%; border: 2px solid transparent; background: var(--swatch); padding: 0;
}
.swatch-btn[aria-pressed="true"] { border-color: var(--text); box-shadow: 0 0 0 2px var(--surface-2) inset; }
.icon-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(40px, 1fr)); gap: 6px; }
.icon-pick button {
    display: grid; place-items: center; height: 40px; border-radius: 8px; border: 1px solid var(--border);
    background: var(--surface-3); color: var(--text-muted);
}
.icon-pick button[aria-pressed="true"] { color: var(--swatch, var(--brand)); border-color: var(--swatch, var(--brand)); background: var(--surface); }

.tag {
    display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 99px;
    font-size: 11.5px; background: var(--surface-3); color: var(--text-muted);
}
.tag .icon { width: 12px; height: 12px; }
.code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; letter-spacing: .04em;
    background: var(--surface-3); border-radius: var(--radius-s); padding: 10px 12px; word-break: break-all;
}
.code-lg { font-size: 1.2rem; text-align: center; padding: 16px; border: 1px dashed var(--brand); }

/* FAB (mobil) */
.fab {
    display: none; position: fixed; right: 18px; bottom: 18px; z-index: 25;
    width: 58px; height: 58px; border-radius: 50%; border: 0;
    background: var(--brand); color: var(--brand-contrast); box-shadow: var(--shadow);
    place-items: center;
}
.fab .icon { width: 28px; height: 28px; }

/* ============================= Responsive ============================= */
@media (max-width: 1100px) {
    .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .field { padding-left: 16px; padding-right: 8px; }
    .field-label { font-size: 1.15rem; }
}

@media (max-width: 900px) {
    :root { --header-h: 62px; --gap: 16px; }
    .app-header { padding: 0 12px 0 6px; gap: 6px; }
    .brand { gap: 10px; }
    .brand-logo { width: 46px; height: 46px; padding: 3px; }
    .brand-text { height: 18px; }
    .nav-open-btn { display: inline-grid; }
    .vault-select { max-width: 130px; }

    .app-nav {
        width: min(300px, 86vw); transform: translateX(-102%);
        box-shadow: var(--shadow); z-index: 40;
    }
    body.nav-open .app-nav { transform: none; }
    body.nav-collapsed .app-nav { width: min(300px, 86vw); padding: 22px 16px 12px 22px; }
    body.nav-collapsed .nav-label, body.nav-collapsed .nav-foot a { display: inline; }
    .nav-collapse { display: none; }
    .nav-backdrop { position: fixed; inset: var(--header-h) 0 0 0; z-index: 35; background: var(--overlay); }
    body.nav-open .nav-backdrop { display: block; }

    .app-main, body.nav-collapsed .app-main { padding: calc(var(--header-h) + 16px) 14px 96px; }
    .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); }
    .title-box { padding: 12px 20px; }
    .card-2, .form-card { padding: 20px 14px; }
    .field { grid-template-columns: minmax(0, 1fr); gap: 4px; padding: 10px 6px 6px; }
    .field-label { font-size: 1rem; color: var(--text-muted); }
    .field-control { align-items: stretch; }
    .field-control > input, .field-control > select { text-align: left; font-size: 1.1rem; }
    .field-control > select { text-align-last: left; }
    .chips { justify-content: flex-start; max-width: none; }
    .chip { font-size: 13px; padding: 7px 14px; }
    .toggles { margin-top: 28px; }
    .toggle-row { padding: 10px 6px; }
    .sheet { padding: 18px 14px 14px; }
    .sheet-tools { opacity: 1; }
    .btn-lg { min-height: 54px; padding: 0 28px; font-size: 1.2rem; width: 100%; }
    .form-grid { grid-template-columns: minmax(0, 1fr); }
    .form-grid .span-2 { grid-column: auto; }
    .fab { display: grid; }
    .hide-mobile { display: none !important; }
    .toasts { bottom: 88px; }
}

@media (min-width: 901px) {
    .show-mobile { display: none !important; }
}

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

@media print {
    .app-header, .app-nav, .fab, .toasts, .tool-btn, .sheet-tools { display: none !important; }
    .app-main { padding: 0 !important; }
}
