:root {
  --bg: #0b1020;
  --bg-soft: #141b30;
  --card: #18223c;
  --border: #25304f;
  --text: #e6ebf5;
  --muted: #93a0bd;
  --accent: #4f8cff;
  --up: #2ecc71;
  --down: #ff5c5c;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

a { color: var(--accent); }

.site-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 24px;
  background: var(--bg-soft);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand { display: flex; align-items: center; gap: 12px; }
.logo { font-size: 28px; }
.site-header h1 { font-size: 20px; margin: 0; }
.tagline { margin: 0; color: var(--muted); font-size: 13px; }

.search-wrap { position: relative; flex: 0 1 280px; }
#global-search {
  width: 100%; background: var(--bg-soft); border: 1px solid var(--border);
  color: var(--text); padding: 8px 12px; border-radius: 8px; font-size: 14px;
}
#global-search:focus { outline: none; border-color: var(--accent); }
.search-results {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 30;
  background: var(--card); border: 1px solid var(--border); border-radius: 8px;
  max-height: 320px; overflow-y: auto; box-shadow: 0 8px 24px rgba(0,0,0,.4);
}
.search-result-item {
  display: flex; justify-content: space-between; gap: 10px;
  padding: 9px 12px; cursor: pointer; font-size: 13px;
}
.search-result-item:hover { background: var(--bg-soft); }
.search-result-item .sym { font-weight: 600; }
.search-result-item .meta { color: var(--muted); text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-section-header {
  padding: 6px 12px 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
}
.hidden { display: none; }

.tabs { display: flex; gap: 8px; }
.tab {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
}
.tab.active { background: var(--accent); color: #fff; border-color: var(--accent); }

main { max-width: 1100px; margin: 0 auto; padding: 24px; }
.panel { display: none; }
.panel.active { display: block; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 18px;
  margin-bottom: 18px;
}
.card h2 { margin: 0 0 12px; font-size: 16px; }

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}
@media (max-width: 760px) { .grid-2 { grid-template-columns: 1fr; } }

.mini-list { display: flex; flex-direction: column; gap: 8px; }
.mini-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 10px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
}
.mini-row:hover { border-color: var(--accent); }
.mini-row .sym { font-weight: 600; }
.mini-row .meta { color: var(--muted); font-size: 12px; }
.mini-row .chg { font-weight: 600; }

.status { color: var(--muted); font-size: 13px; margin: 4px 0 12px; min-height: 18px; }
.status.warn { color: #ffcf66; }

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: end;
  margin-bottom: 14px;
}
.filters label { display: flex; flex-direction: column; font-size: 12px; color: var(--muted); gap: 4px; }
.filters input, .filters select {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 14px;
  min-width: 140px;
}
.filters button {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 10px 18px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
}

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: right; padding: 9px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
th:first-child, td:first-child, th:nth-child(2), td:nth-child(2) { text-align: left; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: var(--bg-soft); }
.sym-link { color: var(--accent); font-weight: 600; cursor: pointer; }

.up { color: var(--up); }
.down { color: var(--down); }

.modal {
  position: fixed; inset: 0; background: rgba(3, 7, 18, 0.7);
  display: flex; align-items: center; justify-content: center; padding: 24px; z-index: 50;
}
.modal.hidden { display: none; }
.modal-box {
  background: var(--card); border: 1px solid var(--border); border-radius: 14px;
  width: min(720px, 100%); max-height: 88vh; overflow-y: auto; padding: 22px; position: relative;
}
.modal-close {
  position: absolute; top: 12px; right: 12px; background: transparent; border: none;
  color: var(--muted); font-size: 18px; cursor: pointer;
}
.detail-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 8px; }
.detail-price { font-size: 26px; font-weight: 700; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 18px; margin: 14px 0; }
.detail-grid div { display: flex; justify-content: space-between; border-bottom: 1px dashed var(--border); padding: 4px 0; font-size: 13px; }
.detail-grid span:first-child { color: var(--muted); }
canvas { width: 100%; height: 240px; background: var(--bg-soft); border: 1px solid var(--border); border-radius: 8px; }
.news-list { list-style: none; padding: 0; margin: 8px 0 0; }
.news-list li { padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.news-list a { text-decoration: none; }
.insider-table td, .insider-table th { font-size: 12px; }

.site-footer { text-align: center; color: var(--muted); font-size: 12px; padding: 24px; }

/* ---------- NEW SIGNALS STYLES ---------- */
.chip {
  display: inline-block;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 4px 10px;
  border-radius: 10px;
  font-size: 12px;
  margin-right: 6px;
  margin-bottom: 4px;
}
.chip.up { background: rgba(46, 204, 113, 0.15); border-color: var(--up); color: var(--up); }
.chip.down { background: rgba(255, 92, 92, 0.15); border-color: var(--down); color: var(--down); }
.chip.warn { background: rgba(255, 191, 0, 0.15); border-color: #ffbf00; color: #ffbf00; }

.sentiment-bar {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  margin: 8px 0;
  overflow: hidden;
}
.sentiment-bar-fill {
  height: 100%;
  background: var(--up);
  transition: width 0.3s ease;
}
.sentiment-bar-fill.down { background: var(--down); }
.sentiment-bar-fill[style*="0%"] { background: var(--muted); }

.signal-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 18px;
  font-size: 13px;
}
.signal-grid div { display: flex; justify-content: space-between; border-bottom: 1px dashed var(--border); padding: 4px 0; }
.signal-grid span:first-child { color: var(--muted); }

.small-list { list-style: none; padding: 0; margin: 8px 0 0; }
.small-list li { padding: 6px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.small-list a { text-decoration: none; }
.small-list .meta { color: var(--muted); font-size: 11px; }

.flag-banner {
  background: rgba(255, 92, 92, 0.12);
  color: var(--down);
  padding: 8px 12px;
  border-radius: 8px;
  margin-bottom: 12px;
  font-weight: 600;
  font-size: 13px;
}

.signal-chips { display: flex; flex-wrap: wrap; gap: 4px; }

/* Ensure tables inside cards are readable */
.card .table-wrap { overflow-x: auto; }
.card .small-table th,
.card .small-table td {
  text-align: left;
  padding: 8px 10px;
  font-size: 12px;
  white-space: normal;
  word-break: break-word;
}

/* ---------- FEAR & GREED WIDGET ---------- */
.fg-widget {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}
@media (max-width: 900px) {
  .fg-widget { display: none; }
}

/* ---------- LAYMAN OPTIONS CARD ---------- */
.layman-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px dashed var(--border);
  font-size: 14px;
}
.layman-row:last-child { border-bottom: none; }
.layman-label { color: var(--muted); font-size: 13px; }
.layman-range { font-weight: 700; font-size: 15px; letter-spacing: 0.5px; }
.layman-sub { color: var(--muted); font-size: 12px; margin-top: 2px; }

.options-details summary { list-style: none; }
.options-details summary::-webkit-details-marker { display: none; }
.options-details summary::before { content: '▸ '; }
.options-details[open] summary::before { content: '▾ '; }

/* ---------- NARRATIVE CARD ---------- */
.narrative-card {
  background: linear-gradient(135deg, var(--card) 0%, #1a2a4a 100%);
  border-color: var(--accent);
}
.narrative-card h3 { color: var(--accent); }

/* ---------- SCORECARD ---------- */
.scorecard-card {
  border-color: var(--accent);
  border-width: 1px;
}

/* ---------- SIGNAL CARD SECTION HEADINGS ---------- */
.card h3 {
  margin: 0 0 10px;
  font-size: 14px;
  color: var(--text);
}

/* ---------- SENTIMENT BAR DUAL (retail) ---------- */
.sentiment-bar.dual {
  display: flex;
  gap: 2px;
}
.sentiment-bar.dual .sentiment-bar-fill {
  height: 100%;
}

/* ---------- EARNINGS SURPRISE ROWS ---------- */
.signal-grid .surprise-row {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
}

@media (max-width: 600px) {
  .signal-grid { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
}
