/* Credit Predix — demo front end.
 *
 * Deliberately plain. This is a working demonstration of the platform, not a
 * design proposal: anything that looks like a finished visual identity would
 * invite a conversation about colour when the point is the behaviour underneath.
 */

:root {
  --ink: #14181f;
  --muted: #5d6773;
  --line: #dfe3e8;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --brand: #1f4e79;
  --brand-soft: #eaf1f8;
  --warn: #8a5a00;
  --warn-soft: #fdf3e2;
  --deny: #8c2f2f;
  --deny-soft: #fbeceb;
  --ok: #1f6b3f;
  --ok-soft: #e9f5ee;

  /* --- The TAC density standard -------------------------------------------
   * Information per screen is a product requirement, not a taste preference.
   * Density comes from spacing; the base text size never shrinks below 13px.
   * `tests/api/test_density_standard.py` holds these values, so a new size has
   * to be added here deliberately rather than appear beside a rule.
   *
   * 12px is deliberately absent: four sizes inside a 3px range is drift. */
  --fs-micro: 10px;   /* badges, uppercase labels */
  --fs-sm: 11px;      /* table headers, metadata, hints */
  --fs-base: 13px;    /* body, cells, inputs, buttons */
  --fs-lg: 15px;      /* page title, section heading */
  --fs-xl: 20px;      /* KPI value */
  --fs-hero: 26px;    /* one number per screen, maximum */

  /* The 4px grid. No other spacing value. */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-6: 24px;
  --sp-8: 32px;

  /* Component padding. Fixed pairs, and not all on the 4px grid: a table cell
   * at 4px looked cramped and at 12px cost a row per screenful. */
  --cell-pad: 5px 10px;
  --cell-head-pad: 4px 10px;
  --card-pad: 12px;
  --kpi-pad: 10px 12px;
  --badge-pad: 2px 8px;

  /* Chrome and controls. */
  --topbar-h: 44px;
  --tabstrip-h: 32px;
  --ctl-h: 28px;
  --ctl-h-sm: 22px;
  --row-lh: 1.35;

  /* Radius. 10px and 12px read as consumer web and ate vertical space. */
  --r: 6px;
  --r-lg: 8px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font: var(--fs-base)/var(--row-lh) -apple-system, BlinkMacSystemFont,
        "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
  height: var(--topbar-h);
  padding: 0 var(--sp-6);
  background: var(--brand);
  color: #fff;
}

header .product { font-weight: 600; letter-spacing: .02em; }
header .product .subtitle { opacity: .7; font-weight: 400; margin-left: 8px; }

/* The bank the session belongs to, shown at all times. Tenant isolation is the
 * platform's central claim, so which bank you are inside is never off screen. */
.bank {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  font-size: var(--fs-base);
}
.bank strong { font-weight: 600; }

button {
  font: inherit;
  /* `min-height`, not `height`: a single-line button lines up with the input
   * beside it, and a ribbon button that draws over two lines -- the source
   * writes "Re-assign \n(ADMIN)" -- still grows instead of spilling over the
   * group caption underneath it. */
  min-height: var(--ctl-h);
  padding: 0 var(--sp-3);
  border: 1px solid var(--brand);
  border-radius: var(--r);
  background: var(--brand);
  color: #fff;
  cursor: pointer;
}
button.secondary { background: transparent; color: var(--brand); }
/* More specific than `button.secondary`, deliberately. The header sits on the
 * brand colour, and `button.secondary` alone renders dark blue on dark blue —
 * which made Sign out an empty box until someone looked at it. */
header button,
header button.secondary { border-color: rgba(255,255,255,.5); background: transparent; color: #fff; }

/* The EN | BM switch (Bahasa Malaysia spec 4): left of Sign out, and outside
 * #bank-bar so it shows on the sign-in page too. The pressed one is filled. */
.header-right { display: flex; align-items: center; gap: var(--sp-3); }
.lang-switch { display: flex; gap: var(--sp-1); }
header .lang-switch button[aria-pressed="true"] { background: rgba(255,255,255,.2); }

/* A phone: the header was already wider than the screen. The subtitle goes. */
@media (max-width: 720px) {
  header .product .subtitle { display: none; }
}
button:disabled { opacity: .45; cursor: not-allowed; }

main { max-width: 1040px; margin: var(--sp-6) auto; padding: 0 var(--sp-6); }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: var(--card-pad);
  margin-bottom: var(--sp-4);
}

h1 { font-size: var(--fs-lg); margin: 0 0 4px; }
h2 { font-size: var(--fs-lg); margin: 0 0 var(--sp-3); }
.hint { color: var(--muted); font-size: var(--fs-sm); margin: 0 0 var(--sp-3); }

label { display: block; font-size: var(--fs-sm); color: var(--muted);
        margin-bottom: var(--sp-1); }
input[type=text], input[type=email], input[type=password], select {
  font: inherit;
  width: 100%;
  height: var(--ctl-h);
  padding: 0 var(--sp-2);
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: #fff;
}
input:disabled { background: #f4f5f7; color: var(--muted); }

.row { display: flex; gap: var(--sp-3); align-items: flex-end; }
.row > * { flex: 1; }
.row > button { flex: 0 0 auto; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: var(--cell-pad); border-bottom: 1px solid var(--line);
         line-height: var(--row-lh); }
th { padding: var(--cell-head-pad); }
th { font-size: var(--fs-sm); text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
tbody tr.open { cursor: pointer; }
tbody tr.open:hover { background: var(--brand-soft); }
/* The row View Obligor will re-open. The legacy highlights the row you picked;
   a button that acts on "the selected one" needs something visible to point at. */
tbody tr.selected { outline: 2px solid var(--accent, #1f6feb); outline-offset: -2px; }
tbody tr.closed { color: var(--muted); background: #fbfbfc; }

.tag {
  display: inline-block;
  font-size: var(--fs-micro);
  padding: var(--badge-pad);
  border-radius: 999px;
  white-space: nowrap;
}
.tag.ok { background: var(--ok-soft); color: var(--ok); }
.tag.closed { background: var(--deny-soft); color: var(--deny); }

.note {
  border-left: 3px solid var(--line);
  background: #fafbfc;
  padding: 10px 14px;
  margin: 16px 0 0;
  font-size: var(--fs-base);
  color: var(--muted);
}
.note.warn { border-color: var(--warn); background: var(--warn-soft); color: var(--warn); }
.note.deny { border-color: var(--deny); background: var(--deny-soft); color: var(--deny); }
.note.ok { border-color: var(--ok); background: var(--ok-soft); color: var(--ok); }

.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.fields .wide { grid-column: 1 / -1; }

.meta { display: flex; gap: 22px; flex-wrap: wrap; font-size: var(--fs-base); color: var(--muted); }
.meta b { color: var(--ink); font-weight: 600; }

.hidden { display: none !important; }

/* Module bar. Everything not built says so, with the phase it belongs to, so
 * the shape of the platform is visible without implying more exists than does. */
/* The ribbon. Light, because the Windows one is: dark chrome here left the
 * group captions unreadable against their own background. The old dark tab
 * strip this replaced was a flat list of modules invented here; the ribbon and
 * its contents are read out of the delivered source. */
nav#modules {
  display: block;
  padding: 0;
  background: var(--brand-soft);
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
}
.tab {
  border: 0;
  border-radius: 0;
  background: transparent;
  color: rgba(255,255,255,.72);
  padding: 11px 16px;
  white-space: nowrap;
  border-bottom: 3px solid transparent;
}
.tab.active { color: #fff; border-bottom-color: #fff; }
/* Not built, and clickable anyway. A greyed-out tab is a dead end; these open a
 * panel saying what the module is and what reading its specification already
 * turned up, which is a better answer than nothing when someone asks. */

.stats { display: flex; gap: 28px; flex-wrap: wrap; margin: 4px 0 18px; }
.stats div { display: flex; flex-direction: column; }
.stats b { font-size: var(--fs-xl); color: var(--brand); }
.stats span { font-size: var(--fs-sm); color: var(--muted); max-width: 220px; }

textarea {
  font: 13px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  resize: vertical;
}

.result {
  display: flex;
  align-items: baseline;
  gap: 14px;
  margin-top: 16px;
  padding: 14px 18px;
  background: var(--ok-soft);
  border-left: 3px solid var(--ok);
}
.result b { font-size: var(--fs-xl); font-family: ui-monospace, Menlo, monospace; color: var(--ok); }
.result span { font-size: var(--fs-base); color: var(--muted); }


#view-roadmap ul { margin: 0; padding-left: 20px; }
#view-roadmap li { margin-bottom: 10px; }
#view-roadmap li b { color: var(--ink); }


/* Scorecard. A model defines Modules -> Factors -> Items -> Options, and this
 * renders whatever it is given rather than assuming a shape. */
.module-title { font-size: var(--fs-lg); font-weight: 600; margin: 22px 0 2px; }
.factor {
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 14px 16px;
  margin: 12px 0;
  background: #fcfdfe;
}
.factor h3 { font-size: var(--fs-lg); margin: 0 0 2px; }
.factor .weight { font-size: var(--fs-sm); color: var(--muted); }
.item { margin-top: 14px; }
.item > label { font-size: var(--fs-base); color: var(--ink); font-weight: 600; margin-bottom: 6px; }
.choices { display: flex; flex-direction: column; gap: 4px; }
.choices label {
  display: flex;
  gap: 8px;
  align-items: baseline;
  font-size: var(--fs-base);
  color: var(--ink);
  font-weight: 400;
  margin: 0;
  cursor: pointer;
}
.choices .score { color: var(--muted); font-variant-numeric: tabular-nums; margin-left: auto; }
#grade-value { font-size: var(--fs-hero); }


/* Rating model browser. Formulas are shown, because they are the model -- a
 * screen that hides them is a screen that hides what the bank actually does. */
.node { margin: 4px 0 4px 0; }
.node .head { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.node .kind {
  font-size: var(--fs-sm);
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
  min-width: 54px;
}
.node .short {
  font-family: ui-monospace, Menlo, monospace;
  font-size: var(--fs-sm);
  background: var(--brand-soft);
  color: var(--brand);
  padding: 1px 6px;
  border-radius: var(--r);
}
.node .weight { font-size: var(--fs-sm); color: var(--muted); }
.node code {
  display: block;
  font-size: var(--fs-sm);
  color: #334;
  background: #f7f8fa;
  border-left: 2px solid var(--line);
  padding: 5px 9px;
  margin: 4px 0 0;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
}
.level-factor { margin-left: 18px; }
.level-item { margin-left: 36px; }
.level-option { margin-left: 54px; font-size: var(--fs-base); color: var(--muted); }

/* The financial spreadsheet.
 *
 * Figures are right-aligned and tabular-figured so that columns of numbers line
 * up on the decimal point. On a balance sheet that is not decoration: a total
 * that does not sit under its own components is hard to check by eye, which is
 * the first thing a credit officer does. */
#fss-sheet td.figure, #fss-sheet th.figure {
  text-align: right;
  font-variant-numeric: tabular-nums;
  width: 180px;
}

#fss-sheet .figure-box {
  width: 140px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  padding: 6px 8px;
}

/* A header line names a section and holds no figure; a total closes one. */
#fss-sheet tr.sheet-header td { background: var(--soft, #f5f6f8); }
#fss-sheet tr.sheet-total td { border-top: 2px solid var(--line); font-weight: 600; }

#fss-sheet td { padding: 6px 12px; }

/* The prior period sits beside this one, and reads as reference rather than as
 * something to change: it belongs to a statement that is already settled. */
#fss-sheet td.prior { color: var(--muted); }

/* A number on the model tree that can be typed into. Sized to its content so the
 * tree still reads as a tree rather than as a form. */
#model-tree input.weight {
  width: 90px;
  padding: 2px 6px;
  font-size: var(--fs-sm);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* An item the model answers for itself. SCO005 calls these auto-select items:
 * every option carries a formula, and the accounts decide which one applies.
 * The options stay on screen and stay legible -- greying the whole block would
 * hide the bands, and the bands are how an analyst checks the figure landed
 * where it should. Only the control is unavailable. */
.choices.computed label { cursor: default; }
.choices.computed input[type="radio"] { accent-color: var(--muted); }

/* The System Value: the figure that decided the item, shown so a computed
 * answer can be checked rather than taken on trust. */
.system-values {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  margin-bottom: 6px;
}

.system-value {
  font-size: var(--fs-sm);
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

/* A line the model reads and the statement does not supply. Named rather than
 * left blank: "we needed this and did not get it" is the useful fact, and it is
 * what the scoring gate refuses on. */
.system-value.absent { color: var(--deny, #b3261e); }

.computed-note {
  font-size: var(--fs-sm);
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* The properties panel. RMA0014 puts it at the bottom of the configuration
 * screen, under the tree, and that is where it sits here. */
.panel-inset {
  margin-top: 18px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--soft, #f5f6f8);
}

.panel-inset h3 { margin: 0 0 4px; font-size: var(--fs-lg); }

/* A node the analyst can select. The whole row is the target, because the
 * legacy selects on the node and not on a control inside it. */
.node .head { cursor: default; }
#model-tree.editable .node .head { cursor: pointer; }
#model-tree .node.selected > .head { outline: 2px solid var(--accent, #1f6feb); border-radius: var(--r); }

/* "Click Here To Add New Factor" — the legacy's own words, and its own way of
 * adding a node. It reads as an instruction because it is one. */
.node.placeholder .head { color: var(--accent, #1f6feb); font-style: italic; cursor: pointer; }
.node.placeholder .kind { display: none; }

button.danger { color: var(--deny, #b3261e); }

/* All screens — the 231 legacy screens rendered from the generated manifest.
   A list beside a host panel, because a dropdown of 231 names is not navigation
   and the module a screen belongs to is part of finding it. */
#screen-layout { display: grid; grid-template-columns: 260px 1fr; gap: 20px; align-items: start; }
#screen-list { list-style: none; margin: 0; padding: 0; max-height: 62vh; overflow-y: auto;
               border: 1px solid var(--line, #30363d); border-radius: var(--r); }
#screen-list li { border-bottom: 1px solid var(--line, #30363d); }
#screen-list li:last-child { border-bottom: 0; }
#screen-list button.link { width: 100%; text-align: left; background: none; border: 0;
                           padding: 7px 10px; color: inherit; font: inherit; cursor: pointer; }
#screen-list button.link:hover { background: rgba(127, 127, 127, 0.12); }
#screen-list button.link.selected { outline: 2px solid var(--accent, #1f6feb); outline-offset: -2px; }
#screen-host { min-height: 200px; }
/* One control per line. The legacy lays these out on a designer grid this does
   not reproduce; stacking keeps every caption attached to its own field. */
#screen-fields .row { margin-bottom: 10px; align-items: center; }
#screen-fields .row > label { flex: 0 0 240px; }
@media (max-width: 900px) {
  #screen-layout { grid-template-columns: 1fr; }
  #screen-list { max-height: 30vh; }
}
/* A legacy Label that captions nothing: a group heading, a note, a placeholder
   the old screen filled in. Rendered as a label element because that is what it
   is, but it must not take the caption column's width. */
#screen-fields label.standalone { flex: 1 1 auto; color: var(--muted); font-weight: normal; }

/* ---------------------------------------------------- legacy screen layout
 *
 * The Windows screens were drawn as tables -- 227 of the 335 delivered designer
 * files place their controls in a TableLayoutPanel cell -- so the same shape is
 * a CSS grid here. That is what makes these both faithful and responsive: the
 * column count comes from the original, and the columns fold when there is no
 * room for them rather than being redrawn by hand for a narrow window.
 */
.screen-group {
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 12px 14px 14px;
  margin: 0 0 14px;
}

/* An unnamed grouping is still a grouping. It gets the spacing and none of the
 * chrome, so it reads as a break rather than as a box with a missing title. */
.screen-group:not(:has(legend)) {
  border-color: transparent;
  padding-left: 0;
  padding-right: 0;
}

.screen-group > legend {
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0 6px;
}

.screen-grid {
  display: grid;
  /* `auto-fit` with a minimum is what folds the columns: a two-column form
   * stays two columns on a laptop and becomes one on a phone, without a media
   * query per screen.
   *
   * It used to be `repeat(var(--columns), minmax(320px, 1fr))` -- the designer's
   * own column count times a fixed minimum. `FinancialVariableManagement`
   * declares six, which demanded 2,040px before it could fit, so the grid
   * overflowed its container and the last column collapsed to a sliver that
   * wrapped "Weightage (%)" one character per line. `--columns` is still set on
   * the element and still describes the source; it no longer multiplies a
   * minimum width. */
  grid-template-columns: repeat(auto-fit, minmax(min(280px, 100%), 1fr));
  gap: 4px 24px;
  align-items: center;
}

@media (max-width: 760px) {
  /* Below this a second column leaves no room for the box beside its caption,
   * and a cramped two-column form is harder to read than a long one-column
   * form. */
  .screen-grid { grid-template-columns: 1fr; }
}

.screen-cell > .row { margin: 0; }

/* A caption that labels nothing -- a section heading, or one of the asterisks
 * marking a field as mandatory. Kept because they are marks a reader uses, and
 * set apart so neither is mistaken for a field's own caption. */
.screen-cell.caption-only {
  color: var(--muted);
  font-size: var(--fs-sm);
  padding: 2px 0;
}

/* The mandatory mark. A third column on the Windows screen, and an asterisk
 * after the caption here -- the same information, without a row of its own. */
.screen-cell.required > .row > label::after {
  content: " *";
  color: var(--deny, #b00020);
  font-weight: 600;
}

/* Inside a grid cell the caption cannot keep the fixed 240px width it has in a
 * single-column form: in a two-column section that width exceeds the cell and
 * the box beside it renders on top of the next caption. A grid of two tracks
 * that may both shrink is what stops the overlap, and `minmax(0, …)` is the
 * part that actually allows it -- a grid track's default minimum is its content
 * width, which is exactly the overflow being fixed. */
.screen-cell > .row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px;
  align-items: center;
}
.screen-cell > .row > label {
  flex: none;
  min-width: 0;
  overflow-wrap: anywhere;
}
.screen-cell > .row > input,
.screen-cell > .row > select,
.screen-cell > .row > textarea {
  min-width: 0;
  width: 100%;
}

/* -------------------------------------------------------------------- ribbon
 *
 * The shape of the Windows menu: one tab strip, then a row of groups, each a
 * bordered box of buttons with its caption centred underneath. The groups and
 * captions come from `ribbon.json`, which is read out of the delivered source --
 * nothing here decides what is on the menu, only how it looks.
 */
#modules {
  display: block;
  background: var(--brand-soft, #eef3f8);
  border-bottom: 1px solid var(--line);
  padding: 0;
}

#ribbon-tabs {
  display: flex;
  gap: 2px;
  padding: 4px 10px 0;
}

.ribbon-tab {
  background: #fff;
  border: 1px solid var(--line);
  border-bottom: none;
  border-radius: var(--r) 4px 0 0;
  padding: 4px 16px;
  font-size: var(--fs-base);
  color: var(--ink, #1b2b3a);
  cursor: default;
}

#ribbon-groups {
  display: flex;
  align-items: stretch;
  gap: 0;
  padding: 6px 10px 0;
  /* Scrolls rather than wraps. A ribbon that reflows onto a second row stops
   * reading as a ribbon, and the original never does it. */
  overflow-x: auto;
}

.ribbon-group {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  /* The separator between groups, which is what the original draws. */
  border-right: 1px solid var(--line);
  padding: 0 10px 2px;
  flex: 0 0 auto;
}
.ribbon-group:last-child { border-right: none; }

.ribbon-group-buttons {
  display: flex;
  align-items: flex-start;
  gap: 2px;
}

.ribbon-group-caption {
  text-align: center;
  font-size: var(--fs-sm);
  color: var(--muted);
  padding-top: 3px;
  border-top: 1px solid transparent;
}

.ribbon-button {
  /* `pre-line` is load-bearing: the source writes "Re-assign \n(ADMIN)" and the
   * ribbon draws it over two lines. Collapsing it makes one wide button where
   * the original has a narrow one. */
  white-space: pre-line;
  text-align: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--r);
  color: var(--ink, #1b2b3a);
  font-size: var(--fs-sm);
  line-height: 1.25;
  padding: var(--sp-1) var(--sp-2);
  min-width: 62px;
  max-width: 130px;
  cursor: pointer;
}
.ribbon-button:hover:not(:disabled) {
  background: #fff;
  border-color: var(--line);
}
.ribbon-button:disabled {
  /* Declared in the legacy source and not built here. Shown rather than hidden,
   * because a menu missing its items misrepresents the system as smaller than
   * it is -- and greyed rather than live, because a button that looks working
   * and does nothing is worse than one that says so. */
  color: var(--muted);
  cursor: not-allowed;
  opacity: 0.55;
}

/* ------------------------------------------------------------ document tabs
 *
 * The legacy keeps several screens open and lets a user move between them. */
#doc-tabs {
  display: flex;
  gap: 2px;
  padding: 6px 10px 0;
  background: var(--brand-soft, #eef3f8);
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
}

.doc-tab {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #fff;
  border: 1px solid var(--line);
  border-bottom: none;
  border-radius: var(--r) 4px 0 0;
  padding: 3px 8px 4px 12px;
  flex: 0 0 auto;
}
.doc-tab.active { border-bottom: 2px solid var(--brand); }

.doc-tab-label {
  background: none;
  border: none;
  padding: 0;
  font-size: var(--fs-base);
  color: var(--brand);
  cursor: pointer;
}
.doc-tab.active .doc-tab-label { font-weight: 600; }

.doc-tab-close {
  background: none;
  border: none;
  padding: 0 2px;
  font-size: var(--fs-sm);
  color: var(--muted);
  cursor: pointer;
}
.doc-tab-close:hover { color: var(--deny, #b00020); }

/* ------------------------------------------------- a form laid out as declared
 *
 * `Base/Base/Views/Search.Designer.cs` puts the four criteria one per row with
 * the caption to the left, and centres the buttons beneath them. A two-column
 * grid of label and box is the same shape, and it folds to one column on a
 * narrow window rather than needing a second layout.
 */
.legacy-form {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr) max-content;
  gap: 8px 12px;
  align-items: center;
  margin-bottom: 16px;
}

.legacy-row {
  display: contents;
}

.legacy-row > label {
  font-size: var(--fs-base);
  color: var(--ink);
  white-space: nowrap;
}

/* A row with no third control still ends where the others do, so every box is
 * the same width and the column edge is straight -- which is what the original
 * looks like and what a ragged right edge would break. */
.legacy-row > input,
.legacy-row > textarea {
  grid-column: 2 / span 2;
  width: 100%;
}
.legacy-row > input + select,
.legacy-row > select:last-child:not(:first-of-type) {
  grid-column: 3;
}
.legacy-row > input:has(+ select) {
  grid-column: 2;
}

.legacy-buttons {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

@media (max-width: 700px) {
  /* Below this the caption column leaves too little for the box beside it. */
  .legacy-form { grid-template-columns: 1fr; }
  .legacy-row > input,
  .legacy-row > textarea,
  .legacy-row > select { grid-column: 1; }
}

/* --------------------------------------------------- the administration list
 *
 * Six entries, in the order the legacy registers them. Five are not built and
 * are shown disabled beside the access type that gates them in the original:
 * a shorter list would make the administration of this system look like one
 * screen when it is six.
 */
.admin-nav {
  list-style: none;
  padding: 0;
  margin: 0;
  max-width: 620px;
}
.admin-nav li {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
  padding: 2px 0;
}
.admin-nav-item {
  background: none;
  border: none;
  padding: 10px 0;
  font-size: var(--fs-lg);
  color: var(--brand);
  text-align: left;
  cursor: pointer;
}
.admin-nav-item:disabled {
  color: var(--muted);
  cursor: not-allowed;
}
.admin-nav-access {
  font-size: var(--fs-sm);
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  white-space: nowrap;
}

/* A region on a rendered legacy screen: a tree, a list, a report viewer, a
 * picture, or a whole sub-screen the designer file drops on as one control.
 *
 * Drawn as an empty bordered area with the kind written inside it. The reason it
 * is not a text input is that a text input would be a lie: 213 controls were
 * recovered by teaching the parser the vendor's own types, and ~90 of them are
 * regions rather than boxes. Showing a text box where a spreadsheet goes is the
 * same fault as showing a caption with no box beside it, in the other direction.
 */
.screen-region {
  border: 1px dashed var(--line);
  border-radius: var(--r);
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.screen-region > .hint {
  font-size: var(--fs-sm);
  text-transform: lowercase;
}

/* The mandatory mark on a hand-built screen. The gallery has its own rule for
 * the same thing on a rendered one (`.screen-cell.required`), which reads the
 * marker out of the designer's third column; here the caption is written by
 * hand, so the mark is written beside it.
 *
 * The Windows screens carry it as a red asterisk in a column of its own --
 * `lblMandatoryCIF`, `label7`, `label10` on Reassign Obligor Ownership. Same
 * information, without a column of its own.
 */
.required {
  color: var(--deny, #b00020);
  font-weight: 600;
}

/* --- the formula builder ---------------------------------------------------
 *
 * Captured off the running Windows client on 19 August 2026. Three things here
 * come from that capture rather than from the specification: the case list is
 * an indented tree and not a table, each box carries operator buttons, and the
 * variable list is per formula type.
 *
 * Every value is a token. `tests/api/test_density_standard.py` walks this file
 * and fails on a raw font-size, padding, gap, margin or radius, which is how the
 * ladder stays six sizes rather than drifting to nine. */

.builder-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sp-2);
}

/* Three columns while there is room, stacking on a narrow screen. The picker is
 * the one that goes first, because it is the only one that is transient. */
.builder-body {
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(0, 4fr);
  gap: var(--sp-4);
  align-items: start;
}
.builder-body:has(.builder-picker:not(.hidden)) {
  grid-template-columns: minmax(0, 3fr) minmax(0, 4fr) minmax(0, 3fr);
}
@media (max-width: 900px) {
  .builder-body,
  .builder-body:has(.builder-picker:not(.hidden)) { grid-template-columns: 1fr; }
}

/* The case list. Bounded and scrolling inside itself, so opening the builder
 * never pushes the model tree off the screen. */
.builder-tree {
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--panel);
  max-height: 240px;
  overflow: auto;
  padding: var(--sp-1);
}

.case-node {
  padding: var(--sp-1) var(--sp-2);
  border-radius: var(--r);
  cursor: pointer;
  font-size: var(--fs-base);
  line-height: var(--row-lh);
}
.case-node:hover { background: var(--bg); }
.case-node.selected { background: var(--brand-soft); }

/* The indented children. The legacy renders `Condition :` and `Formula :` as
 * child nodes of the case, not as columns. */
.case-part {
  padding-left: var(--sp-4);
  color: var(--muted);
  font-size: var(--fs-sm);
  white-space: pre-wrap;
  word-break: break-word;
}
.case-part b { color: var(--ink); font-weight: 500; }

/* The default case. Marked, because "first true case wins" makes its position
 * load-bearing and a default that is not last can never be reached. */
.case-node .default-flag {
  font-size: var(--fs-micro);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ok);
  margin-left: var(--sp-2);
}
.case-node .order-flag {
  font-size: var(--fs-micro);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--deny);
  margin-left: var(--sp-2);
}

.builder-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  margin-top: var(--sp-2);
}

.builder-edit label {
  display: block;
  margin-top: var(--sp-3);
  font-size: var(--fs-sm);
  color: var(--muted);
}
.builder-edit input,
.builder-edit textarea {
  width: 100%;
  font-size: var(--fs-base);
}
.builder-edit textarea {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  resize: vertical;
}

/* The operator buttons. Small, dense, and directly under the box they type
 * into, which is where the legacy puts them. */
.builder-ops {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-1);
  margin-top: var(--sp-1);
}
.builder-ops button {
  height: var(--ctl-h-sm);
  padding: 0 var(--sp-2);
  font-size: var(--fs-sm);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.builder-picker {
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--panel);
  padding: var(--sp-3);
}
.builder-picker input[type="search"] { width: 100%; margin-top: var(--sp-2); }

.picker-list {
  max-height: 260px;
  overflow: auto;
  margin-top: var(--sp-2);
  border-top: 1px solid var(--line);
}
.picker-group {
  font-size: var(--fs-micro);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  padding: var(--sp-2) var(--sp-2) var(--sp-1);
  position: sticky;
  top: 0;
  background: var(--panel);
}
.picker-item {
  padding: var(--sp-1) var(--sp-2);
  border-radius: var(--r);
  cursor: pointer;
  font-size: var(--fs-base);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.picker-item:hover { background: var(--brand-soft); }
.picker-item .picker-note {
  display: block;
  font-family: inherit;
  font-size: var(--fs-sm);
  color: var(--muted);
}

/* --- overriding a figure the accounts gave (SCO005) ------------------------
 *
 * "The scorecard will display the system financial value and overridden value
 * (blank by default)... Justification Box is disabled by default until User
 * enters Overridden Value."
 *
 * So both figures sit on one line, and the justification sits under the item
 * rather than under each figure -- one reason covers every figure changed on
 * that item, which is how the specification keys it. */

.system-line {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-wrap: wrap;
  padding: var(--sp-1) 0;
}

/* `input[type=text]` is width:100% globally, and the flex row let it take the
 * whole line. Both are needed: flex:0 0 auto stops it growing, and the explicit
 * width beats the global rule without an !important. */
.system-line .override-box {
  flex: 0 0 auto;
  height: var(--ctl-h-sm);
  width: 14ch;
  font-size: var(--fs-sm);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  text-align: right;
}

/* The figure the accounts gave, given a fixed share of the line so the override
 * boxes line up down the item instead of stepping in and out with the length of
 * each variable name. */
.system-line .system-value {
  flex: 1 1 22rem;
  min-width: 0;
}

.system-line .reset-override {
  flex: 0 0 auto;
  height: var(--ctl-h-sm);
  padding: 0 var(--sp-2);
  font-size: var(--fs-micro);
}

/* What an override looks like once the card is no longer a draft: read only,
 * and still visible. A figure that was replaced has to stay visible after
 * approval or the credit file cannot show its own working. */
.override-shown {
  font-size: var(--fs-sm);
  color: var(--warn);
}

.system-values .computed-note { display: block; }

/* The ratio the band was tested on -- Philip's demonstration script, step 3.1.9.
 *
 * Deliberately not styled like the lines above it. Those are figures the
 * statement supplied and can be overridden; this one is the engine's own
 * working over them and has no box beside it. Monospace because it is an
 * expression, and indented under the lines it is computed from. */
.system-line.ratio-comparison {
  padding-top: 0;
  padding-left: var(--sp-3);
  border-left: 2px solid var(--line);
  margin-left: var(--sp-1);
}

.system-line.ratio-comparison .system-value {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--brand);
}

.justification-box {
  width: 100%;
  height: var(--ctl-h);
  font-size: var(--fs-sm);
  margin-top: var(--sp-1);
}

/* Disabled until a figure is overridden. Greyed rather than hidden, so an
 * analyst can see a reason will be wanted before they type the figure. */
.justification-box:disabled {
  background: var(--bg);
  color: var(--muted);
}

/* Overridden, and still no reason. The save will be refused, and saying so on
 * the field is kinder than saying it after the round trip. */
.justification-box.wanted {
  border-color: var(--deny);
  background: var(--deny-soft);
}


/* The two tabs of a facility scorecard. Philip's demo script, 3.2: "We have
 * Facilities Info and Scorecard in FG Scorecard."
 *
 * Inside the card, not the page's own tab strip at the top: those switch
 * screens, and these switch between two halves of one scorecard. Same
 * vocabulary, one level down, so the difference is visible in the size. */
.card-tabs {
  display: flex;
  gap: var(--sp-1);
  border-bottom: 1px solid var(--line);
  margin-bottom: var(--sp-3);
}

.card-tab {
  height: var(--ctl-h);
  padding: 0 var(--sp-3);
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  background: none;
  color: var(--muted);
  font-size: var(--fs-base);
}

.card-tab.active {
  color: var(--brand);
  border-bottom-color: var(--brand);
  font-weight: 600;
}

/* The ratio, its override and its reason, laid out as the scoring tab lays out
 * a system value -- because it is the same control and must not read as a
 * different one. */
#facility-ratio-row { margin-top: var(--sp-4); }

/* The Formula Viewer's Formula column.

   The stored XML, shown as it is stored. His viewer prints the engine's own
   `ToTraceString()`; this platform has no such printer, and a case list wrapped
   in a proportional font is unreadable either way. Monospaced, wrapped, and
   capped so one long formula cannot push the Value column off the screen —
   `SS_Corp`'s longest is 11,500 characters. */
.formula-source {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: var(--fs-sm);
  color: var(--muted);
  word-break: break-all;
  max-width: 32rem;
}

/* A line carrying an analyst's comment, and the line the Comment panel is bound
   to. The mark is a character rather than an icon: an image that fails to load
   leaves a note invisible, which is the one thing this mark exists to prevent. */
.comment-mark { color: var(--muted); font-size: var(--fs-sm); cursor: help; }
tr.commented > td { box-shadow: inset 2px 0 0 var(--muted); }

/* A line this bank added under a template line — Add/Del Row. Marked so a
   reader can tell a customer's own breakdown from the template's own lines;
   indented in the same rule the report indents children by. */
.client-line { font-style: italic; }

/* One administration entry's own children — the legacy's `NavAdministration`
   is a list that opens one of six screens, and this is that list. Indented so a
   reader can see it belongs to the entry above it. */
.admin-subnav { list-style: none; margin: var(--sp-2) 0 var(--sp-3) var(--sp-4);
                padding: 0; border-left: 2px solid var(--line); }
.admin-subnav li { display: flex; align-items: baseline; gap: var(--sp-3);
                   padding-left: var(--sp-3); }

/* The year selector on the Financial list, and the row it marks.
 *
 * A ticked row is shaded as well as ticked: the checkbox is one small mark at
 * the left of a wide row, and an analyst opening three years wants to see at a
 * glance which three. */
#fss-list-table tr.picked { background: var(--brand-soft); }
#fss-list-table .year-box { margin: 0; }

/* The heading over an earlier financial year opened for comparison. Styled like
 * the prior-period heading it stands in for, so a reader can tell at a glance
 * which columns are history and which one they are typing into. */
#fss-sheet th.comparison-heading { color: var(--muted); font-weight: 600; }

/* The blue question mark on a scorecard item — step 3.1.8 — and the guidance it
   opens. Blue because his is: it is the one control on the item an analyst is
   meant to notice before answering. */
.item-help {
  border: 1px solid var(--brand); color: var(--brand); background: transparent;
  border-radius: 50%; width: 1.15rem; height: 1.15rem; line-height: 1;
  padding: 0; font-size: var(--fs-sm); cursor: help;
}
.item-help-text {
  margin: var(--sp-2) 0 0; padding: var(--sp-2) var(--sp-3);
  border-left: 2px solid var(--brand); background: var(--brand-soft);
  font-size: var(--fs-sm); color: var(--muted); white-space: pre-wrap;
}


/* The scenario screen: two panes side by side, each scrolling on its own. */
.scn-split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: var(--sp-3);
  align-items: start;
}
/* Two panes need more than the 1040px every other screen gets; at that width
 * each pane was ~500px and its label column was squeezed out of sight. */
main:has(#scn-body:not(.hidden)) { max-width: 1600px; }
.scn-scroll { overflow-x: auto; }
/* Six right-hand tabs do not fit one row at half width. A tab keeps its name
 * on one line and the row wraps, rather than each name breaking in two. */
.scn-pane .card-tabs { flex-wrap: wrap; }
.scn-pane .card-tab { white-space: nowrap; }
.scn-table td.figure { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
/* "Projection 31/12/2026 (12)" is too long for one line. */
.scn-table th.figure { text-align: right; font-weight: 600; vertical-align: bottom; min-width: 9em; }
/* The line name is what a figure means; it stays in view when the pane
 * scrolls sideways, and is never narrower than a short name. */
.scn-table th:first-child, .scn-table td:first-child {
  position: sticky; left: 0; z-index: 1;
  min-width: 12em; background: var(--panel);
}
.scn-table tr.sheet-total td:first-child { font-weight: 700; }
/* A driver cell reads as a spreadsheet cell, not a form field: no box, a
 * light fill to show it takes typing, and an outline only while typing. */
.scn-table .figure-box {
  width: 9em; height: auto; padding: 2px 6px;
  text-align: right; font-variant-numeric: tabular-nums;
  border: 0; border-radius: 2px; background: var(--brand-soft);
}
.scn-table .figure-box:focus { outline: 2px solid var(--brand); outline-offset: 0; background: #fff; }
/* A balancing entry on the scenario screen: amber, the app's "adjusted"
   colour, with its calculation in the hover note. */
td.plug { color: var(--warn); cursor: help; }
/* Under the Reconciliation tab: how each projected year reaches 0. */
#scn-recon-notes { margin-top: var(--sp-3); }
#scn-recon-notes p { margin: var(--sp-1) 0; }
#scn-recon-notes p[title] { cursor: help; }
@media (max-width: 1100px) {
  .scn-split { grid-template-columns: 1fr; }
}


/* Special Treatment & Overrides: a question per block, its grade on the right. */
.adj-node { border-top: 1px solid var(--line); padding: var(--sp-3) 0; }
.adj-node-head { display: flex; justify-content: space-between; align-items: baseline; gap: var(--sp-3); }
.adj-node-title { font-weight: 600; }
.adj-grade { font-weight: 600; white-space: nowrap; }
.adj-grade.off { color: var(--muted); font-weight: 400; }
.adj-option { display: block; padding: 2px 0; }
.adj-option.automatic { color: var(--muted); }
.adj-child { margin: var(--sp-2) 0 0 var(--sp-4); padding-left: var(--sp-3); border-left: 2px solid var(--line); }
.adj-party-grid { width: 100%; margin-top: var(--sp-2); }
.adj-party-grid th, .adj-party-grid td { text-align: left; padding: 2px var(--sp-2); }

/* A base year offered in Scenario Management. */
.scn-base-year { display: inline-block; padding: 2px 0; }


/* ------------------------------------------------------- portfolio projection */
#pp-scenarios tr.picked { background: var(--brand-soft); }
#pp-scenarios td { white-space: nowrap; }
.pp-dual { display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px 12px; align-items: end;
           margin-bottom: 12px; }
.pp-dual select { width: 100%; min-height: 7em; }
.pp-arrows { display: flex; flex-direction: column; gap: 6px; padding-bottom: 4px; }
.pp-arrows button { min-width: 2.5em; }
.pp-caps { width: auto; }
.pp-caps input { width: 7em; }
#pp-fin-table input { width: 7em; text-align: right; }
#pp-fin-table tr.header td { font-weight: 700; }
#pp-og-table select { max-width: 14em; }
#pp-og-table tr.measured td { color: var(--muted, #666); }
#pp-whole-book { margin-top: 18px; }
@media (max-width: 720px) {
  .pp-dual { grid-template-columns: 1fr; }
  .pp-arrows { flex-direction: row; }
}
.table-scroll { overflow-x: auto; }


/* ------------------------------------------------------- BAR tab */
#bar-derivation select, #bar-trends select { min-width: 6em; max-width: 12em; }
#bar-derivation input, #bar-trends input { width: 8em; }
#bar-derivation td.overridden { background: var(--brand-soft); }
#bar-result, #bar-adjusted-result { margin: 8px 0; }


/* ------------------------------------------------------- batch review */
#br-table tr.picked { background: var(--brand-soft); }
#br-detail td.improved { background: #dff3e4; }
#br-detail td.worse { background: #fbdde3; }
