:root {
    --ruah-accent: #55b6c5;
    --ruah-accent-hover: #25717d;
    --ruah-accent-dark: #349aaa;
    --ruah-bg: #f3f0eb;
    --ruah-bg-mid: #ebe6df;
    --ruah-card: #fffefb;
    --ruah-text: #263340;
    --ruah-muted: #5c6b78;
    --ruah-line: #e2dcd4;
    --ruah-accent-soft: #d4eef1;
    --radius: 14px;
    --shadow: 0 8px 24px rgba(38, 51, 64, 0.08);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: "Inter Tight", "Segoe UI", system-ui, sans-serif;
    background: linear-gradient(180deg, var(--ruah-bg) 0%, var(--ruah-bg-mid) 55%, var(--ruah-bg) 100%);
    color: var(--ruah-text);
    line-height: 1.55;
    min-height: 100vh;
}

.app-header {
    background: linear-gradient(180deg, var(--ruah-accent-dark) 0%, var(--ruah-accent) 100%);
    color: #fff;
    box-shadow: var(--shadow);
}

.app-header-inner {
    max-width: 52rem;
    margin: 0 auto;
    padding: 0.75rem 1.1rem;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem 1rem;
}

.app-brand {
    display: inline-flex;
    align-items: center;
    gap: 0.65rem;
    text-decoration: none !important;
    flex-shrink: 0;
}

.app-brand-icon {
    width: 2.85rem;
    height: 2.85rem;
    object-fit: contain;
    display: block;
    filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.2));
}

.app-brand-name {
    font-weight: 800;
    font-size: 1.45rem;
    letter-spacing: 0.06em;
    line-height: 1;
    color: #fff;
    text-transform: uppercase;
}

body.is-guest .app-header {
    display: none;
}

.login-brand {
    text-align: center;
    margin-bottom: 1.25rem;
}

.login-brand img {
    max-width: min(100%, 20rem);
    height: auto;
    display: inline-block;
}

.app-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem 0.85rem;
    flex: 1;
}

.app-nav a {
    color: rgba(255, 255, 255, 0.92);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.92rem;
}

.app-nav a:hover { color: #fff; text-decoration: underline; }

.app-user {
    margin: 0;
    font-size: 0.85rem;
    opacity: 0.92;
    color: #fff;
}

.app-user-link {
    color: inherit;
}

.app-main {
    max-width: 52rem;
    margin: 0 auto;
    padding: 1.25rem 1.1rem 2.5rem;
    width: 100%;
}

.app-foot {
    text-align: center;
    padding: 1.25rem 1rem 1.75rem;
    margin-top: 1.5rem;
    background: var(--ruah-accent-soft);
    border-top: 1px solid rgba(52, 154, 170, 0.25);
    font-size: 0.82rem;
    line-height: 1.5;
    color: var(--ruah-muted);
}

.app-foot-meta {
    margin: 0 0 0.5rem;
    font-size: 0.8rem;
}

.app-foot-license {
    margin: 0;
    max-width: 40rem;
    margin-left: auto;
    margin-right: auto;
    overflow-wrap: anywhere;
}

.app-foot-license a {
    color: var(--ruah-accent-hover);
    text-underline-offset: 3px;
}

h1 { margin: 0 0 0.35rem; font-size: 1.65rem; color: var(--ruah-accent-hover); }
.lead { color: var(--ruah-muted); margin: 0 0 1.25rem; }

.card {
    background: var(--ruah-card);
    border-radius: var(--radius);
    padding: 1.15rem 1.2rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--ruah-line);
}

.card--hero {
    text-align: center;
    padding: 1.5rem 1.2rem;
    background: linear-gradient(160deg, #184f58, var(--ruah-accent-dark));
    color: #fff;
    border: none;
}

.card--hero .amount {
    font-size: 2.4rem;
    font-weight: 800;
    margin: 0.35rem 0 0;
    letter-spacing: -0.02em;
}

.card--hero .hint {
    color: rgba(255, 255, 255, 0.9);
    opacity: 1;
    font-size: 0.9rem;
    margin: 0.5rem 0 0;
}

.grid-2 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 0.75rem;
}

.stat {
    background: var(--ruah-accent-soft);
    border-radius: 12px;
    padding: 0.85rem;
    text-align: center;
}

.stat strong { display: block; font-size: 1.15rem; color: var(--ruah-accent-hover); }
.stat span { font-size: 0.82rem; color: var(--ruah-muted); }

.form label {
    display: block;
    margin: 0 0 0.85rem;
    font-weight: 600;
    font-size: 0.92rem;
}

.form input,
.form select,
.form textarea {
    display: block;
    width: 100%;
    margin-top: 0.35rem;
    padding: 0.65rem 0.75rem;
    border: 1px solid var(--ruah-line);
    border-radius: 10px;
    font: inherit;
    background: #fff;
}

.kind-picker {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
    margin: 0.5rem 0 1rem;
}

.kind-picker label {
    margin: 0;
    cursor: pointer;
}

.kind-picker input { position: absolute; opacity: 0; pointer-events: none; }

.kind-picker span {
    display: block;
    text-align: center;
    padding: 0.75rem 0.4rem;
    border-radius: 12px;
    border: 2px solid var(--ruah-line);
    background: #fff;
    font-weight: 700;
    font-size: 0.88rem;
    transition: border-color 0.15s, background 0.15s;
}

.kind-picker input:checked + span {
    border-color: var(--ruah-accent-dark);
    background: var(--ruah-accent-soft);
    color: var(--ruah-accent-hover);
}

.btn {
    display: inline-block;
    padding: 0.7rem 1.2rem;
    border-radius: 999px;
    border: none;
    font-weight: 700;
    font-size: 0.95rem;
    cursor: pointer;
    text-decoration: none !important;
    background: linear-gradient(180deg, var(--ruah-accent-dark), var(--ruah-accent));
    color: #fff !important;
}

.btn--ghost {
    background: transparent;
    color: var(--ruah-accent-hover) !important;
    border: 2px solid var(--ruah-accent);
}

.btn-row { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.5rem; }

.btn--tiny {
    padding: 0.35rem 0.65rem;
    font-size: 0.78rem;
    border-radius: 8px;
}

.inline-form {
    display: inline;
    margin: 0;
}

.hint {
    font-size: 0.88rem;
    color: var(--ruah-muted);
    line-height: 1.45;
}

.msg { padding: 0.65rem 0.85rem; border-radius: 10px; margin-bottom: 1rem; }
.msg--ok { background: #e8f5e9; color: #2e5a3a; }
.msg--err { background: #fdecea; color: #8a2a22; }

table.data {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.92rem;
}

table.data th,
table.data td {
    padding: 0.5rem 0.35rem;
    border-bottom: 1px solid var(--ruah-line);
    text-align: left;
}

table.data th { color: var(--ruah-muted); font-weight: 600; }

.login-wrap {
    max-width: 22rem;
    margin: 3rem auto;
}

.journal-filter {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 0.75rem;
    align-items: end;
}

.journal-filter label { margin: 0; }

.tag {
    display: inline-block;
    font-weight: 800;
    font-size: 0.75rem;
    width: 1.25rem;
    text-align: center;
    border-radius: 6px;
    margin-right: 0.25rem;
}

.tag--in { background: #e8f5e9; color: #2e5a3a; }
.tag--out { background: #fdecea; color: #8a2a22; }

.amt-in { color: #2e5a3a; font-weight: 600; }
.amt-out { color: #8a2a22; font-weight: 600; }

.cell-muted { color: var(--ruah-muted); font-size: 0.88rem; }
.cell-actions { white-space: nowrap; font-size: 0.88rem; }

.check-row {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    font-weight: 500;
    margin: 0 0 1rem;
}

.check-row input { margin-top: 0.25rem; width: auto; }

.bar-chart {
    display: flex;
    gap: 0.5rem;
    align-items: flex-end;
    min-height: 8rem;
    padding: 0.5rem 0;
}

.bar-chart-col {
    flex: 1;
    text-align: center;
    min-width: 0;
}

.bar-chart-bars {
    display: flex;
    gap: 3px;
    align-items: flex-end;
    justify-content: center;
    height: 6.5rem;
}

.bar {
    width: 42%;
    min-height: 2px;
    border-radius: 6px 6px 0 0;
}

.bar--in { background: var(--ruah-accent-dark); }
.bar--out { background: #c97a72; }

.bar-chart-label {
    display: block;
    font-size: 0.72rem;
    color: var(--ruah-muted);
    margin-top: 0.35rem;
}

.chart-legend { margin: 0.5rem 0 0; font-size: 0.82rem; }
.dot { display: inline-block; width: 0.65rem; height: 0.65rem; border-radius: 50%; vertical-align: middle; margin-right: 0.15rem; }
.dot--in { background: var(--ruah-accent-dark); }
.dot--out { background: #c97a72; }

.inline-bar {
    display: inline-block;
    height: 0.45rem;
    background: var(--ruah-accent-soft);
    border-radius: 4px;
    margin-right: 0.35rem;
    vertical-align: middle;
    max-width: 8rem;
}

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

.budget-list li {
    margin-bottom: 0.75rem;
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0.25rem 0.75rem;
    font-size: 0.92rem;
}

.budget-list--over { color: #8a2a22; font-weight: 600; }

.budget-track {
    grid-column: 1 / -1;
    height: 0.45rem;
    background: var(--ruah-line);
    border-radius: 999px;
    overflow: hidden;
}

.budget-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--ruah-accent-dark), var(--ruah-accent));
    border-radius: 999px;
}

.budget-list--over .budget-fill { background: #c97a72; }

/* Touch & iOS: keine Auto-Zoom bei Fokus */
.form input,
.form select,
.form textarea {
    font-size: 1rem;
    min-height: 2.75rem;
}

.input-amount {
    font-size: 1.35rem !important;
    font-weight: 700;
    text-align: center;
    min-height: 3.25rem !important;
}

.btn--block {
    display: block;
    width: 100%;
    text-align: center;
    min-height: 3rem;
    padding: 0.85rem 1.2rem;
}

.form-actions {
    margin-top: 0.5rem;
    padding-top: 0.25rem;
}

body.has-app-nav .form--capture .form-actions {
    position: sticky;
    bottom: calc(4.25rem + env(safe-area-inset-bottom, 0px));
    z-index: 5;
    background: linear-gradient(180deg, transparent, var(--ruah-card) 28%);
    padding: 0.75rem 0 0.25rem;
    margin-bottom: -0.25rem;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

.quick-tiles-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.65rem;
}

.quick-tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    min-height: 4.5rem;
    padding: 0.85rem 0.5rem;
    border-radius: 14px;
    text-decoration: none !important;
    font-weight: 700;
    font-size: 0.92rem;
    color: var(--ruah-accent-hover) !important;
    background: var(--ruah-accent-soft);
    border: 2px solid transparent;
    text-align: center;
}

.quick-tile-icon {
    font-size: 1.35rem;
    line-height: 1;
}

.quick-tile--in { background: #e8f5e9; color: #2e5a3a !important; }
.quick-tile--out { background: #fdecea; color: #8a2a22 !important; }

.mobile-menu {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    padding: 0.65rem;
}

.mobile-menu-link {
    display: block;
    padding: 1rem 1rem;
    border-radius: 12px;
    font-weight: 700;
    text-decoration: none !important;
    color: var(--ruah-accent-hover) !important;
    background: var(--ruah-accent-soft);
    min-height: 3rem;
}

.mobile-menu-link--muted {
    background: transparent;
    color: var(--ruah-muted) !important;
    font-weight: 600;
}

.table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -0.25rem;
    padding: 0 0.25rem;
}

.app-user-link {
    padding: 0.35rem 0;
}

@media (max-width: 768px) {
    body.has-app-nav {
        padding-bottom: calc(4.5rem + env(safe-area-inset-bottom, 0px));
    }

    body.has-app-nav .app-main {
        padding-bottom: 1rem;
    }

    body.has-app-nav .app-foot {
        font-size: 0.75rem;
        padding-bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
    }

    body.has-app-nav .app-foot-license {
        display: none;
    }

    .app-nav--desktop,
    .app-user--desktop {
        display: none;
    }

    .app-header-inner {
        justify-content: flex-start;
        padding: 0.7rem 1rem;
    }

    .app-brand-icon {
        width: 2.5rem;
        height: 2.5rem;
    }

    .app-brand-name {
        font-size: 1.25rem;
    }

    h1 { font-size: 1.35rem; }
    .lead { font-size: 0.92rem; margin-bottom: 1rem; }

    .card--hero .amount {
        font-size: 2rem;
    }

    .kind-picker {
        grid-template-columns: 1fr;
        gap: 0.45rem;
    }

    .kind-picker span {
        padding: 0.95rem 0.5rem;
        font-size: 1rem;
    }

    .btn-row .btn {
        flex: 1 1 100%;
        text-align: center;
        min-height: 2.85rem;
    }

    .app-bottom-nav {
        display: flex;
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 100;
        justify-content: space-around;
        align-items: stretch;
        gap: 0;
        padding: 0.35rem 0.25rem calc(0.35rem + env(safe-area-inset-bottom, 0px));
        background: rgba(255, 254, 251, 0.96);
        border-top: 1px solid var(--ruah-line);
        box-shadow: 0 -4px 20px rgba(38, 51, 64, 0.1);
        backdrop-filter: blur(8px);
    }

    .bottom-nav-item {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 0.15rem;
        min-height: 3.25rem;
        min-width: 3rem;
        padding: 0.25rem 0.15rem;
        text-decoration: none !important;
        color: var(--ruah-muted) !important;
        font-size: 0.65rem;
        font-weight: 700;
        border-radius: 10px;
    }

    .bottom-nav-item.is-active {
        color: var(--ruah-accent-hover) !important;
        background: var(--ruah-accent-soft);
    }

    .bottom-nav-item--accent .bottom-nav-icon {
        background: linear-gradient(180deg, var(--ruah-accent-dark), var(--ruah-accent));
        color: #fff;
        width: 2rem;
        height: 2rem;
        border-radius: 999px;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 1.15rem;
        line-height: 1;
    }

    .bottom-nav-icon {
        font-size: 1.1rem;
        line-height: 1;
    }

    .data--journal thead {
        display: none;
    }

    .data--journal tbody tr {
        display: block;
        padding: 0.85rem 0;
        border-bottom: 1px solid var(--ruah-line);
    }

    .data--journal tbody td {
        display: flex;
        justify-content: space-between;
        align-items: baseline;
        gap: 0.75rem;
        border: none;
        padding: 0.25rem 0;
        text-align: right;
    }

    .data--journal tbody td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--ruah-muted);
        font-size: 0.78rem;
        text-align: left;
        flex-shrink: 0;
    }

    .data--journal tbody td[data-label=""]::before {
        content: none;
    }

    .data--journal tbody td[data-label="Vorgang"] {
        flex-direction: column;
        align-items: flex-start;
        text-align: left;
        padding-bottom: 0.5rem;
    }

    .data--journal tbody td[data-label="Vorgang"]::before {
        margin-bottom: 0.15rem;
    }

    .data--journal .cell-actions {
        justify-content: flex-end;
        padding-top: 0.35rem;
    }

    .login-wrap {
        margin: 1.5rem auto;
        max-width: none;
    }

    .journal-filter {
        grid-template-columns: 1fr;
    }

    .journal-filter .btn {
        width: 100%;
        text-align: center;
    }
}

@media (min-width: 769px) {
    .app-bottom-nav {
        display: none !important;
    }

    body.has-app-nav {
        padding-bottom: 0;
    }
}
