/* OilGene brand for the hybrid explorer (R2 Task 7, spec §6).

   Tokens from oilgene.ru. Three rules this file keeps, each one gated in
   explorer/tests/test_workspace_page.py:

   - NOTHING IS HIDDEN BY A RULE except `[hidden]`. An inactive tab, the two
     unpenalised columns and a closed panel use the `hidden` attribute or a
     <details>, so present-in-HTML means visible unless the markup says not.
   - TEXT IS COLOURED ONLY WITH THE LEGIBLE TOKENS (at least 4.5:1 on every
     surface it sits on). `--leaf` and `--amber` colour borders, bars and the
     focus ring, never text.
   - EVERY ASSET IS LOCAL: Montserrat from fonts/, with its OFL licence beside
     it; no @import and no other host. */
@font-face { font-family: 'Montserrat'; font-style: normal; font-weight: 400; font-display: swap;
  src: url('fonts/montserrat-cyrillic-400-normal.woff2') format('woff2');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: 'Montserrat'; font-style: normal; font-weight: 400; font-display: swap;
  src: url('fonts/montserrat-latin-400-normal.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Montserrat'; font-style: normal; font-weight: 500; font-display: swap;
  src: url('fonts/montserrat-cyrillic-500-normal.woff2') format('woff2');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: 'Montserrat'; font-style: normal; font-weight: 500; font-display: swap;
  src: url('fonts/montserrat-latin-500-normal.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Montserrat'; font-style: normal; font-weight: 600; font-display: swap;
  src: url('fonts/montserrat-cyrillic-600-normal.woff2') format('woff2');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: 'Montserrat'; font-style: normal; font-weight: 600; font-display: swap;
  src: url('fonts/montserrat-latin-600-normal.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Montserrat'; font-style: normal; font-weight: 700; font-display: swap;
  src: url('fonts/montserrat-cyrillic-700-normal.woff2') format('woff2');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: 'Montserrat'; font-style: normal; font-weight: 700; font-display: swap;
  src: url('fonts/montserrat-latin-700-normal.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

:root {
  --ink: #072114;
  --forest: #0e4026;
  --forest-2: #15573a;
  --leaf: #84a94f;
  --sage: #bfd4a0;
  --sage-soft: #e7efdb;
  --mist: #f2f2f2;
  --paper: #ffffff;
  --zebra: #f8f9f6;
  --leaf-text: #4a6424;
  --amber: #b7791f;
  --amber-text: #8a5a12;
  --amber-soft: #fbf3e4;
  --red: #b91c1c;
  --red-soft: #fdf0f0;
  --muted: #56615a;
  --line: #dfe6d6;
  --score-bar: rgba(132, 169, 79, .28);
  --radius: 8px;
  --shadow: 0 1px 2px rgba(7, 33, 20, .06), 0 4px 14px rgba(7, 33, 20, .05);
}

[hidden] { display: none !important; }
* { box-sizing: border-box; }
html { color-scheme: light; }
body {
  margin: 0; background: var(--mist); color: var(--ink);
  font-family: 'Montserrat', system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 14px; line-height: 1.5;
}
a { color: var(--forest); text-underline-offset: 2px; }
a:hover { color: var(--leaf-text); }
h1, h2, h3 { color: var(--forest); line-height: 1.25; }
h1 { margin: 0 0 14px; font-size: 22px; }
:focus-visible { outline: 2px solid var(--leaf); outline-offset: 2px; }

/* ---- controls ---- */
button, input, select, textarea { font: inherit; }
button {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px;
  border: 1px solid var(--sage); border-radius: 6px; background: var(--paper); color: var(--forest);
  font-size: 13px; font-weight: 600; cursor: pointer;
}
button:hover { background: var(--sage-soft); }
.button-primary { border-color: var(--forest); background: var(--forest); color: var(--paper); }
.button-primary:hover { background: var(--forest-2); }
.button-quiet { padding: 4px 8px; border-color: transparent; background: transparent; color: var(--muted); }
.button-quiet:hover { background: var(--mist); color: var(--ink); }
.button-on-dark { border-color: rgba(191, 212, 160, .6); background: transparent; color: var(--paper); }
.button-on-dark:hover { background: var(--forest-2); }
input, select, textarea {
  padding: 5px 8px; border: 1px solid var(--line); border-radius: 6px;
  background: var(--paper); color: var(--ink);
}
input[type="checkbox"], input[type="radio"] { width: 15px; height: 15px; padding: 0; accent-color: var(--forest); }
input:disabled, select:disabled { background: var(--mist); cursor: not-allowed; }

/* ---- header ---- */
.site-header {
  position: sticky; top: 0; z-index: 20;
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; padding: 10px 24px;
  background: var(--forest); color: var(--paper); box-shadow: 0 2px 10px rgba(7, 33, 20, .25);
}
.brand { display: flex; align-items: baseline; gap: 10px; margin-right: auto; color: var(--paper); text-decoration: none; }
.brand:hover { color: var(--paper); }
.brand-mark { font-size: 19px; font-weight: 700; letter-spacing: .01em; }
.brand-sub { color: var(--sage); font-size: 13px; font-weight: 500; }
.header-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.header-controls form { display: flex; align-items: center; gap: 8px; margin: 0; }
.header-controls label { color: var(--sage); font-size: 12px; }
.header-select {
  min-width: 220px; padding: 6px 30px 6px 10px; appearance: none;
  border: 1px solid rgba(191, 212, 160, .45); background-color: var(--forest-2); color: var(--paper);
  font-weight: 600;
  background-image: linear-gradient(45deg, transparent 50%, var(--sage) 50%),
                    linear-gradient(135deg, var(--sage) 50%, transparent 50%);
  background-position: calc(100% - 15px) 55%, calc(100% - 10px) 55%;
  background-size: 5px 5px; background-repeat: no-repeat;
}
.header-select option { background-color: var(--paper); color: var(--ink); }
.header-select-small { min-width: 0; font-size: 12px; }
.account { position: relative; }
.account > summary {
  padding: 6px 10px; border: 1px solid rgba(191, 212, 160, .6); border-radius: 6px;
  color: var(--paper); font-size: 13px; font-weight: 500; list-style: none; cursor: pointer;
}
.account > summary:hover { background: var(--forest-2); }
.account-menu {
  position: absolute; top: calc(100% + 6px); right: 0; z-index: 30; min-width: 200px; padding: 6px;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); color: var(--ink);
  box-shadow: var(--shadow);
}
.account-menu form { display: block; }
.account-menu a, .account-menu button {
  display: block; width: 100%; padding: 7px 10px; border: 0; border-radius: 6px; background: none;
  color: var(--ink); font-size: 13px; font-weight: 500; text-align: left; text-decoration: none;
}
.account-menu a:hover, .account-menu button:hover { background: var(--mist); }

/* ---- layout ---- */
.page { max-width: 1480px; margin: 0 auto; padding: 20px 24px 48px; }
.card { padding: 18px 20px; border: 1px solid var(--sage); border-radius: var(--radius); background: var(--paper); box-shadow: var(--shadow); }
.card + .card { margin-top: 16px; }
.card-narrow { max-width: 520px; margin: 40px auto; }
.card-narrow form p { display: flex; flex-direction: column; gap: 4px; }
.card-narrow input:not([type="checkbox"]) { width: 100%; }
.helptext { display: block; color: var(--muted); font-size: 12px; }
.errorlist { margin: 4px 0; padding-left: 18px; color: var(--red); font-size: 13px; }
p[role="alert"] { color: var(--red); font-weight: 600; }

/* ---- the goals panel ---- */
.goals-head { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 8px 12px; }
.goals-head h2 { margin: 0 auto 0 0; font-size: 18px; }
.goals-head form { margin: 0; }
.goals-readonly { margin: 0; color: var(--muted); font-size: 12px; }
.goals-error { margin: 8px 0 0; color: var(--red); font-weight: 600; }
.goals-error:empty { margin: 0; }
.severity-legend { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 12px 0 0; padding: 0; color: var(--muted); font-size: 12px; list-style: none; }
.goal-list { margin: 12px 0 0; padding: 0; border-top: 1px solid var(--line); list-style: none; }
.goal { display: grid; grid-template-columns: 150px 1fr auto; align-items: center; gap: 14px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.goal .chip { justify-self: start; }
.goal-text { min-width: 0; font-weight: 500; }
.goal-locked { color: var(--muted); font-size: 12px; }
.goal-controls { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 6px 10px; }
.goal-controls form { display: inline-flex; align-items: center; margin: 0; }
.goal-controls label { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; }
.goal-controls select, .goal-controls input { padding: 3px 6px; font-size: 13px; }
.chip { display: inline-flex; align-items: center; justify-content: center; padding: 3px 12px; border: 1.5px solid transparent; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.chip-hard { border-color: var(--forest); background: var(--forest); color: var(--paper); }
.chip-soft { border-color: var(--leaf); background: var(--paper); color: var(--leaf-text); }
.chip-flag { border-color: var(--amber); background: var(--paper); color: var(--amber-text); }
.goal-add, .program-actions { margin-top: 12px; }
.goal-add > summary, .program-actions > summary { color: var(--forest); font-weight: 600; cursor: pointer; }
.goal-add-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 16px; margin-top: 10px; padding: 12px; border-radius: 6px; background: var(--mist); }
.goal-add-form label { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }
.goal-add-form fieldset { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 0; padding: 6px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--paper); }
.goal-add-form legend { padding: 0 4px; color: var(--muted); font-size: 12px; }
.program-actions form { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 10px 0 0; }
.program-actions label { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }
.program-actions-note, #program-grants { margin: 8px 0 0; color: var(--muted); font-size: 12px; }
.stat-pills { display: flex; flex-wrap: wrap; gap: 8px 10px; margin: 14px 0 0; padding: 0; list-style: none; }
.stat-pills li { display: inline-flex; align-items: baseline; gap: 6px; padding: 5px 12px; border-radius: 999px; background: var(--mist); color: var(--ink); font-size: 13px; }
.stat-pills strong { font-size: 15px; font-variant-numeric: tabular-nums; }
.stat-pills li[data-count="ranked"] { background: var(--sage-soft); color: var(--forest); }
.stat-pills li[data-count="rejected"] { background: var(--red-soft); color: var(--red); }
.stat-pills li[data-count="penalised"] { background: var(--sage-soft); color: var(--leaf-text); }
.stat-pills li[data-count="flagged"] { background: var(--amber-soft); color: var(--amber-text); }
#deferred-lines { margin: 10px 0 0; color: var(--muted); font-size: 12px; }
.moved-line { margin: 10px 0 0; padding: 8px 12px; border-left: 3px solid var(--leaf); border-radius: 0 6px 6px 0; background: var(--sage-soft); font-size: 13px; }
.guide { margin-top: 12px; font-size: 13px; }
.guide > summary { color: var(--forest); font-weight: 600; cursor: pointer; }
.guide dl { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 10px 0 0; }
.guide dt { font-weight: 600; }
.guide dd { margin: 0; color: var(--muted); }
.formula { padding: 8px 10px; border-radius: 6px; background: var(--mist); font-family: ui-monospace, 'SFMono-Regular', Menlo, monospace; }
.score-formula { margin: 12px 0 0; padding: 10px 12px; border-left: 3px solid var(--forest); border-radius: 0 6px 6px 0; background: var(--mist); font-size: 13px; }
.score-formula p { margin: 0; }
.score-formula ul { margin: 6px 0; padding-left: 18px; }
.score-formula-note { color: var(--muted); font-size: 12px; }
.probability-help { margin: 8px 0 0; color: var(--muted); font-size: 12px; }
.goal-add-form .probability-help { flex-basis: 100%; margin: 0; }

/* ---- tabs ---- */
.workspace-tabs { padding: 0; }
.tabs { display: flex; gap: 4px; padding: 0 12px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tab { display: inline-flex; align-items: center; gap: 6px; padding: 12px 14px 10px; border-bottom: 3px solid transparent; color: var(--muted); font-weight: 600; text-decoration: none; white-space: nowrap; }
.tab:hover { color: var(--forest); }
.tab[aria-selected="true"] { border-bottom-color: var(--leaf); color: var(--forest); }
.tab-count { display: inline-block; padding: 0 8px; border-radius: 999px; background: var(--mist); color: var(--ink); font-size: 12px; font-variant-numeric: tabular-nums; }
.tab[aria-selected="true"] .tab-count { background: var(--sage-soft); color: var(--forest); }
.tab-panel { padding: 14px 16px 16px; }

/* ---- the ranking's toolbar ---- */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 18px; margin-bottom: 10px; }
.column-chooser { position: relative; font-size: 13px; }
.column-chooser > summary { color: var(--forest); font-weight: 600; cursor: pointer; }
/* An absolute box shrinks to its 190-px parent: without a width every fieldset wrapped into one
   807-px column past the fold. */
.column-groups { position: absolute; z-index: 20; display: flex; flex-wrap: wrap; align-items: flex-start; gap: 10px 16px; width: min(56rem, 90vw); max-height: calc(100vh - 14rem); overflow: auto; margin-top: 6px; padding: 12px; border: 1px solid var(--sage); border-radius: 6px; background: var(--paper); box-shadow: var(--shadow); }
.column-groups fieldset { display: flex; flex-direction: column; gap: 4px; margin: 0; padding: 6px 10px; border: 1px solid var(--line); border-radius: 6px; }
.column-actions { flex: 1 0 100%; }
.column-groups legend { padding: 0 4px; color: var(--muted); font-size: 12px; }
.column-groups label { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.search { min-width: 260px; }
.toggle { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; cursor: pointer; }
.row-count { margin-left: auto; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.table-status { margin: 0 0 8px; color: var(--amber-text); font-size: 13px; font-weight: 600; }
.table-status:empty { margin: 0; }
.table-card[data-stale] .table-wrap { opacity: .45; }
.star-states { margin: 0 0 10px; padding: 8px 12px; border-left: 3px solid var(--amber); background: var(--paper); font-size: 13px; list-style: none; }
.star-states li + li { margin-top: 4px; }
.star-cause { color: var(--muted); }
.star-states-none { margin: 0 0 10px; color: var(--muted); font-size: 13px; }

/* ---- the ranking and the rejected table ----
   Child combinators throughout: the cross card carries a table of its own (the
   per-marker F1 table), and a descendant rule here would reach it.
   THE RANKING'S ROWS ARE ONE LINE, 2rem, EXACTLY (R3 spec §3): the script renders
   only the rows in view between two spacers and computes their height from it. */
.page-wide { max-width: none; padding-left: 12px; padding-right: 12px; }
.page-wide .tab-panel { padding-left: 6px; padding-right: 6px; }
.table-wrap { height: calc(100vh - 11rem); min-height: 24rem; overflow: auto; border: 1px solid var(--line); border-radius: 6px; }
.table-scroll { max-height: 72vh; overflow: auto; border: 1px solid var(--line); border-radius: 6px; }
.workspace-tabs[data-fullscreen] { position: fixed; inset: 0; z-index: 25; margin: 0; overflow: auto; border-radius: 0; }
.workspace-tabs[data-fullscreen] .table-wrap { height: calc(100vh - 9rem); }
table.ranking { table-layout: fixed; border-collapse: separate; border-spacing: 0; font-size: 13px; font-variant-numeric: tabular-nums; }
table.rejected { width: max-content; min-width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; font-variant-numeric: tabular-nums; }
.ranking > thead > tr > th, .rejected > thead > tr > th, .rejected > tbody > tr > td {
  padding: 6px 10px; border-bottom: 1px solid var(--line); background-color: var(--paper);
  text-align: left; white-space: nowrap;
}
.ranking > thead > tr > th { white-space: normal; overflow-wrap: anywhere; }
.ranking > tbody > tr > td {
  box-sizing: border-box; height: 2rem; padding: 0 10px; overflow: hidden;
  border-bottom: 1px solid var(--line); background-color: var(--paper);
  line-height: calc(2rem - 1px); text-align: left; text-overflow: ellipsis; white-space: nowrap;
}
.ranking > tbody > tr.spacer > td { padding: 0; border: 0; background: none; line-height: 0; }
table.ranking > thead, table.rejected > thead { position: sticky; top: 0; z-index: 3; }
.ranking > thead > tr > th, .rejected > thead > tr > th { border-bottom: 2px solid var(--sage); color: var(--forest); font-weight: 600; vertical-align: bottom; }
.ranking > thead > tr:first-child > th[colspan] { border-bottom: 1px solid var(--sage); color: var(--leaf-text); font-size: 11px; letter-spacing: .04em; text-align: center; text-transform: uppercase; }
.ranking > thead > tr > th[data-k] { cursor: pointer; user-select: none; }
.ranking > thead > tr > th[data-k]:hover { color: var(--leaf-text); }
.ranking > thead > tr > th[aria-sort="ascending"]::after { content: ' ▲'; color: var(--leaf-text); font-size: 9px; }
.ranking > thead > tr > th[aria-sort="descending"]::after { content: ' ▼'; color: var(--leaf-text); font-size: 9px; }
.ranking > thead > tr > th.num, .ranking > tbody > tr > td.num { text-align: right; }
/* The five fixed columns stay at the left edge; the offsets are the running sums
   of `columns.FIXED_WIDTH` (2.25, 6, 7.25, 5, 7.25 rem). */
.ranking > thead > tr > th.star, .ranking > tbody > tr > td.star { position: sticky; left: 0; padding-left: 0; padding-right: 0; text-align: center; text-overflow: clip; }
.ranking > thead > tr > th.rank, .ranking > tbody > tr > td.rank { position: sticky; left: 2.25rem; }
.ranking > thead > tr > th.female, .ranking > tbody > tr > td.female { position: sticky; left: 8.25rem; font-weight: 600; }
.ranking > thead > tr > th.female_group, .ranking > tbody > tr > td.female_group { position: sticky; left: 15.5rem; text-align: center; font-weight: 600; }
.ranking > tbody > tr > td.female_group[data-group="B"] { color: var(--amber-text); }
/* The ♀ group on the Rejected tab and the «Отобранные F1» page (R4): the row carries it. */
.rejected > tbody > tr > td.female_group { text-align: center; font-weight: 600; }
.rejected > tbody > tr[data-group="B"] > td.female_group { color: var(--amber-text); }
.page-title { margin: 0 0 8px; color: var(--forest); font-size: 20px; }
.muted { color: var(--muted); }
.header-link { color: var(--paper); font-size: 13px; font-weight: 600; text-decoration: none; }
.header-link:hover { color: var(--sage); }
.ranking > thead > tr > th.male, .ranking > tbody > tr > td.male { position: sticky; left: 20.5rem; font-weight: 600; box-shadow: 6px 0 8px -6px rgba(7, 33, 20, .18); }
.ranking > tbody > tr > td:is(.star, .rank, .female, .female_group, .male) { z-index: 1; }
.ranking > thead > tr > th:is(.star, .rank, .female, .female_group, .male) { z-index: 4; }
.ranking > tbody > tr.alt > td, .rejected > tbody > tr:nth-child(even) > td { background-color: var(--zebra); }
.ranking > tbody > tr[data-pair] { cursor: pointer; }
.ranking > tbody > tr[data-pair]:hover > td, .ranking > tbody > tr.open > td, .rejected > tbody > tr:hover > td { background-color: var(--sage-soft); }
.ranking > tbody > tr.open > td.rank { box-shadow: inset 3px 0 0 var(--forest); }
.ranking > tbody > tr > td.score {
  font-weight: 600;
  background-image: linear-gradient(90deg, var(--score-bar) 0 calc(var(--score, 0) * 100%),
                                    transparent calc(var(--score, 0) * 100%));
}
.open-card { padding: 0; border: 0; background: none; color: var(--forest); font: inherit; font-weight: 600; text-decoration: underline dotted; }
.open-card:hover { background: none; color: var(--leaf-text); }
.pareto-mark { margin-left: 4px; color: var(--leaf-text); }
.flag-chip { display: inline-block; margin: 0 4px 0 0; padding: 0 8px; border: 1px solid var(--amber); border-radius: 999px; background: var(--amber-soft); color: var(--amber-text); font-size: 11px; font-weight: 600; line-height: 1.5; white-space: nowrap; }
.star-toggle { padding: 0 2px; border: 0; background: none; color: var(--muted); font-size: 16px; line-height: 1; }
.star-toggle:hover { background: none; color: var(--amber-text); }
.star-toggle[aria-pressed="true"] { color: var(--amber-text); }
.panel-loading, .heatmap-hint { margin: 0; color: var(--muted); font-size: 13px; }
.panel-error { margin: 0; color: var(--red); font-weight: 600; }

/* ---- one cross ---- */
.cross-panel { font-size: 13px; }
.cross-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 14px; }
.cross-head h3 { margin: 0; font-size: 16px; }
.cross-rank { margin: 0; color: var(--muted); }
.is-rejected { color: var(--red); font-weight: 600; }
.cross-causes { margin: 8px 0 0; padding-left: 18px; }
.cross-metrics { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px 16px; margin: 10px 0 0; }
.cross-metrics div { padding: 6px 8px; border-radius: 6px; background: var(--paper); }
.cross-metrics dt { color: var(--muted); font-size: 11px; }
.cross-metrics dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; }
.cross-flags { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 10px 0 0; }
.cross-genotypes { margin-top: 12px; overflow-x: auto; }
.genotype-table { min-width: 760px; border-collapse: collapse; background: var(--paper); font-size: 12px; }
.genotype-table th, .genotype-table td { padding: 4px 8px; border: 1px solid var(--line); text-align: left; vertical-align: top; }
.genotype-table th { background: var(--mist); color: var(--forest); font-weight: 600; }
.weight { color: var(--amber-text); }
.series { display: block; color: var(--muted); }
.cross-overrides { margin-top: 12px; }
.override-list { margin: 6px 0; padding-left: 18px; }
.override-form { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 6px; }
.override-error { color: var(--red); font-weight: 600; }

/* ---- the rejected tab ---- */
.rejected-summary { margin: 0 0 10px; color: var(--muted); font-size: 13px; }
.state-legend { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 0 0 10px; padding: 0; font-size: 12px; list-style: none; }
.rejected > tbody > tr > td.causes { min-width: 280px; max-width: 520px; white-space: normal; }
.rejected > tbody > tr > td.causes ul { margin: 0; padding-left: 16px; }
.rejected > tbody > tr > td.state { text-align: center; }
.glyph { margin-right: 4px; font-weight: 700; }
.state-passed { color: var(--leaf-text); }
.state-failed { color: var(--red); }
.rejected > tbody > tr > td.state-failed { background-color: var(--red-soft); font-weight: 600; }
.state-not_applicable { color: var(--muted); }

/* ---- the heatmap ---- */
.heatmap { display: grid; grid-template-columns: minmax(0, 760px) minmax(280px, 1fr); align-items: start; gap: 16px; }
.heatmap-legend { display: flex; align-items: center; gap: 8px; margin: 0 0 8px; color: var(--muted); font-size: 12px; }
.ramp { display: inline-block; width: 180px; height: 10px; border: 1px solid var(--line); border-radius: 3px; }
#map { display: block; width: 100%; max-width: 760px; height: auto; border: 1px solid var(--line); border-radius: 6px; background: var(--paper); cursor: crosshair; image-rendering: pixelated; }
.cell-detail { min-width: 0; padding: 12px 14px; border: 1px solid var(--line); border-radius: 6px; background: var(--mist); }
/* The card (R3 spec §6): a drawer at the right, over the table. */
.cross-card { position: fixed; top: 0; right: 0; bottom: 0; z-index: 30; width: min(38rem, 100vw); overflow: auto; border-left: 1px solid var(--sage); background: var(--paper); box-shadow: var(--shadow); }
.cross-card-bar { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; justify-content: space-between; padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--paper); }
.cross-card-bar h2 { margin: 0; font-size: 14px; color: var(--forest); }
.cross-card-body { padding: 14px 16px; }
.cross-section { margin-top: 14px; }
.cross-section h4 { margin: 0 0 6px; color: var(--forest); font-size: 13px; }
.score-line { margin: 0; font-variant-numeric: tabular-nums; }
.cross-goal-states { margin: 0; padding: 0; list-style: none; }
.cross-goal-states li { padding: 4px 0; border-bottom: 1px solid var(--line); }
.cross-genotype-cells { display: grid; grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr)); gap: 6px 12px; margin: 0 0 10px; }
.cross-genotype-cells dt { color: var(--muted); font-size: 11px; }
.cross-genotype-cells dd { margin: 0; overflow-wrap: anywhere; }

@media (max-width: 980px) {
  .heatmap { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .site-header { padding: 10px 16px; }
  .page { padding: 12px 16px 32px; }
  .goal { grid-template-columns: 1fr; gap: 6px; }
  .goal-controls { justify-content: flex-start; }
  .header-select { width: 100%; min-width: 0; }
  .search { width: 100%; min-width: 0; }
  .row-count { margin-left: 0; }
  .guide dl { grid-template-columns: 1fr; }
}

/* Shared material metadata stays within the current workspace. */
#materials-drawer {
  position: fixed; inset: 0 0 0 auto; margin: 0; width: min(620px, 100%);
  max-width: 100%; height: 100dvh; max-height: 100dvh; box-sizing: border-box;
  border: 0; padding: 24px; overflow-y: auto; color: var(--ink); background: var(--paper);
  box-shadow: -12px 0 40px #142c3926;
}
#materials-drawer::backdrop { background: #11252b66; }
.materials-heading { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.materials-heading h2 { margin: 0; }
.materials-heading button { font-size: 1.6rem; }
.materials-list { padding-left: 0; list-style: none; }
.materials-list li { padding: 10px 0; border-bottom: 1px solid var(--line, #d8e1e6); overflow-wrap: anywhere; }
.materials-list small, .selected-f1 small, .rejected small { display: block; color: var(--muted); }
.material-editor p { margin: 16px 0; }
#material-form label { display: block; font-weight: 600; margin-bottom: 4px; }
#material-form input:not([type="hidden"]), #material-form select, #material-form textarea {
  box-sizing: border-box; width: 100%; max-width: 100%;
}
#material-form p:has(select[name$="_state"]) { border-top: 1px solid var(--line, #d8e1e6); padding-top: 16px; }
#material-form .helptext { display: block; font-size: .8rem; color: var(--muted); margin-top: 4px; }
.material-editor .errorlist { color: var(--red); padding-left: 20px; }
.material-notice, .material-preview { padding: 10px 12px; background: #f0f5e9; border-radius: 6px; overflow-wrap: anywhere; }
.material-reload { float: right; }
.material-history { margin-top: 24px; }
.material-history details { padding: 12px 0; border-top: 1px solid var(--line, #d8e1e6); }
.material-history summary { cursor: pointer; overflow-wrap: anywhere; }
.material-history dd { margin: 4px 0 12px; white-space: pre-wrap; overflow-wrap: anywhere; }
.material-label { display: inline-block; vertical-align: middle; max-width: 100%; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; cursor: help; }
.material-label:focus { outline: 2px solid var(--accent, #56752a); outline-offset: 2px; }
.material-label:focus::after, .material-label:hover::after {
  content: attr(data-full-name); position: fixed; inset: auto 16px 16px; z-index: 20;
  padding: 12px 16px; max-width: min(680px, calc(100vw - 64px)); border-radius: 6px;
  background: var(--forest); color: var(--paper); white-space: normal; overflow-wrap: anywhere;
  font-size: .9rem; font-weight: 500; box-shadow: 0 4px 20px #0003;
}
.cross-head h3 { max-width: 100%; overflow-wrap: anywhere; }
.cross-head .material-label { max-width: 45%; }
.map-labels { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.map-labels label, .map-labels select { min-width: 0; max-width: 100%; width: 100%; }
.map-labels output { grid-column: 1 / -1; overflow-wrap: anywhere; }
@media (max-width: 500px) {
  #materials-drawer { padding: 16px; }
  .map-labels { grid-template-columns: 1fr; }
}
