:root {
    --bg: #f4f6f8;
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --border: #d9e1e7;
    --text: #1f2937;
    --muted: #6b7280;
    --primary: #1f4f82;
    --primary-2: #2f6aa8;
    --success-bg: #e8f7ee;
    --success-text: #1f6b45;
    --warn-bg: #fff4db;
    --warn-text: #8a5b00;
    --danger-bg: #fdecec;
    --danger-text: #9a2c2c;
    --info-bg: #eaf3fb;
    --info-text: #255d92;
    --sidebar-bg: #0f1720;
    --sidebar-text: #e5edf6;
    --sidebar-muted: #8ea2b8;
    --shadow: 0 8px 24px rgba(17, 24, 39, 0.06);
    --radius: 14px;
    --radius-sm: 10px;
    --sidebar-width: 270px;
    --sidebar-width-collapsed: 72px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
    margin: 0;
    font-family: Inter, "Segoe UI", Roboto, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
}

.app {
    display: grid;
    grid-template-columns: var(--sidebar-width) 1fr;
    min-height: 100vh;
    transition: grid-template-columns 0.2s ease;
}

.app.collapsed {
    grid-template-columns: var(--sidebar-width-collapsed) 1fr;
}

/* Sidebar */
.sidebar {
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    padding: 18px 12px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.brand {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.04);
}

.brand-badge {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: linear-gradient(135deg, #2f6aa8, #15395c);
    display: grid;
    place-items: center;
    font-weight: 700;
    color: white;
}

.brand-text h1 {
    font-size: 15px;
    margin: 0;
    line-height: 1.2;
}

.brand-text small { color: var(--sidebar-muted); }

.sidebar-toggle {
    background: transparent;
    color: var(--sidebar-text);
    border: 0;
    cursor: pointer;
    font-size: 18px;
    padding: 4px 6px;
    border-radius: 8px;
}
.sidebar-toggle:hover { background: rgba(255, 255, 255, 0.08); }

.nav-section-title {
    color: var(--sidebar-muted);
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 0.08em;
    margin: 4px 12px 0;
}

.nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.nav-item {
    color: #dce6f2;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 10px;
    font-size: 14px;
    cursor: pointer;
    border: 1px solid transparent;
    background: transparent;
    width: 100%;
    text-align: left;
}

.nav-item:hover { background: rgba(255, 255, 255, 0.06); }

.nav-item.active {
    background: rgba(47, 106, 168, 0.22);
    color: #ffffff;
    border-color: rgba(121, 168, 219, 0.28);
}

.nav-item.muted {
    color: var(--sidebar-muted);
    cursor: default;
    font-style: italic;
    font-size: 12px;
}
.nav-item.muted:hover { background: transparent; }

.icon {
    width: 18px;
    text-align: center;
    opacity: 0.9;
    flex-shrink: 0;
}

.caret {
    margin-left: auto;
    opacity: 0.6;
    transition: transform 0.15s ease;
}

.nav-group > summary { list-style: none; }
.nav-group > summary::-webkit-details-marker { display: none; }
.nav-group[open] > summary .caret { transform: rotate(180deg); }

.nav-sub {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin: 2px 0 2px 22px;
    padding-left: 8px;
    border-left: 1px solid rgba(255, 255, 255, 0.08);
}

.nav-sub .nav-item {
    padding: 7px 10px;
    font-size: 13px;
}

.sidebar-footer {
    margin-top: auto;
    display: grid;
    gap: 10px;
}

.status-box {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 12px;
    display: grid;
    gap: 6px;
}

.status-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 4px;
    font-size: 13px;
}

.status-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    font-size: 12px;
    color: #c5d3e3;
}

.status-pill {
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 999px;
}
.status-pill.ok { background: var(--success-bg); color: var(--success-text); }
.status-pill.info { background: var(--info-bg); color: var(--info-text); }
.status-pill.warn { background: var(--warn-bg); color: var(--warn-text); }
.status-pill.err { background: var(--danger-bg); color: var(--danger-text); }

.dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #26c281;
    box-shadow: 0 0 0 4px rgba(38, 194, 129, 0.14);
}

/* Collapsed sidebar */
.app.collapsed .brand-text,
.app.collapsed .nav-section-title,
.app.collapsed .nav-item .label,
.app.collapsed .nav-item .caret,
.app.collapsed .status-box,
.app.collapsed .nav-sub {
    display: none;
}
.app.collapsed .brand { grid-template-columns: 1fr; justify-items: center; }
.app.collapsed .nav-item { justify-content: center; padding: 10px 6px; }

/* Main */
.main {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    background: rgba(244, 246, 248, 0.92);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--border);
    padding: 16px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.title-wrap h2 {
    margin: 0;
    font-size: 24px;
    line-height: 1.2;
}

.breadcrumbs {
    color: var(--muted);
    font-size: 13px;
    margin-bottom: 4px;
}

.top-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.search {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 10px 12px;
    min-width: 280px;
    box-shadow: var(--shadow);
}

.search input {
    border: 0;
    outline: 0;
    width: 100%;
    font-size: 14px;
    background: transparent;
    color: var(--text);
}

.btn {
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}
.btn.primary {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}
.btn:hover { filter: brightness(0.98); }

.content {
    padding: 24px;
    display: grid;
    gap: 22px;
}

/* Cards & stats */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.section { padding: 18px; }

.section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}

.section-head h3 {
    margin: 0;
    font-size: 17px;
}

.stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(180px, 1fr));
    gap: 16px;
}

.stat-card { padding: 18px; }

.stat-label {
    color: var(--muted);
    font-size: 13px;
    margin-bottom: 8px;
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.stat-sub {
    margin-top: 8px;
    color: var(--muted);
    font-size: 12px;
}

.chip {
    display: inline-flex;
    align-items: center;
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    border: 1px solid transparent;
    white-space: nowrap;
}
.chip.active { background: var(--info-bg); color: var(--info-text); }
.chip.ok { background: var(--success-bg); color: var(--success-text); }
.chip.warn { background: var(--warn-bg); color: var(--warn-text); }
.chip.err { background: var(--danger-bg); color: var(--danger-text); }

.subtle-link {
    color: var(--primary-2);
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
}

/* Strategy header strip */
.strategy-header {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 16px;
    align-items: start;
}

.strategy-title h3 {
    margin: 0 0 6px;
    font-size: 22px;
}

.meta-row {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    color: var(--muted);
    font-size: 13px;
}

.inline-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}

/* Session bar */
.session-bar {
    padding: 14px 18px;
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 18px;
}

.session-item .label {
    font-size: 11px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 4px;
}

.session-item .value {
    font-size: 14px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.ok-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #26c281;
    box-shadow: 0 0 0 3px rgba(38, 194, 129, 0.18);
    display: inline-block;
}

/* 2/1 grid used for dashboard body */
.grid-2-1 {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(320px, 1fr);
    gap: 20px;
    align-items: start;
}

/* P&L tone */
.pos { color: var(--success-text); }
.neg { color: var(--danger-text); }

/* Chart */
.chart {
    width: 100%;
    height: 160px;
    display: block;
}
.chart-axis {
    display: flex;
    justify-content: space-between;
    color: var(--muted);
    font-size: 11px;
    margin-top: 4px;
    font-variant-numeric: tabular-nums;
}

/* Tables */
.table-wrap {
    overflow: auto;
    border: 1px solid var(--border);
    border-radius: 14px;
}

.tg-table-filter {
    margin: 0 0 .75rem 0;
    max-width: 24rem;
}

.tg-data-table th.tg-sortable {
    cursor: pointer;
    user-select: none;
}

.tg-data-table th.tg-sortable::after {
    content: "↕";
    margin-left: 6px;
    color: #9aa7b6;
    font-size: 10px;
}

.tg-data-table th.tg-sortable[data-sort-dir="asc"]::after { content: "↑"; color: var(--primary); }
.tg-data-table th.tg-sortable[data-sort-dir="desc"]::after { content: "↓"; color: var(--primary); }

.tg-data-table .tg-actions-col,
.tg-data-table .tg-actions-cell {
    width: 13.5rem;
    min-width: 13.5rem;
}

.tg-symbol-name-table th:nth-child(2),
.tg-symbol-name-table td:nth-child(2) {
    width: 18rem;
    min-width: 18rem;
    max-width: 22rem;
}

.tg-actions-cell {
    white-space: normal;
    vertical-align: top;
}

.tg-actions-cell .btn,
.tg-actions-cell .blitz-action-btn {
    margin: 0 .25rem .35rem 0;
}

.tg-actions-cell .inline-actions {
    gap: .35rem;
}

.chip.ai-chip {
    color: #075985;
    background: #e0f2fe;
}

.chip.consensus-chip {
    color: #581c87;
    background: #f3e8ff;
}

.symbol-stack,
.metric-stack {
    display: flex;
    flex-direction: column;
    gap: .25rem;
}

.metric-line {
    display: flex;
    flex-wrap: wrap;
    gap: .35rem;
    align-items: center;
}

.blitz-universe-detail,
.blitz-insight-detail,
.blitz-pipeline-detail,
.blitz-ledger-detail,
.backtest-detail {
    display: none;
    background: #f8fafc;
}

.blitz-universe-detail.open,
.blitz-insight-detail.open,
.blitz-pipeline-detail.open,
.blitz-ledger-detail.open,
.backtest-detail.open {
    display: table-row;
}

.blitz-universe-detail-cell,
.blitz-insight-detail-cell,
.blitz-pipeline-detail-cell,
.blitz-ledger-detail-cell,
.backtest-detail-cell {
    padding: 1rem 1.25rem;
}

.blitz-insight-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
    gap: .75rem;
}

.blitz-insight-panel {
    border: 1px solid var(--border, #d7e0ea);
    border-radius: 8px;
    padding: .7rem;
    background: #fff;
}

.page-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}

.page-head h2 {
    margin: 0;
}

.page-head p {
    margin: .35rem 0 0;
}

.page-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: .5rem;
    flex-wrap: wrap;
}

.page-actions form {
    margin: 0;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    min-width: 760px;
}

th, td {
    padding: 12px 14px;
    text-align: left;
    border-bottom: 1px solid #e7edf2;
    font-size: 14px;
    vertical-align: middle;
}

th {
    background: #f8fafc;
    color: var(--muted);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    position: sticky;
    top: 0;
    z-index: 1;
}

tbody tr:hover { background: #fbfdff; }
td.amount, th.amount { text-align: right; font-variant-numeric: tabular-nums; }
td.mono { font-family: "SF Mono", Menlo, Consolas, monospace; font-size: 13px; color: var(--muted); }
.muted { color: var(--muted); }

.field-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.info-tooltip {
    width: 18px;
    height: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    border: 1px solid #cbd8e5;
    background: #f8fafc;
    color: var(--primary);
    font-size: 11px;
    font-weight: 800;
    line-height: 1;
    cursor: help;
    padding: 0;
}

.info-tooltip:hover,
.info-tooltip:focus {
    background: #edf3f9;
    border-color: #9fb8d0;
    outline: none;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    border-bottom: 1px solid var(--border);
    padding-bottom: 10px;
    margin-bottom: 16px;
}

.tab {
    padding: 8px 14px;
    border-radius: 10px;
    background: transparent;
    color: var(--muted);
    font-size: 13px;
    font-weight: 600;
    border: 1px solid transparent;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
}
.tab:hover {
    background: #f1f5f9;
    color: var(--primary);
    text-decoration: none;
}
.tab.active {
    background: #edf3f9;
    border-color: #d6e3ef;
    color: var(--primary);
}

.tab-count {
    background: #e5edf6;
    color: var(--primary);
    padding: 1px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

.news-feed {
    display: grid;
    gap: 0;
    border: 1px solid var(--border);
    border-radius: 14px;
    overflow: hidden;
    background: var(--surface);
}

.news-feed-row {
    display: grid;
    grid-template-columns: 44px minmax(120px, 180px) minmax(0, 1fr);
    gap: 16px;
    align-items: start;
    padding: 15px 16px;
    border-bottom: 1px solid #e7edf2;
}

.news-feed-row:last-child { border-bottom: 0; }
.news-feed-row:hover { background: #fbfdff; }

.news-rank {
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    background: #eef4fb;
    color: var(--primary);
    font-size: 12px;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}

.news-symbol {
    display: grid;
    gap: 4px;
}

.news-symbol strong { font-size: 15px; }

.news-symbol span,
.news-meta {
    color: var(--muted);
    font-size: 12px;
}

.news-feed-row p {
    margin: 0;
    color: var(--text);
    font-size: 14px;
    line-height: 1.45;
}

.news-meta {
    grid-column: 3;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: -4px;
}

.news-empty {
    display: grid;
    gap: 6px;
    padding: 22px;
    border: 1px dashed var(--border);
    border-radius: 14px;
    color: var(--muted);
}

/* Filters */
.filters {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}

.filter-pill {
    padding: 7px 12px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: #fff;
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}
.filter-pill.active {
    background: #edf3f9;
    color: var(--primary);
    border-color: #d6e3ef;
}

/* Small button variant */
.btn-xs {
    padding: 5px 10px;
    font-size: 12px;
    border-radius: 8px;
    margin-right: 4px;
}

/* Chip variants used on Live */
.chip.muted-chip { background: #eef1f5; color: var(--muted); }

/* Score cell */
.score {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}
.score.good { background: var(--success-bg); color: var(--success-text); }
.score.mid  { background: var(--warn-bg);    color: var(--warn-text); }
.score.low  { background: var(--danger-bg);  color: var(--danger-text); }

/* Position list */
.position-list { display: grid; gap: 10px; }

.position-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #fbfcfd;
    gap: 12px;
}

.pos-sym {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
}

.pos-values { text-align: right; }

.pos-pnl {
    font-size: 15px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

/* Alerts */
.alert-list { display: grid; gap: 10px; }

.alert-row {
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid transparent;
    font-size: 13px;
}
.alert-row strong { display: block; margin-bottom: 2px; font-size: 14px; }
.alert-row.warn { background: var(--warn-bg);    color: var(--warn-text);    border-color: #f5dfac; }
.alert-row.info { background: var(--info-bg);    color: var(--info-text);    border-color: #c9ddef; }
.alert-row.ok   { background: var(--success-bg); color: var(--success-text); border-color: #c6ecd5; }
.alert-row .muted { color: inherit; opacity: 0.85; }

/* AI Insight cards */
.insight-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
}

.insight-card {
    border: 1px solid var(--border);
    background: #fbfcfd;
    border-radius: 14px;
    padding: 16px;
    display: grid;
    gap: 10px;
}

.insight-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.insight-head strong { font-size: 16px; margin-right: 8px; }

.insight-body {
    margin: 0;
    font-size: 13px;
    line-height: 1.55;
    color: var(--text);
}

.insight-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    font-size: 12px;
    color: var(--muted);
    border-top: 1px solid var(--border);
    padding-top: 10px;
}

/* --------------------------------------------------------------------------
   Today's Universe table (Module 6.5 Phase 2 UI prep)
   Six-column redesign: Stock | Price | Status | Reason | Actions | Recs.
   The per-row expand shows OHLCV + 52W + market cap + P/E and the Module 6
   admission data (rank, overlap, fingerprint, built UTC). Every interactive
   piece is delegated at the tbody level so SSE innerHTML swaps don't lose
   their handlers.
   -------------------------------------------------------------------------- */

.todays-universe-table table { min-width: 1100px; } /* six rich columns need room */

.tu-stock-head {
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.tu-toggle {
    background: transparent;
    border: 0;
    color: var(--muted);
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 6px;
    font-size: 14px;
    line-height: 1;
    flex: 0 0 auto;
}
.tu-toggle:hover { background: #eef3f9; color: var(--primary); }

.tu-chev {
    display: inline-block;
    transition: transform 0.15s ease;
}
.tu-toggle[aria-expanded="true"] .tu-chev { transform: rotate(90deg); }

.tu-symbol {
    font-size: 17px;
    font-weight: 700;
    letter-spacing: -0.01em;
    line-height: 1.15;
}
.tu-company {
    font-size: 12px;
    color: var(--text);
    margin-top: 2px;
}
.tu-source { margin-top: 4px; }

/* Price column */
.tu-price {
    font-size: 16px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    line-height: 1.1;
}
.tu-price-abs, .tu-price-pct {
    font-size: 12px;
    font-variant-numeric: tabular-nums;
    line-height: 1.2;
}
.tu-price.pos, .tu-price-abs.pos, .tu-price-pct.pos { color: var(--success-text); }
.tu-price.neg, .tu-price-abs.neg, .tu-price-pct.neg { color: var(--danger-text); }

/* Reason column — four tight lines */
.tu-reason { font-size: 12px; line-height: 1.35; }
.tu-reason-line { margin: 0; padding: 1px 0; }
.tu-reason-lbl {
    display: inline-block;
    min-width: 34px;
    color: var(--muted);
    font-weight: 700;
    margin-right: 4px;
}

/* Recommendations column */
.tu-reco {
    font-size: 12px;
    color: var(--muted);
    line-height: 1.4;
}

/* Action pills — three buttons side by side */
.tu-actions {
    display: inline-flex;
    gap: 6px;
    flex-wrap: wrap;
}

.action-pill {
    border-radius: 999px;
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-width: 48px;
    justify-content: center;
    border: 1px solid var(--border);
    background: #fff;
    color: var(--muted);
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.action-pill .spinner-border-sm {
    display: none;
    width: 0.85rem;
    height: 0.85rem;
    border-width: 0.15em;
}

/* State matrix — all five exist so Module 7+ can set any state directly via
   data-state on the server-rendered button. Demo click handler only cycles
   pending → running → completed. */
.action-pill[data-state="pending"] {
    background: #fff;
    color: var(--muted);
    border-color: var(--border);
}
.action-pill[data-state="running"] {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}
.action-pill[data-state="running"] .spinner-border-sm { display: inline-block; }
.action-pill[data-state="completed"] {
    background: var(--success-bg);
    color: var(--success-text);
    border-color: #c6ecd5;
}
.action-pill[data-state="cancelled"] {
    background: var(--warn-bg);
    color: var(--warn-text);
    border-color: #f5dfac;
}
.action-pill[data-state="failed"] {
    background: var(--danger-bg);
    color: var(--danger-text);
    border-color: #f2c2c2;
}

/* Expand / collapse detail row */
.tu-details-row > td {
    background: #f8fafc;
    padding: 16px 20px;
}

.tu-details-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 18px;
}

.tu-details-group {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px 14px;
}

.tu-details-heading {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
    font-weight: 700;
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border);
}

.tu-details-kv {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    font-size: 13px;
    padding: 3px 0;
}
.tu-details-kv span { color: var(--muted); }
.tu-details-kv strong { font-variant-numeric: tabular-nums; }

/* Responsive */
@media (max-width: 1200px) {
    .stats { grid-template-columns: repeat(2, minmax(180px, 1fr)); }
    .session-bar { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .grid-2-1 { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
    .app { grid-template-columns: 1fr; }
    .sidebar { position: relative; height: auto; }
    .topbar { flex-direction: column; align-items: stretch; }
    .search { min-width: 0; width: 100%; }
    .stats { grid-template-columns: 1fr; }
    .session-bar { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .strategy-header { grid-template-columns: 1fr; }
}

/* ===== Settings page (Module 7 Phase 1 UI prep) ===== */
/* Visual-shell styling for the Strike Force Settings page. Every form on
   the page is a stub today; the layout tokens here are intended to carry
   through to the live wiring in Module 7 Phase 1d / Module 6.5 Phase 3
   without rework. Nothing here overrides a shared utility — all classes
   are scoped with a `.settings-` prefix. */

/* Floating toast — fixed top-right so it doesn't push the form down.
   Operator wanted this to pop visibly; the old inline-flow banner was
   easy to miss since it sat above a tall form. Slides in from the right
   on render, slides back out on dismiss / auto-timeout. */
.settings-toast {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 1080; /* above Bootstrap modals (1055) */
    display: inline-flex;
    align-items: center;
    gap: .75rem;
    padding: .75rem 1rem;
    /* Thick status-accent border with a light tint of the same hue inside.
       Status modifier classes (.settings-toast-ok / -warn / -err) override
       these defaults so the container itself carries the color — no inner
       pill/chip to make it look squishy. */
    background: var(--card, #fff);
    border: 3px solid var(--border, rgba(0,0,0,0.15));
    border-radius: 6px;
    box-shadow: 0 14px 34px rgba(0,0,0,0.18), 0 2px 6px rgba(0,0,0,0.08);
    max-width: 480px;
    opacity: 1;
    transform: translateX(0);
    transition: transform 240ms ease-out, opacity 240ms ease-out;
    animation: settings-toast-in 260ms ease-out;
}
.settings-toast-ok   { background: var(--success-bg); border-color: var(--success-text); }
.settings-toast-warn { background: var(--warn-bg);    border-color: var(--warn-text); }
.settings-toast-err  { background: var(--danger-bg);  border-color: var(--danger-text); }

.settings-toast.dismissed {
    opacity: 0;
    transform: translateX(40px);
}
@keyframes settings-toast-in {
    from { opacity: 0; transform: translateX(40px); }
    to   { opacity: 1; transform: translateX(0); }
}
.settings-toast-msg {
    flex: 1 1 auto;
    white-space: normal; /* allow longer stub messages to wrap */
    font-weight: 600;
    line-height: 1.35;
    color: var(--text, #222);
}
.settings-toast-ok  .settings-toast-msg { color: var(--success-text); }
.settings-toast-warn .settings-toast-msg { color: var(--warn-text); }
.settings-toast-err .settings-toast-msg { color: var(--danger-text); }

.settings-toast-close {
    line-height: 1;
    padding: 0 .4rem;
    font-size: 20px;
    font-weight: 700;
    color: currentColor;
    opacity: .6;
    background: transparent;
    border: 0;
    cursor: pointer;
    transition: opacity 120ms ease;
}
.settings-toast-close:hover,
.settings-toast-close:focus-visible {
    opacity: 1;
    outline: none;
}

/* Respect reduced-motion preference — drop the slide, keep the fade. */
@media (prefers-reduced-motion: reduce) {
    .settings-toast,
    .settings-toast.dismissed {
        transition: opacity 160ms ease;
        transform: none !important;
        animation: none;
    }
}

.settings-form { display: grid; gap: 16px; }

.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 16px;
}
.settings-grid-3 {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

.settings-field {
    position: relative;
    display: grid;
    gap: 6px;
}

.settings-label {
    font-size: 12px;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.settings-input {
    font-size: 14px;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    width: 100%;
    font-family: inherit;
}
.settings-input:focus {
    outline: 0;
    border-color: var(--primary-2);
    box-shadow: 0 0 0 3px rgba(47, 106, 168, 0.15);
}

/* Masked input + reveal button — same pattern across AI + Alpaca. */
.settings-secret {
    display: flex;
    gap: 8px;
    align-items: stretch;
}
.settings-secret .settings-input { flex: 1 1 auto; }
.settings-reveal {
    flex: 0 0 auto;
    min-width: 64px;
}

/* Select + adjacent "Refresh models" button. */
.settings-combo {
    display: flex;
    gap: 8px;
    align-items: stretch;
}
.settings-combo .settings-input { flex: 1 1 auto; }

/* Paper/Live environment toggle — two pill-style radios side by side. */
.settings-env-toggle {
    display: inline-flex;
    gap: 6px;
    padding: 4px;
    border-radius: 12px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    width: fit-content;
}
.settings-env-opt {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 7px 14px;
    border-radius: 9px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 700;
    color: var(--muted);
    user-select: none;
}
.settings-env-opt input[type="radio"] { margin: 0; cursor: pointer; }
.settings-env-opt:has(input[type="radio"]:checked) {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 1px 2px rgba(17, 24, 39, 0.08);
}
.settings-env-live:has(input[type="radio"]:checked) {
    background: var(--danger-text);
    color: #fff;
}

/* Paper vs Live credential groups — Live gets a red-tinted callout so the
   foot-gun section is obvious before you type. */
.settings-cred-group {
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 14px 16px;
    background: var(--surface-2);
    display: grid;
    gap: 14px;
}
.settings-cred-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}
.settings-cred-head h4 {
    margin: 0;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: -0.005em;
}
.settings-live-group {
    border-color: #f2c2c2;
    background: #fef7f7;
}

.settings-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding-top: 4px;
}

/* Placeholder cards dim slightly so the active-vs-future split is legible
   at a glance. */
.settings-placeholder .section-head h3 { color: var(--muted); }
.settings-placeholder { opacity: 0.9; }

/* ===== Settings nav + info chips (Module 7 Phase 1 UI refinement, 2026-04-18) ===== */
/* Two-column layout for the Settings surface: a vertical left nav (Claude-style)
   plus the content slot on the right. Info-chip popovers are CSS-only show/hide;
   the shell script toggles the `.open` class. */

.settings-shell {
    display: grid;
    grid-template-columns: 220px minmax(0, 1fr);
    gap: 20px;
    align-items: start;
    margin-top: 14px;
}

.settings-nav {
    position: sticky;
    top: 88px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 12px 10px;
}

.settings-nav-head {
    font-size: 11px;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 4px 10px 8px;
}

.settings-nav nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.settings-nav-item {
    display: block;
    padding: 8px 10px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    text-decoration: none;
    border: 1px solid transparent;
    transition: background 0.12s ease, border-color 0.12s ease;
}
.settings-nav-item:hover {
    background: var(--hover, rgba(0, 0, 0, 0.04));
    color: var(--text);
}
.settings-nav-item.active {
    background: var(--info-bg);
    color: var(--info-text);
    border-color: var(--info-bg);
}

.settings-content { min-width: 0; }

.historical-data-grid {
    align-items: stretch;
}

.historical-header {
    gap: 18px;
}

.historical-live-actions {
    justify-content: flex-end;
}

.historical-updated {
    align-self: center;
    font-size: 12px;
}

.historical-toast-host {
    display: grid;
    gap: 8px;
}

.historical-alert {
    display: flex;
    align-items: center;
    min-height: 38px;
    padding: 10px 14px;
    border-radius: 14px;
    font-weight: 700;
    font-size: 13px;
}

.historical-alert.ok {
    background: var(--success-bg);
    color: var(--success-text);
}

.historical-alert.warn {
    background: var(--warn-bg);
    color: var(--warn-text);
}

.historical-alert.err {
    background: var(--danger-bg);
    color: var(--danger-text);
}

.historical-checks {
    margin: 16px 0;
}

.historical-symbols {
    min-height: 118px;
    resize: vertical;
}

.historical-download-button {
    min-width: 150px;
}

.historical-spinner,
.historical-download-running {
    display: none;
}

.historical-download-button.is-running .historical-download-label {
    display: none;
}

.historical-download-button.is-running .historical-download-running,
.historical-download-button.is-running .historical-spinner {
    display: inline-block;
}

.historical-spinner {
    width: 14px;
    height: 14px;
    margin-right: 8px;
    border: 2px solid rgba(255, 255, 255, .45);
    border-top-color: #fff;
    border-radius: 50%;
    animation: historical-spin .8s linear infinite;
    vertical-align: -2px;
}

.historical-active-strip {
    margin-bottom: 14px;
    padding: 0;
}

.historical-progress {
    height: 8px;
    background: #e8edf3;
    border-radius: 999px;
    overflow: hidden;
    flex: 1;
}

.historical-progress .progress-bar {
    background: #1f5f9f;
    height: 100%;
}

.historical-active-message {
    margin-top: 12px;
    font-size: 0.9rem;
    color: var(--muted);
}

.historical-progress-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 8px 0 12px;
    font-weight: 700;
    color: var(--muted);
    font-size: 12px;
}

.historical-active-details {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.historical-active-details span {
    background: #f4f7fb;
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 6px 10px;
    color: var(--muted);
    font-size: 12px;
}

.historical-idle-state {
    display: grid;
    gap: 6px;
    color: var(--muted);
}

.historical-idle-state strong {
    color: var(--text);
}

@keyframes historical-spin {
    to { transform: rotate(360deg); }
}

/* Collapse to one column on narrow viewports — put the nav on top,
   content below. Matches existing @media(max-width: 860px) break in
   this file for .strategy-header. */
@media (max-width: 860px) {
    .settings-shell { grid-template-columns: 1fr; }
    .settings-nav { position: static; }
}

/* Info chips — small disc next to each label that opens an explanation
   popover containing a short description + default value + reset button. */
.settings-label-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.settings-info-disc {
    width: 18px;
    height: 18px;
    padding: 0;
    margin: 0;
    line-height: 1;
    font-size: 14px;
    color: var(--muted);
    background: transparent;
    border: 0;
    cursor: help;
    border-radius: 999px;
}
.settings-info-disc:hover { color: var(--primary-2); }
.settings-info-disc:focus-visible {
    outline: 2px solid var(--primary-2);
    outline-offset: 2px;
}

.settings-info-pop {
    display: none;
    position: absolute;
    top: 24px;
    left: 0;
    z-index: 1060;
    padding: 10px 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 16px 38px rgba(15, 23, 42, 0.18), 0 4px 10px rgba(15, 23, 42, 0.08);
    font-size: 13px;
    color: var(--text);
    width: min(360px, calc(100vw - 48px));
}
.settings-info-pop.open { display: block; }
.settings-info-pop p { margin: 0 0 6px; }
.settings-info-pop p:last-child { margin-bottom: 0; }
.settings-info-pop code {
    background: rgba(0, 0, 0, 0.05);
    padding: 1px 5px;
    border-radius: 4px;
    font-size: 12px;
}

.settings-reset-btn {
    margin-top: 4px;
    padding: 4px 8px;
    font-size: 12px;
    font-weight: 600;
    color: var(--primary-2);
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
}
.settings-reset-btn:hover {
    background: rgba(47, 106, 168, 0.08);
    border-color: var(--primary-2);
}

.error-meta {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
}

.error-meta-item {
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-2);
}

.error-meta-item span {
    display: block;
    margin-bottom: 4px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
}

.error-meta-item strong {
    font-size: 13px;
    overflow-wrap: anywhere;
}

.error-exception {
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
}

.error-detail {
    max-height: 460px;
    overflow: auto;
    padding: 12px;
    margin: 0;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-2);
    color: var(--text);
    font-size: 12px;
    line-height: 1.5;
    white-space: pre-wrap;
}

/* ===== AI Settings page (3-provider cards), 2026-04-18 =====
   /strategy/strike_force/settings/ai renders one .ai-provider-card per
   backend (OpenAI / Claude / Gemini). Accent border tracks the card's
   status: configured + default → thick success border; configured only
   → thin success border; not-configured → thin muted border. Same
   "thick border + light tint" language the settings toast uses. */

.ai-default-pill-group {
    display: inline-flex;
    gap: 6px;
    padding: 4px;
    border-radius: 12px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    width: fit-content;
}
.ai-default-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 7px 14px;
    border-radius: 9px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 700;
    color: var(--muted);
    user-select: none;
}
.ai-default-pill input[type="radio"] { margin: 0; cursor: pointer; }
.ai-default-pill:has(input[type="radio"]:checked) {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 1px 2px rgba(17, 24, 39, 0.08);
}
.ai-default-pill.disabled {
    opacity: 0.55;
    cursor: not-allowed;
}
.ai-default-pill.disabled input[type="radio"] { cursor: not-allowed; }

.ai-provider-card {
    border-top: 1px solid var(--border);
}
.ai-provider-card.configured {
    border-top: 2px solid var(--success-text);
}
.ai-provider-card.configured.default {
    border-top: 4px solid var(--success-text);
    background: linear-gradient(to bottom, var(--success-bg) 0, var(--success-bg) 6px, var(--card, #fff) 6px);
}
.ai-provider-card.muted {
    border-top: 1px solid var(--border);
}

.ai-card-status {
    display: inline-flex;
    gap: 6px;
    align-items: center;
}

/* Keep the per-row Save button on the same line as the inputs; allow wrap
   on narrow viewports so it tucks under rather than clipping. */
.ai-provider-card .settings-secret,
.ai-provider-card .settings-combo {
    flex-wrap: wrap;
}
.ai-provider-card .settings-secret .btn,
.ai-provider-card .settings-combo .btn {
    flex: 0 0 auto;
}

/* Refresh Models button — aligned right, matches .settings-actions but
   tighter vertical rhythm since it's a single button. */
.ai-provider-card .settings-actions {
    padding-top: 10px;
    margin: 0;
}

.ai-model-hint {
    color: var(--muted);
    font-size: 12px;
    margin: 4px 0 0;
}

/* ===== Logs pages (Strategy + System), 2026-04-18 ===== */
/* Visual-stub styling for /strategy/strike_force/logs and /diagnostics/logs.
   Both pages render Pages/Shared/_LogsTable.cshtml; styles below are scoped
   with .logs-* / .log-* / .live-tail-* prefixes so nothing collides with
   the existing chip/filter/table tokens. Level chip colour variants live
   alongside the shared .chip palette above. */

.logs-root { display: grid; gap: 16px; }

.log-filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 18px;
    align-items: flex-end;
    padding: 14px 16px;
}

.log-filter-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}

.log-filter-tail {
    margin-left: auto;
    flex-direction: row;
    align-items: center;
    gap: 12px;
}

.log-filter-label {
    font-size: 11px;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.log-level-chips,
.log-range-chips {
    display: inline-flex;
    gap: 6px;
    flex-wrap: wrap;
}

.log-filter-select {
    min-width: 180px;
    min-height: 38px;
    padding: 4px 8px;
    font-size: 13px;
}
.log-filter-select[multiple] {
    height: 38px;
}

.log-filter-input {
    padding: 8px 12px;
    font-size: 14px;
}

/* Level chip colour variants. Complement the existing .chip base. */
.chip.log-level-debug {
    background: #eef1f5;
    color: var(--muted);
    border-color: #dfe5ec;
}
.chip.log-level-info {
    background: var(--info-bg);
    color: var(--info-text);
    border-color: #c9ddef;
}
.chip.log-level-warn {
    background: var(--warn-bg);
    color: var(--warn-text);
    border-color: #f5dfac;
}
.chip.log-level-error {
    background: var(--danger-bg);
    color: var(--danger-text);
    border-color: #f2c2c2;
}

/* Level filter-pill tint when active, so operators can see at a glance
   which levels are on. */
.log-level-filter[data-level="debug"].active { background: #eef1f5; color: var(--muted);        border-color: #dfe5ec; }
.log-level-filter[data-level="info"].active  { background: var(--info-bg);    color: var(--info-text);    border-color: #c9ddef; }
.log-level-filter[data-level="warn"].active  { background: var(--warn-bg);    color: var(--warn-text);    border-color: #f5dfac; }
.log-level-filter[data-level="error"].active { background: var(--danger-bg);  color: var(--danger-text);  border-color: #f2c2c2; }

/* Live-tail pill — paused (grey) vs live (green pulsing dot). */
.live-tail-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 7px 14px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: #fff;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.live-tail-pill[data-state="paused"] {
    background: #eef1f5;
    color: var(--muted);
    border-color: #dfe5ec;
}
.live-tail-pill[data-state="live"] {
    background: var(--success-bg);
    color: var(--success-text);
    border-color: #c6ecd5;
}
.live-tail-pill:hover { filter: brightness(0.98); }

.live-tail-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #9ca3af;
    flex-shrink: 0;
}
.live-tail-pill[data-state="live"] .live-tail-dot {
    background: #26c281;
    box-shadow: 0 0 0 0 rgba(38, 194, 129, 0.55);
    animation: live-tail-pulse 1.5s ease-out infinite;
}

@keyframes live-tail-pulse {
    0%   { box-shadow: 0 0 0 0   rgba(38, 194, 129, 0.55); }
    70%  { box-shadow: 0 0 0 9px rgba(38, 194, 129, 0);    }
    100% { box-shadow: 0 0 0 0   rgba(38, 194, 129, 0);    }
}

.log-count {
    font-size: 12px;
    font-variant-numeric: tabular-nums;
}

/* Logs table — tighter vertical rhythm than the default so a denser stream
   stays glanceable. */
.logs-table { min-width: 1000px; }
.logs-table th,
.logs-table td { padding: 8px 12px; font-size: 13px; }

.log-ts {
    white-space: nowrap;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}

.log-expand-toggle {
    background: transparent;
    border: 0;
    color: var(--muted);
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 6px;
    font-size: 14px;
    line-height: 1;
}
.log-expand-toggle:hover { background: #eef3f9; color: var(--primary); }

.log-chev {
    display: inline-block;
    transition: transform 0.15s ease;
}
.log-expand-toggle[aria-expanded="true"] .log-chev { transform: rotate(90deg); }

.log-message {
    font-size: 13px;
    line-height: 1.5;
    word-break: break-word;
}

/* Smart-link chrome. Distinct per kind so the operator can eye-grep
   ticker vs. order vs. job vs. exception at a scan. */
.log-link {
    display: inline-block;
    padding: 0 6px;
    border-radius: 6px;
    font-weight: 700;
    font-size: 12.5px;
    line-height: 1.6;
    text-decoration: none;
    border: 1px solid transparent;
    background: rgba(47, 106, 168, 0.06);
    color: var(--primary);
    margin: 0 2px;
    cursor: pointer;
    font-family: inherit;
}
.log-link:hover {
    background: rgba(47, 106, 168, 0.14);
    border-color: #c9ddef;
}

.log-link-symbol {
    background: #eef5ff;
    color: #1d4fa0;
    font-variant-numeric: tabular-nums;
}
.log-link-order {
    background: #eaf7ef;
    color: var(--success-text);
    font-family: "SF Mono", Menlo, Consolas, monospace;
    font-size: 12px;
}
.log-link-job {
    background: #f4efff;
    color: #5b3c9e;
    font-family: "SF Mono", Menlo, Consolas, monospace;
    font-size: 12px;
}
.log-link-exception {
    background: var(--danger-bg);
    color: var(--danger-text);
}
.log-link-universe {
    background: #fff4db;
    color: var(--warn-text);
    font-size: 12px;
}

/* Expanded JSON row — monospace, soft-grey card. */
.log-row-expanded > td {
    background: #f8fafc;
    padding: 10px 16px 16px;
}
.log-row-json {
    margin: 0;
    padding: 12px 14px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 12px;
    line-height: 1.5;
    overflow-x: auto;
    white-space: pre;
    max-height: 260px;
}

/* Live-tail flash-in for new rows — subtle, fades out in ~2s. */
.log-row-tail-new {
    animation: log-row-flash 2s ease-out 1;
}
@keyframes log-row-flash {
    0%   { background: #fff5cc; }
    100% { background: transparent; }
}

/* Modal tokens — shared across order / job / exception bodies. */
.log-modal-kv {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 5px 0;
    font-size: 14px;
    border-bottom: 1px solid var(--border);
}
.log-modal-kv:last-of-type { border-bottom: 0; }
.log-modal-kv span    { color: var(--muted); }
.log-modal-kv strong  { font-variant-numeric: tabular-nums; }
.log-modal-note       { font-size: 12px; }

.log-exception-trace {
    margin: 0;
    padding: 14px 16px;
    background: #fdf5f5;
    border: 1px solid #f2c2c2;
    border-radius: 8px;
    font-size: 12px;
    line-height: 1.55;
    color: #5b1f1f;
    white-space: pre;
    overflow-x: auto;
    max-height: 420px;
}

@media (max-width: 900px) {
    .log-filter-bar { flex-direction: column; align-items: stretch; }
    .log-filter-tail { margin-left: 0; }
}

/* =========================================================================
   === SFFE Shell (WS-6) ===================================================

   Styles backing the Strike Force Fingerprint Engine visual shell:
     - Fingerprint inspector modal (_FingerprintInspector.cshtml)
     - AI call popover (_AiCallPopover.cshtml)
     - Prompt registry list + editor (Settings/Prompts[.Edit])
     - Ops AI Call log list + detail (/ops/ai-calls)

   Reuses .chip, .meta-row, .strategy-header, .settings-*, .card.section
   where the existing palette already fits. New classes below carry the
   `fp-` (fingerprint inspector), `ai-call-` (popover), and `sffe-` (misc)
   prefixes so grep stays sharp.
   ========================================================================= */

/* ---- Shared monospace helper ---- */
.fp-mono {
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
    font-size: 12px;
    background: var(--surface-2);
    padding: 2px 6px;
    border-radius: 4px;
    border: 1px solid var(--border);
    color: var(--text);
}

/* ---- Fingerprint Inspector modal -------------------------------------- */
.fp-inspector-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(17, 24, 39, 0.45);
    backdrop-filter: blur(2px);
    z-index: 1040;
    opacity: 0;
    transition: opacity 0.15s ease;
}
.fp-inspector-backdrop.open { opacity: 1; }

.fp-inspector-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: min(960px, calc(100vw - 32px));
    max-height: calc(100vh - 48px);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 24px 48px rgba(17, 24, 39, 0.22);
    z-index: 1050;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transition: opacity 0.15s ease;
}
.fp-inspector-modal.open { opacity: 1; }

.fp-inspector-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    background: var(--surface-2);
}
.fp-inspector-title-group h3 {
    margin: 0 0 4px;
    font-size: 18px;
}
.fp-inspector-ticker {
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
    font-size: 14px;
    margin-left: 8px;
    padding: 2px 8px;
    background: var(--info-bg);
    color: var(--info-text);
    border-radius: 6px;
}
.fp-inspector-close {
    background: transparent;
    border: 0;
    font-size: 24px;
    line-height: 1;
    color: var(--muted);
    cursor: pointer;
    padding: 4px 10px;
    border-radius: 8px;
}
.fp-inspector-close:hover { background: rgba(17, 24, 39, 0.06); color: var(--text); }

.fp-inspector-body {
    padding: 16px 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.fp-inspector-empty {
    padding: 32px 20px;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* ---- Inspector sections (accordion) ----------------------------------- */
.fp-section {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
}
.fp-section > summary { list-style: none; cursor: pointer; }
.fp-section > summary::-webkit-details-marker { display: none; }

.fp-section-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    font-weight: 600;
    font-size: 14px;
    background: #f4f7fa;
    border-bottom: 1px solid transparent;
}
.fp-section[open] .fp-section-head { border-bottom-color: var(--border); }

.fp-section-num {
    display: inline-grid;
    place-items: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    font-size: 11px;
    font-weight: 700;
}
.fp-section-title { flex: 1; }
.fp-section-tag { margin-left: auto; font-size: 11px; }

.fp-section-body { padding: 14px; display: flex; flex-direction: column; gap: 12px; }

/* Key-value grid used across Identity/Posture/Invalidation sections. */
.fp-kv-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 10px 20px;
}
.fp-kv {
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-size: 13px;
}
.fp-kv-k { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; }

.fp-chip-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }

.fp-subsection {
    border-top: 1px dashed var(--border);
    padding-top: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.fp-subsection-head {
    color: var(--muted);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.fp-headline {
    margin: 0;
    padding: 8px 12px;
    background: var(--info-bg);
    border-left: 3px solid var(--info-text);
    border-radius: 6px;
    font-size: 13px;
}

/* Archetype distribution table + bar. */
.fp-dist-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.fp-dist-table th, .fp-dist-table td { padding: 6px 8px; border-bottom: 1px solid var(--border); }
.fp-dist-table tbody tr:last-child td { border-bottom: 0; }
.fp-dist-bar {
    height: 8px;
    background: #e8ecf1;
    border-radius: 4px;
    overflow: hidden;
    min-width: 120px;
}
.fp-dist-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-2), var(--primary));
    border-radius: 4px;
}

/* Cohort confidence bar. */
.fp-conf-bar {
    flex: 1;
    height: 8px;
    background: #e8ecf1;
    border-radius: 4px;
    overflow: hidden;
    margin-right: 8px;
    min-width: 80px;
}
.fp-conf-bar-fill { height: 100%; background: var(--primary-2); border-radius: 4px; }

/* Archetype chip hue tints — subtle, one per enum value. */
.fp-arch { font-size: 11px; padding: 3px 8px; }
.fp-arch.fp-arch-IpoDay123                { background: #fdf1e6; color: #8a4a00; }
.fp-arch.fp-arch-FdaBiotechCatalyst       { background: #eaf7ea; color: #276a2e; }
.fp-arch.fp-arch-EarningsReaction         { background: #eef0fc; color: #2d3b8a; }
.fp-arch.fp-arch-PrContractGuidance       { background: #eef7f9; color: #1d5a6a; }
.fp-arch.fp-arch-SympathyMover            { background: #f3eefa; color: #5a2d8a; }
.fp-arch.fp-arch-ShortSqueeze             { background: #fdecec; color: #8a1f1f; }
.fp-arch.fp-arch-LowFloatNewsRunner       { background: #fff4db; color: #8a5b00; }
.fp-arch.fp-arch-SectorMomentumSpillover  { background: #eaf1fb; color: #1f4a82; }
.fp-arch.fp-arch-UnknownCatalyst          { background: #eef1f5; color: #4a5160; }
.fp-arch.fp-arch-NeedsReview              { background: #fff0f4; color: #8a2d53; }

/* Probability grid — 2x3 cells with a colored bar. */
.fp-prob-grid { width: 100%; border-collapse: collapse; font-size: 13px; }
.fp-prob-grid th, .fp-prob-grid td { padding: 8px 10px; border: 1px solid var(--border); text-align: left; }
.fp-prob-grid thead th { background: var(--surface-2); }
.fp-prob-cell { position: relative; min-width: 90px; vertical-align: top; }
.fp-prob-cell span { display: block; font-weight: 700; margin-bottom: 4px; }
.fp-prob-bar { height: 6px; background: rgba(17, 24, 39, 0.08); border-radius: 3px; overflow: hidden; }
.fp-prob-bar-fill { height: 100%; border-radius: 3px; }
.fp-prob-cell.fp-prob-low  { background: #fbe9e9; }
.fp-prob-cell.fp-prob-low .fp-prob-bar-fill  { background: #c65151; }
.fp-prob-cell.fp-prob-mid  { background: #fff5d9; }
.fp-prob-cell.fp-prob-mid .fp-prob-bar-fill  { background: #c78a00; }
.fp-prob-cell.fp-prob-high { background: #e2f3e4; }
.fp-prob-cell.fp-prob-high .fp-prob-bar-fill { background: #2f8a43; }

/* Narrative block. */
.fp-narrative {
    padding: 10px 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
}
.fp-narrative p { margin: 0 0 8px; font-size: 13px; line-height: 1.55; }
.fp-narrative-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }

.fp-rationale {
    margin: 0;
    font-size: 13px;
    color: var(--muted);
    font-style: italic;
}

.fp-baserate-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.fp-baserate-table th, .fp-baserate-table td { padding: 6px 8px; border-bottom: 1px solid var(--border); }
.fp-baserate-table tbody tr:last-child td { border-bottom: 0; }

.fp-analog-list, .fp-hardcond-list {
    margin: 0;
    padding-left: 18px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 13px;
}

.fp-copy-btn { margin-left: 6px; }
.fp-ai-popover-trigger { font-size: 11px; padding: 2px 10px; }

/* ---- AI call popover -------------------------------------------------- */
.ai-call-popover { max-width: 520px !important; }
.ai-call-popover .popover-body { padding: 0; }

.ai-call-popover-body {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 14px 14px 12px;
    font-size: 13px;
}
.ai-call-popover-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}
.ai-call-popover-head strong { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.ai-call-popover-head .muted { font-size: 11px; }

.ai-call-kv-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px 12px;
}
.ai-call-kv { display: flex; flex-direction: column; gap: 1px; font-size: 12px; }
.ai-call-kv .muted { font-size: 10px; text-transform: uppercase; letter-spacing: 0.04em; }
.ai-call-kv-wide { grid-column: 1 / -1; }

.ai-call-details {
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface-2);
    font-size: 12px;
}
.ai-call-details > summary {
    padding: 6px 10px;
    cursor: pointer;
    color: var(--muted);
    font-weight: 600;
    list-style: none;
}
.ai-call-details > summary::-webkit-details-marker { display: none; }
.ai-call-details[open] > summary { border-bottom: 1px solid var(--border); }

.ai-call-pre {
    margin: 0;
    padding: 8px 10px;
    max-height: 160px;
    overflow: auto;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 11px;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
    background: var(--surface);
}

.ai-call-footer {
    display: flex;
    justify-content: flex-end;
    padding-top: 4px;
}

/* ---- Prompt registry: list page --------------------------------------- */
.sffe-prompt-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-end;
    margin: 12px 0 18px;
}
.sffe-prompt-filter-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 160px;
}
.sffe-prompt-filter-toggle, .sffe-prompt-filter-submit { min-width: auto; }
.sffe-prompt-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    padding-top: 6px;
}

.sffe-prompt-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.sffe-prompt-table th, .sffe-prompt-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.sffe-prompt-table tbody tr:hover { background: var(--surface-2); }
.sffe-prompt-actions-col { width: 140px; text-align: right; white-space: nowrap; }
.sffe-prompt-actions-col .btn { margin-left: 4px; }
.sffe-prompt-row-inactive { opacity: 0.58; }

/* ---- Prompt registry: editor ------------------------------------------ */
.sffe-prompt-edit-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.sffe-prompt-edit-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    gap: 18px;
    align-items: start;
}
@media (max-width: 1100px) {
    .sffe-prompt-edit-grid { grid-template-columns: 1fr; }
}

.sffe-prompt-editor-area {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 12px;
    line-height: 1.55;
    min-height: 120px;
    background: var(--surface-2);
}

.sffe-prompt-preview-cell { align-self: end; }

.sffe-prompt-history { padding: 16px; }
.sffe-prompt-history-list {
    margin: 0;
    padding: 0;
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.sffe-prompt-history-row {
    padding: 10px 12px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 12px;
}
.sffe-prompt-history-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
}
.sffe-prompt-history-notes {
    color: var(--muted);
    font-size: 12px;
    line-height: 1.4;
}

/* ---- Ops AI Call log -------------------------------------------------- */
.sffe-aicalls-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-end;
    margin: 12px 0 18px;
}
.sffe-aicalls-filter-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 150px;
}
.sffe-aicalls-filter-submit { min-width: auto; }

.sffe-aicalls-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.sffe-aicalls-table th, .sffe-aicalls-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.sffe-aicalls-table tbody tr:hover { background: var(--surface-2); }

/* ---- Ops AI Call detail page ------------------------------------------ */
.sffe-aicall-kv-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 10px 20px;
}
.sffe-aicall-kv {
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-size: 13px;
}
.sffe-aicall-kv .muted { font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; }

.sffe-aicall-body-card > summary { list-style: none; cursor: pointer; }
.sffe-aicall-body-card > summary::-webkit-details-marker { display: none; }
.sffe-aicall-body-head { margin-bottom: 0; }

.sffe-aicall-pre {
    margin: 12px 0 0;
    padding: 12px 14px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 12px;
    line-height: 1.55;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 420px;
    overflow: auto;
}

.sffe-aicall-error-card { border-color: #f2c2c2; }
.sffe-aicall-error-pre { background: #fdf5f5; color: #5b1f1f; border-color: #f2c2c2; }

