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

:root {
  --bg:       #f0f4ff;
  --surface:  #ffffff;
  --surface2: #f8f9fe;
  --border:   #e2e8f0;
  --text:     #1e293b;
  --muted:    #64748b;
  --accent:   #6366f1;
  --accent2:  #8b5cf6;
  --red:      #ef4444;
  --green:    #10b981;
  --yellow:   #f59e0b;
  --orange:   #f97316;
  --purple:   #8b5cf6;
  --pink:     #ec4899;
  --teal:     #14b8a6;
  --radius:   16px;
  --shadow:   0 2px 16px rgba(99,102,241,.08);
  --shadow-md: 0 4px 32px rgba(99,102,241,.13);
}

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

/* ── Header ── */
header {
  background: linear-gradient(120deg, #6366f1 0%, #8b5cf6 60%, #ec4899 100%);
  padding: 0 32px;
  display: flex;
  align-items: center;
  gap: 28px;
  height: 60px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 4px 24px rgba(99,102,241,.25);
}
header h1 {
  font-size: 17px;
  font-weight: 800;
  white-space: nowrap;
  color: #ffffff;
  letter-spacing: -.01em;
}

/* ── Nav ── */
nav { display: flex; gap: 4px; }
nav button {
  background: rgba(255,255,255,.15);
  border: 1.5px solid rgba(255,255,255,.25);
  color: rgba(255,255,255,.85);
  padding: 6px 18px;
  border-radius: 99px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: all .18s;
  backdrop-filter: blur(4px);
}
nav button:hover {
  background: rgba(255,255,255,.28);
  color: #fff;
  border-color: rgba(255,255,255,.5);
}
nav button.active {
  background: #ffffff;
  color: #6366f1;
  font-weight: 700;
  border-color: #ffffff;
  box-shadow: 0 2px 12px rgba(0,0,0,.15);
}

.data-note {
  margin-left: auto;
  font-size: 11px;
  color: rgba(255,255,255,.9);
  background: rgba(255,255,255,.18);
  border: 1px solid rgba(255,255,255,.35);
  border-radius: 99px;
  padding: 4px 12px;
  white-space: nowrap;
}

/* ── Main ── */
main { padding: 28px 32px; max-width: 1400px; margin: 0 auto; }

/* ── Views ── */
.view { display: none; }
.view.active { display: block; }

/* ── Cards ── */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px 22px;
  box-shadow: var(--shadow);
  border: 1.5px solid rgba(99,102,241,.07);
}
.card h2 {
  font-size: 13px;
  color: var(--muted);
  font-weight: 600;
  margin-bottom: 14px;
  text-transform: uppercase;
  letter-spacing: .06em;
}

/* ── Stat cards ── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}
.stat-card {
  border-radius: var(--radius);
  padding: 18px 22px;
  position: relative;
  overflow: hidden;
  background: var(--surface);
  box-shadow: var(--shadow);
  border: 1.5px solid rgba(99,102,241,.07);
  transition: transform .18s, box-shadow .18s;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-card .label {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
  margin-bottom: 4px;
}
.stat-card .value {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -.02em;
  color: var(--text);
}
.stat-card .sub {
  font-size: 11px;
  color: var(--muted);
  margin-top: 3px;
}

/* Coloured stat variants */
.stat-card.blue   { background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%); }
.stat-card.green  { background: linear-gradient(135deg, #10b981 0%, #14b8a6 100%); }
.stat-card.orange { background: linear-gradient(135deg, #f97316 0%, #f59e0b 100%); }
.stat-card.pink   { background: linear-gradient(135deg, #ec4899 0%, #f43f5e 100%); }
.stat-card.blue .label,  .stat-card.blue .sub,
.stat-card.green .label, .stat-card.green .sub,
.stat-card.orange .label,.stat-card.orange .sub,
.stat-card.pink .label,  .stat-card.pink .sub  { color: rgba(255,255,255,.8); }
.stat-card.blue .value,  .stat-card.green .value,
.stat-card.orange .value,.stat-card.pink .value  { color: #ffffff; }

/* Dynamic text colours (set by JS) */
.red-text   { color: var(--red)   !important; }
.green-text { color: var(--green) !important; }

/* ── Grid layouts ── */
.two-col   { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.three-col { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
@media (max-width: 960px) { .two-col, .three-col { grid-template-columns: 1fr; } }

/* ── Chart wrapper ── */
.chart-wrap { position: relative; }
.chart-wrap canvas { width: 100% !important; }

/* ── Controls ── */
.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
  margin-bottom: 22px;
}
.control-group { display: flex; flex-direction: column; gap: 5px; }
.control-group label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .05em;
}
select, input[type=text] {
  background: var(--surface);
  border: 2px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 14px;
  min-width: 220px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  box-shadow: 0 1px 4px rgba(0,0,0,.04);
}
select:focus, input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(99,102,241,.12);
}

/* ── Table ── */
.tbl-wrap { overflow-x: auto; border-radius: 12px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  background: linear-gradient(135deg, #f0f4ff 0%, #f5f3ff 100%);
  color: var(--muted);
  font-weight: 700;
  text-align: left;
  padding: 11px 14px;
  white-space: nowrap;
  border-bottom: 2px solid var(--border);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .05em;
}
tbody tr {
  border-bottom: 1px solid #f1f5f9;
  transition: background .1s;
}
tbody tr:nth-child(even) { background: #fafbff; }
tbody tr:hover { background: #eff6ff; }
tbody td { padding: 9px 14px; }

/* ── Badges ── */
.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .02em;
}
.badge-red    { background: #fef2f2; color: var(--red); }
.badge-green  { background: #f0fdf4; color: #059669; }
.badge-yellow { background: #fffbeb; color: #d97706; }
.badge-blue   { background: #eff6ff; color: #3b82f6; }

/* ── Category chips ── */
.chips { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 18px; }
.chip {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 99px;
  padding: 5px 14px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all .15s;
  color: var(--muted);
  box-shadow: 0 1px 4px rgba(0,0,0,.04);
}
.chip:hover   { border-color: var(--accent); color: var(--accent); background: #f0f4ff; }
.chip.active  {
  background: linear-gradient(120deg, #6366f1, #8b5cf6);
  border-color: transparent;
  color: #ffffff;
  font-weight: 700;
  box-shadow: 0 2px 10px rgba(99,102,241,.3);
}

/* ── Loading ── */
#loading {
  position: fixed; inset: 0;
  background: linear-gradient(135deg, #f0f4ff 0%, #fdf4ff 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 18px;
  z-index: 999;
  font-size: 15px;
  color: var(--muted);
  font-weight: 500;
}
.spinner {
  width: 40px; height: 40px;
  border: 4px solid #e0e7ff;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Multi-chart grid ── */
.chart-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}
.chart-item {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  border: 1.5px solid rgba(99,102,241,.07);
}
.chart-item .title   { font-size: 13px; font-weight: 700; margin-bottom: 4px; color: var(--text); }
.chart-item .subtitle { font-size: 11px; color: var(--muted); margin-bottom: 8px; }

/* ── Section title ── */
.section-title {
  font-size: 17px;
  font-weight: 800;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  letter-spacing: -.01em;
}
.collapsible-trigger {
  cursor: pointer;
  user-select: none;
}
.collapsible-trigger:hover { color: var(--accent); }
.collapse-arrow {
  font-size: 11px;
  transition: transform .2s ease;
  color: var(--muted);
}
.collapsible-trigger[aria-expanded="true"] .collapse-arrow {
  transform: rotate(90deg);
}

.divider {
  height: 2px;
  background: linear-gradient(90deg, #e0e7ff, transparent);
  margin: 24px 0;
  border-radius: 99px;
}
.mt16 { margin-top: 16px; }
.mt20 { margin-top: 20px; }
.empty { color: var(--muted); text-align: center; padding: 40px; font-size: 13px; }

/* ── Report button ── */
.report-btn {
  background: linear-gradient(120deg, #6366f1, #8b5cf6);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 8px 18px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity .15s, transform .15s;
  align-self: flex-end;
  box-shadow: 0 2px 10px rgba(99,102,241,.3);
}
.report-btn:hover:not(:disabled) { opacity: .85; transform: translateY(-1px); }

/* ── Insight cards ── */
.insight-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 16px;
  margin-bottom: 8px;
}
.insight-card {
  display: flex;
  gap: 14px;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
  border-left: 4px solid transparent;
  transition: transform .18s, box-shadow .18s;
}
.insight-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.insight-red    { border-left-color: var(--red); }
.insight-orange { border-left-color: var(--orange); }
.insight-blue   { border-left-color: #6366f1; }
.insight-green  { border-left-color: var(--green); }
.insight-purple { border-left-color: var(--purple); }
.insight-icon { font-size: 26px; flex-shrink: 0; line-height: 1.2; }
.insight-body { flex: 1; min-width: 0; }
.insight-title {
  font-size: 14px;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 6px;
  letter-spacing: -.01em;
}
.insight-text {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.65;
  margin-bottom: 10px;
}
.insight-text strong { color: var(--text); font-weight: 700; }
.insight-text em { font-style: italic; }
.insight-tags { display: flex; flex-wrap: wrap; gap: 5px; }
.itag {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 9px;
  border-radius: 99px;
}
.itag-red    { background: #fef2f2; color: var(--red); }
.itag-green  { background: #f0fdf4; color: #059669; }
.itag-orange { background: #fff7ed; color: var(--orange); }
.itag-blue   { background: #eff6ff; color: #6366f1; }
.itag-purple { background: #faf5ff; color: var(--purple); }

/* ── Strategy grid ── */
.strategy-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}
.strategy-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px 22px;
  box-shadow: var(--shadow);
  border: 1.5px solid rgba(99,102,241,.07);
}
.strategy-icon {
  width: 38px; height: 38px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  margin-bottom: 10px;
}
.s-blue   { background: #eff6ff; }
.s-purple { background: #faf5ff; }
.s-green  { background: #f0fdf4; }
.strategy-title {
  font-size: 15px;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 10px;
  letter-spacing: -.01em;
}
.strategy-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.strategy-list li {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.6;
  padding-left: 16px;
  position: relative;
}
.strategy-list li::before {
  content: '▸';
  position: absolute;
  left: 0;
  color: var(--accent);
  font-size: 12px;
}
.report-btn:disabled { opacity: .4; cursor: not-allowed; }
