/* Hallmark · pre-emit critique: P4 H4 E4 S4 R4 V3 · weakest: V, an enterprise tool is meant to look familiar; the signature is the persistent organisation block and the workflow stepper, not decoration */
/* Hallmark · shape: app screen · scope: app · genre: modern-minimal · surface: absolute · nav: left sidebar, a disclosure menu under 64rem */
/* Hallmark · waive 7b · surface #ffffff stays the paper token for panels and tables · panels hold the persistent organisation block and the workflow stepper on the tinted ground */
/* Hallmark · waive 49b · links that wrap are position titles typed by users (a 90 character stress title in the fixtures) and two settings destinations with descriptive labels · a reviewer must read the whole position title and the descriptive link text, so they wrap inside their cell rather than truncate */
/* Hallmark · waive 72 · the notice box has 16px padding on every side; the reported -304px bottom comes from text rects of the collapsed details disclosure inside it · the "How to read the columns" notice holds a closed details element whose hidden definitions are measured as overflowing */
/* Hallmark · waive 39b · only the organisation choice buttons exceed 40px, because long organisation names wrap onto several lines inside a full-width button · every organisation name must stay fully readable, so the button grows with its text and keeps a 44px minimum hit area */
/* Hallmark · answered F7 · the shared recipe is the one panel surface for every card, panel and stat on a dashboard, with controls kept separate */
/* DECITRIA local stylesheet. No external fonts, scripts or CDNs. Contract: docs/decitria-design-system.md */

:root {
  color-scheme: light dark;

  /* colour: light */
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #eef0f4;
  --text: #1c2430;
  --muted: #5b6676;
  --border: #d9dee6;
  --border-strong: #aab3c0;
  --field-border: #7d8899; /* form-control edge: >=3:1 on surface, bg and surface-2 (WCAG 1.4.11) */
  --accent: #1f4fd8;
  --accent-hover: #1a43b8;
  --accent-active: #15399c;
  --on-accent: #ffffff;
  --notice-bg: #eef3ff;
  --notice-border: #c4d3f7;
  --focus-ring: #1f4fd8;

  /* colour: semantic (red, amber, green only for state) */
  --danger-bg: #fdecec;
  --danger-text: #8a1f1f;
  --danger-border: #e3a5a5;
  --warn-bg: #fff3d6;
  --warn-text: #6b4300;
  --warn-border: #e3c27a;
  --ok-bg: #e6f4ea;
  --ok-text: #14602e;
  --ok-border: #9fcdad;

  --shadow-color: rgb(28 36 48 / 7%);
  --shadow: 0 1px 2px var(--shadow-color);
  --scrim: rgb(28 36 48 / 45%);

  /* type scale, ratio 1.125 */
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  --fs-xs: .75rem;
  --fs-sm: .875rem;
  --fs-base: 1rem;
  --fs-md: 1.125rem;
  --fs-lg: 1.265rem;
  --fs-xl: 1.42rem;
  --fs-2xl: 1.6rem;

  /* spacing scale, 4px base */
  --s-1: .25rem;
  --s-2: .5rem;
  --s-3: .75rem;
  --s-4: 1rem;
  --s-5: 1.5rem;
  --s-6: 2rem;
  --s-7: 3rem;

  /* shape and layout */
  --radius: 8px;
  --radius-sm: 6px;
  --control-h: 2.5rem;
  --control-h-sm: 2rem;
  --hit: 2.75rem;
  --sidebar-w: 16rem;
  --content-max: 76rem;
  --measure: 68ch;

  /* motion: state only */
  --dur-micro: 90ms;
  --dur-short: 160ms;
  --ease: cubic-bezier(.2, 0, 0, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12161c;
    --surface: #1a2029;
    --surface-2: #222a35;
    --text: #e8ecf2;
    --muted: #9aa5b5;
    --border: #2c3542;
    --border-strong: #46515f;
    --field-border: #6b7787;
    --accent: #6d94ff;
    --accent-hover: #8aa9ff;
    --accent-active: #a3bbff;
    --on-accent: #0b1220;
    --notice-bg: #1b2538;
    --notice-border: #2f4067;
    --focus-ring: #8aa9ff;

    --danger-bg: #3a1b1b;
    --danger-text: #ffb4b4;
    --danger-border: #7a3a3a;
    --warn-bg: #352a10;
    --warn-text: #f2c879;
    --warn-border: #6e5421;
    --ok-bg: #14291c;
    --ok-text: #8fd7a5;
    --ok-border: #2f6a45;

    --shadow-color: rgb(0 0 0 / 35%);
    --scrim: rgb(0 0 0 / 60%);
  }
}

/* base */
* { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  overflow-x: clip;
  scrollbar-color: var(--border-strong) var(--bg);
}

body {
  margin: 0;
  overflow-x: clip;
  background: var(--bg);
  color: var(--text);
  font: var(--fs-base)/1.5 var(--font);
  caret-color: var(--accent);
  font-variant-numeric: tabular-nums;
}

::selection { background: var(--notice-border); color: var(--text); }

h1, h2, h3, h4 { text-wrap: balance; overflow-wrap: break-word; min-width: 0; }
h1 { font-size: var(--fs-2xl); margin: 0 0 var(--s-4); line-height: 1.25; font-weight: 650; }
h2 { font-size: var(--fs-md); margin: 0 0 var(--s-2); line-height: 1.3; font-weight: 650; }
h3 { font-size: var(--fs-base); margin: 0 0 var(--s-2); line-height: 1.35; font-weight: 650; }
h4 { font-size: var(--fs-sm); margin: 0 0 var(--s-2); font-weight: 650; }
p { margin: 0 0 var(--s-4); text-wrap: pretty; }
ul, ol { padding-left: 1.25rem; }
small { font-size: var(--fs-sm); }
code, kbd, samp { font-family: var(--mono); font-size: .9em; }
hr { border: 0; border-top: 1px solid var(--border); margin: var(--s-5) 0; }

a { color: var(--accent); text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }

.muted { color: var(--muted); }
.fineprint { color: var(--muted); font-size: var(--fs-sm); margin: var(--s-5) 0 0; }
.num, .stat strong, .score-metric strong, td.num, th.num { font-variant-numeric: tabular-nums; }
.eyebrow { color: var(--muted); font-size: var(--fs-sm); margin: 0 0 var(--s-1); }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0;
}
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.preserve-whitespace { white-space: pre-wrap; overflow-wrap: anywhere; }

/* focus: every interactive element, instant */
:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
a:focus-visible, .btn:focus-visible, summary:focus-visible { outline-offset: 2px; }

.skip-link {
  position: absolute; left: var(--s-3); top: var(--s-3); z-index: 100;
  padding: var(--s-2) var(--s-4); border-radius: var(--radius-sm);
  background: var(--accent); color: var(--on-accent); font-weight: 600; text-decoration: none;
  transform: translateY(-300%);
}
.skip-link:focus { transform: none; }

/* app frame: sidebar + main */
.app-frame { display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); min-height: 100vh; min-height: 100dvh; }
.app-main { display: flex; flex-direction: column; min-width: 0; }

.container {
  width: 100%; max-width: var(--content-max); margin: 0 auto;
  padding: var(--s-5) var(--s-4) var(--s-7); flex: 1 0 auto; min-width: 0;
}
.container:focus { outline: none; }

/* sidebar (class kept as .topbar for compatibility) */
.topbar {
  background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2) var(--s-3);
  padding: var(--s-2) var(--s-4); min-width: 0;
}
.brand {
  display: inline-flex; align-items: center; gap: var(--s-2);
  font-weight: 700; font-size: var(--fs-md); color: var(--text); text-decoration: none; letter-spacing: 0;
}
.brand::before {
  content: "D" / ""; display: inline-grid; place-items: center; flex: none;
  width: 1.75rem; height: 1.75rem; border-radius: var(--radius-sm);
  background: var(--accent); color: var(--on-accent); font-size: var(--fs-base); font-weight: 700;
}
.menu-toggle { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; pointer-events: none; }
.menu-button {
  margin: 0 0 0 auto; display: inline-flex; align-items: center; min-height: var(--hit);
  padding: 0 var(--s-3); border: 1px solid var(--field-border); border-radius: var(--radius-sm);
  font-size: var(--fs-sm); font-weight: 600; cursor: pointer; background: var(--surface); color: var(--text);
}
.menu-button:hover { background: var(--surface-2); }
.menu-toggle:focus-visible + .menu-button { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
.menu-toggle:checked + .menu-button { background: var(--surface-2); }
.topbar-panel { display: none; flex: 1 0 100%; flex-direction: column; gap: var(--s-4); padding: var(--s-2) 0 var(--s-3); min-width: 0; }
.menu-toggle:checked ~ .topbar-panel { display: flex; }
.topbar-left { display: flex; flex-direction: column; gap: var(--s-4); min-width: 0; }
.topbar-right {
  display: flex; flex-direction: column; gap: var(--s-3); min-width: 0;
  padding-top: var(--s-4); border-top: 1px solid var(--border);
}

.org-switch { display: grid; gap: var(--s-2); padding: var(--s-3); background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); }
.org-label { margin: 0; font-size: var(--fs-xs); color: var(--muted); }
.org-name {
  font-size: var(--fs-base); line-height: 1.3; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden;
}
.org-switch select { min-height: var(--control-h-sm); font-size: var(--fs-sm); padding: var(--s-1) var(--s-2); text-overflow: ellipsis; }
.org-switch .btn { width: 100%; }

.navlinks { display: flex; flex-direction: column; gap: 2px; }
.navlinks a {
  display: flex; align-items: center; min-height: var(--control-h); padding: 0 var(--s-3);
  border-radius: var(--radius-sm); color: var(--text); font-size: var(--fs-sm); font-weight: 500; text-decoration: none;
}
.navlinks a:hover { background: var(--surface-2); }
.navlinks a[aria-current="page"] { background: var(--notice-bg); color: var(--accent); font-weight: 650; box-shadow: inset 0 0 0 1px var(--notice-border); }

.identity { display: grid; gap: 2px; font-weight: 600; font-size: var(--fs-sm); overflow-wrap: anywhere; line-height: 1.3; }
.identity small { color: var(--muted); font-weight: 400; font-size: var(--fs-xs); }
.account-actions { display: flex; flex-wrap: wrap; gap: var(--s-2); }
.inline-form { margin: 0; }

.footer {
  padding: var(--s-4); text-align: center; color: var(--muted); font-size: var(--fs-xs);
  border-top: 1px solid var(--border); background: var(--surface);
}

@media (min-width: 64rem) {
  .app-frame { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); padding-left: var(--sidebar-w); }
  .topbar {
    position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); overflow-y: auto; overscroll-behavior: contain;
    flex-direction: column; flex-wrap: nowrap; align-items: stretch; gap: var(--s-5);
    padding: var(--s-5) var(--s-4); border-bottom: 0; border-right: 1px solid var(--border);
  }
  .menu-toggle, .menu-button { display: none; }
  .topbar-panel { display: flex; flex: 1 1 auto; justify-content: space-between; padding: 0; }
  .container { padding: var(--s-6) var(--s-6) var(--s-7); }
}

/* page header */
.page-header, .heading-row {
  display: flex; justify-content: space-between; align-items: center; gap: var(--s-3) var(--s-4);
  flex-wrap: wrap; margin-bottom: var(--s-5); min-width: 0;
}
.page-header h1, .heading-row h1 { margin: 0; min-width: 0; }
.page-header .lead, .page-lead { color: var(--muted); max-width: var(--measure); margin: var(--s-2) 0 0; }
.page-actions { display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; }

/* breadcrumbs, backlink, tabs */
.breadcrumb { margin: 0 0 var(--s-3); font-size: var(--fs-sm); }
.breadcrumb ol { list-style: none; display: flex; flex-wrap: wrap; gap: var(--s-1) var(--s-2); margin: 0; padding: 0; }
.breadcrumb li { display: inline-flex; align-items: center; gap: var(--s-2); color: var(--muted); min-width: 0; }
.breadcrumb li + li::before { content: "/" / ""; color: var(--border-strong); }
.breadcrumb a { color: var(--muted); }
.breadcrumb [aria-current="page"] { color: var(--text); font-weight: 600; overflow-wrap: anywhere; }
.backlink { display: inline-block; margin: 0 0 var(--s-4); font-size: var(--fs-sm); }

.tabs { display: flex; gap: var(--s-1); border-bottom: 1px solid var(--border); margin-bottom: var(--s-5); overflow-x: auto; }
.tabs a {
  display: inline-flex; align-items: center; min-height: var(--control-h); padding: 0 var(--s-4); white-space: nowrap;
  color: var(--muted); font-size: var(--fs-sm); font-weight: 500; text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs a:hover { color: var(--text); background: var(--surface-2); }
.tabs a[aria-current="page"] { color: var(--accent); border-bottom-color: var(--accent); font-weight: 650; }

/* surfaces */
.card, .panel, .stat, .score-metric, .rubric-criterion, .empty-state {
  background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: var(--radius);
}
.card { padding: var(--s-6); }
.panel { margin-bottom: var(--s-5); box-shadow: var(--shadow); overflow: hidden; }
.panel:not(.form-panel) > p, .panel:not(.form-panel) > .muted { padding: 0 var(--s-5); }
.panel:not(.form-panel) > p:first-child { padding-top: var(--s-4); }
.panel-heading {
  display: flex; justify-content: space-between; align-items: baseline; gap: var(--s-3) var(--s-4); flex-wrap: wrap;
  padding: var(--s-3) var(--s-5); border-bottom: 1px solid var(--border); min-width: 0;
}
.panel-heading h2 { margin: 0; }
.panel-heading a { font-size: var(--fs-sm); }
.panel-body { padding: var(--s-4) var(--s-5); }
.form-panel { padding: var(--s-5); }
.form-panel h2 { margin-bottom: var(--s-4); }
.form-panel > .panel-heading { padding-left: 0; padding-right: 0; }
.panel-heading + p { margin-top: var(--s-3); }
.review-two-col + p { margin-top: var(--s-4); }
.review-two-col + label { margin-top: var(--s-4); }
td form input + .btn { margin-top: var(--s-2); }
.narrow { max-width: 36rem; margin: 0 auto; }
.wide-form { max-width: 48rem; }
.metadata { display: flex; gap: var(--s-2) var(--s-5); flex-wrap: wrap; margin-bottom: var(--s-5); font-size: var(--fs-sm); }

.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s-3); margin-bottom: var(--s-5); }
.stat { padding: var(--s-4) var(--s-5); display: grid; gap: var(--s-1); box-shadow: var(--shadow); min-width: 0; }
.stat strong { font-size: 2rem; line-height: 1.1; }
.stat span, .stat small { color: var(--muted); font-size: var(--fs-sm); }

.notice {
  background: var(--notice-bg); color: var(--text); border: 1px solid var(--notice-border);
  border-radius: var(--radius); padding: var(--s-3) var(--s-4); font-size: var(--fs-sm); margin: 0 0 var(--s-4);
}
.notice > :last-child { margin-bottom: 0; }
p.muted, p.notice, .notice, .panel > p, .card > p { max-width: calc(var(--measure) + 2 * var(--s-5)); }

/* alerts: tinted surface + full border + text prefix from the template; never colour alone */
.alert {
  padding: var(--s-3) var(--s-4); border-radius: var(--radius); margin: var(--s-4) 0;
  background: var(--notice-bg); color: var(--text); border: 1px solid var(--notice-border); font-size: var(--fs-sm);
}
.alert > :last-child { margin-bottom: 0; }
.alert-error, .alert-danger { background: var(--danger-bg); color: var(--danger-text); border-color: var(--danger-border); }
.alert-warning { background: var(--warn-bg); color: var(--warn-text); border-color: var(--warn-border); }
.alert-success { background: var(--ok-bg); color: var(--ok-text); border-color: var(--ok-border); }
.alert-info { background: var(--notice-bg); color: var(--text); border-color: var(--notice-border); }
.alert-inline { color: var(--danger-text); font-size: var(--fs-sm); }

/* badges: text plus a shape glyph, so state never relies on colour */
.pill, .badge {
  display: inline-flex; align-items: center; gap: var(--s-1); padding: 2px var(--s-2); border-radius: var(--radius-sm);
  font-size: var(--fs-xs); font-weight: 600; line-height: 1.4; white-space: nowrap; text-transform: capitalize;
  background: var(--surface-2); color: var(--text); border: 1px solid var(--border-strong);
}
.badge::before { content: "-" / ""; font-weight: 700; }
.badge-ok { background: var(--ok-bg); color: var(--ok-text); border-color: var(--ok-border); }
.badge-ok::before { content: "\2713" / ""; }
.badge-warn { background: var(--warn-bg); color: var(--warn-text); border-color: var(--warn-border); }
.badge-warn::before { content: "!" / ""; }
.badge-danger { background: var(--danger-bg); color: var(--danger-text); border-color: var(--danger-border); }
.badge-danger::before { content: "\2715" / ""; }
.badge-info { background: var(--notice-bg); color: var(--accent); border-color: var(--notice-border); }
.badge-info::before { content: "i" / ""; }
.pill.badge-ok, .pill.badge-warn, .pill.badge-danger, .pill.badge-info { gap: var(--s-1); }
.pill.badge-ok::before { content: "\2713" / ""; font-weight: 700; }
.pill.badge-warn::before { content: "!" / ""; font-weight: 700; }
.pill.badge-danger::before { content: "\2715" / ""; font-weight: 700; }
.pill.badge-info::before { content: "i" / ""; font-weight: 700; }

/* forms */
label { display: block; font-weight: 600; font-size: var(--fs-sm); margin: var(--s-4) 0 var(--s-1); }
input:not([type="hidden"], [type="checkbox"], [type="radio"], [type="file"]), textarea, select {
  width: 100%; min-height: var(--control-h); padding: var(--s-2) var(--s-3);
  border: 1px solid var(--field-border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); font: inherit; font-size: var(--fs-base); font-weight: 400;
}
textarea { resize: vertical; min-height: 6rem; line-height: 1.45; }
input[type="file"] { width: 100%; max-width: 100%; font: inherit; color: var(--text); padding: var(--s-2); border: 1px dashed var(--field-border); border-radius: var(--radius-sm); background: var(--surface); }
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); width: 1.1rem; height: 1.1rem; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 1; }
input:hover:not(:disabled), textarea:hover:not(:disabled), select:hover:not(:disabled) { border-color: var(--muted); }
input:focus-visible, textarea:focus-visible, select:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 1px; border-color: var(--focus-ring); }
input:disabled, textarea:disabled, select:disabled, input[readonly] { background: var(--surface-2); color: var(--muted); cursor: not-allowed; }
input[aria-invalid="true"], textarea[aria-invalid="true"], select[aria-invalid="true"], .is-invalid { border-color: var(--danger-text); }
input:user-invalid, textarea:user-invalid { border-color: var(--danger-text); }

.field { display: grid; gap: var(--s-1); margin-top: var(--s-4); min-width: 0; }
.field > label { margin: 0; }
.field-hint { margin: 0; color: var(--muted); font-size: var(--fs-sm); min-height: 1lh; }
.field-error { margin: 0; color: var(--danger-text); font-size: var(--fs-sm); font-weight: 600; }
.required-mark { color: var(--danger-text); font-weight: 700; }
.form-error-summary { margin-bottom: var(--s-4); }
fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: var(--s-3) var(--s-4); margin: var(--s-4) 0 0; min-width: 0; }
legend { padding: 0 var(--s-2); font-weight: 600; font-size: var(--fs-sm); }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-1) var(--s-4); align-items: end; }
.form-grid label { margin-top: var(--s-1); }
.form-grid .align-bottom { display: flex; align-items: end; margin-top: var(--s-4); }
.actions, .form-actions { display: flex; align-items: center; gap: var(--s-3); margin-top: var(--s-5); flex-wrap: wrap; }
.actions input { max-width: 10rem; }
.compact-form { display: flex; gap: var(--s-2); align-items: center; flex-wrap: wrap; margin: 0 0 var(--s-2); }
.compact-form select { width: auto; min-width: 7rem; }
.compact-form input:not([type="hidden"]) { width: auto; min-width: 9rem; max-width: 14rem; flex: 1 1 9rem; }
.compact-form input, .compact-form select { min-height: var(--control-h-sm); padding: var(--s-1) var(--s-2); font-size: var(--fs-sm); }

/* buttons: one filled primary recipe per screen */
.btn {
  white-space: nowrap;
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  min-height: var(--control-h); padding: 0 var(--s-4); border-radius: var(--radius-sm); border: 1px solid transparent;
  font: inherit; font-size: var(--fs-sm); font-weight: 600; line-height: 1.2; text-decoration: none; cursor: pointer;
  transition: background-color var(--dur-micro) var(--ease), border-color var(--dur-micro) var(--ease), color var(--dur-micro) var(--ease);
}
@media (max-width: 30rem) { .btn { max-width: 100%; padding: 0 var(--s-3); font-size: clamp(0.7rem, 3.3vw, var(--fs-sm)); } .btn-small { font-size: var(--fs-xs); } }
.btn-primary { width: 100%; margin-top: var(--s-5); background: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:active { background: var(--accent-active); }
.btn-quiet { background: var(--surface); color: var(--text); border-color: var(--field-border); }
.btn-quiet:hover { background: var(--surface-2); }
.btn-quiet:active { background: var(--border); }
.btn-inline { width: auto; margin-top: 0; }
form > .btn-inline:last-child { margin-bottom: var(--s-5); }
.btn-small { min-height: var(--control-h-sm); padding: 0 var(--s-3); font-size: var(--fs-xs); }
.btn-danger { background: var(--danger-bg); color: var(--danger-text); border-color: var(--danger-text); }
.btn-danger:hover { background: var(--danger-border); }
.btn-danger:active { background: var(--danger-border); }
.btn:disabled, .btn[disabled], .btn[aria-disabled="true"] {
  background: var(--surface-2); color: var(--muted); border-color: var(--border); cursor: not-allowed; box-shadow: none;
}
@media (pointer: coarse) {
  .btn, .navlinks a, .tabs a { min-height: var(--hit); }
  .btn-small { min-height: var(--hit); }
}

/* destructive confirmation: separated zone, plain consequence text, typed phrase, danger button */
.danger-zone { border: 1px solid var(--danger-border); border-radius: var(--radius); padding: var(--s-4) var(--s-5); margin-top: var(--s-6); background: var(--surface); }
.danger-zone h2 { color: var(--danger-text); }
.delete-form { border-top: 1px solid var(--border); margin-top: var(--s-6); padding-top: var(--s-4); }
.delete-form label, .danger-zone label { color: var(--danger-text); }

/* tables: intentional scroll in a bounded wrapper, sticky head (one sticky thead per table; th itself is not sticky), no page-level overflow */
.table-scroll { overflow: auto; max-height: min(75vh, 48rem); max-width: 100%; overscroll-behavior-x: contain; }
.table-scroll:focus-visible { outline-offset: -2px; }
table { border-collapse: separate; border-spacing: 0; width: 100%; text-align: left; font-size: var(--fs-sm); }
.table-scroll > table { min-width: 40rem; }
caption { text-align: left; color: var(--muted); font-size: var(--fs-sm); padding: var(--s-3) var(--s-4); }
thead { position: sticky; top: 0; z-index: 1; }
th {
  background: var(--surface-2); color: var(--muted);
  font-size: var(--fs-sm); font-weight: 600; text-transform: none; letter-spacing: 0; white-space: nowrap;
}
td, th { border-bottom: 1px solid var(--border); padding: var(--s-3) var(--s-4); vertical-align: top; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--bg); }
td code { font-size: var(--fs-xs); overflow-wrap: anywhere; white-space: normal; }
th a { color: inherit; }
td.num, th.num { text-align: right; }
td.actions-cell { white-space: nowrap; }
td.actions-cell a { display: block; }
time { font-variant-numeric: tabular-nums; }

/* lists */
.settings-list { display: grid; grid-template-columns: 13.75rem minmax(0, 1fr); gap: var(--s-2) var(--s-4); }
.settings-list dt { color: var(--muted); }
.settings-list dd { margin: 0; overflow-wrap: anywhere; }

/* workflow stepper: a status map with links, not a wizard (any step stays reachable) */
.stepper { list-style: none; margin: 0 0 var(--s-5); padding: 0; display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: var(--s-3); counter-reset: step; }
.step {
  counter-increment: step; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: var(--s-1) var(--s-3); align-items: start;
  padding: var(--s-3) var(--s-4); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); min-width: 0;
}
.step::before {
  content: counter(step); grid-row: span 2; display: grid; place-items: center; width: 1.75rem; height: 1.75rem; border-radius: 50%;
  border: 2px solid var(--border-strong); color: var(--muted); font-size: var(--fs-xs); font-weight: 700; font-variant-numeric: tabular-nums;
}
.step-title { font-weight: 600; font-size: var(--fs-sm); overflow-wrap: anywhere; }
.step-title a { color: inherit; }
.step-state { font-size: var(--fs-xs); color: var(--muted); }
.step-done::before { content: "\2713" / ""; background: var(--ok-bg); border-color: var(--ok-border); color: var(--ok-text); }
.step-current { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.step-current::before { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.step-blocked { background: var(--surface-2); color: var(--text); }
.step-blocked::before { content: "\2715" / ""; border-style: dashed; }
.step-blocked .step-title { color: var(--muted); }

/* empty, loading and error states */
.empty-state { border-style: dashed; padding: var(--s-6) var(--s-5); text-align: center; margin-bottom: var(--s-5); }
.empty-state h2 { margin-bottom: var(--s-2); }
.empty-state p { color: var(--muted); max-width: var(--measure); margin-left: auto; margin-right: auto; }
.empty-state > :last-child { margin-bottom: 0; }
.state-error { background: var(--danger-bg); color: var(--danger-text); border: 1px solid var(--danger-border); border-radius: var(--radius); padding: var(--s-4) var(--s-5); margin-bottom: var(--s-5); }
.skeleton { display: block; min-height: 1em; border-radius: var(--radius-sm); background: var(--surface-2); animation: pulse 1.4s var(--ease) infinite; }
[aria-busy="true"] { cursor: progress; }
@keyframes pulse { 50% { opacity: .5; } }

/* auth layout */
.page-center { min-height: 100vh; min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: var(--s-4); }
.auth-page { width: 100%; max-width: 26rem; display: grid; gap: var(--s-4); }
.auth-page.auth-wide { max-width: 32rem; }
.auth-mark {
  display: inline-grid; place-items: center; width: 2.5rem; height: 2.5rem; border-radius: var(--radius);
  background: var(--accent); color: var(--on-accent); font-size: var(--fs-xl); font-weight: 700;
}
.auth-wordmark { margin: 0; font-weight: 700; font-size: var(--fs-md); }
.auth-brand { display: flex; align-items: center; gap: var(--s-3); }
.login-card { width: 100%; }
.auth-card { padding: var(--s-5); box-shadow: var(--shadow); }
.auth-card h1 { margin-bottom: var(--s-2); }
.auth-card .btn-primary { margin-top: var(--s-5); }
.auth-aside { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: var(--s-3); margin: 0; font-size: var(--fs-sm); color: var(--muted); }
.brand-title { margin-bottom: var(--s-1); }
.org-choices { display: grid; gap: var(--s-2); margin-top: var(--s-4); }
.org-choices .inline-form { display: block; }
.org-choice { width: 100%; justify-content: flex-start; text-align: left; min-height: var(--hit); height: auto; padding-top: var(--s-2); padding-bottom: var(--s-2); overflow-wrap: anywhere; white-space: normal; }
.org-choice-name { display: block; min-width: 0; overflow-wrap: anywhere; white-space: normal; text-align: left; }

/* ---- feature blocks used by page templates ---- */
.review-compare-status { display: inline-block; font-size: var(--fs-xs); font-weight: 700; }
.review-adjudication { border: 1px solid var(--notice-border); border-radius: var(--radius); padding: var(--s-4); }
.review-verification-note { font-size: var(--fs-sm); color: var(--muted); }
.review-locked { opacity: .94; }
.review-summary { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s-4); margin: var(--s-5) 0; }
.review-filters { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; gap: var(--s-3); align-items: end; }
.review-filters label { margin-top: 0; }
.review-filters.review-filters-pair { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.score-metric-active { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.review-save-draft { margin: var(--s-4) 0; }
.form-panel .field-error + .btn-inline { margin-top: var(--s-4); }
.review-filters button { margin-bottom: 0; }
.review-export-links { margin: var(--s-4) 0; }
.review-comparison { margin: var(--s-5) 0; }
.review-criterion-number { font-weight: 700; font-size: var(--fs-sm); color: var(--muted); margin-bottom: var(--s-3); }
.review-two-col { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-5); }
.review-col { min-width: 0; }
.review-col + .review-col { border-left: 1px solid var(--border); padding-left: var(--s-5); }
.review-excerpt, .evidence-citation blockquote, .rubric-readonly blockquote {
  background: var(--notice-bg); color: var(--text); border: 1px solid var(--notice-border); border-radius: var(--radius-sm);
  padding: var(--s-3) var(--s-4); margin: var(--s-3) 0; white-space: pre-wrap; overflow-wrap: anywhere;
}
.score-metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s-4); margin: var(--s-5) 0; }
.score-metric { padding: var(--s-4); display: flex; flex-direction: column; gap: var(--s-2); min-width: 0; }
.score-metric strong { font-size: var(--fs-xl); line-height: 1.1; overflow-wrap: anywhere; }
.score-metric small { color: var(--muted); font-size: var(--fs-xs); }
.evidence-citation { margin: var(--s-4) 0; border-top: 1px solid var(--border); padding-top: var(--s-3); }
.evidence-citation blockquote { font-size: var(--fs-sm); }
.evidence-citation p { display: flex; flex-wrap: wrap; gap: var(--s-3); }
.evidence-citation a { font-size: var(--fs-sm); }
.sanitized-preview { overflow-wrap: anywhere; }
.rubric-criterion { padding: var(--s-4); margin: var(--s-4) 0; }
.rubric-criterion-heading { display: flex; align-items: center; justify-content: space-between; gap: var(--s-4); }
.rubric-criterion-heading h3 { margin: var(--s-1) 0 var(--s-2); }
.rubric-fields { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s-1) var(--s-4); }
.rubric-fields label { font-size: var(--fs-sm); margin-top: var(--s-2); display: block; }
.rubric-fields input, .rubric-fields textarea, .rubric-fields select { margin-top: var(--s-1); }
.rubric-wide { grid-column: 1 / -1; }
.rubric-anchors { border-top: 1px solid var(--border); padding-top: var(--s-3); }
.rubric-anchors h4 { margin: var(--s-1) 0 var(--s-2); }
.rubric-actions { display: flex; justify-content: space-between; align-items: center; gap: var(--s-4); flex-wrap: wrap; margin: var(--s-4) 0; }
.rubric-readonly details { padding: var(--s-2) 0; }
.rubric-readonly dl { display: grid; grid-template-columns: 5.5rem minmax(0, 1fr); gap: var(--s-2); }
.rubric-readonly dt { color: var(--muted); font-weight: 600; }
.rubric-readonly dd { margin: 0; }
.rubric-confirm { display: flex; gap: var(--s-3); align-items: flex-start; font-weight: 500; margin-bottom: var(--s-4); }
.rubric-confirm input { margin-top: .2rem; flex: none; }
.rubric-abandon-form, .rubric-manual-form { margin-top: var(--s-5); }
.rubric-approval-form { margin-top: var(--s-5); }
.doc-upload-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-4); }
.drop-zone { border-style: dashed; display: grid; align-content: start; gap: var(--s-2); }
.drop-zone.drag-over { border-color: var(--accent); background: var(--notice-bg); }
.drop-zone h2 { margin-bottom: var(--s-1); }
.drop-zone button { justify-self: start; }
.upload-progress { grid-column: 1 / -1; }
.upload-item { padding: var(--s-3) 0; display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(5.5rem, 1fr) minmax(0, 1fr); align-items: center; gap: var(--s-4); border-bottom: 1px solid var(--border); }
.upload-item span { overflow-wrap: anywhere; font-size: var(--fs-sm); }
.upload-item progress { width: 100%; accent-color: var(--accent); }
.document-row { display: flex; justify-content: space-between; padding: var(--s-4) var(--s-5); align-items: center; gap: var(--s-5); flex-wrap: wrap; }
.document-actions { display: flex; align-items: center; gap: var(--s-2) var(--s-4); margin-bottom: var(--s-4); flex-wrap: wrap; font-size: var(--fs-sm); }
.filename { overflow-wrap: anywhere; max-width: 20rem; }
.compact-upload { display: inline-flex; align-items: center; gap: var(--s-2); border: 1px solid var(--field-border); border-radius: var(--radius-sm); padding: var(--s-1) var(--s-2); font-size: var(--fs-sm); font-weight: 500; margin: 0; cursor: pointer; background: var(--surface); }
.compact-upload input { width: 8.75rem; border: 0; padding: 0; background: transparent; font-size: var(--fs-xs); }
.table-scroll:not(.table-scroll-wide) td > strong:only-child { white-space: nowrap; }
.document-text { white-space: pre-wrap; overflow-wrap: anywhere; font: var(--fs-sm)/1.55 var(--mono); margin: 0; }
.pagination { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s-2) var(--s-4); margin-bottom: var(--s-4); }
.page-size-form { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); margin: 0; }
@media (max-width: 50rem) { .page-size-form { flex-basis: 100%; } }
/* position_detail: nine-step stepper wraps into a responsive grid */
.stepper.stepper-wide { grid-auto-flow: row; grid-auto-columns: auto; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); }
.stepper-wide .step-title { overflow-wrap: break-word; }
/* documents: filename column keeps a readable floor inside tables */
.table-scroll td .filename { display: inline-block; min-width: 12rem; }
/* review candidate table: nine readable columns scroll horizontally inside the region; no vertical scroller, so the head is not sticky */
.table-scroll-wide { max-height: none; overflow-x: auto; overflow-y: visible; scrollbar-width: auto; scrollbar-color: var(--border-strong) var(--surface-2); padding-bottom: var(--s-1); }
.table-scroll-wide > table { width: max-content; min-width: 100%; }
.table-scroll-wide thead { position: static; }
.table-review th, .table-review td { min-width: 7rem; }
.table-review th:first-child, .table-review td:first-child { min-width: 10rem; max-width: 14rem; overflow-wrap: anywhere; }
.table-review th:nth-child(7), .table-review td:nth-child(7) { min-width: 10rem; }
.table-review th:nth-child(8), .table-review td:nth-child(8) { min-width: 11rem; }
.table-review th:last-child, .table-review td:last-child { min-width: 11rem; }
.table-review tbody th[scope="row"] { text-align: left; font-weight: inherit; background: inherit; color: inherit; }
.table-review td:first-child strong, .table-review th[scope="row"] strong { overflow-wrap: anywhere; }
.scroll-hint { margin: 0 0 var(--s-2); font-size: var(--fs-sm); }
.table-scroll .compact-form input:not([type="hidden"]) { min-width: 11rem; max-width: none; text-overflow: clip; }

/* responsive */
@media (max-width: 64rem) {
  .stats-grid, .review-summary, .score-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stepper { grid-auto-flow: row; grid-auto-columns: auto; }
}
@media (max-width: 50rem) {
  .form-grid, .settings-list, .rubric-fields, .rubric-readonly dl { grid-template-columns: minmax(0, 1fr); }
  .review-filters, .review-filters.review-filters-pair, .review-two-col, .doc-upload-grid { grid-template-columns: minmax(0, 1fr); }
  .review-col + .review-col { border-left: 0; border-top: 1px solid var(--border); padding-left: 0; padding-top: var(--s-4); }
  .upload-item { grid-template-columns: minmax(0, 1fr); gap: var(--s-1); }
  .page-actions { width: 100%; }
}
@media (max-width: 30rem) {
  .stepper.stepper-wide { grid-template-columns: minmax(0, 1fr); }
  .container { padding: var(--s-4) var(--s-3) var(--s-6); }
  .card { padding: var(--s-4); }
  .auth-card { padding: var(--s-4); }
  .stats-grid, .review-summary, .score-metrics { grid-template-columns: minmax(0, 1fr); gap: var(--s-2); }
  .stat { padding: var(--s-3) var(--s-4); }
  .form-panel { padding: var(--s-4); }
  .panel-heading, .document-row { padding-left: var(--s-4); padding-right: var(--s-4); }
  .form-panel > .panel-heading { padding-left: 0; padding-right: 0; }
  .panel:not(.form-panel) > p, .panel:not(.form-panel) > .muted { padding-left: var(--s-4); padding-right: var(--s-4); }
  td, th { padding: var(--s-2) var(--s-3); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* spacing after blocks that end a group: preformatted payloads and forms */
pre + p, form + p { margin-top: var(--s-4); }
.form-panel form > .btn-inline:not(:first-child) { margin-top: var(--s-4); }

.review-errors h2 { font-size: var(--fs-md, 1rem); margin-top: 0; }
.review-errors:focus { outline: 2px solid #1f4fd8; outline-offset: 2px; }
.review-anchor-nav { display: flex; flex-wrap: wrap; gap: var(--s-2); list-style: none; padding: 0; margin: var(--s-3) 0 0; }
.review-anchor-nav a { display: inline-block; min-width: 2rem; text-align: center; padding: 2px 8px; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.review-progress ul { margin: var(--s-2) 0; }
[aria-invalid="true"] { border-color: var(--danger-border); }

/* P0-02 administrator reconciliation */
/* P0-02: panels holding lists/nav/headings (not only <p>) need their own padding */
.review-progress, .adj-summary, nav.panel { padding: var(--s-4) var(--s-5); }
.review-progress > p, .adj-summary > p, .adj-summary > .muted, nav.panel > p { padding-left: 0 !important; padding-right: 0 !important; }
.review-progress > p:first-child, .adj-summary > p:first-child { padding-top: 0 !important; }
@media (max-width: 640px) { .review-progress, .adj-summary, nav.panel { padding: var(--s-3) var(--s-4); } }
.adj-counts { display: flex; flex-wrap: wrap; gap: var(--s-5); list-style: none; padding: 0; margin: 0 0 var(--s-3); }
.adj-counts strong { font-size: 1.4em; margin-right: var(--s-2); }
.adj-nav { display: flex; flex-wrap: wrap; gap: var(--s-3) var(--s-5); list-style: none; padding: 0; }
.adj-subhead { font-size: 1em; margin-top: var(--s-4); }
.field-error { color: var(--danger-text); font-size: var(--fs-sm); margin-top: var(--s-1); }

/* human review status pill: long status text wraps instead of truncating, keeps its own casing */
.pill.status-pill { white-space: normal; max-width: 100%; text-transform: none; }

/* Private JD redaction editor: coordinates are not part of selectable content. */
#jd-redaction-editor [hidden], #jd-approval[hidden], #jd-generation[hidden] { display: none !important; }
.jd-preview { display: grid; gap: 0; white-space: normal; font-family: inherit; }
.jd-line { margin: 0; padding: 0; line-height: 1.4; }
.jd-preview:not(.jd-show-page-numbers) .jd-page-footer { display: none; }
.jd-coordinate { font-weight: 600; color: var(--muted); user-select: none; }
.jd-content { white-space: pre-wrap; overflow-wrap: anywhere; }
.jd-mask {
  display: inline; padding: 0 5px; margin: 0 1px;
  border: 1px solid #a16207; border-radius: 4px;
  background: #fef08a; color: #713f12; font: inherit; font-weight: 600;
  cursor: pointer; white-space: pre-wrap; overflow-wrap: anywhere; user-select: none;
}
.jd-mask[aria-pressed="true"] { background: #fde68a; color: #713f12; border-style: dashed; }
.jd-mask:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
#jd-redact-selection { position: fixed; z-index: 100; box-shadow: 0 3px 12px #0004; background: var(--surface); }
#jd-preview[aria-busy="true"] { cursor: progress; }

