/* =====================================================================
   Maker MachShip Check - Vertilux Portal Design System
   Based on MakerBOMVisualiserWeb design system
   ===================================================================== */

:root {
    /* Brand */
    --orange: #de3a00;
    --orange-light: #f04010;
    --orange-dark: #b82e00;

    /* Structural */
    --charcoal: #1c1c1c;
    --charcoal-2: #242424;
    --charcoal-3: #2e2e2e;
    --white: #ffffff;
    --off-white: #f7f6f4;
    --surface: #ffffff;

    /* Greys */
    --grey-50: #fafafa;
    --grey-100: #f2f2f2;
    --grey-200: #e4e4e4;
    --grey-300: #cccccc;
    --grey-500: #888888;
    --grey-700: #444444;

    /* Text */
    --text: #1c1c1c;
    --text-light: #666666;

    /* Semantic */
    --error: #cc2200;
    --success: #1a7a40;

    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(0,0,0,.07);
    --shadow-md: 0 4px 16px rgba(0,0,0,.09);

    /* Radii */
    --radius: 5px;
    --radius-lg: 8px;

    /* Transition */
    --transition: 0.16s ease;

    /* Header */
    --header-h: 68px;

    /* Match row colours */
    --row-green-bg: #dcfce7;
    --row-green-text: #14532d;
    --row-red-bg: #fce4e4;
    --row-red-text: #7f1d1d;
}

*, *::before, *::after {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    font-size: 15px;
    color: var(--text);
    background: var(--off-white);
    height: 100%;
    line-height: 1.6;
}

/* -- App layout --------------------------------------------------------- */

.app-layout {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

/* -- Site header (Portal style) ----------------------------------------- */

.site-header {
    height: var(--header-h);
    background: var(--charcoal);
    border-bottom: 2px solid var(--orange);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.site-logo {
    display: flex;
    align-items: center;
    gap: 14px;
    text-decoration: none;
}

.site-logo img {
    height: 32px;
    display: block;
}

.site-logo__divider {
    width: 1px;
    height: 22px;
    background: rgba(255,255,255,0.2);
}

.site-logo__text {
    font-family: 'Segoe UI', system-ui, sans-serif;
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.14em;
    color: rgba(255,255,255,0.55);
    text-transform: uppercase;
    white-space: nowrap;
}

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

.nav-user {
    display: flex;
    align-items: center;
    gap: 8px;
    border-left: 1px solid rgba(255,255,255,0.12);
    padding-left: 18px;
}

.nav-user__email {
    font-size: 0.82rem;
    color: rgba(255,255,255,0.45);
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.nav-logout {
    padding: 7px 13px;
    background: rgba(222,58,0,0.12);
    color: rgba(255,255,255,0.75);
    border: 1px solid rgba(222,58,0,0.3);
    border-radius: var(--radius);
    font-size: 0.8rem;
    font-weight: 500;
    font-family: 'Segoe UI', sans-serif;
    cursor: pointer;
    transition: all var(--transition);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.nav-logout:hover {
    background: var(--orange);
    border-color: var(--orange);
    color: white;
}

/* -- Loading / redirect ------------------------------------------------- */

.loading-message {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    font-size: 0.95rem;
    color: var(--text-light);
    padding: 3rem;
}

/* -- Auth / Login page -------------------------------------------------- */

.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--charcoal);
    padding: 32px 16px;
    position: relative;
}

.auth-wrapper::before {
    content: '';
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(
        -55deg,
        transparent,
        transparent 39px,
        rgba(222,58,0,0.03) 39px,
        rgba(222,58,0,0.03) 40px
    );
    pointer-events: none;
}

.auth-card {
    background: white;
    max-width: 440px;
    width: 100%;
    padding: 48px 44px;
    border-radius: var(--radius-lg);
    box-shadow: 0 24px 64px rgba(0,0,0,.45);
    position: relative;
    z-index: 1;
}

.auth-logo {
    margin-bottom: 28px;
}

.auth-logo img {
    height: 40px;
    display: block;
}

.auth-title {
    font-family: 'Segoe UI', system-ui, sans-serif;
    font-size: 1.7rem;
    font-weight: 700;
    text-transform: uppercase;
    margin: 0 0 6px;
    color: var(--text);
    letter-spacing: 0.01em;
}

.auth-subtitle {
    font-size: 0.88rem;
    color: var(--text-light);
    line-height: 1.55;
    margin: 0 0 28px;
}

.auth-error {
    background: #fff1f0;
    color: #8a1500;
    border: 1px solid #ffc9c0;
    padding: 14px 16px;
    border-radius: var(--radius);
    margin-bottom: 20px;
    font-size: 0.88rem;
}

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

.form-label {
    display: block;
    font-size: 0.82rem;
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text);
    margin-bottom: 7px;
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid var(--grey-200);
    border-radius: var(--radius);
    font-size: 0.95rem;
    font-family: 'Segoe UI', sans-serif;
    color: var(--text);
    transition: border-color var(--transition), box-shadow var(--transition);
    background: white;
}

.form-control::placeholder {
    color: var(--grey-300);
}

.form-control:focus {
    outline: none;
    border-color: var(--orange);
    box-shadow: 0 0 0 3px rgba(222,58,0,0.10);
}

.btn-primary {
    width: 100%;
    height: 42px;
    background: var(--orange);
    color: white;
    border: 2px solid var(--orange);
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 400;
    font-family: 'Segoe UI', sans-serif;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    cursor: pointer;
    transition: all var(--transition);
    margin-top: 8px;
}

.btn-primary:hover:not(:disabled) {
    background: var(--orange-dark);
    border-color: var(--orange-dark);
}

.btn-primary:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

/* -- Filter panel ------------------------------------------------------- */

.filter-panel {
    background: var(--surface);
    border-bottom: 1px solid var(--grey-200);
    padding: 14px 28px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex-shrink: 0;
    box-shadow: var(--shadow-sm);
}

.filter-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 6px;
}

.filter-label {
    font-size: 0.82rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text);
    white-space: nowrap;
}

.filter-panel input[type="text"],
.filter-panel input[type="number"],
.filter-panel input[type="date"] {
    padding: 8px 14px;
    border: 1.5px solid var(--grey-200);
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-family: 'Segoe UI', sans-serif;
    color: var(--text);
    transition: border-color var(--transition), box-shadow var(--transition);
}

.filter-panel input:focus {
    outline: none;
    border-color: var(--orange);
    box-shadow: 0 0 0 3px rgba(222,58,0,0.10);
}

/* -- Step panels -------------------------------------------------------- */

.step-panel {
    background: var(--surface);
    border-bottom: 1px solid var(--grey-200);
    margin: 0;
    transition: opacity var(--transition);
}

.step-panel.step-disabled {
    opacity: 0.45;
    pointer-events: none;
}

.step-header {
    background: var(--charcoal);
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 28px;
}

.step-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--orange);
    color: white;
    font-size: 0.82rem;
    font-weight: 700;
    flex-shrink: 0;
}

.step-title {
    font-size: 0.82rem;
    font-weight: 600;
    color: rgba(255,255,255,0.85);
    text-transform: uppercase;
    letter-spacing: 0.07em;
}

.step-body {
    padding: 14px 28px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.step-body input[type="text"],
.step-body input[type="number"],
.step-body input[type="date"] {
    padding: 8px 14px;
    border: 1.5px solid var(--grey-200);
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-family: 'Segoe UI', sans-serif;
    color: var(--text);
    transition: border-color var(--transition), box-shadow var(--transition);
}

.step-body input:focus {
    outline: none;
    border-color: var(--orange);
    box-shadow: 0 0 0 3px rgba(222,58,0,0.10);
}

.step-body input:disabled {
    background: var(--grey-100);
    color: var(--grey-500);
}

.count-label {
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-light);
}

.chk-label {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.85rem;
    cursor: pointer;
    white-space: nowrap;
}

.chk-label input[type="checkbox"] {
    accent-color: var(--orange);
}

/* -- Buttons ------------------------------------------------------------ */

.btn-search {
    height: 42px;
    padding: 0 24px;
    background: var(--orange);
    color: white;
    border: 2px solid var(--orange);
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 400;
    font-family: 'Segoe UI', sans-serif;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    cursor: pointer;
    white-space: nowrap;
    transition: all var(--transition);
}

.btn-search:hover:not(:disabled) {
    background: var(--orange-dark);
    border-color: var(--orange-dark);
}

.btn-search:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.btn-export {
    height: 42px;
    padding: 0 20px;
    background: var(--charcoal);
    color: white;
    border: 1.5px solid var(--charcoal);
    border-radius: var(--radius);
    font-size: 0.82rem;
    font-weight: 500;
    font-family: 'Segoe UI', sans-serif;
    cursor: pointer;
    transition: all var(--transition);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    white-space: nowrap;
}

.btn-export:hover:not(:disabled) {
    background: var(--charcoal-3);
}

.btn-export:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

/* -- Tables ------------------------------------------------------------- */

.table-scroll {
    overflow: auto;
    min-height: 0;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
}

.data-table thead {
    position: sticky;
    top: 0;
    z-index: 1;
}

.data-table th {
    background: var(--charcoal);
    font-size: 0.75rem;
    font-weight: 600;
    color: rgba(255,255,255,0.85);
    text-align: left;
    padding: 9px 10px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    white-space: nowrap;
}

.data-table td {
    padding: 8px 10px;
    border-bottom: 1px solid var(--grey-100);
    white-space: nowrap;
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.data-table tbody tr {
    transition: background var(--transition);
    background: var(--white);
}

.data-table tbody tr:nth-child(even) {
    background: var(--grey-50);
}

.data-table tbody tr:hover {
    background: rgba(222,58,0,0.04) !important;
}

/* Match state row colours */
.row-green {
    background: var(--row-green-bg) !important;
    color: var(--row-green-text);
}

.row-red {
    background: var(--row-red-bg) !important;
    color: var(--row-red-text);
}

/* -- Cross-match area --------------------------------------------------- */

.crossmatch-area {
    padding: 0 28px 14px;
}

.crossmatch-grid {
    margin-bottom: 14px;
}

.sub-header {
    font-size: 0.78rem;
    font-weight: 600;
    padding: 8px 14px;
    background: var(--grey-50);
    border-bottom: 1px solid var(--grey-200);
    color: var(--text);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.unmatched-lists {
    display: flex;
    gap: 16px;
}

.unmatched-list-col {
    flex: 1;
    border: 1px solid var(--grey-200);
    border-radius: var(--radius);
    overflow: hidden;
}

.list-box {
    max-height: 180px;
    overflow-y: auto;
    background: var(--white);
}

.list-item {
    padding: 6px 12px;
    font-size: 0.85rem;
    cursor: pointer;
    border-bottom: 1px solid var(--grey-100);
    transition: background var(--transition);
    user-select: none;
}

.list-item:hover {
    background: rgba(222,58,0,0.06);
}

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

/* -- Status bar --------------------------------------------------------- */

.status-bar {
    background: var(--charcoal);
    border-top: 1px solid var(--charcoal-3);
    padding: 10px 28px;
    font-size: 0.8rem;
    color: rgba(255,255,255,0.55);
    flex-shrink: 0;
    white-space: pre-line;
    position: sticky;
    bottom: 0;
    z-index: 50;
}

.status-bar.status-error {
    color: #ff6b6b;
}

/* =====================================================================
   RESPONSIVE
   ===================================================================== */

@media (max-width: 768px) {
    .site-header {
        flex-wrap: wrap;
        height: auto;
        min-height: var(--header-h);
        padding: 10px 16px;
        gap: 8px;
    }

    .nav-user {
        border-left: none;
        padding-left: 0;
    }

    .filter-row {
        flex-direction: column;
        align-items: stretch;
    }

    .filter-group {
        flex-direction: column;
        align-items: stretch;
    }

    .step-body {
        padding: 12px 16px;
    }

    .crossmatch-area {
        padding: 0 16px 14px;
    }

    .unmatched-lists {
        flex-direction: column;
    }

    .data-table th,
    .data-table td {
        padding: 7px 8px;
        font-size: 0.75rem;
    }
}

@media (max-width: 640px) {
    .site-header {
        padding: 8px 12px;
    }

    .site-logo__text {
        display: none;
    }

    .site-logo__divider {
        display: none;
    }

    .step-header {
        padding: 10px 16px;
    }

    .btn-search {
        width: 100%;
    }

    .auth-card {
        padding: 32px 24px;
    }
}

@media (max-width: 480px) {
    .auth-wrapper {
        padding: 0;
        align-items: stretch;
    }

    .auth-card {
        max-width: 100%;
        border-radius: 0;
        padding: 28px 18px;
    }

    .auth-title {
        font-size: 1.4rem;
    }
}
