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

/* ==========================================================================
   1. DESIGN TOKENS & VARIABLES
   ========================================================================== */
:root {
    --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
    
    /* Premium Color Palette - Vibrant Teal & Slate */
    --primary: #0d9488;
    --primary-hover: #0f766e;
    --primary-light: rgba(13, 148, 136, 0.15);
    
    /* Custom UI settings fallback variables */
    --btn-radius: 8px;
    --table-border: 1px solid var(--border-color);
    --table-striped: transparent;
    
    --success: #10b981;
    --success-hover: #059669;
    --success-light: rgba(16, 185, 129, 0.15);
    
    --warning: #f59e0b;
    --warning-hover: #d97706;
    --warning-light: rgba(245, 158, 11, 0.15);
    
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --danger-light: rgba(239, 68, 68, 0.15);
    
    /* Light Mode Neutrals */
    --bg-body: #f8fafc;
    --bg-surface: #ffffff;
    --border-color: #e2e8f0;
    --text-main: #334155;
    --text-muted: #64748b;
    --text-heading: #0f172a;
    
    /* Dimensions */
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 80px;
    --topbar-height: 70px;
    
    /* Radii & Shadows */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Dark Mode Tokens - Premium Glass Aesthetic */
body.dark-mode {
    --bg-body: #0f172a;
    --bg-surface: #1e293b;
    --border-color: #334155;
    --text-main: #cbd5e1;
    --text-muted: #94a3b8;
    --text-heading: #f8fafc;
    
    /* Subtle adjustments for dark mode */
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
}

/* ==========================================================================
   2. RESET & BASE
   ========================================================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-sans);
    background-color: var(--bg-body);
    color: var(--text-main);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
    transition: background-color var(--transition), color var(--transition);
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: color var(--transition);
}

button {
    font-family: inherit;
}

/* Skip Link (Accessibility) */
.skip-link {
    position: absolute;
    top: -100px;
    left: 20px;
    background-color: var(--primary);
    color: white;
    padding: 10px 20px;
    border-radius: 0 0 8px 8px;
    font-weight: 600;
    z-index: 99999;
    transition: top 0.2s ease;
    box-shadow: var(--shadow-lg);
}

.skip-link:focus {
    top: 0;
    outline: 2px solid var(--primary-hover);
}

/* ==========================================================================
   3. LAYOUT STRUCTURE
   ========================================================================== */
.layout-wrapper {
    display: flex;
    min-height: 100vh;
}

/* --- SIDEBAR --- */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-surface);
    border-right: 1px solid var(--border-color);
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 1000;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    border-bottom: 1px solid var(--border-color);
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text-heading);
    font-weight: 700;
    font-size: 20px;
}

.brand-icon {
    color: var(--primary);
    display: flex;
}

.sidebar-close-btn {
    display: none; /* Only show on mobile */
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
}

.sidebar-user {
    padding: 20px 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--border-color);
    transition: var(--transition);
}

.user-avatar-link {
    display: block;
    flex-shrink: 0;
}

.user-avatar, .sidebar-avatar-img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: var(--primary-light);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
    object-fit: cover;
}

.user-info {
    overflow: hidden;
    transition: opacity var(--transition);
}

.user-name {
    display: block;
    font-weight: 600;
    color: var(--text-heading);
    font-size: 14px;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
}

.user-email {
    display: block;
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 16px 12px;
}

.sidebar-nav ul {
    list-style: none;
}

.nav-section-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin: 16px 0 8px 12px;
    transition: opacity var(--transition);
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    color: var(--text-main);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 4px;
    white-space: nowrap;
    transition: var(--transition);
}

.nav-link i {
    flex-shrink: 0;
}

.nav-link:hover {
    background-color: var(--bg-body);
    color: var(--text-heading);
}

.nav-link.active {
    background-color: var(--primary-light);
    color: var(--primary);
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border-color);
}

.logout-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px;
    background-color: var(--danger-light);
    color: var(--danger);
    border: none;
    border-radius: var(--radius-sm);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.logout-btn:hover {
    background-color: var(--danger);
    color: white;
}

/* --- SIDEBAR COLLAPSED STATE (DESKTOP) --- */
@media (min-width: 1024px) {
    body.sidebar-collapsed .sidebar {
        width: var(--sidebar-collapsed-width);
        overflow-x: hidden;
    }
    
    body.sidebar-collapsed .layout-main {
        margin-left: var(--sidebar-collapsed-width);
    }
    
    body.sidebar-collapsed .brand-name,
    body.sidebar-collapsed .user-info,
    body.sidebar-collapsed .nav-section-label,
    body.sidebar-collapsed .nav-link span,
    body.sidebar-collapsed .logout-btn span {
        display: none;
    }
    
    body.sidebar-collapsed .sidebar-header {
        justify-content: center;
        padding: 0;
    }
    
    body.sidebar-collapsed .brand {
        justify-content: center;
        gap: 0;
    }
    
    body.sidebar-collapsed .sidebar-user {
        justify-content: center;
        padding: 20px 0;
        gap: 0;
    }
    
    body.sidebar-collapsed .nav-link {
        justify-content: center;
        padding: 12px 0;
        gap: 0;
    }
    
    body.sidebar-collapsed .logout-btn {
        justify-content: center;
        padding: 12px 0;
        gap: 0;
        width: 100%;
    }
}

/* --- SIDEBAR MOBILE STATE --- */
@media (max-width: 1023px) {
    .sidebar {
        transform: translateX(-100%);
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .sidebar-close-btn {
        display: block;
    }
}

.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 999;
    opacity: 0;
    pointer-events: none;
    transition: var(--transition);
}

.sidebar-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

/* --- MAIN CONTENT AREA --- */
.layout-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-width: 0; /* Important for flex children truncating */
    margin-left: var(--sidebar-width);
    transition: var(--transition);
}

@media (max-width: 1023px) {
    .layout-main {
        margin-left: 0 !important;
    }
}

/* --- TOPBAR --- */
.topbar {
    height: var(--topbar-height);
    background-color: var(--bg-surface);
    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: 99;
}

.topbar-left, .topbar-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.topbar-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 8px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.topbar-btn:hover {
    background-color: var(--bg-body);
    color: var(--text-heading);
}

.page-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-heading);
    margin: 0;
}

.topbar-date {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-muted);
}

@media (max-width: 767px) {
    .topbar-date {
        display: none;
    }
    .page-title {
        font-size: 16px;
    }
}

/* --- NOTIFICATIONS --- */
.notification-wrapper {
    position: relative;
}

.notification-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 8px;
    height: 8px;
    background-color: var(--danger);
    border-radius: 50%;
}

.notification-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    width: 320px;
    max-height: 400px;
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    margin-top: 10px;
    display: none;
    flex-direction: column;
    overflow: hidden;
    z-index: 1000;
}

.notification-dropdown.show {
    display: flex;
}

.notification-dropdown-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
    font-size: 14px;
}

.notification-dropdown-body {
    overflow-y: auto;
    max-height: 300px;
}

.notification-item {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    gap: 12px;
}

.notification-item:last-child {
    border-bottom: none;
}

.notification-item:hover {
    background-color: var(--bg-body);
}

.notification-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.notification-content {
    flex: 1;
    min-width: 0;
}

.notification-text {
    font-size: 13px;
    color: var(--text-heading);
    margin-bottom: 4px;
    line-height: 1.4;
}

.notification-time {
    font-size: 11px;
    color: var(--text-muted);
}

/* --- MAIN CONTENT CONTAINER --- */
.main-content {
    padding: 24px;
    flex: 1;
}

.app-footer {
    padding: 20px 24px;
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
    border-top: 1px solid var(--border-color);
    background-color: var(--bg-surface);
}

/* ==========================================================================
   4. COMPONENTS
   ========================================================================== */
   
/* Cards */
.card {
    background-color: var(--bg-surface);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-heading);
    margin: 0;
}

.card-body {
    padding: 20px;
    flex: 1;
}

.card-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border-color);
    background-color: rgba(0,0,0,0.02);
}

/* Stat Cards */
.stat-card {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 20px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    box-shadow: var(--shadow-sm);
}

.stat-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
}

.stat-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stat-icon-wrapper {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
}

.stat-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-heading);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 42px;
    padding: 0 20px;
    box-sizing: border-box;
    border-radius: var(--btn-radius, var(--radius-sm));
    font-weight: 500;
    font-size: 14px;
    cursor: pointer;
    transition: var(--transition);
    border: 1px solid transparent;
    line-height: 1;
}

.btn-sm {
    height: 34px;
    padding: 0 12px;
    font-size: 12px;
}
.btn-primary {
    background-color: var(--primary);
    color: white;
}

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

.btn-outline {
    background-color: transparent;
    border-color: var(--border-color);
    color: var(--text-main);
}

.btn-outline:hover {
    background-color: var(--bg-body);
    color: var(--text-heading);
}

.icon-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 6px;
    border-radius: var(--btn-radius, var(--radius-sm));
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.icon-btn:hover {
    background-color: var(--bg-body);
    color: var(--text-heading);
}

/* Forms */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-heading);
    margin-bottom: 6px;
}

.form-control {
    width: 100%;
    height: 42px;
    padding: 0 14px;
    box-sizing: border-box;
    border: 1px solid var(--border-color);
    border-radius: var(--btn-radius, var(--radius-sm));
    background-color: var(--bg-surface);
    color: var(--text-main);
    font-size: 14px;
    font-family: inherit;
    transition: border-color var(--transition);
    display: block;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.form-control-sm {
    height: 34px;
    padding: 0 10px;
    font-size: 13px;
}

.form-control-color {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    width: 100%;
    height: 42px;
    padding: 4px;
    border-radius: var(--btn-radius, var(--radius-sm));
    border: 1px solid var(--border-color);
    background-color: var(--bg-surface);
    cursor: pointer;
    transition: var(--transition);
}

.form-control-color::-webkit-color-swatch-wrapper {
    padding: 0;
}

.form-control-color::-webkit-color-swatch {
    border: none;
    border-radius: 4px;
}

textarea.form-control {
    height: auto;
    min-height: 80px;
    padding: 10px 12px;
    resize: vertical;
}

/* Tables */
.table-responsive {
    overflow-x: auto;
    width: 100%;
}

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

.table th, .table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: var(--table-border, 1px solid var(--border-color));
}

.table th {
    font-weight: 600;
    color: var(--text-muted);
    background-color: var(--table-header-bg, rgba(0,0,0,0.02));
}

.table tbody tr:nth-child(even) {
    background-color: var(--table-striped, transparent);
}

.table tbody tr:hover {
    background-color: rgba(0,0,0,0.01);
}

.table tbody tr:last-child td {
    border-bottom: none;
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 9999px;
    font-size: 12px;
    font-weight: 500;
}

.badge-primary { background-color: var(--primary-light); color: var(--primary); }
.badge-success { background-color: var(--success-light); color: var(--success); }
.badge-warning { background-color: var(--warning-light); color: var(--warning); }
.badge-danger { background-color: var(--danger-light); color: var(--danger); }

/* Alerts */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
}

.alert-success {
    background-color: var(--success-light);
    color: var(--success-hover);
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.alert-error {
    background-color: var(--danger-light);
    color: var(--danger-hover);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.alert-close {
    margin-left: auto;
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    opacity: 0.7;
}

.alert-close:hover {
    opacity: 1;
}

/* Modals */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 1100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    pointer-events: none;
    transition: var(--transition);
}

.modal.open {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    background-color: var(--bg-surface);
    border-radius: var(--radius-md);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
    transform: translateY(20px);
    transition: transform var(--transition);
}

.modal.open .modal-content {
    transform: translateY(0);
}

.modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-heading);
}

.modal-close {
    background: none;
    border: none;
    font-size: 20px;
    color: var(--text-muted);
    cursor: pointer;
}

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

.modal-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* Progress Bar */
.progress-bar-wrapper {
    height: 8px;
    background-color: var(--bg-body);
    border-radius: 9999px;
    overflow: hidden;
    margin: 8px 0;
}

.progress-bar-fill {
    height: 100%;
    background-color: var(--primary);
    border-radius: 9999px;
    transition: width 0.5s ease-in-out;
}

/* Specific Card Layouts (Wallets, Budgets, etc) */
.item-card {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 20px;
    display: flex;
    flex-direction: column;
    height: 100%;
    transition: var(--transition);
}

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

.item-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 16px;
}

.item-card-body {
    flex: 1;
}

.item-card-footer {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    color: var(--text-muted);
}

/* Scroll to top */
.scroll-to-top {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background-color: var(--primary);
    color: white;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--shadow-md);
    opacity: 0;
    pointer-events: none;
    transform: translateY(20px);
    transition: var(--transition);
    z-index: 990;
}

.scroll-to-top.visible {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

/* ==========================================================================
   5. UTILITIES (Tailwind-like classes used in Blade files)
   ========================================================================== */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.flex-1 { flex: 1 1 0%; }

.grid { display: grid; }
.grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.col-span-full { grid-column: 1 / -1; }

.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.items-end { align-items: flex-end; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }

.gap-1 { gap: 0.25rem; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }
.gap-6 { gap: 1.5rem; }

.m-0 { margin: 0; }
.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 0.75rem; }
.mt-4 { margin-top: 1rem; }
.mt-6 { margin-top: 1.5rem; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 0.75rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-6 { margin-bottom: 1.5rem; }
.my-4 { margin-top: 1rem; margin-bottom: 1rem; }
.mx-auto { margin-left: auto; margin-right: auto; }

.p-0 { padding: 0; }
.p-4 { padding: 1rem; }
.p-6 { padding: 1.5rem; }
.p-8 { padding: 2rem; }
.px-4 { padding-left: 1rem; padding-right: 1rem; }
.px-6 { padding-left: 1.5rem; padding-right: 1.5rem; }
.py-2 { padding-top: 0.5rem; padding-bottom: 0.5rem; }
.py-4 { padding-top: 1rem; padding-bottom: 1rem; }
.py-6 { padding-top: 1.5rem; padding-bottom: 1.5rem; }
.py-8 { padding-top: 2rem; padding-bottom: 2rem; }

.w-3 { width: 0.75rem; }
.w-4 { width: 1rem; }
.w-5 { width: 1.25rem; }
.w-6 { width: 1.5rem; }
.w-8 { width: 2rem; }
.w-12 { width: 3rem; }
.w-full { width: 100%; }

.h-3 { height: 0.75rem; }
.h-4 { height: 1rem; }
.h-5 { height: 1.25rem; }
.h-6 { height: 1.5rem; }
.h-8 { height: 2rem; }
.h-12 { height: 3rem; }
.h-full { height: 100%; }

.text-xs { font-size: 0.75rem; }
.text-sm { font-size: 0.875rem; }
.text-base { font-size: 1rem; }
.text-lg { font-size: 1.125rem; }
.text-xl { font-size: 1.25rem; }
.text-2xl { font-size: 1.5rem; }
.text-3xl { font-size: 1.875rem; }

.font-normal { font-weight: 400; }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }
.font-extrabold { font-weight: 800; }

.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.text-primary { color: var(--primary); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-danger { color: var(--danger); }
.text-muted { color: var(--text-muted); }
.text-dark { color: var(--text-heading); }
.text-white { color: #ffffff; }

.bg-primary { background-color: var(--primary); }
.bg-success { background-color: var(--success); }
.bg-warning { background-color: var(--warning); }
.bg-danger { background-color: var(--danger); }
.bg-primary-light { background-color: var(--primary-light); }
.bg-success-light { background-color: var(--success-light); }
.bg-warning-light { background-color: var(--warning-light); }
.bg-danger-light { background-color: var(--danger-light); }
.bg-white { background-color: #ffffff; }
.bg-transparent { background-color: transparent; }

.rounded { border-radius: 0.25rem; }
.rounded-md { border-radius: var(--radius-sm); }
.rounded-lg { border-radius: var(--radius-md); }
.rounded-full { border-radius: 9999px; }

.border { border: 1px solid var(--border-color); }
.border-t { border-top: 1px solid var(--border-color); }
.border-b { border-bottom: 1px solid var(--border-color); }

.shadow-sm { box-shadow: var(--shadow-sm); }
.shadow { box-shadow: var(--shadow-md); }
.shadow-lg { box-shadow: var(--shadow-lg); }

.hidden { display: none; }
.block { display: block; }
.inline-block { display: inline-block; }

.relative { position: relative; }
.absolute { position: absolute; }

.whitespace-nowrap { white-space: nowrap; }
.overflow-hidden { overflow: hidden; }

/* Custom Component Utilities */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.mood-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.item-grid { /* For wallets, budgets, etc */
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 24px;
    margin-bottom: 24px;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 24px;
    margin-bottom: 24px;
    min-width: 0;
}

@media (min-width: 1024px) {
    .dashboard-grid {
        grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
    }
}

.dashboard-main-area,
.dashboard-sidebar-area {
    display: flex;
    flex-direction: column;
    gap: 24px;
    min-width: 0;
}

.filters-layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
    align-items: flex-end;
}

.filters-layout > div {
    width: 100%;
}

.filters-layout .form-group {
    margin-bottom: 0;
}

@media (min-width: 640px) {
    .filters-layout {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 1024px) {
    .filters-layout {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (min-width: 1280px) {
    .filters-layout {
        grid-template-columns: repeat(6, 1fr);
    }
}

.category-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: inline-block;
}

/* Custom Premium Cards & Spacing */
.item-card {
    background-color: var(--bg-surface);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: transform var(--transition), box-shadow var(--transition);
}

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

.item-card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.item-card-body {
    padding: 20px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.item-card-footer {
    padding: 12px 20px;
    border-top: 1px solid var(--border-color);
    background-color: rgba(0, 0, 0, 0.015);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    color: var(--text-muted);
}

body.dark-mode .item-card-footer {
    background-color: rgba(255, 255, 255, 0.02);
}

.wallet-avatar {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

.wallet-name-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-heading);
    margin: 0;
}

.wallet-balance-amount {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-heading);
    margin: 10px 0 6px 0;
}

.wallet-desc-text {
    font-size: 13px;
    color: var(--text-muted);
    margin: 0;
    line-height: 1.4;
    flex: 1;
}

.wallet-card-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 9999px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.budget-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-heading);
    margin: 0;
}

.budget-meta {
    font-size: 12px;
    color: var(--text-muted);
    display: block;
    margin-top: 2px;
}

.budget-note-box {
    font-size: 12px;
    color: var(--text-muted);
    background-color: var(--bg-body);
    padding: 8px 12px;
    border-radius: 4px;
    margin-top: 12px;
    border-left: 3px solid var(--primary);
}

.wishlist-item-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-heading);
    margin: 0;
}

.wishlist-price-amount {
    font-size: 20px;
    font-weight: 700;
    color: var(--primary);
    margin: 8px 0;
}

.wishlist-notes {
    font-size: 13px;
    color: var(--text-muted);
    font-style: italic;
    margin: 8px 0 0 0;
    line-height: 1.4;
}

.activity-date-time {
    font-size: 11px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 4px;
}

.activity-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-heading);
    margin: 0;
}

.activity-mood-badge {
    font-size: 18px;
    padding: 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.activity-content-text {
    font-size: 13px;
    color: var(--text-main);
    line-height: 1.5;
    margin: 0;
    white-space: pre-wrap;
}

.tag-badge {
    font-size: 11px;
    background-color: var(--primary-light);
    color: var(--primary);
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 500;
}

.wallet-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    background-color: var(--bg-body);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    transition: var(--transition);
}

.wallet-item:hover {
    border-color: var(--primary);
}

.wallet-icon-box {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.wallet-item-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-heading);
    margin: 0;
}

.wallet-item-type {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: capitalize;
}

.wallet-item-balance {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-heading);
}

.progress-bar-wrapper {
    width: 100%;
    height: 8px;
    background-color: var(--border-color);
    border-radius: 9999px;
    overflow: hidden;
    margin: 8px 0;
}

.progress-bar-fill {
    height: 100%;
    border-radius: 9999px;
    transition: width 0.5s ease-out;
}

.header-action-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.section-subtitle {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 4px;
    margin-top: 0;
}

.checkbox-group {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
}

.form-checkbox {
    width: 16px;
    height: 16px;
    border-radius: 4px;
    border: 1px solid var(--border-color);
    background-color: var(--bg-surface);
    cursor: pointer;
    accent-color: var(--primary);
}

.checkbox-label {
    font-size: 14px;
    color: var(--text-main);
    cursor: pointer;
    user-select: none;
}

.mood-selector {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 8px;
}

.mood-option {
    flex: 1;
    min-width: 70px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 10px;
    background-color: var(--bg-body);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    position: relative;
}

.mood-option input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.mood-option:hover {
    border-color: var(--primary);
    background-color: var(--primary-light);
}

.mood-option input[type="radio"]:checked + .mood-emoji + .mood-text,
.mood-option input[type="radio"]:checked ~ .mood-emoji,
.mood-option input[type="radio"]:checked ~ .mood-text {
    color: var(--primary);
}

.mood-option:has(input[type="radio"]:checked) {
    border-color: var(--primary);
    background-color: var(--primary-light);
    box-shadow: 0 0 0 2px var(--primary-light);
}

.mood-emoji {
    font-size: 24px;
    margin-bottom: 4px;
}

.mood-text {
    font-size: 11px;
    font-weight: 500;
    color: var(--text-muted);
}

.pagination-footer {
    display: flex;
    justify-content: center;
    align-items: center;
    border-top: 1px solid var(--border-color);
    padding: 16px 24px;
}
.pagination-footer nav {
    width: 100%;
}

.profile-avatar-container {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--primary-light);
    border: 2px solid var(--border-color);
}

.profile-avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Auth Pages */
.auth-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
    background: linear-gradient(135deg, var(--bg-body) 0%, var(--primary-light) 100%);
}

.auth-card {
    width: 100%;
    max-width: 400px;
    background-color: var(--bg-surface);
    padding: 40px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
}

.auth-brand {
    text-align: center;
    margin-bottom: 30px;
}

.auth-brand-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 64px;
    height: 64px;
    border-radius: 16px;
    background-color: var(--primary-light);
    color: var(--primary);
    margin-bottom: 16px;
}

.auth-brand-name {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-heading);
    margin: 0 0 4px 0;
}

.auth-brand-tagline {
    font-size: 14px;
    color: var(--text-muted);
    margin: 0;
}

.input-icon-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.input-icon-wrapper .input-icon {
    position: absolute;
    left: 12px;
    color: var(--text-muted);
    width: 18px;
    height: 18px;
    pointer-events: none;
}

.input-icon-wrapper .form-control {
    padding-left: 40px;
}

.form-label-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.invalid-feedback {
    display: block;
    margin-top: 6px;
    font-size: 12px;
    color: var(--danger);
}

.is-invalid {
    border-color: var(--danger) !important;
}

.is-invalid:focus {
    box-shadow: 0 0 0 3px var(--danger-light) !important;
}

.btn-block {
    display: flex;
    width: 100%;
    justify-content: center;
}

.auth-divider {
    text-align: center;
    margin: 24px 0;
    position: relative;
}

.auth-divider::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
    background-color: var(--border-color);
    z-index: 1;
}

.auth-divider span {
    position: relative;
    z-index: 2;
    background-color: var(--bg-surface);
    padding: 0 12px;
    color: var(--text-muted);
    font-size: 13px;
}

.auth-footer-note {
    text-align: center;
    margin-top: 24px;
    color: var(--text-muted);
    font-size: 12px;
}

/* Ensure SweetAlert2 is always on top of all modals */
.swal2-container {
    z-index: 999999 !important;
}

/* Chart containers */
.chart-container {
    position: relative;
    width: 100%;
    min-width: 0;
}
.chart-container canvas {
    display: block;
    width: 100% !important;
    height: 100% !important;
}
.chart-container-cashflow {
    height: 280px;
}
.chart-container-category {
    height: 240px;
}

/* Responsive Overrides for Mobile & Tablet Dashboard Layouts */
@media (max-width: 767px) {
    .main-content {
        padding: 16px 12px;
    }
    .card-body {
        padding: 16px 12px;
        min-width: 0;
        overflow: hidden;
    }
    .card {
        min-width: 0;
        overflow: hidden;
    }
    .dashboard-grid {
        gap: 16px;
        min-width: 0;
        overflow: hidden;
    }
    .dashboard-main-area {
        min-width: 0;
        overflow: hidden;
    }
    .stat-card {
        padding: 16px;
    }
    .stat-value {
        font-size: 20px;
    }
    /* Make sure grid gap is a bit tighter on mobile */
    .stats-grid {
        gap: 12px;
        margin-bottom: 16px;
    }
    .chart-container-cashflow {
        height: 200px;
    }
    .chart-container-category {
        height: 200px;
    }
}

@media (max-width: 480px) {
    .stat-value {
        font-size: 18px;
    }
    .card-title {
        font-size: 14px;
    }
    .chart-container-cashflow {
        height: 180px;
    }
    .chart-container-category {
        height: 180px;
    }
}
