/* ============================================================
   PROSPECTAI STATS PAGE
   Uses the same CSS variables as style.css (dark theme).
   ============================================================ */

/* ── Action-type colour palette ─────────────────────────────── */
:root {
  --action-longbuy:     #4a7c59;
  --action-wait:        #e0a040;
  --action-monitor:     #8c8c8c;
  --action-avoid:       #c0392b;
  --roi-positive:       #00C896;
  --roi-negative:       #c0392b;
}

/* ── Header ─────────────────────────────────────────────────── */
.stats-header {
  padding: 40px 0 32px;
  border-bottom: 1px solid var(--border);
}

.stats-back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-dim);
  font-family: var(--mono);
  font-size: 11px;
  text-decoration: none;
  letter-spacing: .04em;
  margin-bottom: 24px;
  transition: color .15s;
}
.stats-back-link:hover { color: var(--text); }

.stats-title-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
}

.stats-h1 {
  font-family: 'DM Serif Display', serif;
  font-size: clamp(2rem, 5vw, 3.2rem);
  color: var(--text);
  margin: 4px 0 0;
  line-height: 1.1;
}
.stats-h1 em { color: var(--amber); font-style: italic; }

.stats-live-badge {
  display: inline-block;
  padding: 3px 10px;
  background: transparent;
  border: 1px solid var(--green-dim);
  color: var(--green);
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .12em;
  border-radius: 2px;
  margin-bottom: 6px;
}

.stats-subtitle {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-dim);
  margin: 12px 0 0;
}

/* ── Tab bar ─────────────────────────────────────────────────── */
.stats-tabs {
  display: flex;
  gap: 2px;
  border-bottom: 2px solid var(--border2);
  margin-top: 32px;
  margin-bottom: 0;
}

.stats-tab {
  /* reset all button defaults */
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  border-top: none;
  border-left: none;
  border-right: none;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;       /* overlap the tab bar's bottom border */
  padding: 10px 24px 12px;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--text-dim);
  cursor: pointer;
  transition: color .15s, border-color .15s, background .15s;
  border-radius: 0;
  outline: none;
}
.stats-tab:hover {
  color: var(--text);
  background: rgba(255,255,255,.03);
}
.stats-tab[aria-selected="true"] {
  color: var(--amber);
  border-bottom-color: var(--amber);
  background: rgba(240,165,0,.04);
}

/* ── Tab panels ──────────────────────────────────────────────── */
/* Use .is-active class instead of hidden attribute — avoids cross-browser
   cascade conflicts between display:block and the [hidden] attribute. */
.stats-panel { display: none; }
.stats-panel.is-active { display: block; }

/* ── Empty state ─────────────────────────────────────────────── */
.stats-empty {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-dim);
  padding: 32px 0;
}

/* ── Skeleton loaders ────────────────────────────────────────── */
@keyframes skeleton-pulse {
  0%   { opacity: .35; }
  50%  { opacity: .65; }
  100% { opacity: .35; }
}
.skeleton {
  background: var(--border2);
  border-radius: 3px;
  animation: skeleton-pulse 1.4s ease-in-out infinite;
  display: inline-block;
}
.skeleton--line  { height: 12px; width: 100%; margin: 4px 0; }
.skeleton--value { height: 2.4rem; width: 70px; margin: 4px 0; }
.skeleton--block { height: 120px; width: 100%; margin: 8px 0; }
.skeleton--bar   { height: 10px; border-radius: 2px; }

/* ── Horizontal bar chart (sector coverage) ──────────────────── */
.stat-bar-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.stat-bar-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--mono);
  font-size: 11px;
}
.stat-bar-label {
  width: 130px;
  flex-shrink: 0;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.stat-bar-track {
  flex: 1;
  height: 8px;
  background: rgba(255,255,255,.06);
  border-radius: 2px;
  overflow: hidden;
}
.stat-bar-fill {
  height: 100%;
  background: var(--green);
  border-radius: 2px;
  transition: width .4s ease;
}
.stat-bar-count {
  width: 32px;
  text-align: right;
  color: var(--amber);
  font-weight: 600;
  flex-shrink: 0;
}

/* ── Risk profile donut in Activity tab ──────────────────────── */
.stats-risk-donut-wrap {
  display: flex;
  align-items: flex-start;
  gap: 20px;
}

/* ── Decisions filter dropdown ───────────────────────────────── */
.stats-chart-filter {
  -webkit-appearance: none;
  appearance: none;
  background: rgba(255,255,255,.03);
  border: 1px solid var(--border2);
  color: var(--text);
  font-family: var(--mono);
  font-size: 11px;
  padding: 6px 32px 6px 10px;
  cursor: pointer;
  margin-bottom: 20px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%236B7F96'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  outline: none;
}
.stats-chart-filter:focus { border-color: var(--amber-dim); }

/* ── Decisions single-donut layout ──────────────────────────── */
.stats-decisions-wrap {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}
.stats-decisions-inner {
  display: flex;
  gap: 40px;
  align-items: flex-start;
  flex-wrap: wrap;
}

/* ── Performance sector filter ───────────────────────────────── */
.stats-filter-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
}

/* ── Performance disclaimer ──────────────────────────────────── */
.stats-disclaimer {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-dim);
  border-left: 2px solid var(--amber-dim);
  padding: 8px 12px;
  margin: 0 0 20px;
  background: rgba(240,165,0,.03);
  line-height: 1.6;
}

/* ── Version column ──────────────────────────────────────────── */
.col-version { color: var(--muted); font-size: 10px; white-space: nowrap; }

/* ── Report column ───────────────────────────────────────────── */
.col-report { white-space: nowrap; }
.report-link {
  color: var(--green);
  font-size: 11px;
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color .15s;
}
.report-link:hover { border-bottom-color: var(--green); }

/* ── Report history cards (reports.html) ─────────────────────── */
#reports-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.report-card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: 4px;
  padding: 14px 18px;
  text-decoration: none;
  color: var(--text);
  transition: border-color .18s, background .18s;
}
.report-card:hover {
  border-color: var(--green-dim);
  background: rgba(74, 124, 89, .05);
}
.report-card-top {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}
.report-card-sector {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}
.report-card-version {
  font-size: 10px;
  color: var(--green);
  background: rgba(74,124,89,.12);
  border: 1px solid var(--green-dim);
  padding: 1px 6px;
  border-radius: 3px;
  margin-left: auto;
}
.report-card-meta {
  font-size: 11px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.report-card-sep { color: var(--border2); }

/* ── Sortable column headers ─────────────────────────────────── */
.col-sortable {
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
.col-sortable:hover { color: var(--text); }
.sort-arrow {
  display: inline-block;
  margin-left: 4px;
  font-size: 10px;
  color: var(--muted);
}
.sort-arrow.active { color: var(--amber); }

/* ── KPI cards ───────────────────────────────────────────────── */
.stats-kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 32px;
}
@media (max-width: 900px) {
  .stats-kpi-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 500px) {
  .stats-kpi-grid { grid-template-columns: 1fr; }
}

.stats-kpi-card {
  padding: 18px 20px;
  background: rgba(255,255,255,.02);
  border: 1px solid var(--border2);
}
.stats-kpi-label {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 8px;
}
.stats-kpi-value {
  font-family: var(--mono);
  font-size: 1.8rem;
  font-weight: 600;
  color: var(--amber);
  line-height: 1;
  margin-bottom: 6px;
}
.stats-kpi-value--pos { color: var(--roi-positive); }
.stats-kpi-value--neg { color: var(--roi-negative); }
.stats-kpi-sub {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--muted);
}

/* ── Sections ────────────────────────────────────────────────── */
.stats-section {
  padding: 40px 0;
  border-bottom: 1px solid var(--border);
}
.stats-section:last-child { border-bottom: none; }

.stats-section-title {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--amber);
  margin: 0 0 6px;
}
.stats-section-sub {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-dim);
  margin: 0 0 28px;
}

/* ── Summary cards ───────────────────────────────────────────── */
.stats-cards-grid {
  display: grid;
  grid-template-columns: 200px 1fr 1fr;
  gap: 16px;
}
@media (max-width: 700px) {
  .stats-cards-grid { grid-template-columns: 1fr; }
}

.stats-card {
  padding: 20px 22px;
  background: rgba(255,255,255,.02);
  border: 1px solid var(--border2);
}
.stats-card-label {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 10px;
}
.stats-card-value {
  font-family: var(--mono);
  font-size: 2.6rem;
  font-weight: 600;
  color: var(--amber);
  line-height: 1;
  margin-bottom: 6px;
}
.stats-card-sub {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--muted);
}

/* sector list */
.stats-sector-list,
.stats-risk-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.stats-sector-item,
.stats-risk-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--mono);
  font-size: 11px;
}
.stats-sector-name,
.stats-risk-name {
  color: var(--text);
}
.stats-sector-count,
.stats-risk-count {
  color: var(--amber);
  font-weight: 600;
}

/* ── Charts ──────────────────────────────────────────────────── */
.stats-charts-row {
  display: flex;
  gap: 24px;
  margin-bottom: 32px;
}

.stats-chart-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px;
  background: rgba(255,255,255,.02);
  border: 1px solid var(--border2);
  min-width: 200px;
}
.stats-chart-card--overall {
  min-width: 220px;
}

.stats-chart-title {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 16px;
}

.stats-donut-wrap {
  position: relative;
  width: 120px;
  height: 120px;
  margin-bottom: 16px;
}
.stats-donut-wrap--sm {
  width: 90px;
  height: 90px;
}
.stats-donut {
  transform: rotate(-90deg);
}
.stats-donut--sm {
  width: 90px;
  height: 90px;
}
.stats-donut-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-family: var(--mono);
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  pointer-events: none;
}
.stats-donut-center span {
  font-size: 10px;
  color: var(--text-dim);
  font-weight: 400;
}

.stats-legend {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
  align-self: stretch;
}
.stats-legend-item {
  display: flex;
  align-items: center;
  gap: 7px;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-dim);
}
.stats-legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.stats-legend-label { color: var(--text); flex: 1; }
.stats-legend-count { color: var(--amber); font-weight: 600; margin-left: 2px; }
.stats-legend-pct   { color: var(--muted); }

/* per-sector donuts row */
.stats-sector-donuts {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}
.stats-chart-card--sector {
  min-width: 180px;
}

/* ── Track Record Table ──────────────────────────────────────── */
.stats-table-wrap {
  overflow-x: auto;
}

.stats-loading,
.stats-error {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-dim);
  padding: 24px 0;
}
.stats-error { color: var(--roi-negative); }

.stats-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--mono);
  font-size: 12px;
}
.stats-table th {
  text-align: left;
  padding: 8px 12px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border2);
  white-space: nowrap;
}
.stats-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  white-space: nowrap;
}
.stats-table tbody tr:hover td {
  background: rgba(255,255,255,.02);
}

/* column sizing */
.col-rank    { width: 36px; color: var(--muted); }
.col-ticker  { font-weight: 600; color: var(--text); }
.col-sector  { color: var(--text-dim); max-width: 130px; overflow: hidden; text-overflow: ellipsis; }
.col-date    { color: var(--text-dim); }
.col-entry   { color: var(--text); }
.col-current { color: var(--text); }
.col-roi     { min-width: 140px; }

/* ROI cell */
.roi-cell {
  display: flex;
  align-items: center;
  gap: 8px;
}
.roi-badge {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 2px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.roi-badge--pos {
  background: rgba(0, 200, 150, .12);
  color: var(--roi-positive);
}
.roi-badge--neg {
  background: rgba(192, 57, 43, .12);
  color: var(--roi-negative);
}
.roi-badge--null {
  color: var(--muted);
  background: transparent;
  padding: 0;
}

.roi-bar-track {
  flex: 1;
  height: 4px;
  background: rgba(255,255,255,.06);
  border-radius: 2px;
  overflow: hidden;
  max-width: 80px;
}
.roi-bar-fill {
  height: 100%;
  background: var(--roi-positive);
  border-radius: 2px;
}
