/* WPSBC Enrollment demo. Brand colors are sampled exactly from the
   WPSBC logo (public/logo.png): purple #34246B and teal #027378. The tints
   are only for light backgrounds and borders. */
:root {
  --wpsbc-purple: #34246B;
  --wpsbc-teal: #027378;
  --brand: var(--wpsbc-teal);
  --brand-dark: var(--wpsbc-teal);
  --brand-darker: var(--wpsbc-purple);
  --brand-tint: #e6f1f2;
  --brand-line: #9fc9cb;
  --ink: #1f2937;
  --ink-2: #4b5563;
  --muted: #5f6b7a;
  --line: #e2e8ee;
  --surface: #ffffff;
  --page: #f4f6f8;
  --warn-bg: #fff7e6;
  --warn-line: #f0c36d;
  --warn-ink: #7a4b00;
  --ok-ink: #1e6b3a;
  --err-bg: #fdecec;
  --err-line: #e8a1a1;
  --err-ink: #9b1c1c;
  --focus: #0b5fff;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--page);
}
a { color: var(--brand-dark); }
a:hover { color: var(--brand-darker); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
code { font-family: Consolas, "Cascadia Mono", monospace; font-size: .92em; }
h1, h2 { line-height: 1.25; margin: 0 0 .25rem; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.1rem; }
p { margin: 0 0 .5rem; }

.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; }
.skip-link { position: absolute; left: -999px; top: 0; background: #fff; padding: .5rem 1rem; z-index: 10; }
.skip-link:focus { left: 1rem; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }

.demo-banner { background: #fdf3d6; color: #6b4e00; text-align: center; font-size: .8rem; font-weight: 600; padding: 4px 16px; letter-spacing: .02em; }

/* --- Header ------------------------------------------------------------- */
.site-header { background: var(--wpsbc-purple); color: #fff; }
.header-inner { max-width: 1200px; margin: 0 auto; padding: 10px 20px; display: flex; align-items: center; gap: 24px; flex-wrap: wrap; }
.brand { color: #fff; text-decoration: none; font-weight: 700; font-size: 1.1rem; display: flex; align-items: center; gap: 10px; }
.brand:hover { color: #fff; }
.brand-logo { height: 40px; width: 40px; background: #fff; border-radius: 50%; padding: 1px; }
.nav-links { list-style: none; display: flex; gap: 4px; margin: 0; padding: 0; flex-wrap: wrap; }
.nav-links a { color: #e6f4f4; text-decoration: none; padding: 8px 12px; border-radius: 6px; display: block; font-weight: 500; }
.nav-links a:hover { background: var(--wpsbc-teal); color: #fff; }
.nav-links a[aria-current="page"] { background: #fff; color: var(--wpsbc-purple); }
.user-box { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.user-name { display: flex; flex-direction: column; text-align: right; font-weight: 600; font-size: .9rem; line-height: 1.2; }
.user-role { font-weight: 400; font-size: .78rem; color: #cfe9e9; }
.user-box form { margin: 0; }

/* --- Layout ------------------------------------------------------------- */
.container { max-width: 1200px; margin: 0 auto; padding: 24px 20px 40px; }
.site-footer { color: var(--muted); font-size: .8rem; border-top: 1px solid var(--line); }
.site-footer .container { padding: 16px 20px; }
.footer-inner { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.footer-inner form { margin: 0; }
.link-button { background: none; border: 0; padding: 0; font: inherit; color: var(--muted); text-decoration: underline; cursor: pointer; }
.link-button:hover { color: var(--ink); }
.link-button.danger { color: var(--err-ink); }
.doc-link { font-weight: 600; }
.doc-size { margin-left: 6px; white-space: nowrap; }
.doc-desc { margin: 4px 0 0; font-size: .88rem; color: var(--ink-2); }
.field input[type="file"] { padding: 8px; background: #f8fafb; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.breadcrumb { margin-bottom: 12px; }
.breadcrumb a { text-decoration: none; font-weight: 500; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin-bottom: 16px; }
.card.flush { padding: 0; overflow-x: auto; position: relative; }
.card.narrow { max-width: 640px; }
.stack > * + * { margin-top: 14px; }

/* --- Buttons ------------------------------------------------------------ */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: inherit; font-weight: 600; font-size: .92rem; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line); background: #fff; color: var(--ink); text-decoration: none; cursor: pointer; }
.btn:hover { background: #f3f6f8; color: var(--ink); }
.btn-primary { background: var(--brand-dark); border-color: var(--brand-dark); color: #fff; }
.btn-primary:hover { background: var(--brand-darker); color: #fff; }
.btn-ghost { background: transparent; color: #fff; border-color: rgba(255,255,255,.5); }
.btn-ghost:hover { background: var(--wpsbc-teal); color: #fff; }
.btn-ghost-dark { background: transparent; color: var(--brand-dark); border-color: var(--brand-line); }
.btn-danger-ghost { background: transparent; color: var(--err-ink); border-color: var(--err-line); }
.btn-danger-ghost:hover { background: var(--err-bg); color: var(--err-ink); }
.btn-small { padding: 5px 10px; font-size: .85rem; }
.btn-block { width: 100%; }

/* --- Flash / callouts --------------------------------------------------- */
.flash { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; border: 1px solid; }
.flash-success { background: #e9f7ef; border-color: #a6d9b8; color: var(--ok-ink); }
.flash-error { background: var(--err-bg); border-color: var(--err-line); color: var(--err-ink); }
.callout-warn { background: var(--warn-bg); border: 1px solid var(--warn-line); color: var(--warn-ink); border-radius: var(--radius); padding: 14px 18px; margin-bottom: 16px; }
.callout-warn h2 { font-size: 1rem; }
.callout-warn ul { margin: 4px 0 0; padding-left: 20px; }
.callout-warn .dup-list { list-style: none; padding: 0; margin-top: 8px; display: grid; gap: 6px; }
.callout-warn .dup-list a { font-weight: 700; color: var(--warn-ink); }
.callout-warn .dup-list .muted { color: var(--warn-ink); opacity: .85; }

/* --- KPIs --------------------------------------------------------------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin-bottom: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; color: var(--ink); text-decoration: none; display: block; }
.kpi-link:hover { border-color: var(--brand); color: var(--ink); }
.kpi-label { font-size: .85rem; font-weight: 600; color: var(--ink-2); margin: 0; }
.kpi-value { font-size: 2.4rem; font-weight: 700; line-height: 1.1; margin: 6px 0 4px; font-variant-numeric: tabular-nums; }
.kpi-note { font-size: .82rem; color: var(--muted); margin: 0; }

/* --- Bar chart (single series, one hue) --------------------------------- */
.bar-chart { list-style: none; margin: 14px 0 8px; padding: 0; }
.bar-row { display: grid; grid-template-columns: 190px 1fr 40px; align-items: center; gap: 12px; padding: 5px 6px; border-radius: 6px; text-decoration: none; color: var(--ink); }
.bar-row:hover { background: var(--brand-tint); color: var(--ink); }
.bar-row:hover .bar-fill { background: var(--brand-darker); }
.bar-label { font-size: .92rem; }
.bar-track { height: 22px; display: block; }
.bar-fill { display: block; height: 100%; min-width: 2px; background: var(--brand-dark); border-radius: 0 4px 4px 0; }
.bar-value { font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; }
.table-view summary { cursor: pointer; color: var(--brand-dark); font-weight: 600; font-size: .9rem; }
.table-view table { margin-top: 8px; border-collapse: collapse; min-width: 280px; }
.table-view th, .table-view td { padding: 4px 12px 4px 0; border-bottom: 1px solid var(--line); text-align: left; }
.num { text-align: right !important; font-variant-numeric: tabular-nums; }

/* --- Tables ------------------------------------------------------------- */
table.data { width: 100%; border-collapse: collapse; font-size: .93rem; }
table.data th, table.data td { padding: 11px 16px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
table.data thead th { background: #f8fafb; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-2); font-weight: 700; white-space: nowrap; }
table.data tbody th { font-weight: 600; white-space: nowrap; }
table.data tbody tr:hover { background: #fafcfc; }
table.data tbody tr:last-child > * { border-bottom: 0; }
table.data td.wrap { max-width: 380px; }
table.data .actions { text-align: right; white-space: nowrap; }
.empty { color: var(--muted); padding: 16px; margin: 0; font-style: italic; }

/* --- Badges & flags ----------------------------------------------------- */
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .8rem; font-weight: 600; white-space: nowrap; border: 1px solid; background: #f3f4f6; border-color: #d6dae0; color: #374151; }
.stage-initial-contact { background: #eef4ff; border-color: #c7d7fb; color: #1e3a8a; }
.stage-awaiting-review { background: #f5f0ff; border-color: #d9ccf7; color: #4c1d95; }
.stage-approved { background: var(--brand-tint); border-color: var(--brand-line); color: var(--brand-dark); }
.stage-not-approved { background: #f3f4f6; border-color: #d6dae0; color: #374151; }
.stage-withdrawn { background: #fdf2ef; border-color: #ecc9bf; color: #7a2e17; }
.stage-adult-program-active { background: #e8f6ee; border-color: #b3dcc3; color: #14532d; }
.stage-adult-program-on-hold { background: #fbf6e9; border-color: #e6d4a3; color: #5c4400; }
.stage-adult-program-exited { background: #f1f5f4; border-color: #cfdad6; color: #334e45; }
.stage-no-activity { background: #fff; border-style: dashed; color: var(--muted); }
.flag-warn { color: var(--warn-ink); font-weight: 600; white-space: nowrap; }
.flag-ok { color: var(--ok-ink); white-space: nowrap; }

/* --- Forms -------------------------------------------------------------- */
.field label { display: block; font-weight: 600; margin-bottom: 4px; }
.field input, .field select, .field textarea { width: 100%; font: inherit; padding: 9px 11px; border: 1px solid #b9c3cd; border-radius: 8px; background: #fff; color: var(--ink); }
.field textarea { resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--brand-dark); }
.field .help { font-size: .85rem; color: var(--muted); margin: -2px 0 6px; }
.req { color: var(--err-ink); }
.has-error input, .has-error select, .has-error textarea { border-color: var(--err-ink); border-width: 2px; }
.field-error { color: var(--err-ink); font-weight: 600; font-size: .9rem; margin: 0 0 6px; }
.error-summary { border: 2px solid var(--err-ink); background: var(--err-bg); border-radius: 8px; padding: 12px 16px; margin: 12px 0; }
.error-summary h2 { font-size: 1rem; color: var(--err-ink); }
.error-summary ul { margin: 4px 0 0; padding-left: 20px; }
.error-summary a { color: var(--err-ink); font-weight: 600; }
.form-actions { display: flex; gap: 10px; padding-top: 6px; }
.delete-form { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line); }

.filters { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; padding: 16px 20px; }
.filters .field { min-width: 170px; }
.filters .field.grow { flex: 1 1 240px; }
.field-actions { display: flex; gap: 8px; }

.chip-filter { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.chip { text-decoration: none; padding: 6px 12px; border-radius: 999px; border: 1px solid #c9d4dc; background: #fff; color: var(--ink); font-size: .9rem; font-weight: 500; }
.chip:hover { border-color: var(--brand-dark); color: var(--ink); }
.chip[aria-current="true"], .chip[aria-pressed="true"] { background: var(--brand-dark); border-color: var(--brand-dark); color: #fff; }
.chip-count { font-variant-numeric: tabular-nums; opacity: .75; margin-left: 2px; }

/* --- Person detail ------------------------------------------------------ */
.profile { display: flex; justify-content: space-between; gap: 20px; flex-wrap: wrap; }
.profile h1 { font-size: 1.9rem; }
.profile-main { flex: 1 1 480px; min-width: 0; }
.profile-actions { display: flex; gap: 8px; align-items: flex-start; }
.profile-actions form { margin: 0; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px 28px; margin: 14px 0 0; }
.facts dt { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 700; }
.facts dd { margin: 2px 0 0; font-weight: 500; }
.detail-grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; align-items: start; }
.section-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.section-head h2 { margin: 0; }
.count { display: inline-block; min-width: 24px; text-align: center; font-size: .8rem; background: #eef2f5; border-radius: 999px; padding: 1px 8px; color: var(--ink-2); margin-left: 4px; vertical-align: middle; }
.timeline { position: sticky; top: 16px; }
.timeline ol { list-style: none; margin: 10px 0 0; padding: 0 0 0 14px; border-left: 2px solid #cfe5e5; }
.timeline li { position: relative; padding: 0 0 14px 12px; }
.timeline li::before { content: ""; position: absolute; left: -21px; top: 6px; width: 10px; height: 10px; border-radius: 50%; background: var(--brand-dark); border: 2px solid #fff; }
.tl-date { font-size: .8rem; color: var(--muted); margin: 0; }
.tl-kind { font-weight: 700; color: var(--brand-darker); }
.tl-text { margin: 0; font-size: .92rem; }

/* --- Login -------------------------------------------------------------- */
.login-wrap { display: flex; justify-content: center; padding-top: 12px; }
.login-card { width: 100%; max-width: 440px; text-align: center; padding: 28px; }
.login-card form, .demo-accounts { text-align: left; }
.login-logo { height: 96px; width: auto; margin-bottom: 8px; }
.demo-accounts { margin-top: 24px; border-top: 1px solid var(--line); padding-top: 16px; }
.demo-accounts h2 { font-size: .95rem; }
.demo-accounts ul { list-style: none; padding: 0; margin: 8px 0; display: grid; gap: 8px; }
.account-pick { width: 100%; text-align: left; font: inherit; background: #f8fafb; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; cursor: pointer; display: flex; flex-direction: column; }
.account-pick:hover { border-color: var(--brand-dark); background: var(--brand-tint); }
.account-pick span { font-size: .85rem; color: var(--muted); }

/* --- Spreadsheet -------------------------------------------------------- */
.container-wide { max-width: none; }
.sheet-tabs { display: flex; gap: 2px; flex-wrap: wrap; border-bottom: 2px solid var(--brand-dark); }
.sheet-tabs a { padding: 7px 14px; border: 1px solid var(--line); border-bottom: 0; border-radius: 8px 8px 0 0; background: #eef2f5; color: var(--ink-2); text-decoration: none; font-weight: 600; font-size: .9rem; }
.sheet-tabs a:hover { background: #fff; color: var(--ink); }
.sheet-tabs a[aria-current="page"] { background: var(--brand-dark); border-color: var(--brand-dark); color: #fff; }
.grid-shell { border-top-left-radius: 0; overflow: hidden; }
.formula-bar { display: flex; align-items: center; gap: 0; border-bottom: 1px solid var(--line); background: #fff; font-size: .9rem; }
.name-box { width: 72px; padding: 6px 10px; border-right: 1px solid var(--line); font-family: Consolas, "Cascadia Mono", monospace; text-align: center; }
.fx { padding: 6px 10px; color: var(--muted); font-style: italic; font-family: Georgia, serif; border-right: 1px solid var(--line); }
.formula-value { flex: 1; padding: 6px 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-height: 1.5em; }
.grid-scroll { overflow: auto; max-height: calc(100vh - 300px); min-height: 280px; scroll-padding: 96px 0 0 58px; }
table.sheet { border-collapse: separate; border-spacing: 0; table-layout: fixed; width: max-content; min-width: 100%; font-size: .9rem; }
.sheet th, .sheet td { border-right: 1px solid #dfe4e8; border-bottom: 1px solid #dfe4e8; padding: 0 8px; height: 30px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: left; background: #fff; }
.sheet thead { position: sticky; top: 0; z-index: 3; }
.sheet thead th, .sheet thead td { background: #f3f5f7; }
.sheet .letters th { height: 20px; font-size: .72rem; color: var(--muted); text-align: center; font-weight: 600; }
.sheet .labels th { padding: 0; font-weight: 700; color: var(--ink); }
.sort-btn { all: unset; box-sizing: border-box; display: block; width: 100%; height: 30px; padding: 0 8px; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sort-btn:hover { background: #e7ecef; }
.sort-btn:focus-visible { outline: 3px solid var(--focus); outline-offset: -3px; }
.sort-arrow { color: var(--brand-dark); font-size: .75rem; }
.filters-row td { padding: 3px 4px; }
.filters-row input, .filters-row select { width: 100%; font: inherit; font-size: .82rem; padding: 3px 6px; border: 1px solid #c4ccd4; border-radius: 4px; background: #fff; }
.filter-label { font-size: .7rem; color: var(--muted); text-align: center; }
.sheet .row-head { position: sticky; left: 0; z-index: 2; width: 58px; text-align: center; background: #f3f5f7; color: var(--muted); font-weight: 500; font-size: .8rem; padding: 0 4px; }
.sheet thead .row-head { z-index: 4; }
.sheet .frozen { position: sticky; left: 58px; z-index: 1; box-shadow: 2px 0 0 #c4ccd4; }
.sheet thead .frozen { z-index: 4; }
.open-link { color: var(--muted); text-decoration: none; display: block; }
.open-link:hover { color: var(--brand-dark); text-decoration: underline; }
.sheet td.ro { background: #f8f9fa; color: var(--ink-2); }
.sheet td.date { font-variant-numeric: tabular-nums; }.sheet td.active { outline: 2px solid var(--brand-dark); outline-offset: -2px; }
.sheet tbody tr:hover td:not(.active) { background-image: linear-gradient(rgba(64,179,181,.06), rgba(64,179,181,.06)); }
.sheet td:focus { outline: 3px solid var(--focus); outline-offset: -3px; }
.sheet td.editing { padding: 0; overflow: visible; outline: 2px solid var(--brand-dark); outline-offset: -2px; }
.cell-editor { width: 100%; height: 30px; border: 0; padding: 0 7px; font: inherit; background: #fff; box-shadow: inset 0 0 0 2px var(--brand); }
.cell-editor:focus { outline: none; }
.sheet td.saving { color: var(--muted); font-style: italic; }
.sheet td.saved { background: #e3f5ea; transition: background .3s; }
.sheet td.invalid { box-shadow: inset 0 0 0 2px var(--err-ink); }
.sheet td.pending { background: var(--warn-bg); color: var(--warn-ink); font-style: italic; box-shadow: inset 0 0 0 2px var(--warn-line); }
.empty-sheet { padding: 24px !important; color: var(--muted); font-style: italic; height: auto !important; }
.status-bar { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; padding: 6px 12px; border-top: 1px solid var(--line); background: #f3f5f7; font-size: .82rem; color: var(--ink-2); }
.grid-message { color: var(--err-ink); font-weight: 600; flex: 1; }
.grid-message:empty { flex: 1; }
.status-help { margin-left: auto; color: var(--muted); }
kbd { font-family: inherit; font-size: .75rem; border: 1px solid #c4ccd4; border-bottom-width: 2px; border-radius: 4px; padding: 0 4px; background: #fff; }

/* --- Import ------------------------------------------------------------- */
.import-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.template-list { list-style: none; padding: 0; margin: 8px 0 14px; display: grid; gap: 8px; }
.template-list a { font-weight: 600; }
.template-list li > span { display: block; }
.kpi-error .kpi-value { color: var(--err-ink); }
.callout-info { background: #eef4ff; border: 1px solid #c7d7fb; color: #1e3a8a; border-radius: var(--radius); padding: 10px 14px; }
.result-create, .result-update { background: #e8f6ee; border-color: #b3dcc3; color: #14532d; }
.result-skip { background: #f3f4f6; border-color: #d6dae0; color: #374151; }
.result-error { background: var(--err-bg); border-color: var(--err-line); color: var(--err-ink); }
.new-person { background: #eef4ff; border-color: #c7d7fb; color: #1e3a8a; margin-left: 4px; }
.person-how { display: block; }
.import-table td, .import-table th { vertical-align: top; }
.import-table input[type="checkbox"] { width: 18px; height: 18px; }
.import-row-error { background: #fffafa; }
.import-msgs { margin: 0; padding-left: 16px; }
.import-msgs li { margin-bottom: 2px; }
.msg-error { color: var(--err-ink); font-weight: 600; }
.msg-warning { color: var(--warn-ink); font-weight: 600; }
.msg-info { color: var(--ink-2); }
.import-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin: 4px 0 8px; }
.cancel-form { margin: 0 0 12px; }
.chip-filter button.chip { font: inherit; font-size: .9rem; cursor: pointer; }
.import-previewed { background: #fbf6e9; border-color: #e6d4a3; color: #5c4400; }
.import-imported { background: #e8f6ee; border-color: #b3dcc3; color: #14532d; }
.import-undone, .import-cancelled { background: #f3f4f6; border-color: #d6dae0; color: #374151; }
.badge-lg { font-size: .95rem; padding: 4px 14px; }
.people-created { columns: 3 220px; margin: 8px 0 0; padding-left: 20px; }

/* --- Small screens ------------------------------------------------------ */
@media (max-width: 900px) {
  .detail-grid { grid-template-columns: minmax(0, 1fr); }
  .import-grid { grid-template-columns: minmax(0, 1fr); }
  .timeline { position: static; }
  .user-box { margin-left: 0; }
}
@media (max-width: 600px) {
  .container { padding: 16px 16px 32px; }
  .bar-row { grid-template-columns: 1fr 36px; }
  .bar-track { grid-column: 1 / -1; grid-row: 2; }
  .filters .field { min-width: 100%; }
}

/* Grouped form sections and checkbox lists (intake / exit forms) */
.form-group { border: 0; border-top: 1px solid var(--line); margin: 8px 0 0; padding: 16px 0 0; min-width: 0; }
.form-group > legend { font-size: 1.05rem; font-weight: 700; color: var(--brand-dark); padding: 0 8px 0 0; }
.form-group > .field:not([hidden]) ~ .field { margin-top: 14px; }
.checks { border: 0; margin: 0; padding: 0; }
.checks > legend { font-weight: 600; padding: 0; margin-bottom: 4px; }
.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px 16px; margin-top: 6px; }
.field .check { display: flex; align-items: center; gap: 8px; font-weight: 400; margin: 0; cursor: pointer; }
.field .check input { width: 18px; height: 18px; margin: 0; padding: 0; flex: none; }
.field[hidden] { display: none; }

/* Parent survey (public page) */
.choice-group { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px 16px; margin: 0; min-width: 0; }
.choice-group > legend { font-weight: 700; padding: 0 6px; }
.choice-group.has-error { border-color: var(--err-ink); }
.choice { display: flex; align-items: center; gap: 10px; padding: 7px 0; cursor: pointer; }
.choice input { width: 20px; height: 20px; margin: 0; flex: none; accent-color: var(--brand-dark); }
.rating { display: flex; flex-wrap: wrap; gap: 4px 22px; }
.field.nested { margin: 6px 0 0 30px; }
.survey .btn-primary { font-size: 1.05rem; padding: 12px 22px; }

/* Intake / exit record cards on the person page */
.record-card { padding: 14px 20px 16px; border-top: 1px solid var(--line); }
.record-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.record-head h3 { font-size: 1rem; margin: 0; }
.record-edit { margin-left: auto; }
.record-group { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 14px 0 6px; }
.record-facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px 20px; margin: 0; }
.record-facts dt { font-size: .82rem; color: var(--ink-2); font-weight: 600; }
.record-facts dd { margin: 2px 0 0; white-space: pre-line; overflow-wrap: anywhere; }
.survey-status { margin: 0 0 8px; }
.survey-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; }
.kpi-unit { font-size: 1rem; font-weight: 600; color: var(--muted); }

/* Contact log inside the intake card */
.record-group-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 6px; }
.record-group-head .record-group { margin: 8px 0 6px; }
.contact-log { margin-top: 4px; }
.contact-log td, .contact-log th { padding-left: 0; }
.contact-log .contact-first td { color: var(--ink-2); }
.contact-log { table-layout: fixed; width: 100%; }
.contact-log th:nth-child(1) { width: 112px; }
.contact-log th:nth-child(2) { width: 112px; }
.contact-log th:nth-child(4) { width: 96px; }
.contact-log th:nth-child(5) { width: 44px; }
.contact-log td.wrap { max-width: none; }

/* Current services: each ticked service has an "about how long?" choice */
.check-rows { display: grid; gap: 4px; margin-top: 6px; }
.check-row { display: grid; grid-template-columns: minmax(140px, 180px) 1fr; align-items: center; gap: 12px; min-height: 42px; }
.field .check-detail select { padding: 6px 10px; }
.check-detail[hidden] { display: none; }
@media (max-width: 520px) { .check-row { grid-template-columns: 1fr; gap: 2px; } .check-detail { margin: 0 0 6px 26px; } }
fieldset.form-group[hidden] { display: none; }

/* --- Users page --------------------------------------------------------- */
.access { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .8rem; font-weight: 600; white-space: nowrap; border: 1px solid; }
.access-edit { background: var(--brand-tint); border-color: var(--brand-line); color: var(--brand-dark); }
.access-view { background: #eaf1fb; border-color: #a9c3e8; color: #1f4b85; }
.access-none { background: #f3f4f6; border-color: #d6dae0; color: #4b5563; }
table.data.access-matrix tbody th { white-space: normal; min-width: 180px; width: 30%; }
table.data.access-matrix th, table.data.access-matrix td { padding-left: 10px; padding-right: 10px; }
table.data.access-matrix thead th { white-space: normal; }
.group-desc { display: block; font-weight: 400; font-size: .85rem; color: var(--muted); margin-top: 2px; }
.row-inactive th, .row-inactive td { color: var(--muted); }
.table-note { padding: 10px 16px; margin: 0; border-top: 1px solid var(--line); }
.subhead { font-size: 1rem; margin: 14px 0 2px; }
.access-field select { max-width: 280px; }
.access-choice { border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px 12px; }
.access-choice > legend { font-weight: 700; padding: 0 4px; }
.access-choice .help { margin: 0 0 6px; }
.radio-row { display: flex; flex-wrap: wrap; gap: 6px 22px; }
.danger-zone { margin-top: 22px; padding-top: 14px; border-top: 1px solid var(--line); }
#own-settings[hidden], #admin-note[hidden] { display: none; }
.radio-row .check { display: flex; align-items: center; gap: 8px; font-weight: 400; margin: 0; cursor: pointer; min-height: 32px; }
.radio-row .check input { width: 18px; height: 18px; margin: 0; flex: none; }
