/* Base styles and the shared component library. Every colour comes from tokens.css.
   Desktop-first at 1440; responsive.css (loaded after every page stylesheet) adapts each screen down to a
   375 px phone without horizontal page scroll. */

/* ── Document ─────────────────────────────────────────────────────────────── */
html { background: var(--bg-page); }
body {
  font-family: var(--font-body);
  font-size: var(--fs-body);
  line-height: var(--lh-base);
  color: var(--text-primary);
  background: var(--bg-page);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: var(--link); text-underline-offset: 3px; }
a:hover { color: var(--link-hover); }
::placeholder { color: var(--text-placeholder); opacity: 1; }
:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
strong, b { font-weight: var(--fw-semibold); }

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: var(--sp-4); top: -60px; z-index: 100;
  padding: var(--sp-2_5) var(--sp-4); border-radius: var(--radius-md);
  background: var(--gold-500); color: var(--navy-900); font-weight: var(--fw-semibold); text-decoration: none;
}
.skip-link:focus { top: var(--sp-4); }

/* ── Type helpers ─────────────────────────────────────────────────────────── */
.display { font-family: var(--font-display); font-weight: var(--fw-regular); line-height: var(--lh-tight); letter-spacing: var(--ls-display); }
.eyebrow {
  font-size: var(--fs-micro); font-weight: var(--fw-semibold); letter-spacing: var(--ls-eyebrow);
  text-transform: uppercase; color: var(--text-secondary);
}
.eyebrow--gold { color: var(--gold-500); letter-spacing: var(--ls-eyebrow-xl); }
.text-secondary { color: var(--text-secondary); }
.text-tertiary { color: var(--text-tertiary); }
.text-muted { color: var(--text-muted); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.text-sm { font-size: var(--fs-ui); }
.text-caption { font-size: var(--fs-caption); }
.nowrap { white-space: nowrap; }
.link { color: var(--link); font-size: var(--fs-ui); font-weight: var(--fw-medium); text-decoration: underline; text-underline-offset: 3px; }
.link:hover { color: var(--link-hover); }

/* ── Top bar ──────────────────────────────────────────────────────────────── */
.topbar {
  height: var(--header-h); padding: 0 var(--gutter); flex-shrink: 0;
  display: flex; align-items: center; justify-content: space-between;
  background: var(--bg-brand); color: var(--text-inverse);
}
.topbar__left { display: flex; align-items: center; gap: var(--sp-12); height: var(--header-h); flex-shrink: 0; }
.topbar__brand { display: flex; align-items: center; }
.topbar__logo { height: 24px; width: auto; }
/* The nav + CTA + account menu share one panel so the phone menu (responsive.css) reuses the same links. */
.topbar__panel { flex: 1 1 auto; min-width: 0; margin-left: var(--sp-12); height: var(--header-h); display: flex; align-items: center; justify-content: space-between; gap: var(--sp-6); }
.topbar__menu-button, .topbar__account, .topbar__cta-short { display: none; }
.topbar__nav { display: flex; align-items: stretch; gap: var(--sp-2); height: var(--header-h); }
.topbar__tab {
  display: flex; align-items: center; padding: 0 var(--sp-3_5);
  border-bottom: 2px solid var(--navy-900);
  font-size: var(--fs-body); font-weight: var(--fw-medium); color: var(--text-on-brand-muted); text-decoration: none;
}
.topbar__tab:hover { color: var(--gold-500); }
.topbar__tab[aria-current="page"] { border-bottom-color: var(--gold-500); font-weight: var(--fw-semibold); color: var(--gold-500); }
/* Deletion requests waiting on the admin's Admin tab (hidden at zero). */
.topbar__count {
  display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px; margin-left: var(--sp-2); padding: 0 var(--sp-1_5);
  border-radius: var(--radius-sm); background: var(--gold-500); color: var(--navy-900);
  font-size: var(--fs-micro); font-weight: var(--fw-semibold); line-height: 1;
}
/* Recruiter suggestions (roles, certifications, places) waiting for review: the outlined twin of the deletion badge. */
.topbar__count--suggestions { margin-left: var(--sp-1); background: transparent; color: var(--gold-500); box-shadow: inset 0 0 0 1px var(--gold-500); }
.topbar__count[hidden] + .topbar__count--suggestions { margin-left: var(--sp-2); }
.topbar__right { display: flex; align-items: center; gap: var(--sp-6); }
.topbar :focus-visible { outline-color: var(--gold-500); }

.user-menu { position: relative; }
.user-menu__summary { display: flex; align-items: center; gap: var(--sp-3); height: var(--h-control-sm); border-radius: var(--radius-md); }
.user-menu__name { font-size: var(--fs-ui); font-weight: var(--fw-semibold); color: var(--text-inverse); line-height: 1.2; }
.user-menu__role { font-size: var(--fs-micro); color: var(--text-on-brand-muted); line-height: 1.2; }
.user-menu__panel {
  position: absolute; right: 0; top: calc(100% + 10px); z-index: 40; min-width: 260px;
  padding: var(--sp-2); border: 1px solid var(--border-control); border-radius: var(--radius-md);
  background: var(--bg-surface); color: var(--text-primary); box-shadow: var(--shadow-popover);
}
.user-menu__email { padding: var(--sp-2_5) var(--sp-3); font-size: var(--fs-caption); color: var(--text-secondary); border-bottom: 1px solid var(--border-hairline); word-break: break-all; }
.user-menu__item {
  display: flex; align-items: center; width: 100%; height: var(--h-control-sm); padding: 0 var(--sp-3);
  border-radius: var(--radius-sm); font-size: var(--fs-ui); font-weight: var(--fw-medium); color: var(--text-primary); text-decoration: none;
}
.user-menu__item:hover { background: var(--bg-muted); }

/* ── Page frame ───────────────────────────────────────────────────────────── */
.main { flex-grow: 1; padding: var(--main-pad-top) var(--gutter) var(--gutter); display: flex; flex-direction: column; gap: var(--sp-9); }
.main--record { padding-top: var(--main-pad-top-record); gap: var(--sp-5); }
.main--admin { gap: var(--sp-6); }
.main--profile { gap: var(--sp-6); }
@media (max-width: 1280px) { :root { --gutter: 32px; } }
.page-header { display: flex; justify-content: space-between; align-items: flex-end; gap: var(--sp-6); }
.page-header__text { display: flex; flex-direction: column; gap: var(--sp-2); }
.page-header__title { font-family: var(--font-display); font-weight: var(--fw-regular); font-size: var(--fs-display-lg); line-height: var(--lh-tight); }
.page-header__subtitle { font-size: var(--fs-body); color: var(--text-secondary); }
.page-header__right { display: flex; align-items: center; gap: var(--sp-3); }

.section-head { display: flex; justify-content: space-between; align-items: baseline; gap: var(--sp-4); }
.stack { display: flex; flex-direction: column; gap: var(--sp-4); }
.stack--sm { gap: var(--sp-2_5); }
.stack--lg { gap: var(--sp-5); }
.row { display: flex; align-items: center; gap: var(--sp-3); }
.row--between { justify-content: space-between; }
.row--wrap { flex-wrap: wrap; }
.grow { flex-grow: 1; min-width: 0; }
.hairline { border: 0; border-top: 1px solid var(--border-hairline); }

/* Sub-header (record steps, profile) */
.subheader {
  padding: var(--sp-6) var(--gutter); display: flex; justify-content: space-between; align-items: flex-end; gap: var(--sp-8);
  border-bottom: 1px solid var(--border-card); background: var(--bg-surface); flex-shrink: 0;
}
.subheader__text { display: flex; flex-direction: column; gap: var(--sp-2); min-width: 0; }
.subheader__back { display: inline-flex; align-items: center; gap: var(--sp-2); font-size: var(--fs-ui); font-weight: var(--fw-medium); }
.subheader__titlerow { display: flex; align-items: center; gap: var(--sp-3_5); }
.subheader__title { font-family: var(--font-display); font-weight: var(--fw-regular); font-size: var(--fs-display-sm); line-height: var(--lh-tight); }
.subheader__meta { font-size: var(--fs-ui); color: var(--text-secondary); }
.subheader__right { display: flex; align-items: center; gap: var(--sp-3_5); flex-shrink: 0; }

/* Two-column body (content + aside) */
.layout { display: flex; align-items: flex-start; gap: var(--sp-7); }
.layout__content { flex-grow: 1; min-width: 0; display: flex; flex-direction: column; gap: var(--sp-5); }
.aside { flex-shrink: 0; display: flex; flex-direction: column; gap: var(--sp-5); }
.aside--cv { width: var(--aside-w-cv); }
.aside--interview { width: var(--aside-w-interview); }
.aside--profile { width: var(--aside-w-profile); }
.aside--upload { width: var(--aside-w-upload); }
.aside--filters { width: var(--sidebar-w); }
.aside--sticky { position: sticky; top: calc(var(--header-h) + 20px); }

/* Footer action bar */
.footer-bar {
  position: sticky; bottom: 0; z-index: 20; height: 80px; padding: 0 var(--gutter); flex-shrink: 0;
  display: flex; justify-content: space-between; align-items: center; gap: var(--sp-6);
  border-top: 1px solid var(--border-card); background: var(--bg-surface);
}
.footer-bar__status { font-size: var(--fs-ui); color: var(--text-secondary); display: flex; align-items: center; gap: var(--sp-3); }
.footer-bar__status .is-error { color: var(--danger-text); font-weight: var(--fw-medium); }
.footer-bar__actions { display: flex; align-items: center; gap: var(--sp-3); }

/* Tab strips (routes) */
.tab-strip { display: flex; gap: var(--sp-7); border-bottom: 1px solid var(--border-rule); }
.tab-strip__tab {
  display: flex; align-items: center; gap: var(--sp-2); height: var(--h-control-lg); padding: 0 var(--sp-1);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  font-size: var(--fs-body); font-weight: var(--fw-medium); color: var(--text-secondary); text-decoration: none;
}
.tab-strip__tab:hover { color: var(--text-primary); }
.tab-strip__tab[aria-current="page"], .tab-strip input:checked + .tab-strip__tab { border-bottom-color: var(--navy-900); color: var(--text-primary); font-weight: var(--fw-semibold); }
.tab-strip__count { font-size: var(--fs-caption); color: var(--text-secondary); }
.tab-strip input[type="radio"] { position: absolute; opacity: 0; width: 0; height: 0; }
.tab-strip input:focus-visible + .tab-strip__tab { outline: 2px solid var(--focus-ring); outline-offset: 2px; }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2_5);
  height: var(--h-control-sm); padding: 0 var(--sp-4_5); border: 1px solid transparent; border-radius: var(--radius-md);
  font-family: inherit; font-size: var(--fs-ui); font-weight: var(--fw-semibold); line-height: 1; white-space: nowrap;
  text-decoration: none; cursor: pointer; transition: background-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.btn svg { flex-shrink: 0; }
.btn--primary { background: var(--navy-900); border-color: var(--navy-900); color: var(--gold-500); }
.btn--primary:hover { background: var(--btn-primary-hover); border-color: var(--btn-primary-hover); color: var(--gold-500); }
.btn--secondary { background: var(--bg-surface); border-color: var(--navy-900); color: var(--navy-900); }
.btn--secondary:hover { background: var(--btn-secondary-hover); color: var(--navy-900); }
.btn--outline { background: var(--bg-surface); border-color: var(--border-control); color: var(--navy-900); font-weight: var(--fw-medium); }
.btn--outline:hover { background: var(--btn-secondary-hover); color: var(--navy-900); }
.btn--gold { background: var(--gold-500); border-color: var(--gold-500); color: var(--navy-900); }
.btn--gold:hover { background: var(--gold-400); border-color: var(--gold-400); color: var(--navy-900); }
.btn--danger { background: var(--red-800); border-color: var(--red-800); color: var(--white); }
.btn--danger:hover { background: var(--red-700); border-color: var(--red-700); color: var(--white); }
.btn--danger-outline { background: var(--bg-surface); border-color: var(--red-700); color: var(--red-800); }
.btn--dashed { background: var(--bg-subtle); border: 1px dashed var(--gold-400); color: var(--gold-800); padding: 0 var(--sp-3_5); }
.btn--dashed:hover { background: var(--gold-50); color: var(--gold-800); }
.btn--ghost { background: transparent; border-color: transparent; color: var(--text-tertiary); font-weight: var(--fw-medium); }
.btn--ghost:hover { background: var(--bg-muted); color: var(--text-primary); }
.btn--link { background: transparent; border-color: transparent; color: var(--text-tertiary); font-weight: var(--fw-medium); text-decoration: underline; text-underline-offset: 3px; padding: 0 var(--sp-2); height: auto; }
.btn--link:hover { color: var(--text-primary); }
.btn--icon { width: var(--size-hit); height: var(--size-hit); padding: 0; background: transparent; border-color: transparent; color: var(--text-secondary); }
.btn--icon:hover { background: var(--bg-muted); color: var(--text-primary); }
.btn--icon-sm { width: var(--h-chip-remove); height: var(--h-chip-remove); }
.btn--sm { height: var(--h-control-sm); }
.btn--md { height: var(--h-control); }
.btn--lg { height: var(--h-control-lg); padding: 0 var(--sp-5); }
.btn--auth { width: 100%; height: var(--h-auth-button); letter-spacing: var(--ls-button); text-transform: uppercase; }
.btn--cta { height: var(--h-cta-step1); padding: 0 var(--sp-6); letter-spacing: var(--ls-cta); text-transform: uppercase; }
.btn--block { width: 100%; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: var(--disabled-opacity); cursor: not-allowed; pointer-events: none; }
.btn[aria-busy="true"] { position: relative; color: transparent !important; pointer-events: none; }
.btn[aria-busy="true"]::after {
  content: ""; position: absolute; width: 18px; height: 18px; border-radius: var(--radius-full);
  border: 2px solid currentColor; border-right-color: transparent; color: var(--gold-500); animation: spin 0.8s linear infinite;
}
.btn--secondary[aria-busy="true"]::after, .btn--outline[aria-busy="true"]::after, .btn--gold[aria-busy="true"]::after { color: var(--navy-900); }
@keyframes spin { to { transform: rotate(360deg); } }
.btn-row { display: flex; align-items: center; gap: var(--sp-2_5); }

/* ── Cards ────────────────────────────────────────────────────────────────── */
.card {
  padding: var(--sp-6); display: flex; flex-direction: column; gap: var(--sp-5);
  border: 1px solid var(--border-card); border-radius: var(--radius-lg); background: var(--bg-surface);
}
.card--p20 { padding: var(--sp-5); gap: var(--sp-4); }
.card--p24 { padding: var(--sp-6); }
.card--p28 { padding: var(--sp-7); gap: var(--sp-5_5); }
.card--p32 { padding: var(--sp-8); gap: var(--sp-6); }
.card--emphasised { border-color: var(--border-emphasis); }
.card--dashed { border: 1px dashed var(--gold-400); border-radius: var(--radius-md); background: var(--bg-subtle); }
.card--subtle { background: var(--bg-subtle); }
.card__head { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--sp-4); }
.card__heading { display: flex; flex-direction: column; gap: var(--sp-1); min-width: 0; }
.card__titlerow { display: flex; align-items: center; gap: var(--sp-3); }
.card__title { font-family: var(--font-display); font-weight: var(--fw-regular); line-height: var(--lh-heading); font-size: var(--fs-h2); }
.card__title--xl { font-size: var(--fs-h2-xl); line-height: var(--lh-tight); }
.card__title--lg { font-size: var(--fs-h2-lg); }
.card__title--md { font-size: var(--fs-h2); }
.card__title--sm { font-size: var(--fs-h2-sm); }
.card__title--xs { font-size: var(--fs-h2-xs); }
.card__subtitle { font-size: var(--fs-body); line-height: var(--lh-base); color: var(--text-secondary); }
.card__right { flex-shrink: 0; display: flex; align-items: center; gap: var(--sp-3); }
.card__foot { padding-top: var(--sp-4); border-top: 1px solid var(--border-hairline); display: flex; justify-content: space-between; align-items: center; gap: var(--sp-4); font-size: var(--fs-ui); color: var(--text-secondary); }
.row-card { padding: var(--sp-4_5); display: flex; flex-direction: column; gap: var(--sp-3_5); border: 1px solid var(--border-card); border-radius: var(--radius-md); background: var(--bg-row-card); }

/* ── Badges, chips, avatars ───────────────────────────────────────────────── */
.badge {
  display: inline-block; padding: 5px 10px; border-radius: var(--radius-sm);
  font-size: var(--fs-caption); font-weight: var(--fw-semibold); line-height: 1.2; white-space: nowrap;
  background: var(--badge-neutral-bg); color: var(--badge-neutral-fg);
}
.badge--sm { padding: 4px 10px; }
.badge--micro { padding: 2px 7px; font-size: var(--fs-badge); text-transform: uppercase; letter-spacing: var(--ls-badge); }
.badge--in_pool { background: var(--badge-in-pool-bg); color: var(--badge-in-pool-fg); }
.badge--shortlisted { background: var(--badge-shortlisted-bg); color: var(--badge-shortlisted-fg); }
.badge--submitted { background: var(--badge-submitted-bg); color: var(--badge-submitted-fg); }
.badge--interview { background: var(--badge-interview-bg); color: var(--badge-interview-fg); box-shadow: inset 0 0 0 1px var(--badge-interview-ring); }
.badge--offer { background: var(--badge-offer-bg); color: var(--badge-offer-fg); }
.badge--placed { background: var(--badge-placed-bg); color: var(--badge-placed-fg); }
.badge--on_hold { background: var(--badge-on-hold-bg); color: var(--badge-on-hold-fg); box-shadow: inset 0 0 0 1px var(--badge-on-hold-ring); }
.badge--rejected { background: var(--badge-rejected-bg); color: var(--badge-rejected-fg); }
.badge--neutral { background: var(--badge-neutral-bg); color: var(--badge-neutral-fg); }
.badge--gold { background: var(--badge-gold-bg); color: var(--badge-gold-fg); }
.badge--success { background: var(--badge-success-bg); color: var(--badge-success-fg); }
.badge--danger { background: var(--badge-danger-bg); color: var(--badge-danger-fg); }
.badge--outline { background: var(--badge-outline-bg); color: var(--badge-outline-fg); box-shadow: inset 0 0 0 1px var(--badge-outline-ring); padding: 4px 10px; }
.badge--count { padding: 4px 10px; }
.badge--most { font-size: var(--fs-micro); }
.provenance { display: inline-block; padding: 2px 7px; border-radius: var(--radius-sm); font-size: var(--fs-badge); font-weight: var(--fw-semibold); letter-spacing: var(--ls-badge); text-transform: uppercase; white-space: nowrap; background: var(--badge-neutral-bg); color: var(--badge-neutral-fg); }
.provenance--parsed { background: var(--badge-gold-bg); color: var(--badge-gold-fg); }
.provenance--edited { background: var(--badge-success-bg); color: var(--badge-success-fg); }
.provenance--needs_selection { background: var(--badge-danger-bg); color: var(--badge-danger-fg); }   /* the CV had text, no list option matched: pick one */
.provenance--not_found { background: var(--badge-outline-bg); color: var(--badge-outline-fg); box-shadow: inset 0 0 0 1px var(--badge-outline-ring); }   /* nothing parsed: pick a value or confirm Not in CV */
.provenance-legend { display: flex; align-items: center; gap: var(--sp-3_5); flex-wrap: wrap; font-size: var(--fs-caption); color: var(--text-secondary); }
.provenance-legend__item { display: inline-flex; align-items: center; gap: var(--sp-2); }

.chip {
  display: inline-flex; align-items: center; gap: 2px; height: var(--h-chip); padding: 0 2px 0 12px;
  border-radius: var(--radius-sm); background: var(--bg-muted); font-size: var(--fs-ui); font-weight: var(--fw-medium); white-space: nowrap;
}
.chip--compact { height: var(--h-chip-compact); padding-right: 12px; }
.chip--pending { background: var(--gold-100); color: var(--gold-800); }
.chip__tag { margin-left: 6px; font-size: var(--fs-micro); font-weight: var(--fw-semibold); letter-spacing: var(--ls-cta); text-transform: uppercase; }
/* "Pending review" by a field whose entry was added from a record and waits for the admin (macros/record.html pending_tag). */
.field__pending { display: inline-flex; align-items: center; height: 20px; margin-left: var(--sp-2); padding: 0 8px; border-radius: var(--radius-sm); background: var(--gold-100); color: var(--gold-800); font-size: var(--fs-micro); font-weight: var(--fw-semibold); letter-spacing: var(--ls-cta); text-transform: uppercase; white-space: nowrap; }
.field > .field__pending, .language-row__note .field__pending { margin: var(--sp-1) 0 0; align-self: flex-start; }
.chip--saving { opacity: .55; }   /* an option's write on its way (request-queue.js): the real chip replaces it when the box re-renders */
.chip__remove { width: var(--h-chip-remove); height: var(--h-chip-remove); display: inline-flex; align-items: center; justify-content: center; border-radius: var(--radius-sm); color: var(--text-secondary); text-decoration: none; }
.chip__remove:hover { color: var(--text-primary); background: var(--cream-600); }
.chip__remove form { display: contents; }
.chip-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); }

.avatar {
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
  border-radius: var(--radius-full); font-weight: var(--fw-semibold); line-height: 1; user-select: none;
  background: var(--avatar-1-bg); color: var(--avatar-1-fg);
}
.avatar--c0 { background: var(--avatar-1-bg); color: var(--avatar-1-fg); }
.avatar--c1 { background: var(--avatar-2-bg); color: var(--avatar-2-fg); }
.avatar--c2 { background: var(--avatar-3-bg); color: var(--avatar-3-fg); }
.avatar--c3 { background: var(--avatar-4-bg); color: var(--avatar-4-fg); }
.avatar--c4 { background: var(--avatar-5-bg); color: var(--avatar-5-fg); }
.avatar--c5 { background: var(--avatar-6-bg); color: var(--avatar-6-fg); }
.avatar--outlined { background: transparent; border: 1px solid var(--gold-500); color: var(--gold-500); letter-spacing: var(--ls-badge); }
.avatar--22 { width: 22px; height: 22px; font-size: 12px; } .avatar--22.avatar--two { font-size: 10px; }
.avatar--24 { width: 24px; height: 24px; font-size: 12px; } .avatar--24.avatar--two { font-size: 10px; }
.avatar--26 { width: 26px; height: 26px; font-size: 11px; } .avatar--26.avatar--two { font-size: 10px; }
.avatar--28 { width: 28px; height: 28px; font-size: 12px; } .avatar--28.avatar--two { font-size: 10px; }
.avatar--32 { width: 32px; height: 32px; font-size: 12px; } .avatar--32.avatar--two { font-size: 11px; }
.avatar--38 { width: 38px; height: 38px; font-size: 13px; }
.avatar--40 { width: 40px; height: 40px; font-size: 14px; }
.avatar--44 { width: 44px; height: 44px; font-size: 16px; }
.identity { display: flex; align-items: center; gap: var(--sp-3); min-width: 0; }
.identity__name { font-size: var(--fs-body-md); font-weight: var(--fw-semibold); line-height: 1.2; }
.identity__sub { font-size: var(--fs-caption); color: var(--text-secondary); line-height: 1.2; }

/* ── Grid tables (real <table>, rows laid out with grid) ──────────────────── */
.grid-table { width: 100%; display: block; --cols: 1fr; --col-gap: 16px; --row-h: var(--h-row-lg); }
.grid-table caption { display: block; }
.grid-table thead, .grid-table tbody, .grid-table tfoot { display: block; }
.grid-table tr { display: grid; grid-template-columns: var(--cols); column-gap: var(--col-gap); align-items: center; }
.grid-table thead tr { height: var(--h-th); border-bottom: 1px solid var(--border-control); }
.grid-table th { display: block; padding: 0; text-align: left; font-size: var(--fs-micro); font-weight: var(--fw-semibold); letter-spacing: var(--ls-th); text-transform: uppercase; color: var(--text-secondary); }
.grid-table--th-sm th { letter-spacing: var(--ls-th-sm); }
.grid-table tbody tr { min-height: var(--row-h); border-bottom: 1px solid var(--border-hairline); font-size: var(--fs-body); }
.grid-table td { display: block; padding: 0; min-width: 0; }
.grid-table td.is-end, .grid-table th.is-end { text-align: right; justify-self: end; }
.grid-table--gap14 { --col-gap: 14px; }
.grid-table--gap12 { --col-gap: 12px; }
.grid-table--row52 { --row-h: var(--h-row-sm); }
.grid-table--row58 { --row-h: var(--h-row-md); }
.grid-table--row64 { --row-h: var(--h-row); }
.grid-table--row68 { --row-h: var(--h-row-lg); }
.grid-table tbody tr.is-dup { min-height: var(--h-row-dup); }
.grid-table tfoot tr { display: flex; justify-content: space-between; align-items: center; padding-top: var(--sp-4); font-size: var(--fs-ui); color: var(--text-secondary); }
.grid-table tfoot td { display: block; }
.grid-table .cell-main { font-weight: var(--fw-semibold); }
.grid-table .cell-main a { color: var(--text-primary); text-decoration: none; }
.grid-table .cell-main a:hover { text-decoration: underline; }
.grid-table .cell-sub { font-size: var(--fs-caption); color: var(--text-secondary); margin-top: 2px; }
.grid-table .cell-warn { font-size: var(--fs-caption); color: var(--danger); margin-top: 2px; }
/* "Source missing" under a candidate's name: the badge opens the Source dialog. */
.source-missing:empty { display: none; }
.source-missing__btn { display: inline-flex; flex-wrap: wrap; align-items: center; column-gap: var(--sp-1_5); row-gap: 2px; padding: 0; border: 0; background: none; font: inherit; text-align: left; color: var(--link); cursor: pointer; }
.source-missing__action { font-weight: var(--fw-medium); white-space: nowrap; text-decoration: underline; text-underline-offset: 3px; }
.source-missing__btn:hover .source-missing__action { color: var(--link-hover); }
.grid-table .cell-actions { display: flex; justify-content: flex-end; align-items: center; gap: var(--sp-2); }
.grid-table .is-zero { color: var(--text-muted); }
.table-footer { display: flex; justify-content: space-between; align-items: center; gap: var(--sp-4); padding-top: var(--sp-4); font-size: var(--fs-ui); color: var(--text-secondary); }
.table-toolbar { display: flex; justify-content: space-between; align-items: center; gap: var(--sp-4); }
.skeleton { display: block; height: 14px; border-radius: var(--radius-xs); background: linear-gradient(90deg, var(--cream-500) 0%, var(--cream-300) 50%, var(--cream-500) 100%); background-size: 200% 100%; animation: shimmer 1.2s linear infinite; }
.is-loading .skeleton, .grid-table.is-loading tbody { opacity: 0.7; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* Key-value list, stat tiles, rating dots, progress */
.kv { display: flex; flex-direction: column; }
.kv__row { display: grid; grid-template-columns: var(--kv-label-w, 150px) 1fr; column-gap: var(--sp-3); padding: 9px 0; border-bottom: 1px solid var(--border-hairline); font-size: var(--fs-body-sm); }
.kv__label { color: var(--text-secondary); }
.kv__value { min-width: 0; }
.kv__value--danger { color: var(--danger-text); }
.stat-tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--sp-3); padding-top: var(--sp-4); border-top: 1px solid var(--border-hairline); }
.stat-tile { display: flex; flex-direction: column; gap: var(--sp-1); }
.stat-tile__value { font-size: 20px; font-weight: var(--fw-semibold); line-height: 1.2; }
.stat-tile__caption { font-size: var(--fs-micro); letter-spacing: var(--ls-stat); text-transform: uppercase; color: var(--text-secondary); }
.rating { display: inline-flex; align-items: center; gap: var(--sp-1); }
.rating__dot { width: var(--size-rating-dot); height: var(--size-rating-dot); border-radius: var(--radius-full); background: var(--cream-700); }
.rating__dot--on { background: var(--navy-900); }
.progress { width: 100%; height: 6px; border-radius: var(--radius-sm); background: var(--cream-500); overflow: hidden; }
.progress--4 { height: 4px; border-radius: var(--radius-xs); }
.progress__bar { height: 100%; border-radius: inherit; background: var(--navy-900); transition: width var(--dur-base) var(--ease); }

/* Steppers */
.stepper { display: flex; align-items: center; gap: var(--sp-3_5); }
.stepper__step { display: flex; align-items: center; gap: var(--sp-2_5); font-size: var(--fs-ui); font-weight: var(--fw-medium); color: var(--text-tertiary); text-decoration: none; }
.stepper__node { width: var(--size-stepper-node); height: var(--size-stepper-node); display: flex; align-items: center; justify-content: center; border-radius: var(--radius-full); border: 1px solid var(--border-control); background: var(--bg-surface); font-size: var(--fs-caption); font-weight: var(--fw-semibold); color: var(--text-tertiary); }
.stepper__step--done .stepper__node { border-color: var(--navy-900); background: var(--navy-900); color: var(--gold-500); }
.stepper__step--done { color: var(--text-primary); }
.stepper__step--current .stepper__node { border: 2px solid var(--gold-700); color: var(--gold-800); }
.stepper__step--current { color: var(--text-primary); font-weight: var(--fw-semibold); }
.stepper__connector { width: 36px; height: 1px; background: var(--border-control); }
.status-stepper { display: flex; align-items: flex-start; }
.status-stepper__step { position: relative; display: flex; flex-direction: column; align-items: center; gap: var(--sp-2); width: 96px; font-size: var(--fs-caption); color: var(--text-tertiary); text-align: center; }
.status-stepper__step::before { content: ""; position: absolute; top: 13px; left: -48px; width: 96px; height: 1px; background: var(--border-control); }
.status-stepper__step:first-child::before { display: none; }
.status-stepper__step--reached::before, .status-stepper__step--current::before { background: var(--navy-900); }
.status-stepper__node { position: relative; width: var(--size-status-node); height: var(--size-status-node); display: flex; align-items: center; justify-content: center; border-radius: var(--radius-full); border: 1px solid var(--border-control); background: var(--bg-surface); }
.status-stepper__step--reached .status-stepper__node { border-color: var(--navy-900); background: var(--navy-900); color: var(--gold-500); }
.status-stepper__step--reached { color: var(--text-primary); }
.status-stepper__step--current .status-stepper__node { border: 7px solid var(--gold-500); background: var(--navy-900); }
.status-stepper__step--current { color: var(--text-primary); font-weight: var(--fw-semibold); }
.status-stepper__step--override .status-stepper__node { border-color: var(--red-600); }

/* Requirement checklist */
.checklist { display: flex; flex-direction: column; gap: var(--sp-4); }
.checklist__head { display: flex; flex-direction: column; gap: var(--sp-1); }
.checklist__title { font-family: var(--font-display); font-weight: var(--fw-regular); font-size: var(--fs-h2-xs); }
.checklist__count { font-size: var(--fs-ui); color: var(--text-secondary); }
.checklist__items { display: flex; flex-direction: column; gap: var(--sp-2); }
.checklist__item { display: flex; align-items: center; gap: var(--sp-2_5); font-size: var(--fs-ui); color: var(--text-tertiary); text-decoration: none; min-height: 24px; }
.checklist__item .icon { color: var(--success); }
.checklist__ring { width: 18px; height: 18px; flex-shrink: 0; border: 2px solid var(--red-600); border-radius: var(--radius-full); }
.checklist__item--missing { color: var(--red-800); font-weight: var(--fw-semibold); }
.checklist__foot { padding-top: var(--sp-3_5); border-top: 1px solid var(--border-hairline); font-size: var(--fs-caption); line-height: var(--lh-snug); color: var(--text-secondary); }

/* Empty state */
.empty { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--sp-1_5); padding: var(--sp-10) var(--sp-6); text-align: center; color: var(--text-secondary); }
.empty__icon { color: var(--gold-700); margin-bottom: var(--sp-2); }
.empty__title { font-size: var(--fs-body); font-weight: var(--fw-semibold); color: var(--text-primary); }
.empty__desc { font-size: var(--fs-ui); }
.empty__action { margin-top: var(--sp-3); }

/* ── Forms ────────────────────────────────────────────────────────────────── */
.form-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--sp-4_5) var(--sp-5); align-items: start; }
.form-grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid--1 { grid-template-columns: minmax(0, 1fr); }
.field { display: flex; flex-direction: column; gap: var(--sp-1_5); min-width: 0; }
.field--span2 { grid-column: span 2; }
.field--span3 { grid-column: span 3; }
.field__labelrow { display: flex; justify-content: space-between; align-items: center; gap: var(--sp-2); min-height: 20px; }
.field__label { font-size: var(--fs-ui-sm); font-weight: var(--fw-semibold); }
.field__label--auth { font-size: var(--fs-ui); }
.field__required { color: var(--danger); }
.field__help { font-size: var(--fs-caption); line-height: var(--lh-snug); color: var(--text-secondary); }
.field__error { font-size: var(--fs-caption); line-height: var(--lh-snug); font-weight: var(--fw-medium); color: var(--danger); }
/* Always-present message slots (the record's fields, also in the Source dialog) take no space while empty. */
.field__error:empty { display: none; }
.field__badge { display: inline-flex; align-items: center; }
.field--fieldset > .field__labelrow { display: flex; }
.field__legend { display: contents; }

.input, .select, .textarea {
  width: 100%; height: var(--h-control); padding: 0 var(--sp-3_5); border: 1px solid var(--border-control); border-radius: var(--radius-md);
  background: var(--bg-surface); font-family: inherit; font-size: var(--fs-body); color: var(--text-primary);
}
.input:hover, .select:hover, .textarea:hover { border-color: var(--navy-700); }
.input--auth { height: var(--h-auth-input); padding: 0 var(--sp-4); font-size: var(--fs-body-md); }
.input--compact, .select--compact { height: var(--h-control-sm); font-size: var(--fs-ui); }
.input--table, .select--table { height: var(--h-control-sm); }
.input--lg, .select--lg { height: var(--h-control-lg); }
.input[aria-invalid="true"], .select[aria-invalid="true"], .textarea[aria-invalid="true"], .is-invalid { border-color: var(--border-error); }
.input:disabled, .select:disabled, .textarea:disabled { background: var(--bg-muted); border-color: var(--border-rule); color: var(--text-tertiary); cursor: not-allowed; }
.input[readonly] { background: var(--bg-muted); border-color: var(--border-rule); color: var(--text-tertiary); }
.select {
  appearance: none; -webkit-appearance: none; padding-right: 40px; cursor: pointer;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%233A4458' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center;
}
.select:invalid, .select.is-placeholder { color: var(--text-placeholder); }
.textarea { height: var(--h-textarea); padding: 11px var(--sp-3_5); line-height: var(--lh-base); resize: vertical; }
.textarea--sm { height: var(--h-textarea-sm); }
.textarea--lg { height: var(--h-textarea-lg); }
.input--search { height: var(--h-control-sm); width: var(--search-w); font-size: var(--fs-ui); }
input[type="search"]::-webkit-search-cancel-button { -webkit-appearance: none; }
.input-wrap { position: relative; }
.input-wrap .input { padding-right: 56px; }
.input-wrap__toggle { position: absolute; top: 50%; right: 4px; transform: translateY(-50%); width: var(--size-hit); height: var(--size-hit); display: flex; align-items: center; justify-content: center; border-radius: var(--radius-md); color: var(--text-secondary); }
.input-wrap__toggle:hover { color: var(--text-primary); }
.input-wrap--auth .input-wrap__toggle { top: 4px; transform: none; }
/* One eye at a time: password-toggle.js flips aria-pressed (an SVG has no .hidden property, so CSS picks the icon). */
.input-wrap__toggle[aria-pressed="false"] .icon--hide, .input-wrap__toggle[aria-pressed="true"] .icon--show { display: none; }

.checkbox { display: flex; align-items: center; gap: var(--sp-3); min-height: var(--size-hit); font-size: var(--fs-body); }
.checkbox--top { align-items: flex-start; min-height: 0; }
.checkbox--top .checkbox__box { margin-top: 3px; }
.checkbox__box { width: var(--size-checkbox); height: var(--size-checkbox); margin: 0; flex-shrink: 0; accent-color: var(--navy-900); }
.checkbox__text { display: flex; flex-direction: column; gap: 2px; }
.checkbox__desc { font-size: var(--fs-caption); line-height: var(--lh-snug); color: var(--text-secondary); }
.checkbox--boxed { padding: var(--sp-4); border: 1px solid var(--border-control); border-radius: var(--radius-md); background: var(--bg-surface); align-items: flex-start; }
.checkbox--boxed.is-invalid { border-color: var(--border-error); }
.checkbox--boxed .checkbox__box { margin-top: 3px; }
.checkbox--inline { min-height: 28px; font-size: var(--fs-ui); }

.read-only { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); width: 100%; height: var(--h-control); padding: 0 var(--sp-3_5); border: 1px solid var(--border-rule); border-radius: var(--radius-md); background: var(--bg-muted); font-size: var(--fs-body); color: var(--text-tertiary); }
.read-only--auth { height: var(--h-auth-input); padding: 0 var(--sp-4); font-size: var(--fs-body-md); }
.read-only__value { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.read-only .icon { flex-shrink: 0; color: var(--text-secondary); }

/* Segmented control (radios inside a shell) */
.segmented { display: inline-flex; padding: 3px; border: 1px solid var(--border-control); border-radius: var(--radius-md); background: var(--bg-surface); position: relative; }
.segmented input[type="radio"] { position: absolute; opacity: 0; width: 0; height: 0; }
.segmented__option { display: inline-flex; align-items: center; justify-content: center; height: var(--h-segment); padding: 0 var(--sp-4_5); border-radius: var(--radius-sm); font-size: var(--fs-ui); font-weight: var(--fw-medium); color: var(--text-tertiary); cursor: pointer; white-space: nowrap; }
.segmented input:checked + .segmented__option { background: var(--navy-900); color: var(--gold-500); font-weight: var(--fw-semibold); }
.segmented input:focus-visible + .segmented__option { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
.segmented input:disabled + .segmented__option { opacity: var(--disabled-opacity); cursor: not-allowed; }
.segmented--form { display: flex; width: 100%; padding: 2px; height: var(--h-control); }
.segmented--form .segmented__option { flex-grow: 1; height: var(--h-segment-inner); padding: 0 var(--sp-3_5); color: var(--text-primary); }
.segmented--compact { display: flex; padding: 0; border: 0; background: transparent; gap: var(--sp-2); }
.segmented--compact .segmented__option { height: var(--h-segment-inner); padding: 0 var(--sp-3_5); border: 1px solid var(--border-control); border-radius: var(--radius-md); color: var(--text-primary); }
.segmented--compact input:checked + .segmented__option { border-color: var(--navy-900); }

/* Pill groups (checkbox / radio pills) */
.pills { display: flex; flex-wrap: wrap; gap: var(--sp-2); position: relative; }
.pills input[type="checkbox"], .pills input[type="radio"] { position: absolute; opacity: 0; width: 0; height: 0; }
.pill { display: inline-flex; align-items: center; gap: var(--sp-2); height: var(--h-control-sm); padding: 0 var(--sp-4); border: 1px solid var(--border-control); border-radius: var(--radius-md); background: var(--bg-surface); color: var(--text-primary); font-size: var(--fs-ui); font-weight: var(--fw-medium); white-space: nowrap; cursor: pointer; }
.pill:hover { background: var(--btn-secondary-hover); }
.pills input:checked + .pill { border-color: var(--navy-900); background: var(--navy-900); color: var(--gold-500); font-weight: var(--fw-semibold); }
.pills--negative input:checked + .pill { border-color: var(--red-800); background: var(--red-800); color: var(--white); }
.pills input:focus-visible + .pill { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
.pills input:disabled + .pill { opacity: var(--disabled-opacity); cursor: not-allowed; }
.pill__count { font-weight: var(--fw-regular); opacity: 0.85; }
.pills--compact .pill { padding: 0 var(--sp-3_5); }

/* Money input */
/* The amount takes what the currency and period selects leave: each select is as wide as its longest option, so
   "per month" reads whole at 1280 px too (F10: fractions of the field clipped it to "per montl"). */
.money { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: var(--sp-2_5); }
.money__extra { min-height: 28px; display: flex; align-items: center; }

/* Chip input box */
.chip-box { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-1_5); min-height: var(--h-control); padding: 5px 6px; border: 1px solid var(--border-control); border-radius: var(--radius-md); background: var(--bg-surface); }
.chip-box:focus-within { border: 2px solid var(--navy-900); padding: 4px 5px; }
.chip-box__input { flex-grow: 1; min-width: 180px; height: var(--h-chip); padding: 0 var(--sp-2); border: 0; background: transparent; font-family: inherit; font-size: var(--fs-body); color: var(--text-primary); }
.chip-box__input:focus { outline: none; }
.chip-box form { display: contents; }

/* Combobox listbox (server-rendered options) */
.combobox { position: relative; }
.listbox { position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 30; max-height: 360px; overflow-y: auto; border: 1px solid var(--border-control); border-radius: var(--radius-md); background: var(--bg-surface); box-shadow: var(--shadow-popover); }
.listbox__group { display: flex; justify-content: space-between; align-items: center; height: 40px; padding: 0 var(--sp-4); background: var(--bg-page); font-size: var(--fs-micro); font-weight: var(--fw-semibold); letter-spacing: var(--ls-cta); text-transform: uppercase; color: var(--text-secondary); }
.listbox__option { display: flex; align-items: center; width: 100%; height: var(--h-control-sm); padding: 0 var(--sp-3_5) 0 28px; font-size: var(--fs-body); color: var(--text-primary); text-align: left; }
.listbox__option:hover, .listbox__option[aria-selected="true"], .listbox__option.is-active { background: var(--gold-100); font-weight: var(--fw-semibold); }
.listbox__empty { padding: var(--sp-3_5); font-size: var(--fs-ui); color: var(--text-secondary); }
.listbox.is-stale { opacity: .6; }   /* answers an earlier text: the search for what is typed now is on its way (combobox.js) */
.listbox__option--muted { color: var(--text-secondary); border-bottom: 1px solid var(--border-hairline); }   /* "Not in CV" above the list options */
/* "Add “X”" (list_additions): a name the list lacks, added for everyone at once; the admin reviews it later. */
.listbox__option--add { flex-direction: column; align-items: flex-start; justify-content: center; gap: 2px; height: auto; min-height: var(--h-control-sm); padding-top: var(--sp-2); padding-bottom: var(--sp-2); color: var(--gold-800); font-weight: var(--fw-semibold); border-bottom: 1px solid var(--border-hairline); }
.listbox__option--add > span:first-child { white-space: normal; overflow-wrap: anywhere; }
.listbox__option--add .listbox__hint { margin-left: 0; max-width: 100%; font-weight: var(--fw-regular); white-space: normal; }
/* The suggest footer stays in view at the bottom of the scrolling list; combobox.js caps the list's height to the room
   below its box (or flips it above, .listbox--up) so that bottom is on screen, and scrolls the highlighted option clear
   of the footer, which otherwise covers an option scrolled up to the bottom edge. */
.listbox__footer { position: sticky; bottom: 0; padding: var(--sp-3) var(--sp-3_5); border-top: 1px solid var(--border-hairline); background: var(--bg-surface); font-size: var(--fs-ui); color: var(--text-secondary); }
.listbox__footer .link { font-weight: var(--fw-semibold); }
.listbox__footer--empty { border-top: 0; color: var(--text-primary); }
.listbox--up { top: auto; bottom: calc(100% + 4px); }

/* ── Dialogs ──────────────────────────────────────────────────────────────── */
.dialog { width: var(--dialog-w); max-width: calc(100vw - 48px); max-height: calc(100vh - 80px); padding: var(--sp-8); border-radius: var(--radius-md); background: var(--bg-surface); color: var(--text-primary); box-shadow: var(--shadow-dialog); display: none; flex-direction: column; gap: var(--sp-6); overflow: auto; }
.dialog[open] { display: flex; }
.dialog::backdrop { background: var(--scrim); }
.dialog--620 { width: var(--dialog-w-role); }
.dialog--520 { width: 520px; }
.dialog--960 { width: 960px; }   /* wide tables: the countries dialog with its aliases column */
.dialog__head { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--sp-4); }
.dialog__heading { display: flex; flex-direction: column; gap: var(--sp-1_5); }
.dialog__title { font-family: var(--font-display); font-weight: var(--fw-regular); font-size: var(--fs-display-xs); line-height: var(--lh-tight); }
.dialog__desc { font-size: var(--fs-body); line-height: var(--lh-base); color: var(--text-secondary); }
.dialog__close { width: var(--size-hit); height: var(--size-hit); flex-shrink: 0; display: flex; align-items: center; justify-content: center; border-radius: var(--radius-md); color: var(--text-tertiary); }
.dialog__close:hover { background: var(--bg-muted); }
.dialog__body { display: flex; flex-direction: column; gap: var(--sp-6); }
.dialog__foot { display: flex; justify-content: space-between; align-items: center; gap: var(--sp-4); padding-top: var(--sp-5); border-top: 1px solid var(--border-hairline); }
.dialog__foot .btn { height: var(--h-control-lg); }
.dialog__foot-note { font-size: var(--fs-ui); color: var(--text-secondary); }
.dialog__actions { display: flex; align-items: center; gap: var(--sp-3); margin-left: auto; }
.dialog__body-text { font-size: var(--fs-body); line-height: var(--lh-relaxed); }
.dialog__body-text > * + * { margin-top: var(--sp-2_5); }
/* What goes with a deleted candidate: the delete, approve and request dialogs and Admin › Deletion requests. */
.delete-impact { display: flex; flex-direction: column; gap: var(--sp-1); padding-left: var(--sp-5); list-style: disc; }

/* ── Toasts ───────────────────────────────────────────────────────────────── */
/* --toast-lift (set on #toast-host by toast.js): the height of the page's sticky footer bar, so a toast never covers its buttons;
   --toast-clear: the width of a sticky aside beside the form (the record steps), so it never covers the aside either. */
.toast-host { position: fixed; right: calc(var(--sp-6) + var(--toast-clear, 0px)); bottom: calc(var(--sp-6) + var(--toast-lift, 0px)); z-index: 90; display: flex; flex-direction: column; gap: var(--sp-2_5); width: 380px; max-width: calc(100vw - 48px); pointer-events: none; }
.toast-oob { display: contents; }
.toast { display: flex; align-items: flex-start; gap: var(--sp-3); padding: var(--sp-3_5) var(--sp-3) var(--sp-3_5) var(--sp-4); border: 1px solid var(--border-card); border-left: 4px solid var(--navy-900); border-radius: var(--radius-md); background: var(--bg-surface); box-shadow: var(--shadow-popover); pointer-events: auto; animation: toast-in var(--dur-base) var(--ease); }
.toast--success { border-left-color: var(--success); }
.toast--error { border-left-color: var(--danger); }
.toast--info { border-left-color: var(--gold-700); }
.toast__icon { flex-shrink: 0; margin-top: 1px; }
.toast--success .toast__icon { color: var(--success); }
.toast--error .toast__icon { color: var(--danger); }
.toast--info .toast__icon { color: var(--gold-700); }
.toast__body { flex-grow: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.toast__title { font-size: var(--fs-body); font-weight: var(--fw-semibold); }
.toast__desc { font-size: var(--fs-ui); line-height: var(--lh-snug); color: var(--text-secondary); }
.toast__action { margin-top: var(--sp-1); }
.toast__close { width: 32px; height: 32px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; border-radius: var(--radius-sm); color: var(--text-secondary); margin: -4px -4px 0 0; }
.toast__close:hover { background: var(--bg-muted); color: var(--text-primary); }
.toast.is-leaving { opacity: 0; transform: translateY(6px); transition: opacity var(--dur-base) var(--ease), transform var(--dur-base) var(--ease); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ── Alert banners, inline status ─────────────────────────────────────────── */
.alert { display: flex; gap: var(--sp-3); padding: var(--sp-3_5) var(--sp-4_5); border: 1px solid var(--border-card); border-radius: var(--radius-md); background: var(--bg-subtle); }
.alert:focus { outline: none; }
.alert__icon { flex-shrink: 0; margin-top: 1px; color: var(--gold-700); }
.alert__body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.alert__title { font-size: var(--fs-body); font-weight: var(--fw-semibold); }
.alert__text { font-size: var(--fs-ui); line-height: var(--lh-base); }
.alert--error { border-color: var(--red-200); background: var(--red-50); }
.alert--error .alert__icon, .alert--error .alert__title, .alert--error .alert__text { color: var(--red-800); }
.alert--error .alert__icon { color: var(--red-700); }
.alert--warning { border-color: var(--gold-400); background: var(--gold-50); }
.alert--warning .alert__title, .alert--warning .alert__text { color: var(--gold-800); }
.alert--info { border-color: var(--border-card); background: var(--gold-50); }
.alert--info .alert__text { color: var(--text-secondary); }
.alert--session { position: sticky; top: 0; z-index: 30; }
.inline-status { display: inline-flex; align-items: center; gap: var(--sp-2); font-size: var(--fs-ui); color: var(--success); }
.inline-status--warning { color: var(--gold-800); }
.inline-status--error { color: var(--danger-text); }
.inline-status--neutral { color: var(--text-secondary); }

/* ── Dropzone and file cards ─────────────────────────────────────────────── */
.dropzone-form { display: contents; }
.dropzone { display: flex; align-items: center; gap: var(--sp-4); padding: var(--sp-4_5) var(--sp-5); border: 1px dashed var(--gold-400); border-radius: var(--radius-md); background: var(--bg-subtle); cursor: pointer; }
.dropzone.is-over { border: 2px solid var(--navy-900); padding: calc(var(--sp-4_5) - 1px) calc(var(--sp-5) - 1px); }
.dropzone.is-disabled { opacity: var(--disabled-opacity); cursor: not-allowed; }
.dropzone__icon { flex-shrink: 0; color: var(--gold-700); }
.dropzone__text { display: flex; flex-direction: column; gap: 2px; }
.dropzone__title { font-size: var(--fs-body); font-weight: var(--fw-semibold); }
.dropzone__help { font-size: var(--fs-ui); color: var(--text-secondary); }
.dropzone--dialog { flex-direction: column; justify-content: center; gap: var(--sp-1_5); height: 96px; text-align: center; }
.dropzone--dialog .dropzone__text { align-items: center; }
.dropzone--compact { padding: var(--sp-3_5) var(--sp-4); }
.dropzone--page { padding: var(--sp-4_5) var(--sp-5); }
.upload-source { width: 320px; max-width: 100%; }   /* the upload dialog's source select: the dialog opens on every page */
.file-list { display: flex; flex-direction: column; gap: var(--sp-2_5); }
.file-card { display: flex; align-items: center; gap: var(--sp-3_5); padding: var(--sp-3) var(--sp-4); border: 1px solid var(--border-card); border-radius: var(--radius-md); background: var(--bg-surface); }
.file-card--stack { flex-direction: column; align-items: stretch; gap: var(--sp-3); padding-bottom: var(--sp-4); }
.file-card__row { display: flex; align-items: center; gap: var(--sp-3_5); }
.file-card__icon { flex-shrink: 0; }
.file-card__icon--ok { color: var(--success); }
.file-card__icon--dup { color: var(--gold-700); }
.file-card__icon--err { color: var(--danger); }
.file-card__text { flex-grow: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.file-card__title { font-size: var(--fs-body); font-weight: var(--fw-semibold); }
.file-card__meta { font-size: var(--fs-ui-sm); color: var(--text-secondary); }
.file-card__status { font-size: var(--fs-ui); color: var(--text-secondary); white-space: nowrap; }
.file-card__note { font-size: var(--fs-ui); line-height: var(--lh-base); color: var(--gold-800); }
.file-card__actions { display: flex; flex-wrap: wrap; gap: var(--sp-2_5); }
.file-card__remove { margin-left: auto; }
.file-card--duplicate { border-color: var(--gold-400); background: var(--gold-50); }
.file-card--error { border-color: var(--red-200); background: var(--red-25); }
.file-card--error .file-card__title { color: var(--red-800); }

/* ── Charts ───────────────────────────────────────────────────────────────── */
.donut-wrap { display: flex; align-items: center; gap: var(--sp-8); }
.donut { position: relative; flex-shrink: 0; width: var(--donut-sm); height: var(--donut-sm); }
.donut--260 { width: var(--donut-lg); height: var(--donut-lg); }
.donut svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.donut__track { stroke: var(--cream-500); }
.donut__centre { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--sp-1); text-align: center; }
.donut__value { font-family: var(--font-display); font-size: var(--fs-display-md); line-height: 1; }
.donut__caption { font-size: var(--fs-caption); color: var(--text-secondary); max-width: 120px; line-height: var(--lh-snug); }
.legend { display: flex; flex-direction: column; gap: var(--sp-2_5); }
.legend__row { display: flex; align-items: center; gap: var(--sp-2_5); font-size: var(--fs-body); }
.legend__swatch { width: 10px; height: 10px; flex-shrink: 0; border-radius: var(--radius-xs); }
.legend__count { margin-left: auto; font-weight: var(--fw-semibold); }
.legend-strip { display: flex; align-items: center; gap: var(--sp-4_5); font-size: var(--fs-ui); color: var(--text-secondary); }
.legend-strip__item { display: inline-flex; align-items: center; gap: var(--sp-2); }
.chart-1 { background: var(--chart-1); } .chart-2 { background: var(--chart-2); } .chart-3 { background: var(--chart-3); }
.chart-4 { background: var(--chart-4); } .chart-5 { background: var(--chart-5); } .chart-6 { background: var(--chart-6); } .chart-7 { background: var(--chart-7); }
.bars { display: flex; flex-direction: column; }
.bars__row { display: grid; grid-template-columns: 200px 1fr 170px; column-gap: var(--sp-4_5); align-items: center; min-height: 52px; border-bottom: 1px solid var(--border-hairline); font-size: var(--fs-body); }
.bars__label { font-weight: var(--fw-medium); }
.bars__label a { color: var(--text-primary); text-decoration: none; }
.bars__label a:hover { text-decoration: underline; }
.bars__track { display: flex; height: 22px; border-radius: var(--radius-xs); overflow: hidden; background: transparent; }
.bars__seg { height: 100%; }
.bars__nums { display: flex; justify-content: flex-end; gap: var(--sp-2); font-size: var(--fs-ui); color: var(--text-secondary); white-space: nowrap; }
.bars__total { font-weight: var(--fw-semibold); color: var(--text-primary); }

/* ── HTMX indicators, motion ──────────────────────────────────────────────── */
.htmx-indicator { opacity: 0; transition: opacity var(--dur-fast) var(--ease); }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { opacity: 1; }
.htmx-request .btn[data-busy], .btn.htmx-request { position: relative; color: transparent !important; pointer-events: none; }
.htmx-request .btn[data-busy]::after, .btn.htmx-request::after { content: ""; position: absolute; width: 18px; height: 18px; border-radius: var(--radius-full); border: 2px solid var(--gold-500); border-right-color: transparent; animation: spin 0.8s linear infinite; }
.btn--secondary.htmx-request::after, .btn--outline.htmx-request::after, .btn--gold.htmx-request::after { border-color: var(--navy-900); border-right-color: transparent; }
.htmx-request > .grid-table tbody, .grid-table.htmx-request tbody, .htmx-request .is-dimmable { opacity: 0.6; transition: opacity var(--dur-fast) var(--ease); }
.htmx-swapping { opacity: 0.5; }

/* Note thread: the profiles' notes card and the record's step 3 */
.notes-thread { display: flex; flex-direction: column; margin: var(--sp-2) 0 0; padding: 0; list-style: none; border-top: 1px solid var(--border-hairline); }
.note { display: flex; flex-direction: column; gap: var(--sp-1_5); padding: var(--sp-3) 0; border-bottom: 1px solid var(--border-hairline); }
.note__meta { display: flex; align-items: center; gap: var(--sp-2); font-size: var(--fs-caption); color: var(--text-secondary); }
.note__body { font-size: var(--fs-body-sm); line-height: var(--lh-relaxed); white-space: pre-wrap; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
}
