/* ============================================================
   PORTARIA — Design System
   Premium SaaS Dark Theme with Dynamic Branding
   ============================================================ */

/* ---------- CSS Custom Properties ---------- */
:root {
    /* Brand (overridden by template inline) */
    --brand-primary: #1a1a2e;
    --brand-secondary: #16213e;
    --brand-accent: #0f3460;

    /* Neutrals */
    --bg-body: #0a0a1a;
    --bg-surface: #111128;
    --bg-surface-2: #1a1a3e;
    --bg-surface-3: #242450;
    --bg-hover: rgba(255, 255, 255, 0.04);

    /* Text */
    --text-primary: #e8e8f0;
    --text-secondary: #a0a0c0;
    --text-muted: #6a6a8e;
    --text-brand: #818cf8;

    /* Borders */
    --border-color: rgba(255, 255, 255, 0.06);
    --border-hover: rgba(255, 255, 255, 0.12);

    /* Status */
    --success: #34d399;
    --success-bg: rgba(52, 211, 153, 0.1);
    --warning: #fbbf24;
    --warning-bg: rgba(251, 191, 36, 0.1);
    --danger: #f87171;
    --danger-bg: rgba(248, 113, 113, 0.1);
    --info: #60a5fa;
    --info-bg: rgba(96, 165, 250, 0.1);

    /* Dimensions */
    --sidebar-width: 260px;
    --sidebar-collapsed: 72px;
    --header-height: 64px;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;

    /* Shadows */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 20px rgba(129, 140, 248, 0.15);

    /* Transitions */
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-normal: 250ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);

    /* Glass */
    --glass-bg: rgba(17, 17, 40, 0.7);
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-blur: 16px;
}

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

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-body);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
}

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

a:hover {
    color: #a5b4fc;
}

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

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

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* ============================================================
   LAYOUT — App Body (Sidebar + Main)
   ============================================================ */
.app-body {
    display: flex;
    min-height: 100vh;
}

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

.sidebar.collapsed {
    width: var(--sidebar-collapsed);
}

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

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

.brand-icon {
    font-size: 28px;
    color: var(--text-brand);
}

.brand-text {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
}

.sidebar-logo {
    max-height: 36px;
    max-width: 140px;
    object-fit: contain;
}

.sidebar-toggle {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 6px;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
}

.sidebar-toggle:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

/* Sidebar Nav */
.sidebar-nav {
    flex: 1;
    padding: 12px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    transition: all var(--transition-fast);
    text-decoration: none;
}

.nav-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.nav-item.active {
    background: rgba(129, 140, 248, 0.1);
    color: var(--text-brand);
}

.nav-item .material-icons-outlined {
    font-size: 22px;
    min-width: 22px;
}

.nav-divider {
    height: 1px;
    background: var(--border-color);
    margin: 8px 0;
}

/* Sidebar Footer */
.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea, #764ba2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 700;
    color: white;
    flex-shrink: 0;
    text-transform: uppercase;
}

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

.user-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-role {
    font-size: 11px;
    color: var(--text-muted);
}

.logout-btn {
    color: var(--text-muted);
    padding: 6px;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
}

.logout-btn:hover {
    color: var(--danger);
    background: var(--danger-bg);
}

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

.main-content.expanded {
    margin-left: var(--sidebar-collapsed);
}

/* Top Header */
.top-header {
    position: sticky;
    top: 0;
    height: var(--header-height);
    background: rgba(10, 10, 26, 0.8);
    backdrop-filter: blur(var(--glass-blur));
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    z-index: 50;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.mobile-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 6px;
    border-radius: var(--radius-sm);
}

.page-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.company-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: var(--bg-surface-2);
    border-radius: var(--radius-xl);
    font-size: 12px;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.company-badge .material-icons-outlined {
    font-size: 16px;
    color: var(--text-brand);
}

/* User dropdown */
.header-user {
    position: relative;
}

.user-menu-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.user-menu-btn:hover {
    background: var(--bg-hover);
}

.user-avatar-sm {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea, #764ba2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    color: white;
    text-transform: uppercase;
}

.user-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 220px;
    background: var(--bg-surface-2);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    z-index: 200;
}

.dropdown-header {
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
}

.dropdown-header strong {
    font-size: 14px;
    color: var(--text-primary);
}

.dropdown-header small {
    font-size: 12px;
    color: var(--text-muted);
}

.dropdown-divider {
    height: 1px;
    background: var(--border-color);
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    font-size: 14px;
    color: var(--text-secondary);
    transition: all var(--transition-fast);
}

.dropdown-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.dropdown-item .material-icons-outlined {
    font-size: 18px;
}

/* Content Wrapper */
.content-wrapper {
    padding: 24px;
    max-width: 1400px;
}

/* ============================================================
   COMPONENTS — Alerts
   ============================================================ */
.messages-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 20px;
}

.alert {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    font-size: 14px;
    border: 1px solid;
    animation: slideDown 0.3s ease;
}

.alert-success {
    background: var(--success-bg);
    border-color: rgba(52, 211, 153, 0.2);
    color: var(--success);
}

.alert-error {
    background: var(--danger-bg);
    border-color: rgba(248, 113, 113, 0.2);
    color: var(--danger);
}

.alert-warning {
    background: var(--warning-bg);
    border-color: rgba(251, 191, 36, 0.2);
    color: var(--warning);
}

.alert-info {
    background: var(--info-bg);
    border-color: rgba(96, 165, 250, 0.2);
    color: var(--info);
}

.alert-close {
    margin-left: auto;
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    padding: 2px;
    opacity: 0.6;
    transition: opacity var(--transition-fast);
}

.alert-close:hover {
    opacity: 1;
}

/* ============================================================
   COMPONENTS — Cards
   ============================================================ */
.stat-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: all var(--transition-normal);
}

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

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

.stat-icon .material-icons-outlined {
    font-size: 26px;
    color: white;
}

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

.stat-value {
    font-size: 28px;
    font-weight: 800;
    line-height: 1.1;
    color: var(--text-primary);
}

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

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

/* Welcome Card */
.welcome-card {
    background: var(--glass-bg);
    backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: 48px;
    text-align: center;
}

.welcome-icon {
    font-size: 64px;
    color: var(--text-brand);
    margin-bottom: 16px;
}

.welcome-card h2 {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.welcome-card p {
    color: var(--text-secondary);
    font-size: 14px;
}

/* ============================================================
   LOGIN PAGE
   ============================================================ */
.login-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.login-wrapper {
    position: relative;
    width: 100%;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

/* Login Background */
.login-bg {
    position: fixed;
    inset: 0;
    z-index: 0;
}

.bg-gradient {
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at 20% 50%, var(--brand-primary) 0%, transparent 50%),
                radial-gradient(ellipse at 80% 20%, var(--brand-accent) 0%, transparent 50%),
                radial-gradient(ellipse at 50% 80%, var(--brand-secondary) 0%, transparent 50%),
                var(--bg-body);
}

.bg-grid {
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.02) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
    background-size: 60px 60px;
}

.floating-shapes {
    position: absolute;
    inset: 0;
    overflow: hidden;
}

.shape {
    position: absolute;
    background: linear-gradient(135deg, rgba(129, 140, 248, 0.1), rgba(129, 140, 248, 0.02));
    border-radius: 50%;
    animation: float 20s ease-in-out infinite;
}

.shape-1 {
    width: 300px;
    height: 300px;
    top: 10%;
    left: 10%;
    animation-delay: 0s;
}

.shape-2 {
    width: 200px;
    height: 200px;
    top: 60%;
    right: 10%;
    animation-delay: -5s;
}

.shape-3 {
    width: 150px;
    height: 150px;
    bottom: 10%;
    left: 30%;
    animation-delay: -10s;
}

.shape-4 {
    width: 250px;
    height: 250px;
    top: 30%;
    right: 30%;
    animation-delay: -15s;
}

@keyframes float {
    0%, 100% { transform: translate(0, 0) rotate(0deg); }
    25% { transform: translate(30px, -30px) rotate(5deg); }
    50% { transform: translate(-20px, 20px) rotate(-5deg); }
    75% { transform: translate(10px, -10px) rotate(3deg); }
}

/* Login Card */
.login-card {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 420px;
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-xl);
    padding: 40px;
    box-shadow: var(--shadow-lg);
    animation: fadeInUp 0.6s ease;
}

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

.login-header {
    text-align: center;
    margin-bottom: 32px;
}

.login-brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.login-icon {
    font-size: 48px;
    color: var(--text-brand);
}

.login-logo {
    max-height: 56px;
    max-width: 200px;
    object-fit: contain;
    margin-bottom: 8px;
}

.login-title {
    font-size: 28px;
    font-weight: 800;
    color: var(--text-primary);
}

.login-subtitle {
    font-size: 14px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* Login messages */
.login-messages {
    margin-bottom: 20px;
}

.login-alert {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    margin-bottom: 8px;
}

.login-alert-error {
    background: var(--danger-bg);
    color: var(--danger);
    border: 1px solid rgba(248, 113, 113, 0.2);
}

.login-alert-success {
    background: var(--success-bg);
    color: var(--success);
    border: 1px solid rgba(52, 211, 153, 0.2);
}

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

.form-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.form-label .material-icons-outlined {
    font-size: 16px;
}

.form-input {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-surface-2);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: all var(--transition-fast);
}

.form-input::placeholder {
    color: var(--text-muted);
}

.form-input:focus {
    border-color: var(--text-brand);
    box-shadow: 0 0 0 3px rgba(129, 140, 248, 0.1);
}

.password-wrapper {
    position: relative;
}

.password-wrapper .form-input {
    padding-right: 44px;
}

.password-toggle {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    transition: color var(--transition-fast);
}

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

.password-toggle .material-icons-outlined {
    font-size: 20px;
}

/* Login Button */
.btn-login {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    border: none;
    border-radius: var(--radius-md);
    color: white;
    font-size: 15px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all var(--transition-normal);
    margin-top: 4px;
}

.btn-login:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(102, 126, 234, 0.3);
}

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

.btn-login:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.btn-login .material-icons-outlined {
    font-size: 20px;
}

.btn-loading {
    display: flex;
    align-items: center;
    gap: 8px;
}

.spinner {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

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

/* Login Footer */
.login-footer {
    text-align: center;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

.login-footer p {
    font-size: 12px;
    color: var(--text-muted);
}

/* ============================================================
   ANIMATIONS
   ============================================================ */
@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
        width: var(--sidebar-width);
    }

    .sidebar.collapsed {
        width: var(--sidebar-width);
    }

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

    .mobile-toggle {
        display: flex;
    }
}

@media (max-width: 640px) {
    .content-wrapper {
        padding: 16px;
    }

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

    .login-card {
        padding: 28px;
    }

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

/* ============================================================
   PHASE 2 — Page Headers
   ============================================================ */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 16px;
}

.page-subtitle {
    font-size: 14px;
    color: var(--text-muted);
    margin-top: 2px;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 18px;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    border: none;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.btn .material-icons-outlined {
    font-size: 18px;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(102, 126, 234, 0.3);
}

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

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

.btn-danger {
    background: linear-gradient(135deg, #f87171, #dc2626);
    color: white;
}

.btn-danger:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(248, 113, 113, 0.3);
}

/* ============================================================
   FILTERS BAR
   ============================================================ */
.filters-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.search-box {
    position: relative;
    flex: 1;
    min-width: 250px;
}

.search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 20px;
}

.search-input {
    width: 100%;
    padding: 10px 16px 10px 44px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: all var(--transition-fast);
}

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

.search-input:focus {
    border-color: var(--text-brand);
    box-shadow: 0 0 0 3px rgba(129, 140, 248, 0.1);
}

.filter-toggle .material-icons-outlined {
    font-size: 18px;
}

.filters-expanded {
    width: 100%;
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    padding-top: 8px;
}

/* ============================================================
   FORM SELECT
   ============================================================ */
.form-select {
    width: 100%;
    padding: 10px 16px;
    background: var(--bg-surface-2);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    outline: none;
    cursor: pointer;
    transition: all var(--transition-fast);
    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='%236a6a8e' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

.form-select:focus {
    border-color: var(--text-brand);
    box-shadow: 0 0 0 3px rgba(129, 140, 248, 0.1);
}

.form-select option {
    background: var(--bg-surface-2);
    color: var(--text-primary);
}

/* ============================================================
   FORM GRID & EXTRAS (for modals)
   ============================================================ */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.form-col-2 {
    grid-column: span 2;
}

.form-check {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-primary);
}

.form-check input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--text-brand);
    cursor: pointer;
}

.form-check-label {
    user-select: none;
}

.form-hint {
    display: block;
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

.form-file {
    padding: 8px 12px;
}

/* ============================================================
   DATA TABLES
   ============================================================ */
.data-table-wrapper {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

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

.data-table thead {
    background: var(--bg-surface-2);
}

.data-table th {
    padding: 12px 16px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    text-align: left;
    white-space: nowrap;
}

.data-table td {
    padding: 12px 16px;
    font-size: 14px;
    color: var(--text-primary);
    border-top: 1px solid var(--border-color);
    vertical-align: middle;
}

.table-row {
    transition: background var(--transition-fast);
}

.table-row:hover {
    background: var(--bg-hover);
}

.th-actions, .td-actions {
    width: 100px;
    text-align: center;
}

/* Table cells */
.cell-with-avatar {
    display: flex;
    align-items: center;
    gap: 10px;
}

.table-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.table-avatar-placeholder {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea, #764ba2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 700;
    color: white;
    flex-shrink: 0;
    text-transform: uppercase;
}

.cell-name {
    font-weight: 500;
}

.cell-mono {
    font-family: 'Courier New', monospace;
    font-size: 13px;
    color: var(--text-secondary);
}

.cell-plate {
    background: var(--bg-surface-2);
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    letter-spacing: 0.05em;
}

.cell-muted {
    color: var(--text-muted);
}

.cell-small {
    font-size: 12px;
    display: block;
    line-height: 1.4;
}

.cell-contact {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.cell-validity {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.color-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 6px;
    vertical-align: middle;
    border: 1px solid rgba(255,255,255,0.2);
}

/* ============================================================
   BADGES
   ============================================================ */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: var(--radius-xl);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

.badge-success {
    background: var(--success-bg);
    color: var(--success);
    border: 1px solid rgba(52, 211, 153, 0.2);
}

.badge-danger {
    background: var(--danger-bg);
    color: var(--danger);
    border: 1px solid rgba(248, 113, 113, 0.2);
}

.badge-warning {
    background: var(--warning-bg);
    color: var(--warning);
    border: 1px solid rgba(251, 191, 36, 0.2);
}

.badge-info {
    background: var(--info-bg);
    color: var(--info);
    border: 1px solid rgba(96, 165, 250, 0.2);
}

.badge-neutral {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.badge-accent {
    background: rgba(129, 140, 248, 0.1);
    color: var(--text-brand);
    border: 1px solid rgba(129, 140, 248, 0.2);
}

/* ============================================================
   ACTION BUTTONS (table)
   ============================================================ */
.action-btns {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.action-btn {
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    border: none;
    background: transparent;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.action-btn .material-icons-outlined {
    font-size: 18px;
}

.action-edit {
    color: var(--text-muted);
}

.action-edit:hover {
    background: var(--info-bg);
    color: var(--info);
}

.action-delete {
    color: var(--text-muted);
}

.action-delete:hover {
    background: var(--danger-bg);
    color: var(--danger);
}

/* ============================================================
   MODALS
   ============================================================ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.modal-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: fadeInUp 0.3s ease;
}

.modal-lg {
    max-width: 680px;
}

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

.modal-header h2 {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

.modal-header h2 .material-icons-outlined {
    font-size: 22px;
    color: var(--text-brand);
}

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

.modal-close:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.modal-form {
    display: flex;
    flex-direction: column;
    min-height: 0; 
    /* To allow scrolling in child body */
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
}

.modal-body .form-group {
    margin-bottom: 16px;
}

.modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
}

/* ============================================================
   PAGINATION
   ============================================================ */
.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-top: 1px solid var(--border-color);
    flex-wrap: wrap;
    gap: 12px;
}

.pagination-info {
    font-size: 13px;
    color: var(--text-muted);
}

.pagination-controls {
    display: flex;
    align-items: center;
    gap: 4px;
}

.page-btn {
    min-width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background: transparent;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

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

.page-btn.active {
    background: rgba(129, 140, 248, 0.15);
    border-color: rgba(129, 140, 248, 0.3);
    color: var(--text-brand);
}

.page-btn .material-icons-outlined {
    font-size: 18px;
}

/* ============================================================
   EMPTY STATE
   ============================================================ */
.empty-state {
    text-align: center;
    padding: 64px 24px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
}

.empty-icon {
    font-size: 56px;
    color: var(--text-muted);
    opacity: 0.4;
    margin-bottom: 16px;
}

.empty-state h3 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.empty-state p {
    font-size: 14px;
    color: var(--text-muted);
}

/* ============================================================
   LOADING SKELETON
   ============================================================ */
.loading-skeleton {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 20px;
}

.skeleton-row {
    height: 48px;
    background: linear-gradient(90deg, var(--bg-surface) 25%, var(--bg-surface-2) 50%, var(--bg-surface) 75%);
    background-size: 200% 100%;
    border-radius: var(--radius-sm);
    animation: shimmer 1.5s infinite;
}

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

/* ============================================================
   DELETE CONFIRMATION
   ============================================================ */
.confirm-delete-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 1100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.confirm-delete-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: 32px;
    max-width: 420px;
    text-align: center;
    box-shadow: var(--shadow-lg);
    animation: fadeInUp 0.3s ease;
}

.confirm-delete-icon {
    width: 56px;
    height: 56px;
    background: var(--danger-bg);
    border: 1px solid rgba(248, 113, 113, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
}

.confirm-delete-icon .material-icons-outlined {
    font-size: 28px;
    color: var(--danger);
}

.confirm-delete-card h3 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.confirm-delete-card p {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 24px;
}

.confirm-delete-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
}

/* ============================================================
   TYPEAHEAD / Search Results
   ============================================================ */
.search-results-list {
    list-style: none;
    background: var(--bg-surface-2);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    max-height: 240px;
    overflow-y: auto;
    box-shadow: var(--shadow-md);
}

.search-result-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    cursor: pointer;
    transition: background var(--transition-fast);
}

.search-result-item:hover {
    background: var(--bg-hover);
}

.search-result-item:not(:last-child) {
    border-bottom: 1px solid var(--border-color);
}

.result-info strong {
    display: block;
    font-size: 14px;
    color: var(--text-primary);
}

.result-info small {
    font-size: 12px;
    color: var(--text-muted);
}

.search-no-results {
    padding: 20px;
    text-align: center;
    font-size: 13px;
    color: var(--text-muted);
}

/* ============================================================
   RESPONSIVE — Phase 2 additions
   ============================================================ */
@media (max-width: 1024px) {
    .data-table-wrapper {
        overflow-x: auto;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

    .form-col-2 {
        grid-column: span 1;
    }
}

@media (max-width: 640px) {
    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }

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

    .search-box {
        min-width: 100%;
    }

    .modal-card {
        max-height: 100vh;
        border-radius: var(--radius-md);
    }

    .confirm-delete-actions {
        flex-direction: column;
    }
}

/* ============================================================
   PHASE 3 — Gate Control
   ============================================================ */

/* Gate Action Bar */
.gate-actions {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
}

.btn-lg {
    padding: 14px 24px;
    font-size: 15px;
    font-weight: 600;
}

.btn-accent {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: white;
}

.btn-accent:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(245, 158, 11, 0.3);
}

/* Tabs */
.gate-tabs {
    margin-bottom: 24px;
}

.tab-header {
    display: flex;
    gap: 4px;
    border-bottom: 2px solid var(--border-color);
    margin-bottom: 20px;
}

.tab-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.tab-btn:hover {
    color: var(--text-primary);
}

.tab-btn.active {
    color: var(--text-brand);
    border-bottom-color: var(--text-brand);
}

.tab-btn .material-icons-outlined {
    font-size: 20px;
}

.tab-badge {
    background: rgba(129, 140, 248, 0.15);
    color: var(--text-brand);
    padding: 2px 8px;
    border-radius: var(--radius-xl);
    font-size: 11px;
    font-weight: 700;
}

/* Gate Filters */
.gate-filters {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.form-select-inline {
    width: auto;
    min-width: 160px;
}

.form-input-inline {
    width: auto;
    min-width: 140px;
    padding: 10px 14px;
}

/* Entry Type Selector */
.entry-type-selector {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-bottom: 24px;
}

.entry-type-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 16px 12px;
    background: var(--bg-surface-2);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    font-size: 13px;
    color: var(--text-secondary);
    text-align: center;
}

.entry-type-option:hover {
    border-color: var(--border-hover);
    color: var(--text-primary);
}

.entry-type-option.active {
    border-color: var(--text-brand);
    background: rgba(129, 140, 248, 0.08);
    color: var(--text-brand);
}

.entry-type-option .material-icons-outlined {
    font-size: 28px;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
}

/* Modal XL */
.modal-xl {
    max-width: 780px;
}

/* Gate avatar variants */
.gate-avatar-employee {
    background: linear-gradient(135deg, #667eea, #764ba2) !important;
}

.gate-avatar-visitor {
    background: linear-gradient(135deg, #f59e0b, #d97706) !important;
}

.gate-avatar-service_provider {
    background: linear-gradient(135deg, #4facfe, #00f2fe) !important;
}

.gate-avatar-delivery {
    background: linear-gradient(135deg, #a78bfa, #7c3aed) !important;
}

.gate-avatar-employee .material-icons-outlined,
.gate-avatar-visitor .material-icons-outlined,
.gate-avatar-service_provider .material-icons-outlined,
.gate-avatar-delivery .material-icons-outlined {
    font-size: 18px;
}

.cell-person {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

/* Time Elapsed */
.time-elapsed {
    font-size: 12px;
    color: var(--warning);
    font-weight: 500;
}

/* Status Pulse */
.status-pulse {
    animation: pulse 2s ease-in-out infinite;
}

.stat-pulse {
    position: relative;
}

.stat-pulse::after {
    content: '';
    position: absolute;
    top: 12px;
    right: 12px;
    width: 8px;
    height: 8px;
    background: var(--success);
    border-radius: 50%;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* Action buttons */
.action-view {
    color: var(--text-muted);
}

.action-view:hover {
    background: rgba(129, 140, 248, 0.1);
    color: var(--text-brand);
}

.action-exit {
    color: var(--text-muted);
}

.action-exit:hover {
    background: var(--success-bg);
    color: var(--success);
}

/* Exit Confirm */
.confirm-exit-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: 32px;
    max-width: 440px;
    text-align: center;
    box-shadow: var(--shadow-lg);
    animation: fadeInUp 0.3s ease;
}

.confirm-exit-icon {
    width: 56px;
    height: 56px;
    background: var(--success-bg);
    border: 1px solid rgba(52, 211, 153, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
}

.confirm-exit-icon .material-icons-outlined {
    font-size: 28px;
    color: var(--success);
}

.confirm-exit-card h3 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.exit-person-info {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 12px;
}

.exit-person-info strong {
    font-size: 16px;
    color: var(--text-primary);
}

.exit-details {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 24px;
    line-height: 1.6;
}

/* Quick Entry */
.quick-entry-hint {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 20px;
    padding: 12px 16px;
    background: rgba(245, 158, 11, 0.05);
    border: 1px solid rgba(245, 158, 11, 0.1);
    border-radius: var(--radius-md);
}

.modal-header-accent {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.08), rgba(217, 119, 6, 0.04));
}

/* Detail View */
.detail-status-banner {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 24px;
}

.status-inside {
    background: var(--success-bg);
    color: var(--success);
    border: 1px solid rgba(52, 211, 153, 0.2);
}

.status-exited {
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.status-expired {
    background: var(--danger-bg);
    color: var(--danger);
    border: 1px solid rgba(248, 113, 113, 0.2);
}

.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.detail-section {
    background: var(--bg-surface-2);
    border-radius: var(--radius-md);
    padding: 16px;
}

.detail-section-title {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-brand);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 12px;
}

.detail-section-title .material-icons-outlined {
    font-size: 16px;
}

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

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

.detail-label {
    font-size: 12px;
    color: var(--text-muted);
}

.detail-value {
    font-size: 14px;
    color: var(--text-primary);
    font-weight: 500;
}

.detail-notes {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.6;
}

/* Checklist Sections */
.checklist-section {
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

.section-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 16px;
}

.section-title .material-icons-outlined {
    font-size: 20px;
    color: var(--text-brand);
}

.checklist-templates {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.checklist-template-card {
    background: var(--bg-surface-2);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 12px 16px;
}

.checklist-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 14px;
}

.checklist-toggle input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--text-brand);
}

.checklist-items-form {
    padding-top: 12px;
    border-top: 1px solid var(--border-color);
    margin-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.checklist-item-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.checklist-item-row .form-check {
    flex: 1;
}

.checklist-obs-input {
    max-width: 200px;
    padding: 6px 10px !important;
    font-size: 12px !important;
}

.required-mark {
    color: var(--danger);
    margin-left: 2px;
}

/* Checklist Responses (detail view) */
.checklist-responses-section {
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

.checklist-response-card {
    background: var(--bg-surface-2);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px;
    margin-bottom: 12px;
}

.checklist-response-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-color);
}

.checklist-items-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.checklist-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    padding: 4px 0;
}

.item-checked {
    color: var(--success);
}

.item-unchecked {
    color: var(--danger);
}

.checklist-item .material-icons-outlined {
    font-size: 18px;
}

.checklist-obs {
    font-size: 12px;
    color: var(--text-muted);
    margin-left: auto;
    font-style: italic;
}

/* Textarea */
.form-textarea {
    resize: vertical;
    min-height: 60px;
}

/* Responsive Phase 3 */
@media (max-width: 1024px) {
    .entry-type-selector {
        grid-template-columns: repeat(2, 1fr);
    }

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

@media (max-width: 640px) {
    .gate-actions {
        flex-direction: column;
    }

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

    .form-select-inline,
    .form-input-inline {
        width: 100%;
    }

    .tab-header {
        overflow-x: auto;
    }

    .entry-type-selector {
        grid-template-columns: 1fr 1fr;
    }

    .checklist-item-row {
        flex-direction: column;
        align-items: flex-start;
    }

    .checklist-obs-input {
        max-width: 100%;
    }
}

/* ============================================================
   PHASE 4 — Dashboard & Reports
   ============================================================ */

/* Stats Grid Variants */
.stats-grid-4 {
    grid-template-columns: repeat(4, 1fr);
}

.stats-grid-3 {
    grid-template-columns: repeat(3, 1fr);
}

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

.stat-mini {
    padding: 16px;
}

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

.stat-icon-sm .material-icons-outlined {
    font-size: 22px;
}

.stat-value-sm {
    font-size: 22px;
}

/* Chart Cards */
.dashboard-charts {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
    margin-bottom: 24px;
}

.chart-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.chart-header {
    padding: 16px 20px 0;
}

.chart-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.chart-title .material-icons-outlined {
    font-size: 18px;
    color: var(--text-brand);
}

.chart-body {
    padding: 8px 12px 12px;
    min-height: 200px;
}

.chart-wide {
    grid-column: span 1;
}

/* Department Bar List */
.dept-list {
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.dept-item {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.dept-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.dept-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
}

.dept-count {
    font-size: 12px;
    color: var(--text-muted);
}

.dept-bar-container {
    height: 6px;
    background: var(--bg-surface-2);
    border-radius: 3px;
    overflow: hidden;
}

.dept-bar {
    height: 100%;
    background: linear-gradient(90deg, #818cf8, #6366f1);
    border-radius: 3px;
    min-width: 4px;
    transition: width 0.6s ease;
}

/* Activity Feed */
.dashboard-activity {
    margin-bottom: 24px;
}

.activity-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
}

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

.activity-feed {
    max-height: 420px;
    overflow-y: auto;
}

.activity-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    border-bottom: 1px solid var(--border-color);
    transition: background var(--transition-fast);
}

.activity-item:last-child {
    border-bottom: none;
}

.activity-item:hover {
    background: var(--bg-hover);
}

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

.activity-icon .material-icons-outlined {
    font-size: 18px;
    color: white;
}

.activity-icon-employee { background: linear-gradient(135deg, #667eea, #764ba2); }
.activity-icon-visitor { background: linear-gradient(135deg, #f59e0b, #d97706); }
.activity-icon-service_provider { background: linear-gradient(135deg, #4facfe, #00f2fe); }
.activity-icon-delivery { background: linear-gradient(135deg, #a78bfa, #7c3aed); }

.activity-content {
    flex: 1;
    min-width: 0;
}

.activity-main {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 2px;
}

.activity-main strong {
    font-size: 14px;
    color: var(--text-primary);
}

.activity-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-muted);
}

.activity-time {
    color: var(--text-muted);
    opacity: 0.7;
}

.activity-status {
    flex-shrink: 0;
}

/* Empty State SM */
.empty-state-sm {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 40px 20px;
    color: var(--text-muted);
    font-size: 13px;
}

.empty-state-sm .material-icons-outlined {
    font-size: 32px;
    opacity: 0.4;
}

/* Button SM */
.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

/* ============================================================
   REPORTS
   ============================================================ */

/* Report Cards */
.report-cards {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.report-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px 24px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    text-decoration: none;
    transition: all var(--transition-normal);
}

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

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

.report-card-icon .material-icons-outlined {
    font-size: 26px;
}

.report-card-content {
    flex: 1;
}

.report-card-content h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.report-card-content p {
    font-size: 13px;
    color: var(--text-muted);
}

.report-card-arrow {
    color: var(--text-muted);
    font-size: 20px;
    transition: transform var(--transition-fast);
}

.report-card:hover .report-card-arrow {
    transform: translateX(4px);
    color: var(--text-brand);
}

/* Report Filters */
.report-filters {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-bottom: 24px;
}

.report-filters-form {
    display: flex;
    align-items: flex-end;
    gap: 16px;
    flex-wrap: wrap;
}

.report-filters-form .form-group {
    margin-bottom: 0;
    min-width: 140px;
}

.report-filter-btn {
    flex-shrink: 0;
}

/* Report Summary */
.report-summary {
    display: flex;
    gap: 24px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.summary-stat {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.summary-value {
    font-size: 28px;
    font-weight: 800;
    color: var(--text-primary);
}

.summary-label {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

/* Report Chart */
.report-chart {
    margin-bottom: 24px;
}

/* Report Note */
.report-note {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    margin-top: 16px;
    background: var(--info-bg);
    color: var(--info);
    border: 1px solid rgba(96, 165, 250, 0.2);
    border-radius: var(--radius-md);
    font-size: 13px;
}

/* Table Empty */
.td-empty {
    text-align: center;
    padding: 40px 20px !important;
    color: var(--text-muted);
    font-size: 14px;
}

/* Frequency Bar */
.frequency-value {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-brand);
}

.frequency-bar-container {
    height: 8px;
    background: var(--bg-surface-2);
    border-radius: 4px;
    overflow: hidden;
    min-width: 120px;
}

.frequency-bar {
    height: 100%;
    background: linear-gradient(90deg, #34d399, #059669);
    border-radius: 4px;
    min-width: 4px;
    transition: width 0.6s ease;
}

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

    .dashboard-charts {
        grid-template-columns: 1fr;
    }

    .report-filters-form {
        flex-direction: column;
        align-items: stretch;
    }
}

@media (max-width: 640px) {
    .stats-grid-4 { grid-template-columns: 1fr 1fr; }
    .stats-grid-3 { grid-template-columns: 1fr; }
    .stats-grid-2 { grid-template-columns: 1fr; }

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

/* ============================================================
   Premium Photo Uploader
   ============================================================ */

.form-profile-header {
    display: flex;
    gap: 24px;
    align-items: flex-start;
    margin-bottom: 24px;
    background: var(--bg-surface-2);
    padding: 20px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
}

.photo-upload-card {
    flex-shrink: 0;
}

.photo-upload-label {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 110px;
    height: 110px;
    border-radius: 24px;
    border: 2px dashed rgba(255, 255, 255, 0.2);
    background: var(--bg-surface);
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition: all var(--transition-normal);
    box-shadow: var(--shadow-sm);
}

.photo-upload-label:hover {
    border-color: var(--text-brand);
    transform: translateY(-2px);
    box-shadow: var(--shadow-glow);
}

.photo-upload-label.has-image {
    border-style: solid;
    border-color: transparent;
    padding: 0;
}

.photo-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    color: var(--text-muted);
}

.photo-placeholder .material-icons-outlined {
    font-size: 28px;
    background: linear-gradient(135deg, #a78bfa, #818cf8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.photo-text {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.photo-preview-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.photo-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    backdrop-filter: blur(2px);
    transition: opacity var(--transition-fast);
}

.photo-upload-label:hover .photo-overlay {
    opacity: 1;
}

.photo-overlay .material-icons-outlined {
    color: white;
    font-size: 28px;
}

.profile-main-fields {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 16px;
    justify-content: center;
    width: 100%;
}

@media (max-width: 640px) {
    .form-profile-header {
        flex-direction: column;
        align-items: center;
        text-align: center;
        padding: 16px;
    }
}

/* ============================================================
   PHASE 5 — Settings & Audit
   ============================================================ */

/* Settings Layout */
.settings-layout {
    display: flex;
    gap: 32px;
    align-items: flex-start;
}

/* Settings Sidebar */
.settings-nav {
    width: 240px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.settings-nav-title {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0 16px;
    margin-bottom: 8px;
}

.settings-nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
}

.settings-nav-item .material-icons-outlined {
    font-size: 20px;
}

.settings-nav-item:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.settings-nav-item.active {
    color: var(--text-brand);
    background: rgba(129, 140, 248, 0.1);
}

/* Settings Content */
.settings-content {
    flex: 1;
    min-width: 0;
}

.settings-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 32px;
}

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

.settings-header h2 {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 6px;
}

.form-section-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 16px;
}

.form-divider {
    height: 1px;
    background: var(--border-color);
    margin: 32px 0;
}

.settings-actions {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid var(--border-color);
}

/* Toggles / Preferences */
.preferences-toggles {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-top: 24px;
}

.toggle-style {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.toggle-style input[type="checkbox"] {
    margin-top: 2px;
    width: 20px;
    height: 20px;
}

.toggle-content {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.toggle-content .form-check-label {
    font-size: 15px;
    font-weight: 500;
}

/* Color Pickers */
.colors-grid {
    grid-template-columns: repeat(3, 1fr);
}

.color-input-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
}

.color-picker {
    appearance: none;
    -webkit-appearance: none;
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    background: none;
    padding: 0;
    overflow: hidden;
    box-shadow: 0 0 0 1px var(--border-color);
}

.color-picker::-webkit-color-swatch-wrapper {
    padding: 0;
}

.color-picker::-webkit-color-swatch {
    border: none;
    border-radius: 8px;
}

.color-hex {
    font-family: 'Courier New', Courier, monospace;
    font-size: 14px;
    color: var(--text-secondary);
    background: var(--bg-surface-2);
    padding: 6px 12px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
}

/* File Previews */
.file-preview-group {
    display: flex;
    flex-direction: column;
}

.current-image-preview {
    margin-bottom: 12px;
    border-radius: var(--radius-md);
    border: 1px dashed var(--border-color);
    padding: 12px;
    background: var(--bg-surface-2);
    display: inline-flex;
    justify-content: center;
    align-items: center;
}

.logo-preview img {
    max-height: 50px;
    max-width: 200px;
    object-fit: contain;
}

.favicon-preview img {
    width: 32px;
    height: 32px;
    object-fit: cover;
}

.bg-preview img {
    max-height: 100px;
    max-width: 100%;
    object-fit: cover;
    border-radius: 4px;
}

/* Audit JSON Diff */
.audit-json-diff {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-top: 16px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

.json-panel {
    background: var(--bg-surface-2);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.json-panel h4 {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    padding: 10px 16px;
    background: rgba(0,0,0,0.2);
    border-bottom: 1px solid var(--border-color);
}

.json-panel-old h4 { color: var(--danger); }
.json-panel-new h4 { color: var(--success); }

.json-content {
    margin: 0;
    padding: 16px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 13px;
    line-height: 1.5;
    color: var(--text-secondary);
    overflow-x: auto;
    max-height: 300px;
    overflow-y: auto;
}

/* Responsive Phase 5 */
@media (max-width: 900px) {
    .settings-layout {
        flex-direction: column;
    }
    
    .settings-nav {
        width: 100%;
        flex-direction: row;
        gap: 8px;
        overflow-x: auto;
        padding-bottom: 8px;
    }
    
    .settings-nav-title {
        display: none;
    }
    
    .settings-nav-item {
        white-space: nowrap;
    }
    
    .colors-grid {
        grid-template-columns: 1fr;
    }
    
    .audit-json-diff {
        grid-template-columns: 1fr;
    }
}

