:root {
    --bg: #000000;
    --surface: #0f0f0f;
    --surface-2: #1a1a1a;
    --border: #262626;
    --text: #ffffff;
    --text-muted: #737373;
    --green: #16a34a;
    --green-dim: #14532d;
    --red: #dc2626;
    --red-dim: #7f1d1d;
    --sidebar-width: 220px;
    --blue-gauge: #3b5bdb;
    --green-gauge: #2d8a4e;
    --gray-gauge: #d4d4d4;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
}

button, input, select, textarea {
    font-family: inherit;
    font-size: inherit;
}

a { color: inherit; text-decoration: none; }

.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--bg);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 100;
}

.sidebar-header {
    padding: 1.5rem 1.25rem;
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.brand-icon {
    width: 28px;
    height: 28px;
    flex: 0 0 auto;
}

.brand-name {
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: 0;
}

.sidebar-nav {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 0 0.5rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 0.75rem;
    border-radius: 0.5rem;
    color: var(--text-muted);
    transition: all 0.15s;
    font-size: 0.9rem;
}

.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--surface-2); color: var(--text); }

.sidebar-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.user-name { font-size: 0.85rem; color: var(--text-muted); }

.logout-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.8rem;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
}

.logout-btn:hover { color: var(--text); background: var(--surface-2); }

.main-content {
    margin-left: var(--sidebar-width);
    padding: 2rem;
    min-height: 100vh;
}

.main-content.no-sidebar {
    margin-left: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mobile-nav { display: none; }

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.page-header h1 { font-size: 1.5rem; font-weight: 600; }

.page-header-icon {
    width: 28px;
    height: 28px;
    flex: 0 0 auto;
    margin-right: 0.75rem;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text);
    cursor: pointer;
    font-size: 0.875rem;
    transition: all 0.15s;
}

.btn:hover { background: var(--border); }

.btn-primary {
    background: var(--green);
    border-color: var(--green);
    color: #fff;
    font-weight: 500;
}

.btn-primary:hover { background: #15803d; }

.btn-full { width: 100%; justify-content: center; }

.btn-sm { padding: 0.3rem 0.6rem; font-size: 0.8rem; }

.btn-ghost { background: transparent; border-color: transparent; color: var(--text-muted); }
.btn-ghost:hover { color: var(--text); background: var(--surface-2); }

.btn-icon {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 0.25rem;
    display: inline-flex;
    align-items: center;
}

.btn-icon:hover { color: var(--text); background: var(--surface-2); }

.gauges-container {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
    width: 100%;
    max-width: 860px;
    margin-left: auto;
    margin-right: auto;
}

.gauges-secondary {
    display: flex;
    gap: 1.5rem;
    flex: 0 0 auto;
}

.gauge-item {
    flex: 0 0 260px;
    max-width: 260px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.gauge-svg {
    width: 100%;
    max-width: 220px;
    height: auto;
}

.gauge-track {
    fill: none;
    stroke: #1f1f1f;
    stroke-width: 14;
    stroke-linecap: round;
}

.gauge-fill {
    fill: none;
    stroke-width: 14;
    stroke-linecap: round;
    transition: stroke-dasharray 0.6s ease;
}

.gauge-value {
    font-size: 1.35rem;
    font-weight: 700;
    fill: var(--text);
    text-anchor: middle;
}

.gauge-label {
    font-size: 0.6rem;
    fill: var(--text-muted);
    text-anchor: middle;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.gauge-delta-wrap {
    margin-top: 0.35rem;
    text-align: center;
}

.gauge-delta {
    font-size: 0.8rem;
    font-weight: 600;
}

.gauge-delta.positive { color: var(--green); }
.gauge-delta.negative { color: var(--red); }
.gauge-delta.neutral { color: var(--text-muted); }

.nowrap { white-space: nowrap; }

.accounts-grid {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.account-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    border-left: 4px solid;
    overflow: hidden;
}

.account-header {
    display: flex;
    align-items: center;
    padding: 0.85rem 1rem;
    cursor: pointer;
    gap: 0.75rem;
}

.account-header:hover { background: var(--surface-2); }

.account-name { font-weight: 500; flex: 1; }
.account-total { color: var(--text-muted); font-size: 0.9rem; }

.expand-icon {
    transition: transform 0.2s;
    color: var(--text-muted);
}

.account-card.expanded .expand-icon { transform: rotate(180deg); }

.collapse-arrow { display: none; }

.account-body {
    display: none;
    border-top: 1px solid var(--border);
}

.account-card.expanded .account-body { display: block; }

.sub-account-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 1rem;
    border-bottom: 1px solid var(--border);
}

.sub-account-row:last-child { border-bottom: none; }

.sa-name { font-size: 0.9rem; color: var(--text-muted); }

.sa-type {
    font-size: 0.7rem;
    padding: 0.1rem 0.4rem;
    border-radius: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.sa-type.invested { background: var(--green-dim); color: var(--green); }
.sa-type.liquid { background: rgba(59,130,246,0.15); color: #3b82f6; }

.sa-value { font-size: 0.9rem; font-weight: 500; }

.chart-container {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    padding: 0;
    height: 360px;
    margin-bottom: 1.5rem;
    display: flex;
    flex-direction: column;
}

.chart-toggle {
    display: flex;
    gap: 0;
    padding: 0.75rem 0.75rem 0 0.75rem;
    align-items: center;
}

.chart-toggle-btn {
    flex: 1;
    padding: 0.4rem 0;
    background: #1a1a1a;
    border: 1px solid #333;
    color: #666;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    height: 2rem;
}

.chart-toggle-btn:first-child {
    border-radius: 0.5rem 0 0 0.5rem;
}

.chart-toggle-btn:nth-child(3) {
    border-radius: 0 0.5rem 0.5rem 0;
}

.chart-toggle-btn:not(:first-child) {
    border-left: none;
}

.chart-toggle-btn.active[data-view="gesamt"] {
    background: #d4d4d4;
    color: #000000;
    border-color: #d4d4d4;
}

.chart-toggle-btn.active[data-view="liquid"] {
    background: #3b5bdb;
    color: #ffffff;
    border-color: #3b5bdb;
}

.chart-toggle-btn.active[data-view="investiert"] {
    background: #2d8a4e;
    color: #ffffff;
    border-color: #2d8a4e;
}

.chart-toggle-btn.active + .chart-toggle-btn {
    border-left-color: #333;
}

.chart-canvas-wrap {
    flex: 1;
    padding: 0.5rem 0.75rem 0.5rem 0.75rem;
    min-height: 0;
}

.chart-canvas-wrap canvas {
    display: block;
}

.chart-zoom-btn {
    margin-left: 0.5rem;
    background: #1a1a1a;
    border: 1px solid #333;
    color: #888;
    font-size: 0.7rem;
    padding: 0 0.6rem;
    border-radius: 0.5rem;
    cursor: pointer;
    height: 2rem;
    line-height: 1;
}

.chart-zoom-btn.zoomed {
    color: #fff;
    border-color: #555;
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    color: var(--text-muted);
    padding: 4rem 0;
}

.login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 1rem;
}

.login-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 1rem;
    padding: 2.5rem;
    width: 100%;
    max-width: 380px;
}

.login-title { font-size: 1.5rem; font-weight: 700; text-align: center; margin-bottom: 0.25rem; }
.login-subtitle { text-align: center; color: var(--text-muted); font-size: 0.9rem; margin-bottom: 1.5rem; }

.login-logo {
    display: block;
    width: 72px;
    height: 72px;
    object-fit: contain;
    margin: 0 auto 1rem;
}

.login-error {
    background: var(--red-dim);
    color: var(--red);
    padding: 0.5rem 0.75rem;
    border-radius: 0.5rem;
    font-size: 0.85rem;
    margin-bottom: 1rem;
}

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

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

.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="date"] {
    width: 100%;
    padding: 0.6rem 0.75rem;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    color: var(--text);
    font-size: 0.9rem;
    outline: none;
}

.form-group input:focus { border-color: var(--text-muted); }

.form-check {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.form-check label { margin-bottom: 0; }

.badge {
    display: inline-block;
    background: var(--green-dim);
    color: var(--green);
    padding: 0.15rem 0.5rem;
    border-radius: 1rem;
    font-size: 0.75rem;
    margin-left: 0.5rem;
}

.entry-form {
    max-width: 700px;
}

.entry-section {
    margin-bottom: 1.5rem;
}

.entry-section-header {
    padding: 0.5rem 0.75rem;
    border-left: 4px solid;
    font-size: 1rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.entry-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--border);
}

.entry-row label {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.entry-row input[type="number"] {
    width: 160px;
    padding: 0.4rem 0.6rem;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    color: var(--text);
    font-size: 0.9rem;
    text-align: right;
    outline: none;
}

.entry-row input[type="number"]:focus { border-color: var(--text-muted); }

.table-container {
    overflow-x: auto;
}

.history-cards {
    display: none;
}

.history-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    padding: 0.85rem 1rem;
    position: relative;
    cursor: pointer;
}

.hc-date {
    color: var(--text-muted);
    font-size: 0.75rem;
    margin-bottom: 0.25rem;
}

.hc-main {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
}

.hc-total {
    font-size: 1.05rem;
    font-weight: 600;
}

.hc-delta {
    font-size: 0.85rem;
    font-weight: 600;
}

.hc-delta.positive { color: var(--green); }
.hc-delta.negative { color: var(--red); }
.hc-delta.neutral { color: var(--text-muted); }

.hc-sub {
    display: flex;
    gap: 1rem;
    margin-top: 0.25rem;
    color: var(--text-muted);
    font-size: 0.75rem;
}

.hc-delete {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    min-height: 44px;
    min-width: 44px;
    padding: 0;
}

.date-display {
    display: block;
    margin-top: 0.35rem;
    color: var(--text-muted);
    font-size: 0.8rem;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th {
    text-align: left;
    padding: 0.75rem 1rem;
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border);
}

.data-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
}

.data-table .clickable-row { cursor: pointer; }
.data-table .clickable-row:hover { background: var(--surface-2); }

.data-table .positive { color: var(--green); }
.data-table .negative { color: var(--red); }
.data-table .neutral { color: var(--text-muted); }

.delete-btn { color: var(--text-muted); }
.delete-btn:hover { color: var(--red); }

.tabs {
    display: flex;
    gap: 0;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.tab-btn {
    padding: 0.75rem 1.25rem;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.9rem;
}

.tab-btn.active { color: var(--text); border-bottom-color: var(--green); }
.tab-btn:hover { color: var(--text); }

.tab-content { display: none; }
.tab-content.active { display: block; }

.settings-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    border-left: 4px solid;
    margin-bottom: 1rem;
    overflow: hidden;
}

.settings-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    background: var(--surface-2);
}

.account-edit-inline {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.inline-input {
    padding: 0.35rem 0.5rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 0.375rem;
    color: var(--text);
    font-size: 0.85rem;
    outline: none;
}

.inline-input.sm { width: 120px; }

.inline-input:focus { border-color: var(--text-muted); }

.inline-select {
    padding: 0.3rem 0.5rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 0.375rem;
    color: var(--text);
    font-size: 0.8rem;
    outline: none;
}

.color-input {
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 0.25rem;
    cursor: pointer;
    padding: 0;
    background: none;
}

.color-input::-webkit-color-swatch-wrapper { padding: 0; }
.color-input::-webkit-color-swatch { border: 1px solid var(--border); border-radius: 0.25rem; }

.sub-accounts-list { padding: 0.5rem 1rem; }

.sub-account-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0;
    border-bottom: 1px solid var(--border);
}

.sub-account-item:last-child { border-bottom: none; }
.sub-account-item.inactive { opacity: 0.5; }

.reorder-btns {
    display: flex;
    gap: 0.25rem;
}

.toggle {
    position: relative;
    width: 36px;
    height: 20px;
    display: inline-block;
}

.toggle input { opacity: 0; width: 0; height: 0; }

.toggle-slider {
    position: absolute;
    inset: 0;
    background: var(--border);
    border-radius: 1rem;
    cursor: pointer;
    transition: 0.2s;
}

.toggle-slider::before {
    content: '';
    position: absolute;
    height: 14px;
    width: 14px;
    left: 3px;
    bottom: 3px;
    background: var(--text);
    border-radius: 50%;
    transition: 0.2s;
}

.toggle input:checked + .toggle-slider { background: var(--green); }
.toggle input:checked + .toggle-slider::before { transform: translateX(16px); }

.add-inline {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0;
    flex-wrap: wrap;
}

@media (max-width: 767px) {
    .sidebar { display: none; }

    .main-content {
        margin-left: 0;
        padding: 1rem;
        padding-bottom: 5rem;
    }

    .main-content.no-sidebar {
        padding: 0;
        height: 100dvh;
        overflow: hidden;
        overscroll-behavior: none;
    }

    .main-content.no-sidebar .login-container {
        min-height: 100%;
        padding: 1rem;
    }

    .main-content.no-sidebar .login-card {
        width: min(380px, calc(100vw - 2rem));
        padding: 1.5rem;
    }

    .mobile-nav {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: var(--bg);
        border-top: 1px solid var(--border);
        z-index: 100;
        justify-content: space-around;
        padding: 0.5rem 0;
    }

    .mobile-nav-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 0.2rem;
        color: var(--text-muted);
        font-size: 0.7rem;
        padding: 0.25rem;
        min-height: 44px;
    }

    .mobile-nav-item.active { color: var(--text); }

    .page-header {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }

    .page-header .btn-primary {
        width: 100%;
        justify-content: center;
    }

    .gauges-container {
        display: grid;
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .gauges-secondary {
        display: flex;
        gap: 0.75rem;
        justify-content: center;
    }

    .gauge-item {
        max-width: none;
    }

    .gauge-gesamt {
        justify-self: center;
        width: min(260px, 85vw);
    }

    .gauge-investiert,
    .gauge-liquide {
        width: min(160px, 44vw);
    }

    .gauge-value { font-size: 1.15rem; }
    .gauge-label { font-size: 0.55rem; }
    .gauge-delta { font-size: 0.75rem; }

    .chart-canvas-wrap { padding: 0; }
    .chart-container { height: 320px; }

    .history-table-wrap { display: none; }
    .history-cards {
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
    }

    .history-card { min-height: 44px; padding-right: 3.25rem; }

    .btn,
    .btn-icon,
    .tab-btn,
    .account-header,
    .history-card {
        min-height: 44px;
    }

    .account-card .expand-icon { display: none; }
    .collapse-arrow {
        display: inline-block;
        margin-left: 0.5rem;
        font-size: 0.7rem;
        color: var(--text-muted);
        transition: transform 0.2s;
    }

    .account-card .account-body { display: none !important; }
    .account-card.open .account-body { display: block !important; }
    .account-card.open .collapse-arrow { transform: rotate(180deg); }

    .entry-form { max-width: none; }
    .entry-row { gap: 0.75rem; }
    .entry-row input[type="number"] { width: 120px; }
}
