/* ============================================================
   XSELLEREIGHT · Org Chart
   Attio-inspired · light · airy · pill nav · refined sans
   ============================================================ */

:root {
  /* Surfaces */
  --bg:            #f5f4f2;
  --sidebar-bg:    #f1f0ed;
  --surface:       #ffffff;
  --surface-2:     #f7f6f4;
  --surface-3:     #ecebe7;

  /* Borders */
  --border:        #e7e5e0;
  --border-strong: #d8d5cd;
  --hairline:      rgba(20,18,14,0.06);

  /* Text */
  --text:          #14130f;
  --text-soft:     #3d3a34;
  --text-muted:    #807c73;
  --text-faint:    #b3afa5;

  /* Accent */
  --accent:        #14130f;
  --accent-blue:   #2563eb;
  --accent-blue-soft: #e0eaff;

  /* Department palette - soft tinted backgrounds for avatars + dots */
  --dept-executive:        #e9d8ff;   --dept-executive-fg:   #5b2bb1;
  --dept-operations:       #ffe4cc;   --dept-operations-fg:  #8b4a14;
  --dept-finance:          #d3f2dd;   --dept-finance-fg:     #1a6b3c;
  --dept-legal:            #d8e3ff;   --dept-legal-fg:       #1f3da6;
  --dept-creative:         #ffd4e0;   --dept-creative-fg:    #a02050;
  --dept-growth:           #fde9b3;   --dept-growth-fg:      #82591a;
  --dept-engineering:      #cdebe9;   --dept-engineering-fg: #0e5e57;

  --ok:            #15a06b;
  --warn:          #d99a3a;
  --danger:        #c92a2a;

  /* Geometry */
  --radius-xs:     6px;
  --radius-sm:     8px;
  --radius:        12px;
  --radius-lg:     16px;
  --radius-pill:   999px;

  --shadow-card:   0 0 0 1px rgba(20,18,14,0.04), 0 1px 2px rgba(20,18,14,0.04);
  --shadow-active: 0 0 0 1px rgba(20,18,14,0.06), 0 1px 2px rgba(20,18,14,0.06);
  --shadow-pop:    0 0 0 1px rgba(20,18,14,0.05), 0 12px 32px -10px rgba(20,18,14,0.16);

  /* Type */
  --font-sans:     "Manrope", ui-sans-serif, system-ui, -apple-system, sans-serif;
  --font-mono:     "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;

  /* Layout */
  --sidebar-w:     244px;
  --content-pad:   24px;
  --connector:     #d8d5cd;
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  letter-spacing: -0.005em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; border: none; background: none; color: inherit; padding: 0; }
input { font: inherit; }
h1, h2, h3, h4, p, ul { margin: 0; padding: 0; }
ul { list-style: none; }
svg { width: 1em; height: 1em; display: block; flex-shrink: 0; }

/* ============================================================
   APP SHELL
   ============================================================ */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
  background: var(--bg);
  transition: grid-template-columns 180ms ease;
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
  background: var(--sidebar-bg);
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: hidden;               /* the inner .nav scrolls; sidebar itself never shows a bar */
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.sidebar::-webkit-scrollbar,
.sidebar::-webkit-scrollbar-track,
.sidebar::-webkit-scrollbar-thumb { width: 0; height: 0; display: none; background: transparent; }

.workspace { display: flex; align-items: center; gap: 4px; padding: 4px; position: relative; }
.workspace-trigger {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px 6px 6px;
  border-radius: var(--radius-sm);
  flex: 1; min-width: 0;
  transition: background 100ms ease;
}
.workspace-trigger:hover { background: var(--surface-3); }
.workspace-mark {
  width: 22px; height: 22px;
  border-radius: 6px;
  background: var(--text); color: var(--bg);
  display: grid; place-items: center;
  font-size: 14px; flex-shrink: 0;
}
.workspace-name {
  font-size: 13.5px; font-weight: 600; color: var(--text);
  letter-spacing: -0.01em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  flex: 1; min-width: 0; text-align: left;
}
.workspace-chev { font-size: 14px; color: var(--text-muted); margin-left: auto; flex-shrink: 0; transition: transform 140ms ease; }
.workspace-trigger[aria-expanded="true"] .workspace-chev { transform: rotate(180deg); }

/* Full brand wordmark in the switcher (same lockup as the contracts) */
.workspace-logo { height: 18px; width: auto; max-width: 150px; display: block; flex-shrink: 0; }

/* Workspace switcher dropdown menu */
.workspace-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 4px;
  right: 4px;
  z-index: 60;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-pop);
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.workspace-menu[hidden] { display: none; }
.workspace-menu-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-align: left;
  width: 100%;
  transition: background 100ms ease;
}
.workspace-menu-item:hover { background: var(--surface-2); }
.wm-mark {
  width: 24px; height: 24px;
  border-radius: 6px;
  background: var(--text);
  display: grid; place-items: center;
  flex-shrink: 0;
}
.wm-mark img { width: 13px; height: 13px; display: block; }
.wm-mark-3d {
  background: transparent;
  border-radius: 0;
  overflow: visible;
}
.wm-mark-3d img {
  width: 24px;
  height: 24px;
  object-fit: contain;
  filter: drop-shadow(0 1px 1px rgba(20,18,14,0.18));
}
.wm-mark-academy-3d img {
  filter: drop-shadow(0 1px 1px rgba(111,73,13,0.2));
}
.wm-mark-academy { background: var(--dept-creative-fg); }
.wm-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.wm-name { font-size: 13px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wm-sub { font-size: 10.5px; color: var(--text-muted); }
.wm-check { width: 16px; height: 16px; color: var(--accent-blue); flex-shrink: 0; }
.workspace-menu-item:not(.is-current) .wm-check { display: none; }
.workspace-menu-sep { height: 1px; background: var(--border); margin: 5px 2px; }
.wm-action { gap: 10px; }
.wm-ico {
  width: 24px; height: 24px;
  display: grid; place-items: center;
  color: var(--text-muted);
  flex-shrink: 0;
}
.wm-ico svg { width: 16px; height: 16px; }
.wm-action .wm-name { font-weight: 500; color: var(--text-soft); }
.wm-action:hover .wm-name { color: var(--text); }
.wm-action:hover .wm-ico { color: var(--text); }

.icon-btn {
  width: 28px; height: 28px;
  border-radius: var(--radius-xs);
  display: grid; place-items: center;
  color: var(--text-muted);
  transition: background 100ms ease, color 100ms ease;
  flex-shrink: 0;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn svg { font-size: 15px; }

.qa-row { display: flex; gap: 4px; padding: 0 4px 4px; }
.qa {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  background: var(--surface-3);
  color: var(--text-muted);
  font-size: 12.5px; font-weight: 500;
  flex: 1; min-width: 0;
  transition: background 100ms ease, color 100ms ease;
}
.qa:hover { background: #e3e1da; color: var(--text-soft); }
.qa-icon { font-size: 13px; color: var(--text-soft); }
.qa > span { flex: 1; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.qa kbd {
  font-family: var(--font-mono);
  font-size: 10.5px;
  background: var(--surface);
  padding: 1px 5px; border-radius: 4px;
  color: var(--text-muted);
  border: 1px solid var(--border); font-weight: 500;
}
.qa-narrow { flex: 0 0 auto; padding: 6px 8px; }
.qa-narrow svg { font-size: 13px; }
.qa-full { width: 100%; }
.qa-full > span { color: var(--text-muted); }

/* ---------- Global search palette (Cmd+K) ---------- */
.cmdk-overlay {
  position: fixed; inset: 0;
  background: rgba(20, 18, 14, 0.36);
  z-index: 9000;
  display: grid;
  place-items: start center;
  padding-top: 12vh;
  animation: fadeIn 100ms ease;
}
.cmdk-overlay[hidden] { display: none; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.cmdk {
  width: min(640px, 92vw);
  max-height: 70vh;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 24px 60px -12px rgba(15, 18, 32, 0.35);
  display: flex; flex-direction: column;
  overflow: hidden;
  animation: cmdkPop 140ms ease;
}
@keyframes cmdkPop { from { transform: translateY(-6px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.cmdk-input-row {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.cmdk-input-row svg { color: var(--text-muted); flex: 0 0 auto; }
.cmdk-input-row input {
  border: 0; outline: 0; background: transparent;
  flex: 1; font-size: 15px; color: var(--text);
  font-family: var(--font-sans);
}
.cmdk-input-row input::placeholder { color: var(--text-faint); }
.cmdk-esc {
  font-family: var(--font-mono);
  font-size: 10.5px;
  background: var(--surface-2);
  padding: 2px 7px; border-radius: 4px;
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.cmdk-results {
  flex: 1;
  overflow: auto;
  padding: 6px 0;
}
.cmdk-group { padding: 4px 0 8px; }
.cmdk-group-label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  font-weight: 600;
  padding: 8px 16px 4px;
}
.cmdk-item {
  display: grid;
  grid-template-columns: 24px 1fr;
  gap: 12px;
  align-items: center;
  width: 100%;
  padding: 9px 16px;
  background: transparent;
  border: 0;
  cursor: pointer;
  text-align: left;
  color: var(--text);
}
.cmdk-item:hover { background: var(--surface-2); }
.cmdk-item.is-active { background: var(--surface-2); }
.cmdk-item-icon {
  width: 24px; height: 24px;
  display: grid; place-items: center;
  color: var(--text-muted);
}
.cmdk-item-text { display: flex; flex-direction: column; min-width: 0; }
.cmdk-item-title {
  font-size: 13px; font-weight: 500; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cmdk-item-sub {
  font-size: 11.5px; color: var(--text-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  margin-top: 2px;
}
.cmdk-empty {
  padding: 28px 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}
.cmdk-foot {
  display: flex; gap: 16px;
  padding: 9px 14px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  font-size: 11px;
  color: var(--text-muted);
}
.cmdk-foot kbd {
  font-family: var(--font-mono);
  font-size: 10px;
  background: var(--surface);
  padding: 1px 5px;
  border-radius: 3px;
  border: 1px solid var(--border);
  margin-right: 3px;
}

/* ---------- Nav ---------- */
.nav {
  display: flex; flex-direction: column; gap: 4px;
  flex: 1; padding: 4px 0;
  min-height: 0;                  /* let flex shrink so internal scroll is what actually scrolls */
  overflow-y: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.nav::-webkit-scrollbar,
.nav::-webkit-scrollbar-track,
.nav::-webkit-scrollbar-thumb { width: 0; height: 0; display: none; background: transparent; }
.nav-group { display: flex; flex-direction: column; gap: 1px; }

.nav-item {
  display: flex; align-items: center; gap: 9px;
  padding: 5px 8px; margin: 0 4px;
  border-radius: var(--radius-sm);
  color: var(--text-soft);
  font-size: 13px; font-weight: 500;
  letter-spacing: -0.005em;
  position: relative;
  transition: background 90ms ease, color 90ms ease;
}
.nav-item svg { font-size: 15px; color: var(--text-muted); transition: color 90ms ease; }
.nav-item:hover { background: var(--surface-3); color: var(--text); }
.nav-item:hover svg { color: var(--text-soft); }
.nav-item.active {
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  box-shadow: var(--shadow-active);
}
.nav-item.active svg { color: var(--text); }

.nav-item > span:first-of-type:not(.nav-badge):not(.nav-meta) { flex: 1; min-width: 0; }
.nav-item.child { padding-left: 26px; }

.nav-badge {
  font-size: 10.5px; font-weight: 600;
  font-family: var(--font-mono);
  background: var(--accent-blue-soft); color: var(--accent-blue);
  padding: 1px 6px; border-radius: var(--radius-pill);
}
.nav-meta {
  font-size: 11px; color: var(--text-faint);
  font-weight: 400; font-family: var(--font-mono);
}

.nav-section {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 8px; margin: 6px 4px 0;
  font-size: 11.5px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-muted);
  border-radius: var(--radius-xs);
  text-align: left;
  width: calc(100% - 8px);
  transition: color 90ms ease, background 90ms ease;
}
.nav-section:hover { color: var(--text-soft); background: var(--surface-3); }
.nav-section .chev {
  font-size: 11px; color: var(--text-faint);
  transition: transform 150ms ease;
}
.nav-section.open .chev { transform: rotate(90deg); }
.nav-section .folder { font-size: 14px; color: var(--text-muted); }

.nav-section.sub {
  text-transform: none;
  font-size: 13px; font-weight: 500;
  letter-spacing: -0.005em;
  color: var(--text-soft);
  padding: 5px 8px; margin: 0 4px;
  border-radius: var(--radius-sm);
}
.nav-section.sub:hover { background: var(--surface-3); color: var(--text); }

.nav-children {
  display: flex; flex-direction: column; gap: 1px;
  overflow: hidden; max-height: 800px;
  transition: max-height 220ms ease;
}
.nav-children.collapsed { max-height: 0; }
.nav-children.sub { padding-left: 16px; }
.nav-children.sub .nav-item.child { padding-left: 28px; }

.sidebar-bottom { padding: 6px 4px 2px; }
.user-card {
  display: flex; align-items: center; gap: 9px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  width: 100%;
  transition: background 100ms ease;
}
.user-card:hover { background: var(--surface-3); }
.user-avatar {
  width: 26px; height: 26px;
  border-radius: 7px;
  background: var(--dept-executive); color: var(--dept-executive-fg);
  display: grid; place-items: center;
  font-size: 10.5px; font-weight: 700;
  letter-spacing: 0.02em; flex-shrink: 0;
}
.user-meta { flex: 1; min-width: 0; line-height: 1.2; text-align: left; }
.user-name {
  font-size: 12.5px; font-weight: 600; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.user-role { font-size: 11px; color: var(--text-muted); margin-top: 1px; }
.user-chev { font-size: 12px; color: var(--text-faint); }

@media (min-width: 861px) {
  body.sidebar-collapsed .app {
    grid-template-columns: 58px 1fr;
  }

  body.sidebar-collapsed .sidebar {
    padding-inline: 6px;
    align-items: stretch;
  }

  body.sidebar-collapsed .workspace {
    justify-content: center;
    padding-inline: 0;
  }

  body.sidebar-collapsed .workspace-trigger,
  body.sidebar-collapsed .qa-row,
  body.sidebar-collapsed .sidebar-bottom,
  body.sidebar-collapsed .nav-section {
    display: none;
  }

  body.sidebar-collapsed .nav {
    align-items: center;
    gap: 6px;
    padding-top: 8px;
  }

  body.sidebar-collapsed .nav-group {
    width: 100%;
    gap: 3px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border);
  }

  body.sidebar-collapsed .nav-group:last-child {
    border-bottom: 0;
    padding-bottom: 0;
  }

  body.sidebar-collapsed .nav-children {
    max-height: none;
    overflow: visible;
  }

  body.sidebar-collapsed .nav-item,
  body.sidebar-collapsed .nav-item.child {
    width: 36px;
    height: 34px;
    margin-inline: auto;
    padding: 0;
    justify-content: center;
    gap: 0;
  }

  body.sidebar-collapsed .nav-item svg {
    font-size: 16px;
  }

  body.sidebar-collapsed .nav-item > span,
  body.sidebar-collapsed .nav-badge,
  body.sidebar-collapsed .nav-meta {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }
}

/* ============================================================
   MAIN
   ============================================================ */
/* The frame around the main .surface card uses the sidebar's soft gray (not
   white) so the white card reads as a clean panel floating on a matching
   backdrop - gray on every side (sidebar on the left, this frame on the rest). */
.main { padding: 10px 10px 10px 0; min-width: 0; background: var(--sidebar-bg); }
.surface {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  min-height: calc(100vh - 20px);
  display: flex; flex-direction: column;
  overflow: hidden;
}

/* ---------- Page header ---------- */
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.page-header-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.page-icon {
  width: 22px; height: 22px;
  display: grid; place-items: center;
  color: var(--text-muted);
  font-size: 16px;
}
/* On Delivery the page title/sub/icon all give way to the filter chips. */
.view[data-view="pipeline-board"]:has(.pipeline-board-body.is-fixed-height) .page-icon {
  display: none;
}
.page-title { font-size: 15px; font-weight: 600; color: var(--text); letter-spacing: -0.01em; }
.page-header-right { display: flex; gap: 8px; align-items: center; position: relative; }

/* ---------- Offers & ICP tabs (compact, on the right of the header) ---------- */
/* Two short text tabs. The active tab is darker with a thin underline; no hover
   treatment - the underline is the only selection cue. */
.oic-tabs {
  display: flex;
  align-items: center;
  gap: 2px;
}
.oic-tab {
  position: relative;
  appearance: none;
  background: transparent;
  border: 0;
  cursor: pointer;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 10px 9px;
  border-radius: 8px;
  color: var(--text-muted);
}
.oic-tab-name { font-size: 13px; font-weight: 600; line-height: 1; }
.oic-tab-count {
  font-size: 10.5px;
  font-weight: 700;
  line-height: 1;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}
.oic-tab.is-active { color: var(--text); }
.oic-tab.is-active .oic-tab-count { color: var(--text-muted); }
.oic-tab.is-active::after {
  content: "";
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 2px;
  height: 2px;
  border-radius: 2px;
  background: var(--text);
}
.oic-tab:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 2px;
}
.page-header-divider {
  flex-shrink: 0;
  width: 1px;
  height: 20px;
  margin: 0 4px;
  background: var(--border);
}
.offers-icp-pane[hidden] { display: none; }
.page-header-search { min-width: 280px; }

/* ---------- Help popover (anchored to ? button in page headers) ---------- */
.help-anchor[aria-expanded="true"] {
  background: var(--surface-2);
  color: var(--text);
}
.help-pop {
  position: absolute;
  top: calc(100% + 12px);
  right: 0;
  width: min(380px, calc(100vw - 32px));
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 16px 40px rgba(15, 18, 32, 0.14), 0 4px 12px rgba(15, 18, 32, 0.06);
  z-index: 80;
  overflow: hidden;
  animation: helpPopIn 160ms cubic-bezier(0.2, 0.8, 0.3, 1);
}
.help-pop[hidden] { display: none; }
@keyframes helpPopIn {
  from { opacity: 0; transform: translateY(-4px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0)   scale(1); }
}
.help-pop-arrow {
  position: absolute;
  top: -6px;
  right: 18px;
  width: 12px;
  height: 12px;
  background: var(--surface);
  border-left: 1px solid var(--border);
  border-top: 1px solid var(--border);
  transform: rotate(45deg);
}
.help-pop-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 14px 14px 10px 18px;
  border-bottom: 1px solid var(--border);
  position: relative;
  z-index: 1;
  background: var(--surface);
}
.help-pop-head h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.005em;
}
.help-pop-close {
  width: 28px;
  height: 28px;
}
.help-pop-body {
  padding: 14px 18px 18px;
  max-height: calc(100vh - 180px);
  overflow: auto;
  font-size: 13px;
  line-height: 1.55;
  color: var(--text-soft);
}
.help-pop-body > p:first-child {
  margin: 0 0 14px;
  color: var(--text);
}
.help-pop-section {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--hairline, var(--border));
}
.help-pop-section:first-of-type {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}
.help-pop-label {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.help-pop-body ul {
  margin: 0;
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.help-pop-body ul li { color: var(--text); }
.help-pop-body ul li strong { color: var(--text); font-weight: 600; }
.help-pop-body p { margin: 8px 0 0; }
.help-pop-note {
  margin-top: 10px !important;
  padding: 10px 12px;
  background: var(--surface-2);
  border-radius: 8px;
  font-size: 12.5px;
  color: var(--text-soft);
}

/* ---------- Filter bar ---------- */
.filterbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.filter-chips { display: flex; gap: 4px; flex-wrap: wrap; }
.deals-filter-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 500;
  padding: 5px 10px;
  border-radius: var(--radius-pill);
  color: var(--text-muted);
  transition: background 100ms ease, color 100ms ease;
}
.chip:hover { background: var(--surface-2); color: var(--text-soft); }
.chip.active { background: var(--text); color: var(--surface); }
.chip.active .chip-count { color: rgba(255,255,255,0.55); }
.chip-count {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-faint);
  font-weight: 500;
}
.chip .dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--text-faint);
}
.dot-executive   { background: var(--dept-executive-fg); }
.dot-operations  { background: var(--dept-operations-fg); }
.dot-finance     { background: var(--dept-finance-fg); }
.dot-legal       { background: var(--dept-legal-fg); }
.dot-creative    { background: var(--dept-creative-fg); }
.dot-growth      { background: var(--dept-growth-fg); }
.dot-engineering { background: var(--dept-engineering-fg); }
.dot-client     { background: var(--ok); }
.dot-external   { background: transparent; border: 1px dashed var(--text-muted); width: 7px; height: 7px; }

.chip-divider {
  width: 1px;
  height: 14px;
  background: var(--border-strong);
  margin: 0 4px;
  align-self: center;
}

.filter-views { display: flex; gap: 2px; }
.view-btn {
  width: 30px; height: 28px;
  border-radius: var(--radius-xs);
  display: grid; place-items: center;
  color: var(--text-muted);
  transition: background 100ms ease, color 100ms ease;
}
.view-btn:hover { background: var(--surface-2); color: var(--text-soft); }
.view-btn.active { background: var(--surface-3); color: var(--text); }
.view-btn svg { font-size: 14px; }

/* ============================================================
   VIEW CONTAINER (swaps between Org Chart, Journey, etc.)
   ============================================================ */
.view {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  min-width: 0;
}
.view[hidden] { display: none; }

/* ============================================================
   ORG CHART BODY
   ============================================================ */
.body.org-body {
  flex: 1;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* ---------- Org Chart: list view (mirrors the clean Tasks list) ---------- */
/* Groups reuse .tasks-group / .tasks-group-head / .tasks-list for an identical
   look + collapse behavior; only the row internals are org-specific. */
#orgList { flex: 1 1 auto; min-height: 0; overflow-y: auto; }
.org-list { padding: 4px 0 48px; }
.org-list-row {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 14px;
  padding: 10px 22px;
  min-height: 56px;
  border-bottom: 1px solid var(--hairline);
  cursor: pointer;
  transition: background 80ms ease;
}
.org-list-row:last-child { border-bottom: 0; }
.org-list-row:hover { background: var(--surface-2); }
.org-list-row:focus-visible { outline: 2px solid var(--accent-blue); outline-offset: -2px; border-radius: 8px; }
.org-list-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 12px; font-weight: 650; letter-spacing: 0.02em;
}
.org-list-main { min-width: 0; }
.org-list-name {
  display: flex; align-items: center; gap: 7px;
  font-size: 13px; font-weight: 550; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.org-list-role {
  font-size: 11.5px; color: var(--text-muted); margin-top: 1px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.org-added-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent-blue); flex: none; }
.org-list-access { justify-self: end; }
.org-access-pill {
  font-size: 10.5px; font-weight: 500;
  padding: 3px 10px; border-radius: 999px; white-space: nowrap;
}
.org-access-pill.is-client { background: #e8f1fe; color: #2563c9; }
.org-access-pill.is-internal { background: var(--surface-3); color: var(--text-soft); }
.org-list-tools { justify-self: end; font-size: 11px; color: var(--text-faint); white-space: nowrap; }
@media (max-width: 640px) {
  .org-list-access { display: none; }
  .org-list-row { grid-template-columns: 34px minmax(0, 1fr) auto; gap: 12px; padding: 10px 16px; }
}

/* Inline checkbox row in the Add-person modal */
/* Client-facing checkbox row in the Add-person modal. Dedicated class (not based
   on .send-field) so the later .send-field { flex-direction: column } can't flip it. */
.addperson-check {
  display: flex; align-items: center; gap: 10px;
  margin-top: 16px;
  font-size: 12.5px; color: var(--text-soft);
  cursor: pointer; user-select: none;
}
.addperson-check input {
  width: 16px; height: 16px; flex: none;
  accent-color: var(--accent-blue); cursor: pointer; margin: 0;
}

.org-chart {
  position: relative;
  overflow: hidden;
  flex: 1 1 auto;
  min-height: 0;
  cursor: grab;
  background:
    radial-gradient(circle, rgba(20,18,14,0.05) 1px, transparent 1.2px) 0 0 / 22px 22px,
    var(--surface);
  user-select: none;
}
.org-chart.panning { cursor: grabbing; }

.chart-canvas {
  position: absolute;
  top: 0; left: 0;
  transform-origin: 0 0;
  padding: 36px 28px 48px;
  will-change: transform;
  min-width: 1240px;
}

/* ============================================================
   ZOOM CONTROLS
   ============================================================ */
.zoom-controls {
  position: absolute;
  bottom: 16px;
  right: 16px;
  display: flex;
  align-items: center;
  gap: 2px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 4px;
  box-shadow: 0 6px 16px -6px rgba(20,18,14,0.16), 0 0 0 1px rgba(20,18,14,0.02);
  z-index: 4;
  transition: right 240ms cubic-bezier(.2,.8,.2,1);
}
.body.org-body:has(.detail-rail:not([hidden])) .zoom-controls {
  right: 376px;
}
.zoom-btn {
  width: 28px; height: 28px;
  border-radius: 50%;
  display: grid; place-items: center;
  color: var(--text-soft);
  transition: background 100ms ease, color 100ms ease;
}
.zoom-btn:hover { background: var(--surface-2); color: var(--text); }
.zoom-btn:active { transform: scale(0.94); }
.zoom-level {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-soft);
  padding: 0 8px;
  min-width: 50px;
  text-align: center;
  height: 28px;
  border-radius: var(--radius-pill);
  display: grid; place-items: center;
  letter-spacing: 0;
  transition: background 100ms ease, color 100ms ease;
}
.zoom-level:hover { background: var(--surface-2); color: var(--text); }
.zoom-sep {
  width: 1px; height: 16px;
  background: var(--border);
  margin: 0 4px;
}
.zoom-fit {
  height: 28px;
  padding: 0 10px 0 9px;
  border-radius: var(--radius-pill);
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-soft);
  font-size: 12px;
  font-weight: 500;
  transition: background 100ms ease, color 100ms ease;
}
.zoom-fit:hover { background: var(--surface-2); color: var(--text); }
.zoom-fit svg { color: var(--text-muted); }
.zoom-fit kbd {
  font-family: var(--font-mono);
  font-size: 9.5px;
  background: var(--surface-2);
  padding: 1px 5px;
  border-radius: 3px;
  color: var(--text-muted);
  border: 1px solid var(--border);
  font-weight: 500;
}

/* ============================================================
   ORG CHART - TREE
   ============================================================ */
.org-tree {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: fit-content;
  margin: 0 auto;
}

/* ---- Root (President, with optional EA on the right) ---- */
.org-root {
  position: relative;
  padding-bottom: 24px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  column-gap: 28px;
}
.org-root-main {
  grid-column: 2;
  position: relative;
}
/* Vertical trunk from the president down to the departments row */
.org-root-main::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -24px;
  transform: translateX(-50%);
  width: 1px;
  height: 24px;
  background: var(--connector);
}
/* Executive assistant - small card to the right of the president */
.org-root-assistant {
  grid-column: 3;
  justify-self: start;
  position: relative;
}
/* Short horizontal connector linking the EA back to the president */
.org-root-assistant::before {
  content: "";
  position: absolute;
  top: 50%;
  left: -28px;
  width: 28px;
  height: 1px;
  background: var(--connector);
}

/* ---- Departments row ---- */
.org-depts {
  display: grid;
  grid-template-columns: repeat(5, minmax(210px, 1fr));
  gap: 18px;
  position: relative;
  padding-top: 28px;
  width: 100%;
  max-width: 1200px;
}

/* Horizontal trunk that joins all dept columns */
.org-depts::before {
  content: "";
  position: absolute;
  top: 0;
  left: calc((100% / 5) / 2);
  right: calc((100% / 5) / 2);
  height: 1px;
  background: var(--connector);
}

.org-dept {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  position: relative;
}
/* Vertical drop from trunk to dept lead */
.org-dept::before {
  content: "";
  position: absolute;
  top: -28px;
  left: 50%;
  width: 1px;
  height: 28px;
  background: var(--connector);
}

/* Reports inside a dept */
.org-reports {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 6px;
  padding-left: 14px;
  position: relative;
}
/* Vertical guide line for reports */
.org-reports::before {
  content: "";
  position: absolute;
  top: 0; bottom: 16px;
  left: 4px;
  width: 1px;
  background: var(--connector);
  border-radius: 1px;
}
/* Horizontal tick on each report */
.org-reports .org-card::before {
  content: "";
  position: absolute;
  top: 50%;
  left: -10px;
  width: 10px;
  height: 1px;
  background: var(--connector);
}

/* ============================================================
   ORG CARD
   ============================================================ */
.org-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  position: relative;
  cursor: pointer;
  transition: border-color 120ms ease, box-shadow 120ms ease, transform 120ms ease;
  z-index: 1;
}
.org-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-card);
  transform: translateY(-1px);
}
.org-card.selected {
  border-color: var(--text);
  box-shadow: 0 0 0 2px rgba(20,18,14,0.08);
}

/* President - dark */
.org-card.president {
  background: var(--text);
  color: var(--surface);
  border-color: var(--text);
  box-shadow: var(--shadow-pop);
  min-width: 280px;
  padding: 12px 14px;
}
.org-card.president .org-name { font-size: 14px; }
.org-card.president .org-role { color: rgba(255,255,255,0.6); }
.org-card.president .org-tag { background: rgba(255,255,255,0.15); color: var(--surface); }
.org-card.president .org-avatar { background: rgba(255,255,255,0.1); color: var(--surface); border: none; }

/* Lead card - slightly heavier */
.org-card.lead { padding: 11px 12px; }
.org-card.lead .org-name { font-weight: 700; }

/* Empty placeholder card - shown when a department has no lead yet */
.org-card-empty {
  border: 1.5px dashed var(--border);
  background: transparent;
  box-shadow: none;
  cursor: default;
}
.org-card-empty:hover { border-color: var(--text-soft); background: var(--surface-2); }
.org-card-empty .placeholder-text { color: var(--text-soft); font-weight: 500; }
.org-avatar.placeholder { background: transparent; color: var(--text-soft); border: 1.5px dashed var(--border); }

.org-avatar {
  width: 30px; height: 30px;
  border-radius: 8px;
  display: grid; place-items: center;
  font-size: 11px; font-weight: 700;
  letter-spacing: 0.02em;
  background: var(--surface-2);
  color: var(--text-soft);
  flex-shrink: 0;
}

/* Department-tinted avatars */
.org-avatar.executive   { background: var(--dept-executive);   color: var(--dept-executive-fg); }
.org-avatar.operations  { background: var(--dept-operations);  color: var(--dept-operations-fg); }
.org-avatar.finance     { background: var(--dept-finance);     color: var(--dept-finance-fg); }
.org-avatar.legal       { background: var(--dept-legal);       color: var(--dept-legal-fg); }
.org-avatar.creative    { background: var(--dept-creative);    color: var(--dept-creative-fg); }
.org-avatar.growth      { background: var(--dept-growth);      color: var(--dept-growth-fg); }
.org-avatar.engineering { background: var(--dept-engineering); color: var(--dept-engineering-fg); }

.org-info { flex: 1; min-width: 0; line-height: 1.25; }
.org-name {
  font-size: 13px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.org-role {
  font-size: 11.5px; color: var(--text-muted);
  margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.org-tag {
  font-size: 9.5px; font-weight: 700;
  letter-spacing: 0.05em; text-transform: uppercase;
  background: var(--surface-2); color: var(--text-soft);
  padding: 2px 6px;
  border-radius: var(--radius-pill);
  flex-shrink: 0;
}

/* External cards: subtle dashed border */
.org-card.external {
  border-style: dashed;
  border-color: var(--border-strong);
  background: var(--surface);
}
.org-card.external:hover { border-color: var(--text-muted); }
.org-card.external.president { border-style: solid; }

/* Corner badges */
.org-badges {
  position: absolute;
  top: 6px;
  right: 8px;
  display: flex;
  gap: 4px;
}
.badge-mini {
  width: 16px; height: 16px;
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 9px;
  flex-shrink: 0;
}
.badge-mini svg { width: 10px; height: 10px; }
.badge-mini.badge-client {
  background: #d3f2dd;
  color: #1a6b3c;
}
.badge-mini.badge-external {
  background: var(--surface-2);
  color: var(--text-muted);
  border: 1px dashed var(--border-strong);
}
.org-card.president .badge-mini.badge-client {
  background: rgba(255,255,255,0.18);
  color: #c4f5d9;
}

/* Filter dim */
.org-card.dim { opacity: 0.28; }
.org-card.dim:hover { opacity: 0.6; }

/* ============================================================
   DETAIL RAIL - overlay, not part of grid
   ============================================================ */
.detail-rail {
  position: absolute;
  top: 0; right: 0; bottom: 0;
  width: 360px;
  background: var(--sidebar-bg);
  border-left: 1px solid var(--border);
  box-shadow: -10px 0 30px -18px rgba(20,18,14,0.18);
  display: flex;
  flex-direction: column;
  z-index: 5;
  animation: slideInRight 240ms cubic-bezier(.2,.8,.2,1);
}
.detail-rail[hidden] { display: none; }
@keyframes slideInRight {
  from { transform: translateX(24px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* Head */
.detail-head {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 16px 16px 14px;
  border-bottom: 1px solid var(--border);
}
.detail-avatar {
  width: 44px; height: 44px;
  border-radius: 10px;
  background: var(--surface-2);
  display: grid; place-items: center;
  font-size: 14px; font-weight: 700;
  letter-spacing: 0.02em;
}
.detail-head-text { min-width: 0; }
.detail-name {
  font-size: 15px; font-weight: 700; color: var(--text);
  letter-spacing: -0.01em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.detail-role {
  font-size: 12px; color: var(--text-muted); margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* Tabs */
.detail-tabs {
  display: flex;
  gap: 0;
  padding: 0 12px;
  border-bottom: 1px solid var(--border);
}
.detail-tab {
  padding: 10px 12px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-muted);
  position: relative;
  transition: color 100ms ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.detail-tab:hover { color: var(--text-soft); }
.detail-tab.active { color: var(--text); font-weight: 600; }
.detail-tab.active::after {
  content: "";
  position: absolute;
  left: 8px; right: 8px; bottom: -1px;
  height: 2px;
  background: var(--text);
  border-radius: 2px 2px 0 0;
}
.tab-count {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-faint);
  font-weight: 500;
  padding: 1px 5px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
}
.detail-tab.active .tab-count {
  color: var(--text-soft);
}

/* Tab content */
.detail-content {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.detail-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.detail-row .label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  font-weight: 600;
}
.detail-row .value {
  font-size: 13px;
  color: var(--text);
  font-weight: 500;
}
.detail-row .value.mono { font-family: var(--font-mono); font-size: 12px; }

.detail-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  width: fit-content;
}
.detail-pill .dot { width: 7px; height: 7px; border-radius: 50%; }
.detail-pill-wrap { display: flex; flex-wrap: wrap; gap: 6px; }

.detail-pill.pill-internal      { background: var(--surface-2); color: var(--text-soft); }
.detail-pill.pill-external      {
  background: var(--surface-2); color: var(--text-soft);
  border: 1px dashed var(--border-strong); padding: 2px 8px;
}
.detail-pill.pill-client        { background: #d3f2dd; color: #1a6b3c; }
.detail-pill.pill-internal-only { background: var(--surface-2); color: var(--text-muted); }

/* ============================================================
   TOOLS LIST
   ============================================================ */
.tools-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 0 2px 2px;
}
.tools-count {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  font-weight: 600;
}
.tools-link {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-soft);
}
.tools-link:hover { color: var(--text); }

.tool-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: border-color 120ms ease, transform 120ms ease;
  cursor: pointer;
}
.tool-item:hover {
  border-color: var(--border-strong);
  transform: translateY(-1px);
}
.tool-icon {
  width: 30px; height: 30px;
  border-radius: 7px;
  display: grid; place-items: center;
  font-size: 10px;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
  letter-spacing: 0.02em;
}
.tool-info { flex: 1; min-width: 0; line-height: 1.25; }
.tool-name {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tool-meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.tool-status {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0;
  flex-shrink: 0;
}
.tool-status .pulse {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--ok);
}
.tool-status.connected { color: var(--ok); }
.tool-status.pending   { color: var(--warn); }
.tool-status.pending .pulse { background: var(--warn); }

.add-tool-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 12px;
  background: transparent;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 12.5px;
  font-weight: 500;
  margin-top: 4px;
  transition: background 100ms ease, color 100ms ease, border-color 100ms ease;
}
.add-tool-btn:hover {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--text-muted);
}

/* ============================================================
   EMPTY STATE
   ============================================================ */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 32px 16px;
  gap: 8px;
  color: var(--text-muted);
}
.empty-state-icon {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: var(--surface-2);
  display: grid; place-items: center;
  color: var(--text-faint);
  font-size: 18px;
  margin-bottom: 4px;
}
.empty-state-title { font-size: 13px; font-weight: 600; color: var(--text-soft); }
.empty-state-desc { font-size: 11.5px; color: var(--text-muted); max-width: 220px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1280px) {
  .org-depts {
    grid-template-columns: repeat(3, minmax(210px, 1fr));
    row-gap: 36px;
  }
  /* When wrapping, the trunk doesn't make sense - hide */
  .org-depts::before { display: none; }
  .org-dept::before { display: none; }
}

@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: sticky; top: 0; z-index: 10;
    height: auto;
    flex-direction: row; align-items: center;
    gap: 8px; padding: 8px 10px;
    overflow-x: auto; overflow-y: hidden;
  }
  .workspace { flex: 0 0 auto; }
  .qa-row { display: none; }
  .nav { flex-direction: row; gap: 4px; padding: 0; flex: 1; overflow-x: auto; overflow-y: hidden; }
  .nav-group { flex-direction: row; gap: 2px; }
  .nav-section, .nav-children { display: none; }
  .nav-item.child { display: none; }
  .nav-item { padding: 6px 10px; white-space: nowrap; }
  .nav-meta, .nav-badge { display: none; }
  .sidebar-bottom { display: none; }
  .main { padding: 8px; }
  .surface { min-height: calc(100vh - 16px); }
  .org-depts { grid-template-columns: 1fr; }
  .detail-rail { width: 100%; }
}

/* External (client-facing) stage card - friendly paragraph, no step list */
.stage-blurb {
  font-size: 14px;
  line-height: 1.65;
  color: var(--text-soft);
  letter-spacing: -0.003em;
  margin: 0;
}
.stage-card--external {
  background: linear-gradient(180deg, var(--surface), var(--surface-2));
}
.stage-card--external .stage-duration-text {
  color: var(--ok);
}
/* The blurb is the flexible region: it absorbs equal-height stretch and is the
   only thing that scrolls if a card ever exceeds the available height. */
.stage-card--external .stage-blurb {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
}

/* ============================================================
   CLIENT JOURNEY BODY
   ============================================================ */
.body.journey-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}
.body.journey-body[hidden] { display: none; }

.journey {
  flex: 1;
  min-height: 0;                 /* let it shrink inside the flex column so children are height-bounded */
  /* Horizontal-only: the stage cards run left-to-right; never scroll the page up/down. */
  overflow-x: auto;
  overflow-y: hidden;
  padding: 24px 32px;
  background:
    radial-gradient(circle, rgba(20,18,14,0.05) 1px, transparent 1.2px) 0 0 / 22px 22px,
    var(--surface);
}

.stages {
  display: flex;
  gap: 0;
  align-items: stretch;
  min-width: fit-content;
}
/* External cards sit in one left-to-right row, capped to the viewport height so
   the page itself never scrolls vertically. A card taller than the area scrolls
   its own blurb (rare); normally everything fits with no scrollbar at all. */
.stages-external {
  max-height: 100%;
}

.stage-arrow {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 20px;
  color: var(--text-faint);
  flex-shrink: 0;
}
.stage-arrow svg { width: 22px; height: 22px; }

/* ============================================================
   STAGE CARD
   ============================================================ */
.stage-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 20px 18px;
  width: 320px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-shadow: var(--shadow-card);
  position: relative;
  transition: border-color 120ms ease, box-shadow 120ms ease, transform 120ms ease;
}
.stage-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-2, var(--shadow-pop));
  transform: translateY(-1px);
}
/* Brief flash when deep-linked from the Pipeline > Delivery phase ring,
   so the user's eye snaps to the right card after the scroll. */
@keyframes stageCardFlash {
  0%   { box-shadow: 0 0 0 0 rgba(234, 179, 8, 0.0),    var(--shadow-card); }
  35%  { box-shadow: 0 0 0 4px rgba(234, 179, 8, 0.35), var(--shadow-pop); }
  100% { box-shadow: 0 0 0 0 rgba(234, 179, 8, 0.0),    var(--shadow-card); }
}
.stage-card.is-flash {
  animation: stageCardFlash 1.4s ease-out;
}

/* Launch stage - sales begin here, subtle green accent */
.stage-card[data-stage="launch"] {
  border-color: rgba(21, 160, 107, 0.55);
  box-shadow: 0 0 0 1px rgba(21, 160, 107, 0.18), var(--shadow-card);
}
.stage-card[data-stage="launch"]:hover {
  border-color: var(--ok);
  box-shadow: 0 0 0 1px rgba(21, 160, 107, 0.28), var(--shadow-pop);
}

.stage-header {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.stage-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}
.stage-label .stage-num {
  font-family: var(--font-mono);
  background: var(--surface-2);
  color: var(--text-soft);
  padding: 1px 6px;
  border-radius: 4px;
  letter-spacing: 0.02em;
}
.stage-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
  line-height: 1.25;
}
.stage-duration-strip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  border-top: 1px solid var(--hairline);
  border-bottom: 1px solid var(--hairline);
  color: var(--text-muted);
  margin-top: -4px;
}
.stage-duration-strip svg {
  color: var(--text-faint);
  flex-shrink: 0;
}
.stage-duration-text {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-soft);
  letter-spacing: 0;
  flex: 1;
}
.stage-parallel-tag {
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.stage-owners {
  display: flex;
  align-items: center;
  gap: 6px;
}
.owner-stack {
  display: flex;
}
.owner-chip {
  width: 24px; height: 24px;
  border-radius: 7px;
  display: grid; place-items: center;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.02em;
  border: 2px solid var(--surface);
  margin-left: -6px;
  cursor: pointer;
  transition: transform 100ms ease;
}
.owner-chip:first-child { margin-left: 0; }
.owner-chip:hover { transform: translateY(-2px); }
.owner-chip.executive   { background: var(--dept-executive);   color: var(--dept-executive-fg); }
.owner-chip.operations  { background: var(--dept-operations);  color: var(--dept-operations-fg); }
.owner-chip.finance     { background: var(--dept-finance);     color: var(--dept-finance-fg); }
.owner-chip.legal       { background: var(--dept-legal);       color: var(--dept-legal-fg); }
.owner-chip.creative    { background: var(--dept-creative);    color: var(--dept-creative-fg); }
.owner-chip.growth      { background: var(--dept-growth);      color: var(--dept-growth-fg); }
.owner-chip.engineering { background: var(--dept-engineering); color: var(--dept-engineering-fg); }
.owner-names {
  font-size: 11.5px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* External (client-facing) view - role/department pills, no individual people */
.stage-roles {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.stage-role-pill {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-soft);
  white-space: nowrap;
}
.stage-role-pill.executive   { background: var(--dept-executive);   color: var(--dept-executive-fg); }
.stage-role-pill.operations  { background: var(--dept-operations);  color: var(--dept-operations-fg); }
.stage-role-pill.finance     { background: var(--dept-finance);     color: var(--dept-finance-fg); }
.stage-role-pill.legal       { background: var(--dept-legal);       color: var(--dept-legal-fg); }
.stage-role-pill.creative    { background: var(--dept-creative);    color: var(--dept-creative-fg); }
.stage-role-pill.growth      { background: var(--dept-growth);      color: var(--dept-growth-fg); }
.stage-role-pill.engineering { background: var(--dept-engineering); color: var(--dept-engineering-fg); }

.stage-steps {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-top: 14px;
  border-top: 1px solid var(--hairline);
}
.stage-step {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 12.5px;
  color: var(--text-soft);
  line-height: 1.5;
}
.stage-step .step-text {
  padding-top: 2px;
}

/* Per-step owner avatars - replaces the old done-toggle circle */
.step-owners {
  display: flex;
  flex-shrink: 0;
  padding-top: 1px;
}
.step-owner {
  width: 22px; height: 22px;
  border-radius: 7px;
  display: grid; place-items: center;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.02em;
  border: 2px solid var(--surface);
  margin-left: -5px;
  background: var(--surface-2);
  color: var(--text-soft);
  padding: 0;
  cursor: pointer;
  font-family: inherit;
  transition: transform 100ms ease;
}
.step-owner:first-child { margin-left: 0; }
.step-owner:hover { transform: translateY(-1px); }
.step-owner.executive   { background: var(--dept-executive);   color: var(--dept-executive-fg); }
.step-owner.operations  { background: var(--dept-operations);  color: var(--dept-operations-fg); }
.step-owner.finance     { background: var(--dept-finance);     color: var(--dept-finance-fg); }
.step-owner.legal       { background: var(--dept-legal);       color: var(--dept-legal-fg); }
.step-owner.creative    { background: var(--dept-creative);    color: var(--dept-creative-fg); }
.step-owner.growth      { background: var(--dept-growth);      color: var(--dept-growth-fg); }
.step-owner.engineering { background: var(--dept-engineering); color: var(--dept-engineering-fg); }
.step-owner.external {
  background: transparent;
  color: var(--text-muted);
  border: 1.5px dashed var(--border-strong);
  cursor: default;
}
.step-owner.placeholder {
  background: transparent;
  border: 1.5px dashed var(--border);
  cursor: default;
}

.journey-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 64px 24px;
  gap: 8px;
  text-align: center;
  color: var(--text-muted);
}
.journey-empty-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-soft);
}
.journey-empty-desc {
  font-size: 12.5px;
  color: var(--text-muted);
  max-width: 280px;
}

/* ============================================================
   TECH STACK VIEW
   ============================================================ */
.techstack-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 0; /* full-bleed canvas - meets the header's bottom line, no inner stripe */
  width: 100%;
  overflow: hidden;
}
.techstack {
  position: relative;
  flex: 1;
  min-height: 0;
  width: 100%;
  overflow: hidden;
  cursor: grab;
  user-select: none;
  background:
    radial-gradient(circle, rgba(20,18,14,0.05) 1px, transparent 1.2px) 0 0 / 22px 22px,
    var(--surface);
}
.techstack.panning { cursor: grabbing; }
.tech-section { display: flex; flex-direction: column; gap: 12px; }
.tech-section-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
}
.tech-section-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-soft);
  margin: 0;
}
.tech-section-count {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--surface-2);
  padding: 1px 7px;
  border-radius: 10px;
}
.tech-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}
.tech-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}
.tech-card:hover {
  border-color: var(--text-soft);
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}
.tech-card-head {
  display: flex;
  align-items: center;
  gap: 12px;
}
.tech-mark {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  color: white;
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.02em;
  flex-shrink: 0;
}
.tech-name-block { flex: 1; min-width: 0; line-height: 1.25; }
.tech-name {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tech-tier {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 1px;
}
.tech-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-soft);
  flex-shrink: 0;
}
.tech-status .pulse {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.tech-status.status-active     { color: #1a6b3c; background: rgba(26,107,60,0.10); }
.tech-status.status-evaluating { color: #8b4a14; background: rgba(139,74,20,0.10); }
.tech-status.status-pending    { color: #82591a; background: rgba(130,89,26,0.10); }
.tech-purpose {
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--text-soft);
  margin: 0;
}

/* Referral / affiliate chip on tech-card */
.tech-card-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.tech-referral {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
  letter-spacing: 0.01em;
}
.tech-referral.has-code { background: rgba(26,107,60,0.10); color: #1a6b3c; }
.tech-referral.tbd      { background: rgba(139,74,20,0.10); color: #8b4a14; }
.tech-referral.free     { background: var(--surface-2);     color: var(--text-muted); }

/* Replace the old .tech-referral chip with action buttons in the card foot. */
.tech-card-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 2px;
}
.tech-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text-soft);
  border: 1px solid transparent;
  transition: background 110ms ease, color 110ms ease, border-color 110ms ease;
  white-space: nowrap;
}
.tech-btn svg { color: currentColor; }
.tech-btn:hover { background: var(--surface-3); color: var(--text); }

/* Copy button states */
.copy-btn.has-affiliate {
  background: rgba(26,107,60,0.10);
  color: #1a6b3c;
}
.copy-btn.has-affiliate:hover { background: rgba(26,107,60,0.16); }
.copy-btn.needs-affiliate {
  background: rgba(139,74,20,0.08);
  color: #8b4a14;
  border-color: rgba(139,74,20,0.18);
  border-style: dashed;
}
.copy-btn.needs-affiliate:hover { background: rgba(139,74,20,0.14); }
.copy-btn.free-link { /* uses neutral .tech-btn defaults */ }

.copy-btn.flashed {
  background: #1a6b3c !important;
  color: #fff !important;
  border-color: transparent !important;
}

.guide-btn[disabled] {
  opacity: 0.55;
  cursor: not-allowed;
}
.guide-btn[disabled]:hover { background: var(--surface-2); color: var(--text-soft); }

/* Tech mark - favicon variant. The brand-colored letter mark stays underneath
   as a fallback that shows automatically if the <img> fails to load (the img
   is removed by its onerror handler, exposing the letter underneath). */
.tech-mark.with-icon {
  position: relative;
  background: #fff;
  border: 1px solid var(--border);
  color: var(--text-soft);
  overflow: hidden;
}
.tech-mark-fallback {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #fff;
  background: var(--mark-bg, var(--text-soft));
}
.tech-mark-img {
  position: relative;
  width: 22px;
  height: 22px;
  object-fit: contain;
  display: block;
  z-index: 1;
}

.tech-status.status-planned { color: #5b2bb1; background: rgba(91,43,177,0.10); }

/* ============================================================
   HEADER LINK - used in Tech Stack page headers
   ============================================================ */
.header-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-soft);
  background: var(--surface-2);
  border-radius: 8px;
  border: 1px solid var(--border);
  transition: background 110ms ease, color 110ms ease, border-color 110ms ease;
  white-space: nowrap;
}
.header-link:hover { background: var(--surface-3); color: var(--text); border-color: var(--border-strong); }
.page-sub {
  font-size: 12.5px;
  color: var(--text-muted);
  margin-left: 8px;
  font-weight: 500;
}

/* ============================================================
   ROADMAP (Gantt)
   ============================================================ */
.view[data-view="roadmap"] { position: relative; }
.body.roadmap-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: var(--content-pad);
  overflow: hidden;
  min-height: 0;
}
.body.roadmap-body[hidden] { display: none; }

/* The #roadmap wrapper must itself be a height-bounded flex column, or the
   .gantt card's flex:1 height never resolves (the wrapper is block/auto by
   default). Horizontal-only scroll on a narrow panel; never vertical. */
.roadmap {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow-x: auto;
  overflow-y: hidden;
}

/* ============================================================
   ROADMAP GANTT - refined-classic (synthesized redesign)
   Same Gantt the user likes, every pixel re-cut. Light theme only.
   Three stacked bands inside a height-driving card:
     strip (duration chip + legend) -> axis -> rows (split equally).
   Shared geometry tokens keep the ruler pixel-aligned to every bar.
   ============================================================ */
.gantt {
  --label-w: 290px;               /* width of the left phase-name column */
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  /* No inner card frame - the chart uses the full page real estate.
     The outer .roadmap-body padding is the only gutter now. */
  background: transparent;
  overflow-x: auto;
  overflow-y: hidden;
}

/* Plot: vertical month gridlines behind, one pill lane per phase on top. */
.gantt-plot {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  min-width: 660px;
  display: flex;
  flex-direction: column;
}
.gantt-grid { position: absolute; top: 0; bottom: 0; left: var(--label-w); right: 0; z-index: 0; pointer-events: none; }
.gantt-grid .gantt-gridline {
  position: absolute;
  top: 0; bottom: 0;
  width: 0;
  border-left: 1px dashed var(--hairline);
}
.gantt-rows {
  position: relative;
  z-index: 1;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

/* One lane per phase - lanes split the height evenly, no vertical scroll. */
.gantt-row {
  display: flex;
  align-items: stretch;
  flex: 1 1 0;
  min-height: 42px;
}
/* Left column: phase name + duration (replaces the old beside-the-bar label). */
.gantt-row-label {
  width: var(--label-w);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding-right: 16px;
  min-width: 0;
}
.gantt-row-name {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.005em;
  color: var(--text);
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
}
/* Timeline track: the date-positioned bar lives here (position context). */
.gantt-row-track {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
}

/* The positioned span: start -> worst-case end. */
.gantt-bar-wrap {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  height: 34px;
  min-width: 140px;               /* always wide enough for duration + owner avatars inside */
  cursor: pointer;
}

/* Pill = solid (expected duration) + hatched (buffer up to worst case). */
.gantt-bar {
  display: flex;
  width: 100%;
  height: 100%;
  border-radius: var(--radius-pill);
  overflow: hidden;
  box-shadow:
    0 1px 2px rgba(20, 18, 14, 0.06),
    inset 0 0 0 1px color-mix(in srgb, var(--text) 6%, transparent);
  transition: transform 130ms ease, box-shadow 130ms ease;
}
.gantt-bar-wrap:hover .gantt-bar {
  transform: translateY(-1px);
  box-shadow:
    0 8px 20px -8px rgba(20, 18, 14, 0.26),
    inset 0 0 0 1px color-mix(in srgb, var(--text) 8%, transparent);
}
.gantt-bar-wrap:active .gantt-bar { transform: none; }

.gantt-bar-solid {
  flex: 1 1 auto;                 /* fills the whole pill - the buffer tail is now solid */
  display: flex;
  align-items: center;
  justify-content: flex-start;    /* duration sits against the LEFT edge of the pillar */
  gap: 8px;
  padding: 0 11px;
  min-width: 0;
  background-color: var(--dept-operations);
  color: var(--dept-operations-fg);
  border-radius: var(--radius-pill);
}

.gantt-bar-dur {
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 500;
  opacity: 0.82;
  color: currentColor;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* Per-department solid fills (critical-path phases). */
.gantt-bar-executive   .gantt-bar-solid { background-color: var(--dept-executive);   color: var(--dept-executive-fg); }
.gantt-bar-operations  .gantt-bar-solid { background-color: var(--dept-operations);  color: var(--dept-operations-fg); }
.gantt-bar-finance     .gantt-bar-solid { background-color: var(--dept-finance);     color: var(--dept-finance-fg); }
.gantt-bar-legal       .gantt-bar-solid { background-color: var(--dept-legal);       color: var(--dept-legal-fg); }
.gantt-bar-creative    .gantt-bar-solid { background-color: var(--dept-creative);    color: var(--dept-creative-fg); }
.gantt-bar-growth      .gantt-bar-solid { background-color: var(--dept-growth);      color: var(--dept-growth-fg); }
.gantt-bar-engineering .gantt-bar-solid { background-color: var(--dept-engineering); color: var(--dept-engineering-fg); }

/* Parallel (non-critical) phases: softer wash + dark text. */
.gantt-bar-wrap.is-parallel .gantt-bar-solid { color: var(--text); }
.is-parallel.gantt-bar-executive   .gantt-bar-solid { background-color: color-mix(in srgb, var(--dept-executive) 38%, var(--surface)); }
.is-parallel.gantt-bar-operations  .gantt-bar-solid { background-color: color-mix(in srgb, var(--dept-operations) 38%, var(--surface)); }
.is-parallel.gantt-bar-finance     .gantt-bar-solid { background-color: color-mix(in srgb, var(--dept-finance) 38%, var(--surface)); }
.is-parallel.gantt-bar-legal       .gantt-bar-solid { background-color: color-mix(in srgb, var(--dept-legal) 38%, var(--surface)); }
.is-parallel.gantt-bar-creative    .gantt-bar-solid { background-color: color-mix(in srgb, var(--dept-creative) 38%, var(--surface)); }
.is-parallel.gantt-bar-growth      .gantt-bar-solid { background-color: color-mix(in srgb, var(--dept-growth) 38%, var(--surface)); }
.is-parallel.gantt-bar-engineering .gantt-bar-solid { background-color: color-mix(in srgb, var(--dept-engineering) 38%, var(--surface)); }

/* Owner avatar stack at the right end of the wrap (sits over the buffer tail). */
.gantt-owners {
  position: absolute;
  right: 5px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  z-index: 4;
}
.gantt-owner {
  width: 23px;
  height: 23px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: #fff;
  background: var(--dept-operations);
  border: 2px solid var(--surface);
  margin-left: -7px;
  box-shadow: 0 1px 2px rgba(20, 18, 14, 0.14);
}
.gantt-owner:first-child { margin-left: 0; }
.gantt-owner.executive   { background: var(--dept-executive);   color: var(--dept-executive-fg); }
.gantt-owner.operations  { background: var(--dept-operations);  color: var(--dept-operations-fg); }
.gantt-owner.finance     { background: var(--dept-finance);     color: var(--dept-finance-fg); }
.gantt-owner.legal       { background: var(--dept-legal);       color: var(--dept-legal-fg); }
.gantt-owner.creative    { background: var(--dept-creative);    color: var(--dept-creative-fg); }
.gantt-owner.growth      { background: var(--dept-growth);      color: var(--dept-growth-fg); }
.gantt-owner.engineering { background: var(--dept-engineering); color: var(--dept-engineering-fg); }
.gantt-owner-more { background: var(--surface-3); color: var(--text-soft); }

/* Month ruler along the bottom. */
.gantt-axis {
  display: flex;
  flex: 0 0 auto;
  height: 15px;
  margin-top: 9px;
  min-width: 660px;
}
.gantt-axis-spacer {
  width: var(--label-w);
  flex-shrink: 0;
}
.gantt-axis-track {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
}
.gantt-axis-tick {
  position: absolute;
  top: 0;
  transform: translateX(1px);
  font-size: 11px;
  font-weight: 500;
  color: var(--text-faint);
  letter-spacing: -0.01em;
  white-space: nowrap;
}

/* ============================================================
   ROADMAP DRAWER - per-phase checklist side card
   ============================================================ */
.roadmap-drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 18, 14, 0.18);
  z-index: 99;
  animation: fadeIn 180ms ease;
}
.roadmap-drawer-backdrop[hidden] { display: none; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.roadmap-drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: 420px;
  max-width: 92vw;
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: -16px 0 40px -20px rgba(20,18,14,0.24);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transform: translateX(16px);
  opacity: 0;
  transition: transform 220ms cubic-bezier(.2,.8,.2,1), opacity 220ms ease;
}

/* Prevent the page beneath from scrolling while the roadmap drawer is open.
   The drawer is position:fixed, so without this lock the user could still
   scroll the page behind the drawer. */
body.is-roadmap-drawer-open { overflow: hidden; }
.roadmap-drawer.open {
  transform: translateX(0);
  opacity: 1;
}
.roadmap-drawer[hidden] { display: none; }

.roadmap-drawer-head {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: flex-start;
  padding: 18px 18px 16px;
}
.roadmap-drawer-num {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: 4px;
}
.roadmap-drawer-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
  line-height: 1.3;
}
.roadmap-drawer-meta {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 6px;
}

.roadmap-drawer-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.roadmap-drawer-list {
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  margin: 0 18px;
  padding: 4px 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  flex: 1;
}
.roadmap-drawer-list[hidden],
.roadmap-drawer-detail[hidden] { display: none; }

.roadmap-drawer-item { cursor: pointer; }
.roadmap-drawer-item-text-wrap {
  display: contents;
}

.roadmap-drawer-detail {
  margin: 0 18px;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 12px 0 20px;
  overflow-y: auto;
  overscroll-behavior: contain;
  flex: 1;
  display: flex;
  flex-direction: column;
}
.roadmap-detail-back {
  appearance: none;
  background: transparent;
  border: 0;
  padding: 4px 6px 4px 0;
  margin-bottom: 10px;
  align-self: flex-start;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.roadmap-detail-back:hover { color: var(--text); }
.roadmap-detail-back svg { width: 14px; height: 14px; }

.roadmap-detail-head {
  margin-bottom: 12px;
}
.roadmap-detail-kicker {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: 4px;
}
.roadmap-detail-title {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.35;
  color: var(--text);
  letter-spacing: -0.01em;
}
.roadmap-detail-head-owners {
  display: flex;
  margin-top: 8px;
}

.roadmap-detail-tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--hairline);
  margin-bottom: 14px;
}
.roadmap-detail-tab {
  appearance: none;
  background: transparent;
  border: 0;
  padding: 8px 12px;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 120ms ease, border-color 120ms ease;
}
.roadmap-detail-tab:hover { color: var(--text); }
.roadmap-detail-tab.is-active {
  color: var(--text);
  border-bottom-color: var(--text);
}

.roadmap-detail-panel {
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-soft);
}
.roadmap-detail-panel[hidden] { display: none; }
.roadmap-detail-panel p { margin: 0 0 10px; white-space: pre-wrap; }
.roadmap-detail-panel p:last-child { margin-bottom: 0; }

.roadmap-detail-section-label {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin: 14px 0 6px;
}
.roadmap-detail-section-label:first-child { margin-top: 0; }

.roadmap-detail-section-heading {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.005em;
  margin: 18px 0 6px;
}
.roadmap-detail-section-heading:first-child { margin-top: 0; }
.roadmap-detail-section-heading + p { margin-top: 0; }

.roadmap-detail-breakdown {
  margin: 0;
  padding: 0 0 0 18px;
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--text-soft);
}
.roadmap-detail-breakdown li { margin: 4px 0; }

.roadmap-detail-empty {
  font-size: 12.5px;
  color: var(--text-faint);
  font-style: italic;
  padding: 18px 4px;
  line-height: 1.55;
}

.roadmap-detail-meta-row {
  display: flex;
  gap: 14px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.roadmap-detail-meta-row span { display: inline-flex; gap: 4px; }
.roadmap-detail-meta-row b { color: var(--text); font-weight: 600; }

.roadmap-drawer-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: flex-start;
  padding: 11px 4px;
  cursor: pointer;
  border: 0;
  border-bottom: 1px solid var(--hairline);
  background: transparent;
  width: 100%;
  text-align: left;
  font: inherit;
  color: inherit;
  transition: background 120ms ease;
}
.roadmap-drawer-item:hover .roadmap-drawer-textbody { color: var(--text); }
.roadmap-drawer-owners {
  display: flex;
  flex-shrink: 0;
  margin-top: 1px;
}
.roadmap-drawer-owner {
  width: 22px; height: 22px;
  border-radius: 6px;
  display: grid; place-items: center;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.02em;
  border: 2px solid var(--surface);
  margin-left: -5px;
  background: var(--surface-2);
  color: var(--text-soft);
}
.roadmap-drawer-owner:first-child { margin-left: 0; }
.roadmap-drawer-owner.executive   { background: var(--dept-executive);   color: var(--dept-executive-fg); }
.roadmap-drawer-owner.operations  { background: var(--dept-operations);  color: var(--dept-operations-fg); }
.roadmap-drawer-owner.finance     { background: var(--dept-finance);     color: var(--dept-finance-fg); }
.roadmap-drawer-owner.legal       { background: var(--dept-legal);       color: var(--dept-legal-fg); }
.roadmap-drawer-owner.creative    { background: var(--dept-creative);    color: var(--dept-creative-fg); }
.roadmap-drawer-owner.growth      { background: var(--dept-growth);      color: var(--dept-growth-fg); }
.roadmap-drawer-owner.engineering { background: var(--dept-engineering); color: var(--dept-engineering-fg); }
.roadmap-drawer-owner.external {
  background: transparent;
  color: var(--text-muted);
  border: 1.5px dashed var(--border-strong);
}
.roadmap-drawer-item:last-child { border-bottom: 0; }
.roadmap-drawer-item:hover { background: color-mix(in srgb, var(--surface-2) 60%, transparent); }

.roadmap-drawer-check {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 0; height: 0;
}
.roadmap-drawer-box {
  width: 18px; height: 18px;
  border-radius: 5px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  display: grid;
  place-items: center;
  flex-shrink: 0;
  margin-top: 1px;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease;
  color: transparent;
}
.roadmap-drawer-box svg {
  width: 12px; height: 12px;
}
.roadmap-drawer-item.checked .roadmap-drawer-box {
  background: var(--text);
  border-color: var(--text);
  color: var(--surface);
}
.roadmap-drawer-text {
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--text-soft);
  transition: color 120ms ease;
  display: inline-flex;
  align-items: baseline;
  gap: 10px;
}
.roadmap-drawer-num {
  flex: 0 0 auto;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--text-faint, #b3afa5);
  font-variant-numeric: tabular-nums;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  min-width: 18px;
}
.roadmap-drawer-textbody { min-width: 0; }
.roadmap-drawer-item.checked .roadmap-drawer-text {
  color: var(--text-faint);
  text-decoration: line-through;
  text-decoration-color: var(--text-faint);
}
.roadmap-drawer-item.checked .roadmap-drawer-num {
  text-decoration: none;
  opacity: 0.55;
}

/* ============================================================
   STAGE ACTIONS PANEL - phase-drawer-style render for pipeline-stage rails
   (e.g. the Sales stage rail). Mirrors the Roadmap phase drawer so the
   "what happens in this stage" view feels consistent everywhere.
   ============================================================ */
.stage-actions-panel {
  display: flex;
  flex-direction: column;
  gap: 0;
}
.stage-actions-eyebrow {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: 6px;
}
.stage-actions-title {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
  line-height: 1.25;
}
.stage-actions-meta {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 6px;
}
.stage-actions-divider {
  height: 1px;
  background: var(--border);
  margin: 16px 0 0;
}
.stage-actions-list {
  display: flex;
  flex-direction: column;
}
.stage-action-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px 4px;
  border-bottom: 1px solid var(--hairline, var(--border));
}
.stage-action-item:last-child { border-bottom: 0; }
.stage-action-box {
  width: 18px; height: 18px;
  border-radius: 5px;
  border: 1.5px dashed var(--border-strong, var(--text-faint));
  background: transparent;
  display: grid;
  place-items: center;
  color: transparent;
  flex-shrink: 0;
}
.stage-action-box svg { width: 12px; height: 12px; }
.stage-action-text {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.35;
}
.stage-action-meta {
  font-size: 11px;
  color: var(--text-muted);
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.stage-actions-empty {
  font-size: 12.5px;
  color: var(--text-faint);
  padding: 20px 0;
  text-align: center;
  font-style: italic;
}

/* ============================================================
   DOCUMENTATION VIEW - single tree nav (Stages expand to reveal Phases) + page
   ============================================================ */
.view[data-view="docs"] {
  flex: 1;
  min-height: 0;
  overflow: hidden;
}
.docs-layout {
  flex: 1;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 0;
  height: 100%;
  background: var(--surface);
}

/* ---- Panes (Stages + Phases share the same look) ---- */
.docs-pane {
  border-right: 1px solid var(--border);
  background: var(--surface-2);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.docs-pane-stages { background: var(--sidebar-bg); }
.docs-pane-head {
  padding: 22px 18px 14px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: inherit;
  z-index: 1;
}
.docs-pane-label {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-faint);
  margin-bottom: 4px;
}
.docs-pane-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
  line-height: 1.25;
}
.docs-pane-list {
  padding: 8px 8px 24px;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.docs-pane-group-label {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-faint);
  padding: 14px 12px 6px;
}
.docs-pane-group-label:first-child { padding-top: 6px; }
.docs-pane-item {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--text-soft);
  transition: background 100ms ease, color 100ms ease;
}
.docs-pane-item:hover {
  background: color-mix(in srgb, var(--surface) 70%, transparent);
  color: var(--text);
}
.docs-pane-item.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 0 0 1px var(--border), 0 1px 2px rgba(20,18,14,0.04);
}
.docs-pane-num {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  color: var(--text-faint);
  text-align: center;
}
.docs-pane-num-icon {
  font-size: 14px;
  font-weight: 400;
  color: var(--text-faint);
}
.docs-pane-item.active .docs-pane-num {
  color: var(--text);
}
.docs-pane-text {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}
.docs-pane-text-title {
  font-size: 13px;
  font-weight: 500;
  line-height: 1.35;
  word-break: break-word;
  overflow-wrap: anywhere;
}
.docs-pane-item.active .docs-pane-text-title { font-weight: 600; }
.docs-pane-text-sub {
  font-size: 11.5px;
  color: var(--text-muted);
  line-height: 1.35;
  word-break: break-word;
  overflow-wrap: anywhere;
}
.docs-pane-chev {
  width: 14px;
  height: 14px;
  color: var(--text-faint);
  flex-shrink: 0;
  opacity: 0.7;
  transition: opacity 120ms ease, transform 160ms ease;
}
.docs-pane-item:hover .docs-pane-chev { opacity: 1; }
.docs-pane-item.open .docs-pane-chev { transform: rotate(90deg); opacity: 1; }
.docs-pane-empty {
  padding: 18px 14px;
  font-size: 12.5px;
  color: var(--text-faint);
  font-style: italic;
  text-align: center;
  line-height: 1.5;
}

/* ---- Inline phases sublist (rendered under an open stage) ---- */
.docs-pane-sublist {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 2px 0 8px 16px;
  margin-left: 22px;
  border-left: 1px solid var(--border);
  position: relative;
}
.docs-pane-subitem {
  display: grid;
  grid-template-columns: 32px 1fr;
  align-items: baseline;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 6px;
  color: var(--text-muted);
  transition: background 100ms ease, color 100ms ease;
}
.docs-pane-subitem:hover {
  background: color-mix(in srgb, var(--surface) 70%, transparent);
  color: var(--text-soft);
}
.docs-pane-subitem.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 0 0 1px var(--border), 0 1px 2px rgba(20,18,14,0.04);
  font-weight: 600;
}
.docs-pane-subnum {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-faint);
  letter-spacing: 0.02em;
}
.docs-pane-subitem.active .docs-pane-subnum { color: var(--text); }
.docs-pane-subtitle {
  font-size: 12.5px;
  line-height: 1.4;
  word-break: break-word;
  overflow-wrap: anywhere;
}
.docs-pane-subempty {
  padding: 10px 12px;
  font-size: 11.5px;
  color: var(--text-faint);
  font-style: italic;
}

/* ---- Center: SOP page ---- */
.docs-main {
  overflow-y: auto;
  padding: 40px 56px 80px;
}
.docs-page-header {
  max-width: 760px;
  margin: 0 auto 28px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 22px;
}
.docs-eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-faint);
  margin-bottom: 10px;
}
.docs-title {
  font-size: 30px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
  line-height: 1.15;
  margin: 0;
}
.docs-subtitle {
  margin: 10px 0 0 0;
  font-size: 14.5px;
  line-height: 1.55;
  color: var(--text-soft);
  max-width: 640px;
}
.docs-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 18px;
}
.docs-action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 12.5px;
  color: var(--text-muted);
  border: 1px solid transparent;
  transition: background 100ms ease, color 100ms ease, border-color 100ms ease;
}
.docs-action:hover {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border);
}
.docs-action svg { width: 14px; height: 14px; }
.docs-actions-sep {
  width: 1px;
  height: 16px;
  background: var(--border);
}

/* ---- Body sections ---- */
.docs-body {
  max-width: 760px;
  margin: 0 auto;
}
.docs-section {
  padding: 18px 0 28px;
  border-bottom: 1px solid var(--hairline);
}
.docs-section:last-child { border-bottom: 0; }
.docs-section-heading {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
  margin: 0 0 12px;
  scroll-margin-top: 24px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.docs-section-anchor {
  color: var(--text-faint);
  font-weight: 400;
  opacity: 0;
  transition: opacity 120ms ease, color 120ms ease;
  font-size: 16px;
}
.docs-section-heading:hover .docs-section-anchor { opacity: 1; }
.docs-section-anchor:hover { color: var(--accent-blue); }

.docs-section-body {
  font-size: 13.5px;
  line-height: 1.65;
  color: var(--text-soft);
}
.docs-section-body p { margin: 0 0 10px; }
.docs-section-body p:last-child { margin-bottom: 0; }
.docs-section-body ul, .docs-section-body ol {
  margin: 4px 0 12px;
  padding-left: 22px;
}
.docs-section-body li { margin: 4px 0; }
.docs-section-body strong { color: var(--text); font-weight: 600; }

.docs-stub {
  color: var(--text-faint);
  font-style: italic;
  background: var(--surface-2);
  padding: 12px 14px;
  border-radius: 6px;
  border: 1px dashed var(--border);
  margin: 0 !important;
}

/* ---- Phases-in-this-stage grid (shown on stage intro pages) ---- */
.docs-phase-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
  margin-top: 4px;
}
.docs-phase-card {
  display: block;
  padding: 14px 16px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  transition: border-color 120ms ease, transform 120ms ease, box-shadow 120ms ease;
}
.docs-phase-card:hover {
  border-color: var(--border-strong);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px -4px rgba(20,18,14,0.1);
}
.docs-phase-card-num {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: 6px;
}
.docs-phase-card-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
  margin-bottom: 4px;
}
.docs-phase-card-sub {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.45;
}

/* ---- Empty state for the page area ---- */
.docs-main.docs-main-empty .docs-page-header { border-bottom: 0; }
.docs-main.docs-main-empty .docs-actions { display: none; }
.docs-main.docs-main-empty {
  display: flex;
  align-items: center;
  justify-content: center;
}
.docs-main.docs-main-empty .docs-page-header {
  text-align: center;
  margin: 0;
  max-width: 480px;
}

/* ---- Responsive ---- */
@media (max-width: 1000px) {
  .docs-layout { grid-template-columns: 240px minmax(0, 1fr); }
  .docs-main { padding: 32px 32px 64px; }
}
@media (max-width: 640px) {
  .docs-layout { grid-template-columns: minmax(0, 1fr); }
  .docs-pane-stages { display: none; }
}

/* ============================================================
   CRM MODULE - Clients, Contracts, Templates
   ============================================================ */

/* ---- Status palette ---- */
:root {
  --status-draft-bg:     #ecebe7;   --status-draft-fg:     #56524a;
  --status-sent-bg:      #dde7ff;   --status-sent-fg:      #1f3da6;
  --status-viewed-bg:    #fce8c4;   --status-viewed-fg:    #82591a;
  --status-signed-bg:    #cdeedb;   --status-signed-fg:    #1a6b3c;
  --status-completed-bg: #c4e9d3;   --status-completed-fg: #0d5e35;
  --status-voided-bg:    #f4d4d4;   --status-voided-fg:    #99211e;
}

/* ---- Buttons (reusable) ---- */
.btn-primary, .btn-ghost {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 600;
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  letter-spacing: -0.005em;
  transition: background 120ms ease, color 120ms ease, box-shadow 120ms ease;
  white-space: nowrap;
}
.btn-primary {
  background: var(--text);
  color: var(--surface);
  box-shadow: var(--shadow-card);
}
.btn-primary:hover { background: #2a2620; }
.btn-primary:disabled {
  background: var(--surface-3);
  color: var(--text-faint);
  cursor: not-allowed;
  box-shadow: none;
}
.btn-primary svg { color: currentColor; }
.btn-ghost {
  background: transparent;
  color: var(--text-soft);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
/* Soft danger variant - signals destructive intent (Void, Delete) without screaming */
.btn-ghost.btn-danger-soft {
  color: var(--danger);
  border-color: #f1cccc;
}
.btn-ghost.btn-danger-soft:hover {
  background: #fdecec;
  color: var(--danger);
  border-color: #e9b6b6;
}

/* ---- Page sub label ---- */
.page-header-left .page-sub {
  font-size: 12px;
  color: var(--text-muted);
  padding-left: 8px;
  margin-left: 6px;
  border-left: 1px solid var(--border);
  white-space: nowrap;
}

/* ---- CRM toolbar (lighter than filterbar) ---- */
.crm-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.crm-search {
  position: relative;
  display: inline-flex;
  align-items: center;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 5px 10px;
  gap: 6px;
  min-width: 260px;
  transition: border-color 120ms ease, background 120ms ease;
}
.crm-search:focus-within {
  background: var(--surface);
  border-color: var(--text-muted);
}
.crm-search svg { color: var(--text-muted); }
.crm-search input {
  border: none;
  background: transparent;
  outline: none;
  flex: 1;
  font-size: 12.5px;
  color: var(--text);
  min-width: 0;
}
.crm-search input::placeholder { color: var(--text-faint); }

.deal-date-filter {
  position: relative;
  flex: 0 0 auto;
}
.date-filter-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 32px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text-soft);
  font-size: 12.5px;
  font-weight: 500;
  white-space: nowrap;
  transition: background 100ms ease, border-color 100ms ease, color 100ms ease;
}
.date-filter-btn:hover,
.date-filter-btn.active {
  background: var(--surface);
  border-color: var(--border-strong);
  color: var(--text);
}
.date-filter-btn svg { color: var(--text-muted); }
.date-filter-pop {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 360px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow-pop);
  z-index: 50;
}
.date-filter-pop[hidden] { display: none; }
.date-filter-section {
  padding: 10px 0;
  border-bottom: 1px solid var(--hairline);
}
.date-filter-section:first-child { padding-top: 0; }
.date-filter-section:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}
.date-filter-title {
  margin-bottom: 8px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-faint);
}
.date-preset-grid,
.date-year-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.date-preset,
.date-year-btn {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 5px 9px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
  transition: background 100ms ease, color 100ms ease, border-color 100ms ease;
}
.date-preset:hover,
.date-year-btn:hover {
  background: var(--surface-3);
  color: var(--text);
}
.date-preset.active,
.date-year-btn.active {
  background: var(--text);
  border-color: var(--text);
  color: var(--surface);
}
.date-field-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}
.date-range-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.date-range-grid label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}
.date-range-grid span {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
}
.date-filter-pop input[type="date"] {
  width: 100%;
  min-height: 32px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  padding: 5px 8px;
  font: inherit;
  font-size: 12.5px;
}
.date-filter-pop input[type="date"]:focus {
  outline: none;
  background: var(--surface);
  border-color: var(--text-muted);
}
.date-filter-foot {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 10px;
}
.date-apply-btn,
.date-clear-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  font-weight: 600;
}
.date-apply-btn {
  background: var(--text);
  color: var(--surface);
}
.date-clear-btn {
  color: var(--text-muted);
}
.date-clear-btn:hover { background: var(--surface-2); color: var(--text); }

@media (max-width: 960px) {
  .view[data-view="deals"] .filterbar {
    align-items: stretch;
    flex-direction: column;
  }

  .deals-filter-actions {
    width: 100%;
    margin-left: 0;
  }

  .deals-filter-actions .crm-search {
    flex: 1;
    min-width: 180px;
  }
}

@media (max-width: 560px) {
  .deals-filter-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .date-filter-btn,
  .deals-filter-actions .crm-search {
    width: 100%;
  }

  .date-filter-pop {
    left: 0;
    right: auto;
    width: min(360px, calc(100vw - 36px));
  }
}

.crm-meta-count {
  font-size: 11.5px;
  font-family: var(--font-mono);
  color: var(--text-muted);
  letter-spacing: 0.01em;
}

/* ---- CRM body ---- */
.body.crm-body {
  flex: 1;
  overflow: auto;
  padding: 0;
  min-height: 0;
  background: var(--surface);
}

/* ---- CRM table ---- */
.crm-table {
  display: flex;
  flex-direction: column;
}
.crm-row {
  display: grid;
  align-items: center;
  gap: 16px;
  padding: 11px 20px;
  border-bottom: 1px solid var(--hairline);
  cursor: pointer;
  transition: background 100ms ease;
  min-height: 56px;
}
.crm-row:hover { background: var(--surface-2); }
.crm-row.is-header {
  cursor: default;
  background: var(--surface-2);
  padding-top: 9px; padding-bottom: 9px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
  min-height: 36px;
  position: sticky;
  top: 0;
  z-index: 2;
}
.crm-row.is-header:hover { background: var(--surface-2); }

/* Clients table columns */
.clients-row {
  grid-template-columns: minmax(220px, 1.5fr) minmax(240px, 1.6fr) minmax(160px, 1fr) minmax(120px, auto);
}
.clients-row .col-portal { display: flex; align-items: center; }
@media (max-width: 720px) {
  .clients-row { grid-template-columns: minmax(160px, 1.5fr) minmax(200px, 1.6fr) auto; }
  .clients-row .col-phone { display: none; }
}

/* Portal status pill - shared across clients table + client detail header */
.portal-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  font-family: var(--font-mono);
  background: var(--surface-2);
  color: var(--text-muted);
  border: 1px solid var(--border);
  line-height: 1.4;
}
.portal-pill[data-status="invited"]   { background: #fff3da; color: #82591a; border-color: #f1d99c; }
.portal-pill[data-status="activated"] { background: #d3f2dd; color: #1a6b3c; border-color: #b4e4c5; }
.portal-pill[data-status="expired"]   { background: #fde0e0; color: #9b2222; border-color: #f1bcbc; }
.portal-pill[data-status="not-invited"] { background: transparent; color: var(--text-faint); }

#clientDetailInvite { display: inline-flex; align-items: center; gap: 8px; }
#clientDetailInvite .portal-pill { font-size: 9.5px; padding: 2px 7px; }

/* Invite modal: recipient card + meta strip */
.invite-recipient {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  margin-bottom: 16px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.invite-recipient-avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  flex-shrink: 0;
}
.invite-recipient-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.invite-recipient-name  { font-size: 14px; font-weight: 600; color: var(--text); }
.invite-recipient-email { font-size: 12px; color: var(--text-muted); }
.invite-meta {
  margin-top: 12px;
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.invite-meta-row {
  display: flex;
  justify-content: space-between;
  font-size: 11.5px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}
.invite-meta-row span:last-child { color: var(--text); }

/* Invite email preview */
.invite-preview-banner {
  padding: 10px 14px;
  margin-bottom: 14px;
  background: #d3f2dd;
  color: #1a6b3c;
  border: 1px solid #b4e4c5;
  border-radius: var(--radius);
  font-size: 13px;
}
.invite-preview-envelope {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 14px;
  margin-bottom: 16px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: 12px;
}
.invite-preview-envelope-row { display: grid; grid-template-columns: 110px 1fr; gap: 12px; color: var(--text-muted); }
.invite-preview-envelope-row span:last-child { color: var(--text); }
.invite-preview-preheader { font-style: italic; color: var(--text-soft) !important; }
.invite-preview-canvas {
  padding: 28px 36px;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: #1a1a1a;
  font-size: 14px;
  line-height: 1.6;
  max-width: 620px;
  margin: 0 auto;
}
.invite-preview-canvas p { margin: 0 0 14px; }
.invite-preview-canvas ul { margin: 0 0 16px; padding-left: 22px; }
.invite-preview-canvas li { margin-bottom: 4px; }
.invite-meta-table {
  width: 100%;
  border-collapse: collapse;
  margin: 4px 0 18px;
  font-size: 13.5px;
}
.invite-meta-table td {
  padding: 8px 0;
  border-bottom: 1px solid #eee;
}
.invite-meta-table td:first-child { color: #6b6b6b; width: 38%; }
.invite-meta-table td:last-child { color: #1a1a1a; font-weight: 500; }
.invite-cta {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 14px 28px;
  margin: 8px 0 22px;
  background: #0a0a0a;
  color: #fff;
  border-radius: 8px;
  text-align: center;
}
.invite-cta span { font-weight: 700; font-size: 14px; letter-spacing: 0.04em; }
.invite-cta small { font-size: 11px; opacity: 0.7; }
.invite-note {
  margin: 16px 0;
  padding: 12px 16px;
  border-left: 3px solid #d4d4d4;
  background: #fafafa;
  font-style: italic;
  color: #444;
}
.invite-signoff { margin-top: 24px !important; color: #1a1a1a; }
.invite-signoff strong { display: inline-block; margin-top: 4px; }
.invite-sig-role { color: #6b6b6b; font-size: 12.5px; }

/* Contracts table columns */
.contracts-row {
  grid-template-columns: 120px minmax(220px, 2fr) minmax(160px, 1.2fr) 120px 120px;
}
@media (max-width: 980px) {
  .contracts-row { grid-template-columns: 110px minmax(180px, 2fr) minmax(140px, 1.2fr) 120px; }
  .contracts-row .col-sent { display: none; }
}

.col-primary {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.col-primary-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.col-primary-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.005em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.col-primary-sub {
  font-size: 11.5px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.client-avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--dept-legal);
  color: var(--dept-legal-fg);
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  flex-shrink: 0;
}

.col-soft {
  font-size: 12.5px;
  color: var(--text-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.col-faint {
  font-size: 12px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  letter-spacing: 0.005em;
}
.col-count {
  font-size: 12.5px;
  color: var(--text-soft);
  font-variant-numeric: tabular-nums;
}
.col-actions {
  display: flex;
  justify-content: flex-end;
  gap: 2px;
}

/* ---- Status pills + dots ---- */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px 3px 8px;
  border-radius: var(--radius-pill);
  letter-spacing: 0.01em;
  white-space: nowrap;
}
.status-pill .status-dot { width: 6px; height: 6px; border-radius: 50%; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-faint); display: inline-block; }

.status-pill.s-draft     { background: var(--status-draft-bg);     color: var(--status-draft-fg); }
.status-pill.s-sent      { background: var(--status-sent-bg);      color: var(--status-sent-fg); }
.status-pill.s-viewed    { background: var(--status-viewed-bg);    color: var(--status-viewed-fg); }
.status-pill.s-signed    { background: var(--status-signed-bg);    color: var(--status-signed-fg); }
.status-pill.s-completed { background: var(--status-completed-bg); color: var(--status-completed-fg); }
.status-pill.s-voided    { background: var(--status-voided-bg);    color: var(--status-voided-fg); }

.status-dot.s-draft     { background: var(--status-draft-fg); }
.status-dot.s-sent      { background: var(--status-sent-fg); }
.status-dot.s-viewed    { background: var(--status-viewed-fg); }
.status-dot.s-signed    { background: var(--status-signed-fg); }
.status-dot.s-completed { background: var(--status-completed-fg); }
.status-dot.s-voided    { background: var(--status-voided-fg); }
.status-pill.s-draft     .status-dot { background: var(--status-draft-fg); }
.status-pill.s-sent      .status-dot { background: var(--status-sent-fg); }
.status-pill.s-viewed    .status-dot { background: var(--status-viewed-fg); }
.status-pill.s-signed    .status-dot { background: var(--status-signed-fg); }
.status-pill.s-completed .status-dot { background: var(--status-completed-fg); }
.status-pill.s-voided    .status-dot { background: var(--status-voided-fg); }

/* ---- Empty state ---- */
.crm-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 24px;
  text-align: center;
  gap: 8px;
  min-height: 380px;
}
.crm-empty-icon {
  width: 56px; height: 56px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  display: grid;
  place-items: center;
  color: var(--text-muted);
  font-size: 26px;
  margin-bottom: 8px;
}
.crm-empty-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.005em;
}
.crm-empty-sub {
  font-size: 12.5px;
  color: var(--text-muted);
  max-width: 340px;
  margin-bottom: 16px;
}

/* ---- Template grid ---- */
.template-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
  padding: 18px;
}
.template-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 14px 12px;
  cursor: pointer;
  transition: border-color 120ms ease, box-shadow 120ms ease, transform 120ms ease;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 130px;
}
.template-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-active);
}
.template-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}
.template-card-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.005em;
  line-height: 1.3;
}
.template-cat {
  display: inline-flex;
  align-items: center;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 2px 7px;
  border-radius: var(--radius-xs);
  background: var(--surface-2);
  border: 1px solid var(--border);
  white-space: nowrap;
}
.template-card-desc {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
  flex: 1;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.template-card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 10px;
  border-top: 1px solid var(--hairline);
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}
.template-card-vars {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.template-card-vars svg { color: var(--text-faint); }

/* ============================================================
   MODALS
   ============================================================ */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 18, 14, 0.36);
  backdrop-filter: blur(2px);
  z-index: 100;
  animation: fadeIn 140ms ease;
}
.modal-backdrop[hidden] { display: none; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes popIn {
  from { opacity: 0; transform: translate(-50%, -48%) scale(0.97); }
  to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

.modal {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: min(520px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-pop);
  z-index: 101;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: popIn 160ms cubic-bezier(0.2, 0.8, 0.3, 1);
}
.modal[hidden] { display: none; }
.modal-wide { width: min(880px, calc(100vw - 32px)); }

/* Right-side drawer variant of the modal - slides in from the edge. */
@keyframes drawerIn {
  from { opacity: 0; transform: translateX(24px); }
  to   { opacity: 1; transform: translateX(0); }
}
.modal-drawer {
  top: 0;
  right: 0;
  left: auto;
  bottom: 0;
  width: min(420px, calc(100vw - 32px));
  max-height: 100vh;
  height: 100vh;
  transform: none;
  border-radius: 0;
  box-shadow: -16px 0 40px -20px rgba(20,18,14,0.24);
  animation: drawerIn 220ms cubic-bezier(.2,.8,.2,1);
}
.modal-drawer .modal-head { padding: 18px 20px 14px; }
.modal-drawer .modal-body { padding: 18px 20px; }
.modal-drawer .modal-foot { padding: 14px 20px; }

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px 14px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.005em;
}
.modal-body {
  flex: 1;
  overflow: auto;
  padding: 18px 20px;
  min-height: 0;
}
.modal-body-split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 0;
  padding: 0;
}
.modal-body-split > .form-grid { padding: 18px 20px; overflow: auto; max-height: calc(100vh - 200px); }
.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 16px;
  background: var(--surface-2);
  border-top: 1px solid var(--border);
}

/* ---- Form grid ---- */
.form-grid {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.form-row { display: flex; flex-direction: column; gap: 14px; }
.form-row-split { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 560px) {
  .form-row-split { grid-template-columns: 1fr; }
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.form-label {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-soft);
  letter-spacing: 0.005em;
  display: flex;
  align-items: center;
  gap: 6px;
}
.form-optional {
  font-weight: 500;
  color: var(--text-muted);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.form-help {
  display: block;
  margin-top: 6px;
  font-size: 11.5px;
  color: var(--text-muted);
  line-height: 1.5;
}
.form-hint {
  font-weight: 500;
  color: var(--text-muted);
  font-size: 11px;
}
.form-hint code, .modal code {
  font-family: var(--font-mono);
  font-size: 10.5px;
  background: var(--surface-3);
  border-radius: 4px;
  padding: 1px 5px;
  color: var(--text-soft);
}

.form-field input[type="text"],
.form-field input[type="email"],
.form-field input[type="tel"],
.form-field select,
.form-field textarea {
  font-family: inherit;
  font-size: 13px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  outline: none;
  transition: border-color 100ms ease, box-shadow 100ms ease;
  width: 100%;
}
.form-field textarea {
  resize: vertical;
  min-height: 90px;
  line-height: 1.55;
}
.form-field textarea#templateBody {
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.6;
  min-height: 280px;
}
.form-field select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%23807c73' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m7 10 5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
  padding-right: 36px;
}
.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus {
  border-color: var(--text);
  box-shadow: 0 0 0 3px rgba(20, 18, 14, 0.06);
}

/* ---- Template editor preview pane ---- */
.template-preview-pane {
  background: var(--surface-2);
  border-left: 1px solid var(--border);
  padding: 18px;
  overflow: auto;
  max-height: calc(100vh - 200px);
}
.template-preview-label {
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.template-preview-vars {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.template-preview-vars .var-chip {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-family: var(--font-mono);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-soft);
  padding: 3px 8px;
  border-radius: var(--radius-xs);
}
.template-preview-empty {
  font-size: 11.5px;
  color: var(--text-muted);
  line-height: 1.5;
}
.template-preview {
  font-size: 11.5px;
  line-height: 1.65;
  color: var(--text-soft);
  white-space: pre-wrap;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  max-height: 260px;
  overflow: auto;
}
.template-preview .var-token {
  background: var(--accent-blue-soft);
  color: var(--accent-blue);
  font-family: var(--font-mono);
  font-size: 10.5px;
  padding: 1px 6px;
  border-radius: 4px;
}
@media (max-width: 800px) {
  .modal-body-split { grid-template-columns: 1fr; }
  .template-preview-pane { border-left: none; border-top: 1px solid var(--border); }
}

/* ---- Wizard ---- */
.wizard-steps {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: var(--text-muted);
  flex: 1;
  justify-content: center;
}
.wizard-step {
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--text-muted);
  font-weight: 500;
  letter-spacing: 0.005em;
}
.wizard-step.active {
  background: var(--surface-3);
  color: var(--text);
  font-weight: 600;
}
.wizard-step.done {
  color: var(--ok);
}
.wizard-pane[hidden] { display: none; }
.wizard-search {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 12px;
  margin-bottom: 12px;
  width: 100%;
}
.wizard-search svg { color: var(--text-muted); }
.wizard-search input {
  border: none;
  background: transparent;
  outline: none;
  flex: 1;
  font-size: 13px;
}
.wizard-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 360px;
  overflow: auto;
  padding: 2px;
}
.wizard-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color 100ms ease, background 100ms ease;
  background: var(--surface);
}
.wizard-item:hover { background: var(--surface-2); }
.wizard-item.selected {
  border-color: var(--text);
  background: var(--surface);
  box-shadow: 0 0 0 3px rgba(20, 18, 14, 0.05);
}
.wizard-item-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}
.wizard-item-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.wizard-item-sub {
  font-size: 11.5px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.wizard-empty {
  padding: 40px 20px;
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
}

/* Step-2 client mode tabs (Existing client / Add new client) */
.wizard-tabs {
  display: flex;
  gap: 4px;
  padding: 3px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 14px;
  width: fit-content;
}
.wizard-tab {
  padding: 6px 14px;
  font: inherit;
  font-size: 12.5px;
  font-weight: 500;
  background: transparent;
  border: none;
  border-radius: 6px;
  color: var(--text-soft);
  cursor: pointer;
  transition: background 100ms ease, color 100ms ease;
}
.wizard-tab:hover { color: var(--text); }
.wizard-tab.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 2px rgba(20,18,14,0.06);
}
.wizard-client-mode[hidden] { display: none; }

/* Inline "new client" form inside the wizard */
.wizard-new-client-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.wizard-form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.wizard-form-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.wizard-form-field > span {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-soft);
  letter-spacing: 0.01em;
}
.wizard-form-field em {
  color: var(--danger);
  font-style: normal;
  margin-left: 2px;
}
.wizard-form-field input,
.wizard-form-field textarea {
  width: 100%;
  padding: 8px 11px;
  border: 1px solid var(--border);
  border-radius: 7px;
  font: inherit;
  font-size: 13px;
  background: var(--surface);
  color: var(--text);
  resize: vertical;
  transition: border-color 100ms ease, box-shadow 100ms ease;
}
.wizard-form-field input:focus,
.wizard-form-field textarea:focus {
  outline: none;
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px var(--accent-blue-soft);
}
.wizard-form-hint {
  font-size: 11.5px;
  color: var(--text-muted);
  padding: 6px 10px;
  background: var(--accent-blue-soft);
  border-left: 2px solid var(--accent-blue);
  border-radius: 4px;
}

/* Tag inside the review block header (e.g. "New client - will be saved on send") */
.wizard-review-tag {
  display: inline-block;
  margin-left: 8px;
  padding: 1px 7px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: none;
  color: var(--accent-blue);
  background: var(--accent-blue-soft);
  border-radius: 4px;
}

@media (max-width: 540px) {
  .wizard-form-row { grid-template-columns: 1fr; }
}

.wizard-review {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.wizard-review-block {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}
.wizard-review-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.wizard-review-head .btn-ghost {
  padding: 3px 8px;
  font-size: 11px;
  border-radius: var(--radius-xs);
}
.wizard-review-body {
  padding: 12px 14px;
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--text-soft);
}
.wizard-review-body .review-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 0;
}
.wizard-review-body .review-row-label { color: var(--text-muted); }
.wizard-review-preview {
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.65;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: 12px;
  white-space: pre-wrap;
  max-height: 220px;
  overflow: auto;
}
.wizard-review-preview .var-token {
  background: var(--accent-blue-soft);
  color: var(--accent-blue);
  padding: 1px 5px;
  border-radius: 4px;
}

/* ============================================================
   CRM detail rail
   ============================================================ */
.crm-rail {
  position: fixed;
  top: 0; right: 0;
  height: 100vh;
  width: min(420px, 100vw);
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-pop);
  z-index: 90;
  display: flex;
  flex-direction: column;
  animation: slideIn 200ms cubic-bezier(0.2, 0.8, 0.3, 1);
}
.crm-rail[hidden] { display: none; }
@keyframes slideIn {
  from { transform: translateX(20px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}
.crm-rail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px 14px 20px;
  border-bottom: 1px solid var(--border);
}
.crm-rail-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.005em;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

/* Inline chip row for the lead rail Overview (source + leadStage chips). */
.rail-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}
.rail-chip {
  display: inline-flex;
  align-items: center;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-soft);
  text-transform: capitalize;
}
.rail-chip.tone-amber   { background: #fff5e0; color: #82591a; }
.rail-chip.tone-blue    { background: var(--accent-blue-soft, #e7eefc); color: var(--accent-blue, #2e5bbc); }
.rail-chip.tone-green   { background: #e2f5e7; color: #1a6b3c; }
.rail-chip.tone-violet  { background: #ece7fc; color: #6a44d6; }
.rail-chip.tone-neutral { background: var(--surface-2); color: var(--text-soft); }
.rail-note-body {
  font-size: 13px;
  color: var(--text);
  line-height: 1.5;
  padding: 10px 12px;
  background: var(--surface-2);
  border-radius: 8px;
}

/* Rich title used by the generic-mode rail. Two stacked lines: a small
   uppercase "Stage NN" eyebrow and the stage name beneath it. Sits inside
   the rail header alongside the X close button. */
.crm-rail-title-rich {
  display: flex;
  flex-direction: column;
  gap: 2px;
  white-space: normal;
}
.crm-rail-title-badge {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  font-family: var(--font-mono);
}
.crm-rail-title-name {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
  line-height: 1.15;
}
.crm-rail-body {
  flex: 1;
  overflow: auto;
  padding: 0 20px 32px;
}
.crm-rail-head-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}
.rail-menu { position: relative; }
.rail-menu-pop {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 180px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(15, 18, 32, 0.10);
  padding: 6px;
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.rail-menu-pop[hidden] { display: none; }
.rail-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: transparent;
  border: 0;
  border-radius: 6px;
  font: inherit;
  font-size: 13px;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}
.rail-menu-item:hover { background: var(--surface-2); }
.rail-menu-item.is-danger { color: var(--err, #c0392b); }
.rail-menu-item.is-danger:hover { background: rgba(192, 57, 43, 0.06); }
.rail-menu-sep {
  height: 1px;
  background: var(--hairline, var(--border));
  margin: 4px 2px;
}

.rail-section { display: flex; flex-direction: column; gap: 6px; margin-bottom: 22px; }

/* ============================================================
   RUNBOOK FLOW - polished trigger map
   ----------------------------------------------------------------
   Vertical chain of parent action nodes (.rb-step-parent), each
   with an optional child verification node (.rb-step-child) that
   branches off to the right via an L-wire. The vertical connector
   between rows + the horizontal wire to the child form the L
   visually. Status indicator fills green when done, empty when
   pending. Polished card-style nodes - rounded borders, subtle
   shadow on hover, smooth state transitions.
   ============================================================ */
/* ============================================================
   FLOW STAGE PICKER - the dropdown at the top of every Flow tab.
   Lets the user move the active person to a different stage (or
   switch the viewed stage in the generic rail). Sits above the
   trigger header and the flow.
   ============================================================ */
/* Stage picker at the top of the Flow tab - compact, modern button-shaped
   select pushed to the right edge of the rail. The select takes only its
   natural width (sized to the longest stage label, "Contracting & Payment"),
   so it doesn't stretch full-width across the rail. */
.flow-stage-picker {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0;
  margin-bottom: 14px;
  justify-content: flex-end;
}
.flow-stage-picker-eyebrow {
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
  flex-shrink: 0;
  /* Push the eyebrow to the left while the select sits at the right. */
  margin-right: auto;
}
.flow-stage-picker-select {
  /* Natural content width - browsers size native selects to the longest
     option text by default when flex-grow/width:1 aren't set. */
  flex: 0 0 auto;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  padding: 5px 26px 5px 10px;
  font: inherit;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text);
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: 7px;
  cursor: pointer;
  outline: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%23807c73' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m7 10 5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 9px center;
  transition: border-color 100ms ease, box-shadow 100ms ease, background-color 100ms ease;
}
.flow-stage-picker-select:hover {
  border-color: var(--text-muted);
  background-color: var(--surface-2);
}
.flow-stage-picker-select:focus {
  border-color: var(--text);
  box-shadow: 0 0 0 3px rgba(20, 18, 14, 0.06);
}

/* ============================================================
   FLOW ITEMS - runbook flow list
   ----------------------------------------------------------------
   Used in the side rail to render an action chain: trigger at the
   top, parents stacked below, optional smaller children indented
   right with an L-shaped wire. Continuous hairline runs through
   the icon column. Done state fills the tile solid green.
   ============================================================ */
.flow-items {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 4px 0 2px;
}
/* Continuous vertical wire down the centre of the icon column. Anchored
   tile-centre to tile-centre so it reads as one clean rail; each tile sits
   on z-index:1 to mask the wire crossing behind it. */
.flow-items::before {
  content: '';
  position: absolute;
  left: 15px;                /* centre of 30px tile column */
  top: 19px;                 /* centre of first tile */
  bottom: 19px;              /* centre of last tile */
  border-left: 1px solid var(--border);
  pointer-events: none;
}
.flow-item {
  position: relative;
  display: grid;
  grid-template-columns: 30px 1fr;
  gap: 12px;
  padding: 5px 0;
  align-items: start;
}
.flow-items > .flow-item:first-child { padding-top: 2px; }
.flow-items > .flow-item:last-child  { padding-bottom: 2px; }

/* Circular click-target. Pending = white fill, green outline ring, faded
   icon inside - reads as a clickable "mark done" button. Fired = solid
   green fill with a crisp white icon. Same column position in both states
   so the row doesn't shift when a step is toggled. */
.flow-item-icon {
  position: relative;
  z-index: 1;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--surface);
  color: rgba(22, 163, 74, 0.55);
  border: 1.5px solid #16a34a;
  padding: 0;
  cursor: pointer;
  font: inherit;
  transition: background 160ms ease, color 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}
.flow-item-icon:hover {
  color: #16a34a;
  background: rgba(22, 163, 74, 0.06);
  box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.10);
}
.flow-item-icon:focus-visible { outline: 2px solid var(--accent-blue, #3b6eff); outline-offset: 2px; }
.flow-item-icon svg { width: 14px; height: 14px; }

.flow-item.is-trigger .flow-item-title {
  font-weight: 700;
}

/* Fired: solid green fill + white icon at full opacity. */
.flow-item-icon.is-fired {
  background: #16a34a;
  color: #fff;
  border-color: #16a34a;
}
.flow-item-icon.is-fired:hover {
  box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.18);
}

.flow-item-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
/* Fixed right column reserves a consistent slot for the stamp so clicking a
   row to toggle done state doesn't shift the title left/right. min-height
   keeps the head's vertical size constant whether the 2-line stamp is
   rendered or not - title stays centered against the icon in both states. */
.flow-item-head {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 12px;
  min-width: 0;
  min-height: 30px;
}
.flow-item-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.005em;
  line-height: 1.3;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.flow-item-meta {
  font-size: 11.5px;
  color: var(--text-muted);
  line-height: 1.3;
}
/* Chevron toggle at the far right of each flow item's head. Rotates when
   the row is expanded. Quiet hover state - it's a secondary affordance. */
.flow-item-chevron {
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 4px;
  flex-shrink: 0;
  transition: background 100ms ease, transform 200ms ease, color 100ms ease;
}
.flow-item-chevron:hover { background: var(--surface-2); color: var(--text); }
.flow-item.is-expanded .flow-item-chevron { transform: rotate(180deg); }

/* Detail chips revealed when a flow item is expanded. Small pill-style
   capsules holding metadata (date, time, etc.) - sit below the title in a
   wrappable row. */
.flow-item-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
.flow-item-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 8px 4px 7px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.flow-item-chip svg { flex-shrink: 0; opacity: 0.85; }
.flow-item-chip-muted {
  font-style: italic;
  text-transform: none;
  letter-spacing: 0;
  color: var(--text-soft);
}

/* Single-line "Today · 7:43 PM" stamp on the right of each done step.
   Sentence case + soft color reads more humane than the prior stacked
   uppercase pair, and the row stays single-height whether stamped or not. */
.flow-item-stamp {
  justify-self: end;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-soft);
  font-variant-numeric: tabular-nums;
  line-height: 1.3;
  white-space: nowrap;
  flex-shrink: 0;
}

/* Tiny "auto" / "manual" tag at the top right of each flow item. Tells the
   user at a glance whether the system handles the step or someone needs to
   do it. Lower visual weight than the title - this is a quiet meta label. */
.flow-item-mode {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: var(--surface-2);
  padding: 2px 6px;
  border-radius: 4px;
  white-space: nowrap;
  flex-shrink: 0;
  line-height: 1.4;
}
.flow-item-mode.is-manual {
  color: #82591a;
  background: #fff1d8;
}

/* Per-step time row: absolute stamp ("Friday 3:12 PM") on the left, relative
   ("2 hours ago") on the right. Modeled after the reference notification
   cards Anna shared. Sits between the title row and the type-meta line. */
.flow-item-time {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 2px;
  font-size: 11.5px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  line-height: 1.3;
}
.flow-item-when {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.flow-item-ago {
  white-space: nowrap;
  flex-shrink: 0;
}

/* Status pills - reuse the same colour palette as .rb-status for
   consistency across all flow surfaces. */
.flow-item-status {
  font-size: 10.5px;
  font-weight: 600;
  padding: 2px 9px;
  border-radius: 6px;
  letter-spacing: 0.01em;
  white-space: nowrap;
  flex-shrink: 0;
}
.flow-item-status-pending {
  background: var(--surface-2);
  color: var(--text-muted);
}
.flow-item-status-in-progress {
  background: rgba(59, 110, 255, 0.12);
  color: var(--accent-blue, #3b6eff);
}
.flow-item-status-completed {
  background: rgba(22, 163, 74, 0.12);
  color: #16a34a;
}
.flow-item-status-auto {
  background: rgba(59, 110, 255, 0.10);
  color: var(--accent-blue, #3b6eff);
}
.flow-item-status-manual {
  background: var(--surface-2);
  color: var(--text-soft);
}

/* Nested sub-actions - clean indented list under the parent's body. One
   continuous vertical accent bar runs down the left of the whole sub-item
   group (not per row), matching the Ark UI accordion content pattern.
   No icon, no L-wire - just an indented, clickable row. */
.flow-item-substeps {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  /* The accent bar lives on the container so it's one continuous line
     regardless of how many children there are. Thin black hairline. */
  border-left: 1px solid var(--text);
  padding-left: 0;
}
.flow-item-substep {
  /* Clickable row. Resets default button chrome so it reads as plain text
     with an affordance on hover. Title + optional right-aligned stamp. */
  appearance: none;
  background: transparent;
  border: 0;
  padding: 6px 10px 6px 14px;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  cursor: pointer;
  font: inherit;
  color: var(--text);
  border-radius: 0 6px 6px 0;
  transition: background 140ms ease, color 140ms ease;
  min-width: 0;
}
.flow-item-substep-stamp {
  margin-left: auto;
  flex-shrink: 0;
  font-size: 10px;
  font-weight: 500;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
  white-space: nowrap;
}
.flow-item-substep.is-done .flow-item-substep-stamp {
  color: var(--text-faint);
}
.flow-item-substep + .flow-item-substep { margin-top: 1px; }
.flow-item-substep:hover {
  background: color-mix(in srgb, var(--accent-blue, #3b6eff) 5%, transparent);
}
.flow-item-substep:focus-visible {
  outline: 2px solid var(--accent-blue, #3b6eff);
  outline-offset: -2px;
}
/* Done state for substeps. Replaces the old strikethrough treatment with
   a tiny green outline ring + soft green wash on the row - reads as
   "completed" without obscuring the title. The title color stays normal so
   the row remains scannable; the stamp keeps its existing muted tone. */
.flow-item-substep.is-done {
  background: rgba(22, 163, 74, 0.05);
  box-shadow: inset 0 0 0 1px rgba(22, 163, 74, 0.32);
  border-radius: 6px;
}
.flow-item-substep.is-done .flow-item-substep-title {
  color: var(--text);
  text-decoration: none;
}
.flow-item-substep-title {
  font-size: 13px;
  font-weight: 500;
  color: inherit;
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: -0.005em;
  min-width: 0;
}

/* The flow itself: stacked items with even spacing. No outer card chrome -
   the items breathe directly on the rail's background. */
.rb-flow {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 4px 0;
}

/* An item is the parent action row + any indented sub-actions. Use article
   for semantics + an "is-{status}" class so done items can pick up the
   strikethrough treatment from a single rule. */
.rb-item {
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* Parent row: small tick on the left, label in the middle, right-aligned
   status pill. Grid columns: tick / label (flex) / status pill (auto). */
.rb-item-row {
  display: grid;
  grid-template-columns: 12px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  background: transparent;
  border: 0;
  border-radius: 6px;
  font: inherit;
  color: var(--text);
  text-align: left;
  cursor: default;
  width: 100%;
  transition: background 120ms ease;
}
button.rb-item-row { cursor: pointer; }
button.rb-item-row:hover:not([disabled]) {
  background: var(--surface-2);
}
button.rb-item-row[disabled] {
  cursor: not-allowed;
}

/* Label: clean medium weight, truncates if too long. Done items get
   strikethrough + muted color via the .is-done class on .rb-item. */
.rb-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  letter-spacing: -0.005em;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.rb-item.is-done > .rb-item-row .rb-label,
.rb-substep.is-done .rb-label {
  color: var(--text-muted);
  text-decoration: line-through;
}

/* Status pills on the right. Subtle tinted background + matching text
   color for each state. Lowercase for the soft "in-progress" / "pending"
   feel from the reference. */
.rb-status {
  font-size: 10.5px;
  font-weight: 600;
  padding: 2px 9px;
  border-radius: 6px;
  letter-spacing: 0.01em;
  white-space: nowrap;
}
.rb-status-pending {
  background: var(--surface-2);
  color: var(--text-muted);
}
.rb-status-in-progress {
  background: rgba(59, 110, 255, 0.12);
  color: var(--accent-blue, #3b6eff);
}
.rb-status-completed {
  background: rgba(22, 163, 74, 0.12);
  color: #16a34a;
}
.rb-status-auto {
  background: rgba(59, 110, 255, 0.10);
  color: var(--accent-blue, #3b6eff);
}
.rb-status-manual {
  background: var(--surface-2);
  color: var(--text-soft);
}
/* PLANNED (un-wired) steps: same layout, just grayed + inert. Renders for the
   lifecycle steps we haven't built yet so they read as a blueprint, never as
   something live. Flip a step live by adding its id to WIRED_STEPS (app.js). */
.rb-item.is-planned {
  opacity: 0.5;
  filter: grayscale(1);
}
.rb-item.is-planned .rb-item-row {
  cursor: default;
}
.rb-substep.is-planned {
  opacity: 0.5;
  filter: grayscale(1);
  cursor: default;
}
.rb-status-planned {
  background: var(--surface-2);
  color: var(--text-faint, #a8a39a);
}

/* TICKS - small status dots on the left. 10px circles, one of three
   states: pending (filled solid grey), in-progress (dashed blue outline),
   done (filled green with checkmark). Pending is a solid fill - no
   outline - so the row reads as "dot · title" cleanly inline. */
.rb-tick {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-grid;
  place-items: center;
  flex-shrink: 0;
  background: transparent;
  transition: background 160ms ease, border-color 160ms ease;
  box-sizing: border-box;
}
.rb-tick-pending {
  background: var(--border-strong, #c9c4b8);
  border: 0;
}
.rb-tick-in-progress {
  width: 12px;
  height: 12px;
  border: 1.4px dashed var(--accent-blue, #3b6eff);
  background: transparent;
}
.rb-tick-done {
  width: 12px;
  height: 12px;
  border: 1.4px solid #16a34a;
  background: #16a34a;
  color: #fff;
  font-size: 8px;
  font-weight: 800;
  line-height: 1;
}
.rb-tick-done::after { content: '✓'; }

/* INDENTED SUB-ACTIONS - stack of rows under a parent, connected by a
   thin vertical dashed line on the left. Each sub row has its own small
   tick + label, no status pill. */
.rb-substeps {
  display: flex;
  flex-direction: column;
  gap: 0;
  position: relative;
  padding: 2px 0 6px 26px;     /* 26px indent past the parent's tick */
  margin-left: 0;
}
.rb-substeps::before {
  content: '';
  position: absolute;
  left: 6px;                   /* aligns visually with parent tick center */
  top: 2px;
  bottom: 8px;
  width: 0;
  border-left: 1px dashed var(--border-strong, #c9c4b8);
  opacity: 0.7;
}
.rb-substep {
  display: grid;
  grid-template-columns: 12px 1fr;
  align-items: center;
  gap: 10px;
  padding: 5px 0;
  background: transparent;
  border: 0;
  font: inherit;
  color: var(--text);
  text-align: left;
  cursor: default;
  width: 100%;
  border-radius: 6px;
  transition: background 120ms ease;
}
button.rb-substep { cursor: pointer; }
button.rb-substep:hover:not([disabled]) { background: var(--surface-2); }
button.rb-substep[disabled] { cursor: not-allowed; }
.rb-substep .rb-label {
  font-size: 12.5px;
  font-weight: 400;
  color: var(--text-soft);
}

/* Disposition buttons (Sold / Not sold) sit below the flow. Keep their
   existing styles - they live in .runbook-disposition. */

/* ============================================================
   Legacy runbook list styles - retained below for any panels that
   still reference .runbook-step / .runbook-steps directly.
   ============================================================ */

/* Runbook is now a chrome-free vertical list of action items. No outer card,
   no title, no blurb. Each row is a thin-divider task line with a square
   checkbox on the left, label in the middle, meta on the right. */
.runbook-section {
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  gap: 0;
  margin-bottom: 22px;
}
.runbook-blurb { display: none; }
.runbook-steps {
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--hairline, rgba(0,0,0,0.06));
}
.runbook-step {
  display: grid;
  grid-template-columns: 22px 1fr auto;
  align-items: center;
  gap: 14px;
  padding: 12px 4px;
  border: 0;
  border-bottom: 1px solid var(--hairline, rgba(0,0,0,0.06));
  border-radius: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
  font: inherit;
  color: var(--text);
  transition: background 80ms ease;
}
.runbook-step:hover { background: var(--surface-2); }
.runbook-step:last-child { border-bottom: 0; }
.runbook-step[disabled] { cursor: default; }
.runbook-step[disabled]:hover { background: transparent; }
.runbook-step-tick {
  width: 20px;
  height: 20px;
  border: 1.6px solid var(--border-strong, var(--border));
  border-radius: 5px;
  display: grid;
  place-items: center;
  font-size: 0;
  line-height: 1;
  color: transparent;
  background: transparent;
  transition: background 100ms ease, border-color 100ms ease, color 100ms ease, font-size 100ms ease;
}
.runbook-step:hover .runbook-step-tick { border-color: var(--text-muted); }
.runbook-step.is-done .runbook-step-tick {
  background: #1a6b3c;
  border-color: #1a6b3c;
  color: #fff;
  font-size: 12px;
}
.runbook-step-label {
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text);
  line-height: 1.4;
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
}
.runbook-step.is-done .runbook-step-label {
  text-decoration: line-through;
  text-decoration-color: var(--text-faint);
  color: var(--text-muted);
}
.runbook-step-meta {
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.01em;
  white-space: nowrap;
}

/* Trigger header that sits above the action items inside the Actions tab.
   Eyebrow label + dashed-circle dot + the event label that fires this list. */
.runbook-trigger {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 0 14px;
  border-bottom: 1px solid var(--hairline);
  margin-bottom: 10px;
}
.runbook-trigger-eyebrow {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
}
.runbook-trigger-row {
  display: flex;
  align-items: center;
  gap: 9px;
}
.runbook-trigger-dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-blue);
  flex-shrink: 0;
}
.runbook-trigger-dot.is-fired {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #1a6b3c;
  box-shadow: 0 0 0 3px rgba(26, 107, 60, 0.15);
}
.runbook-trigger-value {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.005em;
  text-transform: capitalize;
}
.runbook-trigger-time {
  margin-left: auto;
  font-size: 11px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
.runbook-flow-label {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 16px 0 12px;
}
.runbook-flow-label-title {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.runbook-flow-label-count {
  margin-left: auto;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-soft);
  font-variant-numeric: tabular-nums;
}

/* Lead-stage flow card. Wraps the flow-items list in a rounded, bordered
   surface with hairline dividers between rows - inspired by the Ark UI
   accordion treatment but with no expand/collapse affordance. Scoped via
   .lead-stage-flow-card so other rails using .flow-items keep the bare
   floating-rail look. */
.lead-stage-flow {
  margin-bottom: 22px;
}
.lead-stage-flow-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: linear-gradient(135deg, var(--surface) 0%, var(--surface-2) 100%);
  overflow: hidden;
}
.lead-stage-flow-card .flow-items {
  padding: 0;
}
/* Card variant has hairline row dividers, so the continuous vertical rail
   would be redundant - hide it. */
.lead-stage-flow-card .flow-items::before {
  display: none;
}
.lead-stage-flow-card .flow-item {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  transition: background 180ms ease;
}
.lead-stage-flow-card .flow-items > .flow-item:first-child {
  padding-top: 14px;
}
.lead-stage-flow-card .flow-items > .flow-item:last-child {
  padding-bottom: 14px;
  border-bottom: 0;
}
.lead-stage-flow-card .flow-item:hover {
  background: linear-gradient(90deg, rgba(22, 163, 74, 0.05), rgba(22, 163, 74, 0) 70%);
}

/* Generic (no-client) step rows - flat, non-interactive variant of the
   action item used in the rail's "Actions" tab before a card is clicked. */
.runbook-step.is-generic { cursor: default; }
.runbook-step.is-generic:hover { background: transparent; }
.runbook-step.is-generic .runbook-step-tick { border-style: dashed; }

/* Generic empty state - prompts the user to click a card. Big centered icon
   + title + subtitle. */
.rail-generic-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 72px 24px 40px;
  gap: 8px;
}
.rail-generic-empty-icon {
  color: var(--text-faint);
  margin-bottom: 4px;
}
.rail-generic-empty-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}
.rail-generic-empty-sub {
  font-size: 12.5px;
  color: var(--text-soft);
  line-height: 1.5;
  max-width: 280px;
}

.runbook-disposition {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--border);
  margin-top: 4px;
}
.runbook-dispose {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 10px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background 100ms ease, border-color 100ms ease, color 100ms ease;
}
.runbook-dispose-yes {
  background: var(--accent-blue);
  border-color: var(--accent-blue);
  color: #fff;
}
.runbook-dispose-yes:hover { filter: brightness(0.95); }
.runbook-dispose-no:hover {
  background: rgba(180, 40, 40, 0.06);
  border-color: #b53737;
  color: #b53737;
}

/* Pre-call questionnaire (lead-stage rail). Placeholder shape until the
   real send/receive flow is wired. */
.questionnaire-section { gap: 10px; }
.questionnaire-section .rail-section-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.rail-section-status {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 2px 8px;
  background: var(--surface-2);
  border-radius: 999px;
}
.rail-section-status.is-sent { color: var(--accent-blue); background: var(--accent-blue-soft); }
.rail-section-status.is-answered { color: #1a6b3c; background: rgba(26, 107, 60, 0.1); }
.questionnaire-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.questionnaire-q {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 12.5px;
  color: var(--text);
  line-height: 1.4;
}
.questionnaire-q-tick {
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1;
  width: 14px;
  flex-shrink: 0;
  text-align: center;
}

/* Sticky disposition footer for lead-stage rail. Anchored at the bottom of
   the scroll container with a top border so it visually peels off the panel. */
/* Stage sub-tabs inside the lead rail's Overview panel. Horizontal strip of
   chip-style pills, one per pipeline stage. Scrolls horizontally on narrow
   rails so all 6 stages remain reachable without truncating labels. */
.lead-stage-history { margin-top: 8px; }
.lead-stage-subtabs {
  display: flex;
  gap: 4px;
  margin: 6px -4px 12px;
  padding: 4px;
  overflow-x: auto;
  scrollbar-width: none;
}
.lead-stage-subtabs::-webkit-scrollbar { display: none; }
.lead-stage-subtab {
  flex-shrink: 0;
  padding: 6px 11px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
}
.lead-stage-subtab:hover {
  color: var(--text-soft);
  border-color: var(--border-strong);
}
.lead-stage-subtab.is-active {
  background: var(--text);
  color: var(--surface);
  border-color: var(--text);
  font-weight: 600;
}
/* Past stages - the person has already cleared these. A soft, modern green
   wash inside the pill (same "completed" tokens as the receipt) says "done"
   without shouting, and stays quieter than the current stage, which carries
   the green ring. Scoped to :not(.is-active) so the black selected-tab fill
   always wins when a done stage is the one being viewed (mirrors is-current).
   Tab stays clickable for history review. */
.lead-stage-subtab.is-past:not(.is-active) {
  color: var(--status-completed-fg, #0d5e35);
  background: color-mix(in srgb, var(--status-completed-bg, #c4e9d3) 45%, var(--surface));
  border-color: color-mix(in srgb, var(--status-completed-fg, #0d5e35) 18%, var(--border));
}
.lead-stage-subtab.is-past:not(.is-active):hover {
  color: var(--status-completed-fg, #0d5e35);
  background: color-mix(in srgb, var(--status-completed-bg, #c4e9d3) 65%, var(--surface));
  border-color: color-mix(in srgb, var(--status-completed-fg, #0d5e35) 30%, var(--border));
}
/* Current stage - where the person actually sits today. Inset green ring
   + soft tint, persists regardless of which tab the user has clicked. The
   bolder weight makes the live stage scannable from the strip. */
.lead-stage-subtab.is-current:not(.is-active) {
  box-shadow: inset 0 0 0 1.5px #16a34a;
  background: rgba(22, 163, 74, 0.05);
  color: var(--text);
  font-weight: 600;
}
.lead-stage-subtab.is-current:not(.is-active):hover {
  background: rgba(22, 163, 74, 0.09);
}
/* When the selected tab also happens to be the current stage, lift the
   ring outside the filled selection so the green "you are here" cue still
   reads on top of the black fill. */
.lead-stage-subtab.is-active.is-current {
  box-shadow: 0 0 0 1.5px #16a34a;
}
/* Nav-only tabs (Delivery, Ongoing Management): clicking these doesn't change
   the Stage Status panel - it navigates away to that stage's pipeline view.
   Visually we keep them in the strip for continuity but signal the difference
   with a subtle outward arrow glyph and a lighter dashed border. */
.lead-stage-subtab.is-nav-only {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border-style: dashed;
  color: var(--text-muted);
}
.lead-stage-subtab.is-nav-only:hover {
  background: var(--surface-2);
  color: var(--text);
  border-style: solid;
}
.lead-stage-subtab-nav-arrow {
  opacity: 0.65;
  flex-shrink: 0;
}
.lead-stage-subtab.is-nav-only:hover .lead-stage-subtab-nav-arrow {
  opacity: 1;
}

/* Locked / no-activity state for stages the lead hasn't reached yet. Sits
   inside the .lead-stage-subtab-panel so the sub-tab strip stays visible. */
.lead-stage-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 28px 16px;
  border: 1px dashed var(--border);
  border-radius: 12px;
  background: linear-gradient(135deg, var(--surface) 0%, var(--surface-2) 100%);
  text-align: center;
}
.lead-stage-empty-icon {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text-muted);
}
.lead-stage-empty-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-soft);
  letter-spacing: -0.005em;
}
.lead-stage-empty-body {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.45;
  max-width: 260px;
}

.lead-dispose-footer {
  position: sticky;
  bottom: 0;
  z-index: 2;
  display: flex;
  gap: 8px;
  padding: 12px 20px;
  margin: 16px -20px 0;
  /* Frosted glass instead of a solid bar: list rows scrolling underneath blur
     out (still faintly visible, never readable) rather than showing through
     sharp. The -webkit- prefix keeps Safari happy. */
  background: rgba(255, 255, 255, 0.55);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  backdrop-filter: blur(16px) saturate(180%);
  border-top: 1px solid var(--border);
  box-shadow: 0 -8px 18px -10px rgba(15, 18, 32, 0.14);
}
/* The scroll container (.crm-rail-body) has 32px of bottom padding, which makes
   a `sticky; bottom:0` bar pin ~32px ABOVE the true bottom - leaving a strip
   below the buttons where the next row bled through. This apron extends the same
   frosted glass down across that strip so nothing readable peeks under the bar.
   Buttons stay exactly where they are. */
.lead-dispose-footer::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  height: 34px;
  background: rgba(255, 255, 255, 0.55);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  backdrop-filter: blur(16px) saturate(180%);
}
.lead-dispose-footer .lead-dispose {
  flex: 1 1 0;
}
.lead-dispose {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease, transform 80ms ease;
}
.lead-dispose:active { transform: translateY(1px); }

/* Primary (Sold): solid black, white text - matches the +New lead CTA. */
.lead-dispose-yes {
  background: var(--text, #1a1a1a);
  border-color: var(--text, #1a1a1a);
  color: #fff;
  flex-grow: 1.4;       /* visually weight the positive action a hair larger */
}
.lead-dispose-yes:hover {
  background: #000;
  border-color: #000;
}
.lead-dispose-yes svg { stroke: #fff; }

/* Secondary (Not sold): ghost - subtle border, muted text, only hints
   destructive on hover (light red border + text) so it never competes
   visually with the primary CTA. */
.lead-dispose-no {
  background: transparent;
  border-color: var(--border, rgba(0,0,0,0.12));
  color: var(--text-muted, #6b6b6b);
}
.lead-dispose-no:hover {
  background: rgba(180, 40, 40, 0.04);
  border-color: rgba(180, 40, 40, 0.45);
  color: #b53737;
}
.lead-dispose-no svg { stroke: currentColor; opacity: 0.85; }
/* Auto-promote variant - the system handled (or is about to handle) the
   promotion because the discovery call was booked by the bot. Blue tones
   set it apart from the green manual-action variant; the bot glyph next to
   the chevron makes the source of the action legible at a glance. */
.lead-dispose-auto {
  background: var(--accent-blue-soft, #e0eaff);
  border-color: rgba(37, 99, 235, 0.35);
  color: var(--accent-blue, #2563eb);
}
.lead-dispose-auto:hover {
  background: #d3deff;
  border-color: var(--accent-blue, #2563eb);
}
.lead-dispose-bot {
  opacity: 0.85;
  flex-shrink: 0;
}
.lead-dispose-chevron {
  flex-shrink: 0;
  transition: transform 140ms ease;
}
.lead-dispose:hover .lead-dispose-chevron {
  transform: translateX(2px);
}

.rail-section-label {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.rail-kv {
  display: grid;
  grid-template-columns: 104px 1fr;
  gap: 6px 12px;
  font-size: 12.5px;
}
.rail-kv dt { color: var(--text-muted); }
.rail-kv dd { color: var(--text); margin: 0; word-break: break-word; }
.rail-kv dd a { color: var(--accent-blue); }

.rail-hero {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 22px;
}
.rail-hero .client-avatar {
  width: 44px; height: 44px;
  font-size: 14px;
}
.rail-hero-text { display: flex; flex-direction: column; min-width: 0; }
.rail-hero-name { font-size: 15px; font-weight: 600; color: var(--text); }
.rail-hero-sub { font-size: 12px; color: var(--text-muted); }

.rail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 20px;
}
.rail-actions .btn-primary {
  flex: 1 1 100%;
  justify-content: center;
}
.rail-actions .btn-ghost {
  flex: 1 1 calc(50% - 3px);
  min-width: 0;
  justify-content: center;
  font-size: 12px;
  padding: 7px 10px;
  white-space: nowrap;
}

/* Equal-width 3-button action row (Edit / New / Delete) inside the client rail */
.rail-actions-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 6px;
  margin-bottom: 18px;
}
.rail-action {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: -0.003em;
  color: var(--text-soft);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 8px 10px;
  min-height: 60px;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease, transform 100ms ease;
  cursor: pointer;
  text-align: center;
}
.rail-action:hover {
  background: var(--surface-2);
  border-color: var(--border-strong);
  color: var(--text);
}
.rail-action svg { color: var(--text-muted); transition: color 120ms ease; }
.rail-action:hover svg { color: var(--text); }
.rail-action:active { transform: translateY(0.5px); }

.rail-action.rail-action-primary {
  background: var(--text);
  color: var(--surface);
  border-color: var(--text);
}
.rail-action.rail-action-primary svg { color: var(--surface); }
.rail-action.rail-action-primary:hover {
  background: #2a2620;
  border-color: #2a2620;
  color: var(--surface);
}
.rail-action.rail-action-primary:hover svg { color: var(--surface); }

.rail-action.rail-action-danger:hover {
  background: var(--status-voided-bg);
  border-color: var(--status-voided-bg);
  color: var(--status-voided-fg);
}
.rail-action.rail-action-danger:hover svg { color: var(--status-voided-fg); }

/* Inline (single-row) variant - used in empty states */
.rail-action.rail-action-primary[style*="margin-top"] {
  flex-direction: row;
  min-height: 0;
  padding: 7px 12px;
}

/* Tabs in the rail (reuse detail-tabs aesthetic with rail-friendly spacing) */
.rail-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin: 0 -20px 18px;
  padding: 4px 16px 0;
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 2;
}
.rail-tab {
  padding: 10px 12px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-muted);
  position: relative;
  transition: color 100ms ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.rail-tab:hover { color: var(--text-soft); }
.rail-tab.active { color: var(--text); font-weight: 600; }
.rail-tab.active::after {
  content: "";
  position: absolute;
  left: 8px; right: 8px; bottom: -1px;
  height: 2px;
  background: var(--text);
  border-radius: 2px 2px 0 0;
}
.rail-tab .tab-count {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-faint);
  font-weight: 500;
  padding: 1px 5px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 4px;
}
.rail-tab.active .tab-count {
  color: var(--text-soft);
  background: var(--surface);
}
.rail-tab-panel { display: flex; flex-direction: column; }

/* At-a-glance progress inside Overview tab */
.rail-progress-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin-bottom: 4px;
}
.rail-progress-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
}
.rail-progress-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}
.rail-progress-head span {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.rail-progress-head strong {
  font-size: 18px;
  line-height: 1;
  color: var(--text);
  letter-spacing: -0.015em;
  font-variant-numeric: tabular-nums;
}
.rail-progress-track {
  height: 7px;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill, 999px);
}
.rail-progress-track span {
  display: block;
  height: 100%;
  min-width: 0;
  background: linear-gradient(90deg, var(--accent-green, #5fb36a), var(--accent-blue, #4f8cff));
  border-radius: inherit;
}

.rail-notes {
  font-size: 12.5px;
  color: var(--text-soft);
  line-height: 1.6;
  white-space: pre-wrap;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
}
.rail-avatar-story,
.client-avatar-story-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--avatar-tone, var(--text-faint));
  border-radius: var(--radius);
  padding: 12px;
}
.client-avatar-story-card { background: var(--surface); }
.avatar-tone-amber { --avatar-tone: #D97706; }
.avatar-tone-teal { --avatar-tone: #0D9488; }
.avatar-tone-purple { --avatar-tone: #8B5CF6; }
.avatar-tone-blue { --avatar-tone: #1F6FEB; }
.avatar-tone-green { --avatar-tone: #16A34A; }
.avatar-tone-neutral { --avatar-tone: var(--text-faint); }
.avatar-story-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.avatar-story-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.avatar-story-type {
  margin-top: 2px;
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0;
}
.avatar-story-chip {
  max-width: 46%;
  padding: 4px 7px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text-muted);
  font-size: 11px;
  line-height: 1.35;
  text-align: right;
}
.client-avatar-story-card .avatar-story-chip { background: var(--surface-2); }
.avatar-story-type-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.avatar-story-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  min-width: 28px;
  height: 24px;
  padding: 0 7px;
  border-radius: 7px;
  background: var(--avatar-tone, var(--text-faint));
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.02em;
}
.avatar-story-body {
  color: var(--text-soft);
  font-size: 12.5px;
  line-height: 1.6;
  white-space: pre-wrap;
}
.avatar-story-body.is-empty {
  color: var(--text-faint);
  font-style: italic;
}
.avatar-story-category {
  margin-top: 3px;
  color: var(--text-muted);
  font-size: 11px;
}
.avatar-preset-picker {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}
.avatar-type-only .avatar-preset-picker {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}
.avatar-type-only {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.avatar-preset-picker span {
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.avatar-preset-picker select {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  min-height: 34px;
  padding: 0 32px 0 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface) url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>") right 10px center / 12px no-repeat;
  color: var(--text);
  font: inherit;
  font-size: 12.5px;
  cursor: pointer;
}
.client-avatar-story-card .avatar-preset-picker select {
  background-color: var(--surface-2);
}
.avatar-selected-brief {
  position: relative;
  padding: 12px 14px 12px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.55);
}
.avatar-selected-head {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding-right: 130px;
}
.avatar-selected-mark {
  flex-shrink: 0;
  width: 25px;
  height: 25px;
  border-radius: 7px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: color-mix(in srgb, var(--avatar-tone) 11%, var(--surface));
  color: var(--avatar-tone);
  font-size: 9.5px;
  font-weight: 800;
  line-height: 1;
  border: 1px solid color-mix(in srgb, var(--avatar-tone) 24%, var(--border));
}
.avatar-selected-title {
  color: var(--text);
  font-size: 13.5px;
  font-weight: 750;
  line-height: 1.22;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.avatar-selected-brief p {
  margin: 8px 0 0;
  color: var(--text-soft);
  font-size: 12px;
  line-height: 1.45;
}
.avatar-selected-open {
  position: absolute;
  top: 10px;
  right: 10px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px 4px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  font: inherit;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
  white-space: nowrap;
}
.avatar-selected-open:hover {
  background: var(--surface-2);
  color: var(--text);
  border-color: color-mix(in srgb, var(--text) 25%, var(--border));
}
.avatar-selected-open svg {
  flex-shrink: 0;
  opacity: 0.85;
}
.avatar-selected-brief-modal {
  margin: 0 0 2px;
  background: var(--surface-2);
}

.rail-tab-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 16px;
  text-align: center;
  gap: 4px;
}
.rail-tab-empty-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
}
.rail-tab-empty-sub {
  font-size: 12px;
  color: var(--text-muted);
  max-width: 280px;
  line-height: 1.5;
}

.rail-list {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.contract-rail-list {
  gap: 10px;
  border: 0;
  border-radius: 0;
  overflow: visible;
}
.rail-contract-card {
  background: var(--surface);
  border-bottom: 1px solid var(--hairline);
}
.contract-rail-list .rail-contract-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}
.rail-contract-card:last-child { border-bottom: none; }
.rail-contract-card .rail-list-item { border-bottom: none; }
.rail-contract-head {
  align-items: flex-start;
}
.rail-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 12px;
  border-bottom: 1px solid var(--hairline);
  font-size: 12.5px;
  cursor: pointer;
  transition: background 100ms ease;
}
.rail-list-item:last-child { border-bottom: none; }
.rail-list-item:hover { background: var(--surface-2); }
.rail-list-item .rail-list-title { color: var(--text); font-weight: 500; }
.rail-list-item .rail-list-sub { color: var(--text-muted); font-size: 11.5px; }

.rail-empty {
  padding: 20px 14px;
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
  background: var(--surface-2);
  border-radius: var(--radius);
}

/* ---- Audit timeline ---- */
.timeline {
  position: relative;
  padding-left: 18px;
}
.timeline::before {
  content: '';
  position: absolute;
  left: 5px;
  top: 6px;
  bottom: 6px;
  width: 1px;
  background: var(--border);
}
.timeline-item {
  position: relative;
  padding: 4px 0 12px;
}
.timeline-item::before {
  content: '';
  position: absolute;
  left: -16px;
  top: 8px;
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--text-muted);
}
.timeline-item.event-signed::before,
.timeline-item.event-countersigned::before,
.timeline-item.event-completed::before { border-color: var(--ok); }
.timeline-item.event-sent::before { border-color: var(--accent-blue); }
.timeline-item.event-viewed::before { border-color: var(--warn); }
.timeline-item.event-voided::before { border-color: var(--danger); }
.timeline-title {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
}
.timeline-meta {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 1px;
}

/* Variable highlighter token (used in preview rendering) */
.var-token {
  font-family: var(--font-mono);
  font-size: 0.92em;
  background: var(--accent-blue-soft);
  color: var(--accent-blue);
  padding: 1px 5px;
  border-radius: 4px;
}

@media (max-width: 560px) {
  .crm-search { min-width: 0; flex: 1; }
  .crm-toolbar { gap: 8px; }
  .crm-meta-count { display: none; }
  .modal { width: calc(100vw - 16px); max-height: calc(100vh - 16px); }
  .wizard-steps { display: none; }
}

/* ============================================================
   CONTRACT ROW ACTIONS + AUDIT LOG + CONTRACT VIEW
   ============================================================ */

/* Override the row grid so the last column fits Log + View buttons */
.contracts-row {
  grid-template-columns: 120px minmax(220px, 2fr) minmax(160px, 1.2fr) 120px 160px;
}
@media (max-width: 980px) {
  .contracts-row { grid-template-columns: 110px minmax(180px, 2fr) minmax(140px, 1.2fr) 120px 160px; }
}
@media (max-width: 720px) {
  .contracts-row { grid-template-columns: 100px minmax(150px, 2fr) 110px 140px; }
  .contracts-row .col-client { display: none; }
}
.contracts-row .col-date {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.row-actions {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  justify-content: flex-end;
}
.row-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: -0.003em;
  color: var(--text-soft);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 5px 9px 5px 8px;
  transition: background 100ms ease, border-color 100ms ease, color 100ms ease, transform 100ms ease;
  white-space: nowrap;
}
.row-action-btn:hover {
  background: var(--text);
  color: var(--surface);
  border-color: var(--text);
}
.row-action-btn:hover svg { color: var(--surface); }
.row-action-btn svg { color: var(--text-muted); transition: color 100ms ease; }
.row-action-btn:active { transform: translateY(0.5px); }

/* Modal head with eyebrow + subtitle (richer than default modal-head) */
.modal-head-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}
.modal-eyebrow {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.modal-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.modal-head-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Audit log modal */
.audit-body {
  padding: 0;
  display: flex;
  flex-direction: column;
}
.audit-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}
.audit-summary-cell {
  padding: 12px 16px;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.audit-summary-cell:last-child { border-right: none; }
.audit-summary-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.audit-summary-value {
  font-size: 12.5px;
  color: var(--text);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.audit-summary-value.is-mono {
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: 0.005em;
}

.audit-log {
  padding: 4px 0;
  overflow: auto;
  max-height: 56vh;
}
.audit-entry {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--hairline);
}
.audit-entry:last-child { border-bottom: none; }
.audit-icon {
  width: 26px; height: 26px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 13px;
  margin-top: 1px;
}
.audit-icon.event-created   { background: var(--status-draft-bg);     color: var(--status-draft-fg);     border-color: transparent; }
.audit-icon.event-sent      { background: var(--status-sent-bg);      color: var(--status-sent-fg);      border-color: transparent; }
.audit-icon.event-viewed    { background: var(--status-viewed-bg);    color: var(--status-viewed-fg);    border-color: transparent; }
.audit-icon.event-signed,
.audit-icon.event-countersigned,
.audit-icon.event-completed { background: var(--status-completed-bg); color: var(--status-completed-fg); border-color: transparent; }
.audit-icon.event-voided    { background: var(--status-voided-bg);    color: var(--status-voided-fg);    border-color: transparent; }

.audit-content {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}
.audit-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}
.audit-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.005em;
}
.audit-time {
  font-size: 11.5px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  white-space: nowrap;
  flex-shrink: 0;
}
.audit-actor {
  font-size: 12px;
  color: var(--text-soft);
}
.audit-actor .actor-name { font-weight: 600; color: var(--text); }
.audit-actor .actor-email { color: var(--accent-blue); }
.audit-detail {
  font-size: 12px;
  color: var(--text-soft);
  line-height: 1.55;
}
.audit-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  font-size: 11.5px;
  color: var(--text-muted);
  padding-top: 4px;
  border-top: 1px dashed var(--hairline);
  margin-top: 2px;
}
.audit-meta-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.audit-meta-item .meta-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-faint);
}
.audit-meta-item .meta-value {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-soft);
  letter-spacing: 0.005em;
}
.audit-meta-item .meta-value.is-long {
  font-family: var(--font-sans);
  max-width: 380px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.audit-fingerprint {
  flex: 1;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-faint);
  letter-spacing: 0.02em;
  align-self: center;
}

/* Contract view modal */
.contract-view-body {
  padding: 0;
  background: var(--surface-2);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.contract-view-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  flex-shrink: 0;
}
.contract-view-meta-left {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--text-muted);
}
.contract-view-meta-left b { color: var(--text); font-weight: 600; }
.contract-view-pages {
  flex: 1;
  overflow: auto;
  max-height: 60vh;
  padding: 6px 0 24px;
}
.contract-view-doc {
  background: var(--surface);
  margin: 18px auto;
  max-width: 720px;
  width: calc(100% - 36px);
  padding: 48px 56px;
  border-radius: var(--radius);
  box-shadow: 0 0 0 1px rgba(20,18,14,0.05), 0 8px 32px -12px rgba(20,18,14,0.18);
  font-size: 13px;
  line-height: 1.7;
  color: var(--text);
  white-space: pre-wrap;
  font-family: var(--font-sans);
  letter-spacing: -0.005em;
}

/* "Audit trail" page appended at the end of the contract preview - styled to
   feel like a separate PDF page tucked behind the signed document. */
.contract-audit-page {
  white-space: normal;
  padding: 40px 48px 36px;
}
.audit-page-head {
  border-bottom: 1px solid var(--hairline, var(--border));
  padding-bottom: 14px;
  margin-bottom: 18px;
}
.audit-page-eyebrow {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  font-weight: 600;
}
.audit-page-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  margin: 4px 0 4px;
  letter-spacing: -0.01em;
}
.audit-page-sub {
  font-size: 11.5px;
  color: var(--text-muted);
}
.audit-page-meta {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px 24px;
  font-size: 12px;
  margin: 0 0 22px;
}
.audit-page-meta > div { display: grid; grid-template-columns: 80px 1fr; gap: 8px; }
.audit-page-meta dt { color: var(--text-muted); font-size: 11px; padding-top: 1px; }
.audit-page-meta dd { color: var(--text); margin: 0; }
.audit-page-timeline {
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--hairline, var(--border));
}
.audit-page-entry {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--hairline, var(--border));
}
.audit-page-entry-icon {
  width: 24px; height: 24px;
  border-radius: 50%;
  display: grid; place-items: center;
  background: var(--surface-2);
  color: var(--text-muted);
}
.audit-page-entry-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 12px;
}
.audit-page-entry-event {
  font-size: 12.5px; font-weight: 600; color: var(--text);
}
.audit-page-entry-time {
  font-size: 11px; color: var(--text-muted); font-variant-numeric: tabular-nums;
}
.audit-page-entry-actor {
  font-size: 11.5px; color: var(--text-muted); margin-top: 2px;
}
.audit-page-entry-detail {
  font-size: 11.5px; color: var(--text-soft); margin-top: 3px;
}
.audit-page-entry-meta {
  display: flex; flex-wrap: wrap; gap: 12px;
  font-size: 11px; color: var(--text-muted); margin-top: 5px;
}
.audit-page-entry-meta b { color: var(--text); font-weight: 500; }
.audit-page-foot {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--hairline, var(--border));
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.6;
}
.is-mono { font-family: var(--font-mono); font-size: 0.92em; }
.contract-view-doc .var-token {
  background: var(--accent-blue-soft);
  color: var(--accent-blue);
  font-family: var(--font-mono);
  font-size: 0.92em;
  padding: 1px 6px;
  border-radius: 4px;
  font-weight: 500;
}
@media (max-width: 560px) {
  .contract-view-doc { padding: 28px 24px; margin: 12px auto; }
  .audit-entry { padding: 12px 14px; }
  .audit-meta-item .meta-value.is-long { max-width: 180px; }
}

/* ============================================================
   COPY-TO-CLIPBOARD - inline field + button + toast
   ============================================================ */
.copy-field {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  max-width: 100%;
}
.copy-field-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.copy-field-empty { color: var(--text-faint); }
.copy-btn {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border-radius: 4px;
  color: var(--text-faint);
  flex-shrink: 0;
  opacity: 0;
  transition: opacity 100ms ease, background 100ms ease, color 100ms ease;
}
.copy-btn svg { width: 11px; height: 11px; }
.copy-btn:hover { background: var(--surface-2); color: var(--text); }
.crm-row:hover .copy-btn,
.client-card-kv .copy-btn,           /* always visible inside the detail card */
.rail-kv .copy-btn,
.contact-card:hover .copy-btn,
.copy-field:focus-within .copy-btn,
.copy-btn:focus { opacity: 1; }
/* Pipeline / Sales board cards are NOT hover-reveal rows - their phone + email
   copy buttons must always be visible (user-flagged). */
.pw-board-card-contact .copy-btn { opacity: 1; }
/* Org-chart rail email row: copy button pinned far-right and always visible */
.detail-row .value.copy-field { width: 100%; }
.detail-row .copy-btn { opacity: 1; margin-left: auto; }
.copy-btn:focus-visible { outline: 2px solid var(--accent-blue); outline-offset: 1px; }
/* Skip the copy button entirely for empty / dash fields */
.copy-field-empty + .copy-btn,
.copy-field:has(.copy-field-empty) .copy-btn { display: none; }

.copy-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(8px);
  background: var(--text);
  color: var(--surface);
  font-size: 12.5px;
  font-weight: 500;
  padding: 8px 14px;
  border-radius: 999px;
  box-shadow: 0 6px 24px -8px rgba(0,0,0,0.35);
  pointer-events: none;
  opacity: 0;
  transition: opacity 160ms ease, transform 160ms ease;
  z-index: 9999;
}
.copy-toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ============================================================
   CLIENT DETAIL PAGE
   ============================================================ */
.client-detail-header { gap: 10px; }
.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-muted);
  transition: background 100ms ease, color 100ms ease;
}
.back-btn:hover { background: var(--surface-2); color: var(--text); }
.page-header-divider {
  width: 1px;
  height: 18px;
  background: var(--border);
  margin: 0 4px;
}

.client-tabs {
  display: flex;
  gap: 4px;
  padding: 0 18px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.client-tab {
  position: relative;
  padding: 12px 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: color 100ms ease;
  background: transparent;
}
.client-tab:hover { color: var(--text-soft); }
.client-tab.active { color: var(--text); font-weight: 600; }
.client-tab.active::after {
  content: "";
  position: absolute;
  left: 8px; right: 8px; bottom: -1px;
  height: 2px;
  background: var(--text);
  border-radius: 2px 2px 0 0;
}
.client-tab .tab-count {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-faint);
  background: var(--surface-2);
  padding: 1px 6px;
  border-radius: 999px;
  letter-spacing: 0.02em;
}
.client-tab.active .tab-count { color: var(--text-soft); background: var(--surface-3); }

.body.client-detail-body {
  flex: 1;
  min-height: 0;
  padding: 24px;
  overflow-y: auto;
  background: var(--surface);
}

.client-detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
  max-width: 1100px;
}

.client-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow-card);
}
.client-card-wide { grid-column: 1 / -1; }
.client-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.client-card-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.client-card-kv {
  display: grid;
  grid-template-columns: 100px 1fr;
  row-gap: 9px;
  column-gap: 12px;
  margin: 0;
  font-size: 13px;
}
.client-card-kv dt {
  color: var(--text-muted);
  font-weight: 500;
}
.client-card-kv dd {
  color: var(--text);
  margin: 0;
  min-width: 0;
}
.client-card-faint { color: var(--text-muted) !important; font-family: var(--font-mono); font-size: 12px; }

.client-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.client-stat {
  background: var(--surface-2);
  border-radius: 8px;
  padding: 10px 12px;
}
.client-stat-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
}
.client-stat-label {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 4px;
}

.overview-link { color: var(--accent-blue); }
.overview-link:hover { text-decoration: underline; }
.overview-meta { color: var(--text-muted); }
.overview-empty { color: var(--text-faint); font-style: italic; }

.client-notes-body, .client-notes-card {
  font-size: 13px;
  color: var(--text-soft);
  line-height: 1.6;
  white-space: pre-wrap;
}
.client-notes-card {
  background: var(--surface-2);
  padding: 16px 18px;
  border-radius: 10px;
  max-width: 720px;
}

/* ---- Contracts tab list ---- */
.client-contracts-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-width: 1100px;
}
.client-contract-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  transition: border-color 100ms ease, background 100ms ease;
}
.client-contract-card:hover {
  border-color: var(--border-strong);
}
.client-contract-row {
  display: grid;
  grid-template-columns: minmax(220px, 1.6fr) minmax(280px, 1.6fr) auto;
  align-items: center;
  gap: 18px;
  padding: 14px 16px;
  cursor: pointer;
}
.client-contract-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
}
.client-contract-package {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 4px;
}
.client-contract-dates {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  font-size: 11.5px;
}
.client-contract-dates > div {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.client-contract-status {
  display: flex;
  justify-content: flex-end;
}
.contract-view-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 58px;
  height: 30px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-size: 12px;
  font-weight: 650;
  cursor: pointer;
  transition: background 100ms ease, border-color 100ms ease, color 100ms ease;
}
.contract-view-btn:hover {
  background: var(--text);
  border-color: var(--text);
  color: var(--surface);
}
.cc-date-label {
  font-size: 9.5px;
  font-weight: 600;
  color: var(--text-faint);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.cc-date-value {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-soft);
}
.contract-mini-log {
  margin: 0 16px 16px;
  padding: 10px 12px 8px;
  border: 1px solid var(--hairline);
  border-radius: 10px;
  background: var(--surface-2);
}
.rail-contract-card .contract-mini-log {
  margin: 0 12px 12px;
  background: var(--surface-2);
}
.contract-mini-log-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
  color: var(--text-muted);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.contract-mini-log-head span:last-child {
  letter-spacing: 0;
  font-variant-numeric: tabular-nums;
}
.contract-mini-log-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.contract-mini-log-entry {
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 8px;
  padding: 6px 0;
}
.contract-mini-log-dot {
  width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  margin-top: 1px;
}
.contract-mini-log-dot svg {
  width: 10px;
  height: 10px;
}
.contract-mini-log-body { min-width: 0; }
.contract-mini-log-line {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}
.contract-mini-log-line span {
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
}
.contract-mini-log-line time {
  color: var(--text-muted);
  font-size: 11px;
  text-align: right;
  line-height: 1.35;
  font-variant-numeric: tabular-nums;
}
.contract-mini-log-meta,
.contract-mini-log-detail,
.contract-mini-log-empty {
  color: var(--text-muted);
  font-size: 11.5px;
  line-height: 1.45;
}
.contract-mini-log-meta span { color: var(--accent-blue); }
.contract-mini-log-detail {
  margin-top: 2px;
}
.contract-mini-log-empty {
  padding: 6px 0 2px;
}
@media (max-width: 880px) {
  .client-contract-row { grid-template-columns: 1fr; }
  .client-contract-dates { grid-template-columns: repeat(3, 1fr); }
}

/* ---- Payments tab ---- */
.client-payments-summary {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 16px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 12px;
  max-width: 640px;
}
.client-payments-summary-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.client-payments-summary-value {
  font-family: var(--font-mono);
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
}
.client-payments-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 1100px;
}
.client-payment-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.client-payment-amount {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}
.client-payment-sub {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 3px;
}
.client-payment-date {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-muted);
}

/* ---- Generic empty state for a tab panel ---- */
.tab-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 60px 20px;
  gap: 8px;
  color: var(--text-muted);
}
.tab-empty-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}
.tab-empty-sub {
  font-size: 13px;
  color: var(--text-muted);
  max-width: 420px;
  line-height: 1.5;
}
.tab-empty-action, .tab-empty .btn-primary, .tab-empty .btn-ghost {
  margin-top: 12px;
}

/* ============================================================
   REPORTS PAGE
   ============================================================ */

.report-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  padding: 0 18px;
  background: var(--surface);
}
.report-tab {
  padding: 12px 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  position: relative;
  transition: color 100ms ease;
  display: inline-flex;
  align-items: center;
  gap: 7px;
}
.report-tab:hover { color: var(--text-soft); }
.report-tab.active { color: var(--text); font-weight: 600; }
.report-tab.active svg { color: var(--text); }
.report-tab svg { color: var(--text-muted); transition: color 100ms ease; }
.report-tab.active::after {
  content: "";
  position: absolute;
  left: 10px; right: 10px; bottom: -1px;
  height: 2px;
  background: var(--text);
  border-radius: 2px 2px 0 0;
}

.body.report-body {
  flex: 1;
  overflow: auto;
  padding: 20px 22px 40px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  background: var(--bg);
}

/* KPI row */
.report-kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}
@media (max-width: 1100px) { .report-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px)  { .report-kpis { grid-template-columns: 1fr; } }

.report-kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 110px;
  box-shadow: var(--shadow-card);
}
.report-kpi-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.report-kpi-label {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.report-kpi-icon {
  width: 22px; height: 22px;
  border-radius: var(--radius-xs);
  background: var(--surface-2);
  display: grid; place-items: center;
  color: var(--text-muted);
}
.report-kpi-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.report-kpi-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: auto;
  padding-top: 6px;
}
.report-trend {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 11.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  padding: 2px 7px 2px 5px;
  border-radius: var(--radius-pill);
  letter-spacing: -0.003em;
}
.report-trend.up   { color: var(--status-completed-fg); background: var(--status-completed-bg); }
.report-trend.down { color: var(--status-voided-fg);    background: var(--status-voided-bg); }
.report-trend.flat { color: var(--text-muted);          background: var(--surface-2); }
.report-trend svg { width: 10px; height: 10px; }

.report-spark {
  height: 24px;
  width: 80px;
  display: block;
  color: var(--text-muted);
}
.report-spark.up   { color: var(--status-completed-fg); }
.report-spark.down { color: var(--status-voided-fg); }

/* Two-column main row (chart + side block) */
.report-grid {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
  gap: 12px;
}
@media (max-width: 900px) {
  .report-grid { grid-template-columns: 1fr; }
}

.report-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px 16px;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.report-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.report-card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.005em;
}
.report-card-sub {
  font-size: 11.5px;
  color: var(--text-muted);
}
.report-card-actions {
  display: inline-flex;
  gap: 2px;
}
.report-card-pill {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 3px 8px;
  border-radius: var(--radius-pill);
}

/* Line chart */
.report-chart {
  position: relative;
  width: 100%;
  height: 200px;
}
.report-chart svg { display: block; width: 100%; height: 100%; }
.report-chart .grid-line { stroke: var(--hairline); stroke-width: 1; }
.report-chart .axis-label {
  font-family: var(--font-mono);
  font-size: 9.5px;
  fill: var(--text-faint);
  letter-spacing: 0.02em;
}
.report-chart .line-path {
  fill: none;
  stroke: var(--text);
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.report-chart .line-area {
  fill: var(--text);
  fill-opacity: 0.06;
}
.report-chart .data-dot {
  fill: var(--surface);
  stroke: var(--text);
  stroke-width: 1.6;
}

/* Horizontal bar list */
.report-bars {
  display: flex;
  flex-direction: column;
  gap: 9px;
}
.report-bar {
  display: grid;
  grid-template-columns: 140px 1fr 80px;
  align-items: center;
  gap: 10px;
}
.report-bar-label {
  font-size: 12px;
  color: var(--text-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.report-bar-track {
  position: relative;
  height: 8px;
  background: var(--surface-2);
  border-radius: var(--radius-pill);
  overflow: hidden;
}
.report-bar-fill {
  position: absolute;
  inset: 0 auto 0 0;
  background: var(--text);
  border-radius: var(--radius-pill);
}
.report-bar-fill.c-blue   { background: var(--accent-blue); }
.report-bar-fill.c-green  { background: var(--status-completed-fg); }
.report-bar-fill.c-amber  { background: var(--warn); }
.report-bar-fill.c-pink   { background: var(--dept-creative-fg); }
.report-bar-fill.c-purple { background: var(--dept-executive-fg); }
.report-bar-value {
  font-size: 11.5px;
  font-family: var(--font-mono);
  color: var(--text-soft);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* Mini bar chart (vertical bars, per-day) */
.report-mini-bars {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 120px;
  padding: 4px 0 18px;
  position: relative;
}
.report-mini-bar {
  flex: 1;
  background: var(--text);
  border-radius: 3px 3px 0 0;
  min-height: 2px;
  position: relative;
  transition: opacity 100ms ease;
  cursor: default;
}
.report-mini-bar.weekend { background: var(--surface-3); }
.report-mini-bar.today   { background: var(--accent-blue); }
.report-mini-bar:hover   { opacity: 0.85; }
.report-mini-bar::after {
  content: attr(data-label);
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  margin-top: 4px;
  font-size: 9.5px;
  color: var(--text-faint);
  font-family: var(--font-mono);
}

/* Report table (compact rows) */
.report-table {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
  box-shadow: var(--shadow-card);
}
.report-row {
  display: grid;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--hairline);
  font-size: 12.5px;
  color: var(--text-soft);
}
.report-row:last-child { border-bottom: none; }
.report-row.is-header {
  background: var(--surface-2);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding-top: 9px; padding-bottom: 9px;
}
.report-row.is-header div { display: flex; align-items: center; gap: 4px; }

.row-marketing { grid-template-columns: minmax(150px, 2fr) 100px 100px 80px 80px; }
.row-income    { grid-template-columns: minmax(160px, 2fr) minmax(120px, 1.4fr) 100px 110px; }
.row-tasks     { grid-template-columns: minmax(120px, 1fr) 70px 70px 70px 60px; }
.row-website   { grid-template-columns: minmax(180px, 2fr) 90px 100px 80px; }

@media (max-width: 720px) {
  .row-marketing { grid-template-columns: minmax(140px, 2fr) 90px 80px; }
  .row-marketing .col-clicks, .row-marketing .col-ctr { display: none; }
  .row-income    { grid-template-columns: minmax(140px, 2fr) 100px 90px; }
  .row-income .col-method { display: none; }
  .row-tasks     { grid-template-columns: minmax(120px, 1fr) 70px 60px; }
  .row-tasks .col-inprog, .row-tasks .col-pending { display: none; }
  .row-website   { grid-template-columns: minmax(140px, 2fr) 80px 70px; }
  .row-website .col-avgtime { display: none; }
}

.report-row .col-name {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.report-row .col-name-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.report-row .col-name-primary {
  font-weight: 600;
  color: var(--text);
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.report-row .col-name-sub {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.report-row .col-num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text);
}
.report-row .col-num.is-soft { color: var(--text-muted); }
.report-row .col-amount {
  text-align: right;
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.team-avatar {
  width: 26px; height: 26px;
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.02em;
  flex-shrink: 0;
}
.team-avatar.a-1 { background: var(--dept-executive); color: var(--dept-executive-fg); }
.team-avatar.a-2 { background: var(--dept-operations); color: var(--dept-operations-fg); }
.team-avatar.a-3 { background: var(--dept-finance);    color: var(--dept-finance-fg); }
.team-avatar.a-4 { background: var(--dept-legal);      color: var(--dept-legal-fg); }
.team-avatar.a-5 { background: var(--dept-creative);   color: var(--dept-creative-fg); }
.team-avatar.a-6 { background: var(--dept-growth);     color: var(--dept-growth-fg); }

/* Channel dot */
.channel-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.channel-dot.c-blue   { background: var(--accent-blue); }
.channel-dot.c-green  { background: var(--status-completed-fg); }
.channel-dot.c-amber  { background: var(--warn); }
.channel-dot.c-pink   { background: var(--dept-creative-fg); }
.channel-dot.c-purple { background: var(--dept-executive-fg); }

/* ============================================================
   Tasks view - minimal PM dashboard
   ============================================================ */
.tasks-toolbar {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 10px 20px;
  border-bottom: 1px solid var(--hairline);
}
.tasks-toolbar .crm-search { flex: 0 0 280px; min-width: 200px; }
.tasks-filters {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}
.chip-select {
  padding: 5px 24px 5px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--surface);
  font-family: inherit;
  font-size: 12px;
  color: var(--text-soft);
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%23807c73' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
}
.chip-select:hover { border-color: var(--border-strong); }
.chip-select:focus { outline: none; border-color: var(--text); }

/* Custom pill trigger that replaces native <select> for task filters so the
   opened panel uses our clean styling instead of the OS dropdown. */
.chip-trigger {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px 5px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--surface);
  font-family: inherit;
  font-size: 12px;
  color: var(--text-soft);
  cursor: pointer;
  line-height: 1.2;
  transition: border-color 0.12s, color 0.12s, background 0.12s;
}
.chip-trigger:hover { border-color: var(--border-strong); }
.chip-trigger:focus { outline: none; border-color: var(--text); }
.chip-trigger.is-active { color: var(--text); border-color: var(--border-strong); }
.chip-trigger-text { white-space: nowrap; }
.chip-trigger-chev { color: var(--text-faint, #807c73); flex: 0 0 auto; }
#tasksFilterMine.chip { cursor: pointer; }
#tasksFilterMine.chip.active { background: var(--text); color: var(--surface); border-color: var(--text); }

.tasks-body { padding: 0; }

.tasks-group { border-bottom: 1px solid var(--hairline); }
.tasks-group:last-child { border-bottom: 0; }
.tasks-group-head {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 9px 20px;
  background: var(--surface-2);
  border: 0;
  border-bottom: 1px solid var(--hairline);
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  cursor: pointer;
  text-align: left;
}
.tasks-group-head:hover { background: var(--surface-3); }
.tasks-group-head .chev {
  width: 11px; height: 11px;
  transition: transform 120ms ease;
  color: var(--text-faint);
}
.tasks-group.collapsed .tasks-group-head .chev { transform: rotate(-90deg); }
.tasks-group.collapsed .tasks-list { display: none; }
.tasks-group-label { flex: 1; }
.tasks-group-count {
  color: var(--text-faint);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.tasks-list { display: block; }
.tasks-empty-row {
  padding: 16px 20px;
  font-size: 12px;
  color: var(--text-faint);
  font-style: italic;
}

.task-row {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) auto auto 64px;
  align-items: center;
  gap: 16px;
  padding: 11px 20px;
  min-height: 52px;
  border-bottom: 1px solid var(--hairline);
  cursor: pointer;
  transition: background 80ms ease;
}
.task-row:hover { background: var(--surface-2); }
.task-row:last-child { border-bottom: 0; }

.task-status {
  width: 18px; height: 18px;
  border: 1.6px solid var(--border-strong);
  border-radius: 50%;
  display: grid; place-items: center;
  background: transparent;
  padding: 0;
  cursor: pointer;
  color: var(--surface);
  font-size: 10px;
  line-height: 1;
  transition: border-color 120ms ease, background 120ms ease;
}
.task-status:hover { border-color: var(--text); }
.task-status.inprogress {
  border-color: var(--accent-blue);
  background: conic-gradient(var(--accent-blue) 0 50%, transparent 50% 100%);
}
.task-status.done {
  border-color: var(--status-completed-fg, #1a6b3c);
  background: var(--status-completed-fg, #1a6b3c);
  color: #fff;
}

.task-title-cell { min-width: 0; }
.task-title {
  font-size: 13px;
  color: var(--text);
  font-weight: 500;
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.task-sub {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.task-row.is-done .task-title {
  color: var(--text-muted);
  text-decoration: line-through;
  text-decoration-color: var(--text-faint);
}
.task-row.is-done .task-sub { color: var(--text-faint); }

.task-phase-chip {
  font-size: 10.5px;
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  background: var(--surface-3);
  color: var(--text-soft);
  white-space: nowrap;
  font-weight: 500;
  letter-spacing: 0.01em;
}
.task-project-row {
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.task-project-chip {
  display: inline-flex;
  align-items: center;
  font-size: 10px;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  background: var(--text);
  color: var(--surface);
  white-space: nowrap;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.task-assignees {
  display: flex;
  align-items: center;
  padding-left: 6px;
}
.owner-chip.owner-chip-more {
  background: var(--surface-3);
  color: var(--text-muted);
  font-size: 10px;
}

.task-due {
  font-size: 11.5px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}
.task-due.overdue { color: var(--err, #c43e3e); font-weight: 500; }
.task-due-empty { color: var(--text-faint); }

/* ---- Critical ("insanely red") tasks --------------------------------------
   Top-priority ops that block everything downstream. Loud on purpose: red
   left bar, red wash, a pulsing CRITICAL badge. Set priority:'critical' on
   the task to opt in. */
.task-row.is-critical {
  background: linear-gradient(90deg, rgba(201,42,42,0.12), rgba(201,42,42,0.035) 55%, transparent);
  box-shadow: inset 4px 0 0 0 var(--danger);
}
.task-row.is-critical:hover {
  background: linear-gradient(90deg, rgba(201,42,42,0.18), rgba(201,42,42,0.06) 55%, transparent);
}
.task-row.is-critical .task-title { color: #8f1d1d; font-weight: 650; }
.task-row.is-critical .task-status { border-color: var(--danger); }
.task-row.is-critical.is-done { box-shadow: inset 4px 0 0 0 rgba(201,42,42,0.35); }
.task-row.is-critical.is-done .task-title { color: var(--text-muted); }

.task-crit-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 10px;
  padding: 2px 9px;
  border-radius: var(--radius-pill);
  background: var(--danger);
  color: #fff;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
  box-shadow: 0 0 0 0 rgba(201,42,42,0.55);
  animation: critPulse 1.9s ease-out infinite;
}
.task-crit-badge::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  background: #fff;
}
@keyframes critPulse {
  0%   { box-shadow: 0 0 0 0 rgba(201,42,42,0.55); }
  70%  { box-shadow: 0 0 0 7px rgba(201,42,42,0); }
  100% { box-shadow: 0 0 0 0 rgba(201,42,42,0); }
}
@media (prefers-reduced-motion: reduce) {
  .task-crit-badge { animation: none; }
}

/* Rail variant - status circle in hero */
.rail-task-status {
  width: 36px; height: 36px;
  font-size: 18px;
  border-width: 2px;
  cursor: default;
  flex-shrink: 0;
}

/* Assignee picker (in modal) */
.assignee-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 4px 0;
  max-height: 220px;
  overflow-y: auto;
}
.assignee-option {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 10px 4px 4px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  font-family: inherit;
  font-size: 12px;
  color: var(--text-soft);
  cursor: pointer;
  transition: background 80ms ease, border-color 80ms ease;
}
.assignee-option:hover { background: var(--surface-3); border-color: var(--border-strong); }
.assignee-option .owner-chip { margin-left: 0; cursor: pointer; }
.assignee-option.selected {
  background: var(--text);
  border-color: var(--text);
  color: var(--surface);
}
.assignee-option.selected .owner-chip {
  outline: 1.5px solid var(--surface);
  outline-offset: 1px;
}
.assignee-option-name { white-space: nowrap; }

/* Tasks empty state */
#tasksEmpty { padding: 64px 24px; }

/* ============================================================
   ICP - Ideal Customer Profiles
   ============================================================ */
.body.icp-body {
  flex: 1;
  min-height: 0;
  width: 100%;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
/* Ambient brand-colour gradient behind the frosted avatar cards. Pinned to the
   pane (does not scroll) so the glass blur always has something rich to sample.
   The blobs use the six avatar accent colours at low alpha over the warm --bg. */
.body.icp-body::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(60% 75% at 14% 8%,  rgba(31,111,235,0.34), transparent 60%),
    radial-gradient(52% 68% at 88% 4%,  rgba(217,119,6,0.30),  transparent 58%),
    radial-gradient(56% 72% at 84% 94%, rgba(139,92,246,0.32), transparent 60%),
    radial-gradient(58% 76% at 6% 96%,  rgba(13,148,136,0.30), transparent 60%),
    radial-gradient(50% 62% at 48% 50%, rgba(225,29,72,0.16),  transparent 66%),
    radial-gradient(46% 58% at 64% 30%, rgba(13,148,136,0.14), transparent 64%),
    var(--bg);
}
.icp-scroll {
  position: relative;
  z-index: 1;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 24px 28px 44px;
}
.icp-intro {
  color: var(--text-soft);
  font-size: 13.5px;
  line-height: 1.55;
  max-width: 720px;
  margin: 0 0 24px 0;
}
.icp-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  align-content: start;
}
/* Frosted-glass avatar card - translucent over the gradient with a strong
   backdrop blur, a diagonal sheen, a bright glass edge and a grain overlay. */
.icp-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 20px 20px 17px;
  border-radius: 22px;
  cursor: pointer;
  text-align: left;
  overflow: hidden;
  /* Liquid-glass fill: a bright specular wash at the top-left, near-clear through
     the body so the colour gradient lenses through the pane like real glass. */
  background:
    linear-gradient(140deg, rgba(255,255,255,0.50) 0%, rgba(255,255,255,0.16) 40%, rgba(255,255,255,0.10) 64%, rgba(255,255,255,0.30) 100%);
  border: 1px solid rgba(255,255,255,0.55);
  box-shadow:
    0 18px 46px -22px rgba(20,18,14,0.42),      /* soft floating ambient */
    0 2px 6px -3px rgba(20,18,14,0.14),         /* tight contact shadow */
    inset 0 1px 0 0 rgba(255,255,255,0.85),     /* top specular edge */
    inset 0 0 0 1px rgba(255,255,255,0.14),     /* inner glass ring */
    inset 0 -22px 36px -28px rgba(255,255,255,0.28); /* faint base glow */
  -webkit-backdrop-filter: blur(24px) saturate(185%) brightness(1.04);
  backdrop-filter: blur(24px) saturate(185%) brightness(1.04);
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}
/* Specular sheen: a soft lens highlight blooming from the top-left corner plus a
   thin bright line along the very top edge - the "wet glass" catch-light. */
.icp-tile::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  border-radius: inherit;
  pointer-events: none;
  background:
    radial-gradient(125% 80% at 0% -8%, rgba(255,255,255,0.55) 0%, rgba(255,255,255,0) 46%),
    linear-gradient(180deg, rgba(255,255,255,0.40) 0%, rgba(255,255,255,0) 12%);
}
/* Grain - subtle fractal-noise speckle for that frosted-glass texture. Sits
   above the glass fill but below the card content (content is z-index:1). */
.icp-tile::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  border-radius: inherit;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='150' height='150'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='matrix' values='0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 0.9 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 150px 150px;
  opacity: 0.07;
}
.icp-tile > .icp-tile-head,
.icp-tile > .icp-tile-quote,
.icp-tile > .icp-tile-foot { position: relative; z-index: 1; }
.icp-tile:hover {
  transform: translateY(-3px);
  border-color: rgba(255,255,255,0.78);
  background:
    linear-gradient(140deg, rgba(255,255,255,0.62) 0%, rgba(255,255,255,0.24) 40%, rgba(255,255,255,0.16) 64%, rgba(255,255,255,0.40) 100%);
  box-shadow:
    0 30px 60px -24px rgba(20,18,14,0.50),
    0 3px 8px -3px rgba(20,18,14,0.16),
    inset 0 1px 0 0 rgba(255,255,255,0.95),
    inset 0 0 0 1px rgba(255,255,255,0.20),
    inset 0 -22px 36px -28px rgba(255,255,255,0.36);
}
.icp-tile.active {
  border-color: color-mix(in srgb, var(--icp-bg) 45%, rgba(255,255,255,0.7));
  box-shadow:
    0 0 0 1px color-mix(in srgb, var(--icp-bg) 65%, transparent),
    0 24px 54px -22px color-mix(in srgb, var(--icp-bg) 38%, rgba(20,18,14,0.42)),
    inset 0 1px 0 0 rgba(255,255,255,0.85),
    inset 0 0 0 1px rgba(255,255,255,0.14);
}
.icp-tile-num {
  position: absolute;
  top: 14px;
  right: 16px;
  z-index: 2;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--text-faint);
}
.icp-tile-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-right: 26px; /* clear the 0X number */
}
.icp-tile-avatar {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  border-radius: 13px;
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.01em;
  background: var(--icp-bg, var(--text-soft));
  box-shadow:
    0 6px 16px -6px color-mix(in srgb, var(--icp-bg) 70%, transparent),
    inset 0 0 0 1px rgba(255,255,255,0.22);
}
.icp-tile-id {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}
.icp-tile-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.25;
  letter-spacing: -0.01em;
}
.icp-tile-role {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.2;
}
.icp-tile-quote {
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--text-soft);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.icp-tile-foot {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.icp-tile-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 0;
  flex: 1 1 auto;
}
.icp-tile-tag {
  max-width: 100%;
  font-size: 10.5px;
  font-weight: 500;
  line-height: 1;
  padding: 5px 9px;
  border-radius: 999px;
  background: rgba(255,255,255,0.40);
  border: 1px solid rgba(255,255,255,0.62);
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.icp-rail {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 380px;
  /* Frosted-glass panel - kept fairly opaque so the dense text + info chips stay
     crisp, with a bright glass edge and a deep soft shadow lifting it off. */
  background: linear-gradient(180deg, rgba(255,255,255,0.86) 0%, rgba(255,255,255,0.80) 100%);
  -webkit-backdrop-filter: blur(30px) saturate(160%);
  backdrop-filter: blur(30px) saturate(160%);
  border-left: 1px solid rgba(255,255,255,0.70);
  box-shadow:
    -26px 0 60px -34px rgba(20,18,14,0.30),
    inset 1px 0 0 rgba(255,255,255,0.85);
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 20px 22px;
  overflow-y: auto;
  z-index: 5;
  animation: slideInRight 240ms cubic-bezier(.2,.8,.2,1);
}
.icp-rail[hidden] { display: none; }
.icp-rail-head {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}
.icp-rail-avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: white;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.01em;
  background: var(--icp-bg, var(--text-soft));
  flex-shrink: 0;
}
.icp-rail-head-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.icp-rail-eyebrow {
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-faint);
}
.icp-rail-title {
  font-size: 15.5px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
  line-height: 1.2;
}
.icp-rail-headline {
  font-size: 12px;
  color: var(--text-soft);
  line-height: 1.45;
  margin-top: 2px;
}
.icp-rail-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.icp-rail-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding-top: 4px;
}
.icp-profile-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--hairline);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text-muted);
  font-size: 11px;
}
.icp-profile-meta strong {
  color: var(--text);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.icp-tag {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-muted);
  letter-spacing: 0.01em;
}
.icp-section {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.icp-section-label {
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-faint);
  margin: 0;
}
.icp-section-body {
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--text-soft);
  margin: 0;
}
.icp-section-list {
  margin: 0;
  padding-left: 16px;
  color: var(--text-soft);
  font-size: 12.5px;
  line-height: 1.5;
}
.icp-section-list li + li {
  margin-top: 3px;
}
.icp-rail-foot {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding-top: 10px;
  border-top: 1px solid var(--hairline);
}
.icp-foot-label {
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-faint);
}
.icp-foot-value {
  font-size: 11.5px;
  color: var(--text-soft);
  line-height: 1.4;
}

/* Mobile: full-width rail, tighter spacing, and a lighter blur so a phone GPU
   is not compositing six heavy backdrop filters at once. */
@media (max-width: 900px) {
  .icp-rail { width: 100%; border-left: 0; }
}
@media (max-width: 680px) {
  .icp-scroll { padding: 16px 14px 32px; }
  .icp-intro { font-size: 12.5px; margin: 0 0 16px; }
  .icp-tiles { grid-template-columns: 1fr; gap: 12px; }
  .icp-tile {
    padding: 16px 16px 14px;
    border-radius: 18px;
    -webkit-backdrop-filter: blur(16px) saturate(170%);
    backdrop-filter: blur(16px) saturate(170%);
  }
  .icp-rail {
    padding: 16px 16px 22px;
    -webkit-backdrop-filter: blur(22px) saturate(160%);
    backdrop-filter: blur(22px) saturate(160%);
  }
}

/* Where backdrop-filter is unsupported, fall back to opaque-ish panes so the
   glass content stays readable instead of going fully transparent. */
@supports not ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
  .icp-tile { background: rgba(255,255,255,0.84); }
  .icp-tile:hover { background: rgba(255,255,255,0.92); }
  .icp-rail { background: rgba(252,251,249,0.97); }
}

@media (prefers-reduced-motion: reduce) {
  .icp-tile { transition: none; }
  .icp-tile:hover { transform: none; }
  .icp-rail { animation: none; }
}

/* ============================================================
   TECH STACK - X-Mind style mindmap
   ============================================================ */

/* Floating Fit pill in the bottom-right of the techstack viewport */
/* Tech Stack fit button reuses the Email Flows pill (.em-zoom-toolbar /
   .em-zoom-btn) - see renderTechStack() in app.js. No tech-specific button
   styles needed. */

/* Canvas - panned and scaled via inline transform from app.js */
.tech-zoom-wrap {
  position: absolute;
  top: 0;
  left: 0;
  transform-origin: 0 0;
  will-change: transform;
}

.tech-connectors {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
  z-index: 0;
  overflow: visible;
}
.tech-conn {
  fill: none;
  stroke: var(--border-strong);
  stroke-width: 1.5;
  stroke-linecap: round;
}
.tech-conn-stage   { stroke: var(--text-muted); stroke-width: 1.8; }
.tech-conn-leaf    { stroke: var(--border-strong); stroke-width: 1.4; stroke-dasharray: 0; }
.tech-conn-consume { stroke: var(--accent-blue); stroke-width: 1.2; stroke-dasharray: 4 4; opacity: 0.55; }
.tech-conn-group   { stroke: var(--accent-blue); stroke-width: 2.4; opacity: 0.85; }

.tech-mindmap {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0 96px;
  padding: 28px 24px 48px;
  min-width: max-content;
}

/* Root node */
.tech-root {
  align-self: center;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  background: var(--text);
  color: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: 0 0 0 1px rgba(20,18,14,0.08), 0 14px 32px -16px rgba(20,18,14,0.32);
  white-space: nowrap;
  position: sticky;
  top: 16px;
  z-index: 2;
}
.tech-root-mark {
  width: 36px; height: 36px;
  border-radius: var(--radius);
  background: rgba(255,255,255,0.08);
  display: grid; place-items: center;
  color: var(--surface);
}
.tech-root-text { display: flex; flex-direction: column; gap: 2px; }
.tech-root-title {
  font-size: 13.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  line-height: 1;
}
.tech-root-sub {
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.55);
}

/* Branches column */
.tech-branches {
  display: flex;
  flex-direction: column;
  gap: 28px;
}

/* Group: a supercategory (e.g. Development) that bundles multiple sub-section
   branches under a single owner. Layout is group-node on the left, the stack
   of sub-branches on the right. */
.tech-group {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0 72px;
  align-items: center;
}
.tech-group-node {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  min-width: 240px;
  position: relative;
}
.tech-group-node.c-blue   { border-left: 3px solid var(--accent-blue); padding-left: 14px; }
.tech-group-node.c-green  { border-left: 3px solid var(--status-completed-fg); padding-left: 14px; }
.tech-group-node.c-amber  { border-left: 3px solid var(--warn); padding-left: 14px; }
.tech-group-node.c-pink   { border-left: 3px solid var(--dept-creative-fg); padding-left: 14px; }
.tech-group-node.c-purple { border-left: 3px solid var(--dept-executive-fg); padding-left: 14px; }

.tech-group-head { display: flex; align-items: center; gap: 10px; }
.tech-group-dot {
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--text-muted);
  flex-shrink: 0;
}
.tech-group-node.c-blue   .tech-group-dot { background: var(--accent-blue); }
.tech-group-node.c-green  .tech-group-dot { background: var(--status-completed-fg); }
.tech-group-node.c-amber  .tech-group-dot { background: var(--warn); }
.tech-group-node.c-pink   .tech-group-dot { background: var(--dept-creative-fg); }
.tech-group-node.c-purple .tech-group-dot { background: var(--dept-executive-fg); }
.tech-group-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.tech-group-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.005em;
}
.tech-group-meta {
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.tech-group-owner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
}
.tech-group-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--text-soft);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  letter-spacing: 0.02em;
}
.tech-group-avatar.engineering { background: var(--dept-engineering); color: var(--dept-engineering-fg); }
.tech-group-avatar.executive   { background: var(--dept-executive);   color: var(--dept-executive-fg); }
.tech-group-avatar.operations  { background: var(--dept-operations,  var(--text-soft)); color: #fff; }
.tech-group-avatar.finance     { background: var(--dept-finance,     var(--text-soft)); color: #fff; }
.tech-group-avatar.legal       { background: var(--dept-legal,       var(--text-soft)); color: #fff; }
.tech-group-avatar.creative    { background: var(--dept-creative);    color: var(--dept-creative-fg); }
.tech-group-avatar.growth      { background: var(--dept-growth,      var(--text-soft)); color: #fff; }
.tech-group-owner-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.tech-group-owner-name {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
}
.tech-group-owner-role {
  font-size: 10.5px;
  color: var(--text-muted);
  letter-spacing: 0.01em;
}

.tech-group-branches {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* Each stage row contains a stage node and a list of leaf cards */
.tech-branch {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0 72px;
  align-items: center;
}
/* Tiered branches add a third column for tools that tier-1 leaves consume. */
.tech-branch.tiered {
  grid-template-columns: auto auto auto;
}
.tech-consumes {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: flex-start;
  margin-left: 72px;
}

/* Stage node (pill / button-like) */
.tech-stage-node {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px 11px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  min-width: 200px;
  position: relative;
}
.tech-stage-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--text-muted);
  flex-shrink: 0;
}
.tech-stage-node.c-blue   .tech-stage-dot { background: var(--accent-blue); }
.tech-stage-node.c-blue              { border-left: 3px solid var(--accent-blue); padding-left: 10px; }
.tech-stage-node.c-green  .tech-stage-dot { background: var(--status-completed-fg); }
.tech-stage-node.c-green             { border-left: 3px solid var(--status-completed-fg); padding-left: 10px; }
.tech-stage-node.c-amber  .tech-stage-dot { background: var(--warn); }
.tech-stage-node.c-amber             { border-left: 3px solid var(--warn); padding-left: 10px; }
.tech-stage-node.c-pink   .tech-stage-dot { background: var(--dept-creative-fg); }
.tech-stage-node.c-pink              { border-left: 3px solid var(--dept-creative-fg); padding-left: 10px; }
.tech-stage-node.c-purple .tech-stage-dot { background: var(--dept-executive-fg); }
.tech-stage-node.c-purple            { border-left: 3px solid var(--dept-executive-fg); padding-left: 10px; }
.tech-stage-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.tech-stage-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.005em;
  white-space: nowrap;
}
.tech-stage-meta {
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* Leaf list (tools) */
.tech-leaves {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: flex-start;
}

.tech-leaf {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 14px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  min-width: 320px;
  max-width: 360px;
  text-decoration: none;
  color: inherit;
  transition: border-color 120ms ease, box-shadow 120ms ease, transform 120ms ease;
}
.tech-leaf:hover {
  border-color: var(--text-muted);
  box-shadow: var(--shadow-pop);
  transform: translateY(-1px);
}

.tech-leaf-head {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.tech-leaf-name-block {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.tech-leaf-name {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.005em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tech-leaf-tier {
  font-size: 11.5px;
  color: var(--text-muted);
  line-height: 1.4;
}

.tech-leaf-purpose {
  font-size: 12px;
  color: var(--text-soft);
  line-height: 1.55;
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.tech-leaf-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: -0.003em;
  margin-top: auto;
  align-self: flex-start;
}
.tech-leaf:hover .tech-leaf-link { color: var(--text); }
.tech-leaf:hover .tech-leaf-link svg { color: var(--text); }
.tech-leaf-link svg { transition: color 120ms ease; color: var(--text-faint); }

@media (max-width: 880px) {
  .tech-mindmap { grid-template-columns: 1fr; gap: 28px; padding: 20px; }
  .tech-branch,
  .tech-branch.tiered { grid-template-columns: 1fr; gap: 8px; }
  .tech-consumes { margin-left: 0; padding-left: 16px; border-left: 2px solid var(--border); }
  .tech-group { grid-template-columns: 1fr; gap: 12px; }
  .tech-group-branches { padding-left: 16px; border-left: 2px solid var(--border); }
  .tech-root { position: static; align-self: flex-start; }
  .tech-connectors { display: none; }
  .tech-leaves { padding-left: 16px; border-left: 2px solid var(--border); }
  .tech-leaf { min-width: 0; max-width: 100%; width: 100%; }
}

/* ============================================================
   EMAILS - zoomable email design library + operational map
   Mirrors the Tech Stack mindmap + Pathway branch-flow.
   ============================================================ */

/* Body fills the view; intro + canvas (or detail) stack vertically. */
.em-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 0; /* full-bleed canvas - meets the header's bottom line, no inner stripe */
  width: 100%;
  overflow: hidden;
}
.help-pop-body kbd {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 600;
  padding: 1px 5px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface-2);
  color: var(--text-soft);
}

/* Status filter chips (in the page header). Frosted-glass pill, sized to the
   icon buttons so the Email Flows header is the same height as the other map
   headers (e.g. Margins) - the buttons then center at the same Y automatically. */
.em-filter {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px;
  background: linear-gradient(180deg, rgba(255,255,255,0.55), rgba(243,241,237,0.32));
  -webkit-backdrop-filter: blur(14px) saturate(175%);
  backdrop-filter: blur(14px) saturate(175%);
  border: 1px solid rgba(20,18,14,0.09);
  border-radius: var(--radius-pill);
  box-shadow:
    0 4px 14px -6px rgba(20,18,14,0.22),
    inset 0 1px 0 rgba(255,255,255,0.85);
}
.em-filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border: 1px solid transparent;
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 11.5px;
  font-weight: 500;
  line-height: 1.25;
  cursor: pointer;
  transition: background 100ms ease, color 100ms ease, box-shadow 100ms ease;
}
.em-filter-chip:hover { color: var(--text-soft); }
.em-filter-chip.active {
  background: linear-gradient(180deg, rgba(255,255,255,0.96), rgba(255,255,255,0.78));
  -webkit-backdrop-filter: blur(8px) saturate(150%);
  backdrop-filter: blur(8px) saturate(150%);
  color: var(--text);
  border-color: rgba(255,255,255,0.8);
  box-shadow:
    0 2px 6px -2px rgba(20,18,14,0.18),
    inset 0 1px 0 rgba(255,255,255,0.9);
}

/* Status dots */
.em-dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; display: inline-block; }
.em-dot-live    { background: var(--ok); }
.em-dot-planned { background: var(--warn); }
.em-dot-system  { background: var(--text-faint); }

/* ---- Map state: the zoomable canvas (viewport = #emailmap) ---- */
.em-stage { flex: 1; min-height: 0; display: flex; }
/* Author display rules above beat the UA [hidden] reset, so re-assert hidden. */
.em-stage[hidden] { display: none; }
.emailmap-viewport {
  position: relative;
  flex: 1;
  min-height: 0;
  width: 100%;
  overflow: hidden; /* clips the pan/zoom canvas - keep */
  cursor: grab;
  user-select: none;
  background:
    radial-gradient(circle, rgba(20,18,14,0.05) 1px, transparent 1.2px) 0 0 / 22px 22px,
    var(--surface);
}
.emailmap-viewport.panning { cursor: grabbing; }

/* Canvas - panned + scaled via inline transform from app.js */
.em-zoom-wrap {
  position: absolute;
  top: 0;
  left: 0;
  transform-origin: 0 0;
  will-change: transform;
}
.em-connectors {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
  z-index: 0;
  overflow: visible;
}
.em-conn { fill: none; stroke: var(--border-strong); stroke-width: 1.5; stroke-linecap: round; }
.em-conn-cat    { stroke: var(--text-muted); stroke-width: 2.2; }
.em-conn-seq    { stroke: var(--text-muted); stroke-width: 1.6; }
.em-conn-step   { stroke: var(--border-strong); stroke-width: 1.6; }
.em-conn-branch { stroke: var(--border-strong); stroke-width: 1.3; stroke-dasharray: 5 4; opacity: 0.75; }

.em-mindmap {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0 88px;
  padding: 32px 28px 56px;
  min-width: max-content;
}

/* Root node */
.em-root {
  align-self: center;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  background: var(--accent);
  border-radius: var(--radius);
  box-shadow: var(--shadow-pop);
  color: #fff;
}
.em-root-mark {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px; height: 38px;
  border-radius: 10px;
  background: rgba(255,255,255,0.12);
  color: #fff;
  flex-shrink: 0;
}
.em-root-text { display: flex; flex-direction: column; gap: 1px; }
.em-root-title { font-size: 14px; font-weight: 700; letter-spacing: 0.06em; }
.em-root-sub {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.6);
}

.em-categories { display: flex; flex-direction: column; gap: 26px; }

/* Category: bracket node on the left, its sequences on the right */
.em-category {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0 72px;
  align-items: center;
}
.em-category-node {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 13px 16px 13px 14px;
  min-width: 248px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--tn, var(--text-muted));
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
}
.em-category-head { display: flex; align-items: center; gap: 10px; }
.em-category-dot { width: 11px; height: 11px; border-radius: 50%; background: var(--tn, var(--text-muted)); flex-shrink: 0; }
.em-category-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.em-category-title { font-size: 14px; font-weight: 600; color: var(--text); letter-spacing: -0.005em; }
.em-category-meta {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
  font-family: var(--font-mono);
}
.em-category-sender {
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text-muted);
  padding-top: 8px;
  border-top: 1px dashed var(--border);
  word-break: break-all;
}

.em-sequences { display: flex; flex-direction: column; gap: 16px; }

/* Sequence: label node on the left, the horizontal email flow on the right */
.em-sequence {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0 56px;
  align-items: center;
}
.em-sequence-node {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 9px 13px 9px 11px;
  min-width: 184px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--tn, var(--text-muted));
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
}
.em-sequence-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--tn, var(--text-muted)); flex-shrink: 0; }
.em-sequence-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.em-sequence-title { font-size: 12.5px; font-weight: 600; color: var(--text); white-space: nowrap; }
.em-sequence-meta {
  font-size: 9.5px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* Tone colors - one --tn variable drives both the left border + the dot */
.em-category-node.tone-amber,       .em-sequence-node.tone-amber       { --tn: #c89640; }
.em-category-node.tone-blue,        .em-sequence-node.tone-blue        { --tn: var(--accent-blue); }
.em-category-node.tone-legal,       .em-sequence-node.tone-legal       { --tn: var(--dept-legal-fg); }
.em-category-node.tone-green,       .em-sequence-node.tone-green       { --tn: #1a6b3c; }
.em-category-node.tone-creative,    .em-sequence-node.tone-creative    { --tn: var(--dept-creative-fg); }
.em-category-node.tone-executive,   .em-sequence-node.tone-executive   { --tn: var(--dept-executive-fg); }
.em-category-node.tone-engineering, .em-sequence-node.tone-engineering { --tn: var(--dept-engineering-fg); }

/* The horizontal email flow */
.em-flow { display: flex; align-items: flex-start; flex-wrap: nowrap; }

/* Email pill (minimal) */
.em-node {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 13px;
  margin: 0 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  font-family: var(--font-sans);
  font-size: 12px;
  color: var(--text);
  white-space: nowrap;
  min-height: 38px;
  flex-shrink: 0;
  transition: background 100ms ease, border-color 100ms ease, box-shadow 100ms ease;
}
.em-node:hover { background: var(--surface-2); border-color: var(--text-muted); box-shadow: var(--shadow-active); }
.em-node.active { background: var(--text); color: var(--surface); border-color: var(--text); box-shadow: 0 6px 16px -6px rgba(0,0,0,0.25); }
.em-node-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.em-node-num { font-family: var(--font-mono); font-size: 10.5px; color: var(--text-muted); }
.em-node.active .em-node-num { color: rgba(255,255,255,0.55); }
.em-node-name { font-weight: 500; letter-spacing: -0.005em; }

/* Wrapper used only when a pill carries branch offshoots (keeps flow spacing) */
.em-node-wrap { display: flex; flex-direction: column; align-items: center; margin: 0 16px; flex-shrink: 0; }
.em-node-wrap > .em-node { margin: 0; }
.em-node-branches {
  padding-top: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  position: relative;
}
.em-node-branches::before {
  content: "";
  position: absolute;
  top: 0; left: 50%;
  width: 2px; height: 16px;
  background: var(--border);
  transform: translateX(-50%);
}

/* Branch (conditional offshoot) pill - smaller, softer */
.em-branch {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 10px 5px 6px;
  background: var(--surface-2);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-pill);
  font-family: var(--font-sans);
  font-size: 10.5px;
  color: var(--text-soft);
  cursor: pointer;
  white-space: nowrap;
  position: relative;
  z-index: 1;
  transition: background 100ms ease, border-color 100ms ease, color 100ms ease;
}
.em-branch:hover { background: var(--surface); border-style: solid; color: var(--text); }
.em-branch.active { background: var(--text); color: var(--surface); border-color: var(--text); border-style: solid; }
.em-branch-kind {
  font-family: var(--font-mono);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 2px 5px;
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--text-muted);
  border: 1px solid var(--border);
  line-height: 1;
}
.em-branch.active .em-branch-kind { background: rgba(255,255,255,0.18); color: var(--surface); border-color: rgba(255,255,255,0.25); }
.em-branch-name { font-weight: 500; }

/* Status filter dimming (class toggled on #emailmap) */
.em-filter-live    [data-status="planned"],
.em-filter-live    [data-status="system"],
.em-filter-planned [data-status="live"],
.em-filter-planned [data-status="system"] { opacity: 0.26; }

/* Floating Fit pill */
.em-zoom-toolbar {
  position: absolute;
  bottom: 16px;
  right: 16px;
  z-index: 4;
  display: flex;
  align-items: center;
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  box-shadow: 0 6px 16px -6px rgba(20,18,14,0.16), 0 0 0 1px rgba(20,18,14,0.02);
}
.em-zoom-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-pill);
  color: var(--text-soft);
  font: inherit;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background 100ms ease, color 100ms ease;
}
.em-zoom-btn:hover { background: var(--surface-2); color: var(--text); }
.em-zoom-btn kbd {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  padding: 1px 5px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface-2);
  color: var(--text-soft);
  line-height: 1;
}

/* ---- Detail card: a slide-out drawer (Client Journey style) ---- */
.em-drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 18, 14, 0.18);
  z-index: 99;
  animation: fadeIn 180ms ease;
}
.em-drawer-backdrop[hidden] { display: none; }

.em-drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: 440px;
  max-width: 92vw;
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: -16px 0 40px -20px rgba(20,18,14,0.24);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transform: translateX(16px);
  opacity: 0;
  transition: transform 220ms cubic-bezier(.2,.8,.2,1), opacity 220ms ease;
}
.em-drawer.open { transform: translateX(0); opacity: 1; }
.em-drawer[hidden] { display: none; }

.em-drawer-head {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: flex-start;
  padding: 18px 18px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.em-drawer-head-text { min-width: 0; }
.em-drawer-crumb {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  font-family: var(--font-mono);
  margin-bottom: 6px;
}
.em-drawer-titlerow { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.em-drawer-title { font-size: 16px; font-weight: 700; color: var(--text); margin: 0; letter-spacing: -0.01em; line-height: 1.3; }
.em-drawer-status {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: var(--radius-pill);
  white-space: nowrap;
}
.em-status-live    { color: #1a6b3c; background: rgba(26,107,60,0.10); }
.em-status-planned { color: #82591a; background: rgba(130,89,26,0.10); }
.em-status-system  { color: var(--text-muted); background: var(--surface-3); }

.em-drawer-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* The primary CTA: open the rendered email design in a new browser tab */
.em-drawer-cta { display: flex; flex-direction: column; }
.em-view-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 12px 16px;
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  color: #fff;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: filter 120ms ease, transform 120ms ease;
}
.em-view-btn:hover { filter: brightness(1.08); }
.em-view-btn:active { transform: translateY(1px); }
.em-view-btn svg { opacity: 0.85; }

/* Disabled CTA - shown (grayed, inert) when an email has no linked design */
.em-view-btn.is-disabled, .em-view-btn:disabled {
  background: var(--surface-3);
  border-color: var(--border);
  color: var(--text-muted);
  cursor: not-allowed;
}
.em-view-btn.is-disabled:hover, .em-view-btn:disabled:hover { filter: none; }
.em-view-btn.is-disabled:active, .em-view-btn:disabled:active { transform: none; }
.em-view-note { font-size: 11px; color: var(--text-muted); margin-top: 6px; text-align: center; }

/* ---- Compliance block (CAN-SPAM / FTC) - one calm, contained card ---- */
.em-comp-card {
  --cc: var(--text-muted);
  --cc-bg: var(--surface-3);
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 13px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--cc);
  border-radius: var(--radius);
}
.em-comp-ok      { --cc: #1a6b3c; --cc-bg: rgba(26,107,60,0.10); }
.em-comp-warn    { --cc: #a3361f; --cc-bg: rgba(163,54,31,0.10); }
.em-comp-mid     { --cc: #82591a; --cc-bg: rgba(130,89,26,0.10); }
.em-comp-neutral { --cc: var(--text-muted); --cc-bg: var(--surface-3); }

.em-comp-top { display: flex; align-items: baseline; gap: 9px; flex-wrap: wrap; }
.em-comp-badge {
  font-size: 10.5px; font-weight: 700; letter-spacing: 0.03em;
  padding: 3px 9px; border-radius: var(--radius-pill);
  color: var(--cc); background: var(--cc-bg);
}
.em-comp-status { font-size: 11.5px; font-weight: 500; color: var(--cc); }

.em-comp-summary { font-size: 12px; color: var(--text-soft); line-height: 1.55; margin: 0; }

.em-comp-note { font-size: 12px; color: var(--text-soft); line-height: 1.55; margin: 0; }
.em-comp-note-k, .em-comp-watch-k {
  font-family: var(--font-mono); font-size: 9px; font-weight: 700;
  letter-spacing: 0.07em; text-transform: uppercase; margin-right: 8px;
}
.em-comp-note-k { color: var(--text-faint); }

.em-comp-groups { display: flex; flex-direction: column; gap: 11px; }
.em-comp-gh {
  display: flex; align-items: center; gap: 7px;
  font-size: 11px; font-weight: 600; color: var(--text); margin-bottom: 5px;
}
.em-comp-gdot { width: 6px; height: 6px; border-radius: 50%; background: var(--text-faint); flex-shrink: 0; }
.em-comp-req .em-comp-gdot { background: #1a6b3c; }
.em-comp-rec .em-comp-gdot { background: var(--text-muted); }
.em-comp-not .em-comp-gdot { background: var(--border-strong); }
.em-comp-gl { margin: 0; padding: 0 0 0 13px; list-style: none; display: flex; flex-direction: column; gap: 4px; }
.em-comp-gl li {
  position: relative; padding-left: 13px;
  font-size: 12px; color: var(--text-soft); line-height: 1.45;
}
.em-comp-gl li::before {
  content: ''; position: absolute; left: 0; top: 6.5px;
  width: 3px; height: 3px; border-radius: 50%; background: var(--border-strong);
}
.em-comp-not .em-comp-gl li { color: var(--text-muted); }

.em-comp-watch {
  font-size: 11.5px; line-height: 1.5; color: #82591a; margin: 0;
  padding: 9px 11px; border-radius: var(--radius-sm);
  background: rgba(130,89,26,0.07); border: 1px solid rgba(130,89,26,0.18);
}
.em-comp-watch-k { color: #82591a; }

.em-comp-sources { font-size: 10.5px; color: var(--text-muted); line-height: 1.7; }
.em-comp-sources-label {
  font-family: var(--font-mono); font-size: 9px; font-weight: 700;
  letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-faint); margin-right: 8px;
}
.em-comp-sources-links a { color: var(--text-muted); text-decoration: none; border-bottom: 1px solid var(--border-strong); }
.em-comp-sources-links a:hover { color: var(--text); border-bottom-color: var(--text-muted); }
.em-comp-dot { margin: 0 5px; color: var(--text-faint); }
.em-meta-block { display: flex; flex-direction: column; gap: 8px; }
.em-meta-row { display: grid; grid-template-columns: 84px 1fr; gap: 10px; align-items: start; }
.em-meta-label {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-faint);
  font-family: var(--font-mono);
  padding-top: 2px;
}
.em-meta-value { font-size: 12.5px; color: var(--text-soft); line-height: 1.5; word-break: break-word; }
.em-meta-subject { font-family: var(--font-mono); font-size: 11.5px; color: var(--text); }
.em-meta-doc { font-size: 12.5px; color: var(--text-soft); line-height: 1.6; margin: 0; }

.em-steps { display: flex; flex-direction: column; gap: 6px; }
.em-step {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-align: left;
  font: inherit;
  transition: background 100ms ease, border-color 100ms ease;
}
.em-step:hover { background: var(--surface-2); border-color: var(--text-muted); }
.em-step.current { background: var(--accent); border-color: var(--accent); }
.em-step.current .em-step-name { color: #fff; }
.em-step.current .em-step-num { color: rgba(255,255,255,0.55); }
.em-step-num { font-family: var(--font-mono); font-size: 10px; color: var(--text-muted); flex-shrink: 0; }
.em-step-name { font-size: 12px; color: var(--text); flex: 1; min-width: 0; }
.em-step-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }

@media (max-width: 560px) {
  .em-drawer { width: 100vw; max-width: 100vw; }
  .em-filter { display: none; }
}

/* ============================================================
   ICP - Форматы сотрудничества (engagement formats block)
   ============================================================ */

.icp-formats-block {
  margin-top: 36px;
  padding-top: 28px;
  border-top: 1px solid var(--border);
}
.icp-formats-head {
  margin-bottom: 18px;
  max-width: 720px;
}
.icp-formats-eyebrow {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.icp-formats-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.015em;
  margin: 0 0 6px;
}
.icp-formats-sub {
  font-size: 13px;
  color: var(--text-soft);
  line-height: 1.55;
  margin: 0;
}

.icp-formats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
  align-items: stretch;
}

.icp-format-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: var(--shadow-card);
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
.icp-format-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-active);
}

.icp-format-head {
  display: flex;
  align-items: center;
  gap: 12px;
}
.icp-format-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--icp-bg, var(--text-soft));
  color: var(--surface);
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.01em;
  flex-shrink: 0;
}
.icp-format-head-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.icp-format-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
}
.icp-format-duration {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.icp-format-headline {
  font-size: 13px;
  color: var(--text-soft);
  line-height: 1.5;
  margin: 0;
  padding: 10px 12px;
  background: var(--surface-2);
  border-radius: var(--radius);
  border-left: 3px solid var(--icp-bg, var(--text));
}

.icp-format-section {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.icp-format-section-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.icp-format-section-body {
  font-size: 12.5px;
  color: var(--text-soft);
  line-height: 1.55;
  margin: 0;
}

.icp-format-subs {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 4px;
  padding-top: 12px;
  border-top: 1px dashed var(--border);
}
.icp-format-sub {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--icp-bg, var(--text));
  border-radius: var(--radius);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.icp-format-sub-title {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.005em;
}
.icp-format-sub-desc {
  font-size: 12px;
  color: var(--text-soft);
  line-height: 1.55;
  margin: 0;
}
.icp-format-sub-invest {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
  border-top: 1px solid var(--hairline);
  padding-top: 6px;
}
.icp-format-sub-invest strong {
  text-transform: none;
  letter-spacing: -0.005em;
  font-size: 12.5px;
  color: var(--text);
}

@media (max-width: 720px) {
  .icp-formats-grid { grid-template-columns: 1fr; }
}

/* ============================================================
   ПРОДУКТЫ - separate page with pricing + payment options
   ============================================================ */

.body.products-body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 20px 24px 48px;
  /* Faint ambient wash so the area around the panel is not flat beige. Sits on
     the scroller's background box, so it stays put as the offers list scrolls. */
  background:
    radial-gradient(48% 50% at 16% 2%,  rgba(31,111,235,0.08), transparent 62%),
    radial-gradient(46% 48% at 88% 98%, rgba(139,92,246,0.08), transparent 62%),
    var(--bg);
  min-width: 0;
}
.products-intro {
  font-size: 13px;
  color: var(--text-soft);
  line-height: 1.55;
  max-width: 760px;
  margin: 0 0 22px;
}

.products-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
  gap: 12px;
  align-items: stretch;
  min-width: 0;
  width: 100%;
}
@media (max-width: 1100px) {
  .products-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 700px) {
  .products-grid { grid-template-columns: 1fr; }
}

.product-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: border-color 120ms ease, box-shadow 120ms ease;
  min-width: 0;
  overflow: hidden;
}
.product-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-active);
}

.product-head {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}
.product-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: var(--product-bg, var(--text-soft));
  color: var(--surface);
  display: grid;
  place-items: center;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.01em;
  flex-shrink: 0;
}
.product-head-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}
.product-category {
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  font-family: var(--font-mono);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.product-title {
  font-size: 14.5px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.012em;
  margin: 0;
  line-height: 1.2;
}
.product-headline {
  font-size: 11.5px;
  color: var(--text-muted);
  line-height: 1.4;
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.product-price-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 10px 12px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--product-bg, var(--text));
}
.product-price-block {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex: 1;
}
.product-price-divider {
  width: 1px;
  align-self: stretch;
  background: var(--border);
}
.product-price-label {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  white-space: nowrap;
}
.product-price-value {
  font-size: 18px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.product-price-unit {
  font-size: 10.5px;
  color: var(--text-muted);
  font-weight: 500;
  letter-spacing: 0.01em;
}
.product-price-note {
  font-size: 10.5px;
  color: var(--text-muted);
  line-height: 1.45;
  margin: 0;
  font-style: italic;
}

/* Payment plan selector - full-width dropdown replacing the pill row */
.pay-select {
  position: relative;
  width: 100%;
}
.pay-select-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  padding: 10px 16px;
  background: var(--text);
  color: var(--surface);
  border: 1px solid var(--text);
  border-radius: var(--radius-pill);
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: -0.003em;
  cursor: pointer;
  text-align: left;
  transition: background 120ms ease, border-color 120ms ease;
}
.pay-select-trigger:hover { background: color-mix(in srgb, var(--text) 88%, var(--surface) 12%); }
.pay-select-trigger:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }
.pay-select-trigger-label { font-weight: 700; }
.pay-select-chevron {
  transition: transform 160ms ease;
  flex-shrink: 0;
}
.pay-select.open .pay-select-chevron { transform: rotate(180deg); }

.pay-select-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.08), 0 2px 6px rgba(0,0,0,0.04);
  padding: 4px;
  display: flex;
  flex-direction: column;
  gap: 1px;
  opacity: 0;
  transform: translateY(-4px);
  pointer-events: none;
  transition: opacity 140ms ease, transform 140ms ease;
  z-index: 20;
}
.pay-select.open .pay-select-menu {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
.pay-select-option {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 12px;
  background: transparent;
  border: 0;
  border-radius: 8px;
  font-family: inherit;
  font-size: 12px;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  transition: background 100ms ease;
}
.pay-select-option:hover { background: var(--surface-2); }
.pay-select-option.active { background: color-mix(in srgb, var(--text) 8%, transparent); }
.pay-select-option-label { font-weight: 600; }
.pay-select-option-badge {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 1px 6px;
  background: var(--status-completed-bg);
  color: var(--status-completed-fg);
  border-radius: var(--radius-pill);
}

.pay-breakdown {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 10px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  border: 1px solid var(--hairline);
}
.pay-breakdown-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  font-size: 11.5px;
}
.pay-breakdown-label { color: var(--text-muted); }
.pay-breakdown-amount {
  color: var(--text);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.pay-breakdown-strike .pay-breakdown-amount,
.pay-breakdown-strike .pay-breakdown-label { color: var(--text-faint); }
.pay-breakdown-note {
  font-size: 10.5px;
  color: var(--text-muted);
  font-style: italic;
  margin-top: 2px;
  padding-top: 3px;
  border-top: 1px dashed var(--hairline);
}

.product-includes {
  display: flex;
  flex-direction: column;
  gap: 3px;
  list-style: none;
  padding: 0;
  margin: 0;
}
.product-includes li {
  display: flex;
  gap: 6px;
  font-size: 11.5px;
  color: var(--text-soft);
  line-height: 1.4;
}
.product-includes li::before {
  content: '';
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--text-muted);
  margin-top: 7px;
  flex-shrink: 0;
}

.product-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 6px;
  margin-top: auto;
  padding-top: 4px;
}
.product-action-btn {
  width: 100%;
  min-width: 0;
  justify-content: center;
  gap: 6px;
  padding: 9px 6px;
  font-size: 12px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  min-height: 36px;
  overflow: hidden;
}
.product-action-btn svg { width: 13px; height: 13px; flex-shrink: 0; }
/* One black "Контракт" button with the copy action as a small rounded chip
   inset on the right - not a split segment with a full-height divider. */
.product-action-combo {
  position: relative;
  display: flex;
  align-items: center;
  min-width: 0;
  min-height: 36px;
  padding-right: 5px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--text);
}
.product-action-combo .product-action-main {
  flex: 1 1 auto;
  min-width: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}
/* The main label area is not its own hover target - within the combo the copy
   chip is the only distinct button, so only it reacts. Override the base
   .btn-primary/.btn-ghost hover so the big button stays flat. */
.product-action-combo .product-action-main:hover {
  background: transparent;
}
.product-action-copy {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  margin-left: 5px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: color-mix(in srgb, var(--surface) 16%, transparent);
  color: var(--surface);
  cursor: pointer;
  transition: background 0.12s ease;
}
.product-action-copy:hover {
  background: color-mix(in srgb, var(--surface) 30%, transparent);
}
.product-action-copy:focus-visible {
  outline: 2px solid var(--surface);
  outline-offset: -2px;
}
.product-action-copy svg {
  width: 12px;
  height: 12px;
}
/* Ghost variant - the Оплата button's combo (light, outlined) with a copy chip
   that copies the currently-selected payment option's link. */
.product-action-combo.product-action-combo--ghost {
  background: transparent;
  border: 1px solid var(--border);
}
.product-action-combo--ghost .product-action-main { color: var(--text); }
.product-action-combo--ghost .product-action-main:hover {
  background: transparent;
}
.product-action-copy--ghost {
  background: color-mix(in srgb, var(--text) 8%, transparent);
  color: var(--text-soft);
}
.product-action-copy--ghost:hover {
  background: color-mix(in srgb, var(--text) 16%, transparent);
}
.product-action-copy--ghost:focus-visible {
  outline-color: var(--text);
}
.product-action-btn span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.product-action-btn svg { width: 15px; height: 15px; }

/* Focused pricing-card layout for Offers */
.body.products-body {
  display: flex;
  justify-content: center;
  padding: 22px 18px 48px;
}
.products-grid {
  display: flex;
  justify-content: center;
  width: 100%;
}
.products-pricing-panel {
  width: min(100%, 520px);
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 18px;
  border-radius: 22px;
  /* Cool aurora wash - indigo -> violet -> fuchsia -> pink - the rich surface the
     glass plan-cards lens through. The fabulous gradient edge is the ring below. */
  background:
    radial-gradient(70% 60% at 12% 6%,  rgba(99,102,241,0.26), transparent 60%),
    radial-gradient(60% 55% at 90% 8%,  rgba(139,92,246,0.22), transparent 58%),
    radial-gradient(66% 60% at 86% 96%, rgba(192,38,211,0.22), transparent 60%),
    radial-gradient(60% 62% at 6% 94%,  rgba(99,102,241,0.20), transparent 60%),
    radial-gradient(54% 50% at 50% 52%, rgba(236,72,153,0.12), transparent 66%),
    var(--surface);
  border: 1px solid rgba(255,255,255,0.60);
  box-shadow:
    0 22px 54px -30px rgba(20,18,14,0.42),
    inset 0 1px 0 rgba(255,255,255,0.70);
}
.products-pricing-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 2px 2px 0;
}
.products-pricing-head h2 {
  margin: 0;
  color: var(--text);
  font-size: 22px;
  line-height: 1.1;
  letter-spacing: -0.02em;
}
.products-pricing-eyebrow {
  margin-bottom: 4px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.products-pricing-count {
  flex-shrink: 0;
  padding: 5px 9px;
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
}
.products-plan-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.products-pricing-panel .product-card {
  position: relative;
  gap: 0;
  padding: 0;
  border-radius: 16px;
  /* Liquid glass over the panel's colour wash. A touch more opaque than the ICP
     tiles because each row carries dense text, chips and buttons that stay crisp. */
  border: 1px solid rgba(255,255,255,0.55);
  background:
    linear-gradient(140deg, rgba(255,255,255,0.55) 0%, rgba(255,255,255,0.26) 45%, rgba(255,255,255,0.40) 100%);
  box-shadow:
    0 12px 30px -20px rgba(20,18,14,0.34),
    inset 0 1px 0 0 rgba(255,255,255,0.80),
    inset 0 0 0 1px rgba(255,255,255,0.12);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  backdrop-filter: blur(20px) saturate(180%);
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease, background 160ms ease;
}
.products-pricing-panel .product-card:hover {
  transform: translateY(-1px);
  border-color: rgba(255,255,255,0.80);
  background:
    linear-gradient(140deg, rgba(255,255,255,0.66) 0%, rgba(255,255,255,0.34) 45%, rgba(255,255,255,0.48) 100%);
  box-shadow:
    0 18px 38px -22px rgba(20,18,14,0.42),
    inset 0 1px 0 0 rgba(255,255,255,0.92),
    inset 0 0 0 1px rgba(255,255,255,0.16);
}
.products-pricing-panel .product-card.selected {
  /* Solid accent edge is the fallback; the aurora gradient ring overlays it in
     @supports below. Plus a soft accent glow so the row lifts off the panel. */
  border-color: color-mix(in srgb, var(--product-bg) 60%, #ffffff);
  background:
    linear-gradient(140deg, rgba(255,255,255,0.62) 0%, rgba(255,255,255,0.30) 45%, rgba(255,255,255,0.44) 100%);
  box-shadow:
    0 18px 40px -22px color-mix(in srgb, var(--product-bg) 42%, rgba(20,18,14,0.4)),
    0 0 26px -8px color-mix(in srgb, var(--product-bg) 38%, transparent),
    inset 0 1px 0 0 rgba(255,255,255,0.80);
}

/* Aurora gradient borders (the AuroraCard mask technique) - the "fabulous" edges.
   Gated on mask support so unsupported browsers keep the solid edges above. */
@supports ((mask-composite: exclude) or (-webkit-mask-composite: xor)) {
  .products-pricing-panel { border-color: transparent; }
  .products-pricing-panel::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    padding: 1.5px;
    background: linear-gradient(135deg,
      rgba(99,102,241,0.70) 0%,
      rgba(139,92,246,0.60) 30%,
      rgba(192,38,211,0.52) 58%,
      rgba(236,72,153,0.55) 80%,
      rgba(255,255,255,0.85) 100%);
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
            mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
            mask-composite: exclude;
    pointer-events: none;
  }
  .products-pricing-panel .product-card.selected { border-color: transparent; }
  .products-pricing-panel .product-card.selected::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    padding: 1.6px;
    background: linear-gradient(135deg,
      color-mix(in srgb, var(--product-bg) 78%, #241433) 0%,
      var(--product-bg) 38%,
      color-mix(in srgb, var(--product-bg) 48%, #ffffff) 74%,
      rgba(255,255,255,0.92) 100%);
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
            mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
            mask-composite: exclude;
    pointer-events: none;
  }
}
/* Mobile: lighter blur so a phone GPU is not frosting a tall stack of rows. */
@media (max-width: 700px) {
  .products-pricing-panel .product-card {
    -webkit-backdrop-filter: blur(14px) saturate(170%);
    backdrop-filter: blur(14px) saturate(170%);
  }
}
/* Fallback where backdrop-filter is unsupported: opaque-ish rows stay readable. */
@supports not ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
  .products-pricing-panel .product-card { background: rgba(255,255,255,0.86); }
  .products-pricing-panel .product-card:hover { background: rgba(255,255,255,0.93); }
}
.products-pricing-panel .product-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 16px;
}
.product-select-dot {
  width: 22px;
  height: 22px;
  margin-top: 2px;
  border: 2px solid var(--border-strong);
  border-radius: 50%;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  transition: border-color 160ms ease;
}
.product-card.selected .product-select-dot {
  border-color: var(--product-bg);
}
.product-select-dot span {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--product-bg);
}
.products-pricing-panel .product-category {
  margin-bottom: 3px;
}
.products-pricing-panel .product-title {
  font-size: 16px;
}
.products-pricing-panel .product-headline {
  -webkit-line-clamp: 2;
  font-size: 12px;
}
.product-price-side {
  min-width: 104px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  text-align: right;
}
.products-pricing-panel .product-price-value {
  font-size: 19px;
  font-weight: 800;
}
.products-pricing-panel .product-price-unit {
  max-width: 116px;
  font-size: 10.5px;
  line-height: 1.25;
}
.product-expanded {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 0 16px 16px 50px;
  animation: productExpand 180ms ease-out;
}
@keyframes productExpand {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}
.product-description {
  margin: 0;
  color: var(--text-soft);
  font-size: 12.5px;
  line-height: 1.55;
}
.products-pricing-panel .product-price-note {
  padding: 10px 12px;
  border: 1px solid rgba(255,255,255,0.30);
  border-radius: 10px;
  background: rgba(255,255,255,0.14);
  font-style: normal;
}
/* Translucent glass tray - shows the frosted card behind it instead of a grey fill. */
.product-payment-tabs {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 5px;
  border: 1px solid rgba(255,255,255,0.28);
  border-radius: 12px;
  background: rgba(255,255,255,0.12);
}
.product-payment-option {
  display: grid;
  grid-template-columns: 14px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  cursor: pointer;
  transition: background 140ms ease, color 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
}
.product-payment-option:hover {
  color: var(--text);
  background: rgba(255,255,255,0.18);
}
/* Selected option = a clean frosted-glass chip (GlassTimeCard style): translucent
   white, thin bright edge, soft lift - clear, not grey. */
.product-payment-option.active {
  background: rgba(255,255,255,0.42);
  border-color: rgba(255,255,255,0.65);
  box-shadow:
    0 10px 26px -12px rgba(20,18,14,0.22),
    inset 0 1px 0 rgba(255,255,255,0.75);
  color: var(--text);
  -webkit-backdrop-filter: blur(8px) saturate(150%);
  backdrop-filter: blur(8px) saturate(150%);
}
.product-payment-dot {
  width: 11px;
  height: 11px;
  border: 1.5px solid var(--border-strong);
  border-radius: 50%;
}
.product-payment-option.active .product-payment-dot {
  border-color: var(--product-bg);
  background: radial-gradient(circle at center, var(--product-bg) 0 45%, transparent 49%);
}
.product-payment-text {
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  text-align: left;
}
.product-payment-label {
  font-size: 11.5px;
  font-weight: 700;
  line-height: 1.1;
  color: var(--text);
}
.product-payment-schedule {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
}
.product-payment-amount {
  padding-left: 8px;
  color: var(--text);
  font-size: 12px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.products-pricing-panel .pay-breakdown {
  border-radius: 10px;
}
.products-pricing-panel .product-includes {
  gap: 8px;
}
.products-pricing-panel .product-includes li {
  align-items: flex-start;
  gap: 8px;
  font-size: 12.5px;
}
.products-pricing-panel .product-includes li::before {
  content: none;
}
.products-pricing-panel .product-includes svg {
  margin-top: 2px;
  color: var(--product-bg);
  flex-shrink: 0;
}
.products-pricing-panel .product-actions {
  padding-top: 2px;
}

@media (max-width: 620px) {
  .products-pricing-panel {
    border-radius: 16px;
    padding: 12px;
  }
  .products-pricing-panel .product-head {
    padding: 14px;
  }
  .product-expanded {
    padding: 0 14px 14px;
  }
  .product-price-side {
    min-width: 86px;
  }
  .products-pricing-panel .product-price-value {
    font-size: 16px;
  }
}

/* ============================================================
   PUBLIC SIGN PAGE - what a client sees when they click the
   sign-link in their email. Hides the sidebar so the page feels
   like a focused document, not an internal app view.
   ============================================================ */
body.sign-public-mode .sidebar { display: none; }
body.sign-public-mode .app { grid-template-columns: 1fr; }

.view.sign-public { padding: 0; background: #f7f5f1; }
.sign-page {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  width: 100%;
}

/* Top bar with branding + sender meta */
.sign-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 28px;
  background: #fff;
  border-bottom: 1px solid var(--border);
}
.sign-brand { display: flex; align-items: center; gap: 10px; }
.sign-brand-mark {
  width: 32px; height: 32px;
  border-radius: 8px;
  background: var(--text);
  color: var(--surface);
  display: grid; place-items: center;
  overflow: hidden;
}
.sign-brand-mark img { width: 20px; height: 20px; display: block; }
.sign-brand-name {
  font-size: 13.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--text);
}
.sign-topbar-meta {
  font-size: 12px;
  color: var(--text-soft);
}
.sign-topbar-meta b { color: var(--text); font-weight: 600; }

/* Main content area - centered column */
.sign-main {
  flex: 1;
  width: 100%;
  max-width: 880px;
  margin: 0 auto;
  padding: 36px 24px 60px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Hero section */
.sign-hero { padding: 8px 0 4px; }
.sign-hero-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 10px;
}
.sign-hero-eyebrow {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--warn);
}
.sign-hero-ref {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text-muted);
  padding: 4px 9px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  white-space: nowrap;
}
.sign-hero-title {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.015em;
  margin: 0 0 8px 0;
  line-height: 1.2;
}
.sign-hero-sub {
  font-size: 14px;
  color: var(--text-soft);
  margin-bottom: 18px;
}
.sign-hero-sub b { color: var(--text); font-weight: 600; }
.sign-hero-meta {
  display: flex;
  gap: 28px;
  padding-top: 6px;
}
.sign-hero-meta > div {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.sign-hero-meta span {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.sign-hero-meta b {
  font-size: 13px;
  color: var(--text);
  font-weight: 600;
}

/* Document card */
.sign-doc-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}
.sign-doc-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 22px;
  border-bottom: 1px solid var(--border);
  background: #fafaf8;
}
.sign-doc-icon {
  width: 36px; height: 36px;
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text-soft);
  display: grid; place-items: center;
  flex-shrink: 0;
  overflow: hidden;
}
.sign-doc-icon img {
  width: 22px; height: 22px;
  display: block;
}
.sign-doc-letterhead {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 26px 32px 18px;
  border-bottom: 1px solid var(--hairline);
  background: #fff;
}
.sign-doc-letterhead-mark {
  height: 22px;
  width: auto;
  display: block;
}
@media (max-width: 520px) {
  .sign-doc-letterhead { padding: 20px 22px 14px; }
  .sign-doc-letterhead-mark { height: 18px; }
}
.sign-doc-head-text {
  min-width: 0;
  flex: 1;
}
.sign-doc-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}
.sign-doc-sub {
  font-size: 11.5px;
  color: var(--text-muted);
}
.sign-doc-ref {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  margin-left: auto;
  padding: 5px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  flex-shrink: 0;
  white-space: nowrap;
}
.sign-doc-ref-label {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-faint);
}
.sign-doc-ref-id {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text);
}
@media (max-width: 520px) {
  .sign-doc-ref { padding: 4px 8px; }
  .sign-doc-ref-label { display: none; }
}
.sign-doc-body {
  margin: 0;
  padding: 44px 56px 56px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.85;
  color: var(--text);
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow-wrap: break-word;
}
.doc-heading {
  font-weight: 700;
  color: var(--text);
}
.sig-divider {
  border: 0;
  border-top: 1px solid var(--hairline);
  margin: 32px 0 18px;
  height: 0;
}
.ct-section,
.ct-signatures {
  display: block;
}
.ct-section + .ct-section,
.ct-section + .ct-signatures {
  margin-top: 22px;
}
.ct-signatures {
  line-height: 2.35;
}
@media (max-width: 640px) {
  .sign-doc-body { padding: 28px 22px 36px; font-size: 12px; line-height: 1.8; }
}

/* Variable tokens inside the doc body (rendered by renderTemplateBodyHtml) */
.sign-doc-body .var-token {
  background: var(--accent-blue-soft);
  color: var(--accent-blue);
  padding: 0 4px;
  border-radius: 3px;
  font-weight: 500;
}

/* Signing form card */
.sign-form-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 24px 28px 22px;
}
.sign-form-card h2 {
  font-size: 18px;
  font-weight: 700;
  margin: 0 0 6px 0;
  color: var(--text);
}
.sign-form-intro {
  font-size: 13px;
  color: var(--text-soft);
  line-height: 1.5;
  margin: 0 0 18px 0;
}
.sign-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}
.sign-field > span {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0.01em;
}
.sign-field-optional {
  margin-left: 6px;
  font-size: 10.5px;
  font-style: normal;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-faint);
}
.sign-field input[type="text"] {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
  font-size: 14px;
  background: #fff;
  color: var(--text);
  transition: border-color 100ms ease, box-shadow 100ms ease;
}
.sign-field input[type="text"]:focus {
  outline: none;
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px var(--accent-blue-soft);
}
.sign-signer-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 14px;
}

/* Signature pad (canvas) */
.signature-pad {
  position: relative;
  background: #fafaf8;
  border: 1px dashed var(--border-strong);
  border-radius: 8px;
  overflow: hidden;
}
.signature-pad canvas {
  display: block;
  width: 100%;
  height: 180px;
  cursor: crosshair;
  background:
    repeating-linear-gradient(
      to right,
      transparent 0,
      transparent calc(100% - 1px),
      var(--border) calc(100% - 1px),
      var(--border) 100%
    );
  touch-action: none;
}
.signature-pad-hint {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
  font-size: 13px;
  color: var(--text-muted);
  font-style: italic;
  transition: opacity 120ms ease;
}
.signature-clear {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 4px 10px;
  font-size: 11.5px;
  font-weight: 500;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-soft);
  cursor: pointer;
}
.signature-clear:hover {
  border-color: var(--text-muted);
  color: var(--text);
}

/* Agreement checkbox */
.sign-checkbox {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  background: #fafaf8;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 16px;
  cursor: pointer;
}
.sign-checkbox input { margin-top: 2px; }
.sign-checkbox span {
  font-size: 13px;
  color: var(--text);
  line-height: 1.5;
}

/* Submit button */
.sign-submit {
  width: 100%;
  padding: 13px 16px;
  font-size: 14px;
  font-weight: 600;
}
.sign-submit:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.sign-disclaimer {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  font-size: 11.5px;
  color: var(--text-muted);
  line-height: 1.55;
}
.sign-disclaimer b { color: var(--text-soft); font-weight: 600; }

/* Success state (after signing) */
.sign-success-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 32px 28px 24px;
  text-align: center;
}
.sign-success-icon {
  width: 56px; height: 56px;
  margin: 0 auto 14px;
  border-radius: 50%;
  background: #d3f2dd;
  color: #1a6b3c;
  display: grid; place-items: center;
}
.sign-success-card h2 {
  font-size: 20px;
  font-weight: 700;
  margin: 0 0 8px 0;
  color: var(--text);
}
.sign-success-card p {
  font-size: 13.5px;
  color: var(--text-soft);
  line-height: 1.55;
  max-width: 520px;
  margin: 0 auto 18px;
}
.sign-success-card p b { color: var(--text); font-weight: 600; }
.sign-success-meta {
  display: flex;
  justify-content: center;
  gap: 28px;
  flex-wrap: wrap;
  margin-bottom: 18px;
  padding: 14px 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.sign-success-meta > div {
  display: flex;
  flex-direction: column;
  gap: 3px;
  text-align: left;
}
.sign-success-meta span {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.sign-success-meta b {
  font-size: 12.5px;
  color: var(--text);
  font-weight: 600;
}
.sign-success-action {
  font-size: 13px;
}

/* Voided state */
.sign-voided-icon {
  background: #ffe1e1;
  color: var(--danger);
}

/* Footer */
.sign-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 28px;
  font-size: 11.5px;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  background: #fff;
}

/* Activity timeline card on the sign page (mirrors the team-side audit trail) */
.sign-activity-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 22px 26px 18px;
}
.sign-activity-head { margin-bottom: 16px; }
.sign-activity-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}
.sign-activity-sub {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
}
.sign-activity-list {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding-left: 18px;
}
.sign-activity-list::before {
  content: '';
  position: absolute;
  left: 5px;
  top: 6px;
  bottom: 6px;
  width: 1.5px;
  background: var(--border);
}
.sign-activity-item {
  position: relative;
  display: flex;
  gap: 12px;
  align-items: flex-start;
}
.sign-activity-dot {
  position: absolute;
  left: -18px;
  top: 4px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--text-muted);
  flex-shrink: 0;
  z-index: 1;
}
.sign-activity-item.event-created    .sign-activity-dot { border-color: var(--text-muted); }
.sign-activity-item.event-sent       .sign-activity-dot { border-color: var(--accent-blue); }
.sign-activity-item.event-viewed     .sign-activity-dot { border-color: var(--warn); }
.sign-activity-item.event-signed     .sign-activity-dot { border-color: var(--ok); background: var(--ok); }
.sign-activity-item.event-countersigned .sign-activity-dot { border-color: var(--ok); background: var(--ok); }
.sign-activity-item.event-completed  .sign-activity-dot { border-color: var(--ok); background: var(--ok); }
.sign-activity-item.event-voided     .sign-activity-dot { border-color: var(--danger); background: var(--danger); }
.sign-activity-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.sign-activity-meta {
  font-size: 11.5px;
  color: var(--text-muted);
  line-height: 1.5;
  margin-top: 2px;
}

@media (max-width: 720px) {
  .sign-main { padding: 24px 16px 48px; }
  .sign-hero-title { font-size: 22px; }
  .sign-hero-top { flex-direction: row; align-items: flex-start; }
  .sign-doc-body { padding: 20px 16px; max-height: none; }
  .sign-signer-row { grid-template-columns: 1fr; gap: 0; }
  .sign-form-card { padding: 20px 18px; }
  .sign-success-meta { flex-direction: column; align-items: center; gap: 12px; }
  .sign-activity-card { padding: 18px 18px 14px; }
}

/* ============================================================
   PATHWAY - full client lifecycle horizontal track
   ============================================================ */
.body.pathway-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
  padding: 20px 28px 28px;
  width: 100%;
}
.body.pathway-body[hidden] { display: none; }

/* ---------- Stage Kanban primitives (used in Pipeline single-stage view) ----
   Step-columns + draggable client cards. Same building blocks regardless of
   which stage we're viewing - tone classes shift per stage. */
.pw-board-phase {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}
.pw-board-phase-head {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}
.pw-board-phase-head.tone-amber       { background: #fff5e0; border-bottom-color: #f0d8a4; }
.pw-board-phase-head.tone-blue        { background: var(--accent-blue-soft); border-bottom-color: #c5d8ec; }
.pw-board-phase-head.tone-legal       { background: var(--dept-legal); border-bottom-color: rgba(75,85,140,0.18); }
.pw-board-phase-head.tone-green       { background: #e2f5e7; border-bottom-color: #b6e5c5; }
.pw-board-phase-head.tone-creative    { background: var(--dept-creative); border-bottom-color: rgba(124,75,162,0.18); }
.pw-board-phase-head.tone-executive   { background: var(--dept-executive); border-bottom-color: rgba(45,60,90,0.18); }
.pw-board-phase-head.tone-engineering { background: var(--dept-engineering); border-bottom-color: rgba(14,94,87,0.18); }

.pw-board-phase-meta {
  display: flex;
  align-items: baseline;
  gap: 10px;
}
.pw-board-phase-name {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.pw-board-phase-head.tone-amber       .pw-board-phase-name { color: #82591a; }
.pw-board-phase-head.tone-blue        .pw-board-phase-name { color: var(--accent-blue); }
.pw-board-phase-head.tone-legal       .pw-board-phase-name { color: var(--dept-legal-fg); }
.pw-board-phase-head.tone-green       .pw-board-phase-name { color: #1a6b3c; }
.pw-board-phase-head.tone-creative    .pw-board-phase-name { color: var(--dept-creative-fg); }
.pw-board-phase-head.tone-executive   .pw-board-phase-name { color: var(--dept-executive-fg); }
.pw-board-phase-head.tone-engineering .pw-board-phase-name { color: var(--dept-engineering-fg); }
.pw-board-phase-count {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 500;
  opacity: 0.75;
}
.pw-board-phase-sub {
  font-size: 11.5px;
  color: var(--text-soft);
  text-align: right;
  max-width: 55%;
  line-height: 1.4;
}

/* Column rail - horizontal scroll if many step-columns */
.pw-board-cols {
  display: flex;
  align-items: stretch;
  gap: 10px;
  padding: 12px;
  overflow-x: auto;
  min-height: 110px;
}
.pw-board-col {
  flex: 0 0 200px;
  display: flex;
  flex-direction: column;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  min-height: 0;
}
.pw-board-col-head {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}
.pw-board-col-titles {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}
.pw-board-col-track {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.pw-board-col-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.25;
}
.pw-board-col-count {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-muted);
  padding: 2px 7px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  flex-shrink: 0;
}

/* Drop-zone (the cards container inside each column) */
.pw-board-col-cards {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px;
  min-height: 80px;
  border-radius: 0 0 10px 10px;
  transition: background 100ms ease, box-shadow 100ms ease;
}
.pw-board-col-cards.is-drop-over {
  background: var(--accent-blue-soft);
  box-shadow: inset 0 0 0 2px var(--accent-blue);
}
.pw-board-col-empty {
  font-size: 11px;
  color: var(--text-faint);
  text-align: center;
  padding: 8px 0;
  font-family: var(--font-mono);
}

/* Cards */
.pw-board-card {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  padding: 8px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--text-muted);
  border-radius: 8px;
  cursor: grab;
  transition: box-shadow 100ms ease, border-color 100ms ease, transform 100ms ease;
}
.pw-board-card:hover { box-shadow: 0 4px 12px -6px rgba(15,18,32,0.18); border-color: var(--text-muted); }
.pw-board-card:active { cursor: grabbing; }
.pw-board-card.is-dragging { opacity: 0.45; transform: scale(0.98); }
.pw-board-card.tone-amber       { border-left-color: #c89640; }
.pw-board-card.tone-blue        { border-left-color: var(--accent-blue); }
.pw-board-card.tone-legal       { border-left-color: var(--dept-legal-fg); }
.pw-board-card.tone-green       { border-left-color: #1a6b3c; }
.pw-board-card.tone-creative    { border-left-color: var(--dept-creative-fg); }
.pw-board-card.tone-executive   { border-left-color: var(--dept-executive-fg); }
.pw-board-card.tone-engineering { border-left-color: var(--dept-engineering-fg); }

.pw-board-card-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.pw-board-card-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding-top: 6px;
  border-top: 1px dashed var(--border);
}
.pw-board-card-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 5px 8px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.01em;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: background 100ms ease, border-color 100ms ease, color 100ms ease;
}
.pw-board-card-btn:hover { border-color: var(--text-muted); }
.pw-board-card-btn-yes {
  background: var(--accent-blue);
  border-color: var(--accent-blue);
  color: #fff;
}
.pw-board-card-btn-yes:hover { filter: brightness(0.95); }
.pw-board-card-btn-no:hover {
  background: rgba(180, 40, 40, 0.06);
  border-color: #b53737;
  color: #b53737;
}

.pw-board-card-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--surface-2);
  color: var(--text);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  flex-shrink: 0;
}
.pw-board-card-body { min-width: 0; flex: 1; }
.pw-board-card-name {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.005em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pw-board-card-company {
  font-size: 10.5px;
  color: var(--text-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ============================================================
   Pathway · single horizontal canvas
   ----------------------------------------------------------------
   All 7 phases laid out left-to-right inside one scroll container.
   Each phase has a colored pill header, a short summary, and a row
   (or stacked rows, for Awareness) of clickable step nodes connected
   by thin lines. Arrows between phases. The whole thing reads as a
   single x-axis flow from "stranger" on the far left to "managed
   long-term" on the far right.
   ============================================================ */
/* The pathway viewport: a single canvas the user can pan and zoom. The actual
   layout (#pwZoomWrap) is absolutely positioned inside and transformed via
   inline CSS from applyPathwayTransform. SVG bezier curves are drawn over the
   whole thing by drawPathwayConnectors after layout settles. */
.pathway {
  position: relative;
  flex: 1;
  min-height: 0;
  width: 100%;
  overflow: hidden;
  cursor: grab;
  user-select: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background:
    radial-gradient(circle, rgba(20,18,14,0.05) 1px, transparent 1.2px) 0 0 / 22px 22px,
    var(--surface);
}
.pathway.panning { cursor: grabbing; }
.pw-zoom-wrap {
  position: absolute;
  top: 0;
  left: 0;
  transform-origin: 0 0;
  will-change: transform;
}
.pw-connectors {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
  z-index: 0;
  overflow: visible;
}
.pw-conn {
  fill: none;
  stroke: var(--border-strong, var(--text-muted));
  stroke-width: 1.6;
  stroke-linecap: round;
}
.pw-conn-cross { stroke-width: 1.8; opacity: 0.85; }
.pw-conn.tone-amber       { stroke: #c08a2c; }
.pw-conn.tone-blue        { stroke: var(--accent-blue); }
.pw-conn.tone-legal       { stroke: var(--dept-legal-fg); }
.pw-conn.tone-green       { stroke: #1a6b3c; }
.pw-conn.tone-engineering { stroke: var(--dept-engineering-fg); }
.pw-conn.tone-creative    { stroke: var(--dept-creative-fg); }
.pw-conn.tone-executive   { stroke: var(--dept-executive-fg); }

/* Floating Fit pill - bottom-right of the pathway viewport (mirrors Tech Stack). */
.pw-zoom-toolbar {
  position: absolute;
  bottom: 14px;
  right: 14px;
  z-index: 5;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 4px;
  box-shadow: var(--shadow-card);
  display: flex;
  gap: 2px;
}
.pw-zoom-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 10px;
  background: transparent;
  border: 0;
  border-radius: var(--radius-pill);
  cursor: pointer;
  font-size: 12px;
  color: var(--text);
}
.pw-zoom-btn:hover { background: var(--surface-2); }
.pw-zoom-btn kbd {
  font-family: var(--font-mono);
  font-size: 10px;
  background: var(--surface-2);
  padding: 1px 5px;
  border-radius: 3px;
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.pw-flow {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 0;
  padding: 36px 28px 32px;
  min-width: max-content;
}

/* One phase column - vertical stack of bracket header + step body. The phase
   column auto-sizes to the widest of (bracket-natural-width, step-row-width);
   the bracket inside is forced to fill that width so it always spans the steps. */
.pw-phase {
  display: flex;
  flex-direction: column;
  gap: 22px;             /* gap accounts for the bracket's downward feet */
  align-self: stretch;
  padding: 0 14px;
  position: relative;
}

/* The "bracket": a wide colored pill spanning the full phase width, with two
   small downward arms hanging from the bottom corners. Reads as an umbrella /
   square-bracket grouping the steps beneath it. */
.pw-phase-bracket {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 18px 10px 10px;
  border-radius: 999px;
  align-self: stretch;
  white-space: nowrap;
  cursor: default;
}
.pw-phase-bracket.tone-amber       { --bg: #fff1d8; --fg: #82591a; background: var(--bg); color: var(--fg); }
.pw-phase-bracket.tone-blue        { --bg: var(--accent-blue-soft); --fg: var(--accent-blue); background: var(--bg); color: var(--fg); }
.pw-phase-bracket.tone-legal       { --bg: var(--dept-legal); --fg: var(--dept-legal-fg); background: var(--bg); color: var(--fg); }
.pw-phase-bracket.tone-green       { --bg: #d3f2dd; --fg: #1a6b3c; background: var(--bg); color: var(--fg); }
.pw-phase-bracket.tone-engineering { --bg: var(--dept-engineering); --fg: var(--dept-engineering-fg); background: var(--bg); color: var(--fg); }
.pw-phase-bracket.tone-creative    { --bg: var(--dept-creative); --fg: var(--dept-creative-fg); background: var(--bg); color: var(--fg); }
.pw-phase-bracket.tone-executive   { --bg: var(--dept-executive); --fg: var(--dept-executive-fg); background: var(--bg); color: var(--fg); }

/* The two downward arms - small slim bars dropping from the corners of the
   bracket, "embracing" the steps below. */
.pw-phase-bracket::before,
.pw-phase-bracket::after {
  content: '';
  position: absolute;
  top: 100%;
  width: 3px;
  height: 14px;
  background: var(--bg);
  border-radius: 0 0 2px 2px;
}
.pw-phase-bracket::before { left: 16px; }
.pw-phase-bracket::after  { right: 16px; }

/* Branch row: sits BELOW the main flow as a fork off a specific decision step.
   Visually quieter than the main line so it reads as a secondary path. */
.pw-branches {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 0;
  padding: 24px 28px 32px;
  margin-top: 12px;
  min-width: max-content;
}
.pw-phase.is-branch { opacity: 0.94; }
.pw-phase-branch-tag {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 3px 7px;
  margin-left: auto;
  border-radius: 4px;
  background: rgba(255,255,255,0.55);
  flex-shrink: 0;
}
/* Branch connectors: dashed + slightly muted so the eye reads them as
   "alternate path" not "main pipeline". */
.pw-conn-branch {
  stroke-dasharray: 6 5;
  opacity: 0.85;
}
.pw-conn-fork {
  stroke-width: 1.8;
}

.pw-phase-num {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  padding: 3px 7px;
  background: rgba(255, 255, 255, 0.55);
  border-radius: 5px;
  letter-spacing: 0.02em;
  flex-shrink: 0;
}
.pw-phase-bracket-text { display: flex; flex-direction: column; gap: 0; min-width: 0; }
.pw-phase-name {
  font-size: 13px; font-weight: 600;
  letter-spacing: -0.005em; line-height: 1.2;
}
.pw-phase-meta {
  font-size: 9.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.06em;
  opacity: 0.82; line-height: 1.4;
}

/* Steps */
.pw-phase-body {
  display: flex; align-items: flex-start; gap: 0;
  flex-wrap: nowrap;
  margin-top: 4px;
  padding-top: 4px;  /* small breathing room so the row's top aligns cleanly */
}
.pw-phase-body-multi {
  display: flex; flex-direction: column; gap: 10px;
  align-items: flex-start;
}
.pw-lane {
  display: grid; grid-template-columns: 120px 1fr;
  gap: 0 12px;
  align-items: center;
}
.pw-lane-tag {
  font-size: 9.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--text-muted);
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  white-space: nowrap;
  background: var(--surface);
  text-align: center;
}
.pw-lane-nodes { display: flex; align-items: center; gap: 0; }

.pw-node {
  position: relative;
  z-index: 1;  /* sits above the SVG connector layer */
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 12px;
  margin: 0 14px;  /* room between pills for the bezier curves to breathe */
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  font-family: var(--font-sans);
  font-size: 12px;
  color: var(--text);
  white-space: nowrap;
  min-height: 38px;
  flex-shrink: 0;
  transition: background 100ms ease, border-color 100ms ease, box-shadow 100ms ease;
}
.pw-node:hover { background: var(--surface-2); border-color: var(--text-muted); }
.pw-node.active {
  background: var(--text); color: var(--surface);
  border-color: var(--text);
  box-shadow: 0 6px 16px -6px rgba(0,0,0,0.25);
}
.pw-node.active .pw-node-num { color: rgba(255,255,255,0.6); }
.pw-node-num {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}
.pw-node-name { font-weight: 500; letter-spacing: -0.005em; }

/* Step wrapper - only used when a step carries sub-branches. Keeps the main
   pill's horizontal spacing identical to a bare .pw-node so the SVG bezier
   connectors line up regardless of which steps have branches. */
.pw-node-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 0 14px;
  flex-shrink: 0;
}
.pw-node-wrap > .pw-node { margin: 0; }

/* The branch container: a vertical stem dropping from the parent pill,
   then one or more small offshoot pills. Reads as "this happens as part
   of the parent step, automatically, off to the side." */
.pw-node-branches {
  margin-top: 0;
  padding-top: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  position: relative;
}
.pw-node-branches::before {
  content: "";
  position: absolute;
  top: 0;
  left: 50%;
  width: 2px;
  height: 14px;
  background: var(--border);
  transform: translateX(-50%);
}

/* The branch pill itself - smaller, softer than a main step. */
.pw-branch {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 9px 5px 5px;
  background: var(--surface-2);
  border: 1px dashed var(--border);
  border-radius: 999px;
  font-family: var(--font-sans);
  font-size: 10.5px;
  color: var(--text-soft);
  cursor: pointer;
  white-space: nowrap;
  transition: background 100ms ease, border-color 100ms ease, color 100ms ease;
  position: relative;
  z-index: 1;
}
.pw-branch:hover {
  background: var(--surface);
  border-style: solid;
  color: var(--text);
}
.pw-branch.active {
  background: var(--text);
  color: var(--surface);
  border-color: var(--text);
  border-style: solid;
}
.pw-branch-kind {
  font-family: var(--font-mono);
  font-size: 8.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 2px 6px;
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-muted);
  border: 1px solid var(--border);
  line-height: 1;
}
.pw-branch.active .pw-branch-kind {
  background: rgba(255,255,255,0.18);
  color: var(--surface);
  border-color: rgba(255,255,255,0.25);
}
.pw-branch-name { font-weight: 500; letter-spacing: -0.005em; }

/* Per-tone branch colors - apply to dashed border + kind chip so the branch
   still feels visually tied to its parent phase. */
.pw-branch.tone-blue        { border-color: rgba(43,108,176,0.35); }
.pw-branch.tone-blue .pw-branch-kind        { color: var(--accent-blue); border-color: var(--accent-blue-soft); }
.pw-branch.tone-amber       { border-color: rgba(200,150,64,0.35); }
.pw-branch.tone-amber .pw-branch-kind       { color: #82591a; border-color: #f0d8a4; }
.pw-branch.tone-legal       { border-color: rgba(75,85,140,0.35); }
.pw-branch.tone-legal .pw-branch-kind       { color: var(--dept-legal-fg); border-color: var(--dept-legal); }
.pw-branch.tone-green       { border-color: rgba(26,107,60,0.35); }
.pw-branch.tone-green .pw-branch-kind       { color: #1a6b3c; border-color: #b6e5c5; }
.pw-branch.tone-creative    { border-color: rgba(124,75,162,0.35); }
.pw-branch.tone-creative .pw-branch-kind    { color: var(--dept-creative-fg); border-color: var(--dept-creative); }
.pw-branch.tone-executive   { border-color: rgba(45,60,90,0.35); }
.pw-branch.tone-executive .pw-branch-kind   { color: var(--dept-executive-fg); border-color: var(--dept-executive); }
.pw-branch.tone-engineering { border-color: rgba(14,94,87,0.35); }
.pw-branch.tone-engineering .pw-branch-kind { color: var(--dept-engineering-fg); border-color: var(--dept-engineering); }

/* Connector lines between consecutive nodes */
.pw-link {
  display: inline-block;
  width: 14px; height: 1.5px;
  background: var(--border);
  flex-shrink: 0;
}
.pw-link.tone-amber       { background: var(--warn); opacity: 0.4; }
.pw-link.tone-blue        { background: var(--accent-blue); opacity: 0.4; }
.pw-link.tone-legal       { background: var(--dept-legal-fg); opacity: 0.4; }
.pw-link.tone-green       { background: #1a6b3c; opacity: 0.4; }
.pw-link.tone-engineering { background: var(--dept-engineering-fg); opacity: 0.4; }
.pw-link.tone-creative    { background: var(--dept-creative-fg); opacity: 0.4; }
.pw-link.tone-executive   { background: var(--dept-executive-fg); opacity: 0.4; }

/* Arrow between phases */
.pw-arrow {
  display: flex; align-items: center; justify-content: center;
  width: 44px;
  flex-shrink: 0;
  color: var(--text-faint);
  align-self: center;
  padding: 0 4px;
}
.pw-arrow svg { width: 22px; height: 22px; }

/* Everything below this point styled the OLD pathway layout. The new
   renderPathway() no longer emits those classes - the rules are orphaned but
   left in place to avoid touching unrelated selectors. */
.pathway-track {
  min-width: max-content;
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* Phase header bands at the top */
.pathway-phases-row {
  display: flex;
  gap: 2px;
  margin-bottom: 18px;
}
.pathway-phase {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  padding: 10px 14px;
  border-radius: 8px;
  min-width: 0;
  position: relative;
  cursor: default;
}
.pathway-phase-name {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  line-height: 1.1;
}
.pathway-phase-count {
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.02em;
  opacity: 0.7;
  margin-top: 2px;
  font-family: var(--font-mono);
}

/* Phase color tones - light tinted background + matching text */
.pathway-phase.tone-amber     { background: #fff1d8; color: #82591a; }
.pathway-phase.tone-blue      { background: var(--accent-blue-soft); color: var(--accent-blue); }
.pathway-phase.tone-legal     { background: var(--dept-legal);     color: var(--dept-legal-fg); }
.pathway-phase.tone-green     { background: #d3f2dd; color: #1a6b3c; }
.pathway-phase.tone-creative  { background: var(--dept-creative);  color: var(--dept-creative-fg); }
.pathway-phase.tone-executive { background: var(--dept-executive); color: var(--dept-executive-fg); }
.pathway-phase.tone-engineering { background: var(--dept-engineering); color: var(--dept-engineering-fg); }

/* Phase columns row - each column stacks 1+ track rows vertically. */
.pathway-cols-row {
  display: flex;
  align-items: flex-start;
  gap: 2px;
}
.pathway-phase-col {
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-width: 0;
  padding-top: 4px;
}
.pathway-phase-col.is-multi {
  background: rgba(15, 18, 32, 0.015);
  border-radius: 10px;
  padding: 10px 6px 6px;
  gap: 14px;
}

/* One track row inside a phase column: optional label + horizontal node row */
.pathway-track-row {
  display: flex;
  align-items: stretch;
  gap: 10px;
  min-width: 0;
}
.pathway-track-label {
  flex: 0 0 auto;
  align-self: flex-start;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 4px 8px;
  border-radius: 999px;
  margin-top: 14px;        /* visually align with the connector line height */
  white-space: nowrap;
  background: var(--surface);
  border: 1px solid var(--border);
  line-height: 1;
}
.pathway-track-label.tone-amber       { color: #82591a; border-color: #f0d8a4; background: #fff8ea; }
.pathway-track-label.tone-blue        { color: var(--accent-blue);         border-color: var(--accent-blue-soft); background: var(--surface); }
.pathway-track-label.tone-legal       { color: var(--dept-legal-fg);       border-color: var(--dept-legal);       background: var(--surface); }
.pathway-track-label.tone-green       { color: #1a6b3c; border-color: #b6e5c5; background: #eef9f1; }
.pathway-track-label.tone-creative    { color: var(--dept-creative-fg);    border-color: var(--dept-creative);    background: var(--surface); }
.pathway-track-label.tone-executive   { color: var(--dept-executive-fg);   border-color: var(--dept-executive);   background: var(--surface); }
.pathway-track-label.tone-engineering { color: var(--dept-engineering-fg); border-color: var(--dept-engineering); background: var(--surface); }

/* The nodes row inside a track. The line sits behind the dots. */
.pathway-track-nodes {
  flex: 1 1 auto;
  display: flex;
  align-items: flex-start;
  gap: 4px;
  position: relative;
  min-width: 0;
}
.pathway-track-line {
  position: absolute;
  top: 24px;               /* aligns to the vertical center of the dots */
  left: 12%;
  right: 12%;
  height: 2px;
  background: var(--border);
  z-index: 0;
}
.pathway-node {
  flex: 1 0 92px;
  min-width: 92px;
  max-width: 130px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 0 4px;
  background: transparent;
  border: none;
  font: inherit;
  text-align: center;
  cursor: pointer;
  color: var(--text-soft);
  transition: color 100ms ease, transform 100ms ease;
  position: relative;
  z-index: 1;
}
.pathway-node-num {
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}
.pathway-node-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--text-muted);
  transition: border-color 120ms ease, background 120ms ease, transform 120ms ease, box-shadow 120ms ease;
  flex-shrink: 0;
}
.pathway-node-name {
  font-size: 11.5px;
  font-weight: 500;
  line-height: 1.25;
  color: var(--text);
  max-width: 100%;
  overflow-wrap: break-word;
}
.pathway-node:hover { color: var(--text); }
.pathway-node:hover .pathway-node-dot { transform: scale(1.15); }

/* Per-tone node colors */
.pathway-node.tone-amber     .pathway-node-dot { border-color: #c89640; }
.pathway-node.tone-blue      .pathway-node-dot { border-color: var(--accent-blue); }
.pathway-node.tone-legal     .pathway-node-dot { border-color: var(--dept-legal-fg); }
.pathway-node.tone-green     .pathway-node-dot { border-color: var(--ok); }
.pathway-node.tone-creative  .pathway-node-dot { border-color: var(--dept-creative-fg); }
.pathway-node.tone-executive .pathway-node-dot { border-color: var(--dept-executive-fg); }
.pathway-node.tone-engineering .pathway-node-dot { border-color: var(--dept-engineering-fg); }

/* Active node (one currently shown in the detail card) */
.pathway-node.active .pathway-node-dot {
  background: currentColor;
  transform: scale(1.25);
  box-shadow: 0 0 0 4px rgba(0,0,0,0.04);
}
.pathway-node.active.tone-amber     .pathway-node-dot { background: #c89640; }
.pathway-node.active.tone-blue      .pathway-node-dot { background: var(--accent-blue); }
.pathway-node.active.tone-legal     .pathway-node-dot { background: var(--dept-legal-fg); }
.pathway-node.active.tone-green     .pathway-node-dot { background: var(--ok); }
.pathway-node.active.tone-creative  .pathway-node-dot { background: var(--dept-creative-fg); }
.pathway-node.active.tone-executive .pathway-node-dot { background: var(--dept-executive-fg); }
.pathway-node.active.tone-engineering .pathway-node-dot { background: var(--dept-engineering-fg); }

/* Detail card - shows below the track when a node is clicked */
.pathway-detail {
  margin-top: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}
.pathway-detail[hidden] { display: none; }
.pathway-detail-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 18px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}
.pathway-detail-eyebrow {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 2px;
}
.pathway-detail-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.005em;
}
.pathway-detail-body {
  padding: 16px 18px 18px;
}
.pathway-detail-summary {
  margin: 0 0 16px;
  font-size: 13.5px;
  color: var(--text-soft);
  line-height: 1.55;
}
.pathway-detail-section {
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.pathway-detail-section + .pathway-detail-section { margin-top: 12px; }
.pathway-detail-label {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.pathway-detail-owners {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.pathway-detail-owner {
  display: flex;
  align-items: center;
  gap: 10px;
}
.pathway-owner-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.pathway-owner-role {
  font-size: 11.5px;
  color: var(--text-muted);
}
.pathway-detail-jump {
  display: inline-block;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--accent-blue);
  text-decoration: none;
  padding: 6px 0;
}
.pathway-detail-jump:hover { text-decoration: underline; }

.pathway-empty {
  padding: 40px 16px;
  text-align: center;
  font-size: 12.5px;
  color: var(--text-muted);
}

/* Funnel-style Pathway: multiple awareness lanes converge into one booked call. */
.pathway-flow-board {
  min-width: 1180px;
}
.pathway-flow-head {
  display: grid;
  grid-template-columns: 320px 190px minmax(620px, 1fr);
  gap: 18px;
  margin-bottom: 10px;
  color: var(--text-muted);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.pathway-flow-grid {
  display: grid;
  grid-template-columns: 320px 190px minmax(620px, 1fr);
  gap: 18px;
  align-items: stretch;
  position: relative;
}
.pathway-flow-grid::before {
  content: "";
  position: absolute;
  left: 314px;
  right: 0;
  top: 50%;
  height: 2px;
  background: linear-gradient(90deg, #f0d8a4, var(--accent-blue-soft), var(--border));
  transform: translateY(-1px);
  z-index: 0;
}
.pathway-awareness-panel,
.pathway-booked-panel,
.pathway-lifecycle-panel {
  position: relative;
  z-index: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
}
.pathway-awareness-panel {
  padding: 16px;
  box-shadow: var(--shadow-card);
}
.pathway-panel-kicker,
.pathway-converge-label {
  color: var(--text-faint);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}
.pathway-awareness-panel h3 {
  margin: 4px 0 5px;
  color: #82591a;
  font-size: 16px;
  letter-spacing: -0.01em;
}
.pathway-awareness-panel p {
  margin: 0 0 14px;
  color: var(--text-soft);
  font-size: 12.5px;
  line-height: 1.5;
}
.pathway-channel-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.pathway-channel-lane {
  border: 1px solid #f0d8a4;
  background: #fff8ea;
  border-radius: 12px;
  padding: 10px;
  position: relative;
}
.pathway-channel-lane::after {
  content: "";
  position: absolute;
  left: 100%;
  top: 50%;
  width: 18px;
  height: 2px;
  background: #f0d8a4;
}
.pathway-channel-label {
  color: #82591a;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 8px;
}
.pathway-channel-nodes {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
.pathway-channel-node.pathway-node,
.pathway-booked-node.pathway-node,
.pathway-lifecycle-node.pathway-node {
  flex: initial;
  min-width: 0;
  max-width: none;
  padding: 0;
  border: none;
  background: transparent;
}
.pathway-channel-node.pathway-node {
  width: 128px;
}
.pathway-channel-node .pathway-node-name,
.pathway-booked-node .pathway-node-name,
.pathway-lifecycle-node .pathway-node-name {
  display: block;
}
.pathway-booked-panel {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 18px 14px;
  box-shadow: 0 0 0 1px rgba(31,111,235,0.08), var(--shadow-card);
}
.pathway-booked-panel::before,
.pathway-booked-panel::after {
  content: "";
  position: absolute;
  top: 50%;
  width: 18px;
  height: 2px;
  background: var(--accent-blue-soft);
}
.pathway-booked-panel::before { right: 100%; }
.pathway-booked-panel::after { left: 100%; }
.pathway-booked-node.pathway-node {
  width: 140px;
  min-height: 132px;
  justify-content: center;
  padding: 14px 10px;
  border-radius: 14px;
  border: 1px solid var(--accent-blue-soft);
  background: linear-gradient(180deg, var(--surface), #f7faff);
}
.pathway-booked-node .pathway-node-dot {
  width: 22px;
  height: 22px;
  border-width: 3px;
}
.pathway-booked-node .pathway-node-name {
  font-size: 13px;
  font-weight: 800;
}
.pathway-lifecycle-panel {
  padding: 14px 16px;
  overflow: hidden;
  box-shadow: var(--shadow-card);
}
.pathway-lifecycle-scroll {
  display: flex;
  gap: 14px;
  overflow-x: auto;
  padding-bottom: 4px;
}
.pathway-lifecycle-phase {
  flex: 0 0 auto;
  min-width: 210px;
}
.pathway-mini-phase {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 42px;
  padding: 9px 11px;
  border-radius: 10px;
  margin-bottom: 14px;
}
.pathway-mini-phase span {
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  line-height: 1.15;
}
.pathway-mini-phase strong {
  font-family: var(--font-mono);
  font-size: 11px;
}
.pathway-mini-phase.tone-blue      { background: var(--accent-blue-soft); color: var(--accent-blue); }
.pathway-mini-phase.tone-legal     { background: var(--dept-legal); color: var(--dept-legal-fg); }
.pathway-mini-phase.tone-engineering { background: var(--dept-engineering); color: var(--dept-engineering-fg); }
.pathway-mini-phase.tone-green     { background: #d3f2dd; color: #1a6b3c; }
.pathway-mini-phase.tone-creative  { background: var(--dept-creative); color: var(--dept-creative-fg); }
.pathway-mini-phase.tone-executive { background: var(--dept-executive); color: var(--dept-executive-fg); }
.pathway-lifecycle-nodes {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  position: relative;
}
.pathway-lifecycle-node.pathway-node {
  width: 96px;
}
.pathway-lifecycle-nodes .pathway-track-line {
  left: 48px;
  right: 48px;
}

@media (max-width: 900px) {
  .body.pathway-body { padding: 16px; }
  .pathway-flow-board { min-width: 980px; }
  .pathway-flow-head,
  .pathway-flow-grid {
    grid-template-columns: 280px 170px minmax(520px, 1fr);
  }
  .pathway-channel-node.pathway-node { width: 112px; }
}

/* ============================================================
   Deals - Pipeline view + Stage chips + MSA modal + Rail activity
   ============================================================ */

/* Activity log inside the client rail (every contract event for this deal). */
.rail-section-count {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  background: var(--surface-2);
  color: var(--text-muted);
  border-radius: var(--radius-pill, 999px);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: none;
  vertical-align: 1px;
}
.rail-empty-inline {
  padding: 12px;
  background: var(--surface);
  border: 1px dashed var(--hairline);
  border-radius: 8px;
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
}
.rail-activity {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.rail-activity-entry {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 10px;
  align-items: flex-start;
  padding: 10px 0;
  border-bottom: 1px solid var(--hairline);
}
.rail-activity-entry:last-child { border-bottom: 0; }
.rail-activity-icon {
  width: 24px; height: 24px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  margin-top: 2px;
}
.rail-activity-icon svg { width: 12px; height: 12px; }
.rail-activity-content { min-width: 0; }
.rail-activity-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}
.rail-activity-event {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
}
.rail-activity-time {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.rail-activity-sub {
  font-size: 11.5px;
  color: var(--text-soft);
  margin-top: 1px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.rail-activity-actor {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}
.rail-activity-email { color: var(--accent-blue); }
.rail-activity-detail {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 4px;
  line-height: 1.45;
}

/* Agreed payment schedule (Payments tab in client rail) */
.payment-block {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  margin-bottom: 14px;
  overflow: hidden;
}
.payment-block-head {
  padding: 12px 14px;
  border-bottom: 1px solid var(--hairline);
  background: var(--surface-2);
}
.payment-block-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.payment-block-meta {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 2px;
}
.payment-summary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--hairline);
}
.payment-summary-cell {
  background: var(--surface);
  padding: 10px 14px;
}
.payment-summary-value {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.payment-summary-of {
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-muted);
  margin-left: 1px;
}
.payment-summary-label {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-top: 1px;
}
.payment-list { display: flex; flex-direction: column; }
.payment-row {
  display: grid;
  grid-template-columns: 18px 1fr;
  align-items: center;
  gap: 12px;
  padding: 14px 16px 14px 14px;
  padding-right: 110px;             /* reserve room for the absolute right column */
  border-top: 1px solid var(--hairline);
  position: relative;
  min-height: 68px;                  /* keeps paid + unpaid rows the same height */
  transition: background 120ms ease;
}
.payment-list .payment-row:first-child { border-top: 0; }
.payment-row.is-received {
  background: linear-gradient(to right, rgba(22,163,74,0.028), transparent 240px);
}
.payment-row.is-received::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 2px;
  background: rgba(22, 163, 74, 0.42);
}
.payment-check {
  width: 15px; height: 15px;
  border: 1.5px solid var(--border-strong, var(--text-faint));
  border-radius: 3.5px;
  background: var(--surface);
  cursor: pointer;
  padding: 0;
  display: grid;
  place-items: center;
  color: #fff;
  transition: background 100ms ease, border-color 100ms ease;
}
.payment-check:hover { border-color: var(--text-soft); }
.payment-row.is-received .payment-check {
  background: #16a34a;
  border-color: #16a34a;
}
.payment-main { min-width: 0; }
.payment-num {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.payment-due {
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
.payment-receipt-line {
  margin-top: 3px;
  color: var(--text-muted);
  font-size: 10.8px;
  line-height: 1.35;
  font-variant-numeric: tabular-nums;
}
.payment-amount {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
/* Paid rows: keep readable - just colored amount + green accent + method chip.
   No line-through, no muting. The user wants the info visible, not faded. */
.payment-row.is-received .payment-amount { color: #1a6b3c; }

/* Meta row inside payment-main: holds either the method+datetime (paid) or
   the "Due date" (unpaid). One line, tight. */
.payment-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
  font-size: 11.5px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
.payment-meta-due { color: var(--text-muted); }
.payment-meta-when { color: var(--text-muted); }
.payment-meta-sep { color: var(--text-faint, var(--text-muted)); }
/* Method appears as plain inline text on the meta line - no chip / no dot. */
.payment-method-text {
  color: var(--text);
  font-weight: 600;
}
.payment-method-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-muted);
  flex-shrink: 0;
}
.payment-method-dot.tone-stripe { background: #6772e5; }
.payment-method-dot.tone-wire   { background: #4060d0; }
.payment-method-dot.tone-zelle  { background: #9b59b6; }
.payment-method-dot.tone-check  { background: #c08a2c; }
.payment-method-dot.tone-cash   { background: #16a34a; }
.payment-method-dot.tone-any    { background: var(--text-muted); }

/* Top-right cluster: method label (plain text) + receipt icon (no chrome). */
.payment-corner-top {
  position: absolute;
  top: 12px;
  right: 14px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.payment-method-text {
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: 0.01em;
}
/* Bottom-right cluster: amount only. Consistent position for every row. */
.payment-corner-bottom {
  position: absolute;
  bottom: 12px;
  right: 14px;
}
/* Receipt icon: top-right, no border / background / box. Just the glyph. */
.payment-receipt-btn {
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  background: transparent;
  padding: 0;
  color: var(--text-muted);
  cursor: pointer;
  transition: color 100ms ease, transform 100ms ease;
}
.payment-receipt-btn:hover {
  color: var(--text);
  transform: translateY(-1px);
}

/* Method picker popover (anchored to the clicked element, position: fixed) */
.payment-picker {
  z-index: 200;
  min-width: 260px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow:
    0 1px 2px rgba(0,0,0,0.04),
    0 12px 32px -8px rgba(20,18,14,0.22),
    0 4px 12px -4px rgba(20,18,14,0.10);
  animation: pbStageMenuIn 120ms ease-out;
}
.payment-picker-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 6px 10px 8px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text);
}
.payment-picker-head small {
  font-size: 10.5px;
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
  color: var(--text-muted);
}
.payment-picker-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.payment-picker-item {
  display: grid;
  grid-template-columns: 10px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 0;
  background: transparent;
  border-radius: 6px;
  font: inherit;
  font-size: 12.5px;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  transition: background 100ms ease;
}
.payment-picker-item:hover { background: var(--surface-2); }
.payment-picker-item.is-current {
  background: var(--surface-3, #ecebe7);
  font-weight: 600;
}
.payment-picker-item-label { font-weight: 600; }
.payment-picker-item-blurb {
  font-size: 10.5px;
  color: var(--text-muted);
  font-weight: 500;
}

/* ============================================================
   RECEIPT MODAL - mock document
   ============================================================ */
.modal-drawer-md { max-width: 560px; }
.receipt-modal-body { padding: 18px 22px; background: var(--surface-2); }
.receipt-doc {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 24px 28px;
  font-size: 13px;
  color: var(--text);
  line-height: 1.45;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.receipt-doc-head {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--hairline, rgba(0,0,0,0.08));
}
.receipt-doc-brand { display: flex; align-items: center; gap: 12px; flex: 1; }
.receipt-doc-brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 6px;
  background: var(--text);
  color: var(--surface);
  display: grid;
  place-items: center;
  font-family: var(--font-mono, ui-monospace, monospace);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.02em;
}
.receipt-doc-brand-name {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: var(--text);
}
.receipt-doc-brand-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}
.receipt-doc-badge {
  padding: 4px 12px;
  border-radius: 999px;
  background: #d3f2dd;
  color: #1a6b3c;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
}
.receipt-doc-id-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  padding: 16px 0;
  border-bottom: 1px solid var(--hairline, rgba(0,0,0,0.06));
}
.receipt-doc-id-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}
.receipt-doc-id-value {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-top: 4px;
  font-family: var(--font-mono, ui-monospace, monospace);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}
.receipt-doc-parties {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  padding: 18px 0;
  border-bottom: 1px solid var(--hairline, rgba(0,0,0,0.06));
}
.receipt-doc-party-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.receipt-doc-party-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}
.receipt-doc-party-meta {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 2px;
}
.receipt-doc-table {
  width: 100%;
  border-collapse: collapse;
  margin: 18px 0;
}
.receipt-doc-table thead th {
  text-align: left;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  padding: 0 0 8px;
  border-bottom: 1px solid var(--hairline, rgba(0,0,0,0.08));
}
.receipt-doc-table th.num, .receipt-doc-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.receipt-doc-table tbody td {
  padding: 12px 0;
  font-size: 13px;
  color: var(--text);
}
.receipt-doc-item-name { font-weight: 600; }
.receipt-doc-item-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 3px;
}
.receipt-doc-table tfoot td {
  padding: 12px 0 4px;
  border-top: 2px solid var(--text);
  font-size: 13px;
}
.receipt-doc-total-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}
.receipt-doc-total-amount { font-size: 16px; font-weight: 700; }
.receipt-doc-meta-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  padding: 16px 0 0;
  border-top: 1px solid var(--hairline, rgba(0,0,0,0.06));
}
.receipt-doc-meta-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.receipt-doc-meta-value {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
}
.receipt-doc-foot {
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid var(--hairline, rgba(0,0,0,0.06));
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.5;
  font-style: italic;
}
.payment-log {
  border-top: 1px solid var(--hairline);
  background: var(--surface);
}
.payment-log-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 14px 8px;
  color: var(--text);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.payment-log-head small {
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
}
.payment-log-list {
  display: flex;
  flex-direction: column;
  padding: 0 14px 12px;
}
.payment-log-row {
  display: grid;
  grid-template-columns: 8px minmax(0, 1fr) auto;
  gap: 9px;
  padding: 8px 0;
  border-top: 1px solid var(--hairline);
}
.payment-log-row:first-child { border-top: 0; }
.payment-log-dot {
  width: 7px;
  height: 7px;
  margin-top: 5px;
  border-radius: 999px;
  background: #16a34a;
  box-shadow: 0 0 0 3px color-mix(in srgb, #16a34a 12%, transparent);
}
.payment-log-row.is-reversed .payment-log-dot {
  background: var(--text-faint);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--text-faint) 15%, transparent);
}
.payment-log-main { min-width: 0; }
.payment-log-title {
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.3;
}
.payment-log-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 8px;
  margin-top: 3px;
  color: var(--text-muted);
  font-size: 10.8px;
  line-height: 1.35;
}
.payment-log-meta span + span::before {
  content: "·";
  margin-right: 8px;
  color: var(--text-faint);
}
.payment-log-time {
  color: var(--text-muted);
  font-size: 10.8px;
  line-height: 1.35;
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.payment-log-empty {
  padding: 11px 14px 13px;
  border-top: 1px solid var(--hairline);
  color: var(--text-muted);
  font-size: 11.5px;
  line-height: 1.45;
}
.client-payments-schedule {
  max-width: 760px;
}

.pipeline-row {
  grid-template-columns: minmax(220px, 1.6fr) 140px 140px 120px;
  gap: 16px;
}
.pipeline-row .col-stage { display: flex; align-items: center; }
.stage-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: var(--radius-pill, 999px);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.stage-pill .stage-dot,
.stage-dot {
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}
.stage-pill.s-new        { background: #f1f5f9; color: #64748b; }
.stage-pill.s-nda-sent   { background: #fef3c7; color: #92400e; }
.stage-pill.s-nda-signed { background: #dbeafe; color: #1d4ed8; }
.stage-pill.s-msa-sent   { background: #fef3c7; color: #92400e; }
.stage-pill.s-active     { background: #dcfce7; color: #166534; }
.stage-dot.s-nda-sent   { background: #f59e0b; }
.stage-dot.s-nda-signed { background: #3b82f6; }
.stage-dot.s-msa-sent   { background: #f59e0b; }
.stage-dot.s-active     { background: #16a34a; }
.row-action-btn.primary {
  background: var(--text);
  color: var(--surface);
  border-color: var(--text);
}
.row-action-btn.primary:hover { opacity: 0.9; }

/* MSA modal: locked recipient header */
.msa-recipient { margin-bottom: 18px; }
.msa-recipient-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  border-radius: 12px;
}
.msa-recipient-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--text);
  color: var(--surface);
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  flex-shrink: 0;
}
.msa-recipient-info { flex: 1; min-width: 0; }
.msa-recipient-name { font-size: 13.5px; font-weight: 600; color: var(--text); }
.msa-recipient-meta { font-size: 12px; color: var(--text-muted); margin-top: 1px; }
.msa-recipient-tag {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-soft);
  background: var(--surface);
  padding: 3px 8px;
  border-radius: var(--radius-pill, 999px);
  border: 1px solid var(--hairline);
}

@media (max-width: 720px) {
  .pipeline-row { grid-template-columns: 1fr; gap: 8px; }
  .pipeline-row .col-stage,
  .pipeline-row .col-date { font-size: 11.5px; }
  .pipeline-row.is-header { display: none; }
}

/* ============================================================
   Contracts - Send flow (landing tab)
   ============================================================ */
.contracts-send-body {
  flex: 1;
  overflow: auto;
  padding: 24px 28px 40px;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  gap: 22px;
}
/* Accordion step container */
.send-step {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  overflow: hidden;
  transition: border-color 150ms ease, opacity 150ms ease;
}
.send-step[data-state="locked"] {
  opacity: 0.55;
  pointer-events: none;
}
.send-step[data-state="open"] {
  border-color: var(--text);
}
.send-step-head {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  cursor: default;
}
.send-step[data-state="done"] .send-step-head { cursor: pointer; }
.send-step[data-state="done"] .send-step-head:hover { background: var(--surface-2); }
.send-step-num {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  background: var(--surface-2);
  color: var(--text-soft);
  border-radius: 50%;
  font-size: 12px;
  font-weight: 700;
  flex: 0 0 26px;
  border: 1px solid var(--border);
  transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
}
.send-step[data-state="open"] .send-step-num   { background: var(--text); color: var(--surface); border-color: var(--text); }
.send-step[data-state="done"] .send-step-num   { background: #16a34a; color: #fff; border-color: #16a34a; font-size: 0; }
.send-step[data-state="done"] .send-step-num::after { content: "✓"; font-size: 13px; font-weight: 700; }
.send-step-titles { flex: 1; min-width: 0; }
.send-step-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}
.send-step-summary {
  margin-top: 2px;
  font-size: 12.5px;
  color: var(--text-muted);
  display: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.send-step[data-state="done"] .send-step-summary { display: block; }
.send-step-edit {
  display: none;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent-blue, #2563EB);
  padding: 6px 10px;
  border-radius: 6px;
  background: transparent;
  border: 0;
  cursor: pointer;
}
.send-step[data-state="done"] .send-step-edit { display: inline-flex; }
.send-step-edit:hover { background: var(--surface-2); }
.send-step-body {
  padding: 4px 18px 18px;
  border-top: 1px solid var(--hairline);
}
.send-step[data-state="done"] .send-step-body,
.send-step[data-state="locked"] .send-step-body { display: none; }
.send-cards {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.send-card {
  --card-accent: var(--text);
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-align: left;
  padding: 18px 18px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  cursor: pointer;
  transition: border-color 100ms ease, box-shadow 120ms ease, transform 100ms ease;
  position: relative;
}
.send-card:hover {
  border-color: var(--border-strong, var(--text-faint));
  box-shadow: 0 1px 3px rgba(0,0,0,0.04), 0 4px 12px rgba(0,0,0,0.04);
}
.send-card.selected {
  border-color: var(--card-accent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--card-accent) 18%, transparent);
}
.send-card.selected::after {
  content: "";
  position: absolute;
  top: 12px; right: 12px;
  width: 18px; height: 18px;
  background: var(--card-accent);
  border-radius: 50%;
  box-shadow: inset 0 0 0 4px var(--surface);
  border: 1px solid var(--card-accent);
}
.send-card-icon {
  display: inline-grid;
  place-items: center;
  width: 38px; height: 38px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--card-accent) 10%, var(--surface-2));
  color: var(--card-accent);
}
.send-card-name {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
}
.send-card-blurb {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.45;
  flex: 1;
}
.send-card-tag {
  align-self: flex-start;
  margin-top: 2px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-soft);
  background: var(--surface-2);
  padding: 3px 8px;
  border-radius: var(--radius-pill, 999px);
}
.send-card-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.send-pkg-badge {
  display: inline-grid;
  place-items: center;
  width: 32px; height: 32px;
  border-radius: 8px;
  color: #fff;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.03em;
}
.send-pkg-price {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.send-empty {
  padding: 22px;
  border: 1px dashed var(--border);
  border-radius: 12px;
  background: var(--surface);
  font-size: 12.5px;
  color: var(--text-muted);
  text-align: center;
  grid-column: 1 / -1;
}

/* Minimal row list (used for programs + payment plans) */
.send-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.send-row {
  display: grid;
  grid-template-columns: 26px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  text-align: left;
  font: inherit;
  transition: background 100ms ease, border-color 100ms ease, box-shadow 100ms ease;
}
.send-row:hover { background: var(--surface-2); }
.send-row.selected {
  border-color: var(--text);
  box-shadow: inset 0 0 0 1px var(--text);
  background: var(--surface);
}
.send-row--pay { grid-template-columns: 1fr auto; }
.send-row-badge {
  width: 26px; height: 26px;
  border-radius: 6px;
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.send-row-name {
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.send-row.selected .send-row-name { font-weight: 600; }
.send-row-price {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* Payment-method rows: two-line name (strong + sub) instead of nowrap ellipsis */
.send-row--method {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
}
.send-row--method .send-row-name {
  display: flex;
  flex-direction: column;
  gap: 2px;
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  font-weight: 500;
}
.send-row--method .send-row-name strong {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
}
.send-row-sub {
  font-size: 11.5px;
  font-weight: 400;
  color: var(--text-muted);
  line-height: 1.35;
}
.send-row-tag {
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 3px 7px;
  border-radius: 999px;
  background: var(--surface-2, rgba(0,0,0,0.05));
  color: var(--text-muted);
  white-space: nowrap;
}
.send-row.selected .send-row-tag {
  background: var(--text);
  color: var(--surface);
}
@media (max-width: 560px) {
  .deal-recipient-picker-head {
    align-items: flex-start;
    flex-direction: column;
  }
  .send-row--method {
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
  }
  .send-row--method .send-row-tag {
    justify-self: start;
  }
}

/* Segmented picker (used for language inside Start-a-Deal) */
.deal-recipient-picker-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.seg-picker {
  display: inline-flex;
  gap: 4px;
  padding: 3px;
  background: var(--surface-2, rgba(0,0,0,0.04));
  border-radius: 8px;
  border: 1px solid var(--border);
  align-self: start;
}
.seg-pill {
  padding: 6px 14px;
  border: 0;
  background: transparent;
  border-radius: 6px;
  font: inherit;
  font-size: 12.5px;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease;
}
.seg-pill:hover { color: var(--text); }
.seg-pill.active {
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}

/* Full-width send-field (used for the special-terms textarea) */
.send-field--full {
  grid-column: 1 / -1;
}
.send-field textarea {
  font: inherit;
  font-size: 13px;
  color: var(--text);
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  resize: vertical;
  min-height: 64px;
}
.send-field textarea:focus {
  outline: none;
  border-color: var(--text-muted);
  box-shadow: 0 0 0 3px rgba(0,0,0,0.04);
}

/* Start-a-Deal: tighten step bodies so 5 collapsible sections fit comfortably */
#startDealModal .send-step + .send-step { margin-top: 10px; }
#startDealModal .modal-body { padding-bottom: 12px; }

/* NDA opt-in checkbox */
.send-toggle {
  display: grid;
  grid-template-columns: 18px 1fr;
  gap: 10px;
  padding: 10px 14px;
  margin-bottom: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  align-items: start;
  transition: background 100ms ease;
}
.send-toggle:hover { background: var(--surface-2); }
.send-toggle input { position: absolute; opacity: 0; pointer-events: none; }
.send-toggle-box {
  width: 18px; height: 18px;
  border: 1.5px solid var(--border-strong, var(--text-faint));
  border-radius: 4px;
  background: var(--surface);
  margin-top: 1px;
  position: relative;
  transition: background 100ms ease, border-color 100ms ease;
}
.send-toggle input:checked ~ .send-toggle-box {
  background: var(--text);
  border-color: var(--text);
}
.send-toggle input:checked ~ .send-toggle-box::after {
  content: "";
  position: absolute;
  inset: 2px;
  background: no-repeat center / 12px url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'><polyline points='5 12 10 17 19 7'/></svg>");
}
.send-toggle-copy { display: flex; flex-direction: column; gap: 2px; }
.send-toggle-text { font-size: 13px; font-weight: 500; color: var(--text); }
.send-toggle-sub  { font-size: 11.5px; color: var(--text-muted); }

/* Recipient mode tabs */
.send-recipient-tabs {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  background: var(--surface-2);
  border-radius: 10px;
  margin-bottom: 14px;
}
.send-pill {
  padding: 7px 14px;
  background: transparent;
  border: 0;
  border-radius: 7px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 100ms ease, color 100ms ease;
}
.send-pill:hover { color: var(--text-soft); }
.send-pill.active {
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}

/* New-client form */
.send-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  max-width: 640px;
}
.send-form-grid .send-field { gap: 4px; }
.send-field-label {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-soft);
  letter-spacing: 0.02em;
}
.send-field-opt {
  margin-left: 4px;
  font-size: 10.5px;
  font-weight: 500;
  color: var(--text-faint);
  text-transform: uppercase;
}
.send-form-grid .send-field input {
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  font: inherit;
  font-size: 13px;
  color: var(--text);
  width: 100%;
}
.send-form-grid .send-field input:focus {
  outline: 2px solid color-mix(in srgb, var(--accent-blue) 35%, transparent);
  outline-offset: 1px;
  border-color: var(--text);
}
.send-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.send-field--compact {
  align-items: flex-start;
  margin-bottom: 10px;
}
.send-select {
  appearance: none;
  -webkit-appearance: none;
  padding: 10px 36px 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface) url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>") right 12px center / 12px no-repeat;
  font: inherit;
  font-size: 13px;
  color: var(--text);
  width: 100%;
  max-width: 640px;
  cursor: pointer;
}
.send-select:disabled { cursor: not-allowed; color: var(--text-faint); }
.send-select:focus { outline: 2px solid color-mix(in srgb, var(--accent-blue) 35%, transparent); outline-offset: 1px; }
.send-field-hint {
  font-size: 11.5px;
  color: var(--text-muted);
  min-height: 14px;
}
.send-footer {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
  padding-top: 6px;
  border-top: 1px solid var(--hairline);
  margin-top: 4px;
  padding-top: 18px;
}
@media (max-width: 720px) {
  .contracts-send-body { padding: 16px 14px 32px; gap: 14px; }
  .send-step-head { gap: 12px; padding: 14px 14px; }
  .send-step-body { padding: 4px 14px 16px; }
  .send-row { padding: 11px 12px; }
  .send-form-grid { grid-template-columns: 1fr; gap: 10px; }
  .send-footer { flex-direction: column-reverse; align-items: stretch; }
  .send-footer .btn-primary, .send-footer .btn-ghost { width: 100%; justify-content: center; }
}

/* ============================================================
   INVITATIONS PAGE
   Unified view of all portal invites - clients, team, students.
   ============================================================ */

.invites-new-wrap {
  position: relative;
  display: inline-block;
}
.invites-new-menu {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: 260px;
  padding: 5px;
  background: var(--bg);
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: 14px;
  box-shadow:
    -4px -4px 12px var(--shadow-light),
    8px 12px 24px var(--shadow-dark);
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
/* The class rule above wins the specificity fight against the browser's
   default [hidden] { display: none }. Force-hide when the attribute is set. */
.invites-new-menu[hidden] { display: none; }
.invites-new-item {
  display: flex;
  gap: 11px;
  align-items: center;
  padding: 10px 12px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  font-size: 13px;
  transition: background-color 120ms ease, color 120ms ease;
}
.invites-new-item:hover,
.invites-new-item:focus-visible {
  background: var(--surface-2, rgba(0, 0, 0, 0.04));
  outline: none;
}
.invites-new-item:hover svg,
.invites-new-item:focus-visible svg {
  color: var(--text);
}
.invites-new-item:active {
  background: rgba(0, 0, 0, 0.08);
}
.invites-new-item svg {
  width: 17px;
  height: 17px;
  flex-shrink: 0;
  color: var(--text-muted);
  transition: color 120ms ease;
}
.invites-new-item > div {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}
.invites-new-title {
  font-weight: 600;
  color: var(--text);
  font-size: 13px;
  line-height: 1.25;
}
.invites-new-sub {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.3;
}

/* Client picker modal - opens when "Invite client" is clicked from the
   New invite dropdown. Lists clients with a search box. */
.client-picker-search {
  position: relative;
  margin-bottom: 12px;
}
.client-picker-search input {
  width: 100%;
  padding: 10px 12px 10px 36px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 10px;
  background: var(--bg-soft);
  font-family: inherit;
  font-size: 13px;
  color: var(--text);
}
.client-picker-search svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
}
.client-picker-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 380px;
  overflow-y: auto;
  padding-right: 2px;
}
.client-picker-row {
  display: grid;
  grid-template-columns: 32px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  background: var(--bg);
  border: 1px solid rgba(0, 0, 0, 0.04);
  border-radius: 10px;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  transition: background-color 120ms ease, border-color 120ms ease;
}
.client-picker-row:hover {
  background: var(--bg-soft);
  border-color: rgba(0, 0, 0, 0.08);
}
.client-picker-row .client-picker-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6b85d0, #4a64b8);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.client-picker-meta {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}
.client-picker-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.client-picker-sub {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.client-picker-status {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  padding: 3px 8px;
  border-radius: 999px;
  white-space: nowrap;
}
.client-picker-status[data-status="not-invited"] { background: rgba( 86, 116, 198, 0.12); color: #4a64b8; }
.client-picker-status[data-status="invited"]     { background: rgba(214, 167,  74, 0.18); color: #a87528; }
.client-picker-status[data-status="activated"]   { background: rgba( 76, 156, 130, 0.16); color: #2f7d5e; }
.client-picker-status[data-status="expired"]     { background: rgba(184, 184, 184, 0.20); color: #707070; }
.client-picker-empty {
  padding: 30px 12px;
  text-align: center;
  color: var(--text-muted);
  font-size: 12.5px;
}

.invites-filters {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  padding: 16px 24px 8px;
}
.filter-chips {
  display: inline-flex;
  gap: 6px;
  padding: 4px;
  background: var(--bg-soft);
  border-radius: 999px;
  box-shadow:
    inset 2px 2px 5px var(--shadow-dark),
    inset -2px -2px 5px var(--shadow-light);
}
.filter-chips.status {
  margin-left: auto;
}
.filter-chips .chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 160ms ease;
}
.filter-chips .chip:hover {
  color: var(--text);
}
.filter-chips .chip.active {
  background: var(--bg);
  color: var(--text);
  box-shadow:
    -3px -3px 6px var(--shadow-light),
    3px 3px 6px var(--shadow-dark);
}
.filter-chips .chip-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: rgba(0, 0, 0, 0.06);
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
}
.filter-chips .chip.active .chip-count {
  background: var(--accent-soft, rgba(120, 140, 200, 0.18));
  color: var(--text);
}

.invites-body {
  padding: 8px 24px 32px;
}
.invites-table {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.invites-row {
  display: grid;
  grid-template-columns:
    minmax(220px, 1.6fr)   /* recipient (avatar + name + email) */
    minmax(90px, auto)     /* audience badge */
    minmax(140px, 1fr)     /* role / package / program */
    minmax(120px, 0.9fr)   /* invited by */
    minmax(80px, auto)     /* sent (relative) */
    minmax(100px, auto)    /* status pill */
    36px;                  /* kebab */
  align-items: center;
  gap: 16px;
  padding: 12px 16px;
  background: var(--bg);
  border-radius: 14px;
  box-shadow:
    -3px -3px 7px var(--shadow-light),
    3px 3px 7px var(--shadow-dark);
}
.invites-row:hover {
  box-shadow:
    -5px -5px 10px var(--shadow-light),
    5px 5px 10px var(--shadow-dark);
}
.invites-recipient {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.invites-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  letter-spacing: 0.3px;
}
.invites-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.invites-email {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.invites-recipient-text {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.audience-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  white-space: nowrap;
}
.audience-badge[data-audience="client"]  { background: rgba( 86, 116, 198, 0.14); color: #4a64b8; }
.audience-badge[data-audience="team"]    { background: rgba( 76, 156, 130, 0.14); color: #2f7d5e; }
.audience-badge[data-audience="student"] { background: rgba(192, 130,  82, 0.16); color: #a05e2c; }

.invites-detail,
.invites-inviter,
.invites-sent {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.invites-detail { color: var(--text); }

.invites-kebab {
  position: relative;
}
.invites-kebab-btn {
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.invites-kebab-btn:hover {
  background: var(--bg-soft);
}
.invites-kebab-menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  min-width: 180px;
  padding: 5px;
  background: var(--bg);
  border-radius: 12px;
  box-shadow:
    -5px -5px 12px var(--shadow-light),
    5px 5px 12px var(--shadow-dark);
  z-index: 18;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.invites-kebab-menu button {
  padding: 8px 11px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  text-align: left;
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
}
.invites-kebab-menu button:hover {
  background: var(--bg-soft);
}
.invites-kebab-menu button.danger {
  color: #c44a4a;
}

/* Status pills for unified Invites page - reuses portal-pill values
   plus a "revoked" state.  pending == invited.  */
.invites-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.invites-status[data-status="pending"]   { background: rgba(214, 167,  74, 0.16); color: #a87528; }
.invites-status[data-status="activated"] { background: rgba( 76, 156, 130, 0.16); color: #2f7d5e; }
.invites-status[data-status="expired"]   { background: rgba(184, 184, 184, 0.18); color: #707070; }
.invites-status[data-status="revoked"]   { background: rgba(196,  74,  74, 0.14); color: #a23d3d; }

/* Avatar tint by audience (overrides dept- variants on the unified page).
   Department colors continue to apply on the org chart. */
.invites-avatar[data-audience="client"]  { background: linear-gradient(135deg, #6b85d0, #4a64b8); }
.invites-avatar[data-audience="team"]    { background: linear-gradient(135deg, #5fb592, #2f7d5e); }
.invites-avatar[data-audience="student"] { background: linear-gradient(135deg, #d2986a, #a05e2c); }

/* Documents fieldset inside the team invite modal */
.invite-docs {
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: 12px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--bg-soft);
  margin: 0;
}
.invite-docs legend {
  padding: 0 6px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}
.invite-docs-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.invite-docs-row.check {
  flex-direction: row;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
}
.invite-docs-row.check input[type="checkbox"] {
  margin-top: 2px;
  flex-shrink: 0;
}
.invite-docs-row.check > div {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.radio-pill-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.radio-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 13px;
  border-radius: 999px;
  background: var(--bg);
  font-size: 12px;
  cursor: pointer;
  box-shadow:
    -2px -2px 5px var(--shadow-light),
    2px 2px 5px var(--shadow-dark);
  transition: all 160ms ease;
}
.radio-pill input[type="radio"] {
  margin: 0;
}
.radio-pill:has(input:checked) {
  background: var(--bg-soft);
  box-shadow:
    inset 2px 2px 5px var(--shadow-dark),
    inset -2px -2px 5px var(--shadow-light);
  font-weight: 600;
}

/* Help drawer - wider drawer + tabs + panels */
.modal-drawer.modal-drawer-wide {
  width: min(640px, 92vw);
}
.help-tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--bg-soft);
  border-radius: 999px;
  margin-bottom: 18px;
  box-shadow:
    inset 2px 2px 5px var(--shadow-dark),
    inset -2px -2px 5px var(--shadow-light);
}
.help-tab {
  flex: 1;
  padding: 8px 14px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 160ms ease;
}
.help-tab:hover {
  color: var(--text);
}
.help-tab.active {
  background: var(--bg);
  color: var(--text);
  box-shadow:
    -3px -3px 6px var(--shadow-light),
    3px 3px 6px var(--shadow-dark);
}
.help-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  font-size: 13px;
  color: var(--text);
  line-height: 1.55;
}
/* The class rule above sets display:flex, which outranks the default
   [hidden]{display:none}. This higher-specificity rule lets the inactive
   tab panels actually collapse so only the selected tab shows. */
.help-panel[hidden] { display: none; }
.help-panel h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}
.help-panel p {
  margin: 0;
}
.help-panel ul {
  margin: 0;
  padding-left: 20px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.help-panel code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11.5px;
  padding: 1.5px 6px;
  background: var(--bg-soft);
  border-radius: 5px;
  color: var(--text);
}
.help-callout {
  padding: 14px 16px;
  background: var(--bg-soft);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.help-callout h4 {
  margin: 0;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
}

/* Mobile collapse for the invites table */
@media (max-width: 900px) {
  .invites-row {
    grid-template-columns: 1fr auto;
    grid-auto-rows: auto;
    gap: 6px 12px;
    padding: 12px 14px;
  }
  .invites-row > * { grid-column: 1; }
  .invites-row .invites-recipient { grid-column: 1 / span 2; }
  .invites-row .invites-kebab     { grid-column: 2; grid-row: 1; align-self: start; }
  .invites-row .audience-badge,
  .invites-row .invites-status    { justify-self: start; }
  .filter-chips.status { margin-left: 0; }
}

/* Auto-invite toast - flashes when togglePaymentReceived fires the first
   payment and the system auto-creates the portal invite. */
.auto-invite-toast {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 999;
  padding: 12px 18px;
  background: linear-gradient(135deg, #2f7d5e, #4a9e7a);
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  border-radius: 999px;
  box-shadow: 0 10px 28px rgba(47, 125, 94, 0.32), 0 2px 6px rgba(0, 0, 0, 0.08);
  opacity: 0;
  animation: auto-invite-toast-in 240ms ease forwards;
  max-width: min(640px, 92vw);
  text-align: center;
}
.auto-invite-toast.fade-out {
  animation: auto-invite-toast-out 600ms ease forwards;
}
@keyframes auto-invite-toast-in {
  from { opacity: 0; transform: translateX(-50%) translateY(-8px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}
@keyframes auto-invite-toast-out {
  from { opacity: 1; transform: translateX(-50%) translateY(0); }
  to   { opacity: 0; transform: translateX(-50%) translateY(-8px); }
}

/* ============================================================
   Multi-contact: founders / signers / billing / portal admins
   ============================================================ */
.rail-section-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.rail-section-action {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill, 999px);
  color: var(--text);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: none;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease;
}
.rail-section-action:hover {
  background: var(--surface-1);
  border-color: var(--text-muted);
}

.contact-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.contact-card {
  display: flex;
  gap: 10px;
  padding: 10px 12px;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-md, 10px);
  transition: border-color 120ms ease;
}
.contact-card:hover { border-color: var(--text-muted); }
.contact-card-avatar {
  flex: 0 0 32px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.contact-card-body { flex: 1; min-width: 0; }
.contact-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.contact-card-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0;
  text-transform: none;
  min-width: 0;
}
.contact-card-actions {
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity 120ms ease;
}
.contact-card:hover .contact-card-actions { opacity: 1; }
.contact-card-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  padding: 0;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
}
.contact-card-icon:hover {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border);
}
.contact-card-icon-danger:hover {
  color: var(--accent-red, #d04545);
}
.contact-card-icon[disabled] {
  opacity: 0.3;
  cursor: not-allowed;
}
.contact-card-role {
  margin-top: 2px;
  font-size: 11.5px;
  color: var(--text-muted);
}
.contact-card-lines {
  margin-top: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 12px;
}
.contact-card-line {
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.contact-card-line a { color: var(--accent-blue); }
.contact-card-line-label {
  display: inline-block;
  width: 44px;
  color: var(--text-muted);
}
.contact-card-badges {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.contact-badge {
  display: inline-block;
  padding: 2px 7px;
  background: var(--surface-2);
  color: var(--text-muted);
  border-radius: var(--radius-pill, 999px);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.contact-badge-primary {
  background: var(--accent-green-soft, #d8efd8);
  color: var(--accent-green-strong, #2f6f3a);
}

/* Contact modal - role flag toggles */
.contact-flags {
  border: 1px solid var(--border);
  border-radius: var(--radius-md, 10px);
  padding: 12px 14px;
  margin: 0;
}
.contact-flags legend {
  padding: 0 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.contact-flag-row {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 8px 0;
  border-bottom: 1px dashed var(--border);
  font-size: 12.5px;
  color: var(--text);
  cursor: pointer;
}
.contact-flag-row:last-child { border-bottom: none; }
.contact-flag-row input { margin-top: 3px; }
.contact-flag-row strong { color: var(--text); font-weight: 600; }
.contact-flag-row span { line-height: 1.5; }

.contact-field-lang {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.contact-field-lang .send-field-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}

/* Wizard step 2 - inline recipients panel + extra-contact stack */
.wizard-recipients {
  margin-top: 16px;
  padding: 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md, 10px);
}
.wizard-recipients-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}
.wizard-recipients-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.wizard-recipients-count {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
}
.wizard-recipients-hint {
  margin: 0 0 10px;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
}
.wizard-recipients-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 10px;
}
.wizard-recipient-row {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 8px 10px;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-md, 10px);
  cursor: pointer;
  transition: border-color 120ms ease, background 120ms ease;
}
.wizard-recipient-row:hover { border-color: var(--text-muted); }
.wizard-recipient-row.is-checked {
  border-color: var(--accent-green-strong, #2f6f3a);
  background: var(--accent-green-soft, #f1f8f1);
}
.wizard-recipient-row input { margin: 0; }
.wizard-recipient-avatar {
  flex: 0 0 26px;
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
}
.wizard-recipient-body {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
  flex: 1;
}
.wizard-recipient-name {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.wizard-recipient-tag {
  display: inline-block;
  padding: 1px 6px;
  background: var(--accent-green-soft, #d8efd8);
  color: var(--accent-green-strong, #2f6f3a);
  border-radius: var(--radius-pill, 999px);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.wizard-recipient-meta {
  font-size: 11px;
  color: var(--text-muted);
}
.wizard-recipients-add {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  background: transparent;
  border: 1px dashed var(--border);
  border-radius: var(--radius-pill, 999px);
  color: var(--text);
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease;
}
.wizard-recipients-add:hover {
  background: var(--surface-1);
  border-color: var(--text-muted);
}

/* New-client extra-contact rows (stackable founder/co-signer forms) */
.wizard-form-section-label {
  margin-top: 4px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.wizard-form-section-label-tight { margin-top: 14px; }
.wizard-form-section-label em {
  color: var(--accent-red, #d04545);
  font-style: normal;
  margin-left: 2px;
}
.wizard-extra-contacts {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.wizard-extra-row {
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md, 10px);
}
.wizard-extra-row-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}
.wizard-extra-row-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.wizard-extra-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease;
}
.wizard-extra-remove:hover {
  background: var(--surface-1);
  color: var(--accent-red, #d04545);
  border-color: var(--border);
}

/* Deal modal - inline multi-recipient picker (step 1) */
.deal-recipients {
  margin-top: 12px;
  padding: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md, 10px);
}
.deal-recipients-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.deal-recipients-count {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
}
.deal-recipients-hint {
  margin: 0 0 8px;
  font-size: 11.5px;
  color: var(--text-muted);
  line-height: 1.5;
}
.deal-recipients-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 10px;
}
.deal-recipient-row {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 8px 10px;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-md, 10px);
  cursor: pointer;
  transition: border-color 120ms ease, background 120ms ease;
}
.deal-recipient-row:hover { border-color: var(--text-muted); }
.deal-recipient-row.is-checked {
  border-color: var(--accent-green-strong, #2f6f3a);
  background: var(--accent-green-soft, #f1f8f1);
  box-shadow: inset 0 0 0 1px var(--accent-green-strong, #2f6f3a);
}
/* Checkbox is hidden visually - selection is conveyed by the row's green
   outline + tinted background when .is-checked. Input stays in the DOM so
   the wrapping <label> still toggles it on click (and the change handler
   continues to fire) - we just clip it out of the layout. */
.deal-recipient-row input {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: 0;
  padding: 0;
  border: 0;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  overflow: hidden;
  opacity: 0;
}
.deal-recipient-avatar {
  flex: 0 0 26px;
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--text);
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700;
}
.deal-recipient-body {
  display: flex; flex-direction: column; gap: 1px;
  min-width: 0; flex: 1;
}
.deal-recipient-name {
  font-size: 12.5px; font-weight: 600; color: var(--text);
  display: inline-flex; align-items: center; gap: 6px;
}
.deal-recipient-tag {
  display: inline-block;
  padding: 1px 6px;
  background: var(--accent-green-soft, #d8efd8);
  color: var(--accent-green-strong, #2f6f3a);
  border-radius: var(--radius-pill, 999px);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.deal-recipient-meta {
  font-size: 11px;
  color: var(--text-muted);
}
.deal-recipients-add {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 100%;
  padding: 9px 12px;
  background: transparent;
  border: 1px dashed var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease;
}
.deal-recipients-add:hover {
  background: var(--surface-1);
  border-color: var(--text-muted);
}

.deal-extra-contacts-wrap {
  margin-top: 12px;
  border-top: 1px dashed var(--border);
}
.deal-extra-contacts {
  display: flex; flex-direction: column; gap: 8px;
  margin: 8px 0;
}
.deal-extra-row {
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md, 10px);
}
.deal-extra-row-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 6px;
}
.deal-extra-row-title {
  font-size: 11px; font-weight: 700;
  letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--text-muted);
}
.deal-extra-remove {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px;
  background: transparent; border: 1px solid transparent;
  border-radius: 6px; color: var(--text-muted);
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease;
}
.deal-extra-remove:hover {
  background: var(--surface-1);
  color: var(--accent-red, #d04545);
  border-color: var(--border);
}
.deal-step-next {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  margin-top: 12px;
  padding: 10px 14px;
  border: 1px solid var(--text);
  border-radius: 10px;
  background: var(--text);
  /* --surface-0 was never defined which made the label invisible against
     the black fill. Use --surface (the canonical white) for the label color
     instead. */
  color: var(--surface);
  font-size: 13px;
  font-weight: 650;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease, opacity 120ms ease;
}
.deal-step-next:hover:not(:disabled) {
  background: #2a2620;
  border-color: #2a2620;
}
.deal-step-next:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.deal-document-sequence {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.deal-sequence-row {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 10px;
  align-items: start;
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md, 10px);
}
.deal-sequence-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--surface-1);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 11px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.deal-sequence-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.deal-sequence-body strong {
  color: var(--text);
  font-size: 13px;
  font-weight: 650;
}
.deal-sequence-body span {
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.45;
}

/* Step 3 review - recipients list */
.wizard-review-recipients {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 4px;
}
.wizard-review-recipient {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px dashed var(--border);
}
.wizard-review-recipient:last-child { border-bottom: none; }
.wizard-review-recipient-name {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
}
.wizard-review-recipient-meta {
  font-size: 11.5px;
  color: var(--text-muted);
}

/* ============================================================
   Multi-signer contracts (Phase 2)
   ============================================================ */
.signer-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.signer-row {
  display: flex;
  gap: 10px;
  padding: 10px 12px;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-md, 10px);
}
.signer-avatar {
  flex: 0 0 32px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
}
.signer-body { flex: 1; min-width: 0; }
.signer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.signer-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: baseline;
  gap: 6px;
}
.signer-order {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}
.signer-status {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--radius-pill, 999px);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.signer-status-pending { background: var(--surface-2); color: var(--text-muted); }
.signer-status-sent    { background: #e6e9f3; color: #4757a0; }
.signer-status-viewed  { background: #fef4d9; color: #8a6c1a; }
.signer-status-signed  { background: #d8efd8; color: #2f6f3a; }
.signer-status-cc      { background: var(--surface-2); color: var(--text-muted); }

.signer-row-cc { background: var(--surface-2); }
.signer-avatar-cc {
  background: transparent;
  border: 1px dashed var(--border);
  color: var(--text-muted);
}

/* CC list widget - shared by contract wizard step 2 + deal modal step 1 */
.cc-block {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px dashed var(--border);
}
.cc-block-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.cc-row {
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md, 10px);
}
.cc-row-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 6px;
}
.cc-row-title {
  font-size: 11px; font-weight: 700;
  letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--text-muted);
}
.cc-row-remove {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px;
  background: transparent; border: 1px solid transparent;
  border-radius: 6px; color: var(--text-muted);
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
}
.cc-row-remove:hover {
  background: var(--surface-1);
  color: var(--accent-red, #d04545);
  border-color: var(--border);
}
.cc-row-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.cc-field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; }
.cc-field span {
  font-size: 10.5px; font-weight: 600;
  letter-spacing: 0.02em; color: var(--text-muted);
  text-transform: uppercase;
}
.cc-field input {
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-1);
  font-size: 12.5px;
  color: var(--text);
}
.cc-block-add {
  display: flex; align-items: center; justify-content: center; gap: 4px;
  width: 100%;
  padding: 9px 12px;
  background: transparent;
  border: 1px dashed var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 12px; font-weight: 600;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease;
}
.cc-block-add:hover {
  background: var(--surface-1);
  border-color: var(--text-muted);
}

.signer-meta {
  margin-top: 2px;
  font-size: 11.5px;
  color: var(--text-muted);
}
.signer-stamp {
  margin-top: 6px;
  font-size: 11px;
  color: var(--text-faint, var(--text-muted));
  font-variant-numeric: tabular-nums;
}
.signer-actions {
  margin-top: 8px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.btn-ghost-xs {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill, 999px);
  color: var(--text);
  font-size: 10.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease;
}
.btn-ghost-xs:hover {
  background: var(--surface-1);
  border-color: var(--text-muted);
}

.signer-progress {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--radius-pill, 999px);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: none;
  background: var(--surface-2);
  color: var(--text-muted);
}
.signer-progress-partial   { background: #fef4d9; color: #8a6c1a; }
.signer-progress-completed { background: #d8efd8; color: #2f6f3a; }
.signer-progress-sent,
.signer-progress-viewed    { background: #e6e9f3; color: #4757a0; }

/* Wizard step 3 signer picker */
.wizard-signer-hint {
  margin: 0 0 10px;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
}
.wizard-signers {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.wizard-signer-row {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px 12px;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-md, 10px);
  cursor: pointer;
  transition: border-color 120ms ease, background 120ms ease;
}
.wizard-signer-row:hover { border-color: var(--text-muted); }
.wizard-signer-row.is-checked {
  border-color: var(--accent-green-strong, #2f6f3a);
  background: var(--accent-green-soft, #f1f8f1);
}
.wizard-signer-row input { margin-top: 3px; }
.wizard-signer-body { display: flex; flex-direction: column; gap: 2px; }
.wizard-signer-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.wizard-signer-meta {
  font-size: 11.5px;
  color: var(--text-muted);
}
.wizard-signer-add {
  margin-top: 8px;
  font-size: 12px;
  padding: 6px 10px;
}

/* ============================================================
   PIPELINE BOARD - horizontal swim lanes
   ============================================================ */
.pipeline-board-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 0;
  background: var(--surface);
  /* Hide native scrollbar; scrolling still works (wheel, trackpad, keys). */
  scrollbar-width: none;            /* Firefox */
  -ms-overflow-style: none;         /* IE/Edge legacy */
}
.pipeline-board-body::-webkit-scrollbar { width: 0; height: 0; display: none; } /* WebKit */

/* ---------- Delivery view: viewport-locked layout ----------
   On the Delivery stage the entire page is pinned to the viewport. The page
   itself does not scroll (overflow:hidden) - instead each kanban column's
   card list scrolls internally. JS toggles .is-fixed-height when entering /
   leaving Delivery (setPipelineHeaderForDelivery).

   The root constraint: .app's main column track grows to its tallest content
   by default, so even with .pipeline-board-body set to overflow:hidden the
   document itself would still scroll. Locking the Pipeline view to 100vh
   stops that growth at the source - the height cascades through flex:1 +
   min-height:0 down to the column lists. */
.view[data-view="pipeline-board"]:has(.pipeline-board-body.is-fixed-height) {
  /* .main has 10px top/bottom padding around the surface, so the effective
     viewport for the view is 100vh minus those 20px. Matches .surface's
     min-height: calc(100vh - 20px). */
  height: calc(100vh - 20px);
  max-height: calc(100vh - 20px);
  overflow: hidden;
}
.pipeline-board-body.is-fixed-height {
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.pipeline-board-body.is-fixed-height > .pb-board {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.pipeline-board-body.is-fixed-height .delivery-board-page {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.pipeline-board-body.is-fixed-height .phase-stepper-wrap { flex: 0 0 auto; }
.pipeline-board-body.is-fixed-height .kbn-page-board {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.pipeline-board-body.is-fixed-height .kbn-page-board > .kbn-board {
  flex: 1 1 auto;
  min-height: 0;
  height: 100%;
}
.pipeline-board-body.is-fixed-height .kbn-col {
  min-height: 0;
  overflow: hidden;
}
.pipeline-board-body.is-fixed-height .kbn-col-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding-right: 2px;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.pipeline-board-body.is-fixed-height .kbn-col-list::-webkit-scrollbar {
  width: 0; height: 0; display: none;
}
/* Cards must NOT shrink in the flex column - otherwise when a column has
   more cards than fit, every card squeezes (clipping the title). Keep cards
   at their natural height; the overflow goes to the list, which scrolls. */
.pipeline-board-body.is-fixed-height .kbn-col-list > .kbn-card {
  flex: 0 0 auto;
}
/* Same fixed-height treatment for the all-stages OVERVIEW board. The page
   doesn't scroll; each stage column scrolls its own card list internally. */
.pipeline-board-body.is-fixed-height .pb-overview-board {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}
/* The KPI command band sits above the board inside .pb-board (a flex column);
   it keeps its natural height while the board flexes to fill the rest. */
.pipeline-board-body.is-fixed-height .pb-ov-kpis { flex: 0 0 auto; }
.pipeline-board-body.is-fixed-height .pb-overview-col {
  height: 100%;
  min-height: 0;
  overflow: hidden;
}
.pipeline-board-body.is-fixed-height .pb-overview-col-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding-right: 2px;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.pipeline-board-body.is-fixed-height .pb-overview-col-body::-webkit-scrollbar {
  width: 0; height: 0; display: none;
}
/* Cards must not shrink in the flex column - keep their natural height so
   long-name cards don't get clipped when the column overflows. */
.pipeline-board-body.is-fixed-height .pb-overview-col-body > .pb-overview-card {
  flex: 0 0 auto;
}

/* ============================================================
   Standalone Delivery Board view (its own menu tab). Viewport-locked like
   the in-pipeline delivery board so the kanban columns scroll internally
   instead of growing the whole page. Mirrors the .pipeline-board-body
   is-fixed-height treatment, scoped to this view.
   ============================================================ */
.view[data-view="delivery-board"]:not([hidden]) {
  height: calc(100vh - 20px);
  max-height: calc(100vh - 20px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.view[data-view="delivery-board"] > .page-header { flex: 0 0 auto; }
.view[data-view="delivery-board"] > .delivery-board-view-body {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 0;
}
.view[data-view="delivery-board"] .delivery-board-page {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.view[data-view="delivery-board"] .phase-stepper-wrap { flex: 0 0 auto; }
.view[data-view="delivery-board"] .kbn-page-board {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.view[data-view="delivery-board"] .kbn-page-board > .kbn-board {
  flex: 1 1 auto;
  min-height: 0;
  height: 100%;
}
.view[data-view="delivery-board"] .kbn-col { min-height: 0; overflow: hidden; }
.view[data-view="delivery-board"] .kbn-col-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.view[data-view="delivery-board"] .kbn-col-list::-webkit-scrollbar { width: 0; height: 0; display: none; }
.view[data-view="delivery-board"] .kbn-col-list > .kbn-card { flex: 0 0 auto; }
.pb-board {
  display: flex;
  flex-direction: column;
  gap: 0;
  min-height: 100%;
}

/* ============================================================
   Pipeline OVERVIEW BOARD - vertical kanban columns side by side.
   Each column = a stage. Cards inside are draggable across columns
   to move people between stages. Replaces the old "horizontal lanes
   with descriptions" layout.
   ============================================================ */
.pb-overview-board {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
  padding: 18px 16px 24px;
  align-items: stretch;
  flex: 1;
  min-height: 100%;
}
.pb-overview-col {
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--surface-2);
  border-radius: 12px;
  padding: 12px 10px 14px;
  min-height: 320px;
}
.pb-overview-col-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 2px 4px 4px;
}

/* ---- Overview command-center additions ---- */
/* KPI band: a touch shorter than the Reports KPIs so it doesn't crowd the
   board, and a warn tone when the "Need attention" tile is non-zero. */
.pb-ov-kpis { padding: 14px 16px 0; }
.report-kpi.pb-ov-kpi { min-height: 90px; }
.pb-ov-kpi-foot { font-size: 11px; color: var(--text-muted); font-weight: 500; }
.report-kpi.pb-ov-kpi.tone-warn { border-color: rgba(217, 154, 58, 0.5); }
.report-kpi.pb-ov-kpi.tone-warn .report-kpi-value { color: var(--warn, #d99a3a); }

/* Stage number + signal sub-line in each column header. */
.pb-ov-col-num {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
  flex: 0 0 auto;
}
.pb-ov-col-signal {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-muted);
  padding: 0 4px 10px;
  min-height: 12px;
  letter-spacing: -0.005em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pb-ov-col-signal.is-empty { visibility: hidden; }

/* ============================================================
   Pipeline OVERVIEW v2 - stage-flow ribbon + needs-attention focus.
   Replaces the kanban columns. The flow reads left-to-right on desktop
   (nodes joined by chevrons) and stacks vertically on mobile. The whole
   overview scrolls as a normal page (no viewport lock on All-stages).
   ============================================================ */
.pb-flow {
  display: flex;
  align-items: stretch;
  gap: 10px;
  padding: 18px 16px 6px;
}
.pb-flow-node {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 9px;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 14px 16px;
  cursor: pointer;
  font: inherit;
  color: inherit;
  transition: border-color 120ms ease, box-shadow 120ms ease, transform 120ms ease;
}
.pb-flow-node:hover {
  border-color: var(--text-muted);
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(15, 18, 32, 0.07);
}
.pb-flow-node.is-empty { opacity: 0.6; box-shadow: none; }
.pb-flow-top { display: flex; align-items: center; gap: 7px; min-width: 0; }
.pb-flow-num {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
  flex: 0 0 auto;
}
.pb-flow-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-muted); flex: 0 0 auto; }
.pb-flow-name {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pb-flow-count {
  font-size: 26px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.pb-flow-foot { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pb-flow-metric { font-size: 11.5px; font-weight: 500; color: var(--text-muted); }
.pb-flow-idle {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--warn, #d99a3a);
  background: rgba(217, 154, 58, 0.12);
  padding: 2px 7px;
  border-radius: 999px;
}
.pb-flow-node.tone-amber       .pb-flow-dot { background: #c08a2c; }
.pb-flow-node.tone-blue        .pb-flow-dot { background: var(--accent-blue, #3b6eff); }
.pb-flow-node.tone-legal       .pb-flow-dot { background: #4060d0; }
.pb-flow-node.tone-green       .pb-flow-dot { background: #1f8a4c; }
.pb-flow-node.tone-engineering .pb-flow-dot { background: #0e8a82; }
.pb-flow-node.tone-creative    .pb-flow-dot { background: #c1467e; }
.pb-flow-node.tone-executive   .pb-flow-dot { background: #7c44d6; }

.pb-focus { padding: 14px 16px 28px; }
.pb-focus-head { display: flex; align-items: center; gap: 8px; padding: 8px 2px 12px; }
.pb-focus-title { font-size: 13px; font-weight: 700; color: var(--text); margin: 0; letter-spacing: -0.01em; }
.pb-focus-count {
  font-size: 11px;
  font-weight: 700;
  color: var(--warn, #d99a3a);
  background: rgba(217, 154, 58, 0.12);
  border-radius: 999px;
  padding: 1px 8px;
  min-width: 20px;
  text-align: center;
}
.pb-focus-list { display: flex; flex-direction: column; gap: 6px; }
.pb-focus-row {
  display: grid;
  grid-template-columns: 8px minmax(0, 1fr) auto auto auto;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm, 10px);
  padding: 11px 14px;
  cursor: pointer;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
.pb-focus-row:hover { border-color: var(--text-muted); box-shadow: 0 1px 0 rgba(15, 18, 32, 0.04); }
.pb-focus-idledot { width: 8px; height: 8px; border-radius: 50%; background: var(--warn, #d99a3a); }
.pb-focus-person { min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.pb-focus-name {
  font-size: 13px; font-weight: 600; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.pb-focus-company {
  font-size: 11px; color: var(--text-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.pb-focus-stage {
  font-size: 10px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--text-soft); background: var(--surface-2);
  border-radius: 999px; padding: 3px 9px; white-space: nowrap;
}
.pb-focus-days {
  font-size: 11.5px; font-weight: 600; color: var(--warn, #d99a3a);
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.pb-focus-owners { display: inline-flex; gap: 3px; }
.pb-focus-clear {
  display: flex; align-items: center; gap: 10px;
  color: var(--text-muted); font-size: 12.5px;
  background: var(--surface-2); border-radius: var(--radius-sm, 10px);
  padding: 16px 18px;
}
.pb-focus-clear svg { color: #1f8a4c; flex: 0 0 auto; }

/* Responsive: stack the flow into full-width rows + simplify focus rows. */
@media (max-width: 1100px) {
  .pb-flow { flex-direction: column; gap: 8px; }
  .pb-flow-node { flex-flow: row wrap; align-items: center; padding: 12px 14px; gap: 6px 12px; }
  .pb-flow-node .pb-flow-top { flex: 1 1 auto; order: 1; }
  .pb-flow-node .pb-flow-count { order: 2; font-size: 20px; }
  .pb-flow-node .pb-flow-foot { order: 3; flex-basis: 100%; }
}
@media (max-width: 560px) {
  .pb-focus-row { grid-template-columns: 8px minmax(0, 1fr) auto; row-gap: 7px; }
  .pb-focus-stage { grid-column: 2 / -1; justify-self: start; }
  .pb-focus-owners { display: none; }
}
.pb-overview-col-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--text-muted);
}
.pb-overview-col.tone-amber       .pb-overview-col-dot { background: #c08a2c; }
.pb-overview-col.tone-blue        .pb-overview-col-dot { background: var(--accent-blue, #3b6eff); }
.pb-overview-col.tone-legal       .pb-overview-col-dot { background: #4060d0; }
.pb-overview-col.tone-green       .pb-overview-col-dot { background: #1f8a4c; }
.pb-overview-col.tone-engineering .pb-overview-col-dot { background: #0e8a82; }
.pb-overview-col.tone-creative    .pb-overview-col-dot { background: #c1467e; }
.pb-overview-col.tone-executive   .pb-overview-col-dot { background: #7c44d6; }
.pb-overview-col-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  background: transparent;
  border: 0;
  padding: 0;
  margin: 0;
  cursor: pointer;
  flex: 1;
  text-align: left;
  letter-spacing: -0.005em;
  font-family: inherit;
}
.pb-overview-col-name:hover {
  text-decoration: underline;
}
.pb-overview-col-count {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--surface);
  padding: 1px 7px;
  border-radius: 999px;
  min-width: 20px;
  text-align: center;
}
.pb-overview-col-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
  min-height: 80px;
  border-radius: 8px;
  padding: 2px;
  transition: background 100ms ease, box-shadow 100ms ease;
}
.pb-overview-col-body.is-drop-over {
  background: var(--accent-blue-soft, rgba(59,110,255,0.10));
  box-shadow: inset 0 0 0 2px var(--accent-blue);
}
.pb-overview-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 11px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text);
  cursor: grab;
  transition: border-color 100ms ease, box-shadow 100ms ease, transform 100ms ease;
  letter-spacing: -0.005em;
  user-select: none;
}
.pb-overview-card:hover {
  border-color: var(--text-muted);
  box-shadow: 0 1px 0 rgba(15,18,32,0.04);
}
.pb-overview-card:active {
  cursor: grabbing;
}
.pb-overview-card.is-dragging {
  opacity: 0.45;
  transform: scale(0.97);
}
.pb-overview-card {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 5px;
}
.pb-overview-card.is-stale { border-color: rgba(217, 154, 58, 0.45); }
.pb-ov-card-top {
  display: flex;
  align-items: center;
  gap: 7px;
}
.pb-ov-card-stale {
  flex: 0 0 auto;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--warn, #d99a3a);
}
.pb-ov-card-company {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pb-ov-card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}
.pb-ov-card-days {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}
.pb-ov-card-days.is-stale { color: var(--warn, #d99a3a); }
.pb-ov-card-right { display: inline-flex; align-items: center; gap: 3px; }
.pb-ov-card-src {
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-faint);
}
.pb-overview-card-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
  flex: 1 1 auto;
  min-width: 0;
}
/* Engagement type chip (#8). DFY = blue, Academy = violet. */
.pb-overview-card-type {
  flex: 0 0 auto;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 999px;
  line-height: 1;
}
.pb-overview-card-type[data-engagement="dfy"]     { color: #1d4ed8; background: rgba(96, 165, 250, 0.18); }
.pb-overview-card-type[data-engagement="student"] { color: #6d28d9; background: rgba(167, 139, 250, 0.20); }
.pb-overview-empty {
  font-size: 11.5px;
  color: var(--text-faint);
  padding: 14px 8px;
  text-align: center;
  border: 1px dashed var(--border);
  border-radius: 8px;
  background: transparent;
}

/* One stage = one full-width horizontal row (legacy - kept for reference) */
.pb-lane {
  display: grid;
  grid-template-columns: 232px 1fr;
  gap: 18px;
  align-items: stretch;
  padding: 18px 24px;
  border-bottom: 1px solid var(--hairline, rgba(0,0,0,0.06));
  background: var(--surface);
  min-height: 130px;
}
.pb-lane:last-child { border-bottom: 0; }

.pb-lane-head {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-top: 4px;
}
.pb-lane-title {
  display: flex;
  align-items: center;
  gap: 8px;
}
.pb-lane-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.pb-lane.tone-amber       .pb-lane-dot { background: #c08a2c; }
.pb-lane.tone-blue        .pb-lane-dot { background: var(--accent-blue, #3b6eff); }
.pb-lane.tone-legal       .pb-lane-dot { background: #4060d0; }
.pb-lane.tone-green       .pb-lane-dot { background: #1f8a4c; }
.pb-lane.tone-engineering .pb-lane-dot { background: #0e8a82; }
.pb-lane.tone-creative    .pb-lane-dot { background: #c1467e; }
.pb-lane.tone-executive   .pb-lane-dot { background: #7c44d6; }

.pb-lane-name {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
}
.pb-lane-count {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--surface-2);
  padding: 1px 7px;
  border-radius: 999px;
  margin-left: 2px;
  min-width: 18px;
  text-align: center;
}
.pb-lane-desc {
  font-size: 11.5px;
  color: var(--text-muted);
  line-height: 1.4;
  max-width: 220px;
}

/* Horizontal scrolling card row */
.pb-lane-cards {
  display: flex;
  flex-direction: row;
  gap: 10px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 2px 4px 6px 0;
  scroll-snap-type: x proximity;
}
.pb-lane-cards::-webkit-scrollbar { height: 8px; }
.pb-lane-cards::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 4px; }

.pb-empty {
  flex-shrink: 0;
  width: 220px;
  border: 1px dashed var(--border);
  border-radius: 10px;
  padding: 22px;
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
  align-self: center;
}

/* The card itself */
.pb-card {
  flex: 0 0 232px;
  scroll-snap-align: start;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 12px 10px;
  transition: border-color 100ms ease, box-shadow 100ms ease;
  position: relative;
}
.pb-card:hover {
  border-color: var(--text-muted);
  box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}
.pb-card.is-stale { border-color: #e3a23a; box-shadow: inset 3px 0 0 #e3a23a; padding-left: 14px; }

.pb-card-head { cursor: pointer; }
.pb-card-name {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.pb-card-company {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pb-card-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 10px;
  margin-bottom: 10px;
  min-height: 22px;
}
.pb-card-days {
  font-size: 10.5px;
  font-weight: 500;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--surface-2);
}
.pb-card-days.is-stale { color: #8a5512; background: #fdebc4; }
.pb-card-flag {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 2px 7px;
  border-radius: 999px;
  background: #fdebc4;
  color: #8a5512;
}
.pb-card-owners {
  display: inline-flex;
  align-items: center;
  margin-left: auto;
}
.pb-owner-chip {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--surface-3);
  border: 1.5px solid var(--surface);
  font-size: 9.5px;
  font-weight: 600;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: -6px;
}
.pb-owner-chip:first-child { margin-left: 0; }
.pb-owner-chip.dept-legal       { background: var(--dept-legal);       color: var(--dept-legal-fg); }
.pb-owner-chip.dept-engineering { background: var(--dept-engineering); color: var(--dept-engineering-fg); }
.pb-owner-chip.dept-creative    { background: var(--dept-creative);    color: var(--dept-creative-fg); }
.pb-owner-chip.dept-executive   { background: var(--dept-executive);   color: var(--dept-executive-fg); }

.pb-card-foot {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: auto;
}

.pb-action {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  padding: 4px 8px;
  font: inherit;
  font-size: 11px;
  font-weight: 500;
  border-radius: 6px;
  cursor: pointer;
  transition: background 100ms ease, border-color 100ms ease, color 100ms ease;
}
.pb-action:hover {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--text-muted);
}
.pb-action svg { color: currentColor; }
.pb-action-primary {
  background: var(--text);
  color: var(--surface);
  border-color: var(--text);
}
.pb-action-primary:hover {
  background: var(--text);
  color: var(--surface);
  opacity: 0.88;
}
.pb-action-warn {
  border-color: #f0c47b;
  color: #8a5512;
  background: #fff4dc;
}
.pb-action-warn:hover {
  background: #fdebc4;
  color: #8a5512;
  border-color: #e3a23a;
}

/* Wrapper around the help (?) button so the legend popover can anchor under
   it via absolute positioning. */
.pb-help-wrap { position: relative; display: inline-flex; }

/* Phase-status color legend popover (Delivery stage). Anchored under the
   (?) button. Same color tokens used by .phase-pill state styles. */
.legend-pop {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 60;
  min-width: 180px;
  padding: 10px 12px 11px;
  background: var(--surface, #fff);
  border: 1px solid var(--border, rgba(0,0,0,0.12));
  border-radius: 10px;
  box-shadow: 0 6px 18px -6px rgba(0,0,0,0.20), 0 1px 0 rgba(0,0,0,0.04);
}
.legend-pop[hidden] { display: none; }
.legend-pop-title {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
  color: var(--text-faint, #b3afa5);
  margin: 0 0 8px;
}
.legend-pop-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.legend-pop-list li {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 12.5px;
  color: var(--text, #1a1a1a);
  line-height: 1.1;
}
.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex: 0 0 auto;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.04) inset;
}
.legend-dot--not-started { background: rgba(0,0,0,0.28); }
.legend-dot--in-progress { background: #FFFC00; border: 1px solid rgba(0,0,0,0.12); }
.legend-dot--review      { background: #7c3aed; }
.legend-dot--complete    { background: #16a34a; }

/* Help (?) button in the pipeline page header. Opens the generic stage rail
   showing the runbook for the active stage. Only visible when the current
   stage has a runbook defined. */
.pb-help-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  transition: border-color 100ms ease, background 100ms ease, color 100ms ease;
}
.pb-help-btn:hover {
  border-color: var(--text-muted);
  background: var(--surface-2);
  color: var(--text);
}
/* The class rule above has higher specificity than the browser default
   [hidden]{display:none}, so we have to re-assert hidden here or the button
   stays visible on the All-stages overview where it has no target stage. */
.pb-help-btn[hidden] { display: none; }

/* ---- Stage picker dropdown (replaces the pill bar) ---- */
.pb-stage-picker {
  position: relative;
}
.pb-stage-picker-trigger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 32px;
  padding: 0 10px 0 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  transition: border-color 100ms ease, background 100ms ease;
}
.pb-stage-picker-trigger:hover { border-color: var(--text-muted); background: var(--surface-2); }
.pb-stage-picker-trigger[aria-expanded="true"] { border-color: var(--text); background: var(--surface-2); }

.pb-stage-picker-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--text-muted);
}
.pb-stage-picker-dot.tone-neutral      { background: var(--text-muted); }
.pb-stage-picker-dot.tone-amber        { background: #c08a2c; }
.pb-stage-picker-dot.tone-blue         { background: var(--accent-blue, #3b6eff); }
.pb-stage-picker-dot.tone-legal        { background: #4060d0; }
.pb-stage-picker-dot.tone-engineering  { background: #0e8a82; }
.pb-stage-picker-dot.tone-creative     { background: #c1467e; }
.pb-stage-picker-dot.tone-executive    { background: #7c44d6; }

.pb-stage-picker-num {
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-faint, var(--text-muted));
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
}
.pb-stage-picker-label { font-weight: 600; }
.pb-stage-picker-count {
  font-size: 10.5px;
  font-weight: 600;
  background: var(--surface-2);
  color: var(--text-muted);
  padding: 1px 6px;
  border-radius: 999px;
  min-width: 18px;
  text-align: center;
}
.pb-stage-picker-trigger:hover .pb-stage-picker-count { background: var(--surface); }
.pb-stage-picker-chev {
  color: var(--text-muted);
  margin-left: 2px;
  transition: transform 120ms ease;
}
.pb-stage-picker-trigger[aria-expanded="true"] .pb-stage-picker-chev { transform: rotate(180deg); }

/* The dropdown panel */
.pb-stage-picker-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 280px;
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow:
    0 1px 2px rgba(0,0,0,0.04),
    0 10px 28px -10px rgba(20,18,14,0.18),
    0 3px 10px -4px rgba(20,18,14,0.08);
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: 1px;
  animation: pbStageMenuIn 120ms ease-out;
}
/* `display: flex` above outranks the UA stylesheet's `[hidden] { display: none }`,
   so we need an explicit rule here for menu.hidden=true to actually hide the menu. */
.pb-stage-picker-menu[hidden] { display: none; }
@keyframes pbStageMenuIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0);   }
}
.pb-stage-picker-item {
  display: grid;
  grid-template-columns: 18px 8px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  background: transparent;
  border: 0;
  border-radius: 6px;
  font: inherit;
  font-size: 12.5px;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  position: relative;
  transition: background 100ms ease;
}
.pb-stage-picker-item:hover { background: var(--surface-2); }
/* Active row reads as "picked" via a noticeably darker tint - no check mark
   needed since the trigger button already shows the active stage. */
.pb-stage-picker-item.is-active {
  background: var(--surface-3, #ecebe7);
  font-weight: 600;
}
/* Subtle hairline underneath "All stages" - separates it from the numbered list */
.pb-stage-picker-item.has-divider {
  margin-bottom: 4px;
}
.pb-stage-picker-item.has-divider::after {
  content: '';
  position: absolute;
  left: 6px;
  right: 6px;
  bottom: -3px;
  height: 1px;
  background: var(--hairline, rgba(0,0,0,0.06));
}
.pb-stage-picker-item-num {
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-faint, var(--text-muted));
  letter-spacing: 0.02em;
  text-align: left;
  font-variant-numeric: tabular-nums;
}
.pb-stage-picker-item.is-active .pb-stage-picker-item-num { color: var(--text); }
.pb-stage-picker-item-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  letter-spacing: -0.005em;
}
.pb-stage-picker-item-count {
  font-size: 10.5px;
  font-weight: 600;
  background: var(--surface-2);
  color: var(--text-muted);
  padding: 1px 7px;
  border-radius: 999px;
  min-width: 20px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.pb-stage-picker-item:hover .pb-stage-picker-item-count,
.pb-stage-picker-item.is-active .pb-stage-picker-item-count {
  background: var(--surface);
}
/* ---- Pill tab bar across the top of the Pipeline view ---- */
.pb-tabs {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--hairline, rgba(0,0,0,0.06));
  overflow-x: auto;
  scrollbar-width: none;
  flex-wrap: nowrap;
}
.pb-tabs::-webkit-scrollbar { display: none; }
.pb-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border: 1px solid transparent;
  background: transparent;
  border-radius: 999px;
  font: inherit;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
  transition: background 100ms ease, border-color 100ms ease, color 100ms ease;
}
.pb-tab:hover { color: var(--text); background: var(--surface-2); }
.pb-tab.is-active {
  background: var(--text);
  color: var(--surface);
  border-color: var(--text);
  font-weight: 600;
}
.pb-tab.is-active .pb-tab-count { background: rgba(255,255,255,0.16); color: var(--surface); }
.pb-tab-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--text-muted);
  flex-shrink: 0;
}
.pb-tab.tone-neutral      .pb-tab-dot { background: var(--text-muted); }
.pb-tab.tone-amber        .pb-tab-dot { background: #c08a2c; }
.pb-tab.tone-blue         .pb-tab-dot { background: var(--accent-blue, #3b6eff); }
.pb-tab.tone-legal        .pb-tab-dot { background: #4060d0; }
.pb-tab.tone-engineering  .pb-tab-dot { background: #0e8a82; }
.pb-tab.tone-creative     .pb-tab-dot { background: #c1467e; }
.pb-tab.tone-executive    .pb-tab-dot { background: #7c44d6; }
.pb-tab-count {
  font-size: 10.5px;
  font-weight: 600;
  background: var(--surface-2);
  color: var(--text-muted);
  padding: 1px 6px;
  border-radius: 999px;
  min-width: 18px;
  text-align: center;
}

/* Make the lane title in overview mode look like a clickable link */
.pb-lane-name.pb-lane-open {
  font: inherit;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  background: transparent;
  border: 0;
  padding: 0;
  cursor: pointer;
  text-align: left;
}
.pb-lane-name.pb-lane-open:hover { text-decoration: underline; }

/* ============================================================
   SINGLE-STAGE VIEW - steps strip + people grid
   ============================================================ */
.pb-stage-view {
  flex: 1;
  min-height: 100%;
  padding: 18px 24px 32px;
  background: var(--surface);
}
.pb-stage-head {
  margin-bottom: 14px;
}
/* The Sales view hides the verbose multi-line subtitle - tab titles already
   say what each step is, and the redundant copy steals vertical space. */
.pb-stage-view.tone-blue .pb-stage-desc { display: none; }

/* Step tabs - one per Pathway step inside this stage. Pill segmented control
   styled to match the rest of the dashboard. Each tab is also a drop zone:
   drag a card onto a tab to move it to that step. */
.pb-step-tabs {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  margin-bottom: 14px;
  max-width: 100%;
  overflow-x: auto;
}
.pb-step-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  background: transparent;
  border: 0;
  border-radius: 999px;
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-soft);
  cursor: pointer;
  white-space: nowrap;
  transition: background 100ms ease, color 100ms ease, box-shadow 100ms ease;
}
.pb-step-tab:hover { color: var(--text); }
.pb-step-tab.is-active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 2px rgba(15,18,32,0.06);
}
.pb-step-tab.is-drop-over {
  background: var(--accent-blue-soft);
  color: var(--accent-blue);
  box-shadow: inset 0 0 0 2px var(--accent-blue);
}
.pb-step-tab-count {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  padding: 1px 7px;
  background: var(--surface);
  border-radius: 999px;
  min-width: 22px;
  text-align: center;
}
.pb-step-tab.is-active .pb-step-tab-count {
  background: var(--surface-2);
  color: var(--text);
}

/* Body for whichever step tab is currently active. Sits flush on the page
   surface - no outer card. Cards lay out in a responsive grid. */
.pb-step-content {
  background: transparent;
  padding: 4px 0 0;
  min-height: 280px;
  border-radius: 10px;
  transition: background 100ms ease, box-shadow 100ms ease;
}
.pb-step-content.is-drop-over {
  background: var(--accent-blue-soft);
  box-shadow: inset 0 0 0 2px var(--accent-blue);
}
.pb-step-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 10px;
}
.pb-step-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 64px 20px;
  text-align: center;
  font-size: 13px;
  color: var(--text-faint);
  line-height: 1.5;
}
.pb-step-empty svg { color: var(--text-faint); opacity: 0.5; }

.pb-stage-board .pw-board-card {
  padding: 12px 14px;
  border-radius: 10px;
  border-left: 1px solid var(--border);
  box-shadow: 0 1px 0 rgba(15,18,32,0.03);
  gap: 6px;
}
.pb-stage-board .pw-board-card:hover {
  box-shadow: 0 6px 16px -8px rgba(15,18,32,0.18);
  border-color: var(--text-muted);
}
.pb-stage-board .pw-board-card-name {
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: -0.005em;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pw-board-card-contact {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-soft);
  font-variant-numeric: tabular-nums;
  min-width: 0;
}

/* NDA / MSA / Payment indicator row at the foot of a Contracting & Payment
   pipeline card. Three equal cells, label on top, status mark below. */
.pw-board-card-signatures {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 10px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.pw-sig-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.pw-sig-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.pw-sig-mark {
  width: 22px;
  height: 22px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1.5px solid var(--border-strong);
  background: var(--surface-2);
  color: transparent;
  transition: background 120ms, border-color 120ms, color 120ms;
}
.pw-sig-mark-done {
  background: #16a34a;
  border-color: #16a34a;
  color: #fff;
}
.pw-sig-mark-todo {
  background: var(--surface-2);
  border-color: var(--border-strong);
  color: transparent;
}
.pw-board-card-contact-text {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pw-board-card-iconbtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  flex-shrink: 0;
  text-decoration: none;
  transition: background 100ms ease, color 100ms ease;
}
.pw-board-card-iconbtn:hover {
  background: var(--surface-2);
  color: var(--text);
}

/* Sales-stage card booking pill. Rendered at the bottom of the card body
   above the disposition buttons. Three states:
   - upcoming (booked, in the future)  -> tinted accent pill, clickable if
     a meeting link is attached
   - past (call already held)           -> muted ok-green confirmation pill
   - empty (no call booked yet)         -> faint dashed pill with a dot */
.pw-board-card-booking {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 500;
  line-height: 1;
  text-decoration: none;
  align-self: flex-start;
  max-width: 100%;
  min-width: 0;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease;
}
.pw-board-card-booking-icon { display: inline-flex; flex-shrink: 0; opacity: 0.9; }
.pw-board-card-booking-text {
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-variant-numeric: tabular-nums;
}
.pw-board-card-booking-arrow { flex-shrink: 0; opacity: 0.8; }
a.pw-board-card-booking-upcoming,
.pw-board-card-booking-upcoming {
  background: color-mix(in srgb, var(--accent-blue, #3b6eff) 9%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--accent-blue, #3b6eff) 22%, var(--border));
  color: color-mix(in srgb, var(--accent-blue, #3b6eff) 72%, var(--text));
}
a.pw-board-card-booking-upcoming:hover {
  background: color-mix(in srgb, var(--accent-blue, #3b6eff) 14%, var(--surface));
  border-color: color-mix(in srgb, var(--accent-blue, #3b6eff) 36%, var(--border));
  color: color-mix(in srgb, var(--accent-blue, #3b6eff) 90%, var(--text));
}
.pw-board-card-booking-past {
  background: color-mix(in srgb, var(--ok, #2f9e6e) 8%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--ok, #2f9e6e) 20%, var(--border));
  color: color-mix(in srgb, var(--ok, #2f9e6e) 65%, var(--text));
}
.pw-board-card-booking-empty {
  background: transparent;
  border: 1px dashed var(--border);
  color: var(--text-muted);
}
.pw-board-card-booking-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-faint, #b3afa5);
  flex-shrink: 0;
}

/* Sales-stage contact card: monogram + name header on top, hairline divider,
   then phone/email rows. Drops the tone-colored left stripe inherited from
   .pw-board-card so the card reads as a clean, designed rectangle. Tone
   overrides are listed explicitly to beat the .pw-board-card.tone-* selectors
   defined earlier. */
.pw-board-card-contact-card,
.pw-board-card-contact-card.tone-amber,
.pw-board-card-contact-card.tone-blue,
.pw-board-card-contact-card.tone-legal,
.pw-board-card-contact-card.tone-green,
.pw-board-card-contact-card.tone-creative,
.pw-board-card-contact-card.tone-executive,
.pw-board-card-contact-card.tone-engineering {
  border-left: 1px solid var(--border);
  border-left-color: var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  gap: 6px;
}
.pw-board-card-contact-card:hover {
  border-color: var(--border);
  box-shadow: 0 8px 24px -14px rgba(15,18,32,0.22);
}
.pw-board-card-contact-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 10px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--border);
}
.pw-board-card-monogram {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--text);
  display: grid;
  place-items: center;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  flex-shrink: 0;
  user-select: none;
}
.pw-board-card-contact-card .pw-board-card-name {
  font-size: 14.5px;
  font-weight: 600;
  letter-spacing: -0.005em;
  line-height: 1.25;
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* Source chip on Leads cards (Paid Traffic, Organic, Referral, etc.) - sits at
   the right of the header so the card stays visually unified with non-leads
   stages where this chip is simply absent. */
.pw-board-card-source {
  flex-shrink: 0;
  font-size: 9.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 3px 8px;
  border-radius: 999px;
  line-height: 1;
  white-space: nowrap;
}
.pw-board-card-source.tone-amber       { background: #fff1d8; color: #82591a; }
.pw-board-card-source.tone-blue        { background: var(--accent-blue-soft, #e0eaff); color: var(--accent-blue, #1e40af); }
.pw-board-card-source.tone-green       { background: #d3f2dd; color: #1a6b3c; }
.pw-board-card-source.tone-legal       { background: var(--dept-legal, #d8e3ff); color: var(--dept-legal-fg, #1f3da6); }
.pw-board-card-source.tone-creative    { background: var(--dept-creative, #ffd4e0); color: var(--dept-creative-fg, #a02050); }
.pw-board-card-source.tone-executive   { background: var(--dept-executive, #e9d8ff); color: var(--dept-executive-fg, #5b2bb1); }
.pw-board-card-source.tone-engineering { background: var(--dept-engineering, #cdebe9); color: var(--dept-engineering-fg, #0e5e57); }
.pw-board-card-source.tone-neutral     { background: var(--surface-2); color: var(--text-muted); }

/* Footer under the contact rows: absolute timestamp on the left, relative
   ("2 hours ago") on the right. Reads as a quiet meta strip, separated from
   the contact rows by a hairline. */
.pw-board-card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 4px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  font-size: 11.5px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
.pw-board-card-when {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.pw-board-card-ago {
  white-space: nowrap;
  flex-shrink: 0;
}

/* Sales-stage contact card. No avatar, no drag. Stacked name + phone + email
   rows with action icons on the right (tel: / mailto:). Clicking the body
   opens the rail; clicking an icon link triggers the native action. */
.pw-board-card.pw-contact-card {
  padding: 16px 18px;
  gap: 8px;
  cursor: pointer;
  border-radius: 10px;
}
.pw-board-card.pw-contact-card:hover {
  border-color: var(--accent-blue);
  box-shadow: 0 6px 16px -10px rgba(15,18,32,0.18);
}
.pw-contact-card-name {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
  line-height: 1.2;
  margin-bottom: 4px;
}
.pw-contact-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 4px 0;
  color: var(--text-soft);
  font-size: 13px;
  text-decoration: none;
  border-radius: 6px;
  transition: color 100ms ease;
}
.pw-contact-row:hover { color: var(--accent-blue); }
.pw-contact-row-text {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pw-contact-row svg {
  flex-shrink: 0;
  color: var(--text-muted);
}
.pw-contact-row:hover svg { color: var(--accent-blue); }

/* Tighten the page header chrome - smaller name, no big margin. */
.pb-stage-name { font-size: 18px; }
.pb-stage-count { font-size: 12px; padding: 1px 8px; }

/* ============================================================
   LEADS BOARD - booking funnel, volume-optimized
   Compact cards, search + source filter, parked column muted.
   ============================================================ */

/* Toolbar: search input on the left, source chips center, count summary right */
.lb-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.lb-search-wrap {
  position: relative;
  flex: 0 0 280px;
  max-width: 100%;
}
.lb-search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}
.lb-search {
  width: 100%;
  padding: 7px 10px 7px 30px;
  font: inherit;
  font-size: 12.5px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
}
.lb-search:focus {
  outline: none;
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px var(--accent-blue-soft);
}
.lb-search::placeholder { color: var(--text-muted); }

.lb-source-filter {
  display: inline-flex;
  gap: 4px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px;
}
.lb-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  background: transparent;
  border: 0;
  border-radius: 999px;
  font: inherit;
  font-size: 11.5px;
  color: var(--text-soft);
  cursor: pointer;
  transition: background 100ms ease, color 100ms ease;
}
.lb-chip:hover { color: var(--text); }
.lb-chip.is-active {
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(15,18,32,0.05);
}
.lb-chip-count {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
  padding: 1px 5px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  line-height: 1;
}
.lb-chip.is-active .lb-chip-count { background: var(--surface-2); }

.lb-summary-hint {
  margin-left: auto;
  font-size: 11.5px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* Board frame */
.lb-board {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-2);
  overflow: hidden;
}
.lb-cols {
  display: flex;
  align-items: stretch;
  gap: 10px;
  padding: 12px;
  overflow-x: auto;
  min-height: 300px;
}

/* Column - single per stage */
.lb-col {
  flex: 1 1 240px;
  min-width: 220px;
  max-width: 320px;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  min-height: 0;
}
.lb-col.is-muted {
  background: rgba(15,18,32,0.025);
  opacity: 0.85;
}
.lb-col.is-muted .lb-col-name { color: var(--text-muted); }

.lb-col-head {
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.lb-col-titles {
  display: flex;
  align-items: center;
  gap: 8px;
}
.lb-col-name {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text);
}
.lb-col.tone-amber .lb-col-name { color: #82591a; }
.lb-col.tone-blue  .lb-col-name { color: var(--accent-blue); }
.lb-col.tone-green .lb-col-name { color: #1a6b3c; }
.lb-col-count {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-muted);
  padding: 2px 7px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
}
.lb-col-meta {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--err, #c0392b);
  text-transform: uppercase;
}

.lb-col-cards {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 8px;
  min-height: 80px;
  border-radius: 0 0 10px 10px;
  transition: background 100ms ease, box-shadow 100ms ease;
}
.lb-col-cards.is-drop-over {
  background: var(--accent-blue-soft);
  box-shadow: inset 0 0 0 2px var(--accent-blue);
}
.lb-col-empty {
  font-size: 11px;
  color: var(--text-faint);
  text-align: center;
  padding: 8px 0;
  font-family: var(--font-mono);
}

/* Compact 2-line card */
.lb-card {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 7px 9px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: grab;
  position: relative;
  transition: box-shadow 100ms ease, border-color 100ms ease, transform 100ms ease;
}
.lb-card:hover {
  border-color: var(--text-muted);
  box-shadow: 0 3px 10px -5px rgba(15,18,32,0.18);
}
.lb-card:active { cursor: grabbing; }
.lb-card.is-dragging { opacity: 0.45; transform: scale(0.98); }
.lb-card.is-stale { border-left: 3px solid var(--err, #c0392b); padding-left: 7px; }

.lb-card-row {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.lb-card-row-meta { font-size: 11px; color: var(--text-soft); }
.lb-card-stale {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--err, #c0392b);
  flex-shrink: 0;
}
.lb-card-name {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.005em;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lb-card-age {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-muted);
  flex-shrink: 0;
}
.lb-card-company {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lb-card-company.is-muted { color: var(--text-faint); font-style: italic; }

/* Source tag - per-source tinted */
.lb-card-source {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-muted);
  border: 1px solid var(--border);
  flex-shrink: 0;
  line-height: 1;
}
.lb-card-source.tone-paid     { background: var(--accent-blue-soft); color: var(--accent-blue); border-color: rgba(43,108,176,0.2); }
.lb-card-source.tone-referral { background: #ede4f7;                 color: #6a3fa5;          border-color: rgba(124,75,162,0.18); }
.lb-card-source.tone-organic  { background: #e2f5e7;                 color: #1a6b3c;          border-color: rgba(26,107,60,0.2); }
.lb-card-source.tone-other    { background: var(--surface-2);        color: var(--text-muted); border-color: var(--border); }

/* Park-reason badge replaces source tag in parked column */
.lb-card-park {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 999px;
  flex-shrink: 0;
  line-height: 1;
  border: 1px solid;
}
.lb-card-park[data-reason="cold"]         { background: #f0f1f5; color: #4a5468; border-color: rgba(74,84,104,0.2); }
.lb-card-park[data-reason="disqualified"] { background: #fde9e9; color: #c0392b; border-color: rgba(192,57,43,0.25); }

/* Hover-revealed action row at the bottom of the card */
.lb-card-actions {
  display: none;
  gap: 4px;
  margin-top: 4px;
  padding-top: 6px;
  border-top: 1px dashed var(--border);
}
.lb-card:hover .lb-card-actions { display: flex; }
.lb-action {
  flex: 1;
  padding: 5px 8px;
  font: inherit;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text);
  background: var(--text);
  color: var(--surface);
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  transition: background 100ms ease, color 100ms ease;
  white-space: nowrap;
}
.lb-action:hover { background: #000; }
.lb-action-ghost {
  background: transparent;
  color: var(--text-soft);
  border: 1px solid var(--border);
}
.lb-action-ghost:hover {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--text-muted);
}
.pb-stage-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.pb-stage-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  flex-shrink: 0;
}
.pb-stage-view.tone-amber        .pb-stage-dot { background: #c08a2c; }
.pb-stage-view.tone-blue         .pb-stage-dot { background: var(--accent-blue, #3b6eff); }
.pb-stage-view.tone-legal        .pb-stage-dot { background: #4060d0; }
.pb-stage-view.tone-engineering  .pb-stage-dot { background: #0e8a82; }
.pb-stage-view.tone-creative     .pb-stage-dot { background: #c1467e; }
.pb-stage-view.tone-executive    .pb-stage-dot { background: #7c44d6; }

.pb-stage-name {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
  margin: 0;
}
.pb-stage-count {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--surface-2);
  padding: 2px 10px;
  border-radius: 999px;
}
.pb-stage-owners {
  display: inline-flex;
  align-items: center;
  margin-left: auto;
}
.pb-stage-desc {
  margin: 8px 0 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-muted);
  max-width: 780px;
}
.pb-owner-chip-lg {
  width: 28px; height: 28px;
  font-size: 11px;
  margin-left: -8px;
}

/* Steps strip */
.pb-steps-wrap {
  margin-bottom: 28px;
}
.pb-steps-label,
.pb-people-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 10px;
}
.pb-steps-strip {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  padding: 14px;
  background: var(--surface-2);
  border-radius: 10px;
  border: 1px solid var(--hairline, rgba(0,0,0,0.06));
}
.pb-step-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
}
.pb-step-chip.tone-amber       { background: #fff8eb; border-color: #f0d8a4; }
.pb-step-chip.tone-blue        { background: var(--accent-blue-soft, #e0eaff); border-color: #bcd0ff; }
.pb-step-chip.tone-legal       { background: var(--dept-legal, #d8e3ff); border-color: #b6c5ee; }
.pb-step-chip.tone-green       { background: #e3f5e9; border-color: #b7e0c4; }
.pb-step-chip.tone-engineering { background: var(--dept-engineering, #cdebe9); border-color: #a5d6d3; }
.pb-step-chip.tone-creative    { background: var(--dept-creative, #ffd4e0); border-color: #efb8c8; }
.pb-step-chip.tone-executive   { background: var(--dept-executive, #e9d8ff); border-color: #c9b2ec; }
.pb-step-num {
  font-family: var(--font-mono, monospace);
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}
.pb-step-name { font-size: 12px; color: var(--text); }
.pb-step-arrow {
  color: var(--text-muted);
  font-size: 13px;
  margin: 0 2px;
}
.pb-steps-empty {
  padding: 18px;
  font-size: 12.5px;
  color: var(--text-muted);
  text-align: center;
}

/* People grid */
.pb-people-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}
.pb-empty-lg {
  grid-column: 1 / -1;
  width: auto;
  padding: 40px;
  font-size: 13px;
}

/* The larger card */
.pb-card-lg {
  flex: none;
  padding: 16px 16px 14px;
  gap: 12px;
}
.pb-card-lg-head { cursor: pointer; }
.pb-card-lg-name {
  font-size: 16px;
  font-weight: 700;
  line-height: 1.25;
  color: var(--text);
}
.pb-card-lg-company {
  font-size: 12.5px;
  color: var(--text-muted);
  margin-top: 2px;
}
.pb-card-lg-email {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 6px;
  word-break: break-all;
}
.pb-card-lg-substep {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  margin-top: 12px;
  background: var(--surface-2);
  border-radius: 8px;
  border: 1px solid var(--hairline, rgba(0,0,0,0.06));
}
.pb-substep-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent-blue, #3b6eff);
  flex-shrink: 0;
  box-shadow: 0 0 0 3px rgba(59,110,255,0.18);
}
.pb-substep-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
}
.pb-card-lg-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 10px;
  margin-bottom: 12px;
}
.pb-card-lg-foot {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: auto;
}
.pb-card-lg-secondary {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.pb-action-lg {
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 600;
  justify-content: center;
}

/* ============================================================
   LEADS FLOW VIEW - per-lead nurture timeline
   ============================================================ */
.leads-flow-view .pb-stage-head { margin-bottom: 16px; }

/* Toolbar: search + filter button + sort button + total count */
.leads-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.leads-search-wrap {
  position: relative;
  flex: 1 1 280px;
  max-width: 380px;
}
.leads-search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}
.leads-search {
  width: 100%;
  height: 32px;
  padding: 0 12px 0 30px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  font: inherit;
  font-size: 12.5px;
  color: var(--text);
  transition: border-color 100ms ease, background 100ms ease;
}
.leads-search:hover { border-color: var(--text-muted); }
.leads-search:focus {
  outline: none;
  border-color: var(--text);
  background: var(--surface);
}
.leads-search::placeholder { color: var(--text-faint, var(--text-muted)); }

.leads-tools {
  display: flex;
  align-items: center;
  gap: 6px;
}
.leads-tool-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  position: relative;
  transition: border-color 100ms ease, background 100ms ease;
}
.leads-tool-btn:hover { background: var(--surface-2); border-color: var(--text-muted); }
.leads-tool-btn[aria-expanded="true"] { background: var(--surface-2); border-color: var(--text); }
.leads-tool-btn svg { color: var(--text-muted); }
.leads-tool-btn:hover svg, .leads-tool-btn[aria-expanded="true"] svg { color: var(--text); }
.leads-tool-chev { transition: transform 120ms ease; }
.leads-tool-btn[aria-expanded="true"] .leads-tool-chev { transform: rotate(180deg); }
.leads-tool-badge {
  font-size: 10px;
  font-weight: 700;
  background: var(--text);
  color: var(--surface);
  padding: 1px 6px;
  border-radius: 999px;
  min-width: 16px;
  text-align: center;
}
.leads-total {
  margin-left: auto;
  font-size: 11.5px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* Popover (filter / sort) - same recipe as the stage picker */
.leads-popover-wrap { position: relative; }
.leads-popover {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 240px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow:
    0 1px 2px rgba(0,0,0,0.04),
    0 10px 28px -10px rgba(20,18,14,0.18),
    0 3px 10px -4px rgba(20,18,14,0.08);
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: 1px;
  animation: pbStageMenuIn 120ms ease-out;
}
.leads-popover[hidden] { display: none; }
.leads-popover-group { display: flex; flex-direction: column; gap: 1px; }
.leads-popover-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-faint, var(--text-muted));
  padding: 6px 10px 4px;
}
.leads-popover-divider {
  height: 1px;
  background: var(--hairline, rgba(0,0,0,0.06));
  margin: 4px 6px;
}
.leads-popover-item {
  display: grid;
  grid-template-columns: 10px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  background: transparent;
  border: 0;
  border-radius: 6px;
  font: inherit;
  font-size: 12.5px;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  transition: background 100ms ease;
}
.leads-popover-item:not(:has(.leads-popover-dot)) { grid-template-columns: 1fr auto; }
.leads-popover-item:hover { background: var(--surface-2); }
.leads-popover-item.is-active { background: var(--surface-3, #ecebe7); font-weight: 600; }
.leads-popover-dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--text-muted);
}
.leads-popover-dot.tone-neutral      { background: var(--text-muted); }
.leads-popover-dot.tone-amber        { background: #c08a2c; }
.leads-popover-dot.tone-blue         { background: var(--accent-blue, #3b6eff); }
.leads-popover-dot.tone-legal        { background: #4060d0; }
.leads-popover-dot.tone-engineering  { background: #0e8a82; }
.leads-popover-dot.tone-creative     { background: #c1467e; }
.leads-popover-dot.tone-executive    { background: #7c44d6; }
.leads-popover-dot.tone-green        { background: #1f8a4c; }
.leads-popover-count {
  font-size: 10.5px;
  font-weight: 600;
  background: var(--surface-2);
  color: var(--text-muted);
  padding: 1px 7px;
  border-radius: 999px;
  min-width: 20px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.leads-popover-item:hover .leads-popover-count,
.leads-popover-item.is-active .leads-popover-count { background: var(--surface); }

/* Two-column layout: active leads stack on the left, persistent Parked
   column on the right. Sidebar is fixed-width so the active grid keeps a
   predictable column count regardless of viewport. */
.leads-board-with-parked {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 14px;
  align-items: stretch;
}

/* When the Pipeline body is viewport-locked on the Leads stage, both columns
   scroll internally instead of the page. Pillars stay hidden via the same
   scrollbar-width: none / -webkit-scrollbar trick used elsewhere. */
.pipeline-board-body.is-fixed-height .leads-flow-view {
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.pipeline-board-body.is-fixed-height .leads-board-with-parked {
  flex: 1 1 auto;
  min-height: 0;
  height: 100%;
}
.pipeline-board-body.is-fixed-height .leads-stack {
  overflow-y: auto;
  min-height: 0;
  align-content: start;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.pipeline-board-body.is-fixed-height .leads-stack::-webkit-scrollbar { width: 0; height: 0; display: none; }
.pipeline-board-body.is-fixed-height .leads-parked-col {
  position: static;
  height: 100%;
  top: auto;
}
@media (max-width: 900px) {
  .leads-board-with-parked {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* Lead grid - same shape as the Sales stage grid (.pb-step-grid) so every
   pipeline stage lays cards out identically. */
.leads-stack {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 10px;
  align-content: start;
  /* When empty (only the .lf-empty placeholder), keep a comfortable target
     height so drop-into-active still works visually. */
  min-height: 160px;
  padding: 4px;
  border-radius: 10px;
  transition: background 0.12s, box-shadow 0.12s;
}
.leads-stack.is-drop-target {
  background: rgba(22, 163, 74, 0.06);
  box-shadow: inset 0 0 0 1px rgba(22, 163, 74, 0.25);
}

/* Parked sidebar column - reuses .kbn-col base styles for visual parity
   with the Delivery board columns. Fixed full-viewport height (even when
   empty), so the column always reads as a real container that goes "all
   the way down". Scroll lives on the inner list, with hidden scrollbar. */
.leads-parked-col {
  position: sticky;
  top: 4px;
  height: calc(100vh - 160px);
  display: flex;
  flex-direction: column;
  overflow: hidden;             /* contain the scrolling list */
  min-height: 0;
}
.leads-parked-col .kbn-col-head { flex: 0 0 auto; }
.leads-parked-col .kbn-col-dot  { background: #6b6b6b; }
.leads-parked-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-right: 2px;
  /* Hide the native scrollbar; scrolling still works (wheel/trackpad/keys). */
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.leads-parked-list::-webkit-scrollbar { width: 0; height: 0; display: none; }
/* Cards inside must not shrink - otherwise a long Parked list would squeeze
   each card to fit, clipping content. Same pattern used in Delivery cols. */
.leads-parked-list > * { flex: 0 0 auto; }
/* Drag feedback */
.lf-drag-card { cursor: grab; }
.lf-drag-card.is-dragging {
  opacity: 0.55;
  cursor: grabbing;
  transform: rotate(-1deg);
}
.lf-empty {
  padding: 36px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  border: 1px dashed var(--border);
  border-radius: 10px;
}
.lf-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 18px;
  transition: border-color 100ms ease, box-shadow 100ms ease;
}
.lf-card:hover { border-color: var(--text-muted); box-shadow: 0 1px 4px rgba(0,0,0,0.04); }
.lf-card-head {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 12px;
}
.lf-card-id { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.lf-card-name {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
}
.lf-card-source {
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 2px 7px;
  border-radius: 999px;
}
.lf-card-source.tone-amber       { background: #fff1d8; color: #82591a; }
.lf-card-source.tone-blue        { background: var(--accent-blue-soft, #e0eaff); color: var(--accent-blue, #1e40af); }
.lf-card-source.tone-green       { background: #d3f2dd; color: #1a6b3c; }
.lf-card-source.tone-legal       { background: var(--dept-legal, #d8e3ff); color: var(--dept-legal-fg, #1f3da6); }
.lf-card-source.tone-creative    { background: var(--dept-creative, #ffd4e0); color: var(--dept-creative-fg, #a02050); }
.lf-card-source.tone-executive   { background: var(--dept-executive, #e9d8ff); color: var(--dept-executive-fg, #5b2bb1); }
.lf-card-source.tone-engineering { background: var(--dept-engineering, #cdebe9); color: var(--dept-engineering-fg, #0e5e57); }
.lf-card-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--text-muted);
}
.lf-card-meta > span:not(:last-child)::after {
  content: '·';
  margin-left: 8px;
  color: var(--text-faint, var(--text-muted));
}
.lf-card-age { font-variant-numeric: tabular-nums; }

.lf-flow-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.lf-flow-progress { color: var(--text-faint, var(--text-muted)); font-weight: 500; }

/* Timeline of steps - vertical stack, one step per row, tiny vertical rails
   between consecutive steps aligned under the dot column. */
.lf-timeline {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0;
  padding: 12px 14px;
  background: var(--surface-2);
  border-radius: 8px;
  margin-bottom: 10px;
}
.lf-step {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 500;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  transition: all 100ms ease;
}
.lf-step.is-done {
  background: #e3f5e9;
  border-color: #b7e0c4;
  color: #1a6b3c;
  font-weight: 600;
}
.lf-step.is-next {
  background: var(--text);
  border-color: var(--text);
  color: var(--surface);
  font-weight: 600;
  box-shadow: 0 0 0 3px rgba(20,18,14,0.08);
}
.lf-step.is-upcoming {
  background: transparent;
  border-style: dashed;
  color: var(--text-faint, var(--text-muted));
}
.lf-step-dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.lf-step-rail {
  width: 1px;
  height: 10px;
  margin: 2px 0 2px 13px;  /* left margin aligns rail under the step's dot center */
  background: var(--border-strong, var(--text-faint));
  opacity: 0.7;
}

/* Next-touch banner */
.lf-next {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--surface-2);
  border: 1px solid var(--hairline, rgba(0,0,0,0.06));
  border-radius: 8px;
  font-size: 12.5px;
  color: var(--text);
  margin-bottom: 10px;
}
.lf-next-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}
.lf-next-label { flex: 1; }
.lf-next-label strong { font-weight: 600; }
.lf-next-when {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
.lf-next-when.is-today {
  background: var(--accent-blue, #3b6eff);
  color: var(--surface);
}
.lf-next-when.is-overdue {
  background: #fff4dc;
  color: #8a5512;
}
.lf-next-done {
  background: #e3f5e9;
  border-color: #b7e0c4;
  color: #1a6b3c;
}

.lf-note {
  padding: 8px 12px;
  border-left: 3px solid var(--border-strong, var(--text-faint));
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
  margin-bottom: 10px;
}

.lf-card-foot {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  padding-top: 6px;
}

/* Field labels in modals - "required" marker variant */
.send-field-req {
  font-size: 10.5px;
  font-weight: 600;
  color: #c14545;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.send-field-hint {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 6px;
}
.send-field textarea {
  font: inherit;
  font-size: 13px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  resize: vertical;
  min-height: 64px;
}
.send-field textarea:focus {
  outline: none;
  border-color: var(--text);
}

/* ============================================================
   NEW LEAD - SCREENSHOT INTAKE
   Drag/drop/paste/browse area at the top of the New lead modal.
   Empty state is a clean dashed dropzone; once a file lands we
   swap to a row with a thumbnail + analyzer status. The whole
   block is keyboard-focusable so paste works without clicking.
   ============================================================ */
/* New-lead modal: give the stacked fields real vertical rhythm. The body becomes
   a flex column with a generous gap, so the dropzone, the 2x2 contact grid, and
   the Source / Avatar / Note fields all breathe evenly instead of touching.
   Scoped to this modal so other forms that reuse .send-field / .send-form-grid
   are untouched. */
#newLeadModal .modal-body {
  display: flex;
  flex-direction: column;
  gap: 18px;
}
#newLeadModal .lead-shot { margin-bottom: 0; }
#newLeadModal .send-form-grid { gap: 14px; }
#newLeadModal .send-form-grid .send-field { gap: 6px; }

/* Minimal screenshot dropzone. A clean frosted card - subtle fill, hairline
   border, soft shadow, light blur - with one floating upload-cloud icon (no
   tile) centered above the copy. The whole card is the dropzone: click to
   browse, drag a file in, or paste (Cmd/Ctrl+V) while the modal is open. */
.lead-shot {
  position: relative;
  overflow: hidden;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface-2) 55%, var(--surface));
  box-shadow: 0 1px 2px rgba(20,18,14,0.04), 0 10px 26px -20px rgba(20,18,14,0.20);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  padding: 28px 22px;
  margin-bottom: 16px;
  cursor: pointer;
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
  outline: none;
}
.lead-shot:hover {
  border-color: var(--border-strong);
  background: color-mix(in srgb, var(--surface-2) 78%, var(--surface));
  box-shadow: 0 1px 2px rgba(20,18,14,0.05), 0 14px 30px -20px rgba(20,18,14,0.26);
}
.lead-shot:focus-visible {
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-blue) 20%, transparent);
}
.lead-shot[data-state="dragover"] {
  border-color: var(--accent-blue);
  background: color-mix(in srgb, var(--accent-blue) 6%, var(--surface));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-blue) 18%, transparent);
}
.lead-shot[data-state="preview"],
.lead-shot[data-state="analyzing"],
.lead-shot[data-state="done"] {
  cursor: default;
  padding: 14px 14px;
}
.lead-shot[data-state="done"] {
  border-color: color-mix(in srgb, var(--accent-green, #2f9e6e) 45%, var(--border));
}

.lead-shot-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 14px;
}
.lead-shot[data-state="empty"] .lead-shot-empty { display: flex; }
.lead-shot[data-state="dragover"] .lead-shot-empty { display: flex; }
.lead-shot[data-state="preview"] .lead-shot-empty,
.lead-shot[data-state="analyzing"] .lead-shot-empty,
.lead-shot[data-state="done"] .lead-shot-empty { display: none; }

.lead-shot-icon {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  color: var(--accent-blue);
  filter: drop-shadow(0 3px 6px color-mix(in srgb, var(--accent-blue) 22%, transparent));
  transition: transform 180ms ease, color 160ms ease, filter 160ms ease;
}
.lead-shot:hover .lead-shot-icon {
  transform: translateY(-2px);
}
.lead-shot[data-state="dragover"] .lead-shot-icon {
  transform: translateY(-2px) scale(1.06);
}
.lead-shot-copy {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 0;
}
.lead-shot-title {
  font-size: 14.5px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.25;
}
.lead-shot-sub {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.45;
  max-width: 330px;
}
.lead-shot-browse {
  appearance: none;
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  font-size: 12px;
  color: var(--accent-blue);
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}
.lead-shot-browse:hover { color: color-mix(in srgb, var(--accent-blue) 80%, #000); }

.lead-shot-preview {
  /* Hidden by default - the data-state rules below reveal it only once a file
     is dropped / pasted (preview / analyzing / done). Must be `none` here, not
     `flex`: `flex` overrides the [hidden] attribute and the phantom preview
     (broken thumb + "Analyzing screenshot...") stacks under the empty state on
     a fresh modal. */
  display: none;
  align-items: center;
  gap: 12px;
}
.lead-shot[data-state="preview"] .lead-shot-preview,
.lead-shot[data-state="analyzing"] .lead-shot-preview,
.lead-shot[data-state="done"] .lead-shot-preview { display: flex; }

.lead-shot-thumb {
  flex: 0 0 56px;
  width: 56px;
  height: 56px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
}
.lead-shot-meta {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.lead-shot-status {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--text);
  font-weight: 600;
}
.lead-shot[data-state="done"] .lead-shot-status { color: var(--accent-green, #2f9e6e); }
.lead-shot[data-state="error"] .lead-shot-status { color: #c14545; }
.lead-shot-spinner {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1.6px solid color-mix(in srgb, var(--accent-blue) 30%, transparent);
  border-top-color: var(--accent-blue);
  animation: leadShotSpin 720ms linear infinite;
}
.lead-shot[data-state="done"] .lead-shot-spinner,
.lead-shot[data-state="error"] .lead-shot-spinner { display: none; }
@keyframes leadShotSpin { to { transform: rotate(360deg); } }
.lead-shot-found {
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.01em;
}
.lead-shot-clear {
  flex: 0 0 24px;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease;
}
.lead-shot-clear:hover {
  background: var(--surface-2);
  color: var(--text);
}

.modal-intro.lead-goal {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--hairline);
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.5;
}

/* ============================================================
   LEAD RAIL - INLINE EDIT FIELDS
   The Overview tab fields (name/email/phone/company) and the
   intake note are contenteditable spans. Default appearance is
   plain text - no chrome - so the value reads identically to
   the read-only version. Hover and focus reveal subtle affordance
   so the user knows it's editable, then they type and on blur
   we persist + lightly re-render outside the rail.
   ============================================================ */
.lead-kv-edit dd { min-width: 0; }
.lead-edit-field {
  display: inline-block;
  min-width: 24px;
  padding: 2px 6px;
  margin: -2px -6px;
  border-radius: 6px;
  color: inherit;
  cursor: text;
  outline: none;
  transition: background 120ms ease, box-shadow 120ms ease;
  white-space: pre-wrap;
  word-break: break-word;
  max-width: 100%;
}
.lead-edit-field:hover {
  background: color-mix(in srgb, var(--accent-blue, #3b6eff) 5%, var(--surface-2));
}
.lead-edit-field:focus,
.lead-edit-field:focus-visible {
  background: var(--surface);
  box-shadow: 0 0 0 1.5px color-mix(in srgb, var(--accent-blue, #3b6eff) 55%, transparent);
}
.lead-edit-field:empty::before {
  content: attr(data-placeholder);
  color: var(--text-faint);
  pointer-events: none;
}
.lead-edit-field-multi {
  display: block;
  min-height: 38px;
  padding: 10px 12px;
  margin: 0;
  line-height: 1.5;
}
/* When the editable field is followed by an inline copy button, neutralise
   the field's negative right margin so the copy icon doesn't sit on top of
   the field's hover background. The .copy-field gap (6px) handles spacing. */
.lead-edit-copy .lead-edit-field { margin-right: 0; }
/* The intake-note container reuses .rail-note-body for the soft grey card;
   we zero its padding here so the inner contenteditable owns the inset and
   the focus ring lines up with the card edge. */
.lead-note-edit.rail-note-body {
  padding: 0;
}
.lead-note-edit .lead-edit-field-multi {
  padding: 10px 12px;
  border-radius: 8px;
}

/* ============================================================
   LEAD RAIL - AVATAR TAB
   Dropdown picker at the top, then a persona detail card, then
   an AI summary block. Persona detail uses an initials mark in
   the persona's accent color (--avatar-tone), tag chips, and a
   labeled field stack so all profile data is scannable.
   ============================================================ */
.lead-avatar-tab {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.lead-avatar-picker {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.lead-avatar-picker-label {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.lead-avatar-picker-control { position: relative; }
.lead-avatar-select {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  padding: 10px 36px 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface) url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>") right 12px center / 12px no-repeat;
  font: inherit;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
}
.lead-avatar-select:focus {
  outline: 2px solid color-mix(in srgb, var(--accent-blue, #3b6eff) 35%, transparent);
  outline-offset: 1px;
}

.lead-avatar-empty {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  padding: 18px;
  border: 1px dashed var(--border);
  border-radius: 12px;
  background: var(--surface-2);
}
.lead-avatar-empty-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
}
.lead-avatar-empty-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
}
.lead-avatar-empty-body {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
}

.lead-avatar-card {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: linear-gradient(180deg, var(--surface) 0%, color-mix(in srgb, var(--avatar-tone) 5%, var(--surface)) 100%);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.lead-avatar-card-head {
  display: flex;
  align-items: center;
  gap: 12px;
}
.lead-avatar-mark {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: var(--avatar-tone);
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.02em;
  flex-shrink: 0;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.04), 0 2px 6px color-mix(in srgb, var(--avatar-tone) 35%, transparent);
}
.lead-avatar-card-meta { min-width: 0; }
.lead-avatar-card-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
  letter-spacing: -0.01em;
}
.lead-avatar-card-sub {
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  font-size: 11px;
}
.lead-avatar-card-cat {
  padding: 2px 7px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--avatar-tone) 14%, transparent);
  color: color-mix(in srgb, var(--avatar-tone) 70%, var(--text));
  font-weight: 600;
}
.lead-avatar-card-prio {
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-muted);
  font-weight: 500;
  border: 1px solid var(--border);
}
.lead-avatar-headline {
  margin: 0;
  font-size: 13.5px;
  color: var(--text);
  line-height: 1.45;
  font-style: italic;
}
.lead-avatar-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.lead-avatar-tag {
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-soft, var(--text-muted));
  font-weight: 500;
}
/* Concise overview block - 3 short summary rows (Who / Pain / Offer) shown
   by default. Lives between the tag chips and the "Show full profile" toggle
   so the user can size up the persona at a glance without scrolling. */
.lead-avatar-overview {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 0 4px;
  border-top: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
}
.lead-avatar-overview-row {
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 12px;
  align-items: baseline;
}
.lead-avatar-overview-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.lead-avatar-overview-body {
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--text);
}
.lead-avatar-expand {
  appearance: none;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-soft, var(--text-muted));
  font: inherit;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
  padding: 7px 10px;
  border-radius: 8px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  align-self: flex-start;
  transition: background 140ms ease, color 140ms ease, border-color 140ms ease;
}
.lead-avatar-expand:hover {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--text-faint);
}
.lead-avatar-fields {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-top: 4px;
}
.lead-avatar-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.lead-avatar-field-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.lead-avatar-field-body {
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--text);
}
.lead-avatar-list {
  margin: 0;
  padding: 0 0 0 16px;
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--text);
}
.lead-avatar-list li { margin: 2px 0; }

/* AI summary callout - sits below the persona card. Has a subtle gradient
   border and a small sparkle glyph in the header so it reads as
   model-generated, not editorial. */
.lead-avatar-ai {
  position: relative;
  border-radius: 14px;
  padding: 14px 14px 16px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent-blue, #3b6eff) 5%, var(--surface)) 0%, var(--surface) 100%);
  border: 1px solid color-mix(in srgb, var(--accent-blue, #3b6eff) 22%, var(--border));
}
.lead-avatar-ai-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.lead-avatar-ai-glyph {
  width: 22px;
  height: 22px;
  border-radius: 7px;
  display: grid;
  place-items: center;
  background: var(--accent-blue, #3b6eff);
  color: #fff;
}
.lead-avatar-ai-title {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.005em;
}
.lead-avatar-ai-source {
  margin-left: auto;
  font-size: 10.5px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.lead-avatar-ai-body {
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--text);
}
.lead-avatar-ai-body.is-empty {
  color: var(--text-muted);
}

/* ============================================================
   DELIVERY KANBAN BOARD
   ============================================================
   Two surfaces share the same primitives:
   - Per-client board in the client rail Flow tab (horizontal scroll)
   - Global Delivery page (full-width 4-column grid)
   Status accent: each column has a colored dot + each card a left border.
   ============================================================ */

.delivery-board-wrap {
  margin-top: 4px;
}
.delivery-board-page {
  padding: 12px 16px 32px;
  overflow: hidden;
}

.kbn-board {
  display: grid;
  grid-template-columns: repeat(4, minmax(240px, 1fr));
  gap: 10px;
}
.delivery-board-wrap .kbn-board {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 8px;
  scrollbar-width: thin;
}
.delivery-board-wrap .kbn-col {
  min-width: 230px;
  max-width: 280px;
  flex: 0 0 auto;
}
.kbn-page-board {
  width: 100%;
}
.kbn-page-board .kbn-board {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.kbn-col {
  display: flex;
  flex-direction: column;
  gap: 8px;
  /* soft vertical gradient for a modern, lit feel (was flat --surface-2) */
  background: linear-gradient(180deg, #faf9f7 0%, #f2f0ec 100%);
  border: 1px solid var(--border, rgba(0,0,0,0.07));
  border-radius: 10px;
  padding: 10px 8px 10px;
  min-height: 160px;
  transition: background 0.12s, border-color 0.12s, box-shadow 0.12s;
}
/* Per-status column tint - a slight gradient fill keyed to each column's dot
   color, so the board reads as gently color-coded. Kept very low-alpha. */
.kbn-col-todo   { background: linear-gradient(180deg, #f7f8fa 0%, #eceef2 100%); }
.kbn-col-doing  { background: linear-gradient(180deg, #fffbe6 0%, #fdf5c8 100%); }
.kbn-col-review { background: linear-gradient(180deg, #f8f5fd 0%, #efeaf8 100%); }
.kbn-col-done   { background: linear-gradient(180deg, #f1faf4 0%, #e8f4ec 100%); }

/* Drop target lights up in the destination column's OWN dot color (not a
   generic green) so it is obvious where the card will land. */
.kbn-col.is-drop-target { border-color: rgba(20, 18, 14, 0.18); box-shadow: inset 0 0 0 1px rgba(20, 18, 14, 0.10); }
.kbn-col-todo.is-drop-target   { background: linear-gradient(180deg, #eef1f6 0%, #e3e7ee 100%); border-color: rgba(148, 163, 184, 0.6); box-shadow: inset 0 0 0 1.5px rgba(148, 163, 184, 0.4); }
.kbn-col-doing.is-drop-target  { background: linear-gradient(180deg, #fff7cc 0%, #ffefa0 100%); border-color: rgba(255, 214, 10, 0.9);  box-shadow: inset 0 0 0 1.5px rgba(240, 185, 0, 0.6); }
.kbn-col-review.is-drop-target { background: linear-gradient(180deg, #f1ebfd 0%, #e7dcfb 100%); border-color: rgba(139, 92, 246, 0.6); box-shadow: inset 0 0 0 1.5px rgba(139, 92, 246, 0.45); }
.kbn-col-done.is-drop-target   { background: linear-gradient(180deg, #e6f8ec 0%, #d6f0e0 100%); border-color: rgba(34, 197, 94, 0.6);  box-shadow: inset 0 0 0 1.5px rgba(34, 197, 94, 0.45); }

.kbn-col-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 2px 6px 4px;
}
/* ---------------------------------------------------------------------
   STATUS DOTS - solid, tiny, modern. Flat color fill + a soft subtle glow
   (echoing the reference dots). Drives BOTH the column header dots and the
   card status dots in sync. TO DO stays a calm neutral with no glow.
   --------------------------------------------------------------------- */
.kbn-col-dot,
.kbn-card-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: 0 0 auto;
  background: #94a3b8;
}
/* TO DO - calm neutral slate (no glow, kept quiet on purpose). */
.kbn-col-todo          .kbn-col-dot,
.kbn-card-status-todo  .kbn-card-status-dot {
  background: #94a3b8;
}
/* IN PROGRESS - bright Snapchat-style yellow. Faint darker ring defines the
   edge so the bright yellow stays visible on the light column. */
.kbn-col-doing          .kbn-col-dot,
.kbn-card-status-doing  .kbn-card-status-dot {
  background: #ffe000;
  box-shadow:
    0 0 0 0.5px rgba(190, 150, 0, 0.5),
    0 0 7px 0 rgba(255, 224, 0, 0.7);
}
/* IN REVIEW - modern violet. */
.kbn-col-review          .kbn-col-dot,
.kbn-card-status-review  .kbn-card-status-dot {
  background: #8b5cf6;
  box-shadow: 0 0 6px 0 rgba(139, 92, 246, 0.5);
}
/* DONE - modern green. */
.kbn-col-done          .kbn-col-dot,
.kbn-card-status-done  .kbn-card-status-dot {
  background: #22c55e;
  box-shadow: 0 0 6px 0 rgba(34, 197, 94, 0.5);
}
.kbn-col-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  color: var(--text-muted, #6b6b6b);
  flex: 1 1 auto;
}
.kbn-col-count {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted, #6b6b6b);
  background: var(--surface, #fff);
  border: 1px solid var(--border, rgba(0,0,0,0.07));
  border-radius: 999px;
  padding: 1px 8px;
  min-width: 22px;
  text-align: center;
}

.kbn-col-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.kbn-col-empty {
  font-size: 11.5px;
  color: var(--text-faint, #b3afa5);
  text-align: center;
  padding: 14px 6px;
  border: 1px dashed var(--border, rgba(0,0,0,0.08));
  border-radius: 8px;
  background: transparent;
}

/* "+ add custom task" affordance - To Do column only. Pure icon button, no
   label. Sits flush below the card list, full column width, subtle until
   hover. */
.kbn-col-add {
  appearance: none;
  background: transparent;
  border: 1px dashed var(--border, rgba(0,0,0,0.12));
  border-radius: 8px;
  margin-top: 8px;
  padding: 6px 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-faint, #b3afa5);
  cursor: pointer;
  font-family: inherit;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.kbn-col-add:hover {
  background: var(--surface-2, #f7f6f3);
  color: var(--text, #1a1a1a);
  border-color: rgba(0,0,0,0.22);
}
.kbn-col-add:focus-visible {
  outline: 2px solid var(--text, #1a1a1a);
  outline-offset: 2px;
}

/* ---------------------------------------------------------------------
   CARD SURFACE - frosted glass. A translucent panel + backdrop blur picks
   up the tinted column behind it; a subtle film-grain layer adds texture.
   Card content rides above the grain via z-index. Falls back to a mostly
   opaque panel where backdrop-filter is unsupported.
   --------------------------------------------------------------------- */
.kbn-card {
  position: relative;
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: 12px;
  padding: 0;
  display: flex;
  flex-direction: column;
  cursor: grab;
  /* glassy edge: top sheen + crisp ring + a light seat (no heavy shadow) */
  box-shadow:
    inset 0 1px 0 0 rgba(255, 255, 255, 0.85),
    inset 0 0 0 1px rgba(255, 255, 255, 0.25),
    0 0 0 1px rgba(20, 18, 14, 0.03),
    0 1px 3px -1px rgba(20, 18, 14, 0.06);
  transition:
    transform 0.10s ease,
    box-shadow 0.16s ease,
    border-color 0.16s ease;
  overflow: hidden;
}
@supports ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
  .kbn-card {
    background: rgba(255, 255, 255, 0.5);
    -webkit-backdrop-filter: blur(13px) saturate(1.5);
    backdrop-filter: blur(13px) saturate(1.5);
  }
}
/* Subtle film grain over the glass - sits below the card content. */
.kbn-card::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  border-radius: inherit;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23g)'/%3E%3C/svg%3E");
  background-size: 140px 140px;
  opacity: 0.4;
  mix-blend-mode: overlay;
}
/* Card content rides above the grain layer. */
.kbn-card-head,
.kbn-card-body { position: relative; z-index: 1; }
/* Hover affordance = a tiny crisp outline ring, no lift, no drop shadow. */
.kbn-card:hover {
  border-color: var(--border-strong, #d8d5cd);
  box-shadow:
    inset 0 1px 0 0 rgba(255, 255, 255, 0.9),
    inset 0 0 0 1px rgba(255, 255, 255, 0.3),
    0 0 0 1.5px rgba(20, 18, 14, 0.30);
}
.kbn-card.is-dragging {
  opacity: 0.55;
  cursor: grabbing;
  transform: rotate(-1deg);
  box-shadow:
    inset 0 1px 0 0 rgba(255, 255, 255, 0.9),
    0 0 0 1px rgba(20, 18, 14, 0.06),
    0 18px 40px -12px rgba(20, 18, 14, 0.26);
}
/* Cards stay clean white (no per-status wash) so they pop against the tinted
   columns. Done keeps only its muted title below. */
.kbn-status-done .kbn-card-title { color: var(--text-muted, #807c73); }

/* ---------- Card: head (status pill + actor stack) ---------- */
/* Head reads as a faintly brighter glassy band on the card. No own backdrop-
   filter - the card already blurs - to avoid nested-blur artifacts. */
.kbn-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 10px 9px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.42) 0%, rgba(255, 255, 255, 0.14) 100%);
  border-bottom: 1px solid rgba(255, 255, 255, 0.5);
  box-shadow: inset 0 -1px 0 rgba(20, 18, 14, 0.04);
}
.kbn-card-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted, #6b6b6b);
  background: var(--surface, #fff);
  border: 1px solid var(--border, rgba(0,0,0,0.1));
  border-radius: 999px;
  padding: 3px 10px 3px 8px;
}
/* .kbn-card-status-dot is styled together with .kbn-col-dot above (shared
   solid-dot rules) so the column + card status dots stay in sync. */

.kbn-card-actors {
  display: inline-flex;
  align-items: center;
  gap: 0;
}
.kbn-card-actors > .kbn-actor + .kbn-actor { margin-left: -6px; }
.kbn-actor {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  font-size: 9.5px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  /* Client Journey palette: soft dept-tinted bg + dark-tinted text, white ring.
     Dept class is emitted by renderCardActorsHtml; this is the neutral default. */
  color: var(--dept-operations-fg);
  background: var(--dept-operations);
  border: 1.5px solid var(--surface);
  letter-spacing: 0.02em;
}
.kbn-actor.executive   { background: var(--dept-executive);   color: var(--dept-executive-fg); }
.kbn-actor.operations  { background: var(--dept-operations);  color: var(--dept-operations-fg); }
.kbn-actor.finance     { background: var(--dept-finance);     color: var(--dept-finance-fg); }
.kbn-actor.legal       { background: var(--dept-legal);       color: var(--dept-legal-fg); }
.kbn-actor.creative    { background: var(--dept-creative);    color: var(--dept-creative-fg); }
.kbn-actor.growth      { background: var(--dept-growth);      color: var(--dept-growth-fg); }
.kbn-actor.engineering { background: var(--dept-engineering); color: var(--dept-engineering-fg); }
.kbn-actor-more {
  background: var(--surface-3);
  color: var(--text-soft);
}
.kbn-actor-external {
  background: repeating-linear-gradient(45deg, #b3afa5, #b3afa5 3px, #d9d6d0 3px, #d9d6d0 6px);
}
.kbn-card-add {
  margin-left: 6px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--surface, #fff);
  border: 1px dashed var(--border, rgba(0,0,0,0.25));
  color: var(--text-muted, #6b6b6b);
  cursor: pointer;
  padding: 0;
  transition: background 0.1s, color 0.1s, border-color 0.1s;
}
.kbn-card-add:hover {
  background: var(--text, #1a1a1a);
  color: #fff;
  border-color: var(--text, #1a1a1a);
  border-style: solid;
}

/* ---------- Card: body ---------- */
.kbn-card-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 12px 11px;
}

.kbn-card-client {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted, #6b6b6b);
  background: transparent;
  border: none;
  padding: 0;
  cursor: pointer;
  text-align: left;
  width: max-content;
  max-width: 100%;
}
.kbn-card-client:hover { color: var(--text, #1a1a1a); }
.kbn-card-client-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.55;
  flex: 0 0 auto;
}
.kbn-card-client-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.kbn-card-client-co {
  color: var(--text-faint, #b3afa5);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kbn-card-title {
  font-size: 13px;
  line-height: 1.38;
  color: var(--text, #14130f);
  font-weight: 600;
  letter-spacing: -0.006em;
  margin: 2px 0;
}
.kbn-card-num {
  display: inline-block;
  margin-right: 8px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--text-faint, #b3afa5);
  font-variant-numeric: tabular-nums;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  vertical-align: 1px;
}
.kbn-status-done .kbn-card-num { opacity: 0.55; }

/* Step-number pill at the top of each kanban card (replaces the old status
   pill - status is already implied by the column the card lives in). */
.kbn-card-num-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  padding: 2px 8px;
  border-radius: 999px;
  background: linear-gradient(180deg, #ffffff 0%, var(--surface-3, #ecebe7) 100%);
  border: 1px solid var(--border, #e7e5e0);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.9),
    0 1px 1px rgba(20, 18, 14, 0.03);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--text-soft, #3d3a34);
  font-variant-numeric: tabular-nums;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
/* Invisible placeholder so cards without a step index still keep the head
   row aligned (actors push to the right via the existing flex layout). */
.kbn-card-num-pill-placeholder {
  visibility: hidden;
}
.kbn-status-done .kbn-card-num-pill { opacity: 0.55; }

/* Respect reduced-motion: drop the hover lift transform on kanban cards. */
@media (prefers-reduced-motion: reduce) {
  .kbn-card { transition: box-shadow 0.16s ease, border-color 0.16s ease; }
  .kbn-card:hover { transform: none; }
}

.kbn-card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 4px;
}
.kbn-card-foot-left,
.kbn-card-foot-right {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
/* Let the left cluster wrap if a "Changes requested" tab + chips get crowded. */
.kbn-card-foot-left { flex-wrap: wrap; row-gap: 5px; min-width: 0; }
/* Returned-for-changes tab - a compact red flag at the card's bottom-left. The
   full reason lives in the task detail view; this just signals "needs attention". */
.kbn-card-flag-changes {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.01em;
  white-space: nowrap;
  color: #c92a2a;
  background: rgba(201, 42, 42, 0.10);
  border: 1px solid rgba(201, 42, 42, 0.24);
  border-radius: 999px;
  padding: 3px 9px 3px 7px;
}
.kbn-card-flag-changes svg { flex: 0 0 auto; }
.kbn-card-due {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 600;
  color: #15803d;
  background: rgba(132, 204, 22, 0.18);
  border-radius: 999px;
  padding: 3px 9px 3px 7px;
}
/* SLA color variants for the due chip. data-sla is set by renderCardOpsChipsHtml. */
.kbn-card-due[data-sla="overdue"]  { color: #b91c1c; background: rgba(248, 113, 113, 0.22); }
.kbn-card-due[data-sla="due-soon"] { color: #b45309; background: rgba(251, 191, 36, 0.22); }
.kbn-card-due[data-sla="on-track"] { color: #15803d; background: rgba(132, 204, 22, 0.18); }
.kbn-card-due[data-sla="no-sla"]   { color: var(--text-muted, #6b6b6b); background: rgba(0,0,0,0.05); }

/* Generic operational chip used for Blocked / Client approval / Automation. */
.kbn-card-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 999px;
  padding: 3px 9px 3px 7px;
  color: var(--text-muted, #6b6b6b);
  background: rgba(0,0,0,0.05);
}
.kbn-card-chip-blocked { color: #b91c1c; background: rgba(248, 113, 113, 0.22); }
.kbn-card-chip-client  { color: #6d28d9; background: rgba(167, 139, 250, 0.22); }
.kbn-card-chip-auto    { color: #1d4ed8; background: rgba(96, 165, 250, 0.20); }
.kbn-card-chip-auto[data-auto="success"] { color: #15803d; background: rgba(132, 204, 22, 0.18); }
.kbn-card-chip-auto[data-auto="failure"] { color: #b91c1c; background: rgba(248, 113, 113, 0.22); }
.kbn-card-chip-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: currentColor;
  display: inline-block;
}
/* "Running" automation dot is intentionally STATIC - no pulse animation. */
.kbn-card-phase {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
  color: var(--text-faint, #b3afa5);
}
.kbn-card-icon-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: transparent;
  border: 1px solid var(--border, rgba(0,0,0,0.1));
  border-radius: 8px;
  padding: 4px 7px;
  color: var(--text-muted, #6b6b6b);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.1s, color 0.1s, border-color 0.1s;
}
.kbn-card-icon-btn:hover {
  color: var(--text, #1a1a1a);
  border-color: rgba(0,0,0,0.2);
  background: var(--surface-2, #f7f6f3);
}
.kbn-card-icon-count { font-variant-numeric: tabular-nums; }

/* Legacy class still referenced inside renderDeliveryOwnersHtml (kept for the
   client rail's delivery board surface, which uses the old card layout). */
.kbn-card-owners {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
}
.kbn-card-owners > .kbn-owner + .kbn-owner { margin-left: -6px; }
.kbn-owner {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  font-size: 9.5px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: hsl(var(--owner-hue, 0), 55%, 48%);
  border: 1.5px solid var(--surface, #fff);
  letter-spacing: 0.02em;
}
.kbn-owner-external {
  background: repeating-linear-gradient(45deg, #b3afa5, #b3afa5 3px, #d9d6d0 3px, #d9d6d0 6px);
  color: #fff;
}
.kbn-owner-empty {
  background: transparent;
  color: var(--text-faint, #b3afa5);
  border: 1px dashed var(--border, rgba(0,0,0,0.18));
  font-weight: 400;
}

/* Adjustment note from a reviewer - shown on cards that came back from In
   Review with rework notes. Lives on the card while it sits in To Do (and
   stays visible if work resumes in In Progress), gets cleared on Done. */
.kbn-card-note {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  font-size: 10.5px;
  line-height: 1.4;
  color: #b45309;
  background: rgba(217, 119, 6, 0.08);
  border-radius: 6px;
  padding: 5px 8px;
  width: 100%;
  max-width: 100%;
}
.kbn-card-note svg { flex-shrink: 0; margin-top: 2px; }
.kbn-card-note span { word-wrap: break-word; min-width: 0; }

/* ============================================================
   PIPELINE PAGE HEADER FILTERS
   ============================================================
   Replaces the page-sub line when the Pipeline is scoped to the
   Delivery stage. Two equal-width selects (Client + Assignee) with
   small uppercase eyebrow labels. Sits inline with the page title.
   ============================================================ */
.pipeline-stage-filters {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  align-items: flex-end;
  justify-content: flex-start;
  gap: 18px;
  margin-left: 8px;
}
.pipeline-stage-filters[hidden] { display: none; }

/* Leads-stage toolbar variant: lives in the middle of the header, centered
   between the "Pipeline" title (left) and the action buttons (right). */
.pipeline-stage-filters.is-leads-toolbar {
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-left: 0;
  padding-left: 0;
  position: relative;
}
.pipeline-stage-filters.is-leads-toolbar .leads-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: nowrap;
  margin-bottom: 0;
}
.pipeline-stage-filters.is-leads-toolbar .leads-search-wrap {
  flex: 0 0 320px;
  max-width: 320px;
}
.pipeline-stage-filters.is-leads-toolbar .leads-search { height: 30px; }
.psf-field {
  display: inline-flex;
  flex-direction: column;
  gap: 3px;
}
.psf-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  color: var(--text-faint, #b3afa5);
  line-height: 1;
}
.psf-select {
  appearance: none;
  -webkit-appearance: none;
  width: 220px;
  max-width: 220px;
  background: var(--surface, #fff);
  border: 1px solid var(--border, rgba(0,0,0,0.1));
  border-radius: 8px;
  padding: 6px 26px 6px 10px;
  font-size: 12.5px;
  color: var(--text, #1a1a1a);
  font-family: inherit;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236b6b6b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='m6 9 6 6 6-6'/></svg>");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 11px;
  cursor: pointer;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
}
.psf-select:hover  { border-color: rgba(0, 0, 0, 0.22); }
.psf-select:focus  { outline: none; border-color: var(--text, #1a1a1a); }

/* Custom trigger button that replaces the native <select> for the Delivery
   > Per Client filters. Paired with .psf-pop (a variant of .assign-pop). */
.psf-trigger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: 240px;
  max-width: 240px;
  background: var(--surface, #fff);
  border: 1px solid var(--border, rgba(0,0,0,0.1));
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12.5px;
  color: var(--text, #1a1a1a);
  font-family: inherit;
  cursor: pointer;
  text-align: left;
  line-height: 1.2;
  transition: border-color 0.12s, background 0.12s;
}
.psf-trigger:hover:not([disabled]) { border-color: rgba(0, 0, 0, 0.22); }
.psf-trigger:focus { outline: none; border-color: var(--text, #1a1a1a); }
.psf-trigger[disabled] { cursor: not-allowed; color: var(--text-faint, #b3afa5); }
.psf-trigger-text {
  flex: 1 1 auto;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.psf-trigger-chev {
  flex: 0 0 auto;
  color: var(--text-muted, #6b6b6b);
}
.psf-pop-plain .assign-pop-row { grid-template-columns: 1fr 16px; }

/* Single filter icon that replaces the Client + Assignee dropdowns on the
   project board. Sits on the right of the page header; opens one popover that
   holds both pickers. A small dot marks it when an assignee filter is active. */
#deliveryBoardFilters {
  flex: 1 1 0;
  justify-content: flex-end;
  align-items: center;
}
.psf-filter-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  background: var(--surface, #fff);
  border: 1px solid var(--border, rgba(0,0,0,0.1));
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text, #1a1a1a);
  font-family: inherit;
  line-height: 1;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s, color 0.12s;
}
.psf-filter-btn:hover { border-color: rgba(0, 0, 0, 0.22); background: var(--surface-2, #f7f6f3); }
.psf-filter-btn:focus-visible { outline: none; border-color: var(--text, #1a1a1a); }
.psf-filter-btn svg { flex: 0 0 auto; color: var(--text-muted, #6b6b6b); }
.psf-filter-btn.is-active { border-color: var(--accent-blue, #2563eb); color: var(--text, #1a1a1a); }
.psf-filter-btn.is-active svg { color: var(--accent-blue, #2563eb); }
.psf-filter-label { white-space: nowrap; }
.psf-filter-dot {
  position: absolute;
  top: -3px;
  right: -3px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-blue, #2563eb);
  border: 1.5px solid var(--surface, #fff);
}

/* Combined Project + Assignee filter popover. Two stacked, independently
   scrollable sections under one panel; selections apply live. */
.psf-filter-pop { max-height: 460px; }
.psf-filter-pop .psf-filter-head { padding-bottom: 8px; }
.psf-filter-section { display: flex; flex-direction: column; }
.psf-filter-section-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
  color: var(--text-faint, #b3afa5);
  padding: 4px 12px 2px;
}
.psf-filter-pop .assign-pop-list { max-height: 156px; }
.psf-filter-divider {
  height: 1px;
  background: var(--border, rgba(0,0,0,0.08));
  margin: 6px 10px;
}
.psf-filter-empty {
  padding: 8px 12px 10px;
  font-size: 12px;
  color: var(--text-faint, #b3afa5);
}

/* ---------- Global page: filters + header summary ---------- */
.kbn-filters {
  display: flex;
  align-items: center;
  gap: 10px 14px;
  flex-wrap: wrap;
  padding: 6px 2px 14px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--border, rgba(0,0,0,0.06));
}
.kbn-filter {
  display: inline-flex;
  flex-direction: column;
  gap: 3px;
}
.kbn-filter-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  color: var(--text-faint, #b3afa5);
}
.kbn-filter-select {
  appearance: none;
  -webkit-appearance: none;
  background: var(--surface, #fff);
  border: 1px solid var(--border, rgba(0,0,0,0.1));
  border-radius: 6px;
  padding: 5px 22px 5px 8px;
  font-size: 12px;
  color: var(--text, #1a1a1a);
  font-family: inherit;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236b6b6b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='m6 9 6 6 6-6'/></svg>");
  background-repeat: no-repeat;
  background-position: right 6px center;
  background-size: 10px;
  min-width: 150px;
  cursor: pointer;
}
.kbn-filter-select:focus {
  outline: none;
  border-color: var(--text, #1a1a1a);
}
.kbn-filter-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted, #6b6b6b);
  cursor: pointer;
  align-self: flex-end;
  padding-bottom: 5px;
}
.kbn-filter-toggle input { accent-color: #16a34a; cursor: pointer; }
.kbn-filter-clear {
  align-self: flex-end;
  background: transparent;
  border: 1px solid var(--border, rgba(0,0,0,0.1));
  color: var(--text-muted, #6b6b6b);
  font-size: 11px;
  border-radius: 6px;
  padding: 5px 9px;
  cursor: pointer;
  margin-bottom: 0;
}
.kbn-filter-clear:hover {
  border-color: var(--text, #1a1a1a);
  color: var(--text, #1a1a1a);
}

/* ---------- Assignee popover (the + on each card) ---------- */
.assign-pop {
  position: absolute;
  z-index: 9000;
  width: 260px;
  max-height: 360px;
  background: var(--surface, #fff);
  border: 1px solid var(--border, rgba(0,0,0,0.12));
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(0,0,0,0.14);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  font-family: inherit;
}

/* Card operational-fields popover (the "≡" menu, #6). */
.card-ops-pop {
  position: absolute;
  z-index: 9000;
  width: 280px;
  background: var(--surface, #fff);
  border: 1px solid var(--border, rgba(0,0,0,0.12));
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(0,0,0,0.14);
  font-family: inherit;
  overflow: hidden;
}
.card-ops-pop-head {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
  color: var(--text-faint, #b3afa5);
  padding: 10px 12px 6px;
}
.card-ops-pop-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 4px 12px 12px;
}
.card-ops-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.card-ops-row-toggle {
  flex-direction: row;
  align-items: center;
  gap: 8px;
}
.card-ops-label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 700;
  color: var(--text-muted, #6b6b6b);
}
.card-ops-input {
  font: inherit;
  font-size: 12.5px;
  color: var(--text, #1a1a1a);
  background: var(--surface-2, #f7f6f3);
  border: 1px solid var(--border, rgba(0,0,0,0.1));
  border-radius: 7px;
  padding: 6px 8px;
  outline: none;
  width: 100%;
  box-sizing: border-box;
}
.card-ops-input:focus {
  border-color: rgba(59, 130, 246, 0.6);
  background: var(--surface, #fff);
}
.card-ops-textarea {
  resize: vertical;
  min-height: 44px;
  font-family: inherit;
}
.assign-pop-head {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
  color: var(--text-faint, #b3afa5);
  padding: 10px 12px 6px;
}
.assign-pop-list {
  overflow-y: auto;
  padding: 2px 4px 6px;
  display: flex;
  flex-direction: column;
  gap: 1px;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.assign-pop-list::-webkit-scrollbar { width: 0; height: 0; display: none; }
.assign-pop-row {
  display: grid;
  grid-template-columns: 24px 1fr 16px;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  background: transparent;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  color: var(--text, #1a1a1a);
}
.assign-pop-row:hover { background: var(--surface-2, #f7f6f3); }
.assign-pop-row.is-checked { background: rgba(22, 163, 74, 0.06); }
.assign-pop-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  font-size: 10px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  /* Default = hsl fallback (still used by the filter popovers that pass a hue);
     the "Assign to" picker passes a department class which overrides below. */
  color: #fff;
  background: hsl(var(--owner-hue, 220), 55%, 48%);
  letter-spacing: 0.02em;
}
.assign-pop-avatar.executive   { background: var(--dept-executive);   color: var(--dept-executive-fg); }
.assign-pop-avatar.operations  { background: var(--dept-operations);  color: var(--dept-operations-fg); }
.assign-pop-avatar.finance     { background: var(--dept-finance);     color: var(--dept-finance-fg); }
.assign-pop-avatar.legal       { background: var(--dept-legal);       color: var(--dept-legal-fg); }
.assign-pop-avatar.creative    { background: var(--dept-creative);    color: var(--dept-creative-fg); }
.assign-pop-avatar.growth      { background: var(--dept-growth);      color: var(--dept-growth-fg); }
.assign-pop-avatar.engineering { background: var(--dept-engineering); color: var(--dept-engineering-fg); }
.assign-pop-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}
.assign-pop-name {
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.assign-pop-role {
  font-size: 11px;
  color: var(--text-faint, #b3afa5);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.assign-pop-check {
  color: #16a34a;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* ---------- View-mode toggle (All clients / Per client) ---------- */
.kbn-mode-bar {
  display: flex;
  align-items: center;
  padding: 4px 2px 10px;
}
.kbn-mode-toggle {
  display: inline-flex;
  background: var(--surface-2, #f7f6f3);
  border: 1px solid var(--border, rgba(0,0,0,0.08));
  border-radius: 8px;
  padding: 3px;
  gap: 2px;
}
.kbn-mode-btn {
  background: transparent;
  border: none;
  color: var(--text-muted, #6b6b6b);
  font-size: 12px;
  font-weight: 600;
  padding: 5px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.12s, color 0.12s;
}
.kbn-mode-btn:hover { color: var(--text, #1a1a1a); }
.kbn-mode-btn.is-active {
  background: var(--surface, #fff);
  color: var(--text, #1a1a1a);
  box-shadow: 0 1px 0 rgba(0,0,0,0.04);
}

/* ---------- Per-client: large client picker ---------- */
.pc-picker {
  display: inline-flex;
  flex-direction: column;
  gap: 3px;
  flex: 1 1 240px;
  min-width: 240px;
  max-width: 360px;
}
.pc-picker-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  color: var(--text-faint, #b3afa5);
}
.pc-picker-select {
  appearance: none;
  -webkit-appearance: none;
  background: var(--surface, #fff);
  border: 1px solid var(--border, rgba(0,0,0,0.12));
  border-radius: 8px;
  padding: 8px 28px 8px 12px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text, #1a1a1a);
  font-family: inherit;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%231a1a1a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='m6 9 6 6 6-6'/></svg>");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 12px;
  cursor: pointer;
  width: 100%;
}
.pc-picker-select:focus {
  outline: none;
  border-color: var(--text, #1a1a1a);
}

/* ---------- Phase Stepper (underline-tab style with twin stripes) ----------
   Layout per tab (top → bottom):
     1) head row: NN + name + N/M count
     2) progress stripe: per-stage progress bar (fill = % done)
     3) active stripe: visible only on the picked stage (bold underline)
   The two stripes sit flush against each other to read as a single 2-line
   indicator under each stage, matching the reference design. */
.phase-stepper-wrap {
  padding: 4px 2px 10px;
  margin-bottom: 6px;
  border-bottom: 1px solid var(--border, rgba(0,0,0,0.06));
  display: none;
}
.phase-stepper-wrap.is-visible { display: block; }
.phase-stepper {
  display: grid;
  grid-template-columns: repeat(9, minmax(0, 1fr));
  gap: 4px;
  align-items: stretch;
}

/* The tab: button reset + stacked rows.
   No border, no fill - the indicator is the underline stripe. */
.phase-tab {
  appearance: none;
  background: transparent;
  border: 0;
  padding: 6px 6px 0;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  border-radius: 6px;
  transition: background 0.12s;
}
.phase-tab:focus-visible {
  outline: 2px solid var(--text, #1a1a1a);
  outline-offset: 2px;
}
.phase-tab:not(.is-active):hover {
  background: var(--surface-2, #f7f6f3);
}

/* Head: NN  Name ...........  N/M  */
.phase-tab-head {
  display: flex;
  align-items: baseline;
  gap: 6px;
  min-width: 0;
  line-height: 1.2;
}
.phase-tab-num {
  flex: 0 0 auto;
  font-size: 10px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
  color: var(--text-faint, #b3afa5);
}
.phase-tab-name {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-muted, #6b6b6b);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color 0.12s;
}
.phase-tab-count {
  flex: 0 0 auto;
  font-size: 10px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text-faint, #b3afa5);
  white-space: nowrap;
}

/* Stripe 1 - per-stage progress line. The track sits flush under the head;
   the fill width is set inline (style="width: N%"). The fill color carries
   the state (in-progress = amber, complete = green, etc.). */
.phase-tab-progress {
  position: relative;
  height: 3px;
  width: 100%;
  background: rgba(0,0,0,0.18);
  border-radius: 2px;
  overflow: hidden;
}
.phase-tab-progress-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0%;
  background: #1a1a1a;
  border-radius: 2px;
  transition: width 0.3s ease, background 0.12s;
}

/* Stripe 2 - active indicator. Always present in the layout so tabs line up,
   but only colored on the picked stage. Sits directly under the progress
   stripe; together they read as the two-line indicator the design calls for. */
.phase-tab-active {
  display: block;
  height: 2px;
  width: 100%;
  background: transparent;
  border-radius: 0 0 2px 2px;
  margin-top: 1px;
  transition: background 0.12s;
}

/* State colors on the progress fill + count text.
   Gray = not started, Snapchat yellow = in progress, Purple = review/blocked,
   Green = complete. */
.phase-tab-not-started .phase-tab-progress-fill { background: transparent; }
.phase-tab-not-started .phase-tab-count         { color: var(--text-faint, #b3afa5); }
.phase-tab-in-progress .phase-tab-progress-fill { background: #FFFC00; }
.phase-tab-in-progress .phase-tab-count         { color: #a16207; }
.phase-tab-review      .phase-tab-progress-fill { background: #7c3aed; }
.phase-tab-review      .phase-tab-count         { color: #6d28d9; }
.phase-tab-blocked     .phase-tab-progress-fill { background: #7c3aed; }
.phase-tab-blocked     .phase-tab-count         { color: #6d28d9; }
.phase-tab-complete    .phase-tab-progress-fill { background: #16a34a; }
.phase-tab-complete    .phase-tab-count         { color: #16a34a; }

/* Active tab: name + NN turn dark, and the selection underline lights up.
   The bottom stripe is purely a "selected" indicator - it is ALWAYS solid
   black on the active tab, regardless of phase state, and is invisible
   on every other tab. State color belongs to the top progress stripe only. */
.phase-tab.is-active .phase-tab-name { color: var(--text, #1a1a1a); }
.phase-tab.is-active .phase-tab-num  { color: var(--text, #1a1a1a); }
.phase-tab.is-active .phase-tab-active { background: #1a1a1a; }

.kbn-summary-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11.5px;
  color: var(--text-muted, #6b6b6b);
  background: var(--surface-2, #f7f6f3);
  border: 1px solid var(--border, rgba(0,0,0,0.07));
  border-radius: 999px;
  padding: 4px 10px;
  margin-left: 6px;
}
.kbn-summary-chip strong {
  font-weight: 700;
  color: var(--text, #1a1a1a);
}
.kbn-summary-chip.is-green { background: rgba(22, 163, 74, 0.08); border-color: rgba(22, 163, 74, 0.2); color: #15803d; }
.kbn-summary-chip.is-green strong { color: #15803d; }
.kbn-summary-chip.is-amber { background: rgba(217, 119, 6, 0.1);  border-color: rgba(217, 119, 6, 0.25); color: #b45309; }
.kbn-summary-chip.is-amber strong { color: #b45309; }

.kbn-page-empty {
  text-align: center;
  padding: 56px 24px;
  color: var(--text-muted, #6b6b6b);
  border: 1px dashed var(--border, rgba(0,0,0,0.12));
  border-radius: 12px;
}
.kbn-page-empty-icon {
  display: inline-flex;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--surface-2, #f7f6f3);
  align-items: center;
  justify-content: center;
  color: var(--text-faint, #b3afa5);
  margin-bottom: 10px;
}
.kbn-page-empty-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text, #1a1a1a);
  margin-bottom: 4px;
}
.kbn-page-empty-body {
  font-size: 12.5px;
  max-width: 380px;
  margin: 0 auto;
  line-height: 1.45;
}

/* ============================================================
   LEAD-RAIL TRACE FLOW (the "leads info button" surface)
   ============================================================
   One-step-after-another vertical activity trace. Same visual
   grammar as .contract-mini-log: tinted circular icon left,
   title + right-aligned timestamp on the head row, muted meta
   line under it, optional detail, and indented substeps.
   ============================================================ */

.lead-trace-flow .lead-trace-card {
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  border-radius: 18px;
  padding: 8px 24px;
}
.lead-trace-list {
  display: flex;
  flex-direction: column;
}
.lead-trace-row {
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  border: none;
  text-align: left;
  font: inherit;
  color: inherit;
  cursor: pointer;
  display: grid;
  grid-template-columns: 26px 1fr;
  gap: 12px;
  /* Negative side margin + matching extra padding extends the hover
     rectangle outward without shifting the icon or title. */
  margin: 0 -12px;
  padding: 14px 22px 14px 18px;
  border-radius: 10px;
  transition: background 0.12s;
}
.lead-trace-row:hover {
  background: rgba(0, 0, 0, 0.04);
}
.lead-trace-row:focus-visible {
  outline: 2px solid var(--accent-blue, #3b6eff);
  outline-offset: -2px;
}
/* PLANNED (un-wired) trace rows: grayed + inert, no hover affordance. Mirrors
   the .rb-item.is-planned treatment in the per-client rail. */
.lead-trace-row.is-planned {
  opacity: 0.5;
  filter: grayscale(1);
  cursor: default;
}
.lead-trace-row.is-planned:hover {
  background: transparent;
}
.lead-trace-list > .lead-trace-row + .lead-trace-row {
  border-top: 1px solid var(--hairline);
}

.lead-trace-icon {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  margin-top: 1px;
  flex-shrink: 0;
}
.lead-trace-icon svg {
  width: 12px;
  height: 12px;
}
/* Pending-state tints by step type. Done state always uses the green
   completed tint via .audit-icon.event-completed (already defined). */
.lead-trace-icon.type-system  { background: var(--status-draft-bg);  color: var(--status-draft-fg); }
.lead-trace-icon.type-email   { background: var(--status-sent-bg);   color: var(--status-sent-fg); }
.lead-trace-icon.type-sms     { background: var(--status-sent-bg);   color: var(--status-sent-fg); }
.lead-trace-icon.type-call    { background: var(--status-viewed-bg); color: var(--status-viewed-fg); }
.lead-trace-icon.type-manual  { background: var(--status-draft-bg);  color: var(--status-draft-fg); }

.lead-trace-body {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.lead-trace-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
}
.lead-trace-title {
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.35;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.lead-trace-row.is-done .lead-trace-title {
  /* Keep titles readable when done - no strike-through, just a slightly
     muted tone. */
  color: var(--text);
}
.lead-trace-stamp {
  color: var(--text-muted);
  font-size: 11px;
  text-align: right;
  line-height: 1.35;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  flex-shrink: 0;
  margin-left: auto;
  padding-left: 12px;
}
.lead-trace-sub .lead-trace-stamp {
  font-size: 9.5px;
  letter-spacing: 0.01em;
  /* Visual nudge: pushes the substep stamp closer to the card's top-right
     edge without expanding the substep row's outer box (which would make
     the hover/done wrapper touch the parent card frame). */
  transform: translateX(10px);
}
.lead-trace-meta {
  color: var(--text-muted);
  font-size: 11.5px;
  line-height: 1.45;
}
.lead-trace-meta span {
  color: var(--accent-blue);
}
.lead-trace-detail {
  color: var(--text-muted);
  font-size: 11.5px;
  line-height: 1.45;
  margin-top: 2px;
}

/* Trigger row sits at the top of the trace - same tint as system events,
   slightly bolder framing so it reads as "this is where the journey began". */
.lead-trace-row.is-trigger .lead-trace-title {
  letter-spacing: 0.005em;
}

/* Indented substeps: smaller icon, indented column, no separator line above
   the first substep so it groups tightly under the parent. */
.lead-trace-substeps {
  margin: 10px 0 0 0;
  padding: 8px 0 2px 0;
  border-top: 1px dashed var(--hairline);
  display: flex;
  flex-direction: column;
}
.lead-trace-substeps > .lead-trace-row + .lead-trace-row {
  border-top: 1px solid var(--hairline);
}
.lead-trace-sub {
  grid-template-columns: 20px 1fr;
  gap: 10px;
  /* Symmetric -12 negative margin (matches parent rows) keeps the substep
     wrapper inset from the card's right edge so the hover / done background
     never touches the parent card frame. The stamp uses a small translateX
     to nudge visually right without expanding the row's outer box. */
  margin: 0 -12px;
  padding: 10px 22px 10px 18px;
  /* Anchor for the bottom-right doc preview button (e.g. signed NDA). */
  position: relative;
}

/* Receipt affordance: a tiny green receipt glyph in the bottom-right corner of
   a verification substep (NDA signed / MSA signed / client paid invoice),
   rendered the instant the system logs that step done. It sits just below the
   timestamp as a calm visual proof and is kept deliberately small because the
   substep row's spacing is very tight. Always a <button> (uniform hover /
   tooltip / focus); on hover the glyph itself lights from its "logged" green to
   an actionable blue - no background container, no size change. Where a
   viewable document backs it (the signed NDA / MSA for a real client) clicking
   opens the executed copy via open-contract; otherwise it is an inert button. */
.lead-trace-receipt {
  position: absolute;
  bottom: 7px;
  right: 13px;
  width: 16px;
  height: 16px;
  display: grid;
  place-items: center;
  border: 0;
  padding: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--status-completed-fg, #0d5e35);
  opacity: 0.9;
  cursor: pointer;
  transition: color 120ms ease, opacity 120ms ease, transform 80ms ease;
}
.lead-trace-receipt:hover {
  background: transparent;
  color: var(--accent-blue, #3b6eff);
  opacity: 1;
}
.lead-trace-receipt:active {
  transform: scale(0.92);
}
.lead-trace-receipt:focus-visible {
  outline: 2px solid var(--accent-blue, #3b6eff);
  outline-offset: 2px;
}
/* Custom tooltip for the receipt glyphs - dark bubble, fast, viewport-clamped.
   Positioned via fixed coords set by setupReceiptTip() in app.js. */
.receipt-tip {
  position: fixed;
  z-index: 1000;
  pointer-events: none;
  max-width: 240px;
  padding: 6px 9px;
  border-radius: 7px;
  background: var(--text);
  color: var(--surface);
  font-size: 11.5px;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  box-shadow: 0 8px 22px -8px rgba(20,18,14,0.45);
  opacity: 0;
  transform: translateY(-3px);
  transition: opacity 110ms ease, transform 110ms ease;
}
.receipt-tip.is-visible {
  opacity: 1;
  transform: translateY(0);
}
.lead-trace-sub .lead-trace-icon {
  width: 18px;
  height: 18px;
}
.lead-trace-sub .lead-trace-icon svg {
  width: 10px;
  height: 10px;
}
.lead-trace-sub .lead-trace-title {
  font-size: 12px;
  font-weight: 500;
}
.lead-trace-sub.is-done .lead-trace-title {
  color: var(--text-muted);
}

/* ============================================================
   LEAD-RAIL AVATAR TAB - simplified stack
   ============================================================
   1) Picker
   2) Brief avatar card
   3) Tiny "Open full avatar" link
   4) AI sales-call summary
   ============================================================ */
.lead-avatar-brief-wrap {
  margin-top: 10px;
}
.lead-avatar-openlink {
  margin-top: 10px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: 1px solid var(--hairline);
  border-radius: 999px;
  padding: 5px 11px 5px 12px;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.12s, border-color 0.12s, background 0.12s;
  font-family: inherit;
}
.lead-avatar-openlink:hover {
  color: var(--text);
  border-color: var(--text);
  background: rgba(0, 0, 0, 0.025);
}
.lead-avatar-openlink svg {
  opacity: 0.85;
}

/* ============================================================
   EXPENSES VIEW (per-program cost tracks)
   Standalone sidebar view. Mirrors the Pathway visual language:
   one colored phase bracket per program + a horizontal row of
   team-cost pills, ending with a Net-margin totals card.
   ============================================================ */
.body.expenses-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 20px 28px 28px;
  width: 100%;
  overflow-y: auto;
  gap: 18px;
}
.expenses-head {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.expenses-title {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0;
}
.expenses-sub {
  color: var(--text-soft);
  font-size: 13px;
  line-height: 1.55;
  max-width: 760px;
  margin: 0;
}
.expenses-sub-tag {
  display: inline-block;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: var(--surface-2);
  padding: 2px 8px;
  border-radius: 4px;
  margin-left: 6px;
  vertical-align: 2px;
}

.expenses-tracks {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background:
    radial-gradient(circle, rgba(20,18,14,0.05) 1px, transparent 1.2px) 0 0 / 22px 22px,
    var(--surface);
  padding: 28px 24px;
  overflow-x: auto;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.exp-track {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: max-content;
}

/* Reuse the .pw-phase-bracket markup/styles for the program header.
   Override align-self so the bracket hugs its own content rather than
   stretching across the (often very wide) cost row. */
.exp-track > .pw-phase-bracket {
  align-self: flex-start;
  min-width: 280px;
}

.exp-track-body {
  display: flex;
  align-items: stretch;
  gap: 0;
  padding-top: 6px;
}

.exp-nodes {
  display: flex;
  align-items: stretch;
  gap: 0;
}

.exp-node {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 13px;
  margin: 0 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  min-width: 178px;
  white-space: nowrap;
  cursor: default;
  transition: border-color 100ms ease, box-shadow 100ms ease;
}
.exp-node:hover {
  border-color: var(--text-muted);
  box-shadow: 0 2px 8px -4px rgba(0,0,0,0.12);
}
.exp-node-num {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-muted);
  letter-spacing: 0.02em;
  flex-shrink: 0;
}
.exp-node-body {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}
.exp-node-role {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.005em;
  line-height: 1.25;
}
.exp-node-who {
  font-size: 10.5px;
  color: var(--text-muted);
  line-height: 1.3;
}
.exp-node-amt {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  padding-left: 12px;
  white-space: nowrap;
}

/* Thin dashed connector between consecutive nodes, mirroring the
   pathway feel without the heavier SVG bezier curves. */
.exp-node:not(:last-child)::after {
  content: '';
  position: absolute;
  top: 50%;
  right: -16px;
  width: 16px;
  height: 1.5px;
  background: var(--border);
  transform: translateY(-50%);
  pointer-events: none;
}

/* Per-tone tint on the node border so each program's cost row
   reads as visually tied to its program bracket. */
.exp-node.tone-blue        { border-color: rgba(43,108,176,0.32); }
.exp-node.tone-amber       { border-color: rgba(200,150,64,0.38); }
.exp-node.tone-green       { border-color: rgba(26,107,60,0.32); }
.exp-node.tone-executive   { border-color: rgba(45,60,90,0.32); }
.exp-node.tone-legal       { border-color: rgba(75,85,140,0.32); }
.exp-node.tone-creative    { border-color: rgba(124,75,162,0.32); }
.exp-node.tone-engineering { border-color: rgba(14,94,87,0.32); }

/* Totals card on the far right of every track. Three rows:
   Revenue (neutral) - Costs (red) - Net per sale (green emphasis). */
.exp-totals {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-self: center;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: 12px;
  min-width: 200px;
  margin-left: 24px;
  flex-shrink: 0;
}
.exp-totals-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  font-size: 11.5px;
  color: var(--text-soft);
}
.exp-totals-row .exp-totals-val {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--text);
}
.exp-totals-row.is-cost .exp-totals-val { color: #b8451f; }
.exp-totals-row.is-net {
  margin-top: 4px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text);
}
.exp-totals-row.is-net .exp-totals-val {
  color: #1a6b3c;
  font-size: 13px;
}

/* =============================================================
   TASK DETAIL MODAL
   Full collaboration surface. Two-column on desktop, single-column
   full-viewport on mobile. The whole modal handles its own overflow
   so the body scrolls inside the chrome.
   ============================================================= */
.modal-task-detail {
  /* Override the default .modal width/height for a roomier surface. */
  width: min(1120px, 96vw);
  height: min(840px, 90vh);
  max-height: 90vh;
  padding: 0;
  display: flex;
  flex-direction: column;
}
.td-head {
  display: grid;
  grid-template-columns: 36px 1fr 36px;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 2;
}
.td-head .icon-btn {
  width: 32px; height: 32px;
  border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--text-muted);
  background: transparent;
  border: 1px solid transparent;
}
.td-head .icon-btn:hover { background: var(--surface-2); color: var(--text); }
.td-head .td-delete:hover { color: #b91c1c; background: rgba(248,113,113,0.10); }
.td-head-meta { min-width: 0; }
.td-head-eyebrow {
  display: block;
  font-size: 10.5px; font-weight: 700;
  letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--text-faint);
}
.td-head-title {
  margin: 2px 0 0;
  font-size: 15.5px; font-weight: 600;
  color: var(--text);
  letter-spacing: -0.005em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* The grid that contains main content + sidebar. min-height: 0 lets the
   inner scrollers actually scroll instead of overflowing the modal. */
.td-body {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  overflow: hidden;
}
.td-main {
  min-height: 0;
  overflow-y: auto;
  padding: 18px 22px 14px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  scrollbar-width: thin;
}
.td-side {
  min-height: 0;
  overflow-y: auto;
  padding: 18px 18px 22px;
  background: var(--surface-2);
  border-left: 1px solid var(--border);
}

/* Mobile chip strip - hidden on desktop because the sidebar shows the same. */
.td-mchips { display: none; }

.td-section {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  padding: 14px 14px 12px;
  position: relative;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
.td-section.is-drop-over {
  border-color: rgba(59,130,246,0.55);
  box-shadow: 0 0 0 3px rgba(59,130,246,0.12);
}
.td-section-head {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 8px;
}
.td-section-head h3 {
  margin: 0;
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-faint);
  flex: 1 1 auto;
}
.td-count {
  font-size: 11px; font-weight: 700;
  color: var(--text-muted);
  background: var(--surface-2);
  border-radius: 999px;
  padding: 1px 8px;
}
.td-link {
  background: transparent; border: 0; padding: 4px 6px;
  font: inherit; font-size: 12px; font-weight: 600;
  color: var(--text-muted);
  cursor: pointer; border-radius: 6px;
}
.td-link:hover { color: var(--text); background: var(--surface-2); }

/* Description -------------------------------------------------- */
.td-desc-body {
  font-size: 13.5px; line-height: 1.55;
  color: var(--text);
  white-space: pre-wrap;
}
.td-desc-body.is-empty { color: var(--text-faint); font-style: italic; }
.td-desc-edit { display: flex; flex-direction: column; gap: 10px; }
.td-desc-edit[hidden] { display: none; }
.td-desc-input {
  font: inherit; font-size: 13.5px; line-height: 1.55;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  resize: vertical;
  outline: none;
  width: 100%;
  box-sizing: border-box;
}
.td-desc-input:focus { border-color: rgba(59,130,246,0.6); background: var(--surface); }
.td-desc-actions { display: flex; justify-content: flex-end; gap: 8px; }

/* Attachments -------------------------------------------------- */
.td-att-meter {
  flex: 0 0 80px;
  height: 4px; border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}
.td-att-meter-fill {
  display: block; height: 100%;
  background: linear-gradient(90deg, #60a5fa, #818cf8);
  transition: width 200ms ease;
}
.td-att-attach { cursor: pointer; }
.td-att-empty {
  display: flex; align-items: center; gap: 10px;
  font-size: 12.5px;
  color: var(--text-faint);
  padding: 18px;
  border: 1px dashed var(--border);
  border-radius: 10px;
  background: var(--surface-2);
}
.td-att-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 10px;
}
.td-att-tile {
  position: relative;
  display: flex; flex-direction: column;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  overflow: hidden;
  transition: border-color 120ms ease;
}
.td-att-tile:hover { border-color: var(--text-muted); }
.td-att-preview {
  display: block;
  aspect-ratio: 4 / 3;
  background: #0b0b0b;
  overflow: hidden;
  text-decoration: none;
}
.td-att-preview img {
  width: 100%; height: 100%; object-fit: cover; display: block;
}
.td-att-preview-file {
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted);
}
.td-att-meta {
  padding: 8px 10px 10px;
  display: flex; flex-direction: column; gap: 2px;
  min-width: 0;
}
.td-att-name {
  font-size: 12.5px; font-weight: 600;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.td-att-name:hover { color: #60a5fa; }
.td-att-sub {
  font-size: 11px; color: var(--text-faint);
}
.td-att-remove {
  position: absolute; top: 6px; right: 6px;
  width: 22px; height: 22px;
  border-radius: 6px;
  background: rgba(15,15,15,0.7);
  color: #fff;
  border: 0;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  opacity: 0;
  transition: opacity 120ms ease;
}
.td-att-tile:hover .td-att-remove,
.td-att-tile:focus-within .td-att-remove { opacity: 1; }
.td-att-foot {
  margin-top: 10px;
  font-size: 11px;
  color: var(--text-faint);
}

/* Activity thread + composer ---------------------------------- */
.td-section-activity { display: flex; flex-direction: column; min-height: 0; }
.td-activity-thread {
  display: flex; flex-direction: column; gap: 12px;
  max-height: 380px;
  overflow-y: auto;
  padding: 6px 2px 10px;
  scrollbar-width: thin;
}
.td-activity-empty {
  padding: 20px;
  text-align: center;
  font-size: 12.5px;
  color: var(--text-faint);
}
.td-act {
  display: grid;
  grid-template-columns: 28px 1fr 28px;
  gap: 10px;
  align-items: start;
}
.td-act-comment .td-act-body { min-width: 0; }
.td-act-head {
  display: flex; gap: 8px; align-items: baseline;
  font-size: 12.5px;
}
.td-act-head strong { font-weight: 600; color: var(--text); }
.td-act-time { color: var(--text-faint); font-size: 11px; }
.td-act-text {
  margin-top: 3px;
  font-size: 13px; line-height: 1.5;
  color: var(--text);
  white-space: pre-wrap;
  word-wrap: break-word;
}
.td-act-del {
  width: 22px; height: 22px;
  border-radius: 6px;
  color: var(--text-faint);
  background: transparent;
  border: 0;
  opacity: 0;
  cursor: pointer;
}
.td-act-comment:hover .td-act-del,
.td-act-comment:focus-within .td-act-del { opacity: 1; }
.td-act-del:hover { color: #b91c1c; background: rgba(248,113,113,0.12); }

.td-act-system { grid-template-columns: 12px 1fr; }
.td-act-system-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--text-faint);
  margin-top: 8px;
  margin-left: 3px;
}
.td-act-system-text {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
}
.td-act-system-text strong { color: var(--text); font-weight: 600; }
.td-act-system-text em { font-style: normal; color: var(--text); font-weight: 600; }

.owner-chip-system {
  background: var(--surface-2);
  color: var(--text-faint);
  font-weight: 700;
}

.td-composer-wrap {
  position: relative;
  margin-top: 10px;
  display: flex;
  align-items: flex-end;
  gap: 8px;
}
.td-composer {
  flex: 1 1 auto;
  font: inherit; font-size: 13.5px; line-height: 1.5;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  resize: none;
  outline: none;
  min-height: 42px; max-height: 140px;
}
.td-composer:focus { border-color: rgba(59,130,246,0.55); background: var(--surface); }
.td-send {
  width: 38px; height: 38px;
  border-radius: 50%;
  border: 0;
  background: var(--text);
  color: var(--surface);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  flex: 0 0 auto;
  transition: background 120ms ease, transform 80ms ease;
}
.td-send:hover  { background: #2a2a2a; }
.td-send:active { transform: scale(0.96); }

/* Sidebar ------------------------------------------------------ */
.td-side-card {
  display: flex; flex-direction: column; gap: 18px;
}
.td-side-section {
  display: flex; flex-direction: column; gap: 10px;
}
.td-side-section-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.td-side-row {
  display: grid;
  grid-template-columns: 90px 1fr;
  align-items: center;
  gap: 10px;
}
.td-side-label {
  font-size: 10.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-faint);
}
.td-side-static {
  font-size: 12.5px; color: var(--text);
}
.td-side-input,
.td-side-select {
  font: inherit; font-size: 12.5px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 8px;
  outline: none;
  width: 100%; min-width: 0; box-sizing: border-box;
}
.td-side-input:focus,
.td-side-select:focus { border-color: rgba(59,130,246,0.55); }
.td-side-owner {
  display: grid;
  grid-template-columns: 26px 1fr 22px;
  gap: 8px; align-items: center;
  padding: 4px 0;
}
.td-side-owner-text { min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.td-side-owner-name { font-size: 12.5px; font-weight: 600; color: var(--text); }
.td-side-owner-role { font-size: 11px; color: var(--text-faint); }
.td-side-unassign {
  width: 22px; height: 22px; border-radius: 6px;
  color: var(--text-faint);
  background: transparent;
  border: 0; cursor: pointer;
  opacity: 0; transition: opacity 120ms ease;
}
.td-side-owner:hover .td-side-unassign,
.td-side-owner:focus-within .td-side-unassign { opacity: 1; }
.td-side-unassign:hover { color: #b91c1c; background: rgba(248,113,113,0.12); }
.td-side-empty {
  font-size: 12px; color: var(--text-faint); font-style: italic;
}
.td-side-meta { border-top: 1px solid var(--border); padding-top: 14px; }

/* Status pills (shared with mobile chip + sidebar select) ----- */
.td-status-pill {
  background-image: linear-gradient(currentColor, currentColor);
  background-size: 6px 6px;
  background-repeat: no-repeat;
  background-position: 10px center;
  padding-left: 24px;
}
.td-status-todo       { color: #f59e0b; }
.td-status-inprogress { color: #3b82f6; }
.td-status-done       { color: #16a34a; }

/* Mobile chip strip styling (kept ready for the breakpoint to enable). */
.td-mchip {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 600;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 10px;
  white-space: nowrap;
}
.td-mchip-status { cursor: pointer; }
.td-status-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: currentColor;
  display: inline-block;
}
.td-mchip-due svg { color: var(--text-faint); }
.td-mchip-due.is-overdue { color: #b91c1c; }
.td-mchip-owners { padding: 3px 6px; }
.td-mchip-owners .owner-chip { width: 22px; height: 22px; font-size: 10px; }
.td-mchip-empty { font-size: 11.5px; color: var(--text-faint); padding: 0 4px; }

/* =============================================================
   RESPONSIVE: mobile and tablet behavior
   ============================================================= */
@media (max-width: 899px) {
  .modal-task-detail {
    /* Full-viewport on small screens, accounting for the iOS dynamic toolbar. */
    width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
    top: 0; left: 0;
    transform: none;
    inset: 0;
  }
  .td-head {
    padding: 12px 14px;
    padding-top: max(12px, env(safe-area-inset-top));
    grid-template-columns: 40px 1fr 40px;
  }
  .td-head .icon-btn { width: 40px; height: 40px; }
  .td-head-title { font-size: 14.5px; }
  .td-body {
    grid-template-columns: minmax(0, 1fr);
    overflow-y: auto;
  }
  .td-main {
    padding: 14px 14px 14px;
    overflow-y: visible;
    gap: 14px;
  }
  .td-side {
    border-left: 0;
    border-bottom: 1px solid var(--border);
    padding: 12px 14px 16px;
    background: var(--surface);
  }
  /* On mobile the sidebar lives ABOVE the content but the assignees + project
     are mostly informational, so we collapse it visually and let the mobile
     chip strip handle the high-frequency edits. The chip strip lives at the
     top of the main column. */
  .td-side { order: 2; }
  .td-main { order: 1; }
  .td-mchips {
    display: flex;
    flex-wrap: nowrap;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 2px;
    -ms-overflow-style: none; scrollbar-width: none;
  }
  .td-mchips::-webkit-scrollbar { display: none; }
  .td-section { padding: 12px 12px 10px; border-radius: 10px; }
  .td-activity-thread { max-height: none; }
  /* Composer becomes sticky at the bottom of the modal so it stays in reach
     no matter how long the thread is. */
  .td-composer-wrap {
    position: sticky;
    bottom: 0;
    background: var(--surface);
    padding: 8px 0 max(8px, env(safe-area-inset-bottom));
    margin-bottom: -2px;
    z-index: 1;
  }
  .td-composer { font-size: 14px; min-height: 44px; }
  .td-send { width: 44px; height: 44px; }
  .td-att-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .td-side-row { grid-template-columns: 80px 1fr; }
  /* Touch-friendly: always show remove + unassign buttons on mobile (no hover). */
  .td-att-remove,
  .td-side-unassign,
  .td-act-del { opacity: 1; }
}

@media (max-width: 480px) {
  .td-att-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
  .td-side-row { grid-template-columns: 70px 1fr; }
}

/* ============================================================
   PM Work Order Detail
   Replicated from PM.tsx. Lives inside .modal-task-detail when
   rendered by renderDeliveryCardDetail(). Uses the app's light
   tokens (--surface / --border / --text) so it matches the rest
   of the dashboard.
   ============================================================ */

/* Hide the existing td-head meta - the PM layout has its own
   title at the top of the body, so we don't want to double-print. */
#dcDetailModal .td-head { background: var(--surface); border-bottom-color: var(--border); }
#dcDetailModal .td-head-spacer { display: none; }
/* Title on the left, close on the right, in the same sticky header row. */
#dcDetailModal .td-head { grid-template-columns: 1fr auto; padding: 16px 20px; }
#dcDetailModal .td-head-meta { grid-column: 1 / 2; justify-self: start; min-width: 0; }
#dcDetailModal .td-head-eyebrow { display: none; }
#dcDetailModal .td-head-title {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#dcDetailModal .td-close { grid-column: 2 / 3; justify-self: end; }
#dcDetailModal .td-head .icon-btn { color: var(--text-muted); }
#dcDetailModal .td-head .icon-btn:hover { background: var(--surface-2); color: var(--text); }
/* Body fills the modal but does NOT scroll - each column manages its own
   scroll so we never get the long ugly outer scrollbar. On narrow viewports
   we fall back to body scrolling since the columns stack. */
#dcDetailModal .td-body {
  display: flex;
  flex-direction: column;
  padding: 0;
  background: var(--bg);
  overflow: hidden;
}

.pm-page {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  padding: 24px 28px 0;
  font-family: var(--font-sans, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif);
}

.pm-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.pm-title {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
  line-height: 1.3;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pm-title-more {
  width: 32px; height: 32px;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent; border: 0; border-radius: 999px;
  color: var(--text-muted); cursor: pointer;
  transition: background 120ms, color 120ms;
}
.pm-title-more:hover { background: var(--surface-2); color: var(--text); }

.pm-grid {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
  gap: 16px;
  padding-bottom: 24px;
}
@media (max-width: 960px) {
  .pm-grid { grid-template-columns: 1fr; }
  /* Stacked: let the modal body scroll, columns just flow naturally. */
  #dcDetailModal .td-body { overflow-y: auto; }
  .pm-page { flex: 0 0 auto; min-height: 0; }
  .pm-main, .pm-side { overflow: visible; max-height: none; }
}

.pm-main, .pm-side {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
  /* Hide the scrollbar visually (Firefox + WebKit). */
  scrollbar-width: none;
}
.pm-main::-webkit-scrollbar,
.pm-side::-webkit-scrollbar { display: none; }

/* Shared surfaces */
.pm-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
}
.pm-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

/* ---- Properties row ---- */
.pm-props-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}
.pm-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 11px;
  color: var(--text-muted);
}
.pm-props-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
@media (max-width: 720px) {
  .pm-props-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 480px) {
  .pm-props-grid { grid-template-columns: 1fr; }
}
.pm-field { min-width: 0; }
.pm-field-label {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 6px;
}
.pm-dot {
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 999px;
  flex-shrink: 0;
}

/* ---- Custom dropdown ---- */
.pm-dd { position: relative; }
.pm-dd-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  transition: background 120ms, border-color 120ms;
}
.pm-dd-btn:hover { background: var(--surface-3); border-color: var(--border-strong); }
.pm-dd-val { display: inline-flex; align-items: center; gap: 8px; min-width: 0; }
.pm-dd-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pm-dd-caret { color: var(--text-muted); flex-shrink: 0; }
.pm-dd-menu {
  position: absolute;
  z-index: 30;
  left: 0; right: 0; top: calc(100% + 4px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 12px 32px -10px rgba(20,18,14,0.18);
}
.pm-dd-menu[hidden] { display: none; }
.pm-dd-opt {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  background: transparent;
  border: 0;
  text-align: left;
  font-size: 13px;
  color: var(--text-soft);
  cursor: pointer;
  transition: background 100ms, color 100ms;
}
.pm-dd-opt:hover { background: var(--surface-2); color: var(--text); }
.pm-dd-opt.is-active { background: var(--surface-3); color: var(--text); }

/* ---- Date field ---- */
.pm-date {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  cursor: pointer;
  transition: background 120ms, border-color 120ms;
}
.pm-date:hover { background: var(--surface-3); border-color: var(--border-strong); }
.pm-date-text { font-size: 13px; color: var(--text); }
.pm-date-text.is-empty { color: var(--text-faint); }
.pm-date svg { color: var(--text-muted); flex-shrink: 0; }
.pm-date-input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  font-size: 16px; /* avoid iOS Safari zoom */
}

/* ---- Scope ---- */
.pm-card-scope { display: flex; flex-direction: column; gap: 10px; }
.pm-scope-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.pm-scope-path {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-soft);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.pm-scope-path-sep { color: var(--text-faint); font-weight: 400; }
.pm-scope-input {
  width: 100%;
  min-height: 140px;
  background: transparent;
  border: 0;
  resize: vertical;
  color: var(--text);
  font-size: 14px;
  line-height: 1.55;
  font-family: inherit;
}
.pm-scope-input:focus { outline: none; }
.pm-scope-input::placeholder { color: var(--text-faint); }

/* ---- Team ---- */
.pm-card-team { display: flex; flex-direction: column; gap: 14px; }
.pm-team-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.pm-team-tabs { display: flex; align-items: center; gap: 18px; }
.pm-team-tab {
  background: transparent; border: 0;
  padding: 0 0 6px;
  font-size: 14px; font-weight: 500;
  color: var(--text-muted); cursor: pointer;
  border-bottom: 1px solid transparent;
}
.pm-team-tab.is-active { color: var(--text); border-bottom-color: var(--text); }
.pm-team-add {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12px; font-weight: 500;
  color: var(--text); cursor: pointer;
  transition: background 120ms, border-color 120ms;
}
.pm-team-add:hover { background: var(--surface-3); border-color: var(--border-strong); }
.pm-team-empty { color: var(--text-faint); font-size: 13px; padding: 14px 0; text-align: center; }

/* Compact avatar grid: each member is a circular initials chip. The X badge
   sits on the top-right of the chip and only appears on hover. A custom
   pop-up tooltip shows full name + role on hover. */
.pm-team-chips {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding-top: 2px;
}
.pm-team-chip {
  position: relative;
  display: inline-flex;
}
.pm-team-avatar {
  width: 36px; height: 36px;
  border-radius: 999px;
  flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600; letter-spacing: 0.02em;
  background: hsl(var(--owner-hue, 220), 70%, 92%);
  color: hsl(var(--owner-hue, 220), 65%, 30%);
  border: 1px solid hsl(var(--owner-hue, 220), 70%, 80%);
  cursor: default;
  transition: transform 120ms;
}
.pm-team-chip:hover .pm-team-avatar { transform: scale(1.05); }
.pm-team-remove {
  position: absolute;
  top: -4px; right: -4px;
  width: 16px; height: 16px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  color: var(--text-soft); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 4px rgba(20,18,14,0.10);
  opacity: 0;
  transition: opacity 120ms, background 120ms, border-color 120ms, color 120ms;
}
.pm-team-chip:hover .pm-team-remove { opacity: 1; }
.pm-team-remove:hover { background: #fee2e2; border-color: #fca5a5; color: #b91c1c; }

/* Floating hover tooltip: name on top, role below. Uses pseudo-elements on
   the chip so no extra DOM. Arrow points down toward the avatar. */
.pm-team-chip::before,
.pm-team-chip::after {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  transform: translateX(-50%) translateY(4px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 120ms ease, transform 120ms ease;
  z-index: 60;
}
.pm-team-chip::before {
  content: attr(data-pm-name) "\A" attr(data-pm-role);
  white-space: pre;
  background: #18181b;
  color: #fff;
  padding: 7px 10px;
  border-radius: 8px;
  font-size: 11.5px;
  line-height: 1.35;
  font-weight: 500;
  box-shadow: 0 8px 20px -8px rgba(0,0,0,0.45);
  min-width: max-content;
  max-width: 220px;
  text-align: center;
}
.pm-team-chip::after {
  content: '';
  bottom: calc(100% + 2px);
  width: 0; height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 5px solid #18181b;
}
.pm-team-chip:hover::before,
.pm-team-chip:hover::after {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
/* When the chip has no role, the line break still renders. Skip the empty
   second line so the tooltip stays tight. */
.pm-team-chip[data-pm-role=""]::before {
  content: attr(data-pm-name);
}
@media (max-width: 600px) {
  /* Always show the remove badge on touch devices (no hover). */
  .pm-team-remove { opacity: 1; }
  .pm-team-chip::before, .pm-team-chip::after { display: none; }
}

/* ---- Files ---- */
.pm-card-files {
  display: flex; flex-direction: column; gap: 14px;
  transition: background 120ms, border-color 120ms;
}
.pm-card-files.is-drop-over {
  background: var(--surface-2);
  border-color: var(--accent-blue);
}
.pm-files-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.pm-files-tabs { display: flex; align-items: center; gap: 10px; }
.pm-files-count {
  font-size: 11px; color: var(--text-muted);
  background: var(--surface-2);
  border-radius: 999px;
  padding: 1px 8px;
  font-variant-numeric: tabular-nums;
}
.pm-files-head-right { display: flex; align-items: center; gap: 10px; }
.pm-files-meter {
  width: 80px; height: 4px;
  background: var(--surface-3);
  border-radius: 999px;
  overflow: hidden;
}
.pm-files-meter-fill {
  display: block; height: 100%;
  background: var(--accent-blue);
  border-radius: 999px;
  transition: width 200ms ease;
}
.pm-files-attach { cursor: pointer; }
.pm-files-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 10px;
}
.pm-file-empty {
  grid-column: 1 / -1;
  display: flex; align-items: center; justify-content: center;
  gap: 8px;
  padding: 22px 16px;
  background: var(--surface-2);
  border: 1px dashed var(--border-strong);
  border-radius: 12px;
  color: var(--text-muted);
  font-size: 13px;
  text-align: center;
}
.pm-file-empty strong { color: var(--text); font-weight: 600; }
.pm-file-tile {
  position: relative;
  display: flex; flex-direction: column;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  transition: border-color 120ms, transform 120ms;
}
.pm-file-tile:hover { border-color: var(--border-strong); }
.pm-file-preview {
  display: flex; align-items: center; justify-content: center;
  height: 96px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  overflow: hidden;
}
.pm-file-preview img { width: 100%; height: 100%; object-fit: cover; }
.pm-file-preview-doc { color: var(--text-muted); }
.pm-file-meta { display: flex; flex-direction: column; gap: 2px; padding: 8px 10px; min-width: 0; }
.pm-file-name {
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pm-file-name:hover { color: var(--accent-blue); }
.pm-file-sub { color: var(--text-muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.pm-file-remove {
  position: absolute;
  top: 6px; right: 6px;
  width: 22px; height: 22px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-soft); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 6px rgba(20,18,14,0.10);
  opacity: 0;
  transition: opacity 120ms, background 120ms, border-color 120ms, color 120ms;
}
.pm-file-tile:hover .pm-file-remove { opacity: 1; }
.pm-file-remove:hover { background: #fee2e2; border-color: #fca5a5; color: #b91c1c; }
.pm-files-foot {
  font-size: 11px;
  color: var(--text-faint);
}
@media (max-width: 600px) {
  .pm-file-remove { opacity: 1; }
}

/* ---- Client (right column) ---- */
/* Single-row layout: "CLIENT" label sits on the left, name pill on the right. */
.pm-card-client {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 18px;
}
.pm-card-client .pm-label { flex-shrink: 0; }
.pm-client-name {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 12px;
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---- Updates / composer ---- */
/* The Updates card grows to fill the right column so its inner activity feed
   has somewhere to expand into and scroll independently. */
.pm-card-updates {
  display: flex;
  flex-direction: column;
  gap: 16px;
  flex: 1 1 auto;
  min-height: 0;
}
.pm-composer { display: flex; flex-direction: column; gap: 12px; }
.pm-composer-input {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  color: var(--text);
  font-size: 16px; /* avoid iOS zoom */
  line-height: 1.45;
  resize: none;
  font-family: inherit;
}
.pm-composer-input:focus { outline: none; border-color: var(--border-strong); background: var(--surface); }
.pm-composer-input::placeholder { color: var(--text-faint); }
.pm-composer-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.pm-mic {
  width: 40px; height: 40px;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-muted); cursor: pointer;
  transition: background 120ms, color 120ms, border-color 120ms;
}
.pm-mic:hover { background: var(--surface-2); color: var(--text); border-color: var(--border-strong); }
.pm-send {
  width: 40px; height: 40px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--text);
  color: var(--surface);
  border: 0; border-radius: 999px;
  cursor: pointer;
  transition: background 120ms, opacity 120ms;
}
.pm-send:hover { background: var(--text-soft); }
.pm-send:disabled { opacity: 0.4; cursor: default; }

/* ---- Activity feed ---- */
.pm-activity-head {
  display: flex; align-items: center; justify-content: space-between;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.pm-label-row { display: flex; align-items: center; gap: 8px; }
.pm-activity-count { font-size: 11px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.pm-activity-toggle {
  width: 26px; height: 26px;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent; border: 0; border-radius: 999px;
  color: var(--text-muted); cursor: pointer;
  transition: background 120ms, color 120ms;
}
.pm-activity-toggle:hover { background: var(--surface-2); color: var(--text); }
.pm-activity-toggle svg { transition: transform 180ms ease; }
.pm-activity-toggle.is-collapsed svg { transform: rotate(-90deg); }
.pm-activity-feed {
  display: flex; flex-direction: column; gap: 16px;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  scrollbar-width: none;
  transition: opacity 180ms ease;
}
.pm-activity-feed::-webkit-scrollbar { display: none; }
.pm-activity-feed.is-collapsed {
  flex: 0 0 0;
  max-height: 0;
  min-height: 0;
  opacity: 0;
  pointer-events: none;
  overflow: hidden;
}

.pm-act {
  display: flex; align-items: flex-start; gap: 10px;
}
.pm-avatar {
  width: 28px; height: 28px;
  border-radius: 999px;
  flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 600;
  border: 1px solid transparent;
}
.pm-avatar-system {
  background: var(--surface-2);
  border-color: var(--border);
  color: var(--text-muted);
}
.pm-act-body { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 4px; }
.pm-act-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.pm-act-name { font-size: 14px; font-weight: 600; color: var(--text); }
.pm-act-text { margin: 0; font-size: 13px; line-height: 1.4; color: var(--text-soft); white-space: pre-line; }
.pm-act-time { font-size: 11px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.pm-act-edited { color: var(--text-faint); }

.pm-act-more-wrap { position: relative; }
.pm-act-more {
  width: 28px; height: 28px;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent; border: 0; border-radius: 999px;
  color: var(--text-muted); cursor: pointer;
  transition: background 120ms, color 120ms;
}
.pm-act-more:hover { background: var(--surface-2); color: var(--text); }
.pm-act-menu {
  position: absolute;
  right: 0; top: calc(100% + 4px);
  width: 140px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 12px 32px -10px rgba(20,18,14,0.18);
  z-index: 50;
}
.pm-act-menu-item {
  width: 100%;
  padding: 9px 12px;
  background: transparent; border: 0;
  text-align: left;
  font-size: 13px; color: var(--text-soft);
  cursor: pointer;
  transition: background 100ms;
}
.pm-act-menu-item:hover { background: var(--surface-2); }
.pm-act-menu-item-danger { color: #b91c1c; }
.pm-act-menu-item-danger:hover { background: #fef2f2; }

.pm-act-edit { display: flex; flex-direction: column; gap: 8px; }
.pm-act-edit-input {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 9px 12px;
  font-size: 16px; /* avoid iOS zoom */
  color: var(--text);
  font-family: inherit; resize: vertical;
  min-height: 56px;
}
.pm-act-edit-input:focus { outline: none; border-color: var(--border-strong); background: var(--surface); }
.pm-act-edit-actions { display: flex; align-items: center; gap: 8px; }
.pm-act-edit-save {
  padding: 6px 12px;
  background: var(--text); color: var(--surface);
  border: 0; border-radius: 8px;
  font-size: 12px; font-weight: 600;
  cursor: pointer;
}
.pm-act-edit-save:hover { background: var(--text-soft); }
.pm-act-edit-cancel {
  padding: 6px 12px;
  background: transparent; color: var(--text-muted);
  border: 0; border-radius: 8px;
  font-size: 12px; font-weight: 500;
  cursor: pointer;
}
.pm-act-edit-cancel:hover { background: var(--surface-2); color: var(--text); }

.pm-act-tombstone {
  margin: 4px 0 0;
  font-size: 13px; font-style: italic;
  color: var(--text-muted);
  line-height: 1.4;
}
.pm-act-tombstone-name { color: var(--text-soft); font-style: normal; }
.pm-act-tombstone-time { color: var(--text-faint); }

/* ---- Confirm-delete overlay (built dynamically) ---- */
.pm-confirm-overlay {
  position: fixed; inset: 0;
  z-index: 200;
  display: flex; align-items: center; justify-content: center;
  background: rgba(20,18,14,0.45);
  animation: fadeIn 120ms ease;
}
.pm-confirm-card {
  width: 320px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 20px 50px -10px rgba(20,18,14,0.20);
  display: flex; flex-direction: column; gap: 12px;
}
.pm-confirm-title { margin: 0; font-size: 14px; font-weight: 600; color: var(--text); }
.pm-confirm-sub { margin: 0; font-size: 13px; color: var(--text-muted); }
.pm-confirm-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding-top: 4px; }
.pm-confirm-cancel {
  padding: 6px 12px;
  background: transparent; color: var(--text-muted);
  border: 0; border-radius: 8px;
  font-size: 13px; cursor: pointer;
}
.pm-confirm-cancel:hover { background: var(--surface-2); color: var(--text); }
.pm-confirm-del {
  padding: 6px 12px;
  background: #fee2e2;
  border: 1px solid #fca5a5;
  color: #b91c1c;
  border-radius: 8px;
  font-size: 13px; font-weight: 600;
  cursor: pointer;
}
.pm-confirm-del:hover { background: #fecaca; }

/* "Send back for adjustments" modal - shown when a card is dragged Review -> To Do. */
.kbn-rework-overlay {
  position: fixed; inset: 0;
  z-index: 220;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background: rgba(20, 18, 14, 0.5);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  animation: fadeIn 120ms ease;
}
.kbn-rework-card {
  width: 440px; max-width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 24px 60px -12px rgba(20, 18, 14, 0.28);
  display: flex; flex-direction: column; gap: 14px;
  animation: cmdkPop 140ms ease;
}
.kbn-rework-head { display: flex; align-items: flex-start; gap: 12px; }
.kbn-rework-badge {
  flex: 0 0 auto;
  width: 34px; height: 34px; border-radius: 10px;
  display: grid; place-items: center;
  background: #fff7cc; color: #946c00;
  border: 1px solid rgba(240, 185, 0, 0.4);
}
.kbn-rework-head-text { min-width: 0; }
.kbn-rework-title { margin: 0; font-size: 15px; font-weight: 700; color: var(--text); }
.kbn-rework-sub { margin: 2px 0 0; font-size: 12.5px; color: var(--text-muted); }
.kbn-rework-from { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.kbn-rework-from-label {
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--text-faint);
}
.kbn-rework-chips { display: flex; gap: 6px; }
.kbn-rework-chip {
  padding: 4px 11px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 12px; font-weight: 600; color: var(--text-muted);
  cursor: pointer; font-family: inherit;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.kbn-rework-chip:hover { color: var(--text); border-color: var(--border-strong); }
.kbn-rework-chip.is-active { background: var(--text); color: #fff; border-color: var(--text); }
.kbn-rework-input {
  width: 100%; box-sizing: border-box;
  min-height: 92px; resize: vertical;
  padding: 11px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  font-family: inherit; font-size: 13.5px; line-height: 1.45; color: var(--text);
  transition: border-color 0.12s, box-shadow 0.12s;
}
.kbn-rework-input::placeholder { color: var(--text-faint); }
.kbn-rework-input:focus {
  outline: none;
  border-color: var(--accent-blue, #2563eb);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}
.kbn-rework-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.kbn-rework-cancel {
  padding: 8px 14px;
  background: transparent; color: var(--text-muted);
  border: 0; border-radius: 9px;
  font-size: 13px; font-weight: 600; cursor: pointer; font-family: inherit;
}
.kbn-rework-cancel:hover { background: var(--surface-2); color: var(--text); }
.kbn-rework-send {
  padding: 8px 16px;
  background: var(--text); color: #fff;
  border: 1px solid var(--text); border-radius: 9px;
  font-size: 13px; font-weight: 600; cursor: pointer; font-family: inherit;
  transition: opacity 0.12s;
}
.kbn-rework-send:hover { opacity: 0.88; }

/* ============================================================
   DocuSign-style signing experience
   ============================================================ */

/* Page-like contract card: widen on desktop, ensure full-bleed-ish mobile */
.sign-public-mode .sign-main { padding-bottom: 110px; }
@media (max-width: 640px) {
  .sign-public-mode .sign-main { padding-bottom: 100px; padding-left: 12px; padding-right: 12px; }
}

/* Inline signature / initials zones rendered inside the contract body */
.sig-zone {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  vertical-align: middle;
  padding: 9px 14px;
  min-height: 36px;
  min-width: 180px;
  background: #fff7e3;
  border: 1.5px dashed #d4a017;
  border-radius: 6px;
  font-family: var(--font-sans);
  font-size: 12.5px;
  font-weight: 600;
  color: #8a6612;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease, transform 80ms ease;
  white-space: nowrap;
  text-decoration: none;
}
.sig-zone:hover { background: #fff0c8; border-color: #b8860b; }
.sig-zone:active { transform: translateY(1px); }
.sig-zone:focus-visible { outline: 2px solid var(--accent-blue); outline-offset: 2px; }
.sig-zone-icon {
  display: inline-grid; place-items: center;
  width: 20px; height: 20px;
  border-radius: 4px;
  background: #d4a017;
  color: #fff;
  font-size: 11px;
}
.sig-zone-label { letter-spacing: 0.02em; }

.sig-zone-initials {
  min-width: 80px;
  padding: 9px 12px;
}

.sig-zone-signed {
  background: #f0f7ff;
  border: 1.5px solid #b4d4f7;
  color: var(--text);
  padding: 6px 14px;
  min-height: 40px;
}
.sig-zone-signed:hover { background: #e3efff; border-color: #94c0f0; }
.sig-zone-signed .sig-zone-mark {
  font-size: 30px;
  line-height: 1.1;
  color: #0e1c29;
  font-weight: 500;
}
.sig-zone-initials.sig-zone-signed .sig-zone-mark { font-size: 24px; }

/* XSE pre-signed (non-interactive span) */
.sig-zone-pre-signed {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  background: transparent;
  border: 0;
  cursor: default;
  min-width: 0;
  min-height: 0;
}
.sig-zone-pre-signed .sig-zone-mark {
  font-size: 30px;
  color: #0e1c29;
  font-weight: 500;
}

/* Final (terminal/PDF) rendering - no chrome, just the cursive signature */
.sig-zone-final {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  background: transparent;
  border: 0;
  cursor: default;
  min-width: 0;
  min-height: 0;
}
.sig-zone-final .sig-zone-mark {
  font-size: 32px;
  color: #0e1c29;
  font-weight: 500;
}
.sig-zone-initials.sig-zone-final .sig-zone-mark { font-size: 24px; }
.sig-zone-empty {
  color: var(--text-faint);
  font-style: italic;
  font-size: 12px;
}

/* Awaiting XSELLEREIGHT countersignature - pending placeholder on the company line
   before Anna counter-signs. Muted, dashed, clearly "not yet executed". */
.sig-zone-pending {
  display: inline-flex;
  align-items: center;
  padding: 5px 12px;
  background: var(--surface-2, rgba(20,18,14,0.03));
  border: 1px dashed var(--text-faint);
  border-radius: 8px;
  color: var(--text-muted);
  font-style: italic;
  font-size: 12.5px;
  letter-spacing: 0.01em;
  cursor: default;
}

/* Minimal helper card (replaces old full form) */
.sign-form-card-minimal { padding: 18px 22px; }
.sign-form-helper {
  display: flex; align-items: flex-start; gap: 14px;
}
.sign-form-helper-icon {
  width: 36px; height: 36px;
  border-radius: 8px;
  background: var(--accent-blue-soft);
  color: var(--accent-blue);
  display: grid; place-items: center;
  flex-shrink: 0;
}
.sign-form-helper-text {
  font-size: 13px;
  color: var(--text-soft);
  line-height: 1.55;
}
.sign-form-helper-text strong { display: block; color: var(--text); margin-bottom: 4px; font-weight: 600; }
.sign-form-helper-text em { font-style: normal; color: #8a6612; background: #fff7e3; padding: 0 4px; border-radius: 3px; }

/* Sticky bottom action bar */
.sign-action-bar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  background: #fff;
  border-top: 1px solid var(--border);
  box-shadow: 0 -8px 24px rgba(20, 19, 15, 0.06);
  padding: 14px 24px calc(14px + env(safe-area-inset-bottom, 0px));
  display: flex; align-items: center; gap: 18px;
  z-index: 40;
}
.sign-action-progress { flex: 1; min-width: 0; }
.sign-action-counter {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}
.sign-action-progress-bar {
  height: 6px;
  background: var(--surface-2);
  border-radius: 3px;
  overflow: hidden;
}
.sign-action-progress-fill {
  height: 100%;
  background: var(--accent-blue);
  border-radius: 3px;
  transition: width 200ms ease;
}
.sign-action-finish {
  padding: 12px 22px;
  font-size: 14px;
  font-weight: 600;
  min-height: 44px;
  white-space: nowrap;
}
.sign-action-finish:disabled { opacity: 0.5; cursor: not-allowed; }
@media (max-width: 640px) {
  .sign-action-bar { padding: 12px 14px calc(12px + env(safe-area-inset-bottom, 0px)); gap: 12px; }
  .sign-action-counter { font-size: 12px; }
  .sign-action-finish { padding: 10px 16px; font-size: 13.5px; }
}

/* Adoption modal */
.adopt-modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.adopt-modal[hidden] { display: none !important; }
.adopt-overlay {
  position: absolute;
  inset: 0;
  background: rgba(14, 28, 41, 0.55);
  backdrop-filter: blur(2px);
}
.adopt-sheet {
  position: relative;
  width: 100%;
  max-width: 560px;
  max-height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 24px 60px rgba(20, 19, 15, 0.24);
  overflow: hidden;
}
.adopt-grabber { display: none; }
.adopt-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--hairline);
}
.adopt-head h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}
.adopt-close-btn {
  width: 36px; height: 36px;
  border: 0;
  background: transparent;
  font-size: 22px;
  color: var(--text-soft);
  cursor: pointer;
  border-radius: 8px;
}
.adopt-close-btn:hover { background: var(--surface-2); color: var(--text); }
.adopt-body {
  padding: 20px 22px 4px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}
.adopt-intro {
  margin: 0 0 16px 0;
  font-size: 13px;
  color: var(--text-soft);
  line-height: 1.5;
}
.adopt-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 14px;
}
.adopt-field { display: flex; flex-direction: column; gap: 6px; }
.adopt-field > span {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}
.adopt-field-optional {
  margin-left: 6px;
  font-size: 10.5px;
  font-style: normal;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-faint);
}
.adopt-field input {
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
  font-size: 13.5px;
  background: #fff;
  min-height: 44px;
}
.adopt-field input:focus { outline: 2px solid var(--accent-blue); outline-offset: -1px; border-color: var(--accent-blue); }
.adopt-field-initials { max-width: 130px; }

.adopt-section-label {
  margin: 8px 0 10px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.adopt-fonts {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin-bottom: 16px;
}
.adopt-font {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  transition: border-color 120ms ease, background 120ms ease;
  min-height: 56px;
}
.adopt-font:hover { background: var(--surface-2); }
.adopt-font.is-selected { border-color: var(--accent-blue); background: var(--accent-blue-soft); }
.adopt-font input[type="radio"] {
  width: 18px; height: 18px;
  margin: 0;
  accent-color: var(--accent-blue);
  flex-shrink: 0;
}
.adopt-font-preview {
  flex: 1; min-width: 0;
  display: flex; align-items: baseline; gap: 16px;
}
.adopt-font-sig {
  font-size: 30px;
  color: #0e1c29;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}
.adopt-font-init {
  font-size: 24px;
  color: #0e1c29;
  flex-shrink: 0;
  min-width: 50px;
  text-align: right;
}
.adopt-font-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-faint);
  letter-spacing: 0.02em;
  flex-shrink: 0;
}

.adopt-consent {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 14px;
  background: var(--surface-2);
  border-radius: 10px;
  margin-bottom: 8px;
  cursor: pointer;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--text);
}
.adopt-consent input[type="checkbox"] {
  width: 18px; height: 18px;
  margin: 1px 0 0;
  flex-shrink: 0;
  accent-color: var(--accent-blue);
}

.adopt-foot {
  display: flex; gap: 10px; justify-content: flex-end;
  padding: 14px 22px 18px;
  border-top: 1px solid var(--hairline);
  background: #fff;
}
.adopt-foot .btn-primary,
.adopt-foot .btn-ghost {
  min-height: 44px;
  padding: 0 18px;
  font-size: 14px;
  font-weight: 600;
}

/* Mobile: bottom sheet variant */
@media (max-width: 640px) {
  .adopt-modal { padding: 0; align-items: flex-end; }
  .adopt-overlay { background: rgba(14, 28, 41, 0.6); }
  .adopt-sheet {
    max-width: none;
    max-height: 92vh;
    border-radius: 18px 18px 0 0;
    animation: adoptSheetIn 220ms ease;
  }
  .adopt-grabber {
    display: block;
    width: 40px; height: 4px;
    margin: 8px auto 0;
    border-radius: 2px;
    background: var(--border);
  }
  .adopt-head { padding: 12px 18px; }
  .adopt-body { padding: 12px 18px 4px; }
  .adopt-row { grid-template-columns: 1fr; gap: 12px; }
  .adopt-field-initials { max-width: none; }
  .adopt-foot { padding: 12px 18px 22px; }
}

@keyframes adoptSheetIn {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

/* Body lock when modal is open (prevent background scroll) */
body.sign-modal-open { overflow: hidden; }

/* ============================================================
   PRINT / PDF rendering
   When user clicks "Download signed copy (PDF)" we trigger
   window.print(); they choose Save as PDF in the dialog.
   ============================================================ */
@media print {
  body { background: #fff !important; }
  .sign-topbar,
  .sign-footer,
  .sign-action-bar,
  .sign-form-card,
  .sign-success-card,
  .sign-activity-card,
  .adopt-modal { display: none !important; }
  .sign-main { padding: 0 !important; max-width: none !important; }
  .sign-doc-card {
    box-shadow: none !important;
    border: 0 !important;
    border-radius: 0 !important;
    page-break-inside: auto;
  }
  .sign-doc-head {
    background: #fff !important;
    border-bottom: 2px solid #0e1c29 !important;
  }
  .sign-doc-letterhead { border-bottom: 1px solid #d4d4d0 !important; }
  .sign-doc-body {
    padding: 36px 48px !important;
    font-size: 11.5pt !important;
    line-height: 1.6 !important;
  }
  .sig-zone {
    background: transparent !important;
    border: 0 !important;
    color: #0e1c29 !important;
    padding: 0 !important;
    min-height: 0 !important;
    min-width: 0 !important;
  }
  .sig-zone .sig-zone-icon,
  .sig-zone .sig-zone-label { display: none !important; }
  .sig-zone-signed .sig-zone-mark,
  .sig-zone-final .sig-zone-mark,
  .sig-zone-pre-signed .sig-zone-mark { font-size: 20pt !important; }
  .var-token {
    background: transparent !important;
    color: inherit !important;
    padding: 0 !important;
  }
}

/* ============================================================
   Margins money-flow map - mirrors the Email Flows canvas
   (pan/zoom viewport + bezier connectors). Engine: mg* in app.js.
   ============================================================ */
.mg-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 0; /* full-bleed canvas - meets the header's bottom line, no inner stripe */
  width: 100%;
  overflow: hidden;
}
.mg-stage { flex: 1; min-height: 0; display: flex; }
.marginmap-viewport {
  position: relative;
  flex: 1;
  min-height: 0;
  width: 100%;
  overflow: hidden; /* clips the pan/zoom canvas - keep */
  cursor: grab;
  user-select: none;
  background:
    radial-gradient(circle, rgba(20,18,14,0.05) 1px, transparent 1.2px) 0 0 / 22px 22px,
    var(--surface);
}
.marginmap-viewport.panning { cursor: grabbing; }
.mg-zoom-wrap {
  position: absolute;
  top: 0; left: 0;
  transform-origin: 0 0;
  will-change: transform;
}
.mg-connectors {
  position: absolute;
  top: 0; left: 0;
  pointer-events: none;
  z-index: 0;
  overflow: visible;
}
.mg-conn { fill: none; stroke: var(--border-strong); stroke-width: 1.6; stroke-linecap: round; }
.mg-conn-pkg  { stroke: var(--text-muted); stroke-width: 2.2; }
.mg-conn-step { stroke: var(--border-strong); stroke-width: 1.6; }
.mg-conn-net  { stroke: #1a6b3c; stroke-width: 2.4; }

.mg-mindmap {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0 88px;
  padding: 32px 28px 56px;
  min-width: max-content;
}
.mg-root {
  align-self: center;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  background: var(--accent);
  border-radius: var(--radius);
  box-shadow: var(--shadow-pop);
  color: #fff;
}
.mg-root-mark {
  display: flex; align-items: center; justify-content: center;
  width: 38px; height: 38px;
  border-radius: 10px;
  background: rgba(255,255,255,0.12);
  color: #fff;
  flex-shrink: 0;
}
.mg-root-text { display: flex; flex-direction: column; gap: 1px; }
.mg-root-title { font-size: 14px; font-weight: 700; letter-spacing: 0.06em; }
.mg-root-sub {
  font-size: 10.5px; font-weight: 600; letter-spacing: 0.08em;
  text-transform: uppercase; color: rgba(255,255,255,0.6);
}

.mg-packages { display: flex; flex-direction: column; gap: 30px; }
.mg-package {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0 72px;
  align-items: center;
}
.mg-package-node {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 13px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--tn, var(--text-muted));
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  min-width: 200px;
}
.mg-package-dot { width: 11px; height: 11px; border-radius: 50%; background: var(--tn, var(--text-muted)); flex-shrink: 0; }
.mg-package-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.mg-package-title { font-size: 14px; font-weight: 600; color: var(--text); letter-spacing: -0.005em; }
.mg-package-meta { font-size: 11.5px; color: var(--text-muted); font-family: var(--font-mono); }

.mg-flow { display: flex; align-items: center; flex-wrap: nowrap; gap: 16px; }
.mg-node {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 13px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  flex-shrink: 0;
  white-space: nowrap;
  transition: background 100ms ease, border-color 100ms ease, box-shadow 100ms ease;
}
.mg-node:hover { background: var(--surface-2); border-color: var(--text-muted); box-shadow: var(--shadow-active); }
.mg-node-num { font-family: var(--font-mono); font-size: 10.5px; color: var(--text-muted); }
.mg-node-text { display: flex; flex-direction: column; gap: 1px; }
.mg-node-role { font-size: 12.5px; font-weight: 500; color: var(--text); letter-spacing: -0.005em; }
.mg-node-who { font-size: 11px; color: var(--text-muted); }
.mg-node-amt { font-family: var(--font-mono); font-size: 12.5px; font-weight: 600; color: var(--text-soft); margin-left: 2px; }

.mg-net {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 11px 17px;
  border-radius: 12px;
  flex-shrink: 0;
  white-space: nowrap;
  color: #fff;
}
.mg-net.is-positive { background: #25d366; box-shadow: 0 8px 20px -10px rgba(37,211,102,0.7); }
.mg-net.is-negative { background: #b4452f; box-shadow: 0 8px 20px -10px rgba(180,69,47,0.7); }
.mg-net-label { font-size: 9.5px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: rgba(255,255,255,0.72); }
.mg-net-amt { font-family: var(--font-mono); font-size: 17px; font-weight: 700; letter-spacing: -0.01em; }
.mg-net-pct { font-size: 11px; font-weight: 600; color: rgba(255,255,255,0.82); }

/* Tone accents (mirror the Email Flows palette) */
.mg-package-node.tone-amber     { --tn: #c89640; }
.mg-package-node.tone-blue      { --tn: var(--accent-blue); }
.mg-package-node.tone-green     { --tn: #1a6b3c; }
.mg-package-node.tone-executive { --tn: var(--dept-executive-fg); }

/* Floating fit pill */
/* Rounded "Fit" pill - matches the Email Flows toolbar: a pill-shaped
   container wrapping a transparent button whose hover fill follows the same
   pill shape (no squared-off hover box). */
.mg-zoom-toolbar {
  position: absolute;
  right: 16px;
  bottom: 16px;
  z-index: 4;
  display: flex;
  align-items: center;
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  box-shadow: 0 6px 16px -6px rgba(20,18,14,0.16), 0 0 0 1px rgba(20,18,14,0.02);
}
.mg-zoom-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-pill);
  color: var(--text-soft);
  font: inherit;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background 100ms ease, color 100ms ease;
}
.mg-zoom-btn:hover { background: var(--surface-2); color: var(--text); }
.mg-zoom-btn kbd {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  padding: 1px 5px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface-2);
  color: var(--text-soft);
  line-height: 1;
}

/* ============================================================
   MONEY PATH DRIVER - client rail demo panel (see app.js)
   ============================================================ */
.mp-panel { }
.mp-label { display: flex; align-items: center; }
.mp-steps {
  display: flex;
  flex-direction: column;
  gap: 1px;
  margin: 4px 0 10px;
}
.mp-step {
  display: grid;
  grid-template-columns: 14px 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  border-radius: 8px;
}
.mp-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--border-strong);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.04);
}
.mp-step-main { font-size: 12.5px; font-weight: 600; color: var(--text-soft); }
.mp-step-sub  { font-size: 11px; color: var(--text-muted); }
.mp-step.is-sent   .mp-dot { background: #c89640; }
.mp-step.is-sent   .mp-step-main { color: var(--text); }
.mp-step.is-active .mp-dot { background: var(--accent-blue); animation: mp-pulse 1.2s ease-in-out infinite; }
.mp-step.is-active .mp-step-main { color: var(--text); }
.mp-step.is-done   .mp-dot { background: #1a6b3c; }
.mp-step.is-done   .mp-step-main { color: var(--text); }
.mp-step.is-done   .mp-step-sub  { color: #1a6b3c; }
@keyframes mp-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.32; } }
.mp-action-row { display: flex; }
.mp-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  padding: 9px 12px;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  font-size: 12.5px;
  font-weight: 650;
  color: #fff;
  background: var(--text);
  box-shadow: var(--shadow-card);
}
.mp-action:hover { filter: brightness(1.1); }
.mp-action:active { transform: translateY(1px); }
.mp-done {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  padding: 9px 12px;
  border-radius: 10px;
  font-size: 12.5px;
  font-weight: 650;
  color: #1a6b3c;
  background: rgba(26, 107, 60, 0.08);
}
.mp-waiting {
  width: 100%;
  text-align: center;
  padding: 9px 12px;
  font-size: 12px;
  font-style: italic;
  color: var(--text-muted);
}
.mp-run {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-left: auto;
  padding: 3px 9px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-soft);
  cursor: pointer;
  font-size: 11px;
  font-weight: 600;
}
.mp-run:hover { color: var(--text); border-color: var(--border-strong); }
.mp-note {
  margin: 8px 0 0;
  font-size: 10.5px;
  line-height: 1.45;
  color: var(--text-muted);
}
/* Live worker send row - amber-tinted so it reads as "this is real" vs the mock */
.mp-live {
  margin-top: 10px;
  padding: 8px 10px;
  border: 1px dashed #c89640;
  border-radius: 10px;
  background: rgba(200, 150, 64, 0.06);
}
.mp-live-eyebrow {
  display: block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: #8a6a2d;
}
.mp-live-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}
.mp-live-btn {
  flex: 1 1 auto;
  padding: 6px 10px;
  border: 1px solid #c89640;
  border-radius: 8px;
  background: var(--surface);
  color: #8a6a2d;
  cursor: pointer;
  font-size: 11.5px;
  font-weight: 650;
}
.mp-live-btn:hover { background: #c89640; color: #fff; }
.mp-live-link {
  display: inline-block;
  margin-top: 7px;
  font-size: 11px;
  color: var(--accent-blue);
  text-decoration: none;
}
.mp-live-link:hover { text-decoration: underline; }

/* ============================================================
   ONGOING MANAGEMENT - Managed Accounts surface
   Roster + bento for the recurring book of business. Reuses the
   report-kpi / report-card vocabulary; .ma-* styles the roster.
   ============================================================ */
.body.ma-body {
  flex: 1;
  overflow: auto;
  padding: 20px 22px 40px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  background: var(--bg);
}
.ma-kpi-foot { font-size: 11.5px; color: var(--text-muted); }

.ma-card { gap: 14px; }
.ma-roster { display: flex; flex-direction: column; overflow-x: auto; }

.ma-roster-head,
.ma-row {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) 156px minmax(0, 1.4fr) 92px 104px 64px 84px;
  align-items: center;
  gap: 12px;
  min-width: 720px;
}
.ma-roster-head {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 0 8px 9px;
  border-bottom: 1px solid var(--border);
}
.ma-row {
  padding: 11px 8px;
  border-bottom: 1px solid var(--hairline);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 100ms ease;
}
.ma-row:hover { background: var(--surface-2); }
.ma-row:last-child { border-bottom: 0; }

.ma-brand-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.005em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ma-brand-owner { font-size: 11.5px; color: var(--text-muted); margin-top: 1px; }

.ma-num {
  text-align: right;
  font-size: 12.5px;
  color: var(--text-soft);
  font-variant-numeric: tabular-nums;
}
.ma-roster-head .ma-num { color: var(--text-muted); }

/* status pill tones, layered on the shared .status-pill base */
.ma-pill { font-weight: 600; }
.ma-pill.tone-blue   { color: var(--status-sent-fg);      background: var(--status-sent-bg); }
.ma-pill.tone-blue   .status-dot { background: var(--status-sent-fg); }
.ma-pill.tone-green  { color: var(--status-signed-fg);    background: var(--status-signed-bg); }
.ma-pill.tone-green  .status-dot { background: var(--status-signed-fg); }
.ma-pill.tone-amber  { color: var(--status-viewed-fg);    background: var(--status-viewed-bg); }
.ma-pill.tone-amber  .status-dot { background: var(--status-viewed-fg); }
.ma-pill.tone-draft  { color: var(--status-draft-fg);     background: var(--status-draft-bg); }
.ma-pill.tone-draft  .status-dot { background: var(--status-draft-fg); }
.ma-pill.tone-voided { color: var(--status-voided-fg);    background: var(--status-voided-bg); }
.ma-pill.tone-voided .status-dot { background: var(--status-voided-fg); }

.ma-freebar {
  height: 4px;
  max-width: 150px;
  margin-top: 6px;
  background: var(--surface-2);
  border-radius: var(--radius-pill);
  overflow: hidden;
}
.ma-freebar-fill { height: 100%; background: var(--status-sent-fg); border-radius: inherit; }
.ma-freebar-fill.closing { background: var(--warn); }

.ma-terms-label { font-size: 12.5px; color: var(--text-soft); }
.ma-chip {
  display: inline-block;
  margin-top: 4px;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.ma-chip.ok { color: var(--status-signed-fg); background: var(--status-signed-bg); border-color: transparent; }
.ma-chip.muted { color: var(--text-faint); }

.ma-ops { display: inline-flex; align-items: center; }
.ma-ops .pb-owner-chip:not(:first-child) { margin-left: -6px; }
.ma-ops-empty { color: var(--text-faint); font-size: 12.5px; }

.ma-empty {
  padding: 28px 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.5;
}

/* ---------- Role preview switcher (sidebar bottom) ----------
   Mock affordance: lets the owner preview the Dashboard as any role to
   see what that team member would (and would not) be able to access.
   Replaced by the signed-in user's real role once auth lands. */
.role-preview {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 5px;
  padding: 6px 8px 8px;
  margin-bottom: 2px;
}
.role-preview-label {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--text-faint);
  padding-left: 2px;
}
.role-preview-select {
  width: 100%;
  min-width: 0;
  font: inherit;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-soft);
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  /* extra right padding clears the custom chevron, which is inset from the edge */
  padding: 6px 30px 6px 10px;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23807c73' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m7 10 5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 14px 14px;
}
.role-preview-select:hover { border-color: var(--border-strong); }
.role-preview-select:focus-visible { outline: 2px solid var(--accent-blue); outline-offset: 1px; }
