:root {
  --bg: #f7f4ee;
  --bg-glow: #fff6e8;
  --bg-accent: #e7f0f7;
  --blob-1: #fde7c7;
  --blob-2: #d9f1ef;
  --ink: #18212b;
  --muted: #5f6b76;
  --card: #ffffff;
  --border: #e5e7eb;
  --shadow: 0 18px 40px rgba(15, 23, 42, 0.08);
  --green: #1f9d55;
  --yellow: #d97706;
  --red: #d14343;
  --neutral: #94a3b8;
  --badge-bg: rgba(15, 23, 42, 0.08);
  --progress-bg: #f3f4f6;
  --btn-bg: #111827;
  --btn-ink: #f9fafb;
  --btn-border: #111827;
  --btn-ghost-bg: transparent;
  --btn-ghost-ink: var(--ink);
  --btn-ghost-border: var(--border);
  --ghost-hover: rgba(15, 23, 42, 0.08);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b1220;
  --bg-glow: #111c2a;
  --bg-accent: #102439;
  --blob-1: #1a2b45;
  --blob-2: #0d2a2a;
  --ink: #e2e8f0;
  --muted: #94a3b8;
  --card: #0f1b2d;
  --border: #1f2937;
  --shadow: 0 18px 40px rgba(2, 6, 23, 0.55);
  --green: #22c55e;
  --yellow: #f59e0b;
  --red: #f87171;
  --neutral: #64748b;
  --badge-bg: rgba(226, 232, 240, 0.12);
  --progress-bg: #1f2937;
  --btn-bg: #e2e8f0;
  --btn-ink: #0f172a;
  --btn-border: #e2e8f0;
  --btn-ghost-ink: #e2e8f0;
  --btn-ghost-border: #334155;
  --ghost-hover: rgba(248, 250, 252, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(circle at top left, var(--bg-glow) 0%, var(--bg) 45%),
    radial-gradient(circle at 20% 20%, var(--bg-accent) 0%, transparent 40%);
  color: var(--ink);
  font-family: "IBM Plex Sans", sans-serif;
}

body::before,
body::after {
  content: "";
  position: fixed;
  inset: auto;
  z-index: -1;
  border-radius: 999px;
  opacity: 0.35;
}

body::before {
  width: 520px;
  height: 520px;
  background: radial-gradient(circle, var(--blob-1) 0%, transparent 70%);
  top: -200px;
  right: -120px;
}

body::after {
  width: 420px;
  height: 420px;
  background: radial-gradient(circle, var(--blob-2) 0%, transparent 70%);
  bottom: -180px;
  left: -120px;
}

.page {
  max-width: 1100px;
  margin: 0 auto;
  padding: 48px 24px 64px;
}

.header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 24px;
  align-items: center;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted);
}

h1 {
  margin: 8px 0 6px;
  font-family: "Space Grotesk", sans-serif;
  font-size: clamp(2rem, 3.4vw, 3rem);
}

.subtitle {
  margin: 0;
  color: var(--muted);
  max-width: 520px;
}

.controls {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: flex-end;
}

.toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.btn {
  border: 1px solid var(--btn-border);
  background: var(--btn-bg);
  color: var(--btn-ink);
  font-family: "Space Grotesk", sans-serif;
  padding: 10px 18px;
  border-radius: 999px;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.btn:disabled {
  opacity: 0.6;
  cursor: wait;
  transform: none;
}

.btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 10px 20px rgba(17, 24, 39, 0.2);
}

.btn-ghost {
  background: var(--btn-ghost-bg);
  color: var(--btn-ghost-ink);
  border-color: var(--btn-ghost-border);
  box-shadow: none;
  padding: 8px 14px;
}

.btn-ghost:hover:not(:disabled) {
  background: var(--ghost-hover);
  box-shadow: none;
  transform: translateY(-1px);
}

.meta {
  text-align: right;
  font-size: 0.88rem;
  color: var(--muted);
}

.meta-line {
  margin: 2px 0;
}

.banner {
  margin-top: 20px;
  padding: 12px 16px;
  border-radius: 12px;
  background: #fff4d7;
  border: 1px solid #fbd38d;
  color: #92400e;
}

.banner.error {
  background: #fee2e2;
  border-color: #fecaca;
  color: #991b1b;
}

:root[data-theme="dark"] .banner {
  background: rgba(251, 191, 36, 0.12);
  border-color: rgba(251, 191, 36, 0.4);
  color: #fbbf24;
}

:root[data-theme="dark"] .banner.error {
  background: rgba(248, 113, 113, 0.14);
  border-color: rgba(248, 113, 113, 0.5);
  color: #fecaca;
}

.hidden {
  display: none;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 18px;
  margin-top: 26px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 18px;
  box-shadow: var(--shadow);
  animation: fadeUp 0.5s ease both;
  animation-delay: calc(var(--i) * 70ms);
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  gap: 12px;
}

.card h3 {
  margin: 0;
  font-size: 1.1rem;
}

.badge {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--badge-bg);
  color: var(--ink);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.metric {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 12px;
}

.metric-value {
  font-size: 1.7rem;
  font-weight: 700;
  font-family: "Space Grotesk", sans-serif;
}

.metric-label {
  color: var(--muted);
}

.progress {
  height: 10px;
  border-radius: 999px;
  background: var(--progress-bg);
  overflow: hidden;
  margin-bottom: 12px;
}

.progress-bar {
  height: 100%;
  width: 0;
  background: var(--tone, var(--neutral));
  transition: width 0.4s ease;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  font-size: 0.86rem;
  color: var(--muted);
}

.stat-value {
  display: block;
  font-weight: 600;
  color: var(--ink);
  margin-top: 4px;
}

.error {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  background: #fee2e2;
  color: #991b1b;
  font-size: 0.84rem;
}

.tone-good {
  --tone: var(--green);
}

.tone-warn {
  --tone: var(--yellow);
}

.tone-danger {
  --tone: var(--red);
}

.tone-neutral {
  --tone: var(--neutral);
}

.footer {
  margin-top: 28px;
  font-size: 0.85rem;
  color: var(--muted);
  text-align: center;
}

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

@media (max-width: 720px) {
  .controls {
    align-items: flex-start;
  }

  .toolbar {
    justify-content: flex-start;
  }

  .stats {
    grid-template-columns: 1fr 1fr;
  }
}
