:root[data-theme="dark"] {
    --bg: #050505;
    --card: rgba(255, 255, 255, 0.03);
    --border: rgba(255, 255, 255, 0.06);
    --primary: #e11d48;
    --text: #ffffff;
    --dim: #a1a1aa;
    --sidebar-w: 260px;
    --modal-bg: rgba(0, 0, 0, 0.85);
    --input-bg: rgba(255, 255, 255, 0.05);
    --option-bg: #1a1a1a;
}

:root[data-theme="light"] {
    --bg: #f8fafc;
    --card: rgba(255, 255, 255, 0.8);
    --border: rgba(0, 0, 0, 0.1);
    --primary: #e11d48;
    --text: #0f172a;
    --dim: #64748b;
    --sidebar-w: 260px;
    --modal-bg: rgba(0, 0, 0, 0.5);
    --input-bg: rgba(0, 0, 0, 0.02);
    --option-bg: #ffffff;
}

* { margin:0; padding:0; box-sizing:border-box; font-family:'Outfit',sans-serif; }
body { background:var(--bg); color:var(--text); display:flex; min-height:100vh; overflow-x:hidden; transition: background 0.3s ease, color 0.3s ease; }
.blob { position:fixed; width:600px; height:600px; background:var(--primary); filter:blur(150px); opacity:0.1; top:-200px; right:-100px; z-index:-1; }
.glass { background:var(--card); border:1px solid var(--border); backdrop-filter:blur(20px); transition: background 0.3s, border 0.3s; }
.sidebar { width:var(--sidebar-w); height:100vh; position:fixed; left:0; top:0; padding:2.5rem 1.5rem; border-right:1px solid var(--border); z-index:100; display:flex; flex-direction:column; background: var(--bg); transition: background 0.3s ease; }
.sidebar-logo { display:flex; align-items:center; gap:0.5rem; margin-bottom:3rem; font-size:1.3rem; font-weight:700; }
.sidebar-logo span span { color:var(--primary); margin-left:2px; }
.sidebar-nav { flex-grow: 1; display: flex; flex-direction: column; gap: 0.5rem; }
.nav-item { background:none; border:none; color:var(--dim); padding:1rem; border-radius:12px; width:100%; text-align:left; cursor:pointer; display:flex; gap:0.8rem; margin-bottom:0.5rem; transition:0.2s; }
.nav-item.active { background:var(--primary); color:white; }
.nav-item:hover:not(.active) { background: var(--border); color: var(--text); }
.sidebar-footer { position: absolute; bottom: 1.5rem; left: 1.5rem; display: flex; flex-direction: column; gap: 0.5rem; }
.theme-toggle-btn { margin-bottom: 15px; }
.status-indicator { display:flex; align-items:center; gap:0.6rem; font-size:0.75rem; color:var(--dim); font-weight:500; }
.dot { width:8px; height:8px; background:#10b981; border-radius:50%; box-shadow:0 0 10px #10b981; animation:pulse 2s infinite; }
@keyframes pulse { 0% { opacity:0.5; transform:scale(0.9); } 50% { opacity:1; transform:scale(1.1); } 100% { opacity:0.5; transform:scale(0.9); } }
.app-content { margin-left:var(--sidebar-w); flex-grow:1; padding:4rem; }
.tab-content { display:none; animation:fadeIn 0.5s ease; }
.tab-content.active { display:block; }
@keyframes fadeIn { from { opacity:0; transform:translateY(5px); } to { opacity:1; transform:translateY(0); } }

/* Utility Classes */
.welcome-text { color: var(--dim); margin-bottom: 2rem; }
.header-actions { display: flex; justify-content: space-between; align-items: center; margin-bottom: 2rem; }
.chart-container { height: 250px; position: relative; width: 100%; }
.sort-icon { width: 14px; display: inline-block; vertical-align: middle; }
.total-label { text-align: right; font-weight: 600; }
.total-value { font-weight: 700; color: var(--primary); }
.mb-2 { margin-bottom: 2rem; }

.stats-grid { display:grid; grid-template-columns:repeat(auto-fit, minmax(280px, 1fr)); gap:1.5rem; }
.stat-card { padding:2rem; border-radius:24px; position:relative; overflow:hidden; }
.stat-label { font-size:0.75rem; color:var(--dim); text-transform:uppercase; margin-bottom:1rem; display:block; }
.stat-value { font-size:1.8rem; font-weight:700; }
.stat-icon-bg { position:absolute; right:-10px; bottom:-10px; width:80px; height:80px; opacity:0.04; transform:rotate(-15deg); }
.overview-widgets { display:grid; grid-template-columns:1.2fr 1fr; gap:2rem; margin-top:2.5rem; }
.widget { padding:2rem; border-radius:28px; }
.upcoming-item { display:flex; align-items:center; gap:1.2rem; padding:1.2rem; border-radius:16px; background:var(--input-bg); margin-bottom:0.8rem; }
.upcoming-amount { font-weight: 600; }
.day-badge { width:45px; height:45px; background:var(--card); border-radius:12px; display:flex; flex-direction:column; align-items:center; justify-content:center; font-weight:700; border: 1px solid var(--border); }
.day-badge span { font-size:0.5rem; color:var(--dim); }

/* Progress Rings CSS */
.progress-rings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 1rem; }
.ring-card { padding: 1.5rem; border-radius: 24px; text-align: center; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.ring-title { font-size: 0.8rem; font-weight: 600; color: var(--dim); margin-bottom: 0.5rem; height: 32px; display: flex; align-items: center; justify-content: center; }
.circular-chart { display: block; margin: 0 auto; max-width: 80px; max-height: 80px; }
.circle-bg { fill: none; stroke: var(--border); stroke-width: 3.8; }
.circle { fill: none; stroke-width: 2.8; stroke-linecap: round; transition: stroke-dasharray 1s ease-out; }
.percentage { fill: var(--text); font-family: 'Outfit', sans-serif; font-size: 0.5em; text-anchor: middle; font-weight: 700; }
.ring-footer { font-size: 0.75rem; margin-top: 0.5rem; color: var(--text); font-weight: 600; }
.ring-footer span { font-size: 0.65rem; color: var(--dim); font-weight: normal; display: block; }

.search-input { width:300px; background:var(--input-bg); border:1px solid var(--border); padding:0.8rem 1.2rem; color:var(--text); border-radius:12px; outline:none; margin: 0; }
.search-input::placeholder { color: var(--dim); }
.table-container { border-radius:24px; overflow-x: auto; }
.table-actions { padding: 1.5rem 1.5rem 0.5rem 1.5rem; display: flex; justify-content: flex-start; }
table { width:100%; border-collapse:collapse; }
th { text-align:left; color:var(--dim); font-size:0.8rem; padding:1.2rem 1.5rem; text-transform:uppercase; cursor: pointer; transition: color 0.2s; user-select: none; }
th.sortable:hover { color: var(--text); }
td { padding:1.2rem 1.5rem; border-bottom:1px solid var(--border); }
.actions-cell { display: flex; gap: 0.5rem; }
.btn-primary { background:var(--primary); color:white; border:none; padding:0.8rem 1.5rem; border-radius:12px; cursor:pointer; font-weight:600; display:flex; align-items:center; gap:0.5rem; transition: transform 0.2s, box-shadow 0.2s; }
.btn-primary:hover { transform:translateY(-2px); box-shadow:0 10px 20px -5px rgba(225,29,72,0.4); }
.btn-secondary { background:var(--input-bg); color:var(--text); border:1px solid var(--border); padding:0.8rem 1.5rem; border-radius:12px; cursor:pointer; }
.btn-icon { background:transparent; border:1px solid var(--border); color:var(--dim); width:36px; height:36px; border-radius:8px; cursor:pointer; display:flex; align-items:center; justify-content:center; transition:0.2s; }
.btn-icon:hover { color:var(--text); background: var(--border); }
.modal { display:none; position:fixed; top:0; left:0; width:100%; height:100%; background:var(--modal-bg); z-index:1000; align-items:center; justify-content:center; backdrop-filter: blur(5px); }
.modal.active { display:flex; }
.modal-content { width:95%; max-width:480px; padding:2.5rem; border-radius:30px; border:1px solid var(--border); }
.modal-title { margin-bottom: 1.5rem; }
.form-group { display: flex; flex-direction: column; gap: 0.5rem; margin-bottom: 1rem; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1rem; }
.modal-footer { display: flex; justify-content: flex-end; gap: 1rem; margin-top: 1.5rem; }
input, select { width:100%; background:var(--input-bg); border:1px solid var(--border); padding:0.9rem; color:var(--text); border-radius:12px; outline:none; margin-top:5px; }
option { background: var(--option-bg); color: var(--text); }
@media (max-width: 850px) {
    .sidebar { 
        height: 70px; 
        padding: 0;
        flex-direction: row;
        top: auto;
        bottom: 0;
        width: 100%;
        border-right: none;
        border-top: 1px solid var(--border);
        align-items: stretch;
        z-index: 9999 !important; 
        pointer-events: auto !important;
    }
    .sidebar-logo, .sidebar-footer { display: none; }
    .sidebar-nav { 
        flex-direction: row; justify-content: space-around;
        height: 100%; 
        width: 100%;
        gap: 0; 
    }
    .nav-item { 
        height: 100%; 
        border-radius: 0; 
        flex: 1; 
        flex-direction: column; 
        justify-content: center; 
        align-items: center;
        gap: 2px;
        padding: 5px 0;
        font-size: 0.65rem;
        text-align: center;
        -webkit-tap-highlight-color: transparent; 
    }
    .nav-item i { width: 18px; height: 18px; margin-bottom: 2px; }
    .nav-item.active { 
        background: transparent; 
        border-top: 3px solid var(--primary); 
        color: var(--primary);
    }
    .app-content { 
        margin-left: 0; padding: 1rem; padding-bottom: 90px; width: 100%; 
        position: relative;
        z-index: 1;
    }
    .overview-widgets, .stats-grid { grid-template-columns: 1fr; }
    
    .header-actions {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
    .header-actions > div {
        width: 100%;
        flex-direction: column;
    }
    .header-actions select, .header-actions button {
        width: 100% !important;
    }
    .btn-secondary {
        width: 100%;
    }

    /* Transform Table into Cards */
    table, thead, tbody, th, td, tr {
        display: block;
    }
    thead tr {
        display: none; /* Hide table headers */
    }
    tr {
        margin-bottom: 1rem;
        border: 1px solid var(--border);
        border-radius: 16px;
        padding: 1rem;
        background: var(--input-bg);
    }
    td {
        border: none;
        padding: 0.5rem 0;
        position: relative;
        text-align: right;
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 1rem;
    }
    td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--dim);
        font-size: 0.8rem;
        text-transform: uppercase;
        text-align: left;
    }
    .actions-cell {
        justify-content: flex-end;
        margin-top: 0.5rem;
        padding-top: 0.5rem;
        border-top: 1px dashed var(--border);
    }
}

/* Row Actions */
.row-actions { display: flex; gap: 0.5rem; justify-content: flex-start; }
.btn-icon-sm { background: transparent; border: 1px solid var(--border); color: var(--dim); width: 30px; height: 30px; border-radius: 8px; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: 0.2s; font-size: 0.85rem; padding: 0; line-height: 1; }
.btn-icon-sm:hover { color: var(--text); background: var(--border); }
.btn-icon-sm.btn-del:hover { color: #fff; background: #ef4444; border-color: #ef4444; }

