/* ═══════════════════════════════════════════════════════
   Trader's Lab — Research Dashboard (polished)
   ═══════════════════════════════════════════════════════ */

/* ── Layout ── */
.app-header {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-3) var(--space-5);
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface-raised);
  flex-shrink: 0;
}

.app-header h1 {
  font-size: var(--text-2xl);
  font-weight: 700;
  color: var(--color-text-brand);
  letter-spacing: -0.5px;
}

.app-header .sub {
  font-size: var(--text-xs);
  color: var(--color-text-secondary);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 2px 8px;
  background: oklch(0.55 0.16 260 / 0.1);
  border-radius: var(--radius-sm);
}

.app-header .subtitle {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  margin-left: auto;
}

.app-header .subtitle a {
  color: var(--color-accent);
  text-decoration: none;
  font-weight: 500;
}

.app-header .subtitle a:hover { text-decoration: underline; }

.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: var(--space-5) 24px;
}

/* ── Filter Bar ── */
.filter-bar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--color-surface-raised);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-5);
  flex-wrap: wrap;
}

.filter-bar label {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  font-weight: 500;
}

.filter-bar input,
.filter-bar select {
  background: var(--color-surface-base);
  border: 1px solid var(--color-border);
  color: var(--color-text-primary);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  font-family: var(--font-sans);
  outline: none;
  transition: border-color var(--duration-fast) var(--ease-out);
}

.filter-bar input:focus,
.filter-bar select:focus { border-color: var(--color-accent); }

.filter-bar .stats {
  margin-left: auto;
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  display: flex;
  gap: var(--space-4);
}

.filter-bar .stats span {
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

.stat-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

/* ── Timeframe Buttons ── */
.tf-btn {
  background: transparent;
  border: 1px solid var(--color-border);
  color: var(--color-text-secondary);
  padding: 3px 8px;
  font-size: var(--text-xs);
  cursor: pointer;
  font-family: var(--font-sans);
  transition: border-color var(--duration-fast) var(--ease-out),
              color var(--duration-fast) var(--ease-out);
}

.tf-btn:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.tf-btn:last-child  { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.tf-btn:only-child  { border-radius: var(--radius-sm); }
.tf-btn + .tf-btn { border-left: none; }

.tf-btn:hover { border-color: var(--color-accent); color: var(--color-text-primary); }
.tf-btn.active { border-color: var(--color-accent); color: var(--color-text-primary); background: oklch(0.55 0.16 260 / 0.1); }

/* ── Generate Button ── */
.gen-btn {
  background: var(--color-accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 6px 14px;
  cursor: pointer;
  font-size: var(--text-sm);
  font-weight: 600;
  font-family: var(--font-sans);
  transition: opacity var(--duration-fast) var(--ease-out);
}

.gen-btn:hover { opacity: 0.9; }

/* ── Research Status ── */
.research-status {
  display: none;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  color: var(--color-accent);
  margin-left: auto;
}

.research-status.visible { display: flex; }

/* ── Table ── */
.table-wrap {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--color-surface-raised);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-base);
}

th {
  text-align: left;
  padding: 10px 14px;
  font-weight: 600;
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  color: var(--color-text-secondary);
  border-bottom: 1px solid var(--color-border);
  background: oklch(0.83 0.012 265 / 0.03);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  font-family: var(--font-sans);
  transition: color var(--duration-fast) var(--ease-out);
}

th:hover { color: var(--color-text-primary); }
th.active-sort { color: var(--color-accent); }

th .sort-arrow {
  margin-left: var(--space-1);
  font-size: 10px;
  display: inline-block;
  width: 14px;
  text-align: center;
}

td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--color-border);
  vertical-align: middle;
}

tr:last-child td { border-bottom: none; }
tr.clickable { cursor: pointer; transition: background var(--duration-fast) var(--ease-out); }
tr.clickable:hover { background: var(--color-surface-hover); }
tr.expanded { background: oklch(0.55 0.16 260 / 0.06); }

.detail-row td { padding: 0; }
.detail-row.hidden { display: none; }

.detail-content {
  padding: var(--space-4) 20px 20px;
  border-top: 1px solid var(--color-border);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-4);
}

.detail-section {
  background: var(--color-surface-base);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-3);
}

.detail-section h4 {
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--color-text-secondary);
  margin-bottom: var(--space-2);
}

.detail-section.full { grid-column: 1 / -1; }

.detail-section .research-item {
  padding: 6px 0;
  border-bottom: 1px solid var(--color-border);
  font-size: var(--text-sm);
}

.detail-section .research-item:last-child { border: none; }

.detail-section .research-item .meta {
  font-size: var(--text-xs);
  color: var(--color-text-secondary);
}

.detail-section .strat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 0;
  border-bottom: 1px solid var(--color-border);
  font-size: var(--text-sm);
}

.detail-section .strat-row:last-child { border: none; }

/* ── Badges ── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 2px 8px;
  border-radius: 10px;
  font-size: var(--text-xs);
  font-weight: 600;
  white-space: nowrap;
}

.badge-bullish {
  background: oklch(0.62 0.14 155 / 0.15);
  color: var(--color-up);
}

.badge-bearish {
  background: oklch(0.55 0.18 25 / 0.15);
  color: var(--color-down);
}

.badge-neutral {
  background: oklch(0.55 0.02 265 / 0.15);
  color: var(--color-neutral);
}

.signal-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
  margin-right: var(--space-1);
}

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

.expand-icon {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  transition: transform var(--duration-normal) var(--ease-out);
}

.expand-icon.open { transform: rotate(90deg); }

/* ── Empty / Loading ── */
.loading {
  text-align: center;
  padding: 60px 20px;
  color: var(--color-text-secondary);
}

.loading::after {
  content: '';
  display: block;
  margin: 12px auto 0;
  width: 24px;
  height: 24px;
  border: 2px solid var(--color-border);
  border-top-color: var(--color-accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--color-text-secondary);
}

.empty-state h3 {
  font-size: var(--text-xl);
  font-weight: 500;
  margin-bottom: var(--space-2);
}

.empty-state p { font-size: var(--text-base); }

/* ── Consensus Bar ── */
.consensus-bar {
  margin-top: 6px;
  height: 6px;
  background: var(--color-border);
  border-radius: 3px;
  overflow: hidden;
  display: flex;
}

.consensus-bar .bull {
  height: 100%;
  background: var(--color-up);
  transition: width var(--duration-slow) var(--ease-out);
}

.consensus-bar .neut {
  height: 100%;
  background: var(--color-neutral);
  transition: width var(--duration-slow) var(--ease-out);
}

.consensus-bar .bear {
  height: 100%;
  background: var(--color-down);
  transition: width var(--duration-slow) var(--ease-out);
}

/* ── Responsive ── */
@media (max-width: 900px) {
  .container { padding: var(--space-3); }
  .filter-bar { flex-direction: column; align-items: stretch; }
  .filter-bar .stats { margin-left: 0; }
  .detail-content { grid-template-columns: 1fr; }
}
