/* Sierra Dairy Lab - Recurring Obligations Register
   One stylesheet, plain CSS, no build step. Colours are defined once as
   custom properties at the top and reused everywhere below. */

:root {
  color-scheme: light dark;

  --bg: #f6f7f5;
  --surface: #ffffff;
  --surface-2: #f0f2ee;
  --border: #dcdfd8;
  --text: #1e2420;
  --text-muted: #5f6b63;
  --accent: #2f6b46;
  --accent-text: #ffffff;
  --accent-soft: #e6f0e8;
  --urgent: #a8442a;
  --urgent-soft: #fbeae4;

  /* Completed. A true green, distinct from the muted brand accent, with a
     white tick on top of it in both themes. */
  --done: #1e8e4a;
  --done-soft: #e4f4ea;
  --done-tick: #ffffff;

  /* Coming up, but not a problem yet - the middle state between "fine" and
     "deal with this", which servicing needs and nothing else did. */
  --warn: #8a5a12;
  --warn-soft: #fbf1df;
  --shadow: 0 1px 2px rgba(20, 30, 25, 0.06);
  --radius: 10px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141816;
    --surface: #1c211e;
    --surface-2: #232925;
    --border: #333b36;
    --text: #e6ebe7;
    --text-muted: #9aa79f;
    --accent: #6fbf8c;
    --accent-text: #102016;
    --accent-soft: #23342a;
    --urgent: #e8917a;
    --urgent-soft: #3a241e;
    --done: #2aa75d;
    --done-soft: #1d3327;
    --done-tick: #ffffff;
    --warn: #e0b055;
    --warn-soft: #33291a;
    --shadow: none;
  }
}

* { box-sizing: border-box; }

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

.wrap {
  width: min(920px, 100% - 2.5rem);
  margin-inline: auto;
}

/* ------------------------------------------------------------ header */

.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 1.1rem;
  flex-wrap: wrap;
  padding: 0.9rem 0;
}

/* Logo and app name sit side by side rather than stacked. The lockup needs
   about 60px of height before "DAIRY LABORATORY" is legible at all, and
   stacking a subtitle under that makes the header eat the top of a phone
   screen. */
.brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  text-decoration: none;
  color: inherit;
  margin-right: auto;
}

/* Built from the brand kit's vectors. The dark theme is served the kit's own
   white version of the lockup via <picture>, rather than propping a
   full-colour logo on a white plate - the wordmark's navy would otherwise
   measure about 1.3:1 against the dark surface and disappear. */
.brand-logo,
.panel-brand img {
  display: block;
  height: auto;
}

.brand-logo {
  width: 158px;
}

.brand-name { font-weight: 650; letter-spacing: -0.01em; }

.brand-sub {
  font-size: 0.8rem;
  line-height: 1.25;
  color: var(--text-muted);
  border-left: 1px solid var(--border);
  padding-left: 0.7rem;
  max-width: 11rem;
}

.panel-brand {
  max-width: 32rem;
  margin-bottom: 1.25rem;
}

.panel-brand img {
  width: 210px;
  max-width: 100%;
}

/* Six items plus the account block is enough to wrap a laptop-width header,
   so the spacing is tighter than it would be for three. */
.site-nav { display: flex; gap: 0.85rem; flex-wrap: wrap; }

.site-nav a,
.site-user a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.92rem;
  padding-bottom: 2px;
  border-bottom: 2px solid transparent;
}

.site-nav a:hover,
.site-user a:hover { color: var(--text); }

.site-nav a.active,
.site-user a.active {
  color: var(--text);
  border-bottom-color: var(--accent);
}

.site-user {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.92rem;
}

/* The phone menu. Hidden on wide screens, where the links sit in the header;
   see the phone rules at the end of this file for how it is shown. */
.site-menu { display: none; }

/* The account menu: everything set up once and rarely reopened, folded under
   the name so the header carries only the places you actually go. */
.site-account { position: relative; }

.site-account-toggle {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  cursor: pointer;
  list-style: none;
  font-size: 0.92rem;
  color: var(--text-muted);
  padding: 0.3rem 0;
}

.site-account-toggle::-webkit-details-marker { display: none; }
.site-account-toggle::marker { content: ''; }
.site-account-toggle:hover { color: var(--text); }
.site-account[open] .site-account-toggle { color: var(--text); }
.site-account[open] .site-account-toggle svg { transform: rotate(180deg); }

.site-account-panel {
  position: absolute;
  right: 0;
  top: 100%;
  z-index: 20;
  min-width: 13rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 10px 24px rgba(20, 30, 25, 0.14);
  padding: 0.35rem;
  display: flex;
  flex-direction: column;
}

.site-account-panel a,
.site-account-panel .link-button {
  display: block;
  padding: 0.5rem 0.6rem;
  border-radius: 7px;
  font-size: 0.92rem;
  color: var(--text);
  text-decoration: none;
  border-bottom: none;
  text-align: left;
}

.site-account-panel a:hover,
.site-account-panel .link-button:hover { background: var(--surface-2); }
.site-account-panel a.active { background: var(--accent-soft); font-weight: 600; }
.site-account-panel form { border-top: 1px solid var(--border); margin-top: 0.25rem; padding-top: 0.25rem; }
.site-account-panel .link-button { width: 100%; text-decoration: none; }

/* The register's four views, as tabs under the page heading rather than four
   unrelated-looking entries in the header. */
.subnav {
  display: flex;
  gap: 0.25rem;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.5rem;
}

.subnav a {
  padding: 0.5rem 0.85rem;
  font-size: 0.92rem;
  color: var(--text-muted);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

.subnav a:hover { color: var(--text); }

.subnav a.active {
  color: var(--text);
  font-weight: 600;
  border-bottom-color: var(--accent);
}

.site-footer {
  margin: 3rem 0 2rem;
  color: var(--text-muted);
  font-size: 0.82rem;
}

main.wrap { padding: 1.75rem 0 0; }

/* ------------------------------------------------------- page furniture */

h1 { font-size: 1.5rem; margin: 0; letter-spacing: -0.015em; }

.page-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}

.page-head p { margin: 0; }

.section-title {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  margin: 2rem 0 0.75rem;
  font-weight: 600;
}

.muted { color: var(--text-muted); }
.right { text-align: right; }
.nowrap { white-space: nowrap; }

.flash {
  padding: 0.7rem 0.9rem;
  border-radius: var(--radius);
  margin: 0 0 1.25rem;
  font-size: 0.92rem;
  border: 1px solid var(--border);
  background: var(--accent-soft);
}

.flash-error {
  background: var(--urgent-soft);
  border-color: var(--urgent);
  color: var(--urgent);
}

/* Tells you when the Monday email next goes out, so the schedule is visible
   rather than something you have to trust. Deliberately quiet - it is
   reference information, not an alert. */
.summary-bar {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex-wrap: wrap;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.6rem 0.85rem;
  margin-bottom: 1.25rem;
  font-size: 0.88rem;
  color: var(--text-muted);
}

.summary-bar svg { flex-shrink: 0; color: var(--accent); }
.summary-bar strong { color: var(--text); font-weight: 650; }
.summary-to { margin-left: auto; font-size: 0.82rem; }

.summary-bar-warn {
  background: var(--urgent-soft);
  border-color: var(--urgent);
  color: var(--urgent);
}

.summary-bar-warn svg { color: var(--urgent); }

@media (max-width: 640px) {
  .summary-to { margin-left: 0; width: 100%; }
}

.empty {
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  text-align: center;
  color: var(--text-muted);
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  max-width: 32rem;
}

.panel h1 { margin-bottom: 0.75rem; }

/* ---------------------------------------------------------- home page

   A two-column grid of cards. Each card declares whether it is full width or
   half, and the grid collapses to one column on a narrow screen. Adding a card
   is a registry entry and a partial - nothing here needs to change for it. */

.dashboard {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  align-items: start;
}

.dash-wide { grid-column: 1 / -1; }

.dash-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.1rem 1.2rem 1.2rem;
  min-width: 0;
}

.dash-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

/* The home page puts a heading on each band, so a card's own title dropped a
   level to sit under it. Both are styled here so the two cannot drift. */
.dash-head h2,
.dash-head h3 {
  margin: 0;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  font-weight: 600;
}

.dash-lede { margin: 0 0 0.6rem; font-size: 0.95rem; }
.dash-lede strong { font-weight: 650; }
.dash-warn { color: var(--urgent); }

.dash-empty {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.88rem;
}

.dash-empty code {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 0.05rem 0.3rem;
  font-size: 0.85em;
}

.dash-list,
.dash-links {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.1rem;
}

.dash-list li,
.dash-links li {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.45rem 0;
  border-top: 1px solid var(--border);
}

.dash-list li:first-child,
.dash-links li:first-child { border-top: none; }

.dash-list-main { min-width: 0; display: flex; flex-direction: column; }
.dash-list-name { font-size: 0.92rem; font-weight: 550; }
.dash-list-name a { color: var(--text); text-decoration: none; }
.dash-list-name a:hover { text-decoration: underline; }

.dash-list-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.dash-list-meta.urgent { color: var(--urgent); font-weight: 600; }
.dash-list-plain li { padding: 0.4rem 0; }

.dash-links a { color: var(--text); font-size: 0.92rem; font-weight: 550; }
.dash-links li { flex-direction: column; align-items: flex-start; gap: 0.1rem; }

.dash-more { margin: 0.6rem 0 0; font-size: 0.86rem; }
.dash-do { display: flex; }

/* The same tick as everywhere else, with the label carried by the title and a
   screen-reader-only span rather than visible text - a home card has room for
   the mark but not for a full-width button per row. */
.check-button {
  display: flex;
  align-items: center;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  color: inherit;
}

.check-button:hover .check { transform: scale(1.08); }

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

.dash-subtitle {
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  font-weight: 600;
  margin: 1rem 0 0.35rem;
}

.dash-foot {
  margin: 0.85rem 0 0;
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* Pipeline stages. A label, a proportional bar and a count - scaled to the
   busiest stage so the shape of the funnel is what you see first. */
.stage-bars {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.3rem;
}

.stage-bars li {
  display: grid;
  grid-template-columns: minmax(6rem, 10rem) 1fr 2rem;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.86rem;
}

.stage-label {
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stage-track {
  background: var(--surface-2);
  border-radius: 999px;
  height: 0.6rem;
  overflow: hidden;
}

.stage-fill {
  display: block;
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
}

.stage-count { text-align: right; font-weight: 650; font-variant-numeric: tabular-nums; }

/* A closed stage (Closed Won, Wrong Fit) is still worth seeing, but it is not
   part of the live funnel and should not compete with it. */
.stage-closed .stage-fill { background: var(--text-muted); opacity: 0.45; }
.stage-closed .stage-label,
.stage-closed .stage-count { opacity: 0.7; }

@media (max-width: 520px) {
  .stage-bars li { grid-template-columns: minmax(5rem, 7rem) 1fr 1.8rem; font-size: 0.8rem; }
}

/* Pipelines page: the sales pipelines sit two-up beside each other, with
   acquisition given the full width above them. */
.pipeline-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(20rem, 100%), 1fr));
  gap: 1rem;
  align-items: start;
}

.pipeline-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.1rem 1.2rem 1.2rem;
  min-width: 0;
}

.pipeline-card .dash-head h3 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 650;
}

.pipeline-card .dash-head h3 a { color: var(--text); text-decoration: none; }
.pipeline-card .dash-head h3 a:hover { text-decoration: underline; }

.panel-wide { max-width: none; }
.pipelines-foot { margin-top: 1rem; font-size: 0.86rem; }

/* Finance. Money is right-aligned and tabular so columns of figures line up
   digit for digit - the whole point of a budget-versus-actual table. */
.table-figures td,
.table-figures th { font-variant-numeric: tabular-nums; }
.table-figures .figure-actual { font-weight: 650; }

.variance-good { color: var(--done); font-weight: 600; }
.variance-bad { color: var(--urgent); font-weight: 600; }
.variance-pct { font-size: 0.82em; opacity: 0.8; margin-left: 0.2rem; }

/* Where things stand now: a fixed strip above the period section, because
   the bank balance does not change depending on which month you are reading
   underneath it. */
.today-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 0.9rem 1rem 1rem;
  margin-bottom: 0.5rem;
}
.today-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.today-head .section-title { margin: 0 0 0.6rem; }
.today-asof { font-size: 0.82rem; }
.today-tiles { margin-bottom: 0; grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); }
.today-tiles .stat-tile { background: var(--surface-2); }
.today-tiles .stat-value { font-variant-numeric: tabular-nums; }

/* The line under a tile's label: what the figure is made of, or the part of
   it that needs doing something about. */
.stat-note { font-size: 0.74rem; color: var(--text-muted); }
.stat-note-bad { color: var(--urgent); font-weight: 600; }

.period-cash { font-size: 0.86rem; margin: 0 0 0.6rem; font-variant-numeric: tabular-nums; }

/* ------------------------------------------------- keying in lab results

   Ten columns of boxes. The grid scrolls sideways rather than wrapping,
   because a line that wraps stops being a line you can read across from a
   bench sheet - which is the only way it is ever filled in. */
.entry-scroll { overflow-x: auto; margin-bottom: 0.8rem; }
.entry-table { font-size: 0.88rem; }
.entry-table th, .entry-table td { padding: 0.35rem 0.4rem; vertical-align: middle; }
.entry-table thead th { font-size: 0.68rem; white-space: nowrap; }
.entry-table tbody th {
  text-align: left;
  font-weight: 500;
  font-size: 0.86rem;
  text-transform: none;
  letter-spacing: normal;
  background: transparent;
  color: var(--text);
  white-space: nowrap;
}
.entry-table input {
  font: inherit;
  font-size: 0.86rem;
  padding: 0.22rem 0.35rem;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--surface);
  color: var(--text);
}
.entry-num { text-align: right; font-variant-numeric: tabular-nums; }
.entry-small { width: 4rem; }
.entry-ticket { width: 6rem; }
.entry-date { width: 9.5rem; }
.entry-error {
  display: block;
  font-size: 0.72rem;
  color: var(--urgent);
  margin-top: 0.15rem;
}

/* The two summary lines, set apart from the samples they summarise. */
.entry-average > *, .entry-overall > * {
  background: var(--surface-2);
  font-weight: 600;
  border-top: 1px solid var(--border);
}
.entry-overall > * { border-top: 2px solid var(--border); }

/* A button that is really a link - used where a form is needed for the CSRF
   token but the thing is one word in a row. */
.linkish {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  font-size: 0.82rem;
  color: var(--text-muted);
  text-decoration: underline;
  cursor: pointer;
}
.linkish:hover { color: var(--urgent); }
.inline-form { display: inline; margin: 0; }

/* One column since the entry form went: the balance is read, not typed. */
.cash-panel {
  display: grid;
  gap: 1.5rem;
  align-items: start;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
}

.cash-panel .section-title { margin-top: 0; }

.cash-amount {
  margin: 0;
  font-size: 2rem;
  font-weight: 650;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.cash-inline { font-variant-numeric: tabular-nums; }

.cash-history { font-size: 0.84rem; margin-top: 0.6rem; }

/* Period picker. One control on the heading row - three rows of links were
   honest but ate a third of the page before a figure appeared. */
.period-form {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-left: auto;
}
.period-form-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}
.period-form select {
  font: inherit;
  font-size: 0.88rem;
  padding: 0.25rem 0.45rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
}
.period-go { padding: 0.28rem 0.6rem; font-size: 0.82rem; }

/* Who owes what. Five bucket columns plus a total, so the figures are tight
   and anything past its terms is the only colour in the row. */
.aging-table th, .aging-table td { padding: 0.5rem 0.6rem; }
.aging-table thead th { font-size: 0.68rem; white-space: nowrap; }
.aging-table tbody th {
  text-align: left;
  font-weight: 600;
  font-size: 0.88rem;
  text-transform: none;
  letter-spacing: normal;
  background: transparent;
  color: var(--text);
}
.aging-name { min-width: 11rem; }
.aging-table tbody tr:hover { background: var(--surface-2); }
.aging-table tfoot th, .aging-table tfoot td {
  border-top: 2px solid var(--border);
  font-weight: 650;
  text-transform: none;
  letter-spacing: normal;
  background: var(--surface-2);
}
.aging-late > :first-child { box-shadow: inset 3px 0 0 var(--urgent); }

/* Only on rows with money past its terms, and quiet until the row is under
   the cursor - fifty of these shouting at once is not a call list. */
.chase-link {
  display: inline-block;
  margin-left: 0.5rem;
  padding: 0.05rem 0.4rem;
  font-size: 0.72rem;
  font-weight: 600;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--text-muted);
  text-decoration: none;
  white-space: nowrap;
  opacity: 0.55;
}
tr:hover > .aging-name > .chase-link,
.chase-link:focus { opacity: 1; color: var(--urgent); border-color: var(--urgent); }

/* A section folded away until it is wanted. */
.fold {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.7rem 0.9rem;
  margin: 1.2rem 0 0.6rem;
}
.fold[open] { padding-bottom: 0.9rem; }
.fold-summary {
  cursor: pointer;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.6rem;
}
.fold-title {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  font-weight: 600;
  color: var(--text-muted);
}
.fold-figures { font-size: 0.92rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.fold-figures .muted { font-weight: 400; }
.fold-bad { color: var(--urgent); }
.fold[open] .fold-summary { margin-bottom: 0.3rem; }

@media (max-width: 42rem) {
  .period-form { margin-left: 0; width: 100%; }
  .period-form select { flex: 1 1 auto; min-width: 0; }
  /* Five buckets will not fit a phone. The two that matter when you are not
     at a desk are what is current and what is badly late. */
  .aging-table thead th:nth-child(3), .aging-table tbody td:nth-child(3),
  .aging-table tfoot td:nth-child(3),
  .aging-table thead th:nth-child(4), .aging-table tbody td:nth-child(4),
  .aging-table tfoot td:nth-child(4),
  .aging-table thead th:nth-child(5), .aging-table tbody td:nth-child(5),
  .aging-table tfoot td:nth-child(5) { display: none; }
}

.form-wide { max-width: none; }
.form-wide .table input { width: 100%; }


/* Stat tiles. The template for any card that shows figures. */
.stat-tiles {
  list-style: none;
  margin: 0 0 0.75rem;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(7rem, 1fr));
  gap: 0.6rem;
}

.stat-tile {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.6rem 0.7rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.stat-value {
  font-size: 1.4rem;
  font-weight: 650;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.stat-tile-empty .stat-value { color: var(--text-muted); }

.stat-label {
  font-size: 0.76rem;
  color: var(--text-muted);
  line-height: 1.25;
}

/* Layout chooser and the link list. */
.layout-form .col-show,
.layout-form .col-order { width: 4.5rem; vertical-align: middle; }
.layout-form .col-order input { width: 3.6rem; }
.layout-form td { vertical-align: middle; }
.layout-form input[type="checkbox"] { width: 1.1rem; height: 1.1rem; }

.link-address {
  color: var(--text-muted);
  font-size: 0.84rem;
  word-break: break-all;
}

@media (max-width: 700px) {
  .dashboard { grid-template-columns: minmax(0, 1fr); }
}

/* -------------------------------------------------------------- cards */

.cards {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.6rem;
}

.card {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 0.9rem 1.1rem;
}

.card-urgent { border-left-color: var(--urgent); }
.card-done { border-left-color: var(--done); }
.card-main { flex: 1; min-width: 0; }
.card-action { flex-shrink: 0; min-width: 9rem; }
.card-action-done { display: flex; flex-direction: column; }

.card-title { margin: 0; font-size: 1rem; font-weight: 600; }

.card-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem 0.75rem;
  flex-wrap: wrap;
  margin: 0.35rem 0 0;
  font-size: 0.84rem;
  color: var(--text-muted);
}

.card-detail {
  margin: 0.5rem 0 0;
  font-size: 0.88rem;
  color: var(--text-muted);
  white-space: pre-wrap;
}

.card-missed {
  margin: 0.5rem 0 0;
  font-size: 0.84rem;
  color: var(--urgent);
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.due-in.urgent { color: var(--urgent); font-weight: 600; }
.cards-done .card-title { font-weight: 500; }

.badge {
  display: inline-block;
  padding: 0.12rem 0.5rem;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 0.74rem;
  letter-spacing: 0.01em;
  color: var(--text-muted);
  white-space: nowrap;
}

.badge-weekly { background: var(--accent-soft); }

/* ------------------------------------------------------------- tables */

.table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  font-size: 0.92rem;
}

.table th {
  text-align: left;
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  background: var(--surface-2);
  padding: 0.6rem 0.9rem;
  border-bottom: 1px solid var(--border);
}

.table td {
  padding: 0.7rem 0.9rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.table tr:last-child td { border-bottom: none; }
.table a { color: var(--text); }

/* The note under an item on the count sheet: which cartridge, which size -
   the part the name does not carry. */
.count-note {
  display: block;
  font-size: 0.8rem;
  font-weight: 400;
  color: var(--text-muted);
}

.row-detail {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.row-undone td { color: var(--text-muted); text-decoration: line-through; }

/* Obligations list: the "mark done" column leads the row. */
.table-register .col-do {
  width: 9.5rem;
  vertical-align: middle;
}

.table-register td { vertical-align: middle; }

.row-complete td { background: var(--done-soft); }
.row-complete .row-manage a,
.row-complete .row-manage .link-button { opacity: 0.75; }

.done-pill {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.45rem 0.6rem;
  border-radius: 8px;
  background: var(--done-soft);
  border: 1px solid var(--done);
  /* The label stays in the normal text colour: green-on-green tint only
     reaches 3.7:1, short of the 4.5:1 small bold text needs. The green lives
     on the box, which is a graphic and only needs 3:1. */
  color: var(--text);
  font-size: 0.88rem;
  font-weight: 650;
  white-space: nowrap;
}

/* In the obligations list the mark stacks above its label, which makes the
   check column read as a checklist rather than as a row of buttons. */
.table-register .button-do,
.table-register .done-pill {
  flex-direction: column;
  gap: 0.3rem;
  padding: 0.7rem 0.5rem;
}

.table-register .button-do { font-size: 0.88rem; }
.table-register .done-pill { font-size: 0.85rem; }

.undo-form { text-align: center; margin-top: 0.3rem; }
.undo-form .link-button { font-size: 0.8rem; }

/* The log carries the same mark: ticked for entries that stand, an empty box
   for ones that were withdrawn. */
.log-name {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
}

/* A withdrawn entry keeps the same box, just empty and muted. */
.log-name .check-open { color: var(--text-muted); }

.row-manage a { margin-right: 0.6rem; }
.row-detail.urgent { color: var(--urgent); font-weight: 600; }

.archived { margin-top: 2.5rem; }
.archived .table { opacity: 0.85; }

.pager {
  display: flex;
  gap: 1rem;
  align-items: center;
  justify-content: center;
  margin-top: 1.25rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* -------------------------------------------------------------- forms */

.form { margin-top: 1rem; max-width: 32rem; }

.field { margin-bottom: 1.1rem; }

.field label {
  display: block;
  font-size: 0.86rem;
  font-weight: 600;
  margin-bottom: 0.3rem;
}

.optional { font-weight: 400; color: var(--text-muted); }

input[type="text"],
input[type="email"],
input[type="password"],
input[type="date"],
input[type="month"],
input[type="number"],
input[type="tel"],
input[type="url"],
input[type="search"],
select,
textarea {
  width: 100%;
  padding: 0.55rem 0.7rem;
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

textarea { resize: vertical; }

input:focus-visible,
select:focus-visible,
textarea:focus-visible,
button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.hint { margin: 0.35rem 0 0; font-size: 0.82rem; color: var(--text-muted); }

.field-error {
  margin: 0.35rem 0 0;
  font-size: 0.84rem;
  color: var(--urgent);
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 1.5rem;
}

.filters {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 0.9rem;
  margin-bottom: 1.25rem;
  font-size: 0.9rem;
}

.filters label { font-size: 0.86rem; color: var(--text-muted); }
.filters select { width: auto; min-width: 12rem; }
.filters .checkbox { display: flex; align-items: center; gap: 0.35rem; }
.filters .checkbox input { width: auto; }

.inline-form { display: inline; }

/* ------------------------------------------------------------ buttons */

.button {
  display: inline-block;
  padding: 0.5rem 1rem;
  font: inherit;
  font-size: 0.92rem;
  font-weight: 550;
  color: var(--accent-text);
  background: var(--accent);
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}

.button:hover { filter: brightness(1.06); }

.button-quiet {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}

/* The primary action everywhere an obligation is listed: one tap, no
   confirmation step, and deliberately the heaviest thing in the row. */
.button-do {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.55rem 1.15rem;
  font-size: 0.95rem;
  font-weight: 650;
  width: 100%;
  box-shadow: var(--shadow);
}

/* The status mark. Same glyph, same place, whichever state a row is in, so
   the column can be scanned straight down. */
.check { flex-shrink: 0; }

/* The completed mark carries its own colour wherever it appears - a green box
   with a white tick - rather than inheriting the surrounding text colour. */
.check-done {
  color: var(--done);
  --check-tick: var(--done-tick);
}

.button-do:hover .check { transform: scale(1.06); }
.check { transition: transform 0.12s ease; }

@media (prefers-reduced-motion: reduce) {
  .check { transition: none; }
  .button-do:hover .check { transform: none; }
}

.link-button {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  font-size: inherit;
  color: var(--text-muted);
  text-decoration: underline;
  cursor: pointer;
}

.link-button:hover { color: var(--text); }

.quiet-link { color: var(--text-muted); font-size: 0.9rem; }

.task-extra { margin-top: 2.5rem; max-width: 32rem; }
.task-extra form { margin-top: 0.75rem; }

@media (max-width: 640px) {
  .card { flex-direction: column; align-items: stretch; }
  .card-action .button { width: 100%; }
  .header-inner { gap: 0.75rem 1.25rem; }
  /* On a phone the logo keeps its size - shrinking it is what made the
     wordmark illegible in the first place - and the subtitle steps aside. */
  .brand-sub { display: none; }
  .table { font-size: 0.86rem; }
  .table-register .col-do { width: 6.5rem; }
  .table-register td { padding: 0.6rem 0.4rem; }
  .table-register .button-do,
  .table-register .done-pill { padding: 0.55rem 0.3rem; font-size: 0.78rem; }
}

/* ------------------------------------------------------------- the chain

   A row of periods, oldest on the left. Solid is logged, hollow is missed, a
   dashed outline is the period still running. Size comes in as --chain-size
   so the same partial can draw a 12px strip on a card and a 16px one on its
   own page. */

.chain {
  display: inline-flex;
  gap: 0.26em;
  align-items: center;
  vertical-align: middle;
  font-size: var(--chain-size, 13px);
}

.chain-slot {
  width: 1em;
  height: 1em;
  border-radius: 0.28em;
  flex: none;
}

.chain-done { background: var(--done); }

/* A miss is drawn, not left blank: an empty space reads as "nothing was due",
   which is the one thing it does not mean. */
.chain-missed {
  border: 1.5px solid var(--border);
  background: var(--surface-2);
}

.chain-open {
  border: 1.5px dashed var(--accent);
  background: transparent;
}

/* Before the obligation existed. Barely there on purpose - it is history that
   was never anybody's to miss. */
.chain-before {
  background: var(--border);
  opacity: 0.35;
}

.card-chain {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin: 0.55rem 0 0;
}

.card-chain-note {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.card-chain-note.urgent { color: var(--urgent); }

/* --------------------------------------------------------- the reward

   Shown once, at the top of whatever page the tick redirected to. Everything
   in it was already true a moment earlier; what it adds is that you can see
   it. */

.reward {
  background: var(--surface);
  border: 1px solid var(--done);
  border-left: 4px solid var(--done);
  border-radius: var(--radius);
  padding: 0.95rem 1.1rem;
  margin: 1.25rem 0 0;
  box-shadow: var(--shadow);
  animation: reward-in 320ms cubic-bezier(0.2, 0.9, 0.3, 1.2);
}

@keyframes reward-in {
  from { opacity: 0; transform: translateY(-6px) scale(0.985); }
  to   { opacity: 1; transform: none; }
}

.reward-head {
  display: flex;
  align-items: center;
  gap: 0.8rem;
}

.reward-mark {
  color: var(--done);
  --check-tick: var(--done-tick);
  display: flex;
  animation: reward-mark 420ms 60ms cubic-bezier(0.2, 0.9, 0.3, 1.4) backwards;
}

@keyframes reward-mark {
  from { transform: scale(0.4); opacity: 0; }
  60%  { transform: scale(1.15); opacity: 1; }
  to   { transform: none; }
}

.reward-said { margin-right: auto; }
.reward-lede { margin: 0; }
.reward-lede strong { font-weight: 650; }

.reward-streak {
  margin: 0.15rem 0 0;
  font-size: 0.88rem;
  color: var(--text-muted);
}

.reward-score {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  line-height: 1.15;
}

.reward-points {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--done);
  font-variant-numeric: tabular-nums;
  animation: reward-points 480ms 80ms cubic-bezier(0.2, 0.9, 0.3, 1.4) backwards;
}

@keyframes reward-points {
  from { transform: translateY(8px) scale(0.7); opacity: 0; }
  to   { transform: none; opacity: 1; }
}

.reward-total {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.reward-parts {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.9rem;
  margin: 0.7rem 0 0;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.reward-part-n {
  font-weight: 650;
  color: var(--done);
  font-variant-numeric: tabular-nums;
}

.reward-level { margin-left: auto; }

.reward-unlocked {
  list-style: none;
  margin: 0.85rem 0 0;
  padding: 0.8rem 0 0;
  border-top: 1px solid var(--border);
  display: grid;
  gap: 0.5rem;
}

.reward-unlocked li {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.reward-badge {
  background: var(--accent);
  color: var(--accent-text);
  border-radius: 99px;
  padding: 0.1rem 0.5rem;
  font-size: 0.7rem;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.reward-badge-title { font-weight: 650; }

.reward-badge-detail,
.reward-note {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.reward-note { margin: 0.7rem 0 0; }
.reward-more { font-size: 0.85rem; }

/* ---------------------------------------------------------- home card */

.momentum-strip {
  display: flex;
  gap: 1.4rem;
  flex-wrap: wrap;
  align-items: flex-start;
}

.momentum-score {
  display: grid;
  gap: 0.25rem;
  min-width: 11rem;
}

.momentum-points {
  font-size: 1.9rem;
  font-weight: 700;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.momentum-level,
.momentum-next {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.momentum-bar {
  display: block;
  height: 6px;
  border-radius: 99px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  overflow: hidden;
  margin: 0.2rem 0;
}

.momentum-bar-fill {
  display: block;
  height: 100%;
  background: var(--accent);
  min-width: 2px;
}

.momentum-list {
  list-style: none;
  margin: 0;
  padding: 0;
  flex: 1 1 18rem;
  display: grid;
  gap: 0.4rem;
}

.momentum-list li {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.9rem;
}

.momentum-name {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.momentum-run {
  font-size: 0.8rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.momentum-run.at-risk { color: var(--urgent); }

/* ------------------------------------------------------- chains page */

.standing {
  display: flex;
  gap: 1.6rem;
  flex-wrap: wrap;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.1rem 1.25rem;
  margin-bottom: 1.5rem;
}

.standing-score {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
}

.standing-points {
  font-size: 2.6rem;
  font-weight: 700;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.standing-unit { color: var(--text-muted); font-size: 0.9rem; }

.standing-level { flex: 1 1 14rem; }
.standing-name { margin: 0 0 0.25rem; font-weight: 650; }
.standing-next { margin: 0.25rem 0 0; font-size: 0.85rem; }

.standing-facts {
  display: flex;
  gap: 1.4rem;
  margin: 0;
}

.standing-facts div { text-align: right; }

.standing-facts dt {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.standing-facts dd {
  margin: 0.1rem 0 0;
  font-size: 1.15rem;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

.chain-rows {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.6rem;
}

.chain-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 0.85rem 1rem;
}

.chain-row-risk { border-color: var(--urgent); }

.chain-row-main { flex: 1 1 14rem; min-width: 0; }
.chain-row-name { margin: 0; font-size: 1rem; font-weight: 650; }

.chain-row-meta {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  align-items: center;
  margin: 0.3rem 0 0;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.chain-row-run {
  display: flex;
  align-items: baseline;
  gap: 0.35rem;
  flex-wrap: wrap;
  justify-content: flex-end;
  min-width: 8.5rem;
  text-align: right;
}

.chain-run-n {
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.chain-run-noun,
.chain-run-zero {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.chain-run-risk {
  flex-basis: 100%;
  font-size: 0.78rem;
  color: var(--urgent);
}

/* --------------------------------------------------------- milestones */

.badges {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr));
  gap: 0.6rem;
}

.badge-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--done);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 0.8rem 0.95rem;
}

.badge-card-head {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
}

.badge-card-head h3 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 650;
  flex: 1 1 auto;
}

.badge-when { font-size: 0.75rem; color: var(--text-muted); white-space: nowrap; }

.badge-detail {
  margin: 0.35rem 0 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.scoring {
  margin: 0.5rem 0 0;
  padding-left: 1.1rem;
  display: grid;
  gap: 0.3rem;
  font-size: 0.9rem;
}

.scoring-n {
  font-weight: 650;
  color: var(--done);
  font-variant-numeric: tabular-nums;
}

.scoring-note { font-size: 0.88rem; max-width: 44rem; }

@media (max-width: 640px) {
  .reward-head { flex-wrap: wrap; }
  .reward-score { align-items: flex-start; flex-direction: row; gap: 0.5rem; align-self: center; }
  .reward-level { margin-left: 0; }
  .standing { gap: 1rem; }
  .standing-facts { gap: 1.1rem; }
  .chain-row-run { justify-content: flex-start; text-align: left; }
}

/* Animation here is decoration on top of information that is already on the
   page, so it is the first thing to go when somebody has asked for less. */
@media (prefers-reduced-motion: reduce) {
  .reward,
  .reward-mark,
  .reward-points { animation: none; }
}

/* --------------------------------------------------- who hears about it

   The list of people an obligation emails when it is logged. Each row is one
   label, so the name and the address are both part of the click target - a
   checkbox on its own is a small target and this is a choice about sending
   mail on somebody's behalf. */

.watchers {
  list-style: none;
  margin: 0.2rem 0 0;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}

.watchers li + li { border-top: 1px solid var(--border); }

.watcher {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  padding: 0.55rem 0.75rem;
  cursor: pointer;
  font-weight: 400;
}

.watcher:hover { background: var(--surface-2); }

.watcher input {
  accent-color: var(--accent);
  width: 1rem;
  height: 1rem;
  flex: none;
  align-self: center;
}

.watcher-name { font-weight: 600; }

/* The fill switch sits under the test it belongs to rather than beside it:
   it is a sentence, and a sentence does not fit on the same line as a name
   and a number without one of them being cut off. */
.watcher-sub {
  padding-top: 0;
  padding-left: 2.3rem;
}

.watcher-sub .watcher-email { white-space: normal; }

.watcher-email {
  color: var(--text-muted);
  font-size: 0.85rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}


/* ------------------------------------------------------ accounts and access

   One card per person, with every area listed whether or not they have it.
   Reading a full list is what makes access auditable; showing only what
   somebody has tells you nothing about what they do not. */

.user-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.1rem 1.2rem 1.2rem;
  margin-bottom: 1rem;
}

.user-off { opacity: 0.7; border-style: dashed; }

.user-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.user-name {
  margin: 0;
  font-size: 1.05rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.user-email { margin: 0.15rem 0 0; font-size: 0.88rem; }
.user-actions { display: flex; align-items: center; gap: 0.9rem; }
.badge-off { background: var(--urgent-soft); border-color: var(--urgent); color: var(--urgent); }

.access-grid {
  list-style: none;
  margin: 0.9rem 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
  gap: 0.25rem 1rem;
}

.access-grid li {
  display: flex;
  align-items: baseline;
  gap: 0.45rem;
  font-size: 0.88rem;
  padding: 0.15rem 0;
}

.access-mark { width: 0.9rem; flex: none; font-weight: 700; }
.access-yes .access-mark { color: var(--done); }
.access-no .access-mark { color: var(--text-muted); }
.access-no .access-label { color: var(--text-muted); }
.access-label { flex: 1 1 auto; min-width: 0; }

.access-state {
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  white-space: nowrap;
}

.access-yes .access-state { color: var(--done); }
.access-form { margin-top: 1rem; border-top: 1px solid var(--border); padding-top: 0.9rem; }

/* -------------------------------------------------------------- vehicles

   Three states worth telling apart at a glance: overdue, due now, and coming
   up. Colour carries it, but never alone - every one of these also says how
   many miles in words, because a red edge means nothing to somebody who
   cannot pick it out. */

.due-overdue { --due-colour: var(--urgent); --due-soft: var(--urgent-soft); }
.due-due { --due-colour: var(--urgent); --due-soft: var(--urgent-soft); }
.due-soon { --due-colour: var(--warn); --due-soft: var(--warn-soft); }
.due-ok { --due-colour: var(--border); --due-soft: var(--surface); }
.due-no-baseline { --due-colour: var(--border); --due-soft: var(--surface); }

.due-text-overdue,
.due-text-due { color: var(--urgent); font-weight: 600; }
.due-text-soon { color: var(--warn); font-weight: 600; }
.due-text-ok,
.due-text-no-baseline { color: var(--text-muted); }

.due-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 0.4rem 1.1rem 1rem;
  margin-bottom: 1.25rem;
}

.due-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.1rem; }

.due-list li {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.55rem 0;
  border-top: 1px solid var(--border);
}

.due-list li:first-child { border-top: none; }

.due-mark {
  width: 0.5rem;
  height: 1.6rem;
  border-radius: 999px;
  background: var(--due-colour);
  flex: none;
}

.due-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.due-main a { color: var(--text); font-weight: 600; text-decoration: none; }
.due-main a:hover { text-decoration: underline; }
.due-vehicle { font-size: 0.8rem; color: var(--text-muted); }
.due-label { font-size: 0.86rem; white-space: nowrap; color: var(--due-colour); font-weight: 600; }

.vehicle-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(18rem, 100%), 1fr));
  gap: 1rem;
  align-items: start;
}

.vehicle-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.1rem 1.2rem 1.2rem;
  min-width: 0;
}

.vehicle-card .dash-head h2 { margin: 0; font-size: 1rem; font-weight: 650; }
.vehicle-card .dash-head h2 a { color: var(--text); text-decoration: none; }
.vehicle-card .dash-head h2 a:hover { text-decoration: underline; }
.vehicle-miles { margin: 0 0 0.6rem; font-size: 0.95rem; font-variant-numeric: tabular-nums; }

/* The driver's form. First on the page, and the only thing most people who
   open this will ever touch. */
.log-panel { margin-bottom: 1.5rem; }
.log-form { margin-top: 0.5rem; }
.log-form .field { margin-bottom: 0.9rem; }
.force-check { font-size: 0.84rem; color: var(--text-muted); display: flex; align-items: center; gap: 0.4rem; }
.force-check input { width: auto; }

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

.service-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--due-colour);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem 1.1rem;
  margin-bottom: 0.8rem;
}

.service-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.service-name { margin: 0; font-size: 1rem; font-weight: 650; }
.service-meta { margin: 0.2rem 0 0; font-size: 0.82rem; }

/* One row on a desktop, stacked on a phone by the rules further down. */
.service-done {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.8rem;
  align-items: center;
}

.service-done input[type="text"] { width: auto; flex: 1 1 8rem; min-width: 0; }
.service-done input[type="date"] { width: auto; flex: 0 1 11rem; }
.service-done button { flex: none; }

.service-history {
  list-style: none;
  margin: 0.7rem 0 0;
  padding: 0.6rem 0 0;
  border-top: 1px solid var(--border);
  font-size: 0.82rem;
  color: var(--text-muted);
  display: grid;
  gap: 0.2rem;
}

.service-edit { margin-top: 0.8rem; font-size: 0.86rem; }
.service-edit summary { cursor: pointer; color: var(--text-muted); }
.service-edit summary:hover { color: var(--text); }

/* =============================================================== phones

   Kept together at the end on purpose, so these rules win over the ones above
   without needing extra specificity, and so everything that changes on a
   phone can be read in one place.

   Measured against a 375px screen before these existed: three pages scrolled
   sideways, the header took a quarter of every page, most tap targets were
   under the 24px accessibility minimum, and iPhone zoomed in on any form field
   whose text was under 16px. Each block below answers one of those. */

/* -------------------------------------------------------------- supplies

   The count sheet replaces a piece of paper, and the paper is the thing to
   beat: it is fast, it is walkable in shelf order, and a blank line on it
   plainly means "did not get to this". So the list keeps its own order rather
   than sorting the urgent things to the top, the boxes are big enough to type
   into while holding a clipboard, and what was counted last time sits under
   each name - which is the number people actually check against. */

.due-name { color: var(--text); font-weight: 600; }

/* The two states that mean the same thing as a vehicle's, reusing its colours
   so "needs doing" looks the same everywhere in the app. */
.due-unknown { --due-colour: var(--border); --due-soft: var(--surface); }
.due-text-unknown,
.due-text-no-level { color: var(--text-muted); }

.count-hint { margin: 0 0 1.25rem; }
.count-hint code {
  background: var(--surface-sunken, var(--surface));
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 0.05rem 0.3rem;
  font-size: 0.85em;
}

.count-group { margin-bottom: 1.5rem; }

.count-list { list-style: none; margin: 0; padding: 0; }

.count-row {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  flex-wrap: wrap;
  padding: 0.5rem 0;
  border-top: 1px solid var(--border);
}

.count-row:first-child { border-top: none; }

.count-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }

.count-name { font-weight: 600; color: var(--text); cursor: pointer; }

.count-unit {
  font-weight: 400;
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-left: 0.35rem;
}

.count-last { font-size: 0.8rem; color: var(--text-muted); }
.count-unset { color: var(--warn); }

/* Wide enough for "1000" and a fraction, no wider: a row of full-width boxes
   reads as a wall and makes the sheet look longer than it is. */
.count-input {
  width: 7rem;
  flex: none;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.count-error { flex: 1 1 100%; margin: 0.2rem 0 0; }

/* A left edge on the rows that need ordering, so the sheet itself shows what
   the panel at the top is about without re-reading it. */
.count-row.count-out,
.count-row.count-low {
  border-left: 3px solid var(--due-colour);
  padding-left: 0.7rem;
  margin-left: -0.7rem;
}

.count-row.count-out { --due-colour: var(--urgent); }
.count-row.count-low { --due-colour: var(--warn); }


/* The three numbers at the top of On hand. Big enough to read from across the
   room, which is where somebody glances at this before ordering. */

.tally {
  list-style: none;
  margin: 0 0 1.5rem;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(7rem, 1fr));
  gap: 0.75rem;
}

.tally li {
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 3px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 0.8rem 1rem;
}

.tally-bad  { border-top-color: var(--urgent); }
.tally-warn { border-top-color: var(--warn); }
.tally-good { border-top-color: var(--accent, var(--border)); }

.tally-figure {
  display: block;
  font-size: 1.7rem;
  font-weight: 650;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.tally-label { font-size: 0.82rem; color: var(--text-muted); }

.on-hand-figure { font-variant-numeric: tabular-nums; }

/* Direction, never by colour alone - the sign is always there to read. */
.change { font-weight: 600; font-variant-numeric: tabular-nums; }
.change-down { color: var(--warn); }
.change-up { color: var(--text-muted); }
/* Two fields that are one thing - a first and last name. Side by side on a
   screen with room, stacked on a phone, where two half-width boxes would be
   two cramped boxes. */

.field-row {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.field-row .field { flex: 1 1 12rem; min-width: 0; }

/* A few related boxes kept together without the browser's default
   fieldset border, which belongs to another decade. */
.field-group {
  border: none;
  padding: 0;
  margin: 0 0 1rem;
}
.field-group legend {
  padding: 0;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.field-group-title {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  margin: 1.5rem 0 0.6rem;
}

/* How many of a test one sample gets, beside its tick on the setup page.
   Narrow, because it is almost always 1 and occasionally 2. */

.times-input {
  width: 3.2rem;
  padding: 0.1rem 0.3rem;
  font-size: 0.85rem;
  text-align: right;
}

/* The worked-out total at the head of the daily count. It sits where an
   input would, so the column of numbers reads straight down, but it is an
   output: nothing to type, and nothing that can disagree with the lines
   under it. */

.count-total {
  display: inline-block;
  width: 7rem;
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 650;
  font-size: 1.05rem;
  padding: 0.25rem 0.1rem;
}

/* The sample counts read as the thing the tests are counts of, so the first
   line of the block is a little heavier. */
.count-row-lead .count-name { font-size: 1.02rem; }

/* ------------------------------------------------------------- the rota

   Who is in, which days. A real table because the question is read down a
   column - "is anybody here on Thursday" - and a tick is a big target
   because this gets filled in quickly by somebody standing up. */

.rota .rota-day { text-align: center; }
.rota-day-name { display: block; font-size: 0.72rem; letter-spacing: 0.05em; }
.rota-day-date { display: block; font-size: 0.7rem; color: var(--text-muted); font-weight: 400; }

.rota-cell { text-align: center; padding: 0 !important; }

/* The whole cell is the target, not just the box inside it. */
.rota-tick {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  min-width: 44px;
  cursor: pointer;
}

.rota-tick input { width: 20px; height: 20px; cursor: pointer; }

/* Today reads down the column, so the day somebody is actually asking about
   is the one that stands out. */
.rota-today { background: var(--accent-soft); }

.rota-count { text-align: center; font-weight: 650; font-variant-numeric: tabular-nums; }
.rota-none { color: var(--urgent); }

.rota-note input { width: 100%; min-width: 9rem; font-size: 0.85rem; }

/* The sample count sits beside the test counts but is not one of them: it is
   how many came in, not how many were run. Weight is what keeps the eye from
   reading it as the first test column. */
.grid-total { font-weight: 650; color: var(--text); }

/* One row, two cells. Without a width the label would take half the table and
   leave the number adrift at the far edge. */
.components-table .grid-row-head { width: 12rem; }

/* ------------------------------------------------- the lab's own mark

   The sample section is the only part of the app that belongs to I&A rather
   than the company, and it is read on a shared bench machine that is usually
   already open when somebody walks up to it. */

.lab-head {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  margin-bottom: 0.9rem;
  padding: 0.6rem 0.9rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

/* The mark is black line art on an opaque white background, so it sits on a
   white chip rather than being inverted - inverting would turn the background
   into a black rectangle on the dark card. In light mode the chip is the same
   white as the page and disappears. The same reasoning keeps the emailed copy
   on an explicit white background, where a dark-mode mail client would
   otherwise flip the page around it. */
.lab-logo {
  width: 96px;
  height: auto;
  flex: none;
  background: #ffffff;
  border-radius: 6px;
}

/* ------------------------------------------------ switching registers

   One row of pill tabs: the company's recurring obligations, the lab
   integration work, and everything at once. Pills rather than the underlined
   subnav above them, because two rows of the same tab style would read as one
   confused navigation. */

.list-switch {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 1.2rem;
}

.list-switch a {
  display: inline-flex;
  align-items: baseline;
  gap: 0.45rem;
  padding: 0.35rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.9rem;
}

.list-switch a:hover { color: var(--text); }

.list-switch a.active {
  background: var(--accent-soft);
  border-color: var(--accent, var(--border));
  color: var(--text);
  font-weight: 600;
}

/* The count is the point of the tab: it says whether there is anything in
   there before you click it. */
.list-count {
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
}

.list-switch a.active .list-count { color: var(--text); }

.list-blurb { margin-top: -0.7rem; margin-bottom: 1.2rem; }

.badge-once { background: var(--warn-soft); }

/* --------------------------------------------------------- the lab notes

   A day's log: written in a box, read back as a list. The writing box is
   deliberately tall - this replaced a document, and a four-line textarea
   would have people writing less than they did before. */

.note-box {
  width: 100%;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.92rem;
  line-height: 1.6;
  resize: vertical;
}

.note-send { margin-top: -0.6rem; }

.note-read {
  list-style: none;
  margin: 1.2rem 0 0;
  padding: 0;
  line-height: 1.6;
}

.note-read li { padding: 0.18rem 0; }
.note-read .note-bullet { list-style: disc; margin-left: 1.15rem; text-indent: 0; }
.note-read .note-text { font-weight: 650; padding-top: 0.7rem; list-style: none; }
.note-read .note-sub { margin-left: 2.6rem; }

/* The warning before a note goes out. Amber rather than red: this is a guess
   about what a line means, and a guess should not look like a verdict. */
.secret-warn {
  margin: 0 0 1.2rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--warn);
  border-left-width: 4px;
  border-radius: var(--radius);
  background: var(--warn-soft);
  color: var(--text);
  font-size: 0.92rem;
}

.secret-warn p { margin: 0 0 0.5rem; }
.secret-warn ul { margin: 0; padding-left: 1.1rem; }
.secret-warn li { padding: 0.15rem 0; font-size: 0.88rem; }

.secret-line {
  font-variant-numeric: tabular-nums;
  color: var(--warn);
  font-weight: 650;
  padding-right: 0.35rem;
}

.lab-name {
  font-size: 1.25rem;
  font-weight: 650;
  letter-spacing: 0.01em;
}

/* ------------------------------------------------- which half is missing

   Two rows at the top of the day: micro and components. Whoever walks up to
   key components in hours later should not have to read a paragraph to find
   what is already there, so the outstanding row carries the colour and the
   finished one gets out of the way. */

.half-state { margin-bottom: 1.4rem; }

/* The header row is uppercase small type; the row headings are names, and
   a name set in that is a label rather than a word you read. */
.half-table th[scope='row'] {
  font-weight: 650;
  font-size: 0.95rem;
  text-transform: none;
  letter-spacing: 0;
  color: var(--text);
  background: transparent;
}

.half-what {
  display: block;
  font-weight: 400;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.half-when {
  font-size: 0.8rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.half-out { background: var(--warn-soft); }
.half-out th[scope='row'] { color: var(--warn); }

.badge-in { background: var(--accent-soft); }

.badge-out {
  background: var(--warn);
  border-color: var(--warn);
  color: var(--surface);
  font-weight: 600;
}

/* ------------------------------------------------------- the sample grid

   The lab's own sheet: a row per kind of sample, a column per test. It is a
   real table rather than stacked cards because the whole point is reading
   down a column, and it scrolls sideways on a narrow screen instead of
   wrapping - a grid that reflows is a grid you cannot add up. */

.grid-scroll {
  overflow-x: auto;
  margin-bottom: 1.25rem;
  /* So a sideways scroll is discoverable rather than a surprise. */
  border-radius: var(--radius);
}

.sample-grid { margin-bottom: 0; min-width: 100%; }
.sample-grid th, .sample-grid td { white-space: nowrap; }

.grid-row-head {
  text-align: left;
  font-weight: 600;
  color: var(--text);
  position: sticky;
  left: 0;
  background: var(--surface);
}

.grid-count { text-align: right; font-variant-numeric: tabular-nums; }
.grid-fill { width: 1%; }

.sample-grid tfoot td,
.sample-grid tfoot th {
  border-top: 2px solid var(--border);
  font-variant-numeric: tabular-nums;
}

.grid-input {
  width: 4.6rem;
  text-align: right;
}

.tally-good { border-top-color: var(--accent); }

/* A section heading with an action beside it - the "same as raw" offer on the
   daily sample count. The button sits on the heading rather than above the
   boxes so it reads as being about that section, not about the next field. */

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.section-head .section-title { margin-bottom: 0.3rem; }

.fill-button {
  font-size: 0.85rem;
  white-space: nowrap;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.15rem 0.7rem;
  background: var(--surface);
}

.fill-button:hover { border-color: var(--accent); color: var(--accent); }

/* ----------------------------------------------------------------- paper

   The supply count as a sheet of paper, and the rules that make any page in
   this app print without the furniture.

   Two columns, because the form this replaces was two columns and because 21
   items down one of them is two pages. Nothing here relies on colour: a
   printer may well be black and white, and "the red ones need ordering" is
   not a sentence you can act on from a photocopy. Every low line is marked
   with a word as well as a rule. */

.print-sheet {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.print-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  border-bottom: 2px solid var(--text);
  padding-bottom: 0.6rem;
  margin-bottom: 0.9rem;
}

.print-title { margin: 0; font-size: 1.25rem; }
.print-sub { margin: 0.1rem 0 0; color: var(--text-muted); font-size: 0.85rem; }
.print-meta { text-align: right; font-size: 0.8rem; color: var(--text-muted); line-height: 1.5; }
.print-meta strong { color: var(--text); }

.print-order {
  border: 1px solid var(--text);
  border-radius: 6px;
  padding: 0.6rem 0.9rem;
  margin-bottom: 1rem;
}

.print-order h3 {
  margin: 0 0 0.35rem;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

.print-order ul {
  margin: 0;
  padding: 0;
  list-style: none;
  columns: 2;
  column-gap: 1.5rem;
  font-size: 0.85rem;
}

.print-order li { break-inside: avoid; padding: 0.1rem 0; }
.print-order-name { font-weight: 650; }
.print-order-detail { color: var(--text-muted); }

.print-allgood { font-weight: 600; margin: 0 0 1rem; }

.print-cols { columns: 3; column-gap: 1.4rem; }

/* A category must not be split down the middle by a column break - half an
   entry list under a heading that is somewhere else is worse than a ragged
   column. */
.print-group { break-inside: avoid; margin: 0 0 0.9rem; }

.print-group h3 {
  margin: 0 0 0.2rem;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.15rem;
}

.print-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  table-layout: fixed;
}

.print-table td { padding: 0.3rem 0; vertical-align: baseline; }

/* Percentages rather than content widths, so every rule in a column lines up
   with the one above it. A long name wraps rather than being cut short with an
   ellipsis: this is a sheet somebody acts on, and a name they cannot read in
   full is worse than a row that costs an extra line. */
.print-item { width: 52%; }
/* The last count and the space to write a new one share one continuous rule,
   the way the paper form this replaces does: a number written on a line, not
   a number with an orphaned line next to it. */
.print-qty,
.print-blank { border-bottom: 1px solid var(--border); }

.print-qty {
  width: 28%;
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  padding: 0.3rem 0.3rem 0.12rem 0.4rem;
}

.print-blank { width: 20%; }

.print-low .print-item { font-weight: 650; }

.print-flag {
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  border: 1px solid currentColor;
  border-radius: 3px;
  padding: 0 0.22rem;
  vertical-align: 0.05em;
}

.print-key {
  margin: 0.6rem 0 0;
  font-size: 0.72rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  padding-top: 0.5rem;
}

kbd {
  font: inherit;
  font-size: 0.85em;
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 0.05rem 0.3rem;
  background: var(--surface);
}

@media print {
  /* Everything that is screen furniture. The header, the tabs, the flash
     message and anything marked no-print are all navigation, and navigation
     on paper is just ink. */
  .site-header,
  .site-footer,
  .subnav,
  .page-head,
  .flash,
  .no-print { display: none !important; }

  /* And anything that is not ours at all. A browser extension - Apollo, a
     password manager, a grammar checker - injects its panel into the page,
     which puts it outside the named page an invoice prints on, so it comes
     out as an extra sheet in the app's default landscape after the portrait
     invoice. Every printable thing this app has is inside <main>, so nothing
     else is wanted on paper.

     Both lines are needed. A panel appended to <body> is caught by the
     second; Apollo hangs its off <html> instead, usually as a shadow host,
     which only the first reaches. Hiding the host hides the shadow tree with
     it. An extension that sets display on its own element inline and marks
     it important still wins - inline important beats a stylesheet - and the
     answer there is to turn the extension off for this site.

     Worth knowing when this looks wrong again: a PDF whose pages are not all
     the same size is the tell. Mixed 612x792 and 792x612 means something
     outside the invoice claimed a page of its own, and it is worth finding
     out which element before changing anything about the invoice. */
  html > *:not(head):not(body) { display: none !important; }
  body > *:not(main) { display: none !important; }

  /* Landscape by default. The sheet is a wide, shallow thing - three columns
     of short lists - and on a portrait page that wastes the bottom third while
     cramping the columns. Browsers that honour this open the print dialog
     already set to landscape; the dialog can still override it. */
  @page { size: letter landscape; margin: 13mm; }

  /* Wider page, so the lists go three across instead of two. That is what
     keeps it on one sheet: landscape gives about 240px less height to play
     with, and a third column takes a third off the stack. */
  .print-cols { columns: 3; column-gap: 1.6rem; }

  /* Room to write. A cramped row is a row somebody writes over the line. */
  .print-table td { padding: 0.42rem 0; }
  .print-qty { padding: 0.42rem 0.3rem 0.16rem 0.4rem; }
  .print-group { margin-bottom: 1.15rem; }

  /* Nothing to order, so the box at the top is not there and about 150px of
     page came free. Spent on taller rows and bigger type rather than left as
     white space at the bottom, which reads as a sheet that printed wrong. */
  .print-roomy { font-size: 1.18em; }
  .print-roomy .print-table td { padding: 0.95rem 0; }
  .print-roomy .print-qty { padding: 0.95rem 0.3rem 0.2rem 0.4rem; }
  .print-roomy .print-group { margin-bottom: 1.6rem; }
  .print-roomy .print-allgood { font-size: 1.1em; margin-bottom: 1.5rem; }

  /* Sized to fill the sheet rather than huddle in the top half. This is read
     at arm length on a bench, often by somebody holding a clipboard, so the
     type is bigger than it would be on a screen and the rows are tall enough
     to write a number into. */
  html, body {
    background: #ffffff;
    color: #000000;
    font-size: 11pt;
  }

  /* main.wrap carries 1.75rem of top padding on screen, and "main.wrap"
     outranks ".wrap", so naming only the class here left that padding on the
     paper. Twenty-eight pixels is nothing to look at and everything to a
     sheet sized to the full height of the page: the invoice no longer fit
     and every one of them printed on page two, behind a blank. */
  .wrap,
  main.wrap { max-width: none; width: auto; padding: 0; margin: 0; }

  /* On paper the card is the page, so it loses the things that made it look
     like a card on a screen. */
  .print-sheet {
    border: none;
    border-radius: 0;
    padding: 0;
    margin: 0;
    background: #ffffff;
  }

  .print-head { border-bottom-color: #000000; }
  .print-meta, .print-sub, .print-group h3, .print-order-detail, .print-key { color: #333333; }
  .print-order { border-color: #000000; }
  .print-group h3, .print-key, .print-blank, .print-qty { border-color: #999999; }

  /* Links print as plain text: a blue underlined word on paper tells you
     nothing, and the URL behind it is not worth the ink either. */
  a { color: inherit; text-decoration: none; }

  /* Tables and groups keep themselves together across the page break. */
  tr, .print-group, .print-order { break-inside: avoid; page-break-inside: avoid; }
}

@media (max-width: 640px) {

  /* ------------------------------------------------------------- header
     Logo on the left, Menu on the right, one row. The logo keeps its full
     size - shrinking it is what made the wordmark illegible before. */

  .site-header { position: relative; }
  .header-inner { flex-wrap: nowrap; gap: 0.75rem; padding: 0.6rem 0; }
  .site-nav-wide,
  .site-user-wide { display: none; }

  .site-menu { display: block; flex: none; }

  .site-menu-toggle {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    min-height: 44px;
    padding: 0 0.85rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    color: var(--text);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    list-style: none;
    user-select: none;
  }

  /* No disclosure triangle - the icon already says what this is. */
  .site-menu-toggle::-webkit-details-marker { display: none; }
  .site-menu-toggle::marker { content: ''; }

  .site-menu[open] .site-menu-toggle {
    background: var(--surface-2);
    border-color: var(--accent);
  }

  /* The panel drops down over the page rather than pushing it, so opening the
     menu does not throw the content you were looking at off the screen. */
  .site-menu-panel {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 20;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 12px 24px rgba(20, 30, 25, 0.12);
    padding: 0.35rem 1.25rem 0.9rem;
  }

  .site-menu-panel .site-nav {
    display: flex;
    flex-direction: column;
    flex-wrap: nowrap;
    gap: 0;
  }

  /* Every link a full-width row a thumb can hit, with the current page marked
     down the left edge rather than underlined. */
  .site-menu-panel .site-nav a {
    display: flex;
    align-items: center;
    min-height: 48px;
    padding: 0 0.75rem;
    border-bottom: 1px solid var(--border);
    border-left: 3px solid transparent;
    font-size: 1rem;
    color: var(--text);
  }

  .site-menu-panel .site-nav a.active {
    border-left-color: var(--accent);
    border-bottom-color: var(--border);
    background: var(--accent-soft);
    font-weight: 600;
  }

  /* The secondary items follow the primary ones, set apart by a rule rather
     than by a menu inside a menu. */
  .site-menu-panel .site-nav-secondary { margin-top: 0.5rem; }
  .site-menu-panel .site-nav-secondary a { color: var(--text-muted); }

  .site-menu-panel .site-nav-secondary form {
    border-top: 1px solid var(--border);
    margin-top: 0.4rem;
    padding-top: 0.4rem;
  }

  .site-menu-panel .site-nav-secondary .link-button {
    display: flex;
    align-items: center;
    min-height: 48px;
    padding: 0 0.75rem;
    font-size: 1rem;
    text-decoration: none;
  }

  .subnav { gap: 0; }
  .subnav a { flex: 1 1 auto; text-align: center; min-height: 44px; display: flex; align-items: center; justify-content: center; }

  /* --------------------------------------------------------- tables
     A table wider than the phone made the whole page drag sideways. Tables
     marked .table-stack turn each row into a card: the name as its title, the
     other columns as labelled lines beneath, the actions along the bottom. */

  .table-stack,
  .table-stack tbody,
  .table-stack tr,
  .table-stack td {
    display: block;
    width: 100%;
  }

  /* Hidden visually, not removed - the column names still reach a screen
     reader, and each cell carries its own label below. */
  .table-stack thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  .table-stack tr {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    padding: 0.85rem 0.95rem;
    border-bottom: 1px solid var(--border);
  }

  .table-stack tr:last-child { border-bottom: none; }

  .table-stack td {
    padding: 0;
    border: none;
    text-align: left;
    white-space: normal;
  }

  .table-stack td[data-label]::before {
    content: attr(data-label);
    display: block;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    margin-bottom: 0.1rem;
  }

  .table-stack .col-name { font-size: 1rem; font-weight: 600; }
  .table-stack .col-name a { display: inline-block; padding: 0.15rem 0; }

  /* The obligations list: title first, then when it recurs and when it is
     due, and the Mark done button at the bottom of the card - the same order
     as the cards on This period, so the two screens read alike. */
  .table-register.table-stack .col-name { order: 1; }
  .table-register.table-stack td[data-label] { order: 2; }
  .table-register.table-stack .col-do { order: 3; width: 100%; margin-top: 0.35rem; }
  .table-register.table-stack .row-manage { order: 4; }

  .table-register.table-stack .button-do,
  .table-register.table-stack .done-pill {
    flex-direction: row;
    gap: 0.45rem;
    width: 100%;
    min-height: 48px;
    padding: 0.55rem 1rem;
    font-size: 0.95rem;
  }

  /* Row actions: a row of real buttons-sized targets, not 18px text links. */
  .table-stack .row-manage {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 1rem;
    border-top: 1px solid var(--border);
    padding-top: 0.2rem;
  }

  /* --------------------------------------------------------- targets
     Anything tapped should be at least 44px tall on a phone. Where the thing
     itself is small - a checkbox, a text link - the hit area grows while what
     you see stays put. */

  /* Links inside running prose ("...Tick them off.") are left alone: they are
     exempt from the target-size rule, and padding them would break the line. */
  .row-manage a,
  .row-manage .link-button,
  .undo-form .link-button,
  .quiet-link,
  .dash-more a,
  .dash-links a,
  .pager a {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
  }

  /* The solid buttons came out at 40px from their padding alone - under the
     44px everything else on a phone meets, and these are the one thing on a
     form you actually have to hit. */

  .button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
  }

  /* Height alone is not enough: "Edit" and "Log" are 23px of text, so the
     target is widened too. */
  .row-manage a,
  .row-manage .link-button { margin-right: 0; padding: 0 0.6rem; }
  .row-manage a:first-child { padding-left: 0; }
  .undo-form { margin-top: 0; }
  .undo-form .link-button { font-size: 0.9rem; padding: 0 0.5rem; }

  /* The tick on the home card: the box stays 22px, the target becomes 44px,
     and the negative margin keeps the row from moving. */
  .check-button {
    padding: 11px;
    margin: -11px 0 -11px -11px;
  }

  /* Listed with the filter bar's own checkbox, which otherwise wins on
     specificity and keeps its 13px native size. */
  input[type="checkbox"],
  input[type="radio"],
  .filters .checkbox input,
  .layout-form input[type="checkbox"] {
    width: 1.5rem;
    height: 1.5rem;
  }

  .filters .checkbox { min-height: 44px; }

  /* Choose cards: four columns, and 4px too wide for a phone. Tighter cells
     and a narrower order box bring it inside the screen. */
  .layout-form th,
  .layout-form td { padding: 0.55rem 0.4rem; }
  .layout-form .col-show,
  .layout-form .col-order { width: 3.4rem; }
  .layout-form .col-order input { width: 3rem; padding-inline: 0.35rem; }

  /* --------------------------------------------------------- fields
     iPhone zooms the page in when a field with text under 16px is tapped, and
     does not zoom back out. 16px is the threshold, so every field is at least
     that - including the ones inside tables, which inherited the tables'
     smaller type. */

  input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]),
  select,
  textarea {
    font-size: max(16px, 1em);
    min-height: 44px;
  }

  .filters select { min-width: 0; width: 100%; }

  /* ----------------------------------------------------- the chains card
     The streak row sat beside the name, and a name, a dozen squares and a
     count do not fit across a phone - which made the whole home page scroll
     sideways. The name takes its own line, the chain and count go beneath. */

  .momentum-strip { flex-direction: column; align-items: stretch; }
  .momentum-list { flex: 1 1 auto; min-width: 0; }

  .momentum-list li {
    flex-wrap: wrap;
    gap: 0.2rem 0.6rem;
    padding: 0.35rem 0;
  }

  .momentum-name {
    flex: 1 1 100%;
    white-space: normal;
  }

  /* -------------------------------------------------------- vehicles
     The mark-done row becomes a stack, so each field gets the full width and
     the 44px height everything else on a phone has. */

  .service-done { flex-direction: column; align-items: stretch; }
  .service-done input[type="text"],
  .service-done input[type="date"] { width: 100%; flex: none; }
  .service-done button { width: 100%; }
  .due-list li { flex-wrap: wrap; }
  .due-label { width: 100%; padding-left: 1.2rem; }

  /* -------------------------------------------------------- supplies
     The count box goes full width and 44px tall, because this form is filled
     in one-handed while walking round the room. Everything else stacks. */

  .count-row { gap: 0.4rem; }
  .count-main { flex: 1 1 100%; }
  .count-entry { flex: 1 1 100%; }
  .count-input { width: 100%; min-height: 44px; text-align: left; }

  /* --------------------------------------------------------- finance
     Budget against actual only works as columns, so it stays a table - it just
     has to fit. Tighter cells, and the percentage drops under the amount. */

  .table-figures th,
  .table-figures td { padding: 0.55rem 0.45rem; }
  .table-figures th { font-size: 0.66rem; letter-spacing: 0.04em; }
  .table-figures .variance-pct { display: block; margin-left: 0; }
}

/* ------------------------------------------------------------- invoices

   The printed bill, laid out as the QuickBooks ones it replaces: lab top
   left, the word Invoice with its date and number top right, Bill To under
   that, a strip of terms, then the lines. Styled the same on screen as on
   paper, so what you look at before pressing print is what comes out.

   The labels are Arial and the values under them are Times, which is the
   original's split rather than a stylistic choice. */

.paper-run { margin-top: 1.2rem; }

/* A whole sheet of letter paper, on screen as well as on paper. Sizing it in
   inches rather than letting it grow to fit its contents is what puts the
   total band at the foot of the page instead of tucked under the last line,
   which is the difference anyone notices first between one of these and an
   original. The measurements come off the August run, including the quarter
   inch margin - narrower than the half inch the rest of the app prints to. */
.sheet {
  background: #ffffff;
  color: #000000;
  font-family: "Times New Roman", Times, serif;
  font-size: 11px;
  line-height: 1.35;
  box-sizing: border-box;
  width: 8.5in;
  height: 11in;
  padding: 0.25in;
  margin: 0 auto 1.2rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
}

.sheet-box th,
.sheet-word,
.sheet-totalword { font-family: Arial, Helvetica, sans-serif; }

.sheet-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; }
.sheet-lab { font-size: 15px; padding-top: 0.27in; }
.sheet-address { padding-top: 0.29in; font-size: 13px; }
.sheet-title { text-align: right; flex: none; }
.sheet-word { font-size: 30px; font-weight: 700; letter-spacing: 0.01em; line-height: 1; padding-top: 0.13in; }

.sheet-box { border-collapse: collapse; }
.sheet-box th,
.sheet-box td {
  border: 1px solid #000000;
  padding: 3px 6px;
  text-align: left;
  vertical-align: top;
  font-weight: 400;
}
.sheet-box th { text-align: center; font-size: 11px; }

.sheet-datebox { margin: 0.22in 0 0 auto; }
.sheet-datebox td { text-align: center; min-width: 0.95in; }

/* The Bill To box is inset from the page margin, and the e-mail label sits
   in a narrow box centred over a wider value box. Both are quirks of the
   template rather than anything meant, and both are kept: a customer holding
   August next to September should find the two indistinguishable. */
.sheet-parties { display: flex; justify-content: space-between; align-items: flex-start; margin-top: 0.42in; }
.sheet-billto { width: 43%; margin-left: 6%; }
.sheet-billto th { text-align: left; }
.sheet-billto td { height: 1.25in; }
.sheet-emails { display: flex; flex-direction: column; align-items: center; width: 27%; margin-top: 0.07in; }
.sheet-emaillabel { width: 62%; }
.sheet-emailvalue { width: 100%; margin-top: 0.14in; }
.sheet-emailvalue td { text-align: center; }
.sheet-customer { font-weight: 400; }

/* Two groups with a gap between them, not one row of five boxes. */
.sheet-strip { display: flex; justify-content: space-between; margin-top: 0.27in; }
.sheet-strip-left { width: 31%; }
.sheet-strip-right { width: 52%; }
.sheet-strip td { text-align: center; height: 0.44in; }
.sheet-strip-left th, .sheet-strip-left td { width: 50%; }

/* The lines box runs to the foot of the page. The filler row swallows
   whatever is left over, so two lines and twenty both leave the terms note
   and the total band in the same place. */
.sheet-lines { width: 100%; margin-top: 0.11in; flex: 1 1 auto; table-layout: fixed; }
.sheet-lines th:nth-child(1) { width: 15%; }
.sheet-lines th:nth-child(2) { width: 15%; }
.sheet-lines th:nth-child(3) { width: 40%; }
.sheet-lines th:nth-child(4) { width: 15%; }
.sheet-lines th:nth-child(5) { width: 15%; }
.sheet-lines .right { text-align: right; }

/* Column rules the whole way down and no rule between one line and the next:
   the original is a single tall box with the writing at the top of it. */
.sheet-lines tbody td { border-top: none; border-bottom: none; padding-top: 0; padding-bottom: 0; }
.sheet-lines tbody tr:first-child td { padding-top: 5px; }
.sheet-fill { height: 100%; }
.sheet-tail { height: 2.5in; }
.sheet-tail td { border-bottom: 1px solid #000000; }

.sheet-totalbar { width: 100%; margin-top: -1px; margin-bottom: 0.35in; }
.sheet-totalbar td { height: 0.52in; vertical-align: middle; }
.sheet-totalbar td:first-child { width: 70%; }
.sheet-totalrow { display: flex; align-items: baseline; justify-content: space-between; gap: 0.5rem; }
.sheet-totalword { font-size: 20px; font-weight: 700; }
.sheet-totalamount { font-size: 13px; }

/* The entry grid: narrow boxes for figures, wide for words. */
.invoice-lines input { width: 100%; font-size: 0.9rem; }
.invoice-lines .count-input { width: 5.5rem; text-align: right; }
.invoice-lines td { vertical-align: middle; }

/* "Or one at a time" on the print run. A customer gets their own bill and
   nobody else's, so the run page offers a way to do them singly as well as
   all at once. */
.print-one { margin: 1.4rem 0 1.6rem; }
.print-one h2 { font-size: 1rem; margin: 0 0 0.2rem; }
.print-one p { margin: 0 0 0.7rem; }
.print-one-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.3rem; }
.print-one-list a {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  padding: 0.45rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  text-decoration: none;
  color: inherit;
}
.print-one-list a:hover { border-color: var(--text-muted); }
.print-one-who { font-weight: 600; }
.print-one-total { margin-left: auto; white-space: nowrap; }

/* Four columns in a card is tight, so the boxes take whatever room their
   column has rather than their default width - a select that reads "Yes, sen"
   is worse than useless. */
.contact-lines { width: 100%; }
.contact-lines input,
.contact-lines select { width: 100%; min-width: 0; font-size: 0.9rem; }
.contact-lines th:nth-child(1) { width: 22%; }
.contact-lines th:nth-child(2) { width: 34%; }
.contact-lines th:nth-child(3) { width: 20%; }
.contact-lines th:nth-child(4) { width: 24%; }
.contact-lines td { vertical-align: middle; }

/* The send page's summary: what is about to leave, as a short list of
   labelled facts rather than a form somebody has to read twice. */
.send-summary {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 0.7rem 0.9rem;
  margin-bottom: 1.1rem;
}
.send-row { display: flex; gap: 0.8rem; padding: 0.2rem 0; align-items: baseline; }
.send-label {
  flex: none;
  width: 5rem;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.send-value { word-break: break-word; }

/* The line about who is NOT being emailed needs air around it; it sat flush
   against the Subject label and read as part of it. */
.send-summary + .hint { margin: 0 0 1.1rem; }

/* One supply with its vendors under it: the comparison is the point, so the
   rows sit close together and the figures line up down the page. */
.supply-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.8rem 1rem 0.9rem;
  margin-bottom: 1rem;
  background: var(--surface);
}
.supply-card-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.6rem; }
.supply-card-head h3 { margin: 0; font-size: 1rem; }
.supply-gap { margin: 0.3rem 0 0.5rem; }

/* How long the shelf lasts. The bar is the quick read and the line under it
   shows the working, because a days-of-cover number gets ordered against.

   Deliberately thin and square-ended. A fat rounded bar reads as a progress
   meter - something filling up on its way to done - and this is the opposite:
   a level draining towards a reorder. */
.cover { margin: 0.5rem 0 0.7rem; }
.cover-bar {
  display: block;
  height: 3px;
  margin: 0.3rem 0 0.25rem;
  background: var(--border);
  overflow: hidden;
}
.cover-bar span { display: block; height: 100%; background: var(--accent); }
.cover-text { margin: 0.3rem 0 0; font-size: 0.85rem; }

/* The item page and the ordering sheet put the band on a wrapper around the
   bar; the dashboard table puts it on the row. Both need colouring, and the
   two sets of rules are kept apart so neither quietly depends on the other. */
.cover-soon .cover-bar span,
.cover-low .cover-bar span { background: var(--warn); }
.cover-out .cover-bar span { background: var(--urgent); }
.cover-soon .cover-text strong,
.cover-low .cover-text strong { color: var(--warn); }
.cover-out .cover-text strong { color: var(--urgent); }

/* ------------------------------------------------------- the supply table

   One item a row, five columns, figures right-aligned in tabular numerals so
   a column of prices can be read down rather than hunted through. The status
   is a rule down the left edge rather than a coloured bar across the row:
   at a glance it is the only colour on the page, which is what makes the
   three that need ordering findable without reading any of it. */
.supply-table { margin-bottom: 1.5rem; }
.supply-table th,
.supply-table td {
  padding: 0.6rem 0.75rem;
  vertical-align: top;
  font-variant-numeric: tabular-nums;
}
.supply-table thead th {
  font-size: 0.7rem;
  white-space: nowrap;
  font-weight: 600;
}
/* A row header is still a <th>, so it arrives wearing the column header's
   clothes - uppercase, letterspaced, grey-filled. It is a name, not a
   heading, so all of that comes back off. */
.supply-table tbody th {
  text-align: left;
  font-weight: 600;
  font-size: 0.92rem;
  text-transform: none;
  letter-spacing: normal;
  background: transparent;
  color: var(--text);
}
.supply-table tbody th a { color: var(--text); text-decoration: none; }
.supply-table tbody th a:hover { text-decoration: underline; }
.supply-table tbody tr:hover { background: var(--surface-2); }

/* The sub-line under a figure: the unit, the catalogue number, the reorder
   level. Always smaller and quieter than the thing it qualifies, so the
   column still scans as one number per row. */
.supply-sub {
  display: block;
  font-size: 0.78rem;
  font-weight: 400;
  color: var(--text-muted);
  margin-top: 0.1rem;
}

.supply-cell-num { text-align: right; width: 1%; white-space: nowrap; }
.supply-cell-cover { width: 7.5rem; }
.supply-cell-vendor { width: 9rem; }
.supply-cell-item { min-width: 11rem; }

.supply-table .cover-days { font-weight: 650; font-size: 0.92rem; }
.supply-gap-link { font-size: 0.82rem; }

/* The status rule. Three pixels on the leading edge of the row, and the
   days figure picks up the same colour - nothing else does. */
.supply-row > :first-child { border-left: 3px solid transparent; }
.supply-row-ok > :first-child { border-left-color: var(--accent); }
.supply-row-soon > :first-child,
.supply-row-low > :first-child { border-left-color: var(--warn); }
.supply-row-out > :first-child { border-left-color: var(--urgent); }

.supply-row-soon .cover-days,
.supply-row-low .cover-days { color: var(--warn); }
.supply-row-out .cover-days { color: var(--urgent); }
.supply-row-soon .cover-bar span,
.supply-row-low .cover-bar span { background: var(--warn); }
.supply-row-out .cover-bar span { background: var(--urgent); }

/* A heading with the count beside it, so "Order these" carries how many
   without a sentence underneath saying so. */
.supply-section-head {
  display: flex;
  align-items: baseline;
  gap: 0.55rem;
  margin: 2rem 0 0.75rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--border);
}
.supply-section-head .section-title { margin: 0; }
.section-count {
  font-size: 0.72rem;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.05rem 0.45rem;
}

.page-head-ruled { padding-bottom: 0.8rem; border-bottom: 1px solid var(--border); }

/* The actions as a row of buttons rather than one button and two underlined
   links, which read as a footnote rather than as things you can do. */
.toolbar { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 1.1rem 0 0.4rem; }

/* Everything that is fine, out of the way until somebody asks. */
.supply-rest { margin: 0.4rem 0 1.2rem; }
.supply-rest summary { cursor: pointer; font-size: 0.9rem; color: var(--text-muted); }
.supply-rest .supply-table { margin-top: 0.8rem; }

/* On a phone there is no room for five columns. The vendor and the price are
   what you look up when you are about to buy, which is not what you are doing
   on a phone in the lab - so they go, and what is left is what is running
   out. */
@media (max-width: 42rem) {
  .supply-table .supply-cell-vendor,
  .supply-table tbody td:last-child,
  .supply-table thead th:last-child { display: none; }
  .supply-table th, .supply-table td { padding: 0.55rem 0.5rem; }

  /* Three columns in 375px only works if the days figure is allowed to keep
     its own line. Wrapped across two it stops being a figure. */
  .supply-cell-item { min-width: 0; }
  .supply-cell-cover { width: 4.5rem; }
  .supply-table .cover-days { white-space: nowrap; font-size: 0.86rem; }
  /* The rate is the working behind the figure, and there is no room for the
     working on a phone. */
  .supply-cell-cover .supply-sub { display: none; }
}

.cover-setup { margin: 0.2rem 0 0.6rem; }
.cover-setup summary { cursor: pointer; font-size: 0.85rem; color: var(--text-muted); }
.cover-setup .table { margin-top: 0.5rem; }

/* A vendor on one line: name, number, pack, price, when, note. */
.offer { padding: 0.45rem 0 0.5rem; border-top: 1px solid var(--border); }
.offer:first-of-type { border-top: none; }
/* The one the sheet names, so it is findable without reading every price. */
.offer-chosen { background: var(--surface-raised, transparent); }

.offer-form { display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: center; margin: 0; }
.offer-form input { font-size: 0.88rem; min-width: 0; }
.offer-vendor { flex: 2 1 8rem; }
.offer-catalog { flex: 2 1 8rem; }
.offer-unit { flex: 1 1 5.5rem; }
.offer-price { flex: 0 0 5rem; text-align: right; }
.offer-when { flex: 0 0 8.5rem; }
/* The note takes the next line rather than squeezing the figures. */
.offer-note { flex: 1 1 100%; }
.offer-new { margin-top: 0.5rem; padding-top: 0.6rem; border-top: 1px dashed var(--border); }
.offer-marks { margin: 0.25rem 0 0; font-size: 0.8rem; color: var(--text-muted); }
.offer-marks .badge { margin-right: 0.3rem; }

.plain-list { list-style: none; margin: 0 0 0.6rem; padding: 0; }
.plain-list li { padding: 0.15rem 0; }

.invoice-who {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  padding: 0.6rem 0.9rem;
  margin-bottom: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

@media print {
  /* An invoice is portrait. The supply count sheet sets the document's
     @page to landscape so its columns fit, and that rule would otherwise
     turn these sideways - so invoices claim a named page of their own and
     the landscape default is left alone for the sheet that needs it. */
  @page invoice { size: letter portrait; margin: 0.25in; }

  /* One invoice per sheet of paper, and no app chrome around it. An explicit
     width rather than max-width: none, which let the sheet grow to the
     window and come out 1,009px wide on an 816px page. */
  /* A tenth of an inch short of the 10.5in the page actually gives, rather
     than exactly it. Sized to the millimetre, any rounding anywhere above
     this - a stray margin, a printer's idea of Letter - tips the sheet onto
     the next page, and the symptom is a blank page rather than anything
     that points at the cause. The tenth is invisible and the slack is not. */
  .sheet {
    page: invoice;
    width: 8in;
    height: 10.4in;
    max-width: 8in;
    border: none;
    border-radius: 0;
    padding: 0;
    margin: 0;
    break-after: page;
  }
  .sheet:last-child { break-after: auto; }
  .paper-run { margin: 0; }
}

/* The box on a new invoice that counts a month of backup into the
   quantities below. Set apart from the invoice itself because it is working
   material, not part of the bill. */
.backup-count {
  margin: 1.5rem 0 2rem;
  padding: 1.25rem 1.25rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.backup-count .section-title { margin-top: 0; }
.backup-count .form { margin: 0; }
.backup-count .table { margin-top: 1rem; }
.backup-count tr.muted td { color: var(--text-muted); }

/* ---------------------------------------------------------------- home

   The home page grew from a handful of cards to eleven, plus a dozen places
   with no card at all. Flat, that reads as a list; banded, it reads as a
   landing page - what needs doing, how the business is, how the lab is, and
   then a way into everything else. */

.home-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.75rem;
}

.home-head h1 { margin: 0 0 0.15rem; }
.home-date { margin: 0; color: var(--text-muted); }


/* The row of figures across the top. Numbers first, because the point is to
   be read at a glance rather than studied; the note under each one is what
   turns a number into something you can act on. */
.glance {
  list-style: none;
  margin: 0 0 2rem;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
  gap: 0.75rem;
}

.glance a {
  display: block;
  height: 100%;
  padding: 0.85rem 1rem 0.9rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: inherit;
}

.glance a:hover,
.glance a:focus-visible { border-color: var(--accent); }

/* Urgent is a left edge and a coloured note, not a red number: the figure
   itself is just a fact, and colouring it makes a busy day look like a
   broken one. */
.glance-urgent a { border-left-color: var(--urgent); }
.glance-urgent .glance-note { color: var(--urgent); }

.glance-value {
  display: block;
  font-size: 1.6rem;
  font-weight: 650;
  line-height: 1.1;
  letter-spacing: -0.01em;
}

.glance-label {
  display: block;
  margin-top: 0.15rem;
  font-size: 0.9rem;
}

.glance-note {
  display: block;
  margin-top: 0.2rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}
.home-band { margin-bottom: 2.25rem; }
.home-band:last-child { margin-bottom: 0; }

.home-band-head {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 0.85rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

.home-band-head h2 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 650;
}

.home-band-head p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* The directory. Wider than the card grid on purpose: these are signposts,
   not panels, so they want to be scannable rather than substantial. */
.home-places {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
  gap: 0.75rem;
}

.home-places a {
  display: block;
  height: 100%;
  padding: 0.8rem 0.9rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: inherit;
}

.home-places a:hover,
.home-places a:focus-visible {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.home-places strong {
  display: block;
  font-weight: 600;
  margin-bottom: 0.15rem;
}

.home-places span {
  display: block;
  color: var(--text-muted);
  font-size: 0.88rem;
  line-height: 1.35;
}

@media (max-width: 640px) {
  .home-head { flex-direction: column; gap: 0.4rem; }
  .home-places { grid-template-columns: 1fr; }
}

/* A disabled button has to look disabled.

   The send button is switched off when an invoice is not ready to go - no
   recipient, no mail settings, a validation report the customer insists on
   and nobody has attached. Left looking like every other green button, the
   block reads as the app being broken: you press it, nothing happens, and
   nothing on screen connects the two. */
.button:disabled,
.button[disabled] {
  background: var(--surface-2);
  color: var(--text-muted);
  border-color: var(--border);
  cursor: not-allowed;
  box-shadow: none;
}

.button:disabled:hover,
.button[disabled]:hover {
  background: var(--surface-2);
  color: var(--text-muted);
}

/* The two one-tap vehicle actions. Side by side on a desktop, stacked and
   full width on a phone, where somebody is standing beside a truck. */
.quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-bottom: 0.6rem;
}

.quick-actions form { margin: 0; }

.quick-detail {
  margin-top: 1rem;
  border-top: 1px solid var(--border);
  padding-top: 0.75rem;
}

.quick-detail > summary {
  cursor: pointer;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.quick-detail > summary:hover { color: var(--accent); }
.quick-detail .log-form { margin-top: 0.75rem; }

@media (max-width: 560px) {
  .quick-actions { flex-direction: column; }
  .quick-actions form,
  .quick-actions .button { width: 100%; }
}

/* Things somebody asked for, on the counting page and the ordering page. */
.request-list { list-style: none; margin: 0 0 1.5rem; padding: 0; }

.request-list li {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.7rem 0.9rem;
  border: 1px solid var(--border);
  border-left: 3px solid var(--warn);
  border-radius: var(--radius);
  background: var(--surface);
  margin-bottom: 0.5rem;
}

.request-note { font-size: 0.9rem; padding-top: 0.15rem; }
.request-who { font-size: 0.8rem; color: var(--text-muted); padding-top: 0.2rem; }

.request-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-shrink: 0;
}

.ask-panel {
  margin: 0 0 2rem;
  padding: 1.1rem 1.2rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.ask-panel .section-title { margin-top: 0; }

@media (max-width: 560px) {
  .request-list li { flex-direction: column; gap: 0.5rem; }
}

/* Expiry, beside the item it belongs to. A quantity says how much is there
   and nothing about whether it is still good; this is the other half. */
.supply-expiry {
  display: block;
  font-size: 0.8rem;
  padding-top: 0.15rem;
  color: var(--text-muted);
}

.supply-expiry-low,
.supply-expiry-out { color: var(--urgent); font-weight: 600; }
.supply-expiry-soon { color: var(--warn); }

.count-expiry {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding-top: 0.35rem;
}

.count-expiry label { font-size: 0.8rem; color: var(--text-muted); }

/* The review page before a company-wide email. Two jobs: say who it is from
   and to in a form that cannot be mistaken for an editable box, and show the
   body broken into the paragraphs it will actually arrive in. */
.facts { margin: 0 0 1rem; }

.facts div {
  display: flex;
  gap: 0.75rem;
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--border);
}

.facts dt {
  flex: 0 0 5rem;
  color: var(--text-muted);
  font-size: 0.85rem;
  padding-top: 0.1rem;
}

.facts dd { margin: 0; flex: 1; min-width: 0; word-break: break-word; }

/* The real email, in a document of its own.

   An iframe rather than the email's HTML dropped into the page. Email
   markup is nested tables carrying their own inline styles and their own
   600px width: inlined it would both fight this stylesheet and hand typed
   text a way into the page. Sandboxed with nothing granted, so it is a
   picture that happens to be live.

   Light colours even under a dark app theme, because that is the email -
   showing it any other way would be showing something the recipient will
   not get. */
.mail-frame {
  display: block;
  width: 100%;
  height: 34rem;
  max-height: 75vh;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #f1f3f1;
}

/* Plain words shown as plain words: the covering note on a draft, before
   anybody presses send. Not the email's own HTML - there is none here worth
   framing, and the question being answered is "does this read right". */
.mail-preview {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1rem 1.1rem;
  background: var(--surface-2);
  font-size: 0.95rem;
  line-height: 1.5;
}

/* Pointing a file at the report it is. Capped rather than left to size
   itself: forty producers with names in them made the dropdown wide enough
   to squeeze every other column in the row to nothing. */
.report-pick { width: 100%; max-width: 20rem; }

/* The report numbers on a mailing rule. They wrap between numbers and never
   inside one: "28943.1" broken across two lines is unreadable, and nine of
   them on one line is wider than a phone. */
.rule-reports {
  font-variant-numeric: tabular-nums;
  font-size: 0.88rem;
  word-spacing: 0.1rem;
}

/* Tables that borrow .supply-table's looks but whose last column is the
   whole point.

   The phone rule above drops the last column of a .supply-table, because on
   the inventory that column is the vendor and nobody looks one up from the
   lab floor. On the results screens the last column is who the email goes
   to, which cannot be the thing that quietly disappears on a narrow window -
   it was doing exactly that, and the column looked simply absent rather
   than hidden. */
@media (max-width: 42rem) {
  .supply-table.keep-columns tbody td:last-child,
  .supply-table.keep-columns thead th:last-child { display: table-cell; }
}

/* Not an error and not good news: a state somebody chose, that the page has
   to keep saying out loud. Used where customer sending is held back - red
   would read as "something is broken" and green as "carry on". */
.flash-warn {
  background: var(--warn-soft);
  border-color: var(--warn);
  color: var(--warn);
}

/* The buttons under a draft. Side by side on a wide screen, stacked on a
   phone, with the one that reaches a customer never alone in the row - so
   "send" and "send this to me" are always read together. */
.draft-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
  margin-top: 1rem;
}

/* ---------------------------------------------------------------- Order brief

   The third supply output, and the only one meant to be read as a decision.
   The count sheet is a list and Natalie's workbook is a form; this is a page
   of figures, so it is set like one - hairline rules instead of boxes,
   tabular numerals everywhere, and the unit of each figure smaller and under
   it rather than beside it. Nothing here is coloured except what is wrong. */

.brief { max-width: 72rem; margin: 0 auto; }

.brief-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 0.75rem;
  padding-bottom: 0.9rem;
  border-bottom: 1px solid var(--text);
  margin-bottom: 1.4rem;
}
.brief-head h1 { margin: 0; font-size: 1.5rem; letter-spacing: -0.01em; }
.brief-sub { margin: 0.25rem 0 0; color: var(--text-muted); font-size: 0.88rem; }
.brief-actions { display: flex; gap: 0.4rem; flex-wrap: wrap; }

/* The three questions. Separated by rules rather than sat in cards: a card
   says "widget", and these are the headline figures of the page. */
.brief-figures {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0 1.6rem;
  margin-bottom: 1.8rem;
}
.brief-figure { padding-left: 1rem; border-left: 1px solid var(--border); }
.brief-figure:first-child { padding-left: 0; border-left: 0; }
.brief-figure-label {
  display: block;
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.brief-figure-value {
  display: block;
  margin: 0.2rem 0 0.15rem;
  font-size: 1.9rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.brief-figure-note { display: block; font-size: 0.78rem; color: var(--text-muted); line-height: 1.35; }
.brief-figure.is-risk .brief-figure-value { color: var(--urgent); }

.brief-block { margin-bottom: 2rem; }
.brief-title {
  margin: 0 0 0.55rem;
  font-size: 0.82rem;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.brief-title-note {
  margin-left: 0.5rem;
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
  color: var(--text-muted);
}
.brief-empty { margin: 0; color: var(--text-muted); font-size: 0.9rem; }

.brief-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}
.brief-table th,
.brief-table td {
  padding: 0.5rem 0.6rem;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--border);
}
.brief-table thead th {
  padding-top: 0;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 1px solid var(--text);
  white-space: nowrap;
}
.brief-table tbody th { font-weight: 500; padding-left: 0; }
.brief-table thead th:first-child,
.brief-table tfoot th { padding-left: 0; }
.brief-table th.num, .brief-table td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.brief-table tbody tr:hover { background: var(--surface-2); }
.brief-table tfoot th, .brief-table tfoot td {
  border-bottom: 0;
  border-top: 1px solid var(--text);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.72rem;
  letter-spacing: 0.07em;
}
.brief-table tfoot td { font-size: 0.95rem; letter-spacing: 0; text-transform: none; }
.brief-table-tight { font-size: 0.84rem; }
.brief-table-tight th, .brief-table-tight td { padding-top: 0.38rem; padding-bottom: 0.38rem; }

/* Every cell can carry a second line saying what the figure is - the unit,
   the basis, the date it runs out. Smaller, quieter, and on its own line, so
   a column of figures stays a column. */
.brief-item { display: block; font-weight: 600; }
.brief-meta {
  display: block;
  margin-top: 0.1rem;
  font-size: 0.73rem;
  font-weight: 400;
  color: var(--text-muted);
  letter-spacing: 0;
  text-transform: none;
}
.brief-meta a { color: var(--text-muted); }
.brief-days { font-size: 1.05rem; font-weight: 600; }
.brief-order, .brief-cost { font-weight: 600; white-space: nowrap; }
.brief-flag { color: var(--urgent); font-weight: 500; }

/* Out, rather than merely low: a rule down the left edge, which reads at a
   glance without turning the row into a block of colour. */
.brief-out > th:first-child { box-shadow: inset 2px 0 0 var(--urgent); padding-left: 0.5rem; }
.brief-out .brief-days { color: var(--urgent); }

/* Thirty days of cover is the full width. Past that it is simply full - the
   bar is there to show which of these is worse than which, and a shelf with
   four months on it does not need a longer bar to say so. */
.brief-bar {
  display: block;
  height: 2px;
  margin-top: 0.3rem;
  margin-left: auto;
  width: 4.5rem;
  background: var(--border);
}
.brief-bar > span { display: block; height: 100%; background: var(--text-muted); }
.brief-out .brief-bar > span { background: var(--urgent); }

.brief-rest { margin-bottom: 2rem; }
.brief-rest > summary {
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0.4rem 0;
}
.brief-rest > summary .brief-meta { display: inline; margin-left: 0.5rem; }

.brief-foot { margin: 0.6rem 0 0; font-size: 0.78rem; color: var(--text-muted); max-width: 46rem; }

.brief-terms { border-top: 1px solid var(--border); padding-top: 1rem; }
.brief-terms dl { margin: 0; display: grid; grid-template-columns: 12rem 1fr; gap: 0.3rem 1rem; }
.brief-terms dt { font-weight: 600; font-size: 0.82rem; }
.brief-terms dd { margin: 0; font-size: 0.82rem; color: var(--text-muted); }

@media (max-width: 54rem) {
  .brief-figures { grid-template-columns: 1fr; gap: 0; }
  .brief-figure {
    padding: 0.7rem 0;
    border-left: 0;
    border-top: 1px solid var(--border);
  }
  .brief-figure:first-child { border-top: 0; padding-top: 0; }
  .brief-figure-value { font-size: 1.5rem; }
  /* The tables stay tables and scroll, rather than folding into stacked
     cards. Comparing two vendors' unit costs is the point of the page, and
     figures you have to scroll vertically to compare are no comparison. */
  .brief-block, .brief-rest { overflow-x: auto; }
  .brief-table { min-width: 44rem; }
  .brief-terms dl { grid-template-columns: 1fr; }
  .brief-terms dd { margin-bottom: 0.4rem; }
}

@media print {
  .brief { max-width: none; }
  .brief-table tbody tr:hover { background: transparent; }
  .brief-rest[open] > summary { list-style: none; }
  .brief-block, .brief-terms { break-inside: avoid; }
  .brief-table thead { display: table-header-group; }
  .brief-table tr { break-inside: avoid; }
}
.brief-names { margin: 0; font-size: 0.86rem; line-height: 1.5; color: var(--text); max-width: 60rem; }


/* ------------------------------------------------------------
   Checking the day's emails one at a time, top to bottom: the email
   first, the report it carries underneath.
   ------------------------------------------------------------ */
.check-steps { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; margin: 0 0 1rem; }
.check-steps select { max-width: 100%; }
.check-steps .is-disabled { opacity: 0.45; pointer-events: none; }
.check-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1rem; }
.check-mail .facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 2rem; }
.check-mail { margin: 0; }
.check-status { margin: 0 0 0.75rem; }
.check-badge { display: inline-block; padding: 0.15rem 0.6rem; border-radius: 999px; font-size: 0.85rem; font-weight: 600; background: var(--accent-soft); color: var(--accent); }
.check-badge-done { background: var(--done-soft); color: var(--done); }
.check-badge-stop { background: var(--urgent-soft); color: var(--urgent); }
/* Addresses get the whole row, and break only when a phone leaves no choice. */
.check-mail .facts > div:first-child { grid-column: 1 / -1; }
.check-to li { overflow-wrap: anywhere; }
.check-report { min-width: 0; }
.check-frame { display: block; width: 100%; height: 90vh; min-height: 32rem; border: 1px solid var(--border); border-radius: 6px; background: var(--surface-2); }
.check-actions { margin-top: 1rem; }
.check-mail .plain-list .row-detail { display: inline; }
@media (max-width: 640px) {
  .check-mail .facts { grid-template-columns: minmax(0, 1fr); }
  .check-frame { height: 70vh; min-height: 24rem; }
}

/* ------------------------------------------------------------
   A report opened over the send page instead of in a new tab.
   ------------------------------------------------------------ */
.report-preview { width: min(64rem, calc(100vw - 2rem)); height: calc(100vh - 2rem); max-height: none; padding: 0; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); overflow: hidden; }
.report-preview[open] { display: flex; flex-direction: column; }
.report-preview::backdrop { background: rgba(10, 15, 12, 0.55); }
.report-preview-head { display: flex; align-items: center; gap: 0.75rem; padding: 0.5rem 0.75rem; border-bottom: 1px solid var(--border); }
.report-preview-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.report-preview-frame { flex: 1; width: 100%; border: 0; background: var(--surface-2); }
.check-keys { font-size: 0.85rem; }
.check-keys kbd { display: inline-block; padding: 0 0.35rem; border: 1px solid var(--border); border-radius: 4px; background: var(--surface-2); font: inherit; }
@media (max-width: 640px) {
  .report-preview { width: 100vw; height: 100vh; border-radius: 0; }
  .check-keys { display: none; }
}

/* The choice to copy a send to the lab, next to the button that sends. */
.bcc-choice { display: inline-flex; align-items: center; gap: 0.35rem; margin-right: 0.6rem; font-size: 0.9rem; color: var(--text-muted); }

/* The day at a glance on Send today: what has gone, what has not. */
.day-checklist { margin-bottom: 1.25rem; }
.day-checklist-count { margin: 0 0 0.6rem; }
.day-checklist-stop { color: var(--urgent); font-weight: 600; }
.day-checklist-done { color: var(--done); font-weight: 600; }
.day-checklist-list { columns: 2 18rem; column-gap: 2rem; }
.day-checklist-list .day-checklist-row { position: relative; padding: 0.2rem 0 0.2rem 1.5rem; break-inside: avoid; }
.day-checklist-row .row-detail { display: inline; }
.day-checklist-mark { position: absolute; left: 0; width: 1.1rem; text-align: center; font-weight: 700; color: var(--text-muted); }
.day-checklist-row.is-done .day-checklist-mark { color: var(--done); }
.day-checklist-row.is-stop .day-checklist-mark { color: var(--urgent); }
.day-checklist-row.is-done a { color: var(--text-muted); }
.day-checklist-sub { margin: 1rem 0 0.4rem; font-size: 0.95rem; }
.day-checklist-row .inline-form { display: inline; margin-left: 0.35rem; }
.day-checklist.is-complete { border-color: var(--done); }
.day-checklist-banner { margin: 0 0 0.6rem; padding: 0.5rem 0.75rem; border-radius: 6px; background: var(--done-soft); color: var(--done); font-weight: 600; }

/* The provider's id for a results email, under the addresses it went to.
   Small and quiet: it is never read, only copied, on the one morning
   somebody needs to find out what became of a message. */
.sent-id {
  display: block;
  margin-top: 0.2rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.72rem;
  color: var(--text-muted);
  word-break: break-all;
  user-select: all;
}
