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

:root {
  --bg:       #F4F5F7;
  --surface:  #FFFFFF;
  --border:   #E2E4E9;
  --text:     #0D0F12;
  --muted:    #6B7280;
  --green:    #16A34A;
  --green-bg: #DCFCE7;
  --amber:    #B7770A;
  --amber-bg: #FEF3C7;
  --red:      #C0392B;
  --red-bg:   #FEE2E2;
  --accent:   #2563EB;
}

body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; }

/* ── topbar ── */
.topbar {
  position: sticky; top: 0; z-index: 100;
  background: var(--surface); border-bottom: 1px solid var(--border);
  padding: 0 20px; height: 52px;
  display: flex; align-items: center; justify-content: space-between;
}
.topbar-left { display: flex; align-items: center; gap: 12px; }
.logo { font-weight: 700; font-size: 15px; letter-spacing: -0.3px; }
.logo span { color: var(--accent); }
.badge { font-size: 11px; font-weight: 600; background: var(--accent); color: #fff; border-radius: 4px; padding: 2px 6px; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.meta-text { font-size: 12px; color: var(--muted); }
.btn-refresh {
  font-size: 12px; font-weight: 600; padding: 6px 14px;
  border: 1px solid var(--border); border-radius: 6px;
  background: var(--surface); color: var(--text); cursor: pointer; transition: background 0.15s;
}
.btn-refresh:hover { background: var(--bg); }
.btn-refresh:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── page ── */
.page { max-width: 1280px; margin: 0 auto; padding: 28px 20px 60px; }

.section-label {
  font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--muted); margin-bottom: 16px;
}

/* ── responsive card grid ── */
/* align-items:start lets a collapsed "held" card stay short next to a full dip card */
.cards-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  align-items: start;
}
@media (min-width: 680px)  { .cards-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1060px) { .cards-grid { grid-template-columns: repeat(3, 1fr); } }

/* ── states ── */
.state-box {
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 48px 24px; text-align: center; color: var(--muted); grid-column: 1 / -1;
}
.state-box .title { font-size: 15px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.state-box .sub { font-size: 13px; }
.spinner { display: inline-block; width: 20px; height: 20px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.7s linear infinite; margin-bottom: 14px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── card ── */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 0 20px 18px; cursor: pointer; transition: box-shadow 0.15s, transform 0.1s;
  display: flex; flex-direction: column; overflow: hidden;
}
/* status band — the one-glance answer: did it drop after earnings, or hold? */
.band {
  margin: 0 -20px 14px; padding: 7px 20px;
  display: flex; justify-content: space-between; align-items: center;
  font-size: 12px; font-weight: 700;
}
.band-move { font-weight: 800; font-variant-numeric: tabular-nums; }
.band-drop { background: var(--red); color: #fff; }
.band-drop.band-unknown { background: var(--red-bg); color: var(--red); }   /* drop seen in news, size unknown */
.band-held { background: var(--bg); color: var(--muted); border-bottom: 1px solid var(--border); }
.band-held .band-move { color: var(--text); }
/* a name that reported and held: header only, no verdict, no KPI */
.card-held .card-header { margin-bottom: 0; }
.card-held .card-ticker { color: var(--muted); }
.card:hover { box-shadow: 0 4px 14px rgba(0,0,0,0.08); transform: translateY(-1px); }
/* confident-GREEN = the validated, actionable signal — lift it; mute the coin-flips */
.card-signal { border-color: var(--green); box-shadow: 0 0 0 1px var(--green), 0 2px 8px rgba(22,163,74,0.10); }
.card-signal:hover { box-shadow: 0 0 0 1px var(--green), 0 6px 18px rgba(22,163,74,0.18); }
/* mute the body, never the band — the drop/held answer must stay legible */
.card-muted > :not(.band) { opacity: 0.6; }
.card-muted:hover > :not(.band) { opacity: 1; }
.signal-badge {
  display: inline-block; vertical-align: middle; margin-left: 8px;
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.3px;
  background: var(--green-bg); color: var(--green); border-radius: 4px; padding: 2px 6px;
}

.card-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 14px; }
.card-ticker { font-size: 17px; font-weight: 800; letter-spacing: -0.3px; }
.card-name   { font-size: 12px; color: var(--muted); margin-top: 2px; }
.card-right  { text-align: right; flex-shrink: 0; margin-left: 12px; }
.kpi-main    { font-size: 18px; font-weight: 800; letter-spacing: -0.4px; }
.kpi-sub     { font-size: 11px; color: var(--muted); margin-top: 2px; }
.card-date   { font-size: 11px; color: var(--muted); margin-top: 3px; }

/* conviction bar (compact for card) */
.cscale-sm { margin-bottom: 12px; }
.cscale-sm .cs-top { display: flex; align-items: baseline; gap: 6px; margin-bottom: 5px; }
.cs-label  { font-size: 12px; font-weight: 700; }
.cs-conf   { font-size: 11px; color: var(--muted); }
.cs-track  {
  position: relative; height: 5px; border-radius: 3px;
  background: linear-gradient(to right, var(--red-bg) 0%, var(--amber-bg) 42%, var(--amber-bg) 58%, var(--green-bg) 100%);
  margin-bottom: 3px;
}
.cs-mk {
  position: absolute; top: 50%; transform: translate(-50%, -50%);
  width: 11px; height: 11px; border-radius: 50%;
  border: 2px solid white; box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.cs-ends { display: flex; justify-content: space-between; font-size: 10px; color: var(--muted); }
.cs-ends span:nth-child(2) { color: var(--amber); }

.card-verdict { font-size: 13px; font-weight: 600; color: var(--text); margin-top: auto; padding-top: 6px; }

/* history section */
.history-section { margin-top: 36px; }

/* Upcoming (future column) — compact schedule chips, no conviction/verdict */
.upcoming-section { margin-bottom: 32px; }
.upcoming-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 680px)  { .upcoming-grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1060px) { .upcoming-grid { grid-template-columns: repeat(4, 1fr); } }
.up-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 12px 14px; display: flex; flex-direction: column; gap: 2px;
}
.up-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.up-ticker { font-size: 15px; font-weight: 800; letter-spacing: -0.3px; }
.up-when   { font-size: 12px; font-weight: 700; color: var(--accent); }
.up-name   { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.up-meta   { display: flex; align-items: center; gap: 6px; margin-top: 3px; }
.up-date   { font-size: 11px; color: var(--muted); }
.up-time   { font-size: 9px; font-weight: 700; letter-spacing: 0.3px; padding: 1px 5px; border-radius: 3px; background: var(--bg); color: var(--muted); border: 1px solid var(--border); }
.up-soon .up-when { color: var(--red); }
.card-history { background: #FBFBFC; }
.card-history .card-ticker { color: var(--muted); }
.archived-tag { font-size: 10px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }

/* ── modal overlay ── */
.modal-overlay {
  display: none; position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,0.45); backdrop-filter: blur(2px);
  align-items: flex-end; justify-content: center;
}
.modal-overlay.open { display: flex; }
@media (min-width: 680px) { .modal-overlay { align-items: center; } }

.modal {
  background: var(--surface); width: 100%; max-height: 92vh; overflow-y: auto;
  border-radius: 16px 16px 0 0;
  box-shadow: 0 -4px 40px rgba(0,0,0,0.15);
  animation: slideUp 0.22s ease;
}
@media (min-width: 680px) {
  .modal { max-width: 680px; border-radius: 16px; max-height: 88vh; animation: fadeIn 0.18s ease; }
}
@keyframes slideUp { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fadeIn  { from { opacity: 0; transform: scale(0.97); } to { opacity: 1; transform: none; } }

/* drag handle (mobile) */
.modal-handle { display: flex; justify-content: center; padding: 10px 0 4px; }
.modal-handle span { width: 36px; height: 4px; background: var(--border); border-radius: 2px; }
@media (min-width: 680px) { .modal-handle { display: none; } }

.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 22px 14px;
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: var(--surface); z-index: 1;
}
.modal-title-left {}
.modal-ticker-row { display: flex; align-items: center; gap: 10px; }
.modal-ticker { font-size: 20px; font-weight: 800; letter-spacing: -0.4px; }
.modal-datepill {
  font-size: 11px; font-weight: 600; color: var(--muted);
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 20px; padding: 3px 10px; white-space: nowrap;
}
.modal-name   { font-size: 13px; color: var(--muted); margin-top: 2px; }
.modal-close  { font-size: 20px; color: var(--muted); cursor: pointer; padding: 4px 8px; border: none; background: none; line-height: 1; border-radius: 6px; }
.modal-close:hover { background: var(--bg); }
.modal-actions { display: flex; gap: 8px; align-items: center; }
.btn-regen {
  font-size: 12px; font-weight: 600; padding: 5px 12px;
  border: 1px solid var(--border); border-radius: 6px;
  background: var(--surface); color: var(--text); cursor: pointer; transition: background 0.12s;
  display: flex; align-items: center; gap: 5px;
}
.btn-regen:hover:not(:disabled) { background: var(--bg); }
.btn-regen:disabled { opacity: 0.5; cursor: not-allowed; }
.regen-spin { display: inline-block; width: 11px; height: 11px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.7s linear infinite; }

.modal-body { padding: 0 22px 28px; }

/* modal sections */
.msec { padding: 20px 0; border-bottom: 1px solid var(--border); }
.msec:last-child { border-bottom: none; }
.msec-title {
  font-size: 10px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--muted); margin-bottom: 14px;
}

/* section 1: drop analysis */
.drop-reason { font-size: 14px; color: var(--text); line-height: 1.55; margin-bottom: 14px; }
.conf-badge {
  display: inline-block; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 4px;
  background: var(--bg); color: var(--muted); border: 1px solid var(--border); margin-bottom: 14px;
}
.hl-list-modal { display: flex; flex-direction: column; gap: 1px; }
.hl-item-modal {
  font-size: 12px; padding: 8px 0; border-bottom: 1px solid var(--border); line-height: 1.4; display: flex; align-items: flex-start; gap: 8px;
}
.hl-item-modal:last-child { border-bottom: none; }
.hl-item-modal a { color: var(--text); text-decoration: none; flex: 1; }
.hl-item-modal a:hover { text-decoration: underline; }
.hl-ext { font-size: 10px; color: var(--accent); flex-shrink: 0; margin-top: 1px; }

/* section 2: ai verdict */
.cscale-full { margin-bottom: 16px; }
.cscale-full .cs-top { display: flex; align-items: baseline; gap: 8px; margin-bottom: 7px; }
.cscale-full .cs-label { font-size: 14px; font-weight: 700; }
.cscale-full .cs-track { height: 7px; margin-bottom: 5px; }
.cscale-full .cs-mk { width: 14px; height: 14px; }
.cscale-full .cs-ends { font-size: 11px; }
.verdict-line-modal { font-size: 15px; font-weight: 700; margin-bottom: 8px; }
.verdict-why-modal  { font-size: 13px; color: var(--muted); line-height: 1.6; }

/* section 3: price & chart */
.price-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 18px; }
.price-stat { background: var(--bg); border-radius: 8px; padding: 12px 14px; }
.price-stat-label { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin-bottom: 4px; }
.price-stat-value { font-size: 18px; font-weight: 800; letter-spacing: -0.4px; }
.price-stat-sub   { font-size: 11px; color: var(--muted); margin-top: 2px; }

.tv-frame { width: 100%; height: 240px; border: none; border-radius: 8px; display: block; }

.ext-links { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.ext-link {
  font-size: 12px; font-weight: 600; padding: 7px 14px;
  border: 1px solid var(--border); border-radius: 7px;
  color: var(--text); text-decoration: none; background: var(--surface);
  transition: background 0.12s;
}
.ext-link:hover { background: var(--bg); }

/* ── floating chat (ticker analyser) ── */
.chat-fab {
  position: fixed; right: 20px; bottom: 20px; z-index: 150;
  height: 50px; padding: 0 20px; border-radius: 25px; border: none;
  background: var(--accent); color: #fff; font-size: 14px; font-weight: 700;
  cursor: pointer; box-shadow: 0 4px 16px rgba(37,99,235,0.4);
  display: flex; align-items: center; gap: 8px; transition: transform 0.12s, box-shadow 0.12s;
}
.chat-fab:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(37,99,235,0.5); }
.chat-panel {
  position: fixed; right: 20px; bottom: 20px; z-index: 160;
  width: 380px; max-width: calc(100vw - 40px); height: 540px; max-height: calc(100vh - 40px);
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  box-shadow: 0 12px 48px rgba(0,0,0,0.22);
  display: none; flex-direction: column; overflow: hidden;
}
.chat-panel.open { display: flex; }
.chat-header { padding: 14px 16px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.chat-title { font-size: 14px; font-weight: 700; }
.chat-title small { font-weight: 500; color: var(--muted); font-size: 11px; display: block; margin-top: 1px; }
.chat-close { font-size: 18px; color: var(--muted); background: none; border: none; cursor: pointer; padding: 4px 8px; border-radius: 6px; }
.chat-close:hover { background: var(--bg); }
.chat-messages { flex: 1; overflow-y: auto; padding: 14px 16px; display: flex; flex-direction: column; gap: 12px; }
.chat-msg { display: flex; }
.chat-msg.user { justify-content: flex-end; }
.chat-bubble { max-width: 88%; font-size: 13px; line-height: 1.5; padding: 10px 12px; border-radius: 12px; }
.chat-msg.user .chat-bubble { background: var(--accent); color: #fff; font-weight: 700; border-bottom-right-radius: 4px; }
.chat-msg.assistant .chat-bubble { background: var(--bg); color: var(--text); border-bottom-left-radius: 4px; width: 100%; max-width: 100%; }
.chat-msg.error .chat-bubble { background: var(--red-bg); color: var(--red); }
.chat-thinking { display: flex; gap: 4px; padding: 4px; }
.chat-thinking span { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: cblink 1.2s infinite both; }
.chat-thinking span:nth-child(2) { animation-delay: 0.2s; }
.chat-thinking span:nth-child(3) { animation-delay: 0.4s; }
@keyframes cblink { 0%, 80%, 100% { opacity: 0.25; } 40% { opacity: 1; } }
.chat-input-row { display: flex; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--border); }
.chat-input { flex: 1; font-size: 14px; padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px; text-transform: uppercase; }
.chat-input:focus { outline: none; border-color: var(--accent); }
.chat-send { font-size: 13px; font-weight: 700; padding: 0 16px; border: none; border-radius: 8px; background: var(--accent); color: #fff; cursor: pointer; }
.chat-send:disabled { opacity: 0.5; cursor: not-allowed; }
.ca-head { font-size: 14px; margin-bottom: 8px; }
.ca-head .ca-name { color: var(--muted); font-weight: 500; }
.ca-head .pos { color: var(--green); font-weight: 700; }
.ca-head .neg { color: var(--red); font-weight: 700; }
.ca-verdict { font-size: 13px; font-weight: 700; margin: 6px 0 4px; }
.ca-why { font-size: 12px; color: var(--muted); line-height: 1.5; }
.ca-why b { color: var(--text); }
.ca-note { font-size: 12px; color: var(--muted); }
.ca-hls { margin-top: 10px; display: flex; flex-direction: column; gap: 4px; }
.ca-hls > div { font-size: 11px; color: var(--muted); line-height: 1.4; }
.ca-src { color: var(--accent); }
@media (max-width: 480px) { .chat-panel { width: calc(100vw - 24px); right: 12px; bottom: 12px; height: calc(100vh - 90px); } }
