﻿/* ===== CSS VARIABLES ===== */
:root {
    --bg: #ffffff;
    --surface: #ffffff;
    --surface2: #f8f9fc;
    --border: #e5e7eb;
    --accent: #f0c060;
    --accent2: #60d4c0;
    --accent3: #f06080;
    --text: #111827;
    --muted: #6b7280;
    --income-color: #60d4a0;
    --expense-color: #f06080;
    --font-display: 'Playfair Display', serif;
    --font-mono: 'DM Mono', monospace;
    --font-body: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    --sidebar-w: 240px;
    --radius: 12px;
}

/* ===== RESET ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { background: var(--bg); color: var(--text); font-family: var(--font-body); font-size: 14px; line-height: 1.6; min-height: 100vh; }
a { color: inherit; text-decoration: none; }
button { cursor: pointer; font-family: var(--font-body); }
input, select, textarea { font-family: var(--font-body); }

/* ===== LAYOUT ===== */
body:not(.auth-body) { min-height: 100vh; }

/* ===== SIDEBAR ===== */
.sidebar {
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0;
    width: var(--sidebar-w);
    height: 100vh;
    z-index: 50;
}
.sidebar-logo {
    padding: 28px 24px 20px;
    
    font-size: 26px;
    font-weight: 900;
    color: var(--accent);
    letter-spacing: -1px;
    border-bottom: 1px solid var(--border);
}
.logo-dot { color: var(--text); font-weight: 400; }

.sidebar-nav { flex: 1; padding: 16px 12px; overflow-y: auto; }
.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    border-radius: 10px;
    color: var(--muted);
    font-size: 13.5px;
    font-weight: 500;
    transition: all 0.15s;
    margin-bottom: 4px;
}
.nav-item:hover { background: var(--surface2); color: var(--text); }
.nav-item.active { background: rgba(240, 192, 96, 0.12); color: var(--accent); }
.nav-icon { font-size: 16px; width: 22px; text-align: center; }

.sidebar-footer {
    padding: 16px 16px 20px;
    border-top: 1px solid var(--border);
}
.user-info { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.user-avatar {
    width: 36px; height: 36px;
    background: var(--accent);
    color: #0d0d0f;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 14px;
    flex-shrink: 0;
}
.user-name { font-size: 13px; font-weight: 600; }
.user-email { font-size: 11px; color: var(--muted); }
.logout-btn {
    width: 100%;
    padding: 8px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--muted);
    font-size: 12px;
    transition: all 0.15s;
}
.logout-btn:hover { border-color: var(--expense-color); color: var(--expense-color); }

/* ===== MAIN CONTENT ===== */
.main-content {
    margin-left: var(--sidebar-w);
    width: auto;
    min-height: 100vh;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

/* ===== TOPBAR ===== */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    padding: 20px 32px;
    border-bottom: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(12px);
    position: sticky;
    top: 0;
    z-index: 40;
}
.topbar-title {  font-size: 22px; font-weight: 700; }
.topbar-actions { display: flex; align-items: center; justify-content: flex-end; gap: 12px; flex-wrap: wrap; }
.month-label { font-size: 13px; font-weight: 500; min-width: 120px; text-align: center; color: var(--text); }
.month-nav { display: flex; align-items: center; gap: 8px; }

.page-body {
    flex: 1;
    width: 100%;
    max-width: 1600px;
    margin: 0 auto;
    padding: 28px 32px;
}

/* ===== ALERTS ===== */
.alert { padding: 12px 24px; font-size: 13px; border-left: 3px solid; margin: 0; }
.alert-success { background: rgba(96, 212, 160, 0.1); border-color: var(--income-color); color: var(--income-color); }
.alert-error { background: rgba(240, 96, 128, 0.1); border-color: var(--expense-color); color: var(--expense-color); }

/* ===== STAT CARDS ===== */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 18px;
    margin-bottom: 24px;
}
.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 22px;
    position: relative;
    overflow: hidden;
    transition: transform 0.2s, border-color 0.2s;
}
.stat-card:hover { transform: translateY(-2px); }
.stat-card::after { content:''; position:absolute; top:-20px;right:-20px;width:80px;height:80px;border-radius:50%;opacity:0.08; }
.stat-balance::after { background: var(--accent); }
.stat-income::after { background: var(--income-color); }
.stat-expense::after { background: var(--expense-color); }
.stat-savings::after { background: var(--accent2); }
.stat-label { font-size: 11px; font-weight: 500; letter-spacing: 1.5px; text-transform: uppercase; color: var(--muted); margin-bottom: 10px; font-family: var(--font-mono); }
.stat-value {font-size: 28px; font-weight: 700; letter-spacing: -1px; margin-bottom: 6px; color: var(--accent); }
.stat-value.income { color: var(--income-color); }
.stat-value.expense { color: var(--expense-color); }
.stat-value.savings { color: var(--accent2); }
.stat-sub { font-size: 11px; color: var(--muted); }

/* ===== PANELS ===== */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; overflow: hidden; }
.panel-header { display: flex; align-items: center; justify-content: space-between; padding: 18px 24px; border-bottom: 1px solid var(--border); }
.panel-title {font-size: 17px; font-weight: 700; }

/* ===== TWO COLUMN GRID ===== */
.two-col-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.7fr) minmax(320px, 1fr);
    gap: 20px;
    align-items: start;
}

/* ===== TRANSACTION LIST ===== */
.tx-list { max-height: 480px; overflow-y: auto; }
.tx-list::-webkit-scrollbar { width: 4px; }
.tx-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
.tx-item { display: flex; align-items: center; gap: 14px; padding: 14px 24px; border-bottom: 1px solid var(--border); transition: background 0.15s; }
.tx-item:hover { background: var(--surface2); }
.tx-item:last-child { border-bottom: none; }
.tx-icon { width: 40px; height: 40px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 18px; flex-shrink: 0; }
.tx-icon.income { background: rgba(96, 212, 160, 0.15); }
.tx-icon.expense { background: rgba(240, 96, 128, 0.15); }
.tx-info { flex: 1; min-width: 0; }
.tx-name { font-weight: 500; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-meta { font-size: 11px; color: var(--muted); margin-top: 2px; font-family: var(--font-mono); }
.tx-amount { font-family: var(--font-mono); font-weight: 500; font-size: 14px; white-space: nowrap; }
.tx-amount.income { color: var(--income-color); }
.tx-amount.expense { color: var(--expense-color); }
.tx-actions { display: flex; gap: 4px; opacity: 0; transition: opacity 0.15s; }
.tx-item:hover .tx-actions { opacity: 1; }
.tx-btn { background: none; border: none; font-size: 14px; color: var(--muted); padding: 4px 8px; border-radius: 6px; transition: all 0.15s; }
.tx-btn:hover { background: var(--surface2); color: var(--text); }

/* ===== CATEGORY BREAKDOWN ===== */
.cat-list { padding: 16px 24px; }
.cat-item { margin-bottom: 18px; }
.cat-row { display: flex; justify-content: space-between; margin-bottom: 6px; }
.cat-name { font-size: 13px; font-weight: 500; }
.cat-amount { font-size: 12px; font-family: var(--font-mono); color: var(--muted); }
.cat-bar { height: 5px; background: var(--surface2); border-radius: 4px; overflow: hidden; }
.cat-fill { height: 100%; background: linear-gradient(90deg, var(--accent2), var(--accent)); border-radius: 4px; transition: width 0.6s; }

/* ===== CHART ===== */
.chart-wrap { padding: 20px 24px; }

/* ===== DATA TABLE ===== */
.table-responsive { overflow-x: auto; }
.data-table { width: 100%; min-width: 760px; border-collapse: collapse; font-size: 13px; }
.data-table th { padding: 12px 18px; text-align: left; font-family: var(--font-mono); font-size: 11px; letter-spacing: 1px; text-transform: uppercase; color: var(--muted); background: var(--surface2); border-bottom: 1px solid var(--border); }
.data-table td { padding: 13px 18px; border-bottom: 1px solid var(--border); }
.data-table tbody tr:hover td { background: var(--surface2); }
.data-table tbody tr:last-child td { border-bottom: none; }
.sort-link { color: var(--muted); transition: color 0.15s; }
.sort-link:hover { color: var(--accent); }

/* ===== BADGES ===== */
.badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 600; text-transform: uppercase; }
.badge-income { background: rgba(96, 212, 160, 0.15); color: var(--income-color); }
.badge-expense { background: rgba(240, 96, 128, 0.15); color: var(--expense-color); }

/* ===== SUMMARY BAR ===== */
.summary-bar { display: grid; grid-template-columns: repeat(3, 1fr); border-top: 1px solid var(--border); background: var(--surface2); }
.summary-item { padding: 16px 24px; border-right: 1px solid var(--border); }
.summary-item:last-child { border-right: none; }
.summary-label { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); font-family: var(--font-mono); margin-bottom: 4px; }
.summary-value { font-size: 18px; font-weight: 700;  }
.summary-value.income { color: var(--income-color); }
.summary-value.expense { color: var(--expense-color); }

/* ===== FILTERS ===== */
.filter-form { padding: 16px 24px 20px; }
.filter-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
@media (min-width: 1200px) { .filter-grid { grid-template-columns: repeat(6, 1fr); } }

/* ===== FORMS ===== */
.form-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.form-group:last-child { margin-bottom: 0; }
.form-label { font-size: 11px; font-weight: 500; letter-spacing: 1.5px; text-transform: uppercase; color: var(--muted); font-family: var(--font-mono); }
.form-control {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 11px 14px;
    color: var(--text);
    font-size: 14px;
    transition: border-color 0.2s;
    outline: none;
    width: 100%;
}
.form-control:focus { border-color: var(--accent); background: var(--bg); }
.form-control option { background: var(--surface2); }
.form-error { font-size: 12px; color: var(--expense-color); margin-top: 2px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.required { color: var(--expense-color); }

/* ===== TYPE TOGGLE ===== */
.type-toggle {
    display: grid;
    grid-template-columns: 1fr 1fr;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 4px;
}
.type-btn {
    padding: 10px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--muted);
    font-size: 13px;
    font-weight: 600;
    transition: all 0.2s;
}
.type-income.active { background: var(--income-color); color: #0d0d0f; }
.type-expense.active { background: var(--expense-color); color: #fff; }

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: 10px;
    font-size: 13.5px;
    font-weight: 600;
    transition: all 0.2s;
    text-decoration: none;
    white-space: nowrap;
}
.btn-primary { background: var(--accent); color: #0d0d0f; }
.btn-primary:hover { background: #f5d080; transform: translateY(-1px); }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--accent); color: var(--accent); }
.btn-danger { background: rgba(240,96,128,0.15); border: 1px solid rgba(240,96,128,0.3); color: var(--expense-color); }
.btn-danger:hover { background: rgba(240,96,128,0.25); }
.btn-sm { padding: 7px 14px; font-size: 12px; }
.btn-xs { padding: 4px 10px; font-size: 11px; border-radius: 6px; }

/* ===== INLINE LAYOUT UTILITIES ===== */
.actions-row {
    display: flex;
    gap: 12px;
    margin-top: 16px;
    flex-wrap: wrap;
}
.actions-row.tight { gap: 8px; margin-top: 0; }
.actions-row.with-top-lg { margin-top: 24px; }
.actions-spacer { margin-left: auto; }

/* ===== EMPTY STATE ===== */
.empty-state { text-align: center; padding: 48px 24px; color: var(--muted); }
.empty-state.large { padding: 80px 24px; }
.empty-icon { font-size: 44px; margin-bottom: 14px; }
.empty-state h3 {  font-size: 20px; color: var(--text); margin-bottom: 8px; }
.empty-state p { font-size: 14px; }
.empty-cell { text-align: center; padding: 40px; color: var(--muted); }

/* ===== GOALS ===== */
.goals-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.goal-card { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 22px; transition: transform 0.2s, border-color 0.2s; }
.goal-card:hover { transform: translateY(-2px); border-color: var(--accent2); }
.goal-card.completed { border-color: var(--income-color); }
.goal-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 10px; }
.goal-emoji { font-size: 32px; }
.goal-actions { display: flex; gap: 6px; opacity: 0; transition: opacity 0.15s; }
.goal-card:hover .goal-actions { opacity: 1; }
.goal-name { font-size: 16px; font-weight: 600; margin-bottom: 4px; }
.goal-desc { font-size: 12px; color: var(--muted); margin-bottom: 12px; }
.goal-amounts { font-size: 14px; margin-bottom: 8px; }
.goal-amounts span:last-child { margin-left: 8px; color: var(--muted); font-size: 12px; }
.goal-bar { height: 8px; background: var(--surface2); border-radius: 4px; overflow: hidden; margin-bottom: 8px; }
.goal-fill { height: 100%; background: linear-gradient(90deg, var(--accent2), var(--accent)); border-radius: 4px; transition: width 0.8s; }
.goal-meta { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.goal-pct {  font-size: 22px; font-weight: 700; color: var(--accent2); }
.goal-pct.complete { color: var(--income-color); }
.goal-deadline { font-size: 11px; color: var(--muted); margin-bottom: 12px; }
.contribute-form { display: flex; gap: 8px; margin-top: 12px; }
.contribute-form .form-control { margin-bottom: 0; padding: 8px 12px; font-size: 13px; }

/* ===== UTILITY ===== */
.mono { font-family: var(--font-mono); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.income { color: var(--income-color) !important; }
.expense { color: var(--expense-color) !important; }

/* ===== AUTH ===== */
.auth-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: var(--bg); }
.auth-container { width: 100%; max-width: 420px; padding: 24px; }
.auth-logo {  font-size: 36px; font-weight: 900; color: var(--accent); text-align: center; margin-bottom: 4px; }
.auth-logo span { color: var(--text); font-weight: 400; }
.auth-subtitle { text-align: center; color: var(--muted); font-size: 13px; margin-bottom: 32px; }
.auth-card { background: var(--surface); border: 1px solid var(--border); border-radius: 20px; padding: 32px; }
.auth-title {  font-size: 22px; font-weight: 700; margin-bottom: 24px; }

/* ===== PAGINATION ===== */
.pagination { display: flex; gap: 4px; list-style: none; }
.page-item .page-link { display: block; padding: 6px 12px; background: var(--surface2); border: 1px solid var(--border); border-radius: 8px; color: var(--muted); font-size: 12px; transition: all 0.15s; }
.page-item.active .page-link { background: var(--accent); border-color: var(--accent); color: #0d0d0f; }
.page-item .page-link:hover { border-color: var(--accent); color: var(--accent); }

/* ===== PAGE-SPECIFIC ===== */
.reports-summary-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); margin-bottom: 24px; }
.reports-charts-grid { margin-bottom: 24px; }

/* ===== MOBILE NAV ===== */
.mobile-nav {
    display: grid;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 60;
    border-top: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.97);
    backdrop-filter: blur(10px);
    grid-template-columns: repeat(5, minmax(0, 1fr));
}
.mobile-nav-link {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-height: 62px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 600;
}
.mobile-nav-link.active { color: var(--accent); }
.mobile-nav-icon { font-size: 16px; line-height: 1; }
.mobile-nav-text { line-height: 1.1; white-space: nowrap; }

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

/* ===== RESPONSIVE ===== */
@media (max-width: 1200px) {
    :root { --sidebar-w: 200px; }
    .two-col-grid { grid-template-columns: 1fr; }
}
@media (max-width: 1024px) {
    .cards-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .goals-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 768px) {
    .sidebar { display: none; }
    .main-content {
        margin-left: 0;
        width: 100%;
    }
    .topbar {
        align-items: flex-start;
        padding: 16px;
    }
    .topbar-actions {
        width: 100%;
        justify-content: flex-start;
    }
    .month-label { min-width: auto; }
    .cards-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .goals-grid { grid-template-columns: 1fr; }
    .filter-grid { grid-template-columns: 1fr 1fr; }
    .summary-bar { grid-template-columns: 1fr; }
    .summary-item {
        border-right: 0;
        border-bottom: 1px solid var(--border);
    }
    .summary-item:last-child { border-bottom: 0; }
    .panel-header {
        flex-wrap: wrap;
        gap: 10px;
        padding: 14px 16px;
    }
    .table-responsive { -webkit-overflow-scrolling: touch; }
    .data-table { min-width: 680px; }
    .tx-item {
        display: grid;
        grid-template-columns: 40px 1fr auto;
        align-items: center;
    }
    .tx-actions { opacity: 1; }
    .page-body {
        padding: 16px;
        padding-bottom: 84px;
    }
    .form-row { grid-template-columns: 1fr; }
    .reports-summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .actions-spacer { margin-left: 0; }
}
@media (max-width: 560px) {
    .cards-grid { grid-template-columns: 1fr; }
    .filter-grid { grid-template-columns: 1fr; }
    .reports-summary-grid { grid-template-columns: 1fr; }
    .topbar-actions .btn { width: 100%; justify-content: center; }
    .month-nav { width: 100%; justify-content: space-between; }
    .mobile-nav-text { font-size: 10px; }
    .tx-item {
        grid-template-columns: 40px 1fr;
        row-gap: 8px;
    }
    .tx-amount,
    .tx-actions {
        grid-column: 2;
        justify-self: start;
    }
    .actions-row:not(.tight) > .btn {
        width: 100%;
        justify-content: center;
    }

    .data-table {
        min-width: 0;
    }
    .data-table thead {
        display: none;
    }
    .data-table,
    .data-table tbody,
    .data-table tr,
    .data-table td {
        display: block;
        width: 100%;
    }
    .data-table tbody tr {
        border-bottom: 1px solid var(--border);
        padding: 10px 0;
    }
    .data-table tbody tr:last-child {
        border-bottom: none;
    }
    .data-table td {
        border: 0;
        padding: 8px 14px;
    }
    .data-table td:not(.empty-cell) {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 10px;
    }
    .data-table td:not(.empty-cell)::before {
        content: attr(data-label);
        color: var(--muted);
        font-family: var(--font-mono);
        font-size: 10px;
        letter-spacing: 0.8px;
        text-transform: uppercase;
        flex-shrink: 0;
    }
    .data-table td .actions-row.tight {
        justify-content: flex-end;
        width: auto;
    }
    .data-table td.empty-cell {
        text-align: center;
        padding: 20px 14px;
    }
}
