/* ─── STATS PAGE ─── */
.stats-main {
  max-width: 780px;
  margin: 0 auto;
  padding: 90px 1.25rem 4rem;
  display: flex;
  flex-direction: column;
  gap: 2.5rem;
}

.stats-header { text-align: center; padding: 1rem 0; }
.stats-title {
  font-size: clamp(1.6rem, 5vw, 2.2rem);
  font-weight: 700;
  background: linear-gradient(135deg, #7dd3fc, #38bdf8, #0ea5e9);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 0.4rem;
}
.stats-sub { font-size: 0.85rem; color: var(--muted); }

/* ─── OVERVIEW CARDS ─── */
.overview-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
}

.ov-card {
  padding: 1.25rem 0.75rem;
  background: rgba(7,21,37,0.7);
  border: 1px solid rgba(14,165,233,0.12);
  border-radius: 14px;
  text-align: center;
  transition: border-color 0.3s;
}
.ov-card:hover { border-color: rgba(14,165,233,0.3); }

.ov-val {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--blue-2);
  font-variant-numeric: tabular-nums;
  margin-bottom: 0.3rem;
}
.ov-label {
  font-size: 0.7rem;
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* ─── CHART SECTIONS ─── */
.chart-section {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.section-heading {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--blue-2);
}
.section-sub-stat {
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 0.75rem;
}

.chart-wrap {
  background: rgba(7,21,37,0.5);
  border: 1px solid rgba(14,165,233,0.1);
  border-radius: 14px;
  padding: 1.25rem 1rem;
}

.chart-legend {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.7rem;
  color: var(--muted);
  margin-top: 0.5rem;
  letter-spacing: 0.03em;
}
.legend-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.no-data-msg {
  text-align: center;
  padding: 2rem;
  color: var(--muted);
  font-size: 0.85rem;
  letter-spacing: 0.03em;
}

/* ─── BAR CHART (trigger/helper) ─── */
.bar-chart {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.bar-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.bar-label {
  flex: 0 0 120px;
  text-align: right;
  font-size: 0.8rem;
  color: var(--text);
  white-space: nowrap;
}

.bar-track {
  flex: 1;
  height: 20px;
  background: rgba(14,165,233,0.06);
  border-radius: 6px;
  overflow: hidden;
  position: relative;
}

.bar-fill {
  height: 100%;
  border-radius: 6px;
  transition: width 0.6s ease;
  min-width: 4px;
}
.bar-fill.trigger { background: linear-gradient(90deg, #ef4444, #f87171); }
.bar-fill.helper  { background: linear-gradient(90deg, #34d399, #6ee7b7); }

.bar-pct {
  flex: 0 0 40px;
  font-size: 0.75rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* ─── RELAPSE CALENDAR ─── */
.calendar-wrap {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.cal-header {
  font-size: 0.6rem;
  color: var(--muted);
  text-align: center;
  letter-spacing: 0.08em;
  padding-bottom: 4px;
}

.cal-day {
  aspect-ratio: 1;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.6rem;
  color: rgba(255,255,255,0.3);
  font-variant-numeric: tabular-nums;
  transition: transform 0.15s;
  cursor: default;
  position: relative;
}
.cal-day:hover { transform: scale(1.2); z-index: 2; }

.cal-day.empty   { background: transparent; }
.cal-day.no-data { background: rgba(255,255,255,0.03); }
.cal-day.clean   { background: rgba(52,211,153,0.2); border: 1px solid rgba(52,211,153,0.3); color: rgba(52,211,153,0.7); }
.cal-day.relapse { background: rgba(239,68,68,0.2); border: 1px solid rgba(239,68,68,0.3); color: rgba(239,68,68,0.8); }
.cal-day.today   { box-shadow: 0 0 0 2px var(--blue-2); }

/* tooltip */
.cal-day[data-tip]:hover::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  padding: 0.3rem 0.6rem;
  background: #0a1929;
  border: 1px solid rgba(14,165,233,0.2);
  border-radius: 6px;
  font-size: 0.65rem;
  color: var(--text);
  pointer-events: none;
  z-index: 10;
}

/* ─── RISK WINDOW ─── */
.risk-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.risk-header {
  font-size: 0.6rem;
  color: var(--muted);
  text-align: center;
  padding-bottom: 2px;
}

.risk-cell {
  height: 28px;
  border-radius: 4px;
  transition: transform 0.15s;
}
.risk-cell:hover { transform: scale(1.1); }

/* ─── FOOTER ─── */
.stats-footer {
  text-align: center;
  font-size: 0.7rem;
  color: var(--muted);
  opacity: 0.6;
  margin-top: 1rem;
}

/* ─── MOBILE ─── */
@media (max-width: 640px) {
  .stats-main { padding: 80px 1rem 4rem; }
  .overview-row { grid-template-columns: repeat(2, 1fr); }
  .ov-val { font-size: 1.4rem; }
  .bar-label { flex: 0 0 80px; font-size: 0.7rem; }
}
