/* Scrapper dashboard — "Operations Desk" (docs/design-system/DESIGN_SYSTEM.md).
   An ink navigation rail, bright mist-and-paper work surfaces, and exactly one
   green action per view. That design system ships as Tailwind/shadcn; this
   dashboard is plain Jinja + HTMX with no build step, so its tokens are carried
   over verbatim (section 1) and the recipes are re-expressed as plain classes
   below. Light only -- the system has no branded dark theme. */

/* ---------- 1. Brand tokens (verbatim from docs/design-system/theme.css) ---------- */

:root {
  color-scheme: light;

  --dj-blue: #2f5da8;
  --dj-cyan: #5bbbe3;
  --dj-green: #57e3a3;
  --dj-green-hover: #3dd598;
  --dj-white: #ffffff;
  --dj-ink: #1a1a1a;
  --dj-mist: #f5f7fa;
  --dj-pale: #e0ecf7;

  --dj-border-light: rgba(26, 26, 26, 0.1);
  --dj-border-light-firm: rgba(26, 26, 26, 0.14);
  --dj-border-dark: rgba(224, 236, 247, 0.16);
  --dj-border-dark-firm: rgba(224, 236, 247, 0.28);
  --dj-border-accent: rgba(87, 227, 163, 0.55);

  --dj-text-muted: rgba(26, 26, 26, 0.62);

  --dj-shadow-card: 0 10px 26px rgba(26, 26, 26, 0.06), inset 0 1px 0 rgba(255, 255, 255, 0.9);
  --dj-shadow-card-hover: 0 24px 52px rgba(26, 26, 26, 0.14), 0 0 0 1px rgba(87, 227, 163, 0.35);
  --dj-shadow-dark: 0 18px 42px rgba(26, 26, 26, 0.4), inset 0 1px 0 rgba(224, 236, 247, 0.16);

  --dj-ease: cubic-bezier(0.22, 1, 0.36, 1);
  --dj-dur-move: 0.26s;
  --dj-dur-color: 0.18s;

  --dj-radius-card: 12px;

  --dj-font-display: "Space Grotesk", ui-sans-serif, system-ui, sans-serif;
  --dj-font-label: "IBM Plex Mono", ui-monospace, monospace;

  --dj-tone-neutral-bg: oklch(0.955 0.006 255);
  --dj-tone-neutral-fg: oklch(0.45 0.02 255);
  --dj-tone-blue-bg: oklch(0.945 0.035 245);
  --dj-tone-blue-fg: oklch(0.45 0.14 255);
  --dj-tone-violet-bg: oklch(0.945 0.04 295);
  --dj-tone-violet-fg: oklch(0.46 0.17 295);
  --dj-tone-amber-bg: oklch(0.95 0.08 85);
  --dj-tone-amber-fg: oklch(0.47 0.11 60);
  --dj-tone-orange-bg: oklch(0.945 0.05 50);
  --dj-tone-orange-fg: oklch(0.49 0.15 45);
  --dj-tone-red-bg: oklch(0.945 0.035 25);
  --dj-tone-red-fg: oklch(0.51 0.19 27);
  --dj-tone-green-bg: oklch(0.945 0.06 160);
  --dj-tone-green-fg: oklch(0.44 0.1 160);

  --destructive: oklch(0.577 0.245 27.325);
}

/* ---------- 2. Dashboard roles, mapped onto the brand ---------- */

:root {
  --ink: var(--dj-ink);
  --ink-soft: rgba(255, 255, 255, 0.06);
  --ink-softer: rgba(255, 255, 255, 0.04);
  --sidebar-text: var(--dj-pale);
  --sidebar-text-dim: rgba(224, 236, 247, 0.55);
  --sidebar-border: var(--dj-border-dark);

  /* Green is the next action / current location only (design system rule 1). */
  --accent: var(--dj-green);
  --focus-ring: 0 0 0 3px rgba(87, 227, 163, 0.45);

  --paper: var(--dj-mist);
  --surface: var(--dj-white);
  --surface-sunk: rgba(26, 26, 26, 0.03);
  --border: var(--dj-border-light);
  --border-strong: var(--dj-border-light-firm);
  --text: var(--dj-ink);
  --text-muted: var(--dj-text-muted);
  --link: var(--dj-blue);

  --success: var(--dj-tone-green-fg);
  --success-bg: var(--dj-tone-green-bg);
  --danger: var(--dj-tone-red-fg);
  --danger-bg: var(--dj-tone-red-bg);
  --warning: var(--dj-tone-amber-fg);
  --warning-bg: var(--dj-tone-amber-bg);

  --radius-sm: 10px;              /* controls */
  --radius: var(--dj-radius-card); /* cards */
  --radius-lg: 14px;              /* dialogs */
  --sidebar-w: 240px;

  --font-sans: var(--dj-font-display);
  --font-mono: var(--dj-font-label);

  --shadow-sm: var(--dj-shadow-card);
  --shadow-md: 0 24px 52px rgba(26, 26, 26, 0.14);
}

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

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--paper);
  color: var(--text);
  line-height: 1.5;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

::selection {
  background: var(--dj-pale);
  color: var(--dj-ink);
}

@media (prefers-reduced-motion: no-preference) {
  .sidebar,
  .nav-scrim {
    transition: transform var(--dj-dur-move) var(--dj-ease), opacity var(--dj-dur-move) var(--dj-ease);
  }
}

h1, h2, h3 {
  font-family: var(--font-sans);
  color: var(--text);
  line-height: 1.25;
  text-wrap: balance;
}

/* Headline: one per page (design system §4). */
h1 {
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 0 0 1rem;
}

/* Section headings: Title style. */
h2 {
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 2rem 0 0.75rem;
}

h2:first-child {
  margin-top: 0;
}

h3 {
  font-size: 0.9375rem;
  font-weight: 600;
  margin: 0 0 0.5rem;
}

p {
  margin: 0 0 0.9rem;
}

a {
  color: var(--link);
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
}

:focus-visible {
  outline: 3px solid var(--dj-green);
  outline-offset: 2px;
}

code {
  font-family: var(--font-mono);
  font-size: 0.85em;
}

/* Mono uppercase label about data: column headers, rail groups, field labels. */
.kicker {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.icon {
  width: 16px;
  height: 16px;
  flex: none;
}

/* ---------- shell / layout ---------- */

.app-shell {
  min-height: 100vh;
}

/* Visually hidden, not display:none -- a checkbox this app's only path to
   opening the mobile nav has to stay reachable by Tab and toggleable with
   Space, not just tap. Its focus ring is drawn on .nav-burger below since
   the checkbox itself is invisible. */
.nav-toggle-input {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
  outline: none;
}

.nav-toggle-input:focus-visible ~ .topbar .nav-burger {
  outline: 3px solid var(--dj-green);
  outline-offset: 2px;
}

.topbar {
  display: none;
}

.sidebar-close {
  display: none;
}

.sidebar {
  display: flex;
  flex-direction: column;
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  background: var(--dj-ink);
  color: var(--sidebar-text);
  z-index: 40;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 1.25rem 1.25rem;
  border-bottom: 1px solid var(--sidebar-border);
}

/* App mark: an ink letter on signal cyan -- cyan is the system's "app name
   on the rail" colour, keeping green free for the current location. */
.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  flex: none;
  border-radius: 8px;
  background: var(--dj-cyan);
  color: var(--dj-ink);
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: 1rem;
}

.sidebar-brand .brand-text {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  line-height: 1.2;
}

.sidebar-brand strong {
  color: #fff;
  font-size: 0.9375rem;
  font-weight: 600;
}

.brand-text span {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--dj-cyan);
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 0.75rem;
}

.nav-group + .nav-group {
  margin-top: 1.25rem;
}

.nav-eyebrow {
  margin: 0 0 0.375rem;
  padding: 0 0.75rem;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: rgba(224, 236, 247, 0.4);
}

.nav-link {
  display: block;
  padding: 0.5rem 0.75rem;
  margin: 0.125rem 0;
  border-radius: 6px;
  border-left: 2px solid transparent;
  color: rgba(224, 236, 247, 0.72);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  transition: background-color var(--dj-dur-color) var(--dj-ease), color var(--dj-dur-color) var(--dj-ease), border-color var(--dj-dur-color) var(--dj-ease);
}

.nav-link:hover {
  background: var(--ink-softer);
  border-left-color: var(--dj-border-dark-firm);
  color: #fff;
}

.nav-link.active {
  background: var(--ink-soft);
  border-left-color: var(--dj-green);
  color: #fff;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--sidebar-border);
}

.user-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  flex: none;
  border-radius: 999px;
  background: rgba(224, 236, 247, 0.12);
  color: var(--dj-pale);
  font-weight: 600;
  font-size: 0.8125rem;
}

.user-meta {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.user-email {
  font-size: 0.8125rem;
  color: var(--sidebar-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 150px;
}

.link-button {
  background: none;
  border: none;
  padding: 0;
  height: auto;
  font: inherit;
  font-size: 0.75rem;
  color: var(--sidebar-text-dim);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
  align-self: flex-start;
}

.link-button:hover {
  background: none;
  color: #fff;
}

.user-actions {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
}

.content {
  margin-left: var(--sidebar-w);
  padding: 1.5rem 2rem 4rem;
  max-width: calc(1280px + var(--sidebar-w));
}

.app-shell--bare {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: var(--paper);
}

.app-shell--bare .content {
  margin: 0;
  padding: 0;
  max-width: none;
}

.nav-scrim {
  display: none;
}

/* ---------- mobile shell ---------- */

@media (max-width: 899px) {
  .topbar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    position: sticky;
    top: 0;
    z-index: 30;
    height: 56px;
    padding: 0 1rem;
    background: rgba(255, 255, 255, 0.92);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-strong);
    color: var(--text);
  }

  .topbar-brand {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-weight: 600;
    font-size: 0.9375rem;
  }

  .topbar-brand .brand-mark {
    width: 26px;
    height: 26px;
    border-radius: 7px;
    font-size: 0.8125rem;
  }

  .nav-burger {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 4px;
    /* 44px touch target -- this is the only way to reach the nav on a
       phone, so it gets the generous hit area, offset by a matching
       negative margin so it doesn't push the rest of the topbar around. */
    width: 44px;
    height: 44px;
    margin: 0 -10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
  }

  .nav-burger span {
    display: block;
    width: 18px;
    height: 2px;
    border-radius: 2px;
    background: var(--dj-ink);
  }

  .sidebar {
    width: 256px;
    transform: translateX(-100%);
    box-shadow: var(--dj-shadow-dark);
    max-width: 85vw;
  }

  .nav-toggle-input:checked ~ .sidebar {
    transform: translateX(0);
  }

  .nav-toggle-input:checked ~ .nav-scrim {
    display: block;
  }

  .nav-scrim {
    position: fixed;
    inset: 0;
    z-index: 35;
    background: rgba(0, 0, 0, 0.4);
  }

  /* The drawer overlays the page rather than replacing it -- without this
     the content underneath keeps scrolling with it, which reads as broken
     on touch. */
  body:has(.nav-toggle-input:checked) {
    overflow: hidden;
  }

  .sidebar-brand {
    position: relative;
  }

  .sidebar-close {
    display: flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    top: 50%;
    right: 0.5rem;
    transform: translateY(-50%);
    width: 44px;
    height: 44px;
    border-radius: var(--radius-sm);
    color: var(--sidebar-text-dim);
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
  }

  .sidebar-close:hover,
  .sidebar-close:focus-visible {
    background: var(--ink-soft);
    color: #fff;
  }

  .content {
    margin-left: 0;
    padding: 1rem 1rem 3rem;
  }
}

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

form {
  margin: 0;
}

label {
  font-weight: 500;
  font-size: 0.875rem;
}

.field-hint {
  display: block;
  font-weight: 400;
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-top: 0.375rem;
}

.field-hint code {
  font-size: 0.8125rem;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"],
input[type="url"],
select,
textarea {
  font: inherit;
  font-size: 0.875rem;
  height: 36px;
  padding: 0 0.75rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  min-width: 12rem;
  transition: border-color var(--dj-dur-color) var(--dj-ease), box-shadow var(--dj-dur-color) var(--dj-ease);
}

select {
  padding-right: 2rem;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%231a1a1a' stroke-opacity='.55' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.6rem center;
  background-size: 16px;
}

textarea {
  height: auto;
  padding: 0.5rem 0.75rem;
  resize: vertical;
  min-height: 6rem;
  line-height: 1.5;
}

::placeholder {
  color: rgba(26, 26, 26, 0.45);
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="search"]:focus,
input[type="url"]:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--dj-green);
  box-shadow: var(--focus-ring);
}

/* Inputs are 16px on phones so iOS doesn't zoom on focus (rule 10). */
@media (max-width: 767px) {
  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="search"],
  input[type="url"],
  select,
  textarea {
    font-size: 16px;
    height: 44px;
  }

  textarea {
    height: auto;
  }
}

/* Vertical stacked-field form: label above control, fields gap-4. */
.field-grid {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 1rem;
}

.field-grid label {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  width: 100%;
}

.field-grid input[type="text"],
.field-grid select,
.field-grid textarea {
  width: 100%;
  min-width: 0;
}

.field-grid .field-hint {
  width: 100%;
  margin-top: -0.5rem;
}

.field-grid button {
  align-self: flex-start;
}

input[type="checkbox"] {
  accent-color: var(--dj-ink);
  width: 16px;
  height: 16px;
  margin: 0;
  cursor: pointer;
}

/* Buttons. Quiet by default (outline); exactly one .button-primary per view. */
button,
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  height: 32px;
  padding: 0 0.875rem;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  text-decoration: none;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: background-color var(--dj-dur-color) var(--dj-ease), border-color var(--dj-dur-color) var(--dj-ease), color var(--dj-dur-color) var(--dj-ease);
}

button:hover,
.btn:hover {
  background: var(--dj-mist);
  border-color: rgba(26, 26, 26, 0.24);
}

button:active,
.btn:active {
  background: rgba(26, 26, 26, 0.06);
}

button:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

.button-primary {
  background: var(--dj-green);
  border-color: var(--dj-green);
  color: var(--dj-ink);
  font-weight: 600;
}

.button-primary:hover {
  background: var(--dj-green-hover);
  border-color: var(--dj-green-hover);
}

.button-ghost {
  background: transparent;
  border-color: transparent;
}

.button-ghost:hover {
  background: rgba(26, 26, 26, 0.06);
  border-color: transparent;
}

/* Row-level destructive icon: muted at rest, red only on intent. */
.product-table .col-actions .button-ghost {
  color: var(--text-muted);
}

.product-table .col-actions .button-ghost:hover,
.product-table .col-actions .button-ghost:focus-visible {
  color: var(--destructive);
  background: color-mix(in oklch, var(--destructive) 10%, transparent);
}

/* Destructive: a 10% red wash with red text, never a solid slab (rule 6). */
.button-danger {
  background: color-mix(in oklch, var(--destructive) 10%, transparent);
  border-color: transparent;
  color: var(--destructive);
}

.button-danger:hover {
  background: color-mix(in oklch, var(--destructive) 18%, transparent);
  border-color: transparent;
  color: var(--destructive);
}

.button-small {
  height: 28px;
  padding: 0 0.625rem;
  font-size: 0.8125rem;
}

.button-icon {
  width: 32px;
  padding: 0;
}

.button-icon.button-small {
  width: 28px;
}

.button .icon,
button .icon,
.btn .icon {
  width: 16px;
  height: 16px;
}

@media (max-width: 767px) {
  button,
  .btn {
    min-height: 40px;
  }

  .button-icon {
    width: 44px;
    min-height: 44px;
  }

  .button-icon.button-small {
    width: 44px;
  }

  .link-button {
    min-height: 0;
  }
}

/* Card: lit, not stacked -- hairline + soft drop + 1px inner highlight. */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: var(--shadow-sm);
  margin-bottom: 1rem;
}

@media (min-width: 640px) {
  .panel {
    padding: 1.25rem;
  }
}

.danger-panel {
  margin-top: 1rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.danger-panel form {
  display: inline;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: end;
}

.filters label {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-muted);
}

.filters label > input,
.filters label > select {
  font-family: var(--font-sans);
  letter-spacing: normal;
  text-transform: none;
  font-weight: 400;
}

details {
  margin: 0.9rem 0;
}

summary {
  cursor: pointer;
  font-weight: 500;
  font-size: 0.875rem;
  color: var(--text-muted);
  padding: 0.4rem 0;
}

summary:hover {
  color: var(--text);
}

fieldset {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.9rem 1rem;
  margin: 0.9rem 0;
}

legend {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 0 0.4rem;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 400;
  font-size: 0.875rem;
  padding: 0.25rem 0;
}

.form-error {
  display: flex;
  gap: 0.5rem;
  align-items: flex-start;
  color: var(--destructive);
  background: color-mix(in oklch, var(--destructive) 5%, transparent);
  border: 1px solid color-mix(in oklch, var(--destructive) 30%, transparent);
  border-radius: var(--radius-sm);
  padding: 0.75rem;
  font-size: 0.875rem;
}

.form-error .icon {
  margin-top: 2px;
}

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

/* Wide tables scroll inside their own card instead of pushing the page
   sideways. Edge shadows only appear once there's more to see that way
   (local-attachment masks ride with the content). */
.table-scroll {
  overflow-x: auto;
  background:
    linear-gradient(to right, var(--surface), color-mix(in srgb, var(--surface) 0%, transparent)) 0 0,
    linear-gradient(to left, var(--surface), color-mix(in srgb, var(--surface) 0%, transparent)) 100% 0,
    linear-gradient(to right, rgba(0, 0, 0, 0.12), rgba(0, 0, 0, 0)) 0 0,
    linear-gradient(to left, rgba(0, 0, 0, 0.12), rgba(0, 0, 0, 0)) 100% 0;
  background-color: var(--surface);
  background-repeat: no-repeat;
  background-size: 28px 100%, 28px 100%, 10px 100%, 10px 100%;
  background-attachment: local, local, scroll, scroll;
}

table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 0.5rem;
  background: var(--surface);
}

th, td {
  text-align: left;
  padding: 0.625rem 0.75rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  font-size: 0.875rem;
}

th {
  font-family: var(--font-mono);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  background: var(--surface);
  white-space: nowrap;
}

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

tbody tr:hover {
  background: var(--dj-mist);
}

tbody tr td[colspan] {
  color: var(--text-muted);
  text-align: center;
  padding: 2rem 1rem;
}

/* Timestamps and counts are marked per cell, not by column position --
   the runs tables don't share a column order. */
.cell-time {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
  font-size: 0.8125rem;
}

th.num,
td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ---------- status pills (design system §3 "Status tones") ---------- */

.pill,
.badge {
  --tone-bg: var(--dj-tone-neutral-bg);
  --tone-fg: var(--dj-tone-neutral-fg);
  display: inline-flex;
  width: fit-content;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  border-radius: 9999px;
  padding: 3px 9px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  line-height: 14px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: var(--tone-bg);
  color: var(--tone-fg);
  box-shadow: inset 0 0 0 1px color-mix(in oklch, var(--tone-fg) 16%, transparent);
  vertical-align: middle;
}

.pill {
  padding-left: 7px;
}

.pill > .icon {
  width: 12px;
  height: 12px;
  stroke-width: 2.25;
}

/* Tone classes come after .pill/.badge so they win the cascade. */
.dj-tone-neutral { --tone-bg: var(--dj-tone-neutral-bg); --tone-fg: var(--dj-tone-neutral-fg); }
.dj-tone-blue { --tone-bg: var(--dj-tone-blue-bg); --tone-fg: var(--dj-tone-blue-fg); }
.dj-tone-violet { --tone-bg: var(--dj-tone-violet-bg); --tone-fg: var(--dj-tone-violet-fg); }
.dj-tone-amber { --tone-bg: var(--dj-tone-amber-bg); --tone-fg: var(--dj-tone-amber-fg); }
.dj-tone-orange { --tone-bg: var(--dj-tone-orange-bg); --tone-fg: var(--dj-tone-orange-fg); }
.dj-tone-red { --tone-bg: var(--dj-tone-red-bg); --tone-fg: var(--dj-tone-red-fg); }
.dj-tone-green { --tone-bg: var(--dj-tone-green-bg); --tone-fg: var(--dj-tone-green-fg); }

/* Legacy badge modifiers used across the other feature pages, re-pointed
   at tones. */
.badge-enabled,
.badge-availability-in_stock,
.badge-status-success,
.badge-status-new {
  --tone-bg: var(--dj-tone-green-bg);
  --tone-fg: var(--dj-tone-green-fg);
}

.badge-availability-preorder,
.badge-status-partial {
  --tone-bg: var(--dj-tone-amber-bg);
  --tone-fg: var(--dj-tone-amber-fg);
}

.badge-status-running,
.badge-status-update {
  --tone-bg: var(--dj-tone-blue-bg);
  --tone-fg: var(--dj-tone-blue-fg);
}

.badge-status-locked {
  --tone-bg: var(--dj-tone-violet-bg);
  --tone-fg: var(--dj-tone-violet-fg);
}

.badge-status-failed,
.badge-status-invalid {
  --tone-bg: var(--dj-tone-red-bg);
  --tone-fg: var(--dj-tone-red-fg);
}

/* Data values (source ids, categories, a Shopify Type) are not labels --
   they stay in the sans face (rule 4), on the lightest fill. */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  max-width: 100%;
  padding: 2px 10px;
  border-radius: 9999px;
  background: var(--dj-pale);
  color: var(--dj-ink);
  font-size: 0.8125rem;
  font-weight: 500;
  line-height: 20px;
  text-decoration: none;
  overflow-wrap: anywhere;
}

/* ---------- run progress bar (imports in progress, TECH_SPEC §8.5) ---------- */

.progress-bar {
  width: 96px;
  height: 6px;
  border-radius: 999px;
  background: var(--dj-pale);
  overflow: hidden;
  display: inline-block;
  vertical-align: middle;
}

.progress-bar__fill {
  height: 100%;
  background: var(--dj-blue);
  border-radius: 999px;
  transition: width var(--dj-dur-move) var(--dj-ease);
}

.progress-bar__label {
  display: inline-block;
  margin-left: 8px;
  font-size: 0.8125rem;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
  vertical-align: middle;
}

.progress-bar__label--muted {
  font-style: italic;
}

.progress-bar--wide {
  width: min(100%, 320px);
}

.upload-status {
  margin: 4px 0 12px;
}

.upload-status[hidden] {
  display: none;
}

/* ---------- misc components ---------- */

.thumb {
  display: block;
  width: 44px;
  height: 44px;
  object-fit: cover;
  border-radius: 8px;
  background: var(--dj-mist);
  box-shadow: inset 0 0 0 1px var(--border);
}

img.thumb {
  box-shadow: none;
  outline: 1px solid var(--border);
  outline-offset: -1px;
}

.thumb-placeholder {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: rgba(26, 26, 26, 0.3);
  border: 1px dashed var(--border-strong);
  box-shadow: none;
}

.lightbox-trigger {
  cursor: zoom-in;
}

ul.tree {
  list-style: none;
  padding-left: 1.2rem;
  margin: 0.25rem 0;
}

ul.tree > li:first-child {
  padding-left: 0;
}

ul.tree a {
  text-decoration: none;
  font-weight: 500;
}

ul.tree a:hover {
  text-decoration: underline;
}

.count {
  color: var(--text-muted);
  font-size: 0.8125rem;
  font-variant-numeric: tabular-nums;
}

/* ---------- image lightbox ---------- */

body.lightbox-open {
  overflow: hidden;
}

.lightbox-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 10, 10, 0.86);
  padding: 3rem;
}

.lightbox-overlay[hidden] {
  display: none;
}

.lightbox-image {
  max-width: min(90vw, 1100px);
  max-height: 85vh;
  object-fit: contain;
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  background: var(--surface);
}

.lightbox-close,
.lightbox-nav {
  position: absolute;
  border: none;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  border-radius: 999px;
  width: 44px;
  height: 44px;
  padding: 0;
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox-close:hover,
.lightbox-nav:hover {
  background: rgba(255, 255, 255, 0.24);
  border: none;
}

.lightbox-close {
  top: 1.25rem;
  right: 1.25rem;
}

.lightbox-prev {
  left: 1.25rem;
  top: 50%;
  transform: translateY(-50%);
}

.lightbox-next {
  right: 1.25rem;
  top: 50%;
  transform: translateY(-50%);
}

.lightbox-nav[hidden] {
  display: none;
}

.lightbox-counter {
  position: absolute;
  bottom: 1.25rem;
  left: 50%;
  transform: translateX(-50%);
  color: #fff;
  font-size: 0.8125rem;
  font-variant-numeric: tabular-nums;
  opacity: 0.85;
}

/* ---------- type-to-confirm dialog ---------- */

body.danger-confirm-open {
  overflow: hidden;
}

.danger-confirm-overlay {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.4);
  padding: 1rem;
}

.danger-confirm-overlay[hidden] {
  display: none;
}

.danger-confirm-box {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 1.25rem;
  max-width: 420px;
  width: 100%;
}

.danger-confirm-message {
  margin: 0 0 0.75rem;
  font-weight: 600;
  font-size: 0.9375rem;
}

.danger-confirm-hint {
  margin: 0 0 0.75rem;
  color: var(--text-muted);
  font-size: 0.875rem;
}

.danger-confirm-hint strong {
  color: var(--destructive);
  font-family: var(--font-mono);
}

.danger-confirm-input {
  width: 100%;
  font: inherit;
  height: 36px;
  padding: 0 0.75rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  margin-bottom: 1rem;
}

.danger-confirm-input:focus {
  outline: none;
  border-color: var(--dj-green);
  box-shadow: var(--focus-ring);
}

.danger-confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

.hint {
  color: var(--text-muted);
  font-size: 0.875rem;
}

/* Sub-nav for a sidebar section that spans more than one page. */
.section-tabs {
  display: flex;
  gap: 0.25rem;
  border-bottom: 1px solid var(--border);
  margin: -0.25rem 0 1.25rem;
}

.section-tab {
  padding: 0.5rem 0.9rem;
  margin-bottom: -1px;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
}

.section-tab:hover {
  color: var(--text);
}

.section-tab.active {
  color: var(--text);
  border-bottom-color: var(--dj-green);
}

.pagination {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  margin-top: 1rem;
  font-size: 0.875rem;
}

.pagination a {
  text-decoration: none;
  font-weight: 500;
}

.empty-panel {
  max-width: 42rem;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  margin-bottom: 0.75rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
}

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

.inline-form {
  display: inline;
}

/* Identifiers (SKUs, handles, external ids) are code-like data. */
.mono {
  font-family: var(--font-mono);
  font-size: 0.9em;
}

.table-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-width: 170px;
}

.table-actions form {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.table-actions label {
  font-size: 0.75rem;
}

.table-actions input[type="password"] {
  min-width: 0;
  width: 100%;
}

.table-actions button {
  align-self: flex-start;
}

.table-actions details {
  margin: 0;
}

.table-actions summary {
  font-size: 0.8125rem;
  padding: 0.15rem 0;
}

.error-detail {
  margin: 0.2rem 0 0;
}

.error-detail summary {
  font-size: 0.75rem;
  padding: 0;
  color: var(--destructive);
}

.error-detail__text,
.error-detail__list {
  font-size: 0.8125rem;
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0.3rem 0 0;
  max-width: 28rem;
}

.error-detail__list {
  padding-left: 1.1rem;
}

/* ---------- auth page (design system §7.4: centred card on mist) ---------- */

.auth-card {
  width: min(384px, calc(100vw - 2rem));
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.75rem 1.5rem;
  box-shadow: var(--shadow-sm);
}

.auth-card .brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  font-size: 1.1rem;
  margin-bottom: 1rem;
}

.auth-card h1 {
  font-size: 1.25rem;
  margin-bottom: 0.375rem;
}

.auth-card p.hint {
  margin-bottom: 1.25rem;
}

.auth-card label {
  display: block;
  margin: 1rem 0 0.5rem;
}

.auth-card input {
  width: 100%;
}

.auth-card button {
  width: 100%;
  margin-top: 1.5rem;
  height: 40px;
  background: var(--dj-green);
  border-color: var(--dj-green);
  color: var(--dj-ink);
  font-weight: 600;
}

.auth-card button:hover {
  background: var(--dj-green-hover);
  border-color: var(--dj-green-hover);
}

.auth-card .form-error {
  margin: 1rem 0 0;
}

.auth-card .notice {
  margin: 1rem 0 0;
  font-size: 0.875rem;
}

/* Label + "Forgot password?" on one line above the password field. */
.auth-label-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  margin: 1rem 0 0.5rem;
}

.auth-card .auth-label-row label {
  margin: 0;
}

.auth-link {
  font-size: 0.8125rem;
  color: var(--text-muted);
  text-decoration: underline;
  text-underline-offset: 3px;
}

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

.auth-footer {
  margin-top: 1.25rem;
  text-align: center;
}

/* Change-password page: the auth card inside the app shell. */
.auth-card--inline {
  margin: 0 auto;
}

/* =====================================================================
   Products -- list (features/products/list.html, _table.html)
   ===================================================================== */

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

.page-head h1 {
  margin: 0;
}

.page-head-meta {
  margin: 0.25rem 0 0;
  color: var(--text-muted);
  font-size: 0.875rem;
  font-variant-numeric: tabular-nums;
}

.product-filters {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 0.75rem;
  align-items: end;
}

.product-filters label {
  min-width: 0;
}

.product-filters select,
.product-filters input[type="search"] {
  width: 100%;
  min-width: 0;
}

.product-filters .filter-search {
  grid-column: span 2;
}

.search-field {
  position: relative;
  display: block;
}

.search-field > .icon {
  position: absolute;
  left: 0.7rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.search-field input[type="search"] {
  padding-left: 2.1rem;
}

.filter-foot {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  min-height: 28px;
}

.filter-foot:empty,
.js .filter-foot:not(:has(.chip, .filter-clear)) {
  display: none;
}

.filter-foot .chip {
  font-family: var(--font-sans);
  letter-spacing: normal;
  text-transform: none;
}

.filter-clear {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-muted);
  font-family: var(--font-sans);
  letter-spacing: normal;
  text-transform: none;
}

.filter-clear:hover {
  color: var(--text);
}

/* Filtering is live (HTMX on change); the button is the no-JS fallback. */
.js .filter-submit {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

@media (max-width: 1099px) {
  .product-filters {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .product-filters .filter-search {
    grid-column: span 3;
    order: -1;
  }
}

@media (max-width: 639px) {
  .product-filters {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .product-filters .filter-search {
    grid-column: span 2;
  }
}

/* Results card: toolbar + table + footer, one level of elevation. */
.results {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: opacity var(--dj-dur-color) var(--dj-ease);
}

.htmx-request .results,
.results.htmx-request {
  opacity: 0.55;
}

.results-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  padding: 0.625rem 0.75rem;
  border-bottom: 1px solid var(--border);
  min-height: 52px;
}

.selection-count {
  font-size: 0.875rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  margin-right: auto;
  padding-left: 0.25rem;
}

.selection-count[data-empty] {
  color: var(--text-muted);
  font-weight: 400;
}

.results-toolbar .toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.results table {
  margin: 0;
}

.product-table th:first-child,
.product-table td:first-child {
  width: 40px;
  padding-right: 0;
}

.product-table th:first-child {
  vertical-align: middle;
}

.product-table {
  min-width: 720px;
}

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

.product-table td.col-check {
  padding-top: 0.625rem;
}

.product-table .col-thumb {
  width: 60px;
}

.product-table .col-actions {
  width: 52px;
  text-align: right;
}

.product-table tbody tr {
  transition: background-color var(--dj-dur-color) var(--dj-ease);
}

.product-table tbody tr:has(.row-select:checked) {
  background: color-mix(in srgb, var(--dj-pale) 60%, transparent);
}

.product-name {
  display: block;
  color: var(--text);
  font-weight: 500;
  text-decoration: none;
  overflow-wrap: anywhere;
  max-width: 44ch;
}

.product-name:hover {
  text-decoration: underline;
}

.product-sub {
  display: block;
  margin-top: 0.125rem;
  color: var(--text-muted);
  font-size: 0.8125rem;
}

.cell-muted {
  color: var(--text-muted);
  overflow-wrap: anywhere;
}

.results-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  margin: 1rem;
  padding: 2.5rem 1rem;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  color: var(--text-muted);
  text-align: center;
  font-size: 0.875rem;
}

.results-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.625rem 0.75rem;
  border-top: 1px solid var(--border);
  font-size: 0.875rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.pager {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.pager-label {
  padding: 0 0.25rem;
}

/* "Everything matching" -- acts on the whole filter, not the page. */
.scope-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.75rem 1.5rem;
  align-items: center;
  margin-top: 1rem;
}

.scope-actions h2 {
  margin: 0 0 0.25rem;
}

.scope-actions p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.875rem;
  max-width: 62ch;
}

.scope-actions .scope-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: flex-end;
}

.scope-actions .scope-danger {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
  font-size: 0.875rem;
}

.scope-actions .scope-danger a {
  color: var(--text-muted);
}

@media (max-width: 767px) {
  .scope-actions {
    grid-template-columns: 1fr;
  }

  .scope-actions .scope-buttons {
    justify-content: flex-start;
  }
}

/* Mobile Record Row (design system §7.8): below md the table reflows into
   one divided list -- same markup, so selection and actions stay wired.
   Source/vendor collapse into one muted meta line; the pills move under
   the name. */
.product-sub-mobile,
.product-pills-mobile {
  display: none;
}

@media (max-width: 767px) {
  .product-table {
    min-width: 0;
  }

  .product-table thead {
    display: none;
  }

  .product-table,
  .product-table tbody {
    display: block;
  }

  .product-table tbody tr {
    display: grid;
    grid-template-columns: 20px 56px minmax(0, 1fr) 44px;
    align-items: start;
    column-gap: 0.75rem;
    padding: 0.75rem;
    border-bottom: 1px solid var(--border);
  }

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

  .product-table td {
    display: block;
    padding: 0;
    border: none;
    width: auto;
  }

  .product-table td.col-source,
  .product-table td.col-vendor,
  .product-table td.col-avail,
  .product-table td.col-sync {
    display: none;
  }

  .product-table td.col-check {
    padding-top: 1.125rem;
  }

  .product-table td.col-actions {
    margin-top: 0.375rem;
  }

  .product-table .thumb {
    width: 56px;
    height: 56px;
  }

  .product-table .product-name {
    font-size: 0.9375rem;
  }

  .product-sub-mobile {
    display: block;
  }

  .product-pills-mobile {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
    margin-top: 0.5rem;
  }

  .product-table input.row-select {
    width: 20px;
    height: 20px;
  }

  .results-toolbar .toolbar-actions {
    width: 100%;
  }

  .results-toolbar .toolbar-actions button {
    flex: 1 1 0;
  }

  .results-toolbar .toolbar-actions .button-primary {
    flex-basis: 100%;
  }
}

/* =====================================================================
   Products -- detail (features/products/detail.html)
   ===================================================================== */

.detail-head {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  margin-bottom: 1.5rem;
}

.detail-head .thumb {
  width: 72px;
  height: 72px;
  border-radius: 10px;
}

.detail-head-body {
  min-width: 0;
  flex: 1;
}

.detail-head h1 {
  margin: 0 0 0.5rem;
  text-align: left;
  overflow-wrap: anywhere;
}

.detail-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.375rem 0.75rem;
  color: var(--text-muted);
  font-size: 0.875rem;
}

.detail-meta .pills {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.375rem;
}

.meta-sep {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.5;
}

.detail-meta a {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.detail-meta a .icon {
  width: 14px;
  height: 14px;
}

.detail-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 1rem;
  align-items: start;
}

.detail-main,
.detail-aside {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-width: 0;
}

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

  /* On one column, curation (the reason anyone opens this page) leads. */
  .detail-aside {
    order: -1;
  }
}

.detail-layout .panel {
  margin: 0;
}

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

.panel-head h2 {
  margin: 0;
}

.panel-head .count {
  white-space: nowrap;
}

.panel-note {
  color: var(--text-muted);
  font-size: 0.8125rem;
  margin: 0.75rem 0 0;
}

.panel-note:first-child {
  margin-top: 0;
}

/* Curation status block: state, explanation, action. */
.status-block + .status-block {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.status-block .status-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.375rem;
}

.status-block .status-title {
  font-weight: 600;
  font-size: 0.9375rem;
}

.status-block p {
  margin: 0 0 0.75rem;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.status-block form button {
  width: 100%;
}

.status-alert {
  display: flex;
  gap: 0.5rem;
  margin: 0 0 0.75rem;
  padding: 0.625rem 0.75rem;
  border-radius: var(--radius-sm);
  background: var(--dj-tone-amber-bg);
  color: var(--dj-tone-amber-fg);
  font-size: 0.8125rem;
  line-height: 1.45;
}

.status-alert .icon {
  margin-top: 1px;
}

/* Definition rows: label above value on the rail. */
.facts {
  display: grid;
  gap: 0.875rem;
  margin: 0;
}

.facts > div {
  min-width: 0;
}

.facts dt {
  margin-bottom: 0.25rem;
}

.facts dd {
  margin: 0;
  font-size: 0.875rem;
  overflow-wrap: anywhere;
}

.facts .chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
}

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

.handle-form {
  display: flex;
  gap: 0.5rem;
}

.handle-form input[type="text"] {
  flex: 1;
  min-width: 0;
  font-family: var(--font-mono);
  font-size: 0.8125rem;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  margin-bottom: 0.875rem;
}

/* Tag toggles: the checkbox is the state; the chip is its label. */
.tag-toggle {
  position: relative;
  display: inline-flex;
}

.tag-toggle input {
  position: absolute;
  opacity: 0;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  cursor: pointer;
}

.tag-toggle > span {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 3px 10px;
  border-radius: 9999px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 0.8125rem;
  font-weight: 500;
  line-height: 20px;
  transition: background-color var(--dj-dur-color) var(--dj-ease), border-color var(--dj-dur-color) var(--dj-ease), color var(--dj-dur-color) var(--dj-ease);
}

.tag-toggle > span .icon {
  width: 13px;
  height: 13px;
  display: none;
}

.tag-toggle input:checked + span {
  background: var(--dj-pale);
  border-color: transparent;
  color: var(--dj-ink);
}

.tag-toggle input:checked + span .icon {
  display: inline;
}

.tag-toggle input:focus-visible + span {
  outline: 3px solid var(--dj-green);
  outline-offset: 2px;
}

.tag-toggle:hover > span {
  border-color: rgba(26, 26, 26, 0.3);
}

/* Image gallery */
.image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  gap: 0.75rem;
}

.image-choice {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin: 0;
}

.image-choice img {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 10px;
  background: var(--dj-mist);
  outline: 1px solid var(--border);
  outline-offset: -1px;
}

.image-choice.is-default img {
  outline: 2px solid var(--dj-ink);
  outline-offset: -2px;
}

.image-choice figcaption {
  min-height: 28px;
  display: flex;
  align-items: center;
}

.image-choice button {
  width: 100%;
}

.image-default-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.image-default-badge .icon {
  width: 12px;
  height: 12px;
}

.image-grid--small {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  margin-top: 0.5rem;
}

.image-grid--small img {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 6px;
  outline: 1px solid var(--border);
  outline-offset: -1px;
}

/* Rendered scraped description: a readable measure, contained. */
.description-body {
  max-width: 72ch;
  text-align: left;
  font-size: 0.9375rem;
  line-height: 1.65;
  overflow-wrap: anywhere;
}

.description-body > :first-child {
  margin-top: 0;
}

.description-body > :last-child {
  margin-bottom: 0;
}

.description-body img {
  max-width: 100%;
  height: auto;
}

/* Variants: a divided list, not cards in a card. */
.variant-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.variant-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.75rem 1rem;
  padding: 0.875rem 0;
  border-top: 1px solid var(--border);
}

.variant-row:first-child {
  border-top: none;
  padding-top: 0;
}

.variant-row:last-child {
  padding-bottom: 0;
}

.variant-title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  font-weight: 500;
}

.variant-price {
  font-size: 1rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.variant-compare {
  color: var(--text-muted);
  text-decoration: line-through;
  font-variant-numeric: tabular-nums;
  font-size: 0.875rem;
}

/* Import preview: one line per variant's price / compare-at. */
.preview-prices {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.25rem;
}

.preview-prices > li {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.375rem;
}

.preview-prices .variant-price {
  font-size: 0.875rem;
}

.preview-prices__tag {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0 0.375rem;
  border-radius: 999px;
  background: var(--dj-tone-green-bg);
  color: var(--dj-tone-green-fg);
}

.preview-prices__was {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.variant-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.25rem;
  margin: 0;
  font-size: 0.8125rem;
}

.variant-facts > div {
  display: flex;
  gap: 0.375rem;
  align-items: baseline;
}

.variant-facts dt {
  color: var(--text-muted);
}

.variant-facts dd {
  margin: 0;
  font-variant-numeric: tabular-nums;
}

.variant-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.5rem;
}

@media (max-width: 639px) {
  .variant-row {
    grid-template-columns: 1fr;
  }

  .variant-side {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
}

.raw-attrs {
  margin: 0;
  background: var(--dj-mist);
  border-radius: var(--radius-sm);
  padding: 0.875rem 1rem;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  line-height: 1.6;
  max-height: 28rem;
}

.disclosure {
  margin: 0;
}

.disclosure > summary {
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0;
  color: var(--text);
}

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

.disclosure > summary h2 {
  margin: 0;
}

.disclosure > summary .icon {
  color: var(--text-muted);
  transition: transform var(--dj-dur-move) var(--dj-ease);
}

.disclosure[open] > summary .icon {
  transform: rotate(90deg);
}

.disclosure[open] > summary {
  margin-bottom: 0.875rem;
}

.danger-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.danger-row p {
  margin: 0;
  font-size: 0.8125rem;
  color: var(--text-muted);
  max-width: 40ch;
}

@media (max-width: 639px) {
  .detail-head .thumb {
    width: 56px;
    height: 56px;
  }

  .handle-form {
    flex-direction: column;
  }

  .handle-form button {
    align-self: flex-start;
  }
}

/* =====================================================================
   Dialogs, toasts, Users & Roles (features/users, features/roles) --
   the drjoseph admin's Dialog / sonner toast / Badge variants / permission
   matrix, re-expressed as plain classes.
   ===================================================================== */

/* ---------- dialog (shared/templates/dialog.html, static/dialog.js) ---------- */

.dialog {
  width: calc(100% - 2rem);
  max-width: 24rem;
  max-height: calc(100dvh - 2rem);
  overflow-y: auto;
  padding: 1rem;
  border: none;
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 0 0 1px var(--border), var(--shadow-md);
}

.dialog::backdrop {
  background: rgba(0, 0, 0, 0.1);
  backdrop-filter: blur(4px);
}

@media (prefers-reduced-motion: no-preference) {
  .dialog[open] {
    animation: dialog-in 0.1s var(--dj-ease);
  }
}

@keyframes dialog-in {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin: -0.25rem -0.5rem 1rem 0;
}

.dialog-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 500;
  line-height: 1;
}

.dialog-form input[type="email"],
.dialog-form input[type="password"] {
  width: 100%;
  min-width: 0;
}

.dialog-form .dialog-submit {
  align-self: flex-end;
}

.dialog-form .form-error {
  margin: 0;
}

/* A second, independent form under a dialog's main one (e.g. "Send
   password reset email" in Edit user). */
.dialog-secondary-action {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.5rem;
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

/* `.field-grid` stacks every label as a column; a checkbox row stays a row. */
.field-grid .check-row {
  flex-direction: row;
  align-items: center;
  width: auto;
}

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

/* ---------- toasts (static/toast.js, shared/flash.py) ---------- */

.toaster {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 400;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  width: min(22rem, calc(100% - 2rem));
  margin: 0;
  padding: 0;
  list-style: none;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.875rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  font-size: 0.875rem;
  font-weight: 500;
  pointer-events: auto;
  transition: opacity 0.2s var(--dj-ease), transform 0.2s var(--dj-ease);
}

.toast .icon {
  margin-top: 1px;
}

.toast-success .icon { color: var(--success); }
.toast-warning .icon { color: var(--warning); }
.toast-error .icon { color: var(--destructive); }

.toast-leaving {
  opacity: 0;
  transform: translateY(0.5rem);
}

@media (prefers-reduced-motion: no-preference) {
  .toast {
    animation: toast-in 0.26s var(--dj-ease);
  }
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(0.5rem); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- badges ---------- */

/* Badge "outline" variant: a hairline, no fill -- counts, "Active". */
.badge-outline {
  background: transparent;
  color: var(--text);
  box-shadow: inset 0 0 0 1px var(--border-strong);
}

/* ---------- Users & Roles tables ---------- */

.users-table td,
.roles-table td {
  vertical-align: middle;
  white-space: nowrap;
}

.users-table td:first-child,
.role-name {
  font-weight: 500;
}

.users-table td:first-child .badge,
.role-name .badge {
  margin-left: 0.375rem;
}

.users-table .col-edit {
  width: 40px;
  text-align: right;
}

.roles-table .col-actions {
  width: 80px;
}

.row-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.25rem;
}

/* Row-level destructive icon: muted at rest, red only on intent. */
.row-actions .row-delete {
  color: var(--text-muted);
}

.row-actions .row-delete:hover,
.row-actions .row-delete:focus-visible {
  color: var(--destructive);
  background: color-mix(in oklch, var(--destructive) 10%, transparent);
}

/* ---------- permission matrix (static/permission-matrix.js) ---------- */

.section-title {
  margin-top: 2rem;
  font-size: 1.125rem;
}

.permission-matrix {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.matrix-card-title {
  margin: 0;
  padding: 1rem 1rem 0.25rem;
  font-size: 1rem;
  font-weight: 500;
}

.matrix-card table {
  margin: 0;
}

.matrix-card td {
  vertical-align: middle;
}

.matrix-role,
.matrix-cell {
  width: 6rem;
  text-align: center;
}

.matrix-cell input[type="checkbox"]:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* =====================================================================
   Shared page patterns -- pipeline, catalog-structure and admin pages
   (scrapes, imports, export, Shopify sync, categories, tags, settings,
   run histories). Same card, table and form recipes as
   the products pages, factored so each page is markup only.
   ===================================================================== */

/* Page heading with its one-paragraph explanation. */
.page-head > div {
  flex: 1 1 auto;
  min-width: 0;
}

.page-lede {
  margin: 0.375rem 0 0;
  max-width: 72ch;
  color: var(--text-muted);
  font-size: 0.875rem;
}

.page-lede + .page-lede {
  margin-top: 0.5rem;
}

.page-head + .section-tabs {
  margin-top: 0.25rem;
}

/* A titled section below the page's main form: heading, optional note,
   then its card. */
.section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.25rem 1rem;
  margin: 2rem 0 0.75rem;
}

.section-head h2 {
  margin: 0;
}

.section-head p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.8125rem;
}

.section-head a {
  font-size: 0.875rem;
}

/* Table card: the products results card without the toolbar. */
.table-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  margin-bottom: 1rem;
}

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

.table-card table {
  margin: 0;
  background: transparent;
}

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

.table-card tbody tr td[colspan] {
  padding: 2.25rem 1rem;
}

.table-card .row-title {
  font-weight: 500;
  color: var(--text);
  text-decoration: none;
  overflow-wrap: anywhere;
}

.table-card .row-title:hover {
  text-decoration: underline;
}

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

/* Runs tables can be wide; give their text cells room to breathe rather
   than wrapping a file name one character per line. */
.runs-table {
  min-width: 640px;
}

.runs-table .mono {
  overflow-wrap: anywhere;
}

/* Horizontal form: stacked label-over-control fields that wrap, action
   aligned to the controls' baseline. */
.form-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.75rem 1rem;
}

.form-row > label {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  min-width: 0;
  flex: 1 1 12rem;
  max-width: 22rem;
}

.form-row > label.grow {
  max-width: 36rem;
  flex-basis: 18rem;
}

.form-row > label > input,
.form-row > label > select {
  width: 100%;
  min-width: 0;
}

.form-row > button {
  flex: none;
}

.field-grid input[type="email"],
.field-grid input[type="password"],
.field-grid input[type="url"] {
  width: 100%;
  min-width: 0;
}

.field-grid--narrow {
  max-width: 32rem;
}

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

/* Footer row for a form: primary action, then quieter alternatives. */
.form-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1rem;
  margin-top: 1.25rem;
}

.form-actions .hint {
  margin: 0;
  font-size: 0.8125rem;
}

.form-actions > a {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
}

.form-actions > a:hover,
.form-actions > a.btn {
  color: var(--text);
}

/* File inputs: the picker button speaks the same language as .btn. */
input[type="file"] {
  font: inherit;
  font-size: 0.875rem;
  color: var(--text-muted);
  max-width: 100%;
}

input[type="file"]::file-selector-button {
  height: 32px;
  margin-right: 0.75rem;
  padding: 0 0.875rem;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: background-color var(--dj-dur-color) var(--dj-ease), border-color var(--dj-dur-color) var(--dj-ease);
}

input[type="file"]::file-selector-button:hover {
  background: var(--dj-mist);
  border-color: rgba(26, 26, 26, 0.24);
}

input[type="file"]:focus-visible {
  outline: none;
}

input[type="file"]:focus-visible::file-selector-button {
  outline: 3px solid var(--dj-green);
  outline-offset: 2px;
}

/* Optional scoping (categories for a scrape/sync/export): collapsed by
   default, a bounded scrollable checklist once open, grouped by source. */
.scope-picker {
  margin: 1.25rem 0 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.scope-picker > summary {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.625rem 0.875rem;
  color: var(--text);
}

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

.scope-picker > summary > .icon {
  color: var(--text-muted);
  transition: transform var(--dj-dur-move) var(--dj-ease);
}

.scope-picker[open] > summary > .icon {
  transform: rotate(90deg);
}

.scope-picker > summary .scope-note {
  margin-left: auto;
  font-weight: 400;
  font-size: 0.8125rem;
  color: var(--text-muted);
  text-align: right;
}

.scope-picker[open] > summary {
  border-bottom: 1px solid var(--border);
}

.check-list {
  max-height: 20rem;
  overflow-y: auto;
  padding: 0.5rem 0.875rem 0.75rem;
  overscroll-behavior: contain;
}

.check-group + .check-group {
  margin-top: 0.75rem;
}

.check-group-title {
  position: sticky;
  top: 0;
  z-index: 1;
  margin: 0;
  padding: 0.375rem 0;
  background: var(--surface);
}

.check-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
  gap: 0 1rem;
}

.check-grid .check-row {
  min-width: 0;
  border-radius: 6px;
}

.check-grid .check-row > span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.check-row {
  cursor: pointer;
}

.check-row .count,
.check-row .mono {
  color: var(--text-muted);
}

.check-option {
  margin-top: 1rem;
  align-items: flex-start;
}

.check-option input {
  margin-top: 3px;
}

.check-option strong {
  font-weight: 600;
}

.check-option .field-hint {
  margin-top: 0.125rem;
}

/* Danger zone: one row per irreversible action, consequence stated beside
   the button. */
.danger-zone {
  border-color: color-mix(in oklch, var(--destructive) 22%, transparent);
}

.danger-zone .danger-row + .danger-row {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.danger-zone .danger-row p {
  max-width: 64ch;
}

.danger-row .danger-title {
  display: block;
  margin-bottom: 0.25rem;
  color: var(--text);
  font-weight: 600;
  font-size: 0.875rem;
}

.danger-row-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.875rem;
}

.danger-row-actions a {
  color: var(--text-muted);
}

/* Feature flag: a checkbox row with its consequence written out. */
.flag-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0.25rem 0.75rem;
  cursor: pointer;
}

.flag-row input {
  margin-top: 3px;
}

.flag-row strong {
  font-weight: 600;
  font-size: 0.9375rem;
}

.flag-body p {
  margin: 0.375rem 0 0;
  max-width: 72ch;
  font-weight: 400;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.flag-state {
  margin-left: 0.5rem;
}

/* Detail-page header for a non-product record (category, tag). */
.record-head {
  margin-bottom: 1.5rem;
}

.record-head h1 {
  margin: 0 0 0.5rem;
  overflow-wrap: anywhere;
}

/* ---------- category mapping tree ---------- */

.tree-card {
  padding: 0.25rem 0;
}

.tree-card ul.tree {
  padding: 0;
  margin: 0;
}

.tree-card ul.tree ul.tree {
  margin-left: 1.5rem;
  border-left: 1px solid var(--border);
}

.tree-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto 15rem;
  align-items: center;
  gap: 0.5rem 1rem;
  padding: 0.5rem 1rem;
  border-top: 1px solid var(--border);
}

.tree-card > ul.tree > li:first-child > .tree-row {
  border-top: none;
}

.tree-row:hover {
  background: var(--dj-mist);
}

.tree-name {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  min-width: 0;
}

.tree-name a {
  overflow-wrap: anywhere;
}

.tree-row select {
  width: 100%;
  min-width: 0;
  height: 32px;
}

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

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

  .tree-row .inline-form {
    grid-column: 1 / -1;
  }

  .tree-row select {
    height: 44px;
  }

  .tree-card ul.tree ul.tree {
    margin-left: 0.75rem;
  }
}

/* ---------- import preview ---------- */

.preview-summary {
  display: grid;
  gap: 0.75rem;
}

.preview-summary p {
  margin: 0;
}

.preview-counts {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.375rem 0.5rem;
}

.preview-counts .mono {
  font-weight: 600;
}

.notice {
  display: flex;
  gap: 0.5rem;
  padding: 0.625rem 0.75rem;
  border-radius: var(--radius-sm);
  background: var(--dj-tone-violet-bg);
  color: var(--dj-tone-violet-fg);
  font-size: 0.8125rem;
  line-height: 1.45;
}

.notice .icon {
  margin-top: 1px;
}

.sticky-actions {
  position: sticky;
  bottom: 0;
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1rem;
  margin-top: 1rem;
  padding: 0.75rem 1rem;
  background: rgba(255, 255, 255, 0.94);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 -8px 24px rgba(26, 26, 26, 0.06);
}

.sticky-actions p {
  margin: 0 auto 0 0;
  color: var(--text-muted);
  font-size: 0.8125rem;
}

.sticky-actions a {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
}

/* ---------- export empty state, bulk-delete result ---------- */

.result-list {
  margin: 0.75rem 0 0;
  padding-left: 1.1rem;
  font-size: 0.875rem;
}

.result-list li + li {
  margin-top: 0.375rem;
}

@media (max-width: 639px) {
  .form-row > label {
    max-width: none;
    flex-basis: 100%;
  }

  .scope-picker > summary {
    flex-wrap: wrap;
  }

  .scope-picker > summary .scope-note {
    margin-left: 1.5rem;
    text-align: left;
    flex-basis: 100%;
  }

  .sticky-actions p {
    flex-basis: 100%;
  }
}

.cell-error {
  color: var(--destructive);
  font-size: 0.8125rem;
}

/* A field diff is information, not an error -- only failures are red. */
.change-detail summary {
  color: var(--link);
}

.change-detail .error-detail__text {
  background: var(--dj-mist);
  border-radius: 6px;
  padding: 0.5rem 0.625rem;
  font-family: var(--font-mono);
  font-size: 0.75rem;
}

.status-line-lg {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0 0 1rem;
  font-size: 1rem;
  font-weight: 500;
}

.status-line-lg .icon {
  color: var(--success);
}

.form-error p {
  margin: 0;
}

.form-error .result-list {
  color: var(--text);
}

/* An explained one-off action: paragraph left, button right. */
.action-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1.5rem;
}

.action-row > p {
  flex: 1 1 32rem;
  margin: 0;
  max-width: 80ch;
  color: var(--text-muted);
  font-size: 0.875rem;
}

.empty-panel .btn {
  height: auto;
  min-height: 32px;
  padding: 0.5rem 0.875rem;
  white-space: normal;
  text-align: left;
  line-height: 1.3;
}

.form-row > .field-hint {
  flex-basis: 100%;
  margin-top: -0.25rem;
}

/* A checkbox row inside a stacked form stays a row. */
.field-grid label.check-row {
  flex-direction: row;
  gap: 0.5rem;
}

/* Danger buttons carry full-sentence labels; on narrow screens they wrap
   instead of pushing the page sideways. */
.danger-row .button-danger {
  height: auto;
  min-height: 32px;
  padding-top: 0.375rem;
  padding-bottom: 0.375rem;
  white-space: normal;
  text-align: left;
  line-height: 1.3;
}

.runs-table .cell-file {
  min-width: 24ch;
}

/* Source ids are short slugs; never break one mid-word. */
.runs-table td.mono:first-child {
  white-space: nowrap;
  overflow-wrap: normal;
}

/* ---------- orders (docs/features/ORDERS.md) ---------- */

.order-address {
  font-style: normal;
  line-height: 1.5;
}

/* "Change in Shopify" panel (ORDERS.md §4.6): one action per row. */
.order-actions {
  display: flex;
  flex-direction: column;
  margin-top: 0.75rem;
}

.order-actions > * {
  padding: 0.625rem 0;
  border-top: 1px solid var(--border);
}

.order-actions > *:last-child {
  padding-bottom: 0;
}

.order-actions .disclosure > summary {
  cursor: pointer;
}

.order-actions .disclosure > summary h3 {
  margin: 0;
  font-size: 0.875rem;
  font-weight: 600;
}

.order-activity {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.order-activity li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 0.5rem;
}

.order-activity .product-sub {
  flex-basis: 100%;
}
