/* ── Info icon & tooltip (shared across Analytics + History) ── */
.info-icon {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    cursor: default;
}

.info-icon svg {
    color: var(--text-tertiary);
    transition: color 0.15s;
}

.info-icon:hover svg {
    color: var(--text-secondary);
}

.info-icon .tooltip {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 9px 12px;
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.6;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s;
    z-index: 200;
    max-width: 280px;
    width: max-content;
    text-align: left;
    font-weight: 400;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    white-space: normal;
}

.info-icon .tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: var(--border-color);
}

.info-icon:hover .tooltip {
    opacity: 1;
    pointer-events: auto;
}

.tooltip-learn {
    display: inline-block;
    margin-top: 7px;
    font-size: 11px;
    font-weight: 600;
    color: var(--accent);
    text-decoration: none;
    letter-spacing: 0.02em;
    border-top: 1px solid var(--border-color);
    padding-top: 7px;
    width: 100%;
}
.tooltip-learn:hover {
    color: #fff;
}

.card-title-row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 14px;
}

.kpi-label-row {
    display: flex;
    align-items: center;
    gap: 5px;
    margin-bottom: 10px;
}

/* ── Analytics & History pages ─────────────────────────────── */
.page-section {
    display: none;
    padding: 28px 24px;
    max-width: 1400px;
    margin: 0 auto;
}

.page-section.active {
    display: block;
}

.page-section-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}

.page-section-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.page-section-subtitle {
    font-size: 12px;
    color: var(--text-secondary);
}

.page-tab-row {
    display: flex;
    gap: 4px;
    background: var(--bg-tertiary);
    padding: 4px;
    border-radius: 8px;
}

.page-tab {
    font-size: 12px;
    padding: 6px 16px;
    border-radius: 6px;
    color: var(--text-secondary);
    cursor: pointer;
    background: none;
    border: none;
    font-family: inherit;
    transition: background 0.15s, color 0.15s;
}

.page-tab.active {
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-weight: 600;
}

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}

.kpi-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 18px;
}

.kpi-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-tertiary);
}

.kpi-value {
    font-size: 26px;
    font-weight: 700;
    font-family: 'IBM Plex Mono', monospace;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.kpi-value.green {
    color: var(--green);
}

.kpi-value.red {
    color: var(--red);
}

.kpi-value.yellow {
    color: var(--accent);
}

.kpi-value.blue {
    color: #5B8FFF;
}

.kpi-value.muted {
    color: var(--text-tertiary);
}

.kpi-sub {
    font-size: 11px;
    color: var(--text-tertiary);
}

.analytics-grid-main {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 16px;
    margin-bottom: 20px;
}

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

.analytics-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 20px;
}

.analytics-card-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

/* Heatmap */
.heatmap-legend {
    display: flex;
    gap: 16px;
    margin-bottom: 12px;
}

.hm-legend-item {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    color: var(--text-secondary);
}

.hm-legend-dot {
    width: 8px;
    height: 8px;
    border-radius: 2px;
}

.heatmap-grid {
    display: grid;
    grid-template-columns: repeat(10, 1fr);
    gap: 4px;
}

.hm-cell {
    aspect-ratio: 1;
    border-radius: 5px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: default;
    transition: opacity 0.15s;
}

.hm-cell:hover {
    opacity: 0.7;
}

.hm-cell .hm-sym {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.95);
    margin-bottom: 2px;
    letter-spacing: 0.3px;
}

.hm-cell .hm-sig {
    font-size: 7px;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.hm-buy {
    background: rgba(14, 203, 129, 0.40);
    border: 1px solid rgba(14, 203, 129, 0.70);
}

.hm-hold {
    background: rgba(240, 185, 11, 0.30);
    border: 1px solid rgba(240, 185, 11, 0.60);
}

.hm-sell {
    background: rgba(246, 70, 93, 0.40);
    border: 1px solid rgba(246, 70, 93, 0.70);
}

/* Distribution bars */
.dist-bar-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.dist-bar-label {
    font-size: 11px;
    font-weight: 600;
    width: 36px;
}

.dist-bar-bg {
    flex: 1;
    height: 7px;
    background: var(--bg-tertiary);
    border-radius: 4px;
    overflow: hidden;
}

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

.dist-bar-count {
    font-size: 11px;
    font-family: 'IBM Plex Mono', monospace;
    color: var(--text-tertiary);
    width: 24px;
    text-align: right;
}

/* Portfolio exposure */
.exposure-bar-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.exposure-sym {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-primary);
    width: 44px;
}

.exposure-bar-bg {
    flex: 1;
    height: 8px;
    background: var(--bg-tertiary);
    border-radius: 4px;
    overflow: hidden;
}

.exposure-bar-fill {
    height: 100%;
    border-radius: 4px;
}

.fill-buy {
    background: var(--green);
}

.fill-hold {
    background: var(--accent);
}

.fill-sell {
    background: var(--red);
}

.fill-none {
    background: var(--text-tertiary);
}

.exposure-pct {
    font-size: 10px;
    font-family: 'IBM Plex Mono', monospace;
    width: 36px;
    text-align: right;
}

.exposure-summary {
    display: flex;
    gap: 8px;
    margin-top: 14px;
}

.exposure-box {
    flex: 1;
    background: var(--bg-tertiary);
    border-radius: 6px;
    padding: 10px;
    text-align: center;
}

.exposure-box-val {
    font-size: 18px;
    font-weight: 700;
    font-family: 'IBM Plex Mono', monospace;
    margin-bottom: 3px;
}

.exposure-box-label {
    font-size: 10px;
    color: var(--text-tertiary);
}

/* Risk meter */
.risk-section {
    margin-top: 16px;
}

.risk-label-row {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-tertiary);
    margin-bottom: 8px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-color);
    font-weight: 600;
}

.risk-bar {
    position: relative;
    height: 8px;
    background: linear-gradient(to right, #0ECB81, #F0B90B, #F6465D);
    border-radius: 4px;
    margin-bottom: 6px;
    overflow: visible;
}

.risk-needle {
    position: absolute;
    top: -4px;
    width: 3px;
    height: 16px;
    background: white;
    border-radius: 2px;
    transform: translateX(-50%);
    box-shadow: 0 0 4px rgba(0, 0, 0, 0.5);
}

.risk-labels {
    display: flex;
    justify-content: space-between;
    font-size: 9px;
    color: var(--text-tertiary);
    margin-bottom: 10px;
}

.risk-score-text {
    font-size: 12px;
    color: var(--text-secondary);
}

/* Signal table */
.signal-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 12px;
}

.signal-table th {
    position: sticky;
    top: 0;
    z-index: 5;
    background: var(--bg-secondary);
    text-align: left;
    color: var(--text-tertiary);
    font-weight: 500;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    padding: 8px 10px;
    border-bottom: 1px solid var(--border-color);
}

.signal-table th:not(:first-child) {
    text-align: center;
}

.signal-table td {
    padding: 9px 10px;
    border-bottom: 1px solid rgba(43, 49, 57, 0.5);
    color: var(--text-secondary);
    vertical-align: middle;
}

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

.sig-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 7px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 700;
    font-family: 'IBM Plex Mono', monospace;
}

.sig-buy {
    background: rgba(14, 203, 129, 0.12);
    color: var(--green);
}

.sig-sell {
    background: rgba(246, 70, 93, 0.12);
    color: var(--red);
}

.sig-hold {
    background: rgba(240, 185, 11, 0.12);
    color: var(--accent);
}

.sig-deposit {
    background: rgba(240, 185, 11, 0.12);
    color: #F0B90B;
}

/* History page */
.history-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 20px;
}

/* Timeline */
.signal-timeline {
    position: relative;
    padding-left: 20px;
    max-height: 568px;
    overflow-y: auto;
}

.signal-timeline::before {
    content: '';
    position: absolute;
    left: 6px;
    top: 8px;
    bottom: 8px;
    width: 1px;
    background: var(--border-color);
}

.tl-item {
    position: relative;
    margin-bottom: 16px;
}

.tl-dot {
    position: absolute;
    left: -17px;
    top: 4px;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    border: 1.5px solid;
}

.tl-dot.buy {
    background: rgba(14, 203, 129, 0.25);
    border-color: var(--green);
}

.tl-dot.sell {
    background: rgba(246, 70, 93, 0.25);
    border-color: var(--red);
}

.tl-dot.hold {
    background: rgba(240, 185, 11, 0.25);
    border-color: var(--accent);
}

.tl-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 3px;
    flex-wrap: wrap;
    gap: 4px;
}

.tl-asset {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 6px;
}

.tl-date {
    font-size: 10px;
    color: var(--text-tertiary);
    font-family: 'IBM Plex Mono', monospace;
}

.tl-detail {
    font-size: 11px;
    color: var(--text-secondary);
}

.outcome-win {
    color: var(--green);
    font-weight: 600;
    display: flex;
    gap: 2px;
    align-items: center;
}

.outcome-loss {
    color: var(--red);
    font-weight: 600;
    display: flex;
    gap: 2px;
    align-items: center;
}

.outcome-pending {
    color: var(--text-tertiary);
    display: flex;
    gap: 2px;
    align-items: center;
}

/* Sparkline */
.sparkline {
    display: flex;
    align-items: flex-end;
    gap: 2px;
    height: 28px;
}

.spark-bar {
    width: 4px;
    border-radius: 1px;
    min-height: 2px;
}

/* Outcome summary boxes */
.outcome-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.outcome-box {
    background: var(--bg-tertiary);
    border-radius: 6px;
    padding: 10px;
    text-align: center;
}

.outcome-box-val {
    font-size: 16px;
    font-weight: 700;
    font-family: 'IBM Plex Mono', monospace;
    margin-bottom: 2px;
}

.outcome-box-label {
    font-size: 9px;
    color: var(--text-tertiary);
}

/* P&L missing cost basis */
.pnl-missing {
    color: var(--text-tertiary);
    font-size: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.add-price-btn {
    background: none;
    border: 1px dashed var(--text-tertiary);
    border-radius: 4px;
    color: var(--text-secondary);
    font-size: 11px;
    padding: 2px 8px;
    cursor: pointer;
    white-space: nowrap;
    transition: border-color 0.15s, color 0.15s;
}

.add-price-btn:hover {
    border-color: #5B8FFF;
    color: #5B8FFF;
}

/* Inline buy price edit overlay */
.buy-price-popup {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.buy-price-popup-inner {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 28px 32px;
    width: 320px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.buy-price-popup-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}

.buy-price-popup-sub {
    font-size: 12px;
    color: var(--text-tertiary);
    margin-top: -10px;
}

.buy-price-popup input {
    background: var(--input-bg, #0f0f1a);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 14px;
    padding: 10px 14px;
    width: 100%;
    box-sizing: border-box;
    outline: none;
}

.buy-price-popup input:focus {
    border-color: var(--accent);
}

.buy-price-popup-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.buy-price-popup-actions button {
    border: none;
    border-radius: 8px;
    padding: 8px 20px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
}
/* Bounded scroll container for tables inside analytics cards — makes sticky th work */
.analytics-card .table-container {
    overflow: auto;
    max-height: 480px;
}