:root {
    --navy-950: #07182d;
    --navy-900: #0b2545;
    --navy-800: #12385f;
    --blue-600: #0879ca;
    --blue-500: #1597e5;
    --blue-100: #e8f5fd;
    --cyan-400: #20c4d9;
    --ink: #172033;
    --muted: #657186;
    --line: #dfe6ee;
    --surface: #ffffff;
    --canvas: #f4f7fa;
    --success: #147a55;
    --success-bg: #e8f7f0;
    --warning: #966100;
    --warning-bg: #fff5d9;
    --danger: #b42335;
    --danger-bg: #fff0f1;
    --shadow: 0 18px 50px rgba(7, 24, 45, .1);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--ink);
    background: var(--canvas);
}

*, *::before, *::after { box-sizing: border-box; }
html { min-height: 100%; scroll-behavior: smooth; }
body { min-height: 100vh; margin: 0; display: flex; flex-direction: column; background: var(--canvas); color: var(--ink); }
a { color: var(--blue-600); text-underline-offset: 3px; }
a:hover { color: var(--navy-800); }
button, input { font: inherit; }
[hidden] { display: none !important; }

.portal-container { width: min(1180px, calc(100% - 40px)); margin-inline: auto; }
.skip-link { position: fixed; left: 16px; top: -80px; z-index: 100; padding: 10px 16px; border-radius: 6px; background: var(--surface); color: var(--ink); }
.skip-link:focus { top: 12px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.portal-header { background: var(--surface); border-bottom: 1px solid rgba(11, 37, 69, .1); }
.portal-header__inner { min-height: 74px; display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.portal-brand { display: flex; align-items: center; gap: 14px; color: var(--navy-900); font-weight: 700; text-decoration: none; }
.portal-brand img { width: 132px; max-height: 42px; object-fit: contain; object-position: left center; }
.portal-brand span { padding-left: 14px; border-left: 1px solid var(--line); }
.portal-help { font-size: .92rem; font-weight: 650; }
.portal-user { display: flex; align-items: center; gap: 18px; }
.portal-user form { margin: 0; }
.portal-user__name { max-width: 300px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 650; }
.portal-main { flex: 1; padding: 44px 0 64px; }
.auth-main { flex: 1; display: flex; }
.portal-footer { color: #8090a5; background: var(--navy-950); font-size: .84rem; }
.portal-footer .portal-container { min-height: 58px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }

.portal-auth { background: linear-gradient(120deg, var(--navy-950) 0%, var(--navy-900) 48%, var(--canvas) 48%); }
.portal-auth .portal-header { background: transparent; border-color: rgba(255,255,255,.14); }
.portal-auth .portal-brand, .portal-auth .portal-help { color: white; }
.portal-auth .portal-brand img { background: white; border-radius: 5px; padding: 4px 8px; }
.portal-auth .portal-brand span { border-color: rgba(255,255,255,.25); }
.auth-shell { display: grid; grid-template-columns: 1fr minmax(380px, 470px); gap: clamp(48px, 10vw, 130px); align-items: center; padding-block: 56px; }
.auth-shell--single { display: flex; justify-content: flex-end; }
.auth-shell--single .auth-card { width: min(100%, 490px); }
.auth-intro { color: white; max-width: 580px; }
.auth-intro h1 { max-width: 700px; margin: 12px 0 18px; font-size: clamp(2.35rem, 5vw, 4.4rem); line-height: 1.03; letter-spacing: -.045em; }
.auth-intro > p { max-width: 560px; color: #c1ccda; font-size: 1.08rem; line-height: 1.75; }
.feature-list { display: flex; flex-wrap: wrap; gap: 12px 24px; margin: 34px 0 0; padding: 0; list-style: none; color: #e6edf5; font-size: .93rem; }
.feature-list span { display: inline-grid; place-items: center; width: 20px; height: 20px; margin-right: 7px; border-radius: 50%; color: var(--navy-950); background: var(--cyan-400); font-weight: 800; }
.auth-card { padding: clamp(28px, 5vw, 48px); border: 1px solid rgba(11, 37, 69, .08); border-radius: 18px; background: var(--surface); box-shadow: var(--shadow); }
.auth-card__heading { margin: 14px 0 30px; }
.auth-card__heading h1, .auth-card__heading h2 { margin: 8px 0 10px; color: var(--navy-950); font-size: clamp(1.65rem, 4vw, 2.15rem); letter-spacing: -.025em; }
.auth-card__heading p { margin: 0; color: var(--muted); line-height: 1.65; }
.auth-card__footer { display: flex; justify-content: center; gap: 7px; margin-top: 24px; padding-top: 24px; border-top: 1px solid var(--line); color: var(--muted); font-size: .92rem; }
.eyebrow { color: var(--blue-600); font-size: .77rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.auth-intro .eyebrow { color: var(--cyan-400); }
.back-link { display: inline-flex; margin-bottom: 18px; font-size: .9rem; font-weight: 650; text-decoration: none; }
.step-indicator { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; margin: 4px 0 28px; }
.step-indicator span { height: 4px; border-radius: 999px; background: var(--line); }
.step-indicator .is-active { background: var(--blue-600); }
.step-indicator .is-complete { background: var(--success); }

.portal-form { display: grid; gap: 19px; }
.field { display: grid; gap: 7px; }
.field label, .field__label-row { color: var(--navy-950); font-size: .9rem; font-weight: 700; }
.field__label-row { display: flex; justify-content: space-between; gap: 16px; }
.field__label-row a { font-weight: 600; }
.field input { width: 100%; min-height: 50px; padding: 12px 14px; color: var(--ink); border: 1px solid #c9d3df; border-radius: 8px; background: white; outline: none; transition: border-color .15s, box-shadow .15s; }
.field input:focus { border-color: var(--blue-600); box-shadow: 0 0 0 4px rgba(8, 121, 202, .13); }
.field small { color: var(--muted); line-height: 1.45; }
.field-error, .validation-summary { color: var(--danger); font-size: .83rem; }
.validation-summary:empty, .field-error:empty { display: none; }
.validation-summary ul { margin: 0; padding-left: 20px; }
.input-validation-error { border-color: var(--danger) !important; }
.code-input { text-align: center; font-size: 1.55rem !important; font-weight: 750; letter-spacing: .45em; padding-left: calc(14px + .45em) !important; }
.check-field { display: flex; align-items: flex-start; gap: 9px; color: var(--muted); font-size: .88rem; line-height: 1.4; cursor: pointer; }
.check-field input { width: 17px; height: 17px; margin-top: 1px; accent-color: var(--blue-600); }
.privacy-note { margin: 22px 0 0; color: var(--muted); font-size: .82rem; line-height: 1.55; text-align: center; }
.alert { padding: 12px 14px; margin-bottom: 20px; border-radius: 7px; font-size: .9rem; line-height: 1.45; }
.alert--error { color: var(--danger); background: var(--danger-bg); border: 1px solid #f5c8ce; }

.button { min-height: 42px; display: inline-flex; align-items: center; justify-content: center; padding: 10px 18px; border: 1px solid transparent; border-radius: 7px; font-weight: 750; text-decoration: none; cursor: pointer; transition: transform .15s, background .15s, border-color .15s; }
.button:hover { transform: translateY(-1px); }
.button:focus-visible, a:focus-visible { outline: 3px solid rgba(21,151,229,.35); outline-offset: 3px; }
.button--primary { color: white; background: var(--blue-600); box-shadow: 0 7px 18px rgba(8,121,202,.23); }
.button--primary:hover { color: white; background: #066caf; }
.button--secondary { color: var(--navy-900); border-color: #c9d5e2; background: white; }
.button--secondary:hover { color: var(--navy-950); border-color: #91a7bd; }
.button--quiet { min-height: 36px; padding: 7px 12px; color: var(--navy-900); border-color: var(--line); background: transparent; }
.button--full { width: 100%; min-height: 51px; }

.dashboard-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 28px; margin-bottom: 30px; }
.dashboard-heading h1 { margin: 6px 0 6px; color: var(--navy-950); font-size: clamp(2rem, 5vw, 3rem); letter-spacing: -.04em; }
.dashboard-heading p { margin: 0; color: var(--muted); font-size: 1.02rem; }
.summary-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 24px; }
.summary-card { min-height: 112px; display: flex; align-items: center; gap: 18px; padding: 22px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface); }
.summary-card__icon { width: 44px; height: 44px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 10px; color: var(--blue-600); background: var(--blue-100); font-size: 1.25rem; font-weight: 800; }
.summary-card strong, .summary-card span { display: block; }
.summary-card strong { color: var(--navy-950); font-size: 1.65rem; line-height: 1; }
.summary-card div span { margin-top: 6px; color: var(--muted); font-size: .88rem; }
.summary-card--active { border-color: #b8dbef; }
.summary-card--attention .summary-card__icon { color: var(--warning); background: var(--warning-bg); }
.projects-panel { overflow: hidden; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); box-shadow: 0 8px 28px rgba(7,24,45,.045); }
.projects-panel__header { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 24px 26px; border-bottom: 1px solid var(--line); }
.projects-panel__header h2 { margin: 0 0 4px; color: var(--navy-950); font-size: 1.25rem; }
.projects-panel__header p { margin: 0; color: var(--muted); font-size: .84rem; }
.project-search { width: min(100%, 320px); display: flex; align-items: center; gap: 8px; padding: 0 12px; border: 1px solid #cbd5df; border-radius: 7px; color: var(--muted); }
.project-search:focus-within { border-color: var(--blue-600); box-shadow: 0 0 0 3px rgba(8,121,202,.11); }
.project-search input { width: 100%; min-height: 42px; border: 0; outline: 0; }
.project-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; padding: 22px; }
.project-card { position: relative; min-width: 0; padding: 22px; border: 1px solid var(--line); border-radius: 10px; background: white; transition: border-color .18s, box-shadow .18s, transform .18s; }
.project-card:hover { border-color: #b4c9dc; box-shadow: 0 12px 28px rgba(7,24,45,.08); transform: translateY(-2px); }
.project-card__topline { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.project-number { color: var(--blue-600); font-size: .76rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.project-card h3 { max-width: 430px; margin: 7px 0 0; overflow: hidden; color: var(--navy-950); font-size: 1.06rem; line-height: 1.4; text-overflow: ellipsis; white-space: nowrap; }
.status-badge { display: inline-flex; align-items: center; flex: 0 0 auto; padding: 5px 9px; border-radius: 999px; color: #31516f; background: #edf3f8; font-size: .72rem; font-weight: 800; white-space: nowrap; }
.status-badge--complete, .status-badge--archive { color: var(--success); background: var(--success-bg); }
.status-badge--delivery, .status-badge--readytopickup { color: #06667d; background: #e4f7f9; }
.status-badge--startjob, .status-badge--endjob, .status-badge--readytocut { color: #075f9d; background: var(--blue-100); }
.status-badge--pending, .status-badge--material { color: var(--warning); background: var(--warning-bg); }
.status-badge--cancel { color: var(--danger); background: var(--danger-bg); }
.project-meta { display: grid; grid-template-columns: 1.3fr 1fr 1fr; gap: 14px; margin: 22px 0; }
.project-meta div { min-width: 0; }
.project-meta dt { margin-bottom: 5px; color: var(--muted); font-size: .7rem; font-weight: 650; text-transform: uppercase; }
.project-meta dd { margin: 0; overflow: hidden; color: var(--ink); font-size: .84rem; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.progress-block__label { display: flex; justify-content: space-between; gap: 14px; margin-bottom: 8px; color: var(--muted); font-size: .78rem; }
.progress-block__label strong { color: var(--navy-900); }
.progress-track { height: 7px; overflow: hidden; border-radius: 999px; background: #e7edf3; }
.progress-track span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--blue-600), var(--cyan-400)); }
.project-card__link { display: flex; align-items: center; justify-content: space-between; margin: 20px -22px -22px; padding: 15px 22px; border-top: 1px solid var(--line); color: var(--navy-800); font-size: .84rem; font-weight: 800; text-decoration: none; }
.empty-state { padding: 64px 24px; text-align: center; }
.empty-state__icon { width: 58px; height: 58px; display: grid; place-items: center; margin: 0 auto 16px; border-radius: 50%; color: var(--blue-600); background: var(--blue-100); font-size: 1.6rem; }
.empty-state h3 { margin: 0 0 8px; color: var(--navy-950); }
.empty-state p { margin: 0 0 22px; color: var(--muted); }

.project-detail > .back-link { margin-bottom: 22px; }
.project-hero { display: flex; align-items: flex-end; justify-content: space-between; gap: 30px; margin-bottom: 28px; }
.project-hero__eyebrow { display: flex; align-items: center; gap: 12px; color: var(--blue-600); font-size: .78rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.project-hero h1 { max-width: 820px; margin: 10px 0 8px; color: var(--navy-950); font-size: clamp(1.8rem, 4vw, 2.8rem); line-height: 1.15; letter-spacing: -.035em; }
.project-hero p { margin: 0; color: var(--muted); }
.detail-progress { padding: 26px; margin-bottom: 22px; border: 1px solid #beddec; border-radius: 12px; background: linear-gradient(120deg, white, #f0f9fd); }
.progress-track--large { height: 10px; }
.date-strip { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; margin-top: 22px; }
.date-strip div { display: grid; gap: 5px; }
.date-strip div:nth-child(2) { text-align: center; }
.date-strip div:last-child { text-align: right; }
.date-strip span { color: var(--muted); font-size: .72rem; font-weight: 650; text-transform: uppercase; }
.date-strip strong { color: var(--navy-950); font-size: .92rem; }
.detail-grid { display: grid; grid-template-columns: minmax(300px, .8fr) minmax(0, 1.2fr); gap: 22px; align-items: start; }
.detail-card { min-width: 0; padding: 26px; border: 1px solid var(--line); border-radius: 12px; background: white; }
.detail-card__heading { margin-bottom: 24px; }
.detail-card__heading h2 { margin: 6px 0 0; color: var(--navy-950); font-size: 1.25rem; }
.timeline { margin: 0; padding: 0; list-style: none; }
.timeline li { position: relative; display: grid; grid-template-columns: 20px 1fr; gap: 12px; min-height: 62px; }
.timeline li:not(:last-child)::before { content: ""; position: absolute; left: 6px; top: 14px; bottom: -2px; width: 2px; background: var(--line); }
.timeline__marker { position: relative; z-index: 1; width: 14px; height: 14px; margin-top: 2px; border: 3px solid white; border-radius: 50%; background: #aab7c5; box-shadow: 0 0 0 2px #aab7c5; }
.timeline .is-current .timeline__marker { background: var(--blue-600); box-shadow: 0 0 0 2px var(--blue-600); }
.timeline strong, .timeline time { display: block; }
.timeline strong { color: var(--navy-950); font-size: .9rem; }
.timeline time { margin-top: 4px; color: var(--muted); font-size: .78rem; }
.project-description { margin: 0 0 22px; white-space: pre-line; color: #3e4a5d; line-height: 1.65; }
.line-table-wrap { overflow-x: auto; }
.line-table { width: 100%; border-collapse: collapse; font-size: .85rem; }
.line-table th { padding: 10px 12px; color: var(--muted); border-bottom: 1px solid var(--line); font-size: .7rem; text-align: left; text-transform: uppercase; }
.line-table td { padding: 14px 12px; border-bottom: 1px solid #edf1f5; }
.line-table th:nth-child(2), .line-table td:nth-child(2) { text-align: center; }
.line-table th:last-child, .line-table td:last-child { text-align: right; white-space: nowrap; }
.muted { color: var(--muted); line-height: 1.6; }

@media (max-width: 900px) {
    .portal-auth { background: var(--canvas); }
    .portal-auth .portal-header { background: var(--navy-950); }
    .auth-shell { grid-template-columns: 1fr; justify-items: center; gap: 34px; }
    .auth-intro { display: none; }
    .auth-card { width: min(100%, 520px); }
    .auth-shell--single { justify-content: center; }
    .project-list { grid-template-columns: 1fr; }
    .detail-grid { grid-template-columns: 1fr; }
}

@media (max-width: 680px) {
    .portal-container { width: min(100% - 24px, 1180px); }
    .portal-header__inner { min-height: 64px; }
    .portal-brand img { width: 104px; }
    .portal-brand span { display: none; }
    .portal-user { gap: 8px; }
    .portal-user__name { display: none; }
    .portal-main { padding: 28px 0 44px; }
    .auth-shell { padding-block: 28px; }
    .auth-card { padding: 26px 20px; border-radius: 12px; }
    .portal-footer .portal-container { justify-content: center; }
    .portal-footer span:last-child { display: none; }
    .dashboard-heading, .project-hero { align-items: stretch; flex-direction: column; }
    .dashboard-heading .button, .project-hero .button { align-self: flex-start; }
    .summary-grid { grid-template-columns: 1fr; gap: 10px; }
    .summary-card { min-height: 84px; padding: 16px; }
    .projects-panel__header { align-items: stretch; flex-direction: column; padding: 20px; }
    .project-search { width: 100%; }
    .project-list { padding: 12px; gap: 12px; }
    .project-card { padding: 18px; }
    .project-card__topline { flex-direction: column-reverse; }
    .project-card h3 { white-space: normal; }
    .project-meta { grid-template-columns: 1fr 1fr; }
    .project-meta div:first-child { grid-column: 1 / -1; }
    .project-card__link { margin: 18px -18px -18px; padding: 14px 18px; }
    .project-hero__eyebrow { align-items: flex-start; flex-direction: column; }
    .detail-progress, .detail-card { padding: 20px; }
    .date-strip { grid-template-columns: 1fr; gap: 14px; }
    .date-strip div:nth-child(2), .date-strip div:last-child { text-align: left; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
