* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: #1a1a2e;
    color: #e0e0e0;
    overflow-x: hidden;
}

#controls {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 16px;
    background: #16213e;
    border-bottom: 1px solid #0f3460;
    flex-wrap: wrap;
}

#ticker-select {
    padding: 6px 12px;
    background: #0f3460;
    color: #e0e0e0;
    border: 1px solid #533483;
    border-radius: 4px;
    font-size: 14px;
    cursor: pointer;
}

#period-buttons {
    display: flex;
    align-items: center;
    gap: 4px;
}

.period-label {
    font-size: 11px;
    color: #888;
    margin-right: 2px;
}

.period-btn {
    padding: 6px 14px;
    background: #0f3460;
    color: #e0e0e0;
    border: 1px solid #533483;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    transition: background 0.15s;
}
.period-btn:hover { background: #533483; }
.period-btn.active { background: #533483; border-color: #e94560; }

.action-btn {
    padding: 6px 16px;
    background: #0f3460;
    color: #e0e0e0;
    border: 1px solid #533483;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    transition: all 0.15s;
}
.action-btn:hover { background: #533483; }
.action-btn.active { background: #533483; border-color: #e94560; }
.params-toggle { border-color: #60a5fa; color: #60a5fa; }
.params-toggle:hover { background: #60a5fa; color: #1a1a2e; }

/* ── Parameter Drawer ── */
#param-drawer {
    background: #16213e;
    border-bottom: 1px solid #0f3460;
    padding: 10px 16px;
    overflow: hidden;
    transition: max-height 0.2s;
}
#param-drawer.hidden { display: none; }

#param-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 8px 24px;
}

.param-section { margin-bottom: 4px; }

.param-group-title {
    font-size: 11px;
    text-transform: uppercase;
    color: #60a5fa;
    letter-spacing: 1px;
    margin-bottom: 6px;
    padding-bottom: 3px;
    border-bottom: 1px solid #0f3460;
}

.param-row {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 3px 0;
    font-size: 12px;
}
.param-row.disabled { opacity: 0.4; }

.param-checkbox { width: 14px; height: 14px; cursor: pointer; flex-shrink: 0; accent-color: #4ade80; }
.param-checkbox-spacer { width: 14px; flex-shrink: 0; }

.param-label { width: 130px; flex-shrink: 0; color: #ccc; font-size: 12px; cursor: help; }

.param-range {
    flex: 1;
    min-width: 60px;
    accent-color: #60a5fa;
    height: 4px;
    cursor: pointer;
}

.param-number {
    width: 55px;
    padding: 2px 4px;
    background: #0f3460;
    color: #e0e0e0;
    border: 1px solid #533483;
    border-radius: 3px;
    font-size: 12px;
    text-align: center;
}

.param-auto-label {
    font-size: 11px;
    color: #888;
    display: flex;
    align-items: center;
    gap: 3px;
    cursor: pointer;
    white-space: nowrap;
}
.param-auto-label input { accent-color: #60a5fa; cursor: pointer; }

.param-auto-note {
    font-size: 11px;
    color: #60a5fa;
    font-style: italic;
}

#reset-params {
    margin-top: 8px;
    font-size: 11px;
    padding: 4px 12px;
}

#rejected-toggle {
    font-size: 12px;
    color: #888;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
}
#rejected-toggle input { cursor: pointer; }

.nav-link {
    margin-left: auto;
    color: #60a5fa;
    text-decoration: none;
    font-size: 13px;
}
.nav-link:hover { text-decoration: underline; }

#main-chart-container {
    position: relative;
    width: 100%;
    height: calc(100vh - 52px); /* full height minus controls bar */
}
#main-chart { width: 100%; height: 100%; }

#chart-loader {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(26, 26, 46, 0.85);
    color: #60a5fa;
    font-size: 16px;
    font-weight: 600;
    letter-spacing: 0.5px;
    z-index: 10;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s;
}
#chart-loader.visible {
    opacity: 1;
    pointer-events: auto;
}

/* Impulse list panel */
#impulse-panel {
    border-top: 1px solid #0f3460;
    max-height: 250px;
    overflow-y: auto;
}

#impulse-list {
    display: flex;
    flex-direction: column;
}

.impulse-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 16px;
    border-bottom: 1px solid #1e2d4a;
    cursor: pointer;
    transition: background 0.1s;
    font-size: 13px;
}
.impulse-item:hover { background: #16213e; }
.impulse-item.selected { background: #0f3460; }

.impulse-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}
.impulse-dot.positive { background: #4ade80; }
.impulse-dot.negative { background: #e94560; }
.impulse-dot.uncertain { background: #ffd700; }

.impulse-date { color: #888; min-width: 140px; }
.impulse-strength { min-width: 60px; }
.impulse-prob {
    font-weight: 600;
    min-width: 50px;
    text-align: right;
}
.impulse-prob.high { color: #4ade80; }
.impulse-prob.mid { color: #ffd700; }
.impulse-prob.low { color: #e94560; }

.impulse-days { color: #888; font-size: 12px; }
.entry-badge { color: #60a5fa; font-size: 13px; }
.impulse-obv { color: #60a5fa; font-size: 11px; min-width: 60px; }

.impulse-item.rejected { opacity: 0.5; }
.impulse-item.rejected:hover { opacity: 0.8; }
.impulse-item .rejected-tag {
    font-size: 10px;
    padding: 1px 5px;
    background: #e94560;
    color: #fff;
    border-radius: 3px;
    font-weight: 600;
}

.rule-list { margin: 6px 0; }
.rule-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 3px 0;
    font-size: 12px;
}
.rule-icon { font-size: 14px; width: 18px; text-align: center; }
.rule-icon.pass { color: #4ade80; }
.rule-icon.fail { color: #e94560; }
.rule-desc { flex: 1; }
.rule-desc.fail { color: #e94560; }

/* Info panel (right side) */
#info-panel {
    position: fixed;
    right: 0;
    top: 50px;
    width: 320px;
    background: #16213e;
    border-left: 1px solid #0f3460;
    border-bottom: 1px solid #0f3460;
    padding: 16px;
    z-index: 50;
    border-radius: 0 0 0 8px;
}

#info-content {
    margin-bottom: 12px;
    font-size: 13px;
    line-height: 1.6;
}
#info-content .label { color: #888; }
#info-content .value { color: #e0e0e0; font-weight: 600; }
#info-content .positive { color: #4ade80; }
#info-content .negative { color: #e94560; }

#info-actions {
    display: flex;
    gap: 8px;
}

.verdict-btn {
    flex: 1;
    padding: 8px;
    border: 1px solid #533483;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    background: #0f3460;
    color: #e0e0e0;
    transition: all 0.15s;
}
.verdict-btn.confirm { border-color: #4ade80; color: #4ade80; }
.verdict-btn.confirm:hover { background: #4ade80; color: #1a1a2e; }
.verdict-btn.reject { border-color: #e94560; color: #e94560; }
.verdict-btn.reject:hover { background: #e94560; color: #fff; }
.verdict-btn.close:hover { background: #533483; }

/* Feature & backtest panels */
#feature-panel, #backtest-panel {
    position: fixed;
    bottom: 40px;
    left: 0;
    right: 0;
    background: #16213e;
    border-top: 1px solid #0f3460;
    padding: 16px;
    max-height: 300px;
    overflow-y: auto;
    z-index: 40;
}
#feature-panel h3, #backtest-panel h3 {
    font-size: 14px;
    margin-bottom: 12px;
    color: #888;
}

.hidden { display: none !important; }

/* ── Impulse overlay (on chart click) ── */
#impulse-overlay {
    position: absolute;
    top: 60px; /* below controls + param drawer */
    right: 10px;
    width: 420px;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
    background: rgba(22, 33, 62, 0.96);
    border: 1px solid #533483;
    border-radius: 8px;
    z-index: 100;
    box-shadow: 0 4px 20px rgba(0,0,0,0.5);
}
#impulse-overlay.hidden { display: none; }

#impulse-overlay-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    border-bottom: 1px solid #0f3460;
    font-size: 13px;
    font-weight: 600;
}
#impulse-overlay-close {
    background: none;
    border: none;
    color: #888;
    font-size: 18px;
    cursor: pointer;
    padding: 0 4px;
}
#impulse-overlay-close:hover { color: #e94560; }

#impulse-overlay-body { padding: 8px 12px; }

.overlay-section { margin-bottom: 8px; }

.overlay-bar-info { font-size: 12px; color: #888; margin-bottom: 6px; }

.overlay-rules-list {
    display: flex;
    flex-direction: column;
    gap: 3px;
    font-size: 11px;
}
.overlay-rule {
    white-space: nowrap;
    cursor: help;
}
.overlay-rule.pass { color: #4ade80; }
.overlay-rule.fail { color: #e94560; }

.overlay-vol-profile {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 12px;
    font-size: 11px;
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px solid #1e2d4a;
}
.overlay-vol-metric {
    cursor: help;
    white-space: nowrap;
}

.overlay-status { margin-bottom: 6px; }
.overlay-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
}
.overlay-badge.confirmed { background: #4ade8022; color: #4ade80; border: 1px solid #4ade8044; }
.overlay-badge.waiting { background: #ffd70022; color: #ffd700; border: 1px solid #ffd70044; }
.overlay-badge.late { background: #e9456022; color: #e94560; border: 1px solid #e9456044; margin-left: 4px; }

.overlay-ev { margin: 6px 0; }
.overlay-ev-line {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    padding: 3px 0;
    border-bottom: 1px solid #0f346033;
}
.overlay-ev-profile { font-weight: 600; min-width: 65px; color: #ccc; }
.overlay-ev-entry { color: #888; min-width: 80px; }
.overlay-ev-prob { color: #60a5fa; min-width: 70px; }
.overlay-ev-rr { color: #888; min-width: 55px; }
.overlay-ev-val { font-weight: 600; min-width: 55px; }
.overlay-ev-verdict { font-weight: 700; }

.overlay-curves {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 6px;
}
.overlay-curve-box {
    background: #0f346044;
    border-radius: 4px;
    padding: 6px 8px;
}
.overlay-curve-title {
    font-size: 10px;
    text-transform: uppercase;
    color: #60a5fa;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.overlay-loading {
    color: #888;
    font-size: 12px;
    padding: 8px 0;
    text-align: center;
}

/* ── Advisor modal ── */
#advisor-modal {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
}
#advisor-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.7);
}
#advisor-content {
    position: relative;
    background: #16213e;
    border: 1px solid #0f3460;
    border-radius: 8px;
    width: 680px;
    max-width: 95vw;
    max-height: 90vh;
    overflow-y: auto;
    z-index: 201;
}
#advisor-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    border-bottom: 1px solid #0f3460;
}
#advisor-title {
    font-size: 15px;
    font-weight: 700;
    color: #ffd700;
}
#advisor-close {
    background: none;
    border: none;
    color: #888;
    font-size: 18px;
    cursor: pointer;
    padding: 0 4px;
}
#advisor-close:hover { color: #e0e0e0; }
#advisor-body {
    padding: 20px;
}
#advisor-loading {
    color: #888;
    font-size: 13px;
    text-align: center;
    padding: 20px;
}
.advisor-section {
    margin-bottom: 20px;
}
.advisor-section-title {
    font-size: 12px;
    font-weight: 700;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 10px;
}
.advisor-prices {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}
.advisor-price-item {
    font-size: 12px;
}
.advisor-price-item .price-label { color: #888; }
.advisor-price-item .price-value { color: #e0e0e0; font-weight: 600; margin-left: 4px; }
.advisor-charts {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 16px;
}
.advisor-chart-box {
    background: #0f1e3a;
    border-radius: 6px;
    padding: 12px;
}
.advisor-chart-box h4 {
    font-size: 12px;
    color: #60a5fa;
    margin-bottom: 10px;
    font-weight: 600;
}
.advisor-bars {
    display: flex;
    flex-direction: column;
    gap: 5px;
}
.advisor-bar-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
}
.advisor-bar-label {
    width: 36px;
    text-align: right;
    color: #888;
    flex-shrink: 0;
}
.advisor-bar-track {
    flex: 1;
    height: 14px;
    background: #1a2d4a;
    border-radius: 3px;
    overflow: hidden;
}
.advisor-bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.4s ease;
}
.advisor-bar-prob {
    width: 36px;
    text-align: left;
    font-weight: 600;
    flex-shrink: 0;
}
.advisor-strategy {
    background: #0f1e3a;
    border-radius: 6px;
    padding: 14px;
    font-size: 12px;
    line-height: 1.7;
    white-space: pre-line;
    color: #c0d0e0;
}
.advisor-entry-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 700;
    margin-bottom: 10px;
}
.advisor-entry-badge.confirmed { background: #4ade8022; color: #4ade80; border: 1px solid #4ade80; }
.advisor-entry-badge.waiting   { background: #ffd70022; color: #ffd700; border: 1px solid #ffd700; }
.advisor-profiles-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 8px;
    margin-bottom: 10px;
}
.advisor-profile-card {
    border: 1px solid #4ade80;
    border-radius: 6px;
    padding: 10px;
    background: #0f1e3a;
}
.advisor-profile-header {
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 4px;
}
.advisor-profile-verdict {
    font-size: 14px;
    font-weight: 800;
    margin-bottom: 6px;
}
.advisor-profile-detail {
    font-size: 11px;
    line-height: 1.6;
    color: #a0b0c0;
}
.advisor-profile-ev {
    font-size: 15px;
    font-weight: 800;
    margin-top: 6px;
}
.advisor-ev-box {
    border: 1px solid #4ade80;
    border-radius: 6px;
    padding: 12px 14px;
    margin-bottom: 12px;
}
.advisor-ev-verdict {
    font-size: 16px;
    font-weight: 800;
    margin-bottom: 8px;
    letter-spacing: 0.05em;
}
.advisor-ev-detail {
    display: flex;
    flex-direction: column;
    gap: 3px;
    font-size: 12px;
}
.advisor-ev-row { color: #c0d0e0; }
.advisor-ev-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 11px;
    margin-top: 8px;
}
.advisor-ev-table th {
    text-align: left;
    padding: 4px 6px;
    color: #555;
    border-bottom: 1px solid #1e2d4a;
    font-weight: 600;
}
.advisor-ev-table td {
    padding: 4px 6px;
    border-bottom: 1px solid #0f1e3a;
}
.advisor-ev-table tr:first-child td { font-weight: 600; }
.advisor-warning {
    background: #ffd70015;
    border: 1px solid #ffd700;
    border-radius: 4px;
    padding: 6px 12px;
    color: #ffd700;
    font-size: 11px;
    margin-bottom: 12px;
}
.advisor-quality {
    font-size: 11px;
    color: #888;
    margin-top: 6px;
    line-height: 1.8;
}
.advisor-quality b { color: #c0d0e0; }
.advisor-btn {
    padding: 6px 14px;
    background: #0f3460;
    color: #ffd700;
    border: 1px solid #ffd700;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    transition: all 0.15s;
    margin-top: 6px;
}
.advisor-btn:hover { background: #ffd700; color: #1a1a2e; }
