:root {
    /* Semantic HSL system for cmsminds.com (Primary Blue: #0066B3) */
    --h: 206;
    --s: 100%;
    /* Primary brand blue (#0066B3) */
    --p-h: 206;
    --p-s: 100%;
    --p-l: 35%;
    /* Secondary brand cyan (#00A5CF) */
    --sec-h: 194;
    --sec-s: 100%;
    --sec-l: 41%;

    /* Brand Gradient */
    --brand-gradient: linear-gradient(99deg, #0066B3 0%, #00A5CF 100%);

    /* Theme Variables */
    --primary: hsl(var(--p-h), var(--p-s), var(--p-l));
    --primary-hover: hsl(var(--p-h), var(--p-s), calc(var(--p-l) + 10%));
    --primary-glow: hsla(var(--p-h), var(--p-s), var(--p-l), 0.25);

    --bg-main: #F3F7F8;
    --bg-card: #ffffff;
    --text-main: #111111;
    --text-muted: #3B3A39;
    --border: #D1E5ED;

    /* Adaptive Glassmorphism (Modern CMSMinds Style) */
    --glass-bg: hsla(0, 0%, 100%, 0.85);
    --glass-bg-subtle: hsla(var(--h), 20%, 50%, 0.03);
    --glass-bg-heavy: hsla(var(--h), 20%, 50%, 0.08);
    --glass-border: hsla(var(--h), 20%, 80%, 0.4);
    --glass-blur: 16px;

    /* Elevation */
    --shadow-sm: 0 4px 6px -1px rgba(0, 102, 179, 0.05);
    --shadow-md: 0 10px 15px -3px rgba(0, 102, 179, 0.08);
    --shadow-lg: 0 20px 25px -5px rgba(0, 102, 179, 0.1);

    --radius-sm: 6px;
    --radius-md: 8px; /* Brand button radius */
    --radius-lg: 12px; /* Brand card radius */

    /* Sidebar/Shell (Modern CMSMinds Slate/Navy) */
    --sidebar-width: 275px;
    --sidebar-bg: #003359; /* A deeper tint of the brand blue */
    --header-height: 64px;
    --hide-if-collapsed: block;
}

[data-theme="dark"] {
    --bg-main: hsl(222, 47%, 6%);
    --bg-card: hsl(222, 47%, 10%);
    --text-main: hsl(210, 40%, 98%);
    --text-muted: hsl(215, 20%, 65%);
    --border: hsl(217, 33%, 17%);

    --glass-bg: hsla(222, 47%, 12%, 0.85);
    --glass-bg-subtle: hsla(0, 0%, 100%, 0.05); /* Light tint for Dark Mode depth */
    --glass-bg-heavy: hsla(0, 0%, 100%, 0.1);
    --glass-border: hsla(210, 40%, 98%, 0.05);
    --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.3), 0 1px 2px -1px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -2px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 25px 50px -12px rgba(0, 0, 0, 0.6);
}

.top-header .header-logo,
.sidebar .header-logo,
.header-logo {
    opacity: 1;
    transition: opacity 0.3s ease;
}

/* Dual Logo Theme Toggle */
/* Light Mode (default): Hide white/bright logos (.theme-logo-dark) */
html:not([data-theme="dark"]) .theme-logo-dark { display: none !important; }
/* Dark Mode: Hide dark/black logos (.theme-logo-light) */
[data-theme="dark"] .theme-logo-light { display: none !important; }

/* If no specialized dark-mode logo is uploaded, always force show the default light-mode logo */
body:not(.has-light-logo) .theme-logo-light { display: block !important; }

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    line-height: 1.6;
    overflow-x: hidden;
    transition: background-color 0.4s cubic-bezier(0.4, 0, 0.2, 1), color 0.4s ease;
    -webkit-font-smoothing: antialiased;
}

body.modal-open {
    overflow: hidden !important;
}

/* Glassmorphism 2.0 Utilities */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
}

.text-gradient {
    background: linear-gradient(135deg, var(--text-main) 30%, var(--primary) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.glass-card {
    background: var(--glass-bg);
    backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.glass-card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--primary-glow);
}

/* Signature Card Design System */
.signature-card {
    background: var(--bg-card);
    border-radius: 1.5rem;
    border: 1px solid var(--border);
    border-top-width: 4px;
    border-top-style: solid;
    border-top-color: var(--primary);
    box-shadow: var(--shadow-md);
    overflow: hidden;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
}
.signature-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}
.signature-card-header {
    padding: 1.25rem 1.5rem;
    background: var(--glass-bg-subtle);
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.signature-card-header h3 {
    margin: 0;
    font-size: 0.8rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
}
.signature-card-body {
    padding: 1.5rem;
    flex: 1;
}

/* Dashboard Navigation Tabs */
.dashboard-nav-tabs {
    display: flex;
    gap: 0.5rem;
    background: var(--glass-bg-subtle);
    padding: 0.4rem;
    border-radius: 2.5rem;
    border: 1px solid var(--border);
    flex-wrap: wrap; /* Added for mobile */
}

@media (max-width: 640px) {
    .dashboard-nav-tabs {
        border-radius: 1rem;
        width: 100%;
    }
    .dashboard-nav-link {
        flex: 1;
        text-align: center;
        padding: 0.5rem 0.75rem;
    }
}
.dashboard-nav-link {
    padding: 0.6rem 1.25rem;
    border-radius: 2rem;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-muted);
    text-decoration: none;
    transition: all 0.2s ease;
}
.dashboard-nav-link:hover {
    color: var(--primary);
}
.dashboard-nav-link.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 12px var(--primary-glow);
}

/* Layout Structure */
.app-wrapper {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-width) !important;
    background: var(--sidebar-bg) !important;
    color: white !important;
    height: 100vh !important;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    z-index: 3000 !important;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex !important;
    flex-direction: column !important;
    padding: 0 0.5rem 0.5rem !important; /* Reduced bottom padding */
    overflow: hidden !important; 
    border-right: 1px solid rgba(255, 255, 255, 0.05);
}

.sidebar nav {
    flex: 1 !important;
    min-height: 0 !important; /* Crucial for flex scrolling */
    overflow-y: auto !important;
    margin-bottom: 0.5rem;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

/* Custom Scrollbar for Sidebar */
.sidebar nav::-webkit-scrollbar {
    width: 6px;
}

.sidebar nav::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar nav::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15); /* Slightly darker/more visible */
    border-radius: 10px;
}

.sidebar nav:hover::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3); /* Brighter on hover */
}

.sidebar-logo {
    margin-bottom: 2rem !important;
    padding: 0 !important;
    display: flex !important;
    align-items: center !important;
    gap: 6px !important;
    overflow: visible !important;
}

.sidebar nav {
    display: flex !important;
    flex-direction: column !important;
    gap: 0.1rem !important;
    flex: 1 !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    padding-right: 0.25rem;
    margin-top: 0.5rem;
    scrollbar-width: thin;
}

.sub-nav-item {
    transition: all 0.25s ease !important;
}

body.sidebar-collapsed .sub-nav-item {
    padding-left: 0 !important;
    justify-content: center !important;
}

body.sidebar-collapsed .sub-nav-item i {
    margin-right: 0 !important;
}

body.sidebar-collapsed .sidebar:hover .sub-nav-item {
    padding-left: 1.5rem !important;
    justify-content: flex-start !important;
}

body.sidebar-collapsed .sidebar:hover .sub-nav-item i {
    margin-right: 12px !important;
}

.main-content {
    flex: 1 !important;
    margin-left: var(--sidebar-width) !important;
    padding: 0 !important;
    /* Header has its own padding */
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    min-height: 100vh;
}

/* Sidebar Collapsed State (Desktop) */
body.sidebar-collapsed .sidebar {
    width: 68px !important;
    padding: 0 0.5rem 1.5rem !important;
    --hide-if-collapsed: none;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.3s ease !important;
}

body.sidebar-collapsed .sidebar:hover {
    width: var(--sidebar-width) !important;
    box-shadow: 10px 0 30px rgba(0,0,0,0.25) !important;
    --hide-if-collapsed: block;
}

body.sidebar-collapsed .main-content {
    margin-left: 68px !important;
}

body.sidebar-collapsed .sidebar-logo {
    justify-content: center !important;
}

body.sidebar-collapsed .sidebar:hover .sidebar-logo {
    justify-content: flex-start !important;
    padding: 0 1rem !important;
}

body.sidebar-collapsed .sidebar-logo svg,
body.sidebar-collapsed .sidebar-logo span {
    display: none !important;
}

body.sidebar-collapsed .sidebar:hover .sidebar-logo svg,
body.sidebar-collapsed .sidebar:hover .sidebar-logo span {
    display: block !important;
}

body.sidebar-collapsed .sidebar-logo .sidebar-logo-icon {
    display: block !important;
}

body.sidebar-collapsed .sidebar-heading span,
body.sidebar-collapsed .sidebar-header .sidebar-brand,
body.sidebar-collapsed .sidebar-nav-title {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
}

body.sidebar-collapsed .sidebar:hover .sidebar-heading span,
body.sidebar-collapsed .sidebar:hover .sidebar-header .sidebar-brand,
body.sidebar-collapsed .sidebar:hover .sidebar-nav-title {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    height: auto !important;
    margin: 1.5rem 0 0.5rem !important;
    padding: 0 1rem !important;
}

body.sidebar-collapsed .sidebar-heading {
    justify-content: center !important;
    padding: 1rem 0 0.4rem !important;
}

body.sidebar-collapsed .sidebar-heading i {
    margin: 0 !important;
    font-size: 1.25rem !important;
}


body.sidebar-collapsed .sidebar-nav-item span {
    display: none !important;
}

body.sidebar-collapsed .sidebar:hover .sidebar-nav-item span {
    display: inline-block !important;
}

body.sidebar-collapsed .sidebar-nav-item {
    justify-content: center !important;
    padding: 0.9rem 0 !important;
}

body.sidebar-collapsed .sidebar:hover .sidebar-nav-item {
    justify-content: flex-start !important;
    padding: 0.9rem 1.25rem !important;
}

body.sidebar-collapsed .sidebar-nav-item i {
    margin: 0 !important;
    font-size: 1.25rem !important;
}

body.sidebar-collapsed .sidebar:hover .sidebar-nav-item i {
    margin-right: 12px !important;
    font-size: 1.1rem !important;
}

body.sidebar-collapsed .sidebar-footer span {
    display: none !important;
}

body.sidebar-collapsed .sidebar:hover .sidebar-footer span {
    display: inline-block !important;
}

.page-container,
.project-details-container,
.container,
.container-fluid {
    width: 100%;
    margin: 0 auto;
    padding: 0 2rem 2rem;
    max-width: 100%;
    transition: padding 0.3s ease;
}

@media (max-width: 1440px) {
    .page-container,
    .project-details-container,
    .container,
    .container-fluid {
        padding: 0 1rem 1rem;
    }
}

@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%) !important;
    }

    .main-content {
        margin-left: 0 !important;
        padding-top: var(--header-height) !important;
    }

    #sidebar-toggle {
        display: flex !important;
        align-items: center;
        justify-content: center;
    }

    .sidebar-open .sidebar {
        transform: translateX(0) !important;
    }

    .sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.5);
        backdrop-filter: blur(4px);
        z-index: 2500;
    }

    .sidebar-open .sidebar-overlay {
        display: block;
    }
}

/* Typography */
h1,
h2,
h3,
h4 {
    font-family: 'Lexend', sans-serif;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text-main);
}

h1 {
    font-size: clamp(1.8rem, 4vw, 2.4rem);
    background: var(--brand-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    line-height: 1.2;
    margin-bottom: 1.5rem;
}

h2 {
    font-size: clamp(1.4rem, 2.5vw, 1.75rem);
    margin-bottom: 1rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 0.9rem;
    text-decoration: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    border: 1px solid transparent;
    gap: 0.75rem;
    white-space: nowrap;
}

.btn-primary {
    background: var(--brand-gradient);
    color: white !important;
    box-shadow: 0 8px 20px -6px var(--primary-glow);
    border: none;
}

.btn-primary:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 12px 24px -8px var(--primary-glow);
}

.btn-ghost {
    background: hsla(var(--h), 20%, 90%, 0.3);
    color: var(--text-muted);
    border: 1px solid var(--border);
}

.btn-ghost:hover {
    background: hsla(var(--p-h), var(--p-s), var(--p-l), 0.08);
    color: var(--primary);
    border-color: var(--primary-glow);
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.8rem;
}

/* Cards */
.card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 2rem;
    border: 1px solid var(--border);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.card::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, var(--primary) 0%, transparent 100%);
    opacity: 0;
    transition: opacity 0.4s ease;
    pointer-events: none;
}

.card:hover {
    transform: translateY(-4px);
    border-color: var(--primary-glow);
    box-shadow: var(--shadow-lg);
}

.card:hover::after {
    opacity: 0.03;
}

/* Grid & Layout Utilities */
.grid {
    display: grid;
    gap: 1.75rem;
}

.grid-2 {
    grid-template-columns: repeat(2, 1fr);
}

.grid-3 {
    grid-template-columns: repeat(3, 1fr);
}

.grid-4 {
    grid-template-columns: repeat(4, 1fr);
}

@media (max-width: 1536px) {
    .grid-4 {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 1366px) {
    .grid-4,
    .grid-3 {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 1024px) {
    .grid-4,
    .grid-2 {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .grid-4,
    .grid-3,
    .grid-2 {
        grid-template-columns: 1fr !important;
    }
}

.grid-fluid-5 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

@media (max-width: 1200px) {
    .grid-fluid-5 {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    }
}

@media (max-width: 640px) {
    .grid-fluid-5 {
        grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    }
}

@media (max-width: 480px) {
    .dashboard-nav-tabs {
        flex-direction: column !important;
        border-radius: 0.75rem !important;
        gap: 0.25rem !important;
    }
    .dashboard-nav-link {
        width: 100% !important;
        text-align: center !important;
    }
}

input,
textarea,
select {
    width: 100%;
    padding: 0.85rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 0.6rem;
    color: var(--text-main);
    font-size: 0.95rem;
    margin-bottom: 0.5rem;
    transition: all 0.2s;
}

/* Date picker specific polish */
input[type="date"]::-webkit-calendar-picker-indicator {
    filter: invert(1);
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.2s;
}

input[type="date"]::-webkit-calendar-picker-indicator:hover {
    opacity: 1;
}

input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--primary);
    background: var(--bg-card);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

select option {
    background-color: var(--bg-card);
    color: var(--text-main);
    padding: 10px;
}

label {
    display: block;
    font-size: 0.825rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Header & Nav REFACTORED */
.top-header {
    height: var(--header-height);
    background: var(--glass-bg);
    backdrop-filter: blur(var(--glass-blur));
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 2000;
    padding: 0 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    max-width: 100vw;
    overflow: visible;
}

.top-header-left {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    flex: 1;
    min-width: 0;
}

.header-logo-section {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-right: 1.5rem;
    flex-shrink: 0;
}

.top-header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-shrink: 0;
}

@media (max-width: 640px) {
    .top-header-right { gap: 0.5rem; }
    .header-logo-section { margin-right: 0.5rem; gap: 0.5rem; }
    .responsive-search-wrap { max-width: 120px; }
}

@media (max-width: 1700px) {
    /* Support for 1680x1050 and similar high-res laptop displays */
    .top-header-left { gap: 1rem; }
    .top-header-right { gap: 0.75rem; }
    .header-logo-section { margin-right: 1rem; }
    .top-header { padding: 0 1rem; }
}

@media (max-width: 1600px) {
    .top-header-left { gap: 0.75rem; }
    .header-nav { margin-right: 0.75rem; }
    .responsive-search-wrap { max-width: 200px; }
}

/* Kanban / Command Board Responsive Header */
.command-board-header {
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 2rem;
    flex-wrap: nowrap;
    transition: all 0.3s ease;
}

.header-action-group {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-shrink: 0;
}

@media (max-width: 1600px) {
    .command-board-header { padding: 1rem; gap: 1rem; }
    .header-action-group { gap: 0.75rem; }
}

@media (max-width: 1366px) {
    .command-board-header { flex-direction: column; align-items: flex-start; gap: 1rem; }
    .header-action-group { width: 100%; justify-content: space-between; }
}

.top-header input {
    margin-bottom: 0;
    border-radius: 2rem;
    background: var(--bg-main);
    border: 1px solid var(--border);
    font-size: 0.85rem;
    transition: all 0.3s ease;
}

.top-header input:focus {
    background: var(--bg-card);
}

@media (max-width: 768px) {
    /* Kept for backwards compatibility if needed */
}

.responsive-search-wrap {
    position: relative;
    flex: 1;
    width: 100%;
    max-width: 320px;
    min-width: 150px;
    transition: max-width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.header-spacer {
    display: block;
}

.header-nav {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: nowrap;
    margin-right: 1.5rem;
}
.header-nav-item {
    padding: 0.5rem 0.85rem;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 600;
    border-radius: 0.5rem;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    white-space: nowrap;
}

.header-nav-item:hover {
    background: hsla(var(--p-h), var(--p-s), var(--p-l), 0.05);
    color: var(--primary);
    transform: translateY(-1px);
}

.header-nav-item.active {
    background: hsla(var(--p-h), var(--p-s), var(--p-l), 0.1);
    color: var(--primary);
}

@media (min-width: 1441px) {
    .header-nav {
        gap: 1.5rem !important;
        flex-wrap: nowrap !important;
    }
    .header-nav-item {
        padding: 0.6rem 1rem;
        font-size: 0.95rem;
    }
}

@media (max-width: 1536px) {
    /* 15.6" Laptop / High Scaling protection */
    .header-nav { gap: 0.5rem !important; }
    .header-nav-item { padding: 0.5rem 0.75rem; font-size: 0.85rem; }
    .responsive-hide-text { display: none !important; }
    .header-logo-section a span { font-size: 1rem !important; }
}

@media (max-width: 1440px) {
    /* Hide nav text for standard laptop widths */
    .header-nav-item { padding: 0.5rem; font-size: 1.1rem !important; }
    .header-nav-item i { margin: 0 !important; }
    /* Visual trick: icon only mode */
    .header-nav-item {
        width: 42px;
        height: 42px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    .header-nav-item {
        color: transparent; /* Hide text but keep icon */
        text-indent: -9999px; /* Fallback */
        position: relative;
    }
    .header-nav-item i {
        color: var(--text-muted);
        text-indent: 0;
        position: absolute;
        left: 50%;
        top: 50%;
        transform: translate(-50%, -50%);
    }
    .header-nav-item.active i { color: var(--primary); }
    .responsive-search-wrap { max-width: 220px; }
}

@media (max-width: 1200px) {
    .header-nav {
        gap: 0.25rem !important;
    }
    .header-nav-item {
        padding: 0.4rem 0.6rem;
        font-size: 0.8rem;
    }
    .responsive-search-wrap {
        max-width: 180px;
    }
}

@media (max-width: 1280px) {
    .desktop-only {
        display: none !important;
    }
    .header-spacer {
        display: none !important;
    }
}

@media (max-width: 1366px) {
    .responsive-hide-text {
        display: none !important;
    }
}

/* Sidebar Navigation Item */
.sidebar-nav-item {
    display: flex !important;
    align-items: center !important;
    gap: 0.75rem !important;
    padding: 0.45rem 1rem !important;
    color: hsla(0, 0%, 100%, 0.5) !important;
    text-decoration: none !important;
    font-size: 0.9rem !important;
    font-weight: 500 !important;
    border-radius: var(--radius-sm) !important;
    margin-bottom: 0 !important;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    width: 100% !important;
    box-sizing: border-box !important;
    position: relative;
}

.sidebar-nav-item i {
    width: 24px;
    text-align: center;
    font-size: 1.1rem;
    flex-shrink: 0;
    transition: transform 0.3s ease;
}

.sidebar-nav-item:hover {
    background: hsla(0, 0%, 100%, 0.05) !important;
    color: hsla(0, 0%, 100%, 0.95) !important;
    padding-left: 1.5rem !important;
}

.sidebar-nav-item:hover i {
    transform: scale(1.15);
}

.sidebar-nav-item.active {
    background: var(--brand-gradient) !important;
    color: white !important;
    box-shadow: 0 8px 20px -6px var(--primary-glow) !important;
    font-weight: 600;
}

body.sidebar-collapsed .sidebar-nav-item.active {
    background: hsla(var(--p-h), var(--p-s), var(--p-l), 0.15) !important;
    color: var(--primary) !important;
    box-shadow: none !important;
    border: 1px solid var(--primary-glow) !important;
}

body.sidebar-collapsed .sidebar-nav-item.active i {
    color: var(--primary) !important;
}

.sidebar-nav-item.active::before {
    content: '';
    position: absolute;
    left: -1.25rem;
    top: 20%;
    height: 60%;
    width: 4px;
    background: var(--primary);
    border-radius: 0 4px 4px 0;
}

/* Cleanup Legacy Nav */
.desktop-nav,
.nav-text {
    display: none !important;
}

/* Standardized Page Headers */
.page-header-standard {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.25rem;
}

.page-header-standard h1 {
    margin: 0;
    font-size: 1.5rem;
    letter-spacing: -1px;
}

.page-header-standard .badge {
    font-size: 0.65rem;
    padding: 0.2rem 0.6rem;
    background: hsla(var(--p-h), var(--p-s), var(--p-l), 0.1);
    color: var(--primary);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-radius: 4px;
}

.page-description-standard {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin: 0;
    line-height: 1.4;
}

/* Dropdown */
.dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-content {
    display: none;
    position: absolute;
    left: 0;
    top: 100%;
    margin-top: 0.5rem;
    min-width: 220px;
    background: var(--bg-card) !important;
    border: 1px solid var(--border) !important;
    border-radius: 0.75rem !important;
    padding: 0.6rem !important;
    box-shadow: var(--shadow-lg);
    z-index: 3000;
}

.dropdown-right .dropdown-content {
    right: 0;
    left: auto;
}

.dropdown:hover .dropdown-content {
    display: block;
}

/* Bridge the gap for hover stability */
.dropdown-content::before {
    content: '';
    position: absolute;
    top: -0.5rem;
    left: 0;
    width: 100%;
    height: 0.5rem;
    background: transparent;
}

/* Sidebar Edit Mode Styles */
.sidebar.is-editing .draggable-nav-item {
    cursor: grab !important;
    border: 1px dashed rgba(255, 255, 255, 0.2);
    position: relative;
    user-select: none;
}

.sidebar.is-editing .sidebar-nav-item:not(.draggable-nav-item)::after {
    display: none !important;
}

.sidebar.is-editing .draggable-nav-item:active {
    cursor: grabbing !important;
}

.sidebar.is-editing .draggable-nav-item::after {
    content: '\f338'; /* FontAwesome drag handle icon */
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    position: absolute;
    right: 1rem;
    opacity: 0.5;
    font-size: 0.8rem;
}

body.sidebar-collapsed .sidebar.is-editing .draggable-nav-item::after {
    display: none !important;
}

.sidebar-sortable-ghost {
    opacity: 0.4;
    background: var(--primary) !important;
}

.sidebar-sortable-chosen {
    border-color: var(--primary) !important;
    background: hsla(var(--p-h), var(--p-s), var(--p-l), 0.1) !important;
}

.dropdown-content a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.8rem 1rem;
    color: var(--text-main);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    border-radius: 0.5rem !important;
    margin: 0.15rem 0 !important;
    transition: all 0.2s;
}

.dropdown-content a:hover {
    background: rgba(242, 101, 34, 0.08) !important;
    color: var(--primary) !important;
    transform: translateX(4px);
}

/* Avatar */
.avatar-circle {
    box-shadow: 0 0 0 2px var(--border);
    transition: 0.3s;
}

.avatar-circle:hover {
    transform: scale(1.1);
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.35rem 0.85rem;
    border-radius: 2rem;
    font-size: 0.7rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    gap: 0.35rem;
}

.badge-primary {
    background: hsla(var(--p-h), var(--p-s), var(--p-l), 0.1);
    color: var(--primary);
    border: 1px solid hsla(var(--p-h), var(--p-s), var(--p-l), 0.1);
}

.badge-success {
    background: hsla(142, 70%, 50%, 0.1);
    color: #10b981;
    border: 1px solid hsla(142, 70%, 50%, 0.1);
}

.badge-warning {
    background: hsla(38, 92%, 50%, 0.1);
    color: #00A5CF;
    border: 1px solid hsla(38, 92%, 50%, 0.1);
}

.badge-danger {
    background: hsla(0, 84%, 60%, 0.1);
    color: #ef4444;
    border: 1px solid hsla(0, 84%, 60%, 0.1);
}

/* Animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideInDown {
    from {
        transform: translateY(-20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.animate-fade-in {
    animation: fadeIn 0.4s ease-out;
}

/* ============================================================
   GLOBAL MICRO-ANIMATIONS & PHASE 3 UTILITIES
   ============================================================ */

/* Stagger fade-in for lists */
.animate-stagger>*:nth-child(1) {
    animation: fadeInUp 0.5s 0.05s cubic-bezier(0.22, 1, 0.36, 1) forwards;
    opacity: 0;
}

.animate-stagger>*:nth-child(2) {
    animation: fadeInUp 0.5s 0.10s cubic-bezier(0.22, 1, 0.36, 1) forwards;
    opacity: 0;
}

.animate-stagger>*:nth-child(3) {
    animation: fadeInUp 0.5s 0.15s cubic-bezier(0.22, 1, 0.36, 1) forwards;
    opacity: 0;
}

.animate-stagger>*:nth-child(4) {
    animation: fadeInUp 0.5s 0.20s cubic-bezier(0.22, 1, 0.36, 1) forwards;
    opacity: 0;
}

.animate-stagger>*:nth-child(5) {
    animation: fadeInUp 0.5s 0.25s cubic-bezier(0.22, 1, 0.36, 1) forwards;
    opacity: 0;
}

.animate-stagger>*:nth-child(6) {
    animation: fadeInUp 0.5s 0.30s cubic-bezier(0.22, 1, 0.36, 1) forwards;
    opacity: 0;
}

.animate-stagger>*:nth-child(n+7) {
    animation: fadeInUp 0.5s 0.35s cubic-bezier(0.22, 1, 0.36, 1) forwards;
    opacity: 0;
}

/* Slide-in from left (sidebar panels) */
@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.animate-slide-left {
    animation: slideInLeft 0.5s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

/* Scale-in (modals, cards appearing) */
@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.94);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.animate-scale-in {
    animation: scaleIn 0.35s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

/* Pulse glow for active/selected elements */
@keyframes pulseGlow {

    0%,
    100% {
        box-shadow: 0 0 0 0 var(--primary-glow);
    }

    50% {
        box-shadow: 0 0 0 8px transparent;
    }
}

.animate-pulse-glow {
    animation: pulseGlow 2s ease infinite;
}

/* Skeleton Shimmer */
.skeleton {
    background: linear-gradient(90deg,
            rgba(255, 255, 255, 0.03) 25%,
            rgba(255, 255, 255, 0.08) 37%,
            rgba(255, 255, 255, 0.03) 63%);
    background-size: 400% 100%;
    animation: skeleton-loading 1.4s ease infinite;
    border-radius: var(--radius-sm);
    color: transparent !important;
    pointer-events: none;
    user-select: none;
}

[data-theme="light"] .skeleton {
    background: linear-gradient(90deg,
            rgba(0, 0, 0, 0.03) 25%,
            rgba(0, 0, 0, 0.08) 37%,
            rgba(0, 0, 0, 0.03) 63%);
    background-size: 400% 100%;
}

@keyframes skeleton-loading {
    0% {
        background-position: 100% 50%;
    }

    100% {
        background-position: 0% 50%;
    }
}

/* Empty State Polish */
.empty-state-illust {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 2rem;
    text-align: center;
    opacity: 0.6;
}

.empty-state-illust i {
    font-size: 3rem;
    margin-bottom: 1.25rem;
    background: linear-gradient(135deg, var(--text-muted), var(--primary));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* ---- Shared Settings Input System ---- */
.input-container {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.settings-label {
    display: block;
    font-size: 0.78rem;
    font-weight: 800;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin-bottom: 0.6rem;
}

.settings-input {
    width: 100%;
    padding: 0.9rem 1.25rem;
    background: hsla(222, 47%, 5%, 0.35);
    border: 1px solid var(--border);
    color: var(--text-main);
    border-radius: 0.9rem;
    font-size: 0.95rem;
    font-weight: 500;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    margin-bottom: 0;
}

.settings-input:focus {
    outline: none;
    border-color: var(--primary);
    background: hsla(222, 47%, 8%, 0.55);
    box-shadow: 0 0 0 4px hsla(var(--p-h), var(--p-s), var(--p-l), 0.12);
}

/* Light mode overrides for settings inputs */
[data-theme="light"] .settings-input,
:root:not([data-theme="dark"]) .settings-input {
    background: var(--glass-bg-subtle);
}

/* ---- Modern Search Box ---- */
.search-box-modern {
    position: relative;
    min-width: 260px;
}

.search-box-modern i {
    position: absolute;
    left: 1.1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
    font-size: 0.9rem;
    transition: color 0.3s;
}

.search-box-modern input {
    width: 100%;
    padding: 0.8rem 1rem 0.8rem 2.75rem;
    background: var(--glass-bg-subtle);
    border: 1px solid var(--border);
    border-radius: 0.85rem;
    color: var(--text-main);
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.3s;
    margin-bottom: 0;
}

.search-box-modern input:focus {
    outline: none;
    border-color: var(--primary);
    background: var(--glass-bg-heavy);
    box-shadow: 0 0 0 4px hsla(var(--p-h), var(--p-s), var(--p-l), 0.12);
}

.search-box-modern input:focus+i,
.search-box-modern input:focus~i,
.search-box-modern:focus-within i {
    color: var(--primary);
}

/* ---- Stat Card Modern (Phase 3) ---- */
.stat-card-modern {
    padding: 1.75rem 2rem;
    display: flex;
    align-items: center;
    gap: 1.5rem;
    transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.stat-card-modern:hover {
    transform: translateY(-5px);
    border-color: var(--accent, var(--primary-glow));
    box-shadow: 0 12px 32px hsla(0, 0%, 0%, 0.18);
}

.stat-icon-modern {
    width: 56px;
    height: 56px;
    border-radius: 14px;
    background: hsla(222, 47%, 12%, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    color: var(--accent, var(--primary));
    border: 1px solid var(--border);
    flex-shrink: 0;
    transition: all 0.3s;
}

.stat-card-modern:hover .stat-icon-modern {
    transform: scale(1.1) rotate(-5deg);
    box-shadow: 0 4px 20px hsla(var(--p-h), var(--p-s), var(--p-l), 0.25);
}

.stat-info-modern {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.stat-info-modern .stat-label {
    font-size: 0.78rem;
    font-weight: 800;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin-bottom: 0;
}

.stat-info-modern .stat-value {
    font-size: 2.2rem;
    font-weight: 900;
    letter-spacing: -2px;
    line-height: 1;
    color: var(--text-main);
}

/* ---- Empty State ---- */
.empty-icon-ring {
    width: 110px;
    height: 110px;
    border-radius: 50%;
    border: 2px dashed var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 0.5rem;
    font-size: 2.5rem;
    color: var(--text-muted);
    opacity: 0.4;
    animation: rotateSlow 30s linear infinite;
}

@keyframes rotateSlow {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

/* ---- Signal Toggles (Notifications) ---- */
.signal-item {
    display: flex;
    align-items: flex-start;
    gap: 1.25rem;
    padding: 1.5rem;
    background: hsla(222, 47%, 8%, 0.3);
    border: 1px solid var(--border);
    border-radius: 1rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.signal-item:hover {
    background: hsla(222, 47%, 12%, 0.5);
    border-color: var(--primary-glow);
    transform: translateX(4px);
}

.signal-icon {
    width: 46px;
    height: 46px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    flex-shrink: 0;
}

/* ---- Toggle Switch ---- */
.toggle-switch {
    position: relative;
    width: 52px;
    height: 28px;
    flex-shrink: 0;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
    margin: 0;
    position: absolute;
}

.toggle-track {
    position: absolute;
    inset: 0;
    background: var(--border);
    border-radius: 100px;
    cursor: pointer;
    transition: background 0.3s;
    border: 1px solid var(--border);
}

.toggle-track::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: white;
    top: 3px;
    left: 3px;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.toggle-switch input:checked~.toggle-track {
    background: var(--primary);
    border-color: var(--primary);
}

.toggle-switch input:checked~.toggle-track::after {
    transform: translateX(24px);
}

/* ---- Interactive Card Lift ---- */
.card-lift {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1),
        box-shadow 0.3s ease,
        border-color 0.3s ease;
}

.card-lift:hover {
    transform: translateY(-6px);
    box-shadow: 0 20px 40px -10px rgba(0, 0, 0, 0.2);
    border-color: var(--primary-glow);
}

/* ---- Scroll-Triggered Fade ---- */
.fade-up {
    opacity: 0;
    transform: translateY(24px);
    transition: opacity 0.6s cubic-bezier(0.22, 1, 0.36, 1),
        transform 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}

.fade-up.is-visible {
    opacity: 1;
    transform: translateY(0);
}

/* ---- Global Button Micro-interaction ---- */
.btn {
    position: relative;
    overflow: hidden;
}

.btn::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.15);
    opacity: 0;
    transition: opacity 0.2s;
    border-radius: inherit;
}

.btn:active::after {
    opacity: 1;
}

/* ---- Skeleton Loading ---- */
@keyframes shimmer {
    0% {
        background-position: -200% 0;
    }

    100% {
        background-position: 200% 0;
    }
}

.skeleton {
    background: linear-gradient(90deg,
            var(--bg-card) 25%,
            hsla(222, 47%, 15%, 0.5) 50%,
            var(--bg-card) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.8s infinite;
    border-radius: var(--radius-sm);
}

/* ---- Notification Badge Pulse ---- */
.badge-pulse {
    position: relative;
}

.badge-pulse::before {
    content: '';
    position: absolute;
    inset: -3px;
    border-radius: inherit;
    background: var(--primary);
    opacity: 0;
    animation: pulseBadge 2.5s ease infinite;
    z-index: -1;
}

@keyframes pulseBadge {

    0%,
    100% {
        transform: scale(1);
        opacity: 0;
    }

    50% {
        transform: scale(1.4);
        opacity: 0.25;
    }
}

/* ---- Focus-visible global ring ---- */
:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 3px;
    border-radius: var(--radius-sm);
}

/* ---- Scroll reveal utility (JS hook) ---- */
[data-reveal] {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.6s cubic-bezier(0.22, 1, 0.36, 1),
        transform 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}

[data-reveal].revealed {
    opacity: 1;
    transform: translateY(0);
}

/* ============================================================
   B2: DARK / LIGHT MODE CROSS-FADE TRANSITION
   ============================================================ */

/* Apply smooth transitions on theme vars for all elements.
   We exclude 'transform' & 'opacity' to avoid fighting with
   animation keyframes, and use will-change hint only on body. */
body {
    will-change: background-color, color;
}

[data-theme-transitioning],
[data-theme-transitioning] *,
[data-theme-transitioning] *::before,
[data-theme-transitioning] *::after {
    transition:
        background-color 0.45s cubic-bezier(0.4, 0, 0.2, 1),
        border-color 0.45s cubic-bezier(0.4, 0, 0.2, 1),
        color 0.4s ease,
        box-shadow 0.45s ease !important;
}

/* Theme toggle button — FA icon version */
#theme-toggle {
    width: 40px;
    height: 40px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    overflow: hidden;
    position: relative;
}

#theme-toggle .theme-icon-wrap {
    position: relative;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#theme-toggle .ti-moon,
#theme-toggle .ti-sun {
    position: absolute;
    font-size: 1rem;
    transition: opacity 0.35s ease, transform 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}

#theme-toggle .ti-moon {
    opacity: 1;
    transform: rotate(0deg) scale(1);
    color: #a5b4fc;
}

#theme-toggle .ti-sun {
    opacity: 0;
    transform: rotate(-90deg) scale(0.5);
    color: #00A5CF;
}

[data-theme="dark"] #theme-toggle .ti-moon {
    opacity: 0;
    transform: rotate(90deg) scale(0.5);
}

[data-theme="dark"] #theme-toggle .ti-sun {
    opacity: 1;
    transform: rotate(0deg) scale(1);
}

/* Spin animation on click */
@keyframes themeSpin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

#theme-toggle.spinning .theme-icon-wrap {
    animation: themeSpin 0.45s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============================================================
   B1: RESPONSIVE / MOBILE PASS  (≤ 768px)
   ============================================================ */

/* -- Sidebar overlay backdrop -- */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(3px);
    z-index: 2999;
    transition: opacity 0.3s ease;
    opacity: 0;
}

.sidebar-open .sidebar-overlay {
    display: block;
    opacity: 1;
}

@media (max-width: 768px) {

    /* Show hamburger toggle button */
    #sidebar-toggle {
        display: flex !important;
    }

    /* Sidebar hidden off-screen on mobile */
    .sidebar {
        transform: translateX(-100%) !important;
        z-index: 3000 !important;
    }

    /* Sidebar slides in when open */
    .sidebar-open .sidebar {
        transform: translateX(0) !important;
        box-shadow: 0 0 60px rgba(0, 0, 0, 0.5);
    }

    /* No left margin on mobile */
    .main-content {
        margin-left: 0 !important;
        padding-top: 0 !important;
    }

    /* Header: tighter padding, wrap if needed */
    .top-header {
        padding: 0 1rem !important;
        height: auto !important;
        min-height: var(--header-height);
        flex-wrap: wrap;
        gap: 0.5rem;
        margin-bottom: 1.5rem !important;
    }

    /* Collapse search bar on mobile — show icon only, expand on focus */
    #global-search-wrap {
        width: 160px !important;
        transition: width 0.3s ease;
    }

    #global-search-wrap:focus-within {
        width: 260px !important;
    }

    /* Quick action — hide text label, icon only */
    .top-header .btn-primary span.qa-label {
        display: none;
    }

    /* Tighter container padding */
    .container {
        padding: 1rem !important;
    }

    /* Stack command-header flex rows */
    [class*="command-header"],
    .page-header-row {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 1rem !important;
    }

    /* All grid variants → single column */
    .grid-4,
    .grid-3,
    .grid-2 {
        grid-template-columns: 1fr !important;
    }

    /* Stat cards: slightly reduced padding */
    .stat-card-modern {
        padding: 1.25rem 1.5rem;
        gap: 1rem;
    }

    .stat-info-modern .stat-value {
        font-size: 1.75rem !important;
    }

    /* h1 font size floor on very small screens */
    h1 {
        font-size: clamp(1.4rem, 5vw, 2rem) !important;
    }

    /* Attendance button: shrink on mobile */
    #attendance-text {
        display: none;
    }

    /* Notification drawer: full width on mobile */
    #notif-drawer {
        width: calc(100vw - 2rem) !important;
        right: -1rem !important;
    }

    /* Global search results: full width */
    #gs-results {
        width: calc(100vw - 2rem) !important;
        max-width: none !important;
    }

    /* Cards: reduce padding */
    .card {
        padding: 1.25rem !important;
    }

    /* Tables: allow horizontal scroll */
    .table-responsive-wrap {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
}

/* ============================================================
   B2: SMOOTH THEME TRANSITION ANIMATION
   Applies a 400ms cross-fade to all colour-carrying surfaces
   so the dark ↔ light switch feels polished, not jarring.
   ============================================================ */

/* Opt every element into colour transitions (NOT layout props) */
*,
*::before,
*::after {
    transition-property: background-color, border-color, color, fill, stroke, box-shadow, opacity;
    transition-duration: 0.4s;
    transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
}

/* Exempt elements where transitions would hurt performance or UX */
*[class*="animate-"],
.kanban-task,
.sidebar-nav-item,
.modal-overlay {
    transition: none !important;
}

.modal {
    position: fixed;
    inset: 0;
    z-index: 4000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(6px);
    transition: all 0.3s ease;
}

.modal.active {
    display: flex !important;
}

.modal-content {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    box-shadow: var(--shadow-lg);
    padding: 0;
    animation: modalScaleUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modalScaleUp {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(10px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.modal-header {
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    margin: 0;
    font-size: 1.25rem;
}

.modal-close {
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
    transition: color 0.2s;
}

.modal-close:hover {
    color: var(--primary);
}

.modal-body {
    padding: 2.5rem;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
}

.form-full {
    grid-column: 1 / -1;
}

.form-group {
    margin-bottom: 1.25rem;
}

.form-control {
    width: 100%;
    padding: 0.75rem 1rem;
    background: hsla(222, 47%, 95%, 0.3);
    border: 1px solid var(--border);
    border-radius: 0.6rem;
    color: var(--text-main);
    font-size: 0.95rem;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] .form-control {
    background: rgba(15, 23, 42, 0.3);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    background: var(--bg-card);
    box-shadow: 0 0 0 4px var(--primary-glow);
}

.btn-primary {
    background: var(--brand-gradient);
    border: none;
    box-shadow: 0 4px 15px var(--primary-glow);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px var(--primary-glow);
}

.modal-footer {
    padding: 1.5rem 2rem;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    background: hsla(var(--h), 20%, 98%, 0.5);
}

[data-theme="dark"] .modal-footer {
    background: hsla(222, 47%, 8%, 0.3);
}

/* ── Theme Toggle Button ── */
#theme-toggle {
    position: relative;
    overflow: hidden;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    padding: 0;
    border: 1px solid var(--border);
    background: hsla(var(--h), 20%, 90%, 0.15);
    transition: background 0.3s, border-color 0.3s, transform 0.3s !important;
}

#theme-toggle:hover {
    background: hsla(var(--p-h), var(--p-s), var(--p-l), 0.1);
    border-color: var(--primary-glow);
    transform: scale(1.1);
}

/* Icon container */
.theme-icon-wrap {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

/* Both icons stacked; only the contextual one shows */
.theme-icon-wrap .ti-moon,
.theme-icon-wrap .ti-sun {
    position: absolute;
    font-size: 1rem;
    transition: opacity 0.3s ease, transform 0.4s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

/* Light mode → show moon */
:root:not([data-theme="dark"]) .ti-moon {
    opacity: 1;
    transform: rotate(0deg) scale(1);
}

:root:not([data-theme="dark"]) .ti-sun {
    opacity: 0;
    transform: rotate(90deg) scale(0.5);
}

/* Dark mode → show sun */
[data-theme="dark"] .ti-moon {
    opacity: 0;
    transform: rotate(-90deg) scale(0.5);
}

[data-theme="dark"] .ti-sun {
    opacity: 1;
    transform: rotate(0deg) scale(1);
}

/* Spin animation fired by JS (class="spinning") */
@keyframes themeSpin {
    0% {
        transform: rotate(0deg) scale(0.8);
    }

    50% {
        transform: rotate(180deg) scale(1.15);
    }

    100% {
        transform: rotate(360deg) scale(1);
    }
}

#theme-toggle.spinning .theme-icon-wrap {
    animation: themeSpin 0.5s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

/* ── Full-page colour wash overlay on theme change ── */
/* Triggered by JS: html[data-theme-transitioning] */
[data-theme-transitioning]::after {
    content: '';
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 99999;
    background: var(--bg-main);
    opacity: 0;
    animation: themeWash 0.45s ease forwards;
}

@keyframes themeWash {
    0% {
        opacity: 0.18;
    }

    100% {
        opacity: 0;
    }
}

/* ============================================================
   B1: RESPONSIVE / MOBILE PASS
   ============================================================ */

/* ── Sidebar overlay backdrop ── */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(3px);
    z-index: 2999;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sidebar-open .sidebar-overlay {
    display: block;
    opacity: 1;
}

/* ── Top header sticky fix on mobile ── */
@media (max-width: 1024px) {
    .top-header {
        position: fixed !important;
        top: 0;
        left: 0;
        right: 0;
        z-index: 2500;
        padding: 0 1.25rem;
    }

    /* Show hamburger toggle button */
    #sidebar-toggle {
        display: flex !important;
    }

    /* Collapse global search on mobile */
    #global-search-wrap {
        width: 200px !important;
    }

    /* Tighten quick action area */
    .top-header .btn-primary span,
    .top-header .btn span {
        display: none;
    }
}

@media (max-width: 640px) {

    /* Fully collapse search on small screens */
    #global-search-wrap {
        width: 140px !important;
    }

    /* Hide attendance widget */
    #attendance-status-widget {
        display: none;
    }

    /* Make modals full-screen on small phones */
    .res-modal-box {
        max-width: 100% !important;
        border-radius: 0 !important;
        height: 100vh;
        overflow-y: auto;
    }
}

/* ── Card-stack tables on mobile ── */
@media (max-width: 640px) {

    /* For tables with class table-stack or inside .table-responsive-wrap */
    .table-responsive-wrap table,
    .table-responsive-wrap thead,
    .table-responsive-wrap tbody,
    .table-responsive-wrap th,
    .table-responsive-wrap td,
    .table-responsive-wrap tr {
        display: block;
    }

    .table-responsive-wrap thead {
        display: none;
        /* Hide header row — labels come from data-label */
    }

    .table-responsive-wrap tbody tr {
        background: var(--bg-card);
        border: 1px solid var(--border);
        border-radius: var(--radius-sm);
        margin-bottom: 0.85rem;
        padding: 0.5rem 0;
    }

    .table-responsive-wrap tbody td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0.5rem 1rem;
        border: none;
        border-bottom: 1px solid var(--border);
        font-size: 0.875rem;
    }

    .table-responsive-wrap tbody td:last-child {
        border-bottom: none;
    }

    /* Show column label from data-label attr */
    .table-responsive-wrap tbody td::before {
        content: attr(data-label);
        font-size: 0.7rem;
        font-weight: 800;
        color: var(--text-muted);
        text-transform: uppercase;
        letter-spacing: 0.05em;
        flex-shrink: 0;
        margin-right: 1rem;
    }
}

/* ── Kanban: horizontal scroll on small screens ── */
@media (max-width: 900px) {
    .kanban-scroller {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
    }

    .kanban-grid {
        min-width: 900px !important;
    }
}

/* Page Layout Standardization */
.page-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 1.5rem 4rem;
    width: 100%;
}

@media (max-width: 1440px) {
    .page-container {
        max-width: 100%;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════
   Skeleton Loading System
   ═══════════════════════════════════════════════════════════════════════════ */

@keyframes skeleton-shimmer {
    0% { background-position: -400px 0; }
    100% { background-position: 400px 0; }
}

@keyframes skeleton-fade-in {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Base skeleton element */
.skeleton {
    background: linear-gradient(
        90deg,
        var(--glass-bg-heavy) 25%,
        var(--glass-bg-subtle) 37%,
        var(--glass-bg-heavy) 63%
    );
    background-size: 800px 100%;
    animation: skeleton-shimmer 1.8s ease-in-out infinite;
    border-radius: var(--radius-sm);
    position: relative;
    overflow: hidden;
}

/* Text line placeholder */
.skeleton-text {
    height: 0.85rem;
    margin-bottom: 0.6rem;
    border-radius: 4px;
    width: 100%;
}

.skeleton-text.w-75 { width: 75%; }
.skeleton-text.w-50 { width: 50%; }
.skeleton-text.w-33 { width: 33%; }
.skeleton-text.w-25 { width: 25%; }

/* Heading placeholder */
.skeleton-heading {
    height: 1.5rem;
    margin-bottom: 1rem;
    border-radius: 6px;
    width: 60%;
}

/* Avatar circle */
.skeleton-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    flex-shrink: 0;
}

.skeleton-avatar.lg { width: 56px; height: 56px; }
.skeleton-avatar.sm { width: 28px; height: 28px; }

/* Badge/chip */
.skeleton-badge {
    height: 1.5rem;
    width: 5rem;
    border-radius: 2rem;
    display: inline-block;
}

/* Button placeholder */
.skeleton-btn {
    height: 2.5rem;
    width: 8rem;
    border-radius: var(--radius-md);
}

/* Full card skeleton */
.skeleton-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Stat KPI skeleton */
.skeleton-stat {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    min-height: 100px;
}

.skeleton-stat .skeleton-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    margin-bottom: 1rem;
}

.skeleton-stat .skeleton-number {
    height: 2rem;
    width: 5rem;
    border-radius: 6px;
    margin-bottom: 0.5rem;
}

/* Kanban column skeleton */
.skeleton-kanban-col {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1rem;
    min-width: 280px;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.skeleton-kanban-col .skeleton-col-header {
    height: 1.25rem;
    width: 60%;
    border-radius: 4px;
    margin-bottom: 0.5rem;
}

.skeleton-kanban-card {
    background: var(--glass-bg-subtle);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

/* Table row skeleton */
.skeleton-table-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 0;
    border-bottom: 1px solid var(--border);
}

.skeleton-table-row .skeleton-cell {
    height: 0.85rem;
    border-radius: 4px;
    flex: 1;
}

.skeleton-table-row .skeleton-cell:first-child { flex: 2; }

/* Container that auto-hides skeletons when content loads */
.skeleton-container {
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.skeleton-container.loaded {
    display: none !important;
}

/* Content that fades in after skeleton hides */
.content-loaded {
    animation: skeleton-fade-in 0.4s ease forwards;
}

/* Dark mode adjustments */
[data-theme="dark"] .skeleton {
    background: linear-gradient(
        90deg,
        hsla(222, 47%, 15%, 0.8) 25%,
        hsla(222, 47%, 22%, 0.6) 37%,
        hsla(222, 47%, 15%, 0.8) 63%
    );
    background-size: 800px 100%;
}

/* ═══════════════════════════════════════════════════════════════════════════
   @Mentions System
   ═══════════════════════════════════════════════════════════════════════════ */

.mention-tag {
    background: hsla(var(--p-h), var(--p-s), var(--p-l), 0.15);
    color: var(--primary);
    padding: 0.1rem 0.35rem;
    border-radius: 4px;
    font-weight: 700;
    font-size: 0.85em;
    cursor: default;
}

.mention-item {
    transition: background 0.15s ease;
}

.mention-item:hover,
.mention-active {
    background: hsla(var(--p-h), var(--p-s), var(--p-l), 0.12) !important;
}

.mentions-dropdown::-webkit-scrollbar { width: 4px; }
.mentions-dropdown::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 2px;
}
/* --- Z-Index Priority Overrides --- */
.top-header {
    z-index: 99999 !important;
}
.dropdown-content, 
#notif-drawer, 
#gs-results {
    z-index: 100000 !important;
}
.dropdown-content.show-dropdown {
    display: block !important;
}
/* Guarantee DHTMLX Gantt stays pushed beneath Header */
.gantt-container {
    position: relative;
    z-index: 1;
}

@media (max-width: 1024px) {
    .nav-text { display: none; }
    .btn-ghost i { margin-right: 0 !important; font-size: 1.1rem; }
}

@media (max-width: 640px) {
    .desktop-nav { display: none !important; }
}
