:root {
    /* ===== DESIGN TOKENS - Spacing Scale ===== */
    --space-0: 0;
    --space-1: 0.25rem;   /* 4px */
    --space-2: 0.5rem;    /* 8px */
    --space-3: 0.75rem;   /* 12px */
    --space-4: 1rem;      /* 16px */
    --space-5: 1.25rem;   /* 20px */
    --space-6: 1.5rem;    /* 24px */
    --space-8: 2rem;      /* 32px */
    --space-10: 2.5rem;   /* 40px */
    --space-12: 3rem;     /* 48px */
    --space-16: 4rem;     /* 64px */

    /* ===== Typography Scale ===== */
    --text-xs: 0.75rem;    /* 12px */
    --text-sm: 0.8125rem;  /* 13px */
    --text-base: 0.9375rem;/* 15px - optimized for readability */
    --text-md: 1rem;       /* 16px */
    --text-lg: 1.125rem;   /* 18px */
    --text-xl: 1.25rem;    /* 20px */
    --text-2xl: 1.5rem;    /* 24px */
    --text-3xl: 1.875rem;  /* 30px */

    /* Line Heights */
    --leading-none: 1;
    --leading-tight: 1.25;
    --leading-snug: 1.375;
    --leading-normal: 1.5;
    --leading-relaxed: 1.625;

    /* Font Weights */
    --font-normal: 400;
    --font-medium: 500;
    --font-semibold: 600;
    --font-bold: 700;

    /* ===== Color Palette - Light Theme ===== */
    --ink: #0f172a;
    --slate: #1e293b;
    --primary-color: #0d9488;
    --primary-hover: #0f766e;
    --primary-light: #ccfbf1;
    --primary-subtle: rgba(13, 148, 136, 0.08);
    --accent-color: #d97706;
    --accent-light: #fef3c7;
    --bg-subtle: #f1f5f9;
    --secondary-color: #64748b;

    /* Semantic Colors */
    --success-color: #059669;
    --success-light: #d1fae5;
    --success-muted: #10b981;
    --danger-color: #dc2626;
    --danger-light: #fee2e2;
    --danger-muted: #ef4444;
    --info-color: #0284c7;
    --info-light: #e0f2fe;
    --warning-color: #d97706;
    --warning-light: #fef3c7;

    /* ===== Backgrounds ===== */
    --bg-body: #f8fafc;
    --bg-surface: #ffffff;
    --bg-glass: rgba(255, 255, 255, 0.8);
    --bg-elevated: #ffffff;
    --bg-input: #ffffff;
    --bg-hover: rgba(13, 148, 136, 0.04);
    --bg-active: rgba(13, 148, 136, 0.08);
    --bg-skeleton: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);

    /* ===== Text Colors ===== */
    --text-main: #0f172a;
    --text-muted: #475569;
    --text-light: #64748b;
    --text-placeholder: #94a3b8;
    --text-inverse: #ffffff;

    /* ===== Borders & Shadows ===== */
    --border-color: rgba(15, 23, 42, 0.08);
    --border-color-strong: rgba(15, 23, 42, 0.16);
    --border-color-hover: rgba(13, 148, 136, 0.3);
    --border-width: 1px;
    --border-width-thick: 2px;

    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -1px rgba(0, 0, 0, 0.04);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -2px rgba(0, 0, 0, 0.04);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.08), 0 10px 10px -5px rgba(0, 0, 0, 0.03);
    --shadow-glow: 0 0 20px rgba(13, 148, 136, 0.2);
    --shadow-inner: inset 0 2px 4px 0 rgba(0, 0, 0, 0.04);

    /* ===== Border Radius ===== */
    --radius-sm: 0.375rem;  /* 6px */
    --radius-md: 0.5rem;    /* 8px */
    --radius-lg: 0.75rem;   /* 12px */
    --radius-xl: 1rem;      /* 16px */
    --radius-2xl: 1.25rem;  /* 20px */
    --radius-full: 9999px;

    /* ===== Fonts ===== */
    --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
    --font-heading: 'Space Grotesk', 'Inter', system-ui, sans-serif;
    --font-mono: 'SF Mono', 'Fira Code', monospace;

    /* ===== Transitions ===== */
    --transition-fast: all 0.15s ease;
    --transition-normal: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-bounce: all 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);

    /* ===== Focus & Accessibility ===== */
    --focus-ring: 0 0 0 3px rgba(13, 148, 136, 0.4);
    --focus-ring-offset: 0 0 0 2px var(--bg-body);
    --focus-ring-danger: 0 0 0 3px rgba(220, 38, 38, 0.3);

    /* Touch target minimum */
    --touch-target: 44px;
    --touch-target-sm: 36px;

    /* ===== Z-Index Scale ===== */
    --z-dropdown: 100;
    --z-sticky: 200;
    --z-fixed: 300;
    --z-modal-backdrop: 400;
    --z-modal: 500;
    --z-popover: 600;
    --z-tooltip: 700;
    --z-toast: 800;

    /* ===== Layout ===== */
    --bottom-nav-height: 64px;
    --header-height: 64px;
    --sidebar-width: 280px;
    --container-max: 1280px;
}

/* ===== DARK MODE ===== */
[data-theme="dark"] {
    /* Colors - Refined Dark Theme with better contrast */
    --ink: #f8fafc;
    --slate: #e2e8f0;
    --primary-color: #2dd4bf; /* brighter teal for dark mode visibility */
    --primary-hover: #5eead4;
    --primary-light: #134e4a;
    --primary-subtle: rgba(45, 212, 191, 0.12);
    --accent-color: #fbbf24;
    --accent-light: #451a03;
    --bg-subtle: #0f172a;
    --secondary-color: #94a3b8;
    --success-color: #34d399;
    --success-light: #064e3b;
    --danger-color: #f87171;
    --danger-light: #7f1d1d;
    --info-color: #60a5fa;
    --info-light: #1e3a8a;
    --warning-color: #fbbf24;
    --warning-light: #451a03;

    /* Backgrounds - Rich, deep tones */
    --bg-body: #0c1222;
    --bg-surface: rgba(30, 41, 59, 0.95);
    --bg-glass: rgba(30, 41, 59, 0.85);
    --bg-elevated: #1e293b;
    --bg-input: #1e293b;
    --bg-hover: rgba(45, 212, 191, 0.08);
    --bg-active: rgba(45, 212, 191, 0.15);

    /* Text - High contrast for readability */
    --text-main: #f1f5f9;
    --text-muted: #94a3b8;
    --text-light: #64748b;
    --text-inverse: #0f172a;

    /* Borders & Shadows - Subtle but visible */
    --border-color: rgba(148, 163, 184, 0.12);
    --border-color-strong: rgba(148, 163, 184, 0.22);
    --border-color-hover: rgba(45, 212, 191, 0.4);
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.2);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.25), 0 1px 2px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.35), 0 4px 6px -2px rgba(0, 0, 0, 0.2);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.4), 0 10px 10px -5px rgba(0, 0, 0, 0.2);
    --shadow-glow: 0 0 25px rgba(45, 212, 191, 0.3);
    --shadow-inner: inset 0 2px 4px 0 rgba(0, 0, 0, 0.2);

    /* Focus ring for dark mode */
    --focus-ring: 0 0 0 3px rgba(45, 212, 191, 0.5);
    --focus-ring-danger: 0 0 0 3px rgba(248, 113, 113, 0.4);
}

[data-theme="dark"] body {
    background-color: var(--bg-body);
}

[data-theme="dark"] .navbar {
    background: rgba(12, 18, 34, 0.92) !important;
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-bottom-color: var(--border-color);
    box-shadow: var(--shadow-md);
}

[data-theme="dark"] .nav-elevated {
    background: linear-gradient(180deg, rgba(15, 23, 42, 0.98) 0%, rgba(12, 18, 34, 0.95) 100%) !important;
    box-shadow: 0 4px 25px rgba(0, 0, 0, 0.4);
    border-bottom-color: var(--border-color);
}

[data-theme="dark"] .card {
    background: var(--bg-surface);
    border-color: var(--border-color);
    box-shadow: var(--shadow-sm);
}

[data-theme="dark"] .card:hover {
    border-color: var(--border-color-hover);
    box-shadow: var(--shadow-md);
}

[data-theme="dark"] .card-header {
    background: linear-gradient(180deg, rgba(30, 41, 59, 0.5), transparent);
}

[data-theme="dark"] .card-footer {
    background: linear-gradient(180deg, transparent, rgba(30, 41, 59, 0.5));
}

[data-theme="dark"] .form-control,
[data-theme="dark"] .form-select {
    background: var(--bg-input);
    border-color: var(--border-color-strong);
    color: var(--text-main);
}

[data-theme="dark"] .form-control:focus,
[data-theme="dark"] .form-select:focus {
    background: var(--bg-input);
    border-color: var(--primary-color);
    color: var(--text-main);
}

[data-theme="dark"] .form-control::placeholder {
    color: var(--text-light);
}

[data-theme="dark"] .table {
    /* Prevent Bootstrap tables from defaulting to white cell backgrounds in dark mode */
    --bs-table-bg: transparent;
    --bs-table-color: var(--text-main);
    --bs-table-border-color: var(--border-color);
}

[data-theme="dark"] .table-light {
    /* If used, keep "light" table variants readable in dark mode */
    --bs-table-bg: rgba(30, 41, 59, 0.75);
    --bs-table-color: var(--text-muted);
    --bs-table-border-color: var(--border-color);
}

[data-theme="dark"] .table thead th {
    background: rgba(30, 41, 59, 0.8);
    color: var(--text-muted);
    border-bottom-color: var(--border-color);
}

[data-theme="dark"] .table tbody td {
    border-bottom-color: var(--border-color);
    color: var(--text-main);
}

[data-theme="dark"] .table-hover tbody tr:hover {
    background-color: rgba(30, 41, 59, 0.6);
}

[data-theme="dark"] .table-striped tbody tr:nth-child(odd) {
    background-color: rgba(30, 41, 59, 0.4);
}

[data-theme="dark"] .list-group-item {
    background: transparent;
    border-color: var(--border-color);
    color: var(--text-main);
}

[data-theme="dark"] .list-group-item:hover {
    background: var(--primary-light);
}

[data-theme="dark"] .dropdown-menu {
    background: var(--bg-elevated);
    border-color: var(--border-color);
}

[data-theme="dark"] .dropdown-item {
    color: var(--text-main);
}

[data-theme="dark"] .dropdown-item:hover {
    background: rgba(148, 163, 184, 0.1);
    color: var(--text-main);
}

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

[data-theme="dark"] .btn-outline-secondary:hover {
    background: rgba(148, 163, 184, 0.15);
    border-color: var(--text-muted);
    color: var(--text-main);
}

[data-theme="dark"] .nav-user-pill {
    background: rgba(30, 41, 59, 0.8);
    border-color: var(--border-color);
}

[data-theme="dark"] .nav-icon:hover {
    border-color: var(--border-color);
    background: rgba(20, 184, 166, 0.08);
}

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

[data-theme="dark"] .text-dark {
    color: var(--text-main) !important;
}

[data-theme="dark"] .alert {
    background: var(--bg-elevated);
    border-color: var(--border-color);
    color: var(--text-main);
}

[data-theme="dark"] .mobile-user {
    background: rgba(30, 41, 59, 0.8);
}

[data-theme="dark"] .navbar-collapse {
    background: rgba(15, 23, 42, 0.98);
}

[data-theme="dark"] .page-header-sticky {
    background: var(--bg-body);
}

[data-theme="dark"] .toolbar {
    background: var(--bg-elevated);
    border-color: var(--border-color);
}

[data-theme="dark"] .panel-subtle {
    background: transparent;
    border-color: var(--border-color);
}

[data-theme="dark"] .kanban-task {
    background: var(--bg-elevated);
    border-color: var(--border-color);
}

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

/* Kanban dark mode colors */
[data-theme="dark"] .kanban-todo .card-header {
    color: var(--text-main);
    background: linear-gradient(135deg, rgba(100, 116, 139, 0.15), rgba(100, 116, 139, 0.08));
    border-bottom-color: rgba(100, 116, 139, 0.3);
}
[data-theme="dark"] .kanban-todo .card-body {
    background: rgba(30, 41, 59, 0.6);
}

[data-theme="dark"] .kanban-in_progress .card-header {
    color: #fbbf24;
    background: linear-gradient(135deg, rgba(251, 191, 36, 0.18), rgba(251, 191, 36, 0.08));
    border-bottom-color: rgba(251, 191, 36, 0.35);
}
[data-theme="dark"] .kanban-in_progress .card-body {
    background: rgba(120, 53, 15, 0.15);
}

[data-theme="dark"] .kanban-done .card-header {
    color: #34d399;
    background: linear-gradient(135deg, rgba(52, 211, 153, 0.18), rgba(52, 211, 153, 0.08));
    border-bottom-color: rgba(52, 211, 153, 0.35);
}
[data-theme="dark"] .kanban-done .card-body {
    background: rgba(5, 46, 22, 0.2);
}

[data-theme="dark"] .auth-page {
    background: radial-gradient(circle at 15% 20%, rgba(34, 197, 94, 0.14), transparent 32%),
        radial-gradient(circle at 85% 80%, rgba(14, 165, 233, 0.12), transparent 30%),
        var(--bg-body);
}

[data-theme="dark"] .auth-showcase {
    background: linear-gradient(145deg, rgba(13, 148, 136, 0.2), rgba(15, 23, 42, 0.6));
    border-color: var(--border-color);
}

[data-theme="dark"] .auth-chip {
    background: rgba(15, 23, 42, 0.7);
}

[data-theme="dark"] .auth-card-modern {
    background: rgba(15, 23, 42, 0.96);
    border-color: var(--border-color);
}

[data-theme="dark"] .auth-tag {
    background: rgba(15, 23, 42, 0.85);
}

[data-theme="dark"] .input-flat {
    background: rgba(15, 23, 42, 0.9) !important;
    box-shadow: inset 0 0 0 1px var(--border-color);
}

[data-theme="dark"] .form-actions-sticky {
    background: rgba(15, 23, 42, 0.95);
    border-top-color: var(--border-color);
}

[data-theme="dark"] .stat-value {
    background: linear-gradient(135deg, var(--text-main), var(--text-muted));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

[data-theme="dark"] .bottom-nav {
    background: rgba(12, 18, 34, 0.96);
    border-top-color: var(--border-color);
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .bottom-nav-item:hover,
[data-theme="dark"] .bottom-nav-item:focus {
    background: var(--bg-hover);
    color: var(--primary-color);
}

[data-theme="dark"] .bottom-nav-item.active {
    color: var(--primary-color);
}

[data-theme="dark"] .bottom-nav-item.active::after {
    background: var(--primary-color);
}

[data-theme="dark"] .bottom-nav-menu {
    background: var(--bg-elevated);
    border-color: var(--border-color);
    box-shadow: var(--shadow-lg);
}

[data-theme="dark"] .bottom-nav-menu-item:hover {
    background: var(--bg-hover);
    color: var(--primary-color);
}

[data-theme="dark"] ::-webkit-scrollbar-thumb {
    background: #475569;
}

[data-theme="dark"] ::-webkit-scrollbar-thumb:hover {
    background: #64748b;
}

body {
    font-family: var(--font-sans);
    background-color: #f4f5f7;
    color: var(--text-main);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    font-family: var(--font-heading);
    font-weight: 700;
    color: var(--text-main);
    letter-spacing: -0.02em;
    margin-bottom: 0.75rem;
}

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

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

/* Glassmorphism Utilities */
.glass {
    background: var(--bg-surface);
    backdrop-filter: blur(16px) saturate(180%);
    -webkit-backdrop-filter: blur(16px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.glass-hover:hover {
    background: rgba(255, 255, 255, 0.95);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

[data-theme="dark"] .glass {
    background: var(--bg-surface);
    border-color: var(--border-color);
}

[data-theme="dark"] .glass-hover:hover {
    background: rgba(30, 41, 59, 0.95);
}

/* Offline state banner */
.offline-banner {
    display: none;
    position: sticky;
    top: 0;
    z-index: 1055;
    background: #fef3c7;
    color: #92400e;
    padding: 0.6rem 1rem;
    text-align: center;
    font-weight: 600;
    border-bottom: 1px solid var(--border-color);
}

.offline-banner.show {
    display: block;
}

[data-theme="dark"] .offline-banner {
    background: rgba(251, 191, 36, 0.12);
    color: #fde68a;
    border-color: rgba(251, 191, 36, 0.35);
}

/* Navigation - Enhanced for both themes */
.navbar {
    background: rgba(255, 255, 255, 0.92) !important;
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-bottom: 1px solid var(--border-color);
    padding: 0.85rem 0;
    box-shadow: var(--shadow-sm);
    transition: var(--transition-normal);
}

.nav-elevated {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.98) 0%, rgba(248, 250, 252, 0.95) 100%) !important;
    box-shadow: 0 4px 20px rgba(15, 23, 42, 0.06);
    border-bottom: 1px solid rgba(15, 23, 42, 0.06);
}

.subnav {
    border-bottom: 1px solid var(--border-color);
    background: #f8fafc;
}

.subnav-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.75rem 0;
}

.subnav-tabs {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.subnav-link {
    padding: 0.45rem 0.85rem;
    border-radius: 999px;
    font-weight: 600;
    color: var(--text-muted);
    border: 1px solid transparent;
}

.subnav-link.active {
    color: var(--primary-color);
    background: rgba(13, 148, 136, 0.08);
    border-color: rgba(13, 148, 136, 0.25);
}

.subnav-link.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.subnav-actions {
    display: inline-flex;
    gap: 0.5rem;
    align-items: center;
}

.nav-container {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.35rem;
    max-width: 1320px;
}

.nav-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    gap: 1rem;
}

.nav-shell {
    width: 100%;
}

.nav-rail {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    width: 100%;
}

@media (min-width: 768px) {
    .nav-rail {
        flex-direction: row;
        align-items: center;
        gap: 0.85rem;
    }
}

.nav-utility {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.nav-utility-desktop {
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: 0.3rem 0.5rem;
    box-shadow: var(--shadow-sm);
}

.nav-utility-mobile {
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 0.5rem;
    box-shadow: var(--shadow-sm);
}

.nav-pill-track {
    flex: 1;
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: 0.35rem 0.45rem;
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
}

.nav-pills-scroll {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    overflow-x: auto;
    scrollbar-width: thin;
    scroll-snap-type: x mandatory;
    padding-right: 0.5rem;
}

.nav-pills-scroll::-webkit-scrollbar {
    height: 6px;
}

.nav-pills-scroll::-webkit-scrollbar-thumb {
    background: rgba(15, 23, 42, 0.15);
    border-radius: 999px;
}

[data-theme="dark"] .nav-pills-scroll::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.3);
}

.app-nav .nav-links .nav-link {
    padding-left: 0.7rem !important;
    padding-right: 0.7rem !important;
}

.app-nav .navbar-toggler {
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 0.45rem 0.6rem;
    background: white;
}

.app-nav .navbar-collapse {
    padding-top: 0.25rem;
}

.mobile-user {
    background: #f8fafc;
    border-radius: var(--radius-md);
    padding: 0.5rem 0.75rem;
    margin-top: 0.5rem;
}

.navbar-brand {
    font-weight: 800;
    font-size: 1.5rem;
    color: var(--text-main) !important;
    letter-spacing: -0.03em;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.brand-logo {
    height: 40px;
    width: auto;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

.nav-links {
    gap: 0.25rem;
    flex-wrap: nowrap;
}

.nav-link {
    color: var(--text-muted) !important;
    font-weight: 600;
    padding: 0.55rem 0.95rem !important;
    border-radius: 12px;
    transition: var(--transition-fast);
    font-size: 0.95rem;
    position: relative;
    border: 1px solid transparent;
    scroll-snap-align: start;
    white-space: nowrap;
}

.nav-link:hover,
.nav-link.active {
    color: var(--primary-color) !important;
    background: rgba(13, 148, 136, 0.08);
    border-color: rgba(13, 148, 136, 0.2);
}

.nav-link.active::after {
    display: none;
}

.nav-icon {
    width: 38px;
    height: 38px;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    border: 1px solid transparent;
}

.nav-icon:hover {
    border-color: var(--border-color);
    background: rgba(13, 148, 136, 0.06);
}

.nav-user-pill {
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 0.35rem 0.6rem !important;
    background: rgba(248, 250, 252, 0.9);
}

/* Cards - Enhanced with better depth and aesthetics */
.card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    transition: var(--transition-normal);
    overflow: hidden;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

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

.card-header {
    background: linear-gradient(180deg, rgba(248, 250, 252, 0.5), transparent);
    border-bottom: 1px solid var(--border-color);
    padding: 1.25rem 1.5rem;
    font-weight: 600;
    font-size: 1.05rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--text-main);
}

.card-body {
    padding: 1.5rem;
}

.card-footer {
    background: linear-gradient(180deg, transparent, rgba(248, 250, 252, 0.5));
    border-top: 1px solid var(--border-color);
    padding: 1rem 1.5rem;
}

/* Card variants */
.card-flat {
    box-shadow: none;
    border-color: var(--border-color-strong);
}

.card-flat:hover {
    box-shadow: var(--shadow-sm);
}

/* Stats Cards */
.stat-card {
    position: relative;
    overflow: hidden;
}

.badge-status {
    padding: 0.35rem 0.75rem;
    border-radius: 999px;
    font-weight: 700;
    letter-spacing: 0.01em;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.06);
}

.badge-won {
    background: rgba(15, 159, 103, 0.14);
    color: #0b4f37;
    border: 1px solid rgba(15, 159, 103, 0.45);
}

.badge-lost {
    background: rgba(225, 29, 72, 0.14);
    color: #7a102c;
    border: 1px solid rgba(225, 29, 72, 0.45);
}

.badge-discussion {
    background: rgba(214, 167, 91, 0.2);
    color: #8a5a16;
    border: 1px solid rgba(214, 167, 91, 0.5);
}

.badge-new {
    background: rgba(59, 130, 246, 0.14);
    color: #1e3a8a;
    border: 1px solid rgba(59, 130, 246, 0.45);
}

.btn-convert {
    background: linear-gradient(135deg, #0f766e, #0ea371);
    color: #fff;
    border: none;
    box-shadow: 0 8px 18px rgba(14, 163, 113, 0.25);
}

.btn-convert:hover {
    background: linear-gradient(135deg, #0d5f59, #0c9a64);
    color: #fff;
}

.btn-converted,
.btn-locked {
    background: #f4f4f5;
    color: #6b7280;
    border: 1px solid #e5e7eb;
    cursor: not-allowed;
    box-shadow: none;
}

/* Global button tweaks */
.btn-primary {
    background: linear-gradient(135deg, #0f766e, #0d9488);
    border: none;
    box-shadow: 0 10px 20px rgba(13, 148, 136, 0.18);
}

.btn-primary:hover {
    background: linear-gradient(135deg, #0d5f59, #0b8a7c);
}

.btn-outline-secondary {
    border-color: #cbd5e1;
    color: #334155;
}

.btn-outline-secondary:hover {
    background: #f1f5f9;
    color: #111827;
}

thead th {
    color: #334155;
    font-weight: 700;
    letter-spacing: 0.01em;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
}

table.table tr:hover {
    background: rgba(8, 145, 178, 0.04);
}

table td {
    vertical-align: middle;
}

.page-shell {
    background: transparent;
    border: none;
    border-radius: 0;
    padding: 0;
    box-shadow: none;
    max-width: 1280px;
    width: 100%;
    margin: 1.25rem auto 0 auto;
}
.page-shell > * + * {
    margin-top: 1rem;
}

.section-title {
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 0.9rem;
    color: var(--text-muted);
}

input.form-control,
select.form-select,
textarea.form-control {
    border-radius: var(--radius-md);
    border: 1px solid #e2e8f0;
    padding: 0.65rem 0.8rem;
    transition: var(--transition-fast);
}

input.form-control:focus,
select.form-select:focus,
textarea.form-control:focus {
    border-color: rgba(13, 148, 136, 0.5);
    box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.15);
}

/* Ensure date inputs stay visible in both themes */
input[type="date"],
input[type="date"].form-control {
    background: var(--bg-input);
    color: var(--text-main);
    border: 1px solid var(--border-color-strong);
    border-radius: var(--radius-md);
    /* Force appropriate native UI/icon colors regardless of OS theme */
    color-scheme: light;
    padding-right: 2.75rem;
    background-image: url("data:image/svg+xml,%3Csvg%20xmlns%3D%27http%3A//www.w3.org/2000/svg%27%20width%3D%2720%27%20height%3D%2720%27%20viewBox%3D%270%200%2024%2024%27%20fill%3D%27none%27%20stroke%3D%27%23334155%27%20stroke-width%3D%272%27%20stroke-linecap%3D%27round%27%20stroke-linejoin%3D%27round%27%3E%3Crect%20x%3D%273%27%20y%3D%274%27%20width%3D%2718%27%20height%3D%2718%27%20rx%3D%272%27%20ry%3D%272%27/%3E%3Cline%20x1%3D%278%27%20y1%3D%272%27%20x2%3D%278%27%20y2%3D%276%27/%3E%3Cline%20x1%3D%2716%27%20y1%3D%272%27%20x2%3D%2716%27%20y2%3D%276%27/%3E%3Cline%20x1%3D%273%27%20y1%3D%2710%27%20x2%3D%2721%27%20y2%3D%2710%27/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.9rem center;
    background-size: 18px 18px;
}

input[type="date"]:focus,
input[type="date"].form-control:focus {
    border-color: rgba(13, 148, 136, 0.5);
    box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.15);
}

input[type="date"]::-webkit-calendar-picker-indicator {
    opacity: 0;
    cursor: pointer;
}

[data-theme="dark"] input[type="date"] {
    border-color: var(--border-color-strong);
    color-scheme: dark;
    background-image: url("data:image/svg+xml,%3Csvg%20xmlns%3D%27http%3A//www.w3.org/2000/svg%27%20width%3D%2720%27%20height%3D%2720%27%20viewBox%3D%270%200%2024%2024%27%20fill%3D%27none%27%20stroke%3D%27%23e2e8f0%27%20stroke-width%3D%272%27%20stroke-linecap%3D%27round%27%20stroke-linejoin%3D%27round%27%3E%3Crect%20x%3D%273%27%20y%3D%274%27%20width%3D%2718%27%20height%3D%2718%27%20rx%3D%272%27%20ry%3D%272%27/%3E%3Cline%20x1%3D%278%27%20y1%3D%272%27%20x2%3D%278%27%20y2%3D%276%27/%3E%3Cline%20x1%3D%2716%27%20y1%3D%272%27%20x2%3D%2716%27%20y2%3D%276%27/%3E%3Cline%20x1%3D%273%27%20y1%3D%2710%27%20x2%3D%2721%27%20y2%3D%2710%27/%3E%3C/svg%3E");
}

[data-theme="dark"] input[type="date"]::-webkit-calendar-picker-indicator {
    filter: invert(1);
}

.table > :not(caption) > * > * {
    padding: 0.9rem 0.75rem;
}

.table-responsive {
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.page-header .actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.page-header-sticky {
    position: sticky;
    top: 72px;
    z-index: 8;
    padding: 0.35rem 0;
    background: #f4f5f7;
}

.filter-toggle {
    display: none;
}

.filter-collapse {
    transition: height 0.2s ease;
}

.table-stack {
    border: none;
}

@media (max-width: 768px) {
    .table-stack thead {
        display: none;
    }
    .table-stack tbody {
        display: grid;
        gap: 0.75rem;
        width: 100%;
    }
    .table-stack tr {
        display: grid;
        gap: 0.35rem;
        padding: 0.85rem 0.9rem;
        background: var(--bg-surface);
        border: 1px solid var(--border-color);
        border-radius: var(--radius-lg);
        box-shadow: var(--shadow-sm);
        width: 100%;
        box-sizing: border-box;
    }
    .table-stack td {
        display: flex;
        align-items: flex-start;
        justify-content: space-between;
        gap: 0.75rem;
        padding: 0.15rem 0;
        border: 0;
        min-width: 0;
        overflow-wrap: anywhere;
    }
    .table-stack td::before {
        content: attr(data-label);
        font-size: 0.78rem;
        color: var(--text-muted);
        font-weight: 700;
        letter-spacing: 0.02em;
    }
    .table-stack td.text-end {
        justify-content: flex-end;
    }
    .stack-inline {
        display: flex;
        gap: 0.5rem;
        flex-wrap: wrap;
    }
    .filter-toggle {
        display: block;
    }
    .page-header-sticky {
        top: 64px;
    }
}

.layout-duo {
    display: grid;
    grid-template-columns: 1.5fr 1fr;
    gap: 1.5rem;
    align-items: start;
}

.eyebrow {
    letter-spacing: 0.08em;
    font-size: 0.72rem;
    text-transform: uppercase;
    color: var(--text-light);
    font-weight: 700;
}

.searchbar {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 0.35rem 0.35rem 0.35rem 0.75rem;
    box-shadow: var(--shadow-sm);
    min-width: 260px;
}

.searchbar .form-control {
    border: none;
    background: transparent;
    padding-left: 0;
    box-shadow: none;
}

.searchbar .form-control:focus {
    box-shadow: none;
}

.client-grid {
    display: grid;
    gap: 1rem;
}

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

.client-card {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    background: var(--bg-elevated);
    box-shadow: var(--shadow-sm);
    padding: 1rem 1.1rem;
    transition: var(--transition-normal);
}

.client-card:hover {
    border-color: rgba(13, 148, 136, 0.35);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.client-avatar {
    width: 46px;
    height: 46px;
    border-radius: 12px;
    background: linear-gradient(135deg, #0d9488, #0f766e);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-family: var(--font-heading);
}

.client-name {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1rem;
    color: var(--ink);
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem 0.65rem;
    border-radius: 999px;
    font-size: 0.82rem;
    font-weight: 600;
}

.chip-soft {
    background: var(--primary-light);
    color: var(--primary-color);
    border: 1px solid rgba(13, 148, 136, 0.18);
}

.chip-ghost {
    background: transparent;
    color: var(--text-muted);
    border: 1px dashed var(--border-color);
}

.chip-warning {
    background: #fef3c7;
    color: #92400e;
    border: 1px solid rgba(234, 179, 8, 0.35);
}

.client-form-shell {
    position: sticky;
    top: 96px;
}

.client-form-card {
    border: 1px solid rgba(13, 148, 136, 0.12);
    background: linear-gradient(180deg, rgba(13, 148, 136, 0.06), rgba(13, 148, 136, 0.02));
}

.client-form-card .form-control {
    background: var(--bg-input);
}

.client-form-card .btn-primary {
    box-shadow: var(--shadow-glow);
}

.client-directory .panel-subtle {
    border-style: dashed;
}

.client-layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
}

.client-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 0.5rem;
}

.stat-pill {
    padding: 0.65rem 0.75rem;
    border: 1px dashed var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-surface);
}

.stat-pill .label {
    font-size: 0.75rem;
    color: var(--text-light);
    letter-spacing: 0.01em;
}

.stat-pill .value {
    font-weight: 700;
    color: var(--ink);
}

.finance-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.75rem;
}

.finance-summary .stat-pill {
    border-style: solid;
    box-shadow: var(--shadow-sm);
}

.btn-soft {
    background: rgba(13, 148, 136, 0.08);
    color: var(--primary-color);
    border: 1px solid rgba(13, 148, 136, 0.16);
}

.btn-soft:hover {
    background: rgba(13, 148, 136, 0.12);
    color: var(--primary-hover);
}

.txn-cards {
    display: grid;
    gap: 1rem;
    grid-template-columns: 1fr;
    width: 100%;
}

.txn-card {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    background: var(--bg-surface);
    box-shadow: var(--shadow-sm);
    padding: 1rem;
}

.txn-card__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.txn-card__item {
    flex: 1 1 0;
}

.txn-card__item--amount {
    flex: 0 0 auto;
    min-width: 120px;
}

.txn-date {
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.txn-amount {
    font-weight: 700;
    font-size: 1.05rem;
    white-space: nowrap;
    text-align: right;
}

.txn-title {
    font-weight: 700;
    margin-bottom: 0.35rem;
    word-break: break-word;
}

.txn-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.txn-meta .chip {
    border-radius: var(--radius-full);
    padding: 0.2rem 0.6rem;
    font-size: 0.8rem;
}

.form-section {
    border-style: dashed;
}

.toolbar.soft {
    background: #f8fafc;
    border: 1px dashed var(--border-color);
}

.filter-chip .form-check-input {
    margin-top: 0;
}

.filter-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.85rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    background: var(--bg-elevated);
    box-shadow: var(--shadow-sm);
    margin-bottom: 1rem;
}

.filter-bar .chip {
    margin: 0;
}

.fab-add {
    position: fixed;
    bottom: 96px;
    right: 24px;
    z-index: 30;
    border-radius: 999px;
    box-shadow: var(--shadow-lg);
    padding: 0.9rem 1.1rem;
}

.modal-elevated .modal-content {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: 0 24px 64px rgba(15, 23, 42, 0.18);
    z-index: 9999;
}

.offcanvas:not(.show) {
    pointer-events: none;
}

.modal-sheet .modal-dialog {
    margin: 0 auto;
    height: 100%;
    display: flex;
    align-items: flex-end;
    max-width: 560px;
    width: 100%;
}

.modal-sheet .modal-content {
    border-radius: 16px 16px 0 0;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-lg);
}

.modal-sheet .modal-body {
    padding-bottom: 1.5rem;
}

@media (min-width: 768px) {
    .modal-sheet .modal-dialog {
        align-items: center;
        height: auto;
    }

    .modal-sheet .modal-content {
        border-radius: var(--radius-lg);
    }
}

.modal-elevated .form-control,
.modal-elevated .form-select {
    border-radius: var(--radius-md);
    border-color: var(--border-color);
}

.modal-elevated .form-control:focus,
.modal-elevated .form-select:focus {
    border-color: var(--primary-color);
    box-shadow: var(--focus-ring);
}

.modal-elevated .card.form-section {
    border: 1px dashed var(--border-color);
    background: var(--bg-surface);
}
.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.stat-tile {
    padding: 0.9rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    background: var(--bg-elevated);
    box-shadow: var(--shadow-sm);
}

.stat-tile .label {
    font-size: 0.8rem;
    color: var(--text-light);
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.stat-tile .value {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--ink);
}

.stat-tile.action {
    display: flex;
    flex-direction: column;
    justify-content: center;
}

@media (max-width: 768px) {
    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }
    .searchbar {
        width: 100%;
    }
    .filter-bar {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    .filter-bar form {
        width: 100%;
        gap: 0.5rem;
    }
    .filter-bar .chip {
        width: auto;
    }
    .summary-grid {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    }
    .client-card {
        width: 100%;
    }
    .offcanvas-end.offcanvas-glow {
        width: 100%;
        max-width: none;
    }
    .fab-add {
        right: 16px;
        bottom: 80px;
    }
}

.table th,
.table td {
    vertical-align: middle;
}

.table-sort {
    color: inherit;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    text-decoration: none;
    white-space: nowrap;
}

.table-sort:hover {
    text-decoration: underline;
}

.sort-indicator {
    font-size: 0.8em;
    opacity: 0.45;
}

.sort-indicator.active {
    opacity: 0.9;
}

.table-striped tbody tr:nth-child(odd) {
    background-color: #f8fafc;
}

.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    background: #fff;
    margin-bottom: 0.75rem;
}

.toolbar .actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.kanban-board {
    display: flex;
    gap: 1rem;
    overflow-x: auto;
    padding-bottom: 0.5rem;
    scroll-snap-type: x proximity;
}

.kanban-column {
    min-width: 260px;
    flex: 0 0 280px;
    scroll-snap-align: start;
}

.kanban-col {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

/* Kanban column status colors - Light theme */
.kanban-todo .card-header {
    color: var(--text-main);
    background: linear-gradient(135deg, rgba(100, 116, 139, 0.08), rgba(100, 116, 139, 0.04));
    border-bottom: 2px solid rgba(100, 116, 139, 0.2);
}
.kanban-todo .card-body {
    background: rgba(248, 250, 252, 0.8);
}

.kanban-in_progress .card-header {
    color: #b45309;
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.12), rgba(245, 158, 11, 0.06));
    border-bottom: 2px solid rgba(245, 158, 11, 0.3);
}
.kanban-in_progress .card-body {
    background: rgba(255, 251, 235, 0.8);
}

.kanban-done .card-header {
    color: #047857;
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.12), rgba(16, 185, 129, 0.06));
    border-bottom: 2px solid rgba(16, 185, 129, 0.3);
}
.kanban-done .card-body {
    background: rgba(236, 253, 245, 0.8);
}

/* WIP limit exceeded highlight */
.kanban-wip-exceeded .card-header {
    background: rgba(239, 68, 68, 0.12) !important;
    border-bottom-color: #ef4444 !important;
    color: #b91c1c !important;
}

/* Kanban task card */
.kanban-task {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.85rem;
    background: var(--bg-elevated);
    box-shadow: var(--shadow-sm);
    transition: var(--transition-fast);
}

.kanban-task:hover {
    border-color: var(--border-color-hover);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.kanban-task.dragging {
    opacity: 0.6;
    cursor: grabbing;
    transform: scale(0.98);
}

.kanban-overdue {
    border-left: 4px solid #ef4444;
    background: rgba(239, 68, 68, 0.04);
}

.kanban-dropzone.dragover {
    outline: 2px dashed var(--border-color-hover);
    outline-offset: -6px;
    background: rgba(59, 130, 246, 0.04);
}

.nav-search-input {
    width: 220px;
    border-radius: 999px;
    background: var(--bg-subtle);
    border: 1px solid var(--border-color);
    padding-left: 0.75rem;
}

.nav-search-input:focus {
    background: var(--bg-elevated);
}

.panel-subtle {
    background: transparent;
    border: 1px solid #e2e8f0;
    border-radius: var(--radius-lg);
    box-shadow: none;
}

.panel-subtle .card-body {
    padding: 1rem 1.25rem;
}

@media (max-width: 992px) {
    .page-shell {
        padding: 1rem;
    }
    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }
    .page-header .actions {
        width: 100%;
        justify-content: flex-start;
    }
.navbar .dropdown-menu {
    border-radius: var(--radius-md);
}
    .navbar .nav-link {
        padding: 0.5rem 0.75rem !important;
    }
    .layout-duo {
        grid-template-columns: 1fr;
    }
    .navbar .nav-link {
        padding: 0.5rem 0.75rem !important;
    }
    .table-responsive {
        border-radius: var(--radius-md);
    }
    .table > :not(caption) > * > * {
        padding: 0.75rem 0.65rem;
    }
    .client-form-shell {
        position: static;
    }
    .subnav-inner {
        flex-wrap: wrap;
    }
    .toolbar.soft {
        flex-direction: column;
        align-items: flex-start;
    }
}

@media (max-width: 640px) {
    body {
        background-size: auto;
    }
    .page-shell {
        border: none;
        box-shadow: none;
        padding: 0.75rem;
    }
    .navbar {
        padding: 0.5rem 0;
    }
    .navbar-collapse {
        background: rgba(255,255,255,0.96);
        padding: 0.75rem 0.5rem 0.5rem;
        border: 1px solid var(--border-color);
        border-radius: 14px;
        box-shadow: var(--shadow-sm);
        margin-top: 0.75rem;
    }
    h1, h2, h3 {
        margin-bottom: 0.5rem;
    }
    .btn {
        font-size: 0.95rem;
    }
    .searchbar {
        width: 100%;
    }
}

[data-theme="dark"] .client-card {
    background: var(--bg-surface);
    border-color: var(--border-color);
}

[data-theme="dark"] .client-card:hover {
    border-color: rgba(20, 184, 166, 0.35);
}

[data-theme="dark"] .client-form-card {
    border-color: rgba(20, 184, 166, 0.25);
    background: linear-gradient(180deg, rgba(20, 184, 166, 0.1), rgba(20, 184, 166, 0.03));
}
[data-theme="dark"] .subnav {
    background: #0f172a;
    border-bottom-color: var(--border-color);
}

[data-theme="dark"] .stat-pill {
    background: rgba(30, 41, 59, 0.85);
    border-color: var(--border-color);
}

[data-theme="dark"] .toolbar.soft {
    background: rgba(30, 41, 59, 0.8);
    border-color: var(--border-color);
}

[data-theme="dark"] .btn-soft {
    background: rgba(20, 184, 166, 0.12);
    color: var(--primary-hover);
    border-color: rgba(20, 184, 166, 0.25);
}
.stat-card::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 100px;
    height: 100px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.4), transparent);
    border-radius: 50%;
    transform: translate(30%, -30%);
}

.stat-value {
    font-size: 2.5rem;
    font-weight: 800;
    letter-spacing: -0.05em;
    background: linear-gradient(135deg, var(--text-main), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0.25rem;
}

.stat-label {
    text-transform: uppercase;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    color: var(--text-muted);
}

/* Lists & Tables */
.list-group-item {
    background: transparent;
    border-color: var(--border-color);
    padding: 1rem 1.5rem;
    transition: var(--transition-fast);
}

.list-group-item:hover {
    background: var(--primary-light);
}

.table {
    margin-bottom: 0;
}

.table thead th {
    background: rgba(248, 250, 252, 0.5);
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    border-bottom: 2px solid var(--border-color);
    padding: 1rem 1.5rem;
}

.table tbody td {
    padding: 1rem 1.5rem;
    vertical-align: middle;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-main);
    font-weight: 500;
}

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

/* Buttons - Refined styling */
.btn {
    padding: 0.6rem 1.2rem;
    border-radius: var(--radius-md);
    font-weight: 600;
    letter-spacing: 0.01em;
    transition: var(--transition-fast);
    border: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-hover));
    color: white;
    box-shadow: 0 2px 8px rgba(13, 148, 136, 0.25);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(13, 148, 136, 0.35);
    background: linear-gradient(135deg, var(--primary-hover), var(--primary-color));
    color: white;
}

.btn-primary:active {
    transform: translateY(0);
    box-shadow: 0 2px 6px rgba(13, 148, 136, 0.25);
}

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

.btn-secondary:hover {
    background: var(--slate);
    color: white;
}

.btn-success {
    background: linear-gradient(135deg, var(--success-color), #10b981);
    color: white;
    box-shadow: 0 2px 8px rgba(5, 150, 105, 0.25);
}

.btn-success:hover {
    box-shadow: 0 4px 12px rgba(5, 150, 105, 0.35);
    color: white;
}

.btn-danger {
    background: linear-gradient(135deg, var(--danger-color), #ef4444);
    color: white;
    box-shadow: 0 2px 8px rgba(220, 38, 38, 0.25);
}

.btn-danger:hover {
    box-shadow: 0 4px 12px rgba(220, 38, 38, 0.35);
    color: white;
}

.btn-outline-primary {
    background: transparent;
    border: 1.5px solid var(--primary-color);
    color: var(--primary-color);
}

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

.btn-outline-secondary {
    background: var(--bg-elevated);
    border: 1px solid var(--border-color-strong);
    color: var(--text-main);
}

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

.btn-outline-danger {
    background: transparent;
    border: 1.5px solid var(--danger-color);
    color: var(--danger-color);
}

.btn-outline-danger:hover {
    background: var(--danger-light);
    color: var(--danger-color);
}

/* Dark mode button adjustments */
[data-theme="dark"] .btn-primary {
    box-shadow: 0 2px 10px rgba(45, 212, 191, 0.3);
}

[data-theme="dark"] .btn-primary:hover {
    box-shadow: 0 4px 15px rgba(45, 212, 191, 0.4);
}

[data-theme="dark"] .btn-outline-secondary {
    background: var(--bg-surface);
    border-color: var(--border-color-strong);
}

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

/* Forms - Enhanced styling for better UX */
.form-control,
.form-select {
    background: var(--bg-input);
    border: 1px solid var(--border-color-strong);
    border-radius: var(--radius-md);
    padding: 0.7rem 0.9rem;
    font-size: 0.95rem;
    transition: var(--transition-fast);
    box-shadow: var(--shadow-inner);
    color: var(--text-main);
}

.form-control::placeholder {
    color: var(--text-light);
    opacity: 0.8;
}

/* File inputs */
.form-control[type="file"] {
    color: var(--text-main);
    padding: 0.45rem 0.65rem;
}

.form-control[type="file"]::file-selector-button {
    margin-right: 0.75rem;
    border: 1px solid var(--border-color-strong);
    border-radius: var(--radius-md);
    background: var(--bg-subtle);
    color: var(--text-main);
    padding: 0.4rem 0.85rem;
    transition: var(--transition-fast);
    cursor: pointer;
}

.form-control[type="file"]::-webkit-file-upload-button {
    margin-right: 0.75rem;
    border: 1px solid var(--border-color-strong);
    border-radius: var(--radius-md);
    background: var(--bg-subtle);
    color: var(--text-main);
    padding: 0.4rem 0.85rem;
    transition: var(--transition-fast);
    cursor: pointer;
}

.form-control[type="file"]:hover::file-selector-button,
.form-control[type="file"]:hover::-webkit-file-upload-button {
    background: var(--bg-hover);
    border-color: var(--border-color-hover);
}

.form-control[type="file"]:focus::file-selector-button,
.form-control[type="file"]:focus::-webkit-file-upload-button {
    border-color: var(--primary-color);
}

.form-control:hover,
.form-select:hover {
    border-color: var(--secondary-color);
}

.form-control:focus,
.form-select:focus {
    border-color: var(--primary-color);
    box-shadow: var(--focus-ring);
    background: var(--bg-input);
    outline: none;
}

/* Form labels */
.form-label {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-main);
    margin-bottom: 0.5rem;
}

.form-actions-sticky {
    position: sticky;
    bottom: 0;
    padding: 0.75rem 0;
    background: rgba(255, 255, 255, 0.94);
    backdrop-filter: blur(8px);
    border-top: 1px solid var(--border-color);
    margin-top: 1rem;
}

/* Badges */
.badge {
    padding: 0.5em 0.8em;
    font-weight: 600;
    border-radius: 2rem;
    letter-spacing: 0.02em;
}

.bg-primary {
    background-color: var(--primary-color) !important;
}

.bg-success {
    background-color: var(--success-color) !important;
}

.bg-warning {
    background-color: var(--accent-color) !important;
}

.bg-danger {
    background-color: var(--danger-color) !important;
}

/* Utilities */
.text-primary {
    color: var(--primary-color) !important;
}

.text-success {
    color: var(--success-color) !important;
}

.text-warning {
    color: var(--accent-color) !important;
}

.text-danger {
    color: var(--danger-color) !important;
}

.shadow-glow {
    box-shadow: var(--shadow-glow);
}

.page-shell {
    max-width: 1280px;
    padding: 0 1.5rem 4rem;
}

/* Animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-fade-in {
    animation: fadeInUp 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* Auth Pages */
.auth-shell {
    padding: 0;
    margin: 0;
    max-width: none;
}

.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    padding: clamp(2rem, 3vw, 3rem) clamp(1.25rem, 2vw, 2rem);
    background: radial-gradient(circle at 20% 20%, rgba(16, 185, 129, 0.08), transparent 35%),
        radial-gradient(circle at 85% 80%, rgba(14, 165, 233, 0.08), transparent 32%),
        linear-gradient(135deg, rgba(15, 23, 42, 0.02), rgba(13, 148, 136, 0.03)),
        var(--bg-body);
}

.auth-page-minimal {
    background: var(--bg-body);
    justify-content: center;
}

.auth-card-minimal {
    width: 100%;
    max-width: 440px;
    margin: 0 auto;
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 2.25rem 2.25rem 1.75rem;
    box-shadow: 0 24px 60px rgba(2, 6, 23, 0.08);
}

.auth-brand {
    display: flex;
    justify-content: center;
    margin-bottom: 1.25rem;
}

.auth-brand-logo {
    height: 46px;
    width: auto;
    max-width: 260px;
    object-fit: contain;
}

.auth-header {
    text-align: center;
    margin-bottom: 1.5rem;
}

.auth-title {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1.6rem;
    margin: 0 0 0.35rem 0;
    letter-spacing: 0.2px;
}

.auth-subtitle {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.98rem;
}

.auth-footer {
    margin-top: 1.25rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border-color);
    text-align: center;
    font-size: 0.95rem;
}

.auth-page-minimal .input-flat {
    background: #ffffff !important;
    box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.12);
}

.auth-page-minimal .input-flat:focus {
    background: #ffffff !important;
}

.auth-page-minimal .btn-primary {
    box-shadow: none;
}

@media (max-width: 480px) {
    .auth-card-minimal {
        padding: 1.75rem 1.4rem 1.25rem;
        border-radius: 18px;
    }

    .auth-brand-logo {
        height: 40px;
    }

    .auth-title {
        font-size: 1.45rem;
    }
}

.auth-grid {
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: clamp(1.25rem, 3vw, 2rem);
    align-items: stretch;
}

.auth-showcase {
    position: relative;
    overflow: hidden;
    background: linear-gradient(145deg, rgba(13, 148, 136, 0.12), rgba(15, 23, 42, 0.04));
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: clamp(1.5rem, 3vw, 2.2rem);
    box-shadow: var(--shadow-lg);
}

.auth-showcase::after {
    content: '';
    position: absolute;
    right: -90px;
    top: -40px;
    width: 220px;
    height: 220px;
    background: radial-gradient(circle, rgba(34, 197, 94, 0.25), transparent 65%);
    filter: blur(6px);
}

.auth-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.45rem 0.8rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.75);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    font-weight: 700;
    letter-spacing: 0.01em;
}

.auth-headline {
    font-size: clamp(1.8rem, 3vw, 2.2rem);
    line-height: 1.2;
    margin: 1rem 0 0.35rem;
}

.auth-points {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    gap: 0.6rem;
    color: var(--text-muted);
    font-weight: 600;
}

.auth-card-modern {
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: clamp(1.6rem, 3vw, 2.4rem);
    box-shadow: var(--shadow-xl);
}

.auth-logo-mark {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    background: linear-gradient(160deg, rgba(13, 148, 136, 0.15), rgba(14, 165, 233, 0.12));
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.auth-logo-mark img {
    width: 72%;
    height: 72%;
    object-fit: contain;
}

.auth-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem 0.8rem;
    border-radius: 999px;
    border: 1px solid var(--border-color);
    background: var(--bg-body);
    color: var(--text-muted);
    font-weight: 700;
    font-size: 0.9rem;
}

.auth-alert {
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
    background: rgba(239, 68, 68, 0.08);
    border: 1px solid rgba(239, 68, 68, 0.35);
    color: var(--danger-color);
    border-radius: 12px;
    padding: 0.75rem 0.85rem;
}

.input-flat {
    border: 1px solid transparent !important;
    background: var(--bg-body) !important;
    box-shadow: inset 0 0 0 1px var(--border-color);
    border-radius: 12px;
    padding: 0.9rem 1rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.input-flat:focus {
    border-color: rgba(13, 148, 136, 0.6) !important;
    box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.15);
    background: var(--bg-elevated) !important;
}

.auth-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    font-size: 0.95rem;
}

@media (max-width: 768px) {
    .auth-meta {
        flex-direction: column;
        align-items: flex-start;
    }
}

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

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* ===== ACCESSIBILITY IMPROVEMENTS ===== */

/* Enhanced focus states for all interactive elements */
a:focus-visible,
button:focus-visible,
.btn:focus-visible,
.form-control:focus-visible,
.form-select:focus-visible,
.nav-link:focus-visible,
.dropdown-toggle:focus-visible,
.list-group-item:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}

/* Skip to main content link */
.skip-link {
    position: absolute;
    top: -100%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--primary-color);
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-md);
    z-index: 9999;
    font-weight: 600;
    transition: top 0.2s ease;
}

.skip-link:focus {
    top: 1rem;
    color: white;
}

/* Improved color contrast for muted text */
.text-muted {
    color: var(--text-muted) !important;
}

/* Screen reader only utility */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    :root {
        --border-color: rgba(15, 23, 42, 0.3);
        --text-muted: #1f2937;
    }

    .btn-primary {
        background: var(--primary-color);
        border: 2px solid var(--ink);
    }

    .card {
        border-width: 2px;
    }
}

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

    .animate-fade-in {
        animation: none;
        opacity: 1;
    }

    .card:hover {
        transform: none;
    }

    .btn-primary:hover {
        transform: none;
    }
}

/* ===== BOTTOM NAVIGATION BAR - Enhanced ===== */

.bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--bottom-nav-height);
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-top: 1px solid var(--border-color);
    z-index: var(--z-fixed);
    padding: 0;
    padding-bottom: env(safe-area-inset-bottom);
    box-shadow: 0 -2px 20px rgba(0, 0, 0, 0.06);
    overflow: visible;
}

.bottom-nav-inner {
    display: flex;
    justify-content: space-around;
    align-items: stretch;
    height: 100%;
    max-width: 560px;
    width: 100%;
    margin: 0 auto;
    padding: 0 var(--space-2);
}

.bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.15rem;
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-lg);
    color: var(--text-light);
    text-decoration: none;
    transition: var(--transition-fast);
    min-width: var(--touch-target);
    min-height: var(--touch-target);
    flex: 1 1 0;
    position: relative;
    -webkit-tap-highlight-color: transparent;
}

.bottom-nav-item:hover,
.bottom-nav-item:focus-visible {
    color: var(--primary-color);
    background: var(--bg-hover);
}

.bottom-nav-item:active {
    transform: scale(0.95);
}

.bottom-nav-item.active {
    color: var(--primary-color);
}

/* Active indicator - pill style */
.bottom-nav-item.active::before {
    content: '';
    position: absolute;
    bottom: 2px;
    left: 50%;
    transform: translateX(-50%);
    width: 4px;
    height: 4px;
    background: var(--primary-color);
    border-radius: var(--radius-full);
}

/* Remove old top indicator */
.bottom-nav-item.active::after {
    display: none;
}

/* Action button (Add/New) */
.bottom-nav-action {
    background: var(--primary-color);
    color: white;
    box-shadow: 0 2px 12px rgba(13, 148, 136, 0.35);
    border-radius: var(--radius-lg);
    min-width: 52px;
    margin: var(--space-1) 0;
}

.bottom-nav-action:hover,
.bottom-nav-action:focus-visible {
    color: white;
    background: var(--primary-hover);
    box-shadow: 0 4px 16px rgba(13, 148, 136, 0.4);
}

.bottom-nav-action:active {
    transform: scale(0.95);
}

.bottom-nav-action.active::before {
    display: none;
}

.bottom-nav-action .bottom-nav-icon,
.bottom-nav-action .bottom-nav-label {
    color: inherit;
}

.bottom-nav-icon {
    width: 22px;
    height: 22px;
    stroke-width: 2;
    transition: var(--transition-fast);
}

.bottom-nav-item.active .bottom-nav-icon {
    stroke-width: 2.5;
}

.bottom-nav-label {
    font-size: 0.625rem;
    font-weight: var(--font-semibold);
    letter-spacing: 0.01em;
    text-transform: uppercase;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    line-height: 1.2;
}

/* Badge - improved */
.bottom-nav-badge {
    position: absolute;
    top: 4px;
    right: calc(50% - 14px);
    min-width: 8px;
    height: 8px;
    background: var(--danger-color);
    border-radius: var(--radius-full);
    border: 2px solid white;
    box-shadow: 0 1px 3px rgba(220, 38, 38, 0.3);
}

/* More menu in bottom nav */
.bottom-nav-more {
    position: relative;
}

.bottom-nav-more-toggle {
    background: none;
    border: 0;
    font: inherit;
    cursor: pointer;
}

.bottom-nav-sheet {
    display: none;
    position: fixed;
    left: 0.75rem;
    right: 0.75rem;
    bottom: calc(var(--bottom-nav-height) + 0.5rem + env(safe-area-inset-bottom, 0px));
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    padding: 0.75rem 1rem 1rem;
    z-index: 1045;
}

.bottom-nav-more.open .bottom-nav-sheet {
    display: block;
}

.bottom-nav-sheet-handle {
    width: 44px;
    height: 4px;
    background: var(--border-color);
    border-radius: var(--radius-full);
    margin: 0 auto 0.65rem;
}

.bottom-nav-sheet-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.35rem;
}

.bottom-nav-menu-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.7rem 0.85rem;
    color: var(--text-main);
    text-decoration: none;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 500;
}

.bottom-nav-menu-item:hover {
    background: rgba(13, 148, 136, 0.08);
    color: var(--primary-color);
}

.bottom-nav-menu-item svg {
    width: 18px;
    height: 18px;
    opacity: 0.7;
}

/* Show bottom nav on mobile/tablet (below md breakpoint) */
@media (max-width: 767px) {
    .bottom-nav {
        display: block;
    }

    /* Add padding to body to prevent content from being hidden behind bottom nav */
    body {
        /* bottom-nav has height + vertical padding (1rem total) */
        padding-bottom: calc(var(--bottom-nav-height) + 1rem + env(safe-area-inset-bottom, 0px));
    }

    /* Adjust sticky form actions to sit above bottom nav */
    .form-actions-sticky {
        bottom: calc(var(--bottom-nav-height) + 1rem + env(safe-area-inset-bottom, 0px));
    }
}

@media (max-width: 380px) {
    .bottom-nav-icon {
        width: 22px;
        height: 22px;
    }
    .bottom-nav-label {
        font-size: 0.55rem;
    }
}

/* ===== PWA INSTALL PROMPT ===== */

.pwa-install-prompt {
    position: fixed;
    left: 1rem;
    right: 1rem;
    bottom: calc(var(--bottom-nav-height) + 1rem + env(safe-area-inset-bottom, 0px));
    z-index: 1045;
    display: none !important;
}

.show-pwa-prompt .pwa-install-prompt.is-visible {
    display: block !important;
}

.pwa-install-card {
    display: flex;
    gap: 0.85rem;
    align-items: center;
    padding: 0.85rem 1rem;
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
}

.pwa-install-icon img {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
}

.pwa-install-title {
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 0.15rem;
}

.pwa-install-text {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.pwa-install-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
    flex-wrap: wrap;
}

@media (min-width: 820px) {
    .pwa-install-prompt {
        left: auto;
        right: 1.5rem;
        max-width: 360px;
    }
}

/* ===== THEME TOGGLE ===== */

.theme-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition-fast);
}

.theme-toggle:hover {
    background: rgba(13, 148, 136, 0.08);
    color: var(--primary-color);
    border-color: var(--primary-color);
}

.theme-toggle svg {
    width: 18px;
    height: 18px;
}

.theme-toggle .icon-sun {
    display: none;
}

.theme-toggle .icon-moon {
    display: block;
}

[data-theme="dark"] .theme-toggle .icon-sun {
    display: block;
}

[data-theme="dark"] .theme-toggle .icon-moon {
    display: none;
}

/* ===== IMPROVED MOBILE STYLES ===== */

/* Fix dashboard stats on small screens */
@media (max-width: 576px) {
    .stat-value {
        font-size: 1.75rem;
        word-break: break-word;
    }

    .stat-label {
        font-size: 0.65rem;
    }

    /* Dashboard cards 2 columns on mobile */
    .row.g-4.mb-4 > [class*="col-md-3"] {
        flex: 0 0 50%;
        max-width: 50%;
    }

    /* Smaller card padding on mobile */
    .card-body {
        padding: 1rem;
    }

    /* Financial snapshot tighter */
    .row.text-center.g-3 .p-3 {
        padding: 0.75rem !important;
    }

    .row.text-center.g-3 h4 {
        font-size: 1.1rem;
    }
}

/* Very small screens */
@media (max-width: 375px) {
    .page-shell {
        padding: 0.5rem;
    }

    .stat-value {
        font-size: 1.5rem;
    }

    .btn {
        padding: 0.5rem 0.85rem;
        font-size: 0.875rem;
    }

    .btn-sm {
        padding: 0.35rem 0.6rem;
        font-size: 0.8rem;
    }

    .card-header {
        padding: 1rem;
        font-size: 1rem;
    }

    h2 {
        font-size: 1.35rem;
    }

    /* Single column stats on very small screens */
    .row.g-4.mb-4 > [class*="col-md-3"] {
        flex: 0 0 100%;
        max-width: 100%;
    }
}

/* ===== ACTION BUTTON DROPDOWN FOR MOBILE ===== */

.action-dropdown {
    position: relative;
    display: inline-block;
}

.action-dropdown-toggle {
    display: none;
}

.action-dropdown-menu {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

@media (max-width: 768px) {
    /* Show dropdown toggle, hide individual buttons */
    .action-dropdown-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 36px;
        height: 36px;
        border-radius: var(--radius-md);
        background: var(--bg-surface);
        border: 1px solid var(--border-color);
        color: var(--text-muted);
        cursor: pointer;
    }

    .action-dropdown-toggle:hover {
        background: rgba(13, 148, 136, 0.08);
        color: var(--primary-color);
    }

    .action-dropdown-menu {
        display: none;
        position: absolute;
        right: 0;
        top: calc(100% + 0.5rem);
        background: var(--bg-elevated);
        border: 1px solid var(--border-color);
        border-radius: var(--radius-lg);
        box-shadow: var(--shadow-lg);
        padding: 0.5rem;
        min-width: 180px;
        z-index: 1050;
        flex-direction: column;
        gap: 0.25rem;
    }

    .action-dropdown.open .action-dropdown-menu {
        display: flex;
    }

    .action-dropdown-menu .btn {
        width: 100%;
        text-align: left;
        justify-content: flex-start;
    }

    /* For tables without dropdown wrapper, stack buttons nicely */
    .stack-inline {
        flex-direction: column;
        gap: 0.35rem;
    }

    .stack-inline .btn {
        width: 100%;
    }
}

/* ===== IMPROVED KANBAN FOR MOBILE ===== */

@media (max-width: 768px) {
    .kanban-board {
        flex-direction: column;
        overflow-x: visible;
        gap: 1rem;
    }

    .kanban-column {
        min-width: 100%;
        flex: 1 1 auto;
    }

    .kanban-col .card-body {
        min-height: auto !important;
        padding: 0.75rem;
    }

    .kanban-task {
        padding: 0.65rem;
    }

    /* Collapsible kanban columns on mobile */
    .kanban-col .card-header {
        cursor: pointer;
        user-select: none;
    }

    .kanban-col .card-header::after {
        content: '';
        display: inline-block;
        width: 8px;
        height: 8px;
        border-right: 2px solid var(--text-muted);
        border-bottom: 2px solid var(--text-muted);
        transform: rotate(45deg);
        transition: transform 0.2s ease;
        margin-left: auto;
    }

    .kanban-col.collapsed .card-header::after {
        transform: rotate(-135deg);
    }

    .kanban-col.collapsed .card-body {
        display: none;
    }
}

/* ===== IMPROVED FORM VALIDATION UX ===== */

.form-control.is-invalid,
.form-select.is-invalid {
    border-color: var(--danger-color);
    background-image: none;
}

.form-control.is-invalid:focus,
.form-select.is-invalid:focus {
    border-color: var(--danger-color);
    box-shadow: 0 0 0 3px rgba(225, 29, 72, 0.2);
}

.invalid-feedback,
.text-danger.small {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    margin-top: 0.35rem;
    font-size: 0.8rem;
    color: var(--danger-color);
}

.invalid-feedback::before,
.form-group .text-danger.small::before {
    content: '';
    display: inline-block;
    width: 14px;
    height: 14px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23e11d48' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'%3E%3C/circle%3E%3Cline x1='12' y1='8' x2='12' y2='12'%3E%3C/line%3E%3Cline x1='12' y1='16' x2='12.01' y2='16'%3E%3C/line%3E%3C/svg%3E");
    background-size: contain;
    background-repeat: no-repeat;
    flex-shrink: 0;
}

.form-control.is-valid,
.form-select.is-valid {
    border-color: var(--success-color);
    background-image: none;
}

/* Form field hints */
.form-text {
    font-size: 0.8rem;
    color: var(--text-light);
    margin-top: 0.35rem;
}

/* Required field indicator */
.form-label.required::after {
    content: '*';
    color: var(--danger-color);
    margin-left: 0.25rem;
}

/* ===== LOADING STATES & SKELETON ===== */

.skeleton {
    background: linear-gradient(
        90deg,
        var(--border-color) 25%,
        rgba(255, 255, 255, 0.5) 50%,
        var(--border-color) 75%
    );
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: var(--radius-sm);
}

@keyframes skeleton-loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

.skeleton-text {
    height: 1em;
    margin-bottom: 0.5em;
}

.skeleton-text:last-child {
    width: 70%;
}

.skeleton-card {
    height: 120px;
}

.skeleton-row {
    height: 56px;
    margin-bottom: 0.5rem;
}

.skeleton-table {
    width: 100%;
}

.skeleton-table-row {
    display: flex;
    gap: 1rem;
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.skeleton-cell {
    flex: 1;
    height: 1rem;
}

.skeleton-cell.narrow {
    flex: 0.5;
}

.skeleton-cell.wide {
    flex: 2;
}

/* Skeleton for client cards */
.skeleton-client-card {
    height: 180px;
    border-radius: var(--radius-lg);
}

/* Skeleton for stat tiles */
.skeleton-stat {
    height: 100px;
    border-radius: var(--radius-lg);
}

/* Reduced motion: disable skeleton animation */
@media (prefers-reduced-motion: reduce) {
    .skeleton {
        animation: none;
        background: var(--border-color);
    }
}

/* Loading spinner */
.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.spinner-sm {
    width: 14px;
    height: 14px;
    border-width: 2px;
}

.spinner-lg {
    width: 32px;
    height: 32px;
    border-width: 3px;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Button loading state */
.btn.loading {
    position: relative;
    color: transparent !important;
    pointer-events: none;
}

.btn.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 16px;
    height: 16px;
    margin: -8px 0 0 -8px;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.btn-primary.loading::after {
    border-color: rgba(255, 255, 255, 0.3);
    border-top-color: white;
}

/* Page loading overlay */
.page-loading {
    position: fixed;
    inset: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

.page-loading.active {
    opacity: 1;
    visibility: visible;
}

[data-theme="dark"] .page-loading {
    background: rgba(15, 23, 42, 0.9);
}

/* ===== IMPROVED TABLET STYLES ===== */

@media (min-width: 768px) and (max-width: 991px) {
    /* Better stat card layout on tablets */
    .row.g-4.mb-4 > [class*="col-md-3"] {
        flex: 0 0 50%;
        max-width: 50%;
    }

    /* Better spacing for two-column layouts */
    .layout-duo {
        gap: 1rem;
    }

    /* Tighter table cells */
    .table > :not(caption) > * > * {
        padding: 0.65rem 0.5rem;
    }
}

/* ===== SMOOTH PAGE TRANSITIONS ===== */

.page-shell {
    opacity: 0;
    animation: pageEnter 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

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

/* ===== TOAST NOTIFICATIONS ===== */

.toast-container {
    position: fixed;
    bottom: calc(var(--bottom-nav-height) + 1rem);
    right: 1rem;
    z-index: 1100;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-width: 360px;
}

@media (min-width: 992px) {
    .toast-container {
        bottom: 1rem;
    }
}

.toast {
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 1rem;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    animation: toastEnter 0.3s ease;
}

@keyframes toastEnter {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes toastExit {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(100%);
    }
}

.toast-info .toast-icon {
    color: var(--info-color);
}

.toast-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.toast-success .toast-icon {
    color: var(--success-color);
}

.toast-error .toast-icon {
    color: var(--danger-color);
}

.toast-content {
    flex: 1;
}

.toast-title {
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.toast-message {
    font-size: 0.875rem;
    color: var(--text-muted);
}

.toast-close {
    background: none;
    border: none;
    color: var(--text-light);
    cursor: pointer;
    padding: 0.25rem;
    margin: -0.25rem;
    border-radius: var(--radius-sm);
}

.toast-close:hover {
    background: var(--border-color);
    color: var(--text-main);
}

/* ===== EMPTY STATES ===== */

.empty-state {
    text-align: center;
    padding: 3rem 2rem;
}

.empty-state-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 1.5rem;
    color: var(--text-light);
    opacity: 0.5;
}

.empty-state-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-main);
}

.empty-state-description {
    color: var(--text-muted);
    margin-bottom: 1.5rem;
    max-width: 320px;
    margin-left: auto;
    margin-right: auto;
}

/* ===== IMPROVED BADGE CONTRAST ===== */

.badge.bg-secondary {
    background-color: var(--secondary-color) !important;
    color: white;
}

[data-theme="dark"] .badge.bg-secondary {
    background-color: #475569 !important;
}

[data-theme="dark"] .badge.bg-light {
    background-color: var(--bg-elevated) !important;
    color: var(--text-main) !important;
}

/* ===== PAGINATION ===== */

.pagination {
    gap: 0.25rem;
}

.page-link {
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 0.5rem 0.85rem;
    font-weight: 500;
    transition: var(--transition-fast);
}

.page-link:hover {
    background: var(--primary-light);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.page-item.active .page-link {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

.page-item.disabled .page-link {
    background: var(--bg-surface);
    color: var(--text-light);
}

[data-theme="dark"] .page-link {
    background: var(--bg-surface);
    border-color: var(--border-color);
    color: var(--text-main);
}

[data-theme="dark"] .page-link:hover {
    background: var(--primary-light);
}

[data-theme="dark"] .page-item.disabled .page-link {
    background: transparent;
    color: var(--text-light);
}

/* ===== PROGRESSIVE DISCLOSURE FILTERS ===== */

.filter-details {
    position: relative;
}

.filter-details summary {
    cursor: pointer;
    list-style: none;
}

.filter-details summary::-webkit-details-marker {
    display: none;
}

.filter-details[open] summary {
    background: var(--primary-light);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.filter-dropdown {
    position: absolute;
    top: calc(100% + 0.5rem);
    left: 0;
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 1rem;
    min-width: 280px;
    z-index: 100;
}

.filter-field {
    margin-bottom: 0.75rem;
}

.filter-field:last-of-type {
    margin-bottom: 0;
}

[data-theme="dark"] .filter-dropdown {
    background: var(--bg-elevated);
    border-color: var(--border-color);
}

/* ===== PRINT STYLES ===== */

@media print {
    .navbar,
    .bottom-nav,
    .btn,
    .theme-toggle,
    .filter-toggle {
        display: none !important;
    }

    body {
        padding-bottom: 0;
        background: white;
    }

    .page-shell {
        padding: 0;
        max-width: 100%;
    }

    .card {
        box-shadow: none;
        border: 1px solid #ddd;
    }
}

/* ===== COMPREHENSIVE BOOTSTRAP UTILITY DARK MODE OVERRIDES ===== */

/* Background utilities with opacity - dark mode */
[data-theme="dark"] .bg-success.bg-opacity-10,
[data-theme="dark"] .bg-success-subtle {
    background-color: rgba(52, 211, 153, 0.15) !important;
}

[data-theme="dark"] .bg-warning.bg-opacity-10,
[data-theme="dark"] .bg-warning-subtle {
    background-color: rgba(251, 191, 36, 0.15) !important;
}

[data-theme="dark"] .bg-danger.bg-opacity-10,
[data-theme="dark"] .bg-danger-subtle {
    background-color: rgba(248, 113, 113, 0.15) !important;
}

[data-theme="dark"] .bg-info.bg-opacity-10,
[data-theme="dark"] .bg-info-subtle {
    background-color: rgba(96, 165, 250, 0.15) !important;
}

[data-theme="dark"] .bg-primary.bg-opacity-10,
[data-theme="dark"] .bg-primary-subtle {
    background-color: rgba(45, 212, 191, 0.15) !important;
}

[data-theme="dark"] .bg-secondary.bg-opacity-10,
[data-theme="dark"] .bg-secondary-subtle {
    background-color: rgba(148, 163, 184, 0.15) !important;
}

/* Badge variants for dark mode */
[data-theme="dark"] .badge.bg-success-subtle {
    background-color: rgba(52, 211, 153, 0.2) !important;
    color: #34d399 !important;
}

[data-theme="dark"] .badge.bg-warning-subtle {
    background-color: rgba(251, 191, 36, 0.2) !important;
    color: #fbbf24 !important;
}

[data-theme="dark"] .badge.bg-danger-subtle {
    background-color: rgba(248, 113, 113, 0.2) !important;
    color: #f87171 !important;
}

[data-theme="dark"] .badge.bg-info-subtle {
    background-color: rgba(96, 165, 250, 0.2) !important;
    color: #60a5fa !important;
}

[data-theme="dark"] .badge.bg-primary-subtle {
    background-color: rgba(45, 212, 191, 0.2) !important;
    color: #2dd4bf !important;
}

[data-theme="dark"] .badge.bg-success {
    background-color: var(--success-color) !important;
    color: #064e3b !important;
}

[data-theme="dark"] .badge.bg-warning {
    background-color: var(--warning-color) !important;
    color: #451a03 !important;
}

[data-theme="dark"] .badge.bg-danger {
    background-color: var(--danger-color) !important;
    color: #450a0a !important;
}

[data-theme="dark"] .badge.bg-info {
    background-color: var(--info-color) !important;
    color: #1e3a8a !important;
}

[data-theme="dark"] .badge.bg-primary {
    background-color: var(--primary-color) !important;
    color: #042f2e !important;
}

/* Text color utilities for dark mode */
[data-theme="dark"] .text-success {
    color: var(--success-color) !important;
}

[data-theme="dark"] .text-danger {
    color: var(--danger-color) !important;
}

[data-theme="dark"] .text-warning {
    color: var(--warning-color) !important;
}

[data-theme="dark"] .text-info {
    color: var(--info-color) !important;
}

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

[data-theme="dark"] .text-secondary {
    color: var(--secondary-color) !important;
}

[data-theme="dark"] .text-body {
    color: var(--text-main) !important;
}

[data-theme="dark"] .text-body-secondary {
    color: var(--text-muted) !important;
}

/* Border utilities for dark mode */
[data-theme="dark"] .border {
    border-color: var(--border-color) !important;
}

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

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

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

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

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

/* White and light backgrounds in dark mode */
[data-theme="dark"] .bg-white {
    background-color: var(--bg-elevated) !important;
}

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

[data-theme="dark"] .bg-body-secondary {
    background-color: var(--bg-surface) !important;
}

[data-theme="dark"] .bg-body-tertiary {
    background-color: var(--bg-elevated) !important;
}

/* ===== ENHANCED COMPONENT STYLES FOR BOTH THEMES ===== */

/* Improved chip/tag styling */
.chip-success {
    background: var(--success-light);
    color: var(--success-color);
    border: 1px solid rgba(5, 150, 105, 0.25);
}

.chip-danger {
    background: var(--danger-light);
    color: var(--danger-color);
    border: 1px solid rgba(220, 38, 38, 0.25);
}

.chip-info {
    background: var(--info-light);
    color: var(--info-color);
    border: 1px solid rgba(2, 132, 199, 0.25);
}

[data-theme="dark"] .chip-success {
    background: rgba(52, 211, 153, 0.15);
    color: #34d399;
    border-color: rgba(52, 211, 153, 0.3);
}

[data-theme="dark"] .chip-danger {
    background: rgba(248, 113, 113, 0.15);
    color: #f87171;
    border-color: rgba(248, 113, 113, 0.3);
}

[data-theme="dark"] .chip-info {
    background: rgba(96, 165, 250, 0.15);
    color: #60a5fa;
    border-color: rgba(96, 165, 250, 0.3);
}

[data-theme="dark"] .chip-warning {
    background: rgba(251, 191, 36, 0.15);
    color: #fbbf24;
    border-color: rgba(251, 191, 36, 0.3);
}

[data-theme="dark"] .chip-soft {
    background: var(--primary-subtle);
    color: var(--primary-color);
    border-color: rgba(45, 212, 191, 0.3);
}

/* ===== ENHANCED MODAL STYLES ===== */

[data-theme="dark"] .modal-content {
    background: var(--bg-elevated);
    border-color: var(--border-color);
    color: var(--text-main);
}

[data-theme="dark"] .modal-header {
    border-bottom-color: var(--border-color);
}

[data-theme="dark"] .modal-footer {
    border-top-color: var(--border-color);
}

[data-theme="dark"] .modal-backdrop {
    background-color: rgba(0, 0, 0, 0.7);
}

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

/* ===== ENHANCED OFFCANVAS STYLES ===== */

[data-theme="dark"] .offcanvas {
    background: var(--bg-elevated);
    border-color: var(--border-color);
    color: var(--text-main);
}

[data-theme="dark"] .offcanvas-header {
    border-bottom-color: var(--border-color);
}

/* ===== IMPROVED ALERT STYLES ===== */

.alert-success {
    background: var(--success-light);
    border-color: rgba(5, 150, 105, 0.3);
    color: #065f46;
}

.alert-danger {
    background: var(--danger-light);
    border-color: rgba(220, 38, 38, 0.3);
    color: #991b1b;
}

.alert-warning {
    background: var(--warning-light);
    border-color: rgba(217, 119, 6, 0.3);
    color: #92400e;
}

.alert-info {
    background: var(--info-light);
    border-color: rgba(2, 132, 199, 0.3);
    color: #075985;
}

[data-theme="dark"] .alert-success {
    background: rgba(52, 211, 153, 0.12);
    border-color: rgba(52, 211, 153, 0.25);
    color: #34d399;
}

[data-theme="dark"] .alert-danger {
    background: rgba(248, 113, 113, 0.12);
    border-color: rgba(248, 113, 113, 0.25);
    color: #f87171;
}

[data-theme="dark"] .alert-warning {
    background: rgba(251, 191, 36, 0.12);
    border-color: rgba(251, 191, 36, 0.25);
    color: #fbbf24;
}

[data-theme="dark"] .alert-info {
    background: rgba(96, 165, 250, 0.12);
    border-color: rgba(96, 165, 250, 0.25);
    color: #60a5fa;
}

/* ===== IMPROVED LIST GROUP STYLES ===== */

[data-theme="dark"] .list-group-item-action:hover,
[data-theme="dark"] .list-group-item-action:focus {
    background: var(--bg-hover);
    color: var(--text-main);
}

[data-theme="dark"] .list-group-item-action.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: var(--text-inverse);
}

/* ===== IMPROVED ACCORDION STYLES ===== */

[data-theme="dark"] .accordion-item {
    background: var(--bg-surface);
    border-color: var(--border-color);
}

[data-theme="dark"] .accordion-button {
    background: var(--bg-elevated);
    color: var(--text-main);
}

[data-theme="dark"] .accordion-button:not(.collapsed) {
    background: var(--primary-light);
    color: var(--primary-color);
}

[data-theme="dark"] .accordion-button::after {
    filter: invert(1);
}

[data-theme="dark"] .accordion-body {
    background: var(--bg-surface);
}

/* ===== IMPROVED BREADCRUMB STYLES ===== */

[data-theme="dark"] .breadcrumb-item + .breadcrumb-item::before {
    color: var(--text-light);
}

[data-theme="dark"] .breadcrumb-item.active {
    color: var(--text-muted);
}

/* ===== IMPROVED PROGRESS BAR STYLES ===== */

[data-theme="dark"] .progress {
    background-color: var(--bg-surface);
}

/* ===== USER ADMIN TABS ===== */

.user-admin-tabs {
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    padding: 0.5rem;
    border: 1px solid var(--border-color);
}

.user-admin-tabs .nav-link {
    border-radius: var(--radius-md);
    padding: 0.75rem 1rem;
    font-weight: 500;
    color: var(--text-muted);
    transition: var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
}

.user-admin-tabs .nav-link:hover {
    background: var(--bg-hover);
    color: var(--text-main);
}

.user-admin-tabs .nav-link.active {
    background: var(--primary-color);
    color: var(--text-inverse);
}

.user-admin-tabs .nav-link.active .badge {
    background: rgba(255, 255, 255, 0.2) !important;
    color: inherit !important;
}

@media (max-width: 575.98px) {
    .user-admin-tabs {
        padding: 0.25rem;
    }
    .user-admin-tabs .nav-link {
        padding: 0.5rem 0.75rem;
        font-size: 0.875rem;
    }
    .user-admin-tabs .nav-link svg {
        display: none;
    }
}

[data-theme="dark"] .user-admin-tabs {
    background: var(--bg-elevated);
}

/* ===== CARD ENHANCEMENTS ===== */

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

.card-elevated:hover {
    box-shadow: var(--shadow-lg);
}

.card-interactive {
    cursor: pointer;
}

.card-interactive:hover {
    border-color: var(--border-color-hover);
}

/* ===== IMPROVED SKELETON LOADING FOR DARK MODE ===== */

[data-theme="dark"] .skeleton {
    background: linear-gradient(
        90deg,
        var(--bg-surface) 25%,
        var(--bg-elevated) 50%,
        var(--bg-surface) 75%
    );
    background-size: 200% 100%;
}

/* =====================================================
   CASHBOOK 2.0 - Premium Mobile-First Design
   ===================================================== */

/* ----- Base Container ----- */
.cb {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding-bottom: 1rem;
}

/* Extra padding on mobile for FAB + bottom nav */
@media (max-width: 767.98px) {
    .cb {
        padding-bottom: calc(var(--bottom-nav-height) + 80px);
    }
}

/* ----- Header ----- */
.cb-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.cb-header__title {
    font-size: 1.35rem;
    font-weight: 700;
    margin: 0;
    color: var(--ink);
}

.cb-header__actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* ----- Buttons ----- */
.cb-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.65rem 1rem;
    font-size: 0.9rem;
    font-weight: 600;
    border-radius: var(--radius-md);
    border: none;
    cursor: pointer;
    transition: var(--transition-fast);
    text-decoration: none;
    white-space: nowrap;
}

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

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

.cb-btn--ghost {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border-color);
}

.cb-btn--ghost:hover {
    background: var(--bg-hover);
    border-color: var(--border-color-hover);
    color: var(--primary-color);
}

.cb-btn--sm {
    padding: 0.5rem 0.85rem;
    font-size: 0.8rem;
}

.cb-btn--lg {
    padding: 1rem 1.5rem;
    font-size: 1rem;
}

.cb-btn--block {
    width: 100%;
}

/* ----- Stats Strip ----- */
.cb-stats {
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    margin: 0 -1rem;
    padding: 0 1rem;
}

.cb-stats::-webkit-scrollbar {
    display: none;
}

.cb-stat {
    flex: 1 0 auto;
    min-width: 100px;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    padding: 0.75rem 1rem;
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
}

.cb-stat__label {
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-light);
}

.cb-stat__value {
    font-size: 1.1rem;
    font-weight: 700;
    white-space: nowrap;
}

.cb-stat--out .cb-stat__value { color: var(--danger-color); }
.cb-stat--in .cb-stat__value { color: var(--success-color); }
.cb-stat--positive .cb-stat__value { color: var(--success-color); }
.cb-stat--negative .cb-stat__value { color: var(--danger-color); }

/* ----- Filter Bar ----- */
.cb-filterbar {
    position: relative;
}

.cb-filterbar__toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 0.85rem;
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition-fast);
}

.cb-filterbar__toggle:hover {
    border-color: var(--border-color-hover);
    color: var(--primary-color);
}

.cb-filterbar__badge {
    width: 8px;
    height: 8px;
    background: var(--primary-color);
    border-radius: 50%;
}

.cb-filterbar__panel {
    display: none;
    position: absolute;
    top: calc(100% + 0.5rem);
    left: 0;
    right: 0;
    z-index: 100;
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1rem;
    box-shadow: var(--shadow-lg);
}

.cb-filterbar__panel.active {
    display: block;
}

.cb-filterbar__form {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.cb-filterbar__actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

/* ----- Transactions List ----- */
.cb-list {
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.cb-list__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.85rem 1rem;
    background: var(--bg-subtle);
    border-bottom: 1px solid var(--border-color);
}

.cb-list__title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
}

.cb-list__count {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.2rem 0.5rem;
    background: var(--primary-subtle);
    color: var(--primary-color);
    border-radius: var(--radius-full);
}

/* ----- Transaction Item ----- */
.cb-txn {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--border-color);
    transition: var(--transition-fast);
}

.cb-txn:last-child {
    border-bottom: none;
}

.cb-txn:active {
    background: var(--bg-hover);
}

.cb-txn__date {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    background: var(--bg-subtle);
    border-radius: var(--radius-md);
    flex-shrink: 0;
}

.cb-txn__day {
    font-size: 1rem;
    font-weight: 700;
    line-height: 1;
    color: var(--ink);
}

.cb-txn__mon {
    font-size: 0.6rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-light);
    margin-top: 0.1rem;
}

.cb-txn__body {
    flex: 1;
    min-width: 0;
}

.cb-txn__title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 0.25rem;
}

.cb-txn__tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
}

.cb-txn__amt {
    font-size: 1rem;
    font-weight: 700;
    white-space: nowrap;
    padding-left: 0.5rem;
}

.cb-txn__amt--out { color: var(--danger-color); }
.cb-txn__amt--in { color: var(--success-color); }

/* ----- Tags ----- */
.cb-tag {
    display: inline-flex;
    padding: 0.15rem 0.45rem;
    font-size: 0.65rem;
    font-weight: 500;
    background: var(--bg-subtle);
    color: var(--text-muted);
    border-radius: var(--radius-full);
    white-space: nowrap;
}

.cb-tag--accent {
    background: var(--primary-light);
    color: var(--primary-color);
}

.cb-tag--info {
    background: var(--info-light);
    color: var(--info-color);
}

/* ----- Empty State ----- */
.cb-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 1.5rem;
    text-align: center;
    color: var(--text-light);
}

.cb-empty svg {
    margin-bottom: 1rem;
    opacity: 0.5;
}

.cb-empty p {
    font-size: 0.95rem;
    margin-bottom: 1rem;
    color: var(--text-muted);
}

/* ----- FAB ----- */
.cb-fab {
    position: fixed;
    bottom: calc(var(--bottom-nav-height) + 16px);
    right: 16px;
    z-index: 90;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--radius-full);
    box-shadow: 0 4px 14px rgba(13, 148, 136, 0.4);
    cursor: pointer;
    transition: var(--transition-normal);
}

.cb-fab:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(13, 148, 136, 0.5);
}

.cb-fab:active {
    transform: scale(0.95);
}

/* ----- Full-Screen Form Overlay ----- */
.cb-form-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9999;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    pointer-events: none;
}

.cb-form-overlay.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

/* ----- Form Panel ----- */
.cb-form-panel {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 10000;
    height: 90vh;
    max-height: 90vh;
    background: var(--bg-elevated);
    border-radius: 16px 16px 0 0;
    transform: translateY(100%);
    transition: transform 0.35s cubic-bezier(0.32, 0.72, 0, 1);
    display: flex;
    flex-direction: column;
    box-shadow: 0 -4px 30px rgba(0, 0, 0, 0.15);
    overflow: hidden;
}

.cb-form-panel.active {
    transform: translateY(0);
}

/* Desktop: Centered card */
@media (min-width: 768px) {
    .cb-form-panel {
        top: 50%;
        left: 50%;
        right: auto;
        bottom: auto;
        width: 100%;
        max-width: 480px;
        max-height: 85vh;
        border-radius: var(--radius-xl);
        transform: translate(-50%, -50%) scale(0.95);
        opacity: 0;
        transition: transform 0.3s ease, opacity 0.3s ease;
        box-shadow: var(--shadow-xl);
    }

    .cb-form-panel.active {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
}

/* ----- Form Header ----- */
.cb-form-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1rem 1rem;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-elevated);
    flex-shrink: 0;
}

/* Drag handle for mobile */
.cb-form-header::before {
    content: '';
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    width: 36px;
    height: 4px;
    background: var(--border-color-strong);
    border-radius: 2px;
}

@media (min-width: 768px) {
    .cb-form-header::before {
        display: none;
    }
}

.cb-form-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: transparent;
    border: none;
    border-radius: var(--radius-full);
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition-fast);
}

.cb-form-close:hover {
    background: var(--bg-hover);
    color: var(--text-main);
}

.cb-form-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin: 0;
    color: var(--ink);
}

.cb-form-header__spacer {
    width: 40px;
}

/* ----- Form Body ----- */
.cb-form {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: visible;
}

.cb-form__body {
    flex: 1;
    overflow-y: auto;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.cb-form__footer {
    padding: 1rem 1.25rem;
    padding-bottom: calc(1rem + env(safe-area-inset-bottom));
    background: var(--bg-elevated);
    border-top: 1px solid var(--border-color);
    flex-shrink: 0;
    position: sticky;
    bottom: 0;
    z-index: 3;
    box-shadow: 0 -6px 24px rgba(0, 0, 0, 0.12);
}

/* Ensure bottom CTA stays visible on mobile when bottom nav is present */
@media (max-width: 767.98px) {
    .cb-form-panel {
        height: 100vh;
        max-height: 100vh;
    }
    .cb-form__footer {
        padding-bottom: calc(1rem + var(--bottom-nav-height) + env(safe-area-inset-bottom, 0px));
    }
}

/* Hide bottom nav when the cashbook form is open to avoid overlap */
body.cb-form-open .bottom-nav {
    display: none !important;
}
/* ----- Form Fields ----- */
.cb-field {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.cb-field--compact {
    gap: 0.25rem;
}

.cb-field__label {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
}

.cb-field__label svg {
    color: var(--text-light);
}

.cb-field__error {
    font-size: 0.75rem;
    color: var(--danger-color);
}

/* ----- Transaction Type Toggle ----- */
.cb-type-toggle {
    margin-bottom: 1rem;
}

.cb-type-toggle .btn-group {
    display: flex;
    gap: 0;
}

.cb-type-toggle .btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    font-weight: 600;
    border-radius: 0;
}

.cb-type-toggle .btn:first-of-type {
    border-radius: var(--radius-md) 0 0 var(--radius-md);
}

.cb-type-toggle .btn:last-of-type {
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

.cb-type-toggle .btn-check:checked + .btn-outline-danger {
    background-color: var(--danger-color, #ef4444);
    border-color: var(--danger-color, #ef4444);
    color: #fff;
}

.cb-type-toggle .btn-check:checked + .btn-outline-success {
    background-color: var(--success-color, #10b981);
    border-color: var(--success-color, #10b981);
    color: #fff;
}

/* ----- Hero Field (Amount) ----- */
.cb-field--hero {
    padding: 1.25rem 1rem;
    background: linear-gradient(135deg, var(--primary-subtle) 0%, var(--bg-subtle) 100%);
    border: 1px solid var(--primary-light);
    border-radius: var(--radius-lg);
    margin-bottom: 0.5rem;
    transition: all 0.2s ease;
}

.cb-field--hero.cb-field--income {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.1) 0%, var(--bg-subtle) 100%);
    border-color: rgba(16, 185, 129, 0.3);
}

.cb-field--hero.cb-field--income .cb-field__label {
    color: var(--success-color, #10b981);
}

.cb-field--hero .cb-field__label {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.cb-field__hero-wrap {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.cb-field__currency {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-muted);
    line-height: 1;
}

.cb-input--hero {
    font-size: 2.5rem !important;
    font-weight: 700 !important;
    padding: 0 !important;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    line-height: 1 !important;
    height: auto !important;
    min-height: 0 !important;
}

.cb-input--hero:focus {
    outline: none !important;
    box-shadow: none !important;
}

.cb-input--hero::placeholder {
    color: var(--text-light);
    opacity: 0.5;
}

/* ----- Inputs ----- */
.cb-input {
    width: 100%;
    padding: 0.85rem 1rem;
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-main);
    background: var(--bg-input);
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-md);
    transition: var(--transition-fast);
    -webkit-appearance: none;
    appearance: none;
}

.cb-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--primary-subtle);
}

.cb-input::placeholder {
    color: var(--text-light);
}

.cb-select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    padding-right: 2.5rem;
}

.cb-textarea {
    min-height: 80px;
    resize: vertical;
}

/* ----- More Options Toggle ----- */
.cb-more-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.75rem;
    background: transparent;
    border: 1px dashed var(--border-color);
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition-fast);
}

.cb-more-toggle:hover {
    border-color: var(--border-color-hover);
    color: var(--primary-color);
    background: var(--bg-hover);
}

.cb-more-toggle.active {
    border-style: solid;
    background: var(--primary-subtle);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.cb-more-toggle.active svg {
    transform: rotate(45deg);
}

.cb-more-toggle svg {
    transition: transform 0.2s ease;
}

/* ----- More Fields Container ----- */
.cb-more-fields {
    display: none;
    flex-direction: column;
    gap: 1rem;
    padding-top: 0.5rem;
}

.cb-more-fields.active {
    display: flex;
}

/* ===== CASHBOOK TOOLBAR & SEARCH ===== */

.cb-toolbar {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    margin-bottom: var(--space-4);
    border: 1px solid var(--border-color);
}

.cb-search {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
}

.cb-search__icon {
    position: absolute;
    left: var(--space-3);
    color: var(--text-light);
    pointer-events: none;
    z-index: 1;
}

.cb-search__input {
    width: 100%;
    padding: var(--space-2) var(--space-3) var(--space-2) 2.5rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-input);
    color: var(--text-main);
    font-size: var(--text-sm);
    transition: var(--transition-fast);
    min-height: 40px;
}

.cb-search__input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--primary-subtle);
}

.cb-search__input::placeholder {
    color: var(--text-placeholder);
}

.cb-toolbar__btn {
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    width: 40px;
    height: 40px;
    padding: 0;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-input);
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition-fast);
    flex-shrink: 0;
}

.cb-toolbar__btn:hover {
    border-color: var(--primary-light);
    color: var(--primary-color);
    background: var(--primary-subtle);
}

.cb-toolbar__btn--active {
    border-color: var(--primary-color);
    color: var(--primary-color);
    background: var(--primary-subtle);
}

.cb-toolbar__badge {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--primary-color);
    color: white;
    font-size: 10px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ===== CASHBOOK FILTER PANEL ===== */

.cb-filter-panel {
    display: none;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    margin-bottom: var(--space-4);
    overflow: hidden;
    animation: slideDown 0.2s ease;
}

.cb-filter-panel.active {
    display: block;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.cb-filter-form {
    padding: var(--space-4);
}

.cb-filter-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-3);
}

@media (min-width: 768px) {
    .cb-filter-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

.cb-filter-field {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
}

.cb-filter-field label {
    font-size: var(--text-xs);
    font-weight: var(--font-medium);
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.cb-filter-actions {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-4);
    background: var(--bg-subtle);
    border-top: 1px solid var(--border-color);
}

/* ===== CASHBOOK DATE GROUPING ===== */

.cb-date-group {
    margin-bottom: var(--space-4);
}

.cb-date-group:last-child {
    margin-bottom: 0;
}

.cb-date-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-2) var(--space-3);
    margin-bottom: var(--space-2);
    background: var(--bg-subtle);
    border-radius: var(--radius-md);
}

.cb-date-header__date {
    font-size: var(--text-sm);
    font-weight: var(--font-semibold);
    color: var(--text-main);
}

.cb-date-header__count {
    font-size: var(--text-xs);
    color: var(--text-light);
    background: var(--bg-surface);
    padding: var(--space-1) var(--space-2);
    border-radius: var(--radius-sm);
}

/* ===== CASHBOOK TRANSACTION ENHANCEMENTS ===== */

.cb-txn__icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    flex-shrink: 0;
    margin-right: var(--space-3);
}

.cb-txn__icon--out {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger-color);
}

.cb-txn__icon--in {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success-color);
}

.cb-txn__icon svg {
    width: 18px;
    height: 18px;
}

.cb-txn__meta {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    margin-top: var(--space-1);
}

.cb-txn__category,
.cb-txn__account {
    font-size: var(--text-xs);
    color: var(--text-light);
    background: var(--bg-subtle);
    padding: 2px 6px;
    border-radius: var(--radius-sm);
}

.cb-txn__account {
    background: transparent;
    color: var(--text-placeholder);
}

/* Field row layout for filter forms */
.cb-field-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-3);
}

@media (max-width: 480px) {
    .cb-field-row {
        grid-template-columns: 1fr;
    }
}

/* Enhanced stats with icons */
.cb-stat__icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: var(--radius-full);
    margin-bottom: var(--space-2);
}

.cb-stat--out .cb-stat__icon {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger-color);
}

.cb-stat--in .cb-stat__icon {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success-color);
}

.cb-stat--balance .cb-stat__icon {
    background: var(--primary-subtle);
    color: var(--primary-color);
}

.cb-stat__icon svg {
    width: 16px;
    height: 16px;
}

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

@media (min-width: 768px) {
    .cb-stats {
        margin: 0;
        padding: 0;
        overflow: visible;
    }

    .cb-stat {
        flex: 1;
        min-width: 0;
    }

    .cb-filterbar__panel {
        max-width: 360px;
    }
}

@media (max-width: 374px) {
    .cb-header__title {
        font-size: 1.15rem;
    }

    .cb-stat {
        min-width: 85px;
        padding: 0.6rem 0.75rem;
    }

    .cb-stat__value {
        font-size: 0.95rem;
    }

    .cb-txn__title {
        font-size: 0.85rem;
    }

    .cb-txn__amt {
        font-size: 0.9rem;
    }
}

/* ===== CASHBOOK DARK MODE ===== */

[data-theme="dark"] .cb-stat {
    background: var(--bg-surface);
}

[data-theme="dark"] .cb-list {
    background: var(--bg-surface);
}

[data-theme="dark"] .cb-list__header {
    background: var(--bg-elevated);
}

[data-theme="dark"] .cb-txn__date {
    background: var(--bg-elevated);
}

[data-theme="dark"] .cb-filterbar__toggle {
    background: var(--bg-surface);
}

[data-theme="dark"] .cb-filterbar__panel {
    background: var(--bg-elevated);
}

[data-theme="dark"] .cb-form-panel {
    background: var(--bg-body);
}

[data-theme="dark"] .cb-form-header {
    background: var(--bg-surface);
}

[data-theme="dark"] .cb-form__footer {
    background: var(--bg-surface);
}

[data-theme="dark"] .cb-field--hero {
    background: linear-gradient(135deg, var(--primary-subtle) 0%, var(--bg-elevated) 100%);
    border-color: rgba(45, 212, 191, 0.2);
}

[data-theme="dark"] .cb-field--hero .cb-field__label {
    color: var(--primary-color);
}

[data-theme="dark"] .cb-input {
    background: var(--bg-input);
    border-color: var(--border-color);
    color: var(--text-main);
}

[data-theme="dark"] .cb-input:focus {
    border-color: var(--primary-color);
}

[data-theme="dark"] .cb-tag {
    background: var(--bg-elevated);
}

[data-theme="dark"] .cb-tag--accent {
    background: var(--primary-subtle);
}

[data-theme="dark"] .cb-tag--info {
    background: rgba(96, 165, 250, 0.15);
    color: #60a5fa;
}

[data-theme="dark"] .cb-select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
}

[data-theme="dark"] .cb-fab {
    box-shadow: 0 4px 14px rgba(45, 212, 191, 0.3);
}

[data-theme="dark"] .cb-fab:hover {
    box-shadow: 0 6px 20px rgba(45, 212, 191, 0.4);
}

[data-theme="dark"] .cb-form-overlay {
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

[data-theme="dark"] .cb-stat--out .cb-stat__value { color: #f87171; }
[data-theme="dark"] .cb-stat--in .cb-stat__value { color: #34d399; }
[data-theme="dark"] .cb-stat--positive .cb-stat__value { color: #34d399; }
[data-theme="dark"] .cb-stat--negative .cb-stat__value { color: #f87171; }
[data-theme="dark"] .cb-txn__amt--out { color: #f87171; }
[data-theme="dark"] .cb-txn__amt--in { color: #34d399; }

/* Dark mode for toolbar & search */
[data-theme="dark"] .cb-toolbar {
    background: var(--bg-surface);
    border-color: var(--border-color);
}

[data-theme="dark"] .cb-search__input {
    background: var(--bg-input);
    border-color: var(--border-color);
    color: var(--text-main);
}

[data-theme="dark"] .cb-search__input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(45, 212, 191, 0.15);
}

[data-theme="dark"] .cb-toolbar__btn {
    background: var(--bg-input);
    border-color: var(--border-color);
    color: var(--text-muted);
}

[data-theme="dark"] .cb-toolbar__btn:hover,
[data-theme="dark"] .cb-toolbar__btn--active {
    background: var(--primary-subtle);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

/* Dark mode for filter panel */
[data-theme="dark"] .cb-filter-panel {
    background: var(--bg-surface);
    border-color: var(--border-color);
}

[data-theme="dark"] .cb-filter-actions {
    background: var(--bg-elevated);
    border-color: var(--border-color);
}

/* Dark mode for date grouping */
[data-theme="dark"] .cb-date-header {
    background: var(--bg-elevated);
}

[data-theme="dark"] .cb-date-header__count {
    background: var(--bg-surface);
}

/* Dark mode for transaction icons */
[data-theme="dark"] .cb-txn__icon--out {
    background: rgba(248, 113, 113, 0.15);
    color: #f87171;
}

[data-theme="dark"] .cb-txn__icon--in {
    background: rgba(52, 211, 153, 0.15);
    color: #34d399;
}

[data-theme="dark"] .cb-txn__category {
    background: var(--bg-elevated);
}

/* Dark mode for stat icons */
[data-theme="dark"] .cb-stat--out .cb-stat__icon {
    background: rgba(248, 113, 113, 0.15);
    color: #f87171;
}

[data-theme="dark"] .cb-stat--in .cb-stat__icon {
    background: rgba(52, 211, 153, 0.15);
    color: #34d399;
}

[data-theme="dark"] .cb-stat--balance .cb-stat__icon {
    background: rgba(45, 212, 191, 0.15);
    color: var(--primary-color);
}

/* =====================================================
   UNIFIED UI COMPONENTS - Global Design System
   ===================================================== */

/* ===== UNIFIED BUTTONS ===== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-4);
    font-size: var(--text-sm);
    font-weight: var(--font-semibold);
    line-height: var(--leading-tight);
    border-radius: var(--radius-md);
    border: var(--border-width) solid transparent;
    cursor: pointer;
    transition: var(--transition-fast);
    text-decoration: none;
    white-space: nowrap;
    min-height: var(--touch-target);
    -webkit-tap-highlight-color: transparent;
}

.btn:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}

.btn:active {
    transform: scale(0.98);
}

.btn:disabled,
.btn.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

/* Primary Button */
.btn-primary {
    background: var(--primary-color);
    color: var(--text-inverse);
    border-color: var(--primary-color);
}

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

/* Secondary/Outline Button */
.btn-outline-secondary,
.btn-secondary {
    background: transparent;
    color: var(--text-muted);
    border-color: var(--border-color-strong);
}

.btn-outline-secondary:hover,
.btn-secondary:hover {
    background: var(--bg-subtle);
    color: var(--text-main);
    border-color: var(--border-color-strong);
}

/* Ghost Button */
.btn-ghost {
    background: transparent;
    color: var(--text-muted);
    border-color: transparent;
}

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

/* Danger Button */
.btn-danger {
    background: var(--danger-color);
    color: var(--text-inverse);
    border-color: var(--danger-color);
}

.btn-danger:hover {
    background: var(--danger-muted);
    border-color: var(--danger-muted);
}

/* Success Button */
.btn-success {
    background: var(--success-color);
    color: var(--text-inverse);
    border-color: var(--success-color);
}

.btn-success:hover {
    background: var(--success-muted);
    border-color: var(--success-muted);
}

/* Button Sizes */
.btn-sm {
    padding: var(--space-2) var(--space-3);
    font-size: var(--text-xs);
    min-height: var(--touch-target-sm);
}

.btn-lg {
    padding: var(--space-4) var(--space-6);
    font-size: var(--text-md);
    min-height: 52px;
}

/* Icon Button */
.btn-icon {
    padding: var(--space-2);
    min-width: var(--touch-target);
    min-height: var(--touch-target);
}

.btn-icon.btn-sm {
    min-width: var(--touch-target-sm);
    min-height: var(--touch-target-sm);
}

/* ===== UNIFIED FORM INPUTS ===== */

.form-control,
.form-select {
    display: block;
    width: 100%;
    padding: var(--space-3) var(--space-4);
    font-size: var(--text-base);
    font-weight: var(--font-normal);
    line-height: var(--leading-normal);
    color: var(--text-main);
    background-color: var(--bg-input);
    background-clip: padding-box;
    border: var(--border-width) solid var(--border-color-strong);
    border-radius: var(--radius-md);
    transition: var(--transition-fast);
    min-height: var(--touch-target);
    -webkit-appearance: none;
    appearance: none;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--primary-color);
    outline: 0;
    box-shadow: var(--focus-ring);
}

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

.form-control:disabled,
.form-select:disabled {
    background-color: var(--bg-subtle);
    opacity: 0.7;
    cursor: not-allowed;
}

/* Select Arrow */
.form-select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right var(--space-3) center;
    background-size: 16px;
    padding-right: var(--space-10);
}

/* Form Labels */
.form-label {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    margin-bottom: var(--space-2);
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    color: var(--text-muted);
}

/* Form Help Text */
.form-text {
    margin-top: var(--space-1);
    font-size: var(--text-xs);
    color: var(--text-light);
}

/* Textarea */
textarea.form-control {
    min-height: 100px;
    resize: vertical;
}

/* Input Group */
.input-group {
    position: relative;
    display: flex;
    flex-wrap: wrap;
    align-items: stretch;
    width: 100%;
}

.input-group > .form-control {
    position: relative;
    flex: 1 1 auto;
    width: 1%;
    min-width: 0;
}

/* ===== UNIFIED CARDS ===== */

.card {
    background: var(--bg-elevated);
    border: var(--border-width) solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    transition: var(--transition-fast);
}

.card-body {
    padding: var(--space-5);
}

.card-header {
    padding: var(--space-4) var(--space-5);
    background: var(--bg-surface);
    border-bottom: var(--border-width) solid var(--border-color);
    font-weight: var(--font-semibold);
}

.card-footer {
    padding: var(--space-4) var(--space-5);
    background: var(--bg-surface);
    border-top: var(--border-width) solid var(--border-color);
}

.card-interactive {
    cursor: pointer;
}

.card-interactive:hover {
    border-color: var(--border-color-hover);
    box-shadow: var(--shadow-md);
}

.card-interactive:active {
    transform: scale(0.995);
}

/* ===== SKELETON LOADERS ===== */

.skeleton {
    background: var(--bg-skeleton);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.5s ease-in-out infinite;
    border-radius: var(--radius-sm);
}

.skeleton-text {
    height: 1em;
    margin-bottom: var(--space-2);
}

.skeleton-text:last-child {
    width: 70%;
}

.skeleton-avatar {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
}

.skeleton-card {
    height: 120px;
}

@keyframes skeleton-shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ===== EMPTY STATES - Enhanced ===== */

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-12) var(--space-6);
    text-align: center;
}

.empty-state-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 80px;
    height: 80px;
    margin-bottom: var(--space-4);
    background: var(--bg-subtle);
    border-radius: var(--radius-xl);
    color: var(--text-light);
}

.empty-state-icon svg {
    width: 40px;
    height: 40px;
    opacity: 0.6;
}

.empty-state-title {
    font-size: var(--text-lg);
    font-weight: var(--font-semibold);
    color: var(--text-main);
    margin-bottom: var(--space-2);
}

.empty-state-description {
    font-size: var(--text-sm);
    color: var(--text-muted);
    max-width: 320px;
    margin: 0 auto var(--space-5);
}

.empty-state .btn {
    margin-top: var(--space-2);
}

/* Compact empty state */
.empty-state-compact {
    padding: var(--space-8) var(--space-4);
}

.empty-state-compact .empty-state-icon {
    width: 60px;
    height: 60px;
}

.empty-state-compact .empty-state-icon svg {
    width: 28px;
    height: 28px;
}

/* ===== BADGES & CHIPS ===== */

.badge,
.chip {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    padding: var(--space-1) var(--space-3);
    font-size: var(--text-xs);
    font-weight: var(--font-medium);
    line-height: var(--leading-tight);
    border-radius: var(--radius-full);
    white-space: nowrap;
}

.badge-primary,
.chip-primary {
    background: var(--primary-light);
    color: var(--primary-color);
}

.badge-success,
.chip-success {
    background: var(--success-light);
    color: var(--success-color);
}

.badge-danger,
.chip-danger {
    background: var(--danger-light);
    color: var(--danger-color);
}

.badge-warning,
.chip-warning {
    background: var(--warning-light);
    color: var(--warning-color);
}

.badge-info,
.chip-info {
    background: var(--info-light);
    color: var(--info-color);
}

.badge-ghost,
.chip-ghost {
    background: transparent;
    border: var(--border-width) dashed var(--border-color-strong);
    color: var(--text-muted);
}

/* ===== MICRO-INTERACTIONS ===== */

/* Tap feedback for all interactive elements */
.tap-target {
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.tap-target:active {
    transform: scale(0.97);
}

/* Smooth page transitions */
.page-transition {
    animation: pageIn 0.3s ease-out;
}

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

/* Fade in animation */
.fade-in {
    animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Slide up animation */
.slide-up {
    animation: slideUp 0.3s ease-out;
}

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

/* Scale in animation */
.scale-in {
    animation: scaleIn 0.2s ease-out;
}

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

/* Pulse animation for notifications */
.pulse {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* ===== TYPOGRAPHY UTILITIES ===== */

.text-xs { font-size: var(--text-xs); }
.text-sm { font-size: var(--text-sm); }
.text-base { font-size: var(--text-base); }
.text-md { font-size: var(--text-md); }
.text-lg { font-size: var(--text-lg); }
.text-xl { font-size: var(--text-xl); }
.text-2xl { font-size: var(--text-2xl); }
.text-3xl { font-size: var(--text-3xl); }

.font-normal { font-weight: var(--font-normal); }
.font-medium { font-weight: var(--font-medium); }
.font-semibold { font-weight: var(--font-semibold); }
.font-bold { font-weight: var(--font-bold); }

/* ===== SPACING UTILITIES ===== */

.p-0 { padding: var(--space-0); }
.p-1 { padding: var(--space-1); }
.p-2 { padding: var(--space-2); }
.p-3 { padding: var(--space-3); }
.p-4 { padding: var(--space-4); }
.p-5 { padding: var(--space-5); }
.p-6 { padding: var(--space-6); }

.m-0 { margin: var(--space-0); }
.m-1 { margin: var(--space-1); }
.m-2 { margin: var(--space-2); }
.m-3 { margin: var(--space-3); }
.m-4 { margin: var(--space-4); }
.m-5 { margin: var(--space-5); }
.m-6 { margin: var(--space-6); }

.gap-1 { gap: var(--space-1); }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.gap-5 { gap: var(--space-5); }
.gap-6 { gap: var(--space-6); }

/* ===== ACCESSIBILITY IMPROVEMENTS ===== */

/* Focus visible for keyboard navigation */
:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}

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

/* High contrast mode */
@media (prefers-contrast: high) {
    :root {
        --border-color: rgba(0, 0, 0, 0.3);
        --border-color-strong: rgba(0, 0, 0, 0.5);
    }
}

/* ===== DARK MODE - Unified Components ===== */

[data-theme="dark"] .form-control,
[data-theme="dark"] .form-select {
    background-color: var(--bg-input);
    border-color: var(--border-color-strong);
    color: var(--text-main);
}

[data-theme="dark"] .form-control:focus,
[data-theme="dark"] .form-select:focus {
    border-color: var(--primary-color);
}

[data-theme="dark"] .form-select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
}

[data-theme="dark"] .card {
    background: var(--bg-surface);
    border-color: var(--border-color);
}

[data-theme="dark"] .card-header,
[data-theme="dark"] .card-footer {
    background: var(--bg-elevated);
}

[data-theme="dark"] .skeleton {
    background: linear-gradient(90deg, var(--bg-surface) 25%, var(--bg-elevated) 50%, var(--bg-surface) 75%);
    background-size: 200% 100%;
}

[data-theme="dark"] .empty-state-icon {
    background: var(--bg-elevated);
}

[data-theme="dark"] .badge-ghost,
[data-theme="dark"] .chip-ghost {
    border-color: var(--border-color-strong);
}

[data-theme="dark"] .bottom-nav {
    background: rgba(12, 18, 34, 0.95);
    border-top-color: var(--border-color);
}

[data-theme="dark"] .bottom-nav-badge {
    border-color: var(--bg-body);
}

/* =====================================================
   UI/UX IMPROVEMENTS - Comprehensive Fixes
   ===================================================== */

/* ===== 1. FORM RESPONSIVENESS < 576px ===== */

@media (max-width: 576px) {
    /* Stack all form columns on small phones */
    .row.g-3 > [class*="col-md-"],
    .row.g-4 > [class*="col-md-"],
    .row.g-3 > [class*="col-lg-"],
    .row.g-4 > [class*="col-lg-"] {
        flex: 0 0 100%;
        max-width: 100%;
    }

    /* Exception: keep 2-col for small paired fields */
    .row.g-3 > .col-6,
    .row.g-4 > .col-6 {
        flex: 0 0 50%;
        max-width: 50%;
    }

    /* Form cards - reduce padding */
    .card-body {
        padding: 1rem;
    }

    /* Page header - stack on mobile */
    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

    .page-header .btn {
        width: 100%;
    }

    /* Invoice sidebar - make full width on mobile */
    .col-lg-4 .card.position-sticky {
        position: relative !important;
        top: auto !important;
    }

    /* Form labels - slightly larger on mobile */
    .form-label {
        font-size: var(--text-sm);
    }

    /* Reduce form-group spacing */
    .mb-4 {
        margin-bottom: 1rem !important;
    }

    .mb-3 {
        margin-bottom: 0.75rem !important;
    }
}

/* Very small screens (iPhone SE, etc.) */
@media (max-width: 375px) {
    .row.g-3 > .col-6,
    .row.g-4 > .col-6 {
        flex: 0 0 100%;
        max-width: 100%;
    }

    .card-body {
        padding: 0.875rem;
    }

    .form-control,
    .form-select {
        font-size: 16px; /* Prevents iOS zoom on focus */
    }
}

/* ===== 2. TOUCH TARGETS - 44px MINIMUM ===== */

.action-dropdown-toggle {
    min-width: var(--touch-target);
    min-height: var(--touch-target);
}

@media (max-width: 768px) {
    .action-dropdown-toggle {
        width: var(--touch-target);
        height: var(--touch-target);
    }
}

/* Ensure all interactive elements meet touch target */
.tap-target {
    min-height: var(--touch-target);
}

.btn-sm {
    min-height: var(--touch-target-sm);
}

.btn-icon {
    min-width: var(--touch-target);
    min-height: var(--touch-target);
}

.btn-icon.btn-sm {
    min-width: var(--touch-target-sm);
    min-height: var(--touch-target-sm);
}

/* Links in lists/tables should have adequate tap area */
.table a,
.list-group-item a {
    display: inline-block;
    padding: 0.25rem 0;
    min-height: 32px;
    line-height: 1.5;
}

/* Page link touch targets */
.page-link {
    min-width: var(--touch-target);
    min-height: var(--touch-target);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ===== 3. FORM VALIDATION ACCESSIBILITY ===== */

/* Error container with live region */
.form-error-summary {
    padding: 1rem;
    background: var(--danger-light);
    border: 1px solid var(--danger-color);
    border-radius: var(--radius-md);
    margin-bottom: 1.5rem;
}

.form-error-summary h4 {
    color: var(--danger-color);
    font-size: var(--text-md);
    font-weight: var(--font-semibold);
    margin: 0 0 0.5rem 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.form-error-summary ul {
    margin: 0;
    padding-left: 1.25rem;
    color: var(--danger-color);
}

.form-error-summary li {
    margin-bottom: 0.25rem;
}

/* Error messages styling - enhanced visibility */
.invalid-feedback,
.text-danger.small,
.field-error {
    display: flex;
    align-items: flex-start;
    gap: 0.35rem;
    margin-top: 0.35rem;
    font-size: var(--text-sm);
    color: var(--danger-color);
    font-weight: var(--font-medium);
}

/* Ensure error messages are always visible */
.form-control.is-invalid ~ .invalid-feedback,
.form-select.is-invalid ~ .invalid-feedback {
    display: flex;
}

/* Focus indicator for invalid fields */
.form-control.is-invalid:focus,
.form-select.is-invalid:focus {
    box-shadow: var(--focus-ring-danger);
}

/* ===== 4. TABLE LAYOUT FOR 768-820px TABLETS ===== */

@media (min-width: 768px) and (max-width: 820px) {
    /* Tighter table cells on tablets */
    .table > :not(caption) > * > * {
        padding: 0.5rem 0.4rem;
        font-size: var(--text-sm);
    }

    /* Hide less important columns on small tablets */
    .table .hide-tablet {
        display: none;
    }

    /* Truncate long text in cells */
    .table td {
        max-width: 150px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    /* Exception for action buttons */
    .table td:last-child {
        max-width: none;
        white-space: normal;
    }

    /* Stack layout-duo on tablets */
    .layout-duo {
        grid-template-columns: 1fr;
    }
}

/* Tablet portrait mode */
@media (min-width: 768px) and (max-width: 1024px) and (orientation: portrait) {
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Horizontal scroll indicator */
    .table-responsive::after {
        content: '';
        position: absolute;
        right: 0;
        top: 0;
        bottom: 0;
        width: 40px;
        background: linear-gradient(to right, transparent, var(--bg-surface));
        pointer-events: none;
        opacity: 0;
        transition: opacity 0.2s;
    }

    .table-responsive.has-scroll::after {
        opacity: 1;
    }
}

/* ===== 5. DARK MODE CONTRAST IMPROVEMENTS ===== */

[data-theme="dark"] {
    /* Increase secondary text contrast */
    --text-light: #8b9cb8;  /* Increased from #64748b to ~5.5:1 contrast */
    --text-muted: #a1b1c9;  /* Increased from #94a3b8 for better readability */
    --text-placeholder: #6b7a8f;
}

/* Ensure badges/chips have sufficient contrast */
[data-theme="dark"] .badge,
[data-theme="dark"] .chip {
    font-weight: var(--font-semibold);
}

[data-theme="dark"] .text-muted {
    color: var(--text-muted) !important;
}

[data-theme="dark"] .text-secondary {
    color: var(--text-light) !important;
}

/* Better contrast for form hints */
[data-theme="dark"] .form-text {
    color: var(--text-muted);
}

/* ===== 6. STANDARDIZED EMPTY STATES ===== */

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: var(--space-10) var(--space-6);
    min-height: 200px;
}

.empty-state-icon {
    width: 80px;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-full);
    background: var(--bg-subtle);
    margin-bottom: var(--space-4);
    color: var(--text-light);
}

.empty-state-icon svg {
    width: 40px;
    height: 40px;
    stroke-width: 1.5;
}

.empty-state-title {
    font-size: var(--text-lg);
    font-weight: var(--font-semibold);
    color: var(--text-main);
    margin-bottom: var(--space-2);
}

.empty-state-description {
    font-size: var(--text-base);
    color: var(--text-muted);
    max-width: 300px;
    margin-bottom: var(--space-5);
}

.empty-state .btn {
    margin-top: var(--space-2);
}

/* Compact empty state for cards/sidebars */
.empty-state-compact {
    padding: var(--space-6) var(--space-4);
    min-height: auto;
}

.empty-state-compact .empty-state-icon {
    width: 56px;
    height: 56px;
    margin-bottom: var(--space-3);
}

.empty-state-compact .empty-state-icon svg {
    width: 28px;
    height: 28px;
}

.empty-state-compact .empty-state-title {
    font-size: var(--text-base);
}

.empty-state-compact .empty-state-description {
    font-size: var(--text-sm);
}

/* ===== 7. MOBILE-OPTIMIZED PAGINATION ===== */

.pagination {
    display: flex;
    gap: 0.25rem;
    flex-wrap: wrap;
    justify-content: center;
}

.page-item {
    margin: 0;
}

.page-link {
    padding: 0;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    background: var(--bg-surface);
    color: var(--text-muted);
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    transition: var(--transition-fast);
}

.page-link:hover {
    background: var(--bg-hover);
    border-color: var(--primary-light);
    color: var(--primary-color);
}

.page-item.active .page-link {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

.page-item.disabled .page-link {
    background: var(--bg-subtle);
    color: var(--text-placeholder);
    cursor: not-allowed;
}

@media (max-width: 576px) {
    /* Compact pagination on mobile */
    .pagination {
        gap: 0.125rem;
    }

    .page-link {
        min-width: 36px;
        min-height: 36px;
        font-size: var(--text-xs);
    }

    /* Hide extra page numbers, show only essential */
    .page-item:not(.active):not(:first-child):not(:last-child):not(:nth-child(2)):not(:nth-last-child(2)) {
        display: none;
    }

    /* Always show first, last, prev, next, current */
    .page-item.active,
    .page-item:first-child,
    .page-item:last-child {
        display: block;
    }
}

/* Pagination info text */
.pagination-info {
    font-size: var(--text-sm);
    color: var(--text-muted);
    text-align: center;
    margin-top: var(--space-2);
}

/* ===== 8. SKELETON LOADING COMPONENTS ===== */

.skeleton-container {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
}

/* Skeleton card for dashboards */
.skeleton-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--space-4);
}

.skeleton-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-4);
}

.skeleton-card-body {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

/* Skeleton lines with shimmer */
.skeleton-line {
    height: 1rem;
    background: var(--bg-skeleton);
    background-size: 200% 100%;
    border-radius: var(--radius-sm);
    animation: skeleton-shimmer 1.5s infinite;
}

.skeleton-line.short { width: 60%; }
.skeleton-line.medium { width: 80%; }
.skeleton-line.full { width: 100%; }
.skeleton-line.tiny { width: 40%; height: 0.75rem; }

/* Skeleton circle (avatars) */
.skeleton-circle {
    border-radius: var(--radius-full);
    background: var(--bg-skeleton);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.5s infinite;
}

.skeleton-circle.sm { width: 32px; height: 32px; }
.skeleton-circle.md { width: 48px; height: 48px; }
.skeleton-circle.lg { width: 64px; height: 64px; }

/* Skeleton for table rows */
.skeleton-table-row {
    display: flex;
    gap: var(--space-4);
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--border-color);
}

.skeleton-table-cell {
    flex: 1;
}

/* Skeleton for stat cards */
.skeleton-stat-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--space-4);
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

@keyframes skeleton-shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Reduce motion: disable shimmer */
@media (prefers-reduced-motion: reduce) {
    .skeleton-line,
    .skeleton-circle {
        animation: none;
        background: var(--bg-subtle);
    }
}

/* ===== 9. KEYBOARD NAVIGATION & FOCUS STATES ===== */

/* High-visibility focus ring */
:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}

/* Skip link for keyboard users */
.skip-link {
    position: absolute;
    top: -100px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--primary-color);
    color: white;
    padding: var(--space-3) var(--space-5);
    border-radius: var(--radius-md);
    font-weight: var(--font-semibold);
    z-index: 9999;
    transition: top 0.2s;
}

.skip-link:focus {
    top: var(--space-4);
    color: white;
}

/* Focus visible on buttons */
.btn:focus-visible {
    box-shadow: var(--focus-ring);
}

/* Focus visible on form controls */
.form-control:focus-visible,
.form-select:focus-visible {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: var(--focus-ring);
}

/* Focus visible on links */
a:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}

/* Focus visible on cards/list items */
.card:focus-visible,
.list-group-item:focus-visible,
.dropdown-item:focus-visible {
    outline: none;
    box-shadow: inset 0 0 0 2px var(--primary-color);
}

/* Focus ring on nav items */
.nav-link:focus-visible,
.bottom-nav-item:focus-visible {
    outline: none;
    box-shadow: inset 0 0 0 2px var(--primary-color);
    border-radius: var(--radius-md);
}

/* Keyboard focus indicator for dropdown menus */
.dropdown-menu:focus-within {
    box-shadow: var(--shadow-lg), var(--focus-ring);
}

/* Tab focus order visual indicator */
[tabindex]:focus-visible {
    box-shadow: var(--focus-ring);
}

/* ===== 10. ICON SIZING UTILITIES ===== */

.icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.icon-xs { width: 12px; height: 12px; }
.icon-sm { width: 16px; height: 16px; }
.icon-md { width: 20px; height: 20px; }
.icon-lg { width: 24px; height: 24px; }
.icon-xl { width: 32px; height: 32px; }
.icon-2xl { width: 40px; height: 40px; }
.icon-3xl { width: 48px; height: 48px; }

/* Icon colors */
.icon-primary { color: var(--primary-color); }
.icon-success { color: var(--success-color); }
.icon-danger { color: var(--danger-color); }
.icon-warning { color: var(--warning-color); }
.icon-info { color: var(--info-color); }
.icon-muted { color: var(--text-muted); }

/* Icon in buttons - auto-size */
.btn svg,
.btn .icon {
    width: 1.125em;
    height: 1.125em;
}

.btn-sm svg,
.btn-sm .icon {
    width: 1em;
    height: 1em;
}

.btn-lg svg,
.btn-lg .icon {
    width: 1.25em;
    height: 1.25em;
}

/* ===== 11. TOAST NOTIFICATION POSITIONING ===== */

.toast-container {
    position: fixed;
    z-index: var(--z-toast);
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    max-width: 400px;
    pointer-events: none;
}

/* Desktop: top-right, avoiding sidebar */
@media (min-width: 992px) {
    .toast-container {
        top: calc(var(--header-height) + var(--space-4));
        right: var(--space-4);
    }
}

/* Tablet: top-center */
@media (min-width: 768px) and (max-width: 991px) {
    .toast-container {
        top: calc(var(--header-height) + var(--space-4));
        left: 50%;
        transform: translateX(-50%);
    }
}

/* Mobile: bottom-center, above bottom nav */
@media (max-width: 767px) {
    .toast-container {
        bottom: calc(var(--bottom-nav-height) + var(--space-4));
        left: var(--space-4);
        right: var(--space-4);
        max-width: none;
    }
}

.toast {
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    padding: var(--space-4);
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    pointer-events: auto;
    animation: toastSlideIn 0.3s ease;
}

.toast-success { border-left: 4px solid var(--success-color); }
.toast-danger { border-left: 4px solid var(--danger-color); }
.toast-warning { border-left: 4px solid var(--warning-color); }
.toast-info { border-left: 4px solid var(--info-color); }

.toast-icon {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
}

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

.toast-title {
    font-weight: var(--font-semibold);
    font-size: var(--text-base);
    margin-bottom: var(--space-1);
}

.toast-message {
    font-size: var(--text-sm);
    color: var(--text-muted);
}

.toast-close {
    flex-shrink: 0;
    padding: var(--space-1);
    background: none;
    border: none;
    color: var(--text-light);
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: var(--transition-fast);
}

.toast-close:hover {
    background: var(--bg-hover);
    color: var(--text-main);
}

@keyframes toastSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 767px) {
    @keyframes toastSlideIn {
        from {
            opacity: 0;
            transform: translateY(20px);
        }
        to {
            opacity: 1;
            transform: translateY(0);
        }
    }
}

/* ===== 12. BREADCRUMB NAVIGATION ===== */

.breadcrumb {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-1);
    padding: 0;
    margin: 0 0 var(--space-3) 0;
    background: transparent;
    font-size: var(--text-sm);
    list-style: none;
}

.breadcrumb-item {
    display: flex;
    align-items: center;
}

.breadcrumb-item a {
    color: var(--text-muted);
    text-decoration: none;
    transition: var(--transition-fast);
    padding: var(--space-1) 0;
}

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

.breadcrumb-item.active {
    color: var(--text-main);
    font-weight: var(--font-medium);
}

.breadcrumb-separator {
    color: var(--text-placeholder);
    margin: 0 var(--space-1);
}

.breadcrumb-separator svg {
    width: 14px;
    height: 14px;
}

/* Truncate long breadcrumb on mobile */
@media (max-width: 576px) {
    .breadcrumb {
        font-size: var(--text-xs);
    }

    .breadcrumb-item a,
    .breadcrumb-item.active {
        max-width: 100px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    /* Hide middle items if too many */
    .breadcrumb-item:not(:first-child):not(:last-child):not(:nth-child(2)) {
        display: none;
    }

    /* Show ellipsis */
    .breadcrumb-item.breadcrumb-ellipsis {
        display: flex;
    }
}

/* ===== 13. DATE INPUT CROSS-BROWSER FIXES ===== */

/* Standard date input styling */
input[type="date"],
input[type="time"],
input[type="datetime-local"] {
    appearance: none;
    -webkit-appearance: none;
    position: relative;
    padding-right: 2.5rem;
}

/* Custom calendar icon */
input[type="date"]::-webkit-calendar-picker-indicator,
input[type="time"]::-webkit-calendar-picker-indicator,
input[type="datetime-local"]::-webkit-calendar-picker-indicator {
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    padding: 0;
    margin: 0;
    cursor: pointer;
    opacity: 0.6;
    transition: opacity 0.2s;
}

input[type="date"]:hover::-webkit-calendar-picker-indicator,
input[type="time"]:hover::-webkit-calendar-picker-indicator,
input[type="datetime-local"]:hover::-webkit-calendar-picker-indicator {
    opacity: 1;
}

/* Firefox date input */
input[type="date"]::-moz-focus-inner {
    border: 0;
}

/* Ensure minimum font size to prevent iOS zoom */
@media (max-width: 768px) {
    input[type="date"],
    input[type="time"],
    input[type="datetime-local"] {
        font-size: 16px;
    }
}

/* Safari iOS date picker overrides */
@supports (-webkit-touch-callout: none) {
    input[type="date"],
    input[type="time"],
    input[type="datetime-local"] {
        min-height: var(--touch-target);
    }
}

/* Dark mode date picker icon */
[data-theme="dark"] input[type="date"]::-webkit-calendar-picker-indicator,
[data-theme="dark"] input[type="time"]::-webkit-calendar-picker-indicator,
[data-theme="dark"] input[type="datetime-local"]::-webkit-calendar-picker-indicator {
    filter: invert(0.8);
}

/* ===== ADDITIONAL POLISH ===== */

/* Smooth scroll for anchor links */
html {
    scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }
}

/* Better text selection */
::selection {
    background: var(--primary-light);
    color: var(--primary-color);
}

[data-theme="dark"] ::selection {
    background: var(--primary-subtle);
    color: var(--primary-color);
}

/* Print styles */
@media print {
    .bottom-nav,
    .sidebar,
    .navbar,
    .fab,
    .toast-container,
    .btn-icon,
    .action-dropdown {
        display: none !important;
    }

    .page-shell {
        padding: 0;
    }

    .card {
        box-shadow: none;
        border: 1px solid #ddd;
    }
}
