/* assets/css/style.css */

@import url('https://fonts.googleapis.com/css2?family=Syne:wght@400;500;600;700;800&family=DM+Sans:wght@300;400;500;600&display=swap');

:root {
    --font-head: 'Syne', sans-serif;
    --font-body: 'DM Sans', sans-serif;

    /* Light theme */
    --bg-primary: #f0f2f5;
    --bg-card: #ffffff;
    --bg-sidebar: #1a1d2e;
    --bg-sidebar-item: rgba(255,255,255,0.07);
    --bg-sidebar-active: rgba(99,179,237,0.18);
    --bg-table-head: #1a1d2e;
    --bg-table-alt: #f8fafc;
    --bg-input: #f8fafc;

    --text-primary: #1a202c;
    --text-secondary: #4a5568;
    --text-muted: #718096;
    --text-sidebar: rgba(255,255,255,0.75);
    --text-sidebar-active: #63b3ed;
    --text-sidebar-head: rgba(255,255,255,0.4);
    --text-table-head: rgba(255,255,255,0.9);

    --border: #e2e8f0;
    --border-input: #cbd5e0;

    --accent-blue: #3b82f6;
    --accent-green: #10b981;
    --accent-red: #ef4444;
    --accent-orange: #f59e0b;
    --accent-purple: #8b5cf6;
    --accent-teal: #14b8a6;

    --income-color: #10b981;
    --expense-color: #ef4444;

    --shadow-sm: 0 1px 3px rgba(0,0,0,0.07), 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.05);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.1), 0 4px 6px rgba(0,0,0,0.05);
    --shadow-xl: 0 20px 40px rgba(0,0,0,0.12);

    --radius: 10px;
    --radius-sm: 6px;
    --radius-lg: 16px;
    --transition: 0.2s ease;

    --sidebar-width: 240px;
}

[data-theme="dark"] {
    --bg-primary: #0f1117;
    --bg-card: #1a1d2e;
    --bg-sidebar: #0a0c14;
    --bg-sidebar-item: rgba(255,255,255,0.05);
    --bg-sidebar-active: rgba(99,179,237,0.15);
    --bg-table-head: #0f1117;
    --bg-table-alt: #1f2236;
    --bg-input: #252840;

    --text-primary: #e2e8f0;
    --text-secondary: #a0aec0;
    --text-muted: #718096;

    --border: #2d3748;
    --border-input: #4a5568;
}

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

body {
    font-family: var(--font-body);
    background: var(--bg-primary);
    color: var(--text-primary);
    transition: background var(--transition), color var(--transition);
    min-height: 100vh;
    font-size: 14px;
}

/* ---- LAYOUT ---- */
.app-wrapper { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    position: fixed;
    top: 0; left: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 100;
    transition: transform var(--transition);
    display: flex;
    flex-direction: column;
}

.sidebar-logo {
    padding: 24px 20px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.07);
}
.sidebar-logo h1 {
    font-family: var(--font-head);
    font-size: 15px;
    font-weight: 700;
    color: #fff;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}
.sidebar-logo p {
    font-size: 11px;
    color: var(--text-sidebar-head);
    margin-top: 2px;
}

.nav-section { padding: 12px 12px 4px; }
.nav-section-label {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-sidebar-head);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    padding: 0 8px;
    margin-bottom: 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-sidebar);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    transition: background var(--transition), color var(--transition);
    margin-bottom: 1px;
    cursor: pointer;
    border: none;
    background: transparent;
    width: 100%;
    text-align: left;
}
.nav-item:hover { background: var(--bg-sidebar-item); color: #fff; }
.nav-item.active { background: var(--bg-sidebar-active); color: var(--text-sidebar-active); }
.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; opacity: 0.8; }

.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.topbar {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 0 24px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: var(--shadow-sm);
}

.topbar-left { display: flex; align-items: center; gap: 12px; }
.page-title {
    font-family: var(--font-head);
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
}

.topbar-right { display: flex; align-items: center; gap: 12px; }

.year-selector {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 6px 12px;
}
.year-selector button {
    border: none; background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    padding: 2px 4px;
    border-radius: 4px;
    transition: background var(--transition);
}
.year-selector button:hover { background: var(--border); }
.year-selector span {
    font-family: var(--font-head);
    font-weight: 700;
    font-size: 14px;
    min-width: 40px;
    text-align: center;
}

.content { padding: 24px; flex: 1; }

/* ---- CARDS ---- */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.card-title {
    font-family: var(--font-head);
    font-size: 14px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.card-body { padding: 20px; }

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

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    position: relative;
    overflow: hidden;
}
.stat-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
}
.stat-card.income::before { background: var(--income-color); }
.stat-card.expense::before { background: var(--expense-color); }
.stat-card.balance::before { background: var(--accent-blue); }
.stat-card.saving::before { background: var(--accent-purple); }

.stat-label { font-size: 11px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.07em; margin-bottom: 8px; }
.stat-value { font-family: var(--font-head); font-size: 22px; font-weight: 700; }
.stat-card.income .stat-value { color: var(--income-color); }
.stat-card.expense .stat-value { color: var(--expense-color); }
.stat-card.balance .stat-value { color: var(--accent-blue); }
.stat-card.saving .stat-value { color: var(--accent-purple); }
.stat-sub { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

/* ---- TABLE ---- */
.budget-table-wrapper { overflow-x: auto; }

.budget-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.budget-table thead th {
    background: var(--bg-table-head);
    color: var(--text-table-head);
    padding: 10px 12px;
    text-align: right;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    white-space: nowrap;
}
.budget-table thead th:first-child { text-align: left; min-width: 150px; padding-left: 16px; }

.budget-table tbody tr { border-bottom: 1px solid var(--border); transition: background var(--transition); }
.budget-table tbody tr:hover { background: var(--bg-table-alt); }
.budget-table tbody tr:last-child { border-bottom: none; }

.budget-table td {
    padding: 9px 12px;
    text-align: right;
    color: var(--text-secondary);
    white-space: nowrap;
}
.budget-table td:first-child { text-align: left; padding-left: 0; }

.budget-table tfoot td {
    font-family: var(--font-head);
    font-weight: 700;
    font-size: 13px;
    padding: 12px 12px;
    border-top: 2px solid var(--border);
}

.source-row-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
    color: var(--text-primary);
}
.source-color-dot {
    width: 10px; height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.section-header-row td {
    background: var(--bg-table-head);
    color: var(--text-table-head);
    font-family: var(--font-head);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 8px 12px !important;
}

.amount-cell {
    cursor: pointer;
    transition: background var(--transition);
    border-radius: 4px;
    padding: 4px 8px !important;
}
.amount-cell:hover { background: rgba(59,130,246,0.1); color: var(--accent-blue) !important; }

.cell-with-entries { color: var(--text-primary); font-weight: 500; }
.cell-zero { color: var(--text-muted); }

/* ---- MODAL ---- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s, visibility 0.25s;
    backdrop-filter: blur(4px);
}
.modal-overlay.open { opacity: 1; visibility: visible; }

.modal {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    width: min(600px, 95vw);
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    transform: translateY(20px) scale(0.97);
    transition: transform 0.25s;
    border: 1px solid var(--border);
}
.modal-overlay.open .modal { transform: translateY(0) scale(1); }

.modal-wide { width: min(780px, 95vw); }

.modal-header {
    padding: 20px 24px 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}
.modal-title {
    font-family: var(--font-head);
    font-size: 15px;
    font-weight: 700;
}
.modal-close {
    border: none;
    background: var(--bg-primary);
    color: var(--text-secondary);
    border-radius: 50%;
    width: 32px; height: 32px;
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--transition);
}
.modal-close:hover { background: var(--border); }

.modal-body {
    padding: 20px 24px;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    flex-shrink: 0;
}

/* ---- FORMS ---- */
.form-group { margin-bottom: 16px; }
.form-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 6px;
}
.form-control {
    width: 100%;
    padding: 9px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border-input);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 13px;
    transition: border-color var(--transition), box-shadow var(--transition);
    outline: none;
}
.form-control:focus {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(59,130,246,0.15);
}
.form-control::placeholder { color: var(--text-muted); }

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

/* ---- BUTTONS ---- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-family: var(--font-body);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all var(--transition);
    white-space: nowrap;
    text-decoration: none;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary { background: var(--accent-blue); color: #fff; border-color: var(--accent-blue); }
.btn-primary:hover { background: #2563eb; }

.btn-success { background: var(--income-color); color: #fff; border-color: var(--income-color); }
.btn-success:hover { background: #059669; }

.btn-danger { background: var(--expense-color); color: #fff; border-color: var(--expense-color); }
.btn-danger:hover { background: #dc2626; }

.btn-secondary { background: var(--bg-primary); color: var(--text-secondary); border-color: var(--border); }
.btn-secondary:hover { background: var(--border); }

.btn-outline { background: transparent; color: var(--accent-blue); border-color: var(--accent-blue); }
.btn-outline:hover { background: var(--accent-blue); color: #fff; }

.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-icon { padding: 6px; border-radius: 6px; }

/* ---- BADGE ---- */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
}
.badge-income { background: rgba(16,185,129,0.12); color: var(--income-color); }
.badge-expense { background: rgba(239,68,68,0.12); color: var(--expense-color); }
.badge-cc { background: rgba(139,92,246,0.12); color: var(--accent-purple); }

/* ---- ENTRY LIST ---- */
.entry-list { display: flex; flex-direction: column; gap: 8px; }

.entry-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
    background: var(--bg-primary);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    transition: border-color var(--transition);
}
.entry-item:hover { border-color: var(--accent-blue); }

.entry-item-left { flex: 1; min-width: 0; }
.entry-item-amount {
    font-family: var(--font-head);
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
}
.entry-item-desc { font-size: 12px; color: var(--text-muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.entry-item-cat { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; color: var(--text-muted); margin-top: 3px; }
.entry-item-cat-dot { width: 8px; height: 8px; border-radius: 50%; }
.entry-item-actions { display: flex; gap: 4px; flex-shrink: 0; }

.entry-edit-form {
    padding: 14px;
    background: var(--bg-primary);
    border: 2px solid var(--accent-blue);
    border-radius: var(--radius);
    margin-top: 4px;
}

/* ---- TOGGLE ---- */
.toggle-group {
    display: flex;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
}
.toggle-btn {
    flex: 1;
    padding: 8px;
    border: none;
    background: var(--bg-input);
    color: var(--text-secondary);
    font-family: var(--font-body);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
}
.toggle-btn.active { background: var(--accent-blue); color: #fff; }

/* ---- CREDIT CARD ---- */
.cc-section {
    margin-top: 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}
.cc-section-header {
    padding: 12px 16px;
    background: rgba(139,92,246,0.08);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 13px;
    font-weight: 600;
    color: var(--accent-purple);
}
.cc-items { padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.cc-item {
    padding: 10px 12px;
    background: var(--bg-primary);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    font-size: 13px;
}
.cc-unassigned {
    padding: 8px 12px;
    background: rgba(245,158,11,0.08);
    border: 1px dashed var(--accent-orange);
    border-radius: var(--radius-sm);
    font-size: 12px;
    color: var(--accent-orange);
    text-align: center;
}

/* ---- PROGRESS ---- */
.progress { height: 6px; background: var(--bg-primary); border-radius: 3px; overflow: hidden; }
.progress-bar { height: 100%; border-radius: 3px; transition: width 0.5s ease; }

/* ---- DRAG HANDLE ---- */
.drag-handle {
    cursor: grab;
    color: var(--text-muted);
    padding: 2px;
}
.drag-handle:active { cursor: grabbing; }

/* ---- TABS ---- */
.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--border); margin-bottom: 20px; }
.tab-btn {
    padding: 10px 16px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-family: var(--font-body);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all var(--transition);
}
.tab-btn:hover { color: var(--text-primary); }
.tab-btn.active { color: var(--accent-blue); border-bottom-color: var(--accent-blue); }
.tab-pane { display: none; }
.tab-pane.active { display: block; }

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

/* ---- SAVINGS ---- */
.savings-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.saving-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    position: relative;
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s;
}
.saving-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.saving-card-name { font-family: var(--font-head); font-size: 16px; font-weight: 700; }
.saving-card-qty { font-size: 24px; font-weight: 700; color: var(--accent-purple); margin: 8px 0; }
.saving-card-unit { font-size: 12px; color: var(--text-muted); }
.saving-card-tl { font-size: 13px; font-weight: 600; color: var(--income-color); margin-top: 8px; }
.saving-card-updated { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

/* ---- LOG TABLE ---- */
.log-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.log-table th { text-align: left; padding: 10px 12px; border-bottom: 2px solid var(--border); font-size: 11px; font-weight: 700; text-transform: uppercase; color: var(--text-muted); letter-spacing: 0.06em; }
.log-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); color: var(--text-secondary); }
.log-table tr:hover td { background: var(--bg-table-alt); }

.log-action { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.log-create { background: rgba(16,185,129,0.12); color: var(--income-color); }
.log-update { background: rgba(59,130,246,0.12); color: var(--accent-blue); }
.log-delete { background: rgba(239,68,68,0.12); color: var(--expense-color); }
.log-setting { background: rgba(139,92,246,0.12); color: var(--accent-purple); }

/* ---- ALERTS ---- */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
}
.alert-success { background: rgba(16,185,129,0.1); color: #065f46; border: 1px solid rgba(16,185,129,0.3); }
.alert-error { background: rgba(239,68,68,0.1); color: #991b1b; border: 1px solid rgba(239,68,68,0.3); }
[data-theme="dark"] .alert-success { color: #6ee7b7; }
[data-theme="dark"] .alert-error { color: #fca5a5; }

/* ---- TOAST ---- */
.toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; }
.toast {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 16px;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 280px;
    animation: toastIn 0.3s ease;
    font-size: 13px;
}
.toast.removing { animation: toastOut 0.3s ease forwards; }
.toast-icon { font-size: 16px; flex-shrink: 0; }
.toast-success .toast-icon { color: var(--income-color); }
.toast-error .toast-icon { color: var(--expense-color); }

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

/* ---- DRAG SORT ---- */
.sortable-ghost { opacity: 0.4; background: rgba(59,130,246,0.1); }
.sortable-chosen { box-shadow: var(--shadow-md); }

/* ---- MISC ---- */
.separator { border: none; border-top: 1px solid var(--border); margin: 16px 0; }
.text-income { color: var(--income-color); }
.text-expense { color: var(--expense-color); }
.text-muted { color: var(--text-muted); }
.text-right { text-align: right; }
.flex { display: flex; }
.flex-1 { flex: 1; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mb-3 { margin-bottom: 12px; }
.fw-bold { font-weight: 700; }
.font-mono { font-family: monospace; }

/* ---- SIDEBAR TOGGLE ---- */
.sidebar-toggle {
    display: none;
    border: none;
    background: transparent;
    color: var(--text-primary);
    cursor: pointer;
    padding: 4px;
}

/* ---- RESPONSIVE ---- */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .sidebar-toggle { display: flex; }
    .form-row { grid-template-columns: 1fr; }
    .form-row-3 { grid-template-columns: 1fr 1fr; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .content { padding: 16px; }
    .savings-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
    .savings-grid { grid-template-columns: 1fr; }
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 99;
}
.sidebar-overlay.show { display: block; }

/* Add source form inline */
.add-source-form {
    padding: 12px;
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    margin-top: 8px;
}

select.form-control { cursor: pointer; }

.color-preview { width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--border); }
input[type="color"] { width: 40px; height: 32px; padding: 2px; border-radius: var(--radius-sm); cursor: pointer; }

.empty-state {
    text-align: center;
    padding: 32px;
    color: var(--text-muted);
    font-size: 13px;
}
.empty-state svg { opacity: 0.3; margin-bottom: 8px; }

.recurring-badge {
    font-size: 10px;
    background: rgba(59,130,246,0.1);
    color: var(--accent-blue);
    padding: 2px 6px;
    border-radius: 20px;
    font-weight: 600;
}

/* ==================== BUDGET TABLE (yeni tasarım) ==================== */
.bt-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.bt-section-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 20px;
    font-family: var(--font-head);
    font-size: 13px;
    font-weight: 700;
    letter-spacing: .07em;
    text-transform: uppercase;
    border-bottom: 1px solid rgba(255,255,255,0.07);
}

.bt-cash   { background: #1c1f30; color: #f59e0b; }
.bt-income { background: #0f2318; color: var(--income-color); }
.bt-expense{ background: #1f100f; color: var(--expense-color); }

[data-theme="light"] .bt-cash    { background: #fef9ec; color: #92400e; border-bottom:1px solid #fde68a; }
[data-theme="light"] .bt-income  { background: #ecfdf5; color: #065f46; border-bottom:1px solid #a7f3d0; }
[data-theme="light"] .bt-expense { background: #fef2f2; color: #991b1b; border-bottom:1px solid #fecaca; }

.bt-section-icon { font-size: 16px; }

.bt-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12.5px;
}

.bt-th-label, .bt-th {
    padding: 9px 10px;
    text-align: right;
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: .07em;
    text-transform: uppercase;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    background: var(--bg-card);
}
.bt-th-label {
    text-align: left;
    padding-left: 16px;
    min-width: 180px;
    position: sticky;
    left: 0;
    z-index: 2;
    background: var(--bg-card);
}

.bt-row { border-bottom: 1px solid var(--border); transition: background .15s; }
.bt-row:last-child { border-bottom: none; }
.bt-row:hover { background: var(--bg-table-alt); }
.bt-row:hover .bt-th-label,
.bt-row:hover .bt-td-label { background: var(--bg-table-alt); }

.bt-td-label {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 10px 10px 10px 12px;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    position: sticky;
    left: 0;
    background: var(--bg-card);
    z-index: 1;
    min-width: 180px;
    transition: background .15s;
}

.bt-dot {
    width: 9px; height: 9px;
    border-radius: 50%;
    flex-shrink: 0;
}

.bt-drag-handle {
    color: var(--text-muted);
    cursor: grab;
    font-size: 14px;
    opacity: .4;
    flex-shrink: 0;
}

.bt-source-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }

.bt-row-actions {
    display: flex;
    gap: 3px;
    flex-shrink: 0;
    visibility: hidden;
}
.bt-row:hover .bt-row-actions { visibility: visible; }

.bt-action-btn {
    border: none;
    background: var(--border);
    color: var(--text-secondary);
    border-radius: 4px;
    width: 22px; height: 22px;
    cursor: pointer;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .15s, color .15s;
    padding: 0;
}
.bt-action-btn:hover { background: var(--accent-blue); color: #fff; }
.bt-action-del:hover { background: var(--expense-color); color: #fff; }

.bt-td {
    padding: 10px 10px;
    text-align: right;
    color: var(--text-secondary);
    white-space: nowrap;
    border-left: 1px solid var(--border);
    position: relative;
}

.bt-amount-cell {
    cursor: pointer;
    transition: background .15s;
}
.bt-amount-cell:hover { background: rgba(59,130,246,.1); }

.bt-cell-val { font-size: 12.5px; }
.bt-has-val .bt-cell-val { color: var(--text-primary); font-weight: 500; }

.bt-cell-dot {
    display: inline-block;
    width: 5px; height: 5px;
    border-radius: 50%;
    background: var(--accent-blue);
    margin-left: 4px;
    vertical-align: middle;
    opacity: .7;
}

.bt-total-cell {
    font-family: var(--font-head);
    font-weight: 700;
    font-size: 13px;
    border-left: 2px solid var(--border);
}

.bt-footer-row {
    background: var(--bg-table-alt);
    border-top: 2px solid var(--border);
}
.bt-footer-row .bt-td-label {
    background: var(--bg-table-alt);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .05em;
    color: var(--text-primary);
}
.bt-footer-cell {
    font-weight: 700;
    font-family: var(--font-head);
    font-size: 12.5px;
}
.bt-grand-total {
    font-size: 13px;
    border-left: 2px solid var(--border);
}

.bt-row-cash .bt-td-label { font-weight: 600; }

/* ==================== SAVINGS HISTORY ==================== */
.sh-table { width: 100%; border-collapse: collapse; font-size: 12.5px; margin-top: 0; }
.sh-table th { padding: 8px 12px; text-align: right; font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); border-bottom: 1px solid var(--border); }
.sh-table th:first-child { text-align: left; }
.sh-table td { padding: 9px 12px; border-bottom: 1px solid var(--border); color: var(--text-secondary); text-align: right; }
.sh-table td:first-child { text-align: left; font-size: 11px; color: var(--text-muted); }
.sh-table tr:last-child td { border-bottom: none; }
.sh-table tr:hover td { background: var(--bg-table-alt); }

/* ---- Drag & Drop ---- */
.bt-row[draggable="true"] { cursor: default; }
.bt-row[draggable="true"] .bt-drag-handle { cursor: grab; }
.bt-dragging { opacity: 0.4; background: rgba(59,130,246,0.08) !important; }
.bt-drag-over { background: rgba(59,130,246,0.12) !important; border-top: 2px solid var(--accent-blue) !important; }
.bt-drag-over td { background: transparent !important; }

/* ==================== STICKY TABLE HEADERS ==================== */
.budget-table-wrapper {
    overflow: auto;
/*    max-height: calc(100vh - 220px);*/
    position: relative;
}
.bt-table thead th {
    position: sticky;
    top: 0;
    z-index: 3;
    background: var(--bg-card);
    box-shadow: 0 1px 0 var(--border);
}
.bt-table thead .bt-th-label {
    z-index: 4;
    left: 0;
}

/* ==================== PAID STATUS ==================== */
.bt-paid-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 14px; height: 14px;
    border-radius: 50%;
    font-size: 9px; font-weight: 700;
    margin-left: 3px; vertical-align: middle;
}
.bt-paid-income { background: rgba(16,185,129,0.25); color: #065f46; }
.bt-paid-expense { background: rgba(239,68,68,0.25); color: #991b1b; }
[data-theme="dark"] .bt-paid-income { color: #6ee7b7; }
[data-theme="dark"] .bt-paid-expense { color: #fca5a5; }

.paid-badge {
    font-size: 10px; font-weight: 600;
    padding: 2px 7px; border-radius: 20px;
}
.paid-badge-income { background: rgba(16,185,129,0.15); color: var(--income-color); }
.paid-badge-expense { background: rgba(239,68,68,0.15); color: var(--expense-color); }
.unpaid-badge {
    font-size: 10px; font-weight: 600;
    padding: 2px 7px; border-radius: 20px;
    background: var(--bg-primary); color: var(--text-muted);
    border: 1px solid var(--border);
}
.entry-paid-income { background: rgba(16,185,129,0.06) !important; border-color: rgba(16,185,129,0.25) !important; }
.entry-paid-expense { background: rgba(239,68,68,0.06) !important; border-color: rgba(239,68,68,0.25) !important; }

/* ==================== CATEGORY ANALYSIS ==================== */
.ca-section { margin-top: 20px; }
.ca-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 768px) { .ca-grid { grid-template-columns: 1fr; } }
.ca-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow-sm); }
.ca-card-header { padding: 14px 20px; border-bottom: 1px solid var(--border); }
.ca-card-title { font-family: var(--font-head); font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.ca-card-body { padding: 16px 20px; }
.ca-item { margin-bottom: 14px; cursor: pointer; transition: background .15s; padding: 8px 10px; border-radius: var(--radius-sm); margin-left: -10px; margin-right: -10px; }
.ca-item:hover { background: var(--bg-table-alt); }
.ca-item-header { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.ca-item-left { display: flex; align-items: center; gap: 8px; min-width: 0; flex: 1; }
.ca-item-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.ca-item-name { font-size: 13px; font-weight: 500; color: var(--text-primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ca-item-right { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.ca-item-amount { font-family: var(--font-head); font-size: 13px; font-weight: 700; }
.ca-item-pct { font-size: 11px; font-weight: 600; color: var(--text-muted); background: var(--bg-primary); padding: 2px 6px; border-radius: 4px; min-width: 42px; text-align: center; }
.ca-item-bar { height: 4px; background: var(--bg-primary); border-radius: 2px; overflow: hidden; }
.ca-item-bar-fill { height: 100%; border-radius: 2px; transition: width 0.5s ease; }
.ca-item-chevron { font-size: 10px; color: var(--text-muted); transition: transform .2s; flex-shrink: 0; }
.ca-item.expanded .ca-item-chevron { transform: rotate(90deg); }
.ca-detail { display: none; margin-top: 8px; padding: 10px 12px; background: var(--bg-primary); border-radius: var(--radius-sm); border: 1px solid var(--border); }
.ca-item.expanded .ca-detail { display: block; }
.ca-detail-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 5px 0; font-size: 12px; color: var(--text-secondary); border-bottom: 1px solid var(--border); }
.ca-detail-row:last-child { border-bottom: none; }
.ca-detail-source { font-weight: 500; color: var(--text-primary); }
.ca-detail-month { color: var(--text-muted); font-size: 11px; }
.ca-detail-amount { font-weight: 600; }
.ca-detail-desc { font-size: 11px; color: var(--text-muted); font-style: italic; }

/* ==================== QUICK EDIT ==================== */
.qe-container {}
.qe-info { display: flex; align-items: center; gap: 8px; padding: 10px 14px; background: rgba(59,130,246,0.06); border: 1px solid rgba(59,130,246,0.15); border-radius: 8px; margin-bottom: 16px; font-size: 12px; color: var(--text-secondary); }
.qe-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.qe-table thead th { padding: 10px 8px; text-align: left; font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); border-bottom: 2px solid var(--border); background: var(--bg-table-head); }
.qe-row td { padding: 6px 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.qe-row:hover td { background: var(--bg-table-alt); }
.qe-month-label { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 13px; }
.qe-month-name { min-width: 60px; }
.qe-multi-badge { font-size: 10px; font-weight: 500; background: rgba(139,92,246,0.12); color: var(--accent-purple); padding: 2px 6px; border-radius: 4px; }
.form-control-sm { padding: 6px 8px !important; font-size: 12.5px !important; height: 32px; }
select.form-control-sm { height: 32px; }
.qe-saved-badge { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; border-radius: 50%; background: rgba(16,185,129,0.12); color: var(--income-color); font-size: 12px; font-weight: 700; }
.qe-deleted-badge { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; border-radius: 50%; background: rgba(239,68,68,0.12); color: var(--expense-color); font-size: 12px; font-weight: 700; }
.qe-status { text-align: center; }
.qe-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border); }

/* ==================== DASHBOARD VIEW TOGGLE ==================== */
.dash-view-toggle { display: flex; align-items: center; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.toggle-group { display: flex; border: 1px solid var(--border); border-radius: var(--radius-md); overflow: hidden; }
.toggle-btn { padding: 6px 16px; font-size: 12px; font-weight: 600; background: var(--bg-card); border: none; cursor: pointer; color: var(--text-secondary); transition: all .15s; }
.toggle-btn:not(:last-child) { border-right: 1px solid var(--border); }
.toggle-btn.active { background: var(--accent-blue); color: #fff; }
.toggle-btn:hover:not(.active) { background: var(--bg-table-alt); }

/* ==================== DASHBOARD SAVINGS CARDS ==================== */
.dash-savings-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }
.dash-saving-item { padding: 12px; background: var(--bg-primary); border: 1px solid var(--border); border-radius: var(--radius-md); }
.dash-saving-name { font-size: 12px; font-weight: 600; color: var(--text-secondary); margin-bottom: 4px; }
.dash-saving-val { font-size: 18px; font-weight: 700; color: var(--accent-purple); }
.dash-saving-target { margin-top: 8px; }
.progress { height: 4px; background: var(--bg-table-alt); border-radius: 2px; overflow: hidden; }
.progress-bar { height: 100%; border-radius: 2px; transition: width 0.5s ease; }

/* ==================== STAT CARD DRAG ==================== */
.stat-card[draggable] { cursor: grab; }
.stat-card[draggable]:active { cursor: grabbing; }
.stat-card .stat-sub { font-size: 10px; color: var(--text-muted); margin-top: 2px; }

/* ==================== BTN VARIANTS ==================== */
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text-primary); }
.btn-outline:hover { background: var(--bg-table-alt); }
.btn-success { background: var(--income-color); color: #fff; border: 1px solid transparent; }
.btn-success:hover { opacity: 0.85; }

/* ==================== AI SPINNER ==================== */
.ai-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--border);
    border-top-color: var(--accent-purple);
    border-radius: 50%;
    animation: ai-spin 0.8s linear infinite;
    margin: 0 auto;
}
@keyframes ai-spin { to { transform: rotate(360deg); } }
