/* ===================================
   MODERN FINANCE MANAGER - PREMIUM UI
   Dark Mode | Animations | Glassmorphism
   =================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=Playfair+Display:wght@700;900&display=swap');
@import url('https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/css/select2.min.css');
@import url('https://cdn.jsdelivr.net/npm/select2-bootstrap-5-theme@1.3.0/dist/select2-bootstrap-5-theme.min.css');

/* ============ CSS VARIABLES ============ */
:root {
    /* Brand Colors */
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #818cf8;
    --secondary: #8b5cf6;
    --accent: #ec4899;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #06b6d4;
    
    /* Light Theme */
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-tertiary: #f1f5f9;
    --bg-elevated: #ffffff;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-tertiary: #94a3b8;
    --border-color: #e2e8f0;
    --shadow: rgba(15, 23, 42, 0.05);
    --shadow-lg: rgba(15, 23, 42, 0.1);
    --focus-ring: rgba(99, 102, 241, 0.2);
    
    /* Glassmorphism */
    --glass-bg: rgba(255, 255, 255, 0.8);
    --glass-border: rgba(255, 255, 255, 0.2);
    
    /* Spacing */
    --radius-sm: 0.5rem;
    --radius-md: 0.75rem;
    --radius-lg: 1rem;
    --radius-xl: 1.5rem;
    
    /* Transitions */
    --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 0.5s cubic-bezier(0.4, 0, 0.2, 1);

    /* Layering */
    --z-base: 1;
    --z-dropdown: 1040;
    --z-sticky: 1060;
    --z-overlay: 1070;
    --z-sidebar: 1080;
    --z-navbar: 1090;
    --z-modal: 1100;
}

/* ============ DARK MODE ============ */
[data-theme="dark"] {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --bg-elevated: #172033;
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-tertiary: #64748b;
    --border-color: #334155;
    --shadow: rgba(0, 0, 0, 0.3);
    --shadow-lg: rgba(0, 0, 0, 0.5);
    --glass-bg: rgba(30, 41, 59, 0.8);
    --glass-border: rgba(255, 255, 255, 0.1);
    --focus-ring: rgba(129, 140, 248, 0.28);
}

/* ============ BASE STYLES ============ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Select2 visual consistency with Bootstrap form controls */
.select2-container {
    width: 100% !important;
}

.select2-container--open {
    z-index: 2100;
}

.select2-container--bootstrap-5 .select2-selection,
.select2-container .select2-selection {
    min-height: 38px;
    border-radius: 0.375rem;
}

.select2-container--bootstrap-5 .select2-selection--single .select2-selection__rendered {
    line-height: 36px;
}

[data-theme="dark"] .select2-container--bootstrap-5 .select2-selection,
[data-theme="dark"] .select2-container--bootstrap-5 .select2-dropdown {
    background-color: var(--bg-secondary);
    border-color: var(--border-color);
    color: var(--text-primary);
}

[data-theme="dark"] .select2-container--bootstrap-5 .select2-results__option {
    color: var(--text-primary);
}

[data-theme="dark"] .select2-container--bootstrap-5 .select2-search__field {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
    border-color: var(--border-color);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background:
        linear-gradient(180deg, var(--bg-secondary) 0%, var(--bg-primary) 100%);
    color: var(--text-primary);
    overflow-x: hidden;
    transition: background var(--transition-base), color var(--transition-base);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    position: relative;
}

html,
body {
    min-height: 100%;
}

/* Smooth component transitions during theme switch */
html.theme-switching *,
html.theme-switching *::before,
html.theme-switching *::after {
    transition:
        background-color var(--transition-base),
        color var(--transition-base),
        border-color var(--transition-base),
        box-shadow var(--transition-base),
        fill var(--transition-base),
        stroke var(--transition-base) !important;
}

main,
.container-fluid,
.row {
    position: relative;
    z-index: var(--z-base);
}
main {
    padding: 4rem;
}

@media (max-width: 1199.98px) {
    main {
        padding: 1.5rem 1.25rem;
    }
}

@media (max-width: 991.98px) {
    main {
        padding: 1rem 0.85rem;
        padding-top: calc(64px + 0.5rem);
    }
}

@media (max-width: 575.98px) {
    main {
        padding: 0.75rem 0.5rem;
        padding-top: calc(64px + 0.25rem);
    }
}

.fw-bold, .card-title, .card-body h5, strong {
    color: var(--text-primary);
}

a {
    color: var(--primary-dark);
}

a:hover {
    color: var(--primary);
}

[data-theme="dark"] a {
    color: #a5b4fc;
}

[data-theme="dark"] a:hover {
    color: #c7d2fe;
}

/* Animated Background Gradient */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        radial-gradient(circle at 20% 50%, rgba(99, 102, 241, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(139, 92, 246, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 40% 90%, rgba(236, 72, 153, 0.05) 0%, transparent 50%);
    z-index: -1;
    animation: gradientFloat 20s ease-in-out infinite;
}

[data-theme="dark"] body::before {
    background: 
        radial-gradient(circle at 20% 50%, rgba(99, 102, 241, 0.15) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(139, 92, 246, 0.15) 0%, transparent 50%),
        radial-gradient(circle at 40% 90%, rgba(236, 72, 153, 0.1) 0%, transparent 50%);
}

@keyframes gradientFloat {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.8; transform: scale(1.1); }
}

/* Selection Styling */
::selection {
    background: var(--primary);
    color: white;
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-tertiary);
}

::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary-dark);
}

/* ============ TYPOGRAPHY ============ */
h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: 0.5rem;
}

.display-title {
    font-family: 'Playfair Display', serif;
    font-weight: 900;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ============ ANIMATIONS ============ */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(-30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes shimmer {
    0% {
        background-position: -1000px 0;
    }
    100% {
        background-position: 1000px 0;
    }
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.05);
        opacity: 0.8;
    }
}

@keyframes float {
    0%, 100% {
        transform: translateY(0px);
    }
    50% {
        transform: translateY(-10px);
    }
}

.animate-fade-in {
    animation: fadeIn 0.6s ease-out forwards;
}

.animate-fade-in-up {
    animation: fadeInUp 0.8s ease-out forwards;
}

.animate-scale-in {
    animation: scaleIn 0.5s ease-out forwards;
}

.stagger-1 { animation-delay: 0.1s; opacity: 0; }
.stagger-2 { animation-delay: 0.2s; opacity: 0; }
.stagger-3 { animation-delay: 0.3s; opacity: 0; }
.stagger-4 { animation-delay: 0.4s; opacity: 0; }

/* ============ GLASS MORPHISM ============ */
.glass {
    background: var(--glass-bg);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid var(--glass-border);
}

.glass-card {
    background: var(--glass-bg);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    transition: all var(--transition-base);
}

.glass-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 20px 40px var(--shadow-lg);
    border-color: var(--primary);
}

/* ============ CARDS ============ */
.card {
    background: var(--bg-elevated);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    transition: all var(--transition-base);
    overflow: hidden;
    position: relative;
}

.card-header,
.card-footer {
    background: var(--bg-elevated);
    color: var(--text-primary);
    border-color: var(--border-color);
}

.bg-white,
[data-theme="dark"] .bg-white {
    background-color: var(--bg-primary) !important;
    color: var(--text-primary) !important;
}

[data-theme="dark"] .border-bottom,
[data-theme="dark"] .border-top,
[data-theme="dark"] .border,
[data-theme="dark"] hr {
    border-color: var(--border-color) !important;
}

.card::before {
    /* content: ''; */
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, transparent, rgba(99, 102, 241, 0.05));
    opacity: 0;
    transition: opacity var(--transition-base);
}

.card:hover::before {
    opacity: 1;
}

.card:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: 
        0 20px 40px var(--shadow-lg),
        0 0 0 1px var(--primary);
    border-color: var(--primary);
}

.card-gradient {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    border: none;
}

.card-shine {
    position: relative;
    overflow: hidden;
}

.card-shine::after {
    content: '';
    position: absolute;
    top: -50%;
    right: -50%;
    bottom: -50%;
    left: -50%;
    background: linear-gradient(
        to bottom,
        transparent,
        rgba(255, 255, 255, 0.3) 50%,
        transparent
    );
    transform: rotate(45deg) translateX(-100%);
    transition: transform var(--transition-slow);
}

.card-shine:hover::after {
    transform: rotate(45deg) translateX(100%);
}

/* ============ BUTTONS ============ */
.btn {
    position: relative;
    overflow: hidden;
    border-radius: var(--radius-md);
    font-weight: 600;
    transition: all var(--transition-base);
    border: none;
    cursor: pointer;
}

.btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.btn:hover::before {
    width: 300px;
    height: 300px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(99, 102, 241, 0.4);
}

/* ============ NAVBAR ============ */
.navbar {
    background: var(--bg-primary);
    /* backdrop-filter: blur(20px) saturate(180%); */
    /* -webkit-backdrop-filter: blur(20px) saturate(180%); */
    border-bottom: 1px solid var(--border-color);
    transition: all var(--transition-base);
    position: fixed;
    left: 0;
    top: 0;
    width: 100%;
    z-index: var(--z-navbar);
}

.navbar.bg-light,
[data-theme="dark"] .navbar.bg-light {
    background: var(--glass-bg) !important;
    border-bottom: 1px solid var(--border-color);
}

.navbar-brand {
    font-weight: 800;
    font-size: 1.5rem;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.navbar .nav-link,
.navbar .navbar-text,
.navbar .dropdown-toggle,
.navbar .navbar-brand {
    color: var(--text-primary) !important;
}

.navbar .nav-link:hover,
.navbar .dropdown-toggle:hover {
    color: var(--primary) !important;
}

[data-theme="dark"] .navbar-toggler {
    border-color: var(--border-color);
}

[data-theme="dark"] .navbar-toggler-icon {
    filter: invert(1);
}

/* ============ SIDEBAR ============ */
.sidebar {
    background: var(--bg-primary);
    border-right: 1px solid var(--border-color);
    transition: transform var(--transition-base), background-color var(--transition-base), border-color var(--transition-base);
    z-index: var(--z-sidebar);
    height: 100vh;
    position: fixed;
    top: 64px;
}

.sidebar.bg-light,
[data-theme="dark"] .sidebar.bg-light {
    background: var(--bg-primary) !important;
}

.sidebar .nav-link {
    position: relative;
    border-radius: var(--radius-md);
    transition: all var(--transition-base);
    color: var(--text-secondary);
    margin: 0.25rem 0;
}

.sidebar .nav-link::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 0;
    background: var(--primary);
    border-radius: 0 3px 3px 0;
    transition: height var(--transition-base);
}

.sidebar .nav-link:hover,
.sidebar .nav-link.active {
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary);
}

.sidebar .nav-link:hover::before,
.sidebar .nav-link.active::before {
    height: 70%;
}

.sidebar-overlay {
    position: fixed;
    top: 64px;
    right: 0;
    bottom: 0;
    left: 0;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity var(--transition-base), visibility var(--transition-base);
    z-index: var(--z-overlay);
}

/* .sidebar-overlay.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
} */

/* ============ LANDING PAGE ============ */
.hero-section {
    min-height: 100vh;
    display: flex;
    align-items: center;
    position: relative;
    overflow: hidden;
}

.hero-section::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -50%;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle, rgba(99, 102, 241, 0.2), transparent 70%);
    animation: float 6s ease-in-out infinite;
}

.feature-icon {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-base);
}

.feature-icon:hover {
    transform: scale(1.1) rotate(5deg);
}

/* ============ AUTH PAGES ============ */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.auth-page .card {
    max-width: 450px;
    backdrop-filter: blur(20px);
}

/* ============ DASHBOARD ============ */
.stat-card {
    position: relative;
    overflow: hidden;
}

.stat-card::after {
    content: '';
    position: absolute;
    top: -50%;
    right: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(45deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    transform: translateX(-100%) translateY(-100%) rotate(45deg);
    transition: transform 0.6s;
}

.stat-card:hover::after {
    transform: translateX(100%) translateY(100%) rotate(45deg);
}

/* ============ EXPENSES CUSTOM DESIGN ============ */
.page-expenses .expenses-main {
    position: relative;
}

.page-expenses .expenses-main::before {
    content: '';
    position: absolute;
    top: -12px;
    left: 0;
    right: 0;
    height: 220px;
    background:
        radial-gradient(circle at 8% 22%, rgba(239, 68, 68, 0.16), transparent 55%),
        radial-gradient(circle at 88% 8%, rgba(245, 158, 11, 0.14), transparent 56%),
        linear-gradient(160deg, rgba(15, 23, 42, 0.03), transparent 58%);
    border-radius: 20px;
    pointer-events: none;
    z-index: 0;
}

[data-theme="dark"] .page-expenses .expenses-main::before {
    background:
        radial-gradient(circle at 8% 22%, rgba(248, 113, 113, 0.18), transparent 56%),
        radial-gradient(circle at 88% 8%, rgba(251, 191, 36, 0.16), transparent 56%),
        linear-gradient(160deg, rgba(248, 250, 252, 0.04), transparent 58%);
}

.page-expenses .expenses-hero,
.page-expenses .expenses-kpis,
.page-expenses .expenses-filters,
.page-expenses .expenses-list-card {
    position: relative;
    z-index: 1;
}

.page-expenses .expenses-hero {
    margin-top: 0.35rem;
    padding: 1rem 1rem 0.9rem;
    border-radius: 16px;
    border: 1px solid var(--border-color);
    background: linear-gradient(135deg, var(--bg-elevated) 12%, var(--bg-primary) 100%);
    box-shadow: 0 14px 30px var(--shadow);
}

.page-expenses .expenses-hero .h2 {
    letter-spacing: 0.2px;
    margin-bottom: 0;
}

.page-expenses .expenses-kpis .card {
    border: 1px solid var(--border-color);
    overflow: hidden;
}

.page-expenses .expenses-kpis .card::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--danger), var(--warning));
    opacity: 0.88;
}

.page-expenses .expenses-filters {
    border: 1px solid var(--border-color) !important;
    background:
        linear-gradient(140deg, var(--bg-elevated), var(--bg-primary)),
        radial-gradient(circle at 100% 0%, rgba(99, 102, 241, 0.07), transparent 40%);
    box-shadow: 0 18px 36px var(--shadow);
}

.page-expenses .expenses-filters .form-label {
    font-size: 0.84rem;
    letter-spacing: 0.25px;
    text-transform: uppercase;
    color: var(--text-secondary);
    font-weight: 700;
}

.page-expenses .expenses-filters .btn-primary {
    background: linear-gradient(135deg, #dc2626, #ea580c);
    box-shadow: 0 10px 20px rgba(220, 38, 38, 0.24);
}

.page-expenses .expenses-filters .btn-primary:hover {
    box-shadow: 0 14px 28px rgba(220, 38, 38, 0.3);
}

.page-expenses .expenses-list-card {
    border: 1px solid var(--border-color) !important;
    box-shadow: 0 18px 40px var(--shadow);
}

.page-expenses .expenses-list-card .card-header {
    background: linear-gradient(180deg, var(--bg-elevated), var(--bg-primary));
    border-bottom: 1px solid var(--border-color);
}

.page-expenses .expenses-list-card .table thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--bg-tertiary);
    backdrop-filter: blur(4px);
}

.page-expenses .expenses-list-card .table tbody td {
    vertical-align: middle;
}

.page-expenses .expenses-list-card .badge.bg-warning.text-dark {
    border: 1px solid rgba(161, 98, 7, 0.25);
}

[data-theme="dark"] .page-expenses .expenses-hero,
[data-theme="dark"] .page-expenses .expenses-filters,
[data-theme="dark"] .page-expenses .expenses-list-card {
    box-shadow: 0 20px 45px rgba(2, 6, 23, 0.5);
}

[data-theme="dark"] .page-expenses .expenses-hero {
    background: linear-gradient(135deg, rgba(15, 23, 42, 0.9), rgba(23, 32, 51, 0.9));
}

/* ============ MODULE CUSTOM DESIGN (ACCOUNTS / INCOME / CREDIT CARDS) ============ */
.module-page .module-main {
    position: relative;
}

.module-page .module-main::before {
    content: '';
    position: absolute;
    top: -12px;
    left: 0;
    right: 0;
    height: 210px;
    border-radius: 20px;
    pointer-events: none;
    z-index: 0;
    background:
        radial-gradient(circle at 8% 22%, var(--module-accent-soft-1, rgba(59, 130, 246, 0.13)), transparent 56%),
        radial-gradient(circle at 88% 8%, var(--module-accent-soft-2, rgba(16, 185, 129, 0.12)), transparent 56%),
        linear-gradient(160deg, rgba(15, 23, 42, 0.04), transparent 58%);
}

.module-page .module-hero,
.module-page .module-kpis,
.module-page .module-filters,
.module-page .module-analytics,
.module-page .module-list,
.module-page .module-list-card {
    position: relative;
    z-index: 1;
}

.module-page .module-hero {
    margin-top: 0.35rem;
    padding: 1rem 1rem 0.9rem;
    border-radius: 16px;
    border: 1px solid var(--border-color);
    background: linear-gradient(135deg, var(--bg-elevated) 12%, var(--bg-primary) 100%);
    box-shadow: 0 14px 30px var(--shadow);
}

.module-page .module-hero .h2 {
    letter-spacing: 0.2px;
    margin-bottom: 0;
}

.module-page .module-kpis .card {
    border: 1px solid var(--border-color);
    overflow: hidden;
}

.module-page .module-kpis .card::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--module-accent-strong-1, #3b82f6), var(--module-accent-strong-2, #10b981));
    opacity: 0.9;
}

.module-page .module-filters,
.module-page .module-list-card {
    border: 1px solid var(--border-color) !important;
    box-shadow: 0 18px 36px var(--shadow);
}

.module-page .module-filters {
    background:
        linear-gradient(140deg, var(--bg-elevated), var(--bg-primary)),
        radial-gradient(circle at 100% 0%, var(--module-accent-soft-1, rgba(59, 130, 246, 0.07)), transparent 40%);
}

.module-page .module-filters .form-label {
    font-size: 0.84rem;
    letter-spacing: 0.25px;
    text-transform: uppercase;
    color: var(--text-secondary);
    font-weight: 700;
}

.module-page .module-filters .btn-primary,
.module-page .module-hero .btn-primary {
    background: linear-gradient(135deg, var(--module-accent-strong-1, #3b82f6), var(--module-accent-strong-2, #10b981));
    box-shadow: 0 10px 20px var(--module-btn-shadow, rgba(59, 130, 246, 0.24));
}

.module-page .module-filters .btn-primary:hover,
.module-page .module-hero .btn-primary:hover {
    box-shadow: 0 14px 28px var(--module-btn-shadow-hover, rgba(59, 130, 246, 0.3));
}

.module-page .module-list-card .card-header {
    background: linear-gradient(180deg, var(--bg-elevated), var(--bg-primary));
    border-bottom: 1px solid var(--border-color);
}

.module-page .module-list-card .table thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--bg-tertiary);
    backdrop-filter: blur(4px);
}

[data-theme="dark"] .module-page .module-hero,
[data-theme="dark"] .module-page .module-filters,
[data-theme="dark"] .module-page .module-list-card {
    box-shadow: 0 20px 45px rgba(2, 6, 23, 0.5);
}

[data-theme="dark"] .module-page .module-main::before {
    background:
        radial-gradient(circle at 8% 22%, var(--module-accent-soft-1-dark, rgba(96, 165, 250, 0.16)), transparent 56%),
        radial-gradient(circle at 88% 8%, var(--module-accent-soft-2-dark, rgba(52, 211, 153, 0.14)), transparent 56%),
        linear-gradient(160deg, rgba(248, 250, 252, 0.04), transparent 58%);
}

[data-theme="dark"] .module-page .module-hero {
    background: linear-gradient(135deg, rgba(15, 23, 42, 0.9), rgba(23, 32, 51, 0.9));
}

.page-accounts {
    --module-accent-soft-1: rgba(59, 130, 246, 0.13);
    --module-accent-soft-2: rgba(20, 184, 166, 0.12);
    --module-accent-soft-1-dark: rgba(96, 165, 250, 0.18);
    --module-accent-soft-2-dark: rgba(45, 212, 191, 0.16);
    --module-accent-strong-1: #2563eb;
    --module-accent-strong-2: #0d9488;
    --module-btn-shadow: rgba(37, 99, 235, 0.24);
    --module-btn-shadow-hover: rgba(37, 99, 235, 0.3);
}

.page-income {
    --module-accent-soft-1: rgba(16, 185, 129, 0.14);
    --module-accent-soft-2: rgba(14, 165, 233, 0.12);
    --module-accent-soft-1-dark: rgba(74, 222, 128, 0.18);
    --module-accent-soft-2-dark: rgba(56, 189, 248, 0.16);
    --module-accent-strong-1: #059669;
    --module-accent-strong-2: #0284c7;
    --module-btn-shadow: rgba(5, 150, 105, 0.24);
    --module-btn-shadow-hover: rgba(5, 150, 105, 0.3);
}

.page-credit-cards {
    --module-accent-soft-1: rgba(245, 158, 11, 0.15);
    --module-accent-soft-2: rgba(217, 70, 239, 0.12);
    --module-accent-soft-1-dark: rgba(251, 191, 36, 0.18);
    --module-accent-soft-2-dark: rgba(232, 121, 249, 0.16);
    --module-accent-strong-1: #d97706;
    --module-accent-strong-2: #c026d3;
    --module-btn-shadow: rgba(217, 119, 6, 0.24);
    --module-btn-shadow-hover: rgba(217, 119, 6, 0.3);
}

.page-dashboard {
    --module-accent-soft-1: rgba(99, 102, 241, 0.14);
    --module-accent-soft-2: rgba(6, 182, 212, 0.12);
    --module-accent-soft-1-dark: rgba(129, 140, 248, 0.18);
    --module-accent-soft-2-dark: rgba(34, 211, 238, 0.16);
    --module-accent-strong-1: #4f46e5;
    --module-accent-strong-2: #0891b2;
    --module-btn-shadow: rgba(79, 70, 229, 0.24);
    --module-btn-shadow-hover: rgba(79, 70, 229, 0.3);
}

.page-budgets {
    --module-accent-soft-1: rgba(5, 150, 105, 0.14);
    --module-accent-soft-2: rgba(132, 204, 22, 0.12);
    --module-accent-soft-1-dark: rgba(52, 211, 153, 0.18);
    --module-accent-soft-2-dark: rgba(163, 230, 53, 0.16);
    --module-accent-strong-1: #047857;
    --module-accent-strong-2: #65a30d;
    --module-btn-shadow: rgba(4, 120, 87, 0.24);
    --module-btn-shadow-hover: rgba(4, 120, 87, 0.3);
}

.page-bills {
    --module-accent-soft-1: rgba(234, 88, 12, 0.14);
    --module-accent-soft-2: rgba(244, 63, 94, 0.12);
    --module-accent-soft-1-dark: rgba(251, 146, 60, 0.18);
    --module-accent-soft-2-dark: rgba(251, 113, 133, 0.16);
    --module-accent-strong-1: #c2410c;
    --module-accent-strong-2: #e11d48;
    --module-btn-shadow: rgba(194, 65, 12, 0.24);
    --module-btn-shadow-hover: rgba(194, 65, 12, 0.3);
}

.page-reports {
    --module-accent-soft-1: rgba(14, 165, 233, 0.14);
    --module-accent-soft-2: rgba(99, 102, 241, 0.12);
    --module-accent-soft-1-dark: rgba(56, 189, 248, 0.18);
    --module-accent-soft-2-dark: rgba(129, 140, 248, 0.16);
    --module-accent-strong-1: #0284c7;
    --module-accent-strong-2: #4338ca;
    --module-btn-shadow: rgba(2, 132, 199, 0.24);
    --module-btn-shadow-hover: rgba(2, 132, 199, 0.3);
}

.page-settings {
    --module-accent-soft-1: rgba(168, 85, 247, 0.14);
    --module-accent-soft-2: rgba(244, 63, 94, 0.12);
    --module-accent-soft-1-dark: rgba(196, 181, 253, 0.18);
    --module-accent-soft-2-dark: rgba(251, 113, 133, 0.16);
    --module-accent-strong-1: #7e22ce;
    --module-accent-strong-2: #db2777;
    --module-btn-shadow: rgba(126, 34, 206, 0.24);
    --module-btn-shadow-hover: rgba(126, 34, 206, 0.3);
}

/* Module modal design */
.module-page .modal-dialog {
    transform: translateY(8px);
    transition: transform var(--transition-base);
}

.module-page .modal.show .modal-dialog {
    transform: translateY(0);
}

.module-page .modal-content {
    border: 1px solid var(--border-color);
    border-radius: 18px;
    overflow: hidden;
    background:
        linear-gradient(155deg, var(--bg-elevated), var(--bg-primary)),
        radial-gradient(circle at 100% 0%, var(--module-accent-soft-1, rgba(59, 130, 246, 0.07)), transparent 42%);
    box-shadow: 0 26px 50px rgba(15, 23, 42, 0.22);
}

.module-page .modal-header {
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 1.2rem;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.7), rgba(255, 255, 255, 0));
}

.module-page .modal-title {
    letter-spacing: 0.2px;
    font-weight: 700;
}

.module-page .modal-body {
    padding: 1.15rem 1.2rem;
}

.module-page .modal-footer {
    border-top: 1px solid var(--border-color);
    padding: 0.9rem 1.2rem 1rem;
    background: linear-gradient(0deg, rgba(255, 255, 255, 0.7), rgba(255, 255, 255, 0));
}

.module-page .modal-footer .btn-primary,
.module-page .modal-footer .btn-success,
.module-page .modal-footer .btn-danger {
    border: none;
    box-shadow: 0 10px 20px var(--module-btn-shadow, rgba(59, 130, 246, 0.24));
}

.module-page .modal-footer .btn-primary,
.module-page .modal-footer .btn-success {
    background: linear-gradient(135deg, var(--module-accent-strong-1, #3b82f6), var(--module-accent-strong-2, #10b981));
}

.module-page .modal-footer .btn-danger {
    background: linear-gradient(135deg, #dc2626, #f97316);
}

.module-page .modal-footer .btn-primary:hover,
.module-page .modal-footer .btn-success:hover,
.module-page .modal-footer .btn-danger:hover {
    transform: translateY(-1px);
}

[data-theme="dark"] .module-page .modal-content {
    background:
        linear-gradient(155deg, rgba(15, 23, 42, 0.96), rgba(23, 32, 51, 0.95)),
        radial-gradient(circle at 100% 0%, var(--module-accent-soft-1-dark, rgba(96, 165, 250, 0.12)), transparent 44%);
    box-shadow: 0 30px 65px rgba(2, 6, 23, 0.72);
}

[data-theme="dark"] .module-page .modal-header,
[data-theme="dark"] .module-page .modal-footer {
    background: linear-gradient(180deg, rgba(148, 163, 184, 0.08), rgba(148, 163, 184, 0));
}

[data-theme="dark"] .module-page .modal-backdrop.show {
    opacity: 0.72;
}

/* ============ TABLES ============ */
.table {
    border-collapse: separate;
    border-spacing: 0;
    color: var(--text-primary);
    --bs-table-bg: transparent;
    --bs-table-color: var(--text-primary);
    --bs-table-border-color: var(--border-color);
}

.table thead th {
    background: var(--bg-tertiary);
    border: none;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
}

.table tbody td,
.table tbody th {
    color: var(--text-primary);
    border-color: var(--border-color);
    background: transparent;
}

.table > :not(caption) > * > * {
    border-bottom-color: var(--border-color);
}

.table tbody tr {
    transition: background-color var(--transition-fast), transform var(--transition-fast);
}

.table tbody tr:hover {
    background: rgba(99, 102, 241, 0.05);
    transform: scale(1.01);
}

[data-theme="dark"] .table-light,
[data-theme="dark"] .table > :not(caption) > * > th,
[data-theme="dark"] .table > :not(caption) > * > td {
    background-color: transparent !important;
    color: var(--text-primary) !important;
}

.table-responsive {
    border-radius: var(--radius-lg);
    -webkit-overflow-scrolling: touch;
}

/* ============ FORMS ============ */
.form-control,
.form-select {
    background: var(--bg-primary);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    transition: all var(--transition-base);
}

.form-control::placeholder {
    color: var(--text-tertiary);
    opacity: 1;
}

.form-control:focus,
.form-select:focus {
    background: var(--bg-primary);
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--focus-ring);
    color: var(--text-primary);
}

.form-control:disabled{
    background: var(--bg-secondary);
    border-color: var(--border-color);
    color: var(--text-secondary);
}

.input-group-text {
    background: var(--bg-tertiary);
    border: 2px solid var(--border-color);
    color: var(--text-secondary);
}

.form-check-input {
    background-color: var(--bg-primary);
    border-color: var(--border-color);
}

.form-check-input:checked {
    background-color: var(--primary);
    border-color: var(--primary);
}

.form-check-input:focus {
    box-shadow: 0 0 0 0.25rem var(--focus-ring);
    border-color: var(--primary);
}

/* ============ BADGES ============ */
.badge {
    padding: 0.5rem 1rem;
    border-radius: var(--radius-md);
    font-weight: 600;
    letter-spacing: 0.3px;
}

/* ============ PROGRESS BARS ============ */
.progress {
    height: 12px;
    border-radius: var(--radius-md);
    background: var(--bg-tertiary);
    overflow: hidden;
}

.progress-bar {
    border-radius: var(--radius-md);
    transition: width 1s ease-out;
    position: relative;
    overflow: hidden;
}

.progress-bar::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.3),
        transparent
    );
    animation: shimmer 2s infinite;
}

/* ============ MODALS ============ */
.modal-content {
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.2);
}

.modal {
    z-index: var(--z-modal);
}

.modal-header,
.modal-footer {
    border-color: var(--border-color);
}

.modal-title,
.form-label,
label,
.form-text {
    color: var(--text-primary);
}

.form-text,
.text-muted {
    color: var(--text-secondary) !important;
}

.dropdown-menu {
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    box-shadow: 0 10px 30px var(--shadow-lg);
    z-index: var(--z-dropdown);
}

.dropdown-item,
.dropdown-header {
    color: var(--text-primary);
}

.dropdown-item:hover,
.dropdown-item:focus {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.dropdown-divider {
    border-top-color: var(--border-color);
}

.list-group-item {
    background: var(--bg-elevated);
    color: var(--text-primary);
    border-color: var(--border-color);
}

.list-group-item:hover,
.list-group-item:focus {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.list-group-item.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

/* ============ SETTINGS TABS (vertical list-group as tabs) ============ */
.page-settings .module-list .list-group {
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: 0 10px 24px var(--shadow);
}

.page-settings .module-list .list-group-item {
    position: relative;
    border-left: 0;
    border-right: 0;
    padding: 0.85rem 1rem 0.85rem 1.1rem;
    font-weight: 500;
    color: var(--text-secondary);
    background: var(--bg-elevated);
    overflow: hidden;
    transition:
        color var(--transition-base),
        background-color var(--transition-base),
        transform var(--transition-base),
        padding-left var(--transition-base),
        box-shadow var(--transition-base);
    will-change: transform, background-color;
}

.page-settings .module-list .list-group-item i {
    margin-right: 0.6rem;
    transition: transform var(--transition-base), color var(--transition-base);
}

/* Sliding accent bar on the left edge */
.page-settings .module-list .list-group-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    width: 3px;
    height: 0;
    background: linear-gradient(180deg, var(--primary), var(--secondary));
    border-radius: 0 3px 3px 0;
    transform: translateY(-50%);
    transition: height var(--transition-base), opacity var(--transition-base);
    opacity: 0;
}

/* Soft gradient sheen that slides in on hover */
.page-settings .module-list .list-group-item::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(
        90deg,
        rgba(99, 102, 241, 0.10),
        rgba(139, 92, 246, 0.06) 60%,
        transparent
    );
    opacity: 0;
    transform: translateX(-12%);
    transition: opacity var(--transition-base), transform var(--transition-slow);
    pointer-events: none;
    z-index: 0;
}

.page-settings .module-list .list-group-item > * {
    position: relative;
    z-index: 1;
}

.page-settings .module-list .list-group-item:hover {
    color: var(--primary);
    background: var(--bg-elevated);
    padding-left: 1.4rem;
    transform: translateX(2px);
    box-shadow: 0 6px 18px var(--shadow);
}

.page-settings .module-list .list-group-item:hover i {
    color: var(--primary);
    transform: scale(1.08);
}

.page-settings .module-list .list-group-item:hover::before {
    height: 60%;
    opacity: 1;
}

.page-settings .module-list .list-group-item:hover::after {
    opacity: 1;
    transform: translateX(0);
}

.page-settings .module-list .list-group-item.active {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    border-color: transparent;
    padding-left: 1.4rem;
    box-shadow: 0 10px 22px rgba(99, 102, 241, 0.32);
}

.page-settings .module-list .list-group-item.active i {
    color: #fff;
    transform: scale(1.05);
}

.page-settings .module-list .list-group-item.active::before {
    height: 70%;
    opacity: 1;
    background: linear-gradient(180deg, #ffffff, rgba(255, 255, 255, 0.6));
}

.page-settings .module-list .list-group-item.active::after {
    opacity: 0;
}

/* Smooth tab-pane transition: fade + lift + scale.
   Bootstrap toggles .show on the active pane and removes it from the rest;
   inactive panes are display:none, so we animate from the moment they get
   .show added. A keyframe animation on .show gives a deterministic entrance. */
.page-settings .tab-content {
    position: relative;
}

.page-settings .tab-content > .tab-pane {
    transition:
        opacity var(--transition-base),
        transform var(--transition-base);
    will-change: opacity, transform;
}

.page-settings .tab-content > .tab-pane:not(.show) {
    opacity: 0;
    transform: translateY(8px) scale(0.995);
}

.page-settings .tab-content > .tab-pane.show {
    opacity: 1;
    transform: translateY(0) scale(1);
    animation: tabPaneIn 0.45s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Stagger child cards/forms inside the active tab for a polished reveal */
.page-settings .tab-content > .tab-pane.show > .card,
.page-settings .tab-content > .tab-pane.show > div > .card {
    animation: tabPaneCardIn 0.55s cubic-bezier(0.4, 0, 0.2, 1) both;
}

.page-settings .tab-content > .tab-pane.show > .card:nth-child(2),
.page-settings .tab-content > .tab-pane.show > div > .card:nth-child(2) {
    animation-delay: 0.08s;
}

.page-settings .tab-content > .tab-pane.show > .card:nth-child(3),
.page-settings .tab-content > .tab-pane.show > div > .card:nth-child(3) {
    animation-delay: 0.16s;
}

@keyframes tabPaneIn {
    from {
        opacity: 0;
        transform: translateY(12px) scale(0.99);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes tabPaneCardIn {
    from {
        opacity: 0;
        transform: translateY(14px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (prefers-reduced-motion: reduce) {
    .page-settings .module-list .list-group-item,
    .page-settings .module-list .list-group-item::before,
    .page-settings .module-list .list-group-item::after,
    .page-settings .module-list .list-group-item i,
    .page-settings .tab-content > .tab-pane,
    .page-settings .tab-content > .tab-pane.show,
    .page-settings .tab-content > .tab-pane.show > .card,
    .page-settings .tab-content > .tab-pane.show > div > .card {
        transition: none !important;
        transform: none !important;
        animation: none !important;
    }
}

.tab-content,
.tab-content p,
.tab-content h1,
.tab-content h2,
.tab-content h3,
.tab-content h4,
.tab-content h5,
.tab-content h6,
.tab-content label,
.tab-content small {
    color: var(--text-primary);
}

.tab-content small.text-muted,
.tab-content .text-muted {
    color: var(--text-secondary) !important;
}

.alert {
    border: 1px solid var(--border-color);
}

[data-theme="dark"] .alert-info {
    background-color: rgba(6, 182, 212, 0.14);
    color: #bae6fd;
    border-color: rgba(6, 182, 212, 0.35);
}

[data-theme="dark"] .alert-success {
    background-color: rgba(16, 185, 129, 0.14);
    color: #bbf7d0;
    border-color: rgba(16, 185, 129, 0.35);
}

[data-theme="dark"] .alert-warning {
    background-color: rgba(245, 158, 11, 0.14);
    color: #fde68a;
    border-color: rgba(245, 158, 11, 0.35);
}

[data-theme="dark"] .alert-danger {
    background-color: rgba(239, 68, 68, 0.14);
    color: #fecaca;
    border-color: rgba(239, 68, 68, 0.35);
}

.pagination .page-link {
    background: var(--bg-elevated);
    border-color: var(--border-color);
    color: var(--text-primary);
}

.pagination .page-link:hover,
.pagination .page-item.active .page-link {
    background: var(--bg-tertiary);
    border-color: var(--primary);
    color: var(--text-primary);
}

[data-theme="dark"] .btn-close {
    filter: invert(1) grayscale(100%) brightness(180%);
}

[data-theme="dark"] .modal-backdrop.show {
    opacity: 0.7;
}

[data-theme="dark"] .offcanvas,
[data-theme="dark"] .offcanvas-header,
[data-theme="dark"] .offcanvas-body {
    background: var(--bg-elevated);
    color: var(--text-primary);
}

[data-theme="dark"] .btn-outline-secondary,
[data-theme="dark"] .btn-outline-light,
[data-theme="dark"] .btn-outline-dark {
    color: var(--text-secondary);
    border-color: var(--border-color);
}

[data-theme="dark"] .btn-outline-secondary:hover,
[data-theme="dark"] .btn-outline-light:hover,
[data-theme="dark"] .btn-outline-dark:hover {
    color: var(--text-primary);
    background: var(--bg-tertiary);
    border-color: var(--primary);
}

[data-theme="dark"] .card,
[data-theme="dark"] .modal-content,
[data-theme="dark"] .table thead th,
[data-theme="dark"] .input-group-text,
[data-theme="dark"] .form-control,
[data-theme="dark"] .form-select,
[data-theme="dark"] .dropdown-menu {
    transition: background-color var(--transition-base), color var(--transition-base), border-color var(--transition-base), box-shadow var(--transition-base);
}

/* ============ DARK MODE TOGGLE ============ */
.theme-toggle {
    width: 60px;
    height: 30px;
    background: var(--bg-tertiary);
    border-radius: 30px;
    position: relative;
    cursor: pointer;
    transition: all var(--transition-base);
}

.theme-toggle-slider {
    width: 24px;
    height: 24px;
    background: var(--primary);
    border-radius: 50%;
    position: absolute;
    top: 3px;
    left: 3px;
    transition: all var(--transition-base);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

[data-theme="dark"] .theme-toggle-slider {
    left: 33px;
}

/* ============ CREDIT CARDS ============ */
.credit-card {
    border-radius: var(--radius-xl);
    padding: 2rem;
    position: relative;
    overflow: hidden;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    transform-style: preserve-3d;
    transition: all var(--transition-base);
}

.credit-card::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.1), transparent 50%);
    animation: float 8s ease-in-out infinite;
}

.credit-card:hover {
    transform: translateY(-10px) rotateY(5deg) rotateX(5deg);
    box-shadow: 0 30px 60px rgba(0, 0, 0, 0.3);
}

/* ============ UTILITY CLASSES ============ */
.text-gradient {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.shadow-soft {
    box-shadow: 0 10px 30px var(--shadow);
}

.shadow-strong {
    box-shadow: 0 20px 60px var(--shadow-lg);
}

/* ============ RESPONSIVE ============ */

/* Sidebar toggle button (mobile hamburger) */
.btn-sidebar-toggle {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.35rem 0.6rem;
    border-radius: var(--radius-sm);
    line-height: 1;
}

.btn-sidebar-toggle:hover,
.btn-sidebar-toggle:focus {
    background: rgba(99, 102, 241, 0.08);
    color: var(--primary);
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--focus-ring);
}

/* Lock body scroll when mobile sidebar is open */
body.sidebar-locked {
    overflow: hidden;
}

/* Navbar inline collapse replacement (we don't use Bootstrap collapse for the main bar) */
.navbar-collapse-inline {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
}

/* Ensure navbar dropdowns float above the bar at all breakpoints.
   Bootstrap only applies position:absolute to navbar dropdowns at >=lg
   via the .navbar-expand-lg rule, which doesn't fire for our inline
   collapse replacement on small screens. Without this, Popper's transforms
   have no effect and the menu renders inline, stretching the navbar. */
.navbar .navbar-collapse-inline .dropdown-menu,
.navbar .navbar-nav .dropdown-menu {
    position: absolute;
}

/* Right-aligned dropdowns must stay inside the viewport on small screens */
@media (max-width: 575.98px) {
    .navbar .dropdown-menu-end {
        right: -1rem !important;
        left: auto !important;
    }
}

@media (max-width: 991.98px) {
    .navbar .container-fluid {
        flex-wrap: nowrap;
        gap: 0.25rem;
    }

    .navbar-brand {
        font-size: 1.15rem;
        margin-right: 0;
    }

    .navbar-collapse-inline .navbar-nav {
        gap: .8rem;
    }

    /* Compact "Add Transaction" to icon-only on small screens */
    .btn-add-transaction .btn-label {
        display: none;
    }

    .btn-add-transaction {
        padding: 0.35rem 0.55rem;
    }

    /* Sidebar above overlay on mobile */
    #sidebar {
        z-index: calc(var(--z-overlay) + 1);
    }
}

@media (max-width: 575.98px) {
    .navbar-brand .brand-text {
        display: none;
    }

    .navbar-brand i {
        font-size: 1.4rem;
    }
}

@media (max-width: 768px) {
    .navbar .container-fluid {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }

    #sidebar {
        position: fixed !important;
        top: 64px;
        left: 0;
        width: min(82vw, 300px);
        height: calc(100vh - 64px) !important;
        overflow-y: auto;
        transform: translateX(-105%);
        box-shadow: 0 18px 35px var(--shadow-lg);
        border-right: 1px solid var(--border-color);
        display: block !important;
    }

    #sidebar.show,
    #sidebar.sidebar-open {
        transform: translateX(0);
    }

    .card {
        border-radius: var(--radius-md);
    }

    .card:hover {
        transform: translateY(-2px) scale(1.005);
    }

    .table-responsive {
        margin: 0 -0.25rem;
    }

    .dropdown-menu {
        width: min(92vw, 320px) !important;
        max-height: 70vh;
        overflow-y: auto;
    }

    .btn-toolbar {
        width: 100%;
        gap: 0.5rem;
    }

    .btn-toolbar .btn-group,
    .btn-toolbar .btn {
        width: 100%;
    }

    /* Module hero stacking */
    .module-page .module-hero {
        flex-direction: column;
        align-items: stretch !important;
        gap: 0.75rem;
    }

    .module-page .module-hero .h2,
    .h2, h2 {
        font-size: 1.35rem;
    }

    /* KPI cards: reduce vertical spacing */
    .module-page .module-kpis .card-body,
    .stat-card .card-body {
        padding: 1rem;
    }

    /* Modals: full-width with breathing room */
    .modal-dialog {
        margin: 0.5rem;
    }

    /* Tables: tighter cells, allow horizontal scroll */
    .table > :not(caption) > * > * {
        padding: 0.55rem 0.5rem;
    }

    .hero-section {
        padding-top: 80px;
    }

    /* Footer stacks neatly */
    footer .col-md-6.text-md-end {
        text-align: left !important;
        margin-top: 0.5rem;
    }
}

/* Ensure sidebar slides on tablet too (md breakpoint) */
@media (max-width: 991.98px) {
    #sidebar {
        position: fixed !important;
        top: 64px;
        left: 0;
        width: min(82vw, 300px);
        height: calc(100vh - 64px) !important;
        overflow-y: auto;
        transform: translateX(-105%);
        box-shadow: 0 18px 35px var(--shadow-lg);
        border-right: 1px solid var(--border-color);
        display: block !important;
        background: var(--bg-primary);
    }

    #sidebar.sidebar-open,
    #sidebar.show {
        transform: translateX(0);
    }

    /* Hide the main col offsets so layout doesn't push content */
    main.col-md-9,
    main.col-lg-10 {
        flex: 0 0 100%;
        max-width: 100%;
        margin-left: 0 !important;
    }

    /* Footer flows in document on mobile (was position:fixed for desktop) */
    footer {
        position: static !important;
        width: 100% !important;
    }
}

@media (max-width: 992px) {
    .container-fluid > .row {
        --bs-gutter-x: 0.5rem;
    }

    .sidebar .nav-link {
        padding: 0.72rem 0.85rem;
    }

    .h2,
    h2 {
        font-size: 1.35rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }

    body::before,
    .progress-bar::after,
    .stat-card::after,
    .card-shine::after,
    .credit-card::before {
        animation: none !important;
    }
}

/* ============ LOADING STATES ============ */
.skeleton {
    background: linear-gradient(
        90deg,
        var(--bg-tertiary) 25%,
        var(--bg-secondary) 50%,
        var(--bg-tertiary) 75%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-md);
}

.app-footer {

    position: fixed;
    bottom: 0;
    right: 0;
    width: calc(100% - 243px);
    z-index: 9;
    background: var(--bg-primary);
    border-top: 1px solid var(--border-color);
    padding: 1rem 0;
    text-align: center;
    color: var(--text-secondary);
    transition: background-color var(--transition-base), color var(--transition-base), border-color var(--transition-base);
}

/* ============ MODAL MICRO-POLISH ============ */

/* Title hierarchy */
.module-page .modal-title {
    font-size: 1.05rem;
    letter-spacing: 0.15px;
}

.module-page .modal-title .modal-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--module-accent-strong-1, #3b82f6), var(--module-accent-strong-2, #10b981));
    color: #fff;
    font-size: 0.78rem;
    margin-right: 0.45rem;
    flex-shrink: 0;
    vertical-align: middle;
}

/* Close button */
.module-page .modal-header .btn-close {
    margin-right: -0.1rem;
    opacity: 0.55;
    transition: opacity 0.15s ease, transform 0.15s ease;
}
.module-page .modal-header .btn-close:hover {
    opacity: 1;
    transform: rotate(90deg);
}
[data-theme="dark"] .module-page .modal-header .btn-close {
    filter: invert(1) grayscale(1);
}

/* Header separator line */
.module-page .modal-header::after {
    content: '';
    position: absolute;
    left: 1.2rem;
    right: 1.2rem;
    bottom: 0;
    height: 1px;
    background: linear-gradient(90deg, var(--module-accent-strong-1, #3b82f6), transparent);
    opacity: 0.25;
}
.module-page .modal-header {
    position: relative;
}

/* Form label hierarchy */
.module-page .modal-body .form-label {
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.35px;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: 0.32rem;
}

/* Vertical rhythm between form groups */
.module-page .modal-body .mb-3 {
    margin-bottom: 1rem !important;
}
.module-page .modal-body .row .mb-3 {
    margin-bottom: 0.85rem !important;
}

/* Inputs & selects */
.module-page .modal-body .form-control,
.module-page .modal-body .form-select {
    border-radius: 8px;
    border-color: var(--border-color);
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 0.875rem;
    padding: 0.5rem 0.75rem;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color var(--transition-base);
}
.module-page .modal-body .form-control:focus,
.module-page .modal-body .form-select:focus {
    border-color: var(--module-accent-strong-1, #3b82f6);
    box-shadow: 0 0 0 3px var(--module-accent-soft-1, rgba(59, 130, 246, 0.15));
    background-color: var(--bg-elevated);
    outline: none;
}
.module-page .modal-body .form-control::placeholder {
    color: var(--text-muted, var(--text-secondary));
    opacity: 0.65;
}

/* Textarea */
.module-page .modal-body textarea.form-control {
    resize: vertical;
    min-height: 72px;
}

/* Input group */
.module-page .modal-body .input-group-text {
    background-color: var(--bg-tertiary);
    border-color: var(--border-color);
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 600;
    border-radius: 8px 0 0 8px;
    padding: 0.5rem 0.7rem;
}
.module-page .modal-body .input-group .form-control {
    border-radius: 0 8px 8px 0;
}

/* Select2 inside modal */
.module-page .modal-body .select2-container--bootstrap-5 .select2-selection {
    border-radius: 8px !important;
    border-color: var(--border-color) !important;
    background-color: var(--bg-secondary) !important;
    font-size: 0.875rem;
    min-height: 38px;
}
.module-page .modal-body .select2-container--bootstrap-5.select2-container--focus .select2-selection,
.module-page .modal-body .select2-container--bootstrap-5.select2-container--open .select2-selection {
    border-color: var(--module-accent-strong-1, #3b82f6) !important;
    box-shadow: 0 0 0 3px var(--module-accent-soft-1, rgba(59, 130, 246, 0.15)) !important;
}

/* Footer button layout */
.module-page .modal-footer {
    gap: 0.55rem;
    flex-wrap: nowrap;
}
.module-page .modal-footer .btn {
    font-size: 0.85rem;
    font-weight: 600;
    padding: 0.48rem 1.15rem;
    border-radius: 8px;
    letter-spacing: 0.2px;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.module-page .modal-footer .btn-secondary,
.module-page .modal-footer .btn-outline-secondary {
    background: var(--bg-tertiary);
    border-color: var(--border-color);
    color: var(--text-secondary);
}
.module-page .modal-footer .btn-secondary:hover,
.module-page .modal-footer .btn-outline-secondary:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border-color: var(--border-color);
}

/* Dark mode form internals */
[data-theme="dark"] .module-page .modal-body .form-control,
[data-theme="dark"] .module-page .modal-body .form-select {
    background-color: rgba(15, 23, 42, 0.6);
    border-color: rgba(148, 163, 184, 0.18);
    color: var(--text-primary);
}
[data-theme="dark"] .module-page .modal-body .form-control:focus,
[data-theme="dark"] .module-page .modal-body .form-select:focus {
    background-color: rgba(15, 23, 42, 0.8);
    border-color: var(--module-accent-strong-1, #60a5fa);
}
[data-theme="dark"] .module-page .modal-body .input-group-text {
    background-color: rgba(30, 41, 59, 0.8);
    border-color: rgba(148, 163, 184, 0.18);
}
[data-theme="dark"] .module-page .modal-body .form-label {
    color: rgba(148, 163, 184, 0.85);
}
[data-theme="dark"] .module-page .modal-footer .btn-secondary,
[data-theme="dark"] .module-page .modal-footer .btn-outline-secondary {
    background: rgba(30, 41, 59, 0.7);
    border-color: rgba(148, 163, 184, 0.2);
    color: rgba(148, 163, 184, 0.9);
}

/* ============ PRINT STYLES ============ */
@media print {
    body::before {
        display: none;
    }
    
    .sidebar,
    .navbar,
    .btn,
    .app-footer {
        display: none !important;
    }
}