:root {
  --navy-0: #0F1628; --navy-1: #1B2540; --panel: #1B2540; --panel-2: #243150;
  --ink: #FFFFFF; --muted: #848B9B; --line: #2A3550;
  --amber: #C6AF5C; --gold: #C6AF5C; --green: #3FA34D; --red: #C0473A;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { max-width: 100%; overflow-x: hidden; }
body {
  /* Fill the viewport and let MAIN scroll, so the header and footer stay static and the
     scrollbar sits above the footer (the footer never scrolls away). */
  margin: 0; height: 100vh; overflow: hidden; display: flex; flex-direction: column;
  background: var(--navy-0); color: var(--ink);
  font-family: 'Helvetica Neue', Arial, sans-serif;
}
a { color: var(--gold); }

/* ---- Header ---- */
.brandwrap { display: flex; align-items: center; gap: .85rem; min-width: 0; }
/* Tagline fills the leftover of the logo cell and centers in it, sitting between the
   wordmark and the centered classification pill. */
.brand-tag { flex: 1; text-align: center; color: var(--muted); font-size: .8rem; font-style: italic; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 1100px) { .brand-tag { display: none; } }
header.appbar {
  flex: 0 0 auto;   /* static at the top; main scrolls below it */
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  gap: 1rem; padding: .5rem 1.25rem;
  background: linear-gradient(180deg, var(--navy-1), var(--navy-0));
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: .55rem; justify-self: start; text-decoration: none; }
.brand .emblem { height: 38px; width: auto; display: block; margin-left: .5rem; transform-origin: center; animation: mf-spin 0.9s ease-out 1; }
@keyframes mf-spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
.brand .wm { font-weight: 800; font-size: 1.4rem; letter-spacing: .01em; line-height: 1; }
.brand .wm .m { color: #c4ccd4; }
.brand .wm .f { background: linear-gradient(180deg, var(--gold), var(--amber)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.pill {
  justify-self: center; text-transform: uppercase; font-weight: 700;
  letter-spacing: .06em; color: #fff; border-radius: 999px;
  padding: .25rem .9rem; line-height: 1.1; box-shadow: 0 1px 3px rgba(0,0,0,.25);
  background: #555; white-space: nowrap; font-size: .8rem;
}
.account { justify-self: end; display: flex; align-items: center; gap: .75rem; min-height: 38px; }
.cyclebar { display: flex; align-items: center; gap: .4rem; padding-right: .75rem; margin-right: .25rem; border-right: 1px solid var(--line); }
.cyclebar-label { color: var(--muted); font-size: .68rem; text-transform: uppercase; letter-spacing: .05em; }
.cycle-select { padding: .25rem .5rem; font-size: .82rem; max-width: 12rem; }
.cycle-new { padding: .25rem .5rem; font-weight: 700; line-height: 1; }
.mf-modal { position: fixed; inset: 0; z-index: 100; display: none; align-items: center; justify-content: center; background: rgba(6,12,20,.6); }
.mf-modal-card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 1.25rem; width: min(92vw, 24rem); box-shadow: 0 12px 40px rgba(0,0,0,.5); }
.mf-modal-card h3 { margin: 0 0 .35rem; font-size: 1.05rem; }
.mf-modal-sub { color: var(--muted); font-size: .8rem; margin: 0 0 .85rem; line-height: 1.35; }
.mf-modal-card .field { margin-bottom: .65rem; }
.mf-modal-card .field input { width: 100%; }
.mf-check { display: flex; align-items: center; gap: .5rem; font-size: .82rem; color: var(--muted); margin: .15rem 0 .25rem; }
.mf-check input { width: auto; }
.mf-modal-msg { color: var(--gold); font-size: .8rem; min-height: 1rem; margin: .25rem 0 0; }
.mf-modal-actions { display: flex; justify-content: flex-end; gap: .5rem; margin-top: .75rem; }
.who { line-height: 1.15; display: flex; flex-direction: column; text-align: left; }
.who .name { font-weight: 700; font-size: .9rem; }
.who .role { font-size: .72rem; color: var(--muted); }

/* Account dropdown (user menu: product overview, version, logout) */
.acct { position: relative; }
.acct-btn { display: flex; align-items: center; gap: .5rem; background: transparent; color: var(--ink);
  border: 1px solid var(--line); border-radius: 6px; padding: .3rem .6rem; cursor: pointer; font-family: inherit; }
.acct-btn:hover { border-color: #C6AF5C55; }
.acct-btn .caret { color: var(--muted); font-size: .8rem; }
.acct-btn .acct-ava { width: 28px; height: 28px; flex: none; border-radius: 50%; background: #C6AF5C1a; border: 1px solid #C6AF5C44; display: flex; align-items: center; justify-content: center; }
.acct-btn .acct-ava svg { width: 16px; height: 16px; fill: none; stroke: var(--gold); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.acct-drop { position: absolute; right: 0; top: calc(100% + .35rem); min-width: 15rem; z-index: 60;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: .35rem;
  box-shadow: 0 8px 24px rgba(0,0,0,.45); }
.acct-meta { padding: .45rem .6rem .55rem; border-bottom: 1px solid var(--line); margin-bottom: .25rem; }
.acct-meta-name { display: block; font-weight: 600; font-size: .88rem; color: var(--ink); }
.acct-meta-role { display: block; font-size: .78rem; color: var(--gold); margin-top: .18rem; line-height: 1.3; }
.acct-meta-email { display: block; font-size: .72rem; color: var(--muted); margin-top: .12rem; }
.acct-item { display: block; padding: .45rem .6rem; border-radius: 6px; color: var(--ink); text-decoration: none; font-size: .88rem; }
.acct-item:hover { background: #C6AF5C1a; }
.acct-item.danger { color: var(--gold); }
.acct-ver { padding: .4rem .6rem; color: var(--muted); font-size: .75rem; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); margin: .25rem 0; }
.acct-navhdr { padding: .35rem .6rem .2rem; color: var(--muted); font-size: .66rem; letter-spacing: .14em; text-transform: uppercase; }
.acct-item.nav { display: flex; align-items: center; gap: .6rem; color: #c7cdd6; }
.acct-item.nav .ai-ic { display: inline-flex; width: 1.05rem; color: var(--muted); }
.acct-item.nav .ai-ic svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; display: block; }
.acct-item.nav:hover { color: var(--ink); }
.acct-item.nav.active { color: var(--gold); background: #C6AF5C12; }
.acct-item.nav.active .ai-ic { color: var(--gold); }
.acct-sep { height: 1px; background: var(--line); margin: .35rem .2rem; }
.appbar-spacer { min-width: 0; }

/* ---- Buttons / inputs ---- */
.btn {
  background: transparent; color: var(--gold); border: 1px solid #C6AF5C55;
  padding: .4rem .8rem; border-radius: 6px; font-size: .82rem; cursor: pointer;
  text-decoration: none; display: inline-flex; align-items: center; gap: .35rem;
}
.btn:hover { background: #C6AF5C1a; }
.btn.primary { background: linear-gradient(180deg, var(--gold), var(--amber)); color: #1b1b1b; border: none; font-weight: 700; }
.btn.danger { color: var(--red); border-color: #C0473A66; }
.btn.danger:hover { background: #C0473A1a; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.pginfo.hint-warn { color: var(--gold); font-weight: 600; }
/* Term-sheet structured form editor (label/value rows under section headers). */
.ts-form { max-height: 48vh; overflow-y: auto; border: 1px solid var(--line); border-radius: 8px; padding: .6rem .8rem; background: var(--panel-2); }
.ts-form .ts-sec { font-weight: 700; color: var(--gold); text-transform: uppercase; font-size: .72rem; letter-spacing: .04em; margin: .8rem 0 .35rem; border-bottom: 1px solid var(--line); padding-bottom: .2rem; }
.ts-form .ts-sec:first-child { margin-top: 0; }
.ts-form .ts-row { display: flex; align-items: center; gap: .6rem; margin: .25rem 0; }
.ts-form .ts-lab { flex: 0 0 16rem; font-size: .82rem; color: var(--muted); }
.ts-form .ts-inp { flex: 1; }
.btn.primary:hover { filter: brightness(1.05); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
input, select {
  background: var(--panel-2); color: var(--ink); border: 1px solid var(--line);
  border-radius: 6px; padding: .4rem .6rem; font-size: .9rem; font-family: inherit;
}

/* ---- Main / layout ---- */
main { flex: 1 1 auto; overflow-y: auto; min-height: 0; padding: .4rem clamp(1rem, 4vw, 3rem) 1rem; width: 100%; max-width: 100%; min-width: 0; }
.appbar > * { min-width: 0; }
.account { overflow: visible; }
.table-scroll { max-width: 100%; }
.title-row { display: flex; align-items: baseline; gap: .75rem; margin-bottom: .6rem; flex-wrap: wrap; }
.title-row h1 { font-size: 1.1rem; margin: 0; }
.title-row .sub { color: var(--muted); font-size: .9rem; }
.title-row .spacer { flex: 1; }

/* ---- Cards ---- */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: .7rem; }
.card {
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line); border-radius: 10px; padding: .95rem 1rem;
}
.card .k { font-size: 1.7rem; font-weight: 800; color: var(--gold); }
.card .l { color: var(--muted); font-size: .68rem; margin-top: .1rem; text-transform: uppercase; letter-spacing: .05em; }
.card.accent { border-color: #C6AF5C66; }

/* Dashboard fills the viewport: the "At a glance" charts absorb the remaining height, so they're
   as large as possible without ever pushing the page into a scrollbar. */
@media (min-width: 900px) {
  main.dash { display: flex; flex-direction: column; min-height: calc(100vh - 104px); }
  main.dash > section.block { flex: 1 1 auto; display: flex; flex-direction: column; min-height: 260px; }
  main.dash > section.block .charts { flex: 1; grid-template-rows: 1fr; align-items: stretch; }
  main.dash > section.block .chart-card { display: flex; flex-direction: column; height: 100%; }
  main.dash > section.block .chart-card .wrap { flex: 1; height: auto !important; min-height: 220px; }
}

/* ---- Sections / tables ---- */
section.block { margin-top: 1.75rem; }
section.block h2 { font-size: 1rem; margin: 0 0 .6rem; }
.table-scroll { max-height: 38vh; overflow: auto; border: 1px solid var(--line); border-radius: 10px; }
/* Auto-fit data-grid pages: the grid consumes the leftover viewport height, so it's always
   full and the page never scrolls — no per-page vh tuning, adapts to charts shown/hidden.
   Handles #grid as a direct child of main OR wrapped in a section.block. */
main.grid-page { display: flex; flex-direction: column; }
main.grid-page > #grid,
main.grid-page > .block:has(> #grid) { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
main.grid-page > .block:has(> #grid) > #grid { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
main.grid-page #grid .table-scroll { flex: 1 1 auto; max-height: none; min-height: 140px; }
thead th.sortable { cursor: pointer; user-select: none; }
thead th.sortable:hover { color: var(--ink); }
.sortarrow { color: var(--gold); }

/* Editable-grid: drag handle + cycle drop-zones (drag rows to another POM cycle) */
.rv-table td.rv-gripcell { text-align: center; padding-left: .3rem; padding-right: .3rem; }
.rv-table .rv-grip { cursor: grab; color: var(--muted); user-select: none; font-size: 1rem; }
.rv-table .rv-grip:active { cursor: grabbing; }
.rv-table td.rv-movecell { text-align: center; padding-left: .2rem; padding-right: .2rem; }
.rv-table .rv-rowmove { padding: 0 .25rem; border: 1px solid transparent; border-radius: 5px;
  background: transparent; color: var(--muted); font-size: 1.05rem; font-weight: 700; line-height: 1.2; cursor: pointer; vertical-align: middle; }
.rv-table .rv-rowmove:hover, .rv-table .rv-rowmove:focus { background: var(--panel-2); color: var(--ink); border-color: var(--line); outline: none; }
.rv-table tr.rv-dragging { opacity: .45; }
.rv-table thead th { cursor: pointer; }
.rv-table thead th .sortarrow { color: var(--gold); font-size: .8rem; }
/* Show/hide columns dropdown for the editable grid. */
.mf-colpanel { position: absolute; z-index: 60; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: .5rem .65rem; display: grid; gap: .3rem; box-shadow: 0 8px 24px rgba(0,0,0,.5); max-height: 60vh; overflow: auto; }
.mf-colpanel label { display: flex; align-items: center; gap: .45rem; font-size: .85rem; color: var(--ink); white-space: nowrap; cursor: pointer; }
.rv-dropzones { display: inline-flex; align-items: center; gap: .35rem; flex-wrap: wrap; }
.rv-dz-label { color: var(--muted); font-size: .78rem; }
.rv-chip { display: inline-flex; align-items: center; padding: .25rem .6rem; border-radius: 999px;
  border: 1px dashed var(--line); color: var(--muted); font-size: .8rem; white-space: nowrap; transition: all .12s ease; }
.rv-chip.armed { border-color: var(--gold); color: var(--ink); }
.rv-chip.over { background: var(--gold); border-style: solid; border-color: var(--gold); color: #1b1b1b; font-weight: 700; }
/* Right-click "move row" menu — accessible alternative to drag-and-drop. */
.rv-ctxmenu { position: absolute; z-index: 200; background: var(--panel); border: 1px solid var(--line);
  border-radius: 8px; padding: .3rem; min-width: 11rem; max-height: 60vh; overflow-y: auto;
  box-shadow: 0 10px 28px rgba(0,0,0,.55); }
.rv-ctxmenu .rv-ctxhdr { position: sticky; top: 0; background: var(--panel); }
.rv-ctxmenu[hidden] { display: none; }
.rv-ctxhdr { padding: .35rem .55rem .4rem; font-size: .72rem; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); border-bottom: 1px solid var(--line); margin-bottom: .25rem; }
.rv-ctxitem { display: block; width: 100%; text-align: left; padding: .45rem .6rem; border: none; border-radius: 6px;
  background: transparent; color: var(--ink); font-size: .86rem; cursor: pointer; white-space: nowrap; }
.rv-ctxitem:not(:disabled):hover, .rv-ctxitem:not(:disabled):focus { background: var(--gold); color: #1b1b1b; outline: none; }
.rv-ctxitem:disabled { opacity: .4; cursor: default; }
/* Visible ⋮ "move" affordance auto-placed on each board card (top-right corner). */
.rv-kebab { position: absolute; top: 50%; right: 8px; transform: translateY(-50%); width: 26px; height: 26px;
  padding: 0; line-height: 22px; text-align: center; font-size: 18px; font-weight: 700; border: 1px solid transparent;
  border-radius: 6px; background: transparent; color: var(--muted); cursor: pointer; z-index: 2; }
.rv-kebab:hover, .rv-kebab:focus { background: var(--panel-2); color: var(--ink); border-color: var(--line); outline: none; }
.table-scroll table { border: none; border-radius: 0; }
table { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
th, td { text-align: left; padding: .6rem .8rem; border-bottom: 1px solid var(--line); font-size: .86rem; }
th { background: var(--panel-2); color: var(--muted); text-transform: uppercase; letter-spacing: .04em; font-size: .72rem; }
tr:last-child td { border-bottom: none; }
thead th { position: sticky; top: 0; z-index: 1; }
.pager { display: flex; align-items: center; gap: 1rem; margin-top: .6rem; flex-wrap: wrap; }
.pager .pgleft { display: flex; align-items: center; gap: .5rem; }
.pager .pgright { display: flex; align-items: center; gap: 1rem; margin-left: auto; flex-wrap: wrap; }
.pager .pginfo { color: var(--muted); font-size: .8rem; }
.pginfo { color: var(--muted); font-size: .84rem; line-height: 1.35; }
.pager .pgsize { color: var(--muted); font-size: .8rem; display: flex; align-items: center; gap: .4rem; }
.pager .pgselect { padding: .2rem .4rem; }
.pager .pgnav { display: flex; align-items: center; gap: .5rem; }
.pager .pgbtn { padding: .2rem .55rem; }

/* Per-column filter funnel + popup (GridSquare-style) */
thead th .funnel { display: inline-flex; align-items: center; margin-left: .35rem; cursor: pointer; opacity: .45; vertical-align: middle; }
thead th .funnel:hover { opacity: 1; color: var(--ink); }
thead th .funnel.active { opacity: 1; color: var(--gold); }
.mf-filterpop {
  position: absolute; z-index: 60; display: none; min-width: 12.5rem;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px;
  padding: .6rem; box-shadow: 0 8px 24px rgba(0,0,0,.45);
}
.mf-filterpop .mf-fp-row { margin-bottom: .5rem; }
.mf-filterpop select, .mf-filterpop input { width: 100%; }
.mf-filterpop .mf-fp-actions { display: flex; justify-content: flex-end; gap: .5rem; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.tag { display: inline-block; padding: .1rem .5rem; border-radius: 999px; font-size: .72rem; font-weight: 700; }
.p-Critical { background: #C8102E33; color: #ff8a8a; }
.p-High { background: #C6AF5C33; color: var(--gold); }
.p-Medium { background: #2f6db033; color: #9cc4ee; }
.p-Low { background: #4a5a6a33; color: var(--muted); }
.empty { color: var(--muted); padding: 1rem; }

/* ---- One-line "Load data" toolbar + on-demand panels ---- */
.loadbar { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; margin-top: 1.25rem; }
.loadbar-label { color: var(--muted); font-size: .85rem; }
.loadbody { margin-top: .75rem; }

/* ---- COA builder ---- */
.builder-controls { display: flex; gap: 1rem; align-items: flex-end; flex-wrap: wrap; margin-bottom: 1rem; }
.field { display: flex; flex-direction: column; gap: .25rem; }
.field label { font-size: .72rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: .75rem; margin: 1rem 0; }
.bar { height: 12px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 999px; overflow: hidden; margin-top: .5rem; }
.bar > span { display: block; height: 100%; background: linear-gradient(90deg, var(--amber), var(--gold)); transition: width .5s ease, background .3s ease; }
.bar.over > span { background: var(--red); }
@keyframes mf-flash { from { background: rgba(63,191,127,.35); } to { background: transparent; } }
tr.mf-flash > td { animation: mf-flash .9s ease-out; }
tr.funded td:first-child { border-left: 3px solid var(--green); }
tr.unfunded td { color: var(--muted); }
tr.unfunded td:first-child { border-left: 3px solid var(--line); }
.dot { display: inline-block; width: .6rem; height: .6rem; border-radius: 50%; margin-right: .4rem; }
.dot.green { background: var(--green); }
.dot.gray { background: #4a5a6a; }

/* ---- Drag-and-drop COA board ---- */
.coa-board { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; align-items: start; }
@media (max-width: 880px) { .coa-board { grid-template-columns: 1fr; } }
.coa-col {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  display: flex; flex-direction: column; min-height: 180px;
}
.coa-col > header {
  display: flex; align-items: center; gap: .5rem; padding: .7rem .9rem;
  border-bottom: 1px solid var(--line); font-size: .78rem; text-transform: uppercase;
  letter-spacing: .05em; color: var(--muted);
}
.coa-col > header .pill {
  margin-left: auto; background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 999px; padding: .1rem .5rem; font-size: .72rem; color: var(--ink);
}
.coa-col .lane-cap { font-size: .72rem; color: var(--muted); text-transform: none; letter-spacing: 0; }
.coa-col[data-lane="force"]   { border-top: 3px solid var(--green); }
.coa-col[data-lane="auto"]    { border-top: 3px solid var(--amber); }
.coa-col[data-lane="exclude"] { border-top: 3px solid #4a5a6a; }
.coa-drop { flex: 1; padding: .6rem; display: flex; flex-direction: column; gap: .5rem; min-height: 90px; }
.coa-drop.drag-over { background: #C6AF5C12; outline: 2px dashed #C6AF5C66; outline-offset: -6px; border-radius: 8px; }
.coa-drop .lane-empty { color: var(--muted); font-size: .8rem; text-align: center; padding: 1.2rem .5rem; }

.coa-card {
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line); border-radius: 10px; padding: .55rem .65rem;
  cursor: grab; transition: border-color .12s ease, transform .12s ease, box-shadow .12s ease;
}
.coa-card:hover { border-color: #C6AF5C66; }
.coa-card:active { cursor: grabbing; }
.coa-card.dragging { opacity: .5; transform: scale(.98); }
.coa-card .ttl { font-size: .86rem; font-weight: 600; display: flex; gap: .4rem; align-items: baseline; }
.coa-card .grip { color: #5f7385; font-size: .9rem; cursor: grab; }
.coa-card .pgm { color: var(--muted); font-size: .76rem; margin: .2rem 0 .35rem; }
.coa-card .meta { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; font-size: .76rem; color: var(--muted); }
.coa-card .meta .num { color: var(--ink); font-weight: 600; }
.coa-card .outcome { margin-left: auto; font-weight: 700; font-size: .74rem; }
.coa-card .outcome.green { color: var(--green); }
.coa-card .outcome.gray { color: #7e8c9a; }
.coa-card.is-funded { border-left: 3px solid var(--green); }
.coa-card.is-unfunded { border-left: 3px solid #4a5a6a; }

/* ---- Approvals Kanban ---- */
.kanban { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; align-items: start; }
@media (max-width: 980px) { .kanban { grid-template-columns: repeat(2, 1fr); } }
.kan-col { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; display: flex; flex-direction: column; min-height: 160px; }
.kan-col > header { display: flex; align-items: center; gap: .5rem; padding: .65rem .85rem; border-bottom: 1px solid var(--line); font-size: .76rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.kan-col > header .pill { margin-left: auto; background: var(--panel-2); border: 1px solid var(--line); border-radius: 999px; padding: .1rem .5rem; font-size: .72rem; color: var(--ink); }
.kan-col[data-status="Draft"]       { border-top: 3px solid #5f7385; }
.kan-col[data-status="UnderReview"] { border-top: 3px solid var(--amber); }
.kan-col[data-status="Approved"]    { border-top: 3px solid var(--green); }
.kan-col[data-status="Rejected"]    { border-top: 3px solid var(--red); }
.kan-drop { flex: 1; padding: .55rem; display: flex; flex-direction: column; gap: .5rem; min-height: 80px; }
.kan-drop.drag-over { background: #C6AF5C12; outline: 2px dashed #C6AF5C66; outline-offset: -6px; border-radius: 8px; }
.kan-drop .lane-empty { color: var(--muted); font-size: .8rem; text-align: center; padding: 1rem .5rem; }
.kan-card { background: linear-gradient(180deg, var(--panel-2), var(--panel)); border: 1px solid var(--line); border-radius: 10px; padding: .5rem .6rem; cursor: grab; }
.kan-card:hover { border-color: #C6AF5C66; }
.kan-card.dragging { opacity: .5; }
.kan-card .ttl { font-size: .84rem; font-weight: 600; }
.kan-card .meta { display: flex; gap: .4rem; align-items: center; margin-top: .35rem; flex-wrap: wrap; font-size: .74rem; color: var(--muted); }

/* ---- Drag-to-rank list ---- */
.rank-list { display: flex; flex-direction: column; gap: .5rem; max-width: 820px; }
.rank-item { display: flex; align-items: center; gap: .75rem; background: linear-gradient(180deg, var(--panel-2), var(--panel)); border: 1px solid var(--line); border-radius: 10px; padding: .55rem .7rem; cursor: grab; }
.rank-item:hover { border-color: #C6AF5C66; }
.rank-item.dragging { opacity: .5; }
.rank-item.drop-before { box-shadow: 0 -3px 0 var(--gold); }
.rank-item.drop-after  { box-shadow: 0 3px 0 var(--gold); }
.rank-item .badge { width: 2rem; height: 2rem; flex: 0 0 auto; display: flex; align-items: center; justify-content: center; border-radius: 8px; font-weight: 800; background: #C6AF5C1a; border: 1px solid #C6AF5C33; color: var(--gold); }
.rank-item .grip { color: #5f7385; font-size: 1rem; }
.rank-item .body { flex: 1; }
.rank-item .body .t { font-size: .9rem; font-weight: 600; }
.rank-item .body .s { font-size: .76rem; color: var(--muted); }
.rank-item .rank-actions { display: inline-flex; gap: .3rem; flex: 0 0 auto; }
.rank-item .rank-actions .pgbtn { padding: .15rem .45rem; cursor: pointer; }

/* ---- Visual ZBT builder ---- */
.zbt-build { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; align-items: start; }
@media (max-width: 880px) { .zbt-build { grid-template-columns: 1fr; } }
.pe-grid { display: grid; grid-template-columns: 1fr; gap: .5rem; max-height: 38vh; overflow: auto; padding: .25rem; }
/* Fit the viewport: the Programs/package row flexes into the space left below the chart,
   and the program list fills its column (scrolling internally) so the page never scrolls. */
main.zbt-page { display: flex; flex-direction: column; }
main.zbt-page > .zbt-build { flex: 1 1 auto; min-height: 0; align-items: stretch; }
main.zbt-page > .zbt-build > section.block { min-height: 0; display: flex; flex-direction: column; }
main.zbt-page .pe-grid { flex: 1 1 auto; min-height: 120px; max-height: none; }
.pe-card { background: linear-gradient(180deg, var(--panel-2), var(--panel)); border: 1px solid var(--line); border-radius: 10px; padding: .55rem .7rem; cursor: grab; }
.pe-card[data-role="donor"] { cursor: grab; }
.pe-card.dragging { opacity: .5; }
.pe-card.drag-over { outline: 2px dashed #3fbf7f88; outline-offset: -5px; }
.pe-card .c { font-weight: 700; font-size: .86rem; }
.pe-card .n { color: var(--muted); font-size: .76rem; }
.pe-card .delta { float: right; font-weight: 700; font-size: .82rem; }
.pe-card .delta.pos { color: var(--green); }
.pe-card .delta.neg { color: var(--red); }
.meter { background: var(--panel-2); border: 1px solid var(--line); border-radius: 999px; height: 14px; overflow: hidden; margin: .5rem 0; }
.meter > span { display: block; height: 100%; background: linear-gradient(90deg, var(--amber), var(--gold)); width: 0; }
.balance-ok { color: var(--green); font-weight: 700; }
.balance-bad { color: var(--red); font-weight: 700; }

/* ---- Treemap ---- */
.tm-bread { display: flex; gap: .4rem; align-items: center; color: var(--muted); font-size: .85rem; margin-bottom: .6rem; flex-wrap: wrap; }
.tm-bread a { color: var(--gold); cursor: pointer; text-decoration: none; }
.tm-bread .sep { color: #5f7385; }
.treemap { position: relative; width: 100%; height: 62vh; min-height: 380px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); overflow: hidden; }
.tm-tile { position: absolute; border: 2px solid var(--navy-0); border-radius: 6px; overflow: hidden; cursor: pointer; transition: filter .1s ease; padding: .35rem .45rem; box-sizing: border-box; }
.tm-tile:hover { filter: brightness(1.12); }
.tm-tile .tl { font-size: .78rem; font-weight: 700; color: #0c151f; line-height: 1.1; word-break: break-word; }
.tm-tile .tv { font-size: .72rem; color: #0c151fcc; margin-top: .15rem; }

/* ---- Sankey ---- */
.sankey-wrap { border: 1px solid var(--line); border-radius: 12px; background: var(--panel); padding: .5rem; overflow-x: auto; }
.sankey-node rect { rx: 3; }
.sankey-link { fill: none; opacity: .45; transition: opacity .12s ease; }
.sankey-link:hover { opacity: .8; }
.sankey-label { fill: var(--ink); font-size: 11px; }
.sankey-amt { fill: var(--muted); font-size: 10px; }

/* ---- Hub tiles ---- */
.welcome { margin-bottom: 1.25rem; }
.welcome .hi { font-size: 1.5rem; font-weight: 800; }
.welcome .sub { color: var(--muted); margin-top: .15rem; }
/* Fixed-width, left-aligned tiles so every tile is the SAME size regardless of how many are in a tab. */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, 230px); gap: .85rem; justify-content: start; }
.tile-group { margin: 1.5rem 0 .6rem; font-size: .78rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .08em; color: var(--gold); display: flex; align-items: center; gap: .6rem; }
.tile-group::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.tile-group:first-of-type { margin-top: .4rem; }
.flowhint { color: var(--muted); font-size: .9rem; margin: .2rem 0 .4rem; }
.flowhint strong { color: var(--gold); font-weight: 600; }
.tile {
  display: flex; flex-direction: column; gap: .35rem; padding: .8rem .9rem; min-height: 178px;
  border: 1px solid var(--line); border-radius: 12px; position: relative;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  text-decoration: none; color: var(--ink); transition: transform .12s ease, border-color .12s ease;
}
.tile:hover { border-color: #C6AF5C66; transform: translateY(-2px); }
/* Tiles rise + fade in with a slight stagger on load */
@keyframes mf-rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.tiles .tile { animation: mf-rise .4s ease-out both; }
.tiles .tile:nth-child(1) { animation-delay: .03s; }
.tiles .tile:nth-child(2) { animation-delay: .06s; }
.tiles .tile:nth-child(3) { animation-delay: .09s; }
.tiles .tile:nth-child(4) { animation-delay: .12s; }
.tiles .tile:nth-child(5) { animation-delay: .15s; }
.tiles .tile:nth-child(6) { animation-delay: .18s; }
.tiles .tile:nth-child(7) { animation-delay: .21s; }
.tiles .tile:nth-child(8) { animation-delay: .24s; }
.tiles .tile:nth-child(9) { animation-delay: .27s; }
.tiles .tile:nth-child(n+10) { animation-delay: .30s; }
@media (prefers-reduced-motion: reduce) { .tiles .tile { animation: none; } }
.tile.soon { opacity: .65; pointer-events: none; }
/* Feature-flagged "Labs" tiles: hidden unless Features:Labs is enabled (body.labs-on). */
.lab-only { display: none; }
body.labs-on .lab-only { display: flex; }
.admin-only { display: none; }
body.admin-on .admin-only { display: flex; }
.tile .ic {
  width: 34px; height: 34px; border-radius: 9px; display: flex; align-items: center; justify-content: center;
  background: #C6AF5C1a; border: 1px solid #C6AF5C33;
}
.tile .ic svg { width: 18px; height: 18px; stroke: var(--gold); fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tile h3 { margin: .15rem 0 0; font-size: .96rem; }
.tile p { margin: 0; color: var(--muted); font-size: .8rem; line-height: 1.3; }
.tile .meta { margin-top: auto; padding-top: .3rem; }
.tile .count { font-size: 1.25rem; font-weight: 800; color: var(--gold); }
.tile .count small { font-size: .8rem; color: var(--muted); font-weight: 400; margin-left: .25rem; }
.badge-soon {
  position: absolute; top: .8rem; right: .8rem; font-size: .6rem; text-transform: uppercase;
  letter-spacing: .06em; background: #4a5a6a33; color: var(--muted); padding: .15rem .45rem;
  border-radius: 999px; border: 1px solid var(--line);
}

/* ---- Dashboard tabs ---- */
.tabbar { display: flex; gap: .25rem; flex-wrap: wrap; border-bottom: 1px solid var(--line); margin: .25rem 0 1.25rem; }
.tab { background: transparent; border: 1px solid transparent; border-bottom: none; color: var(--muted); padding: .6rem 1.1rem; border-radius: 8px 8px 0 0; cursor: pointer; font-size: .9rem; font-family: inherit; margin-bottom: -1px; }
.tab:hover { color: var(--ink); background: #ffffff0a; }
.tab.active { color: var(--gold); border-color: var(--line); border-bottom-color: var(--navy-0); background: var(--panel); font-weight: 600; }
.panel-sub { color: var(--muted); font-size: .85rem; margin: 0 0 1.1rem; }
.welcome-row { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem 1.5rem; flex-wrap: wrap; }
.ppbe { color: var(--muted); font-size: .8rem; letter-spacing: .02em; margin-left: auto; white-space: nowrap; }
.ppbe strong { color: var(--gold); font-weight: 700; }

/* Collapsible sections (native <details>) — keep everything, just foldable */
details.collapsible { margin-top: 1.5rem; }
details.collapsible > summary { cursor: pointer; list-style: none; font-size: 1rem; font-weight: 700;
  color: var(--ink); display: flex; align-items: center; gap: .5rem; padding: .25rem 0; }
details.collapsible > summary::-webkit-details-marker { display: none; }
details.collapsible > summary::marker { content: ""; }
details.collapsible > summary::before { content: "\25B8"; color: var(--gold); width: .9rem; display: inline-block; }
details.collapsible[open] > summary::before { content: "\25BE"; }
details.collapsible > summary:hover { color: var(--gold); }
details.collapsible > *:not(summary) { margin-top: .6rem; }

/* ---- Dashboard tier headings (legacy) ---- */
.tier-head { display: flex; align-items: baseline; gap: .75rem; flex-wrap: wrap; margin: 1.9rem 0 .9rem; padding-bottom: .4rem; border-bottom: 1px solid var(--line); }
.tier-head:first-of-type { margin-top: .5rem; }
.tier-head h2 { margin: 0; font-size: 1.05rem; letter-spacing: .01em; }
.tier-head span { color: var(--muted); font-size: .85rem; }

/* ---- Charts ---- */
/* One-line portfolio summary strip above heavy charts/grids. */
.summary-strip { display: flex; flex-wrap: wrap; gap: 1.5rem; align-items: baseline; padding: .6rem .9rem; margin: 0 0 .8rem;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; color: var(--muted); font-size: .9rem; }
.summary-strip strong { color: var(--ink); font-size: 1.05rem; }
/* Exception/alert strip linking into the Anomalies page. */
.flag-strip { margin: -.2rem 0 .8rem; }
/* Flag tucked on the right of the summary strip (saves a line). */
.summary-strip .flag-inline { margin-left: auto; align-self: center; display: inline-block;
  padding: .3rem .7rem; border-radius: 8px; font-size: .82rem; font-weight: 600;
  color: #ffb3b3; border: 1px solid #ff8a8a55; background: #ff8a8a18; }
.summary-strip .flag-inline:hover { background: #ff8a8a2c; }
.flag-strip a { display: inline-block; padding: .45rem .8rem; border-radius: 8px; font-size: .88rem; font-weight: 600;
  color: #ffd0a8; background: #ff8a8a18; border: 1px solid #ff8a8a44; text-decoration: none; }
.flag-strip a:hover { background: #ff8a8a2c; }
/* Chart filter toolbar (search + Top-N) above a .charts grid. */
.chartfilter { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; margin: 0 0 1rem; }
.chartfilter input[type="search"] { min-width: 16rem; padding: .4rem .6rem; }
.chartfilter label { color: var(--muted); font-size: .85rem; display: inline-flex; align-items: center; gap: .4rem; }
.chartfilter .pginfo { color: var(--muted); font-size: .82rem; }
/* Segmented level toggle (By Component | By Program) + drill breadcrumb. */
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { background: transparent; color: var(--muted); border: none; padding: .35rem .75rem; cursor: pointer; font-size: .85rem; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.active { background: #C6AF5C; color: #0c151f; font-weight: 600; }
.crumb { display: inline-flex; align-items: center; gap: .45rem; font-size: .85rem; color: var(--muted); }
.crumb .crumb-cur { color: var(--ink); font-weight: 600; }
/* Compact variant for a filter inside a chart-card header. */
.chart-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin: 0 0 .6rem; }
.chart-head h3 { margin: 0; }
.chartfilter.compact { margin: 0; gap: .4rem; }
.chartfilter.compact input[type="search"] { min-width: 7rem; padding: .25rem .45rem; font-size: .8rem; }
.chartfilter.compact select { padding: .2rem .35rem; font-size: .8rem; }
.charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1rem; }
/* Full-width single chart row: lets a growable chart expand without skewing a grid of fixed ones. */
.charts.charts-1col { grid-template-columns: 1fr; margin-bottom: 1rem; }
/* Split row: a dominant chart (left) beside a compact one (right), no wasted space.
   Cards stretch to equal height and the chart fills, so panel bottoms align even when one
   card has a taller header (e.g. a filter toolbar). */
.charts.charts-split { grid-template-columns: minmax(0, 3fr) minmax(280px, 1fr); align-items: stretch; }
.charts-split .chart-card { display: flex; flex-direction: column; }
.charts-split .chart-card > .wrap { flex: 1 1 auto; height: auto; min-height: 240px; }
@media (max-width: 720px) { .charts.charts-split { grid-template-columns: 1fr; } }
.chart-card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 1rem 1.1rem; }
.chart-card h3 { margin: 0 0 .6rem; font-size: .92rem; color: var(--ink); }
/* Default height; category charts override it inline (mfFitChart) to grow with the data
   so the page scrolls rather than a cramped inner scroll-box. Past mfFitChart's optional
   maxPx the wrap caps and scrolls internally (.scrolly) so the page stays ~one screen. */
.chart-card .wrap { position: relative; height: 260px; }
.chart-card .wrap.scrolly { overflow-y: auto; overflow-x: hidden; }
.chart-card .canvas-host { position: relative; width: 100%; height: 100%; }
/* Cards align to the top of a row so the charts stay aligned as they grow. */
.charts { align-items: start; }

/* ---- Footer ---- */
footer {
  flex: 0 0 auto;   /* static at the bottom; main scrolls above it */
  position: relative;
  display: flex; align-items: center; justify-content: center;
  min-height: 2.75rem;
  text-align: center; padding: .75rem clamp(1rem, 4vw, 3rem); color: var(--muted); font-size: .8rem;
  border-top: 1px solid var(--line); background: var(--navy-0);
}
footer .foot-powered {
  position: absolute; left: clamp(1rem, 4vw, 3rem); top: 50%; transform: translateY(-50%);
  display: inline-flex; align-items: center; gap: .55rem; text-decoration: none; color: var(--muted);
}
footer .foot-powered-label {
  font-size: .56rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase;
  color: #c5d0d8; white-space: nowrap; line-height: 1;
}
@keyframes foot-logo-spin {
  from { transform: rotate(0deg); opacity: 0; }
  to { transform: rotate(360deg); opacity: .96; }
}
footer .foot-powered-logo {
  height: 1.75rem; width: auto; display: block; opacity: .96;
  transform-origin: 15% 50%;
  animation: foot-logo-spin .85s cubic-bezier(.22, 1, .36, 1) .2s both;
}
footer .foot-powered:hover { color: var(--gold); }
footer .foot-powered:hover .foot-powered-label { color: var(--gold); }
footer .foot-powered:hover .foot-powered-logo { opacity: 1; filter: drop-shadow(0 0 6px rgba(228, 3, 123, .35)); }
@media (prefers-reduced-motion: reduce) {
  footer .foot-powered-logo { animation: none; opacity: .96; }
}
/* Version pinned to the right corner — "MissionForge v1.0.0" (like GridSquare). */
footer .foot-ver {
  position: absolute; right: clamp(1rem, 4vw, 3rem); top: 50%; transform: translateY(-50%);
  color: #5f7385; font-size: .78rem; white-space: nowrap;
}
@media (max-width: 640px) {
  footer .foot-ver { display: none; }
  footer .foot-powered-label { font-size: .5rem; letter-spacing: .06em; }
  footer .foot-powered-logo { height: 1.5rem; }
}

/* ---- Command palette (Ctrl/Cmd-K) ---- */
.mf-cmdk { position: fixed; inset: 0; background: rgba(6,12,18,.55); backdrop-filter: blur(2px); z-index: 1000; display: none; align-items: flex-start; justify-content: center; }
.mf-cmdk.show { display: flex; }
.mf-cmdk-box { margin-top: 12vh; width: min(640px, 92vw); background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 24px 60px rgba(0,0,0,.5); overflow: hidden; }
.mf-cmdk-input { width: 100%; border: none; border-bottom: 1px solid var(--line); border-radius: 0; padding: .9rem 1rem; font-size: 1rem; background: var(--panel-2); }
.mf-cmdk-input:focus { outline: none; }
.mf-cmdk-list { max-height: 52vh; overflow-y: auto; }
.mf-cmdk-item { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .55rem 1rem; cursor: pointer; }
.mf-cmdk-item.sel { background: #C6AF5C1f; }
.mf-cmdk-name { color: var(--ink); font-size: .9rem; }
.mf-cmdk-type { color: var(--muted); font-size: .68rem; text-transform: uppercase; letter-spacing: .05em; border: 1px solid var(--line); border-radius: 999px; padding: .1rem .5rem; }
.mf-cmdk-empty { padding: 1rem; color: var(--muted); text-align: center; }
.mf-cmdk-foot { display: flex; gap: 1rem; padding: .5rem 1rem; border-top: 1px solid var(--line); color: var(--muted); font-size: .72rem; background: var(--panel-2); }

/* ---- Generic summary cards row ---- */
.summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: .75rem; margin: 1rem 0 1.25rem; }
.summary .card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: .85rem 1rem; }
.summary .card .k { font-size: 1.5rem; font-weight: 800; color: var(--gold); }
.summary .card .l { color: var(--muted); font-size: .78rem; margin-top: .15rem; }

/* ---- Controls row ---- */
.builder-controls { display: flex; gap: 1rem; align-items: flex-end; flex-wrap: wrap; margin-bottom: 1rem; }
.builder-controls .field { display: flex; flex-direction: column; gap: .25rem; }
.builder-controls label { font-size: .78rem; color: var(--muted); }

/* ---- Modal overlay / dialog ---- */
.mf-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: flex; align-items: center; justify-content: center; z-index: 300; padding: 1rem; }
.mf-overlay[hidden] { display: none; }
.mf-dialog { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 1.25rem 1.4rem; width: min(460px, 94vw); box-shadow: 0 20px 60px rgba(0,0,0,.55); }
.mf-dialog h3 { margin: 0 0 .3rem; }
.mf-dialog .field { margin: .65rem 0; }
.mf-dialog label { display: block; font-size: .75rem; color: var(--muted); margin-bottom: .2rem; }
.mf-dialog input, .mf-dialog select { width: 100%; }

/* ---- What-if sliders ---- */
.wf-list { display: grid; gap: .5rem; }
.wf-row { display: grid; grid-template-columns: minmax(10rem, 1.4fr) 2fr auto auto; gap: .75rem; align-items: center; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: .5rem .75rem; }
.wf-row.cut { opacity: .5; }
.wf-row .nm { font-size: .85rem; }
.wf-row .sub { color: var(--muted); font-size: .72rem; }
.wf-row input[type=range] { width: 100%; }
.wf-cost { font-variant-numeric: tabular-nums; color: var(--gold); font-size: .85rem; text-align: right; }
.pill-funded { font-size: .68rem; padding: .12rem .5rem; border-radius: 999px; background: #007A3333; color: #6fd99a; border: 1px solid #007A3355; }
.pill-cut { font-size: .68rem; padding: .12rem .5rem; border-radius: 999px; background: #C8102E22; color: #ff9b9b; border: 1px solid #C8102E55; }

/* ---- Compare / diff ---- */
.cmp-grid { overflow-x: auto; }
.cmp table { width: 100%; }
.diff-add { color: #6fd99a; }
.diff-rem { color: #ff9b9b; }
.cell-fund { color: #6fd99a; font-weight: 700; }
.cell-cut { color: #7d8c9b; }

/* ---- Justification narrative ---- */
.narrative-out { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 1.25rem 1.4rem; line-height: 1.6; }
.narrative-out p { margin: 0 0 .85rem; }
.narrative-out .cls { font-size: .72rem; color: var(--muted); letter-spacing: .08em; text-transform: uppercase; margin-bottom: .75rem; }

/* ---- Anomaly / burndown flags ---- */
.flag { font-size: .7rem; padding: .12rem .5rem; border-radius: 999px; border: 1px solid var(--line); }
.flag.bad { background: #C8102E22; color: #ff9b9b; border-color: #C8102E55; }
.flag.warn { background: #C6AF5C22; color: var(--gold); border-color: #C6AF5C55; }
.flag.ok { background: #007A3322; color: #6fd99a; border-color: #007A3355; }

/* ---- Print ----
   The app shell locks the body to 100vh with an internally-scrolling <main> (sticky footer).
   For print that must be undone, or the printout is a single scrolled screen with scrollbars.
   initChrome() also REPLACES #appbar/#footer with <header class="appbar">/<footer>, so hide
   the rendered elements (not just the placeholder ids). */
@media print {
  /* Undo the 100vh scroll-lock so content flows across pages, but KEEP the on-screen
     dark theme (this brief goes to leadership and must match the screen). */
  html, body { height: auto !important; min-height: 0 !important; overflow: visible !important; display: block !important; }
  main { overflow: visible !important; height: auto !important; min-height: 0 !important; max-height: none !important; padding: 0 !important; display: block !important; }
  /* initChrome replaces #appbar/#footer with header.appbar/footer — hide the rendered nodes
     and the interactive controls, but nothing else. */
  header.appbar, #appbar, footer, #footer,
  .no-print, .mf-png, .tabbar, .pager, .rv-actions, .chartfilter, .loadbar { display: none !important; }
  /* Keep blocks/cards/charts intact across page breaks. */
  .card, .chart-card, section.block, table, tr, .charts > * { break-inside: avoid; page-break-inside: avoid; }
  h1, h2, h3 { break-after: avoid; page-break-after: avoid; }
  /* Force the dark backgrounds and chart colors to actually print. */
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ---- HDMG INVEST brand overrides ---- */
.brand .wm { font-family: 'Playfair Display', Georgia, 'Times New Roman', serif; font-weight: 700; letter-spacing: .04em; }
.brand .wm .m { color: var(--ink); }
.brand .wm .f { color: var(--gold); -webkit-text-fill-color: var(--gold); background: none; }
.brand-tag { font-style: normal; letter-spacing: .02em; }
.brand .emblem { animation: none; }
/* ---- HDMG top nav ---- */
.appbar { grid-template-columns: auto 1fr auto; }
.topnav { display: flex; gap: .35rem; justify-content: center; flex-wrap: wrap; }
.topnav .navlink { color: var(--muted); text-decoration: none; font-size: .9rem; padding: .4rem .8rem; border-radius: 6px; border: 1px solid transparent; }
.topnav .navlink:hover { color: var(--ink); background: var(--panel-2); }
.topnav .navlink.active { color: var(--gold); border-color: var(--gold); }
@media (max-width: 900px) { .topnav { display: none; } }

/* ---- Sub-page workflow strip: breadcrumb (left) + next-step button (right). ---- */
.crumbbar { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; margin: 0 0 .8rem; }
.crumbs { display: flex; align-items: center; gap: .45rem; font-size: .92rem; }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--gold); }
.crumb-sep { color: var(--muted); opacity: .55; }
.crumb-cur { color: var(--ink); font-weight: 600; }
.backlink { color: var(--muted); text-decoration: none; font-size: .9rem; }
.backlink:hover { color: var(--gold); }
.btn.nextstep { border-color: var(--gold); color: var(--gold); }
.btn.nextstep:hover { background: #C6AF5C1a; }
/* A primary CTA that also carries the nextstep arrow must keep its dark text — otherwise the gold
   nextstep colour lands on the gold primary background and the label becomes unreadable. */
.btn.primary.nextstep { color: #1b1b1b; }

/* Global KPI strip (shown on every sub-page; cards link to their area). Collapsible. */
/* KPI strip stays pinned at the top of the scroll area so it's always visible. */
#kpiWrap { position: sticky; top: 0; z-index: 6; background: var(--navy-0); padding: .3rem 0 .7rem; margin: 0 0 .6rem; }
main.lead-page .lead-page-pin {
  position: sticky;
  top: 0;
  z-index: 18;
  background: var(--navy-0);
  padding-bottom: .4rem;
  margin-bottom: .35rem;
  box-shadow: 0 10px 18px -14px rgba(0, 0, 0, .85);
}
main.lead-page .lead-page-pin #kpiWrap {
  position: static;
  top: auto;
  z-index: auto;
  margin: 0 0 .35rem;
  padding: .25rem 0 .45rem;
}
main.lead-page .lead-page-pin > .lead-head { margin-bottom: .4rem; }
main.lead-page .lead-page-pin #meta .record-summary { margin-bottom: .4rem; }
main.lead-page .lead-page-pin #investorRead:not([hidden]) { margin: 0 0 .35rem; }
main.lead-page .lead-page-pin #convertedBanner:not([hidden]) { margin: 0 0 .35rem; }
.kpi-toggle { background: transparent; border: none; color: var(--muted); cursor: pointer; font: inherit; font-size: .72rem; letter-spacing: .04em; text-transform: uppercase; padding: .1rem .1rem .4rem; }
.kpi-toggle:hover { color: var(--gold); }
.kpi-strip { margin: 0; }
.kpi-strip .card { text-decoration: none; color: inherit; transition: border-color .12s, transform .12s; }
.kpi-strip .card:hover { border-color: #C6AF5C66; transform: translateY(-1px); }
.kpi-strip .card { perspective: 600px; }
.kpi-strip .card .k { transition: color .2s; transform-style: preserve-3d; backface-visibility: hidden; }
/* When a figure changes, the card flashes gold and the number does a 3D flip with a color sweep. */
.kpi-strip .card.kpi-bump { animation: kpiBump 1.4s ease-out; }
.kpi-strip .card.kpi-bump .k { animation: kpiFlip 1.4s cubic-bezier(.34,1.56,.64,1); }
@keyframes kpiBump {
  0%   { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold), 0 0 18px #C6AF5C66; }
  100% { border-color: var(--line); box-shadow: none; }
}
/* Odometer-style flip on the X axis, sweeping cool-cyan → bright gold → settle gold. */
@keyframes kpiFlip {
  0%   { transform: rotateX(-90deg) scale(1.25); color: #6FE3D2; }
  45%  { transform: rotateX(15deg)  scale(1.15); color: #F4E08A; }
  70%  { transform: rotateX(-6deg)  scale(1.06); color: #FFF1B8; }
  100% { transform: rotateX(0)      scale(1);    color: var(--gold); }
}
@media (prefers-reduced-motion: reduce) {
  .kpi-strip .card.kpi-bump, .kpi-strip .card.kpi-bump .k { animation: none; }
}

/* Status as a colored dot + tooltip (compact). */
.statusdot { display: inline-block; width: 11px; height: 11px; border-radius: 50%; vertical-align: middle; border: 1px solid #ffffff22; }
.statusdot.green { background: #3ca36b; }
.statusdot.gold { background: var(--gold); }
.statusdot.red { background: #d9534f; }
.statusdot.slate { background: #6b7785; }

/* ⋮ row action menu */
.inv-menu { position: relative; display: inline-block; }
.inv-kebab { background: transparent; border: 1px solid transparent; color: var(--muted); cursor: pointer; font-size: 1.1rem; line-height: 1; padding: .15rem .45rem; border-radius: 6px; }
.inv-kebab:hover { color: var(--ink); border-color: var(--line); background: var(--panel-2); }
/* Pinned with JS (position:fixed) so the menu is never clipped by table/scroll overflow. */
.inv-pop { position: fixed; z-index: 200; min-width: 11rem; background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: .3rem; box-shadow: 0 8px 24px rgba(0,0,0,.45); }
.inv-item { display: block; width: 100%; text-align: left; background: transparent; border: none; color: var(--ink); text-decoration: none; font: inherit; font-size: .86rem; padding: .45rem .6rem; border-radius: 6px; cursor: pointer; }
.inv-item:hover { background: #C6AF5C1a; }

/* Borrower cell: keep on two tidy lines, ellipsize overflow (full value in the tooltip). */
.borrowercell { max-width: 18rem; }
.borrowercell .bname, .borrowercell .bco { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---- Section title accent ---- */
h1.page, h2.page { font-family: 'Playfair Display', Georgia, serif; font-size: 1.45rem; line-height: 1.1; border-left: 3px solid var(--gold); padding-left: .6rem; margin: 0 0 .6rem; }

/* ---- Milestone checklist ---- */
.milestones { display: grid; gap: .5rem; }
.milestones .ms-row { display: flex; align-items: center; gap: .6rem; padding: .5rem .7rem; background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; }
.milestones .ms-check { display: flex; align-items: center; gap: .6rem; flex: 1; cursor: pointer; margin: 0; }
.milestones input { width: auto; accent-color: var(--gold); }
.milestones .ms-date { color: var(--muted); font-size: .78rem; }
.milestones .ms-num { display: inline-flex; align-items: center; justify-content: center; min-width: 1.4rem; height: 1.4rem; border-radius: 999px; background: var(--panel); border: 1px solid var(--line); color: var(--muted); font-size: .72rem; font-weight: 700; }
.milestones .ms-row.done .ms-num { background: var(--gold); border-color: var(--gold); color: #1b1b1b; }
.milestones .ms-doc-pending { opacity: .5; }
/* Email milestones track two timestamps: Sent (request) and Received (payment/response). */
.milestones .ms-track { display: flex; gap: .9rem; font-size: .72rem; white-space: nowrap; }
.milestones .ms-track .ms-sent, .milestones .ms-track .ms-recv { color: var(--ink); }
.milestones .ms-track .muted { color: var(--muted); }

/* Compact account-officer picker in the deal header. */
.deal-owner { display: inline-flex; align-items: center; gap: .4rem; }
/* Owner lives at the right end of the deal's tab row (no dedicated row of its own). */
.ws-nav .deal-owner { margin-left: auto; align-self: center; }
.deal-owner .do-label { font-size: .66rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.deal-owner select { width: auto; max-width: 13rem; }
.deal-owner select.unassigned { border-color: var(--gold); color: var(--gold); }
/* When the deal has no owner, the whole control becomes a loud gold pill so it can't be missed;
   once assigned it reverts to the quiet inline label above. No dedicated row either way. */
.deal-owner.needs-owner { background: #C0473A26; border: 1px solid var(--red); border-radius: 999px; padding: .25rem .7rem; }
.deal-owner.needs-owner .do-label { color: var(--red); font-weight: 700; }
.deal-owner.needs-owner select.unassigned { border-color: var(--red); color: var(--red); }

/* ---- Tabs (deal workspace) ---- */
.tabbar { display: flex; gap: .25rem; border-bottom: 1px solid var(--line); margin-bottom: 1rem; flex-wrap: wrap; }
.tab { background: transparent; color: var(--muted); border: none; border-bottom: 2px solid transparent; padding: .55rem .9rem; cursor: pointer; font: inherit; }
.tab.active { color: var(--gold); border-bottom-color: var(--gold); }
.tabpanel { animation: fadeIn .2s ease; }
/* A hidden tab panel must stay hidden even if it also carries .admin-only (whose display:flex would
   otherwise override the [hidden] attribute). */
.tabpanel[hidden] { display: none !important; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ---- Forms grid ---- */
.formgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: .8rem; }
.field { display: grid; gap: .25rem; }
.field[hidden] { display: none; }   /* the display rule above otherwise overrides the hidden attribute */
.field label { color: var(--muted); font-size: .78rem; }
.field input, .field select, .field textarea { width: 100%; }
.field.full { grid-column: 1 / -1; }

/* ---- Status chips ---- */
.chip { display: inline-block; padding: .12rem .5rem; border-radius: 999px; font-size: .72rem; font-weight: 700; border: 1px solid var(--line); }
.chip.gold { color: var(--gold); border-color: var(--gold); }
.chip.green { color: #7FD49A; border-color: #2f6f48; }
.chip.red { color: #ff9a8f; border-color: #6f2f2f; }
.chip.slate { color: var(--muted); }

/* ---- Modal ---- */
.mf-modal { position: fixed; inset: 0; z-index: 100; display: none; align-items: center; justify-content: center; background: rgba(6,10,20,.6); }
.mf-modal.show { display: flex; }
.mf-modal-card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 1.5rem 1.75rem; width: min(96vw, 58rem); max-height: 92vh; overflow:auto; box-shadow: 0 12px 40px rgba(0,0,0,.5); }
.mf-modal-card h3 { margin: 0 0 .85rem; font-family: 'Playfair Display', Georgia, serif; }
.mf-modal-actions { display: flex; justify-content: flex-end; gap: .5rem; margin-top: 1rem; }

/* ---- Toast ---- */
.mf-toast { position: fixed; bottom: 1.2rem; left: 50%; transform: translateX(-50%) translateY(2rem); opacity: 0;
  background: var(--panel-2); color: var(--ink); border: 1px solid var(--gold); border-radius: 8px; padding: .6rem 1rem;
  font-size: .88rem; z-index: 300; transition: all .2s ease; pointer-events: none; }
.mf-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.mf-toast.error { border-color: var(--red); }

.note-save-status { font-size: .78rem; font-weight: 500; margin-left: .45rem; text-transform: none; letter-spacing: normal; color: var(--muted); }
.note-save-status.draft { color: var(--gold); }
.note-save-status.saving { color: var(--muted); }
.note-save-status.saved { color: var(--green); }
.note-save-status.error { color: var(--red); }

.note-just-saved { animation: noteSavedPulse 2.5s ease-out; }
@keyframes noteSavedPulse {
  0%, 15% { box-shadow: 0 0 0 2px var(--gold); border-color: var(--gold); }
  100% { box-shadow: none; }
}

.note-scroll {
  height: min(240px, 30vh);
  max-height: min(240px, 30vh);
  overflow-x: hidden;
  overflow-y: scroll;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  scrollbar-color: color-mix(in srgb, var(--gold) 35%, var(--line)) var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-2);
  padding: .4rem .45rem .4rem .55rem;
  margin-top: .5rem;
}
.note-scroll::-webkit-scrollbar { width: 10px; }
.note-scroll::-webkit-scrollbar-track { background: var(--panel); border-radius: 10px; margin: .2rem 0; }
.note-scroll::-webkit-scrollbar-thumb { background: color-mix(in srgb, var(--gold) 35%, var(--line)); border-radius: 10px; border: 2px solid var(--panel-2); }
.note-scroll::-webkit-scrollbar-thumb:hover { background: var(--gold); }
.note-scroll .card { margin: .35rem 0 !important; }
.note-scroll .empty { margin: .45rem .25rem; }

/* Lead document folders — grouped by category, mirroring the storage tree. */
.doc-group { margin: 0 0 .55rem; }
.doc-group:last-child { margin-bottom: 0; }
.doc-group-h { font-size: .68rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 0 0 .15rem; padding-bottom: .12rem; border-bottom: 1px solid var(--line); }
.doc-ver { font-size: .68rem; font-weight: 600; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 0 .4rem; }
.doc-latest { font-size: .64rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: #6FE3B0; border: 1px solid #6FE3B055; background: #6FE3B014; border-radius: 999px; padding: 0 .4rem; }
.doc-when { margin-left: auto; font-size: .72rem; font-weight: 400; color: var(--muted); }
/* Lead workspace docs scroll in .lead-wb-docs #d-docs — keep other #d-docs usages unconstrained. */
.lead-wb-docs #d-docs { padding-right: 0; }
.doc-group { margin-bottom: .7rem; }
.doc-group:last-child { margin-bottom: 0; }
.doc-group-h { font-size: .66rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 0 0 .25rem; padding-bottom: .2rem; border-bottom: 1px solid var(--line); }
.doc-group-h-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: .75rem 1rem;
  flex-wrap: wrap;
}
.doc-group-empty {
  flex-shrink: 0;
  margin-left: auto;
  font: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  color: inherit;
}
.doc-group-count {
  flex-shrink: 0;
  margin-left: auto;
  font: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  color: var(--green);
}
.doc-stack .doc-group {
  margin-bottom: .55rem;
  padding: .5rem .65rem .55rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--panel-2) 38%, transparent);
}
.doc-stack .doc-group:last-child { margin-bottom: 0; }

/* AI reviewer status pill — honestly shows Live / Demo / Not-live. */
.ai-status { font-size: .72rem; font-weight: 600; letter-spacing: .02em; padding: .12rem .5rem; border-radius: 999px; border: 1px solid var(--line); white-space: nowrap; }
.ai-status.live { color: #6FE3B0; border-color: #6FE3B055; background: #6FE3B014; }
.ai-status.demo { color: var(--gold); border-color: #C6AF5C55; background: #C6AF5C14; }
.ai-status.off  { color: var(--muted); border-color: var(--line); background: transparent; }
/* Investor pre-deal read — full-width collapsible gold bar under the borrower header. */
.investor-read-bar { margin: .6rem 0 0; border-radius: 10px; line-height: 1.4;
  border: 1px solid color-mix(in srgb, var(--gold) 40%, var(--line)); background: color-mix(in srgb, var(--gold) 9%, transparent); color: var(--ink); }
.investor-read-bar strong { color: var(--gold); }
.investor-read-bar .ir-toggle { width: 100%; display: flex; align-items: center; gap: .6rem; padding: .55rem .8rem;
  background: none; border: 0; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.investor-read-bar .ir-head { flex: 1; }
.investor-read-bar .ir-head .pginfo { margin-left: .25rem; }
.investor-read-bar .ir-caret { color: var(--gold); transition: transform .15s ease; }
.investor-read-bar.open .ir-caret { transform: rotate(180deg); }
.investor-read-bar .ir-detail { padding: 0 .9rem .7rem; }
.investor-read-bar .ir-detail p { margin: .25rem 0; }
.investor-read-bar .ir-ov-title { font-weight: 700; color: var(--gold); letter-spacing: .03em; margin: .1rem 0 .15rem; }
.investor-read-bar .ir-steps { list-style: none; margin: .4rem 0; padding: 0; display: grid; gap: .4rem; }
.investor-read-bar .ir-steps li { display: flex; flex-wrap: wrap; align-items: center; gap: .25rem .6rem;
  padding: .45rem .6rem; border-radius: 8px; border: 1px solid var(--line); background: color-mix(in srgb, var(--panel-2) 55%, transparent); }
.investor-read-bar .ir-step-k { min-width: 13rem; font-weight: 600; color: var(--muted); }
.investor-read-bar .ir-step-k em { font-style: normal; color: var(--muted); opacity: .85; }
.investor-read-bar .ir-step-v { flex: 1; }
/* Shared client ⇄ staff comment thread (deal page + client portal). */
.comment-thread { display: flex; flex-direction: column; gap: .5rem; max-height: 340px; overflow-y: auto; padding: .2rem 0; }
.comment { max-width: 85%; padding: .5rem .7rem; border-radius: 12px; border: 1px solid var(--line); background: var(--panel-2); }
.comment.from-staff { align-self: flex-start; }
.comment.from-client { align-self: flex-end; background: color-mix(in srgb, var(--gold) 14%, var(--panel-2)); border-color: color-mix(in srgb, var(--gold) 35%, var(--line)); }
.comment .c-who { font-size: .72rem; font-weight: 600; color: var(--muted); margin-bottom: .2rem; }
.comment .c-body { line-height: 1.45; white-space: pre-wrap; }
.comment-compose { display: flex; gap: .5rem; align-items: flex-end; margin-top: .6rem; }
.comment-compose textarea { flex: 1; min-height: 2.4rem; max-height: 7rem; resize: vertical; }

/* Client portal — collapsible sections (Progress, Payment schedule, Invoices). */
.portal-sec > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: .5rem;
  font-size: .95rem; font-weight: 600; color: var(--ink); padding: .15rem 0; }
.portal-sec > summary::-webkit-details-marker { display: none; }
.portal-sec > summary::after { content: '▾'; color: var(--gold); margin-left: auto; transition: transform .15s ease; }
.portal-sec[open] > summary::after { transform: rotate(180deg); }
/* Force-collapse: an explicit display on a child (e.g. .milestones grid) can defeat the native hide. */
.portal-sec:not([open]) > :not(summary) { display: none !important; }

/* Client portal — highlight the loan card an email deep-link points to. */
.portal-deal.deal-target { outline: 2px solid var(--gold); outline-offset: 2px; animation: deal-target-fade 2.6s ease; }
@keyframes deal-target-fade { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--gold) 55%, transparent); } 100% { box-shadow: 0 0 0 12px transparent; } }

/* Client portal — "you're funded" celebratory banner. */
.funded-banner { display: flex; align-items: center; gap: .8rem; margin: 0 0 1rem; padding: .8rem 1rem; border-radius: 12px;
  border: 1px solid color-mix(in srgb, var(--gold) 55%, var(--line)); background: linear-gradient(100deg, color-mix(in srgb, var(--gold) 18%, transparent), color-mix(in srgb, var(--gold) 6%, transparent)); }
.funded-banner .fb-icon { font-size: 1.4rem; line-height: 1; display: inline-block; transform-origin: 70% 70%; animation: funded-tada 1.3s ease .35s both; }
.funded-banner .fb-line { color: var(--ink); font-size: .92rem; }
.funded-banner .fb-title { font-family: 'Playfair Display', Georgia, serif; font-weight: 700; font-size: 1.05rem; color: var(--gold); margin-right: .3rem; }

/* Celebratory entrance + a gold glow pulse when the funded banner appears. */
.funded-banner { animation: funded-pop .5s cubic-bezier(.2,.9,.3,1.2) both, funded-glow 2.4s ease-in-out .4s 2; }
@keyframes funded-pop { from { opacity: 0; transform: translateY(-8px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes funded-glow {
  0%, 100% { box-shadow: 0 0 0 0 transparent; border-color: color-mix(in srgb, var(--gold) 55%, var(--line)); }
  50% { box-shadow: 0 0 20px 1px color-mix(in srgb, var(--gold) 45%, transparent); border-color: var(--gold); }
}
@keyframes funded-tada {
  0% { transform: scale(1) rotate(0); }
  15% { transform: scale(1.25) rotate(-12deg); }
  30%, 50%, 70% { transform: scale(1.25) rotate(10deg); }
  40%, 60% { transform: scale(1.25) rotate(-10deg); }
  100% { transform: scale(1) rotate(0); }
}
@media (prefers-reduced-motion: reduce) {
  .funded-banner, .funded-banner .fb-icon { animation: none; }
}

/* Celebratory falling petals when a funded borrower opens their portal. */
.petal-layer { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 60; }
.petal { position: absolute; top: -10vh; width: 12px; height: 12px; border-radius: 50% 0 50% 0;
  background: linear-gradient(135deg, color-mix(in srgb, var(--gold) 92%, #fff), var(--gold));
  box-shadow: 0 0 4px color-mix(in srgb, var(--gold) 35%, transparent);
  animation: petal-fall linear forwards; }
@keyframes petal-fall {
  0% { transform: translateY(0) translateX(0) rotate(0); opacity: .95; }
  100% { transform: translateY(112vh) translateX(var(--drift, 30px)) rotate(720deg); opacity: 0; }
}

/* Client portal — milestone progress bar at the top of each loan card. */
.portal-progress { margin: 0 0 1rem; }
.portal-progress .pp-head { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; margin-bottom: .35rem; }
.portal-progress .pp-label { font-weight: 600; letter-spacing: .02em; }
.portal-progress .pp-meta { color: var(--muted); font-size: .85rem; }
.portal-progress .pp-meta strong { color: var(--gold); }
.portal-progress .pp-track { height: 10px; border-radius: 999px; background: var(--panel-2); border: 1px solid var(--line); overflow: hidden; }
.portal-progress .pp-fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, color-mix(in srgb, var(--gold) 70%, #fff) , var(--gold)); transition: width .4s ease; }
.portal-progress .pp-next { margin-top: .35rem; font-size: .82rem; color: var(--muted); }

/* Collapsed-section peek (next payment / invoice) and red "new message" badge. */
.sec-peek { color: var(--muted); font-weight: 400; font-size: .82rem; margin-left: .15rem; }
.msg-new { background: var(--red, #d9534f); color: #fff; font-size: .64rem; font-weight: 700; letter-spacing: .03em;
  padding: .08rem .45rem; border-radius: 999px; white-space: nowrap; animation: msg-new-pulse 1.6s ease-in-out infinite; }
@keyframes msg-new-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .55; } }
@media (prefers-reduced-motion: reduce) { .msg-new { animation: none; } }

/* Submit-a-Deal: structured "Deal package" upload sections — compact two-column rows. */
.dealpkg { display: grid; gap: .4rem; }
.dealpkg .dp-row { display: flex; align-items: center; gap: .8rem; flex-wrap: wrap; padding: .5rem .7rem; border: 1px solid var(--line); border-radius: 8px; background: var(--panel-2); transition: border-color .12s, background .12s; }
.dealpkg .dp-row:hover { border-color: color-mix(in srgb, var(--gold) 45%, var(--line)); }
.dealpkg .dp-row label { flex: 1; min-width: 12rem; font-weight: 500; font-size: .9rem; }
.dealpkg .dp-row label::before { content: '📎 '; opacity: .6; }
.dealpkg .dp-row input[type="file"] { flex: 0 0 auto; max-width: 100%; font-size: .82rem; }
.dealpkg .dp-req { color: var(--gold); }

/* Uppercase encouragement callout in the Executive Summary section. */
.exec-note { margin: 0 0 .9rem; padding: .6rem .8rem; border-radius: 8px; font-size: .82rem; font-weight: 700; letter-spacing: .03em; line-height: 1.4;
  color: var(--gold); border: 1px solid color-mix(in srgb, var(--gold) 45%, var(--line)); background: color-mix(in srgb, var(--gold) 10%, transparent); }

/* Submit-a-Deal: collapsible intake sections (steps 1–5 vs. Executive Summary). */
.intake-sec { border: 1px solid var(--line); border-radius: 10px; margin: .6rem 0; background: color-mix(in srgb, var(--panel-2) 50%, transparent); }
.intake-sec > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: .5rem; padding: .7rem .9rem; font-weight: 600; font-family: 'Playfair Display', Georgia, serif; font-size: 1.05rem; }
.intake-sec > summary::-webkit-details-marker { display: none; }
.intake-sec > summary::after { content: '▾'; margin-left: auto; color: var(--gold); transition: transform .15s ease; }
.intake-sec[open] > summary::after { transform: rotate(180deg); }
.intake-sec .intake-body { padding: 0 .9rem .9rem; }
.exec-fields .exec-grp { margin: 1rem 0 .35rem; font-size: .82rem; text-transform: uppercase; letter-spacing: .06em; color: var(--gold); border: none; padding: 0; }
.exec-fields .exec-grp:first-child { margin-top: .2rem; }
.exec-template { margin: 0 0 .75rem; font-size: .84rem; line-height: 1.45; }
.exec-template a { color: var(--gold); font-weight: 600; text-decoration: none; }
.exec-template a:hover { text-decoration: underline; }

/* Collapsible ws-panel (e.g. the deal-page Milestones section). */
details.ws-collapse > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: .5rem; }
details.ws-collapse > summary::-webkit-details-marker { display: none; }
details.ws-collapse > summary h2 { margin: 0; }
details.ws-collapse > summary::after { content: '▾'; color: var(--gold); margin-left: auto; transition: transform .15s ease; }
details.ws-collapse[open] > summary::after { transform: rotate(180deg); }
/* Force-collapse: an explicit display on a child (the .milestones grid) can defeat the native hide. */
details.ws-collapse:not([open]) > :not(summary) { display: none !important; }
details.ws-collapse[hidden] { display: none !important; }   /* keep the JS .hidden toggle working */

/* Collapsible AI analysis bars under the lead header (deal review, document analysis). */
.ai-bar { margin: .6rem 0 0; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); }
.ai-bar > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: .6rem; padding: .55rem .8rem; }
.ai-bar > summary::-webkit-details-marker { display: none; }
.ai-bar > summary::marker { content: ''; }
.ai-bar .ai-bar-head { flex: 1; font-weight: 600; }
.ai-bar .ai-bar-head strong { color: var(--gold); }
.ai-bar .ai-caret { color: var(--gold); transition: transform .15s ease; }
.ai-bar[open] .ai-caret { transform: rotate(180deg); }
.ai-bar .ai-bar-body { padding: 0 .8rem .7rem; }
.ai-bar .ai-bar-actions { display: flex; align-items: center; gap: .5rem; margin: .2rem 0 .5rem; }
/* Sub-sections inside the combined AI analysis panel. */
.ai-bar .ai-subhead { display: flex; align-items: center; gap: .6rem; margin: .55rem 0 .35rem; }
.ai-bar .ai-subsection { margin-top: .85rem; border-top: 1px solid var(--line); padding-top: .55rem; }
/* Hidden AI source — rendered only in the Open ↗ pulldown from the action bar. */
.ai-bar-source { display: none !important; }
.ai-bar-source .ai-bar-body #ai-out,
.ai-bar-source .ai-bar-body #docIntelWrap { display: block; }
.ai-popout-btn {
  flex-shrink: 0;
  pointer-events: auto;
  padding: .32rem .65rem;
  font-size: .8rem;
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: .01em;
  color: var(--gold);
  border-color: color-mix(in srgb, var(--gold) 60%, var(--line));
  background: color-mix(in srgb, var(--gold) 14%, var(--panel));
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--gold) 18%, transparent);
}
.ai-popout-btn:hover,
.lead-ai-bar.ai-drop-open .ai-popout-btn {
  color: var(--gold);
  border-color: var(--gold);
  background: color-mix(in srgb, var(--gold) 24%, var(--panel));
}
.lead-ai-bar .ai-expand-drop {
  position: fixed;
  z-index: 500;
  width: min(55rem, calc(100vw - 1.5rem));
  min-width: 20rem;
  padding: .75rem .85rem .8rem;
  box-sizing: border-box;
  border: 1px solid color-mix(in srgb, var(--gold) 50%, var(--line));
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 14px 40px rgba(0, 0, 0, .45);
  max-height: min(620px, calc(100vh - 6rem));
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  scrollbar-color: color-mix(in srgb, var(--gold) 40%, var(--line)) var(--panel-2);
}
.lead-ai-bar .ai-expand-drop .ai-expand-doc:not(:empty) { margin-top: .45rem; padding-top: .4rem; border-top: 1px solid var(--line); }
.lead-ai-bar .ai-expand-drop .pginfo { margin: .2rem 0 !important; font-size: .76rem; line-height: 1.3; }
.lead-ai-bar .ai-expand-drop .ai-subhead { margin: .25rem 0 .15rem; }
.lead-ai-bar .ai-expand-drop::-webkit-scrollbar { width: 9px; }
.lead-ai-bar .ai-expand-drop::-webkit-scrollbar-track { background: var(--panel-2); border-radius: 999px; margin: .15rem 0; }
.lead-ai-bar .ai-expand-drop::-webkit-scrollbar-thumb { background: color-mix(in srgb, var(--gold) 45%, var(--line)); border-radius: 999px; border: 2px solid var(--panel-2); }
.lead-ai-bar .ai-expand-drop::-webkit-scrollbar-thumb:hover { background: var(--gold); }

/* Executive Summary panel (right column, above Documents). */
.exec-sub { margin-top: 0; border-top: none; padding-top: 0; }
.exec-sub > summary .exec-sub-h { font-weight: 600; font-size: .95rem; border-left: 3px solid var(--gold); padding-left: .5rem; }
.lead-wb-exec details.ws-collapse > summary::after { display: none; }
.lead-wb-exec { align-self: start; }
.lead-wb-exec .exec-summary-body { max-height: none; overflow: visible; padding-right: 0; line-height: 1.5; }

/* Appraisal prediction — a forecast inside the AI analysis body. */
.ai-prediction { margin: .5rem 0; padding: .4rem .6rem; border-radius: 8px; line-height: 1.45;
  border: 1px solid var(--line); background: color-mix(in srgb, var(--panel-2) 60%, transparent); color: var(--ink); }
.ai-prediction strong { color: var(--ink); }

.ai-review-scroll {
  max-height: min(320px, 40vh);
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  scrollbar-color: color-mix(in srgb, var(--gold) 35%, var(--line)) var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-2);
  padding: .45rem .55rem;
  margin-top: .25rem;
}
.ai-review-scroll:empty { border: none; background: transparent; min-height: 0; padding: 0; overflow: hidden; }
.ai-review-scroll::-webkit-scrollbar { width: 10px; }
.ai-review-scroll::-webkit-scrollbar-track { background: var(--panel); border-radius: 10px; margin: .2rem 0; }
.ai-review-scroll::-webkit-scrollbar-thumb { background: color-mix(in srgb, var(--gold) 35%, var(--line)); border-radius: 10px; border: 2px solid var(--panel-2); }
.ai-review-scroll::-webkit-scrollbar-thumb:hover { background: var(--gold); }

.note-compose { display: flex; flex-direction: column; gap: .45rem; margin-bottom: .65rem; }
.note-compose[hidden] { display: none; }   /* an explicit display: beats the [hidden] UA rule — restore it */
.note-compose-bar { display: flex; align-items: flex-end; justify-content: space-between; gap: .75rem; flex-wrap: wrap; }
.note-compose-bar .note-type { width: min(100%, 11rem); margin: 0; flex-shrink: 0; }
.note-compose-bar .note-save-status { margin-left: auto; margin-bottom: .35rem; }
.note-input {
  width: 100%; box-sizing: border-box; min-height: 4.5rem; resize: vertical;
  background: var(--panel-2); color: var(--ink); border: 1px solid var(--line); border-radius: 8px;
  padding: .55rem .65rem; font: inherit; line-height: 1.45;
}
.note-input:focus { outline: none; border-color: color-mix(in srgb, var(--gold) 55%, var(--line)); }

textarea { background: var(--panel-2); color: var(--ink); border: 1px solid var(--line); border-radius: 6px; padding: .4rem .6rem; font: inherit; }
.row-actions { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin-bottom: 1rem; }
.row-actions.triage-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: flex-start;
  gap: 1rem 1.25rem;
  margin-top: .35rem;
  margin-bottom: 0;
}
.row-actions.triage-actions .field { margin: 0; flex: 0 1 auto; min-width: 0; }
.row-actions.triage-actions .triage-officer { width: min(100%, 14rem); }
.row-actions.triage-actions .triage-status { width: min(100%, 11rem); }
.row-actions.triage-actions .btn { flex-shrink: 0; align-self: flex-end; margin-left: auto; }
.triage-fit-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.65rem 0.85rem;
  margin-bottom: 0;
}
.triage-fit-row .field { margin: 0; min-width: 0; }
.triage-fit-row .triage-fit { flex: 1 1 9rem; max-width: 12rem; }
.triage-fit-row .triage-fitreason { flex: 2 1 12rem; }
.triage-officer-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.65rem 0.85rem;
  margin-top: 0.65rem;
}
.triage-officer-row .field { margin: 0; min-width: 0; }
.triage-officer-row .triage-status { flex: 1 1 8rem; max-width: 11rem; }
.triage-officer-row .triage-officer { flex: 1 1 14rem; max-width: 22rem; }
.triage-officer-row .field select { width: 100%; }
.triage-fit-row .field select,
.triage-fit-row .field input { width: 100%; }
.triage-fit-row .triage-save-status { align-self: flex-end; flex: 0 0 auto; white-space: nowrap; margin-left: 0.15rem; }
.lead-wb-triage.lead-panel { padding: .55rem .8rem .6rem; align-self: start; }
.lead-wb-triage h2 { margin-bottom: .35rem; font-size: .88rem; }
.lead-wb-triage .lead-panel-intro { margin: 0 0 .35rem; line-height: 1.3; }
.lead-wb-triage #d-reason-wrap { margin-top: .55rem; }
.detailbox { display: grid; grid-template-columns: max-content 1fr; gap: .35rem .9rem; }
.detailbox .k { color: var(--muted); font-size: .84rem; }
.detailbox-wide { grid-template-columns: max-content 1fr; }
.detailbox-wide .k { align-self: start; padding-top: .12rem; }
/* Secondary (inline) label in a combined row — same muted colour as the left-column labels. */
.detailbox .sublabel { color: var(--muted); font-size: .84rem; }
.detailbox .rowsep { color: var(--muted); opacity: .5; margin: 0 .15rem; }
.submission-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem 1.25rem; }
.submission-col-wide { grid-column: 1 / -1; }
.sub-sec-h { font-size: .72rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 0 0 .45rem; }
.sub-sec-h .pginfo { text-transform: none; letter-spacing: 0; font-weight: 400; font-size: .78rem; }
.sub-msg { white-space: pre-wrap; line-height: 1.5; font-size: .9rem; }
.exec-summary-text { white-space: pre-wrap; line-height: 1.5; font-size: .9rem; }
.doc-grid .doc-empty { display: block; padding: .12rem 0 .2rem; font-size: .85rem; }
@media (max-width: 960px) { .submission-grid { grid-template-columns: 1fr; } .submission-col-wide { grid-column: auto; } }
.fit-triage-row { display: flex; align-items: center; justify-content: space-between; gap: 1.15rem; flex-wrap: wrap; }
.fit-reasons { margin: 0 0 0 auto; padding: 0; list-style: none; display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .25rem 1rem; font-size: .88rem; color: var(--ink); line-height: 1.35; }
.fit-reasons li { position: relative; padding-left: .9rem; }
.fit-reasons li::before { content: '•'; position: absolute; left: 0; color: var(--gold); font-weight: 700; }

.risk-summary-row {
  display: flex;
  align-items: center;
  gap: .65rem .85rem;
  flex-wrap: wrap;
  min-width: 0;
  margin-bottom: .65rem;
  padding: .55rem .75rem;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  font: 400 .84rem/1.35 'Helvetica Neue', Arial, sans-serif;
}
.risk-summary-main {
  display: flex;
  align-items: center;
  gap: .5rem .75rem;
  flex-wrap: wrap;
  min-width: 0;
  flex: 1 1 12rem;
}
.risk-summary-row .chip,
.risk-summary-row .risk-stat,
.risk-summary-row .risk-reasons,
.risk-summary-row .risk-muted,
.risk-summary-row .risk-decision-label,
.risk-summary-row .risk-decided-by {
  font-size: .84rem;
  line-height: 1.35;
}
.risk-summary-row .chip { font-weight: 600; padding: .1rem .48rem; vertical-align: baseline; }
.risk-stat { color: var(--ink); font-weight: 400; white-space: nowrap; }
.risk-reasons,
.risk-muted,
.risk-decision-label { color: var(--muted); font-weight: 400; }
.risk-decided-by { color: var(--ink); font-weight: 400; white-space: nowrap; }
.risk-summary-sep {
  width: 1px;
  align-self: stretch;
  min-height: 1.35rem;
  background: var(--line);
  flex-shrink: 0;
}
.risk-decision-block {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  flex-shrink: 0;
  white-space: nowrap;
  font-size: .84rem;
  font-weight: 400;
  line-height: 1.35;
}
.risk-decision-label { letter-spacing: 0; text-transform: none; }
.risk-reasons { min-width: 0; }
.risk-actions {
  display: flex;
  align-items: flex-end;
  flex-wrap: nowrap;
  gap: .45rem .6rem;
  margin-top: .5rem;
  margin-bottom: 0;
  font-size: .84rem;
}
.risk-actions .field label { font-size: .78rem; }
.risk-actions .risk-field { margin: 0; width: min(100%, 7.5rem); flex-shrink: 0; }
.risk-actions .risk-note { flex: 1 1 7rem; min-width: 5.5rem; }
.risk-actions .btn { flex-shrink: 0; white-space: nowrap; }
.risk-actions-sep {
  width: 1px;
  align-self: stretch;
  min-height: 2.1rem;
  margin: 0 .1rem;
  background: var(--line);
  flex-shrink: 0;
}
.risk-actions #decHint { flex-shrink: 0; margin-bottom: .35rem; white-space: nowrap; }
.dates-actions {
  display: flex;
  align-items: flex-end;
  flex-wrap: nowrap;
  gap: .8rem;
  margin-top: 0;
  margin-bottom: 0;
  font-size: .84rem;
}
.dates-actions .field label { font-size: .78rem; }
.dates-actions .dates-field { flex: 0 1 14rem; min-width: 10rem; max-width: 14rem; margin: 0; }
.dates-actions .btn { flex-shrink: 0; white-space: nowrap; }
@media (max-width: 900px) {
  .risk-summary-sep { display: none; }
}
@media (max-width: 1100px) {
  .risk-actions { flex-wrap: wrap; }
  .risk-actions-sep { display: none; }
}
@media (max-width: 720px) {
  .dates-actions { flex-wrap: wrap; }
  .dates-actions .btn { margin-left: 0; width: 100%; }
}

/* Lead workspace — collapsible grid; on wide screens the workbench column scrolls, not the header. */
.lead-workbench {
  display: flex;
  flex-direction: column;
  gap: .5rem;
  margin-top: 0;
  min-height: 0;
}
.lead-wb-stack {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  min-width: 0;
  min-height: 0;
}
.lead-wb-stack > summary {
  padding: .48rem .7rem;
  border-radius: 10px;
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .35rem .75rem;
}
.lead-wb-stack > summary::-webkit-details-marker { display: none; }
.lead-wb-stack > summary::after {
  content: '▾';
  color: var(--gold);
  margin-left: auto;
  transition: transform .15s ease;
  flex-shrink: 0;
}
.lead-wb-stack[open] > summary::after { transform: rotate(180deg); }
.lead-wb-stack[open] > summary { border-bottom: 1px solid var(--line); border-radius: 10px 10px 0 0; }
.lead-wb-stack[open] > summary { flex: 0 0 auto; }
.lead-wb-stack-h { font-weight: 600; font-size: .95rem; border-left: 3px solid var(--gold); padding-left: .5rem; }
.lead-wb-stack-hint { font-size: .82rem; }
.lead-wb-stack[open] .lead-wb-grid {
  padding: .3rem .5rem .45rem;
}
/* Lead phase tabs — Review vs Before deal. */
.lead-phase-tabs { margin-bottom: .8rem; }
.lead-phase-next { display: flex; align-items: center; gap: .8rem; margin: 1rem 0 .2rem; padding: .8rem 1rem; border: 1px dashed color-mix(in srgb, var(--gold) 40%, var(--line)); border-radius: 10px; background: color-mix(in srgb, var(--gold) 6%, transparent); }
/* The display:flex above would otherwise beat the [hidden] attribute, so a converted (read-only) lead
   still showed the "Continue to pre-deal checklist" bar. Honour hidden so it disappears as intended. */
.lead-phase-next[hidden] { display: none; }
.lead-phase-back { margin-bottom: .7rem; }
.phase-badge { display: inline-flex; align-items: center; justify-content: center; min-width: 1.15rem; height: 1.15rem; padding: 0 .3rem; margin-left: .35rem; border-radius: 999px; font-size: .68rem; font-weight: 700; line-height: 1; }
.phase-badge.danger { background: color-mix(in srgb, var(--red, #d9534f) 22%, transparent); color: var(--red, #d9534f); border: 1px solid color-mix(in srgb, var(--red, #d9534f) 45%, transparent); }
.phase-badge.ok { background: color-mix(in srgb, var(--green, #3ca36b) 20%, transparent); color: var(--green, #6FE3B0); border: 1px solid color-mix(in srgb, var(--green, #3ca36b) 45%, transparent); }

/* Lead closing checklist — documents to sign + fees to pay before convert. */
.lead-closing-panel { margin: 0 0 .9rem; border-color: color-mix(in srgb, var(--gold) 30%, var(--line)); }
.lead-closing-panel > h2 { margin-bottom: .2rem; }
.closing-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; align-items: start; }
@media (max-width: 760px) { .closing-cols { grid-template-columns: 1fr; } }
.closing-list { display: flex; flex-direction: column; gap: .4rem; }
.closing-item { display: flex; align-items: center; gap: .6rem; padding: .45rem .6rem; border: 1px solid var(--line); border-radius: 8px; background: var(--panel-2); }
.closing-item .ci-name { font-weight: 500; }
.closing-item .ci-status { margin-left: auto; }
.closing-item .ci-rm { color: var(--muted); padding: .1rem .45rem; }
.closing-add { display: flex; gap: .4rem; margin-top: .5rem; }
.closing-add select { flex: 1; min-width: 0; }
.closing-foot { display: flex; align-items: center; gap: .6rem; margin-top: 1rem; padding-top: .8rem; border-top: 1px solid var(--line); }

/* Leads list — Active vs Closed sections. Two tables flow down the page (not one app-shell scroll),
   and both get the same height cap so they read consistently instead of the active one being squeezed. */
main.grid-page.leads-page { display: block; }
main.grid-page.leads-page #grid { display: block; }
main.grid-page.leads-page #grid .table-scroll,
main.grid-page.leads-page .leads-closed .table-scroll { flex: none; height: 42vh; max-height: 42vh; min-height: 200px; overflow: auto; }
.leads-sec-h { font-size: 1rem; font-weight: 600; margin: .2rem 0 .15rem; border-left: 3px solid var(--gold); padding-left: .5rem; display: inline-block; }
.leads-sec-count { color: var(--muted); font-weight: 400; font-size: .85rem; }
details.leads-closed { margin-top: 1.4rem; }
details.leads-closed > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: .5rem; }
details.leads-closed > summary::-webkit-details-marker { display: none; }
details.leads-closed > summary::after { content: '▾'; color: var(--gold); transition: transform .15s ease; }
details.leads-closed[open] > summary::after { transform: rotate(180deg); }
details.leads-closed[open] > summary { margin-bottom: .2rem; }

.lead-wb-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  grid-template-rows: auto;
  /* Shared scroll height keeps Submission and Documents panels aligned. */
  --lead-wb-scroll-h: min(22rem, 40vh);
  /* AI lives in the action bar above; workspace is Submission + Documents side by side. */
  grid-template-areas:
    "submission rightstack";
  gap: 0.4rem 0.5rem;
  align-items: stretch;
  container-type: inline-size;
  container-name: lead-wb;
}

/* Triage + AI Analysis as side-by-side action bars above the workspace. */
.lead-action-bars {
  display: flex;
  align-items: stretch;
  gap: .55rem;
  margin: 0 0 .1rem;
  min-width: 0;
}
.lead-action-bar {
  display: flex;
  flex: 1 1 0;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
  align-items: center;
  gap: .75rem;
  padding: .35rem .85rem .35rem .7rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
}
.lead-action-bar .lt-head { flex: 0 0 auto; font-weight: 600; font-size: .9rem; border-left: 3px solid var(--gold); padding-left: .5rem; }
.lead-action-bar .lt-head-spacer { flex: 1 1 auto; min-width: 2rem; }
.lead-ai-bar .ai-status { flex-shrink: 0; margin-left: .1rem; }
.lead-ai-bar.ai-drop-open { position: relative; z-index: 120; }
.lead-action-bars:has(.ai-drop-open) { position: relative; z-index: 120; overflow: visible; }
.lead-workbench:has(.ai-drop-open) { overflow: visible; }
.lead-action-bars:has(#triagePanel[hidden]) .lead-ai-bar { flex: 1 1 100%; }
.lt-expand-wrap { position: relative; flex: 0 0 auto; }
.lt-drop { position: fixed; z-index: 500; width: min(680px, calc(100vw - 1.5rem)); padding: .8rem .9rem; box-sizing: border-box; border: 1px solid color-mix(in srgb, var(--gold) 50%, var(--line)); border-radius: 10px; background: var(--panel); box-shadow: 0 14px 40px rgba(0, 0, 0, .45); }
.lead-wb-col-left,
.lead-wb-col-right { display: contents; }
.lead-wb-triage { grid-area: triage; align-self: start; min-width: 0; }
.lead-wb-submission {
  grid-area: submission;
  align-self: stretch;
  min-width: 0;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.lead-wb-subcol {
  grid-area: rightstack;
  display: flex;
  flex-direction: column;
  gap: 0;
  min-width: 0;
  align-self: stretch;
  min-height: 0;
}
.lead-wb-subcol > .lead-panel {
  width: 100%;
  min-width: 0;
  min-height: 0;
  flex: 1 1 auto;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
}
.lead-wb-docs {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  align-self: stretch;
  box-sizing: border-box;
}
.lead-wb-docs #d-docs {
  flex: 1 1 0;
  min-height: var(--lead-wb-scroll-h, min(22rem, 40vh));
  height: auto;
  max-height: none;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-right: .35rem;
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  scrollbar-color: color-mix(in srgb, var(--gold) 45%, var(--line)) transparent;
}
.lead-wb-docs #d-docs::-webkit-scrollbar { width: 9px; }
.lead-wb-docs #d-docs::-webkit-scrollbar-track { background: transparent; border-radius: 999px; margin: .1rem 0; }
.lead-wb-docs #d-docs::-webkit-scrollbar-thumb { background: color-mix(in srgb, var(--gold) 45%, var(--line)); border-radius: 999px; border: 2px solid var(--panel); }
.lead-wb-docs #d-docs::-webkit-scrollbar-thumb:hover { background: var(--gold); }
.lead-wb-exec { align-self: start; flex: 0 0 auto; }
.lead-wb-notes {
  min-width: 0;
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  max-height: none;
  overflow: visible;
}
.lead-wb-notes .note-compose { flex: 0 0 auto; }
.lead-wb-notes .note-scroll {
  flex: 0 0 auto;
  min-height: 0;
  max-height: none;
  overflow: visible;
}
.lead-panel-intro { margin: -.35rem 0 .55rem; font-size: .82rem; }
.lead-panel-submission {
  container-type: inline-size;
  container-name: submission-panel;
  box-sizing: border-box;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  padding: .5rem .7rem .55rem;
  display: flex;
  flex-direction: column;
}
.lead-panel-submission .submission-grid {
  grid-template-columns: 1fr 1fr;
  gap: .4rem .7rem;
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  min-height: var(--lead-wb-scroll-h, min(22rem, 40vh));
  height: auto;
  max-height: none;
  overflow-x: hidden;
  overflow-y: auto;
  padding-right: .15rem;
  scrollbar-width: thin;
  scrollbar-color: color-mix(in srgb, var(--gold) 35%, var(--line)) transparent;
}
.lead-panel-submission .submission-grid::-webkit-scrollbar { width: 8px; }
.lead-panel-submission .submission-grid::-webkit-scrollbar-thumb { background: color-mix(in srgb, var(--gold) 35%, var(--line)); border-radius: 999px; }
.lead-panel-submission > h2 { flex: 0 0 auto; margin-bottom: .35rem; font-size: .88rem; }
.lead-panel-submission .submission-col-wide { grid-column: 1 / -1; }
.lead-panel-submission .sub-sec-h { margin: 0 0 .2rem; font-size: .64rem; letter-spacing: .07em; }
.lead-panel-submission .detailbox { overflow-wrap: anywhere; word-break: break-word; gap: .18rem .55rem; font-size: .82rem; }
.lead-panel-submission .detailbox .k { font-size: .76rem; line-height: 1.2; }
/* Two label/value pairs per row — one shared grid so column 2 lines up across sections. */
.lead-panel-submission .submission-kv-grid {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr) max-content minmax(0, 1fr);
  gap: .06rem .35rem;
  align-items: baseline;
}
.lead-panel-submission .submission-kv-grid .kv-span { grid-column: 1 / -1; margin: .28rem 0 .12rem; }
.lead-panel-submission .submission-kv-grid .kv-span:first-child { margin-top: 0; }
.lead-panel-submission .detailbox-2col { display: contents; }
.lead-panel-submission #d-fields-msg .sub-msg {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: normal;
  word-break: break-word;
  max-height: none;
  min-height: 0;
  margin: 0;
  padding: .28rem .4rem;
  font-size: .84rem;
  line-height: 1.4;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-2);
  cursor: help;
}
.lead-panel-submission #d-fields-msg .sub-msg-empty { cursor: default; color: var(--muted); }
.lead-panel-submission #d-fields-final .sub-final {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: normal;
  word-break: break-word;
  max-height: none;
  min-height: 0;
  margin: 0;
  padding: .28rem .4rem;
  font-size: .84rem;
  line-height: 1.4;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-2);
  cursor: help;
}
.lead-panel-submission #d-fields-final .sub-final-empty { cursor: default; color: var(--muted); }
.exec-fields .field.exec-final textarea { min-height: 5.5rem; }
.lead-panel-submission #d-execsummary .detailbox-exec {
  grid-template-columns: max-content minmax(0, 1fr) max-content minmax(0, 1fr);
  column-gap: .65rem 1rem;
  row-gap: .22rem;
}
.lead-panel-submission #execSummarySec[hidden] { display: none !important; }
.lead-panel-submission .exec-grp-h {
  margin: .55rem 0 .25rem;
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--gold);
}
.lead-panel-submission .exec-grp-h:first-child { margin-top: 0; }
.lead-panel-submission .sub-empty { color: var(--muted); }
.lead-panel-submission #d-execsummary {
  overflow: visible;
  max-height: none;
  padding: 0;
  border: none;
  border-radius: 0;
  background: transparent;
}
.lead-panel-submission #d-execsummary .detailbox-exec { margin: 0 0 .15rem; }
.lead-panel-submission #d-execsummary .exec-summary-text { white-space: pre-wrap; line-height: 1.35; font-size: .82rem; }
.lead-wb-docs.lead-panel {
  flex: 1 1 auto;
  min-height: 0;
  padding: .5rem .7rem .55rem;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-sizing: border-box;
}
.lead-wb-docs.lead-panel h2 { flex: 0 0 auto; margin-bottom: .35rem; font-size: .88rem; }
.lead-wb-docs .doc-stack .doc-group {
  margin-bottom: .32rem;
  padding: .32rem .5rem .36rem;
}
.lead-wb-docs .doc-group-h { margin-bottom: 0; padding-bottom: .1rem; }
.lead-wb-docs .doc-upload-row { display: flex; align-items: center; gap: .45rem; flex-wrap: wrap; margin-top: .28rem; }
.lead-wb-docs .doc-upload-row .doc-up-msg { font-size: .72rem; min-height: 1em; }
.lead-wb-docs .doc-upload-row .pgbtn { padding: .14rem .45rem; font-size: .72rem; }
@container submission-panel (max-width: 480px) {
  .lead-panel-submission .submission-grid { grid-template-columns: 1fr; }
  .lead-panel-submission .submission-col-wide { grid-column: auto; }
  .lead-panel-submission .submission-kv-grid { grid-template-columns: max-content minmax(0, 1fr); }
  .lead-panel-submission #d-execsummary .detailbox-exec { grid-template-columns: max-content 1fr; }
}
#triagePanel[hidden] { display: none !important; }
@media (max-width: 720px) {
  .lead-action-bars { flex-direction: column; }
}
@container lead-wb (max-width: 720px) {
  .lead-wb-grid,
  .lead-wb-grid:has(#triagePanel[hidden]) {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto;
    grid-template-areas:
      "submission"
      "docs";
    align-items: start;
  }
  .lead-wb-submission { grid-area: submission; align-self: start; }
  .lead-wb-subcol { display: contents; }
  .lead-wb-docs { grid-area: docs; }
  .lead-wb-notes { min-height: 0; max-height: none; }
}
/* Tight header stack — no dead air between summary strip and workbench. */
main.lead-page > .lead-page-pin .lead-head { margin-bottom: .45rem; }
main.lead-page > .lead-page-pin #meta .record-summary { margin-bottom: .55rem; }
main.lead-page > .lead-page-pin #investorRead[hidden],
main.lead-page > .lead-page-pin #convertedBanner[hidden] { display: none !important; }
main.lead-page > .lead-page-pin #investorRead:not([hidden]) { margin: .35rem 0 0; }
main.lead-page > .lead-page-pin #convertedBanner:not([hidden]) { margin: .35rem 0 .45rem; }
.lead-col { display: grid; gap: 1rem; align-content: start; }
.lead-panel { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 1rem 1.15rem; }
.lead-panel h2 { font-size: .95rem; margin: 0 0 .75rem; font-family: inherit; font-weight: 600; border-left: 3px solid var(--gold); padding-left: .5rem; }
.lead-panel-h { display: flex; align-items: center; justify-content: space-between; gap: .75rem; }
.lead-panel-h-t { flex: 1; min-width: 0; }
.lead-panel-count { font-size: .88rem; font-weight: 600; font-variant-numeric: tabular-nums; flex-shrink: 0; line-height: 1; }
.lead-panel-count.danger { color: var(--red); }
.lead-panel-count.ok { color: var(--green); }
button.lead-doc-chip { border: none; cursor: pointer; font: inherit; padding: .12rem .45rem; }
button.lead-doc-chip:hover { filter: brightness(1.12); }
.lead-panel-focus { outline: 1px solid color-mix(in srgb, var(--gold) 65%, transparent); outline-offset: 2px; border-radius: 6px; animation: lead-panel-focus-fade 2.2s ease-out forwards; }
@keyframes lead-panel-focus-fade { from { outline-color: color-mix(in srgb, var(--gold) 65%, transparent); } to { outline-color: transparent; } }
#fitChip .chip { cursor: help; }
.lead-head .spacer { flex: 1; }
.lead-deal-hint {
  font-size: .82rem;
  color: var(--muted);
  padding: .38rem .75rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  max-width: min(22rem, 42vw);
  line-height: 1.3;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity .24s ease, transform .24s ease;
  pointer-events: none;
}
.lead-deal-hint.show { opacity: 1; transform: translateY(0); }
.lead-deal-hint.warn { color: #e8b4ae; border-color: color-mix(in srgb, var(--red) 45%, var(--line)); }
.lead-deal-hint.flash { border-color: var(--gold); color: var(--gold); animation: hintPulse 2.5s ease-out; }
@keyframes hintPulse {
  0%, 18% { box-shadow: 0 0 0 2px color-mix(in srgb, var(--gold) 35%, transparent); }
  100% { box-shadow: none; }
}

/* Lead page: KPI + breadcrumb + summary stay fixed; only the workbench scrolls (same shell as deal page). */
@media (min-width: 961px) {
  main.lead-page {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
    flex: 1 1 auto;
    padding-bottom: 0;
  }
  main.lead-page > .lead-page-pin {
    flex: 0 0 auto;
    position: static;
    top: auto;
    z-index: auto;
    box-shadow: none;
    margin-bottom: .25rem;
  }
  main.lead-page .lead-workbench {
    flex: 1 1 auto;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    padding-right: .35rem;
    padding-bottom: 1.5rem;
    scrollbar-width: thin;
    scrollbar-color: color-mix(in srgb, var(--gold) 35%, var(--line)) transparent;
  }
  main.lead-page .lead-workbench::-webkit-scrollbar { width: 10px; }
  main.lead-page .lead-workbench::-webkit-scrollbar-track { background: transparent; }
  main.lead-page .lead-workbench::-webkit-scrollbar-thumb {
    background: color-mix(in srgb, var(--gold) 35%, var(--line));
    border-radius: 999px;
    border: 2px solid var(--navy-0);
  }
  main.lead-page .lead-workbench::-webkit-scrollbar-thumb:hover { background: var(--gold); }
  .lead-wb-stack {
    flex: none;
    min-height: 0;
    overflow: visible;
  }
  .lead-wb-stack[open] .lead-wb-grid {
    padding-right: .35rem;
  }
  .lead-wb-notes { flex: none; }

  /* Deal page: same app-shell — KPI + breadcrumb + summary + tab bar stay fixed; section content scrolls. */
  main.deal-page { display: flex; flex-direction: column; overflow: hidden; min-height: 0; }
  main.deal-page > #kpiWrap, main.deal-page > .deal-head, main.deal-page > #summary { flex: 0 0 auto; }
  main.deal-page .workspace { flex: 1 1 auto; min-height: 0; }
  main.deal-page .ws-nav { flex: 0 0 auto; }
  main.deal-page .ws-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding-right: .35rem; padding-bottom: 1.25rem; }
}

/* Deal (and similar) workspace — horizontal tabs on top + section panels below. */
.workspace { display: flex; flex-direction: column; gap: .85rem; }
.ws-nav { display: flex; flex-direction: row; flex-wrap: wrap; gap: .25rem; border-bottom: 1px solid var(--line); }
.ws-nav button {
  background: transparent; border: none; border-bottom: 2px solid transparent; margin-bottom: -1px;
  color: var(--muted); cursor: pointer; font: inherit; font-size: .9rem;
  padding: .55rem .95rem; border-radius: 6px 6px 0 0;
}
.ws-nav button:hover { color: var(--ink); background: #ffffff0a; }
.ws-nav button.active { color: var(--gold); border-bottom-color: var(--gold); font-weight: 600; }
.ws-body { min-width: 0; }
.ws-panel { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 1rem 1.15rem; margin-bottom: 1rem; }
.ws-panel:last-child { margin-bottom: 0; }
.ws-panel h2 { font-size: .95rem; margin: 0 0 .75rem; font-family: inherit; font-weight: 600; border-left: 3px solid var(--gold); padding-left: .5rem; }
.ws-section[hidden] { display: none !important; }
.deal-head .spacer { flex: 1; }

/* Record summary strip — borrower/lead name + labeled key metrics (deal & lead headers). */
.record-summary {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: .85rem 1.5rem; margin: 0 0 1.1rem; padding: .9rem 1.1rem;
  background: linear-gradient(135deg, var(--panel) 0%, var(--panel-2) 100%);
  border: 1px solid var(--line); border-radius: 10px;
}
.rs-primary { display: flex; flex-direction: column; gap: .2rem; min-width: 10rem; }
.rs-name { font-family: 'Playfair Display', Georgia, serif; font-size: 1.2rem; font-weight: 600; color: var(--ink); line-height: 1.15; }
.rs-co { font-size: .85rem; color: var(--muted); letter-spacing: .01em; line-height: 1.3; display: inline-flex; align-items: center; }
.rs-role {
  font-size: .85rem;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: .04em;
  text-transform: uppercase;
  line-height: 1.3;
  display: inline-flex;
  align-items: center;
  gap: .35rem;
}
.rs-subline .rs-co + .rs-contact > .rs-role:first-child::before {
  content: '·';
  margin: 0 .5rem;
  opacity: .55;
  text-transform: none;
  letter-spacing: 0;
}
/* Company name + contact share one line under the record name. */
.rs-subline { display: flex; flex-wrap: wrap; align-items: center; gap: .25rem 1.1rem; margin-top: .15rem; line-height: 1.3; }
/* Lead contact row — role, email, phone, location, source, loan type, received. */
.rs-contact { display: flex; flex-wrap: wrap; align-items: center; gap: .25rem 1.1rem; line-height: 1.3; min-height: 1.3em; }
.rs-contact-i { font-size: .85rem; color: var(--ink); text-decoration: none; display: inline-flex; align-items: center; gap: .35rem; line-height: 1.3; }
.rs-contact-i:hover { color: var(--gold); }
.rs-location { font-size: .85rem; color: var(--muted); display: inline-flex; align-items: center; gap: .35rem; line-height: 1.3; max-width: min(22rem, 42vw); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rs-received { font-size: .85rem; color: var(--ink); display: inline-flex; align-items: center; gap: .35rem; line-height: 1.3; white-space: nowrap; }
.rs-received .pginfo { font-size: .85rem; color: var(--muted); }
.rs-source { font-size: .85rem; color: var(--muted); display: inline-flex; align-items: center; gap: .35rem; line-height: 1.3; white-space: nowrap; }
.rs-loan-type { font-size: .85rem; color: var(--muted); display: inline-flex; align-items: center; gap: .35rem; line-height: 1.3; white-space: nowrap; }
/* Banner on a converted (read-only) lead — its only action is jumping to the deal. */
.converted-banner { display: flex; align-items: center; gap: .6rem; margin: 0 0 1rem; padding: .6rem .9rem; border: 1px solid #C6AF5C66; border-radius: 10px; background: #C6AF5C14; color: var(--ink); font-size: .9rem; }
.converted-banner[hidden] { display: none; }   /* hide the empty bar on non-converted leads */
.converted-banner.danger { border-color: #C0473A66; background: #C0473A14; }   /* declined deal — read-only */
.converted-banner .cb-lock { font-size: 1rem; }
.converted-banner .cb-text { flex: 1; }
.converted-banner .cb-view { white-space: nowrap; }
.rs-stats { display: flex; flex-wrap: wrap; gap: .65rem 1.35rem; align-items: flex-end; }
.rs-stat { display: flex; flex-direction: column; gap: .18rem; min-width: 4.5rem; }
/* Lead & deal headers: centre each stat (label over value). */
#meta .rs-stat, #summary .rs-stat { align-items: center; text-align: center; }
.rs-k { font-size: .65rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.rs-v { font-size: .95rem; font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; line-height: 1.2; }
.rs-v.accent { color: var(--gold); }
.rs-v.ok { color: var(--green); }
.rs-v.danger { color: var(--red); }
.rs-v.muted { color: var(--muted); font-weight: 500; font-style: italic; }
.record-summary.compact { padding: .7rem .95rem; margin-bottom: .85rem; gap: .65rem 1.1rem; }
.record-summary.compact .rs-name { font-size: 1.05rem; }
.record-summary.mini { padding: .55rem .65rem; margin: .35rem 0 0; gap: .4rem .65rem; border-radius: 8px; }
.record-summary.mini .rs-name { font-size: .92rem; }
.record-summary.mini .rs-stats { gap: .35rem .65rem; }
.record-summary.mini .rs-stat { min-width: 3rem; }
.record-summary.mini .rs-k { font-size: .58rem; }
.record-summary.mini .rs-v { font-size: .8rem; }
.record-summary.embedded { margin-bottom: .75rem; }

/* Table / list cells — Playfair names + muted sub-lines (deals, leads, invoices). */
.rs-cell { line-height: 1.3; max-width: 18rem; }
.rs-cell-name { font-family: 'Playfair Display', Georgia, serif; font-weight: 600; font-size: .92rem; color: var(--ink); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rs-cell-sub { font-size: .78rem; color: var(--muted); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.deal-num { font-family: 'Playfair Display', Georgia, serif; font-weight: 600; color: var(--ink); text-decoration: none; }
.deal-num:hover { color: var(--gold); }
.amount-accent { color: var(--gold); font-weight: 600; font-variant-numeric: tabular-nums; }
.borrowercell .bname { font-family: 'Playfair Display', Georgia, serif; font-weight: 600; color: var(--ink); }
@media (max-width: 640px) { .rs-stats { width: 100%; } }
@media (max-width: 800px) {
  .workspace { grid-template-columns: 1fr; }
  .ws-nav { flex-direction: row; flex-wrap: wrap; position: static; gap: .35rem; margin-bottom: .5rem; }
  .ws-nav button { border-left: none; border-bottom: 2px solid transparent; border-radius: 6px; padding: .4rem .65rem; }
  .ws-nav button.active { border-left: none; border-bottom-color: var(--gold); }
}
/* ---- HDMG marketing-site chrome ---- */
.utilbar { flex: 0 0 auto; display: flex; justify-content: space-between; align-items: center;
  background: #0A0F1C; border-bottom: 1px solid var(--line); color: var(--muted);
  font-size: .74rem; letter-spacing: .02em; padding: .3rem clamp(1rem, 4vw, 3rem); }
.utilbar .util-ic { color: var(--gold); }
.utilbar .util-right { color: var(--muted); }
@media (max-width: 760px) { .utilbar .util-right { display: none; } }

.appbar { grid-template-columns: auto 1fr auto; padding-top: .7rem; padding-bottom: .7rem; }
.brand { flex-direction: column; align-items: flex-start; gap: .1rem; }
.brand .wm { font-size: 1.5rem; }
.brand-sub { font-size: .58rem; letter-spacing: .32em; color: var(--gold); text-transform: uppercase; }

.topnav { gap: .15rem; }
.topnav .navlink { text-transform: uppercase; letter-spacing: .12em; font-size: .74rem; font-weight: 500; }

.headright { display: flex; align-items: center; gap: 1rem; justify-self: end; }
.submit-cta { text-transform: uppercase; letter-spacing: .08em; font-size: .74rem; font-weight: 700; }
@media (max-width: 900px) { .submit-cta { display: none; } }

/* ---- Public marketing page (submit a deal / landing) ---- */
.mktg { display: block; height: auto; overflow: visible; }
.mktg body, body.mktg { height: auto; overflow: auto; }
.hero { position: relative; padding: clamp(3rem, 9vw, 7rem) clamp(1rem, 6vw, 5rem) clamp(2rem, 5vw, 4rem);
  background: radial-gradient(1200px 500px at 75% -10%, rgba(198,175,92,.10), transparent 60%), linear-gradient(180deg, #0F1628, #0B1120); }
.hero .eyebrow { color: var(--gold); text-transform: uppercase; letter-spacing: .28em; font-size: .76rem; }
.hero h1 { font-family: 'Playfair Display', Georgia, serif; font-weight: 700; font-size: clamp(2.1rem, 5vw, 3.6rem);
  line-height: 1.08; margin: .6rem 0 .8rem; max-width: 18ch; }
.hero h1 .gold { color: var(--gold); }
.hero p.lede { color: #C7CDD9; font-size: 1.05rem; line-height: 1.6; max-width: 56ch; margin: 0 0 1.6rem; }
.hero .hero-cta { display: flex; gap: .8rem; flex-wrap: wrap; }
.btn.lg { padding: .7rem 1.4rem; font-size: .9rem; }
.mktg-section { padding: clamp(2rem, 5vw, 4rem) clamp(1rem, 6vw, 5rem); border-top: 1px solid var(--line); }
.mktg-grid { display: grid; grid-template-columns: 1.1fr 1fr; gap: clamp(1.5rem, 4vw, 3.5rem); align-items: start; }
@media (max-width: 860px) { .mktg-grid { grid-template-columns: 1fr; } }
.value-list { display: grid; gap: 1rem; }
.value-list .v { display: flex; gap: .8rem; }
.value-list .v .vic { color: var(--gold); font-size: 1.2rem; line-height: 1.2; }
.value-list .v h4 { margin: 0 0 .2rem; font-size: 1rem; }
.value-list .v p { margin: 0; color: var(--muted); font-size: .9rem; line-height: 1.5; }
.dealcard { background: linear-gradient(180deg, var(--panel-2), var(--panel)); border: 1px solid var(--line); border-radius: 14px;
  padding: clamp(1.2rem, 3vw, 2rem); box-shadow: 0 20px 50px rgba(0,0,0,.35); }
.dealcard h3 { font-family: 'Playfair Display', Georgia, serif; margin: 0 0 .3rem; }
.dealcard .sub { color: var(--muted); font-size: .88rem; margin: 0 0 1.2rem; }
.dealcard .ok { text-align: center; padding: 1rem 0; }
.dealcard .ok .big { color: var(--gold); font-family: 'Playfair Display', Georgia, serif; font-size: 1.4rem; }
.mktg-footer { padding: 2rem clamp(1rem, 6vw, 5rem); border-top: 1px solid var(--line); color: var(--muted); font-size: .82rem;
  display: flex; justify-content: space-between; flex-wrap: wrap; gap: .5rem; }

/* ---- Public submit-deal page (matches hdmginvest.com light layout) ---- */
body.deal-submit-page {
  height: auto; overflow: auto; display: block;
  background: #F8F6F1; color: #0A1628;
  font-family: 'Inter', 'Helvetica Neue', Arial, sans-serif;
  color-scheme: light;
}
.deal-submit-page a { color: #9A7B2F; }
.deal-submit-page a:hover { color: #C8A951; }
.ds-hero {
  background: #0A1628; color: #fff;
  padding: 5.5rem 1.5rem 3.5rem;
}
.ds-hero-inner { max-width: 56rem; margin: 0 auto; }
.ds-back {
  display: inline-flex; align-items: center; gap: .35rem;
  color: #C8A951; text-decoration: none; font-size: .72rem;
  letter-spacing: .12em; text-transform: uppercase; margin-bottom: 1.5rem;
}
.ds-back:hover { color: #E8D48B; }
.ds-eyebrow {
  color: #C8A951; font-size: .68rem; letter-spacing: .28em;
  text-transform: uppercase; margin: 0 0 .75rem;
}
.ds-hero h1 {
  font-family: 'Playfair Display', Georgia, serif; font-weight: 700;
  font-size: clamp(2rem, 5vw, 3.25rem); line-height: 1.08; margin: 0 0 .75rem;
}
.ds-rule { width: 4rem; height: 2px; background: #C8A951; margin-bottom: 1.1rem; }
.ds-lede { color: rgba(255,255,255,.55); font-size: 1rem; line-height: 1.65; max-width: 40rem; margin: 0; }
.ds-lede a { color: #C8A951; font-weight: 600; text-decoration: none; }
.ds-main { max-width: 56rem; margin: 0 auto; padding: 2.5rem 1.5rem 4rem; }
.ds-section { margin-bottom: 2.5rem; }
.ds-sec-head { display: flex; align-items: center; gap: .75rem; margin-bottom: 1.25rem; }
.ds-sec-num {
  width: 1.75rem; height: 1.75rem; flex-shrink: 0;
  background: #0A1628; color: #C8A951;
  font-size: .72rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  border-radius: 2px;
}
.ds-sec-head h2 { margin: 0; font-size: 1.05rem; font-weight: 700; color: #0A1628; }
.ds-panel {
  background: #fff; border: 1px solid #E8E4DC;
  padding: 1.5rem 1.75rem; border-radius: 2px;
  box-shadow: 0 1px 3px rgba(10,22,40,.04);
}
.ds-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.15rem; }
.ds-grid .full { grid-column: 1 / -1; }
@media (max-width: 720px) { .ds-grid { grid-template-columns: 1fr; } }
.ds-field label {
  display: block; font-size: .68rem; font-weight: 600;
  letter-spacing: .08em; text-transform: uppercase;
  color: #4B5563; margin-bottom: .35rem;
}
.ds-field label .req { color: #DC2626; }
.ds-field input, .ds-field select, .ds-field textarea {
  width: 100%; background: #fff; border: 1px solid #D1D5DB;
  color: #0A1628; font: inherit; font-size: .875rem;
  padding: .7rem .85rem; border-radius: 2px;
  transition: border-color .15s, box-shadow .15s;
}
.ds-field input::placeholder, .ds-field textarea::placeholder { color: #9CA3AF; }
.ds-field input:focus, .ds-field select:focus, .ds-field textarea:focus {
  outline: none; border-color: #C8A951; box-shadow: 0 0 0 1px #C8A951;
}
.ds-field select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%236B7280' stroke-width='2'%3E%3Cpath d='M4 6l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right .75rem center; padding-right: 2rem;
}
.ds-field textarea { min-height: 7rem; resize: vertical; line-height: 1.5; }
.ds-file-hint { font-size: .78rem; color: #6B7280; margin-top: .35rem; line-height: 1.45; }
.ds-file-hint a { color: #9A7B2F; }
.ds-actions { margin-top: 2rem; display: flex; flex-direction: column; align-items: center; gap: .75rem; }
.ds-submit {
  width: 100%; max-width: 22rem; padding: .85rem 1.5rem;
  background: #0A1628; color: #C8A951; border: none;
  font-size: .78rem; font-weight: 700; letter-spacing: .14em;
  text-transform: uppercase; cursor: pointer; border-radius: 2px;
  transition: background .15s, color .15s;
}
.ds-submit:hover { background: #132038; color: #E8D48B; }
.ds-submit:disabled { opacity: .55; cursor: not-allowed; }
.ds-urgent { font-size: .82rem; color: #6B7280; }
.ds-urgent a { color: #9A7B2F; font-weight: 600; text-decoration: none; }
.ds-footnote { margin-top: 1.5rem; font-size: .75rem; color: #9CA3AF; line-height: 1.5; text-align: center; }
#hdmg-lead-status { text-align: center; font-size: .9rem; font-weight: 500; }
.deal-submit-page .exec-note {
  margin: 0 0 .9rem; padding: .65rem .85rem; border-radius: 2px; font-size: .82rem; font-weight: 700;
  letter-spacing: .03em; line-height: 1.45; background: #FFF8E7; border: 1px solid #E8D48B; color: #5C4A1F;
}
.deal-submit-page .exec-template { font-size: .85rem; color: #6B7280; margin: 0 0 .85rem; }
.deal-submit-page .ds-attach-title { margin: 1.1rem 0 .45rem; font-size: .95rem; font-weight: 700; color: #0A1628; }
.deal-submit-page .intake-sec {
  border: 1px solid #E8E4DC; border-radius: 2px; background: #fff;
  margin-bottom: 1.25rem;
}
.deal-submit-page .intake-sec > summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; gap: .5rem;
  padding: .85rem 1rem; font-weight: 700; font-size: 1rem; color: #0A1628;
}
.deal-submit-page .intake-sec > summary::-webkit-details-marker { display: none; }
.deal-submit-page .intake-sec > summary::after { content: '▾'; margin-left: auto; color: #C8A951; }
.deal-submit-page .intake-sec[open] > summary::after { transform: rotate(180deg); }
.deal-submit-page .intake-sec .intake-body { padding: 0 1rem 1rem; }
.deal-submit-page .intake-sec .intake-body .ds-section { margin-bottom: 0; }
.deal-submit-page .exec-fields .exec-grp {
  margin: 1rem 0 .35rem; font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: #9A7B2F;
}
.deal-submit-page .exec-fields .ds-field { margin-bottom: .85rem; }
.deal-submit-page .exec-fields .exec-final textarea { min-height: 5.5rem; }
.deal-submit-page .dealpkg .dp-row {
  display: flex; align-items: center; gap: .8rem; flex-wrap: wrap;
  padding: .55rem .7rem; margin-bottom: .45rem;
  border: 1px solid #E8E4DC; border-radius: 2px; background: #FAFAF8;
}
.deal-submit-page .dealpkg .dp-row label { flex: 1; min-width: 12rem; font-size: .85rem; font-weight: 500; color: #0A1628; }
.deal-submit-page .dealpkg .dp-row input[type="file"] { font-size: .82rem; }
.deal-submit-page .ds-status { text-align: center; margin-top: .75rem; min-height: 1.2rem; font-size: .9rem; font-weight: 500; }
.deal-submit-page .ds-status.err { color: #DC2626; }
.deal-submit-page .ds-status.ok { color: #9A7B2F; }

/* ---- Live dashboard ---- */
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: #3FA34D; box-shadow: 0 0 0 0 rgba(63,163,77,.6); animation: livePulse 2s infinite; display: inline-block; }
@keyframes livePulse { 0% { box-shadow: 0 0 0 0 rgba(63,163,77,.5); } 70% { box-shadow: 0 0 0 6px rgba(63,163,77,0); } 100% { box-shadow: 0 0 0 0 rgba(63,163,77,0); } }
@keyframes mfBump { 0% { color: var(--gold); transform: scale(1.12); } 100% { transform: scale(1); } }
.mf-bump { animation: mfBump .6s ease; display: inline-block; }
@media (prefers-reduced-motion: reduce) { .live-dot, .mf-bump { animation: none; } }

/* ---- Alert bell (header) ---- */
.mf-bell { position: relative; }
.mf-bell-btn { position: relative; background: transparent; border: none; color: var(--muted); cursor: pointer; padding: .35rem; border-radius: 8px; line-height: 0; }
.mf-bell-btn:hover { color: var(--gold); background: #ffffff10; }
.mf-bell-btn svg { fill: currentColor; }
.mf-bell-badge { position: absolute; top: -2px; right: -2px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 999px;
  background: var(--red, #c0392b); color: #fff; font-size: .62rem; font-weight: 700; line-height: 16px; text-align: center;
  box-shadow: 0 0 0 0 rgba(192,57,43,.6); animation: bellPulse 1.8s infinite; }
@keyframes bellPulse { 0% { box-shadow: 0 0 0 0 rgba(192,57,43,.55); } 70% { box-shadow: 0 0 0 7px rgba(192,57,43,0); } 100% { box-shadow: 0 0 0 0 rgba(192,57,43,0); } }
.mf-bell-drop { position: absolute; right: 0; top: 2.2rem; z-index: 200; width: min(92vw, 22rem); background: var(--panel);
  border: 1px solid var(--line); border-radius: 10px; padding: .4rem; box-shadow: 0 12px 40px rgba(0,0,0,.5); animation: fadeIn .15s ease; }
.mf-bell-head { display: flex; justify-content: space-between; align-items: center; padding: .35rem .55rem .5rem; font-weight: 600; color: var(--gold); }
.mf-bell-item { display: flex; align-items: center; gap: .5rem; padding: .45rem .55rem; border-radius: 8px; color: var(--ink); text-decoration: none; }
.mf-bell-item:hover { background: #ffffff10; }
.mf-bell-msg { font-size: .82rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mf-bell-empty { padding: .6rem .55rem; color: var(--muted); font-size: .85rem; }
.mf-bell-all { display: block; text-align: center; padding: .5rem; margin-top: .25rem; border-top: 1px solid var(--line); color: var(--gold); text-decoration: none; font-size: .82rem; }

/* ---- Alert banner (client portal) ---- */
.alert-banner { display: grid; gap: .5rem; margin-bottom: 1.2rem; }
.alert-item { display: flex; align-items: center; gap: .6rem; padding: .7rem .9rem; border-radius: 10px; border: 1px solid var(--line);
  background: var(--panel-2); animation: alertIn .25s ease; }
.alert-item.crit { border-color: #6f2f2f; background: linear-gradient(180deg, rgba(192,57,43,.12), var(--panel-2)); }
.alert-item.warn { border-color: var(--gold); background: linear-gradient(180deg, rgba(198,175,92,.10), var(--panel-2)); }
.alert-item .ai-ic { font-size: 1.1rem; }
.alert-item .ai-msg { flex: 1; font-size: .9rem; }
@keyframes alertIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: translateY(0); } }
@media (prefers-reduced-motion: reduce) { .mf-bell-badge, .alert-item { animation: none; } }

/* ---- Drag-and-drop boards (deals + leads) ---- */
.board { display: flex; gap: .75rem; overflow-x: auto; padding-bottom: .5rem; align-items: flex-start; }
.bcol { flex: 1 1 0; min-width: 200px; background: #ffffff08; border: 1px solid var(--line); border-radius: 10px; padding: .5rem; }
.bcol.over { border-color: var(--gold); background: #c6af5c14; }
.bcol-h { font-weight: 600; color: var(--gold); padding: .2rem .3rem .5rem; display: flex; justify-content: space-between; align-items: center; }
.bcol-list { min-height: 60px; display: flex; flex-direction: column; gap: .45rem; }
.bcard { position: relative; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: .5rem .6rem; cursor: grab; }
.bcard.dragging { opacity: .5; }
.bcard-head { display: flex; justify-content: space-between; align-items: flex-start; gap: .4rem; }
.bcard-t { font-family: 'Playfair Display', Georgia, serif; font-weight: 600; }
.bcard-menu { background: transparent; border: none; color: var(--muted); cursor: pointer; font-size: 1.15rem; line-height: 1; padding: 0 .15rem; border-radius: 6px; }
.bcard-menu:hover { color: var(--gold); background: #ffffff12; }
.bcard-pop { position: absolute; right: .4rem; top: 1.8rem; z-index: 20; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: .3rem; display: flex; flex-direction: column; gap: .15rem; box-shadow: 0 8px 24px #0009; }
.bcard-pop[hidden] { display: none; }
.bcard-pop button { background: transparent; border: none; color: var(--ink); text-align: left; padding: .35rem .7rem; border-radius: 6px; cursor: pointer; font: inherit; white-space: nowrap; }
.bcard-pop button:hover { background: #ffffff14; }
.brow { margin-top: .35rem; display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
.totals { margin-top: 1rem; }