: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;
}

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;
}

* {
    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;
}

.icon {
    width: 18px;
    height: 18px;
    vertical-align: middle;
}

@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;
}

/* LOGIN */
#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;
}

.login-box {
    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;
}

.login-title {
    font-size: 22px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 4px;
}

.login-sub {
    color: #4b5563;
    font-size: 13px;
    margin-bottom: 6px;
}

.login-meta {
    color: #6b7280;
    font-size: 11px;
    margin-bottom: 10px;
}

.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%;
    }

.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);
    }

.login-hint {
    font-size: 11px;
    color: #6b7280;
    margin-top: 6px;
}

/* SIDEBAR */
.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 {
    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-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;
}

.theme-toggle {
    margin-top: auto;
    padding: 12px 18px 4px;
    font-size: 11px;
    color: #9ca3af;
}

    .theme-toggle button {
        margin-top: 6px;
        width: 100%;
        padding: 7px 10px;
        border-radius: 999px;
        border: 1px solid rgba(148,163,184,.6);
        background: transparent;
        color: #e5e7eb;
        font-size: 11px;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 6px;
        transition: background .12s ease,border-color .12s ease;
    }

        .theme-toggle button:hover {
            background: rgba(15,23,42,.8);
            border-color: rgba(148,163,184,.9);
        }

/* MAIN LAYOUT */
.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;
}

.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);
    }

.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;
}

.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);
}

.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 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}

.order-sub {
    font-size: 12px;
    color: var(--muted);
    margin-top: 2px;
}

.project-title {
    font-size: 14px;
    font-weight: 600;
}

.project-created {
    font-size: 11px;
    color: var(--muted);
    margin-top: 2px;
}

.project-sub {
    font-size: 12px;
    color: var(--muted);
    margin-top: 3px;
}

.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);
    }

.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;
}

    .badge.searching {
        background: #eff6ff;
        border-color: #bfdbfe;
        color: #1d4ed8;
    }

    .badge.docs {
        background: #ecfdf5;
        border-color: #a7f3d0;
        color: #047857;
    }

    .badge.offer {
        background: #fffbeb;
        border-color: #fbbf24;
        color: #92400e;
    }

    .badge.permit {
        background: #fef2f2;
        border-color: #fecaca;
        color: #b91c1c;
    }

    .badge.arrival {
        background: #ecfeff;
        border-color: #67e8f9;
        color: #0e7490;
    }

    .badge.completed {
        background: #e5e7eb;
        border-color: #cbd5f5;
        color: #111827;
    }

body.dark .badge.completed {
    background: #1f2937;
    border-color: #4b5563;
    color: #e5e7eb;
}

.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;
}

.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;
    }

.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));
}

.weak-warning {
    margin-top: 8px;
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid #fbbf24;
    background: #fffbeb;
    font-size: 12px;
    color: #92400e;
}

/* FEED */
.feed {
    display: grid;
    gap: 8px;
    margin-top: 6px;
}

.feed-item {
    display: flex;
    gap: 8px;
    align-items: flex-start;
    padding: 8px 10px;
    border-radius: 10px;
    border: 1px solid var(--border-subtle);
    background: var(--card-bg);
}

.feed-dot {
    width: 8px;
    height: 8px;
    border-radius: 999px;
    background: var(--primary);
    margin-top: 6px;
}

.feed-text {
    font-size: 12px;
    font-weight: 600;
}

.feed-sub {
    font-size: 11px;
    color: var(--muted);
    margin-top: 2px;
}

/* FILTER BAR */
.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);
    }

/* SPLIT CANDIDATES (CLIENT VIEW) */
.split-cands {
    display: grid;
    grid-template-columns: minmax(0,1.2fr) minmax(0,1.4fr);
    gap: 10px;
    align-items: stretch;
}

@media(max-width:1000px) {
    .split-cands {
        grid-template-columns: 1fr;
    }
}

.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;
}

.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;
}

.cand-row {
    display: flex;
    gap: 8px;
    align-items: center;
    padding: 7px 8px;
    border-radius: 8px;
    border: 1px solid transparent;
    cursor: pointer;
}

    .cand-row:hover {
        background: var(--primary-soft);
        border-color: var(--primary-border);
    }

    .cand-row.active {
        background: var(--primary-soft);
        border-color: var(--primary-border);
    }

.cand-meta {
    font-size: 11px;
    color: var(--muted);
    font-weight: 500;
}

.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;
    }

.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;
}

.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);
}

.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: -6px;
    top: 3px;
    width: 6px;
    height: 6px;
    border-radius: 999px;
    background: var(--primary);
}

.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;
}

/* REQUIREMENT HEADER SUMMARY */
.summary-grid {
    display: grid;
    grid-template-columns: repeat(4,minmax(0,1fr));
    gap: 8px;
    margin-top: 8px;
}

@media(max-width:800px) {
    .summary-grid {
        grid-template-columns: repeat(2,minmax(0,1fr));
    }
}

.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;
}

/* 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);
}

    .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 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;
}

.modal textarea {
    resize: vertical;
    min-height: 70px;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
}

.small-note {
    font-size: 11px;
    color: var(--muted);
    margin-top: 2px;
}

.roles-box {
    border-radius: 10px;
    border: 1px dashed var(--primary-border);
    background: var(--primary-soft);
    padding: 8px;
    margin-top: 4px;
}

/* 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;
}

.pipeline-loading {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(15, 23, 42, 0.65); /* dark translucent */
    display: none; /* default hidden, JS shows it */
    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;
}

/* Card look */
.auth-card {
    max-width: 420px;
    margin: 40px auto;
    padding: 24px 24px 18px;
    border-radius: 18px;
    background: #ffffff;
    box-shadow: 0 18px 45px rgba(15, 23, 42, 0.16);
}

/* Header */
.login-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
}

.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;
    }

.login-heading {
    display: flex;
    flex-direction: column;
}

.login-title-text {
    font-weight: 600;
    font-size: 18px;
}

.login-sub {
    font-size: 13px;
    color: #6b7280;
}

.login-meta {
    margin-top: 6px;
    margin-bottom: 16px;
    font-size: 12px;
    color: #6b7280;
}

    .login-meta .muted {
        color: #9ca3af;
    }

/* 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);
    }

/* Forms */
.auth-form {
    display: none;
}

    .auth-form.active {
        display: block;
    }

.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-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 rgb @keyframes pipeline-spin {
    to {
        transform: rotate(360deg);
    }
}

@media(max-width:900px) {
    .sidebar {
        display: none;
    }

    .main {
        padding: 16px;
    }
}
