/* MyInti AI. Colours are the site's own (unchanged by the round 5 layout,
   owner 2026-12-01: "i dont want to change the colors"). Layout (round 5):
   one slim top bar, one centred page width, five text sizes
   (22 / 18 / 15 / 14 / 12; 16 in boxes on phones), one card style, two
   button heights (36 and 30; 44 and 36 on phones). */
:root {
  --bg: #f6f7f5;
  --surface: #ffffff;
  --text: #1b1f1d;
  --muted: #5f6763;
  --line: #d9ddd9;
  --accent: #17623f;
  --accent-text: #ffffff;
  --stripe: #f3f5f3;
  --bad: #9c0006;
  --bad-bg: #ffc7ce;
  --good: #006100;
  --good-bg: #c6efce;
  --warn-bg: #fdf4dc;
  --warn-line: #e3c877;
  /* Excel's "Neutral": missing data */
  --warn: #9c5700;
  --warn-cell-bg: #ffeb9c;
  --bad-soft: #fff0f1;
  /* An impossible reading: its own colour, purple (owner, 2026-12-01); 7.6:1 */
  --odd: #5b2a86;
  --odd-bg: #e6ddf8;
  /* A suspect reading (owner, 2026-12-01): an orange outline, no fill of its own. */
  --suspect: #c45f00;
  --suspect-text: #9a4a00;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  /* One page width for every tab and tool (the side gutters included). */
  --page: 1360px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131615;
    --surface: #1b1f1d;
    --text: #e8ebe9;
    --muted: #9aa39e;
    --line: #2f3532;
    --accent: #4fb985;
    --accent-text: #0c1a13;
    --stripe: #202523;
    --bad: #ffb3ab;
    --bad-bg: #5a1f1c;
    --good: #a6e3b4;
    --good-bg: #1d4a2a;
    --warn-bg: #2e2812;
    --warn-line: #6b5a1f;
    --warn: #f3d27a;
    --warn-cell-bg: #4a3a0c;
    --bad-soft: #2c1513;
    --odd: #d7c6ff;
    --odd-bg: #3b2a5c;
    --suspect: #ff9d3d;
    --suspect-text: #ffb870;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
.visually-hidden { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; clip-path: inset(50%); }

html, body { height: 100%; }

body {
  margin: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

h1 { margin: 0; font-size: 22px; font-weight: 650; letter-spacing: -0.01em; }
h2 { margin: 0; font-size: 18px; font-weight: 650; letter-spacing: -0.01em; }
h3 { margin: 0; font-size: 15px; font-weight: 650; }
.ai { color: var(--accent); }
.muted { color: var(--muted); font-weight: 400; }

/* The app fills the window; each tab scrolls inside it (one scroll only). */
.app { flex: 1; min-height: 0; display: flex; flex-direction: column; }

/* ---- Login */
.login { flex: 1; display: grid; place-items: center; padding: 24px 16px; }
.login-card {
  width: min(360px, 100%);
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
}
/* The company logo, at most 2x its 75 px height so it stays sharp. */
.login-logo { display: block; height: 38px; width: auto; align-self: flex-start; }
.login-card h1 { font-size: 22px; font-weight: 700; }
.login-card .hint { margin-top: -8px; }
.login-card label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; font-weight: 600; }
.login-card input {
  font: inherit;
  font-weight: 400;
  min-height: 36px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
}
.login-card input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.login-error { margin: 0; color: var(--bad); font-size: 14px; }

/* ---- The top bar: logo + product name, main tabs, who is logged in (one 56 px bar) */
.topbar { flex: none; background: var(--surface); border-bottom: 1px solid var(--line); }
.topbar-in { max-width: var(--page); margin: 0 auto; padding: 0 24px; height: 56px; display: flex; align-items: center; gap: 28px; }
.brand { flex: none; display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-logo { display: block; height: 36px; width: auto; }
.brand-name { padding-left: 12px; border-left: 1px solid var(--line); font-size: 18px; font-weight: 700; letter-spacing: -0.015em; line-height: 1.2; white-space: nowrap; }
/* Who is logged in (auth.js) and Log out. */
.account { flex: none; margin-left: auto; display: flex; align-items: center; gap: 12px; }
.whoami { font-size: 14px; white-space: nowrap; }
.whoami:not(:empty)::before { content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 7px; border-radius: 50%; background: var(--accent); vertical-align: 1px; }

/* Main tabs: PDF tools | Zoller HMI, in the bar */
.sections { align-self: stretch; display: flex; gap: 4px; }
.sections button {
  height: 100%;
  min-height: 0;
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  padding: 2px 14px 0;
  font-size: 15px;
  font-weight: 600;
}
.sections button:hover:not(:disabled) { color: var(--text); border-color: transparent; }
.sections button[aria-selected="true"]:not(:disabled) { color: var(--text); border-bottom-color: var(--accent); }
.sections button:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

/* A main tab's content fills the rest of the window. position: relative keeps
   the visually hidden labels inside it, so the window itself never scrolls
   (before: the page scrolled twice and a grey band showed at the bottom). */
.section { flex: 1; min-height: 0; display: flex; flex-direction: column; position: relative; }
/* The Admin (PDF tools) tab's own styles are in admin.css. */

.panel { display: flex; flex-direction: column; gap: 10px; flex: 1; min-height: 0; }
.empty-note { margin: 0; padding: 18px 12px; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: 8px; }

/* ---- Zoller HMI: a step bar, then four steps (zollerpage.js, checkui.js). The tab scrolls as one page. */
.section.zoller { overflow-y: auto; }
.step-bar { position: sticky; top: 0; z-index: 20; flex: none; background: var(--bg); border-bottom: 1px solid var(--line); }
.step-bar-in { max-width: var(--page); margin: 0 auto; padding: 8px 24px; display: flex; align-items: center; gap: 8px; overflow-x: auto; scrollbar-width: none; }
.step-link {
  flex: none; display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 14px 0 6px;
  border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--text);
  font-size: 14px; font-weight: 600; text-decoration: none; white-space: nowrap;
}
.step-link:hover { border-color: var(--muted); }
.step-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.step-link small { font-size: 12px; font-weight: 500; color: var(--muted); }
.step-link small:empty { display: none; }
.step-link small.bad { color: var(--bad); font-weight: 650; }
.step-link small.good { color: var(--good); }
.step-dot { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--stripe); border: 1px solid var(--line); font-size: 12px; font-weight: 700; }
.step-link.done .step-dot { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.step-link[aria-current="step"] { border: 2px solid var(--accent); padding-left: 5px; padding-right: 13px; }
/* Once per tab: files stay on this computer (in the bar on wide screens, in step 1 on phones). */
.step-bar-note { flex: 1 1 180px; min-width: 160px; padding-left: 16px; font-size: 12px; line-height: 1.3; color: var(--muted); text-align: right; }
#uploadHint { display: none; }

.steps { flex: none; width: 100%; max-width: var(--page); margin: 0 auto; display: flex; flex-direction: column; gap: 16px; padding: 16px 24px 32px; }
/* A jump from the step bar lands under the bar, not behind it. */
.step { flex: none; min-width: 0; scroll-margin-top: 64px; }

/* One card style */
.pane {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px 20px;
  gap: 12px;
}
.pane-head { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; }
.pane-head > .actions { margin-left: auto; }
.pane-head h2 { display: flex; align-items: center; gap: 10px; }
.pane-head h3 { margin: 0; font-size: 15px; font-weight: 650; }
/* Step titles: 18 px with a number circle. */
.step-num { flex: none; display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--accent); color: var(--accent-text); font-size: 14px; font-weight: 700; letter-spacing: 0; }
/* A step's one-line summary, next to its title. */
.step-sum { margin: 0; flex: 1 1 320px; min-width: 0; font-size: 14px; overflow-wrap: anywhere; }
.fine { margin: 0; font-size: 12px; color: var(--muted); }
.fine:empty { display: none; }
/* Step 1 after the files are read, and step 3: one slim row. */
.step.folded, .step.slim { padding-top: 12px; padding-bottom: 12px; gap: 6px; }
.step.folded .run-drop { display: none; }
.step.folded .pane-head .button.primary { background: var(--surface); border-color: var(--line); color: var(--text); font-weight: 400; }

.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

/* Buttons: 36 px, small ones 30 px (44 and 36 on phones). */
button, .button {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 36px;
  font: inherit;
  font-size: 14px;
  line-height: 1.25;
  padding: 4px 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}
button:hover:not(:disabled), .button:hover { border-color: var(--muted); }
button:disabled { opacity: 0.45; cursor: not-allowed; }
button.primary, .button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
  font-weight: 600;
}
button.small, .button.small { min-height: 30px; padding: 2px 12px; }
button:focus-visible, .button:has(input:focus-visible), select:focus-visible, textarea:focus-visible, summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
/* A button that reads like a link (a tool number, Edit, Show every tool). */
button.link { display: inline; min-height: 0; border: none; background: none; padding: 0; color: var(--accent); font-weight: 600; font-size: inherit; line-height: inherit; text-decoration: underline; text-underline-offset: 2px; border-radius: 3px; }

textarea {
  flex: 1;
  min-height: 140px;
  resize: none;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 var(--mono);
  white-space: pre;
  overflow: auto;
  tab-size: 4;
}
body.dragging textarea { border-color: var(--accent); border-style: dashed; }

.badge {
  margin: 0;
  align-self: flex-start;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--stripe);
  border: 1px solid var(--line);
  font-size: 14px;
  color: var(--muted);
}

.options {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 18px;
  font-size: 14px;
  color: var(--muted);
}
.options label { display: flex; align-items: center; gap: 8px; }
/* A long saved sheet name must not push the page wider than a phone screen. */
#savedRow label { flex-wrap: wrap; min-width: 0; max-width: 100%; }
#savedRow select { min-width: 0; max-width: 100%; }
select {
  font: inherit;
  font-size: 14px;
  min-height: 32px;
  padding: 4px 8px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
}
input[type="checkbox"] { accent-color: var(--accent); width: 16px; height: 16px; margin: 0; }

.preview {
  flex: 1;
  min-height: 220px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}
.empty { margin: 0; padding: 28px 16px; color: var(--muted); text-align: center; }

.preview h3 { position: sticky; left: 0; width: max-content; margin: 0; padding: 10px 12px 8px; font-size: 14px; font-weight: 600; }
.preview table + h3 { margin-top: 10px; }

/* Tables: 14 px, a line under each row. Only problems stand out: OK is green
   text with no fill (on screen; the .xlsx keeps its colours), NG red, No data
   amber and Impossible purple keep their fills. */
table { border-collapse: collapse; font-size: 14px; white-space: nowrap; }
th, td { padding: 6px 12px; border-bottom: 1px solid var(--line); text-align: left; }
th { position: sticky; top: 0; background: var(--stripe); font-weight: 600; z-index: 1; }
tbody tr:nth-child(even) td { background: var(--stripe); }
td.num { text-align: right; font-variant-numeric: tabular-nums; }
/* The first column (tool number) stays in view while a wide table is scrolled sideways. */
.preview th:first-child, .preview td:first-child { position: sticky; left: 0; z-index: 1; box-shadow: inset -1px 0 0 var(--line); }
.preview th:first-child { z-index: 2; }
.preview tbody tr td:first-child { background: var(--surface); }
.preview tbody tr:nth-child(even) td:first-child { background: var(--stripe); }

tbody tr td.bad { background: var(--bad-bg); color: var(--bad); font-weight: 600; }
tbody tr td.good { color: var(--good); }
tbody tr td.warn { background: var(--warn-cell-bg); color: var(--warn); }
tbody tr td.odd { background: var(--odd-bg); color: var(--odd); font-weight: 600; }
/* A suspect reading: an orange 2px outline and a "?" on top of the cell's own colour. */
td.suspect { outline: 2px solid var(--suspect); outline-offset: -2px; }
td.suspect::after { content: " ?"; color: var(--suspect-text); font-weight: 700; }
/* An impossible reading named in a line of text (the red notice, the missing-data chips). */
.odd-text { padding: 0 4px; border-radius: 4px; background: var(--odd-bg); color: var(--odd); font-weight: 600; }
.rownum { color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; min-width: 36px; }

.hint { margin: 0; font-size: 14px; color: var(--muted); }

.summary { margin: 0; min-height: 21px; font-size: 14px; color: var(--muted); }

/* Notes ("n things need a look"): never cut off. */
.warnings {
  padding: 8px 12px;
  border: 1px solid var(--warn-line);
  border-radius: 8px;
  background: var(--warn-bg);
  font-size: 14px;
  overflow-wrap: anywhere;
}
.warnings ul { margin: 4px 0 0; padding-left: 18px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 12px);
  /* left: 50% leaves only half the screen; a long file name must wrap, not run off. */
  width: max-content;
  max-width: calc(100vw - 32px);
  overflow-wrap: anywhere;
  padding: 9px 16px;
  border-radius: 8px;
  background: var(--text);
  color: var(--bg);
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s, transform 0.15s;
  z-index: 100;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---- Step 1: upload */
.source-line { margin: 0; font-size: 14px; overflow-wrap: anywhere; }
.source-line.muted { color: var(--muted); }
.run-drop {
  display: flex; flex-direction: column; gap: 2px; padding: 18px 16px; text-align: center;
  border: 1.5px dashed var(--line); border-radius: 8px; background: var(--bg); color: var(--muted);
  font-size: 14px; cursor: pointer;
}
.run-drop strong { color: var(--text); font-weight: 600; }
.run-drop:hover, body.dragging .run-drop { border-color: var(--accent); }
body.dragging .step.folded { outline: 2px dashed var(--accent); outline-offset: 2px; }
progress { width: 100%; height: 8px; accent-color: var(--accent); }
/* The check sheet of each program, next to the files (owner, 2026-12-01): one row each. */
.sheet-slots { display: flex; flex-direction: column; gap: 6px; }
.sheet-slots:empty { display: none; }
.sheet-slot {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 6px 12px;
  padding: 6px 8px 6px 12px; border: 1px solid var(--line); border-left: 5px solid var(--good); border-radius: 8px; background: var(--surface);
}
.sheet-slot.warn { border-color: var(--warn-line); border-left-color: var(--warn-line); background: var(--warn-bg); }
.sheet-slot .slot-text { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 10px; min-width: 0; flex: 1 1 260px; font-size: 14px; }
.sheet-slot .slot-status { color: var(--muted); overflow-wrap: anywhere; }
.sheet-slot.warn .slot-status { color: var(--warn); }
.sheet-slot .button { flex: none; min-height: 30px; padding: 2px 12px; }

/* ---- Step 2: check the data */
.inline-label { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); min-width: 0; max-width: 100%; margin-left: auto; }
/* A long batch name ("… · 3 tools with missing data (2 passed)") must not widen the page on a phone. */
.inline-label select { min-width: 0; max-width: 100%; text-overflow: ellipsis; }
/* The pieces of step 2 sit one under the other; the filter line and the colour key share one toolbar line. */
.run-result { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; min-width: 0; }
.run-result > * { flex: 1 1 100%; min-width: 0; }
.run-result > .filter-line { flex: 1 1 320px; }
.run-result > .legend { flex: 0 1 auto; }

/* The red notice: tools without all their data, a short 3-column list (tool · result · what is missing). */
.notice-bad { padding: 10px 16px 12px; border: 1px solid var(--bad); border-left-width: 5px; border-radius: 8px; background: var(--bad-soft); font-size: 14px; overflow-wrap: anywhere; }
.notice-bad > strong { color: var(--bad); font-size: 15px; }
.notice-lead { display: inline; margin: 0; }
.notice-lead::before { content: " · "; }
.notice-bad p.notice-others { margin: 8px 0 2px; overflow-wrap: anywhere; }
.notice-list {
  list-style: none; margin: 6px 0 0; padding: 0; line-height: 1.45;
  display: grid; grid-template-columns: max-content max-content minmax(0, 1fr); gap: 1px 18px; align-items: baseline;
}
.notice-list > li { grid-column: 1 / -1; display: grid; grid-template-columns: 3.5em 4.5em minmax(0, 1fr); grid-template-columns: subgrid; align-items: baseline; }
.notice-list > li.more { display: block; }
/* Never a scroll box (round 5 review): a long list shows its first lines and a "Show all" button. */
.notice-list.clipped > li.extra { display: none; }
.notice-bad > .notice-more { display: block; margin-top: 6px; }
.notice-lead .notice-more { white-space: nowrap; }
.notice-list .sep { display: none; }
.notice-list .tool-link { justify-self: start; font-size: 15px; font-weight: 700; }
.notice-list .n-res { color: var(--muted); }
/* No check sheet for the program shown: tolerances cannot be judged. */
.notice-warn { padding: 10px 14px; border: 1px solid var(--warn-line); border-left-width: 5px; border-radius: 8px; background: var(--warn-bg); font-size: 14px; overflow-wrap: anywhere; }
.notice-warn strong { color: var(--warn); font-weight: 600; }
/* Suspect readings, under the red notice (owner, 2026-12-01). */
.notice-suspect { padding: 10px 16px 12px; border: 1px solid var(--suspect); border-left-width: 5px; border-radius: 8px; background: var(--surface); font-size: 14px; overflow-wrap: anywhere; }
.notice-suspect > strong { color: var(--suspect-text); font-weight: 650; font-size: 15px; }
/* Several short lines side by side: 8 tools take three rows. */
.notice-suspect .notice-list { grid-template-columns: repeat(auto-fill, minmax(min(350px, 100%), 1fr)); column-gap: 24px; }
.notice-suspect .notice-list > li { grid-column: auto; grid-template-columns: 3.2em 4.2em minmax(0, 1fr); }

/* The four groups as a 2 x 2 grid (rows Passed / Failed, columns All data / Data missing), next to why tools failed. */
.sum-row { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 16px 40px; align-items: start; }
.counts { display: grid; grid-template-columns: max-content 150px 150px; grid-template-rows: auto 52px 52px; gap: 6px 8px; align-items: center; }
.counts-col { grid-row: 1; padding-left: 2px; font-size: 12px; font-weight: 600; color: var(--muted); }
.counts-col.c1 { grid-column: 2; }
.counts-col.c2 { grid-column: 3; }
.counts-row { grid-column: 1; padding-right: 4px; font-size: 14px; font-weight: 600; color: var(--muted); }
.counts-row.r1 { grid-row: 2; }
.counts-row.r2 { grid-row: 3; }
.group-boxes {
  grid-column: 2 / 4; grid-row: 2 / 4; display: grid;
  grid-template-columns: 150px 150px; grid-template-rows: 52px 52px; gap: 6px 8px;
  grid-template-columns: subgrid; grid-template-rows: subgrid;
}
.group-box { display: flex; align-items: baseline; justify-content: flex-start; gap: 8px; height: 52px; min-height: 0; padding: 0 14px; text-align: left; border-radius: 8px; }
.group-box .box-count { font-size: 22px; font-weight: 700; line-height: 50px; font-variant-numeric: tabular-nums; }
.group-box .box-label { font-size: 12px; color: var(--muted); }
.g-passedComplete.has-tools .box-count { color: var(--good); }
.g-passedMissing.has-tools { background: var(--bad-soft); border-color: var(--bad); }
.g-passedMissing.has-tools .box-count { color: var(--bad); }
.g-failedComplete.has-tools .box-count { color: var(--bad); }
.g-failedMissing.has-tools { background: var(--warn-bg); border-color: var(--warn-line); }
.g-failedMissing.has-tools .box-count { color: var(--warn); }
.group-box[aria-pressed="true"] { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
.reasons { display: flex; flex-direction: column; gap: 12px; min-width: 0; padding-top: 20px; }
#reasonChips { display: flex; flex-direction: column; gap: 8px; }

/* The measurement list, where the limits come from and the notes: one grey line. */
.setup-line { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 14px; padding: 6px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--stripe); font-size: 14px; }
.setup-line .actions { gap: 4px 12px; }
.setup-line .source-line { flex: 0 1 auto; }
.setup-line #limitsLine { color: var(--muted); }
.notes-more { flex: 0 1 auto; min-width: 0; font-size: 14px; }
.notes-more:has(details[open]) { flex-basis: 100%; }
.notes-more summary { color: var(--accent); font-weight: 600; text-decoration: underline; text-underline-offset: 2px; cursor: pointer; border-radius: 3px; }
.notes-more ul { margin: 6px 0 0; padding: 8px 12px 8px 30px; border: 1px solid var(--warn-line); border-radius: 8px; background: var(--warn-bg); overflow-wrap: anywhere; }
.tag { font-size: 14px; }
.tag.suggested { color: var(--warn); }
.tag.saved { color: var(--good); }
.list-editor { display: flex; flex-direction: column; gap: 8px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); }
.list-editor label { display: flex; flex-direction: column; gap: 4px; font-size: 14px; font-weight: 600; }
.list-editor input { font: inherit; font-size: 14px; font-weight: 400; min-height: 36px; padding: 4px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--text); }
.list-editor input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.tally h3 { margin: 0; font-size: 14px; font-weight: 650; }
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { min-height: 30px; padding: 2px 12px; border-radius: 999px; text-align: left; font-size: 14px; font-weight: 600; }
.chip.bad { border-color: var(--bad); color: var(--bad); }
.chip.warn { border-color: var(--warn-line); color: var(--warn); }
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.chip .odd-text { padding: 0 3px; }
.chip[aria-pressed="true"] .odd-text { background: none; color: inherit; }
/* No data per measurement: one small line of chips at most. */
.chip-line { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; min-width: 0; }
.chip-line .chip-line-title { flex: none; font-size: 12px; font-weight: 600; color: var(--muted); }
.chip-line .chip-row { min-width: 0; }
.chip-line .chip { flex: none; min-height: 26px; padding: 1px 10px; font-size: 12px; }
.filter-line { margin: 0; font-size: 14px; }
.filter-line .hint { display: inline; }
/* The colour key, in the toolbar line just above the step 2 table (and above step 4's preview). */
.legend { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; margin: 0; font-size: 12px; color: var(--muted); }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.swatch { width: 14px; height: 14px; flex: none; border-radius: 3px; border: 1px solid; }
.swatch.good { background: var(--surface); border-color: var(--good); }
.swatch.bad { background: var(--bad-bg); border-color: var(--bad); }
.swatch.warn { background: var(--warn-cell-bg); border-color: var(--warn); }
.swatch.odd { background: var(--odd-bg); border-color: var(--odd); }
.swatch.suspect { background: transparent; border: 2px solid var(--suspect); }

/* The table box fits the screen under the bars; it scrolls inside. */
.run-table { max-height: calc(100vh - 132px); max-height: calc(100dvh - 132px); overflow: auto; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
/* A box that scrolls sideways fades at its right edge while there is more to
   see (zollerpage.js sets "more-right"), so a cut value never looks whole. */
.table-wrap { position: relative; min-width: 0; }
.table-wrap.more-right::after {
  content: ""; position: absolute; top: 1px; right: calc(1px + var(--sb-y, 0px)); bottom: calc(1px + var(--sb-x, 0px)); width: 36px; pointer-events: none; z-index: 5;
  border-radius: 0 8px 8px 0; background: linear-gradient(to right, transparent, color-mix(in srgb, var(--text) 22%, transparent));
}
.preview.more-right .check-table .judgment { box-shadow: inset 1px 0 0 var(--line), -10px 0 10px -6px color-mix(in srgb, var(--text) 30%, transparent); }
.run-grid { min-width: 100%; }
.run-grid thead { position: sticky; top: 0; z-index: 3; }
.run-grid thead th { position: static; vertical-align: bottom; font-size: 14px; }
.run-grid th.num { text-align: right; }
.run-grid th small { display: block; font-weight: 400; color: var(--muted); font-size: 12px; }
.run-grid th small.no-limits { font-style: italic; }
.run-grid .tool-col { position: sticky; left: 0; z-index: 2; font-weight: 650; box-shadow: inset -1px 0 0 var(--line); }
.run-grid thead th.tool-col { position: sticky; z-index: 4; }
.run-grid tbody td.tool-col { background: var(--surface); }
.run-grid tbody tr:nth-child(even) td.tool-col { background: var(--stripe); }
.run-grid tbody tr[data-key] { cursor: pointer; }
.run-grid tbody tr[data-key]:hover td.tool-col { color: var(--accent); }
.run-grid tbody tr[data-key]:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
/* Result: Passed green text, Failed red bold, no fill. Data: a green tick, or "6 missing" in amber. */
.run-grid tbody tr td.res.bad { background: var(--surface); font-weight: 650; }
.run-grid tbody tr:nth-child(even) td.res.bad { background: var(--stripe); }
.run-grid tbody tr td.data.good { font-weight: 700; }
.run-grid tbody tr td.data.warn { font-weight: 600; }
/* A tool without all its data: an amber edge on the tool number. */
.run-grid tbody tr.row-missing td.tool-col { box-shadow: inset 5px 0 0 var(--warn-line), inset -1px 0 0 var(--line); background: var(--warn-bg); padding-left: 16px; }
/* Why: one line; the full text shows on hover and in the tool's detail. */
.run-grid td.why { max-width: 360px; overflow: hidden; text-overflow: ellipsis; color: var(--muted); }
.run-grid tbody tr td.why.warn { color: var(--warn); }
.run-grid tbody tr.detail-row > td { padding: 0; background: var(--bg); white-space: normal; }
/* The tool's detail: Why first, the file facts on the right. */
.tool-detail {
  position: sticky; left: 0; width: min(1000px, calc(100vw - 96px)); padding: 14px 16px 16px;
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(220px, 300px); gap: 10px 20px; align-items: start; font-size: 14px;
}
.tool-detail > * { grid-column: 1; min-width: 0; }
.tool-detail > .detail-head { grid-column: 1 / -1; }
.tool-detail > .facts { grid-column: 2; grid-row: 2 / span 2; }
.detail-head { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; font-size: 15px; }
.detail-head button { margin-left: auto; }
.facts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 3px 12px; margin: 0; padding: 10px 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.detail-values { justify-self: start; max-width: 100%; background: var(--surface); border: 1px solid var(--line); }
.detail-values th { position: static; }
.detail-values td, .detail-values th { padding: 4px 12px; }
.detail-note { margin: 0; overflow-wrap: anywhere; }
.detail-why ul { margin: 4px 0 0; padding-left: 18px; }
.detail-why p { margin: 4px 0 0; }
/* A re-measured tool: its earlier readings, kept for the record only (owner, 2026-12-01). */
.detail-earlier { display: flex; flex-direction: column; gap: 4px; padding: 8px 10px; border: 1px dashed var(--line); border-radius: 8px; background: var(--surface); overflow-x: auto; }
.detail-earlier .earlier-values { max-width: 100%; }
.detail-earlier td.file { white-space: normal; overflow-wrap: anywhere; min-width: 160px; font-size: 12px; color: var(--muted); }

/* ---- Step 4: fill the check sheet */
.sheet-line { margin: 0; font-size: 14px; overflow-wrap: anywhere; }
.sheet-line .sep { color: var(--muted); }
.sheet-line span:empty + .sep, .sheet-line .sep:has(+ span:empty) { display: none; }
.check-options { display: flex; flex-direction: column; gap: 12px; flex: none; }
.check-options input[type="text"] {
  min-height: 36px; padding: 4px 10px; font: inherit; font-size: 14px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface); color: var(--text); min-width: 0;
}
.check-options input[type="text"]:focus-visible, .check-table input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.check-options input:disabled, .check-options input[readonly] { color: var(--muted); background: var(--stripe); }
.check-options .check { display: flex; align-items: center; gap: 8px; font-size: 14px; }
/* The five header boxes in one row. */
.header-fields { margin: 0; padding: 8px 14px 12px; border: 1px solid var(--line); border-radius: 8px; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px 12px; }
.header-fields legend { padding: 0 4px; font-size: 14px; font-weight: 600; }
.header-fields label { display: flex; flex-direction: column; gap: 4px; font-size: 14px; font-weight: 600; min-width: 0; }
/* The tool choice in one row. */
.pick-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; padding: 10px 14px; border: 1px solid var(--line); border-radius: 8px; }
.choice { margin: 0; padding: 0; border: none; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px; font-size: 14px; }
.choice legend { float: left; margin-right: 4px; padding: 0; font-size: 14px; font-weight: 600; }
.tools-field { flex: 1 1 240px; display: flex; min-width: 0; }
.tools-field input { flex: 1; }
.tab-field { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; }
.tab-field select { min-width: 140px; max-width: 100%; }
input[type="radio"] { accent-color: var(--accent); width: 16px; height: 16px; margin: 0; }
/* How many tools go on the sheet, in plain words, and the sample size chart beside it (owner, 2026-12-01). */
.decision-row { display: grid; grid-template-columns: minmax(0, 1fr) max-content; gap: 12px 24px; align-items: start; }
.decision-text { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.decision { margin: 0; padding: 8px 12px; border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: 8px; background: var(--bg); font-size: 14px; overflow-wrap: anywhere; }
.decision.warn { border-color: var(--warn-line); border-left-color: var(--warn-line); background: var(--warn-bg); }
/* A few rows of the chart show; the batch's row is scrolled into view (checkui.js). */
.chart-box { position: relative; max-width: 100%; max-height: 214px; overflow: auto; }
.chart-table { font-size: 12px; }
.chart-table caption { caption-side: top; text-align: left; padding: 0 0 4px; font-size: 12px; font-weight: 600; color: var(--muted); white-space: normal; }
.chart-table th, .chart-table td { padding: 2px 8px; }
.chart-table th { position: sticky; top: 0; }
.chart-table td:nth-child(2), .chart-table td:nth-child(3) { text-align: right; font-variant-numeric: tabular-nums; }
.chart-table tbody tr.current td { background: var(--accent); color: var(--accent-text); font-weight: 650; }
/* The preview, full width: its header row holds the colour key and the one main button. */
.sheet-out { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.preview-head { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 16px; }
.preview-head > .actions { margin-left: auto; }
.sheet-out .preview { min-height: 160px; max-height: calc(100vh - 132px); max-height: calc(100dvh - 132px); }
#checkPart { min-width: 0; }

.check-table th.sample { text-align: center; min-width: 64px; }
.check-table th.sample small { white-space: normal; }
.check-table th.sample, .check-table td.num { padding-left: 8px; padding-right: 8px; }
.check-table th small { display: block; font-weight: 400; color: var(--muted); font-size: 12px; }
.check-table th.sample.warn small { color: var(--warn); font-weight: 600; }
.check-table td.from { white-space: nowrap; }
.check-table td.from.warn { background: var(--warn-bg); }
.check-table td.from.muted { color: var(--muted); }
.check-table td.from.bad { background: var(--bad-bg); color: var(--bad); }
/* The Judgment column stays in view on the right. */
.check-table .judgment { position: sticky; right: 0; z-index: 1; font-weight: 700; text-align: center; box-shadow: inset 1px 0 0 var(--line); }
.check-table th.judgment { z-index: 2; }
.check-table tbody tr td.judgment { background: var(--surface); }
.check-table tbody tr:nth-child(even) td.judgment { background: var(--stripe); }
.check-table tbody tr td.judgment.bad { background: var(--bad-bg); }
.check-table input {
  width: 64px; min-height: 28px; padding: 2px 6px; font: inherit; font-size: 14px; text-align: right;
  border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--text);
}
.check-table input.invalid { border-color: var(--bad); }
.check-table td.good input, .check-table td.bad input { background: transparent; color: inherit; }

/* ---- Mid widths */
@media (max-width: 1100px) {
  .sum-row { grid-template-columns: minmax(0, 1fr); }
  .reasons { padding-top: 0; }
  .tool-detail { grid-template-columns: minmax(0, 1fr); }
  .tool-detail > .facts { grid-column: 1; grid-row: auto; justify-self: start; }
  .header-fields { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .decision-row { grid-template-columns: minmax(0, 1fr); }
  .step-bar-note { display: none; }
  #uploadHint { display: block; }
}

/* ---- Phones and narrow windows: the window scrolls (not the tab) */
@media (max-width: 860px) {
  html, body { height: auto; }
  .section.zoller { overflow: visible; }
  .topbar-in, .step-bar-in { padding-left: 16px; padding-right: 16px; }
  .steps { padding: 12px 16px 24px; }
  .run-table, .sheet-out .preview { max-height: calc(100vh - 72px); max-height: calc(100dvh - 72px); }
}

@media (max-width: 760px) {
  /* The bar: logo, name and Log out on one row, the two tabs full width under it. */
  .topbar-in { flex-wrap: wrap; height: auto; gap: 0 12px; }
  .brand { height: 52px; gap: 10px; }
  .brand-logo { height: 32px; }
  .brand-name { font-size: 18px; padding-left: 10px; }
  .sections { order: 3; flex: 1 1 100%; margin: 0 -16px; border-top: 1px solid var(--line); }
  .sections button { flex: 1; height: 46px; }
  .pane { padding: 14px; }
  .step.folded .pane-head > .actions, .step.slim .pane-head > .actions { flex: 1 1 100%; margin-left: 0; }
  .step-sum { flex-basis: 100%; }
  /* Tap targets: 44 px; boxes 16 px text so the phone does not zoom in. */
  button, .button { min-height: 44px; }
  button.small, .button.small, .chip, .sheet-slot .button { min-height: 36px; }
  .chip-line .chip { min-height: 32px; }
  select, input[type="text"], input[type="search"], input[type="password"], input:not([type]), .list-editor input, .check-options input[type="text"], textarea { font-size: 16px; min-height: 44px; }
  .check-table input { min-height: 36px; font-size: 16px; width: 76px; }
  .step-link { height: 40px; }
  .notice-list, .notice-suspect .notice-list { grid-template-columns: max-content minmax(0, 1fr); gap: 0 12px; }
  .notice-list > li, .notice-suspect .notice-list > li { grid-column: 1 / -1; grid-template-columns: 3em minmax(0, 1fr); grid-template-columns: subgrid; padding-bottom: 6px; }
  /* Small text buttons on their own (Edit, Show all): a 44 px tap target. */
  .setup-line button.link, button.notice-more { display: inline-flex; align-items: center; min-height: 44px; padding: 0 8px; }
  .notice-list .tool-link { grid-row: span 2; display: inline-flex; min-width: 32px; min-height: 40px; font-size: 17px; }
  .notice-list .n-res { font-size: 14px; }
  .counts { grid-template-columns: max-content minmax(0, 1fr) minmax(0, 1fr); grid-template-rows: auto 60px 60px; }
  .group-boxes { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-rows: 60px 60px; grid-template-columns: subgrid; grid-template-rows: subgrid; }
  .group-box { flex-direction: column; align-items: flex-start; justify-content: center; gap: 0; height: 60px; padding: 0 10px; }
  .group-box .box-count { line-height: 1.1; }
  .header-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .header-fields label:last-child { grid-column: span 2; }
  .preview-head > .actions { margin-left: 0; flex: 1 1 100%; }
  .preview-head > .actions button { flex: 1 1 auto; }
  /* The step 2 table: Data and Why are hidden so the values show (both are in the tool's detail). */
  .run-grid .data, .run-grid .why { display: none; }
  .run-grid th, .run-grid td { padding: 9px 8px; }
  .run-grid tbody tr.row-missing td.tool-col { padding-left: 12px; }
  .check-table td.from { display: none; }
  .check-table th.from { display: none; }
  /* Min and Max go under the item's name, so a value shows next to it. */
  .check-table .lim { display: none; }
  .check-table td[data-lim]::after { content: attr(data-lim); display: block; font-size: 12px; font-weight: 400; color: var(--muted); }
  /* The tool's detail opens as a sheet from the bottom, with Close on top. */
  .tool-detail {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 60; width: auto; max-height: 85vh; max-height: 85dvh; overflow: auto;
    padding: 0 16px 20px; background: var(--surface); border-top: 1px solid var(--line); border-radius: 14px 14px 0 0;
    box-shadow: 0 -8px 30px rgb(0 0 0 / 0.25); grid-template-columns: minmax(0, 1fr);
  }
  .tool-detail > .detail-head { position: sticky; top: 0; z-index: 1; margin: 0 -16px; padding: 12px 16px 8px; background: var(--surface); border-bottom: 1px solid var(--line); }
  .tool-detail .facts { background: var(--bg); }
  .tool-detail .detail-values { display: block; overflow-x: auto; }
  /* The tool's values fit the phone: Limits go under the name, Status wraps (the earlier readings' table keeps its own scroll). */
  .tool-detail .detail-values:not(.earlier-values) td { white-space: normal; }
  .tool-detail .detail-values:not(.earlier-values) td:nth-child(2) { white-space: nowrap; }
  .tool-detail .detail-values .lim { display: none; }
  .tool-detail .detail-values td[data-lim]::after { content: attr(data-lim); display: block; font-size: 12px; color: var(--muted); }
}

/* Dark: the logo keeps its own red and blue, on a light plate. */
@media (prefers-color-scheme: dark) {
  /* A placeholder (Search tools) in the page's own grey: 6.5:1 on a dark box. */
  ::placeholder { color: var(--muted); opacity: 1; }
  .brand-logo, .login-logo { box-sizing: content-box; padding: 3px 6px; border-radius: 6px; background: #ffffff; }
}

@media (prefers-reduced-motion: reduce) {
  .toast { transition: none; }
}
