/* PeakR&D Client Portal — calm, minimal layout: quiet sidebar, one centered column,
   generous white space. No inline styles anywhere: the Content Security Policy blocks them. */

:root {
  --bg: #ffffff;
  --sidebar: #f9f9f9;
  --surface: #ffffff;
  --subtle: #f3f3f3;
  --hover: #ececec;
  --text: #0d0d0d;
  --muted: #5d5d5d;
  --faint: #8e8e8e;
  --line: #ececec;
  --line-strong: #dedede;
  --primary: #0d0d0d;
  --on-primary: #ffffff;
  --focus: #2563eb;
  --progress: #0d0d0d;
  --brand: #1f4fd1;   --brand-bg: #eef2fd;  --on-brand: #ffffff;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 1px 3px rgba(16, 24, 40, 0.06);
  --ok: #15803d;      --ok-bg: #e9f7ee;
  --warn: #a15c07;    --warn-bg: #fdf4e3;
  --danger: #c81e1e;  --danger-bg: #fdeeee;
  --info: #1d4ed8;    --info-bg: #ebf1fe;
  --radius: 14px;
  --radius-sm: 10px;
  --font: ui-sans-serif, -apple-system, "Segoe UI", system-ui, Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #212121;
    --sidebar: #171717;
    --surface: #262626;
    --subtle: #2f2f2f;
    --hover: #333333;
    --text: #ececec;
    --muted: #b4b4b4;
    --faint: #8e8e8e;
    --line: #333333;
    --line-strong: #444444;
    --primary: #ececec;
    --on-primary: #171717;
    --focus: #7aa7ff;
    --progress: #ececec;
    --brand: #8eaaff;   --brand-bg: #1f2740;  --on-brand: #10162a;
    --shadow: none;
    --ok: #6fd394;      --ok-bg: #1d3326;
    --warn: #f0b85b;    --warn-bg: #3a2e17;
    --danger: #ff8a8a;  --danger-bg: #3f2020;
    --info: #9bb9ff;    --info-bg: #1f2a40;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.55 var(--font); }
a { color: inherit; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 1.75rem; line-height: 1.25; }
h2 { font-size: 1.1rem; }
h3 { font-size: 1rem; }
p { margin: 0; }
svg { flex: none; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 6px; }

/* ---------- Shell ---------- */

/* The menu toggle: hidden on wide screens; on small screens it is focusable (see Small screens). */
.nav-toggle { display: none; }
.app { display: grid; grid-template-columns: 260px minmax(0, 1fr); min-height: 100vh; background: linear-gradient(to right, var(--sidebar) 259px, var(--line) 259px, var(--line) 260px, var(--bg) 260px); }

.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  background: var(--sidebar); padding: 14px 12px; display: flex; flex-direction: column; gap: 20px;
  border-right: 1px solid var(--line);
}
.sidebar-head { display: flex; align-items: center; justify-content: space-between; padding: 4px 6px; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 650; text-decoration: none; font-size: 1.02rem; letter-spacing: -0.01em; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 9px; background: var(--brand); color: var(--on-brand);
  display: inline-grid; place-items: center; flex: none;
}
.brand-mark svg { fill: currentColor; stroke: none; }
.brand-word { display: inline-flex; flex-direction: column; line-height: 1.15; }
.brand-sub { font-size: 0.74rem; font-weight: 500; color: var(--faint); letter-spacing: 0.01em; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-group { display: flex; flex-direction: column; gap: 2px; }
.nav-label { color: var(--faint); font-size: 0.8rem; padding: 6px 10px 4px; }
.nav-link {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius-sm);
  text-decoration: none; color: var(--text); overflow-wrap: anywhere;
}
.nav-link:hover { background: var(--hover); }
.nav-link.active { background: var(--surface); font-weight: 550; box-shadow: var(--shadow); color: var(--text); }
.nav-link.active svg { color: var(--brand); }
.nav-admin .nav-link { padding: 6px 10px 6px 12px; font-size: 0.88rem; color: var(--muted); }
.nav-admin .nav-link.active { color: var(--text); }
.nav-link svg { color: var(--muted); }
.sidebar-foot { margin-top: auto; display: flex; align-items: center; gap: 8px; padding: 8px 6px 4px; border-top: 1px solid var(--line); }
.me { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; background: var(--brand-bg); color: var(--brand);
  display: inline-grid; place-items: center; font-size: 0.8rem; font-weight: 600; flex: none;
}
.me-text { display: flex; flex-direction: column; min-width: 0; }
.me-name { font-size: 0.9rem; overflow-wrap: anywhere; }
.me-role { font-size: 0.78rem; color: var(--faint); }
.sidebar-foot form { margin: 0; }

.main { min-width: 0; position: relative; }
.content { max-width: 880px; margin: 0 auto; padding: 28px 40px 88px; }
.content.wide { max-width: 1320px; }
.env-pill {
  display: block; width: fit-content; margin: 14px 18px -14px auto; font-size: 0.75rem; color: var(--warn);
  background: var(--warn-bg); padding: 3px 10px; border-radius: 999px;
}
.topbar { display: none; }
.backdrop { display: none; }
.only-mobile, .icon-btn.only-mobile { display: none; }

.icon-btn {
  display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 10px;
  background: none; border: 0; color: var(--muted); cursor: pointer; padding: 0;
}
.icon-btn:hover { background: var(--hover); color: var(--text); }

/* ---------- Public pages (sign-in) ---------- */

.public { min-height: 100vh; display: grid; place-items: center; padding: 32px 16px; }
.public-card { width: 100%; max-width: 440px; }
.public-card .brand { margin-bottom: 28px; }
.pick { display: flex; flex-direction: column; gap: 6px; margin: 12px 0 24px; }
.pick form { margin: 0; }
.pick button {
  width: 100%; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 10px 14px; cursor: pointer; color: var(--text); font: inherit;
}
.pick button:hover { border-color: var(--line-strong); background: var(--subtle); }
.pick .who { font-weight: 500; }
.pick .what { color: var(--faint); font-size: 0.82rem; }

/* ---------- Page structure ---------- */

.crumbs { color: var(--faint); font-size: 0.85rem; margin-bottom: 10px; }
.crumbs a { text-decoration: none; color: var(--muted); }
.crumbs a:hover { color: var(--text); }
.crumbs span { margin: 0 6px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.eyebrow { color: var(--faint); font-size: 0.85rem; margin-bottom: 4px; }
.lede { color: var(--muted); margin-top: 6px; font-size: 1.02rem; }
.section { margin-top: 44px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 0.85rem; }
.sub { color: var(--faint); font-size: 0.83rem; margin-top: 2px; }
.text-danger { color: var(--danger); }
.empty { color: var(--faint); text-align: center; padding: 40px 16px; }
.empty-inline { color: var(--faint); font-size: 0.9rem; }
.link-sm { font-size: 0.88rem; color: var(--muted); text-decoration: none; }
.link-sm:hover { color: var(--text); text-decoration: underline; }

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex; align-items: center; gap: 8px; border-radius: 999px; padding: 9px 18px;
  font: inherit; font-weight: 500; text-decoration: none; cursor: pointer; border: 1px solid transparent;
  line-height: 1.2; white-space: nowrap;
}
.btn-primary { background: var(--primary); color: var(--on-primary); }
.btn-primary:hover { opacity: 0.88; }
.btn-ghost { background: var(--surface); color: var(--text); border-color: var(--line-strong); }
.btn-ghost:hover { background: var(--subtle); }
.btn-danger { background: var(--surface); color: var(--danger); border-color: var(--line-strong); }
.btn-sm { padding: 6px 13px; font-size: 0.88rem; }
.btn[disabled] { opacity: 0.45; cursor: default; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin: -8px 0 8px; }
.linkish { background: none; border: 0; padding: 0; color: inherit; text-decoration: underline; cursor: pointer; font: inherit; }

/* ---------- Chips and health ---------- */

.chip {
  display: inline-flex; align-items: center; gap: 6px; border-radius: 999px; padding: 3px 10px;
  font-size: 0.8rem; font-weight: 500; white-space: nowrap; background: var(--subtle); color: var(--muted);
}
.chip::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.chip-plain::before, .chip-muted::before { display: none; }
.chip-ok, .health-on_track, .status-accepted, .file-available, .health-submitted { background: var(--ok-bg); color: var(--ok); }
.chip-warn, .health-at_risk, .status-requested, .status-scanning, .file-scanning { background: var(--warn-bg); color: var(--warn); }
.chip-danger, .health-behind, .status-needs_fix, .file-quarantined, .file-rejected { background: var(--danger-bg); color: var(--danger); }
.chip-info, .status-uploaded, .status-unavailable { background: var(--info-bg); color: var(--info); }
.file-withdrawn { background: var(--subtle); color: var(--faint); }
.callout-info, .item .callout-info { background: var(--info-bg); color: var(--info); }
.callout-info p { margin: 0 0 4px; }
details.withdraw, details.unavailable { display: inline-block; margin-left: 6px; }
details.unavailable { display: block; margin: 8px 0 0; }
.menu-panel .menu-form { display: grid; gap: 6px; padding: 8px 10px; }
.menu-panel .menu-form input { width: 100%; }
/* M8: each document version's review status, and PeakR&D's own files. */
.review-accepted { background: var(--ok-bg); color: var(--ok); }
.review-needs_fix { background: var(--danger-bg); color: var(--danger); }
.review-to_review { background: var(--info-bg); color: var(--info); }
.review-peakrnd, .review- { background: var(--surface-2, #f1f3f5); color: var(--muted, #555); }
.review-peakrnd::before, .review-::before { display: none; }
.file.doc { flex-wrap: wrap; }
.file.doc .doc-review { display: inline-flex; gap: 6px; align-items: center; margin-left: auto; }
.file.doc .doc-review details[open] { flex-basis: 100%; }
.file.doc .file-note { flex-basis: 100%; margin: 2px 0 0 22px; }
.doc-history { flex-basis: 100%; margin: 2px 0 0 22px; }
.doc-history ul { margin: 4px 0 0; padding-left: 16px; }
.review-confirm { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.health-no_plan, .status-not_applicable { background: var(--subtle); color: var(--faint); }

/* ---------- Stats and tiles ---------- */

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 18px; margin: 22px 0 0; }
.stats div { min-width: 0; }
.stats dt { color: var(--faint); font-size: 0.82rem; }
.stats dd { margin: 3px 0 0; font-weight: 500; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 32px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; display: flex; flex-direction: column; gap: 4px; }
.tile-label { color: var(--faint); font-size: 0.85rem; }
.tile-value { font-size: 1.6rem; font-weight: 600; letter-spacing: -0.02em; }
.tile-alert .tile-value { color: var(--danger); }

progress { appearance: none; width: 84px; height: 6px; border: 0; border-radius: 999px; background: var(--subtle); overflow: hidden; vertical-align: middle; }
progress::-webkit-progress-bar { background: var(--subtle); border-radius: 999px; }
progress::-webkit-progress-value { background: var(--progress); border-radius: 999px; }
progress::-moz-progress-bar { background: var(--progress); border-radius: 999px; }
.progress-cell { display: inline-flex; align-items: center; gap: 10px; white-space: nowrap; font-size: 0.9rem; }

/* ---------- Stage steps ---------- */

.steps { list-style: none; display: flex; gap: 0; padding: 0; margin: 4px 0 0; overflow-x: auto; }
.step { flex: 1; min-width: 92px; display: flex; flex-direction: column; gap: 8px; font-size: 0.8rem; color: var(--faint); position: relative; }
.step::before { content: ""; height: 3px; border-radius: 999px; background: var(--line); margin-right: 6px; }
.step-done::before, .step-current::before { background: var(--progress); }
.step-current { color: var(--text); font-weight: 600; }
.step-done { color: var(--muted); }

/* ---------- Program cards (client home) ---------- */

.program-card { border: 1px solid var(--line); border-radius: 18px; padding: 24px; margin-bottom: 18px; background: var(--surface); }
.program-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 18px; }
.program-head h2 { font-size: 1.25rem; }
.card-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line); flex-wrap: wrap; }

/* ---------- Tables ---------- */

/* Positioned, so anything absolutely placed inside a table (the .sr-only labels) stays inside the card's own
   scrolling area instead of widening the page. A wide table scrolls inside the card, with a soft edge shadow on the
   side that has more to show (pure CSS: the covers scroll with the content, the shadows stay with the card). */
.table-card {
  position: relative; border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto;
  background:
    linear-gradient(to right, var(--surface) 30%, transparent) left center / 40px 100% no-repeat local,
    linear-gradient(to left, var(--surface) 30%, transparent) right center / 40px 100% no-repeat local,
    radial-gradient(farthest-side at 0 50%, rgba(0, 0, 0, 0.12), transparent) left center / 12px 100% no-repeat scroll,
    radial-gradient(farthest-side at 100% 50%, rgba(0, 0, 0, 0.12), transparent) right center / 12px 100% no-repeat scroll,
    var(--surface);
}
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-weight: 500; color: var(--faint); font-size: 0.82rem; padding: 12px 16px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 14px 16px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--subtle); }
.table a.strong { font-weight: 500; text-decoration: none; }
.table a.strong:hover { text-decoration: underline; }

.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 0 16px; }
.filters select { width: auto; border-radius: 999px; padding: 7px 34px 7px 14px; font-size: 0.88rem; }
.check-pill { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line-strong); border-radius: 999px; padding: 6px 14px; font-size: 0.88rem; cursor: pointer; }

/* ---------- Timeline ---------- */

.timeline { list-style: none; padding: 0; margin: 0; }
.tl { display: flex; gap: 14px; padding-bottom: 16px; position: relative; }
.tl:not(:last-child)::after { content: ""; position: absolute; left: 6px; top: 18px; bottom: 0; width: 1px; background: var(--line-strong); }
.tl-dot { width: 13px; height: 13px; border-radius: 50%; border: 2px solid var(--line-strong); background: var(--bg); margin-top: 5px; flex: none; }
.tl-done .tl-dot { background: var(--progress); border-color: var(--progress); }
.tl-overdue .tl-dot { border-color: var(--danger); }
.tl-soon .tl-dot { border-color: var(--warn); }
.tl-body { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.tl-title { font-weight: 500; }
.tl-done .tl-title { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--faint); }
.tl-meta { color: var(--faint); font-size: 0.85rem; }
.tl-overdue .tl-meta { color: var(--danger); }
.tl-actions { display: flex; gap: 6px; align-items: center; }
.tl-actions form { margin: 0; }

/* ---------- Checklist items ---------- */

.items { display: flex; flex-direction: column; gap: 12px; }
.item { border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; background: var(--surface); scroll-margin-top: 24px; }
.item:target { border-color: var(--focus); }
.item-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.item-title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.item-side { display: flex; align-items: center; gap: 4px; }
.item-help { color: var(--muted); margin-top: 6px; }
.item-meta { color: var(--faint); font-size: 0.85rem; margin-top: 6px; }
.item-not_applicable { opacity: 0.6; }
.callout { background: var(--danger-bg); color: var(--danger); border-radius: var(--radius-sm); padding: 10px 14px; margin-top: 12px; font-size: 0.92rem; }
.confirm { background: var(--subtle); border-radius: var(--radius-sm); padding: 10px 14px; margin-top: 12px; }

details.hint { margin-top: 10px; font-size: 0.9rem; }
details.hint summary { cursor: pointer; color: var(--muted); list-style: none; }
details.hint summary::-webkit-details-marker { display: none; }
details.hint summary::before { content: "+ "; }
details.hint[open] summary::before { content: "− "; }
details.hint p, details.hint > div { margin-top: 6px; color: var(--muted); }

details.menu { position: relative; }
details.menu summary { list-style: none; }
details.menu summary::-webkit-details-marker { display: none; }
.menu-panel {
  position: absolute; right: 0; top: 38px; z-index: 5; min-width: 190px; padding: 6px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
  display: flex; flex-direction: column;
}
.menu-panel a, .menu-panel button {
  text-align: left; padding: 8px 10px; border-radius: 8px; text-decoration: none; background: none; border: 0;
  color: var(--text); font: inherit; font-size: 0.9rem; cursor: pointer;
}
.menu-panel a:hover, .menu-panel button:hover { background: var(--subtle); }
.menu-panel form { margin: 0; display: contents; }
.menu-panel .danger { color: var(--danger); }

/* ---------- Files and uploads ---------- */

.files { list-style: none; padding: 0; margin: 14px 0 0; display: flex; flex-direction: column; gap: 6px; }
.file { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 0.9rem; padding: 8px 12px; background: var(--subtle); border-radius: var(--radius-sm); }
.file .file-name { font-weight: 500; }
.file a { text-decoration: none; }
.file a:hover { text-decoration: underline; }
.file-note { color: var(--danger); flex-basis: 100%; }

.upload { margin-top: 14px; }
/* One slim line per item: the whole card stays easy to scan. */
.upload-drop {
  position: relative; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; padding: 10px 14px; cursor: pointer;
  border: 1px dashed var(--line-strong); border-radius: var(--radius-sm); color: var(--muted); font-size: 0.9rem;
}
.upload-drop .upload-hint { margin-left: auto; }
.upload-drop:hover, .upload.dragging .upload-drop { border-color: var(--text); color: var(--text); background: var(--subtle); }
.upload-drop input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.upload-list { list-style: none; padding: 0; margin: 8px 0 0; display: flex; flex-direction: column; gap: 4px; font-size: 0.88rem; }
.upload-list li { display: flex; justify-content: space-between; gap: 12px; padding: 6px 2px; }
.upload-list li[data-state="error"], .upload-list li[data-state="quarantined"], .upload-list li[data-state="rejected"] { color: var(--danger); }
.upload-list li[data-state="available"] { color: var(--ok); }
details.add-files { margin-top: 10px; }
details.add-files summary { cursor: pointer; color: var(--muted); font-size: 0.9rem; list-style: none; }
details.add-files summary::-webkit-details-marker { display: none; }

/* ---------- Voice notes ---------- */

.voice { display: flex; gap: 14px; align-items: flex-start; padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 10px; background: var(--surface); }
.voice-compact { background: var(--subtle); border-color: transparent; margin: 12px 0 0; }
.voice-icon { width: 34px; height: 34px; border-radius: 50%; background: var(--primary); color: var(--on-primary); display: grid; place-items: center; flex: none; }
.voice-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.voice-title { font-weight: 500; }
.voice-meta { color: var(--faint); font-size: 0.83rem; }
.voice audio { width: 100%; max-width: 420px; height: 36px; }
.voice form { margin: 0; }

.recorder { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 28px 16px; border: 1px solid var(--line); border-radius: 18px; margin: 18px 0; text-align: center; }
.record-btn {
  width: 72px; height: 72px; border-radius: 50%; border: 0; cursor: pointer; display: grid; place-items: center;
  background: var(--primary); color: var(--on-primary);
}
.record-btn.recording { background: var(--danger); color: #fff; }
.timer { font-variant-numeric: tabular-nums; font-size: 1.4rem; font-weight: 600; }
.recorder audio { width: 100%; max-width: 420px; }

/* ---------- Forms ---------- */

.form-card { border: 1px solid var(--line); border-radius: 18px; padding: 24px; background: var(--surface); }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 18px; }
.field > label { font-weight: 500; font-size: 0.92rem; }
.field-check > label { display: flex; align-items: center; gap: 10px; font-weight: 400; }
.help { color: var(--faint); font-size: 0.83rem; }
.error { color: var(--danger); font-size: 0.85rem; }
.has-error input, .has-error select, .has-error textarea { border-color: var(--danger); }
input[type="text"], input[type="email"], input[type="number"], input[type="date"], select, textarea {
  width: 100%; font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm); padding: 10px 12px;
}
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--faint) 50%), linear-gradient(135deg, var(--faint) 50%, transparent 50%); background-position: calc(100% - 18px) 55%, calc(100% - 13px) 55%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 36px; }
textarea { resize: vertical; }
input[type="checkbox"] { width: 17px; height: 17px; accent-color: var(--primary); }
.field [id$="accepted"] { display: flex; flex-wrap: wrap; gap: 6px; }
.field [id$="accepted"] > div label { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line-strong); border-radius: 999px; padding: 5px 12px; font-size: 0.85rem; cursor: pointer; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0 18px; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; flex-wrap: wrap; }

/* ---------- Lists, notes, messages ---------- */

.list { list-style: none; padding: 0; margin: 0; border-top: 1px solid var(--line); }
.list li { padding: 12px 2px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; gap: 12px; }
.facts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 8px 24px; margin: 0; }
.facts dt { color: var(--faint); }
.facts dd { margin: 0; }
.internal { background: var(--subtle); border-radius: 18px; padding: 22px 24px; }
.messages { list-style: none; padding: 0; margin: 0 0 24px; display: flex; flex-direction: column; gap: 8px; }
.msg { padding: 11px 16px; border-radius: 12px; background: var(--subtle); font-size: 0.93rem; }
.msg-success { background: var(--ok-bg); color: var(--ok); }
.msg-error { background: var(--danger-bg); color: var(--danger); }
.warning { background: var(--warn-bg); color: var(--warn); border-radius: 12px; padding: 12px 14px; font-size: 0.9rem; }
.status-card { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; border: 1px solid var(--line); border-radius: 18px; padding: 20px 22px; margin-bottom: 24px; }
.status-card form { margin: 0; }

/* ---------- Small screens ---------- */

@media (max-width: 900px) {
  /* Focusable on small screens: Tab reaches it first, Space opens and closes the menu. */
  .nav-toggle { display: block; position: absolute; top: 10px; left: 12px; width: 34px; height: 34px; margin: 0; opacity: 0; z-index: 1; }
  .nav-toggle:focus-visible + .app .menu-btn { outline: 2px solid var(--focus); outline-offset: 2px; }
  .app { grid-template-columns: minmax(0, 1fr); background: var(--bg); }
  .only-mobile, .icon-btn.only-mobile { display: inline-grid; }
  .sidebar {
    position: fixed; z-index: 20; left: 0; top: 0; width: 280px; transform: translateX(-100%);
    transition: transform 0.2s ease;
  }
  /* The shadow only while the menu is open: a closed menu's shadow would show as a grey band at the left edge. */
  .nav-toggle:checked + .app .sidebar { transform: none; box-shadow: 0 0 40px rgba(0, 0, 0, 0.15); }
  .nav-toggle:checked + .app .backdrop { display: block; position: fixed; inset: 0; z-index: 10; background: rgba(0, 0, 0, 0.3); }
  .topbar { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
  .brand-small { font-weight: 650; gap: 8px; }
  .brand-small .brand-mark { width: 26px; height: 26px; border-radius: 8px; }
  .content { padding: 28px 16px 72px; }
  .env-pill { position: absolute; top: 16px; right: 12px; margin: 0; }
  .page-head { flex-direction: column; }
  h1 { font-size: 1.45rem; }
}

/* Reviews, answers and stage (milestone 3) */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.answer { border-left: 3px solid var(--line-strong); padding: 4px 0 4px 12px; margin-top: 12px; }
.answer-label { color: var(--faint); font-size: 0.83rem; }
.answer-text { margin-top: 2px; white-space: normal; overflow-wrap: anywhere; }
.answer-form { margin-top: 12px; }
.answer-form > textarea { margin-top: 0; }
.answer-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.review { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 8px; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.review form { margin: 0; }
details.review-fix { flex: 1 1 260px; }
details.review-fix summary { list-style: none; display: inline-flex; }
details.review-fix summary::-webkit-details-marker { display: none; }
details.review-fix[open] summary { background: var(--subtle); }
.review-form { margin-top: 10px; }
.review-form label { display: block; color: var(--muted); font-size: 0.85rem; margin-bottom: 6px; }
.review-note { color: var(--faint); font-size: 0.83rem; margin-top: 10px; }
.stage-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.stage-form select { width: auto; min-width: 160px; }
.stage-form input[type="text"] { flex: 1 1 220px; width: auto; }

/* ---------- Two-column workspace (engagement page, client home) ----------
   Work on the left; a compact summary and the timeline on the right. Stacks on
   narrower screens: summary first, then the work, then the timeline. */

.workspace {
  display: grid; grid-template-columns: minmax(0, 1fr) 320px;
  grid-template-areas: "main summary" "main timeline"; grid-template-rows: auto 1fr;
  column-gap: 56px; row-gap: 28px; margin-top: 30px; align-items: start;
}
.workspace-single { grid-template-columns: minmax(0, 1fr); grid-template-areas: "main"; }
.ws-main { grid-area: main; min-width: 0; }
.ws-main > :first-child, .ws-main > .section:first-child { margin-top: 0; }
.ws-main > .toolbar { margin: 0 0 4px; }
.ws-main > .toolbar + .section { margin-top: 28px; }
.ws-summary { grid-area: summary; min-width: 0; }
.ws-timeline { grid-area: timeline; min-width: 0; }
.h-side { font-size: 1rem; }
.side-card { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); padding: 18px 20px; }
.side-facts { display: grid; gap: 16px; margin: 0; }
.side-facts dt { color: var(--faint); font-size: 0.8rem; }
.side-facts dd { margin: 3px 0 0; font-weight: 500; }

@media (max-width: 1180px) {
  .workspace { grid-template-columns: minmax(0, 1fr); grid-template-areas: "summary" "main" "timeline"; grid-template-rows: auto; column-gap: 0; }
  .workspace-single { grid-template-areas: "main"; }
  .side-facts { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
}

/* ---------- Alerts and retention ---------- */

.nav-count { margin-left: auto; min-width: 20px; padding: 0 6px; border-radius: 999px; background: var(--danger); color: #fff; font-size: 0.72rem; font-weight: 600; line-height: 20px; text-align: center; }
.alert-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.alert-row { display: flex; align-items: center; gap: 14px; border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px; background: var(--surface); }
.alert-row.unread { border-color: var(--line-strong); }
.alert-row.unread .alert-text { font-weight: 600; }
.alert-row form { margin: 0 0 0 auto; }
.alert-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--line-strong); flex: none; }
.alert-row.unread .alert-dot { background: var(--danger); }
.alert-body { display: flex; flex-direction: column; min-width: 0; }
.status-safe { border-color: var(--ok-bg); background: var(--surface); }
.inline-form { display: inline; margin: 0 0 0 6px; }
.approve-card { margin-top: 14px; }
.check { display: flex; align-items: center; gap: 10px; margin: 12px 0; }
.hold { margin-bottom: 12px; display: flex; flex-direction: column; gap: 4px; }
.add-hold summary, .hold summary { cursor: pointer; color: var(--muted); font-size: 0.9rem; }
.add-hold form { margin-top: 14px; }
.add-hold select, .add-hold textarea, .hold input { width: 100%; }
.records-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 0; }

/* ---------- Questions: one compact row ---------- */

.q-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin-top: 10px; }
.q-row > .answer-line, .q-row > .files, .q-row > .upload { flex-basis: 100%; }
.q-row details.add-files { margin: 0; }
.q-row details.add-files summary { display: inline-flex; align-items: center; gap: 6px; font-size: 0.85rem; }
.q-row details.add-files[open] { flex-basis: 100%; }
.answer-line { margin: 0; font-size: 0.95rem; overflow-wrap: anywhere; }
.answer-line .answer-label { color: var(--faint); font-size: 0.85rem; margin-right: 4px; }
.answer-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; flex: 1 1 420px; margin: 0; }
.answer-ask { margin: 0 6px 0 0; padding: 7px 12px; border-radius: var(--radius-sm); background: var(--subtle); }
.answer-change { margin: 0; }
.answer-change[open] { flex-basis: 100%; display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }
.answer-change[open] .answer-input-row { width: 100%; }
.answer-change > summary { list-style: none; cursor: pointer; }
.answer-change > summary::-webkit-details-marker { display: none; }
.answer-change[open] > summary { background: var(--subtle); }
.answer-input-row { display: flex; align-items: flex-start; gap: 8px; flex: 1 1 100%; }
.answer-input-row textarea {
  flex: 1; min-height: 36px; max-height: 220px; padding: 7px 12px; resize: vertical;
  field-sizing: content; /* grows with the answer where supported */
}
.add-hold > summary, .hold summary { list-style: none; }
.add-hold > summary::-webkit-details-marker, .hold summary::-webkit-details-marker { display: none; }
.records-actions { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 8px; margin-top: 6px; }
.records-action > summary { list-style: none; }
.records-action > summary::-webkit-details-marker { display: none; }
.records-action[open] { flex-basis: 100%; }
.records-action[open] > summary { background: var(--subtle); }
.records-action form, .records-action .help { margin-top: 8px; }

/* ---------- Compact checklist cards ----------
   Line 1: title, dates and status, with the action beside them.
   Line 2: what is needed (and where to find it). Anything else only when it applies. */

.items { gap: 8px; }
.item { padding: 12px 16px; transition: border-color 0.15s, background 0.15s; }
.item.dragging { border-color: var(--text); background: var(--subtle); }
.item-head { align-items: center; }
.item-title { align-items: baseline; gap: 4px 10px; min-width: 0; }
.item-title h3 { font-size: 0.98rem; font-weight: 600; }
.item-title .item-meta { margin: 0; font-size: 0.82rem; }
.item-side { gap: 8px; flex: none; }
.item-sub { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 12px; margin-top: 3px; font-size: 0.88rem; }
.item-sub .item-help { color: var(--muted); margin: 0; }
.item-sub details.hint { margin: 0; font-size: 0.85rem; }
.item-sub details.hint summary::before { content: ""; }
.item-sub details.hint summary { text-decoration: underline; text-decoration-color: var(--line-strong); text-underline-offset: 3px; }
.item-sub details.hint[open] { flex-basis: 100%; }
.item .callout { margin-top: 8px; padding: 7px 12px; font-size: 0.88rem; }
.item .files { margin-top: 8px; gap: 4px; }
.item .file { padding: 5px 10px; font-size: 0.86rem; }
.item .upload-list:empty { display: none; }
.item .review { margin-top: 10px; padding-top: 10px; }
.item .review-note { margin-top: 6px; }
.item .q-row { margin-top: 8px; }

.upload-btn {
  position: relative; display: inline-flex; align-items: center; gap: 6px; cursor: pointer; white-space: nowrap;
  border: 1px solid var(--line-strong); border-radius: 999px; padding: 5px 12px; font-size: 0.85rem; font-weight: 500;
  background: var(--surface); color: var(--text);
}
.upload-btn:hover { background: var(--subtle); }
.upload-btn:focus-within { outline: 2px solid var(--focus); outline-offset: 2px; }
.upload-btn input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.upload-btn-strong { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.upload-btn-strong:hover { background: var(--primary); opacity: 0.88; }
.upload-btn-quiet { border: 0; background: none; padding: 5px 4px; color: var(--muted); font-weight: 400; margin-left: auto; }
.upload-btn-quiet:hover { background: none; color: var(--text); }

@media (max-width: 640px) {
  /* Phone: title and what is needed first, then one row with the status and the action. */
  .item { display: flex; flex-direction: column; }
  .item-head { display: contents; }
  .item-title { order: 1; }
  .item-sub { order: 2; }
  .item > * { order: 3; }
  .item-side { order: 4; flex-direction: row-reverse; justify-content: space-between; margin-top: 10px; }
  .item .review, .item .review-note { order: 5; }
}

/* ---------- Voice notes: one slim row (player beside the title) ---------- */

.voice { align-items: center; gap: 12px; padding: 8px 12px; margin-bottom: 8px; }
.voice-icon { width: 28px; height: 28px; }
.voice-body { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 2px 12px; }
.voice-title { font-size: 0.92rem; }
.voice-meta { font-size: 0.8rem; }
.voice audio { width: 280px; max-width: 100%; height: 32px; margin-left: auto; }
.voice-compact { margin: 8px 0 0; padding: 6px 10px; }
.voice-compact .voice-icon { width: 24px; height: 24px; }
.voice-compact .voice-icon svg { width: 13px; height: 13px; }
@media (max-width: 640px) {
  .voice audio { width: 100%; margin-left: 0; }
}
.item .review { align-items: center; }
.item .review .review-note { margin: 0 0 0 auto; min-width: 0; }
.item .review-quiet { border-top: 0; padding-top: 0; margin-top: 4px; }
.item .review-quiet .review-note { margin-left: 0; text-align: left; }
.item .review details.review-fix[open] { flex-basis: 100%; }

/* ---------- Long text: wraps, never overflows; nothing is hover-only ---------- */

.item-title h3, .item-sub .item-help, .file-name, .upload-list li, .voice-title, .callout, .tl-title,
.program-head h2, .page-head h1 { overflow-wrap: anywhere; }
.item-title { flex: 1 1 auto; }
.item .file { align-items: baseline; }
.upload-list li > :first-child { min-width: 0; overflow-wrap: anywhere; }
details.review-note { flex: 1 1 260px; min-width: 0; max-width: 100%; font-size: 0.83rem; color: var(--faint); }
details.review-note > summary {
  cursor: pointer; list-style: none; display: block; text-align: right;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border-radius: 6px;
}
details.review-note > summary::-webkit-details-marker { display: none; }
details.review-note[open] > summary .review-note-preview { display: none; }
details.review-note[open] > summary { white-space: normal; }
details.review-note > p { margin-top: 4px; color: var(--muted); white-space: pre-line; overflow-wrap: anywhere; text-align: left; }
.item .review-quiet details.review-note > summary { text-align: left; }
@media (max-width: 640px) {
  details.review-note > summary { text-align: left; }
  .item .review .review-note { margin-left: 0; }
}
.item .review { align-items: flex-start; }
details.review-note[open] { flex-basis: 100%; }
details.review-note[open] > summary { text-align: left; }
.item .file .file-name { flex: 1 1 220px; min-width: 0; }

/* ---------- Questionnaires: typed answers, tables, follow-ups ---------- */

.status-waiting { background: var(--subtle); color: var(--faint); }
.item-waiting { opacity: 0.7; border-style: dashed; }
.q-section { font-size: 0.8rem; font-weight: 600; letter-spacing: 0.02em; text-transform: uppercase; color: var(--muted); margin: 14px 2px 0; }
.items > .q-section:first-child { margin-top: 0; }
.item-followup { margin-left: 22px; border-left: 3px solid var(--line-strong); }
.followup-tag { color: var(--muted); }
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 0.86rem; }

/* Yes / No: two joined buttons. Quick ones send on click; with a note they are radios. */
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 999px; overflow: hidden; flex: none; }
.seg-btn {
  display: inline-flex; align-items: center; padding: 5px 14px; font: inherit; font-size: 0.86rem; font-weight: 500;
  background: var(--surface); color: var(--text); border: 0; cursor: pointer; line-height: 1.3;
}
.seg .seg-btn + .seg-btn { border-left: 1px solid var(--line-strong); }
.seg-btn:hover { background: var(--subtle); }
.seg-btn[aria-pressed="true"] { background: var(--primary); color: var(--on-primary); }
.yn-quick { flex: none; gap: 10px; }
.item-side .yn-quick { margin: 0; }
.yn { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 8px; flex: 1 1 auto; }
.yn .yn-r { position: absolute; opacity: 0; width: 1px; height: 1px; }
.yn .seg-btn { border: 1px solid var(--line-strong); border-radius: 999px; }
.yn .yn-r:checked + .seg-btn { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.yn .yn-r:focus-visible + .seg-btn { outline: 2px solid var(--focus); outline-offset: 2px; }
.yn-note { display: flex; flex: 1 1 240px; }
.yn-note input { padding: 6px 12px; }
.yn[data-note=""] .yn-note, .yn[data-note="if_no"] .yn-note, .yn[data-note="if_yes"] .yn-note { display: none; }
.yn[data-note="if_no"] .yn-r[value="no"]:checked ~ .yn-note,
.yn[data-note="if_yes"] .yn-r[value="yes"]:checked ~ .yn-note { display: flex; }

/* Single values beside their Send button */
.answer-input-row select, .answer-input-row input[type="date"] { width: auto; min-width: 180px; padding: 6px 36px 6px 12px; }
.answer-input-row input[type="date"] { padding-right: 12px; }
.num-input { position: relative; display: inline-flex; }
.num-input input { width: 180px; padding: 6px 12px; }
.num-input.is-money input { padding-left: 24px; }
.num-input.is-money::before { content: "$"; position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--faint); }
.checks { display: flex; flex-wrap: wrap; gap: 6px; flex: 1 1 auto; }
.check-chip { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line-strong); border-radius: 999px; padding: 4px 12px; font-size: 0.86rem; cursor: pointer; }
.check-chip:has(input:checked) { border-color: var(--text); background: var(--subtle); }
.answer-input-row.answer-yes_no, .answer-input-row.answer-multi_choice { align-items: center; flex-wrap: wrap; }

/* Tables */
.item-table .q-row > .qtable-form, .item-table .q-row > .qtable-wrap { flex-basis: 100%; }
.qtable-form { margin: 0; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.qtable-hint { margin: 0; font-size: 0.85rem; color: var(--muted); }
.qtable-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.qtable { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.qtable th { text-align: left; font-weight: 600; font-size: 0.8rem; color: var(--muted); padding: 7px 10px; border-bottom: 1px solid var(--line); background: var(--surface); }
.qtable td { padding: 0; border-bottom: 1px solid var(--line); vertical-align: middle; }
.qtable tr:last-child td { border-bottom: 0; }
.qtable td + td, .qtable th + th { border-left: 1px solid var(--line); }
.qtable .is-locked { background: var(--subtle); color: var(--muted); }
.qtable td.is-locked, .qtable.is-readonly td { padding: 7px 10px; }
.qtable td input, .qtable td select {
  border: 0; border-radius: 0; background-color: transparent; padding: 7px 10px; min-width: 90px; font-size: 0.88rem;
}
.qtable td select { padding-right: 30px; }
.qtable td input[type="text"] { min-width: 120px; }
.q-row > .answer-line { flex: 1 1 320px; }
.qtable-send .upload-btn-quiet { margin-left: 0; }
.answers-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 16px; }
.answers-head .help { display: inline-flex; align-items: center; gap: 8px; }
.qtable td input:focus, .qtable td select:focus { outline: 2px solid var(--focus); outline-offset: -2px; }
.qtable-x { width: 36px; text-align: center; }
.qtable-x .icon-btn { width: 28px; height: 28px; font-size: 1.1rem; }
.qtable td.is-changed { background: var(--warn-bg); }
.qtable .was { display: block; font-size: 0.75rem; color: var(--warn); }
.qtable tr.is-added td:first-child .chip { margin-left: 4px; padding: 1px 8px; font-size: 0.72rem; }
.qtable-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.qtable-send { margin-left: auto; display: inline-flex; align-items: center; gap: 10px; }
@media (max-width: 640px) {
  /* Phone: each row becomes a small card, with the column name beside each value. */
  .item-followup { margin-left: 10px; }
  .qtable-wrap { border: 0; overflow: visible; }
  .qtable thead { display: none; }
  .qtable, .qtable tbody, .qtable tr, .qtable td { display: block; width: 100%; }
  .qtable tr { border: 1px solid var(--line); border-radius: var(--radius-sm); margin-bottom: 8px; overflow: hidden; }
  .qtable td { display: flex; align-items: center; gap: 10px; border-bottom: 1px solid var(--line); }
  .qtable td + td { border-left: 0; }
  .qtable td::before { content: attr(data-label); flex: 0 0 40%; font-size: 0.78rem; color: var(--faint); padding: 7px 0 7px 10px; }
  .qtable td.is-locked::before, .qtable.is-readonly td::before { padding: 0; }
  .qtable td.is-locked, .qtable.is-readonly td { gap: 20px; }
  .qtable td input, .qtable td select { flex: 1; min-width: 0; }
  .qtable td.qtable-x { justify-content: flex-end; width: 100%; }
  .qtable td.qtable-x::before { content: none; }
  .qtable-send { margin-left: 0; width: 100%; justify-content: space-between; }
  .answer-input-row { flex-wrap: wrap; }
  .answer-input-row select, .num-input, .num-input input { width: 100%; min-width: 0; }
}

/* Staff question builder */
.form-part { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 14px 16px 2px; margin: 0 0 18px; }
.form-part > legend { font-weight: 600; font-size: 0.9rem; padding: 0 6px; }
.form-part > .help { margin: 0 0 10px; }
.col-editor { display: flex; flex-direction: column; gap: 6px; margin-bottom: 18px; }
.col-editor-head, .col-editor-row { display: grid; grid-template-columns: 2fr 1.2fr auto 2fr; gap: 8px; align-items: center; }
.col-editor-head { font-size: 0.78rem; color: var(--faint); }
.col-editor-row input[type="text"], .col-editor-row select { padding: 6px 10px; font-size: 0.88rem; }
.col-client { display: inline-flex; align-items: center; gap: 6px; font-size: 0.85rem; white-space: nowrap; }
@media (max-width: 640px) {
  .col-editor-head { display: none; }
  .col-editor-row { grid-template-columns: 1fr 1fr; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
}

/* All answers: a page to print or save as PDF */
.answers-list { display: flex; flex-direction: column; }
.answers-q { padding: 12px 0; border-bottom: 1px solid var(--line); break-inside: avoid; }
.answers-q h3 { font-size: 0.95rem; font-weight: 600; margin: 0 0 4px; }
.answers-q .answer-line { margin-top: 4px; }
.answers-q .qtable-wrap { margin-top: 6px; }
.answers-q .q-section { margin-top: 18px; }
.answers-q .help { overflow-wrap: anywhere; } /* M11: full SHA-256 checksums wrap on a phone */
@media print {
  .sidebar, .topbar, .env-pill, .no-print, .messages, .crumbs { display: none !important; }
  .app { display: block !important; }
  .content, .content.wide { max-width: none; padding: 0; }
  .qtable-wrap { overflow: visible; }
  .qtable td.is-changed { background: none; text-decoration: underline; }
}

/* ---------- People, templates, audit (Milestone 5) ---------- */

.people-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.person-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; background: var(--surface); }
.person-name { flex: 1 1 260px; min-width: 0; font-weight: 500; overflow-wrap: anywhere; }
.person-name .sub { font-weight: 400; }
.person-row form { margin: 0; }
.row-actions { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.row-actions form { margin: 0; }
.invite-form .field, .side-card .field { margin-bottom: 12px; }
.invite-form input, .invite-form select { width: 100%; }
.item-picks { display: flex; flex-direction: column; gap: 6px; max-height: 260px; overflow-y: auto; margin-top: 8px; }
.item-picks .check { margin: 0; align-items: flex-start; }
.review-confirm { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.inline-row { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0; }
.template-versions { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.template-versions .chip { text-decoration: none; }
.plan-table { width: 100%; border-collapse: collapse; margin: 8px 0 12px; font-size: 0.86rem; }
.plan-table th { text-align: left; color: var(--faint); font-weight: 500; padding: 4px; }
.plan-table td { padding: 3px 4px; vertical-align: top; }
.plan-table input, .plan-table select { width: 100%; padding: 5px 7px; font-size: 0.85rem; }
.plan-table td:first-child select { margin-top: 4px; }
.plan-table input.days { width: 4.5em; }
.audit-table code { font-size: 0.82rem; }
.audit-detail details summary { cursor: pointer; color: var(--muted); overflow-wrap: anywhere; }
.audit-detail pre { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 0.78rem; margin: 6px 0 0; }
.activity { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.activity li { display: flex; gap: 14px; font-size: 0.9rem; }
.activity-when { color: var(--faint); font-size: 0.82rem; flex: 0 0 9.5em; }
.tile-money { font-size: 1.25rem; }
.file-share { display: inline; margin: 0; }
.assignment form { display: inline; }
@media (max-width: 640px) {
  .activity li { flex-direction: column; gap: 2px; }
  .activity-when { flex-basis: auto; }
}
.review-confirm input[type="text"] { flex: 1 1 220px; width: auto; min-width: 0; }
.review-confirm .check { margin: 0; }
.inline-row select { width: auto; }
.status-card .review-confirm { flex: 1 1 520px; justify-content: flex-end; }
.person-name .sub, .item-picks .sub { display: block; }

/* ---------- Assign a request (client admins, teams of two or more) ---------- */

details.assign { display: inline; position: relative; }
details.assign > summary {
  display: inline; list-style: none; cursor: pointer; color: var(--muted); border-radius: 4px;
  text-decoration: underline; text-decoration-color: var(--line-strong); text-underline-offset: 3px;
}
details.assign > summary::-webkit-details-marker { display: none; }
details.assign > summary:hover, details.assign[open] > summary { color: var(--text); }
details.assign > summary:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.assign-caret { margin-left: 3px; font-size: 0.75em; text-decoration: none; display: inline-block; }
.assign-panel {
  position: absolute; left: 0; top: calc(100% + 8px); z-index: 6; width: 360px; max-width: calc(100vw - 32px);
  display: flex; flex-direction: column; gap: 10px; padding: 12px; margin: 0;
  background: var(--surface); color: var(--text); font-size: 0.88rem; text-align: left;
  border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}
.assign-panel fieldset { border: 0; padding: 0; margin: 0; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.assign-panel fieldset[disabled] { opacity: 0.5; }
.assign-panel legend { padding: 0 0 4px; font-size: 0.8rem; font-weight: 600; color: var(--muted); }
.assign-panel label { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 8px; cursor: pointer; min-width: 0; }
.assign-panel label:hover { background: var(--subtle); }
.assign-panel label:has(input:checked) { background: var(--subtle); }
.assign-panel label .faint { margin-left: auto; font-size: 0.8rem; white-space: nowrap; }
.assign-panel label .file-name { min-width: 0; overflow-wrap: anywhere; }
.assign-panel input[type="radio"] { width: 16px; height: 16px; accent-color: var(--primary); flex: none; margin: 0; }
.assign-panel input[type="checkbox"] { flex: none; margin: 0; }
.assign-panel input:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.assign-note { margin: 0; color: var(--muted); font-size: 0.82rem; line-height: 1.4; }
.assign-actions { display: flex; justify-content: flex-end; }
@media (max-width: 640px) {
  /* Phone: the panel opens in place, full width, under the card's details. */
  details.assign { position: static; }
  details.assign[open] { display: block; margin-top: 6px; }
  .assign-panel { position: static; width: auto; max-width: none; margin-top: 8px; box-shadow: none; }
  .assign-actions .btn { width: 100%; justify-content: center; }
}

/* ---------- Draft answers and the sign-out warning (M10) ---------- */

.draft-status { align-self: center; }
.draft-status:empty { display: none; }
/* The draft's saved time takes its own compact line under the input, so the input keeps its full width
   with or without a draft (the row wraps only where the label needs it). */
.answer-input-row.has-draft { flex-wrap: wrap; }
.answer-input-row.has-draft .draft-status { flex: 1 1 100%; order: 1; line-height: 1.3; }
.qtable-send.has-draft { flex-wrap: wrap; justify-content: flex-end; }
.qtable-send.has-draft .draft-status { flex: 1 1 100%; order: 1; text-align: right; line-height: 1.3; }
@media (max-width: 640px) {
  .qtable-send.has-draft { justify-content: space-between; }
  .qtable-send.has-draft .draft-status { text-align: left; }
}
.session-warning {
  position: fixed; left: 16px; right: 16px; bottom: 16px; z-index: 50; max-width: 560px; margin: 0 auto;
  display: flex; gap: 12px; align-items: center; flex-wrap: wrap; padding: 12px 16px; border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); border: 1px solid var(--line-strong); box-shadow: 0 6px 24px rgba(0, 0, 0, 0.15);
}
.session-warning[hidden], .session-warning [hidden] { display: none; }
.session-warning p { margin: 0; flex: 1 1 240px; }
.draft-note { flex: 1 1 100%; margin: 0 0 8px; padding: 8px 12px; border-radius: var(--radius-sm);
  background: var(--warn-bg); color: var(--warn); font-size: 0.88rem; }
.draft-note a { color: inherit; font-weight: 600; }
.draft-replace p { margin: 0 0 6px; }
.draft-replace label { display: inline-flex; align-items: center; gap: 8px; color: var(--text); cursor: pointer; }

/* ---------- Draft approval (M11) ---------- */

.approval { flex: 1 1 100%; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.approval .answer-row { flex: 1 1 100%; }
.approval-draft { margin: 0; overflow-wrap: anywhere; }

/* ---------- Consent (M14 WS5) ---------- */

.consent-card { margin-bottom: 16px; }
.consent-text { white-space: pre-wrap; overflow-wrap: anywhere; max-height: 50vh; overflow-y: auto; margin-top: 12px; }
.consent-accept { margin-bottom: 16px; }

/* ---------- Overview, lists and sign-in (portal UX simplification, 2026-11-18) ---------- */

.welcome { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin: 6px 0 24px; }
.welcome h1 { font-size: 1.9rem; letter-spacing: -0.02em; }

.cards { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 26px; }
.stat-card {
  display: grid; grid-template-columns: auto 1fr; grid-template-areas: "icon label" "value value" "sub sub";
  align-items: center; column-gap: 10px; row-gap: 6px; padding: 18px 18px 16px; border: 1px solid var(--line);
  border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); text-decoration: none; color: var(--text);
  transition: border-color 0.15s ease;
}
.stat-card:hover { border-color: var(--line-strong); }
.stat-icon { grid-area: icon; width: 32px; height: 32px; border-radius: 9px; display: inline-grid; place-items: center; background: var(--brand-bg); color: var(--brand); }
.stat-label { grid-area: label; color: var(--muted); font-size: 0.88rem; font-weight: 500; }
.stat-value { grid-area: value; font-size: 2rem; font-weight: 650; letter-spacing: -0.03em; line-height: 1.1; margin-top: 6px; }
.stat-sub { grid-area: sub; color: var(--faint); font-size: 0.8rem; }
.stat-info .stat-icon { background: var(--info-bg); color: var(--info); }
.stat-warn .stat-icon { background: var(--warn-bg); color: var(--warn); }
.stat-danger .stat-icon { background: var(--danger-bg); color: var(--danger); }
.stat-danger .stat-value { color: var(--danger); }

.overview { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 18px; align-items: start; }
.overview-main, .overview-side { min-width: 0; display: flex; flex-direction: column; gap: 18px; }
.overview-main > .section { margin-top: 10px; }
.panel { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); padding: 18px 20px; box-shadow: var(--shadow); min-width: 0; }
.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.panel-head h2 { font-size: 1.02rem; }
.panel .empty { padding: 24px 8px; }

.attention-list, .mini-list { list-style: none; margin: 0; padding: 0; }
.attention-row { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-top: 1px solid var(--line); }
.attention-row:first-child { border-top: 0; }
.attention-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--faint); }
.tone-danger { background: var(--danger); }
.tone-warn { background: var(--warn); }
.tone-info { background: var(--info); }
.attention-text, .mini-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.attention-title, .mini-title { font-weight: 500; overflow-wrap: anywhere; }
.attention-row .btn { flex: none; }
.mini-list li { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-top: 1px solid var(--line); }
.mini-list li:first-child { border-top: 0; }
.mini-title { font-size: 0.92rem; }

.glance { margin: 0; display: grid; gap: 0; }
.glance div { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-top: 1px solid var(--line); }
.glance div:first-child { border-top: 0; }
.glance dt { color: var(--muted); font-size: 0.9rem; }
.glance dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; }
.glance .is-danger dd { color: var(--danger); }

.tabs { display: flex; flex-wrap: wrap; gap: 4px; margin: 0 0 16px; padding: 4px; border-radius: 999px; background: var(--subtle); width: fit-content; max-width: 100%; }
.tab { padding: 6px 14px; border-radius: 999px; text-decoration: none; color: var(--muted); font-size: 0.9rem; font-weight: 500; }
.tab:hover { color: var(--text); }
.tab.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

.search-field { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line-strong); border-radius: 999px; padding: 0 14px; background: var(--surface); color: var(--faint); flex: 1 1 260px; max-width: 420px; }
.search-field input { border: 0; background: none; padding: 8px 0; width: 100%; color: var(--text); font: inherit; font-size: 0.92rem; }
.search-field input:focus { outline: none; }
.search-field:focus-within { outline: 2px solid var(--focus); outline-offset: 2px; }
.cell-actions { white-space: nowrap; text-align: right; }
.cell-actions .inline-form { margin: 0 8px 0 0; }
.row-archived td { color: var(--muted); }
.section-note { margin-top: 10px; }

/* Sign-in */
.public-signin { display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 16px; padding: 32px 16px; background: var(--sidebar); }
.public-signin > .messages { width: 100%; max-width: 920px; margin: 0; }
.signin {
  width: 100%; max-width: 920px; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr);
  border: 1px solid var(--line); border-radius: 20px; overflow: hidden; background: var(--surface); box-shadow: var(--shadow);
}
.signin-intro { padding: 40px 36px; background: var(--brand-bg); display: flex; flex-direction: column; gap: 22px; }
.brand-large { font-size: 1.2rem; }
.brand-large .brand-mark { width: 40px; height: 40px; border-radius: 12px; }
.signin-tagline { font-size: 1.15rem; line-height: 1.45; font-weight: 500; letter-spacing: -0.01em; }
.signin-points { list-style: none; margin: auto 0 0; padding: 0; display: grid; gap: 10px; color: var(--muted); font-size: 0.9rem; }
.signin-points li { display: flex; align-items: center; gap: 10px; }
.signin-points svg { color: var(--brand); }
.signin-card { padding: 40px 36px; display: flex; flex-direction: column; gap: 4px; }
.signin-options { display: grid; gap: 10px; margin: 22px 0 6px; }
.signin-option {
  display: flex; align-items: center; gap: 14px; padding: 14px 16px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  text-decoration: none; color: var(--text); background: var(--surface); transition: border-color 0.15s ease, background 0.15s ease;
}
a.signin-option:hover { border-color: var(--brand); background: var(--brand-bg); }
.signin-option.is-off { color: var(--faint); background: var(--subtle); border-style: dashed; }
.signin-icon { width: 38px; height: 38px; border-radius: 10px; display: inline-grid; place-items: center; background: var(--brand-bg); color: var(--brand); flex: none; }
.is-off .signin-icon { background: var(--hover); color: var(--faint); }
.signin-text { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.signin-name { font-weight: 600; }
.signin-what { color: var(--faint); font-size: 0.85rem; }
.signin-go { color: var(--faint); }
a.signin-option:hover .signin-go { color: var(--brand); }
.signin-note { margin-top: 4px; }
.demo-box { margin-top: 22px; padding: 16px; border: 1px dashed var(--line-strong); border-radius: var(--radius-sm); display: grid; gap: 10px; }
.demo-title { font-weight: 600; font-size: 0.92rem; display: flex; align-items: center; gap: 8px; }
.demo-box select { width: 100%; }
.demo-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.demo-row .check { margin: 0; flex: 1 1 220px; }

@media (max-width: 1180px) {
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .overview { grid-template-columns: minmax(0, 1fr); }
}

/* ---------- Polish round (2026-11-18): archive actions, grouped alerts, staff rows, filters ---------- */

.title-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; }
.head-actions { display: flex; flex-wrap: wrap; gap: 8px; flex: none; }
.confirm-layout { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 18px; margin-bottom: 18px; }
.confirm-layout .facts { gap: 8px 20px; font-size: 0.93rem; }
.confirm-layout .facts dd { overflow-wrap: anywhere; min-width: 0; }
.effects { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; font-size: 0.93rem; }
.effects li { display: flex; gap: 10px; align-items: flex-start; }
.effects svg { color: var(--brand); margin-top: 3px; }
.confirm-form .field { margin-bottom: 8px; }
.confirm-form-plain { border: 0; padding: 0; background: none; }
.archive-cell .sub { overflow-wrap: anywhere; }
.alert-count { margin-left: 6px; padding: 1px 8px; font-size: 0.75rem; font-weight: 500; vertical-align: 1px; }
.alert-text { overflow-wrap: anywhere; }
.status-line { margin: 0 0 12px; }
.cell-actions > * { vertical-align: middle; }
.cell-actions .btn + .link-sm { margin-left: 10px; }

/* Staff rows: the status and its actions, evenly spaced. The add form's button keeps its own width, on the inputs' line. */
.staff-actions { gap: 6px 16px; }
.staff-actions .linkish, .staff-actions a { font-size: 0.85rem; }
.field-submit { align-self: end; align-items: flex-start; }
.field-submit .btn { padding-top: 10px; padding-bottom: 10px; }

/* Filters that hold text and date inputs (the audit log): one row on wide screens, wrapping on small ones. */
.filters-row input[type="text"], .filters-row input[type="date"] {
  width: auto; flex: 1 1 170px; min-width: 0; border-radius: 999px; padding: 7px 14px; font-size: 0.88rem;
}
.filters-row input[type="date"] { flex: 0 1 165px; }
.filters-row select { flex: 0 1 200px; min-width: 0; }

/* Sign-in: the intro's content sits together in the middle of its panel instead of at both ends. */
.signin-intro { justify-content: center; }
.signin-points { margin: 4px 0 0; }

@media (max-width: 640px) {
  /* Lists on a phone: each row becomes a small card, the column name beside each value. */
  .table-stack thead { display: none; }
  .table-stack, .table-stack tbody, .table-stack tr, .table-stack td { display: block; width: 100%; }
  .table-stack tr { padding: 12px 16px; border-bottom: 1px solid var(--line); }
  .table-stack tr:last-child { border-bottom: 0; }
  .table-stack td { border: 0; padding: 3px 0; min-width: 0; overflow-wrap: anywhere; }
  /* Each labelled cell: the column name, then its value (wrapped in .cv), side by side; both may wrap. */
  .table-stack td[data-label] { display: grid; grid-template-columns: minmax(0, 36%) minmax(0, 1fr); column-gap: 12px; align-items: baseline; }
  .table-stack td[data-label]::before { content: attr(data-label); color: var(--faint); font-size: 0.8rem; line-height: 1.4; }
  .table-stack td[data-label] > .cv { min-width: 0; }
  .table-stack td[data-label]:has(> .cv:empty) { display: none; }  /* no label beside an empty value */
  .table-stack td.cell-title { padding-bottom: 6px; font-size: 1rem; }
  .table-stack td.cell-actions { text-align: left; white-space: normal; padding-top: 8px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; }
  .table-stack td.cell-actions .inline-form, .table-stack td.cell-actions .btn + .link-sm { margin: 0; }
  .table-stack td.empty { padding: 28px 0; }
  .table-stack .chip { white-space: normal; }
  .table-stack .progress-cell { white-space: normal; }
  .table-stack tbody tr:hover { background: none; }

  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }

  /* The client's progress steps: two rows of three, never cut at the card's edge. */
  .steps { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); row-gap: 14px; overflow: visible; }
  .step { min-width: 0; }
  .program-card { padding: 18px; }
  .program-head { flex-wrap: wrap; }
  .head-actions { width: 100%; }

  /* Label-and-value lists (the engagement's Internal section, company profiles): the label above its value. */
  .facts { grid-template-columns: minmax(0, 1fr); gap: 2px 0; }
  .facts dd { margin-bottom: 10px; min-width: 0; overflow-wrap: anywhere; }
  .stage-form select, .stage-form input[type="text"], .stage-form input[type="date"] { min-width: 0; flex: 1 1 100%; width: 100%; }
}
@media (max-width: 760px) {
  .signin { grid-template-columns: minmax(0, 1fr); }
  .signin-intro { padding: 24px 22px; gap: 14px; }
  .signin-points { display: none; }
  .signin-card { padding: 26px 22px; }
}
@media (max-width: 640px) {
  .welcome { flex-direction: column; align-items: flex-start; }
  .welcome h1 { font-size: 1.5rem; }
  .cards { gap: 10px; }
  .stat-card { padding: 14px; }
  .stat-value { font-size: 1.6rem; }
  .stat-sub { display: none; }
  .panel { padding: 14px 16px; }
  .attention-row { flex-wrap: wrap; }
  .attention-row .btn { margin-left: 20px; }
}
