/* MGP Contractor Portal — B2B, desktop-first, light-only. Calibrated to MGP.Admin.Portal/DESIGN.md:
   Technicolor Blue #021EFF (primary), Almost Black #2D2D2D (text/nav), Relaxy Tealy #00B794 (success
   only), Illuminated Grey #E8E8E8 (cards/dividers), muted red #D64545 (error), amber #F2A93B (warning
   band). Outfit for headings, Nunito Sans for body. 8px spacing base. */

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;600;700&family=Nunito+Sans:wght@400;600;700&display=swap');

:root {
    --blue: #021EFF;
    --blue-dark: #0014BF;
    --ink: #2D2D2D;
    --tealy: #00B794;
    --grey: #E8E8E8;
    --red: #D64545;
    --amber: #F2A93B;
    --muted: #6b6b6b;
    --line: #e2e2e2;
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: 'Nunito Sans', system-ui, sans-serif;
    color: var(--ink);
    background: #fff;
    line-height: 1.5;
}

h1, h2, h3 { font-family: 'Outfit', sans-serif; font-weight: 700; margin: 0 0 8px; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1rem; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── App shell ─────────────────────────────────────────────────────────── */
.appbar {
    display: flex; align-items: center; gap: 24px;
    padding: 0 24px; height: 60px;
    background: var(--ink); color: #fff;
    position: sticky; top: 0; z-index: 10;
}
.logo { display: inline-flex; align-items: center; }
.logo img { height: 34px; width: auto; display: block; }
.appbar__nav { display: flex; gap: 4px; margin-left: 8px; }
.appbar__nav a {
    color: #cfcfcf; padding: 8px 12px; border-radius: var(--radius-md); font-weight: 600; font-size: .92rem;
}
.appbar__nav a:hover { background: rgba(255,255,255,.08); color: #fff; text-decoration: none; }
.appbar__nav a.active { color: #fff; background: rgba(255,255,255,.12); }
.appbar__spacer { flex: 1; }
.appbar__user { color: #cfcfcf; font-size: .9rem; }

.page { max-width: 1120px; margin: 0 auto; padding: 32px 24px; }
.page__head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 24px; gap: 16px; }
.page__head p { color: var(--muted); margin: 4px 0 0; }

/* ── Auth ──────────────────────────────────────────────────────────────── */
.auth-shell { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
/* Brand logo anchored top-left; the value block sits centred below it; a footer anchors the base — the
   panel reads as intentional at any size. A faint, whitened logo-mark motif gives the solid blue depth
   without a gradient (DESIGN.md: color-block over gradients; the repeated logo-mark surface pattern is
   the brand-sanctioned texture for a login background). */
.auth-hero {
    position: relative; overflow: hidden;
    background: var(--blue); color: #fff; padding: 56px 64px; display: flex; flex-direction: column;
}
.auth-hero::before {
    content: ""; position: absolute; inset: -20%;
    background: url('../img/MGP-Logo-white.png') repeat; background-size: 132px;
    filter: brightness(0) invert(1);            /* recolour the blue brand mark to white */
    opacity: .06; transform: rotate(-8deg); pointer-events: none;
}
.auth-hero > * { position: relative; z-index: 1; }   /* content sits above the motif */
.auth-hero__logo img { height: 60px; width: auto; display: block; }
.auth-hero__body { margin: auto 0; max-width: 34ch; }
.auth-hero h2 { font-size: 2.6rem; line-height: 1.1; color: #fff; margin: 0 0 16px; }
.auth-hero p { opacity: .85; line-height: 1.6; margin: 0; }
.auth-hero__points { list-style: none; margin: 28px 0 0; padding: 0; display: grid; gap: 12px; }
.auth-hero__points li { position: relative; padding-left: 30px; line-height: 1.4; font-weight: 600; }
.auth-hero__points li::before {
    content: "✓"; position: absolute; left: 0; top: -1px;
    width: 20px; height: 20px; border-radius: 50%; background: rgba(255,255,255,.18);
    display: inline-flex; align-items: center; justify-content: center; font-size: .72rem; font-weight: 700;
}
.auth-hero__foot { margin-top: 32px; font-size: .82rem; opacity: .6; }
.auth-main { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 48px 24px; }
.auth-main__brand { display: none; margin-bottom: 28px; }   /* shown only when the hero is hidden (mobile) */
.auth-main__brand img { height: 46px; width: auto; display: block; }
/* The sign-in language switcher sits on the LIGHT half of the split, so it cannot borrow the app bar's
   light-on-dark button colours. Same width as the card beneath it, and it follows the page direction. */
.auth-main__lang { width: 100%; max-width: 380px; display: flex; justify-content: flex-end; margin-bottom: 12px; }
.auth-main__lang .appbar__langbtn { color: var(--muted); border-color: var(--grey); min-height: 36px; }
.auth-main__lang .appbar__langbtn:hover { color: var(--ink); border-color: var(--ink); }

.auth-card { width: 100%; max-width: 380px; }
.auth-card__title { margin-bottom: 4px; }
.auth-card__sub { color: var(--muted); margin: 0 0 24px; }
.auth-card__foot { margin-top: 20px; color: var(--muted); font-size: .92rem; }

/* ── Cards / grid ──────────────────────────────────────────────────────── */
.grid { display: grid; gap: 16px; }
.grid--cards { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.card { border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 20px; background: #fff; }
.card h3 { margin-bottom: 4px; }
.card__muted { color: var(--muted); font-size: .9rem; }

/* Checklist */
.checklist { display: grid; gap: 12px; }
.check { display: flex; align-items: center; gap: 12px; padding: 16px 20px; border: 1px solid var(--line); border-radius: var(--radius-lg); }
.check__dot { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--line); flex: 0 0 auto; }
.check--done .check__dot { background: var(--tealy); border-color: var(--tealy); }
.check__body { flex: 1; }
.check__body strong { font-family: 'Outfit', sans-serif; }
.check__body span { display: block; color: var(--muted); font-size: .9rem; }

/* ── Forms ─────────────────────────────────────────────────────────────── */
.stack { display: grid; gap: 16px; }
.field { display: grid; gap: 6px; }
.field__label { font-weight: 600; font-size: .9rem; }
.field__hint { color: var(--muted); font-size: .8rem; }
.field__input, select.field__input {
    height: 40px; padding: 0 12px; border: 1px solid var(--line); border-radius: var(--radius-md);
    font: inherit; color: var(--ink); background: #fff;
    width: 100%; max-width: 100%;
}
/* A grid item's automatic minimum is its MIN-CONTENT width, and a form control's min-content is
   whatever the browser decides: a <select> is as wide as its longest option, and a file input is as
   wide as the browser's own "Choose file / no file selected" chrome, which is longer in some UI
   languages than in English. Either one could push a track past its container, so the upload modal
   overflowed its own box and clipped the Upload button (live QA, 2026-08-07). Opting these tracks
   out of the automatic minimum lets the controls shrink to the space they actually have. */
.stack > *, .grid-2 > *, .field > * { min-width: 0; }
select.field__input { text-overflow: ellipsis; }
.field__input:focus { outline: 2px solid var(--blue); outline-offset: 1px; border-color: var(--blue); }
textarea.field__input { height: auto; padding: 10px 12px; }

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    height: 40px; padding: 0 18px; border-radius: var(--radius-md); border: 1px solid transparent;
    font: inherit; font-weight: 700; cursor: pointer; min-width: 44px;
}
.btn--primary { background: var(--blue); color: #fff; }
.btn--primary:hover { background: var(--blue-dark); text-decoration: none; }
.btn--ghost { background: #fff; border-color: var(--line); color: var(--ink); }
.btn--ghost:hover { background: var(--grey); text-decoration: none; }
.btn--block { width: 100%; }
.btn--sm { height: 32px; padding: 0 12px; font-size: .88rem; }

/* Busy state (site.js) — spinner + disabled while a form submits, so slow actions give feedback and can't
   be double-clicked. currentColor keeps the spinner legible on primary (white) and ghost (ink) buttons. */
.btn-spinner {
    display: inline-block; width: 14px; height: 14px; margin-inline-end: 8px; vertical-align: -2px;
    border: 2px solid currentColor; border-top-color: transparent; border-radius: 50%;
    animation: btn-spin .6s linear infinite;
}
@keyframes btn-spin { to { transform: rotate(360deg); } }
.btn.is-busy, button.is-busy { cursor: progress; opacity: .9; }
[aria-busy="true"] { cursor: progress; }

/* ── Banners / pills ───────────────────────────────────────────────────── */
.banner { padding: 12px 16px; border-radius: var(--radius-md); margin-bottom: 16px; font-size: .92rem; }
.banner--error { background: #fdecec; color: var(--red); border: 1px solid #f6cccc; }
.banner--success { background: #e6f7f2; color: #06795f; border: 1px solid #b7e8dc; }
.banner--info { background: #eef0ff; color: var(--blue-dark); border: 1px solid #cfd5ff; }

.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: .78rem; font-weight: 700; }
.pill--ok { background: #e6f7f2; color: #06795f; }
.pill--warn { background: #fdf1dd; color: #8a5a12; }
.pill--bad { background: #fdecec; color: var(--red); }
.pill--neutral { background: var(--grey); color: var(--ink); }

/* ── Tables / lists ────────────────────────────────────────────────────── */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); font-size: .92rem; }
.table th { font-family: 'Outfit', sans-serif; font-weight: 600; color: var(--muted); text-transform: uppercase; font-size: .72rem; letter-spacing: .5px; }
.table tbody tr:hover { background: #fafafa; }
/* PR7 worker picker: not-yet-verified workers are shown but not selectable (design decision 1B). */
.table tbody tr.is-ineligible { opacity: .55; }
.table tbody tr.is-ineligible:hover { background: transparent; }

.empty { text-align: center; padding: 40px 20px; color: var(--muted); border: 1px dashed var(--line); border-radius: var(--radius-lg); }
.empty strong { display: block; font-family: 'Outfit', sans-serif; color: var(--ink); margin-bottom: 4px; }

.row-actions { display: flex; gap: 8px; }
.section { margin-top: 28px; }
.section__head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }

/* Work-order rows (invite inbox) */
.workorder { display: flex; align-items: center; gap: 16px; padding: 16px 20px; border: 1px solid var(--line); border-radius: var(--radius-lg); }
.workorder__body { flex: 1; }
.workorder__body strong { font-family: 'Outfit', sans-serif; }
.workorder__body span { display: block; color: var(--muted); font-size: .88rem; }

@media (max-width: 860px) {
    .auth-shell { grid-template-columns: 1fr; }
    .auth-hero { display: none; }
    .auth-main__brand { display: block; }   /* keep the brand present once the hero is gone */
    .grid-2 { grid-template-columns: 1fr; }
    /* Decision 5A: the 3 links (1A) stay INLINE at every width — contractors upload documents
       from phones; a nav that disappears breaks the primary journey. */
    .appbar__nav { gap: 2px; margin-left: 4px; }
    .appbar__nav a { padding: 12px 10px; font-size: .85rem; min-height: 44px; display: inline-flex; align-items: center; }
    .appbar__user { display: none; }
}

/* ── Readiness strip (Company page at-a-glance status) ─────────────────────── */
.readiness { display: flex; flex-wrap: wrap; gap: 24px; padding: 14px 18px; margin-bottom: 20px;
    border: 1px solid var(--line); border-radius: var(--radius-lg); background: #fafafa; }
.readiness__group { display: flex; align-items: center; gap: 8px; }
.readiness__label { font-family: 'Outfit', sans-serif; font-weight: 600; text-transform: uppercase;
    font-size: .72rem; letter-spacing: .5px; color: var(--muted); }

/* ── Destructive button (DESIGN.md muted red) ─────────────────────────────── */
.btn--danger { background: #fff; border-color: var(--red); color: var(--red); }
.btn--danger:hover { background: var(--red); color: #fff; text-decoration: none; }

/* ── Modal (add forms + delete confirm) ───────────────────────────────────── */
.modal-overlay { position: fixed; inset: 0; background: rgba(20,20,30,.45); display: flex;
    align-items: center; justify-content: center; padding: 20px; z-index: 60; }
.modal-overlay[hidden] { display: none; }
.modal { background: #fff; border-radius: var(--radius-lg); width: 100%; max-width: 520px;
    max-height: 90vh; overflow-y: auto; padding: 22px; box-shadow: 0 12px 40px rgba(0,0,0,.18); }
.modal__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.modal__head h3 { margin: 0; font-family: 'Outfit', sans-serif; }
.modal__close { background: none; border: 0; font-size: 1.6rem; line-height: 1; color: var(--muted);
    cursor: pointer; padding: 0 4px; }
.modal__close:hover { color: var(--ink); }
.modal__foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.modal p { color: var(--ink); line-height: 1.5; }

@media (max-width: 640px) {
    .modal-overlay { align-items: flex-end; padding: 0; }
    .modal { max-width: none; border-radius: var(--radius-lg) var(--radius-lg) 0 0; max-height: 92vh; }
    .modal__foot .btn { flex: 1; }
    .readiness { gap: 12px; }
}

/* ── Property list (company profile summary) ──────────────────────────────── */
.proplist { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px 28px; margin: 0; }
.proplist div { display: flex; flex-direction: column; gap: 2px; }
.proplist dt { font-family: 'Outfit', sans-serif; font-weight: 600; text-transform: uppercase;
    font-size: .7rem; letter-spacing: .5px; color: var(--muted); }
.proplist dd { margin: 0; color: var(--ink); }

/* ── Checkbox field (worker acknowledgement) ──────────────────────────────── */
.field--check { flex-direction: row; align-items: center; gap: 10px; }
.field--check input { width: 18px; height: 18px; flex: 0 0 auto; accent-color: var(--blue); }

/* ── Worker photo (B2: surfaced from the verified ID) ─────────────────────── */
.worker-photo { display: flex; align-items: center; gap: 12px; }
.worker-photo img { width: 64px; height: 64px; object-fit: cover; border-radius: var(--radius-md); border: 1px solid var(--line); }

/* ── Activity timeline (derived history) ──────────────────────────────────── */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline__item { display: flex; gap: 14px; padding: 0 0 20px 2px; position: relative; }
.timeline__item:not(:last-child)::before { content: ""; position: absolute; left: 6px; top: 16px; bottom: 0;
    width: 2px; background: var(--line); }
.timeline__dot { width: 14px; height: 14px; border-radius: 50%; flex: 0 0 auto; margin-top: 3px; z-index: 1;
    border: 2px solid #fff; box-shadow: 0 0 0 1px var(--line); }
.timeline__dot.dot--ok { background: var(--tealy); }
.timeline__dot.dot--bad { background: var(--red); }
.timeline__dot.dot--warn { background: var(--amber); }
.timeline__dot.dot--neutral { background: var(--grey); }
.timeline__title { font-weight: 600; }
.timeline__time { display: block; color: var(--muted); font-size: .8rem; margin-top: 2px; }

/* ── Mission-control vocabulary (design pass 2026-08-05; shared: Home, Company, events) ── */
.tasklist { display: grid; gap: 10px; }
.task {
    display: flex; align-items: center; gap: 14px; padding: 14px 18px;
    border: 1px solid var(--line); border-left: 4px solid var(--grey);
    border-radius: var(--radius-lg); background: #fff;
}
.task--doc { border-left-color: var(--amber); }
.task--staff { border-left-color: var(--blue); }
.task--service { border-left-color: var(--amber); }   /* PTW v2: a scheduled service is due */
.task__form { margin: 0; }
.task--done { border-left-color: var(--tealy); }
.task--first { box-shadow: 0 2px 10px rgba(45, 45, 45, .07); }
.task__num {
    font-family: 'Outfit', sans-serif; font-weight: 700; font-size: .85rem;
    width: 26px; height: 26px; border-radius: 50%; flex: 0 0 auto;
    display: grid; place-items: center; background: var(--ink); color: #fff;
}
.task--first .task__num { background: var(--blue); }
.task__check {
    width: 26px; height: 26px; border-radius: 50%; flex: 0 0 auto;
    display: grid; place-items: center; background: var(--tealy); color: #fff; font-weight: 700;
}
.task__body { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.task__body span { color: var(--muted); font-size: .9rem; }

.allclear {
    display: flex; align-items: center; gap: 14px; padding: 18px 20px;
    border: 1px solid rgba(0, 183, 148, .35); background: rgba(0, 183, 148, .07);
    border-radius: var(--radius-lg);
}
.allclear__mark {
    width: 32px; height: 32px; border-radius: 50%; background: var(--tealy); color: #fff;
    display: grid; place-items: center; font-weight: 700; flex: 0 0 auto;
}

.eventgrid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); }
.eventcard {
    display: flex; align-items: center; gap: 16px; padding: 16px 18px;
    border: 1px solid var(--line); border-radius: var(--radius-lg); background: #fff;
    color: inherit; text-decoration: none; transition: border-color .12s;
}
.eventcard:hover { border-color: var(--blue); }
.eventcard__date {
    width: 52px; height: 56px; flex: 0 0 auto; border-radius: var(--radius-md);
    background: rgba(2, 30, 255, .07); color: var(--blue);
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    font-family: 'Outfit', sans-serif; font-weight: 700;
}
.eventcard__day { font-size: 1.35rem; line-height: 1.1; }
.eventcard__month { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; }
.eventcard__body { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.eventcard__body strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.eventcard__ready { font-size: .85rem; color: var(--muted); }
.eventcard__ready .ok { color: #00795f; font-weight: 600; }
.eventcard__ready .warn { color: #8a5a00; font-weight: 600; }

.costrip {
    display: flex; align-items: center; gap: 14px; padding: 13px 18px; margin-bottom: 8px;
    border: 1px solid var(--line); border-radius: var(--radius-lg); background: #fff;
    color: inherit; text-decoration: none; transition: border-color .12s;
}
.costrip:hover { border-color: var(--blue); }
.costrip__facts { flex: 1; display: flex; gap: 8px; color: var(--muted); font-size: .9rem; }
.costrip__go { color: var(--blue); font-weight: 600; font-size: .9rem; }

@media (max-width: 640px) {
    .task { flex-wrap: wrap; }
    .task .btn { margin-inline-start: 40px; }
    .costrip { flex-wrap: wrap; }
    .costrip__facts { flex-basis: 100%; order: 3; }
}


/* ── Work area (decision 1A): shared card vocabulary — the eventcard carries BOTH kinds; the
   type badge is a small uppercase neutral pill (anti-slop spec).

   Work items are full-width LIST ROWS, never grid tiles: a row reads
   [date] [type + title + meta] [status] [action] left-to-right and needs the full content
   width. (.eventgrid's 340px auto-fill columns squeezed each row until titles truncated to a
   single character — fixed 2026-08-07.) ── */
.worklist { display: flex; flex-direction: column; gap: 12px; }
.workbadge { font-size: .62rem; text-transform: uppercase; letter-spacing: .06em; align-self: flex-start; }
.worklist .eventcard { flex-wrap: wrap; }
.worklist .eventcard__body { flex: 1 1 260px; }
.eventcard--action { border-inline-start: 3px solid var(--amber); }
.eventcard form { margin: 0; }
/* The row's status + action sit at the end; on narrow widths they wrap as a pair, not apart. */
.worklist .eventcard > .pill { margin-inline-start: auto; }
@media (max-width: 700px) {
    .eventgrid { grid-template-columns: 1fr; }
    .worklist .eventcard > .pill { margin-inline-start: 0; }
}
@media (max-width: 480px) {
    .eventcard .btn { width: 100%; text-align: center; }
    .worklist .eventcard form { width: 100%; }
}

/* ── Contractor permit detail: row link + crew count + status filter + file chips + timeline verified. ── */
/* The date block and title are the link to the issued-permit detail (NOT the whole row — event rows carry
   their own CTA buttons, so a full-row anchor would nest interactive elements). */
a.eventcard__date { text-decoration: none; }
a.eventcard__date:hover { background: rgba(2, 30, 255, .14); }
.eventcard__link {
    font-family: 'Outfit', sans-serif; font-weight: 600; color: var(--ink); text-decoration: none;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; align-self: flex-start; max-width: 100%;
}
.eventcard__link:hover { color: var(--blue); text-decoration: underline; }
.crewcount { color: var(--muted); font-size: .82rem; font-weight: 600; white-space: nowrap; }

.wo-filters { display: flex; gap: 6px; flex-wrap: wrap; }
.wo-chip {
    font-size: .82rem; font-weight: 600; color: var(--muted); text-decoration: none;
    border: 1px solid var(--line); border-radius: 999px; padding: 4px 12px; background: #fff;
}
.wo-chip:hover { border-color: var(--blue); color: var(--blue); }
.wo-chip.is-on { background: var(--blue); border-color: var(--blue); color: #fff; }

.filechips { display: flex; flex-wrap: wrap; gap: 8px; }
.filechip {
    display: inline-flex; align-items: center; gap: 8px; font-size: .85rem; font-weight: 600;
    color: var(--ink); text-decoration: none; background: #fafafa;
    border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 8px 12px;
}
.filechip:hover { border-color: var(--blue); color: var(--blue); }
.filechip__ic { width: 16px; height: 20px; border-radius: 2px; background: rgba(2, 30, 255, .12); flex: 0 0 auto; }

.backlink { color: var(--blue); text-decoration: none; font-weight: 600; font-size: .9rem; }
.backlink:hover { text-decoration: underline; }
.verified { color: var(--tealy); font-weight: 600; white-space: nowrap; }

/* Organiser/staff rows — promoted from per-page <style> blocks (W6 consolidation). */
.org-event__row { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; padding: 6px 0; }
.org-phases { display: flex; gap: 8px; flex-wrap: wrap; }

/* ── PTW v2 (Contractor-A, 2026-09-17): stepper, segments, pick rows, drop zone, closure, reference.
   Logical properties only (the page mirrors to RTL from the layout's dir attribute). ── */
.appbar__lang { margin: 0; }
.appbar__langbtn {
    background: none; border: 1px solid rgba(255,255,255,.25); color: #cfcfcf; border-radius: var(--radius-md);
    padding: 6px 10px; font: inherit; font-size: .85rem; font-weight: 600; cursor: pointer; min-height: 32px;
}
.appbar__langbtn:hover { color: #fff; border-color: #fff; }

/* The reference is the one string every actor quotes: monospace, prominent, selectable. */
.ref { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; letter-spacing: .02em; }
h1.ref { font-size: 1.5rem; font-weight: 700; }

.stepper { max-width: 680px; margin: 0 auto; }
.stepper__track { display: flex; gap: 6px; }
.stepper__track span { flex: 1; height: 4px; border-radius: 2px; background: var(--grey); transition: background .2s ease-out; }
.stepper__track span.is-done { background: var(--tealy); }
.stepper__track span.is-current { background: var(--blue); }
.stepper__labels { display: flex; justify-content: space-between; list-style: none; margin: 6px 0 0; padding: 0; font-size: .72rem; color: var(--muted); }
.stepper__labels li.is-current { color: var(--blue); font-weight: 700; }
.stepper__head { margin: 16px 0 12px; }
.stepper__head h1 { margin: 0; }
.stepper__meta { color: var(--muted); margin: 4px 0 0; font-size: .92rem; }
.stepper__section { font-size: 1.05rem; margin: 20px 0 4px; }
.stepper__form { padding-block-end: 120px; }

/* US-106: the Checks step, one section per screen. Phone: the section list folds under a one-line
   summary. Desktop (960px+): the list is a side panel next to the section. */
.secnav { margin: 4px 0 8px; border: 1px solid var(--line); border-radius: var(--radius-md); background: #fff; }
.secnav__toggle { display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; min-height: 44px;
    padding: 8px 12px; background: none; border: 0; font: inherit; font-weight: 600; color: var(--ink); text-align: start; cursor: pointer; }
.secnav__chev { width: 8px; height: 8px; border-inline-end: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg); transition: transform .15s ease-out; flex: none; }
.secnav.is-open .secnav__chev { transform: rotate(-135deg); }
.secnav__list { display: none; list-style: none; margin: 0; padding: 0 0 6px; border-top: 1px solid var(--line); }
.secnav.is-open .secnav__list { display: block; }
.secnav__item { display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; min-height: 44px;
    padding: 8px 12px; background: none; border: 0; border-inline-start: 3px solid transparent; font: inherit; color: var(--ink); text-align: start; cursor: pointer; }
.secnav__item:hover { background: var(--grey); }
.secnav__item.is-current { border-inline-start-color: var(--blue); color: var(--blue); font-weight: 600; }
.secnav__state { font-size: .8rem; color: var(--muted); white-space: nowrap; }
.secnav__item.is-done .secnav__state { color: var(--tealy); font-weight: 600; }
.secnav__item.is-done .secnav__state::before { content: "\2713"; margin-inline-end: 4px; }
.secflow__default { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; padding: 0; }
.stepper__hint { font-size: .82rem; color: var(--muted); margin: 0 auto 6px; max-width: 680px; min-height: 1.1em; }
.stepper__row .btn:disabled { opacity: .5; cursor: not-allowed; }
@media (min-width: 960px) {
    .stepper:has(.secnav) { max-width: 960px; }
    .secnav { float: inline-start; width: 240px; margin: 20px 0 0; }
    .secnav__toggle { display: none; }
    .secnav__list { display: block; border-top: 0; padding-top: 6px; }
    .stepper:has(.secnav) .ptw-csec { margin-inline-start: 264px; }
}

/* US-102: start from the last permit. The offer is a card above the sections; a copied answer carries a
   small "From last permit" mark until it is touched or its section is confirmed. */
.prefill-offer { border: 1.5px solid var(--blue); border-radius: var(--radius-md); padding: 12px 14px; margin: 4px 0 12px; background: #fff; }
.prefill-offer p { margin: 4px 0 10px; }
.prefill-offer__row { display: flex; flex-wrap: wrap; gap: 8px; }
.prefill-offer__row .btn { min-height: 44px; }
.prefill-tag { display: inline-block; margin-inline-start: 6px; padding: 1px 8px; border-radius: 999px; background: var(--amber); color: var(--ink); font-size: .72rem; font-weight: 600; vertical-align: middle; }
.ptw-csec__head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.ptw-csec__head .btn { min-height: 36px; flex: none; }

/* US-108: the site's help text under a question and its note under a section title. Muted, wraps, always
   visible (never tooltip-only, so it works on a phone). */
.q__help, .ptw-csec__desc { margin: 2px 0 6px; font-size: .85rem; line-height: 1.4; color: var(--muted); overflow-wrap: anywhere; }
.ptw-csec__desc { margin-top: 0; }

/* US-107: "Not applicable to this job" on a whole section. */
.na-switch { margin: 6px 0 10px; padding: 8px 12px; border: 1px dashed var(--line); border-radius: var(--radius-md); }
.na-switch .field--check { margin: 0; min-height: 36px; }
.na-switch__reason { margin-top: 8px; }
.review-sec__na { margin: 6px 0 0; font-size: .9rem; color: var(--muted); font-style: italic; }

/* US-103: a worker's certificates on the Company page, and a text-style button for small row actions. */
.certs { list-style: none; margin: 6px 0 2px; padding: 0; font-size: .85rem; }
.certs li { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; padding: 2px 0; }
.certs__del { display: inline; margin: 0; }
.linkbtn { background: none; border: 0; padding: 4px 0; min-height: 32px; font: inherit; font-size: .85rem; color: var(--blue); cursor: pointer; text-decoration: underline; }
.linkbtn:hover { color: var(--blue-dark); }

/* US-103: questions answered from the crew's certificates. */
.q__linked { margin: 4px 0 0; font-size: .88rem; color: var(--muted); }
.competence { border: 1px solid var(--line); border-radius: var(--radius-md); padding: 10px 12px; margin: 10px 0; background: #fff; }
.competence--gap { border-color: var(--red); }
.competence__head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.competence__note { margin: 6px 0 0; font-size: .88rem; }
.competence__workers { list-style: none; margin: 8px 0 0; padding: 0; }
.competence__worker { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 8px; padding: 6px 0; border-top: 1px solid var(--line); }
.competence__status { font-size: .85rem; color: var(--muted); }
.competence__worker--valid .competence__status { color: var(--tealy); font-weight: 600; }
.competence__worker--missing .competence__status, .competence__worker--expired .competence__status { color: var(--red); font-weight: 600; }
.competence__upload { flex-basis: 100%; display: grid; gap: 8px; margin-top: 6px; }
.competence__upload .btn { min-height: 44px; }

/* US-106 Review: answers read back by section, each with an Edit link to it. */
.review-sec { border-top: 1px solid var(--line); padding: 10px 0; }
.review-sec__head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.review-sec__head h3 { margin: 0; font-size: 1rem; }
.review-sec__list { margin: 6px 0 0; }
.review-sec__list > div { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0; font-size: .9rem; }
.review-sec__list dt { color: var(--muted); }
.review-sec__list dd { margin: 0; font-weight: 600; text-align: end; overflow-wrap: anywhere; }
.review-sec__list .is-missing dd { color: var(--red); }
.stepper__form .grid-2 { margin-top: 12px; }
.stepper__form .field--check { margin-top: 12px; }

.job { border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 16px; }
.job__title { font-family: 'Outfit', sans-serif; font-weight: 700; font-size: 1.1rem; margin-bottom: 8px; }
.proplist--tight { gap: 8px 20px; }

/* One question, one row (list rows, not cards: decision P4). */
.q { padding: 14px 0; border-bottom: 1px solid var(--grey); }
.q__label { font-size: 1rem; line-height: 1.35; margin-bottom: 8px; }
.q__label .req { color: var(--red); }
.q--collapsed { color: var(--muted); font-size: .85rem; padding: 8px 0; opacity: .8; }
.q--err .seg { border-color: var(--red); }
.q--err .seg .seg__opt + .seg__opt { border-inline-start-color: var(--red); }
.q--err .field__input { border-color: var(--red); }
.q__err { color: var(--red); font-size: .85rem; margin-top: 6px; }
.q__attached { margin: 0 0 8px; font-size: .9rem; }

/* Segmented radio group: Yes | No | N/A. 44px targets, the selected segment fills blue. */
.seg { display: flex; border: 1.5px solid var(--blue); border-radius: var(--radius-md); overflow: hidden; }
.seg__opt { flex: 1; position: relative; }
.seg__opt + .seg__opt { border-inline-start: 1.5px solid var(--blue); }
.seg__opt input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.seg__opt span { display: flex; align-items: center; justify-content: center; height: 44px; color: var(--blue); font-weight: 600; font-size: 1rem; }
.seg__opt input:checked + span { background: var(--blue); color: #fff; }
/* US-105: the pick is a filled button AND a check mark, never colour alone. */
.seg__opt input:checked + span::before { content: "\2713"; margin-inline-end: 6px; font-weight: 700; }
/* Choice options are free text: let a long one wrap inside its button rather than overflow at 360px. */
.seg--wrap .seg__opt { min-width: 0; }
.seg--wrap .seg__opt span { height: auto; min-height: 44px; padding: 6px 8px; text-align: center; line-height: 1.25; overflow-wrap: break-word; }
/* Long options: one full-width button per line, label at the start like a list. */
.seg--stack { flex-direction: column; }
.seg--stack .seg__opt + .seg__opt { border-inline-start: 0; border-top: 1.5px solid var(--blue); }
.seg--stack .seg__opt span { justify-content: flex-start; text-align: start; padding: 10px 14px; }
.q--err .seg--stack .seg__opt + .seg__opt { border-top-color: var(--red); }
.seg__opt input:focus-visible + span { outline: 2px solid var(--ink); outline-offset: -3px; }

/* Worker picker: 44px+ list rows with the checkbox at the inline end. */
.pick { display: flex; flex-direction: column; }
.pick__row { display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 10px 4px; border-bottom: 1px solid var(--grey); cursor: pointer; }
.pick__row.is-ineligible { opacity: .55; cursor: default; }
.pick__body { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.pick__body .pill { align-self: flex-start; margin-top: 2px; }
.pick__check { width: 24px; height: 24px; flex: 0 0 auto; accent-color: var(--blue); margin-inline-start: auto; }

/* Drop zone: the ONE upload surface (camera on phones through capture="environment"). */
.dropzone { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
    min-height: 64px; padding: 14px; border: 1.5px dashed var(--blue); border-radius: var(--radius-md);
    color: var(--blue); font-weight: 600; cursor: pointer; position: relative; margin-top: 8px; }
.dropzone input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.dropzone__file { color: var(--ink); font-weight: 400; font-size: .85rem; }
.dropzone:focus-within { outline: 2px solid var(--blue); outline-offset: 2px; }

/* Review: grouped proplist with an Edit link per group. */
.review { display: grid; gap: 14px; margin: 0; }
.review div { display: flex; flex-direction: column; gap: 4px; padding-bottom: 12px; border-bottom: 1px solid var(--grey); }
.review dt { display: flex; justify-content: space-between; font-family: 'Outfit', sans-serif; font-weight: 600; text-transform: uppercase; font-size: .72rem; letter-spacing: .5px; color: var(--muted); }
.review dt a { text-transform: none; letter-spacing: 0; font-weight: 600; }
.review dd { margin: 0; }
.review__warn { color: #8a5a12; font-weight: 600; }
.review__na { display: block; margin-top: 4px; }

/* Sticky bar: ghost on the inline start, primary on the inline end, 48px, above the keyboard. */
.stepper__bar { position: fixed; inset-inline: 0; bottom: 0; background: #fff; border-top: 1px solid var(--grey);
    padding: 8px 16px calc(12px + env(safe-area-inset-bottom)); z-index: 20; }
.stepper__saved { font-size: .78rem; color: var(--tealy); min-height: 1.1em; margin-bottom: 6px; max-width: 680px; margin-inline: auto; }
.stepper__row { display: flex; gap: 8px; max-width: 680px; margin-inline: auto; }
.stepper__row .btn { height: 48px; }
.stepper__row .btn--ghost { flex: 1; }
.stepper__row .btn--primary { flex: 2; }
.stepper__exit { display: block; margin: 8px auto 0; background: none; border: 0; color: var(--muted); font: inherit; font-size: .85rem; cursor: pointer; text-decoration: underline; min-height: 32px; }

/* Closure page: the job block first, then one upload, then what happens next. */
.closure__crew { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.closure__quote { border-inline-start: 3px solid var(--amber); padding: 8px 12px; background: #fdf6e8; border-radius: var(--radius-md); margin: 12px 0; }
.ticklist { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 6px; }
.ticklist li { display: flex; gap: 10px; align-items: flex-start; }
.ticklist li::before { content: "\2610"; color: var(--muted); }
.closure__done { display: flex; gap: 14px; align-items: center; padding: 18px 20px; border: 1px solid rgba(0,183,148,.35); background: rgba(0,183,148,.07); border-radius: var(--radius-lg); }

/* Chain timeline reuses .timeline; an extension row is labelled with its reference. */
.timeline__ref { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .85rem; }

.page__actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0 0; }
@media (max-width: 480px) { .page__actions .btn { flex: 1; } }

/* RTL mirrors through logical properties; the few physical rules above are corrected here. */
[dir="rtl"] .table th, [dir="rtl"] .table td { text-align: right; }
[dir="rtl"] .timeline__item:not(:last-child)::before { left: auto; right: 6px; }
[dir="rtl"] .task { border-left: 1px solid var(--line); border-right: 4px solid var(--grey); }
[dir="rtl"] .task--doc { border-right-color: var(--amber); }
[dir="rtl"] .task--service { border-right-color: var(--amber); }
[dir="rtl"] .task--staff { border-right-color: var(--blue); }
[dir="rtl"] .task--done { border-right-color: var(--tealy); }
[dir="rtl"] .appbar__nav { margin-left: 0; margin-right: 8px; }
