:root {
    --sidebar-width: 260px;
    --sidebar-collapsed: 0px;
    --header-height: 60px;
    --primary: #4F46E5;
    --primary-light: #818CF8;
    --primary-dark: #3730A3;
    --success: #10B981;
    --warning: #F59E0B;
    --danger: #EF4444;
    --info: #3B82F6;
    --bg-main: #F3F4F6;
    --bg-card: #FFFFFF;
    --text-dark: #1F2937;
    --text-muted: #6B7280;
    --border-color: #E5E7EB;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
    --radius: 12px;
    --radius-sm: 8px;
}

* { box-sizing: border-box; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-main);
    color: var(--text-dark);
    margin: 0;
    padding: 0;
    min-height: 100vh;
}

/* LOGIN */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #4F46E5 0%, #7C3AED 100%);
    padding: 20px;
}

.login-card {
    background: white;
    border-radius: 20px;
    padding: 40px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
    text-align: center;
}

.login-logo {
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--primary);
    margin-bottom: 8px;
}

.login-subtitle {
    color: var(--text-muted);
    margin-bottom: 30px;
    font-size: 0.9rem;
}

.pin-display {
    font-size: 2rem;
    letter-spacing: 16px;
    padding: 15px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    margin-bottom: 20px;
    min-height: 65px;
    font-family: 'Courier New', monospace;
    color: var(--text-dark);
    background: var(--bg-main);
}

.pin-keypad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    max-width: 280px;
    margin: 0 auto 20px;
}

.pin-key {
    width: 100%;
    aspect-ratio: 1;
    border: 2px solid var(--border-color);
    border-radius: 50%;
    background: white;
    font-size: 1.4rem;
    font-weight: 600;
    color: var(--text-dark);
    cursor: pointer;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pin-key:hover { background: var(--bg-main); border-color: var(--primary); }
.pin-key:active { transform: scale(0.95); background: var(--primary); color: white; }
.pin-key.action { background: var(--danger); color: white; border-color: var(--danger); font-size: 1rem; }
.pin-key.action:hover { background: #DC2626; }
.pin-key.submit { background: var(--primary); color: white; border-color: var(--primary); }
.pin-key.submit:hover { background: var(--primary-dark); }
.pin-key.empty { border: none; cursor: default; background: transparent; }

/* SIDEBAR */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: linear-gradient(180deg, #1E1B4B 0%, #312E81 100%);
    color: white;
    z-index: 1040;
    transition: transform 0.3s ease;
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-brand {
    padding: 20px 24px;
    font-size: 1.3rem;
    font-weight: 800;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-brand i { font-size: 1.5rem; color: var(--primary-light); }

.sidebar-nav { padding: 12px 0; }

.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 24px;
    color: rgba(255,255,255,0.7);
    text-decoration: none;
    font-size: 0.9rem;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}

.sidebar-nav .nav-link:hover {
    color: white;
    background: rgba(255,255,255,0.08);
}

.sidebar-nav .nav-link.active {
    color: white;
    background: rgba(255,255,255,0.12);
    border-left-color: var(--primary-light);
    font-weight: 600;
}

.sidebar-nav .nav-link i { font-size: 1.15rem; width: 22px; text-align: center; }

.sidebar-section {
    padding: 8px 24px;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: rgba(255,255,255,0.4);
    font-weight: 600;
    margin-top: 12px;
}

/* MAIN CONTENT */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    transition: margin 0.3s ease;
}

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

.topbar-title { font-weight: 700; font-size: 1.1rem; color: var(--text-dark); }

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

.content-area { padding: 20px 28px 80px; max-width: 1400px; }

/* CARDS */
.card-financial {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
    transition: box-shadow 0.2s;
}

.card-financial:hover { box-shadow: var(--shadow-md); }

.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
    position: relative;
    overflow: hidden;
}

.stat-card .stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
}

.stat-card .stat-value {
    font-size: 1.5rem;
    font-weight: 800;
    margin: 8px 0 4px;
    color: var(--text-dark);
}

.stat-card .stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 500;
}

.stat-card::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 100px;
    height: 100px;
    border-radius: 50%;
    opacity: 0.05;
    transform: translate(30px, -30px);
}

.stat-card.income::after { background: var(--success); }
.stat-card.expense::after { background: var(--danger); }
.stat-card.savings::after { background: var(--info); }
.stat-card.available::after { background: var(--warning); }
.stat-card.debt::after { background: #6C757D; }

/* BUTTONS */
.btn-primary-custom {
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    padding: 10px 20px;
    font-weight: 600;
    transition: all 0.2s;
}

.btn-primary-custom:hover { background: var(--primary-dark); color: white; }

.btn-fab {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    border: none;
    box-shadow: 0 4px 14px rgba(79, 70, 229, 0.4);
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s;
    z-index: 1050;
}

.btn-fab:hover { transform: scale(1.1); background: var(--primary-dark); box-shadow: 0 6px 20px rgba(79, 70, 229, 0.5); }

/* TABLES */
.table-custom {
    border-collapse: separate;
    border-spacing: 0;
}

.table-custom thead th {
    background: var(--bg-main);
    border: none;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    font-weight: 600;
    padding: 12px 16px;
}

.table-custom tbody td {
    padding: 12px 16px;
    vertical-align: middle;
    border-top: 1px solid var(--border-color);
    font-size: 0.9rem;
}

.table-custom tbody tr:hover { background: #F9FAFB; }

/* BADGES */
.badge-category {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}

/* PROGRESS */
.progress-custom {
    height: 8px;
    border-radius: 4px;
    background: var(--bg-main);
    overflow: hidden;
}

.progress-custom .bar {
    height: 100%;
    border-radius: 4px;
    transition: width 0.6s ease;
}

/* MODAL */
.modal-custom .modal-content {
    border-radius: var(--radius);
    border: none;
    box-shadow: 0 20px 60px rgba(0,0,0,0.15);
}

.modal-custom .modal-header {
    border-bottom: 1px solid var(--border-color);
    padding: 16px 24px;
}

.modal-custom .modal-body { padding: 24px; }
.modal-custom .modal-footer { border-top: 1px solid var(--border-color); padding: 16px 24px; }

/* FORM */
.form-control-custom {
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    font-size: 0.9rem;
    transition: border-color 0.2s;
}

.form-control-custom:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1); }

/* ALERTS */
.alert-custom {
    border-radius: var(--radius-sm);
    border: none;
    font-weight: 500;
}

/* CHARTS */
.chart-container { position: relative; height: 300px; }

/* CALENDAR */
.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
}

.calendar-day {
    aspect-ratio: 1;
    border-radius: var(--radius-sm);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    cursor: pointer;
    transition: background 0.2s;
    padding: 4px;
    min-height: 60px;
}

.calendar-day:hover { background: var(--bg-main); }
.calendar-day.today { background: var(--primary); color: white; border-radius: 50%; }
.calendar-day.has-events { border: 2px solid var(--primary); }

.calendar-day .day-number { font-weight: 600; }
.calendar-day .day-events { font-size: 0.6rem; display: flex; gap: 2px; margin-top: 2px; }
.calendar-day .day-dot { width: 4px; height: 4px; border-radius: 50%; }

/* MOBILE */
@media (max-width: 992px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.show { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0,0,0,0.5);
        z-index: 1035;
    }
    .sidebar-overlay.show { display: block; }
}

@media (max-width: 576px) {
    .content-area { padding: 14px 14px 70px; }
    .stat-card .stat-value { font-size: 1.2rem; }
    .pin-key { font-size: 1.2rem; }
    .btn-fab { bottom: 20px; right: 20px; width: 50px; height: 50px; }
}

/* SCROLLBAR */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #D1D5DB; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #9CA3AF; }

/* ANIMATIONS */
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.fade-in { animation: fadeIn 0.3s ease; }

/* QUICK EXPENSE MODAL */
.quick-expense-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1060;
    align-items: flex-end;
    justify-content: center;
}

.quick-expense-overlay.show { display: flex; }

.quick-expense-panel {
    background: white;
    border-radius: 20px 20px 0 0;
    padding: 24px;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }

.quick-expense-handle {
    width: 40px;
    height: 4px;
    background: #D1D5DB;
    border-radius: 2px;
    margin: 0 auto 16px;
}
