/* ═══════════════════════════════════════════════════════════════════════════
   Placement AI — design system
   Cool-neutral palette (Untitled-UI-derived), Inter, 8pt grid, 13px base.
   One accent (indigo). Bordered badges. Subtle depth. Dense, calm, precise.
   ═══════════════════════════════════════════════════════════════════════════ */

:root {
  /* neutrals */
  --gray-25: #FCFCFD; --gray-50: #F9FAFB; --gray-100: #F2F4F7; --gray-200: #EAECF0;
  --gray-300: #D0D5DD; --gray-400: #98A2B3; --gray-500: #667085; --gray-600: #475467;
  --gray-700: #344054; --gray-800: #182230; --gray-900: #101828; --gray-950: #0C111D;

  /* brand */
  --brand-50: #EEF4FF; --brand-100: #E0EAFF; --brand-500: #6172F3; --brand-600: #444CE7;
  --brand-700: #3538CD; --brand-ring: rgba(68, 76, 231, .18);

  /* semantic (text / bg / border triads) */
  --green-t: #067647;  --green-b: #ECFDF3;  --green-br: #ABEFC6;
  --amber-t: #B54708;  --amber-b: #FFFAEB;  --amber-br: #FEDF89;
  --red-t: #B42318;    --red-b: #FEF3F2;    --red-br: #FECDCA;
  --blue-t: #175CD3;   --blue-b: #EFF8FF;   --blue-br: #B2DDFF;
  --indigo-t: #3538CD; --indigo-b: #EEF4FF; --indigo-br: #C7D7FE;

  /* aliases used across the app */
  --primary: var(--brand-600);
  --content-bg: #F7F8FA;
  --card: #FFFFFF;
  --border: var(--gray-200);
  --border-strong: var(--gray-300);
  --ink: var(--gray-900);
  --body: var(--gray-700);
  --sub: var(--gray-500);
  --faint: var(--gray-400);

  --sidebar: #0C111D;
  --sidebar-text: #94A3B8;

  --r-sm: 6px; --r-md: 8px; --r-lg: 10px; --r-xl: 12px;

  --sh-xs: 0 1px 2px rgba(16, 24, 40, .05);
  --sh-sm: 0 1px 3px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .04);
  --sh-md: 0 4px 8px -2px rgba(16, 24, 40, .1), 0 2px 4px -2px rgba(16, 24, 40, .06);
  --sh-xl: 0 20px 24px -4px rgba(16, 24, 40, .1), 0 8px 8px -4px rgba(16, 24, 40, .04);

  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", "Cascadia Code", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font); color: var(--body); background: var(--content-bg);
  font-size: 13px; line-height: 1.5;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
  font-feature-settings: "cv05" 1;
}
a { color: var(--brand-600); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
button { font-family: var(--font); cursor: pointer; }
::selection { background: var(--brand-100); }
b { color: var(--ink); font-weight: 600; }

/* icons */
.ic { width: 16px; height: 16px; flex: none; vertical-align: -3px; }
.ic.sm { width: 14px; height: 14px; }
.ic.lg { width: 18px; height: 18px; }

/* focus */
:focus { outline: none; }
:focus-visible { box-shadow: 0 0 0 3px var(--brand-ring); border-radius: var(--r-sm); }
input:focus, textarea:focus, select:focus {
  border-color: var(--brand-500) !important; box-shadow: 0 0 0 3px var(--brand-ring);
}

/* ── Layout shell ─────────────────────────────────────────────────────────── */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 232px; background: var(--sidebar); color: var(--sidebar-text); flex-shrink: 0;
  position: fixed; top: 0; bottom: 0; left: 0; display: flex; flex-direction: column;
  padding: 16px 12px 14px; z-index: 40;
}
.logo { display: flex; align-items: center; gap: 10px; padding: 2px 8px 16px; }
.logo .mark {
  width: 30px; height: 30px; border-radius: 8px; flex: none;
  background: linear-gradient(135deg, #6172F3 0%, #444CE7 60%, #3538CD 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .22), 0 1px 2px rgba(0, 0, 0, .4);
  color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 14px; letter-spacing: -.02em;
}
.logo .name { color: #F8FAFC; font-weight: 600; font-size: 13.5px; line-height: 1.2; letter-spacing: -.01em; }
.logo .sub { color: #566175; font-size: 11px; margin-top: 1px; }

.nav-label {
  font-size: 10.5px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase;
  color: #475569; padding: 10px 10px 6px;
}
.nav { display: flex; flex-direction: column; gap: 1px; }
.nav a {
  display: flex; align-items: center; gap: 9px; padding: 6px 10px; border-radius: 6px;
  color: var(--sidebar-text); font-weight: 500; font-size: 13px; position: relative;
  transition: background .1s, color .1s; text-decoration: none;
}
.nav a:hover { background: rgba(255, 255, 255, .04); color: #E2E8F0; text-decoration: none; }
.nav a.active { background: rgba(255, 255, 255, .07); color: #FFFFFF; }
.nav a.active::before {
  content: ""; position: absolute; left: -12px; top: 6px; bottom: 6px; width: 2.5px;
  border-radius: 0 2px 2px 0; background: var(--brand-500);
}
.nav a .ic { opacity: .75; }
.nav a.active .ic { opacity: 1; }
.nav .badge {
  margin-left: auto; background: rgba(239, 68, 68, .16); color: #FCA5A5;
  border: 1px solid rgba(239, 68, 68, .25);
  font-size: 10.5px; font-weight: 600; border-radius: 999px; padding: 0 6px;
  min-width: 18px; height: 17px; line-height: 15px; text-align: center;
}
.sidebar .foot {
  margin-top: auto; padding: 10px 8px 0; border-top: 1px solid rgba(255, 255, 255, .06);
  font-size: 11px; line-height: 1.7; color: #566175;
}
.sidebar .foot .pill {
  display: inline-flex; align-items: center; gap: 5px; margin: 2px 6px 2px 0;
}
.sidebar .foot .pill .dot { width: 5px; height: 5px; border-radius: 50%; background: #3F4A5F; }
.sidebar .foot .pill .dot.ok { background: #12B76A; }

.main { margin-left: 232px; flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 12px; height: 56px; padding: 0 28px;
  background: rgba(255, 255, 255, .82); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 30;
}
.topbar h1 { font-size: 14.5px; margin: 0; font-weight: 600; color: var(--ink); letter-spacing: -.01em; flex-shrink: 0; }
.topbar h1 .crumb { color: var(--faint); font-weight: 500; }
.searchwrap { margin-left: auto; position: relative; }
.searchwrap .ic {
  position: absolute; left: 9px; top: 50%; transform: translateY(-50%); color: var(--faint);
}
.topbar .search {
  background: var(--gray-50); border: 1px solid var(--border); border-radius: var(--r-sm);
  padding: 6px 10px 6px 30px; width: 260px; font-size: 12.5px; color: var(--ink);
  font-family: var(--font); transition: border-color .12s, box-shadow .12s, background .12s;
}
.topbar .search::placeholder { color: var(--faint); }
.topbar .search:focus { background: #fff; }
.live {
  display: inline-flex; align-items: center; gap: 6px; font-weight: 500; color: var(--sub);
  font-size: 12px; border: 1px solid var(--border); border-radius: 999px; padding: 3px 10px 3px 8px;
  background: #fff;
}
.live .pip { width: 7px; height: 7px; border-radius: 50%; background: var(--gray-300); }
.live.on .pip { background: #12B76A; box-shadow: 0 0 0 3px rgba(18, 183, 106, .15); }
.live.on { color: var(--gray-600); }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; flex: none;
  background: linear-gradient(135deg, #E0EAFF, #C7D7FE); color: var(--brand-700);
  display: grid; place-items: center; font-weight: 600; font-size: 11px;
  border: 1px solid var(--indigo-br);
}
.content { padding: 20px 28px 48px; }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--border-strong); background: #fff; color: var(--gray-700);
  border-radius: var(--r-sm); padding: 0 12px; height: 32px; font-weight: 500; font-size: 13px;
  box-shadow: var(--sh-xs); transition: background .1s, border-color .1s, box-shadow .1s;
  white-space: nowrap; text-decoration: none;
}
.btn:hover { background: var(--gray-50); color: var(--ink); text-decoration: none; }
.btn:active { box-shadow: none; }
.btn.primary { background: var(--brand-600); color: #fff; border-color: var(--brand-600); }
.btn.primary:hover { background: var(--brand-700); border-color: var(--brand-700); }
.btn.green { background: #079455; color: #fff; border-color: #079455; }
.btn.green:hover { background: #067647; }
.btn.red, .btn.danger { background: #fff; color: var(--red-t); border-color: var(--red-br); }
.btn.red:hover, .btn.danger:hover { background: var(--red-b); border-color: #F97066; }
.btn.sm { height: 26px; padding: 0 9px; font-size: 12px; gap: 5px; box-shadow: none; }
.btn.ghost { border-color: transparent; box-shadow: none; background: transparent; }
.btn.ghost:hover { background: var(--gray-100); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn .ic { width: 14px; height: 14px; }

/* ── Chips / badges ───────────────────────────────────────────────────────── */
.chip {
  display: inline-flex; align-items: center; gap: 5px; padding: 1px 8px; border-radius: 999px;
  font-size: 11.5px; font-weight: 500; white-space: nowrap; border: 1px solid transparent;
  line-height: 18px;
}
.chip.amber { color: var(--amber-t); background: var(--amber-b); border-color: var(--amber-br); }
.chip.green { color: var(--green-t); background: var(--green-b); border-color: var(--green-br); }
.chip.red { color: var(--red-t); background: var(--red-b); border-color: var(--red-br); }
.chip.blue { color: var(--blue-t); background: var(--blue-b); border-color: var(--blue-br); }
.chip.indigo { color: var(--indigo-t); background: var(--indigo-b); border-color: var(--indigo-br); }
.chip.gray { color: var(--gray-700); background: var(--gray-50); border-color: var(--gray-200); }

.tag {
  font-size: 10px; font-weight: 600; letter-spacing: .06em; padding: 2px 7px;
  border-radius: 4px; text-transform: uppercase; border: 1px solid transparent;
}
.tag.gate { color: var(--amber-t); background: var(--amber-b); border-color: var(--amber-br); }
.tag.urgent { color: var(--red-t); background: var(--red-b); border-color: var(--red-br); }

/* ── Cards ────────────────────────────────────────────────────────────────── */
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: 16px 18px; box-shadow: var(--sh-xs);
}
.card h3 {
  margin: 0 0 12px; font-size: 11px; letter-spacing: .07em; color: var(--sub);
  text-transform: uppercase; font-weight: 600;
}
.muted { color: var(--sub); }
.small { font-size: 12px; }
.num { font-variant-numeric: tabular-nums; }

/* ── Pipeline board ───────────────────────────────────────────────────────── */
.board { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 12px; }
.column {
  flex: 1; min-width: 236px; background: var(--gray-100); border-radius: var(--r-xl);
  padding: 10px; border: 1px solid var(--gray-200);
}
.column .col-head {
  display: flex; align-items: center; gap: 7px; font-size: 11px; font-weight: 600;
  letter-spacing: .07em; color: var(--gray-600); text-transform: uppercase; margin: 2px 4px 10px;
}
.column .count {
  background: #fff; color: var(--gray-600); border: 1px solid var(--gray-200);
  border-radius: 999px; padding: 0 7px; font-size: 10.5px; line-height: 16px; font-weight: 600;
}
.deal-card {
  background: #fff; border: 1px solid var(--gray-200); border-radius: var(--r-md); padding: 12px;
  margin-bottom: 8px; cursor: pointer; box-shadow: var(--sh-xs);
  transition: box-shadow .12s, border-color .12s, transform .12s;
}
.deal-card:hover { border-color: var(--gray-300); box-shadow: var(--sh-md); transform: translateY(-1px); }
.deal-card .dc-title { font-weight: 600; font-size: 13px; color: var(--ink); letter-spacing: -.01em; }
.deal-card .dc-sub { color: var(--sub); font-size: 12px; margin: 1px 0 9px; }
.deal-card .chip { white-space: normal; line-height: 1.45; max-width: 100%; }
.deal-card .dc-foot {
  display: flex; align-items: center; justify-content: space-between; margin-top: 10px;
  color: var(--faint); font-size: 11px; font-variant-numeric: tabular-nums;
}
.ofac-dot { width: 8px; height: 8px; border-radius: 50%; }
.ofac-GREEN { background: #12B76A; } .ofac-YELLOW { background: #F79009; }
.ofac-ORANGE { background: #FB6514; } .ofac-RED { background: #F04438; } .ofac-BLACK { background: #101828; }

/* ── Deal room ────────────────────────────────────────────────────────────── */
.dealroom { display: grid; grid-template-columns: 232px 1fr 336px; gap: 16px; align-items: start; }
.deal-header {
  grid-column: 1 / -1; background: #fff; border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 16px 20px; box-shadow: var(--sh-xs);
}
.deal-header .dh-title { font-size: 17px; font-weight: 600; color: var(--ink); letter-spacing: -.015em; }
.deal-header .dh-sub { color: var(--sub); margin: 3px 0 12px; font-size: 12.5px; }
.deal-header .chips { display: flex; gap: 6px; flex-wrap: wrap; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li {
  display: flex; gap: 10px; align-items: flex-start; padding: 0 0 2px; font-size: 12.5px;
  position: relative; min-height: 26px; color: var(--sub);
}
.timeline li::before {
  content: ""; position: absolute; left: 7px; top: 18px; bottom: -2px; width: 1.5px;
  background: var(--gray-200);
}
.timeline li:last-child::before { display: none; }
.timeline .mk {
  width: 15px; height: 15px; border-radius: 50%; flex-shrink: 0; margin-top: 2px;
  border: 1.5px solid var(--gray-300); background: #fff; position: relative; z-index: 1;
  display: grid; place-items: center;
}
.timeline .mk svg { width: 9px; height: 9px; }
.tl-done { color: var(--gray-600); }
.tl-done .mk { background: #12B76A; border-color: #12B76A; color: #fff; }
.tl-current { color: var(--brand-700); font-weight: 600; }
.tl-current .mk { border-color: var(--brand-600); }
.tl-current .mk::after { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--brand-600); }
.tl-gate { color: var(--amber-t); font-weight: 600; }
.tl-gate .mk { border-color: #F79009; background: var(--amber-b); }
.tl-gate .mk::after { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #F79009; }
.tl-blocked { color: var(--red-t); font-weight: 600; }
.tl-blocked .mk { border-color: #F04438; background: #F04438; color: #fff; }
.tl-pending .mk { border-style: dashed; }

.tabs { display: flex; gap: 2px; margin-bottom: 14px; flex-wrap: wrap; border-bottom: 1px solid var(--border); }
.tab {
  padding: 7px 12px 9px; font-weight: 500; font-size: 13px; color: var(--sub);
  background: transparent; border: none; border-bottom: 2px solid transparent;
  margin-bottom: -1px; transition: color .1s; display: inline-flex; align-items: center; gap: 6px;
}
.tab.active { color: var(--brand-700); border-bottom-color: var(--brand-600); font-weight: 600; }
.tab:hover:not(.active) { color: var(--ink); }

.grid2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px; }
.grid2 > * { min-width: 0; }
.kv { display: grid; grid-template-columns: 118px 1fr; gap: 7px 14px; font-size: 12.5px; align-items: start; }
.kv .k { color: var(--sub); }
.kv .v {
  font-weight: 500; color: var(--ink);
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}

/* waiting-on-you panel */
.waiting { border-left: 3px solid #F79009; }
.waiting h3 { color: var(--amber-t); display: flex; align-items: center; gap: 6px; }
.waiting .g-title { font-weight: 600; font-size: 14.5px; color: var(--ink); letter-spacing: -.01em; }

.fail-card { border-left: 3px solid #F04438; }
.fail-card h3 { color: var(--red-t); display: flex; align-items: center; gap: 6px; }

.mini-feed { list-style: none; margin: 0; padding: 0; }
.mini-feed li {
  display: flex; gap: 10px; padding: 6px 0; font-size: 12px; border-bottom: 1px solid var(--gray-100);
  align-items: baseline;
}
.mini-feed li:last-child { border-bottom: none; }
.mini-feed .t { color: var(--faint); flex-shrink: 0; width: 40px; font-variant-numeric: tabular-nums; font-size: 11px; }
.mini-feed .bul { color: var(--brand-500); flex-shrink: 0; }

/* ── Advanced activity trace (the engine log the console prints) ──────────── */
.adv-log { display: flex; flex-direction: column; }
.adv-row {
  display: flex; gap: 8px; align-items: flex-start; padding: 6px 4px; font-size: 12px;
  border-bottom: 1px solid var(--gray-100);
}
.adv-row:last-child { border-bottom: none; }
.adv-row.bad { background: var(--red-bg, #fef2f2); }
.adv-row .chip { flex-shrink: 0; }
.adv-t {
  color: var(--faint); flex-shrink: 0; width: 96px; font-size: 11px;
  font-variant-numeric: tabular-nums; padding-top: 2px;
}
.adv-src {
  flex-shrink: 0; width: 96px; font-weight: 600; color: var(--sub);
  font-size: 11px; padding-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.adv-main { flex: 1; min-width: 0; }
.adv-title { word-break: break-word; }
.adv-ref { flex-shrink: 0; color: var(--brand-600); font-size: 11px; padding-top: 2px; }
.adv-det summary {
  cursor: pointer; color: var(--faint); font-size: 11px; margin-top: 3px; user-select: none;
}
.adv-det summary:hover { color: var(--brand-600); }
.adv-det pre {
  margin: 6px 0 2px; padding: 8px 10px; background: var(--gray-25); border: 1px solid var(--border);
  border-radius: var(--r-sm, 6px); font-size: 11px; line-height: 1.5; max-height: 320px;
  overflow: auto; white-space: pre-wrap; word-break: break-word;
}

/* ── CLI log tail (the real uvicorn console output) ───────────────────────── */
.cli-log {
  margin: 0; padding: 12px 14px; background: #0d1117; color: #c9d1d9;
  border: 1px solid #1f2630; border-radius: var(--r-md);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11.5px; line-height: 1.55; height: 60vh; overflow: auto;
  white-space: pre-wrap; word-break: break-word; overflow-wrap: anywhere;
}
.cli-line { display: block; }
/* fixed gutter so the message column lines up the way the console does */
.cli-lvl { color: #6e7681; display: inline-block; min-width: 76px; }
.cli-txt { color: #c9d1d9; }
.cli-line.warn .cli-lvl, .cli-line.warn .cli-txt { color: #d29922; }
.cli-line.err .cli-lvl, .cli-line.err .cli-txt { color: #ff7b72; }
.cli-log .muted { color: #6e7681; }

/* ── Tables ───────────────────────────────────────────────────────────────── */
table.tbl { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.tbl thead th {
  text-align: left; color: var(--sub); font-size: 11px; letter-spacing: .05em; font-weight: 600;
  text-transform: uppercase; padding: 8px 12px; border-bottom: 1px solid var(--border);
  background: var(--gray-25); white-space: nowrap;
}
table.tbl thead th:first-child { border-top-left-radius: var(--r-md); }
table.tbl thead th:last-child { border-top-right-radius: var(--r-md); }
table.tbl tbody td { padding: 10px 12px; border-bottom: 1px solid var(--gray-100); vertical-align: top; color: var(--body); }
table.tbl tbody tr:last-child td { border-bottom: none; }
table.tbl tbody tr:hover { background: var(--gray-25); }
table.tbl .num, table.tbl td:has(> .money) { font-variant-numeric: tabular-nums; }
.row-actions { opacity: 0; transition: opacity .12s; display: flex; gap: 6px; }
tr:hover .row-actions { opacity: 1; }

/* ── Fields ───────────────────────────────────────────────────────────────── */
.field-row {
  display: grid; grid-template-columns: 240px 1fr; gap: 10px; align-items: center;
  padding: 7px 0; border-bottom: 1px solid var(--gray-100);
}
.field-row:last-child { border-bottom: none; }
.field-row .fl { font-size: 12.5px; color: var(--gray-600); display: flex; gap: 7px; align-items: flex-start; }
.star {
  border: none; background: none; cursor: pointer; padding: 1px 0 0; flex: none;
  color: var(--gray-300); transition: color .1s, transform .1s; line-height: 0;
}
.star svg { width: 14px; height: 14px; }
.star.on { color: #F79009; }
.star:hover { transform: scale(1.15); color: #F79009; }
.field-row input {
  width: 100%; border: 1px solid var(--border); border-radius: var(--r-sm);
  padding: 6px 10px; font-size: 12.5px; font-family: var(--font); color: var(--ink);
  background: #fff; transition: border-color .12s, box-shadow .12s;
}
.field-row input:hover { border-color: var(--border-strong); }
.field-row.missing input { background: #FFFBFA; border-color: var(--red-br); }
/* Typed over by a person. The amber edge is the flag on the value itself, so a
   merged row (Period) shows which half was corrected and which is still the
   agent's. Colour never carries it alone — the row also has an "edited" chip. */
.field-row input.edited { border-left: 3px solid #F79009; background: #FFFCF5; }
/* Breakdown fields (fees, deductibles, sub-limits, ...) — one line per item plus a
   Total line — get a real multi-line box instead of a single-line input, so the
   whole value is visible instead of scrolling off the edge. */
.field-row textarea {
  width: 100%; border: 1px solid var(--border); border-radius: var(--r-sm);
  padding: 6px 10px; font-size: 12.5px; font-family: var(--font); color: var(--ink);
  background: #fff; transition: border-color .12s, box-shadow .12s;
  min-height: 64px; line-height: 1.5; resize: vertical;
}
.field-row textarea:hover { border-color: var(--border-strong); }
.field-row.missing textarea { background: #FFFBFA; border-color: var(--red-br); }
.field-row textarea.edited { border-left: 3px solid #F79009; background: #FFFCF5; }
.field-row .fl-note {
  max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  margin-top: 1px;
}
.field-row .fl-note.edited { color: var(--amber-t); display: flex; align-items: center; gap: 4px; }
.field-row .fl-note.edited .ic { flex: none; }
/* The submission gate's "Review the MRC" list lives in the 336px right-hand panel,
   not the wide Fields tab — the fixed 240px label column there would leave the
   value box only a few characters wide, so stack label above value instead. */
#mrcList .field-row { grid-template-columns: 1fr; gap: 4px; }
.chip.tiny { font-size: 10px; padding: 0 5px; line-height: 15px; vertical-align: 1px; }

/* ── Approvals ────────────────────────────────────────────────────────────── */
.approval {
  display: flex; align-items: center; gap: 16px; background: #fff; border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 14px 16px; margin-bottom: 10px; box-shadow: var(--sh-xs);
  border-left-width: 3px; transition: box-shadow .12s, border-color .12s;
}
.approval:hover { box-shadow: var(--sh-sm); }
.approval.urgent { border-left-color: #F04438; }
.approval.normal { border-left-color: #F79009; }
.approval .a-body { flex: 1; min-width: 0; }
.approval .a-title { font-weight: 600; font-size: 13.5px; margin: 4px 0 2px; color: var(--ink); letter-spacing: -.01em; }
.approval .a-meta { color: var(--sub); font-size: 12px; }
.approval .a-actions { display: flex; gap: 8px; flex-shrink: 0; }

.filter-chips { display: flex; gap: 6px; margin-bottom: 16px; flex-wrap: wrap; }
.filter-chips .fc {
  padding: 0 12px; height: 28px; border-radius: 999px; border: 1px solid var(--border);
  background: #fff; font-weight: 500; font-size: 12.5px; color: var(--sub);
  display: inline-flex; align-items: center; box-shadow: var(--sh-xs);
}
.filter-chips .fc:hover { color: var(--ink); background: var(--gray-50); }
.filter-chips .fc.active { background: var(--gray-900); color: #fff; border-color: var(--gray-900); }
.filter-chips .fc .n { opacity: .65; margin-left: 5px; font-variant-numeric: tabular-nums; }

/* ── Workbench ────────────────────────────────────────────────────────────── */
.wb { display: grid; grid-template-columns: 1fr 400px; gap: 16px; align-items: start; }
.agent-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.agent-card {
  background: #fff; border: 1px solid var(--border); border-radius: var(--r-lg); padding: 14px;
  cursor: pointer; box-shadow: var(--sh-xs); transition: border-color .12s, box-shadow .12s;
}
.agent-card:hover { border-color: var(--gray-300); box-shadow: var(--sh-sm); }
.agent-card.sel { border-color: var(--brand-500); box-shadow: 0 0 0 3px var(--brand-ring); }
.agent-card .ac-head { display: flex; align-items: center; gap: 9px; }
.agent-card .ac-icon {
  width: 28px; height: 28px; border-radius: 7px; flex: none;
  background: linear-gradient(135deg, var(--indigo-b), var(--brand-100));
  border: 1px solid var(--indigo-br);
  color: var(--brand-700); display: grid; place-items: center; font-weight: 600; font-size: 12.5px;
}
.agent-card .ac-name { font-weight: 600; font-size: 13px; color: var(--ink); letter-spacing: -.01em; }
.agent-card .ac-desc { color: var(--sub); font-size: 11.5px; margin: 8px 0 10px; min-height: 30px; line-height: 1.45; }
.agent-card .ac-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; }

.console {
  background: var(--gray-950); color: #CBD5E1; border-radius: var(--r-md); padding: 14px;
  font-family: var(--mono); font-size: 12px; line-height: 1.6; white-space: pre-wrap;
  word-break: break-word; max-height: 420px; overflow: auto;
  border: 1px solid var(--gray-800);
}
.console .ok { color: #34D399; } .console .warn { color: #FBBF24; } .console .lnk { color: #93C5FD; }

/* ── Forms ────────────────────────────────────────────────────────────────── */
label.fld { display: block; margin-bottom: 12px; font-size: 12px; color: var(--gray-700); font-weight: 500; }
label.fld input, label.fld textarea, label.fld select {
  display: block; width: 100%; margin-top: 5px; border: 1px solid var(--border-strong);
  border-radius: var(--r-sm); padding: 7px 10px; font-size: 13px; font-family: var(--font);
  color: var(--ink); background: #fff; transition: border-color .12s, box-shadow .12s;
}
label.fld textarea { min-height: 110px; resize: vertical; line-height: 1.55; }

.email-preview {
  background: var(--gray-25); border: 1px solid var(--border); border-radius: var(--r-md);
  padding: 12px 14px; font-size: 12.5px; white-space: pre-wrap; max-height: 300px; overflow: auto;
  color: var(--gray-700); line-height: 1.6;
}
.check-list { display: flex; flex-direction: column; gap: 6px; }
.check-item {
  display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: var(--r-md); background: #fff;
  transition: border-color .1s, background .1s;
}
.check-item:hover { border-color: var(--border-strong); background: var(--gray-25); }
.check-item input { margin-top: 3px; accent-color: var(--brand-600); }
.check-item .ci-name { font-weight: 600; font-size: 12.5px; color: var(--ink); }
.check-item .ci-sub { color: var(--sub); font-size: 12px; }

/* ── Modal / drawer ───────────────────────────────────────────────────────── */
.overlay {
  position: fixed; inset: 0; background: rgba(12, 17, 29, .55); z-index: 100; display: grid;
  place-items: center; padding: 24px; animation: fadeIn .12s ease-out;
}
.modal {
  background: #fff; border-radius: var(--r-xl); width: 620px; max-width: 100%; max-height: 88vh;
  overflow: auto; padding: 20px 22px; box-shadow: var(--sh-xl);
  animation: slideUp .16s cubic-bezier(.16, 1, .3, 1);
}
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: 440px; max-width: 96vw; background: #fff;
  z-index: 100; box-shadow: var(--sh-xl); overflow: auto; padding: 20px 22px;
  border-left: 1px solid var(--border); animation: slideIn .18s cubic-bezier(.16, 1, .3, 1);
}
.modal h2, .drawer h2 {
  margin: 0 0 4px; font-size: 15px; font-weight: 600; color: var(--ink); letter-spacing: -.01em;
}
.close-x {
  float: right; border: none; background: transparent; color: var(--faint); cursor: pointer;
  width: 26px; height: 26px; border-radius: 6px; display: grid; place-items: center;
}
.close-x:hover { background: var(--gray-100); color: var(--ink); }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(8px) scale(.99); } }
@keyframes slideIn { from { transform: translateX(24px); opacity: 0; } }

/* ── Empty / stats / toast ────────────────────────────────────────────────── */
.empty { text-align: center; color: var(--sub); padding: 44px 20px; font-size: 12.5px; }
.empty .ic { width: 28px; height: 28px; color: var(--gray-300); display: block; margin: 0 auto 10px; }

.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.stat { background: #fff; border: 1px solid var(--border); border-radius: var(--r-lg); padding: 14px 16px; box-shadow: var(--sh-xs); }
.stat .s-label { color: var(--sub); font-size: 11.5px; font-weight: 500; }
.stat .s-val { font-size: 20px; font-weight: 600; margin-top: 3px; color: var(--ink); letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat .s-val.green { color: var(--green-t); } .stat .s-val.amber { color: var(--amber-t); }

#toasts { position: fixed; bottom: 20px; right: 20px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--gray-950); color: #E2E8F0; border-radius: var(--r-md); padding: 10px 14px;
  font-size: 12.5px; box-shadow: var(--sh-xl); display: flex; align-items: center; gap: 9px;
  max-width: 380px; border: 1px solid var(--gray-800); animation: slideUp .18s cubic-bezier(.16, 1, .3, 1);
}
.toast.error { border-left: 3px solid #F04438; }
.toast.ok { border-left: 3px solid #12B76A; }

.spinner {
  display: inline-block; width: 13px; height: 13px; border: 2px solid var(--gray-200);
  border-top-color: var(--brand-600); border-radius: 50%; animation: spin .6s linear infinite;
  vertical-align: -2px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 1280px) {
  .dealroom { grid-template-columns: 200px 1fr 300px; }
}
@media (max-width: 1100px) {
  .dealroom { grid-template-columns: 1fr; }
  .wb { grid-template-columns: 1fr; }
  .agent-grid { grid-template-columns: repeat(2, 1fr); }
}

/* == Agent workbench (standalone tools) ==================================== */
.wb2 { display: grid; grid-template-columns: 340px 1fr; gap: 16px; align-items: start; }
.tool-card {
  display: flex; gap: 12px; align-items: flex-start; margin-bottom: 10px;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--r-xl);
  padding: 15px 14px; cursor: pointer; box-shadow: var(--sh-xs);
  transition: border-color .12s, box-shadow .12s;
}
.tool-card:hover { border-color: var(--gray-300); box-shadow: var(--sh-sm); }
.tool-card.sel { border-color: var(--brand-500); box-shadow: 0 0 0 3px var(--brand-ring); }
.tc-icon {
  width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center;
  flex: none; border: 1px solid var(--border);
}
.tc-icon.red { background: var(--red-b); border-color: var(--red-br); color: var(--red-t); }
.tc-icon.blue { background: var(--blue-b); border-color: var(--blue-br); color: var(--blue-t); }
.tc-icon.indigo { background: var(--indigo-b); border-color: var(--indigo-br); color: var(--indigo-t); }
.tc-name { font-weight: 600; color: var(--ink); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; letter-spacing: -.01em; }
.tc-desc { color: var(--sub); font-size: 11.5px; margin-top: 4px; line-height: 1.5; }
.tc-runs { color: var(--faint); font-size: 10.5px; margin-top: 8px; }

.wb-panel { padding: 18px; }
.wbp-head { display: flex; gap: 12px; align-items: center; }
.wb-in {
  border: 1px solid var(--border-strong); border-radius: var(--r-sm); padding: 8px 11px;
  font-size: 13px; font-family: var(--font); color: var(--ink); background: #fff;
  transition: border-color .12s, box-shadow .12s;
}
.wb-note { background: var(--gray-50); border: 1px solid var(--border); border-radius: var(--r-md); padding: 10px 12px; font-size: 12px; line-height: 1.55; }
.warn-note { background: var(--amber-b); border-color: var(--amber-br); color: var(--amber-t); margin-bottom: 8px; }

/* OFAC verdict banner */
.ofac-verdict { display: flex; align-items: center; gap: 12px; padding: 12px 15px; border-radius: var(--r-lg); border: 1px solid; font-weight: 600; }
.ofac-verdict .lvl { font-size: 16px; letter-spacing: .03em; }
.ofac-verdict.green { background: var(--green-b); border-color: var(--green-br); color: var(--green-t); }
.ofac-verdict.amber { background: var(--amber-b); border-color: var(--amber-br); color: var(--amber-t); }
.ofac-verdict.red { background: var(--red-b); border-color: var(--red-br); color: var(--red-t); }

/* KB chat */
.wb-panel.chatty { display: flex; flex-direction: column; min-height: 560px; }
.chat-thread {
  flex: 1; overflow-y: auto; margin: 14px 0 0; padding: 4px 2px 12px;
  display: flex; flex-direction: column; gap: 10px; max-height: calc(100vh - 330px);
}
.chat-empty { margin: auto; text-align: center; color: var(--faint); max-width: 380px; padding: 40px 0; }
.chat-empty p { margin: 10px 0 0; font-size: 12px; line-height: 1.55; }
.msg { display: flex; }
.msg.user { justify-content: flex-end; }
.msg .bubble { max-width: 78%; padding: 10px 13px; border-radius: 12px; font-size: 12.5px; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.user .bubble { background: var(--brand-600); color: #fff; border-bottom-right-radius: 4px; }
.msg.bot .bubble { background: var(--gray-50); border: 1px solid var(--border); color: var(--body); border-bottom-left-radius: 4px; }
.msg-src { margin-top: 8px; display: flex; gap: 6px; flex-wrap: wrap; }
.msg-meta { margin-top: 6px; color: var(--faint); font-size: 10.5px; }
/* The trail of steps an agent has already finished, under the one it is on now.
   Muted and small: it is context while you wait, not the answer. */
.msg-steps { margin-top: 6px; color: var(--faint); font-size: 10.5px; line-height: 1.6; }
.msg-steps div { opacity: .75; }
.msg-steps div::before { content: "¹3  "; }
.chat-inbar { display: flex; gap: 8px; align-items: flex-end; border-top: 1px solid var(--border); padding-top: 12px; }
.chat-inbar textarea { flex: 1; resize: none; min-height: 38px; max-height: 120px; line-height: 1.5; }
.chat-deal { width: 92px; flex: none; }

@media (max-width: 1100px) {
  .wb2 { grid-template-columns: 1fr; }
}

/* == Attachments (draft editor) ============================================ */
.att-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 6px; }
.att-chip { display: inline-flex; align-items: center; gap: 5px; padding: 3px 8px; font-size: 11.5px;
  background: var(--gray-50); border: 1px solid var(--border); border-radius: 999px; color: var(--gray-700); }
.att-chip .att-x { display: inline-flex; padding: 0; margin-left: 2px; border: none; background: none;
  color: var(--gray-400); cursor: pointer; line-height: 1; }
.att-chip .att-x:hover { color: var(--red-t); }
.draft-card { border-left: 3px solid var(--amber-br); }

/* == Commercial terms table ================================================ */
.comm-tbl th { white-space: nowrap; font-size: 11px; }
.comm-tbl td { padding: 4px 6px; }
.comm-in { width: 84px; border: 1px solid var(--border-strong); border-radius: var(--r-sm);
  padding: 4px 6px; font-size: 12px; font-family: var(--font); color: var(--ink); background: #fff; }
/* the (re)insurer identity uses the same boxed design as the editable cells, just
   sized to fit the name and not editable */
.comm-in.comm-name { display: inline-flex; align-items: center; width: auto; min-width: 110px;
  max-width: 210px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; }
/* colour each cell by where its value comes from */
.comm-in.src-mrc,      .comm-name.src-mrc      { background: var(--blue-b); }
.comm-in.src-insurer,  .comm-name.src-insurer  { background: var(--green-b); }
.comm-in.src-broker,   .comm-name.src-broker   { background: var(--amber-b); }
.comm-in.src-computed                          { background: var(--gray-50); }
/* an edited/overridden cell keeps its source colour but gains a ring + bold */
.comm-in.ovr { border-color: var(--brand-500); box-shadow: 0 0 0 2px var(--brand-ring); font-weight: 700; }
.comm-total td { background: var(--gray-50); font-weight: 600; border-top: 2px solid var(--border-strong); }
.comm-legend { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 10px; color: var(--sub); align-items: center; }
.comm-legend .lg { display: inline-flex; align-items: center; gap: 6px; }
.comm-legend .sw { width: 13px; height: 13px; border-radius: 3px; border: 1px solid var(--border-strong); }
.comm-legend .sw.src-mrc { background: var(--blue-b); }
.comm-legend .sw.src-insurer { background: var(--green-b); }
.comm-legend .sw.src-broker { background: var(--amber-b); }
.comm-legend .sw.src-computed { background: var(--gray-50); }
.comm-legend .sw.ovr-sw { background: #fff; border-color: var(--brand-500); box-shadow: 0 0 0 2px var(--brand-ring); }
/* formula editor + column glossary (under the commercial table) */
.fx-panel { margin-top: 14px; border: 1px solid var(--border); border-radius: var(--r-md);
  padding: 10px 12px; background: var(--gray-25); }
.fx-panel > summary { cursor: pointer; font-size: 12.5px; font-weight: 600; color: var(--ink); }
.fx-panel > summary:hover { color: var(--brand-700); }
.fx-row { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; flex-wrap: wrap; }
.fx-name { font-size: 11.5px; color: var(--sub); min-width: 170px; font-weight: 600; }
.fx-eq { color: var(--gray-400); font-weight: 700; }
.fx-in { flex: 1; min-width: 260px; border: 1px solid var(--border-strong); border-radius: var(--r-sm);
  padding: 5px 8px; font-size: 12px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--ink); background: #fff; }
.fx-in.edited { border-color: var(--brand-500); box-shadow: 0 0 0 2px var(--brand-ring); font-weight: 600; }
.cfld { display: flex; flex-direction: column; font-size: 11px; color: var(--sub); gap: 3px; }
.cfld input, .cfld select { width: 110px; border: 1px solid var(--border-strong); border-radius: var(--r-sm);
  padding: 6px 8px; font-size: 12.5px; font-family: var(--font); color: var(--ink); background: #fff; }
.ovr-key { color: var(--brand-700); background: var(--brand-50); border: 1px solid var(--brand-100);
  padding: 0 5px; border-radius: 4px; font-weight: 600; }

/* Other-deductions breakdown: the rates that add up to the Other Deductions % column */
.dedn-row { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; flex-wrap: wrap;
  padding: 6px 8px; background: #fff; border: 1px solid var(--border); border-radius: var(--r-sm); }
.dedn-row input[type="text"], .dedn-row input:not([type]), .dedn-row input[type="number"] {
  border: 1px solid var(--border-strong); border-radius: var(--r-sm); padding: 5px 8px;
  font-size: 12.5px; font-family: var(--font); color: var(--ink); background: #fff; }
.dedn-label { flex: 1; min-width: 190px; font-weight: 600; }
.dedn-pct { width: 74px; text-align: right; font-weight: 700; }
.dedn-unit { color: var(--gray-400); font-weight: 700; margin-left: -4px; }
.dedn-note { flex: 1; min-width: 150px; }
.dedn-col { display: inline-flex; align-items: center; gap: 4px; color: var(--sub);
  white-space: nowrap; cursor: pointer; }
.dedn-total { margin-top: 8px; padding: 6px 10px; border-radius: var(--r-sm);
  background: var(--blue-b); border: 1px solid var(--border-strong); display: inline-block; }

/* ═══════════════════════════════════════════════════════════════════════════
   Dashboard — KPI tiles, charts, calendar, alerts
   Data marks use one validated blue (#2a78d6) and, for the single two-series
   chart, one orange (#eb6834). The brand indigo stays on UI chrome so data ink
   and interface ink never compete.
   ═══════════════════════════════════════════════════════════════════════════ */

.sec-title {
  display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600;
  color: var(--ink); margin: 26px 0 12px; letter-spacing: -.01em;
}
.sec-title .ic { color: var(--sub); }

/* ── KPI tiles ─────────────────────────────────────────────────────────────
   Proportional figures on the value (tabular-nums makes a display number
   look loose); tabular-nums is kept for table rows and axis ticks. */
/* 8 tiles land as a clean 4x2 block; narrower viewports step down to 2 and 1 */
.kpi-row {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px; margin-bottom: 16px;
}
.kpi {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: 13px 15px; box-shadow: var(--sh-xs);
}
.kpi-label { color: var(--sub); font-size: 11px; font-weight: 500; text-transform: uppercase; letter-spacing: .04em; }
.kpi-value { font-size: 22px; font-weight: 600; color: var(--ink); letter-spacing: -.02em; margin: 5px 0 2px; }
.kpi-note { color: var(--faint); font-size: 11.5px; line-height: 1.4; }
.kpi.good { border-left: 3px solid #0ca30c; }
.kpi.bad { border-left: 3px solid #d03b3b; }
.kpi.bad .kpi-value { color: #B42318; }

/* ── chart cards ───────────────────────────────────────────────────────────── */
.dash-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 14px; align-items: start; }
.viz-card { min-width: 0; }
.viz-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.viz-head h3 { margin: 0; display: flex; align-items: center; gap: 6px; }
.viz-head .ic { color: var(--sub); }
.viz-sub { color: var(--faint); font-size: 11.5px; margin-left: auto; }
.viz-head > .btn { margin-left: auto; }

/* the container grows with the plot + its axis band, so no nested scrollbar */
svg.viz { display: block; width: 100%; height: auto; overflow: visible; }
.viz-tick {
  fill: #667085; font-size: 10px; font-family: var(--font);
  font-variant-numeric: tabular-nums;
}
.viz-val { fill: #101828; font-size: 10.5px; font-weight: 600; font-family: var(--font); }
.viz-empty {
  color: var(--faint); font-size: 12px; text-align: center; padding: 34px 10px;
  background: var(--gray-25); border: 1px dashed var(--border); border-radius: var(--r-md);
}
.viz-legend { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 6px; }
.viz-legend .vl { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--body); }
.vl-dot { width: 9px; height: 9px; border-radius: 2px; flex: none; }

/* every chart's table twin — a value is never hover-only */
.viz-table { margin-top: 10px; }
.viz-table summary {
  cursor: pointer; color: var(--sub); font-size: 11.5px; padding: 4px 0;
  list-style: none;
}
.viz-table summary::-webkit-details-marker { display: none; }
.viz-table summary::before { content: "▸ "; color: var(--faint); }
.viz-table[open] summary::before { content: "▾ "; }
.viz-table summary:hover { color: var(--brand-600); }
.tbl.mini { font-size: 11.5px; margin-top: 6px; }
.tbl.mini th, .tbl.mini td { padding: 4px 8px; }

/* ── horizontal bars ──────────────────────────────────────────────────────── */
.hbars { display: flex; flex-direction: column; gap: 7px; }
.hbar { display: grid; grid-template-columns: 118px 1fr 56px; gap: 10px; align-items: center; }
.hb-label {
  font-size: 12px; color: var(--body); overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.hb-track { background: var(--gray-100); border-radius: 4px; height: 9px; overflow: hidden; }
.hb-fill { height: 100%; border-radius: 4px; min-width: 3px; }
.hb-val { font-size: 11.5px; color: var(--ink); font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }

/* ── stacked outcome bar ──────────────────────────────────────────────────── */
.stackbar { display: flex; height: 14px; border-radius: 4px; overflow: hidden; gap: 2px; background: var(--gray-100); }
.st-seg { min-width: 3px; }
.st-legend, .cal-key { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 10px; }
.st-key { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--body); }
.st-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }

/* ── budget meter ─────────────────────────────────────────────────────────── */
.meter-wrap { margin-top: 4px; }
.meter { position: relative; height: 15px; background: var(--gray-100); border-radius: 8px; overflow: visible; }
.meter-fill { height: 100%; background: #2a78d6; border-radius: 8px; min-width: 3px; transition: width .3s; }
.meter-mark {
  position: absolute; top: -4px; bottom: -4px; width: 2px; background: var(--gray-700);
  border-radius: 1px;
}
.meter-mark::after {
  content: ""; position: absolute; top: -3px; left: -3px; width: 8px; height: 8px;
  border-radius: 50%; background: var(--gray-700);
}
.meter-foot { display: flex; justify-content: space-between; gap: 10px; margin-top: 9px; font-size: 12px; }
.meter-note { margin-top: 10px; font-size: 11.5px; color: var(--sub); display: flex; align-items: center; gap: 6px; }
.meter-note .ic { color: #2a78d6; }

/* ── calendar ─────────────────────────────────────────────────────────────── */
.cal-nav { margin-left: auto; display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink); }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; }
.cal-grid.head { margin-bottom: 3px; }
.cal-h { text-align: center; font-size: 10px; color: var(--faint); text-transform: uppercase; letter-spacing: .04em; }
.cal-cell {
  min-height: 38px; border: 1px solid var(--border); border-radius: var(--r-sm);
  padding: 3px 4px; display: flex; flex-direction: column; gap: 2px; background: var(--gray-25);
}
.cal-cell.pad { border: none; background: transparent; }
.cal-cell.has { background: #fff; border-color: var(--border-strong); cursor: default; }
.cal-cell.today { border-color: var(--brand-500); box-shadow: 0 0 0 2px var(--brand-ring); }
.cal-n { font-size: 10.5px; color: var(--sub); font-variant-numeric: tabular-nums; }
.cal-cell.today .cal-n { color: var(--brand-700); font-weight: 700; }
.cal-dots { display: flex; gap: 2px; flex-wrap: wrap; }
.cal-dot { width: 5px; height: 5px; border-radius: 50%; }

.ev-list { list-style: none; margin: 0; padding: 0; }
.ev-list li {
  display: flex; align-items: center; gap: 8px; padding: 7px 0;
  border-bottom: 1px solid var(--gray-100); font-size: 12px; cursor: pointer;
}
.ev-list li:last-child { border-bottom: none; }
.ev-list li:hover .ev-title { color: var(--brand-700); }
.ev-dot { width: 7px; height: 7px; border-radius: 50%; flex: none; }
.ev-when { color: var(--sub); width: 48px; flex: none; font-variant-numeric: tabular-nums; }
.ev-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--body); }
.ev-in { flex: none; font-size: 11px; }

/* ── alert rows ───────────────────────────────────────────────────────────── */
.alert-list { list-style: none; margin: 0; padding: 0; }
.alert-row {
  display: flex; gap: 10px; align-items: flex-start; padding: 9px 0;
  border-bottom: 1px solid var(--gray-100); cursor: pointer;
}
.alert-row:last-child { border-bottom: none; }
.alert-row:hover .al-main b { color: var(--brand-700); }
/* status colour + icon + text label — never colour alone */
.al-badge {
  display: inline-flex; align-items: center; gap: 4px; flex: none;
  font-size: 9.5px; font-weight: 700; letter-spacing: .05em; padding: 3px 6px;
  border-radius: var(--r-sm); border: 1px solid var(--amber-br);
  background: var(--amber-b); color: var(--amber-t);
}
.alert-row.late .al-badge { border-color: var(--red-br); background: var(--red-b); color: var(--red-t); }
.al-badge .ic { width: 11px; height: 11px; }
.al-main { flex: 1; min-width: 0; font-size: 12.5px; }

/* ── deal card: stage clock + alert tint ──────────────────────────────────── */
.deal-card .dc-stage {
  display: flex; align-items: center; gap: 5px; margin-top: 8px;
  font-size: 11px; color: var(--sub);
}
.deal-card .dc-stage .ic { width: 12px; height: 12px; color: var(--faint); }
.deal-card.warn { border-left: 3px solid #fab219; }
.deal-card.late { border-left: 3px solid #d03b3b; }
.stage-flag {
  font-size: 9.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  padding: 1px 5px; border-radius: 3px; border: 1px solid var(--amber-br);
  background: var(--amber-b); color: var(--amber-t);
}
.stage-flag.late { border-color: var(--red-br); background: var(--red-b); color: var(--red-t); }
.col-late {
  margin-left: auto; font-size: 10px; font-weight: 600; color: var(--red-t);
  background: var(--red-b); border: 1px solid var(--red-br); border-radius: 3px; padding: 1px 5px;
}
.dc-chat {
  background: none; border: none; padding: 2px; color: var(--faint); display: inline-flex;
  border-radius: var(--r-sm); cursor: pointer;
}
.dc-chat:hover { color: var(--brand-600); background: var(--gray-100); }

/* ── Deal room list ──────────────────────────────────────────────────────── */
.room-bar {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px;
}
tr.deal-row { cursor: pointer; }
td.cell-warn { color: var(--amber-t); font-weight: 600; }
td.cell-late { color: var(--red-t); font-weight: 600; }

/* ── New inquiry page / workbench intro ──────────────────────────────────── */
.inq-head, .wb-intro {
  display: flex; gap: 16px; align-items: center; justify-content: space-between;
  flex-wrap: wrap; margin-bottom: 14px;
}
.inq-head h3, .wb-intro h3 { display: flex; align-items: center; gap: 7px; }
.inq-head h3 .ic, .wb-intro h3 .ic { color: var(--sub); }
.pill-lg {
  display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; font-weight: 500;
  padding: 5px 10px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--gray-50); color: var(--sub); white-space: nowrap;
}
.pill-lg.on { border-color: var(--green-br); background: var(--green-b); color: var(--green-t); }

/* ── per-deal assistant + stage timestamps ───────────────────────────────── */
.wb-panel.chatty.deal-chat { min-height: 480px; }
.sh-list { list-style: none; margin: 0; padding: 0; }
.sh-row {
  display: grid; grid-template-columns: 1fr auto auto; gap: 8px; align-items: baseline;
  padding: 6px 0; border-bottom: 1px solid var(--gray-100); font-size: 12px;
}
.sh-row:last-child { border-bottom: none; }
.sh-row.open .sh-stage { color: var(--brand-700); font-weight: 600; }
.sh-stage { color: var(--body); }
.sh-when { color: var(--faint); font-size: 10.5px; font-variant-numeric: tabular-nums; }
.sh-dur { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; font-size: 11.5px; }

@media (max-width: 1180px) {
  .dash-2 { grid-template-columns: 1fr; }
}
@media (max-width: 1180px) {
  .kpi-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
  .kpi-row { grid-template-columns: 1fr; }
  .hbar { grid-template-columns: 90px 1fr 48px; }
}

/* ═══════════════════════════════════════════════════════════════════════════
   Deal room — overview market table, documents filters, mail list, endorsements
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Overview: starred key fields + market summary ────────────────────────── */
.kv.kv-star-grid .k { display: flex; align-items: baseline; gap: 5px; }
.kv-star { color: #F79009; flex: none; line-height: 1; }
.kv-star svg { width: 11px; height: 11px; vertical-align: -1px; }
/* Overview keeps the requested card order — Key fields, Market, Compliance, Risk
   summary — but the market table needs the width, so the left column is narrow and
   the right column takes the rest. */
.ov-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px; }
.ov-grid > * { min-width: 0; }
/* Market and Risk summary take the whole row — the market table is 7 columns wide and
   a half-column would push half of it behind a horizontal scrollbar. */
.ov-grid > .ov-wide { grid-column: 1 / -1; }
@media (max-width: 1100px) { .ov-grid { grid-template-columns: minmax(0, 1fr); } }

.mkt-tbl { min-width: 520px; }              /* below this the wrapper scrolls */
.mkt-tbl th { white-space: normal; line-height: 1.3; }
.mkt-tbl td { vertical-align: top; }
.mkt-tbl td:nth-child(2) { max-width: 120px; }
/* the market card owns the wide table, so give the key-field card a workable
   label/value split at the narrower width that leaves */
.kv.kv-star-grid { grid-template-columns: minmax(84px, 44%) minmax(0, 1fr); }
.kv.kv-star-grid .v { -webkit-line-clamp: 4; }

/* ── Documents: search + sortable headers ────────────────────────────────── */
.doc-bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.doc-bar .searchwrap.doc-search { margin-left: 0; flex: 1; min-width: 200px; }
.doc-bar .searchwrap.doc-search .search {
  width: 100%; height: 32px; padding: 0 10px 0 30px; font-size: 12.5px;
  border: 1px solid var(--border); border-radius: var(--r-md); background: var(--gray-25);
  color: var(--ink); font-family: var(--font);
}
.doc-bar .searchwrap.doc-search .search::placeholder { color: var(--faint); }
.doc-bar .searchwrap.doc-search .search:focus { background: #fff; }
th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
th.sortable:hover { color: var(--brand-700); }
th.sortable.on { color: var(--brand-700); }
.sort-ar { font-size: 8px; margin-left: 4px; vertical-align: 1px; }

/* ── Emails: collapsed thread, expand one to read it ─────────────────────── */
.mail-list { list-style: none; margin: 0; padding: 0; }
.mail-item { border-bottom: 1px solid var(--gray-100); }
.mail-item:last-child { border-bottom: none; }
.mail-head {
  display: flex; align-items: center; gap: 8px; padding: 9px 4px; cursor: pointer;
  border-radius: var(--r-sm);
}
.mail-head:hover { background: var(--gray-25); }
.mail-item.open .mail-head { background: var(--gray-25); }
.mail-caret { color: var(--faint); width: 10px; flex: none; font-size: 10px; }
.mail-subject {
  flex: 1; min-width: 0; font-weight: 600; color: var(--ink); font-size: 12.5px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.mail-item.open .mail-subject { white-space: normal; }
.mail-att {
  display: inline-flex; align-items: center; gap: 2px; color: var(--sub);
  font-size: 11px; flex: none;
}
.mail-when {
  color: var(--faint); font-size: 11px; flex: none; font-variant-numeric: tabular-nums;
}
.mail-body { padding: 4px 4px 14px 22px; }
.kv.mail-kv { grid-template-columns: 70px 1fr; gap: 4px 12px; margin-bottom: 10px; }
.email-preview.open { max-height: none; }

/* ── Activity feeds: date + time gutter ──────────────────────────────────── */
.mini-feed .t.wide { width: 82px; }
.adv-secs { color: var(--gray-500); }

/* ── Endorsements ────────────────────────────────────────────────────────── */
.end-stats {
  display: flex; gap: 20px; flex-wrap: wrap; align-items: baseline;
  padding: 11px 14px; background: var(--gray-25); border: 1px solid var(--border);
  border-radius: var(--r-md); font-size: 12px; color: var(--sub);
}
.end-stats b { color: var(--ink); font-size: 14px; }
.adj-up { color: var(--green-t) !important; }
.adj-down { color: var(--red-t) !important; }

.end-card {
  border: 1px solid var(--border); border-radius: var(--r-lg); padding: 13px 15px;
  margin-bottom: 10px; background: var(--card);
}
.end-card.editing { border-color: var(--brand-500); box-shadow: 0 0 0 3px var(--brand-ring); }
.end-head { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.end-ref {
  font-family: var(--mono); font-size: 11.5px; font-weight: 600; color: var(--brand-700);
  background: var(--brand-50); border: 1px solid var(--indigo-br);
  padding: 2px 7px; border-radius: var(--r-sm); flex: none;
}
.end-title { font-weight: 600; color: var(--ink); font-size: 13px; }
.end-meta {
  display: flex; gap: 16px; flex-wrap: wrap; margin-top: 9px;
  font-size: 11.5px; color: var(--sub);
}
.end-meta span { display: inline-flex; align-items: center; gap: 5px; }
.end-meta .ic { color: var(--faint); }
.end-detail {
  margin-top: 10px; font-size: 12.5px; line-height: 1.55; color: var(--body);
  white-space: pre-wrap; padding-left: 10px; border-left: 2px solid var(--gray-200);
}
.end-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; align-items: center; }
.end-form { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-top: 12px; }

/* endorsement marker on a pipeline card / deal-room row */
.end-flag {
  display: inline-flex; align-items: center; gap: 4px; color: var(--brand-700);
  font-size: 10.5px; font-weight: 600; margin-top: 4px;
}
.end-flag .ic { width: 11px; height: 11px; }

/* endorsement count on the deal-room tab strip */
.tab .tab-n {
  margin-left: 5px; font-size: 10px; font-weight: 700; padding: 0 5px;
  border-radius: 8px; background: var(--brand-50); color: var(--brand-700);
  border: 1px solid var(--indigo-br);
}
.tab.active .tab-n { background: var(--brand-600); color: #fff; border-color: var(--brand-600); }

/* ═══════════════════════════════════════════════════════════════════════════
   Pipeline run — ten-step workflow, gate email composer, per-insurer requests
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── The ten steps ────────────────────────────────────────────────────────── */
.ws-card .viz-head { flex-direction: column; align-items: flex-start; gap: 1px; margin-bottom: 10px; }
.ws-card .viz-sub { margin-left: 0; }
.ws-list > li { padding-bottom: 8px; min-height: 34px; }
.ws-body { flex: 1; min-width: 0; }
.ws-label { line-height: 1.35; }
.ws-label > .chip { margin-left: 5px; vertical-align: 1px; }
.ws-n {
  font-family: var(--mono); font-size: 10px; font-weight: 700; color: var(--faint);
  background: var(--gray-50); border: 1px solid var(--border); border-radius: 4px;
  padding: 0 4px; margin-right: 5px; display: inline-block;
}
.tl-current .ws-n, .tl-gate .ws-n { color: inherit; border-color: currentColor; background: transparent; }
.ws-hint { font-size: 11px; color: var(--faint); font-weight: 400; margin-top: 1px; }
.ws-det > summary {
  font-size: 10.5px; color: var(--faint); cursor: pointer; margin-top: 3px;
  list-style: none; font-weight: 400;
}
.ws-det > summary::before { content: "▸ "; }
.ws-det[open] > summary::before { content: "▾ "; }
.ws-det > summary:hover { color: var(--brand-700); }
.ws-inner { margin: 5px 0 4px 2px; }
.ws-inner > li { font-size: 11.5px; min-height: 20px; padding-bottom: 0; }
.ws-inner .mk { width: 11px; height: 11px; margin-top: 3px; }
.ws-inner .mk svg { width: 7px; height: 7px; }
.ws-inner li::before { left: 5px; top: 14px; }

/* ── A gate's emails: side panel block, or the same block in the main area ── */
.gm-block { border-top: 1px solid var(--gray-100); margin-top: 12px; padding-top: 10px; }
.gm-block:first-of-type { border-top: none; margin-top: 6px; padding-top: 0; }
.gm-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 4px; }
.gm-to { font-size: 11.5px; color: var(--sub); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gm-x {
  margin-left: auto; background: none; border: 1px solid var(--border); border-radius: var(--r-sm);
  color: var(--sub); cursor: pointer; padding: 2px 5px; display: inline-grid; place-items: center;
}
.gm-x:hover { color: var(--brand-700); border-color: var(--brand-500); background: var(--brand-50); }
.gm-stub {
  display: flex; align-items: center; gap: 9px; margin-top: 10px; padding: 10px 11px;
  border: 1px dashed var(--brand-500); border-radius: var(--r-md); background: var(--brand-50);
  font-size: 12px; color: var(--body);
}
.gm-stub .ic { color: var(--brand-700); flex: none; }
.gm-stub button { margin-left: auto; flex: none; }
.gm-full { border-top: 1px solid var(--border); margin-top: 18px; padding-top: 14px; }
#gateComposer .gm-full:first-of-type { border-top: none; margin-top: 0; padding-top: 0; }

/* ── Two-page gate (insurers, then client) ────────────────────────────────── */
.gp-steps { display: flex; gap: 8px; margin: 4px 0 12px; }
.gp-step {
  flex: 1; min-width: 0; text-align: left; cursor: pointer; font: inherit; font-size: 11.5px;
  background: var(--gray-25); border: 1px solid var(--border); border-radius: var(--r-md);
  padding: 7px 9px; color: var(--sub); display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
}
.gp-step:hover { border-color: var(--brand-500); }
.gp-step.on { background: var(--brand-50); border-color: var(--brand-500); color: var(--brand-700); font-weight: 600; }
.gp-step.done { color: var(--gray-600); }
.gp-step.done .gp-n { background: #12B76A; border-color: #12B76A; color: #fff; }
.gp-n {
  font-family: var(--mono); font-size: 10px; font-weight: 700; flex: none;
  width: 16px; height: 16px; border-radius: 50%; display: grid; place-items: center;
  border: 1px solid var(--gray-300); background: #fff;
}
.gp-step.on .gp-n { border-color: var(--brand-600); color: var(--brand-700); }
.gp-sub { width: 100%; font-size: 10.5px; color: var(--faint); font-weight: 400; }

/* ── Submission: per-insurer request for quotation ────────────────────────── */
.sub-list { display: flex; flex-direction: column; gap: 6px; }
.sub-ins { border: 1px solid var(--border); border-radius: var(--r-md); padding: 8px 10px; background: var(--card); }
.sub-ins.editing { border-color: var(--brand-500); box-shadow: 0 0 0 3px var(--brand-ring); }
/* Ticked off in "Send to which insurers?" above — wording can still be kept ready here,
   but dimmed so it reads as "won't go out", not "about to send". */
.sub-ins-unselected { opacity: .55; }
.sub-head { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; font-size: 12px; }
.sub-prev {
  font-size: 11px; color: var(--sub); margin-top: 5px; padding-left: 8px;
  border-left: 2px solid var(--gray-200); overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ── Drafts read as one line, like the rest of the thread ─────────────────── */
.draft-card { padding: 4px 12px 6px; }
.draft-card.open { padding-bottom: 14px; }
.draft-card .mail-head { padding: 8px 2px; }
.mail-to {
  font-size: 11px; color: var(--sub); flex: none; max-width: 190px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.draft-body { padding: 2px 2px 0 20px; }

/* ── Merged field row (Period writes two slip placeholders) ───────────────── */
.fr-split { display: flex; gap: 6px; min-width: 0; }
.fr-split input { min-width: 0; }

/* ═══════════════════════════════════════════════════════════════════════════
   PDF downloads · inquiry preview · dashboard settings strip
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Document row actions (original + PDF) ────────────────────────────────── */
.doc-acts { display: flex; gap: 6px; align-items: center; white-space: nowrap; }
.btn.disabled {
  opacity: .5; cursor: not-allowed; pointer-events: none;
  display: inline-flex; align-items: center;
}
.doc-acts .spinner { margin-right: 5px; }

/* ── Inquiry: the message you picked, in full, above the confirm bar ──────── */
.mail-pick.sel {
  border-color: var(--brand-500); background: var(--brand-50);
  box-shadow: 0 0 0 2px var(--brand-ring);
}
.card.inbox-prev { margin-top: 12px; border-color: var(--brand-500); }
.inbox-body {
  max-height: 40vh; overflow: auto; background: var(--gray-25);
  border: 1px solid var(--border); border-radius: var(--r-md); padding: 10px 12px;
  font-size: 12.5px; line-height: 1.55; white-space: pre-wrap;
}
.inbox-confirm {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 12px;
  padding-top: 12px; border-top: 1px solid var(--gray-100);
}

/* ── Dashboard: what the page measures against, and the way to change it ──── */
.dash-bar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 10px 14px; margin-bottom: 14px; background: var(--card);
  border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--sh-xs);
}
.db-facts {
  display: flex; gap: 18px; flex-wrap: wrap; flex: 1; min-width: 0;
  font-size: 12px; color: var(--sub);
}
.db-facts > span { display: inline-flex; align-items: center; gap: 5px; }
.db-facts b { color: var(--ink); }
.db-facts .ic { color: var(--faint); width: 13px; height: 13px; }

/* the settings dialog: label / control / note */
.kv.set-kv { grid-template-columns: 140px 1fr; gap: 10px 14px; margin: 8px 0 4px; }
.kv.set-kv .wb-in { width: 100%; max-width: 260px; }

/* a message that could not be read — the confirm bar still stands below it */
.prev-fail {
  display: flex; gap: 9px; align-items: flex-start; padding: 11px 12px;
  background: var(--amber-b); border: 1px solid var(--amber-br);
  border-radius: var(--r-md); color: var(--body); font-size: 12.5px;
}
.prev-fail .ic { color: var(--amber-t); flex: none; margin-top: 1px; }

/* ═══════════════════════════════════════════════════════════════════════════
   Quick editor — the slip's words and their styling
   Full window, like the full editor and for the same reason: a slip cannot be
   read through the deal room's 600px middle column. A wide centred sheet on a
   grey desk, the template's own Arial, and the risk-details grid drawn as the
   ruled table it is. The sheet stays white and its ink dark in either theme —
   it is a document being marked up, not a panel of the app.
   ═══════════════════════════════════════════════════════════════════════════ */
.mrc-overlay {
  position: fixed; inset: 0; z-index: 150;      /* under #toasts (200) */
  display: flex; flex-direction: column; background: var(--content-bg);
}
.mrc-bar {
  flex: none; display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 8px 14px; background: var(--card);
  border-bottom: 1px solid var(--border); box-shadow: var(--sh-xs);
}
.mrc-bar .sep { width: 1px; height: 22px; background: var(--border-strong); }
.mrc-grp { display: flex; align-items: center; gap: 4px; }
.mrc-b {
  min-width: 34px; height: 32px; padding: 0 9px; display: inline-flex;
  align-items: center; justify-content: center; cursor: pointer;
  background: var(--card); color: var(--body); border: 1px solid var(--border);
  border-radius: var(--r-sm); font-size: 14px; line-height: 1;
}
.mrc-b.wide { font-size: 12.5px; }
.mrc-b:hover { background: var(--gray-50); border-color: var(--border-strong); }
.mrc-b:active { background: var(--brand-50); border-color: var(--brand-500); color: var(--brand-700); }
.mrc-b i { font-family: Georgia, serif; }
.mrc-sw {
  width: 26px; height: 26px; padding: 0; border-radius: 50%; cursor: pointer;
  border: 2px solid var(--card); box-shadow: 0 0 0 1px var(--border-strong);
}
.mrc-sw:hover { box-shadow: 0 0 0 2px var(--brand-500); transform: scale(1.08); }
.mrc-find {
  height: 32px; padding: 0 10px; min-width: 200px;
  border: 1px solid var(--border); border-radius: var(--r-sm);
  font: inherit; font-size: 12.5px; color: var(--ink); background: var(--card);
}
.mrc-find:focus { outline: none; border-color: var(--brand-500); box-shadow: 0 0 0 3px var(--brand-ring); }
.mrc-count { font-size: 12px; color: var(--sub); margin-left: auto; }
.mrc-count b { color: var(--brand-700); }

.mrc-body { flex: 1; min-height: 0; display: flex; }
.mrc-outline {
  width: 196px; flex: none; overflow: auto; padding: 10px 8px;
  border-right: 1px solid var(--border); background: var(--gray-25);
}
.mrc-outline button {
  display: block; width: 100%; text-align: left; background: none; border: 0;
  padding: 5px 8px; border-radius: var(--r-sm); cursor: pointer;
  font-size: 11.5px; color: var(--sub); line-height: 1.35;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.mrc-outline button:hover { background: var(--brand-50); color: var(--brand-700); }
@media (max-width: 1100px) { .mrc-outline { display: none; } }

/* the desk, and the sheet on it */
.mrc-scroll { flex: 1; min-height: 0; overflow: auto; padding: 26px 20px 60px; }
.mrc-page {
  width: 100%; max-width: 960px; margin: 0 auto;
  background: #FFFFFF; color: #101828;
  border: 1px solid var(--border-strong); border-radius: 3px;
  box-shadow: var(--sh-md); padding: 46px 56px;
  font-family: Arial, Helvetica, sans-serif; font-size: 13px; line-height: 1.5;
}
.mrc-p {
  white-space: pre-wrap; word-wrap: break-word; min-height: 1.25em;
  outline: none; padding: 2px 4px; border-radius: 3px;
  transition: background .12s;
}
.mrc-p:hover { background: #F4F6F9; }
.mrc-p:focus { background: var(--brand-50); box-shadow: inset 0 0 0 1px var(--brand-500); }
.mrc-p.edited { background: #FFFAEB; }
.mrc-p.edited:focus { background: var(--brand-50); }
.mrc-p.found { background: #FEF0C7; box-shadow: inset 0 0 0 1px var(--amber-br); }

.mrc-tbl { border-collapse: collapse; width: 100%; margin: 10px 0; table-layout: fixed; }
.mrc-tbl td { border: 1px solid #B8BEC9; padding: 5px 8px; vertical-align: top; }

.mrc-foot {
  flex: none; padding: 8px 14px; font-size: 12px; color: var(--sub);
  background: var(--card); border-top: 1px solid var(--border);
}
.mrc-foot b { color: var(--body); }

/* ═══════════════════════════════════════════════════════════════════════════
   The document server's editor — given the whole window
   A word processor needs width: its ribbon collapses into an overflow arrow
   long before the deal room's middle column (1fr of 232px/1fr/336px) is wide
   enough for it. So the editor is a full-viewport overlay on <body> rather
   than a card in the grid — which also means exactly one scrollbar, the
   document's own, instead of the page's fighting it for the wheel.
   ═══════════════════════════════════════════════════════════════════════════ */
.oo-overlay {
  position: fixed; inset: 0; z-index: 150;      /* under #toasts (200) */
  display: flex; flex-direction: column;
  background: var(--content-bg);
}
/* nothing behind the editor scrolls while it is open */
body.oo-open { overflow: hidden; }

.oo-bar {
  flex: none; display: flex; align-items: center; gap: 10px;
  padding: 8px 14px; background: var(--card);
  border-bottom: 1px solid var(--border); box-shadow: var(--sh-xs);
}
.oo-name {
  display: inline-flex; align-items: center; gap: 6px;
  font-weight: 600; font-size: 13px; color: var(--ink);
  max-width: 42vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.oo-state { font-size: 12px; color: var(--sub); }
.oo-state.dirty { color: var(--amber-t); font-weight: 600; }
.oo-hint {
  font-size: 12px; color: var(--faint); margin-left: auto;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
@media (max-width: 900px) { .oo-hint { display: none; } }

/* The frame fills everything left over. The editor is given an absolutely
   positioned box to live in and its inline width/height are overridden, because
   the document server sets those on the iframe itself — left alone it sizes to
   whatever the placeholder happened to be at mount and never grows again. */
.oo-frame { flex: 1; min-height: 0; position: relative; }
.oo-frame > div,
.oo-frame iframe {
  position: absolute; inset: 0;
  width: 100% !important; height: 100% !important;
  border: 0; display: block;
}

/* ═══════════════════════════════════════════════════════════════════════════
   Sign-in, identity, audit trail, accounts
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── the sign-in gate ─────────────────────────────────────────────────────── */
.authgate {
  position: fixed; inset: 0; z-index: 200; display: grid; place-items: center;
  padding: 24px; background:
    radial-gradient(1100px 620px at 50% -10%, #EEF4FF 0%, rgba(238, 244, 255, 0) 60%),
    var(--content-bg);
  overflow: auto;
}
.auth-card {
  width: 100%; max-width: 380px; background: var(--card); padding: 28px;
  border: 1px solid var(--border); border-radius: var(--r-xl); box-shadow: var(--sh-lg, 0 12px 32px rgba(16,24,40,.10));
}
.auth-card h2 { margin: 0 0 4px; font-size: 18px; }
.auth-mark { display: flex; align-items: center; gap: 11px; margin-bottom: 22px; }
.auth-mark .mark {
  width: 32px; height: 32px; border-radius: 8px; flex: none; display: grid; place-items: center;
  background: var(--gray-900); color: #fff; font-weight: 700; font-size: 15px;
}
.auth-name { font-weight: 600; font-size: 13.5px; color: var(--ink); }
.auth-sub { font-size: 11.5px; color: var(--sub); }
.auth-err {
  background: var(--red-b); border: 1px solid var(--red-br); color: var(--red-t);
  border-radius: var(--r-md); padding: 9px 11px; font-size: 12px; margin-bottom: 12px;
}
.auth-go { width: 100%; justify-content: center; margin-top: 4px; }

/* ── the identity chip and its menu ───────────────────────────────────────── */
.avatar.as-btn { cursor: pointer; padding: 0; font-family: inherit; }
.avatar.as-btn:hover { border-color: var(--brand-500); }
.usermenu {
  position: fixed; z-index: 210; width: 250px; background: var(--card);
  border: 1px solid var(--border); border-radius: var(--r-lg);
  box-shadow: 0 12px 28px rgba(16, 24, 40, .14); overflow: hidden;
}
.um-head { padding: 12px 14px; border-bottom: 1px solid var(--border); }
.um-name { font-weight: 600; font-size: 13px; color: var(--ink); }
.um-mail { font-size: 11.5px; color: var(--sub); word-break: break-all; }
.um-role {
  display: inline-block; margin-top: 6px; font-size: 11px; padding: 2px 8px;
  border-radius: 999px; background: var(--indigo-b); color: var(--indigo-t);
  border: 1px solid var(--indigo-br);
}
.um-note {
  padding: 9px 14px; font-size: 11.5px; line-height: 1.5; color: var(--amber-t);
  background: var(--amber-b); border-bottom: 1px solid var(--amber-br);
}
.um-acts { padding: 5px; display: flex; flex-direction: column; }
.um-acts a, .um-acts button {
  display: flex; align-items: center; gap: 9px; padding: 8px 10px; font-size: 12.5px;
  color: var(--body); background: none; border: 0; border-radius: var(--r-sm);
  cursor: pointer; text-align: left; font-family: inherit; text-decoration: none;
}
.um-acts a:hover, .um-acts button:hover { background: var(--gray-50); color: var(--ink); }
.um-acts .danger { color: var(--red-t); }
.um-acts .danger:hover { background: var(--red-b); }

/* ── audit: filter bar ────────────────────────────────────────────────────── */
.kpi-row.five { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.audit-filters { margin-bottom: 14px; padding: 14px 16px; }
.af-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(155px, 1fr));
  gap: 10px 12px; align-items: end;
}
.afl { display: block; font-size: 11px; font-weight: 500; color: var(--sub); text-transform: uppercase; letter-spacing: .03em; }
.afl.grow { grid-column: span 2; }
.afl input, .afl select {
  display: block; width: 100%; margin-top: 4px; box-sizing: border-box;
  border: 1px solid var(--border-strong); border-radius: var(--r-sm);
  padding: 7px 9px; font-size: 12.5px; font-family: var(--font); color: var(--ink);
  background: #fff; text-transform: none; letter-spacing: 0; font-weight: 400;
}
.afl input:focus, .afl select:focus {
  outline: none; border-color: var(--brand-500); box-shadow: 0 0 0 3px var(--brand-ring);
}
.af-actions {
  display: flex; align-items: center; gap: 10px; margin-top: 12px;
  padding-top: 12px; border-top: 1px solid var(--border); flex-wrap: wrap;
}
.af-check { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; color: var(--body); cursor: pointer; }
.af-check input { margin: 0; }

/* ── audit: the trail table ───────────────────────────────────────────────── */
.aud-tbl tbody tr.aud-row { cursor: pointer; }
.aud-tbl tbody tr.aud-row:hover { background: var(--gray-25); }
.aud-tbl tbody tr.aud-row.open { background: var(--brand-50); }
.aud-t { white-space: nowrap; color: var(--sub); font-variant-numeric: tabular-nums; font-size: 11.5px; }
.aud-who b { font-weight: 600; }
.aud-via { font-size: 11px; color: var(--sub); }
.aud-act {
  font-family: var(--mono, ui-monospace, "JetBrains Mono", monospace); font-size: 11px;
  background: var(--gray-100); border: 1px solid var(--border); border-radius: 4px;
  padding: 2px 6px; white-space: nowrap; color: var(--gray-700);
}
.aud-act.red { background: var(--red-b); border-color: var(--red-br); color: var(--red-t); }
.aud-sum { min-width: 240px; }
.aud-n, .aud-caret { text-align: center; white-space: nowrap; }
.aud-caret .ic { color: var(--faint); }
.aud-detail > td { background: var(--gray-25); padding: 0 !important; }
.aud-det {
  display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 20px;
  padding: 14px 16px 18px; border-bottom: 2px solid var(--border);
}
.aud-det-side { border-left: 1px solid var(--border); padding-left: 18px; }
.aud-det-links { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; }
.aud-diff { width: 100%; table-layout: fixed; }
.aud-diff td { vertical-align: top; word-break: break-word; }
.aud-f {
  font-family: var(--mono, ui-monospace, "JetBrains Mono", monospace);
  font-size: 11px; color: var(--indigo-t); width: 30%;
}
.aud-old .aud-val { background: var(--red-b); color: var(--red-t); border-radius: 3px; padding: 1px 4px; }
.aud-new .aud-val { background: var(--green-b); color: var(--green-t); border-radius: 3px; padding: 1px 4px; }
.aud-nil { color: var(--faint); }
.aud-more { padding: 12px 4px 2px; text-align: center; }

/* ── record history drawer ────────────────────────────────────────────────── */
.rh-item { padding: 10px 0; border-bottom: 1px solid var(--gray-100); }
.rh-item:last-child { border-bottom: none; }
.rh-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }

/* ── accounts ─────────────────────────────────────────────────────────────── */
.pw-reveal {
  display: flex; align-items: center; gap: 10px; margin: 12px 0;
  background: var(--gray-50); border: 1px solid var(--border-strong);
  border-radius: var(--r-md); padding: 12px 14px;
}
.pw-reveal code {
  flex: 1; font-size: 14px; letter-spacing: .04em; word-break: break-all; color: var(--ink);
}

@media (max-width: 1100px) {
  .aud-det { grid-template-columns: 1fr; }
  .aud-det-side { border-left: 0; padding-left: 0; border-top: 1px solid var(--border); padding-top: 14px; }
  .kpi-row.five { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
