/* ═══════════════════════════════════════════════════════════════════
   Maker BOM Visualiser – Vertilux Portal 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);
    --shadow-lg: 0 12px 40px rgba(0,0,0,.13);

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

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

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

    /* Job row colours */
    --row-white: #ffffff;
    --row-grey: #e5e5e5;
    --row-fixed: #dcfce7;
}

*, *::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: hidden;
}

/* ── 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 (Portal style) ───────────────────────────── */

.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-grow {
    flex: 1;
    min-width: 180px;
}

.filter-grow input {
    flex: 1;
    width: 100%;
}

.filter-rows input {
    width: 80px;
}

.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);
}

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

.job-id-input {
    width: 220px;
    text-align: right;
}

.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;
}

/* ── Content area (three panels) ────────────────────────────────── */

.content-area {
    flex: 1;
    display: flex;
    gap: 0;
    overflow: hidden;
    min-height: 0;
}

.panel {
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--grey-200);
    overflow: hidden;
    background: var(--surface);
}

.panel:last-child {
    border-right: none;
}

.panel-main {
    flex: 2;
    min-width: 0;
}

.panel-detail {
    flex: 2;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.panel-bom {
    flex: 1;
    min-width: 0;
}

.panel-header {
    background: var(--charcoal);
    color: rgba(255,255,255,0.85);
    font-size: 0.78rem;
    font-weight: 600;
    padding: 11px 14px;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-shrink: 0;
}

.detail-grids-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: auto;
    min-height: 0;
}

.sub-panel {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    flex: 1;
    min-height: 0;
}

.sub-panel.collapsed {
    flex: 0 0 auto;
}

.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;
    flex-shrink: 0;
}

.clickable-header {
    cursor: pointer;
    user-select: none;
    transition: background var(--transition);
}

.clickable-header:hover {
    background: var(--grey-100);
}

.collapse-icon {
    display: inline-block;
    width: 1em;
    font-size: 0.65rem;
    margin-right: 6px;
    color: var(--orange);
}

.detail-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 14px;
    border-bottom: 1px solid var(--grey-200);
    background: var(--grey-50);
    flex-shrink: 0;
    flex-wrap: wrap;
}

.chk-fixed {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
}

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

.btn-export {
    height: 34px;
    padding: 0 16px;
    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);
    margin-left: auto;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

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

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

/* ── Fixed-by footer ────────────────────────────────────────────── */

.fixed-by-footer {
    background: #f0fdf4;
    border-top: 1px solid #bbf7d0;
    padding: 10px 14px;
    font-size: 0.82rem;
    color: #166534;
    flex-shrink: 0;
}

.fixed-by-footer strong {
    font-weight: 700;
}

/* ── Tables (Portal style) ──────────────────────────────────────── */

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

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

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

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

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

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

/* Main table row colours */
.row-group-white { background: var(--row-white); }
.row-group-grey  { background: var(--grey-50); }
.row-fixed       { background: var(--row-fixed); }
.row-selected    { outline: 2px solid var(--orange); outline-offset: -2px; }

.clickable-row {
    cursor: pointer;
}

.clickable-row:hover {
    background: rgba(222,58,0,0.04) !important;
}

/* Detail table first column styling */
.detail-table td:first-child {
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text);
    width: 42%;
}

.empty-message {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 64px 24px;
    color: var(--text-light);
    font-size: 0.95rem;
}

/* ── Status bar (Portal footer style) ───────────────────────────── */

.status-bar {
    background: var(--charcoal);
    border-top: 1px solid var(--charcoal-3);
    padding: 8px 28px;
    font-size: 0.78rem;
    color: rgba(255,255,255,0.45);
    flex-shrink: 0;
}

/* ═══════════════════════════════════════════════════════════════════
   RESPONSIVE BREAKPOINTS
   ═══════════════════════════════════════════════════════════════════ */

@media (max-width: 1024px) {
    .content-area {
        flex-direction: column;
        overflow-y: auto;
    }

    .panel {
        border-right: none;
        border-bottom: 1px solid var(--grey-200);
        min-height: 200px;
        max-height: 50vh;
    }

    .panel:last-child {
        border-bottom: none;
    }

    .panel-main,
    .panel-detail,
    .panel-bom {
        flex: none;
    }

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

    .filter-panel {
        padding: 12px 16px;
    }

    .status-bar {
        padding: 8px 16px;
    }
}

@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;
    }

    .filter-grow {
        min-width: 0;
    }

    .data-table th,
    .data-table td {
        padding: 9px 10px;
        font-size: 0.8rem;
    }
}

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

    .site-logo__text {
        display: none;
    }

    .site-logo__divider {
        display: none;
    }

    .nav-user__email {
        max-width: 130px;
        font-size: 0.75rem;
    }

    .filter-panel {
        padding: 10px 12px;
    }

    .job-id-input {
        width: 100%;
        text-align: left;
    }

    .filter-rows input {
        width: 100%;
    }

    .btn-search {
        width: 100%;
    }

    .panel {
        min-height: 150px;
        max-height: 70vh;
    }

    .data-table {
        font-size: 0.75rem;
    }

    .data-table th,
    .data-table td {
        padding: 8px;
    }

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

    .btn-export {
        margin-left: 0;
        text-align: center;
    }

    .detail-table td:first-child {
        width: 48%;
    }

    /* Auth responsive */
    .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;
    }
}
