/* =========================================================
   JOIN · Component Library Styles
   All values come from tokens.css. Never hard-code colours,
   sizes, or radii here - reference --token names.
   ========================================================= */

/* ---------- Typography utilities ---------- */
.display { font: 700 var(--fs-display)/var(--lh-display) var(--font-heading); letter-spacing: -0.03em; margin: 0; }
.h-xl    { font: 600 var(--fs-h-xl)/var(--lh-h-xl) var(--font-heading); letter-spacing: -0.025em; margin: 0; }
.h-lg    { font: 600 var(--fs-h-lg)/var(--lh-h-lg) var(--font-heading); letter-spacing: -0.02em; margin: 0; }
.h-md    { font: 600 var(--fs-h)/var(--lh-h) var(--font-heading); margin: 0; }
h1, h2, h3, h4 { font-family: var(--font-heading); font-weight: 600; letter-spacing: -0.02em; line-height: 1.15; margin: 0; }
h1 { font-size: var(--fs-display); font-weight: 700; letter-spacing: -0.03em; }
h2 { font-size: var(--fs-h-xl); }
h3 { font-size: var(--fs-h-lg); }
h4 { font-size: 16px; }

.eyebrow {
  font-family: var(--font-mono);
  font-size: var(--fs-caption);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 500;
}
.meta {
  font-family: var(--font-mono);
  font-size: var(--fs-caption);
  letter-spacing: 0.04em;
  color: var(--muted);
}
.label {
  font-family: var(--font-sans);
  font-size: var(--fs-label);
  font-weight: 600;
  letter-spacing: var(--track-wide);
  color: var(--muted);
  text-transform: uppercase;
}
.no-tt { text-transform: none; letter-spacing: 0; font-weight: 400; }
.mono { font-family: var(--font-mono); font-size: var(--fs-mono); font-variant-numeric: tabular-nums; }
.mono-sm { font-size: 10px; }
.mono-xs { font-size: var(--fs-caption); }
.muted { color: var(--muted); }
.strong { font-weight: 600; }
.small { font-size: var(--fs-caption); }
.lead { font-size: 15px; line-height: 1.6; max-width: 720px; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
code { font-family: var(--font-mono); font-size: 12px; color: var(--fg-2); }

/* Semantic text */
.delta-success { color: var(--success); }
.delta-warning { color: var(--warning); }
.delta-danger  { color: var(--danger); }
.delta-info    { color: var(--info); }
.dot-gold      { color: var(--brand-gold); }
.link          { color: var(--info); text-decoration: none; }
.link:hover    { text-decoration: underline; }
.title-link    { color: inherit; text-decoration: none; cursor: pointer; }
.title-link:hover { text-decoration: underline; }

/* ---------- Library shell (this page only) ---------- */
.lib-rail {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: var(--sp-3) var(--sp-6);
  box-shadow: var(--shadow-sm);
}
.lib-rail-left { display: flex; align-items: center; gap: var(--sp-4); }
.lib-rail-right { display: flex; align-items: center; gap: var(--sp-3); }
.lib-logo { height: 22px; width: auto; }
.lib-rail-divider { width: 1px; height: 22px; background: var(--border); }
.lib-rail-title {
  font-family: var(--font-mono);
  font-size: var(--fs-caption);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.lib-section {
  padding: var(--sp-16) var(--sp-12);
  border-bottom: 1px solid var(--border);
}
.lib-section + .lib-section { background: var(--surface); }
.lib-section:nth-child(even of .lib-section) { background: var(--bg); }
.lib-intro { background: var(--surface); }
.lib-section-head { max-width: 980px; margin-bottom: var(--sp-12); }
.lib-section-head h1, .lib-section-head h2 { margin-top: var(--sp-3); }
.lib-section-head .lead { margin-top: var(--sp-4); color: var(--fg-2); }

.lib-block {
  max-width: 1240px;
  margin: 0 auto var(--sp-12);
}
.lib-block:last-child { margin-bottom: 0; }
.lib-block-head {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-bottom: var(--sp-4);
  padding-bottom: var(--sp-3);
  border-bottom: 1px dashed var(--border);
}

.lib-grid { display: grid; gap: var(--sp-6); }
.lib-grid-2 { grid-template-columns: repeat(2, 1fr); }
.lib-grid-3 { grid-template-columns: repeat(3, 1fr); }
.lib-grid-4 { grid-template-columns: repeat(4, 1fr); }

.lib-fact h4 { margin: var(--sp-2) 0 var(--sp-2); }
.lib-fact p { margin: 0; }

.lib-footer { background: var(--brand-navy); color: #F8FAFC; padding: var(--sp-12); margin-top: var(--sp-16); }
.lib-footer .meta { color: rgba(248, 250, 252, 0.6); }
.lib-footer-inner { max-width: 1240px; margin: 0 auto; display: flex; justify-content: space-between; align-items: flex-end; gap: var(--sp-8); }
.lib-footer-title { font-size: 24px; font-weight: 600; letter-spacing: -0.02em; margin-top: var(--sp-2); }

/* ---------- Foundations: colour swatches ---------- */
.swatches { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--sp-3); }
.swatches-4 { grid-template-columns: repeat(4, 1fr); }
.swatch {
  aspect-ratio: 16/9;
  padding: var(--sp-4);
  display: flex; flex-direction: column; justify-content: space-between;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
.swatch .sw-name { font-size: 16px; font-weight: 600; letter-spacing: -0.01em; margin-top: 2px; }

.scale { display: grid; grid-template-columns: repeat(10, 1fr); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
.scale-step { aspect-ratio: 1/1.4; padding: 10px 8px; display: flex; flex-direction: column; justify-content: flex-end; gap: 1px; }
.scale-step .mono-xs { color: inherit; }

/* ---------- Foundations: type scale rows ---------- */
.ts-row {
  display: grid; grid-template-columns: 110px 140px 1fr;
  align-items: baseline;
  padding: var(--sp-3) var(--sp-5);
  border-bottom: 1px solid var(--border);
}
.ts-row:last-child { border-bottom: 0; }
.ts-row .tk { letter-spacing: 0.08em; }

/* ---------- Foundations: spacing scale ---------- */
.space-row { display: flex; align-items: flex-end; gap: var(--sp-4); }
.sp { background: rgba(59, 130, 246, 0.18); border: 1px solid var(--info); }
.space-row-labels { display: grid; grid-template-columns: repeat(8, auto); gap: var(--sp-4); margin-top: var(--sp-3); }

/* ---------- Card primitive ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.card.pad { padding: var(--sp-6); }
.card.pad-lg { padding: var(--sp-12); }
.card.no-pad { padding: 0; }
/* Note: overflow: hidden was removed so position:sticky on thead inside
   .card.no-pad can stick to viewport during page scroll. Tables inside
   handle their own corner clipping via the first-/last-child border-radius
   rules in .cc-table thead below. */

/* ---------- Buttons ---------- */
.btn {
  font-family: var(--font-sans);
  font-size: var(--fs-body-sm);
  font-weight: 500;
  padding: 8px 15px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  line-height: 1.2;
  white-space: nowrap;
  transition: background-color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
[hidden] { display: none !important; }
.btn-primary   { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--surface); color: var(--fg); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--surface-2); }
.btn-tertiary  { background: transparent; color: var(--muted); }
.btn-tertiary:hover { background: rgba(20,20,20,0.05); color: var(--fg); }
.btn-accent    { background: var(--surface); color: var(--fg); border-color: var(--fg); }
.btn-accent:hover { background: var(--surface-2); }
/* THE delete button - pastel, same voice as the status pills. Use for every destructive action. */
.btn-danger    { background: var(--danger-bg); color: var(--danger-fg); }
.btn-danger:hover { background: #F6D2CA; color: #9C2F1F; }
.btn-info      { background: var(--info); color: #fff; }
.btn-info:hover { background: #2563EB; }
.btn-sm { height: var(--control-h); padding: 0 13px; font-size: var(--fs-body-sm); }
.btn-lg { padding: 12px 18px; font-size: 15px; }

/* ---------- Inputs ---------- */
.input {
  width: 100%;
  padding: 8px 12px;
  font: inherit;
  font-size: var(--fs-body-sm);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  color: var(--fg);
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.input::placeholder { color: var(--muted-2); }
.input:focus { outline: none; border-color: var(--fg); box-shadow: 0 0 0 3px var(--focus); }
.input.error { border-color: var(--danger); }
.field { margin-bottom: var(--sp-4); }
.field .label { display: block; margin-bottom: var(--sp-2); }
.field-pair { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-4); margin-bottom: var(--sp-4); }
.field-trio { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: var(--sp-4); margin-bottom: var(--sp-4); }
.field-pair .field, .field-trio .field { margin-bottom: 0; }
.hint { font-size: var(--fs-caption); color: var(--muted); margin-top: 6px; }
.hint-error { color: var(--danger); }
.form-actions { display: flex; gap: var(--sp-3); justify-content: flex-end; margin-top: var(--sp-6); }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-family: var(--font-sans);
  font-size: var(--fs-caption); font-weight: 500;
  padding: 3px 9px;
  border-radius: var(--radius-full);
  line-height: 1.45;
  white-space: nowrap;
}
.badge-success { background: var(--success-bg); color: var(--success-fg); }
.badge-warning { background: var(--warning-bg); color: var(--warning-fg); }
.badge-danger  { background: var(--danger-bg);  color: var(--danger-fg); }
.badge-info    { background: var(--info-bg);    color: var(--info-fg); }
.badge-neutral { background: var(--neutral-bg); color: var(--neutral-fg); }
.badge-gold    { background: var(--gold-bg);    color: var(--gold-fg); }
.badge.mono    { font-family: var(--font-mono); }

/* ---------- Subcontractor score bar (Delivery & Quality) ---------- */
.score { display: flex; align-items: center; gap: var(--sp-3); }
.score-label { flex: 0 0 auto; font-size: 12px; color: var(--muted); }
.score-track { flex: 1; height: 6px; border-radius: var(--radius-full); background: var(--surface-3); overflow: hidden; }
.score-fill { display: block; height: 100%; border-radius: var(--radius-full); background: var(--muted-2); }
.score-fill.is-high { background: var(--success); }
.score-fill.is-mid  { background: var(--warning); }
.score-fill.is-low  { background: var(--danger); }
.score-val { flex: 0 0 32px; text-align: right; font-family: var(--font-mono); font-size: 12px; font-weight: 500; color: var(--fg); font-variant-numeric: tabular-nums; }
.score-badge { display: inline-flex; align-items: baseline; gap: 2px; font-family: var(--font-mono); font-weight: 600; font-size: var(--fs-body-sm); padding: 2px 8px; border-radius: var(--radius); }
.score-badge .score-badge-max { font-size: var(--fs-caption); font-weight: 400; color: var(--muted); }
.score-badge.is-high { background: var(--success-bg); color: var(--success-fg); }
.score-badge.is-mid  { background: var(--warning-bg); color: var(--warning-fg); }
.score-badge.is-low  { background: var(--danger-bg);  color: var(--danger-fg); }

/* ---------- Procurement risk chip (Delivery & Quality) ---------- */
.risk-chip { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-caption); font-weight: 500; padding: 2px 8px; border-radius: var(--radius-full); line-height: 1.5; }
.risk-chip .risk-score { font-family: var(--font-mono); }
.risk-chip.risk-low  { background: var(--success-bg); color: var(--success-fg); }
.risk-chip.risk-mid  { background: var(--warning-bg); color: var(--warning-fg); }
.risk-chip.risk-high { background: var(--danger-bg);  color: var(--danger-fg); }

/* ---------- Hold-point type marker (ITP) ---------- */
.hp-type { display: inline-flex; align-items: center; font-size: 10px; font-weight: 600; font-family: var(--font-mono); text-transform: uppercase; letter-spacing: 0.04em; padding: 2px 7px; border-radius: var(--radius-sm); line-height: 1.4; }
.hp-type.hp-hold    { background: var(--danger-bg);  color: var(--danger-fg); }
.hp-type.hp-witness { background: var(--warning-bg); color: var(--warning-fg); }
.hp-type.hp-review  { background: var(--info-bg);    color: var(--info-fg); }

/* ---------- Assignee chip (tasks / ITP sign-offs) ---------- */
.assignee { display: inline-flex; align-items: center; gap: 6px; }
.assignee-avatar { width: 22px; height: 22px; border-radius: var(--radius-full); background: var(--surface-3); color: var(--fg-2); font-size: 10px; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.assignee-name { font-size: 12px; color: var(--fg); }
.assignee-unset { color: var(--muted); font-size: 12px; }

/* ---------- Editor layout + patterns (claim / BR / forecast editors) ---------- */
.editor-grid { display: grid; grid-template-columns: 1fr 320px; gap: var(--sp-6); align-items: start; }
.editor-aside { position: sticky; top: var(--sp-4); display: flex; flex-direction: column; gap: var(--sp-4); }
@media (max-width: 900px) { .editor-grid { grid-template-columns: 1fr; } .editor-aside { position: static; } }

.tabs { display: flex; gap: var(--sp-1); border-bottom: 1px solid var(--border); }
.tab { background: none; border: none; padding: 9px 14px; font: inherit; font-size: var(--fs-body-sm); font-weight: 500; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; transition: color var(--dur-fast) var(--ease); }
.tab:hover { color: var(--fg); }
.tab.active { color: var(--fg); border-bottom-color: var(--fg); font-weight: 600; }
.tab-count { font-family: var(--font-mono); font-size: var(--fs-caption); color: var(--muted); margin-left: 4px; }
.tab.active .tab-count { color: var(--fg); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

.src-tag { display: inline-block; font-family: var(--font-mono); font-size: var(--fs-caption); letter-spacing: 0.06em; text-transform: uppercase; padding: 1px 6px; border-radius: var(--radius-sm); border: 1px solid var(--border); color: var(--muted); background: var(--surface-2); margin-right: 6px; vertical-align: 1px; }
.src-tag.src-labour { color: var(--warning-fg); background: var(--warning-bg); border-color: var(--warning-bg); }
.src-tag.src-internal { color: var(--info-fg); background: var(--info-bg); border-color: var(--info-bg); }

.claim-group { margin-bottom: var(--sp-3); }
.cg-head { display: flex; align-items: center; gap: var(--sp-2); padding: 7px 12px; background: var(--surface-2); border-bottom: 1px solid var(--border); }
.cg-code { font-family: var(--font-mono); font-size: var(--fs-caption); color: var(--muted); }
.cg-name { font-weight: 600; }
.cg-subtotal { margin-left: auto; font-weight: 600; font-variant-numeric: tabular-nums; }
tr.line-excluded td { opacity: 0.5; text-decoration: line-through; }
tr.line-excluded td.sel-cell { opacity: 1; text-decoration: none; }

.row-total td { background: var(--surface-2); font-weight: 600; }
.row-grand td { background: var(--accent); color: #fff; font-weight: 600; }

.action-bar { position: sticky; bottom: 0; z-index: 5; display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-4) 0; margin-top: var(--sp-8); background: var(--surface); border-top: 1px solid var(--border-strong); }
.action-bar-meta { font-size: 12px; color: var(--muted); }
.action-bar-meta strong { color: var(--fg); font-weight: 600; margin-left: 6px; }
.action-bar .spacer { flex: 1; }

/* ---------- Form controls: segmented toggle, cell input, drop-zone ---------- */
.segmented { display: inline-flex; border: 1px solid var(--border-strong); border-radius: var(--radius); overflow: hidden; }
.segmented button { border: none; background: var(--surface); color: var(--muted); padding: 6px 14px; font: inherit; font-size: var(--fs-body-sm); font-weight: 500; cursor: pointer; }
.segmented button + button { border-left: 1px solid var(--border-strong); }
.segmented button.active { background: var(--accent); color: #fff; }
.segmented button:hover:not(.active) { background: var(--surface-2); color: var(--fg); }
.input-cell { width: 72px; padding: 5px 8px; font-size: var(--fs-body-sm); text-align: right; }
.input-row { display: flex; align-items: center; gap: var(--sp-2); }
.input-row .unit { color: var(--muted); }
.flex-center { display: flex; align-items: center; gap: var(--sp-3); }
.form-col { max-width: 680px; }
.dropzone { padding: var(--sp-6); text-align: center; background: var(--surface-2); border: 1.5px dashed var(--border-strong); border-radius: var(--radius-lg); color: var(--muted); }
.dropzone strong { color: var(--fg); font-weight: 600; }
.claim-group.is-deferred .cg-name { color: var(--muted); }
.claim-group.is-deferred .cg-subtotal { color: var(--muted); text-decoration: line-through; }

/* ---------- Icon button (quiet utility actions: print / export) ---------- */
.btn-icon { display: inline-flex; align-items: center; justify-content: center; width: var(--control-h); height: var(--control-h); padding: 0; border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--surface); color: var(--muted); cursor: pointer; font-family: var(--font-sans); font-size: var(--fs-body-sm); }
.btn-icon:hover { background: var(--surface-2); color: var(--fg); }
.btn-icon svg { width: 16px; height: 16px; display: block; }

/* ---------- Modal / dialog ---------- */
.modal-backdrop { position: fixed; inset: 0; background: var(--scrim); display: none; align-items: flex-start; justify-content: center; padding: 64px 20px; z-index: 100; overflow-y: auto; }
.modal-backdrop.open { display: flex; }
.modal { background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); width: 480px; max-width: 100%; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4); padding: var(--sp-5) var(--sp-6); border-bottom: 1px solid var(--border); }
.modal-close { background: none; border: none; font-size: 20px; line-height: 1; color: var(--muted); cursor: pointer; width: 28px; height: 28px; border-radius: var(--radius); }
.modal-close:hover { background: var(--surface-2); color: var(--fg); }
.modal-body { padding: var(--sp-6); }
.modal-foot { display: flex; justify-content: flex-end; gap: var(--sp-3); padding: var(--sp-4) var(--sp-6); border-top: 1px solid var(--border); }
.modal.modal-wide { width: 820px; }
/* Group related fields in a form/modal under a small section heading */
.form-section { font-size: var(--fs-caption); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); font-weight: 600; margin: 22px 0 10px; padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.modal-body > .form-section:first-of-type, .form-section:first-child { margin-top: 2px; }

/* ---------- Hover-note "i" (column / field explainers) ---------- */
.note-i { display: inline-flex; align-items: center; justify-content: center; width: 14px; height: 14px; border-radius: var(--radius-full); background: var(--accent); color: #fff; font-family: var(--font-mono); font-size: 9px; line-height: 1; cursor: help; vertical-align: middle; margin-left: 4px; position: relative; }
.note-i:hover::after { content: attr(data-note); position: absolute; left: 0; top: 18px; z-index: 80; width: 240px; background: var(--accent); color: #fff; padding: 8px 11px; border-radius: var(--radius); font-family: var(--font-sans); font-size: var(--fs-caption); font-weight: 400; line-height: 1.5; letter-spacing: 0; text-transform: none; text-align: left; white-space: normal; box-shadow: var(--shadow-lg); }
.notes-off .note-i { display: none; }

/* ---------- Dropdown menu ---------- */
.dropdown { position: relative; display: inline-block; }
.dropdown-menu { position: absolute; top: calc(100% + 4px); right: 0; min-width: 210px; background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 4px 0; display: none; z-index: 60; }
.dropdown-menu.open { display: block; }
.dropdown-menu a { display: block; padding: 7px 14px; font-size: var(--fs-body-sm); color: var(--fg); text-decoration: none; cursor: pointer; }
.dropdown-menu a:hover { background: var(--surface-2); }
.dropdown-menu hr { border: 0; border-top: 1px solid var(--border); margin: 4px 0; }
.dropdown-menu .menu-label { padding: 6px 14px 2px; font: 500 9.5px/1.3 var(--font-mono); letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }

/* ---------- Bulk action bar (drill drawers) ---------- */
.bulk-bar { display: flex; align-items: center; gap: var(--sp-3); background: var(--accent); color: #fff; padding: 8px 12px; border-radius: var(--radius); margin-bottom: var(--sp-4); font-size: var(--fs-body-sm); }
.bulk-bar .spacer { flex: 1; }
.bulk-bar select { background: var(--surface); color: var(--fg); border: 1px solid var(--surface); border-radius: var(--radius); padding: 5px 10px; font: inherit; font-size: var(--fs-body-sm); }
.bulk-bar .btn-secondary { background: rgba(255,255,255,0.12); color: #fff; border-color: rgba(255,255,255,0.3); }
.bulk-bar .btn-secondary:hover { background: rgba(255,255,255,0.22); }
/* a row whose cost code / allocation has been changed but not yet saved */
.table tbody tr.row-changed td { background: var(--warning-bg); }
.table tbody tr.row-changed td:first-child { box-shadow: inset 3px 0 0 var(--warning); }

/* ---------- Forecast spreadsheet (cc-table navy language) ---------- */
.fc-wrap { overflow: auto; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); max-height: 72vh; }
.fc-table { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 12px; font-variant-numeric: tabular-nums; background: var(--surface); white-space: nowrap; }
.fc-table th, .fc-table td { padding: 7px 10px; text-align: right; border-bottom: 1px solid var(--border); }
.fc-table th.first, .fc-table td.first { text-align: left; position: sticky; left: 0; z-index: 2; }
.fc-table td.first { background: var(--surface); }
/* header: navy band, white text - same language as cc-table */
.fc-table thead th { background: var(--accent); color: #fff; }
.fc-table thead tr.blocks th { position: sticky; top: 0; z-index: 5; text-align: center; font-weight: 600; font-size: var(--fs-caption); letter-spacing: 0.04em; padding: 7px 10px; border-bottom: 1px solid rgba(255,255,255,0.18); }
.fc-table thead tr.blocks th.first { left: 0; z-index: 6; text-align: left; }
.fc-table thead tr.cols th { position: sticky; top: 33px; z-index: 4; font-weight: 500; font-size: var(--fs-caption); color: rgba(255,255,255,0.92); vertical-align: bottom; white-space: normal; }
.fc-table thead tr.cols th.first { left: 0; z-index: 5; }
/* zone separators: light on the navy header, slate in the body */
.fc-table thead .g-end { border-right: 1px solid rgba(255,255,255,0.22); }
.fc-table tbody .g-end, .fc-table tfoot .g-end { border-right: 1px solid var(--border-strong); }
.fc-table tbody tr.code { cursor: pointer; }
.fc-table tbody tr.code:hover td { background: var(--surface-2); }
.fc-table tbody tr.code:hover td.first { background: var(--surface-2); }
/* rows with no forward-cost breakdown don't expand - no chevron, no clickable cursor */
.fc-table tbody tr.code.no-expand { cursor: default; }
.fc-table tbody td.z-totals { background: #EFF6FF; }
/* zone column tints - same mechanism & paleness as cc-table: a <colgroup> carries the
   tint, the navy thead paints over it, so the tint reads only down the body columns */
.fc-table col.c-budget  { background-color: #F1F5F9; }  /* slate - same as cc-table budget-col */
.fc-table col.c-billing { background-color: #E7F6EC; }  /* green - same as cc-table rec-col */
.fc-table col.c-forward { background-color: #FBF4E3; }  /* gold  - pale brand gold, clear of warning amber */
.fc-table col.c-totals  { background-color: #EFF6FF; }  /* blue  - same as cc-table claim-col */
.fc-chev { display: inline-block; width: 12px; color: var(--muted); font-size: 9px; transition: transform .15s; }
.fc-table tr.code.expanded .fc-chev { transform: rotate(90deg); }
.fc-code-num { font-family: var(--font-mono); font-size: var(--fs-caption); color: var(--muted); margin: 0 6px 0 4px; }
.fc-table td.fc-muted { color: var(--muted-2); }
.fc-table td.val-over { color: var(--danger); font-weight: 600; }
.fc-table td.val-under { color: var(--success); font-weight: 600; }
.fc-table td.val-amber { color: var(--warning); font-weight: 600; }
.fc-table td.fc-drill { cursor: pointer; color: var(--info); text-decoration: underline; text-decoration-style: dotted; }
.fc-table td.fc-drill:hover { background: var(--info-bg); }
.row-mark { display: inline-block; width: 3px; height: 13px; vertical-align: -2px; margin-right: 4px; border-radius: 1px; background: var(--border-strong); }
.row-mark.ok { background: var(--success); }
.row-mark.over { background: var(--danger); }
.row-mark.amber { background: var(--warning); }
.fc-table tr.fc-total td { background: var(--surface-2); font-weight: 600; position: sticky; bottom: 0; z-index: 1; border-top: 2px solid var(--border-strong); }
.fc-table tr.fc-total td.first { background: var(--surface-2); }
.fc-table tr.fc-total td.z-totals { background: #E2EBF6; }
/* total row is opaque (sticky), so it sits above the colgroup - carry the zone story with
   one-step-deeper tints, keyed by column position (cols 2-4 budget, 5-8 billing, 9-14 forward) */
.fc-table tr.fc-total td:nth-child(n+2):nth-child(-n+4)  { background: #E3E8EF; }
.fc-table tr.fc-total td:nth-child(n+5):nth-child(-n+8)  { background: #D6EEDD; }
.fc-table tr.fc-total td:nth-child(n+9):nth-child(-n+14) { background: #F3E9CC; }
.fc-table tr.fc-expand > td { padding: 0; background: var(--surface-2); white-space: normal; }
.fc-subwrap { padding: 12px 16px 16px 40px; }
.fc-subhead { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }

/* commitment subtable (inside an expanded cost code) - slate header, our type */
.commit { border-collapse: collapse; width: 100%; font-size: 12px; background: var(--surface); border: 1px solid var(--border); font-variant-numeric: tabular-nums; }
.commit th { background: var(--surface-2); color: var(--fg-2); font-weight: 600; font-size: var(--fs-caption); text-align: right; padding: 6px 10px; border-bottom: 1px solid var(--border-strong); }
.commit th.first { text-align: left; }
.commit td { padding: 6px 10px; border-bottom: 1px solid var(--border); text-align: right; }
.commit td.first { text-align: left; }
.commit tr:last-child td { border-bottom: 0; }
.commit tr.section-head td { background: var(--surface-3); color: var(--fg); font-weight: 600; font-size: var(--fs-caption); text-align: left; }
.commit tr.section-head .count { color: var(--muted); margin-left: 8px; font-weight: 400; }
.commit tr.drill-row { cursor: pointer; }
.commit tr.drill-row:hover td { background: var(--surface-2); }

/* ---------- Alerts ---------- */
.alert {
  display: flex; gap: var(--sp-4); align-items: flex-start;
  padding: var(--sp-4) var(--sp-5);
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.alert-success { border-left-color: var(--success); }
.alert-warning { border-left-color: var(--warning); }
.alert-danger  { border-left-color: var(--danger); }
.alert-info    { border-left-color: var(--info); }
.alert-icon {
  width: 20px; height: 20px; border-radius: 50%;
  color: #fff; font-size: 12px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.alert-success .alert-icon { background: var(--success); }
.alert-warning .alert-icon { background: var(--warning); }
.alert-danger  .alert-icon { background: var(--danger); }
.alert-info    .alert-icon { background: var(--info); }
.alert-title { font-weight: 500; font-size: var(--fs-body-sm); }
.alert-msg   { font-size: var(--fs-body-sm); color: var(--muted); margin-top: 2px; }

/* ---------- KPI cards ---------- */
.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--sp-5);
  box-shadow: var(--shadow-sm);
}
.kpi-value {
  font-size: 32px; font-weight: 600;
  letter-spacing: -0.025em;
  margin-top: var(--sp-2);
  color: var(--fg);
  font-variant-numeric: tabular-nums;
}
.kpi-suffix { font-size: 16px; color: var(--muted); font-weight: 400; }
.kpi-delta { font-size: 12px; margin-top: var(--sp-1); color: var(--muted); }

/* ---------- Table (compact for screen density) ---------- */
.table { width: 100%; border-collapse: collapse; font-size: var(--fs-body-sm); }
.table thead tr { background: var(--surface); }
.table th {
  padding: 9px 12px;
  text-align: left;
  font-weight: 600;
  color: var(--muted);
  font-size: var(--fs-label);
  letter-spacing: var(--track-wide);
  text-transform: uppercase;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table th.num { text-align: right; }
.table td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--border-soft);
  line-height: 1.45;
  vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: 0; }

/* ---------- Empty state ---------- */
.empty { text-align: center; background: var(--bg); border: 1px dashed var(--border-strong); }
.empty-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 56px; height: 56px;
  background: var(--surface-3);
  border-radius: var(--radius-lg);
  margin-bottom: var(--sp-4);
}
.empty-icon img { width: 28px; height: 28px; opacity: 0.6; }
.empty-title { font-size: 18px; margin: 0; }
.empty-msg { margin: var(--sp-2) auto var(--sp-5); max-width: 360px; font-size: var(--fs-body-sm); color: var(--muted); line-height: 1.55; }

/* ---------- Row grids (for the buttons demo) ---------- */
.row-grid { display: grid; align-items: center; gap: var(--sp-3); padding: var(--sp-4) var(--sp-5); border-bottom: 1px solid var(--border); }
.row-grid-4 { grid-template-columns: 200px 1fr 1fr 1fr; }
.row-head { background: var(--surface-2); padding: var(--sp-3) var(--sp-5); }
.row-last { border-bottom: 0; }
.rg-label { font-weight: 500; font-size: var(--fs-body-sm); }
.rg-class { font-family: var(--font-mono); font-size: 10px; color: var(--muted); margin-top: 2px; }

/* =========================================================
   COST-CONTROL COMPONENTS
   ========================================================= */

/* ---------- 3.1 Financial KPI (extends .kpi) ---------- */
.kpi-financial .kpi-value { font-variant-numeric: tabular-nums; }

/* ---------- 3.2 Cost-code line table ---------- */
/* border-collapse: separate is required for position:sticky to work
   reliably on the navy thead th. border-spacing: 0 keeps the visual
   identical to collapsed-border tables. */
.cc-table { border-collapse: separate; border-spacing: 0; }
.cc-table .cc-code { width: 80px; }
.cc-table tbody tr.cc-group td {
  background: var(--surface-2);
  font-weight: 600;
  border-top: 1px solid var(--border);
  font-size: var(--fs-caption);
  letter-spacing: 0.04em;
  color: var(--accent);
}
.cc-table td { font-size: 12px; }

/* Major section divider in body - no fill, strong top rule + bold caps (Excel section-break style) */
.cc-table tbody tr.cc-group-major td {
  background: transparent;
  color: var(--accent);
  font-weight: 700;
  font-size: var(--fs-caption);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 14px 12px 6px;
  border-top: 2px solid var(--accent);
  border-bottom: 1px solid var(--border);
}

/* Key totals (TOTAL CONTRACT SUM, ADJUSTED PRICE) - most prominent, medium blue */
.cc-table tbody tr.tender-total td {
  background: var(--surface-3);
  font-weight: 700;
  font-size: var(--fs-body-sm);
  padding: 9px 10px;
  border-top: 1.5px solid var(--accent);
  border-bottom: 1.5px solid var(--accent);
  color: var(--accent);
}

/* Light subtotal / GST rows - less prominent than tender-total (replaces inline styles) */
.cc-table tbody tr.cc-subtotal td {
  background: var(--surface-2);
  font-weight: 600;
  color: var(--accent);
  border-top: 1px solid var(--border);
}

/* ---------- Inline-editable line cells (schedule edit mode) ---------- */
/* cells read as plain text until the table is put into edit mode */
.cell-input, .cell-select {
  width: 100%; font: inherit; font-size: 12px; color: var(--fg);
  background: transparent; border: 1px solid transparent;
  border-radius: var(--radius); padding: 4px 6px;
  font-variant-numeric: tabular-nums;
}
.cell-select { appearance: none; -webkit-appearance: none; }
td.num .cell-input { text-align: right; }
.cell-input[readonly], .cell-select:disabled {
  color: var(--fg); -webkit-text-fill-color: var(--fg); opacity: 1;
}
.li-edit.editing .cell-input:not([readonly]),
.li-edit.editing .cell-select:not(:disabled) {
  border-color: var(--border-strong); background: var(--surface);
}
.li-edit.editing .cell-input:focus, .li-edit.editing .cell-select:focus {
  outline: none; border-color: var(--info); box-shadow: 0 0 0 2px var(--info-bg);
}
/* edit-mode-only affordances (delete, add-line, save bar) */
.li-edit .edit-only { display: none; }
.li-edit.editing .view-only { display: none; }
.li-edit.editing span.edit-only { display: inline-flex; gap: var(--sp-2); }
.li-edit.editing tr.add-line-row { display: table-row; }
.li-edit.editing .li-del { display: inline-flex; }
tr.add-line-row { display: none; }
.li-del {
  display: none; align-items: center; justify-content: center;
  width: 18px; height: 18px; margin-right: 6px; padding: 0; vertical-align: middle;
  border: none; border-radius: var(--radius); cursor: pointer; font-size: 13px;
  background: var(--danger-bg); color: var(--danger-fg);
}
.add-line-row td { padding: 6px 10px; }
.add-line-btn {
  background: none; border: 1px dashed var(--border-strong); color: var(--info);
  border-radius: var(--radius); padding: 5px 10px; cursor: pointer; font: inherit; font-size: 12px;
}
.add-line-btn:hover { background: var(--info-bg); }
/* inline contenteditable cells (tender comparison edit mode) */
.li-edit.editing [contenteditable="true"] { background: var(--surface-2); cursor: text; border-radius: var(--radius); }
[contenteditable="true"]:focus { outline: 2px solid var(--info); outline-offset: -2px; background: var(--surface); }

/* ---------- 3.2b Budget Baseline - expandable cost-code table ---------- */
.budget-table tbody tr.cc-row.cc-expandable { cursor: pointer; }
.budget-table tbody tr.cc-row.cc-expandable:hover td { background: var(--surface-2); }
.budget-table tbody tr.cc-row td { border-bottom: 1px solid var(--border); }
.budget-table tbody tr.cc-row.cc-open td { background: var(--surface-2); }
/* Cost-code row status tint - green = let/procured, blue = in a BR (being procured) */
.budget-table tbody tr.cc-row[data-filt="let"] td  { background: #E7F6EC; }
.budget-table tbody tr.cc-row[data-filt="inbr"] td { background: #E1ECFB; }
.budget-table tbody tr.cc-row.cc-expandable[data-filt="let"]:hover td  { background: #D8EFE0; }
.budget-table tbody tr.cc-row.cc-expandable[data-filt="inbr"]:hover td { background: #D2E2F8; }
.cc-chevron {
  display: inline-block;
  margin-left: 4px;
  color: var(--accent);
  font-size: 9px;
}
.budget-table tbody tr.cc-line td {
  background: var(--surface);
  font-size: var(--fs-caption);
  padding: 4px 10px;
  border-bottom: 1px solid var(--border);
}
.budget-table tbody tr.cc-line td:first-child { padding-left: 26px; }
.budget-table tbody tr.cc-line:hover td { background: var(--surface-2); }
.budget-table tbody tr.cc-subgroup td {
  background: var(--surface-2);
  font-weight: 600;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent);
  padding: 5px 10px 5px 26px;
}
/* Closing subtotal row - marks the end of an expanded cost code */
.budget-table tbody tr.cc-line-total td {
  background: var(--surface-2);
  font-size: 12px;
  padding: 6px 10px;
  border-top: 1.5px solid var(--accent);
  border-bottom: 2px solid var(--accent);
  color: var(--accent);
}
.budget-table tbody tr.cc-line-total td:first-child { padding-left: 10px; }

/* ---------- 3.3 BR summary card ---------- */
.br-card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--sp-5);
  box-shadow: var(--shadow-sm);
  text-decoration: none;
  color: inherit;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
.br-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow); }
.br-card-head { display: flex; justify-content: space-between; gap: var(--sp-3); margin-bottom: var(--sp-3); }
.br-card-trade { font-size: 18px; font-weight: 600; letter-spacing: -0.015em; margin-bottom: var(--sp-2); }
.br-card-rec { display: flex; gap: var(--sp-2); align-items: baseline; margin-bottom: var(--sp-4); flex-wrap: wrap; }
.br-card-fin { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-3); padding: var(--sp-3) 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); margin-bottom: var(--sp-3); }
.br-card-fin .amt { font-size: 16px; font-weight: 600; font-variant-numeric: tabular-nums; margin-top: var(--sp-1); }
.br-card-foot { font-size: var(--fs-caption); color: var(--muted); display: flex; justify-content: flex-end; }

/* ---------- 3.4 Variation card ---------- */
.var-card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--sp-5);
  box-shadow: var(--shadow-sm);
  text-decoration: none;
  color: inherit;
}
.var-card:hover { border-color: var(--border-strong); }
.var-card-head { display: flex; justify-content: space-between; gap: var(--sp-3); margin-bottom: var(--sp-3); }
.var-card-title { font-size: 16px; font-weight: 600; letter-spacing: -0.015em; }
.var-card-detail { font-size: 12px; margin: var(--sp-2) 0 var(--sp-4); }
.var-card-delta { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-3); padding: var(--sp-3) 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); margin-bottom: var(--sp-3); }
.var-card-delta .amt { font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; margin-top: var(--sp-1); }
.var-card-foot { font-size: var(--fs-caption); color: var(--muted); }

/* ---------- 3.5 Claim summary block ---------- */
.claim-summary {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  max-width: 580px;
}
.claim-summary-head {
  display: flex; justify-content: space-between; align-items: flex-start; gap: var(--sp-6);
  padding: var(--sp-6);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.claim-summary-head h3 { margin: var(--sp-2) 0 var(--sp-1); }
.claim-summary-due { text-align: right; padding-left: var(--sp-6); border-left: 1px solid var(--border); }
.claim-due-amt {
  font-size: 28px; font-weight: 700; letter-spacing: -0.025em;
  font-variant-numeric: tabular-nums;
  margin-top: var(--sp-2);
}
.claim-formula { padding: var(--sp-2) 0; }
.cf-row {
  display: grid; grid-template-columns: 110px 1fr 180px;
  align-items: baseline;
  padding: var(--sp-3) var(--sp-6);
  border-bottom: 1px solid var(--border);
  font-size: var(--fs-body-sm);
}
.cf-row:last-child { border-bottom: 0; }
.cf-key { color: var(--muted); font-size: var(--fs-caption); letter-spacing: 0.04em; }
.cf-lbl { color: var(--fg-2); }
.cf-val { text-align: right; font-variant-numeric: tabular-nums; }
.cf-row-sum { background: var(--surface-2); }
.cf-row-final { background: var(--surface-3); }   /* Strong neutral for the load-bearing rows */
.cf-row-final .cf-val,
.cf-row-final .cf-lbl { color: var(--accent); }

/* ---------- 3.6 Reconciliation table ---------- */
.recon-table tbody tr.recon-stage td {
  background: var(--surface-2);
  font-weight: 600;
  font-size: var(--fs-caption);
  letter-spacing: 0.06em;
  color: var(--muted);
  text-transform: uppercase;
}

/* ---------- 3.7 Signature & gate ---------- */
.sig {
  display: grid; grid-template-columns: 36px 1fr auto; align-items: center; gap: var(--sp-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--sp-4) var(--sp-5);
  box-shadow: var(--shadow-sm);
}
.sig-signed { border-left: 3px solid var(--success); }
.sig-pending { border-left: 3px solid var(--warning); }
.sig-icon {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--success-bg); color: var(--success);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; font-weight: 600;
}
.sig-icon-pending { background: var(--warning-bg); color: var(--warning); }
.sig-name { font-weight: 600; font-size: var(--fs-body-sm); }
.sig-role { font-size: 12px; margin-top: 2px; }
.sig-time { font-size: var(--fs-caption); margin-top: 4px; }

/* Inline notes inside the sig box - spans all 3 columns on a second row */
.sig .sig-inline-note {
  grid-column: 1 / -1;
  margin-top: var(--sp-3);
  padding-top: var(--sp-3);
  border-top: 1px solid var(--border);
}
.sig-inline-note-label {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 4px;
}
.sig-inline-note-body {
  font-size: var(--fs-body-sm);
  line-height: 1.5;
  color: var(--fg);
}

.gate {
  display: flex; align-items: center; gap: var(--sp-3);
  background: #FEF3C7;
  border: 1px solid #FCD34D;
  border-left: 3px solid var(--warning);
  border-radius: var(--radius);
  padding: var(--sp-2) var(--sp-4);
  margin-top: var(--sp-4);
}
.gate-icon {
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--warning); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 12px; flex-shrink: 0;
}
.gate-body { flex: 1; display: flex; align-items: baseline; gap: var(--sp-2); flex-wrap: wrap; }
.gate-title { font-weight: 600; font-size: var(--fs-body-sm); color: var(--warning-fg); }
.gate-msg { font-size: 12px; margin-top: 0; }
.gate-actions { display: flex; gap: var(--sp-2); flex-shrink: 0; }

/* Approved variant - green tint instead of warning amber */
.gate.gate-approved {
  background: #ECFDF5;
  border: 1px solid #A7F3D0;
  border-left: 4px solid var(--success-fg);
}
.gate-icon.gate-icon-success {
  background: var(--success-fg);
  color: #FFFFFF;
}

/* ---------- 3.8 Audit feed ---------- */
.feed { list-style: none; margin: 0; padding: 0; }
.feed-item {
  display: grid; grid-template-columns: 110px 16px 1fr;
  gap: var(--sp-4); align-items: flex-start;
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--border);
  font-size: var(--fs-body-sm);
}
.feed-item:last-child { border-bottom: 0; }
.feed-when { color: var(--muted); padding-top: 2px; }
.feed-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--muted-2);
  margin-top: 6px; justify-self: center;
}
.feed-dot-success { background: var(--success); }
.feed-dot-warning { background: var(--warning); }
.feed-dot-info    { background: var(--info); }
.feed-body .small { display: block; margin-top: 2px; }

/* ---------- 3.9 Cash flow chart ---------- */
.cf-chart { width: 100%; height: auto; }
.cf-legend {
  display: flex; gap: var(--sp-5); align-items: center;
  font-size: 12px; color: var(--fg-2);
  margin-bottom: var(--sp-4);
}
.cf-key-line {
  display: inline-block;
  width: 22px; height: 2px;
  margin-right: 6px; vertical-align: middle;
}
.cf-line-forecast { background: var(--muted); background-image: linear-gradient(to right, var(--muted) 50%, transparent 50%); background-size: 8px 2px; }
.cf-line-actual   { background: var(--accent); height: 3px; }

/* ---------- 3.10 Decision queue ---------- */
.queue {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.queue-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: var(--sp-5) var(--sp-6);
  border-bottom: 1px solid var(--border);
}
.queue-head h3 { font-size: 22px; margin-top: var(--sp-1); }
.queue-list { list-style: none; margin: 0; padding: 0; }
.queue-item {
  display: grid; grid-template-columns: 100px 1fr auto;
  gap: var(--sp-5); align-items: center;
  padding: var(--sp-4) var(--sp-6);
  border-bottom: 1px solid var(--border);
}
.queue-item:last-child { border-bottom: 0; }
.queue-title { font-weight: 600; font-size: var(--fs-body-sm); }
.queue-meta { font-size: 12px; margin-top: 2px; }

/* =========================================================
   LAYOUT PATTERNS
   ========================================================= */

/* ---------- App shell ---------- */
.shell-demo {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}
/* v3.2 reference shell (14 Jul 2026): full-height 232px side nav
   (56px logo block, section eyebrows, ink-filled active items,
   footer slot) + slim 56px topbar carrying the breadcrumb. The
   footer toggle collapses the nav to a 56px icon rail (remembered
   per browser, body.nav-rail). Rendered by shared/app.js - pages
   only provide <header class="shell-topbar"> + <aside class="shell-side">. */
body { --side-w: 232px; }
body.nav-rail { --side-w: 56px; }
body.nav-anim .shell-side { transition: width var(--dur-med) var(--ease); }
body.nav-anim .shell-body { transition: margin-left var(--dur-med) var(--ease); }

/* Topbar spans the full width (logo left, portal tabs beside it) so every
   internal portal shares the Handover/Maintenance shell arrangement. */
.shell-topbar {
  display: flex; align-items: center;
  height: 56px;
  padding: 0 var(--sp-5);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  gap: var(--sp-4);
  position: sticky;
  top: 0;
  z-index: 60;
}
.shell-logo { height: 20px; width: auto; }
/* Breadcrumb: app (muted) then current page (ink) */
.crumb { display: flex; align-items: center; gap: var(--sp-2); min-width: 0; font-size: var(--fs-body-sm); }
.crumb-app { color: var(--muted); white-space: nowrap; }
.crumb-sep { display: inline-flex; color: var(--muted-2); }
.crumb-page { font-weight: 600; color: var(--fg); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.shell-nav { display: flex; align-items: center; gap: 4px; margin-left: 10px; }
.shell-nav-item { font-size: 13px; font-weight: 500; color: var(--muted); text-decoration: none; cursor: pointer; padding: 6px 12px; border-radius: 7px; white-space: nowrap; }
.shell-nav-item:hover { color: var(--fg); background: var(--surface-2); }
.shell-nav-item.active { color: var(--fg); font-weight: 600; background: var(--surface-3); }
.shell-nav-item.hidden { display: none; }
.shell-topbar-right { display: flex; align-items: center; gap: var(--sp-2); margin-left: auto; }
.shell-search { width: 220px; height: 30px; font-size: 12px; padding: 4px 10px; }
.shell-avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--surface-3); }
/* Account avatar = clickable initials, identical on every page */
.acct-avatar { border: 0; padding: 0; cursor: pointer; background: var(--accent); color: #fff;
  display: inline-flex; align-items: center; justify-content: center; font: 600 11px/1 var(--font-sans); letter-spacing: 0.02em; }
.acct-avatar:hover { filter: brightness(1.12); }

.shell-body { margin-left: var(--side-w); min-height: calc(100vh - 56px); }

/* Side nav: fixed below the topbar, own scroll, footer slot */
.shell-side {
  position: fixed; top: 56px; left: 0; bottom: 0;
  width: var(--side-w);
  z-index: 55;
  display: flex; flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow: hidden;
}
.side-brand { flex: none; display: flex; align-items: center; height: 56px; padding: 0 var(--sp-4); border-bottom: 1px solid var(--border); overflow: hidden; }
.side-brand a { display: inline-flex; }
.side-brand img { height: 20px; width: auto; max-width: none; }
.side-nav { flex: 1; overflow-y: auto; overflow-x: hidden; padding: var(--sp-3) var(--sp-3) var(--sp-4); display: flex; flex-direction: column; gap: 1px; }
.side-head { flex: none; padding: var(--sp-4) var(--sp-2) 5px; font-size: var(--fs-label); font-weight: 600; letter-spacing: var(--track-wide); text-transform: uppercase; color: var(--muted-2); white-space: nowrap; overflow: hidden; }
.side-nav .side-head:first-child { padding-top: var(--sp-1); }
.side-item {
  flex: none;
  display: flex; align-items: center; gap: 9px;
  height: 30px; padding: 0 var(--sp-2);
  font-size: var(--fs-body-sm);
  font-weight: 450;
  color: var(--fg-2);
  border-radius: var(--radius);
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--dur-fast) var(--ease);
}
.side-item svg { flex: none; color: var(--muted); }
.side-item span { overflow: hidden; text-overflow: ellipsis; }
.side-item:hover { background: var(--surface-2); color: var(--fg); }
.side-item.active { background: var(--accent); color: #fff; font-weight: 500; }
.side-item.active:hover { background: var(--accent); }
.side-item.active svg { color: rgba(255,255,255,0.8); }
.side-item.active .side-count { color: rgba(255,255,255,0.75); }
.side-count { margin-left: auto; font-family: var(--font-mono); font-size: var(--fs-caption); color: var(--muted); }
.side-foot { flex: none; border-top: 1px solid var(--border); padding: var(--sp-2) var(--sp-3); }
.side-collapse { display: flex; align-items: center; gap: 9px; width: 100%; height: 30px; padding: 0 var(--sp-2); border: 0; background: none; border-radius: var(--radius); font: inherit; font-size: var(--fs-body-sm); color: var(--muted); cursor: pointer; white-space: nowrap; }
.side-collapse svg { flex: none; }
.side-collapse:hover { background: var(--surface-2); color: var(--fg); }

/* Icon rail (collapsed): icons only, eyebrows become hairlines */
body.nav-rail .side-brand { justify-content: center; padding: 0; }
body.nav-rail .side-brand img { display: none; }
body.nav-rail .side-head { height: 1px; padding: 0; margin: 9px var(--sp-2); background: var(--border); font-size: 0; }
body.nav-rail .side-nav .side-head:first-child { display: none; }
body.nav-rail .side-item { justify-content: center; gap: 0; padding: 0; }
body.nav-rail .side-item span, body.nav-rail .side-item .side-count { display: none; }
body.nav-rail .side-collapse { justify-content: center; gap: 0; padding: 0; }
body.nav-rail .side-collapse span { display: none; }

/* Small screens: nav becomes a burger-toggled overlay */
.nav-burger { display: none; flex: none; align-items: center; justify-content: center; width: 32px; height: 32px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--fg); border-radius: var(--radius); cursor: pointer; }
.nav-burger:hover { background: var(--surface-2); }
@media (max-width: 720px) {
  body, body.nav-rail { --side-w: 0px; }
  .shell-side { width: 232px; transform: translateX(-100%); transition: transform var(--dur-med) var(--ease); }
  body.nav-open .shell-side { transform: none; box-shadow: var(--shadow-lg); }
  body.nav-open .side-brand img, body.nav-open .side-item span { display: block; }
  body.nav-open .side-head { height: auto; background: none; font-size: var(--fs-label); padding: var(--sp-4) var(--sp-2) 5px; margin: 0; }
  .side-foot { display: none; }
  .nav-burger { display: inline-flex; }
  .shell-nav { display: none; }
}

.shell-main {
  padding: var(--sp-8);
  background: var(--bg);
  /* Allow the grid 1fr column to shrink below its widest child so that
     overflow-x containers inside (cashflow table, forecast spreadsheet)
     scroll within their own frame instead of stretching the whole page. */
  min-width: 0;
}
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--sp-6); }
.breadcrumb { font-size: var(--fs-caption); letter-spacing: 0.04em; }
.page-title { font-family: var(--font-heading); font-size: var(--fs-h-xl); font-weight: 600; line-height: var(--lh-h-xl); letter-spacing: -0.01em; margin: var(--sp-2) 0 var(--sp-2); }
.page-actions { display: flex; gap: var(--sp-2); }

/* Title row: BR-XXX - Trade with status badge inline */
.page-title-row {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin: var(--sp-3) 0 var(--sp-1);
}
.page-title-row .page-title { margin: 0; }
.page-title .page-br-num-inline {
  font-family: var(--font-mono);
  font-weight: 600;
  letter-spacing: 0.01em;
}
.page-title .page-br-sep {
  color: var(--muted);
  font-weight: 400;
  margin: 0 8px;
}
.page-title-meta {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.02em;
  margin-top: var(--sp-1);
}

/* =========================================================
   LAYOUT UTILITIES (portal page composition)
   ========================================================= */
.grid { display: grid; gap: var(--sp-6); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-5 { grid-template-columns: repeat(5, 1fr); }
.grid-3-2 { grid-template-columns: 3fr 2fr; }
/* Two-column layout: narrow filter sidebar (240px) + main content (1fr).
   Used on the Documents page; the filter aside should be position:sticky. */
.layout-filters { display: grid; grid-template-columns: 240px 1fr; gap: var(--sp-6); align-items: start; }
.filter-aside { position: sticky; top: var(--sp-6); }

/* Horizontal filter row above a register table. Inputs and selects inside a
   .filter-bar are compact and auto-width so they don't bloat to 100%.
   Use .input-wide to give the search input more breathing room. */
.filter-bar { display: flex; gap: var(--sp-2) var(--sp-3); align-items: center; flex-wrap: wrap; }
.filter-bar .input { width: auto; min-width: 140px; padding: 6px 10px; font-size: var(--fs-body-sm); }
.filter-bar .input.input-wide { min-width: 240px; }
.filter-bar .spacer { margin-left: auto; }

/* ----- Sticky aside -----
   For a column inside a grid that should stick to the top of the viewport
   while the other column scrolls. align-self:start is required so the grid
   item doesn't stretch to the row's full height (which breaks sticky). */
.sticky-aside {
  position: sticky;
  top: var(--sp-6);
  align-self: start;
}

/* ----- Dense table for wide registers (e.g. RFIs) -----
   White-space: nowrap by default so dates, codes, badges stay on one line;
   long-text columns (marked with .col-wrap) wrap with a min-width. The first
   column is sticky so context stays in view during horizontal scroll. Use
   inside a .card.no-pad.scroll-x parent for the scroll context. */
.table-dense { border-collapse: separate; border-spacing: 0; }
.table-dense thead th,
.table-dense tbody td { white-space: nowrap; }
.table-dense thead th.col-wrap,
.table-dense tbody td.col-wrap { white-space: normal; min-width: 220px; }
.table-dense thead th:first-child,
.table-dense tbody td:first-child {
  position: sticky;
  left: 0;
  z-index: 2;
  background: var(--surface);
  box-shadow: 1px 0 0 var(--border);
}
.table-dense thead th:first-child { background: var(--surface-2); z-index: 3; }

.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; gap: var(--sp-4); }
.items-center { align-items: center; }
.gap-3 { gap: var(--sp-3); }
.gap-4 { gap: var(--sp-4); }
.gap-6 { gap: var(--sp-6); }

.mr-auto { margin-right: auto; }
.mt-2 { margin-top: var(--sp-2); }
.mt-3 { margin-top: var(--sp-3); }
.mt-4 { margin-top: var(--sp-4); }
.mt-6 { margin-top: var(--sp-6); }
.mt-8 { margin-top: var(--sp-8); }
.mt-12 { margin-top: var(--sp-12); }

.mb-0 { margin-bottom: 0; }
.mb-2 { margin-bottom: var(--sp-2); }
.mb-3 { margin-bottom: var(--sp-3); }
.mb-4 { margin-bottom: var(--sp-4); }
.mb-6 { margin-bottom: var(--sp-6); }
.mb-8 { margin-bottom: var(--sp-8); }

.scroll-x { overflow-x: auto; }

/* Scope chip - quiet workspace/status indicator for the .page-actions corner */
.scope-chip {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 12px; font-weight: 500; color: var(--fg-2);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-full); padding: 4px 12px;
  white-space: nowrap;
}
.scope-chip::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--muted-2); }

/* Info strip - flat horizontal key/value row (alternative to .kpi cards) */
.info-strip {
  display: flex;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  overflow: hidden;
}
.info-strip-cell {
  flex: 1;
  min-width: 0;
  padding: var(--sp-4) var(--sp-5);
  border-right: 1px solid var(--border);
}
.info-strip-cell:last-child { border-right: 0; }
.info-strip-cell .label { font-size: var(--fs-label); }
.info-strip-value {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.015em;
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
}
.info-strip-meta { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* Hero cells - the recommendation + amount, what the client should see first */
.info-strip-cell.info-strip-hero {
  background: #ECFDF5;
  border-top: 2px solid var(--success-fg);
}
.info-strip-cell.info-strip-hero .label { color: var(--success-fg); font-weight: 600; }
.info-strip-cell.info-strip-hero .info-strip-value { font-size: 16px; color: var(--fg); }
/* Top-accent line extends to the other two cells - grey = fixed reference, red/green = outcome */
.info-strip-cell.info-strip-budget { border-top: 2px solid #94A3B8; }
.info-strip-cell.info-strip-saving-pos { border-top: 2px solid var(--success-fg); }
.info-strip-cell.info-strip-saving-neg { border-top: 2px solid var(--danger-fg); }

/* Interactive table - rows hoverable, action column right-aligned */
.table-interactive tbody tr { transition: background-color 120ms ease; }
.table-interactive tbody tr:hover { background: var(--surface-2); }
/* Whole-row click affordance when a row links to a detail page */
.table tbody tr[onclick] { cursor: pointer; }
/* Company switcher dropdown opens from the left edge */
.dropdown-menu.menu-left { left: 0; right: auto; }
/* Disabled / read-only fields show a clear greyed state - platform-wide */
.input:disabled, .input[disabled] { background: var(--surface-2); color: var(--muted); border-color: var(--border); cursor: not-allowed; -webkit-text-fill-color: var(--muted); opacity: 1; }
/* Tabs rendered as links shouldn't be underlined */
.tab { text-decoration: none; }
/* Slightly wider form column (e.g. the PIP form) */
.form-col-wide { max-width: 900px; }
/* Logo preview on the brand navy (settings) */
.logo-preview { display: inline-flex; align-items: center; background: var(--brand-navy); border-radius: var(--radius); padding: 14px 20px; }
.logo-preview img { height: 24px; width: auto; }
/* Signature capture (shared modal: type or draw) */
.sig-modal-tabs { display: flex; width: 100%; margin-bottom: var(--sp-4); }
.sig-modal-tabs button { flex: 1; }
.sig-pad { width: 100%; height: 160px; background: var(--surface-2); border: 1px dashed var(--border-strong); border-radius: var(--radius); touch-action: none; cursor: crosshair; display: block; }
.sig-type-wrap { height: 160px; display: flex; align-items: center; justify-content: center; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); margin-top: var(--sp-3); }
.sig-script { font-family: 'Brush Script MT', 'Segoe Script', 'Snell Roundhand', cursive; color: var(--fg); }
.sig-type-preview { font-size: 36px; }
.sig-applied { display: flex; align-items: center; margin-top: 4px; }
.sig-applied .sig-script { font-size: 22px; line-height: 1; }
.sig-applied img { height: 32px; }
/* Org chart */
.org-top { display: flex; justify-content: center; margin-bottom: var(--sp-2); }
.org-stem { width: 2px; height: 24px; background: var(--border-strong); margin: 0 auto; }
.org-teams { display: flex; gap: var(--sp-5); align-items: flex-start; overflow-x: auto; padding-bottom: var(--sp-3); }
.org-team { flex: 1; min-width: 210px; }
.org-node { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: var(--sp-3) var(--sp-4); box-shadow: var(--shadow-sm); text-align: center; }
.org-node.is-lead { border: 1px solid var(--fg); }
.org-node .on-name { font-weight: 600; font-size: var(--fs-body-sm); }
.org-node .on-role { font-size: var(--fs-caption); color: var(--muted); margin-top: 2px; }
.org-node .on-people { font-family: var(--font-mono); font-size: 10px; color: var(--muted); margin-top: 4px; }
.org-reports { display: flex; flex-direction: column; gap: var(--sp-2); margin-top: var(--sp-4); padding-top: var(--sp-4); border-top: 2px solid var(--border); }
.org-report { background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--surface-3); border-radius: var(--radius); padding: 8px 12px; text-decoration: none; color: inherit; display: block; }
.org-report:hover { background: var(--surface-2); border-left-color: var(--fg); }
.org-report .or-name { font-weight: 500; font-size: 12px; }
.org-report .or-role { font-size: var(--fs-caption); color: var(--muted); }
.org-report { cursor: grab; }
.org-report:active { cursor: grabbing; }
.org-subteam { margin-top: var(--sp-3); padding-left: var(--sp-3); border-left: 2px dashed var(--border-strong); }
.org-subteam-head { font-size: 10px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); margin: 0 0 var(--sp-2); }
.org-reports.drop-hover { outline: 2px dashed var(--fg); outline-offset: 3px; border-radius: var(--radius); }
/* Chip multi-select (e.g. sites / projects on an employee) */
.chip-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: var(--sp-2); }
.chip-tag { display: inline-flex; align-items: center; gap: 4px; background: var(--surface-3); color: var(--fg-2); border-radius: var(--radius-full); padding: 3px 4px 3px 10px; font-size: 12px; font-weight: 500; }
.chip-tag button { background: none; border: none; cursor: pointer; color: var(--muted); font-size: 15px; line-height: 1; padding: 0 4px; border-radius: var(--radius-full); }
.chip-tag button:hover { color: var(--danger); }
.chip-empty { color: var(--muted-2); font-size: 12px; margin-bottom: var(--sp-2); }
/* Compact right-aligned rate input in a table cell */
.input-rate { width: 96px; text-align: right; padding: 6px 8px; font-size: var(--fs-body-sm); }
/* Approved / locked table row - greyed, not editable */
.table tbody tr.row-locked td { background: var(--surface-2); }
/* Sortable table headers (click to sort) */
.sortable thead th.th-sort { cursor: pointer; user-select: none; }
.sortable thead th.th-sort:hover { color: var(--fg); }
.sortable thead th[data-sort="asc"]::after { content: " ▲"; font-size: 9px; color: var(--muted); }
.sortable thead th[data-sort="desc"]::after { content: " ▼"; font-size: 9px; color: var(--muted); }
/* Small inline info icon in a table header / label (hover for tooltip) */
.info-i { display: inline-flex; align-items: center; margin-left: 4px; color: var(--muted-2); cursor: help; vertical-align: -2px; }
.info-i:hover { color: var(--info); }
.info-i svg { width: 13px; height: 13px; }
/* "With" / ball-in-court initials chip */
.who-chips { display: inline-flex; gap: 4px; }
.who-chip { display: inline-flex; align-items: center; justify-content: center; min-width: 24px; height: 22px; padding: 0 6px; border-radius: var(--radius-full); background: var(--surface-3); color: var(--fg-2); font-family: var(--font-mono); font-size: 10px; font-weight: 600; letter-spacing: 0.02em; }
.who-chip.is-director { background: var(--gold-bg); color: var(--gold-fg); }
.who-chip.is-hr { background: var(--info-bg); color: var(--info-fg); }
.table-actions { text-align: right; white-space: nowrap; }

/* Alternative options - compact row layout */
.alt-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--sp-3) var(--sp-4);
}
.alt-panel-head {
  display: flex; justify-content: space-between; align-items: baseline;
  gap: var(--sp-4); margin-bottom: var(--sp-2);
}
.alt-panel-head .label { font-size: var(--fs-label); }
.alt-row {
  display: grid;
  grid-template-columns: 180px 110px 1fr;
  gap: var(--sp-4);
  padding: 6px 0;
  border-top: 1px solid var(--border);
  align-items: baseline;
  font-size: 12px;
}
.alt-row:last-child { padding-bottom: 0; }
.alt-name { font-weight: 600; }
.alt-delta { font-family: var(--font-mono); }
.alt-tradeoff { color: var(--muted); line-height: 1.45; }

/* Navy header row for the cost-code table (Tender Comparison, Budget Allocation) */
.cc-table thead tr { background: var(--accent); }
.cc-table thead th {
  /* Sticky so the column headers stay in view when you scroll a long
     budget / tender / breakdown down past viewport. Background must be
     on the th itself (not just the tr) for the sticky cell to be opaque. */
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--accent);
  color: #FFFFFF;
  border-right-color: rgba(255,255,255,0.12);
  border-bottom-color: var(--accent);
  letter-spacing: 0.06em;
}
/* Round the outer top corners to match the parent .card.no-pad now that
   the card no longer clips overflow - keeps the navy header from peeking
   past the card's rounded border. */
.cc-table thead tr:first-child th:first-child { border-top-left-radius: var(--radius-lg); }
.cc-table thead tr:first-child th:last-child  { border-top-right-radius: var(--radius-lg); }

/* Recommended column highlight in tender comparison - green tint in body */
.cc-table col.rec-col { background-color: #E7F6EC; }
.cc-table th.rec-col-head { color: #FFFFFF; }
/* Budget column - grey tint signals a reference column that can't be edited */
.cc-table col.budget-col { background-color: #F1F5F9; }
.cc-table col.claim-col { background-color: #EFF6FF; }
.rec-tag {
  display: block;
  width: fit-content;
  margin: 3px 0 0 auto;     /* right-aligned because thead cells use text-align: right on .num */
  font-size: var(--fs-caption); font-weight: 600; letter-spacing: 0.08em;
  color: var(--success-fg);
  background: var(--success-bg);
  padding: 1px 5px;
  border-radius: 3px;
}

/* Due Diligence card - designed for 3-column grid */
.dd-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.dd-card-head {
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: flex-start; gap: var(--sp-2);
}
.dd-card-bidder { font-size: var(--fs-body-sm); font-weight: 600; letter-spacing: -0.015em; }
.dd-card-head .mono { font-size: 10px; margin-top: 2px; }
.dd-contact {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px dashed var(--border);
  font-size: var(--fs-caption);
  line-height: 1.45;
}
.dd-contact-name { font-weight: 500; color: var(--fg); }
.dd-contact-line { font-family: var(--font-mono); font-size: 10px; color: var(--muted); margin-top: 1px; }
.dd-section {
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--border);
}
.dd-section:last-child { border-bottom: 0; }
.dd-section-head {
  font-family: var(--font-mono);
  font-size: 10px; font-weight: 500; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--muted);
  margin-bottom: var(--sp-2);
}
.dd-row { display: flex; justify-content: space-between; gap: var(--sp-2); padding: 2px 0; font-size: 12px; }
.dd-key { color: var(--fg-2); }
.dd-val { font-weight: 500; font-variant-numeric: tabular-nums; }
.dd-val .check { color: var(--success); margin-right: 2px; }
.dd-val .cross { color: var(--danger); margin-right: 2px; }
.dd-val .warn { color: var(--warning); margin-right: 2px; }
.dd-history { font-size: 12px; line-height: 1.55; }
.dd-history .strong { font-weight: 600; }

/* Doc section - for long-form printable content (narrative blocks) */
.doc-section { padding: var(--sp-6) var(--sp-8); }
.doc-section + .doc-section { border-top: 1px solid var(--border); }
.doc-section h4 {
  font-family: var(--font-mono);
  font-size: var(--fs-caption);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 500;
  margin: 0 0 var(--sp-3);
}
.doc-section p { margin: 0; font-size: var(--fs-body-sm); line-height: 1.6; color: var(--fg-2); }
.doc-section p + p { margin-top: var(--sp-3); }

/* ---------- Progress-claim Contract Works table ---------- */
/* table-layout: fixed so expanding line-item rows can't shift the column widths */
.cw-table { table-layout: fixed; min-width: 980px; }
/* highlight the "This claim" columns - what's being claimed this period */
.cw-table tbody tr td.cw-this { background: #FEF7E0; }

/* Compact claim formula rows for the UI (progress-claim detail pages) */
.claim-formula .cf-row { padding: 5px 10px; font-size: var(--fs-body-sm); line-height: 1.35; }
.claim-formula .cf-row-sum { padding: 6px 10px; }
.claim-formula .cf-row-final { padding: 8px 10px; }
.claim-summary-head h3 { font-size: 16px; margin: 2px 0 4px; }
.claim-summary-head .eyebrow { font-size: 10px; }
.claim-due-amt { font-size: 22px; }

/* ----- JOIN Hub admin surface ----- */
.hub-eyebrow { color: var(--muted); }
.locked .edit-gate { display: none !important; }
.ready-row { display: flex; align-items: center; gap: var(--sp-2); padding: 10px 16px; flex-wrap: wrap; }
.ready-chip { font-family: var(--font-mono); font-size: var(--fs-caption); padding: 3px 10px; border-radius: 999px; border: 1px dashed var(--border-strong); color: var(--muted); }
.ready-chip.ok { border-style: solid; color: var(--fg); }
.workspace { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: var(--sp-6); align-items: start; }
.rail { position: sticky; top: 24px; display: flex; flex-direction: column; gap: var(--sp-4); }
.ready-li { display: flex; justify-content: space-between; align-items: center; gap: var(--sp-2); padding: 8px 16px; font-size: 12px; border-bottom: 1px solid var(--border); color: inherit; text-decoration: none; }
.ready-li:last-child { border-bottom: 0; }
.ready-li .mono { font-size: var(--fs-caption); }
.rt-toolbar { display: flex; gap: 4px; padding: 8px 12px; border-bottom: 1px solid var(--border); }
.rt-btn { border: 1px solid var(--border-strong); background: var(--surface); border-radius: var(--radius); font: inherit; font-size: 12px; min-width: 28px; padding: 3px 8px; cursor: pointer; color: var(--fg); }
.rt-btn:hover { background: var(--surface-2); }
.doc-rich { padding: 20px 24px; min-height: 220px; outline: none; }
.doc-rich h4 { font-size: var(--fs-caption); font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); margin: 18px 0 6px; }
.doc-rich h4:first-child { margin-top: 0; }
.doc-rich p { font-size: var(--fs-body-sm); line-height: 1.6; margin: 0 0 10px; }
.doc-rich ul, .doc-rich ol { font-size: var(--fs-body-sm); line-height: 1.6; margin: 0 0 10px; padding-left: 20px; }
.doc-rich[contenteditable="true"] { background: var(--surface-2); border-radius: 0 0 var(--radius) var(--radius); cursor: text; }
.cell-ro { color: var(--fg); }
.rail-label { display: block; padding: 12px 16px 4px; }
.rail-pad { padding: 0 12px 12px; }
.badge-help { margin-left: 6px; cursor: help; }
.check-list label { display: block; margin-bottom: 6px; }
.check-list label:last-child { margin-bottom: 0; }
.cc-table .li-del { float: right; margin-left: 8px; }
.rt-bold { font-weight: 700; }
.rt-italic { font-style: italic; }
.row-computed { background: var(--surface-2); }
.badge-inline { margin-left: 4px; }
.ready-li { cursor: pointer; }
.rec-pick { display: block; margin-left: auto; margin-top: 4px; }
.dd-check-row { display: flex; gap: 8px; }
.dd-check-row .input { flex: 1; }

/* =========================================================
   Filter - icon button + sectioned single-select dropdown
   Reusable list/table filter. Builds on .dropdown / .dropdown-menu.
   Markup: .dropdown > button.btn-icon.filter-btn  +  .dropdown-menu.filter-menu
           sections via .menu-label, options via a.filter-opt[data-group][data-val]
   ========================================================= */
.filter-btn { position: relative; }
.filter-btn.is-active { border-color: var(--accent); color: var(--accent); background: var(--surface-2); }
.filter-btn .filter-count {
  position: absolute; top: -6px; right: -6px;
  min-width: 16px; height: 16px; padding: 0 4px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent); color: #fff;
  font-family: var(--font-mono); font-size: 10px; line-height: 1;
  border-radius: var(--radius-full);
}
.dropdown-menu.filter-menu { min-width: 240px; }
.dropdown-menu .filter-opt { position: relative; padding-left: 30px; cursor: pointer; }
.dropdown-menu .filter-opt::before {
  content: '✓'; position: absolute; left: 12px; top: 7px;
  color: var(--fg); font-size: 11px; opacity: 0;
}
.dropdown-menu .filter-opt.selected { color: var(--fg); font-weight: 500; }
.dropdown-menu .filter-opt.selected::before { opacity: 1; }
.dropdown-foot { display: flex; justify-content: flex-end; padding: 6px 10px; border-top: 1px solid var(--border); margin-top: 4px; }

/* ---------- Form text sizing - denser inputs & labels ---------- */
.input { font-size: 12px; }
.label { font-size: var(--fs-label); }

/* ---------- Auth / sign-in (platform login) ---------- */
.auth-wrap {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: var(--sp-6);
  background: var(--bg);
}
.auth-card {
  width: 100%; max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  padding: var(--sp-8);
}
.auth-logo { height: 26px; width: auto; margin-bottom: var(--sp-6); }
.auth-title { font-size: 20px; font-weight: 600; letter-spacing: -0.02em; margin: 0 0 var(--sp-1); }
.auth-sub { font-size: var(--fs-body-sm); color: var(--muted); margin: 0 0 var(--sp-6); }
.auth-btn { width: 100%; display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2); }
.auth-divider { display: flex; align-items: center; gap: var(--sp-3); color: var(--muted-2); font-size: 12px; margin: var(--sp-5) 0; }
.auth-divider::before, .auth-divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.auth-foot { font-size: var(--fs-caption); color: var(--muted); margin: var(--sp-6) 0 0; text-align: center; line-height: 1.5; }

/* ---------- Module card (platform launcher / dashboard) ---------- */
.module-card { display: block; text-decoration: none; color: inherit; transition: box-shadow 0.15s ease, transform 0.15s ease; }
a.module-card:hover { box-shadow: var(--shadow-lg); transform: translateY(-1px); }
.module-card.is-soon { position: relative; opacity: 0.6; cursor: not-allowed; pointer-events: none; }
.module-card.is-soon .module-lock { position: absolute; top: var(--sp-3); right: var(--sp-3); color: var(--muted); }

/* ---------- Horizontal stepper (e.g. Prepare → Preview → Send) ---------- */
.steps { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; margin: 16px 0 4px; }
.step { display: flex; align-items: center; gap: 8px; font-size: var(--fs-body-sm); color: var(--muted); }
.step .step-n { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; border-radius: 999px; background: var(--neutral-bg); color: var(--muted); font-size: 12px; font-weight: 600; }
.step.is-active { color: var(--accent); font-weight: 600; }
.step.is-active .step-n, .step.is-done .step-n { background: var(--accent); color: #fff; }
.step-sep { color: var(--muted); }

/* ---------- Print (certificate / signed copy → Save as PDF) ---------- */
@media print {
  .no-print { display: none !important; }
  .shell-topbar, .shell-side { display: none !important; }
  .shell-topbar, .shell-body { margin-left: 0 !important; }
  body { background: #fff; }
}

/* ---------- Stage rail (workflow progress sidebar) ---------- */
.stage-rail { display: flex; flex-direction: column; gap: 2px; }
.stage-item { display: flex; align-items: flex-start; gap: var(--sp-3); width: 100%; text-align: left; background: none; border: none; padding: 10px 12px; border-radius: var(--radius); font: inherit; color: var(--fg); cursor: pointer; }
.stage-item:hover:not(.is-locked) { background: var(--surface-2); }
.stage-item.active { background: var(--surface-2); box-shadow: inset 2px 0 0 var(--fg); }
.stage-item.is-locked { color: var(--muted-2); cursor: not-allowed; }
.stage-num { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; border-radius: var(--radius-full); background: var(--surface-3); color: var(--muted); font-size: var(--fs-caption); font-weight: 600; flex-shrink: 0; }
.stage-item.active .stage-num { background: var(--accent); color: #fff; }
.stage-item.is-done .stage-num { background: var(--success); color: #fff; }
.stage-label { font-size: var(--fs-body-sm); font-weight: 500; line-height: 1.3; }
.stage-status { font-size: var(--fs-caption); color: var(--muted); margin-top: 2px; }

/* Locked tab (stage not yet reachable) */
.tab:disabled { color: var(--muted-2); cursor: not-allowed; opacity: 0.75; }
.tab:disabled svg { opacity: 0.7; }

/* ---------- Letterhead document (letters, contracts) - matches JOIN Plus letterhead ---------- */
.letter-wrap { background: var(--surface-2); padding: var(--sp-8) var(--sp-4); min-height: 100vh; }
.letter-toolbar { max-width: 780px; margin: 0 auto var(--sp-4); display: flex; justify-content: flex-end; gap: var(--sp-2); }
.letter { max-width: 780px; margin: 0 auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow); }
.letter-band { background: var(--brand-navy); padding: var(--sp-6) var(--sp-8); display: flex; align-items: center; justify-content: space-between; }
.letter-band img { height: 24px; width: auto; }
.letter-contact { font-family: var(--font-mono); font-size: 10px; line-height: 1.8; text-align: right; color: rgba(255,255,255,0.55); text-transform: uppercase; letter-spacing: 0.04em; }
.letter-body { padding: var(--sp-10) var(--sp-8) var(--sp-8); }
.letter-body p { margin: 0 0 var(--sp-4); line-height: 1.7; }
.letter-meta { margin-bottom: var(--sp-6); }
.letter-rule { border: 0; border-top: 1px solid var(--border); margin: var(--sp-5) 0; }
.letter-subject { font-size: 22px; font-weight: 700; color: var(--brand-navy); letter-spacing: -0.02em; margin: var(--sp-3) 0; }
.letter-sign-line { border-top: 1px solid var(--border-strong); width: 260px; margin-top: var(--sp-10); padding-top: var(--sp-2); }
.letter-foot { border-top: 1px solid var(--border); padding: var(--sp-4) var(--sp-8); display: flex; justify-content: space-between; font-family: var(--font-mono); font-size: 10px; line-height: 1.7; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted-2); }
.letter-foot > :last-child { text-align: right; }

/* ---------- Letterhead sheet (embeddable: documents/letters on JOIN branding) ---------- */
.letterhead { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.letterhead .letter-band { background: var(--surface); border-bottom: 2px solid var(--brand-gold, var(--border-strong)); }
.letterhead .letter-band img { height: 30px; }
.letterhead .letter-contact { color: var(--muted); }
.letterhead .letter-body { padding: var(--sp-8); }
.letterhead .letter-body :first-child { margin-top: 0; }

/* Rich-text content rendering (editor + rendered documents) */
.doc-rich h1 { font-size: 24px; font-weight: 700; margin: 18px 0 8px; }
.doc-rich h2 { font-size: 20px; font-weight: 700; margin: 16px 0 8px; }
.doc-rich h3 { font-size: 16px; font-weight: 700; margin: 14px 0 6px; }
.doc-rich p { margin: 0 0 10px; line-height: 1.6; }
.doc-rich ul, .doc-rich ol { margin: 0 0 10px 22px; }
.doc-rich li { margin: 2px 0; }
.doc-rich blockquote { border-left: 3px solid var(--border-strong); margin: 0 0 10px; padding: 4px 0 4px 12px; color: var(--muted); }
.doc-rich hr { border: 0; border-top: 1px solid var(--border); margin: 16px 0; }
.doc-rich u { text-decoration: underline; }

/* Small layout utilities */
.list-scroll { max-height: 320px; overflow: auto; }
.col-check { width: 42px; }
.break-all { word-break: break-all; }

/* Signers list in the Documents register cell */
.sig-line + .sig-line { margin-top: var(--sp-2); }

/* WHS induction: signature capture box + stacked checklist labels */
.sig-capture { border: 1px dashed var(--border-strong); border-radius: var(--radius); padding: var(--sp-3); min-height: 56px; display: flex; align-items: center; background: var(--surface); }
.sig-capture .sig-script { font-size: 22px; line-height: 1.2; }
.sig-capture .sgn-img { max-height: 44px; }
label.block-label { display: block; padding: 5px 0; }

/* Long-answer question: a clear question above a multi-line field (not an eyebrow label) */
.q-label { display: block; font: 600 13.5px/1.45 var(--font-sans); color: var(--fg); margin-bottom: 6px; }
textarea.input { min-height: 68px; resize: vertical; font: inherit; line-height: 1.45; }

/* WHS induction wizard: handbook reference (left) beside the step form (right) */
.induct-grid { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1.05fr); gap: var(--sp-5); align-items: start; }
.induct-ref { position: sticky; top: var(--sp-4); }
.induct-ref iframe { width: 100%; height: 72vh; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.induct-steps { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: var(--sp-4); }
.induct-step-dot { font-size: var(--fs-caption); padding: 3px 9px; border-radius: var(--radius-full); background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }
.induct-step-dot.is-active { background: var(--accent); color: #fff; border-color: var(--accent); }
.induct-step-dot.is-done { background: var(--success-bg); color: var(--success-fg); border-color: var(--success-fg); }
@media (max-width: 980px) { .induct-grid { grid-template-columns: 1fr; } .induct-ref { position: static; } .induct-ref iframe { height: 50vh; } }

/* Signature entries (one per signer, on the signed document) */
.sig-entry { padding: var(--sp-3) 0; border-top: 1px solid var(--border); }
.sig-entry:first-child { border-top: 0; padding-top: 0; }
.sig-entry .sig-script { font-size: 22px; line-height: 1.25; margin: 2px 0; }

/* ---------- PDF signature-field placement editor (pf-*) ---------- */
.pf-wrap { display: grid; grid-template-columns: 260px 1fr; gap: var(--sp-4); align-items: start; }
.pf-rail { position: sticky; top: var(--sp-4); display: flex; flex-direction: column; gap: var(--sp-3); }
.pf-rail .label { display: block; margin-bottom: var(--sp-2); }
.pf-chips { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.pf-chip { font: 500 13px/1 var(--font-sans); padding: 8px 10px; border: 1px solid var(--border-strong);
  background: var(--surface); border-radius: var(--radius); cursor: pointer; color: var(--fg); }
.pf-chip.is-armed { background: var(--accent); color: #fff; border-color: var(--accent); }
.pf-hint-line { color: var(--muted); font-size: 12px; }

.pf-pages { display: flex; flex-direction: column; gap: var(--sp-4); align-items: center; }
.pf-page { position: relative; box-shadow: 0 1px 3px rgba(0,0,0,.18); background: #fff; line-height: 0; }
.pf-overlay { position: absolute; inset: 0; }
.pf-overlay.is-arming { cursor: crosshair; }

.pf-field { position: absolute; border: 1.5px solid var(--accent); background: rgba(3,19,43,.07);
  border-radius: var(--radius-sm); box-sizing: border-box; cursor: move; line-height: 1.1;
  display: flex; align-items: center; justify-content: center; overflow: visible; }
.pf-field-label { font: 600 11px/1.1 var(--font-sans); color: var(--accent); padding: 2px 4px;
  text-align: center; pointer-events: none; user-select: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pf-field-x { position: absolute; top: -9px; right: -9px; width: 18px; height: 18px; border-radius: 50%;
  background: var(--danger); color: #fff; border: 0; font-size: 12px; line-height: 18px; text-align: center;
  cursor: pointer; padding: 0; }
.pf-field-resize { position: absolute; right: -4px; bottom: -4px; width: 12px; height: 12px;
  background: var(--accent); border: 2px solid #fff; border-radius: 2px; cursor: nwse-resize; }
/* per-signer accent colours */
.pf-c0 { border-color: var(--accent); background: rgba(3,19,43,.07); }
.pf-c0 .pf-field-label { color: var(--accent); }
.pf-c1 { border-color: #2563EB; background: rgba(37,99,235,.08); }
.pf-c1 .pf-field-label { color: #1D4ED8; }
.pf-c2 { border-color: #0E9384; background: rgba(14,147,132,.08); }
.pf-c2 .pf-field-label { color: #0B7268; }
.pf-c3 { border-color: #9333EA; background: rgba(147,51,234,.08); }
.pf-c3 .pf-field-label { color: #7E22CE; }
.pf-legend-dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: middle; }
.pf-legend-dot.pf-c0 { background: var(--accent); }
.pf-legend-dot.pf-c1 { background: #2563EB; }
.pf-legend-dot.pf-c2 { background: #0E9384; }
.pf-legend-dot.pf-c3 { background: #9333EA; }

/* Read-only signature markers shown on the PDF when signing / viewing */
.sgn-field { position: absolute; box-sizing: border-box; border: 1.5px dashed var(--brand-gold);
  background: rgba(229,186,65,.14); border-radius: var(--radius-sm); display: flex; align-items: center;
  justify-content: center; text-align: center; line-height: 1.1; overflow: visible; }
.sgn-field.is-target { cursor: pointer; }
.sgn-field.is-target:hover { background: rgba(229,186,65,.28); }
.sgn-field-label { font: 600 11px/1.1 var(--font-sans); color: var(--gold-fg); padding: 0 4px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; pointer-events: none; }
.sgn-field.is-filled { border-style: solid; border-color: var(--accent); background: rgba(3,19,43,.05); }
.sgn-field.is-filled .sgn-field-label { display: none; }
.sgn-field .sgn-script { font-family: var(--font-script, 'Brush Script MT', cursive); font-size: 18px;
  color: var(--fg); padding: 0 4px; pointer-events: none; }
.sgn-field-cap { position: absolute; left: 0; bottom: -15px; font: 500 10px/1 var(--font-sans);
  color: var(--muted); white-space: nowrap; pointer-events: none; }
/* Guided signing: the next field pulses, plus a sticky action bar */
.sgn-field.is-next { border-style: solid; border-color: var(--accent); animation: sgnPulse 1.15s ease-in-out infinite; }
@keyframes sgnPulse { 0%,100% { box-shadow: 0 0 0 0 rgba(229,186,65,0); } 50% { box-shadow: 0 0 0 4px rgba(229,186,65,.55); } }
.sgn-field.is-done { cursor: default; }
.sgn-bar { position: sticky; bottom: 0; z-index: 6; display: flex; align-items: center; justify-content: space-between;
  gap: var(--sp-3); flex-wrap: wrap; background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg); padding: var(--sp-3) var(--sp-4); margin-top: var(--sp-4); box-shadow: 0 -2px 12px rgba(0,0,0,.08); }
.sgn-bar-progress { font: 600 14px/1 var(--font-sans); color: var(--fg); }
.sgn-bar-progress .muted { font-weight: 400; }
.sgn-bar-actions { display: flex; gap: var(--sp-2); align-items: center; }
/* Two-column signing layout: document on the left, sign controls sticky on the right */
.sign-wrap { max-width: 1280px; margin: 0 auto; }
.sign-grid { display: grid; grid-template-columns: minmax(0,1fr) 380px; gap: var(--sp-5); align-items: start; }
.sign-doc { min-width: 0; }
.sign-side { position: sticky; top: var(--sp-4); }
.sgn-field { scroll-margin-top: 88px; scroll-margin-bottom: 56vh; }
@media (max-width: 980px){
  .sign-grid { grid-template-columns: 1fr; }
  .sign-doc { padding-bottom: 52vh; }                 /* keep document clear of the bottom sheet */
  /* DocuSign-style: sign controls become a fixed bottom sheet, always reachable */
  .sign-side { position: fixed; left: 0; right: 0; bottom: 0; top: auto; z-index: 60;
    max-height: 50vh; overflow-y: auto; background: var(--surface);
    border-top: 2px solid var(--accent); box-shadow: 0 -6px 22px rgba(0,0,0,.18); }
  .sign-side > .h-md { display: none; }                /* hide heading to save sheet space */
  .sign-side .card.pad { border: 0; border-radius: 0; margin: 0; }
  .sign-jump { display: none; }                        /* "Show me where" in the sheet replaces it */
}
.adopt-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-3); margin-top: var(--sp-3); align-items: start; }
.adopt-grid .sig-type-preview { min-height: 26px; font-size: 20px; line-height: 1.2; }
.sign-jump { position: sticky; top: 0; z-index: 7; padding: var(--sp-2) 0; }
.rule { border: 0; border-top: 1px solid var(--border); margin: var(--sp-3) 0; }
/* ---------- Toggle switch (yes/no settings - use instead of Yes/No dropdowns) ---------- */
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: var(--fs-body-sm); color: var(--fg); user-select: none; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .sw-track { position: relative; width: 36px; height: 21px; border-radius: var(--radius-full); background: var(--surface-3); transition: background var(--dur-fast) var(--ease); flex: none; }
.switch .sw-track::after { content: ""; position: absolute; top: 2.5px; left: 2.5px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(20,20,20,0.2); transition: transform var(--dur-fast) var(--ease); }
.switch input:checked + .sw-track { background: var(--accent); }
.switch input:checked + .sw-track::after { transform: translateX(15px); }
.switch input:focus-visible + .sw-track { outline: 2px solid var(--focus); outline-offset: 1px; }
.switch-list { display: flex; flex-direction: column; gap: 10px; margin: 2px 0 var(--sp-4); }

/* ---------- Filter chips (rounded, linear-style; click the active chip to clear) ---------- */
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: var(--control-h); padding: 0 12px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-full);
  background: var(--surface); color: var(--fg-2);
  font-size: var(--fs-caption); font-weight: 500; cursor: pointer; user-select: none; white-space: nowrap;
  transition: border-color var(--dur-fast) var(--ease), background-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.chip:hover { border-color: var(--muted); color: var(--fg); }
.chip.is-on { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip .chip-n { font-size: var(--fs-caption); color: var(--muted-2); font-variant-numeric: tabular-nums; }
.chip.is-on .chip-n { color: rgba(255,255,255,0.65); }

/* ---------- Select (JoinUI.select in shared/app.js): searchable dropdown with
   keyboard nav (↑ ↓ Enter Esc) and a clear action. Use for ANY dropdown with
   more than ~6 options instead of a native <select>. ---------- */
.select-host { display: inline-flex; min-width: 0; }
select.native-hidden { display: none; }
.field .select-host, .field .select-host .select-btn { display: flex; width: 100%; }
.select-btn {
  display: inline-flex; align-items: center; gap: 7px;
  height: var(--control-h); padding: 0 9px;
  border: 1px solid var(--border-strong); border-radius: var(--radius);
  background: var(--surface); color: var(--fg);
  font-size: var(--fs-body-sm); font-family: var(--font-sans); cursor: pointer;
  min-width: 0; max-width: 100%;
  transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}
.select-btn:hover { background: var(--surface-2); }
.select-btn .sb-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.select-btn .sb-label .sb-sub { color: var(--muted); }
.select-btn .sb-label.is-placeholder { color: var(--muted); }
.select-btn .sb-car { margin-left: auto; color: var(--muted-2); font-size: 8px; flex: none; }
.select-btn .sb-x { flex: none; color: var(--muted-2); font-size: 13px; line-height: 1; padding: 0 1px; border-radius: var(--radius-full); }
.select-btn .sb-x:hover { color: var(--fg); }
.select-btn.is-set { color: var(--fg); border-color: var(--fg); }
.select-btn.sb-cell { width: 158px; border-color: var(--border); background: var(--surface); }
.select-btn.sb-cell:hover { border-color: var(--border-strong); background: var(--surface); }
.select-panel {
  position: absolute; z-index: 130;   /* above modals (100) and popovers (60) */
  min-width: 230px; max-width: 360px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  padding: 6px;
}
.select-panel .sp-search { width: 100%; margin-bottom: 6px; }
.sp-list { max-height: 264px; overflow-y: auto; }
.sp-group { font-size: 10px; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); padding: 7px 8px 2px; }
.sp-item { display: flex; align-items: baseline; gap: 7px; padding: 6px 8px; border-radius: var(--radius); cursor: pointer; font-size: var(--fs-body-sm); }
.sp-item .sp-code { font-variant-numeric: tabular-nums; font-weight: 500; flex: none; }
.sp-item .sp-sub { color: var(--muted); font-size: var(--fs-caption); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sp-item:hover, .sp-item.is-active { background: var(--surface-2); }
.sp-item.is-selected { font-weight: 600; }
.sp-item.is-selected::after { content: "✓"; margin-left: auto; font-size: var(--fs-caption); color: var(--fg); }
.sp-empty { padding: 8px; font-size: 12px; color: var(--muted); }
.sp-clear { display: block; width: 100%; text-align: left; border: 0; background: none; border-top: 1px solid var(--border); margin-top: 5px; padding: 7px 8px 4px; color: var(--muted); cursor: pointer; font: 500 12px var(--font-sans); }
.sp-clear:hover { color: var(--fg); }

/* Type / Draw segmented toggle */
.seg { display: inline-flex; padding: 3px; gap: 2px; background: var(--surface-3); border-radius: var(--radius); height: var(--control-h); align-items: stretch; }
.seg-btn { padding: 0 12px; background: transparent; border: 0; border-radius: var(--radius-sm); font: 500 var(--fs-caption)/1 var(--font-sans); color: var(--muted); cursor: pointer; white-space: nowrap; transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease); }
/* signature Type/Draw toggle keeps its original breathing room */
.sig-type-wrap ~ .seg, .sigpad-wrap ~ .seg, .adopt-grid .seg { margin-top: var(--sp-3); }
.seg-btn.is-active { background: var(--surface); color: var(--fg); box-shadow: var(--shadow-sm); }
/* Signature draw pad */
.sigpad-wrap { border: 1px solid var(--border-strong); border-radius: var(--radius); background: #fff; margin-top: var(--sp-2); }
.sigpad { width: 100%; height: 140px; display: block; touch-action: none; cursor: crosshair; border-radius: var(--radius); }
.sgn-img { max-width: 100%; max-height: 100%; object-fit: contain; display: block; margin: auto; }
.sgn-field .sgn-img { width: 100%; height: 100%; }
.draw-preview { max-height: 46px; width: auto; margin: 4px 0; }
/* Per-signer certificate accordion */
.acc-item { border-top: 1px solid var(--border); }
.acc-item:first-child { border-top: 0; }
.acc-head { display: flex; align-items: center; gap: var(--sp-3); width: 100%; background: none; border: 0; padding: var(--sp-3); cursor: pointer; text-align: left; font-family: var(--font-sans); }
.acc-head:hover { background: var(--surface-2); }
.acc-thumb-wrap { width: 70px; flex: 0 0 70px; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.acc-thumb { max-height: 32px; }
.acc-thumb-txt { font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.acc-id { flex: 1 1 auto; display: flex; flex-direction: column; min-width: 0; }
.acc-caret { color: var(--muted); transition: transform .15s; }
.acc-head.is-open .acc-caret { transform: rotate(180deg); }
.acc-body { padding: 2px var(--sp-3) var(--sp-3); }
.cert-row { display: flex; justify-content: space-between; gap: var(--sp-4); padding: 5px 0; border-top: 1px dashed var(--border); }
.cert-row .label { margin: 0; flex: 0 0 auto; }
.cert-val { text-align: right; color: var(--fg); word-break: break-word; font-size: var(--fs-body-sm); }
.legend-row { padding: 2px 0; }
/* PDF zoom control */
.pdf-zoom { display: flex; align-items: center; gap: var(--sp-2); margin-bottom: var(--sp-2); }
.pdf-zoom #zoomLabel { font: 500 13px/1 var(--font-mono); color: var(--muted); min-width: 44px; text-align: center; }
/* Mobile: stack + bigger touch targets */
@media (max-width: 980px){
  .sign-side .form-actions { flex-direction: column; align-items: stretch; }
  .sign-side .form-actions .btn { width: 100%; }
  #applyBtn, #signBtn { padding: 12px 16px; font-size: 15px; }
  .sigpad { height: 170px; }
}
.input.is-locked { background: var(--surface-2); color: var(--fg-2); cursor: not-allowed; }
/* Field kinds on the signing PDF: only signatures are cursive */
.sgn-plain { font-family: var(--font-sans); font-size: var(--fs-body-sm); line-height: 1.1; color: var(--fg); padding: 0 4px; pointer-events: none; white-space: nowrap; }
.sgn-field.is-input { border-style: solid; border-color: var(--brand-gold); background: rgba(229,186,65,.10); padding: 0; }
.sgn-input { width: 100%; height: 100%; border: 0; background: transparent; font: 500 13px/1.1 var(--font-sans); color: var(--fg); padding: 0 4px; box-sizing: border-box; }
.sgn-input:focus { outline: 2px solid var(--accent); outline-offset: -2px; }
.sgn-field.is-auto { border-style: solid; border-color: var(--border-strong); background: var(--surface-2); }
.sgn-field.is-other { border-style: solid; border-color: var(--border-strong); background: var(--surface-2); }
.sgn-field.is-other-pending { border-style: dashed; border-color: var(--border-strong); background: transparent; }
.sgn-field.is-other-pending .sgn-field-label { color: var(--muted); }
@media print {
  .letter-wrap { background: #fff; padding: 0; }
  .letter { box-shadow: none; border: 0; max-width: 100%; border-radius: 0; }
  .letter-toolbar { display: none; }
}

/* ---- Timesheet grid (JOIN Admin) - employee × day matrix, clean sheet style:
   horizontal hairlines only; vertical rules only frame the name / action columns;
   worked hours plain, colour reserved for the cells that need attention ---- */
.ts-grid { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 12px; }
.ts-grid th, .ts-grid td { border-bottom: 1px solid var(--border); padding: 8px 10px; text-align: center; white-space: nowrap; }
.ts-grid tbody tr:last-child td { border-bottom: 0; }
.ts-grid thead th { font-size: 10px; font-weight: 500; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); padding: 9px 10px 7px; }
.ts-grid thead th .meta { display: block; font-size: var(--fs-caption); font-weight: 500; color: var(--muted-2); margin-top: 1px; letter-spacing: 0; }
.ts-grid td.ts-name, .ts-grid th.ts-name { text-align: left; border-right: 1px solid var(--border); }
.ts-grid td.ts-name { font-weight: 600; white-space: normal; min-width: 120px; max-width: 170px; padding: 8px 12px; }
.ts-grid td.ts-name .small { display: block; font-weight: 400; margin-top: 1px; }
.ts-early { color: var(--muted); font-weight: 400; }
.ts-cell { font-weight: 500; font-variant-numeric: tabular-nums; }
.ts-ok    { color: var(--fg); }
.ts-miss  { color: var(--danger-fg); background: color-mix(in srgb, var(--danger-fg) 8%, transparent); }
.ts-warn  { color: var(--warning-fg); background: color-mix(in srgb, var(--warning) 13%, transparent); }
.ts-tafe  { color: var(--info-fg); }
.ts-na    { color: var(--muted-2); }
.ts-ph    { color: var(--muted-2); }
.ts-off   { color: var(--muted-2); }
.ts-adj   { color: var(--info-fg); background: color-mix(in srgb, var(--info) 9%, transparent); font-weight: 500; }
.ts-blank { color: var(--border-strong); }
.ts-exp   { color: var(--muted-2); }
/* The grid is its own 2D scroll box so the header row + worker column can freeze */
.ts-gridwrap { max-height: 72vh; overflow: auto; }
.scroll-y { max-height: 52vh; overflow-y: auto; }
/* Searchable code/job picker (combobox) */
.combo-btn { width: 100%; text-align: left; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 4px 8px; font-size: 12px; cursor: pointer; color: var(--fg); }
.combo-btn:hover { border-color: var(--muted-2); }
.ts-combo { min-width: 300px; max-width: 400px; }
.combo-list { max-height: 260px; overflow-y: auto; margin-top: 6px; }
.combo-list a { display: block; padding: 4px 6px; font-size: 12px; cursor: pointer; border-radius: 4px; }
.combo-list a:hover { background: var(--surface-2); }
.combo-group { font-size: 10px; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); margin: 8px 0 2px; font-weight: 600; }
/* Tab-scoped action groups inside .page-actions - swap per active view tab */
.page-actions .act-group { display: inline-flex; gap: 8px; align-items: center; }
.page-actions .act-group[hidden] { display: none; }
/* Small square checkbox for table row selection */
input.cbx { width: 14px; height: 14px; accent-color: var(--accent); cursor: pointer; margin: 0; vertical-align: middle; }
/* Coded-hours review table column sizing */
.ch-sel { width: 1%; white-space: nowrap; }
.ch-row-excluded td.ch-sel { opacity: 1; }
.ch-desc { min-width: 300px; }
.ch-desc .input { width: 100%; }
.ch-reason { max-width: 200px; white-space: normal; word-break: break-word; font-size: 12px; color: var(--muted); }
.ch-status { white-space: nowrap; }
.ch-status .badge { white-space: nowrap; }
/* Clickable status badge - opens a JoinUI panel to override the status */
.ch-status-btn { display: inline-flex; align-items: center; gap: 4px; border: 0; background: transparent; padding: 2px 4px; margin: -2px -4px; border-radius: var(--radius-sm); cursor: pointer; font: inherit; }
.ch-status-btn:hover { background: var(--surface-2); }
.ch-status-btn .sb-car { font-size: 8px; color: var(--muted-2); }
.ch-status-btn:hover .sb-car { color: var(--muted); }
.ch-row-changed td { background: color-mix(in srgb, var(--info) 9%, var(--surface)); }
.raw-text { font-family: var(--font-mono); font-size: var(--fs-caption); line-height: 1.5; color: var(--muted); background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; max-height: 280px; overflow: auto; white-space: pre-wrap; word-break: break-word; }
/* CLAB reconcile - side-by-side */
.recon-split { display: grid; grid-template-columns: 1fr; gap: var(--sp-4); align-items: start; }
.recon-split.has-pdf { grid-template-columns: 1fr 1fr; }
.recon-split.has-pdf.pdf-min { grid-template-columns: 1fr 42px; }
/* invoice pane: sticky on the right, collapsible to a slim rail */
.pdf-pane { position: sticky; top: 12px; max-height: calc(100vh - 100px); display: flex; flex-direction: column; }
.pdf-pane .recon-scroll { max-height: none; flex: 1; }
.pdf-rail { writing-mode: vertical-rl; border: 1px solid var(--border); background: var(--surface); border-radius: var(--radius-lg); cursor: pointer; font: 600 12px/1 var(--font-sans); letter-spacing: .02em; color: var(--muted); padding: 14px 10px; height: 190px; position: sticky; top: 12px; }
.pdf-rail:hover { color: var(--fg); border-color: var(--border-strong); }
.recon-pane { border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); overflow: hidden; }
.recon-pane-head { padding: 8px 12px; font-weight: 600; font-size: var(--fs-body-sm); border-bottom: 1px solid var(--border); background: var(--surface-2); display: flex; gap: 8px; align-items: baseline; justify-content: space-between; }
.recon-scroll { max-height: 72vh; overflow: auto; }
.recon-table .input-sm.num { width: 78px; text-align: right; }
.recon-table th, .recon-table td { white-space: nowrap; }
.recon-status .badge { white-space: nowrap; }
.recon-totals { display: flex; gap: 18px; flex-wrap: wrap; padding: 10px 12px; border-top: 1px solid var(--border); font-size: var(--fs-body-sm); position: sticky; bottom: 0; background: var(--surface); }
.pdf-view { padding: 10px; background: var(--surface-2); }
.pdf-view canvas { width: 100%; height: auto; display: block; margin: 0 auto 10px; box-shadow: var(--shadow-sm); background: #fff; }
@media (max-width: 980px) { .recon-split { grid-template-columns: 1fr; } }
.shared-banner { display: flex; align-items: center; gap: 10px; padding: 8px 12px; margin-top: 16px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: color-mix(in srgb, var(--info) 7%, var(--surface)); font-size: var(--fs-body-sm); }
.shared-banner-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--info); flex: none; }
.shared-banner-text { flex: 1; color: var(--text); }
.ch-act { width: 1%; white-space: nowrap; text-align: right; }
.ch-row-excluded td { opacity: .5; }
.ch-row-excluded td.ch-act { opacity: 1; }
.ch-row-excluded td.strong, .ch-row-excluded .ch-desc .input { text-decoration: line-through; }
.ts-grid thead th { position: sticky; top: 0; z-index: 2; background: var(--surface); }
.ts-grid td.ts-name, .ts-grid th.ts-name { position: sticky; left: 0; z-index: 1; background: var(--surface); }
.ts-grid thead th.ts-name { z-index: 3; background: var(--surface); }
.ts-legend { display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: center; }
.ts-legend span b { font-weight: 700; }
/* Whole-page drag target: fixed overlay shown while a file is dragged over the page */
.drag-overlay {
  position: fixed; inset: 0; z-index: 90;
  display: none; align-items: center; justify-content: center;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  outline: 3px dashed var(--fg); outline-offset: -14px;
  font-size: 15px; font-weight: 600; color: var(--fg);
  pointer-events: none;
}
.drag-overlay.on { display: flex; }

/* Drop-zone for the report upload */
.ts-drop { border: 1.5px dashed var(--border-strong); border-radius: 10px; padding: 22px; text-align: center; color: var(--muted); cursor: pointer; transition: border-color .15s, background .15s; }
.ts-drop:hover, .ts-drop.is-over { border-color: var(--fg); background: var(--surface-2); }
.ts-drop.is-loaded { border-style: solid; border-color: var(--success-fg); color: var(--fg); }
/* Compact inline input (in-table status/note controls) + resolved-row dimming */
.input-sm { padding: 4px 9px; font-size: 12px; height: var(--control-h); line-height: 1.3; min-width: 92px; }
tr.is-done td { opacity: .5; }
/* Actionable grid cells + per-row action list + cell disposition popover */
.ts-cell.ts-click { cursor: pointer; }
.ts-cell.ts-click:hover { outline: 2px solid var(--fg); outline-offset: -2px; }
.ts-cell.is-done { opacity: .45; }
.ts-grid td.ts-act, .ts-grid th.ts-act { text-align: left; border-left: 1px solid var(--border); }
.ts-grid td.ts-act { white-space: normal; min-width: 220px; max-width: 380px; width: 380px; word-break: break-word; }
.ts-items { list-style: none; margin: 0; padding: 0; font-size: 11.5px; }
.ts-items li { margin: 3px 0; padding-left: 12px; position: relative; }
.ts-items li::before { content: ""; position: absolute; left: 0; top: 6px; width: 5px; height: 5px; border-radius: 50%; background: var(--warning); }
.ts-items li.ts-item-done::before { background: var(--border-strong); }
.ts-items li.ts-item-done { color: var(--muted); text-decoration: line-through; }
.ts-note { display: block; margin-top: 2px; color: var(--info); font-style: italic; }
.ts-items li.ts-item-done .ts-note { text-decoration: none; }
.ts-menu { position: absolute; z-index: 60; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 8px 28px rgba(0,0,0,.16); padding: 12px; min-width: 230px; max-width: 300px; max-height: 60vh; overflow-y: auto; }
.ts-menu-head { font-weight: 600; font-size: var(--fs-body-sm); margin-bottom: 6px; }
.ts-menu-issues { margin: 0 0 8px; padding-left: 16px; font-size: 12px; color: var(--muted); max-height: 26vh; overflow-y: auto; word-break: break-word; }

/* ============================================================================
   Drawer (slide-over + master-detail) + custom checkbox
   Ported from the Handover admin pattern into the shared system (v3.1 tokens).
   Additive — used by the Logins console and available to every admin/people page.
   ========================================================================== */
.drawer-overlay{position:fixed;inset:0;background:var(--scrim);opacity:0;pointer-events:none;transition:opacity var(--dur-med,.2s) var(--ease);z-index:80}
.drawer-overlay.show{opacity:1;pointer-events:auto}
.drawer{position:fixed;top:0;right:0;height:100vh;width:500px;max-width:94vw;background:var(--surface);box-shadow:var(--shadow-lg,0 18px 44px -14px rgba(20,20,20,.28));transform:translateX(103%);transition:transform .24s var(--ease);z-index:81;display:flex;flex-direction:column}
.drawer.show{transform:none}
.drawer-head{display:flex;align-items:flex-start;gap:12px;padding:15px 16px 15px 20px;border-bottom:1px solid var(--border);background:var(--surface)}
.drawer-heading{flex:1;min-width:0;display:flex;flex-direction:column;gap:2px}
.drawer-eyebrow{font-size:var(--fs-caption,10px);font-weight:600;letter-spacing:.1em;text-transform:uppercase;color:var(--muted-2)}
.drawer-head h2{font-size:var(--fs-h,17px);font-weight:600;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-family:var(--font-display,inherit)}
.drawer-close{width:30px;height:30px;min-width:30px;display:inline-flex;align-items:center;justify-content:center;border:1px solid var(--border);border-radius:var(--radius,6px);background:var(--surface);color:var(--muted);font-size:18px;line-height:1;cursor:pointer;transition:background var(--dur-fast) var(--ease),color var(--dur-fast) var(--ease)}
.drawer-close:hover{background:var(--surface-2);color:var(--fg);border-color:var(--border-strong)}
.drawer-body{flex:1;overflow:auto;padding:6px 20px 48px}
.drawer-body .dsection{padding:18px 0;border-bottom:1px solid var(--border)}
.drawer-body .dsection:last-child{border-bottom:none}
.drawer-body .dsection h4{font-size:var(--fs-caption,10px);text-transform:uppercase;letter-spacing:.07em;color:var(--muted);margin-bottom:12px}
.drawer-foot{position:sticky;bottom:0;display:flex;align-items:center;gap:8px;padding:12px 20px;border-top:1px solid var(--border);background:var(--surface)}
.drawer-foot .sp{flex:1}
@media (min-width:1280px){
  body.docked .drawer-overlay{background:transparent;pointer-events:none}
  body.docked .drawer{width:440px;box-shadow:-1px 0 0 var(--border)}
  body.docked .shell-main{margin-right:440px}
}
@media (max-width:640px){
  .drawer{width:100vw;max-width:100vw}
  .drawer-close{width:40px;height:40px;min-width:40px}
}
tr.row-link.open td{background:var(--surface-2)}

/* ---- Custom checkbox + inline "box + label" row ---- */
input[type=checkbox]{appearance:none;-webkit-appearance:none;width:16px;height:16px;min-width:16px;padding:0;border:1.5px solid var(--border-strong);border-radius:5px;background:var(--surface);cursor:pointer;vertical-align:middle;transition:background var(--dur-fast) var(--ease),border-color var(--dur-fast) var(--ease)}
input[type=checkbox]:hover{border-color:var(--muted)}
input[type=checkbox]:checked{background-color:var(--accent);border-color:var(--accent);background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23ffffff' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6L9 17l-5-5'/%3E%3C/svg%3E");background-repeat:no-repeat;background-position:center;background-size:11px}
input[type=checkbox]:focus-visible{outline:2px solid var(--focus);outline-offset:1px}
.check{display:inline-flex;align-items:center;gap:9px;cursor:pointer;font-size:var(--fs-body-sm,12px);color:var(--fg);user-select:none}
.check input[type=checkbox]{flex:none}
.check-list{display:flex;flex-direction:column;gap:10px}
.indent{margin-left:25px}

/* ---- Logins access table (Portal | Access | Role) + ink role tag ---- */
.badge-ink{display:inline-flex;align-items:center;gap:5px;padding:2px 9px;border-radius:var(--radius-full,999px);background:var(--accent);color:#fff;font-size:var(--fs-caption,10px);font-weight:600;letter-spacing:.02em}
.access-table th.ac-col,.access-table td.ac-col{text-align:center;width:70px}
.access-table td{vertical-align:top}
.role-cell{display:flex;flex-direction:column;gap:6px;align-items:flex-start}
.cap-list{display:flex;flex-direction:column;gap:6px;margin-top:2px}
.cap-check{font-size:var(--fs-caption,10px);color:var(--muted)}
