/* MechanicBazaar Lead Console. Brand colours from mechanicbazaar.com. */
:root {
  color-scheme: light;
  --navy: #062138;
  --navy-2: #0a2c4a;
  --navy-3: #133b5e;
  --blue: #02406f;
  --blue-2: #00508a;
  /* --orange is for accents only (bars, underlines). White text sits on --orange-2 (4.8:1)
     or --orange-3 (6.4:1); --orange-3 is also the orange for text on light tints. */
  --orange: #e55b25;
  --orange-2: #c9461a;
  --orange-3: #a83a14;
  --orange-soft: #fdeee6;
  --bg: #f4f6fa;
  --surface: #ffffff;
  --line: #e4e9f0;
  --line-2: #d3dbe5;
  --text: #0f1f2e;
  --muted: #5d6d7e;
  --faint: #617083;
  /* Focus ring: 3:1 or more against white, --bg and the chat background; a light ring on navy. */
  --focus: #00508a;
  --focus-on-dark: #7cc4ff;
  --hot: #dc2626;
  --hot-soft: #fee2e2;
  --message-alert: #b42318;
  --message-alert-dark: #912018;
  --message-alert-soft: #fff1ee;
  --warm: #b45309;
  --warm-soft: #fef3c7;
  --cold: #2563eb;
  --cold-soft: #dbeafe;
  --green: #15803d;
  --green-soft: #dcfce7;
  --gray-soft: #eef2f6;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(6, 33, 56, .06), 0 4px 16px rgba(6, 33, 56, .05);
  --font: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { background: var(--bg); }
body { margin: 0; min-height: 100vh; color: var(--text); font: 14px/1.5 var(--font); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--blue-2); text-decoration: none; }
a:hover { text-decoration: underline; }
code { padding: 1px 6px; border-radius: 5px; color: var(--navy-3); background: var(--gray-soft); font: 12px var(--mono); }
h1, h2, h3 { margin: 0; color: var(--navy); line-height: 1.25; }
p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .5; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.sidebar :focus-visible, .toast :focus-visible { outline-color: var(--focus-on-dark); }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); border: 0; white-space: nowrap; }
.skip-link {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 100;
  padding: 10px 16px;
  border-radius: 8px;
  color: #fff;
  background: var(--navy);
  font-weight: 700;
  transform: translateY(-200%);
}
.skip-link:focus { transform: none; text-decoration: none; }
/* White ring next to the navy link, blue ring outside it: visible on the sidebar and on light pages. */
.skip-link:focus-visible { outline: 3px solid #fff; outline-offset: 0; box-shadow: 0 0 0 6px var(--focus); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.block { display: block; }
.eyebrow { color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.eyebrow.on-dark { color: #f7a37f; }

input:not([type="checkbox"]), select, textarea {
  width: 100%;
  min-height: 38px;
  padding: 8px 11px;
  border: 1px solid var(--line-2);
  border-radius: 8px;
  background: var(--surface);
  transition: border-color .15s, box-shadow .15s;
}
textarea { resize: vertical; min-height: 76px; }
/* Text fields: blue border plus a 2px outline. Checkboxes and switches keep the :focus-visible ring. */
input:not([type="checkbox"]):not([type="radio"]):focus, select:focus, textarea:focus { border-color: var(--focus); outline: 2px solid var(--focus); outline-offset: 0; }
input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--orange-2); }

/* ---- Buttons ------------------------------------------------------------------ */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 38px;
  padding: 8px 14px;
  border: 1px solid var(--line-2);
  border-radius: 8px;
  color: var(--navy);
  background: var(--surface);
  font-weight: 600;
  white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s;
}
.button:hover:not(:disabled) { border-color: var(--blue-2); color: var(--blue-2); text-decoration: none; }
.button.primary { border-color: var(--orange-2); color: #fff; background: var(--orange-2); }
.button.primary:hover:not(:disabled) { border-color: var(--orange-3); color: #fff; background: var(--orange-3); }
.button.primary-outline { border-color: var(--orange); color: var(--orange-2); }
.button.primary-outline:hover:not(:disabled) { border-color: var(--orange-2); color: #fff; background: var(--orange-2); }
.small-button { min-height: 32px; padding: 5px 10px; font-size: 13px; }
.plain-button { padding: 0; border: 0; background: none; }
.button.block { width: 100%; }
.icon-button {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line-2);
  border-radius: 8px;
  color: var(--navy);
  background: var(--surface);
}
.icon-button:hover { border-color: var(--blue-2); color: var(--blue-2); }
.icon-button.spinning svg { animation: spin .8s linear infinite; }
.link-button { color: var(--blue-2); font-size: 13px; font-weight: 600; }
.button-row { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---- Pills, badges, tags ------------------------------------------------------ */
.pill { display: inline-flex; align-items: center; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.pill.neutral { color: #475569; background: var(--gray-soft); }
.pill.info { color: #1e40af; background: #e0eaff; }
.pill.success { color: var(--green); background: var(--green-soft); }
.pill.warning { color: var(--warm); background: var(--warm-soft); }
.pill.danger { color: #b91c1c; background: var(--hot-soft); }
.quality { display: inline-flex; align-items: center; gap: 5px; padding: 2px 4px 2px 8px; border-radius: 6px; font-size: 11px; font-weight: 800; letter-spacing: .04em; }
.quality b { padding: 1px 6px; border-radius: 4px; background: rgba(255, 255, 255, .75); font-size: 12px; letter-spacing: 0; }
.quality.hot { color: #b91c1c; background: var(--hot-soft); }
.quality.warm { color: var(--warm); background: var(--warm-soft); }
.quality.cold { color: #1d4ed8; background: var(--cold-soft); }
.quality.ineligible, .quality.open { padding-right: 8px; color: #526073; background: var(--gray-soft); }
.quality.ineligible b, .quality.open b { display: none; }
.source-tag { display: inline-block; padding: 1px 8px; border: 1px solid var(--line-2); border-radius: 6px; color: var(--muted); font-size: 12px; font-weight: 600; white-space: nowrap; }
.source-tag.meta_lead_ad { border-color: #c7d7fe; color: #1e40af; background: var(--surface-soft); }
.source-tag.meta_click_to_whatsapp { border-color: #bbf7d0; color: var(--green); background: var(--surface-soft); }
.source-tag.simulator { border-style: dashed; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px; color: var(--navy-3); background: var(--gray-soft); font-size: 12px; font-weight: 600; }
.muted-chip { color: var(--muted); font-weight: 500; }
.avatar {
  display: inline-grid;
  flex: 0 0 auto;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  color: #fff;
  background: var(--navy-3);
  font-size: 13px;
  font-weight: 700;
}
.avatar.hot { background: var(--hot); }
.avatar.warm { background: var(--warm); }
.avatar.cold { background: var(--cold); }
.avatar.ineligible { background: #64748b; }
.avatar.agent { background: var(--orange-2); }

.notice { display: flex; align-items: flex-start; gap: 8px; margin-top: 12px; padding: 10px 12px; border-radius: 8px; font-size: 13px; }
.notice svg { flex: 0 0 auto; margin-top: 2px; }
.notice.warning { color: #7c4a03; background: var(--warm-soft); }
.notice.danger { color: #991b1b; background: var(--hot-soft); }
.form-error { margin: 4px 0 0; color: #b91c1c; font-size: 13px; }

/* ---- Login -------------------------------------------------------------------- */
.login-screen { display: grid; grid-template-columns: minmax(320px, 1.05fr) minmax(320px, 1fr); min-height: 100vh; }
.login-brand {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 44px 56px;
  color: #dbe6f1;
  background:
    radial-gradient(circle at 85% 15%, rgba(229, 91, 37, .28), transparent 42%),
    linear-gradient(160deg, var(--navy) 0%, #031424 100%);
}
.login-logo { width: 232px; height: auto; }
.login-pitch { max-width: 480px; }
.login-pitch h1 { margin: 12px 0 28px; color: #fff; font-size: 32px; font-weight: 800; letter-spacing: -.02em; }
.login-steps { display: grid; gap: 14px; margin: 0; padding: 0; list-style: none; font-size: 15px; }
.login-steps li { display: flex; align-items: center; gap: 12px; }
.login-steps span { display: inline-grid; flex: 0 0 auto; place-items: center; width: 28px; height: 28px; border-radius: 50%; color: #fff; background: var(--orange-2); font-weight: 700; }
.login-foot { color: #8fa6bb; }
.login-panel { display: grid; place-items: center; padding: 32px; }
.login-card { display: grid; gap: 12px; width: min(400px, 100%); padding: 32px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); box-shadow: var(--shadow); }
.login-card h2 { font-size: 24px; }
.login-card p { color: var(--muted); }
.login-card label { margin-top: 6px; color: var(--navy); font-weight: 600; }
.login-mark { border-radius: 12px; }

/* ---- App shell ---------------------------------------------------------------- */
.app { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  height: 100vh;
  padding: 22px 14px 16px;
  color: #c8d6e3;
  background: var(--navy);
  overflow-y: auto;
}
.sidebar-logo { display: block; padding: 0 8px; }
.sidebar-logo img { width: 168px; height: auto; }
.sidebar-product { margin: 2px 8px 18px; color: #f7a37f; font-size: 11px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }
.nav { display: grid; gap: 2px; }
.nav-link { display: flex; align-items: center; gap: 11px; padding: 9px 10px; border-radius: 8px; color: #c8d6e3; font-weight: 500; }
.nav-link:hover { color: #fff; background: rgba(255, 255, 255, .06); text-decoration: none; }
.nav-link.active { color: #fff; background: var(--navy-3); box-shadow: inset 3px 0 0 var(--orange); }
.nav-icon { display: inline-grid; place-items: center; }
.nav-badge { margin-left: auto; min-width: 22px; padding: 1px 7px; border-radius: 999px; color: #fff; background: var(--orange-2); font-size: 11px; font-weight: 700; text-align: center; }
.nav-badge.warn { color: #3d2600; background: #fbbf24; }
.nav-badge.whatsapp-badge, .pill.message-count { color: #fff; background: var(--message-alert); font-weight: 800; }
.nav-badge.whatsapp-badge { box-shadow: 0 0 0 2px #fff; }
.nav-badge.whatsapp-badge + .nav-badge { margin-left: 6px; }
.message-alerts { padding: 18px 22px; border: 1px solid #f0b8b0; border-left: 5px solid var(--message-alert); border-radius: 12px; background: var(--message-alert-soft); margin-bottom: 18px; }
.message-alert-heading { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.message-alert-heading > svg, .message-alert-heading > strong { color: var(--message-alert-dark); }
.message-alert-heading > a { margin-left: auto; }
.message-alert-heading > a { color: var(--message-alert-dark); text-decoration: underline; }
.message-alert-links { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.message-alert-link { display: inline-flex; align-items: center; gap: 10px; padding: 8px 12px; border: 1px solid #e8aaa0; border-radius: 8px; background: var(--surface); text-decoration: none; color: var(--text); }
.message-alert-link:hover { border-color: var(--message-alert); background: var(--surface-soft); }
.button.message-filter { border-color: var(--message-alert); color: var(--message-alert-dark); }
.button.message-filter:hover, .button.message-filter.active { color: #fff; background: var(--message-alert); border-color: var(--message-alert); }
.button.message-filter:hover .message-count, .button.message-filter.active .message-count { color: var(--message-alert-dark); background: var(--surface); }
.button.pending-filter { border-color: var(--orange-3); color: var(--orange-3); }
.button.pending-filter:hover, .button.pending-filter.active { color: #fff; background: var(--orange-3); border-color: var(--orange-3); }
.unread-message-badge { margin: 4px 0 2px; }
.leads-table tr.has-unread { background: var(--message-alert-soft); }
.leads-table tr.has-unread > td:first-child { box-shadow: inset 4px 0 0 var(--message-alert); }
.leads-table tr.has-unread.clickable:hover td, .leads-table tr.has-unread.clickable:focus-within td { background: #ffe4de; }
.sidebar-status { display: grid; gap: 8px; margin-top: auto; padding: 14px 12px; border-radius: 10px; background: rgba(255, 255, 255, .05); font-size: 12px; }
.status-row { display: flex; align-items: center; gap: 8px; min-width: 0; }
.status-row > span:not(.dot) { flex: 0 0 auto; }
.status-row strong { min-width: 0; margin-left: auto; overflow: hidden; color: #fff; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.dot { flex: 0 0 auto; width: 8px; height: 8px; border-radius: 50%; background: #64748b; }
.dot.idle { background: #94a3b8; }
.dot.ok { background: #22c55e; box-shadow: 0 0 0 3px rgba(34, 197, 94, .2); }
.dot.warn { background: #fbbf24; }
.dot.off { background: #f87171; }
.sidebar-signout { display: flex; align-items: center; gap: 11px; margin-top: 8px; padding: 9px 10px; border: 0; border-radius: 8px; color: #c8d6e3; background: none; text-align: left; }
.sidebar-signout:hover { color: #fff; background: rgba(255, 255, 255, .06); }

.workspace { min-width: 0; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(244, 246, 250, .92);
  backdrop-filter: blur(8px);
}
.menu-toggle { display: none; }
.topbar-title { min-width: 0; }
.topbar-title h1 { overflow: hidden; font-size: 21px; font-weight: 750; text-overflow: ellipsis; white-space: nowrap; }
.topbar-title p { color: var(--muted); font-size: 13px; }
.topbar-tools { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.select-inline select { min-width: 150px; }
.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; font-size: 13px; font-weight: 600; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
/* Track off #7b8a9c (3.5:1 on white) and on --orange-2 (4.8:1), so both states are visible parts. */
.switch-track { position: relative; flex: 0 0 auto; width: 36px; height: 20px; border-radius: 999px; background: #7b8a9c; transition: background .15s; }
.switch-track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--surface); box-shadow: 0 1px 2px rgba(0, 0, 0, .2); transition: transform .15s; }
.switch input:checked + .switch-track { background: var(--orange-2); }
.switch input:checked + .switch-track::after { transform: translateX(16px); }
.switch input:focus-visible + .switch-track { outline: 3px solid var(--focus); outline-offset: 2px; }
.switch input:disabled + .switch-track { opacity: .6; }
.updated { color: var(--faint); font-size: 12px; white-space: nowrap; }
.setup-banner { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin: 16px 28px 0; padding: 10px 14px; border: 1px solid #fcd34d; border-radius: 10px; color: #6b4100; background: #fffbeb; font-size: 13px; }
.setup-banner a { font-weight: 700; }
.banner-close { display: inline-grid; place-items: center; margin-left: auto; padding: 4px; border: 0; border-radius: 6px; color: inherit; background: none; }
.banner-close:hover { background: rgba(0, 0, 0, .06); }

.content { padding: 22px 28px 40px; outline: none; }
.page { display: grid; gap: 18px; max-width: 1480px; margin: 0 auto; }
.page.loading { min-height: 50vh; }
.loading-bar { height: 3px; overflow: hidden; border-radius: 3px; background: var(--line); }
.loading-bar::after { content: ""; display: block; width: 35%; height: 100%; background: var(--orange); animation: loading 1s ease-in-out infinite; }

/* ---- Cards & grids ------------------------------------------------------------ */
.card { min-width: 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.card-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 16px 18px 0; }
.card-header h2 { font-size: 15px; font-weight: 700; }
.card-header p { margin-top: 2px; color: var(--muted); font-size: 12.5px; }
.card-actions { display: flex; flex: 0 0 auto; align-items: center; gap: 8px; }
.card-body { padding: 16px 18px 18px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.span-2 { grid-column: span 2; }
.grid-2 > .span-2, .page > .span-2 { grid-column: auto; }
.stack { display: grid; align-content: start; gap: 18px; min-width: 0; }
.error-card .card-body { display: grid; justify-items: center; gap: 10px; padding: 48px 20px; text-align: center; }
.error-icon { color: var(--hot); }
.danger-card { border-color: #fecaca; }
.help-card .help-steps { display: grid; gap: 8px; margin: 0; padding-left: 20px; color: var(--muted); }

.empty { display: grid; justify-items: center; gap: 6px; padding: 30px 16px; color: var(--muted); text-align: center; }
.empty strong { color: var(--navy); }
.empty p { max-width: 360px; font-size: 13px; }
.empty .button { margin-top: 8px; }
.empty-icon { display: inline-grid; place-items: center; width: 52px; height: 52px; margin-bottom: 4px; border-radius: 50%; color: var(--faint); background: var(--gray-soft); }

/* ---- KPIs --------------------------------------------------------------------- */
.kpi-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 14px; }
.kpi-grid.compact { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.kpi { display: grid; align-content: start; gap: 4px; padding: 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.kpi-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.kpi-label { color: var(--muted); font-size: 12.5px; font-weight: 600; }
.kpi-icon { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 8px; color: var(--blue-2); background: var(--surface-soft); }
.kpi-value { color: var(--navy); font-size: 28px; font-weight: 800; letter-spacing: -.02em; line-height: 1.15; }
.kpi-sub { color: var(--muted); font-size: 12px; }
.kpi.hot .kpi-icon { color: var(--hot); background: var(--hot-soft); }
.kpi.hot .kpi-value { color: var(--hot); }
.kpi.success .kpi-icon { color: var(--green); background: var(--green-soft); }
.kpi.success .kpi-value { color: var(--green); }
.kpi.warning { border-color: #fcd34d; }
.kpi.warning .kpi-icon { color: var(--warm); background: var(--warm-soft); }
.delta { margin-top: 2px; font-size: 11.5px; font-weight: 600; }
.delta.up { color: var(--green); }
.delta.down { color: #b91c1c; }
.delta.flat { color: var(--faint); }

/* ---- Attention list ------------------------------------------------------------ */
.attention-list { display: grid; gap: 8px; }
.attention-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; color: var(--text); }
.attention-item:hover { border-color: var(--blue-2); text-decoration: none; }
.attention-count { min-width: 44px; padding: 4px 0; border-radius: 8px; font-size: 18px; text-align: center; }
.attention-copy { display: grid; flex: 1; }
.attention-copy b { color: var(--navy); font-size: 13.5px; }
.attention-copy small { color: var(--muted); font-size: 12px; }
.attention-item svg { color: var(--faint); }
.attention-item.warning .attention-count { color: var(--warm); background: var(--warm-soft); }
.attention-item.danger .attention-count { color: #b91c1c; background: var(--hot-soft); }
/* "All clear" rows are quieter without opacity, which used to drop the text below 4.5:1. */
.attention-item.clear { border-style: dashed; }
.attention-item.clear .attention-copy b { color: var(--muted); font-weight: 600; }
.attention-item.clear .attention-count { color: var(--green); background: var(--green-soft); }

/* ---- Charts ------------------------------------------------------------------- */
.chart { display: block; width: 100%; height: auto; }
.chart .grid { stroke: #edf1f5; }
.chart .axis { stroke: var(--line-2); }
.chart .tick { fill: var(--faint); font-size: 11px; }
.chart .bar-hit { fill: transparent; }
.chart .bar-group:hover .bar-hit { fill: rgba(6, 33, 56, .04); }
.legend { display: flex; flex-wrap: wrap; gap: 8px 18px; margin: 12px 0 0; padding: 0; list-style: none; font-size: 12.5px; }
.legend li { display: flex; align-items: center; gap: 6px; color: var(--muted); }
.legend strong { color: var(--navy); }
.legend .legend-title { font-weight: 600; }
.chart-table-wrap:not(.sr-only) { margin-top: 12px; overflow-x: auto; }
.chart-table caption { padding-bottom: 6px; color: var(--muted); font-size: 12px; text-align: left; }
.chart-table th[scope="row"] { color: var(--navy); font-weight: 600; text-align: left; white-space: nowrap; }
.swatch { width: 10px; height: 10px; border-radius: 3px; }
.donut-wrap { display: grid; justify-items: center; gap: 4px; }
.donut { width: min(200px, 100%); height: auto; }
.donut-value { fill: var(--navy); font-size: 30px; font-weight: 800; }
.donut-label { fill: var(--faint); font-size: 12px; }
.donut-wrap .legend { justify-content: center; }
.funnel { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.funnel li { display: grid; grid-template-columns: minmax(150px, 1.2fr) 2fr; align-items: center; gap: 2px 14px; }
.funnel-label { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; }
.funnel-label strong { color: var(--navy); }
.funnel-track { height: 12px; overflow: hidden; border-radius: 6px; background: var(--gray-soft); }
.funnel-bar { display: block; height: 100%; border-radius: 6px; background: linear-gradient(90deg, var(--blue-2), var(--orange)); }
.funnel-rate { grid-column: 2; color: var(--faint); font-size: 11.5px; }
.meter { display: block; width: 100%; height: 6px; overflow: hidden; border-radius: 999px; background: var(--gray-soft); }
.meter > span { display: block; height: 100%; border-radius: inherit; background: var(--blue-2); }
.meter.warning > span { background: #f59e0b; }
.meter.danger > span { background: var(--hot); }
.score-ring { width: 112px; height: 112px; flex: 0 0 auto; }
.score-value { fill: var(--navy); font-size: 30px; font-weight: 800; }
.score-max { fill: var(--faint); font-size: 11px; }

/* ---- Tables ------------------------------------------------------------------- */
.table-scroll { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th { padding: 9px 12px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 12px; font-weight: 600; text-align: left; white-space: nowrap; }
.table td { padding: 11px 12px; border-bottom: 1px solid #eef2f6; vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table.compact th, .table.compact td { padding: 7px 8px; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table tr.clickable { cursor: pointer; }
/* Rows are opened through the name link (the tab stop); the row shows where focus is. */
.table tr.clickable:hover td, .table tr.clickable:focus-within td { background: var(--surface-soft); }
.table tr.clickable:focus-visible { outline: 3px solid var(--focus); outline-offset: -3px; }
.lead-link { min-width: 0; overflow: hidden; color: var(--navy); font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.lead-link:hover, .lead-link:focus-visible { color: var(--blue-2); text-decoration: underline; }
.hidden-contact { font-style: italic; }
.person { display: flex; align-items: center; gap: 10px; min-width: 0; }
.person > div { display: grid; min-width: 0; }
.person strong { overflow: hidden; color: var(--navy); text-overflow: ellipsis; white-space: nowrap; }
.person small { color: var(--muted); font-size: 12px; }
.person.large .avatar { width: 44px; height: 44px; font-size: 15px; }
.table .person { min-width: 150px; }
.load-cell { display: grid; grid-template-columns: 80px auto; align-items: center; gap: 8px; }
.load-cell small { color: var(--muted); }

/* ---- Feeds & timelines -------------------------------------------------------- */
.feed { display: grid; gap: 12px; margin: 0; padding: 0; list-style: none; }
.feed li { display: grid; grid-template-columns: 10px 1fr; gap: 10px; }
.feed p { font-size: 13px; }
.feed small { color: var(--faint); font-size: 12px; }
.feed-dot, .timeline-dot { width: 9px; height: 9px; margin-top: 6px; border-radius: 50%; background: #94a3b8; }
.feed-dot.info, .timeline-dot.info { background: var(--cold); }
.feed-dot.success, .timeline-dot.success { background: #22c55e; }
.feed-dot.warning, .timeline-dot.warning { background: #f59e0b; }
.feed-dot.danger, .timeline-dot.danger { background: var(--hot); }
.timeline { display: grid; margin: 0; padding: 0; list-style: none; }
.timeline-item { position: relative; display: grid; grid-template-columns: 14px 1fr; gap: 12px; padding-bottom: 16px; }
.timeline-item::before { content: ""; position: absolute; top: 16px; bottom: 0; left: 4px; width: 1px; background: var(--line); }
.timeline-item:last-child::before { display: none; }
.timeline-body p { font-size: 13.5px; }
.timeline-body small { color: var(--faint); font-size: 12px; }
.timeline.compact .timeline-item { padding-bottom: 12px; }
.strong-link { font-weight: 700; }
.load-more { display: flex; justify-content: center; padding-top: 6px; }

/* ---- Leads page --------------------------------------------------------------- */
.leads-card .card-body { display: grid; gap: 14px; }
.tabs { display: flex; gap: 4px; overflow-x: auto; border-bottom: 1px solid var(--line); }
.tab { padding: 9px 12px; border: 0; border-bottom: 2px solid transparent; color: var(--muted); background: none; font-weight: 600; white-space: nowrap; }
.tab:hover { color: var(--navy); }
.tab.active { border-bottom-color: var(--orange); color: var(--navy); }
/* .tabs scrolls sideways, which would clip an outside ring. */
.tab:focus-visible { outline-offset: -3px; border-radius: 6px 6px 0 0; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.search-field { position: relative; display: flex; flex: 1 1 280px; align-items: center; }
.search-field svg { position: absolute; left: 11px; color: var(--faint); }
.search-field input { padding-left: 34px; }
.select-field select { min-width: 150px; }
.leads-table td:first-child { min-width: 220px; }
.pager { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; color: var(--muted); font-size: 13px; }
.pager-buttons { display: flex; align-items: center; gap: 8px; }
.pager-buttons .button { width: 38px; padding: 0; }

/* ---- Lead detail -------------------------------------------------------------- */
.lead-header .card-body { display: grid; gap: 12px; }
.back-link { display: inline-flex; align-items: center; gap: 4px; width: max-content; color: var(--muted); font-size: 13px; font-weight: 600; }
.lead-header-main { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; }
.lead-header-main > .avatar { width: 52px; height: 52px; font-size: 18px; }
.lead-header-copy { display: grid; flex: 1 1 360px; gap: 4px; min-width: 0; }
.lead-title-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.lead-title-row h2 { font-size: 22px; font-weight: 800; }
.lead-header-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.detail-layout { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(300px, 1fr); align-items: start; gap: 18px; }
.detail-main, .detail-side { display: grid; gap: 18px; min-width: 0; }
.score-summary { display: flex; align-items: center; gap: 18px; }
.score-summary.small .score-ring { width: 90px; height: 90px; }
.score-text { margin-top: 8px; }
.dimensions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 24px; margin-top: 18px; }
.dimension-label { display: flex; justify-content: space-between; margin-bottom: 6px; font-size: 13px; }
.dimension-label strong { color: var(--navy); font-variant-numeric: tabular-nums; }
.dimension-track { display: block; height: 8px; overflow: hidden; border-radius: 999px; background: var(--gray-soft); }
.dimension-track span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--blue-2), #22a06b); }
.gates { display: flex; flex-wrap: wrap; gap: 8px; margin: 18px 0 0; padding: 0; list-style: none; }
.gates li { display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.gates li.pass { color: var(--green); background: var(--green-soft); }
.gates li.fail { color: #526073; background: var(--gray-soft); }
.detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 20px; margin: 0; }
.detail-grid.single { grid-template-columns: 1fr; gap: 8px; }
.detail-grid dt { color: var(--muted); font-size: 12px; }
.detail-grid dd { margin: 1px 0 0; color: var(--navy); font-weight: 600; overflow-wrap: anywhere; }
.chat { display: grid; gap: 8px; max-height: 620px; padding: 14px; overflow-y: auto; border-radius: 10px; background: #efeae2; }
.bubble-row { display: flex; }
.bubble-row.out { justify-content: flex-end; }
.bubble { max-width: min(78%, 560px); padding: 8px 11px 6px; border-radius: 10px 10px 10px 2px; background: var(--surface); box-shadow: 0 1px 1px rgba(0, 0, 0, .08); }
.bubble-row.out .bubble { border-radius: 10px 10px 2px 10px; background: #d9fdd3; }
.bubble.template { border: 1px dashed #86c98f; }
.bubble.ai-answer { border: 1px solid #b9cdf5; }
.bubble p { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 13.5px; }
.bubble small { display: block; margin-top: 2px; color: var(--muted); font-size: 11px; text-align: right; }
.bubble-tag { display: inline-block; margin-bottom: 3px; color: var(--green); font-size: 11px; font-weight: 700; text-transform: uppercase; }
.bubble-tag.brain { display: inline-flex; align-items: center; gap: 3px; margin-left: 2px; color: #1e40af; }
.assignment-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 12px; font-size: 13px; }
.inline-form { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; margin-top: 14px; }
.card-body > .button { margin-top: 12px; }
.stack-form { display: grid; gap: 10px; }
.history { display: grid; gap: 12px; margin: 0; padding: 0; list-style: none; }
.history li { padding-bottom: 12px; border-bottom: 1px solid #eef2f6; }
.history li:last-child { padding-bottom: 0; border-bottom: 0; }
.history-top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.history small { display: block; margin-top: 2px; }
.issue-list { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.issue-list li { display: grid; gap: 2px; padding-left: 10px; border-left: 3px solid var(--hot); }
.issue-list strong { color: #991b1b; text-transform: capitalize; }
.issue-list small { color: var(--muted); }

/* ---- Agents ------------------------------------------------------------------- */
.page-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.agent-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 18px; }
.agent-card { display: grid; gap: 14px; padding: 18px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.agent-card.inactive { background: var(--surface-soft); }
.agent-card.inactive .agent-identity strong { color: var(--muted); }
.agent-card-header { display: flex; align-items: center; gap: 12px; }
.agent-card-header .avatar { width: 44px; height: 44px; font-size: 15px; }
.agent-identity { display: grid; flex: 1; min-width: 0; }
.agent-identity strong { overflow: hidden; color: var(--navy); font-size: 15px; text-overflow: ellipsis; white-space: nowrap; }
.agent-identity a { font-size: 13px; }
.agent-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.agent-load { display: grid; gap: 6px; }
.agent-load-label { display: flex; justify-content: space-between; font-size: 13px; }
.agent-load-label span { color: var(--muted); }
.agent-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.agent-stat { display: grid; padding: 8px; border-radius: 8px; background: var(--surface-soft); text-align: center; }
.agent-stat strong { color: var(--navy); font-size: 16px; }
.agent-stat span { color: var(--muted); font-size: 11px; }
.agent-window { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; }
.agent-window.open { color: var(--green); }
.agent-actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding-top: 12px; border-top: 1px solid #eef2f6; }

/* ---- Settings ----------------------------------------------------------------- */
.progress { height: 8px; margin-bottom: 14px; overflow: hidden; border-radius: 999px; background: var(--gray-soft); }
.progress span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--orange), #f59e0b); }
.checklist { display: grid; gap: 4px; margin: 0 0 12px; padding: 0; list-style: none; }
.check-row { display: flex; align-items: flex-start; gap: 12px; padding: 9px 4px; border-bottom: 1px solid #eef2f6; }
.check-row:last-child { border-bottom: 0; }
.check-row strong { display: block; color: var(--navy); }
.check-row small { color: var(--muted); font-size: 12.5px; overflow-wrap: anywhere; }
.check-icon { display: inline-grid; flex: 0 0 auto; place-items: center; width: 26px; height: 26px; border-radius: 50%; }
.check-row.ok .check-icon { color: var(--green); background: var(--green-soft); }
.check-row.todo .check-icon { color: #b91c1c; background: var(--hot-soft); }
.check-row.optional .check-icon { color: var(--muted); background: var(--gray-soft); }
.copy-field { display: flex; align-items: center; gap: 8px; padding: 8px 8px 8px 12px; border: 1px solid var(--line-2); border-radius: 8px; background: var(--surface-soft); }
.copy-field code { flex: 1; overflow-x: auto; padding: 0; background: none; white-space: nowrap; }
.card-body > .table, .card-body > .table-scroll { margin-top: 14px; }
.card-body > .table-scroll:first-child { margin-top: 0; }
.template-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.template { display: grid; align-content: start; gap: 10px; padding: 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-soft); }
.template header { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.template header > div { display: grid; gap: 2px; }
.template header small { color: var(--muted); font-size: 12px; }
.template-name { width: max-content; font-weight: 700; }
.template-body { padding: 10px 12px; border-radius: 8px; background: #d9fdd3; font-size: 13px; }
.template-buttons { display: flex; flex-wrap: wrap; gap: 6px; }
.template .button { justify-self: start; }
.stat-strip { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; margin-bottom: 16px; }
.stat-strip > div { display: grid; padding: 10px 12px; border-radius: 10px; background: var(--surface-soft); }
.stat-strip strong { color: var(--navy); font-size: 20px; }
.stat-strip span { color: var(--muted); font-size: 12px; }
.stat-strip .danger strong { color: #b91c1c; }
.error-text { max-width: 320px; }

/* ---- Simulator ---------------------------------------------------------------- */
.simulator-layout { display: grid; grid-template-columns: minmax(340px, 520px) minmax(280px, 1fr); align-items: start; gap: 18px; }
.phone { overflow: hidden; }
.phone-header { display: flex; align-items: center; gap: 10px; padding: 12px 16px; color: #fff; background: #075e54; }
.phone-header div { display: grid; }
.phone-header small { color: #cfe9e3; font-size: 12px; }
.phone-avatar img { border-radius: 50%; background: var(--surface); }
.phone-setup { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.phone-setup .button-row { grid-column: 1 / -1; }
.field { display: grid; gap: 4px; color: var(--navy); font-size: 12.5px; font-weight: 600; }
.phone-chat { height: 440px; max-height: none; border-radius: 0; }
.chat-hint { align-self: center; justify-self: center; padding: 6px 12px; border-radius: 8px; color: var(--muted); background: #fff8c4; font-size: 12.5px; text-align: center; }
.quick-replies { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 14px 0; }
.quick-replies:empty { display: none; }
.quick-reply { padding: 6px 12px; border: 1px solid #25a366; border-radius: 999px; color: #0f7a43; background: var(--surface); font-size: 13px; font-weight: 600; }
.quick-reply:hover { border-color: #0f7a43; color: #fff; background: #0f7a43; }
.composer { display: grid; grid-template-columns: 1fr auto; gap: 8px; padding: 12px 14px 14px; }
.composer .send { display: inline-grid; place-items: center; width: 42px; height: 38px; border: 0; border-radius: 8px; color: #fff; background: #25a366; }
.sim-inspector { display: grid; gap: 14px; }
.sim-status { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---- Dialog ------------------------------------------------------------------- */
.dialog { width: min(560px, calc(100vw - 24px)); padding: 0; border: 0; border-radius: 14px; background: var(--surface); box-shadow: 0 24px 64px rgba(2, 18, 30, .35); }
.dialog::backdrop { background: rgba(3, 20, 36, .6); backdrop-filter: blur(2px); }
.dialog-form { display: grid; gap: 14px; padding: 22px; }
.dialog-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.dialog-header h2 { margin-top: 2px; font-size: 20px; }
.dialog-note { color: var(--muted); font-size: 13px; }
.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.field-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.choice-group { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 0; padding: 10px 12px; border: 1px solid var(--line-2); border-radius: 8px; }
.choice-group legend { padding: 0 4px; color: var(--navy); font-size: 12.5px; font-weight: 600; }
.choice-group label { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 500; }
.block-switch { margin-top: 2px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; padding-top: 6px; }
.invite-group { flex-direction: column; align-items: flex-start; }

/* ---- Toasts ------------------------------------------------------------------- */
.toast-stack { position: fixed; right: 20px; bottom: 20px; z-index: 50; display: grid; gap: 8px; }
.toast { display: flex; align-items: center; gap: 8px; max-width: 400px; padding: 9px 8px 9px 14px; border-left: 4px solid #22c55e; border-radius: 10px; color: #fff; background: var(--navy); box-shadow: 0 12px 32px rgba(2, 18, 30, .3); font-size: 13.5px; animation: toast-in .2s ease; transition: opacity .3s, transform .3s; }
.toast > svg { flex: 0 0 auto; }
.toast-text { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.toast-close { display: inline-grid; flex: 0 0 auto; place-items: center; width: 28px; height: 28px; border: 0; border-radius: 6px; color: #c8d6e3; background: none; }
.toast-close:hover { color: #fff; background: rgba(255, 255, 255, .12); }
.toast.error { border-left-color: #f87171; }
.toast.leaving { opacity: 0; transform: translateY(8px); }

/* ---- Motion ------------------------------------------------------------------- */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes loading { 0% { transform: translateX(-100%); } 100% { transform: translateX(300%); } }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
.skeleton-block { display: grid; gap: 10px; }
.skeleton { display: block; height: 14px; border-radius: 6px; background: linear-gradient(90deg, #eef2f6, #f8fafc, #eef2f6); background-size: 200% 100%; animation: loading 1.2s infinite; }

/* ---- Team access, stages, call logs, handoffs ------------------------------------ */
.check-line { display: inline-flex; align-items: center; gap: 8px; color: var(--navy); font-size: 13px; font-weight: 500; }
.check-line.align-end { align-self: end; padding-bottom: 8px; }
.login-card .check-line { margin-top: 4px; font-weight: 500; }
.login-team, .login-owner { display: grid; gap: 8px; }
.login-switch { justify-self: center; padding: 4px; border: 0; background: none; }
.sidebar-user { margin-top: auto; }
.sidebar-user:empty { display: none; }
.sidebar-user:not(:empty) + .sidebar-status { margin-top: 8px; }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 10px; background: rgba(255, 255, 255, .06); }
.user-chip > div { display: grid; min-width: 0; }
.user-chip strong { overflow: hidden; color: #fff; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.user-chip small { color: #9fb3c8; font-size: 11.5px; }
.small-avatar { width: 32px; height: 32px; font-size: 12px; }
.switch-stack { display: grid; gap: 8px; }
.login-fields { display: grid; gap: 10px; margin: 0; padding: 12px; border: 1px solid var(--line-2); border-radius: 8px; }
.login-fields legend { padding: 0 4px; }
.login-fields select { width: 100%; }

.kpi-link { color: inherit; text-decoration: none; transition: border-color .15s, transform .15s; }
.kpi-link:hover { border-color: var(--blue-2); text-decoration: none; transform: translateY(-1px); }
.kpi-more { display: inline-flex; align-items: center; gap: 2px; margin-top: 4px; color: var(--blue-2); font-size: 12px; font-weight: 600; }

.stage-tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.stage-tile { display: grid; gap: 4px; padding: 14px; border: 1px solid var(--line); border-left-width: 4px; border-radius: 10px; color: var(--text); }
.stage-tile:hover { border-color: var(--blue-2); text-decoration: none; }
.stage-tile strong { color: var(--navy); font-size: 26px; font-weight: 800; line-height: 1.1; }
.stage-tile small { color: var(--muted); font-size: 12px; }
.stage-tile-top { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }
.stage-tile.warning { border-left-color: #f59e0b; }
.stage-tile.warning .stage-tile-top { color: var(--warm); }
.stage-tile.info { border-left-color: #3b82f6; }
.stage-tile.info .stage-tile-top { color: #1e40af; }
.stage-tile.success { border-left-color: #22c55e; }
.stage-tile.success .stage-tile-top { color: var(--green); }
.stage-tile.danger { border-left-color: var(--hot); }
.stage-tile.danger .stage-tile-top { color: #b91c1c; }

.stage-badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border: 1px solid; border-radius: 6px; font-size: 11.5px; font-weight: 700; letter-spacing: .02em; text-transform: uppercase; white-space: nowrap; }
.stage-badge.warning { border-color: #fcd34d; color: var(--warm); background: #fffbeb; }
.stage-badge.info { border-color: #bfdbfe; color: #1e40af; background: var(--surface-soft); }
.stage-badge.success { border-color: #bbf7d0; color: var(--green); background: var(--surface-soft); }
.stage-badge.danger { border-color: #fecaca; color: #b91c1c; background: var(--surface-soft); }
.stage-cell { min-width: 150px; }
.status-line { margin-top: 4px; }
.tab { display: inline-flex; align-items: center; gap: 6px; }
.tab-count { min-width: 22px; padding: 0 6px; border-radius: 999px; color: var(--muted); background: var(--gray-soft); font-size: 11.5px; text-align: center; }
.tab.active .tab-count { color: #fff; background: var(--navy); }
.tab-warning.active .tab-count { background: var(--warm); }
.tab-danger.active .tab-count { background: var(--hot); }
.filter-note { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0; padding: 8px 12px; border-radius: 8px; color: var(--navy-3); background: var(--surface-soft); font-size: 13px; }
.filter-note.warning { color: #7c4a03; background: var(--warm-soft); }
.filter-note.success { color: var(--green); background: var(--green-soft); }
.filter-note.danger { color: #991b1b; background: var(--hot-soft); }
.filter-note .link-button { padding: 0; border: 0; background: none; }
.phone-line { display: inline-flex; align-items: center; gap: 4px; }
.copy-button { width: 26px; height: 26px; border-radius: 6px; }
.channel-id { margin-top: 3px; font-size: 11.5px; overflow-wrap: anywhere; }
.received-cell { white-space: nowrap; font-variant-numeric: tabular-nums; }
.received-cell span { color: var(--navy); font-size: 12.5px; }
.follow-due { display: inline-flex; align-items: center; gap: 4px; margin-top: 4px; color: var(--warm); font-size: 12px; font-weight: 600; }
.follow-due.overdue { color: #b91c1c; }

.context-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.strong-chip { color: #fff; background: var(--navy-3); }
.handled-by { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 10px; }
.author-chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.author-chip.bot { color: #1e40af; background: #e0eaff; }
.author-chip.human { color: #7a2e0e; background: var(--orange-soft); }
.chat-divider { display: flex; justify-content: center; }
.chat-divider span { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 8px; color: #7a2e0e; background: #fde7d9; font-size: 11.5px; font-weight: 600; }
.bubble-author { display: flex; align-items: center; gap: 4px; margin-bottom: 2px; font-size: 11px; font-weight: 700; }
.bubble-author.bot { color: #1e40af; }
.bubble-author.human { color: var(--orange-3); }
.bubble-author.lead { color: var(--navy-3); }
.bubble-row.out.human .bubble { border: 1px solid #f7c3a6; background: #fff1e8; }
.reply-form { display: grid; gap: 8px; margin-top: 12px; }
.stack-form > .form-note { margin-top: 0; }
.reply-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.notice.info-notice { color: var(--navy-3); background: var(--surface-soft); }
.handoff-reason { display: flex; align-items: flex-start; gap: 6px; margin-top: 8px; color: var(--navy-3); font-size: 12.5px; }
.handoff-reason svg { flex: 0 0 auto; margin-top: 2px; }
.history small.handoff-reason { margin-top: 4px; }
.transfer-form { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.form-label { color: var(--navy); font-size: 12.5px; font-weight: 700; }
.call-log { display: grid; gap: 12px; margin: 0; padding: 0; list-style: none; }
.call-log li { display: grid; gap: 4px; padding-bottom: 12px; border-bottom: 1px solid #eef2f6; }
.call-log li:last-child { padding-bottom: 0; border-bottom: 0; }
.call-note { white-space: pre-wrap; overflow-wrap: anywhere; color: var(--text); font-size: 13.5px; }

.agent-pills { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 4px; margin-left: auto; }
.agent-grid.single { grid-template-columns: minmax(0, 560px); }
.performance-table td, .performance-table th { white-space: nowrap; }

/* ---- Settings: AI ----------------------------------------------------------------- */
.ai-key-note { margin-top: 12px; }
.ai-links { margin-top: 12px; }
.ai-models { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.ai-models h3 { margin: 0 0 10px; color: var(--navy); font-size: 14px; }
.ai-models .field small { font-weight: 400; line-height: 1.45; }
.ai-models > .button-row { margin-top: 8px; }

/* ---- Brand brain ------------------------------------------------------------------ */
.brain-status { display: grid; grid-template-columns: minmax(240px, 1fr) minmax(0, 2fr); align-items: start; gap: 16px 24px; }
.brain-status-main { display: grid; gap: 8px; }
.brain-connection { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.brain-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; }
.brain-stat { display: grid; padding: 10px 12px; border-radius: 10px; background: var(--surface-soft); }
.brain-stat strong { color: var(--navy); font-size: 20px; }
.brain-stat span { color: var(--muted); font-size: 12px; }
.brain-layout { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(320px, 1fr); align-items: start; gap: 18px; }
.brain-main, .brain-side { display: grid; gap: 18px; min-width: 0; }
.brain-knowledge .card-body { display: grid; gap: 14px; }
.brain-knowledge .notice { margin-top: 0; }
.brain-entries { display: grid; gap: 12px; margin: 0; padding: 0; list-style: none; }
.brain-entry { display: grid; gap: 6px; padding: 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-soft); }
.brain-entry.draft { border-style: dashed; border-color: #fcd34d; }
.brain-entry.archived { background: var(--surface-soft); }
.brain-entry-top { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 8px; }
.brain-entry-top h3 { min-width: 0; font-size: 14.5px; font-weight: 700; overflow-wrap: anywhere; }
.brain-entry-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.always-chip { color: var(--green); background: var(--green-soft); }
.brain-entry-meta { font-size: 12px; }
.brain-content { color: var(--text); font-size: 13.5px; white-space: pre-wrap; overflow-wrap: anywhere; }
.brain-content.clamped { display: -webkit-box; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 4; line-clamp: 4; }
.brain-entry > .link-button { justify-self: start; }
.brain-entry-actions { margin-top: 4px; }
.brain-test-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 10px; }
.brain-test-result > * { margin-top: 12px; }
.brain-test-answer { display: grid; gap: 8px; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-soft); }
.brain-test-top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.brain-reply { padding: 10px 12px; border-radius: 8px; background: #d9fdd3; font-size: 13.5px; white-space: pre-wrap; overflow-wrap: anywhere; }
.question-list { display: grid; gap: 12px; margin: 0; padding: 0; list-style: none; }
.question-item { display: grid; gap: 6px; padding-bottom: 12px; border-bottom: 1px solid #eef2f6; }
.question-item:last-child { padding-bottom: 0; border-bottom: 0; }
.question-item .button { justify-self: start; }
.question-top { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.question-time { margin-left: auto; font-size: 12px; }
.question-text { color: var(--navy); font-weight: 600; overflow-wrap: anywhere; }
.question-reply { color: var(--text); font-size: 13px; white-space: pre-wrap; overflow-wrap: anywhere; }
.brain-dialog { width: min(680px, calc(100vw - 24px)); }
.char-count { justify-self: end; color: var(--muted); font-size: 12px; font-weight: 500; }
.char-count.near-limit { color: var(--warm); font-weight: 700; }
.always-field { display: grid; align-content: end; gap: 2px; padding-bottom: 4px; }
.always-field small { font-size: 12px; }

/* ---- AI assistant ----------------------------------------------------------------- */
.assistant-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(260px, 340px); align-items: start; gap: 18px; }
.assistant-card .card-body { display: grid; gap: 10px; }
.assistant-window { height: min(62vh, 640px); min-height: 320px; padding: 14px; overflow-y: auto; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-soft); }
.assistant-log { display: flex; flex-direction: column; gap: 10px; }
.assistant-empty { display: grid; justify-items: center; align-content: center; gap: 8px; min-height: 100%; padding: 12px; text-align: center; }
.assistant-empty strong { color: var(--navy); }
.assistant-empty p { max-width: 440px; font-size: 13px; }
.assistant-suggestions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 4px; }
.suggestion-chip { padding: 7px 12px; border: 1px solid var(--line-2); border-radius: 999px; color: var(--navy); background: var(--surface); font-size: 13px; font-weight: 600; text-align: left; }
.suggestion-chip:hover:not(:disabled) { border-color: var(--blue-2); color: var(--blue-2); }
.assistant-msg { display: grid; gap: 2px; max-width: min(82%, 680px); padding: 8px 12px 6px; border-radius: 12px; box-shadow: 0 1px 1px rgba(0, 0, 0, .06); }
.assistant-msg.user { align-self: flex-end; border-radius: 12px 12px 2px 12px; color: #fff; background: var(--navy-3); }
.assistant-msg.assistant { align-self: flex-start; border: 1px solid var(--line); border-radius: 12px 12px 12px 2px; background: var(--surface); }
.assistant-text { font-size: 13.5px; white-space: pre-wrap; overflow-wrap: anywhere; }
.assistant-text a { text-decoration: underline; }
.assistant-msg.user a { color: #fff; }
.assistant-msg.user :focus-visible { outline-color: #fff; }
.assistant-author { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 700; }
.assistant-msg.assistant .assistant-author { color: #1e40af; }
.assistant-msg.user .assistant-author, .assistant-msg.user .assistant-time { color: #c8d6e3; }
.assistant-time { justify-self: end; color: var(--muted); font-size: 11px; }
.assistant-action { display: grid; gap: 8px; align-self: stretch; padding: 12px; border: 1px solid var(--line-2); border-left-width: 4px; border-radius: 10px; background: var(--surface); }
.assistant-action.pending { border-color: #fcd34d; border-left-color: #f59e0b; background: #fffbeb; }
.assistant-action.done { border-left-color: #22c55e; }
.assistant-action.failed { border-color: #fecaca; border-left-color: var(--hot); }
.assistant-action.cancelled, .assistant-action.stale { border-left-color: #94a3b8; }
.assistant-action .assistant-author { color: var(--navy-3); }
.assistant-action-top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.action-result { padding: 8px 10px; border-radius: 8px; background: var(--surface-soft); }
.action-details summary, .tool-list summary { width: max-content; max-width: 100%; color: var(--blue-2); font-size: 12.5px; font-weight: 600; cursor: pointer; }
.action-details pre { margin: 6px 0 0; padding: 8px 10px; overflow-x: auto; border-radius: 8px; color: var(--navy-3); background: var(--gray-soft); font: 12px/1.45 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; }
.assistant-status { display: flex; align-items: center; gap: 8px; min-height: 20px; color: var(--muted); font-size: 12.5px; }
.assistant-status.thinking::before { content: ""; width: 12px; height: 12px; border: 2px solid var(--line-2); border-top-color: var(--blue-2); border-radius: 50%; animation: spin .8s linear infinite; }
.assistant-composer { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 8px; }
.assistant-composer textarea { min-height: 60px; max-height: 240px; }
.assistant-hint { font-size: 12px; }
.assistant-about .help-steps { margin-bottom: 12px; }
.tool-group { display: grid; gap: 4px; margin-top: 10px; }
.tool-group strong { color: var(--navy); font-size: 12.5px; }
.tool-group ul { display: grid; gap: 4px; margin: 0; padding-left: 18px; color: var(--muted); font-size: 12.5px; }

/* ---- Leaderboard --------------------------------------------------------------- */
.rank-badge { display: inline-flex; align-items: center; justify-content: center; gap: 3px; min-width: 38px; padding: 2px 8px; border-radius: 999px; color: var(--navy-3); background: var(--gray-soft); font-size: 12px; font-weight: 800; font-variant-numeric: tabular-nums; }
.rank-badge.rank-1 { color: #6b4100; background: #fde68a; }
.rank-badge.rank-2 { color: #334155; background: #e2e8f0; }
.rank-badge.rank-3 { color: #7c2d12; background: #fed7aa; }
.podium { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: end; gap: 14px; margin: 0 0 18px; padding: 0; list-style: none; }
.podium-place { display: grid; justify-items: center; gap: 4px; padding: 14px 10px 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface-soft); text-align: center; }
.podium-place .avatar { width: 44px; height: 44px; font-size: 15px; }
.podium-place.place-1 { border-color: #fcd34d; background: #fffbeb; }
.podium-place.place-1 .avatar { width: 54px; height: 54px; font-size: 18px; }
.podium-name { color: var(--navy); }
.podium-points { color: var(--navy); font-size: 22px; font-weight: 800; letter-spacing: -.01em; }
.podium-gap { color: var(--muted); font-size: 12px; }
.podium-gap.leader { color: var(--green); font-weight: 700; }
.podium-step { width: 100%; margin-top: 8px; border-radius: 6px 6px 0 0; background: var(--line); }
.place-1 .podium-step { height: 34px; background: #fcd34d; }
.place-2 .podium-step { height: 22px; background: #cbd5e1; }
.place-3 .podium-step { height: 14px; background: #fdba74; }
.leader-list { display: grid; gap: 8px; margin: 0 0 12px; padding: 0; list-style: none; }
.leader-row { display: grid; grid-template-columns: auto minmax(160px, 1.3fr) minmax(80px, 1fr) auto; align-items: center; gap: 6px 12px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; }
.leader-bar { height: 8px; overflow: hidden; border-radius: 999px; background: var(--gray-soft); }
.leader-bar > span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--blue-2), var(--orange)); }
.leader-points { color: var(--navy); font-variant-numeric: tabular-nums; text-align: right; }
.leader-badges { display: flex; flex-wrap: wrap; grid-column: 2 / -1; gap: 4px; }
.leader-badges:empty { display: none; }
.badge-chip { color: #6b4100; background: #fef3c7; }
.standing-card { display: flex; align-items: flex-start; gap: 14px; padding: 16px 18px; border: 1px solid #fcd34d; border-radius: var(--radius); background: #fffbeb; }
.standing-card .rank-badge { font-size: 16px; padding: 6px 12px; }
.standing-card p { margin-top: 2px; }
.demo-pill { margin-left: 4px; }

/* ---- Members ------------------------------------------------------------------- */
.member-plan-row { margin-bottom: 10px; }
.members-table td:first-child { min-width: 200px; }
.members-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.members-toolbar .search-field { flex: 1 1 260px; }
.import-result { margin-top: 10px; }
.import-result ul { margin: 4px 0 0; padding-left: 18px; }
.plan-mix { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: -4px 0 14px; }
.stat-strip .warning strong { color: var(--warm); }
.integration-steps ul { margin: 6px 0 0; padding-left: 18px; }
.website-events { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; font-size: 13px; }
.website-events li { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 10px; padding-bottom: 8px; border-bottom: 1px solid #eef2f6; }
.website-events li:last-child { border-bottom: 0; }
.integration-steps { display: grid; gap: 8px; margin: 0; padding-left: 20px; color: var(--muted); }
.integration-steps code { word-break: break-all; }

/* ---- Responsive --------------------------------------------------------------- */
@media (max-width: 1360px) {
  .kpi-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .stat-strip { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 1180px) {
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 > .span-2 { grid-column: 1 / -1; }
  .detail-layout { grid-template-columns: minmax(0, 1fr); }
  /* One column: put the actions near the top and the long transcript last. */
  .detail-main, .detail-side { display: contents; }
  .card-context { order: 1; }
  .card-assignment { order: 2; }
  .card-outcome { order: 3; }
  .card-calls { order: 4; }
  .transcript-card { order: 5; }
  .detail-main > .enrollment-card { order: 5; }
  .card-score { order: 6; }
  .card-answers { order: 7; }
  .card-form { order: 8; }
  .card-history { order: 9; }
  .card-issues { order: 10; }
  .card-timeline { order: 11; }
  .template-grid { grid-template-columns: minmax(0, 1fr); }
  .simulator-layout { grid-template-columns: minmax(0, 1fr); }
  /* Brand brain in one column: tester first, then the knowledge, then the questions. */
  .brain-layout { grid-template-columns: minmax(0, 1fr); }
  .brain-main, .brain-side { display: contents; }
  .brain-tester { order: 1; }
  .brain-knowledge { order: 2; }
  .brain-questions { order: 3; }
  .assistant-layout { grid-template-columns: minmax(0, 1fr); }
}

/* minmax(0, 1fr) instead of 1fr: plain 1fr tracks never shrink below a table's width. */
@media (max-width: 1024px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  /* Closed: hidden after the slide-out, so its links leave the tab order. */
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 30;
    width: 264px;
    transform: translateX(-100%);
    visibility: hidden;
    transition: transform .2s ease, visibility 0s linear .2s;
  }
  body.menu-open .sidebar { transform: none; visibility: visible; box-shadow: 0 0 40px rgba(0, 0, 0, .3); transition: transform .2s ease, visibility 0s; }
  body.menu-open::after { content: ""; position: fixed; inset: 0; z-index: 20; background: rgba(3, 20, 36, .45); }
  .menu-toggle { display: inline-grid; }
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .kpi-grid.compact { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stage-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .brain-status { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 760px) {
  .podium { grid-template-columns: minmax(0, 1fr); }
  .podium-place.place-1 { order: -1; }
  .podium-step { display: none; }
  .podium-place { padding-bottom: 12px; }
  .leader-row { grid-template-columns: auto minmax(0, 1fr) auto; }
  .leader-bar { grid-column: 1 / -1; grid-row: 2; }
  .leader-badges { grid-column: 1 / -1; }
  .topbar { flex-wrap: wrap; padding: 12px 16px; }
  .topbar-title { flex: 1 1 0; }
  .topbar-title p { display: none; }
  .topbar-tools { flex-wrap: wrap; width: 100%; margin-left: 0; }
  .select-inline { flex: 1; }
  .select-inline select { min-width: 0; }
  .updated { display: none; }
  .content { padding: 16px 14px 32px; }
  .setup-banner { margin: 12px 14px 0; }
  .kpi-grid, .kpi-grid.compact { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi { padding: 12px; }
  .kpi-value { font-size: 23px; }
  .kpi-icon { display: none; }
  .grid-3 { grid-template-columns: minmax(0, 1fr); }
  .grid-3 > .span-2 { grid-column: auto; }
  .dimensions, .detail-grid { grid-template-columns: minmax(0, 1fr); }
  .agent-grid { grid-template-columns: minmax(0, 1fr); }
  .agent-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .stat-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .funnel li { grid-template-columns: minmax(0, 1fr); }
  .funnel-rate { grid-column: 1; }
  .field-grid, .field-grid.three, .phone-setup { grid-template-columns: minmax(0, 1fr); }
  .toolbar > * { flex: 1 1 140px; }
  .select-field select { min-width: 0; }
  /* Leads table becomes stacked rows so stage, agent and date stay visible. */
  .leads-table thead { display: none; }
  .leads-table, .leads-table tbody { display: block; }
  .leads-table tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 6px 10px; padding: 12px 4px; border-bottom: 1px solid #eef2f6; }
  .leads-table tr:last-child { border-bottom: 0; }
  .leads-table td { padding: 0; border: 0; }
  .leads-table td:first-child { grid-column: 1 / -1; min-width: 0; }
  .leads-table td:nth-child(even) { justify-self: start; }
  .leads-table td:nth-child(odd):not(:first-child) { justify-self: end; text-align: right; }
  .leads-table td:nth-child(n+4) { color: var(--muted); font-size: 12.5px; }
  .login-screen { grid-template-columns: minmax(0, 1fr); }
  .login-brand { gap: 28px; padding: 32px 24px; }
  .login-pitch h1 { font-size: 24px; }
  .question-time { margin-left: 0; }
  .assistant-window { height: 58vh; min-height: 280px; padding: 10px; }
  .assistant-msg { max-width: 92%; }
  .assistant-suggestions { justify-content: stretch; }
  .suggestion-chip { flex: 1 1 100%; }
  .toast-stack { right: 12px; bottom: 12px; left: 12px; }
  .toast { max-width: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* ---- Settings → WhatsApp connection (Official API / WAHA switch) ------------------- */
.whatsapp-card { margin-bottom: 18px; }
.wa-section { display: grid; gap: 12px; padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.wa-section h3, .wa-panel h3, .first-message h3 { margin: 0; color: var(--navy); font-size: 14px; }
.mode-tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.mode-tile { position: relative; display: flex; gap: 10px; padding: 12px 14px; border: 1px solid var(--line-2); border-radius: 10px; background: var(--surface-soft); cursor: pointer; }
.mode-tile:has(input:checked) { border-color: var(--orange-2); background: #fff7ed; box-shadow: 0 0 0 1px var(--orange-2) inset; }
.mode-tile input[type="radio"], .option-row input[type="radio"] { flex: 0 0 auto; width: 16px; height: 16px; min-height: 0; margin: 3px 0 0; padding: 0; border: 0; accent-color: var(--orange-2); }
.mode-tile-body { display: grid; gap: 6px; min-width: 0; }
.mode-tile-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px; }
.mode-tile-head strong { color: var(--navy); font-size: 14px; }
.mode-pills { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.mode-tile small, .option-row small { color: var(--muted); font-size: 12.5px; line-height: 1.45; }
.first-message { display: grid; gap: 6px; }
.first-message .small { margin: 0; }
.option-list { display: grid; gap: 6px; }
.option-row { display: flex; align-items: flex-start; gap: 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; }
.option-row:has(input:checked) { border-color: var(--orange-2); background: #fff7ed; }
.option-row.risky:has(input:checked) { border-color: #d97706; background: var(--warm-soft); }
.option-row span { display: grid; gap: 2px; }
.option-row strong { color: var(--navy); font-size: 13px; }
.wa-panels { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; padding-top: 16px; }
.wa-panel { display: grid; align-content: start; gap: 12px; min-width: 0; padding: 14px; border: 1px solid var(--line); border-radius: 10px; }
.wa-panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.wa-panel-head > div { display: grid; gap: 2px; }
.wa-details { padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-soft); }
.wa-details summary { color: var(--navy); font-size: 13px; font-weight: 600; cursor: pointer; }
.wa-details[open] summary { margin-bottom: 10px; }
.field-with-action { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 8px; }
.wa-paste { display: grid; gap: 6px; min-width: 0; font-size: 12.5px; }
.wa-panel .copy-field { min-width: 0; }
.wa-panel .copy-field code { min-width: 0; }
.waha-status { display: grid; gap: 10px; }
.waha-linked { display: flex; align-items: center; gap: 8px; margin: 0; color: var(--green); font-weight: 700; }
.qr-steps { margin: 0; padding-left: 20px; color: var(--navy); font-size: 13px; line-height: 1.6; }
.qr-box { display: grid; justify-items: center; gap: 6px; padding: 12px; border: 1px dashed var(--line-2); border-radius: 10px; background: var(--surface); }
.qr-image { width: 264px; max-width: 100%; height: auto; image-rendering: pixelated; }
.qr-image[hidden] { display: none; }
.pairing-code { display: block; margin-top: 8px; color: var(--navy); font-size: 18px; letter-spacing: 2px; }
.waha-risk ul { margin: 4px 0 0; padding-left: 18px; }
.waha-risk li { margin: 2px 0; }
@media (max-width: 900px) {
  .mode-tiles, .wa-panels { grid-template-columns: 1fr; }
}

/* Client enrollment: one readable workspace, with separate saves for each record. */
.enrollment-card { min-width: 0; scroll-margin-top: 115px; }
.enrollment-card > .card-body { display: grid; gap: 20px; }
.enrollment-card .card-header { align-items: flex-start; }
.enrollment-stages { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; list-style: none; }
.enrollment-stages li { padding: 6px 10px; border: 1px solid var(--line); border-radius: 6px; color: var(--muted); background: var(--bg); font-size: 12px; }
.enrollment-stages li.complete { color: var(--green); border-color: var(--green); background: var(--green-soft); }
.enrollment-stages li.current { color: #fff; border-color: var(--blue); background: var(--blue); font-weight: 700; }
.enrollment-totals { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); margin: 0; padding: 14px 0; border-block: 1px solid var(--line); }
.enrollment-totals > div { padding: 0 16px; border-left: 1px solid var(--line); }
.enrollment-totals > div:first-child { padding-left: 0; border: 0; }
.enrollment-totals dt { color: var(--muted); font-size: 12px; }
.enrollment-totals dd { margin: 3px 0 0; color: var(--navy); font-size: 21px; font-weight: 700; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.enrollment-form { display: grid; gap: 12px; min-width: 0; }
.enrollment-form h3, .enrollment-section > h3 { font-size: 15px; }
.enrollment-form fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
.enrollment-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.enrollment-field { display: grid; align-content: start; gap: 5px; min-width: 0; margin: 0; }
.enrollment-field > span { color: var(--muted); font-size: 12px; font-weight: 600; }
.enrollment-field input, .enrollment-field select, .enrollment-field textarea { min-width: 0; }
.enrollment-wide { grid-column: 1 / -1; }
.enrollment-checkbox { align-content: center; grid-template-columns: auto 1fr; }
.enrollment-checkbox > span { grid-column: 2; }
.enrollment-checkbox > input { grid-column: 1; grid-row: 1; }
.enrollment-checkbox > small { grid-column: 1 / -1; }
.enrollment-form-footer { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 12px; }
.enrollment-form-status { color: var(--muted); overflow-wrap: anywhere; }
.enrollment-section { display: grid; gap: 12px; padding-top: 20px; border-top: 1px solid var(--line); min-width: 0; }
.enrollment-section > .enrollment-form { padding-top: 12px; }
.enrollment-task-group { display: grid; gap: 6px; }
.enrollment-task-group > h4 { margin: 8px 0 4px; color: var(--navy); font-size: 13px; }
.enrollment-task { min-width: 0; border: 1px solid var(--line); border-radius: 8px; }
.enrollment-task > summary { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; padding: 11px 12px; cursor: pointer; }
.enrollment-task > summary::before { content: '+'; flex: 0 0 12px; color: var(--blue); font-weight: 700; }
.enrollment-task[open] > summary::before { content: '−'; }
.enrollment-task > summary > span:first-of-type { flex: 1 1 180px; font-weight: 600; overflow-wrap: anywhere; }
.enrollment-task[open] > summary { border-bottom: 1px solid var(--line); }
.enrollment-task > .enrollment-form { padding: 14px; }
.enrollment-task > .enrollment-form > h3 { display: none; }
.enrollment-task-date { padding: 0 14px 12px; }
.enrollment-retired { background: var(--bg); }
.enrollment-payment-list { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.enrollment-payment-list > li { display: grid; gap: 6px; padding: 12px; border-left: 3px solid var(--line-2); background: var(--bg); overflow-wrap: anywhere; }
.enrollment-payment-top { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.enrollment-payment-top > strong { font-variant-numeric: tabular-nums; }
.enrollment-action { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.enrollment-action > [role="status"]:empty { display: none; }
.enrollment-flow-editor { max-width: 980px; }
.simple-enrollment > .card-body { display: grid; gap: 14px; }
.simple-enrollment-plan { display: flex; flex-wrap: wrap; gap: 10px; align-items: baseline; }
.simple-enrollment .enrollment-totals { padding: 10px 0; }
.simple-enrollment .enrollment-totals dd { font-size: 20px; }
.enrollment-disclosure, .enrollment-previous, .simple-checklist-removed { padding: 10px 0; border-bottom: 1px solid var(--line); min-width: 0; }
.enrollment-disclosure > summary, .enrollment-previous > summary, .simple-checklist-removed > summary { color: var(--navy); cursor: pointer; font-size: 13px; font-weight: 600; }
.enrollment-disclosure[open] > summary, .enrollment-previous[open] > summary, .simple-checklist-removed[open] > summary { margin-bottom: 12px; }
.simple-setup, .simple-products { display: grid; gap: 8px; }
.simple-setup h3, .simple-products h3 { margin: 6px 0; font-size: 15px; }
.simple-setup-row { display: grid; grid-template-columns: minmax(0, 1fr) 160px; gap: 14px; align-items: center; padding: 7px 0; }
.simple-setup-row > div { display: grid; gap: 3px; overflow-wrap: anywhere; }
.simple-setup-row select { width: 100%; }
.enrollment-previous ul { padding-left: 20px; font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
.simple-checklist-editor { max-width: 850px; }
.simple-checklist-list { display: grid; gap: 10px; }
.simple-checklist-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 14px; align-items: end; }
.simple-checklist-name { min-width: 0; margin: 0; }
.simple-checklist-name input { width: 100%; }
.simple-checklist-actions { display: flex; gap: 6px; }
.simple-checklist-status { grid-column: 1 / -1; }
.simple-checklist-status:empty { display: none; }
.simple-checklist-add { padding-top: 16px; border-top: 1px solid var(--line); }
.simple-checklist-removed .simple-checklist-row { padding: 7px 0; align-items: center; font-size: 13px; }
@media (max-width: 620px) {
  .simple-enrollment .enrollment-totals { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .simple-enrollment .enrollment-totals dd { font-size: 16px; }
  .simple-setup-row { grid-template-columns: minmax(0, 1fr) 130px; gap: 8px; font-size: 13px; }
  .simple-checklist-row { grid-template-columns: minmax(0, 1fr); }
}
.enrollment-card fieldset:disabled input, .enrollment-card fieldset:disabled select, .enrollment-card fieldset:disabled textarea { opacity: 1; color: var(--muted); background: var(--bg); cursor: default; }
@media (max-width: 620px) {
  .enrollment-fields { grid-template-columns: minmax(0, 1fr); }
  .enrollment-totals { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .enrollment-totals > div { padding: 0; border: 0; }
  .enrollment-totals dd { font-size: 20px; }
  .enrollment-card .card-header { flex-wrap: wrap; gap: 10px; }
  .enrollment-task > summary > span:first-of-type { flex-basis: 140px; }
}
