/* =============================================================================
   Capital Intelligence — Page-specific CSS
   Uses design system variables from 1-foundation.css
   ============================================================================= */

/* ========== SGE ACTIONS BAR ========== */

.ci-sge-bar {
    display: flex;
    gap: 8px;
    padding: 6px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin-bottom: 16px;
    overflow-x: auto;
    white-space: nowrap;
}

.ci-sge-action {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border-radius: 6px;
    font-size: 0.7rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid transparent;
    white-space: nowrap;
}

.ci-sge-action.critical {
    background: rgba(239, 68, 68, 0.1);
    color: var(--accent-red);
    border-color: rgba(239, 68, 68, 0.25);
}

.ci-sge-action.action {
    background: rgba(245, 158, 11, 0.08);
    color: var(--accent-yellow);
    border-color: rgba(245, 158, 11, 0.2);
}

.ci-sge-action.success {
    background: rgba(16, 185, 129, 0.08);
    color: var(--accent-green);
    border-color: rgba(16, 185, 129, 0.2);
}

.ci-sge-action:hover {
    transform: translateY(-1px);
}

/* ========== HERO KPIs (Zone 1) ========== */

.ci-hero-kpis {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}

.ci-kpi-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 14px 16px;
    position: relative;
    cursor: help;
    transition: all 0.2s;
}

.ci-kpi-card:hover {
    background: var(--bg-hover);
    border-color: rgba(255, 255, 255, 0.12);
}

.ci-kpi-label {
    font-size: 0.6rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 5px;
}

.ci-kpi-label i {
    width: 12px;
    height: 12px;
    opacity: 0.6;
}

.ci-kpi-value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

.ci-kpi-value.good { color: var(--accent-green); }
.ci-kpi-value.neutral { color: var(--accent-blue); }
.ci-kpi-value.warning { color: var(--accent-yellow); }
.ci-kpi-value.danger { color: var(--accent-red); }

.ci-kpi-sub {
    font-size: 0.6rem;
    color: var(--text-muted);
    margin-top: 4px;
}

/* Rich Tooltip — base visual styles (no parent scope so portal inherits them) */
.ci-rich-tooltip {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 16px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    font-size: 0.75rem;
    line-height: 1.5;
    color: var(--text-secondary);
    cursor: default;
    width: 240px;
}

/* Hidden state + CSS-hover fallback (scoped to parent, overridden by smart-tooltip.js in portal) */
.ci-kpi-card .ci-rich-tooltip,
.ci-reserves-metric .ci-rich-tooltip {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    z-index: 200;
    pointer-events: none;
}

/* Allow tooltip to overflow the card boundary */
#panel-reserves .ci-card { overflow: visible; }
#panel-reserves .ci-card-body { overflow: visible; }
#panel-reserves .ci-reserves-grid { overflow: visible; }

.ci-tt-title {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.ci-tt-metric {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 3px 0;
}

.ci-tt-val {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 600;
    color: var(--text-primary);
}

.ci-tt-divider {
    border-top: 1px solid var(--border-color);
    margin: 8px 0;
}

.ci-tt-cta {
    font-size: 0.68rem;
    color: var(--accent-blue);
    margin-top: 6px;
    font-weight: 500;
}

/* ========== VISUALIZATIONS (Zone 2) ========== */

.ci-viz-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 20px;
}

/* Treemap */
/* ========== TREEMAP CONTROLS ========== */

.ci-treemap-controls {
    display: flex;
    align-items: center;
    gap: 12px;
}

.ci-toggle-label {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.65rem;
    color: var(--text-muted);
    cursor: pointer;
    user-select: none;
}

.ci-toggle-label input[type="checkbox"] {
    width: 14px;
    height: 14px;
    accent-color: var(--accent-blue);
    cursor: pointer;
}

/* ========== TREEMAP CONTAINER ========== */

.ci-treemap-container {
    position: relative;
    min-height: 300px;
    border-radius: 8px;
    overflow: visible;
}

.ci-treemap-block {
    position: absolute;
    border-radius: 6px;
    padding: 8px 10px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 2px;
    cursor: pointer;
    transition: filter 0.15s, box-shadow 0.15s;
    overflow: visible;
    box-sizing: border-box;
}

.ci-treemap-block:hover {
    filter: brightness(1.25);
    box-shadow: 0 0 0 2px rgba(255,255,255,0.25);
    z-index: 100;
}

.ci-tm-symbol {
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--text-primary);
    line-height: 1;
}

.ci-tm-yield {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85rem;
    font-weight: 700;
    line-height: 1;
}

/* ========== TREEMAP HOVER TOOLTIP (floating, appended to body) ========== */

.ci-tm-tooltip {
    display: none;
    position: fixed;
    width: 220px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 10px 12px;
    z-index: 9999;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
    font-size: 0.7rem;
    color: var(--text-secondary);
    pointer-events: none;
}

.ci-tm-tt-header {
    font-weight: 700;
    font-size: 0.75rem;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.ci-tm-tt-divider {
    height: 1px;
    background: var(--border-color);
    margin: 5px 0;
}

.ci-tm-tt-row {
    display: flex;
    justify-content: space-between;
    padding: 2px 0;
    font-size: 0.68rem;
}

.ci-tm-tt-row span:last-child {
    font-family: 'JetBrains Mono', monospace;
    color: var(--text-primary);
}

/* Scatter Plot */
.ci-scatter-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px 0;
}

.ci-scatter-toggle {
    display: flex;
    gap: 4px;
}

.ci-scatter-toggle-btn {
    padding: 4px 12px;
    font-size: 0.65rem;
    font-weight: 600;
    border-radius: 4px;
    border: 1px solid var(--border-color);
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s;
}

.ci-scatter-toggle-btn.active {
    background: var(--accent-blue);
    color: #fff;
    border-color: var(--accent-blue);
}

.ci-scatter-container {
    padding: 12px;
    height: 270px;
    position: relative;
    transition: height 0.3s ease;
}

/* ========== MAGIC QUADRANT (Productivity mode) ========== */
.mq-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    gap: 2px;
    height: 100%;
    border-radius: 8px;
    overflow: hidden;
}
.mq-cell {
    padding: 10px 14px;
    position: relative;
    display: flex;
    flex-direction: column;
}
.mq-heavy-carry  { background: rgba(34,211,238,0.08); }
.mq-workhorse    { background: rgba(74,222,128,0.08); }
.mq-dead-capital { background: rgba(239,68,68,0.08);  }
.mq-churn        { background: rgba(250,204,21,0.08); }
.mq-label {
    font-size: 0.82rem;
    font-weight: 700;
    margin-bottom: 1px;
}
.mq-heavy-carry .mq-label  { color: #22d3ee; }
.mq-workhorse .mq-label    { color: #4ade80; }
.mq-dead-capital .mq-label { color: #ef4444; }
.mq-churn .mq-label        { color: #facc15; }
.mq-desc {
    font-size: 0.68rem;
    color: var(--text-muted);
    margin-bottom: 6px;
}
.mq-positions {
    font-size: 0.72rem;
    color: var(--text-secondary);
    line-height: 1.5;
    flex: 1;
    overflow-y: auto;
}
.mq-positions .mq-pos {
    display: inline-block;
    background: rgba(255,255,255,0.06);
    border-radius: 4px;
    padding: 1px 6px;
    margin: 1px 2px;
    font-family: var(--font-mono);
    font-size: 0.68rem;
}
.mq-positions .mq-empty {
    color: var(--text-muted);
    font-style: italic;
    font-size: 0.68rem;
}
.mq-axes {
    display: flex;
    justify-content: space-between;
    padding: 4px 4px 0;
    font-size: 0.68rem;
    color: var(--text-muted);
}
.mq-axis-x, .mq-axis-y { display: flex; align-items: center; gap: 3px; }
.mq-cell { cursor: pointer; transition: background 0.15s, transform 0.15s; }
.mq-cell:hover { filter: brightness(1.4); transform: scale(1.02); }
.mq-drill-hint {
    display: flex; align-items: center; justify-content: center; gap: 4px;
    padding: 6px 0 2px;
    font-size: 0.7rem; color: var(--text-muted); opacity: 0.7;
}

/* Expanded scatter: fills viewport center */
.ci-scatter-expanded {
    position: fixed !important;
    top: 60px;
    left: 5%;
    right: 5%;
    bottom: 40px;
    width: 90% !important;
    z-index: 999;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 8px 40px rgba(0,0,0,0.6);
}
.ci-scatter-expanded .ci-scatter-container {
    height: calc(100% - 50px);  /* full card minus header */
}
/* Dim background when expanded */
.ci-scatter-expanded::before {
    content: '';
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: -1;
}

/* ========== RANKING TABLE (Zone 3) ========== */

.ci-table-section,
#ci-ranking-section {
    margin-bottom: 20px;
}

.ci-table-filters {
    display: flex;
    gap: 8px;
    padding: 10px 16px;
    background: var(--bg-secondary);
    border-radius: 8px 8px 0 0;
    border: 1px solid var(--border-color);
    border-bottom: none;
}

.ci-filter-btn {
    padding: 5px 12px;
    font-size: 0.68rem;
    font-weight: 600;
    border-radius: 5px;
    border: 1px solid var(--border-color);
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    gap: 5px;
}

.ci-filter-btn i {
    width: 13px;
    height: 13px;
}

.ci-filter-btn:hover {
    background: var(--bg-hover);
}

.ci-filter-btn.active {
    background: rgba(59, 130, 246, 0.15);
    color: var(--accent-blue);
    border-color: rgba(59, 130, 246, 0.3);
}

.ci-filter-btn.active.danger {
    background: rgba(239, 68, 68, 0.1);
    color: var(--accent-red);
    border-color: rgba(239, 68, 68, 0.25);
}

.ci-filter-btn.active.warning {
    background: rgba(245, 158, 11, 0.1);
    color: var(--accent-yellow);
    border-color: rgba(245, 158, 11, 0.25);
}

.ci-filter-btn.active.success {
    background: rgba(16, 185, 129, 0.1);
    color: var(--accent-green);
    border-color: rgba(16, 185, 129, 0.25);
}

/* CI Tabulator tables — visual tweaks on top of ps-grid.css light theme.
   Dark background overrides removed: ps-grid.css handles row/header/hover colors. */
#ci-ranking-table .tabulator-cell,
#growth-positions-summary .tabulator-cell {
    border-right: none !important;
    padding: 5px 8px !important;
}

/* Allow column header titles to wrap — prevents truncation on narrow columns */
#ci-ranking-table .tabulator-col-title,
#growth-positions-summary .tabulator-col-title {
    white-space: normal;
    line-height: 1.2;
    word-break: break-word;
}


/* Risk tinting via CSS classes (applied by rowFormatter, not inline styles) */
#ci-ranking-table .tabulator-row.ci-row-risk-dead {
    background: rgba(239, 68, 68, 0.05) !important;
}

#ci-ranking-table .tabulator-row.ci-row-risk-under {
    background: rgba(245, 158, 11, 0.05) !important;
}

/* ========== REDEPLOYMENT PANEL (Zone 4) ========== */

.ci-redeploy-panel {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    margin-bottom: 20px;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.ci-redeploy-panel.collapsed .ci-redeploy-body {
    display: none;
}

.ci-redeploy-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    user-select: none;
}

.ci-redeploy-header:hover {
    background: var(--bg-hover);
}

.ci-redeploy-title {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.ci-redeploy-title i {
    width: 16px;
    height: 16px;
    color: var(--accent-yellow);
}

.ci-redeploy-body {
    padding: 20px;
}

.ci-redeploy-grid {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 20px;
    align-items: start;
}

.ci-redeploy-current,
.ci-redeploy-replacements {
    background: var(--bg-inset);
    border-radius: 8px;
    padding: 16px;
    border: 1px solid var(--border-color);
}

.ci-redeploy-current {
    border-left: 3px solid var(--accent-red);
}

.ci-redeploy-replacements {
    border-left: 3px solid var(--accent-green);
}

.ci-redeploy-arrow {
    display: flex;
    align-items: center;
    justify-content: center;
    padding-top: 30px;
    color: var(--text-muted);
}

.ci-redeploy-arrow i {
    width: 24px;
    height: 24px;
}

.ci-redeploy-label {
    font-size: 0.62rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.ci-redeploy-symbol {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 10px;
}

.ci-redeploy-metric {
    display: flex;
    justify-content: space-between;
    padding: 3px 0;
    font-size: 0.72rem;
}

.ci-redeploy-metric span:first-child {
    color: var(--text-muted);
}

.ci-redeploy-metric span:last-child {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 600;
    color: var(--text-primary);
}

.ci-improvement-summary {
    text-align: center;
    padding: 12px;
    margin-top: 16px;
    background: rgba(16, 185, 129, 0.06);
    border-radius: 8px;
    border: 1px solid rgba(16, 185, 129, 0.15);
}

.ci-improvement-headline {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--accent-green);
    margin-bottom: 4px;
}

.ci-improvement-detail {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.ci-redeploy-actions {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 16px;
}

.ci-btn-primary {
    padding: 8px 16px;
    font-size: 0.72rem;
    font-weight: 600;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--accent-blue);
    color: #fff;
}

.ci-btn-primary:hover {
    background: #2563eb;
}

.ci-btn-secondary {
    padding: 8px 16px;
    font-size: 0.72rem;
    font-weight: 600;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    gap: 6px;
}

.ci-btn-secondary:hover {
    background: var(--bg-hover);
}

/* ========== SIMULATION PANEL (Zone 5) ========== */

.ci-sim-panel {
    display: none;
    margin-top: 16px;
    padding: 16px;
    background: var(--bg-inset);
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.ci-sim-panel.visible {
    display: block;
}

.ci-sim-title {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.ci-sim-title i {
    width: 14px;
    height: 14px;
    color: var(--accent-blue);
}

.ci-sim-grid {
    display: grid;
    grid-template-columns: 2fr 1fr auto 1fr auto;
    gap: 4px 12px;
    font-size: 0.72rem;
    align-items: center;
}

.ci-sim-label {
    color: var(--text-muted);
    font-weight: 500;
}

.ci-sim-before,
.ci-sim-after {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 600;
    text-align: right;
}

.ci-sim-arrow {
    color: var(--text-muted);
    text-align: center;
}

.ci-sim-change {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 700;
    text-align: right;
}

.ci-sim-change.up { color: var(--accent-green); }
.ci-sim-change.down { color: var(--accent-red); }

.ci-sim-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 14px;
}

/* ========== EFFICIENCY BARS (Zones 6-7) ========== */

.ci-efficiency-section {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    margin-bottom: 16px;
    overflow: hidden;
}

.ci-efficiency-section.collapsed .ci-efficiency-body {
    display: none;
}

.ci-efficiency-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    user-select: none;
}

.ci-efficiency-header:hover {
    background: var(--bg-hover);
}

.ci-efficiency-title {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 6px;
}

.ci-efficiency-title i {
    width: 14px;
    height: 14px;
}

.ci-efficiency-chevron {
    width: 14px;
    height: 14px;
    color: var(--text-muted);
    transition: transform 0.2s;
}

.ci-efficiency-section.collapsed .ci-efficiency-chevron {
    transform: rotate(-90deg);
}

.ci-efficiency-body {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.ci-eff-bar-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.ci-eff-bar-label {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-secondary);
    min-width: 110px;
    text-align: right;
}

.ci-eff-bar-track {
    flex: 1;
    height: 8px;
    background: var(--bg-inset);
    border-radius: 4px;
    overflow: hidden;
    position: relative;
}

.ci-eff-bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.4s ease;
}

.ci-eff-bar-fill.good { background: var(--accent-green); }
.ci-eff-bar-fill.warning { background: var(--accent-yellow); }
.ci-eff-bar-fill.danger { background: var(--accent-red); }

.ci-eff-bar-value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.7rem;
    font-weight: 600;
    min-width: 45px;
    text-align: right;
}

/* Reference lines in efficiency bars */
.ci-eff-bar-track .ci-ref-line {
    position: absolute;
    top: -2px;
    bottom: -2px;
    width: 2px;
    border-radius: 1px;
    z-index: 1;
}

.ci-ref-line.target { background: var(--accent-yellow); }
.ci-ref-line.cash { background: var(--accent-red); opacity: 0.6; }

/* ========== CARD CONTAINER (shared) ========== */

.ci-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    overflow: hidden;
}

.ci-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
}

.ci-card-title {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 6px;
}

.ci-card-title i {
    width: 14px;
    height: 14px;
}

/* ========== LOADING & EMPTY STATES ========== */

.ci-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 40px;
}

.ci-spinner {
    border: 3px solid var(--border-color);
    border-top: 3px solid var(--accent-blue);
    border-radius: 50%;
    width: 36px;
    height: 36px;
    animation: ci-spin 0.8s linear infinite;
    margin-bottom: 16px;
}

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

.ci-loading p {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.ci-empty-state {
    text-align: center;
    padding: 40px;
    color: var(--text-muted);
    font-size: 0.8rem;
}

.ci-hidden { display: none !important; }

/* ========== VALUE COLORS ========== */

.ci-positive { color: var(--accent-green) !important; }
.ci-negative { color: var(--accent-red) !important; }
.ci-warning { color: var(--accent-yellow) !important; }
.ci-neutral { color: var(--accent-blue) !important; }
.ci-text-success { color: var(--accent-green) !important; }
.ci-text-danger { color: var(--accent-red) !important; }
.ci-text-warning { color: var(--accent-yellow) !important; }
.ci-text-info { color: var(--accent-blue) !important; }

/* ========== BUTTONS ========== */

.ci-btn {
    padding: 8px 16px;
    font-size: 0.72rem;
    font-weight: 600;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    transition: all 0.15s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.ci-btn.ci-btn-sm {
    padding: 5px 10px;
    font-size: 0.65rem;
}

.ci-btn.ci-btn-primary {
    background: var(--accent-blue);
    color: #fff;
}

.ci-btn.ci-btn-primary:hover {
    background: #2563eb;
}

.ci-btn.ci-btn-secondary {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.ci-btn.ci-btn-secondary:hover {
    background: var(--bg-hover);
}

/* Table action buttons */
.ci-action-btn {
    font-size: 0.6rem;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 5px;
    cursor: pointer;
    border: 1px solid;
    transition: all 0.15s;
}

.ci-action-redeploy {
    background: rgba(239,68,68,0.12);
    color: #ef4444;
    border-color: rgba(239,68,68,0.25);
}

.ci-action-redeploy:hover {
    background: rgba(239,68,68,0.2);
}

.ci-action-harvest {
    background: rgba(16,185,129,0.1);
    color: #10b981;
    border-color: rgba(16,185,129,0.2);
}

.ci-action-harvest:hover {
    background: rgba(16,185,129,0.18);
}

.ci-action-urgent {
    background: rgba(239,68,68,0.15);
    color: #ef4444;
    border-color: rgba(239,68,68,0.3);
}

.ci-action-urgent:hover {
    background: rgba(239,68,68,0.25);
}

/* Inline action labels (no button border) */
.ci-action-label {
    font-size: 0.6rem;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
}

.ci-action-monitor {
    color: #d97706;
    background: rgba(217,119,6,0.1);
}

.ci-action-hold {
    color: #059669;
    background: rgba(5,150,105,0.1);
}

/* Symbol text */
.ci-sym-text {
    color: var(--text-primary, #e2e8f0);
}

#ci-ranking-table .tabulator-row:hover .ci-sym-text,
#growth-positions-summary .tabulator-row:hover .ci-sym-text {
    color: #f1f5f9 !important;
}

/* ========== CARD EXTRAS ========== */

.ci-card-hint {
    font-size: 0.6rem;
    color: var(--text-muted);
}

.ci-card-body {
    padding: 16px;
}

/* ========== SCATTER TOGGLE (alias) ========== */

.ci-scatter-btn {
    padding: 4px 12px;
    font-size: 0.65rem;
    font-weight: 600;
    border-radius: 4px;
    border: 1px solid var(--border-color);
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s;
}

.ci-scatter-btn:first-child { border-radius: 6px 0 0 6px; }
.ci-scatter-btn:last-child { border-radius: 0 6px 6px 0; }

.ci-scatter-btn.active {
    background: var(--accent-blue);
    color: #fff;
    border-color: var(--accent-blue);
}

/* ========== SGE BAR EXTRAS ========== */

.ci-sge-label {
    font-size: 0.6rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 4px;
}

.ci-sge-empty {
    font-size: 0.68rem;
    color: var(--text-muted);
}

/* ========== REPLACEMENT CARDS ========== */

.ci-replacement-card {
    border-radius: 6px;
    padding: 10px;
    margin-bottom: 8px;
    transition: outline 0.15s;
}

.ci-replacement-name {
    font-weight: 700;
    font-size: 0.82rem;
    color: var(--text-primary);
    margin-bottom: 6px;
}

/* Wash Sale Warning Banner */
.wash-sale-warning {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    background: rgba(245, 158, 11, 0.12);
    border: 1px solid var(--accent-yellow);
    border-radius: 4px;
    padding: 8px;
    margin-bottom: 10px;
}

.wash-sale-warning i {
    color: var(--accent-yellow);
    flex-shrink: 0;
    margin-top: 2px;
}

.wash-sale-text {
    flex: 1;
}

.wash-sale-text strong {
    display: block;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.wash-sale-text p {
    font-size: 0.7rem;
    line-height: 1.4;
    color: var(--text-secondary);
    margin: 0;
}

/* ========== REDEPLOY IMPROVEMENT ========== */

.ci-redeploy-improvement {
    text-align: center;
    padding: 12px;
    margin-top: 16px;
    background: rgba(16, 185, 129, 0.06);
    border-radius: 8px;
    border: 1px solid rgba(16, 185, 129, 0.15);
}

.ci-redeploy-improvement-value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--accent-green);
    margin-bottom: 4px;
}

.ci-redeploy-improvement-label {
    font-size: 0.68rem;
    color: var(--text-muted);
}

/* ========== COLLAPSIBLE SECTIONS ========== */

.ci-collapse-section {
    margin-bottom: 16px;
}

.ci-collapse-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    cursor: pointer;
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--text-secondary);
    user-select: none;
}

.ci-collapse-header:hover {
    background: var(--bg-hover);
}

.ci-collapse-header span {
    display: flex;
    align-items: center;
    gap: 6px;
}

.ci-collapse-icon {
    transition: transform 0.2s;
}

.ci-collapse-section.collapsed .ci-collapse-icon {
    transform: rotate(-90deg);
}

.ci-collapse-body {
    max-height: 600px;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.ci-collapse-section.collapsed .ci-collapse-body {
    max-height: 0;
}

/* ========== EFFICIENCY BARS CONTAINER ========== */

.ci-eff-bars {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.ci-eff-bar-fill.ci-eff-high {
    background: rgba(16,185,129,0.25);
    color: var(--accent-green);
    display: flex;
    align-items: center;
    padding-left: 10px;
    font-size: 0.65rem;
    font-weight: 700;
    font-family: 'JetBrains Mono', monospace;
}

.ci-eff-bar-fill.ci-eff-mid {
    background: rgba(59,130,246,0.2);
    color: var(--accent-blue);
    display: flex;
    align-items: center;
    padding-left: 10px;
    font-size: 0.65rem;
    font-weight: 700;
    font-family: 'JetBrains Mono', monospace;
}

.ci-eff-bar-fill.ci-eff-low {
    background: rgba(245,158,11,0.18);
    color: var(--accent-yellow);
    display: flex;
    align-items: center;
    padding-left: 10px;
    font-size: 0.65rem;
    font-weight: 700;
    font-family: 'JetBrains Mono', monospace;
}

.ci-eff-bar-fill.ci-eff-danger {
    background: rgba(239,68,68,0.18);
    color: var(--accent-red);
    display: flex;
    align-items: center;
    padding-left: 10px;
    font-size: 0.65rem;
    font-weight: 700;
    font-family: 'JetBrains Mono', monospace;
}

.ci-eff-bar-count {
    font-size: 0.62rem;
    color: var(--text-muted);
    min-width: 50px;
    text-align: right;
}

.ci-eff-bar-track {
    height: 22px;
}

/* ========== SIMULATION PANEL EXTRAS ========== */

.ci-sim-val {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 600;
    text-align: right;
}

.ci-sim-up { color: var(--accent-green); }
.ci-sim-down { color: var(--accent-red); }

.ci-sim-subtitle {
    font-weight: 400;
    color: var(--text-muted);
    font-size: 0.65rem;
    margin-left: 4px;
}

.ci-sim-divider {
    grid-column: span 5;
    height: 1px;
    background: var(--border-color);
    margin: 4px 0;
}

/* ========== LOADING OVERLAY ========== */

.ci-loading-overlay {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 120px 40px;
    position: fixed;
    inset: 0;
    background: rgba(10, 10, 18, 0.85);
    z-index: 500;
}

.ci-loading-overlay p {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.ci-loading-inline {
    padding: 20px;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.78rem;
}

/* ========== RICH TOOLTIP INNER ELEMENTS ========== */

.tt-title {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 5px;
}

.tt-metric {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 2px 0;
    font-size: 0.68rem;
}

.tt-val {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 600;
    color: var(--text-primary);
}

.tt-divider {
    border-top: 1px solid var(--border-color);
    margin: 6px 0;
}

.tt-body {
    font-size: 0.65rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.tt-cta {
    font-size: 0.62rem;
    color: var(--accent-blue);
    margin-top: 6px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 4px;
}

.tt-action {
    font-size: 0.65rem;
    padding: 4px 8px;
    background: rgba(59,130,246,0.1);
    border-radius: 4px;
    color: var(--accent-blue);
}

/* ========== RESPONSIVE ========== */

@media (max-width: 1400px) {
    .ci-hero-kpis {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 1200px) {
    .ci-viz-grid {
        grid-template-columns: 1fr;
    }
    .ci-redeploy-grid {
        grid-template-columns: 1fr;
    }
    .ci-redeploy-arrow {
        transform: rotate(90deg);
        padding: 0;
    }
}

@media (max-width: 768px) {
    .ci-hero-kpis {
        grid-template-columns: repeat(2, 1fr);
    }
    .ci-sim-grid {
        grid-template-columns: 1fr 1fr;
        gap: 6px 8px;
    }
    .ci-sim-arrow {
        display: none;
    }
}

/* ========== ALLOCATION BAR (Zone 0) ========== */

.ci-alloc-bar-container {
    margin-bottom: 12px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.ci-alloc-bar-label {
    font-size: 0.62rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    white-space: nowrap;
    min-width: 110px;
    padding-top: 7px; /* vertically align with bar center */
}

/* Inner column: bar on top, legend below */
.ci-alloc-bar-inner {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}

.ci-alloc-bar-track {
    height: 22px;
    background: var(--bg-inset, #13131e);
    border-radius: 6px;
    display: flex;
    gap: 2px;
    cursor: pointer;
}

.ci-alloc-segment {
    height: 100%;
    border-radius: 4px;
    transition: opacity 0.2s, flex 0.4s ease;
    cursor: pointer;
}

.ci-alloc-segment:hover { filter: brightness(1.2); }

/* External legend — dots + name + pct, always readable */
.ci-alloc-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 14px;
}

.ci-alloc-legend-item {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.73rem;
    cursor: pointer;
    opacity: 0.85;
    transition: opacity 0.15s;
}

.ci-alloc-legend-item:hover { opacity: 1; }

.ci-alloc-legend-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
}

.ci-alloc-legend-name { color: var(--text-secondary); }

.ci-alloc-legend-pct {
    color: var(--text-primary);
    font-weight: 600;
    font-family: 'JetBrains Mono', monospace;
}

/* ========== ENGINE CARDS (Zone 0.5) ========== */

.ci-engine-cards {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 10px;
    margin-bottom: 16px;
}

.ci-engine-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 14px 16px;
    cursor: pointer;
    transition: all 0.2s;
}

.ci-engine-card:hover {
    background: var(--bg-hover);
    border-color: rgba(255,255,255,0.12);
}

.ci-engine-card.active {
    border-color: var(--accent-blue);
    background: rgba(59,130,246,0.06);
}

.ci-engine-card[data-engine="campaigns"].active {
    border-color: var(--accent-cyan);
    background: rgba(6,182,212,0.06);
}

.ci-engine-card[data-engine="campaigns"].active .ci-engine-icon {
    color: var(--accent-cyan);
}

.ci-engine-card[data-engine="growth"].active {
    border-color: var(--accent-green);
    background: rgba(16,185,129,0.06);
}

.ci-engine-card[data-engine="protection"].active {
    border-color: var(--accent-purple);
    background: rgba(124,58,237,0.06);
}

.ci-engine-card[data-engine="reserves"].active {
    border-color: var(--text-muted);
    background: rgba(148,163,184,0.06);
}

.ci-engine-icon {
    color: var(--text-muted);
    margin-bottom: 6px;
}

.ci-engine-card.active .ci-engine-icon {
    color: var(--accent-blue);
}

.ci-engine-title {
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 6px;
}

.ci-engine-value {
    font-size: 1.2rem;
    font-weight: 700;
    font-family: 'JetBrains Mono', monospace;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.ci-engine-meta {
    font-size: 0.68rem;
    color: var(--text-secondary);
    margin-bottom: 2px;
}

.ci-engine-detail {
    font-size: 0.62rem;
    color: var(--text-muted);
}

/* ========== ENGINE PANELS ========== */

.ci-engine-panel {
    /* Panels are shown/hidden by JS */
}

/* ========== EMPTY STATES ========== */

.ci-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 24px;
    text-align: center;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 10px;
}

.ci-empty-state h3 {
    font-size: 0.95rem;
    font-weight: 700;
    margin-top: 12px;
    margin-bottom: 6px;
}

.ci-empty-state p {
    font-size: 0.75rem;
    color: var(--text-secondary);
    max-width: 400px;
    line-height: 1.5;
}

/* ========== RESERVES PANEL ========== */

.ci-reserves-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 16px;
}

.ci-reserves-metric {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.ci-reserves-label {
    font-size: 0.62rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
}

.ci-reserves-value {
    font-size: 1.1rem;
    font-weight: 700;
    font-family: 'JetBrains Mono', monospace;
}

.ci-reserves-bar {
    height: 6px;
    background: var(--bg-inset, #13131e);
    border-radius: 3px;
    overflow: hidden;
    margin-top: 4px;
}

.ci-reserves-bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.3s;
}

.ci-reserves-context {
    margin-top: 12px;
}

.ci-reserves-msg {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
    border-radius: 8px;
    font-size: 0.75rem;
    line-height: 1.5;
    color: var(--text-secondary);
}

.ci-reserves-msg-info { background: rgba(59,130,246,0.06); border: 1px solid rgba(59,130,246,0.15); }
.ci-reserves-msg-success { background: rgba(16,185,129,0.06); border: 1px solid rgba(16,185,129,0.15); }
.ci-reserves-msg-action { background: rgba(245,158,11,0.06); border: 1px solid rgba(245,158,11,0.15); }
.ci-reserves-msg-critical { background: rgba(239,68,68,0.06); border: 1px solid rgba(239,68,68,0.15); }

/* ========== ENGINE CARD RESPONSIVE ========== */

@media (max-width: 1200px) {
    .ci-engine-cards {
        grid-template-columns: repeat(2, 1fr);
    }
    .ci-reserves-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .ci-engine-cards {
        grid-template-columns: 1fr 1fr;
    }
    .ci-alloc-bar-label {
        display: none;
    }
}

/* =============================================================================
   SCATTER — Risk-Adjusted note badge
   ============================================================================= */

.ci-scatter-note {
    font-size: 0.58rem;
    font-weight: 600;
    color: var(--accent-green);
    background: rgba(16, 185, 129, 0.1);
    padding: 2px 8px;
    border-radius: 4px;
    margin-left: 8px;
    white-space: nowrap;
}

/* =============================================================================
   MASTER-DETAIL LAYOUT (Zone 3: ranking + TER detail panel — same card)
   ============================================================================= */

.ci-master-detail-card {
    overflow: hidden;
}

.ci-master-detail {
    display: flex;
}

.ci-master-table {
    flex: 3;
    min-width: 0;
    overflow: auto;
}

.ci-detail-panel {
    flex: 2;
    min-width: 260px;
    border-left: 1px solid var(--border-color);
    padding: 0;
    background: var(--bg-card);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

/* Panel title bar — always visible at top */
.ci-detail-panel-header {
    display: flex;
    align-items: baseline;
    gap: 8px;
    padding: 12px 20px 10px;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.ci-detail-panel-title {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.ci-detail-panel-subtitle {
    font-size: 0.65rem;
    color: var(--text-muted);
}

/* Empty state and content sit below the header */
.ci-detail-empty,
#ter-detail-content {
    flex: 1;
    padding: 20px 20px;
}

/* Empty state (shown before any row is clicked) */
.ci-detail-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 300px;
    color: var(--text-muted);
    font-size: 0.72rem;
    text-align: center;
    gap: 8px;
}

/* Detail header */
.ci-detail-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 14px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-color);
}

.ci-detail-symbol {
    font-size: 1rem;
    font-weight: 700;
}

.ci-detail-strategy {
    font-size: 0.7rem;
    color: var(--text-muted);
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* TER Hero — fills full panel width */
.ci-detail-ter-hero {
    text-align: center;
    padding: 20px;
    margin-bottom: 16px;
    background: var(--bg-secondary);
    border-radius: 8px;
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.ci-detail-ter-label {
    font-size: 0.6rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 4px;
}

.ci-detail-ter-value {
    font-size: 3rem;
    font-weight: 700;
    font-family: 'JetBrains Mono', monospace;
    line-height: 1;
}

.ci-detail-ter-status {
    font-size: 0.7rem;
    font-weight: 600;
    margin-top: 4px;
}

/* TER hero left side (label + value) */
.ci-detail-ter-main {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 0 0 auto;
}

/* TER hero right side (status + sub info) */
.ci-detail-ter-info {
    flex: 1;
    text-align: left;
    padding-left: 16px;
    border-left: 1px solid var(--border-color);
}

/* Metrics rows — 2-column grid to fill the wider panel space */
.ci-detail-metrics {
    margin-bottom: 14px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 16px;
}

.ci-detail-divider-full {
    grid-column: 1 / -1;
    height: 1px;
    background: var(--border-color);
    margin: 6px 0;
}

.ci-detail-metric-row {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
    font-size: 0.7rem;
    color: var(--text-secondary);
    border-bottom: 1px solid rgba(255,255,255,0.03);
}

.ci-detail-metric-val {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 600;
    color: var(--text-primary);
}

/* TER subtitle — plain-English reading of TER value */
.ci-detail-ter-subtitle {
    font-size: 0.62rem;
    color: var(--text-muted);
    margin-top: 4px;
}

/* 2-column metric grid for yield / SCR section */
.ci-detail-metric-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px 12px;
    margin-bottom: 14px;
}

.ci-detail-metric-cell {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 6px 8px;
    background: rgba(255,255,255,0.03);
    border-radius: 4px;
    border: 1px solid rgba(255,255,255,0.05);
}

.ci-detail-metric-cell-label {
    font-size: 0.58rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ci-detail-metric-grid .ci-detail-metric-val {
    font-size: 0.75rem;
}

.ci-detail-divider {
    grid-column: 1 / -1;  /* spans both columns in the metrics grid */
    height: 1px;
    background: var(--border-color);
    margin: 6px 0;
}

/* Decay Chart */
.ci-detail-chart-container {
    margin-bottom: 12px;
}

.ci-detail-chart-title {
    font-size: 0.62rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 6px;
}

#ci-ter-decay-chart {
    width: 100% !important;
    height: 180px !important;
}

/* Disclaimer */
.ci-detail-disclaimer {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.58rem;
    color: var(--text-muted);
    font-style: italic;
    padding-top: 8px;
    border-top: 1px solid var(--border-color);
}

/* Selected row highlight — visible blue tint on the ps-grid white background */
#ci-ranking-table .tabulator-row.ci-row-selected {
    background: rgba(37, 99, 235, 0.12) !important;
}

#ci-ranking-table .tabulator-row.ci-row-selected > .tabulator-cell:first-child {
    box-shadow: inset 3px 0 0 0 #2563eb;
}

/* Selected + hover: dark navy so ps-grid white-text hover rules stay correct */
#ci-ranking-table .tabulator-row.ci-row-selected:hover {
    background: #1a2f6b !important;
}

#ci-ranking-table .tabulator-row.ci-row-selected:hover > .tabulator-cell:first-child {
    box-shadow: inset 3px 0 0 0 #60a5fa;
}

/* Responsive: stack detail panel below table on small screens */
@media (max-width: 1100px) {
    .ci-master-detail {
        flex-direction: column;
    }

    .ci-detail-panel {
        flex: none;
        min-width: 0;
        border-left: none;
        border-top: 1px solid var(--border-color);
    }
}

/* ========================================================================
   ROLE KPIs — shared by Growth, Protection panels
   ======================================================================== */

.ci-role-kpis {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 12px;
    margin-bottom: 16px;
}

.ci-role-kpi {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 14px;
    text-align: center;
}

.ci-role-kpi-label {
    font-size: 0.6rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 6px;
}

.ci-role-kpi-value {
    font-size: 1.3rem;
    font-weight: 700;
    font-family: 'JetBrains Mono', monospace;
    margin-bottom: 4px;
}

.ci-role-kpi-status {
    font-size: 0.6rem;
    color: var(--text-muted);
}

/* ========================================================================
   ROLE ALERTS
   ======================================================================== */

.ci-role-alerts {
    margin-bottom: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ci-role-alert {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 0.72rem;
    line-height: 1.4;
}

.ci-role-alert-warning {
    background: rgba(245,158,11,0.06);
    border: 1px solid rgba(245,158,11,0.15);
    color: var(--accent-yellow);
}

.ci-role-alert-info {
    background: rgba(59,130,246,0.06);
    border: 1px solid rgba(59,130,246,0.15);
    color: var(--accent-blue);
}

.ci-role-alert-success {
    background: rgba(16,185,129,0.06);
    border: 1px solid rgba(16,185,129,0.15);
    color: var(--accent-green);
}

.ci-role-alert-critical {
    background: rgba(239,68,68,0.06);
    border: 1px solid rgba(239,68,68,0.15);
    color: var(--accent-red);
}

/* ========================================================================
   COMPACT POSITION SUMMARY — matches ps-grid visual language
   Dark header (#1a1a28) + white rows (#ffffff) + dark text (#0f172a)
   ======================================================================== */

/* CI table cell classes (no inline styles) */
.ci-cost-neg { color: var(--accent-red, #dc2626); }
.ci-pnl-pos  { color: var(--accent-green, #059669); }
.ci-pnl-neg  { color: var(--accent-red, #dc2626); }

.ci-role-positions {
    background: var(--bg-card, #1e1e2e);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
    font-family: 'Inter', sans-serif;
    font-size: 0.78rem;
    /* Height is bounded by the right chart column (flex sibling).
       Rows scroll inside; the grid never pushes past the right column's height. */
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.ci-role-pos-header {
    display: grid;
    grid-template-columns: 1fr 82px 66px 72px 96px 44px 44px;
    background: #1a1a28;
    color: rgba(255,255,255,0.85);
    font-size: 0.64rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-family: 'Inter', sans-serif;
    padding: 7px 12px;
    margin: 0;
    flex-shrink: 0;  /* header never shrinks — rows scroll below it */
}

/* Scrollable rows container — fills remaining height inside .ci-role-positions */
.ci-role-pos-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
}

.ci-role-pos-hdr-sort {
    cursor: pointer;
    user-select: none;
}
.ci-role-pos-hdr-sort:hover {
    color: #ffffff;
}

.ci-role-pos-row {
    display: grid;
    grid-template-columns: 1fr 82px 66px 72px 96px 44px 44px;
    padding: 7px 12px;
    border-bottom: 1px solid rgba(0,0,0,0.06);
    align-items: center;
    font-size: 0.78rem;
    color: #0f172a;
    background: #ffffff;
    transition: background-color 0.12s ease;
}

.ci-role-pos-row:hover {
    background: #1a1a28;
    border-bottom-color: rgba(255,255,255,0.04);
    cursor: pointer;
}
.ci-role-pos-row:hover .ci-role-pos-name-top { color: #f1f5f9; }
.ci-role-pos-row:hover .ci-role-pos-name-sub { color: #94a3b8; }
.ci-role-pos-row:hover .ci-role-pos-pnl,
.ci-role-pos-row:hover .ci-role-pos-roi,
.ci-role-pos-row:hover .ci-role-pos-days { color: #f1f5f9 !important; }

.ci-role-pos-row:last-child {
    border-bottom: none;
}

/* Two-line position cell */
.ci-role-pos-name {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}
.ci-role-pos-name-top {
    display: flex;
    align-items: center;
    gap: 5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 700;
    color: var(--text-primary, #e2e8f0);
}
.ci-role-pos-name-sub {
    font-size: 0.67rem;
    color: var(--text-muted, #64748b);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Strategy tag + quantity pill inside position cell */
.ci-pos-strat {
    font-size: 0.6rem;
    font-weight: 700;
    background: rgba(99,102,241,0.1);
    color: #6366f1;
    padding: 1px 5px;
    border-radius: 3px;
    flex-shrink: 0;
}
.ci-pos-qty {
    font-size: 0.62rem;
    color: #64748b;
    font-weight: 600;
    flex-shrink: 0;
}

.ci-role-pos-pnl,
.ci-role-pos-roi,
.ci-role-pos-days {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.74rem;
    font-weight: 600;
    text-align: right;
}

.ci-role-pos-status {
    font-size: 0.72rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding-left: 4px;
}

/* Score columns (TS / FS) in role-position grids */
.ci-role-pos-score {
    text-align: center;
}

/* Score badge — colored pill used in both Income Grid (Tabulator) and Growth Grid */
.ci-score-badge {
    display: inline-block;
    font-size: 0.62rem;
    font-weight: 700;
    font-family: 'JetBrains Mono', monospace;
    padding: 2px 6px;
    border-radius: 4px;
    white-space: nowrap;
}
.ci-score-badge--green {
    background: rgba(16, 185, 129, 0.12);
    color: #059669;
}
.ci-score-badge--amber {
    background: rgba(245, 158, 11, 0.12);
    color: #d97706;
}
.ci-score-badge--red {
    background: rgba(239, 68, 68, 0.12);
    color: #dc2626;
}
.ci-score-badge--na {
    color: #94a3b8;
}

/* Retained for any legacy usage — backgrounds removed per design */
.ci-role-badge-success { color: #059669; }
.ci-role-badge-warning { color: #d97706; }
.ci-role-badge-info    { color: #2563eb; }
.ci-role-badge-critical{ color: #dc2626; }

/* Responsive */
@media (max-width: 1200px) {
    .ci-role-kpis { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 768px) {
    .ci-role-kpis { grid-template-columns: repeat(2, 1fr); }
}

/* ========================================================================
   GROWTH 2-COLUMN LAYOUT (KPIs/Alerts/Summary left, Charts right)
   ======================================================================== */

.ci-growth-layout {
    /* Right column is in normal flow → its natural height defines the container.
       Left column is position:absolute top:0 bottom:0 → gets a definite height
       equal to the right column, enabling flex:1 + overflow-y:auto scrolling. */
    position: relative;
}

.ci-growth-left {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    width: calc(60% - 8px);   /* 6:4 ratio, minus half the 16px gap */
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background: transparent;   /* page bg shows behind KPIs/alerts; Tabulator ps-grid has its own #fff */
}

.ci-growth-right {
    margin-left: calc(60% + 8px);  /* 6:4 ratio, plus half the 16px gap */
    min-width: 280px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.ci-growth-chart-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px;
}

.ci-growth-chart-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 6px;
}

.ci-growth-chart-title {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.62rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* Period selector buttons (30D / 90D / YTD) */
.ci-growth-curve-controls {
    display: flex;
    gap: 2px;
}

.ci-curve-btn {
    padding: 2px 7px;
    font-size: 0.6rem;
    font-weight: 600;
    line-height: 1.4;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-muted);
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.ci-curve-btn:hover {
    background: rgba(255,255,255,0.05);
    color: var(--text-primary);
}

.ci-curve-btn.active {
    background: rgba(99,102,241,0.18);
    border-color: #6366f1;
    color: #a5b4fc;
}

/* Alpha vs SPY badge */
.ci-growth-alpha-badge {
    display: inline-flex;
    align-items: center;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    margin-bottom: 6px;
}

/* Empty state */
.ci-growth-curve-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 190px;
    color: var(--text-muted);
    font-size: 0.72rem;
    text-align: center;
    line-height: 1.5;
}

/* Fixed-height wrapper — Chart.js requires the PARENT to have an explicit
   height when maintainAspectRatio:false, otherwise canvas grows infinitely */
.ci-growth-chart-wrap {
    position: relative;
    height: 190px;
}

@media (max-width: 1100px) {
    .ci-growth-left {
        position: static;
        width: auto;
        overflow: visible;
    }
    .ci-growth-right {
        margin-left: 0;
        min-width: auto;
    }
}
