/* MPG Portal — Apple palette, demand-transparency aesthetic
   Calibrated against DESIGN.md (Apple Style Reference).
   Card surfaces use background-shift separation (Canvas White page, Pure White cards),
   no decorative borders, 0px card radius per spec. */
:root {
  --text:        #1d1d1f;  /* Midnight Graphite — primary text */
  --text-muted:  #6e6e73;  /* Medium Gray — secondary text */
  --text-light:  #6e6e73;  /* WCAG AA fix: was #86868b which fails contrast on body text */
  --accent:      #0071e3;  /* Interactive Blue — buttons + focus rings */
  --accent-link: #0066cc;  /* Action Blue — link text (slightly darker per spec) */
  --accent-dim:  #0077ed;  /* hover state */
  --bg:          #ffffff;  /* Pure White — elevated card surfaces */
  --bg-soft:     #f5f5f7;  /* Canvas White — page background (per spec) */
  --bg-fill:     #f5f5f7;  /* Canvas White — secondary fills */
  --bg-recess:   #e2e2e5;  /* Lightest Gray Background — recessed inputs/inset */
  --border:      #d6d6d6;  /* Border Silver — thin separators only (per spec) */
  --border-soft: #e2e2e5;  /* lighter divider (was --border) */
  --success:     #34c759;
  --warn:        #ff9500;
  --danger:      #ff3b30;

  /* FM stage colors — admin-only; the doctrine forbids FM in client view */
  --fm1: #5856d6;  /* category entry */
  --fm2: #af52de;  /* trust */
  --fm3: #ff9500;  /* comparison */
  --fm4: #ff3b30;  /* action */

  /* Apple spec: cards 0px, images 8px, buttons 980px pill */
  --radius: 0px;       /* cards — was 12px; Apple uses square cards */
  --radius-sm: 8px;    /* images, inputs */
  --radius-pill: 980px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, sans-serif;
  font-size: 15px; line-height: 1.5;
  color: var(--text); background: var(--bg-soft);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.container { max-width: 1100px; margin: 0 auto; padding: 56px 28px; }
.container.narrow { max-width: 480px; }
.container.wide { max-width: 1280px; }

.brand { margin-bottom: 32px; }
.kicker { font-size: 12px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-muted); margin: 0 0 6px; }
/* Headings — calibrated to DESIGN.md (Apple Style Reference).
   h1 → display-xl: 34px / 1.0 leading / tight tracking. The 'numr' OpenType
   feature aligns numerals to a grid so numbers in headlines feel intentional. */
h1 {
  font-size: 34px;
  font-weight: 600;
  line-height: 1.0;
  letter-spacing: -0.01em;
  margin: 0;
  color: var(--text);
  font-feature-settings: "ss01", "ss02";  /* SF Pro stylistic alternates when available */
  font-variant-numeric: tabular-nums;
}

/* Archive dropdown — Phase 10.4. Native <details> styled as a button + popover. */
.archive-menu { position: relative; }
.archive-menu summary {
  list-style: none;
  user-select: none;
}
.archive-menu summary::-webkit-details-marker { display: none; }
.archive-menu summary::marker { content: ''; }
.archive-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 280px;
  max-height: 360px;
  overflow-y: auto;
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 8px 0;
  z-index: 100;
  box-shadow: 0 8px 24px rgba(0,0,0,0.08);
}
.archive-item {
  display: block;
  padding: 10px 18px;
  color: var(--text);
  text-decoration: none;
  font-size: 14px;
  line-height: 1.4;
}
.archive-item:hover { background: var(--bg-fill); text-decoration: none; }
.archive-item .archive-item-issue {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.archive-item .archive-item-date {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}
.archive-item.current { background: var(--bg-fill); }
.archive-item.current::after {
  content: 'current';
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-left: 8px;
  font-weight: 600;
}

/* Banner shown when viewing a past read. Phase 10.4. */
.archive-banner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  padding: 14px 20px;
  background: var(--bg);
  margin-bottom: 20px;
  font-size: 14px;
}
.archive-banner .archive-banner-text { color: var(--text); }
.archive-banner .archive-banner-text strong { font-variant-numeric: tabular-nums; }
.archive-banner a {
  color: var(--accent-link, var(--accent));
  font-weight: 500;
  white-space: nowrap;
  text-decoration: none;
}
.archive-banner a:hover { text-decoration: underline; }

/* Issue meta — editorial framing under the client name. Phase 10.1.
   "Read No. 23 · Week of May 19, 2026" — turns each visit into an artifact, not a refresh. */
.issue-meta {
  margin: 8px 0 0;
  font-size: 13px;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}
.issue-meta .issue-number {
  font-weight: 600;
  color: var(--text);
}
.issue-meta .issue-sep {
  margin: 0 8px;
  color: var(--border);
}
/* h2 → heading-sm: 24px / 1.33 / -0.24px tracking */
h2 {
  font-size: 24px;
  font-weight: 600;
  line-height: 1.33;
  letter-spacing: -0.012em;
  margin: 0 0 16px;
  color: var(--text);
}
/* h3 → subheading: 18px / 1.24 / -0.22px tracking */
h3 {
  font-size: 18px;
  font-weight: 600;
  line-height: 1.24;
  letter-spacing: -0.012em;
  margin: 0 0 12px;
  color: var(--text);
}

/* Card — Apple-strict: 0px radius, no border. Separation from page via
   background-shift only (Canvas White page → Pure White elevated card). */
.card {
  background: var(--bg);
  border: 0;
  border-radius: var(--radius);
  padding: 28px;
  margin-bottom: 20px;
}

.card.tight { padding: 20px; }
.card + .card { margin-top: 0; }

label { display: block; font-size: 13px; font-weight: 500; color: var(--text); margin: 14px 0 6px; }
input[type=text], input[type=email], input[type=password], textarea, select {
  width: 100%;
  font: inherit;
  padding: 10px 12px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 10px 18px;
  border: 1px solid var(--border-soft);
  border-radius: 980px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  margin-top: 14px;
  transition: background 0.15s, box-shadow 0.15s;
}
.btn:hover { background: var(--bg-fill); text-decoration: none; }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn.primary { background: var(--accent); color: white; border-color: var(--accent); }
.btn.primary:hover { background: var(--accent-dim); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--accent); padding: 10px 14px; min-height: 44px; }
.btn.small { padding: 8px 14px; font-size: 13px; min-height: 36px; }  /* dense UI exception — still tap-friendly */
.btn.danger { color: var(--danger); }

/* Skip link — visible only on keyboard focus. First focusable element on every page. */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--text);
  color: #ffffff;
  padding: 12px 18px;
  font-weight: 500;
  text-decoration: none;
  z-index: 200;
}
.skip-link:focus {
  left: 12px;
  top: 12px;
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.muted { color: var(--text-muted); }
.light { color: var(--text-light); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.mt-l { margin-top: 20px; }
.mt-s { margin-top: 8px; }
.hidden { display: none !important; }

.msg { padding: 10px 0; min-height: 22px; font-size: 13px; color: var(--text-muted); }
.msg[data-kind=error] { color: var(--danger); }
.msg[data-kind=success] { color: var(--success); }

.footer { margin-top: 64px; padding-top: 24px; border-top: 1px solid var(--border); text-align: center; }

/* ----- Demand Position indicator — top of every client view ----- */
.demand-position {
  background: linear-gradient(135deg, #fff 0%, #f5f5f7 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-bottom: 28px;
}
.demand-position .label { font-size: 11px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-muted); margin: 0 0 8px; }
.demand-position .fm-badge { display: inline-block; padding: 2px 10px; border-radius: 980px; font-size: 12px; font-weight: 600; color: #fff; margin-right: 8px; vertical-align: 2px; }
.fm-badge.fm1 { background: var(--fm1); }
.fm-badge.fm2 { background: var(--fm2); }
.fm-badge.fm3 { background: var(--fm3); }
.fm-badge.fm4 { background: var(--fm4); }
.demand-position .statement { font-size: 17px; font-weight: 500; color: var(--text); margin: 0; line-height: 1.4; }
.demand-position .meta { margin-top: 12px; font-size: 12px; color: var(--text-light); }

/* Section narratives — analyst voice prose that leads each section */
.narrative { margin: 0 0 8px; }
/* Narrative headline — sits inside a card after the h2 section title.
   Calibrated to DESIGN.md callout (21px) — the editorial lead of each section. */
.narrative-headline {
  font-size: 21px;
  font-weight: 600;
  line-height: 1.19;
  letter-spacing: -0.013em;
  color: var(--text);
  margin: 0 0 18px;
  font-variant-numeric: tabular-nums;
}

/* ───────────────────────────────────────────────────────────────────────────
   Phase 10.3 — Texture variety
   Per-section layouts replace the identical-card pattern. Each section's
   visual treatment matches its content's character.
   ─────────────────────────────────────────────────────────────────────────── */

/* where_you_are — Editorial cover. No card chrome; lives on the canvas.
   Display-size headline acts as the magazine cover for the read. */
#section-where_you_are {
  background: transparent;
  padding: 12px 0 48px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
#section-where_you_are .kicker {
  font-size: 11px;
  letter-spacing: 0.14em;
  margin-bottom: 16px;
}
#section-where_you_are .narrative-headline {
  font-size: 40px;
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -0.015em;
  margin: 0 0 28px;
  max-width: 22ch;
}
#section-where_you_are .narrative-body {
  font-size: 17px;
  line-height: 1.65;
  max-width: 62ch;
}
#section-where_you_are .narrative-body p { margin-bottom: 16px; }

/* Rating hero — App-Store-style numeric anchor for GBP + Reviews sections.
   Massive rating + star row + count caption. Built by JS via .rating-hero markup. */
.rating-hero {
  display: flex;
  align-items: baseline;
  gap: 24px;
  margin: 4px 0 28px;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--border);
}
.rating-hero .rating-number {
  font-size: 72px;
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.025em;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.rating-hero .rating-meta { flex: 1; min-width: 0; }
.rating-hero .rating-stars {
  font-size: 22px;
  color: #f5a623;
  letter-spacing: 2px;
  line-height: 1;
}
.rating-hero .rating-count {
  display: block;
  margin-top: 8px;
  font-size: 13px;
  color: var(--text-muted);
}

/* DVS score hero — AI Visibility section. Score (0–100) + profile band + scored-on date.
   Apple-strict: no card chrome, typography carries the weight. */
.score-hero {
  display: flex;
  align-items: baseline;
  gap: 24px;
  margin: 4px 0 28px;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--border);
}
.score-hero .score-number {
  font-size: 72px;
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.025em;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.score-hero .score-meta { flex: 1; min-width: 0; }
.score-hero .score-profile {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--text);
  text-transform: uppercase;
}
.score-hero .score-caption {
  display: block;
  margin-top: 6px;
  font-size: 13px;
  color: var(--text-muted);
}

/* DVS dimension rows — 4 dimensions stacked, each with score, bar, and top-gap caption */
.dim-stack { margin-top: 8px; }
.dim-row {
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}
.dim-row:last-child { border-bottom: 0; }
.dim-row-label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 8px;
}
.dim-row .dim-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
}
.dim-row .dim-score {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}
.dim-row .dim-max {
  color: var(--text-muted);
  font-weight: 400;
}
.dim-bar {
  height: 4px;
  background: var(--bg-recess);
  position: relative;
  overflow: hidden;
  margin-bottom: 8px;
}
.dim-bar-fill {
  position: absolute;
  inset: 0 auto 0 0;
  background: var(--text);
  transition: width 0.4s ease;
}
.dim-gap {
  margin: 4px 0 0;
  font-style: italic;
}

/* Generic metric hero — reused by custom_intent, paid_social, ga4, site_experience, pipeline.
   Same typographic pattern as rating-hero/score-hero/share-hero — big tabular number,
   caption block, border-bottom isolates from KPI grid below. */
.metric-hero {
  display: flex;
  align-items: baseline;
  gap: 24px;
  margin: 4px 0 28px;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.metric-hero .metric-number {
  font-size: 56px;
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.022em;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.metric-hero .metric-meta { flex: 1; min-width: 200px; }
.metric-hero .metric-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  color: var(--text-muted);
  text-transform: uppercase;
  margin: 0 0 6px;
}
.metric-hero .metric-caption {
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.4;
  margin: 0;
}
.metric-hero .metric-caption strong {
  color: var(--text);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* Email funnel viz — delivered → opens → clicks shown as 3 descending bars.
   Width proportional to count; widest = delivered, narrowest = clicks. */
.funnel {
  margin: 4px 0 24px;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--border);
}
.funnel-row {
  display: flex;
  align-items: baseline;
  gap: 14px;
  margin-bottom: 10px;
}
.funnel-row:last-child { margin-bottom: 0; }
.funnel-row .funnel-label {
  flex-shrink: 0;
  width: 90px;
  font-size: 13px;
  color: var(--text-muted);
}
.funnel-row .funnel-bar {
  flex: 1;
  height: 26px;
  background: var(--bg-recess);
  position: relative;
}
.funnel-row .funnel-fill {
  position: absolute;
  inset: 0 auto 0 0;
  background: var(--text);
  display: flex;
  align-items: center;
  padding: 0 12px;
  color: #ffffff;
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

/* Channel mix bar — ga4 visual, horizontal stacked bar showing relative session share */
.channel-mix {
  margin: 4px 0 22px;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--border);
}
.channel-mix-bar {
  display: flex;
  height: 28px;
  margin-bottom: 12px;
  overflow: hidden;
}
.channel-mix-seg {
  background: var(--text);
  border-right: 1px solid var(--bg);
}
.channel-mix-seg:nth-child(2) { background: #555; }
.channel-mix-seg:nth-child(3) { background: #888; }
.channel-mix-seg:nth-child(4) { background: #b0b0b0; }
.channel-mix-seg:nth-child(5) { background: var(--bg-recess); }
.channel-mix-seg:last-child { border-right: 0; }
.channel-mix-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  font-size: 12px;
  color: var(--text-muted);
}
.channel-mix-legend .legend-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 6px;
  vertical-align: middle;
}
.channel-mix-legend .legend-dot.s1 { background: var(--text); }
.channel-mix-legend .legend-dot.s2 { background: #555; }
.channel-mix-legend .legend-dot.s3 { background: #888; }
.channel-mix-legend .legend-dot.s4 { background: #b0b0b0; }
.channel-mix-legend .legend-dot.s5 { background: var(--bg-recess); }

/* Impression share hero — paid_search visual. Percentage + thin progress bar. */
.share-hero {
  margin: 4px 0 28px;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--border);
}
.share-hero .share-number {
  font-size: 48px;
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.02em;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  margin: 0 0 4px;
}
.share-hero .share-caption {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0 0 14px;
}
.share-hero .share-bar {
  height: 6px;
  background: var(--bg-recess);
  position: relative;
  overflow: hidden;
}
.share-hero .share-bar-fill {
  position: absolute;
  inset: 0 auto 0 0;
  background: var(--text);
  transition: width 0.4s ease;
}

/* Mobile: dial down the editorial cover so phones stay readable */
@media (max-width: 720px) {
  #section-where_you_are .narrative-headline { font-size: 30px; max-width: none; }
  #section-where_you_are .narrative-body { font-size: 16px; }
  .rating-hero { flex-direction: column; align-items: flex-start; gap: 8px; }
  .rating-hero .rating-number { font-size: 56px; }
  .share-hero .share-number { font-size: 40px; }
}
.narrative-body {
  font-size: 15.5px;
  line-height: 1.65;
  color: var(--text);
  margin: 0 0 14px;
}
.narrative-body p {
  margin: 0 0 14px;
  font-size: inherit;
  line-height: inherit;
  color: inherit;
}
.narrative-body p:last-child { margin-bottom: 0; }
.narrative-evidence {
  font-size: 12px;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
  padding: 10px 14px;
  background: var(--bg-fill);
  border-radius: 8px;
  margin: 4px 0;
  line-height: 1.5;
  color: var(--text-muted);
}

/* Knowledge Card — editorial pull-aside, not SaaS callout.
   No container, no border, no background. Typography carries the distinction:
   small caps label + italic body + small caps attribution. */
.knowledge-card {
  margin: 24px 0 8px;
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: 0;
}
.knowledge-card-header {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin: 0 0 8px;
}
.knowledge-card-body {
  font-size: 15px;
  font-style: italic;
  line-height: 1.55;
  color: var(--text);
  margin: 0 0 10px;
}
.knowledge-card-attribution {
  font-size: 10.5px;
  font-style: italic;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 0;
}

/* Evidence lists inside sections (top companies, top sources, top pages, etc.) */
.evidence-list {
  list-style: none;
  padding: 0;
  margin: 6px 0 0;
}
.evidence-list li {
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
}
.evidence-list li:last-child { border-bottom: 0; }

/* Review item — used in GBP section's recent reviews block */
.review-item {
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.review-item:last-child { border-bottom: 0; }
.review-stars {
  color: #f5a623;
  font-size: 14px;
  margin-bottom: 4px;
}
.review-text {
  font-size: 14px;
  line-height: 1.5;
  margin: 0 0 6px;
}
.review-meta { margin: 0; }
.review-list { margin-top: 6px; }

/* KPI subsections — each data source gets its own labeled group */
.kpi-group { margin-top: 22px; }
.kpi-group:first-of-type { margin-top: 4px; }
.kpi-group-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text);
  margin: 0 0 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.kpi-group-label .muted {
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: none;
  font-size: 12px;
}

/* ----- KPI tiles — both legacy .kpi (admin) and .kpi-tile (v3 dashboard) -----
   Apple-strict: no border, no radius. Nested inside cards (#ffffff) so we use
   --bg-recess (#e2e2e5) for background-shift separation. */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.kpi-grid--compact { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }

.kpi, .kpi-tile {
  background: var(--bg-recess);
  border: 0;
  border-radius: 0;
  padding: 16px 18px;
  position: relative;
}
.kpi .name, .kpi-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 0 0 6px;
}
/* KPI value — Apple's headline-lg with tabular numerals so columns of numbers
   read as a grid, not as ragged characters. The single most important type
   detail for a data dashboard. */
.kpi .value, .kpi-value {
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.012em;
  margin: 0 0 4px;
  color: var(--text);
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum", "ss01";
}
.kpi .delta, .kpi-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin: 0;
}
.kpi .sparkline { display: block; width: 100%; height: 30px; margin: 10px 0 4px; }
.kpi .baseline {
  font-size: 12px; font-weight: 500; margin: 6px 0 0; padding-top: 8px;
  border-top: 1px solid var(--border-soft); color: var(--text-muted);
}
.kpi .baseline.up { color: var(--success); }
.kpi .baseline.down { color: var(--danger); }
.kpi .interp { font-size: 13px; line-height: 1.45; color: var(--text); margin-top: 10px; }

/* ----- Pipeline (Source 9 — the funnel boundary) ----- */
.pipeline-summary {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px;
  margin-bottom: 24px;
}
.pipeline-summary .stat {
  background: var(--bg-recess); border: 0; border-radius: 0;
  padding: 16px;
}
.pipeline-summary .stat .num { font-size: 24px; font-weight: 600; color: var(--text); margin: 4px 0; }
.pipeline-summary .stat .lbl { font-size: 12px; color: var(--text-muted); }

.lead-table { width: 100%; border-collapse: collapse; }
.lead-table th, .lead-table td { padding: 12px 12px; text-align: left; font-size: 14px; border-bottom: 1px solid var(--border); }
.lead-table th { font-weight: 600; color: var(--text-muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; }
.lead-table select {
  font-size: 13px;
  padding: 10px 12px;
  min-height: 40px;  /* touch-friendly without dominating the row */
  border-radius: 6px;
}
.lead-table select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.status-pill { display: inline-block; padding: 2px 10px; border-radius: 980px; font-size: 12px; font-weight: 500; }
.status-pill.new { background: #f5f5f7; color: var(--text-muted); }
.status-pill.contacted { background: #e3f2fd; color: #0071e3; }
.status-pill.appointment_set { background: #e8f5e9; color: #2e7d32; }
.status-pill.closed { background: #f3e5f5; color: #6a1b9a; }
.status-pill.no_response { background: #ffebee; color: var(--danger); }

.stale-banner {
  background: #fff7e6; border: 1px solid #ffe082; border-radius: var(--radius);
  padding: 14px 18px; margin-bottom: 20px; font-size: 14px; color: #5d4037;
}

/* Skeleton loading placeholders — replace "Loading…" text with proper visual shapes */
@keyframes skeleton-shimmer {
  0% { background-position: -200px 0; }
  100% { background-position: 200px 0; }
}
.skeleton {
  display: inline-block;
  background: linear-gradient(90deg, #f0f0f3 25%, #e6e6ea 50%, #f0f0f3 75%);
  background-size: 400px 100%;
  border-radius: 4px;
  animation: skeleton-shimmer 1.4s ease-in-out infinite;
  vertical-align: middle;
}
.skeleton.text-line { height: 16px; width: 80%; }
.skeleton.text-line.short { width: 40%; }
.skeleton.text-line.medium { width: 60%; }
.skeleton.heading { height: 32px; width: 60%; }
.skeleton.kicker { height: 12px; width: 90px; }
.skeleton.box { height: 80px; width: 100%; display: block; margin: 8px 0; }
.skeleton.tile { height: 76px; width: 100%; display: block; border-radius: 0; }

/* Section nav — sticky horizontal strip below the header. Anchors to each rendered
   section. Apple-strict: no border, no radius, separation via background-shift. */
.section-nav {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--bg);
  margin: 0 0 20px;
  padding: 0;
}
.section-nav-inner {
  display: flex;
  gap: 0;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.section-nav-inner::-webkit-scrollbar { display: none; }
.section-nav-item {
  flex-shrink: 0;
  min-height: 44px;
  padding: 14px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  font-family: inherit;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.section-nav-item:hover { color: var(--text); }
.section-nav-item:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
  color: var(--text);
}
.section-nav-item.active {
  color: var(--text);
  font-weight: 600;
  border-bottom-color: var(--text);
}
/* Bring the active item into view when nav jumps (horizontal scroll on narrow widths) */
html { scroll-behavior: smooth; scroll-padding-top: 60px; }

/* Pipeline pairing rail — connects pipeline narrative card to its lead table.
   A small kicker above the table that echoes the relationship. */
.pipeline-pair-kicker {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: -8px 0 12px;
}

/* Progress narration — shown above skeleton stack during initial report generation */
.progress-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 20px;
  background: var(--bg);
  margin-bottom: 20px;
}
.progress-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: progress-spin 0.8s linear infinite;
  flex-shrink: 0;
}
@keyframes progress-spin {
  to { transform: rotate(360deg); }
}
.progress-text {
  font-size: 14px;
  color: var(--text);
  margin: 0;
  flex: 1;
}
.progress-stage {
  font-size: 12px;
  color: var(--text-muted);
  margin: 2px 0 0;
  transition: opacity 0.4s ease;
}

/* Skeleton card — matches the Apple-strict .card pattern. Used during loading. */
.skeleton-card {
  background: var(--bg);
  padding: 28px;
  margin-bottom: 20px;
}
.skeleton-card .skeleton + .skeleton { margin-top: 10px; }
.skeleton-card .skeleton-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-top: 20px;
}

/* Empty/Error state cards — same Apple aesthetic as real cards, dedicated structure */
.state-card {
  background: var(--bg);
  padding: 40px 36px;
  margin-bottom: 20px;
  text-align: left;
}
.state-card .state-headline {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
  margin: 0 0 14px;
  line-height: 1.3;
}
.state-card .state-body {
  font-size: 15.5px;
  line-height: 1.6;
  color: var(--text);
  margin: 0 0 22px;
  max-width: 60ch;
}
.state-card .state-body p { margin: 0 0 12px; }
.state-card .state-body p:last-child { margin: 0; }
.state-card .state-actions { margin-top: 4px; }

/* Connection status list — used in empty state */
.source-status-list {
  list-style: none;
  padding: 0;
  margin: 22px 0 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0;
  border-top: 1px solid var(--border);
}
.source-status-list li {
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.source-status-list .status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.source-status-list .status-dot.connected { background: var(--success); }
.source-status-list .status-dot.pending { background: var(--border); }
.source-status-list .source-name { color: var(--text); }
.source-status-list .source-detail { color: var(--text-muted); font-size: 12px; margin-left: auto; }

/* Intent recap — custom intent data section */
.intent-summary-line { font-size: 16px; line-height: 1.55; color: var(--text); margin: 8px 0 0; }
.intent-summary-line strong { color: var(--text); font-weight: 600; }

.intent-detail-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 24px;
  padding-top: 18px; border-top: 1px solid var(--border);
}
.intent-detail-title {
  font-size: 11px; font-weight: 700; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--text-muted); margin: 0 0 10px;
}
.intent-detail-list { list-style: none; padding: 0; margin: 0; }
.intent-detail-list li {
  display: flex; justify-content: space-between; padding: 6px 0;
  font-size: 14px; color: var(--text); border-bottom: 1px solid var(--border);
}
.intent-detail-list li:last-child { border-bottom: 0; }

.insight-quote {
  margin: 22px 0 0; padding: 18px 20px; font-size: 14px; line-height: 1.6;
  background: #fafaff; border-left: 3px solid var(--accent); border-radius: 0 8px 8px 0;
  color: var(--text);
}
.insight-quote em { color: var(--text); font-style: italic; }

/* FM education modal */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.4); backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center; z-index: 100;
  padding: 24px;
}
.modal {
  background: var(--bg); border-radius: 16px; padding: 40px 44px;
  max-width: 720px; width: 100%; max-height: 88vh; overflow-y: auto;
  position: relative;
}
.modal-close {
  position: absolute; top: 16px; right: 18px; background: none; border: none;
  font-size: 28px; color: var(--text-muted); cursor: pointer; line-height: 1;
}
.modal-close:hover { color: var(--text); }
.fm-deep-dive p { font-size: 15px; line-height: 1.65; margin: 0 0 14px; color: var(--text); }
.fm-citations {
  margin-top: 24px; padding-top: 18px; border-top: 1px solid var(--border);
}
.fm-citations ul { padding-left: 20px; margin: 6px 0 0; }
.fm-citations li { font-size: 13px; color: var(--text-muted); padding: 2px 0; }
.fm-client-voice {
  margin-top: 22px; padding: 14px 18px; font-style: italic; font-size: 15px;
  color: var(--text-muted); border-left: 3px solid var(--border-soft);
}

/* Preliminary banner — surfaces "baseline establishing" before client diagnosis is data-backed */
.preliminary-banner {
  background: #f0f7ff; border: 1px solid #b3d4ff; border-radius: var(--radius);
  padding: 16px 20px; margin-bottom: 20px;
}
.preliminary-banner-inner .kicker { margin: 0 0 4px; }
.preliminary-text { font-size: 14px; color: var(--text); margin: 0 0 6px; line-height: 1.5; }
.preliminary-tag {
  display: inline-block; padding: 2px 8px; border-radius: 6px;
  background: #f0f7ff; color: #0050b3; border: 1px solid #b3d4ff;
  font-size: 11px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase;
  margin-right: 8px; vertical-align: 2px;
}

/* ----- Admin layout ----- */
.admin-shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.admin-sidebar { background: var(--bg); border-right: 1px solid var(--border); padding: 28px 20px; }
.admin-sidebar .nav { display: flex; flex-direction: column; gap: 4px; margin-top: 24px; }
.admin-sidebar .nav a { padding: 8px 12px; border-radius: 8px; color: var(--text); font-size: 14px; }
.admin-sidebar .nav a:hover { background: var(--bg-fill); text-decoration: none; }
.admin-sidebar .nav a.active { background: var(--bg-fill); font-weight: 600; }
.admin-main { padding: 40px 48px; background: var(--bg-soft); }

.client-row {
  display: grid; grid-template-columns: 1fr auto auto auto; gap: 16px; align-items: center;
  padding: 14px 18px; border-bottom: 1px solid var(--border);
}
.client-row:last-child { border-bottom: 0; }
.client-row .name { font-weight: 500; }
.client-row .vertical { font-size: 12px; color: var(--text-muted); }

/* Enriched client row — admin overview */
.client-row-rich {
  display: grid;
  grid-template-columns: minmax(160px, 1.4fr) 60px minmax(200px, 1.8fr) minmax(140px, 1fr) auto;
  gap: 14px; align-items: center;
  padding: 14px 18px; border-bottom: 1px solid var(--border);
}
.client-row-rich:last-child { border-bottom: 0; }
.client-row-rich .name { font-weight: 500; font-size: 15px; }
.client-row-rich .cr-sources { display: flex; flex-wrap: wrap; gap: 4px; }

.source-badge {
  display: inline-block; padding: 2px 7px; border-radius: 4px;
  font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em;
  background: var(--bg-fill); color: var(--text);
}
.source-badge.source-ga4      { background: #ffeacc; color: #b75900; }
.source-badge.source-ads      { background: #d2e7ff; color: #0050b3; }
.source-badge.source-gsc      { background: #d6f5d6; color: #1a7f1a; }
.source-badge.source-gbp      { background: #e3f2fd; color: #0d6efd; }
.source-badge.source-meta     { background: #d4e3ff; color: #2a4ec5; }
.source-badge.source-audience { background: #f3e5f5; color: #6a1b9a; }
.source-badge.source-formspree{ background: #fff7e0; color: #8a6d0e; }
.source-badge.source-reviews  { background: #ffe4e1; color: #b21f1f; }

.draft-box {
  background: #f0f7ff; border: 1px solid #b3d4ff; border-radius: var(--radius);
  padding: 18px 20px; margin: 16px 0;
}
.draft-box .label { font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: #0050b3; margin: 0 0 6px; }
.draft-box .pattern-list { margin: 10px 0 0; padding-left: 20px; font-size: 13px; color: var(--text); }
.draft-box .pattern-list li { margin: 4px 0; }

@media (max-width: 720px) {
  /* Container padding — give phone screens breathing room */
  .container, .container.wide, .container.narrow { padding: 24px 16px; }
  .admin-main { padding: 24px 16px; }

  /* Admin sidebar collapses to a top bar */
  .admin-shell { grid-template-columns: 1fr; }
  .admin-sidebar { border-right: 0; border-bottom: 1px solid var(--border); padding: 16px; position: relative; }
  .admin-sidebar p.tiny { position: static !important; display: none; }
  .admin-sidebar .nav { flex-direction: row; flex-wrap: wrap; gap: 4px; margin-top: 12px; }
  .admin-sidebar .nav a { padding: 6px 10px; font-size: 13px; }

  /* Headers + spacing */
  h1 { font-size: 26px; }
  h2 { font-size: 19px; }
  .card { padding: 18px; }

  /* Pipeline summary: 2-col on mobile */
  .pipeline-summary { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .pipeline-summary .stat { padding: 12px; }
  .pipeline-summary .stat .num { font-size: 20px; }

  /* KPI grid — auto-fit already, but make tile min smaller */
  .kpi-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi { padding: 14px 16px; }
  .kpi .value { font-size: 22px; }

  /* Enriched client row collapses to stacked layout */
  .client-row-rich {
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 14px 16px;
  }
  .client-row-rich .cr-main, .client-row-rich .cr-fm, .client-row-rich .cr-sources, .client-row-rich .cr-meta {
    grid-column: 1;
  }
  .client-row-rich .cr-fm { margin-top: -6px; }

  /* Lead table: horizontal scroll */
  .lead-table { display: block; overflow-x: auto; white-space: nowrap; }

  /* Intent detail: stack columns on mobile */
  .intent-detail-grid { grid-template-columns: 1fr; gap: 16px; padding-top: 14px; }

  /* Modal: full width on mobile */
  .modal { padding: 28px 22px; border-radius: 12px; }
  .fm-deep-dive p { font-size: 14px; line-height: 1.55; }

  /* Demand position card */
  .demand-position { padding: 16px 18px; }
  .demand-position .statement { font-size: 15px; }

  /* Preliminary banner */
  .preliminary-banner { padding: 14px 16px; }
  .preliminary-text { font-size: 13px; }

  /* Insight quote inline */
  .insight-quote { padding: 14px 16px; font-size: 13px; }

  /* Status pills shrink */
  .status-pill, .fm-badge { font-size: 11px; padding: 2px 8px; }
  .source-badge { font-size: 9px; padding: 2px 6px; }
}

@media (max-width: 420px) {
  /* Single-column KPI grid on very narrow screens */
  .kpi-grid { grid-template-columns: 1fr; }
  .pipeline-summary { grid-template-columns: 1fr; }
  h1 { font-size: 22px; }
}
