:root {
    --bg-color: #0a0e1a;
    --bg-surface: #111827;
    --text-main: #f1f5f9;
    --text-muted: #94a3b8;
    --text-dim: #64748b;
    --glass-bg: rgba(17, 24, 39, 0.75);
    --glass-border: rgba(255, 255, 255, 0.08);
    --accent-blue: #3b82f6;
    --accent-purple: #8b5cf6;
    --accent-cyan: #06b6d4;
    --success: #10b981;
    --success-dim: rgba(16, 185, 129, 0.15);
    --danger: #ef4444;
    --danger-dim: rgba(239, 68, 68, 0.15);
    --warning: #f59e0b;
    --warning-dim: rgba(245, 158, 11, 0.15);
    --info: #3b82f6;
    --info-dim: rgba(59, 130, 246, 0.15);
    --radius: 16px;
    --radius-sm: 10px;
}

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

body {
    font-family: 'Inter', -apple-system, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.6;
}

/* Background Blobs */
.background-blobs { position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: -1; overflow: hidden; }
.blob { position: absolute; border-radius: 50%; filter: blur(100px); opacity: 0.35; }
.blob-1 { top: -15%; left: -10%; width: 600px; height: 600px; background: #3b82f6; animation: float 12s infinite alternate ease-in-out; }
.blob-2 { bottom: -15%; right: -10%; width: 500px; height: 500px; background: #8b5cf6; animation: float 10s infinite alternate-reverse ease-in-out; }
.blob-3 { top: 40%; left: 50%; width: 400px; height: 400px; background: #06b6d4; animation: float 14s infinite alternate ease-in-out; opacity: 0.2; }
@keyframes float { 0% { transform: translate(0, 0) scale(1); } 100% { transform: translate(40px, 30px) scale(1.08); } }

/* Layout */
.dashboard-container { max-width: 1400px; margin: 0 auto; padding: 1.5rem; }

/* Header */
header { text-align: center; margin-bottom: 2rem; }
header h1 {
    font-size: 2.8rem; font-weight: 800; margin-bottom: 0.3rem;
    background: linear-gradient(135deg, #60a5fa, #a78bfa, #06b6d4);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
header p { color: var(--text-muted); font-size: 1.1rem; font-weight: 300; }

/* Glass Panels */
.glass-panel {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    padding: 1.5rem;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

/* Controls Bar */
.controls-bar {
    display: flex; align-items: flex-end; gap: 1.5rem; flex-wrap: wrap;
    margin-bottom: 2rem; padding: 1.2rem 1.5rem;
}
.control-group { display: flex; flex-direction: column; gap: 0.3rem; }
.control-group label { font-size: 0.8rem; color: var(--text-muted); font-weight: 500; text-transform: uppercase; letter-spacing: 0.5px; }
select {
    padding: 0.6rem 1rem; border-radius: var(--radius-sm);
    border: 1px solid var(--glass-border); background: rgba(10, 14, 26, 0.9);
    color: var(--text-main); font-size: 0.95rem; font-family: inherit;
    outline: none; cursor: pointer; transition: border-color 0.3s;
    min-width: 160px;
}
select:focus { border-color: var(--accent-blue); }

/* Summary Cards */
.cards-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1.2rem; margin-bottom: 2rem; }
.glass-card {
    background: var(--glass-bg); border: 1px solid var(--glass-border);
    border-radius: var(--radius); padding: 1.5rem;
    backdrop-filter: blur(20px); transition: transform 0.3s, box-shadow 0.3s;
    position: relative; overflow: hidden;
}
.glass-card::before {
    content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
    border-radius: var(--radius) var(--radius) 0 0;
}
.card-salary::before { background: linear-gradient(90deg, #3b82f6, #60a5fa); }
.card-income::before { background: linear-gradient(90deg, #10b981, #34d399); }
.card-expense::before { background: linear-gradient(90deg, #ef4444, #f87171); }
.card-balance::before { background: linear-gradient(90deg, #8b5cf6, #a78bfa); }
.glass-card:hover { transform: translateY(-4px); box-shadow: 0 12px 30px rgba(0,0,0,0.3); }
.card-icon { font-size: 1.5rem; margin-bottom: 0.5rem; }
.glass-card h3 { font-size: 0.85rem; color: var(--text-muted); font-weight: 400; margin-bottom: 0.5rem; }
.glass-card .amount { font-size: 1.6rem; font-weight: 700; }

/* Progress Bar */
.progress-bar { width: 100%; height: 6px; background: rgba(255,255,255,0.1); border-radius: 3px; margin-top: 0.8rem; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 3px; transition: width 0.8s ease, background 0.5s; background: linear-gradient(90deg, #10b981, #34d399); }
.progress-label { font-size: 0.75rem; color: var(--text-muted); margin-top: 0.3rem; }

/* Chart Section */
.chart-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; margin-bottom: 2rem; }
.chart-panel h2, .monthly-panel h2 { font-size: 1.2rem; font-weight: 600; margin-bottom: 1rem; }
.chart-wrapper { position: relative; max-height: 320px; display: flex; justify-content: center; }
.chart-wrapper canvas { max-height: 300px; }
.chart-subtitle { text-align: center; color: var(--text-dim); font-size: 0.85rem; margin-top: 0.8rem; }

/* Monthly Breakdown */
.monthly-list { display: flex; flex-direction: column; gap: 0.6rem; max-height: 380px; overflow-y: auto; padding-right: 0.5rem; }
.monthly-list::-webkit-scrollbar { width: 4px; }
.monthly-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 2px; }
.month-item {
    display: flex; justify-content: space-between; align-items: center;
    padding: 0.8rem 1rem; border-radius: var(--radius-sm);
    background: rgba(255,255,255,0.03); border: 1px solid rgba(255,255,255,0.05);
    transition: background 0.2s; cursor: default;
}
.month-item:hover { background: rgba(255,255,255,0.06); }
.month-item.active { background: rgba(59, 130, 246, 0.1); border-color: rgba(59, 130, 246, 0.3); }
.month-name { font-weight: 500; font-size: 0.9rem; }
.month-detail { display: flex; flex-direction: column; align-items: flex-end; gap: 0.15rem; }
.month-balance { font-weight: 600; font-size: 0.9rem; }
.month-sub { font-size: 0.75rem; color: var(--text-dim); }
.month-badge { font-size: 0.7rem; padding: 0.15rem 0.5rem; border-radius: 999px; font-weight: 600; }
.badge-positive { background: var(--success-dim); color: var(--success); }
.badge-negative { background: var(--danger-dim); color: var(--danger); }

/* Debt Section */
.debt-section { margin-bottom: 2rem; }
.debt-section h2 { font-size: 1.2rem; font-weight: 600; margin-bottom: 1rem; }
.debt-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
.debt-column h3 { font-size: 0.95rem; margin-bottom: 0.8rem; }
.debt-item { display: flex; justify-content: space-between; padding: 0.6rem 0; border-bottom: 1px solid var(--glass-border); }
.debt-person { font-weight: 500; }
.debt-amount { font-weight: 600; }
.debt-empty { color: var(--text-dim); font-size: 0.9rem; padding: 0.5rem 0; }

/* Transactions */
.transactions-section { margin-bottom: 2rem; }
.tx-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; flex-wrap: wrap; gap: 1rem; }
.tx-header h2 { font-size: 1.2rem; font-weight: 600; }
.search-box input {
    padding: 0.5rem 1rem; border-radius: var(--radius-sm);
    border: 1px solid var(--glass-border); background: rgba(10,14,26,0.9);
    color: var(--text-main); font-family: inherit; font-size: 0.9rem; outline: none;
    min-width: 240px; transition: border-color 0.3s;
}
.search-box input:focus { border-color: var(--accent-blue); }
.table-container { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 0.8rem 1rem; text-align: left; border-bottom: 1px solid var(--glass-border); font-size: 0.9rem; }
th { color: var(--text-muted); font-weight: 600; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.5px; }
tr:last-child td { border-bottom: none; }
tbody tr { transition: background 0.2s; }
tbody tr:hover { background: rgba(255,255,255,0.04); }
.tx-count { color: var(--text-dim); font-size: 0.8rem; margin-top: 0.8rem; text-align: right; }

/* Type Badges */
.type-badge { padding: 0.2rem 0.6rem; border-radius: 999px; font-size: 0.78rem; font-weight: 600; white-space: nowrap; }
.type-income { background: var(--success-dim); color: var(--success); }
.type-expense { background: var(--danger-dim); color: var(--danger); }
.type-borrow { background: var(--warning-dim); color: var(--warning); }
.type-lend { background: var(--info-dim); color: var(--info); }
.type-pay_borrow { background: rgba(168, 85, 247, 0.15); color: #a855f7; }
.type-pay_lend { background: rgba(6, 182, 212, 0.15); color: #06b6d4; }
/* Delete Button */
.btn-delete {
    padding: 0.3rem 0.7rem; border-radius: 8px; border: 1px solid rgba(239,68,68,0.3);
    background: rgba(239,68,68,0.1); color: #ef4444; font-size: 0.8rem; font-weight: 600;
    cursor: pointer; transition: all 0.2s; font-family: inherit; white-space: nowrap;
}
.btn-delete:hover { background: rgba(239,68,68,0.25); border-color: rgba(239,68,68,0.5); transform: scale(1.05); }

/* Toast Confirmation Overlay */
.toast-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.6); backdrop-filter: blur(6px);
    display: none; justify-content: center; align-items: center; z-index: 1000;
    animation: fadeIn 0.2s ease;
}
.toast-overlay.active { display: flex; }
.toast-box {
    background: var(--bg-surface); border: 1px solid var(--glass-border);
    border-radius: 20px; padding: 2rem; text-align: center;
    max-width: 400px; width: 90%; box-shadow: 0 20px 60px rgba(0,0,0,0.5);
    animation: slideUp 0.3s ease;
}
.toast-icon { font-size: 3rem; margin-bottom: 0.8rem; }
.toast-title { font-size: 1.3rem; font-weight: 700; margin-bottom: 0.5rem; }
.toast-message { color: var(--text-muted); font-size: 0.95rem; margin-bottom: 1.5rem; line-height: 1.5; }
.toast-actions { display: flex; gap: 0.8rem; justify-content: center; }
.toast-btn {
    padding: 0.6rem 1.5rem; border-radius: 10px; border: none;
    font-size: 0.95rem; font-weight: 600; cursor: pointer; font-family: inherit;
    transition: all 0.2s;
}
.btn-cancel { background: rgba(255,255,255,0.1); color: var(--text-main); }
.btn-cancel:hover { background: rgba(255,255,255,0.2); }
.btn-confirm { background: linear-gradient(135deg, #ef4444, #dc2626); color: white; }
.btn-confirm:hover { transform: scale(1.05); box-shadow: 0 4px 15px rgba(239,68,68,0.4); }

/* Notification Toast */
.notif-toast {
    position: fixed; bottom: 2rem; left: 50%; transform: translateX(-50%) translateY(100px);
    background: var(--bg-surface); border: 1px solid var(--glass-border);
    border-radius: 12px; padding: 0.8rem 1.5rem; font-size: 0.95rem; font-weight: 500;
    box-shadow: 0 10px 30px rgba(0,0,0,0.4); z-index: 1001;
    opacity: 0; transition: all 0.4s ease; pointer-events: none;
}
.notif-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); pointer-events: auto; }
.notif-toast.success { border-color: rgba(16,185,129,0.4); }
.notif-toast.error { border-color: rgba(239,68,68,0.4); }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(20px) scale(0.95); opacity: 0; } to { transform: translateY(0) scale(1); opacity: 1; } }

/* Footer */
footer { text-align: center; color: var(--text-dim); font-size: 0.8rem; padding: 1.5rem 0; }

/* Responsive */
@media (max-width: 1024px) {
    .cards-grid { grid-template-columns: repeat(2, 1fr); }
    .chart-row { grid-template-columns: 1fr; }
    .debt-grid { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
    .dashboard-container { padding: 1rem; }
    header h1 { font-size: 2rem; }
    .glass-panel { padding: 1rem; }
    .toast-box { padding: 1.5rem; }
    .toast-actions { flex-direction: column; }
    .toast-btn { width: 100%; }
}
@media (max-width: 640px) {
    header h1 { font-size: 1.6rem; }
    header p { font-size: 0.95rem; }
    .cards-grid { grid-template-columns: repeat(2, 1fr); gap: 0.8rem; }
    .controls-bar { flex-direction: column; align-items: stretch; gap: 1rem; }
    .control-group { width: 100%; }
    select { min-width: auto; width: 100%; font-size: 1rem; padding: 0.8rem 1rem; }
    .glass-card { padding: 1rem 0.8rem; }
    .card-icon { font-size: 1.2rem; margin-bottom: 0.4rem; }
    .glass-card h3 { font-size: 0.75rem; margin-bottom: 0.3rem; }
    .glass-card .amount { font-size: 1.15rem; }
    .tx-header { flex-direction: column; align-items: flex-start; gap: 0.8rem; }
    .search-box { width: 100%; }
    .search-box input { min-width: auto; width: 100%; padding: 0.8rem 1rem; }
    
    /* Optimize table for small screens */
    th, td { padding: 0.6rem 0.5rem; font-size: 0.85rem; }
    .btn-delete { padding: 0.4rem 0.6rem; font-size: 0.75rem; }
    
    /* Make debt items stack better */
    .debt-item { flex-direction: column; align-items: flex-start; gap: 0.2rem; }
    .debt-amount { align-self: flex-start; }
}
@media (max-width: 480px) {
    /* Super small screens like iPhone SE */
    .type-badge { font-size: 0.7rem; padding: 0.15rem 0.4rem; }
    th, td { font-size: 0.8rem; }
}
