:root {
  --bg: #0a1628;
  --surface: #112240;
  --surface-2: #172f54;
  --border: #1d4070;
  --border-light: #2a5a9a;
  --primary: #22c55e;
  --primary-dim: #16a34a;
  --teal: #14b8a6;
  --gold: #f59e0b;
  --purple: #a855f7;
  --blue: #3b82f6;
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --radius: 12px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
}

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

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

/* ---- HEADER ---- */
header {
  background: linear-gradient(135deg, #0d2137 0%, #0a1628 100%);
  border-bottom: 1px solid var(--border);
  padding: 20px 24px;
  position: sticky;
  top: 0;
  z-index: 10;
}

.header-content {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-icon {
  font-size: 34px;
  line-height: 1;
}

.logo h1 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.tagline {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 1px;
}

.header-stats {
  display: flex;
  gap: 12px;
}

.stat {
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 16px;
  min-width: 88px;
}

.stat-value {
  display: block;
  font-size: 20px;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: -0.5px;
}

.stat-label {
  display: block;
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 2px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

/* ---- TABS ---- */
.tabs {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  display: flex;
  overflow-x: auto;
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar { display: none; }

.tab {
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  color: var(--text-muted);
  padding: 14px 20px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s;
}

.tab:hover { color: var(--text); }

.tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

/* ---- MAIN ---- */
main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 28px 24px;
}

.tab-content { display: none; }
.tab-content.active { display: block; }

.section-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 22px;
}

.section-header h2 {
  font-size: 18px;
  font-weight: 600;
}

.protocol-badge {
  background: rgba(34, 197, 94, 0.12);
  color: var(--primary);
  border: 1px solid rgba(34, 197, 94, 0.3);
  border-radius: 20px;
  padding: 3px 12px;
  font-size: 12px;
  font-weight: 500;
}

/* ---- SUPPLEMENT GRID ---- */
.supplement-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.supp-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  transition: border-color 0.2s, transform 0.15s;
  cursor: default;
}

.supp-card:hover {
  border-color: var(--border-light);
  transform: translateY(-2px);
}

.supp-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
}

.supp-icon {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.supp-info { flex: 1; min-width: 0; }

.supp-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.supp-dose {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.supp-pct {
  font-size: 22px;
  font-weight: 700;
  flex-shrink: 0;
  letter-spacing: -0.5px;
}

.supp-bar {
  height: 5px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 12px;
}

.supp-bar-fill {
  height: 100%;
  border-radius: 3px;
  opacity: 0.85;
}

.supp-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.supp-category {
  font-size: 11px;
  background: var(--surface-2);
  color: var(--text-muted);
  border-radius: 4px;
  padding: 2px 8px;
  white-space: nowrap;
}

.supp-timing {
  font-size: 11px;
  color: var(--text-dim);
}

.supp-streak {
  font-size: 12px;
  color: var(--gold);
}

.supp-streak.no-streak { color: var(--text-dim); }

/* ---- LOG TABLE ---- */
#tab-log h2 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 22px;
}

.log-table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
}

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

.log-table thead { background: var(--surface-2); }

.log-table th {
  padding: 12px 16px;
  text-align: left;
  color: var(--text-muted);
  font-weight: 500;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.log-table td {
  padding: 11px 16px;
  border-bottom: 1px solid rgba(29, 64, 112, 0.5);
  vertical-align: middle;
}

.log-table tbody tr:last-child td { border-bottom: none; }
.log-table tbody tr:hover { background: rgba(255, 255, 255, 0.02); }

.log-date {
  font-weight: 500;
  white-space: nowrap;
}

.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.badge-good { background: rgba(22, 163, 74, 0.2); color: #4ade80; }
.badge-ok   { background: rgba(217, 119, 6, 0.2); color: #fbbf24; }
.badge-low  { background: rgba(220, 38, 38, 0.2); color: #f87171; }

.score-dots {
  display: flex;
  align-items: center;
  gap: 2px;
}

.dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  display: inline-block;
  flex-shrink: 0;
}

.dot.filled { background: var(--primary); }

.score-num {
  font-size: 12px;
  color: var(--text-muted);
  margin-left: 5px;
}

.wellness-score {
  font-weight: 700;
  font-size: 15px;
}

/* ---- INSIGHTS ---- */
#tab-insights h2 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 22px;
}

.insights-grid {
  display: grid;
  grid-template-columns: 3fr 2fr;
  gap: 20px;
  align-items: start;
}

.chart-card,
.correlations-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 18px;
}

.chart-wrapper {
  position: relative;
  height: 280px;
}

/* ---- CORRELATIONS ---- */
.corr-list { display: flex; flex-direction: column; gap: 0; }

.corr-item {
  padding: 13px 0;
  border-bottom: 1px solid rgba(29, 64, 112, 0.5);
}

.corr-item:last-child { border-bottom: none; }

.corr-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.corr-supp-icon { font-size: 15px; }

.corr-supp-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  flex: 1;
}

.corr-arrow { color: var(--text-dim); font-size: 12px; }

.corr-metric-label {
  font-size: 12px;
  color: var(--text-muted);
}

.corr-diff {
  font-size: 14px;
  font-weight: 700;
  color: var(--primary);
  margin-left: auto;
}

.corr-detail {
  font-size: 11px;
  color: var(--text-dim);
  padding-left: 23px;
}

.corr-empty {
  font-size: 13px;
  color: var(--text-dim);
  padding: 16px 0;
}

/* ---- RESPONSIVE ---- */
@media (max-width: 768px) {
  .insights-grid { grid-template-columns: 1fr; }
  .header-stats { width: 100%; justify-content: space-between; }
}

@media (max-width: 600px) {
  header { padding: 14px 16px; position: static; }
  .tabs  { padding: 0 16px; }
  main   { padding: 18px 16px; }
  .header-content { flex-direction: column; align-items: flex-start; }
  .header-stats { gap: 8px; }
  .stat { flex: 1; min-width: 0; padding: 8px 10px; }
  .stat-value { font-size: 17px; }
  .supplement-grid { grid-template-columns: 1fr; }
  .logo h1 { font-size: 19px; }
}
