﻿/* ============================================================
   Employee Management Dashboard - Stylesheet
   Dark theme · Emerald accent (#10B981) · senior-grade surfaces
   ============================================================ */

/* --- Reset & Base --- */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    color-scheme: dark;

    /* ── Signature Accent (Emerald) ── */
    --accent: #10B981;
    --accent-hover: #34D399;
    --accent-strong: #059669;
    --accent-soft: rgba(16, 185, 129, 0.12);
    --accent-border: rgba(16, 185, 129, 0.35);
    --accent-glow: rgba(16, 185, 129, 0.35);

    /* ── Dark Surfaces (layered) ── */
    --bg-deep: #0B0F14;
    --bg-base: #10151D;
    --surface: #161C26;
    --surface-raised: #1C2330;
    --elevated: #222B3A;

    /* ── Text ── */
    --text-primary: #EDF2F7;
    --text-secondary: #9AA7B8;
    --text-muted: #7D8A9B;

    /* ── Borders (translucent) ── */
    --border: rgba(255, 255, 255, 0.07);
    --border-strong: rgba(255, 255, 255, 0.14);
    --border-accent: rgba(16, 185, 129, 0.45);

    /* ── Status ── */
    --success: #34D399;
    --success-soft: rgba(16, 185, 129, 0.15);
    --danger: #F87171;
    --danger-soft: rgba(248, 113, 113, 0.14);
    --warning: #FBBF24;
    --warning-soft: rgba(251, 191, 36, 0.14);

    /* Semantic aliases (kept for compatibility) */
    --color-primary: var(--accent);
    --color-on-primary: #04120C;
    --color-primary-dark: var(--accent-strong);
    --color-primary-light: var(--accent-soft);
    --color-secondary: var(--accent);
    --color-accent: var(--accent);
    --color-success: var(--success);
    --color-success-light: var(--success-soft);
    --color-danger: var(--danger);
    --color-danger-light: var(--danger-soft);
    --color-warning: var(--warning);
    --color-warning-light: var(--warning-soft);
    --color-bg: var(--bg-deep);
    --color-surface: var(--surface);
    --color-card: var(--surface);
    --color-card-foreground: var(--text-primary);
    --color-foreground: var(--text-primary);
    --color-text: var(--text-primary);
    --color-background: var(--bg-deep);
    --color-muted: rgba(255, 255, 255, 0.05);
    --color-muted-foreground: var(--text-secondary);
    --color-border: var(--border);
    --color-ring: var(--accent);
    --color-destructive: var(--danger);
    --color-on-destructive: #1A0A0A;
    --color-text-secondary: var(--text-secondary);

    /* Spacing Scale */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    --space-2xl: 48px;
    --space-3xl: 64px;

    /* Layout */
    --sidebar-width: 260px;
    --header-height: 72px;

    /* Radii */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;

    /* Shadows (dark, depth through black) */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 8px 24px -8px rgba(0, 0, 0, 0.6);
    --shadow-lg: 0 16px 40px -12px rgba(0, 0, 0, 0.75);
    --shadow-xl: 0 24px 60px -12px rgba(0, 0, 0, 0.85);
    --glow-accent: 0 0 0 1px var(--border-accent), 0 0 20px -4px var(--accent-glow);

    /* Typography */
    --font-heading: 'Fira Code', ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;
    --font-body: 'Fira Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

    /* Motion */
    --transition-fast: 150ms ease;
    --transition: 200ms ease;
    --transition-slow: 300ms ease;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-body);
    background-color: var(--color-bg);
    background-image:
        radial-gradient(1200px 600px at 15% -10%, rgba(16, 185, 129, 0.06), transparent 60%),
        radial-gradient(900px 500px at 110% 0%, rgba(16, 185, 129, 0.05), transparent 55%);
    background-attachment: fixed;
    color: var(--color-text);
    line-height: 1.6;
    min-height: 100vh;
}

::selection {
    background: var(--accent);
    color: #04120C;
}

::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

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

::-webkit-scrollbar-thumb {
    background: var(--elevated);
    border-radius: 10px;
    border: 2px solid var(--bg-base);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent-strong);
}

h1, h2, .stat-card-value, .table-title, .modal-title, .logo-icon, .sidebar-brand, .message-title {
    font-family: var(--font-heading);
}

/* --- Generic visibility helper --- */
.hidden {
    display: none !important;
}

/* --- Layout --- */
.dashboard-layout {
    display: flex;
    min-height: 100vh;
}

/* --- Sidebar --- */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--bg-base);
    border-right: 1px solid var(--color-border);
    z-index: 100;
    display: flex;
    flex-direction: column;
    transition: transform var(--transition-slow);
}

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

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    width: 38px;
    height: 38px;
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-strong) 100%);
    color: #04120C;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1rem;
    box-shadow: 0 4px 14px -4px var(--accent-glow);
}

.sidebar-brand {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-primary);
}

.brand-accent {
    color: var(--accent);
    font-weight: 600;
}

.sidebar-nav {
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    text-decoration: none;
    text-align: left;
    border: 1px solid transparent;
    background: none;
    color: var(--color-text-secondary);
    font-family: var(--font-body);
    font-size: 0.9rem;
    font-weight: 500;
    line-height: 1.4;
    cursor: pointer;
    transition: background-color var(--transition), color var(--transition), border-color var(--transition);
}

.nav-link:hover {
    background: var(--elevated);
    color: var(--text-primary);
}

.nav-link.active {
    background: var(--accent-soft);
    color: var(--accent);
    border-color: var(--accent-border);
    font-weight: 600;
    box-shadow: inset 0 0 0 1px var(--accent-border);
}

.nav-icon {
    display: inline-flex;
    width: 20px;
    flex-shrink: 0;
}

.nav-label {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* --- Sidebar user footer --- */
.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--color-border);
}

.user-chip {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-md);
    background: var(--surface);
    border: 1px solid var(--color-border);
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-strong) 100%);
    color: #04120C;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.8rem;
    flex-shrink: 0;
}

.user-avatar svg {
    width: 18px;
    height: 18px;
    display: block;
    color: #04120C;
}

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

.user-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
}

.user-role {
    font-size: 0.72rem;
    color: var(--text-secondary);
}

/* --- Main Content --- */
.main-content {
    flex: 1;
    min-width: 0;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* --- Top Header --- */
.top-header {
    height: var(--header-height);
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    padding: 0 32px;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 50;
}

.sidebar-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: var(--space-xs);
    border-radius: var(--radius-sm);
    color: var(--color-text);
    line-height: 1;
    transition: background-color var(--transition-fast), color var(--transition-fast);
}

.sidebar-toggle:hover {
    background: var(--elevated);
    color: var(--accent);
}

.sidebar-toggle:focus-visible,
.nav-link:focus-visible,
.sort-btn:focus-visible,
.btn-view:focus-visible,
.retry-btn:focus-visible,
.clear-filters-btn:focus-visible,
.modal-close:focus-visible,
.search-input:focus-visible,
.filter-select:focus-visible {
    outline: 2px solid var(--color-ring);
    outline-offset: 2px;
}

.header-title h1 {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--color-foreground);
}

.header-subtitle {
    font-size: 0.8rem;
    color: var(--color-text-secondary);
}

.header-actions {
    margin-left: auto;
}

.header-datetime {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
}

.header-time {
    font-family: var(--font-heading);
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--accent);
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.02em;
    line-height: 1.2;
}

.header-date {
    font-size: 0.82rem;
    color: var(--color-text-secondary);
    font-weight: 500;
}

/* --- Dashboard Body --- */
.dashboard-body {
    padding: 28px 32px;
    flex: 1;
    max-width: 1400px;
}

/* --- Panels (section switching) --- */
.panel[hidden] {
    display: none;
}

.panel {
    animation: panelIn var(--transition) ease;
}

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

.panel-heading {
    margin-bottom: 24px;
}

.panel-title {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.panel-subtitle {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* --- Stats Section --- */
.stats-section {
    margin-bottom: 28px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
}

.stat-card {
    background: linear-gradient(180deg, var(--surface-raised) 0%, var(--surface) 100%);
    border-radius: var(--radius-md);
    padding: 20px 22px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--color-border);
    transition: box-shadow var(--transition), transform var(--transition), border-color var(--transition), background var(--transition);
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.stat-card::after {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(120px 80px at 0% 0%, var(--accent-soft), transparent 70%);
    opacity: 0;
    transition: opacity var(--transition);
    pointer-events: none;
}

.stat-card:hover {
    box-shadow: var(--glow-accent), var(--shadow-md);
    transform: translateY(-2px);
    border-color: var(--border-accent);
}

.stat-card:hover::after {
    opacity: 1;
}

.stat-card-icon {
    width: 52px;
    height: 52px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform var(--transition);
}

.stat-card:hover .stat-card-icon {
    transform: scale(1.05);
}

.stat-card-icon--total { background: var(--accent-soft); color: var(--accent); }
.stat-card-icon--active { background: var(--success-soft); color: var(--success); }
.stat-card-icon--inactive { background: var(--danger-soft); color: var(--danger); }
.stat-card-icon--departments { background: var(--warning-soft); color: var(--warning); }

.stat-card-value {
    display: block;
    font-size: 1.6rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    line-height: 1.2;
    color: var(--text-primary);
}

.stat-card-label {
    display: block;
    font-size: 0.78rem;
    color: var(--color-text-secondary);
    font-weight: 500;
    margin-top: 2px;
}

/* --- Controls Section --- */
.controls-section {
    margin-bottom: 24px;
}

.controls-bar {
    background: linear-gradient(180deg, var(--surface-raised) 0%, var(--surface) 100%);
    border-radius: var(--radius-md);
    padding: 16px 18px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--color-border);
    flex-wrap: wrap;
}

.search-wrapper {
    flex: 1;
    min-width: 0;
    position: relative;
}

.search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--color-text-secondary);
    display: inline-flex;
    pointer-events: none;
    transition: color var(--transition);
}

.search-input {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    padding: 11px 14px 11px 42px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    color: var(--color-text);
    background: var(--bg-base);
    transition: border-color var(--transition), box-shadow var(--transition), background-color var(--transition);
    font-family: inherit;
}

.search-input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--accent-soft);
    background: var(--surface);
    background-color: var(--surface);
}

.search-input:focus + .search-icon,
.search-wrapper:focus-within .search-icon {
    color: var(--accent);
}

.search-input::placeholder {
    color: var(--color-text-secondary);
}

.filters-group {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    flex: 0 0 auto;
}

.filter-label-sr {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.filter-select {
    padding: 11px 36px 11px 14px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    color: var(--color-text);
    background: var(--bg-base);
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236B7888' d='M2 4l4 4 4-4'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    font-family: inherit;
    transition: border-color var(--transition), box-shadow var(--transition), background-color var(--transition);
    min-width: 0;
    max-width: 100%;
    width: 160px;
    flex: 0 1 auto;
}

.filter-select:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--accent-soft);
    background-color: var(--surface);
}

/* --- Table Section --- */
.table-section {
    background: var(--color-surface);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--color-border);
    overflow: hidden;
}

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

.table-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--color-foreground);
}

.table-count {
    font-size: 0.78rem;
    color: var(--color-text-secondary);
    background: var(--color-primary-light);
    padding: 4px 12px;
    border-radius: 20px;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
}

.table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.employee-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 700px;
}

.employee-table thead {
    background: rgba(255, 255, 255, 0.03);
    border-bottom: 1px solid var(--color-border);
}

.employee-table th {
    padding: 12px 20px;
    text-align: left;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    white-space: nowrap;
    user-select: none;
}

.employee-table td {
    padding: 14px 20px;
    font-size: 0.88rem;
    color: var(--color-text);
    border-bottom: 1px solid var(--color-border);
    vertical-align: middle;
}

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

.employee-table tbody tr:hover {
    background: var(--accent-soft);
}

.employee-table tbody tr:last-child td {
    border-bottom: none;
}

.sort-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: inherit;
    font-weight: inherit;
    font-family: inherit;
    text-transform: inherit;
    letter-spacing: inherit;
    color: inherit;
    padding: 0;
}

.sort-icon {
    display: inline-flex;
    flex-direction: column;
    font-size: 0.6rem;
    line-height: 1;
    gap: 1px;
    opacity: 0.3;
    transition: opacity var(--transition-fast);
}

.sort-icon::before,
.sort-icon::after {
    content: '';
    display: block;
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
}

.sort-icon::before {
    border-bottom: 5px solid currentColor;
}

.sort-icon::after {
    border-top: 5px solid currentColor;
}

th[data-sort-asc="true"] .sort-icon::before,
th[data-sort-desc="true"] .sort-icon::after {
    opacity: 1;
}

th[data-sort-asc="true"] .sort-icon::after,
th[data-sort-desc="true"] .sort-icon::before {
    opacity: 0.2;
}

th[data-sort-asc="true"] .sort-icon,
th[data-sort-desc="true"] .sort-icon {
    opacity: 1;
}

/* --- Status Badge --- */
.status-badge {
    display: inline-block;
    padding: 3px 12px;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 600;
    white-space: nowrap;
    border: 1px solid transparent;
}

.status-badge--active {
    background: var(--color-success-light);
    color: var(--color-success);
    border-color: rgba(52, 211, 153, 0.25);
}

.status-badge--inactive {
    background: var(--color-danger-light);
    color: var(--color-danger);
    border-color: rgba(248, 113, 113, 0.25);
}

/* --- Performance Bar --- */
.performance-cell {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 140px;
}

.performance-bar-track {
    flex: 1;
    height: 7px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 10px;
    overflow: hidden;
    min-width: 60px;
}

.performance-bar-fill {
    height: 100%;
    border-radius: 10px;
    transition: width var(--transition-slow);
    box-shadow: 0 0 8px -2px currentColor;
}

.performance-value {
    font-size: 0.85rem;
    font-weight: 600;
    min-width: 28px;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.performance--high .performance-bar-fill { background: linear-gradient(90deg, #059669, var(--color-success)); color: var(--color-success); }
.performance--high .performance-value { color: var(--color-success); }
.performance--medium .performance-bar-fill { background: linear-gradient(90deg, #B45309, var(--color-warning)); color: var(--color-warning); }
.performance--medium .performance-value { color: var(--color-warning); }
.performance--low .performance-bar-fill { background: linear-gradient(90deg, #B91C1C, var(--color-danger)); color: var(--color-danger); }
.performance--low .performance-value { color: var(--color-danger); }

/* --- Action Button --- */
.btn-view {
    padding: 6px 16px;
    background: var(--color-primary);
    color: var(--color-on-primary);
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color var(--transition), box-shadow var(--transition);
    white-space: nowrap;
    font-family: inherit;
}

.btn-view:hover {
    background: var(--accent-hover);
    box-shadow: 0 4px 14px -4px var(--accent-glow);
}

/* --- Message States --- */
.message-state {
    padding: 48px 24px;
    text-align: center;
}

.message-icon {
    width: 84px;
    height: 84px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
}

.message-icon--error { background: var(--color-danger-light); color: var(--color-danger); }
.message-icon--empty { background: var(--color-primary-light); color: var(--color-primary); }
.message-icon--no-results { background: var(--color-warning-light); color: var(--color-warning); }

.message-title {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--color-foreground);
    margin-bottom: 6px;
}

.message-text {
    font-size: 0.9rem;
    color: var(--color-text-secondary);
    max-width: 460px;
    margin: 0 auto 20px;
}

.retry-btn,
.clear-filters-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 24px;
    background: var(--color-primary);
    color: var(--color-on-primary);
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color var(--transition), box-shadow var(--transition);
    font-family: inherit;
}

.retry-btn:hover,
.clear-filters-btn:hover {
    background: var(--accent-hover);
    box-shadow: 0 6px 18px -6px var(--accent-glow);
}

/* --- Loading Skeleton --- */
.skeleton-card {
    max-width: 520px;
    margin: 0 auto 20px;
    background: linear-gradient(180deg, var(--surface-raised) 0%, var(--surface) 100%);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 24px;
    text-align: left;
}

.skeleton {
    background: linear-gradient(90deg, rgba(255, 255, 255, 0.05) 25%, rgba(255, 255, 255, 0.12) 37%, rgba(255, 255, 255, 0.05) 63%);
    background-size: 400% 100%;
    animation: shimmer 1.4s ease infinite;
    border-radius: var(--radius-sm);
}

.skeleton-title {
    height: 18px;
    width: 40%;
    margin-bottom: 16px;
}

.skeleton-text {
    height: 14px;
    width: 30%;
    margin-bottom: 12px;
}

.skeleton-row {
    height: 44px;
    margin-top: 10px;
}

.skeleton-row.short {
    width: 70%;
}

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

.loading-message {
    font-size: 0.9rem;
    color: var(--color-text-secondary);
}

/* --- Modal --- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(4, 8, 12, 0.7);
    backdrop-filter: blur(6px) saturate(1.1);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    animation: fadeIn var(--transition-fast) ease;
}

.modal-overlay.hidden {
    display: none;
}

.modal-overlay.closing {
    animation: fadeOut var(--transition-fast) ease forwards;
}

.modal {
    background: linear-gradient(180deg, var(--surface-raised) 0%, var(--surface) 100%);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 520px;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: var(--shadow-xl);
    animation: modalIn var(--transition) ease;
}

.modal::before {
    content: '';
    display: block;
    height: 3px;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    background: linear-gradient(90deg, var(--accent-strong) 0%, var(--accent) 50%, var(--accent-soft) 100%);
}

.modal.closing {
    animation: modalOut var(--transition-fast) ease forwards;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes fadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

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

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

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

.modal-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--color-foreground);
}

.modal-close {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid var(--color-border);
    background: var(--bg-base);
    color: var(--color-text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color var(--transition), color var(--transition), border-color var(--transition);
    line-height: 1;
}

.modal-close:hover {
    background: var(--color-danger-light);
    border-color: rgba(248, 113, 113, 0.3);
    color: var(--color-danger);
}

.modal-body {
    padding: 24px 28px 28px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* --- Modal profile head --- */
.modal-profile-head {
    display: flex;
    align-items: center;
    gap: 16px;
}

.modal-avatar {
    width: 56px;
    height: 56px;
    border-radius: 14px;
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-strong) 100%);
    color: #04120C;
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: var(--glow-accent);
}

.modal-identity {
    min-width: 0;
}

.modal-name-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.modal-name {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--color-foreground);
    letter-spacing: -0.01em;
}

.modal-role {
    display: block;
    margin-top: 2px;
    font-size: 0.85rem;
    color: var(--color-text-secondary);
}

/* --- Modal quick meta strip --- */
.modal-profile-meta {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    background: var(--bg-base);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 14px 16px;
}

.modal-meta-item {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
}

.modal-meta-label {
    font-size: 0.68rem;
    font-weight: 600;
    color: var(--color-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.modal-meta-value {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--color-text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* --- Modal performance --- */
.modal-perf {
    background: var(--surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 16px 18px;
}

.modal-perf-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 12px;
}

.modal-perf-label {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--color-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.modal-perf-value {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent);
    font-variant-numeric: tabular-nums;
    line-height: 1;
}

.modal-perf-suffix {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--color-text-secondary);
}

.modal-perf-track {
    height: 10px;
    background: rgba(255, 255, 255, 0.07);
    border-radius: 10px;
    overflow: hidden;
}

.modal-perf-fill {
    height: 100%;
    border-radius: 10px;
    transition: width 0.6s ease;
}

.modal-perf--high { background: linear-gradient(90deg, #059669, var(--success)); }
.modal-perf--good { background: linear-gradient(90deg, #0E9F6E, #34D399); }
.modal-perf--medium { background: linear-gradient(90deg, #B45309, var(--warning)); }
.modal-perf--low { background: linear-gradient(90deg, #B91C1C, var(--danger)); }

.modal-perf-scale {
    display: flex;
    justify-content: space-between;
    margin-top: 6px;
    font-size: 0.62rem;
    color: var(--color-text-secondary);
}

/* --- Modal remaining detail --- */
.modal-detail-grid {
    display: grid;
    gap: 14px;
}

.modal-detail-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
}

.modal-detail-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.modal-detail-label {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--color-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.modal-detail-value {
    font-size: 0.95rem;
    color: var(--color-text);
    font-weight: 500;
}

.modal-detail-value--break {
    word-break: break-word;
    white-space: normal;
}

/* ============================================================
   Section Views — Employees / Reports / Settings
   ============================================================ */

/* --- Employees: department grid --- */
.dept-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 16px;
}

.dept-card {
    background: linear-gradient(180deg, var(--surface-raised) 0%, var(--surface) 100%);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 18px 20px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    transition: transform var(--transition), border-color var(--transition), box-shadow var(--transition);
}

.dept-card:hover {
    transform: translateY(-2px);
    border-color: var(--accent-border);
    box-shadow: var(--glow-accent), var(--shadow-md);
}

.dept-card-head {
    display: flex;
    align-items: center;
    gap: 12px;
}

.dept-avatar {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: var(--accent-soft);
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.dept-name {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.95rem;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dept-card-body {
    display: flex;
    align-items: baseline;
    gap: 8px;
}

.dept-count {
    font-family: var(--font-heading);
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--accent);
    font-variant-numeric: tabular-nums;
    line-height: 1;
}

.dept-caption {
    font-size: 0.82rem;
    color: var(--text-secondary);
}

.dept-card-foot {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.76rem;
    padding-top: 12px;
    border-top: 1px solid var(--color-border);
}

.dept-active {
    color: var(--success);
    font-weight: 600;
}

.dept-share {
    color: var(--text-secondary);
}

.dept-loading,
.dept-empty,
.report-loading {
    grid-column: 1 / -1;
    padding: 40px;
    text-align: center;
    color: var(--text-secondary);
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius-md);
}

/* --- Reports --- */
.reports-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.report-card {
    background: linear-gradient(180deg, var(--surface-raised) 0%, var(--surface) 100%);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 20px 22px;
}

.report-card--wide {
    grid-column: 1 / -1;
}

.report-card-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 18px;
}

.report-bar-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
}

.report-bar-label {
    width: 92px;
    flex-shrink: 0;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.report-bar-track {
    flex: 1;
    height: 9px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 10px;
    overflow: hidden;
}

.report-bar-fill {
    height: 100%;
    border-radius: 10px;
    transition: width 0.6s ease;
}

.report-bar--high { background: linear-gradient(90deg, #059669, var(--success)); }
.report-bar--good { background: linear-gradient(90deg, #0E9F6E, #34D399); }
.report-bar--medium { background: linear-gradient(90deg, #B45309, var(--warning)); }
.report-bar--low { background: linear-gradient(90deg, #B91C1C, var(--danger)); }
.report-bar--accent { background: linear-gradient(90deg, var(--accent-strong), var(--accent)); }

.report-bar-value {
    width: 28px;
    text-align: right;
    font-family: var(--font-heading);
    font-variant-numeric: tabular-nums;
    font-size: 0.82rem;
    color: var(--text-primary);
    font-weight: 600;
}

.composition-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.composition-item {
    background: var(--surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 18px 20px;
    text-align: center;
}

.composition-value {
    display: block;
    font-family: var(--font-heading);
    font-size: 1.7rem;
    font-weight: 700;
    color: var(--accent);
    font-variant-numeric: tabular-nums;
}

.composition-label {
    font-size: 0.78rem;
    color: var(--text-secondary);
    margin-top: 4px;
    display: block;
}

/* --- Settings --- */
.settings-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.settings-card {
    background: linear-gradient(180deg, var(--surface-raised) 0%, var(--surface) 100%);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 20px 22px;
}

.settings-card-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 18px;
}

.settings-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.settings-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.settings-field--inline {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
}

.settings-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-primary);
}

.settings-hint {
    font-size: 0.75rem;
    color: var(--text-secondary);
    display: block;
    margin-top: 2px;
}

.settings-input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--bg-base);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 0.9rem;
    transition: border-color var(--transition), box-shadow var(--transition), background-color var(--transition);
}

.settings-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
    background-color: var(--surface);
}

.color-picker-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.color-swatch {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    border: 2px solid var(--border-strong);
    flex-shrink: 0;
}

.pref-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.pref-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 0;
    border-bottom: 1px solid var(--color-border);
}

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

/* --- Toggle switch --- */
.toggle {
    position: relative;
    width: 44px;
    height: 24px;
    border-radius: 20px;
    background: var(--elevated);
    border: 1px solid var(--border-strong);
    cursor: pointer;
    flex-shrink: 0;
    transition: background-color var(--transition), border-color var(--transition);
    display: inline-block;
}

.toggle-knob {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--text-secondary);
    transition: transform var(--transition), background-color var(--transition);
}

.toggle.is-on {
    background: var(--accent);
    border-color: var(--accent);
}

.toggle.is-on .toggle-knob {
    transform: translateX(20px);
    background: #04120C;
}

.toggle:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* ============================================================ */

/* --- Reduced Motion --- */
@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .skeleton {
        animation: none;
        background: var(--color-muted);
    }

    .sidebar,
    .stat-card,
    .btn-view,
    .retry-btn,
    .clear-filters-btn,
    .nav-link,
    .dept-card,
    .toggle,
    .toggle-knob {
        transition: none;
    }
}

/* --- Responsive: Tablet --- */
@media (max-width: 1024px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .controls-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .search-wrapper {
        min-width: 0;
    }

    .filters-group {
        width: 100%;
    }

    .filter-select {
        flex: 1;
    }
}

/* --- Responsive: Mobile sidebar --- */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
        box-shadow: var(--shadow-xl);
    }

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

    .main-content {
        margin-left: 0;
    }

    .top-header {
        padding: 0 16px;
    }

    .dashboard-body {
        padding: 20px 16px;
    }

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

    .stat-card {
        padding: 16px;
    }

    .stat-card-icon {
        width: 42px;
        height: 42px;
    }

    .stat-card-value {
        font-size: 1.3rem;
    }

    .controls-bar {
        padding: 14px 16px;
    }

    .table-header-bar {
        padding: 14px 16px;
    }

    .employee-table th,
    .employee-table td {
        padding: 10px 14px;
    }

    .modal {
        margin: 12px;
        max-height: 90vh;
    }

    .modal-header {
        padding: 16px 20px;
    }

    .modal-body {
        padding: 20px;
    }

    .modal-detail-row {
        grid-template-columns: 1fr;
    }

    .modal-profile-meta {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .reports-grid,
    .settings-grid {
        grid-template-columns: 1fr;
    }

    .report-card--wide {
        grid-column: auto;
    }

    .composition-row {
        grid-template-columns: 1fr;
    }
}

/* --- Responsive: Small Mobile --- */
@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

    .stat-card {
        padding: 14px 12px;
        gap: 10px;
    }

    .stat-card-icon {
        width: 36px;
        height: 36px;
    }

    .stat-card-value {
        font-size: 1.1rem;
    }

    .stat-card-label {
        font-size: 0.7rem;
    }

    .header-subtitle {
        display: none;
    }

    .filters-group {
        flex-direction: column;
    }

    .filter-select {
        width: 100%;
    }
}

/* --- Responsive: Very Small --- */
@media (max-width: 360px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .stat-card {
        flex-direction: row;
    }
}

/* --- Scrollbar styling --- */
.table-container::-webkit-scrollbar {
    height: 6px;
}

.table-container::-webkit-scrollbar-track {
    background: var(--color-muted);
    border-radius: 3px;
}

.table-container::-webkit-scrollbar-thumb {
    background: var(--color-border);
    border-radius: 3px;
}

.table-container::-webkit-scrollbar-thumb:hover {
    background: var(--color-text-secondary);
}

/* --- Overlay for mobile sidebar --- */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(4, 8, 12, 0.55);
    backdrop-filter: blur(2px);
    z-index: 99;
}

.sidebar-overlay.active {
    display: block;
}
