/* ==========================================================================
   v2-loi.css - the LOI Analysis page.

   ITS OWN FILE, AND NOT A COPY OF v1's. Every rule here is written against v2's
   shell: v2's card, v2's density, v2's type scale, v2's spacing tokens. The
   only thing shared with v1 is the brand token layer, which both trees link off
   one copy on disk.

   EVERY SELECTOR IS PREFIXED `loi`, so nothing in here can reach the LOI Deals
   workspace or the Dashboard, and a future page can be built without reading
   this file first.

   STRICT CSP: no inline style attribute is parsed anywhere on this page. The
   two dynamic values the bars need - fill width and fill colour - arrive as the
   custom properties `--w` and `--bar`, written through CSSOM by cc2-dom.js.
   ========================================================================== */

/* ---------------- page frame ---------------- */
.loipage { display: flex; flex-direction: column; gap: var(--space-lg); }
.loipage .card + .card { margin-top: 0; }
/* Five tiles, five columns. The shell's .tiles is a six-up grid built for the
   Dashboard's six KPIs; left alone it leaves a sixth of the row empty here. */
.loipage .tiles { grid-template-columns: repeat(5, minmax(0, 1fr)); margin-bottom: 0; }
@media (max-width: 1280px) { .loipage .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.loibody { padding: var(--space-lg); }
.loibody > * + * { margin-top: var(--space-md); }
.loihead__num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; margin-right: var(--space-sm);
  border-radius: var(--radius-pill); background: var(--color-surface-2);
  color: var(--color-text-muted); font-size: 11px; font-weight: 700;
}
.loihead__hint { margin-left: auto; font-size: 12px; color: var(--color-text-muted); }

/* ---------------- text ---------------- */
.loisub {
  font-size: 13px; font-weight: 700; color: var(--color-text-strong);
  margin: var(--space-lg) 0 var(--space-xs);
}
.loibody > .loisub:first-child { margin-top: 0; }
.loinote { font-size: 12px; line-height: 1.5; color: var(--color-text-muted); margin: 0; }
.loilede { font-size: var(--text-body); margin: 0; }

.loitag {
  display: inline-block; padding: 1px 6px; margin-right: 6px;
  border-radius: var(--radius-xs); font-size: 11px; font-weight: 700;
  background: var(--color-surface-2); color: var(--color-text-muted);
  text-transform: uppercase; letter-spacing: .03em;
}
.loitag--caution {
  background: var(--surface-status-warning); color: var(--on-surface-status-warning);
}

/* THE MARK CARRIES THE WORD AND THE COLOUR IS SECOND. `n/a` plus a reason is
   readable in greyscale, on a projector and through a screen reader. */
.loina { display: inline-flex; flex-direction: column; gap: 1px; }
.loina__mark { font-weight: 700; color: var(--color-text-muted); font-size: 12px; }
.loina__why { font-size: 11px; color: var(--color-text-muted); line-height: 1.4; }

/* A group of notes: railed, so a caveat is visibly a caveat, and given room, so
   four of them are not one wall. */
.loinotes {
  border-left: 2px solid var(--color-border);
  padding: var(--space-sm) 0 var(--space-sm) var(--space-md);
}
.loinotes--stack { display: flex; flex-direction: column; gap: var(--space-sm); }
.loinotes--grid {
  display: grid; gap: var(--space-sm) var(--space-lg);
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

/* ---------------- definition lists ---------------- */
.loidl { margin: 0; display: flex; flex-direction: column; }
.loifield {
  display: grid; grid-template-columns: minmax(120px, 200px) 1fr;
  gap: var(--space-md); padding: 7px 0;
  border-top: 1px solid var(--color-border);
}
.loifield:first-child { border-top: 0; }
.loifield__k { font-size: 12px; font-weight: 600; color: var(--color-text-muted); }
.loifield__v { margin: 0; font-size: 13px; color: var(--color-text); min-width: 0; }
.loifield__v > * + * { margin-top: 4px; }
@media (max-width: 900px) { .loifield { grid-template-columns: 1fr; gap: 2px; } }

/* ---------------- verdict boxes ---------------- */
.loiverdict {
  border: 1px solid var(--color-border); border-left-width: 3px;
  border-radius: var(--radius-sm); background: var(--color-surface-2);
  padding: var(--space-md) var(--space-lg);
  display: flex; flex-direction: column; gap: var(--space-sm);
}
.loiverdict > p { margin: 0; font-size: 13px; line-height: 1.5; }
/* A TINTED BOX SETS ITS OWN INK, and this is not decoration. The three
   --surface-status-* fills are defined ONCE and are not redefined for the dark
   canvas, on purpose (see brand/tokens.css) - so on the dark theme the box is
   still a light tint while --color-text has gone light, and every sentence
   inside it goes light-on-light. Photographed in the browser on the dark theme
   before this rule existed: the headline box was unreadable.

   THE PAIRED INK IS WHAT THE TOKEN PAIR IS FOR. Setting `color` on the BOX
   means every child inherits it - the strong lead, the plain spans, the notes -
   so nothing inside can be missed the way three per-child overrides missed the
   <p> and the <strong>. */
.loiverdict--lost {
  border-left-color: var(--on-surface-status-danger);
  background: var(--surface-status-danger); color: var(--on-surface-status-danger);
}
.loiverdict--signal {
  border-left-color: var(--on-surface-status-warning);
  background: var(--surface-status-warning); color: var(--on-surface-status-warning);
}
.loiverdict--open {
  border-left-color: var(--on-surface-status-success);
  background: var(--surface-status-success); color: var(--on-surface-status-success);
}
.loiverdict--lost .loinote, .loiverdict--signal .loinote, .loiverdict--open .loinote,
.loiverdict--lost .loismall, .loiverdict--signal .loismall, .loiverdict--open .loismall {
  color: inherit;
}
/* The rate cards sit INSIDE the tinted headline box and are their own neutral
   surface: the box carries the danger pairing, and three of the figures on
   these cards are arithmetic rather than a verdict. */
.loiverdict .loirate { color: var(--color-text); }
.loiverdict--zero { border-left-color: var(--color-border-strong); }
.loiverdict--wip { border-left-color: var(--on-surface-status-warning); }
.loiverdict--unknown { border-left-color: var(--color-border-strong); border-left-style: dashed; }

.loifact { margin: 0; font-size: 13px; font-weight: 600; color: var(--color-text-strong); }

/* ---------------- bars ---------------- */
.loibars { display: flex; flex-direction: column; gap: 5px; }
.loibar {
  display: grid; grid-template-columns: minmax(120px, 210px) 1fr minmax(150px, auto);
  gap: var(--space-md); align-items: center;
}
.loibar__label { font-size: 12px; color: var(--color-text); line-height: 1.35; }
.loibar__track {
  height: 16px; border-radius: var(--radius-xs);
  background: var(--color-surface-2); overflow: hidden;
}
.loibar__fill { display: block; height: 100%; width: var(--w); background: var(--bar); }
/* AN OUTLINE IS AN ABSENCE, NEVER A CATEGORY. A dashed, unfilled bar is what
   this page uses for "nobody wrote it down" and "never checked", so neither can
   read as a measured bucket at a glance. */
.loibar--outline .loibar__track { border: 1px dashed var(--color-border-strong); background: none; }
.loibar--outline .loibar__fill { background: none; }
.loibar__val { font-size: 12px; color: var(--color-text-muted); text-align: right; }
@media (max-width: 900px) {
  .loibar { grid-template-columns: 1fr; gap: 2px; }
  .loibar__val { text-align: left; }
}

/* ---------------- sub-tabs ---------------- */
.loitabs {
  display: flex; gap: 2px; flex-wrap: wrap;
  border-bottom: 1px solid var(--color-border);
}
.loitab {
  border: 0; background: none; padding: 7px 12px; margin-bottom: -1px;
  font-size: 13px; font-weight: 600; color: var(--color-text-muted);
  border-bottom: 2px solid transparent;
}
.loitab:hover { color: var(--color-text); }
.loitab.is-active { color: var(--color-accent-ink); border-bottom-color: var(--color-accent); }

/* All four sub-panels stay MOUNTED and toggle with `hidden`, so the page can be
   printed and searched with the browser's own find with no script running. */
.loisubpanel { display: flex; flex-direction: column; gap: var(--space-md); }
/* REQUIRED, not belt and braces. The UA sheet hides [hidden] with a
   type-selector rule, so any class rule setting `display` beats it and the
   hidden panel paints anyway. Caught in the browser: clicking a sub-tab moved
   the underline and left the previous panel on screen. */
.loisubpanel[hidden] { display: none; }
.loisubpanel > .loisub:first-child { margin-top: var(--space-sm); }

/* ---------------- tables ---------------- */
.loiscroll {
  overflow-x: auto; border: 1px solid var(--color-border);
  border-radius: var(--radius-sm); background: var(--color-surface);
}
/* 259 rows unbounded is a table a reader scrolls PAST rather than reads, and it
   pushes the panels beneath it out of reach. The BOX is capped; every row stays
   in the DOM, and the sort control still sorts the whole set. */
.loiscroll--roster { max-height: 620px; overflow-y: auto; }
.loitable { width: 100%; border-collapse: collapse; font-size: 12px; }
.loitable caption {
  caption-side: top; text-align: left; padding: var(--space-sm) var(--space-md);
  font-size: 12px; font-weight: 700; color: var(--color-text-strong);
  border-bottom: 1px solid var(--color-border);
}
.loitable th, .loitable td {
  text-align: left; padding: 6px var(--space-md); vertical-align: top;
  border-bottom: 1px solid var(--color-border);
}
.loitable thead th {
  position: sticky; top: 0; z-index: 1;
  background: var(--color-surface-2); color: var(--color-text-muted);
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: var(--eyebrow-tracking); white-space: nowrap;
}
.loitable tbody tr:nth-child(even) { background: var(--v2-zebra); }
.loitable .num, .loitable th.num { text-align: right; }
/* The roster header: label, then the funnel that opens the column menu.
   The grid overlays its funnel on a fixed-width cell; these columns size to
   their content, so the button sits in the flow and the header simply gets
   wider by the 20px it takes. */
.loith { display: flex; align-items: center; gap: 6px; }
.funnel--loi { position: static; transform: none; margin-left: auto; }
.loicol-name { min-width: 140px; }
.loicol-text { min-width: 200px; }
.loicol-date { white-space: nowrap; }
/* A THIN ROW IS DIMMED AND TAGGED, never merely footnoted. The word beside the
   count is what carries it; the dim is the second channel. */
.loithin td { opacity: .62; }
.loithin td.loi-nodim { opacity: 1; }
.loismall { font-size: 11px; color: var(--color-text-muted); font-weight: 600; }
.loistack { display: flex; flex-direction: column; gap: 2px; align-items: flex-start; }
/* A TAG INSIDE A TABLE CELL DROPS THE CAPS AND THE MARGIN. Uppercase is a
   third wider, and a cell tag sets its column's min-content width: "no outcome
   field" in caps wrapped to three lines and pushed the columns after it off the
   right edge. The word is unchanged; only its case and its gutter are. */
/* Same reason inside a bar's value string: "INCL. 2 REVERSE QUOTES" in caps
   shouts louder than the count it qualifies. */
.loibar__val .loitag { text-transform: none; letter-spacing: 0; margin: 0 0 0 6px; font-weight: 600; }
.loistack .loitag, .loitable .loitag {
  text-transform: none; letter-spacing: 0; margin-right: 0; font-weight: 600;
}
.loitable--compact .loi-optional { display: none; }

/* ---------------- roster chips ---------------- */
.loichips { display: flex; gap: var(--space-xs); flex-wrap: wrap; align-items: center; }
.loichip {
  border: 1px solid var(--color-border); background: var(--color-surface);
  border-radius: var(--radius-pill); padding: 4px 11px;
  font-size: 12px; font-weight: 600; color: var(--color-text-muted);
}
.loichip:hover { border-color: var(--color-border-strong); color: var(--color-text); }
.loichip.is-active {
  border-color: var(--border-selected); color: var(--color-accent-ink);
  background: color-mix(in srgb, var(--color-accent) 8%, transparent);
}
.loichips .btn { margin-left: auto; }

/* ---------------- follow-up rate cards ---------------- */
.loirates {
  display: grid; gap: var(--space-md); margin: 0;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
}
.loirate {
  background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: var(--radius-sm); padding: var(--space-md);
}
.loirate--whole { border-color: var(--color-border-strong); }
.loirate--thin { opacity: .7; }
.loirate__label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: var(--eyebrow-tracking); color: var(--color-text-muted); }
.loirate__pct { margin: 4px 0 0; font-size: var(--text-metric-sm); font-weight: 700; color: var(--color-text-strong); line-height: 1.1; }
.loirate__of, .loirate__median { margin: 2px 0 0; font-size: 12px; color: var(--color-text-muted); }

/* THE WITHDRAWN READING STAYS ON SCREEN, and the dashed rail says so a second
   time. The word is what tells: the heading, the pill and both captions open on
   "Withdrawn". */
.loiwithdrawn {
  border: 1px dashed var(--color-border-strong); border-radius: var(--radius-sm);
  padding: var(--space-md); display: flex; flex-direction: column; gap: var(--space-md);
}
.loitwo { display: grid; gap: var(--space-md); grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }

/* ---------------- journey ---------------- */
.loipick { display: flex; align-items: center; gap: var(--space-sm); flex-wrap: wrap; }
.loipick select {
  max-width: 520px; padding: 5px 8px; border-radius: var(--radius-sm);
  border: 1px solid var(--color-border); background: var(--color-surface);
}
.loipick__label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: var(--eyebrow-tracking); color: var(--color-text-muted); }
.loipick__name { margin: 0; font-size: 13px; font-weight: 700; color: var(--color-text-strong); }
.loijourney { display: flex; flex-direction: column; gap: var(--space-md); }
.loistackblock { display: flex; flex-direction: column; gap: var(--space-sm); }
/* The engagement history runs to hundreds of rows on the busiest clients. Same
   rule as the roster: every row stays in the DOM and the BOX is capped. */
.loiscroll--timeline { max-height: 460px; overflow-y: auto; }
.loibadge {
  margin: 0; font-size: 12px; line-height: 1.5; padding: var(--space-sm) var(--space-md);
  border-left: 3px solid var(--color-border-strong); background: var(--color-surface-2);
  border-radius: var(--radius-sm);
}
.loibadge--done { border-left-color: var(--on-surface-status-success); }
.loibadge--zero { border-left-color: var(--color-border-strong); }
.loibadge--counts, .loibadge--wip { border-left-color: var(--on-surface-status-warning); }

/* THE LADDER IS THE SHAPE OF THIS PAGE. A funded loan has a timeline; a stalled
   LOI has a point where the record goes quiet. Three rung states, and the third
   is the one that keeps it honest: a rung nobody measured is neither cleared
   nor never-reached. */
.loiladder { list-style: none; margin: 0; padding: 0; }
.loirung { display: grid; grid-template-columns: 20px 1fr; gap: var(--space-sm); padding: 6px 0; }
.loirung__dot { text-align: center; line-height: 1.3; color: var(--color-text-muted); }
.loirung--done .loirung__dot { color: var(--on-surface-status-success); }
.loirung__head { margin: 0; display: flex; gap: var(--space-sm); align-items: baseline; flex-wrap: wrap; }
.loirung__label { font-size: 13px; font-weight: 600; color: var(--color-text-strong); }
.loirung__state { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: var(--eyebrow-tracking); color: var(--color-text-muted); }
.loirung__detail { margin: 1px 0 0; font-size: 12px; color: var(--color-text-muted); }
.loirung--never .loirung__label { color: var(--color-text-muted); }

.loiscope {
  border-left: 3px solid var(--color-border-strong); background: var(--color-surface-2);
  border-radius: var(--radius-sm); padding: var(--space-sm) var(--space-md);
  display: flex; flex-direction: column; gap: 4px;
}
.loiscope--shared, .loiscope--unknown { border-left-color: var(--on-surface-status-warning); }
.loiscope__head { margin: 0; font-size: 12px; font-weight: 700; color: var(--color-text-strong); }

.loilist { margin: 0; padding-left: var(--space-lg); font-size: 12px; color: var(--color-text-muted); }
.loilist li + li { margin-top: 3px; }
.loirules { margin: 0; padding-left: var(--space-lg); font-size: 13px; }
.loirules li + li { margin-top: 4px; }

.loihslinks { margin: 0; font-size: 12px; }
.loihslinks a, .loilink { color: var(--color-accent-ink); font-weight: 600; }

.loieng--inbound td:first-child { box-shadow: inset 2px 0 0 var(--color-accent); }
