h1:focus {
    outline: none;
}

.valid.modified:not([type=checkbox]) {
    outline: 1px solid var(--c-ok-text);
}

.invalid {
    outline: 1px solid var(--c-error-text);
}

.validation-message {
    color: var(--c-error-text);
}

.blazor-error-boundary {
    background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4MzcgMjY2LjYwNiA1Mi4yNjU4TDI2Ny4wNTIgNTIuNzk4NyAyNjcuNTM5IDUzLjYyODMgMjkwLjE4NSA5Mi4xODMxIDI5MC41NDUgOTIuNzk1IDI5MC42NTYgOTIuOTk2QzI5MC44NzcgOTMuNTEzIDI5MSA5NC4wODE1IDI5MSA5NC42NzgyIDI5MSA5Ny4wNjUxIDI4OS4wMzggOTkgMjg2LjYxNyA5OUwyNDAuMzgzIDk5QzIzNy45NjMgOTkgMjM2IDk3LjA2NTEgMjM2IDk0LjY3ODIgMjM2IDk0LjM3OTkgMjM2LjAzMSA5NC4wODg2IDIzNi4wODkgOTMuODA3MkwyMzYuMzM4IDkzLjAxNjIgMjM2Ljg1OCA5Mi4xMzE0IDI1OS40NzMgNTMuNjI5NCAyNTkuOTYxIDUyLjc5ODUgMjYwLjQwNyA1Mi4yNjU4QzI2MS4yIDUxLjQ4MzcgMjYyLjI5NiA1MSAyNjMuNTA2IDUxWk0yNjMuNTg2IDY2LjAxODNDMjYwLjczNyA2Ni4wMTgzIDI1OS4zMTMgNjcuMTI0NSAyNTkuMzEzIDY5LjMzNyAyNTkuMzEzIDY5LjYxMDIgMjU5LjMzMiA2OS44NjA4IDI1OS4zNzEgNzAuMDg4N0wyNjEuNzk1IDg0LjAxNjEgMjY1LjM4IDg0LjAxNjEgMjY3LjgyMSA2OS43NDc1QzI2Ny44NiA2OS43MzA5IDI2Ny44NzkgNjkuNTg3NyAyNjcuODc5IDY5LjMxNzkgMjY3Ljg3OSA2Ny4xMTgyIDI2Ni40NDggNjYuMDE4MyAyNjMuNTg2IDY2LjAxODNaTTI2My41NzYgODYuMDU0N0MyNjEuMDQ5IDg2LjA1NDcgMjU5Ljc4NiA4Ny4zMDA1IDI1OS43ODYgODkuNzkyMSAyNTkuNzg2IDkyLjI4MzcgMjYxLjA0OSA5My41Mjk1IDI2My41NzYgOTMuNTI5NSAyNjYuMTE2IDkzLjUyOTUgMjY3LjM4NyA5Mi4yODM3IDI2Ny4zODcgODkuNzkyMSAyNjcuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem;
    background-color: var(--c-error-text);
    padding: 1rem 1rem 1rem 3.7rem;
    color: var(--c-on-dark);
}

    .blazor-error-boundary::after {
        content: "An error has occurred."
    }

.darker-border-checkbox.form-check-input {
    border-color: var(--c-input-border);
}

/* Base (redesign spec §3). Selectors kept from the skeleton; values from tokens.css. */
html { background: var(--c-page); }
body { font-family: var(--font-body); font-size: var(--fs-md); color: var(--c-text); background: var(--c-page); margin: 0; line-height: 1.45; }
h1, h2, h3, h4 { font-family: var(--font-head); font-weight: 600; color: var(--c-text); line-height: 1.2; }
h1 { font-size: var(--fs-xl); margin: 0 0 var(--space-3); }
h2 { font-size: var(--fs-lg); margin: var(--space-6) 0 var(--space-3); }
h3 { font-size: var(--fs-md); margin: var(--space-5) 0 var(--space-2); }
/* A sub-heading inside a view reads one step below the view's h3 (§72.4). */
.view-panel h4 { font-size: var(--fs-sm); margin: var(--space-4) 0 var(--space-2); }
a { color: var(--c-link); }
input, select, textarea, button { font: inherit; }
input, select, textarea { font-variant-numeric: tabular-nums; }

table.grid { width: 100%; border-collapse: collapse; margin: var(--space-2) 0 var(--space-5); background: var(--c-panel); font-variant-numeric: tabular-nums; }
table.grid th, table.grid td { border-bottom: 1px solid var(--c-rule-soft); padding: 0.35rem 0.65rem; text-align: right; }
table.grid th:first-child, table.grid td:first-child,
table.grid th:nth-child(2), table.grid td:nth-child(2) { text-align: left; }
table.grid thead th { background: var(--c-sunken); font-family: var(--font-head); font-weight: 600; font-size: var(--fs-sm); color: var(--c-muted); text-transform: uppercase; letter-spacing: 0.03em; border-bottom: 1px solid var(--c-rule); }
td.differs { font-weight: 600; color: var(--c-error-text); }
/* An ion's unit, once per ion rather than once per cell (ui-conventions §1.4). */
table.grid .unit { margin-left: 0.35em; font-size: var(--fs-xs); font-weight: 400; color: var(--c-muted); text-transform: none; letter-spacing: normal; }
table.grid thead th .unit { display: block; margin-left: 0; }

button.btn, a.btn { display: inline-block; padding: 0.4rem 0.95rem; border-radius: var(--radius); border: 1px solid var(--c-input-border); background: var(--c-panel); color: var(--c-text); font-weight: 600; cursor: pointer; text-decoration: none; }
button.btn:hover, a.btn:hover { border-color: var(--c-primary); }
button.btn.primary:hover { background: var(--c-primary-hover); }


button.link { background: none; border: none; padding: 0; color: var(--c-link); cursor: pointer; text-decoration: underline; }

/* Diagnostics. Severity is a word and a shape, never colour alone — colour-blind readers and printed
   worksheets both exist, and this is a safety screen (UI conventions §3). */
li.diag { list-style: none; margin: 0.3rem 0; padding-left: 1.4rem; position: relative; }
li.diag::before { position: absolute; left: 0; font-weight: 700; }
li.diag.info::before    { content: "i";  color: var(--c-text-2); }
li.diag.warning::before { content: "!";  color: var(--c-warn-text); }
li.diag.error::before   { content: "\00d7"; color: var(--c-error-text); }
li.diag.warning strong { color: var(--c-warn-text); }
li.diag.error strong { color: var(--c-error-text); }
li.diag code { color: var(--c-muted); font-size: 0.8rem; margin-left: 0.5rem; }
/* The word keeps its distance when the message wraps; on a phone it takes its own line (§51). */
li.diag strong { margin-right: 0.35rem; }
@media (max-width: 767px) { li.diag strong { display: block; margin-right: 0; } }

/* The review screen. The decision is the point of the page, so it is a block of its own rather than
   a button trailing the tables (UI conventions §3, §6). */
section.decision {
    background: var(--c-panel); border: 1px solid var(--c-rule); border-left: 3px solid var(--c-primary); border-radius: var(--radius);
    padding: 0.9rem 1.1rem; margin: 1rem 0 1.5rem; max-width: 46rem;
}
.decision-status { margin-bottom: 0.5rem; }
.decision-actions { display: flex; align-items: center; gap: 1rem; margin: 0.6rem 0 0.2rem; }
.decision p.decided { margin: 0.4rem 0; }
/* The reason a control is unavailable, beside the control — never three scrolls away. */
.decision p.blocked { margin: 0.5rem 0 0; color: var(--c-error-text); font-weight: 600; }
.reject-form { margin-top: 0.6rem; }
.reject-form textarea { width: 100%; padding: 0.4rem 0.5rem; border: 1px solid var(--c-input-border); border-radius: var(--radius); }
.reject-form label { display: block; font-size: 0.9rem; color: var(--c-text-2); margin-bottom: 0.2rem; }
.reject-form div { margin-top: 0.5rem; display: flex; align-items: center; gap: 1rem; }
button.btn.primary { background: var(--c-primary); border: 1px solid var(--c-primary); color: var(--c-on-dark); font-weight: 600; }
button.btn.danger { background: var(--c-danger); border: 1px solid var(--c-danger); color: var(--c-on-dark); font-weight: 600; }
button.btn:disabled { opacity: 0.5; cursor: default; }

/* Status is a word, never a colour alone — an Active instruction that was never delivered has to
   read differently from one that arrived (§4). */
.status { display: inline-block; padding: 0.05rem 0.5rem; border-radius: var(--radius-pill); font-size: var(--fs-sm); font-weight: 600; }
.status.active { background: var(--c-ok-bg); color: var(--c-ok-text); }
.status.pending { background: var(--c-warn-bg); color: var(--c-warn-text); }
.status.rejected, .status.superseded, .status.proposed, .status.obsolete, .status.withdrawn { background: var(--c-neutral-bg); color: var(--c-neutral-text); }
.status-note { display: block; color: var(--c-error-text); font-size: 0.9rem; }
.status-note.neutral { color: var(--c-muted); }
.muted { color: var(--c-muted); font-size: 0.85rem; }
tr.set-aside td.value { text-decoration: line-through; color: var(--c-muted); }
/* Small print — an identifier shown for checking, never as the name (§42.4). */
.small { font-size: 0.75rem; }

ul.diagnostics { padding-left: 0; margin: 0.5rem 0 1.5rem; }
table.grid tr.unchanged td { color: var(--c-faint); }
table.grid.inputs th { text-align: left; background: var(--c-sunken); font-weight: 600; white-space: nowrap; }
table.grid.inputs td { text-align: left; }

/* --- rig setup -------------------------------------------------------------------------------- */
fieldset.setup { border: none; padding: 0; margin: 0; min-width: 0; }
fieldset.setup:disabled { opacity: 0.6; }
/* A field is a row (DL25): the label sits in a reserved column, so whatever wraps (a hint) starts under the control, not under the label. */
.field { display: flex; align-items: baseline; gap: 0.6rem; margin: 0.5rem 0; flex-wrap: wrap; position: relative; padding-left: 11.6rem; }
.field > label:first-child:not(.checkbox):not(.radio):not(.tick) { position: absolute; left: 0; top: 0.4rem; width: 11rem; color: var(--c-text-2); font-size: 0.9rem; line-height: 1.3; }
.field:has(> label:first-child + :is(label.checkbox, label.radio, label.tick, span, strong)) > label:first-child { top: 0.1rem; }
.field input[type=text], .field input[type=password], .field input[type=number], .field select, .field input[type=datetime-local] {
  padding: 0.3rem 0.4rem; border: 1px solid var(--c-input-border); border-radius: var(--radius);
}
/* A size attribute is a preference, not a floor — at phone width the field gives way rather than scroll the page. */
.field input[type=text], .field input[type=password], .field select { max-width: 100%; box-sizing: border-box; }
.field input[type=number] { width: 7rem; text-align: right; }
.field .unit, .field .prefix { color: var(--c-text-2); font-size: 0.9rem; }
.field .hint { color: var(--c-muted); font-size: var(--fs-sm); margin-left: var(--space-3); max-width: 34rem; }
.field label.radio, .field label.checkbox { display: flex; align-items: baseline; gap: 0.35rem; font-size: 0.95rem; }
.field .sources { display: flex; flex-direction: column; gap: 0.2rem; }
.field.confirm { background: var(--c-warn-bg); border: 1px solid var(--c-warn-rule); padding: 0.6rem 0.8rem; border-radius: var(--radius); max-width: 46rem; box-sizing: border-box; }
/* One with a caption (a link shown once) keeps the label column inside its padding (§68). */
.field.confirm:has(> label:first-child:not(.checkbox):not(.radio):not(.tick)) { padding-left: calc(11.6rem + 0.8rem); max-width: none; }
.field.confirm > label:first-child:not(.checkbox):not(.radio):not(.tick) { left: 0.8rem; top: 1rem; }
.field .link-box { display: flex; gap: 0.4rem; align-items: baseline; flex-wrap: wrap; max-width: 100%; }
.field .link-box input[type=text] { width: 32rem; max-width: 100%; font-family: monospace; font-size: 0.85rem; }
p.confirmed { color: var(--c-ok-text); margin: 0.6rem 0; }
table.grid.ions { max-width: 24rem; }
table.grid.ions td.label, table.grid.ions th { text-align: left; }
table.grid.ions tr.group th, table.grid.inputs tr.group th { background: var(--c-sunken); font-weight: 600; }
table.grid.ions input.ion { width: 6rem; text-align: right; padding: 0.15rem 0.3rem; border: 1px solid var(--c-input-border); border-radius: var(--radius); }
.save { margin: 1.5rem 0; display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.save p { margin: 0; flex-basis: 100%; }
p.saved { color: var(--c-ok-text); font-weight: 600; }

/* --- recipe editor ---------------------------------------------------------------------------- */
/* The charge balance sits directly under the targets: it is a check on what was just typed, not a
   summary somewhere else on the page. */
p.balance { margin: 0.4rem 0; font-size: 0.95rem; }
p.balance strong.agrees { color: var(--c-ok-text); }
p.balance strong.differs { color: var(--c-error-text); }
/* A warning changes nothing on its own (UI conventions §3) — it is a sentence, not a block. */
p.warn { color: var(--c-warn-text); max-width: 42rem; margin: 0.3rem 0 0.8rem; }
table.grid tr.superseded td { color: var(--c-muted); }
table.grid td .note { display: block; max-width: 24rem; }

/* --- products & stock tanks ------------------------------------------------------------------- */
table.grid.products td { vertical-align: top; text-align: left; }
table.grid.products .vessel { display: flex; align-items: baseline; gap: 0.4rem; margin-bottom: 0.25rem; }
.field .vessel { display: flex; align-items: baseline; gap: 0.4rem; }
.field .vessel input.label { width: 5rem; }
table.grid.products input.label { width: 5rem; padding: 0.15rem 0.3rem; border: 1px solid var(--c-input-border); border-radius: var(--radius); }
table.grid.products input[type=number],
table.grid.shares input[type=number] { width: 6rem; text-align: right; padding: 0.15rem 0.3rem; border: 1px solid var(--c-input-border); border-radius: var(--radius); }
table.grid.shares td:last-child { text-align: left; }
.availability { display: flex; align-items: baseline; gap: 0.8rem; margin: -0.4rem 0 0.4rem; flex-wrap: wrap; }
table.grid.log tr.superseded td { color: var(--c-faint); }
/* The make-up form reuses the decision block: recording one changes what every later dose is drawn against. */
section.decision.makeup .field { padding-left: 8.6rem; }
section.decision.makeup .field > label:first-child { width: 8rem; }
section.decision.makeup p.decided { flex-basis: 100%; }
.decision-actions { flex-wrap: wrap; }
/* The reason something is refused, wherever it is stated — not only inside a decision block. */
p.blocked { color: var(--c-error-text); font-weight: 600; max-width: 46rem; }
table.grid.tanks td { vertical-align: top; }
table.grid.tanks td:nth-child(2) { text-align: left; }
table.grid.tanks tr.product-start td { border-top: 2px solid var(--c-input-border); }
table.grid.tanks tr.detail > td { text-align: left; background: var(--c-sunken); }
table.grid.tanks tr.detail section.decision { margin: 0.4rem 0; }
table.grid.tanks td.num { text-align: right; }
table.grid.tanks td.text { text-align: left; }
table.grid.log td:nth-child(6), table.grid.log td:nth-child(7) { text-align: left; }
table.grid.log td.num { text-align: right; }
table.grid.products th, table.grid.log th { text-align: left; }

/* --- catalogue -------------------------------------------------------------------------------- */
.scroll { overflow-x: auto; }
table.grid.catalogue td.num, table.grid.label td.num { text-align: right; }
table.grid.catalogue td.text, table.grid.label td.text { text-align: left; }
table.grid.label input[type=number] { width: 6rem; text-align: right; padding: 0.15rem 0.3rem; border: 1px solid var(--c-input-border); border-radius: var(--radius); }
table.grid.label label.checkbox { display: flex; gap: 0.3rem; align-items: baseline; font-size: 0.9rem; }
table.grid.catalogue th, table.grid.label th { text-align: left; }

/* --- controllers ------------------------------------------------------------------------------ */
table.grid.controllers td.num, table.grid.mapping td.num { text-align: right; }
table.grid.controllers td.text, table.grid.mapping td.text, table.grid.controllers th, table.grid.mapping th { text-align: left; }
table.grid.mapping tr.superseded td { color: var(--c-faint); }
table.grid.mapping select { max-width: 22rem; }
textarea.paste { width: 100%; max-width: 60rem; font-family: ui-monospace, monospace; font-size: 0.8rem; padding: 0.4rem; border: 1px solid var(--c-input-border); border-radius: var(--radius); }
details.refresh { margin: 0.5rem 0 1rem; }
section.rig-slot { border-top: 1px solid var(--c-rule); padding-top: 0.4rem; margin-bottom: 1rem; max-width: 60rem; }
label.confirm-slot { background: var(--c-warn-bg); border: 1px solid var(--c-warn-rule); padding: 0.3rem 0.6rem; border-radius: var(--radius); }
ul.readiness { margin: 0.2rem 0 0.8rem; }
.warn-inline { color: var(--c-warn-text); font-size: 0.85rem; }

/* --- water (§41) ------------------------------------------------------------------------------ */
tr.editing > td { background: var(--c-sunken); }
.inline-editor { padding: 0.3rem 0.2rem; }
.inline-editor > strong { display: block; margin-bottom: 0.3rem; }
ul.water-summary { margin: 0.2rem 0 0.4rem; padding-left: 1.2rem; }
ul.water-summary li { margin-bottom: 0.2rem; }
details.water-values { margin: 0.2rem 0 0.4rem; }

/* A value under question (docs/workbook-logbook.md). Small, but never silent: it sits against the
   number, and it reads as the logbook id so the mark and the record share one address. */
.advisory {
    display: inline-block; margin-left: 0.3rem; padding: 0 0.3rem;
    font-size: 0.7rem; font-weight: 700; line-height: 1.5; vertical-align: super;
    border-radius: 0.2rem; text-decoration: none; white-space: nowrap;
}
.advisory.followed { background: var(--c-warn-bg); color: var(--c-warn-text); border: 1px solid var(--c-warn-rule); }
.advisory.corrected { background: var(--c-note-bg); color: var(--c-note-text); border: 1px solid var(--c-note-rule); }
.advisory:hover { text-decoration: underline; }
h2 .advisory { vertical-align: middle; font-size: 0.75rem; margin: 0 0.4rem 0 0; }
section.decision p.route { margin: 0.25rem 0 0.5rem; font-weight: 600; }

/* A difference nothing can be done about (§37): stated, not alarmed. Deliberately not blue — blue is
   already a link and an advisory badge here, and a third meaning is a legend to learn. */
table.grid td.accounted { color: var(--c-text-2); }
table.grid td.reason { font-size: 0.85rem; white-space: nowrap; text-align: left; }

p.crumbs, nav.crumbs { margin: 0.1rem 0 0.4rem; font-size: 0.9rem; }
nav.crumbs .crumb-sep { margin: 0 0.4em; color: var(--c-faint); }
nav.crumbs [aria-current] { color: var(--c-muted); }
.field label.tick, label.tick { display: inline-flex; align-items: baseline; gap: 0.3rem; margin-right: 0.75rem; font-size: 0.95rem; }

/* Blazor's reconnect/unhandled-error banner. */
#blazor-error-ui {
    background: var(--c-warn-bg);
    bottom: 0;
    box-shadow: 0 -1px 2px var(--c-shadow);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

    #blazor-error-ui .dismiss {
        cursor: pointer;
        position: absolute;
        right: 0.75rem;
        top: 0.5rem;
    }

.interval { display: flex; align-items: baseline; gap: var(--space-2); flex-wrap: wrap; margin: var(--space-1) 0 0; }
.interval input[type=number] { width: 5rem; text-align: right; padding: 0.15rem 0.3rem; border: 1px solid var(--c-input-border); border-radius: var(--radius); }

/* The tank layout (shared tanks spec §7.3): one card per tank. */
.layout-tank { border: 1px solid var(--c-input-border); border-radius: 6px; padding: 0.6rem 0.8rem; margin: 0.6rem 0; }
.layout-tank h3 { margin: 0 0 0.4rem; font-size: 1rem; }
.layout-tank .vessel { display: flex; align-items: baseline; gap: 0.4rem; margin-bottom: 0.25rem; }
.layout-tank input.label { width: 5rem; }
.tank-state { margin: 1.2rem 0; }
.tank-state h2 .muted { font-weight: normal; font-size: 0.9em; }
.tank-products { list-style: none; padding: 0; margin: 0.2rem 0 0.6rem; display: flex; flex-wrap: wrap; gap: 0.4rem 1.2rem; }
.vessel-state { border-left: 3px solid var(--c-input-border); padding-left: 0.8rem; margin: 0.6rem 0; }
.vessel-state h3 { margin: 0.2rem 0; font-size: 1rem; }
.vessel-actions { margin: 0.3rem 0; }

/* The design language (ui-conventions §12). */

/* A narrow table of few short columns reads better close together than stretched across the page. */
table.grid.compact, table.grid.label, table.grid.shares, table.grid.units, table.grid.inputs { width: auto; }
table.grid td.text, table.grid th.text { text-align: left; }

/* Actions: a value and its action never share a cell. */
button.btn.small, a.btn.small { padding: 0.15rem 0.6rem; margin-left: 0.5rem; font-size: var(--fs-sm); font-weight: 500; }
td.actions > .btn.small:first-child, p > .btn.small:first-child, div > .btn.small:first-child { margin-left: 0; }
a.btn.primary { background: var(--c-primary); border: 1px solid var(--c-primary); color: var(--c-on-dark); }
table.grid td.actions, table.grid th.actions { text-align: right; white-space: nowrap; width: 1%; }
td.actions > * + * { margin-left: 0.4rem; }

/* An area holds what one Save writes, with the Save at its foot, always in the same place. */
section.area { background: var(--c-panel); border: 1px solid var(--c-rule); border-radius: var(--radius); padding: var(--space-4) var(--space-5); margin: var(--space-5) 0; }
section.area > h2:first-child, section.area > fieldset > h2:first-of-type { margin-top: 0; }
.save-bar { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; margin-top: var(--space-4); padding-top: var(--space-3); border-top: 1px solid var(--c-rule-soft); }
.save-bar p { margin: 0; }
.save-bar p.decided { flex-basis: 100%; }
button.btn.primary[aria-disabled="true"] { opacity: 0.45; cursor: default; }
button.btn.primary[aria-disabled="true"]:hover { background: var(--c-primary); border-color: var(--c-primary); }
button.btn:not(.primary)[aria-disabled="true"] { opacity: 0.45; cursor: default; }

/* --- the design language audit (§68) ------------------------------------------------------------ */

/* Running text stops at a readable width (DL32); tables and grids are not paragraphs. */
.content p, .content li:not(.needs-item) { max-width: 46rem; }

/* An area inside a view: the view's panel is the frame (DL8). */
.view-panel > section.area { border: 0; padding: 0; background: none; margin: 0 0 var(--space-6); }
.view-panel > section.area:last-child { margin-bottom: 0; }

/* Row actions in fixed places, so each sits in the same column on every row (Stock tanks › State). */
td.actions .slot { display: inline-block; min-width: 5.4rem; text-align: right; }
table.grid.state td { vertical-align: middle; }
/* A vessel's own cells span its products' rows: they sit beside the first product, not half-way down the list. */
table.grid.state td[rowspan]:not([rowspan="1"]) { vertical-align: top; }

/* Quick fill: a shortcut beside the form, marked optional, never mistaken for a heading (catalogue product, §68). */
.quick { max-width: 46rem; background: var(--c-sunken); border: 1px dashed var(--c-input-border); border-radius: var(--radius); padding: var(--space-3) var(--space-4); margin: var(--space-2) 0 var(--space-4); box-sizing: border-box; }
.quick p.quick-head { font-family: var(--font-head); font-weight: 600; margin: 0 0 var(--space-1); }
.quick .tag { font-family: var(--font-body); font-weight: 500; font-size: var(--fs-xs); color: var(--c-muted); border: 1px solid var(--c-rule); border-radius: var(--radius); padding: 0 var(--space-1); margin-left: var(--space-2); background: var(--c-panel); }
.quick p.muted { margin: 0 0 var(--space-2); }
.quick-row { display: flex; gap: var(--space-2); align-items: baseline; flex-wrap: wrap; }
.quick-row select { max-width: 16rem; padding: 0.3rem 0.4rem; border: 1px solid var(--c-input-border); border-radius: var(--radius); }
.quick-row input[type=number] { width: 5rem; text-align: right; padding: 0.3rem 0.4rem; border: 1px solid var(--c-input-border); border-radius: var(--radius); }

/* The refill worksheet: a table's number box is 6rem (DL26), and its unit reads as a unit, not as a faint ion label. */
table.grid.worksheet input[type=number] { width: 6rem; text-align: right; padding: 0.15rem 0.3rem; border: 1px solid var(--c-input-border); border-radius: var(--radius); }
table.grid.worksheet .unit, table.grid.products .unit { font-size: var(--fs-sm); color: var(--c-text-2); }

table.grid td.value { text-align: right; }

/* A column's header is aligned like its cells (DL37): the header row follows the class its column's cells carry, so a
   table that right-aligns a number column by class cannot leave its header on the left. An explicit class on a header wins. */
table.grid:has(> tbody > tr:not(.group) > td:nth-child(1):is(.num, .value)) > thead > tr:last-child > th:nth-child(1):not(.text),
table.grid:has(> tbody > tr:not(.group) > td:nth-child(2):is(.num, .value)) > thead > tr:last-child > th:nth-child(2):not(.text),
table.grid:has(> tbody > tr:not(.group) > td:nth-child(3):is(.num, .value)) > thead > tr:last-child > th:nth-child(3):not(.text),
table.grid:has(> tbody > tr:not(.group) > td:nth-child(4):is(.num, .value)) > thead > tr:last-child > th:nth-child(4):not(.text),
table.grid:has(> tbody > tr:not(.group) > td:nth-child(5):is(.num, .value)) > thead > tr:last-child > th:nth-child(5):not(.text),
table.grid:has(> tbody > tr:not(.group) > td:nth-child(6):is(.num, .value)) > thead > tr:last-child > th:nth-child(6):not(.text),
table.grid:has(> tbody > tr:not(.group) > td:nth-child(7):is(.num, .value)) > thead > tr:last-child > th:nth-child(7):not(.text),
table.grid:has(> tbody > tr:not(.group) > td:nth-child(8):is(.num, .value)) > thead > tr:last-child > th:nth-child(8):not(.text),
table.grid:has(> tbody > tr:not(.group) > td:nth-child(9):is(.num, .value)) > thead > tr:last-child > th:nth-child(9):not(.text),
table.grid:has(> tbody > tr:not(.group) > td:nth-child(10):is(.num, .value)) > thead > tr:last-child > th:nth-child(10):not(.text),
table.grid:has(> tbody > tr:not(.group) > td:nth-child(11):is(.num, .value)) > thead > tr:last-child > th:nth-child(11):not(.text),
table.grid:has(> tbody > tr:not(.group) > td:nth-child(12):is(.num, .value)) > thead > tr:last-child > th:nth-child(12):not(.text),
table.grid:has(> tbody > tr:not(.group) > td:nth-child(13):is(.num, .value)) > thead > tr:last-child > th:nth-child(13):not(.text),
table.grid:has(> tbody > tr:not(.group) > td:nth-child(14):is(.num, .value)) > thead > tr:last-child > th:nth-child(14):not(.text) { text-align: right; }
table.grid:has(> tbody > tr:not(.group) > td:nth-child(1):is(.text, .label, .reason)) > thead > tr:last-child > th:nth-child(1):not(.num),
table.grid:has(> tbody > tr:not(.group) > td:nth-child(2):is(.text, .label, .reason)) > thead > tr:last-child > th:nth-child(2):not(.num),
table.grid:has(> tbody > tr:not(.group) > td:nth-child(3):is(.text, .label, .reason)) > thead > tr:last-child > th:nth-child(3):not(.num),
table.grid:has(> tbody > tr:not(.group) > td:nth-child(4):is(.text, .label, .reason)) > thead > tr:last-child > th:nth-child(4):not(.num),
table.grid:has(> tbody > tr:not(.group) > td:nth-child(5):is(.text, .label, .reason)) > thead > tr:last-child > th:nth-child(5):not(.num),
table.grid:has(> tbody > tr:not(.group) > td:nth-child(6):is(.text, .label, .reason)) > thead > tr:last-child > th:nth-child(6):not(.num),
table.grid:has(> tbody > tr:not(.group) > td:nth-child(7):is(.text, .label, .reason)) > thead > tr:last-child > th:nth-child(7):not(.num),
table.grid:has(> tbody > tr:not(.group) > td:nth-child(8):is(.text, .label, .reason)) > thead > tr:last-child > th:nth-child(8):not(.num),
table.grid:has(> tbody > tr:not(.group) > td:nth-child(9):is(.text, .label, .reason)) > thead > tr:last-child > th:nth-child(9):not(.num),
table.grid:has(> tbody > tr:not(.group) > td:nth-child(10):is(.text, .label, .reason)) > thead > tr:last-child > th:nth-child(10):not(.num),
table.grid:has(> tbody > tr:not(.group) > td:nth-child(11):is(.text, .label, .reason)) > thead > tr:last-child > th:nth-child(11):not(.num),
table.grid:has(> tbody > tr:not(.group) > td:nth-child(12):is(.text, .label, .reason)) > thead > tr:last-child > th:nth-child(12):not(.num),
table.grid:has(> tbody > tr:not(.group) > td:nth-child(13):is(.text, .label, .reason)) > thead > tr:last-child > th:nth-child(13):not(.num),
table.grid:has(> tbody > tr:not(.group) > td:nth-child(14):is(.text, .label, .reason)) > thead > tr:last-child > th:nth-child(14):not(.num) { text-align: left; }

/* Doses per tank: the same widths in every product's table, so the columns line up down the page (F26). */
table.grid.doses { table-layout: fixed; max-width: 60rem; }
table.grid.doses col.product { width: 32%; }
table.grid.doses col.vessel { width: 10%; }

table.grid select { padding: 0.15rem 0.3rem; border: 1px solid var(--c-input-border); border-radius: var(--radius); }

/* A button is as wide as its label (DL14), also in a column of inputs. */
.field .sources > .btn, .layout-tank .btn { align-self: flex-start; }

@media (max-width: 767.98px) {
    /* A phone has no room for a label column: the label sits above its control. */
    .field, section.decision.makeup .field { padding-left: 0; }
    .field.confirm:has(> label:first-child) { padding-left: 0.8rem; }
    .field > label:first-child:not(.checkbox):not(.radio):not(.tick) { position: static; width: 100%; }
    .field .hint { margin-left: 0; flex-basis: 100%; }
    /* The rig's tabs stay one row and scroll inside themselves (DL3). */
    .rig-header .tabs { flex-wrap: nowrap; overflow-x: auto; white-space: nowrap; }
}
