/* Shared design tokens + components — admin console and client portal.
   Same visual language as the dashboard artifact (teal accent, warm neutrals),
   extended with sidebar nav, tables, and status/band badges for a real app. */

:root {
  --bg: #f6f9f8; --surface: #ffffff; --surface-2: #eef3f1; --line: #dde6e3;
  --ink: #182220; --dim: #5b6b67; --dimmer: #61736c;
  --accent: #0d7a72; --accent-ink: #0a5f59; --accent-bg: #e2f2ec;
  --r1: #bfe3de; --r2: #8fcfc7; --r3: #54b3a8; --r4: #20948a; --r5: #0d6e66;
  --hot-bg: #fdeee4; --hot-ink: #9a4a12;
  --good-bg: #e2f2ec; --good-ink: #116b46;
  --warn-bg: #fdf3dd; --warn-ink: #8a5a08;
  --bad-bg: #fbe9e7; --bad-ink: #a33327;
  --mut-bg: #eef1f0; --mut-ink: #5b6b67;
  --shadow: 0 1px 2px rgba(24, 34, 32, 0.06), 0 1px 1px rgba(24, 34, 32, 0.04);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1514; --surface: #161d1c; --surface-2: #1b2321; --line: #273230;
    --ink: #e4ecea; --dim: #93a5a1; --dimmer: #8fa39d;
    --accent: #3db3a8; --accent-ink: #6ccdc4; --accent-bg: #12312a;
    --r1: #1d4a45; --r2: #20655e; --r3: #2a8479; --r4: #3aa89b; --r5: #5ecabd;
    --hot-bg: #3d2413; --hot-ink: #f0a868;
    --good-bg: #12312a; --good-ink: #5fc99a;
    --warn-bg: #382b10; --warn-ink: #e5b45a;
    --bad-bg: #3a1d19; --bad-ink: #ef8d80;
    --mut-bg: #222b29; --mut-ink: #93a5a1;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 14.5px/1.5 "Segoe UI Variable Text", "Segoe UI", "Avenir Next", system-ui, sans-serif;
}
a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { text-wrap: balance; margin: 0; }
code, pre { font-family: "Cascadia Code", Consolas, ui-monospace, monospace; }

/* ---------- Admin shell: sidebar + topbar ---------- */
.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--surface); border-right: 1px solid var(--line);
  padding: 18px 14px; display: flex; flex-direction: column; gap: 18px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand { display: block; font: 650 15px/1.2 "Segoe UI Variable Display", "Segoe UI", system-ui, sans-serif; letter-spacing: -0.01em; padding: 0 6px; color: var(--ink); }
.brand:hover { text-decoration: none; color: var(--accent-ink); }
.brand .dot { color: var(--accent); }
.client-switcher { padding: 0 6px; }
.client-switcher form { display: grid; gap: 8px; }
.client-switcher select {
  width: 100%; padding: 7px 8px; border-radius: 7px; border: 1px solid var(--line);
  background: var(--surface-2); color: var(--ink); font-size: 13px; font-family: inherit;
}
.nav-group { display: flex; flex-direction: column; gap: 1px; }
.nav-group-label {
  font-size: 10.5px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--dimmer); padding: 10px 8px 4px;
}
.nav-link {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 7px 9px; border-radius: 7px; color: var(--ink); font-size: 13.5px; font-weight: 500;
}
.nav-link:hover { background: var(--surface-2); text-decoration: none; }
.nav-link.active { background: var(--accent-bg); color: var(--accent-ink); font-weight: 650; }
.nav-link .count { font-size: 11px; color: var(--dim); font-variant-numeric: tabular-nums; }
.nav-link.active .count { color: var(--accent-ink); }

.main { padding: 26px 32px 60px; max-width: 1180px; }
.topbar { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px 14px; margin-bottom: 22px; }
.topbar h1 { font: 600 21px/1.2 "Segoe UI Variable Display", "Segoe UI", system-ui, sans-serif; letter-spacing: -0.01em; }
.topbar .sub { color: var(--dim); font-size: 13px; }
.breadcrumb { font-size: 12.5px; color: var(--dimmer); margin-bottom: 12px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.breadcrumb a { color: var(--dim); }
.breadcrumb a:hover { color: var(--accent-ink); }
.breadcrumb span { color: var(--ink); font-weight: 600; }

/* ---------- Portal shell (simpler, no sidebar) ---------- */
.portal-shell { max-width: 980px; margin: 0 auto; padding: 30px 22px 60px; }
.portal-header { display: flex; flex-wrap: wrap; align-items: baseline; gap: 10px 16px; margin-bottom: 8px; }
.portal-header h1 { font: 600 24px/1.2 "Segoe UI Variable Display", "Segoe UI", system-ui, sans-serif; letter-spacing: -0.01em; }
.portal-nav { display: flex; gap: 4px; margin: 18px 0 26px; border-bottom: 1px solid var(--line); }
.portal-nav a { padding: 8px 4px; margin-right: 18px; color: var(--dim); font-weight: 600; font-size: 13.5px; border-bottom: 2px solid transparent; }
.portal-nav a.active { color: var(--accent-ink); border-bottom-color: var(--accent); }
.portal-nav a:hover { text-decoration: none; color: var(--accent-ink); }

/* ---------- Cards, tiles, sections ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  padding: 16px 18px; box-shadow: var(--shadow);
}
.section { margin-bottom: 24px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
h2.h { font-size: 11px; font-weight: 700; letter-spacing: 0.09em; text-transform: uppercase; color: var(--dim); }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; box-shadow: var(--shadow); }
.tile-label { font-size: 11px; font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase; color: var(--dim); }
.tile-value { font-size: 26px; font-weight: 650; letter-spacing: -0.02em; margin-top: 2px; font-variant-numeric: tabular-nums; }
.tile-sub { font-size: 12px; color: var(--dim); margin-top: 2px; }
.cols2 { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: 20px; }
.cols2 > *, .sidebar, .section { min-width: 0; }
@media (max-width: 900px) { .cols2 { grid-template-columns: minmax(0, 1fr); } .shell { grid-template-columns: 1fr; } .sidebar { position: static; height: auto; } }

/* ---------- Funnel bars ---------- */
.frow { display: grid; grid-template-columns: 90px 1fr 36px; gap: 10px; align-items: center; margin: 7px 0; }
.fname { font-size: 13px; color: var(--dim); text-transform: capitalize; }
.ftrack { background: var(--mut-bg); border-radius: 5px; height: 18px; overflow: hidden; }
.fbar { height: 100%; border-radius: 0 4px 4px 0; min-width: 2px; }
.t1 { background: var(--r1); } .t2 { background: var(--r2); } .t3 { background: var(--r3); }
.t4 { background: var(--r4); } .t5 { background: var(--r5); } .t6 { background: var(--r5); }
.fnum { font-variant-numeric: tabular-nums; font-weight: 650; text-align: right; }

/* ---------- Tables ---------- */
.scroll { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 13.5px; }
th { text-align: left; font-size: 10.5px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--dim); padding: 7px 12px 7px 0; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 9px 12px 9px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
tbody tr:hover { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: none; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.num.bad { color: var(--bad-ink); font-weight: 700; }
.mono { font-family: "Cascadia Code", Consolas, ui-monospace, monospace; font-size: 12.5px; }
.dim { color: var(--dim); } .dimmer { color: var(--dimmer); } .small { font-size: 11.5px; }
.row-link { display: block; color: inherit; }
.row-link:hover { text-decoration: none; }
tr.clickable { cursor: pointer; }

/* ---------- Pills / badges ---------- */
.pill { display: inline-block; border-radius: 99px; padding: 2px 10px; font-size: 10.5px; font-weight: 700; letter-spacing: 0.04em; white-space: nowrap; }
.pill.hot { background: var(--hot-bg); color: var(--hot-ink); }
.pill.qualified { background: var(--good-bg); color: var(--good-ink); }
.pill.weak { background: var(--mut-bg); color: var(--mut-ink); }
.pill.disqualified { background: var(--bad-bg); color: var(--bad-ink); }
.pill.unscored { background: var(--mut-bg); color: var(--mut-ink); }
.pill.ok { background: var(--good-bg); color: var(--good-ink); }
.pill.error { background: var(--bad-bg); color: var(--bad-ink); }
.pill.needs_review { background: var(--warn-bg); color: var(--warn-ink); }
.pill.skipped { background: var(--mut-bg); color: var(--mut-ink); }
.pill.draft { background: var(--mut-bg); color: var(--mut-ink); }
.pill.active { background: var(--good-bg); color: var(--good-ink); }
.pill.paused { background: var(--warn-bg); color: var(--warn-ink); }
.pill.agent { background: var(--mut-bg); color: var(--accent-ink); font-family: Consolas, ui-monospace, monospace; font-weight: 600; }

/* ---------- Forms / filters ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; align-items: center; }
.filter-field { display: flex; align-items: center; gap: 8px; min-width: 0; }
.filters select, .filters input[type="search"], .filters input[type="text"] {
  padding: 7px 10px; border-radius: 7px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); font-size: 13px; font-family: inherit;
}
.filters input[type="search"] { min-width: 200px; }
.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 13px; border-radius: 7px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink); font-size: 13px;
  font-weight: 600; cursor: pointer; font-family: inherit;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #ffffff; }
.btn.primary:hover { background: var(--accent-ink); }

/* ---------- Detail / key-value blocks ---------- */
.kv { display: grid; grid-template-columns: 140px minmax(0, 1fr); gap: 6px 14px; font-size: 13.5px; }
.kv dt { color: var(--dim); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.json-block {
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 14px 16px;
  font-size: 12.5px; line-height: 1.6; white-space: pre-wrap; overflow-x: auto; max-height: 480px; overflow-y: auto;
}
.json-block.empty { color: var(--dimmer); font-style: italic; }

/* ---------- Misc ---------- */
.empty-state { color: var(--dim); padding: 24px 0; text-align: center; font-size: 13.5px; }
.badge-row { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { background: var(--mut-bg); color: var(--mut-ink); border-radius: 99px; padding: 2px 10px; font-size: 12px; font-weight: 600; }
.chip.off { font-size: 10px; padding: 1px 7px; text-transform: uppercase; letter-spacing: 0.05em; }
tr.is-off td { opacity: 0.55; }
.error-text { color: var(--bad-ink); font-size: 12.5px; }
.draft-item { border: 1px solid var(--line); border-radius: 8px; margin: 8px 0; background: var(--surface); }
.draft-item summary { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; cursor: pointer; padding: 10px 14px; list-style: none; }
.draft-item summary::-webkit-details-marker { display: none; }
.draft-item summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 8px; }
.draft-subj { font-weight: 600; }
.draft-body { margin: 0; padding: 12px 16px; border-top: 1px solid var(--line); white-space: pre-wrap;
  font: 12.5px/1.55 "Segoe UI", system-ui, sans-serif; color: var(--dim); max-height: 340px; overflow-y: auto; }
/* Expandable event payload (Events list) — truncated summary → full JSON. */
.payload-cell summary { cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; list-style: none; }
.payload-cell summary::-webkit-details-marker { display: none; }
.payload-cell[open] summary { white-space: normal; color: var(--accent-ink); }
.payload-cell pre { white-space: pre-wrap; margin: 8px 0 2px; padding: 10px 12px; background: var(--surface-2); border-radius: 7px; border: 1px solid var(--line); max-width: 560px; }
.pagination { display: flex; gap: 8px; margin-top: 16px; font-size: 13px; }
.stamp { color: var(--dim); font-size: 12.5px; }

/* ======================================================================== */
/* Client portal — premium surface. A calmer, more spacious treatment than  */
/* the admin cockpit: this is what a paying client logs into. All classes    */
/* p-prefixed so nothing here can touch admin styles; colours come from the  */
/* shared tokens above so both themes work for free.                         */
/* ======================================================================== */

.portal-body {
  background:
    radial-gradient(1100px 420px at 78% -8%, var(--accent-bg) 0%, transparent 62%),
    var(--bg);
}
.portal-shell { max-width: 1000px; margin: 0 auto; padding: 34px 24px 40px; }

/* --- masthead --- */
.pmast { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.pmast-id { display: flex; align-items: center; gap: 14px; }
.pmast-mark {
  width: 46px; height: 46px; flex: none; border-radius: 13px;
  background: var(--accent); color: #fff;
  display: grid; place-items: center;
  font: 700 21px/1 "Segoe UI Variable Display", "Segoe UI", system-ui, sans-serif;
  box-shadow: 0 4px 14px -4px var(--accent);
}
.pmast-name { font: 660 24px/1.15 "Segoe UI Variable Display", "Segoe UI", system-ui, sans-serif; letter-spacing: -0.02em; }
.pmast-tag { margin: 3px 0 0; color: var(--dim); font-size: 13.5px; }
.plive {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 12px; font-weight: 650; color: var(--good-ink);
  background: var(--good-bg); border-radius: 99px; padding: 5px 12px;
}
.plive-dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; box-shadow: 0 0 0 0 currentColor; animation: ppulse 2.4s ease-out infinite; }
@keyframes ppulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, currentColor 55%, transparent); } 70% { box-shadow: 0 0 0 7px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }
@media (prefers-reduced-motion: reduce) { .plive-dot { animation: none; } }

/* --- nav --- */
.pnav { display: flex; gap: 26px; margin: 26px 0 24px; border-bottom: 1px solid var(--line); }
.pnav a { padding: 10px 2px; color: var(--dim); font-weight: 600; font-size: 14px; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.pnav a.active { color: var(--accent-ink); border-bottom-color: var(--accent); }
.pnav a:hover { text-decoration: none; color: var(--ink); }

/* --- ROI hero --- */
.phero {
  display: grid; grid-template-columns: 1.5fr 1fr; gap: 20px; align-items: stretch;
  background: linear-gradient(140deg, var(--accent-bg), var(--surface) 118%);
  border: 1px solid var(--line); border-radius: 18px; padding: 26px 28px;
  box-shadow: var(--shadow); margin-bottom: 30px;
}
.phero-eyebrow { font-size: 11.5px; font-weight: 700; letter-spacing: 0.09em; text-transform: uppercase; color: var(--accent-ink); }
.phero-value {
  font: 700 clamp(38px, 7vw, 56px)/1 "Segoe UI Variable Display", "Segoe UI", system-ui, sans-serif;
  letter-spacing: -0.03em; color: var(--ink); margin: 10px 0 8px; font-variant-numeric: tabular-nums;
}
.phero-meta { color: var(--dim); font-size: 14px; }
.phero-meta strong { color: var(--accent-ink); font-weight: 700; }
.phero-side { display: grid; grid-template-rows: 1fr 1fr; gap: 12px; }
.phero-stat { background: var(--surface); border: 1px solid var(--line); border-radius: 13px; padding: 13px 16px; }
.phero-stat-num { font: 700 27px/1 "Segoe UI Variable Display", system-ui, sans-serif; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.phero-stat-lbl { font-size: 12px; color: var(--dim); margin-top: 3px; }
.phero-stat.hot .phero-stat-num { color: var(--hot-ink); }

/* --- sections --- */
.psection { margin-bottom: 30px; }
.psection-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.peyebrow { font-size: 11.5px; font-weight: 700; letter-spacing: 0.09em; text-transform: uppercase; color: var(--dim); margin-bottom: 14px; }
.psection-head .peyebrow { margin-bottom: 0; }
.psection-note { font-size: 12.5px; color: var(--dimmer); }
.pbadge { font-size: 11.5px; font-weight: 700; color: var(--hot-ink); background: var(--hot-bg); border-radius: 99px; padding: 3px 11px; letter-spacing: 0.02em; }

.pcard { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 18px 20px; box-shadow: var(--shadow); }
.pcols { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
.pmuted { color: var(--dim); } .psmall { font-size: 12px; }

/* --- outcome grid ("what your team did") --- */
.pgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; }
.pwork {
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  padding: 16px 17px 15px; box-shadow: var(--shadow);
  transition: transform .14s ease, border-color .14s ease, box-shadow .14s ease;
}
.pwork:hover { transform: translateY(-2px); border-color: var(--r3); box-shadow: 0 6px 20px -8px rgba(20, 100, 90, .28); }
.pwork-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 11px; }
.pwork-icon {
  width: 34px; height: 34px; border-radius: 10px; background: var(--accent-bg); color: var(--accent-ink);
  display: grid; place-items: center; font-size: 17px; line-height: 1;
}
.pwork-count { font: 700 25px/1 "Segoe UI Variable Display", system-ui, sans-serif; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.pwork-head { font-weight: 640; font-size: 14.5px; letter-spacing: -0.01em; }
.pwork-sub { color: var(--dim); font-size: 12.5px; margin-top: 3px; line-height: 1.45; }

/* --- funnel (portal) --- */
.pfrow { display: grid; grid-template-columns: 92px 1fr 34px; gap: 12px; align-items: center; margin: 9px 0; }
.pfname { font-size: 13px; color: var(--dim); text-transform: capitalize; }
.pftrack { background: var(--mut-bg); border-radius: 6px; height: 20px; overflow: hidden; }
.pfbar { height: 100%; border-radius: 0 5px 5px 0; min-width: 3px; }
.pfnum { font-variant-numeric: tabular-nums; font-weight: 700; text-align: right; }

/* --- draft email preview --- */
.pdraft { border: 1px solid var(--line); border-radius: 10px; margin: 9px 0; background: var(--surface); overflow: hidden; }
.pdraft summary { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: baseline; cursor: pointer; padding: 11px 14px; list-style: none; }
.pdraft summary::-webkit-details-marker { display: none; }
.pdraft summary:hover { background: var(--surface-2); }
.pdraft summary:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.pdraft-subj { font-weight: 640; overflow-wrap: anywhere; }
.pdraft-body { margin: 0; padding: 13px 15px; border-top: 1px solid var(--line); white-space: pre-wrap;
  font: 12.5px/1.6 "Segoe UI", system-ui, sans-serif; color: var(--dim); max-height: 320px; overflow-y: auto; overflow-wrap: anywhere; }
.pmore { display: inline-block; margin-top: 12px; font-size: 13px; font-weight: 600; color: var(--accent-ink); }

/* --- hot-leads table (portal) --- */
.ptable { border-collapse: collapse; width: 100%; font-size: 13.5px; }
.ptable th { text-align: left; font-size: 10.5px; font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase; color: var(--dim); padding: 0 14px 9px 0; border-bottom: 1px solid var(--line); white-space: nowrap; }
.ptable td { padding: 11px 14px 11px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
.ptable tbody tr:last-child td { border-bottom: none; }
.pscore {
  display: inline-grid; place-items: center; min-width: 30px; height: 26px; padding: 0 7px;
  border-radius: 8px; background: var(--hot-bg); color: var(--hot-ink);
  font-weight: 700; font-variant-numeric: tabular-nums; font-size: 14px;
}

/* --- activity timeline --- */
.ptimeline { list-style: none; margin: 0; padding: 0; }
.ptl-item { display: grid; grid-template-columns: 16px 1fr auto; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.ptl-item:last-child { border-bottom: none; }
.ptl-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--r3); margin-left: 3px; }
.ptl-what { font-size: 14px; }
.ptl-when { white-space: nowrap; }

/* --- empties + footer --- */
.pempty { color: var(--dim); text-align: center; padding: 26px 18px; }
.pempty-inline { color: var(--dimmer); font-size: 13.5px; padding: 8px 0; }
.pfoot { display: flex; align-items: flex-start; gap: 10px; margin-top: 8px; padding-top: 22px; border-top: 1px solid var(--line); color: var(--dimmer); font-size: 12.5px; line-height: 1.55; }
.pfoot-lock { font-size: 13px; line-height: 1.3; }

@media (max-width: 780px) {
  .phero { grid-template-columns: 1fr; }
  .phero-side { grid-template-rows: none; grid-template-columns: 1fr 1fr; }
  .pcols { grid-template-columns: 1fr; }
}

/* Decision-first workspace and accessible navigation. */
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.sr-only { position:absolute; width:1px; height:1px; padding:0; margin:-1px; overflow:hidden; clip:rect(0,0,0,0); white-space:nowrap; border:0; }
.skip-link { position:fixed; top:8px; left:12px; z-index:100; background:var(--surface); padding:12px 18px; border-radius:8px; transform:translateY(-150%); }
.skip-link:focus { transform:translateY(0); }
.shell { grid-template-columns:220px minmax(0,1fr); }
.main { min-width:0; width:100%; }
tr.row-link { display:table-row; cursor:pointer; }
.workbench { border:1px solid var(--line); border-radius:16px; background:var(--surface); overflow:hidden; box-shadow:var(--shadow); }
.workbench-heading { display:flex; flex-wrap:wrap; justify-content:space-between; align-items:center; gap:20px; padding:24px; }
.eyebrow { color:var(--accent-ink); font-size:11px; font-weight:700; text-transform:uppercase; letter-spacing:.12em; }
.workbench h2 { font-size:25px; font-weight:650; letter-spacing:-.03em; margin:6px 0; }
.workbench p { margin:0; max-width:48ch; }
.workbench-links { display:flex; flex-wrap:wrap; gap:8px 24px; border-top:1px solid var(--line); padding:14px 24px; background:var(--surface-2); }
.workbench-links a { display:flex; align-items:center; gap:7px; min-height:30px; font-size:13px; color:var(--ink); }
.signal { width:7px; height:7px; border-radius:50%; background:var(--accent); }
.signal.attention { background:var(--bad-ink); }
.btn { min-height:40px; }
.draft-subj { overflow-wrap:anywhere; }
@media (max-width:900px) {
 .shell { grid-template-columns:minmax(0,1fr); grid-template-rows:auto 1fr; }
 .sidebar { gap:12px; padding:16px; border-right:0; border-bottom:1px solid var(--line); }
 .sidebar .nav-group { flex-direction:row; overflow-x:auto; gap:4px; padding-bottom:4px; }
 .sidebar .nav-group-label { display:none; }
 .sidebar .nav-link { flex-shrink:0; min-height:42px; }
 .client-switcher { padding:0; }
 .main { padding:24px 18px 48px; }
}
@media (max-width:520px) {
 .workbench-heading { padding:20px; }
 .workbench-heading .btn { width:100%; justify-content:center; }
 .workbench-links { padding:12px 20px; }
 .draft-item summary { flex-wrap:wrap; }
 .topbar h1 { font-size:22px; overflow-wrap:anywhere; }
 .tiles { grid-template-columns:repeat(2,minmax(0,1fr)); }
}

.btn.primary { background:#0a5f59; border-color:#0a5f59; color:#fff; }
@media (prefers-color-scheme:dark) { .btn.primary { background:#3db3a8; border-color:#3db3a8; color:#0f1514; } }

/* Keep client names, long identifiers, and proposal content inside narrow views. */
.pmast-id, .pmast-id > div, .phero-main, .pcols > *, .pgrid > * { min-width: 0; }
.pmast-name, .phero-value, .pdraft summary, .draft-body { overflow-wrap: anywhere; }
.filters input, .filters select { max-width: 100%; }
@media (max-width: 520px) {
  .kv { grid-template-columns: minmax(0, 1fr); gap: 3px; }
  .kv dd { margin-bottom: 9px; }
  .portal-shell { padding: 24px 16px 36px; }
  .phero { padding: 20px; }
  .phero-side { grid-template-columns: minmax(0, 1fr); }
  .pgrid { grid-template-columns: minmax(0, 1fr); }
  .ptl-item { grid-template-columns: 16px minmax(0, 1fr); gap: 3px 12px; }
  .ptl-when { grid-column: 2; white-space: normal; }
}

/* The overview keeps summaries compact; full lead details remain one link away. */
@media (max-width: 600px) {
  .recent-leads { table-layout: fixed; }
  .recent-leads .lead-reason, .recent-leads .lead-updated { display: none; }
  .recent-leads th:first-child { width: 55%; }
  .recent-leads th:nth-child(2) { width: 15%; }
  .recent-leads th:nth-child(3) { width: 30%; }
  .recent-leads .lead-identity { overflow-wrap: anywhere; }
  .recent-leads .pill { max-width: 100%; white-space: normal; overflow-wrap: anywhere; font-size: 9px; padding: 2px 6px; }
  .recent-leads th, .recent-leads td { padding-right: 8px; }
  .recent-leads tbody tr:nth-child(n + 6) { display: none; }
}

.metric-note { margin: 12px 0 24px; color: var(--dim); font-size: 12px; }
.metric-note summary { cursor: pointer; font-weight: 600; padding: 6px 0; }
.metric-note p { max-width: 90ch; margin: 8px 0; }

/* Review and recovery screens must contain long recipients, subjects, and client names. */
.message-card { overflow-wrap: anywhere; }

@media (max-width: 600px) {
  .filters { align-items: flex-end; }
  .filter-field { display: grid; gap: 4px; }
}

/* Individual account and email-code sign-in surfaces. */
.auth-shell { width: min(100% - 32px, 480px); margin: 64px auto; }
.auth-card { padding: 28px; margin: 24px 0 16px; }
.auth-card h1 { font-size: 28px; margin: 8px 0 12px; letter-spacing: -.03em; }
.auth-form { display: flex; flex-direction: column; gap: 10px; margin-top: 24px; }
.auth-form label { font-size: 14px; font-weight: 600; }
.auth-form input:not([type="hidden"]) { min-width: 0; width: 100%; min-height: 44px; box-sizing: border-box; padding: 10px 12px; border: 1px solid var(--dim); border-radius: 7px; background: var(--surface); color: var(--ink); font: inherit; }
.auth-form #code { letter-spacing: .15em; font-variant-numeric: tabular-nums; }
.sidebar .account-bar { margin-top: 0; gap: 8px; }
.auth-form button { margin-top: 8px; min-height: 44px; }
.auth-form input[readonly] { background: var(--mut-bg); color: var(--mut-ink); }
.auth-error { border-left: 3px solid currentColor; padding: 12px; background: var(--mut-bg); }
.auth-back { display: inline-block; margin-top: 20px; }
.account-bar { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; margin-top: 24px; overflow-wrap: anywhere; }
.account-bar form { margin: 0; }
.workspace-choice { display: flex; flex-direction: column; gap: 6px; padding: 16px 0; border-bottom: 1px solid var(--line); }
@media (max-width: 640px) { .auth-shell { margin: 32px auto; } .auth-card { padding: 20px; } }
.execution-control { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 16px; padding: 18px 20px; }
.execution-control > div { flex: 1 1 260px; }
.execution-control p { margin: 6px 0 0; }
.execution-control form { margin: 0; }

.setup-card { padding: 22px; }
.setup-heading { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.setup-heading h2 { margin-top: 4px; font-size: 23px; }
.setup-heading h3 { font-size: 16px; }
.setup-checklist { padding-left: 20px; margin-bottom: 0; }
.setup-checklist li { margin: 10px 0; }
.setup-provider-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.setup-provider-grid > * { min-width: 0; }
.setup-modules { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
button:disabled { cursor: not-allowed; opacity: .65; }
@media (max-width: 640px) { .setup-provider-grid { grid-template-columns: 1fr; } .setup-card { padding: 18px; } }
