* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background: #0f172a; color: #e2e8f0; min-height: 100vh; padding: 24px; }
h1 { font-size: 1.5rem; font-weight: 700; color: #f8fafc; margin-bottom: 4px; }
.subtitle { color: #94a3b8; font-size: 0.875rem; margin-bottom: 24px; }
.controls { background: #1e293b; border-radius: 12px; padding: 20px; margin-bottom: 24px; display: flex; flex-wrap: wrap; gap: 20px; align-items: flex-end; }
.control-group { display: flex; flex-direction: column; gap: 6px; }
label { font-size: 0.75rem; color: #94a3b8; text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600; }
select { background: #0f172a; color: #e2e8f0; border: 1px solid #334155; border-radius: 6px; padding: 8px 12px; font-size: 0.875rem; cursor: pointer; }
select:focus { outline: none; border-color: #3b82f6; }
.checkbox-group { display: flex; align-items: center; gap: 8px; }
input[type="checkbox"] { width: 16px; height: 16px; cursor: pointer; accent-color: #3b82f6; }
.slider-group { display: flex; align-items: center; gap: 10px; }
input[type="range"] { width: 120px; accent-color: #3b82f6; }
.slider-val { font-size: 0.8rem; color: #60a5fa; font-weight: 600; min-width: 40px; }
.filter-block { background: #0f172a; border-radius: 8px; padding: 12px 16px; display: flex; flex-direction: column; gap: 10px; border: 1px solid #1e293b; }
.btn { background: #3b82f6; color: white; border: none; border-radius: 8px; padding: 10px 20px; font-size: 0.875rem; font-weight: 600; cursor: pointer; transition: background 0.2s; height: 40px; }
.btn:hover { background: #2563eb; }
.btn:disabled { background: #1e40af; cursor: not-allowed; }
.btn-green { background: #16a34a; }
.btn-green:hover { background: #15803d; }
.btn-green:disabled { background: #14532d; }
.btn-amber { background: #d97706; }
.btn-amber:hover { background: #b45309; }
.callout { background: #1e293b; border-radius: 12px; padding: 20px 24px; margin-bottom: 24px; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 16px; }
.callout-main { font-size: 1.25rem; font-weight: 700; color: #f8fafc; }
.callout-main span { color: #3b82f6; }
.callout-sub { font-size: 0.875rem; color: #94a3b8; }
.callout-meta { display: flex; flex-direction: column; gap: 4px; text-align: right; }
.badge { display: inline-block; padding: 2px 10px; border-radius: 9999px; font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; }
.badge-1h { background: #78350f; color: #fcd34d; }
.badge-5m { background: #14532d; color: #86efac; }
.badge-1m { background: #1e1b4b; color: #a5b4fc; }
.badge-prefetch { background: #1e3a5f; color: #93c5fd; }
.note-1h { background: #451a03; border: 1px solid #78350f; border-radius: 8px; padding: 10px 16px; font-size: 0.8rem; color: #fcd34d; margin-bottom: 16px; display: none; }
.chart-wrap { background: #1e293b; border-radius: 12px; padding: 24px; margin-bottom: 24px; }
.chart-wrap h2 { font-size: 1rem; color: #94a3b8; margin-bottom: 16px; }
canvas { max-height: 320px; }
.table-wrap { background: #1e293b; border-radius: 12px; padding: 24px; overflow-x: auto; }
.table-wrap h2 { font-size: 1rem; color: #94a3b8; margin-bottom: 16px; }
table { width: 100%; border-collapse: collapse; font-size: 0.8125rem; }
th { color: #64748b; text-transform: uppercase; font-size: 0.7rem; letter-spacing: 0.05em; padding: 8px 12px; text-align: left; border-bottom: 1px solid #334155; }
td { padding: 8px 12px; border-bottom: 1px solid #1e293b; color: #e2e8f0; }
tr.filtered td { color: #475569; text-decoration: line-through; }
.reason-badge { display: inline-block; padding: 1px 8px; border-radius: 4px; font-size: 0.65rem; font-weight: 700; text-transform: uppercase; }
.reason-trend { background: #7c3aed22; color: #a78bfa; border: 1px solid #7c3aed44; }
.reason-included { background: #15803d22; color: #4ade80; border: 1px solid #15803d44; }
.positive { color: #4ade80; }
.negative { color: #f87171; }
.loading { text-align: center; color: #64748b; padding: 40px; font-size: 0.875rem; }
.error { background: #450a0a; border: 1px solid #dc2626; border-radius: 8px; padding: 12px 16px; color: #f87171; font-size: 0.875rem; margin-bottom: 16px; }

/* Tabs */
.tabs { display: flex; gap: 0; margin-bottom: 24px; }
.tab { padding: 12px 24px; font-size: 0.875rem; font-weight: 600; cursor: pointer; border: 1px solid #334155; background: #0f172a; color: #64748b; transition: all 0.2s; }
.tab:first-child { border-radius: 8px 0 0 8px; }
.tab:last-child { border-radius: 0 8px 8px 0; }
.tab.active { background: #1e293b; color: #f8fafc; border-color: #3b82f6; }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* Predictor styles */
.reco-card { background: #1e293b; border-radius: 12px; padding: 24px; margin-bottom: 24px; border: 2px solid #334155; }
.reco-card.sell { border-color: #16a34a; }
.reco-card.likely-sell { border-color: #84cc16; }
.reco-card.hold { border-color: #d97706; }
.reco-card.wait { border-color: #64748b; }
.reco-label { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.1em; color: #94a3b8; margin-bottom: 8px; }
.reco-action { font-size: 2rem; font-weight: 800; margin-bottom: 4px; }
.reco-action.sell { color: #4ade80; }
.reco-action.likely-sell { color: #a3e635; }
.reco-action.hold { color: #fbbf24; }
.reco-action.wait { color: #94a3b8; }
.reco-reason { color: #94a3b8; font-size: 0.875rem; margin-bottom: 16px; }
.reco-stats { display: flex; gap: 32px; flex-wrap: wrap; }
.reco-stat { display: flex; flex-direction: column; gap: 2px; }
.reco-stat-label { font-size: 0.7rem; color: #64748b; text-transform: uppercase; }
.reco-stat-value { font-size: 1.1rem; font-weight: 700; color: #f8fafc; }
.confidence-meter { width: 100%; height: 8px; background: #0f172a; border-radius: 4px; overflow: hidden; margin-top: 16px; }
.confidence-fill { height: 100%; border-radius: 4px; transition: width 0.5s ease; }

.metrics-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 24px; }
.metric-card { background: #1e293b; border-radius: 8px; padding: 16px; text-align: center; }
.metric-value { font-size: 1.5rem; font-weight: 800; color: #f8fafc; }
.metric-label { font-size: 0.7rem; color: #64748b; text-transform: uppercase; margin-top: 4px; }

.backtest-day { display: flex; align-items: center; gap: 12px; padding: 8px 12px; border-bottom: 1px solid #1e293b; }
.backtest-day:last-child { border-bottom: none; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.dot.correct { background: #4ade80; }
.dot.wrong { background: #f87171; }

/* Flatpickr dark theme overrides */
.flatpickr-input { background: #0f172a !important; color: #e2e8f0 !important; border: 1px solid #334155 !important; border-radius: 6px !important; padding: 8px 12px !important; font-size: 0.875rem !important; width: 140px; cursor: pointer; }
.flatpickr-calendar { background: #1e293b !important; border: 1px solid #334155 !important; box-shadow: 0 8px 24px #00000066 !important; }
.flatpickr-months, .flatpickr-weekdays { background: #1e293b !important; }
.flatpickr-month, .flatpickr-weekday { color: #94a3b8 !important; fill: #94a3b8 !important; }
.flatpickr-day { color: #e2e8f0 !important; border-radius: 4px !important; }
.flatpickr-day:hover { background: #334155 !important; border-color: transparent !important; }
.flatpickr-day.selected { background: #3b82f6 !important; border-color: #3b82f6 !important; color: #fff !important; }
.flatpickr-day.today { border-color: #3b82f6 !important; }
.flatpickr-day.disabled,
.flatpickr-day.disabled:hover,
.flatpickr-day.notAllowed,
.flatpickr-day.notAllowed:hover { color: #475569 !important; background: transparent !important; border-color: transparent !important; cursor: default !important; opacity: 0.45; text-decoration: line-through; pointer-events: none; }
.numInput, .cur-year { color: #e2e8f0 !important; background: transparent !important; }
.flatpickr-prev-month svg, .flatpickr-next-month svg { fill: #94a3b8 !important; }
.flatpickr-prev-month:hover svg, .flatpickr-next-month:hover svg { fill: #e2e8f0 !important; }

/* Predictor sub-tabs */
.sub-nav { display:flex; gap:4px; margin-bottom:20px; border-bottom:1px solid #1e293b; padding-bottom:0; }
.sub-tab { background:none; border:none; color:#64748b; padding:8px 18px; font-size:0.9rem; cursor:pointer; border-bottom:2px solid transparent; margin-bottom:-1px; transition:color 0.15s; }
.sub-tab.active { color:#f8fafc; border-bottom-color:#3b82f6; }
.market-status-bar { display:flex; align-items:center; gap:10px; padding:8px 14px; background:#0f172a; border-radius:8px; margin-bottom:16px; font-size:0.85rem; }
.time-slider-row { display:flex; align-items:center; gap:12px; margin:0 0 20px; }
.time-slider-row input[type=range] { flex:1; accent-color:#3b82f6; }
.reco-card.miss { border-color:#f59e0b44; }
.reco-action.miss { color:#f59e0b; }
.reco-card { margin-bottom:0; }

/* Skeleton / loading states */
@keyframes skeleton-pulse {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 0.15; }
}
.skeleton { position: relative; overflow: hidden; pointer-events: none; }
.skeleton * { color: transparent !important; }
.skeleton .reco-action,
.skeleton .reco-stat-value,
.skeleton .reco-label,
.skeleton .reco-stat-label,
.skeleton .confidence-fill { background: #334155; border-radius: 4px; animation: skeleton-pulse 1.5s ease-in-out infinite; }
.skeleton .reco-action { min-width: 80px; min-height: 2rem; }
.skeleton .reco-stat-value { min-width: 48px; min-height: 1.1rem; display: inline-block; }
.skeleton .confidence-fill { width: 60% !important; }

@keyframes spin { to { transform: rotate(360deg); } }
.spinner { display: inline-block; width: 16px; height: 16px; border: 2px solid #334155; border-top-color: #3b82f6; border-radius: 50%; animation: spin 0.6s linear infinite; vertical-align: middle; margin-right: 6px; }
.loading-overlay { display: flex; align-items: center; justify-content: center; padding: 32px; color: #64748b; font-size: 0.85rem; }

.chart-skeleton { background: #1e293b; border-radius: 12px; padding: 24px; margin-top: 20px; min-height: 200px; display: flex; align-items: center; justify-content: center; }
.chart-skeleton-inner { width: 100%; height: 160px; background: linear-gradient(90deg, #334155 25%, #3d4f6a 50%, #334155 75%); background-size: 200% 100%; border-radius: 8px; animation: skeleton-pulse 1.5s ease-in-out infinite; }

/* Streaming indicator */
@keyframes pulse-dot { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }
.stream-indicator { display: inline-flex; align-items: center; gap: 6px; font-size: 0.78rem; padding: 2px 10px; border-radius: 12px; }
.stream-indicator .stream-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.stream-indicator.streaming .stream-dot { background: #4ade80; animation: pulse-dot 1.5s ease-in-out infinite; }
.stream-indicator.streaming { color: #4ade80; }
.stream-indicator.polling .stream-dot { background: #64748b; }
.stream-indicator.polling { color: #64748b; }

/* Technical Analysis tab */
.ta-top-row { display: grid; grid-template-columns: 1fr 260px; gap: 16px; margin-bottom: 16px; align-items: start; }
@media (max-width: 900px) { .ta-top-row { grid-template-columns: 1fr; } }
.ta-card { background: #1e293b; border-radius: 12px; padding: 20px; margin-bottom: 16px; }
.ta-card h3 { font-size: 0.8rem; color: #64748b; margin-bottom: 14px; text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600; }
.ta-level-row { display: flex; align-items: center; gap: 8px; padding: 7px 0; border-bottom: 1px solid #0f172a; font-size: 0.8rem; }
.ta-level-row:last-child { border-bottom: none; }
.ta-level-icon { font-size: 0.75rem; width: 16px; text-align: center; flex-shrink: 0; }
.ta-level-price { font-weight: 700; color: #f8fafc; min-width: 56px; }
.ta-level-label { color: #64748b; flex: 1; font-size: 0.75rem; }
.ta-level-pct { font-size: 0.72rem; margin-left: auto; white-space: nowrap; }
.formation-pills { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.formation-pill { display: inline-flex; align-items: center; gap: 4px; padding: 4px 11px; border-radius: 9999px; font-size: 0.73rem; font-weight: 600; cursor: pointer; border: 1.5px solid #334155; background: #0f172a; color: #475569; transition: all 0.15s; user-select: none; }
.formation-pill.up { border-color: #4ade8055; color: #4ade8099; }
.formation-pill.down { border-color: #f8717155; color: #f8717199; }
.formation-pill.neutral { border-color: #94a3b855; color: #94a3b899; }
.formation-pill.selected.up { background: #4ade8018; border-color: #4ade80; color: #4ade80; }
.formation-pill.selected.down { background: #f8717118; border-color: #f87171; color: #f87171; }
.formation-pill.selected.neutral { background: #94a3b818; border-color: #94a3b8; color: #94a3b8; }
/* Inline tooltip for chart heading terms */
.tip { border-bottom: 1px dashed #475569; cursor: help; position: relative; }
.tip::after {
  content: attr(data-tip);
  position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%);
  background: #1e293b; color: #e2e8f0; font-size: 0.72rem; font-weight: 400;
  white-space: nowrap; padding: 5px 9px; border-radius: 6px;
  border: 1px solid #334155; pointer-events: none; opacity: 0;
  transition: opacity 0.15s; z-index: 100;
}
.tip:hover::after { opacity: 1; }
