:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #eef2ff;
    --secondary: #64748b;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;
    --background: #f8fafc;
    --surface: #ffffff;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --sidebar-width: 260px;
    --radius: 12px;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--background);
    color: var(--text-main);
    line-height: 1.5;
    min-height: 100vh;
}

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

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

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

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

/* Sidebar */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: linear-gradient(180deg, #1e1b4b 0%, #312e81 100%);
    padding: 24px 16px;
    color: white;
    z-index: 100;
    transition: all 0.3s ease;
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 40px;
    padding: 0 12px;
}

.sidebar-header .logo {
    width: 40px;
    height: 40px;
    background: var(--primary);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 20px;
    box-shadow: 0 0 20px rgba(99, 102, 241, 0.4);
}

.sidebar-header h1 {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.nav-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 14px 16px;
    border-radius: 12px;
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-weight: 500;
    font-size: 15px;
    margin-bottom: 4px;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    transform: translateX(4px);
}

.nav-item.active {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
    font-weight: 600;
}

.nav-item svg {
    width: 22px;
    height: 22px;
    margin-right: 14px;
    opacity: 0.8;
    transition: transform 0.3s ease;
}

.nav-item:hover svg {
    transform: scale(1.1);
}

.nav-item.active svg {
    opacity: 1;
}

.btn-danger:hover .logout-icon {
    transform: translateX(4px);
}

/* Main Content */
.main-content {
    margin-left: var(--sidebar-width);
    padding: 32px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Collapsed Sidebar Styles */
body.sidebar-collapsed .sidebar {
    width: 80px;
}

body.sidebar-collapsed .sidebar-header {
    margin-bottom: 24px;
    justify-content: center !important;
    padding: 0 !important;
}

body.sidebar-collapsed .sidebar-header img {
    width: 48px !important;
    height: 48px !important;
}

body.sidebar-collapsed .sidebar-header div {
    display: none;
}

body.sidebar-collapsed .nav-item span {
    display: none;
}

body.sidebar-collapsed .nav-item {
    justify-content: center;
    padding: 14px 0;
}

body.sidebar-collapsed .nav-item svg {
    margin-right: 0;
}

body.sidebar-collapsed .sidebar > div:last-child button span {
    display: none;
}

body.sidebar-collapsed .sidebar > div:last-child button {
    justify-content: center !important;
    padding: 12px 0;
}

body.sidebar-collapsed .sidebar > div:last-child button svg {
    margin-right: 0 !important;
}

body.sidebar-collapsed .main-content {
    margin-left: 80px;
}

/* Top Bar */
.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 32px;
}

.search-box {
    position: relative;
    width: 400px;
}

.search-box input {
    width: 100%;
    padding: 12px 16px 12px 48px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    outline: none;
    transition: all 0.2s ease;
    font-size: 14px;
}

.search-box input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--primary-light);
}

.search-box svg {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.top-bar-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
}

.top-refresh-btn {
    background: var(--bg-surface, #ffffff) !important;
    border: 1px solid var(--border, #e2e8f0) !important;
    color: var(--text-main, #0f172a) !important;
    width: 40px !important;
    height: 40px !important;
    border-radius: 50% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 0 !important;
    min-width: auto !important;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05) !important;
    cursor: pointer;
    transition: all 0.2s ease;
}

.top-refresh-btn:hover {
    background: var(--primary-light, #f0fdf4) !important;
    color: var(--primary, #22c55e) !important;
    border-color: var(--primary-light, #f0fdf4) !important;
    transform: rotate(30deg);
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 24px;
    margin-bottom: 32px;
}

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

.mini-stat-card {
    background: linear-gradient(135deg, #ffffff 0%, #f8faff 100%);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 18px 20px;
    box-shadow: var(--shadow);
}

.mini-stat-label {
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 10px;
}

.mini-stat-value {
    color: var(--text-main);
    font-size: 26px;
    font-weight: 700;
}

.insight-row {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 0;
    border-bottom: 1px solid var(--border);
}

.insight-row:last-child {
    border-bottom: none;
}

.stat-card {
    background: var(--surface);
    padding: 24px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

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

.stat-card .icon-wrapper {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
}

.stat-card.blue .icon-wrapper {
    background: #dbeafe;
    color: #3b82f6;
}

.stat-card.green .icon-wrapper {
    background: #dcfce7;
    color: #10b981;
}

.stat-card.yellow .icon-wrapper {
    background: #fef3c7;
    color: #f59e0b;
}

.stat-card.purple .icon-wrapper {
    background: #f3e8ff;
    color: #a855f7;
}

.stat-card h3 {
    font-size: 14px;
    color: var(--text-muted);
    font-weight: 500;
    margin-bottom: 8px;
}

.stat-card .value {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 4px;
}

.stat-card .trend {
    font-size: 12px;
    font-weight: 600;
}

.trend.up {
    color: var(--success);
}

.trend.down {
    color: var(--danger);
}

/* Content Cards */
.content-card {
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    overflow: hidden;
}

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

.card-header h2 {
    font-size: 18px;
    font-weight: 600;
}

.card-body {
    padding: 24px;
}

/* Tables */
.table-container {
    width: 100%;
    overflow: auto;
    max-height: calc(100vh - 250px);
}

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

th {
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--background);
    padding: 12px 24px;
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

td {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}

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

tr:hover {
    background: #f8fafc;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    gap: 8px;
}

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

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

.btn-secondary {
    background: white;
    color: var(--text-main);
    border: 1px solid var(--border);
}

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

.btn-danger {
    background: #fee2e2;
    color: var(--danger);
}

.btn-danger:hover {
    background: #fecaca;
}

/* Badges */
.badge {
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
}

.badge-success {
    background: #dcfce7;
    color: #15803d;
}

.badge-warning {
    background: #fef3c7;
    color: #b45309;
}

.badge-danger {
    background: #fee2e2;
    color: #b91c1c;
}

.badge-info {
    background: #dbeafe;
    color: #1d4ed8;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.modal.show {
    display: flex;
    animation: fadeIn 0.2s ease;
}

.modal-content {
    background: white;
    width: 100%;
    max-width: 600px;
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    animation: slideUp 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

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

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

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

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-main);
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    outline: none;
    transition: all 0.2s ease;
}

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

/* Password visibility overlay */
.password-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
}

.password-input-wrapper .form-control {
    padding-right: 42px !important;
}

.password-toggle-btn {
    position: absolute;
    right: 12px;
    background: none;
    border: none;
    padding: 0;
    margin: 0;
    cursor: pointer;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s ease;
    z-index: 5;
}

.password-toggle-btn:hover {
    color: var(--text-main);
}

.login-card .password-toggle-btn {
    color: #94a3b8;
}

.login-card .password-toggle-btn:hover {
    color: #475569;
}

/* Redesigned Whitish Split Login Screen */
.login-page {
    position: relative;
    height: 100vh;
    width: 100vw;
    display: flex;
    background: #f8fafc;
    overflow: hidden;
    font-family: 'Outfit', 'Inter', sans-serif;
}

.login-container {
    display: flex;
    width: 100%;
    height: 100%;
}

/* Left Side: Spacious Branding */
.login-branding {
    flex: 1.2;
    background: linear-gradient(135deg, #eef2ff 0%, #e0e7ff 100%);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 64px;
    position: relative;
    overflow: hidden;
}

.login-branding::before {
    content: '';
    position: absolute;
    width: 300px;
    height: 300px;
    background: rgba(99, 102, 241, 0.05);
    border-radius: 50%;
    top: -50px;
    left: -50px;
}

.login-branding::after {
    content: '';
    position: absolute;
    width: 400px;
    height: 400px;
    background: rgba(236, 72, 153, 0.04);
    border-radius: 50%;
    bottom: -100px;
    right: -100px;
}

.login-branding-content {
    position: relative;
    z-index: 10;
    max-width: 480px;
    text-align: center;
}

.login-logo {
    width: auto;
    height: auto;
    max-height: 80px;
    max-width: 280px;
    object-fit: contain;
    margin-bottom: 32px;
    filter: drop-shadow(0 10px 20px rgba(99, 102, 241, 0.08));
    transition: transform 0.4s ease;
}

.login-logo:hover {
    transform: scale(1.08) rotate(-3deg);
}

.login-branding h1 {
    font-size: 38px;
    font-weight: 800;
    color: #1e1b4b;
    margin-bottom: 16px;
    letter-spacing: -0.5px;
}

.login-branding p {
    font-size: 16px;
    color: #475569;
    line-height: 1.6;
    margin-bottom: 0;
}

/* Right Side: Modern Login Form */
.login-form-side {
    flex: 1;
    background: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 64px;
    box-shadow: -10px 0 30px rgba(0, 0, 0, 0.02);
}

.login-card {
    width: 100%;
    max-width: 400px;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
}

.login-card h2 {
    font-size: 28px;
    font-weight: 700;
    color: #0f172a;
    margin-bottom: 8px;
    text-align: left;
}

.login-card p.login-subtitle {
    font-size: 14px;
    color: #64748b;
    line-height: 1.5;
    margin-bottom: 36px;
    text-align: left;
}

/* Light adjustments for inputs in whitish screen */
.login-card .form-group {
    margin-bottom: 24px;
}

.login-card .form-group label {
    color: #475569;
    font-weight: 600;
    font-size: 13px;
    margin-bottom: 8px;
    letter-spacing: 0;
    text-transform: none;
    display: block;
}

.login-card .form-control {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    color: #0f172a !important;
    padding: 14px 16px;
    border-radius: 12px;
    font-size: 15px;
    transition: all 0.25s ease;
}

.login-card .form-control::placeholder {
    color: #94a3b8;
}

.login-card .form-control:focus {
    background: #ffffff;
    border-color: #6366f1;
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
}

.login-btn {
    width: 100%;
    padding: 14px;
    font-size: 15px;
    font-weight: 600;
    margin-top: 12px;
    background: #6366f1;
    border: none;
    border-radius: 12px;
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.25s ease;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.2);
}

.login-btn:hover {
    background: #4f46e5;
    box-shadow: 0 8px 20px rgba(99, 102, 241, 0.3);
    transform: translateY(-2px);
}

.login-btn:hover svg {
    transform: translateX(4px);
}

.login-btn:active {
    transform: translateY(0);
}

@media (max-width: 900px) {
    .login-branding {
        display: none;
    }
    .login-form-side {
        flex: 1;
        padding: 40px 24px;
    }
}

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

.report-panel-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
}

.report-chart-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.report-metric-card {
    padding: 18px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--background);
}

.report-metric-label {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.report-metric-value {
    font-size: 26px;
    font-weight: 700;
    color: var(--text-main);
}

.report-metric-note {
    margin-top: 8px;
    font-size: 12px;
    color: var(--text-muted);
}

.report-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.report-list-row {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 16px;
    border-radius: 12px;
    background: white;
    border: 1px solid var(--border);
    align-items: center;
}

.report-list-row strong {
    display: block;
    margin-bottom: 4px;
}

.report-list-meta {
    font-size: 12px;
    color: var(--text-muted);
}

.report-list-value {
    font-weight: 700;
    color: var(--text-main);
    white-space: nowrap;
}

.report-chart {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.report-chart-row {
    display: grid;
    grid-template-columns: 120px 1fr auto;
    gap: 12px;
    align-items: center;
}

.report-chart-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-main);
}

.report-chart-track {
    position: relative;
    height: 12px;
    border-radius: 999px;
    background: #e5e7eb;
    overflow: hidden;
}

.report-chart-fill {
    height: 100%;
    border-radius: inherit;
}

.report-chart-fill.blue {
    background: linear-gradient(90deg, #2563eb 0%, #60a5fa 100%);
}

.report-chart-fill.green {
    background: linear-gradient(90deg, #059669 0%, #34d399 100%);
}

.report-chart-fill.orange {
    background: linear-gradient(90deg, #ea580c 0%, #fb923c 100%);
}

.report-chart-fill.slate {
    background: linear-gradient(90deg, #475569 0%, #94a3b8 100%);
}

.report-chart-value {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-main);
    white-space: nowrap;
}

.report-rank-card {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.report-rank-row {
    display: grid;
    grid-template-columns: 28px minmax(0, 1fr);
    gap: 12px;
    align-items: start;
}

.report-rank-index {
    width: 28px;
    height: 28px;
    border-radius: 999px;
    background: var(--primary-light);
    color: var(--primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
}

.report-rank-content {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.report-rank-topline {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: baseline;
}

.report-rank-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-main);
}

.report-rank-subtitle {
    font-size: 12px;
    color: var(--text-muted);
}

.report-rank-metric {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-main);
    white-space: nowrap;
}

/* Utilities */
.hidden {
    display: none !important;
}

/* ================================
   RESPONSIVE — TABLET (≤1024px)
   ================================ */
@media (max-width: 1024px) {
    .sidebar {
        width: 80px;
        padding: 24px 12px;
    }

    .sidebar-header h1,
    .nav-item span {
        display: none;
    }

    .main-content {
        margin-left: 80px;
    }

    .search-box {
        width: 240px;
    }
}

/* ================================
   MOBILE SIDEBAR OVERLAY
   ================================ */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(2px);
    z-index: 199;
    transition: opacity 0.3s ease;
}

/* ================================
   MOBILE (≤768px)
   ================================ */
@media (max-width: 768px) {
    /* --- Sidebar: hidden off-screen by default, slides in as drawer --- */
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        width: 260px !important;
        height: 100vh;
        transform: translateX(-100%);
        z-index: 200;
        padding: 24px 16px;
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

    /* Show span labels in mobile drawer */
    .sidebar-header h1,
    .nav-item span {
        display: block !important;
    }
    .nav-item {
        justify-content: flex-start !important;
        padding: 14px 16px !important;
    }
    .nav-item svg {
        margin-right: 14px !important;
    }

    /* Open state — toggled via JS */
    .sidebar.mobile-open {
        transform: translateX(0);
    }
    body.mobile-sidebar-open .sidebar-overlay {
        display: block;
    }

    /* --- Main content takes full width --- */
    .main-content {
        margin-left: 0 !important;
        padding: 12px !important;
    }

    /* --- Top bar --- */
    .top-bar {
        flex-wrap: nowrap;
        gap: 8px;
        margin-bottom: 16px;
        align-items: center;
    }
    .search-box {
        flex: 1;
        width: auto;
        min-width: 0;
    }
    .search-box input {
        font-size: 13px;
        padding: 10px 12px 10px 40px;
    }
    .top-refresh-btn span {
        display: none;
    }
    .top-refresh-btn {
        min-width: unset;
        padding: 8px 10px;
    }

    /* --- Stats grid: 2 columns on mobile --- */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
        margin-bottom: 16px;
    }

    .insights-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .stat-card {
        padding: 16px;
    }
    .stat-card .value {
        font-size: 22px;
    }
    .stat-card .icon-wrapper {
        width: 36px;
        height: 36px;
        margin-bottom: 10px;
    }

    /* --- Card header: wrap buttons below title --- */
    .card-header {
        flex-wrap: wrap;
        gap: 10px;
        padding: 16px;
    }
    .card-header h2 {
        font-size: 15px;
        flex: 1 1 100%;
    }
    .card-header > div,
    .card-header > button {
        flex-wrap: wrap;
        gap: 6px;
    }
    .card-header .btn {
        font-size: 12px;
        padding: 7px 12px;
    }

    /* --- Card body padding --- */
    .card-body {
        padding: 12px;
    }

    /* --- Tables: horizontal scroll with compact cells --- */
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        border-radius: 8px;
    }
    th {
        padding: 10px 12px;
        font-size: 11px;
        white-space: nowrap;
    }
    td {
        padding: 10px 12px;
        font-size: 13px;
    }

    /* --- Forms: full width --- */
    .form-group {
        margin-bottom: 14px;
    }

    /* --- Modals: full screen on mobile --- */
    .modal {
        padding: 0;
        align-items: flex-end;
    }
    .modal-content {
        max-width: 100%;
        width: 100%;
        border-radius: 20px 20px 0 0;
        max-height: 92vh;
        overflow-y: auto;
    }
    .modal-header {
        padding: 16px 20px;
    }
    .modal-body {
        padding: 16px 20px;
    }
    .modal-footer {
        padding: 12px 20px;
    }

    /* --- Report metric grid: 2-col --- */
    .report-metric-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 10px;
    }
    .report-metric-card {
        padding: 14px;
    }
    .report-metric-value {
        font-size: 22px;
    }

    /* --- Reports analytics charts: stack vertically --- */
    #reportsAnalyticsSection {
        grid-template-columns: 1fr !important;
    }

    /* --- Attendance date filters: stack vertically --- */
    #attendanceTab .card-body > div[style*="flex"],
    #employeesTab .card-body > div[style*="flex"] {
        flex-direction: column !important;
        align-items: stretch !important;
    }
    #attendanceTab .card-body > div[style*="flex"] > div,
    #employeesTab .card-body > div[style*="flex"] > div {
        width: 100% !important;
    }

    /* --- Salary/leave grid sections --- */
    .report-chart-grid,
    .report-panel-grid {
        grid-template-columns: 1fr;
    }

    /* --- Dashboard insights two-col layout --- */
    #dashboardTab > div:last-child {
        grid-template-columns: 1fr !important;
    }

    /* --- Login page: single column on mobile --- */
    .login-branding {
        display: none !important;
    }
    .login-form-side {
        width: 100% !important;
        padding: 24px 16px;
    }
    .login-card {
        padding: 28px 20px;
        border-radius: 16px;
    }
    .login-card h2 {
        font-size: 22px;
    }
    .login-btn {
        padding: 14px;
    }

    /* --- Collapsed sidebar override: never collapse on mobile, always full --- */
    body.sidebar-collapsed .sidebar {
        width: 260px !important;
    }
    body.sidebar-collapsed .sidebar-header div {
        display: block !important;
    }
    body.sidebar-collapsed .nav-item span {
        display: block !important;
    }
    body.sidebar-collapsed .main-content {
        margin-left: 0 !important;
    }
}

/* ================================
   SMALL MOBILE (≤480px)
   ================================ */
@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }
    .insights-grid {
        grid-template-columns: 1fr 1fr;
    }
    .main-content {
        padding: 10px !important;
    }
    .stat-card .value {
        font-size: 20px;
    }
    .report-metric-grid {
        grid-template-columns: 1fr 1fr !important;
    }
    .top-bar {
        gap: 6px;
    }
    .card-header h2 {
        font-size: 14px;
    }
}

/* Hide admin-only controls for employees */
body.role-employee .admin-only-control {
    display: none !important;
}

/* Print layout optimizations for PDF export */
@media print {
    body {
        background: #ffffff !important;
        color: #000000 !important;
    }
    
    /* Hide layout chrome and filter buttons */
    .sidebar, .sidebar-header, .nav-group, header, .top-bar,
    .card-header .btn, .card-header button, .card-header select, .card-header input,
    .top-refresh-btn, .glossary-box, .btn, button, svg {
        display: none !important;
    }
    
    .main-content {
        margin-left: 0 !important;
        padding: 0 !important;
        width: 100% !important;
    }
    
    /* Ensure reports tab is visible and other tabs hidden */
    .hidden {
        display: none !important;
    }
    
    section:not(#reportsTab) {
        display: none !important;
    }
    
    #reportsTab {
        display: block !important;
        width: 100% !important;
        position: absolute !important;
        left: 0 !important;
        top: 0 !important;
    }
    
    .content-card {
        box-shadow: none !important;
        border: none !important;
        padding: 0 !important;
        background: transparent !important;
    }
    
    /* Style charts and metrics nicely for print */
    #reportsAnalyticsSection {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        gap: 16px !important;
        margin-top: 16px !important;
    }
    
    .report-metric-grid {
        grid-template-columns: repeat(4, 1fr) !important;
        gap: 8px !important;
    }
    
    .report-metric-card {
        border: 1px solid #cbd5e1 !important;
        background: #f8fafc !important;
        padding: 12px !important;
    }
    
    table {
        border-collapse: collapse !important;
        width: 100% !important;
    }
    
    th, td {
        border: 1px solid #e2e8f0 !important;
        padding: 8px !important;
        font-size: 11px !important;
    }
    
    tr {
        page-break-inside: avoid !important;
    }
}


/* ==========================================
   TASK TRACKER STYLES
   ========================================== */
.task-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 16px;
    margin-bottom: 16px;
    backdrop-filter: blur(12px);
    overflow: hidden;
    transition: transform 0.2s, border-color 0.2s;
}

.task-card:hover {
    border-color: rgba(99, 102, 241, 0.4);
}

.task-card.completed {
    opacity: 0.6;
}

.task-header {
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
}

.task-title {
    font-weight: 600;
    font-size: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.task-meta {
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 13px;
    color: var(--text-muted);
}

.progress-pill {
    background: rgba(99, 102, 241, 0.2);
    color: #818cf8;
    padding: 4px 10px;
    border-radius: 20px;
    font-weight: 600;
}

.chevron {
    transition: transform 0.3s;
}

.task-body {
    padding: 0 20px 20px 20px;
    border-top: 1px solid var(--border);
    background: rgba(0,0,0,0.15);
}

.timeline {
    margin: 20px 0 24px 8px;
    border-left: 2px solid rgba(255,255,255,0.05);
    padding-left: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.update-item {
    position: relative;
}

.update-item::before {
    content: '';
    position: absolute;
    left: -25px;
    top: 5px;
    width: 8px;
    height: 8px;
    background: var(--primary);
    border-radius: 50%;
    box-shadow: 0 0 10px var(--primary);
}

.update-time {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.update-text {
    font-size: 14px;
    color: #cbd5e1;
    line-height: 1.5;
}

.progress-bar-container {
    height: 6px;
    background: rgba(255,255,255,0.05);
    border-radius: 10px;
    margin-bottom: 24px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #6366f1, #a855f7);
    border-radius: 10px;
    transition: width 0.3s ease;
}

.add-update-box {
    display: flex;
    gap: 12px;
}

.add-update-input {
    flex: 1;
    background: rgba(15, 23, 42, 0.4);
    border: 1px solid var(--border);
    padding: 10px 14px;
    border-radius: 8px;
    color: white;
    font-size: 14px;
}

.progress-input {
    width: 80px;
    background: rgba(15, 23, 42, 0.4);
    border: 1px solid var(--border);
    padding: 10px;
    border-radius: 8px;
    color: white;
    font-size: 14px;
    text-align: center;
}

/* Settings Nav Items Hover & Active states */
.settings-nav-item {
    color: var(--text-muted) !important;
    transition: all 0.15s ease !important;
}

.settings-nav-item:hover {
    background: rgba(99, 102, 241, 0.05) !important;
    color: var(--text-main) !important;
}

.settings-nav-item.active {
    background: rgba(99, 102, 241, 0.12) !important;
    color: #6366f1 !important;
    font-weight: 700 !important;
}

/* Custom Sliding Toggle Switches for permissions checkboxes */
#appSettingsFormPermissions label {
    display: flex !important;
    flex-direction: row-reverse !important;
    align-items: center !important;
    justify-content: space-between !important;
    padding: 14px 18px !important;
    background: var(--card-bg, #ffffff) !important;
    border: 1px solid var(--border) !important;
    border-radius: 12px !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
    font-weight: 600 !important;
    font-size: 14px !important;
    color: var(--text-main) !important;
    margin: 0 !important;
}

#appSettingsFormPermissions label:hover {
    background: rgba(99, 102, 241, 0.03) !important;
    border-color: rgba(99, 102, 241, 0.25) !important;
}

#appSettingsFormPermissions input[type="checkbox"] {
    appearance: none !important;
    -webkit-appearance: none !important;
    width: 44px !important;
    height: 24px !important;
    background-color: #d1d1d6 !important; /* iOS style default gray */
    border-radius: 9999px !important;
    position: relative !important;
    cursor: pointer !important;
    transition: background-color 0.2s ease !important;
    outline: none !important;
    border: none !important;
    flex-shrink: 0 !important;
    margin: 0 !important;
}

#appSettingsFormPermissions input[type="checkbox"]::before {
    content: "" !important;
    position: absolute !important;
    width: 20px !important;
    height: 20px !important;
    border-radius: 50% !important;
    background-color: white !important;
    top: 2px !important;
    left: 2px !important;
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1) !important;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15) !important;
}

#appSettingsFormPermissions input[type="checkbox"]:checked {
    background-color: #34c759 !important; /* iOS Green toggle */
}

#appSettingsFormPermissions input[type="checkbox"]:checked::before {
    transform: translateX(20px) !important;
}


