/* =============================================================================
   site.coach — admin dashboard
   -----------------------------------------------------------------------------
   Aesthetic: Studio Press × Stripe, utility-forward.
   White substrate, hairline rules, dense type, persimmon as accent only.
   The customer-facing app gets the Sunrise gradient and editorial bloom; this
   is the staff console — denser, smaller fonts, no decorative gradients.

   The shell is rendered by router.js (topbar + sidebar + main #view); class
   contracts (.btn, .table, .field, .badge, .card, .modal-*, .nav-item, etc.)
   are stable so view modules keep working.
   ============================================================================= */

:root {
  /* ── Substrate ────────────────────────────────────────────────────────── */
  --paper:        #FFFFFF;
  --paper-warm:   #FAFAF7;
  --paper-veil:   #F5F4EE;

  /* ── Type ink ─────────────────────────────────────────────────────────── */
  --ink:          #0A0A0B;
  --ink-soft:     #3D3D42;
  --ink-faded:    #6B6B72;
  --ink-ghost:    #A4A4AB;

  /* ── Brand ────────────────────────────────────────────────────────────── */
  --persimmon:        #E55A3C;
  --persimmon-deep:   #C04421;
  --persimmon-soft:   #FCEBE3;

  /* ── Supporting inks ──────────────────────────────────────────────────── */
  --copper:   #B5713B;
  --success:  #2E7A5A;
  --warning:  #C99A2E;
  --info:     #2D4159;
  --danger:   #C04421;

  /* Soft fills for badges / chips / row hovers — derived from the inks. */
  --success-soft: #E2EFE9;
  --warning-soft: #F5EAC9;
  --info-soft:    #DCE2EA;
  --danger-soft:  #FBE3DD;

  /* ── Borders ──────────────────────────────────────────────────────────── */
  --rule:         rgba(10, 10, 11, 0.08);
  --rule-strong:  rgba(10, 10, 11, 0.16);
  --rule-soft:    rgba(10, 10, 11, 0.04);

  /* ── Type stack ───────────────────────────────────────────────────────── */
  --font-display: 'Fraunces', 'GT Sectra', Georgia, serif;
  --font-body:    'Geist', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono:    'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  /* ── Motion ───────────────────────────────────────────────────────────── */
  --ease-out: cubic-bezier(0.22, 0.61, 0.36, 1);
  --t-fast:   140ms;
  --t-base:   240ms;

  /* ── Radius scale ─────────────────────────────────────────────────────── */
  --radius-xs: 3px;
  --radius-sm: 4px;
  --radius:    6px;
  --radius-lg: 10px;

  /* ── Layout ───────────────────────────────────────────────────────────── */
  --sidebar-w: 232px;
  --topbar-h:  52px;

  /* ── Backwards-compatibility aliases ──────────────────────────────────────
     Anything here is something the old admin.css defined and at least one JS
     file references via var(--name). Keep them alive so HTML rendered by the
     view modules doesn't break colour, font, or border references. */

  /* — Old "Field Journal" paper tokens → flatten onto white substrate — */
  --paper-soft:    var(--paper-warm);
  --paper-deep:    var(--paper-veil);
  --paper-cream:   var(--paper-warm);
  --paper-bone:    var(--paper);

  /* — Old semantic ink names → new equivalents — */
  --oxblood:       var(--persimmon);
  --oxblood-deep:  var(--persimmon-deep);
  --oxblood-soft:  var(--persimmon-soft);

  --mustard:       var(--warning);
  --mustard-soft:  var(--warning-soft);
  --mustard-deep:  #6D4D0A;

  --verdigris:     var(--success);
  --verdigris-soft:var(--success-soft);
  --verdigris-deep:#1F3A30;

  --inkblue:       var(--info);
  --inkblue-soft:  var(--info-soft);

  /* — Old generic theme tokens — */
  --primary:       var(--persimmon);
  --primary-hover: var(--persimmon-deep);
  --primary-soft:  var(--persimmon-soft);
  --primary-fg:    var(--paper);

  --fg:            var(--ink);
  --fg-muted:      var(--ink-soft);
  --fg-light:      var(--ink-faded);
  --bg:            var(--paper);
  --bg-elevated:   var(--paper-warm);

  --border:        var(--rule);
  --border-soft:   var(--rule-soft);
  --border-strong: var(--rule-strong);

  /* — Old admin-specific font tokens — */
  /* Old admin used Fraunces as body font and JetBrains Mono as UI/mono. The new
     direction is Geist for body. --font-ui kept as an alias for legacy refs. */
  --font-ui:       var(--font-mono);

  /* — Drop-shadow tokens (kept for any inline ref; admin chrome no longer
       paints shadows itself, but downstream widgets may still reference). — */
  --shadow-xs: 0 1px 0 rgba(10, 10, 11, 0.03);
  --shadow-sm: 0 1px 0 rgba(10, 10, 11, 0.04);
  --shadow-md: 0 1px 0 rgba(10, 10, 11, 0.04);
  --shadow-lg: 0 1px 0 rgba(10, 10, 11, 0.06);
  --shadow-glow-primary: 0 0 0 3px rgba(229, 90, 60, 0.18);

  /* — coach-approval.js paintNavBadge fallback uses var(--accent,#f59e0b). — */
  --accent: var(--persimmon);
}

/* ── Reset ──────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; font-size: 14px; }

body {
  font-family: var(--font-body);
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-feature-settings: "ss01", "cv11";
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Headings — Fraunces, NOT italic by default. Italic reserved for the page
   title (and modal titles), which gives the admin its little editorial moment.
   Everything else stays sharp Geist. */
h1, h2, h3, .display {
  font-family: var(--font-display);
  font-variation-settings: "opsz" 144;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--ink);
}
h1 { font-size: 30px; line-height: 1.1; }
h2 { font-size: 20px; line-height: 1.2; font-weight: 500; }
h3 { font-size: 16px; line-height: 1.25; font-weight: 500; }

a {
  color: var(--persimmon);
  text-decoration: none;
  transition: color var(--t-fast);
}
a:hover { color: var(--persimmon-deep); text-decoration: underline; text-underline-offset: 3px; }

button { font-family: inherit; cursor: pointer; }

::selection { background: var(--persimmon-soft); color: var(--persimmon-deep); }

code, pre, .mono {
  font-family: var(--font-mono);
  font-size: 0.92em;
  letter-spacing: -0.005em;
}

/* ── Top bar — single hairline strip ────────────────────────────────────── */
.app { display: flex; flex-direction: column; height: 100vh; min-height: 0; }
.app.hidden { display: none; }

.topbar {
  height: var(--topbar-h);
  background: var(--paper);
  border-bottom: 1px solid var(--rule);
  display: flex; align-items: center;
  padding: 0 18px; gap: 14px;
  flex-shrink: 0;
  position: relative;
  z-index: 30;
}

.brand {
  font-family: var(--font-display);
  font-variation-settings: "opsz" 144;
  font-weight: 500;
  font-size: 17px;
  letter-spacing: -0.015em;
  color: var(--ink);
  display: inline-flex; align-items: baseline; gap: 5px;
  user-select: none;
}
.brand b {
  font-weight: 500;
  font-style: italic;
  font-family: var(--font-display);
  font-size: 16px;
  color: var(--persimmon);
}

.env-badge {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--persimmon);
  background: transparent;
  border: 1px solid var(--persimmon);
  padding: 2px 8px;
  border-radius: 2px;
}

.right {
  margin-left: auto;
  display: flex; align-items: center; gap: 14px;
}

.who {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.02em;
  color: var(--ink-soft);
}
.who .muted { color: var(--ink-faded); }

/* ── Layout ─────────────────────────────────────────────────────────────── */
.layout {
  display: flex;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

.sidebar {
  width: var(--sidebar-w);
  background: var(--paper);
  border-right: 1px solid var(--rule);
  display: flex; flex-direction: column;
  flex-shrink: 0;
  overflow-y: auto;
  z-index: 20;
}
.sidebar-section {
  padding: 20px 16px 6px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.20em;
  text-transform: uppercase;
  color: var(--ink-faded);
}
.nav-item {
  display: flex; align-items: center;
  padding: 7px 16px;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 450;
  letter-spacing: 0;
  color: var(--ink-soft);
  cursor: pointer;
  transition: color var(--t-fast), background var(--t-fast);
  user-select: none;
  position: relative;
  text-decoration: none;
}
.nav-item:hover {
  background: var(--paper-warm);
  color: var(--ink);
  text-decoration: none;
}
.nav-item.active {
  color: var(--persimmon);
  background: var(--paper);
  font-weight: 500;
}
.nav-item.active::before {
  content: ""; position: absolute;
  left: 0; top: 6px; bottom: 6px; width: 2px;
  background: var(--persimmon);
}
.nav-item .badge,
.nav-item .nav-badge {
  margin-left: auto;
  font-size: 10px;
  padding: 1px 6px;
}

.sidebar-footer {
  margin-top: auto;
  padding: 14px 16px;
  border-top: 1px solid var(--rule);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.10em;
  color: var(--ink-faded);
  text-transform: uppercase;
}

/* Drawer scrim — visible only on mobile. */
.scrim {
  display: none;
  position: fixed; inset: 0;
  background: rgba(10, 10, 11, 0.40);
  z-index: 19;
  opacity: 0;
  transition: opacity var(--t-base);
}
.scrim.open { display: block; opacity: 1; }

.nav-burger {
  display: none;
  width: 34px; height: 34px;
  align-items: center; justify-content: center;
  border-radius: var(--radius);
  background: var(--paper);
  border: 1px solid var(--rule);
  cursor: pointer;
  color: var(--ink);
  margin-right: 4px;
}
.nav-burger:hover { border-color: var(--rule-strong); }

/* ── Main column ────────────────────────────────────────────────────────── */
.main {
  flex: 1;
  overflow-y: auto;
  padding: 28px 32px 60px;
  min-width: 0;
  scroll-behavior: smooth;
  background: var(--paper);
}
.main > * { max-width: 1280px; margin: 0 auto; }

/* Page title — Fraunces 500, NOT italic by default (small editorial moment).
   Smaller than the customer dashboard's 36–44px; this is the staff console. */
.page-title {
  font-family: var(--font-display);
  font-variation-settings: "opsz" 144;
  font-style: normal;
  font-weight: 500;
  font-size: clamp(26px, 2.6vw, 32px);
  line-height: 1.1;
  color: var(--ink);
  margin-bottom: 4px;
  letter-spacing: -0.015em;
}
.page-sub {
  font-size: 13px;
  color: var(--ink-faded);
  margin-bottom: 22px;
  max-width: 70ch;
  line-height: 1.55;
}
.page-sub.mono {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--ink-faded);
  text-transform: uppercase;
}

/* Mono kicker — used on section headers as a small persimmon label.
   Apply via class="kicker" or explicitly on .card-title.kicker. */
.kicker {
  display: block;
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--persimmon);
  margin-bottom: 4px;
}

/* ── Cards ──────────────────────────────────────────────────────────────── */
.card {
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 14px;
}
.card.hidden { display: none; }
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding-bottom: 12px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--rule);
  gap: 14px;
}
.card-title {
  font-family: var(--font-display);
  font-variation-settings: "opsz" 144;
  font-style: normal;
  font-size: 17px;
  font-weight: 500;
  color: var(--ink);
  letter-spacing: -0.01em;
}

/* ── Buttons ────────────────────────────────────────────────────────────── */
button, .btn {
  font-family: var(--font-body);
  font-size: 12.5px;
  font-weight: 500;
  letter-spacing: 0;
  border: 1px solid var(--rule-strong);
  background: var(--paper);
  color: var(--ink);
  padding: 6px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast), transform var(--t-fast);
  display: inline-flex; align-items: center; gap: 6px;
  white-space: nowrap;
}
button:hover, .btn:hover {
  background: var(--paper-warm);
  border-color: var(--ink-faded);
}
button:active, .btn:active { transform: translateY(0.5px); }
button:disabled, .btn:disabled { opacity: 0.45; cursor: not-allowed; }
button:focus-visible, .btn:focus-visible {
  outline: none;
  box-shadow: var(--shadow-glow-primary);
}

/* Primary — persimmon. Reserved for the single most important action per card. */
button.primary, .btn.primary, .btn-primary {
  background: var(--persimmon);
  color: #FFFFFF;
  border-color: var(--persimmon);
}
button.primary:hover, .btn.primary:hover, .btn-primary:hover {
  background: var(--persimmon-deep);
  border-color: var(--persimmon-deep);
  color: #FFFFFF;
}

/* Ghost — transparent + hairline, persimmon hover. */
button.ghost, .btn.ghost, .btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--ink-soft);
}
button.ghost:hover, .btn.ghost:hover, .btn-ghost:hover {
  background: var(--paper-warm);
  color: var(--persimmon);
  border-color: var(--rule);
}

/* Danger — outlined; turns solid on hover. */
button.danger, .btn.danger, .btn-danger {
  background: var(--paper);
  color: var(--danger);
  border-color: var(--danger);
}
button.danger:hover, .btn.danger:hover, .btn-danger:hover {
  background: var(--danger);
  color: #FFFFFF;
  border-color: var(--danger);
}
button.danger.ghost, .btn.danger.ghost {
  background: transparent;
  border-color: transparent;
}
button.danger.ghost:hover, .btn.danger.ghost:hover {
  background: var(--danger-soft);
  color: var(--persimmon-deep);
  border-color: transparent;
}

/* Copy button — used on snippets / IDs in coach editor + site key modal. */
.copy-btn {
  font-family: var(--font-mono);
  font-size: 10.5px;
  padding: 4px 9px;
  letter-spacing: 0.10em;
  text-transform: uppercase;
}
.copy-btn.primary {
  background: var(--persimmon);
  color: #FFFFFF;
  border-color: var(--persimmon);
}
.copy-btn.copied {
  background: var(--success-soft);
  color: var(--success);
  border-color: var(--success);
}
.copy-btn.copy-failed {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: var(--danger);
}

/* ── Form controls ──────────────────────────────────────────────────────── */
input, textarea, select {
  font-family: var(--font-body);
  font-size: 13px;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius);
  padding: 7px 11px;
  width: 100%;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--persimmon);
  box-shadow: var(--shadow-glow-primary);
}
input::placeholder, textarea::placeholder { color: var(--ink-ghost); }
textarea {
  resize: vertical;
  min-height: 84px;
  line-height: 1.5;
  font-family: var(--font-mono);
  font-size: 12px;
}
input[type="checkbox"], input[type="radio"] { width: auto; accent-color: var(--persimmon); }
select {
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236B6B72' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='m6 9 6 6 6-6'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
}
label {
  display: block;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--ink-faded);
  margin-bottom: 5px;
}

/* Field — label + input block. */
.field { margin-bottom: 12px; }
.field-row { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.field-row > .field { flex: 1; margin-bottom: 0; }

/* Spinner — small persimmon ring. */
.spinner {
  display: inline-block;
  width: 14px; height: 14px;
  border: 1.5px solid var(--rule-strong);
  border-top-color: var(--persimmon);
  border-radius: 50%;
  animation: spin 700ms linear infinite;
  vertical-align: -2px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Tables ─────────────────────────────────────────────────────────────── */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
  background: var(--paper);
  font-variant-numeric: tabular-nums;
}
.table th {
  text-align: left;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-faded);
  padding: 9px 12px 7px;
  border-bottom: 1px solid var(--rule-strong);
  background: var(--paper);
  position: sticky; top: 0; z-index: 1;
  white-space: nowrap;
}
.table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--rule);
  vertical-align: middle;
  font-variant-numeric: tabular-nums;
}
.table tr:nth-child(even) td {
  background: var(--paper-warm);
}
.table td.mono, .table td .mono {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--ink-soft);
  letter-spacing: -0.005em;
}
.table tr.row-hover { transition: background var(--t-fast); }
.table tr.row-hover:hover td {
  background: var(--persimmon-soft);
  cursor: pointer;
}
.table tr:last-child td { border-bottom: 0; }
.table td:first-child, .table th:first-child { padding-left: 16px; }
.table td:last-child, .table th:last-child { padding-right: 16px; }

/* JS uses <th class="right"> and <td class="right"> for trailing-action cells.
   That collides with the global .right (topbar) layout class. Disambiguate
   inside tables: in a cell, "right" means "right-align contents". */
.table th.right, .table td.right {
  text-align: right;
  margin-left: 0;
  display: table-cell;
}

.actions {
  display: flex; gap: 6px;
  justify-content: flex-end;
  align-items: center;
}

/* ── Badges — small chips with colored left rule ────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 2px;
  background: var(--paper-warm);
  color: var(--ink-soft);
  border: 1px solid var(--rule);
  border-left: 2px solid var(--rule-strong);
}
.badge.success { background: var(--success-soft); color: var(--success); border-color: var(--success-soft); border-left-color: var(--success); }
.badge.warning { background: var(--warning-soft); color: #6D4D0A;        border-color: var(--warning-soft); border-left-color: var(--warning); }
.badge.info    { background: var(--info-soft);    color: var(--info);    border-color: var(--info-soft);    border-left-color: var(--info); }
.badge.danger  { background: var(--danger-soft);  color: var(--danger);  border-color: var(--danger-soft);  border-left-color: var(--danger); }

/* nav-badge — pending-approval count chip in sidebar (coach-approval.js) */
.nav-badge {
  display: inline-flex; align-items: center;
  font-family: var(--font-mono);
  font-size: 10px; font-weight: 500;
  background: var(--persimmon);
  color: #FFFFFF;
  padding: 1px 6px;
  border-radius: 8px;
  letter-spacing: 0.04em;
}

/* ── Modals ─────────────────────────────────────────────────────────────── */
.modal-host {
  position: fixed; inset: 0;
  display: none;
  align-items: center; justify-content: center;
  z-index: 200;
  padding: 16px;
  background: rgba(10, 10, 11, 0.50);
}
.modal-host.open { display: flex; animation: fadeIn 200ms var(--ease-out); }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--paper);
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius);
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  display: flex; flex-direction: column;
  overflow: hidden;
  animation: modalIn 240ms var(--ease-out);
}
@keyframes modalIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.modal-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--rule);
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  background: var(--paper);
}
.modal-title {
  font-family: var(--font-display);
  font-variation-settings: "opsz" 144;
  font-style: italic;
  font-size: 20px;
  font-weight: 500;
  color: var(--ink);
  letter-spacing: -0.01em;
}
.modal-body { flex: 1; overflow: auto; padding: 16px 20px; }
.modal-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--rule);
  display: flex; gap: 10px; align-items: center; justify-content: flex-end;
  background: var(--paper-warm);
}

/* ── Toasts ─────────────────────────────────────────────────────────────── */
.toast-host {
  position: fixed; top: 16px; right: 16px;
  z-index: 300;
  display: flex; flex-direction: column; gap: 8px;
  pointer-events: none;
  max-width: 360px;
}
.toast-host > * { pointer-events: auto; }
.toast {
  background: var(--paper);
  border: 1px solid var(--rule-strong);
  border-left: 3px solid var(--persimmon);
  border-radius: var(--radius);
  padding: 9px 14px;
  font-family: var(--font-body);
  font-size: 12.5px;
  color: var(--ink);
  animation: slideIn 240ms var(--ease-out);
}
.toast.error,
.toast.danger  { border-left-color: var(--danger); }
.toast.success { border-left-color: var(--success); }
.toast.warning { border-left-color: var(--warning); }
.toast.info    { border-left-color: var(--info); }
@keyframes slideIn {
  from { transform: translateX(16px); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}

/* ── Coach editor — multi-pane workshop ─────────────────────────────────── */
.coach-editor {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 16px;
  align-items: stretch;
}
.editor-col, .history-col {
  display: flex; flex-direction: column; gap: 14px;
  min-width: 0;
}
.history-col {
  border-left: 1px solid var(--rule);
  padding-left: 16px;
}

/* Library-view summary strip (templates page top, customers page top). */
.coach-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--paper);
  overflow: hidden;
}
.coach-summary-cell {
  padding: 14px 18px;
  border-right: 1px solid var(--rule);
}
.coach-summary-cell:last-child { border-right: 0; }
.coach-summary-label {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-faded);
  margin-bottom: 4px;
}
.coach-summary-value {
  font-family: var(--font-display);
  font-variation-settings: "opsz" 144;
  font-size: 22px;
  font-weight: 500;
  color: var(--ink);
  letter-spacing: -0.01em;
}

/* "Currently active" headline card on Global / Customer coach pages. */
.coach-active-card {
  border: 1px solid var(--rule);
  border-left: 3px solid var(--persimmon);
  border-radius: var(--radius);
  background: var(--paper);
  padding: 14px 18px;
}
.coach-active-card.coach-active-empty {
  border-left-color: var(--rule-strong);
  background: var(--paper-warm);
}
.coach-active-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
}
.coach-active-label {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-faded);
  margin-bottom: 4px;
}
.coach-active-value {
  font-family: var(--font-display);
  font-variation-settings: "opsz" 144;
  font-size: 20px;
  font-weight: 500;
  color: var(--ink);
}

/* Library table row — subtle selection ring when checked for diff. */
.tplx-row td { vertical-align: top; }
.tplx-row-selected td {
  background: var(--info-soft) !important;
}

/* Drawer-mode modal: slide-from-right, wider, full height. */
.modal-host.drawer-mode {
  justify-content: flex-end;
  padding: 0;
}
.modal-host.drawer-mode .modal {
  max-width: 720px;
  width: 720px;
  max-height: 100vh;
  height: 100vh;
  border-radius: 0;
  border-right: 0;
  border-top: 0;
  border-bottom: 0;
  animation: drawerIn 240ms var(--ease-out);
}
@keyframes drawerIn {
  from { opacity: 0; transform: translateX(40px); }
  to   { opacity: 1; transform: translateX(0); }
}
@media (max-width: 880px) {
  .modal-host.drawer-mode .modal { width: 100%; max-width: 100%; }
  .coach-summary { grid-template-columns: 1fr; }
  .coach-summary-cell { border-right: 0; border-bottom: 1px solid var(--rule); }
  .coach-summary-cell:last-child { border-bottom: 0; }
}

.cms-tabs {
  display: flex;
  border-bottom: 1px solid var(--rule);
  gap: 0;
  margin-bottom: 0;
}
.cms-tab {
  padding: 8px 14px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-faded);
  cursor: pointer;
  border: 1px solid transparent;
  border-bottom: 2px solid transparent;
  background: transparent;
  margin-bottom: -1px;
  transition: color var(--t-fast), border-color var(--t-fast);
  user-select: none;
  border-radius: 0;
}
.cms-tab:hover { color: var(--ink); background: transparent; border-color: transparent; border-bottom-color: transparent; }
.cms-tab.active {
  color: var(--persimmon);
  border-bottom-color: var(--persimmon);
  font-weight: 500;
}

/* Code/JSON blocks — workshop-warm fill, hairline border, mono. */
.system-prompt, .workflow {
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.55;
  background: var(--paper-warm);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 12px 14px;
  white-space: pre-wrap;
  color: var(--ink);
  max-height: 540px;
  overflow-y: auto;
}

.checkpoint-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 12px;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--paper);
  margin-bottom: 8px;
  font-size: 12.5px;
  transition: border-color var(--t-fast), background var(--t-fast);
  cursor: pointer;
  flex-wrap: wrap;
  gap: 6px;
}
.checkpoint-row:hover { background: var(--paper-warm); border-color: var(--rule-strong); }
.checkpoint-row.is-default,
.checkpoint-row.active {
  border-left: 2px solid var(--persimmon);
}
.checkpoint-row.selected-a { border-color: var(--info); }
.checkpoint-row.selected-b { border-color: var(--success); }
.checkpoint-row .meta {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.04em;
  color: var(--ink-faded);
}

.diff-host {
  display: flex; gap: 0;
  font-family: var(--font-mono);
  font-size: 11.5px;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  overflow: hidden;
}
.diff-pane {
  flex: 1;
  padding: 12px 14px;
  white-space: pre-wrap;
  line-height: 1.55;
  overflow-x: auto;
  background: var(--paper-warm);
}
.diff-pane:first-child { border-right: 1px solid var(--rule); }
.diff-line { display: block; padding: 0 4px; border-radius: 2px; }
.diff-line.add  { background: var(--success-soft); color: var(--success); }
.diff-line.del  { background: var(--danger-soft);  color: var(--danger); }
.diff-line.same,
.diff-line.ctx  { color: var(--ink-soft); }

@media (max-width: 1100px) {
  .coach-editor { grid-template-columns: 1fr; }
  .history-col {
    border-left: 0;
    padding-left: 0;
    border-top: 1px solid var(--rule);
    padding-top: 16px;
  }
}

/* ── Install banner (used in connector / install views) ─────────────────── */
.install-banner {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius);
  background: var(--paper);
  border: 1px solid var(--rule);
  border-left: 3px solid var(--ink-faded);
  margin-bottom: 16px;
}
.install-banner.pending { border-left-color: var(--warning); }
.install-banner.ok      { border-left-color: var(--success); }
.install-banner:has(.install-dot.ok)      { border-left-color: var(--success); }
.install-banner:has(.install-dot.waiting),
.install-banner:has(.install-dot.pending) { border-left-color: var(--warning); }

.install-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--ink-ghost);
}
.install-dot.ok       { background: var(--success); box-shadow: 0 0 0 4px var(--success-soft); animation: pulse 2.4s var(--ease-out) infinite; }
.install-dot.pending  { background: var(--warning); box-shadow: 0 0 0 4px var(--warning-soft); animation: pulse 2.4s var(--ease-out) infinite; }
.install-dot.waiting  { background: var(--warning); box-shadow: 0 0 0 4px var(--warning-soft); animation: pulse 2.4s var(--ease-out) infinite; }
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 currentColor; }
  70%  { box-shadow: 0 0 0 8px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}
.install-label {
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
}
.install-label.muted { color: var(--ink-faded); font-weight: 400; }
.install-pill {
  margin-left: auto;
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  background: var(--paper-warm);
  padding: 3px 9px;
  border-radius: 2px;
  color: var(--ink-soft);
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border: 1px solid var(--rule);
  border-left: 2px solid var(--rule-strong);
}

/* ── Empty state ────────────────────────────────────────────────────────── */
.empty-state {
  padding: 48px 20px;
  text-align: center;
  color: var(--ink-faded);
  font-family: var(--font-body);
  font-size: 14px;
}
.empty-state .display {
  font-family: var(--font-display);
  font-variation-settings: "opsz" 144;
  font-style: italic;
  font-size: 22px;
  font-weight: 500;
  color: var(--ink);
  margin-bottom: 8px;
  letter-spacing: -0.01em;
}

/* ── Utility ────────────────────────────────────────────────────────────── */
.hidden { display: none !important; }
.muted  { color: var(--ink-faded); }
.spacer { flex: 1; }

.row        { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.row.gap-sm  { gap: 6px; }
.row.gap-md  { gap: 12px; }
.row.gap-lg  { gap: 20px; }

.mt-sm { margin-top: 8px; }
.mt-md { margin-top: 16px; }
.mt-lg { margin-top: 28px; }
.mb-sm { margin-bottom: 8px; }
.mb-md { margin-bottom: 16px; }
.mb-lg { margin-bottom: 28px; }

.check {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--ink-soft);
  user-select: none;
}
.ca-rowsel { display: inline-flex; align-items: center; gap: 8px; }

/* ── Login shell ────────────────────────────────────────────────────────── */
.login-shell {
  display: flex;
  align-items: center; justify-content: center;
  flex: 1;
  padding: 20px;
  position: relative;
  overflow: hidden;
  background: var(--paper);
}
.login-shell.hidden { display: none; }
.login-shell::before {
  /* Small persimmon kicker rule above the card. */
  content: "";
  position: absolute;
  top: 14%; left: 50%; transform: translateX(-50%);
  width: 48px; height: 1.5px;
  background: var(--persimmon);
}
.login-shell::after {
  content: "ADMIN · INTERNAL ONLY · STAFF SIGN-IN";
  position: absolute;
  top: calc(14% + 12px); left: 50%; transform: translateX(-50%);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.32em;
  color: var(--ink-faded);
  white-space: nowrap;
}
@media (max-width: 720px) {
  .login-shell::before, .login-shell::after { display: none; }
}

.login-card {
  width: 380px;
  max-width: 100%;
  padding: 36px 32px;
  background: var(--paper);
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius);
  position: relative;
  animation: modalIn 320ms var(--ease-out);
}
.login-card h1 {
  font-family: var(--font-display);
  font-variation-settings: "opsz" 144;
  font-style: italic;
  font-size: 32px;
  margin: 0;
  text-align: center;
  color: var(--ink);
  letter-spacing: -0.02em;
  line-height: 1;
  font-weight: 500;
}
.login-card .sub {
  text-align: center;
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-faded);
  margin: 10px 0 24px;
}
.login-card .field { margin-bottom: 14px; }
.login-card .field label {
  display: block;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--ink-faded);
  margin-bottom: 5px;
}
.login-card .field input {
  width: 100%;
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius);
  background: var(--paper);
  font-family: var(--font-body);
  font-size: 13.5px;
  color: var(--ink);
  padding: 8px 10px;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.login-card .field input:focus {
  outline: none;
  border-color: var(--persimmon);
  box-shadow: var(--shadow-glow-primary);
}
.login-card form button[type="submit"],
.login-card form button.primary {
  width: 100%;
  padding: 11px;
  background: var(--persimmon);
  color: #FFFFFF;
  border: 1px solid var(--persimmon);
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 13.5px;
  font-weight: 500;
  letter-spacing: 0;
  cursor: pointer;
  margin-top: 6px;
  text-transform: none;
}
.login-card form button[type="submit"]:hover,
.login-card form button.primary:hover {
  background: var(--persimmon-deep);
  border-color: var(--persimmon-deep);
  color: #FFFFFF;
}
.login-error {
  color: var(--danger);
  font-family: var(--font-body);
  font-size: 12.5px;
  margin-bottom: 10px;
  min-height: 16px;
  text-align: center;
}
.login-error.hidden { display: none; }

.btn-google {
  width: 100%;
  padding: 10px 12px;
  display: inline-flex; align-items: center; justify-content: center;
  gap: 10px;
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  cursor: pointer;
  transition: background var(--t-fast), border-color var(--t-fast);
}
.btn-google:hover {
  background: var(--paper-warm);
  border-color: var(--ink-faded);
}
.btn-google .g-icon { display: inline-flex; width: 18px; height: 18px; flex-shrink: 0; }

.login-divider {
  display: flex; align-items: center; gap: 12px;
  margin: 18px 0;
  color: var(--ink-faded);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.30em;
  text-transform: uppercase;
}
.login-divider::before, .login-divider::after {
  content: ""; flex: 1; height: 1px; background: var(--rule);
}

/* ── Scrollbars ─────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--rule-strong);
  border-radius: 999px;
  border: 2px solid var(--paper);
}
::-webkit-scrollbar-thumb:hover { background: var(--ink-faded); }

/* =============================================================================
   Responsive
   ============================================================================= */

@media (max-width: 1100px) {
  :root { --sidebar-w: 200px; }
  .main { padding: 24px 24px 60px; }
}

@media (max-width: 900px) {
  .nav-burger { display: inline-flex; }
  .sidebar {
    position: fixed;
    top: var(--topbar-h);
    left: 0;
    bottom: 0;
    width: 260px;
    transform: translateX(-100%);
    transition: transform 280ms var(--ease-out);
    background: var(--paper);
    border-right: 1px solid var(--rule-strong);
  }
  .sidebar.open { transform: translateX(0); }
  .main { padding: 22px 18px 60px; }
}

@media (max-width: 720px) {
  :root { --topbar-h: 48px; }
  .topbar { padding: 0 12px; gap: 8px; }
  .who { display: none; }
  .env-badge { font-size: 9px; padding: 1px 6px; }
  .main { padding: 20px 14px 60px; }
  .page-title { font-size: 24px; }
  .table { font-size: 12px; }
  .table th { font-size: 9.5px; padding: 7px 9px 6px; }
  .table td { padding: 7px 9px; }
  .modal { max-width: 100%; max-height: 96vh; }
  .modal-header, .modal-body, .modal-footer { padding-left: 16px; padding-right: 16px; }
  .toast-host { top: 8px; right: 8px; left: 8px; max-width: none; }
  .login-card { padding: 28px 22px; }
  .login-card h1 { font-size: 26px; }
}

@media (max-width: 460px) {
  .row.between { flex-wrap: wrap; }
  .actions { flex-wrap: wrap; }
  .field-row { flex-direction: column; align-items: stretch; }
}

/* ── Reduced motion ─────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
