:root {
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --secondary: #64748b;
    --accent: #f43f5e;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --background: #f8fafc;
    --surface: #ffffff;
    --text: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --radius: 12px;
    --radius-lg: 24px;
    --radius-xl: 32px;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -1px rgb(0 0 0 / 0.06);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
    --sidebar-width: 280px;
    --glass-bg: rgba(255, 255, 255, 0.7);
    --glass-border: rgba(255, 255, 255, 0.5);
    /* Claymorphism Tokens */
    --clay-bg: #ffffff;
    --clay-shadow-outer: 8px 8px 16px #d1d9e6, -8px -8px 16px #ffffff;
    --clay-shadow-inner: inset 4px 4px 8px #d1d9e6, inset -4px -4px 8px #ffffff;
    --clay-radius: 20px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', -apple-system, sans-serif;
}

body {
    background-color: var(--background);
    color: var(--text);
    line-height: 1.5;
    height: 100vh;
    overflow: hidden;
}

/* Ensure scroll is restored on desktop/tablet even if menu-open persists */
@media (min-width: 769px) {
    body, body.menu-open {
        overflow: hidden !important; /* Keep main layout lock */
    }
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

.glass {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
}

.glass-header {
    background: rgba(255, 255, 255, 0.82);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: var(--radius-lg);
    box-shadow: 0 8px 32px rgba(31, 38, 135, 0.04);
}

.card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 1.75rem;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    font-size: 0.875rem;
}

.form-control,
select.form-control {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    transition: all 0.2s;
    background: var(--surface);
}

.form-control:focus,
select.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    text-decoration: none;
    font-size: 0.875rem;
}

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

.btn-primary:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
}

.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    background: #1e3a8a;
    color: white;
    position: fixed;
    left: 0;
    top: 0;
    padding: 2rem 1rem;
    display: flex;
    flex-direction: column;
    transition: all 0.3s ease;
    z-index: 1000;
    border-right: 1px solid rgba(255, 255, 255, 0.1);
    overflow-y: auto;
}

.main-content {
    margin-left: var(--sidebar-width);
    padding: 2.5rem;
    height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
    min-width: 0;
    transition: margin-left 0.3s ease;
    background: #f1f5f9;
    position: relative;
    box-sizing: border-box;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.5rem;
    font-weight: 800;
    color: white !important;
    margin-bottom: 2.5rem;
    text-decoration: none;
    white-space: nowrap;
}

.logo-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--primary) 0%, #818cf8 100%);
    color: white;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
    flex-shrink: 0;
}

.nav-link {
    display: flex;
    align-items: center;
    padding: 1rem 1.25rem;
    color: rgba(255, 255, 255, 0.8) !important;
    text-decoration: none;
    border-radius: 12px;
    margin-bottom: 0.5rem;
    transition: all 0.3s ease;
    font-weight: 500;
}

.nav-link i {
    margin-right: 1.25rem;
    font-size: 1.2rem;
    width: 24px;
    text-align: center;
}

.nav-link:hover, .nav-link.active {
    background: rgba(255, 255, 255, 0.2);
    color: white !important;
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2.5rem;
    width: 100%;
}

.metric-card {
    background: white;
    padding: 1.5rem;
    border-radius: var(--radius-xl);
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    transition: all 0.3s ease;
}

.metric-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-xl);
    border-color: var(--primary);
}

.metric-card > div:last-of-type {
    flex: 1;
    min-width: 0;
}

.card-title {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.card-amount {
    font-size: clamp(1.25rem, 5vw, 1.75rem);
    font-weight: 900;
    color: var(--text);
    word-break: break-all;
    line-height: 1.2;
}

.stat-card-premium {
    background: white;
    padding: 1.75rem;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    transition: transform 0.2s;
}

.stat-card-premium:hover {
    transform: translateY(-4px);
}

.premium-section {
    background: rgba(255, 255, 255, 0.5);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: 40px;
    padding: 2.5rem;
    margin-bottom: 4rem;
    max-width: 100%;
    overflow-x: auto;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    flex-wrap: wrap;
    gap: 1rem;
}

.premium-performance-card {
    padding: 2rem;
    border-radius: 32px;
    background: white;
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.premium-performance-card.emerald { background: linear-gradient(135deg, #059669 0%, #10b981 100%); color: white; }
.premium-performance-card.sunset { background: linear-gradient(135deg, #f59e0b 0%, #fb923c 100%); color: white; }
.premium-performance-card.indigo { background: linear-gradient(135deg, #4f46e5 0%, #6366f1 100%); color: white; }

.activity-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1.5rem;
    width: 100%;
}

.activity-grid > * {
    min-width: 0;
}

@media (max-width: 1280px) {
    .activity-grid {
        grid-template-columns: 1fr;
    }
}

/* Responsive Table Wrapper */
.table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    width: 100%;
    margin-bottom: 1rem;
}

/* --- Mobile Styles (Moved to bottom for priority) --- */
.mobile-header {
    display: none;
    justify-content: space-between;
    align-items: center;
    background: var(--clay-bg);
    padding: 0.85rem 1.25rem;
    position: fixed;
    top: 1rem;
    left: 1rem;
    right: 1rem;
    z-index: 1300; /* Highest */
    border-radius: var(--clay-radius);
    box-shadow: var(--clay-shadow-outer);
    border: 1px solid rgba(255, 255, 255, 0.8);
}

.mobile-header::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    box-shadow: var(--clay-shadow-inner);
    pointer-events: none;
}

.mobile-menu-toggle {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: white;
    box-shadow: 4px 4px 8px #d1d9e6, -4px -4px 8px #ffffff;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    border: none;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
    z-index: 10;
}

.mobile-menu-toggle span {
    display: block;
    width: 20px;
    height: 2px;
    background: var(--primary);
    border-radius: 2px;
    transition: all 0.3s ease;
    transform-origin: center;
}

.mobile-menu-toggle.active {
    background: var(--danger);
    box-shadow: inset 2px 2px 5px rgba(0,0,0,0.1);
}

.mobile-menu-toggle.active span {
    background: white;
}

.mobile-menu-toggle.active span:nth-child(1) {
    transform: translateY(6px) rotate(45deg);
}

.mobile-menu-toggle.active span:nth-child(2) {
    opacity: 0;
    transform: translateX(-10px);
}

.mobile-menu-toggle.active span:nth-child(3) {
    transform: translateY(-6px) rotate(-45deg);
}

.mobile-logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 800;
    color: var(--text);
    font-size: 1rem;
}

.overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(4px);
    z-index: 1100; /* Below sidebar and header */
    display: none;
    opacity: 0;
    transition: all 0.3s ease;
}

.overlay.active {
    display: block;
    opacity: 1;
}

/* Safety: Force overlay to stay invisible and non-blocking on desktop */
@media (min-width: 769px) {
    .overlay, .overlay.active {
        display: none !important;
        opacity: 0 !important;
        pointer-events: none !important;
        visibility: hidden !important;
    }
}

@media (max-width: 1024px) {
    :root {
        --sidebar-width: 280px; /* Keep full width for tablet/mobile active for better readability */
    }
    .sidebar-brand span, .nav-link span { display: inline-block; } /* Show labels */
    .sidebar { align-items: stretch; }
    .nav-link i { margin-right: 1.25rem; }
}

@media (max-width: 768px) {
    body {
        overflow: auto;
        height: auto;
    }
    .sidebar {
        left: -320px;
        width: 300px;
        z-index: 1400;
        background: #1e3a8a;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
        display: flex !important;
        padding: 2.5rem 1.5rem; /* Better padding for mobile */
    }
    .sidebar.active { 
        left: 0; 
        box-shadow: 10px 0 30px rgba(0,0,0,0.2);
    }
    .sidebar-brand span, .nav-link span { 
        display: inline-block !important; 
        opacity: 1 !important;
        white-space: nowrap;
    }
    .nav-link {
        padding: 1.25rem 1.5rem; /* Larger touch targets */
    }
    .main-content { 
        margin-left: 0; 
        padding: 6.5rem 1rem 2rem 1rem; /* More top padding for floating header */
        height: auto;
        overflow: visible;
    }
    .mobile-header { display: flex !important; }
    
    .premium-section {
        padding: 1.5rem;
        border-radius: 28px;
    }

    .stat-grid {
        grid-template-columns: 1fr;
    }
}
.cash-metric.hidden { filter: blur(8px); user-select: none; pointer-events: none; }

.password-wrapper { position: relative; width: 100%; }
.password-toggle {
    position: absolute;
    right: 1rem; top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    cursor: pointer;
    z-index: 10;
}
.password-toggle:hover {
    color: #475569;
}

/* --- Modern Alert System --- */
@keyframes slideDownFade {
    from { opacity: 0; transform: translateY(-1rem); }
    to { opacity: 1; transform: translateY(0); }
}

.alert {
    padding: 1rem 1.25rem;
    border-radius: 16px;
    margin-bottom: 2rem;
    display: flex;
    align-items: center;
    gap: 0.85rem;
    font-size: 0.9rem;
    font-weight: 600;
    line-height: 1.5;
    animation: slideDownFade 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 4px 12px rgba(0,0,0,0.03);
    border: 1px solid transparent;
}

.alert i {
    font-size: 1.15rem;
    flex-shrink: 0;
}

.alert-success {
    background-color: #ecfdf5;
    color: #065f46;
    border-color: #d1fae5;
}

.alert-danger {
    background-color: #fef2f2;
    color: #991b1b;
    border-color: #fee2e2;
}

.alert-warning {
    background-color: #fffbeb;
    color: #92400e;
    border-color: #fef3c7;
}

.alert-info {
    background-color: #eff6ff;
    color: #1e40af;
    border-color: #dbeafe;
}

.alert a {
    color: inherit;
    text-decoration: underline;
    font-weight: 800;
}
