/* =========================================================
   VAULT THEME (Patch 7)
   Liegt ueber style.css. Zum Abschalten die <link>-Zeile in
   includes/head.php entfernen.
   ========================================================= */

:root {
    color-scheme: dark;

    --bg: #0e1015;
    --surface: #161920;
    --surface-2: #1c2029;
    --surface-3: #252a35;

    --border: #2a303c;
    --border-strong: #3a4150;

    --text: #eceef3;
    --text-soft: #c3c8d4;
    --text-muted: #8f97a7;

    --primary: #4d63cc;
    --primary-hover: #6178e0;
    --accent-2: #7a6cf0;
    --accent-grad: linear-gradient(135deg, #4d63cc 0%, #6f78ea 100%);
    --link: #8fb4ff;

    --success: #6fdc8c;
    --success-bg: rgba(46, 160, 90, 0.14);
    --success-border: rgba(80, 200, 120, 0.38);
    --warning: #f0c96a;
    --warning-bg: rgba(220, 170, 50, 0.13);
    --warning-border: rgba(230, 190, 90, 0.38);
    --danger: #ff8d8d;
    --danger-bg: rgba(220, 70, 70, 0.14);
    --danger-border: rgba(240, 100, 100, 0.38);

    --radius: 12px;
    --radius-lg: 18px;
    --shadow: 0 1px 0 rgba(255, 255, 255, 0.03) inset, 0 12px 32px rgba(0, 0, 0, 0.28);
    --shadow-hover: 0 1px 0 rgba(255, 255, 255, 0.05) inset, 0 18px 44px rgba(0, 0, 0, 0.4);
    --ease: cubic-bezier(0.22, 0.8, 0.24, 1);
}

html {
    background: var(--bg);
    scroll-behavior: smooth;
}

/* Nie seitlich scrollen (haelt auch die fixierte untere Navigation an Ort und Stelle) */
html { overflow-x: hidden; }
body { overflow-x: clip; }

body {
    background:
        radial-gradient(900px 520px at 12% -8%, rgba(77, 99, 204, 0.16), transparent 60%),
        radial-gradient(700px 420px at 100% 0%, rgba(122, 108, 240, 0.09), transparent 55%),
        var(--bg);
    background-attachment: fixed;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-feature-settings: "tnum" 1, "cv11" 1;
    -webkit-font-smoothing: antialiased;
    letter-spacing: 0.005em;
}

::selection { background: rgba(111, 120, 234, 0.4); }

h1, h2, h3 { letter-spacing: -0.02em; }
h1 { font-size: clamp(1.6rem, 1.2rem + 1.6vw, 2.2rem); font-weight: 750; }
h2 { font-size: 1.15rem; font-weight: 700; }

a { color: var(--link); transition: color 0.15s ease; }

/* ---------- Seitenkopf ---------- */

.topbar {
    align-items: center;
    padding-bottom: 6px;
}

.topbar h1 {
    margin: 0;
    background: linear-gradient(180deg, #fff 0%, #b9c0d4 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.topbar .muted, .topbar .username { margin-top: 4px; }

/* ---------- Karten ---------- */

.card {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.025), rgba(255, 255, 255, 0)) , var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}

.list-card {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.025), rgba(255, 255, 255, 0)), var(--surface);
    box-shadow: var(--shadow);
    transition: transform 0.22s var(--ease), border-color 0.2s ease, box-shadow 0.22s var(--ease);
}

a.list-card:hover, .list-card:hover {
    transform: translateY(-3px);
    border-color: rgba(111, 120, 234, 0.55);
    box-shadow: var(--shadow-hover);
    text-decoration: none;
}

.list-summary-item { border-radius: 10px; }

.empty-state {
    text-align: center;
    padding: 40px 24px;
    border-style: dashed;
    color: var(--text-muted);
}

/* ---------- Formulare ---------- */

input, select, textarea {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text);
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

input:hover, select:hover, textarea:hover { border-color: var(--border-strong); }

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary-hover);
    box-shadow: 0 0 0 3px rgba(97, 120, 224, 0.28);
    background: var(--surface);
}

input[type="checkbox"], input[type="radio"] { accent-color: var(--primary-hover); }

label { color: var(--text-soft); }

/* ---------- Buttons ---------- */

button, .button, .action-button, .nav-button, .secondary-button {
    border-radius: 10px;
    font-weight: 600;
    transition: transform 0.12s ease, background 0.15s ease, border-color 0.15s ease,
                box-shadow 0.15s ease, color 0.15s ease, filter 0.15s ease;
}

button:active, .button:active, .action-button:active, .nav-button:active { transform: scale(0.97); }

button, .button {
    background: var(--accent-grad);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: #fff;
    box-shadow: 0 6px 18px rgba(77, 99, 204, 0.28);
}

button:hover, .button:hover { filter: brightness(1.1); text-decoration: none; }

.action-button, .nav-button, .secondary-button {
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text-soft);
    box-shadow: none;
}

.action-button:hover, .nav-button:hover, .secondary-button:hover {
    background: var(--surface-3);
    border-color: var(--border-strong);
    color: #fff;
    filter: none;
    text-decoration: none;
}

.action-danger, button.action-danger {
    background: var(--danger-bg);
    border: 1px solid var(--danger-border);
    color: var(--danger);
    box-shadow: none;
}

.action-danger:hover { background: rgba(220, 70, 70, 0.24); filter: none; }

.action-success { background: var(--success-bg); border-color: var(--success-border); color: var(--success); box-shadow: none; }
.action-warning { background: var(--warning-bg); border-color: var(--warning-border); color: var(--warning); box-shadow: none; }

button:focus-visible, .button:focus-visible, a:focus-visible, summary:focus-visible {
    outline: 2px solid var(--link);
    outline-offset: 2px;
}

button:disabled { opacity: 0.5; cursor: not-allowed; box-shadow: none; filter: none; }

/* ---------- Hinweise ---------- */

.error, .success {
    position: relative;
    padding: 12px 16px 12px 18px;
    border-radius: 12px;
    border-width: 1px;
    animation: vault-slide-in 0.3s var(--ease) both;
    transition: opacity 0.4s ease, transform 0.4s ease, max-height 0.4s ease, margin 0.4s ease, padding 0.4s ease;
}

.success { background: var(--success-bg); border-color: var(--success-border); color: var(--success); }
.error { background: var(--danger-bg); border-color: var(--danger-border); color: var(--danger); }
.success.is-leaving { opacity: 0; transform: translateY(-6px); max-height: 0; margin: 0; padding-top: 0; padding-bottom: 0; overflow: hidden; }

/* ---------- Tabellen ---------- */

.table-wrapper, .finance-table-wrap {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
    overflow: hidden;
}

.data-table th, .finance-table th {
    background: var(--surface-2);
    color: var(--text-muted);
    font-size: 0.78rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.data-table tbody tr, .finance-table tbody tr { transition: background 0.15s ease; }
.data-table tbody tr:nth-child(even) { background: transparent; }
.data-table tbody tr:hover { background: rgba(255, 255, 255, 0.03); }

/* ---------- Navigation ---------- */

.app-nav {
    background: rgba(14, 16, 21, 0.72);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    backdrop-filter: saturate(160%) blur(18px);
    -webkit-backdrop-filter: saturate(160%) blur(18px);
}

.app-nav-brand {
    background: var(--accent-grad);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    font-weight: 800;
}

.app-nav-links a {
    position: relative;
    border-radius: 10px;
    transition: color 0.15s ease, background 0.15s ease;
}

.app-nav-links a:hover { background: rgba(255, 255, 255, 0.06); }

.app-nav-links a.active {
    color: #fff;
    background: rgba(111, 120, 234, 0.16);
}

.app-nav-links a.active::after {
    content: '';
    position: absolute;
    left: 14px;
    right: 14px;
    bottom: 3px;
    height: 2px;
    border-radius: 2px;
    background: var(--accent-grad);
}

@media (max-width: 700px) {
    .mobile-nav {
        background: rgba(18, 20, 27, 0.82);
        border-top: 1px solid rgba(255, 255, 255, 0.07);
        backdrop-filter: saturate(160%) blur(18px);
        -webkit-backdrop-filter: saturate(160%) blur(18px);
    }

    .mobile-nav a { color: var(--text-muted); transition: color 0.15s ease, transform 0.15s ease; }
    .mobile-nav a:hover, .mobile-nav a:active { background: transparent; color: #fff; }
    .mobile-nav a.active { color: #fff; }
    .mobile-nav a.active svg { color: var(--link); transform: translateY(-1px); }
}

/* ---------- Gemeinsame Bausteine fuer neue Seiten ---------- */

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(170px, 100%), 1fr));
    gap: 14px;
    margin-top: 20px;
}

.stat-card {
    padding: 16px 18px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.03), rgba(255, 255, 255, 0)), var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}

.stat-card .stat-label { overflow-wrap: anywhere; display: block; color: var(--text-muted); font-size: 0.8rem; font-weight: 600; letter-spacing: 0.03em; }
.stat-card .stat-value { display: block; margin-top: 6px; font-size: 1.55rem; font-weight: 750; letter-spacing: -0.02em; }
.stat-card .stat-sub { display: block; margin-top: 2px; color: var(--text-muted); font-size: 0.8rem; }
.stat-card.is-good .stat-value { color: var(--success); }
.stat-card.is-bad .stat-value { color: var(--danger); }

.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    background: var(--surface-3);
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--text-soft);
    font-size: 0.78rem;
    font-weight: 600;
    white-space: nowrap;
}

.chip.is-good { background: var(--success-bg); border-color: var(--success-border); color: var(--success); }
.chip.is-bad { background: var(--danger-bg); border-color: var(--danger-border); color: var(--danger); }
.chip.is-warn { background: var(--warning-bg); border-color: var(--warning-border); color: var(--warning); }
.chip.is-accent { background: rgba(111, 120, 234, 0.16); border-color: rgba(143, 180, 255, 0.4); color: var(--link); }

.progress {
    height: 8px;
    overflow: hidden;
    background: var(--surface-3);
    border-radius: 999px;
}

.progress > span {
    display: block;
    height: 100%;
    background: var(--accent-grad);
    border-radius: inherit;
    transition: width 0.5s var(--ease);
}

.filter-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 18px 0 0; }
.filter-bar input[type="search"] { flex: 1 1 220px; min-width: 0; }

.filter-pills { display: inline-flex; gap: 4px; padding: 3px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; }
.filter-pills button {
    padding: 7px 14px;
    background: transparent;
    border: 0;
    border-radius: 9px;
    color: var(--text-soft);
    box-shadow: none;
    font-size: 0.88rem;
}
.filter-pills button:hover { background: var(--surface-2); filter: none; }
.filter-pills button.is-active { background: var(--surface-3); color: #fff; }

/* ---------- Bewegung ---------- */

@keyframes vault-rise {
    from { opacity: 0; transform: translateY(14px); }
    to { opacity: 1; transform: none; }
}

@keyframes vault-slide-in {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: none; }
}

.container > * { animation: vault-rise 0.5s var(--ease) both; }
.container > *:nth-child(2) { animation-delay: 0.04s; }
.container > *:nth-child(3) { animation-delay: 0.08s; }
.container > *:nth-child(4) { animation-delay: 0.12s; }
.container > *:nth-child(5) { animation-delay: 0.16s; }
.container > *:nth-child(n+6) { animation-delay: 0.2s; }

.list-grid > *, .stat-grid > *, .finance-summary-grid > * { animation: vault-rise 0.5s var(--ease) both; }
.list-grid > *:nth-child(2), .stat-grid > *:nth-child(2) { animation-delay: 0.05s; }
.list-grid > *:nth-child(3), .stat-grid > *:nth-child(3) { animation-delay: 0.1s; }
.list-grid > *:nth-child(4), .stat-grid > *:nth-child(4) { animation-delay: 0.15s; }
.list-grid > *:nth-child(5), .stat-grid > *:nth-child(5) { animation-delay: 0.2s; }
.list-grid > *:nth-child(n+6) { animation-delay: 0.25s; }

/* Weiche Seitenuebergaenge (Chrome, Safari 18+); andere Browser ignorieren das */
@view-transition { navigation: auto; }
::view-transition-old(root) { animation: 0.16s ease both vault-fade-out; }
::view-transition-new(root) { animation: 0.22s ease both vault-fade-in; }
@keyframes vault-fade-out { to { opacity: 0; } }
@keyframes vault-fade-in { from { opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.001ms !important;
        animation-delay: 0ms !important;
        transition-duration: 0.001ms !important;
        scroll-behavior: auto !important;
    }
    @view-transition { navigation: none; }
}

/* Schmale Handys */
@media (max-width: 480px) {
    .filter-bar .filter-pills { width: 100%; }
    .filter-pills button { flex: 1 1 0; min-width: 0; padding: 7px 8px; }
}

/* Ortssuche (Vorschlaege beim Tippen) */
.place-result {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text);
    box-shadow: none;
    font-weight: 500;
}
.place-result:hover, .place-result:focus-visible { background: var(--surface-3); border-color: var(--border-strong); filter: none; }
.place-attribution { margin-top: 2px; color: var(--text-muted); font-size: 0.72rem; text-align: right; }

/* Bereits verwendete Orte und "Letzte" */
.place-result.is-history::before { content: "↺"; margin-right: 8px; color: var(--link); font-weight: 700; }
.place-recent { width: 100%; margin-top: 8px; }
.place-recent[hidden] { display: none; }
.place-recent-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.place-tile { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; width: 100%; min-height: 48px; padding: 10px 12px; text-align: left; font-size: 0.9rem; line-height: 1.3; color: var(--text); background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; cursor: pointer; overflow-wrap: anywhere; }
.place-tile:hover, .place-tile:focus-visible { background: var(--surface-3); border-color: var(--border-strong); filter: none; }
.place-recent-label { margin-bottom: 6px; color: var(--text-muted); font-size: 0.75rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; }
