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

/* =========================================================================
   NPS Command Center — Delighted-style clean light SaaS design system
   Accent (teal) is reserved for UI/brand actions.
   Promoter (green) / passive (amber) / detractor (red) are reserved for NPS.
   ========================================================================= */

:root {
  color-scheme: light;

  /* Canvas + surfaces */
  --bg: #f6f8fb;
  --bg-grad-top: #f6f8fb;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --surface-3: #eef2f6;

  /* Ink + text */
  --ink: #111827;
  --text: #374151;
  --muted: #667085;
  --faint: #98a2b3;

  /* Hairlines */
  --line: #e6eaf0;
  --line-strong: #d4dbe5;

  /* Brand accent — teal */
  /* Accent shades derive from --accent via color-mix, so a per-org theme color only needs
     to override --accent (set by applyWorkspaceAccent) and the whole app re-themes. */
  --accent: #0f766e;
  --accent-strong: color-mix(in srgb, var(--accent) 88%, #000);
  --accent-ink: color-mix(in srgb, var(--accent) 80%, #000);
  --accent-soft: color-mix(in srgb, var(--accent) 12%, #fff);
  --accent-soft-2: color-mix(in srgb, var(--accent) 22%, #fff);

  /* NPS buckets */
  --promoter: #15a05a;
  --promoter-soft: #e4f7ec;
  --passive: #e89611;
  --passive-soft: #fdf2dc;
  --detractor: #e4483b;
  --detractor-soft: #fde9e7;

  /* Accents for code / links */
  --blue: #2f6bed;

  /* Slack surface (intentionally dark — it mimics Slack) */
  --slack-bg: #1a1d21;
  --slack-bg-2: #222529;

  /* Shadows */
  --shadow-xs: 0 1px 2px rgba(17, 24, 39, 0.04);
  --shadow-sm: 0 1px 2px rgba(17, 24, 39, 0.05);
  --shadow:
    0 1px 2px rgba(17, 24, 39, 0.04),
    0 14px 30px -24px rgba(17, 24, 39, 0.28);
  --shadow-lg:
    0 1px 3px rgba(17, 24, 39, 0.06),
    0 24px 48px -28px rgba(17, 24, 39, 0.28);

  /* Radii */
  --r-xl: 8px;
  --r-lg: 8px;
  --r: 8px;
  --r-sm: 8px;
  --pill: 999px;

  --sidebar-w: 252px;
  --page-x: clamp(24px, 3.2vw, 52px);
  --page-y: 40px;
  --section-gap: 34px;
  --panel-pad: clamp(22px, 1.9vw, 30px);
  --control-h: 42px;
}

/* Dark mode — a personal preference (set via Personal Settings). Only the neutral
   tokens flip; the per-workspace --accent is preserved, and accent/NPS "soft"
   shades re-mix toward the dark surface instead of white so they read correctly. */
:root[data-theme="dark"] {
  color-scheme: dark;

  --bg: #0e1217;
  --bg-grad-top: #0e1217;
  --surface: #161b22;
  --surface-2: #1b212b;
  --surface-3: #232b37;

  --ink: #f2f5f9;
  --text: #c3ccd8;
  --muted: #8b97a7;
  --faint: #697485;

  --line: #2a313d;
  --line-strong: #3a4350;

  --accent-strong: color-mix(in srgb, var(--accent) 80%, #fff);
  --accent-ink: color-mix(in srgb, var(--accent) 70%, #fff);
  --accent-soft: color-mix(in srgb, var(--accent) 26%, var(--surface));
  --accent-soft-2: color-mix(in srgb, var(--accent) 40%, var(--surface));

  --promoter-soft: color-mix(in srgb, var(--promoter) 24%, var(--surface));
  --passive-soft: color-mix(in srgb, var(--passive) 24%, var(--surface));
  --detractor-soft: color-mix(in srgb, var(--detractor) 24%, var(--surface));

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.45);
  --shadow:
    0 1px 2px rgba(0, 0, 0, 0.4),
    0 14px 30px -24px rgba(0, 0, 0, 0.7);
  --shadow-lg:
    0 1px 3px rgba(0, 0, 0, 0.5),
    0 24px 48px -28px rgba(0, 0, 0, 0.7);
}

* {
  box-sizing: border-box;
}

/* The HTML hidden attribute must always win — a component's display rule
   (grid/flex) otherwise overrides it and leaks the element onto the page. */
[hidden] {
  display: none !important;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  overflow-x: hidden;
  color: var(--text);
  background: var(--bg);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.58;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, legend {
  color: var(--ink);
  letter-spacing: 0;
}

/* Global safety net: long, unbreakable strings (names, tags, emails, URLs)
   must wrap inside their container instead of overflowing. break-word only
   breaks when a word would otherwise overflow, so normal text is unaffected. */
h1, h2, h3, h4, p, span, strong, small, a, li, td, th, dt, dd, code, legend, label, figcaption {
  overflow-wrap: break-word;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

::selection {
  background: var(--accent-soft-2);
  color: var(--accent-ink);
}

/* tabular figures for all the numbers */
.metric-card strong,
.stat-strip strong,
.segment-score strong,
.account-summary-item strong,
td,
th,
time {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1, "cv01" 1;
}

.app-shell {
  min-height: 100vh;
}

/* =========================================================================
   Sidebar (kept the .topbar class name; styled as a light rail)
   ========================================================================= */

.topbar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  width: var(--sidebar-w);
  min-height: 100vh;
  max-height: 100vh;
  padding: 18px 16px;
  overflow-y: auto;
  color: var(--text);
  background: var(--surface);
  border-right: 1px solid var(--line);
}

.brand,
.topnav,
.top-actions,
.quick-actions,
.panel-header,
.form-actions {
  display: flex;
  align-items: center;
}

.brand {
  gap: 10px;
  width: 100%;
  min-width: 0;
  padding: 2px 4px 16px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  font-weight: 700;
  font-size: 0.94rem;
  letter-spacing: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: var(--r);
  /* Default product mark is the NPS badge image; the "N" stays in markup as a
     fallback but is hidden (font-size: 0). A workspace logo overrides via .has-logo. */
  font-size: 0;
  background: var(--surface) url("/nps-mark.png") center / contain no-repeat;
  border: 1px solid var(--line);
  overflow: hidden;
}

/* When an organization logo is uploaded, drop the teal monogram chrome and show the image. */
.brand-mark.has-logo {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
}

.brand-mark.has-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: var(--r);
}

.workspace-logo-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.workspace-accent-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.workspace-logo-preview {
  border: 1px solid var(--line);
}

.section-head-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.workspace-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px 20px;
  margin: 16px 0 0;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.danger-zone {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 20px;
  padding: 16px 18px;
  border: 1px solid color-mix(in srgb, var(--detractor) 35%, var(--line));
  border-radius: var(--r);
  background: color-mix(in srgb, var(--detractor) 5%, var(--surface));
}

.danger-zone > div {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.danger-zone strong {
  color: var(--detractor);
  font-size: 0.92rem;
}

.danger-zone span {
  color: var(--muted);
  font-size: 0.83rem;
  line-height: 1.5;
}

.workspace-meta > div {
  display: grid;
  gap: 2px;
}

.workspace-meta dt {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.workspace-meta dd {
  margin: 0;
  font-weight: 600;
  font-size: 0.9rem;
}

.workspace-meta-mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-weight: 500 !important;
  font-size: 0.8rem !important;
  word-break: break-all;
}

.brand span:last-child {
  display: grid;
  gap: 1px;
  line-height: 1.2;
}

.workspace-switch {
  position: relative;
  padding: 0 4px 14px;
  margin-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.workspace-switch-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  width: 100%;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
}

.workspace-switch-toggle:hover {
  color: var(--ink);
  border-color: var(--accent);
}

.workspace-switch-menu {
  position: absolute;
  left: 4px;
  right: 4px;
  top: calc(100% - 6px);
  z-index: 60;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 18px 40px -24px rgba(15, 23, 42, 0.45);
  padding: 6px;
  display: grid;
  gap: 2px;
}

.workspace-switch-head {
  margin: 4px 8px;
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.workspace-switch-item,
.workspace-switch-create {
  text-align: left;
  background: transparent;
  border: none;
  border-radius: 7px;
  padding: 8px 10px;
  font-size: 0.85rem;
  cursor: pointer;
  color: var(--ink);
}

.workspace-switch-item:hover,
.workspace-switch-create:hover {
  background: var(--surface-2);
}

.workspace-switch-item.active {
  font-weight: 700;
}

.workspace-switch-create {
  color: var(--accent);
  font-weight: 600;
  border-top: 1px solid var(--line);
  margin-top: 4px;
}

.workspace-switch-empty {
  margin: 4px 8px;
  font-size: 0.8rem;
  color: var(--muted);
}

.topnav {
  flex-direction: column;
  align-items: stretch;
  width: 100%;
  gap: 14px;
}

.nav-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-group-label {
  margin: 0;
  padding: 0 10px 4px;
  color: var(--faint);
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.topnav a {
  position: relative;
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 38px;
  padding: 8px 12px;
  border-radius: var(--r);
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 550;
  line-height: 1.25;
  transition: background 140ms ease, color 140ms ease;
}

.nav-ico {
  display: grid;
  place-items: center;
  width: 18px;
  flex: none;
  color: var(--faint);
  font-size: 0.95rem;
  line-height: 1;
}

.topnav a:hover .nav-ico,
.topnav a.active .nav-ico {
  color: inherit;
}

/* Hub sub-tab bar — groups related pages into one workspace section */
.hub-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  margin-bottom: 26px;
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-xs);
}

.hub-tab {
  display: inline-flex;
  align-items: center;
  padding: 8px 16px;
  border-radius: var(--r);
  color: var(--muted);
  font-size: 0.875rem;
  font-weight: 600;
  transition: background 140ms ease, color 140ms ease;
}

.hub-tab:hover {
  color: var(--ink);
  background: var(--surface-2);
}

.hub-tab.active {
  color: var(--accent-ink);
  background: var(--accent-soft);
}

.topnav a:hover,
.topnav a:focus-visible {
  color: var(--ink);
  background: var(--surface-2);
}

.topnav a.active {
  color: var(--accent-ink);
  background: var(--accent-soft);
  font-weight: 700;
}

.topnav a.active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--accent);
}

.top-actions,
.quick-actions {
  gap: 8px;
  flex-wrap: wrap;
}

.inline-checkbox {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  color: var(--text);
  background: var(--surface);
  font-size: 0.84rem;
  font-weight: 650;
}

.inline-checkbox input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.top-actions {
  flex-direction: column;
  align-items: stretch;
  width: 100%;
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.top-actions .button,
.top-actions .icon-button {
  width: 100%;
}

/* =========================================================================
   Main content
   ========================================================================= */

main {
  width: calc(100% - var(--sidebar-w));
  max-width: 1520px;
  margin-left: var(--sidebar-w);
  padding: var(--page-y) var(--page-x) 72px;
  transition: opacity 140ms ease;
}

/* Boot loading state: mask the data region (so static "0" placeholders / stale values never
   flash) and show a spinner until the first real render. Sidebar/brand stay visible. */
body.app-booting main {
  opacity: 0;
}

.app-boot-spinner {
  position: fixed;
  inset: 0 0 0 var(--sidebar-w);
  display: grid;
  place-items: center;
  pointer-events: none;
  z-index: 400;
}

body:not(.app-booting) .app-boot-spinner {
  display: none;
}

.app-boot-spinner::after {
  content: "";
  width: 26px;
  height: 26px;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: app-spin 0.7s linear infinite;
}

@keyframes app-spin {
  to {
    transform: rotate(360deg);
  }
}

/* Signed-out login screen — covers the whole app; no workspace data behind it. */
.login-gate {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--bg);
}

.login-gate-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 32px clamp(20px, 4vw, 34px);
  box-shadow: 0 30px 60px -40px rgba(15, 23, 42, 0.35);
  display: grid;
  gap: 14px;
}

.login-gate-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.95rem;
  margin-bottom: 4px;
}

.login-gate-card h1 {
  margin: 0 0 6px;
  font-size: 1.3rem;
}

.login-gate-note {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.5;
}

.slack-oauth-alt {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.slack-oauth-alt > summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 0.85rem;
}

.login-gate-card label {
  display: grid;
  gap: 6px;
  font-size: 0.85rem;
  font-weight: 500;
}

.login-gate-card .form-actions {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}

.login-gate-link {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 0.8rem;
  cursor: pointer;
  padding: 4px;
}

.login-gate-link:hover {
  color: var(--ink);
}

main > section + section {
  margin-top: var(--section-gap);
}

.workspace-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 24px;
  align-items: center;
  margin-bottom: 0;
  padding-bottom: 4px;
}

.workspace-header h1 {
  max-width: 840px;
  margin: 5px 0 8px;
  font-size: clamp(1.7rem, 2.2vw, 2.35rem);
  font-weight: 750;
  line-height: 1.12;
}

.lede {
  max-width: 760px;
  margin: 0;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.65;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent-ink);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.workspace-header .eyebrow {
  color: var(--accent-ink);
}

/* =========================================================================
   Buttons
   ========================================================================= */

.button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--control-h);
  border: 1px solid transparent;
  border-radius: var(--r);
  font-weight: 600;
  font-size: 0.86rem;
  letter-spacing: 0;
  transition:
    transform 140ms ease,
    border-color 140ms ease,
    background 140ms ease,
    box-shadow 140ms ease,
    color 140ms ease;
}

.button {
  padding: 0 14px;
  gap: 7px;
}

.icon-button {
  width: 100%;
  gap: 8px;
  padding: 0 12px;
  color: var(--text);
  border-color: var(--line-strong);
  background: var(--surface);
  font-size: 0.88rem;
}

.icon-button:hover {
  border-color: var(--accent);
  color: var(--accent-ink);
  background: var(--accent-soft);
}

.button.primary {
  color: #fff;
  background: linear-gradient(180deg, var(--accent), var(--accent-strong));
  box-shadow: 0 1px 2px color-mix(in srgb, var(--accent) 38%, transparent), inset 0 1px 0 rgba(255, 255, 255, 0.18);
}

.button.primary:hover {
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 82%, #fff), var(--accent));
}

.button:disabled,
.icon-button:disabled,
.mini-button:disabled {
  cursor: not-allowed;
  color: var(--muted);
  border-color: var(--line);
  background: var(--surface-3);
  box-shadow: none;
  opacity: 0.68;
}

.button:disabled:hover,
.icon-button:disabled:hover,
.mini-button:disabled:hover {
  transform: none;
}

.button.secondary {
  color: var(--text);
  border-color: var(--line-strong);
  background: var(--surface);
}

.button.secondary:hover {
  color: var(--accent-ink);
  border-color: var(--accent);
  background: var(--accent-soft);
}

.workspace-header .button.secondary {
  color: var(--text);
}

.button.danger {
  color: var(--detractor);
  border-color: rgba(228, 72, 59, 0.3);
  background: var(--surface);
}

.button.danger:hover {
  background: var(--detractor-soft);
  border-color: var(--detractor);
}

.button:hover,
.icon-button:hover,
.score-button:hover {
  transform: translateY(-1px);
}

.button:disabled:hover,
.icon-button:disabled:hover,
.mini-button:disabled:hover {
  transform: none;
}

.button:active,
.icon-button:active {
  transform: translateY(0);
}

.button:focus-visible,
.icon-button:focus-visible,
.score-button:focus-visible,
.mini-button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 30%, transparent);
  outline-offset: 2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* =========================================================================
   Filters + form controls
   ========================================================================= */

.filters,
.metric-grid,
.stat-strip,
.dashboard-grid,
.workbench {
  display: grid;
  gap: 16px;
}

.filters {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  gap: 14px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 650;
}

input,
select,
textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line-strong);
  border-radius: var(--r);
  background: var(--surface);
  color: var(--ink);
  font-weight: 500;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

input::placeholder,
textarea::placeholder {
  color: var(--faint);
}

/* Disabled form controls must LOOK disabled (admin-gated forms were rendering
   as normal but dead, with no visual cue). */
input:disabled,
select:disabled,
textarea:disabled {
  color: var(--faint);
  background: var(--surface-3);
  cursor: not-allowed;
  opacity: 0.75;
}

input,
select {
  min-height: var(--control-h);
  padding: 0 12px;
}

/* Checkbox/radio must NOT inherit the full-width 42px text-field sizing above.
   Baseline native control; component overrides (defined later) still win. */
input[type="checkbox"],
input[type="radio"] {
  width: 16px;
  min-width: 16px;
  height: 16px;
  min-height: 0;
  padding: 0;
  border: 0;
  background: none;
  accent-color: var(--accent);
  flex: none;
  cursor: pointer;
}

/* Color picker: compact swatch, not a full-width text field. */
input[type="color"] {
  width: 52px;
  min-width: 52px;
  height: var(--control-h);
  padding: 4px;
  cursor: pointer;
}

/* File input: let the native control sit naturally instead of a 42px text box. */
input[type="file"] {
  min-height: 0;
  padding: 9px 12px;
  font-size: 0.88rem;
}

select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 36px;
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%236b7b8d' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}

textarea {
  resize: vertical;
  padding: 12px 13px;
  line-height: 1.55;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 16%, transparent);
  outline: none;
}

/* =========================================================================
   Metric grid + program stats
   ========================================================================= */

.metric-grid {
  grid-template-columns: minmax(240px, 1.25fr) repeat(4, minmax(0, 1fr));
  margin-bottom: 0;
  gap: 18px;
}

.program-panel,
.followup-case-panel,
.slack-panel {
  margin-bottom: 0;
}

.slack-panel,
.setup-panel,
.account-panel,
.followup-case-panel,
.responses-panel {
  scroll-margin-top: 24px;
}

.metric-card,
.panel {
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.metric-card {
  display: flex;
  flex-direction: column;
  min-height: 132px;
  padding: 20px 21px 19px;
}

.metric-card p {
  margin: 0 0 auto;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.metric-card strong {
  display: block;
  margin: 16px 0 6px;
  color: var(--ink);
  font-size: clamp(1.65rem, 2.2vw, 2.25rem);
  font-weight: 750;
  line-height: 1.05;
  overflow-wrap: anywhere;
}

/* The "Top risk driver" card holds a long text label (e.g. "Service Responsiveness"),
   not a number — shrink it and wrap at spaces so it never snaps mid-word. */
#insightTopRiskDriver {
  font-size: clamp(1.1rem, 1.6vw, 1.45rem);
  line-height: 1.2;
  overflow-wrap: break-word;
  word-break: normal;
  hyphens: none;
}

.metric-card span {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 500;
}

.hero-metric {
  position: relative;
  overflow: hidden;
  border-color: color-mix(in srgb, var(--accent) 28%, transparent);
  border-left: 4px solid var(--accent);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.hero-metric p {
  color: var(--accent-ink);
}

.hero-metric strong {
  color: var(--accent-ink);
  font-size: clamp(2rem, 3vw, 2.75rem);
}

.hero-metric span {
  color: var(--muted);
  font-weight: 600;
}

.stat-strip {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 18px;
}

.stat-strip > div {
  display: grid;
  gap: 9px;
  min-height: 90px;
  padding: 16px 17px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface-2);
}

.stat-strip span {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.stat-strip strong {
  align-self: end;
  color: var(--ink);
  font-size: clamp(1.4rem, 2.2vw, 2rem);
  font-weight: 700;
  line-height: 1;
}

/* =========================================================================
   Panels + dashboard grid
   ========================================================================= */

.panel {
  padding: var(--panel-pad);
}

.panel-header {
  align-items: flex-start;
  justify-content: space-between;
  gap: 22px;
  margin-bottom: 24px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.panel-header > div {
  min-width: 0;
  max-width: 780px;
}

.panel-header .eyebrow {
  margin-bottom: 4px;
}

.panel h2 {
  margin: 0;
  font-size: clamp(1.05rem, 1.2vw, 1.18rem);
  font-weight: 700;
  line-height: 1.22;
}

.dashboard-grid {
  grid-template-columns: repeat(12, minmax(0, 1fr));
  margin-bottom: 0;
  gap: var(--section-gap);
  align-items: start;
}

.dashboard-grid > .panel {
  grid-column: span 6;
  align-self: start;
  min-width: 0;
}

.dashboard-grid > *,
.workbench > *,
.survey-builder-layout > *,
.slack-layout > *,
.setup-layout > *,
.account-layout > * {
  min-width: 0;
}

.panel-header > span,
.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 4px 10px;
  border-radius: var(--pill);
  color: var(--accent-ink);
  background: var(--accent-soft);
  font-size: 0.74rem;
  font-weight: 650;
  white-space: nowrap;
}

.pill.promoter {
  color: var(--promoter);
  background: var(--promoter-soft);
}

.pill.detractor {
  color: var(--detractor);
  background: var(--detractor-soft);
}

/* =========================================================================
   Score distribution
   ========================================================================= */

.distribution {
  display: grid;
  gap: 16px;
}

.distribution-track {
  height: 12px;
  overflow: hidden;
  border-radius: var(--pill);
  background: var(--surface-3);
}

.bar {
  display: block;
  width: 0;
  height: 100%;
  min-width: 0;
  border-radius: inherit;
  transition: width 320ms cubic-bezier(0.22, 1, 0.36, 1);
}

.bar.detractor {
  background: var(--detractor);
}

.bar.passive {
  background: var(--passive);
}

.bar.promoter {
  background: var(--promoter);
}

.distribution p {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 8px 0 0;
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 600;
}

.distribution p strong {
  color: var(--ink);
  font-weight: 700;
}

/* Delighted-style category dots on the legend */
.distribution p > span:first-child {
  display: inline-flex;
  align-items: center;
  gap: 9px;
}

.dist-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex: none;
}

.dist-dot.detractor { background: var(--detractor); }
.dist-dot.passive { background: var(--passive); }
.dist-dot.promoter { background: var(--promoter); }

/* =========================================================================
   Trend chart
   ========================================================================= */

.trend-chart {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  align-items: end;
  gap: 12px;
  min-height: 190px;
  padding: 14px 12px 10px;
  border-radius: var(--r);
  background:
    repeating-linear-gradient(
      to top,
      transparent 0,
      transparent calc(25% - 1px),
      var(--line) calc(25% - 1px),
      var(--line) 25%
    ),
    var(--surface-2);
}

.trend-column {
  display: grid;
  align-content: end;
  gap: 8px;
  height: 100%;
  min-width: 0;
}

.trend-bar {
  display: block;
  min-height: 4px;
  border-radius: 6px 6px 2px 2px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 68%, #fff), var(--accent));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.trend-column small {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 600;
  text-align: center;
}

/* =========================================================================
   Theme / follow-up / driver / segment lists
   ========================================================================= */

.theme-list,
.followup-list,
.driver-list,
.segment-list {
  display: grid;
  gap: 12px;
}

.theme-item,
.followup-item,
.driver-item,
.segment-item {
  display: grid;
  gap: 10px;
  padding: 16px 17px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface-2);
  transition: border-color 140ms ease, background 140ms ease;
}

.theme-item:hover,
.followup-item:hover,
.driver-item:hover,
.segment-item:hover {
  border-color: var(--line-strong);
  background: var(--surface);
}

.theme-row,
.followup-meta,
.driver-item,
.segment-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.theme-row strong,
.followup-item strong,
.driver-item strong,
.segment-item strong {
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 650;
}

.theme-detail {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
}

.dashboard-grid > .insights-summary-panel {
  grid-column: span 8;
}

.insights-grid > .panel:not(.insights-summary-panel):not(.insight-evidence-panel) {
  grid-column: span 4;
}

.dashboard-grid > .insight-evidence-panel {
  grid-column: 1 / -1;
}

.insight-table-wrap table {
  min-width: 760px;
}

.table-link {
  display: inline;
  padding: 0;
  border: 0;
  color: var(--ink);
  background: transparent;
  font-weight: 700;
  text-align: left;
}

.table-link:hover {
  color: var(--accent-ink);
  text-decoration: underline;
  text-underline-offset: 3px;
}

tr.selected-row {
  background: var(--accent-soft);
}

.insight-driver-list {
  display: grid;
  gap: 12px;
}

.insight-driver-item {
  display: grid;
  gap: 12px;
  width: 100%;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface-2);
  text-align: left;
  cursor: pointer;
}

.insight-driver-item:hover {
  border-color: var(--accent);
  background: var(--surface);
}

.insight-driver-item > div:first-child {
  display: grid;
  gap: 3px;
}

.insight-driver-item strong {
  color: var(--ink);
  font-size: 0.92rem;
}

.insight-driver-item span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
}

.insight-risk-meter {
  overflow: hidden;
  height: 8px;
  border-radius: var(--pill);
  background: var(--surface-3);
}

.insight-risk-meter span {
  display: block;
  min-width: 2px;
  height: 100%;
  border-radius: inherit;
  background: var(--detractor);
}

.insight-evidence-list {
  display: grid;
  gap: 12px;
}

.followup-case-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 18px;
}

.followup-case-grid > div {
  min-width: 0;
}

.insight-evidence-item {
  display: grid;
  gap: 12px;
  padding: 16px 17px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface-2);
}

.insight-evidence-head,
.insight-evidence-meta {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.insight-evidence-head > div {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.insight-evidence-head strong {
  color: var(--ink);
  font-size: 0.94rem;
}

.insight-evidence-head span,
.insight-evidence-meta {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 600;
}

.insight-evidence-item p {
  margin: 0;
  color: var(--text);
  font-size: 0.9rem;
}

.insight-evidence-meta {
  justify-content: flex-start;
  flex-wrap: wrap;
}

.theme-count,
.score-chip,
.status-chip,
.due-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 26px;
  padding: 4px 10px;
  border-radius: var(--pill);
  font-size: 0.72rem;
  font-weight: 650;
  white-space: nowrap;
}

.theme-count {
  color: var(--accent-ink);
  background: var(--accent-soft);
}

.score-chip.detractor {
  color: var(--detractor);
  background: var(--detractor-soft);
}

.score-chip.passive {
  color: var(--passive);
  background: var(--passive-soft);
}

.score-chip.promoter {
  color: var(--promoter);
  background: var(--promoter-soft);
}

.status-chip {
  color: var(--text);
  background: var(--surface-3);
}

.due-chip {
  color: var(--muted);
  background: var(--surface-3);
}

.due-chip.overdue {
  color: var(--detractor);
  background: var(--detractor-soft);
}

.followup-item p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.driver-item > div,
.segment-item > div:first-child {
  display: grid;
  gap: 3px;
}

.driver-item > div span,
.segment-item span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 500;
}

.segment-score {
  display: grid;
  justify-items: end;
  gap: 1px;
}

.segment-score strong {
  color: var(--ink);
  font-size: 1.3rem;
  font-weight: 700;
}

/* =========================================================================
   Workbench + survey form
   ========================================================================= */

.workbench {
  grid-template-columns: minmax(0, 1.4fr) minmax(320px, 0.6fr);
  align-items: start;
  margin-bottom: 0;
  gap: var(--section-gap);
}

.workbench.single-page-workbench {
  grid-template-columns: minmax(0, 1fr);
  max-width: 920px;
}

form {
  display: grid;
  gap: 20px;
}

fieldset {
  margin: 0;
  padding: 0;
  border: 0;
}

legend {
  margin-bottom: 16px;
  font-size: clamp(1.15rem, 1.8vw, 1.4rem);
  font-weight: 700;
  line-height: 1.25;
}

.score-grid {
  display: grid;
  grid-template-columns: repeat(11, minmax(34px, 1fr));
  gap: 8px;
}

.score-button {
  display: grid;
  place-items: center;
  min-width: 0;
  aspect-ratio: 1 / 1;
  border: 1.5px solid var(--line-strong);
  border-radius: var(--r);
  background: var(--surface);
  color: var(--ink);
  font-weight: 700;
  font-size: 0.98rem;
  transition:
    transform 140ms ease,
    background 140ms ease,
    border-color 140ms ease,
    color 140ms ease,
    box-shadow 140ms ease;
}

/* Delighted-style scale tinting on hover by score range */
.score-button[data-score="0"]:hover,
.score-button[data-score="1"]:hover,
.score-button[data-score="2"]:hover,
.score-button[data-score="3"]:hover,
.score-button[data-score="4"]:hover,
.score-button[data-score="5"]:hover,
.score-button[data-score="6"]:hover {
  border-color: var(--detractor);
  color: var(--detractor);
}

.score-button[data-score="7"]:hover,
.score-button[data-score="8"]:hover {
  border-color: var(--passive);
  color: var(--passive);
}

.score-button[data-score="9"]:hover,
.score-button[data-score="10"]:hover {
  border-color: var(--promoter);
  color: var(--promoter);
}

.score-button.selected {
  color: #fff;
  border-color: var(--promoter);
  background: var(--promoter);
  box-shadow: 0 10px 20px -10px rgba(21, 160, 90, 0.7);
}

.score-button.selected.detractor {
  border-color: var(--detractor);
  background: var(--detractor);
  box-shadow: 0 10px 20px -10px rgba(228, 72, 59, 0.7);
}

.score-button.selected.passive {
  color: #fff;
  border-color: var(--passive);
  background: var(--passive);
  box-shadow: 0 10px 20px -10px rgba(232, 150, 17, 0.7);
}

.scale-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 600;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
  /* Top-align cells so a field with helper text below it doesn't vertically
     center the controls in shorter sibling cells (they'd drift out of line). */
  align-items: start;
}

.form-actions {
  gap: 14px 16px;
  flex-wrap: wrap;
}

.checkbox-label {
  display: flex;
  grid-column: 1 / -1;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 500;
}

.checkbox-label input {
  width: 18px;
  min-width: 18px;
  height: 18px;
  min-height: 18px;
  accent-color: var(--accent);
}

.form-actions p {
  margin: 0;
  color: var(--promoter);
  font-weight: 650;
}

.settings-note {
  margin-top: 18px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface-2);
}

.settings-note strong {
  color: var(--ink);
}

.settings-note p {
  margin: 4px 0 0;
  color: var(--muted);
}

.survey-live-brand {
  display: grid;
  place-items: center;
  min-height: 44px;
  margin-bottom: 18px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  color: var(--accent);
  background: var(--surface-2);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-align: center;
  text-transform: uppercase;
}

.survey-live-brand.has-image {
  min-height: 68px;
  text-transform: none;
}

.survey-live-brand img {
  display: block;
  max-width: min(220px, 80%);
  max-height: 68px;
  width: auto;
  height: auto;
  object-fit: contain;
}

/* =========================================================================
   Survey builder
   ========================================================================= */

.survey-builder-shell {
  display: grid;
  gap: var(--section-gap);
}

.survey-builder-header {
  margin-bottom: 0;
}

.survey-builder-form {
  gap: 0;
}

.builder-tabs {
  display: flex;
  justify-content: center;
  min-width: 0;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--line-strong);
}

.builder-tab {
  min-height: 44px;
  padding: 0 22px;
  border: 0;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  background: transparent;
  font-size: 0.95rem;
  font-weight: 650;
  transition: color 140ms ease, border-color 140ms ease, background 140ms ease;
}

.builder-tab:hover,
.builder-tab:focus-visible {
  color: var(--ink);
  background: var(--surface-2);
}

.builder-tab.active {
  color: var(--blue);
  border-bottom-color: var(--blue);
}

.survey-builder-layout {
  display: grid;
  grid-template-columns: minmax(420px, 0.95fr) minmax(420px, 1.05fr);
  gap: var(--section-gap);
  align-items: start;
}

.builder-pane-stack,
.builder-preview {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.builder-pane {
  padding: var(--panel-pad);
}

.builder-pane[hidden] {
  display: none;
}

.builder-pane-header {
  margin-bottom: 18px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.builder-pane-header h2 {
  margin: 0;
  color: var(--ink);
  font-size: 1.16rem;
  line-height: 1.2;
}

.builder-control-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px 20px;
  align-items: start;
}

.builder-group-title {
  margin: 26px 0 2px;
  font-size: 0.98rem;
}

.builder-group-title:first-of-type {
  margin-top: 6px;
}

.builder-group-hint {
  margin: 0 0 14px;
}

.preview-extra-questions {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.preview-extra-q {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface);
  font-size: 0.85rem;
}

.preview-extra-q small {
  color: var(--muted);
  text-transform: capitalize;
  white-space: nowrap;
}

.thankyou-screen {
  display: grid;
  gap: 10px;
  padding: 18px;
  text-align: center;
}

.thankyou-screen > strong {
  font-size: 1.05rem;
}

.thankyou-row {
  display: flex;
  align-items: center;
  gap: 8px;
  text-align: left;
  font-size: 0.82rem;
  color: var(--muted);
}

.thankyou-row .score-chip {
  flex: none;
}

.builder-control-grid .wide-field {
  grid-column: 1 / -1;
}

.logo-builder-field {
  display: grid;
  gap: 8px;
}

.logo-upload-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
  align-items: center;
}

.logo-upload-button {
  cursor: pointer;
}

.logo-current {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--accent-soft, rgba(15, 23, 42, 0.03));
  font-size: 0.82rem;
  color: var(--muted);
}

.logo-current img {
  width: 40px;
  height: 40px;
  object-fit: contain;
  border-radius: 6px;
  background: #fff;
  border: 1px solid var(--line);
  flex: none;
}

.logo-meta-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.builder-snippet-card {
  display: grid;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface-2);
}

.builder-snippet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.builder-snippet-header strong {
  color: var(--ink);
  font-size: 0.95rem;
}

.builder-snippet-card textarea {
  min-height: 138px;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.8rem;
  line-height: 1.45;
  color: var(--ink);
  background: var(--surface);
}

.builder-preview {
  position: sticky;
  top: 28px;
  padding: var(--panel-pad);
  /* The preview mimics the customer-facing survey/email, which are ALWAYS light
     (the live /s page never goes dark). Re-declare the neutral tokens to their
     light values here so dark mode doesn't bleed into the preview. The
     per-workspace --accent is intentionally NOT overridden. */
  --bg: #f6f8fb;
  --bg-grad-top: #f6f8fb;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --surface-3: #eef2f6;
  --ink: #111827;
  --text: #374151;
  --muted: #667085;
  --faint: #98a2b3;
  --line: #e6eaf0;
  --line-strong: #d4dbe5;
  color-scheme: light;
  color: var(--ink);
}

/* The /survey collector card mirrors the customer-facing survey, which is ALWAYS
   light (the live /s page never goes dark). Re-declare neutral tokens to their
   light values so dark mode doesn't bleed into the survey. The per-workspace
   --accent is intentionally NOT overridden. */
.survey-panel {
  --bg: #f6f8fb;
  --bg-grad-top: #f6f8fb;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --surface-3: #eef2f6;
  --ink: #111827;
  --text: #374151;
  --muted: #667085;
  --faint: #98a2b3;
  --line: #e6eaf0;
  --line-strong: #d4dbe5;
  color-scheme: light;
  color: var(--ink);
}

.preview-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  margin-bottom: 14px;
}

.preview-toolbar div {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.preview-toolbar span,
.preview-header-row span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 650;
}

.preview-toolbar strong,
.preview-header-row strong {
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--ink);
  font-weight: 650;
}

.email-preview-card {
  display: grid;
  gap: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface-3);
}

.preview-section-label {
  margin: 16px 0 6px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.email-body-preview {
  margin-top: 10px;
  padding: 22px 16px 20px;
  border-radius: var(--r-sm);
  background: #fff;
  text-align: center;
}

.email-body-preview p {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 0.85rem;
}

.email-body-preview #builderPreviewGreeting {
  color: var(--ink);
  font-weight: 600;
}

.email-cta-preview {
  display: inline-block;
  padding: 11px 22px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: 0.85rem;
}

.email-fineprint {
  margin: 12px 0 0 !important;
  font-size: 0.72rem;
}

.preview-header-row {
  display: grid;
  grid-template-columns: 86px minmax(0, 1fr);
  min-height: 34px;
  align-items: center;
  border: 1px solid var(--line);
  border-bottom: 0;
  background: var(--surface);
}

.preview-header-row span {
  height: 100%;
  padding: 8px 10px;
  border-right: 1px solid var(--line);
  background: var(--surface-2);
}

.preview-header-row strong {
  padding: 8px 10px;
  font-size: 0.82rem;
}

.survey-preview-card {
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: 0 16px 36px -28px rgba(15, 31, 46, 0.4);
}

.survey-preview-bar {
  height: 4px;
  background: #ff5f5a;
}

.survey-preview-logo {
  display: grid;
  place-items: center;
  min-height: 54px;
  padding: 14px 18px;
  color: #ff5f5a;
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.survey-preview-logo.has-image {
  min-height: 72px;
  text-transform: none;
}

.survey-preview-logo img {
  display: block;
  max-width: min(220px, 80%);
  max-height: 72px;
  width: auto;
  height: auto;
  object-fit: contain;
}

.survey-preview-body {
  padding: 24px 24px 18px;
  background: var(--surface-2);
  text-align: center;
}

.survey-preview-body p {
  margin: 0 0 8px;
  color: var(--muted);
  font-weight: 600;
}

.survey-preview-body h2 {
  margin: 0 auto 18px;
  max-width: 560px;
  color: var(--ink);
  font-size: 1.15rem;
  line-height: 1.35;
}

.preview-score-row {
  --preview-accent: #ff5f5a;
  --preview-text: #ffffff;
  display: grid;
  grid-template-columns: repeat(11, minmax(0, 1fr));
  gap: 5px;
}

.preview-score-row span {
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 32px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  color: var(--ink);
  background: var(--surface);
  font-size: 0.82rem;
  font-weight: 700;
}

/* Mirror the live /s NPS color-coding in the builder preview. */
.preview-score-row.nps span.detractor { border-color: #f1b4ae; color: #b3261a; }
.preview-score-row.nps span.passive { border-color: #f0cd8a; color: #8a5a06; }
.preview-score-row.nps span.promoter { border-color: #a9dcc0; color: #0e7a43; }

.survey-preview-card .scale-labels {
  margin-top: 9px;
  font-size: 0.72rem;
}

.comment-preview {
  display: grid;
  gap: 6px;
  padding: 18px 24px 22px;
  border-top: 1px solid var(--line);
  background: var(--surface);
}

.comment-preview strong {
  color: var(--ink);
  font-weight: 700;
}

.comment-preview span {
  min-height: 52px;
  padding: 12px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-sm);
  color: var(--muted);
  background: var(--surface-2);
  font-size: 0.9rem;
}

.builder-save-note {
  margin-top: 14px;
}

/* =========================================================================
   Responses table
   ========================================================================= */

.search-label {
  width: min(420px, 100%);
}

.inline-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  justify-content: flex-end;
  gap: 14px 16px;
}

.inline-filters label {
  min-width: 160px;
}

.table-wrap {
  overflow: auto;
  max-height: min(72vh, 720px);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
  scrollbar-gutter: stable;
}

table {
  width: 100%;
  min-width: 1080px;
  border-collapse: collapse;
  background: var(--surface);
}

th,
td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  color: var(--muted);
  background: var(--surface-2);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

td {
  font-size: 0.9rem;
  color: var(--text);
}

tbody tr {
  transition: background 120ms ease;
}

tbody tr:hover {
  background: var(--surface-2);
}

tbody tr:last-child td {
  border-bottom: 0;
}

.feedback-cell {
  max-width: 380px;
  color: var(--muted);
}

.followup-history {
  display: grid;
  gap: 6px;
  min-width: 220px;
}

.followup-history span {
  display: block;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.45;
}

.checkbox-row {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 9px;
  min-height: 42px;
  color: var(--text);
  font-size: 0.88rem;
  font-weight: 650;
}

.checkbox-row input {
  width: 16px;
  height: 16px;
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.mini-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 6px 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  color: var(--text);
  background: var(--surface);
  font-size: 0.8rem;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  transition: color 140ms ease, border-color 140ms ease, background 140ms ease;
}

.mini-button:hover {
  color: var(--accent-ink);
  border-color: var(--accent);
  background: var(--accent-soft);
}

.empty-state {
  padding: 48px 28px;
  color: var(--muted);
  text-align: center;
  background: var(--surface-2);
}

.themes-panel .theme-list,
.followup-panel .followup-list,
.drivers-panel .driver-list,
.segments-panel .segment-list,
.insight-driver-list,
.insight-evidence-list {
  max-height: min(68vh, 640px);
  overflow: auto;
  padding-right: 4px;
  scrollbar-gutter: stable;
}

/* =========================================================================
   Slack preview (intentionally dark to mimic Slack)
   ========================================================================= */

.slack-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(250px, 0.26fr);
  gap: var(--section-gap);
  align-items: start;
}

.slack-feed {
  position: relative;
  display: grid;
  gap: 16px;
  overflow: hidden;
  padding: 22px 22px 22px 18px;
  border-radius: var(--r);
  color: #d6d9de;
  background: var(--slack-bg);
}

.slack-day-pill {
  justify-self: center;
  margin-top: -14px;
  padding: 5px 18px;
  border: 1px solid #3a3f47;
  border-radius: var(--pill);
  color: #eef0f3;
  background: var(--slack-bg-2);
  font-size: 0.82rem;
  font-weight: 650;
}

.slack-message {
  display: grid;
  grid-template-columns: 78px minmax(0, 1fr);
  gap: 14px;
}

.slack-message time {
  color: #9aa0aa;
  font-size: 0.92rem;
  text-align: right;
}

.slack-message p {
  margin: 0 0 5px;
}

.slack-message a {
  color: #4cb3e8;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.slack-author {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 4px;
  color: #f4f5f7;
}

.slack-author strong {
  color: #f4f5f7;
  font-size: 1rem;
  font-weight: 700;
}

.slack-author span {
  padding: 1px 6px;
  border-radius: 4px;
  color: #c3c7ce;
  background: #34383f;
  font-size: 0.7rem;
  font-weight: 700;
}

.slack-attachment {
  display: grid;
  gap: 4px;
  margin-top: 10px;
  padding: 6px 0 6px 16px;
  border-left: 4px solid var(--promoter);
  border-radius: 2px;
}

.slack-attachment.promoter { border-left-color: var(--promoter); }
.slack-attachment.passive { border-left-color: var(--passive); }
.slack-attachment.detractor { border-left-color: var(--detractor); }
.slack-attachment.summary { border-left-color: #8a93a1; }

.slack-meter {
  position: relative;
  display: flex;
  overflow: hidden;
  width: min(720px, 100%);
  height: 56px;
  margin-top: 12px;
  border-radius: 6px;
  background: #31363f;
}

.slack-meter span:not(.slack-face) {
  min-width: 3px;
  height: 100%;
}

.slack-meter-promoter { background: var(--promoter); }
.slack-meter-passive { background: #f2f3f4; }
.slack-meter-detractor { background: var(--detractor); }

.slack-face {
  position: absolute;
  top: 50%;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 3px solid currentColor;
  border-radius: 50%;
  font-size: 1rem;
  font-weight: 800;
  transform: translate(-50%, -50%);
}

.slack-face.happy {
  left: 37%;
  color: rgba(255, 255, 255, 0.85);
}

.slack-face.sad {
  left: 89%;
  color: rgba(255, 255, 255, 0.7);
}

.slack-volume {
  margin-top: 10px;
  font-size: 0.85rem;
  opacity: 0.7;
}

/* The actual rendered bar PNG, sized like Slack's legacy-attachment image. */
.slack-bar-img {
  display: block;
  width: 100%;
  max-width: 480px;
  height: auto;
  margin-top: 12px;
  border-radius: 8px;
}

.slack-controls {
  display: grid;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface-2);
}

/* =========================================================================
   Setup / operations
   ========================================================================= */

.setup-panel,
.account-panel {
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.setup-panel > .panel-header,
.account-panel > .panel-header {
  margin-bottom: 28px;
  padding-bottom: 0;
  border-bottom: 0;
}

.setup-actions,
.section-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.ops-status-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 18px;
  margin: 0;
}

.ops-status-item {
  display: grid;
  gap: 11px;
  align-content: start;
  min-height: 126px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface-2);
}

.ops-status-item > span,
.setup-section h3 {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.ops-status-item small {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 500;
  line-height: 1.45;
}

.ops-status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  justify-self: start;
  min-height: 28px;
  padding: 4px 11px;
  border-radius: var(--pill);
  font-size: 0.78rem;
  font-weight: 650;
  white-space: nowrap;
}

.ops-status-pill::before {
  content: "";
  width: 7px;
  height: 7px;
  margin-right: 7px;
  border-radius: 50%;
  background: currentColor;
}

.ops-status-pill.live {
  color: var(--promoter);
  background: var(--promoter-soft);
}

.ops-status-pill.missing {
  color: var(--detractor);
  background: var(--detractor-soft);
}

.ops-status-pill.unknown {
  color: var(--muted);
  background: var(--surface-3);
}

.setup-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(340px, 0.86fr);
  gap: 32px;
  align-items: start;
}

.setup-focus-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.05fr);
  gap: 22px;
  margin-bottom: 30px;
}

.setup-status-section {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  margin-bottom: 30px;
}

.setup-status-section h3 {
  margin-bottom: 16px;
}

.setup-focus-grid .setup-section,
.setup-layout .setup-section,
.setup-disclosure {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.setup-priority-card {
  border-left: 4px solid var(--accent);
}

.setup-column,
.setup-section,
.job-list,
.endpoint-list,
.credential-list,
.missing-list {
  display: grid;
  gap: 16px;
}

.setup-section h3 {
  margin: 0;
}

.setup-focus-grid .setup-section h3 {
  color: var(--ink);
  font-size: 0.9rem;
  letter-spacing: 0;
  text-transform: none;
}

.setup-section p,
.missing-list {
  margin: 0;
  color: var(--muted);
}

.flow-list {
  display: grid;
  gap: 14px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.flow-list li {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.flow-list li > span {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  color: var(--accent-ink);
  background: var(--accent-soft);
  font-size: 0.82rem;
  font-weight: 700;
}

.flow-list strong,
.job-list strong {
  display: block;
  margin-bottom: 3px;
  color: var(--ink);
  font-weight: 650;
}

.flow-list p {
  color: var(--muted);
  font-size: 0.9rem;
}

.job-list > div,
.endpoint-row,
.credential-row {
  display: grid;
  gap: 8px;
  padding: 16px 0;
  border-top: 1px solid var(--line);
}

.setup-focus-grid .credential-row {
  padding: 0;
  border-top: 0;
}

.setup-checklist-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.setup-checklist-grid .credential-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface);
}

.endpoint-row,
.credential-row {
  grid-template-columns: minmax(220px, 0.62fr) minmax(0, 1fr);
  align-items: start;
  min-width: 0;
  width: 100%;
}

.endpoint-row > *,
.credential-row > * {
  min-width: 0;
}

.job-list code,
.endpoint-row code,
.credential-row code {
  width: auto;
  max-width: 100%;
  padding: 2px 7px;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-size: 0.8rem;
  font-weight: 600;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.job-list p,
.endpoint-row span,
.credential-row span {
  min-width: 0;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 500;
  overflow-wrap: anywhere;
}

.missing-list {
  padding-left: 18px;
  gap: 8px;
}

.setup-action-list {
  padding: 0;
  list-style: none;
}

.missing-list li {
  padding-left: 2px;
  color: var(--text);
}

.setup-action-list li {
  position: relative;
  padding: 12px 13px 12px 34px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface);
  line-height: 1.45;
}

.setup-action-list li::before {
  content: "";
  position: absolute;
  left: 13px;
  top: 17px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
}

.section-title-row {
  justify-content: space-between;
}

.setup-disclosure summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  cursor: pointer;
  list-style: none;
}

.setup-disclosure summary::-webkit-details-marker {
  display: none;
}

.setup-disclosure summary::after {
  content: "+";
  display: grid;
  place-items: center;
  flex: none;
  width: 28px;
  height: 28px;
  border: 1px solid var(--line-strong);
  border-radius: var(--pill);
  color: var(--accent-ink);
  background: var(--surface);
  font-weight: 800;
}

.setup-disclosure[open] summary::after {
  content: "-";
}

.setup-disclosure summary span {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.setup-disclosure summary strong {
  color: var(--ink);
}

.setup-disclosure summary small {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 500;
}

.setup-disclosure:not([open]) > :not(summary) {
  display: none;
}

.setup-disclosure .endpoint-list {
  margin-top: 14px;
}

.setup-disclosure-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 14px;
}

.setup-disclosure .code-block {
  margin-top: 12px;
}

.code-block {
  overflow: auto;
  max-height: 280px;
  margin: 0;
  padding: 17px 18px;
  border: 1px solid #1c2738;
  border-radius: var(--r);
  color: #cfe0ff;
  background: #0d1526;
  font-size: 0.78rem;
  line-height: 1.6;
}

/* =========================================================================
   Account workspace
   ========================================================================= */

.account-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 18px;
  margin-bottom: 32px;
}

.account-summary-item {
  display: grid;
  gap: 10px;
  align-content: start;
  min-height: 128px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface-2);
}

.account-summary-item span,
.account-section h3 {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.account-summary-item strong {
  color: var(--ink);
  font-size: 1.02rem;
  font-weight: 700;
}

.account-summary-item small {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 500;
  line-height: 1.45;
}

.account-layout {
  column-count: 2;
  column-gap: 32px;
}

.account-section {
  display: grid;
  gap: 18px;
  align-content: start;
  break-inside: avoid;
  margin: 0 0 24px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.account-section h3 {
  margin: 0;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

/* Tabbed settings panes (Account / Team / Notifications / API) */
.account-tabs {
  margin-bottom: 26px;
}

.account-pane {
  display: grid;
  gap: 22px;
  max-width: 820px;
  padding: 0;
}

.account-pane .account-section {
  margin: 0;
}

/* Webhooks page */
.webhook-grid {
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
}

.webhook-panel {
  display: grid;
  gap: 16px;
  align-content: start;
}

.webhook-help {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.webhook-fields {
  display: grid;
  gap: 14px;
}

.webhook-output {
  display: grid;
  gap: 6px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
}

.copy-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.copy-row input,
.copy-row textarea {
  flex: 1;
  min-width: 0;
}

.copy-row-block {
  align-items: flex-start;
}

.copy-row textarea {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.8rem;
  resize: vertical;
}

.webhook-note {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.5;
}

.webhook-note code {
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--surface-3);
  font-size: 0.78rem;
}

.webhook-events {
  margin: 0;
  padding: 0;
  border: 0;
}

.webhook-events legend {
  padding: 0 0 8px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
}

.webhook-event-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
}

.webhook-event-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  font-size: 0.84rem;
  cursor: pointer;
}

.webhook-event-toggle input {
  flex: none;
}

.webhook-row-events {
  font-size: 0.78rem;
  color: var(--faint);
}

.webhook-row-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.mini-button.danger {
  color: var(--detractor);
  border-color: var(--detractor-soft);
}

.webhook-log-panel {
  margin-top: var(--section-gap);
  display: grid;
  gap: 18px;
}

.webhook-delivery-stats {
  margin: 0;
}

/* Additional survey questions */
.additional-questions-list {
  display: grid;
  gap: 14px;
}

.additional-question {
  display: grid;
  gap: 6px;
  font-weight: 600;
  color: var(--ink);
}

.additional-answers {
  display: grid;
  gap: 3px;
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px dashed var(--line);
}

.additional-answer {
  font-size: 0.82rem;
  color: var(--muted);
}

.additional-question[hidden] {
  display: none;
}

.additional-multiselect,
.additional-rating {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-weight: 500;
}

.additional-checkbox,
.additional-radio {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-weight: 500;
}

.field-label {
  display: block;
  font-weight: 500;
  font-size: 0.85rem;
}

.field-hint {
  color: var(--muted);
  font-size: 0.78rem;
}

.setup-section-lede {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 0.9rem;
  max-width: 64ch;
}

/* Modal dialog (export scoping, etc.) */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(17, 24, 39, 0.4);
}

.modal-card {
  width: min(440px, 100%);
  display: grid;
  gap: 14px;
  padding: 22px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.modal-head h2 {
  flex: 1;
  min-width: 0;
  margin: 0;
  font-size: 1.15rem;
}

.modal-x {
  flex: none;
  display: grid;
  place-items: center;
  width: 34px;
  min-width: 34px;
  height: 34px;
  min-height: 0;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface);
  color: var(--muted);
  font-size: 0.9rem;
}

.modal-x:hover {
  color: var(--ink);
  background: var(--surface-2);
}

.export-dates {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.modal-card label {
  display: grid;
  gap: 6px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
}

.export-count {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
}

/* "Why is this disabled" notice for admin-gated forms */
.permission-notice {
  margin: 0 0 16px;
  padding: 10px 14px;
  border: 1px solid var(--passive-soft);
  border-left: 3px solid var(--passive);
  border-radius: var(--r);
  background: var(--passive-soft);
  color: var(--ink);
  font-size: 0.84rem;
  font-weight: 600;
}

.permission-notice[hidden] {
  display: none;
}

/* Top-right page auth control — clean, no surrounding pill */
.page-auth {
  position: fixed;
  top: 14px;
  right: 20px;
  z-index: 25;
  display: flex;
  align-items: center;
  gap: 10px;
}

.page-auth-avatar {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--accent-strong);
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: 0.85rem;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  padding: 0;
  cursor: pointer;
}

.page-auth-avatar.has-photo {
  background: var(--surface);
}

.page-auth-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Personal settings modal — profile photo row */
.profile-photo-row {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 4px;
}

.profile-photo-preview {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  flex: none;
  border-radius: 50%;
  overflow: hidden;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: 1.4rem;
  border: 1px solid var(--line);
}

.profile-photo-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.profile-photo-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.people-import {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  display: grid;
  gap: 10px;
}

.people-import-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

/* Scoped under .modal-card to beat the `.modal-card label { display: grid }` rule. */
.modal-card .profile-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--ink);
  cursor: pointer;
}

.modal-card .profile-toggle input {
  width: auto;
  min-height: 0;
  margin: 0;
}

.page-auth-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 26;
  display: grid;
  gap: 12px;
  width: 240px;
  max-width: calc(100vw - 32px);
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}

.page-auth-menu-head {
  display: grid;
  gap: 2px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.page-auth-menu-head strong {
  font-size: 0.86rem;
  overflow-wrap: anywhere;
}

.page-auth-menu-head small {
  color: var(--faint);
  font-size: 0.74rem;
}

.page-auth-menu-field {
  display: grid;
  gap: 5px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
}

.page-auth-menu .button {
  width: 100%;
}

/* A form directly in a plain panel has no gap to the block that follows it. */
.panel > .compact-form + * {
  margin-top: 16px;
}

.sidebar-auth-user {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  max-width: 200px;
}

.sidebar-auth-avatar {
  display: grid;
  place-items: center;
  flex: none;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-weight: 700;
  font-size: 0.8rem;
}

.sidebar-auth-meta {
  display: grid;
  min-width: 0;
  line-height: 1.25;
}

.sidebar-auth-meta strong {
  font-size: 0.82rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-auth-meta small {
  color: var(--faint);
  font-size: 0.72rem;
}

.sidebar-auth-btn {
  width: auto;
  min-height: 34px;
  padding: 6px 14px;
}

.page-auth-switcher {
  width: auto;
  min-width: 0;
  max-width: 180px;
  min-height: 34px;
  padding: 0 30px 0 12px;
  background-color: var(--surface);
  font-size: 0.84rem;
}

/* Period-over-period delta on the hero metric */
.hero-delta {
  display: block;
  margin-top: 4px;
  font-size: 0.8rem;
  font-weight: 700;
}

.hero-delta.up {
  color: var(--promoter);
}

.hero-delta.down {
  color: var(--detractor);
}

.hero-delta.flat {
  color: var(--muted);
}

.hero-goal {
  display: block;
  margin-top: 2px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
}

.hero-goal.met {
  color: var(--promoter);
}

/* Non-numeric metric scales (stars / smileys / thumbs) on the hosted survey */
.score-button.metric-stars,
.score-button.metric-smileys,
.score-button.metric-thumbs {
  font-size: 1.5rem;
  line-height: 1;
}

.score-button.metric-stars.selected,
.score-button.metric-stars:hover {
  color: var(--passive);
}

.compact-form,
.compact-field {
  display: grid;
  gap: 14px;
}

.account-disclosure,
.form-disclosure {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface-2);
}

.account-disclosure summary,
.form-disclosure summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 15px;
  cursor: pointer;
  list-style: none;
}

.account-disclosure summary::-webkit-details-marker,
.form-disclosure summary::-webkit-details-marker {
  display: none;
}

.account-disclosure summary::after,
.form-disclosure summary::after {
  content: "+";
  display: grid;
  place-items: center;
  flex: none;
  width: 28px;
  height: 28px;
  border: 1px solid var(--line-strong);
  border-radius: var(--pill);
  color: var(--accent-ink);
  background: var(--surface);
  font-weight: 800;
}

.account-disclosure[open] summary::after,
.form-disclosure[open] summary::after {
  content: "-";
}

.account-disclosure summary span,
.form-disclosure summary span {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.account-disclosure summary strong,
.form-disclosure summary strong {
  color: var(--ink);
  font-weight: 650;
}

.account-disclosure summary small,
.form-disclosure summary small {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 500;
  line-height: 1.4;
}

.account-disclosure-body,
.form-disclosure-body {
  display: grid;
  gap: 14px;
  padding: 0 15px 15px;
}

.account-disclosure:not([open]) > :not(summary),
.form-disclosure:not([open]) > :not(summary) {
  display: none;
}

.account-admin-disclosure {
  break-inside: avoid;
  margin: 0 0 24px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.account-admin-disclosure > summary {
  padding: 18px 20px;
}

.account-admin-stack {
  display: grid;
  gap: 18px;
  padding: 0 20px 20px;
}

.account-admin-stack .account-section {
  margin: 0;
  background: var(--surface-2);
  box-shadow: none;
}

.compact-form .form-actions {
  gap: 12px;
}

.auth-capability-row {
  align-items: flex-start;
}

.auth-capability-row > div:first-child {
  gap: 7px;
}

.auth-capability-side,
.auth-capability-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
}

.auth-capability-side {
  max-width: 100%;
}

.auth-inline-input {
  width: 138px;
  min-height: 30px;
  padding: 6px 9px;
  font-size: 0.82rem;
}

.auth-mfa-setup {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 4px;
}

.auth-mfa-setup img {
  width: 132px;
  height: 132px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: #fff;
}

.auth-mfa-setup code {
  max-width: min(320px, 100%);
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface-2);
  color: var(--ink);
  font-size: 0.78rem;
  overflow-wrap: anywhere;
}

.auth-error-text {
  color: var(--detractor);
  font-size: 0.8rem;
  font-weight: 600;
}

#delightedImportForm .form-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.import-preview {
  display: grid;
  gap: 16px;
  margin-top: 4px;
}

.import-preview-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.import-preview-card {
  display: grid;
  gap: 6px;
  min-height: 106px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface-2);
}

.import-preview-card span,
.import-preview-card small {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 650;
}

.import-preview-card strong {
  min-width: 0;
  color: var(--ink);
  font-size: 1.15rem;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.import-preview-table table {
  min-width: 680px;
}

.import-preview-table td:last-child {
  max-width: 320px;
}

.import-issue-list {
  margin-top: 0;
}

.role-list,
.project-list,
.account-checklist,
.parity-grid {
  display: grid;
  gap: 12px;
}

.preference-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  align-items: start;
}

.preference-toggle {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  align-items: start;
  gap: 12px;
  min-height: 86px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface-2);
}

.preference-toggle input {
  width: 16px;
  height: 16px;
  margin-top: 2px;
  accent-color: var(--accent);
}

.preference-toggle span {
  display: grid;
  gap: 4px;
}

.preference-toggle strong {
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 650;
}

.preference-toggle small {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 500;
  line-height: 1.4;
}

.notification-project-routing {
  gap: 14px;
}

.notification-project-route > div {
  display: grid;
  gap: 12px;
}

.integration-checklist {
  display: grid;
  gap: 14px;
}

.integration-checklist-header,
.integration-checklist-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface-2);
}

.integration-checklist-header > div {
  display: grid;
  gap: 4px;
}

.integration-checklist-header strong,
.integration-checklist-item strong {
  color: var(--ink);
  font-weight: 650;
}

.integration-checklist-header span,
.integration-checklist-item small {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 500;
  line-height: 1.4;
}

.integration-checklist-items {
  display: grid;
  gap: 10px;
}

.integration-checklist-item {
  justify-content: flex-start;
  align-items: flex-start;
  min-height: 74px;
}

.integration-checklist-item input {
  width: 17px;
  height: 17px;
  margin-top: 2px;
  accent-color: var(--accent);
}

.integration-checklist-item span {
  display: grid;
  gap: 4px;
}

.route-field {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.audit-controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  align-items: start;
}

.audit-controls .button {
  align-self: end;
  min-height: 42px;
}

.audit-archive-summary {
  min-height: 34px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  color: var(--muted);
  background: var(--surface-2);
  font-size: 0.82rem;
  font-weight: 600;
}

.audit-details {
  margin-top: 6px;
}

.audit-details summary {
  width: max-content;
  cursor: pointer;
  color: var(--accent-ink);
  font-size: 0.8rem;
  font-weight: 700;
}

.audit-details pre {
  overflow: auto;
  max-height: 160px;
  margin: 8px 0 0;
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface-2);
  color: var(--text);
  font-size: 0.76rem;
  line-height: 1.5;
}

.role-row,
.project-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  padding: 17px 18px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface-2);
  transition: border-color 140ms ease, background 140ms ease;
}

.role-row:hover,
.project-row:hover {
  border-color: var(--line-strong);
  background: var(--surface);
}

.project-row.is-loading {
  opacity: 0.6;
}

/* Activity feed (the Activity page) */
.activity-feed {
  display: grid;
  gap: 2px;
}

.activity-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 4px;
  border-bottom: 1px solid var(--line);
  font-size: 0.9rem;
}

.activity-row:last-child {
  border-bottom: none;
}

.activity-row.is-loading {
  opacity: 0.6;
}

.activity-dot {
  flex: none;
  width: 8px;
  height: 8px;
  margin-top: 7px;
  border-radius: 50%;
  background: var(--accent);
}

/* Avatar chips in the team roster + activity feed */
.role-row .member-identity {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.role-row .member-identity > div {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.member-avatar,
.activity-avatar {
  flex: none;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: 0.85rem;
  border: 1px solid var(--line);
}

.activity-avatar {
  width: 30px;
  height: 30px;
  font-size: 0.78rem;
  margin-top: 1px;
}

.member-avatar.has-photo,
.activity-avatar.has-photo {
  background: var(--surface);
}

.member-avatar img,
.activity-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.activity-row strong {
  color: var(--ink);
  font-weight: 650;
}

.activity-verb {
  color: var(--text);
}

.activity-detail {
  color: var(--ink);
  font-weight: 600;
}

.activity-time {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.78rem;
}

.role-row > div,
.project-row > div {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.section-heading-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.account-section > .section-heading-row h3 {
  padding-bottom: 0;
  border-bottom: 0;
}

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

.inline-actions select {
  width: auto;
  min-width: 112px;
  min-height: 34px;
  padding-inline: 10px 30px;
  font-size: 0.82rem;
}

.role-row strong,
.project-row strong {
  color: var(--ink);
  font-weight: 650;
}

.role-row span,
.project-row span,
.account-checklist,
.parity-grid span {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 500;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.role-row > .score-chip,
.role-row > .status-chip,
.project-row > .score-chip,
.project-row > .status-chip {
  margin-top: 1px;
}

.account-checklist {
  margin: 0;
  padding-left: 20px;
  gap: 10px;
}

.account-checklist li {
  color: var(--text);
  line-height: 1.5;
}

/* The setup-status checklist is its own labeled block, divided from the
   adapter list above it so it doesn't read as part of "Available providers". */
.integration-gap-block {
  margin-top: 22px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.integration-gap-block .eyebrow {
  margin: 0 0 12px;
}

.parity-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.parity-grid > div {
  display: grid;
  gap: 6px;
  padding: 15px 16px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface-2);
}

.parity-grid strong {
  color: var(--ink);
  font-weight: 650;
}

/* =========================================================================
   Toast
   ========================================================================= */

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 30;
  max-width: min(420px, calc(100vw - 40px));
  padding: 13px 16px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: var(--r);
  color: var(--ink);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  font-weight: 600;
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition:
    opacity 180ms ease,
    transform 180ms ease;
}

.toast.visible {
  opacity: 1;
  transform: translateY(0);
}

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

@media (max-width: 1180px) {
  .topbar {
    position: sticky;
    inset: 0 auto auto 0;
    flex-direction: row;
    align-items: center;
    width: auto;
    min-height: 56px;
    max-height: none;
    padding: 12px clamp(14px, 3vw, 30px) 10px;
    overflow: visible;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(12px);
    box-shadow: var(--shadow-xs);
  }

  .topbar {
    flex-wrap: wrap;
  }

  .brand {
    width: auto;
    min-width: 0;
    flex: 1 1 auto;
    padding: 0;
    margin: 0;
    border-bottom: 0;
  }

  .brand span:last-child::after,
  .topnav::before {
    display: none;
  }

  .top-actions {
    flex-direction: row;
    flex: none;
    width: auto;
    margin: 0 0 0 auto;
    padding-top: 0;
    border-top: 0;
  }

  .top-actions .button,
  .top-actions .icon-button,
  .icon-button {
    width: auto;
  }

  main {
    width: min(1480px, 100%);
    margin: 0 auto;
    padding: 28px clamp(18px, 3vw, 34px) 58px;
  }

  .workspace-header,
  .slack-layout,
  .setup-layout,
  .setup-focus-grid,
  .account-summary-grid,
  .dashboard-grid,
  .workbench,
  .survey-builder-layout {
    grid-template-columns: 1fr;
  }

  .account-layout {
    column-count: 1;
  }

  .metric-grid,
  .followup-case-grid,
  .import-preview-grid,
  .stat-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .hero-metric {
    grid-column: 1 / -1;
  }

  .workspace-header {
    align-items: start;
    margin-bottom: 0;
  }

  .dashboard-grid > .panel {
    grid-column: 1 / -1;
  }

  .ops-status-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .topnav {
    flex-direction: row;
    gap: 5px;
    order: 3;
    width: calc(100% + clamp(24px, 6vw, 56px));
    margin: 2px calc(clamp(12px, 3vw, 28px) * -1) 0;
    padding: 0 clamp(12px, 3vw, 28px) 5px;
    border-radius: 0;
    background: transparent;
    scrollbar-width: none;
    overflow-x: auto;
  }

  .topnav::-webkit-scrollbar {
    display: none;
  }

  /* Flatten the grouped sidebar into the horizontal pill row on mobile:
     the group wrappers dissolve so links become direct flex children. */
  .nav-group {
    display: contents;
  }

  .nav-group-label {
    display: none;
  }

  .topnav a {
    flex: 0 0 auto;
    min-height: 32px;
    padding: 6px 10px;
    border: 1px solid var(--line);
    background: var(--surface);
    font-size: 0.82rem;
    white-space: nowrap;
  }

  .topnav a.active {
    border-color: var(--accent);
  }

  .nav-ico {
    display: none;
  }

  .page-auth {
    top: 10px;
    right: 12px;
    padding: 4px;
  }

  .sidebar-auth-user {
    display: none;
  }

  .sidebar-auth-btn {
    min-height: 32px;
    padding: 5px 12px;
    font-size: 0.82rem;
  }

  .topnav a.active::before {
    display: none;
  }

  .slack-panel,
  .setup-panel,
  .account-panel,
  .responses-panel,
  .builder-preview {
    scroll-margin-top: 88px;
  }

  .builder-preview {
    position: static;
  }
}

@media (max-width: 760px) {
  :root {
    --section-gap: 26px;
    --panel-pad: 18px;
  }

  main {
    padding-top: 18px;
  }

  .topbar {
    gap: 7px;
    padding: 9px 12px 8px;
  }

  .top-actions {
    display: none;
  }

  .brand {
    min-width: 0;
  }

  .brand span:last-child {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .icon-button span:last-child {
    display: none;
  }

  .filters,
  .form-grid,
  .builder-control-grid,
  .logo-upload-row,
  .logo-meta-grid {
    grid-template-columns: 1fr;
  }

  .filters {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    padding: 12px;
  }

  .filters label {
    gap: 5px;
    font-size: 0.74rem;
  }

  .filters select {
    min-height: 36px;
  }

  .workspace-header {
    gap: 16px;
    padding-bottom: 0;
  }

  .workspace-header h1 {
    margin-bottom: 6px;
  }

  .lede {
    font-size: 0.9rem;
  }

  .metric-grid {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    overflow-y: hidden;
    margin-right: calc(clamp(18px, 3vw, 34px) * -1);
    padding: 0 clamp(18px, 3vw, 34px) 6px 0;
    scroll-snap-type: x proximity;
    scrollbar-gutter: stable;
  }

  .account-summary-grid {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    overflow-y: hidden;
    margin-right: calc(clamp(18px, 3vw, 34px) * -1);
    padding: 0 clamp(18px, 3vw, 34px) 6px 0;
    scrollbar-gutter: stable;
  }

  .account-summary-item {
    flex: 0 0 min(240px, 78vw);
    min-height: 128px;
  }

  .metric-card {
    flex: 0 0 min(188px, 72vw);
    min-height: 118px;
    padding: 16px;
    scroll-snap-align: start;
  }

  .hero-metric {
    flex-basis: min(230px, 78vw);
  }

  .builder-tabs {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
    border-bottom: 0;
  }

  .builder-tab {
    min-height: 38px;
    padding: 0 10px;
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    font-size: 0.88rem;
  }

  .builder-tab.active {
    color: var(--blue);
    border-color: color-mix(in srgb, var(--blue) 35%, transparent);
    background: color-mix(in srgb, var(--blue) 10%, var(--surface));
  }

  .preview-header-row {
    grid-template-columns: 1fr;
  }

  .preview-header-row span {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .builder-snippet-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .ops-status-grid,
  .setup-checklist-grid,
  .import-preview-grid,
  .parity-grid,
  .preference-grid,
  .audit-controls,
  .endpoint-row,
  .credential-row {
    grid-template-columns: 1fr;
    min-width: 0;
    width: 100%;
  }

  .ops-status-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .ops-status-item {
    min-height: 0;
    gap: 8px;
    padding: 12px;
  }

  .ops-status-item small {
    display: none;
  }

  .ops-status-item:last-child {
    grid-column: 1 / -1;
  }

  .endpoint-row > *,
  .credential-row > * {
    min-width: 0;
  }

  .score-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }

  .preview-score-row {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }

  .slack-feed {
    padding: 18px 14px;
  }

  .slack-message {
    grid-template-columns: 1fr;
    gap: 5px;
  }

  .slack-message time {
    text-align: left;
  }

  .panel-header {
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
  }

  .responses-panel .panel-header {
    margin-bottom: 16px;
  }

  .search-label {
    width: 100%;
  }

  .table-wrap {
    max-height: 58vh;
    border-radius: var(--r);
  }

  table {
    min-width: 940px;
  }

  th,
  td {
    padding: 12px 14px;
  }
}

@media (max-width: 520px) {
  :root {
    --section-gap: 20px;
    --panel-pad: 15px;
  }

  .topbar {
    gap: 8px;
  }

  .brand span:last-child {
    display: none;
  }

  .top-actions .button {
    display: none;
  }

  .workspace-header h1 {
    font-size: 1.65rem;
  }

  .metric-grid {
    gap: 12px;
  }

  .followup-case-grid {
    grid-template-columns: 1fr;
  }

  .metric-card {
    min-height: 110px;
    padding: 15px;
  }

  .metric-card strong {
    font-size: 1.55rem;
  }

  .hero-metric strong {
    font-size: 2.15rem;
  }

  .score-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition: none !important;
  }
}
