:root {
  --ground: #f6f7f9;
  --surface: #ffffff;
  --raised: #eceef1;
  --border: #e6e8ec;
  --rule: #f0f1f3;
  --control: #d6d9de;
  --text: #0a0a0a;
  --muted: #6b6f76;
  --faint: #9a9ea5;
  --accent: #141414;
  --chart: #1d5fbf;
  --chart-soft: #dbe7f8;
  --positive: #2e7d32;
  --negative: #c4242a;
  --warning: #92400e;
  --radius-card: 8px;
  --radius-control: 6px;
  --row-height: 48px;
  --rail-width: 56px;
  --gap: 12px;
  --pad: 24px;
  --control-height: 36px;
  --fs-title: 24px;
  --fs-section: 16px;
  --fs-kpi: 30px;
  --fs-body: 14px;
  --fs-small: 12px;
  --font: "Geist", "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "Geist Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--ground);
  color: var(--text);
  font-family: var(--font);
  font-size: var(--fs-body);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
[hidden] { display: none !important; }

:focus-visible {
  outline: 2px solid var(--chart);
  outline-offset: 2px;
}

/* Shell ------------------------------------------------------------------ */
.app-shell {
  min-height: 100svh;
  display: grid;
  grid-template-columns: var(--rail-width) minmax(0, 1fr);
}
.rail {
  position: sticky;
  top: 0;
  height: 100svh;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 0;
  z-index: 10;
}
.brand {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: var(--text);
}
.brand svg { width: 24px; height: 24px; }
.rail-nav {
  margin-top: 20px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
  align-items: center;
}
.rail-link {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: var(--muted);
  position: relative;
}
.rail-link:hover { background: var(--ground); color: var(--text); }
.rail-link[aria-current="page"] { background: var(--raised); color: var(--text); }
.rail-link svg { width: 19px; height: 19px; }
.rail-label { display: none; }
.rail-tip {
  position: absolute;
  left: 48px;
  top: 50%;
  transform: translateY(-50%);
  background: var(--text);
  color: #fff;
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 4px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity .12s ease;
}
.rail-link:hover .rail-tip, .rail-link:focus-visible .rail-tip { opacity: 1; }
.rail-bottom {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.rail-sep { width: 24px; height: 1px; background: var(--border); margin: 4px 0; }
.icon-btn {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border: 0;
  background: transparent;
  border-radius: 6px;
  color: var(--muted);
}
.icon-btn:hover { background: var(--raised); color: var(--text); }
.icon-btn svg { width: 18px; height: 18px; }
.avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .01em;
  color: #2d3137;
  background: var(--raised);
  border: 1px solid rgba(0,0,0,.05);
}
.avatar.portrait {
  display: block;
  object-fit: cover;
  background: var(--raised);
}
.avatar-button {
  border: 0;
  padding: 0;
  font-family: inherit;
  color: inherit;
  cursor: pointer;
}
.avatar-button:focus-visible {
  outline: 2px solid var(--chart);
  outline-offset: 2px;
}
.avatar.missing {
  background: var(--raised);
  color: var(--muted);
  border: 1px dashed var(--control);
  font-weight: 500;
}

.main { min-width: 0; }
.page {
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: 32px 36px 72px;
}

/* Type ------------------------------------------------------------------- */
h1, h2, h3, p { margin: 0; }
h1 { font-size: var(--fs-title); line-height: 1.15; font-weight: 600; letter-spacing: -.02em; }
h2 { font-size: var(--fs-section); line-height: 1.25; font-weight: 600; letter-spacing: -.01em; }
h3 { font-size: 14px; font-weight: 600; }
.sub { color: var(--muted); font-size: 13px; margin-top: 6px; }
.finding { color: var(--muted); font-size: 13px; margin-top: 14px; max-width: 76ch; }
.mono { font-family: var(--mono); font-size: 12px; letter-spacing: -.01em; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: var(--fs-small); }
.nowrap { white-space: nowrap; }

/* Buttons ---------------------------------------------------------------- */
.btn {
  height: var(--control-height);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 13px;
  border-radius: var(--radius-control);
  border: 1px solid transparent;
  background: transparent;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  transition: background .12s ease, border-color .12s ease, transform .08s ease;
}
.btn:active { transform: translateY(1px); }
.btn svg { width: 15px; height: 15px; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: #2a2a2a; }
.btn-secondary { background: var(--raised); color: var(--text); }
.btn-secondary:hover { background: #e2e5e9; }
.btn-ghost { border-color: var(--border); background: var(--surface); }
.btn-ghost:hover { background: var(--ground); }
.btn-danger { color: var(--negative); border-color: #f0d2d4; background: #fff; }
.btn-danger:hover { background: #fff5f5; }
.btn-sm { height: 30px; padding: 0 10px; font-size: 12px; }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn-link { border: 0; background: transparent; padding: 0; color: var(--chart); font-size: 13px; }
.btn-link:hover { text-decoration: underline; }

/* Title row -------------------------------------------------------------- */
.title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 22px;
}
.title-row .actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

/* Panels ----------------------------------------------------------------- */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  min-width: 0;
}
.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--rule);
}
.panel-head .panel-sub { color: var(--muted); font-size: 12px; margin-top: 3px; }
.panel-body { padding: 18px; }
.panel-body.flush { padding: 0; }
.panel-foot {
  padding: 12px 18px;
  border-top: 1px solid var(--rule);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 12px;
}

/* KPI strip -------------------------------------------------------------- */
.kpi-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  overflow: hidden;
  margin-bottom: var(--gap);
}
.kpi {
  padding: 17px 20px 18px;
  min-width: 0;
  border-left: 1px solid var(--rule);
}
.kpi:first-child { border-left: 0; }
.kpi-label { font-size: 12px; color: var(--muted); }
.kpi-value {
  margin-top: 7px;
  font-size: var(--fs-kpi);
  line-height: 1;
  font-weight: 500;
  letter-spacing: -.03em;
  font-variant-numeric: tabular-nums;
}
.kpi-value .unit { font-size: 14px; font-weight: 400; color: var(--muted); letter-spacing: 0; margin-left: 4px; }
.kpi-meta { margin-top: 7px; font-size: 12px; color: var(--muted); }

/* Grid ------------------------------------------------------------------- */
.grid-main {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr);
  gap: var(--gap);
  align-items: start;
}
.stack { display: grid; gap: var(--gap); }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--gap); align-items: start; }

/* Quality block ---------------------------------------------------------- */
.quality-top {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding: 18px 18px 14px;
}
.quality-figure { font-size: 42px; line-height: .95; font-weight: 500; letter-spacing: -.04em; font-variant-numeric: tabular-nums; }
.quality-caption { margin-top: 7px; color: var(--muted); font-size: 12px; }
.quality-aside { text-align: right; color: var(--muted); font-size: 12px; }
.quality-aside strong { display: block; color: var(--text); font-size: 18px; font-weight: 500; font-variant-numeric: tabular-nums; margin-top: 3px; }

.meter { padding: 0 18px 18px; }
.meter-track {
  height: 9px;
  border-radius: 99px;
  background: var(--raised);
  display: flex;
  overflow: hidden;
}
.meter-fill { background: var(--chart); height: 100%; }
.meter-fill.neutral { background: #c9cdd3; }
.meter-legend { display: flex; align-items: center; gap: 16px; margin-top: 9px; color: var(--muted); font-size: 12px; }
.meter-legend span { display: inline-flex; align-items: center; gap: 6px; }
.swatch { width: 7px; height: 7px; border-radius: 2px; background: var(--chart); display: inline-block; }
.swatch.neutral { background: #c9cdd3; }

/* Tables ----------------------------------------------------------------- */
.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left;
  font-size: 12px;
  font-weight: 400;
  color: var(--muted);
  padding: 10px 12px;
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}
td {
  padding: 12px;
  border-bottom: 1px solid var(--rule);
  vertical-align: middle;
  font-size: 13px;
}
tbody tr:last-child td { border-bottom: 0; }
tbody tr { transition: background .1s ease; }
tbody tr:hover { background: #fafbfc; }
tr.clickable { cursor: pointer; }
th.r, td.r { text-align: right; font-variant-numeric: tabular-nums; }
td.strong { font-weight: 500; }
.cell-main { display: flex; align-items: center; gap: 10px; min-width: 0; }
.cell-main .who { min-width: 0; }
.cell-main .who .name { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cell-main .who .subline { color: var(--muted); font-size: 12px; margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-actions { display: flex; gap: 4px; justify-content: flex-end; opacity: .65; transition: opacity .1s; }
tr:hover .row-actions, tr:focus-within .row-actions { opacity: 1; }

/* Status / chips --------------------------------------------------------- */
.status { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; white-space: nowrap; }
.status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--faint); }
.status.active::before { background: var(--positive); }
.status.revoked::before, .status.rejected::before, .status.no_match::before { background: var(--negative); }
.status.match::before { background: var(--positive); }
.status.suspended::before, .status.warning::before { background: var(--warning); }
.status.match, .status.active { color: #245e29; }
.status.no_match, .status.revoked, .status.rejected { color: #8d2024; }
.status.suspended, .status.warning { color: var(--warning); }
.chip {
  display: inline-flex;
  align-items: center;
  height: 21px;
  padding: 0 7px;
  border-radius: 4px;
  background: var(--raised);
  color: #3d4148;
  font-size: 11px;
  white-space: nowrap;
}
.chip.outline { background: transparent; border: 1px solid var(--border); color: var(--muted); }
.chip.blue { background: var(--chart-soft); color: #17498f; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; max-width: 360px; }

/* Tabs / toolbar --------------------------------------------------------- */
.tabs {
  display: flex;
  gap: 22px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}
.tab {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  padding: 0 0 11px;
  position: relative;
}
.tab[aria-selected="true"] { color: var(--text); font-weight: 500; }
.tab[aria-selected="true"]::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -1px;
  height: 2px;
  background: var(--text);
}
.tab .count { color: var(--faint); margin-left: 5px; font-size: 12px; }
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}
.search {
  width: min(300px, 100%);
  height: 34px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  padding: 0 11px;
  font-size: 13px;
}
.search::placeholder { color: var(--faint); }
.toolbar-meta { color: var(--muted); font-size: 12px; }

/* Forms ------------------------------------------------------------------ */
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field > label { font-size: 12px; color: var(--muted); }
.input, .select, .textarea {
  width: 100%;
  height: 38px;
  border: 1px solid var(--control);
  border-radius: var(--radius-control);
  background: var(--surface);
  padding: 0 10px;
  font-size: 13px;
}
.textarea { height: auto; min-height: 76px; padding: 9px 10px; resize: vertical; }
.select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 15px) 16px, calc(100% - 10px) 16px; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 28px; }
.input::placeholder, .textarea::placeholder { color: var(--faint); }
.input:focus, .select:focus, .textarea:focus { outline: 2px solid var(--chart-soft); border-color: var(--chart); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-note { color: var(--muted); font-size: 12px; margin-top: -4px; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }

.checks { display: grid; grid-template-columns: 1fr 1fr; gap: 7px 14px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 12px; color: #33363b; }
.check input { width: 14px; height: 14px; accent-color: var(--accent); }
.check code { font-family: var(--mono); font-size: 11px; }

.dropzone {
  border: 1px dashed var(--control);
  border-radius: var(--radius-card);
  background: #fbfcfd;
  min-height: 166px;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 18px;
  position: relative;
  transition: border-color .12s ease, background .12s ease;
}
.dropzone:hover, .dropzone.dragover { border-color: var(--chart); background: #f7faff; }
.dropzone input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.dropzone .dz-icon { width: 34px; height: 34px; color: var(--muted); margin: 0 auto 8px; }
.dropzone .dz-title { font-weight: 500; font-size: 13px; }
.dropzone .dz-sub { color: var(--muted); font-size: 12px; margin-top: 4px; }
.preview-wrap { position: relative; display: none; }
.preview-wrap.show { display: block; }
.preview-img { width: 100%; max-height: 280px; object-fit: contain; border-radius: 6px; background: #0a0a0a; display: block; }
.preview-clear { position: absolute; top: 8px; right: 8px; background: rgba(10,10,10,.78); color: #fff; border: 0; border-radius: 5px; padding: 5px 8px; font-size: 11px; }

/* Results ---------------------------------------------------------------- */
.result { display: grid; gap: 14px; }
.result-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; }
.result-decision { font-size: 28px; font-weight: 600; letter-spacing: -.03em; line-height: 1; }
.result-decision.match { color: #226127; }
.result-decision.no_match { color: #9c2327; }
.result-decision.rejected { color: var(--warning); }
.result-sub { color: var(--muted); font-size: 12px; margin-top: 6px; }
.result-figures {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0;
  border: 1px solid var(--rule);
  border-radius: 6px;
  overflow: hidden;
}
.result-figure { padding: 11px 12px; border-left: 1px solid var(--rule); }
.result-figure:first-child { border-left: 0; }
.result-figure .lab { color: var(--muted); font-size: 11px; }
.result-figure .val { font-size: 17px; margin-top: 3px; font-variant-numeric: tabular-nums; }
.confidence { position: relative; padding-top: 4px; }
.confidence-track { height: 8px; border-radius: 99px; background: var(--raised); overflow: hidden; }
.confidence-fill { height: 100%; background: var(--chart); border-radius: 99px; }
.confidence-mark { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--text); }
.confidence-labels { display: flex; justify-content: space-between; color: var(--muted); font-size: 11px; margin-top: 7px; }
.reasons { display: flex; flex-wrap: wrap; gap: 5px; }
.empty {
  padding: 48px 24px;
  text-align: center;
  color: var(--muted);
}
.empty .empty-title { color: var(--text); font-weight: 500; font-size: 14px; margin-bottom: 4px; }
.empty .empty-sub { font-size: 12px; max-width: 46ch; margin: 0 auto 14px; }
.inline-error { color: var(--negative); font-size: 12px; margin-top: 10px; }

/* Key secret ------------------------------------------------------------- */
.secret-box {
  background: #0a0a0a;
  color: #fff;
  border-radius: 6px;
  padding: 12px;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.6;
  word-break: break-all;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.secret-box code { flex: 1; min-width: 0; }
.warning-box {
  border: 1px solid #f0d8b8;
  background: #fffaf1;
  color: #6d4608;
  border-radius: 6px;
  padding: 10px 12px;
  font-size: 12px;
  line-height: 1.5;
}

/* Definition rows -------------------------------------------------------- */
.defs { display: grid; }
.def {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 0;
  border-bottom: 1px solid var(--rule);
  font-size: 13px;
}
.def:last-child { border-bottom: 0; }
.def .def-label { color: var(--muted); }
.def .def-value { font-variant-numeric: tabular-nums; }
.def .def-value.mono { font-family: var(--mono); font-size: 12px; }

/* Coverage --------------------------------------------------------------- */
.coverage-number { font-size: 24px; font-weight: 500; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.coverage-track { height: 8px; border-radius: 99px; background: var(--raised); overflow: hidden; margin: 10px 0 7px; }
.coverage-fill { height: 100%; background: var(--chart); }
.coverage-note { color: var(--muted); font-size: 12px; }

/* Modal ------------------------------------------------------------------ */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(10, 10, 10, .38);
  display: grid;
  place-items: center;
  padding: 24px;
  z-index: 100;
}
.modal-card {
  width: min(560px, 100%);
  max-height: min(86svh, 820px);
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 18px 50px rgba(10, 10, 10, .16);
  padding: 22px;
}
.modal-card.wide { width: min(720px, 100%); }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.modal-head h2 { font-size: 18px; }
.modal-sub { color: var(--muted); font-size: 12px; margin-top: 4px; }
.modal-close { width: 30px; height: 30px; border: 0; background: transparent; color: var(--muted); border-radius: 5px; display: grid; place-items: center; }
.modal-close:hover { background: var(--raised); color: var(--text); }

/* Toast ------------------------------------------------------------------ */
.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  background: var(--text);
  color: #fff;
  border-radius: 6px;
  padding: 9px 13px;
  font-size: 12px;
  z-index: 200;
  max-width: min(520px, calc(100vw - 32px));
}
.toast.error { background: #7f1d1d; }

/* Login ------------------------------------------------------------------ */
.login-screen {
  min-height: 100svh;
  display: grid;
  grid-template-columns: minmax(560px, 1.08fr) minmax(440px, .92fr);
  background: var(--ground);
}
.login-story {
  background: #0b0d10;
  color: #fff;
  padding: clamp(36px, 4vw, 56px);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 100svh;
}
.login-wordmark { display: flex; align-items: center; gap: 10px; font-weight: 600; letter-spacing: -.02em; }
.login-wordmark svg { width: 26px; height: 26px; }
.login-story h1 { font-size: clamp(42px, 4vw, 56px); line-height: 1.02; letter-spacing: -.045em; max-width: 10ch; margin-top: 24px; }
.login-story .story-copy { color: #c2c6cd; font-size: 15px; line-height: 1.55; max-width: 42ch; margin-top: 18px; }
.login-footnote { color: #a6abb3; font-size: 13px; }
.login-side {
  display: grid;
  place-items: center;
  padding: clamp(36px, 6vw, 80px);
}
.login-form { width: min(440px, 100%); }
.login-form h2 { font-size: 26px; letter-spacing: -.035em; }
.login-form .login-sub { color: #5f646c; font-size: 14px; margin-top: 8px; line-height: 1.5; }
.login-form .field { margin-top: 22px; margin-bottom: 0; }
.login-form .field + .field { margin-top: 17px; }
.login-form .field > label { color: #50555d; font-size: 13px; }
.login-form .input { height: 44px; padding-inline: 12px; font-size: 14px; }
.login-form .btn { width: 100%; height: 44px; margin-top: 22px; }
.login-note { color: #626871; font-size: 13px; line-height: 1.55; margin-top: 28px; padding-top: 18px; border-top: 1px solid var(--border); }
.login-note strong { color: #30343a; font-weight: 500; }
.login-error { color: var(--negative); font-size: 12px; margin-top: 12px; min-height: 16px; }

/* Utilities -------------------------------------------------------------- */
.spacer { flex: 1; }
.right { text-align: right; }
.flex { display: flex; align-items: center; gap: 8px; }
.between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.mt-0 { margin-top: 0; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.section-title { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 24px 0 10px; }
.section-title h2 { font-size: 14px; }
.section-title .small { color: var(--muted); }
.inline { display: inline; }
.pagination {
  min-height: 52px;
  padding: 10px 16px;
  border-top: 1px solid var(--rule);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  color: var(--muted);
  font-size: 12px;
}
.subject-portrait {
  width: 100%;
  height: min(300px, 42vh);
  margin-bottom: 16px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--raised);
}
.subject-portrait img { width: 100%; height: 100%; display: block; object-fit: contain; }
.stream-state {
  height: 30px;
  padding: 0 10px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}
.stream-state i { width: 7px; height: 7px; border-radius: 50%; background: #a7abb2; }
.stream-state.live { color: #226b45; border-color: #cce5d7; background: #f3faf6; }
.stream-state.live i { background: #2f9b62; box-shadow: 0 0 0 3px rgba(47,155,98,.12); }
.stream-state.reconnecting { color: #8a641b; border-color: #eadcb8; background: #fffaf0; }
.stream-state.reconnecting i { background: #c28a22; }
.stream-state.error { color: var(--negative); border-color: #f0d2d4; background: #fff5f5; }
.stream-state.error i { background: var(--negative); }
.transaction-toolbar { justify-content: space-between; }
.transactions-table { min-width: 760px; }
.transactions-table td { vertical-align: middle; }
.transactions-table .cell-main { min-width: 180px; }
.transaction-new { background: #f3faf6; }

/* Responsive ------------------------------------------------------------- */
@media (max-width: 980px) {
  .grid-main { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .app-shell { grid-template-columns: 1fr; }
  .rail {
    position: fixed;
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    height: 62px;
    width: 100%;
    flex-direction: row;
    justify-content: space-around;
    padding: 4px 6px;
    border-right: 0;
    border-top: 1px solid var(--border);
  }
  .brand { display: none; }
  .rail-nav { flex: 1; flex-direction: row; margin: 0; width: auto; gap: 2px; overflow-x: auto; scrollbar-width: none; }
  .rail-nav::-webkit-scrollbar { display: none; }
  .rail-link { width: auto; min-width: 54px; height: 52px; display: flex; flex-direction: column; gap: 3px; padding: 4px 6px; }
  .rail-link .rail-label { display: block; font-size: 11px; color: inherit; }
  .rail-tip { display: none; }
  .rail-bottom { margin: 0; flex-direction: row; gap: 2px; }
  .rail-sep { display: none; }
  .rail-bottom .avatar { display: none; }
  .icon-btn { height: 48px; }
  .page { padding: 24px 16px 92px; }
  .title-row { flex-direction: column; gap: 14px; margin-bottom: 18px; }
  .title-row .actions { width: 100%; }
  .title-row .actions .btn { flex: 1; }
  .kpi-strip { grid-template-columns: 1fr 1fr; }
  .kpi { border-left: 0; border-top: 1px solid var(--rule); }
  .kpi:nth-child(-n+2) { border-top: 0; }
  .kpi:nth-child(even) { border-left: 1px solid var(--rule); }
  .quality-figure { font-size: 34px; }
  .result-figures { grid-template-columns: 1fr 1fr; }
  .result-figure:nth-child(3) { border-left: 0; border-top: 1px solid var(--rule); }
  .result-figure:nth-child(4) { border-top: 1px solid var(--rule); }
  .grid-2 { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .checks { grid-template-columns: 1fr; }
  .hide-sm { display: none !important; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}

/* Small additions used by the console ------------------------------------- */
.avatar.lg { width: 42px; height: 42px; font-size: 14px; }
.subline { color: var(--muted); font-size: 12px; }
.strong { font-weight: 500; }
.code-block {
  margin: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #f6f7f9;
  padding: 12px;
  overflow: auto;
  max-height: 240px;
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  color: #33363b;
}

/* Developer API reference ------------------------------------------------ */
.api-start { display: grid; grid-template-columns: minmax(0, 1fr) minmax(260px, .55fr); gap: 28px; padding: 22px; margin-bottom: 14px; }
.api-start-main { max-width: 72ch; }
.api-start-main h2 { margin: 0 0 7px; font-size: 18px; }
.api-start-main > p { margin: 0 0 15px; color: var(--muted); }
.api-start-main .code-block { max-height: none; white-space: pre; }
.api-start-facts { display: grid; align-content: center; }
.api-start-facts > div { display: flex; justify-content: space-between; gap: 18px; padding: 10px 0; border-bottom: 1px solid var(--rule); }
.api-start-facts > div:last-child { border-bottom: 0; }
.api-start-facts span { color: var(--muted); font-size: 12px; }
.api-start-facts strong { font-size: 12px; font-weight: 500; }
.api-toolbar { display: grid; grid-template-columns: minmax(240px, 1fr) minmax(180px, 240px) auto auto; align-items: center; gap: 10px; margin-bottom: 18px; }
.api-toolbar .select, .api-toolbar .search { width: 100%; }
.api-toolbar .check { white-space: nowrap; margin: 0; }
.api-toolbar .toolbar-meta { text-align: right; white-space: nowrap; }
.api-reference { display: grid; gap: 24px; }
.api-group-head { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin: 0 2px 8px; }
.api-group-head h2 { margin: 0; font-size: 16px; }
.api-group-head p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.api-group-head > span { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.api-operation { border-bottom: 1px solid var(--rule); }
.api-operation:last-child { border-bottom: 0; }
.api-operation > summary { display: grid; grid-template-columns: 62px minmax(230px, .8fr) minmax(220px, 1fr) auto; align-items: center; gap: 12px; min-height: 54px; padding: 8px 16px; cursor: pointer; list-style: none; }
.api-operation > summary::-webkit-details-marker { display: none; }
.api-operation > summary:hover { background: #fafbfc; }
.api-operation > summary:focus-visible { outline: 2px solid var(--chart); outline-offset: -2px; }
.api-operation[open] > summary { background: #fafbfc; border-bottom: 1px solid var(--rule); }
.api-method { display: inline-flex; justify-content: center; width: 58px; padding: 4px 6px; border-radius: 4px; font: 600 10px/1 var(--mono); letter-spacing: .04em; }
.api-method.get { color: #17498f; background: #e8f0fb; }
.api-method.post { color: #245e29; background: #e8f3e8; }
.api-method.put, .api-method.patch { color: #7a4a08; background: #f8efdc; }
.api-method.delete { color: #8d2024; background: #fbe9ea; }
.api-method.head, .api-method.options { color: #5d3c78; background: #f0e9f5; }
.api-path { overflow-wrap: anywhere; font-size: 12px; color: var(--text); }
.api-summary { min-width: 0; color: var(--muted); font-size: 13px; }
.chip.warning { color: #7a4a08; border-color: #ead8b6; background: #fffaf0; }
.api-operation-body { padding: 18px; }
.api-description { max-width: 75ch; margin: 0 0 14px; color: #45484d; }
.api-description code, .api-group-head code { font-family: var(--mono); font-size: .92em; background: var(--raised); padding: 1px 4px; border-radius: 3px; }
.api-contract-line { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 18px; }
.api-contract-line > span, .api-contract-line > code { border: 1px solid var(--border); border-radius: 999px; padding: 3px 7px; color: var(--muted); font-size: 11px; }
.api-contract-line > code { font-family: var(--mono); color: var(--text); }
.api-detail-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(320px, .9fr); gap: 24px; align-items: start; }
.api-detail-block + .api-detail-block { margin-top: 20px; }
.api-detail-block h4, .api-example h4 { margin: 0 0 8px; font-size: 12px; font-weight: 600; }
.api-detail-block h4 span { color: var(--muted); font-weight: 400; }
.api-def-list > div { display: grid; grid-template-columns: minmax(120px, .45fr) minmax(120px, .55fr); gap: 2px 12px; padding: 8px 0; border-bottom: 1px solid var(--rule); }
.api-def-list > div:last-child { border-bottom: 0; }
.api-def-list code { overflow-wrap: anywhere; font-family: var(--mono); font-size: 11px; }
.api-def-list span { color: var(--muted); font-size: 11px; }
.api-def-list p { grid-column: 1 / -1; margin: 2px 0 0; color: var(--muted); font-size: 12px; }
.api-response-list { display: grid; }
.api-response-list > div { display: grid; grid-template-columns: 48px 1fr; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--rule); }
.api-response-list > div:last-child { border-bottom: 0; }
.api-response-list code { font-family: var(--mono); font-size: 11px; }
.api-response-list span { color: var(--muted); font-size: 12px; }
.api-example { min-width: 0; position: sticky; top: 18px; }
.api-example .code-block { max-height: 420px; white-space: pre; }

@media (max-width: 900px) {
  .api-start { grid-template-columns: 1fr; }
  .api-toolbar { grid-template-columns: 1fr 1fr; }
  .api-toolbar .toolbar-meta { text-align: left; }
  .api-operation > summary { grid-template-columns: 62px minmax(0, 1fr); gap: 8px 10px; padding: 10px 12px; }
  .api-summary { grid-column: 2; }
  .api-operation > summary .chip { grid-column: 2; justify-self: start; }
  .api-detail-grid { grid-template-columns: 1fr; }
  .api-example { position: static; }
}

@media (max-width: 560px) {
  .api-toolbar { grid-template-columns: 1fr; }
  .api-start { padding: 16px; gap: 16px; }
  .api-operation-body { padding: 14px 12px; }
  .api-path { font-size: 11px; }
}
.sa-row { padding: 12px 18px; border-bottom: 1px solid var(--rule); }
.sa-row:last-child { border-bottom: 0; }
.sa-row .between { margin-bottom: 3px; }
.candidates { border-top: 1px solid var(--rule); }
.candidate-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 160px 28px;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--rule);
}
.candidate-row:last-child { border-bottom: 0; }
.candidate-row .cell-main { min-width: 0; }
.candidate-score { display: grid; gap: 5px; justify-items: end; }
.candidate-bar { width: 120px; height: 5px; border-radius: 99px; background: var(--raised); overflow: hidden; }
.candidate-bar > div { height: 100%; border-radius: 99px; background: var(--chart); }
@media (max-width: 720px) {
  #settings-link { display: none; }
  .rail-link { min-width: 44px; padding: 4px 3px; }
  .rail-link .rail-label { font-size: 11px; }
  .candidate-row { grid-template-columns: minmax(0, 1fr) 100px 22px; gap: 8px; }
  .candidate-bar { width: 80px; }
}

/* Dense table helpers ----------------------------------------------------- */
.truncate { display: block; max-width: 164px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.keys-table { min-width: 680px; }
.keys-table td:first-child { min-width: 190px; }
.keys-table td:nth-child(2) { max-width: 180px; }
.keys-table td:nth-child(3) .chips { flex-wrap: nowrap; max-width: none; }
.model-row { padding: 14px 18px; border-bottom: 1px solid var(--rule); }
.model-row:last-child { border-bottom: 0; }
.model-row .between { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }

/* Reports ---------------------------------------------------------------- */
.seg {
  display: inline-flex;
  padding: 2px;
  border-radius: 6px;
  background: var(--raised);
  gap: 2px;
}
.seg-item {
  height: 28px;
  padding: 0 10px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
}
.seg-item[aria-selected="true"] {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 2px rgba(0,0,0,.07);
}
.report-kpis { margin-top: 18px; }
.kpi-change { font-weight: 500; }
.kpi-change.good { color: var(--positive); }
.kpi-change.bad { color: var(--negative); }
.kpi-change.flat { color: var(--muted); }
.report-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(280px, .9fr);
  gap: var(--gap);
  margin-top: 12px;
  align-items: start;
}
.chart-body {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 10px;
  min-height: 238px;
}
.chart-y {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: flex-end;
  color: var(--faint);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
  padding: 4px 0 21px;
}
.bar-chart {
  display: flex;
  align-items: stretch;
  gap: 7px;
  min-height: 238px;
  padding-top: 12px;
  border-bottom: 1px solid var(--border);
}
.bar-col {
  flex: 1;
  min-width: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 7px;
}
.bar-plot {
  width: 100%;
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.bar-stack {
  width: min(30px, 82%);
  min-height: 2px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  overflow: hidden;
  border-radius: 3px 3px 0 0;
  background: var(--raised);
  transition: height .25s ease;
}
.bar-seg { width: 100%; }
.bar-seg.matched { background: var(--chart); }
.bar-seg.unmatched { background: #c9cdd3; }
.bar-seg.refused { background: #e6b8bb; }
.bar-label { font-size: 10px; color: var(--muted); white-space: nowrap; }
.chart-legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 14px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 11px;
}
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.swatch.grey { background: #c9cdd3; }
.swatch.pale { background: #e6b8bb; }
.chart-note { margin-left: auto; color: var(--faint); }
.outcome-total {
  font-size: 42px;
  line-height: .95;
  font-weight: 500;
  letter-spacing: -.04em;
  font-variant-numeric: tabular-nums;
}
.outcome-total span { font-size: 12px; font-weight: 400; letter-spacing: 0; color: var(--muted); margin-left: 7px; }
.outcomes { display: grid; gap: 13px; margin-top: 20px; }
.outcome-line { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; font-size: 12px; }
.outcome-line span { color: var(--muted); }
.outcome-line strong { font-weight: 500; font-variant-numeric: tabular-nums; }
.outcome-bar { height: 6px; border-radius: 99px; background: var(--raised); overflow: hidden; margin-top: 6px; }
.outcome-bar > div { height: 100%; border-radius: 99px; transition: width .3s ease; }
.outcome-bar .matched { background: var(--chart); }
.outcome-bar .unmatched { background: #c9cdd3; }
.outcome-bar .refused { background: #e6b8bb; }
.compare-note {
  margin-top: 18px;
  padding-top: 13px;
  border-top: 1px solid var(--rule);
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.55;
}
.history-table tr.current { background: #f7faff; }
.history-table tr.current td { border-bottom-color: #dbe7f8; }
.history-table th, .history-table td { padding: 10px 12px; }

/* Camera capture --------------------------------------------------------- */
.capture-source {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 12px;
  margin-bottom: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  background: var(--ground);
}
.capture-source-copy { display: grid; gap: 2px; min-width: 0; }
.capture-source-copy strong { font-size: 13px; font-weight: 500; }
.capture-source-copy span { color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.capture-source-actions { display: flex; align-items: center; gap: 7px; flex-shrink: 0; }
.capture-source-actions label.btn { cursor: pointer; }
.camera-stage {
  position: relative;
  aspect-ratio: 4 / 3;
  background: #0a0a0a;
  border-radius: 8px;
  overflow: hidden;
  margin: 14px 0 12px;
}
.camera-stage video { width: 100%; height: 100%; object-fit: cover; display: block; transform: scaleX(-1); }
.camera-guide { position: absolute; inset: 15% 24%; pointer-events: none; }
.camera-guide span { position: absolute; width: 24px; height: 24px; border-color: rgba(255,255,255,.85); border-style: solid; }
.camera-guide span:nth-child(1) { top: 0; left: 0; border-width: 1px 0 0 1px; }
.camera-guide span:nth-child(2) { top: 0; right: 0; border-width: 1px 1px 0 0; }
.camera-guide span:nth-child(3) { bottom: 0; left: 0; border-width: 0 0 1px 1px; }
.camera-guide span:nth-child(4) { bottom: 0; right: 0; border-width: 0 1px 1px 0; }
.camera-flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; }
.camera-flash.active { animation: camera-flash .28s ease-out; }
@keyframes camera-flash { 0% { opacity: .8; } 100% { opacity: 0; } }
.camera-hint { color: var(--muted); font-size: 12px; line-height: 1.55; }
.camera-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

/* Login descriptor field ------------------------------------------------ */
.scan {
  width: min(520px, 100%);
  aspect-ratio: 16 / 10;
  border: 1px solid rgba(255,255,255,.17);
  border-radius: 10px;
  background: #0e1013;
  margin-top: 28px;
  position: relative;
  overflow: hidden;
  cursor: crosshair;
}
.scan canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.scan-grid { display: none; }
.scan-top {
  position: absolute;
  top: 12px;
  left: 14px;
  right: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  pointer-events: none;
}
.scan-label { color: #a6abb3; font-size: 12px; }
.scan-state {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #b4b8bf;
  font-size: 12px;
}
.scan-state i { width: 6px; height: 6px; border-radius: 50%; background: #6d8fc4; }
.scan-state.live i { background: #9dc3ff; animation: scan-pulse 1.2s ease-in-out infinite; }
@keyframes scan-pulse { 50% { opacity: .35; } }
.scan-reticle {
  position: absolute;
  inset: 23% 27%;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,.07);
  pointer-events: none;
}
.scan-reticle .corner { position: absolute; width: 16px; height: 16px; border-color: rgba(255,255,255,.45); border-style: solid; }
.scan-reticle .tl { top: -1px; left: -1px; border-width: 1px 0 0 1px; }
.scan-reticle .tr { top: -1px; right: -1px; border-width: 1px 1px 0 0; }
.scan-reticle .bl { bottom: -1px; left: -1px; border-width: 0 0 1px 1px; }
.scan-reticle .br { bottom: -1px; right: -1px; border-width: 0 1px 1px 0; }
.scan::before, .scan::after { display: none; }
.scan-footer {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  background: rgba(11,13,16,.9);
  border-top: 1px solid rgba(255,255,255,.08);
}
.scan-readout { color: #a6abb3; font-size: 12px; line-height: 1.4; }
.scan-trigger {
  flex-shrink: 0;
  border: 1px solid rgba(255,255,255,.18);
  background: rgba(255,255,255,.06);
  color: #d7dbe1;
  border-radius: 5px;
  font-size: 12px;
  padding: 6px 10px;
  transition: background .15s ease, border-color .15s ease;
}
.scan-trigger:hover { background: rgba(255,255,255,.12); border-color: rgba(255,255,255,.3); }
.story-facts {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px;
  border-top: 1px solid rgba(255,255,255,.11);
  margin-top: 30px;
  padding-top: 20px;
  max-width: 560px;
}
.story-facts strong { display: block; font-size: 13px; font-weight: 500; color: #e7eaee; letter-spacing: -.005em; }
.story-facts span { display: block; color: #a6abb3; font-size: 13px; line-height: 1.5; margin-top: 4px; }
.password-field { position: relative; }
.password-field .input { padding-right: 56px; }
.pw-toggle {
  position: absolute;
  top: 50%;
  right: 6px;
  transform: translateY(-50%);
  height: 28px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  padding: 0 8px;
  border-radius: 4px;
}
.pw-toggle:hover { background: var(--raised); color: var(--text); }
@media (max-width: 1080px) {
  .report-grid { grid-template-columns: 1fr; }
}
@media (max-width: 980px) {
  .login-screen { grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr); }
  .login-story { min-height: 0; padding: 28px 36px; }
  .login-story > div {
    display: grid;
    grid-template-columns: minmax(220px, .8fr) minmax(340px, 1.2fr);
    grid-template-rows: auto auto 1fr;
    column-gap: 32px;
    align-items: start;
  }
  .login-wordmark { grid-column: 1; }
  .login-story h1 { grid-column: 1; font-size: 38px; margin-top: 20px; }
  .login-story .story-copy { grid-column: 1; font-size: 13px; margin-top: 14px; }
  .scan { grid-column: 2; grid-row: 1 / span 3; width: 100%; margin-top: 0; }
  .story-facts, .login-footnote { display: none; }
  .login-side { min-height: 0; place-items: start center; padding: 40px 36px 42px; }
}
@media (max-width: 720px) {
  .report-grid { grid-template-columns: 1fr; }
  .chart-body { min-height: 190px; grid-template-columns: 28px minmax(0,1fr); }
  .bar-chart { min-height: 190px; gap: 4px; }
  .bar-stack { width: min(20px, 90%); }
  .chart-note { margin-left: 0; width: 100%; }
  .outcome-total { font-size: 34px; }
  .seg { width: 100%; }
  .seg-item { flex: 1; }
  .camera-guide { inset: 12% 16%; }
  .capture-source { align-items: stretch; flex-direction: column; }
  .capture-source-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .capture-source-actions .btn { width: 100%; }

  .login-story { min-height: auto; padding: 24px 20px; }
  .login-screen { grid-template-rows: auto auto; }
  .login-story > div { display: block; }
  .login-story h1 { font-size: 34px; margin-top: 12px; max-width: 12ch; }
  .login-story .story-copy { font-size: 13px; margin-top: 10px; line-height: 1.5; }
  .scan { width: 100%; aspect-ratio: 16 / 9; margin-top: 16px; }
  .scan-footer { align-items: flex-end; padding: 18px 12px 10px; }
  .scan-readout { max-width: 62%; font-size: 11px; }
  .scan-trigger { font-size: 11px; padding: 5px 8px; }
  .story-facts { display: none; }
  .login-side { min-height: auto; padding: 30px 20px 40px; }
  .login-form h2 { font-size: 24px; }
  .login-note { margin-top: 24px; }
}
@media (prefers-reduced-motion: reduce) {
  .camera-flash.active { animation: none; opacity: .25; }
  .scan-state.live i { animation: none; }
}
