/*
 * Application styles for Fast. Plain CSS, no framework — see CLAUDE.md.
 */

/* ==========================================================================
   Tokens
   Colours, surfaces and the status colours as custom properties.
   Breakpoints (media queries cannot read custom properties): 699 px phone, 860 px narrow
   editor (861 px from the other side), 1359 px the ramp-up's status column.
   ========================================================================== */

:root {
  /* phenobyte colours (phase 73, variant B, docs/mockups/fast-colours-b.html): navy text and
     header, brand blue for links and actions, cool greys for lines and quiet text. */
  --color-text: #1f2044;
  --color-text-muted: #5b5f73;
  --color-background: #f3f4f4;
  --color-surface: #fff;
  --color-surface-muted: #f7f8fa;
  --color-border: #d6d9df;
  --color-border-strong: #b9c0c9;
  --color-accent: #1767f3;
  --color-accent-dark: #0542af;
  --color-navy: #1f2044;
  /* The header a touch lighter than the navy text (phase 73a): white 11.9:1, the muted
     blue-grey 8.5:1 on it. */
  --color-header: #2c3363;
  --color-logo-green: #70a71d;
  --color-logo-green-light: #9ccb3a;
  --color-danger: #b42318;
  --color-success-bg: #e7f5ec;
  --color-success-text: #1c6b33;
  --color-error-bg: #fdecea;
  /* A pale note behind a suggestion in the panel: no status, so none of the five colours. */
  --color-note-bg: #fff8e6;
  /* The tour's own colour is the logo's green: the presenter's layer, never a status. */
  --color-tour: var(--color-logo-green);

  /* On the navy header: white for the brand, the current item and the buttons, a light
     blue-grey for the rest, translucent white for lines, hover and the current item. */
  --color-on-navy: #fff;
  --color-on-navy-muted: #d7d9e6;
  --color-on-navy-line: rgba(255, 255, 255, 0.35);
  --color-on-navy-hover: rgba(255, 255, 255, 0.12);
  --color-on-navy-current: rgba(255, 255, 255, 0.14);

  --focus-ring: rgba(23, 103, 243, 0.2);
  --shadow-popover: 0 6px 20px rgba(31, 32, 68, 0.16);
  --shadow-card: 0 10px 30px rgba(31, 32, 68, 0.22);
  --shadow-bar: 0 -4px 12px rgba(31, 32, 68, 0.08);
  --radius: 6px;
  /* A badge's or a count's round ends, whatever its height. */
  --radius-pill: 999px;
  /* The thin line around a box and between rows. */
  --line: 1px solid var(--color-border);
  --space: 16px;

  /* Roboto, self-hosted (see Fonts below); the system fonts if it has not loaded yet. */
  --font-sans: Roboto, -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
}

/* Status colours ---------------------------------------------------------- */

:root {
  /* Five colours, one meaning each (phase 63), read as a traffic light: red is late, amber will be
     late or is close, green is done, blue is on its way, grey has nothing to say yet. Colour
     means delivery status and nothing else; every colour has a mark (DeliveryStatus::MARKS).
     Clear signal tones (phase 63a), tuned to the phenobyte palette (phase 73): lights, dots,
     borders and bars use them in full. */
  --status-red: #d93a2f;
  --status-amber: #f0b400;
  --status-green: #2f9e4f;
  --status-blue: var(--color-accent);
  --status-grey: #8b93a1;

  /* The same five as ink: words in a status colour on white or on a light tint stay dark
     enough to read (a clear yellow word on white is not). */
  --status-red-ink: #a3241b;
  --status-amber-ink: #4a3600;
  --status-green-ink: #1c6b33;
  --status-blue-ink: #0c3f9c;
  --status-grey-ink: #4f5666;

  /* The light tint behind a badge and inside a tree node: one share of the status colour. */
  --status-tint: 12%;

  /* The mark inside a light or a dot: white, dark on amber. */
  --status-on-dark: #fff;
  --status-on-light: var(--color-navy);

  /* The names the rules below read, each one of the five. */
  --status-overdue: var(--status-red);
  --status-at-risk: var(--status-amber);
  --status-complete: var(--status-green);
  --status-on-time: var(--status-blue);
  --status-received: var(--status-blue);
  --status-unplanned: var(--status-grey);
}

/* ==========================================================================
   Fonts
   Roboto 400, 500 and 700 (latin and latin-ext for the umlauts and accents), served by
   Propshaft from app/assets/fonts/roboto — no request to Google. Licence: docs/licences/roboto.md.
   ========================================================================== */

@font-face {
  font-family: "Roboto";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/assets/roboto/roboto-latin-ext-400-normal-d7afea5f.woff2") format("woff2");
  unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF;
}

@font-face {
  font-family: "Roboto";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("/assets/roboto/roboto-latin-ext-500-normal-d33cf132.woff2") format("woff2");
  unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF;
}

@font-face {
  font-family: "Roboto";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("/assets/roboto/roboto-latin-ext-700-normal-beda1b6c.woff2") format("woff2");
  unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF;
}

@font-face {
  font-family: "Roboto";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/assets/roboto/roboto-latin-400-normal-1ec7bce5.woff2") format("woff2");
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}

@font-face {
  font-family: "Roboto";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("/assets/roboto/roboto-latin-500-normal-80162539.woff2") format("woff2");
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}

@font-face {
  font-family: "Roboto";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("/assets/roboto/roboto-latin-700-normal-8202161f.woff2") format("woff2");
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}

/* ==========================================================================
   Base
   Elements before any class.
   ========================================================================== */

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  color: var(--color-text);
  background: var(--color-background);
}

a {
  color: var(--color-accent);
}

/* ==========================================================================
   Layout and header
   Header, navigation, containers, page header, flash, breadcrumbs, tabs, footer.
   ========================================================================== */

/* The navy header (phase 73, variant B): the brand in white with the green "pb" mark, the
   navigation in a light blue-grey, the current item on translucent white. Every layout —
   the app, the weekly report, the sign-in page — carries it, so each page says the same brand. */
.app-header {
  display: flex;
  align-items: center;
  gap: calc(var(--space) * 1.5);
  padding: 10px var(--space);
  color: var(--color-on-navy-muted);
  background: var(--color-header);
}

.app-title {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--color-on-navy);
  text-decoration: none;
}

/* The phenobyte mark before the brand, drawn in CSS: nothing to read for a screen reader. */
.app-title::before {
  content: "pb" / "";
  flex: none;
  width: 26px;
  height: 26px;
  font-size: 12px;
  font-weight: 700;
  line-height: 26px;
  letter-spacing: 0;
  text-align: center;
  color: var(--color-on-navy);
  background: linear-gradient(var(--color-logo-green-light), var(--color-logo-green));
  border-radius: 6px;
}

.app-nav {
  display: flex;
  gap: 4px;
}

.app-nav a {
  padding: 6px 12px;
  font-size: 15px;
  font-weight: 500;
  color: var(--color-on-navy-muted);
  text-decoration: none;
  border-radius: var(--radius);
}

/* A header item hovered or open, and the one of the current section: a nav link or the
   Master data menu's summary. */
.app-nav a:hover,
.nav-menu > summary:hover,
.nav-menu[open] > summary {
  color: var(--color-on-navy);
  background: var(--color-on-navy-hover);
}

.app-nav a[aria-current="page"],
.nav-menu.is-current > summary {
  color: var(--color-on-navy);
  background: var(--color-on-navy-current);
}

/* Guide, Tour and Sign out on the navy: outlined in translucent white. */
.app-header .button-plain,
.app-header .button-secondary {
  color: var(--color-on-navy);
  background: transparent;
  border-color: var(--color-on-navy-line);
}

.app-header .button-plain:hover,
.app-header .button-secondary:hover {
  background: var(--color-on-navy-hover);
  border-color: var(--color-on-navy-line);
}

.container {
  max-width: 1120px;
  margin: 0 auto;
  padding: calc(var(--space) * 1.5) var(--space);
}

/* Pages with wide tables (project deliveries, reports, company page) take the whole
   window, like the editor: a feed of eleven columns needs every pixel a wide screen has. */
.container-wide {
  max-width: none;
}

.table-scroll {
  overflow-x: auto;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space);
  margin-bottom: var(--space);
}

.page-header h1 {
  margin: 0;
  font-size: 22px;
}

/* Flash ------------------------------------------------------------------- */

.flash {
  padding: 10px 12px;
  margin-bottom: var(--space);
  border-radius: var(--radius);
  background: var(--color-success-bg);
  color: var(--color-success-text);
}

.flash-alert {
  background: var(--color-error-bg);
  color: var(--color-danger);
}

/* Page subtitle and toolbar ----------------------------------------------- */

.page-subtitle {
  margin-left: 8px;
  font-size: 16px;
  font-weight: 400;
  color: var(--color-text-muted);
}

.toolbar {
  display: flex;
  gap: 6px;
  align-items: center;
}

/* Aside and footer -------------------------------------------------------- */

/* Guide and Tour sit apart from the navigation, at the right end of the header. */
.app-aside {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-left: auto;
}

.app-user {
  color: var(--color-on-navy-muted);
  font-size: 14px;
  margin-right: 4px;
}

/* Version and "Powered by" on every page, out of the way at the bottom. */
.app-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 20px;
  padding: 16px var(--space) 20px;
  color: var(--color-text-muted);
  font-size: 12px;
}

.app-powered {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.app-powered-logo {
  height: 16px;
  width: auto;
  vertical-align: middle;
}

.app-header-note {
  color: var(--color-on-navy-muted);
}

/* Breadcrumbs and tabs ---------------------------------------------------- */

/* "Projects › OM 651 › A-sample" above the page header: the way up, instead of Back buttons. */
.breadcrumbs ol {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 6px;
  padding: 0;
  list-style: none;
  font-size: 14px;
  color: var(--color-text-muted);
}

.breadcrumbs li + li::before {
  content: "›";
  margin-right: 6px;
}

.breadcrumbs a {
  color: var(--color-text-muted);
  text-decoration: none;
}

.breadcrumbs a:hover {
  color: var(--color-text);
  text-decoration: underline;
}

.breadcrumbs a[aria-current="page"] {
  color: var(--color-text);
  font-weight: 500;
}

/* The four views of one batch (phase 70: a bar that cannot be overlooked). One control on a light
   surface, each tab with its icon; the current tab is marked by weight and an accent underline,
   not by a fill of its own: colour means delivery status. */
.tabs {
  display: flex;
  gap: 2px;
  margin: 0 0 var(--space);
  padding: 0 4px;
  background: var(--color-surface-muted);
  border: var(--line);
  border-radius: 8px 8px 0 0;
}

.tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 16px;
  margin-bottom: -1px;
  font-weight: 500;
  color: var(--color-text);
  text-decoration: none;
  white-space: nowrap;
  border-bottom: 2px solid transparent;
}

.tab:hover {
  color: var(--color-text);
  background: color-mix(in srgb, var(--color-text) 5%, transparent);
}

.tab[aria-current="page"] {
  font-weight: 700;
  border-bottom-color: var(--color-accent);
}

@media (max-width: 699px) {
  .tabs {
    padding: 0;
  }

  .tab {
    flex: 1 1 0;
    justify-content: center;
    gap: 5px;
    min-width: 0;
    padding: 0 6px;
    font-size: 13px;
  }
}

/* ==========================================================================
   Buttons and forms
   ========================================================================== */

/* Buttons ----------------------------------------------------------------- */

.button,
input[type="submit"] {
  display: inline-block;
  padding: 7px 14px;
  font: inherit;
  font-weight: 500;
  color: var(--color-surface);
  text-decoration: none;
  background: var(--color-accent);
  border: 1px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
  white-space: nowrap;
}

.button:hover,
input[type="submit"]:hover {
  background: var(--color-accent-dark);
}

/* Secondary buttons: white, a stronger border and accent text, so a layman sees them as buttons.
   The one filled .button per page stays the primary action (docs/ux-ideas.md §10). */
.button-secondary,
.button-plain {
  font-weight: 500;
  color: var(--color-accent);
  background: var(--color-surface);
  border-color: var(--color-border-strong);
}

.button-secondary:hover,
.button-plain:hover {
  background: color-mix(in srgb, var(--color-accent) 8%, white);
  border-color: var(--color-accent);
}

.button-danger {
  color: var(--color-danger);
  background: var(--color-surface);
  border-color: var(--color-border-strong);
}

.button-danger:hover {
  color: var(--color-surface);
  background: var(--color-danger);
  border-color: var(--color-danger);
}

.button-small {
  padding: 4px 10px;
  font-size: 13px;
}

.inline-form {
  display: inline-block;
}

/* Search ------------------------------------------------------------------ */

.search-form {
  display: flex;
  gap: 8px;
  margin-bottom: var(--space);
}

.search-form input[type="search"] {
  flex: 1;
  max-width: 360px;
}

/* Surfaces ---------------------------------------------------------------- */

/* A box on the page: white, the thin line, the radius — forms, cards, tables, the tree's panel,
   the charts' frames, the report page's Send bar, Today's tiles, the tour card and the help
   box. Each component's own rule below adds size, padding and shadow. The weekly report's
   phone card keeps its own in the phone query, where it applies. */
.form,
.card,
.menu-items,
.table,
.panel,
.timeline-scroll,
.ramp-up-header,
.ramp-up-group,
.weekly-report-actions,
.today-number,
.today-projects,
.tour-card,
.help-box {
  background: var(--color-surface);
  border: var(--line);
  border-radius: var(--radius);
}

/* Forms ------------------------------------------------------------------- */

.form {
  max-width: 480px;
  padding: var(--space);
}

.field {
  margin-bottom: var(--space);
}

.field label {
  display: block;
  margin-bottom: 4px;
  font-weight: 500;
}

/* A form control: the text's font on the surface, the thin line, the radius. Every input and
   select the app draws shares this look and the focus below; the forms' own rules further down
   set their size and padding. */
input[type="text"],
input[type="search"],
input[type="email"],
input[type="password"],
input[type="tel"],
.field input[type="date"],
.field select,
.field input[type="number"],
.panel input[type="number"],
.receipt-form input,
.receipt-form select,
.list-filters select,
.list-filters input[type="search"],
.panel .promise-change select,
.panel .promise-change input,
.weekly-report-table input,
.weekly-report-table select {
  font: inherit;
  color: var(--color-text);
  background: var(--color-surface);
  border: var(--line);
  border-radius: var(--radius);
}

input[type="text"],
input[type="search"],
input[type="email"],
input[type="password"],
input[type="tel"],
.field input[type="date"],
.field select,
.field input[type="number"],
.panel input[type="number"] {
  width: 100%;
  padding: 7px 10px;
}

input[type="text"]:focus,
input[type="search"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="tel"]:focus,
.field input[type="date"]:focus,
.field select:focus,
.field input[type="number"]:focus,
.panel input[type="number"]:focus,
.receipt-form input:focus,
.receipt-form select:focus,
.list-filters select:focus,
.weekly-report-table input:focus,
.weekly-report-table select:focus {
  border-color: var(--color-accent);
  outline: 2px solid var(--focus-ring);
}

/* A password with an eye at its right end that shows and hides it (phase 68). The input keeps its
   full width; the padding keeps the typed text clear of the eye. */
.password-field {
  position: relative;
  display: block;
}

.password-field input {
  padding-right: 40px;
}

.password-toggle {
  position: absolute;
  top: 50%;
  right: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 30px;
  padding: 0;
  color: var(--color-text-muted);
  background: none;
  border: 0;
  border-radius: var(--radius);
  cursor: pointer;
  transform: translateY(-50%);
}

.password-toggle:hover,
.password-toggle[aria-pressed="true"] {
  color: var(--color-accent);
}

.password-toggle:focus-visible {
  outline: 2px solid var(--color-accent);
}

.password-toggle .password-eye-hide,
.password-toggle[aria-pressed="true"] .password-eye-show {
  display: none;
}

.password-toggle[aria-pressed="true"] .password-eye-hide {
  display: block;
}

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

.form-errors {
  padding: 10px 12px;
  margin-bottom: var(--space);
  color: var(--color-danger);
  background: var(--color-error-bg);
  border-radius: var(--radius);
}

.form-errors h2 {
  margin: 0 0 4px;
  font-size: 15px;
}

.form-errors ul {
  margin: 0;
  padding-left: 18px;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: var(--space);
}

.field-hint {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--color-text-muted);
}

.form-hint {
  margin: 0 0 var(--space);
  padding: 8px 10px;
  font-size: 0.9rem;
  color: var(--color-text-muted);
  background: var(--color-background);
  border-radius: var(--radius);
}

.field-locked {
  margin: 0;
  padding: 7px 10px;
  background: var(--color-background);
  border: var(--line);
  border-radius: var(--radius);
}

.button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* New batch, sign in ------------------------------------------------------ */

/* The new-batch form's "Start from": a copy of the last batch, or empty. */
.source-choice {
  border: 0;
  padding: 0;
  margin: 0 0 var(--space);
}

.source-choice legend {
  padding: 0;
  margin-bottom: 6px;
  font-weight: 600;
}

.source-choice .choice {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  margin-bottom: 6px;
  font-weight: 400;
}

.source-choice .choice input {
  margin-top: 4px;
}

.source-choice .choice .field-hint {
  display: block;
  margin: 0;
}

/* The new-batch form's root: an existing part, or one created right here. Only the fields of
   the chosen way are shown. */
.root-choice .choice {
  display: flex;
  gap: 8px;
  align-items: center;
  margin: 6px 0;
  font-weight: 400;
}

.root-choice-fields {
  display: grid;
  gap: 8px;
  margin: 0 0 10px 24px;
}

.root-choice-fields .field-hint {
  margin-top: -4px;
}

.root-choice:has(input[value="pick"]:checked) .root-choice-new,
.root-choice:has(input[value="new"]:checked) .root-choice-pick {
  display: none;
}

/* Sign in and password reset: one narrow form in the middle of the page. */
.sign-in {
  max-width: 480px;
}

.sign-in h1 {
  margin: var(--space) 0;
  font-size: 22px;
}

.user-form .field {
  margin-bottom: 10px;
}

.user-form .field-checkbox label {
  display: inline;
  font-weight: 400;
}

/* Button group ------------------------------------------------------------ */

/* Buttons that belong together, drawn as one control. */
.button-group {
  display: inline-flex;
}

.button-group > .button {
  border-radius: 0;
}

.button-group > .button + .button {
  margin-left: -1px;
}

.button-group > .button:first-child {
  border-radius: var(--radius) 0 0 var(--radius);
}

.button-group > .button:last-child {
  border-radius: 0 var(--radius) var(--radius) 0;
}

/* ==========================================================================
   Cards, folds and menus
   ========================================================================== */

.cards {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space);
  align-items: flex-start;
}

.card {
  flex: 1 1 300px;
  padding: var(--space);
}

.card h2 {
  margin: 0 0 10px;
  font-size: 15px;
}

/* A card's heading with a small action beside it, e.g. the company card's Edit (phase 68). */
.card-head {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.card-head h2 {
  margin: 0;
}

.card-empty {
  margin: 0;
  font-size: 13px;
  color: var(--color-text-muted);
}

/* Card headline and detail list ------------------------------------------- */

.card-headline {
  margin: 0 0 8px;
  font-size: 1rem;
  font-weight: 600;
}

.detail-list {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 12px;
  margin: 0;
  font-size: 0.9rem;
}

.detail-list dt {
  color: var(--color-text-muted);
}

.detail-list dd {
  margin: 0;
}

/* Project summary */

.card-wide {
  flex: 2 1 420px;
}

/* Part page cards --------------------------------------------------------- */

.part-projects .card h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 8px;
  font-size: 1rem;
}

.part-projects .detail-list dd .part-number + .part-number {
  margin-left: 8px;
}

/* A lone manufacturer card should not stretch across the page. */
.part-cards .card {
  max-width: 520px;
}

/* Company page cards ------------------------------------------------------ */

/* The report link on the company page: the whole URL, selectable, never cut. */
.card-hint {
  margin: 0 0 8px;
  font-size: 13px;
  color: var(--color-text-muted);
}

.report-link {
  margin: 0 0 10px;
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 13px;
  overflow-wrap: anywhere;
  user-select: all;
}

.report-last {
  margin: 10px 0 0;
  font-size: 14px;
}

.report-reminder {
  margin-top: 10px;
}

/* Who gets the Monday mail (phase 78): the company's e-mail, then the recipients. */
.report-recipients {
  margin-top: 14px;
}

.report-recipients-head {
  margin: 0 0 4px;
  font-size: 14px;
  font-weight: 600;
}

/* Folds ------------------------------------------------------------------- */

/* A list folded until asked for (the company page's parts). */
.list-fold > summary {
  cursor: pointer;
  list-style-position: outside;
  margin-left: 1rem;
}

.list-fold > summary .section-heading {
  display: inline;
}

.list-fold[open] > summary {
  margin-bottom: 0.75rem;
}

.list-fold-count,
.list-fold-worst {
  font-weight: 400;
}

/* A card folded to its heading (the company page's master-data parts). */
.card-fold > summary {
  cursor: pointer;
}

.card-fold > summary h2 {
  display: inline;
  margin: 0;
}

.card-fold[open] > summary {
  margin-bottom: 10px;
}

/* Menus ------------------------------------------------------------------- */

/* A <details> menu: "…" for a page's or a row's secondary actions, "Master data" in the nav. */
.menu {
  position: relative;
  display: inline-block;
}

.menu > summary {
  list-style: none;
  cursor: pointer;
}

.menu > summary::-webkit-details-marker {
  display: none;
}

.menu-toggle {
  min-width: 32px;
  text-align: center;
}

.menu-items {
  position: absolute;
  right: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  min-width: 160px;
  margin-top: 4px;
  padding: 4px;
  text-align: left;
  box-shadow: var(--shadow-popover);
}

.menu-items > a,
.menu-items > form button {
  display: block;
  width: 100%;
  padding: 6px 10px;
  font: inherit;
  font-size: 14px;
  color: var(--color-text);
  text-align: left;
  text-decoration: none;
  white-space: nowrap;
  background: none;
  border: 0;
  border-radius: 4px;
  cursor: pointer;
}

.menu-items > form {
  margin: 0;
}

.menu-items > a:hover,
.menu-items > form button:hover {
  background: var(--color-background);
}

.menu-items > form button.menu-danger {
  color: var(--color-danger);
}

/* "Master data ▾" in the nav: a nav entry that opens its three pages. */
.nav-menu > summary {
  padding: 6px 12px;
  font-size: 15px;
  font-weight: 500;
  color: var(--color-on-navy-muted);
  border-radius: var(--radius);
}

.nav-menu > summary::after {
  content: " ▾";
  font-size: 12px;
}

.nav-menu .menu-items {
  right: auto;
  left: 0;
}

/* The dropdown keeps its white surface, so its entries go back to dark text. */
.app-nav .nav-menu .menu-items a {
  padding: 6px 10px;
  color: var(--color-text);
  border-radius: 4px;
}

.app-nav .nav-menu .menu-items a:hover {
  background: var(--color-background);
}

.app-nav .nav-menu .menu-items a[aria-current="page"] {
  color: var(--color-accent-dark);
  background: color-mix(in srgb, var(--color-accent) 10%, white);
}

/* ==========================================================================
   Badges, lights and marks
   Colour means delivery status and nothing else; the kind is a glyph.
   ========================================================================== */

/* Kind badge -------------------------------------------------------------- */

/* The kind is told by its glyph; the badge stays neutral so that colour means delivery
   status wherever it appears. */
.kind-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 10px;
  border: var(--line);
  border-radius: var(--radius-pill);
  background: var(--color-surface);
  color: var(--color-text-muted);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  vertical-align: middle;
  white-space: nowrap;
}

/* Variant and provisional tags -------------------------------------------- */

.variant-tag,
.variant-count {
  display: inline-block;
  margin-left: 0.4rem;
  padding: 0 6px;
  border: var(--line);
  border-radius: 8px;
  color: var(--color-text-muted);
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 400;
  white-space: nowrap;
  vertical-align: middle;
  text-decoration: none;
}

/* On their own line under the number, so the number column keeps its width. */
td.part-number .variant-tag,
td.part-number .variant-count {
  display: block;
  width: fit-content;
  margin: 2px 0 0 18px;
}

.panel-part-meta .variant-tag,
.ru-part .variant-tag {
  margin-left: 0;
}

/* A provisional part number (the template's, decision 8): the same plain tag, and a dashed
   frame on the canvas — a dash of its own, so it is not read as the pseudo-root (4 3) or as
   "complete late" (6 3), and no colour of its own. */
.provisional-tag {
  display: inline-block;
  margin-left: 0.4rem;
  padding: 0 6px;
  border: 1px dashed var(--color-text-muted);
  border-radius: 8px;
  color: var(--color-text-muted);
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 400;
  white-space: nowrap;
  vertical-align: middle;
}

td.part-number .provisional-tag {
  display: block;
  width: fit-content;
  margin: 2px 0 0;
}

a.variant-tag:hover {
  color: var(--color-accent);
  border-color: var(--color-accent);
}

/* Delivery status --------------------------------------------------------- */

/* A status's colour, its ink and the text on it; a batch's light (traffic-light-*) and the light
   badge beside it read the same three. */
.status-overdue,
.traffic-light-red {
  --status-color: var(--status-red);
  --status-ink: var(--status-red-ink);
  --status-on: var(--status-on-dark);
}

.status-at-risk,
.status-inspection-overdue,
.status-due-soon,
.traffic-light-amber {
  --status-color: var(--status-amber);
  --status-ink: var(--status-amber-ink);
  --status-on: var(--status-on-light);
}

.status-complete,
.status-complete-late,
.traffic-light-green {
  --status-color: var(--status-green);
  --status-ink: var(--status-green-ink);
  --status-on: var(--status-on-dark);
}

.status-partly-shipped,
.status-shipped,
.status-received {
  --status-color: var(--status-blue);
  --status-ink: var(--status-blue-ink);
  --status-on: var(--status-on-dark);
}

.status-unplanned,
.status-unassigned,
.status-open,
.status-ordered,
.traffic-light-none,
.traffic-light-grey {
  --status-color: var(--status-grey);
  --status-ink: var(--status-grey-ink);
  --status-on: var(--status-on-dark);
}

/* One sentence in the status colour, after the colour's mark. */
.status-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--status-color, var(--status-grey));
  color: var(--status-ink, var(--status-grey-ink));
  background: color-mix(in srgb, var(--status-color, var(--status-grey)) var(--status-tint), white);
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
  vertical-align: middle;
}

/* Phase 64e: in the narrow panel a sentence wider than the panel wraps inside its badge. */
.panel-status .status-badge {
  white-space: normal;
  line-height: 1.3;
  max-width: 100%;
}

.icon {
  flex: none;
  vertical-align: middle;
}

/* A status colour's Lucide icon before its sentence (IconsHelper#status_icon), in the ink. */
.status-mark {
  color: var(--status-ink, var(--status-grey-ink));
  stroke-width: 2.5;
  vertical-align: -3px;
}

/* A mark in a round dot of its status colour: the rows' status dot, the legend's and the
   counts' marks, a traffic light. The size is the only thing that differs. */
.mark-dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: var(--status-color, var(--status-grey));
  color: var(--status-on, var(--status-on-dark));
  line-height: 1;
  vertical-align: middle;
}

/* The mark inside the disc: the icon's inner shape, as large as the disc (IconsHelper#disc_mark). */
.mark-dot > .disc-mark {
  width: 100%;
  height: 100%;
}

/* A batch's or a project's traffic light: a big light in its colour with the mark, no number
   inside, and the sentence beside it that says why. */
.traffic-light-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--color-text);
  vertical-align: middle;
}

/* The mark is centred by flex, not by line-height, so light and words share one centre line in
   Firefox and Chrome alike. */
.traffic-light {
  width: 26px;
  height: 26px;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--status-color) 28%, transparent);
}

.page-header h1 .traffic-light-status {
  margin-left: 10px;
  font-size: 0.95rem;
}

/* A batch row's light alone in a narrow first column; its sentence is the badge beside the
   progress, tinted in the light's colour. */
.batches-table .light-column {
  width: 52px;
  text-align: center;
}

.traffic-light.is-small {
  width: 22px;
  height: 22px;
  box-shadow: none;
}

/* Project phases ---------------------------------------------------------- */

.phase-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: var(--radius-pill);
  border: var(--line);
  background: var(--color-background);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--color-text);
  vertical-align: middle;
}

/* Status dot -------------------------------------------------------------- */

/* The row's status at its start, a dot in the status colour like the legend under the tree. */
.status-dot {
  margin-right: 6px;
}

.admin-badge {
  padding: 1px 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--color-accent-dark);
  background: color-mix(in srgb, var(--color-accent) 10%, white);
  border-radius: var(--radius-pill);
}

/* ==========================================================================
   Lists, tables and filters
   The tables of every page: parts, deliveries, receipts, promise history, projects,
   batches, users; the filter row and its count.
   ========================================================================== */

/* Table ------------------------------------------------------------------- */

.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  overflow: hidden;
}

.table th,
.table td {
  padding: 9px 12px;
  text-align: left;
  border-bottom: var(--line);
}

.table thead th {
  font-size: 13px;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--color-surface-muted);
}

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

.part-number {
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-weight: 600;
}

/* Part numbers and headings never wrap, so the section tables line up with each other. */
.table th,
td.part-number {
  white-space: nowrap;
}

.actions-column {
  width: 1%;
  white-space: nowrap;
  text-align: right;
}

.actions-column > * + * {
  margin-left: 6px;
}

.count-column {
  width: 1%;
  color: var(--color-text-muted);
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

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

/* Part lists -------------------------------------------------------------- */

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

.part-list li {
  display: flex;
  gap: 8px;
  align-items: baseline;
  padding: 6px 0;
}

.part-list li + li {
  border-top: var(--line);
}

.part-list-name {
  color: var(--color-text-muted);
}

/* Parts list grouped by kind ---------------------------------------------- */

.list-summary {
  margin: 0 0 var(--space);
  color: var(--color-text-muted);
  font-size: 0.9rem;
}

.kind-section {
  margin-bottom: calc(var(--space) * 1.75);
}

.kind-heading {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 8px;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--color-text-muted);
  text-transform: uppercase;
}

.kind-heading .kind-icon {
  width: 14px;
  height: 14px;
}

.manufacturer-column {
  color: var(--color-text);
}

.is-unknown {
  color: var(--color-text-muted);
  font-style: italic;
}

td.part-number .kind-icon {
  margin-right: 4px;
  color: var(--color-text-muted);
}

/* Variants: indented under their type in the parts list, a small tag wherever a variant needs
   telling apart from its siblings. Neutral grey, since colour means delivery status. */
tr.is-variant td.part-number {
  padding-left: 2rem;
}

/* Variant list ------------------------------------------------------------ */

.variant-list {
  margin: 0 0 8px;
  padding-left: 1.1rem;
}

.variant-list li {
  margin: 2px 0;
}

/* Delivery rows ----------------------------------------------------------- */

.is-empty {
  color: var(--color-text-muted);
}

/* Supplied parts sit below their deliverable, indented, on a slightly quieter row. */
.delivery-row.is-supplied td:first-child {
  padding-left: 1.8rem;
}

.delivery-row.is-supplied {
  background: color-mix(in srgb, var(--color-text-muted) 5%, white);
}

.form-mode {
  display: inline-block;
  margin-left: 0.4rem;
  padding: 0 6px;
  border-radius: 4px;
  background: color-mix(in srgb, var(--color-text-muted) 15%, white);
  color: var(--color-text-muted);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  vertical-align: middle;
}

.reported.is-silent,
.delay.is-open {
  color: var(--status-red-ink);
  font-weight: 600;
}

.reported-column,
.progress-column,
.shipped-column {
  white-space: nowrap;
}

.shipped-column {
  font-variant-numeric: tabular-nums;
}

/* The forecast under the promise, when the numbers say something else than the manufacturer. */
.forecast-date {
  display: block;
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

.forecast-date.is-late {
  color: var(--status-amber-ink);
}

/* "12 behind plan" (phase 80): muted, red ink while pieces are missing against the plan. */
.behind-plan {
  color: var(--color-text-muted);
}

.behind-plan.is-behind {
  color: var(--status-red-ink);
}

/* The weeks of a plan that differ from its rate, under the order form in the panel. */
.plan-weeks {
  margin-top: 0.5rem;
}

.plan-weeks-list {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  margin: 0.25rem 0;
  padding: 0;
  list-style: none;
  font-variant-numeric: tabular-nums;
}

.plan-week-form input[type="number"] {
  width: 6em;
}

.summary-supplied {
  display: block;
  margin-top: 0.25rem;
  color: var(--color-text-muted);
  font-size: 0.9rem;
}

.filter-form {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: end;
  margin-bottom: 1rem;
}

.filter-form label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

.date-column,
.status-column {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.delay.is-settled {
  color: var(--color-text-muted);
}

/* One line, cut with an ellipsis: a note, a maker, a programme title, a search hit. Each rule
   below says how wide. */
.delivery-note,
.deliveries-table .manufacturer-column,
.reports-table .project-column,
#my_orders .project-column,
.receipt-note,
.slip-note,
.panel-result-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.delivery-note {
  display: block;
  max-width: 200px;
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

.delivery-row.is-editing td {
  background: var(--color-surface-muted);
}

.delivery-form-title {
  display: flex;
  gap: 8px;
  align-items: baseline;
  margin: 0 0 8px;
}

.delivery-fields {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: end;
}

.delivery-fields label {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

.delivery-fields input {
  padding: 6px 8px;
  font: inherit;
  font-size: 0.9rem;
  color: var(--color-text);
  border: var(--line);
  border-radius: var(--radius);
}

.delivery-note-field {
  flex: 1 1 240px;
}

.delivery-form-actions {
  display: flex;
  gap: 6px;
  margin-top: 10px;
}

.deliveries-table .manufacturer-column {
  max-width: 170px;
}

/* A programme title runs to eighty characters; cut it rather than let it wrap into a column
   of six lines while the dashes next to it get the room. The cut grows with the window, so a
   wide screen shows the whole title; the tooltip has it always. */
.reports-table .project-column,
#my_orders .project-column {
  max-width: max(260px, 19vw);
}

.deliveries-table th a {
  color: inherit;
  text-decoration: none;
}

.deliveries-table th a.is-sorted {
  color: var(--color-text);
}

.deliveries-table th a.is-sorted::after {
  content: " ▾";
}

.section-heading,
.stale-deliveries h2 {
  margin: calc(var(--space) * 1.5) 0 8px;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--color-text-muted);
  text-transform: uppercase;
}

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

/* Batch summary ----------------------------------------------------------- */

.summary-headline {
  margin-bottom: 8px;
}

.summary.is-complete .summary-headline strong {
  color: var(--status-green-ink);
}

.progress {
  height: 8px;
  margin-bottom: 10px;
  overflow: hidden;
  background: var(--color-border);
  border-radius: var(--radius-pill);
}

.progress-bar {
  height: 100%;
  background: var(--status-complete);
  transition: width 0.3s ease;
}

.summary-counts {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  margin: 0;
  padding: 0;
  font-size: 0.85rem;
  list-style: none;
}

.summary-counts li {
  display: flex;
  gap: 6px;
  align-items: center;
  color: var(--status-ink);
}

.summary-count {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.progress-column {
  white-space: nowrap;
}

.progress-column .status-badge {
  margin-left: 6px;
}

.progress-label {
  font-variant-numeric: tabular-nums;
}

/* Counts and manufacturer links ------------------------------------------- */

.section-count {
  margin-left: 8px;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
}

.manufacturer-link {
  color: inherit;
}

.manufacturer-link:hover {
  color: var(--color-accent);
}

.required-column {
  font-variant-numeric: tabular-nums;
}

/* Receipts ---------------------------------------------------------------- */

.receipts {
  margin-top: 10px;
  padding-top: 8px;
  border-top: var(--line);
}

.receipts-headline {
  margin: 0 0 6px;
  font-size: 13px;
}

.receipts-list {
  margin: 0 0 8px;
  padding: 0;
  list-style: none;
}

.receipt {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  font-size: 12px;
  border-bottom: 1px dashed var(--color-border);
}

.receipt-date {
  font-variant-numeric: tabular-nums;
}

.receipt-quantity {
  font-weight: 600;
}

.receipt-note {
  color: var(--color-text-muted);
  max-width: 200px;
}

.receipt-actions {
  display: flex;
  gap: 4px;
  margin-left: auto;
}

.inspection-badge {
  padding: 1px 8px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  border: 1px solid var(--status-unplanned);
  color: var(--status-grey-ink);
}

.inspection-badge.inspection-released {
  border-color: var(--status-complete);
  color: var(--status-green-ink);
}

.inspection-badge.inspection-rejected {
  border-color: var(--status-overdue);
  color: var(--status-red-ink);
}

.receipt.inspection-rejected .receipt-quantity {
  text-decoration: line-through;
  color: var(--color-text-muted);
}

.receipt-form {
  display: grid;
  gap: 6px;
  margin-top: 8px;
}

.receipt-form label {
  display: grid;
  grid-template-columns: 70px 1fr;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--color-text-muted);
}

.delivery-form .receipt-form,
.is-editing .receipt-form {
  grid-template-columns: repeat(4, minmax(0, 1fr)) auto;
  align-items: end;
}

.is-editing .receipt-form label {
  grid-template-columns: 1fr;
}

.received {
  font-variant-numeric: tabular-nums;
}

.supplier-part-number,
.order-number {
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 12px;
}

.supplier-part-number {
  display: block;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--color-text-muted);
}

/* The delivery rows carry two buttons; let them stack instead of widening the table. */
.deliveries-table .actions-column {
  white-space: normal;
  max-width: 150px;
}

.deliveries-table .actions-column > * {
  margin: 2px 0;
}

.receipt-form input,
.receipt-form select {
  padding: 6px 8px;
  font-size: 0.9rem;
}

.promise-change {
  display: grid;
  gap: 6px;
  margin: 2px 0 6px;
  padding: 6px 8px;
  border: 1px dashed var(--color-border);
  border-radius: var(--radius);
}

.delivery-fields.promise-change {
  display: flex;
  margin-top: 8px;
}

.promise-change-label {
  align-self: center;
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

/* Promise history --------------------------------------------------------- */

/* Looks like a form control but is not in that rule: it never set the text colour, so joining
   would change the select's text from the browser's to the navy one — a choice, not a merge. */
.delivery-fields.promise-change select {
  padding: 6px 8px;
  font: inherit;
  font-size: 0.9rem;
  border: var(--line);
  border-radius: var(--radius);
  background: var(--color-surface);
}

.slips {
  margin: 6px 0 0;
  padding: 0;
  list-style: none;
}

.slip {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  padding: 3px 0;
  font-size: 12px;
  color: var(--color-text-muted);
  border-bottom: 1px dashed var(--color-border);
}

.slip-dates {
  font-variant-numeric: tabular-nums;
  color: var(--color-text);
}

.slip-days {
  font-weight: 600;
  color: var(--status-amber-ink);
}

.slip-reason {
  font-weight: 600;
}

/* A promise pulled in is good news: green, not the at-risk colour. */
.slip.is-pulled-in .slip-days,
.slip-days.is-pulled-in {
  color: var(--status-green-ink);
}

.slip-note {
  flex-basis: 100%;
}

.slip-count {
  display: block;
  font-size: 0.75rem;
  color: var(--status-amber-ink);
  cursor: help;
}

.deliveries-table .order-column {
  white-space: nowrap;
  font-size: 0.85rem;
}

/* A company without an address gets no reminders: said in the list, not left out. */
.no-email {
  display: inline-block;
  padding: 0 6px;
  border: 1px solid var(--color-text-muted);
  border-radius: 8px;
  font-size: 12px;
  color: var(--color-text-muted);
  white-space: nowrap;
}

/* Three cards side by side on a laptop: the part number keeps its line, the name wraps. */
.part-list .part-number {
  white-space: nowrap;
}

/* Projects and batches ---------------------------------------------------- */

/* The projects index: one block per project, its heading line above its own batch table
   (phase 64a). Fixed column widths so the blocks' columns line up with each other. */
.project-block + .project-block {
  margin-top: calc(var(--space) * 1.5);
}

.project-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.project-heading-title {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
}

.project-heading-customer {
  margin-left: 8px;
  font-weight: 400;
  color: var(--color-text-muted);
}

.project-heading-title .section-count {
  font-size: 0.9rem;
  color: var(--color-text-muted);
}

@media (min-width: 861px) {
  .batches-table {
    table-layout: fixed;
  }

  .batches-table .batch-label-column { width: 14%; }
  .batches-table .part-number-column { width: 14%; }
  .batches-table .date-column { width: 10%; }
  .batches-table .count-column { width: 6%; }
  .batches-table th.actions-column { width: 130px; }
}

.batches-table .progress-column {
  white-space: normal;
}

.batches-table .progress-column .status-badge {
  margin-left: 6px;
}

.weeks-to-end {
  font-weight: 600;
}

.orders-table {
  max-width: 900px;
}

/* Users ------------------------------------------------------------------- */

/* The users of a company on its page: who signs in, and the form to add one. */
.user-list {
  margin: 0 0 var(--space);
  padding: 0;
  list-style: none;
}

.user-list li {
  padding: 4px 0;
  border-bottom: var(--line);
}

/* The row lives in a Turbo Frame (users/_row, phase 68a); Edit swaps it for the form. */
.user-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.user-row.is-editing {
  display: block;
  padding: 6px 0;
}

/* The sentence after a Save: the page's flash sits outside the frame. */
.user-saved {
  font-size: 13px;
  color: var(--color-success-text);
}

/* "Add user" folds the form away; the summary is the button. */
.user-add > summary {
  display: inline-block;
  list-style: none;
}

.user-add > summary::-webkit-details-marker {
  display: none;
}

.user-add[open] > summary {
  margin-bottom: 10px;
}

.user-list-email {
  flex: 1;
}

/* Filters and list heads -------------------------------------------------- */

/* The filter row above a list (ListFilter) and its count line. */
.list-filters {
  margin-bottom: 0.5rem;
}

.list-filters select,
.list-filters input[type="search"] {
  box-sizing: border-box;
  height: 2.3rem;
  padding: 0 10px;
  font-size: 0.9rem;
}

.list-filters select {
  max-width: 24rem;
}

.list-filters input[type="search"] {
  width: 21rem;
}

.list-filters .filter-check {
  flex-direction: row;
  align-items: center;
  gap: 0.4rem;
  padding-bottom: 0.4rem;
}

.list-count {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0 0 0.5rem;
  color: var(--color-text-muted);
  font-size: 0.9rem;
}

.list-filtered {
  color: var(--color-text);
  font-weight: 600;
}

.list-limit {
  margin: 0 0 0.5rem;
  font-size: 0.9rem;
  font-weight: 600;
}

/* Section and day heads inside a list (Upcoming by time, Reports by day). */
.list-group-row th {
  padding-top: 0.9rem;
  text-align: left;
  font-size: 0.9rem;
  font-weight: 600;
  background: var(--color-background);
  border-bottom: var(--line);
}

/* A head shown only for the filtered rows below it: not a match itself. */
.delivery-row.is-context td {
  opacity: 0.55;
}

.card-search input[type="search"] {
  width: 100%;
  max-width: 21rem;
}

/* ==========================================================================
   Tree canvas and panel
   The editor at /batches/:id/tree: canvas, nodes, legend, folding, the node panel.
   ========================================================================== */

/* Tree canvas ------------------------------------------------------------- */

.canvas {
  position: relative;
  flex: 1;
  min-height: 360px;
  /* Never taller than the window: the panel beside it may be long, and a canvas that grows
     with it would centre the tree below the fold. Room is left for the breadcrumb, the header,
     the tabs and the tree tools above it. */
  max-height: calc(100vh - 300px);
  overflow: hidden;
  background-color: var(--color-surface);
  background-image: radial-gradient(circle, var(--color-border) 1px, transparent 1px);
  background-size: 22px 22px;
  border: var(--line);
  border-radius: var(--radius);
  cursor: grab;
  touch-action: none;
  /* Dragging a node must move it, never select the label text underneath the pointer. */
  -webkit-user-select: none;
  user-select: none;
}

.canvas.is-panning {
  cursor: grabbing;
}

.canvas-surface {
  display: block;
  width: 100%;
  height: 100%;
}

.tree-edge {
  fill: none;
  stroke: var(--color-border-strong);
  stroke-width: 1.5;
  pointer-events: none;
}

.tree-node-box,
.tree-toggle rect,
.gs-node rect {
  fill: var(--color-surface);
  stroke: var(--color-border);
  stroke-width: 1.5;
}

.tree-node.is-root .tree-node-box {
  stroke: var(--status-color, var(--color-accent));
  stroke-width: 2;
}

.kind-glyph {
  color: var(--color-text-muted);
}

.glyph-stroke {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
}

.glyph-fill {
  fill: currentColor;
}

.kind-icon {
  width: 12px;
  height: 12px;
  flex: none;
  vertical-align: -1px;
}

/* Delivery status on a node: the border and a light tint. Without a project there is no
   status and the node stays neutral. */
.tree-node[class*="status-"] .tree-node-box {
  stroke: var(--status-color);
  fill: color-mix(in srgb, var(--status-color) var(--status-tint), var(--color-surface));
}

.tree-node.status-complete-late .tree-node-box {
  stroke-dasharray: 6 3;
}

/* Dimming keeps delivered nodes on the canvas, only quieter. */
.canvas.is-dimming .tree-node.status-complete,
.canvas.is-dimming .tree-node.status-complete-late {
  opacity: 0.3;
}

/* The status mark in a node's top right corner: a disc in the status colour, the mark inside. */
.tree-node-mark circle {
  fill: var(--status-color, var(--status-grey));
}

.tree-node-mark use {
  color: var(--status-on, var(--status-on-dark));
}

.tree-node-number {
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 13px;
  font-weight: 600;
  fill: var(--color-text);
}

.tree-node-name {
  font-size: 12px;
  fill: var(--color-text-muted);
}

.tree-hint {
  margin: 8px 0 0;
  font-size: 13px;
  color: var(--color-text-muted);
}

/* Tree editor ------------------------------------------------------------- */

/* The editor takes the whole window: the wider the canvas, the more of the tree fits at a
   readable scale instead of being zoomed down to fit. */
.container:has(.tree-editor) {
  max-width: none;
}

.tree-editor {
  display: flex;
  gap: var(--space);
  align-items: stretch;
  /* Fills the window below the app header and the container's own padding. */
  min-height: calc(100vh - 110px);
}

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

/* The canvas's card (phase 74): the tree tools on a line along its top edge, the canvas beneath,
   one frame around both. On a phone the tools wrap. */
.canvas-card {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.tree-tools {
  flex-wrap: wrap;
  gap: 6px var(--space);
  padding: 6px 8px;
  background: var(--color-surface-muted);
  border: var(--line);
  border-bottom: none;
  border-radius: var(--radius) var(--radius) 0 0;
}

.canvas-card .canvas {
  border-radius: 0 0 var(--radius) var(--radius);
}

.tree-node {
  cursor: pointer;
}

/* The selected node: a heavier frame, a deeper tint and a halo, all in its own status colour
   so that colour keeps meaning status alone. */
.tree-node.is-selected .tree-node-box {
  stroke: var(--status-color, var(--color-accent));
  stroke-width: 3.5;
  fill: color-mix(in srgb, var(--status-color, var(--color-accent)) 18%, var(--color-surface));
  filter: drop-shadow(0 0 7px color-mix(in srgb, var(--status-color, var(--color-accent)) 75%, transparent));
}

.tree-node.is-selected .tree-node-number {
  fill: var(--color-accent-dark);
}

/* The node a link led to: a pulse of the frame, then the plain selection. */
.tree-node.is-focused .tree-node-box {
  animation: node-focus 0.7s ease-out 3;
}

@keyframes node-focus {
  0% { stroke-width: 3.5; stroke-opacity: 1; }
  50% { stroke-width: 14; stroke-opacity: 0.35; }
  100% { stroke-width: 3.5; stroke-opacity: 1; }
}

.tree-node-number {
  fill: var(--color-accent-dark);
}

/* Panel ------------------------------------------------------------------- */

.panel {
  display: block;
  flex: none;
  width: 300px;
  padding: var(--space);
}

.panel-part {
  margin: 0 0 var(--space);
  padding-bottom: 10px;
  border-bottom: var(--line);
}

.panel-part-name {
  display: block;
  color: var(--color-text-muted);
}

.panel-section + .panel-section {
  margin-top: var(--space);
  padding-top: var(--space);
  border-top: var(--line);
}

.panel-section h3 {
  margin: 0 0 8px;
  font-size: 14px;
}

.panel-section h4 {
  margin: var(--space) 0 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text-muted);
}

.panel-section input[type="text"],
.panel-section input[type="search"] {
  margin-bottom: 8px;
}

.panel-search {
  position: relative;
}

.panel-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  left: 0;
  z-index: 5;
  max-height: 260px;
  margin-top: 2px;
  overflow-y: auto;
  background: var(--color-surface);
  border: 1px solid var(--color-text-muted);
  border-radius: var(--radius);
  box-shadow: var(--shadow-popover);
}

.panel-search.is-closed .panel-dropdown {
  display: none;
}

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

.panel-results li + li {
  border-top: var(--line);
}

.panel-result {
  display: flex;
  gap: 8px;
  align-items: baseline;
  width: 100%;
  padding: 8px 10px;
  font: inherit;
  text-align: left;
  background: none;
  border: 0;
}

button.panel-result {
  cursor: pointer;
}

button.panel-result:hover {
  background: color-mix(in srgb, var(--color-accent) 8%, white);
}

.panel-result.is-unavailable {
  color: var(--color-text-muted);
  cursor: not-allowed;
  background: var(--color-background);
}

.panel-result.is-unavailable .part-number,
.panel-result.is-unavailable .panel-result-name {
  color: var(--color-text-muted);
  text-decoration: line-through;
  text-decoration-color: color-mix(in srgb, var(--color-text-muted) 45%, transparent);
}

.panel-result-name {
  flex: 1;
  min-width: 0;
  color: var(--color-text-muted);
}

.panel-result-reason {
  flex: none;
  padding: 1px 7px;
  font-size: 11px;
  color: var(--color-text-muted);
  white-space: nowrap;
  background: var(--color-surface);
  border: var(--line);
  border-radius: var(--radius-pill);
}

.panel-empty {
  margin: 0;
  padding: 8px 10px;
  font-size: 13px;
  color: var(--color-text-muted);
}

.panel-suggestion {
  margin: 0 0 8px;
  font-size: 13px;
  color: var(--color-text-muted);
}

.panel-suggestion {
  padding: 8px 10px;
  color: var(--color-text);
  background: var(--color-note-bg);
  border-radius: var(--radius);
}

.panel-errors {
  margin: 0 0 8px;
  padding: 8px 10px 8px 26px;
  font-size: 13px;
  color: var(--color-danger);
  background: var(--color-error-bg);
  border-radius: var(--radius);
}

.panel-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* Folds (phase 55): what one fills in folds behind a line that says what is in it. The line
   is the heading, a muted state and — read-only — whose it is; the marker turns when open. */
.panel-fold > summary {
  position: relative;
  display: block;
  padding-left: 14px;
  cursor: pointer;
  list-style: none;
}

.panel-fold > summary::-webkit-details-marker {
  display: none;
}

.panel-fold > summary::before {
  position: absolute;
  top: 2px;
  left: 0;
  font-size: 12px;
  color: var(--color-text-muted);
  content: "\25B8";
}

.panel-fold[open] > summary::before {
  content: "\25BE";
}

.panel-fold > summary .panel-fold-title {
  display: inline;
  margin: 0 6px 0 0;
}

/* The fold line's state sits on its own indented line beneath the title (phase 64c). */
.panel-fold-state {
  display: block;
  padding-left: 12px;
  font-size: 12px;
  color: var(--color-text-muted);
}

/* A count ("In this parent ×2") stays on the title line (phase 64d). */
.panel-fold-state.panel-fold-state-inline {
  display: inline;
  padding-left: 0;
}

.panel-fold > summary .panel-read-only {
  display: block;
  cursor: default;
}

.panel-fold[open] > summary {
  margin-bottom: 8px;
}

/* Order, report and receipts inside the delivery section: a title and its state while folded. */
.panel-subfold {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px dashed var(--color-border);
}

.panel-subfold > summary .panel-fold-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text);
}

@media (max-width: 860px) {
  .tree-editor {
    flex-direction: column;
  }

  .panel {
    width: auto;
  }
}

/* Drag & drop ------------------------------------------------------------- */

.move-form {
  display: none;
}

/* Pointer-transparent, so the node under the cursor is the drop target, not the dragged one. */
.tree-node.is-dragging {
  pointer-events: none;
  opacity: 0.6;
}

.tree-node.is-drop-target .tree-node-box {
  stroke: var(--color-success-text);
  stroke-width: 2.5;
}

/* Canvas note ------------------------------------------------------------- */

.canvas-note {
  position: absolute;
  bottom: 14px;
  left: 50%;
  margin: 0;
  padding: 6px 12px;
  font-size: 13px;
  color: var(--color-text-muted);
  background: var(--color-surface);
  border: var(--line);
  border-radius: var(--radius-pill);
  transform: translateX(-50%);
}

/* Provisional nodes ------------------------------------------------------- */

.tree-node.is-provisional .tree-node-box {
  stroke-dasharray: 2 3;
}

.panel-provisional-number {
  display: block;
  font-weight: 600;
}

/* Legends on the canvas --------------------------------------------------- */

.canvas-legend {
  position: absolute;
  bottom: 12px;
  left: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  max-width: calc(100% - 24px);
  margin: 0;
  padding: 7px 12px;
  list-style: none;
  font-size: 12px;
  color: var(--color-text-muted);
  background: color-mix(in srgb, var(--color-surface) 88%, transparent);
  border: var(--line);
  border-radius: var(--radius);
  pointer-events: none;
}

.canvas-legend li {
  display: flex;
  align-items: center;
  gap: 6px;
}

.canvas-legend-status {
  left: auto;
  right: 12px;
}

.canvas-legend-status li {
  color: var(--status-ink);
}

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

.panel-part-title {
  margin: 0 0 6px;
}

.panel-part-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: 12px;
  color: var(--color-text-muted);
}

.panel-section select {
  width: 100%;
  margin-bottom: 8px;
}

/* Folding branches -------------------------------------------------------- */

.tree-toggle {
  cursor: pointer;
}

.tree-toggle text {
  font-size: 11px;
  font-weight: 600;
  fill: var(--color-text-muted);
  text-anchor: middle;
  pointer-events: none;
}

.tree-toggle:hover rect {
  stroke: var(--color-accent);
}

.tree-toggle:hover text {
  fill: var(--color-accent);
}

.panel-report-form h4 {
  margin: 0.5rem 0 0.25rem;
  font-size: 0.85rem;
}

.panel-delivery-meta {
  margin: 0 0 0.35rem;
  font-size: 0.85rem;
}

/* Delivery section of the editor panel ------------------------------------ */

.panel-delivery h3 {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  row-gap: 4px;
}

/* Phase 64e: badge and "?" wrap together under "Delivery" when the sentence does not fit. */
.panel-delivery .panel-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  min-width: 0;
}

.panel-delivery .panel-status .help {
  flex-shrink: 0;
}

.panel-delivery-form label,
.plan-week-form label,
.panel-inline-form label,
.panel-quantity {
  display: grid;
  grid-template-columns: 70px 1fr;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 12px;
  color: var(--color-text-muted);
}

.panel-delivery-form input[type="date"],
.plan-week-form input[type="date"] {
  width: 100%;
}

.panel-delivery-actions {
  margin: 4px 0 8px;
}

.panel-delivery-delay {
  margin: 8px 0 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--status-red-ink);
}

.panel-delivery-delay.is-settled {
  color: var(--color-text-muted);
}

.panel-delivery-summary {
  margin: 0 0 6px;
}

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

/* Quantities -------------------------------------------------------------- */

/* The pieces line and the parts below complete: grey, because colour means delivery status
   and nothing else. */
.tree-node-pieces,
.tree-node-complete {
  font-size: 11px;
  fill: var(--color-text-muted);
  font-variant-numeric: tabular-nums;
}

.tree-node-quantity {
  font-size: 11px;
  font-weight: 600;
  fill: var(--color-text-muted);
  text-anchor: end;
  font-variant-numeric: tabular-nums;
}

.panel-required {
  margin: 0 0 8px;
  font-size: 13px;
}

.panel-shipped,
.panel-forecast {
  margin: -4px 0 8px;
  font-size: 13px;
}

.panel-forecast.is-late strong {
  color: var(--status-amber-ink);
}

.panel-forecast.is-none {
  color: var(--color-text-muted);
  font-size: 12px;
}

.panel-hint-warning {
  color: var(--status-red-ink);
}

.panel-supply-chain-line {
  margin: 0 0 0.35rem;
  font-size: 0.85rem;
}

/* A muted addition to a statement (phase 64c): on its own indented line beneath it, so the
   narrow panel never breaks it mid-phrase. */
.panel-hint-line {
  display: block;
  padding-left: 12px;
  font-size: 12px;
  font-weight: 400;
  color: var(--color-text-muted);
}

.panel .promise-change select,
.panel .promise-change input {
  width: 100%;
  padding: 6px 8px;
  font-size: 12px;
}

.panel-ready-by {
  margin: 0 0 6px;
  font-size: 13px;
}

/* Read-only with a reason ------------------------------------------------- */

/* What the user may not change says whose it is. Neutral on purpose: colour means status. */
.panel-read-only {
  margin: 4px 0 0;
  padding: 6px 8px;
  font-size: 12px;
  color: var(--color-text-muted);
  background: var(--color-background);
  border-left: 3px solid var(--color-border);
  border-radius: 2px;
}

.panel-read-only-values {
  margin: 4px 0;
}

.panel-delivery-form.is-read-only h4 {
  margin-bottom: 4px;
}

/* The pseudo-root over a company's slice is not a part: a dashed frame says so. */
.tree-node.is-pseudo .tree-node-box {
  stroke-dasharray: 4 3;
}

/* ==========================================================================
   Timeline
   ========================================================================== */

.timeline-scroll {
  overflow-x: auto;
}

.timeline {
  display: block;
  font-size: 12px;
}

.timeline-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  margin: 0 0 var(--space);
  padding: 0;
  list-style: none;
  font-size: 12px;
  color: var(--color-text-muted);
}

.legend-glyph {
  width: 12px;
  height: 12px;
  vertical-align: -1px;
}

.tl-week,
.ru-grid {
  stroke: var(--color-border);
  stroke-width: 1;
}

.tl-week-label,
.tl-today-label,
.tl-target-label {
  font-size: 11px;
  fill: var(--color-text-muted);
}

.tl-row-band {
  fill: transparent;
}

.tl-row:nth-child(even) .tl-row-band {
  fill: color-mix(in srgb, var(--color-background) 60%, var(--color-surface));
}

.tl-row:hover .tl-row-band {
  fill: color-mix(in srgb, var(--color-accent) 6%, var(--color-surface));
}

.tl-label-number {
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-weight: 600;
  fill: var(--status-ink, var(--color-text));
}

.tl-label-name,
.tl-undated {
  fill: var(--color-text-muted);
}

.tl-label-link {
  cursor: pointer;
}

.tl-label-link:hover .tl-label-number,
.tl-label-link:focus-visible .tl-label-number {
  text-decoration: underline;
}

.tl-label-link:hover .tl-label-name {
  fill: var(--color-text);
}

.tl-lead {
  stroke: var(--color-text-muted);
  stroke-width: 2;
}

.tl-ordered {
  stroke: var(--color-text-muted);
  stroke-width: 2;
}

.tl-due {
  fill: var(--color-surface);
  stroke: var(--color-text);
  stroke-width: 1.5;
}

.tl-promise {
  fill: var(--color-surface);
  stroke: var(--status-on-time);
  stroke-width: 2;
}

/* Hollow and dashed, in no status colour: the forecast is a reading, the bar says whether it is late. */
.tl-forecast {
  fill: var(--color-surface);
  stroke: var(--color-text);
  stroke-width: 1.5;
  stroke-dasharray: 2.5 1.5;
}

.tl-bar {
  fill: var(--status-on-time);
  opacity: 0.85;
}

.tl-bar-at-risk {
  fill: var(--status-at-risk);
}

.tl-bar-overdue {
  fill: var(--status-overdue);
}

.tl-bar-late {
  fill: var(--status-complete);
  stroke: var(--status-overdue);
  stroke-width: 1;
}

.tl-receipt {
  fill: var(--status-received);
  stroke: var(--color-surface);
  stroke-width: 1;
}

.tl-receipt.inspection-released {
  fill: var(--status-complete);
}

.tl-receipt.inspection-rejected {
  fill: var(--status-overdue);
}

.tl-today,
.ru-today {
  stroke: var(--color-accent);
  stroke-width: 1.5;
}

.tl-today-label {
  fill: var(--color-accent);
  font-weight: 600;
}

.tl-target,
.ru-due {
  stroke: var(--color-navy);
  stroke-width: 1;
  stroke-dasharray: 4 3;
}

/* ==========================================================================
   Ramp-up
   ========================================================================== */

/* Target grey, actual in the status colour of what it draws, forecast dashed: the same three
   lines on the header and on every part. */
.ramp-up-header {
  padding: var(--space);
}

.ramp-up-header .section-heading {
  margin-top: 0;
}

.ramp-up-chart {
  display: block;
  width: 100%;
  height: auto;
  font-size: 11px;
  overflow: visible;
}

.ramp-up-header .ramp-up-chart {
  max-width: 1400px;
}

.ramp-up-note {
  margin: 6px 0 0;
  font-size: 13px;
}

.ramp-up-parts-heading {
  margin-top: calc(var(--space) * 2);
}

.ramp-up-parts-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px var(--space);
}

.ramp-up-parts-note {
  margin: 0 0 var(--space);
  color: var(--color-text-muted);
  font-size: 13px;
}

/* The parts list: the groups stacked, one row per part, the same fixed columns in every group
   so they line up down the page. */
.ramp-up-parts-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  justify-content: space-between;
  gap: 4px var(--space);
}

.ramp-up-range {
  margin: 0 0 0.5rem;
  color: var(--color-text-muted);
  font-size: 13px;
}

.ramp-up-parts-key {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0 var(--space);
}

.ramp-up-parts-legend {
  margin: 0 0 0.5rem;
}

/* The ramp-up's legends: each curve is in a status colour (the batch's or its part's), so the
   glyphs are neutral ink rather than one of the colours (phase 74). */
.legend-neutral .ru-actual,
.legend-neutral .ru-forecast {
  stroke: var(--color-text);
}

.legend-neutral .ru-dot {
  fill: var(--color-text);
}

.ramp-up-groups {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* What the find box hides stays hidden, whatever the layout says (the rows are a grid on a phone):
   two classes' weight beat the one-class display rules of the rows, groups and folds. */
.ramp-up-parts [hidden] {
  display: none;
}

/* A group is a card: its head on a grey bar, the rows below. */
.ramp-up-group {
  overflow: hidden;
}

.ramp-up-group-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px 10px;
  margin: 0;
  padding: 8px 12px;
  font-size: 14px;
  font-weight: 400;
  background: var(--color-background);
  border-bottom: var(--line);
}

.ramp-up-group-title {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 8px;
  font-weight: 600;
}

.ramp-up-group-meta {
  color: var(--color-text-muted);
  font-size: 13px;
}

.ramp-up-group-holds {
  color: var(--color-text);
  white-space: nowrap;
}

.ramp-up-group-size {
  margin-left: auto;
  color: var(--color-text-muted);
  font-size: 13px;
}

.ramp-up-group.is-complete > summary,
.ramp-up-fold > summary {
  cursor: pointer;
  color: var(--color-text-muted);
  font-size: 13px;
}

.ramp-up-group.is-complete > summary {
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding-left: 12px;
  background: var(--color-background);
}

.ramp-up-group.is-complete > summary .ramp-up-group-head {
  flex: 1;
  padding-left: 0;
  border-bottom: 0;
}

.ramp-up-group.is-complete[open] > summary {
  border-bottom: var(--line);
}

.ramp-up-fold > summary {
  padding: 6px 12px;
}

.ramp-up-fold[open] > summary {
  border-bottom: var(--line);
}

.ramp-up-list {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  font-size: 13px;
}

/* Fixed columns that hold from 1400 px to 2500 px: the curve (a 122 px sparkline) and the way to
   the tree in pixels, status, maker and pieces in shares of the width, the status never
   narrower than its longest sentence needs to break once. The part takes what is left, about
   30 % on a wide screen: a fixed 30 % as well would oversubscribe a 1400 px table, and the
   browser would squeeze the status. */
.ru-col-part { width: auto; }

.ru-col-spark { width: 140px; }

.ru-col-status { width: 20%; }

.ru-col-chain { width: 20%; }

.ru-col-pieces { width: 18%; }

.ru-col-open { width: 120px; }

/* A col ignores max(): below 1360 px, where 20 % drops under 260 px, the status holds 260 px. */
@media (max-width: 1359px) {
  .ru-col-status { width: 260px; }
}

.ramp-up-list th {
  padding: 6px 10px;
  color: var(--color-text-muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-align: left;
  text-transform: uppercase;
  border-bottom: var(--line);
}

.ramp-up-row td {
  padding: 6px 10px;
  vertical-align: middle;
  white-space: normal;
  overflow-wrap: anywhere;
  border-bottom: var(--line);
}

/* The badge wraps inside its cell and never runs into the maker. */
.ramp-up-row .ru-status .status-badge {
  max-width: 100%;
  white-space: normal;
  line-height: 1.3;
}

.ramp-up-list tbody tr:last-child td {
  border-bottom: 0;
}

/* Indented by the part's level in its group, 18 px a level, a corner in front of the number;
   the number stays whole, the name wraps. */
.ramp-up-row .ru-part {
  padding-left: calc(10px + var(--level, 0) * 18px);
}

.ramp-up-row .ru-part .part-number {
  white-space: nowrap;
}

.ramp-up-row:not([data-depth="0"]) .ru-part .part-number::before {
  content: "└ ";
  color: var(--color-text-muted);
  font-weight: 400;
}

.ru-name {
  margin-left: 6px;
  color: var(--color-text-muted);
}

/* Pieces and dates wrap rather than lose the due date. */
.ru-pieces {
  color: var(--color-text-muted);
}

.ru-pieces .forecast-date {
  display: inline;
  font-size: inherit;
}

.ru-open {
  white-space: nowrap;
}

.ramp-up-small {
  display: block;
  width: 122px;
  height: 32px;
}

.ramp-up-small .ru-target,
.ramp-up-small .ru-forecast {
  stroke-width: 1.25;
}

.ramp-up-small .ru-actual {
  stroke-width: 1.75;
}

.ramp-up-small .ru-forecast {
  stroke-dasharray: 3 2;
}

.ramp-up-small .ru-today,
.ramp-up-small .ru-due {
  stroke-width: 1;
}

.ramp-up-undrawn {
  color: var(--color-text-muted);
  font-size: 11px;
}

/* On a phone every row is a card: number and status, then the name, then pieces, dates and
   the way to the tree; the curve and the maker give way. */
@media (max-width: 699px) {
  .ramp-up-list thead,
  .ramp-up-list colgroup,
  .ramp-up-row .ru-chain,
  .ramp-up-row .ru-spark {
    display: none;
  }

  .ramp-up-list,
  .ramp-up-list tbody {
    display: block;
  }

  .ramp-up-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 4px 8px;
    align-items: center;
    padding: 8px 12px 8px calc(12px + var(--level, 0) * 14px);
    border-bottom: var(--line);
  }

  .ramp-up-list tbody tr:last-child {
    border-bottom: 0;
  }

  .ramp-up-row .ru-part,
  .ramp-up-row .ru-status,
  .ramp-up-row .ru-pieces,
  .ramp-up-row .ru-open {
    display: block;
    padding: 0;
    border: 0;
  }

  .ramp-up-row .ru-part {
    white-space: normal;
  }

  .ru-name {
    display: block;
    margin-left: 0;
  }

  .ru-pieces {
    grid-column: 1 / -1;
    white-space: normal;
  }

  .ru-open {
    grid-column: 1 / -1;
  }

  .ramp-up-find,
  .ramp-up-find label,
  .ramp-up-parts .list-filters input[type="search"] {
    width: 100%;
  }
}

.ru-week {
  stroke: var(--color-text-muted);
  stroke-width: 1;
}

.ru-axis-label,
.ru-marker-label {
  fill: var(--color-text-muted);
}

/* Like the timeline's Today label, but kept here: it is also a .ru-marker-label and must come
   after that rule to be blue. */
.ru-today-label {
  fill: var(--color-accent);
  font-weight: 600;
}

.ru-target {
  fill: none;
  stroke: var(--status-unplanned);
  stroke-width: 2;
}

.ru-actual {
  fill: none;
  stroke: var(--status-color, var(--status-on-time));
  stroke-width: 2.5;
  stroke-linejoin: round;
}

.ru-dot {
  fill: var(--status-color, var(--status-on-time));
  stroke: var(--color-surface);
  stroke-width: 1;
}

.ru-forecast {
  fill: none;
  stroke: var(--status-color, var(--status-on-time));
  stroke-width: 2;
  stroke-dasharray: 5 4;
}

.ru-forecast-end {
  fill: var(--color-surface);
  stroke: var(--status-color, var(--status-on-time));
  stroke-width: 1.5;
}

.legend-glyph-wide {
  width: 16px;
}

/* ==========================================================================
   Weekly report
   The manufacturer's page, /report/:token and My deliveries.
   ========================================================================== */

.week-switch {
  display: flex;
  gap: 6px;
}

.week-switch a[aria-current="page"] {
  color: var(--color-accent-dark);
  background: color-mix(in srgb, var(--color-accent) 10%, white);
  border-color: color-mix(in srgb, var(--color-accent) 40%, white);
}

/* "Fill in your part number": the provisional parts a company makes, above the weekly rows. */
.placeholders {
  margin-bottom: calc(var(--space) * 2);
}

.placeholders h2 {
  margin: 0 0 4px;
  font-size: 17px;
}

.placeholders > .field-hint {
  max-width: 80ch;
  margin-bottom: 10px;
}

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

.placeholder-line {
  display: block;
}

.placeholder-form {
  display: flex;
  gap: 8px;
  align-items: center;
}

.placeholder-form input[type="text"] {
  width: 220px;
}

.placeholder-errors {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--color-danger);
}

.weekly-report-lead {
  max-width: 80ch;
  margin: 0 0 var(--space);
  color: var(--color-text-muted);
}

.weekly-report-name {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-width: 280px;
  margin-bottom: var(--space);
  font-weight: 500;
}

.weekly-report-table td {
  vertical-align: middle;
}

.weekly-report-part-name {
  display: block;
  color: var(--color-text-muted);
  font-size: 13px;
}

.weekly-report-project-row th {
  padding-top: 14px;
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text);
  white-space: normal;
  background: var(--color-surface-muted);
}

.weekly-report-receiver {
  max-width: 240px;
}

/* How a batch's rows stand, after its title: "3 open · 2 all shipped · 4 done". */
.weekly-report-counts {
  margin-left: 8px;
  font-weight: 400;
  font-size: 13px;
  color: var(--color-text-muted);
}

.weekly-report-next {
  min-width: 160px;
  max-width: 260px;
  font-size: 14px;
}

/* Shipped in full: the receiver's turn. Muted, the fields stay for a rejection. */
.weekly-report-table tr.is-muted td {
  color: var(--color-text-muted);
}

.weekly-report-done-row > td {
  padding-top: 4px;
  padding-bottom: 8px;
}

.weekly-report-done summary {
  cursor: pointer;
  color: var(--color-text-muted);
  font-size: 14px;
}

.weekly-report-done-table {
  margin-top: 6px;
  color: var(--color-text-muted);
}

.weekly-report-table input,
.weekly-report-table select {
  padding: 6px 8px;
  font-size: 14px;
}

/* The one field filled every week: wide enough for four digits, right-aligned like the counts. */
.quantity-column {
  width: 1%;
}

.quantity-column input {
  width: 90px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.weekly-report-note {
  min-width: 180px;
}

.weekly-report-note input {
  width: 100%;
}

/* What the last Send said, under the note: the report was kept, the fields are for the next one.
   In a new week it carries the last note too; a long one wraps instead of widening the column. */
.weekly-report-last {
  display: block;
  max-width: 280px;
  margin-top: 4px;
  color: var(--color-text-muted);
  font-size: 12px;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.weekly-report-table tr.has-errors td {
  background: color-mix(in srgb, var(--color-error-bg) 60%, white);
}

.weekly-report-errors td {
  color: var(--color-danger);
  background: var(--color-error-bg);
  font-size: 14px;
}

/* The bar with the tally and Send stays at the bottom of the window while the table scrolls.
   Sticky inside the form, never fixed to the viewport: iOS Safari resizes the viewport when its
   toolbar hides, and a fixed bar went with it (phase 71a). The bar keeps its place in the flow,
   so the last card ends above it; below the home indicator it pads by the safe-area inset
   (the weekly report layout sets viewport-fit=cover). */
.weekly-report-actions {
  position: sticky;
  bottom: 0;
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  margin-top: var(--space);
  padding: 12px var(--space);
  padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  box-shadow: var(--shadow-bar);
}

/* A field reached by Tab, a jump to a changed row or the mail's autofocus scrolls clear of the bar. */
html:has(.weekly-report-actions) {
  scroll-padding-bottom: 160px;
}

.weekly-report-tally {
  font-weight: 600;
  color: var(--color-text-muted);
  font-variant-numeric: tabular-nums;
}

.weekly-report-tally.has-changes {
  color: var(--color-accent);
}

/* Changed while typing: a blue edge on the row, the field itself framed. */
.weekly-report-table tr.is-changed td {
  background: color-mix(in srgb, var(--color-accent) 6%, white);
}

.weekly-report-table tr.is-changed td:first-child {
  box-shadow: inset 4px 0 0 var(--color-accent);
}

.weekly-report-table input.is-changed,
.weekly-report-table select.is-changed {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 1px var(--color-accent);
  font-weight: 600;
}

/* Changed by the last Send: a green edge, until the next one. */
.weekly-report-table tr.is-just-sent td {
  background: var(--color-success-bg);
}

.weekly-report-table tr.is-just-sent td:first-child {
  box-shadow: inset 4px 0 0 var(--color-success-text);
}

.weekly-report-sent {
  margin: 0 0 var(--space);
  padding: 10px 14px;
  background: var(--color-success-bg);
  border-left: 4px solid var(--color-success-text);
  border-radius: var(--radius);
  font-size: 14px;
}

.weekly-report-sent a,
.weekly-report-sent span {
  font-size: 13px;
}

/* The dot's sentence in words: the dot's tooltip on a wide screen, a line of the card on a phone. */
.weekly-report-sentence {
  display: none;
}

/* The supplier's Monday on a phone (under 700 px): every row a card — part number and name, the
   dot with its sentence, Next, then the fields stacked under their labels (data-label on the
   cells); the batch heads its cards with its counts; the Send bar stays at the bottom. One
   markup for desktop and phone, CSS only. */
@media (max-width: 699px) {
  .app-header,
  .page-header:has(.week-switch) {
    flex-wrap: wrap;
  }

  .weekly-report-name {
    max-width: none;
  }

  .weekly-report-name input,
  .weekly-report-table input,
  .weekly-report-table select,
  .placeholders-table input {
    box-sizing: border-box;
    width: 100%;
    min-height: 44px;
    font-size: 16px;
  }

  .weekly-report-table,
  .weekly-report-table > tbody,
  .weekly-report-table > tbody > tr,
  .placeholders-table,
  .placeholders-table > tbody {
    display: block;
    background: transparent;
    border: none;
    border-radius: 0;
    overflow: visible;
  }

  .weekly-report-table > thead,
  .placeholders-table > thead {
    display: none;
  }

  /* The batch heads its cards: "Gearbox · Prototype  3 open · 2 all shipped". */
  .weekly-report-project-row th {
    display: block;
    padding: 16px 0 8px;
    font-size: 15px;
    background: transparent;
    border: none;
  }

  .weekly-report-counts {
    display: block;
    margin-left: 0;
  }

  .weekly-report-table > tbody > tr[id^="weekly_report_row_"],
  .placeholders-table > tbody > tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 12px;
    margin-bottom: 12px;
    padding: 12px;
    background: var(--color-surface);
    border: var(--line);
    border-radius: var(--radius);
  }

  .weekly-report-table > tbody > tr[id^="weekly_report_row_"] {
    grid-template-areas:
      "part part"
      "receiver receiver"
      "next next"
      "week count"
      "promised due"
      "reason reason"
      "note note";
  }

  .weekly-report-table > tbody > tr > td,
  .placeholders-table > tbody > tr > td {
    display: block;
    width: auto;
    min-width: 0;
    max-width: none;
    padding: 0;
    text-align: left;
    white-space: normal;
    background: transparent;
    border: none;
    box-shadow: none;
  }

  .placeholders-table > tbody > tr > td {
    grid-column: 1 / -1;
  }

  .weekly-report-table td[data-label]::before,
  .placeholders-table td[data-label]::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 2px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--color-text-muted);
  }

  /* Number, tag, name; below them the dot with its sentence. */
  .weekly-report-table td.weekly-report-part {
    grid-area: part;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 2px 6px;
  }

  .weekly-report-part .part-number { order: 1; }
  .weekly-report-part .provisional-tag { order: 2; }
  .weekly-report-part .weekly-report-part-name { order: 3; flex-basis: 100%; }
  .weekly-report-part .status-dot { order: 4; margin-right: 0; }

  .weekly-report-part .weekly-report-sentence {
    order: 5;
    display: inline;
    flex: 1;
    font-size: 14px;
  }

  .weekly-report-next {
    grid-area: next;
    font-size: 15px;
    font-weight: 600;
  }

  .weekly-report-table .quantity-column { grid-area: week; }
  .weekly-report-table .count-column { grid-area: count; font-size: 15px; }
  .weekly-report-promised { grid-area: promised; min-width: 0; }
  .weekly-report-due { grid-area: due; }

  /* Promised and Due side by side: the date field keeps its natural width inside its column
     (iOS draws a date input wider than the cell unless told otherwise), Due's date sits on the
     field's line. */
  .weekly-report-table .weekly-report-promised input {
    display: block;
    -webkit-appearance: none;
    appearance: none;
    width: 150px;
    max-width: 100%;
    min-width: 0;
    text-align: left;
  }

  .weekly-report-table .weekly-report-due {
    line-height: 44px;
  }

  .weekly-report-table .weekly-report-due::before {
    line-height: 1.5;
  }
  .weekly-report-reason { grid-area: reason; }
  .weekly-report-table .weekly-report-note { grid-area: note; min-width: 0; }
  .weekly-report-table .weekly-report-last { max-width: none; }
  .weekly-report-table .weekly-report-receiver { grid-area: receiver; font-size: 14px; }

  .weekly-report-table .quantity-column input {
    font-size: 20px;
    font-weight: 600;
    text-align: left;
  }

  /* Changed while typing, changed by the last Send, refused: the card carries the mark. */
  .weekly-report-table tr.is-changed td,
  .weekly-report-table tr.is-changed td:first-child,
  .weekly-report-table tr.is-just-sent td,
  .weekly-report-table tr.is-just-sent td:first-child,
  .weekly-report-table tr.has-errors td {
    background: transparent;
    box-shadow: none;
  }

  .weekly-report-table > tbody > tr.is-changed {
    background: color-mix(in srgb, var(--color-accent) 6%, white);
    box-shadow: inset 4px 0 0 var(--color-accent);
  }

  .weekly-report-table > tbody > tr.is-just-sent {
    background: var(--color-success-bg);
    box-shadow: inset 4px 0 0 var(--color-success-text);
  }

  .weekly-report-table > tbody > tr.has-errors,
  .placeholders-table > tbody > tr.has-errors {
    background: color-mix(in srgb, var(--color-error-bg) 60%, white);
  }

  .weekly-report-errors td,
  .weekly-report-done-row > td {
    display: block;
    border: none;
  }

  .weekly-report-errors td {
    margin: -8px 0 12px;
    border-radius: var(--radius);
  }

  .weekly-report-done-row > td {
    padding: 0 0 8px;
    background: transparent;
  }

  /* The done ones, folded: a short line each, the labels inline. */
  .weekly-report-done-table,
  .weekly-report-done-table tbody,
  .weekly-report-done-table tr,
  .weekly-report-done-table td {
    display: block;
  }

  .weekly-report-done-table tr {
    padding: 8px 12px;
    border-bottom: var(--line);
  }

  .weekly-report-done-table tr:last-child {
    border-bottom: none;
  }

  .weekly-report-done-table td {
    padding: 2px 0;
    text-align: left;
    border: none;
  }

  .weekly-report-done-table td[data-label]::before {
    display: inline;
    margin-right: 6px;
  }

  .placeholder-form input[type="text"] {
    flex: 1;
    width: auto;
  }

  /* Tally and Send on one line, "Nothing shipped" below them; the due-date hint is in the lead
     and the notice after Send. */
  .weekly-report-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    padding: 10px 12px;
  }

  .weekly-report-actions .button {
    min-height: 44px;
  }

  .weekly-report-nothing {
    grid-column: 1 / -1;
    white-space: normal;
  }

  .weekly-report-actions .field-hint {
    display: none;
  }
}

.weekly-report-table .part-number {
  white-space: nowrap;
}

/* ==========================================================================
   Today
   The home page.
   ========================================================================== */

.upcoming {
  margin-top: calc(var(--space) * 2);
}

/* Today: three numbers, each a sentence and a link; the colour is the status the number counts
   (overdue red, on its way the shipped colour, nothing to do green), none for the report. */
.today-numbers {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: var(--space);
  margin-bottom: calc(var(--space) * 1.5);
}

.today-number {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: var(--space) calc(var(--space) * 1.25);
  color: var(--color-text);
  text-decoration: none;
  border-left: 6px solid var(--status-color, var(--color-border));
}

.today-number:hover {
  border-color: var(--color-accent);
  border-left-color: var(--status-color, var(--color-accent));
}

.today-count {
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1.2;
  color: var(--status-ink, var(--color-text));
}

.today-projects {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 14px;
  margin-bottom: var(--space);
  padding: 12px calc(var(--space) * 1.25);
  color: var(--color-text);
  text-decoration: none;
}

.today-projects:hover {
  border-color: var(--color-accent);
}

.today-projects-title {
  font-weight: 700;
}

.today-projects-title,
.today-sentence {
  font-size: 1.1rem;
}

/* "! 2 red · ▲ 1 amber · ✓ 0 green": each light beside its words on one centre line. */
.today-projects-counts {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 8px;
  font-size: 1.1rem;
  font-weight: 600;
}

.light-count {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.light-count-separator {
  color: var(--color-text-muted);
}

.today-sentence {
  color: var(--color-accent);
  font-weight: 500;
}

.today-table .status-dot {
  margin-right: 8px;
}

/* ==========================================================================
   Guide, help, tooltips and tour
   ========================================================================== */

/* Tooltips ---------------------------------------------------------------- */

/* One floating element, moved by the tooltip controller; the arrow follows the anchor's
   centre even when the box was pushed inside the viewport. */
.tooltip {
  --arrow-offset: 50%;
  position: fixed;
  z-index: 100;
  max-width: 280px;
  padding: 7px 11px;
  font-size: 13px;
  line-height: 1.4;
  color: var(--color-surface);
  background: var(--color-text);
  border-radius: var(--radius);
  box-shadow: var(--shadow-popover);
  pointer-events: none;
  animation: tooltip-in 120ms ease-out;
}

.tooltip::before {
  content: "";
  position: absolute;
  top: -5px;
  left: var(--arrow-offset);
  width: 10px;
  height: 10px;
  background: inherit;
  transform: translateX(-50%) rotate(45deg);
}

.tooltip.is-above::before {
  top: auto;
  bottom: -5px;
}

@keyframes tooltip-in {
  from {
    opacity: 0;
    transform: translateY(-3px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.tooltip.is-above {
  animation-name: tooltip-in-above;
}

@keyframes tooltip-in-above {
  from {
    opacity: 0;
    transform: translateY(3px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* Tour -------------------------------------------------------------------- */

/* The card of the current step: fixed in a corner, above everything, and on the editor pages
   on the left, so it never covers the panel the step talks about. */
.tour-card {
  position: fixed;
  right: var(--space);
  bottom: var(--space);
  z-index: 120;
  width: 360px;
  padding: 14px 16px 12px;
  border-top: 3px solid var(--color-tour);
  box-shadow: var(--shadow-card);
}

.tour-card[data-tour-side="left"] {
  right: auto;
  left: var(--space);
}

.tour-kind {
  margin: 0 0 2px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: color-mix(in srgb, var(--color-tour) 75%, var(--color-text));
}

.tour-title {
  margin: 0 0 6px;
  font-size: 17px;
}

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

/* Only shown when the step's element is not on this page. */
.tour-missing {
  margin: 8px 0 0;
  font-size: 13px;
}

.tour-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: var(--line);
}

.tour-counter {
  font-size: 13px;
  color: var(--color-text-muted);
}

.tour-buttons {
  display: flex;
  gap: 6px;
}

/* The element of the current step, marked like a selected node: its own frame plus a halo. */
.is-tour-target {
  outline: 3px solid var(--color-tour);
  outline-offset: 3px;
  border-radius: var(--radius);
  box-shadow: 0 0 0 7px color-mix(in srgb, var(--color-tour) 22%, transparent);
}

/* Guide and context help -------------------------------------------------- */

.guide-lead {
  max-width: 62ch;
  margin: 0 0 calc(var(--space) * 1.5);
  font-size: 17px;
  line-height: 1.55;
}

.guide-section {
  margin-bottom: calc(var(--space) * 2);
}

.guide-terms {
  display: grid;
  grid-template-columns: 210px minmax(0, 1fr);
  gap: 10px var(--space);
  max-width: 900px;
  margin: 0;
}

.guide-terms dt {
  font-weight: 600;
}

.guide-terms dd {
  margin: 0;
  color: var(--color-text);
}

/* Phase 64g: a longer section reads as a lead sentence, a term list or steps, and a closing
   line. Inside a term of "What the words mean" its list is narrower than the page's. */
.guide-summary {
  margin: 0 0 8px;
}

.guide-aside {
  margin: 8px 0 0;
}

.guide-terms dd > .guide-terms {
  grid-template-columns: 180px minmax(0, 1fr);
  gap: 6px var(--space);
}

.guide-caption + .guide-terms {
  margin-top: 8px;
}

.guide-sequence {
  margin: 0;
  padding-left: 20px;
}

.guide-steps .guide-sequence li {
  margin-bottom: 4px;
}

/* The sketch: the same shapes as the canvas, drawn from nothing, so it cannot go stale. */
.guide-sketch {
  display: block;
  width: 100%;
  max-width: 820px;
  height: auto;
}

.gs-node text {
  font-size: 15px;
  font-weight: 600;
  text-anchor: middle;
  fill: var(--color-text);
}

.gs-node .gs-sub {
  font-size: 13px;
  font-weight: 400;
  fill: var(--color-text-muted);
}

.gs-root rect {
  fill: color-mix(in srgb, var(--color-accent) 8%, var(--color-surface));
  stroke: var(--color-accent);
}

.gs-top rect {
  stroke: var(--color-tour);
  stroke-width: 2.5;
}

.gs-edge {
  fill: none;
  stroke: var(--color-border);
  stroke-width: 1.5;
}

.gs-branch {
  fill: color-mix(in srgb, var(--color-tour) 7%, transparent);
  stroke: var(--color-tour);
  stroke-width: 1.5;
  stroke-dasharray: 6 5;
}

.gs-branch-label,
.gs-note {
  font-size: 13px;
  text-anchor: middle;
  fill: var(--color-text-muted);
}

.gs-note {
  font-style: italic;
}

.guide-caption {
  max-width: 62ch;
  margin: 10px 0 0;
  color: var(--color-text-muted);
}

.guide-steps {
  max-width: 900px;
  margin: 0;
  padding-left: 22px;
}

.guide-steps li {
  margin-bottom: var(--space);
}

.guide-steps h3 {
  margin: 0 0 2px;
  font-size: 16px;
}

.guide-steps p {
  margin: 0;
}

.guide-closing {
  padding-top: var(--space);
  border-top: var(--line);
  color: var(--color-text-muted);
}

/* Context help: the "?" beside a heading and the guide section it opens (phase 60). Neutral
   grey — colour means delivery status. The box is fixed at its place in the flow (no top or
   left), so no scrolling table or canvas clips it; it closes on a scroll. */

.help {
  position: relative;
  display: inline-block;
  margin-left: 4px;
  font-size: 13px;
  font-weight: 400;
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  vertical-align: 1px;
  white-space: normal;
  pointer-events: auto;
}

.help-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 17px;
  height: 17px;
  padding: 0;
  font: inherit;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  color: var(--color-text-muted);
  background: var(--color-surface);
  border: var(--line);
  border-radius: 50%;
  cursor: pointer;
}

.help-button::before {
  content: "?";
}

.help-button:hover,
.help-button:focus-visible,
.help-button[aria-expanded="true"] {
  color: var(--color-text);
  border-color: var(--color-text-muted);
}

.help-box {
  position: fixed;
  z-index: 90;
  width: min(400px, calc(100vw - 32px));
  margin-top: 6px;
  padding: 12px 14px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--color-text);
  text-align: left;
  box-shadow: var(--shadow-popover);
  cursor: auto;
  -webkit-user-select: text;
  user-select: text;
}

.help.is-above .help-box {
  translate: 0 calc(-100% - 17px - 12px);
}

.help-title {
  margin: 0 0 4px;
  font-size: 14px;
  font-weight: 600;
}

.help-text {
  margin: 0;
}

.help-box turbo-frame:empty::before {
  content: "Loading …";
  color: var(--color-text-muted);
}

.help-more {
  margin: 8px 0 0;
  font-size: 12px;
}

/* The box's own sections (how to read a box) stack their terms in the narrow box. */
.help-box .guide-terms {
  grid-template-columns: minmax(0, 1fr);
  gap: 0;
}

.help-box .guide-terms dd {
  margin-bottom: 6px;
}
