/* CRX Trade Inspired Theme - Professional Trading Platform Aesthetic */

/* Color Palette */
:root {
    /* Primary Colors - Deep blue/navy */
    --color-primary-dark: #1a2332;
    --color-primary: #2d3748;
    --color-primary-light: #4a5568;
    
    /* Accent Colors - Purple gradient */
    --color-accent: #8b5cf6;
    --color-accent-hover: #7c3aed;
    --color-accent-light: #a78bfa;
    --color-accent-gradient: linear-gradient(90deg, #a78bfa 0%, #8b5cf6 50%, #7c3aed 100%);
    
    /* Status Colors
       ------------------------------------------------------------------------------------------
       MUTED ON PURPOSE. These were the vivid Tailwind-500 ramp (#10b981 / #f59e0b / #ef4444), and
       on this dark ground a page carrying dozens of status words, chips, meter fills and borders
       read as a warning light rather than as data — which also flattens the difference between
       "amber because a rung is close" and "amber because that is just the colour of that word".
       Each is desaturated ~40% and lifted slightly in lightness, so contrast on every app
       background is preserved or better (error 4.09 -> 4.58 on the card ground) while the whole
       family sits back. The escalation order stays unmistakable: green -> amber -> orange -> red
       -> deep red, with a measured colour distance of at least ~16 between adjacent steps.
       Change these together or not at all: they are one ramp. */
    --color-success: #5cb894;
    --color-success-hover: #4aa17f;
    --color-warning: #d6a95c;
    --color-warning-hover: #c1934a;
    --color-error: #d1706f;
    --color-error-hover: #bb5c5b;
    --color-info: #7fb0d4;
    --color-info-hover: #6b9cc0;
    --color-info-soft: rgba(127, 176, 212, 0.10);

    /* `warning-deep` is the rung BETWEEN warning and error: the hedge "grace" state, where a
       shortfall exists but the countdown has not expired. Both the borrower page and the lender
       dashboard had their own bare #fb923c for it. */
    --color-warning-deep: #d98b57;

    /* Chart series. Declared here (not as hex literals inside a chart function) so an SVG series,
       a metric card and a table cell that mean the same thing cannot drift apart. `error-deep` is
       the beyond-the-last-rung shade, one step past --color-error. The numbered slots are the
       CATEGORICAL ramp: use them for "these are different series", and the semantic
       success/warning/error vars for "this series means good/bad". lending_history_charts.js.html
       had grown a second, disagreeing palette of seven literals; these are those values, named. */
    /* One step PAST error, for the beyond-the-last-rung swatch and the matching chart series. Kept
       a measured distance from --color-error so "worse than the worst rung" is visibly not just
       "the worst rung". */
    --color-error-deep: #ab5266;
    --color-chart-series: #8b5cf6;
    --color-chart-series-alt: #2dd4bf;
    --color-chart-series-3: #4f9dff;
    --color-chart-series-4: #f5a623;
    --color-chart-series-5: #f57bb0;

    /* Background Colors - Dark Theme */
    --color-bg-primary: #0f1419;
    --color-bg-secondary: #1a1f2e;
    --color-bg-card: #1e2532;
    --color-bg-dark: #0a0e14;
    
    /* Text Colors - Light for Dark Theme */
    --color-text-primary: #e2e8f0;
    --color-text-secondary: #f1f5f9;
    --color-text-muted: #94a3b8;
    --color-text-light: #ffffff;
    
    /* Border Colors - Dark Theme */
    --color-border: #2d3748;
    --color-border-focus: #8b5cf6;
    /* Half-weight rule for a secondary grid line (the column dividers in a dense table), where a
       full --color-border would compete with the row rules the reader actually scans along. */
    --color-border-subtle: #232b3a;
    
    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);

    /* Radii & spacing scale */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --transition-fast: 120ms ease;

    /* Layout scale. --layout-max-width is the app-wide content column (header, nav and every page
       body share one .container). No breakpoint needed: a max-width is inert below its own value.
       --layout-text-max-width caps PROSE only — a wide column helps cards, not sentences. */
    --layout-max-width: 1600px;
    --layout-text-max-width: 84ch;

    /* Soft status/accent fills (card tints, badges) */
    --color-accent-soft: rgba(139, 92, 246, 0.12);
    /* These quote their own status colour's RGB, so they move with it — a tint mixed from the old
       vivid ramp under a muted border is the mismatch that makes a callout look dirty. */
    --color-warning-soft: rgba(214, 169, 92, 0.10);
    --color-success-soft: rgba(92, 184, 148, 0.10);
    --color-error-soft: rgba(209, 112, 111, 0.10);

    /* Skeleton loading placeholders */
    --skeleton-base: var(--color-bg-card);
    --skeleton-shine: rgba(255, 255, 255, 0.06);
}

/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
    background-color: var(--color-bg-primary);
    color: var(--color-text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    color: var(--color-text-secondary);
    line-height: 1.2;
}

h1 {
    font-size: 2rem;
}

h2 {
    font-size: 1.15rem;
}

h3 {
    font-size: 1rem;
}

code {
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', 'source-code-pro', monospace;
    font-size: 0.9em;
    background-color: var(--color-bg-dark);
    color: var(--color-text-light);
    padding: 0.125rem 0.375rem;
    border-radius: 0.25rem;
}

/* Layout */
.container {
    max-width: var(--layout-max-width);
    margin: 0 auto;
    padding: 20px;
}

/* Explanatory copy: a section intro under a heading, or a page footnote. Capped width so widening
   .container stretches the cards, not the sentences. */
.page-note {
    margin: 0.75rem 0;
    color: var(--color-text-muted);
    font-size: 0.85rem;
    max-width: var(--layout-text-max-width);
}

/* Error-toned note: a workflow failure line under a summary. The tone IS the datum, so it is not
   left to the muted default. */
.page-note--error {
    color: var(--color-error);
    font-weight: 600;
}

/* Placeholder for a region with nothing to show ("No active transfers", "Loading…", a load
   failure): quiet and centred, so an empty list reads as a state of its panel rather than a
   stray sentence pinned to the panel's corner. Callers may still override the colour (errors). */
.empty-note {
    margin: 0.25rem 0;
    padding: 0.75rem 0.5rem;
    color: var(--color-text-muted);
    font-size: 0.8rem;
    text-align: center;
}

/* Centred footnote variant. Needs auto inline margins as well as text-align: the base rule caps the
   width, so it would otherwise sit against the left edge of a wide page. */
.page-note--center {
    margin-top: 1.5rem;
    margin-inline: auto;
    text-align: center;
}

/* Header: ONE compact top bar — brand left, nav right. The old chrome was a 1.5rem-padded
   centered banner plus a separate boxed-pill nav band: two full-width strips (~210px) before any
   content, on every page. */
.header {
    background: linear-gradient(135deg, var(--color-bg-dark) 0%, var(--color-primary-dark) 100%);
    color: var(--color-text-light);
    padding: 0;
    /* The .container's own top padding supplies the rest of the gap to the portfolio bar. */
    margin-bottom: 0.35rem;
    box-shadow: var(--shadow-sm);
    border-bottom: 1px solid var(--color-border);
}

.header .container {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding-top: 0.4rem;
    padding-bottom: 0.4rem;
    min-height: 3.1rem;
}

.header .logo {
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    color: var(--color-text-light);
    display: flex;
    align-items: center;
    text-transform: uppercase;
    white-space: nowrap;
}

.header .logo .logo-accent {
    background: var(--color-accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-weight: 700;
    margin-left: 0.25rem;
}

/* The product name is the brand's qualifier now, not a page-dominating 2rem headline. Still the
   page's h1 for semantics. */
.header h1.header-product {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--color-text-muted);
    letter-spacing: 0.02em;
    margin: 0;
    padding-left: 0.75rem;
    border-left: 1px solid var(--color-border);
    white-space: nowrap;
}

/* Running build stamp (gui.context_processors.app_version) — staff only. Sits beside the product
   name as a second muted qualifier; the bar centres its items, so no self-alignment. */
.header .header-version {
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', monospace;
    font-size: 0.72rem;
    color: var(--color-text-muted);
    white-space: nowrap;
}

/* Navigation: quiet text links on the bar itself — the boxed pills spent a border and a
   background on every item and read as eight buttons fighting for attention. */
.nav {
    margin-left: auto;
    min-width: 0;
}

.nav > ul {
    list-style: none;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 0.1rem;
    flex-wrap: wrap;
    margin: 0;
    padding: 0;
}

.nav > ul > li > a {
    color: var(--color-text-secondary);
    text-decoration: none;
    padding: 0.45rem 0.7rem;
    display: block;
    white-space: nowrap;
    transition: background 0.15s ease, color 0.15s ease;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
}

.nav > ul > li > a:hover {
    background-color: var(--color-accent-soft);
    color: var(--color-accent-light);
}

.nav > ul > li > a.active {
    background-color: rgba(139, 92, 246, 0.18);
    font-weight: 600;
    color: var(--color-accent-light);
}

/* Navigation Dropdown */
.nav-dropdown {
    position: relative;
}

.nav-dropdown-toggle {
    cursor: pointer;
    user-select: none;
}

.nav-dropdown-menu {
    position: absolute;
    top: calc(100% + 0.25rem);
    /* Right-aligned under its trigger: Account is the bar's LAST item, and a centered 240px
       menu overflowed the viewport edge. */
    right: 0;
    left: auto;
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    min-width: 240px;
    list-style: none;
    padding: 0.25rem 0;
    margin: 0;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.15s ease, visibility 0.15s ease, transform 0.15s ease;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    overflow: hidden;
}

/* Create invisible bridge to maintain hover */
.nav-dropdown::before {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    height: 0.25rem;
    background: transparent;
    z-index: 999;
    display: none;
}

.nav-dropdown:hover::before {
    display: block;
}

.nav-dropdown:hover .nav-dropdown-menu,
.nav-dropdown:focus-within .nav-dropdown-menu {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    /* No X-translate: the menu is right-anchored now (`right: 0`), and the old centring shift
       pushed it half its width to the left of the trigger — out from under the pointer, so the
       hover broke before anyone could reach it. */
    transform: translateY(0);
}

.nav-dropdown-menu li {
    margin: 0;
    display: block;
    width: 100%;
}

.nav-dropdown-menu li + li {
    border-top: 1px solid rgba(148, 163, 184, 0.12);
}

.nav-dropdown-menu a {
    width: 100%;
    padding: 0.8rem 1rem;
    display: block;
    color: var(--color-text-primary);
    text-decoration: none;
    background: transparent;
    border: none;
    border-radius: 0;
    box-shadow: none;
    font-weight: 400;
    font-size: 0.9rem;
    white-space: nowrap;
    text-align: left;
    line-height: 1.2;
}

.nav-dropdown-menu a:hover {
    background-color: var(--color-accent-soft);
    color: var(--color-accent-light);
}

/* Cards */
.card {
    background: var(--color-bg-card);
    border-radius: 12px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.2);
    /* Tightened from 1.5rem/1.5rem. A risk page stacks six to nine of these; at the old rhythm
       the chrome between two containers cost more vertical space than a row of metric cards. */
    padding: 1rem 1.25rem 1.15rem;
    margin-bottom: 1rem;
    border: 1px solid var(--color-border);
    transition: box-shadow 0.2s ease, transform 0.2s ease, border-color 0.2s ease;
}

.card:hover {
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.4), 0 4px 6px -2px rgba(0, 0, 0, 0.3);
    border-color: var(--color-accent);
}

/* ONE container-header geometry, shared by the plain `.card h2` and by `.card-title-row` (the
   heading-plus-page-state variant). Both used to set their own numbers, so a card whose heading
   carried a control sat at a different height from the card above it, and the words floated well
   clear of their own accent rule. The numbers below live in one place on purpose: change them
   together or the two headers drift apart again.
     --card-head-gap  : heading baseline -> accent rule
     --card-head-space: accent rule -> first row of content */
:root {
    --card-head-gap: 0.4rem;
    --card-head-space: 0.7rem;
}

.card h2,
.card-title-row {
    margin-bottom: var(--card-head-space);
    padding-bottom: var(--card-head-gap);
    border-bottom: 2px solid var(--color-accent);
}

.card h2 {
    color: var(--color-text-secondary);
    /* Down from the global h2's 1.5rem: at that size a container name outweighed the figures
       inside it, and nine of them per page is a lot of ink spent on furniture. */
    font-size: 1.15rem;
    font-weight: 600;
}

/* Page title line that carries PAGE-LEVEL state beside the heading (the lender dashboard's loan
   picker). The accent rule lives on the whole row, so the page keeps the same full-width underline
   every other card heading has instead of a stub under the words. */
.card-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.4rem 1.25rem;
}

.card-title-row > h2 {
    margin: 0;
    padding: 0;
    border-bottom: none;
}

/* A container header that carries its own meta or actions on the right (freshness stamp, a
   drill-through link). Same rule and same gaps as a bare `.card h2` — it IS the card heading,
   just with a right-hand slot — so a card with actions never sits at a different height from
   the card above it. */
.card-head-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.35rem 1rem;
    margin-bottom: var(--card-head-space);
    padding-bottom: var(--card-head-gap);
    border-bottom: 2px solid var(--color-accent);
}

.card-head-row > h2 {
    margin: 0;
    padding: 0;
    border-bottom: none;
}

/* Right-hand slot: quiet meta (a "Synced 2m ago" stamp) sitting beside the heading rather than
   stranded on its own line between two blocks of content. */
.card-head-meta {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 0.25rem 0.9rem;
    margin-left: auto;
}

/* The row itself supplies the spacing; a control row inside it must not add its own. */
.card-title-row .control-row {
    margin-bottom: 0;
}

/* Forms */
.form-group {
    margin-bottom: 1.25rem;
}

/* .form-label: identical presentation for a heading over something that is NOT a labelable
   form control (a read-only value, a button group, a JS-mounted widget). A <label> there is
   an accessibility defect — it promises screen readers an association it can't deliver — so
   those headings are <span class="form-label"> instead, paired with role="group"/aria where
   the grouping matters. */
.form-group label,
.form-group .form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--color-text-secondary);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.form-group input,
.form-group select,
.form-group textarea,
.form-control {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    font-size: 0.9rem;
    transition: all 0.2s ease;
    background-color: var(--color-bg-secondary);
    color: var(--color-text-primary);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus,
.form-control:focus {
    outline: none;
    border-color: var(--color-border-focus);
    box-shadow: 0 0 0 3px var(--color-accent-soft);
}

.form-group input:disabled,
.form-group select:disabled {
    background-color: var(--color-bg-dark);
    cursor: not-allowed;
    opacity: 0.5;
    border-color: var(--color-border);
}

.form-group small {
    display: block;
    margin-top: 0.25rem;
    color: var(--color-text-muted);
    font-size: 0.85rem;
}

/* Buttons */
.btn {
    background: var(--color-accent);
    color: var(--color-text-light);
    border: none;
    /* The default tier. Was 0.75rem/1.5rem at 1rem — a 48px-tall slab that read as the page's
       loudest element on every form (Submit RFQ, Move Funds, Project, Recompute). One notch
       slimmer everywhere; .btn-sm / .btn-xs remain the compact tiers below it. */
    padding: 0.5rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    text-decoration: none;
    /* Flat by design (product request): no drop shadow and no hover lift anywhere in the button
       family. Hierarchy comes from fill vs outline, not from elevation. */
}

.btn:hover:not(:disabled) {
    background: var(--color-accent-hover);
}

.btn:disabled {
    background: var(--color-primary-light);
    cursor: not-allowed;
    opacity: 0.5;
}

.btn-success {
    background: var(--color-success);
}

.btn-success:hover:not(:disabled) {
    background: var(--color-success-hover);
}

.btn-warning {
    background: var(--color-warning);
}

.btn-warning:hover:not(:disabled) {
    background: var(--color-warning-hover);
}

.btn-danger {
    background: var(--color-error);
}

.btn-danger:hover:not(:disabled) {
    background: var(--color-error-hover);
}

.btn-secondary {
    background: var(--color-primary);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--color-primary-light);
}

/* Extra-small button for an in-table action (the loan book's per-row "Collect Interest"): a
   full-size .btn sets the row height for every other cell in that row, which is most of why the
   book scrolled for pages. Geometry only — colour still comes from .btn-secondary / .btn-danger. */
.btn-xs {
    padding: 0.2rem 0.55rem;
    font-size: 0.72rem;
    border-radius: 4px;
    white-space: nowrap;
}

/* Outline variant: the quiet size-agnostic style for a panel's SUPPORTING actions — the whitelist
   panel's "Add symbol"/"Resync" on the Exchange Risk tab, and "Prepare amendment"/"Extend term"/
   "Save and send approval emails" on Terms & Amendments. Three filled buttons in a small panel
   compete with the data above them; a FILLED button marks a view's one primary action, an OUTLINED
   one marks everything supporting it. Border and label only; it fills in on hover so it still
   reads as pressable. Compose with a size: `btn btn-outline btn-sm`. */
/* The secondary action, and it should look like one. With a --color-border edge and body-colour
   text it was indistinguishable from a disabled control or a plain bordered box — the accent is
   what says "this is a thing you can press". The FILLED .btn stays the primary; this is the
   quieter sibling, not a different family. */
.btn-outline {
    background: transparent;
    border: 1px solid var(--color-accent);
    color: var(--color-accent-light);
    font-weight: 500;
}

.btn-outline:hover:not(:disabled) {
    background: var(--color-accent-soft);
    border-color: var(--color-accent-hover);
    color: var(--color-accent-light);
}

/* A destructive/cautionary outline action (Revoke, Cancel request) keeps the same geometry and
   takes the warning edge instead, so tone still carries the meaning. */
.btn-outline.btn-warning {
    background: transparent;
    border-color: var(--color-warning);
    color: var(--color-warning);
}

.btn-outline.btn-warning:hover:not(:disabled) {
    background: var(--color-warning-soft);
    border-color: var(--color-warning-hover);
    color: var(--color-warning);
}

/* Destructive action that should not shout (Delete schedule beside Edit / Pause). */
.btn-outline.btn-danger {
    background: transparent;
    border-color: var(--color-error);
    color: var(--color-error);
}

.btn-outline.btn-danger:hover:not(:disabled) {
    background: var(--color-error-soft);
    border-color: var(--color-error-hover);
    color: var(--color-error);
}

.btn-outline:disabled {
    background: transparent;
    border-color: var(--color-border);
    color: var(--color-text-muted);
}

/* Standard small button: the size for a panel's own actions. One step up from .btn-xs (which exists
   only so an in-table button does not set the row height) and well below the 1rem default. */
.btn-sm {
    padding: 0.35rem 0.75rem;
    font-size: 0.8rem;
    font-weight: 500;
    border-radius: var(--radius-sm);
    white-space: nowrap;
}

/* Alerts */
.alert {
    padding: 1rem 1.25rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    border-left: 4px solid;
    box-shadow: var(--shadow-sm);
}

.alert-success {
    background: var(--color-success-soft);
    color: var(--color-success);
    border-color: var(--color-success);
}

.alert-error {
    background: var(--color-error-soft);
    color: var(--color-error);
    border-color: var(--color-error);
}

.alert-info {
    background: var(--color-accent-soft);
    color: var(--color-accent-light);
    border-color: var(--color-accent);
}

.alert-warning {
    background: var(--color-warning-soft);
    color: var(--color-warning);
    border-color: var(--color-warning);
}

/* Inline in-card notice ("callout"): a fully-bordered, denser sibling of .alert for a notice that
   sits INSIDE a card next to the thing it warns about, rather than at the top of the page.
   Three pages had each grown their own copy of this exact box with bare hex literals —
   exchanges.html's .subaccount-warning and .margin-funding-notice, vault.html's
   .vault-deposit-warning — at three slightly different densities. One family, in the design
   system, so a warning on the funding page and a warning on the vault page look like the same
   product making the same kind of statement. */
.callout {
    margin-top: 0.75rem;
    padding: 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    /* Panel body copy (§1 md). Unset, a callout took whatever size its parent had, so a page-level
       gate notice rendered at 1rem beside 0.85rem callouts in the panels under it. */
    font-size: 0.85rem;
    line-height: 1.4;
}

/* The callout's TITLE ("Warning", "Withdrawals unavailable.") is a block: it names the notice. */
.callout > strong {
    display: block;
    margin-bottom: 0.25rem;
}

/* A <strong> INSIDE the body copy is emphasis within a sentence, not a second title. The blanket
   `.callout strong` rule broke the deposit warnings mid-sentence — "…only supports deposits of" /
   "USDC, ETH, USDT" / "on supported networks…" read as three fragments instead of one instruction,
   on the notice that stops a client sending an unrecoverable asset. */
.callout small strong,
.callout p strong {
    display: inline;
    margin-bottom: 0;
}

.callout small {
    display: block;
    line-height: 1.4;
}

/* "Showing 2 of 3…" is a note ABOUT the list, not another item in it, so it drops out of the
   callout's inherited warning colour. */
.callout-footnote {
    display: block;
    margin-top: 0.35rem;
    color: var(--color-text-muted);
    font-size: 0.72rem;
    line-height: 1.35;
}

/* A closed loan's drivers are frozen (appendRiskReasonsHistoricalNote): the dating line sits under
   the heading, muted like the footnote, so it qualifies the list instead of joining it. */
.callout-historical {
    display: block;
    margin: 0.15rem 0 0.35rem;
    color: var(--color-text-muted);
    font-size: 0.75rem;
    line-height: 1.35;
}

.callout--warning {
    background: var(--color-warning-soft);
    border-color: var(--color-warning);
    /* Was a hardcoded #fcd34d, a full step brighter than the border around it. */
    color: var(--color-warning);
}

.callout--error {
    background: var(--color-error-soft);
    border-color: var(--color-error);
    color: var(--color-error);
}

.callout--info {
    background: var(--color-info-soft);
    border-color: var(--color-info);
    /* Was a lavender #c4b5fd that matched neither the info border nor the ramp. */
    color: var(--color-info);
}

/* Bulleted reason list inside a .callout (the Summary tab's risk drivers). The separators inherit
   the callout's own border colour rather than each caller inventing a translucent tint. */
.reason-list {
    margin-top: 0.35rem;
}

.reason-row {
    display: flex;
    align-items: flex-start;
    gap: 0.4rem;
    padding: 0.3rem 0;
    font-size: 0.8rem;
    line-height: 1.35;
}

.reason-row + .reason-row {
    border-top: 1px solid var(--color-border);
}

.reason-bullet {
    flex-shrink: 0;
    color: inherit;
    opacity: 0.7;
}

/* An INFORMATIONAL note, not a driver: it explains how a figure was built and would read the same
   on a healthy loan, so it drops out of the callout's warning tone. */
.reason-bullet--muted {
    color: var(--color-text-muted);
}

/* Action-needed variant: an inline single-line notice (no block <strong> heading break). */
.callout--inline {
    padding: 0.6rem 0.85rem;
    font-size: 0.85rem;
}

.callout--inline strong {
    display: inline;
    margin-bottom: 0;
}

@media (max-width: 768px) {
    .callout {
        padding: 0.5rem;
    }

    .callout small {
        font-size: 0.75rem;
    }
}

/* Toast notifications — floating, fixed position */
.toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-width: 450px;
    pointer-events: none;
}

.toast {
    padding: 0.7rem 1rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--color-border);
    border-left: 3px solid;
    font-size: 0.85rem;
    line-height: 1.4;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.45);
    pointer-events: auto;
    cursor: pointer;
    animation: toast-in 0.3s ease-out;
    transition: opacity 0.3s ease, transform 0.3s ease;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.75rem;
    word-break: break-word;
}

.toast:hover {
    opacity: 0.9;
}

.toast-message {
    flex: 1;
}

.toast-actions {
    flex-shrink: 0;
    display: flex;
    gap: 0.25rem;
    align-items: center;
}

.toast-btn {
    opacity: 0.6;
    font-size: 1.1rem;
    line-height: 1;
    cursor: pointer;
    background: none;
    border: none;
    color: inherit;
    padding: 0.1rem 0.2rem;
}

.toast-btn:hover {
    opacity: 1;
}

.toast.toast-removing {
    opacity: 0;
    transform: translateX(100%);
}

/* Dedup "bump": re-triggered on a repeat toast instead of stacking a duplicate */
.toast.toast-bump {
    animation: toast-bump 0.3s ease-out;
}

@keyframes toast-bump {
    0% { transform: scale(1); }
    35% { transform: scale(1.03); }
    100% { transform: scale(1); }
}

/* Toast tones: the product's own panel language — dark card ground with a tinted wash and a
   coloured rule — instead of a solid saturated block shouting in white-on-green. The tone still
   reads instantly from the rule + wash; the words stay at body contrast. */
.toast-success {
    background: linear-gradient(var(--color-success-soft), var(--color-success-soft)), var(--color-bg-card);
    color: var(--color-text-primary);
    border-left-color: var(--color-success);
}

.toast-error {
    background: linear-gradient(var(--color-error-soft), var(--color-error-soft)), var(--color-bg-card);
    color: var(--color-text-primary);
    border-left-color: var(--color-error);
}

.toast-info {
    background: linear-gradient(var(--color-info-soft), var(--color-info-soft)), var(--color-bg-card);
    color: var(--color-text-primary);
    border-left-color: var(--color-accent);
}

.toast-warning {
    background: linear-gradient(var(--color-warning-soft), var(--color-warning-soft)), var(--color-bg-card);
    color: var(--color-text-primary);
    border-left-color: var(--color-warning);
}

@keyframes toast-in {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Balance Grid */
/* Tightened alongside `.card`: a balance grid is a row of small facts, and at 1.25rem gaps with
   1.25rem-padded cards four assets filled a screen. Same numbers as `.kv-label` / `.metric-card`
   so a balance card and a metric card read as one family. */
.balance-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 0.7rem;
    margin-bottom: 0.85rem;
}

.balance-card {
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: 0.7rem 0.85rem;
    text-align: center;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.balance-card:hover {
    border-color: var(--color-accent);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.2);
    background: var(--color-bg-card);
}

.balance-card h3 {
    color: var(--color-text-muted);
    margin-bottom: 0.3rem;
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    font-weight: 600;
}

.balance-amount {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--color-text-secondary);
    margin-bottom: 0.4rem;
    font-variant-numeric: tabular-nums;
}

.balance-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    flex-wrap: wrap;
}

/* Tables */
table {
    width: 100%;
    border-collapse: collapse;
    background: var(--color-bg-card);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    border: 1px solid var(--color-border);
}

table thead {
    background: var(--color-bg-dark);
    color: var(--color-text-light);
}

table th {
    padding: 1rem;
    text-align: left;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.85rem;
    letter-spacing: 0.05em;
}

table td {
    padding: 1rem;
    border-top: 1px solid var(--color-border);
}

table tbody tr {
    transition: background-color 0.2s ease;
}

table tbody tr:hover {
    background-color: var(--color-bg-secondary);
}

table tbody tr:last-child td {
    border-bottom: none;
}

/* Tabs */
/* `.ra-tabs`/`.ra-tab` are the Risk Analytics page's tab strip. Same family, aliased into these
   selectors rather than renamed in the markup: gui/tests_risk_analytics_ux.py pins the literal
   `class="ra-tabs"` (it asserts the selector card renders above the strip), so the markup keeps
   its names and the LOOK is shared here — one block, two names, nothing to drift. */
.tabs,
.ra-tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--color-border);
    /* Same rhythm as a card heading's own rule-to-content gap (--card-head-space): a tab strip IS
       a heading for what is under it, and 1.5rem made it float clear of its own content. */
    margin-bottom: var(--space-3);
    overflow-x: auto;
}

.tab,
.ra-tab {
    padding: 0.75rem 1.5rem;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    color: var(--color-text-muted);
    transition: all 0.2s ease;
    white-space: nowrap;
}

.tab:hover,
.ra-tab:hover {
    color: var(--color-text-primary);
    background-color: var(--color-bg-secondary);
}

.tab.active,
.ra-tab.active {
    color: var(--color-accent);
    border-bottom-color: var(--color-accent);
    font-weight: 600;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Compact tab variant for dense dashboards (borrower risk page, lender dashboard) */
.tabs--compact,
.ra-tabs {
    margin-bottom: var(--space-4);
}

.tabs--compact .tab,
.ra-tab {
    padding: 0.5rem 0.9rem;
    font-size: 0.9rem;
}

.tab:focus-visible,
.ra-tab:focus-visible {
    outline: 2px solid var(--color-border-focus);
    outline-offset: -2px;
}

/* Pill tab variant: rounded standalone buttons instead of underlined tabs, with the active
   tab filled in solid accent. Used by pages that pick between a small set of top-level venues
   (e.g. the exchanges page's exchange picker) rather than switching content sub-sections. */
.tabs--pills {
    gap: 0.5rem;
    border-bottom: none;
    margin-bottom: 1rem;
}

.tabs--pills .tab {
    padding: 0.6rem 1.4rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-bg-secondary);
    transition: background-color var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast);
}

.tabs--pills .tab:hover {
    color: var(--color-text-primary);
    border-color: var(--color-accent-light);
    background-color: var(--color-bg-secondary);
}

.tabs--pills .tab.active {
    background-color: var(--color-accent);
    border-color: var(--color-accent);
    color: var(--color-text-light);
    font-weight: 600;
}

.tab-badge {
    display: inline-block;
    margin-left: 0.35rem;
    padding: 0 0.45rem;
    border-radius: 10px;
    background: var(--color-accent-soft);
    color: var(--color-accent-light);
    font-size: 0.75em;
    font-weight: 600;
    line-height: 1.5;
}

/* Metric cards (dashboard stat tiles) */
.metric-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: var(--space-3);
    margin-bottom: var(--space-4);
}

/* A notice directly above a tile grid or fact strip (the lender's "No risk snapshot" warning, the
   scheduler's Paused banner) sat flush on it: the callout only carries a top margin. */
.callout + .metric-grid,
.callout + .summary-strip,
.callout + .data-panel {
    margin-top: var(--space-3);
}

/* Hero rows carry 1.35rem values, so they need a wider track than the 150px the secondary card
   grids use: a full USD figure ("$2,682,511.38") wrapped mid-number at the shared minimum. */
.metric-grid--hero {
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
}

/* Quiet by default. These tiles are read a dozen at a time, and at a full-strength border plus a
   raised fill each one competed with its own number: the page read as a wall of boxes rather than a
   set of figures. The chrome recedes to a hairline and a barely-there fill so the LABEL and the
   VALUE are what carry the card — colour is reserved for the value's tone, where it is the datum. */
.metric-card {
    padding: 0.65rem;
    border: 1px solid var(--color-border-subtle);
    border-radius: var(--radius-sm);
    background: var(--color-bg-secondary);
}

/* No hover reaction anywhere in the family: a metric card is not clickable, and a border-and-shadow
   lift on something inert is an affordance that lies. (The `.metric-card:hover` selector still
   drives the threshold-meter popup further down — that is a disclosure, not a style change.) */

.metric-card--important {
    border-color: var(--color-warning);
    background: var(--color-warning-soft);
}

.metric-card .metric-label {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    color: var(--color-text-muted);
    font-size: 0.8em;
}

.metric-card .metric-value {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    margin-top: 0.15rem;
    word-break: break-word;
}

.metric-card .metric-subtext {
    color: var(--color-text-muted);
    font-size: 0.7em;
    margin-top: 0.15rem;
}

/* Pinned metric strip (the mini risk summary shown on non-summary tabs). Sticky so the overview
   stays visible while scrolling long tab bodies; cards WRAP responsively instead of scrolling
   horizontally. */
.metric-card-row {
    position: sticky;
    top: 0;
    z-index: 5; /* keep BELOW tooltips/toasts */
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    padding: var(--space-1) 0 var(--space-2);
    margin-bottom: var(--space-3);
    /* No wrapper border/box — just the cards. Background matches the enclosing .card container
       (invisible at rest) while staying opaque so content doesn't bleed through the gaps while
       the strip is stuck during scroll. */
    background: var(--color-bg-card);
}

/* Plain value cards compress hard so the whole strip fits one line; meter cards keep room.
   Content is vertically centered so short cards don't leave dead space below (flex stretches
   every card to the height of the tallest, i.e. the meter cards). */
.metric-card-row .metric-card {
    flex: 1 1 96px;
    min-width: 0;
    padding: 0.4rem 0.5rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.metric-card-row .metric-card:has(.threshold-meter) {
    flex: 1.8 1 150px;
}

/* The strip's labels are ellipsised so the cards stay narrow — but the ellipsis must clip only the
   LABEL TEXT, never the row. `overflow: hidden` on the label itself silently swallowed the
   absolutely-positioned .tooltip-bubble (and `display: block` dropped the label out of flex, so the
   badge was ellipsised away too): every ⓘ on this strip looked dead. Clip the text span instead. */
.metric-card-row .metric-card .metric-label {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    white-space: nowrap;
    overflow: visible;
}

.metric-card-row .metric-card .metric-label > span:first-child {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* The badge must not be the thing that shrinks when the card is narrow. */
.metric-card .metric-label > .tooltip-icon {
    flex: 0 0 auto;
}

.metric-card--compact {
    padding: 0.4rem 0.55rem;
}

.metric-card--compact .metric-label {
    font-size: 0.7em;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    white-space: nowrap;
}

.metric-card--compact .metric-value {
    font-size: 0.95em;
    /* Long status strings ("reduction required") must wrap to fit the narrow strip cards
       instead of clipping; short numeric values are unaffected. */
    white-space: normal;
    overflow-wrap: anywhere;
    line-height: 1.15;
}

.metric-value--success { color: var(--color-success); }
.metric-value--warning { color: var(--color-warning); }
.metric-value--error { color: var(--color-error); }

/* Before/after line inside a .metric-card: the headline value is always the REAL, current figure;
   this line is the only place a hypothetical (stressed / projected) value may appear, and it is
   always named. Both risk-analytics tabs render it through one helper
   (renderShockDeltaCardHtml in includes/loan_shocks.js.html) so the two tabs cannot describe the
   same before/after with opposite conventions. */
.metric-card .metric-delta {
    font-size: 0.78em;
    margin-top: 0.15rem;
    color: var(--color-text-muted);
}

.metric-delta--worse { color: var(--color-error); }
.metric-delta--better { color: var(--color-success); }
/* A shock that moved the number but not the DISPLAYED number: neither good nor bad news, and it
   must not be coloured as though something happened. */
.metric-delta--neutral { color: var(--color-text-muted); }

/* Hero cards: the handful of decision-driving metrics at the top of the Summary tab. */
/* Hero cards earn their prominence from POSITION and SIZE — first row, wider track, larger value —
   not from an accent bar and a contrasting fill. The 3px purple edge made seven tiles shout at
   once, and it was also what turned grey on hover. */
.metric-card--hero {
    padding: 0.85rem 0.9rem;
    background: var(--color-bg-secondary);
    border-color: var(--color-border-subtle);
}

.metric-card--hero .metric-value {
    /* 1.35rem across a seven-card row was the loudest thing on the page. Still clearly the headline
       tier — the secondary cards sit at 1rem — without dominating everything under it. */
    font-size: 1.15rem;
    margin-top: 0.25rem;
}

/* HERO subtexts wrap. They used to share the strip's one-line ellipsis, on the reasoning that a
   long subtext must not stretch the row — but the cards sit in a stretch grid, so the tallest one
   sets the row height anyway, and the rule was simply deleting text: "Primary collateral value used
   by lender risk" clipped to "Primary collateral valu…". The comment claimed the full text lived on
   the tooltip; it did not — the tooltip carries the metric's explanation, not the subtext. */
.metric-card--hero .metric-subtext {
    white-space: normal;
    overflow-wrap: anywhere;
    line-height: 1.3;
}

/* The pinned strip keeps the single line: it is sticky chrome, and staying one row tall is the
   point of it. */
.metric-card--compact .metric-subtext {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Threshold meter: slim bar + ticks showing a value against its escalation ladder. */
.threshold-meter {
    position: relative;
    margin-top: 0.45rem;
    /* Pointer, not `help`: clicking the bar opens its ladder, so the bar is a control. The help
       cursor advertised a hover behaviour that no longer exists. */
    cursor: pointer;
}

/* The colour-coded ladder, anchored under the bar. CLICK to open, click away or Escape to close —
   the same single trigger the ⓘ badge uses, and for the same reason: with both on hover, the two
   opened on top of each other inside one card and which gesture closed which depended on which had
   opened first. renderThresholdMeter toggles inline `display`. */
.threshold-meter-popup {
    display: none;
    position: absolute;
    z-index: 1000;
    top: calc(100% + 6px);
    left: 0;
    min-width: 190px;
    padding: 0.55rem 0.65rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-bg-primary);
    box-shadow: var(--shadow-lg);
}

/* Bar and badge now divide the work instead of duplicating it: the BAR owns the numbers (click it
   for the ladder), the BADGE owns the words (click it for the prose). Only one is open at a time —
   see the disclosure registry in common.js — so they can no longer stack. */

/* Ladder legend rows: swatch + label + value. Used in the meter popup and ⓘ tooltips. */
.threshold-legend {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    width: 100%;
}

.threshold-legend-row {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    font-size: 0.8rem;
    line-height: 1.2;
    white-space: nowrap;
}

.threshold-legend-row--current {
    font-weight: 700;
}

.threshold-legend-swatch {
    flex: 0 0 auto;
    width: 8px;
    height: 8px;
    border-radius: 2px;
}

.threshold-legend-label {
    color: var(--color-text-muted);
    text-transform: capitalize;
}

.threshold-legend-row--current .threshold-legend-label {
    color: var(--color-text-primary);
}

.threshold-legend-value {
    margin-left: auto;
    font-variant-numeric: tabular-nums;
}

.threshold-meter-track {
    position: relative;
    height: 6px;
    border-radius: 3px;
    background: var(--color-primary-dark);
    border: 1px solid var(--color-border);
    overflow: visible;
}

.threshold-meter-fill {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    border-radius: 3px;
    transition: width var(--transition-fast);
}

.threshold-meter-fill--success { background: var(--color-success); }
.threshold-meter-fill--warning { background: var(--color-warning); }
.threshold-meter-fill--error { background: var(--color-error); }

.threshold-meter-dot {
    position: absolute;
    left: 3px;
    top: 50%;
    transform: translateY(-50%);
    width: 5px;
    height: 5px;
    border-radius: 50%;
}

/* Rung markers on the bar. renderThresholdMeter assigns each one the colour of its legend row, so
   the bar and the popup are one picture; the muted grey here is only the fallback for a meter
   rendered without severity colours. No opacity — it washed the assigned colour back out toward
   grey, which is the problem the colours exist to solve. Each carries its rung name in `title`,
   since a 2px mark cannot label itself. */
.threshold-meter-tick {
    position: absolute;
    top: -3px;
    width: 2px;
    height: 12px;
    background: var(--color-text-muted);
    border-radius: 1px;
    /* Inherit the bar's pointer: a tick sits INSIDE the bar, so a help cursor here put the `?` back
       on the progress bar through the back door. The rung name is still in its title. */
    cursor: inherit;
}

.threshold-meter-caption {
    margin-top: 0.3rem;
    font-size: 0.72em;
    color: var(--color-text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    /* Dotted underline marks the bar as having more behind it — a click now, not a hover. */
    width: fit-content;
    max-width: 100%;
    border-bottom: 1px dotted var(--color-text-muted);
    padding-bottom: 1px;
}

/* Compact themed select (portfolio switcher, history portfolio picker) — matches the dark form
   inputs but sized for inline header use, with a custom chevron. */
.themed-select {
    appearance: none;
    -webkit-appearance: none;
    padding: 0.45rem 2rem 0.45rem 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background-color: var(--color-bg-secondary);
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%2394a3b8' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.7rem center;
    color: var(--color-text-primary);
    font-size: 0.9rem;
    line-height: 1.3;
    max-width: 100%;
    cursor: pointer;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.themed-select:hover {
    border-color: var(--color-primary-light);
}

.themed-select:focus {
    outline: none;
    border-color: var(--color-border-focus);
    box-shadow: 0 0 0 3px var(--color-accent-soft);
}

/* Virtualized searchable picker (portfolio_picker.js) — trigger reuses .themed-select. */
.picker {
    position: relative;
    display: inline-block;
    min-width: 240px;
    max-width: 100%;
}

.picker-trigger {
    width: 100%;
    text-align: left;
    display: flex;
    align-items: center;
}

.picker-trigger-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    min-width: 0;
}

.picker-panel {
    position: absolute;
    z-index: 1000;
    top: calc(100% + 4px);
    left: 0;
    min-width: 100%;
    width: max-content;
    max-width: min(480px, 90vw);
    background-color: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
    overflow: hidden;
}

.picker-search {
    width: 100%;
    box-sizing: border-box;
    padding: 0.5rem 0.75rem;
    background-color: var(--color-bg-secondary);
    border: none;
    border-bottom: 1px solid var(--color-border);
    color: var(--color-text-primary);
    font-size: 0.9rem;
}

.picker-search:focus {
    outline: none;
    box-shadow: inset 0 -2px 0 var(--color-primary-light);
}

.picker-list {
    position: relative;
    overflow-y: auto;
}

.picker-list-spacer {
    position: relative;
}

.picker-option {
    position: absolute;
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    padding: 0 0.75rem;
    box-sizing: border-box;
    color: var(--color-text-primary);
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
}

.picker-option:hover,
.picker-option--active {
    background-color: var(--color-accent-soft);
}

.picker-option-check {
    width: 1.1rem;
    flex: 0 0 1.1rem;
    color: var(--color-primary-light);
    font-weight: 700;
}

.picker-option-label {
    overflow: hidden;
    text-overflow: ellipsis;
}

.picker-option--selected {
    color: var(--color-text-primary);
    font-weight: 600;
    background-color: var(--color-accent-soft);
    box-shadow: inset 3px 0 0 var(--color-primary-light);
}

.picker-list-status {
    padding: 0.5rem 0.75rem;
    color: var(--color-text-muted);
    font-size: 0.85rem;
}

/* Inline header stat (e.g. Last 24h PnL on the portfolio-selector line). */
.header-inline-stat {
    display: inline-flex;
    align-items: baseline;
    gap: 0.4rem;
    margin-left: auto;
}

.header-inline-stat .strip-label {
    font-size: 0.72rem;
}

.header-inline-stat .strip-value {
    font-size: 1rem;
}

/* Labeled metric groups: scan by category instead of hunting through a flat grid. */
.metric-section {
    margin-bottom: var(--space-3);
}

.metric-section-title {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--color-text-muted);
    margin: var(--space-4) 0 var(--space-2);
    padding-bottom: var(--space-1);
    border-bottom: 1px solid var(--color-border);
}

/* Pinned mini-summary strip (shown while a non-summary tab is active) */
.summary-strip {
    position: sticky;
    top: 0;
    z-index: 5; /* keep BELOW tooltips/toasts */
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-4);
    align-items: center;
    padding: var(--space-2) var(--space-3);
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-sm);
    margin-bottom: var(--space-4);
}

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

.strip-label {
    font-size: 0.7em;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--color-text-muted);
    white-space: nowrap;
}

.strip-value {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.strip-value--success { color: var(--color-success); }
.strip-value--warning { color: var(--color-warning); }
.strip-value--error { color: var(--color-error); }

/* Loading States */
.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    text-align: center;
}

/* The page-level #loading block (base.html) used to sit in normal flow at the END of <body>, so
   showLoading() during a submit drew a spinner at the bottom of the page — nowhere near the
   control that was busy. As a fixed overlay it reads as "the page is working". Hiding is the
   `.hidden` utility's job (display: none !important), which this rule never fights: it sets no
   display of its own. */
#loading.loading {
    position: fixed;
    inset: 0;
    z-index: 9998;
    margin: 0;
    background: rgba(10, 14, 20, 0.6);
    backdrop-filter: blur(1px);
}

.loading p {
    margin-top: 1rem;
    color: var(--color-text-muted);
}

/* Utility Classes */
.hidden {
    display: none !important;
}

.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

.text-left {
    text-align: left;
}

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }

/* Slider Input */
input[type="range"] {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: var(--color-bg-secondary);
    outline: none;
    -webkit-appearance: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--color-accent);
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: all 0.2s ease;
}

input[type="range"]::-webkit-slider-thumb:hover {
    background: var(--color-accent-hover);
    transform: scale(1.1);
}

input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--color-accent);
    cursor: pointer;
    border: none;
    box-shadow: var(--shadow-sm);
    transition: all 0.2s ease;
}

input[type="range"]::-moz-range-thumb:hover {
    background: var(--color-accent-hover);
    transform: scale(1.1);
}

/* Progress Indicators */
.progress-bar {
    width: 100%;
    height: 8px;
    background: var(--color-bg-secondary);
    border-radius: 4px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: var(--color-accent-gradient);
    transition: width 0.3s ease;
    border-radius: 4px;
}

/* Status Badges */
.badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.badge-success {
    background: var(--color-success-soft);
    color: var(--color-success);
    border: 1px solid var(--color-success);
}

.badge-warning {
    background: var(--color-warning-soft);
    color: var(--color-warning);
    border: 1px solid var(--color-warning);
}

.badge-error {
    background: var(--color-error-soft);
    color: var(--color-error);
    border: 1px solid var(--color-error);
}

.badge-info {
    background: var(--color-accent-soft);
    color: var(--color-accent-light);
    border: 1px solid var(--color-accent);
}

/* Horizontal-scroll container for a wide table. Was an inline
   `{ overflowX: 'auto', marginTop: '0.75rem' }` object retyped at six call sites, including inside
   common.js's own renderSimpleTable factory. */
.table-scroll {
    overflow-x: auto;
    margin-top: 0.75rem;
    /* The FRAME lives on the wrapper, not the table. A .dense-table is border-collapse: separate
       (sticky cells need it), and a separated table cannot clip its own rounded corners — so a
       radius set on the table left square corners under the header while the viewport-wrapped
       tables looked rounded. Framing the wrapper, which already clips, makes every table on the
       page carry the same outline and the same radius. */
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
}

/* ==========================================================================
   Dense operational grid (.dense-table)
   --------------------------------------------------------------------------
   The lender loan book is ~24 columns of numbers read side by side. The global `table` rule
   (1rem padding, 0.875rem uppercase headers) sizes a five-column summary table; applied to the
   book it produced ~64px rows, so eight loans filled a screen and comparing two of them meant
   scrolling. This variant trades padding for rows-on-screen:

     * the HEADER keeps its room (it is the column's only label, and it may wrap to two lines),
     * the BODY gives up padding and drops to 0.8rem, so a row is one line of text tall,
     * a verbose free-text cell is clamped by .cell-clamp rather than being allowed to set the
       height of the whole row.

   Nothing is hidden: every clamped or shortened cell carries its full value in `title`.
   ========================================================================== */
.dense-table {
    width: 100%;
    border-collapse: separate;   /* `separate` so a sticky <th> border does not scroll away */
    border-spacing: 0;
    background: var(--color-bg-card);
    /* The global `table` rule sets overflow:hidden for its rounded corners. That makes the table
       its own scroll container, which would anchor position:sticky to the table instead of to
       .table-viewport and break the sticky header. */
    overflow: visible;
    box-shadow: none;
    font-variant-numeric: tabular-nums;   /* digits line up column-wise while scanning */
}

.dense-table thead th {
    /* Sticky against .table-viewport. Needs its own opaque background: a `thead` background does
       not paint behind a sticky cell once the body scrolls under it. */
    position: sticky;
    top: 0;
    z-index: 3;
    padding: 0.5rem 0.5rem 0.45rem;
    background: var(--color-bg-dark);
    /* Two dividers, both earning their keep on a 23-column grid: a heavier rule under the whole
       header band so the labels read as a band rather than as a first row of data, and a hairline
       between columns so the eye can follow one column down without drifting into its neighbour. */
    border-bottom: 2px solid var(--color-border);
    border-right: 1px solid var(--color-border);
    color: var(--color-text-muted);
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.07em;
    text-align: left;
    text-transform: uppercase;
    /* One line, always. A header that wraps to two or three lines makes the header band taller than
       three body rows and turns the column labels into a ragged block that is harder to scan than
       a wide column is. The column widens to fit its label instead; the grid already scrolls
       horizontally under a frozen identity column. */
    white-space: nowrap;
    line-height: 1.2;
    vertical-align: bottom;
}

.dense-table td {
    padding: 0.28rem 0.5rem;
    border-top: 1px solid var(--color-border);
    /* Column divider. Deliberately fainter than the row rule: rows are the unit you compare, so
       the horizontal grid should stay dominant and the vertical one should only guide the eye. */
    border-right: 1px solid var(--color-border-subtle);
    font-size: 0.8rem;
    line-height: 1.3;
    vertical-align: middle;
    /* One line per value. The columns that legitimately need two (a value over its unit, a status
       over its message) are block-stacked or .cell-clamp'd, and both opt back into wrapping. */
    white-space: nowrap;
}

.dense-table thead th:last-child,
.dense-table tbody td:last-child {
    border-right: none;
}

.dense-table tbody tr:first-child td {
    border-top: none;
}

.dense-table tbody tr:hover {
    background: var(--color-bg-secondary);
}

.dense-table tbody tr.is-clickable {
    cursor: pointer;
}

/* Selected row: the lender's loan selection drives every per-loan tab, so it needs to be
   unmistakable after scrolling back to it — a tinted row plus an accent edge on the frozen
   column. */
.dense-table tbody tr.is-selected,
.dense-table tbody tr.is-selected:hover {
    background: var(--color-accent-soft);
}

/* Frozen identity column. Past the second column the borrower's name has scrolled out of view, and
   with it the only thing on the row that says WHICH loan these numbers belong to — on a risk grid
   that is the one cell that must never leave the screen.

   A sticky cell needs an OPAQUE background of its own (the rest of the row scrolls underneath it),
   so the row tints, which are translucent by design, are composited over an opaque base via a
   flat gradient layer rather than used directly. */
.dense-table th:first-child,
.dense-table td:first-child {
    position: sticky;
    left: 0;
    z-index: 2;
    background: var(--color-bg-card);
    /* Its edge is an inset shadow (a border would scroll out from under the sticky background),
       so the shared column divider is suppressed here to avoid a doubled line. */
    border-right: none;
    box-shadow: inset -1px 0 0 0 var(--color-border);
}

.dense-table thead th:first-child {
    /* Above both the sticky header row and the sticky column, since it is in both. */
    z-index: 4;
    background: var(--color-bg-dark);
}

.dense-table tbody tr:hover td:first-child {
    background: var(--color-bg-secondary);
}

.dense-table tbody tr.is-selected td:first-child,
.dense-table tbody tr.is-selected:hover td:first-child {
    background: linear-gradient(var(--color-accent-soft), var(--color-accent-soft)), var(--color-bg-card);
    box-shadow: inset 2px 0 0 0 var(--color-accent), inset -1px 0 0 0 var(--color-border);
}

/* Bounded scroll box for a long grid: a max-height plus the scroll container that
   `.dense-table thead th` sticks to, so the page stays one screen tall no matter how many
   rows the server returns. */
.table-viewport {
    max-height: min(62vh, 620px);
    overflow: auto;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
}

/* Inside a viewport the wrapper is the frame, so the table drops the global `table` rule's own
   border and corners rather than drawing a second one just inside the first. */
/* Both wrappers frame the table, so the table never draws its own border or corners. */
.table-scroll > .dense-table,
.table-viewport > .dense-table,
.table-scroll > .data-table,
.table-viewport > .data-table {
    border: none;
    border-radius: 0;
}

/* A .data-table can also be put in a bounded viewport (renderSimpleTable's `viewport` option), and
   a bounded box whose column labels scroll away is worse than an unbounded one. Same sticky
   treatment, same opaque header background, as .dense-table thead th. */
.table-viewport > .data-table {
    overflow: visible;
}

.table-viewport > .data-table thead th {
    position: sticky;
    top: 0;
    z-index: 3;
    background: var(--color-bg-dark);
}

/* Free-text cell content in a dense grid (a workflow message, a venue list): clamped to two lines
   so one verbose row cannot triple the height of every row. The untruncated string is always in the
   enclosing cell's title attribute.
                                                                             ↓ read this before use
   NEVER put this class on a <td> or <th>. `display: -webkit-box` overrides `display: table-cell`,
   so the cell leaves the table's column grid entirely and every column to its right renders one
   slot left, under the wrong header. Always apply it to a wrapper INSIDE the cell — renderTable's
   `clamp: true` column flag does exactly that, and exists so no call site has to remember. */
.cell-clamp {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    overflow: hidden;
    max-width: 15rem;
    /* The enclosing td is nowrap so rows stay one line; clamped text is the exception that wraps. */
    white-space: normal;
}

/* LTV cell: wide enough for its threshold meter to be readable rather than a 2mm stub. */
.cell-ltv {
    min-width: 9rem;
}

/* Error-toned secondary line (a failed workflow's message under its status chip). */
.cell-subtext--error {
    color: var(--color-error);
    font-weight: 600;
}

/* Address / hash cell: shortened monospace text plus a copy glyph, the whole thing clickable.
   The glyph is the affordance — a shortened address with no icon reads as truncated data rather
   than as something you can take with you, and the full value only lives in the title. */
.cell-address {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    cursor: pointer;
    color: var(--color-text-muted);
    white-space: nowrap;
}

.cell-mono {
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', monospace;
    font-size: 0.72rem;
    letter-spacing: -0.01em;
    white-space: nowrap;
}

.cell-copy-icon {
    flex: 0 0 auto;
    width: 0.78rem;
    height: 0.78rem;
    opacity: 0.55;
    transition: opacity var(--transition-fast);
}

.cell-address:hover,
.cell-address:focus-visible {
    color: var(--color-accent-light);
}

.cell-address:hover .cell-copy-icon,
.cell-address:focus-visible .cell-copy-icon {
    opacity: 1;
}

/* Action cell (the loan book's Collect button). The button IS the cell's content, so the cell must
   not also reserve a text line box around it: an inline-flex button sitting on a text baseline left
   a descender's worth of dead space under the header row and above the next row's border, which
   read as a gap between the Collect header and its first button. */
.cell-action {
    line-height: 0;
    white-space: nowrap;
}

.cell-action .btn {
    line-height: 1.2;
    vertical-align: middle;
}

/* Secondary line under a cell's primary value (a status word under a percentage, a USD
   equivalent under a token amount). Was an inline three-property object at every call site. */
.cell-subtext {
    color: var(--color-text-muted);
    font-size: 0.72rem;
    line-height: 1.2;
    margin-top: 0.1rem;
}

/* One row of page controls: a label, its picker, and a hint. Used by the lender loan selector and
   its status filter; keep new control rows on this class rather than retyping the flex object. */
.control-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 0.6rem;
}

/* A tab body's opening heading line: the tab's name, plus any controls that belong to that tab on
   the right (the loan book's status chips). ONE class for every tab in the dashboard, so they all
   open at the same rhythm — Summary used to run its heading straight into the first card row while
   Loans had a note's worth of air under its own. Anything added here applies to future tabs for
   free, which is the point. */
.tab-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
    margin: 0 0 var(--space-4);
}

.tab-heading h3 {
    margin: 0;
}

/* A note directly under a tab heading is the heading's own subtitle, so it tightens up against it
   rather than adding a second full gap. */
.tab-heading + .page-note {
    margin-top: calc(var(--space-4) * -1 + 0.35rem);
}

/* A row of small side-by-side panels (the Exchange Risk tab's term-version notice, risk drivers and
   hedge-control panels). They used to be three full-width stacked boxes, each with its own
   hand-rolled border, which pushed the tables that matter a screen and a half down the page.

   auto-fit rather than a fixed three columns on purpose: two of the three are CONDITIONAL, so a
   fixed grid would leave holes whenever a loan has no term-version problem or no risk drivers.
   Whichever panels exist share the width evenly and drop to one column when there is no room. */
.panel-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: var(--space-3);
    /* STRETCH, not start: `align-items: start` sized each panel to its own content, so a row of
       three read as three unrelated boxes at three different heights. Equal height is what makes
       them a row. */
    align-items: stretch;
    margin-top: var(--space-3);
}

/* A compact titled panel: the small-print sibling of .card, for a named block of supporting detail
   next to others of its kind. Replaces four hand-rolled inline boxes on the lender page that each
   picked their own padding, radius and border colour. */
.mini-panel {
    /* Column flex so a panel can push its action row to the bottom edge — with equal-height
       panels, buttons that sit right under uneven content look misaligned across the row. */
    display: flex;
    flex-direction: column;
    padding: 0.6rem 0.7rem;
    border: 1px solid var(--color-border-subtle);
    border-radius: var(--radius-sm);
    background: var(--color-bg-secondary);
    font-size: 0.8rem;
    line-height: 1.4;
}

/* Pinned to the panel's bottom, so every panel in a row lines its controls up on one baseline. */
.mini-panel-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-top: auto;
    padding-top: 0.6rem;
}

/* Equal widths, so a row of panels shows one tidy pair of buttons per panel rather than two
   different-width buttons starting at the same left edge under content of differing lengths. */
.mini-panel-actions .btn {
    flex: 1 1 0;
    min-width: 0;
    justify-content: center;
}

.mini-panel-title {
    display: block;
    margin-bottom: 0.3rem;
    color: var(--color-text-primary);
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

/* Body lines inside a mini panel: label-ish detail rows that should not each carry their own
   inline colour and margin. */
.mini-panel-line {
    color: var(--color-text-muted);
    margin: 0.2rem 0 0;
}

.mini-panel-line--warning { color: var(--color-warning); }
.mini-panel-line--error { color: var(--color-error); font-weight: 600; }

/* A .callout sharing a panel row adopts the mini-panel's density: the grid supplies the gap, and a
   1rem callout beside a 0.8rem panel makes the row read as two different components. */
.panel-row > .callout,
.panel-row > .mini-panel {
    margin-top: 0;
}

.panel-row > .callout {
    padding: 0.6rem 0.7rem;
    font-size: 0.8rem;
}

.panel-row > .callout > strong {
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

/* Sentence case for the grey second line inside a table cell, in CSS so none of the ~20 call sites
   that build these strings has to remember it — and so the payload text is untouched. `.num-subtext`
   is the shared risk panels' version, `.cell-subtext` the dense tables' (metricStack),
   `.metric-subtext` the stat cards' (renderMetricCard) — the history tiles' lowercase footnotes
   were the last assembled strings left uncapitalised. */
.num-subtext::first-letter,
.cell-subtext::first-letter,
.metric-subtext::first-letter,
/* "transfer block @ 75.00%" under a progress bar, and the "portfolio (lender haircut): …" basis
   lines in the Breach Scope column — both are assembled from rung `label` fields, so the casing
   belongs here rather than at each of the ~10 places that name a rung. */
.threshold-meter-caption::first-letter,
.basis-line::first-letter {
    text-transform: uppercase;
}

/* One "basis: status (leverage vs rung)" line in the Breach Scope column. Was an inline
   two-property object at four call sites. */
.basis-line {
    font-size: 0.72rem;
    line-height: 1.3;
}

/* Header line of a shared risk panel: its name plus the legends that explain how to read it. */
.panel-head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.35rem 0.6rem;
}

.panel-legend {
    color: var(--color-text-muted);
    font-size: 0.72rem;
}

/* A column header's qualifier: the small second line under the name that says WHICH basis the
   column is measured on ("hedge-adj", "raw, hard cap"). These used to be part of the label text and
   were moved into the header's `title`, which made an enforcement semantic hover-only — the
   difference between a limit that binds and one that does not, discoverable only with a mouse. */
.th-qualifier {
    display: block;
    margin-top: 0.1rem;
    color: var(--color-text-muted);
    font-size: 0.68rem;
    font-weight: 400;
    letter-spacing: 0.02em;
    text-transform: none;
    white-space: nowrap;
}

/* Compact analytics table used by the shared risk panels (leverage-by-basis, venue actions).
   It was only ever defined inside two page <style> blocks — stress_test.html and
   liquidation_guide_content.html — so on the lender dashboard the class matched NOTHING and the
   table fell through to the global `table` rule: 1rem padding and uppercase 0.875rem headers. That
   is why it read loose next to the dense tables around it. Defined here, it is tight everywhere;
   the two page blocks still win on their own pages (same specificity, later in document order)
   until those pages get their own pass. */
.guide-table {
    width: 100%;
    /* `separate` with zero spacing so the rounded corners actually clip, and so this table carries
       the same visible outline as every other table on the page — it had none at all. */
    border-collapse: separate;
    border-spacing: 0;
    overflow: hidden;
    background: var(--color-bg-card);
    box-shadow: none;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-variant-numeric: tabular-nums;
}

.guide-table th,
.guide-table td {
    padding: 0.3rem 0.45rem;
    text-align: left;
    /* Top borders, not bottom: a bottom border on the last row would sit on the table's own frame
       and read as a double line inside the rounded corner. */
    border-top: 1px solid var(--color-border-subtle);
    vertical-align: top;
    line-height: 1.3;
}

.guide-table thead th {
    border-top: none;
}

.guide-table tbody tr:first-child td {
    border-top: none;
}

.guide-table thead th {
    background: var(--color-bg-dark);
    border-bottom: 2px solid var(--color-border);
    border-top: none;
    color: var(--color-text-muted);
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    /* Headers WRAP. Several guide tables are table-layout:fixed (the per-venue shock table), where
       a nowrap header wider than its column paints over the neighbouring label ("VENUE LEVERAGE
       VENUE MM USAGE") instead of expanding it. */
}

/* Numeric cells are right-aligned and tabular, but they too must WRAP: with table-layout:fixed an
   overflowing cell draws on top of its neighbour rather than widening the column. The VALUE itself
   still never breaks mid-number — that is what .num-value is for; only label/subtext wraps. */
.guide-table td.num,
.guide-table th.num {
    text-align: right;
}

.guide-table td.num .num-value {
    white-space: nowrap;
}

/* Wrap at word boundaries first; break INSIDE a word only when a single word genuinely cannot fit
   (hyphen-less mid-word splits turned headers into "VENU / E MM / USE"). */
.guide-table th,
.guide-table td {
    overflow-wrap: break-word;
    word-break: normal;
    hyphens: none;
}

/* The per-figure explanation under a number ("reduction aims at 4.25x (15% below the rung)"). It is
   the longest text in the table, so it is the thing that has to give. */
.guide-table .num-subtext {
    display: block;
    color: var(--color-text-muted);
    font-size: 0.68rem;
    line-height: 1.25;
    white-space: normal;
}

/* The rung cell of the per-venue shock table stacks its two bases on labelled lines, so neither
   can wrap into the other ("venue basis: normal" / "lender basis: warning"). */
.guide-table .rung-line {
    display: flex;
    gap: 0.35rem;
    align-items: baseline;
    line-height: 1.3;
}

.guide-table .rung-label {
    color: var(--color-text-muted);
    font-size: 0.72rem;
    min-width: 3.4rem;
}

.guide-table .rung-value {
    font-weight: 600;
}

.guide-table .rung-was {
    font-size: 0.72rem;
    margin-left: 3.8rem;
}

/* ==========================================================================
   Liquidation guide (shared: the standalone /gui/liquidation-guide/ page and the Risk Analytics
   "Liquidation guide" tab). Moved here from a <style> block inside
   includes/liquidation_guide_content.html — which also carried its own duplicate of .guide-table —
   so the guide and the risk pages carry one look and one source of truth.
   ========================================================================== */
ul.guide-list {
    margin: 0.4rem 0 0.4rem 1.1rem;
}

ul.guide-list li {
    margin-bottom: 0.3rem;
}

/* Documentation layout: a sticky "On this page" nav beside a capped reading column, centred as
   one unit. A document reads at a measure, not at 1600px — and the nav earns the leftover width
   instead of leaving it empty. Applies to the standalone page and the Risk Analytics tab. */
.guide-layout {
    display: grid;
    grid-template-columns: 13rem minmax(0, 56rem);
    gap: 0 2.5rem;
    justify-content: center;
    align-items: start;
}

.guide-main {
    min-width: 0;
    /* Its own scroll area: the contents links on the left scroll the guide, not the page
       (guideWireToc). position: relative makes it the offsetParent the scroll maths reads. */
    position: relative;
    max-height: calc(100vh - 7rem);
    overflow-y: auto;
    padding-right: 0.75rem;
    overscroll-behavior: contain;
}

.guide-toc {
    position: sticky;
    top: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    margin: 0.35rem 0 0;
}

.guide-toc-label {
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--color-text-muted);
    padding: 0 0.75rem 0.35rem;
}

/* Nav rail entries: a quiet left rule that lights up on hover, not chips — nine bordered boxes
   read as controls and shouted over the content they point at. */
.guide-toc a {
    font-size: 0.85rem;
    padding: 0.25rem 0.75rem;
    border-left: 2px solid var(--color-border);
    color: var(--color-text-muted);
    text-decoration: none;
}

.guide-toc a:hover {
    color: var(--color-accent-light);
    border-left-color: var(--color-accent-light);
}

/* Narrow screens: no room for a rail — the same links become a wrapped chip row above the text. */
@media (max-width: 960px) {
    .guide-layout {
        display: block;
    }

    .guide-main {
        max-height: none;
        overflow-y: visible;
        padding-right: 0;
    }

    .guide-toc {
        position: static;
        flex-direction: row;
        flex-wrap: wrap;
        gap: 0.5rem;
        margin: 0.75rem 0 1.25rem;
    }

    .guide-toc-label {
        display: none;
    }

    .guide-toc a {
        padding: 0.2rem 0.6rem;
        border: 1px solid var(--color-border);
        border-radius: var(--radius-sm);
    }

    .guide-toc a:hover {
        border-color: var(--color-accent-light);
    }
}

.guide-section {
    margin-bottom: 1rem;
}

/* Rung/step/basis label columns never break mid-word ("3. Reduction" wrapped its own name onto a
   second line); on small screens the room is not there, so they wrap again rather than overflow. */
.guide-table th:first-child,
.guide-table td:first-child {
    white-space: nowrap;
}

@media (max-width: 640px) {
    .guide-table th:first-child,
    .guide-table td:first-child {
        white-space: normal;
    }
}

/* One shock axis per row of the loan-shock matrix, on fixed grid tracks: include-checkbox, name,
   where-it-sits, slider, drawdown value, distance-checkbox. The flex version wrapped each row at
   its own width, so where the slider landed depended on that asset's holdings text. */
.shock-axis-row {
    display: grid;
    grid-template-columns: auto minmax(4.5rem, auto) minmax(0, 1fr) minmax(7rem, 11rem) 3.2rem auto;
    align-items: center;
    gap: 0.6rem;
    padding: 0.35rem 0;
    border-bottom: 1px solid var(--color-border-subtle);
}

.shock-axis-row--head {
    border-bottom: 1px solid var(--color-border);
    padding-bottom: 0.5rem;
    margin-bottom: 0.25rem;
}

.shock-axis-name {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.85rem;
    font-weight: 600;
}

/* The all-selected label spans the name + holdings columns so its slider lands in the same
   column as the per-asset sliders below it. */
.shock-axis-name--wide {
    grid-column: 2 / 4;
}

.shock-axis-holdings {
    font-size: 0.75rem;
    min-width: 0;
}

.shock-axis-row .shock-value {
    text-align: right;
}

.guide-section h2 {
    margin-top: 0;
}

/* --color-text does not exist in this file; the text colour variable is --color-text-primary.
   The old local rule quoted the non-existent name, so the lead paragraph silently inherited. */
.guide-lead {
    font-size: 1rem;
    color: var(--color-text-primary);
}

.guide-note {
    font-size: 0.85rem;
    color: var(--color-text-muted);
}

.guide-callout {
    border-left: 3px solid var(--color-accent-light);
    padding: 0.5rem 0.85rem;
    margin: 0.75rem 0;
    background: var(--color-accent-soft);
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

.guide-callout.warn {
    border-left-color: var(--color-warning);
    background: var(--color-warning-soft);
}

.guide-never {
    border-left: 3px solid var(--color-success);
    padding: 0.5rem 0.85rem;
    margin: 0.75rem 0;
    background: var(--color-success-soft);
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

/* Rung words in the guide's ladder table — the colour is the datum (severity). */
.rung-warning { color: var(--color-warning); }
.rung-stop { color: var(--color-error); }

/* Frozen-term tag (YOUR TERMS / DEFAULT), shared by the guide's ladder tables and the shock tool's
   distance panel. A DEFAULT standing in for an unfrozen rung must never look like the borrower's
   own number, so the fallback variant drops the accent. */
.frozen-tag {
    display: inline-block;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    padding: 0 0.3rem;
    border-radius: 3px;
    border: 1px solid var(--color-accent-light);
    color: var(--color-accent-light);
    margin-left: 0.3rem;
}

.frozen-tag.fallback {
    border-color: var(--color-border);
    color: var(--color-text-muted);
}

/* Sub-section heading inside a tab body (the Exchange Risk tab's three tables). Same visual weight
   as .metric-section-title so a table's name and a card group's name read as the same rank. */
.subsection-title {
    margin: var(--space-4) 0 var(--space-2);
    padding-bottom: var(--space-1);
    border-bottom: 1px solid var(--color-border);
    color: var(--color-text-muted);
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

/* Quiet meta line of identifiers a lender copies (loan id, vault address). */
.entity-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.25rem 0.75rem;
    margin: 0 0 var(--space-3);
    color: var(--color-text-muted);
    font-size: 0.75rem;
}

/* On a .tab-heading row it is a sibling of the heading, so it drops the block margin and hugs the
   right edge. */
.entity-meta--inline {
    margin: 0;
    justify-content: flex-end;
}

/* The identifiers are the point of this line — the words "Loan" and "Vault" are just labels — so
   the values sit a step larger and in the primary text colour. */
.entity-meta .cell-address {
    color: var(--color-text-primary);
}

.entity-meta .cell-mono {
    font-size: 0.85rem;
}

.entity-meta .cell-copy-icon {
    width: 0.85rem;
    height: 0.85rem;
}

/* A wrapping strip of state badges. Distinct from .control-row, which is a page-level row of
   controls and carries its own bottom spacing. */
.chip-strip {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.3rem;
}

/* Whitelist venue panel: its state badges keep the fully-rounded pill shape. */
.whitelist-venue .status-chip {
    border-radius: 999px;
    padding: 0 0.5rem;
}

/* A panel's own title line, ruled off from the body under it. The whitelist's venue name had the
   state badges inline beside it, so a venue with three badges wrapped its own name mid-panel. */
.mini-panel-heading {
    display: block;
    margin-bottom: 0.4rem;
    padding-bottom: 0.35rem;
    border-bottom: 1px solid var(--color-border);
    color: var(--color-text-primary);
    font-size: 0.85rem;
    font-weight: 600;
}

/* Inside a .mini-panel the accordion is the panel's own body, so it drops the standalone card
   treatment it uses elsewhere and just becomes a disclosure line. */
.mini-panel .accordion {
    margin-top: 0.4rem;
    border: none;
    border-radius: 0;
    background: transparent;
}

.mini-panel .accordion-summary {
    padding: 0.25rem 0;
    font-size: 0.8rem;
}

.mini-panel .accordion-body {
    padding: 0 0 0.25rem;
    border-top: none;
}

.symbol-browser-search {
    width: 100%;
    margin-bottom: 0.6rem;
    padding: 0.4rem 0.6rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-bg-secondary);
    color: var(--color-text-primary);
    font-size: 0.85rem;
}

.symbol-browser-search:focus {
    outline: none;
    border-color: var(--color-border-focus);
}

/* The list scrolls inside the modal rather than growing it, so the search box and the footer note
   stay put while you page through ninety symbols.
   Its HEIGHT IS FIXED at open time (openSymbolWhitelistBrowser sets it inline from the unfiltered
   list, capped): the dialog is centred with `margin: auto`, so a list that shrinks as you type
   re-centres the whole modal and it jumps around under the pointer. */
.symbol-browser-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    align-content: start;
    gap: 0.3rem;
    max-height: min(46vh, 380px);
    overflow-y: auto;
    padding: 0.1rem;
}

/* "91 allowed symbol(s) · 6 lender-added   [View symbols]" — one row, because the button acts on
   exactly the thing the text is counting. */
.whitelist-count-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.4rem 0.75rem;
    margin-top: 0.55rem;
}

.symbol-browser-count {
    margin-bottom: 0.5rem;
    color: var(--color-text-muted);
    font-size: 0.8rem;
}

.symbol-browser-empty {
    padding: 0.75rem 0;
    color: var(--color-text-muted);
    font-size: 0.8rem;
}

/* In the browser a chip is a row in a grid, so it fills its cell and its remove control sits at the
   right edge — ragged-width chips in a grid read as broken. */
.symbol-browser-list .symbol-chip {
    justify-content: space-between;
    padding: 0.2rem 0.45rem;
}

/* Symbol whitelist chips. Was an eight-property inline style object rebuilt per symbol, per venue,
   on every poll. */
.symbol-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.1rem 0.4rem;
    border: 1px solid var(--color-border);
    border-radius: 4px;
    background: var(--color-bg-primary);
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', monospace;
    font-size: 0.72rem;
}

.symbol-chip-added {
    color: var(--color-accent-light);
    font-weight: 700;
}

.symbol-chip-remove {
    cursor: pointer;
    color: var(--color-text-muted);
    font-weight: 700;
    line-height: 1;
}

.symbol-chip-remove:hover {
    color: var(--color-error);
}

.symbol-chip-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    margin-top: 0.4rem;
}

/* Heading line that carries controls on its right (a section title + its filter). */
.control-row--split {
    justify-content: space-between;
    gap: 0.75rem;
}

/* A heading placed on a control row supplies the row's spacing, not its own. */
.control-row h3,
.control-row h4 {
    margin: 0;
}

.control-row-label {
    color: var(--color-text-muted);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

/* Quiet one-line hint beside a control (what the control drives). The long form lives in the
   adjacent ⓘ tooltip. */
.control-row-hint {
    color: var(--color-text-muted);
    font-size: 0.8rem;
}

/* Separator above a subsection inside a card (a rule plus the matching space). Was an inline
   three-property object retyped at four call sites across the loan pages and their includes. */
.section-divider {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--color-border);
}

/* Hedge-state pill (includes/borrowed_asset_hedge.js.html). An outlined chip whose border and text
   colour are the hedge severity, set inline because the colour IS the datum. Geometry lives here
   because both loan pages had retyped these six declarations at every call site. */
.hedge-pill {
    /* Same box as .status-chip (one chip family, docs/ui-design-standard.md §7): soft fill from
       the inline colour, 4px radius — it was an outlined 999px pill, a second chip dialect. */
    display: inline-block;
    border-radius: 4px;
    padding: 0.12rem 0.55rem;
    background: rgba(148, 163, 184, 0.14);
    background: color-mix(in srgb, currentColor 15%, transparent);
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1.45;
    white-space: nowrap;
}

.hedge-pill-row {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    margin-top: 0.4rem;
}

/* Neutral/inactive badge: a state with no verdict attached (a deactivated API token, an
   unrecognised status). Deliberately muted — never a colour that implies good or bad. */
.badge-muted {
    background: rgba(148, 163, 184, 0.18);
    color: var(--color-text-muted);
    border: 1px solid var(--color-text-muted);
}

.badge-processing {
    background: var(--color-info-soft);
    color: var(--color-info);
    border: 1px solid var(--color-info);
}

/* Account Link Styling */
.account-link {
    color: var(--color-accent);
    text-decoration: none;
    display: inline-block;
    transition: color 0.2s ease;
}

.account-link:hover {
    color: var(--color-accent-light);
    text-decoration: underline;
}

/* Small staff-only admin hop beside exchange-account labels in shared tables. Keep its density
   in the design system so the borrower/lender account renderers do not hand-roll spacing. */
.exchange-account-admin-link {
    margin-left: 0.45rem;
    font-size: 0.78em;
}

.account-address {
    color: var(--color-accent);
    text-decoration: underline;
    cursor: pointer;
    font-size: 0.9em;
    word-break: break-all;
    display: inline-block;
    max-width: 100%;
    background-color: transparent;
    padding: 0;
}

.account-link-hint {
    color: var(--color-text-muted);
    font-size: 0.85rem;
}

/* Balance Info Styling */
.balance-info {
    margin-bottom: 0.5rem;
    padding: 0.75rem;
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border);
    border-radius: 6px;
    color: var(--color-text-primary);
}

.balance-info strong {
    color: var(--color-text-secondary);
}

.balance-info-text {
    color: var(--color-text-muted);
    display: block;
    margin-top: 0.25rem;
    font-size: 0.85rem;
}

/* Address Display Styling */
.address-display {
    background: var(--color-bg-secondary);
    color: var(--color-text-primary);
    padding: 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    display: block;
    margin-top: 0.5rem;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', monospace;
    font-size: 0.9em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    word-break: break-all;
    transition: border-color 0.2s ease, background-color 0.2s ease;
}

.address-display:hover {
    border-color: var(--color-accent);
    background: var(--color-bg-card);
}

/* Modal dialogs (shared UI primitive — see ui.js showModal) */
.modal {
    background: var(--color-bg-card);
    color: var(--color-text-primary);
    /* Center explicitly: the global * { margin: 0 } reset wipes the UA stylesheet's
       margin:auto that would otherwise center a <dialog> in the top layer. */
    position: fixed;
    inset: 0;
    margin: auto;
    height: fit-content;
    max-height: calc(100vh - 4rem);
    overflow-y: auto;
    /* Override the UA <dialog> border/padding with the theme's card styling. */
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    padding: 1.5rem;
    max-width: 480px;
    width: calc(100% - 2rem);
    animation: modal-pop-in 0.16s ease-out;
}

@keyframes modal-pop-in {
    from {
        opacity: 0;
        transform: scale(0.97) translateY(-6px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* Wide variant, for content that needs the room (a filtered grid of ~90 symbol chips reads far
   better in three columns than in one tall one).
   COMPOUND selector, and placed after `.modal` on purpose: as a bare `.modal--wide` 250 lines
   earlier it tied with `.modal` on specificity and lost on source order, so every "wide" dialog
   silently rendered at 480px. */
.modal.modal--wide {
    max-width: 680px;
}

.modal::backdrop {
    background: rgba(10, 14, 20, 0.7);
}

/* Fallback centering for browsers without <dialog>.showModal() support. */
.modal--fallback {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 10000;
}

.modal-title {
    margin-bottom: 0.75rem;
}

.modal-body {
    color: var(--color-text-muted);
    margin-bottom: 1rem;
    /* Messages migrated from confirm() contain \n\n paragraph breaks — preserve them. */
    white-space: pre-line;
}

.modal-form {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.modal-field {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.modal-field-label {
    font-weight: 600;
    color: var(--color-text-secondary);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.modal-field input,
.modal-field textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    font-size: 1rem;
    transition: all 0.2s ease;
    background-color: var(--color-bg-secondary);
    color: var(--color-text-primary);
}

.modal-field input:focus,
.modal-field textarea:focus {
    outline: none;
    border-color: var(--color-border-focus);
    box-shadow: 0 0 0 3px var(--color-accent-soft);
}

.modal-field-error {
    color: var(--color-error);
    font-size: 0.85rem;
    min-height: 1em;
}

.modal-footer {
    display: flex;
    gap: var(--space-2);
    justify-content: flex-end;
    align-items: center;
    margin-top: var(--space-4);
}

/* Modal buttons are sized HERE, not left to the base .btn. A dialog footer inherited the full-size
   button — 0.75rem/1.5rem at 1rem with the accent glow — so a one-word "Close" came out as a slab
   wider than the sentence above it. One size for every modal in the app, a shared min-width so a
   Cancel/Confirm pair is balanced and a lone Close is not a stub, and no glow: inside a dialog the
   button is already the only thing to press. */
.modal-footer .btn {
    padding: 0.45rem 1rem;
    min-width: 5.5rem;
    font-size: 0.85rem;
    font-weight: 500;
}

/* Exchanges → Scheduled / Planner / Transfers (CJ-13009/13010) on the shared vocabulary: panels are
   .data-panel, notices .callout, states .status-chip. What follows is only the layout these
   surfaces need on top of that. */
.schedule-summary-body {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    font-size: 0.85rem;
}

.schedule-summary-line {
    margin: 0;
    font-size: 0.85rem;
}

.schedule-summary-label {
    color: var(--color-text-muted);
    white-space: pre;
}

.schedule-summary-guardrails {
    grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
}

.schedule-subtabs {
    margin-top: 1rem;
}

.schedule-target-cell {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.15rem;
}

.schedule-target-cell-now {
    margin-top: 0;
    font-size: 0.75rem;
}

.allocation-card-meta {
    gap: 0.75rem;
    font-size: 0.8rem;
    color: var(--color-text-muted);
    white-space: nowrap;
}

.allocation-card-total {
    font-weight: 600;
    color: var(--color-text-secondary);
}

.allocation-group-usd {
    margin: 0.4rem 0 -0.2rem;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--color-text-secondary);
}

/* The % / quantity target inputs with their "Now …" hint under them (Planner + Scheduled grids). */
.target-input-stack {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.target-input-hint {
    color: var(--color-text-muted);
    font-size: 0.72rem;
}

/* The recipients picker sits on its panel body's own padding. */
.schedule-notify {
    margin: 0;
}

.summary-strip.schedule-facts {
    position: static;
    margin-bottom: 0;
    box-shadow: none;
}

/* A text-link BUTTON in a strip or panel head ("View →", "View allocation →"): the link look, not
   the button chrome. */
.schedule-facts button.card-header-link,
.data-panel-head-meta button.card-header-link {
    margin-left: 0;
    background: transparent;
    font: inherit;
    font-size: 0.8rem;
    cursor: pointer;
}

.schedule-facts button.card-header-link {
    align-self: flex-start;
}

.schedule-facts button.card-header-link:hover,
.data-panel-head-meta button.card-header-link:hover {
    background: var(--color-accent-soft);
}

/* Card-header action link (e.g. Transfers → "Open allocation planner"): a quiet
   pill, not a raw browser-blue anchor.

   `display: inline-block` is load-bearing: vertical padding on an `inline` box does not grow the
   line box, so inside the h3's 1.2 line-height the pill overflowed 2.2px below its heading and drew
   over the Transfers tab strip. vertical-align centres it on the heading text. */
.card-header-link {
    display: inline-block;
    vertical-align: middle;
    font-size: 0.8rem;
    font-weight: 500;
    margin-left: 0.75rem;
    padding: 0.2rem 0.6rem;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    color: var(--color-accent);
    text-decoration: none;
    white-space: nowrap;
    transition: background 0.15s ease, border-color 0.15s ease;
}
.card-header-link:hover {
    background: var(--color-accent-soft);
    border-color: var(--color-accent);
    color: var(--color-accent);
    text-decoration: none;
}

/* Inline link inside running text. There is no global `a` colour here, so an unclassed content
   anchor inherits the browser default #0000EE — 1.97:1 against this dark background, i.e. invisible.
   --color-info is 8.11:1 and already the product's "go read this other page" colour. Keep the
   underline: colour alone is not an accessible affordance for a link in prose. */
.inline-link {
    color: var(--color-info);
    text-decoration: underline;
    text-underline-offset: 0.15em;
    font-weight: 500;
}

.inline-link:hover {
    color: var(--color-info-hover);
    text-decoration-thickness: 2px;
}

.inline-link:focus-visible {
    outline: 2px solid var(--color-border-focus);
    outline-offset: 2px;
}

/* .inline-link on a <button> (the event filter's Clear): strip the UA button chrome so it reads
   as the same inline link the anchors do. */
button.inline-link {
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    font-size: 0.8rem;
}

/* Inline action error (surfaced next to a button by runAction) */
.action-error {
    color: var(--color-error);
    font-size: 0.85rem;
    margin-top: var(--space-1);
}

/* Shared component classes (extracted from common.js inline styles) */

/* renderTooltipIcon: "i" badge + hover/focus bubble */
.tooltip-icon {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1rem;
    height: 1rem;
    margin-left: 0.3rem;
    border: 1px solid var(--color-info);
    border-radius: 50%;
    /* Pointer, not `help`: renderTooltipIcon latches the bubble open on click, so the badge is a
       control. A help cursor advertised something the badge does not do. */
    cursor: pointer;
    color: var(--color-info);
    font-size: 0.72rem;
    font-weight: 700;
    line-height: 1;
}

.tooltip-bubble {
    /* Base hidden state — renderTooltipIcon toggles this via inline bubble.style.display on
       click (_wireClickDisclosure); inline style always wins over this class rule. */
    display: none;
    /* fixed + JS placement (positionTooltipBubble): escapes overflow-clipping ancestors
       such as .table-scroll and is clamped inside the viewport. */
    position: fixed;
    z-index: 1000;
    top: 0;
    left: 0;
    width: min(280px, 70vw);
    /* Never taller than the viewport (minus positionTooltipBubble's 16px margins): a tall
       tooltip scrolls inside the bubble instead of running off-screen. */
    max-height: calc(100vh - 32px);
    overflow-y: auto;
    padding: 0.55rem 0.65rem;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    background: var(--color-bg-primary);
    color: var(--color-text-primary);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
    font-size: 0.8rem;
    font-weight: 400;
    line-height: 1.35;
    text-align: left;
    /* The bubble lives INSIDE the label it explains, so it inherits that label's typography: on
       the compact strip that is UPPERCASE + nowrap + letter-spacing, which set the whole
       explanation in capitals on one unbreakable line. Reset to body prose regardless of host. */
    text-transform: none;
    white-space: normal;
    letter-spacing: normal;
    overflow-wrap: anywhere;
}

/* A formula tooltip carries an inputs grid and an equation line — more room than a sentence. */
.tooltip-bubble--wide {
    width: min(360px, 84vw);
}

/* renderFormulaTip: what the figure is → the live inputs → "Calculation" → the equation. The
   inputs sit in their own inset so the numbers line up and read as the operands of the equation
   under them, the way an exchange's margin tooltip lays out equity / margin / ratio. */
.formula-tip {
    display: grid;
    gap: 0.4rem;
}

.formula-tip-what {
    line-height: 1.4;
}

.formula-tip-inputs {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0.2rem 0.75rem;
    padding: 0.4rem 0.55rem;
    border: 1px solid var(--color-border-subtle);
    border-radius: 4px;
    background: var(--color-bg-secondary);
}

.formula-tip-input-label {
    color: var(--color-text-muted);
}

.formula-tip-input-value {
    text-align: right;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    color: var(--color-text-primary);
}

.formula-tip-heading {
    margin-top: 0.1rem;
    color: var(--color-text-muted);
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.formula-tip-formula {
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', monospace;
    font-size: 0.72rem;
    line-height: 1.45;
    color: var(--color-text-primary);
}

.formula-tip-note {
    color: var(--color-text-muted);
    font-size: 0.72rem;
    line-height: 1.35;
}

/* createAccordionSection */
.accordion {
    margin-top: 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    background: var(--color-bg-secondary);
    overflow: hidden;
}

.accordion-summary {
    cursor: pointer;
    padding: 0.75rem;
    list-style: none;
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0.75rem;
    align-items: center;
}

.accordion-subtitle {
    color: var(--color-text-muted);
    font-size: 0.8rem;
    margin-top: 0.2rem;
}

.accordion-badge {
    color: var(--color-text-muted);
    font-size: 0.8rem;
    text-align: right;
}

.accordion-body {
    padding: 0 0.75rem 0.75rem;
    border-top: 1px solid var(--color-border);
}

/* Section-heading variant of the accordion: the summary reads exactly like a .subsection-title
   ("Exchange Risk Parameters" above it — same size, weight, casing, letter-spacing and bottom rule)
   plus a caret, so an openable section and a plain one are visibly the same rank of thing. Used by
   the terms block's three collapsed term families, which were reading as three cards dropped inside
   a panel that was already a card.

   Keep the .subsection-title numbers below in step with that rule: they are quoting it. */
.accordion--subsection {
    margin-top: var(--space-4);
    border: none;
    border-radius: 0;
    background: none;
    /* .accordion sets overflow:hidden for its rounded corners. Without a frame there are no corners
       to clip, and hidden would clip a tooltip bubble opened from a cell inside the body. */
    overflow: visible;
}

.accordion--subsection > .accordion-summary {
    /* Three tracks: caret, title, badge. The base rule is `1fr auto`, and the caret is a grid item
       (it comes from ::before), so it needs a track of its own or it lands on top of the title. */
    grid-template-columns: auto 1fr auto;
    gap: 0.4rem;
    padding: 0 0 var(--space-1);
    border-bottom: 1px solid var(--color-border);
}

.accordion--subsection > .accordion-summary strong {
    color: var(--color-text-muted);
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.accordion--subsection > .accordion-summary:hover strong {
    color: var(--color-text-primary);
}

/* The caret. A CSS triangle rather than a typed glyph: no call site has to remember to add one,
   and there is no character that renders at the same weight across platforms. Points DOWN when
   closed ("there is more below"), flips up when open. */
.accordion--subsection > .accordion-summary::before {
    content: '';
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 5px solid currentColor;
    color: var(--color-text-muted);
    transition: transform var(--transition-fast);
}

.accordion--subsection[open] > .accordion-summary::before {
    transform: rotate(-180deg);
}

.accordion--subsection > .accordion-summary:hover::before {
    color: var(--color-text-primary);
}

/* The table gets air on both sides of itself. The top gap matches .subsection-title's own
   margin-bottom, so an opened section sits its table exactly where a plain section does — which is
   the whole point of the variant. The summary's rule already separates them, so no second border. */
.accordion--subsection > .accordion-body {
    padding: var(--space-2) 0 var(--space-3);
    border-top: none;
}

/* renderStatusChip: outlined pill whose border and text colour ARE the datum (so the colour stays
   inline); only the geometry lives here. --sm is for chips inside a .mini-panel, where a full-size
   chip beside a venue name was heavier than the name itself. */
.status-chip {
    display: inline-block;
    padding: 0.12rem 0.55rem;
    /* A rounded BOX, not a 999px pill. At these sizes a full pill reads as decorative and the text
       sits awkwardly inside the curve; a small radius keeps the label rectangular and legible, and
       matches the panels and tables it sits inside. */
    border-radius: 4px;
    /* A soft FILL, not an outline: .btn-outline owns the outlined-box look now, and a chip that
       shares it reads as a clickable button. The fill derives from the chip's own colour, so the
       one-inline-colour contract (colour IS the datum) is unchanged. */
    border: none;
    background: rgba(148, 163, 184, 0.14);
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1.45;
    white-space: nowrap;
}

@supports (background: color-mix(in srgb, red 10%, transparent)) {
    .status-chip {
        background: color-mix(in srgb, currentColor 15%, transparent);
    }
}

.status-chip--sm {
    padding: 0 0.4rem;
    border-radius: 3px;
    font-size: 0.68rem;
    font-weight: 600;
    line-height: 1.5;
}

/* A run state leads with a dot in the chip's own colour (Running / Paused / Off); --live pulses it
   for something moving money right now (an executing allocation, the live transfers feed). */
.status-chip--dot {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.status-chip--dot::before {
    content: '';
    flex: none;
    width: 0.45rem;
    height: 0.45rem;
    border-radius: 50%;
    background: currentColor;
}

.status-chip--live::before {
    animation: status-chip-pulse 1.6s ease-in-out infinite;
}

@keyframes status-chip-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.35; }
}

@media (prefers-reduced-motion: reduce) {
    .status-chip--live::before { animation: none; }
}

/* createStatusBadge: colored bold text (NOT the .badge pill family) — color stays inline
   since callers pass arbitrary raw colors. */
.status-text {
    font-weight: bold;
    font-size: 0.85em;
}

/* createPaginationControls */
.pagination-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    margin-top: 0.75rem;
    flex-wrap: wrap;
}

.pagination-summary {
    color: var(--color-text-muted);
    font-size: 0.85rem;
}

.pagination-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.pagination-btn {
    padding: 0.35rem 0.7rem;
    font-size: 0.85rem;
}

/* PaginatedTableRenderer.render */
.data-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: auto;
    margin-top: 0.5rem;
}

.data-table thead tr {
    border-bottom: 1px solid var(--color-border);
}

.data-table th {
    /* Per-column align/nowrap/style overrides stay inline (dynamic); only the static padding
       lives here. */
    padding: 0.4rem 0.5rem;
}

/* Transfer cluster: renderTransferSteps / renderTransferFailureNotice / renderTransferCard.
   Dynamic status colors (transferStepStatusColor / transferStatusColor) stay inline. */
.transfer-steps {
    margin-top: 0.5rem;
}

.transfer-step-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin: 0.25rem 0;
}

.transfer-step-dot {
    margin-right: 0.5rem;
}

/* How long a step has been waiting / how long it took. A running step is emphasised: that is
   the number an operator is asking about when a transfer looks stuck. */
.transfer-step-timing {
    color: var(--color-text-muted);
    white-space: nowrap;
}

.transfer-step-timing-running {
    color: var(--color-warning);
    font-weight: 600;
}

/* On-chain hash link (mempool.space / Etherscan / Arbiscan / Hypurrscan).
   `--color-primary` is #2d3748 — the NAVY used for borders and secondary button fills, not a link
   colour. On the card ground that is ~1.1:1 contrast, so every Tx Hash in the deposits and
   withdrawals grids rendered as a barely-visible smudge. Links use the info token, like every
   other link in the app. */
.transfer-step-tx,
.vault-tx-hash {
    color: var(--color-info);
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', monospace;
    font-size: 0.72rem;
    letter-spacing: -0.01em;
    text-decoration: none;
    white-space: nowrap;
}

.transfer-step-tx:hover,
.vault-tx-hash:hover {
    text-decoration: underline;
}

/* Hash we hold but cannot route to an explorer: selectable text, no link. */
.transfer-step-tx-unlinked {
    color: var(--color-text-muted);
    cursor: text;
    text-decoration: none;
    user-select: all;
}

/* A step that moves funds on-chain and has no hash. Absence is ambiguous while the step runs
   and alarming once it has finished — the finished form is the one that cannot be looked up. */
.transfer-step-tx-missing {
    color: var(--color-warning);
    white-space: nowrap;
}

.transfer-step-tx-missing-final {
    color: var(--color-error);
    font-weight: 600;
}

.transfer-step-tx-missing-done {
    color: var(--color-text-muted);
    font-weight: 400;
}

/* Was a light-theme pink box (#fff4f2 / #8f1d12) that glared on the dark ground; now the
   .callout--error recipe. */
.transfer-failure {
    background: var(--color-error-soft);
    border: 1px solid var(--color-error);
    border-radius: var(--radius-sm);
    color: var(--color-error);
    margin: 0.75rem 0;
    padding: 0.75rem;
}

.transfer-card {
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 0.5rem;
}

.transfer-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* "Created"/"Updated" meta lines, muted only when showUpdated is set. */
.transfer-meta-muted {
    color: var(--color-text-muted);
}

.transfer-card-right {
    text-align: right;
}

.transfer-status-text {
    font-weight: 600;
}

.transfer-progress-track {
    background: var(--color-bg-secondary);
    border-radius: 4px;
    height: 8px;
    margin: 0.5rem 0;
}

.transfer-progress-fill {
    height: 100%;
    border-radius: 4px;
}

/* refreshVaultBalances balance-card detail block */
.balance-detail-block {
    margin: 0.5rem 0;
}

/* ==========================================================================
   Shared portfolio components (portfolio.js)
   ========================================================================== */

/* renderVenueBadge */
.venue-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-weight: 600;
    white-space: nowrap;
}

.venue-badge-dot {
    width: 0.6rem;
    height: 0.6rem;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

/* renderAllocationBar */
.alloc-bar {
    display: flex;
    width: 100%;
    border-radius: 6px;
    overflow: hidden;
}

.alloc-bar-segment {
    height: 100%;
    min-width: 2px;
}

.alloc-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: 0.5rem;
    font-size: 0.8rem;
    color: var(--color-text-muted);
}

.alloc-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}

/* renderAssetVenueMatrix numeric cells */
.matrix-num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* renderFreshness */
.freshness {
    color: var(--color-text-muted);
    font-size: 0.75rem;
}

/* renderConsolidatedPositions side cell */
.positions-side {
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 600;
}

/* ==========================================================================
   Responsive breakpoints (Phase 4f)

   Scoped to shared layout primitives only (.metric-grid / .balance-grid,
   .card, .tabs, header/nav, .data-table, .toast-container, .modal, .btn,
   form controls). Every rule below lives inside a max-width media query,
   so desktop (>1024px) rendering is untouched — nothing here modifies or
   restructures the base rules above.

   WIDE screens are not handled here: the upper end of the layout is
   --layout-max-width on .container. Use that variable, not a min-width
   query — a max-width is inert below its own value, so it cannot reach
   these breakpoints.
   ========================================================================== */

/* ---- <=1024px ----
   .metric-grid (repeat(auto-fit, minmax(150px, 1fr))) and .balance-grid
   (repeat(auto-fit, minmax(250px, 1fr))) already reflow their column count
   automatically as the viewport narrows, since they use auto-fit rather
   than a fixed column count. No override is needed at this breakpoint. */

@media (max-width: 768px) {
    /* Header: allow the logo + title to wrap instead of overflowing/clipping
       on narrow viewports. (.nav > .container > ul already has
       flex-wrap: wrap; only .header .container needed it.) */
    .header .container {
        flex-wrap: wrap;
        text-align: center;
    }

    /* .tabs already scrolls horizontally instead of wrapping: it's a flex
       container (default nowrap) with overflow-x: auto, and .tab has
       white-space: nowrap. No change needed here. */

    /* Data tables: give the table's own wrapper horizontal scroll so wide
       tables don't blow out the viewport or force page-level horizontal
       scrolling. Scoped to the table's *direct* parent (not the whole
       .card) so we don't turn .card into a scroll container generally —
       several .card elements host position: sticky strips (.metric-card-row,
       .summary-strip) and position: absolute popups
       (.threshold-meter-popup) that must not be clipped by a
       newly-scrolling ancestor. Some tables (loans.html) already wrap
       themselves in an inline overflow-x: auto div; this is a no-op there
       and only helps the tables that don't. */
    div:has(> table.data-table) {
        overflow-x: auto;
    }

    /* Modal: already `width: calc(100% - 2rem)` with a 480px cap, so it's
       already near-full-width on narrow viewports. No override needed. */

    /* Toast container: narrow to fit within the viewport instead of only
       insetting from the right. */
    .toast-container {
        left: 1rem;
    }
}

@media (max-width: 480px) {
    /* Metric grid: force a single column. (.balance-grid already collapses
       to one column on its own at this width — its 250px minmax leaves no
       room for a second column — so it needs no override.) */
    .metric-grid {
        grid-template-columns: 1fr;
    }

    /* Buttons and form controls: comfortable sizing at small widths. */
    .btn {
        padding: 0.7rem 1.1rem;
        font-size: 0.95rem;
    }

    .form-group input,
    .form-group select,
    .form-group textarea,
    .form-control {
        padding: 0.65rem 0.85rem;
        font-size: 0.95rem;
    }

    /* Modal: reclaim a bit more width on very small screens. */
    .modal {
        width: calc(100% - 1rem);
        padding: 1rem;
    }

    /* Toast container: match the modal's tighter inset. */
    .toast-container {
        left: 0.5rem;
        right: 0.5rem;
    }
}

/* ==========================================================================
   Interactive portfolio components (donut v2, matrix From/To, exposure bars,
   move-funds slider) — GUI modernization phases P1/P4.
   ========================================================================== */

/* --- Donut segments --- */
.donut-segment-group {
    transform-box: view-box;
    transform-origin: center;
    transition: transform 0.15s ease, opacity 0.18s ease;
}
.donut-segment-group--active {
    transform: scale(1.06);
}
.donut-segment-group--selected {
    transform: scale(1.03);
}
.donut-segment-group--dim {
    opacity: 0.25;
}
.donut-segment-group [role="button"] {
    cursor: pointer;
    outline: none;
}
.donut-tooltip {
    position: absolute;
    z-index: 3;
    padding: 0.35rem 0.55rem;
    border-radius: 4px;
    font-size: 0.8rem;
    background: var(--color-bg-primary);
    border: 1px solid var(--color-border);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
    pointer-events: none;
    white-space: nowrap;
}

/* --- Matrix cells (From/To selection) --- */
.matrix-cell {
    transition: background 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}
.matrix-cell--clickable {
    cursor: pointer;
}
.matrix-cell--clickable:hover {
    background: var(--color-accent-soft);
}
.matrix-cell--from {
    box-shadow: inset 0 0 0 2px var(--color-success);
    background: var(--color-success-soft);
}
.matrix-cell--to {
    box-shadow: inset 0 0 0 2px var(--color-info);
    background: var(--color-info-soft);
}
.matrix-cell--eligible {
    box-shadow: inset 0 0 0 1px var(--color-border-focus);
}
.matrix-cell--dim {
    opacity: 0.3;
}
.matrix-row--clickable {
    cursor: pointer;
}
.matrix-row--clickable:hover td {
    background: var(--color-accent-soft);
}
.matrix-row--highlight td {
    background: var(--color-info-soft);
}

/* --- Exposure bars --- */
.exposure-bars {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}
.exposure-bar-row {
    display: grid;
    grid-template-columns: minmax(110px, 1fr) 3fr minmax(70px, auto);
    gap: 0.6rem;
    align-items: center;
}
.exposure-bar-label {
    font-size: 0.8rem;
    color: var(--color-text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.exposure-bar-track {
    height: 10px;
    border-radius: 5px;
    background: var(--color-bg-secondary);
    overflow: hidden;
}
.exposure-bar-fill {
    height: 100%;
    border-radius: 5px;
    transition: width 0.3s ease;
}
.exposure-bar-fill--long {
    background: var(--color-success);
}
.exposure-bar-fill--short {
    background: var(--color-error);
}
.exposure-bar-value {
    font-size: 0.8rem;
    text-align: right;
}

/* --- Move funds From/To banner + slider --- */
.from-to-banner {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
    padding: 0.5rem 0.75rem;
    margin-bottom: 0.75rem;
    border-radius: 6px;
    border: 1px solid var(--color-border);
    background: var(--color-bg-secondary);
    font-size: 0.85rem;
}
.from-to-banner .from-chip,
.from-to-banner .to-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    font-weight: 600;
}
.from-to-banner .from-chip {
    background: var(--color-success-soft);
    border: 1px solid var(--color-success);
}
.from-to-banner .to-chip {
    background: var(--color-info-soft);
    border: 1px solid var(--color-info);
}
.from-to-banner .banner-clear {
    margin-left: auto;
    cursor: pointer;
    color: var(--color-text-muted);
    background: none;
    border: none;
    font-size: 0.8rem;
    text-decoration: underline;
}

input[type="range"].uf-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: var(--color-bg-secondary);
    outline: none;
    margin: 0.5rem 0;
}
input[type="range"].uf-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--color-accent);
    border: 2px solid var(--color-bg-primary);
    cursor: pointer;
    transition: transform 0.1s ease;
}
input[type="range"].uf-slider::-webkit-slider-thumb:hover {
    transform: scale(1.15);
}
input[type="range"].uf-slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--color-accent);
    border: 2px solid var(--color-bg-primary);
    cursor: pointer;
}
.uf-quick-amounts {
    display: flex;
    gap: 0.4rem;
    margin-top: 0.35rem;
}
.uf-quick-amounts button {
    padding: 0.15rem 0.55rem;
    font-size: 0.75rem;
    border-radius: 4px;
    border: 1px solid var(--color-border);
    background: var(--color-bg-secondary);
    color: var(--color-text-muted);
    cursor: pointer;
}
.uf-quick-amounts button:hover {
    border-color: var(--color-border-focus);
    color: var(--color-text-primary);
}

/* --- Entrance animation for re-rendered regions --- */
@keyframes fadeSlideIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}
.fade-slide-in {
    animation: fadeSlideIn 0.25s ease;
}
@media (prefers-reduced-motion: reduce) {
    .fade-slide-in {
        animation: none;
    }
    .donut-segment-group,
    .matrix-cell,
    .exposure-bar-fill {
        transition: none;
    }
}

/* --- Chart boxes (driven pies) --- */
.chart-box {
    padding: 0.75rem;
    border-radius: 8px;
    border: 1px solid transparent;
}
/* Selected-venue cue is the border tint only — a box-shadow ring here read as a stray focus
   outline left behind by the click. The selection is already obvious from the reset chip, the
   popped segment, the dimmed siblings and the driven titles naming the venue. */
.chart-box--driver {
    border-color: var(--color-border-focus);
}
/* renderAllocationDonut sizes its wrap at a fixed 160px while the chart box grows with the page —
   centre it so the slack reads as padding, not a chart pinned to the left of an empty box. */
.chart-box .donut-wrap {
    margin-inline: auto;
}

/* Donut centre stack. The value is capped to the ring's hole by an inline max-width (geometry,
   computed from the radius) and its size steps down for a long total; everything else is here. */
.donut-center-value {
    font-weight: 700;
    line-height: 1.15;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.donut-center-label {
    margin-top: 0.1rem;
    color: var(--color-text-muted);
    font-size: 0.72rem;
    line-height: 1.2;
}
.chart-box-title {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin: 0 0 0.5rem;
    color: var(--color-text-muted);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.chart-reset-chip {
    margin-left: auto;
    padding: 0.1rem 0.5rem;
    font-size: 0.72rem;
    border-radius: 4px;
    border: 1px solid var(--color-border);
    background: var(--color-bg-secondary);
    color: var(--color-text-muted);
    cursor: pointer;
    text-transform: none;
    letter-spacing: normal;
}
.chart-reset-chip:hover {
    border-color: var(--color-border-focus);
    color: var(--color-text-primary);
}

/* --- Vault/exchange chart row --- */
.vault-chart-row {
    display: grid;
    /* Track floor tracks the donut's drawn size (192px + hover bleed + the box's own padding);
       below it the ring would be cropped by its column rather than centred in it. */
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.25rem;
    margin-top: 1rem;
    align-items: start;
}
.chart-label {
    margin: 0 0 0.5rem;
    color: var(--color-text-muted);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.freshness--stale {
    color: var(--color-warning);
}

/* --- Matrix: transfer affordance + blocked cells --- */
/* The pulse animates OPACITY on an overlay (compositor-only), never box-shadow directly:
   animating box-shadow forces a style/paint pass every frame on every eligible cell, which
   pinned a CPU core for as long as a From cell stayed selected. */
@keyframes eligiblePulse {
    0%, 100% { opacity: 0.45; }
    50% { opacity: 1; }
}
.matrix-cell--eligible {
    position: relative;
}
.matrix-cell--eligible::after {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    box-shadow: inset 0 0 0 2px var(--color-accent);
    animation: eligiblePulse 1.6s ease-in-out infinite;
    will-change: opacity;
}
@media (prefers-reduced-motion: reduce) {
    .matrix-cell--eligible::after {
        animation: none;
        opacity: 0.8;
    }
}
.matrix-cell--blocked {
    /* Not transferable from this venue: grey it out (never error-red — nothing is
       wrong, the asset just has no movement route here). */
    opacity: 0.35;
    cursor: not-allowed !important;
    box-shadow: none !important;
    background: transparent;
}
.matrix-cell--clickable {
    cursor: pointer;
}
.matrix-cell--clickable:hover {
    background: var(--color-accent-soft);
    box-shadow: inset 0 0 0 1px var(--color-accent);
}
.matrix-table tfoot td {
    border-top: 2px solid var(--color-border);
    padding-top: 0.5rem;
}
@media (prefers-reduced-motion: reduce) {
    .matrix-cell--eligible {
        animation: none;
    }
}

/* --- Chip group: a small set of filters rendered as dark pills, accent-filled when active.
   `.chip-group` is the general form (the lender loan-status picker); `.venue-filter-chips` is the
   transfers-panel instance, kept as an alias so its call sites need no change. One family, not
   two: a status filter and a venue filter that look different are how the pages drifted apart. --- */
.chip-group,
.venue-filter-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
}
.venue-filter-chips {
    margin-top: 0.65rem;
}
.chip-group button,
.venue-filter-chips button {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.3rem 0.75rem;
    font-size: 0.8rem;
    font-family: inherit;
    border-radius: 6px;
    border: 1px solid var(--color-border);
    background: var(--color-bg-secondary);
    color: var(--color-text-muted);
    cursor: pointer;
    transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}
.chip-group button:hover,
.venue-filter-chips button:hover {
    border-color: var(--color-border-focus);
    color: var(--color-text-primary);
}
.chip-group button.chip-active,
.venue-filter-chips button.chip-active {
    border-color: var(--color-accent);
    background: var(--color-accent-soft);
    color: var(--color-accent-light);
    font-weight: 600;
    box-shadow: 0 0 0 1px var(--color-accent);
}
.chip-group button:focus-visible,
.venue-filter-chips button:focus-visible {
    outline: 2px solid var(--color-border-focus);
    outline-offset: 1px;
}

/* Compact variant for a chip group sitting on a heading line. */
.chip-group--sm button {
    padding: 0.22rem 0.6rem;
    font-size: 0.75rem;
}

/* Version selector on the loan term carousel (both loan pages): a compact tab strip. Selection is
   the tab underline; state is a dot — green = the terms in force, amber = an amendment still open.
   Colour is never the only signal: the tab text says it ("Amendment 2 · Pending Lender Approval"). */
.term-version-tabs .tab--in-force::before,
.term-version-tabs .tab--open::before {
    content: "";
    display: inline-block;
    width: 0.45rem;
    height: 0.45rem;
    margin-right: 0.4rem;
    border-radius: 50%;
    vertical-align: 0.05em;
}

.term-version-tabs .tab--in-force::before { background: var(--color-success); }
.term-version-tabs .tab--open::before { background: var(--color-warning); }

/* A notice directly above the strip (the "amendment is already open" callout) keeps its gap. */
.callout + .term-version-tabs {
    margin-top: var(--space-3);
}

/* ==========================================================================
   Loan terms & amendments (includes/lending_terms.js.html — borrower page,
   lender dashboard's Terms & Amendments tab, and both quote-terms views)
   ========================================================================== */

/* The frame around one frozen set of loan terms — the review block and the editor block are the
   same object in two modes, and each had retyped the identical four-property inline object. */
.terms-block {
    margin-top: var(--space-3);
    padding: var(--space-3);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-bg-secondary);
}

/* Its title line: the block's name on the left, the term-version provenance on the right. */
.terms-block > .control-row--split {
    margin-bottom: 0;
}

/* A .subsection-title is the rank of a table's name inside the block, so the block's FIRST one
   must not add a full section gap under the title line it already follows. */
.terms-block > .control-row--split + .subsection-title {
    margin-top: var(--space-3);
}

/* Editable term cell. Deliberately NOT .form-control: that is the page-form size (0.75rem 1rem
   padding, 1rem text) and a table of ten of them per row would be unreadable. This is the dense
   in-grid size the editor already used inline at every call site. */
.terms-input {
    width: 100%;
    min-width: 92px;
    padding: 0.35rem;
    background: var(--color-bg-primary);
    color: var(--color-text-primary);
    border: 1px solid var(--color-border);
    border-radius: 4px;
    font-family: inherit;
    font-size: 0.85rem;
}

.terms-input:focus {
    outline: none;
    border-color: var(--color-border-focus);
}

/* A checkbox is not a text field: it takes none of the geometry above. */
.terms-input[type="checkbox"] {
    width: auto;
    min-width: 0;
    padding: 0;
    border: 0;
}

/* The portfolio-term editor's field grid. A slightly wider track than .metric-grid: these cells
   carry a label AND an input, and at 150px "Hedge Control Coverage %" wrapped to three lines. */
.terms-field-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 0.55rem;
    margin-top: 0.6rem;
}

/* Label-over-input pair in the portfolio-term editor's grid. */
.terms-field {
    display: grid;
    gap: var(--space-1);
    color: var(--color-text-muted);
    font-size: 0.8rem;
}

/* The one button on the page the reader was sent here to press (the borrower arriving on an
   amendment-approval link). Was five inline properties on the button plus a JS keyframe list, both
   carrying rgba() literals mixed from the PRE-MUTE vivid amber, so the ring did not match the
   border beside it. Tint and ring both quote --color-warning now. */
.btn--attention {
    border: 1px solid var(--color-warning);
    background: var(--color-warning-soft);
    color: var(--color-warning);
    font-weight: 700;
    box-shadow: 0 0 0 3px var(--color-warning-soft);
}

/* Three-beat attention pulse. In CSS rather than element.animate() because animate() cannot
   resolve var(--…) — which forced the old ring colour to be hardcoded — and because a stylesheet
   animation can be switched off for prefers-reduced-motion, which the JS version could not. */
@keyframes btn-attention-pulse {
    0%, 100% { transform: scale(1); box-shadow: 0 0 0 3px var(--color-warning-soft); }
    50% { transform: scale(1.05); box-shadow: 0 0 0 8px var(--color-warning-soft); }
}

.btn--attention-pulse {
    animation: btn-attention-pulse 900ms ease-in-out 150ms 3;
}

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

/* Dense inline form (the RFQs tab's quote form, the Addresses tab's add-address form): a compact
   auto-fit grid of small labelled inputs sitting inside a tab body, at the same rhythm as
   .mini-panel and .dense-table. Deliberately NOT .form-group, which is the full-page form
   vocabulary (uppercase labels, 1rem-padded inputs) and would dwarf the tables beside it. */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 0.65rem;
    align-items: end;
}

.form-field label,
.form-field .form-field-label {
    display: block;
    margin-bottom: 0.25rem;
    color: var(--color-text-muted);
    font-size: 0.8rem;
}

/* Label row carrying a small control beside the label (the Amount unit flip). The control lives
   NEXT TO the <label>, never inside it — a click inside a label also activates the label and
   yanks focus into its input. The row takes over the label's bottom gap. */
.form-label-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.25rem;
}

.form-label-row label {
    margin-bottom: 0;
}

/* Always-visible help line under a field label. min-height keeps a row of fields with help texts
   of different lengths aligned on their inputs. */
.form-field-help {
    min-height: 2.4rem;
    margin-bottom: 0.25rem;
    color: var(--color-text-muted);
    font-size: 0.75rem;
    line-height: 1.35;
}

.form-field input,
.form-field select,
.form-field textarea {
    width: 100%;
    padding: 0.4rem 0.5rem;
    background: var(--color-bg-secondary);
    color: var(--color-text-primary);
    border: 1px solid var(--color-border);
    border-radius: 4px;
    font-size: 0.9rem;
}

.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus {
    outline: none;
    border-color: var(--color-border-focus);
}

/* Icon-only button (the liquidation panel's refresh): a square outline button whose label is an
   inline SVG glyph. Always pair with aria-label + title — the glyph carries no text. */
.btn-icon {
    padding: 0;
    width: 1.9rem;
    height: 1.9rem;
    background: transparent;
    border: 1px solid var(--color-border);
    color: var(--color-text-muted);
    border-radius: var(--radius-sm);
}

.btn-icon:hover:not(:disabled) {
    background: var(--color-bg-secondary);
    border-color: var(--color-border-focus);
    color: var(--color-text-primary);
}

.btn-icon svg {
    width: 0.95rem;
    height: 0.95rem;
}

/* Fixed-width status chip for a COLUMN of chips (the liquidation orders table): equal boxes with
   centred text keep the column scannable; free-width chips of different lengths read as jagged. */
.status-chip--fixed {
    min-width: 6.5rem;
    justify-content: center;
    text-align: center;
}

/* Uniform three-slot stat card, for a row of cards that carry subtexts of different lengths (the
   History tab's stat strip): label at the top, value directly under it, subtext pinned to the
   card's bottom edge — so the headers, the numbers and the footnotes each form one clean line
   across the row instead of drifting with each card's own text length. Modifier only: the base
   .metric-card-row keeps centring, which is right for the single-line whole-book strip. */
.metric-card-row--aligned .metric-card {
    justify-content: flex-start;
}

.metric-card-row--aligned .metric-card .metric-subtext {
    margin-top: auto;
    padding-top: 0.3rem;
}

/* Two-up chart tiles (the History tab): exactly two per row — auto-fit grew a third column on a
   wide screen and the tiles became unreadable — stacking to one column only where two cannot fit.
   Row gap stays 0 because each chart tile brings its own top margin. min-width:0 lets the
   responsive SVGs shrink inside their track. */
.chart-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0 var(--space-3);
    /* STRETCH, not start: a chart with a different legend depth — or one showing "No data for this
       metric", which collapses to a single line — left its row partner ragged. Row spacing still
       comes from each chart's own top margin, hence the zero row gap. */
    align-items: stretch;
}

/* The chart wrappers carry no class of their own (renderTimeSeriesChart builds them inline), so the
   grid addresses them directly. Column flex so a stretched cell's slack lands at the bottom of the
   box rather than pushing the chart off-centre. */
.chart-grid > * {
    display: flex;
    flex-direction: column;
}

@media (max-width: 900px) {
    .chart-grid {
        grid-template-columns: minmax(0, 1fr);
    }
}

.chart-grid > * {
    min-width: 0;
}

/* ==========================================================================
   Page portfolio bar
   --------------------------------------------------------------------------
   Every borrower page is scoped to one firm book, and every one of them had built its own
   selector strip: Vault and Exchanges used a `.card` with an inline flex `<label>` and a bold
   "Portfolio:" run-in, Risk Management a third copy of the same object, Risk Analytics a
   `.control-row` on its title row. Four strips at three heights, so switching pages moved the
   one control the reader uses on all of them. This is that strip, once.

   It is deliberately NOT a `.card`: a full card's padding and hover shadow gave a single select
   the visual weight of a data container. `position: sticky` keeps the book you are looking at
   named while you scroll a long page.
   ========================================================================== */
.portfolio-bar {
    position: sticky;
    top: 0;
    z-index: 6;                       /* above card content, below tooltips (.tooltip-bubble) */
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.35rem 0.75rem;
    margin-bottom: 0.75rem;
    padding: 0.4rem 0.75rem;
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
}

.portfolio-bar-label {
    color: var(--color-text-muted);
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

/* Why the selection matters on THIS page, and any page-level context that rides with it (the
   Risk Analytics loan strip). Pushed to the right so the control itself always sits in the same
   place from page to page. */
.portfolio-bar-hint {
    margin-left: auto;
    color: var(--color-text-muted);
    font-size: 0.75rem;
}

/* The picker sizes itself to its longest book name; cap it so a long name cannot push the hint
   off the row. */
.portfolio-bar .picker-trigger {
    max-width: min(30rem, 52vw);
}

/* ==========================================================================
   Data panel (.data-panel)
   --------------------------------------------------------------------------
   A titled sub-container INSIDE a card, for one member of a repeated set (one custody vault of a
   portfolio, one account of a venue). Bigger than a `.mini-panel`, which is a compact stat panel
   in a `.panel-row` grid; this one owns a header band and a body of fields.

   Both the Vaults and Balances containers stacked one hand-rolled bordered `<div>` per vault with
   its own inline border/radius/padding object, at two different densities.
   ========================================================================== */
.data-panel {
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-bg-secondary);
    overflow: hidden;
}

.data-panel + .data-panel {
    margin-top: 0.7rem;
}

.data-panel-head {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.3rem 0.6rem;
    padding: 0.45rem 0.7rem;
    background: var(--color-bg-dark);
    border-bottom: 1px solid var(--color-border);
}

.data-panel-title {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin: 0;
    color: var(--color-text-secondary);
    font-size: 0.9rem;
    font-weight: 600;
}

/* Provider / default / type qualifiers that ride after the panel's name without competing with it. */
.data-panel-sub {
    color: var(--color-text-muted);
    font-size: 0.8rem;
    font-weight: 500;
}

/* Right-hand slot of the header band (a status chip). */
.data-panel-head-meta {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-left: auto;
}

.data-panel-body {
    padding: 0.7rem;
}

/* A callout inside a panel body opens the body, so it drops the top margin the standalone
   callout carries. */
.data-panel-body > .callout:first-child {
    margin-top: 0;
}

/* ==========================================================================
   Key/value grid (.kv-grid)
   --------------------------------------------------------------------------
   Labelled facts about one entity (vault id, status, type). Was `<strong>Label:</strong><br>` in a
   three-column inline grid, which makes the LABEL the loudest thing in the cell and leaves the
   value — the part being read — in body weight.
   ========================================================================== */
.kv-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.55rem 1.25rem;
}

.kv-label {
    display: block;
    margin-bottom: 0.15rem;
    color: var(--color-text-muted);
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.07em;
    text-transform: uppercase;
}

.kv-value {
    color: var(--color-text-primary);
    font-size: 0.9rem;
    font-weight: 600;
}

/* A second, quieter line under a value (a vault type's supported networks). */
.kv-note {
    display: block;
    margin-top: 0.15rem;
    color: var(--color-text-muted);
    font-size: 0.72rem;
    font-weight: 400;
}

/* ==========================================================================
   Address line (.address-line)
   --------------------------------------------------------------------------
   A full, un-shortened custody address the user is meant to copy and paste somewhere. Distinct
   from `.cell-address`, which SHORTENS an identifier inside a dense grid: a deposit address must
   be readable in full, because getting one character wrong loses the deposit.

   The old form was a 3.5rem-tall boxed `<code>` next to a full-size `.btn` — a bordered block and
   a filled button for one line of text, repeated per vault. The line is now the control: click
   anywhere on it to copy.
   ========================================================================== */
.address-line {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    /* Hug the address, don't stretch: a full-width bar around a 42-character string is the
       "blocky" shape this replaced, just without the button. */
    max-width: 100%;
    padding: 0.3rem 0.5rem;
    background: var(--color-bg-dark);
    border: 1px solid var(--color-border);
    border-radius: 4px;
    color: var(--color-text-primary);
    cursor: pointer;
    text-align: left;
    transition: border-color var(--transition-fast), color var(--transition-fast);
}

.address-line:hover,
.address-line:focus-visible {
    border-color: var(--color-border-focus);
    color: var(--color-accent-light);
}

.address-line .cell-mono {
    /* Shrink-to-fit, not grow: with `flex: 1` the copy glyph was flung to the far right of a
       full-width line, a hand's width from the address it copies. */
    flex: 0 1 auto;
    /* The one place a hash/address is allowed to wrap: it is the value being transcribed, and a
       truncated deposit address is a lost deposit. */
    white-space: normal;
    word-break: break-all;
    font-size: 0.8rem;
    color: var(--color-text-primary);
}

.address-line .cell-copy-icon {
    width: 0.9rem;
    height: 0.9rem;
}

.address-line:hover .cell-copy-icon,
.address-line:focus-visible .cell-copy-icon {
    opacity: 1;
}

/* A checkbox and its label sitting on one line inside a .form-grid (the add-address form's
   "Require OTP for withdrawals"). The grid aligns its children on `end` for the input rows, which
   pushed a bare inline label's box around; this gives the row its own baseline. */
.form-inline-check {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    margin-top: 0.15rem;
    color: var(--color-text-muted);
    font-size: 0.8rem;
}

.form-inline-check input[type="checkbox"] {
    width: auto;
    margin: 0;
    accent-color: var(--color-accent);
}

/* Hint / availability line under a .form-field input. Was a retyped
   `color: muted; margin-top: .25rem; display: block` object at every call site. */
.form-field-note {
    display: block;
    margin-top: 0.25rem;
    color: var(--color-text-muted);
    font-size: 0.75rem;
    line-height: 1.35;
}

/* Deposit-address block inside a vault panel: its own label + .address-line + network warning. */
.deposit-address {
    margin-top: 0.7rem;
}

.deposit-address > .callout {
    margin-top: 0.5rem;
}

/* A callout whose content sits on ONE line beside a leading indicator (a spinner while an action
   is in flight). The base .callout is a block; this makes it a row so the indicator and its
   sentence share a baseline instead of stacking. */
.callout--success {
    background: var(--color-success-soft);
    border-color: var(--color-success);
    color: var(--color-success);
}

/* A neutral notice (no schedule yet, not running): framed like the others, no alarm colour. */
.callout--muted {
    background: var(--color-bg-secondary);
    border-color: var(--color-border);
    color: var(--color-text-secondary);
}

/* A notice that opens a panel body sits on the body's own padding, not 0.75rem below it. */
.data-panel-body > .callout:first-child {
    margin-top: 0;
}

.callout--row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.callout--row strong {
    display: inline;
    margin-bottom: 0;
}

/* .form-grid aligns fields on their BOTTOM edge, which is right when every cell is one label over
   one input. A cell that carries extra rows under its input (a slider, an availability hint) then
   drags its whole row down and its neighbours' selects float mid-cell. `--top` opts that form into
   top alignment instead. */
.form-grid--top {
    align-items: start;
}

/* Narrower fixed slot for a column of SMALL chips (a table's Type column). The 6.5rem base is
   sized for status words; a type tag column at 0.65rem only needs enough for its longest label,
   and the wider slot left a visible gutter between the tag and the column rule. */
.status-chip--fixed-sm {
    min-width: 5.2rem;
}

/* A read-only fact rendered where a field would be (the RFQ form's portfolio): input geometry,
   no affordance to edit. */
.form-static-value {
    width: 100%;
    padding: 0.4rem 0.5rem;
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border);
    border-radius: 4px;
    color: var(--color-text-primary);
    font-size: 0.9rem;
    line-height: 1.4;
}

/* A table header carrying the ⓘ badge (lenderCalcHeader / leverageColumnHeader): label and badge on
   one line, badge never wrapped under the label by the header's nowrap. */
.th-with-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    vertical-align: middle;
}

/* Tx-hash cell: the explorer link plus a copy affordance, on one line. */
.tx-hash-cell {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    white-space: nowrap;
}

/* A .cell-address carrying only the copy glyph (it sits beside a link that owns the text). */
.cell-address--icon-only {
    gap: 0;
}

/* The unique id of the entity a .data-panel is about, on its header band: a small label plus the
   click-to-copy value. Distinct from the panel TITLE, which is the human name. */
.data-panel-head-id {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.data-panel-head-id-label {
    color: var(--color-text-muted);
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.data-panel-head-id .cell-mono {
    font-size: 0.72rem;
}

/* Two-column .form-grid, capped. `.form-grid`'s default auto-fit is right for a ten-slot strip of
   tiny inputs; for a form of four or five real fields on a 1400px card it produced eight 170px
   tracks and squashed the whole form into the left eighth. */
.form-grid--pair {
    /* Two equal field columns, capped: a form of four or five real fields wants a readable
       measure, not the full 1400px of the card it sits in. The action row is a SIBLING of this
       grid, not a cell in it, so its rule and its buttons still run the panel's full width. */
    grid-template-columns: repeat(2, minmax(0, 1fr));
    max-width: 42rem;
}

/* A field that spans both columns (a destination select holding "Label (0x…) · EVM"). */
.form-grid--pair > .form-field--wide {
    grid-column: 1 / -1;
}

/* A strip of SMALL controls (the planner's asset/unit/min-move, the scheduler's guardrails):
   compact fixed-cap tracks, so seven number inputs don't each stretch to an eighth of a 1400px
   card. auto-fit needs a definite minimum, and the 14rem cap stops the stretch. */
.form-grid--compact {
    grid-template-columns: repeat(auto-fit, minmax(11rem, 14rem));
}

.form-grid--compact > .form-field--wide {
    grid-column: 1 / -1;
}

/* Sections of the Scheduled / Planner sub-tabs: framed panels with the tab's rhythm between them. */
.schedule-section-panel {
    margin-top: 0.75rem;
}

/* The one panel in a list that should stand out (the most recent past batch). */
.data-panel--highlight {
    border-color: var(--color-accent);
}

@media (max-width: 720px) {
    .form-grid--pair {
        grid-template-columns: minmax(0, 1fr);
    }
}

/* A form's action row: any note on the left, buttons on the right, ruled off from the fields. */
.form-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem 0.75rem;
    margin-top: 0.35rem;
    padding-top: 0.65rem;
    border-top: 1px solid var(--color-border);
}

/* Buttons sit hard right whether or not the note beside them is showing — a hint that is
   `display: none` (the 2FA-not-enabled line) is not a flex item, so it cannot hold the slack. */
.form-actions > .btn:first-of-type {
    margin-left: auto;
}

/* An arm switch on the action row (the scheduler's Enabled box beside Save): the checkbox and its
   consequence line as one unit, so it reads as part of the commit decision, not a stray setting. */
.form-actions-arm {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 0.15rem 0.6rem;
}

.form-actions-arm .form-field-note {
    margin: 0;
}

/* Inputs inside a dense grid (the scheduler / planner target columns) take the grid's density:
   the page-level .form-control is a 1rem, 0.75rem-padded field sized for a form, and at that size
   four of them per row made the table twice its natural height. */
.dense-table .form-control {
    padding: 0.28rem 0.5rem;
    font-size: 0.8rem;
    border-radius: 4px;
}

.schedule-target-input,
.planner-target-input {
    max-width: 8.5rem;
}

/* When the note IS showing it takes the slack instead, so it wraps rather than the buttons. */
.form-actions-note {
    flex: 1 1 12rem;
    min-width: 0;
    color: var(--color-text-muted);
    font-size: 0.75rem;
    line-height: 1.35;
}

/* A note that flags something unsaved/blocking beside the action ("Unsaved changes"). */
.form-actions-note--warning {
    color: var(--color-warning);
}

/* An input with a button welded to its right edge (Amount + Max). */
.input-with-action {
    display: flex;
    gap: 0.4rem;
}

.input-with-action > input {
    flex: 1 1 auto;
    min-width: 0;
}

.input-with-action > .btn {
    flex: 0 0 auto;
}

/* The withdraw form's panel: the tab's primary action, so it leads rather than filling the card. */
.withdraw-panel {
    margin-bottom: 0.9rem;
}

/* The loan workflow's current state: a chip carrying the word, the detail beside it. Was a bare
   sentence of raw workflow text with an inline colour and its own margins. */
.workflow-line {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 0.4rem 0.6rem;
    margin: 0.6rem 0 0.75rem;
}

.workflow-line-text {
    color: var(--color-text-muted);
    font-size: 0.8rem;
    line-height: 1.4;
}

.workflow-line-text--error {
    color: var(--color-error);
    font-weight: 600;
}

/* The workflow line when it LEADS the Summary tab (above the hero grid): no leading margin —
   the card heading's rule already separates it — and a touch more room before the numbers. */
.workflow-line--lead {
    margin: 0 0 0.85rem;
}

/* One-sentence program gate parked above the dashboard card: it takes the card rhythm's bottom
   gap, since .callout only carries a top margin (built for in-flow notices). */
.program-gate-notice {
    margin: 0 0 1rem;
}

/* A grid row the engine flagged as an error. The tint is composited over an opaque base on the
   frozen first column, the same trick the selected-row rule uses — without it the tint stops dead
   at the sticky column. */
.dense-table tbody tr.row-severity-error {
    background: var(--color-error-soft);
    color: var(--color-error);
    font-weight: 600;
}

.dense-table tbody tr.row-severity-error td:first-child {
    background: linear-gradient(var(--color-error-soft), var(--color-error-soft)), var(--color-bg-card);
}

/* A panel's own action row: right-aligned, ruled off from the body above it. Lighter than
   .form-actions, which belongs to a form and carries a note slot. */
.panel-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 0.6rem;
}

/* A quote card nested inside an RFQ panel's body: it is a panel within a panel, so it drops the
   outer one's ground and sits a shade back from it. */
.quote-card {
    background: var(--color-bg-card);
}

.quote-card + .quote-card,
.data-panel-body > .quote-card {
    margin-top: 0.6rem;
}

/* Per-venue breach-scope stack: the scope chip over the two basis lines. `justify-items: start`
   is load-bearing — a grid item stretches by default, and the chip is an inline-block with a
   border, so without it the chip was drawn as a full-width outlined bar. */
.venue-breach-scope {
    display: grid;
    justify-items: start;
    gap: 0.15rem;
}

/* That stack as the FOOTER of a venue's metric grid: an inset strip on the panel's own ground.
   A bare rule above loose small text read as detached from the venue panel entirely — the frame
   says "this is this venue's summary", the way the metric cards above it carry their own frames. */
.venue-scope-footer {
    margin-top: 0.6rem;
    padding: 0.55rem 0.7rem;
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border-subtle);
    border-radius: var(--radius-sm);
}

/* One venue's block on the Exchange Risk tab. Bounded on purpose: its tile grid rarely fills its
   last row, and an unbounded grid whose final row is half empty reads as "the rest is cut off".
   The panel edge says where the venue's data ends — and its notes (breach scope, unrated
   collateral, a rejected venue call) sit INSIDE it, so they read as this venue's footnotes rather
   than as page-level rows. */
.venue-panel + .venue-panel {
    margin-top: 0.7rem;
}

.venue-panel > .data-panel-body > .metric-grid {
    margin-bottom: 0;
}

/* Notices inside a venue panel are that venue's, so they hug its body rather than carrying the
   standalone callout's top margin. */
.venue-panel > .data-panel-body > .callout {
    margin-top: 0.5rem;
}

/* A venue's tile grid packs to six per row rather than the shared grid's nine, so the usual
   twelve tiles land as two FULL rows instead of eight-then-four. A ragged final row is what read
   as "there is more below that I cannot see". */
.venue-panel .metric-grid {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

/* Term-parameter grids (Loan Parameters, Portfolio Risk Parameters). Each cell is a short label
   over a bare number, so the track floor is lower than .metric-grid's — which lets the usual seven
   and thirteen parameters land as full rows instead of leaving a half-empty one that reads as
   truncation. */
.term-param-grid {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

/* Page-level venue picker (the exchanges page's Overview/Hyperliquid/OKX/… strip). It is chrome,
   not a data container, so it does not get a .card's padding, border and hover shadow — it sits
   directly under the portfolio bar like a tab strip. */
.venue-tabbar {
    margin-bottom: 0.75rem;
}

.venue-tabbar .tabs {
    margin-bottom: 0;
}

/* Clicking a donut segment left the browser's default focus ring on the arc — a hard rectangle
   around a curve. Keyboard focus must still be visible (the arcs are role=button, tabindex=0), so
   the ring is scoped to :focus-visible and drawn as a soft halo that follows the stroke. */
.donut-segment-group [role="button"]:focus:not(:focus-visible) {
    outline: none;
}

.donut-segment-group [role="button"]:focus-visible {
    outline: none;
    filter: drop-shadow(0 0 3px var(--color-border-focus));
}

/* Move Funds sits directly under the balances matrix — the panel's top gap is the table's
   bottom margin. */
.move-funds-panel {
    margin-top: 1rem;
}

/* Two columns on a wide card: the field grid keeps its capped measure on the left, and the facts
   about the move (availability, hints, risk preview) fill the right rail instead of stacking the
   panel taller over dead space. Single column again once the card can't hold both. */
.move-funds-columns {
    display: grid;
    grid-template-columns: minmax(0, 42rem) minmax(16rem, 1fr);
    gap: 0.75rem 1.5rem;
    align-items: start;
}

.move-funds-rail {
    display: grid;
    gap: 0.5rem;
    align-content: start;
}

@media (min-width: 961px) {
    .move-funds-rail {
        border-left: 1px solid var(--color-border-subtle);
        padding-left: 1.25rem;
    }
    /* In the rail the notes ARE the column — the rail's rule replaces their own top rule. */
    .move-funds-rail .move-funds-notes {
        margin-top: 0;
        padding-top: 0;
        border-top: 0;
    }
}

@media (max-width: 960px) {
    .move-funds-columns {
        grid-template-columns: minmax(0, 1fr);
    }
}

/* Move Funds panel: the Available line and its hints sit between the field grid and the action
   row, ruled off from the fields so they read as facts ABOUT the move rather than as more fields. */
.move-funds-notes {
    margin-top: 0.6rem;
    padding-top: 0.55rem;
    border-top: 1px solid var(--color-border-subtle);
    display: grid;
    gap: 0.2rem;
}

.move-funds-available {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 0.2rem 0.5rem;
}

/* The figure never breaks across lines, and the staleness warning takes a line of its own under it
   rather than crowding the number sideways. */
.move-funds-available .kv-value {
    white-space: nowrap;
}

.move-funds-available .move-funds-stale {
    flex-basis: 100%;
}

.move-funds-available .kv-label {
    margin-bottom: 0;
}

.move-funds-stale {
    color: var(--color-error);
    font-size: 0.75rem;
}

/* Three movement forms side by side (deposit / withdraw / exchange transfer). Auto-fit so they
   stack rather than crush on a narrow window — the old fixed `1fr 1fr 1fr` squeezed three full
   forms into a third of the page each at every width. */
.movement-forms {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 22rem), 1fr));
    gap: 0.75rem;
    /* stretch, not start: the three tiles share each row's height, so the row reads as one
       band of forms instead of three boxes of ragged depths. */
    align-items: stretch;
}

/* Inside a ~26rem tile the auto-fit field grid wrapped at ragged breakpoints — one field column
   per tile keeps the three forms in lockstep. The tile is a flex column with the action row
   pinned to its bottom edge, so the three submits sit on one line however the hints wrap. */
.movement-forms > .data-panel {
    display: flex;
    flex-direction: column;
    /* Grid children don't collapse margins: the generic .data-panel + .data-panel gap was
       pushing tiles 2 and 3 down and staggering the row's top edge. The grid gap owns spacing. */
    margin-top: 0;
}

.movement-forms > .data-panel > .data-panel-body {
    display: flex;
    flex-direction: column;
    flex: 1;
}

.movement-forms > .data-panel form {
    display: flex;
    flex-direction: column;
    flex: 1;
}

.movement-forms .form-grid {
    grid-template-columns: minmax(0, 1fr);
}

.movement-forms .form-actions {
    margin-top: auto;
    padding-top: 0.65rem;
}

/* The availability figure a movement form is capped by: a labelled fact under the fields, not a
   bordered `.balance-info` box wedged between two inputs. */
.movement-available {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-top: 0.55rem;
}

.movement-available .kv-label {
    margin-bottom: 0;
}

/* The Open Positions panel's stress control, on the panel's header band. It was an inline-flex
   span with six inline properties wedged inside an <h2>. */
.stress-control {
    gap: 0.5rem;
}

.stress-control input[type="range"] {
    width: 140px;
}

.stress-control-value {
    min-width: 3.2rem;
    color: var(--color-text-primary);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    font-size: 0.8rem;
}

/* One available/wallet/pending line inside an exchange coin card: muted label on the left, the
   tabular figure on the right, so the numbers line up column-wise down the card. */
.coin-detail-line {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    font-size: 0.8rem;
    line-height: 1.6;
    white-space: nowrap;
}

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

.coin-detail-value {
    color: var(--color-text-primary);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.transfers-live {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    vertical-align: middle;
    font-size: 0.8rem;
    font-weight: 400;
    cursor: help;
}

.transfers-live:empty {
    display: none;
}

.transfers-live-time {
    color: var(--color-text-muted);
    font-size: 0.75rem;
}

.transfer-card--focus {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
    box-shadow: 0 0 0 6px var(--color-accent-soft);
}

#scheduleFundingNotice {
    margin: 0.75rem 0 0;
}

.schedule-notify-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 0.5rem;
    margin: 0.4rem 0 0.6rem;
}

.schedule-notify .schedule-notify-option {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.55rem 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    background: var(--color-bg-secondary);
    transition: border-color 0.15s ease, background 0.15s ease;
}

.schedule-notify .schedule-notify-option:hover {
    border-color: var(--color-border-focus);
}

.schedule-notify .schedule-notify-option:has(input:checked) {
    border-color: var(--color-accent);
    background: var(--color-accent-soft);
}

.schedule-notify .schedule-notify-option input[type="checkbox"] {
    flex: none;
    width: 1rem;
    height: 1rem;
    margin: 0;
    padding: 0;
    accent-color: var(--color-accent);
}

.schedule-notify-who {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.schedule-notify-who strong {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--color-text-primary);
}

.schedule-notify-who small {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.schedule-recipient-list {
    list-style: none;
    margin: 0.4rem 0 0;
    padding: 0;
    display: grid;
    gap: 0.35rem;
}

.schedule-recipient-list li {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.5rem;
    font-size: 0.85rem;
}

.schedule-sendonly-line {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem;
    margin-top: 0.6rem;
    font-size: 0.8rem;
    color: var(--color-text-muted);
}

.funding-flow {
    margin-top: 0.75rem;
    padding: 0.85rem 1rem;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    background: color-mix(in srgb, var(--color-accent) 5%, transparent);
}

.funding-flow-title {
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--color-text-secondary);
    margin-bottom: 0.6rem;
}

.funding-flow-steps {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 1.6rem;
}

.funding-flow-step {
    position: relative;
    display: flex;
    gap: 0.6rem;
    align-items: flex-start;
    padding: 0.65rem 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    background: var(--color-bg-secondary);
}

.funding-flow-step + .funding-flow-step::before {
    content: "→";
    position: absolute;
    left: -1.25rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--color-accent);
    font-weight: 700;
}

.funding-flow-step div {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    min-width: 0;
}

.funding-flow-step strong {
    font-size: 0.85rem;
    color: var(--color-text-primary);
}

.funding-flow-step small {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    line-height: 1.35;
}

.funding-flow-num {
    flex: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.4rem;
    height: 1.4rem;
    border-radius: 50%;
    border: 1px solid var(--color-accent);
    color: var(--color-accent);
    font-size: 0.75rem;
    font-weight: 700;
}

.funding-flow-step--trigger {
    border-color: color-mix(in srgb, var(--color-warning) 55%, var(--color-border));
}

.funding-flow-step--trigger .funding-flow-num {
    border-color: var(--color-warning);
    color: var(--color-warning);
}

.funding-flow-foot {
    display: block;
    margin-top: 0.6rem;
    font-size: 0.75rem;
    color: var(--color-text-muted);
}

@media (max-width: 900px) {
    .funding-flow-steps {
        grid-template-columns: 1fr;
        gap: 1.2rem;
    }

    .funding-flow-step + .funding-flow-step::before {
        content: "↓";
        left: 1.1rem;
        top: -1.1rem;
        transform: none;
    }
}

.schedule-venue-cell {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.25rem;
}

.schedule-sendonly-note {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    cursor: help;
}

/* ==========================================================================
   Page rules — Exchanges
   ========================================================================== */
/* --- Exchange account card (moved from exchanges.html's page <style> block) ---
   .account-grid rides on .kv-grid (auto-fit tracks); only the per-column minimums that keep a
   long venue address from crushing its neighbours are page-specific. */
.account-grid {
    align-items: start;
}

.account-name-col,
.account-type-col {
    min-width: 80px;
}

.account-id-col {
    min-width: 0;
    overflow: hidden;
}

.account-status-col {
    min-width: 60px;
}

/* Hyperliquid address: full on wide screens, truncated on phones (both links are rendered). */
.account-address-truncated {
    display: none;
}

.account-address-full {
    display: inline;
}

/* "Unified" mode marker: a .status-chip--sm in the info tone, beside the mode value. */
.account-mode-badge {
    margin-left: var(--space-2);
    color: var(--color-info);
    vertical-align: middle;
}

.account-secondary-row {
    display: flex;
    gap: var(--space-3);
    align-items: stretch;
    margin-top: var(--space-3);
}

.account-secondary-row .callout {
    flex: 1 1 auto;
    margin-top: 0;
}

.account-mode-col {
    flex: 0 0 auto;
    min-width: 180px;
}

/* Venue breakdown panel sits below the chart row on the overview tab. */
.venue-breakdown {
    min-width: 0;
}

/* Overview NAV chart placeholder: holds the chart's 760x246 aspect (viewBox + wrap padding) so
   the history arriving replaces the spinner in place instead of pushing the sub-tabs down. */
.nav-chart-placeholder {
    aspect-ratio: 760 / 246;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

/* Venue breakdown: the Assets / Positions sub-heads keep a gap above them (.chart-label zeroes
   its own top margin). */
.venue-breakdown-panel .chart-label {
    margin-top: var(--space-3);
}

/* Overview donut legend: items select a venue; the selected one is bold. */
.alloc-legend-item--clickable {
    cursor: pointer;
}

.alloc-legend-item--active {
    font-weight: 700;
}

/* Move Funds banner: a TO chip for a non-transferable selection reads in the error tone. */
.from-to-banner .to-chip--blocked {
    border-color: var(--color-error);
    background: var(--color-error-soft);
}

/* Per-cell buying-power hint on the balances matrix. */
.matrix-bp-hint {
    font-size: 0.68rem;
    font-weight: 400;
    color: var(--color-text-muted);
}

/* Credit breakdown line (total buying power + per-asset detail behind <details>). */
.credit-breakdown {
    font-size: 0.72rem;
}

.credit-breakdown--compact {
    font-size: 0.68rem;
}

.credit-breakdown summary {
    cursor: pointer;
}

/* Move Funds risk preview: two-column origin | destination card. */
.uf-risk-card {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-3);
    padding: 0.6rem var(--space-3);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
}

/* Leverage stage bar: the static frame lives here; each band's left/width and its tone colour are
   the datum and stay inline. */
.uf-stage-bar {
    position: relative;
    height: 14px;
    margin-top: var(--space-2);
    border-radius: 7px;
    overflow: hidden;
    background: var(--color-bg-secondary);
}

.uf-stage-band,
.uf-stage-now,
.uf-stage-tick,
.uf-stage-after {
    position: absolute;
    top: 0;
    bottom: 0;
}

.uf-stage-now {
    left: 0;
    opacity: 0.45;
}

.uf-stage-tick {
    width: 2px;
    background: var(--color-text-muted);
}

.uf-stage-after {
    width: 0;
}

.uf-stage-caption {
    margin-top: var(--space-1);
    color: var(--color-text-muted);
    font-size: 0.68rem;
}

/* One allowed-asset checkbox in the planner / schedule target tables. */
.asset-check {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    font-size: 0.75rem;
    cursor: pointer;
}

/* Leverage slider cell (checkbox + range + readout over a threshold meter). */
.lev-slider-cell {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
    min-width: 9rem;
}

.lev-slider-cell input[type="range"] {
    width: 6rem;
}

.lev-slider-readout {
    min-width: 3rem;
    color: var(--color-text-muted);
    font-size: 0.75rem;
}

.lev-slider-meter {
    max-width: 10rem;
}

/* Intro / warning line directly above a target table. */
.table-intro {
    margin: 0 0 var(--space-2);
    color: var(--color-text-muted);
    font-size: 0.75rem;
}

.table-intro--warning {
    color: var(--color-warning);
    font-size: 0.8rem;
}

/* Bulleted list inside a confirm modal body. */
.modal-list {
    margin: var(--space-2) 0;
    padding-left: 1.25rem;
    font-size: 0.85rem;
}

/* Page-local responsive rules: every selector targets an .account-* class used only on the
   Exchanges account card. */
@media (max-width: 768px) {
    .account-grid {
        grid-template-columns: 1fr 1fr;
        gap: var(--space-4);
    }

    .account-id-col {
        grid-column: 1 / -1;
        order: 3;
    }

    .account-type-col {
        display: none;
    }

    .account-address-truncated {
        display: inline;
    }

    .account-address-full {
        display: none;
    }

    .account-secondary-row {
        flex-direction: column;
    }

    .account-mode-col {
        min-width: 0;
    }
}

/* ==========================================================================
   Page rules — Risk Management (loans.html)
   ========================================================================== */
/* A note slot that keeps its line height while empty, so the field does not jump when the RFQ
   size-math / max-borrow line fills in. Was `style="min-height: 1rem"` on three notes. */
.form-field-note--reserve {
    min-height: 1rem;
}

/* The max-borrow note turns red on a failed lookup. The helper .text-error sits earlier in the
   file than .form-field-note, so on its own it loses the colour to the note's muted rule. */
.form-field-note.text-error {
    color: var(--color-error);
}

/* --- Place near .card h2 / accordion rules --- */
/* A card whose heading is a <details> summary (Allocations): reads at the card-heading step, not
   the 1.3rem the inline style gave it. */
.card-summary-heading {
    cursor: pointer;
    color: var(--color-text-secondary);
    font-size: 1.15rem;
    font-weight: 600;
}

/* --- Place near .quote-card rules --- */
/* Post-acceptance preview under a quote card: one rule above it, every line a tight paragraph. */
.quote-preview {
    margin-top: var(--space-2);
    padding-top: var(--space-2);
    border-top: 1px solid var(--color-border);
}

.quote-preview p {
    margin: var(--space-1) 0 0;
}

/* Acknowledgment checkbox row: box top-aligned with a wrapping sentence. */
.quote-preview-ack {
    display: flex;
    align-items: flex-start;
    gap: var(--space-2);
    margin-top: var(--space-2);
    font-size: 0.85rem;
}

/* Read-only allowed-symbols disclosure on a quote. */
.quote-whitelist {
    margin-top: var(--space-2);
}

.quote-whitelist > summary {
    cursor: pointer;
    color: var(--color-text-muted);
}

.quote-whitelist-body {
    padding: var(--space-2) 0;
}

/* --- Place near .reason-list rules --- */
/* One bullet line in the compact "Why <status>" driver list. */
.risk-why-line {
    padding: 0.1rem 0;
    line-height: 1.4;
}

/* A callout carrying a one-click action on its right (the vault-parked borrowed-asset notice with
   its Move Funds button): text left, button right, wraps under on narrow screens. */
.callout-cta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: var(--space-3);
}

.callout-cta p {
    margin: 0.1rem 0;
}

/* A terms input sitting inline after its label (the per-exchange / collateral-weight rows of the
   buy-side limits editor) — fixed width instead of the grid cell's 100%. */
.terms-input--inline {
    width: 7rem;
    min-width: 0;
}

/* Buy-side limits editor (inside a .data-panel body). */
.limits-editor > .subsection-title:first-child {
    margin-top: 0;
}

.limits-editor-row {
    margin-bottom: var(--space-1);
}

/* Row key (venue / asset) column so the inputs line up row to row. */
.limits-editor-key {
    display: inline-block;
    min-width: 8rem;
}

.limits-editor-key--narrow {
    min-width: 6rem;
}

/* --- Place near the early-payback panel / .input-with-action --- */
/* Early-payback quantity field on its action row (beside Max + Pay back). */
.payback-qty-input {
    width: 14rem;
    padding: 0.4rem 0.5rem;
    background: var(--color-bg-secondary);
    color: var(--color-text-primary);
    border: 1px solid var(--color-border);
    border-radius: 4px;
    font-size: 0.9rem;
}

.payback-qty-input:focus {
    outline: none;
    border-color: var(--color-border-focus);
}

/* ==========================================================================
   Page rules — Risk Management includes
   ========================================================================== */
/* Risk-action panels: one outlined panel per engine decision family (venue-scoped reduction,
   hedge ladder, cross-venue moves, breach scope, proceeds sweep, stressed loan liability). The
   border colour is set inline by the caller because it is the decision's tone — the datum. These
   were the same five-property inline object retyped at nine call sites. */
.risk-action-panel {
    margin-top: var(--space-4);
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
}
.risk-action-panel--compact { margin-top: var(--space-2); }
/* "Not in this snapshot": a placeholder panel, so its outline is dashed rather than toned. */
.risk-action-panel--dashed { border-style: dashed; }
.risk-action-title { margin: 0 0 0.2rem; }
/* One decision inside a panel (a ladder step, a reduced venue, a sweep leg). */
.risk-action-card {
    display: grid;
    gap: 0.2rem;
    margin-top: var(--space-2);
    padding: 0.55rem 0.7rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
}
/* The muted explanatory line. These are assembled lowercase from engine words ("evaluated …",
   "skipped binance: …"), so the casing hook capitalises them here (§8) rather than at each of
   the ~40 call sites — and without touching the strings the source-text tests pin. */
.risk-action-line {
    color: var(--color-text-muted);
    font-size: 0.75rem;
    line-height: 1.4;
}
/* "label: value" row inside a decision card. */
.risk-action-row { font-size: 0.8rem; }
.risk-action-line::first-letter,
.risk-action-row::first-letter,
.risk-figure-row > :first-child::first-letter,
.risk-action-panel .status-chip::first-letter {
    text-transform: uppercase;
}
/* The ladder step's imperative headline (tone colour inline). */
.risk-action-headline {
    font-size: 0.9rem;
    font-weight: 600;
}
/* A held reason / "N legs need a human": one step up from the muted line. */
.risk-action-note {
    font-size: 0.85rem;
    line-height: 1.4;
}
/* The plain-language sentence a panel opens with (stressed loan liability). */
.risk-action-lead {
    margin: 0 0 var(--space-2);
    color: var(--color-text-muted);
    font-size: 0.85rem;
    line-height: 1.45;
}
.risk-action-lead:last-child { margin-bottom: 0; }

/* Cross-venue move list: one relocation per row, ruled between rows. */
.risk-move-list {
    display: grid;
    gap: 0.1rem;
    margin-top: var(--space-2);
}
.risk-move-list-title {
    font-size: 0.85rem;
    font-weight: 600;
}
.risk-move-plan {
    display: grid;
    gap: 0.15rem;
}
.risk-move-row {
    display: grid;
    gap: 0.1rem;
    padding: 0.35rem 0;
    border-top: 1px solid var(--color-border);
}
.risk-move-headline {
    font-size: 0.85rem;
    font-weight: 600;
}
.risk-move-qty {
    color: var(--color-text-muted);
    font-weight: 400;
}

/* Label-left / figure-right row (stressed loan liability). The value's tone colour is inline. */
.risk-figure-row {
    display: flex;
    justify-content: space-between;
    gap: var(--space-4);
    padding: 0.2rem 0;
    font-size: 0.85rem;
}
.risk-figure-value {
    color: var(--color-text-primary);
    font-variant-numeric: tabular-nums;
}
/* A leverage figure the LENDER enforces (haircut basis) — the accent marks the authority. */
.risk-figure--lender { color: var(--color-accent); }

/* Heading + body lines of a notice that carries more than one paragraph (buy-to-cover). The
   heading inherits the callout's tone colour. */
.callout-heading {
    margin: 0 0 var(--space-2);
    font-size: 1rem;
}
.callout-line { margin: var(--space-1) 0; }
.callout-line--label { margin: var(--space-2) 0 0; }

/* ==========================================================================
   Page rules — Risk Analytics, loan shocks, liquidation guide, charts
   ========================================================================== */
/* ==========================================================================
   Risk Analytics (stress_test.html) — moved from the page-local <style> block.
   Everything structural on the page is the shared system (.ra-tabs, .metric-*,
   .table-scroll/.dense-table, .guide-table, .status-chip, .page-note). Only rules
   with no shared equivalent live here. Dead page rules dropped on the move:
   .side-long/.side-short (no callers), .stale (→ .text-muted .text-xs).
   ========================================================================== */
.stress-grid { display: grid; grid-template-columns: minmax(300px, 380px) minmax(0, 1fr); gap: 1rem; align-items: start; }
@media (max-width: 900px) { .stress-grid { grid-template-columns: minmax(0, 1fr); } }
/* Venue maintenance-margin BANDS (0.60 trading control / 0.75 reduce-only) — a different
   vocabulary from the lender rung ladder, which is why these are not .metric-value--*. */
.usage-ok { color: var(--color-success); }
.usage-warn { color: var(--color-warning); }
.usage-danger { color: var(--color-error); }
/* Fixed tracks (checkbox / label / value) so the drawdown values line up down the list; the
   detail line breaks under the symbol instead of pushing the value around per-row. */
.collateral-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 0.5rem; padding: 0.4rem 0; border-bottom: 1px solid var(--color-border); }
.collateral-row label { font-weight: 500; min-width: 0; }
.collateral-row .usd { display: block; color: var(--color-text-muted); font-size: 0.75rem; font-weight: 400; }
.shock-slider { width: 100%; }
.shock-value { min-width: 3.5rem; text-align: right; font-variant-numeric: tabular-nums; }
/* Slider + its live value on one non-wrapping line (the slider takes the rest). */
.shock-slider-row { display: flex; align-items: center; gap: var(--space-3); }
.stressed-cell { font-weight: 600; }
/* Row tints on the dense grids. The sticky first column paints its own opaque background, so
   the translucent tint is composited over the card base there (same trick as the lender book's
   .is-selected row) — without it the tint stops dead at the frozen column. */
.liq-close { background: var(--color-error-soft); }
.row-danger { background: var(--color-error-soft); }
.dense-table tbody tr.liq-close td:first-child,
.dense-table tbody tr.row-danger td:first-child {
    background: linear-gradient(var(--color-error-soft), var(--color-error-soft)), var(--color-bg-card);
}
/* Inline muted remark (a figure's aside, a table footnote). Paragraph-level explanatory copy
   uses the shared .page-note instead. --sm for chart legends / table footnotes. */
.muted-note { font-size: 0.85rem; color: var(--color-text-muted); }
.muted-note--sm { font-size: 0.75rem; }
/* Single-asset impact (tornado) rows: symbol | track | usage → usage | liquidations. The bar
   widths and band colour stay inline (per-row geometry, colour is the datum). */
.tornado-row { display: flex; align-items: center; gap: var(--space-2); margin: var(--space-1) 0; }
.tornado-label { width: 4.5rem; font-weight: 600; }
.tornado-track { flex: 1; background: var(--color-border-subtle); border-radius: 4px; height: 18px; position: relative; }
.tornado-bar { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 4px; }
.tornado-bar--stressed { opacity: 0.35; }
.tornado-value { width: 8.5rem; text-align: right; font-variant-numeric: tabular-nums; }
.tornado-liq { width: 4rem; text-align: right; color: var(--color-error); font-size: 0.75rem; }
.loan-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--color-accent-light); margin-left: 4px; }
.stress-detail-header { display: flex; gap: 0.75rem; align-items: center; flex-wrap: wrap; margin-top: 1.25rem; border-top: 1px solid var(--color-border); padding-top: 1rem; }
.stress-detail-header h2 { margin: 0; }
.stress-detail-header > .btn { margin-left: auto; }
/* Horizontal scroll for a wide SVG/figure that is not a table (tables use .table-scroll). */
.scroll-x { overflow-x: auto; }
/* The shock tool's free-text inputs (adjust-position delta, hypothetical-exposure fields).
   The old selector said `table.shock-matrix input`, but #shockMatrix is a div — it matched
   nothing and the inputs rendered unthemed. */
/* The in-table Δ inputs only; the hypothetical-position form uses the standard .form-field input. */
#loanShockTool input.shock-pos-delta { background: var(--color-bg-dark); color: var(--color-text-primary); border: 1px solid var(--color-border); border-radius: 4px; padding: 0.15rem 0.3rem; }
/* The liability panel carries only a top margin (it renders in other mounts too); here its
   next sibling is the margin-usage card, so without this they sit flush against each other.
   Scoped to the mount: an empty #loanLiabilityStress (no loan) contributes no phantom gap. */
#loanLiabilityStress > :last-child { margin-bottom: 1rem; }

/* ==========================================================================
   Loan shock tool (includes/loan_shocks.js.html) — was inline style strings.
   ========================================================================== */
/* Results go stale while a re-run is in flight; the note says so above the old figures. */
.shock-stale-note { color: var(--color-warning); font-size: 0.85rem; font-weight: 600; }
/* The "held as …" venue breakdown under a currency's holdings line. */
.shock-axis-held-as { display: block; }
/* The reader's adjusted size, the second line in a position's Size cell. */
.shock-scenario-size { font-weight: 600; color: var(--color-accent); }
.shock-pos-delta { width: 4rem; text-align: right; }
/* Shock card + positions | results: two columns that fold to one under ~800px. */
.shock-layout { display: grid; grid-template-columns: repeat(auto-fit, minmax(400px, 1fr)); gap: var(--space-4); align-items: start; }
/* Fixed column layout: long account names wrap instead of forcing a horizontal scrollbar.
   Column widths stay on the <colgroup> (per-table geometry). */
.guide-table--fixed { table-layout: fixed; }
/* .muted-note modifiers — modifiers, not the shared .text-* helpers, because .muted-note sets its
   own size/colour and sits later in the cascade. */
.muted-note--xs { font-size: 0.72rem; }
.muted-note--warning { color: var(--color-warning); }

/* ==========================================================================
   Time-series chart (charts.js renderTimeSeriesChart) — was inline style objects.
   Line/swatch colours and the tooltip's position stay inline (datum / per-hover geometry).
   ========================================================================== */
.ts-chart {
    position: relative;
    margin-top: var(--space-4);
    padding: var(--space-3);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    background: var(--color-bg-secondary);
}
.ts-chart-title { display: block; margin-bottom: var(--space-1); }
.ts-chart-tooltip {
    position: absolute;
    z-index: 2;
    pointer-events: none;
    left: 0;
    top: 0;
    padding: 0.4rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    background: var(--color-bg-primary);
    border: 1px solid var(--color-border);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
    white-space: nowrap;
}
.ts-chart-legend { display: flex; flex-wrap: wrap; gap: var(--space-3); margin-top: var(--space-2); }
.ts-chart-legend-item { display: flex; align-items: center; gap: var(--space-1); }
.ts-chart-swatch { display: inline-block; width: 10px; height: 10px; border-radius: 2px; }

/* ==========================================================================
   Page rules — Vault, portfolio.js, common.js, API tokens, lender dashboard, billing
   ========================================================================== */
/* portfolio.js — donut centre label: static centring (was an inline style object);
   the per-instance max-width (hole diameter) stays inline. Place next to .donut-center-value. */
.donut-center {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    pointer-events: none;
}

/* portfolio.js — venue badge used as a drill-in control in matrix headers. Place next to .venue-badge. */
.venue-badge--clickable { cursor: pointer; }

/* portfolio.js — exchange summary one-liner (equity · accounts · positions): wider column gap
   than .inline-row so the three facts read as separate items. */
.exchange-summary-strip { gap: var(--space-2) var(--space-4); }

/* vault.html — balanceDetailLine: one available/held/pending line on a balance card
   (muted label + brighter tabular value). Place next to .balance-detail-block. */
.balance-detail-line {
    display: flex;
    justify-content: center;
    gap: 0.35rem;
    font-size: 0.8rem;
    line-height: 1.6;
    white-space: nowrap;
}
.balance-detail-line--end { justify-content: flex-end; }
.balance-detail-value {
    color: var(--color-text-primary);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

/* api_tokens.html — two row buttons side by side in one .cell-action td. */
.cell-action .btn + .btn { margin-left: var(--space-1); }

/* api_tokens.html — create-token form + one-time token reveal overlay (was all inline style="").
   The overlay keeps its own fixed backdrop (it is not a <dialog>; JS toggles .hidden + display). */
.token-mono-input { font-family: monospace; }
.token-row--inactive { opacity: 0.6; }
.token-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(10, 14, 20, 0.7); /* same scrim as .modal::backdrop */
}
.token-modal {
    position: relative;
    width: 90%;
    max-width: 600px;
    margin: 2rem;
}
.token-modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: none;
    border: none;
    font-size: 1.15rem;
    color: var(--color-text-muted);
    cursor: pointer;
    transition: color 0.2s;
}
.token-modal-close:hover { color: var(--color-text-primary); }
.token-secret,
.token-usage {
    display: block;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-family: monospace;
    font-size: 0.85rem;
    word-break: break-all;
}
.token-secret {
    flex: 1;
    background: var(--color-bg-dark);
    color: var(--color-text-light);
}
.token-usage {
    background: var(--color-bg-secondary);
    color: var(--color-text-primary);
}

/* lender/dashboard.html — the single-column quote form (rows + term editor span 1 / -1 inline). */
.quote-form {
    display: grid;
    gap: var(--space-3);
}

/* fee_filters.js.html — the Firm filter starts a second group on the same row. */
.fee-filter-firm-label { margin-left: var(--space-3); }

/* vault.html — compact balance card (vault with < 3 balances): coin + big balance left, detail
   lines right. Hero value keeps its own size (§1 hero exemption). */
.balance-amount--compact { margin-bottom: 0; font-size: 1.4rem; }
.balance-card-details--compact { min-width: 10rem; }
.balance-card h3.balance-card-title--compact { margin-bottom: var(--space-1); }

/* vault.html — 16px spinner inside a .callout--row (pending-withdrawal banner). Two-class
   selector so it beats .spinner's 40px even though spinners.css loads after theme.css. */
.spinner.spinner--inline { width: 16px; height: 16px; border-width: 2px; flex: 0 0 auto; }

/* ==========================================================================
   Text + layout helpers — the fold targets for one-off inline style objects
   (docs/ui-design-standard.md §0.3). Spacing is the --space-* scale; sizes are
   the §1 type scale. Compose them (`text-muted text-sm mt-half`) rather than
   adding a near-duplicate rule.
   KEEP THIS BLOCK LAST: a helper must beat the component rule it is combined
   with at equal specificity (`inline-link text-muted`, `mini-panel-line mt-1`).
   ========================================================================== */
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.m-0 { margin: 0; }
.mt-half { margin-top: var(--space-1); }
.mb-half { margin-bottom: var(--space-1); }
.text-muted { color: var(--color-text-muted); }
.text-primary { color: var(--color-text-primary); }
.text-success { color: var(--color-success); }
.text-warning { color: var(--color-warning); }
.text-error { color: var(--color-error); }
.text-xs { font-size: 0.72rem; }
.text-sm { font-size: 0.8rem; }
.text-md { font-size: 0.85rem; }
.text-strong { font-weight: 600; }
.text-bold { font-weight: 700; }
.text-nowrap { white-space: nowrap; }
.w-full { width: 100%; }
/* Horizontal run of controls/chips: wraps, vertically centred. */
.inline-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--space-2);
}
.inline-row--tight { gap: var(--space-1); }
/* Stays in the text flow (a venue badge + account name inside a table cell). */
.inline-row--inline { display: inline-flex; }
.inline-row--baseline { align-items: baseline; }
.inline-row--between { justify-content: space-between; }
/* Vertical run of blocks with one gap. */
.stack {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}
