/* ══════════════════════════════════════════════════════════════════════════
   Global Transaction Banking Suite — design system

   Chrome  : Google Material tokens (surfaces, elevation, type, shape).
   Data     : the pre-validated dataviz reference palette. Slot ORDER is the
              colourblind-safety mechanism — never reorder or cycle past 8.

   The chart surface (--surface-1) keeps the palette's own validated values
   rather than Material's, because the dark series steps were chosen for >=3:1
   against #1a1a19; Material's lighter #292a2d would erode that margin.
   ══════════════════════════════════════════════════════════════════════════ */

:root {
    /* ── Material chrome (light) ─────────────────────────────────────────── */
    --md-bg: #f8f9fa;
    --md-surface: #ffffff;
    --md-surface-2: #f1f3f4;
    --md-surface-3: #e8eaed;
    --md-outline: #dadce0;
    --md-outline-soft: #e8eaed;
    --md-primary: #1a73e8;
    --md-primary-wash: rgba(26, 115, 232, 0.08);
    --md-on-primary: #ffffff;

    --md-text: #202124;
    --md-text-2: #5f6368;
    --md-text-3: #80868b;

    --md-shadow-1: 0 1px 2px 0 rgba(60, 64, 67, .3), 0 1px 3px 1px rgba(60, 64, 67, .15);
    --md-shadow-2: 0 1px 3px 0 rgba(60, 64, 67, .3), 0 4px 8px 3px rgba(60, 64, 67, .15);

    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 16px;
    --radius-pill: 999px;

    --font: 'Google Sans', 'Roboto', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --font-mono: 'Roboto Mono', ui-monospace, 'Cascadia Code', monospace;

    /* ── Chart surface & ink (validated values) ──────────────────────────── */
    --surface-1: #fcfcfb;
    --text-primary: #0b0b0b;
    --text-secondary: #52514e;
    --text-muted: #898781;
    --gridline: #e1e0d9;
    --baseline: #c3c2b7;

    /* ── Categorical: fixed order, never cycled ──────────────────────────── */
    --series-1: #2a78d6;
    --series-2: #1baf7a;
    --series-3: #eda100;
    --series-4: #008300;
    --series-5: #4a3aa7;
    --series-6: #e34948;
    --series-7: #e87ba4;
    --series-8: #eb6834;

    /* ── Sequential: one hue, light -> dark ──────────────────────────────── */
    --seq-100: #cde2fb;
    --seq-150: #b7d3f6;
    --seq-200: #9ec5f4;
    --seq-250: #86b6ef;
    --seq-300: #6da7ec;
    --seq-350: #5598e7;
    --seq-400: #3987e5;
    --seq-450: #2a78d6;
    --seq-500: #256abf;
    --seq-550: #1c5cab;
    --seq-600: #184f95;
    --seq-650: #104281;
    --seq-700: #0d366b;

    /* ── Status: reserved, never used as a series colour ─────────────────── */
    --status-good: #0ca30c;
    --status-warning: #fab219;
    --status-serious: #ec835a;
    --status-critical: #d03b3b;
    --status-neutral: #898781;
}

:root[data-theme="dark"],
html.dark {
    --md-bg: #202124;
    --md-surface: #292a2d;
    --md-surface-2: #303134;
    --md-surface-3: #3c4043;
    --md-outline: #3c4043;
    --md-outline-soft: #303134;
    --md-primary: #8ab4f8;
    --md-primary-wash: rgba(138, 180, 248, 0.12);
    --md-on-primary: #202124;

    --md-text: #e8eaed;
    --md-text-2: #9aa0a6;
    --md-text-3: #80868b;

    --md-shadow-1: 0 1px 2px 0 rgba(0, 0, 0, .3), 0 1px 3px 1px rgba(0, 0, 0, .15);
    --md-shadow-2: 0 1px 3px 0 rgba(0, 0, 0, .3), 0 4px 8px 3px rgba(0, 0, 0, .15);

    /* Validated dark surface — deliberately deeper than --md-surface. */
    --surface-1: #1a1a19;
    --text-primary: #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted: #898781;
    --gridline: #2c2c2a;
    --baseline: #383835;

    --series-1: #3987e5;
    --series-2: #199e70;
    --series-3: #c98500;
    --series-4: #008300;
    --series-5: #9085e9;
    --series-6: #e66767;
    --series-7: #d55181;
    --series-8: #d95926;

    --seq-100: #0d366b;
    --seq-150: #104281;
    --seq-200: #184f95;
    --seq-250: #1c5cab;
    --seq-300: #256abf;
    --seq-350: #2a78d6;
    --seq-400: #3987e5;
    --seq-450: #5598e7;
    --seq-500: #6da7ec;
    --seq-550: #86b6ef;
    --seq-600: #9ec5f4;
    --seq-650: #b7d3f6;
    --seq-700: #cde2fb;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
}

body {
    background: var(--md-bg);
    color: var(--md-text);
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--md-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.visually-hidden {
    position: absolute; width: 1px; height: 1px;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}

/* ── App shell ───────────────────────────────────────────────────────────── */

.app { display: grid; grid-template-columns: 256px 1fr; min-height: 100vh; }

.rail {
    background: var(--md-surface);
    border-right: 1px solid var(--md-outline);
    padding: 12px 8px;
    position: sticky; top: 0; height: 100vh; overflow-y: auto;
}

.rail-brand {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 16px 20px;
    font-size: 1.05rem; font-weight: 500; letter-spacing: -0.2px;
}
.rail-brand .mark {
    width: 32px; height: 32px; border-radius: 8px; flex: none;
    background: var(--md-primary); color: var(--md-on-primary);
    display: grid; place-items: center; font-weight: 700; font-size: .85rem;
}

.rail-group { margin-bottom: 4px; }
.rail-heading {
    padding: 14px 16px 6px; font-size: .6875rem; font-weight: 500;
    letter-spacing: .8px; text-transform: uppercase; color: var(--md-text-3);
}

.rail-item {
    display: flex; align-items: center; gap: 14px;
    padding: 9px 16px; margin: 1px 4px;
    border-radius: var(--radius-pill);
    color: var(--md-text-2); font-size: .875rem; font-weight: 500;
    text-decoration: none; transition: background .15s, color .15s;
}
.rail-item:hover { background: var(--md-surface-2); color: var(--md-text); text-decoration: none; }
.rail-item.active { background: var(--md-primary-wash); color: var(--md-primary); }
.rail-item .ico { width: 18px; text-align: center; flex: none; }
.rail-item .count {
    margin-left: auto; font-size: .75rem; font-weight: 500;
    background: var(--md-surface-3); color: var(--md-text-2);
    border-radius: var(--radius-pill); padding: 1px 8px;
}
.rail-item.active .count { background: var(--md-primary); color: var(--md-on-primary); }

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

.topbar {
    display: flex; align-items: center; gap: 16px;
    padding: 14px 28px;
    background: var(--md-surface);
    border-bottom: 1px solid var(--md-outline);
    position: sticky; top: 0; z-index: 20;
}
.topbar h1 { font-size: 1.25rem; font-weight: 400; margin: 0; letter-spacing: -.2px; }
.topbar .spacer { flex: 1; }

.persona {
    display: flex; align-items: center; gap: 10px;
    padding: 5px 6px 5px 14px; border: 1px solid var(--md-outline);
    border-radius: var(--radius-pill); background: transparent;
    color: var(--md-text-2); font: inherit; font-size: .8125rem; cursor: pointer;
}
.persona:hover { background: var(--md-surface-2); }
.avatar {
    width: 28px; height: 28px; border-radius: 50%; flex: none;
    background: var(--md-primary); color: var(--md-on-primary);
    display: grid; place-items: center; font-size: .75rem; font-weight: 500;
}

.icon-btn {
    width: 36px; height: 36px; border-radius: 50%; border: none;
    background: transparent; color: var(--md-text-2); cursor: pointer;
    display: grid; place-items: center; font-size: 1rem;
}
.icon-btn:hover { background: var(--md-surface-2); color: var(--md-text); }

.content { padding: 24px 28px 64px; max-width: 1600px; width: 100%; }

/* ── Cards & grid ────────────────────────────────────────────────────────── */

.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.split { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }

.card {
    background: var(--md-surface);
    border: 1px solid var(--md-outline-soft);
    border-radius: var(--radius-lg);
    padding: 20px;
    min-width: 0;
}
.card.pad-0 { padding: 0; overflow: hidden; }
.card.elevated { box-shadow: var(--md-shadow-1); border-color: transparent; }

.card-head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 16px; }
.card-head h2, .card-head h3 {
    margin: 0; font-size: .9375rem; font-weight: 500; letter-spacing: -.1px;
}
.card-head .sub { margin: 2px 0 0; font-size: .8125rem; color: var(--md-text-2); }
.card-head .spacer { flex: 1; }

/* Charts render on the validated chart surface, not the Material card surface. */
.chart-surface {
    background: var(--surface-1);
    border-radius: var(--radius);
    padding: 12px 8px 4px;
}

/* ── Stat tiles & hero ───────────────────────────────────────────────────── */

.stat {
    background: var(--md-surface);
    border: 1px solid var(--md-outline-soft);
    border-radius: var(--radius-lg);
    padding: 18px 20px;
    display: flex; flex-direction: column; gap: 6px; min-width: 0;
}
.stat .label { font-size: .8125rem; color: var(--md-text-2); }
/* Proportional figures: tabular-nums makes 121 look loose at display sizes. */
.stat .value { font-size: 1.75rem; font-weight: 500; letter-spacing: -.5px; line-height: 1.15; }
.stat .foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 2px; }
.stat .delta { font-size: .8125rem; font-weight: 500; display: inline-flex; align-items: center; gap: 4px; }
.stat .delta.up { color: var(--status-good); }
.stat .delta.down { color: var(--status-critical); }
.stat .delta.flat { color: var(--md-text-2); }

.hero-figure { font-size: 3rem; font-weight: 500; letter-spacing: -1.5px; line-height: 1; }
.hero-sub { color: var(--md-text-2); font-size: .875rem; margin-top: 6px; }

/* ── Badges, chips, pills ────────────────────────────────────────────────── */

.badge {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 3px 10px; border-radius: var(--radius-pill);
    font-size: .75rem; font-weight: 500; white-space: nowrap;
}
/* Status never rides on colour alone — every badge carries an icon and a label. */
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.badge.good     { color: #0a7d0a; background: rgba(12, 163, 12, .12); }
.badge.warning  { color: #8a5b00; background: rgba(250, 178, 25, .16); }
.badge.serious  { color: #a64b22; background: rgba(236, 131, 90, .16); }
.badge.critical { color: #b32626; background: rgba(208, 59, 59, .12); }
.badge.neutral  { color: var(--md-text-2); background: var(--md-surface-3); }

:root[data-theme="dark"] .badge.good     { color: #6dd36d; }
:root[data-theme="dark"] .badge.warning  { color: #fdd663; }
:root[data-theme="dark"] .badge.serious  { color: #f2a181; }
:root[data-theme="dark"] .badge.critical { color: #f28b82; }

.chip {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 6px 14px; border-radius: var(--radius-pill);
    border: 1px solid var(--md-outline); background: transparent;
    color: var(--md-text-2); font: inherit; font-size: .8125rem; cursor: pointer;
    text-decoration: none;
}
.chip:hover { background: var(--md-surface-2); text-decoration: none; }
.chip.active { background: var(--md-primary-wash); border-color: transparent; color: var(--md-primary); }

.filter-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; align-items: center; }

.tier { font-size: .6875rem; font-weight: 600; letter-spacing: .5px; text-transform: uppercase; }
.tier.PLATINUM { color: #5f6368; }
.tier.GOLD { color: #b8860b; }
.tier.SILVER { color: #7d8085; }
.tier.BRONZE { color: #a1662f; }
.tier.UNRATED { color: var(--md-text-3); }

/* ── Buttons & forms ─────────────────────────────────────────────────────── */

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 9px 24px; border-radius: var(--radius-pill);
    border: 1px solid transparent; font: inherit; font-size: .875rem; font-weight: 500;
    cursor: pointer; text-decoration: none; transition: box-shadow .15s, background .15s;
}
.btn:hover { text-decoration: none; }
.btn-filled { background: var(--md-primary); color: var(--md-on-primary); }
.btn-filled:hover { box-shadow: var(--md-shadow-1); }
.btn-tonal { background: var(--md-primary-wash); color: var(--md-primary); }
.btn-outlined { border-color: var(--md-outline); color: var(--md-primary); background: transparent; }
.btn-text { color: var(--md-primary); background: transparent; padding: 9px 12px; }
.btn-danger { background: var(--status-critical); color: #fff; }
.btn:disabled { opacity: .38; cursor: not-allowed; box-shadow: none; }
.btn-sm { padding: 6px 16px; font-size: .8125rem; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; min-width: 0; }
.field label { font-size: .8125rem; color: var(--md-text-2); font-weight: 500; }
.field input, .field select, .field textarea {
    padding: 11px 14px; border: 1px solid var(--md-outline); border-radius: var(--radius-sm);
    background: var(--md-surface); color: var(--md-text); font: inherit; font-size: .875rem;
    width: 100%;
}
.field input:focus, .field select:focus, .field textarea:focus {
    outline: none; border-color: var(--md-primary); box-shadow: 0 0 0 1px var(--md-primary);
}
.field .hint { font-size: .75rem; color: var(--md-text-3); }
.field.error input, .field.error textarea { border-color: var(--status-critical); }
.field .err { font-size: .75rem; color: var(--status-critical); }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 20px; }

/* ── Tables ──────────────────────────────────────────────────────────────── */

.table-wrap { overflow-x: auto; }

table.data { width: 100%; border-collapse: collapse; font-size: .8125rem; }
table.data caption { text-align: left; padding: 0 20px 12px; color: var(--md-text-2); }
table.data th {
    text-align: left; font-weight: 500; color: var(--md-text-2);
    padding: 12px 16px; border-bottom: 1px solid var(--md-outline);
    white-space: nowrap; font-size: .75rem; letter-spacing: .3px; text-transform: uppercase;
}
table.data td {
    padding: 13px 16px; border-bottom: 1px solid var(--md-outline-soft);
    vertical-align: middle;
}
table.data tbody tr:hover { background: var(--md-surface-2); }
table.data tbody tr:last-child td { border-bottom: none; }
/* Columns of numbers align; standalone display figures do not use tabular-nums. */
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data td.mono { font-family: var(--font-mono); font-size: .75rem; color: var(--md-text-2); }
table.data .row-link { color: var(--md-text); font-weight: 500; }

.empty-state { padding: 56px 20px; text-align: center; color: var(--md-text-2); }
.empty-state .ico { font-size: 2rem; color: var(--md-text-3); margin-bottom: 12px; }

/* ── Charts ──────────────────────────────────────────────────────────────── */

.tb-chart { display: block; overflow: visible; }
.tb-chart text { font-family: var(--font); }
.tb-axis-label { font-size: 10.5px; fill: var(--text-muted); }
.tb-axis-tick { font-size: 10.5px; fill: var(--text-muted); font-variant-numeric: tabular-nums; }
.tb-axis-value { font-size: 11px; fill: var(--text-secondary); font-weight: 500; }
.tb-donut-value { font-size: 20px; font-weight: 500; fill: var(--text-primary); }
.tb-gauge-value { font-size: 22px; font-weight: 500; fill: var(--text-primary); }

.tb-mark { cursor: pointer; transition: opacity .12s; }
.tb-mark:hover, .tb-mark:focus-visible { opacity: .82; outline: none; }
.tb-sparkline .tb-mark { cursor: default; }

.tb-legend {
    list-style: none; display: flex; flex-wrap: wrap; gap: 6px 18px;
    margin: 12px 0 0; padding: 0 8px; font-size: .75rem; color: var(--md-text-2);
}
.tb-legend li { display: flex; align-items: center; gap: 7px; }
.tb-legend-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }

.tb-table-view { margin-top: 12px; font-size: .8125rem; }
.tb-table-view summary {
    cursor: pointer; color: var(--md-text-2); font-size: .75rem;
    padding: 6px 8px; border-radius: var(--radius-sm); list-style-position: inside;
}
.tb-table-view summary:hover { background: var(--md-surface-2); }
.tb-table-view table { width: 100%; border-collapse: collapse; margin-top: 8px; }
.tb-table-view th, .tb-table-view td {
    padding: 6px 10px; border-bottom: 1px solid var(--md-outline-soft); text-align: left;
}
.tb-table-view th { color: var(--md-text-2); font-weight: 500; }
.tb-table-view td { font-variant-numeric: tabular-nums; }

/* Tooltips enhance; they never gate a value. Every chart also has a table view. */
#tb-tooltip {
    position: fixed; z-index: 100; pointer-events: none; opacity: 0;
    transform: translate(-50%, -130%); transition: opacity .1s;
    background: var(--md-text); color: var(--md-surface);
    padding: 6px 10px; border-radius: 6px; font-size: .75rem; white-space: nowrap;
    box-shadow: var(--md-shadow-2);
}
#tb-tooltip.show { opacity: 1; }

/* ── Flash messages ──────────────────────────────────────────────────────── */

.flash {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 18px; border-radius: var(--radius); margin-bottom: 16px;
    font-size: .875rem;
}
.flash.success { background: rgba(12, 163, 12, .12); color: #0a7d0a; }
.flash.error { background: rgba(208, 59, 59, .12); color: #b32626; }
.flash.info { background: var(--md-primary-wash); color: var(--md-primary); }

/* ── Timeline / detail panes ─────────────────────────────────────────────── */

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: flex; gap: 14px; padding: 10px 0; }
.timeline .node {
    width: 10px; height: 10px; border-radius: 50%; flex: none; margin-top: 6px;
    background: var(--md-primary); box-shadow: 0 0 0 3px var(--md-primary-wash);
}
.timeline .body { min-width: 0; }
.timeline .when { font-size: .75rem; color: var(--md-text-3); }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 10px 20px; font-size: .8125rem; }
.kv dt { color: var(--md-text-2); }
.kv dd { margin: 0; font-weight: 500; }

.sla-cell { display: flex; align-items: center; gap: 8px; }
.sla-cell .t { font-variant-numeric: tabular-nums; font-size: .75rem; min-width: 34px; }

/* ── Responsive ──────────────────────────────────────────────────────────── */

@media (max-width: 1200px) {
    .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .grid.split { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 960px) {
    .app { grid-template-columns: 1fr; }
    .rail { position: static; height: auto; border-right: none; border-bottom: 1px solid var(--md-outline); }
    .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: minmax(0, 1fr); }
    .form-grid { grid-template-columns: minmax(0, 1fr); }
    .content { padding: 16px; }
}

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; animation: none !important; }
}

@media print {
    .rail, .topbar, .tb-table-view summary, .tb-asst-launch, .tb-asst { display: none; }
    .card { break-inside: avoid; }
}

/* ── Inline help: info dots and self-explaining terms ─────────────────────── */

.tb-tip {
    display: inline-flex; align-items: center; justify-content: center;
    margin-left: 5px; color: var(--md-text-3); font-size: .8125rem;
    cursor: help; vertical-align: middle; line-height: 1;
}
.tb-tip:hover, .tb-tip:focus-visible { color: var(--md-primary); outline: none; }

.tb-term {
    border-bottom: 1px dotted var(--md-text-3); cursor: help;
    text-decoration: none; color: inherit;
}
.tb-term:hover, .tb-term:focus-visible { border-bottom-color: var(--md-primary); color: var(--md-primary); outline: none; }

.tb-help-link {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: .75rem; color: var(--md-text-2); text-decoration: none;
}
.tb-help-link:hover { color: var(--md-primary); text-decoration: none; }

/* ── Assistant ───────────────────────────────────────────────────────────── */

.tb-asst-launch {
    position: fixed; right: 24px; bottom: 24px; z-index: 60;
    display: inline-flex; align-items: center; gap: 9px;
    padding: 12px 20px; border: none; border-radius: var(--radius-pill);
    background: var(--md-primary); color: var(--md-on-primary);
    font: inherit; font-size: .875rem; font-weight: 500; cursor: pointer;
    box-shadow: var(--md-shadow-2);
}
.tb-asst-launch i { font-size: 1rem; }
.tb-asst-launch:hover { filter: brightness(1.05); }

.tb-asst {
    position: fixed; right: 24px; bottom: 24px; z-index: 61;
    width: 380px; max-width: calc(100vw - 32px);
    height: 560px; max-height: calc(100vh - 48px);
    display: none; flex-direction: column;
    background: var(--md-surface); border: 1px solid var(--md-outline);
    border-radius: var(--radius-lg); box-shadow: var(--md-shadow-2); overflow: hidden;
}
.tb-asst.open { display: flex; }

.tb-asst-head {
    display: flex; align-items: center; gap: 12px;
    padding: 14px 16px; border-bottom: 1px solid var(--md-outline-soft);
}
.tb-asst-title { display: flex; align-items: center; gap: 11px; flex: 1; min-width: 0; }
.tb-asst-mark {
    width: 34px; height: 34px; border-radius: 9px; flex: none;
    background: var(--md-primary-wash); color: var(--md-primary);
    display: grid; place-items: center; font-size: .9rem;
}
.tb-asst-title strong { display: block; font-size: .9375rem; }
.tb-asst-tag { display: block; font-size: .6875rem; color: var(--md-text-3); }
.tb-asst-close {
    width: 32px; height: 32px; border-radius: 50%; border: none; flex: none;
    background: transparent; color: var(--md-text-2); cursor: pointer;
}
.tb-asst-close:hover { background: var(--md-surface-2); color: var(--md-text); }

.tb-asst-log { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; }

.tb-asst-msg { max-width: 88%; font-size: .8125rem; line-height: 1.55; }
.tb-asst-msg.user {
    align-self: flex-end; background: var(--md-primary); color: var(--md-on-primary);
    padding: 9px 14px; border-radius: 14px 14px 4px 14px;
}
.tb-asst-msg.bot {
    align-self: flex-start; background: var(--md-surface-2); color: var(--md-text);
    padding: 11px 14px; border-radius: 14px 14px 14px 4px;
}
.tb-asst-answer strong { font-weight: 600; }
.tb-asst-answer a { color: var(--md-primary); }

.tb-asst-figs { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.tb-asst-fig {
    background: var(--md-surface); border: 1px solid var(--md-outline-soft);
    border-radius: var(--radius-sm); padding: 7px 11px; min-width: 0;
}
.tb-asst-fig .v { display: block; font-size: 1rem; font-weight: 600; letter-spacing: -.3px; }
.tb-asst-fig .l { display: block; font-size: .625rem; color: var(--md-text-3); text-transform: uppercase; letter-spacing: .4px; }

.tb-asst-src { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 11px; }
.tb-asst-src a {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: .75rem; font-weight: 500; color: var(--md-primary);
    background: var(--md-primary-wash); padding: 5px 11px; border-radius: var(--radius-pill);
    text-decoration: none;
}
.tb-asst-src a i { font-size: .625rem; }
.tb-asst-note { margin-top: 10px; font-size: .6875rem; color: var(--md-text-3); line-height: 1.4; }

.tb-asst-msg.typing { display: flex; gap: 4px; align-items: center; }
.tb-asst-msg.typing span {
    width: 6px; height: 6px; border-radius: 50%; background: var(--md-text-3);
    animation: tb-asst-blink 1.2s infinite both;
}
.tb-asst-msg.typing span:nth-child(2) { animation-delay: .2s; }
.tb-asst-msg.typing span:nth-child(3) { animation-delay: .4s; }
@keyframes tb-asst-blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }

.tb-asst-suggest { display: flex; flex-wrap: wrap; gap: 7px; padding: 0 16px 8px; }
.tb-asst-chip {
    border: 1px solid var(--md-outline); background: transparent;
    color: var(--md-text-2); font: inherit; font-size: .75rem; cursor: pointer;
    padding: 6px 12px; border-radius: var(--radius-pill); text-align: left;
}
.tb-asst-chip:hover { background: var(--md-primary-wash); border-color: transparent; color: var(--md-primary); }

.tb-asst-form { display: flex; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--md-outline-soft); }
.tb-asst-form input {
    flex: 1; min-width: 0; padding: 10px 14px; font: inherit; font-size: .8125rem;
    border: 1px solid var(--md-outline); border-radius: var(--radius-pill);
    background: var(--md-surface); color: var(--md-text);
}
.tb-asst-form input:focus { outline: none; border-color: var(--md-primary); box-shadow: 0 0 0 1px var(--md-primary); }
.tb-asst-form button {
    width: 40px; height: 40px; flex: none; border: none; border-radius: 50%;
    background: var(--md-primary); color: var(--md-on-primary); cursor: pointer;
}
.tb-asst-form button:hover { filter: brightness(1.05); }

@media (max-width: 600px) {
    .tb-asst { right: 8px; bottom: 8px; height: calc(100vh - 16px); }
    .tb-asst-launch { right: 12px; bottom: 12px; }
    .tb-asst-launch span { display: none; }
}

/* ── Topbar search trigger + alerts bell ─────────────────────────────────── */
.topbar-search {
    display: flex; align-items: center; gap: 8px;
    padding: 7px 12px; border: 1px solid var(--md-outline); border-radius: var(--radius-pill);
    background: var(--md-surface); color: var(--md-text-3); font: inherit; font-size: .8125rem; cursor: text;
    min-width: 200px; max-width: 320px;
}
.topbar-search:hover { background: var(--md-surface-2); }
.topbar-search span { flex: 1; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-search kbd, .tb-palette-input kbd {
    font-family: var(--font-mono); font-size: .6875rem; background: var(--md-surface-3);
    color: var(--md-text-2); border-radius: 4px; padding: 1px 6px; border: 1px solid var(--md-outline);
}
@media (max-width: 960px) { .topbar-search span { display: none; } .topbar-search { min-width: 0; } }

.alert-dot { position: absolute; top: 6px; right: 6px; width: 8px; height: 8px; border-radius: 50%; background: var(--status-critical); border: 2px solid var(--md-surface); }

/* ── Command palette ─────────────────────────────────────────────────────── */
.tb-palette {
    position: fixed; inset: 0; z-index: 80; display: none;
    background: rgba(20, 22, 24, .38); backdrop-filter: blur(2px);
    align-items: flex-start; justify-content: center; padding-top: 12vh;
}
.tb-palette.open { display: flex; }
.tb-palette-box {
    width: 620px; max-width: calc(100vw - 32px); background: var(--md-surface);
    border: 1px solid var(--md-outline); border-radius: var(--radius-lg); box-shadow: var(--md-shadow-2); overflow: hidden;
}
.tb-palette-input { display: flex; align-items: center; gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--md-outline-soft); color: var(--md-text-2); }
.tb-palette-input input { flex: 1; border: none; outline: none; background: transparent; color: var(--md-text); font: inherit; font-size: 1rem; }
.tb-palette-results { max-height: 52vh; overflow-y: auto; }
.tb-palette-item { display: flex; align-items: center; gap: 12px; padding: 11px 18px; cursor: pointer; text-decoration: none; color: inherit; border: none; background: transparent; width: 100%; text-align: left; }
.tb-palette-item:hover, .tb-palette-item.active { background: var(--md-primary-wash); text-decoration: none; }
.tb-palette-item .ico { width: 30px; height: 30px; border-radius: 8px; flex: none; display: grid; place-items: center; background: var(--md-surface-3); color: var(--md-text-2); font-size: .8rem; }
.tb-palette-item .lbl { flex: 1; min-width: 0; }
.tb-palette-item .lbl b { display: block; font-weight: 500; font-size: .875rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tb-palette-item .lbl span { display: block; font-size: .75rem; color: var(--md-text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tb-palette-item .type { font-size: .6875rem; color: var(--md-text-3); text-transform: uppercase; letter-spacing: .5px; flex: none; }
.tb-palette-empty { padding: 28px; text-align: center; color: var(--md-text-3); font-size: .875rem; }

/* ── Alerts panel ────────────────────────────────────────────────────────── */
.tb-alerts {
    position: fixed; top: 60px; right: 20px; z-index: 70; width: 360px; max-width: calc(100vw - 24px);
    max-height: 70vh; display: none; flex-direction: column;
    background: var(--md-surface); border: 1px solid var(--md-outline); border-radius: var(--radius-lg); box-shadow: var(--md-shadow-2); overflow: hidden;
}
.tb-alerts.open { display: flex; }
.tb-alerts-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--md-outline-soft); }
.tb-alerts-body { overflow-y: auto; }
.tb-alert { display: flex; align-items: flex-start; gap: 12px; padding: 12px 16px; text-decoration: none; color: inherit; border-bottom: 1px solid var(--md-outline-soft); }
.tb-alert:hover { background: var(--md-surface-2); text-decoration: none; }
.tb-alert .ico { width: 32px; height: 32px; border-radius: 8px; flex: none; display: grid; place-items: center; font-size: .8rem; }
.tb-alert.warning .ico { background: rgba(250,178,25,.16); color: #8a5b00; }
.tb-alert.critical .ico { background: rgba(208,59,59,.12); color: #b32626; }
.tb-alert .txt b { display: block; font-size: .8125rem; font-weight: 500; }
.tb-alert .txt span { display: block; font-size: .72rem; color: var(--md-text-3); }
.tb-alerts-empty { padding: 32px; text-align: center; color: var(--md-text-3); font-size: .8125rem; }

/* Copilot ledger proof — the balanced journal behind an executed sweep */
.ledger-proof > summary { list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; font-size: .72rem; color: var(--md-primary); padding: 2px 6px; border-radius: 6px; }
.ledger-proof > summary::-webkit-details-marker { display: none; }
.ledger-proof > summary:hover { background: var(--md-primary-wash); }
.ledger-proof[open] > summary { color: var(--md-text-2); }
.ledger-proof-legs { margin-top: 6px; padding: 8px 10px; background: var(--md-surface-2); border-radius: 8px; border: 1px solid var(--md-outline-soft); min-width: 260px; }
.ledger-leg { display: flex; align-items: center; gap: 8px; padding: 3px 0; }
.ledger-leg + .ledger-leg { border-top: 1px dashed var(--md-outline-soft); }
.ledger-leg .spacer { flex: 1; }

@media print { .topbar-search, .tb-palette, .tb-alerts { display: none !important; } }
