/* ============================================
   HEDGE MANAGER — Feature CSS
   ============================================
   Design System (1-foundation, 2-layout, 3-components) provides:
     - Tokens, reset, typography, utilities  (foundation)
     - App shell, sidebar, header            (layout)
     - Buttons, cards, badges, tabs, modals  (components)

   This file: ONLY hedge-manager-specific components.
   Organized by the 5-tab structure:
     §0  Shared / Regime Bar
     §1  Hedge Hub (default tab)
     §2  Protection Monitor
     §3  Positions
     §4  Analysis
     §5  History
     §6  Modals & Overlays
   ============================================ */


/* ============================================
   §0 — SHARED / REGIME BAR
   ============================================ */

.regime-bar {
    display: flex;
    align-items: center;
    gap: var(--space-xl);
    padding: var(--space-sm) var(--space-xl);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-lg);
    flex-wrap: wrap;
}

.regime-item {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-size: var(--font-size-sm);
    cursor: help;
}

.regime-summary { cursor: help; }

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

.regime-value {
    font-weight: 600;
    color: var(--text-primary);
    font-family: var(--font-mono);
}

.regime-value.positive  { color: var(--accent-green); }
.regime-value.negative  { color: var(--accent-red); }
.regime-value.warning   { color: var(--accent-yellow); }
.regime-value.elevated  { color: var(--accent-orange); }

.regime-change {
    font-size: var(--font-size-xs);
    font-weight: 500;
}

.regime-change.positive { color: var(--accent-green); }
.regime-change.negative { color: var(--accent-red); }

.regime-status {
    font-size: var(--font-size-2xs);
    font-weight: 600;
    padding: 2px var(--space-sm);
    border-radius: var(--radius-pill);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.regime-status.contango  { background: rgba(16, 185, 129, 0.15); color: var(--accent-green); }
.regime-status.flat      { background: rgba(245, 158, 11, 0.15); color: var(--accent-yellow); }
.regime-status.backwardation { background: rgba(239, 68, 68, 0.15); color: var(--accent-red); }

.regime-divider {
    width: 1px;
    height: 24px;
    background: var(--border-color);
}

/* Section title pattern (reused across tabs) */
.hm-section-title {
    font-size: var(--font-size-md);
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--space-md);
}

.hm-section-subtitle {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    margin-bottom: var(--space-lg);
}

/* Empty state (reused across tabs) */
.hm-empty-state {
    text-align: center;
    padding: var(--space-4xl) var(--space-2xl);
    color: var(--text-muted);
}

.hm-empty-state .i {
    margin-bottom: var(--space-md);
    opacity: 0.5;
}

.hm-empty-state p {
    font-size: var(--font-size-sm);
    max-width: 360px;
    margin: 0 auto;
    line-height: 1.6;
}


/* ============================================
   §1 — HEDGE HUB (default tab)
   "Cards are everything" — 7 unified layer cards
   ============================================ */

/* --- Hub Layout --- */
.hub-grid {
    display: flex;
    flex-direction: column;
}

/* --- Section Headers --- */
.hub-section-header {
    font-size: var(--font-size-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    padding: var(--space-lg) 0 var(--space-sm);
    border-bottom: 1px solid var(--border-color);
    margin-bottom: var(--space-sm);
}

.hub-section-header:first-child { padding-top: 0; }
.hub-section-action  { color: var(--accent-yellow); border-color: rgba(245, 158, 11, 0.3); }
.hub-section-healing { color: var(--accent-orange); border-color: rgba(249, 115, 22, 0.3); }
.hub-section-good    { color: var(--text-muted);    border-color: var(--border-color); }

/* --- Layer Card Base --- */
.layer-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: var(--space-md) var(--space-lg);
    margin-bottom: var(--space-sm);
    border-left: 3px solid var(--border-color);
    transition: all var(--transition-base);
    cursor: pointer;
    position: relative;
}

.layer-card:hover {
    border-color: var(--border-hover);
    background: var(--bg-hover);
}

.layer-card.expanded {
    cursor: default;
}

.layer-card.expanded:hover {
    background: var(--bg-card);
}

/* --- Card State Styles --- */
.layer-card.hub-state-critical {
    border-left-color: var(--accent-red);
    background: linear-gradient(90deg, rgba(239, 68, 68, 0.06) 0%, var(--bg-card) 20%);
    animation: hub-pulse-critical 2s ease-in-out infinite;
}

.layer-card.hub-state-attention {
    border-left-color: var(--accent-yellow);
    background: linear-gradient(90deg, rgba(245, 158, 11, 0.06) 0%, var(--bg-card) 20%);
}

.layer-card.hub-state-healing {
    border-left-color: var(--accent-orange);
    background: linear-gradient(90deg, rgba(249, 115, 22, 0.06) 0%, var(--bg-card) 20%);
}

.layer-card.hub-state-good {
    border-left-color: var(--accent-green);
    opacity: 0.85;
}

.layer-card.hub-state-standby,
.layer-card.hub-state-not_configured {
    border-left-color: var(--text-muted);
    border-left-style: dashed;
    opacity: 0.5;
}

.layer-card.hub-state-standby:hover,
.layer-card.hub-state-not_configured:hover {
    opacity: 0.7;
}

@keyframes hub-pulse-critical {
    0%, 100% { box-shadow: 0 0 0 0 transparent; }
    50% { box-shadow: 0 0 12px 0 rgba(239, 68, 68, 0.1); }
}

/* --- Card Header --- */
.hub-card-header {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.hub-card-dot {
    width: 10px;
    height: 10px;
    border-radius: var(--radius-full);
    flex-shrink: 0;
}

.hub-card-dot[data-layer="delta_shield"]  { background: var(--accent-blue); }
.hub-card-dot[data-layer="vol_shield"]    { background: var(--accent-purple); }
.hub-card-dot[data-layer="cps"]           { background: var(--accent-cyan); }
.hub-card-dot[data-layer="tail_shield"]   { background: var(--accent-red); }
.hub-card-dot[data-layer="direct_hedge"]  { background: var(--accent-orange); }
.hub-card-dot[data-layer="guardian"]       { background: var(--accent-green); }
.hub-card-dot[data-layer="crisis_harvest"]{ background: var(--accent-yellow); }

.hub-card-name {
    font-size: var(--font-size-base);
    font-weight: 600;
    color: var(--text-primary);
    flex: 1;
}

/* --- Card Badge --- */
.hub-card-badge {
    font-size: var(--font-size-xs);
    padding: 2px var(--space-sm);
    border-radius: var(--radius-xs);
    font-weight: 500;
    white-space: nowrap;
}

.hub-badge-critical      { background: rgba(239, 68, 68, 0.15); color: var(--accent-red); }
.hub-badge-attention     { background: rgba(245, 158, 11, 0.15); color: var(--accent-yellow); }
.hub-badge-healing       { background: rgba(249, 115, 22, 0.15); color: var(--accent-orange); }
.hub-badge-good          { background: rgba(16, 185, 129, 0.15); color: var(--accent-green); }
.hub-badge-standby,
.hub-badge-not_configured { background: rgba(107, 114, 128, 0.15); color: var(--text-muted); }

/* --- Card Metrics (inline, compact) --- */
.hub-card-metrics {
    display: flex;
    gap: var(--space-lg);
    margin-top: var(--space-sm);
    flex-wrap: wrap;
}

.hub-metric {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
}

.hub-metric strong {
    font-weight: 600;
    font-family: var(--font-mono);
    color: var(--text-primary);
}

.hub-hes-green  { color: var(--accent-green); }
.hub-hes-blue   { color: var(--accent-blue); }
.hub-hes-yellow { color: var(--accent-yellow); }
.hub-hes-red    { color: var(--accent-red); }
.hub-pnl-pos    { color: var(--accent-green); }
.hub-pnl-neg    { color: var(--accent-red); }

/* --- Card Context Line --- */
.hub-card-context {
    font-size: var(--font-size-sm);
    color: var(--text-muted);
    margin-top: var(--space-xs);
    line-height: 1.4;
}

/* --- Card Action Button --- */
.hub-card-action {
    margin-top: var(--space-sm);
}

/* --- Cooldown Bar --- */
.hub-cooldown-bar {
    background: rgba(74, 108, 247, 0.1);
    border: 1px solid rgba(74, 108, 247, 0.3);
    border-radius: var(--radius-sm);
    padding: var(--space-xs) var(--space-md);
    margin-top: var(--space-sm);
    font-size: var(--font-size-xs);
    color: var(--accent-blue);
    font-weight: 500;
}

/* --- Status Dot (kept for Monitor/Positions tabs) --- */
.status-dot {
    width: 8px;
    height: 8px;
    border-radius: var(--radius-full);
    flex-shrink: 0;
}

.status-dot.active   { background: var(--accent-green); box-shadow: 0 0 6px rgba(16, 185, 129, 0.4); }
.status-dot.partial  { background: var(--accent-yellow); }
.status-dot.empty    { background: var(--text-muted); }
.status-dot.critical { background: var(--accent-red); animation: pulse-dot 1.5s infinite; }

@keyframes pulse-dot {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* --- Trade Picker (expands inside card) --- */
.trade-picker {
    margin-top: var(--space-lg);
    padding-top: var(--space-lg);
    border-top: 1px solid var(--border-color);
    animation: slideDown 0.2s ease;
}

@keyframes slideDown {
    from { opacity: 0; max-height: 0; }
    to   { opacity: 1; max-height: 600px; }
}

.trade-picker-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-md);
}

.trade-picker-header h4 {
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--text-secondary);
    margin: 0;
}

.trade-picker-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: var(--space-xs);
    border-radius: var(--radius-sm);
    transition: var(--transition-fast);
}

.trade-picker-close:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

/* Trade option rows */
.trade-option {
    display: grid;
    grid-template-columns: 1fr auto auto auto;
    gap: var(--space-md);
    align-items: center;
    padding: var(--space-md);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-sm);
    transition: var(--transition-fast);
}

.trade-option:hover {
    border-color: var(--border-hover);
    background: var(--bg-hover);
}

.trade-option.recommended {
    border-color: rgba(74, 108, 247, 0.3);
    background: rgba(74, 108, 247, 0.05);
}

.trade-option-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.trade-option-symbol {
    font-weight: 600;
    font-size: var(--font-size-base);
    color: var(--text-primary);
}

.trade-option-strategy {
    font-size: var(--font-size-xs);
    color: var(--text-secondary);
}

.trade-option-legs {
    font-size: var(--font-size-2xs);
    color: var(--text-muted);
    font-family: var(--font-mono);
}

.trade-option-metric {
    text-align: right;
    min-width: 70px;
}

.trade-option-metric-label {
    font-size: var(--font-size-2xs);
    color: var(--text-muted);
    text-transform: uppercase;
}

.trade-option-metric-value {
    font-size: var(--font-size-sm);
    font-weight: 600;
    font-family: var(--font-mono);
    color: var(--text-primary);
}

/* Trade option action buttons */
.trade-option-actions {
    display: flex;
    gap: var(--space-xs);
    align-items: center;
    flex-shrink: 0;
}

/* Trade option reasons, conditions, warnings */
.trade-option-reasons {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: var(--space-xs) 0;
}

.trade-reason {
    font-size: var(--font-size-xs);
    color: var(--text-secondary);
    line-height: 1.4;
}

.trade-option-conditions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-xs);
    padding-top: var(--space-xs);
}

.trade-condition {
    font-size: 11px;
    color: var(--accent-yellow);
    background: rgba(255, 193, 7, 0.08);
    padding: 2px 8px;
    border-radius: var(--radius-sm);
}

.trade-option-warnings {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: var(--space-xs) 0;
}

.trade-warning {
    font-size: 11px;
    color: var(--color-warning, #ff9800);
    background: rgba(255, 152, 0, 0.08);
    padding: 2px 8px;
    border-radius: var(--radius-sm);
}

/* Coverage impact bar per trade */
.trade-coverage-impact {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    min-width: 120px;
}

.coverage-impact-bar {
    height: 6px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-pill);
    overflow: hidden;
    display: flex;
    flex: 1;
}

.coverage-current { background: var(--accent-green); height: 100%; }
.coverage-added   { background: var(--accent-blue); height: 100%; opacity: 0.7; }

.coverage-impact-text {
    font-size: var(--font-size-2xs);
    color: var(--text-secondary);
    font-family: var(--font-mono);
    white-space: nowrap;
}

/* HAIE reason text in trade picker */
.trade-picker-reason {
    font-size: var(--font-size-xs);
    color: var(--text-secondary);
    font-style: italic;
    padding: 0 var(--space-md) var(--space-md);
    border-left: 2px solid var(--accent-yellow);
    margin: 0 var(--space-md) var(--space-sm);
}

/* Footer links in trade picker */
.trade-picker-footer {
    display: flex;
    justify-content: space-between;
    padding: var(--space-sm) var(--space-md);
    border-top: 1px solid var(--border-color);
    margin-top: var(--space-sm);
}

.trade-picker-footer a {
    font-size: var(--font-size-xs);
    color: var(--accent-blue);
    text-decoration: none;
}

.trade-picker-footer a:hover {
    text-decoration: underline;
}

/* Loading state for trade picker */
.trade-picker-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: var(--space-2xl);
    color: var(--text-muted);
    font-size: var(--font-size-sm);
}

.trade-picker-loading .spinner {
    width: 16px;
    height: 16px;
    border: 2px solid var(--border-color);
    border-top-color: var(--accent-blue);
    border-radius: var(--radius-full);
    animation: spin 0.6s linear infinite;
}

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

/* ============================================
   §2 — PROTECTION MONITOR
   "How protected am I?"
   Coverage chart, cost governor, NTY, decay, healing
   ============================================ */

/* Coverage chart container */
.coverage-chart-wrapper {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    margin-bottom: var(--space-lg);
}

.coverage-chart-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-md);
}

.coverage-toggle-group {
    display: flex;
    gap: 2px;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    padding: 2px;
}

.coverage-toggle {
    padding: var(--space-xs) var(--space-md);
    font-size: var(--font-size-xs);
    border: none;
    background: none;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: var(--radius-xs);
    transition: var(--transition-fast);
}

.coverage-toggle.active {
    background: var(--accent-blue);
    color: white;
}

/* SVG / Canvas chart area */
.coverage-chart {
    width: 100%;
    height: 200px;
    position: relative;
}

.coverage-chart canvas {
    width: 100% !important;
    height: 100% !important;
}

/* Monitor metrics grid */
.monitor-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: var(--space-lg);
}

/* Monitor widget card */
.monitor-widget {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
}

.monitor-widget-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-md);
}

.monitor-widget-title {
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.monitor-widget-value {
    font-size: var(--font-size-2xl);
    font-weight: 700;
    font-family: var(--font-mono);
    color: var(--text-primary);
    margin-bottom: var(--space-xs);
}

.monitor-widget-sub {
    font-size: var(--font-size-xs);
    color: var(--text-muted);
}

/* Healing panel */
.healing-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.healing-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-md);
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.healing-item-info {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.healing-progress {
    width: 40px;
    height: 40px;
    position: relative;
}

.healing-progress svg {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.healing-progress-text {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--font-size-2xs);
    font-weight: 600;
    font-family: var(--font-mono);
}

.healing-item-details {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.healing-item-name {
    font-size: var(--font-size-sm);
    font-weight: 500;
    color: var(--text-primary);
}

.healing-item-sub {
    font-size: var(--font-size-xs);
    color: var(--text-muted);
}

/* Decay forecast mini chart */
.decay-forecast {
    position: relative;
}

.decay-chart {
    width: 100%;
    height: 120px;
}

.decay-legend {
    display: flex;
    gap: var(--space-lg);
    margin-top: var(--space-sm);
    justify-content: center;
}

.decay-legend-item {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    font-size: var(--font-size-xs);
    color: var(--text-secondary);
}

.decay-legend-dot {
    width: 8px;
    height: 8px;
    border-radius: var(--radius-full);
}

/* ============================================
   §3 — POSITIONS
   "What hedge positions do I own?"
   Layer groups accordion + Gantt timeline
   ============================================ */

/* Summary bar */
.positions-summary {
    display: flex;
    gap: var(--space-2xl);
    padding: var(--space-md) var(--space-lg);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-lg);
    flex-wrap: wrap;
}

.positions-summary-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.positions-summary-label {
    font-size: var(--font-size-2xs);
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.positions-summary-value {
    font-size: var(--font-size-md);
    font-weight: 600;
    font-family: var(--font-mono);
    color: var(--text-primary);
}

/* View toggle (List / Timeline) */
.positions-view-toggle {
    display: flex;
    gap: 2px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 2px;
    margin-bottom: var(--space-lg);
}

.positions-view-btn {
    padding: var(--space-xs) var(--space-md);
    font-size: var(--font-size-xs);
    border: none;
    background: none;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: var(--radius-xs);
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    transition: var(--transition-fast);
}

.positions-view-btn.active {
    background: var(--accent-blue);
    color: white;
}

/* Layer group accordion */
.layer-group {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    margin-bottom: var(--space-md);
    overflow: hidden;
}

.layer-group-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-md) var(--space-lg);
    cursor: pointer;
    transition: var(--transition-fast);
}

.layer-group-header:hover {
    background: var(--bg-hover);
}

.layer-group-left {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.layer-group-color {
    width: 4px;
    height: 24px;
    border-radius: 2px;
}

.layer-group-name {
    font-size: var(--font-size-base);
    font-weight: 600;
    color: var(--text-primary);
}

.layer-group-count {
    font-size: var(--font-size-xs);
    color: var(--text-muted);
}

.layer-group-right {
    display: flex;
    align-items: center;
    gap: var(--space-lg);
}

.layer-group-metric {
    text-align: right;
}

.layer-group-metric-label {
    font-size: var(--font-size-2xs);
    color: var(--text-muted);
}

.layer-group-metric-value {
    font-size: var(--font-size-sm);
    font-weight: 600;
    font-family: var(--font-mono);
}

.layer-group-chevron {
    color: var(--text-muted);
    transition: transform 0.2s ease;
}

.layer-group.open .layer-group-chevron {
    transform: rotate(180deg);
}

/* Position cards inside accordion */
.layer-group-body {
    padding: 0 var(--space-lg) var(--space-lg);
    display: none;
}

.layer-group.open .layer-group-body {
    display: block;
}

.hedge-position-card {
    display: grid;
    grid-template-columns: 1.5fr repeat(5, 1fr) auto;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-sm);
    font-size: var(--font-size-sm);
}

.hedge-position-card:hover {
    border-color: var(--border-hover);
}

.hedge-pos-name {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.hedge-pos-symbol {
    font-weight: 600;
    color: var(--text-primary);
}

.hedge-pos-desc {
    font-size: var(--font-size-xs);
    color: var(--text-muted);
    font-family: var(--font-mono);
}

.hedge-pos-value {
    font-family: var(--font-mono);
    text-align: right;
}

/* HES badge */
.hes-badge {
    font-size: var(--font-size-2xs);
    font-weight: 600;
    padding: 2px var(--space-sm);
    border-radius: var(--radius-pill);
    text-transform: uppercase;
}

.hes-badge.optimal     { background: rgba(16, 185, 129, 0.15); color: var(--accent-green); }
.hes-badge.good        { background: rgba(74, 108, 247, 0.15); color: var(--accent-blue); }
.hes-badge.degraded    { background: rgba(245, 158, 11, 0.15); color: var(--accent-yellow); }
.hes-badge.poor        { background: rgba(239, 68, 68, 0.15); color: var(--accent-red-light); }
.hes-badge.ineffective { background: rgba(239, 68, 68, 0.2); color: var(--accent-red); }

/* Gantt timeline */
.gantt-container {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    overflow-x: auto;
}

.gantt-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-md);
}

.gantt-timespan-btns {
    display: flex;
    gap: 2px;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    padding: 2px;
}

.gantt-timespan-btn {
    padding: var(--space-xs) var(--space-md);
    font-size: var(--font-size-xs);
    border: none;
    background: none;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: var(--radius-xs);
    transition: var(--transition-fast);
}

.gantt-timespan-btn.active {
    background: var(--accent-blue);
    color: white;
}

.gantt-chart {
    position: relative;
    min-height: 120px;
}

/* Gantt rows */
.gantt-row {
    display: flex;
    align-items: center;
    height: 32px;
    margin-bottom: 4px;
}

.gantt-row-label {
    width: 120px;
    font-size: var(--font-size-xs);
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex-shrink: 0;
}

.gantt-row-track {
    flex: 1;
    height: 20px;
    position: relative;
    background: var(--bg-secondary);
    border-radius: var(--radius-xs);
}

.gantt-bar {
    position: absolute;
    height: 100%;
    border-radius: var(--radius-xs);
    opacity: 0.8;
    cursor: help;
    transition: opacity 0.15s ease;
}

.gantt-bar:hover {
    opacity: 1;
}

/* Today marker */
.gantt-today {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--accent-red);
    z-index: 2;
}

.gantt-today::after {
    content: 'Today';
    position: absolute;
    top: -16px;
    left: 50%;
    transform: translateX(-50%);
    font-size: var(--font-size-2xs);
    color: var(--accent-red);
    white-space: nowrap;
}

/* Month headers */
.gantt-months {
    display: flex;
    margin-bottom: var(--space-sm);
    padding-left: 120px;
}

.gantt-month {
    font-size: var(--font-size-2xs);
    color: var(--text-muted);
    text-transform: uppercase;
    border-left: 1px solid var(--border-color);
    padding-left: var(--space-xs);
}


/* ============================================
   §4 — ANALYSIS
   "What happens under different scenarios?"
   MC Forecast + Stress Test merged
   ============================================ */

/* Analysis section toggle (FIX-16) */
.analysis-toggle {
    display: flex;
    gap: var(--space-xs);
    margin-bottom: var(--space-lg);
}

.analysis-toggle-btn {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    padding: var(--space-xs) var(--space-md);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: transparent;
    color: var(--text-muted);
    font-size: var(--font-size-xs);
    cursor: pointer;
    transition: all 0.15s;
}

.analysis-toggle-btn.active {
    background: var(--bg-card);
    border-color: var(--accent-blue);
    color: var(--text-primary);
}

.analysis-toggle-btn:hover:not(.active) {
    border-color: var(--text-muted);
}

/* Analysis layout: two-column for wider screens */
.analysis-layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--space-lg);
}

@media (min-width: 1200px) {
    .analysis-layout {
        grid-template-columns: 1fr 1fr;
    }
}

/* Forecast comparison panel */
.forecast-panel {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
}

.forecast-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-lg);
}

.forecast-comparison {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-lg);
}

.forecast-column {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.forecast-column-title {
    font-size: var(--font-size-xs);
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding-bottom: var(--space-sm);
    border-bottom: 1px solid var(--border-color);
}

.forecast-row {
    display: flex;
    justify-content: space-between;
    font-size: var(--font-size-sm);
}

.forecast-row-label {
    color: var(--text-secondary);
}

.forecast-row-value {
    font-family: var(--font-mono);
    font-weight: 500;
    color: var(--text-primary);
}

.forecast-chart {
    width: 100%;
    height: 180px;
    margin-top: var(--space-md);
}

/* Gap alerts */
.gap-alerts {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    margin-top: var(--space-md);
}

.gap-alert {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    background: rgba(239, 68, 68, 0.08);
    border-radius: var(--radius-sm);
    font-size: var(--font-size-xs);
    color: var(--accent-red-light);
}

/* Stress test panel */
.stress-panel {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
}

.stress-presets {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
    margin-bottom: var(--space-lg);
}

.stress-preset-btn {
    padding: var(--space-xs) var(--space-md);
    font-size: var(--font-size-xs);
    font-weight: 500;
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition-fast);
}

.stress-preset-btn:hover {
    border-color: var(--accent-blue);
    color: var(--accent-blue);
}

.stress-preset-btn.active {
    background: rgba(74, 108, 247, 0.15);
    border-color: var(--accent-blue);
    color: var(--accent-blue);
}

/* Stress sliders */
.stress-sliders {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-md) var(--space-2xl);
    margin-bottom: var(--space-lg);
}

.stress-slider-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

.stress-slider-header {
    display: flex;
    justify-content: space-between;
    font-size: var(--font-size-xs);
}

.stress-slider-label {
    color: var(--text-secondary);
}

.stress-slider-value {
    font-family: var(--font-mono);
    font-weight: 600;
    color: var(--text-primary);
}

.stress-slider-group input[type="range"] {
    width: 100%;
    height: 4px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--bg-hover);
    border-radius: var(--radius-pill);
    outline: none;
}

.stress-slider-group input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    border-radius: var(--radius-full);
    background: var(--accent-blue);
    cursor: pointer;
    border: 2px solid var(--bg-card);
    box-shadow: 0 0 4px rgba(74, 108, 247, 0.3);
}

/* Stress results */
.stress-results {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: var(--space-md);
}

.stress-result-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    text-align: center;
}

.stress-result-label {
    font-size: var(--font-size-xs);
    color: var(--text-muted);
    margin-bottom: var(--space-xs);
}

.stress-result-value {
    font-size: var(--font-size-lg);
    font-weight: 700;
    font-family: var(--font-mono);
}

.stress-result-sub {
    font-size: var(--font-size-2xs);
    color: var(--text-muted);
    margin-top: 2px;
}

/* Per-layer breakdown in forecast/stress */
.layer-breakdown {
    margin-top: var(--space-lg);
    border-top: 1px solid var(--border-color);
    padding-top: var(--space-md);
}

.layer-breakdown-title {
    font-size: var(--font-size-xs);
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: var(--space-md);
}

.layer-breakdown-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-sm) 0;
    border-bottom: 1px solid rgba(42, 42, 60, 0.5);
    font-size: var(--font-size-sm);
}

.layer-breakdown-row:last-child {
    border-bottom: none;
}

.layer-breakdown-name {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    color: var(--text-secondary);
}

.layer-breakdown-dot {
    width: 8px;
    height: 8px;
    border-radius: var(--radius-full);
}

.layer-breakdown-values {
    display: flex;
    gap: var(--space-xl);
    font-family: var(--font-mono);
}


/* ============================================
   §5 — HISTORY
   "What hedges did I have before?"
   Layer filter, time filter, stats bar, events table
   ============================================ */

/* History filters */
.history-filters {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    margin-bottom: var(--space-lg);
    flex-wrap: wrap;
}

.history-filter-group {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.history-filter-label {
    font-size: var(--font-size-xs);
    color: var(--text-muted);
}

.history-filter-select {
    padding: var(--space-xs) var(--space-md);
    font-size: var(--font-size-xs);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    cursor: pointer;
}

.history-filter-select:focus {
    border-color: var(--accent-blue);
    outline: none;
}

/* History stats bar */
.history-stats {
    display: flex;
    gap: var(--space-2xl);
    padding: var(--space-md) var(--space-lg);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-lg);
    flex-wrap: wrap;
}

.history-stat {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.history-stat-label {
    font-size: var(--font-size-2xs);
    color: var(--text-muted);
    text-transform: uppercase;
}

.history-stat-value {
    font-size: var(--font-size-md);
    font-weight: 600;
    font-family: var(--font-mono);
    color: var(--text-primary);
}

/* History events table */
.history-table-wrapper {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.history-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--font-size-sm);
}

.history-table thead th {
    padding: var(--space-md) var(--space-lg);
    text-align: left;
    font-size: var(--font-size-2xs);
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-secondary);
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}

.history-table thead th:hover {
    color: var(--text-secondary);
}

.history-table thead th .sort-icon {
    margin-left: var(--space-xs);
    opacity: 0.4;
}

.history-table thead th.sorted .sort-icon {
    opacity: 1;
    color: var(--accent-blue);
}

.history-table tbody tr {
    border-bottom: 1px solid rgba(42, 42, 60, 0.5);
    transition: var(--transition-fast);
}

.history-table tbody tr:hover {
    background: var(--bg-hover);
}

.history-table tbody td {
    padding: var(--space-md) var(--space-lg);
    color: var(--text-secondary);
    white-space: nowrap;
}

.history-table tbody td .mono {
    font-family: var(--font-mono);
}

/* Event type badges */
.event-type-badge {
    font-size: var(--font-size-2xs);
    font-weight: 600;
    padding: 2px var(--space-sm);
    border-radius: var(--radius-pill);
    text-transform: uppercase;
}

.event-type-badge.open     { background: rgba(16, 185, 129, 0.15); color: var(--accent-green); }
.event-type-badge.close    { background: rgba(239, 68, 68, 0.15); color: var(--accent-red); }
.event-type-badge.roll     { background: rgba(74, 108, 247, 0.15); color: var(--accent-blue); }
.event-type-badge.harvest  { background: rgba(245, 158, 11, 0.15); color: var(--accent-yellow); }
.event-type-badge.transfer { background: rgba(124, 58, 237, 0.15); color: var(--accent-purple); }
.event-type-badge.rebalance { background: rgba(6, 182, 212, 0.15); color: var(--accent-cyan); }

/* Pagination (if needed) */
.history-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: var(--space-md);
}


/* ============================================
   §6 — MODALS & OVERLAYS
   Z-score modal, close-guard confirmation, simulation
   ============================================ */

/* Z-score detail modal */
.zscore-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: var(--space-md);
}

.zscore-item {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: var(--space-md);
}

.zscore-item-label {
    font-size: var(--font-size-xs);
    color: var(--text-muted);
    margin-bottom: var(--space-xs);
}

.zscore-item-value {
    font-size: var(--font-size-lg);
    font-weight: 700;
    font-family: var(--font-mono);
}

/* Close guard confirmation */
.close-guard-summary {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
    margin: var(--space-md) 0;
}

.close-guard-row {
    display: flex;
    justify-content: space-between;
    padding: var(--space-sm) 0;
    border-bottom: 1px solid var(--border-color);
    font-size: var(--font-size-sm);
}

.close-guard-label {
    color: var(--text-secondary);
}

.close-guard-value {
    font-family: var(--font-mono);
    font-weight: 500;
    color: var(--text-primary);
}

.close-guard-warning {
    display: flex;
    align-items: flex-start;
    gap: var(--space-sm);
    padding: var(--space-md);
    background: rgba(239, 68, 68, 0.08);
    border-radius: var(--radius-md);
    border: 1px solid rgba(239, 68, 68, 0.2);
    font-size: var(--font-size-sm);
    color: var(--accent-red-light);
    line-height: 1.5;
}

/* Simulation panel */
.simulation-chart {
    width: 100%;
    height: 250px;
    margin: var(--space-md) 0;
}

.simulation-params {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-md);
    margin-bottom: var(--space-md);
}

.simulation-param {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

.simulation-param label {
    font-size: var(--font-size-xs);
    color: var(--text-muted);
}

.simulation-param input,
.simulation-param select {
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: var(--font-size-sm);
}

.simulation-param input:focus,
.simulation-param select:focus {
    border-color: var(--accent-blue);
    outline: none;
}


/* ============================================
   §7 — RESPONSIVE
   ============================================ */

@media (max-width: 768px) {
    .hub-grid {
        grid-template-columns: 1fr;
    }

    .trade-option {
        grid-template-columns: 1fr;
        gap: var(--space-sm);
    }

    .trade-option-metric {
        text-align: left;
    }

    .hedge-position-card {
        grid-template-columns: 1fr 1fr;
        gap: var(--space-sm);
    }

    .stress-sliders {
        grid-template-columns: 1fr;
    }

    .forecast-comparison {
        grid-template-columns: 1fr;
    }

    .simulation-params {
        grid-template-columns: 1fr;
    }

    .gantt-row-label {
        width: 80px;
        font-size: var(--font-size-2xs);
    }

    .regime-bar {
        gap: var(--space-md);
        padding: var(--space-sm) var(--space-md);
    }

    .regime-divider {
        display: none;
    }
}

/* ==========================================================================
   HUB REGIME BANNER — compact paused/crisis inline state (Task 1)
   ========================================================================== */

.hub-regime-banner {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    padding: var(--space-xs) var(--space-sm);
    border-radius: var(--radius-sm);
    font-size: var(--font-size-xs);
    margin-top: var(--space-xs);
}

.hub-paused-banner {
    background: rgba(245, 158, 11, 0.12);
    border: 1px solid rgba(245, 158, 11, 0.3);
    color: #f59e0b;
}

.hub-crisis-banner {
    background: rgba(239, 68, 68, 0.12);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #ef4444;
}

.hub-regime-banner-icon {
    flex-shrink: 0;
}

.hub-regime-banner-text {
    flex: 1;
    line-height: 1.4;
}

.hub-regime-banner-info {
    flex-shrink: 0;
    cursor: help;
    opacity: 0.7;
    font-size: var(--font-size-2xs);
}

.hub-regime-banner-info:hover {
    opacity: 1;
}

/* ==========================================================================
   TRADE PICKER — shared conditions header + data note
   ========================================================================== */

.trade-picker-conditions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-xs);
    padding: var(--space-xs) 0 var(--space-sm) 0;
    border-bottom: 1px solid var(--border-subtle);
    margin-bottom: var(--space-sm);
}

.trade-picker-data-note {
    font-size: var(--font-size-2xs);
    color: var(--text-muted);
    text-align: center;
    padding: var(--space-xs) 0 var(--space-sm);
    border-top: 1px solid var(--border-subtle);
    margin-top: var(--space-sm);
}

/* ==========================================================================
   COMPACT TRADE OPTION CARDS (Task 3)
   ========================================================================== */

.trade-option-compact {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-subtle);
    background: var(--bg-card);
    transition: border-color 0.15s ease, background 0.15s ease;
}

.trade-option-compact:not(:last-of-type) {
    margin-bottom: var(--space-xs);
}

.trade-option-compact:hover {
    border-color: var(--border-hover);
    background: var(--bg-hover);
}

.trade-option-compact.recommended {
    border-color: rgba(74, 108, 247, 0.35);
    background: rgba(74, 108, 247, 0.05);
}

.trade-option-compact-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
    min-width: 0;
}

.trade-option-compact-title {
    font-weight: 600;
    font-size: var(--font-size-sm);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.trade-option-compact-sub {
    font-size: var(--font-size-2xs);
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.trade-option-compact-pills {
    display: flex;
    gap: var(--space-xs);
    flex-shrink: 0;
}

.tp-pill {
    padding: 2px 8px;
    border-radius: 10px;
    font-size: var(--font-size-2xs);
    font-weight: 600;
    background: var(--bg-hover);
    color: var(--text-primary);
    white-space: nowrap;
}

.tp-pill-cov {
    background: rgba(0, 200, 150, 0.15);
    color: var(--color-success);
}

.trade-option-compact-actions {
    display: flex;
    gap: var(--space-xs);
    flex-shrink: 0;
}

@media (max-width: 768px) {
    .trade-option-compact {
        flex-wrap: wrap;
    }

    .trade-option-compact-pills {
        order: 3;
        flex-wrap: wrap;
    }

    .trade-option-compact-actions {
        order: 4;
        width: 100%;
        justify-content: flex-end;
    }
}
