/* =========================================================
   Onsera portal design system
   Single source of truth for cross-template visuals.
   See .impeccable.md for captured design context.
   ========================================================= */

:root {
  /* ---- Explicit theme declaration (locked light; see .impeccable.md) ---- */
  color-scheme: light;

  /* =========================================================
     PALETTE
     Light-only. Neutrals carry a faint blue-black tint toward
     the brand primary (#1b1b2c) so the whole surface reads as
     cohesive rather than "gray dropped on white".
     ========================================================= */
  --color-ink:            #171717;    /* headings */
  --color-text:           #414651;    /* body copy */
  --color-muted:          #535862;    /* secondary text */
  --color-muted-2:        #717680;    /* placeholders / meta */
  --color-border:         #d0d5dd;    /* input borders */
  --color-border-soft:    rgba(17, 24, 39, 0.08);

  /* Card surface is a barely-tinted off-white instead of pure #fff
     (pure white never appears in nature; this avoids the sterile
     Figma-default look without visible color shift). */
  --color-card:           #fcfcfd;

  --color-primary:        #1b1b2c;
  --color-primary-hover:  #2a2a45;
  --color-primary-soft:   rgba(27, 27, 44, 0.08);
  --color-primary-softer: rgba(27, 27, 44, 0.03);
  --color-primary-disabled: rgba(27, 27, 44, 0.35);
  --color-on-primary:     #fcfdff;
  --color-rule:           rgba(27, 27, 44, 0.2);

  --color-dropzone-bg:             rgba(214, 228, 240, 0.3);
  --color-dropzone-bg-active:      rgba(214, 228, 240, 0.55);
  --color-dropzone-border:         rgba(81, 121, 244, 0.35);
  --color-dropzone-border-active:  rgba(81, 121, 244, 0.75);
  --color-scrim:                   rgba(15, 23, 42, 0.6);

  --color-success:      #10b981;
  --color-success-soft: #d1fae5;
  --color-success-ink:  #065f46;
  --color-error:        #dc2626;
  --color-error-soft:   #fee2e2;
  --color-error-ink:    #991b1b;
  --color-warn-soft:    #fef3c7;
  --color-warn-ink:     #92400e;

  /* =========================================================
     SPACING — 4pt scale with semantic aliases.
     Use these instead of ad-hoc rem values.
     ========================================================= */
  --space-1:  0.25rem;  /*  4px */
  --space-2:  0.5rem;   /*  8px */
  --space-3:  0.75rem;  /* 12px */
  --space-4:  1rem;     /* 16px */
  --space-5:  1.25rem;  /* 20px */
  --space-6:  1.5rem;   /* 24px */
  --space-7:  1.75rem;  /* 28px */
  --space-8:  2rem;     /* 32px */
  --space-10: 2.5rem;   /* 40px */
  --space-12: 3rem;     /* 48px */
  --space-16: 4rem;     /* 64px */

  /* =========================================================
     RADII
     ========================================================= */
  --radius-input: 8px;
  --radius-card:  12px;
  --radius-pill:  999px;

  /* =========================================================
     SHADOW
     ========================================================= */
  --shadow-card:  0 1px 2px rgba(16, 24, 40, 0.04), 0 1px 3px rgba(16, 24, 40, 0.06);
  --shadow-modal: 0 20px 60px rgba(15, 23, 42, 0.25);

  /* =========================================================
     MOTION — quart ease-out for natural deceleration; no bounce.
     Durations stay in one of three buckets.
     ========================================================= */
  --duration-fast: 120ms;
  --duration-base: 180ms;
  --duration-slow: 300ms;
  --ease-out:      cubic-bezier(0.22, 1, 0.36, 1);   /* ease-out-quart */
  --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);    /* stronger deceleration */

  /* =========================================================
     FOCUS RING
     ========================================================= */
  --focus-ring-width:  2px;
  --focus-ring-offset: 3px;

  /* =========================================================
     TYPE
     Font choice is a stop-gap until /typeset swaps in
     Switzer + Gambarino (see .impeccable.md).
     ========================================================= */
  --font-display: "DM Sans", system-ui, sans-serif;
  --font-ui:      "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono:    ui-monospace, SFMono-Regular, Menlo, monospace;

  /* =========================================================
     PAGE BACKGROUND (matches Figma)
     ========================================================= */
  --page-bg: linear-gradient(
    170deg,
    rgb(227, 235, 250) 0%,
    rgb(242, 246, 246) 55%,
    rgb(240, 244, 241) 100%
  );
}

/* =========================================================
   RESET
   ========================================================= */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-ui);
  /* cv11: disambiguate 0 vs O; ss01: 1-storey "a"; tnum applies per-cell */
  font-feature-settings: "cv11", "ss01";
  font-size: 16px;
  line-height: 1.5;
  color: var(--color-text);
  background: var(--page-bg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
a { color: inherit; }
button { font: inherit; }

/* =========================================================
   UTILITIES
   ========================================================= */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}
.text-ink     { color: var(--color-ink); }
.text-muted   { color: var(--color-muted); }
.text-mono    { font-family: var(--font-mono); }
.tabular-nums { font-variant-numeric: tabular-nums; }

/* =========================================================
   PAGE SHELL
   ========================================================= */
.page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-7) var(--space-10);   /* 28px 40px */
}
.page-header .header-slot-left,
.page-header .header-slot-right {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}
.page-main {
  flex: 1 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: var(--space-8) var(--space-5) var(--space-16);
}
.page-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-5) var(--space-10) var(--space-6);
  font-size: 0.8125rem;
  color: var(--color-muted);
}
.page-footer a.footer-contact {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--color-muted);
  text-decoration: none;
  transition: color var(--duration-fast) var(--ease-out);
}
.page-footer a.footer-contact:hover { color: var(--color-ink); }
.page-footer .footer-contact svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

/* =========================================================
   LOGO
   ========================================================= */
.logo { display: inline-flex; align-items: center; }
.logo img { height: 1.75rem; display: block; }

/* =========================================================
   TYPOGRAPHY HELPERS
   ========================================================= */
.eyebrow-group { margin-bottom: var(--space-5); }
.eyebrow {
  font-family: var(--font-ui);
  font-weight: 500;
  font-size: 0.625rem;          /* 10px */
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--color-text);
  display: block;
}
.eyebrow-rule {
  display: block;
  width: 28px;
  height: 2px;
  background: var(--color-rule);
  border-radius: 2px;
  margin-top: var(--space-2);
}
.display-heading {
  font-family: var(--font-display);
  font-weight: 300;
  font-size: 1.75rem;           /* 28px */
  line-height: 1.4;
  letter-spacing: -0.022em;
  color: var(--color-ink);
  font-variation-settings: "opsz" 14;
  text-wrap: balance;           /* avoid orphaned last words */
}
.lead {
  font-size: 1rem;
  line-height: 1.75;
  color: var(--color-text);
  max-width: 62ch;              /* cap long leads for readability */
}
.tagline {
  font-size: 0.75rem;
  line-height: 1.6;
  color: var(--color-muted);    /* AA on all gradient stops */
  text-align: center;
}

/* =========================================================
   FORMS
   ========================================================= */
label, .form-label {
  display: block;
  font-family: var(--font-ui);
  font-weight: 500;
  font-size: 0.875rem;
  line-height: 1.25rem;
  color: var(--color-text);
  margin-bottom: var(--space-2);
}
input[type="email"],
input[type="password"],
input[type="text"] {
  width: 100%;
  font: inherit;
  font-size: 0.95rem;
  color: var(--color-ink);
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-input);
  padding: var(--space-3) var(--space-4);
  height: 52px;
  outline: none;
  transition:
    border-color var(--duration-fast) var(--ease-out),
    box-shadow var(--duration-fast) var(--ease-out),
    background-color var(--duration-fast) var(--ease-out);
}
input::placeholder { color: var(--color-muted-2); }
input:hover:not(:focus):not(:disabled) {
  border-color: color-mix(in oklab, var(--color-border) 60%, var(--color-ink));
}
input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-soft);
}
input:disabled {
  background: var(--color-primary-softer);
  color: var(--color-muted);
  cursor: not-allowed;
  border-color: var(--color-border-soft);
}
/* :user-invalid only fires after the user has interacted — avoids
   red-flashing fields on page load. Chrome 119+, Firefox 88+, Safari 16.5+. */
input:user-invalid {
  border-color: var(--color-error);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--color-error) 15%, transparent);
}

.field + .field { margin-top: var(--space-4); }

/* =========================================================
   BUTTONS
   ========================================================= */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  font-family: var(--font-ui);
  font-weight: 500;
  font-size: 0.9375rem;         /* 15px */
  line-height: 1;
  border: 1px solid transparent;
  border-radius: var(--radius-pill);
  padding: 0 var(--space-6);
  height: 52px;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition:
    background-color var(--duration-fast) var(--ease-out),
    color var(--duration-fast) var(--ease-out),
    border-color var(--duration-fast) var(--ease-out),
    transform 80ms var(--ease-out),
    opacity var(--duration-fast) var(--ease-out);
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn-primary {
  background: var(--color-primary);
  color: var(--color-on-primary);
}
.btn-primary:hover:not(:disabled) { background: var(--color-primary-hover); }
.btn-primary:disabled,
.btn-primary[disabled] {
  background: var(--color-primary-disabled);
  cursor: not-allowed;
}
.btn-ghost {
  background: transparent;
  color: var(--color-text);
  border-color: var(--color-border);
}
.btn-ghost:hover:not(:disabled) {
  background: rgba(27, 27, 44, 0.04);
  color: var(--color-ink);
}
.btn-danger {
  background: transparent;
  color: var(--color-error);
  border-color: rgba(220, 38, 38, 0.35);
}
.btn-danger:hover:not(:disabled) {
  background: var(--color-error-soft);
  border-color: var(--color-error);
}
.btn-pill-dark {
  background: var(--color-primary);
  color: var(--color-on-primary);
  height: 44px;
  padding: 0 var(--space-5);
  border-radius: var(--radius-pill);
  font-size: 0.875rem;
  font-weight: 500;
  border: none;
  cursor: pointer;
  transition:
    background-color var(--duration-fast) var(--ease-out),
    transform 80ms var(--ease-out);
}
.btn-pill-dark:hover:not(:disabled) { background: var(--color-primary-hover); }
.btn-pill-dark:active:not(:disabled) { transform: translateY(1px); }
.btn-sm {
  height: 40px;
  min-width: 44px;
  padding: 0 var(--space-4);
  font-size: 0.8125rem;
}
.btn-block { width: 100%; }
.btn-link {
  background: none;
  border: none;
  color: var(--color-muted);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  padding: var(--space-2);
  text-decoration: none;
  transition: color var(--duration-fast) var(--ease-out);
}
.btn-link:hover { color: var(--color-ink); }

/* =========================================================
   FOCUS-VISIBLE RINGS (WCAG 2.4.7)
   ========================================================= */
.btn:focus-visible,
.btn-pill-dark:focus-visible,
.btn-link:focus-visible,
.al-remove-btn:focus-visible,
.al-add-form button:focus-visible,
a.footer-contact:focus-visible,
.logo:focus-visible {
  outline: var(--focus-ring-width) solid var(--color-primary);
  outline-offset: var(--focus-ring-offset);
  border-radius: var(--radius-pill);
}
.btn-primary:focus-visible {
  outline: none;
  box-shadow:
    0 0 0 2px var(--color-on-primary),
    0 0 0 4px var(--color-primary);
}

/* =========================================================
   CARD
   ========================================================= */
.card {
  background: var(--color-card);
  border: 1px solid var(--color-border-soft);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: var(--space-8);
}

/* =========================================================
   ERROR / STATUS BANNERS
   ========================================================= */
.error-banner, .error {
  background: var(--color-error-soft);
  color: var(--color-error);
  border-radius: var(--radius-input);
  padding: var(--space-2) var(--space-3);
  font-size: 0.85rem;
  margin-bottom: var(--space-4);
  line-height: 1.45;
  display: none;
}
.error:not(:empty) { display: block; }

/* =========================================================
   DIVIDER
   ========================================================= */
.divider {
  display: flex;
  align-items: center;
  text-align: center;
  color: var(--color-muted-2);
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin: var(--space-5) 0;
}
.divider::before, .divider::after {
  content: "";
  flex: 1;
  border-top: 1px solid var(--color-border-soft);
}
.divider span { padding: 0 var(--space-3); }

/* =========================================================
   TOAST
   ========================================================= */
.toast {
  position: fixed;
  bottom: var(--space-6);
  left: 50%;
  transform: translateX(-50%);
  background: var(--color-primary);
  color: var(--color-on-primary);
  border-radius: var(--radius-pill);
  padding: var(--space-3) var(--space-5);
  font-size: 0.9rem;
  box-shadow: var(--shadow-modal);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--duration-slow) var(--ease-out);
  z-index: 100;
}
.toast.show { opacity: 1; pointer-events: auto; }
.toast.success { background: var(--color-success-ink); }
.toast.error   { background: var(--color-error-ink); }

/* =========================================================
   EXCHANGE INVENTORY
   When the signed-in domain has prior uploads, the exchange page
   becomes a reading surface: a wider, left-aligned single column
   organised around session-grouped file rows. The dropzone tucks
   behind a `New upload` action that expands inline.

   Read this block top-to-bottom: shell -> header -> upload region
   -> session groups.
   ========================================================= */
body.exchange-inventory .page-main {
  /* Override the centered single-column composition. Inventory is
     left-aligned and starts at the top of the column, like the
     admin surface. */
  align-items: stretch;
  justify-content: flex-start;
  padding: var(--space-6) var(--space-6) var(--space-12);
}
.exchange-shell {
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-10);
}
.exchange-shell-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-6);
  flex-wrap: wrap;
}
.exchange-shell-titles {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  min-width: 0;
}
.exchange-shell-heading {
  font-family: var(--font-display);
  font-weight: 300;
  font-size: 2rem;            /* 32px — one step bigger than the
                                 centred display heading; the
                                 inventory page can carry it. */
  line-height: 1.1;
  letter-spacing: -0.024em;
  color: var(--color-ink);
}
.exchange-shell-sub {
  font-size: 0.9375rem;
  line-height: 1.55;
  color: var(--color-muted);
  max-width: 60ch;
}
.exchange-shell-domain {
  color: var(--color-text);
  font-weight: 500;
}
.exchange-shell-error,
.exchange-shell-empty {
  font-size: 0.875rem;
  color: var(--color-muted);
  line-height: 1.6;
  padding: var(--space-4) 0;
  border-top: 1px solid var(--color-border-soft);
}
.exchange-shell-empty strong {
  color: var(--color-text);
  font-weight: 500;
}

/* ---- Skeleton placeholder ------------------------------------- */
/* Mirrors the rhythm of real session blocks so the swap is quiet. */
.session-groups-skeleton {
  pointer-events: none;
  user-select: none;
}
.session-groups-skeleton .session-header,
.session-groups-skeleton .session-file {
  /* Slightly less prominent than the real rule — the skeleton
     should read as “structure forming”, not as data. */
  border-color: color-mix(in oklab, var(--color-border-soft) 60%, transparent);
}
.skeleton-line {
  display: inline-block;
  height: 0.6875rem;
  border-radius: 4px;
  background: var(--color-primary-soft);
  animation: skeleton-pulse 1.6s ease-in-out infinite;
  vertical-align: middle;
}
.skeleton-line-xs { width: 4ch; }
.skeleton-line-sm { width: 8ch; }
.skeleton-line-md { width: 18ch; }
.skeleton-line-lg { width: 26ch; max-width: 60%; }
@keyframes skeleton-pulse {
  0%, 100% { opacity: 0.55; }
  50%      { opacity: 0.95; }
}

/* ---- Upload region: height-animated disclosure ---------------- */
/* The grid-template-rows trick lets us transition from 0fr to 1fr
   without animating layout-affecting properties. The inner element
   handles overflow so the contents clip cleanly during the
   transition. */
.upload-region {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows var(--duration-slow) var(--ease-out);
}
.upload-region[data-expanded="true"] {
  grid-template-rows: 1fr;
}
.upload-region-inner {
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}
.upload-region[data-expanded="true"] .upload-region-inner {
  /* Slight extra breathing room once expanded so the dropzone
     doesn't touch the session list above. */
  padding-bottom: var(--space-2);
}

/* ---- Upload buckets (progressive-loading sections) ------------ */
.upload-bucket[data-state="empty"],
.upload-bucket[data-state="deferred"] {
  display: none;  /* empty/deferred buckets collapse completely */
}
.bucket-heading {
  font-family: var(--font-ui);
  font-weight: 500;
  font-size: 0.8125rem;
  color: var(--color-muted);
  letter-spacing: 0.02em;
  text-transform: uppercase;
  margin-bottom: var(--space-4);
}
.upload-expand-actions {
  display: flex;
  gap: var(--space-3);
  flex-wrap: wrap;
  padding: var(--space-5) 0 var(--space-2);
  margin-top: var(--space-4);
  border-top: 1px solid var(--color-border-soft);
}
.upload-expand-actions[hidden] { display: none; }
.expand-older-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-family: var(--font-ui);
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--color-text);
  background: var(--color-card);
  border: 1px solid var(--color-border-soft);
  border-radius: var(--radius-pill);
  padding: var(--space-2) var(--space-4);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition:
    background-color var(--duration-fast) var(--ease-out),
    border-color var(--duration-fast) var(--ease-out),
    color var(--duration-fast) var(--ease-out),
    transform 80ms var(--ease-out);
}
.expand-older-btn:hover {
  background: var(--color-primary-soft);
  border-color: color-mix(in oklab, var(--color-border) 80%, var(--color-primary));
  color: var(--color-ink);
}
.expand-older-btn:active:not(:disabled) {
  transform: translateY(1px);
}
.expand-older-btn:focus-visible {
  outline: var(--focus-ring-width) solid var(--color-primary);
  outline-offset: var(--focus-ring-offset);
}
.expand-older-btn.htmx-request {
  opacity: 0.5;
  pointer-events: none;
}

/* ---- Session groups ------------------------------------------- */
.session-groups {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: var(--space-12);          /* generous between sessions */
  padding: 0;
  margin: 0;
}
.session-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);           /* tight within a session */
}
.session-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
  flex-wrap: wrap;
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--color-border-soft);
}
.session-uploader {
  font-family: var(--font-ui);
  font-weight: 500;
  font-size: 0.9375rem;
  color: var(--color-ink);
  letter-spacing: -0.005em;
  /* If multiple sessions belong to the same uploader, the email is
     the dominant identifier on each header. Cap-and-truncate. */
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 36ch;
}
.session-time {
  font-size: 0.8125rem;
  color: var(--color-muted);
  font-variant-numeric: tabular-nums;
  /* Title attr already supplies absolute time. */
  cursor: default;
}
.session-meta {
  font-size: 0.8125rem;
  color: var(--color-muted-2);
  font-variant-numeric: tabular-nums;
  margin-left: auto;
  white-space: nowrap;
}

/* ---- Session files: hairline list, no card boxes -------------- */
.session-files {
  list-style: none;
  display: flex;
  flex-direction: column;
  padding: 0;
  margin: 0;
}
.session-file {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: baseline;
  gap: var(--space-4);
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--color-border-soft);
  outline: none;
  transition: background-color var(--duration-fast) var(--ease-out);
}
.session-file:last-child {
  border-bottom: 0;
}
.session-file:hover,
.session-file:focus-visible {
  /* The brief said no row hover affordance, but a near-invisible
     surface tint helps signal that the row carries hover-revealed
     details. The contrast is intentionally below the threshold of
     'looks clickable'. */
  background: var(--color-primary-softer);
  border-radius: 4px;
}
.session-file:focus-visible {
  outline: var(--focus-ring-width) solid var(--color-primary);
  outline-offset: 2px;
}
.session-file-name {
  display: flex;
  min-width: 0;
  font-size: 0.9375rem;
  color: var(--color-text);
  font-feature-settings: "tnum" off;
}
/* Two-span middle ellipsis: the prefix grows and is truncated; the
   suffix (last 12 chars) is preserved verbatim so the extension is
   always visible. */
.session-file-name-prefix {
  flex: 0 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.session-file-name-suffix {
  flex: 0 0 auto;
  white-space: nowrap;
}
.session-file-size {
  font-size: 0.8125rem;
  color: var(--color-muted-2);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ---- Hover-revealed file metadata ----------------------------- */
/* Inline details panel sits beneath the row, hidden by default,
   shown when the row is hovered or any descendant is focused.
   We use grid-template-rows for the same reason as the upload
   region — no layout-property animation, no jumping. */
.session-file-details {
  grid-column: 1 / -1;
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows var(--duration-base) var(--ease-out);
  margin: 0;
}
.session-file:hover .session-file-details,
.session-file:focus-visible .session-file-details,
.session-file:focus-within .session-file-details {
  grid-template-rows: 1fr;
}
.session-file-details > div {
  min-height: 0;
  overflow: hidden;
  display: grid;
  grid-template-columns: 80px minmax(0, 1fr);
  gap: var(--space-2) var(--space-3);
  padding: var(--space-1) 0 0;
  font-size: 0.75rem;
  line-height: 1.5;
}
.session-file-details dt {
  color: var(--color-muted-2);
  text-transform: none;
  font-weight: 500;
}
.session-file-details dd {
  color: var(--color-muted);
  margin: 0;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

/* ---- Inventory mode responsive -------------------------------- */
@media (max-width: 720px) {
  body.exchange-inventory .page-main {
    padding: var(--space-5) var(--space-4) var(--space-10);
  }
  .exchange-shell {
    gap: var(--space-8);
  }
  .exchange-shell-heading {
    font-size: 1.625rem;
  }
  .session-groups {
    gap: var(--space-10);
  }
  .session-header {
    /* Stack on narrow viewports so the email and the meta line each
       get their own row instead of squeezing. */
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-1);
  }
  .session-meta { margin-left: 0; }
}

/* =========================================================
   ADMIN CHROME (shared between /admin/allowlist and /admin/users)
   Internal tool aesthetic: left-aligned, asymmetric, sidebar-nav.
   Explicitly NOT the centered single-column composition used by
   partner-facing pages. See .impeccable.md "Admin is left-aligned
   and asymmetric."
   ========================================================= */
body.admin-page .page-main {
  /* Override the centered single-column composition. Admin content
     is wide, left-aligned, and scrolls from the top. */
  align-items: stretch;
  justify-content: flex-start;
  padding: var(--space-6) var(--space-6) var(--space-10);
}
.admin-badge {
  display: inline-flex;
  align-items: center;
  background: var(--color-warn-soft);
  color: var(--color-warn-ink);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 3px var(--space-2);
  border-radius: var(--radius-pill);
}
.admin-layout {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: var(--space-8);
  align-items: start;
}
.admin-sidebar {
  position: sticky;
  top: var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  padding: var(--space-4) 0;
  border-right: 1px solid var(--color-border-soft);
  padding-right: var(--space-5);
  min-height: 60vh;
}
.admin-sidebar-eyebrow {
  font-family: var(--font-ui);
  font-weight: 500;
  font-size: 0.625rem;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--color-muted);
  padding: 0 var(--space-2);
}
.admin-nav {
  display: flex;
  align-items: center;
  padding: var(--space-2) var(--space-3);
  border-radius: 8px;
  font-size: 0.9375rem;
  color: var(--color-text);
  text-decoration: none;
  transition:
    background-color var(--duration-fast) var(--ease-out),
    color var(--duration-fast) var(--ease-out);
}
.admin-nav:hover { background: var(--color-primary-softer); color: var(--color-ink); }
.admin-nav.is-active {
  background: var(--color-primary-soft);
  color: var(--color-ink);
  font-weight: 500;
}
.admin-nav:focus-visible {
  outline: var(--focus-ring-width) solid var(--color-primary);
  outline-offset: var(--focus-ring-offset);
}
.admin-sidebar-footer {
  margin-top: auto;
  padding: var(--space-3) var(--space-2);
  font-size: 0.75rem;
  color: var(--color-muted);
  line-height: 1.4;
  overflow-wrap: anywhere;
}
.admin-main {
  /* minmax(0, 1fr) + min-width: 0 lets internal tables overflow cleanly
     without pushing the grid wider than its container. */
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-8);
}
.admin-section-heading {
  font-family: var(--font-display);
  font-weight: 300;
  font-size: 1.5rem;
  line-height: 1.25;
  letter-spacing: -0.02em;
  color: var(--color-ink);
}
.admin-subheading {
  font-family: var(--font-ui);
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--color-muted);
  letter-spacing: 0;
  text-transform: none;
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}
.admin-subheading .count {
  font-variant-numeric: tabular-nums;
  color: var(--color-muted-2);
  font-weight: 400;
}
.admin-helper {
  font-size: 0.8125rem;
  line-height: 1.6;
  color: var(--color-muted);
  max-width: 72ch;
}
.admin-helper code {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  color: var(--color-ink);
  background: var(--color-primary-softer);
  padding: 0 4px;
  border-radius: 3px;
}
.admin-hero-form {
  display: flex;
  gap: var(--space-2);
  margin-top: var(--space-4);
}
.admin-hero-form input {
  flex: 1;
  min-width: 0;
  height: 52px;
}
.admin-hero-form .btn { flex-shrink: 0; }
.admin-inline-note {
  min-height: 1.25rem;
  margin-top: var(--space-2);
  font-size: 0.8125rem;
  line-height: 1.5;
  color: var(--color-muted);
}
.admin-inline-note.is-error {
  color: var(--color-error-ink);
}
.admin-inline-note.is-error::before {
  content: none;
}
.admin-filter {
  display: block;
  width: 100%;
  max-width: 320px;
  height: 36px;
  font: inherit;
  font-size: 0.875rem;
  color: var(--color-ink);
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--color-border-soft);
  border-radius: 0;
  padding: 0 0 var(--space-1);
  outline: none;
  margin-top: var(--space-6);
  margin-bottom: var(--space-3);
  transition: border-color var(--duration-fast) var(--ease-out);
}
.admin-filter::placeholder { color: var(--color-muted-2); }
.admin-filter:focus {
  border-bottom-color: var(--color-primary);
}
.admin-filter:focus-visible {
  outline: none;
}
.admin-empty {
  font-size: 0.875rem;
  color: var(--color-muted-2);
  padding: var(--space-6) 0;
}
.admin-empty-filter {
  font-size: 0.8125rem;
  color: var(--color-muted-2);
  padding: var(--space-3) 0;
}

/* ---- Undo toast: extended toast variant with an action button ---- */
.toast-undo {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
}
.toast-undo button {
  background: transparent;
  border: 1px solid rgba(252, 253, 255, 0.4);
  color: var(--color-on-primary);
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 500;
  padding: 4px var(--space-3);
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition:
    background-color var(--duration-fast) var(--ease-out),
    border-color var(--duration-fast) var(--ease-out);
}
.toast-undo button:hover {
  background: rgba(252, 253, 255, 0.14);
  border-color: var(--color-on-primary);
}
.toast-undo button:focus-visible {
  outline: 2px solid var(--color-on-primary);
  outline-offset: 2px;
}

/* =========================================================
   RESPONSIVE
   ========================================================= */
@media (max-width: 768px) {
  .page-header, .page-footer {
    padding-left: var(--space-5);
    padding-right: var(--space-5);
  }
  .toast {
    left: var(--space-4);
    right: var(--space-4);
    transform: none;
    text-align: center;
    bottom: 4.5rem;
  }
}

@media (max-width: 720px) {
  /* Admin sidebar collapses into a two-item tab strip at the top of the
     main area. No hamburger / drawer — tab strip is lower-ceremony for
     two items, and sales-on-mobile (from the brief) taps a tab and types. */
  body.admin-page .page-main {
    padding: var(--space-4) var(--space-4) var(--space-10);
  }
  .admin-layout {
    grid-template-columns: minmax(0, 1fr);
    gap: var(--space-5);
  }
  .admin-sidebar {
    position: static;
    flex-direction: row;
    flex-wrap: wrap;
    gap: var(--space-2);
    padding: 0 0 var(--space-2);
    border-right: 0;
    border-bottom: 1px solid var(--color-border-soft);
    min-height: 0;
  }
  .admin-sidebar-eyebrow { flex-basis: 100%; padding: 0; }
  .admin-nav {
    padding: var(--space-2) var(--space-3);
    font-size: 0.875rem;
  }
  .admin-sidebar-footer {
    flex-basis: 100%;
    margin-top: 0;
    padding: var(--space-2) 0 0;
    font-size: 0.6875rem;
  }
}

/* =========================================================
   REDUCED MOTION
   ========================================================= */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

/* =========================================================
   FORCED COLORS (Windows High Contrast, Firefox MSAA)
   In forced-colors mode, browser replaces our palette with
   system colors. Ensure focus rings remain visible and our
   subtle borders don't disappear.
   ========================================================= */
@media (forced-colors: active) {
  .btn, .btn-pill-dark, input, .card {
    border: 1px solid CanvasText;
  }
  .btn-primary:focus-visible {
    outline: 2px solid Highlight;
    box-shadow: none;
  }
  .eyebrow-rule,
  .divider::before,
  .divider::after {
    forced-color-adjust: none;
    background: CanvasText;
    border-color: CanvasText;
  }
}
