/* =============================================================
   AIReady Portal — product-ui surface
   Source of truth: ../../../../DESIGN.md
   Surface: product-ui  ·  Font: Montserrat  ·  Density: Medium
   =============================================================
   This file replaces Bootstrap for the portal pages. Do NOT add
   new colors, radii, fonts, gradients, or shadows here that
   aren't already in DESIGN.md. Flag any deviation to the user.
   ============================================================= */

@import url("https://fonts.googleapis.com/css2?family=Montserrat:wght@400;700&display=swap");

/* ─── Design Tokens ─────────────────────────────────────────── */
:root {
  /* Brand colors */
  --color-primary:       #4c0f5c;
  --color-primary-deep:  #0e0514;

  /* Ink & canvas */
  --color-ink:           #0e0514;
  --color-canvas:        #ffffff;
  --color-canvas-lavender: #f5f0f7;
  --color-hairline:      #d9d9d9;
  --color-lilac:         #ece3ef;

  /* On-dark text & icon */
  --color-body-on-dark:           rgba(255, 255, 255, 0.95);
  --color-body-secondary-on-dark: rgba(255, 255, 255, 0.65);
  --color-icon-on-dark:           rgba(255, 255, 255, 0.45);

  /* Semantic */
  --color-error:        #c0392b;
  --color-error-soft:   #fde8e6;
  --color-success:      #27ae60;
  --color-success-soft: #e8f5e9;

  /* Warm palette (locked / upgrade cards) */
  --color-warm-cream:   #fef9f0;
  --color-warm-butter:  #fff3cd;
  --color-warm-caramel: #92400e;

  /* Typography */
  --font-product:       'Montserrat', Arial, Helvetica, sans-serif;
  --text-display-lg:    2rem;
  --text-display-md:    1.5rem;
  --text-display-sm:    1.125rem;
  --text-body:          1rem;
  --text-eyebrow:       0.6875rem;

  /* Spacing */
  --spacing-xs:  4px;
  --spacing-sm:  8px;
  --spacing-md:  16px;
  --spacing-lg:  24px;
  --spacing-xl:  32px;
  --spacing-xxl: 48px;

  /* Border radius */
  --rounded-sm:   6px;
  --rounded-md:   10px;
  --rounded-xl:   16px;
  --rounded-pill: 9999px;
  --rounded-full: 9999px;

  /* Elevation */
  --shadow-card-emphasis: 0 4px 20px rgba(14, 5, 20, 0.12);

  /* Motion */
  --motion-fast:     0.12s;
  --motion-ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --motion-press:    scale(0.96);

  /* Gradients */
  --gradient-atmosphere: linear-gradient(160deg, #f0f9fa 0%, #ece3ef 100%);
}

/* ─── Reset & Base ──────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-product);
  font-size: var(--text-body);
  line-height: 1.55;
  color: var(--color-ink);
  background: var(--gradient-atmosphere);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
a { color: var(--color-primary); text-decoration: none; }
a:hover { color: var(--color-primary-deep); text-decoration: underline; }
img { max-width: 100%; height: auto; display: block; }
button { font-family: inherit; }

/* ─── Typography ────────────────────────────────────────────── */
h1, h2, h3, h4, h5, h6 { color: var(--color-ink); font-weight: 700; margin: 0 0 var(--spacing-md); }
h1 { font-size: var(--text-display-lg); line-height: 1.12; letter-spacing: -0.4px; }
h2 { font-size: var(--text-display-md); line-height: 1.2;  letter-spacing: -0.3px; }
h3 { font-size: var(--text-display-sm); line-height: 1.25; letter-spacing: -0.2px; }
h4 { font-size: 20px; line-height: 1.3; }
h5 { font-size: 16px; line-height: 1.4; font-weight: 700; }
p  { margin: 0 0 var(--spacing-md); }
.eyebrow {
  font-size: var(--text-eyebrow);
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--color-primary-deep);
  margin-bottom: var(--spacing-xs);
}

/* ─── Layout shell ──────────────────────────────────────────── */
.app-shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}
.app-main {
  padding: var(--spacing-xl) var(--spacing-xxl);
  max-width: 100%;
  overflow-x: hidden;
}
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--spacing-lg);
  margin-bottom: var(--spacing-xl);
}
.page-header h1 { margin: 0 0 6px; font-size: var(--text-display-md); }
.page-header .subtitle { color: var(--color-ink); opacity: 0.7; margin: 0; }
.page-header__actions { display: flex; gap: var(--spacing-sm); flex-wrap: wrap; }

/* ─── Sidebar (product-ui dark sidebar) ─────────────────────── */
.sidebar {
  background: var(--color-primary-deep);
  color: var(--color-body-on-dark);
  padding: var(--spacing-lg) var(--spacing-md);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar__brand {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: var(--spacing-xl);
  letter-spacing: -0.2px;
  padding: 0 var(--spacing-sm);
  color: var(--color-body-on-dark);
}
.sidebar__nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.sidebar__link {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  padding: 10px var(--spacing-sm);
  border-radius: var(--rounded-sm);
  color: var(--color-body-secondary-on-dark);
  font-weight: 400;
  font-size: 14px;
  transition: background var(--motion-fast) var(--motion-ease-out),
              color var(--motion-fast) var(--motion-ease-out);
}
.sidebar__link:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--color-body-on-dark);
  text-decoration: none;
}
.sidebar__link.is-active {
  background: rgba(255, 255, 255, 0.12);
  color: var(--color-body-on-dark);
  font-weight: 700;
}
.sidebar__icon-tile {
  width: 28px;
  height: 28px;
  border-radius: var(--rounded-sm);
  background: rgba(255, 255, 255, 0.08);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--color-icon-on-dark);
}
.sidebar__footer {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-top: var(--spacing-md);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

/* ─── Card (default product-ui card) ────────────────────────── */
.card {
  background: var(--color-canvas);
  border: 1px solid var(--color-hairline);
  border-radius: var(--rounded-xl);
  padding: var(--spacing-lg);
  /* No shadow on default cards — frost hairline only. */
}
.card + .card { margin-top: var(--spacing-md); }
.card--emphasis {
  /* one per card group, max */
  box-shadow: var(--shadow-card-emphasis);
}
.card--warm {
  background: var(--color-warm-cream);
  border-color: var(--color-warm-butter);
  color: var(--color-warm-caramel);
}
.card--warm h2,
.card--warm .card__title { color: var(--color-warm-caramel); }
.card--warm a { color: var(--color-warm-caramel); }
.card--warm a:hover { color: var(--color-warm-caramel); }
.card__body p { margin: 0; }
.locked-card {
  display: flex;
  align-items: flex-start;
  gap: var(--spacing-md);
  padding: var(--spacing-sm) 0;
}
.locked-card p { margin: 0; font-size: 14px; line-height: 1.5; }
.resource-link {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  padding: var(--spacing-xs) 0;
  color: var(--color-ink);
  font-weight: 700;
  font-size: 14px;
}
.resource-link:hover { color: var(--color-primary-deep); text-decoration: none; }
.card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--spacing-md);
  margin-bottom: var(--spacing-md);
}
.card__title { font-size: 18px; font-weight: 700; margin: 0; }

/* ─── Stat card ─────────────────────────────────────────────── */
.stat-card {
  background: var(--color-canvas);
  border: 1px solid var(--color-hairline);
  border-radius: var(--rounded-xl);
  padding: var(--spacing-lg);
  display: flex;
  flex-direction: column;
  gap: var(--spacing-xs);
}
.stat-card__label {
  font-size: var(--text-eyebrow);
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--color-ink);
  opacity: 0.6;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--spacing-xs);
}
.stat-card__value {
  font-size: var(--text-display-md);
  font-weight: 700;
  color: var(--color-ink);
  line-height: 1.1;
}
.stat-card__sub { font-size: 13px; color: var(--color-ink); opacity: 0.7; margin: 0; }

/* ─── Stat grid ─────────────────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--spacing-md);
  margin-bottom: var(--spacing-xl);
}

/* ─── Two-column dashboard layout ───────────────────────────── */
.split-grid {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: var(--spacing-lg);
  margin-bottom: var(--spacing-xl);
}
@media (max-width: 1024px) {
  .split-grid { grid-template-columns: 1fr; }
}

/* ─── Icon tile (light surface) ─────────────────────────────── */
.icon-tile {
  width: 40px;
  height: 40px;
  border-radius: var(--rounded-md);
  background: var(--gradient-atmosphere);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--color-primary-deep);
  flex-shrink: 0;
}
.icon-tile--circle { border-radius: var(--rounded-full); }
.icon-tile--lg { width: 48px; height: 48px; }

/* ─── Buttons (Button Interaction Contract from DESIGN.md) ──── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-xs);
  height: 44px;
  padding: 0 var(--spacing-lg);
  border-radius: var(--rounded-sm);
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: transform var(--motion-fast) var(--motion-ease-out),
              background-color var(--motion-fast) var(--motion-ease-out),
              border-color var(--motion-fast) var(--motion-ease-out),
              color var(--motion-fast) var(--motion-ease-out);
  white-space: nowrap;
}
.btn:hover { transform: translateY(-1px); text-decoration: none; }
.btn:active { transform: scale(0.97); transition-duration: var(--motion-press); }
.btn:focus-visible {
  outline: 2px solid var(--color-primary-deep);
  outline-offset: 2px;
}
.btn:disabled,
.btn[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}
.btn--primary {
  background: var(--color-primary);
  color: var(--color-body-on-dark);
}
.btn--primary:hover { background: var(--color-primary-deep); color: var(--color-body-on-dark); }
.btn--primary-deep {
  background: var(--color-primary-deep);
  color: var(--color-body-on-dark);
}
.btn--ghost {
  background: transparent;
  color: var(--color-primary);
  border: 1.5px solid var(--color-primary);
}
.btn--ghost:hover { background: rgba(99, 33, 164, 0.06); color: var(--color-primary-deep); border-color: var(--color-primary-deep); }
.btn--small { height: 36px; padding: 0 var(--spacing-md); font-size: 13px; }
.btn--large {
  height: 52px;
  padding: 0 var(--spacing-xl);
  font-size: 16px;
  border-radius: var(--rounded-pill);
}
.btn--block { width: 100%; }

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .btn, .btn:hover, .btn:active { transform: none; }
}

/* ─── Inline link buttons (text actions) ────────────────────── */
.link-btn {
  background: none;
  border: none;
  color: var(--color-primary);
  font-family: inherit;
  font-size: inherit;
  font-weight: 700;
  cursor: pointer;
  padding: 0;
}
.link-btn:hover { color: var(--color-primary-deep); text-decoration: underline; }

/* ─── Chip / Pill ───────────────────────────────────────────── */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--rounded-pill);
  background: var(--color-canvas-lavender);
  color: var(--color-primary-deep);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.3px;
}

/* ─── Form fields ───────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: var(--spacing-md); }
.field__label {
  font-size: 13px;
  font-weight: 700;
  color: var(--color-ink);
}
.field__hint { font-size: 12px; color: var(--color-ink); opacity: 0.65; }
.input,
.select {
  width: 100%;
  height: 44px;
  padding: 0 var(--spacing-md);
  border: 1px solid var(--color-hairline);
  border-radius: var(--rounded-sm);
  background: var(--color-canvas);
  color: var(--color-ink);
  font-family: inherit;
  font-size: 14px;
  transition: border-color var(--motion-fast) var(--motion-ease-out);
}
.input::placeholder { color: rgba(30, 5, 46, 0.4); }
.input:hover { border-color: var(--color-lilac); }
.input:focus,
.select:focus {
  outline: none;
  border: 2px solid var(--color-primary);
  padding: 0 calc(var(--spacing-md) - 1px); /* compensate for the +1px border */
}
.input--error { border-color: var(--color-error); }
.input--error:focus { border-color: var(--color-error); }
.input[type="file"] { padding: 9px var(--spacing-sm); }
textarea.input { min-height: 120px; padding: var(--spacing-sm) var(--spacing-md); resize: vertical; }

.field-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: var(--spacing-sm);
  align-items: center;
}
.field-row__sep { color: var(--color-ink); opacity: 0.6; font-weight: 700; font-size: 13px; }
@media (max-width: 520px) {
  .field-row {
    grid-template-columns: 1fr;
  }
  .field-row__sep { display: none; }
}

/* ─── Alerts / inline messages ──────────────────────────────── */
.alert {
  padding: var(--spacing-sm) var(--spacing-md);
  border-radius: var(--rounded-sm);
  font-size: 13px;
  font-weight: 400;
  margin-bottom: var(--spacing-md);
}
.alert--error  { background: var(--color-error-soft);   color: var(--color-error); }
.alert--success { background: var(--color-success-soft); color: var(--color-success); }
.alert[hidden] { display: none; }

/* ─── Table ─────────────────────────────────────────────────── */
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table thead th {
  text-align: left;
  padding: var(--spacing-sm) var(--spacing-md);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--color-ink);
  opacity: 0.6;
  border-bottom: 1px solid var(--color-hairline);
}
.table tbody td {
  padding: var(--spacing-md);
  border-bottom: 1px solid var(--color-hairline);
  color: var(--color-ink);
}
/* Documents-table only: wrap long IDs/names within their column instead of
   stretching the layout. Scoped to #unloaked so the api-keys table (which
   scrolls via its own overflow-x wrapper) is untouched. */
#unloaked .table tbody td {
  max-width: 18rem;
  overflow: hidden;
  word-break: break-all;
  vertical-align: middle;
}
/* Action buttons stay on one line and reserve their own column width. */
#unloaked .table tbody td[data-label="Actions"] {
  max-width: 8rem;
  white-space: nowrap;
  word-break: normal;
  overflow: visible;
}
.table tbody tr:last-child td { border-bottom: none; }
/* Documents table: fixed layout so the columns honor their widths and a long
   Document ID wraps inside its column. With the default auto layout a td's
   max-width is ignored — the column balloons and pushes the table past the
   viewport instead of wrapping. Column widths come from the thead <th>s.
   Inert on mobile, where cells switch to display:block (see the 834px query). */
#unloaked .table { table-layout: fixed; }
.table--empty {
  text-align: center;
  padding: var(--spacing-xxl);
  color: var(--color-ink);
  opacity: 0.6;
  font-size: 14px;
}

/* ─── Activity / segmented control ──────────────────────────── */
.segmented {
  display: inline-flex;
  background: var(--color-canvas-lavender);
  border-radius: var(--rounded-pill);
  padding: 4px;
  gap: 2px;
}
.segmented__btn {
  border: none;
  background: transparent;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 700;
  color: var(--color-primary-deep);
  border-radius: var(--rounded-pill);
  cursor: pointer;
  font-family: inherit;
  transition: background var(--motion-fast) var(--motion-ease-out), color var(--motion-fast) var(--motion-ease-out);
}
.segmented__btn.active,
.segmented__btn:hover { background: var(--color-canvas); color: var(--color-ink); }

/* ─── Chart container ───────────────────────────────────────── */
.chart-canvas { position: relative; height: 220px; }

/* ─── Auth screen layout (template.form-settings) ───────────── */
.auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--spacing-xl) var(--spacing-md);
  background: var(--gradient-atmosphere);
}
.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--color-canvas);
  border: 1px solid var(--color-hairline);
  border-radius: var(--rounded-xl);
  padding: var(--spacing-xl);
}
.auth-card__brand {
  font-size: 22px;
  font-weight: 700;
  color: var(--color-primary-deep);
  margin-bottom: var(--spacing-xs);
  letter-spacing: -0.3px;
}
.auth-card__title {
  font-size: 24px;
  font-weight: 700;
  color: var(--color-ink);
  margin: 0 0 var(--spacing-md);
  letter-spacing: -0.2px;
}
.auth-card__subtitle {
  font-size: 14px;
  color: var(--color-ink);
  opacity: 0.7;
  margin: 0 0 var(--spacing-lg);
  line-height: 1.5;
}
.auth-card__footer {
  margin-top: var(--spacing-lg);
  text-align: center;
  font-size: 13px;
  color: var(--color-ink);
  opacity: 0.7;
}
.auth-card__footer a { font-weight: 700; }

/* ─── Modal ─────────────────────────────────────────────────── */
.modal { display: none; position: fixed; inset: 0; z-index: 10000; }
.modal.is-open { display: block; }

/* Cycle list inside the credits-history modal */
.cycle-item {
  padding: var(--spacing-md) 0;
  border-bottom: 1px solid var(--color-hairline);
}
.cycle-item:last-child { border-bottom: none; }
.cycle-item__header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 6px;
}
.cycle-item__title { font-weight: 700; color: var(--color-ink); }
.cycle-item__dates { font-size: 13px; color: var(--color-ink); opacity: 0.7; }
.cycle-item__usage { font-size: 13px; color: var(--color-primary-deep); font-weight: 700; }
.cycle-item.is-current .cycle-item__title { color: var(--color-primary-deep); }
.modal__overlay {
  position: absolute;
  inset: 0;
  background: rgba(30, 5, 46, 0.5);
}
.modal__panel {
  position: relative;
  background: var(--color-canvas);
  max-width: 520px;
  margin: 80px auto;
  border-radius: var(--rounded-xl);
  box-shadow: var(--shadow-card-emphasis);
  overflow: hidden;
}
.modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--spacing-md) var(--spacing-lg);
  border-bottom: 1px solid var(--color-hairline);
}
.modal__header h3 { margin: 0; font-size: 18px; }
.modal__close {
  background: none;
  border: none;
  font-size: 24px;
  color: var(--color-ink);
  opacity: 0.6;
  cursor: pointer;
  width: 32px;
  height: 32px;
  border-radius: var(--rounded-sm);
  transition: background var(--motion-fast) var(--motion-ease-out), opacity var(--motion-fast) var(--motion-ease-out);
}
.modal__close:hover { opacity: 1; background: var(--color-canvas-lavender); }
.modal__body {
  padding: var(--spacing-lg);
  max-height: 60vh;
  overflow-y: auto;
}

/* ─── Loading overlay ───────────────────────────────────────── */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 255, 0.75);
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(2px);
}
.loading-overlay.is-active { display: flex; }
.loading-overlay__spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--color-canvas-lavender);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .loading-overlay__spinner { animation-duration: 2s; }
}

/* ─── Profile pills (header-level info) ─────────────────────── */
.profile-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--spacing-md);
}
.profile-pill {
  background: var(--color-canvas);
  border: 1px solid var(--color-hairline);
  border-radius: var(--rounded-xl);
  padding: var(--spacing-md);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.profile-pill__label {
  font-size: 11px;
  font-weight: 700;
  color: var(--color-ink);
  opacity: 0.55;
  letter-spacing: 1px;
  text-transform: uppercase;
}
.profile-pill__value {
  font-size: 16px;
  font-weight: 700;
  color: var(--color-ink);
  overflow-wrap: anywhere;   /* long unbroken emails/names wrap instead of clipping */
}

/* ─── Footer ────────────────────────────────────────────────── */
.portal-footer {
  margin-top: var(--spacing-xl);
  padding-top: var(--spacing-lg);
  border-top: 1px solid var(--color-hairline);
  font-size: 13px;
  color: var(--color-ink);
  opacity: 0.7;
}
.portal-footer p { margin: var(--spacing-xs) 0 0; }

/* ─── Responsive ────────────────────────────────────────────── */
@media (max-width: 834px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: static;
    height: auto;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--spacing-xs);
    overflow-x: visible;
    padding: var(--spacing-sm) var(--spacing-md);
  }
  .sidebar__brand { margin-bottom: 0; padding: 0; min-width: max-content; margin-right: var(--spacing-sm); }
  /* Flatten nav + footer so all links become flex children of the bar and wrap
     inline. Previously the footer (Reset Password, Log Out) was display:none and
     overflowing links (User Guide) were clipped — both unreachable on mobile. */
  .sidebar__nav,
  .sidebar__footer {
    display: contents;
  }
  .sidebar__link { white-space: nowrap; }
  .app-main { padding: var(--spacing-lg) var(--spacing-md); }
  .page-header { flex-direction: column; }
  .split-grid { gap: var(--spacing-md); }

  /* Stacked table (documents only): each row becomes a card, each cell labels
     itself from its data-label attribute. Scoped to #unloaked — the api-keys
     table has no data-label cells and scrolls via its own overflow-x wrapper. */
  #unloaked .table thead {
    position: absolute;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    border: 0;
  }
  #unloaked .table tbody tr {
    display: block;
    border-bottom: 2px solid var(--color-hairline);
    padding: var(--spacing-sm) 0;
  }
  #unloaked .table tbody td {
    display: block;
    max-width: 100%;
    text-align: right;
    padding: var(--spacing-xs) var(--spacing-md) var(--spacing-xs) 45%;
    position: relative;
    border-bottom: none;
    white-space: normal;
  }
  #unloaked .table tbody td::before {
    content: attr(data-label);
    position: absolute;
    left: var(--spacing-md);
    width: 40%;
    text-align: left;
    font-weight: 700;
    text-transform: uppercase;
    font-size: 12px;
    opacity: 0.6;
  }
  #unloaked .table tbody td[data-label="Actions"] {
    max-width: 100%;
    text-align: right;
  }
}
@media (max-width: 480px) {
  .stat-grid { grid-template-columns: 1fr; }
}

/* ─── Utility ───────────────────────────────────────────────── */
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
.is-hidden { display: none !important; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: var(--spacing-sm); }
.gap-sm { gap: var(--spacing-sm); }
.mt-md { margin-top: var(--spacing-md); }
.mb-md { margin-bottom: var(--spacing-md); }

/* ─── Document action buttons (replace / delete) ────────────── */
.doc-action-btn {
  all: unset;
  box-sizing: border-box; /* all:unset reverts box-sizing; keep border inside the 1.9rem box */
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.9rem;
  height: 1.9rem;
  border-radius: var(--rounded-sm);
  transition: background var(--motion-fast) var(--motion-ease-out),
              color var(--motion-fast) var(--motion-ease-out),
              border-color var(--motion-fast) var(--motion-ease-out);
}
.doc-action-btn--update {
  color: var(--color-primary);
  border: 1px solid var(--color-primary);
  margin-right: 0.25rem;
}
.doc-action-btn--update:hover {
  background: var(--color-primary);
  color: var(--color-body-on-dark);
}
.doc-action-btn--delete {
  color: #888;
  border: 1px solid #ccc;
}
.doc-action-btn--delete:hover {
  background: var(--color-error);
  border-color: var(--color-error);
  color: #fff;
}

/* ─── Status badges ─────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: var(--rounded-pill);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.3px;
  white-space: nowrap;
}
.badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}
.badge--active   { background: var(--color-success-soft); color: var(--color-success); }
.badge--active::before   { background: var(--color-success); }
.badge--inactive { background: #f1f1f1; color: #888; }
.badge--inactive::before { background: #bbb; }

/* ─── Ghost button variants ─────────────────────────────────── */
.btn--danger-ghost {
  background: transparent;
  color: var(--color-error);
  border: 1.5px solid var(--color-error);
}
.btn--danger-ghost:hover  { background: var(--color-error); color: #fff; }

.btn--success-ghost {
  background: transparent;
  color: var(--color-success);
  border: 1.5px solid var(--color-success);
}
.btn--success-ghost:hover { background: var(--color-success); color: #fff; }

/* ─── Customer ID pill ──────────────────────────────────────── */
.cust-id-pill {
  display: inline-flex;
  align-items: center;
  gap: var(--spacing-md);
  background: var(--color-canvas);
  border: 1px solid var(--color-hairline);
  border-radius: var(--rounded-xl);
  padding: var(--spacing-md) var(--spacing-lg);
  margin-bottom: var(--spacing-xl);
}
.cust-id-pill__label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--color-ink);
  opacity: 0.55;
}
.cust-id-pill__code {
  font-family: 'Courier New', Courier, monospace;
  font-size: 13px;
  font-weight: 700;
  color: var(--color-primary-deep);
}

/* ─── New-key reveal box ────────────────────────────────────── */
.key-reveal-box {
  background: var(--color-canvas-lavender);
  border: 1px solid var(--color-lilac);
  border-radius: var(--rounded-md);
  padding: var(--spacing-md);
  font-family: 'Courier New', Courier, monospace;
  font-size: 13px;
  word-break: break-all;
  color: var(--color-primary-deep);
  line-height: 1.6;
  margin-bottom: var(--spacing-md);
}
.key-once-warning {
  display: flex;
  align-items: flex-start;
  gap: var(--spacing-sm);
  padding: var(--spacing-sm) var(--spacing-md);
  background: #fff8e1;
  border: 1px solid #ffe082;
  border-radius: var(--rounded-sm);
  font-size: 13px;
  color: #7c4a00;
  line-height: 1.5;
  margin-bottom: var(--spacing-md);
}

/* ─── Document ID cell (wraps long IDs + copy button) ───────── */
.doc-id-cell {
  display: inline-flex;
  align-items: flex-start;
  gap: var(--spacing-xs);
  min-width: 0;
}
.doc-id-text {
  font-family: 'Courier New', Courier, monospace;
  font-size: 13px;
  word-break: break-all;        /* long IDs wrap inside the column instead of overflowing */
  line-height: 1.4;
}
.doc-id-copy {
  all: unset;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  color: var(--color-primary);
  opacity: 0.55;
  flex-shrink: 0;
  margin-top: 1px;
  transition: opacity var(--motion-fast) var(--motion-ease-out);
}
.doc-id-copy:hover { opacity: 1; }
.doc-id-copy:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
  border-radius: 3px;
  opacity: 1;
}

/* ─── Upload form grid ──────────────────────────────────────── */
.upload-grid {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: var(--spacing-md);
  align-items: end;
}
@media (max-width: 640px) {
  .upload-grid { grid-template-columns: 1fr; }
  .upload-grid .btn { width: 100%; }
}

