/* ═════════════════════════════════════════════════════════════════════
   SPECTRA /// SENDER — Shell + layout
   ═════════════════════════════════════════════════════════════════════
   Two jobs in one file:

   1. Sender-only shell additions — the collapsed-rail /// mark, the
      SMS/Email channel toggle in the sidebar footer, the Labs
      signature override (left-aligned), and session-status alignment.

   2. Inner-page layout — bounds every container that would otherwise
      stretch to fill the viewport. Charts, KPI grids, tables, cards,
      and the page wrapper all get explicit max-widths and explicit
      heights so an SVG with a viewBox can never blow up.
   ═════════════════════════════════════════════════════════════════════ */

/* ═══════════════════════════════════════════════════════════════════
   1. SHELL ADDITIONS
   ═══════════════════════════════════════════════════════════════════ */

/* ── Collapsed-rail mark — the /// cluster that replaces the
       wordmark when the sidebar collapses. ─────────────────────── */
.brand-collapsed-mark {
  display: none;
  align-items: center;
  justify-content: center;
  width: 100%;
}
.brand-collapsed-mark .slashes {
  display: inline-flex;
  gap: 3px;
  transform: skewX(-15deg);
  font-family: var(--mono);
  font-weight: 700;
  font-size: 22px;
  line-height: 1;
}
.brand-collapsed-mark .slashes span { display: inline-block; line-height: 1; }
.brand-collapsed-mark .slash-teal { color: var(--brand-blue); }
.brand-collapsed-mark .slash-mint { color: var(--sender); }

.app.collapsed .sidebar .brand .logo-stack { display: none !important; }
.app.collapsed .sidebar .brand .brand-collapsed-mark { display: flex !important; }
.app.collapsed .sidebar .brand {
  justify-content: center;
  padding: 18px 8px 16px;
}
.app.collapsed .sidebar .nav-lbl,
.app.collapsed .sidebar .nav-badge,
.app.collapsed .sidebar .nav-grp,
.app.collapsed .sidebar .channel-btn span,
.app.collapsed .sidebar .footer-btn .label,
.app.collapsed .sidebar .session-status,
.app.collapsed .sidebar .idle-chip,
.app.collapsed .sidebar .labs-signature { display: none !important; }

.app.collapsed .sidebar .nav-link { justify-content: center; padding: 10px; }
.app.collapsed .sidebar .nav-link.active::before { left: 0; }
.app.collapsed .sidebar .footer-btn { justify-content: center; padding: 10px; }
.app.collapsed .sidebar .channel-toggle { justify-content: center; }
.app.collapsed .sidebar .channel-btn { padding: 6px 8px; }
.app.collapsed .sidebar .sidebar-controls { padding: 0 4px; }

/* ── Session status — align pip and label with icon column ──── */
.sidebar .session-status { padding: 2px 10px; }
.sidebar .idle-chip { padding: 2px 10px; }

/* ── Channel toggle — SMS / Email ───────────────────────────── */
.sidebar-controls {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
}

.channel-toggle {
  display: flex;
  width: 100%;
  padding: 3px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  gap: 2px;
  box-sizing: border-box;
}

.channel-btn {
  flex: 1 1 0;
  min-width: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 7px 10px;
  border-radius: var(--r-sm);
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--fg-mute);
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
  background: transparent;
  border: none;
  white-space: nowrap;
  pointer-events: auto;
  line-height: 1.2;
}
.channel-btn svg { width: 12px; height: 12px; stroke-width: 2; flex-shrink: 0; }
.channel-btn:hover { color: var(--fg-dim); }
.channel-btn.active {
  background: var(--card-bg-solid);
  color: var(--sender);
  box-shadow: inset 0 0 0 1px var(--sender-line);
}
.channel-btn:focus-visible { outline: 2px solid var(--sender); outline-offset: 2px; }

/* ── Labs signature — left-aligned ──────────────────────────── */
.sidebar .labs-signature {
  padding-top: 12px;
  padding-left: 10px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-start;
  align-items: flex-start;
}
.sidebar .labs-signature .logo-stack {
  display: flex;
  flex-direction: column;
  gap: 3px;
  user-select: none;
  align-items: flex-start;
}
.sidebar .labs-signature .logo-row {
  display: flex;
  align-items: center;
  gap: 8px;
  text-transform: uppercase;
  white-space: nowrap;
}
.sidebar .labs-signature .logo-row.top-row {
  font-size: 11px;
  font-weight: 200;
  letter-spacing: 2.6px;
  color: var(--brand-blue);
  line-height: 1.05;
}
.sidebar .labs-signature .logo-row.bottom-row {
  font-size: 7px;
  font-weight: 300;
  letter-spacing: 3px;
  color: var(--fg-bright);
  line-height: 1.05;
}
.sidebar .labs-signature .slashes {
  display: inline-flex;
  gap: 2px;
  transform: skewX(-15deg);
  font-weight: 700;
  font-size: 10px;
  line-height: 1;
}
.sidebar .labs-signature .slashes span { display: inline-block; line-height: 1; }
.sidebar .labs-signature .slash-coral { color: var(--brand-pink); }
.sidebar .labs-signature .slash-mint  { color: var(--sender); }
.sidebar .labs-signature .slash-teal  { color: var(--brand-blue); }
.sidebar .labs-signature .slash-white { color: var(--fg-bright); }


/* ═══════════════════════════════════════════════════════════════════
   2. INNER-PAGE LAYOUT
   ═══════════════════════════════════════════════════════════════════
   Everything below fixes the giant-arrow problem and any related
   stretch issues. The rule is: if a container has an SVG in it,
   the container MUST have an explicit height and the SVG MUST be
   width:100% height:100% with preserveAspectRatio="none" (or the
   chart module must set width/height itself).
   ═══════════════════════════════════════════════════════════════════ */

/* ── Content column — bounded, centered, no unbounded stretch ── */
.content,
#page-host {
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

/* ── Every direct child of the page host gets a max-width ────── */
#page-host > * {
  max-width: 100%;
  min-width: 0;
}

/* ── Page head — reset any inherited huge text ───────────────── */
#page-host .page-head {
  margin-bottom: 22px;
  min-width: 0;
}
#page-host .page-head h1 {
  font-size: 22px;
  line-height: 1.2;
  word-break: break-word;
}
#page-host .page-head .ph-desc {
  max-width: 720px;
  font-size: 12.5px;
  line-height: 1.6;
}

/* ── KPI / metric grids — bounded columns, min-width:0 ────────── */
.kpi-grid,
.metrics,
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 22px;
  min-width: 0;
}
@media (max-width: 900px) {
  .kpi-grid,
  .metrics,
  .metrics-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
  .kpi-grid,
  .metrics,
  .metrics-grid { grid-template-columns: 1fr; }
}

.kpi-grid > *,
.metrics > *,
.metrics-grid > * {
  min-width: 0;
}

/* ── Chart rows — explicit heights, no unbounded SVGs ────────── */
.home-chart-row,
.chart-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
  margin-bottom: 22px;
  min-width: 0;
}
.home-chart-row > *,
.chart-grid > * {
  min-width: 0;
}

.chart-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 16px 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
  min-height: 0;
}
.chart-card .chart-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
}
.chart-card .chart-head .ct {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--fg-dim);
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.chart-card .chart-head .cm {
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--fg-faint);
  flex-shrink: 0;
}

/* ── THE CRITICAL RULE: chart bodies are always 180px tall ──── */
.chart-card .chart-body,
.chart-body {
  position: relative;
  height: 180px;
  min-height: 180px;
  max-height: 180px;
  width: 100%;
  min-width: 0;
  overflow: hidden;
}

/* ── Every SVG inside a chart body fills it, never overflows ─── */
.chart-card .chart-body > svg,
.chart-body > svg,
.chart-body svg {
  display: block;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  overflow: visible;
  box-sizing: border-box;
}

/* ── The dashboard chart-body wrapper used in this codebase ──── */
.chart-body-flex {
  position: relative;
  height: 180px;
  min-height: 180px;
  max-height: 180px;
  width: 100%;
  min-width: 0;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.chart-body-flex > svg,
.chart-body-flex svg {
  display: block;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
}

/* ── The arrow-SVG from the screenshot: it lives inside a chart
       body. If it still overflows, clamp it explicitly. ──────── */
.chart-card svg,
.chart-body svg,
.home-chart-row svg {
  max-height: 180px;
}

.chart-card .chart-cap {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--fg-faint);
  line-height: 1.5;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Donut grid (channel split card) ─────────────────────────── */
.donut-wrap {
  display: flex;
  justify-content: space-around;
  align-items: center;
  width: 100%;
  gap: 12px;
  min-width: 0;
}
.donut-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.donut {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.donut-inner {
  width: 46px;
  height: 46px;
  background: var(--bg-2);
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
  color: var(--fg-bright);
  z-index: 2;
  box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.8);
}
.donut-label {
  font-family: var(--mono);
  font-size: 9px;
  color: var(--fg-mute);
  text-align: center;
  line-height: 1.3;
}

/* ── Data table wrappers — bounded, scrollable ───────────────── */
.dt-wrap,
.tbl-wrap {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-width: 0;
  max-width: 100%;
}

.dt-scroll,
.tbl-scroll {
  overflow-x: auto;
  overflow-y: visible;
  max-width: 100%;
  min-width: 0;
}

.dt,
.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
  table-layout: auto;
}

/* ── Card head — reset any inherited huge text ───────────────── */
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
  min-width: 0;
  flex-wrap: wrap;
}
.card-head .ttl {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--fg-dim);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.card-head .ttl svg {
  width: 12px;
  height: 12px;
  stroke-width: 2.2;
  color: var(--sender);
  flex-shrink: 0;
}

/* ── Section heads — reset huge text, bounded max-width ──────── */
.sect-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 14px;
  flex-wrap: wrap;
  min-width: 0;
}
.sect-head h2 {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fg-dim);
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.sect-head h2 svg {
  width: 13px;
  height: 13px;
  stroke-width: 2.2;
  color: var(--sender);
  flex-shrink: 0;
}

/* ── Cards — bounded padding, no unbounded stretch ───────────── */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 18px;
  min-width: 0;
}

/* ── Live feed rows — bounded ────────────────────────────────── */
#live-feed > *,
.live-feed > * {
  min-width: 0;
  max-width: 100%;
}

/* ── Generic "grid-2" / "grid-3" helpers used in partials ────── */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
  min-width: 0;
}
.grid-3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
  min-width: 0;
}
.grid-2 > *,
.grid-3 > * { min-width: 0; }

/* ── Provider grid — bounded ─────────────────────────────────── */
.provider-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
  min-width: 0;
}
.provider-grid > * { min-width: 0; }

/* ── Empty state — bounded width so it doesn't stretch ───────── */
.empty-state {
  padding: 56px 24px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  min-width: 0;
  max-width: 100%;
}
.empty-state .sub { max-width: 400px; }

/* ── Widgets from campaign-detail / composer / runner ────────── */
.composer-grid,
.test-layout,
.cd-grid {
  display: grid;
  gap: 20px;
  min-width: 0;
}
.composer-grid { grid-template-columns: minmax(0, 1fr) 380px; }
.test-layout  { grid-template-columns: minmax(0, 1fr) 380px; }
.cd-grid      { grid-template-columns: 1fr 1fr; }

@media (max-width: 1100px) {
  .composer-grid,
  .test-layout { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .cd-grid { grid-template-columns: 1fr; }
}

.composer-grid > *,
.test-layout > *,
.cd-grid > * { min-width: 0; }

/* ── Every img and svg on the page: never overflow its parent ── */
#page-host img,
#page-host svg {
  max-width: 100%;
}

/* ── Buttons inside head bars wrap gracefully ────────────────── */
.page-head .page-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  min-width: 0;
}

/* ═══════════════════════════════════════════════════════════════════
   WORKSPACE SWITCHER
   The chip sits at the top of the sidebar, above the nav. It is a
   button that opens a popover. Its visual grammar matches the user
   chip in the topbar and the footer buttons in the sidebar.
   ═══════════════════════════════════════════════════════════════════ */

.workspace-wrap {
  padding: 12px 12px 6px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  position: relative;
}

.workspace-chip {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 10px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: all 0.15s;
  text-align: left;
  color: var(--fg-dim);
  min-width: 0;
}
.workspace-chip:hover {
  border-color: var(--sender-line);
  background: var(--sender-soft);
  color: var(--fg-bright);
}
.workspace-chip.dirty {
  border-color: var(--amber);
}
.workspace-chip.empty {
  border-style: dashed;
  color: var(--fg-mute);
}

.ws-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
  transition: all 0.2s;
}
.ws-dot.on {
  background: var(--sender);
  box-shadow: 0 0 6px var(--sender);
}
.ws-dot.off {
  background: var(--fg-faint);
}

.ws-body { flex: 1; min-width: 0; line-height: 1.2; }
.ws-name {
  font-family: var(--mono);
  font-size: 11.5px;
  font-weight: 500;
  color: var(--fg-bright);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-bottom: 2px;
}
.ws-dirty { color: var(--amber); font-size: 9px; }
.ws-meta {
  font-family: var(--mono);
  font-size: 9.5px;
  color: var(--fg-mute);
  letter-spacing: 0.02em;
  display: flex;
  align-items: center;
  gap: 5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ws-meta svg { width: 10px; height: 10px; flex-shrink: 0; color: var(--amber); }
.ws-caret {
  width: 12px; height: 12px;
  color: var(--fg-mute);
  flex-shrink: 0;
  transition: transform 0.15s;
}
.workspace-chip:hover .ws-caret { color: var(--sender); }

/* ── Workspace popover ───────────────────────────────────────────── */
.workspace-popover {
  position: absolute;
  top: calc(100% + 6px);
  left: 12px;
  right: 12px;
  background: var(--card-bg-solid);
  border: 1px solid var(--border-hi);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  z-index: 100;
  padding: 8px;
  animation: popIn 0.18s var(--ease-out);
  max-height: calc(100vh - 120px);
  overflow-y: auto;
}
.workspace-popover[hidden] { display: none; }

.wp-head {
  padding: 8px 10px 10px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}
.wp-title {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fg-dim);
  font-weight: 600;
}
.wp-meta {
  font-family: var(--mono);
  font-size: 9.5px;
  color: var(--fg-faint);
  letter-spacing: 0.06em;
}

.wp-current {
  padding: 10px 12px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  margin-bottom: 8px;
}
.wp-current-name {
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--fg-bright);
  font-weight: 500;
  margin-bottom: 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.wp-current-path {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--fg-mute);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-bottom: 8px;
}
.wp-current-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--fg-dim);
}
.wp-current-stats strong {
  color: var(--fg-bright);
  font-weight: 500;
  margin-right: 3px;
}
.wp-dirty { color: var(--amber); }

.wp-empty {
  padding: 14px 12px;
  text-align: center;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--fg-mute);
  line-height: 1.55;
  border: 1px dashed var(--border-hi);
  border-radius: var(--r-md);
  margin-bottom: 8px;
}

.wp-section-head {
  padding: 10px 10px 6px;
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--fg-faint);
  font-weight: 600;
}

.wp-recent {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 4px;
}
.wp-recent-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 10px;
  border-radius: var(--r-sm);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: background 0.12s;
  text-align: left;
  color: var(--fg-dim);
  min-width: 0;
}
.wp-recent-item:hover {
  background: var(--sender-soft);
  color: var(--sender);
}
.wp-recent-item svg {
  width: 12px; height: 12px;
  flex-shrink: 0;
  color: var(--fg-mute);
}
.wp-recent-item:hover svg { color: var(--sender); }
.wp-recent-name {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--fg-bright);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex-shrink: 0;
}
.wp-recent-path {
  font-family: var(--mono);
  font-size: 9.5px;
  color: var(--fg-mute);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-left: auto;
}

.wp-actions, .wp-security {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.wp-action {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: background 0.12s;
  text-align: left;
  color: var(--fg-dim);
  font-size: 12px;
  width: 100%;
}
.wp-action:hover:not(:disabled) {
  background: var(--sender-soft);
  color: var(--sender);
}
.wp-action:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}
.wp-action svg {
  width: 13px; height: 13px;
  stroke-width: 1.85;
  flex-shrink: 0;
  color: var(--fg-mute);
}
.wp-action:hover:not(:disabled) svg { color: var(--sender); }
.wp-kbd {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 9.5px;
  padding: 2px 6px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--fg-faint);
  letter-spacing: 0.06em;
}

/* ── Collapsed sidebar — hide the workspace chip body, keep the dot ── */
.app.collapsed .workspace-wrap {
  padding: 10px 8px 6px;
}
.app.collapsed .workspace-chip {
  justify-content: center;
  padding: 8px 0;
}
.app.collapsed .workspace-chip .ws-body,
.app.collapsed .workspace-chip .ws-caret {
  display: none;
}
.app.collapsed .workspace-chip .ws-dot {
  width: 10px;
  height: 10px;
}
.app.collapsed .workspace-popover {
  left: 72px;
  right: auto;
  width: 300px;
}