/* ILOPLEKS panel: the only stylesheet. Tokens from the public site at admin density (CONVENTIONS.md, design 9).
   No inline styles anywhere; CSP style-src 'self'.

   Sections: fonts, tokens, reset, shell (rail, top bar), page head, cards and grids, text helpers,
   buttons, forms, filters and tabs, tables, badges and tags, timeline and notes, banners and toasts,
   empty state, dialog, help panel, auth layout, error page, combobox, responsive, touch, print. */

/* ---------- fonts (served from /assets/fonts, copied from site/assets/fonts by the build) ---------- */
@font-face { font-family: "IBM Plex Sans"; src: url("fonts/ibm-plex-sans-400.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "IBM Plex Sans"; src: url("fonts/ibm-plex-sans-500.woff2") format("woff2"); font-weight: 500; font-style: normal; font-display: swap; }
@font-face { font-family: "IBM Plex Sans"; src: url("fonts/ibm-plex-sans-600.woff2") format("woff2"); font-weight: 600; font-style: normal; font-display: swap; }
@font-face { font-family: "IBM Plex Sans"; src: url("fonts/ibm-plex-sans-700.woff2") format("woff2"); font-weight: 700; font-style: normal; font-display: swap; }
@font-face { font-family: "IBM Plex Mono"; src: url("fonts/ibm-plex-mono-400.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "IBM Plex Mono"; src: url("fonts/ibm-plex-mono-500.woff2") format("woff2"); font-weight: 500; font-style: normal; font-display: swap; }
@font-face { font-family: "IBM Plex Mono"; src: url("fonts/ibm-plex-mono-600.woff2") format("woff2"); font-weight: 600; font-style: normal; font-display: swap; }

/* ---------- tokens ---------- */
:root {
  --font: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  --blue-50: #EAF3FC;
  --blue-100: #D6E3F0;
  --blue-400: #7DB9EC;
  --blue-600: #1580D6;
  --blue-700: #0072CE;
  --blue-800: #0057B8;
  --blue-900: #16283B;
  --gray-50: #F5F7FA;
  --gray-100: #EEF1F5;
  --gray-200: #DBE2EA;
  --gray-300: #C0CAD5;
  --ink-strong: #333333;
  --ink: #374151;
  --muted: #5d6a63;
  --success: #1B7F4C;
  --success-ink: #156B3F;      /* text on --success-bg: 5.8:1 */
  --success-bg: #E6F4EC;
  --warning: #B7791F;
  --warning-ink: #7A4F0F;      /* text on --warning-bg: 6.4:1 */
  --warning-bg: #FBF1DE;
  --danger: #B42318;
  --danger-bg: #FBEAE8;
  --info: #0057B8;
  --info-bg: #EAF3FC;
  --placeholder: #7A4E9E;
  --placeholder-bg: #F1EAF8;
  --violet-ink: #5B3F9E;       /* second accent for statuses, on --violet-bg: 7:1 */
  --violet-bg: #EEEAF8;

  --paper: #FFFFFF;
  --ground: var(--gray-50);
  --line: var(--gray-200);
  --line-soft: #E9EEF4;
  --focus: var(--blue-600);

  --fs-base: 14px;
  --fs-meta: 12px;
  --fs-h1: 22px;
  --fs-h2: 16px;
  --lh: 1.45;

  --rail-w: 220px;
  --rail-w-narrow: 60px;
  --topbar-h: 56px;
  --row-h: 36px;
  --touch: 44px;
  --content-max: 1200px;
  --gap: 16px;
  --radius: 4px;
  --radius-lg: 6px;
  --shadow-1: 0 1px 2px rgba(22, 40, 59, .06), 0 1px 3px rgba(22, 40, 59, .08);
  --shadow-2: 0 6px 24px rgba(22, 40, 59, .14);
  --dur: 150ms;
  --ease: cubic-bezier(.4, 0, .2, 1);
}

/* ---------- reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 400 var(--fs-base)/var(--lh) var(--font);
  color: var(--ink);
  background: var(--ground);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4, p, dl, dd, figure { margin: 0; }
ul, ol { margin: 0; padding: 0; }
a { color: var(--blue-700); }
a:hover { color: var(--blue-800); }
img, svg { display: inline-block; vertical-align: middle; }
code, pre, .cell-mono, .input--mono { font-family: var(--mono); font-size: 13px; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: var(--radius); }
::selection { background: var(--blue-100); }

/* ---------- text helpers ---------- */
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.muted { color: var(--muted); }
.text-danger { color: var(--danger); }
.mono { font-family: var(--mono); font-size: 13px; white-space: nowrap; letter-spacing: .01em; }
a.mono { color: var(--blue-800); text-decoration: none; font-weight: 500; }
a.mono:hover { text-decoration: underline; }
h1.mono, .page-head__title.mono { font-size: var(--fs-h1); font-weight: 600; letter-spacing: 0; white-space: normal; overflow-wrap: anywhere; }
/* identifiers shown as values (not in table cells) wrap rather than push the page wider */
dd .mono, .facts .mono, .timeline .mono, .note .mono, .banner .mono, .list .mono, .page-head__lead .mono { white-space: normal; overflow-wrap: anywhere; }
.input.mono { white-space: normal; }
.prewrap { white-space: pre-wrap; word-break: break-word; }
mark.deid { background: var(--warning-bg); color: var(--warning-ink); padding: 0 3px; border-radius: 3px; box-shadow: inset 0 -2px 0 var(--warning); }
code.prewrap { display: block; padding: 8px 10px; background: var(--gray-50); border: 1px solid var(--line-soft); border-radius: var(--radius); font-size: 12.5px; line-height: 1.5; }
.wrap { white-space: normal; word-break: break-word; }
.num { font-variant-numeric: tabular-nums; }
th.num, td.num { text-align: right; }
.unit { color: var(--muted); font-size: var(--fs-meta); margin-left: 2px; }
.req { color: var(--danger); font-weight: 600; }
.h4 { font-size: 13px; font-weight: 600; color: var(--ink-strong); letter-spacing: .01em; }
.stack > * + * { margin-top: var(--gap); }
.stack > .h4 + * { margin-top: 6px; }
.stack > * + .h4 { margin-top: 18px; }
.icon { width: 20px; height: 20px; flex: none; }
.skip-link { position: absolute; left: 8px; top: -60px; z-index: 100; padding: 8px 12px; background: var(--paper); color: var(--blue-800); border: 1px solid var(--line); border-radius: var(--radius); }
.skip-link:focus { top: 8px; }

/* ---------- shell ---------- */
.shell { display: flex; min-height: 100vh; }
.frame { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.main { flex: 1; width: 100%; max-width: var(--content-max); margin: 0 auto; padding: 24px 28px 96px; }
.main:focus { outline: none; }

/* rail */
.rail {
  width: var(--rail-w); flex: none; position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; background: var(--blue-900); color: #fff;
  transition: width var(--dur) var(--ease);
}
.rail__brand { display: flex; align-items: center; gap: 10px; height: var(--topbar-h); padding: 0 14px; color: #fff; text-decoration: none; font-weight: 600; letter-spacing: .01em; border-bottom: 1px solid rgba(255, 255, 255, .08); white-space: nowrap; overflow: hidden; }
.rail__logo { display: inline-grid; place-items: center; width: 32px; height: 32px; flex: none; background: var(--blue-700); color: #fff; font: 700 12px/1 var(--mono); border-radius: var(--radius); letter-spacing: .05em; }
.rail__nav { flex: 1; overflow-y: auto; padding: 10px 8px; }
.rail__group + .rail__group { margin-top: 12px; }
.rail__group-label { padding: 8px 10px 4px; font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: rgba(255, 255, 255, .45); white-space: nowrap; overflow: hidden; }
.rail__list { list-style: none; }
.rail__link {
  display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 8px 10px; border-radius: var(--radius);
  color: rgba(255, 255, 255, .82); text-decoration: none; white-space: nowrap; overflow: hidden;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.rail__link:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.rail__link.is-active { background: var(--blue-700); color: #fff; font-weight: 500; }
.rail__link:focus-visible { outline-color: var(--blue-400); }
.rail__foot { padding: 12px 14px; border-top: 1px solid rgba(255, 255, 255, .08); display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: var(--fs-meta); color: rgba(255, 255, 255, .55); }
.rail__version { font-family: var(--mono); font-size: 11px; }

/* topbar */
.topbar {
  position: sticky; top: 0; z-index: 30; height: var(--topbar-h); display: flex; align-items: center; gap: 12px;
  padding: 0 20px; background: var(--paper); border-bottom: 1px solid var(--line);
}
.topbar__menu { display: none; }
.topbar__search { position: relative; flex: 1; max-width: 520px; }
.topbar__search-icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.topbar__search .topbar__search-input { padding-left: 38px; height: 38px; background: var(--gray-50); }
.topbar__right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.topbar__help span { margin-left: 6px; }

.lang { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.lang__btn { min-width: 40px; height: 32px; padding: 0 10px; border: 0; background: var(--paper); color: var(--muted); font-size: var(--fs-meta); font-weight: 600; letter-spacing: .04em; }
.lang__btn + .lang__btn { border-left: 1px solid var(--line); }
.lang__btn:hover { background: var(--gray-50); color: var(--ink-strong); }
.lang__btn.is-active { background: var(--blue-700); color: #fff; }
.lang__btn:focus-visible { outline-offset: -2px; border-radius: 0; }

.usermenu { position: relative; }
.usermenu__summary { list-style: none; display: flex; align-items: center; gap: 8px; min-height: 40px; padding: 4px 8px 4px 4px; border-radius: var(--radius); cursor: pointer; }
.usermenu__summary::-webkit-details-marker { display: none; }
.usermenu__summary:hover { background: var(--gray-50); }
.usermenu__name { font-weight: 500; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.usermenu__menu { min-width: 260px; }
.avatar { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: var(--blue-100); color: var(--blue-800); font-size: 12px; font-weight: 600; }
.menu { position: absolute; right: 0; top: calc(100% + 6px); min-width: 260px; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-2); padding: 6px; z-index: 40; }
.menu__head { padding: 10px 12px 12px; border-bottom: 1px solid var(--line-soft); margin-bottom: 6px; }
.menu__name { font-weight: 600; color: var(--ink-strong); }
.menu__meta { font-size: var(--fs-meta); color: var(--muted); }
.menu__item { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 40px; padding: 8px 12px; border: 0; border-radius: var(--radius); background: none; color: var(--ink); text-decoration: none; text-align: left; }
.menu__item:hover { background: var(--gray-50); color: var(--ink-strong); }
.menu__item--button { font: inherit; cursor: pointer; }
.menu__form { margin: 0; }

/* ---------- page head: title block left, primary action right; stacks under 640 px ---------- */
.page-head { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px var(--gap); align-items: start; margin-bottom: 20px; }
.page-head__main { min-width: 0; }
.page-head__title { font-size: var(--fs-h1); line-height: 1.25; font-weight: 600; color: var(--ink-strong); overflow-wrap: anywhere; }
.page-head__title .tabs__count { vertical-align: middle; margin-left: 4px; }
.page-head__lead { margin-top: 4px; }
.page-head__lead .badge { vertical-align: middle; }
.page-head__crumbs { font-size: var(--fs-meta); color: var(--muted); margin-bottom: 4px; }
.page-head__badges { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin-top: 8px; }
.page-head__badges + .page-head__lead { margin-top: 6px; }
.page-head__actions { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 8px; justify-self: end; min-width: 0; }
.page-head__actions:empty { display: none; }
.page-head__actions form { margin: 0; }
/* case page: the status form lives in the actions slot and drops below the title under 1100 px */
.page-head--case .page-head__actions { align-items: stretch; }

.status-control {
  display: flex; flex-wrap: wrap; gap: 8px 10px; align-items: flex-end;
  width: min(100%, 680px); padding: 12px 14px; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-1);
}
.status-control__field { display: flex; flex-direction: column; gap: 4px; flex: 1 1 150px; min-width: 0; }
.status-control__field--wide { flex: 1.6 1 200px; }
.status-control__actions { flex: 0 0 auto; }
.status-control .field__label { font-size: var(--fs-meta); font-weight: 500; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.status-control .select, .status-control .input { min-height: 36px; padding-top: 6px; padding-bottom: 6px; font-size: 13px; }
.status-control__actions .btn { min-height: 36px; width: 100%; }

/* ---------- cards, grids ---------- */
.card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 20px; box-shadow: var(--shadow-1); }
.card + .card, .grid + .card, .card + .grid, .tiles + .grid, .filters + .card, .tabs + .card, .filters + .empty, .nav + .card, .card + .empty, .tabs + .grid, .tabs + .empty, .grid + .grid, .card + .form, .grid + .form { margin-top: var(--gap); }
.card--narrow { max-width: 520px; }
.card--table { position: relative; padding: 0; overflow: hidden; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.card--accent { border-color: var(--blue-400); background: var(--blue-50); }
.card--danger { border-color: #E9B4AE; background: var(--danger-bg); }
.card--warning { border-color: #EBD3A5; background: #FFFBF3; }
.card--survivor { border-top: 3px solid var(--success); }
.card--duplicate { border-top: 3px solid var(--warning); }
.card__title { font-size: var(--fs-h2); font-weight: 600; color: var(--ink-strong); margin-bottom: 10px; }
.card__title .tabs__count, .card__title .badge { vertical-align: middle; margin-left: 4px; }
.card__title--inset { padding: 16px 16px 0; margin-bottom: 8px; }
.card__lead { margin: -4px 0 14px; }
.card > .form { margin-top: 4px; }
.grid { display: grid; gap: var(--gap); }
.grid > * { min-width: 0; }
.grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid--main-side { grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); align-items: start; }
.grid > aside > .card + .card { margin-top: var(--gap); }
.grid > div > .card + .card { margin-top: var(--gap); }
.case-context .card { padding: 16px 18px; }
.case-context .card__title { font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin-bottom: 8px; }
.case-context .dl { margin-top: 8px; grid-template-columns: minmax(72px, 32%) 1fr; }
.case-context .dl dd, .case-context p { overflow-wrap: anywhere; }
.case-context .inline-form { display: flex; gap: 8px; align-items: center; }
.case-context .inline-form .select { flex: 1; min-width: 0; }
.case-context .inline-form .btn { flex: none; }
.case-context p + .inline-form { margin-top: 8px; }
.case-context .dl + .inline-form, .case-context .inline-form + .dl { margin-top: 10px; }

/* tiles */
.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--gap); margin-bottom: var(--gap); }
.tile { position: relative; display: flex; flex-direction: column; gap: 4px; min-height: 108px; padding: 16px 18px; background: var(--paper); border: 1px solid var(--line); border-left: 4px solid var(--blue-700); border-radius: var(--radius-lg); text-decoration: none; color: var(--ink); box-shadow: var(--shadow-1); transition: box-shadow var(--dur) var(--ease), transform var(--dur) var(--ease); }
.tile:hover { box-shadow: var(--shadow-2); transform: translateY(-1px); color: var(--ink); }
.tile--primary { border-left-color: var(--blue-700); }
.tile--default { border-left-color: var(--gray-300); }
.tile--danger { border-left-color: var(--danger); }
.tile--warning { border-left-color: var(--warning); }
.tile--empty { opacity: .7; }
.tile__icon { position: absolute; right: 14px; top: 14px; color: var(--muted); }
.tile__value { font-size: 30px; font-weight: 600; line-height: 1.1; color: var(--ink-strong); }
.tile__label { font-weight: 500; }
.tile__note { font-size: var(--fs-meta); }

/* facts, dl, lists */
.facts { display: flex; flex-direction: column; }
.facts__row { display: grid; grid-template-columns: minmax(160px, 40%) 1fr; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line-soft); }
.facts__row:first-child { border-top: 0; }
.facts dt { color: var(--muted); }
.facts dd { color: var(--ink-strong); display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-width: 0; overflow-wrap: anywhere; }
.facts dd > * { min-width: 0; max-width: 100%; }
.facts dd > .link { flex-wrap: wrap; }
.dl { display: grid; grid-template-columns: minmax(120px, 40%) 1fr; gap: 8px 12px; }
.dl dt { color: var(--muted); }
.dl dd { color: var(--ink-strong); word-break: break-word; overflow-wrap: anywhere; min-width: 0; }
.dl dd > .table__wrap { max-width: 100%; }
.dl dd .tag + .tag { margin-left: 2px; }
.list { list-style: none; }
.list__item { padding: 8px 0; border-top: 1px solid var(--line-soft); }
.list__item:first-child { border-top: 0; }
.list--files li { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; padding: 8px 0; border-top: 1px solid var(--line-soft); }
.list--files li:first-child { border-top: 0; padding-top: 0; }
.list--files li > a, .list--files li > span:first-child { flex: 1 1 100%; min-width: 0; overflow-wrap: anywhere; }
.list--files li .muted { font-size: var(--fs-meta); }
.list--inline { display: flex; flex-wrap: wrap; gap: 6px 16px; }
.list--inline li { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 0; border: 0; }
.list--follow-ups li { display: flex; flex-direction: column; gap: 6px; padding: 10px 0; border-top: 1px solid var(--line-soft); }
.list--follow-ups li:first-child { border-top: 0; padding-top: 0; }
.list--follow-ups li > div:first-child { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.list--follow-ups li.row--overdue { box-shadow: inset 3px 0 0 var(--danger); padding-left: 10px; }
.list--follow-ups li.row--done { color: var(--muted); }
.list--follow-ups .row-actions { justify-content: flex-start; }
.list--follow-ups + .form { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line-soft); }
.list--notes { display: flex; flex-direction: column; gap: 10px; }
.toc { padding-left: 20px; }
.toc li { padding: 4px 0; }
.steps { padding-left: 22px; }
.steps li { margin-bottom: 8px; }
.pre { margin: 0; padding: 10px 12px; background: var(--gray-50); border: 1px solid var(--line-soft); border-radius: var(--radius); white-space: pre-wrap; word-break: break-word; font-size: 12.5px; line-height: 1.5; max-height: 360px; overflow: auto; }
.details summary { cursor: pointer; color: var(--blue-700); font-weight: 500; min-height: 32px; display: flex; align-items: center; }
.details[open] summary { margin-bottom: 8px; }
.link { color: var(--blue-700); text-decoration: none; display: inline-flex; align-items: center; gap: 6px; }
.link:hover { text-decoration: underline; }
.link--button { background: none; border: 0; padding: 0; min-height: 32px; font: inherit; }
.case-link { text-decoration: none; }
.case-link:hover .mono { text-decoration: underline; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-left: 6px; vertical-align: middle; }
.dot--online { background: var(--success); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 0 16px;
  border: 1px solid transparent; border-radius: var(--radius); font-weight: 500; text-decoration: none; white-space: nowrap;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease), color var(--dur) var(--ease);
}
.btn--primary { background: var(--blue-700); color: #fff; }
.btn--primary:hover { background: var(--blue-800); color: #fff; }
.btn--ghost { background: var(--paper); color: var(--ink); border-color: var(--line); }
.btn--ghost:hover { background: var(--gray-50); border-color: var(--gray-300); color: var(--ink-strong); }
.btn--danger { background: var(--danger); color: #fff; }
.btn--danger:hover { background: #8F1C13; color: #fff; }
.btn--small { min-height: 32px; padding: 0 10px; font-size: 13px; }
.btn--block { width: 100%; }
.btn--icon { width: 40px; padding: 0; background: none; border-color: transparent; color: var(--muted); }
.btn--icon:hover { background: var(--gray-50); color: var(--ink-strong); }
.btn--undo { background: rgba(255, 255, 255, .12); color: #fff; border-color: rgba(255, 255, 255, .25); }
.btn--undo:hover { background: rgba(255, 255, 255, .22); color: #fff; }
.btn:disabled, .btn.is-disabled { opacity: .5; cursor: not-allowed; pointer-events: none; }

/* ---------- forms ---------- */
.form { display: flex; flex-direction: column; gap: 16px; }
.form--compact { gap: 10px; }
.form--compact .btn { align-self: flex-start; }
.form--inline-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: start; }
.form--inline-grid .form__actions { grid-column: 1 / -1; }
.form--record .card > div { display: flex; flex-direction: column; gap: 16px; }
.form__row { display: flex; gap: 16px; align-items: flex-start; }
.form__row > .field { flex: 1 1 0; min-width: 0; }
.form__row > .field--wide { flex: 2 1 0; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field--compact { min-width: 160px; }
.field--grow { flex: 1; }
.field--check { flex-direction: row; align-items: center; gap: 8px; min-height: 40px; }
.field--check input { width: 18px; height: 18px; margin: 0; accent-color: var(--blue-700); }
.field--check label { cursor: pointer; }
.field__label { font-weight: 500; color: var(--ink-strong); }
.field__label .muted { font-weight: 400; }
.field__hint, .field__meta { font-size: var(--fs-meta); color: var(--muted); }
.field__error { font-size: 13px; color: var(--danger); font-weight: 500; }
.field__static { min-height: 40px; display: flex; align-items: center; padding: 0 12px; background: var(--gray-50); border: 1px solid var(--line-soft); border-radius: var(--radius); }
.input, .select, .textarea {
  width: 100%; min-height: 40px; padding: 8px 12px; background: var(--paper); border: 1px solid var(--gray-300); border-radius: var(--radius);
  color: var(--ink-strong); transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.input:hover, .select:hover, .textarea:hover { border-color: var(--blue-400); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--blue-600); box-shadow: 0 0 0 3px var(--blue-50); }
.input:disabled, .select:disabled, .textarea:disabled { background: var(--gray-50); color: var(--muted); }
.input[aria-invalid="true"], .textarea[aria-invalid="true"], .select[aria-invalid="true"], .input--invalid, .has-error .input, .has-error .select, .has-error .textarea { border-color: var(--danger); }
.input[aria-invalid="true"]:focus, .textarea[aria-invalid="true"]:focus, .input--invalid:focus, .has-error .input:focus, .has-error .select:focus, .has-error .textarea:focus { box-shadow: 0 0 0 3px var(--danger-bg); }
.input--code { font-family: var(--mono); font-size: 20px; letter-spacing: .18em; text-align: center; }
.textarea { resize: vertical; min-height: 72px; }
.select { appearance: none; padding-right: 32px; 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='%235d6a63' stroke-width='2' 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 10px center; }
.select--small { min-height: 32px; padding: 4px 28px 4px 8px; font-size: 13px; }
.radio-row { display: flex; gap: 16px; flex-wrap: wrap; }
.radio { display: inline-flex; align-items: center; gap: 8px; min-height: 32px; }
.form__actions { display: flex; gap: 10px; align-items: center; }
.form__actions--split { justify-content: space-between; }
.form__actions--center { justify-content: center; }
.inline-form { display: inline; margin: 0; }
.hidden-form { display: none; }
.copy-row { display: flex; gap: 8px; }
.copy-row .input { flex: 1; }
.settings-form { display: block; }

.error-summary { padding: 14px 16px; margin-bottom: 16px; background: var(--danger-bg); border: 1px solid #E9B4AE; border-left: 4px solid var(--danger); border-radius: var(--radius); }
.error-summary:focus { outline: 2px solid var(--danger); outline-offset: 2px; }
.error-summary__title { display: block; color: var(--danger); margin-bottom: 6px; }
.error-summary__list { padding-left: 18px; }
.error-summary a { color: var(--danger); }

.savebar {
  position: sticky; bottom: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  margin-top: var(--gap); padding: 12px 20px; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: 0 -4px 20px rgba(22, 40, 59, .08);
}
.savebar.is-dirty { border-color: var(--warning); }
.savebar.is-dirty .savebar__state { color: var(--warning-ink); font-weight: 500; }
.savebar__actions { display: flex; gap: 8px; }
.savebar__state { font-size: 13px; }
.savebar__state:empty { display: none; }
.savebar > .btn + .btn { margin-left: -4px; }
.savebar > .savebar__state { margin-left: auto; }
.autosave-state { font-size: var(--fs-meta); color: var(--muted); }
.autosave-state.is-saving { color: var(--blue-700); }
.autosave-state.is-saved { color: var(--success); }
.autosave-state.is-conflict, .autosave-state.is-error { color: var(--danger); font-weight: 500; }

/* settings */
.settings-grid { display: flex; flex-direction: column; }
.settings-row { display: grid; grid-template-columns: minmax(200px, 32%) 1fr auto; gap: 12px 20px; padding: 14px 0; border-top: 1px solid var(--line-soft); align-items: start; }
.settings-row:first-child { border-top: 0; padding-top: 4px; }
.settings-row__label { display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }
.settings-row__value { display: flex; flex-direction: column; gap: 6px; }
.settings-row__actions { display: flex; align-items: center; min-height: 40px; }

/* ---------- filters: labels above controls, Apply/Reset aligned with the controls' baseline ---------- */
.filters { margin-bottom: var(--gap); padding: 14px 16px; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-1); }
.filters__row { display: flex; flex-wrap: wrap; gap: 12px 16px; align-items: flex-end; }
.filters__row > .field { flex: 1 1 160px; max-width: 260px; }
.filters__row > .field--grow { flex: 1 1 280px; max-width: none; }
.filters__row > .field--check { flex: 0 0 auto; max-width: none; }
.filters__actions { display: flex; gap: 8px; align-items: center; min-height: 40px; margin-left: auto; }
.filters--slim { display: flex; align-items: center; gap: 10px; padding: 0; background: none; border: 0; box-shadow: none; }
.filters--slim .select--small { width: auto; min-width: 180px; }

/* ---------- tabs: one horizontal bar on every width, scrolls sideways when it does not fit ---------- */
.tabs { display: flex; gap: 4px; flex-wrap: nowrap; overflow-x: auto; overflow-y: hidden; margin-bottom: var(--gap); box-shadow: inset 0 -1px 0 var(--line); scrollbar-width: thin; -webkit-overflow-scrolling: touch; }
.tabs__tab { display: inline-flex; align-items: center; gap: 6px; flex: none; min-height: var(--touch); padding: 0 14px; color: var(--muted); text-decoration: none; border-bottom: 2px solid transparent; font-weight: 500; white-space: nowrap; }
.tabs__tab:hover { color: var(--ink-strong); }
.tabs__tab.is-active { color: var(--blue-800); border-bottom-color: var(--blue-700); }
.tabs__tab:focus-visible { outline-offset: -2px; }
.tabs__tab.is-disabled { color: var(--gray-300); cursor: default; }
.tabs__tab.is-disabled .tag { color: var(--muted); border-color: var(--line); background: var(--gray-50); }
.tabs__count { font-size: 11px; padding: 1px 6px; border-radius: 10px; background: var(--gray-100); color: var(--ink); }
.tabs__tab.is-active .tabs__count { background: var(--blue-50); color: var(--blue-800); }
.tabs--case { margin-top: -4px; }
.tabs--case + .case-context { margin-bottom: var(--gap); }

/* ---------- tables: 36 px rows; wide tables scroll inside their card ----------
   The wrapper is positioned so absolutely positioned descendants (the sr-only labels of row forms) stay
   inside its scroll clip; otherwise mobile browsers widen the layout viewport to their static position and
   the whole page scrolls sideways. A wrapper that overflows is a focusable, labelled region (tabindex="0"). */
.table__wrap { position: relative; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: thin; }
.table__wrap:focus-visible { outline-offset: -2px; }
.card > .table__wrap { margin: 0 -20px; padding: 0 20px; }
.card--table > .table__wrap { margin: 0; padding: 0; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { height: var(--row-h); padding: 6px 12px; text-align: left; vertical-align: middle; border-bottom: 1px solid var(--line-soft); }
.table thead th { height: 40px; background: var(--gray-50); font-size: var(--fs-meta); font-weight: 600; letter-spacing: .03em; text-transform: uppercase; color: var(--muted); white-space: nowrap; }
.table tbody tr:hover { background: #FAFBFD; }
.table tbody tr.is-muted { color: var(--muted); }
.table tbody tr:last-child td { border-bottom: 0; }
.table td > .muted { font-size: 13px; }
.table td .badge + .badge, .table td .badge + .tag, .table td .mono + .badge, .table td .mono + .tag { margin-left: 4px; }
.table--compact th, .table--compact td { height: 32px; padding: 5px 10px; }
.table--compact thead th { height: 34px; }
.table--list td { vertical-align: top; }
.table--inline { width: auto; min-width: 280px; margin: 2px 0; font-size: 13px; }
.table--inline th, .table--inline td { height: 28px; padding: 3px 8px; }
.table--inline thead th { height: 28px; background: none; border-bottom: 1px solid var(--line); }
.th-actions, .td-actions { text-align: right; white-space: nowrap; }
.td-actions .btn + .btn, .td-actions .inline-form + .btn, .td-actions .btn + .inline-form, .td-actions .inline-form + .inline-form { margin-left: 6px; }
.td-actions .select--small { width: auto; min-width: 0; vertical-align: middle; }
.th-sort__link { color: inherit; text-decoration: none; display: inline-flex; align-items: center; gap: 4px; min-height: 28px; }
.th-sort__link:hover { color: var(--ink-strong); }
.th-sort__link:focus-visible { outline-offset: 0; }
.th-sort__mark::after { content: "↕"; opacity: .4; font-size: 11px; }
.th-sort.is-active .th-sort__mark::after { opacity: 1; color: var(--blue-700); }
.th-sort[aria-sort="ascending"] .th-sort__mark::after { content: "↑"; }
.th-sort[aria-sort="descending"] .th-sort__mark::after { content: "↓"; }
.cell-strong { font-weight: 500; color: var(--ink-strong); }
.cell-muted { color: var(--muted); }
.cell-nowrap { white-space: nowrap; }
.cell-wrap { white-space: normal; min-width: 120px; max-width: 420px; overflow-wrap: anywhere; }
.td-actions .inline-form { display: inline-flex; align-items: center; gap: 6px; vertical-align: middle; }
.cell-id { white-space: nowrap; width: 1%; }
.cell-id .mono { display: inline-block; }
.cell-error { color: var(--danger); font-family: var(--mono); font-size: 12px; }
.table--diff th[scope="row"] { color: var(--muted); font-weight: 500; white-space: nowrap; vertical-align: top; padding-top: 10px; }
.table--diff td { vertical-align: top; }
.table--diff tr.is-changed th[scope="row"] { color: var(--ink-strong); }
.table--diff tr.is-changed td:nth-child(2) .pre { background: var(--danger-bg); }
.table--diff tr.is-changed td:nth-child(3) .pre { background: var(--success-bg); }
/* row states */
.table tbody tr.row--overdue td:first-child { box-shadow: inset 3px 0 0 var(--danger); }
.table tbody tr.row--overdue { background: #FFF8F7; }
.table tbody tr.row--done, .table tbody tr.row--muted, .table tbody tr.row--archived { color: var(--muted); }
.table tbody tr.row--done .cell-strong, .table tbody tr.row--muted .cell-strong, .table tbody tr.row--archived .cell-strong { color: var(--muted); }
.table tbody tr.row--archived .mono { color: var(--muted); }
.row-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: 6px; }
.row-actions .inline-form { display: inline-flex; align-items: center; gap: 6px; }
.row-actions .select--small { width: auto; min-width: 120px; }
.row-actions .input { width: auto; min-width: 150px; min-height: 32px; padding: 4px 8px; font-size: 13px; }
.pagination { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 10px 12px; border-top: 1px solid var(--line-soft); }
.pagination__summary { font-size: var(--fs-meta); }
.pagination__links { display: flex; align-items: center; gap: 8px; }
.pagination__page { font-size: var(--fs-meta); color: var(--muted); }

/* ---------- badges and tags: subtle tints, AA text ---------- */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 10px; font-size: 11.5px; font-weight: 600; line-height: 1.4; white-space: nowrap; background: var(--gray-100); color: var(--ink); vertical-align: middle; text-decoration: none; }
.badge .icon { width: 12px; height: 12px; }
a.badge:hover { text-decoration: underline; }
.badge--success { background: var(--success-bg); color: var(--success-ink); }
.badge--warning { background: var(--warning-bg); color: var(--warning-ink); }
.badge--danger { background: var(--danger-bg); color: var(--danger); }
.badge--info { background: var(--info-bg); color: var(--info); }
.badge--muted { background: var(--gray-100); color: var(--muted); }
.badge--placeholder { background: var(--placeholder-bg); color: var(--placeholder); border: 1px dashed var(--placeholder); }
.badge--large { font-size: 13px; padding: 6px 12px; }
/* case status: tinted, one hue per stage of the funnel */
.badge--status-new { background: var(--blue-50); color: var(--blue-800); }
.badge--status-in_review { background: var(--violet-bg); color: var(--violet-ink); }
.badge--status-waiting_client { background: var(--warning-bg); color: var(--warning-ink); }
.badge--status-answered { background: var(--success-bg); color: var(--success-ink); }
.badge--status-on_hold { background: var(--gray-100); color: #4B5563; }
.badge--status-closed { background: #E4E9EE; color: var(--ink); }
.badge--status-spam { background: var(--danger-bg); color: var(--danger); }
/* case type: outlined with a colour dot, so a type never reads as a status */
[class*="badge--type-"] { background: var(--paper); color: var(--ink); border: 1px solid var(--line); font-weight: 500; padding-left: 7px; }
[class*="badge--type-"]::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--gray-300); flex: none; }
.badge--type-consultation::before { background: var(--blue-700); }
.badge--type-samples::before { background: var(--success); }
.badge--type-replacement::before { background: var(--warning); }
.badge--type-order::before { background: var(--violet-ink); }
.badge--type-contact::before { background: var(--gray-300); }
.badge--type-distributor::before { background: var(--blue-900); }
/* company lifecycle */
.badge--company-lead { background: var(--blue-50); color: var(--blue-800); }
.badge--company-testing { background: var(--warning-bg); color: var(--warning-ink); }
.badge--company-active_customer { background: var(--success-bg); color: var(--success-ink); }
.badge--company-inactive { background: var(--gray-100); color: var(--muted); }
/* trial results */
.badge--trial-pending { background: var(--gray-100); color: var(--ink); }
.badge--trial-positive { background: var(--success-bg); color: var(--success-ink); }
.badge--trial-negative { background: var(--danger-bg); color: var(--danger); }
.badge--trial-inconclusive { background: var(--warning-bg); color: var(--warning-ink); }
/* tags: small neutral chips for values (aliases, list items, counters) */
.tag { display: inline-flex; align-items: center; gap: 4px; padding: 1px 6px; border-radius: 3px; background: var(--gray-100); border: 1px solid var(--gray-200); color: var(--ink); font-size: 11.5px; font-weight: 500; line-height: 1.5; white-space: nowrap; vertical-align: middle; max-width: 100%; }
.tag--muted { background: var(--paper); color: var(--muted); border-color: var(--line); }

/* ---------- timeline: a vertical rail with a marker per event kind ---------- */
.timeline { list-style: none; position: relative; padding-left: 28px; }
.timeline::before { content: ""; position: absolute; left: 9px; top: 8px; bottom: 8px; width: 2px; background: var(--line); border-radius: 1px; }
.timeline__item { position: relative; padding: 2px 0 18px; }
.timeline__item:last-child { padding-bottom: 4px; }
.timeline__item::before { content: ""; position: absolute; left: -24px; top: 6px; width: 12px; height: 12px; border-radius: 50%; background: var(--gray-300); border: 2px solid var(--paper); box-shadow: 0 0 0 1px var(--line); }
.timeline__item--created::before { background: var(--blue-700); }
.timeline__item--status::before { background: var(--blue-800); }
.timeline__item--assign::before { background: var(--blue-400); }
.timeline__item--note::before { background: var(--warning); }
.timeline__item--email_out::before, .timeline__item--email_in::before, .timeline__item--telegram::before { background: var(--info); }
.timeline__item--ai_draft::before, .timeline__item--brief_sent::before { background: var(--placeholder); }
.timeline__item--attachment::before { background: var(--gray-300); }
.timeline__item--link::before { background: var(--blue-400); }
.timeline__item--follow_up::before, .timeline__item--identity::before { background: var(--success); }
.timeline__item--merge::before, .timeline__item--reversal::before { background: var(--violet-ink); }
.timeline__item--erasure::before { background: var(--danger); }
.timeline__meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; font-size: var(--fs-meta); color: var(--muted); min-height: 24px; }
.timeline__meta time { color: var(--ink-strong); font-weight: 500; font-variant-numeric: tabular-nums; }
.timeline__body { margin-top: 4px; color: var(--ink); }
.timeline__body p + p { margin-top: 6px; }
.timeline__body .prewrap { padding: 8px 10px; background: var(--gray-50); border-radius: var(--radius); }

/* ---------- notes: quiet cards ---------- */
.note { padding: 12px 14px; background: var(--gray-50); border: 1px solid var(--line-soft); border-radius: var(--radius-lg); }
.note:target { border-color: var(--blue-400); box-shadow: 0 0 0 3px var(--blue-50); }
.note__meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; font-size: var(--fs-meta); color: var(--muted); margin-bottom: 6px; }
.note__meta time { color: var(--ink-strong); font-weight: 500; font-variant-numeric: tabular-nums; }
.note__meta .btn { margin-left: auto; }
.note__body { color: var(--ink); }
.note .form { margin-top: 4px; }
.note .savebar { position: static; margin-top: 10px; padding: 10px 12px; box-shadow: none; justify-content: flex-start; }

/* ---------- banners, toasts ---------- */
.banner { display: flex; gap: 10px; align-items: flex-start; flex-wrap: wrap; padding: 12px 14px; margin-bottom: 16px; border-radius: var(--radius); border: 1px solid; }
.banner .icon { margin-top: 1px; }
.banner--success { background: var(--success-bg); border-color: #B9DCC7; color: var(--success-ink); }
.banner--info { background: var(--info-bg); border-color: var(--blue-100); color: var(--blue-800); }
.banner--warning { background: var(--warning-bg); border-color: #EBD3A5; color: var(--warning-ink); }
.banner--danger { background: var(--danger-bg); border-color: #E9B4AE; color: var(--danger); }
.banner__text { flex: 1 1 100%; }
.banner .dl { flex: 1 1 100%; margin-top: 4px; color: var(--ink); }
.banner .dl dt { color: inherit; opacity: .8; }
.banner ul { flex: 1 1 100%; padding-left: 18px; }
.banner:focus { outline: 2px solid currentColor; outline-offset: 2px; }

.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 60; display: flex; flex-direction: column; gap: 10px; max-width: 420px; }
.toast { display: flex; align-items: center; gap: 10px; padding: 12px 12px 12px 14px; background: var(--blue-900); color: #fff; border-radius: var(--radius-lg); box-shadow: var(--shadow-2); animation: toast-in var(--dur) var(--ease); }
.toast--success .toast__icon { color: #7CD9A5; }
.toast--warning .toast__icon { color: #F2C572; }
.toast--info .toast__icon { color: var(--blue-400); }
.toast--danger { background: var(--danger); }
.toast__body { flex: 1; }
.toast__form { margin: 0; }
.toast__close { background: none; border: 0; color: rgba(255, 255, 255, .7); width: 32px; height: 32px; display: grid; place-items: center; border-radius: var(--radius); }
.toast__close:hover { color: #fff; background: rgba(255, 255, 255, .1); }
.toast__close:focus-visible, .btn--undo:focus-visible { outline-color: #fff; }
.toast.is-leaving { opacity: 0; transform: translateY(6px); transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- empty state ---------- */
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; padding: 48px 24px; background: var(--paper); border: 1px dashed var(--gray-300); border-radius: var(--radius-lg); }
.empty__icon { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 50%; background: var(--blue-50); color: var(--blue-700); margin-bottom: 4px; }
.empty__icon .icon { width: 24px; height: 24px; }
.empty__title { font-size: var(--fs-h2); font-weight: 600; color: var(--ink-strong); }
.empty__text { max-width: 440px; }
.empty .btn { margin-top: 8px; }

/* ---------- dialog ---------- */
.dialog { width: min(480px, calc(100vw - 32px)); padding: 0; border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-2); color: var(--ink); }
.dialog::backdrop { background: rgba(22, 40, 59, .45); }
.dialog__form { display: flex; flex-direction: column; }
.dialog__head { display: flex; align-items: center; justify-content: space-between; padding: 16px 16px 12px 20px; border-bottom: 1px solid var(--line-soft); }
.dialog__title { font-size: var(--fs-h2); font-weight: 600; color: var(--ink-strong); }
.dialog__body { padding: 16px 20px; display: flex; flex-direction: column; gap: 12px; }
.dialog__actions { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px 16px; border-top: 1px solid var(--line-soft); }
.confirm__expected { padding: 2px 6px; background: var(--gray-100); border-radius: var(--radius); color: var(--ink-strong); }

/* ---------- help panel ---------- */
.help-backdrop { position: fixed; inset: 0; z-index: 45; background: rgba(22, 40, 59, .2); }
.help-panel {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 50; width: min(440px, 100vw); display: flex; flex-direction: column;
  background: var(--paper); border-left: 1px solid var(--line); box-shadow: var(--shadow-2); transform: translateX(0); animation: help-in 200ms var(--ease);
}
@keyframes help-in { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.help-panel__head { display: flex; align-items: center; justify-content: space-between; height: var(--topbar-h); padding: 0 12px 0 20px; border-bottom: 1px solid var(--line); }
.help-panel__title { font-size: var(--fs-h2); font-weight: 600; color: var(--ink-strong); }
.help-panel__search { position: relative; padding: 12px 16px; border-bottom: 1px solid var(--line-soft); }
.help-panel__search .input { padding-left: 38px; }
.help-panel__search-icon { position: absolute; left: 26px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.help-panel__body { flex: 1; overflow-y: auto; padding: 8px 16px 16px; }
.help-panel__section + .help-panel__section { margin-top: 16px; }
.help-panel__section-title { font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); padding: 10px 0 4px; }
.help-panel__empty { padding: 16px 0; }
.help-panel__foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 16px; border-top: 1px solid var(--line); font-size: var(--fs-meta); }
.help-panel__hint { text-align: right; }
.help-topic { border-bottom: 1px solid var(--line-soft); }
.help-topic__summary { list-style: none; display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: var(--touch); padding: 8px 0; cursor: pointer; font-weight: 500; color: var(--ink-strong); }
.help-topic__summary::-webkit-details-marker { display: none; }
.help-topic__summary::after { content: "+"; color: var(--muted); font-size: 18px; line-height: 1; }
.help-topic[open] .help-topic__summary::after { content: "–"; }
.help-topic__summary:hover { color: var(--blue-800); }
.help-topic__body { padding: 0 0 14px; color: var(--ink); }
.help-topic__body p + p, .help-topic__body p + ol, .help-topic__body ol + p, .help-topic__body ul + p, .help-topic__body p + ul { margin-top: 8px; }
.help-topic__body ol, .help-topic__body ul { padding-left: 20px; }
.help-topic__body li { margin: 4px 0; }
.help-topic__body .help-note { padding: 8px 12px; margin-top: 10px; background: var(--blue-50); border-left: 3px solid var(--blue-400); border-radius: var(--radius); }
.help-topic__body--page { font-size: 14.5px; }
.help-topic.is-hidden { display: none; }
.help-page .card + .card { margin-top: var(--gap); }
.help-article { scroll-margin-top: calc(var(--topbar-h) + 16px); }
.help-toc { position: sticky; top: calc(var(--topbar-h) + 16px); }
body.help-open { overflow: hidden; }

/* ---------- auth layout ---------- */
.auth { background: var(--ground); }
.auth__shell { min-height: 100vh; display: flex; flex-direction: column; }
.auth__head { display: flex; align-items: center; justify-content: space-between; padding: 16px 24px; }
.auth__brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 600; color: var(--ink-strong); text-decoration: none; }
.auth__main { flex: 1; display: flex; align-items: flex-start; justify-content: center; padding: 24px 16px 40px; }
.auth__foot { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 16px; font-size: var(--fs-meta); }
.auth-card { width: min(440px, 100%); padding: 28px; }
.auth-card--wide { width: min(760px, 100%); }
.auth-card__title { font-size: var(--fs-h1); font-weight: 600; color: var(--ink-strong); margin-bottom: 6px; }
.auth-card__lead { margin-bottom: 20px; }
.auth-card__foot { margin-top: 20px; font-size: var(--fs-meta); }
.auth-card__links { display: flex; flex-wrap: wrap; gap: 8px 20px; margin-top: 18px; font-size: 13px; align-items: center; }
.enrol { display: grid; grid-template-columns: 236px 1fr; gap: 24px; align-items: start; }
.enrol__qr { padding: 8px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius-lg); }
.enrol__qr svg { width: 100%; height: auto; display: block; }
.enrol__steps { display: flex; flex-direction: column; gap: 16px; }
.secret { display: block; padding: 10px 12px; background: var(--gray-50); border: 1px solid var(--line-soft); border-radius: var(--radius); letter-spacing: .08em; word-break: break-all; }
.codes { list-style: none; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 16px 0; }
.codes li code { display: block; padding: 10px 12px; background: var(--gray-50); border: 1px solid var(--line-soft); border-radius: var(--radius); font-size: 16px; letter-spacing: .1em; text-align: center; color: var(--ink-strong); }

/* ---------- error page ---------- */
.error-card { max-width: 560px; margin: 40px auto; text-align: center; padding: 40px 32px; }
.error-card__icon { display: inline-grid; place-items: center; width: 56px; height: 56px; border-radius: 50%; background: var(--blue-50); color: var(--blue-700); margin-bottom: 12px; }
.error-card__icon .icon { width: 28px; height: 28px; }
.error-card__code { font-family: var(--mono); color: var(--muted); font-size: var(--fs-meta); letter-spacing: .1em; }
.error-card__title { font-size: var(--fs-h1); font-weight: 600; color: var(--ink-strong); margin: 4px 0 8px; }
.error-card__text { color: var(--muted); margin-bottom: 20px; }
.error-card__rid { margin-top: 20px; font-size: var(--fs-meta); }
.error-card .details { text-align: left; margin-bottom: 16px; }

/* ---------- combobox (island) ---------- */
.combobox { position: relative; }
.combobox__list { position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 35; max-height: 260px; overflow-y: auto; list-style: none; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-2); }
.combobox__option, .combobox__empty { padding: 8px 12px; min-height: 36px; display: flex; align-items: center; cursor: pointer; }
.combobox__option:hover, .combobox__option.is-active { background: var(--blue-50); color: var(--blue-800); }
.combobox__empty { color: var(--muted); cursor: default; }

/* ---------- responsive ---------- */
@media (min-width: 1101px) { body.help-open { overflow: auto; } .help-backdrop { display: none; } }
@media (max-width: 1100px) {
  .rail { width: var(--rail-w-narrow); }
  .rail__brand-text, .rail__label, .rail__group-label, .rail__version { display: none; }
  .rail__brand { justify-content: center; padding: 0; }
  .rail__link { justify-content: center; padding: 10px; }
  .rail__foot { justify-content: center; padding: 12px 6px; }
  .rail__env { font-size: 9px; padding: 2px 4px; }
  .main { padding: 20px 20px 96px; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid--main-side { grid-template-columns: 1fr; }
  .help-toc { position: static; }
  .page-head--case { grid-template-columns: 1fr; }
  .page-head--case .page-head__actions { justify-self: stretch; }
  .status-control { width: 100%; }
  .case-context { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .case-context > :nth-child(3) { grid-column: 1 / -1; }
  .case-context > :nth-child(3) .inline-form .select { max-width: 320px; }
}
@media (max-width: 860px) {
  .grid--2, .grid--3 { grid-template-columns: 1fr; }
  .case-context { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .case-context > :nth-child(3) { grid-column: 1 / -1; }
  .form--inline-grid { grid-template-columns: 1fr; }
  .settings-row { grid-template-columns: 1fr; gap: 8px; }
  .enrol { grid-template-columns: 1fr; }
  .enrol__qr { max-width: 236px; }
  .topbar__help span, .usermenu__name { display: none; }
  .filters__actions { margin-left: 0; flex: 1 1 100%; }
}
@media (max-width: 640px) {
  .shell { flex-direction: column; }
  .rail { position: fixed; left: 0; top: 0; z-index: 55; width: var(--rail-w); height: 100vh; transform: translateX(-100%); transition: transform 200ms var(--ease); box-shadow: var(--shadow-2); }
  .rail.is-open { transform: none; }
  .rail__brand-text, .rail__label, .rail__group-label, .rail__version { display: initial; }
  .rail__brand { justify-content: flex-start; padding: 0 14px; }
  .rail__link { justify-content: flex-start; padding: 8px 10px; }
  .rail__foot { justify-content: space-between; padding: 12px 14px; }
  .topbar { padding: 0 12px; gap: 8px; }
  .topbar__menu { display: inline-flex; }
  .topbar__search { max-width: none; }
  .lang__btn { min-width: 36px; }
  .main { padding: 16px 12px 96px; }
  .page-head { grid-template-columns: 1fr; }
  .page-head__actions { justify-self: stretch; justify-content: flex-start; }
  .status-control__field { flex-basis: 140px; }
  .status-control__field--wide, .status-control__actions { flex: 1 1 100%; }
  .tiles { grid-template-columns: 1fr; }
  .case-context { grid-template-columns: 1fr; }
  .case-context > :nth-child(3) { grid-column: auto; }
  .card { padding: 16px; }
  .card > .table__wrap { margin: 0 -16px; padding: 0 16px; }
  /* fact and definition lists: label above value, so a long value or badge row never leaves the card */
  .facts__row { grid-template-columns: 1fr; gap: 4px; padding: 8px 0; }
  .dl { grid-template-columns: minmax(96px, 36%) 1fr; }
  .case-context .dl { grid-template-columns: minmax(72px, 32%) 1fr; }
  .form__row { flex-direction: column; }
  .filters { padding: 12px; }
  .filters__row > .field { flex: 1 1 100%; max-width: none; }
  .savebar { padding: 10px 12px; }
  .toasts { left: 12px; right: 12px; bottom: 12px; max-width: none; }
  .codes { grid-template-columns: 1fr; }
  .auth-card { padding: 20px; }
  .timeline { padding-left: 24px; }
  .timeline__item::before { left: -20px; }
}
@media (hover: none) and (pointer: coarse) {
  .btn, .btn--small, .input, .select, .select--small, .rail__link, .usermenu__summary, .tabs__tab, .help-topic__summary, .lang__btn, .menu__item, .link--button, .th-sort__link, .toast__close, .field--check, .row-actions .input { min-height: var(--touch); }
  .toast__close { width: var(--touch); }
  .btn--icon { width: var(--touch); }
  .status-control .select, .status-control .input, .status-control__actions .btn { min-height: var(--touch); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- print ---------- */
@media print {
  body { background: #fff; color: #000; font-size: 12px; }
  .rail, .topbar, .toasts, .help-panel, .help-backdrop, .savebar, .page-head__actions, .filters, .pagination__links, .td-actions, .th-actions, .row-actions, .status-control, .skip-link, .lang, .auth__head .lang, .btn, .inline-form, .tabs__tab.is-disabled, .case-context .inline-form, .note__meta .btn { display: none !important; }
  .main { max-width: none; padding: 0; }
  .card, .tile, .empty, .note { box-shadow: none; border-color: #999; break-inside: avoid; }
  .card--danger, .card--warning, .card--accent { background: #fff; }
  .card--table, .table__wrap { overflow: visible; }
  .grid, .tiles { display: block; }
  .grid > * + *, .tiles > * + * { margin-top: 12px; }
  .tabs { box-shadow: none; border-bottom: 1px solid #999; overflow: visible; }
  .tabs__tab { color: #666; }
  .tabs__tab.is-active { color: #000; border-bottom-color: #000; }
  .badge, .tag { border: 1px solid #999; background: #fff !important; color: #000 !important; }
  [class*="badge--type-"]::before { background: #000; }
  .timeline::before { background: #999; }
  .timeline__item::before { background: #000; box-shadow: none; }
  .timeline__item { break-inside: avoid; }
  .help-topic { break-inside: avoid; }
  .help-topic__body { display: block !important; }
  a { color: #000; text-decoration: none; }
  a.mono, .mono { color: #000; }
  .codes li code { border-color: #000; }
}
