@import url("https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,400;9..144,500;9..144,600&family=IBM+Plex+Sans:wght@400;500;600&family=IBM+Plex+Mono:wght@400;500;600&display=swap");

:root {
  --paper: #f6f5f1;
  --surface: #ffffff;
  --ink: #201f1d;
  --ink-soft: #6b6862;
  --line: #e3e0d8;

  --plum: #5c1f3d;
  --plum-soft: #7a3355;

  --scale: #3f6b45;
  --scale-bg: #e9f1e9;
  --watch: #a8763a;
  --watch-bg: #f6eee0;
  --reconsider: #a23f2e;
  --reconsider-bg: #f6e6e2;
  --new: #8a8579;
  --new-bg: #eeece7;

  --radius: 10px;
  --shadow: 0 1px 2px rgba(32, 31, 29, 0.06), 0 1px 12px rgba(32, 31, 29, 0.04);
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "IBM Plex Sans", system-ui, sans-serif;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

.wrap {
  max-width: 860px;
  margin: 0 auto;
  padding: 20px 16px 64px;
}

/* ---------- Header ---------- */

.header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 0 20px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 20px;
}

.header h1 {
  font-family: "Fraunces", serif;
  font-weight: 500;
  font-size: clamp(24px, 4vw, 32px);
  margin: 0;
  letter-spacing: -0.01em;
}

.header .updated {
  font-family: "IBM Plex Mono", monospace;
  font-size: 12px;
  color: var(--ink-soft);
}

/* ---------- Alert banner ---------- */

.banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-radius: var(--radius);
  margin-bottom: 20px;
  font-weight: 500;
}

.banner.alert {
  background: var(--reconsider-bg);
  color: var(--reconsider);
  border: 1px solid rgba(162, 63, 46, 0.25);
}

.banner.notice {
  background: var(--watch-bg);
  color: var(--watch);
  border: 1px solid rgba(168, 118, 58, 0.25);
}

.banner .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  flex: none;
}

/* ---------- Range picker ---------- */

.range-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 24px;
}

.range-picker button {
  font-family: "IBM Plex Sans", sans-serif;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-soft);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 14px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.range-picker button:hover {
  border-color: var(--plum-soft);
  color: var(--ink);
}

.range-picker button.active {
  background: var(--plum);
  border-color: var(--plum);
  color: #fff;
}

.range-picker button:focus-visible,
button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--plum);
  outline-offset: 2px;
}

/* ---------- Summary tiles ---------- */

.summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 28px;
}

.tile {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}

.tile .label {
  font-size: 12px;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 6px;
}

.tile .value {
  font-family: "Fraunces", serif;
  font-size: clamp(20px, 3.4vw, 28px);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.tile .delta {
  font-family: "IBM Plex Mono", monospace;
  font-size: 12px;
  margin-top: 4px;
}

.delta.up.good,
.delta.down.good {
  color: var(--scale);
}
.delta.up.bad,
.delta.down.bad {
  color: var(--reconsider);
}
.delta.flat {
  color: var(--ink-soft);
}

/* ---------- Section headers ---------- */

.section-title {
  font-family: "Fraunces", serif;
  font-size: 18px;
  font-weight: 500;
  margin: 0 0 12px;
}

section {
  margin-bottom: 32px;
}

/* ---------- Campaign cards ---------- */

.campaign-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.campaign-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px 16px;
  align-items: center;
}

.campaign-name {
  font-weight: 500;
  font-size: 14px;
  grid-column: 1 / -1;
}

.campaign-stats {
  display: flex;
  gap: 20px;
  font-family: "IBM Plex Mono", monospace;
  font-size: 13px;
  color: var(--ink-soft);
}

.campaign-stats strong {
  color: var(--ink);
  font-weight: 600;
}

/* ---------- Tier badge (the signature element) ---------- */

.tier {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  padding: 5px 10px 5px 8px;
  border-radius: 999px;
  white-space: nowrap;
}

.tier svg {
  width: 12px;
  height: 12px;
  flex: none;
}

.tier.scale {
  background: var(--scale-bg);
  color: var(--scale);
}
.tier.watch {
  background: var(--watch-bg);
  color: var(--watch);
}
.tier.reconsider {
  background: var(--reconsider-bg);
  color: var(--reconsider);
}
.tier.new {
  background: var(--new-bg);
  color: var(--new);
}

/* ---------- Past campaigns (collapsible) ---------- */

.past-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  background: none;
  border: none;
  cursor: pointer;
  font-family: "Fraunces", serif;
  font-size: 18px;
  font-weight: 500;
  color: var(--ink);
  padding: 0;
  margin-bottom: 12px;
}

.past-toggle .chev {
  transition: transform 0.15s;
  font-size: 13px;
  color: var(--ink-soft);
}

.past-toggle[aria-expanded="true"] .chev {
  transform: rotate(90deg);
}

.past-list {
  display: none;
  flex-direction: column;
  gap: 6px;
}

.past-list.open {
  display: flex;
}

.past-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 13px;
  color: var(--ink-soft);
}

.past-row .name {
  color: var(--ink);
}

.past-row .figures {
  font-family: "IBM Plex Mono", monospace;
  white-space: nowrap;
}

/* ---------- States ---------- */

.empty {
  color: var(--ink-soft);
  font-size: 14px;
  padding: 20px 0;
}

.loading {
  color: var(--ink-soft);
  font-size: 14px;
  padding: 40px 0;
  text-align: center;
}

.error-box {
  background: var(--reconsider-bg);
  color: var(--reconsider);
  border-radius: var(--radius);
  padding: 16px;
  font-size: 14px;
}

footer.meta {
  margin-top: 40px;
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px;
  color: var(--ink-soft);
  text-align: center;
}

/* ---------- Motion & responsiveness ---------- */

@media (prefers-reduced-motion: no-preference) {
  .fade-in {
    animation: fadeIn 0.35s ease-out;
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 560px) {
  .summary {
    grid-template-columns: 1fr;
  }
  .campaign-stats {
    gap: 14px;
    flex-wrap: wrap;
  }
}
