:root {
    --bg-gradient: radial-gradient(circle at top left, #231b42 0%, #0a0a0f 40%, #0a0a0f 100%);
    --accent-primary: #8b5cf6;
    --accent-secondary: #06b6d4;
    --accent-success: #10b981;
    --accent-warning: #f59e0b;
    --accent-danger: #f43f5e;
    --glass-bg: rgba(255, 255, 255, 0.03);
    --glass-bg-hover: rgba(255, 255, 255, 0.06);
    --glass-border: rgba(255, 255, 255, 0.08);
    --text-primary: #ffffff;
    --text-secondary: #a1a1aa;
    --text-muted: #52525b;
    --input-bg: rgba(0, 0, 0, 0.4);
    --input-border: rgba(255, 255, 255, 0.15);
    --radius-xl: 24px;
    --radius-lg: 16px;
    --radius-md: 10px;
    --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Outfit', sans-serif;
}

body {
    background: var(--bg-gradient);
    background-attachment: fixed;
    color: var(--text-primary);
    min-height: 100vh;
    padding: 20px;
    display: flex;
    justify-content: center;
}

.app-wrapper {
    max-width: 1300px;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* ---- GLASS PANEL ---- */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-xl);
    padding: 24px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.05);
    transition: var(--transition);
}

/* ---- TOP NAV ---- */
.top-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    border-radius: var(--radius-xl);
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.12) 0%, rgba(6, 182, 212, 0.06) 100%);
    border-top: 1px solid rgba(139, 92, 246, 0.35);
    position: sticky;
    top: 16px;
    z-index: 100;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.nav-icon {
    font-size: 1.4rem;
}

.nav-tabs {
    display: flex;
    gap: 6px;
    background: rgba(0, 0, 0, 0.3);
    padding: 6px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--glass-border);
}

.nav-tab {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 10px 20px;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: var(--transition);
}

.nav-tab:hover {
    color: var(--text-primary);
    background: var(--glass-bg-hover);
}

.nav-tab.active {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.4) 0%, rgba(6, 182, 212, 0.2) 100%);
    color: #fff;
    box-shadow: 0 2px 12px rgba(139, 92, 246, 0.3);
    border: 1px solid rgba(139, 92, 246, 0.4);
}

/* ---- TAB CONTENT ---- */
.tab-content {
    display: none;
    flex-direction: column;
    gap: 24px;
}

.tab-content.active {
    display: flex;
}

/* ---- HEADER PANEL ---- */
.header-panel {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.08) 0%, rgba(6, 182, 212, 0.04) 100%);
    border-top: 1px solid rgba(139, 92, 246, 0.2);
}

.timeline-info,
.rates-info {
    display: flex;
    gap: 20px;
    align-items: center;
    flex-wrap: wrap;
}

.date-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 600;
}

.days-remaining {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: rgba(139, 92, 246, 0.15);
    padding: 10px 20px;
    border-radius: var(--radius-lg);
    border: 1px solid rgba(139, 92, 246, 0.35);
}

#days-left {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1;
    text-shadow: 0 0 15px rgba(139, 92, 246, 0.5);
}

.rate-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

/* ---- INPUTS ---- */
input[type="number"],
input[type="date"],
input[type="text"] {
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    color: var(--text-primary);
    padding: 9px 13px;
    border-radius: var(--radius-md);
    font-size: 1rem;
    outline: none;
    transition: var(--transition);
    width: 130px;
    font-family: monospace;
}

input[type="text"] {
    font-family: 'Outfit', sans-serif;
    width: 100%;
}

input:focus,
input:hover {
    border-color: var(--accent-primary);
    background: rgba(139, 92, 246, 0.07);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.15);
}

input[type="date"] {
    font-family: 'Outfit', sans-serif;
    color-scheme: dark;
    width: auto;
}

/* ---- DASHBOARD GRID ---- */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

.column {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* ---- SECTION HEADERS ---- */
h2 {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 18px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.section-balances h2 {
    color: #67e8f9;
}

.section-expected h2 {
    color: #6ee7b7;
}

.section-expenses h2 {
    color: #fda4af;
}

.section-summary h2 {
    color: #c4b5fd;
}

/* Colored left-border accent per section */
.section-balances {
    border-left: 3px solid var(--accent-secondary);
}

.section-expected {
    border-left: 3px solid var(--accent-success);
}

.section-expenses {
    border-left: 3px solid var(--accent-danger);
}

.section-summary {
    border-left: 3px solid var(--accent-primary);
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.07) 0%, transparent 100%);
    box-shadow: 0 0 40px rgba(139, 92, 246, 0.1);
}

/* ---- TABLE HEADERS ---- */
.table-header {
    display: grid;
    gap: 12px;
    padding: 0 12px 10px;
    color: var(--text-muted);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 600;
    border-bottom: 1px solid var(--glass-border);
    margin-bottom: 8px;
}

.balances-grid {
    grid-template-columns: 1.5fr 1.2fr 1fr;
}

.expected-grid {
    grid-template-columns: 1.5fr 1.2fr 1fr 28px;
}

.expenses-grid {
    grid-template-columns: 1.5fr 1.2fr 28px;
}

/* ---- LIST ITEMS ---- */
.list-item {
    display: grid;
    gap: 12px;
    padding: 12px;
    align-items: center;
    background: rgba(0, 0, 0, 0.2);
    border-radius: var(--radius-md);
    margin-bottom: 8px;
    border: 1px solid transparent;
    transition: var(--transition);
}

.list-item:hover {
    background: rgba(255, 255, 255, 0.03);
    border-color: var(--glass-border);
    transform: translateX(3px);
}

.list-item.balances-grid {
    grid-template-columns: 1.5fr 1.2fr 1fr;
}

.list-item.expected-grid {
    grid-template-columns: 1.5fr 1.2fr 1fr 28px;
}

.list-item.expenses-grid {
    grid-template-columns: 1.5fr 1.2fr 28px;
}

.list-item .place-label {
    font-weight: 600;
    color: #e2e8f0;
}

.list-item .huf-value {
    font-family: monospace;
    color: var(--text-secondary);
    font-size: 1rem;
    text-align: right;
}

/* Delete button */
.btn-delete {
    background: rgba(244, 63, 94, 0.1);
    border: 1px solid rgba(244, 63, 94, 0.25);
    color: var(--accent-danger);
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    transition: var(--transition);
    padding: 0;
    flex-shrink: 0;
}

.btn-delete:hover {
    background: rgba(244, 63, 94, 0.25);
    transform: scale(1.1);
}

/* Add button */
.btn-add {
    width: 100%;
    background: transparent;
    border: 1px dashed rgba(255, 255, 255, 0.15);
    color: var(--text-secondary);
    padding: 12px;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 0.95rem;
    transition: var(--transition);
    margin-top: 4px;
    margin-bottom: 16px;
}

.btn-add:hover {
    border-color: var(--accent-primary);
    color: var(--text-primary);
    background: rgba(139, 92, 246, 0.08);
}

/* Snapshot button */
.btn-snapshot {
    width: 100%;
    margin-top: 24px;
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.3), rgba(6, 182, 212, 0.2));
    border: 1px solid rgba(139, 92, 246, 0.4);
    color: #fff;
    padding: 14px;
    border-radius: var(--radius-lg);
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    transition: var(--transition);
    letter-spacing: 0.02em;
}

.btn-snapshot:hover {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.5), rgba(6, 182, 212, 0.35));
    box-shadow: 0 4px 20px rgba(139, 92, 246, 0.35);
    transform: translateY(-1px);
}

.btn-snapshot:active {
    transform: translateY(0);
}

/* Summary row */
.summary-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 12px 0;
    border-top: 1px dashed var(--glass-border);
    font-size: 1.05rem;
}

.summary-row span {
    color: var(--text-secondary);
}

/* Summary stats */
.summary-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
}

.stat-box {
    background: rgba(0, 0, 0, 0.3);
    padding: 20px;
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    gap: 10px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    position: relative;
    overflow: hidden;
}

.stat-box::after {
    content: '';
    position: absolute;
    right: -20px;
    bottom: -20px;
    width: 90px;
    height: 90px;
    border-radius: 50%;
    background: radial-gradient(circle, var(--accent-primary) 0%, transparent 70%);
    opacity: 0.12;
    filter: blur(16px);
}

.stat-box strong {
    font-size: 1.9rem;
    font-weight: 700;
    font-family: monospace;
    line-height: 1;
}

.positive {
    color: var(--accent-success);
    text-shadow: 0 0 18px rgba(16, 185, 129, 0.3);
}

.negative {
    color: var(--accent-danger);
    text-shadow: 0 0 18px rgba(244, 63, 94, 0.3);
}

.accent-success {
    color: var(--accent-success);
}

.accent-danger {
    color: var(--accent-danger);
}

/* ---- PAGE HEADERS (History, Stats) ---- */
.page-header {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.08) 0%, rgba(6, 182, 212, 0.04) 100%);
    border-top: 1px solid rgba(139, 92, 246, 0.2);
}

.page-header h1 {
    font-size: 1.6rem;
    margin-bottom: 6px;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

/* ---- HISTORY ---- */
.history-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.history-card {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-xl);
    padding: 20px 24px;
    backdrop-filter: blur(16px);
    transition: var(--transition);
}

.history-card:hover {
    background: var(--glass-bg-hover);
    border-color: rgba(139, 92, 246, 0.2);
}

.history-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.history-date {
    font-size: 1.05rem;
    font-weight: 600;
    color: #c4b5fd;
}

.history-metrics {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
}

.metric-item {
    background: rgba(0, 0, 0, 0.25);
    padding: 12px 16px;
    border-radius: var(--radius-md);
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.metric-item .metric-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.metric-item .metric-value {
    font-size: 1.2rem;
    font-weight: 700;
    font-family: monospace;
}

.btn-delete-snapshot {
    background: rgba(244, 63, 94, 0.08);
    border: 1px solid rgba(244, 63, 94, 0.2);
    color: var(--accent-danger);
    padding: 6px 14px;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 0.85rem;
    transition: var(--transition);
}

.btn-delete-snapshot:hover {
    background: rgba(244, 63, 94, 0.2);
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-icon {
    font-size: 3rem;
}

/* ---- CHARTS ---- */
.charts-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

.chart-card {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.chart-card h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.chart-wide {
    grid-column: 1 / -1;
}

.chart-wrap {
    position: relative;
    height: 280px;
}

/* ---- RESPONSIVE ---- */
@media (max-width: 1024px) {

    .dashboard-grid,
    .charts-grid {
        grid-template-columns: 1fr;
    }

    .chart-wide {
        grid-column: auto;
    }
}

@media (max-width: 768px) {
    body {
        padding: 12px;
    }

    .top-nav {
        flex-direction: column;
        gap: 12px;
        position: static;
    }

    .nav-tabs {
        width: 100%;
        justify-content: center;
    }

    .nav-tab {
        flex: 1;
        justify-content: center;
    }

    .header-panel {
        flex-direction: column;
    }

    .stat-box strong {
        font-size: 1.5rem;
    }
}

@media (max-width: 500px) {
    .table-header {
        display: none;
    }

    .list-item.balances-grid,
    .list-item.expected-grid,
    .list-item.expenses-grid {
        grid-template-columns: 1fr 1fr;
    }

    .huf-value {
        display: none;
    }
}