:root {
  --bg: #0a0e17;
  --card: rgba(17, 23, 38, 0.72);
  --border: rgba(129, 140, 248, 0.18);
  --text: #e2e8f0;
  --muted: #8b95a8;
  --accent: #818cf8;
  --accent2: #22d3ee;
  --green: #34d399;
  --warn: #fbbf24;
  --danger: #f87171;
  --radius: 18px;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  padding: 24px;
  position: relative;
  overflow-x: hidden;
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 60% 45% at 25% 20%, rgba(99, 102, 241, 0.16), transparent),
    radial-gradient(ellipse 50% 40% at 78% 75%, rgba(34, 211, 238, 0.10), transparent);
  pointer-events: none;
  z-index: 0;
}
body::after {
  content: "";
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(129, 140, 248, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(129, 140, 248, 0.05) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: radial-gradient(ellipse 80% 70% at 50% 45%, black, transparent 75%);
  -webkit-mask-image: radial-gradient(ellipse 80% 70% at 50% 45%, black, transparent 75%);
  pointer-events: none;
  z-index: 0;
}
.wrap {
  position: relative;
  z-index: 1;
  max-width: 1200px;
  margin: 0 auto;
}
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}
h1 {
  font-size: clamp(1.7rem, 5vw, 2.4rem);
  font-weight: 800;
  letter-spacing: -0.03em;
}
h1 .grad {
  background: linear-gradient(92deg, var(--accent), var(--accent2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.status-line {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.95rem;
  color: var(--muted);
}
.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.5);
  animation: pulse 2.2s ease-out infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.45); }
  70% { box-shadow: 0 0 0 9px rgba(52, 211, 153, 0); }
  100% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0); }
}
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 18px;
}
.card {
  background: var(--card);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.45);
}
.card.wide {
  grid-column: 1 / -1;
}
@media (min-width: 900px) {
  .card.wide { grid-column: span 2; }
}
.card h2 {
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 14px;
}
.big {
  font-size: clamp(2rem, 6vw, 3rem);
  font-weight: 800;
  letter-spacing: -0.03em;
}
.sub {
  font-size: 0.9rem;
  color: var(--muted);
  margin-top: 4px;
}
.donut-wrap {
  display: flex;
  align-items: center;
  gap: 22px;
  flex-wrap: wrap;
}
.donut {
  width: 120px;
  height: 120px;
  flex-shrink: 0;
}
.donut-val {
  font-size: 1.6rem;
  font-weight: 800;
}
.donut-label {
  font-size: 0.9rem;
  color: var(--muted);
}
canvas {
  width: 100%;
  height: auto;
  display: block;
}
.chart-meta {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  margin-top: 10px;
  font-size: 0.85rem;
  color: var(--muted);
}
.legend {
  display: flex;
  align-items: center;
  gap: 6px;
}
.legend span {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  display: inline-block;
}
footer {
  margin-top: 28px;
  text-align: center;
  font-size: 0.82rem;
  color: var(--muted);
  letter-spacing: 0.04em;
}
.error-toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: rgba(248, 113, 113, 0.12);
  border: 1px solid rgba(248, 113, 113, 0.35);
  color: var(--danger);
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 0.9rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
  z-index: 10;
}
.error-toast.visible { opacity: 1; }
