/* Aisle — THE KIT. One rule set per component, on tokens only (ds/tokens.css), so a thing that does one job looks
   the same on every page. ds/DESIGN.md is the language these rules write down; tests/test_design.py holds them to it.

   The WMS grew page by page, and every page named its parts its own way: a delivery in Goods in, a trip in Goods
   out and a customer in Billing are the same card under three class names. Rather than rename them in the code,
   each component here lists every name it answers to. A new page uses the first name in each list.

     button       button.primary · button.go · button.quiet · button.ghost · button.link · button.x · .danger
     chip         button.chip · .see-through · .ops-tool · .undo-button     (a setting or tool you switch)
     segmented    .segmented                                                 (exclusive readings of one thing)
     tabs         .o-tabs · .out-tabs · .tabs                                (where you are: sub-views, and the views)
     badge        .o-chip · .status · .rule-chip                             (a state, in one or two words)
     count        .count · .count-badge                                      (work waiting, a number)
     field        .o-input · inputs in .form-grid, .field-rows, .tag-add …   (a box you type in)
     card         .card · .o-kpi · the cards in a list                       (an object on the concrete)
     table        .o-table · .pallet-table                                   (rows of one kind of thing)
     power        .pt                                (rows you filter, sort and group, a picture in the cells: power.css)
     dialog       .dialog                                                    (a question that stops the page)
     popover      .matches · .tooltip · .o-tip                               (what floats over a card)
     toast        .toast                                                     (what just happened)
     state        .empty-state · .o-empty · .o-loading                       (nothing here, or not yet)

   Everything is scoped to the Aisle looks, so the Current look and the experiment looks stay as they were. */

:root[data-look^="aisle"] {

  /* ═══ the ring, once, for everything ════════════════════════════════════════════════════════════════════════ */

  /* A keyboard reader meets one mark on a button, a row, a menu seat and a tab. A field being typed in shows its
     beam edge instead (below), because the caret is already there. */
  :focus-visible { outline: 0; box-shadow: var(--focus); }
  :is(button, a, [role="button"], [role="radio"], [role="tab"]):disabled,
  [aria-disabled="true"] { cursor: not-allowed; }

  /* ═══ button: an action ═════════════════════════════════════════════════════════════════════════════════════ */

  /* PRIMARY is ink: one per area, the action that moves the work on. 32 high, 28 in a row, 40 to confirm a move. */
  :is(button.primary, a.button.primary, button.go, .label-actions button:not(.quiet, .chip), .card-actions button:not(.quiet, .chip),
      .take-out button[type="submit"], .tag-add-actions button[type="submit"], .pallet-table .row-actions button:not(.quiet),
      .replay-toggle, .tt-play) {
    display: inline-flex; align-items: center; justify-content: center; gap: var(--space-1h);
    height: var(--control-md); padding: 0 var(--space-3); border: 1px solid var(--bg-ink); border-radius: var(--radius-sm);
    background: var(--bg-ink); color: var(--fg-on-ink); cursor: pointer;
    font: var(--wt-strong) var(--ty-ui) / 1 var(--font-sans); letter-spacing: 0; white-space: nowrap; text-decoration: none;
    box-shadow: none;
    transition: background-color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
  }
  :is(button.primary, a.button.primary, .label-actions button:not(.quiet, .chip), .card-actions button:not(.quiet, .chip),
      .take-out button[type="submit"], .tag-add-actions button[type="submit"], .pallet-table .row-actions button:not(.quiet),
      .replay-toggle, .tt-play):hover:not(:disabled) { background: var(--bg-ink-hover); border-color: var(--bg-ink-hover); }
  :is(button.primary, .label-actions button, .card-actions button, .pallet-table .row-actions button,
      .replay-toggle, .tt-play):disabled {
    border-color: transparent; background: var(--wash-on); color: var(--fg-disabled); box-shadow: none;
  }

  /* GO is green: it puts a pallet in a free place, and green means a free place. */
  :is(button.go, #put-here, .placing-target .primary, .pallet-table .row-actions button.go, .tool-fix,
      #label-actions button.go-button, #dock-panel button.go-button) {
    border-color: var(--ok-button); background: var(--ok-button); color: var(--fg-on-accent);
  }
  :is(button.go, #put-here, .placing-target .primary, .pallet-table .row-actions button.go, .tool-fix,
      #label-actions button.go-button, #dock-panel button.go-button):hover:not(:disabled) {
    border-color: var(--ok-button-hover); background: var(--ok-button-hover);
  }

  /* QUIET is the second action: paper with a hairline, washed on hover, never lifted. */
  :is(button.quiet, a.button.quiet) {
    display: inline-flex; align-items: center; justify-content: center; gap: var(--space-1h);
    height: var(--control-md); padding: 0 var(--space-3); border: 1px solid var(--line-2); border-radius: var(--radius-sm);
    background: var(--bg-sheet); color: var(--fg-1); cursor: pointer;
    font: var(--wt-strong) var(--ty-ui) / 1 var(--font-sans); white-space: nowrap; text-decoration: none; box-shadow: none;
    transition: background-color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
  }
  :is(button.quiet, a.button.quiet):hover:not(:disabled) { border-color: var(--line-3); background: color-mix(in srgb, var(--fg-1) 4%, var(--bg-sheet)); }
  :is(button.quiet, a.button.quiet):active:not(:disabled) { background: color-mix(in srgb, var(--fg-1) 8%, var(--bg-sheet)); }
  :is(button.quiet, a.button.quiet):disabled { color: var(--fg-disabled); border-color: var(--line-1); cursor: not-allowed; }

  /* GHOST and X: no edge until the pointer is on them. Icon buttons, closing crosses, the menu's own buttons. */
  :is(button.ghost, button.x, .legend button.x, .label-panel .close) {
    display: inline-flex; align-items: center; justify-content: center; gap: var(--space-1h);
    height: var(--control-md); padding: 0 var(--space-2); border: 0; border-radius: var(--radius-sm);
    background: transparent; color: var(--fg-2); cursor: pointer; box-shadow: none;
    font: var(--wt-mid) var(--ty-ui) / 1 var(--font-sans);
    transition: background-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
  }
  :is(button.x, .legend button.x, .label-panel .close) { width: var(--control-sm); height: var(--control-sm); padding: 0; color: var(--fg-3); }
  :is(button.ghost, button.x, .legend button.x, .label-panel .close):hover { background: var(--wash-hover); color: var(--fg-1); }
  :is(button.ghost, button.x, .legend button.x, .label-panel .close):active { background: var(--wash-press); }

  /* LINK: an action set in a sentence. */
  button.link {
    padding: 0; border: 0; background: none; color: var(--fg-1); cursor: pointer;
    font-weight: var(--wt-strong); text-decoration: underline; text-decoration-color: var(--line-3);
    text-decoration-thickness: 1.5px; text-underline-offset: 3px;
    transition: text-decoration-color var(--dur-fast) var(--ease);
  }
  button.link:hover { text-decoration-color: var(--accent); }

  /* DANGER says so in words ("Delete …") and in red ink; a first press arms it (data-confirm) and only the second,
     now solid red, does it. */
  :is(button.quiet, button.ghost, button).danger { color: var(--bad); }
  :is(button.quiet, button.ghost, button).danger:hover:not(:disabled) { border-color: var(--bad-line); background: var(--bad-soft); }
  :is(button.danger, .label-actions button)[data-confirm="true"] {
    border-color: var(--bad-strong); background: var(--bad-strong); color: var(--fg-on-accent);
  }

  /* Sizes: small in rows and panels, large only where a whole move is confirmed. */
  :is(button.small, .pallet-table .row-actions button, .legend :is(.tag-edit, .legend-new, .picked-note) button,
      .label-tags .add-tag, .placing-actions button.quiet) {
    height: var(--control-sm); padding: 0 var(--space-2h); font-size: var(--ty-ui);
  }
  button.large { height: var(--control-lg); padding: 0 var(--space-4); }
  :is(button, a.button) svg.o-icon { width: 16px; height: 16px; margin: 0; }

  /* ═══ chip: a setting or a tool you switch on ═══════════════════════════════════════════════════════════════ */

  /* A pill, because it stays: it says what is on. Off it is paper with a hairline, on it is washed in ink. */
  :is(button.chip, .see-through, .label-tools button.ops-tool) {
    display: inline-flex; align-items: center; gap: var(--space-1h);
    height: var(--control-sm); padding: 0 var(--space-3); border: 1px solid var(--line-2); border-radius: var(--radius-pill);
    background: var(--bg-sheet); color: var(--fg-2); cursor: pointer; box-shadow: none;
    font: var(--wt-mid) var(--ty-note) / 1 var(--font-sans); white-space: nowrap;
    transition: background-color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
  }
  :is(button.chip, .see-through, .label-tools button.ops-tool):hover { border-color: var(--line-3); background: color-mix(in srgb, var(--fg-1) 4%, var(--bg-sheet)); color: var(--fg-1); }
  :is(button.chip, .see-through, .label-tools button.ops-tool)[aria-pressed="true"] {
    border-color: var(--line-3); background: color-mix(in srgb, var(--fg-1) 8%, var(--bg-sheet)); color: var(--fg-1); font-weight: var(--wt-strong);
  }
  /* Undo sits on the line it can take back: the same pill, smaller, and it lights in safety yellow under the pointer
     because it reverses a move someone is waiting on. */
  .activity li button.undo-button {
    height: 22px; padding: 0 var(--space-2); border: 1px solid var(--line-2); border-radius: var(--radius-pill);
    background: var(--bg-sheet); color: var(--fg-1); font: var(--wt-strong) var(--ty-micro) / 1 var(--font-sans); box-shadow: none;
  }
  .activity li button.undo-button:hover { border-color: var(--wait); background: var(--wait); color: var(--fg-on-wait); }

  /* ═══ segmented: exclusive readings of one thing ════════════════════════════════════════════════════════════ */

  /* The box stays; the chosen reading is washed in ink, not lifted out of a track. */
  .segmented {
    display: inline-flex; gap: var(--space-half); padding: var(--space-half); border: 1px solid var(--line-2);
    border-radius: var(--radius-sm); background: var(--bg-sheet); overflow: visible; box-shadow: none;
  }
  .segmented button {
    height: calc(var(--control-md) - 6px); padding: 0 var(--space-2h); border: 0; border-radius: calc(var(--radius-sm) - 2px);
    background: transparent; color: var(--fg-2); cursor: pointer; box-shadow: none;
    font: var(--wt-mid) var(--ty-ui) / 1 var(--font-sans); white-space: nowrap;
    transition: color var(--dur-fast) var(--ease), background-color var(--dur-fast) var(--ease);
  }
  .segmented button + button { border-left: 0; }
  .segmented button:hover:not(:disabled) { color: var(--fg-1); background: var(--wash-hover); }
  .segmented button:is([aria-checked="true"], [aria-pressed="true"], [aria-selected="true"]) {
    background: var(--wash-on); color: var(--fg-1); font-weight: var(--wt-strong); box-shadow: none;
  }

  /* The switch: one setting, on or off. On is green, because what it turns on is shown. */
  .toggle { display: inline-flex; align-items: center; gap: var(--space-2); font: var(--wt-mid) var(--ty-ui) var(--font-sans); color: var(--fg-2); cursor: pointer; }
  .toggle:hover { color: var(--fg-1); }
  .toggle input {
    appearance: none; -webkit-appearance: none; position: relative; flex: none; width: 30px; height: 18px; margin: 0;
    border-radius: var(--radius-pill); background: var(--control-off); cursor: pointer;
    transition: background-color var(--dur) var(--ease);
  }
  .toggle input::after {
    content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: var(--knob);
    box-shadow: var(--e-1); transition: transform var(--dur) var(--ease);
  }
  .toggle input:checked { background: var(--ok); }
  .toggle input:checked::after { transform: translateX(12px); }

  /* ═══ tabs: where you are ═══════════════════════════════════════════════════════════════════════════════════ */

  /* Views and sub-views are pills as the menu's rows are: no track, no underline, the one you are on washed. While
     the card menu is worn (ds/menu.css) the sub-views live in the menu, and these show only on narrow screens. */
  :is(.out-tabs, .o-tabs) {
    display: inline-flex; align-items: center; gap: var(--space-half); padding: 0; border: 0; border-radius: 0;
    background: transparent; overflow: visible; box-shadow: none;
  }
  :is(.out-tabs, .o-tabs) a {
    display: inline-flex; align-items: center; gap: var(--space-1h); height: var(--control-md); padding: 0 var(--space-3);
    border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--fg-2); text-decoration: none;
    font: var(--wt-mid) var(--ty-ui) var(--font-sans); white-space: nowrap;
    transition: color var(--dur-fast) var(--ease), background-color var(--dur-fast) var(--ease);
  }
  :is(.out-tabs, .o-tabs) a + a { border-left: 0; }
  :is(.out-tabs, .o-tabs) a:hover { color: var(--fg-1); background: var(--wash-hover); }
  :is(.out-tabs, .o-tabs) a[aria-current="page"] { color: var(--fg-1); background: var(--wash-on); font-weight: var(--wt-strong); box-shadow: none; }

  /* ═══ badge: a state, in one or two words ═══════════════════════════════════════════════════════════════════ */

  /* One shape, six tones, each a meaning (principle 2). The dot repeats the tone for a glance down a column. */
  :is(.status, .o-chip, .rule-chip) {
    display: inline-flex; align-items: center; gap: var(--space-1h); height: 22px; padding: 0 var(--space-2) 0 var(--space-2);
    border: 0; border-radius: var(--radius-pill); box-shadow: none;
    font: var(--wt-strong) var(--ty-note) / 1 var(--font-sans); letter-spacing: 0; text-transform: none; white-space: nowrap;
    color: var(--fg-2); background: var(--wash-on);
  }
  .status { padding-left: var(--space-2); }
  .status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: 0.85; }
  .status:empty { display: none; }
  :is(.o-chip.good, .status:is([data-status="stored"], [data-status="done"])) { color: var(--ok-fg); background: var(--ok-soft); box-shadow: inset 0 0 0 1px var(--ok-line); }
  :is(.o-chip.wait, .status:is([data-status="arriving"], [data-status="received"], [data-status="at_dock"])) {
    color: var(--wait-fg); background: var(--wait-soft); box-shadow: inset 0 0 0 1px var(--wait-line);
  }
  .status:is([data-status="arriving"], [data-status="received"], [data-status="at_dock"])::before { background: var(--wait); opacity: 1; }
  :is(.o-chip.bad, .rule-chip) { color: var(--bad-fg); background: var(--bad-soft); box-shadow: inset 0 0 0 1px var(--bad-line); }
  .o-chip.info { color: var(--info-fg); background: var(--info-soft); box-shadow: inset 0 0 0 1px var(--info-line); }
  .o-chip.accent { color: var(--accent-fg); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent-line); }
  :is(.o-chip.ghost, .status[data-status="expected"]) { color: var(--fg-2); background: var(--bg-sheet); box-shadow: inset 0 0 0 1px var(--line-2); }
  .status[data-status="shipped"] { color: var(--fg-3); background: var(--wash-on); }
  .o-sw { width: 9px; height: 9px; border-radius: var(--radius-xs); flex: none; }

  /* The part flag is a badge with a pallet drawn in front (js/partflag.js): a little tighter, so the glyph sits in. */
  .part-flag { gap: var(--space-1); padding-left: var(--space-1h); }
  .part-flag-glyph { flex: none; }

  /* ═══ count: work waiting, as a number ══════════════════════════════════════════════════════════════════════ */

  /* A plain grey number at the end of its row, as the Minos card's counts are: it says how much without asking for
     the eye. No pill, no colour; red (.count-badge) only for what breaks a rule. A label named .count (the pallets
     field in a batch) is not one. */
  :is(.tabs .count, span.count) {
    display: inline-flex; align-items: center; justify-content: flex-end; min-width: 18px; height: 18px; padding: 0;
    background: none; color: var(--fg-3);
    font: var(--wt-mid) var(--ty-ui) / 1 var(--font-sans); font-variant-numeric: tabular-nums;
  }
  .tabs a:is(:hover, [aria-current="page"]) .count { color: var(--fg-2); }
  :is(.tabs .count, span.count)[hidden] { display: none; }
  .count-badge {
    min-width: 20px; height: 20px; padding: 0 6px; border-radius: var(--radius-pill);
    background: var(--bad); color: var(--fg-on-accent); font: var(--wt-code) var(--ty-micro) / 20px var(--font-sans);
  }
  kbd {
    display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 4px; margin: 0 1px;
    border: 1px solid var(--line-2); border-radius: var(--radius-xs); background: var(--bg-sunken); box-shadow: none;
    font: var(--wt-strong) var(--ty-micro) / 1 var(--font-sans); color: var(--fg-2); vertical-align: 1px;
  }

  /* ═══ field: a box you type in ══════════════════════════════════════════════════════════════════════════════ */

  :is(.o-input, .form-grid input, .form-grid select, .form-grid textarea, .field-rows input, .tag-add select, .tag-add input,
      .take-out input, .tag-rename input, .legend-new input, .out-line-row input, #out-import textarea, .space-for,
      dialog input:not([type="checkbox"], [type="radio"], [type="color"], [type="range"]), dialog select, dialog textarea) {
    min-height: var(--control-md); height: auto; padding: 6px 10px; border: 1px solid var(--line-control); border-radius: var(--radius-sm);
    background-color: var(--bg-sheet); color: var(--fg-1); font: var(--wt-regular) var(--ty-body) / var(--leading-snug) var(--font-sans);
    box-shadow: none;
    transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
  }
  :is(.o-input, .form-grid input, .form-grid select, .form-grid textarea, .field-rows input, .tag-add select, .tag-add input,
      .take-out input, .tag-rename input, .legend-new input, .out-line-row input, #out-import textarea, .space-for,
      dialog input:not([type="checkbox"], [type="radio"], [type="color"], [type="range"]), dialog select, dialog textarea):hover { border-color: var(--fg-3); }
  :is(.o-input, .form-grid input, .form-grid select, .form-grid textarea, .field-rows input, .tag-add select, .tag-add input,
      .take-out input, .tag-rename input, .legend-new input, .out-line-row input, #out-import textarea, .space-for,
      dialog input:not([type="checkbox"], [type="radio"], [type="color"], [type="range"]), dialog select, dialog textarea):focus {
    outline: 0; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
  }
  textarea.o-input, .form-grid textarea, dialog textarea { min-height: 72px; }
  /* Every select wears one chevron. */
  :is(select.o-input, .form-grid select, .tag-add select, .space-for, dialog select) {
    appearance: none; -webkit-appearance: none; padding-right: 30px; cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M3 4.5l3 3 3-3' stroke='%236b757a' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 10px center; background-size: 12px;
  }
  /* What a field is called: above it, small, in the field's own grey. */
  :is(.o-field, .form-grid label, .custom-color, .tag-add label) { gap: var(--space-1h); font: var(--wt-mid) var(--ty-ui) var(--font-sans); color: var(--fg-2); }
  .o-field-label { font-weight: var(--wt-mid); }
  :is(.o-field-hint, .form-note) { font-size: var(--ty-note); color: var(--fg-3); }
  :is(.form-note.error, .form-note[data-kind="error"]) { color: var(--bad); }
  ::placeholder { color: var(--fg-3); opacity: 1; }
  input[type="checkbox"]:not(#show-free, #tt-follow, .toggle input) { accent-color: var(--fg-1); }

  /* Search: the way into everything, so it carries its glass and its key. One height wherever it sits. */
  :is(.search input, .page-search input) {
    height: var(--row); padding: 0 14px 0 36px; border: 1px solid var(--line-control); border-radius: var(--radius-sm);
    background: var(--bg-sheet) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Ccircle cx='7' cy='7' r='4.75' stroke='%236b757a' stroke-width='1.6' fill='none'/%3E%3Cpath d='M10.5 10.5l3 3' stroke='%236b757a' stroke-width='1.6' stroke-linecap='round'/%3E%3C/svg%3E") 12px center / 16px no-repeat;
    font: var(--wt-regular) var(--ty-body) var(--font-sans); letter-spacing: 0; color: var(--fg-1); box-shadow: none;
    transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
  }
  :is(.search input, .page-search input)::placeholder { color: var(--fg-3); }
  :is(.search input, .page-search input):hover { border-color: var(--fg-3); }
  :is(.search input, .page-search input):focus { outline: 0; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

  /* ═══ card: an object on the concrete ═══════════════════════════════════════════════════════════════════════ */

  /* Paper, a hairline, the corner of a panel and the lowest height. A card you can press answers with a darker
     edge and one height more; the card you picked wears the beam ring. */
  :is(.card, .o-kpi) {
    border: 1px solid var(--line-1); border-radius: var(--radius-md); background: var(--bg-sheet); box-shadow: var(--e-1);
  }
  .card { padding: var(--space-5) var(--space-6); }
  .card-head { gap: var(--space-2) var(--space-3); margin-bottom: var(--space-4); }
  :is(.card-head h4, .sub-title, .o-card-title) { font: var(--wt-head) var(--ty-head) / 1.2 var(--font-head); letter-spacing: var(--track-head); color: var(--fg-1); }
  :is(.o-card-note, .tally) { font-size: var(--ty-note); color: var(--fg-3); }
  .o-card { gap: var(--space-3); }

  :is(.delivery-list > li > button, .customer-list > li > button, .pallet-results li > button, .out-item, .out-point, .o-bill-customer) {
    border: 1px solid var(--line-1); border-radius: var(--radius-md); background: var(--bg-sheet); box-shadow: var(--e-1); color: var(--fg-1);
    cursor: pointer;
    transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
  }
  :is(.delivery-list > li > button, .customer-list > li > button, .pallet-results li > button, .out-item, .out-point, .o-bill-customer):hover {
    border-color: var(--line-2); box-shadow: var(--e-2);
  }
  :is(.delivery-list > li > button, .customer-list > li > button, .out-item, .out-point)[aria-current="true"], .o-bill-customer.selected {
    border-color: var(--picked-line); box-shadow: 0 0 0 3px var(--picked-bg), var(--e-1);
  }

  /* A figure tile: what it is, the figure in the code face, what qualifies it. */
  .o-kpi { padding: var(--space-3) var(--space-4); }
  .o-kpi-label { font-size: var(--ty-ui); color: var(--fg-2); }
  .o-kpi-value { font: var(--wt-code) var(--ty-fig) / 1.05 var(--font-code); letter-spacing: var(--track-code); color: var(--fg-1); }
  .o-kpi-value small { font: var(--wt-strong) var(--ty-body) var(--font-sans); color: var(--fg-3); letter-spacing: 0; }
  .o-kpi-note { font-size: var(--ty-note); color: var(--fg-3); }
  /* INK IS THE ONE THING: one primary action in an area, and one answer on a page. The tile the page is about is
     ink, as the primary button is; a tile in trouble keeps its paper and says so in its edge and its figure. */
  .o-kpi.hero { border-color: var(--bg-ink); background: var(--bg-ink); }
  .o-kpi.hero :is(.o-kpi-value, .o-kpi-label) { color: var(--fg-on-ink); }
  .o-kpi.hero :is(.o-kpi-note, .o-kpi-value small) { color: color-mix(in srgb, var(--fg-on-ink) 68%, transparent); }
  .o-kpi.hero :is(.o-good, .o-bad) { color: inherit; }
  .o-kpi.bad { border-color: var(--bad-line); }
  .o-kpi.good .o-kpi-value { color: var(--ok-fg); }
  .o-kpi.bad .o-kpi-value { color: var(--bad-fg); }
  .o-kpi.wait .o-kpi-value { color: var(--wait-fg); }

  /* A callout: a sentence that needs saying, in the tone of what it is about. */
  .o-callout { border-radius: var(--radius-md); font-size: var(--ty-body); }
  .banner {
    padding: 10px 14px; border: 1px solid var(--wait-line); border-radius: var(--radius-md); background: var(--wait-soft);
    color: var(--fg-1); font-size: var(--ty-ui); box-shadow: var(--e-2);
  }
  :is(.tool-box, .pick-first) { border-radius: var(--radius-sm); }

  /* ═══ table: rows of one kind of thing ══════════════════════════════════════════════════════════════════════ */

  /* Hairlines, a quiet head in sentence case, numbers to the right in even figures, codes in the label face.
     A row you can open is washed under the pointer; the row you picked wears a beam bar. */
  :is(.pallet-table, .o-table) { width: 100%; border-collapse: collapse; font-size: var(--ty-body); font-variant-numeric: tabular-nums; }
  :is(.pallet-table, .o-table) th {
    padding: var(--space-2) var(--space-3); border-bottom: 1px solid var(--line-2); background: var(--bg-sheet);
    font: var(--wt-mid) var(--ty-note) var(--font-sans); color: var(--fg-3); letter-spacing: 0; text-transform: none; text-align: left;
    white-space: nowrap;
  }
  :is(.pallet-table, .o-table) td { padding: 10px var(--space-3); border-bottom: 1px solid var(--line-1); vertical-align: middle; }
  :is(.pallet-table, .o-table) :is(th, td).num { text-align: right; white-space: nowrap; }
  :is(.pallet-table, .o-table) tbody tr { transition: background-color var(--dur-fast) var(--ease); }
  :is(.pallet-table, .o-table) tbody tr:hover td { background: var(--wash-hover); }
  .o-table tr.o-clickable { cursor: pointer; }
  .o-table tr.o-clickable:focus-visible { box-shadow: none; }
  .o-table tr.o-clickable:focus-visible td { background: var(--wash-on); }
  .o-table tr.o-clickable:focus-visible td:first-child { box-shadow: inset 3px 0 0 var(--fg-1); }
  :is(.pallet-table, .o-table) tr.selected td { background: var(--picked-bg); }
  :is(.pallet-table, .o-table) tr.selected td:first-child { box-shadow: inset 3px 0 0 var(--picked-line); }
  /* A search hit is a highlighter stroke on the row, not a block. */
  .pallet-table tr.hit td { background: color-mix(in srgb, var(--wait) 9%, transparent); }
  .pallet-table tr.hit td:first-child { box-shadow: inset 3px 0 0 var(--wait); }
  .o-table tr.dim td { color: var(--fg-3); }
  .o-table tr.bad td:first-child { box-shadow: inset 3px 0 0 var(--bad); }
  .o-table tr.wait td:first-child { box-shadow: inset 3px 0 0 var(--wait); }
  .o-table tr.good td:first-child { box-shadow: inset 3px 0 0 var(--ok); }
  :is(.pallet-table, .o-table) tfoot td { font-weight: var(--wt-strong); border-top: 1px solid var(--line-2); border-bottom: 0; }
  :is(.pallet-table .code, .o-code) { font: var(--wt-code) var(--ty-code) / 1 var(--font-code); letter-spacing: var(--track-code); white-space: nowrap; word-break: normal; }
  .o-code.big { font-size: var(--ty-code-title); }
  :is(.pallet-table .desc) { color: var(--fg-3); font-size: var(--ty-ui); }
  :is(.pallet-table .empty, .o-table-empty) { padding: var(--space-5) var(--space-3); color: var(--fg-3); text-align: center; }
  .pallet-table .row-actions { gap: var(--space-1h); }
  .pallet-table td a { color: var(--fg-1); text-decoration-color: var(--line-3); text-underline-offset: 3px; }
  .pallet-table td a:hover { text-decoration-color: var(--accent); }
  .o-table-wrap { border-radius: var(--radius-sm); }

  /* ═══ dialog: a question that stops the page ════════════════════════════════════════════════════════════════ */

  /* Raised paper at the highest height, over a scrim that dims and softens the page. A title, the body, then the
     actions on a hairline at the foot: the way back on the left of the way on, the way on last. */
  .dialog {
    width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 48px); padding: var(--space-6);
    border: 1px solid var(--line-1); border-radius: var(--radius-lg); background: var(--bg-raised); color: var(--fg-1);
    box-shadow: var(--e-4);
  }
  .dialog.wide, #delivery-dialog, #out-import, .out-plan-dialog { width: min(720px, calc(100vw - 32px)); }
  .dialog[open] { animation: aisle-pop var(--dur) var(--ease); }
  .dialog::backdrop { background: var(--scrim); backdrop-filter: blur(2px); }
  .dialog[open]::backdrop { animation: aisle-fade var(--dur) var(--ease); }
  .dialog h3 { font: var(--wt-head) var(--ty-title) / var(--leading-tight) var(--font-head); letter-spacing: var(--track-head); margin: 0 0 var(--space-5); word-break: normal; }
  .dialog .eyebrow + h3 { margin-top: var(--space-1); }
  .dialog .form-actions, .o-dialog .form-actions { margin-top: var(--space-6); padding-top: var(--space-4); border-top: 1px solid var(--line-1); }
  .form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
  .o-dialog-body { display: grid; gap: var(--space-3); }

  /* ═══ popover: what floats over a card ══════════════════════════════════════════════════════════════════════ */

  .matches {
    padding: var(--space-1); border: 1px solid var(--line-1); border-radius: var(--radius-md);
    background: var(--bg-raised); box-shadow: var(--e-3); animation: aisle-pop var(--dur) var(--ease);
  }
  .matches button { align-items: baseline; padding: var(--space-2) 10px; border-radius: var(--radius-sm); color: var(--fg-1); transition: background-color var(--dur-fast) var(--ease); }
  .matches button:is(:hover, :focus-visible) { background: var(--wash-hover); box-shadow: none; }
  .matches strong { font: var(--wt-code) var(--ty-code) var(--font-code); letter-spacing: var(--track-code); }
  .matches span { font-size: var(--ty-note); color: var(--fg-3); }

  /* A tooltip is ink: it explains what is under the pointer and goes when the pointer does. */
  :is(.tooltip, .o-tip) {
    padding: 6px 10px; border-radius: var(--radius-sm); background: var(--bg-ink); color: var(--fg-on-ink);
    font: var(--wt-mid) var(--ty-note) / var(--leading-snug) var(--font-sans); box-shadow: var(--e-3);
  }
  .tooltip strong { font: var(--wt-code) var(--ty-code) var(--font-code); margin-right: var(--space-1h); }

  /* ═══ toast: what just happened ═════════════════════════════════════════════════════════════════════════════ */

  /* It comes on its own, so it takes its time arriving: a rise from where it sits. */
  .toast {
    display: flex; align-items: center; gap: var(--space-3); padding: 10px 12px 10px 16px; border-radius: var(--radius-md);
    background: var(--bg-ink); color: var(--fg-on-ink); font: var(--wt-strong) var(--ty-body) var(--font-sans);
    box-shadow: var(--e-3); animation: aisle-rise var(--dur-slow) var(--ease);
  }
  .toast[data-kind="error"] { background: var(--bad-strong); color: var(--fg-on-accent); }
  .toast button { height: var(--control-sm); padding: 0 10px; border: 0; border-radius: var(--radius-sm); background: color-mix(in srgb, currentColor 18%, transparent); color: inherit; font: var(--wt-strong) var(--ty-ui) var(--font-sans); cursor: pointer; }
  .toast-action { background: var(--wait) !important; color: var(--fg-on-wait) !important; }
  .toast-action:hover { background: var(--wait-hover) !important; }

  /* ═══ state: nothing here, or not yet ═══════════════════════════════════════════════════════════════════════ */

  /* Two shapes. A page with nothing to show says so in a dashed box with what to do next; a card with nothing in it
     says so in one grey line. Waiting is one small ring and the word, never two on one surface. */
  .empty-state {
    position: relative; padding: 96px var(--space-8) var(--space-10); border: 1px dashed var(--line-2); border-radius: var(--radius-md);
    background: color-mix(in srgb, var(--bg-sheet) 45%, transparent); color: var(--fg-2); font-size: var(--ty-body); max-width: 56ch;
  }
  .empty-state::before {
    content: ""; position: absolute; top: 32px; left: 50%; width: 44px; height: 44px; margin-left: -22px; border-radius: var(--radius-md);
    background: var(--bg-sheet) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M4 8.5L12 4l8 4.5v7L12 20l-8-4.5z M4 8.5l8 4.5 8-4.5 M12 13v7' stroke='%236b757a' stroke-width='1.5' fill='none' stroke-linejoin='round'/%3E%3C/svg%3E") center / 24px no-repeat;
    box-shadow: var(--e-1), 0 0 0 1px var(--line-1);
  }
  :is(.o-empty, .o-loading) { margin: 0; padding: var(--space-3) 0; color: var(--fg-3); font-size: var(--ty-body); }
  .o-loading::before {
    content: ""; display: inline-block; width: 10px; height: 10px; margin-right: var(--space-2); vertical-align: -1px;
    border: 2px solid var(--line-2); border-top-color: var(--fg-1); border-radius: 50%; animation: aisle-spin var(--dur-spin) linear infinite;
  }
}

/* ═══ motion ═════════════════════════════════════════════════════════════════════════════════════════════════════ */

/* What you asked for comes at once (a dialog, a dropdown: --dur); what comes on its own takes its time so you
   notice it (a toast, a bar, the inspector: --dur-slow). Leaving is never animated longer than arriving. */
@keyframes aisle-pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--ok) 55%, transparent); }
  70%, 100% { box-shadow: 0 0 0 6px transparent; }
}
@keyframes aisle-rise { from { opacity: 0; translate: 0 8px; } to { opacity: 1; translate: 0 0; } }
@keyframes aisle-pop { from { opacity: 0; scale: 0.97; } to { opacity: 1; scale: 1; } }
@keyframes aisle-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes aisle-spin { to { transform: rotate(360deg); } }

/* Motion at the reader's asking: everything that moves, stills. */
@media (prefers-reduced-motion: reduce) {
  :root[data-look^="aisle"] *, :root[data-look^="aisle"] *::before, :root[data-look^="aisle"] *::after {
    animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important;
  }
}
