/* =====================================================================
   SANJI (VizMark Business Development Intelligence Platform) — design
   system (Phase 2A, ADR-0042). A premium intelligence-workspace visual
   language: calm, spacious, and quiet by default, with a refined medical
   rose accent used sparingly against warm white/graphite surfaces —
   deliberately not a recolor of the Phase 1C navy/teal admin-dashboard
   language it replaces. Tokens first, then components. Every rule here is
   a plain stylesheet served same-origin (CSP: style-src 'self', no inline
   styles) — spacing/utility classes exist because inline style="" is not
   permitted.
   ===================================================================== */

:root {
  color-scheme: light;

  /* ---- surfaces & ink ---- */
  --color-bg: #f7f4f3;
  --color-surface: #ffffff;
  --color-surface-sunken: #fbeef2;
  --color-surface-inverse: #1e1517;
  --color-border: #e9dfe0;
  --color-border-strong: #d6c5c8;
  --color-text: #201a1c;
  --color-text-muted: #6b5a5d;
  /* #7c6a6d on white is ~4.6:1 (WCAG AA for normal text needs 4.5:1) — kept
     at the same contrast bar the Phase 1C.1 accessibility fix established. */
  --color-text-faint: #7c6a6d;
  --color-text-inverse: #f3e6ea;

  /* ---- brand: near-black graphite + refined medical rose ---- */
  --graphite-900: #150f11;
  --graphite-800: #241a1d;
  --graphite-700: #362528;
  --graphite-600: #4a3236;
  --rose-700: #9d174d;
  --rose-600: #be185d;
  --rose-500: #d3306f;
  --rose-100: #fbd6e4;
  --rose-50: #fdf0f5;

  /* ---- semantic ---- */
  --success-700: #146138;
  --success-600: #187a45;
  --success-50: #e7f5ec;
  --warning-700: #8a5c07;
  --warning-600: #a06b08;
  --warning-50: #fbf1dc;
  --danger-700: #94261e;
  --danger-600: #b3291f;
  --danger-50: #fbeae8;
  --info-700: #1e40af;
  --info-600: #2554d6;
  --info-50: #eaf1fe;

  /* ---- spacing scale (Phase 2A: widened at the top end for a more
     generous, less card-crowded layout — see item 3) ---- */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 40px;
  --space-7: 56px;

  /* ---- radii & elevation (restrained: shallower shadows than Phase 1C's
     admin-dashboard depth, per item 3) ---- */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 999px;
  --shadow-xs: 0 1px 2px rgba(32, 20, 22, 0.05);
  --shadow-sm: 0 2px 8px rgba(32, 20, 22, 0.05);
  --shadow-md: 0 8px 20px rgba(32, 20, 22, 0.09);
  --shadow-lg: 0 16px 40px rgba(32, 20, 22, 0.16);

  /* ---- type ---- */
  --font-sans:
    ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --text-xs: 12px;
  --text-sm: 12.5px;
  --text-base: 14px;
  --text-md: 15px;
  --text-lg: 17px;
  --text-xl: 22px;
  --text-2xl: 29px;

  --focus-ring: 0 0 0 3px rgba(190, 24, 93, 0.32);
  --duration-fast: 120ms;
  --duration-base: 180ms;

  /* legacy aliases still referenced conceptually across this file */
  --radius: var(--radius-md);
  --line: var(--color-border);
  --ink: var(--color-text);
  --muted: var(--color-text-muted);
  --accent: var(--rose-600);
  --accent-strong: var(--rose-700);
}

/* =====================================================================
   Reset & base
   ===================================================================== */
* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
}

body {
  font: var(--text-base) / 1.55 var(--font-sans);
  color: var(--color-text);
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
h4 {
  font-family: var(--font-sans);
  color: var(--color-text);
  letter-spacing: -0.01em;
  line-height: 1.25;
}

a {
  color: var(--rose-700);
}

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

svg.icon {
  flex: none;
  vertical-align: -3px;
}

:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
  border-radius: var(--radius-sm);
}

.app-root {
  min-height: 100%;
}

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

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 100;
  background: var(--graphite-900);
  color: #fff;
  padding: 10px 16px;
  border-radius: 0 0 var(--radius-sm) 0;
  font-weight: 600;
}

.skip-link:focus {
  left: 0;
}

/* =====================================================================
   Login
   ===================================================================== */
.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: var(--space-5);
  background:
    radial-gradient(1200px 600px at 15% -10%, rgba(211, 48, 111, 0.3), transparent 60%),
    linear-gradient(165deg, var(--graphite-900) 0%, var(--graphite-700) 55%, var(--rose-700) 130%);
}

.login-card {
  width: 100%;
  max-width: 408px;
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: var(--space-6) var(--space-6) var(--space-5);
  box-shadow: var(--shadow-lg);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: var(--space-4);
}

.login-card h1 {
  margin: 0 0 4px;
  font-size: var(--text-xl);
}

.login-card p.sub {
  margin: 0 0 var(--space-2);
  color: var(--color-text-muted);
}

.login-card p.sub-attribution {
  margin: 0 0 var(--space-5);
  font-size: var(--text-sm);
}

/* =====================================================================
   App shell / layout
   ===================================================================== */
.layout {
  display: grid;
  grid-template-columns: 248px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--graphite-900);
  color: var(--color-text-inverse);
  display: flex;
  flex-direction: column;
  padding: var(--space-4) var(--space-3) var(--space-4);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: var(--space-2) var(--space-2) var(--space-5);
  font-weight: 700;
  font-size: var(--text-md);
  color: #fff;
  letter-spacing: 0.01em;
}

.brand-sub {
  display: block;
  font-weight: 500;
  font-size: 10.5px;
  letter-spacing: 0.03em;
  color: #b89ba1;
  text-transform: uppercase;
}

.brand .mark {
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  background: linear-gradient(150deg, var(--rose-500), var(--rose-700));
  display: grid;
  place-items: center;
  color: #ffffff;
  font-weight: 800;
  font-size: 14px;
  box-shadow: var(--shadow-xs);
}

.nav {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  flex: 1;
}

.nav-group + .nav-group {
  margin-top: var(--space-4);
}

.nav-group-label {
  margin: 0 var(--space-2) 6px;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: #a67d85;
}

/* Collapsible sidebar group (item 5, Phase 2A.2): a group with sub-items
   (e.g. Intelligence's kinds) renders its label as a toggle button instead
   of static text, so the sidebar starts short and only grows when the user
   actually wants that group's detail. */
.nav-group-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  margin: 0 0 6px;
  padding: 4px var(--space-2);
  background: none;
  border: none;
  cursor: pointer;
  font: inherit;
  border-radius: var(--radius-sm);
}

.nav-group-toggle:hover {
  background: rgba(255, 255, 255, 0.06);
}

.nav-group-toggle svg.icon {
  color: #a67d85;
  transition: transform var(--duration-fast) ease;
}

.nav-group-toggle[aria-expanded='true'] svg.icon {
  transform: rotate(180deg);
}

.nav-subgroup {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  margin-top: 2px;
}

.nav-subgroup[hidden] {
  display: none;
}

.nav-subgroup .nav-sub {
  padding-left: 30px;
  font-size: 12.5px;
  /* Not `opacity` on --color-text-inverse: axe-core's contrast checker does
     not reliably resolve the blended effective color that produces against
     the dark sidebar, and reported it against the light page background
     instead (a false near-invisible reading). This is the same muted tone
     already verified against this exact graphite-900 background for
     .nav-future a (~6.2:1, Phase 1C.1/1C.2). */
  color: #b298a0;
}

.nav-subgroup .nav-sub:hover {
  color: var(--color-text-inverse);
}

.nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  color: var(--color-text-inverse);
  text-decoration: none;
  font-weight: 500;
  font-size: 13.5px;
  transition: background var(--duration-fast) ease;
}

.nav a svg.icon {
  color: #a67d85;
  transition: color var(--duration-fast) ease;
}

.nav a:hover {
  background: rgba(255, 255, 255, 0.07);
}

.nav a.active {
  background: linear-gradient(90deg, rgba(211, 48, 111, 0.32), rgba(211, 48, 111, 0.08));
  color: #fff;
  box-shadow: inset 2px 0 0 var(--rose-500);
}

.nav a.active svg.icon {
  color: #f472b6;
}

.nav-future {
  margin-top: var(--space-5);
  padding-top: var(--space-4);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.nav-future .nav-group-label {
  /* Recomputed for the Phase 2A graphite-900 sidebar (was tuned against
     Phase 1C's navy-900); #a98d92 on #150f11 is ~6.2:1, above the 4.5:1
     WCAG AA bar the Phase 1C.1 fix established (axe-core, item 4). */
  color: #a98d92;
}

.nav-future a {
  color: #b298a0;
}

.nav-future a:hover {
  background: rgba(255, 255, 255, 0.04);
}

.sidebar-foot {
  margin-top: var(--space-4);
  padding-top: var(--space-3);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 11px;
  /* Recomputed for the Phase 2A graphite-900 sidebar background (the old
     value was tuned against Phase 1C's navy-900 and read as flat blue-gray
     against the new warm graphite): #b89ba1 on #150f11 is ~7.4:1, well
     above the 4.5:1 WCAG AA bar the Phase 1C.1 fix established. */
  color: #b89ba1;
}

.content {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 10px var(--space-5);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  z-index: 20;
}

.menu-toggle {
  display: none;
}

.topbar .title {
  font-weight: 650;
  font-size: var(--text-lg);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.topbar-spacer {
  flex: 1;
}

.topbar-search {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border-radius: var(--radius-full);
  border: 1px solid var(--color-border);
  background: var(--color-surface-sunken);
  color: var(--color-text-muted);
  cursor: pointer;
  font-size: var(--text-sm);
  min-width: 0;
  width: 220px;
  flex-shrink: 1;
}

.topbar-search span.hint-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-search:hover {
  border-color: var(--color-border-strong);
}

.topbar-search kbd {
  margin-left: auto;
  font: 11px var(--font-mono);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  padding: 1px 5px;
  color: var(--color-text-faint);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Search and Ask Winston read as one command area (item 11), not two
   unrelated systems — same tight gap the rest of the topbar's icon
   clusters use, so the eye reads them as a pair. */
.topbar-command {
  display: flex;
  align-items: center;
  gap: 6px;
}

.icon-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--color-text-muted);
  cursor: pointer;
}

.icon-btn:hover {
  background: var(--color-surface-sunken);
  color: var(--color-text);
}

.icon-btn .dot {
  position: absolute;
  top: 5px;
  right: 6px;
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  background: var(--danger-600);
  border: 1.5px solid var(--color-surface);
}

.user-trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px 5px 5px;
  border-radius: var(--radius-full);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  cursor: pointer;
  font-size: var(--text-sm);
}

.user-trigger:hover {
  background: var(--color-surface-sunken);
}

.avatar {
  width: 26px;
  height: 26px;
  border-radius: var(--radius-full);
  background: linear-gradient(150deg, var(--graphite-700), var(--rose-600));
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 11px;
}

.user-trigger .who {
  display: flex;
  flex-direction: column;
  text-align: left;
  line-height: 1.25;
}

.user-trigger .who .name {
  font-weight: 600;
  color: var(--color-text);
}

.user-trigger .who .role {
  color: var(--color-text-faint);
  font-size: 11px;
}

/* Item 12: still unmistakable and always visible in a TEST DATA
   environment, but toned down from a bold, heavy-handed warning strip to a
   quiet persistent caption — it should read as a standing fact about this
   environment, not as an alert competing with the actual workflow. */
.test-data-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--warning-50);
  color: var(--warning-700);
  border-bottom: 1px solid #f1d9a3;
  padding: 6px var(--space-5);
  font-size: var(--text-sm);
  font-weight: 500;
}

/* `display: flex` above (author CSS) outranks the browser's built-in
   `[hidden] { display: none }`, so without this rule the banner is always
   visible and bootApp()'s `bannerElement.hidden = true` has no effect. */
.test-data-banner[hidden] {
  display: none;
}

.test-data-banner svg.icon {
  flex: none;
  width: 13px;
  height: 13px;
}

main.page {
  padding: var(--space-5);
  max-width: 1320px;
  width: 100%;
}

.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.page-header h1 {
  margin: 0;
  font-size: var(--text-2xl);
  font-weight: 650;
}

.page-header .subtitle {
  margin-top: 4px;
  color: var(--color-text-muted);
  font-size: var(--text-base);
}

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

.breadcrumb {
  color: var(--color-text-faint);
  font-size: var(--text-sm);
  margin-bottom: var(--space-2);
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.breadcrumb a {
  color: var(--color-text-muted);
  text-decoration: none;
}

.breadcrumb a:hover {
  color: var(--rose-700);
  text-decoration: underline;
}

/* =====================================================================
   Cards & grids
   ===================================================================== */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xs);
  padding: var(--space-4) var(--space-5);
  margin-bottom: var(--space-4);
}

.card.flush {
  padding: 0;
  overflow: hidden;
}

.card.flush .card-head {
  padding: var(--space-4) var(--space-5) 0;
}

.card.flush .table-wrap {
  padding: 0;
}

.card h2 {
  margin: 0 0 var(--space-3);
  font-size: var(--text-md);
  font-weight: 650;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}

.card-head h2 {
  margin: 0;
}

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

.grid {
  display: grid;
  gap: var(--space-4);
}

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

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

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

.stat {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  box-shadow: var(--shadow-xs);
}

.stat .label {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--color-text-muted);
  font-size: 11.5px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.stat .value {
  font-size: 27px;
  font-weight: 700;
  margin-top: 6px;
  letter-spacing: -0.01em;
}

.stat .hint {
  color: var(--color-text-faint);
  font-size: var(--text-sm);
  margin-top: 2px;
}

.stat.tone-warn {
  border-color: #f0dba4;
  background: var(--warning-50);
}

.stat.tone-danger {
  border-color: #f0c1bc;
  background: var(--danger-50);
}

/* attention feed */
.attention-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.attention-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 8px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: inherit;
}

.attention-row:hover {
  /* Not --color-surface-sunken (#fbeef2): its pink tint sits close enough
     to --color-text-faint's hue that the row's .secondary text drops to
     ~4.49:1, just under the 4.5:1 WCAG AA bar that color was tuned against
     white for (axe caught this once "Needs attention" moved higher up the
     page in Phase 2A.2, item 4, putting a real cursor position over a row
     during the accessibility check). --color-bg keeps the hover affordance
     visible while staying close enough to white to preserve that ratio. */
  background: var(--color-bg);
}

.attention-row .icon-wrap {
  flex: none;
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  display: grid;
  place-items: center;
  background: var(--rose-50);
  color: var(--rose-700);
}

.attention-row .icon-wrap.warn {
  background: var(--warning-50);
  color: var(--warning-700);
}

.attention-row .icon-wrap.danger {
  background: var(--danger-50);
  color: var(--danger-700);
}

.attention-row .body {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}

.attention-row .primary {
  font-weight: 600;
  font-size: var(--text-base);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.attention-row .secondary {
  color: var(--color-text-faint);
  font-size: 12px;
}

.notice {
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  margin-bottom: var(--space-4);
  border: 1px solid;
  display: flex;
  gap: 10px;
  align-items: flex-start;
  font-size: var(--text-base);
}

.notice svg.icon {
  margin-top: 1px;
}

.notice.info {
  background: var(--info-50);
  border-color: #c4d5f7;
  color: var(--info-700);
}

.notice.warn {
  background: var(--warning-50);
  border-color: #f0dba4;
  color: var(--warning-700);
}

.notice.error {
  background: var(--danger-50);
  border-color: #f0c1bc;
  color: var(--danger-700);
}

.not-active {
  background: var(--color-surface);
  border: 1px dashed var(--color-border-strong);
  border-radius: var(--radius-lg);
  padding: var(--space-6) var(--space-5);
  text-align: center;
  color: var(--color-text-muted);
}

.not-active .icon-wrap {
  width: 44px;
  height: 44px;
  margin: 0 auto var(--space-3);
  border-radius: var(--radius-full);
  background: var(--color-surface-sunken);
  color: var(--color-text-faint);
  display: grid;
  place-items: center;
}

.not-active h2 {
  margin: 0 0 6px;
  color: var(--color-text);
  font-size: var(--text-md);
}

.not-active .pill {
  display: inline-block;
  margin-top: var(--space-3);
}

/* =====================================================================
   Empty / skeleton states
   ===================================================================== */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: var(--space-6) var(--space-4);
  color: var(--color-text-muted);
}

.empty-state .icon-wrap {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  background: var(--color-surface-sunken);
  color: var(--color-text-faint);
  display: grid;
  place-items: center;
  margin-bottom: var(--space-3);
}

.empty-state .title {
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 2px;
}

.empty-state .desc {
  font-size: var(--text-sm);
  max-width: 40ch;
}

.empty {
  color: var(--color-text-muted);
  padding: var(--space-4);
  text-align: center;
}

.skeleton {
  background: linear-gradient(
    100deg,
    var(--color-surface-sunken) 30%,
    #e6e9ef 50%,
    var(--color-surface-sunken) 70%
  );
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.3s ease-in-out infinite;
  border-radius: var(--radius-sm);
}

@keyframes skeleton-shimmer {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

.skeleton-page {
  padding: var(--space-5);
  max-width: 1320px;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.skeleton-line {
  height: 14px;
  width: 100%;
}

.skeleton-block {
  height: 120px;
  width: 100%;
}

@media (prefers-reduced-motion: reduce) {
  .skeleton {
    animation: none;
  }
}

/* =====================================================================
   Tables
   ===================================================================== */
.table-wrap {
  overflow-x: auto;
}

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-base);
}

table.data th,
table.data td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--color-border);
  vertical-align: top;
}

table.data thead th {
  position: sticky;
  top: 0;
  background: var(--color-surface);
  color: var(--color-text-muted);
  font-weight: 650;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
  z-index: 1;
}

table.data th.sortable {
  cursor: pointer;
  user-select: none;
}

table.data th.sortable .sort-indicator {
  margin-left: 4px;
  color: var(--color-text-faint);
}

table.data th.sortable.active .sort-indicator {
  color: var(--rose-700);
}

table.data tbody tr:hover {
  /* Not --color-surface-sunken — see the matching comment on
     .attention-row:hover: its pink tint drops --color-text-faint content
     (e.g. the Leads list's per-row stage/owner/last-touch line, item 6)
     below the 4.5:1 bar that color was tuned against white for. */
  background: var(--color-bg);
}

table.data tr.clickable {
  cursor: pointer;
}

table.data td.actions {
  white-space: nowrap;
  text-align: right;
}

table.data tr.row-overdue td:first-child {
  box-shadow: inset 3px 0 0 var(--danger-600);
}

table.data tr.row-due-soon td:first-child {
  box-shadow: inset 3px 0 0 var(--warning-600);
}

/* =====================================================================
   Forms
   ===================================================================== */
form.form {
  display: grid;
  gap: var(--space-4);
}

.field {
  display: grid;
  gap: 5px;
}

.field label {
  font-weight: 600;
  font-size: var(--text-sm);
  color: var(--color-text);
}

.field .help {
  color: var(--color-text-faint);
  font-size: var(--text-xs);
}

.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  font-size: var(--text-base);
  transition:
    border-color var(--duration-fast) ease,
    box-shadow var(--duration-fast) ease;
}

.field input:hover,
.field select:hover,
.field textarea:hover {
  border-color: #9aa4b3;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--rose-600);
  box-shadow: var(--focus-ring);
}

.field textarea {
  min-height: 96px;
  resize: vertical;
}

.field.checkbox {
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 8px;
}

.field.checkbox input {
  width: auto;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-4);
}

.form-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  padding-top: 2px;
}

.form-error {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--danger-700);
  background: var(--danger-50);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: var(--text-sm);
}

.form-error:empty {
  display: none;
  padding: 0;
  background: none;
}

/* =====================================================================
   Buttons, badges
   ===================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border-strong);
  background: var(--color-surface);
  cursor: pointer;
  font-weight: 600;
  font-size: var(--text-base);
  text-decoration: none;
  color: var(--color-text);
  line-height: 1.3;
  transition:
    background var(--duration-fast) ease,
    border-color var(--duration-fast) ease,
    box-shadow var(--duration-fast) ease,
    transform var(--duration-fast) ease;
}

.btn:hover {
  background: var(--color-surface-sunken);
  border-color: var(--color-border-strong);
}

.btn:active {
  transform: translateY(1px);
}

.btn.primary {
  background: var(--rose-600);
  border-color: var(--rose-600);
  color: #fff;
}

.btn.primary:hover {
  background: var(--rose-700);
  border-color: var(--rose-700);
}

.winston-trigger {
  border-color: var(--rose-100);
  background: var(--rose-50);
  color: var(--rose-700);
}

.winston-trigger:hover {
  background: var(--rose-100);
  border-color: var(--rose-500);
}

.btn.ghost {
  border-color: transparent;
  background: transparent;
}

.btn.ghost:hover {
  background: var(--color-surface-sunken);
}

.btn.danger {
  color: var(--danger-700);
  border-color: #f0c1bc;
  background: var(--color-surface);
}

.btn.danger:hover {
  background: var(--danger-50);
}

.btn.small {
  padding: 5px 10px;
  font-size: 12.5px;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.btn.is-loading {
  position: relative;
  color: transparent !important;
}

.btn.is-loading::after {
  content: '';
  position: absolute;
  width: 14px;
  height: 14px;
  border-radius: var(--radius-full);
  border: 2px solid currentColor;
  border-top-color: transparent;
  color: inherit;
  animation: btn-spin 0.7s linear infinite;
  opacity: 0.9;
}

.btn.primary.is-loading::after,
.btn.danger.is-loading::after {
  color: var(--color-text);
}

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

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: var(--radius-full);
  font-size: 11.5px;
  font-weight: 650;
  background: var(--color-surface-sunken);
  color: var(--color-text-muted);
  white-space: nowrap;
  line-height: 1.5;
}

.badge.ok {
  background: var(--success-50);
  color: var(--success-700);
}

.badge.warn {
  background: var(--warning-50);
  color: var(--warning-700);
}

.badge.danger {
  background: var(--danger-50);
  color: var(--danger-700);
}

.badge.info {
  background: var(--info-50);
  color: var(--info-700);
}

.badge.accent {
  background: var(--rose-50);
  color: var(--rose-700);
}

.badge.dot::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: var(--radius-full);
  background: currentColor;
}

/* =====================================================================
   Tabs, toolbar, kv, misc
   ===================================================================== */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: var(--space-4);
  overflow-x: auto;
}

.tabs button {
  border: none;
  background: none;
  padding: 10px 14px;
  cursor: pointer;
  color: var(--color-text-muted);
  font-weight: 600;
  font-size: var(--text-base);
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}

.tabs button:hover {
  color: var(--color-text);
}

.tabs button.active {
  color: var(--rose-700);
  border-bottom-color: var(--rose-600);
}

.toolbar {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: var(--space-3);
}

.toolbar input,
.toolbar select {
  padding: 7px 10px;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-sm);
  font-size: var(--text-base);
}

.toolbar input[type='search'] {
  min-width: 220px;
}

dl.kv {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 8px 18px;
  margin: 0;
}

dl.kv dt {
  color: var(--color-text-faint);
  font-size: var(--text-sm);
  padding-top: 1px;
}

dl.kv dd {
  margin: 0;
  overflow-wrap: anywhere;
}

pre.content-block {
  white-space: pre-wrap;
  font: inherit;
  margin: 0;
  overflow-wrap: anywhere;
}

.muted {
  color: var(--color-text-muted);
}

.faint {
  color: var(--color-text-faint);
}

/* spacing utilities (inline styles are blocked by the CSP) */
.mt-4 {
  margin-top: var(--space-1);
}

.mt-8 {
  margin-top: var(--space-2);
}

.mt-10 {
  margin-top: 10px;
}

.mt-12 {
  margin-top: var(--space-3);
}

.mt-14 {
  margin-top: 14px;
}

.mt-16 {
  margin-top: var(--space-4);
}

.mb-10 {
  margin-bottom: 10px;
}

.row-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.mono {
  font-family: var(--font-mono);
  font-size: 12.5px;
}

.hstack {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.vstack {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

/* =====================================================================
   Toasts
   ===================================================================== */
.toasts {
  position: fixed;
  right: 16px;
  bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 80;
}

.toast {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--graphite-900);
  color: #fff;
  padding: 11px 16px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  max-width: 360px;
  font-size: var(--text-base);
  animation: toast-in var(--duration-base) ease;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}

.toast.error {
  background: var(--danger-600);
}

.toast.ok {
  background: var(--success-600);
}

.spinner {
  padding: var(--space-5);
  color: var(--color-text-muted);
  display: flex;
  align-items: center;
  gap: 10px;
}

.spinner::before {
  content: '';
  width: 16px;
  height: 16px;
  border-radius: var(--radius-full);
  border: 2px solid var(--color-border-strong);
  border-top-color: var(--rose-600);
  animation: btn-spin 0.7s linear infinite;
}

/* =====================================================================
   Tooltip (CSS only; `title` attribute stays for screen readers)
   ===================================================================== */
[data-tip] {
  position: relative;
}

[data-tip]::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%) translateY(2px);
  background: var(--graphite-900);
  color: #fff;
  font-size: 11.5px;
  font-weight: 500;
  padding: 5px 8px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition:
    opacity var(--duration-fast) ease,
    transform var(--duration-fast) ease;
  z-index: 60;
}

[data-tip]:hover::after,
[data-tip]:focus-visible::after {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* =====================================================================
   Dropdown popover (search / create / notifications / user menu)
   ===================================================================== */
.dropdown-wrap {
  position: relative;
}

.dropdown-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 260px;
  max-width: 380px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  padding: var(--space-2);
  z-index: 40;
  animation: pop-in var(--duration-fast) ease;
}

.dropdown-panel.wide {
  min-width: 340px;
}

@keyframes pop-in {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
}

.dropdown-panel .dropdown-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-faint);
  padding: 6px 8px 2px;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  border: none;
  background: none;
  cursor: pointer;
  text-align: left;
  font-size: var(--text-base);
  color: var(--color-text);
  text-decoration: none;
}

.dropdown-item:hover,
.dropdown-item:focus-visible {
  background: var(--color-surface-sunken);
}

.dropdown-item .icon-wrap {
  flex: none;
  width: 26px;
  height: 26px;
  border-radius: var(--radius-sm);
  display: grid;
  place-items: center;
  background: var(--rose-50);
  color: var(--rose-700);
}

.dropdown-item .body {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}

.dropdown-item .primary {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dropdown-item .secondary {
  font-size: 11.5px;
  color: var(--color-text-faint);
}

.dropdown-item.unread .primary::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: var(--radius-full);
  background: var(--info-600);
  margin-right: 6px;
}

.dropdown-divider {
  height: 1px;
  background: var(--color-border);
  margin: 6px 2px;
}

.dropdown-empty {
  padding: var(--space-4);
  text-align: center;
  color: var(--color-text-faint);
  font-size: var(--text-sm);
}

.dropdown-foot {
  padding: 6px 8px 2px;
  border-top: 1px solid var(--color-border);
  margin-top: 4px;
}

/* =====================================================================
   Native <dialog> — command palette, confirm/prompt
   ===================================================================== */
dialog.vm-dialog {
  border: none;
  border-radius: var(--radius-lg);
  padding: 0;
  box-shadow: var(--shadow-lg);
  width: min(520px, 92vw);
  color: var(--color-text);
  background: var(--color-surface);
}

dialog.vm-dialog::backdrop {
  background: rgba(8, 16, 32, 0.5);
}

dialog.vm-dialog .dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--color-border);
}

dialog.vm-dialog .dialog-head h2 {
  margin: 0;
  font-size: var(--text-lg);
}

dialog.vm-dialog .dialog-body {
  padding: var(--space-5);
  max-height: 60vh;
  overflow-y: auto;
}

dialog.vm-dialog .dialog-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--color-border);
}

dialog.vm-dialog.command {
  width: min(560px, 92vw);
  align-self: flex-start;
  margin-top: 10vh;
}

dialog.vm-dialog.command .dialog-body {
  padding: 0;
  max-height: 55vh;
}

.command-input-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--color-border);
  color: var(--color-text-faint);
}

.command-input-wrap input {
  flex: 1;
  border: none;
  outline: none;
  font-size: var(--text-lg);
  background: none;
  color: var(--color-text);
}

.command-results {
  padding: var(--space-2);
  overflow-y: auto;
  max-height: calc(55vh - 60px);
}

.command-results .dropdown-item.is-active {
  background: var(--rose-50);
}

/* =====================================================================
   Drawer (slide-in panel; mobile nav, context panels)
   ===================================================================== */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(8, 16, 32, 0.45);
  z-index: 70;
  animation: fade-in var(--duration-base) ease;
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
}

.drawer {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  width: min(300px, 84vw);
  background: var(--graphite-900);
  color: var(--color-text-inverse);
  z-index: 71;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  padding: var(--space-4) var(--space-3);
  animation: drawer-in var(--duration-base) ease;
  overflow-y: auto;
}

.drawer.right {
  left: auto;
  right: 0;
  background: var(--color-surface);
  color: var(--color-text);
  width: min(380px, 92vw);
}

@keyframes drawer-in {
  from {
    transform: translateX(-100%);
  }
}

.drawer.right {
  animation-name: drawer-in-right;
}

@keyframes drawer-in-right {
  from {
    transform: translateX(100%);
  }
}

.drawer-close {
  align-self: flex-end;
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
}

.drawer-close:hover {
  background: rgba(127, 127, 127, 0.15);
}

/* =====================================================================
   Account 360 / signature workspace layouts
   ===================================================================== */
.entity-header {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  margin-bottom: var(--space-4);
  box-shadow: var(--shadow-xs);
}

.entity-header-top {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
}

.entity-identity {
  display: flex;
  gap: var(--space-3);
  align-items: flex-start;
  min-width: 0;
}

.entity-icon {
  flex: none;
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  background: linear-gradient(150deg, var(--graphite-700), var(--rose-600));
  color: #ffffff;
  display: grid;
  place-items: center;
}

.entity-title {
  min-width: 0;
}

.entity-title h1 {
  margin: 0;
  font-size: var(--text-2xl);
  font-weight: 650;
  overflow-wrap: anywhere;
}

.entity-title .meta {
  margin-top: 4px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  color: var(--color-text-muted);
  font-size: var(--text-sm);
}

.entity-facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: var(--space-3);
  margin-top: var(--space-4);
  padding-top: var(--space-4);
  border-top: 1px solid var(--color-border);
}

.entity-fact .label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-faint);
  font-weight: 650;
}

.entity-fact .value {
  margin-top: 2px;
  font-weight: 600;
  font-size: var(--text-base);
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(260px, 1fr);
  gap: var(--space-4);
  align-items: start;
}

.workspace-main,
.workspace-side {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  min-width: 0;
}

.mini-list {
  display: flex;
  flex-direction: column;
}

.mini-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 2px;
  border-bottom: 1px solid var(--color-border);
  font-size: var(--text-base);
}

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

.mini-row .name {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mini-row .meta {
  color: var(--color-text-faint);
  font-size: 12px;
}

.timeline {
  display: flex;
  flex-direction: column;
}

.timeline-item {
  position: relative;
  padding: 0 0 var(--space-4) 26px;
  border-left: 2px solid var(--color-border);
  margin-left: 6px;
}

.timeline-item:last-child {
  border-color: transparent;
  padding-bottom: 0;
}

.timeline-item::before {
  content: '';
  position: absolute;
  left: -6.5px;
  top: 2px;
  width: 11px;
  height: 11px;
  border-radius: var(--radius-full);
  background: var(--rose-600);
  border: 2px solid var(--color-surface);
}

.timeline-item .when {
  font-size: 11.5px;
  color: var(--color-text-faint);
}

.timeline-item .what {
  font-weight: 600;
  margin-top: 1px;
}

.timeline-item .detail {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-top: 1px;
}

/* =====================================================================
   Intelligence review workspace (3-column)
   ===================================================================== */
.review-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr) minmax(240px, 1fr);
  gap: var(--space-4);
  align-items: start;
}

.review-col {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  min-width: 0;
}

.field-diff {
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  margin-bottom: 6px;
}

.field-diff.changed {
  background: var(--warning-50);
  box-shadow: inset 3px 0 0 var(--warning-600);
}

.field-diff .field-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-faint);
  font-weight: 650;
  display: flex;
  align-items: center;
  gap: 6px;
}

.field-diff-values {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
}

.field-diff-old,
.field-diff-new {
  border-radius: var(--radius-sm);
  padding: 6px 8px;
}

.field-diff-old {
  background: var(--danger-50);
}

.field-diff-new {
  background: var(--success-50);
}

.field-diff-old .content-block {
  text-decoration: line-through;
  color: var(--danger-700);
  opacity: 0.85;
}

.field-diff-new .content-block {
  color: var(--success-700);
}

.diff-tag {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 3px;
  color: var(--color-text-faint);
}

/*
 * `--color-text-faint` is calibrated against the default page background,
 * not the `--danger-50`/`--success-50` tints `.field-diff-old`/
 * `.field-diff-new` sit on (Phase 2E.2 manual+e2e accessibility finding —
 * the same class of "faint text on a non-default background" defect
 * CLAUDE.md already documents for `--color-surface-sunken`). Use the same
 * explicit, already-contrast-checked colors their own content text uses.
 */
.field-diff-old .diff-tag {
  color: var(--danger-700);
}

.field-diff-new .diff-tag {
  color: var(--success-700);
}

@media (max-width: 640px) {
  .field-diff-values {
    grid-template-columns: 1fr;
  }
}

/* =====================================================================
   Responsive
   ===================================================================== */
@media (max-width: 1080px) {
  .review-grid {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }

  .review-grid > .review-col:last-child {
    grid-column: 1 / -1;
  }
}

@media (max-width: 980px) {
  .workspace-grid {
    /* A bare `1fr` track's automatic minimum size is `auto` (content-based),
       not 0 — so a card whose content (e.g. a long unbreakable string) is
       wider than the viewport keeps the track, and the whole grid, that
       wide instead of shrinking to fit. `minmax(0, 1fr)` is required here,
       not just a single-column convenience (ADR-0093 correction). */
    grid-template-columns: minmax(0, 1fr);
  }
}

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

  .sidebar {
    display: none;
  }

  .menu-toggle {
    display: inline-flex;
  }

  .topbar-search span.hint-text,
  .topbar-search kbd {
    display: none;
  }

  .topbar-search {
    padding: 7px;
    justify-content: center;
    width: auto;
    min-width: 34px;
    flex: none;
  }

  .user-trigger .who {
    display: none;
  }

  .user-trigger {
    padding: 5px;
  }

  .btn-label {
    display: none;
  }

  .topbar {
    gap: var(--space-2);
  }

  .topbar-actions {
    gap: 4px;
  }

  main.page {
    padding: var(--space-4);
  }

  .grid.cols-2,
  .grid.cols-3,
  .grid.cols-4,
  .form-row,
  .review-grid {
    grid-template-columns: 1fr;
  }

  .review-grid > .review-col:last-child {
    grid-column: auto;
  }

  .topbar {
    padding: 10px var(--space-3);
  }

  .entity-header-top {
    flex-direction: column;
  }
}

@media (max-width: 520px) {
  .dropdown-panel {
    position: fixed;
    left: var(--space-3);
    right: var(--space-3);
    top: 60px;
    max-width: none;
  }
}

/* =====================================================================
   Paginator (Phase 1C.1, item 6)
   ===================================================================== */
.paginator {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3) 2px 0;
  color: var(--color-text-muted);
  font-size: var(--text-sm);
}

.paginator .actions {
  display: flex;
  gap: 8px;
}

/* =====================================================================
   Reduced motion (Phase 1C.1, item 4): the entrance animations on drawers,
   dropdowns, and toasts are purely decorative — disabling them changes
   nothing about what the element does, only how abruptly it appears.
   Functional motion (the loading spinners in .btn.is-loading/.spinner,
   which communicate an in-progress state rather than decorate an entrance)
   is intentionally left alone.
   ===================================================================== */
@media (prefers-reduced-motion: reduce) {
  .drawer,
  .drawer.right,
  .drawer-backdrop,
  .dropdown-panel,
  .toast {
    animation: none;
  }
}

/* =====================================================================
   Lead 360 (Phase 2A, item 11) — a signature intelligence-dossier layout,
   deliberately not a generic CRM record page: a calm identity header,
   spacious two-column workspace, and a "why this lead" section leading
   the page rather than a raw field grid.
   ===================================================================== */
.lead-identity {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-5);
  padding: var(--space-5) 0 var(--space-4);
  border-bottom: 1px solid var(--color-border);
  margin-bottom: var(--space-5);
}

/* Status hero (Phase 2A.2, item 7): the eligibility status and its
   synthesized reason lead the page, ahead of the person's name — the user
   should understand where this Lead stands before reading anything else. */
.lead-status-hero {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
  flex-wrap: wrap;
  margin-bottom: 6px;
}

.lead-status-hero .badge {
  font-size: var(--text-base);
  font-weight: 700;
  letter-spacing: 0.03em;
  padding: 4px 12px;
}

.lead-status-reason {
  color: var(--color-text-muted);
  font-size: var(--text-sm);
}

.lead-identity-main h1 {
  margin: 0 0 4px;
  font-size: var(--text-2xl);
}

.lead-identity-sub {
  margin: 0 0 var(--space-3);
  color: var(--color-text-muted);
}

.lead-identity-badges {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.lead-identity-meta {
  min-width: 220px;
}

.lead-identity .winston-trigger {
  align-self: flex-start;
}

.lead-workspace-grid {
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(280px, 2fr);
  gap: var(--space-5);
  align-items: start;
}

.lead-workspace-col {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  min-width: 0;
}

.section-label {
  margin: var(--space-4) 0 var(--space-2);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-faint);
}

.section-label:first-child {
  margin-top: 0;
}

.why-this-lead-text {
  white-space: pre-wrap;
}

.reason-list,
.contact-method-list,
.research-mini-list,
.task-mini-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.contact-method-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}

.reason-list {
  padding-left: var(--space-4);
  list-style: disc;
}

.muted-note {
  color: var(--color-text-muted);
  font-size: var(--text-sm);
}

/* Leads list (item 6): the lead's identity dominates its row; stage, owner,
   and last-touch demote to a secondary line instead of three more columns
   competing with eligibility/qualification/distributor for attention. */
.lead-row-identity {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.lead-row-meta {
  color: var(--color-text-faint);
  font-size: 12px;
}

/* =====================================================================
   Today (Phase 2A.2, item 4) — "what needs my attention", not a reporting
   dashboard: the attention feed and Winston's brief lead the page; full
   metrics move here, visually quieter, as secondary context.
   ===================================================================== */
.today-testdata-note {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0 0 var(--space-4);
}

.today-testdata-note svg.icon {
  flex: none;
  color: var(--warning-700);
}

.workspace-snapshot .stat {
  box-shadow: none;
  padding: var(--space-3);
}

.workspace-snapshot .stat .value {
  font-size: 20px;
  margin-top: 2px;
}

.workspace-snapshot .stat .label {
  font-size: 10.5px;
}

.workspace-snapshot .stat .hint {
  font-size: 11px;
}

.winston-brief {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.winston-brief-head {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--rose-700);
}

.winston-brief-head svg.icon {
  color: var(--rose-600);
}

.winston-brief-headline {
  margin: 0;
  font-size: var(--text-md);
  font-weight: 600;
}

.winston-brief-list {
  margin: 0;
  padding-left: var(--space-4);
  list-style: disc;
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.winston-brief-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: var(--space-2);
}

/* Reusable append-oriented activity timeline (item 9) — Lead 360 today,
   reusable on Account/Person detail without any additional CSS. */
.activity-timeline {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  border-left: 2px solid var(--color-border);
  padding-left: var(--space-4);
}

.activity-timeline li {
  position: relative;
}

.activity-timeline li::before {
  content: '';
  position: absolute;
  left: calc(-1 * var(--space-4) - 5px);
  top: 4px;
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  background: var(--rose-500);
}

.activity-time {
  display: block;
  font-size: 11px;
  color: var(--color-text-faint);
}

.activity-summary {
  display: block;
  font-size: var(--text-base);
}

.chip {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  border-radius: var(--radius-full);
  border: 1px solid var(--color-border-strong);
  background: var(--color-surface);
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
  color: var(--color-text);
}

.chip:hover {
  border-color: var(--rose-500);
  color: var(--rose-700);
}

.icon-btn.tiny {
  width: 22px;
  height: 22px;
  padding: 0;
}

/* =====================================================================
   Winston — the SANJI Intelligence Agent (Phase 2A, items 13-20, ADR-0041)
   A premium, deeply-integrated right-hand workspace — deliberately not a
   floating chat bubble: a dedicated panel with a header identity, a
   context chip showing exactly what record Winston currently has (never
   silently broadened), quick contextual actions, structured response
   cards (answer/sources/confidence/why/proposed action), and a composer.
   ===================================================================== */
.winston-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(21, 15, 17, 0.28);
  display: flex;
  justify-content: flex-end;
  z-index: 70;
  animation: fade-in var(--duration-base) ease;
}

.winston-panel {
  width: min(420px, 100vw);
  height: 100vh;
  background: var(--color-surface);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  padding: var(--space-4);
  gap: var(--space-3);
  animation: drawer-in-right var(--duration-base) ease;
}

.winston-header {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--color-border);
}

.winston-title {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}

.winston-title strong {
  font-size: var(--text-md);
  color: var(--rose-700);
}

.winston-title span {
  font-size: 11px;
  color: var(--color-text-faint);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.winston-context-chip {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  background: var(--rose-50);
  border: 1px solid var(--rose-100);
  font-size: var(--text-sm);
}

.winston-context-value {
  flex: 1;
  font-weight: 600;
  color: var(--rose-700);
}

.winston-block-label {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-faint);
  margin-bottom: 4px;
}

.winston-quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.winston-conversation {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding-right: 2px;
}

.winston-empty {
  color: var(--color-text-muted);
  font-size: var(--text-base);
  padding: var(--space-4) 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.winston-empty p {
  margin: 0;
}

.winston-empty-title {
  font-size: var(--text-lg);
  font-weight: 650;
  color: var(--color-text);
}

.winston-message {
  border-radius: var(--radius-md);
  padding: var(--space-3);
  font-size: var(--text-base);
}

.winston-message p {
  margin: 0;
}

.winston-message.user {
  align-self: flex-end;
  background: var(--color-surface-sunken);
  max-width: 85%;
}

.winston-message.assistant {
  background: var(--rose-50);
  border: 1px solid var(--rose-100);
}

.winston-message.assistant.generating {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--color-text-muted);
}

.winston-typing::after {
  content: '…';
}

.winston-answer {
  margin-bottom: var(--space-2);
}

.winston-sources ul {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.winston-sources li {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--text-sm);
}

.winston-why {
  margin-top: var(--space-2);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

.winston-confidence {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: var(--space-2);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

.winston-proposal {
  margin-top: var(--space-3);
  padding: var(--space-3);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  border: 1px solid var(--warning-600);
}

.winston-proposal.decided {
  border-color: var(--color-border);
}

.winston-proposal p {
  margin: 0 0 var(--space-2);
}

.winston-proposal-actions {
  display: flex;
  gap: var(--space-2);
}

.winston-composer {
  display: flex;
  align-items: flex-end;
  gap: var(--space-2);
  padding-top: var(--space-3);
  border-top: 1px solid var(--color-border);
}

.winston-composer-input {
  flex: 1;
  resize: none;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border-strong);
  padding: var(--space-2) var(--space-3);
  font: inherit;
  font-size: var(--text-base);
}

.winston-composer-input:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
  border-color: var(--rose-500);
}

@media (prefers-reduced-motion: reduce) {
  .winston-backdrop,
  .winston-panel {
    animation: none;
  }
}

@media (max-width: 640px) {
  .winston-panel {
    width: 100vw;
  }

  .lead-workspace-grid {
    grid-template-columns: 1fr;
  }

  .lead-identity {
    flex-direction: column;
  }
}
