:root {
  --bg: #070b18;
  --panel: rgba(20, 27, 48, 0.72);
  --panel-solid: #141b30;
  --panel-2: rgba(27, 36, 64, 0.6);
  --border: rgba(120, 140, 200, 0.16);
  --border-bright: rgba(129, 140, 248, 0.4);
  --text: #eef2fb;
  --text-dim: #98a6c8;
  --accent: #818cf8;
  --accent-cyan: #38bdf8;
  --accent-purple: #c084fc;
  --dl: #38bdf8;
  --ul: #c084fc;
  --excellent: #34d399;
  --good: #a3e635;
  --fair: #fbbf24;
  --poor: #f87171;
  --shadow: 0 24px 60px -20px rgba(0, 0, 0, 0.7);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* ===== Background orbs ===== */
.bg-orbs {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
}
.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.5;
  animation: float 18s ease-in-out infinite;
}
.orb-1 { width: 480px; height: 480px; background: #2563eb; top: -140px; left: -100px; }
.orb-2 { width: 420px; height: 420px; background: #7c3aed; bottom: -160px; right: -80px; animation-delay: -6s; }
.orb-3 { width: 360px; height: 360px; background: #0891b2; top: 40%; left: 55%; animation-delay: -12s; }

@keyframes float {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(40px, -30px) scale(1.08); }
  66% { transform: translate(-30px, 24px) scale(0.94); }
}

/* ===== Header ===== */
.site-header {
  padding: 2rem 1.5rem 0.5rem;
  display: flex;
  justify-content: center;
}
.brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}
.brand-mark {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-purple));
  color: #04101f;
  font-weight: 800;
  font-size: 1.1rem;
  border-radius: 13px;
  box-shadow: 0 8px 24px -6px rgba(129, 140, 248, 0.6);
}
.brand-text { display: flex; flex-direction: column; }
.brand-name { font-size: 1.25rem; font-weight: 700; letter-spacing: -0.01em; }
.brand-sub { font-size: 0.82rem; color: var(--text-dim); }

main {
  flex: 1;
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3rem;
}

/* ===== Dashboard ===== */
.dashboard {
  background: var(--panel);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 1.75rem;
  box-shadow: var(--shadow);
}

.dash-top {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 1.5rem;
  align-items: center;
}

/* ===== Gauge ===== */
.gauge-wrap {
  position: relative;
  width: 260px;
  height: 260px;
  margin: 0 auto;
}
.gauge { width: 100%; height: 100%; transform: rotate(135deg); }
.gauge-track {
  fill: none;
  stroke: rgba(120, 140, 200, 0.12);
  stroke-width: 16;
  stroke-linecap: round;
  stroke-dasharray: 528 704;
}
.gauge-arc {
  fill: none;
  stroke: url(#gaugeGrad);
  stroke-width: 16;
  stroke-linecap: round;
  stroke-dasharray: 0 704;
  transition: stroke-dasharray 0.25s ease;
  filter: drop-shadow(0 0 6px rgba(129, 140, 248, 0.5));
}
.gauge-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.15rem;
}
.gauge-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 2.9rem;
  font-weight: 700;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.gauge-unit { color: var(--text-dim); font-size: 0.9rem; font-weight: 500; }
.gauge-mode {
  margin-top: 0.4rem;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent);
  padding: 0.2rem 0.7rem;
  border: 1px solid var(--border-bright);
  border-radius: 999px;
}

/* ===== Chart ===== */
.chart-wrap {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1rem 1.1rem;
  min-width: 0;
}
.chart-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}
.chart-title { font-size: 0.85rem; color: var(--text-dim); font-weight: 600; }
.chart-legend { display: flex; gap: 0.9rem; font-size: 0.75rem; color: var(--text-dim); }
.lg { display: inline-flex; align-items: center; gap: 0.35rem; }
.lg i { width: 10px; height: 3px; border-radius: 2px; display: inline-block; }
.lg-dl i { background: var(--dl); }
.lg-ul i { background: var(--ul); }
.chart { width: 100%; height: 220px; display: block; }

/* ===== Progress + phases ===== */
.progress-block { margin-top: 1.5rem; }
.progress-bar {
  height: 6px;
  background: rgba(120, 140, 200, 0.12);
  border-radius: 999px;
  overflow: hidden;
}
.progress-fill {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent-cyan), var(--accent-purple));
  border-radius: 999px;
  transition: width 0.3s ease;
}
.phases {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  margin-top: 1rem;
  flex-wrap: wrap;
}
.phase {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.82rem;
  color: var(--text-dim);
  transition: color 0.25s ease;
}
.phase .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(120, 140, 200, 0.25);
  transition: all 0.25s ease;
}
.phase.active { color: var(--text); font-weight: 600; }
.phase.active .dot {
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(129, 140, 248, 0.2), 0 0 12px var(--accent);
  animation: pulse 1.2s ease-in-out infinite;
}
.phase.done { color: var(--excellent); }
.phase.done .dot { background: var(--excellent); box-shadow: none; animation: none; }

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.25); }
}

/* ===== Stat tiles ===== */
.stat-tiles {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.85rem;
  margin-top: 1.5rem;
}
.tile {
  position: relative;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.1rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  overflow: hidden;
  transition: transform 0.2s ease, border-color 0.2s ease;
}
.tile.live {
  border-color: var(--border-bright);
  transform: translateY(-2px);
}
.tile.live::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--accent-cyan), var(--accent-purple));
}
.tile-icon {
  font-size: 1.1rem;
  color: var(--accent);
  opacity: 0.85;
}
.tile-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
}
.tile-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.5rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.tile-value small { font-size: 0.7rem; color: var(--text-dim); margin-left: 0.25rem; font-family: 'Inter', sans-serif; }

/* ===== Controls ===== */
.controls {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 1.75rem;
  flex-wrap: wrap;
}
.btn {
  position: relative;
  border: none;
  border-radius: 12px;
  padding: 0.8rem 1.8rem;
  font-size: 1rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  overflow: hidden;
  transition: transform 0.1s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-primary {
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-purple));
  color: #04101f;
  box-shadow: 0 10px 30px -8px rgba(129, 140, 248, 0.6);
}
.btn-primary:not(:disabled):hover { box-shadow: 0 14px 36px -8px rgba(129, 140, 248, 0.8); }
.btn-glow {
  position: absolute;
  inset: 0;
  background: linear-gradient(120deg, transparent 30%, rgba(255,255,255,0.35) 50%, transparent 70%);
  transform: translateX(-120%);
}
.btn-primary:not(:disabled):hover .btn-glow { animation: shine 1s ease; }
@keyframes shine { to { transform: translateX(120%); } }
.btn-ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border-bright);
}
.phase-label { color: var(--text-dim); font-size: 0.9rem; }
.timer {
  margin-left: auto;
  font-family: 'JetBrains Mono', monospace;
  font-variant-numeric: tabular-nums;
  font-size: 1.05rem;
  color: var(--text-dim);
}

/* ===== Results ===== */
.results {
  margin-top: 1.5rem;
  background: var(--panel);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 1.75rem;
  box-shadow: var(--shadow);
  animation: rise 0.5s ease;
}
.results.hidden { display: none; }
@keyframes rise {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

.results-head {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  margin-bottom: 1.75rem;
}
.grade-ring {
  width: 96px;
  height: 96px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--panel-2);
  border: 2px solid var(--border-bright);
  box-shadow: 0 0 30px -6px rgba(129, 140, 248, 0.5);
}
.grade { font-size: 3rem; font-weight: 800; line-height: 1; }
.grade-A { color: var(--excellent); }
.grade-B { color: var(--good); }
.grade-C { color: var(--fair); }
.grade-D { color: #fb923c; }
.grade-F { color: var(--poor); }
.grade-caption { display: block; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.1em; font-size: 0.78rem; }
.grade-desc { display: block; margin-top: 0.35rem; font-size: 1.3rem; font-weight: 700; }

.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 0.75rem;
  margin-bottom: 2rem;
}
.result-item {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1rem 0.9rem;
  text-align: center;
}
.result-label { display: block; color: var(--text-dim); font-size: 0.76rem; }
.result-value {
  display: block;
  margin-top: 0.4rem;
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.15rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.apps-title { margin: 0; font-size: 1.15rem; }
.apps-subtitle { margin: 0.3rem 0 1.1rem; color: var(--text-dim); font-size: 0.9rem; }
.apps-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.8rem;
}
.app-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.1rem;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  transition: transform 0.15s ease;
}
.app-card:hover { transform: translateY(-2px); }
.app-name { font-weight: 600; font-size: 0.95rem; }
.app-rating {
  font-size: 0.75rem;
  text-transform: capitalize;
  padding: 0.25rem 0.7rem;
  border-radius: 999px;
  font-weight: 700;
}
.app-card.excellent { border-color: rgba(52, 211, 153, 0.5); }
.app-card.excellent .app-rating { background: rgba(52, 211, 153, 0.16); color: var(--excellent); }
.app-card.good { border-color: rgba(163, 230, 53, 0.5); }
.app-card.good .app-rating { background: rgba(163, 230, 53, 0.16); color: var(--good); }
.app-card.fair { border-color: rgba(251, 191, 36, 0.5); }
.app-card.fair .app-rating { background: rgba(251, 191, 36, 0.16); color: var(--fair); }
.app-card.poor { border-color: rgba(248, 113, 113, 0.5); }
.app-card.poor .app-rating { background: rgba(248, 113, 113, 0.16); color: var(--poor); }

/* ===== Footer ===== */
.site-footer {
  text-align: center;
  padding: 1.5rem;
  color: var(--text-dim);
  font-size: 0.83rem;
  border-top: 1px solid var(--border);
}

/* ===== Responsive ===== */
@media (max-width: 720px) {
  .dash-top { grid-template-columns: 1fr; }
  .gauge-wrap { width: 220px; height: 220px; }
  .stat-tiles { grid-template-columns: repeat(2, 1fr); }
  .timer { margin-left: 0; }
  .results-head { flex-direction: column; text-align: center; }
}
