/* Design-Tokens (Handoff Teil A5): ruhig, minimalistisch, "persönliches
   digitales Cockpit" statt Enterprise-ERP-Look. Akzent: tiefes Blau/Slate. */
:root {
    --color-bg: #f7f8fa;
    --color-surface: #ffffff;
    --color-border: #e3e6eb;
    --color-text: #14181f;
    --color-text-muted: #6b7280;
    --color-accent: #29416b;
    --color-accent-hover: #1f3255;
    --color-accent-soft: #eaeef5;
    --color-success: #16a34a;
    --color-success-soft: #ecfdf3;
    --color-danger: #dc2626;
    --color-danger-soft: #fef2f2;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 18px;
    --shadow-sm: 0 1px 2px rgba(20, 24, 31, 0.06);
    --shadow-md: 0 6px 20px rgba(20, 24, 31, 0.08);
    --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --nav-height: 64px;
    --transition: 180ms ease;
}

/* Automatisches Dark Mode (Systemeinstellung), aber nur solange der Nutzer in
   den Einstellungen nicht explizit "Hell" gewaehlt hat. */
@media (prefers-color-scheme: dark) {
    html:not([data-theme="light"]) {
        --color-bg: #0f1115;
        --color-surface: #171a20;
        --color-border: #262b34;
        --color-text: #eef1f6;
        --color-text-muted: #9aa2b1;
        --color-accent: #7f9ccf;
        --color-accent-hover: #9db4da;
        --color-accent-soft: #1c2534;
        --color-success: #4ade80;
        --color-success-soft: #14261c;
        --color-danger: #f87171;
        --color-danger-soft: #2a1717;
        --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
        --shadow-md: 0 6px 20px rgba(0, 0, 0, 0.35);
    }
}

/* Manuelle Wahl in den Einstellungen (Teil I: Settings-Theme) gewinnt in beide
   Richtungen gegen die Systemeinstellung. */
html[data-theme="dark"] {
    --color-bg: #0f1115;
    --color-surface: #171a20;
    --color-border: #262b34;
    --color-text: #eef1f6;
    --color-text-muted: #9aa2b1;
    --color-accent: #7f9ccf;
    --color-accent-hover: #9db4da;
    --color-accent-soft: #1c2534;
    --color-success: #4ade80;
    --color-success-soft: #14261c;
    --color-danger: #f87171;
    --color-danger-soft: #2a1717;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 6px 20px rgba(0, 0, 0, 0.35);
}

* {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
}

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
}

body {
    font-family: var(--font-sans);
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--color-accent);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

h1, h2, h3, h4 {
    margin: 0 0 0.5rem;
    font-weight: 600;
    letter-spacing: -0.01em;
}

p {
    margin: 0 0 1rem;
}

/* iOS zoomt beim Fokussieren automatisch in Inputs mit font-size < 16px (Teil A4) */
input, textarea, select, button {
    font-family: inherit;
    font-size: 16px;
}

.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 1.25rem;
}

.card + .card {
    margin-top: 1rem;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.75rem 1.25rem;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: background var(--transition), border-color var(--transition), opacity var(--transition);
    min-height: 44px;
}

.btn-primary {
    background: var(--color-accent);
    color: #ffffff;
}

.btn-primary:hover {
    background: var(--color-accent-hover);
    text-decoration: none;
}

.btn-block {
    display: flex;
    width: 100%;
}

.form-group {
    margin-bottom: 1rem;
}

.form-label {
    display: block;
    margin-bottom: 0.35rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--color-text-muted);
}

.form-input {
    width: 100%;
    padding: 0.75rem 0.9rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-surface);
    color: var(--color-text);
    min-height: 44px;
}

.form-input:focus {
    outline: 2px solid var(--color-accent);
    outline-offset: 1px;
}

.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

.alert-danger {
    background: var(--color-danger-soft);
    color: var(--color-danger);
}

.text-muted {
    color: var(--color-text-muted);
}

/* ---------- Public Landing (Teil A7) ---------- */
.landing {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 2rem;
    padding-top: calc(2rem + env(safe-area-inset-top));
    padding-bottom: calc(2rem + env(safe-area-inset-bottom));
}

.landing-name {
    font-size: 0.95rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--color-text-muted);
    margin-bottom: 2rem;
}

.landing-quote {
    max-width: 32rem;
    font-size: 1.4rem;
    font-weight: 500;
    line-height: 1.5;
    color: var(--color-text);
    margin-bottom: 2.5rem;
}

/* ---------- Auth ---------- */
.auth-shell {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}

.auth-card {
    width: 100%;
    max-width: 22rem;
}

/* ---------- App Shell (Teil G): Bottom Nav Mobile / Sidebar Desktop ---------- */
.app-shell {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
}

.app-main {
    flex: 1;
    padding: 1.25rem;
    padding-top: calc(1.25rem + env(safe-area-inset-top));
    padding-bottom: calc(var(--nav-height) + 1.5rem + env(safe-area-inset-bottom));
    max-width: 40rem;
    margin: 0 auto;
    width: 100%;
}

.app-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 1.25rem;
}

.app-header h1 {
    font-size: 1.4rem;
}

.bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    height: calc(var(--nav-height) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    background: var(--color-surface);
    border-top: 1px solid var(--color-border);
    display: flex;
    align-items: stretch;
    justify-content: space-around;
    z-index: 10;
}

.bottom-nav a, .bottom-nav button {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    font-size: 0.7rem;
    color: var(--color-text-muted);
    background: none;
    border: none;
    min-height: 44px;
}

.bottom-nav a.active {
    color: var(--color-accent);
}

.bottom-nav .fab {
    background: var(--color-accent);
    color: #fff;
    border-radius: 50%;
    width: 48px;
    height: 48px;
    align-self: center;
    font-size: 1.4rem;
    flex: 0 0 48px;
}

.sidebar {
    display: none;
}

@media (min-width: 900px) {
    .bottom-nav {
        display: none;
    }

    .app-main {
        padding-bottom: 1.5rem;
        max-width: 46rem;
    }

    .sidebar {
        display: flex;
        flex-direction: column;
        width: 220px;
        flex-shrink: 0;
        border-right: 1px solid var(--color-border);
        padding: 1.5rem 1rem;
        gap: 0.25rem;
    }

    .sidebar a {
        color: var(--color-text);
        padding: 0.6rem 0.75rem;
        border-radius: var(--radius-sm);
        font-size: 0.9rem;
    }

    .sidebar a:hover {
        background: var(--color-accent-soft);
        text-decoration: none;
    }

    .sidebar a.active {
        background: var(--color-accent-soft);
        color: var(--color-accent);
        font-weight: 600;
    }

    .sidebar-brand {
        font-weight: 700;
        letter-spacing: 0.04em;
        margin-bottom: 1.5rem;
        padding: 0 0.75rem;
    }
}

.life-area-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 0.75rem;
}

.life-area-item {
    padding: 0.9rem;
}

.life-area-item .name {
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 0.25rem;
}

.life-area-item .rating {
    font-size: 0.8rem;
    color: var(--color-text-muted);
}

/* ---------- Charts (Analytik, server-seitig gerendert) ---------- */
.chart-bars {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.chart-bar-row {
    display: grid;
    grid-template-columns: 6.5rem 1fr 3rem;
    align-items: center;
    gap: 0.6rem;
}

.chart-bar-label {
    font-size: 0.78rem;
    color: var(--color-text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chart-bar-track {
    height: 8px;
    border-radius: 999px;
    background: var(--color-accent-soft);
    overflow: hidden;
}

.chart-bar-fill {
    height: 100%;
    border-radius: 999px;
    background: var(--color-accent);
    transition: width var(--transition);
}

.chart-bar-value {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    text-align: right;
}

.chart-lines {
    width: 100%;
    height: 140px;
    display: block;
}

/* ---------- Kleine Utility-Buttons (Bearbeiten/Löschen in Listen) ---------- */
.btn-sm {
    min-height: 36px;
    padding: 0.4rem 0.75rem;
    font-size: 0.8rem;
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--color-border);
    color: var(--color-text-muted);
}

.btn-danger-outline {
    background: transparent;
    border: 1px solid var(--color-danger);
    color: var(--color-danger);
}
