/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface2: #22263a;
  --border: #2e3348;
  --text: #e2e8f0;
  --text-muted: #8892a4;
  --green: #22c55e;
  --red: #ef4444;
  --accent: #6366f1;
  --font: 'Inter', 'Helvetica Neue', Arial, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
}

html {
  background: var(--bg);
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  max-width: 1440px;
  margin: 0 auto;
  box-shadow: 0 0 0 1px var(--border);
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===== Header ===== */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

header h1 { font-size: 20px; font-weight: 700; }
.subtitle { color: var(--text-muted); font-size: 13px; margin-left: 8px; }

.header-right { display: flex; align-items: center; gap: 12px; }
.last-updated { color: var(--text-muted); font-size: 12px; }

.refresh-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 6px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: opacity 0.2s;
}
.refresh-btn:hover { opacity: 0.85; }
.refresh-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ===== Analysis Cards ===== */
.analysis-cards {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 12px;
  padding: 16px 20px;
}

@media (max-width: 900px) {
  .analysis-cards { grid-template-columns: 1fr; }
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 20px;
  overflow-y: auto;
  max-height: 360px;
}

.card p, .card #text-summary, .card #text-news {
  white-space: pre-wrap;
  line-height: 1.8;
  font-size: 13px;
}

.card h2 { font-size: 15px; font-weight: 600; margin-bottom: 10px; }
.placeholder { color: var(--text-muted); font-style: italic; }

/* Analysis tab switcher — removed */

/* Trading advice list */
.advice-list { list-style: none; }
.advice-item {
  border-left: 3px solid var(--green);
  padding: 8px 12px;
  margin-bottom: 8px;
  background: var(--surface2);
  border-radius: 0 6px 6px 0;
}
.advice-item .ticker { font-weight: 700; font-family: var(--font-mono); color: var(--green); }
.advice-item .action { font-size: 12px; color: var(--text-muted); }
.advice-item .reason { font-size: 13px; margin-top: 2px; }
.advice-item .risk { font-size: 12px; color: var(--red); margin-top: 2px; }

.warning-item { border-left-color: var(--red); }
.warning-item .ticker { color: var(--red); }

/* ===== Anchor Nav ===== */
.anchor-nav {
  display: flex;
  gap: 8px;
  padding: 6px 20px;
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 57px;
  z-index: 99;
}

.anchor-nav a {
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  padding: 4px 12px;
  border-radius: 4px;
  transition: background 0.15s, color 0.15s;
}
.anchor-nav a:hover {
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
}

/* ===== Main Sections ===== */
main { padding: 0 20px 40px; }

section { margin-top: 24px; }

.section-title {
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--border);
}

/* ===== Table ===== */
.table-container { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

/* Group header row */
.group-header td {
  background: var(--surface2);
  color: var(--accent);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 5px 6px;
  border-top: 2px solid var(--border);
}

thead th {
  background: var(--surface);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 6px 6px;
  text-align: right;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
thead th:first-child, thead th:nth-child(2) { text-align: left; }
thead th:hover { color: var(--text); }

tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}
tbody tr:hover { background: var(--surface2); }

td {
  padding: 5px 6px;
  text-align: right;
  white-space: nowrap;
}
td:first-child { text-align: left; font-family: var(--font-mono); font-weight: 600; font-size: 12px; }
td:nth-child(2) { text-align: left; color: var(--text-muted); white-space: nowrap; }

/* ===== Color Classes ===== */
.pos { color: var(--green); }
.neg { color: var(--red); }

/* Heatmap for rank/score columns (0-100) */
.heat-0  { color: #ef4444; }
.heat-10 { color: #f97316; }
.heat-20 { color: #f59e0b; }
.heat-30 { color: #eab308; }
.heat-40 { color: #a3a30a; }
.heat-50 { color: #84cc16; }
.heat-60 { color: #4ade80; }
.heat-70 { color: #22c55e; }
.heat-80 { color: #16a34a; }
.heat-90 { color: #15803d; }
.heat-100 { color: #166534; }

/* ===== Footer ===== */
footer {
  text-align: center;
  padding: 24px;
  color: var(--text-muted);
  font-size: 12px;
  border-top: 1px solid var(--border);
}
footer p + p { margin-top: 4px; }
