/* ==========================================================================
   1. VARIABLES & THEME CONFIGURATION
   ========================================================================== */

/* Light Mode (Default) */
:root {
    --bg: #f7f9fc;
    --card-bg: #ffffff;
    --border: #e5e7eb;
    --border-subtle: #edf0f7;
    --text: #111827;
    --muted: #6b7280;
    --primary: #2563eb;
    --primary-soft: #eff6ff;
    --primary-border: #bfdbfe;
    --accent: #22c55e;
    --sidebar-bg: #020617;
    --sidebar-active: #111827;
    --sidebar-border: #020617;
}

/* Dark Mode Overrides */
body.dark {
    --bg: #020617;
    --card-bg: #020617;
    --border: #1f2937;
    --border-subtle: #111827;
    --text: #e2e8f0;
    --muted: #94a3b8;
    --primary: #3b82f6;
    --primary-soft: #0b1120;
    --primary-border: #1d4ed8;
    --accent: #22c55e;
    --sidebar-bg: #000000;
    --sidebar-active: #020617;
    --sidebar-border: #000000;
}

/* ==========================================================================
   2. GLOBAL RESET & BASE STYLES
   ========================================================================== */

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 14px;
    line-height: 1.5;
    height: 100vh;
    display: flex;
    overflow: hidden;
    background: var(--bg);
    color: var(--text);
}

a {
    color: inherit;
    text-decoration: none;
}

/* General Icon Utility */
.icon {
    width: 18px;
    height: 18px;
    vertical-align: middle;
}

/* ==========================================================================
   3. ANIMATIONS
   ========================================================================== */

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        transform: translateY(8px);
        opacity: 0;
    }

    to {
        transform: none;
        opacity: 1;
    }
}

.animate {
    animation: fadeIn .5s ease;
}

.slide {
    animation: slideUp .35s ease;
}

/* ==========================================================================
   4. AUTHENTICATION (LOGIN & REGISTER)
   ========================================================================== */

#login-screen {
    position: fixed;
    inset: 0;
    background: radial-gradient(circle at top,#e5edff 0,#99b3ff 20%,#0f172a 80%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
}

/* Auth Cards */
.login-box, .auth-card {
    background: #ffffff;
    border-radius: 18px;
    padding: 26px 30px 22px;
    max-width: 420px;
    width: 100%;
    box-shadow: 0 20px 55px rgba(15,23,42,.5);
    text-align: center;
}

.auth-card {
    margin: 40px auto;
    padding: 24px 24px 18px;
    box-shadow: 0 18px 45px rgba(15, 23, 42, 0.16);
    text-align: left;
}

/* Headers & Text */
.login-title {
    font-size: 22px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 4px;
}

.login-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
}

.login-heading {
    display: flex;
    flex-direction: column;
}

.login-title-text {
    font-weight: 600;
    font-size: 18px;
}

.login-sub {
    color: #4b5563;
    font-size: 13px;
    margin-bottom: 6px;
}

.login-meta {
    color: #6b7280;
    font-size: 11px;
    margin-bottom: 10px;
}

    .login-meta .muted {
        color: #9ca3af;
    }

.login-hint {
    font-size: 11px;
    color: #6b7280;
    margin-top: 6px;
}

.login-icon {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: rgba(59, 130, 246, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
}

    .login-icon .icon {
        width: 20px;
        height: 20px;
        fill: #2563eb;
    }

/* Auth Buttons */
.login-btn {
    margin-top: 6px;
    padding: 9px 20px;
    border-radius: 999px;
    border: none;
    background: #2563eb;
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 10px 25px rgba(37,99,235,.4);
    transition: background .15s ease,transform .1s ease,box-shadow .15s ease;
}

    .login-btn:hover {
        background: #1d4ed8;
        transform: translateY(-1px);
        box-shadow: 0 14px 32px rgba(37,99,235,.45);
    }

.auth-primary-btn {
    width: 100%;
    margin-top: 4px;
    border-radius: 999px;
    border: none;
    padding: 8px 0;
    font-size: 14px;
    font-weight: 600;
    color: #fff;
    background: linear-gradient(135deg, #2563eb, #4f46e5);
    cursor: pointer;
    box-shadow: 0 10px 25px rgba(37, 99, 235, 0.35);
    transition: transform 0.08s ease-out, box-shadow 0.08s ease-out, opacity 0.15s;
}

    .auth-primary-btn:disabled {
        opacity: 0.6;
        cursor: default;
        box-shadow: none;
    }

    .auth-primary-btn:hover:not(:disabled) {
        transform: translateY(-1px);
        box-shadow: 0 14px 30px rgba(37, 99, 235, 0.4);
    }

    .auth-primary-btn:active:not(:disabled) {
        transform: translateY(0);
        box-shadow: 0 8px 18px rgba(37, 99, 235, 0.35);
    }

/* Auth Tabs */
.auth-tabs {
    display: flex;
    gap: 4px;
    padding: 4px;
    border-radius: 999px;
    background: #f3f4f6;
    margin-bottom: 14px;
}

.auth-tab {
    flex: 1;
    border: none;
    background: transparent;
    border-radius: 999px;
    padding: 6px 0;
    font-size: 13px;
    cursor: pointer;
    color: #6b7280;
    transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}

    .auth-tab.active {
        background: #ffffff;
        color: #111827;
        box-shadow: 0 4px 12px rgba(15, 23, 42, 0.12);
    }

/* Auth Inputs & Forms */
.auth-form {
    display: none;
}

    .auth-form.active {
        display: block;
    }

.login-form {
    display: grid;
    gap: 8px;
    margin-top: 4px;
}

    .login-form input {
        padding: 8px 10px;
        border-radius: 10px;
        border: 1px solid #d1d5db;
        font-size: 13px;
        width: 100%;
    }

.auth-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 10px;
}

    .auth-field label {
        font-size: 12px;
        color: #4b5563;
    }

    .auth-field input {
        border-radius: 9px;
        border: 1px solid #e5e7eb;
        padding: 8px 10px;
        font-size: 13px;
        outline: none;
        transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
    }

        .auth-field input:focus {
            border-color: #2563eb;
            box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.25);
            background: #f9fafb;
        }

.auth-field-inline {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

/* Auth Alerts */
.auth-error, #regError,
.auth-success, #regSuccess {
    font-size: 13px;
    line-height: 1.4;
    margin-top: 8px;
    border-radius: 8px;
    padding: 8px 10px;
}

.auth-error, #regError {
    background: rgba(220, 38, 38, 0.06);
    border: 1px solid rgba(220, 38, 38, 0.35);
    color: #b91c1c;
}

.auth-success, #regSuccess {
    background: rgba(22, 163, 74, 0.06);
    border: 1px solid rgba(22, 163, 74, 0.35);
    color: #15803d;
}

    .auth-error:empty, #regError:empty,
    .auth-success:empty, #regSuccess:empty {
        display: none;
    }

/* ==========================================================================
   5. SIDEBAR NAVIGATION
   ========================================================================== */

.sidebar {
    width: 230px;
    background: var(--sidebar-bg);
    color: #e5e7eb;
    display: flex;
    flex-direction: column;
    padding: 16px 0;
    border-right: 1px solid var(--sidebar-border);
}

/* Logo */
.logo {
    padding: 0 18px 12px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-icon-wrapper {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: #111827;
    display: flex;
    align-items: center;
    justify-content: center;
}

.logo-title {
    font-size: 18px;
    font-weight: 700;
}

.logo-sub {
    font-size: 11px;
    color: #9ca3af;
    padding: 0 18px;
    margin-bottom: 8px;
}

/* Nav Items */
.nav-section-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: #6b7280;
    padding: 6px 18px 4px;
}

.nav-item {
    padding: 8px 18px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    color: #e5e7eb;
    cursor: pointer;
    border-left: 3px solid transparent;
    transition: background .12s ease,border-color .12s ease,color .12s ease;
}

    .nav-item:hover {
        background: #020617;
    }

    .nav-item.active {
        background: #020617;
        border-left-color: var(--primary);
        color: #fff;
    }

.nav-label {
    font-weight: 500;
}

/* Sidebar Footer & User */
.sidebar-footer {
    margin-top: auto;
    padding: 16px 18px 18px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.sidebar-account {
    background: rgba(255, 255, 255, 0.04);
    border-radius: 12px;
    padding: 8px 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.sidebar-account-label, .sidebar-user-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: rgba(255, 255, 255, 0.55);
}

.sidebar-account-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.sidebar-account-email, .sidebar-user-email {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.9);
    flex: 1 1 auto;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-user {
    background: rgba(255, 255, 255, 0.04);
    border-radius: 12px;
    padding: 8px 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.sidebar-user-meta {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Sidebar Buttons */
.sidebar-logout-btn {
    border: none;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 999px;
    width: 26px;
    height: 26px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
}

    .sidebar-logout-btn .icon {
        width: 14px;
        height: 14px;
        fill: rgba(255, 255, 255, 0.9);
    }

    .sidebar-logout-btn:hover {
        background: rgba(255, 255, 255, 0.18);
    }

.sidebar-switcher-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: #fff;
    border: none;
    padding: 10px 12px;
    border-radius: 12px;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
    text-align: left;
}

    .sidebar-switcher-btn:hover {
        transform: translateY(-1px);
        box-shadow: 0 6px 16px rgba(37, 99, 235, 0.4);
    }

.switcher-icon {
    width: 24px;
    height: 24px;
    background: rgba(255,255,255,0.2);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
}

    .switcher-icon .icon {
        width: 14px;
        height: 14px;
        fill: #fff;
    }

.switcher-text {
    font-size: 13px;
    font-weight: 600;
    flex: 1;
}

.switcher-arrow .icon {
    width: 14px;
    height: 14px;
    opacity: 0.7;
}

/* Theme Toggle */
.theme-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 11px;
    color: rgba(255, 255, 255, 0.6);
    padding: 0;
    margin: 0;
}

.theme-toggle-btn {
    border: none;
    border-radius: 999px;
    padding: 4px 10px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.06);
    color: #fff;
    width: auto;
}

    .theme-toggle-btn .icon {
        width: 14px;
        height: 14px;
    }

    .theme-toggle-btn:hover {
        background: rgba(255, 255, 255, 0.12);
    }

/* ==========================================================================
   6. LAYOUT & CONTAINERS
   ========================================================================== */

.main {
    flex: 1;
    overflow-y: auto;
    padding: 18px 22px;
    background: var(--bg);
}

.container-max {
    max-width: 1200px;
    margin: 0 auto;
}

.card {
    background: var(--card-bg);
    padding: 16px 18px;
    border-radius: 12px;
    border: 1px solid var(--border);
    box-shadow: 0 8px 20px rgba(15,23,42,.06);
    margin-bottom: 16px;
}

    .card h2 {
        margin: 0 0 8px;
        font-size: 16px;
        font-weight: 600;
        display: flex;
        align-items: center;
        gap: 8px;
    }

.header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.dash-grid-row {
    display: grid;
    grid-template-columns: 1.6fr 1fr;
    gap: 16px;
    align-items: stretch;
    margin-top: 16px;
}

/* ==========================================================================
   7. COMPONENT: BUTTONS
   ========================================================================== */

.btn {
    border-radius: 8px;
    border: 1px solid transparent;
    background: var(--primary);
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    padding: 7px 12px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    transition: background .12s ease,box-shadow .12s ease,transform .08s ease;
}

    .btn:hover {
        background: #1d4ed8;
        box-shadow: 0 6px 16px rgba(37,99,235,.25);
        transform: translateY(-1px);
    }

/* Standard Primary Button */
.btn-primary {
    background: var(--primary);
    color: #fff;
    border: 1px solid transparent;
}

    .btn-primary:hover {
        background: #1d4ed8;
        box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
    }

.btn-secondary {
    background: #fff;
    color: #111827;
    border-color: var(--border);
    box-shadow: none;
}

    .btn-secondary:hover {
        background: #f3f4f6;
        box-shadow: 0 3px 8px rgba(15,23,42,.08);
    }

.btn-small {
    padding: 5px 10px;
    border-radius: 7px;
    font-size: 12px;
}

.btn-text {
    background: none;
    border: none;
    color: #64748b;
    font-size: 13px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

    .btn-text:hover {
        color: #1e293b;
    }

/* Document Upload Button */
.btn-xs-upload {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    font-weight: 500;
    padding: 2px 8px;
    border-radius: 4px;
    background: #fff;
    border: 1px solid var(--primary);
    color: var(--primary);
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}

    .btn-xs-upload:hover {
        background: var(--primary-soft);
    }

    .btn-xs-upload input[type="file"] {
        display: none;
    }

.icon-btn {
    width: 26px;
    height: 26px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background .12s ease,border-color .12s ease,transform .06s ease;
}

    .icon-btn:hover {
        background: #f3f4f6;
        border-color: var(--primary-border);
        transform: translateY(-1px);
    }

.icon-pill {
    width: 28px;
    height: 28px;
    border-radius: 999px;
    background: var(--primary-soft);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
}

.back-link {
    font-size: 12px;
    color: var(--muted);
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    margin-bottom: 6px;
}

    .back-link:hover {
        color: var(--text);
    }

/* ==========================================================================
   8. COMPONENT: CARDS & LISTS
   ========================================================================== */

/* Feed / Activity Stream */
.feed-container {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.feed {
    display: grid;
    gap: 8px;
    margin-top: 6px;
}

.feed-item {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    padding: 12px 10px;
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    background: #fff;
    margin-bottom: 8px;
    transition: background 0.15s ease;
}

    .feed-item:hover {
        background: var(--bg);
    }

.feed-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #2563eb;
    margin-top: 6px;
    flex-shrink: 0;
}

.feed-text {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 2px;
}

.feed-sub {
    font-size: 12px;
    color: var(--muted);
}

/* Order Cards */
.order-card, .project-card {
    background: var(--card-bg);
    padding: 12px;
    border-radius: 10px;
    border: 1px solid var(--border-subtle);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

    .order-card.clickable, .project-card.clickable {
        cursor: pointer;
    }

        .order-card.clickable:hover, .project-card.clickable:hover {
            border-color: var(--primary-border);
            background: var(--primary-soft);
        }

.order-logo {
    width: 32px;
    height: 32px;
    border-radius: 999px;
    background: #e0ebff;
    color: #1d4ed8;
    border: 1px solid #bfdbfe;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    flex-shrink: 0;
    overflow: hidden;
}

    .order-logo img {
        width: 100%;
        height: 100%;
        object-fit: cover;
        border-radius: inherit;
    }

.order-title, .project-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}

.order-sub, .project-created, .project-sub {
    font-size: 12px;
    color: var(--muted);
    margin-top: 2px;
}

.project-sub {
    margin-top: 3px;
}

/* Candidate Lists (Shared) */
.user-list-container {
    display: flex;
    flex-direction: column;
    background: var(--card-bg);
    border-radius: 0 0 12px 12px;
}

.user-list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-subtle);
    background: var(--card-bg);
    transition: background 0.15s ease;
    cursor: pointer;
    gap: 16px;
}

    .user-list-item:hover {
        background: var(--bg);
    }

    .user-list-item:last-child {
        border-bottom: none;
        border-radius: 0 0 12px 12px;
    }

.user-main-content {
    display: flex;
    align-items: center;
    gap: 16px;
    flex: 1;
    min-width: 0;
}

.user-avatar {
    width: 44px;
    height: 44px;
    border-radius: 12px; /* Or 50% for circles */
    background: var(--bg-alt);
    color: var(--primary);
    font-weight: 700;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    border: 1px solid var(--border-subtle);
}

.user-details {
    display: flex;
    flex-direction: column;
    gap: 3px;
    overflow: hidden;
    min-width: 0;
}

.user-email {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-meta-row {
    font-size: 12px;
    color: var(--muted);
    display: flex;
    align-items: center;
    gap: 6px;
}

    .user-meta-row.muted {
        opacity: 0.6;
    }

    .user-meta-row .icon {
        width: 14px;
        height: 14px;
    }

.user-actions-group {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-shrink: 0;
}

.user-roles-list {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.user-edit-btn {
    padding: 6px 12px;
    height: 34px;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Split Candidate View */
.split-cands {
    display: grid;
    grid-template-columns: minmax(0,1.2fr) minmax(0,1.4fr);
    gap: 10px;
    align-items: stretch;
}

.cand-list {
    background: var(--card-bg);
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
    padding: 8px;
    max-height: 420px;
    overflow: auto;
}

.cand-detail {
    background: var(--card-bg);
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
    padding: 10px;
    min-height: 220px;
    position: relative;
}

.cand-row {
    display: flex;
    gap: 8px;
    align-items: center;
    padding: 7px 8px;
    border-radius: 8px;
    border: 1px solid transparent;
    cursor: pointer;
}

    .cand-row:hover, .cand-row.active {
        background: var(--primary-soft);
        border-color: var(--primary-border);
    }

.cand-meta {
    font-size: 11px;
    color: var(--muted);
    font-weight: 500;
}

.role-group-header {
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
    padding: 4px 2px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-subtle);
    margin-bottom: 2px;
}

.emp-avatar {
    width: 32px;
    height: 32px;
    border-radius: 999px;
    background: var(--primary-soft);
    border: 1px solid var(--primary-border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    color: var(--primary);
    flex-shrink: 0;
    overflow: hidden;
}

    .emp-avatar img {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }

/* ==========================================================================
   9. COMPONENT: BADGES & PROGRESS
   ========================================================================== */

/* Progress Bar */
.role-progress-bar {
    height: 5px;
    border-radius: 999px;
    background: #e5e7eb;
    overflow: hidden;
    margin-top: 2px;
}

.role-progress-fill {
    height: 100%;
    background: linear-gradient(90deg,var(--primary),var(--accent));
    transition: width 0.3s ease;
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 999px;
    border: 1px solid var(--border);
    margin-left: 6px;
}

    /* Light Mode Badge Colors */
    .badge.searching {
        background: #eff6ff;
        border-color: #bfdbfe;
        color: #1d4ed8;
    }

    .badge.docs {
        background: #eef2ff;
        border-color: #c7d2fe;
        color: #4338ca;
    }

    .badge.offer {
        background: #fffbeb;
        border-color: #fcd34d;
        color: #b45309;
    }

    .badge.permit {
        background: #faf5ff;
        border-color: #e9d5ff;
        color: #7e22ce;
    }

    .badge.arrival {
        background: #ecfeff;
        border-color: #a5f3fc;
        color: #0e7490;
    }

    .badge.completed {
        background: #f0fdf4;
        border-color: #bbf7d0;
        color: #15803d;
    }

    .badge.miss {
        background: #fef2f2;
        border-color: #fecaca;
        color: #b91c1c;
    }

/* Dark Mode Badge Colors */
body.dark .badge.searching {
    background: #172554;
    border-color: #1e3a8a;
    color: #93c5fd;
}

body.dark .badge.docs {
    background: #312e81;
    border-color: #3730a3;
    color: #a5b4fc;
}

body.dark .badge.offer {
    background: #451a03;
    border-color: #78350f;
    color: #fcd34d;
}

body.dark .badge.permit {
    background: #581c87;
    border-color: #6b21a8;
    color: #d8b4fe;
}

body.dark .badge.arrival {
    background: #164e63;
    border-color: #155e75;
    color: #67e8f9;
}

body.dark .badge.completed {
    background: #064e3b;
    border-color: #065f46;
    color: #86efac;
}

body.dark .badge.miss {
    background: #7f1d1d;
    border-color: #991b1b;
    color: #fca5a5;
}

.badge-stage {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 500;
    padding: 3px 8px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: #f3f4f6;
    color: #374151;
}

.tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 10px;
    font-weight: 600;
    padding: 3px 6px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: #f9fafb;
    color: var(--muted);
}

body.dark .tag {
    background: #020617;
}

.tag.ok {
    background: #ecfdf5;
    border-color: #a7f3d0;
    color: #047857;
}

.tag.warn {
    background: #fffbeb;
    border-color: #fbbf24;
    color: #92400e;
}

.tag.miss {
    background: #fef2f2;
    border-color: #fecaca;
    color: #b91c1c;
}

/* Status Text Helpers */
.missing {
    color: #b91c1c;
    font-weight: 600;
}

.complete {
    color: #16a34a;
    font-weight: 600;
}

.weak-warning {
    margin-top: 8px;
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid #fbbf24;
    background: #fffbeb;
    font-size: 12px;
    color: #92400e;
}

/* Timeline */
.timeline {
    border-left: 1px solid var(--border-subtle);
    margin-top: 6px;
    padding-left: 10px;
    font-size: 11px;
}

.timeline-item {
    position: relative;
    margin-bottom: 6px;
}

.timeline-dot {
    position: absolute;
    left: -8px;
    top: 6px;
    width: 6px;
    height: 6px;
    border-radius: 999px;
    background: var(--primary); /* Fallback */
}

    /* Timeline Colors */
    .timeline-dot.searching {
        background: #1d4ed8;
    }

    .timeline-dot.docs {
        background: #4338ca;
    }

    .timeline-dot.offer {
        background: #b45309;
    }

    .timeline-dot.permit {
        background: #7e22ce;
    }

    .timeline-dot.arrival {
        background: #0e7490;
    }

    .timeline-dot.completed {
        background: #15803d;
    }

    .timeline-dot.miss {
        background: #b91c1c;
    }

/* Dark Mode Timeline */
body.dark .timeline-dot.searching {
    background: #3b82f6;
}

body.dark .timeline-dot.docs {
    background: #818cf8;
}

body.dark .timeline-dot.offer {
    background: #fbbf24;
}

body.dark .timeline-dot.permit {
    background: #a855f7;
}

body.dark .timeline-dot.arrival {
    background: #22d3ee;
}

body.dark .timeline-dot.completed {
    background: #4ade80;
}

body.dark .timeline-dot.miss {
    background: #f87171;
}

.pill-meta {
    font-size: 11px;
    color: var(--muted);
    padding: 2px 6px;
    border-radius: 999px;
    background: #f3f4f6;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.role-fulfilment {
    font-size: 12px;
    color: var(--muted);
    margin-top: 4px;
}

    .role-fulfilment span.missing {
        color: #b91c1c;
        font-weight: 600;
    }

    .role-fulfilment span.complete {
        color: #16a34a;
        font-weight: 600;
    }

.doc-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 10px;
    font-weight: 500;
    padding: 3px 6px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: #f3f4f6;
    margin: 2px 4px 0 0;
}

.doc-card-hover:hover {
    border-color: var(--primary-border) !important;
    background-color: var(--primary-soft) !important;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

/* ==========================================================================
   10. FORM LAYOUTS & GRIDS (Restored for Modals)
   ========================================================================== */

.form-section {
    margin-bottom: 16px;
}

.section-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.grid-row {
    display: grid;
    gap: 12px;
    margin-bottom: 12px;
}

.two-col {
    grid-template-columns: 1fr 1fr;
}

.three-col {
    grid-template-columns: 1fr 1fr 1fr;
}

.three-col-auto {
    grid-template-columns: 1fr auto auto;
    align-items: center;
}

/* Role Builder Specifics */
.role-builder-card {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 16px;
}

.role-inputs-grid {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.role-row-main {
    display: grid;
    grid-template-columns: 1fr 80px;
    gap: 10px;
}

.role-row-details {
    display: grid;
    grid-template-columns: 1fr 140px;
    gap: 10px;
}

.role-row-financials {
    display: grid;
    grid-template-columns: 1fr 1fr 80px;
    gap: 10px;
}

.role-action-row {
    margin-top: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.roles-preview-box {
    border: 1px dashed var(--border);
    border-radius: 6px;
    padding: 12px;
    min-height: 40px;
    background: #fff;
}

/* ==========================================================================
   11. COMPONENT: MODALS
   ========================================================================== */

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15,23,42,.45);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 40;
}

.modal {
    width: min(720px,94vw);
    background: var(--card-bg);
    border-radius: 12px;
    border: 1px solid var(--border);
    padding: 14px 16px 12px;
    box-shadow: 0 22px 60px rgba(15,23,42,.4);
    display: flex;
    flex-direction: column;
    max-height: 90vh;
}

    .modal.slide {
        max-width: 650px;
        width: 95%;
        padding: 0;
    }

.modal-header {
    padding: 20px 24px 10px;
}

.modal-subtitle {
    font-size: 13px;
    color: #666;
    margin: 4px 0 0;
}

.modal-body {
    padding: 0 24px 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 20px;
    max-height: 70vh;
}

.modal-footer {
    padding: 16px 24px;
    background: #f9fafb;
    border-top: 1px solid #eee;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    border-radius: 0 0 8px 8px;
}

.modal h3 {
    margin: 0 0 6px;
    font-size: 16px;
    font-weight: 600;
}

.modal p {
    margin: 0 0 8px;
    font-size: 12px;
    color: var(--muted);
}

.modal-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 8px;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
}

/* Modal Inputs */
.input-field,
.modal input, .modal select, .modal textarea {
    width: 100%;
    padding: 7px 9px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--card-bg);
    color: var(--text);
    font-size: 13px;
    font-weight: 500;
    outline: none;
}

    .input-field:focus,
    .modal input:focus, .modal select:focus, .modal textarea:focus {
        border-color: #2563eb;
    }

.modal textarea {
    resize: vertical;
    min-height: 70px;
}

/* Checkboxes */
.modal input[type="checkbox"] {
    width: auto;
    margin: 0;
    cursor: pointer;
}

.checkbox-label {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    cursor: pointer;
    width: 100%;
}

.roles-box {
    border-radius: 10px;
    border: 1px dashed var(--primary-border);
    background: var(--primary-soft);
    padding: 8px;
    margin-top: 4px;
}

.small-note {
    font-size: 11px;
    color: var(--muted);
    margin-top: 2px;
}

/* ==========================================================================
   12. COMPONENT: PORTAL SWITCHER MODAL
   ========================================================================== */

.portal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(4px);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
}

.portal-card {
    background: #ffffff;
    width: 100%;
    max-width: 400px;
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    text-align: center;
    color: #1e293b;
}

/* Dark Mode Portal Modal */
body.dark .portal-card {
    background: #1e293b;
    color: #fff;
    border: 1px solid #334155;
}

body.dark .portal-header h3 {
    color: #fff;
}

body.dark .portal-header p {
    color: #94a3b8;
}

body.dark .portal-item {
    background: #0f172a;
    border-color: #334155;
}

body.dark .portal-item-title {
    color: #fff;
}

body.dark .portal-item:hover {
    border-color: #3b82f6;
    background: #1e293b;
}

.portal-header h3 {
    font-size: 20px;
    font-weight: 700;
    color: #1e293b;
    margin: 12px 0 6px;
}

.portal-header p {
    font-size: 14px;
    color: #64748b;
    margin-bottom: 24px;
}

.portal-icon-wrapper {
    width: 48px;
    height: 48px;
    background: #eff6ff;
    color: #2563eb;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
}

    .portal-icon-wrapper .icon {
        width: 24px;
        height: 24px;
    }

.portal-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.portal-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    background: #fff;
    cursor: pointer;
    text-align: left;
    transition: all 0.2s ease;
}

    .portal-item:hover {
        border-color: #2563eb;
        background: #eff6ff;
        transform: translateY(-2px);
        box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.05);
    }

.portal-item-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: #f1f5f9;
    color: #64748b;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, color 0.2s;
}

.portal-item:hover .portal-item-icon {
    background: #2563eb;
    color: #ffffff;
}

.portal-item-info {
    flex: 1;
}

.portal-item-title {
    font-size: 15px;
    font-weight: 600;
    color: #1e293b;
}

.portal-item-desc {
    font-size: 12px;
    color: #64748b;
}

.portal-footer {
    margin-top: 24px;
}

/* ==========================================================================
   13. UTILITIES
   ========================================================================== */

/* Toast */
.toast {
    position: fixed;
    bottom: 18px;
    left: 50%;
    transform: translateX(-50%);
    background: #111827;
    color: #f9fafb;
    padding: 8px 14px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    opacity: 0;
    pointer-events: none;
    transition: .25s ease;
    z-index: 60;
}

/* Loading Overlay */
.pipeline-loading {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(15, 23, 42, 0.65);
    display: none;
    align-items: center;
    justify-content: center;
}

.pipeline-loading-box {
    background: #0f172a;
    color: #e5e7eb;
    padding: 1.5rem 2rem;
    border-radius: 0.75rem;
    box-shadow: 0 20px 40px rgba(15, 23, 42, 0.6);
    display: flex;
    align-items: center;
    gap: 1rem;
    min-width: 260px;
}

.pipeline-spinner {
    width: 28px;
    height: 28px;
    border-radius: 999px;
    border: 3px solid #1e293b;
    border-top-color: #38bdf8;
    animation: pipeline-spin 0.8s linear infinite;
}

.pipeline-loading-text {
    font-size: 0.95rem;
    font-weight: 500;
}

@keyframes pipeline-spin {
    to {
        transform: rotate(360deg);
    }
}

/* Filters & Grids */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    margin-bottom: 8px;
}

    .filter-bar input, .filter-bar select {
        padding: 6px 8px;
        border-radius: 8px;
        border: 1px solid var(--border);
        background: var(--card-bg);
        font-size: 12px;
        color: var(--text);
    }

.summary-grid {
    display: grid;
    grid-template-columns: repeat(4,minmax(0,1fr));
    gap: 8px;
    margin-top: 8px;
}

.summary-item {
    padding: 8px 9px;
    border-radius: 10px;
    border: 1px solid var(--border-subtle);
    background: var(--card-bg);
}

.summary-label {
    font-size: 11px;
    color: var(--muted);
    margin-bottom: 2px;
}

.summary-value {
    font-size: 15px;
    font-weight: 600;
}

/* Detail Grids */
.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 8px;
    font-size: 12px;
}

.detail-item {
    padding: 7px 8px;
    border-radius: 8px;
    border: 1px solid var(--border-subtle);
    background: var(--card-bg);
}

.detail-label {
    font-size: 10px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .06em;
    font-weight: 600;
}

.detail-value {
    margin-top: 4px;
    font-size: 13px;
    font-weight: 500;
}

.drawer-section-title {
    margin-top: 8px;
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
}

/* Shared Accordion */
.accordion-wrapper {
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows 0.3s ease-out;
}

    .accordion-wrapper.open {
        grid-template-rows: 1fr;
    }

.accordion-inner {
    overflow: hidden;
    min-height: 0;
}

.chevron-icon {
    transition: transform 0.3s ease;
}

    .chevron-icon.rotated {
        transform: rotate(90deg);
    }

/* ==========================================================================
   14. RESPONSIVE / MOBILE STYLES
   ========================================================================== */

/* 1. Mobile Header (Hidden on Desktop) */
.mobile-header {
    display: none;
    align-items: center;
    justify-content: space-between;
    height: 60px;
    padding: 0 16px;
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 40;
}

.mobile-menu-btn {
    background: none;
    border: none;
    padding: 8px;
    cursor: pointer;
    color: var(--text);
    display: flex;
    align-items: center;
    justify-content: center;
}

    .mobile-menu-btn .icon {
        width: 24px;
        height: 24px;
    }

.mobile-logo {
    font-weight: 700;
    font-size: 16px;
    color: var(--text);
}

/* 2. Sidebar Backdrop */
.sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 45;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
    backdrop-filter: blur(2px);
}

    .sidebar-backdrop.active {
        opacity: 1;
        pointer-events: auto;
    }

/* 3. Media Queries */
@media(max-width:1000px) {
    .split-cands {
        grid-template-columns: 1fr;
    }
}

@media(max-width:900px) {
    /* Show Header */
    .mobile-header {
        display: flex;
    }

    /* Push body down */
    body {
        padding-top: 60px;
    }

    /* Sidebar Drawer Logic */
    .sidebar {
        position: fixed;
        top: 0;
        bottom: 0;
        left: 0;
        width: 260px;
        transform: translateX(-100%);
        z-index: 50;
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: 4px 0 24px rgba(0,0,0,0.2);
        display: flex !important;
        height: 100vh;
    }

        .sidebar.active {
            transform: translateX(0);
        }

    /* Reset Main */
    .main {
        padding: 16px;
        margin-left: 0;
    }
}

@media(max-width:800px) {
    .summary-grid {
        grid-template-columns: repeat(2,minmax(0,1fr));
    }
}

@media (max-width: 650px) {
    .user-list-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .user-main-content {
        width: 100%;
        border-bottom: 1px dashed var(--border-subtle);
        padding-bottom: 12px;
    }

    .user-actions-group {
        width: 100%;
        justify-content: space-between;
        flex-direction: row-reverse;
    }

    .user-roles-list {
        justify-content: flex-start;
    }

    .user-edit-btn {
        padding: 6px 10px;
        font-size: 12px;
    }
}

/* Mobile responsive for form grids (Added for restored layouts) */
@media (max-width: 550px) {
    .two-col, .three-col {
        grid-template-columns: 1fr;
    }

    .three-col-auto {
        grid-template-columns: 1fr 1fr;
        row-gap: 10px;
    }

        .three-col-auto > :first-child {
            grid-column: 1 / -1;
        }

    .role-row-details, .role-row-financials {
        grid-template-columns: 1fr;
    }

    .role-row-main {
        grid-template-columns: 1fr 70px;
    }
}

/* Hide Desktop Bell on Mobile screens (under 900px) */
@media (max-width: 900px) {
    .desktop-only-bell {
        display: none !important;
    }
}
/* Hide Mobile Bell on Desktop screens */
@media (min-width: 901px) {
    .mobile-only-bell {
        display: none !important;
    }
}

/* ==========================================================================
   RESPONSIVE TABLE (MOBILE STACKED LAYOUT)
   ========================================================================== */
@media (max-width: 900px) {
    .responsive-table {
        display: block;
        width: 100%;
        background: transparent !important;
        border: none !important;
    }

        .responsive-table thead {
            display: none; /* Hide desktop headers */
        }

        .responsive-table tbody {
            display: flex;
            flex-direction: column;
            gap: 16px;
        }

        .responsive-table tr {
            display: flex;
            flex-direction: column;
            background: var(--card-bg, #fff) !important;
            border: 1px solid var(--border-subtle) !important;
            border-radius: 12px;
            padding: 8px 16px;
            box-shadow: 0 4px 10px rgba(0,0,0,0.03);
        }

        .responsive-table td {
            display: flex;
            justify-content: space-between;
            align-items: flex-start;
            padding: 12px 0 !important;
            border-bottom: 1px solid var(--border-subtle) !important;
        }

            .responsive-table td:last-child {
                border-bottom: none !important;
            }
            /* Inject the label from the data-label attribute */
            .responsive-table td::before {
                content: attr(data-label);
                font-size: 11px;
                font-weight: 700;
                text-transform: uppercase;
                color: var(--muted);
                margin-right: 16px;
                flex-shrink: 0;
                padding-top: 2px;
            }
            /* Ensure content inside aligns to the right on mobile */
            .responsive-table td .td-content {
                text-align: right;
                display: flex;
                flex-direction: column;
                align-items: flex-end;
                gap: 4px;
            }
}

/* --- Worker Compliance Highlighting --- */
.input-field.input-warning {
    border-color: #f59e0b !important;
    background-color: #fffbeb !important;
    color: #92400e;
}

.input-field.input-danger {
    border-color: #ef4444 !important;
    background-color: #fef2f2 !important;
    color: #b91c1c;
}

/* --- Skeleton Loader Animation --- */
@keyframes shimmer {
    0% {
        background-position: -800px 0;
    }

    100% {
        background-position: 800px 0;
    }
}

.skeleton-box {
    background: #f6f7f8;
    background-image: linear-gradient(to right, #f6f7f8 0%, #edeef1 20%, #f6f7f8 40%, #f6f7f8 100%);
    background-repeat: no-repeat;
    background-size: 800px 100%;
    animation: shimmer 1.5s infinite linear forwards;
    border-radius: 6px; /* Match your input border radius */
    width: 100%;
}

.btn-cancellation {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #b91c1c;
    width: 100%;
    justify-content: center;
    padding: 10px 16px;
    border-radius: 8px;
    font-weight: 600;
    transition: all 0.2s;
    cursor: pointer;
}

    .btn-cancellation:hover {
        background: #fee2e2;
        border-color: #f87171;
    }