/* Aisle — the base, the app bar and the page frame, plus the Goods in and Customers pages. Tokens in ds/tokens.css,
   the components every page shares (buttons, fields, tabs, badges, cards, tables, dialogs, toasts) in ds/kit.css,
   the card menu that takes the app bar's place on wide screens in ds/menu.css.
   Everything is scoped to the Aisle looks, so the Current look and the experiment looks stay as they were. */

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

  /* ---- base ------------------------------------------------------------------------------------------------ */

  body {
    font: var(--wt-regular) var(--ty-body) / var(--leading) var(--font-sans);
    color: var(--fg-1);
    background: var(--bg-canvas);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    font-variant-numeric: tabular-nums;
  }
  ::selection { background: var(--beam-200); color: var(--zinc-950); }
  * { scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }

  /* ---- the app bar: narrow screens, and the brand, live state and switches the card menu also carries ------- */

  .topbar {
    gap: var(--space-5); padding: 0 var(--space-4);
    background: var(--glass-bg); backdrop-filter: var(--glass-blur); -webkit-backdrop-filter: var(--glass-blur);
    border-bottom: 1px solid var(--line-1);
    box-shadow: 0 1px 0 var(--glass-line) inset;
  }
  /* Over a page there is no scene to see through: a plain bar. (Wide screens wear the card menu, ds/menu.css.) */
  @media (max-width: 999px) {
    body:not([data-view="twin"]) .topbar { background: color-mix(in srgb, var(--bg-canvas) 88%, var(--bg-sheet)); backdrop-filter: none; }
  }
  .brand { align-items: center; gap: var(--space-3); }
  .brand::before {
    content: ""; flex: none; width: 28px; height: 28px; border-radius: var(--radius-sm);
    background:
      url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 28 28'%3E%3Cpath d='M8 7v14M20 7v14M8 11.5h12M8 16.5h12' stroke='%23fff' stroke-width='2.4' stroke-linecap='round' fill='none'/%3E%3C/svg%3E") center / 28px no-repeat,
      linear-gradient(160deg, var(--beam-400), var(--beam-600));
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 1px 2px rgba(156, 55, 18, 0.35);
  }
  .brand h1 { font: var(--wt-head) var(--ty-head) / 1 var(--font-head); letter-spacing: var(--track-head); }
  /* Live, down or replaying: a badge (ds/kit.css) with a dot that breathes while the link is live. */
  .live {
    height: 22px; padding: 0 9px 0 8px; gap: 6px; border-radius: var(--radius-pill);
    font: var(--wt-mid) var(--ty-note) var(--font-sans); color: var(--fg-2); background: var(--wash-on);
  }
  .live::before { width: 7px; height: 7px; background: var(--zinc-400); }
  .live[data-state="live"] { color: var(--ok-fg); background: var(--ok-soft); }
  .live[data-state="live"]::before { background: var(--ok); box-shadow: 0 0 0 0 var(--ok); animation: aisle-pulse 2.4s var(--ease) infinite; }
  .live[data-state="down"] { color: var(--bad-fg); background: var(--bad-soft); }
  .live[data-state="down"]::before { background: var(--bad); }
  .live[data-state="replay"] { color: var(--wait-fg); background: var(--wait-soft); }
  .live[data-state="replay"]::before { background: var(--wait); }

  /* The views, as the tabs of ds/kit.css are: pills, the one you are on washed in ink. */
  .tabs { align-self: center; gap: var(--space-half); padding: 0; border-radius: 0; background: none; box-shadow: none; }
  .tabs a {
    height: var(--control-md); padding: 0 var(--space-3); gap: var(--space-2); border: 0; margin: 0; border-radius: var(--radius-sm);
    font: var(--wt-mid) var(--ty-body) var(--font-sans); letter-spacing: 0; color: var(--fg-2); text-decoration: none;
    transition: color var(--dur-fast) var(--ease), background-color var(--dur-fast) var(--ease);
  }
  .tabs a:hover { color: var(--fg-1); background: var(--wash-hover); }
  .tabs a[aria-current="page"] { color: var(--fg-1); background: var(--wash-on); box-shadow: none; }

  /* Exceptions: the one red thing in the bar. */
  .exceptions-chip {
    height: var(--control-md); padding: 0 12px 0 8px; gap: var(--space-2); border: 1px solid var(--bad-line); border-radius: var(--radius-pill);
    background: var(--bad-soft); color: var(--bad-fg); font: var(--wt-strong) var(--ty-ui) var(--font-sans); box-shadow: none; cursor: pointer;
    transition: border-color var(--dur-fast) var(--ease);
  }
  .exceptions-chip:hover { box-shadow: none; border-color: var(--bad); }
  .exceptions-icon { width: 18px; height: 18px; font: var(--wt-code) var(--ty-micro) var(--font-sans); background: var(--bad); color: var(--fg-on-accent); }

  /* Who is signed in (js/account.js): a quiet name, and Sign out. */
  .account-who { font: var(--wt-mid) var(--ty-ui) var(--font-sans); color: var(--fg-2); }

  /* The Style switch: one compact control, a select between two steps. */
  .look-switch { gap: var(--space-half); padding: var(--space-half); border: 1px solid var(--line-2); border-radius: var(--radius-sm); background: var(--bg-sheet); }
  .look-switch label { display: none; }
  .look-switch select {
    height: calc(var(--control-md) - 6px); max-width: 220px; padding: 0 26px 0 10px; border: 0; border-radius: calc(var(--radius-sm) - 2px); background-color: transparent;
    font: var(--wt-mid) var(--ty-ui) var(--font-sans); color: var(--fg-1); cursor: pointer;
    appearance: none; -webkit-appearance: none;
    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 8px center; background-size: 12px;
  }
  .look-switch select:hover, .look-step:hover { background-color: var(--wash-hover); }
  .look-step {
    width: 26px; height: calc(var(--control-md) - 6px); border: 0; border-radius: calc(var(--radius-sm) - 2px); background: transparent;
    color: var(--fg-2); font-size: var(--ty-head); cursor: pointer;
  }

  /* ---- swatches ---------------------------------------------------------------------------------------------- */

  .swatch { border-radius: var(--radius-xs); box-shadow: inset 0 0 0 1px rgba(15, 18, 19, 0.14); }
  .swatch.big { width: 48px; height: 48px; border-radius: var(--radius-md); box-shadow: inset 0 0 0 1px rgba(15, 18, 19, 0.12), inset 0 -10px 18px rgba(0, 0, 0, 0.1); }
  .eyebrow { font: var(--wt-mid) var(--ty-ui) var(--font-sans); color: var(--fg-3); gap: var(--space-2); }
  .muted { color: var(--fg-2); }
  fieldset { margin-top: var(--space-6); }
  legend { font: var(--wt-head) var(--ty-head) var(--font-head); letter-spacing: var(--track-head); margin-bottom: var(--space-3); }
  .form-grid { gap: var(--space-4); }

  /* ---- pages: Goods in, Customers (Goods out builds on these too) ------------------------------------------------ */

  .page { padding: var(--space-6) var(--space-6) 64px; background: var(--bg-canvas); }
  .page-head { gap: var(--space-3); max-width: 1440px; margin-bottom: var(--space-6); min-height: var(--control-md); }
  .page-head h2 { font: var(--wt-head) var(--ty-page) / 1 var(--font-head); letter-spacing: -0.02em; }
  .page-search { flex: 0 1 380px; }
  .split { grid-template-columns: minmax(300px, 380px) 1fr; gap: var(--space-6); max-width: 1440px; }
  .split-detail { gap: var(--space-5); }
  .split-detail > section { gap: var(--space-5); }
  .split-list { padding: 4px; margin: -4px; }
  /* A heading over a list or inside a card: grey, sentence case, the size of a note. */
  :is(.list-title, .pallet-results h3) { font: var(--wt-strong) var(--ty-note) var(--font-sans); color: var(--fg-2); margin: 0 4px 10px; letter-spacing: 0; }

  .sub-title { margin: var(--space-6) 0 var(--space-3); }
  .card-actions { gap: var(--space-2); }
  .detail-head { margin-bottom: var(--space-5); }
  .detail-head h3 { font: var(--wt-head) var(--ty-page) / 1.1 var(--font-head); letter-spacing: -0.018em; margin-top: 6px; }
  .detail-head.with-swatch { gap: var(--space-4); }
  .form-actions { margin-top: var(--space-5); }

  /* Lists on the left are cards (ds/kit.css): a thin colour rail, the one you picked ringed in beam. */
  :is(.delivery-list, .customer-list, .pallet-results ol) { gap: var(--space-1h); }
  :is(.delivery-list > li > button, .customer-list > li > button, .pallet-results li > button) { padding: 13px 14px 13px 18px; }
  :is(.delivery-list > li > button, .customer-list > li > button)::before { top: 12px; bottom: 12px; left: 0; width: 3px; border-radius: 0 3px 3px 0; }
  .delivery-list .who { font: var(--wt-mid) var(--ty-ui) var(--font-sans); color: var(--fg-2); }
  .delivery-list .ref { font: var(--wt-code) var(--ty-code-title) / 1.1 var(--font-code); letter-spacing: var(--track-code); }
  .delivery-list :is(.when, .counts) { font-size: var(--ty-note); color: var(--fg-3); }
  .delivery-list .progress { height: 4px; margin-top: 8px; border-radius: 2px; background: var(--wash-press); gap: 1px; }
  .progress :is(.stored, .shipped) { background: var(--ok); }
  .progress .received { background: var(--wait); }
  .delivery-list.compact > li > button { padding: 9px 12px 9px 16px; }
  :is(.delivery-list, .customer-list) .empty { padding: var(--space-4); color: var(--fg-2); font-size: var(--ty-ui); }

  .customer-list .name { font: var(--wt-head) var(--ty-head) / 1.2 var(--font-head); letter-spacing: var(--track-head); }
  .customer-list .stored { font: var(--wt-code) var(--ty-code-title) / 1 var(--font-code); }
  .customer-list .stats { font-size: var(--ty-note); color: var(--fg-3); }
  .pallet-results .code { font: var(--wt-code) var(--ty-code) var(--font-code); }
  .pallet-results .what { font-size: var(--ty-note); color: var(--fg-3); }

  /* Tables are the kit's (ds/kit.css); a table in a card runs to the card's edges. */
  .table-wrap { margin: 0 calc(-1 * var(--space-6)); padding: 0 var(--space-6); }
  .pallet-table .sku { font-weight: var(--wt-strong); }

  .add-pallets { margin-top: var(--space-4); padding-top: var(--space-4); border-top: 1px solid var(--line-1); }
  .add-pallets summary { font: var(--wt-strong) var(--ty-body) var(--font-sans); color: var(--fg-1); }
  .add-pallets summary::marker { color: var(--fg-3); }

  /* Packages on a delivery (js/packages.js): the bar for the ticked ones, under the table. */
  .package-bar { gap: var(--space-2) var(--space-3); margin-top: var(--space-4); padding: var(--space-3); border-radius: var(--radius-md); background: var(--wash-press); }
  .package-bar-count { font-weight: var(--wt-strong); color: var(--fg-1); }
  .package-bar label { gap: var(--space-2); font: var(--wt-mid) var(--ty-ui) var(--font-sans); color: var(--fg-2); }
  .package-table .where { font-size: var(--ty-note); color: var(--fg-3); }
  .package-codes { gap: var(--space-2); font: var(--wt-code) var(--ty-code) var(--font-code); letter-spacing: var(--track-code); color: var(--fg-1); }
  .package-codes .muted { font: var(--wt-regular) var(--ty-note) var(--font-sans); letter-spacing: 0; color: var(--fg-3); }
  .pallet-packages { margin-top: var(--space-4); }

  /* Customer colours and details. The colour is a chip at the name; the palette is a popover (ds/kit.css). */
  .form-grid .name-field { gap: var(--space-1h); font: var(--wt-mid) var(--ty-ui) var(--font-sans); color: var(--fg-2); }
  .name-row { gap: var(--space-2); }
  .color-chip {
    width: var(--control-md); min-height: var(--control-md); border: 1px solid var(--line-control); border-radius: var(--radius-sm);
    box-shadow: inset 0 0 0 2px var(--bg-sheet), inset 0 -6px 10px rgba(0, 0, 0, 0.12);
    transition: border-color var(--dur-fast) var(--ease);
  }
  .color-chip:hover, .color-chip[aria-expanded="true"] { border-color: var(--line-ink); }
  .color-pop { padding: var(--space-3); border: 1px solid var(--line-1); border-radius: var(--radius-md); background: var(--bg-raised); color: var(--fg-1); box-shadow: var(--e-3); }
  .color-pop:popover-open { animation: aisle-pop var(--dur) var(--ease); }
  .color-pop-title { margin-bottom: var(--space-2h); font: var(--wt-strong) var(--ty-note) var(--font-sans); color: var(--fg-3); }
  .color-choices { gap: 10px; }
  .color-choices button {
    width: 30px; height: 30px; border: 0; border-radius: 50%;
    box-shadow: inset 0 0 0 1px rgba(15, 18, 19, 0.14), inset 0 -6px 10px rgba(0, 0, 0, 0.12);
    transition: transform var(--dur-fast) var(--ease);
  }
  .color-choices button:hover { transform: scale(1.08); }
  .color-choices button[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--bg-raised), 0 0 0 4px var(--fg-1); }
  .custom-color { margin-top: var(--space-3); }
  .custom-color input { width: 40px; height: 30px; border: 1px solid var(--line-control); border-radius: var(--radius-sm); }

  /* A customer's head: links to their goods (pressable tiles, ds/kit.css list cards), then the tabs. */
  .customer-head { gap: var(--space-5); }
  .customer-links { gap: var(--space-2); }
  .customer-link {
    padding: var(--space-3) var(--space-3) var(--space-2h); border: 1px solid var(--line-1); border-radius: var(--radius-sm);
    background: var(--bg-sheet); box-shadow: var(--e-1);
    transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
  }
  .customer-link:hover { border-color: var(--line-2); box-shadow: var(--e-2); }
  .customer-link-label { font: var(--wt-mid) var(--ty-ui) var(--font-sans); color: var(--fg-2); }
  .customer-link-label::after { color: var(--fg-3); }
  .customer-link-value { font: var(--wt-code) var(--ty-code-title) / 1.15 var(--font-code); letter-spacing: var(--track-code); color: var(--fg-1); }
  .customer-link-note { font-size: var(--ty-note); color: var(--fg-3); }
  .customer-tabs { margin-bottom: calc(-1 * var(--space-2)); }
  .customer-tabs .count { margin-left: var(--space-1); font: var(--wt-regular) var(--ty-note) var(--font-sans); color: var(--fg-3); }

  /* The product master's dialog and hint. */
  .pm-dialog fieldset { margin-top: var(--space-5); }
  .pm-hint { font-size: var(--ty-note); color: var(--fg-3); }
  .field-row { gap: 6px; }
  .details-field { margin-bottom: var(--space-5); }
  .field-row input:first-child { background: var(--bg-sunken); border-color: transparent; box-shadow: none; font-weight: var(--wt-mid); color: var(--fg-2); }
  .field-row button { border: 1px solid transparent; border-radius: var(--radius-sm); background: transparent; color: var(--fg-3); }
  .field-row button:hover { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
}

@media (max-width: 900px) {
  :root[data-look^="aisle"] {
    .topbar { gap: var(--space-2); padding: 0 var(--space-3); }
    .brand h1 { font-size: var(--ty-body); }
    .tabs a { padding: 0 8px; font-size: var(--ty-ui); }
    .page { padding: var(--space-5) var(--space-4) 48px; }
    .page-head h2 { font-size: var(--ty-page); }
    .card { padding: var(--space-4); }
    .table-wrap { margin: 0 calc(-1 * var(--space-4)); padding: 0 var(--space-4); }
    .split { grid-template-columns: 1fr; }
  }
}
