/* ============================================================
   LUCIDE-STYLE SVG ICONS (inline)
   ============================================================ */
.svg-icon {
    width: 18px;
    height: 18px;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    fill: none;
    flex-shrink: 0;
}
.svg-icon.sm { width: 14px; height: 14px; }
.svg-icon.lg { width: 22px; height: 22px; }
.svg-icon.xl { width: 28px; height: 28px; }

/* ============================================================
   CSS VARIABLES — DARK (default)
   ============================================================ */
:root {
    --bg-base:       #09090b;
    --bg-surface:    #18181b;
    --bg-card:       #1c1c21;
    --bg-elevated:   #27272a;
    --bg-hover:      #2e2e33;
    --bg-input:      #131316;
    --border:        #27272a;
    --border-subtle: #1f1f23;
    --border-focus:  #6d5acd;

    --text-primary:   #fafafa;
    --text-secondary: #a1a1aa;
    --text-muted:     #52525b;
    --text-inverse:   #09090b;

    --accent:       #7c5cfc;
    --accent-hover: #9370ff;
    --accent-soft:  rgba(124,92,252,.12);

    --green:       #22c55e;
    --green-soft:  rgba(34,197,94,.12);
    --red:         #ef4444;
    --red-soft:    rgba(239,68,68,.12);
    --blue:        #3b82f6;
    --blue-soft:   rgba(59,130,246,.12);
    --yellow:      #eab308;
    --yellow-soft: rgba(234,179,8,.12);
    --orange:      #f97316;
    --orange-soft: rgba(249,115,22,.12);
    --cyan:        #06b6d4;
    --pink:        #ec4899;
    --purple:      #8b5cf6;
    --teal:        #14b8a6;
    --slate:       #64748b;

    --radius:       14px;
    --radius-sm:    10px;
    --radius-xs:    6px;
    --shadow-sm:    0 1px 2px rgba(0,0,0,.3);
    --shadow:       0 4px 16px rgba(0,0,0,.35);
    --shadow-lg:    0 12px 40px rgba(0,0,0,.45);

    --transition:   .18s cubic-bezier(.4,0,.2,1);
    --font:         'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* ============================================================
   LIGHT THEME
   ============================================================ */
[data-theme="light"] {
    --bg-base:       #f8f9fc;
    --bg-surface:    #ffffff;
    --bg-card:       #ffffff;
    --bg-elevated:   #f1f3f8;
    --bg-hover:      #eef0f5;
    --bg-input:      #f4f5f9;
    --border:        #e2e4ea;
    --border-subtle: #ececf1;
    --border-focus:  #7c5cfc;

    --text-primary:   #18181b;
    --text-secondary: #6b7280;
    --text-muted:     #9ca3af;
    --text-inverse:   #fafafa;

    --accent:       #6d5acd;
    --accent-hover: #5b47b5;
    --accent-soft:  rgba(109,90,205,.08);

    --green-soft:  rgba(34,197,94,.08);
    --red-soft:    rgba(239,68,68,.08);
    --blue-soft:   rgba(59,130,246,.08);
    --yellow-soft: rgba(234,179,8,.08);
    --orange-soft: rgba(249,115,22,.08);

    --shadow-sm:    0 1px 2px rgba(0,0,0,.05);
    --shadow:       0 4px 16px rgba(0,0,0,.06);
    --shadow-lg:    0 12px 40px rgba(0,0,0,.08);
}

/* ============================================================
   RESET & BASE
   ============================================================ */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

html { font-size: 14px; -webkit-font-smoothing: antialiased; }

body {
    font-family: var(--font);
    background: var(--bg-base);
    color: var(--text-primary);
    display: flex;
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.5;
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
    width: 260px;
    background: var(--bg-surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 100;
    transition: transform var(--transition);
}

.sidebar-header {
    padding: 24px 20px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-mark {
    width: 34px;
    height: 34px;
    background: var(--accent);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.logo-text { font-size: 17px; font-weight: 700; letter-spacing: -.02em; }

.sidebar-nav {
    flex: 1;
    padding: 8px 12px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    text-decoration: none;
    transition: all var(--transition);
    font-weight: 500;
    font-size: 13.5px;
}

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

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

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border);
}

/* ============================================================
   MAIN AREA
   ============================================================ */
.main {
    flex: 1;
    margin-left: 260px;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ============================================================
   TOPBAR
   ============================================================ */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 32px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-surface);
    flex-wrap: wrap;
    gap: 12px;
    position: sticky;
    top: 0;
    z-index: 50;
    backdrop-filter: blur(12px);
}

.topbar-left { display: flex; align-items: center; gap: 16px; }
.topbar-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.page-title {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -.02em;
}

.menu-btn {
    display: none;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 6px;
    border-radius: var(--radius-xs);
}
.menu-btn:hover { background: var(--bg-hover); }

/* ============================================================
   DATE FILTERS
   ============================================================ */
.date-filter {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

/* ============================================================
   CONTENT
   ============================================================ */
.content { flex: 1; padding: 28px 32px; }
.page { display: none; }
.page.active { display: block; }

/* ============================================================
   STAT CARDS
   ============================================================ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px;
    transition: all var(--transition);
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    border-radius: var(--radius) var(--radius) 0 0;
}

.stat-card.green::before { background: var(--green); }
.stat-card.red::before { background: var(--red); }
.stat-card.blue::before { background: var(--blue); }
.stat-card.purple::before { background: var(--accent); }

.stat-card:hover {
    border-color: var(--border-focus);
    box-shadow: var(--shadow);
}

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

.stat-card-label {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .06em;
    font-weight: 600;
}

.stat-card-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
}

.stat-card-icon.green { background: var(--green-soft); color: var(--green); }
.stat-card-icon.red { background: var(--red-soft); color: var(--red); }
.stat-card-icon.blue { background: var(--blue-soft); color: var(--blue); }
.stat-card-icon.purple { background: var(--accent-soft); color: var(--accent); }

.stat-card-value {
    font-size: 26px;
    font-weight: 800;
    letter-spacing: -.03em;
    line-height: 1.2;
}

.stat-card-sub {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

.text-green  { color: var(--green); }
.text-red    { color: var(--red); }
.text-blue   { color: var(--blue); }
.text-purple { color: var(--accent); }
.text-yellow { color: var(--yellow); }
.text-muted  { color: var(--text-muted); }

/* ============================================================
   CHARTS
   ============================================================ */
.chart-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.chart-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px;
}

.chart-card-title {
    font-size: 14px;
    font-weight: 700;
    margin-bottom: 18px;
    display: flex;
    align-items: center;
    gap: 8px;
    letter-spacing: -.01em;
}

.chart-card-title .svg-icon { color: var(--accent); }

.chart-wrapper {
    position: relative;
    width: 100%;
    max-height: 340px;
}

/* ============================================================
   TABLE
   ============================================================ */
.table-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.table-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 22px;
    border-bottom: 1px solid var(--border);
}

.table-title {
    font-size: 15px;
    font-weight: 700;
    letter-spacing: -.01em;
}

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

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

th {
    text-align: left;
    padding: 12px 18px;
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .06em;
    border-bottom: 1px solid var(--border);
    background: var(--bg-elevated);
}

td {
    padding: 14px 18px;
    border-bottom: 1px solid var(--border-subtle);
    font-size: 13px;
}

tr:last-child td { border-bottom: none; }
tbody tr { transition: background var(--transition); }
tbody tr:hover td { background: var(--bg-hover); }

.amount { font-weight: 700; font-variant-numeric: tabular-nums; }
.amount-income { color: var(--green); }
.amount-expense { color: var(--red); }

.category-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
    font-family: var(--font);
    line-height: 1;
}

.btn:hover { background: var(--bg-hover); border-color: var(--text-muted); }
.btn-sm { padding: 6px 12px; font-size: 12px; border-radius: var(--radius-xs); }
.btn-full { width: 100%; justify-content: center; }

.btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

.btn-danger { border-color: var(--red); color: var(--red); }
.btn-danger:hover { background: var(--red-soft); }

.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--bg-hover); border-color: transparent; }

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

.btn-icon {
    padding: 7px;
    border-radius: var(--radius-xs);
}

/* ============================================================
   INPUTS
   ============================================================ */
.input, .select, .textarea {
    padding: 9px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 13px;
    font-family: var(--font);
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
    line-height: 1.4;
}

.input:focus, .select:focus, .textarea:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.select { cursor: pointer; appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2371717a' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 32px;
}

.textarea { resize: vertical; min-height: 80px; }

.form-group { margin-bottom: 18px; }

.form-label {
    display: block;
    margin-bottom: 7px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: .02em;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

/* ============================================================
   MODAL
   ============================================================ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.55);
    backdrop-filter: blur(6px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.modal-overlay.active { display: flex; }

.modal {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 18px;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    animation: modalIn .2s ease;
}

@keyframes modalIn {
    from { opacity: 0; transform: scale(.95) translateY(8px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 22px 24px 18px;
    border-bottom: 1px solid var(--border);
}

.modal-title { font-size: 17px; font-weight: 700; letter-spacing: -.01em; }

.modal-close {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-xs);
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
}
.modal-close:hover { background: var(--bg-hover); color: var(--text-primary); }

.modal-body { padding: 24px; }

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 24px;
    padding-top: 18px;
    border-top: 1px solid var(--border);
}

/* ============================================================
   TOAST
   ============================================================ */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 2000;
}

.toast {
    padding: 12px 20px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    animation: toastIn .25s ease;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 8px;
}

.toast-success { background: var(--green); color: white; }
.toast-error { background: var(--red); color: white; }
.toast-info { background: var(--accent); color: white; }

@keyframes toastIn {
    from { transform: translateY(12px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* ============================================================
   CATEGORY ITEMS
   ============================================================ */
.category-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 10px;
}

.category-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 18px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    transition: all var(--transition);
}

.category-item:hover {
    border-color: var(--border-focus);
    box-shadow: var(--shadow-sm);
}

.category-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.category-info { flex: 1; min-width: 0; }
.category-name { font-weight: 600; font-size: 13.5px; }
.category-type {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.category-actions { display: flex; gap: 4px; }

/* ============================================================
   TABS
   ============================================================ */
.tabs {
    display: flex;
    gap: 2px;
    background: var(--bg-elevated);
    padding: 3px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    width: fit-content;
}

.tab {
    padding: 7px 16px;
    border-radius: var(--radius-xs);
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 12.5px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    font-family: var(--font);
    display: flex;
    align-items: center;
    gap: 6px;
}

.tab.active {
    background: var(--bg-card);
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
    font-weight: 600;
}

.tab:hover:not(.active) { color: var(--text-primary); }

/* ============================================================
   PROGRESS BAR
   ============================================================ */
.progress-bar {
    height: 5px;
    background: var(--bg-elevated);
    border-radius: 3px;
    overflow: hidden;
    margin-top: 8px;
}

.progress-fill {
    height: 100%;
    border-radius: 3px;
    transition: width .6s cubic-bezier(.4,0,.2,1);
}

/* ============================================================
   TOP LIST
   ============================================================ */
.top-list-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 11px 0;
    border-bottom: 1px solid var(--border-subtle);
}
.top-list-item:last-child { border-bottom: none; }

.top-list-rank {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--bg-elevated);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    flex-shrink: 0;
}

.top-list-info { flex: 1; min-width: 0; }
.top-list-name { font-weight: 600; font-size: 13px; }
.top-list-date { font-size: 11px; color: var(--text-muted); }
.top-list-amount { font-weight: 700; color: var(--red); font-variant-numeric: tabular-nums; }

/* ============================================================
   EMPTY STATE
   ============================================================ */
.empty-state {
    text-align: center;
    padding: 64px 20px;
    color: var(--text-muted);
}

.empty-state-icon {
    width: 56px;
    height: 56px;
    margin: 0 auto 16px;
    background: var(--bg-elevated);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
}

.empty-state-text { font-size: 14px; font-weight: 500; }

/* ============================================================
   PAGINATION
   ============================================================ */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 18px;
}

/* ============================================================
   THEME TOGGLE
   ============================================================ */
.theme-toggle {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
}

.theme-toggle:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--text-muted);
}

/* ============================================================
   COLOR PICKER
   ============================================================ */
.color-options { display: flex; gap: 8px; flex-wrap: wrap; }

.color-option {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    transition: all var(--transition);
}

.color-option:hover,
.color-option.active {
    border-color: var(--text-primary);
    transform: scale(1.15);
}

/* ============================================================
   ICON PICKER
   ============================================================ */
.icon-picker {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 6px;
}

.icon-option {
    width: 38px;
    height: 38px;
    border-radius: var(--radius-xs);
    border: 1px solid var(--border);
    background: var(--bg-input);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
}

.icon-option:hover {
    border-color: var(--text-muted);
    color: var(--text-primary);
}

.icon-option.active {
    border-color: var(--accent);
    background: var(--accent-soft);
    color: var(--accent);
}

/* ============================================================
   SCROLLBAR
   ============================================================ */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ============================================================
   SIDEBAR OVERLAY (mobile)
   ============================================================ */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    backdrop-filter: blur(4px);
    z-index: 99;
}

.sidebar-overlay.active {
    display: block;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 900px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open {
        transform: translateX(0);
        box-shadow: var(--shadow-lg);
    }
    .main {
        margin-left: 0;
    }
    .menu-btn {
        display: flex;
    }
}

@media (max-width: 768px) {
    .chart-grid {
        grid-template-columns: 1fr;
    }
    .form-row {
        grid-template-columns: 1fr;
    }
    .topbar {
        padding: 12px 16px;
        gap: 10px;
    }
    .topbar-left {
        width: 100%;
    }
    .topbar-right {
        width: 100%;
    }
    .date-filter {
        width: 100%;
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 6px;
    }
    .date-filter .btn,
    .date-filter .btn-ghost {
        grid-column: span 1;
        justify-content: center;
    }
    .content {
        padding: 16px;
    }
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    .stat-card {
        padding: 16px;
    }
    .stat-card-value {
        font-size: 20px;
    }
    .stat-card-icon {
        width: 30px;
        height: 30px;
    }
    .category-list {
        grid-template-columns: 1fr;
    }
    .category-item {
        padding: 12px 14px;
    }
    .modal {
        max-width: 100%;
        margin: 10px;
        border-radius: 14px;
    }
    .modal-body {
        padding: 18px;
    }
    .icon-picker {
        grid-template-columns: repeat(6, 1fr);
    }
    .icon-option {
        width: 34px;
        height: 34px;
    }
    .table-wrapper {
        font-size: 12px;
    }
    th, td {
        padding: 10px 12px;
    }
    .tabs {
        overflow-x: auto;
        width: 100%;
    }
    .tab {
        padding: 7px 12px;
        font-size: 12px;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
    .date-filter {
        grid-template-columns: 1fr;
    }
    .page-title {
        font-size: 16px;
    }
    .chart-card {
        padding: 16px;
    }
    .chart-card-title {
        font-size: 13px;
    }
    .btn-full-mobile {
        width: 100%;
    }
    .topbar {
        padding: 10px 12px;
    }
    .stat-card-sub {
        font-size: 11px;
    }
}
