:root { --bg: #f7f6f2; --fg: #1e1e1e; --muted: #6b6b6b; --line: #dedbd3; --card: #ffffff; --accent: #0b5cad; --good: #1a7f37; --bad: #b42318; --btn: #e9e6df; }
:root[data-theme="dark"] { --bg: #14161a; --fg: #e8e6e1; --muted: #9a9a9a; --line: #2c3037; --card: #1c1f25; --accent: #6db3ff; --good: #4ade80; --bad: #f87171; --btn: #262a31; }
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); }
.top { display: flex; align-items: center; gap: 18px; padding: 10px 18px; border-bottom: 1px solid var(--line); background: var(--card); flex-wrap: wrap; }
.brand { font-weight: 700; font-size: 16px; }
#nav a { margin-right: 12px; text-decoration: none; padding: 4px 6px; border-radius: 4px; }
#nav a.active { background: var(--btn); }
.account { margin-left: auto; display: flex; gap: 12px; align-items: center; }
.muted { color: var(--muted); }
main { padding: 16px 18px; max-width: 1400px; }
h2 { margin: 0 0 4px; } h3 { margin: 18px 0 6px; }
.scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: 6px; background: var(--card); }
table.grid { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
table.grid th, table.grid td { padding: 6px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; white-space: nowrap; }
table.grid th { font-weight: 600; background: var(--btn); position: sticky; top: 0; }
td.money, td.delta, td.pct { text-align: right; }
td.empty { color: var(--muted); text-align: center; padding: 24px; }
.good { color: var(--good); } .bad { color: var(--bad); }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 12px; align-items: center; }
.inline { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
button { background: var(--btn); color: var(--fg); border: 1px solid var(--line); border-radius: 4px; padding: 5px 10px; cursor: pointer; }
button:disabled { opacity: .5; cursor: default; }
input, select { background: var(--card); color: var(--fg); border: 1px solid var(--line); border-radius: 4px; padding: 5px 8px; }
form.login { max-width: 320px; margin: 60px auto; display: flex; flex-direction: column; gap: 10px; background: var(--card); padding: 22px; border: 1px solid var(--line); border-radius: 8px; }
.error { color: var(--bad); min-height: 1em; }
.notice { position: fixed; right: 16px; top: 60px; padding: 10px 14px; border-radius: 6px; background: var(--card); border: 1px solid var(--line); box-shadow: 0 4px 16px rgba(0,0,0,.15); z-index: 5; }
.notice.error { border-color: var(--bad); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 14px 16px; margin: 10px 0; max-width: 900px; }
.card h3 { margin-top: 0; }
.cites { font-size: 12px; color: var(--muted); }
.decisions { margin: 8px 0; }
.foot { padding: 16px 18px; font-size: 12px; }
code { font-size: 12px; white-space: normal; }

/* a run in progress: visible without a reload, and the view refreshes itself when it lands */
.progress { display: flex; align-items: center; gap: 10px; padding: 8px 18px; background: var(--btn); border-bottom: 1px solid var(--line); font-size: 13px; }
.spinner { width: 13px; height: 13px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.9s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; border-top-color: var(--line); } }
td.actions { white-space: nowrap; }
td.actions button { padding: 2px 7px; font-size: 12px; margin-right: 4px; }

.explain { flex-basis: 100%; margin: 2px 0 0; max-width: 105ch; line-height: 1.5; }
.stamp { margin-left: 4px; }

/* "What happened" is a sentence, not a value. Every other cell is nowrap so columns line up;
   this one wraps and is width-capped, or the row grows until the sentence leaves the screen. */
table.grid td.reason { white-space: normal; min-width: 34ch; max-width: 52ch; }
table.grid td.reason code { display: block; margin-top: 2px; font-size: 11px; opacity: 0.65; }

/* Paging and filtering. The count sentence and the warning are the load-bearing parts: a table
   showing 500 of 812 rows looks exactly like a complete one, so the page has to say which. */
.pagebar, .filterbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 6px 0; }
.pagebar { margin-bottom: 10px; }
.filterbar label { flex: none; }
.filterbar input[type="search"] { min-width: 16ch; flex: 0 1 30ch; }
.warn { flex-basis: 100%; margin: 4px 0 0; padding: 6px 10px; border-left: 3px solid var(--bad); background: var(--card); color: var(--fg); max-width: 100ch; }
td.empty { white-space: normal; max-width: 90ch; line-height: 1.5; }
.empty-note { color: var(--muted); max-width: 90ch; }

/* Title forms. A labelled grid rather than a row of bare boxes: a placeholder vanishes once the
   box has a value, which on the editor means six filled boxes and nothing saying which is which. */
.titleform { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 14px 16px; margin: 10px 0; display: grid; gap: 12px 16px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); align-items: start; max-width: 1100px; }
.titleform .formhead, .titleform > .hint, .formactions, .changesummary { grid-column: 1 / -1; }
.titleform .formhead { margin: 0; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field label { font-weight: 600; font-size: 13px; }
.field input, .field select { width: 100%; }
.hint { margin: 0; font-size: 12px; color: var(--muted); line-height: 1.4; }
.fielderr { margin: 0; font-size: 12px; color: var(--bad); font-weight: 600; line-height: 1.4; }
[aria-invalid="true"] { border-color: var(--bad); outline: 1px solid var(--bad); }
.formactions { display: flex; flex-wrap: wrap; gap: 8px; }
.changesummary { font-style: italic; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* Match decisions: a checkbox per candidate so a title that found nine wrong listings is one
   action rather than nine. The per-row buttons stay for the single obvious match. */
.decisionbar { padding: 8px 0; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.decisionrow { padding: 4px 0; align-items: baseline; }
.decisionrow input[type="checkbox"] { width: 16px; height: 16px; flex: none; }
label.pick { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.notice { display: flex; gap: 12px; align-items: flex-start; max-width: min(46ch, calc(100vw - 32px)); }
.notice button.dismiss { flex: none; font-size: 12px; padding: 2px 8px; }

/* A long listing title or URL is one unbreakable run of characters in the places that are NOT
   inside a scroll container. Those are what push the whole page sideways, so they wrap. */
.decisionrow a, .decisionrow, .cites li, .card p, .warn, .hint, .fielderr, td.empty { overflow-wrap: anywhere; }

/* Narrow viewports. The rule being satisfied is that the PAGE never scrolls sideways: wide
   content scrolls inside its own .scroll container, and everything else wraps. */
@media (max-width: 780px) {
  .top { gap: 8px; padding: 8px 12px; }
  #nav { width: 100%; display: flex; flex-wrap: wrap; gap: 2px 10px; }
  #nav a { margin-right: 0; }
  .account { margin-left: 0; width: 100%; justify-content: flex-start; flex-wrap: wrap; }
  main { padding: 12px; }
  .progress { padding: 8px 12px; }
  .foot { padding: 12px; }
  /* Bottom-anchored and full width: a fixed box pinned to the top-right corner of a phone
     covers the controls it is reporting on. */
  .notice { left: 12px; right: 12px; top: auto; bottom: 12px; max-width: none; }
  .titleform { padding: 12px; gap: 10px; }
  .explain, .warn { max-width: none; }
  /* Touch targets. 12px buttons at 2px padding are a pointer-sized control on a finger-sized
     screen; the row actions were the worst of them. */
  button { min-height: 36px; padding: 7px 12px; }
  td.actions button { min-height: 32px; padding: 5px 10px; font-size: 13px; }
  /* button.linkish sets min-height:auto so it reads as a link on a wide screen, and that
     overrode the floor above. Measured at a forced 375px: Sign out and Theme were 28px targets,
     under this file own 36px rule and well under any touch guidance. They are actions a person
     reaches for on a phone, so they get the floor back here. */
  button.linkish { min-height: 36px; padding: 7px 10px; }
  input, select { min-height: 36px; }
  .filterbar input[type="search"] { flex: 1 1 100%; }
}
@media (max-width: 420px) {
  /* The table is allowed to be wider than the screen — it lives in its own scroller. What is not
     allowed is the page moving with it. */
  .scroll { margin-left: -12px; margin-right: -12px; border-left: 0; border-right: 0; border-radius: 0; }
  h2 { font-size: 20px; }
}

/* Keyboard: a skip link that is invisible until it has focus, and header actions that look like
   links but are buttons, because they DO something rather than going somewhere. */
.skip { position: absolute; left: -9999px; top: 0; background: var(--card); color: var(--fg); padding: 10px 14px; border: 1px solid var(--accent); border-radius: 0 0 6px 0; z-index: 10; }
.skip:focus { left: 0; }
#main:focus { outline: none; }
button.linkish { background: none; border: 0; padding: 4px 6px; color: var(--accent); font: inherit; cursor: pointer; text-decoration: underline; min-height: auto; }
button.linkish:hover { text-decoration: none; }

/* A row whose title text is blank still needs to be clickable, and needs to look like what it is. */
a.placeholder, h2.placeholder { font-style: italic; color: var(--muted); }
a.placeholder { text-decoration: underline dotted; }
#instance-label { font-weight: 400; font-size: 12px; }

/* A sentence explaining a column that is legitimately blank across most of a table. */
.footnote { margin: 10px 0 0; padding: 8px 12px; border-left: 3px solid var(--line); background: var(--card); color: var(--muted); max-width: 100ch; line-height: 1.5; }

/* The two core-bundle forms use the same labelled field as the admin forms. */
form.login .field { gap: 4px; }
form.login .field label { font-weight: 600; font-size: 13px; }

/* A save refused because somebody else saved first. Not an error in the user's input, so it does
   not look like a field error; it is a decision they have to make, so it carries its own buttons. */
.conflict { grid-column: 1 / -1; margin: 6px 0 0; padding: 10px 12px; border-left: 3px solid var(--bad); background: var(--card); display: flex; flex-wrap: wrap; gap: 8px; align-items: center; line-height: 1.5; }

/* A withdrawn digest. The body is NOT greyed, dimmed or collapsed: it is the record of what the
   product published and hiding it would be worse than the original error. The withdrawal is
   stated above it and made hard to miss instead. */
.retracted { margin: 0 0 10px; padding: 10px 12px; border: 1px solid var(--bad); border-left-width: 4px; background: var(--card); }
.retracted .warn { margin: 0; padding: 0; border-left: 0; background: none; font-weight: 600; }
.retracted p + p { margin: 6px 0 0; line-height: 1.5; max-width: 90ch; }

/* A run refused because one is already going. The evidence the refusal carries is the only
   liveness signal this instance has, so it gets a box that stays until it is dealt with rather
   than a notice that hides itself. */
.blocked { flex-basis: 100%; margin: 6px 0 0; padding: 10px 12px; border-left: 3px solid var(--bad); background: var(--card); }
.blocked .warn { margin: 0; padding: 0; border-left: 0; background: none; }
.blocked .explain { margin: 6px 0 8px; }

/* The ASIN worklist: a box per row, wide enough for a ten-character code and no wider. */
.asinrow { align-items: baseline; }
input.asinbox { width: 15ch; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; text-transform: uppercase; }
.asinrow .fielderr { flex-basis: 100%; }
