:root {
  --surface: #f8f9ff;
  --surface-soft: #f0f2f6;
  --surface-card: #ffffff;
  --surface-blue: #eaf0ff;
  --text: #0b1c30;
  --muted: #667085;
  --border: #e2e8f0;
  --blue: #1e40af;
  --blue-dark: #00288e;
  --green: #10b981;
  --red: #ef4444;
  --chart: #07101d;
  --chart-grid: #243041;
  --shadow: 0 10px 30px rgba(15, 23, 42, 0.06);
  --radius: 16px;
  --sidebar-width: 280px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--surface);
  color: var(--text);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .6; }

.app-shell { min-height: 100vh; }
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-width);
  padding: 28px 18px 22px;
  background: #fff;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 22px;
  z-index: 60;
  transition: transform .24s ease;
}
.sidebar.hidden { transform: translateX(-100%); }
.brand-row { display: flex; align-items: center; gap: 12px; padding: 0 8px; }
.brand-mark {
  width: 42px; height: 42px; border-radius: 11px; display: grid; place-items: center;
  color: #fff; background: var(--blue); font-family: "Plus Jakarta Sans", sans-serif;
  font-size: 20px; font-weight: 700;
}
.brand-name { font: 700 22px/1.1 "Plus Jakarta Sans", sans-serif; color: var(--blue); }
.brand-subtitle { margin-top: 4px; color: var(--muted); font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; }
.sidebar-close { margin-left: auto; }
.icon-button {
  width: 38px; height: 38px; border-radius: 10px; border: 1px solid transparent;
  background: transparent; color: #475467; display: grid; place-items: center; font-size: 20px;
}
.icon-button:hover { background: var(--surface-soft); color: var(--blue); }
.nav-list { display: grid; gap: 8px; }
.nav-item {
  width: 100%; border: 0; background: transparent; color: #4b5565;
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 10px;
  text-align: left; font-weight: 600;
}
.nav-item:hover { background: var(--surface-soft); color: var(--blue); }
.nav-item.active { background: #dfe9ff; color: var(--blue); box-shadow: inset -4px 0 0 var(--blue); }
.nav-icon { width: 24px; text-align: center; font-size: 20px; }
.sidebar-section { padding: 18px 8px 0; border-top: 1px solid var(--border); }
.section-kicker { color: var(--text); font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; margin-bottom: 14px; }
.field-label { display: flex; justify-content: space-between; gap: 8px; margin: 12px 0 7px; color: #475467; font-size: 12px; font-weight: 600; }
.field-control {
  width: 100%; border: 1px solid #d7deea; border-radius: 9px; background: #fff;
  padding: 10px 12px; color: var(--text); outline: none;
}
.field-control:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(30,64,175,.1); }
input[type="range"] { width: 100%; accent-color: var(--blue); }
.sidebar-footer { margin-top: auto; display: grid; gap: 12px; padding: 16px 8px 0; border-top: 1px solid var(--border); }
.market-status { display: flex; align-items: center; gap: 8px; color: #475467; font-size: 12px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 4px rgba(16,185,129,.12); }
.sidebar-open-button {
  position: fixed; left: 16px; top: 18px; z-index: 55; display: none;
  border: 1px solid var(--border); border-radius: 10px; padding: 9px 13px;
  background: #fff; color: var(--text); box-shadow: var(--shadow); font-weight: 700;
}
.sidebar-open-button.visible { display: block; }
.sidebar-backdrop { display: none; }

.main-content { margin-left: var(--sidebar-width); min-height: 100vh; transition: margin-left .24s ease; }
.main-content.expanded { margin-left: 0; }
.topbar {
  position: sticky; top: 0; z-index: 40; height: 76px; padding: 0 32px;
  display: flex; align-items: center; justify-content: space-between;
  background: rgba(255,255,255,.92); backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
.search-wrap { position: relative; width: min(480px, 62vw); }
.search-wrap input {
  width: 100%; height: 42px; padding: 0 42px; border: 1px solid #d9e1ee;
  border-radius: 10px; background: var(--surface-soft); color: var(--text); outline: none;
}
.search-wrap input:focus { background: #fff; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(30,64,175,.08); }
.search-icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: #667085; font-size: 22px; }
.search-results {
  position: absolute; top: 48px; left: 0; right: 0; background: #fff; border: 1px solid var(--border);
  border-radius: 12px; box-shadow: var(--shadow); padding: 8px; z-index: 80;
}
.search-result { width: 100%; border: 0; background: transparent; padding: 10px 12px; border-radius: 8px; display: flex; justify-content: space-between; text-align: left; }
.search-result:hover { background: var(--surface-soft); }
.search-result strong { display: block; color: var(--text); }
.search-result span { color: var(--muted); font-size: 12px; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.topbar-time { color: #667085; font-size: 13px; }

.page-wrap { max-width: 1440px; margin: 0 auto; padding: 36px 34px 60px; }
.view { display: none; }
.view.active { display: block; }
.page-heading-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; margin-bottom: 26px; }
.eyebrow { margin: 0 0 7px; color: var(--blue); font-size: 11px; font-weight: 700; letter-spacing: .12em; }
h1, h2 { font-family: "Plus Jakarta Sans", sans-serif; }
h1 { margin: 0; font-size: clamp(28px, 3vw, 38px); line-height: 1.2; letter-spacing: -.03em; }
h2 { margin: 0; font-size: 19px; letter-spacing: -.02em; }
.page-description { margin: 9px 0 0; color: var(--muted); font-size: 14px; }
.heading-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.status-chip { display: inline-flex; align-items: center; border-radius: 999px; padding: 6px 10px; font-size: 11px; font-weight: 700; }
.status-chip.positive { color: #047857; background: #dff8ee; }
.status-chip.negative { color: #b42318; background: #fee4e2; }
.status-chip.neutral { color: #475467; background: #edf1f6; }

.card, .metric-card {
  background: var(--surface-card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 4px 12px rgba(15,23,42,.035);
}
.card { padding: 22px; }
.card-header { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 16px; }
.card-header.compact { margin-bottom: 14px; }
.card-header p { margin: 5px 0 0; color: var(--muted); font-size: 12px; }
.metric-grid { display: grid; gap: 16px; margin-bottom: 20px; }
.metric-grid.three { grid-template-columns: repeat(3, 1fr); }
.metric-grid.five { grid-template-columns: repeat(5, 1fr); margin-top: 20px; }
.metric-card { min-height: 130px; padding: 22px; position: relative; overflow: hidden; }
.metric-card.accent-green { background: linear-gradient(180deg,#fff 30%,#eafbf4); }
.metric-label { color: #667085; font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.metric-value { margin-top: 18px; font: 700 28px/1 "Plus Jakarta Sans", sans-serif; letter-spacing: -.03em; }
.metric-value.positive, .positive { color: var(--green); }
.negative { color: var(--red); }
.metric-foot { margin-top: 10px; color: var(--muted); font-size: 12px; }
.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.8fr) minmax(300px, .8fr); gap: 20px; margin-bottom: 20px; }
.chart-card { overflow: hidden; }
.plot { width: 100%; min-width: 0; }
.chart-lg { height: 390px; }
.chart-xl { height: 610px; }
.js-plotly-plot, .plot-container, .svg-container { touch-action: none !important; }
.segmented-control { display: flex; gap: 5px; }
.segmented-control button { border: 1px solid var(--border); background: #fff; color: #667085; border-radius: 8px; padding: 7px 10px; font-size: 12px; font-weight: 600; }
.segmented-control button.active { background: var(--blue); color: #fff; border-color: var(--blue); }
.pick-list { display: grid; gap: 0; }
.pick-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center; padding: 15px 0; border-top: 1px solid var(--border); }
.pick-row:first-child { border-top: 0; }
.pick-symbol { display: flex; align-items: center; gap: 10px; }
.ticker-badge { min-width: 38px; height: 38px; display: grid; place-items: center; border-radius: 9px; background: #e8efff; color: var(--blue); font-weight: 700; }
.pick-symbol strong { display: block; }
.pick-symbol span { color: var(--muted); font-size: 12px; }
.pick-score { text-align: right; }
.pick-score strong { display: block; }
.pick-score span { color: var(--green); font-size: 11px; font-weight: 700; }
.text-button { border: 0; background: transparent; color: var(--blue); font-weight: 700; }

.analysis-toolbar { margin-bottom: 18px; }
.toolbar-grid { display: grid; grid-template-columns: 1fr 220px minmax(340px, auto); gap: 16px; align-items: end; }
.toolbar-buttons { display: flex; gap: 10px; }
.primary-button, .secondary-button {
  min-height: 42px; padding: 10px 16px; border-radius: 9px; font-weight: 700; border: 1px solid transparent;
}
.primary-button { background: var(--blue); color: #fff; }
.primary-button:hover { background: var(--blue-dark); }
.secondary-button { background: #fff; color: #344054; border-color: #cfd8e6; }
.secondary-button:hover { background: var(--surface-soft); }
.secondary-button.small { min-height: 36px; padding: 8px 12px; font-size: 12px; }
.full-width { width: 100%; }
.progress-panel { margin-top: 16px; padding: 14px 16px; border-radius: 11px; background: #eef3ff; }
.progress-line { display: flex; justify-content: space-between; gap: 16px; margin-bottom: 8px; color: #344054; font-size: 12px; }
.progress-track { height: 8px; border-radius: 999px; background: #dbe4f5; overflow: hidden; }
.progress-bar { width: 0%; height: 100%; border-radius: inherit; background: var(--blue); transition: width .18s linear; }
.stock-hero { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 18px; }
.stock-name-row { display: flex; align-items: baseline; gap: 10px; }
.stock-name-row span { color: var(--muted); font-size: 12px; font-weight: 700; }
.stock-price-row { display: flex; align-items: baseline; gap: 12px; margin-top: 12px; }
.stock-price-row strong { font: 700 34px/1 "Plus Jakarta Sans", sans-serif; }
.stock-price-row span { font-size: 13px; font-weight: 700; }
.stock-hero-meta { display: grid; gap: 6px; text-align: right; color: var(--muted); font-size: 12px; }
.analysis-layout { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(310px, .7fr); gap: 20px; }
.side-stack { display: grid; gap: 20px; align-content: start; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 12px; color: var(--muted); font-size: 11px; }
.chart-legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend-dot { width: 8px; height: 8px; border-radius: 50%; }
.legend-dot.up { background: var(--green); }
.legend-dot.down { background: var(--red); }
.legend-line { width: 18px; height: 2px; }
.legend-line.ma20 { background: #f7c948; }
.legend-line.ma60 { background: #6ea8fe; }
.prediction-main { display: grid; grid-template-columns: 98px 1fr; align-items: center; gap: 16px; margin: 20px 0; }
.score-ring { --score: 0; width: 94px; height: 94px; border-radius: 50%; display: grid; place-items: center; background: conic-gradient(var(--green) calc(var(--score) * 1%), #e9edf4 0); position: relative; }
.score-ring::after { content: ""; position: absolute; inset: 9px; border-radius: 50%; background: #fff; }
.score-ring span { position: relative; z-index: 1; font: 700 22px/1 "Plus Jakarta Sans", sans-serif; }
.prediction-label { color: var(--muted); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.prediction-signal { margin-top: 5px; font: 700 22px/1.25 "Plus Jakarta Sans", sans-serif; }
.prediction-summary { margin-top: 7px; color: var(--muted); font-size: 12px; line-height: 1.55; }
.mini-metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.mini-metrics div { padding: 12px; border-radius: 10px; background: var(--surface-soft); }
.mini-metrics span { display: block; color: var(--muted); font-size: 10px; }
.mini-metrics strong { display: block; margin-top: 6px; font-size: 14px; }
.model-breakdown { display: grid; gap: 14px; }
.model-row { display: grid; grid-template-columns: 92px 1fr 54px; gap: 10px; align-items: center; }
.model-row span { font-size: 12px; font-weight: 600; }
.model-bar-track { height: 8px; border-radius: 999px; background: #e8edf4; overflow: hidden; }
.model-bar { height: 100%; border-radius: inherit; background: var(--blue); }
.model-row strong { text-align: right; font-size: 12px; }

.inline-title-row { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.inline-title-row span { color: var(--muted); font-size: 12px; }
.scanner-control-card { margin-bottom: 18px; }
.scanner-control-grid { display: grid; grid-template-columns: 1fr 220px 180px; gap: 16px; align-items: end; }
.scanner-run-button { width: 100%; }
.scanner-summary-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 18px; }
.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th { padding: 12px 14px; color: #667085; background: #f5f7fb; border-bottom: 1px solid var(--border); font-size: 11px; text-align: left; text-transform: uppercase; letter-spacing: .04em; }
td { padding: 14px; border-bottom: 1px solid var(--border); font-size: 13px; }
tr:last-child td { border-bottom: 0; }
.table-symbol { display: flex; align-items: center; gap: 10px; }
.signal-pill { display: inline-flex; align-items: center; border-radius: 999px; padding: 5px 8px; font-size: 11px; font-weight: 700; }
.signal-pill.buy { color: #047857; background: #dff8ee; }
.signal-pill.hold { color: #475467; background: #edf1f6; }
.signal-pill.sell { color: #b42318; background: #fee4e2; }
.empty-state { min-height: 240px; display: grid; place-items: center; align-content: center; gap: 8px; color: var(--muted); text-align: center; }
.empty-icon { width: 54px; height: 54px; border-radius: 50%; display: grid; place-items: center; background: #eef3ff; color: var(--blue); font-size: 24px; }
.empty-state strong { color: var(--text); }
.empty-state span { font-size: 12px; }
.toast { position: fixed; right: 22px; bottom: 22px; z-index: 120; background: #101828; color: #fff; padding: 12px 16px; border-radius: 10px; box-shadow: var(--shadow); font-size: 13px; transform: translateY(30px); opacity: 0; pointer-events: none; transition: .2s ease; }
.toast.show { transform: translateY(0); opacity: 1; }

@media (max-width: 1180px) {
  .metric-grid.five { grid-template-columns: repeat(3, 1fr); }
  .analysis-layout, .dashboard-grid { grid-template-columns: 1fr; }
  .side-stack { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); box-shadow: 20px 0 50px rgba(15,23,42,.12); }
  .sidebar.mobile-open { transform: translateX(0); }
  .sidebar-close { display: grid; }
  .sidebar-open-button { display: block; }
  .sidebar-open-button.visible { display: block; }
  .sidebar-backdrop.active { display: block; position: fixed; inset: 0; z-index: 50; background: rgba(15,23,42,.36); }
  .main-content, .main-content.expanded { margin-left: 0; }
  .topbar { padding: 0 18px 0 120px; }
  .page-wrap { padding: 28px 18px 50px; }
  .metric-grid.three, .scanner-summary-grid { grid-template-columns: 1fr; }
  .toolbar-grid { grid-template-columns: 1fr 1fr; }
  .toolbar-buttons { grid-column: 1 / -1; }
  .scanner-control-grid { grid-template-columns: 1fr 1fr; }
  .scanner-run-button { grid-column: 1 / -1; }
  .stock-hero { align-items: flex-start; }
  .side-stack { grid-template-columns: 1fr; }
  .chart-xl { height: 530px; }
}

@media (max-width: 640px) {
  .topbar { height: 68px; padding: 0 12px 0 108px; }
  .topbar-time { display: none; }
  .search-wrap { width: 100%; }
  .page-wrap { padding: 22px 12px 44px; }
  .page-heading-row, .stock-hero { flex-direction: column; }
  .stock-hero-meta { text-align: left; }
  .metric-grid.five { grid-template-columns: repeat(2, 1fr); }
  .toolbar-grid, .scanner-control-grid { grid-template-columns: 1fr; }
  .toolbar-buttons { flex-direction: column; }
  .scanner-run-button { grid-column: auto; }
  .chart-lg { height: 330px; }
  .chart-xl { height: 470px; }
  .card { padding: 16px; }
  .metric-card { min-height: 112px; padding: 17px; }
  .metric-value { font-size: 24px; }
  .card-header { align-items: flex-start; flex-direction: column; }
  .segmented-control { width: 100%; }
  .segmented-control button { flex: 1; }
  .mini-metrics { grid-template-columns: 1fr; }
  .prediction-main { grid-template-columns: 82px 1fr; }
  .score-ring { width: 78px; height: 78px; }
}


/* Yahoo Finance live-data indicators */
.live-chart-notice {
  margin-top: 13px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 8px 12px;
  border: 1px solid #d5dbe5;
  border-radius: 10px;
  background: #fff;
  color: #101828;
  font-size: 12px;
}
.live-chart-notice.compact { margin-top: 11px; }
.live-chart-notice strong { font-size: 12px; }
.live-chart-notice > span:last-child { color: var(--muted); font-variant-numeric: tabular-nums; }
.live-pulse {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #12b76a;
  box-shadow: 0 0 0 0 rgba(18,183,106,.38);
  animation: livePulse 1.8s infinite;
}
@keyframes livePulse {
  0% { box-shadow: 0 0 0 0 rgba(18,183,106,.36); }
  70% { box-shadow: 0 0 0 8px rgba(18,183,106,0); }
  100% { box-shadow: 0 0 0 0 rgba(18,183,106,0); }
}
.market-status.connected .status-dot { background: #12b76a; box-shadow: 0 0 0 4px rgba(18,183,106,.12); }
.market-status.error .status-dot { background: #f04438; box-shadow: 0 0 0 4px rgba(240,68,56,.12); }
.plot-live-error {
  min-height: 280px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  text-align: center;
  color: #98a2b3;
  background: #07101d;
  border-radius: 12px;
}
.plot-live-error strong { color: #f2f4f7; }
.plot-live-error span { max-width: 440px; font-size: 12px; line-height: 1.6; }
@media (max-width: 640px) {
  .live-chart-notice { width: 100%; align-items: flex-start; flex-wrap: wrap; }
  .live-chart-notice > span:last-child { width: 100%; padding-left: 16px; }
}
