/* The SYSTEM and SOURCES pages (pages.js). Loaded after hud.css and built on its tokens and
   classes (panel, kv, chip, seg-btn, hint, subhead); every class added here is pg-. Status
   colours always come with a glyph and a word, never alone. No animation. */

/* pages.js reports a 'fail' LED; hud.css names the same state 'bad'. */
.led[data-state="fail"] { background: var(--sev-critical); }

.pg-sr { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0; }

.pg-panel, .pg-strip, .pg-toolbar, .pg-lists { margin-bottom: var(--gap); }

/* CODE / AI markers: the word carries the meaning; the glyph and border style repeat it. */
.pg-kind { display: inline-flex; align-items: center; gap: 5px; padding: 2px 7px; font: 600 11px/1.3 var(--font-mono); letter-spacing: 0.08em; white-space: nowrap; color: var(--text); border: 1px solid var(--line-strong); border-radius: var(--radius-sm); }
.pg-kind[data-kind="code"] { color: var(--accent); border-color: var(--accent); }
.pg-kind[data-kind="ai"] { color: var(--ai-inference); border: 1px dashed var(--ai-inference); }
.pg-kind[data-kind="mixed"] { color: var(--text-head); border: 1px dashed var(--line-strong); }
.pg-kind__glyph { font-size: 10px; }

/* HOW A STORY GETS HERE: one row on a wide screen, wrapping down to one column. */
.pg-flow { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 148px), 1fr)); gap: 8px; }
.pg-flow--side { grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); }
.pg-stage { display: grid; gap: 6px; align-content: start; min-width: 0; padding: 10px 11px 12px; background: var(--bg-page); border: 1px solid var(--line); border-top: 2px solid var(--accent); border-radius: 6px; }
.pg-stage[data-kind="ai"] { border: 1px dashed var(--ai-inference); }
.pg-stage__top { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.pg-stage__n { font-size: 11px; color: var(--text-muted); }
.pg-stage__name { font: 600 12px/1.3 var(--font-mono); letter-spacing: 0.06em; color: var(--text-head); }
.pg-stage__text { font-size: 13px; line-height: 1.5; color: var(--text-dim); }

/* WHAT IS CODE, WHAT IS AI */
.pg-split { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); gap: 12px; }
.pg-split__col { min-width: 0; padding: 12px 14px; background: var(--bg-page); border: 1px solid var(--line); border-radius: 6px; }
.pg-split__col[data-kind="ai"] { border-style: dashed; border-color: var(--line-strong); }
.pg-split__head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 8px; font-size: 14px; font-weight: 600; color: var(--text-head); }
.pg-list { margin: 0; padding-left: 18px; display: grid; gap: 4px; font-size: 14px; line-height: 1.5; color: var(--text-dim); }
.pg-budget { max-width: 90ch; padding: 10px 12px; font-size: 14px; line-height: 1.55; color: var(--text); background: var(--bg-page); border-left: 3px solid var(--accent); border-radius: 0 6px 6px 0; }

/* Tables: SCHEDULE and the HOW WE RATE weights. */
.pg-table { width: 100%; border-collapse: collapse; font-size: 14px; text-align: left; }
.pg-table th, .pg-table td { padding: 9px 12px 9px 0; vertical-align: top; border-bottom: 1px solid var(--line); }
.pg-table thead th { font: 600 11px/1.4 var(--font-mono); letter-spacing: 0.08em; color: var(--text-muted); border-bottom-color: var(--line-strong); white-space: nowrap; }
.pg-table tbody th { font: 600 12.5px/1.45 var(--font-mono); letter-spacing: 0.04em; color: var(--text-head); }
.pg-table td { color: var(--text-dim); line-height: 1.5; }
.pg-schedule code { font-size: 12.5px; color: var(--text); white-space: nowrap; }
.pg-tz { font-size: 11.5px; color: var(--text-muted); white-space: nowrap; }
.pg-weights tbody th { font: 400 13.5px/1.45 var(--font-sans); letter-spacing: 0; color: var(--text); }
.pg-weights td { text-align: right; white-space: nowrap; padding-right: 0; color: var(--text-head); }
.pg-weights thead th:last-child { text-align: right; padding-right: 0; }
@media (max-width: 720px) {
  .pg-schedule, .pg-schedule tbody, .pg-schedule tr, .pg-schedule th, .pg-schedule td { display: block; }
  .pg-schedule thead { display: none; }
  .pg-schedule tr { padding: 10px 0; border-bottom: 1px solid var(--line); }
  .pg-schedule th, .pg-schedule td { padding: 2px 0; border: 0; }
  .pg-schedule td[data-label]::before { content: attr(data-label); display: inline-block; min-width: 9ch; margin-right: 8px; font: 600 10.5px/1.4 var(--font-mono); letter-spacing: 0.08em; color: var(--text-muted); }
}

/* LAST RUN: the collection replay, one box per stage. */
.pg-run__head { font-size: 12.5px; line-height: 1.5; letter-spacing: 0.03em; color: var(--text-dim); }
.pg-replay { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 128px), 1fr)); gap: 6px; }
.pg-step { display: grid; gap: 3px; align-content: start; min-width: 0; padding: 10px; background: var(--bg-page); border: 1px solid var(--line); border-radius: 6px; }
.pg-step[data-state="warn"] { border-color: var(--sev-medium); }
.pg-step__name { font: 600 10.5px/1.3 var(--font-mono); letter-spacing: 0.07em; color: var(--text-muted); }
.pg-step__value { font-size: 20px; line-height: 1.2; color: var(--text-head); }
.pg-step__sub { font-size: 12.5px; line-height: 1.4; color: var(--text-dim); }
.pg-run__ai { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 14px; color: var(--text-dim); }
.pg-run__id { font-size: 11.5px; overflow-wrap: anywhere; }
.pg-versions { max-width: 680px; }

/* SOURCES: the summary strip. */
.pg-strip { list-style: none; margin: 0 0 var(--gap); padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.pg-strip[data-tiles="5"] { grid-template-columns: repeat(5, minmax(0, 1fr)); }
@media (max-width: 560px) { .pg-strip, .pg-strip[data-tiles="5"] { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.pg-tile { display: grid; gap: 4px; min-width: 0; padding: 12px 14px; background: var(--bg-surface); border: 1px solid var(--line); border-left: 3px solid var(--tile, var(--line-strong)); border-radius: var(--radius); }
.pg-tile[data-group="ok"] { --tile: var(--sev-low); --tile-text: var(--sev-low); }
.pg-tile[data-group="fail"] { --tile: var(--sev-critical); --tile-text: var(--sev-critical-text); }
.pg-tile[data-group="watch"] { --tile: var(--sev-medium); --tile-text: var(--sev-medium); }
.pg-tile[data-group="off"] { --tile: var(--text-muted); --tile-text: var(--text-muted); }
.pg-tile[data-zero="true"] { --tile: var(--line-strong); --tile-text: var(--text-muted); }
.pg-tile__value { display: flex; align-items: baseline; gap: 8px; font-size: 26px; line-height: 1.1; color: var(--text-head); }
.pg-tile__glyph { font-size: 14px; color: var(--tile-text, var(--text-muted)); }
.pg-tile__label { font: 600 11px/1.3 var(--font-mono); letter-spacing: 0.08em; color: var(--text-dim); }

/* Region and sort controls. */
.pg-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 22px; }
.pg-controls { display: flex; flex-wrap: wrap; gap: 10px 22px; }
.pg-control { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.pg-control__label { min-width: 6ch; font: 600 11px/1 var(--font-mono); letter-spacing: 0.12em; color: var(--text-muted); }
.pg-seg { display: inline-flex; }
.pg-seg .seg-btn:focus-visible { position: relative; z-index: 1; }
.pg-showing { font-size: 13.5px; }

/* Source groups and cards. */
.pg-lists { display: grid; gap: 22px; }
.pg-group { display: grid; gap: 10px; min-width: 0; }
.pg-group__title { display: flex; align-items: baseline; gap: 6px; font: 600 12.5px/1.4 var(--font-mono); letter-spacing: 0.1em; color: var(--text-head); }
.pg-cards { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); gap: 10px; }
.pg-card { display: grid; gap: 8px; align-content: start; min-width: 0; padding: 14px; background: var(--bg-surface); border: 1px solid var(--line); border-radius: var(--radius); }
.pg-card[data-attention="fix"] { border-left: 3px solid var(--sev-critical); }
.pg-card[data-attention="watch"] { border-left: 3px solid var(--sev-medium); }
.pg-card[data-attention="coming"], .pg-card[data-attention="off"] { border-style: dashed; }
.pg-card__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.pg-card__name { min-width: 0; font: 600 15px/1.35 var(--font-sans); color: var(--text-head); overflow-wrap: anywhere; }
.pg-status { flex: none; display: inline-flex; align-items: center; gap: 5px; padding-top: 2px; font: 600 11px/1.2 var(--font-mono); letter-spacing: 0.06em; white-space: nowrap; color: var(--st, var(--text-muted)); }
.pg-status[data-group="ok"] { --st: var(--sev-low); }
.pg-status[data-group="watch"] { --st: var(--sev-medium); }
.pg-status[data-group="fail"] { --st: var(--sev-critical-text); }
.pg-card__publisher { font-size: 13px; color: var(--text-muted); overflow-wrap: anywhere; }
.pg-card__chips { display: flex; flex-wrap: wrap; gap: 6px; }
.pg-chip--life { color: var(--text-muted); border-color: var(--line-strong); }
.pg-card__desc { font-size: 14px; line-height: 1.5; color: var(--text-dim); }
.pg-card__reason { padding: 8px 10px; font-size: 13.5px; line-height: 1.5; color: var(--text); background: var(--bg-page); border-left: 3px solid var(--line-strong); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; overflow-wrap: anywhere; }
.pg-card__reason[data-kind="fix"] { border-left-color: var(--sev-critical); }
.pg-card__reason[data-kind="watch"] { border-left-color: var(--sev-medium); }
.pg-card__reason[data-kind="coming"], .pg-card__reason[data-kind="off"] { color: var(--text-dim); }
.pg-card__good { color: var(--text-muted); }
.pg-card__facts { font-size: 12px; line-height: 1.5; letter-spacing: 0.02em; color: var(--text-dim); }
.pg-card__link { justify-self: start; font-size: 12px; color: var(--accent); text-decoration: none; overflow-wrap: anywhere; }
.pg-card__link:hover { text-decoration: underline; }

/* The check history: filled for OK, hollow for stale, tall and red for a failure. */
.pg-history { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; min-width: 0; }
.pg-history--none { font-size: 13px; color: var(--text-muted); }
.pg-history__cells { flex: none; display: block; max-width: 100%; height: 16px; }
.pg-history__text { font-size: 11.5px; color: var(--text-muted); }
.pg-cell[data-group="ok"] { fill: var(--sev-low); }
.pg-cell[data-group="watch"] { fill: none; stroke: var(--sev-medium); stroke-width: 1.5; }
.pg-cell[data-group="fail"] { fill: var(--sev-critical); }
.pg-cell[data-group="off"] { fill: var(--line-strong); }

/* The reputation meter: one accent bar on a quiet track, its number written beside it. */
.pg-rep { display: grid; gap: 5px; }
.pg-rep__row, .pg-rep--none { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
.pg-rep__label { font: 600 10.5px/1.3 var(--font-mono); letter-spacing: 0.1em; color: var(--text-muted); }
.pg-rep__score { font-size: 15px; color: var(--text-head); }
.pg-rep__of { font-size: 11px; color: var(--text-muted); }
.pg-rep__standing { font: 600 11px/1.3 var(--font-mono); letter-spacing: 0.06em; color: var(--text-dim); }
.pg-rep--none .pg-rep__standing { font-weight: 400; color: var(--text-muted); }
.pg-meter { display: block; width: 100%; height: 6px; }
.pg-meter__track { fill: var(--line); }
.pg-meter__fill { fill: var(--accent); }
.pg-rep__basis { font-size: 12.5px; line-height: 1.45; color: var(--text-muted); }

/* HOW WE RATE */
.pg-rate { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); gap: 16px 28px; }
.pg-rate__col { display: grid; gap: 8px; align-content: start; min-width: 0; }
.pg-rate__note { font-size: 13.5px; line-height: 1.5; color: var(--text-dim); }
.pg-tiers { display: grid; gap: 8px; }
.pg-tiers__legend { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 0; font-size: 13px; color: var(--text); }
.pg-tiers__dot, .pg-tiers__unrated { color: var(--text-muted); white-space: pre; }
.pg-tier { display: inline-flex; align-items: center; gap: 6px; }
.pg-swatch { display: inline-block; width: 10px; height: 10px; border-radius: 2px; background: var(--tier); }
.pg-tier[data-tier="key"], .pg-tierbar__seg[data-tier="key"] { --tier: var(--accent); }
.pg-tier[data-tier="notable"], .pg-tierbar__seg[data-tier="notable"] { --tier: color-mix(in srgb, var(--accent) 65%, var(--bg-surface)); }
.pg-tier[data-tier="routine"], .pg-tierbar__seg[data-tier="routine"] { --tier: var(--line-strong); }
.pg-tierbar { display: block; width: 100%; max-width: 720px; height: 10px; }
.pg-tierbar__seg { fill: var(--tier); }
.pg-top { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.pg-top__item { display: flex; align-items: flex-start; gap: 12px; padding: 10px 12px; background: var(--bg-page); border: 1px solid var(--line); border-radius: 6px; }
.pg-top__score { flex: none; min-width: 36px; padding: 3px 6px; text-align: center; font-size: 14px; color: var(--accent); border: 1px solid var(--accent); border-radius: var(--radius-sm); }
.pg-top__body { display: grid; gap: 3px; min-width: 0; }
.pg-top__link { font-size: 14.5px; font-weight: 600; line-height: 1.4; color: var(--text-head); text-decoration: underline; text-decoration-color: var(--line-strong); text-underline-offset: 3px; overflow-wrap: anywhere; }
.pg-top__link:hover, .pg-top__link:focus-visible { color: var(--accent); }
.pg-top__why { font-size: 12.5px; line-height: 1.45; color: var(--text-muted); }

@media (forced-colors: active) {
  .pg-cell, .pg-meter__fill, .pg-tierbar__seg { fill: CanvasText; }
  .pg-cell[data-group="watch"] { fill: none; stroke: CanvasText; }
  .pg-meter__track { fill: Canvas; stroke: CanvasText; }
}

/* A snapshot that stopped updating says so at the top of the page (pages.js `staleNotice`). */
.pg-stale { margin-bottom: var(--gap); max-width: none; border-color: var(--sev-medium); color: var(--text); }
/* How each job last went: a state marker and its words (pages.js `jobHealth`). */
.pg-health { display: inline-flex; align-items: center; gap: 6px; font: 400 12.5px/1.4 var(--font-mono); color: var(--text-dim); white-space: nowrap; }
.pg-health[data-state="fail"] { color: var(--text); }
.pg-after-run { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; }
.pg-discovery li { max-width: 90ch; }
