/* ============================================================
   Shared components — stat cards, cards, tiles, tables, badges,
   buttons, forms, alerts, modal, definition lists, evidence,
   signatures, the golden-thread timeline, empty states, section titles
   ============================================================ */

/* ---------- KPI stat cards ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(165px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat {
    background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 16px 18px; box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.stat::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--hd-blue); }
.stat.gold::before { background: var(--hd-gold); }
.stat.warn::before { background: var(--warn); }
.stat.danger::before { background: var(--danger); }
.stat .n { font-size: 30px; font-weight: 700; color: var(--ink); line-height: 1.1; }
.stat .l { font-size: 12.5px; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .04em; margin-top: 4px; }
/* A stat card that's a link (e.g. dashboard "needs attention" tiles drilling into the inbox). */
a.stat.as-link { display: block; color: inherit; text-decoration: none; transition: transform .08s, box-shadow .08s; }
a.stat.as-link:hover { text-decoration: none; transform: translateY(-2px); box-shadow: 0 6px 20px rgba(16,32,56,.12); border-color: #cdd9ea; }
/* Notification dot on a stat tile — "you need to react to something here" (RFI/IRS awaiting you).
   Sits inside the padding because .stat clips overflow. */
.stat-dot {
    position: absolute; top: 10px; right: 12px; z-index: 1;
    min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px;
    background: var(--danger); color: #fff; font-size: 12px; font-weight: 700; line-height: 20px;
    text-align: center; box-shadow: 0 0 0 3px var(--card);
}

/* ---------- KPI cards (dashboard) ----------
   Compact metric cards grouped into labelled sections — one for items needing action, one purely
   informational. auto-fill (not auto-fit) keeps the cards at their natural width and left-clustered like the
   building tiles below, rather than stretching a handful of cards across the whole row into sparse boxes.
   Action cards carry a coloured top accent; link cards lift on hover and reveal a chevron.
   (.stat is left untouched — it's still used on the Clients/Projects/Settings pages.) */
/* Two side-by-side sections ("Needs action" + "Overview"), each a 2×2 grid of cards, spread across the full
   width. They wrap to stacked sections on narrower screens. */
.kpi-row { display: flex; flex-wrap: wrap; gap: 28px; align-items: flex-start; margin: 22px 0 8px; }
.kpi-row > .kpi-col { flex: 1 1 360px; min-width: 0; }
/* Size the two groups to their column counts so the tiles stay one width and the rows line up across both
   (a 2-wide "Needs action" beside a 3-wide "Overview" => both two rows tall, no ragged overhang). */
.kpi-row > .kpi-col.span-2 { flex: 2 1 300px; }
.kpi-row > .kpi-col.span-3 { flex: 3 1 440px; }
.kpi-col .section-title { margin: 0 0 14px; }
.kpi-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
@media (max-width: 560px) { .kpi-grid { grid-template-columns: 1fr; } }
/* A single combined, full-width KPI block (client dashboard): six cards as three columns, two rows. */
.kpi-grid-3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 820px) { .kpi-grid-3 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { .kpi-grid-3 { grid-template-columns: 1fr; } }
.kpi {
    display: block; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
    box-shadow: var(--shadow); padding: 16px 18px; border-top: 3px solid transparent;
    color: inherit; text-decoration: none;
}
.kpi .n { font-size: 30px; font-weight: 700; color: var(--ink); line-height: 1.1; }
.kpi .l { font-size: 12.5px; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .04em; margin-top: 4px; }
/* Coloured top accent for the action cards. */
.kpi.blue   { border-top-color: var(--hd-blue); }
.kpi.gold   { border-top-color: var(--hd-gold); }
.kpi.warn   { border-top-color: var(--warn); }
.kpi.danger { border-top-color: var(--danger); }
/* A card that drills into another screen. */
a.kpi { transition: transform .08s, box-shadow .08s; }
a.kpi:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(16,32,56,.12); border-color: #cdd9ea; }
a.kpi .l::after {
    content: "›"; margin-left: 5px; color: var(--ink-soft);
    opacity: 0; transition: opacity .1s, transform .1s; display: inline-block;
}
a.kpi:hover .l::after { opacity: .85; transform: translateX(2px); }

/* ---------- Cards ---------- */
.card {
    background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
    box-shadow: var(--shadow); margin-bottom: 20px;
}
.card-h { padding: 15px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card-h h3 { margin: 0; font-size: 15.5px; }
.card-b { padding: 18px 20px; }
.card-b.tight { padding: 6px 0; }

.grid-2 { display: grid; grid-template-columns: 1.6fr 1fr; gap: 20px; align-items: start; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
@media (max-width: 980px) { .grid-2 { grid-template-columns: 1fr; } }
/* Decision page: the right rail sits beside the Decision-detail card and is matched to ITS height (not the
   whole column). The rest of the left content (evidence, proposals, sign-offs) flows in the row beneath. */
/* Both top-row items stretch to the row's (content-computed) height, so the Decision-detail card and the rail
   always end level whichever one is taller — no fixed heights, so nothing overflows. */
.decision-grid > .dd-card { grid-column: 1; grid-row: 1; align-self: stretch; }
/* Contractor: don't stretch the decision card to a taller side rail — let it take its natural height so it
   doesn't show an empty base. (Thread holder keeps the stretch above to stay level with its rail.) */
.decision-grid > .dd-card-natural { align-self: start; }
/* The rest spans the full width below the detail+rail row, then splits into two columns of its own. */
.decision-grid > .dd-rest { grid-column: 1 / -1; grid-row: 2; }
/* Contractor side rail: the three quick-reference cards (assignment, information requests, evidence) stack in
   a single uniform column beside the big Decision-detail card (column 2). Each cell holds a section-title + its
   card; uniform full-column width so the right edge lines up cleanly down the column. */
.decision-grid > .dd-side, .decision-grid > .dd-side-b { grid-column: 2; align-self: start; display: flex; flex-direction: column; gap: 20px; }
.decision-grid > .dd-side { grid-row: 1; }
.dd-side > .dd-cell, .dd-side-b > .dd-cell { display: flex; flex-direction: column; }
/* Contractor golden-thread audit card: the body scrolls internally so a long trail never runs off the page. */
.dd-thread-card { display: flex; flex-direction: column; }
.dd-thread-card > .card-b { max-height: 460px; overflow: auto; }
/* In the accepted 2×2 the right column stretches to the Decision-detail card's height and the Golden-thread
   card fills whatever's left under "Your assignment" — so its bottom lines up with Decision detail's, however
   many fields or entries there are, instead of hanging a fixed-height "lip" lower. */
.decision-grid.dd-contractor > .dd-side { align-self: stretch; }
.decision-grid.dd-contractor > .dd-side > .dd-cell:last-child { flex: 1 1 0; min-height: 0; }
.decision-grid.dd-contractor .dd-thread-card { flex: 1 1 0; min-height: 0; }
.decision-grid.dd-contractor .dd-thread-card > .card-b { flex: 1 1 auto; max-height: none; }
/* Contractor top section: Decision detail (row 1) and Evidence (row 2) stack in the wide left column; the
   assignment + requests rail takes the right column across both rows, so requests can grow downward as more
   are raised; the work rows (proposal/photos/sign-offs) flow full-width beneath (row 3). */
.decision-grid.dd-contractor > .dd-under  { grid-column: 1; grid-row: 2; }
.decision-grid.dd-contractor > .dd-side   { grid-row: 1; }
.decision-grid.dd-contractor > .dd-side-b { grid-row: 2; }
.decision-grid.dd-contractor > .dd-rest   { grid-row: 3; }
/* The sections below the decision detail pair up into an explicit two-column grid (each section is a block):
   Evidence | Information requests, then Sign-offs | Contractor proposals. Grid rows are independent, so
   opening a proposal grows only its own row instead of reflowing the whole layout. */
/* Natural heights by default, so a card never blows up to match a much taller neighbour (e.g. Sign-offs next
   to an expanded/collapsed proposal accordion — matching that looks terrible). */
.dd-rest.dd-grid { display: grid; grid-template-columns: 1fr 1fr; column-gap: 20px; align-items: start; }
.dd-rest.dd-grid > .dd-late { order: 1; }   /* Contractor proposals lands beside Sign-offs, not Requests. */
.dd-rest.dd-grid > .dd-block { display: flex; flex-direction: column; }
/* Only the Evidence | Information-requests pair is matched: the Information-requests card stretches to its
   neighbour's height (its Raise button pins to the bottom). Nothing else is forced to match. */
.dd-rest.dd-grid > .dd-match { align-self: stretch; }
.dd-rest.dd-grid > .dd-match > .card { flex: 1; }
@media (max-width: 980px) { .dd-rest.dd-grid { grid-template-columns: 1fr; } }
/* Contractor bottom: the long "Your work proposal" (left) sits beside a stack of their photos + sign-offs
   (right, .dd-rstack). The right column stretches to the (taller) proposal's height so the columns bottom-
   align — but the photo + sign-off cards keep their NATURAL size: the space BETWEEN them grows to take up the
   slack, rather than the card faces stretching. So a growing scope box just widens the gap, photos stays put. */
.dd-rest.dd-twocol { display: grid; grid-template-columns: 1fr 1fr; column-gap: 20px; align-items: stretch; }
.dd-rest.dd-twocol > .dd-block { display: flex; flex-direction: column; }
/* The proposal card (left) fills its column, so when the right stack is the taller side the proposal stretches
   down to meet the sign-off card's bottom — columns always end level, never staggered. */
.dd-rest.dd-twocol > .dd-block > .card { flex: 1; }
.dd-rstack { display: flex; flex-direction: column; gap: 20px; justify-content: space-between; }
@media (max-width: 980px) {
    .dd-rest.dd-twocol { grid-template-columns: 1fr; align-items: start; }
    .dd-rstack { justify-content: flex-start; }
}
.decision-grid > .rail { grid-column: 2; grid-row: 1; align-self: stretch; display: flex; flex-direction: column; }
/* Duty holders and Audit each take half the rail; their bodies scroll if there's more than fits. Audit is
   capped at the top few entries (see Details.cshtml) so it stays put — extra duty holders just scroll. */
.decision-grid > .rail > .card { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.decision-grid > .rail > .card > .card-b { flex: 1; min-height: 0; overflow: auto; }
/* Audit: keep its "Show all" link pinned to the bottom of its half. */
.decision-grid > .rail > .card:last-child > .card-b { display: flex; flex-direction: column; }
.decision-grid > .rail > .card:last-child .tl-more-link { margin-top: auto; padding-top: 14px; }
@media (max-width: 980px) {
    /* Stack everything in DOM order on a single column — drop the explicit row/column placement. */
    .decision-grid > .dd-card, .decision-grid > .dd-rest, .decision-grid > .rail, .decision-grid > .dd-side,
    .decision-grid > .dd-side-b, .decision-grid.dd-contractor > .dd-under, .decision-grid.dd-contractor > .dd-side,
    .decision-grid.dd-contractor > .dd-side-b, .decision-grid.dd-contractor > .dd-rest {
        grid-column: auto; grid-row: auto;
    }
}

/* ---------- Client / entity tiles ---------- */
.tile {
    display: block; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 18px; box-shadow: var(--shadow); color: inherit; text-decoration: none; transition: transform .08s, box-shadow .08s;
}
.tile:hover { text-decoration: none; transform: translateY(-2px); box-shadow: 0 6px 20px rgba(16,32,56,.12); border-color: #cdd9ea; }
/* A tile rendered as a <button> (e.g. opens a drawer) should look identical to the anchor tiles. */
button.tile { width: 100%; text-align: left; font: inherit; cursor: pointer; }
.tile .tile-top { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.tile .mono {
    width: 44px; height: 44px; border-radius: 9px; background: var(--hd-blue-soft); color: var(--ink);
    font-weight: 700; display: grid; place-items: center; font-size: 16px; flex: none;
}
.tile .mono svg { width: 22px; height: 22px; }
.tile h4 { margin: 0; font-size: 15.5px; }
.tile .sub { color: var(--ink-soft); font-size: 12.5px; }
.tile-stats { display: flex; gap: 18px; margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--line); }
.tile-stats div b { display: block; color: var(--ink); font-size: 18px; }
.tile-stats div span { color: var(--ink-soft); font-size: 11.5px; text-transform: uppercase; letter-spacing: .03em; }

/* ---------- Tables ---------- */
.tbl { width: 100%; border-collapse: collapse; }
.tbl th, .tbl td { text-align: left; padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl th { font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-soft); background: #fafbfd; }
.tbl tbody tr:hover { background: #fafcff; }
.tbl td .ref { font-weight: 700; color: var(--ink); }
.tbl a { font-weight: 600; }
/* A whole-name cell that acts as the row's primary drill-in link: reads as a strong title, reveals it's
   clickable on hover. Used where the row name navigates into a detail/manage page. */
.row-link { color: var(--ink); text-decoration: none; }
.row-link:hover { color: var(--hd-blue); text-decoration: underline; }
/* Centred variant (e.g. the duty-holders table) — centre every header and cell, including the status cell's
   badge + button row, and align cells to the middle so short content sits centred vertically too. */
.tbl-center th, .tbl-center td { text-align: center; vertical-align: middle; }
.tbl-center .duty-status { justify-content: center; }

/* ---------- Badges ---------- */
.badge {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap;
    border: 1px solid transparent;
}
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: .9; }
.badge-draft { background: #eef1f5; color: #5b6b7e; }
.badge-open { background: #fff4de; color: #9a6a00; }      /* decision raised, active */
.badge-progress { background: #e7eef8; color: #2a557f; } /* work underway */
.badge-review { background: #fff4de; color: #9a6a00; }
.badge-approved { background: #e3f6ec; color: #157f44; }
.badge-rejected { background: #fde7e4; color: #b5392b; }
.badge-superseded { background: #efeaf7; color: #6a4fa3; }
.badge-closed { background: #e7eef8; color: #2a557f; }
.pill { display:inline-block; padding: 2px 9px; border-radius: 999px; background: var(--hd-blue-soft); color: var(--ink); font-size: 11.5px; font-weight: 600; }
.pill.gold { background: var(--hd-gold-soft); color: #475467; }
/* Status cell: keep the state pill and its inline action (e.g. Resend email) on one row rather than stacked. */
.status-cell { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.status-cell .inline-action { margin: 0; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer;
    white-space: nowrap; padding: 9px 16px; border-radius: 8px; font-weight: 600; font-size: 13.5px;
    /* font-family/line-height don't inherit into <button>, so set them so <a.btn> and <button.btn> match. */
    font-family: inherit; line-height: 1.2;
    border: 1px solid var(--hd-navy); background: var(--hd-navy); color: #fff; text-decoration: none;
}
.btn:hover { background: var(--hd-navy-700); text-decoration: none; }
.btn.ghost { background: #fff; color: var(--ink); border-color: var(--line); }
.btn.ghost:hover { background: #f3f6fb; }
/* Former accent button — now matches the standard navy button so every button is one colour. */
.btn.gold { background: var(--hd-navy); border-color: var(--hd-navy); color: #fff; }
.btn.gold:hover { background: var(--hd-navy-700); }
.btn.sm { padding: 6px 12px; font-size: 12.5px; }
.btn[disabled] { opacity: .45; cursor: not-allowed; pointer-events: none; }
/* A row of action buttons (possibly each in its own form) with even spacing. */
.btn-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.btn-row form { margin: 0; }

/* ---------- Forms ---------- */
.form-row, .field { margin-bottom: 16px; }
.form-row label, .field label { display: block; font-weight: 600; font-size: 13px; color: var(--ink); margin-bottom: 5px; }
.form-row .hint, .field .hint { font-weight: 400; color: var(--ink-soft); font-size: 12px; }
.form-row label .req, .field label .req { color: var(--danger, #c0392b); font-weight: 700; margin-left: 2px; }
.sub { color: var(--ink-soft); font-size: 12.5px; }
.form-control, .input, input[type=text], input[type=email], input[type=password], textarea, select {
    width: 100%; min-height: 42px; box-sizing: border-box;
    padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px;
    font-family: var(--font); font-size: 14px; background: #fff; color: var(--ink);
}
.form-control:focus, input:focus, textarea:focus, select:focus { outline: none; border-color: var(--hd-blue); box-shadow: 0 0 0 3px rgba(33,118,189,.14); }
textarea { min-height: 80px; resize: vertical; }

/* Compact numeric input for the per-tenant upload-limit control on the platform tenants table. */
.input.upload-limit { width: 5rem; min-width: 5rem; display: inline-block; vertical-align: middle; margin-right: 4px; }

/* File inputs — replace the dated native "Choose File" button with one that matches our buttons. */
input[type=file] {
    width: 100%; min-height: 42px; box-sizing: border-box; display: flex; align-items: center;
    padding: 5px 8px; border: 1px solid var(--line); border-radius: 8px;
    background: #fff; color: var(--ink-soft); font-family: var(--font); font-size: 13px; cursor: pointer;
}
input[type=file]::file-selector-button {
    flex: 0 0 auto; height: 30px; margin-right: 12px; padding: 0 14px; border-radius: 7px; cursor: pointer;
    border: 1px solid var(--hd-navy); background: var(--hd-navy); color: #fff;
    font-family: var(--font); font-weight: 600; font-size: 12.5px; line-height: 1;
    transition: background .12s ease;
}
input[type=file]::file-selector-button:hover { background: var(--hd-navy-700); }
input[type=file]:focus { outline: none; border-color: var(--hd-blue); box-shadow: 0 0 0 3px rgba(33,118,189,.14); }
/* Two-up when there's room, but stack as soon as the CONTAINER is narrow (e.g. a proposal in a side column),
   not just when the viewport is — so fields never cram or truncate. */
.form-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; align-items: stretch; }
/* Bottom-align the control in each cell so inputs line up even when one label wraps (e.g. a label + hint). */
.form-2 > .form-row { display: flex; flex-direction: column; }
.form-2 > .form-row > input, .form-2 > .form-row > select, .form-2 > .form-row > textarea { margin-top: auto; }
.field-validation-error, .text-danger { color: var(--danger); font-size: 12.5px; }
/* Inline checkbox + label row (e.g. "Make this the level's main plan"). */
.check-row { display: flex; align-items: center; gap: 8px; font-weight: 600; cursor: pointer; }
.check-row input[type="checkbox"] { width: 16px; height: 16px; flex: none; margin: 0; }

/* ---------- Alerts ---------- */
.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 18px; font-weight: 500; border: 1px solid; }
.alert-success { background: #e6f7ee; border-color: #b6e6cc; color: #157f44; }
.alert-error { background: #fdecea; border-color: #f5c6c0; color: #b5392b; }
.alert-info { background: var(--hd-blue-soft); border: 1px solid var(--line); color: var(--ink-soft); }

/* ---------- Modal (reusable component) ---------- */
.modal-overlay {
    position: fixed; inset: 0; z-index: 100;
    background: rgba(15,27,45,.55); backdrop-filter: blur(1.5px);
    display: none; align-items: flex-start; justify-content: center;
    padding: 48px 16px; overflow-y: auto;
}
.modal-overlay.open { display: flex; }
.modal-dialog {
    background: var(--card); border-radius: var(--radius); width: 100%; max-width: 640px;
    margin: 0 auto 48px;   /* top-aligned (overlay pads the top) so dropdowns have room to open downward */
    box-shadow: 0 24px 70px rgba(16,32,56,.38); animation: modalIn .15s ease;
}
.modal-dialog.lg { max-width: 820px; }
@keyframes modalIn { from { transform: translateY(-14px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-head { padding: 18px 22px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.modal-head h3 { margin: 0; font-size: 17px; }
.modal-head .sub { color: var(--ink-soft); font-size: 12.5px; margin-top: 2px; }
.modal-head .x { cursor: pointer; border: none; background: none; font-size: 24px; line-height: 1; color: var(--ink-soft); padding: 0 4px; }
.modal-head .x:hover { color: var(--ink); }
.modal-body { padding: 20px 22px; }
.modal-foot { padding: 16px 22px; border-top: 1px solid var(--line); display: flex; gap: 10px; justify-content: flex-end; }

/* ---------- Definition lists ---------- */
.dl { display: grid; grid-template-columns: 210px 1fr; gap: 0; }
.dl dt { padding: 11px 16px; font-weight: 600; color: var(--ink); background: #fafbfd; border-bottom: 1px solid var(--line); font-size: 13px; }
.dl dd { padding: 11px 16px; margin: 0; border-bottom: 1px solid var(--line); }
@media (max-width: 700px) { .dl { grid-template-columns: 1fr; } .dl dt { border-bottom: none; } }

/* ---------- Inline-editable fields (decision detail) ---------- */
.efields { display: flex; flex-direction: column; }
.efield { padding: 12px 0; border-bottom: 1px solid var(--line); }
.efield:first-child { padding-top: 2px; }
.efield:last-child { border-bottom: none; padding-bottom: 2px; }
.efield-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.efield-label { font-weight: 600; font-size: 13px; color: var(--ink); }
/* Small, unobtrusive pencil that lifts on hover. */
.efield .pencil {
    flex: none; display: inline-flex; align-items: center; justify-content: center;
    width: 26px; height: 26px; padding: 0; border: 1px solid var(--line); border-radius: 6px;
    background: #fff; color: var(--ink-soft); cursor: pointer; opacity: .5;
    transition: opacity .15s, color .15s, border-color .15s;
}
.efield .pencil:hover { opacity: 1; color: var(--hd-blue); border-color: var(--hd-blue); }
.efield .pencil svg { width: 14px; height: 14px; }
/* The value: let big write-ups through in full — preserve the author's line breaks and wrap long words/URLs. */
.efield-view { margin-top: 5px; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; }
.efield-view.empty-val { color: var(--ink-soft); }
.efield-edit { margin-top: 8px; }
.efield-edit .efield-input { width: 100%; }
.efield-edit textarea.efield-input { min-height: 120px; line-height: 1.55; }
.efield-actions { display: flex; gap: 8px; margin-top: 8px; }

/* ---------- Evidence gallery ---------- */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
.ev {
    border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: #fff; box-shadow: var(--shadow);
}
.ev .thumb { height: 130px; background: #0f1b2d; display: grid; place-items: center; overflow: hidden; }
.ev .thumb img { width: 100%; height: 100%; object-fit: cover; }
.ev .thumb .file-ico { color: #fff; font-size: 38px; }
.ev .ev-b { padding: 10px 12px; }
.ev .ev-b .t { font-weight: 600; font-size: 12.5px; color: var(--ink); }
.ev .ev-b .d { color: var(--ink-soft); font-size: 12px; margin-top: 3px; }
.ev .ev-b .m { color: #93a2b5; font-size: 11px; margin-top: 6px; }

/* ---------- Signatures ---------- */
.sign-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.sign { border: 1px solid var(--line); border-radius: var(--radius); background: #fff; box-shadow: var(--shadow); overflow: hidden; }
.sign .sig-img { background: #fff; border-bottom: 1px solid var(--line); height: 92px; display: grid; place-items: center; }
.sign .sig-img img { max-height: 84px; max-width: 90%; }
.sign .sig-b { padding: 11px 14px; }
.sign .sig-b b { color: var(--ink); }
.sign .sig-b .role { color: var(--ink-soft); font-size: 12.5px; }
.sign .sig-b .cmt { font-size: 12.5px; margin-top: 6px; font-style: italic; color: #4a5a6e; }
.sign .sig-b .when { font-size: 11.5px; color: #93a2b5; margin-top: 6px; }

/* Saved-signature preview (profile page + sign-off form) */
.sig-preview { width: 180px; height: 72px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; display: grid; place-items: center; overflow: hidden; flex: none; margin: 6px 0; }
.sig-preview img { max-height: 64px; max-width: 92%; }
.sig-preview span { color: var(--ink-soft); font-size: 12.5px; }
.radio-line { display: flex; align-items: center; gap: 8px; font-weight: 400; margin: 4px 0; }
.radio-line input { width: auto; margin: 0; }

/* ---------- Golden thread / audit timeline ---------- */
/* Dot is 28px at left:0 (centre x=14); the line is 2px at left:13 (centre x=14) — they align. */
.thread { position: relative; }
.thread::before { content: ""; position: absolute; left: 13px; top: 14px; bottom: 14px; width: 2px;
    background: linear-gradient(180deg, var(--hd-gold), #e7d4a1); border-radius: 2px; }
.tl-item { position: relative; padding: 0 0 20px 44px; min-height: 28px; }
.tl-item:last-child { padding-bottom: 0; }
/* The connecting line runs to the thread's bottom; when the last row is tall (e.g. a wrapped heading in a
   narrow column) it would dangle past the final dot. Mask that tail so the line always ends on the last dot. */
.tl-item:last-child::after { content: ""; position: absolute; left: 12px; top: 28px; bottom: -2px; width: 4px; background: var(--card); }
.tl-item .dot {
    position: absolute; left: 0; top: 0; width: 28px; height: 28px; border-radius: 50%;
    background: #fff; border: 2px solid var(--hd-gold); color: var(--ink);
    display: grid; place-items: center; z-index: 1;
}
.tl-item .dot .ico { width: 15px; height: 15px; }
/* inline icons sit nicely on the text baseline */
.ico { display: inline-block; vertical-align: -0.18em; }
.tl-meta .ico { width: 14px; height: 14px; margin-right: 2px; opacity: .85; }
.tl-item .tl-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.tl-item .tl-head b { color: var(--ink); font-size: 13.5px; }
.tl-item .tl-head .ref { font-size: 11.5px; }
.tl-item .tl-meta { color: var(--ink-soft); font-size: 12px; margin-top: 2px; }
.tl-item .tl-detail { color: #4a5a6e; font-size: 12.5px; margin-top: 4px; background: #fafbfd; border: 1px solid var(--line); border-radius: 7px; padding: 7px 10px; }
/* An RFI/IRS message shown in full on its own timeline line. A left accent tells the two sides apart:
   thread-holder (gold) vs contractor (navy), matching the pin-panel thread bubbles. */
.tl-item .tl-msg { border-left: 3px solid var(--line); }
.tl-item .tl-msg.from-holder { border-left-color: var(--hd-gold, #c9a227); }
.tl-item .tl-msg.from-contractor { border-left-color: var(--hd-navy, #1e3a5f); }
.tl-item .tl-msg .ir-msg-body { white-space: pre-wrap; }
.tl-item .tl-msg .ir-msg-files { margin-top: 6px; }
/* "Show all N entries" link to the full audit-trail page (the decision card shows only the most recent). */
.tl-more-link { display: inline-block; margin-top: 4px; padding-left: 44px;
    color: var(--hd-navy); font-weight: 600; font-size: 12.5px; text-decoration: none; }
.tl-more-link:hover { text-decoration: underline; }

.empty { text-align: center; padding: 40px 20px; color: var(--ink-soft); }
.empty .big { font-size: 32px; opacity: .4; }

.section-title { display:flex; align-items:center; gap:10px; margin: 26px 0 14px; }
.section-title h2 { margin: 0; font-size: 18px; }
.section-title .gline { flex: 1; height: 2px; background: linear-gradient(90deg, var(--hd-gold-soft), transparent); }

/* Work-proposal version tabs — one tab per submitted round, each panel tells that round's story. */
.ptabs { margin-bottom: 6px; }
.ptab-strip { display: flex; gap: 6px; flex-wrap: wrap; border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.ptab {
    display: inline-flex; align-items: center; gap: 6px; font: inherit; cursor: pointer;
    background: transparent; color: var(--ink-soft); border: 1px solid var(--line); border-bottom: none;
    border-radius: 8px 8px 0 0; padding: 7px 12px; margin-bottom: -1px;
}
.ptab:hover { color: var(--ink); }
.ptab.active { background: var(--card); color: var(--ink); font-weight: 600; box-shadow: inset 0 -2px 0 var(--hd-gold); }
.ptab-panel { display: none; }
.ptab-panel.active { display: block; padding: 4px 2px 2px; }
.pstory-h { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.pstory-h h4 { margin: 0; font-size: 15px; }
.pstory-meta { color: var(--ink-soft); font-size: 12px; margin: 6px 0 14px; }
.pstory-field { margin-bottom: 14px; }
.pstory-field > label { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-soft); margin-bottom: 4px; }
.pstory-text { white-space: pre-wrap; color: var(--ink); font-size: 14px; line-height: 1.5; }
.pstory-decision { margin-top: 14px; padding: 12px 15px; border-radius: 9px; border: 1px solid var(--line); background: #fafbfd; }
.pstory-decision-h { margin-bottom: 4px; }
.pstory-decision .pstory-text { margin: 4px 0; }
.pstory-decision .pstory-meta { margin: 4px 0 0; }
.pstory-decision.ok { background: #e3f6ec; border-color: #bce6cd; }
.pstory-decision.no { background: #fde7e4; border-color: #f5c6bf; }
.pstory-decision.muted { border-style: dashed; background: transparent; }

/* The per-version approve/reject (or correct-decision) form: note on its own line, then field + buttons. */
.decide-form { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 16px; padding-top: 14px; border-top: 1px dashed var(--line); }
.decide-form .decide-note { flex-basis: 100%; margin: 0 0 2px; }
.decide-form .form-control { flex: 1 1 240px; min-width: 200px; }
.decide-form .btn { white-space: nowrap; }
/* Proposal header: gap between the contractor name and its status badge, and room before the tabs. */
.proposal > .head-meta { display: flex; align-items: center; gap: 8px; margin: 0 0 14px; }
/* Space stacked contractor proposals apart. */
.proposal + .proposal { margin-top: 22px; padding-top: 20px; border-top: 1px solid var(--line); }

/* Thread holder's per-contractor accordion: one collapsible lane per sub-contractor. */
details.prop-acc { border: 1px solid var(--line); border-radius: 10px; margin-bottom: 12px; background: var(--card); }
details.prop-acc[open] { box-shadow: var(--shadow); }
.prop-acc-h { list-style: none; cursor: pointer; user-select: none; display: flex; align-items: center; gap: 10px; padding: 13px 15px; }
.prop-acc-h::-webkit-details-marker { display: none; }
.prop-acc-h::before { content: ""; width: 7px; height: 7px; border-right: 2px solid var(--ink-soft); border-bottom: 2px solid var(--ink-soft); transform: rotate(-45deg); transition: transform .15s ease; margin-right: 2px; }
details.prop-acc[open] .prop-acc-h::before { transform: rotate(45deg); }
details.prop-acc[open] .prop-acc-h { border-bottom: 1px solid var(--line); }
.prop-acc-name { font-weight: 700; color: var(--ink); }
.prop-acc-h .badge { margin-left: auto; }
.prop-acc-h .pill.attention { margin-left: auto; }
.prop-acc-h .pill.attention + .badge { margin-left: 0; }
.prop-acc-b { padding: 16px 15px; }

/* Flag a lane whose proposal is waiting on the thread holder — visible even when collapsed. */
.pill.attention { background: #fff4e0; color: #92600a; border: 1px solid #f3d9a8; }
.prop-acc.needs-action { border-color: #f0c97a; box-shadow: inset 3px 0 0 var(--warn); }
.prop-acc.needs-action > .prop-acc-h { background: #fffaf0; }

/* Per-contractor collaboration: proposal documents + the private conversation. Each block gets a clear
   underlined section header so the documents / conversation don't blend into the version story above. */
.collab { margin-top: 22px; padding-top: 20px; border-top: 2px solid var(--line); }
.collab-h { display: flex; align-items: baseline; flex-wrap: wrap; gap: 8px;
    margin: 24px 0 12px; padding-bottom: 7px; border-bottom: 1px solid var(--line); }
.collab-h:first-child { margin-top: 0; }
.collab-h h4 { margin: 0; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-soft); }
.collab-upload { margin-top: 12px; }
.collab-comment { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.collab-comment .form-control { width: 100%; }
