/* ============================================================
   Operator-grade editorial — shared design system
   Used by landing.html, portal.html, approval_ui.html
   ============================================================ */

:root {
  /* Surfaces — Amber Pop (matches marketing site, 2026-08-24) */
  --paper:        #f4f4f2;
  --paper-2:      #eae9e5;
  --paper-3:      #e0ded7;
  --card:         #ffffff;

  /* Ink */
  --ink:          #1a1a16;
  --ink-soft:     #57554d;
  --ink-muted:    #8a8880;

  /* Borders */
  --hair:         #e3e1d9;
  --hair-strong:  #d3d0c6;

  /* Accent — tangerine (Amber Pop) + teal secondary */
  --accent:       #f97e34;
  --accent-ink:   #c85f14;
  --accent-wash:  #fde3cd;
  --teal:         #1aa3a3;
  --teal-ink:     #0d7d78;

  /* Semantic */
  --ok:           #3d6a4f;
  --ok-wash:      #e6efe7;
  --warn:         #a56f28;
  --warn-wash:    #f3ead5;
  --danger:       #a4432b;
  --danger-wash:  #f2dcd3;

  /* Shadows */
  --shadow-sm:    0 1px 0 rgba(31,42,47,0.04);
  --shadow-md:    0 1px 0 rgba(31,42,47,0.04), 0 12px 32px -20px rgba(31,42,47,0.18);
  --shadow-lg:    0 2px 4px rgba(31,42,47,0.04), 0 24px 48px -24px rgba(31,42,47,0.22);

  /* Type */
  --font-display: "Fraunces", Georgia, "Times New Roman", serif;
  --font-body:    "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono:    "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  /* Reply intent tokens — used by Email Health breakdown widget,
     Sequences filter chips, and lead-card reply badges. Each intent
     has a foreground (ink) and a wash (light background fill). Picked
     to meet WCAG AA contrast (4.5:1) against the wash. Calibrated to
     the warm-terracotta paper palette so they read as part of the same
     design language, not a generic SaaS green/red/blue traffic light. */
  --intent-hot:           #1f6f3f;  /* hot lead — vivid green, the win */
  --intent-hot-wash:      #dbeed8;
  --intent-positive:      #2f5a3f;  /* replied (other) — calmer green */
  --intent-positive-wash: #e6efe7;
  --intent-neutral:       #2f4f8a;  /* question — informational blue */
  --intent-neutral-wash:  #dde6f4;
  --intent-ooo:           #8a5a1a;  /* OOO — amber/sand, calendar-y */
  --intent-ooo-wash:      #f3ead5;
  --intent-decline:       #9a4226;  /* polite no — terracotta-red */
  --intent-decline-wash:  #f2ddd1;
  --intent-unsub:         #6e2f1c;  /* unsub — darker red, finality */
  --intent-unsub-wash:    #ecd5cb;
  --intent-bounce:        #a4321f;  /* bounce — full red, problem */
  --intent-bounce-wash:   #f2dcd3;
  --intent-complaint:     #7d1a14;  /* spam complaint — darkest red */
  --intent-complaint-wash:#ecc9c2;
  --intent-zero:          #9a9484;  /* asked-and-answered-nothing */
  --intent-zero-wash:     #f0ebde;

  /* Legacy aliases — keep existing selectors working during migration */
  --accent-bg:    var(--accent-wash);
  --bg:           var(--paper);
  --border:       var(--hair);
  --text:         var(--ink);
  --muted:        var(--ink-soft);

  /* ── Spacing + type scale (design tokens, 2026-07-05) ──────────────
     New rules use these instead of magic numbers. Canonical breakpoints
     (consolidation pending, tracked in TODOS): 640 / 960 / 1200. */
  --space-1: 4px;   --space-2: 8px;   --space-3: 12px;
  --space-4: 16px;  --space-5: 24px;  --space-6: 32px;
  --text-xs: 11px;  --text-sm: 13px;  --text-md: 16px;
  --text-lg: 20px;  --text-xl: 22px;  --text-2xl: 28px;
  --green:        var(--ok);
  --green-bg:     var(--ok-wash);
  --red:          var(--danger);
  --red-bg:       var(--danger-wash);
  --blue:         var(--ink);
  --yellow:       var(--warn);
  --yellow-bg:    var(--warn-wash);
  --high:         var(--ok);
  --medium:       var(--warn);
  --low:          var(--ink-muted);
  --top:          var(--ok);
  --great:        #2f5a8c;
  --good:         var(--accent);
  --excluded:     var(--ink-muted);
}

/* ─── Reset / base ──────────────────────────────────────────── */
* { box-sizing: border-box; margin: 0; padding: 0; }

html { background: var(--paper); }

body {
  font-family: var(--font-body);
  background: var(--paper);
  color: var(--ink);
  line-height: 1.55;
  font-feature-settings: "ss01" 1, "cv11" 1;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  background-image:
    radial-gradient(circle at 20% 0%, rgba(180,95,61,0.025), transparent 40%),
    radial-gradient(circle at 90% 80%, rgba(31,42,47,0.018), transparent 45%);
  background-attachment: fixed;
}

/* ─── Header ────────────────────────────────────────────────── */
.header {
  background: var(--paper);
  border-bottom: 1px solid var(--hair);
  padding: 16px 28px;
  display: flex;
  align-items: center;
  gap: 20px;
}

.header .brand-lockup {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--ink);
  min-height: 44px;
  padding: 0 4px;
}
.header .brand-mark {
  width: 22px;
  height: 22px;
  background: url('/static/logo.png') no-repeat center / contain;
  position: relative;
  flex-shrink: 0;
}
.header .brand-mark::after { content: none; }
.header h1,
.header .wordmark {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 19px;
  letter-spacing: -0.01em;
  line-height: 1;
}
.header h1 a { color: inherit; text-decoration: none; }
.header h1 a:hover { color: var(--accent-ink); }

.header .brand-title {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--ink-soft);
  padding-left: 16px;
  border-left: 1px solid var(--hair);
}

.header .subtitle {
  color: var(--ink-soft);
  font-size: 13px;
  margin-left: 4px;
  font-family: var(--font-mono);
  letter-spacing: 0.04em;
}

.header .client-id { display: none; }

/* Client switcher */
.client-switcher {
  flex: 1;
  max-width: 300px;
  margin-left: auto;
}
.client-switcher select {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--hair);
  border-radius: 8px;
  font-size: 13px;
  font-family: var(--font-body);
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
  outline: none;
  transition: border-color 0.15s;
}
.client-switcher select:hover { border-color: var(--hair-strong); }
.client-switcher select:focus { border-color: var(--accent-ink); }

/* ─── Tabs ──────────────────────────────────────────────────── */
.tabs-wrapper {
  position: relative;
  overflow: hidden;
}
.tabs-wrapper::after {
  content: '';
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 48px;
  background: linear-gradient(to right, transparent, var(--paper));
  pointer-events: none;
  z-index: 1;
}
.tabs {
  display: flex;
  gap: 2px;
  background: var(--paper);
  border-bottom: 1px solid var(--hair);
  padding: 0 28px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tab-btn {
  background: none;
  border: none;
  padding: 14px 18px 12px;
  min-height: 44px;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-soft);
  cursor: pointer;
  white-space: nowrap;
  position: relative;
  transition: color 0.15s;
  letter-spacing: -0.005em;
}
.tab-btn:hover { color: var(--ink); }
.tab-btn.active { color: var(--ink); }
.tab-btn.active::after {
  content: "";
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: -1px;
  height: 2px;
  background: var(--accent);
  border-radius: 2px 2px 0 0;
}

/* ─── Content shell ────────────────────────────────────────── */
.content { max-width: 1100px; margin: 0 auto; padding: 32px 28px; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ─── Buttons ───────────────────────────────────────────────── */
.btn-primary,
.btn-ink {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--ink);
  color: var(--paper);
  border: none;
  border-radius: 999px;
  padding: 10px 20px;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: -0.005em;
  cursor: pointer;
  transition: background 0.18s, transform 0.18s, box-shadow 0.18s;
  box-shadow: var(--shadow-sm);
  text-decoration: none;
}
.btn-primary:hover,
.btn-ink:hover {
  background: #2a363c;
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}
.btn-primary:active,
.btn-ink:active { transform: translateY(0); }
.btn-primary:disabled,
.btn-ink:disabled { opacity: 0.45; cursor: not-allowed; transform: none; box-shadow: none; }
.btn-primary::after,
.btn-ink::after {
  content: "\2192";
  font-size: 14px;
  line-height: 1;
  transition: transform 0.18s;
}
.btn-primary:hover::after,
.btn-ink:hover::after { transform: translateX(2px); }
.btn-primary.no-arrow::after,
.btn-ink.no-arrow::after { content: none; }

/* Primary action = tangerine, to match the marketing CTA. .btn-ink stays dark. */
.btn-primary {
  background: var(--accent);
  color: #231202;
  box-shadow: 0 8px 18px -10px rgba(249,126,52,0.55);
}
.btn-primary:hover { background: var(--accent-ink); color: #fff; box-shadow: 0 12px 24px -10px rgba(249,126,52,0.6); }

.btn-ghost {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  color: var(--ink-soft);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  padding: 10px 14px;
  cursor: pointer;
  border-radius: 999px;
  transition: color 0.15s, background 0.15s;
}
.btn-ghost:hover {
  color: var(--ink);
  background: var(--paper-2);
}
.btn-ghost.underline-hover { border-radius: 0; padding: 10px 4px; }
.btn-ghost.underline-hover:hover {
  background: none;
  box-shadow: inset 0 -1px 0 var(--ink);
}

.btn-danger {
  background: var(--danger);
  color: var(--paper);
  border: none;
  border-radius: 999px;
  padding: 9px 18px;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.15s;
}
.btn-danger:hover { opacity: 0.9; }

/* ─── Chips / tags / badges ────────────────────────────────── */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  background: var(--paper-2);
  border: 1px solid var(--hair);
  border-radius: 999px;
  font-family: var(--font-body);
  font-size: 12px;
  color: var(--ink);
  line-height: 1.5;
}
.chip .chip-x {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--ink-muted);
  padding: 0 2px;
  font-size: 14px;
  line-height: 1;
}
.chip .chip-x:hover { color: var(--accent-ink); }

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  background: var(--paper-2);
  color: var(--ink-soft);
  border: 1px solid var(--hair);
}
.badge.ok     { background: var(--ok-wash);     color: var(--ok);     border-color: rgba(61,106,79,0.25); }
.badge.warn   { background: var(--warn-wash);   color: var(--warn);   border-color: rgba(165,111,40,0.3); }
.badge.danger { background: var(--danger-wash); color: var(--danger); border-color: rgba(164,67,43,0.3); }
.badge.accent { background: var(--accent-wash); color: var(--accent-ink); border-color: rgba(180,95,61,0.3); }

.kicker {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--ink-soft);
}

/* ─── Form fields ──────────────────────────────────────────── */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.field label {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-soft);
}

.input-underline {
  background: transparent;
  border: none;
  border-bottom: 1.5px solid var(--hair-strong);
  border-radius: 0;
  padding: 8px 2px;
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--ink);
  outline: none;
  transition: border-color 0.18s;
}
.input-underline::placeholder { color: var(--ink-muted); }
.input-underline:focus { border-bottom-color: var(--accent-ink); }

/* ─── Cards ────────────────────────────────────────────────── */
.card {
  background: var(--card);
  border: 1px solid var(--hair);
  border-radius: 18px;
  padding: 20px 24px;
  box-shadow: 0 1px 2px rgba(30,25,15,0.04), 0 26px 50px -34px rgba(30,25,15,0.22);
}
.card-inset {
  background: var(--paper-2);
  border: 1px solid var(--hair);
  border-radius: 14px;
  padding: 16px 20px;
}
.card h3,
.card-inset h3 {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--ink);
  margin: 0 0 12px;
}

/* ─── Tables ───────────────────────────────────────────────── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-body);
}
.data-table thead th {
  text-align: left;
  padding: 10px 12px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-soft);
  border-bottom: 1px solid var(--hair-strong);
  background: transparent;
}
.data-table tbody td {
  padding: 14px 12px;
  font-size: 14px;
  color: var(--ink);
  border-bottom: 1px solid var(--hair);
  vertical-align: middle;
}
.data-table tbody tr:hover { background: var(--paper-2); }
.data-table tbody tr:last-child td { border-bottom: none; }

/* ─── Skeleton shimmer ────────────────────────────────────── */
@keyframes shimmer {
  0% { background-position: -400px 0; }
  100% { background-position: 400px 0; }
}
.skeleton {
  background: linear-gradient(90deg, var(--paper-2) 25%, #eee4ce 50%, var(--paper-2) 75%);
  background-size: 400px 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 8px;
}
.skeleton-card { height: 52px; margin-bottom: 8px; border-radius: 10px; }
.skeleton-stat { height: 80px; border-radius: 10px; }
.skeleton-row  { height: 16px; margin-bottom: 8px; width: 80%; }

/* ─── Error banner ────────────────────────────────────────── */
.error-banner {
  background: var(--danger-wash);
  border: 1px solid rgba(164,67,43,0.35);
  border-radius: 10px;
  padding: 12px 16px;
  margin-bottom: 16px;
  display: none;
  justify-content: space-between;
  align-items: center;
  font-size: 14px;
  color: var(--danger);
}
.error-banner.visible { display: flex; }
.error-banner button {
  padding: 5px 14px;
  background: var(--card);
  border: 1px solid rgba(164,67,43,0.3);
  border-radius: 999px;
  color: var(--danger);
  cursor: pointer;
  font-size: 12px;
  font-family: var(--font-body);
}
.error-banner button:hover { background: var(--danger-wash); }

/* ─── Empty states ────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 64px 24px;
  color: var(--ink-soft);
  font-family: var(--font-body);
}
.empty-state .empty-display {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 400;
  letter-spacing: -0.015em;
  color: var(--ink);
  margin-bottom: 8px;
}
.empty-state .empty-sub {
  font-size: 14px;
  color: var(--ink-soft);
  max-width: 420px;
  margin: 0 auto 20px;
}
.empty-state .empty-action {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
  padding: 10px 20px;
  background: var(--ink);
  color: var(--paper);
  border: none;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font-body);
  cursor: pointer;
  text-decoration: none;
  box-shadow: var(--shadow-sm);
  transition: transform 0.18s, box-shadow 0.18s;
}
.empty-state .empty-action:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}
.empty-state .empty-action::after { content: "\2192"; transition: transform 0.18s; }
.empty-state .empty-action:hover::after { transform: translateX(2px); }

/* ─── Status indicators ───────────────────────────────────── */
.status-indicator {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  margin-right: 6px;
  background: var(--ink-muted);
}
.status-indicator.active { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-wash); }
.status-indicator.paused { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-wash); }
.status-indicator.not_started { background: var(--ink-muted); }

/* ─── Live Strategy Dashboard (P1-4) ────────────────────────
   Full-width stacked sections per D-4 (no 3-column card grid at the
   top level). Tokens only: no new :root entries. */

.strategy-panel {
  padding: 28px 0 24px;
  border-bottom: 1px solid var(--hair);
}
.strategy-panel:first-of-type { padding-top: 8px; }
.strategy-panel:last-of-type  { border-bottom: none; padding-bottom: 8px; }

.strategy-panel-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 18px;
}
.strategy-panel-title {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 500;
  letter-spacing: -0.015em;
  color: var(--ink);
  margin: 4px 0 0;
  line-height: 1.2;
}

/* Panel 1 — Current Strategy */
.strategy-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px 28px;
}
.strategy-cell {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}
.strategy-cell-label {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-soft);
}
.strategy-cell-value {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  color: var(--ink);
}

/* Panel 2 — Lead Pipeline */
.pipeline-stat-row {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
}
.pipeline-stat {
  background: var(--paper-2);
  border: 1px solid var(--hair);
  border-radius: 12px;
  padding: 18px 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.pipeline-stat-value {
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 500;
  letter-spacing: -0.02em;
  color: var(--ink);
  line-height: 1;
}
.pipeline-stat-label {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-soft);
}

/* Panel 3 — Per-Region table */
.strategy-region-table th.num,
.strategy-region-table td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.strategy-region-note {
  margin-top: 10px;
  font-size: 12px;
}

/* Panel 4 — Amendment history (collapsed by default) */
.strategy-amendments-toggle {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0;
  background: transparent;
  border: none;
  text-align: left;
  cursor: pointer;
  color: inherit;
  font-family: inherit;
}
.strategy-amendments-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
  border-radius: 4px;
}
.strategy-amendments-caret {
  width: 10px;
  height: 10px;
  border-right: 1.5px solid var(--ink-soft);
  border-bottom: 1.5px solid var(--ink-soft);
  transform: rotate(45deg);
  margin-right: 8px;
  transition: transform 0.18s ease;
}
.strategy-amendments-toggle[aria-expanded="true"] .strategy-amendments-caret {
  transform: rotate(-135deg);
}
.strategy-amend-count {
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--ink-soft);
  font-weight: 400;
  margin-left: 4px;
}
.strategy-amendments-body {
  padding-top: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.strategy-amendments-body[hidden] { display: none; }
.strategy-amend-row {
  border-left: 2px solid var(--hair-strong);
  padding: 4px 0 4px 14px;
}
.strategy-amend-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}
.strategy-amend-title {
  font-size: 14px;
  color: var(--ink);
  font-weight: 500;
}
.strategy-amend-summary {
  font-size: 13px;
  color: var(--ink-soft);
  line-height: 1.5;
  margin-top: 2px;
}
.strategy-amend-items {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
  align-items: center;
}

/* Responsive — D-6: tablet 2-col, mobile full-stack. */
@media (max-width: 960px) {
  .strategy-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pipeline-stat-row { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .strategy-grid { grid-template-columns: 1fr; }
  .pipeline-stat-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pipeline-stat-value { font-size: 26px; }
  .strategy-panel-title { font-size: 19px; }
}

/* ─── Utility ─────────────────────────────────────────────── */
.hairline { background: var(--hair); height: 1px; border: none; margin: 16px 0; }
.mono { font-family: var(--font-mono); }
.display { font-family: var(--font-display); font-weight: 500; letter-spacing: -0.01em; }
.muted-text { color: var(--ink-soft); }
.accent-text { color: var(--accent-ink); }

/* ─── Store-type display helpers (Lane A 2026-04-22) ────────── */
/* Small caption under store-type chip rows on Strategy Summary + Active
   Targeting. Signals that the dashboard values are the same ones the
   backend pipeline uses, and points the user at the Edit strategy flow. */
.store-types-hint {
  margin-top: 6px;
  font-size: 11px;
  color: var(--ink-soft);
  font-family: var(--font-body);
  line-height: 1.4;
}

/* Inline note on the Brand Profile card when store_types are still the
   Stage-A inference and haven't been user-confirmed. Warm amber, subtle. */
.store-types-inferred-badge {
  display: inline-block;
  margin: 4px 0 8px;
  padding: 4px 10px;
  font-size: 11px;
  font-family: var(--font-body);
  line-height: 1.4;
  color: var(--warn);
  background: var(--warn-wash);
  border: 1px solid rgba(165, 111, 40, 0.3);
  border-radius: 6px;
}

/* ─── Responsive ──────────────────────────────────────────── */
@media (max-width: 768px) {
  .header { padding: 14px 18px; gap: 14px; flex-wrap: wrap; }
  .header .brand-title { padding-left: 0; border-left: none; }
  .content { padding: 20px 16px; }
  .tabs { padding: 0 16px; }
  .tab-btn { padding: 12px 12px 10px; font-size: 12px; }
}

/* ============================================================
   FF6 — TipTap WYSIWYG editor (templates page)
   Scoped via .tt-editor wrapper; uses portal design tokens so
   dark mode + brand themes inherit for free. Per FF6 design
   review Pass 5 (token alignment).
   ============================================================ */

.tt-editor {
  border: 1px solid var(--hair);
  border-radius: 6px;
  background: var(--card);
  overflow: hidden;
}

.tt-editor--signature .tt-toolbar {
  background: color-mix(in srgb, var(--accent) 4%, var(--paper));
}

.tt-toolbar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 8px;
  background: var(--paper-2);
  border-top: 1px solid var(--hair);
  flex-wrap: wrap;
}

.tt-sep {
  display: inline-block;
  width: 1px;
  height: 18px;
  background: var(--hair);
  margin: 0 4px;
}

.tt-btn {
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  padding: 4px 10px;
  border-radius: 3px;
  cursor: pointer;
  font-size: 13px;
  color: var(--ink);
  font-family: var(--font-body);
  min-width: 32px;
  text-align: center;
}
.tt-btn:hover { background: var(--card); border-color: var(--hair); }
/* FF6 follow-up (2026-04-30 PM): image-resize buttons (S/M/L/Full) are
   disabled when no image is selected — visual cue prevents users
   clicking them on text and wondering why nothing happens. */
.tt-btn--disabled {
  opacity: 0.35;
  pointer-events: none;
  cursor: not-allowed;
}
.tt-btn--active {
  background: color-mix(in srgb, var(--accent) 12%, var(--card));
  color: var(--accent-ink);
  border-color: color-mix(in srgb, var(--accent) 30%, transparent);
}
/* FF6 follow-up: visualise the currently-selected image with an
   accent ring. TipTap auto-adds .ProseMirror-selectednode when the
   image node is selected (cursor on it). */
.tt-content .ProseMirror img.ProseMirror-selectednode {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.tt-content {
  padding: 14px 16px;
  min-height: 200px;
  max-height: 600px;
  overflow-y: auto;
}

.tt-editor--signature .tt-content { min-height: 140px; }

.tt-content .ProseMirror {
  outline: none;
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.6;
  color: var(--ink);
}
.tt-content .ProseMirror:focus { outline: none; }
.tt-content .ProseMirror p { margin: 0 0 12px; }
.tt-content .ProseMirror p:last-child { margin-bottom: 0; }
/* The global `* { padding:0 }` reset strips list indent, so markers hug the
   left edge in the editor. Restore it here — scoped to the editable region only,
   so it never reaches the sent email (assembled server-side with inline styles). */
.tt-content .ProseMirror ul,
.tt-content .ProseMirror ol { padding-left: 24px; margin: 0 0 12px; }
.tt-content .ProseMirror li { margin: 0 0 4px; }
.tt-content .ProseMirror li:last-child { margin-bottom: 0; }
.tt-content .ProseMirror a {
  color: var(--accent-ink);
  text-decoration: underline;
}
.tt-content .ProseMirror img.tt-img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 8px 0;
  border-radius: 4px;
}
@keyframes img-pulse { 0%,100% { opacity:0.4; } 50% { opacity:0.15; } }
img[data-uploading] { animation: img-pulse 1.2s ease-in-out infinite; background: var(--paper-2, #f5f5f5); }
.img-upload-error { display:inline-flex; gap:6px; padding:4px 8px; background:#fef2f2; border:1px solid #fca5a5; border-radius:4px; font-size:12px; color:#dc2626; }
.img-upload-error button { background:none; border:none; cursor:pointer; color:#dc2626; padding:0; font-size:14px; line-height:1; }
.tt-content .ProseMirror table {
  border-collapse: collapse;
  margin: 8px 0;
}
.tt-content .ProseMirror td,
.tt-content .ProseMirror th {
  border: 1px solid var(--hair);
  padding: 6px 10px;
  vertical-align: top;
}
/* Signature editor: borderless tables so two-column layouts render
   like the actual email (no cell borders as editing affordance). */
.tt-editor--signature .tt-content .ProseMirror table {
  margin: 4px 0;
}
.tt-editor--signature .tt-content .ProseMirror td,
.tt-editor--signature .tt-content .ProseMirror th {
  border: none;
  padding: 4px 8px;
  vertical-align: middle;
}

/* FF6 variable pill — accent-tinted background, monospace token text.
   Sanitizer allowlists `class` + `data-variable` on span so the round-
   trip survives bleach. _interpolate_template_body substitutes the
   literal `{{owner_greeting}}` text on send. */
.var-pill {
  background: color-mix(in srgb, var(--accent) 12%, var(--card));
  color: var(--accent-ink);
  font-family: var(--font-mono, ui-monospace, "SF Mono", monospace);
  font-size: 13px;
  padding: 1px 6px;
  border-radius: 3px;
  display: inline-block;
}

/* Didactic placeholder pill — preview-only marker for tokens that get
   filled in at send time (per-lead opener, seasonal hook). Mustard
   tones from the warn-* semantic palette read as "pending fill-in"
   without breaking the portal's warm-cream + terracotta aesthetic.
   Italic distinguishes from .var-pill (monospace) at a glance. */
.placeholder-pill {
  background: var(--warn-wash);
  color: var(--warn);
  padding: 1px 6px;
  border-radius: 3px;
  font-style: italic;
  font-size: 0.95em;
}

/* Preview-mode attachment chip — Edit UI chips at templates.html:707+
   show a remove × and a mode dropdown (interactive). Preview reuses the
   same visual but is display-only, so no hover affordance and no
   pointer cursor. */
.attachment-chip.preview-readonly {
  cursor: default;
}
.attachment-chip.preview-readonly:hover {
  background: inherit;
}

/* HTML-source toggle textarea (toolbar </> button) */
.tt-source {
  display: block;
  width: 100%;
  border: none;
  padding: 14px 16px;
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 12px;
  line-height: 1.5;
  background: var(--paper-2);
  color: var(--ink);
  min-height: 200px;
  resize: vertical;
  outline: none;
}

/* Mobile bubble menu — only visible on small viewports per BubbleMenu's
   shouldShow() check in email-editor.js. */
.tt-bubble {
  background: var(--ink);
  color: var(--card);
  border-radius: 6px;
  padding: 4px;
  display: flex;
  gap: 2px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.18);
}
.tt-bubble-btn {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--card);
  padding: 4px 8px;
  border-radius: 3px;
  cursor: pointer;
  font-size: 13px;
}
.tt-bubble-btn:hover { background: rgba(255, 255, 255, 0.12); }

/* Save status pill — atop each editor card; shows Unsaved/Saving/Saved. */
.save-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-family: var(--font-body);
  border: 1px solid var(--hair);
  background: var(--paper-2);
  color: var(--ink-soft);
}
.save-pill--saving { background: var(--warn-wash); color: var(--warn); border-color: rgba(165, 111, 40, 0.3); }
.save-pill--saved { background: color-mix(in srgb, #2e7d5b 10%, white); color: #2e7d5b; border-color: rgba(46, 125, 91, 0.25); }
.save-pill::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ink-muted);
}
.save-pill--saving::before { background: var(--warn); animation: save-pulse 1.2s ease-in-out infinite; }
.save-pill--saved::before { background: #2e7d5b; }
@keyframes save-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* CDN-failure fallback notice — yellow banner above the editor. */
.tt-cdn-fallback {
  margin: 0 0 8px;
  padding: 10px 14px;
  background: var(--warn-wash);
  color: var(--warn);
  border: 1px solid rgba(165, 111, 40, 0.35);
  border-radius: 6px;
  font-size: 12px;
  font-family: var(--font-body);
}

/* Brand-kit sidebar intent dropdown on each asset card. */
.bk-file-intent {
  margin-top: 4px;
  width: 100%;
  font-size: 11px;
  font-family: var(--font-body);
  padding: 2px 6px;
  border: 1px solid var(--hair);
  border-radius: 3px;
  background: var(--card);
  color: var(--ink);
  cursor: pointer;
}

/* ── Sequence Performance block (.sp) ──────────────────────────────────────
   Pinned at the top of the Sequences tab. Collapsed by default; headline
   tiles + A/B banner always visible. Operator clicks inline action to reveal
   the compare table + per-touch funnel.
   ──────────────────────────────────────────────────────────────────────── */

.sp {
  background: var(--card);
  border: 1px solid var(--hair);
  border-radius: 14px;
  box-shadow: var(--shadow-sm);
  padding: 24px 28px;
  margin-bottom: 20px;
}

.sp-head {
  margin-bottom: 20px;
  display: flex;
  align-items: baseline;
  gap: 14px;
  flex-wrap: wrap;
}

.sp-freshness {
  font-family: var(--font-body);
  font-size: 12px;
  color: var(--ink-muted);
}

.sp-head h3 {
  font-family: var(--font-display);
  font-size: 22px;
  letter-spacing: -0.01em;
  text-transform: none;
  color: var(--ink);
  font-weight: 500;
}

/* Headline stat tiles — always visible */
.sp-stats {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.sp-stat {
  background: var(--paper);
  border: 1px solid var(--hair);
  border-radius: 10px;
  padding: 16px 18px;
}

.sp-stat .value {
  font-family: var(--font-display);
  font-size: 36px;
  font-weight: 500;
  line-height: 1;
  color: var(--ink);
  letter-spacing: -0.02em;
  margin-bottom: 8px;
  font-variant-numeric: tabular-nums;
}

.sp-stat.positive .value { color: var(--ok); }

.sp-stat .label {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-bottom: 4px;
}

.sp-stat .sub {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--ink-muted);
}

/* Three hero tiles (Delivered / Reply rate / Positive replies) */
.sp-stats.sp-hero {
  grid-template-columns: repeat(3, 1fr);
}

/* Supporting metrics grouped under the heroes — Reach / Engagement / Responses.
   Quiet typographic lists, not equal-weight cards, so the heroes carry the eye. */
.sp-support {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px 24px;
  margin-bottom: 20px;
}

.sp-support-grp {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-muted);
  margin: 4px 0 2px;
}

.sp-support ul { list-style: none; margin: 0; padding: 0; }

.sp-support li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 7px 0;
  border-top: 1px solid var(--hair);
  font-size: 13px;
}

.sp-support li .k { color: var(--ink-soft); }

.sp-support li .v {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink);
  white-space: nowrap;
}

.sp-support li.dim .k,
.sp-support li.dim .v { color: var(--ink-muted); }

.sp-support li.sp-clickable { cursor: pointer; }
.sp-support li.sp-clickable:hover .k { color: var(--accent-ink); }
.sp-support li.sp-clickable:hover .v { color: var(--accent-ink); }

/* Glossary — one canonical definitions surface for the metric labels */
.sp-glossary {
  margin-left: auto;
  font-family: var(--font-body);
  font-size: 12px;
  color: var(--accent-ink);
  text-decoration: none;
  border-bottom: 1px solid var(--accent-wash);
}
.sp-glossary:hover { border-bottom-color: var(--accent-ink); }

.glossary-overlay {
  position: fixed;
  inset: 0;
  background: rgba(31, 42, 47, 0.45);
  display: none;
  align-items: flex-start;
  justify-content: center;
  z-index: 1000;
  padding: 8vh 16px;
}
.glossary-card {
  background: var(--card);
  border: 1px solid var(--hair);
  border-radius: 14px;
  max-width: 520px;
  width: 100%;
  padding: 22px 26px 26px;
  box-shadow: var(--shadow-md);
  max-height: 80vh;
  overflow: auto;
}
.glossary-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 6px;
}
.glossary-head h3 {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 500;
  margin: 0;
  color: var(--ink);
}
.glossary-close {
  background: none;
  border: none;
  font-size: 24px;
  line-height: 1;
  color: var(--ink-muted);
  cursor: pointer;
  padding: 0 4px;
}
.glossary-card dl { margin: 0; }
.glossary-card dt {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink);
  margin-top: 16px;
}
.glossary-card dd {
  margin: 4px 0 0;
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--ink-soft);
}

@media (max-width: 760px) {
  .sp-support { grid-template-columns: 1fr; }
}

/* A/B banner — always visible when ab_enabled; inline action lives here */
.sp-ab-banner {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  background: var(--accent-wash);
  border-radius: 8px;
  border: 1px solid #ecd9cc;
}

.sp-ab-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent-ink);
  font-weight: 500;
}

.sp-fw-chip {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-ink);
  background: rgba(255,255,255,0.7);
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid #ecd9cc;
}

.sp-fw-chip .arm {
  color: var(--accent-ink);
  font-weight: 600;
  margin-right: 6px;
}

/* Inline toggle action — one element, lives inside banner or in action-bar */
.sp-action {
  margin-left: auto;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  color: var(--accent-ink);
  background: transparent;
  border: none;
  border-bottom: 1px solid transparent;
  padding: 10px 4px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  line-height: 1.2;
  min-height: 44px;
}

.sp-action:hover { border-bottom-color: var(--accent-ink); color: var(--accent-ink); }
.sp-action:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 2px; }

/* Standalone action bar — used when there's no A/B banner */
.sp-action-bar {
  display: flex;
  justify-content: flex-end;
  padding: 2px 0 0;
}

/* Detail section — toggled by .sp.collapsed */
.sp.collapsed .sp-detail { display: none; }

.sp-detail { margin-top: 22px; }

/* Compare table (A vs B outcomes) */
.sp-compare {
  width: 100%;
  border-collapse: collapse;
  background: var(--paper);
  border: 1px solid var(--hair);
  border-radius: 10px;
  overflow: hidden;
}

.sp-compare thead th {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-muted);
  font-weight: 500;
  text-align: right;
  padding: 10px 16px 8px;
  background: var(--paper-2);
  border-bottom: 1px solid var(--hair-strong);
}

.sp-compare thead th:first-child { text-align: left; }

.sp-compare tbody td {
  padding: 13px 16px;
  font-size: 15px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  border-top: 1px solid var(--hair);
  color: var(--ink);
}

.sp-compare tbody tr:first-child td { border-top: none; }

.sp-compare tbody td:first-child {
  text-align: left;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--ink-soft);
  font-weight: 500;
}

.sp-compare .arm-letter {
  color: var(--accent-ink);
  font-weight: 700;
  margin-right: 10px;
  font-size: 13px;
  font-family: var(--font-display);
}

.sp-compare td.sp-pos { color: var(--ok); font-weight: 600; }
.sp-compare td.sp-pos.zero { color: var(--ink-muted); font-weight: 400; }

/* Funnel table (per-touch opens/clicks) */
.sp-funnel {
  width: 100%;
  border-collapse: collapse;
  margin-top: 28px;
}

.sp-funnel thead th {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-muted);
  font-weight: 500;
  text-align: left;
  padding: 10px 14px 8px;
  border-bottom: 1px solid var(--hair-strong);
}

.sp-funnel thead th.num { text-align: right; }

.sp-funnel tbody td {
  font-size: 14px;
  color: var(--ink);
  padding: 11px 14px;
  border-bottom: 1px solid var(--hair);
}

.sp-funnel tbody td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.sp-funnel tbody td.sp-touch-label {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 500;
  vertical-align: middle;
}

/* A/B sub-rows — lighter border between paired rows */
.sp-funnel tbody tr.sp-ab-row td {
  padding-top: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid #f0e8d4;
}

.sp-funnel tbody tr.sp-ab-row.sp-last-pair td {
  border-bottom: 1px solid var(--hair);
}

.sp-funnel .sp-fw-cell {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--ink-soft);
  padding-left: 14px;
  position: relative;
}

.sp-funnel .sp-fw-cell::before {
  content: "";
  position: absolute;
  left: 2px;
  top: 50%;
  width: 8px;
  height: 1px;
  background: var(--hair-strong);
}

.sp-funnel .sp-fw-cell .sp-fw-letter {
  display: inline-block;
  color: var(--accent-ink);
  font-weight: 600;
  margin-right: 8px;
  font-size: 11px;
  letter-spacing: 0.12em;
}

/* Rate cell: number + thin bar below */
.sp-rate-cell {
  text-align: right;
  font-variant-numeric: tabular-nums;
  min-width: 110px;
}

.sp-rate-cell .sp-rate-num { display: inline-block; margin-bottom: 5px; }

.sp-rate-cell .sp-rate-bar {
  height: 3px;
  background: var(--paper-2);
  border-radius: 2px;
  overflow: hidden;
  position: relative;
}

.sp-rate-cell .sp-rate-fill {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  background: var(--accent);
  border-radius: 2px;
}

/* Totals row */
.sp-funnel tfoot td {
  font-size: 13px;
  padding: 13px 14px;
  border-top: 1px solid var(--hair-strong);
  font-weight: 500;
  background: var(--paper-2);
  font-variant-numeric: tabular-nums;
}

.sp-funnel tfoot td.num { text-align: right; }

.sp-funnel .sp-total-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-muted);
  font-weight: 500;
}

/* Footnote */
.sp-footnote {
  font-size: 12px;
  color: var(--ink-muted);
  margin-top: 14px;
  line-height: 1.6;
}

/* Empty state (no sends yet) */
.sp-empty-inner {
  text-align: center;
  padding: 40px 24px;
}

.sp-empty-inner .sp-empty-title {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 500;
  color: var(--ink);
  margin-bottom: 6px;
}

.sp-empty-inner .sp-empty-sub {
  color: var(--ink-soft);
  font-size: 14px;
  max-width: 380px;
  margin: 0 auto 16px;
  line-height: 1.5;
}

.sp-empty-inner .sp-empty-cta {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  background: var(--ink);
  color: white;
  border: none;
  padding: 10px 18px;
  border-radius: 999px;
  cursor: pointer;
}

@media (max-width: 900px) {
  .sp-stats { grid-template-columns: repeat(2, 1fr); }
  .sp { padding: 18px 16px; }
  .sp-ab-banner { flex-wrap: wrap; }
  .sp-action { margin-left: 0; }
}

/* ── Keyboard focus is an invariant (a11y pass 2026-07-05) ─────────────
   25 scattered `outline: none` declarations left keyboard users with no
   visible focus on most controls. This rule wins over all of them by
   design — focus visibility must never lose to component styling. */
a:focus-visible, button:focus-visible, input:focus-visible,
select:focus-visible, textarea:focus-visible,
[role="button"]:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--accent) !important;
  outline-offset: 2px;
}
