:root {
    --primary: #6366F1;
    --primary-light: #818CF8;
    --primary-hover: #4F46E5;
    --primary-rgb: 99, 102, 241;
    --primary-light-rgb: 129, 140, 248;
    --primary-soft: rgba(99, 102, 241, 0.12);
    --primary-border: rgba(99, 102, 241, 0.24);
    --focus-ring: rgba(99, 102, 241, 0.14);
    --shadow-tint: rgba(99, 102, 241, 0.22);
    --shadow-tint-strong: rgba(99, 102, 241, 0.3);
    --page-glow-start: rgba(99, 102, 241, 0.05);
    --page-glow-end: rgba(129, 140, 248, 0.05);
    --bg-color: #F8FAFC;
    --bg-color-alt: #EEF3FB;
    --card-bg: rgba(255, 255, 255, 0.9);
    --glass-bg: rgba(255, 255, 255, 0.7);
    --glass-border: rgba(255, 255, 255, 0.5);
    --text-main: #0F172A;
    --text-muted: #64748B;
    --border-color: #E2E8F0;
    --surface-soft: #F8FBFF;
    --surface-muted: #F3F6FB;
    --indigo: #6366f1;
    --indigo-hover: #4f46e5;
    --indigo-soft: rgba(99, 102, 241, 0.1);
    --error: #EF4444;
    --success: #10B981;
    --warning: #D97706;
    --danger: #EF4444;
    --danger-strong: #DC2626;
    --sidebar-width: 280px;
    --radius-lg: 1rem;
    --radius-md: 0.75rem;
    --radius-sm: 0.5rem;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --app-soft-bg: #eef4ff;
    --app-soft-bg-alt: #f7faff;
    --app-soft-card: rgba(255, 255, 255, 0.88);
    --app-soft-card-strong: rgba(255, 255, 255, 0.96);
    --app-soft-border: rgba(181, 196, 255, 0.34);
    --app-soft-shadow: 0 24px 48px -32px rgba(106, 129, 214, 0.34);
    --app-soft-shadow-sm: 0 16px 36px -28px rgba(106, 129, 214, 0.28);
    --app-soft-text: #18233f;
    --app-soft-muted: #6d7c9e;
    --app-soft-accent: #6f6af7;
    --app-soft-accent-hover: #5a54e8;
    --app-soft-accent-bg: rgba(111, 106, 247, 0.12);
    --theme-page: #f6f8fc;
    --theme-page-alt: #eef3fb;
    --theme-surface: #ffffff;
    --theme-surface-soft: #f8fbff;
    --theme-surface-muted: #f3f6fb;
    --theme-border-strong: #dbe4f0;
    --theme-accent: var(--primary);
    --theme-accent-strong: var(--primary-hover);
    --theme-accent-soft: rgba(99, 102, 241, 0.12);
    --theme-accent-border: rgba(99, 102, 241, 0.24);
    --theme-accent-ring: rgba(99, 102, 241, 0.18);
    --theme-accent-shadow: rgba(99, 102, 241, 0.18);
    --theme-success: #17985f;
    --theme-warning: #d97706;
    --theme-danger: #d4374b;
    --theme-danger-strong: #b72239;
}

body[data-app-theme="indigo"] {
    --primary: #6366F1;
    --primary-light: #818CF8;
    --primary-hover: #4F46E5;
    --primary-rgb: 99, 102, 241;
    --primary-light-rgb: 129, 140, 248;
    --primary-soft: rgba(99, 102, 241, 0.12);
    --primary-border: rgba(99, 102, 241, 0.24);
    --focus-ring: rgba(99, 102, 241, 0.14);
    --shadow-tint: rgba(99, 102, 241, 0.22);
    --shadow-tint-strong: rgba(99, 102, 241, 0.3);
    --page-glow-start: rgba(99, 102, 241, 0.05);
    --page-glow-end: rgba(129, 140, 248, 0.05);
}

body[data-app-theme="emerald"] {
    --primary: #1F9D73;
    --primary-light: #34D399;
    --primary-hover: #157F5B;
    --primary-rgb: 31, 157, 115;
    --primary-light-rgb: 52, 211, 153;
    --primary-soft: rgba(31, 157, 115, 0.12);
    --primary-border: rgba(31, 157, 115, 0.24);
    --focus-ring: rgba(31, 157, 115, 0.14);
    --shadow-tint: rgba(31, 157, 115, 0.2);
    --shadow-tint-strong: rgba(31, 157, 115, 0.28);
    --page-glow-start: rgba(31, 157, 115, 0.05);
    --page-glow-end: rgba(52, 211, 153, 0.05);
    --bg-color: #F6FBF8;
    --bg-color-alt: #EDF8F2;
    --surface-soft: #F7FDF9;
    --surface-muted: #EEF9F2;
    --border-color: #D7E9DF;
    --app-soft-bg: #E8F7F0;
    --app-soft-bg-alt: #F4FCF7;
    --app-soft-border: rgba(125, 211, 174, 0.3);
    --app-soft-shadow: 0 24px 48px -32px rgba(23, 128, 93, 0.24);
    --app-soft-shadow-sm: 0 16px 36px -28px rgba(23, 128, 93, 0.2);
    --app-soft-text: #163429;
    --app-soft-muted: #607668;
    --app-soft-accent: #1F9D73;
    --app-soft-accent-hover: #157F5B;
    --app-soft-accent-bg: rgba(31, 157, 115, 0.12);
    --theme-page: #F5FBF8;
    --theme-page-alt: #EDF8F2;
    --theme-surface-soft: #F7FDF9;
    --theme-surface-muted: #EEF9F2;
    --theme-border-strong: #D7E9DF;
    --theme-accent: #1F9D73;
    --theme-accent-strong: #157F5B;
    --theme-accent-soft: rgba(31, 157, 115, 0.12);
    --theme-accent-border: rgba(31, 157, 115, 0.24);
    --theme-accent-ring: rgba(31, 157, 115, 0.18);
    --theme-accent-shadow: rgba(31, 157, 115, 0.18);
    --theme-success: #15803D;
    --theme-warning: #C47A12;
    --theme-danger: #CC425C;
    --theme-danger-strong: #B91C1C;
}

body[data-app-theme="ocean"] {
    --primary: #0F8FAF;
    --primary-light: #38BDF8;
    --primary-hover: #0D7691;
    --primary-rgb: 15, 143, 175;
    --primary-light-rgb: 56, 189, 248;
    --primary-soft: rgba(15, 143, 175, 0.12);
    --primary-border: rgba(15, 143, 175, 0.24);
    --focus-ring: rgba(15, 143, 175, 0.14);
    --shadow-tint: rgba(15, 143, 175, 0.2);
    --shadow-tint-strong: rgba(15, 143, 175, 0.28);
    --page-glow-start: rgba(15, 143, 175, 0.05);
    --page-glow-end: rgba(56, 189, 248, 0.05);
    --bg-color: #F4FAFC;
    --bg-color-alt: #EDF7FB;
    --surface-soft: #F8FCFF;
    --surface-muted: #EEF8FB;
    --border-color: #D7E8EE;
    --app-soft-bg: #E8F7FB;
    --app-soft-bg-alt: #F2FBFD;
    --app-soft-border: rgba(125, 211, 252, 0.32);
    --app-soft-shadow: 0 24px 48px -32px rgba(15, 118, 145, 0.24);
    --app-soft-shadow-sm: 0 16px 36px -28px rgba(15, 118, 145, 0.2);
    --app-soft-text: #17323D;
    --app-soft-muted: #637787;
    --app-soft-accent: #0F8FAF;
    --app-soft-accent-hover: #0D7691;
    --app-soft-accent-bg: rgba(15, 143, 175, 0.12);
    --theme-page: #F4FAFC;
    --theme-page-alt: #EDF7FB;
    --theme-surface-soft: #F8FCFF;
    --theme-surface-muted: #EEF8FB;
    --theme-border-strong: #D7E8EE;
    --theme-accent: #0F8FAF;
    --theme-accent-strong: #0D7691;
    --theme-accent-soft: rgba(15, 143, 175, 0.12);
    --theme-accent-border: rgba(15, 143, 175, 0.24);
    --theme-accent-ring: rgba(15, 143, 175, 0.18);
    --theme-accent-shadow: rgba(15, 143, 175, 0.18);
    --theme-success: #0F9F74;
    --theme-warning: #D18518;
    --theme-danger: #D9485F;
    --theme-danger-strong: #BE123C;
}

body[data-app-theme="graphite-red"] {
    --primary: #991B1B;
    --primary-light: #EF4444;
    --primary-hover: #7F1D1D;
    --primary-rgb: 153, 27, 27;
    --primary-light-rgb: 239, 68, 68;
    --primary-soft: rgba(153, 27, 27, 0.12);
    --primary-border: rgba(153, 27, 27, 0.24);
    --focus-ring: rgba(153, 27, 27, 0.14);
    --shadow-tint: rgba(17, 17, 17, 0.18);
    --shadow-tint-strong: rgba(17, 17, 17, 0.26);
    --page-glow-start: rgba(153, 27, 27, 0.04);
    --page-glow-end: rgba(239, 68, 68, 0.04);
    --bg-color: #F8F7F7;
    --bg-color-alt: #F2EFEF;
    --surface-soft: #FBF8F8;
    --surface-muted: #F5F1F1;
    --border-color: #E7DEDE;
    --app-soft-bg: #F2EEEE;
    --app-soft-bg-alt: #F8F6F6;
    --app-soft-border: rgba(216, 180, 180, 0.32);
    --app-soft-shadow: 0 24px 48px -32px rgba(67, 21, 21, 0.18);
    --app-soft-shadow-sm: 0 16px 36px -28px rgba(67, 21, 21, 0.14);
    --app-soft-text: #251B1B;
    --app-soft-muted: #726767;
    --app-soft-accent: #991B1B;
    --app-soft-accent-hover: #7F1D1D;
    --app-soft-accent-bg: rgba(153, 27, 27, 0.1);
    --theme-page: #F8F7F7;
    --theme-page-alt: #F2EFEF;
    --theme-surface-soft: #FBF8F8;
    --theme-surface-muted: #F5F1F1;
    --theme-border-strong: #E7DEDE;
    --theme-accent: #1F1F1F;
    --theme-accent-strong: #111111;
    --theme-accent-soft: rgba(185, 28, 28, 0.1);
    --theme-accent-border: rgba(127, 29, 29, 0.24);
    --theme-accent-ring: rgba(153, 27, 27, 0.16);
    --theme-accent-shadow: rgba(17, 17, 17, 0.16);
    --theme-success: #15803D;
    --theme-warning: #B45309;
    --theme-danger: #B91C1C;
    --theme-danger-strong: #991B1B;
}

body[data-app-theme="violet"] {
    --primary: #7C3AED;
    --primary-light: #A78BFA;
    --primary-hover: #6D28D9;
    --primary-rgb: 124, 58, 237;
    --primary-light-rgb: 167, 139, 250;
    --primary-soft: rgba(124, 58, 237, 0.12);
    --primary-border: rgba(124, 58, 237, 0.24);
    --focus-ring: rgba(124, 58, 237, 0.14);
    --shadow-tint: rgba(124, 58, 237, 0.2);
    --shadow-tint-strong: rgba(124, 58, 237, 0.28);
    --page-glow-start: rgba(124, 58, 237, 0.05);
    --page-glow-end: rgba(167, 139, 250, 0.05);
    --bg-color: #F8F7FF;
    --bg-color-alt: #F2F0FF;
    --surface-soft: #FAF8FF;
    --surface-muted: #F5F3FF;
    --border-color: #E6DDF9;
    --app-soft-bg: #F0ECFF;
    --app-soft-bg-alt: #F8F6FF;
    --app-soft-border: rgba(196, 181, 253, 0.34);
    --app-soft-shadow: 0 24px 48px -32px rgba(109, 40, 217, 0.24);
    --app-soft-shadow-sm: 0 16px 36px -28px rgba(109, 40, 217, 0.2);
    --app-soft-text: #22183F;
    --app-soft-muted: #6D6492;
    --app-soft-accent: #7C3AED;
    --app-soft-accent-hover: #6D28D9;
    --app-soft-accent-bg: rgba(124, 58, 237, 0.12);
    --theme-page: #F8F7FF;
    --theme-page-alt: #F2F0FF;
    --theme-surface-soft: #FAF8FF;
    --theme-surface-muted: #F5F3FF;
    --theme-border-strong: #E6DDF9;
    --theme-accent: #7C3AED;
    --theme-accent-strong: #6D28D9;
    --theme-accent-soft: rgba(124, 58, 237, 0.12);
    --theme-accent-border: rgba(124, 58, 237, 0.24);
    --theme-accent-ring: rgba(124, 58, 237, 0.18);
    --theme-accent-shadow: rgba(124, 58, 237, 0.18);
}

body[data-app-theme="teal"] {
    --primary: #0F766E;
    --primary-light: #2DD4BF;
    --primary-hover: #115E59;
    --primary-rgb: 15, 118, 110;
    --primary-light-rgb: 45, 212, 191;
    --primary-soft: rgba(15, 118, 110, 0.12);
    --primary-border: rgba(15, 118, 110, 0.24);
    --focus-ring: rgba(15, 118, 110, 0.14);
    --shadow-tint: rgba(15, 118, 110, 0.2);
    --shadow-tint-strong: rgba(15, 118, 110, 0.28);
    --page-glow-start: rgba(15, 118, 110, 0.05);
    --page-glow-end: rgba(45, 212, 191, 0.05);
    --bg-color: #F4FBFA;
    --bg-color-alt: #EBF8F6;
    --surface-soft: #F7FDFC;
    --surface-muted: #EEF9F7;
    --border-color: #D6ECE7;
    --app-soft-bg: #E7F7F3;
    --app-soft-bg-alt: #F4FCFA;
    --app-soft-border: rgba(153, 246, 228, 0.32);
    --app-soft-shadow: 0 24px 48px -32px rgba(15, 118, 110, 0.22);
    --app-soft-shadow-sm: 0 16px 36px -28px rgba(15, 118, 110, 0.18);
    --app-soft-text: #153631;
    --app-soft-muted: #5F7C78;
    --app-soft-accent: #0F766E;
    --app-soft-accent-hover: #115E59;
    --app-soft-accent-bg: rgba(15, 118, 110, 0.12);
    --theme-page: #F4FBFA;
    --theme-page-alt: #EBF8F6;
    --theme-surface-soft: #F7FDFC;
    --theme-surface-muted: #EEF9F7;
    --theme-border-strong: #D6ECE7;
    --theme-accent: #0F766E;
    --theme-accent-strong: #115E59;
    --theme-accent-soft: rgba(15, 118, 110, 0.12);
    --theme-accent-border: rgba(15, 118, 110, 0.24);
    --theme-accent-ring: rgba(15, 118, 110, 0.18);
    --theme-accent-shadow: rgba(15, 118, 110, 0.18);
}

body[data-app-theme="amber"] {
    --primary: #D97706;
    --primary-light: #F59E0B;
    --primary-hover: #B45309;
    --primary-rgb: 217, 119, 6;
    --primary-light-rgb: 245, 158, 11;
    --primary-soft: rgba(217, 119, 6, 0.12);
    --primary-border: rgba(217, 119, 6, 0.24);
    --focus-ring: rgba(217, 119, 6, 0.14);
    --shadow-tint: rgba(217, 119, 6, 0.2);
    --shadow-tint-strong: rgba(217, 119, 6, 0.28);
    --page-glow-start: rgba(217, 119, 6, 0.05);
    --page-glow-end: rgba(245, 158, 11, 0.05);
    --bg-color: #FFFBF5;
    --bg-color-alt: #FFF6E8;
    --surface-soft: #FFFCF8;
    --surface-muted: #FFF6E7;
    --border-color: #F3E1BF;
    --app-soft-bg: #FFF3DF;
    --app-soft-bg-alt: #FFF9F0;
    --app-soft-border: rgba(253, 186, 116, 0.34);
    --app-soft-shadow: 0 24px 48px -32px rgba(180, 83, 9, 0.22);
    --app-soft-shadow-sm: 0 16px 36px -28px rgba(180, 83, 9, 0.18);
    --app-soft-text: #3E260D;
    --app-soft-muted: #8A6A42;
    --app-soft-accent: #D97706;
    --app-soft-accent-hover: #B45309;
    --app-soft-accent-bg: rgba(217, 119, 6, 0.12);
    --theme-page: #FFFBF5;
    --theme-page-alt: #FFF6E8;
    --theme-surface-soft: #FFFCF8;
    --theme-surface-muted: #FFF6E7;
    --theme-border-strong: #F3E1BF;
    --theme-accent: #D97706;
    --theme-accent-strong: #B45309;
    --theme-accent-soft: rgba(217, 119, 6, 0.12);
    --theme-accent-border: rgba(217, 119, 6, 0.24);
    --theme-accent-ring: rgba(217, 119, 6, 0.18);
    --theme-accent-shadow: rgba(217, 119, 6, 0.18);
}

body[data-app-theme="rose"] {
    --primary: #E11D48;
    --primary-light: #FB7185;
    --primary-hover: #BE123C;
    --primary-rgb: 225, 29, 72;
    --primary-light-rgb: 251, 113, 133;
    --primary-soft: rgba(225, 29, 72, 0.12);
    --primary-border: rgba(225, 29, 72, 0.24);
    --focus-ring: rgba(225, 29, 72, 0.14);
    --shadow-tint: rgba(225, 29, 72, 0.2);
    --shadow-tint-strong: rgba(225, 29, 72, 0.28);
    --page-glow-start: rgba(225, 29, 72, 0.05);
    --page-glow-end: rgba(251, 113, 133, 0.05);
    --bg-color: #FFF7F8;
    --bg-color-alt: #FFF0F3;
    --surface-soft: #FFF9FA;
    --surface-muted: #FFF1F4;
    --border-color: #F5D7DF;
    --app-soft-bg: #FFECEF;
    --app-soft-bg-alt: #FFF8F9;
    --app-soft-border: rgba(253, 164, 175, 0.34);
    --app-soft-shadow: 0 24px 48px -32px rgba(190, 18, 60, 0.22);
    --app-soft-shadow-sm: 0 16px 36px -28px rgba(190, 18, 60, 0.18);
    --app-soft-text: #3F1824;
    --app-soft-muted: #8B6170;
    --app-soft-accent: #E11D48;
    --app-soft-accent-hover: #BE123C;
    --app-soft-accent-bg: rgba(225, 29, 72, 0.12);
    --theme-page: #FFF7F8;
    --theme-page-alt: #FFF0F3;
    --theme-surface-soft: #FFF9FA;
    --theme-surface-muted: #FFF1F4;
    --theme-border-strong: #F5D7DF;
    --theme-accent: #E11D48;
    --theme-accent-strong: #BE123C;
    --theme-accent-soft: rgba(225, 29, 72, 0.12);
    --theme-accent-border: rgba(225, 29, 72, 0.24);
    --theme-accent-ring: rgba(225, 29, 72, 0.18);
    --theme-accent-shadow: rgba(225, 29, 72, 0.18);
}

body[data-app-theme="cobalt"] {
    --primary: #2563EB;
    --primary-light: #60A5FA;
    --primary-hover: #1D4ED8;
    --primary-rgb: 37, 99, 235;
    --primary-light-rgb: 96, 165, 250;
    --primary-soft: rgba(37, 99, 235, 0.12);
    --primary-border: rgba(37, 99, 235, 0.24);
    --focus-ring: rgba(37, 99, 235, 0.14);
    --shadow-tint: rgba(37, 99, 235, 0.2);
    --shadow-tint-strong: rgba(37, 99, 235, 0.28);
    --page-glow-start: rgba(37, 99, 235, 0.05);
    --page-glow-end: rgba(96, 165, 250, 0.05);
    --bg-color: #F5F9FF;
    --bg-color-alt: #EDF4FF;
    --surface-soft: #F8FBFF;
    --surface-muted: #EEF5FF;
    --border-color: #D9E5FA;
    --app-soft-bg: #EAF2FF;
    --app-soft-bg-alt: #F6FAFF;
    --app-soft-border: rgba(147, 197, 253, 0.34);
    --app-soft-shadow: 0 24px 48px -32px rgba(37, 99, 235, 0.22);
    --app-soft-shadow-sm: 0 16px 36px -28px rgba(37, 99, 235, 0.18);
    --app-soft-text: #182C55;
    --app-soft-muted: #65799F;
    --app-soft-accent: #2563EB;
    --app-soft-accent-hover: #1D4ED8;
    --app-soft-accent-bg: rgba(37, 99, 235, 0.12);
    --theme-page: #F5F9FF;
    --theme-page-alt: #EDF4FF;
    --theme-surface-soft: #F8FBFF;
    --theme-surface-muted: #EEF5FF;
    --theme-border-strong: #D9E5FA;
    --theme-accent: #2563EB;
    --theme-accent-strong: #1D4ED8;
    --theme-accent-soft: rgba(37, 99, 235, 0.12);
    --theme-accent-border: rgba(37, 99, 235, 0.24);
    --theme-accent-ring: rgba(37, 99, 235, 0.18);
    --theme-accent-shadow: rgba(37, 99, 235, 0.18);
}

body[data-app-theme="copper"] {
    --primary: #C2410C;
    --primary-light: #F97316;
    --primary-hover: #9A3412;
    --primary-rgb: 194, 65, 12;
    --primary-light-rgb: 249, 115, 22;
    --primary-soft: rgba(194, 65, 12, 0.12);
    --primary-border: rgba(194, 65, 12, 0.24);
    --focus-ring: rgba(194, 65, 12, 0.14);
    --shadow-tint: rgba(194, 65, 12, 0.2);
    --shadow-tint-strong: rgba(194, 65, 12, 0.28);
    --page-glow-start: rgba(194, 65, 12, 0.05);
    --page-glow-end: rgba(249, 115, 22, 0.05);
    --bg-color: #FFF9F6;
    --bg-color-alt: #FFF2EB;
    --surface-soft: #FFF9F5;
    --surface-muted: #FFF1E7;
    --border-color: #F1DACE;
    --app-soft-bg: #FFF0E5;
    --app-soft-bg-alt: #FFF8F2;
    --app-soft-border: rgba(253, 186, 116, 0.34);
    --app-soft-shadow: 0 24px 48px -32px rgba(154, 52, 18, 0.22);
    --app-soft-shadow-sm: 0 16px 36px -28px rgba(154, 52, 18, 0.18);
    --app-soft-text: #432414;
    --app-soft-muted: #8D6756;
    --app-soft-accent: #C2410C;
    --app-soft-accent-hover: #9A3412;
    --app-soft-accent-bg: rgba(194, 65, 12, 0.12);
    --theme-page: #FFF9F6;
    --theme-page-alt: #FFF2EB;
    --theme-surface-soft: #FFF9F5;
    --theme-surface-muted: #FFF1E7;
    --theme-border-strong: #F1DACE;
    --theme-accent: #C2410C;
    --theme-accent-strong: #9A3412;
    --theme-accent-soft: rgba(194, 65, 12, 0.12);
    --theme-accent-border: rgba(194, 65, 12, 0.24);
    --theme-accent-ring: rgba(194, 65, 12, 0.18);
    --theme-accent-shadow: rgba(194, 65, 12, 0.18);
}

body[data-app-theme="black-white"] {
    --primary: #111111;
    --primary-light: #9CA3AF;
    --primary-hover: #000000;
    --primary-rgb: 17, 17, 17;
    --primary-light-rgb: 156, 163, 175;
    --primary-soft: rgba(17, 17, 17, 0.08);
    --primary-border: rgba(17, 17, 17, 0.2);
    --focus-ring: rgba(17, 17, 17, 0.12);
    --shadow-tint: rgba(17, 17, 17, 0.16);
    --shadow-tint-strong: rgba(17, 17, 17, 0.22);
    --page-glow-start: rgba(17, 17, 17, 0.035);
    --page-glow-end: rgba(156, 163, 175, 0.05);
    --bg-color: #F7F7F7;
    --bg-color-alt: #EFEFEF;
    --surface-soft: #FAFAFA;
    --surface-muted: #F1F1F1;
    --border-color: #DEDEDE;
    --text-main: #111111;
    --text-muted: #5F6368;
    --app-soft-bg: #ECECEC;
    --app-soft-bg-alt: #F8F8F8;
    --app-soft-border: rgba(17, 17, 17, 0.12);
    --app-soft-shadow: 0 24px 48px -32px rgba(17, 17, 17, 0.18);
    --app-soft-shadow-sm: 0 16px 36px -28px rgba(17, 17, 17, 0.14);
    --app-soft-text: #171717;
    --app-soft-muted: #686868;
    --app-soft-accent: #111111;
    --app-soft-accent-hover: #000000;
    --app-soft-accent-bg: rgba(17, 17, 17, 0.08);
    --theme-page: #F7F7F7;
    --theme-page-alt: #EFEFEF;
    --theme-surface: #FFFFFF;
    --theme-surface-soft: #FAFAFA;
    --theme-surface-muted: #F1F1F1;
    --theme-border-strong: #DEDEDE;
    --theme-accent: #111111;
    --theme-accent-strong: #000000;
    --theme-accent-soft: rgba(17, 17, 17, 0.08);
    --theme-accent-border: rgba(17, 17, 17, 0.18);
    --theme-accent-ring: rgba(17, 17, 17, 0.14);
    --theme-accent-shadow: rgba(17, 17, 17, 0.16);
}

html,
body {
    overflow-x: hidden !important;
    width: 100% !important;
    position: relative;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-color);
    background-image:
        radial-gradient(at 0% 0%, var(--page-glow-start) 0px, transparent 50%),
        radial-gradient(at 100% 100%, var(--page-glow-end) 0px, transparent 50%);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

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

/* Page Header Alignment */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.page-header h1 {
    margin-bottom: 0 !important;
}

.login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 1.5rem;
    background: radial-gradient(circle at top left, rgba(var(--primary-rgb), 0.08), transparent),
        radial-gradient(circle at bottom right, rgba(var(--primary-light-rgb), 0.08), transparent),
        #F9FAFB;
    position: relative;
    overflow: hidden;
}

.login-container::before {
    content: '';
    position: absolute;
    width: 1000px;
    height: 1000px;
    border-top-right-radius: 40%;
    border-bottom-left-radius: 35%;
    background: linear-gradient(135deg, rgba(var(--primary-rgb), 0.03) 0%, rgba(var(--primary-light-rgb), 0.03) 100%);
    top: -500px;
    right: -200px;
    z-index: 0;
    animation: rotate 60s linear infinite;
}

@keyframes rotate {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

.login-card {
    width: 100%;
    max-width: 440px;
    padding: 3rem 2.5rem;
    border-radius: 1.25rem;
    z-index: 1;
    animation: slideUp 0.6s cubic-bezier(0.165, 0.84, 0.44, 1);
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

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

.login-card.glass {
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.5);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.08);
}

.login-header {
    text-align: center;
    margin-bottom: 2.5rem;
}

.login-header h1,
.login-header h4,
.login-header h2 {
    color: var(--text-main);
}

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

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: var(--text-main);
}

.form-group input {
    width: 100%;
    padding: 0.875rem 1.25rem;
    border: 1.5px solid #E5E7EB;
    border-radius: 12px;
    font-size: 1rem;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    background: #F9FAFB;
    color: var(--text-main);
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--focus-ring);
    background: white;
}

.password-toggle {
    border: none;
    background: transparent;
    padding: 0.5rem;
    color: #9CA3AF;
    transition: color 0.2s;
}

.password-toggle:hover {
    color: var(--primary);
}

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

/* Login Specific Refinements */
.logo-icon-bg {
    width: 64px;
    height: 64px;
    background: var(--primary);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
    box-shadow: 0 10px 20px -5px rgba(var(--primary-rgb), 0.3);
}

.form-label-custom {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.025em;
    margin-bottom: 0.625rem;
}

.form-label-custom i {
    width: 14px;
    height: 14px;
    color: var(--primary);
}

.form-control-custom {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1.5px solid #F3F4F6;
    border-radius: 12px;
    font-size: 0.9375rem;
    color: var(--text-main);
    background: #F9FAFB;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.form-control-custom:focus {
    outline: none;
    border-color: var(--primary);
    background: white;
    box-shadow: 0 0 0 4px var(--focus-ring);
}

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

.password-toggle {
    position: absolute;
    right: 12px;
    background: #F3F4F6;
    border: none;
    padding: 6px;
    border-radius: 8px;
    color: #6B7280;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    cursor: pointer;
}

.password-toggle:hover {
    background: #E5E7EB;
    color: var(--primary);
}

.password-visibility-field {
    position: relative;
    width: 100%;
}

.password-visibility-field > input {
    padding-right: 3.2rem !important;
}

.password-visibility-toggle {
    border: 1px solid rgba(15, 23, 42, 0.12);
    background: rgba(248, 250, 252, 0.95);
    color: #64748B;
    min-width: 2.65rem;
    min-height: 2.65rem;
    border-radius: 0.85rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: border-color 0.2s ease, color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
    cursor: pointer;
    line-height: 1;
    z-index: 3;
}

.password-visibility-field .password-visibility-toggle {
    position: absolute;
    top: 50%;
    right: 0.35rem;
    transform: translateY(-50%);
}

.input-group > .password-visibility-toggle.input-group-text {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
    border-color: #E5E7EB;
}

.password-visibility-toggle:hover,
.password-visibility-toggle:focus {
    background: var(--primary-soft);
    border-color: var(--primary-border);
    color: var(--primary);
    box-shadow: 0 0 0 3px var(--focus-ring);
    outline: none;
}

.password-visibility-toggle i,
.password-visibility-toggle svg {
    width: 1.05rem;
    height: 1.05rem;
}

.forgot-password {
    font-size: 0.8125rem;
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}

.custom-checkbox {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}

.custom-checkbox input {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--primary);
}

.custom-checkbox label {
    font-size: 0.875rem;
    color: var(--text-muted);
    cursor: pointer;
}

.login-btn {
    width: 100%;
    padding: 0.875rem;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 12px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: all 0.2s;
    box-shadow: 0 4px 6px -1px rgba(var(--primary-rgb), 0.2);
}

.login-btn:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 10px 15px -3px rgba(var(--primary-rgb), 0.3);
}

.login-footer {
    margin-top: 3rem;
    padding-top: 1.5rem;
    border-top: 1px solid #F3F4F6;
    text-align: center;
}

.login-footer p {
    font-size: 0.75rem;
    color: #9CA3AF;
    margin-bottom: 0.5rem;
}

.footer-links {
    display: flex;
    justify-content: center;
    gap: 12px;
}

.footer-links a {
    font-size: 0.75rem;
    color: #6B7280;
    text-decoration: none;
}

.footer-links span {
    color: #D1D5DB;
}

/* Mobile Responsiveness Improvements */
@media (max-width: 992px) {
    .app-container {
        flex-direction: column;
    }

    .sidebar {
        position: fixed;
        left: -280px;
        top: 0;
        bottom: 0;
        z-index: 1050;
        transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        width: 280px !important;
    }

    .sidebar.active {
        left: 0;
    }

    .main-content {
        margin-left: 0 !important;
        padding-top: 70px !important;
        /* Space for mobile header */
    }

    .mobile-header {
        display: flex !important;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        height: 78px;
        background:
            linear-gradient(180deg, rgba(249, 251, 255, 0.94), rgba(241, 245, 255, 0.92)),
            radial-gradient(circle at top left, rgba(221, 229, 255, 0.4), transparent 36%);
        z-index: 1040;
        align-items: center;
        justify-content: space-between;
        padding: 0 1.15rem;
        border-bottom: 1px solid rgba(214, 221, 240, 0.82);
        box-shadow: 0 14px 28px rgba(203, 211, 234, 0.24);
    }

    .sidebar-backdrop {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(103, 120, 166, 0.18);
        backdrop-filter: blur(5px);
        -webkit-backdrop-filter: blur(5px);
        z-index: 1045;
    }

    .sidebar.active+.sidebar-backdrop {
        display: block !important;
    }

    .card {
        padding: 1rem !important;
    }

    .grid-4,
    .grid-3,
    .grid-2 {
        grid-template-columns: 1fr !important;
    }
}

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

.login-footer a:hover {
    color: var(--primary) !important;
}

.spinner-border-sm {
    width: 1rem;
    height: 1rem;
    border-width: 0.2em;
}

.btn-primary {
    padding: 0.75rem 1.5rem;
    background-color: var(--primary);
    color: white;
    border: none;
    border-radius: 0.5rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(var(--primary-rgb), 0.3);
}

.alert {
    padding: 1rem 1.25rem;
    border-radius: var(--radius-md);
    margin-bottom: 1.5rem;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    border: 1px solid transparent;
}

.alert.error {
    background-color: #FEF2F2;
    color: var(--error);
    border-color: #FEE2E2;
}

.login-footer {
    margin-top: 1.5rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.75rem;
}

/* Sidebar Layout */
.app-container {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-width);
    background: #ffffff;
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    left: 0;
    top: 0;
    z-index: 1000;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.06);
}

.app-container.sidebar-collapsed .sidebar {
    transform: translateX(-100%);
}

.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 2.5rem;
    width: calc(100% - var(--sidebar-width));
    background: #F8FAFC;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.app-container.sidebar-collapsed .main-content {
    margin-left: 0;
    width: 100%;
}

/* Full Screen Card */
body.card-maximized-open {
    overflow: hidden;
}

.card-maximized {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    z-index: 2000 !important;
    margin: 0 !important;
    max-width: none !important;
    height: 100vh !important;
    border-radius: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    animation: cardZoom 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.card-maximized .card-header {
    flex-shrink: 0;
}

.card-maximized .table-responsive {
    flex-grow: 1;
    max-height: none !important;
    height: auto !important;
    border-radius: 0;
}

@keyframes cardZoom {
    from {
        transform: scale(0.95);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

.maximize-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: all 0.2s;
}

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

.btn {
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-md);
    font-weight: 600;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: none;
    font-size: 0.875rem;
    cursor: pointer;
}

.btn-sm {
    padding: 0.4rem 0.75rem !important;
    font-size: 0.75rem !important;
    height: 32px;
    white-space: nowrap;
}

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

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

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

.btn-indigo:hover {
    background: var(--indigo-hover);
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

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

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

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

.btn-outline-indigo:hover {
    background: var(--indigo);
    color: white;
}

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

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

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

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

.btn-indigo-soft {
    background: var(--indigo-soft);
    color: var(--indigo);
}

.btn-indigo-soft:hover {
    background: var(--indigo);
    color: white;
}

.sidebar-toggle {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    padding: 0.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 2rem;
    transition: all 0.2s;
}

.sidebar-toggle:hover {
    background: white;
    box-shadow: var(--shadow-sm);
}

.sidebar-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-brand {
    font-size: calc(1.5rem * var(--brand-scale, 1));
    font-weight: 700;
    color: var(--primary);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
    line-height: 1.2;
}

.sidebar-brand i {
    width: 20px;
    height: 20px;
    color: var(--primary);
}

.sidebar-brand-text {
    min-width: 0;
    white-space: nowrap;
}

.sidebar-nav {
    flex: 1;
    padding: 1.5rem 1rem;
    overflow-y: auto;
    background: #ffffff;
    scrollbar-width: thin;
    scrollbar-color: rgba(158, 171, 207, 0.55) transparent;
}

.sidebar-nav::-webkit-scrollbar {
    width: 4px;
}

.sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(158, 171, 207, 0.55);
    border-radius: 10px;
}

.nav-section-title {
    margin-top: 1rem;
    margin-bottom: 0.5rem;
    padding-left: 1rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
}

.nav-item {
    list-style: none;
    margin-bottom: 0.5rem;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: auto;
    padding: 0.875rem 1rem;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: var(--radius-md);
    border: none;
    font-weight: 500;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    background: transparent;
}

.nav-icon {
    width: 20px;
    height: 20px;
    stroke-width: 2;
    transition: transform 0.2s ease, color 0.2s ease;
}

.nav-link:hover {
    background: rgba(99, 102, 241, 0.05);
    color: var(--primary);
    transform: translateX(4px);
}

.nav-link:hover .nav-icon {
    color: var(--primary);
}

.nav-link.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.25);
    font-weight: 600;
}

.nav-link.active .nav-icon {
    color: white;
}

.nav-link.active:hover {
    transform: none;
}

.sidebar-footer {
    padding: 1.5rem;
    border-top: 1px solid var(--border-color);
    background: #ffffff;
    margin-top: auto;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.user-avatar {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, rgba(var(--primary-rgb), 0.14), rgba(var(--primary-rgb), 0.06));
    color: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    border: 1px solid rgba(var(--primary-rgb), 0.16);
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
    overflow: hidden;
    flex-shrink: 0;
}

.user-avatar img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
}

.user-avatar.has-image {
    background: #ffffff;
    color: transparent;
}

.user-avatar.is-fallback {
    letter-spacing: 0.01em;
}

.user-details {
    overflow: hidden;
}

.user-name {
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-role {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: capitalize;
    font-weight: 500;
    letter-spacing: 0;
}

.btn-logout {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 0.75rem;
    background: #ffffff;
    color: var(--text-muted);
    border-radius: 0.5rem;
    text-decoration: none;
    font-size: 0.875rem;
    transition: all 0.2s;
    box-shadow: none;
    border: 1px solid var(--border-color) !important;
}

.btn-logout:hover {
    background-color: #FEF2F2;
    color: var(--error);
    border-color: #FECACA !important;
    transform: none;
    box-shadow: none;
}

.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 2.5rem;
    width: calc(100% - var(--sidebar-width));
    background: #F8FAFC;
}

.mobile-header {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 64px;
    background: #ffffff;
    border-bottom: 1px solid var(--border-color);
    z-index: 1000;
    padding: 0 1rem;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
}

.mobile-header .sidebar-brand {
    max-width: calc(100% - 56px);
    font-size: calc(1.2rem * var(--brand-scale, 1));
}

@media (max-width: 320px) {
    .mobile-header .sidebar-brand {
        font-size: 0.9rem !important;
    }

    .mobile-header {
        padding: 0 0.5rem;
    }
}

.mobile-toggle {
    width: auto;
    height: auto;
    min-width: 0;
    min-height: 0;
    flex: 0 0 auto;
    background: transparent;
    border: none;
    border-radius: 0.5rem;
    padding: 0.5rem;
    cursor: pointer;
    color: var(--text-main);
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    position: relative;
    box-shadow: none;
}

.mobile-toggle i,
.mobile-toggle svg {
    width: 1.4rem;
    height: 1.4rem;
    stroke-width: 2.1;
    pointer-events: none;
}

.mobile-toggle:hover,
.mobile-toggle:focus-visible {
    color: var(--primary);
    background: rgba(99, 102, 241, 0.05);
}

@media (max-width: 992px) {
    :root {
        --sidebar-width: 0px;
    }

    .sidebar {
        width: 280px !important;
        /* Force width for correct translateX calculation */
        transform: translateX(-100%);
        box-shadow: 22px 0 44px rgba(194, 203, 231, 0.52);
        z-index: 2001;
        /* Above mobile header */
    }

    .sidebar.active {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
        width: 100%;
        padding: 6.9rem 1rem 2rem 1rem;
        /* Increased top padding for mobile header */
    }

    .mobile-header {
        display: flex;
    }

    .desktop-only-toggle {
        display: none !important;
    }

    .mobile-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .profile-header-card .d-flex {
        flex-direction: column;
        text-align: center;
    }

    .user-avatar-large {
        margin: 0 auto;
    }

    .profile-header-card .ms-auto {
        margin-left: 0 !important;
        margin-top: 1rem;
        text-align: center !important;
    }

    .detail-nav {
        flex-direction: column;
    }
}

@media (max-width: 768px) {
    .mobile-header {
        height: 68px;
        padding: 0 0.9rem 0 1rem;
    }

    .mobile-header .sidebar-brand {
        max-width: calc(100% - 68px);
    }

    .mobile-toggle {
        width: 2.65rem;
        height: 2.65rem;
        min-width: 2.65rem;
        min-height: 2.65rem;
        flex-basis: 2.65rem;
        border-radius: 0.9rem;
    }

    .mobile-toggle i,
    .mobile-toggle svg {
        width: 1.28rem;
        height: 1.28rem;
    }

    .header-info-grid {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }

    .profile-stats-grid {
        grid-template-columns: 1fr 1fr;
    }

    .detail-nav {
        display: flex;
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        gap: 0.5rem;
        padding-bottom: 0.5rem;
        margin-bottom: 1rem;
        border-bottom: 1px solid var(--border-color);
    }

    .detail-nav-item {
        white-space: nowrap;
        padding: 0.5rem 1rem;
        font-size: 0.875rem;
    }

    .info-grid,
    .profile-field-group {
        grid-template-columns: 1fr;
    }

    .status-value {
        font-size: 2rem;
    }

    .btn-clock {
        width: 100%;
        padding: 1rem;
    }
}

@media (max-width: 480px) {
    .profile-stats-grid {
        grid-template-columns: 1fr;
    }

    .card {
        padding: 1.25rem;
    }

    .profile-header-card {
        padding: 1.5rem !important;
    }

    .user-avatar-large {
        width: 80px;
        height: 80px;
        font-size: 2rem;
    }

    .profile-header-card h2 {
        font-size: 1.5rem;
    }
}

/* btn-logout removed from here since it's redesigned in sidebar-footer */

/* Card Styles */
.card {
    background: var(--card-bg);
    padding: 2rem;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-md);
}

/* Table Styles */
.table-container,
.table-responsive {
    display: block;
    width: 100%;
    overflow-x: auto;
    overflow-y: auto;
    /* Enable vertical scroll */
    max-height: 500px;
    /* Default max height for scrollable tables */
    -ms-overflow-style: -ms-autohiding-scrollbar;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 1rem;
    border-radius: 0.5rem;
    position: relative;
}

.table-responsive table {
    min-width: 900px;
    width: 100%;
    margin-bottom: 0;
    border-collapse: separate;
    /* Required for sticky header border */
    border-spacing: 0;
}

table {
    width: 100%;
    border-collapse: collapse;
}

table thead th {
    position: sticky;
    top: 0;
    z-index: 10;
    background: #F8FAFC;
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

td {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.875rem;
    color: var(--text-main);
    white-space: nowrap;
    vertical-align: middle;
}

table tbody tr {
    transition: background-color 0.2s ease;
}

table tbody tr:hover {
    background-color: rgba(99, 102, 241, 0.02);
}

/* Clock Page Styles */
.status-display {
    text-align: center;
    padding: 3rem 0;
}

.status-label {
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.status-value {
    font-size: 3rem;
    font-weight: 800;
    color: var(--text-main);
}

.status-value.in {
    color: var(--success);
}

.status-value.out {
    color: var(--text-muted);
}

.clock-actions {
    display: flex;
    justify-content: center;
    margin-top: 2rem;
}

.btn-clock {
    padding: 1rem 3rem;
    font-size: 1.25rem;
    font-weight: 600;
    border-radius: 9999px;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    color: white;
}

.btn-in {
    background-color: var(--success);
    box-shadow: 0 4px 14px 0 rgba(16, 185, 129, 0.39);
}

.btn-in:hover {
    background-color: #059669;
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.23);
}

.btn-out {
    background-color: var(--error);
    box-shadow: 0 4px 14px 0 rgba(239, 68, 68, 0.39);
}

.btn-out:hover {
    background-color: #DC2626;
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(239, 68, 68, 0.23);
}

.btn-clock:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

/* ==========================================
   UI/UX POLISH - Phase 4
   ========================================== */

/* Smooth Transitions */
.card {
    transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

.btn-primary {
    transition: all 0.2s ease;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(79, 70, 229, 0.3);
}

.btn-primary:active {
    transform: translateY(0) scale(0.98);
}

/* Table Row Hover */
table tbody tr {
    transition: background-color 0.15s ease;
}

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

/* Status Badges */
.badge {
    padding: 0.35rem 0.875rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: all 0.2s ease;
}

.badge:hover {
    transform: translateY(-1px);
    filter: brightness(0.95);
}

/* Pulse Animation */
@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.7;
    }
}

.pulse {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* Loading Spinner */
.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 0.8s linear infinite;
}

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

/* Focus Visible */
*:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
    color: var(--text-muted);
}

.empty-state-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

/* Form Input Polish */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="date"],
input[type="number"],
textarea,
select {
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.compact-select-menu,
.compact-select-menu.form-select {
    font-size: 0.95rem !important;
    line-height: 1.35;
}

.compact-select-menu option,
.compact-select-menu optgroup {
    font-size: 0.95rem;
    line-height: 1.35;
}

input:focus,
textarea:focus,
select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

/* Nav Link Hover */
.nav-link:hover:not(.active) {
    background-color: rgba(99, 102, 241, 0.05);
    color: var(--primary);
}

/* Sidebar Backdrop */
.sidebar-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(103, 120, 166, 0.18);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    z-index: 999;
}

.sidebar.active+.sidebar-backdrop {
    display: block;
}

.sidebar.active ~ .sidebar-backdrop {
    display: block;
}

/* Profile Specific */
.user-avatar-large {
    width: 100px;
    height: 100px;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    font-weight: 700;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
}

.info-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 1.25rem;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    transition: transform 0.2s, box-shadow 0.2s;
}

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

.info-icon {
    width: 40px;
    height: 40px;
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.info-icon i {
    width: 20px;
    height: 20px;
}

.info-content {
    display: flex;
    flex-direction: column;
}

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

.info-value {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-main);
}

/* Profile Header Expansion */
/* Profile Header Expansion */
.profile-header-card {
    background: linear-gradient(135deg, #4338CA 0%, #6366F1 50%, #818CF8 100%) !important;
    color: white;
    border: none;
    overflow: hidden;
    position: relative;
    border-radius: 2.5rem;
    padding: 3rem !important;
    box-shadow: 0 25px 50px -12px rgba(67, 56, 202, 0.4) !important;
}

.user-avatar-large {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    font-weight: 800;
    box-shadow: 0 0 0 8px rgba(255, 255, 255, 0.1), 0 0 0 16px rgba(255, 255, 255, 0.05);
    transition: all 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
    z-index: 2;
    text-transform: uppercase;
}

.user-avatar-large:hover {
    transform: scale(1.05) rotate(5deg);
    box-shadow: 0 0 0 12px rgba(255, 255, 255, 0.15), 0 0 0 24px rgba(255, 255, 255, 0.08);
}

.profile-header-card .btn-primary {
    background: white !important;
    color: #4338CA !important;
    border: none !important;
    font-weight: 700 !important;
    padding: 0.875rem 1.75rem !important;
    border-radius: 9999px !important;
    transition: all 0.3s ease !important;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1) !important;
    white-space: nowrap;
}

.profile-header-card .btn-primary:hover {
    background: #F8FAFC !important;
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1) !important;
}

.profile-header-card h2 {
    font-size: 2.25rem;
    font-weight: 800;
    letter-spacing: -0.025em;
    text-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    margin-bottom: 0.5rem;
}

.header-info-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.75rem;
    margin-top: 1.5rem;
}

@media (min-width: 992px) {
    .header-info-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.25rem 2.5rem;
    }
}

.header-info-item {
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 1.05rem;
    color: rgba(255, 255, 255, 0.95);
    background: rgba(255, 255, 255, 0.05);
    padding: 0.6rem 1rem;
    border-radius: 0.85rem;
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.header-info-item:hover {
    background: rgba(255, 255, 255, 0.12);
    transform: translateY(-2px);
    border-color: rgba(255, 255, 255, 0.2);
}

.header-info-item i {
    width: 18px;
    height: 18px;
    color: #A5B4FC;
}

.profile-header-card .text-muted {
    color: rgba(255, 255, 255, 0.7) !important;
}

/* Premium Soft Button System */
.btn-soft-premium {
    background: white !important;
    color: var(--primary) !important;
    border: none !important;
    font-weight: 700 !important;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.2), 0 1px 3px rgba(0, 0, 0, 0.05) !important;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) !important;
    letter-spacing: -0.01em;
}

.btn-soft-premium:hover {
    background: white !important;
    transform: translateY(-3px);
    box-shadow: 0 15px 30px rgba(99, 102, 241, 0.15) !important;
}

.btn-header-soft {
    background: white !important;
    border: none !important;
    color: var(--text-muted) !important;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.04) !important;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) !important;
}

.btn-header-soft:hover {
    background: white !important;
    color: var(--primary) !important;
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1) !important;
}

.btn-circular {
    width: 44px;
    height: 44px;
    padding: 0 !important;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    border-radius: 50% !important;
}

.btn-header-soft i {
    color: #64748B;
    transition: all 0.2s ease;
}

.btn-header-soft:hover i {
    color: var(--primary);
}

.btn-soft-link {
    background: rgba(255, 255, 255, 0.08) !important;
    color: rgba(255, 255, 255, 0.95) !important;
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) !important;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.btn-soft-link:hover {
    background: rgba(255, 255, 255, 0.15) !important;
    border-color: rgba(255, 255, 255, 0.4) !important;
    color: white !important;
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12) !important;
}

#employeeCodeBadge {
    background: rgba(0, 0, 0, 0.3) !important;
    color: white !important;
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
    backdrop-filter: blur(4px);
}

.profile-header-card::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.05) 0%, transparent 70%);
    pointer-events: none;
}

/* Profile Stats Row */
.profile-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: white;
    padding: 1.25rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 16px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

.stat-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.stat-content {
    display: flex;
    flex-direction: column;
}

.stat-label {
    font-size: 0.65rem;
    color: var(--text-muted);
    font-weight: 600;
}

.stat-value {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-main);
}

/* Collapsible Sections */
.profile-section-item {
    background: white;
    padding: 1.25rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    margin-bottom: 1rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.profile-section-item:hover {
    background: #f1f5f9;
    border-color: var(--primary);
    transform: translateX(4px);
}

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

.profile-section-item.active .profile-section-title,
.profile-section-item.active .text-muted {
    color: white !important;
}

.profile-section-item.active .profile-section-icon {
    background: rgba(255, 255, 255, 0.2) !important;
    color: white !important;
}

.profile-section-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.profile-section-title {
    font-weight: 600;
    font-size: 1.1rem;
    color: var(--text-main);
    flex-grow: 1;
    margin-left: 1rem;
}

/* Sub-nav for Details */
.detail-nav {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.detail-nav-item {
    flex: 1;
    padding: 0.75rem;
    text-align: center;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.detail-nav-item.active {
    background: white;
    border-color: var(--primary);
    color: var(--primary);
    box-shadow: var(--shadow-sm);
}

/* Field Display Styles */
.profile-field-group {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.profile-field {
    display: flex;
    flex-direction: column;
    padding: 0.5rem 0;
}

.profile-field-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 600;
}

.profile-field-value {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-main);
}

.timeline-dot {
    position: absolute;
    top: 5px;
    left: -5px;
    width: 10px;
    height: 10px;
    background: var(--primary);
    border-radius: 50%;
    border: 2px solid white;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.btn-icon-sm {
    padding: 4px;
    border-radius: 6px;
    color: var(--text-muted);
    transition: all 0.2s;
}

.btn-icon-sm:hover {
    background: #FEE2E2;
    color: var(--error);
}

/* Document Cards */
.document-card {
    background: white;
    padding: 1rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: all 0.2s ease;
}

.document-card:hover {
    box-shadow: var(--shadow-sm);
    border-color: var(--primary-light);
    transform: translateY(-2px);
}

.document-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.document-type-icon {
    width: 40px;
    height: 40px;
    background: var(--indigo-soft);
    color: var(--primary);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Address Cards */
.address-card {
    background: white;
    padding: 1.25rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 12px;
    height: 100%;
}

.address-header {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-muted);
    font-size: 0.875rem;
    font-weight: 600;
}

.address-body {
    font-size: 0.95rem;
    color: var(--text-main);
    line-height: 1.5;
}

/* Empty State Re-styling */
.empty-state-card {
    background: white;
    padding: 2.5rem 1.5rem;
    border-radius: var(--radius-md);
    border: 1px dashed var(--border-color);
    text-align: center;
}

.empty-state-icon-large {
    width: 48px;
    height: 48px;
    color: var(--text-muted);
    opacity: 0.3;
    margin-bottom: 1rem;
}

.shadow-primary {
    box-shadow: 0 10px 15px -3px rgba(99, 102, 241, 0.3);
}

.edit-mode-container {
    animation: slideIn 0.4s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

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

/* Mobile Overrides for Premium Components */
@media (max-width: 991px) {
    .profile-header-card {
        padding: 2.5rem 1.25rem !important;
        border-radius: 2rem;
        text-align: center;
    }

    .profile-header-card .d-flex {
        flex-direction: column !important;
    }

    .user-avatar-large {
        width: 110px;
        height: 110px;
        font-size: 2.75rem;
        margin: 0 auto 1.5rem !important;
    }

    .profile-header-card h2 {
        font-size: 1.85rem;
        margin-bottom: 0.5rem !important;
    }

    .header-info-grid {
        width: 100%;
        max-width: 400px;
        margin: 1.5rem auto 0 !important;
        grid-template-columns: 1fr !important;
    }

    .header-info-item {
        justify-content: flex-start !important;
        text-align: left !important;
        padding: 0.75rem 1.25rem;
    }

    .profile-header-card .ms-auto.profile-header-actions {
        margin-left: 0 !important;
        margin-top: 2.5rem;
        width: 100%;
        display: flex;
        flex-direction: column;
        align-items: center !important;
        gap: 1.25rem;
    }

    .edit-profile-pill {
        width: 100% !important;
        max-width: 280px !important;
        height: 64px !important;
        border-radius: 999px !important;
        background: white !important;
        color: var(--primary) !important;
        border: none !important;
        padding: 0 !important;
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        justify-content: center !important;
        box-shadow: 0 15px 30px rgba(0, 0, 0, 0.15) !important;
    }

    .edit-profile-pill .edit-icon-main {
        width: 28px !important;
        height: 28px !important;
        margin-bottom: 4px;
    }

    .edit-profile-pill span {
        font-size: 1.1rem !important;
        letter-spacing: -0.01em;
    }

    .download-summary-btn {
        margin-top: -0.5rem;
        font-size: 0.95rem !important;
        opacity: 0.8 !important;
    }
}

/* Premium Directory Card Grid */
.directory-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
    align-items: start;
}

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

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

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

/* Directory Header */
.directory-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1.5rem;
}

@media (max-width: 575px) {
    .directory-header-row {
        flex-direction: column;
        align-items: center !important;
        text-align: center;
        gap: 1.25rem;
    }

    .add-user-btn {
        width: 100% !important;
        max-width: 300px;
    }
}

.add-user-btn {
    width: auto !important;
    min-width: 180px;
    max-width: fit-content;
    height: 48px;
    padding: 0 2rem !important;
    white-space: nowrap !important;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.add-user-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(79, 70, 229, 0.3) !important;
}

/* Directory Toolbar & Filters */
.directory-toolbar {
    background: white;
    padding: 1rem 1.5rem;
    border-radius: 1.25rem;
    border: 1px solid var(--border-color);
    margin-bottom: 2rem;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: end;
    gap: 1rem;
}

.directory-filter-form {
    display: grid;
    grid-template-columns: minmax(220px, 0.95fr) minmax(360px, 1.35fr) auto auto;
    gap: 0.75rem;
    align-items: center;
    min-width: 0;
}

.directory-filter-form > * {
    min-width: 0;
}

.directory-filter-pair {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
    min-width: 0;
}

.search-input-group {
    flex: 1;
    min-width: 0;
    position: relative;
    display: flex;
    align-items: center;
}

.search-input-group i,
.search-input-group svg {
    position: absolute;
    left: 1.25rem;
    top: 50% !important;
    transform: translateY(-50%) !important;
    color: var(--text-muted);
    pointer-events: none;
    z-index: 10;
    margin: 0 !important;
}

.search-input-group .form-control {
    padding-left: 3rem;
    height: 48px;
    border-radius: 0.75rem;
    border-color: var(--border-color);
    box-shadow: none;
    transition: all 0.2s;
}

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

.directory-search-submit,
.directory-clear-btn {
    height: 48px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
}

.view-toggle-group {
    display: flex;
    background: var(--indigo-soft);
    padding: 0.25rem;
    border-radius: 0.75rem;
    gap: 0.25rem;
    justify-self: end;
    align-self: center;
    flex-shrink: 0;
}

.view-btn {
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    transition: all 0.2s ease;
}

.view-btn i,
.view-btn svg {
    pointer-events: none;
}

.view-btn.active {
    background: white;
    color: var(--primary);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

@media (max-width: 1499px) {
    .directory-toolbar {
        grid-template-columns: 1fr;
        align-items: stretch;
    }

    .view-toggle-group {
        justify-self: start;
    }
}

@media (max-width: 1199px) {
    .directory-filter-form {
        grid-template-columns: minmax(0, 1fr);
    }

    .directory-filter-pair {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .directory-search-submit,
    .directory-clear-btn {
        width: 100%;
    }
}

@media (max-width: 767px) {
    .directory-toolbar {
        padding: 1.25rem;
        gap: 0.75rem;
    }

    .directory-filter-pair {
        grid-template-columns: 1fr;
    }

    .directory-toolbar div[style*="min-width"] {
        width: 100% !important;
        min-width: 0 !important;
    }

    .view-toggle-group {
        justify-self: center;
        margin-top: 0.5rem;
    }
}

/* Directory List View */
.directory-grid.list-view {
    grid-template-columns: 1fr;
}

.list-view .user-directory-card {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(0, 1.35fr) auto;
    align-items: center;
    padding: 1rem 1.5rem;
    gap: 1.5rem;
}

.list-view .user-card-identity {
    min-width: 0;
}

.list-view .user-card-meta-grid {
    grid-template-columns: minmax(0, 0.68fr) minmax(0, 1.35fr) minmax(0, 1.2fr) minmax(0, 0.72fr);
    margin: 0;
    padding: 0;
    border: none;
    min-width: 0;
    width: 100%;
    align-items: start;
}

.list-view .user-card-meta-item-role {
    display: flex;
}

.list-view .user-card-meta-item-job .user-card-value {
    display: block;
    max-width: 100%;
    white-space: nowrap !important;
    overflow: hidden;
    text-overflow: ellipsis;
    word-break: normal;
    overflow-wrap: normal;
    hyphens: none;
}

.list-view .user-card-meta-item {
    min-width: 0;
}

.list-view .user-card-actions {
    margin-top: 0;
    padding: 0;
    border: none;
    min-width: 230px;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.list-view .user-card-actions .d-flex {
    flex-wrap: nowrap;
}

.list-view .user-card-action-row .user-card-action-btn {
    flex: 0 0 auto !important;
    min-width: 140px;
}

.list-view .user-card-action-form {
    margin-top: 0 !important;
    min-width: 180px;
    flex: 0 0 auto;
}

.list-view .user-card-action-form .user-card-action-btn {
    width: 100%;
    min-width: 180px;
}

@media (max-width: 1499px) {
    .list-view .user-directory-card {
        grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
    }

    .list-view .user-card-meta-grid {
        grid-template-columns: minmax(0, 0.68fr) minmax(0, 1.35fr) minmax(0, 1.2fr);
        gap: 0.9rem;
    }

    .list-view .user-card-meta-item-joined {
        display: none;
    }

    .list-view .user-card-actions {
        grid-column: 1 / -1;
        justify-content: flex-start;
        min-width: 0;
    }
}

@media (max-width: 1199px) {
    .list-view .user-card-meta-grid {
        grid-template-columns: 1fr 1fr;
        margin-top: 1rem;
    }

    .list-view .user-card-meta-item-joined {
        display: flex;
    }

    .list-view .user-card-meta-item-department {
        grid-column: 1 / -1;
    }

    .list-view .user-card-meta-item-job {
        grid-column: 1 / -1;
    }
}

@media (max-width: 767px) {
    .list-view .user-directory-card {
        grid-template-columns: 1fr;
        align-items: flex-start;
    }

    .list-view .user-card-meta-grid {
        width: 100%;
    }

    .list-view .user-card-actions .d-flex {
        flex-wrap: wrap;
    }
}

.user-directory-card {
    background: white;
    border-radius: 1.5rem;
    border: 1px solid var(--border-color);
    padding: 1.75rem;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    height: auto;
    min-width: 0;
    max-width: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
}

.user-directory-card > * {
    min-width: 0;
}

.user-card-identity {
    display: flex;
    align-items: center;
    gap: 1rem;
    min-width: 0;
}

.user-card-copy {
    min-width: 0;
}

@media (max-width: 575px) {
    .user-directory-card {
        padding: 1.25rem;
        border-radius: 1.25rem;
    }

    .user-card-avatar {
        width: 50px;
        height: 50px;
        border-radius: 12px;
        font-size: 1.25rem;
    }

    .user-card-name {
        font-size: 1rem;
    }

    .user-card-email {
        font-size: 0.75rem;
    }

    .user-card-meta-grid {
        margin: 1.25rem 0;
        padding: 1rem 0;
        gap: 1rem 0.5rem;
    }

    .user-card-value {
        font-size: 0.8rem;
    }
}

.user-directory-card:hover {
    transform: none;
    box-shadow: 0 20px 40px -12px rgba(79, 70, 229, 0.12) !important;
    border-color: rgba(79, 70, 229, 0.3);
    background: linear-gradient(to bottom, #ffffff, #fcfcff);
}

/* Remove focus outline on click but keep for keyboard navigation */
.user-directory-card:focus {
    outline: none;
}

.user-directory-card:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* Prevent stuck active state */
.user-directory-card:active {
    transform: translateY(-6px);
}

.user-card-avatar {
    width: 64px;
    height: 64px;
    min-width: 64px;
    min-height: 64px;
    flex-shrink: 0;
    border-radius: 16px;
    background: var(--indigo-soft);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: 700;
    position: relative;
    transition: all 0.3s ease;
}

.user-directory-card:hover .user-card-avatar {
    background: var(--primary);
    color: white;
    transform: scale(1.05) rotate(2deg);
}

.user-card-status-indicator {
    position: absolute;
    bottom: -3px;
    right: -3px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 3px solid white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.user-card-status-indicator.active {
    background-color: #10B981;
}

.user-card-status-indicator.inactive {
    background-color: #EF4444;
}

.user-card-name {
    font-size: 1.15rem;
    font-weight: 750;
    color: var(--text-dark);
    margin-bottom: 2px;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.user-card-email {
    font-size: 0.875rem;
    color: var(--text-muted);
    font-weight: 500;
    word-break: break-all;
    overflow-wrap: break-word;
    max-width: 100%;
    line-height: 1.4;
}

.user-card-meta-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem 1rem;
    margin: 1.75rem 0;
    padding: 1.25rem 0;
    border-top: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
}

.user-card-meta-item {
    display: flex;
    flex-direction: column;
}

.user-card-label {
    font-size: 0.65rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin-bottom: 6px;
    opacity: 0.8;
}

.user-card-value {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-main);
    line-height: 1.35;
}

.user-department-stack {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    align-items: center;
    justify-content: flex-start;
}

.user-department-chip {
    display: inline-flex;
    align-items: center;
    max-width: 100%;
    padding: 0.24rem 0.62rem;
    border-radius: 999px;
    background: rgba(99, 102, 241, 0.1);
    color: #4338ca;
    border: 1px solid rgba(99, 102, 241, 0.22);
    font-size: 0.72rem;
    font-weight: 700;
    line-height: 1.25;
    white-space: normal;
    word-break: break-word;
    text-align: left;
}

.user-department-chip-muted {
    background: rgba(148, 163, 184, 0.14);
    color: #475569;
    border-color: rgba(148, 163, 184, 0.28);
}

.user-card-actions {
    margin-top: auto;
    padding-top: 0.5rem;
}

.user-card-actions .d-flex {
    flex-wrap: wrap;
}

.user-card-actions .btn {
    flex: 1;
    min-width: 0;
}

.user-card-action-btn {
    min-height: 46px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    line-height: 1;
}

.user-card-action-btn i,
.user-card-action-btn svg {
    width: 15px !important;
    height: 15px !important;
    flex-shrink: 0;
}


/* Permissions Page */
.permission-picker-panel {
    position: relative;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 1.25rem;
    padding: 1.125rem;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.05);
}

.permission-picker-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.875rem;
    margin-bottom: 0.9rem;
}

.permission-picker-kicker {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-main);
    margin-bottom: 0.35rem;
}

.permission-picker-kicker svg,
.permission-picker-kicker i {
    color: var(--primary);
}

.permission-picker-caption {
    color: var(--text-muted);
    font-size: 0.9rem;
    line-height: 1.45;
    max-width: 28rem;
}

.permission-picker-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.45rem 0.8rem;
    border-radius: 999px;
    background: var(--theme-accent-soft);
    color: var(--theme-accent-strong);
    font-size: 0.74rem;
    font-weight: 700;
    white-space: nowrap;
    border: 1px solid var(--theme-accent-border);
}

.permission-picker-field {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.permission-picker-field .search-input-group {
    min-width: 0;
    flex: 1 1 auto;
}

.permission-picker-field .form-control {
    padding-right: 1.25rem;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(var(--primary-rgb), 0.03));
    border-color: rgba(var(--primary-rgb), 0.14);
}

.permission-picker-clear {
    height: 48px;
    display: inline-flex;
    align-items: center;
    white-space: nowrap;
}

.permission-picker-hint {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    margin-top: 0.85rem;
    font-size: 0.84rem;
    line-height: 1.5;
    color: var(--text-muted);
}

.permission-picker-hint svg,
.permission-picker-hint i {
    color: var(--primary);
    margin-top: 0.15rem;
    flex-shrink: 0;
}

.permission-user-results {
    position: absolute;
    top: calc(100% - 0.25rem);
    left: 1rem;
    right: 1rem;
    z-index: 40;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 1rem;
    box-shadow: 0 18px 40px rgba(15, 23, 42, 0.12);
    padding: 0.5rem;
    max-height: 320px;
    overflow-y: auto;
}

.permission-user-result {
    width: 100%;
    border: 0;
    background: transparent;
    border-radius: 0.875rem;
    padding: 0.75rem 0.875rem;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    text-align: left;
    transition: background 0.2s ease, transform 0.2s ease;
}

.permission-user-result:hover,
.permission-user-result:focus-visible {
    background: var(--indigo-soft);
    outline: none;
}

.permission-user-copy {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.permission-user-name {
    font-weight: 700;
    color: var(--text-dark);
}

.permission-user-email {
    font-size: 0.82rem;
    color: var(--text-muted);
    word-break: break-all;
}

.permission-user-role,
.permission-user-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    padding: 0.35rem 0.75rem;
    background: rgba(79, 70, 229, 0.1);
    color: var(--primary);
    font-size: 0.72rem;
    font-weight: 700;
    white-space: nowrap;
}

.permission-user-empty {
    padding: 0.85rem 1rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.875rem;
}

.permission-selected-user-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.25rem;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.08), rgba(255, 255, 255, 0.95));
    border: 1px solid rgba(99, 102, 241, 0.16);
    border-radius: 1rem;
}

.permission-table-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

.permission-module-search {
    min-width: min(360px, 100%);
    max-width: 520px;
}

.permission-table-row-hidden {
    display: none !important;
}

@media (max-width: 991px) {
    .permission-picker-head,
    .permission-picker-field,
    .permission-selected-user-card,
    .permission-table-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .permission-picker-chip {
        align-self: flex-start;
    }

    .permission-picker-clear,
    .permission-module-search {
        width: 100%;
        max-width: none;
    }

    .permission-user-result {
        flex-direction: column;
    }

    .permission-user-role,
    .permission-user-badge {
        align-self: flex-start;
    }
}

/* Premium Alerts */
.premium-alert {
    background: white;
    border-radius: 1rem !important;
    border: 1px solid var(--border-color) !important;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.05);
    padding: 1rem 1.25rem !important;
}

.alert-success.premium-alert {
    border-left: 4px solid #10B981 !important;
}

.alert-danger.premium-alert {
    border-left: 4px solid #EF4444 !important;
}

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

@media print {

    .sidebar,
    .mobile-toggle,
    .btn,
    form,
    hr {
        display: none !important;
    }

    .main-content {
        margin-left: 0 !important;
        padding: 0 !important;
    }

    .card {
        box-shadow: none !important;
        border: 1px solid #eee !important;
        background: white !important;
    }
}

/* Premium Profile & Directory Components */
.stat-card-v2 {
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

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

.detail-item {
    transition: all 0.3s ease;
}

.detail-item:hover {
    border-color: var(--primary) !important;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.05) !important;
}

/* Timeline v2 - Professional Look */
.timeline-v2 {
    position: relative;
    padding-left: 3rem;
}

.timeline-v2::before {
    content: '';
    position: absolute;
    left: 0.75rem;
    top: 0;
    bottom: 0;
    width: 2px;
    background: linear-gradient(to bottom, var(--primary) 0%, var(--border-color) 100%);
}

.timeline-v2-marker {
    position: absolute;
    left: 0;
    top: 0;
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 50%;
    border: 4px solid white;
    z-index: 2;
}

.timeline-v2-item {
    position: relative;
}

/* Mobile Fixes for Profile */
@media (max-width: 767px) {
    .profile-stats-grid {
        grid-template-columns: 1fr 1fr !important;
    }

    .timeline-v2 {
        padding-left: 2rem;
    }

    .timeline-v2::before {
        left: 0.5rem;
    }

    .timeline-v2-marker {
        width: 1rem;
        height: 1rem;
        left: 0.05rem;
        border-width: 2px;
    }

    .stat-card-v2 {
        padding: 1rem !important;
    }

    .stat-icon-circle {
        width: 36px;
        height: 36px;
        font-size: 1rem;
    }

    .profile-section-item {
        padding: 1rem !important;
    }
}

@media (max-width: 480px) {
    .profile-stats-grid {
        grid-template-columns: 1fr !important;
    }
}

/* ==========================================
   ULTRA-RESPONSIVE REFINEMENTS (All Sizes)
   ========================================== */

/* Base responsiveness for page layout */
@media (max-width: 576px) {
    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .page-header .d-flex {
        width: 100%;
        justify-content: flex-start;
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .page-header h1 {
        font-size: 1.5rem !important;
    }

    .main-content {
        padding: 5.5rem 0.75rem 1.5rem 0.75rem !important;
    }

    .card {
        padding: 1.25rem !important;
        border-radius: 1rem !important;
    }
}

/* Fix for Tables on small screens */
.table-responsive {
    border: 1px solid var(--border-color);
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.02);
}

@media (max-width: 500px) {

    td,
    th {
        padding: 0.65rem 0.75rem !important;
        font-size: 0.8rem !important;
        white-space: normal !important;
        /* Force wrapping even if text-nowrap class is present */
    }

    .badge {
        padding: 0.25rem 0.6rem !important;
        font-size: 0.7rem !important;
    }

    /* Force Vertical Stacking for Card Headers up to 500px */
    .card-header .d-flex,
    .card .d-flex.justify-content-between {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 0.75rem !important;
    }

    .card-header .d-flex .d-flex,
    .card .d-flex.justify-content-between .d-flex {
        flex-direction: column !important;
        width: 100% !important;
        gap: 0.5rem !important;
    }

    .card-header .btn-sm,
    .card .btn-sm {
        width: 100% !important;
        justify-content: center !important;
    }

    /* Title Scaling for mobile */
    .card-header h2,
    .card h2.h5 {
        font-size: 1.15rem !important;
        margin-bottom: 0 !important;
    }
}

/* Extreme small screens (iPhone SE, etc.) */
@media (max-width: 360px) {
    .sidebar-brand {
        font-size: 1.05rem !important;
    }

    .page-header h1 {
        font-size: 1.2rem !important;
    }

    .main-content {
        padding: 5rem 0.6rem 1rem 0.6rem !important;
    }

    .card {
        padding: 1rem !important;
    }

    .btn {
        padding: 0.5rem 0.875rem !important;
        font-size: 0.75rem !important;
    }

    /* Intermediate Table Scaling for 327px etc. */
    td,
    th {
        padding: 0.5rem 0.6rem !important;
        font-size: 0.75rem !important;
    }

    .badge {
        padding: 0.2rem 0.5rem !important;
        font-size: 0.68rem !important;
    }
}

/* Nano screens (Smartwatches, Foldables folded state, etc. down to 256px) */
@media (max-width: 319px) {
    :root {
        --sidebar-width: 0px;
    }

    .sidebar-brand {
        font-size: 0.85rem !important;
        max-width: 160px !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        white-space: nowrap !important;
        display: block !important;
    }

    .mobile-header {
        height: 54px !important;
        padding: 0 0.5rem !important;
        justify-content: space-between !important;
    }

    .mobile-toggle {
        padding: 0.25rem !important;
        flex-shrink: 0 !important;
    }

    .mobile-toggle i,
    .mobile-toggle svg {
        width: 18px !important;
        height: 18px !important;
    }

    .page-header h1 {
        font-size: 1.1rem !important;
    }

    .main-content {
        padding: 4rem 0.25rem 0.75rem 0.25rem !important;
    }

    .card {
        padding: 0.75rem !important;
        border-radius: 0.75rem !important;
    }

    /* Force Vertical Stacking for Card Headers */
    .card-header .d-flex,
    .card .d-flex.justify-content-between {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 0.75rem !important;
    }

    .card-header .d-flex .d-flex,
    .card .d-flex.justify-content-between .d-flex {
        flex-direction: column !important;
        width: 100% !important;
        gap: 0.5rem !important;
    }

    .card-header .btn-sm,
    .card .btn-sm {
        width: 100% !important;
        justify-content: center !important;
    }

    /* Table Nano Refining */
    td,
    th {
        padding: 0.4rem 0.3rem !important;
        font-size: 0.7rem !important;
        white-space: normal !important;
        /* Allow wrapping to prevent overflow */
    }

    .badge {
        padding: 0.2rem 0.4rem !important;
        font-size: 0.65rem !important;
    }

    .btn-sm {
        padding: 0.35rem 0.6rem !important;
        font-size: 0.65rem !important;
    }

    .btn {
        padding: 0.45rem 0.75rem !important;
        font-size: 0.7rem !important;
        border-radius: 0.5rem !important;
    }

    .user-avatar-large {
        width: 60px !important;
        height: 60px !important;
        font-size: 1.5rem !important;
    }

    .profile-header-card {
        padding: 1rem !important;
        border-radius: 1.25rem !important;
    }

    .profile-header-card h2 {
        font-size: 1.1rem !important;
    }

    .header-info-item {
        font-size: 0.75rem !important;
        padding: 0.4rem !important;
        gap: 6px !important;
    }

    .profile-stats-grid {
        grid-template-columns: 1fr !important;
        gap: 0.75rem !important;
    }

    .stat-card-v2 {
        padding: 0.875rem !important;
    }

    .timeline-v2 {
        padding-left: 1.5rem !important;
    }

    .timeline-v2::before {
        left: 0.4rem !important;
    }

    .profile-nav-tabs {
        overflow-x: auto;
        white-space: nowrap;
        padding-bottom: 0.5rem;
    }

    .profile-nav-link {
        padding: 0.5rem 0.75rem !important;
        font-size: 0.75rem !important;
    }

    /* Global Directory & Grid Refinements */
    .directory-grid {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }

    .directory-card {
        padding: 1.25rem !important;
    }

    .directory-toolbar {
        flex-direction: column !important;
        gap: 0.75rem !important;
    }

    .search-input-group {
        width: 100% !important;
    }

    .view-toggle-group {
        width: 100% !important;
        justify-content: center !important;
    }

    /* Users Directory (users.php) Specifics */
    .directory-header-row {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 1rem !important;
    }

    .directory-header-row .add-user-btn {
        width: 100% !important;
        justify-content: center !important;
    }

    .user-directory-card {
        padding: 1rem !important;
    }

    .user-card-meta-grid {
        grid-template-columns: 1fr !important;
        gap: 0.75rem !important;
        margin: 1rem 0 !important;
        padding: 1rem 0 !important;
    }

    .user-card-name {
        font-size: 0.95rem !important;
        max-width: 100% !important;
    }

    .user-card-avatar {
        width: 48px !important;
        height: 48px !important;
        min-width: 48px !important;
        min-height: 48px !important;
        font-size: 1.1rem !important;
    }

    /* Form & Input Scaling */
    .form-group {
        margin-bottom: 1rem !important;
    }

    .form-control,
    .form-select,
    .input-group-text {
        padding: 0.6rem 0.8rem !important;
        font-size: 0.85rem !important;
    }

    .input-group {
        flex-wrap: nowrap !important;
    }

    .input-group-text i {
        width: 16px !important;
        height: 16px !important;
    }

    /* Typography Scaling for Nano */
    h1,
    .h1 {
        font-size: 1.25rem !important;
    }

    h2,
    .h2 {
        font-size: 1.15rem !important;
    }

    h3,
    .h3 {
        font-size: 1.05rem !important;
    }

    h4,
    .h4 {
        font-size: 0.95rem !important;
    }

    h5,
    .h5 {
        font-size: 0.85rem !important;
    }

    h6,
    .h6 {
        font-size: 0.75rem !important;
    }
}

/* Grid System Overrides for small screens */
@media (max-width: 768px) {
    [class*="grid-"] {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }
}

/* Form Responsiveness */
@media (max-width: 500px) {
    .modal-dialog {
        margin: 0.5rem;
    }

    .modal-content {
        border-radius: 1.25rem !important;
    }

    .login-card {
        padding: 2rem 1.5rem !important;
    }

    .login-header h1 {
        font-size: 1.5rem !important;
    }
}

/* Mobile Stacking Helpers */
@media (max-width: 500px) {
    .row.g-3>.col-6 {
        width: 100% !important;
    }

    .input-group-sm>.form-control {
        font-size: 0.9rem !important;
    }
}


/* Modal Content scrolling on small height devices */
@media (max-height: 600px) {
    .modal-dialog-centered {
        align-items: flex-start !important;
        margin-top: 1rem !important;
    }
}

/* Attendance Table Enhancements */
.attendance-card-upgraded {
    border: 1px solid rgba(99, 102, 241, 0.12) !important;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(10px);
}

.attendance-table {
    --bs-table-bg: transparent;
}

.attendance-table thead th {
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: #64748b;
    background: rgba(241, 245, 249, 0.7);
    border-bottom: 1px solid rgba(148, 163, 184, 0.25);
}

.attendance-table tbody td {
    vertical-align: middle;
}

.attendance-table tbody tr:hover {
    background: rgba(99, 102, 241, 0.04);
}

.attendance-employee-link {
    color: #0f172a;
    font-weight: 600;
    text-decoration: none;
}

.attendance-employee-link:hover {
    color: var(--indigo);
}

.location-stack {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.location-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    border: 1px solid rgba(99, 102, 241, 0.22);
    color: var(--indigo);
    background: rgba(99, 102, 241, 0.08);
    border-radius: 999px;
    padding: 0.2rem 0.6rem;
    font-size: 0.72rem;
    font-weight: 600;
    text-decoration: none;
}

.location-chip:hover {
    background: rgba(99, 102, 241, 0.16);
    color: var(--indigo-hover);
}

.location-chip-empty {
    display: inline-flex;
    align-items: center;
    border: 1px dashed rgba(148, 163, 184, 0.55);
    color: #64748b;
    background: rgba(248, 250, 252, 0.9);
    border-radius: 999px;
    padding: 0.2rem 0.6rem;
    font-size: 0.72rem;
}

.summary-preview {
    max-width: 220px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Shared Soft Theme Foundation */
body.app-soft-theme {
    background:
        radial-gradient(circle at top left, rgba(var(--primary-light-rgb), 0.22), transparent 34%),
        radial-gradient(circle at top right, rgba(var(--primary-rgb), 0.16), transparent 28%),
        linear-gradient(180deg, #f8fbff 0%, var(--app-soft-bg) 42%, var(--app-soft-bg-alt) 100%);
    color: var(--app-soft-text);
}

.app-soft-theme .app-container,
.app-soft-theme .main-content {
    background: transparent;
}

.app-soft-theme .main-content {
    position: relative;
}

.app-soft-theme .page-header,
.app-soft-theme .content-card,
.app-soft-theme .card,
.app-soft-theme .table-responsive,
.app-soft-theme .modal-content,
.app-soft-theme .dropdown-menu,
.app-soft-theme .offcanvas,
.app-soft-theme .accordion-item,
.app-soft-theme .list-group,
.app-soft-theme .list-group-item,
.app-soft-theme .alert,
.app-soft-theme .popover,
.app-soft-theme .tooltip-inner,
.app-soft-theme .border.rounded,
.app-soft-theme .shadow-sm,
.app-soft-theme .shadow,
.app-soft-theme .shadow-lg {
    background: var(--app-soft-card);
    border: 1px solid var(--app-soft-border) !important;
    box-shadow: var(--app-soft-shadow) !important;
}

.app-soft-theme .content-card,
.app-soft-theme .card,
.app-soft-theme .table-responsive,
.app-soft-theme .modal-content,
.app-soft-theme .offcanvas,
.app-soft-theme .accordion-item {
    border-radius: 1.6rem !important;
}

.app-soft-theme .card-header,
.app-soft-theme .card-footer,
.app-soft-theme .modal-header,
.app-soft-theme .modal-footer,
.app-soft-theme .accordion-button,
.app-soft-theme .list-group-item,
.app-soft-theme .table-responsive thead th {
    background: transparent;
    border-color: rgba(181, 196, 255, 0.28) !important;
}

.app-soft-theme .table-responsive {
    overflow: hidden;
}

.app-soft-theme table {
    --bs-table-bg: transparent;
    --bs-table-hover-bg: rgba(var(--primary-rgb), 0.045);
    --bs-table-striped-bg: rgba(247, 250, 255, 0.74);
}

.app-soft-theme table thead th,
.app-soft-theme .table > :not(caption) > * > th {
    color: var(--app-soft-muted);
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    font-size: 0.78rem;
}

.app-soft-theme table tbody td,
.app-soft-theme .table > :not(caption) > * > td {
    color: var(--app-soft-text);
    border-color: rgba(181, 196, 255, 0.24);
    vertical-align: middle;
}

.app-soft-theme table tbody tr:hover {
    background: rgba(var(--primary-rgb), 0.045);
}

.app-soft-theme .form-control,
.app-soft-theme .form-select,
.app-soft-theme .input-group-text,
.app-soft-theme textarea,
.app-soft-theme select,
.app-soft-theme input[type="text"],
.app-soft-theme input[type="number"],
.app-soft-theme input[type="date"],
.app-soft-theme input[type="time"],
.app-soft-theme input[type="search"],
.app-soft-theme input[type="email"],
.app-soft-theme input[type="password"] {
    background: var(--app-soft-card-strong);
    border: 1px solid rgba(181, 196, 255, 0.42) !important;
    border-radius: 1.1rem !important;
    color: var(--app-soft-text);
    box-shadow: 0 10px 24px -24px rgba(106, 129, 214, 0.35);
}

.app-soft-theme .form-control::placeholder,
.app-soft-theme textarea::placeholder,
.app-soft-theme input::placeholder {
    color: #94a1bd;
}

.app-soft-theme .form-control:focus,
.app-soft-theme .form-select:focus,
.app-soft-theme textarea:focus,
.app-soft-theme input:focus {
    border-color: var(--primary-border) !important;
    box-shadow: 0 0 0 0.22rem var(--focus-ring), 0 16px 30px -26px rgba(var(--primary-rgb), 0.34) !important;
}

.app-soft-theme .btn {
    border-radius: 999px !important;
    font-weight: 700;
    letter-spacing: 0.01em;
    box-shadow: 0 14px 30px -24px rgba(106, 129, 214, 0.44);
}

.app-soft-theme .btn-primary,
.app-soft-theme .btn-success,
.app-soft-theme .btn-danger {
    border: none !important;
    color: #fff !important;
}

.app-soft-theme .btn-primary {
    background: linear-gradient(135deg, var(--app-soft-accent) 0%, var(--primary-hover) 100%) !important;
}

.app-soft-theme .btn-primary:hover,
.app-soft-theme .btn-primary:focus {
    background: linear-gradient(135deg, var(--app-soft-accent-hover) 0%, var(--primary-hover) 100%) !important;
}

.app-soft-theme .btn-success {
    background: linear-gradient(135deg, #32cf9d 0%, #14b884 100%) !important;
}

.app-soft-theme .btn-danger {
    background: linear-gradient(135deg, var(--danger) 0%, var(--danger-strong) 100%) !important;
}

.app-soft-theme .btn-outline-primary,
.app-soft-theme .btn-light,
.app-soft-theme .btn-secondary,
.app-soft-theme .btn-outline-secondary {
    background: var(--app-soft-card-strong) !important;
    border: 1px solid rgba(181, 196, 255, 0.46) !important;
    color: var(--app-soft-text) !important;
}

.app-soft-theme .btn-outline-primary {
    color: var(--app-soft-accent) !important;
}

.app-soft-theme .btn-outline-primary:hover,
.app-soft-theme .btn-outline-secondary:hover,
.app-soft-theme .btn-light:hover,
.app-soft-theme .btn-secondary:hover {
    background: rgba(var(--primary-rgb), 0.08) !important;
}

.app-soft-theme .nav-tabs,
.app-soft-theme .nav-pills,
.app-soft-theme .pagination {
    gap: 0.45rem;
}

.app-soft-theme .nav-tabs .nav-link,
.app-soft-theme .nav-pills .nav-link,
.app-soft-theme .pagination .page-link {
    border: 1px solid rgba(181, 196, 255, 0.38) !important;
    border-radius: 999px !important;
    background: var(--app-soft-card-strong);
    color: var(--app-soft-muted);
}

.app-soft-theme .nav-tabs .nav-link.active,
.app-soft-theme .nav-pills .nav-link.active,
.app-soft-theme .pagination .active > .page-link {
    background: linear-gradient(135deg, rgba(var(--primary-rgb), 0.16) 0%, rgba(var(--primary-light-rgb), 0.22) 100%);
    color: var(--app-soft-accent);
    border-color: var(--primary-border) !important;
    box-shadow: var(--app-soft-shadow-sm);
}

.app-soft-theme .badge,
.app-soft-theme .pill,
.app-soft-theme .chip {
    border-radius: 999px !important;
    font-weight: 700;
}

.app-soft-theme .badge.bg-primary,
.app-soft-theme .bg-primary-subtle {
    background: rgba(var(--primary-rgb), 0.14) !important;
    color: var(--app-soft-accent) !important;
}

.bg-indigo-subtle {
    background: rgba(99, 102, 241, 0.1) !important;
}

.text-indigo {
    color: #6366f1 !important;
}

.border-indigo-subtle {
    border-color: rgba(99, 102, 241, 0.24) !important;
}

.app-soft-theme .bg-indigo-subtle {
    background: rgba(var(--primary-rgb), 0.14) !important;
}

.app-soft-theme .text-indigo {
    color: var(--app-soft-accent) !important;
}

.app-soft-theme .border-indigo-subtle {
    border-color: rgba(var(--primary-rgb), 0.24) !important;
}

.app-soft-theme .badge.bg-success,
.app-soft-theme .bg-success-subtle {
    background: rgba(50, 207, 157, 0.14) !important;
    color: #129567 !important;
}

.app-soft-theme .badge.bg-danger,
.app-soft-theme .bg-danger-subtle {
    background: rgba(245, 107, 123, 0.14) !important;
    color: #d34661 !important;
}

.app-soft-theme .badge.bg-warning,
.app-soft-theme .bg-warning-subtle {
    background: rgba(255, 193, 94, 0.18) !important;
    color: #b9770e !important;
}

.app-soft-theme .alert {
    color: var(--app-soft-text);
}

.app-soft-theme h1,
.app-soft-theme h2,
.app-soft-theme h3,
.app-soft-theme h4,
.app-soft-theme h5,
.app-soft-theme h6,
.app-soft-theme .h1,
.app-soft-theme .h2,
.app-soft-theme .h3,
.app-soft-theme .h4,
.app-soft-theme .h5,
.app-soft-theme .h6 {
    color: var(--app-soft-text);
}

.app-soft-theme .text-muted,
.app-soft-theme small,
.app-soft-theme .small,
.app-soft-theme .form-text {
    color: var(--app-soft-muted) !important;
}

.app-soft-theme .dropdown-item:hover,
.app-soft-theme .dropdown-item:focus {
    background: rgba(var(--primary-rgb), 0.08);
}

.app-soft-theme .btn-close {
    filter: none;
    opacity: 0.72;
}

.app-soft-theme .modal-backdrop.show {
    opacity: 0.14;
}

@media (max-width: 991.98px) {
    .app-soft-theme .main-content {
        padding-inline: 0.9rem;
    }

    .app-soft-theme .page-header,
    .app-soft-theme .content-card,
    .app-soft-theme .card,
    .app-soft-theme .table-responsive,
    .app-soft-theme .modal-content,
    .app-soft-theme .offcanvas,
    .app-soft-theme .accordion-item {
        border-radius: 1.3rem !important;
    }
}

/* Global responsive safety layer */
html {
    -webkit-text-size-adjust: 100%;
}

body.sidebar-open {
    overflow: hidden !important;
}

.app-container,
.main-content,
.main-content > *,
.main-content .row,
.main-content [class*="col-"],
.main-content .card,
.main-content .content-card,
.main-content .modal-content,
.main-content .d-flex,
.main-content .input-group {
    min-width: 0;
}

.main-content img,
.main-content video,
.main-content canvas,
.main-content iframe {
    max-width: 100%;
}

.main-content .container,
.main-content .container-fluid,
.main-content .container-lg,
.main-content .container-xl,
.main-content .container-xxl {
    max-width: 100%;
}

.table-container,
.table-responsive,
.app-soft-theme .table-responsive {
    max-width: 100%;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
}

.table-responsive .table {
    margin-bottom: 0;
}

.main-content .form-control,
.main-content .form-select,
.main-content textarea,
.main-content select,
.main-content input {
    max-width: 100%;
}

.modal-dialog {
    max-width: calc(100% - 1rem);
}

@media (max-width: 991.98px) {
    .main-content {
        width: 100% !important;
    }

    .sidebar-backdrop {
        z-index: 2000;
    }

    .sidebar.active + .sidebar-backdrop {
        display: block !important;
    }

    .sidebar.active ~ .sidebar-backdrop {
        display: block !important;
    }
}

@media (max-width: 767.98px) {
    .main-content .page-header,
    .main-content .card-header,
    .main-content .modal-header,
    .main-content .modal-footer {
        gap: 0.75rem;
    }

    .main-content .page-header,
    .main-content .page-header > .d-flex,
    .main-content .card-header > .d-flex,
    .main-content .modal-footer {
        flex-wrap: wrap;
    }

    .main-content .table-container,
    .main-content .table-responsive {
        border-radius: 1rem;
        max-height: min(70vh, 520px);
    }
}

@media (max-width: 575.98px) {
    .mobile-header {
        height: 64px !important;
    }

    .mobile-header .sidebar-brand-text {
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .sidebar {
        width: min(86vw, 280px) !important;
    }

    .main-content {
        padding: 5.35rem 0.75rem 1.5rem !important;
    }

    .main-content > .container,
    .main-content > .container-fluid,
    .main-content > .container-lg,
    .main-content > .container-xl,
    .main-content > .container-xxl {
        padding-left: 0 !important;
        padding-right: 0 !important;
    }

    .main-content .page-header,
    .main-content .card-header > .d-flex,
    .main-content .card .d-flex.justify-content-between,
    .main-content .modal-footer {
        flex-direction: column !important;
        align-items: stretch !important;
    }

    .main-content .page-header .btn,
    .main-content .card-header .btn,
    .main-content .modal-footer .btn,
    .main-content form .btn[type="submit"] {
        width: 100%;
        justify-content: center;
    }

    .main-content :is(.detail-shell, .surface, .input-group, .d-flex, .btn, .form-control, .form-select)[style*="min-width"] {
        min-width: 0 !important;
        max-width: 100% !important;
    }

    .main-content .input-group {
        width: 100%;
        flex-wrap: nowrap;
    }

    .main-content .input-group > .form-control,
    .main-content .input-group > .form-select {
        min-width: 0;
    }

    .main-content .row.g-3 > .col-6,
    .main-content .row.g-4 > .col-6 {
        width: 100% !important;
    }

    .main-content .badge {
        max-width: 100%;
        white-space: normal;
        text-align: left;
    }

    .main-content .table-responsive table {
        min-width: max(640px, 100%);
    }

    .main-content .table-responsive .table-sm {
        min-width: max(560px, 100%);
    }
}

@media (max-width: 380px) {
    .main-content {
        padding-left: 0.55rem !important;
        padding-right: 0.55rem !important;
    }

    .main-content .card,
    .main-content .content-card,
    .app-soft-theme .content-card,
    .app-soft-theme .card {
        border-radius: 1rem !important;
    }
}
