:root {
  --bg: #fafafa;
  --paper: #fff;
  --line: #e6e6e8;
  --line-strong: #d2d2d6;
  --ink: #1c1c1e;
  --muted: #6e6e73;
  --muted-2: #8e8e93;
  --brand: #0b6bcb;
  --good: #0a7c4a;
  --warn: #9a5b00;
  --bad: #b3261e;
}

/* One sentence saying what the open queue actually decides. Sits above the
   rule links so the answer to "what is this?" precedes "where are its knobs?". */
.decision-explainer {
  max-width: 78ch;
  margin: 10px 0 0;
  color: var(--muted, #555);
  font-size: 13px;
  line-height: 1.5;
}

.queue-status {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 10px;
  font-size: 12px;
  white-space: nowrap;
}

.queue-status-submitted { background: rgba(10, 124, 74, .12); color: var(--good, #0a7c4a); font-weight: 600; }

/* The build-time funnel for the open queue: how many candidates the analysis
   considered and where the rest went. Collapsed, because it answers a question
   asked occasionally rather than on every row. */
.run-accounting {
  margin: 10px 0 14px;
  padding: 8px 12px;
  border: 1px solid var(--line, #d9d9de);
  border-radius: 6px;
  font-size: 13px;
}

.run-accounting > summary {
  cursor: pointer;
  font-weight: 600;
}

.run-accounting-table {
  width: 100%;
  margin-top: 8px;
  border-collapse: collapse;
}

.run-accounting-table th,
.run-accounting-table td {
  padding: 4px 10px 4px 0;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--line, #ececed);
}

/* Shared decision evidence: labels and values, not Python payload dumps. */
.decision-rules {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px 18px;
  margin: 12px 0 18px;
  font-size: 12px;
}

.decision-evidence {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(135px, 1fr));
  gap: 6px 16px;
  margin: 10px 0;
}

.decision-evidence > div { min-width: 0; }
.decision-evidence dt { color: var(--muted); font-size: 11px; }
.decision-evidence dd { margin: 1px 0 0; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.source-evidence { margin-top: 10px; }
.source-evidence summary { color: var(--muted); font-size: 12px; }
.settings-group { scroll-margin-top: 16px; }
.rank-table td span:not(.status) { white-space: normal; overflow: visible; text-overflow: clip; }
.rank-table td small { white-space: normal; overflow: visible; text-overflow: clip; }
.filters:has(> label:only-of-type) { grid-template-columns: minmax(180px, 480px) auto; justify-content: start; }
aside .workspace-tools { margin: 14px 0 0; padding-top: 12px; border-top: 1px solid var(--line); }
aside .workspace-tools a { padding: 6px 10px 6px 16px; font-size: 12px; }
@media (max-width: 760px) {
  aside .workspace-tools { display: flex; flex-wrap: wrap; gap: 2px; margin-top: 8px; padding-top: 8px; }
  aside .workspace-tools a { padding: 5px 8px; }
  .filters:has(> label:only-of-type) { grid-template-columns: minmax(0, 1fr) auto; }
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select {
  font: inherit;
}

strong,
b {
  font-weight: 600;
}

a {
  color: var(--brand);
}

:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.skip-link {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 100;
  padding: 10px 16px;
  background: var(--paper);
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  transform: translateY(-200%);
}

.skip-link:focus {
  transform: translateY(0);
}

.preview-banner {
  padding: 8px 16px;
  text-align: center;
  background: #fff8ec;
  border-bottom: 1px solid #ead5aa;
  color: var(--warn);
  font-size: 12px;
}

.shell {
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr);
  min-height: calc(100vh - 35px);
}

aside {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 20px 10px;
  background: var(--paper);
  border-right: 1px solid var(--line);
}

.brand {
  display: block;
  padding: 4px 10px 20px;
  color: var(--ink);
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -.02em;
  text-decoration: none;
}

aside nav {
  display: grid;
  gap: 2px;
}

aside nav a {
  padding: 8px 10px;
  border-left: 2px solid transparent;
  color: var(--muted);
  font-size: 12.5px;
  text-decoration: none;
}

aside nav a:hover {
  background: #f5f5f7;
  color: var(--ink);
}

aside nav a[aria-current=page] {
  border-left-color: var(--brand);
  color: var(--ink);
  font-weight: 600;
}

.skills-link {
  display: block;
  margin: 18px 10px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  text-decoration: none;
}

.skills-link:hover {
  color: var(--ink);
}

.sidebar-footer {
  min-height: 32px;
  margin-top: auto;
  padding: 12px 10px 0;
  border-top: 1px solid var(--line);
}

.sidebar-footer form {
  margin: 0;
}

.sidebar-footer button {
  width: 100%;
  font-size: 12px;
}

main {
  min-width: 0;
  padding: 20px clamp(16px, 3vw, 42px) 48px;
}

.login-page {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 20px;
}

.login-card {
  width: min(100%, 360px);
  padding: 24px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 10px;
}

.login-card > p {
  margin: 6px 0 20px;
  color: var(--muted);
}

.login-card form p {
  display: grid;
  gap: 5px;
  margin: 0 0 14px;
}

.login-card label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.login-card input {
  width: 100%;
  height: 34px;
  padding: 6px 8px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--paper);
  color: var(--ink);
}

.login-card button {
  width: 100%;
  margin-top: 2px;
  border-color: var(--brand);
  background: var(--brand);
  color: #fff;
}

.login-card button:hover {
  background: #085daf;
}

h1,
h2,
h3 {
  color: var(--ink);
  font-weight: 600;
}

h1 {
  margin: 0;
  font-size: 22px;
  letter-spacing: -.02em;
  line-height: 1.2;
}

h2 {
  margin: 0;
  font-size: 15px;
  line-height: 1.35;
}

h3 {
  margin: 20px 0 0;
  font-size: 14px;
}

header > p,
.muted {
  color: var(--muted);
}

header > p {
  margin: 5px 0 0;
}

.page-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
}

.mode {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.card,
.notice {
  margin-top: 16px;
  padding: 14px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.unavailable {
  border-left: 3px solid var(--warn);
  background: #fffdf8;
}

.filters {
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr)) auto;
  gap: 8px;
  margin-top: 16px;
}

.filters label {
  display: grid;
  min-width: 0;
  gap: 4px;
  color: var(--muted);
  font-size: 12px;
}

.filters input,
.filters select,
.settings-fields input,
.settings-fields select {
  min-width: 0;
  width: 100%;
  height: 30px;
  padding: 5px 8px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--paper);
  color: var(--ink);
}

button {
  align-self: end;
  min-height: 30px;
  padding: 5px 11px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--paper);
  color: var(--ink);
  font-weight: 600;
  cursor: pointer;
}

button:hover {
  background: #f5f5f7;
}

.save-button {
  border-color: var(--brand);
  background: var(--brand);
  color: #fff;
}

.save-button:hover {
  background: #085daf;
}

.table-heading,
.detail-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
}

.table-heading p {
  margin: 3px 0 0;
}

.table-scroll {
  margin: 12px -14px -14px;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
}

.review-submit {
  margin-top: 30px;
}

table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
}

th,
td {
  padding: 7px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

tbody tr:hover {
  background: #f5f5f7;
}

th {
  background: var(--paper);
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .035em;
  text-transform: uppercase;
}

td a {
  color: inherit;
  text-decoration: none;
}

td a:hover strong {
  text-decoration: underline;
}

td span:not(.status) {
  display: block;
  overflow: hidden;
  color: var(--muted);
  font-size: 11.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 2px 7px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.2;
}

.status.confirmed,
.status.positive,
.status.owner_attested,
.status.ready {
  border-color: #add9c2;
  background: #f0faf5;
  color: var(--good);
}

.status.blocked,
.status.negative,
.status.failed,
.status.error {
  border-color: #edb7b3;
  background: #fdf0ef;
  color: var(--bad);
}

.status.uncertain,
.status.stale,
.status.warning,
.status.unconfirmed_write {
  border-color: #ead5aa;
  background: #fff8ec;
  color: var(--warn);
}

td small {
  display: block;
  margin-top: 2px;
  overflow: hidden;
  color: var(--muted);
  font-size: 11.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.decision-table th:last-child,
.decision-table td:last-child,
.history-table th:last-child,
.history-table td:last-child,
.rank-table th:nth-child(2),
.rank-table td:nth-child(2),
.rank-table th:nth-child(3),
.rank-table td:nth-child(3),
.rank-table th:nth-child(4),
.rank-table td:nth-child(4) {
  text-align: right;
}

.decision-table {
  table-layout: fixed;
}

.decision-table th[data-grid-column="action"] {
  width: 18%;
}

.decision-table th[data-grid-column="subject"] {
  width: 34%;
}

.decision-table th[data-grid-column="objective"] {
  width: 14%;
}

.decision-table th[data-grid-column="status"] {
  width: 16%;
}

.decision-table th[data-grid-column="values"] {
  width: 18%;
}

.decision-table td:nth-child(2) strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.decision-table td:last-child {
  white-space: nowrap;
}

.pagination {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 16px;
  color: var(--muted);
  font-size: 12px;
}

.detail-empty {
  margin-top: 16px;
  padding: 14px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  color: var(--muted);
}

.settings-navigation {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 250px), 1fr));
  gap: 16px;
  align-items: start;
}

.settings-navigation .card {
  min-width: 0;
}

.settings-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 44px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  text-decoration: none;
}

.settings-link:last-child {
  border-bottom: 0;
}

.settings-link span {
  color: var(--muted);
}

/* A job label and its one-line explanation are one reading unit.  Without a
   block layout, inline strong/small elements can run together in the narrow
   Data & Jobs cards. */
.settings-link .settings-link-copy {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.settings-link .settings-link-copy strong,
.settings-link .settings-link-copy small {
  display: block;
}

.settings-link .settings-link-copy strong { color: var(--ink); }
.settings-link .settings-link-copy small { color: var(--muted); }

.detail-grid,
.summary-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 14px 0 0;
}

.checkpoint-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 10px 0;
}

.detail-grid > div,
.summary-list > div,
.checkpoint-grid > div {
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--paper);
}

dt {
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 600;
}

dd {
  margin: 4px 0 0;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.notice-inline {
  margin: 12px 0 0;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f5f5f7;
  color: var(--muted);
  font-size: 12px;
}

.job-reconciliation-hold {
  border-color: #ead5aa;
  background: #fff8ec;
  color: var(--warn);
}

.job-reconciliation-hold strong { color: inherit; }
.console-submission-hold { margin: 0 0 16px; }

.coverage {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 11.5px;
}

.subnav {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.history-filters,
.rank-filters {
  grid-template-columns: repeat(5, minmax(140px, 1fr)) auto;
}

.history-table {
  min-width: 840px;
}

.outcome-table {
  table-layout: fixed;
  min-width: 1280px;
}

.outcome-table th:nth-child(1) { width: 19%; }
.outcome-table th:nth-child(2) { width: 13%; }
.outcome-table th:nth-child(3) { width: 13%; }
.outcome-table th:nth-child(4) { width: 14%; }
.outcome-table th:nth-child(5),
.outcome-table th:nth-child(6),
.outcome-table th:nth-child(7) { width: 12%; }
.outcome-table th:nth-child(8) { width: 17%; }
.outcome-table td { overflow-wrap: anywhere; }

.outcome-direction { margin-top: 16px; }
.outcome-summary-list dd { font-size: 22px; font-weight: 650; }
.outcome-summary-list small { color: var(--muted); font-size: 11.5px; }
.outcome-summary-positive { border-left: 3px solid var(--good) !important; }
.outcome-summary-neutral { border-left: 3px solid var(--line-strong) !important; }
.outcome-summary-negative { border-left: 3px solid var(--bad) !important; }
.outcome-status-groups {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}
.outcome-status-groups > div {
  display: grid;
  gap: 4px;
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--paper);
}
.outcome-status-groups span { color: var(--muted); font-size: 11.5px; }
.outcome-depth { margin-top: 14px; }
.outcome-summary-table { min-width: 680px; }
.decision-test-verdict { display: inline-block; padding: .2rem .5rem; border-radius: 999px; background: var(--surface-2, #f1f3f5); white-space: nowrap; }
.decision-test-verdict.is-good { color: var(--good); background: #e8f6ee; }
.decision-test-verdict.is-bad { color: var(--bad); background: #fbeaec; }
.decision-test-raw { margin-top: 16px; padding: 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface, #f8fafc); }
.decision-test-raw h3 { margin: 0; font-size: 14px; }
.decision-test-uncontrolled { display: inline-block; margin-right: 5px; padding: .2rem .5rem; border: 1px solid #d7b75e; border-radius: 999px; color: #624800; background: #fff3cd; font-size: 12px; letter-spacing: .04em; }
.decision-test-review-candidate { display: inline-block; padding: .15rem .45rem; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); background: var(--paper); white-space: nowrap; }
.outcome-assessment { margin-top: 12px; padding: 14px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface, #f8fafc); }
.outcome-assessment h3,
.outcome-raw-summary h3 { margin: 0; font-size: 13px; }
.outcome-assessment > p { margin: 6px 0 0; }
.outcome-assessment-facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 12px 0 0; }
.outcome-assessment-facts > div { min-width: 0; padding: 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--paper); }
.outcome-assessment-facts dd { overflow-wrap: anywhere; }
.outcome-assessment-facts .outcome-limitation { grid-column: 1 / -1; }
.outcome-raw-summary { margin: 14px 0; }
.outcome-raw-summary > p { margin: 4px 0 8px; }
.outcome-raw-summary table { min-width: 460px; }
.outcome-detail-card > details { margin-top: 10px; }

.rank-table {
  min-width: 860px;
}

.history-table td,
.rank-table td {
  overflow-wrap: anywhere;
}

.history-table td:nth-child(4) {
  white-space: nowrap;
}

.rank-evidence summary {
  color: var(--brand);
  cursor: pointer;
  font-weight: 600;
}

.rank-evidence p {
  margin: 8px 0;
}

.rank-evidence dl {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
  margin: 0;
}

.settings-form {
  margin-top: 16px;
}

.settings-form > .muted {
  font-size: 12px;
}

.settings-group {
  margin: 10px 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
}

.settings-group summary {
  padding: 10px 12px;
  color: var(--ink);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
}

.settings-fields {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 10px;
  padding: 2px 12px 12px;
  border-top: 1px solid var(--line);
}

.settings-fields label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.settings-fields > div {
  min-width: 0;
}

.settings-fields input[type=checkbox] {
  width: auto;
  justify-self: start;
}

.settings-fields input:disabled {
  background: #f5f5f7;
  color: var(--muted);
}

.field-error input {
  border-color: var(--bad);
}

.field-error small,
.errorlist {
  color: var(--bad);
  font-size: 12px;
}

.detail-grid ul {
  margin: 0;
  padding-left: 18px;
}

.review-run-sheets { margin-top: 12px; }
/* Four columns whose widths sum to 100%, and a min-width small enough that
   the Review action stays on screen at ordinary window sizes. An earlier
   revision added the Outstanding column without re-allocating these, which
   pushed the last column past the table and forced a horizontal scroll to
   reach the button. Keep the count of width rules equal to the count of
   columns. */
.action-queue-table { min-width: 0; table-layout: fixed; }
.action-queue-table th:nth-child(1) { width: 52%; }
.action-queue-table th:nth-child(2) { width: 10%; }
.action-queue-table th:nth-child(3) { width: 24%; }
.action-queue-table th:nth-child(4) { width: 14%; }

.action-queue-table th:nth-child(2),
.action-queue-table td:nth-child(2) { text-align: right; }
.action-queue-table th, .action-queue-table td { padding: 5px 10px; }
.action-queue-table td { overflow-wrap: anywhere; }
.action-queue-table td:last-child { white-space: nowrap; }
.action-queue-table td:last-child a { color: var(--brand); font-weight: 600; }
.action-queue-table td:last-child form { display: inline; }
.action-queue-table td:last-child button {
  appearance: none;
  border: 0;
  padding: 0;
  color: var(--brand);
  background: transparent;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.action-queue-table td .source-badge {
  display: inline-flex;
  padding: 2px 7px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 600;
  overflow: visible;
  text-overflow: clip;
  white-space: nowrap;
}
.review-index-details > summary { color: var(--ink); cursor: pointer; font-weight: 600; }
.review-index-details > .filters { margin-top: 12px; }
.resume-drafts { margin: 10px 0 0; padding-left: 18px; }
.resume-drafts li + li { margin-top: 5px; }
.saved-run-summary { padding: 12px 0; border-bottom: 1px solid var(--line); }
.saved-run-summary:last-of-type { border-bottom: 0; }
.saved-run-summary p { margin: 5px 0 0; }
.review-run-filter { grid-template-columns: minmax(0, 520px) auto; max-width: 620px; }
.review-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; padding: 16px 0; }
.selection-controls[hidden] { display: none; }
.selection-controls { display: inline-flex; flex-wrap: wrap; gap: 12px; }
.review-table { table-layout: auto; min-width: 960px; font-size: 13px; }
.review-table th:first-child { width: 64px; }
.review-table th { white-space: normal; line-height: 1.25; }
.review-confirm-table { min-width: 920px; }
.review-table td { overflow-wrap: anywhere; }
.review-table input[type=checkbox] { width: 18px; height: 18px; }

.sanity-strip { margin: 16px 0; padding: 11px 0; border-block: 1px solid var(--line); }
.sanity-heading { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: baseline; font-size: 12px; }
.sanity-heading span, .sanity-list small { color: var(--muted); }
.sanity-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(125px, 1fr)); gap: 8px; margin: 10px 0 0; }
.sanity-list > div { min-width: 0; padding: 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--paper); }
.sanity-list dd { margin-top: 3px; font-size: 15px; font-weight: 600; }
.sanity-list small { display: block; margin-top: 3px; font-size: 10.5px; line-height: 1.35; }

/* Overview: trailing ROAS chart. Axis furniture is drawn by the server-side
   geometry, so these rules only carry weight and colour. */
.roas-chart { display: block; width: 100%; min-width: 540px; height: auto; margin-top: 8px; }
.roas-grid { stroke: var(--line); stroke-width: 1; }
.roas-axis { stroke: var(--line-strong); stroke-width: 1; }
.roas-axis-label { fill: var(--muted); font-size: 14px; font-variant-numeric: tabular-nums; }
.roas-break-even { stroke: var(--muted); stroke-width: 1.5; stroke-dasharray: 2 4; }
.roas-line { fill: none; stroke: var(--brand); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.roas-line-provisional { stroke-opacity: .65; stroke-dasharray: 5 4; }
.roas-dot { fill: var(--brand); }
.roas-dot-provisional { fill: var(--paper); stroke: var(--brand); stroke-width: 1.5; }
.roas-chart circle:hover { r: 4.6; }

/* Overview: portfolio table. Every row stays on the page inside one bounded
   scroller instead of a second table behind a disclosure. */
.table-scroll-tall { max-height: 340px; overflow-y: auto; }
.table-scroll-tall thead th { position: sticky; top: 0; z-index: 1; background: var(--paper); box-shadow: inset 0 -1px 0 var(--line); }
.portfolio-table { min-width: 980px; }
.portfolio-table td.numeric, .portfolio-table th.numeric { text-align: right; }
.sort-link { display: inline-block; color: inherit; text-decoration: none; white-space: nowrap; }
.sort-link:hover { text-decoration: underline; }
.sort-link.is-active { color: var(--brand); }

/* Overview: the three composed summary cards sit side by side on a desktop
   and stack on narrow screens with the rest of the grids below. */
.overview-summaries { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; align-items: start; }
.overview-summary { min-width: 0; }
.summary-list-compact { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.summary-list-compact dd { font-size: 15px; font-weight: 600; }
.metric-change {
  display: inline-flex;
  width: fit-content;
  margin-top: 4px;
  padding: 2px 5px;
  border: 1px solid transparent;
  border-radius: 4px;
  font-size: 11.5px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.metric-change.is-good { color: var(--good); background: #e8f6ee; border-color: #b9e4ca; }
.metric-change.is-bad { color: var(--bad); background: #fbeaec; border-color: #efbfc3; }
.metric-change.is-neutral { color: var(--muted); background: #f5f5f7; border-color: var(--line); }
.portfolio-table .metric-change { margin: 0; }
.overview-run-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin: 6px 0 0;
  padding: 5px 8px;
  border: 1px solid transparent;
  border-radius: 6px;
  font-size: 12px;
}
.overview-run-status.is-good { color: var(--good); background: #e8f6ee; border-color: #b9e4ca; }
.overview-run-status.is-bad { color: var(--bad); background: #fbeaec; border-color: #efbfc3; }
.overview-run-status.is-neutral { color: var(--muted); background: #f5f5f7; border-color: var(--line); }
.overview-run-label { font-weight: 750; }
.overview-run-detail { color: var(--muted); font-weight: 400; }

/* Data & Jobs uses a dense grid of action links. Give its card, filters and
   independently rendered job result enough vertical separation to scan. */
.job-controls .settings-navigation { margin-top: 16px; column-gap: 24px; row-gap: 0; }
.job-controls .settings-link { min-height: 68px; padding-block: 12px; }
.job-filters { margin-top: 24px; }
#job-detail.detail-empty { margin-top: 20px; }
#job-results { margin-top: 20px; }

@media (max-width: 1100px) {
  .overview-summaries { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 760px) {
  .shell {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: max-content 1fr;
  }

  aside {
    padding: 10px 14px 8px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .brand {
    padding: 2px 0 9px;
  }

  aside nav {
    display: flex;
    gap: 6px;
    margin: 0 -14px;
    padding: 0 14px 4px;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
  }

  aside nav a {
    flex: 0 0 auto;
    padding: 6px 8px;
    border: 1px solid var(--line);
    border-radius: 999px;
    font-size: 12px;
    white-space: nowrap;
  }

  aside nav a[aria-current=page] {
    border-color: var(--line-strong);
    border-left-color: var(--line-strong);
    background: #f5f5f7;
  }

  .skills-link {
    display: none;
  }

  .sidebar-footer {
    display: block;
    min-height: 0;
    margin-top: 8px;
    padding: 8px 0 0;
  }

  main {
    padding: 18px 14px 32px;
  }

  .page-head {
    flex-direction: column;
  }

  .filters {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .filters label:first-child {
    grid-column: 1 / -1;
  }

  .filters button {
    justify-self: start;
  }

  .table-scroll {
    margin-inline: -14px;
    padding-inline: 14px;
  }

  .detail-grid,
  .summary-list,
  .checkpoint-grid,
  .settings-fields {
    grid-template-columns: 1fr;
  }

  .outcome-status-groups,
  .outcome-assessment-facts {
    grid-template-columns: 1fr;
  }

  .outcome-assessment-facts .outcome-limitation { grid-column: auto; }

  /* Two compact tiles still read fine at phone width; one per row wastes it. */
  .summary-list-compact {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .mode {
    white-space: normal;
  }
}

@media (max-width: 600px) {
  .action-queue .table-scroll,
  .review-index-details .table-scroll {
    margin: 12px 0 0;
    padding: 0;
    overflow: visible;
  }

  .action-queue-table {
    min-width: 0;
    width: 100%;
  }

  .action-queue-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }

  .action-queue-table,
  .action-queue-table tbody,
  .action-queue-table tr,
  .action-queue-table td {
    display: block;
    width: 100%;
  }

  .action-queue-table tr {
    display: grid;
    grid-template-areas: "name review" "source count";
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 4px 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--line);
  }

  .action-queue-table td {
    padding: 0;
    border: 0;
  }

  .action-queue-table td:nth-child(1) { grid-area: name; }
  .action-queue-table td:nth-child(2) { grid-area: source; }
  .action-queue-table td:nth-child(3) { grid-area: count; text-align: right; }
  .action-queue-table td:nth-child(4) { grid-area: review; text-align: right; }
}

/* ---------------------------------------------------------------------------
   Excel-style grids (Tabulator) layered over server-rendered console tables.
   The plain table stays in the DOM for submission and no-JS use; these rules
   only style the grid view that replaces it visually.
   --------------------------------------------------------------------------- */

.grid-holder {
  margin: 10px 0 4px;
  background: var(--paper);
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  overflow: hidden;
}

.grid-holder:fullscreen {
  border-radius: 0;
  padding: 12px;
  overflow: auto;
}

.grid-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
  font-size: 12px;
}

.grid-holder:focus-within { border-color: var(--line-strong); }

.grid-toolbar .grid-note {
  color: var(--muted);
  flex: 1 1 260px;
  min-width: 0;
}

.grid-page-size {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--muted);
}

.grid-page-size select { font-size: 12px; padding: 2px 4px; }

button.grid-tool {
  font-size: 12px;
  padding: 3px 9px;
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  cursor: pointer;
}

button.grid-tool:hover { border-color: var(--brand); color: var(--brand); }
button.grid-tool:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }

/* These are real submit controls in the source table, not a JavaScript-only
   imitation of sortable headers.  The enhanced grid hides them after it has
   installed its own headers; without enhancement they retain the existing
   table look and sort the complete queue on the server. */
button.grid-fallback-sort {
  min-height: 0;
  margin: -5px -8px;
  padding: 5px 8px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  letter-spacing: inherit;
  text-align: inherit;
  text-transform: inherit;
}
button.grid-fallback-sort:hover { background: #f5f5f7; color: var(--ink); }
button.grid-fallback-sort:focus-visible { outline: 2px solid var(--brand); outline-offset: -1px; }

.grid-toolbar > *:nth-last-child(4) { margin-left: auto; }

/* Cell contents ---------------------------------------------------------- */

.grid-html-cell {
  white-space: normal;
  line-height: 1.35;
  padding: 1px 0;
}

.grid-html-cell .cell-meta {
  display: block;
  color: var(--muted);
  font-size: 11.5px;
}

.grid-html-cell .notice-inline { margin: 4px 0 0; }
.grid-html-cell .decision-evidence { margin: 5px 0 0; font-size: 11.5px; }
.grid-html-cell p { margin: 3px 0 0; }

/* The Rank Actions evidence cells reuse Rank Tracker's compact history graph.
   Keep it narrow here so an action table still reads as a decision grid. */
.rank-scan-metric { display: flex; align-items: center; gap: 5px; min-width: 0; }
.rank-decision-metric .rank-scan-spark { width: 108px; height: 28px; }
.rank-scan-spark { flex: none; overflow: visible; }
.rank-scan-line { fill: none; stroke: #5775a5; stroke-width: 1.5; }
.rank-scan-dot { fill: #234a80; }
.rank-scan-dot-est { fill: #fff; stroke: #234a80; stroke-width: 1.5; }
.rank-scan-off { fill: #fff; stroke: #9d3030; stroke-width: 1.5; }
.rank-scan-hit { fill: transparent; pointer-events: all; }
.rank-scan-hit:focus { fill: rgba(53, 91, 145, .12); outline: none; }
.rank-scan-reading { font-weight: 700; }
.rank-scan-reading.is-np { color: #9d3030; }
.rank-scan-reading.is-stale { font-style: italic; }
.rank-scan-move.improved { color: #247445; }
.rank-scan-move.slipped { color: #9d3030; }
.rank-scan-tooltip { position: fixed; z-index: 20; max-width: 340px; padding: 6px 9px; border-radius: 5px; background: #1e2734; color: #fff; font-size: .82rem; line-height: 1.35; pointer-events: none; }
.rank-scan-tooltip[hidden] { display: none; }

.grid-editable-cell { font-variant-numeric: tabular-nums; }
.grid-editable-cell .grid-before { color: var(--muted); }
.grid-editable-cell .grid-value-editable {
  border-bottom: 1px dashed var(--brand);
  color: var(--brand);
  cursor: text;
}

input.grid-select { width: 15px; height: 15px; cursor: pointer; }
input.grid-select:disabled { cursor: not-allowed; opacity: 0.45; }

/* Tabulator theme alignment ----------------------------------------------
   The vendored theme draws a box around every cell, which reads as graph
   paper rather than as the rest of this console. Rows are separated; columns
   are not. Weight goes on the data, not on the lines between it. */

.grid-mount.tabulator {
  border: 0;
  background: var(--paper);
  font-size: 12.5px;
}

.grid-mount .tabulator-header {
  background: var(--paper);
  border-bottom: 1px solid var(--line-strong);
  color: var(--muted);
  font-weight: 600;
}

.grid-mount .tabulator-col {
  background: var(--paper);
  border-right: 0;
}

.grid-mount .tabulator-col .tabulator-col-content { padding: 6px 9px; }

.grid-mount .tabulator-col-title {
  color: var(--muted);
  font-size: 11.5px;
  letter-spacing: .035em;
  text-transform: uppercase;
  white-space: normal;
  line-height: 1.25;
  max-height: 2.5em;
  overflow: hidden;
}

/* On a paginated queue the arrow submits a full server-side sort, rather
   than pretending the first rendered page is the whole data set. */
.grid-mount .tabulator-col.grid-server-sortable .tabulator-col-title::after {
  content: "↕";
  display: inline-block;
  margin-left: 5px;
  color: var(--muted-2);
  font-size: 10px;
}
.grid-mount .tabulator-col.grid-server-sortable:hover { cursor: pointer; background: #f5f5f7; }
.grid-mount .tabulator-col.grid-server-sortable:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }

/* The per-column menu is useful but should not sit in the reading path. */
.grid-mount .tabulator-header-popup-button {
  opacity: 0;
  transition: opacity 120ms ease;
  color: var(--muted-2);
}

.grid-mount .tabulator-col:hover .tabulator-header-popup-button,
.grid-mount .tabulator-header-popup-button:focus-visible { opacity: 1; }

.grid-mount .tabulator-col .tabulator-header-filter { padding-top: 2px; }

.grid-mount .tabulator-header-filter input {
  width: 100%;
  font-size: 11.5px;
  padding: 3px 6px;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
}

.grid-mount .tabulator-header-filter input:focus {
  outline: none;
  border-color: var(--brand);
  background: var(--paper);
}

.grid-mount .tabulator-row {
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}

.grid-mount .tabulator-row.tabulator-row-even { background: var(--paper); }
.grid-mount .tabulator-row:hover { background: #f5f5f7; }

.grid-mount .tabulator-cell {
  border-right: 0;
  padding: 6px 9px;
  line-height: 1.35;
  vertical-align: top;
}

/* Numbers line up when they share a width. */
.grid-mount .tabulator-cell { font-variant-numeric: tabular-nums; }

.grid-mount .tabulator-cell.tabulator-range-selected:not(.tabulator-range-only-cell-selected) {
  background: rgba(11, 107, 203, 0.10);
}

.grid-mount .tabulator-cell.tabulator-editing {
  box-shadow: inset 0 0 0 1px var(--brand);
  padding: 8px 9px;
}

/* A frozen column should feel like the same sheet, lifted -- not a
   separate grey panel bolted to the side. */
.grid-mount .tabulator-frozen { border-right: 0; }

.grid-mount .tabulator-header .tabulator-frozen,
.grid-mount .tabulator-header .tabulator-col.tabulator-frozen { background: var(--paper); }

/* Follow the row underneath, including its hover, instead of painting a
   separate grey panel down the left edge. */
.grid-mount .tabulator-row .tabulator-cell.tabulator-frozen { background-color: inherit; }

.grid-mount .tabulator-frozen.tabulator-frozen-left {
  box-shadow: 6px 0 6px -6px rgba(0, 0, 0, 0.14);
}

.grid-mount .tabulator-footer {
  background: var(--paper);
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  padding: 4px 8px;
}

.grid-mount .tabulator-footer .tabulator-page {
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 6px;
  border: 1px solid var(--line-strong);
  background: var(--paper);
  color: var(--ink);
}

.grid-mount .tabulator-footer .tabulator-page.active { border-color: var(--brand); color: var(--brand); }

@media (max-width: 720px) {
  .grid-toolbar > *:nth-last-child(4) { margin-left: 0; }
  .grid-holder { margin-left: 0; margin-right: 0; }
}

/* The filters bar is a grid whose labels are grid containers and whose
   inputs are stretched to the full column. A checkbox must opt out of both,
   or it renders as a giant box stacked above its own text. Both selectors
   below out-specify `.filters label` / `.filters input`. */
.filters label.filter-toggle,
.filter-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

.filters label.filter-toggle { align-self: end; padding-bottom: 6px; }

.filter-toggle input[type="checkbox"] {
  flex: none;
  /* Explicit box: the shared `.filters input` rule stretches width, and the
     grid row stretches height, so leaving either to the default produced a
     tall rectangle instead of a checkbox. */
  width: 14px;
  height: 14px;
  min-width: 0;
  padding: 0;
  margin: 0;
  accent-color: var(--brand);
}

/* Keep collection bid and companion choices readable in both table modes. */
label.collection-editor { display: flex; flex-direction: column; gap: 3px; margin-top: 5px; }
.collection-editor input[type=number] { width: 100px; height: 30px; padding: 5px 8px; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--paper); color: var(--ink); }
.collection-editor select { max-width: 100%; }
