/* The theme: every value. Swap this folder to swap the theme. *//* Colors: design/foundations/colors.md. */
:root {
  /* Text */
  --color-ink: #041122;
  --color-ink-soft: #4d5662;
  --color-ink-dim: #94979c;

  /* Surfaces */
  --color-surface: #ffffff;
  --color-panel: #f3f4f6;
  --color-canvas: #edeff2;

  /* Lines */
  --color-line: #d7dbe1;
  --color-line-soft: #e3e6ea;
  --color-control-line: #c9ced6;

  /* Accent */
  --color-accent: #df6f32;
  --color-accent-light: #e8783a;
  --color-accent-dark: #da6a2e;
  --color-accent-line: #c45e26;
  --color-accent-ink: #b84e1a;

  /* Brand */
  --color-brand: #0c3c75;
  --color-brand-tint: #e6edf6;

  /* Status */
  --color-error: #d92d20;
  --color-green: #1f9d55;
  --color-green-ink: #14713c;
  --color-green-tint: #e3f5ea;
  --color-amber: #f2a900;
  --color-amber-ink: #8a5a00;
  --color-amber-tint: #fff4d6;
  --color-red: #ff3200;
  --color-red-ink: #b42300;
  --color-red-tint: #ffe9e3;

  /* Text on accent, ink, red, green and brand fills */
  --color-on-fill: #ffffff;
}
/* Motion: durations and easings. */
:root {
  --duration-hover: 200ms;
  --duration-sm: 100ms;
  --duration-md: 400ms;
  /* prettier-ignore */
  --ease-custom: linear(
    0, 0.002, 0.01 3.6%, 0.034, 0.074 9.1%, 0.128 11.4%, 0.194 13.4%, 0.271 15%,
    0.344 16.1%, 0.544, 0.66 20.6%, 0.717 22.4%, 0.765 24.6%, 0.808 27.3%,
    0.845 30.4%, 0.883 35.1%, 0.916 40.6%, 0.942 47.2%, 0.963 55%, 0.979 64%,
    0.991 74.4%, 0.998 86.4%, 1
  );
}
/* Print: design/components/print.md. Paper is sized in inches, and the type
   on a tag in points, because the stock is. */
:root {
  --color-print: black;
  --color-paper: white;
  --height-print-toolbar: 4rem;

  /* Printed work order */
  --width-print-page: 7.5in;
  --padding-print-page: 0.5in;
  --space-print-section: 0.25in;
  --width-print-column: 0.6in;
  --width-print-logo: 1.6in;
  --height-print-logo: 0.8in;
  --space-print-photos: 0.15in;

  /* Tag */
  --space-tag-hole: 0.45in;
  --padding-tag: 0.12in;
  --size-tag-qr: 1.4in;
  --text-tag-label-size: 24pt;
  --text-tag-label-weight: 800;
}
/* Shop floor: design/foundations/shop-floor.md. */
:root {
  --height-floor-header: 4rem;
  --height-tap-target: 2.75rem;
  --height-station-header: 2.75rem;
  --size-station-icon: 1.25rem;
  --text-station-name-size: 1.25rem;
  --text-station-name-weight: 700;
  --line-photo-card: 0.125rem;
  --height-floor-toolbar: 3.75rem;
  --width-floor-search: 24rem;
  --height-segmented-large: 3.75rem;
  --size-live-dot: 0.375rem;

  /* Board */
  --width-board-column: 21.5rem;
  --width-board-column-folded: 4.5rem;
  --line-board-drop: 0.125rem;

  /* Card action bar */
  --width-card-bar: 80rem;

  /* Photo card */
  --ratio-photo-card: 16 / 9;
  --size-photo-card-icon: 1.5rem;
  --size-photo-card-select: 1.75rem;
  --opacity-dragging: 35%;

  /* Stepper */
  --size-stepper-button: 3.75rem;
  /* Floor modals */
  --width-modal-floor: 30rem;
  --width-modal-wide: 61.25rem;

  /* Checker */
  --width-checker-queue: 20rem;
  --height-checker-bar: 3.5rem;
  --line-queue-current: 0.1875rem;
  --size-checker-checkbox: 1.75rem;
  --width-checker-photo: 7.5rem;
  --height-checker-photo: 5.625rem;
  --width-weights-field: 7.5rem;
  --width-yard-option: 5rem;

  /* Switch */
  --width-switch: 3rem;
  --height-switch: 1.75rem;
  --size-switch-knob: 1.375rem;

  /* Scanner */
  --line-scanner-frame: 0.1875rem;
  /* Photo viewer */
  --size-viewer-button: 3.5rem;
  --size-viewer-button-icon: 2rem;
  --width-viewer-nav: 7rem;
  --size-viewer-nav-icon: 2.5rem;
  --size-viewer-thumb: 4rem;
  --line-viewer-current: 0.1875rem;
  --opacity-viewer-thumb: 60%;
}
/* Sizes the component files give. */
:root {
  /* Page */
  --width-page: 76rem;

  /* Icon: as tall as the text beside it, unless a component says otherwise */
  --size-icon-default: 1.125em;

  /* Logo */
  --size-logo-mark: 2rem;
  --size-logo-mark-large: 2.5rem;

  /* Nav */
  --height-nav: 3.75rem;
  --line-nav-active: 0.1875rem;
  --size-nav-caret: 1.125rem;

  /* Avatar */
  --size-avatar: 2.25rem;

  /* Page header */
  --width-page-header-search: 18.75rem;

  /* Button. Heights and icons are in em, so they follow the label size. */
  --height-button: 2.75em;
  --size-button-icon: 1.25em;
  --height-button-small: 2.29em;
  --size-button-icon-small: 1.14em;
  --height-button-large: 3.75em;
  --padding-button-large: 1.5rem;

  /* Menu */
  --width-menu: 11.875rem;
  --height-menu-item: 2.25rem;
  --size-menu-icon: 1rem;

  /* Card. The header row is as tall as a small button. */
  --height-card-header: 2rem;

  /* Table */
  --height-table-band: 2.75rem;

  /* Detail list */
  --width-detail-list-label: 8rem;

  /* Field */
  --height-field: 3.5rem;
  --height-field-textarea: 6.5rem;
  --height-field-search: 2.75rem;
  --height-field-inline: 2.75rem;
  --size-field-icon: 1.25rem;

  /* Select options */
  --height-option: 2.25rem;
  --height-option-touch: 4rem;
  --height-option-list: 18rem;
  --size-option-icon: 1rem;
  --height-option-search: 3.75rem;
  --size-option-clear: 1.75rem;
  --width-option-grabber: 2.5rem;
  --height-option-grabber: 0.3125rem;

  /* Checkbox */
  --size-checkbox: 1.25rem;
  --size-checkbox-mark: 0.875rem;

  /* Form and modal */
  --width-form: 30rem;
  --width-modal: 26.25rem;
  --offset-modal: 10rem;

  /* Badge, flag, due */
  --height-badge: 1.375rem;
  --height-flag: 1.5rem;
  --size-flag-icon: 0.875rem;
  --height-due: 1.5rem;

  /* Station progress */
  --size-station-progress-cell: 1.125rem;
  --size-station-progress-icon: 0.875rem;
  --height-station-progress-bubble: 1rem;
  --width-station-progress-pointer: 0.375rem;
  --height-station-progress-pointer: 0.25rem;
  --height-station-progress-strip: 4.5rem;
  --size-station-progress-strip-icon: 1rem;

  /* Callout */
  --line-callout: 0.125rem;
  --size-callout-icon: 2rem;
  --padding-callout-start: 1.625rem;
  --gap-callout: 1.3125rem;

  /* Toast */
  --height-toast: 2.75rem;
  --size-toast-icon: 1.25rem;

  /* Settings */
  --width-settings-nav: 11.875rem;
  --height-settings-nav-item: 2.25rem;
  --line-settings-nav-active: 0.1875rem;
  --height-settings-nav-active: 1.125rem;

  /* Editable row */
  --width-editable-row-field: 13.125rem;
  --size-editable-row-mark: 0.875rem;

  /* Row menu trigger */
  --size-menu-trigger: 2.75rem;
  --size-menu-trigger-icon: 1.25rem;

  /* Tile and count */
  --height-tile: 5.875rem;
  --size-tile-icon: 1.5rem;
  --line-tile-state: 0.125rem;

  /* Sign in */
  --width-auth: 22.5rem;
  --size-auth-qr: 12rem;

  /* Activity */
  --size-activity-dot: 0.375rem;

  /* Thumb */
  --width-thumb: 3.5rem;
  --height-thumb: 2.5rem;
  --size-thumb-icon: 1rem;
  --width-thumb-large: 4.5rem;
  --height-thumb-large: 3.25rem;

  /* Work order card */
  --height-work-order-card-photos: 10rem;
  --size-work-order-card-photo-icon: 1.5rem;
  --height-work-order-card-count: 1.5rem;

  /* Fact card */
  --width-fact-card-due: 14.375rem;

  /* Line grid */
  --height-line-grid-header: 2.25rem;
  --height-line-grid-row: 2.75rem;
  --size-line-grid-icon: 1.25rem;
  --width-rate-override: 20rem;
  --width-line-grid-options: 26rem;

  /* Camera */
  --height-camera-bar: 4rem;
  --size-camera-shutter: 4.5rem;
  --line-camera-ring: 0.3125rem;
  --size-camera-thumb: 4rem;
  --size-camera-thumb-remove: 1.5rem;
  --size-camera-thumb-icon: 0.75rem;
}
/* Spacing: design/foundations/spacing.md. */
:root {--space-3xs: clamp(0.25rem, 0.25rem + 0vi, 0.25rem);--space-2xs: clamp(0.375rem, 0.3435rem + 0.1342vi, 0.4375rem);--space-xs: clamp(0.6875rem, 0.6875rem + 0vi, 0.6875rem);--space-s: clamp(1.0625rem, 1.031rem + 0.1342vi, 1.125rem);--space-m: clamp(1.75rem, 1.6871rem + 0.2685vi, 1.875rem);--space-l: clamp(2.8125rem, 2.7496rem + 0.2685vi, 2.9375rem);--space-xl: clamp(4.5rem, 4.3742rem + 0.5369vi, 4.75rem);--space-2xl: clamp(7.3125rem, 7.1237rem + 0.8054vi, 7.6875rem);--space-3xl: clamp(11.8125rem, 11.4664rem + 1.4765vi, 12.5rem);--space-3xs-2xs: clamp(0.25rem, 0.1556rem + 0.4027vi, 0.4375rem);--space-2xs-xs: clamp(0.375rem, 0.2177rem + 0.6711vi, 0.6875rem);--space-xs-s: clamp(0.6875rem, 0.4673rem + 0.9396vi, 1.125rem);--space-s-m: clamp(1.0625rem, 0.6535rem + 1.745vi, 1.875rem);--space-m-l: clamp(1.75rem, 1.1523rem + 2.5503vi, 2.9375rem);--space-l-xl: clamp(2.8125rem, 1.8372rem + 4.1611vi, 4.75rem);--space-xl-2xl: clamp(4.5rem, 2.8956rem + 6.8456vi, 7.6875rem);--space-2xl-3xl: clamp(7.3125rem, 4.7013rem + 11.1409vi, 12.5rem);--space-xs-m: clamp(0.6875rem, 0.0898rem + 2.5503vi, 1.875rem);--space-s-l: clamp(1.0625rem, 0.1187rem + 4.0268vi, 2.9375rem);--space-s-2xl: clamp(1.0625rem, -2.2722rem + 14.2282vi, 7.6875rem);

  /* Gutters */
  --space-g: var(--space-s-m);
  --space-g-half: calc(var(--space-g) / 2);

  /* Flow */
  --flow-space: 1.5em;

  /* Named spaces */
  --space-section: var(--space-m);
  --space-page-top: var(--space-m);
  --space-page-bottom: var(--space-l);
}
/* Surfaces: design/foundations/surfaces.md. */
:root {
  /* Background. The tile file is in public/. */
  --page-background-image: url(/spangle-tile.svg);
  --page-background-size: 30rem;
  --page-background-opacity: 60%;

  /* Shapes */
  --radius-soft: 0.25rem;
  --radius-pill: 999rem;
  --radius-circle: 50%;
  --radius-square: 0;
  --cut-angled: 0.75rem;

  /* Lines */
  --line-hairline: 0.0625rem;

  /* Lift. Every shadow is ink at a low opacity. */
  --color-lift-4: color-mix(in srgb, var(--color-ink) 4%, transparent);
  --color-lift-5: color-mix(in srgb, var(--color-ink) 5%, transparent);
  --color-lift-6: color-mix(in srgb, var(--color-ink) 6%, transparent);
  --color-lift-7: color-mix(in srgb, var(--color-ink) 7%, transparent);
  --color-lift-8: color-mix(in srgb, var(--color-ink) 8%, transparent);
  --color-lift-10: color-mix(in srgb, var(--color-ink) 10%, transparent);
  --color-lift-14: color-mix(in srgb, var(--color-ink) 14%, transparent);
  --color-lift-20: color-mix(in srgb, var(--color-ink) 20%, transparent);
  --color-lift-black-8: color-mix(in srgb, black 8%, transparent);

  --shadow-card: 0 0 0 0.0625rem var(--color-lift-6),
    0 0.0625rem 0.125rem var(--color-lift-6),
    0 0.25rem 0.75rem var(--color-lift-5);
  /* The card lift for an angled shape. A clip cuts off box shadows, so this
     one is a filter. A filter has no spread, so the outline is left out. */
  --shadow-card-angled: drop-shadow(0 0.0625rem 0.125rem var(--color-lift-6)) drop-shadow(0 0.25rem 0.75rem var(--color-lift-5));
  --shadow-control: 0 0.0625rem 0.0625rem var(--color-lift-7),
    inset 0 -0.0625rem 0 var(--color-lift-4);
  --shadow-control-accent: 0 0.0625rem 0.0625rem var(--color-lift-10),
    inset 0 -0.0625rem 0 var(--color-lift-black-8);
  --shadow-inset: inset 0 0.0625rem 0.125rem var(--color-lift-8);
  --shadow-modal: 0 0 0 0.0625rem var(--color-lift-6),
    0 1rem 3rem var(--color-lift-20);
  --shadow-popover: 0 0 0 0.0625rem var(--color-lift-6),
    0 0.5rem 1.5rem var(--color-lift-14);
  --shadow-sheet: 0 -0.5rem 1.5rem var(--color-lift-14);
  --shadow-flat: none;

  /* Focus ring */
  --line-focus: 0.1875rem;
  --color-focus: color-mix(in srgb, var(--color-accent) 20%, transparent);
  --color-focus-error: color-mix(in srgb, var(--color-error) 12%, transparent);
  
  /* Callout fill: surface at 50% */
  --color-surface-half: color-mix(in srgb, var(--color-surface) 50%, transparent);

  /* A count on the active segment or filter */
  --color-on-fill-soft: color-mix(in srgb, var(--color-on-fill) 70%, transparent);

  /* Photo viewer: the pill over a photo, and the shadow that lets a white
     icon read on any picture */
  --color-ink-veil: color-mix(in srgb, var(--color-ink) 72%, transparent);
  --shadow-on-photo: drop-shadow(0 0.0625rem 0.125rem color-mix(in srgb, black 80%, transparent)) drop-shadow(0 0.125rem 0.5rem color-mix(in srgb, black 60%, transparent));

  /* The ring around the camera shutter */
  --color-camera-ring: color-mix(in srgb, var(--color-surface) 55%, transparent);

  /* Scrim behind a modal */
  --color-scrim: color-mix(in srgb, var(--color-ink) 28%, transparent);

  /* The check in a large checkbox. It is an image, so its color is written in. */
  --checkbox-mark-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 256 256' fill='none' stroke='white' stroke-width='28' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='40 144 96 200 216 72'/%3E%3C/svg%3E");

  /* The dim area around the scanner frame */
  --color-scanner-dim: color-mix(in srgb, black 25%, transparent);

  /* The caret on a select field. It is an image, so its color is written in. */
  --field-select-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 256 256'%3E%3Cpolyline points='208 96 128 176 48 96' fill='none' stroke='%23041122' stroke-linecap='round' stroke-linejoin='round' stroke-width='24'/%3E%3C/svg%3E");

  /* States */
  --color-hover: var(--color-lift-6);
  --opacity-disabled: 50%;
}
/* Type: design/foundations/typography.md and assets.md.
   One size, line height, weight and tracking per text style. The text-
   classes in global/text.css read these. */
:root {
  --font-family: "gate-a1-variable", sans-serif;

  /* The name in the logo */
  --text-logo-weight: 800;

  --text-display-size: 2.144rem;
  --text-display-line: 2.25rem;
  --text-display-weight: 800;
  --text-display-tracking: -0.035em;

  --text-heading-size: 1.25rem;
  --text-heading-line: 1.25rem;
  --text-heading-weight: 600;
  --text-heading-tracking: normal;

  --text-subheading-size: 0.9375rem;
  --text-subheading-line: 1.25rem;
  --text-subheading-weight: 750;
  --text-subheading-tracking: normal;

  --text-body-size: 1rem;
  --text-body-line: 1.375rem;
  --text-body-weight: 400;
  --text-body-tracking: normal;

  --text-body-strong-size: 1rem;
  --text-body-strong-line: 1.375rem;
  --text-body-strong-weight: 700;
  --text-body-strong-tracking: normal;

  --text-control-size: 1rem;
  --text-control-line: 1.375rem;
  --text-control-weight: 500;
  --text-control-tracking: normal;

  --text-button-size: 1rem;
  --text-button-line: 1.25rem;
  --text-button-weight: 500;
  --text-button-tracking: normal;

  --text-button-small-size: 0.875rem;
  --text-button-small-line: 1.25rem;
  --text-button-small-weight: 500;
  --text-button-small-tracking: normal;

  --text-nav-size: 0.9375rem;
  --text-nav-line: 1.25rem;
  --text-nav-weight: 500;
  --text-nav-tracking: normal;

  --text-label-size: 0.875rem;
  --text-label-line: 1.125rem;
  --text-label-weight: 700;
  --text-label-tracking: normal;

  --text-caption-size: 0.8125rem;
  --text-caption-line: 1.125rem;
  --text-caption-weight: 400;
  --text-caption-tracking: normal;

  --text-caption-strong-size: 0.8125rem;
  --text-caption-strong-line: 1.125rem;
  --text-caption-strong-weight: 500;
  --text-caption-strong-tracking: normal;

  --text-initials-size: 0.8125rem;
  --text-initials-line: 1rem;
  --text-initials-weight: 700;
  --text-initials-tracking: normal;

  --text-micro-size: 0.75rem;
  --text-micro-line: 1rem;
  --text-micro-weight: 400;
  --text-micro-tracking: normal;

  --text-field-label-size: 0.6875rem;
  --text-field-label-line: 0.875rem;
  --text-field-label-weight: 500;
  --text-field-label-tracking: normal;
}
/* Build-time helpers. They write no CSS by themselves. */

/* A text style from design/foundations/typography.md, read from the theme. */

/* The page background: the tile, repeated from the top left, quiet over
   canvas. The element needs its own stacking context. */
/* Modern reset: https://piccalil.li/blog/a-more-modern-css-reset/ */

/* Box sizing rules */
*,
*::before,
*::after {
  box-sizing: border-box;
}

/* Prevent font size inflation */
html {
  -moz-text-size-adjust: none;
  -webkit-text-size-adjust: none;
  text-size-adjust: none;
}

/* Remove default margin in favour of better control in authored CSS */
body,
h1,
h2,
h3,
h4,
p,
figure,
blockquote,
dl,
dd {
  margin-block-end: 0;
}

/* Remove list styles on ul, ol elements with a list role, which suggests default styling will be removed */
ul[role="list"],
ol[role="list"] {
  list-style: none;
  padding: 0;
}

/* Set core body defaults */
body {
  min-height: 100vh;
  line-height: 1.5;
}

/* Balance text wrapping on headings */
:where(h1, h2, h3, h4) {
  text-wrap: balance;
}

/* A elements that don't have a class get default styles */
:where(a:not([class])) {
  -webkit-text-decoration-skip: ink;
          text-decoration-skip-ink: auto;
  color: currentColor;
}

/* Make images easier to work with */
img,
picture {
  max-width: 100%;
  display: block;
}

/* Inherit fonts for inputs and buttons */
input,
button,
textarea,
select {
  font: inherit;
  color: currentColor;
}

/* Anything that has been anchored to should have extra scroll margin */
:target {
  scroll-margin-block: 5ex;
}

iframe {
  display: block;
}

/* more hidden */
*[hidden],
*[hidden="true"] {
  display: none !important;
}
/*
  Global styles

  Low-specificity, global styles that apply to the whole
  project: https://cube.fyi/css.html
*/

/* The page background: the tile, repeated from the top left, quiet over canvas.
   design/foundations/surfaces.md. */
body {
  font-size: var(--text-body-size);
  line-height: var(--text-body-line);
  font-variation-settings: "wght" var(--text-body-weight);
  letter-spacing: var(--text-body-tracking);
  position: relative;
  isolation: isolate;
  background-color: var(--color-canvas);

  &::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    background: var(--page-background-image) 0 0 / var(--page-background-size) repeat;
    opacity: var(--page-background-opacity);
    pointer-events: none;
  }
  color: var(--color-ink);
  font-family: var(--font-family);
}

:where(*, *::after, *::before) {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  border-width: var(--line-hairline);
  border-color: var(--color-line);
  border-style: none;
  -webkit-tap-highlight-color: transparent;
}

/* Focus ring, for keyboard focus. */
:where(:focus-visible) {
  outline: var(--line-focus) solid var(--color-focus);
  outline-offset: 0;
}

/* Screens that sit on a plain surface, not on the page background:
   anything printed, and the shop floor screens with no Board. */
body:is(.floor:not(:has(.board)), .print-document, .print-sheet) {
  background-color: var(--color-surface);

  &::before { display: none; }
}
/* View transitions */
html::view-transition-group(*) {
  position: absolute;
  top: 0;
  left: 0;

  animation-duration: 100ms;
  animation-fill-mode: both;
}

::view-transition-group(disabled),
::view-transition-old(disabled),
::view-transition-new(disabled) {
  animation-duration: 0s !important;
}

/* Checkbox: design/components/checkbox.md. */
.checkbox {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  inline-size: var(--size-checkbox);
  block-size: var(--size-checkbox);
  border: var(--line-hairline) solid var(--color-control-line);
  border-radius: var(--radius-soft);
  background: var(--color-surface);
  box-shadow: var(--shadow-inset);
  color: var(--color-on-fill);
  cursor: pointer;
  /* Centered on the first line of the label, which may wrap. */
  margin-block-start: calc((var(--text-body-line) - var(--size-checkbox)) / 2);

  /* The real input is visually hidden inside this box, so the box wears the
     focus ring on its behalf. */
  &:has(input:focus-visible) { outline: var(--line-focus) solid var(--color-focus); border-color: var(--color-accent); }

  /* The check is always in the markup; only its visibility follows the input,
     so the box does not reflow when it is ticked. */
  & > .icon {
    --size-icon: var(--size-checkbox-mark);
    visibility: hidden;
  }

  &:has(input:checked) {
    border-color: var(--color-ink);
    background: var(--color-ink);
    box-shadow: var(--shadow-flat);

    & > .icon { visibility: visible; }
  }
}

/* A box, then xs, then the label. */
label:has(input[type="checkbox"]) {
  display: flex;
  align-items: flex-start;
  gap: var(--space-xs);
  inline-size: -moz-fit-content;
  inline-size: fit-content;
  max-inline-size: 100%;
  color: var(--color-ink);
  cursor: pointer;
  -webkit-user-select: none;
     -moz-user-select: none;
          user-select: none;
}
/* Select field and its options: design/components/field.md. */
.combobox {
  position: relative;

  & > input {
    anchor-name: var(--anchor);
    padding-inline-end: calc(var(--space-xs) * 2 + var(--size-field-icon));
  }

  /* Direct child only: the options inside the popover carry .icon too. */
  & > .icon {
    --size-icon: var(--size-field-icon);
    position: absolute;
    inset-inline-end: var(--space-xs);
    inset-block-start: calc(50% - var(--size-field-icon) / 2);
    color: var(--color-ink);
    pointer-events: none;
  }

  & > .popover {
    position-anchor: var(--anchor);
    position-area: block-end span-inline-end;
    position-try-fallbacks: --combobox-above, flip-block;

    /* The UA sheet sets [popover] { inset: 0; margin: auto }, which centres the
       popover in the viewport and ignores the anchor entirely. */
    inset: auto;
    margin: var(--space-3xs) 0 0;

    inline-size: anchor-size(inline);
    max-block-size: min(var(--height-option-list), 40dvh);
    overflow-y: auto;
    overscroll-behavior: contain;
  }
}

@position-try --combobox-above {
  position-area: block-start span-inline-end;
  margin: 0 0 var(--space-3xs);
}

/* A pick-one field: read-only, so it is tapped rather than typed in. */
.combobox-select > input {
  cursor: pointer;
  caret-color: transparent;
}

/* The sheet parts only show on touch screens. Elsewhere the panel is just a
   wrapper the list sits in. */
.listbox-sheet-header, .listbox-matches { display: none; }
.listbox-panel, .listbox-results { display: contents; }

/* Touch screens: the list opens larger. With search it fills the window under
   its own search bar; a pick-one field opens a bottom sheet over the scrim. */
@media (pointer: coarse) {
  /* The doubled class outranks per-field width rules. */
  .combobox > .popover.popover[popover] {
    position: fixed;
    inset: 0;
    position-area: none;
    inline-size: 100%;
    block-size: 100dvh;
    max-inline-size: none;
    max-block-size: none;
    margin: 0;
    overflow: hidden;
    border-radius: var(--radius-square);
    box-shadow: var(--shadow-flat);
  }

  .combobox > .popover > .listbox-panel {
    display: flex;
    flex-direction: column;
    block-size: 100%;
    overflow: hidden;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  }

  /* The bar stays put; only the results below it scroll. */
  .combobox .listbox-results {
    display: block;
    flex: 1;
    min-block-size: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  .listbox-sheet-header {
    display: flex;
    align-items: center;
    flex-shrink: 0;
    gap: var(--space-xs);
    padding: var(--space-s);
    border-block-end: var(--line-hairline) solid var(--color-line);
    background: var(--color-surface);
  }

  .listbox-search {
    position: relative;
    flex: 1;

    & > .icon {
      --size-icon: var(--size-field-icon);
      position: absolute;
      inset-inline-start: var(--space-s);
      inset-block-start: calc(50% - var(--size-field-icon) / 2);
      color: var(--color-ink);
      pointer-events: none;
    }

    & input[type="search"] {
      block-size: var(--height-option-search);
      padding-inline: calc(var(--space-s) + var(--size-field-icon) + var(--space-xs)) calc(var(--size-option-clear) + var(--space-s));
      border-radius: var(--radius-pill);
      -webkit-appearance: none;

      &::-webkit-search-cancel-button { display: none; }
      &::-webkit-search-decoration { -webkit-appearance: none; }
    }
  }

  .listbox-search-clear {
    --size-icon: var(--size-option-icon);
    position: absolute;
    inset-inline-end: var(--space-xs);
    inset-block-start: calc(50% - var(--size-option-clear) / 2);
    display: grid;
    place-items: center;
    inline-size: var(--size-option-clear);
    block-size: var(--size-option-clear);
    border-radius: var(--radius-circle);
    background: var(--color-ink-dim);
    color: var(--color-on-fill);
    cursor: pointer;

    &[hidden] { display: none; }
  }

  .listbox-close {
    --size-icon: var(--size-button-icon);
    display: grid;
    place-items: center;
    flex-shrink: 0;
    inline-size: var(--height-tap-target);
    block-size: var(--height-tap-target);
    border-radius: var(--radius-circle);
    color: var(--color-ink);
    cursor: pointer;

    @media (hover: hover) { &:hover { background: var(--color-hover); } }
  }

  .listbox-matches {
  font-size: var(--text-caption-size);
  line-height: var(--text-caption-line);
  font-variation-settings: "wght" var(--text-caption-weight);
  letter-spacing: var(--text-caption-tracking);
    display: block;
    padding: var(--space-xs) var(--space-s) 0;
    color: var(--color-ink-dim);

    &[hidden] { display: none; }
  }

  /* Full-width rows, tall enough for gloves, divided by an inset hairline. The
     chosen one is filled, with its check at the right edge. */
  .combobox .listbox {
    padding: 0;

    & [role="option"] {
      position: relative;
      min-block-size: var(--height-option-touch);
      padding-inline: var(--space-s);
      border-radius: var(--radius-square);

      &::after {
        content: "";
        position: absolute;
        inset-inline: var(--space-s) 0;
        inset-block-end: 0;
        block-size: var(--line-hairline);
        background: var(--color-line-soft);
      }

      & .check-icon { order: 3; margin-inline-start: auto; }
      & .listbox-meta { order: 2; }

      &[aria-selected="true"] { background: var(--color-panel); }
      &.is-active:not([aria-selected="true"]) { background: none; }
    }

    /* Already set apart by its own full-width border. */
    & .listbox-create { margin: 0; }
    & .listbox-create::after { display: none; }
  }

  /* Pick-one fields: a bottom sheet over the scrim, always at least half the
     window however few options it has. */
  .combobox-select > .popover[popover]:popover-open {
    display: flex;
    align-items: flex-end;
    background: var(--color-scrim);
  }

  .combobox-select > .popover > .listbox-panel {
    inline-size: 100%;
    block-size: auto;
    min-block-size: 50dvh;
    max-block-size: 55dvh;
    padding-block-start: 0;
    border-radius: var(--radius-soft) var(--radius-soft) 0 0;
    background: var(--color-surface);
    box-shadow: var(--shadow-sheet);
  }

  .listbox-sheet-titled {
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding-block-start: var(--space-2xs);
    border-radius: var(--radius-soft) var(--radius-soft) 0 0;
  }

  .listbox-grabber {
    align-self: center;
    inline-size: var(--width-option-grabber);
    block-size: var(--height-option-grabber);
    margin-block-end: var(--space-xs);
    border-radius: var(--radius-pill);
    background: var(--color-line);
  }

  .listbox-sheet-title {
  font-size: var(--text-heading-size);
  line-height: var(--text-heading-line);
  font-variation-settings: "wght" var(--text-heading-weight);
  letter-spacing: var(--text-heading-tracking); color: var(--color-ink); }
  .listbox-sheet-context {
  font-size: var(--text-caption-size);
  line-height: var(--text-caption-line);
  font-variation-settings: "wght" var(--text-caption-weight);
  letter-spacing: var(--text-caption-tracking); color: var(--color-ink-soft); }

  .combobox-select .listbox [aria-selected="true"] .listbox-label::after {
  font-size: var(--text-caption-size);
  line-height: var(--text-caption-line);
  font-variation-settings: "wght" var(--text-caption-weight);
  letter-spacing: var(--text-caption-tracking);
    content: "Current";
    margin-inline-start: var(--space-xs);
    color: var(--color-ink-soft);
  }
}
.icon {
  width: var(--size-icon, var(--size-icon-default));
  height: var(--size-icon, var(--size-icon-default));
  fill: currentColor;
  display: inline;
  vertical-align: -0.15em;
}
/* Every text input, select and textarea is drawn as a Field:
   design/components/field.md. */
:where(input:not([type="checkbox"], [type="radio"], [type="file"], [type="hidden"], [type="range"]), select, textarea, .input) {
  font-size: var(--text-control-size);
  line-height: var(--text-control-line);
  font-variation-settings: "wght" var(--text-control-weight);
  letter-spacing: var(--text-control-tracking);
  inline-size: 100%;
  block-size: var(--height-field);
  padding-inline: var(--space-xs);
  border: var(--line-hairline) solid var(--color-control-line);
  border-radius: var(--radius-soft);
  background: var(--color-surface);
  box-shadow: var(--shadow-inset);
  color: var(--color-ink);
  caret-color: var(--color-accent);

  &::-moz-placeholder { color: var(--color-ink-dim); }

  &::placeholder { color: var(--color-ink-dim); }
  &:focus-visible { border-color: var(--color-accent); }

  /* Locked */
  &:disabled {
    border-color: var(--color-line);
    background: var(--color-panel);
    box-shadow: var(--shadow-flat);
    color: var(--color-ink-dim);
  }
}

:where(textarea) { block-size: var(--height-field-textarea); resize: vertical; }

/* Native selects ignore padding in WebKit; drawn like the other fields instead. */
select {
  -moz-appearance: none;
       appearance: none;
  -webkit-appearance: none;
  background-image: var(--field-select-image), linear-gradient(var(--color-surface), var(--color-surface));
  background-repeat: no-repeat;
  background-position: right var(--space-xs) center, 0 0;
  background-size: var(--size-field-icon), auto;
  padding-inline-end: calc(var(--space-xs) * 2 + var(--size-field-icon));
}

/* iPad Safari draws date inputs natively: taller than the other fields, with
   the date centred. Drawn like a text field instead; tapping still opens the
   date picker. */
input[type="date"] {
  -moz-appearance: none;
       appearance: none;
  -webkit-appearance: none;
  text-align: start;
}

input[type="date"]::-webkit-date-and-time-value {
  margin: 0;
  min-height: 1lh;
  text-align: start;
}

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

/* Select options: design/components/field.md. */
.listbox {
  padding: var(--space-3xs);

  & [role="option"] {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    min-block-size: var(--height-option);
    padding-inline: var(--space-xs);
    border-radius: var(--radius-soft);
    color: var(--color-ink);
    cursor: default;
    -webkit-user-select: none;
       -moz-user-select: none;
            user-select: none;
    overflow-wrap: anywhere;

    & .icon { --size-icon: var(--size-option-icon); flex-shrink: 0; }
    & .check-icon { visibility: hidden; }

    /* The check marks what is committed. */
    &[aria-selected="true"] .check-icon { visibility: visible; }

    /* The fill marks what is highlighted. Hovering promotes an option to
       active via listbox#point, so there is no separate :hover rule: two
       highlighted rows would contradict aria-activedescendant. */
    &.is-active { background: var(--color-panel); }
  }

  /* Not a choice among the options, so a hairline sets it apart. It sits above
     them and filtering never hides it. */
  & .listbox-create {
    margin-block-end: var(--space-3xs);
    border-block-end: var(--line-hairline) solid var(--color-line-soft);
    border-end-start-radius: 0;
    border-end-end-radius: 0;
  }
}

.listbox [role="option"] .listbox-label { flex: 1; min-inline-size: 0; }
.listbox [role="option"] .listbox-meta {
  font-size: var(--text-caption-size);
  line-height: var(--text-caption-line);
  font-variation-settings: "wght" var(--text-caption-weight);
  letter-spacing: var(--text-caption-tracking); flex-shrink: 0; color: var(--color-ink-soft); white-space: nowrap; }
.listbox [role="option"] .listbox-meta.line-grid-special { color: var(--color-accent-ink); }

.listbox-empty { padding: var(--space-xs); color: var(--color-ink-dim); }

.listbox-group {
  font-size: var(--text-caption-strong-size);
  line-height: var(--text-caption-strong-line);
  font-variation-settings: "wght" var(--text-caption-strong-weight);
  letter-spacing: var(--text-caption-strong-tracking);
  padding: var(--space-xs) var(--space-xs) var(--space-3xs);
  color: var(--color-ink-dim);
}

.listbox-expand {
  font-size: var(--text-caption-strong-size);
  line-height: var(--text-caption-strong-line);
  font-variation-settings: "wght" var(--text-caption-strong-weight);
  letter-spacing: var(--text-caption-strong-tracking);
  --size-icon: var(--size-option-icon);
  display: flex;
  align-items: center;
  gap: var(--space-2xs);
  inline-size: 100%;
  padding: var(--space-xs);
  border-block-start: var(--line-hairline) solid var(--color-line-soft);
  color: var(--color-ink-soft);
  cursor: pointer;
}

/* Modal: design/components/modal.md. */
dialog.modal[open] {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  inline-size: 100vw;
  block-size: 100vh;
  max-inline-size: 100vw;
  max-block-size: 100vh;
  padding: var(--offset-modal) var(--space-g) var(--space-g);
  background: none;

  &::backdrop { background: var(--color-scrim); }
}

.modal-content.modal-floor { max-inline-size: var(--width-modal-floor); }
.modal-content.modal-wide { max-inline-size: var(--width-modal-wide); }

.modal-content {
  display: flex;
  flex-direction: column;
  inline-size: 100%;
  max-inline-size: var(--width-modal);
  max-block-size: 100%;
  overflow: auto;
  padding: var(--space-g);
  border-radius: var(--radius-soft);
  background: var(--color-surface);
  box-shadow: var(--shadow-modal);
}

.modal-title {
  font-size: var(--text-heading-size);
  line-height: var(--text-heading-line);
  font-variation-settings: "wght" var(--text-heading-weight);
  letter-spacing: var(--text-heading-tracking); color: var(--color-ink); }

/* The close button's icon lines up with the padding. */
.modal-header {
  flex-shrink: 0;
  margin-block-end: var(--space-s);

  & .button-icon { margin: calc((var(--text-heading-line) - var(--height-button)) / 2) calc((var(--size-button-icon) - var(--height-button)) / 2); }
}

.modal-body { flex: 1 1 auto; }
.modal-footer { margin-block-start: var(--space-m); }

/* The shared dialog that a modal loads into, through its turbo frame. The
   modal draws its own surface, so the dialog shows nothing of its own. */
.board-modal {
  inline-size: min(var(--width-modal), 100% - var(--space-g) * 2);
  max-inline-size: none;
  max-block-size: calc(100% - var(--offset-modal) - var(--space-g));
  /* The reset's margin: 0 undoes the browser's centring of modal dialogs. */
  margin: var(--offset-modal) auto auto;
  padding: 0;
  overflow: visible;
  background: none;

  &::backdrop { background: var(--color-scrim); }
  &:has(.modal-floor) { inline-size: min(var(--width-modal-floor), 100% - var(--space-g) * 2); }

  &:has(.modal-wide) {
    inline-size: min(var(--width-modal-wide), 100% - var(--space-g) * 2);
    max-block-size: calc(100% - var(--space-l) - var(--space-g));
    margin-block-start: var(--space-l);
  }

  /* Near the top on touch screens, clear of the on-screen keyboard. */
  @media (pointer: coarse) { margin-block-start: var(--space-l); }

  & .modal-content { max-inline-size: none; max-block-size: inherit; }
}

/* On the shop floor */
.modal-subtitle {
  font-size: var(--text-caption-size);
  line-height: var(--text-caption-line);
  font-variation-settings: "wght" var(--text-caption-weight);
  letter-spacing: var(--text-caption-tracking); margin-block-start: var(--space-3xs); color: var(--color-ink-soft); }
.modal-group {
  font-size: var(--text-subheading-size);
  line-height: var(--text-subheading-line);
  font-variation-settings: "wght" var(--text-subheading-weight);
  letter-spacing: var(--text-subheading-tracking); margin-block: var(--space-s) var(--space-2xs); color: var(--color-ink); &:first-child { margin-block-start: 0; } }
.modal-stack { display: grid; gap: var(--space-2xs); }

/* Wide: a whole record shown over a board. */
.modal-wide .modal-header { padding-block-end: var(--space-s); border-block-end: var(--line-hairline) solid var(--color-line-soft); }

/* Tablets and phones: near the top, so the on-screen keyboard opens below the
   dialog instead of over it. */
@media (pointer: coarse) {
  dialog.modal[open] { padding-block-start: var(--space-l); }
  dialog.camera[open] { padding-block-start: 0; }
}
.popover {
  border-radius: var(--radius-soft);
  background: var(--color-surface);
  box-shadow: var(--shadow-popover);

  /* The UA sheet sets padding: 0.25em and color: CanvasText on [popover]. */
  padding: 0;
  color: var(--color-ink);
}
/* One class per text style in design/foundations/typography.md. A style sets
   size, line height, weight and tracking. The component sets the color.
   Weight goes through font-variation-settings, never font-weight. */

.text-display {
  font-size: var(--text-display-size);
  line-height: var(--text-display-line);
  font-variation-settings: "wght" var(--text-display-weight);
  letter-spacing: var(--text-display-tracking); }

.text-heading {
  font-size: var(--text-heading-size);
  line-height: var(--text-heading-line);
  font-variation-settings: "wght" var(--text-heading-weight);
  letter-spacing: var(--text-heading-tracking); }

.text-subheading {
  font-size: var(--text-subheading-size);
  line-height: var(--text-subheading-line);
  font-variation-settings: "wght" var(--text-subheading-weight);
  letter-spacing: var(--text-subheading-tracking); }

.text-body {
  font-size: var(--text-body-size);
  line-height: var(--text-body-line);
  font-variation-settings: "wght" var(--text-body-weight);
  letter-spacing: var(--text-body-tracking); }

.text-body-strong {
  font-size: var(--text-body-strong-size);
  line-height: var(--text-body-strong-line);
  font-variation-settings: "wght" var(--text-body-strong-weight);
  letter-spacing: var(--text-body-strong-tracking); }

.text-control {
  font-size: var(--text-control-size);
  line-height: var(--text-control-line);
  font-variation-settings: "wght" var(--text-control-weight);
  letter-spacing: var(--text-control-tracking); }

.text-button {
  font-size: var(--text-button-size);
  line-height: var(--text-button-line);
  font-variation-settings: "wght" var(--text-button-weight);
  letter-spacing: var(--text-button-tracking); }

.text-button-small {
  font-size: var(--text-button-small-size);
  line-height: var(--text-button-small-line);
  font-variation-settings: "wght" var(--text-button-small-weight);
  letter-spacing: var(--text-button-small-tracking); }

.text-nav {
  font-size: var(--text-nav-size);
  line-height: var(--text-nav-line);
  font-variation-settings: "wght" var(--text-nav-weight);
  letter-spacing: var(--text-nav-tracking); }

.text-label {
  font-size: var(--text-label-size);
  line-height: var(--text-label-line);
  font-variation-settings: "wght" var(--text-label-weight);
  letter-spacing: var(--text-label-tracking); }

.text-caption {
  font-size: var(--text-caption-size);
  line-height: var(--text-caption-line);
  font-variation-settings: "wght" var(--text-caption-weight);
  letter-spacing: var(--text-caption-tracking); }

.text-caption-strong {
  font-size: var(--text-caption-strong-size);
  line-height: var(--text-caption-strong-line);
  font-variation-settings: "wght" var(--text-caption-strong-weight);
  letter-spacing: var(--text-caption-strong-tracking); }

.text-initials {
  font-size: var(--text-initials-size);
  line-height: var(--text-initials-line);
  font-variation-settings: "wght" var(--text-initials-weight);
  letter-spacing: var(--text-initials-tracking); }

.text-micro {
  font-size: var(--text-micro-size);
  line-height: var(--text-micro-line);
  font-variation-settings: "wght" var(--text-micro-weight);
  letter-spacing: var(--text-micro-tracking); }

.text-field-label {
  font-size: var(--text-field-label-size);
  line-height: var(--text-field-label-line);
  font-variation-settings: "wght" var(--text-field-label-weight);
  letter-spacing: var(--text-field-label-tracking); }

/* Field stack: form rows in a column, 2xs apart. */
.field-stack {
  display: flex;
  flex-direction: column;
  gap: var(--space-2xs);
}

/* A checkbox list: rows are s apart. */
.field-stack > label:has(input[type="checkbox"]) + label:has(input[type="checkbox"]) {
  margin-block-start: calc(var(--space-s) - var(--space-2xs));
}

/* A checkbox list after fields starts s below them. */
.field-stack > .field + label:has(input[type="checkbox"]) {
  margin-block-start: calc(var(--space-s) - var(--space-2xs));
}
.region {
  padding-block: var(--space-page-top) var(--space-page-bottom);
}
/* Two things pushed to opposite ends of a row. */
.repel {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
/* A row of a page: equal columns with a gutter gap. Columns in a row are all
   as tall as the tallest. On a small screen they stack into one. */
.row {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  gap: var(--space-g);
}

/* A row of three columns. A child can take two of them. */
.row-3 {
  grid-auto-flow: row;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.row-span-2 { grid-column: span 2; }

@media (max-width: 800px) {
  .row, .row-3 {
    grid-auto-flow: row;
    grid-template-columns: minmax(0, 1fr);
  }

  .row-span-2 { grid-column: auto; }
}

.stack {
  display: flex;
  flex-direction: column;
}

/* Page wrap: centered, as wide as the page. On a window narrower than the
   page it keeps a gutter on each side. */
.wrap {
  margin-inline: auto;
  inline-size: min(100% - var(--space-g) * 2, var(--width-page));
}
/* Activity: design/components/activity.md. */
.activity {
  display: grid;
  gap: var(--space-s);
  justify-items: start;

  /* Five items show until the link is pressed. */
  &:not(:has(.activity-more[open])) .activity-list > li:nth-child(n + 6) { display: none; }
}

.activity-list {
  position: relative;
  display: grid;
  gap: var(--space-xs);
  inline-size: 100%;
  margin: 0;
  padding: 0;
  list-style: none;

  /* The rail that joins the dots. */
  &::before {
    content: "";
    position: absolute;
    inset-block: calc(var(--text-caption-line) / 2);
    inset-inline-start: calc((var(--size-activity-dot) - var(--line-hairline)) / 2);
    inline-size: var(--line-hairline);
    background: var(--color-line-soft);
  }
}

.activity-item {
  font-size: var(--text-caption-size);
  line-height: var(--text-caption-line);
  font-variation-settings: "wght" var(--text-caption-weight);
  letter-spacing: var(--text-caption-tracking);
  position: relative;
  display: grid;
  gap: var(--space-3xs);
  padding-inline-start: calc(var(--size-activity-dot) + var(--space-xs));
  color: var(--color-ink-soft);

  & em {
  font-size: var(--text-caption-strong-size);
  line-height: var(--text-caption-strong-line);
  font-variation-settings: "wght" var(--text-caption-strong-weight);
  letter-spacing: var(--text-caption-strong-tracking); font-style: normal; color: var(--color-ink); }
}

.activity-dot {
  position: absolute;
  inset-block-start: calc((var(--text-caption-line) - var(--size-activity-dot)) / 2);
  inset-inline-start: 0;
  inline-size: var(--size-activity-dot);
  block-size: var(--size-activity-dot);
  border-radius: var(--radius-circle);
  background: var(--color-line);
  box-shadow: 0 0 0 var(--line-hairline) var(--color-surface);
}

.activity-good .activity-dot { background: var(--color-green); }
.activity-watch .activity-dot { background: var(--color-amber); }
.activity-bad .activity-dot { background: var(--color-red); }

.activity-head { display: flex; justify-content: space-between; gap: var(--space-xs); }
.activity-who {
  font-size: var(--text-caption-strong-size);
  line-height: var(--text-caption-strong-line);
  font-variation-settings: "wght" var(--text-caption-strong-weight);
  letter-spacing: var(--text-caption-strong-tracking); color: var(--color-ink); }
.activity-when { color: var(--color-ink-dim); white-space: nowrap; }

.activity-more {
  & summary { list-style: none; cursor: pointer; &::-webkit-details-marker { display: none; } }
  &[open] .activity-more-closed, &:not([open]) .activity-more-open { display: none; }
}

.activity-empty { color: var(--color-ink-soft); }

/* Sign in: design/pages/logins/new.md. */
.auth {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  min-block-size: 100vh;

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

.auth-panel {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: var(--space-l);
  background: var(--color-ink);
  color: var(--color-on-fill);

  @media (max-width: 800px) { display: none; }
}

/* The logo, larger and in white. */
.auth-panel .logo { color: var(--color-on-fill); }
.auth-panel .logo-mark { inline-size: var(--size-logo-mark-large); block-size: var(--size-logo-mark-large); }
.auth-panel .logo-name {
  font-size: var(--text-display-size);
  line-height: var(--text-display-line);
  font-variation-settings: "wght" var(--text-display-weight);
  letter-spacing: var(--text-display-tracking); }

.auth-company {
  font-size: var(--text-label-size);
  line-height: var(--text-label-line);
  font-variation-settings: "wght" var(--text-label-weight);
  letter-spacing: var(--text-label-tracking); }

.auth-main {
  display: grid;
  place-items: center;
  padding: var(--space-l) var(--space-g);
}

/* The one column: a title, a message, fields, one button. */
.auth-column {
  display: flex;
  flex-direction: column;
  gap: var(--space-m);
  inline-size: 100%;
  max-inline-size: var(--width-auth);

  & > h1 { text-align: center; }
  & .callout { padding-inline-end: var(--space-s); }
}

.auth-text { color: var(--color-ink-soft); }
.auth-help {
  font-size: var(--text-caption-size);
  line-height: var(--text-caption-line);
  font-variation-settings: "wght" var(--text-caption-weight);
  letter-spacing: var(--text-caption-tracking); margin-block-start: calc(var(--space-s) - var(--space-m)); color: var(--color-ink-soft); }

/* An authenticator page: the column alone, centered on the page. */
.auth-page {
  display: grid;
  place-items: center;
  min-block-size: 100vh;
  padding: var(--space-l) var(--space-g);
}

.auth-qr {
  display: grid;
  justify-items: center;
  gap: var(--space-xs);

  & img { inline-size: var(--size-auth-qr); block-size: var(--size-auth-qr); border-radius: var(--radius-soft); background: var(--color-surface); }
  & figcaption {
  font-size: var(--text-caption-size);
  line-height: var(--text-caption-line);
  font-variation-settings: "wght" var(--text-caption-weight);
  letter-spacing: var(--text-caption-tracking); color: var(--color-ink-soft); }
}

/* Avatar: design/components/avatar.md. */
.avatar {
  font-size: var(--text-initials-size);
  line-height: var(--text-initials-line);
  font-variation-settings: "wght" var(--text-initials-weight);
  letter-spacing: var(--text-initials-tracking);
  display: inline-grid;
  place-items: center;
  flex-shrink: 0;
  inline-size: var(--size-avatar);
  block-size: var(--size-avatar);
  border-radius: var(--radius-circle);
  background: var(--color-brand-tint);
  color: var(--color-brand);
  text-transform: uppercase;
}
/* Badge: design/components/badge.md. Neutral is the default kind. */
.badge {
  font-size: var(--text-micro-size);
  line-height: var(--text-micro-line);
  font-variation-settings: "wght" var(--text-micro-weight);
  letter-spacing: var(--text-micro-tracking);
  display: inline-flex;
  align-items: center;
  gap: var(--space-3xs);
  block-size: var(--height-badge);
  padding-inline: var(--space-2xs);
  border: var(--line-hairline) solid var(--color-line);
  border-radius: var(--radius-soft);
  background: var(--color-panel);
  color: var(--color-ink-soft);
  white-space: nowrap;
}

.badge-green { border-color: transparent; background: var(--color-green-tint); color: var(--color-green-ink); }
.badge-amber { border-color: transparent; background: var(--color-amber-tint); color: var(--color-amber-ink); }
.badge-red { border-color: transparent; background: var(--color-red-tint); color: var(--color-red-ink); }

/* Badges or flags in a row. */
.badge-list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3xs);
}
/* Board: design/components/board.md. One column for each station. Each column
   is a card on the page background, which the body draws. The padding keeps
   every column's shadow inside the board. */
.board {
  flex: 1;
  min-block-size: 0;
  display: flex;
  /* Columns line up at the top. Each is only as tall as its content. */
  align-items: flex-start;
  gap: var(--space-xs);
  padding: var(--space-s);
  overflow-x: auto;
  -moz-user-select: none;
       user-select: none;
  -webkit-user-select: none;
}

.board-station {
  position: relative;
  display: flex;
  flex-direction: column;
  flex: 0 0 var(--width-board-column);
  min-block-size: 0;
  /* Never taller than the board, less the padding. Then the cards scroll. */
  max-block-size: 100%;
  /* Nothing inside a column shows outside its corners. */
  overflow: hidden;
  border-radius: var(--radius-soft);
  /* The gray fill covers the whole column, so the white cards stand off it. */
  background: var(--color-line-soft);
  box-shadow: var(--shadow-card);

  /* The column under a dragged card. */
  &.is-drop-target {
    background: var(--color-brand-tint);

    &::after {
      content: "";
      position: absolute;
      inset: 0;
      z-index: 5;
      border: var(--line-board-drop) dashed var(--color-brand);
      border-radius: inherit;
      pointer-events: none;
    }
  }
}

/* Station header: one row. The icon, the name, then the column menu trigger
   at the right end. No fill and no line of its own. The icon lines up with
   the left edge of the cards. */
.board-station-header {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  gap: var(--space-2xs);
  block-size: var(--height-station-header);
  padding-inline-start: var(--space-xs);
  color: var(--color-ink);

  & h2 {
    flex: 1;
    min-inline-size: 0;
    /* Room for descenders, which the cut-off would clip. */
    padding-block: var(--space-3xs);
    overflow: hidden;
    font-size: var(--text-station-name-size);
    line-height: var(--text-heading-line);
    font-variation-settings: "wght" var(--text-station-name-weight);
    white-space: nowrap;
    text-overflow: ellipsis;
  }

  /* With no trigger, the name still ends xs before the edge. */
  & h2:last-child { margin-inline-end: var(--space-xs); }
}

.board-station-icon { --size-icon: var(--size-station-icon); flex-shrink: 0; }

/* Column menu trigger: its tap area ends at the column edge. */
.board-station-header .board-station-menu { flex-shrink: 0; margin: 0; border-radius: var(--radius-square); }

/* The button that opens a folded column. It shows only then. */
.board-station-open {
  --size-icon: var(--size-station-icon);
  display: none;
  place-items: center;
  flex-shrink: 0;
  inline-size: var(--height-tap-target);
  block-size: var(--height-tap-target);
  color: var(--color-ink);
  cursor: pointer;
}

/* Cards are xs apart, and xs in from the left, right and bottom edges. The
   first card sits right under the header. */
.board-station-cards {
  flex: 0 1 auto;
  min-block-size: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  /* A column scrolls up and down only. Sideways belongs to the whole board. */
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  /* --bar-space is set by board_controller while an action bar is open. */
  padding: 0 var(--space-xs) calc(var(--space-xs) + var(--bar-space, 0rem));
}

.board-empty {
  font-size: var(--text-caption-size);
  line-height: var(--text-caption-line);
  font-variation-settings: "wght" var(--text-caption-weight);
  letter-spacing: var(--text-caption-tracking);
  padding: var(--space-s);
  color: var(--color-ink-dim);
  text-align: center;
}

/* Folded: a narrow rail. Top to bottom: open, the name reading upward, the
   icon. Its height fits its parts. */
.board-station.is-minimized {
  flex-basis: var(--width-board-column-folded);

  & .board-station-header { flex-direction: column; gap: var(--space-xs); block-size: auto; padding: 0 0 var(--space-xs); }
  & .board-station-open { display: grid; order: 1; }
  & h2 { flex: none; order: 2; overflow: visible; writing-mode: vertical-rl; rotate: 180deg; }
  & .board-station-icon { order: 3; }
  & .board-station-menu, & .board-station-cards { display: none; }
}


/* Holding space turns the board into a canvas you drag around. */
.board.is-pan-ready { cursor: grab; & * { cursor: inherit; } }
.board.is-panning { cursor: grabbing; }

/* Station view: the station before, the station, and the one after, as three
   equal columns. */
.station-view {
  overflow: hidden;

  & .board-station { flex: 1 1 0; min-inline-size: 0; }
  & [data-current] .photo-card { cursor: pointer; }
}

.station-view-none { justify-content: center; }

/* The drop zone: drop a card here, or select one and tap, to send it on. */
.station-portal {
  display: grid;
  place-items: center;
  inline-size: 100%;
  aspect-ratio: var(--ratio-photo-card);
  border: var(--line-board-drop) dashed var(--color-control-line);
  border-radius: var(--radius-soft);
  background: var(--color-surface);
  color: var(--color-ink-soft);
  cursor: pointer;
}

.station-view .is-drop-target .station-portal { background: var(--color-brand-tint); border-color: var(--color-brand); }

/* All orders: the work orders table, under the toolbar, on plain surface. */
.board-orders {
  flex: 1;
  min-block-size: 0;
  overflow: auto;
  padding: 0 var(--space-g) var(--space-s);
  background: var(--color-surface);

  & .work-orders { margin-block-start: var(--space-s); }

  /* Small screens: Work order cards, straight on the page background. */
  @media (max-width: 800px) { background: none; }
}

.hold-other summary { list-style: none; }
.hold-other summary::-webkit-details-marker { display: none; }

/* Wall display: design/pages/displays/show.md. The same board, read-only.
   All six stations share the width. */
.board-display {
  overflow: hidden;

  & .board-station { flex: 1 1 0; min-inline-size: 0; }
}

/* Small screens: columns keep their width and their row. The row scrolls. */
@media (max-width: 800px) {
  .station-view, .board-display {
    overflow-x: auto;

    & .board-station { flex: 0 0 var(--width-board-column); }
  }
}

.display-counts { color: var(--color-ink-soft); & strong { color: var(--color-ink); } & .display-overdue { color: var(--color-red-ink); } }
.display-time {
  font-size: var(--text-label-size);
  line-height: var(--text-label-line);
  font-variation-settings: "wght" var(--text-label-weight);
  letter-spacing: var(--text-label-tracking); color: var(--color-ink); }
/* Button: design/components/button.md. */
button {
  background: transparent;
}

.button {
  font-size: var(--text-button-size);
  line-height: var(--text-button-line);
  font-variation-settings: "wght" var(--text-button-weight);
  letter-spacing: var(--text-button-tracking);
  --size-icon: var(--size-button-icon);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  gap: var(--space-2xs);
  inline-size: -moz-fit-content;
  inline-size: fit-content;
  block-size: var(--height-button);
  padding-inline: var(--space-s);
  border: var(--line-hairline) solid transparent;
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-flat);
  color: var(--color-ink);
  white-space: nowrap;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  -webkit-user-select: none;
     -moz-user-select: none;
          user-select: none;
  touch-action: manipulation;

  & .icon { flex-shrink: 0; vertical-align: baseline; }
  &:focus-visible { border-color: var(--color-accent); }
}

/* Types */
.button-primary {
  background: linear-gradient(var(--color-accent-light), var(--color-accent-dark));
  border-color: var(--color-accent-line);
  box-shadow: var(--shadow-control-accent);
  color: var(--color-on-fill);
}

.button-secondary {
  background: linear-gradient(var(--color-surface), var(--color-panel));
  border-color: var(--color-control-line);
  box-shadow: var(--shadow-control);
}

.button-ghost:focus-visible { border-color: transparent; }

/* The second action in a modal that deletes or removes the record. */
.button-destructive { color: var(--color-error); }

@media (hover: hover) {
  .button-primary:hover {
    background: linear-gradient(var(--color-accent-dark), var(--color-accent-line));
    border-color: var(--color-accent-ink);
  }
  .button-secondary:hover { background: linear-gradient(var(--color-panel), var(--color-canvas)); }
  .button-ghost:hover { background: var(--color-hover); }
}

/* Sizes */
.button-small {
  font-size: var(--text-button-small-size);
  line-height: var(--text-button-small-line);
  font-variation-settings: "wght" var(--text-button-small-weight);
  letter-spacing: var(--text-button-small-tracking);
  --size-icon: var(--size-button-icon-small);
  block-size: var(--height-button-small);
  padding-inline: var(--space-xs);
}

.button-large {
  block-size: var(--height-button-large);
  padding-inline: var(--padding-button-large);
}

/* Icon only: a circle as tall as the button. */
.button-icon {
  aspect-ratio: 1 / 1;
  padding-inline: 0;
  border-radius: var(--radius-circle);
}

/* Block: fills the width. */
.button.button-block { inline-size: 100%; }

/* Disabled: faded, and no hover change. */
.button[disabled], .button[aria-disabled="true"] {
  opacity: var(--opacity-disabled);
  cursor: not-allowed;
  pointer-events: none;
}
/* Callout: design/components/callout.md. The one angled shape.
   A clip cuts off shadows and borders, so the lift is a filter on the callout
   and the border is its own clipped layer: a ring that follows the cut. */
.callout {
  --callout-color: var(--color-ink-dim);
  --callout-cut: var(--cut-angled);
  --callout-line: var(--line-callout);
  /* The inner cut, so the diagonal is as thick as the straight edges. */
  --callout-inner: calc(var(--callout-cut) - var(--callout-line) * 0.586);
  position: relative;
  isolation: isolate;
  display: flex;
  align-items: center;
  gap: var(--gap-callout);
  padding: var(--space-s) var(--space-g) var(--space-s) var(--padding-callout-start);
  filter: var(--shadow-card-angled);
  color: var(--color-ink);

  &::before, &::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
  }

  /* The border */
  &::before {
    background: var(--callout-color);
    clip-path: polygon(evenodd,
      var(--callout-cut) 0, calc(100% - var(--callout-cut)) 0, 100% var(--callout-cut), 100% calc(100% - var(--callout-cut)),
      calc(100% - var(--callout-cut)) 100%, var(--callout-cut) 100%, 0 calc(100% - var(--callout-cut)), 0 var(--callout-cut),
      var(--callout-cut) 0,
      calc(var(--callout-line) + var(--callout-inner)) var(--callout-line),
      calc(100% - var(--callout-line) - var(--callout-inner)) var(--callout-line),
      calc(100% - var(--callout-line)) calc(var(--callout-line) + var(--callout-inner)),
      calc(100% - var(--callout-line)) calc(100% - var(--callout-line) - var(--callout-inner)),
      calc(100% - var(--callout-line) - var(--callout-inner)) calc(100% - var(--callout-line)),
      calc(var(--callout-line) + var(--callout-inner)) calc(100% - var(--callout-line)),
      var(--callout-line) calc(100% - var(--callout-line) - var(--callout-inner)),
      var(--callout-line) calc(var(--callout-line) + var(--callout-inner)),
      calc(var(--callout-line) + var(--callout-inner)) var(--callout-line));
  }

  /* The fill, inside the border */
  &::after {
    inset: var(--callout-line);
    background: var(--color-surface-half);
    clip-path: polygon(
      var(--callout-inner) 0, calc(100% - var(--callout-inner)) 0, 100% var(--callout-inner), 100% calc(100% - var(--callout-inner)),
      calc(100% - var(--callout-inner)) 100%, var(--callout-inner) 100%, 0 calc(100% - var(--callout-inner)), 0 var(--callout-inner));
  }

  & > .icon { --size-icon: var(--size-callout-icon); flex-shrink: 0; color: var(--callout-color); }
}

.callout-red { --callout-color: var(--color-red); }
.callout-amber { --callout-color: var(--color-amber); }
.callout-green { --callout-color: var(--color-green); }

.callout-body { flex: 1; display: grid; gap: var(--space-3xs); min-inline-size: 0; }
.callout-title {
  font-size: var(--text-subheading-size);
  line-height: var(--text-subheading-line);
  font-variation-settings: "wght" var(--text-subheading-weight);
  letter-spacing: var(--text-subheading-tracking); color: var(--color-ink); }
.callout-meta {
  font-size: var(--text-caption-size);
  line-height: var(--text-caption-line);
  font-variation-settings: "wght" var(--text-caption-weight);
  letter-spacing: var(--text-caption-tracking); color: var(--color-ink-soft); & a { color: inherit; } }

/* The action at the right end: its right edge as far in as the icon is from the left. */
.callout:has(> .callout-action) { padding-inline-end: var(--padding-callout-start); }
.callout-action { flex-shrink: 0; }

/* A link that ends the body. */
.callout-body p > a { color: var(--color-accent-ink); text-decoration: none; }
/* Camera: design/pages/orders/_form.md. It takes the whole window. */
dialog.modal.camera[open] { padding: 0; }

.camera .modal-content {
  inline-size: 100%;
  max-inline-size: none;
  block-size: 100dvh;
  max-block-size: none;
  padding: 0;
  border-radius: var(--radius-square);
  background: var(--color-ink);
  box-shadow: var(--shadow-flat);
  color: var(--color-on-fill);
}

.camera .modal-header, .camera .modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  min-block-size: var(--height-camera-bar);
  margin: 0;
  padding-inline: var(--space-g);
}

.camera .modal-title, .camera .modal-header .button { color: var(--color-on-fill); }
.camera .modal-header .button-icon { margin: 0; }

.camera .modal-body {
  display: flex;
  flex-direction: column;
  min-block-size: 0;
}

.camera-stage {
  position: relative;
  flex: 1;
  min-block-size: 0;
}

.camera-preview {
  inline-size: 100%;
  block-size: 100%;
  -o-object-fit: cover;
     object-fit: cover;
}

.camera-shutter {
  position: absolute;
  inset-inline-start: 50%;
  inset-block-end: var(--space-s);
  translate: -50% 0;
  inline-size: var(--size-camera-shutter);
  block-size: var(--size-camera-shutter);
  border-radius: var(--radius-circle);
  background: var(--color-surface);
  box-shadow: 0 0 0 var(--line-camera-ring) var(--color-camera-ring);
  cursor: pointer;

  &:active { scale: 0.94; }
}

.camera-note {
  font-size: var(--text-caption-size);
  line-height: var(--text-caption-line);
  font-variation-settings: "wght" var(--text-caption-weight);
  letter-spacing: var(--text-caption-tracking); padding: var(--space-2xs) var(--space-g) 0; color: var(--color-ink-dim); }
.camera .error-well { margin: var(--space-xs) var(--space-g) 0; }

/* The photos taken so far. */
.photo-strip {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
  padding: var(--space-xs) var(--space-g);

  &:empty { display: none; }
}

.photo-thumb {
  position: relative;
  inline-size: var(--size-camera-thumb);
  aspect-ratio: 1 / 1;
  overflow: hidden;
  border-radius: var(--radius-soft);

  & img { inline-size: 100%; block-size: 100%; -o-object-fit: cover; object-fit: cover; }

  & .button {
    position: absolute;
    inset-block-start: var(--space-3xs);
    inset-inline-end: var(--space-3xs);
    block-size: var(--size-camera-thumb-remove);
    background: var(--color-surface);
    --size-icon: var(--size-camera-thumb-icon);
  }
}

/* Card action bar: design/components/card-bar.md. */
.card-bar {
  position: fixed;
  inset: auto 0 var(--space-m) 0;
  inline-size: min(var(--width-card-bar), 100% - var(--space-g) * 2);
  block-size: auto;
  margin: 0 auto;
  padding: var(--space-s) var(--space-g);
  border-radius: var(--radius-soft);
  background: var(--color-surface);
  box-shadow: var(--shadow-popover);
  color: var(--color-ink);

  /* Slides up from below the window on open, and back down on close. */
  translate: 0 calc(100% + var(--space-m));
  opacity: 0;
  transition: translate var(--duration-md) ease, opacity var(--duration-md) ease, overlay var(--duration-md) allow-discrete, display var(--duration-md) allow-discrete;

  &:popover-open {
    display: grid;
    gap: var(--space-s);
    translate: none;
    opacity: 1;

    @starting-style {
      translate: 0 calc(100% + var(--space-m));
      opacity: 0;
    }
  }

  & form { display: contents; }
  @media (prefers-reduced-motion: reduce) { transition: none; }
}

.card-bar-title {
  font-size: var(--text-heading-size);
  line-height: var(--text-heading-line);
  font-variation-settings: "wght" var(--text-heading-weight);
  letter-spacing: var(--text-heading-tracking); padding-inline-end: var(--height-button); }

.card-bar-close {
  position: absolute;
  inset-block-start: calc(var(--space-s) + (var(--text-heading-line) - var(--height-tap-target)) / 2);
  inset-inline-end: calc(var(--space-g) + (var(--size-button-icon) - var(--height-tap-target)) / 2);
}

.card-bar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2xs);
}

/* The menu of stations opens above its button. */
.move-to-menu {
  position-area: block-start span-inline-end;
  inline-size: -moz-max-content;
  inline-size: max-content;
  min-inline-size: var(--width-menu);
  max-block-size: 60vh;
  margin: 0 0 var(--space-3xs);
  overflow-y: auto;
}
/* Card: design/components/card.md. */
.card {
  display: flex;
  flex-direction: column;
  padding: var(--space-s) var(--space-g) var(--space-g);
  border-radius: var(--radius-soft);
  background: var(--color-surface);
  box-shadow: var(--shadow-card);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-s);
  min-block-size: var(--height-card-header);
  margin-block-end: var(--space-xs);
}

.card-title {
  font-size: var(--text-subheading-size);
  line-height: var(--text-subheading-line);
  font-variation-settings: "wght" var(--text-subheading-weight);
  letter-spacing: var(--text-subheading-tracking); color: var(--color-ink); }
.card-note {
  font-size: var(--text-caption-size);
  line-height: var(--text-caption-line);
  font-variation-settings: "wght" var(--text-caption-weight);
  letter-spacing: var(--text-caption-tracking); margin-block-end: var(--space-s); color: var(--color-ink-dim); }
.card-footer { margin-block-start: var(--space-m); }
.card-empty { color: var(--color-ink-soft); }

/* Table card: no title, only a table. The header band sits at the top edge.
   The last row keeps its own xs below, so its text ends s above the bottom. */
.card-table {
  padding-block: 0 calc(var(--space-s) - var(--space-xs));
  /* The header band, edge to edge, under the table's header row. */
  background: linear-gradient(var(--color-ink) var(--height-table-band), var(--color-surface) var(--height-table-band));
}

/* Title outside: the title sits on the page background, xs above a card
   with no header row. */
.card-outside { display: flex; flex-direction: column; gap: var(--space-xs); min-inline-size: 0; }
.card-outside-title {
  font-size: var(--text-subheading-size);
  line-height: var(--text-subheading-line);
  font-variation-settings: "wght" var(--text-subheading-weight);
  letter-spacing: var(--text-subheading-tracking); color: var(--color-ink); }

/* Fact card: one important fact. The label above the value, then subtext.
   The page sets its width, or it fits its text. */
.card-fact {
  inline-size: var(--card-fact-width, auto);
  min-inline-size: 0;
  padding: var(--space-s);
}

.card-fact-label {
  font-size: var(--text-caption-strong-size);
  line-height: var(--text-caption-strong-line);
  font-variation-settings: "wght" var(--text-caption-strong-weight);
  letter-spacing: var(--text-caption-strong-tracking); color: var(--color-ink-soft); }
.card-fact-value {
  font-size: var(--text-heading-size);
  line-height: var(--text-heading-line);
  font-variation-settings: "wght" var(--text-heading-weight);
  letter-spacing: var(--text-heading-tracking); margin-block-start: var(--space-3xs); color: var(--color-ink); }
.card-fact-sentence {
  font-size: var(--text-body-size);
  line-height: var(--text-body-line);
  font-variation-settings: "wght" var(--text-body-weight);
  letter-spacing: var(--text-body-tracking); margin-block-start: var(--space-3xs); color: var(--color-ink); }
.card-fact-subtext {
  font-size: var(--text-caption-size);
  line-height: var(--text-caption-line);
  font-variation-settings: "wght" var(--text-caption-weight);
  letter-spacing: var(--text-caption-tracking); margin-block-start: var(--space-3xs); color: var(--color-ink-soft); }

/* Fact cards in a row, a gutter apart, lined up at the left, all as tall as
   the tallest. A card never grows past the room left in the row; its text
   wraps. On a small screen they stack and fill the width. */
.card-facts {
  display: flex;
  align-items: stretch;
  gap: var(--space-g);

  & > .card-fact { flex: 0 1 auto; }
  & > .card-fact-fixed { flex-shrink: 0; }

  @media (max-width: 800px) {
    flex-direction: column;
    & > .card-fact { inline-size: auto; }
  }
}
/* Checker: design/components/checker.md. A queue on the left, the chosen
   work order on the right. No floor header: the page is the whole window. */
.checker {
  flex: 1;
  min-block-size: 0;
  display: grid;
  grid-template-columns: var(--width-checker-queue) minmax(0, 1fr);
}

body.floor:has(.checker) main { block-size: 100dvh; }

/* iPad Safari lets the page itself scroll under a fixed layout, by a swipe on a
   non-scrolling area or a fling past the end of a list. Pin the page so only the
   queue and the order scroll. */
html:has(body.floor .checker) { overflow: hidden; overscroll-behavior: none; }
body.floor:has(.checker) { position: fixed; inset: 0; inline-size: 100%; overscroll-behavior: none; }

/* Queue */
.checker-queue {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-inline-end: var(--line-hairline) solid var(--color-line);
  background: var(--color-surface);

  & > .segmented { margin: var(--space-s); }
}

/* Only the list scrolls. iPad only bounces a box that overflows, so a strip
   hangs below the list to let it rubber band when it is not full. */
.checker-queue-list {
  position: relative;
  flex: 1;
  min-block-size: 0;
  display: flex;
  flex-direction: column;
  overflow-y: scroll;
  overscroll-behavior: contain;

  &::after { content: ""; position: absolute; inset-block-start: 100%; inline-size: var(--line-hairline); block-size: var(--line-hairline); }
}

.queue-empty { flex: 1; display: grid; place-items: center; color: var(--color-ink-dim); text-align: center; }

.queue-row {
  position: relative;
  display: grid;
  gap: var(--space-3xs);
  padding: var(--space-s);
  color: var(--color-ink);
  text-decoration: none;

  /* The divider between rows, inset on each side. */
  & + &::before {
    content: "";
    position: absolute;
    inset-block-start: 0;
    inset-inline: var(--space-s);
    block-size: var(--line-hairline);
    background: var(--color-line-soft);
  }

  &.is-current {
    background: var(--color-panel);
    box-shadow: inset var(--line-queue-current) 0 0 var(--color-ink);
  }
}

.queue-row-top { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-xs); }
.queue-row-name {
  font-size: var(--text-subheading-size);
  line-height: var(--text-subheading-line);
  font-variation-settings: "wght" var(--text-subheading-weight);
  letter-spacing: var(--text-subheading-tracking); min-inline-size: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.queue-row-time {
  font-size: var(--text-caption-size);
  line-height: var(--text-caption-line);
  font-variation-settings: "wght" var(--text-caption-weight);
  letter-spacing: var(--text-caption-tracking); flex-shrink: 0; color: var(--color-ink-soft); }
.queue-row-sub {
  font-size: var(--text-caption-size);
  line-height: var(--text-caption-line);
  font-variation-settings: "wght" var(--text-caption-weight);
  letter-spacing: var(--text-caption-tracking); overflow: hidden; color: var(--color-ink-soft); white-space: nowrap; text-overflow: ellipsis; }

.checker-account {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  gap: var(--space-2xs);
  block-size: var(--height-checker-bar);
  padding-inline: var(--space-s);
  border-block-start: var(--line-hairline) solid var(--color-line);
}

.checker-user {
  font-size: var(--text-label-size);
  line-height: var(--text-label-line);
  font-variation-settings: "wght" var(--text-label-weight);
  letter-spacing: var(--text-label-tracking); margin-inline-end: auto; color: var(--color-ink); }

/* Work order */
.checker-main {
  position: relative;
  isolation: isolate;
  background-color: var(--color-canvas);

  &::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    background: var(--page-background-image) 0 0 / var(--page-background-size) repeat;
    opacity: var(--page-background-opacity);
    pointer-events: none;
  }
  display: flex;
  flex-direction: column;
  min-block-size: 0;
}

.checker-body {
  flex: 1;
  min-block-size: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-g);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: var(--space-g);
}

.checker-title-row { display: flex; align-items: center; justify-content: space-between; gap: var(--space-s); margin-block-end: calc(var(--space-s) - var(--space-g)); }
.checker-title-actions { display: flex; align-items: center; gap: var(--space-2xs); }

.checker-empty {
  position: relative;
  isolation: isolate;
  background-color: var(--color-canvas);

  &::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    background: var(--page-background-image) 0 0 / var(--page-background-size) repeat;
    opacity: var(--page-background-opacity);
    pointer-events: none;
  } display: grid; place-items: center; color: var(--color-ink-dim); }

/* Action bar */
.checker-footer {
  flex-shrink: 0;
  padding: var(--space-s) var(--space-g);
  border-block-start: var(--line-hairline) solid var(--color-line);
  background: var(--color-surface);
  font-variant-numeric: tabular-nums;
}

/* Sending something on winds it up, then slides it out of the column. */
.is-shipping {
  pointer-events: none;
  animation: ship-away 700ms var(--ease-custom) forwards;
}

@keyframes ship-away {
  14% { translate: calc(var(--space-s) * -1) 0; scale: 0.985; opacity: 1; }
  100% { translate: 110% 0; opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .is-shipping { animation: none; }
}

/* Line card */
.checker-line { gap: var(--space-s); padding-block-start: var(--space-g); }

.check-line-eyebrow {
  font-size: var(--text-caption-size);
  line-height: var(--text-caption-line);
  font-variation-settings: "wght" var(--text-caption-weight);
  letter-spacing: var(--text-caption-tracking); margin-block-end: calc(var(--space-2xs) - var(--space-s)); color: var(--color-ink-dim); }

.check-line { display: flex; align-items: center; gap: var(--space-s); }

.check-line-heading {
  display: flex;
  align-items: center;
  flex: 1;
  gap: var(--space-s);
  min-inline-size: 0;
}

/* On incoming the heading is a label for the line's checkbox. */
.checker-line label.check-line-heading { inline-size: auto; max-inline-size: none; cursor: pointer; }

.check-line-qty {
  font-size: var(--text-heading-size);
  line-height: var(--text-heading-line);
  font-variation-settings: "wght" var(--text-heading-weight);
  letter-spacing: var(--text-heading-tracking); flex: none; font-variant-numeric: tabular-nums; }
.check-line-text { display: grid; min-inline-size: 0; }
.check-line-name {
  font-size: var(--text-subheading-size);
  line-height: var(--text-subheading-line);
  font-variation-settings: "wght" var(--text-subheading-weight);
  letter-spacing: var(--text-subheading-tracking); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.check-line-sub {
  font-size: var(--text-caption-size);
  line-height: var(--text-caption-line);
  font-variation-settings: "wght" var(--text-caption-weight);
  letter-spacing: var(--text-caption-tracking); color: var(--color-ink-soft); }
.check-line-pick { display: grid; }

/* The large checkbox that picks a line. */
.check-line-box {
  -webkit-appearance: none;
     -moz-appearance: none;
          appearance: none;
  flex-shrink: 0;
  inline-size: var(--size-checker-checkbox);
  block-size: var(--size-checker-checkbox);
  margin: 0;
  border: var(--line-hairline) solid var(--color-control-line);
  border-radius: var(--radius-soft);
  background: var(--color-surface) center / 70% no-repeat;
  box-shadow: var(--shadow-inset);
  cursor: pointer;

  &:checked {
    border-color: var(--color-ink);
    background-color: var(--color-ink);
    background-image: var(--checkbox-mark-image);
    box-shadow: var(--shadow-flat);
  }
}

/* Photos: a row that scrolls sideways. */
.checker-photos {
  display: flex;
  gap: var(--space-2xs);
  /* Room for a photo's focus ring, which the scrolling row would clip. */
  margin: calc(var(--space-3xs) * -1);
  padding: var(--space-3xs);
  overflow-x: auto;
  overscroll-behavior-x: contain;

  @media (hover: none) {
    scrollbar-width: none;
    &::-webkit-scrollbar { display: none; }
  }
}

.line-photo {
  flex-shrink: 0;
  display: block;
  inline-size: var(--width-checker-photo);
  block-size: var(--height-checker-photo);
  overflow: hidden;
  border-radius: var(--radius-soft);
  background: var(--color-panel);

  & img { inline-size: 100%; block-size: 100%; -o-object-fit: cover; object-fit: cover; }
}

/* A discrepancy in a list: a red flag before it. */
.discrepancy { display: flex; align-items: flex-start; gap: var(--space-xs); & > .icon { --size-icon: var(--size-menu-icon); flex-shrink: 0; margin-block-start: var(--space-3xs); color: var(--color-red); } }

/* Stat button */
.stat-button {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--space-3xs);
  inline-size: 100%;
  padding: var(--space-s);
  border: var(--line-hairline) solid var(--color-control-line);
  border-radius: var(--radius-soft);
  background: var(--color-surface);
  box-shadow: var(--shadow-control);
  color: var(--color-ink);
  text-align: start;
  cursor: pointer;

  &.is-empty {
    border-color: transparent;
    background: var(--color-panel);
    box-shadow: var(--shadow-flat);

    & .stat-button-number, & .stat-button-label { visibility: hidden; }
  }
}

.stat-button-number {
  font-size: var(--text-display-size);
  line-height: var(--text-display-line);
  font-variation-settings: "wght" var(--text-display-weight);
  letter-spacing: var(--text-display-tracking); font-variant-numeric: tabular-nums; }
.stat-button-unit {
  font-size: var(--text-caption-size);
  line-height: var(--text-caption-line);
  font-variation-settings: "wght" var(--text-caption-weight);
  letter-spacing: var(--text-caption-tracking); margin-inline-start: var(--space-3xs); color: var(--color-ink-soft); }
.stat-button-label {
  font-size: var(--text-caption-size);
  line-height: var(--text-caption-line);
  font-variation-settings: "wght" var(--text-caption-weight);
  letter-spacing: var(--text-caption-tracking); color: var(--color-ink-soft); }
.stat-button-prompt {
  font-size: var(--text-button-size);
  line-height: var(--text-button-line);
  font-variation-settings: "wght" var(--text-button-weight);
  letter-spacing: var(--text-button-tracking); position: absolute; inset: 0; display: grid; place-items: center; color: var(--color-ink-soft); }

/* Small screens: one column. The queue sits above the work order and the page
   scrolls as a whole, so nothing is pinned. */
@media (max-width: 800px) {
  html:has(body.floor .checker) { overflow: visible; }
  body.floor:has(.checker) { position: static; overflow: visible; }
  body.floor:has(.checker) main { block-size: auto; min-block-size: 100dvh; }

  .checker { grid-template-columns: minmax(0, 1fr); align-content: start; }
  .checker-queue { overflow: visible; border-inline-end: 0; border-block-end: var(--line-hairline) solid var(--color-line); }
  .checker-queue-list { flex: none; overflow-y: visible; }
  .checker-main, .checker-empty { min-block-size: 50dvh; }
  .checker-body { flex: none; overflow-y: visible; }
  .checker-title-row { flex-wrap: wrap; }
}
/* Customer panel: design/components/customer-panel.md. */
.customer-panel {
  position: relative;
  display: grid;
  gap: var(--space-xs);
  padding: var(--space-s);
  border: var(--line-hairline) solid var(--color-line);
  border-radius: var(--radius-soft);
  background: var(--color-surface-half);

  & > .link { position: absolute; inset-block-start: var(--space-s); inset-inline-end: var(--space-s); }

  /* Small screens: the link takes a row of its own, under the details. */
  @media (max-width: 800px) {
    & > .link { position: static; justify-self: start; }
  }
}
/* Detail list: design/components/detail-list.md. Side by side is the default:
   dt and dd pairs straight inside the dl. */
.detail-list {
  display: grid;
  grid-template-columns: var(--width-detail-list-label) minmax(0, 1fr);
  row-gap: var(--space-2xs);
  align-content: start;
  margin: 0;

  /* The label is centered on the first line of its value. */
  & dt {
  font-size: var(--text-caption-size);
  line-height: var(--text-caption-line);
  font-variation-settings: "wght" var(--text-caption-weight);
  letter-spacing: var(--text-caption-tracking); line-height: var(--text-body-line); color: var(--color-ink-dim); }
  & dd { margin: 0; color: var(--color-ink); }
}

/* Stacked: each fact is a div holding a dt and a dd. */
.detail-list-stacked {
  grid-template-columns: minmax(0, 1fr);
  row-gap: var(--space-s);

  & dt { line-height: var(--text-caption-line); }
  & dd { margin-block-start: var(--space-3xs); }
}

.detail-list-empty { color: var(--color-ink-dim); }

/* Due: design/components/due.md. */
.due {
  font-size: var(--text-caption-strong-size);
  line-height: var(--text-caption-strong-line);
  font-variation-settings: "wght" var(--text-caption-strong-weight);
  letter-spacing: var(--text-caption-strong-tracking);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  inline-size: -moz-max-content;
  inline-size: max-content;
  block-size: var(--height-due);
  padding-inline: var(--space-xs);
  border-radius: var(--radius-pill);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* On time */
.due-on-time { background: var(--color-green-tint); color: var(--color-green-ink); }
/* Due soon */
.due-soon { background: var(--color-amber-tint); color: var(--color-amber-ink); }
/* Due today */
.due-today { background: var(--color-amber); color: var(--color-ink); }
/* Overdue: a tint, never solid red. */
.due-overdue { background: var(--color-red-tint); color: var(--color-red-ink); }
/* Shipped or no date: plain text. */
.due-neutral {
  font-size: var(--text-body-size);
  line-height: var(--text-body-line);
  font-variation-settings: "wght" var(--text-body-weight);
  letter-spacing: var(--text-body-tracking); block-size: auto; padding-inline: 0; color: var(--color-ink); }
/* Editable row: design/components/editable-row.md. editable_row_controller
   marks the row .is-editing. */
.editable-row { cursor: pointer; }

.editable-row-form {
  display: none;
  align-items: center;
  gap: var(--space-2xs);

  /* The field's text sits where the plain text sat. */
  & .field-inline {
    inline-size: var(--width-editable-row-field);
    margin-inline-start: calc((var(--space-xs) + var(--line-hairline)) * -1);
  }
}

.editable-row.is-editing {
  cursor: default;

  & .editable-row-cell { padding-block: 0; overflow: visible; }
  & .editable-row-value, & .editable-row-saved { display: none; }
  & .editable-row-form { display: flex; }
}

/* Saved: a check and a word after the name. It fades after 4 seconds. */
.editable-row-saved {
  font-size: var(--text-caption-strong-size);
  line-height: var(--text-caption-strong-line);
  font-variation-settings: "wght" var(--text-caption-strong-weight);
  letter-spacing: var(--text-caption-strong-tracking);
  --size-icon: var(--size-editable-row-mark);
  display: inline-flex;
  align-items: center;
  gap: var(--space-3xs);
  margin-inline-start: var(--space-xs);
  color: var(--color-green-ink);
  animation: editable-row-saved 400ms 4s forwards;
}

@keyframes editable-row-saved {
  to { opacity: 0; }
}

/* Empty state: design/components/empty-state.md. A titled card uses card-empty. */
.empty-state {
  display: grid;
  justify-items: center;
  gap: var(--space-3xs);
  padding-block: var(--space-l);
  text-align: center;
}

.empty-state-title {
  font-size: var(--text-subheading-size);
  line-height: var(--text-subheading-line);
  font-variation-settings: "wght" var(--text-subheading-weight);
  letter-spacing: var(--text-subheading-tracking); color: var(--color-ink); }
.empty-state-line {
  font-size: var(--text-caption-size);
  line-height: var(--text-caption-line);
  font-variation-settings: "wght" var(--text-caption-weight);
  letter-spacing: var(--text-caption-tracking); color: var(--color-ink-soft); }

/* Search with no results: straight on the page, below the search field. */
.empty-state-search {
  gap: var(--space-xs);
  padding-block: var(--space-xl) 0;

  & .empty-state-title {
  font-size: var(--text-heading-size);
  line-height: var(--text-heading-line);
  font-variation-settings: "wght" var(--text-heading-weight);
  letter-spacing: var(--text-heading-tracking); }
  & .empty-state-line {
  font-size: var(--text-body-size);
  line-height: var(--text-body-line);
  font-variation-settings: "wght" var(--text-body-weight);
  letter-spacing: var(--text-body-tracking); }
}
/* The errors at the top of a form. */
.error-well {
  font-size: var(--text-caption-size);
  line-height: var(--text-caption-line);
  font-variation-settings: "wght" var(--text-caption-weight);
  letter-spacing: var(--text-caption-tracking);
  padding: var(--space-xs);
  border-radius: var(--radius-soft);
  background: var(--color-red-tint);
  color: var(--color-red-ink);
}
/* Field: design/components/field.md. A wrapper around a label and its input.
   The label sits inside the input and rises when the field is focused or
   filled: field_controller marks a filled wrapper .is-filled. */
.field {
  position: relative;
  display: flex;
  flex-direction: column;

  /* The value sits 2xs from the bottom, below the raised label. */
  & input, & select, & textarea {
    padding-block: calc(var(--height-field) - var(--space-2xs) - var(--text-control-line) - var(--line-hairline)) calc(var(--space-2xs) - var(--line-hairline));
  }

  & > label {
  font-size: var(--text-control-size);
  line-height: var(--text-control-line);
  font-variation-settings: "wght" var(--text-control-weight);
  letter-spacing: var(--text-control-tracking);
    position: absolute;
    inset-block-start: calc((var(--height-field) - var(--text-control-line)) / 2);
    inset-inline-start: var(--space-xs);
    z-index: 1;
    color: var(--color-ink-dim);
    pointer-events: none;
    transition: all 150ms;

    & .empty { display: block; }
    & .filled { display: none; }
  }

  &:focus-within > label,
  &.is-filled > label {
  font-size: var(--text-field-label-size);
  line-height: var(--text-field-label-line);
  font-variation-settings: "wght" var(--text-field-label-weight);
  letter-spacing: var(--text-field-label-tracking);
    inset-block-start: var(--space-2xs);

    & .empty { display: none; }
    & .filled { display: block; }
  }

  &:focus-within > label { color: var(--color-accent-ink); }
}

/* Error */
.field.is-error {
  & input, & select, & textarea { border-color: var(--color-error); outline-color: var(--color-focus-error); }
  & > label { color: var(--color-error); }
}

.field-error {
  font-size: var(--text-field-label-size);
  line-height: var(--text-field-label-line);
  font-variation-settings: "wght" var(--text-field-label-weight);
  letter-spacing: var(--text-field-label-tracking);
  margin-block-start: var(--space-2xs);
  color: var(--color-error);
}

/* Helper text: a note about one field. */
.field-help {
  font-size: var(--text-caption-size);
  line-height: var(--text-caption-line);
  font-variation-settings: "wght" var(--text-caption-weight);
  letter-spacing: var(--text-caption-tracking);
  margin-block-start: var(--space-2xs);
  color: var(--color-ink-soft);
}

/* Locked: the input is disabled. A lock icon sits on the right. */
.field.is-locked {
  & > label { color: var(--color-ink-dim); }
  & input { padding-inline-end: calc(var(--space-xs) * 2 + var(--size-field-icon)); }
}

/* An icon at the right end of a field, like the lock. */
.field-icon {
  --size-icon: var(--size-field-icon);
  position: absolute;
  inset-block-start: calc((var(--height-field) - var(--size-field-icon)) / 2);
  inset-inline-end: var(--space-xs);
  display: inline-grid;
  color: var(--color-ink-dim);
  pointer-events: none;
}

/* Why a field is locked. */
.lock-note {
  font-size: var(--text-caption-size);
  line-height: var(--text-caption-line);
  font-variation-settings: "wght" var(--text-caption-weight);
  letter-spacing: var(--text-caption-tracking);
  --size-icon: 1em;
  display: inline-flex;
  align-items: center;
  gap: var(--space-3xs);
  margin-block-start: var(--space-3xs);
  color: var(--color-ink-dim);
}

/* Search: shorter, a pill, no label, a magnifying glass on the left. */
.field-search {
  position: relative;

  & > .icon {
    --size-icon: var(--size-field-icon);
    position: absolute;
    inset-block-start: calc((var(--height-field-search) - var(--size-field-icon)) / 2);
    inset-inline-start: var(--space-s);
    color: var(--color-ink);
    pointer-events: none;
  }

  & input {
    block-size: var(--height-field-search);
    padding-inline: calc(var(--space-s) + var(--size-field-icon) + var(--space-xs)) var(--space-s);
    border-radius: var(--radius-pill);
  }
}

/* Inline: shorter, no label inside. For a field in a table row. */
.field-inline {
  position: relative;
  display: block;

  & input { block-size: var(--height-field-inline); }
}

/* A unit before the value, like "$". A number value is right aligned. */
.field-prefix {
  font-size: var(--text-control-size);
  line-height: var(--text-control-line);
  font-variation-settings: "wght" var(--text-control-weight);
  letter-spacing: var(--text-control-tracking);
  position: absolute;
  inset-block-start: calc((var(--height-field-inline) - var(--text-control-line)) / 2);
  inset-inline-start: var(--space-xs);
  color: var(--color-ink-dim);
  pointer-events: none;

  & + input { text-align: end; font-variant-numeric: tabular-nums; }
}
/* Filters: design/components/filters.md. The active filter is the pressed one. */
/* One row. When it does not fit it scrolls sideways; it never wraps. The
   padding is room for focus rings and lifts, which scrolling would clip. The
   negative margin gives it back. */
.filters {
  display: flex;
  gap: var(--space-2xs);
  overflow-x: auto;
  scrollbar-width: none;
  padding: var(--space-3xs);
  margin: calc(var(--space-3xs) * -1);

  &::-webkit-scrollbar { display: none; }
}

.filters-item {
  font-size: var(--text-button-small-size);
  line-height: var(--text-button-small-line);
  font-variation-settings: "wght" var(--text-button-small-weight);
  letter-spacing: var(--text-button-small-tracking);
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  gap: var(--space-2xs);
  block-size: var(--height-button-small);
  padding-inline: var(--space-xs);
  border: var(--line-hairline) solid var(--color-control-line);
  border-radius: var(--radius-pill);
  background: linear-gradient(var(--color-surface), var(--color-panel));
  box-shadow: var(--shadow-control);
  color: var(--color-ink);
  white-space: nowrap;
  text-decoration: none;

  &:focus-visible { border-color: var(--color-accent); }
  @media (hover: hover) { &:hover { background: linear-gradient(var(--color-panel), var(--color-canvas)); } }

  &[aria-pressed="true"] {
    border-color: var(--color-ink);
    background: var(--color-ink);
    box-shadow: var(--shadow-flat);
    color: var(--color-on-fill);
  }
}

/* Flag: design/components/flag.md. Every flag is solid: a strong fill with
   white text and icon. On hold keeps ink, because white does not read on amber. */
.flag {
  font-size: var(--text-caption-strong-size);
  line-height: var(--text-caption-strong-line);
  font-variation-settings: "wght" var(--text-caption-strong-weight);
  letter-spacing: var(--text-caption-strong-tracking);
  --size-icon: var(--size-flag-icon);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  gap: var(--space-3xs);
  block-size: var(--height-flag);
  padding-inline: var(--space-2xs);
  border-radius: var(--radius-pill);
  background: var(--color-brand);
  color: var(--color-on-fill);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;

  & .icon { flex-shrink: 0; vertical-align: baseline; }
}

.flag-rush, .flag-credit-hold { background: var(--color-red); color: var(--color-on-fill); }
.flag-holes { background: var(--color-green); color: var(--color-on-fill); }
.flag-coc { background: var(--color-brand); color: var(--color-on-fill); }
/* Label: a custom label the office ticked. It follows the flags. */
.flag-label {
  flex-shrink: 1;
  min-inline-size: 0;
  max-inline-size: 100%;
  background: var(--color-ink);
  color: var(--color-on-fill);

  /* A name wider than the room it has ends in an ellipsis. Its title has the whole name. */
  & .flag-text { overflow: hidden; text-overflow: ellipsis; }
}
.flag-hold { background: var(--color-amber); color: var(--color-ink); }
/* The shop floor: design/foundations/shop-floor.md and
   design/components/floor-header.md. Tablets in landscape, all day. The page
   never scrolls; each part scrolls by itself. */
body.floor { overflow: hidden; }

body.floor main {
  display: flex;
  flex-direction: column;
  block-size: calc(100dvh - var(--height-floor-header));
}

.floor-header {
  display: flex;
  align-items: center;
  gap: var(--space-s);
  block-size: var(--height-floor-header);
  padding-inline: var(--space-s);
  background: var(--color-surface);
  box-shadow: inset 0 calc(var(--line-hairline) * -1) 0 var(--color-line);

  & .button { block-size: var(--height-tap-target); }
}

/* With a toolbar, the hairline sits under the toolbar instead. */
body.floor:has(.floor-toolbar) .floor-header { box-shadow: var(--shadow-flat); }

.floor-header-end {
  display: flex;
  align-items: center;
  gap: var(--space-s);
  margin-inline-start: auto;

  & .nav-user { margin-inline-start: 0; }
}

.floor-title {
  font-size: var(--text-heading-size);
  line-height: var(--text-heading-line);
  font-variation-settings: "wght" var(--text-heading-weight);
  letter-spacing: var(--text-heading-tracking); color: var(--color-ink); }

.floor-search {
  flex: 0 1 var(--width-floor-search);
  margin-inline-start: auto;
}

.floor-search ~ .floor-header-end { margin-inline-start: 0; }
.floor-search-toggle, .button.floor-search-toggle { display: none; }

/* Toolbar: a second row, for filters. */
.floor-toolbar {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  gap: var(--space-s);
  block-size: var(--height-floor-toolbar);
  padding-inline: var(--space-s);
  background: var(--color-surface);
  box-shadow: inset 0 calc(var(--line-hairline) * -1) 0 var(--color-line);

  & .filters { flex: 1; min-inline-size: 0; }
}

/* Touch: filters and other tap targets are taller on the floor. */
.floor .filters-item {
  block-size: var(--height-tap-target);
  padding-inline: var(--space-s);
}

/* Live indicator, on the Station view and the Wall Display. It is hidden until board-live says otherwise. The state sits
   on <html>, which a morph or a visit never touches, so nothing flashes. */
.live {
  font-size: var(--text-caption-strong-size);
  line-height: var(--text-caption-strong-line);
  font-variation-settings: "wght" var(--text-caption-strong-weight);
  letter-spacing: var(--text-caption-strong-tracking);
  display: flex;
  align-items: center;
  flex-shrink: 0;
  gap: var(--space-3xs);
  color: var(--color-ink);
  white-space: nowrap;
  opacity: 0;
  transition: opacity var(--duration-hover);
}

.live-dot {
  inline-size: var(--size-live-dot);
  block-size: var(--size-live-dot);
  border-radius: var(--radius-circle);
  background: var(--color-green);
}

.live-off { display: none; }

html[data-live="live"] .live { opacity: 1; }

html[data-live="reconnecting"] .live {
  opacity: 1;
  color: var(--color-amber-ink);

  & .live-dot { background: var(--color-amber); }
  & .live-on { display: none; }
  & .live-off { display: inline; }
}

/* On a phone the header folds up: home, then search, scan and account as
   icons, with the board control on a row of its own. Search opens in place of
   that row, so the header never changes height. */
@media (max-width: 800px) {
  body.floor:has(.floor-search-toggle) main { block-size: calc(100dvh - var(--height-floor-header) - var(--height-floor-toolbar)); }

  .floor-header:has(.floor-search-toggle) {
    display: grid;
    grid-template-columns: 1fr auto auto;
    grid-template-rows: var(--height-floor-header) var(--height-floor-toolbar);
    grid-template-areas: "home search end" "nav nav nav";
    gap: 0 var(--space-2xs);
    block-size: auto;
    padding-inline: var(--space-xs);

    & .floor-home { grid-area: home; justify-self: start; }
    & .floor-header-end { grid-area: end; }
    & .floor-search-toggle { grid-area: search; display: inline-flex; }
    & .segmented, & .floor-search { grid-area: nav; }
    & .floor-search { display: none; flex-basis: auto; }

    /* Scan as an icon. */
    & .floor-scan { aspect-ratio: 1 / 1; padding-inline: 0; }
    & .floor-scan-label { display: none; }

    &.is-searching .segmented { display: none; }
    &.is-searching .floor-search { display: block; }
  }
}
/* Form: design/components/form.md. One column, centered on the page. */
.form {
  inline-size: 100%;
  max-inline-size: var(--width-form);
  margin-inline: auto;
}

/* In settings: left aligned. */
.form-start { margin-inline: 0; }

/* Wide: the work order form only. */
.form-wide { max-inline-size: none; }

/* The back link at the left edge, centered on the title. */
.form-header {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;

  & .link-back { position: absolute; inset-inline-start: 0; }

  /* Small screens: the back link sits above the title, both left aligned. */
  @media (max-width: 800px) {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-xs);

    & .link-back { position: static; }
  }
}

.form-fieldset {
  display: flex;
  flex-direction: column;
  gap: var(--space-2xs);
  margin-block-start: var(--space-m);
  min-inline-size: 0;
}

.form-title {
  font-size: var(--text-subheading-size);
  line-height: var(--text-subheading-line);
  font-variation-settings: "wght" var(--text-subheading-weight);
  letter-spacing: var(--text-subheading-tracking);
  /* A legend sits outside the fieldset's column, so it sets its own gap. */
  margin-block-end: var(--space-xs);
  padding: 0;
  color: var(--color-ink);
}

/* Several fields side by side. They share the width equally. */
.form-row {
  display: flex;
  gap: var(--space-2xs);

  & > * { flex: 1; min-inline-size: 0; }

  /* A field with a fixed width. The page sets the width on it. */
  & > .form-row-fixed { flex: none; }

  /* Small screens: the fields stack, one per row, and fill the width. */
  @media (max-width: 800px) {
    flex-direction: column;

    & > *, & > .form-row-fixed { flex: none; inline-size: 100% !important; }
  }
}

.form-fieldset > label:has(input[type="checkbox"]) + label:has(input[type="checkbox"]) {
  margin-block-start: calc(var(--space-s) - var(--space-2xs));
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: var(--space-s);
  margin-block-start: var(--space-m);
}

/* File upload */
.form-upload { display: grid; gap: var(--space-2xs); justify-items: start; }
.form-upload-caption, .form-upload-name {
  font-size: var(--text-caption-size);
  line-height: var(--text-caption-line);
  font-variation-settings: "wght" var(--text-caption-weight);
  letter-spacing: var(--text-caption-tracking); color: var(--color-ink-dim); }
.form-upload-row { display: flex; align-items: center; gap: var(--space-xs); }
/* Line grid: design/components/line-grid.md. */
.line-grid {
  inline-size: 100%;
  table-layout: fixed;
  border-collapse: separate;
  border-spacing: 0;
  border: var(--line-hairline) solid var(--color-line);
  border-radius: var(--radius-soft);
  background: var(--color-surface);

  & th {
  font-size: var(--text-caption-size);
  line-height: var(--text-caption-line);
  font-variation-settings: "wght" var(--text-caption-weight);
  letter-spacing: var(--text-caption-tracking);
    block-size: var(--height-line-grid-header);
    padding-inline: var(--space-xs);
    background: var(--color-panel);
    color: var(--color-ink-soft);
    white-space: nowrap;
  }

  & td {
    position: relative;
    block-size: var(--height-line-grid-row);
    padding: 0;
    border-block-start: var(--line-hairline) solid var(--color-line);
    vertical-align: middle;
  }

  & th + th, & td + td { border-inline-start: var(--line-hairline) solid var(--color-line); }
  & thead th:first-child { border-start-start-radius: var(--radius-soft); }
  & thead th:last-child { border-start-end-radius: var(--radius-soft); }

  /* A cell that can be typed in: a field with no border of its own. */
  & td > input:not([type="checkbox"]), & .combobox > input {
    block-size: var(--height-line-grid-row);
    padding-block: 0;
    border: 0;
    border-radius: var(--radius-square);
    background: transparent;
    box-shadow: var(--shadow-flat);

    &:focus-visible { box-shadow: inset 0 0 0 var(--line-hairline) var(--color-accent); }
    &:disabled { background: var(--color-panel); color: var(--color-ink-dim); }
  }

  & .combobox > .icon { --size-icon: var(--size-line-grid-icon); }
}

/* Cells */
.line-grid .line-grid-text { padding-inline: var(--space-xs); }
.line-grid .line-grid-dim { color: var(--color-ink-dim); }
.line-grid .line-grid-number { text-align: end; font-variant-numeric: tabular-nums; & input { text-align: end; } }
.line-grid .line-grid-center { text-align: center; & label { inline-size: auto; justify-content: center; margin-inline: auto; } }

.line-grid-error {
  font-size: var(--text-field-label-size);
  line-height: var(--text-field-label-line);
  font-variation-settings: "wght" var(--text-field-label-weight);
  letter-spacing: var(--text-field-label-tracking);
  display: block;
  padding: 0 var(--space-xs) var(--space-3xs);
  color: var(--color-error);
}

.line-grid td:has(.line-grid-error) { box-shadow: inset 0 0 0 var(--line-hairline) var(--color-error); }

/* A badge at the right end of the description. */
.line-grid-note { position: absolute; inset-block-start: calc((var(--height-line-grid-row) - var(--height-badge)) / 2); inset-inline-end: var(--space-xs); }

/* An icon button that fills its cell: photos, remove. */
.line-grid-button {
  --size-icon: var(--size-line-grid-icon);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2xs);
  inline-size: 100%;
  block-size: var(--height-line-grid-row);
  color: var(--color-ink);
  cursor: pointer;

  @media (hover: hover) { &:is(button):hover { background: var(--color-panel); } }
  &[hidden], & [hidden] { display: none; }
}

.line-grid-locked { color: var(--color-ink-dim); cursor: default; }

/* Rate cell */
.line-grid-rate {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-2xs);
  inline-size: 100%;
  block-size: var(--height-line-grid-row);
  padding-inline: var(--space-xs);
  font-variant-numeric: tabular-nums;

  & [data-rate-override-target="badge"] { margin-inline-end: auto; }
  &:is(button) { cursor: pointer; }
  &:is(button):focus-visible, &:has(+ :popover-open) { box-shadow: inset 0 0 0 var(--line-hairline) var(--color-accent); }
}

.line-grid-special { color: var(--color-accent-ink); }
.line-grid-standard { color: var(--color-ink); }

/* Below the grid */
.line-grid-footer {
  display: flex;
  align-items: center;
  gap: var(--space-s);
  margin-block-start: var(--space-xs);
}

/* Rate override */
.rate-override {
  inset: auto;
  inline-size: var(--width-rate-override);
  margin: var(--space-3xs) 0 0;
  padding: var(--space-s);
  white-space: normal;
  position-area: block-end span-inline-start;
}

.rate-override-title {
  font-size: var(--text-subheading-size);
  line-height: var(--text-subheading-line);
  font-variation-settings: "wght" var(--text-subheading-weight);
  letter-spacing: var(--text-subheading-tracking); color: var(--color-ink); }
.rate-override-list {
  font-size: var(--text-caption-size);
  line-height: var(--text-caption-line);
  font-variation-settings: "wght" var(--text-caption-weight);
  letter-spacing: var(--text-caption-tracking); margin-block: var(--space-3xs) var(--space-xs); color: var(--color-ink-soft); }
.rate-override-actions { display: flex; align-items: center; justify-content: flex-end; gap: var(--space-2xs); margin-block-start: var(--space-s); & > :first-child:not(:only-child) { margin-inline-end: auto; } }

/* The category list carries a rate on every row; give it room. */
.line-grid .combobox > .popover { inline-size: max(anchor-size(inline), var(--width-line-grid-options)); }
/* Link: design/components/link.md. The arrow is a text character in the link. */
.link {
  font-size: var(--text-caption-size);
  line-height: var(--text-caption-line);
  font-variation-settings: "wght" var(--text-caption-weight);
  letter-spacing: var(--text-caption-tracking);
  text-decoration: none;
}

.link-back { color: var(--color-ink-soft); }
.link-more { color: var(--color-accent-ink); }
/* List: design/components/list.md. */
.list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.list-item {
  padding-block: var(--space-2xs);
  color: var(--color-ink);

  & + & { border-block-start: var(--line-hairline) solid var(--color-line-soft); }
  &:first-child { padding-block-start: 0; }
  &:last-child { padding-block-end: 0; }
}

.list-name { color: inherit; text-decoration: none; }

.list-detail {
  font-size: var(--text-caption-size);
  line-height: var(--text-caption-line);
  font-variation-settings: "wght" var(--text-caption-weight);
  letter-spacing: var(--text-caption-tracking);
  display: block;
  margin-block-start: var(--space-3xs);
  color: var(--color-ink-dim);
}

/* An item with one action at its right end. */
.list-item-action {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-s);
}
/* Logo: design/foundations/assets.md. The mark, then the name. */
.logo {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  gap: var(--space-2xs);
  color: var(--color-ink);
  text-decoration: none;
}

.logo-mark {
  inline-size: var(--size-logo-mark);
  block-size: var(--size-logo-mark);
  flex-shrink: 0;
  fill: var(--color-accent);
}

.logo-name {
  font-size: var(--text-heading-size);
  line-height: var(--text-heading-line);
  font-variation-settings: "wght" var(--text-logo-weight);
}

/* Menu: design/components/menu.md. It opens as a popover, 3xs below its
   trigger. The trigger sets which edge it lines up with. */
.menu {
  inset: auto;
  margin: var(--space-3xs) 0 0;
  inline-size: var(--width-menu);
  padding-block: var(--space-2xs);
  border-radius: var(--radius-soft);
  background: var(--color-surface);
  box-shadow: var(--shadow-popover);
  position-area: block-end span-inline-start;

  & a, & button {
  font-size: var(--text-button-small-size);
  line-height: var(--text-button-small-line);
  font-variation-settings: "wght" var(--text-button-small-weight);
  letter-spacing: var(--text-button-small-tracking);
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    inline-size: calc(100% - var(--space-3xs) * 2);
    block-size: var(--height-menu-item);
    margin-inline: var(--space-3xs);
    padding-inline: calc(var(--space-xs) - var(--space-3xs));
    border-radius: var(--radius-soft);
    color: var(--color-ink);
    text-decoration: none;
    text-align: start;
    white-space: nowrap;
    cursor: pointer;

    & .icon { --size-icon: var(--size-menu-icon); flex-shrink: 0; }
  }

  & a:focus-visible, & button:focus-visible { background: var(--color-panel); outline: none; }
  @media (hover: hover) { & a:hover, & button:hover { background: var(--color-panel); } }
}

/* A destructive item goes last, below a divider. */
.menu-divider {
  block-size: var(--line-hairline);
  margin-block: var(--space-2xs);
  background: var(--color-line-soft);
}

.menu .menu-destructive { color: var(--color-error); }

/* Row menu trigger: at the right end of a table row. */
.menu-trigger {
  --size-icon: var(--size-menu-trigger-icon);
  display: inline-grid;
  place-items: center;
  vertical-align: middle;
  inline-size: var(--size-menu-trigger);
  block-size: var(--size-menu-trigger);
  margin-block: calc((var(--text-body-line) - var(--size-menu-trigger)) / 2);
  margin-inline-end: calc((var(--size-menu-trigger-icon) - var(--size-menu-trigger)) / 2);
  border-radius: var(--radius-circle);
  color: var(--color-ink-soft);
  cursor: pointer;

  @media (hover: hover) { &:hover { background: var(--color-hover); } }
}

/* A menu item that is a form's button. */
.menu form { display: contents; }

/* A line of text at the top of a menu, like who is signed in. */
.menu-note {
  font-size: var(--text-caption-size);
  line-height: var(--text-caption-line);
  font-variation-settings: "wght" var(--text-caption-weight);
  letter-spacing: var(--text-caption-tracking);
  padding: var(--space-3xs) var(--space-xs) var(--space-2xs);
  color: var(--color-ink-soft);
}

/* A menu on the floor: a line's actions, with the stations folded under Move to. */
.line-menu {
  inline-size: -moz-max-content;
  inline-size: max-content;
  min-inline-size: var(--width-menu);
  max-block-size: 70vh;
  overflow-y: auto;

  & summary {
  font-size: var(--text-button-small-size);
  line-height: var(--text-button-small-line);
  font-variation-settings: "wght" var(--text-button-small-weight);
  letter-spacing: var(--text-button-small-tracking);
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    block-size: var(--height-menu-item);
    margin-inline: var(--space-3xs);
    padding-inline: calc(var(--space-xs) - var(--space-3xs));
    border-radius: var(--radius-soft);
    list-style: none;
    cursor: pointer;

    & .icon { --size-icon: var(--size-menu-icon); }
    &::-webkit-details-marker { display: none; }
  }

  & details[open] summary { background: var(--color-panel); }
  & details button { padding-inline-start: calc(var(--space-xs) + var(--size-menu-icon)); }
}
/* Nav: design/components/nav.md. */
.nav {
  block-size: var(--height-nav);
  background: var(--color-surface);
  border-radius: var(--radius-square);
  /* The hairline along the bottom, inside the height. */
  box-shadow: inset 0 calc(var(--line-hairline) * -1) 0 var(--color-line);
}

/* The content, inside the page width. */
.nav-bar {
  display: flex;
  align-items: center;
  block-size: 100%;
}

.nav-logo { display: inline-flex; text-decoration: none; }

.nav-items {
  display: flex;
  align-self: stretch;
  gap: var(--space-m);
  margin-inline-start: var(--space-m);
}

.nav-item {
  font-size: var(--text-nav-size);
  line-height: var(--text-nav-line);
  font-variation-settings: "wght" var(--text-nav-weight);
  letter-spacing: var(--text-nav-tracking);
  position: relative;
  display: flex;
  align-items: center;
  color: var(--color-ink);
  text-decoration: none;
  white-space: nowrap;
}

/* The active line: as wide as the label, just above the hairline. */
.nav-item[aria-current="page"]::after {
  content: "";
  position: absolute;
  inset-inline: 0;
  inset-block-end: var(--line-hairline);
  block-size: var(--line-nav-active);
  border-radius: var(--radius-pill);
  background: var(--color-ink);
}

.nav-user {
  display: flex;
  align-items: center;
  gap: var(--space-3xs);
  margin-inline-start: auto;
  cursor: pointer;
  text-align: start;
  color: var(--color-ink);

  & > .icon {
    --size-icon: var(--size-nav-caret);
    margin-inline-start: calc(var(--space-2xs) - var(--space-3xs));
  }
}

.nav-user-text { display: grid; }
.nav-user-name {
  font-size: var(--text-label-size);
  line-height: var(--text-label-line);
  font-variation-settings: "wght" var(--text-label-weight);
  letter-spacing: var(--text-label-tracking); }
.nav-user-role {
  font-size: var(--text-micro-size);
  line-height: var(--text-micro-line);
  font-variation-settings: "wght" var(--text-micro-weight);
  letter-spacing: var(--text-micro-tracking); color: var(--color-ink-dim); }

/* Small screens: the items fold into a menu button. */
.nav-toggle { display: none; }

.nav-menu {
  position-area: block-end span-inline-end;

  & a[aria-current="page"] { background: var(--color-panel); }
}

.nav-user-menu { position-area: block-end span-inline-start; }

@media (max-width: 800px) {
  .nav-toggle { display: inline-flex; margin-inline-start: var(--space-2xs); }
  .nav-items { display: none; }
  /* The user shows the avatar and caret only. */
  .nav-user-text { display: none; }
}

/* Widening the window with the menu open leaves it to the inline items. */
@media (min-width: 800.02px) {
  .nav-menu:popover-open { display: none; }
}
/* Work order form: design/pages/orders/_form.md. */

/* Touch screens: room for the on-screen keyboard below the last field, so the
   page does not grow and shrink, and jump, as it opens and closes. */
@media (pointer: coarse) {
  .order-form { padding-block-end: 50vh; }
}

.order-form-count {
  font-size: var(--text-caption-size);
  line-height: var(--text-caption-line);
  font-variation-settings: "wght" var(--text-caption-weight);
  letter-spacing: var(--text-caption-tracking); margin-inline-end: auto; color: var(--color-ink-soft); }

/* Page header: design/components/page-header.md. */
.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-s);
}

/* The back link above the title, xs apart. */
.page-header-main {
  display: grid;
  justify-items: start;
  gap: var(--space-xs);
}

.page-header-title { color: var(--color-ink); white-space: nowrap; }

/* The title, then the status badge xs after it, centered on it. */
.page-header-heading {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  min-inline-size: 0;
  max-inline-size: 100%;

  & > .badge { flex-shrink: 0; }
}

.page-header-subtitle {
  font-size: var(--text-body-size);
  line-height: var(--text-body-line);
  font-variation-settings: "wght" var(--text-body-weight);
  letter-spacing: var(--text-body-tracking);
  margin-block-start: calc(var(--space-3xs) - var(--space-xs));
  color: var(--color-ink-soft);

  & a { color: var(--color-accent-ink); text-decoration: none; }
  @media (hover: hover) { & a:hover { text-decoration: underline; } }
}

/* Actions are 2xs apart. Search and the first action are s apart. */
.page-header-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2xs);
}

.page-header-search {
  inline-size: var(--width-page-header-search);
  max-inline-size: 100%;
  margin-inline-end: calc(var(--space-s) - var(--space-2xs));
}

/* Small screens: the actions drop under the title, left aligned, and wrap.
   Search fills the width, on a row of its own above them. */
@media (max-width: 800px) {
  .page-header-main, .page-header-actions { flex-basis: 100%; }
  .page-header-main { min-inline-size: 0; }
  .page-header-title { overflow: hidden; text-overflow: ellipsis; max-inline-size: 100%; }
  .page-header-search { inline-size: 100%; margin-inline-end: 0; }
}
/* Pagination: design/components/pagination.md. */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-s);
  margin-block-start: var(--space-s);
}

.pagination-count, .pagination-page {
  font-size: var(--text-caption-size);
  line-height: var(--text-caption-line);
  font-variation-settings: "wght" var(--text-caption-weight);
  letter-spacing: var(--text-caption-tracking); color: var(--color-ink-soft); }

.pagination-controls {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

/* Can't move: only the icon dims. */
.pagination .button[disabled] {
  opacity: 1;

  & .icon { color: var(--color-ink-dim); }
}
/* Photo card: design/components/photo-card.md. */
.photo-card {
  position: relative;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  border-radius: var(--radius-soft);
  background: var(--color-surface);
  box-shadow: var(--shadow-card);
  color: var(--color-ink);
  -moz-user-select: none;
       user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;

  /* On hold, and selected: a border inside the edge, over the photo. */
  &.is-held::before, &.is-selected::before, &.is-active::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 3;
    border: var(--line-photo-card) solid var(--color-amber);
    border-radius: inherit;
    pointer-events: none;
  }

  &.is-selected::before, &.is-active::before { border-color: var(--color-ink); }
  &.is-dragging { opacity: var(--opacity-dragging); }

  /* The browser's own image and link dragging would cancel a card drag. */
  & :is(img, a) { -webkit-user-drag: none; }
}

.photo-card-photo {
  position: relative;
  aspect-ratio: var(--ratio-photo-card);
  overflow: hidden;
  border-start-start-radius: var(--radius-soft);
  border-start-end-radius: var(--radius-soft);
  background: var(--color-panel);
}

.photo-card-image { inline-size: 100%; block-size: 100%; -o-object-fit: cover; object-fit: cover; }

.photo-card-empty {
  --size-icon: var(--size-photo-card-icon);
  display: grid;
  place-items: center;
  block-size: 100%;
  color: var(--color-ink-dim);
}

/* On the photo, xs in from its edges. */
.photo-card-due, .photo-card-qty, .photo-card-select { position: absolute; z-index: 1; }
.photo-card-due { inset-block-start: var(--space-xs); inset-inline-start: var(--space-xs); }

/* Due, on a photo: design/components/due.md. A tint washes out over a photo,
   so it is solid with white text, in the shape of the quantity. Green, orange
   and red: soon and today share the orange, because white does not read on amber. */
.photo-card-due {
  padding-inline: var(--space-2xs);
  border-radius: var(--radius-soft);
  color: var(--color-on-fill);

  &.due-on-time { background: var(--color-green); }
  &.due-soon, &.due-today { background: var(--color-accent); }
  &.due-overdue { background: var(--color-red); }

  &.due-neutral {
  font-size: var(--text-caption-strong-size);
  line-height: var(--text-caption-strong-line);
  font-variation-settings: "wght" var(--text-caption-strong-weight);
  letter-spacing: var(--text-caption-strong-tracking);
    block-size: var(--height-due);
    padding-inline: var(--space-2xs);
    background: var(--color-ink);
  }
}

.photo-card-qty {
  font-size: var(--text-caption-strong-size);
  line-height: var(--text-caption-strong-line);
  font-variation-settings: "wght" var(--text-caption-strong-weight);
  letter-spacing: var(--text-caption-strong-tracking);
  inset-block-start: var(--space-xs);
  inset-inline-end: var(--space-xs);
  display: grid;
  place-items: center;
  block-size: var(--height-flag);
  padding-inline: var(--space-2xs);
  border-radius: var(--radius-soft);
  background: var(--color-ink);
  color: var(--color-on-fill);
  font-variant-numeric: tabular-nums;
}

.photo-card-caption {
  display: grid;
  gap: var(--space-3xs);
  min-inline-size: 0;
  padding: var(--space-xs) var(--space-s);
}

.photo-card-title {
  font-size: var(--text-subheading-size);
  line-height: var(--text-subheading-line);
  font-variation-settings: "wght" var(--text-subheading-weight);
  letter-spacing: var(--text-subheading-tracking); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.photo-card-link { color: inherit; text-decoration: none; }
/* Flags, then the work order's labels: a row under the detail, xs below it.
   The row wraps, so none is cut off. */
.photo-card-flags {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3xs);
  min-inline-size: 0;
  margin-block-start: calc(var(--space-xs) - var(--space-3xs));
}

.photo-card-meta {
  font-size: var(--text-caption-size);
  line-height: var(--text-caption-line);
  font-variation-settings: "wght" var(--text-caption-weight);
  letter-spacing: var(--text-caption-tracking); overflow: hidden; color: var(--color-ink-soft); white-space: nowrap; text-overflow: ellipsis; }

/* A tap anywhere on the card raises its action bar. The select mark sits above this. */
.photo-card-open { position: absolute; inset: 0; z-index: 2; inline-size: 100%; cursor: pointer; }

/* The select mark, only while cards are being selected. */
.photo-card-select {
  --size-icon: var(--size-flag-icon);
  z-index: 4;
  inset-block-end: var(--space-xs);
  inset-inline-end: var(--space-xs);
  display: none;
  place-items: center;
  inline-size: var(--size-photo-card-select);
  block-size: var(--size-photo-card-select);
  border: var(--line-hairline) solid var(--color-control-line);
  border-radius: var(--radius-circle);
  background: var(--color-surface);
  color: transparent;
  cursor: pointer;
}

.board.is-selecting .photo-card-select { display: grid; }
.board.is-selecting .photo-card { cursor: pointer; }

.photo-card.is-selected .photo-card-select {
  display: grid;
  border-color: var(--color-ink);
  background: var(--color-ink);
  color: var(--color-on-fill);
}

/* The copy that follows the pointer during a drag. Its count hangs off the corner. */
.line-card-ghost {
  position: fixed;
  inset-block-start: 0;
  inset-inline-start: 0;
  z-index: 100;
  margin: 0;
  box-shadow: var(--shadow-popover);
  pointer-events: none;

  &[data-count]::after {
  font-size: var(--text-caption-strong-size);
  line-height: var(--text-caption-strong-line);
  font-variation-settings: "wght" var(--text-caption-strong-weight);
  letter-spacing: var(--text-caption-strong-tracking);
    content: attr(data-count);
    position: absolute;
    inset-block-start: calc(var(--space-xs) * -1);
    inset-inline-end: calc(var(--space-xs) * -1);
    display: grid;
    place-items: center;
    inline-size: var(--size-photo-card-select);
    block-size: var(--size-photo-card-select);
    border-radius: var(--radius-circle);
    background: var(--color-ink);
    color: var(--color-on-fill);
  }
}
/* Photo viewer: design/components/photo-viewer.md. */
.photo-viewer-dialog {
  inline-size: 100vw;
  block-size: 100dvh;
  max-inline-size: 100vw;
  max-block-size: 100dvh;
  margin: 0;
  padding: 0;
  background: var(--color-ink);
  color: var(--color-on-fill);

  &::backdrop { background: var(--color-ink); }
}

/* The photo fills the window above the bottom area. The pill and the buttons
   float over its top. The left and right edges are previous and next. */
.photo-viewer {
  position: relative;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  block-size: 100dvh;
  overflow: hidden;
  -moz-user-select: none;
       user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;

  & img { -webkit-user-drag: none; }
  & > .error-well { position: absolute; inset: calc(var(--size-viewer-button) + var(--space-s)) var(--space-s) auto; z-index: 4; }
}

.photo-viewer-header {
  position: absolute;
  inset: 0 0 auto;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-xs) var(--space-s);
  pointer-events: none;

  & > * { pointer-events: auto; }
}

.photo-viewer-close, .photo-viewer-add {
  --size-icon: var(--size-viewer-button-icon);
  display: grid;
  place-items: center;
  inline-size: var(--size-viewer-button);
  block-size: var(--size-viewer-button);
  border-radius: var(--radius-circle);
  color: var(--color-on-fill);
  cursor: pointer;

  & .icon { filter: var(--shadow-on-photo); }
  /* The dialog focuses the close button when it opens, so it wears no ring. */
  &:focus, &:focus-visible { outline: none; }
}

.photo-viewer-stage {
  position: relative;
  z-index: 1;
  min-block-size: 0;
  touch-action: pan-y;
}

.photo-viewer-slide {
  position: absolute;
  inset: 0;
  margin: 0;

  &[hidden] { display: none; }

  & img {
    display: block;
    inline-size: 100%;
    block-size: 100%;
    padding-block-start: calc(var(--size-viewer-button) + var(--space-xs) * 2);
    -o-object-fit: contain;
       object-fit: contain;
  }
}

/* What the photo is, and when it was taken. */
.photo-viewer-pill {
  font-size: var(--text-label-size);
  line-height: var(--text-label-line);
  font-variation-settings: "wght" var(--text-label-weight);
  letter-spacing: var(--text-label-tracking);
  position: absolute;
  inset: var(--space-xs) auto auto 50%;
  z-index: 3;
  translate: -50% 0;
  display: grid;
  justify-items: center;
  max-inline-size: calc(100% - var(--size-viewer-button) * 4);
  padding: var(--space-2xs) var(--space-m);
  border-radius: var(--radius-pill);
  background: var(--color-ink-veil);
  pointer-events: none;

  & strong { max-inline-size: 100%; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
  & time {
  font-size: var(--text-caption-size);
  line-height: var(--text-caption-line);
  font-variation-settings: "wght" var(--text-caption-weight);
  letter-spacing: var(--text-caption-tracking); color: var(--color-on-fill-soft); }
}

.photo-viewer-nav {
  --size-icon: var(--size-viewer-nav-icon);
  position: absolute;
  inset-block: 0;
  z-index: 2;
  display: grid;
  place-items: center;
  inline-size: var(--width-viewer-nav);
  color: var(--color-on-fill);
  cursor: pointer;

  & .icon { filter: var(--shadow-on-photo); }
  &.prev { inset-inline-start: 0; }
  &.next { inset-inline-end: 0; }
}

.photo-viewer-empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--color-on-fill-soft); }

.photo-viewer-footer {
  display: grid;
  justify-items: center;
  gap: var(--space-xs);
  padding: var(--space-xs) var(--space-s) var(--space-s);
}

.photo-viewer-counter {
  font-size: var(--text-label-size);
  line-height: var(--text-label-line);
  font-variation-settings: "wght" var(--text-label-weight);
  letter-spacing: var(--text-label-tracking); color: var(--color-on-fill-soft); }

.photo-viewer-thumbs {
  display: flex;
  gap: var(--space-2xs);
  max-inline-size: 100%;
  /* Room for the current thumb's outline. */
  padding: var(--space-2xs);
  overflow-x: auto;

  & button {
    flex-shrink: 0;
    inline-size: var(--size-viewer-thumb);
    block-size: var(--size-viewer-thumb);
    overflow: hidden;
    border-radius: var(--radius-soft);
    opacity: var(--opacity-viewer-thumb);
    cursor: pointer;
  }

  & button.is-current { opacity: 1; outline: var(--line-viewer-current) solid var(--color-on-fill); outline-offset: var(--line-hairline); }
  & img { inline-size: 100%; block-size: 100%; -o-object-fit: cover; object-fit: cover; }
}

/* Print: design/components/print.md. On screen: a toolbar and a preview. On
   paper: only the document, black on white. */
.print-toolbar {
  position: sticky;
  inset-block-start: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: var(--space-s);
  block-size: var(--height-print-toolbar);
  padding-inline: var(--space-s);
  background: var(--color-canvas);

  & p {
  font-size: var(--text-subheading-size);
  line-height: var(--text-subheading-line);
  font-variation-settings: "wght" var(--text-subheading-weight);
  letter-spacing: var(--text-subheading-tracking); margin-inline-end: auto; }
}

/* Printed work order */
.wo-print {
  display: grid;
  gap: var(--space-print-section);
  max-inline-size: var(--width-print-page);
  margin: 0 auto;
  padding-block: var(--padding-print-page);
  color: var(--color-print);
}

.wo-print-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding-block-end: var(--space-s);
  border-block-end: var(--line-hairline) solid var(--color-print);
}

.wo-print-title {
  font-size: var(--text-heading-size);
  line-height: var(--text-heading-line);
  font-variation-settings: "wght" var(--text-heading-weight);
  letter-spacing: var(--text-heading-tracking); }
.wo-print-number {
  font-size: var(--text-subheading-size);
  line-height: var(--text-subheading-line);
  font-variation-settings: "wght" var(--text-subheading-weight);
  letter-spacing: var(--text-subheading-tracking); }
.wo-print-small {
  font-size: var(--text-caption-size);
  line-height: var(--text-caption-line);
  font-variation-settings: "wght" var(--text-caption-weight);
  letter-spacing: var(--text-caption-tracking); }
.wo-print-end { text-align: end; }
.wo-print-label {
  font-size: var(--text-caption-strong-size);
  line-height: var(--text-caption-strong-line);
  font-variation-settings: "wght" var(--text-caption-strong-weight);
  letter-spacing: var(--text-caption-strong-tracking); margin-block-end: var(--space-3xs); }
.wo-print-name {
  font-size: var(--text-subheading-size);
  line-height: var(--text-subheading-line);
  font-variation-settings: "wght" var(--text-subheading-weight);
  letter-spacing: var(--text-subheading-tracking); }

.wo-print-facts, .wo-print-items {
  inline-size: 100%;
  border-collapse: collapse;

  & th {
  font-size: var(--text-caption-strong-size);
  line-height: var(--text-caption-strong-line);
  font-variation-settings: "wght" var(--text-caption-strong-weight);
  letter-spacing: var(--text-caption-strong-tracking); padding-block: 0 var(--space-2xs); border-block-end: var(--line-hairline) solid var(--color-print); text-align: start; }
  & td { padding-block: var(--space-2xs); border-block-end: var(--line-hairline) solid var(--color-line); }
}

.wo-print-facts { table-layout: fixed; }
.wo-print-items :is(th, td):nth-child(-n + 2) { inline-size: var(--width-print-column); }

.wo-print-customer { display: flex; justify-content: space-between; gap: var(--space-print-section); }
.wo-print-logo { max-inline-size: var(--width-print-logo); max-block-size: var(--height-print-logo); -o-object-fit: contain; object-fit: contain; }

.wo-print-photo-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-print-photos);
  margin-block-start: var(--space-2xs);

  & img { inline-size: 100%; aspect-ratio: 4 / 3; -o-object-fit: contain; object-fit: contain; -moz-column-break-inside: avoid; break-inside: avoid; background: var(--color-panel); }
}

/* Tag. Its width and height come from Settings, in the page's own style. */
.tag {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: var(--padding-tag);
  margin: var(--space-s) auto;
  padding: var(--padding-tag) var(--padding-tag) var(--padding-tag) var(--space-tag-hole);
  overflow: hidden;
  border: var(--line-hairline) solid var(--color-line);
  background: var(--color-paper);
  color: var(--color-print);
  -moz-column-break-after: page;
       break-after: page;
}

.tag-qr svg { display: block; inline-size: var(--size-tag-qr); block-size: var(--size-tag-qr); }
.tag-text { display: grid; min-inline-size: 0; }
.tag-customer {
  font-size: var(--text-caption-strong-size);
  line-height: var(--text-caption-strong-line);
  font-variation-settings: "wght" var(--text-caption-strong-weight);
  letter-spacing: var(--text-caption-strong-tracking); }
.tag-label { white-space: nowrap; font-size: var(--text-tag-label-size); line-height: 1; font-variation-settings: "wght" var(--text-tag-label-weight); }
.tag-material {
  font-size: var(--text-label-size);
  line-height: var(--text-label-line);
  font-variation-settings: "wght" var(--text-label-weight);
  letter-spacing: var(--text-label-tracking); overflow-wrap: anywhere; }
.tag-dates {
  font-size: var(--text-caption-size);
  line-height: var(--text-caption-line);
  font-variation-settings: "wght" var(--text-caption-weight);
  letter-spacing: var(--text-caption-tracking); margin-block-start: var(--space-2xs); }
.tag-none { padding: var(--space-g); color: var(--color-ink-soft); }

@media print {
  .print-toolbar { display: none; }
  .wo-print { max-inline-size: none; padding: 0; }
  .wo-print-photo-grid img { background: none; }
  .tag { margin: 0; border: 0; }
}

/* Scanned tag: design/pages/lines/show.md. */
.scan-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: var(--space-g);

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

.scan-eyebrow, .scan-photo-note, .scan-since {
  font-size: var(--text-caption-size);
  line-height: var(--text-caption-line);
  font-variation-settings: "wght" var(--text-caption-weight);
  letter-spacing: var(--text-caption-tracking); color: var(--color-ink-soft); }
.scan-customer {
  font-size: var(--text-label-size);
  line-height: var(--text-label-line);
  font-variation-settings: "wght" var(--text-label-weight);
  letter-spacing: var(--text-label-tracking); margin-block-start: var(--space-3xs); }
.scan-meta { color: var(--color-ink-soft); }
.scan-photo { display: grid; gap: var(--space-2xs); align-content: start; }
.scan-side { display: grid; gap: var(--space-s); align-content: start; }
.scan-station { display: flex; align-items: center; justify-content: space-between; gap: var(--space-s); }
.scan-station-name {
  font-size: var(--text-heading-size);
  line-height: var(--text-heading-line);
  font-variation-settings: "wght" var(--text-heading-weight);
  letter-spacing: var(--text-heading-tracking); color: var(--color-ink); }
.scan-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-2xs); & > .button { inline-size: 100%; } & form { display: contents; } }
.scan-moves { display: grid; gap: var(--space-2xs); & form { display: contents; } }

/* Opened by itself, not over a board: a card on the page. */
.scan-page {
  position: relative;
  isolation: isolate;
  background-color: var(--color-canvas);

  &::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    background: var(--page-background-image) 0 0 / var(--page-background-size) repeat;
    opacity: var(--page-background-opacity);
    pointer-events: none;
  } flex: 1; overflow-y: auto; padding: var(--space-g); & .modal-content { margin-inline: auto; max-block-size: none; box-shadow: var(--shadow-card); } }

/* The tag scanner: a frame over the camera picture. */
.scanner-stage { position: relative; overflow: hidden; border-radius: var(--radius-soft); background: var(--color-ink); aspect-ratio: 4 / 3; & .camera-preview { position: absolute; inset: 0; } }

.scanner-frame {
  position: absolute;
  inset: 20%;
  border: var(--line-scanner-frame) solid var(--color-surface);
  border-radius: var(--radius-soft);
  box-shadow: 0 0 0 100vmax var(--color-scanner-dim);
}

.scanner-status {
  font-size: var(--text-caption-size);
  line-height: var(--text-caption-line);
  font-variation-settings: "wght" var(--text-caption-weight);
  letter-spacing: var(--text-caption-tracking); margin-block-start: var(--space-xs); color: var(--color-ink-soft); }

/* Segmented control: design/components/segmented.md. */
.segmented {
  display: flex;
  flex-shrink: 0;
  block-size: var(--height-tap-target);
  padding: var(--space-3xs);
  border: var(--line-hairline) solid var(--color-control-line);
  border-radius: var(--radius-pill);
  background: var(--color-surface);
  box-shadow: var(--shadow-inset);

  & > a, & > label {
  font-size: var(--text-button-small-size);
  line-height: var(--text-button-small-line);
  font-variation-settings: "wght" var(--text-button-small-weight);
  letter-spacing: var(--text-button-small-tracking);
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2xs);
    padding-inline: var(--space-s);
    border-radius: var(--radius-pill);
    color: var(--color-ink);
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
  }

  & > a[aria-current="page"], & > label:has(input:checked) {
    background: var(--color-ink);
    color: var(--color-on-fill);

    & .segmented-count { color: var(--color-on-fill-soft); }
  }

  & > label:has(input:focus-visible) { outline: var(--line-focus) solid var(--color-focus); }
  & input[type="radio"] { position: absolute; opacity: 0; pointer-events: none; }
}

.segmented-count { color: var(--color-ink-dim); font-variant-numeric: tabular-nums; }
.segmented-fields { margin: 0; min-inline-size: 0; }
.segmented-large { block-size: var(--height-segmented-large); }
/* Settings: design/components/settings.md. */
.settings {
  display: grid;
  grid-template-columns: var(--width-settings-nav) minmax(0, 1fr);
  gap: var(--space-m);
  align-items: start;

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

.settings-nav {
  display: flex;
  flex-direction: column;

  & a {
  font-size: var(--text-nav-size);
  line-height: var(--text-nav-line);
  font-variation-settings: "wght" var(--text-nav-weight);
  letter-spacing: var(--text-nav-tracking);
    position: relative;
    display: flex;
    align-items: center;
    block-size: var(--height-settings-nav-item);
    padding-inline: calc(var(--space-xs) + var(--line-settings-nav-active));
    border-radius: var(--radius-soft);
    color: var(--color-ink);
    text-decoration: none;
  }

  & a:focus-visible { background: var(--color-surface); }
  @media (hover: hover) { & a:hover { background: var(--color-surface); } }

  /* The active line, at the left edge. */
  & a[aria-current="page"]::before {
    content: "";
    position: absolute;
    inset-inline-start: 0;
    inline-size: var(--line-settings-nav-active);
    block-size: var(--height-settings-nav-active);
    border-radius: var(--radius-pill);
    background: var(--color-ink);
  }
}

/* Add form: one row under a list. The fields, then the button. */
.settings-add {
  display: flex;
  align-items: center;
  gap: var(--space-2xs);
  margin-block-start: var(--space-s);

  & > .field { flex: 1; min-inline-size: 0; }
  & > .settings-add-fixed { flex: none; }
  & > .button { margin-inline-start: calc(var(--space-s) - var(--space-2xs)); }

  /* Small screens: the fields stack and fill the width. The button follows. */
  @media (max-width: 800px) {
    flex-direction: column;
    align-items: stretch;

    & > .field, & > .settings-add-fixed { flex: none; inline-size: 100% !important; }
    & > .button { align-self: flex-start; margin-inline-start: 0; }
  }
}
/* Station progress: design/components/station-progress.md. */

/* Grid: six station icons in a row. A bubble over an icon counts the lines there. */
.station-progress {
  display: inline-flex;
  vertical-align: middle;
  gap: var(--space-3xs);
}

/* One column per station. The first row keeps the room for a bubble and its
   pointer, so the icons line up whether or not a station has lines. */
.station-progress-cell {
  --station-progress-fill: var(--color-line);
  display: grid;
  grid-template-rows: calc(var(--height-station-progress-bubble) + var(--height-station-progress-pointer)) auto;
  row-gap: var(--space-3xs);
  justify-items: center;
  inline-size: var(--size-station-progress-cell);
  color: var(--color-ink-dim);

  &.is-filled { color: var(--color-ink); }
  &.is-held { --station-progress-fill: var(--color-amber); }

  & > .icon { --size-icon: var(--size-station-progress-icon); grid-row: 2; display: block; }
}

.station-progress-bubble {
  font-size: var(--text-initials-size);
  line-height: var(--text-initials-line);
  font-variation-settings: "wght" var(--text-initials-weight);
  letter-spacing: var(--text-initials-tracking);
  position: relative;
  grid-row: 1;
  align-self: start;
  min-inline-size: var(--size-station-progress-cell);
  block-size: var(--height-station-progress-bubble);
  padding-inline: var(--space-3xs);
  border-radius: var(--radius-soft);
  background: var(--station-progress-fill);
  color: var(--color-ink);
  text-align: center;

  &::after {
    content: "";
    position: absolute;
    inset-block-start: 100%;
    inset-inline-start: 50%;
    translate: -50% 0;
    inline-size: var(--width-station-progress-pointer);
    block-size: var(--height-station-progress-pointer);
    background: var(--station-progress-fill);
    clip-path: polygon(0 0, 100% 0, 50% 100%);
  }
}

.station-progress-waiting {
  font-size: var(--text-caption-size);
  line-height: var(--text-caption-line);
  font-variation-settings: "wght" var(--text-caption-weight);
  letter-spacing: var(--text-caption-tracking); color: var(--color-ink-soft); }

/* Strip: a card with no title and no padding, split into six equal cells. */
.station-progress-strip {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  block-size: var(--height-station-progress-strip);
  padding: 0;
}

.station-progress-station {
  display: grid;
  align-content: center;
  gap: var(--space-3xs);
  padding-inline: var(--space-s);
  color: var(--color-ink-dim);

  & + & { border-inline-start: var(--line-hairline) solid var(--color-line-soft); }
  &.is-filled { color: var(--color-ink-soft); }
}

/* Small screens: two rows of three cells, with a hairline between the rows. */
@media (max-width: 800px) {
  .station-progress-strip {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-auto-rows: var(--height-station-progress-strip);
    block-size: auto;
  }

  .station-progress-station:nth-child(3n + 1) { border-inline-start: 0; }
  .station-progress-station:nth-child(n + 4) { border-block-start: var(--line-hairline) solid var(--color-line-soft); }
}

/* The top line: the icon, then the name. The name is cut off, never the icon. */
.station-progress-label {
  display: flex;
  align-items: center;
  gap: var(--space-3xs);
  min-inline-size: 0;

  & > .icon { --size-icon: var(--size-station-progress-strip-icon); flex-shrink: 0; }
}

.station-progress-name {
  font-size: var(--text-caption-strong-size);
  line-height: var(--text-caption-strong-line);
  font-variation-settings: "wght" var(--text-caption-strong-weight);
  letter-spacing: var(--text-caption-strong-tracking); min-inline-size: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.station-progress-count {
  font-size: var(--text-heading-size);
  line-height: var(--text-heading-line);
  font-variation-settings: "wght" var(--text-heading-weight);
  letter-spacing: var(--text-heading-tracking); .is-filled > & { color: var(--color-ink); } }

/* The strip's title, straight on the page background, xs above it. */
.station-progress-title {
  font-size: var(--text-subheading-size);
  line-height: var(--text-subheading-line);
  font-variation-settings: "wght" var(--text-subheading-weight);
  letter-spacing: var(--text-subheading-tracking); color: var(--color-ink); }
/* Stepper: design/components/stepper.md. */
.stepper {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: var(--space-2xs);
  padding: var(--space-2xs);
  border-radius: var(--radius-soft);
  background: var(--color-panel);

  & .button-icon { inline-size: var(--size-stepper-button); block-size: var(--size-stepper-button); }
}

.stepper .stepper-value {
  font-size: var(--text-display-size);
  line-height: var(--text-display-line);
  font-variation-settings: "wght" var(--text-display-weight);
  letter-spacing: var(--text-display-tracking);
  block-size: var(--size-stepper-button);
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: var(--shadow-flat);
  text-align: center;
}

/* Switch: design/components/checker.md. The checkbox is hidden and its track
   draws the state. */
.switch { position: relative; display: inline-flex; }

.switch-track {
  inline-size: var(--width-switch);
  block-size: var(--height-switch);
  border-radius: var(--radius-pill);
  background: var(--color-line);
  transition: background-color var(--duration-sm) ease;

  &::after {
    content: "";
    position: absolute;
    inset-block-start: calc((var(--height-switch) - var(--size-switch-knob)) / 2);
    inset-inline-start: calc((var(--height-switch) - var(--size-switch-knob)) / 2);
    inline-size: var(--size-switch-knob);
    block-size: var(--size-switch-knob);
    border-radius: var(--radius-circle);
    background: var(--color-surface);
    box-shadow: var(--shadow-control);
    transition: translate var(--duration-sm) ease;
  }
}

.switch:has(input:checked) .switch-track { background: var(--color-ink); }
.switch:has(input:checked) .switch-track::after { translate: calc(var(--width-switch) - var(--height-switch)) 0; }
.switch:has(input:focus-visible) .switch-track { outline: var(--line-focus) solid var(--color-focus); }
/* Table: design/components/table.md. */
th { text-align: start; }
table { border-collapse: collapse; }

/* Narrow containers: every table sits in a table-scroll. The table keeps its
   smallest width, set beside its cols, and scrolls sideways in here. Nothing
   else moves. The side room keeps focus rings and inline fields from being
   cut off; the negative margin gives it back. */
.table-scroll {
  /* Holds anything placed out of flow in a cell, so it scrolls too. */
  position: relative;
  overflow-x: auto;
  margin-inline: calc(var(--space-s) * -1);
  padding-inline: var(--space-s);
}

.table {
  inline-size: 100%;

  /* Column widths go on the cols. With them, long text is cut off. */
  &:has(colgroup) { table-layout: fixed; }

  & th {
  font-size: var(--text-caption-strong-size);
  line-height: var(--text-caption-strong-line);
  font-variation-settings: "wght" var(--text-caption-strong-weight);
  letter-spacing: var(--text-caption-strong-tracking);
    padding-block: 0 var(--space-2xs);
    border-block-end: var(--line-hairline) solid var(--color-line-soft);
    color: var(--color-ink-dim);
  }

  & td {
    padding-block: var(--space-xs);
    border-block-end: var(--line-hairline) solid var(--color-line-soft);
    color: var(--color-ink);
  }

  /* One line per cell, cut off with an ellipsis. Each cell but the last
     leaves xs before the next column. */
  & th, & td {
    padding-inline: 0 var(--space-xs);
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    vertical-align: middle;

    &:last-child { padding-inline-end: 0; }
  }

  & tbody tr:last-child td { border-block-end: 0; }
  & a { color: inherit; text-decoration: none; }
}

/* A pill in a cell does not make its row taller. */
.table td :is(.due, .flag) { margin-block: calc((var(--text-body-line) - var(--height-flag)) / 2); }

/* A list of badges or flags in a cell stays on one line, like any cell. The
   Flags cell of a Work order row is the exception: see work-order-row.css. */
.table td .badge-list { flex-wrap: nowrap; }

/* Cell options */
.table .table-soft { color: var(--color-ink-soft); }
.table .table-dim, .table .table-empty { color: var(--color-ink-dim); }
.table .table-accent { color: var(--color-accent-ink); }

/* Number columns: right aligned, header and cells. */
.table .table-number { text-align: end; font-variant-numeric: tabular-nums; }

/* A caption line under a value. */
.table-caption {
  font-size: var(--text-caption-size);
  line-height: var(--text-caption-line);
  font-variation-settings: "wght" var(--text-caption-weight);
  letter-spacing: var(--text-caption-tracking);
  display: block;
  margin-block-start: var(--space-3xs);
  overflow: hidden;
  color: var(--color-ink-dim);
  text-overflow: ellipsis;
}

/* A cell's text with flags and badges after it. The text is cut off first. */
.table-title {
  display: flex;
  align-items: center;
  gap: var(--space-2xs);

  & > :first-child { min-inline-size: 0; overflow: hidden; text-overflow: ellipsis; }
}

.table-marks { display: inline-flex; flex-shrink: 0; gap: var(--space-3xs); }

/* The one action at the right end of a row. */
.table .table-action { text-align: end; overflow: visible; padding-block: 0; & form { display: inline; } }

/* A row that is retired or turned off. */
.table .table-off td { color: var(--color-ink-dim); }

/* Header band: for the main table on a page, in a table card. The card draws
   the band edge to edge behind the header row. See card-table. */
.table-band th {
  block-size: var(--height-table-band);
  padding-block: 0;
  border-block-end: 0;
  color: var(--color-on-fill);
}

/* Fields in rows: no dividers, rows 2xs apart, each as tall as its field. */
.table-fields {
  & th, & td { border-block-end: 0; }
  & td { padding-block: 0 var(--space-2xs); overflow: visible; }
  & tbody tr:last-child td { padding-block-end: 0; }
}
/* Thumb: design/components/thumb.md. */
.thumb {
  --size-icon: var(--size-thumb-icon);
  display: inline-grid;
  place-items: center;
  flex-shrink: 0;
  inline-size: var(--width-thumb);
  block-size: var(--height-thumb);
  overflow: hidden;
  border: var(--line-hairline) solid var(--color-line);
  border-radius: var(--radius-soft);
  background: var(--color-panel);
  color: var(--color-ink-dim);

  & img { inline-size: 100%; block-size: 100%; -o-object-fit: cover; object-fit: cover; }
  &:has(img) { border: 0; }
}

/* Large: for a Work order row. */
.thumb-large {
  inline-size: var(--width-thumb-large);
  block-size: var(--height-thumb-large);
}

/* The big photo on a scanned tag: as wide as its column. */
.thumb-fill {
  --size-icon: var(--size-photo-card-icon);
  inline-size: 100%;
  block-size: auto;
  aspect-ratio: 4 / 3;
}

/* A thumb, then a row's text, in a table cell. */
.thumb-row {
  display: flex;
  align-items: center;
  gap: var(--space-s);
  min-inline-size: 0;

  & > :last-child { min-inline-size: 0; overflow: hidden; text-overflow: ellipsis; }
}
/* Tile and count: design/components/tile.md. */
.tile, .count {
  display: flex;
  flex-direction: column;
  block-size: var(--height-tile);
  padding: var(--space-s);
  border-radius: var(--radius-soft);
  background: var(--color-surface);
  box-shadow: var(--shadow-card);
  color: var(--color-ink);
  text-decoration: none;
}

.tile {
  font-size: var(--text-subheading-size);
  line-height: var(--text-subheading-line);
  font-variation-settings: "wght" var(--text-subheading-weight);
  letter-spacing: var(--text-subheading-tracking);
  --size-icon: var(--size-tile-icon);
  position: relative;
  justify-content: space-between;

  & > .badge { position: absolute; inset-block-start: var(--space-s); inset-inline-end: var(--space-s); }
}

.tile-primary {
  border: var(--line-hairline) solid var(--color-accent-line);
  background: linear-gradient(var(--color-accent-light), var(--color-accent-dark));
  box-shadow: var(--shadow-control-accent);
  color: var(--color-on-fill);
}

.tile-off { background: var(--color-surface-half); color: var(--color-ink-dim); }

.tile-title {
  font-size: var(--text-subheading-size);
  line-height: var(--text-subheading-line);
  font-variation-settings: "wght" var(--text-subheading-weight);
  letter-spacing: var(--text-subheading-tracking); color: var(--color-ink); }

.count { gap: var(--space-3xs); }
.count-number {
  font-size: var(--text-display-size);
  line-height: var(--text-display-line);
  font-variation-settings: "wght" var(--text-display-weight);
  letter-spacing: var(--text-display-tracking); }
.count-label {
  font-size: var(--text-caption-size);
  line-height: var(--text-caption-line);
  font-variation-settings: "wght" var(--text-caption-weight);
  letter-spacing: var(--text-caption-tracking); color: var(--color-ink-soft); }

.count-zero .count-number { color: var(--color-ink-dim); }
.count-alert { box-shadow: inset 0 0 0 var(--line-tile-state) var(--color-red), var(--shadow-card); & .count-number { color: var(--color-red); } }
.count-watch { box-shadow: inset 0 0 0 var(--line-tile-state) var(--color-amber), var(--shadow-card); & .count-number { color: var(--color-amber-ink); } }

/* A row of tiles or counts: the row composition, but s apart, not a gutter, so
   the row reads as one group. On a small screen it is two equal columns, s
   apart, with the rows s apart too, not one column. An odd last one sits alone
   in the left column, as wide as the others. */
.tile-row { gap: var(--space-s); }

@media (max-width: 800px) {
  .tile-row { grid-auto-flow: row; grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Toast: design/components/toast.md. */
.toast {
  font-size: var(--text-button-size);
  line-height: var(--text-button-line);
  font-variation-settings: "wght" var(--text-button-weight);
  letter-spacing: var(--text-button-tracking);
  position: fixed;
  inset-inline: 0;
  inset-block-end: var(--space-m);
  z-index: 30;
  inline-size: -moz-max-content;
  inline-size: max-content;
  max-inline-size: calc(100% - var(--space-g) * 2);
  min-block-size: var(--height-toast);
  margin-inline: auto;
  padding-inline: var(--space-s);
  border-radius: var(--radius-soft);
  background: var(--color-ink);
  box-shadow: var(--shadow-popover);
  color: var(--color-on-fill);
  -webkit-user-select: none;
     -moz-user-select: none;
          user-select: none;

  &:not([hidden]) {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    animation: toast-rise 600ms var(--ease-custom);
  }
}

.toast-icon {
  display: inline-grid;
  color: var(--color-green);

  & .icon { --size-icon: var(--size-toast-icon); }
}

.toast-icon-error { color: var(--color-red); }

.toast-close {
  --size-icon: var(--size-toast-icon);
  display: inline-grid;
  margin-inline-start: var(--space-xs);
  color: inherit;
  cursor: pointer;
}

@keyframes toast-rise {
  from { translate: 0 calc(100% + var(--space-m)); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .toast:not([hidden]) { animation: none; }
}

/* Weight and location dialogs: design/components/checker.md. */
.weights-dialog .modal-content { max-inline-size: var(--width-modal-floor); }
.weights-dialog .modal-footer { display: grid; gap: var(--space-2xs); }

.weights-entry, .weights, .pallet-fields { display: grid; gap: var(--space-2xs); }
.weights-head { display: flex; align-items: center; justify-content: space-between; }
.weights-title {
  font-size: var(--text-subheading-size);
  line-height: var(--text-subheading-line);
  font-variation-settings: "wght" var(--text-subheading-weight);
  letter-spacing: var(--text-subheading-tracking); color: var(--color-ink); }

/* A row: its label on the left, its number on the right. */
label.weights-row:is(label) {
  display: flex;
  align-items: center;
  inline-size: 100%;
  max-inline-size: none;
}

.weights-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-xs);
  inline-size: 100%;
  max-inline-size: none;
  cursor: pointer;

  & .row-label {
  font-size: var(--text-caption-size);
  line-height: var(--text-caption-line);
  font-variation-settings: "wght" var(--text-caption-weight);
  letter-spacing: var(--text-caption-tracking); color: var(--color-ink-soft); }
}

.weights-row-lead { display: flex; align-items: center; gap: var(--space-3xs); margin-inline-start: calc(var(--space-2xs) * -1); }

.weights-field {
  inline-size: var(--width-weights-field);

  & input { text-align: end; font-variant-numeric: tabular-nums; -webkit-appearance: textfield; -moz-appearance: textfield; appearance: textfield; }
  & input::-webkit-outer-spin-button, & input::-webkit-inner-spin-button { -webkit-appearance: none; appearance: none; margin: 0; }
}

/* A running total under its readings. */
.weights-total {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding-block-start: var(--space-2xs);
  border-block-start: var(--line-hairline) solid var(--color-line-soft);
  font-variant-numeric: tabular-nums;

  & span {
  font-size: var(--text-caption-size);
  line-height: var(--text-caption-line);
  font-variation-settings: "wght" var(--text-caption-weight);
  letter-spacing: var(--text-caption-tracking); color: var(--color-ink-soft); }
  & strong {
  font-size: var(--text-subheading-size);
  line-height: var(--text-subheading-line);
  font-variation-settings: "wght" var(--text-subheading-weight);
  letter-spacing: var(--text-subheading-tracking); color: var(--color-ink); }
  &.is-net { border-block-start-color: var(--color-ink); }
}

.pallet-group { display: grid; gap: var(--space-2xs); padding-block: var(--space-s); }
.pallet-fields[hidden], .weights-total[hidden] { display: none; }

/* Location: a grid of yard codes. A chosen one is filled. */
.yard-picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(var(--width-yard-option), 1fr)); gap: var(--space-2xs); }

.yard-picker > .yard-picker-option {
  inline-size: 100%;
  max-inline-size: none;

  &:has(input:checked) { border-color: var(--color-ink); background: var(--color-ink); box-shadow: var(--shadow-flat); color: var(--color-on-fill); }
  &:has(input:focus-visible) { outline: var(--line-focus) solid var(--color-focus); }
}

/* Work order card: design/components/work-order-card.md. On a small screen
   each work order row becomes one of these. */
.work-order-cards { display: none; }

@media (max-width: 800px) {
  .work-orders-table { display: none; }
  .work-order-cards { display: grid; gap: var(--space-g); }

  /* The card that holds the table is not shown. The cards sit straight on
     the page background. A titled card keeps its title. */
  .card:has(.work-order-cards) { padding: 0; background: none; box-shadow: none; }
}

.work-order-card {
  display: block;
  overflow: hidden;
  border-radius: var(--radius-soft);
  background: var(--color-surface);
  box-shadow: var(--shadow-card);
  color: var(--color-ink);
  text-decoration: none;
}

/* Photos: the full width, one per line, split into equal parts a hairline
   apart. Four or more lines are a 2 by 2 grid. */
.work-order-card-photos {
  position: relative;
  display: grid;
  grid-template-columns: repeat(var(--work-order-card-columns, 1), minmax(0, 1fr));
  grid-auto-rows: minmax(0, 1fr);
  gap: var(--line-hairline);
  block-size: var(--height-work-order-card-photos);
  background: var(--color-surface);
}

.work-order-card-photos-2, .work-order-card-photos-4 { --work-order-card-columns: 2; }
.work-order-card-photos-3 { --work-order-card-columns: 3; }

.work-order-card-photo {
  --size-icon: var(--size-work-order-card-photo-icon);
  display: grid;
  place-items: center;
  min-block-size: 0;
  overflow: hidden;
  background: var(--color-panel);
  color: var(--color-ink-dim);

  & img { inline-size: 100%; block-size: 100%; -o-object-fit: cover; object-fit: cover; }
}

/* The lines not shown, at the bottom right of the last quarter. */
.work-order-card-count {
  font-size: var(--text-caption-strong-size);
  line-height: var(--text-caption-strong-line);
  font-variation-settings: "wght" var(--text-caption-strong-weight);
  letter-spacing: var(--text-caption-strong-tracking);
  position: absolute;
  inset-block-end: var(--space-xs);
  inset-inline-end: var(--space-xs);
  display: inline-flex;
  align-items: center;
  block-size: var(--height-work-order-card-count);
  padding-inline: var(--space-2xs);
  border-radius: var(--radius-soft);
  background: var(--color-ink);
  color: var(--color-on-fill);
}

.work-order-card-body { padding: var(--space-s); }

/* The customer, then Due at the right end. The name is cut off first. */
.work-order-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-xs);
}

.work-order-card-customer {
  font-size: var(--text-body-strong-size);
  line-height: var(--text-body-strong-line);
  font-variation-settings: "wght" var(--text-body-strong-weight);
  letter-spacing: var(--text-body-strong-tracking);
  min-inline-size: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.work-order-card-head .due { flex-shrink: 0; }

.work-order-card-caption {
  font-size: var(--text-caption-size);
  line-height: var(--text-caption-line);
  font-variation-settings: "wght" var(--text-caption-weight);
  letter-spacing: var(--text-caption-tracking);
  margin-block-start: var(--space-3xs);
  color: var(--color-ink-soft);
}

.work-order-card-flags { margin-block-start: var(--space-xs); }

/* Below a hairline: progress on the left, the location on the right, on
   the line of the station icons. */
.work-order-card-foot {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-s);
  margin-block-start: var(--space-xs);
  padding-block-start: var(--space-xs);
  border-block-start: var(--line-hairline) solid var(--color-line-soft);
}

.work-order-card-progress { min-inline-size: 0; }

.work-order-card-location {
  font-size: var(--text-body-size);
  line-height: var(--text-body-line);
  font-variation-settings: "wght" var(--text-body-weight);
  letter-spacing: var(--text-body-tracking);
  flex-shrink: 0;
  text-align: end;

  &.is-empty { color: var(--color-ink-dim); }
}

/* Work order row: design/components/work-order-row.md. A row of the work
   orders table: a large thumb, then the customer over a caption line. The
   row is as tall as the thumb, with the table's xs above and below it. */
.work-order-row-customer {
  font-size: var(--text-body-strong-size);
  line-height: var(--text-body-strong-line);
  font-variation-settings: "wght" var(--text-body-strong-weight);
  letter-spacing: var(--text-body-strong-tracking);
  display: block;
  overflow: hidden;
  color: var(--color-ink);
  text-overflow: ellipsis;
}

.work-order-row-caption {
  font-size: var(--text-caption-size);
  line-height: var(--text-caption-line);
  font-variation-settings: "wght" var(--text-caption-weight);
  letter-spacing: var(--text-caption-tracking);
  display: block;
  margin-block-start: var(--space-3xs);
  overflow: hidden;
  color: var(--color-ink-soft);
  text-overflow: ellipsis;
}

/* Flags cell: the one cell in a table that wraps. Flags that do not fit on
   one line go onto the next, 3xs below (the badge list's gap). None is cut
   off. The cell is centered top to bottom on the row, like every cell. The
   table's pill margin is off here, because it would pull the lines together. */
.table td .badge-list.work-order-row-flags {
  flex-wrap: wrap;

  & .flag { margin-block: 0; }
}
/* Utilities: one job each. Spacing comes from the tokens in theme/space.css. */

.gap-3xs { gap: var(--space-3xs); }

.over-3xs { margin-block-start: var(--space-3xs); }

.under-3xs { margin-block-end: var(--space-3xs); }

.gap-2xs { gap: var(--space-2xs); }

.over-2xs { margin-block-start: var(--space-2xs); }

.under-2xs { margin-block-end: var(--space-2xs); }

.gap-xs { gap: var(--space-xs); }

.over-xs { margin-block-start: var(--space-xs); }

.under-xs { margin-block-end: var(--space-xs); }

.gap-s { gap: var(--space-s); }

.over-s { margin-block-start: var(--space-s); }

.under-s { margin-block-end: var(--space-s); }

.gap-m { gap: var(--space-m); }

.over-m { margin-block-start: var(--space-m); }

.under-m { margin-block-end: var(--space-m); }

.gap-l { gap: var(--space-l); }

.over-l { margin-block-start: var(--space-l); }

.under-l { margin-block-end: var(--space-l); }

.gap-xl { gap: var(--space-xl); }

.over-xl { margin-block-start: var(--space-xl); }

.under-xl { margin-block-end: var(--space-xl); }

.gap-2xl { gap: var(--space-2xl); }

.over-2xl { margin-block-start: var(--space-2xl); }

.under-2xl { margin-block-end: var(--space-2xl); }

.gap-3xl { gap: var(--space-3xl); }

.over-3xl { margin-block-start: var(--space-3xl); }

.under-3xl { margin-block-end: var(--space-3xl); }

.gap-g { gap: var(--space-g); }

.over-g { margin-block-start: var(--space-g); }

.under-g { margin-block-end: var(--space-g); }

.items-start { align-items: flex-start; }
.break-word { word-break: break-word; }
.clickable { cursor: pointer; }
.visually-hidden { clip-path: inset(50%); height: 1px; overflow: hidden; position: absolute; white-space: nowrap; width: 1px; }
