:root {
  color-scheme: light dark;
  --bg: #0b0d12;
  --panel: #171a21;
  --panel-2: #1c2029;
  --border: #2a2e37;
  --text: #e7e9ee;
  --muted: #9aa1ad;
  --accent: #4fc3f7;
  --import: #4fc3f7;
  --export: #66bb6a;
  --warn: #ffb74d;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background:
    radial-gradient(1200px 500px at 15% -10%, rgba(79, 195, 247, 0.10), transparent),
    radial-gradient(1000px 500px at 100% 0%, rgba(102, 187, 106, 0.08), transparent),
    var(--bg);
  color: var(--text);
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.75rem;
  border-bottom: 1px solid var(--border);
}

header a {
  color: var(--text);
  text-decoration: none;
  font-weight: 700;
  letter-spacing: 0.01em;
  background: linear-gradient(90deg, var(--import), var(--export));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

main { max-width: 1200px; margin: 0 auto; padding: 1.75rem; }

.card {
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.25rem;
  width: 100%;
}

.site-list { list-style: none; padding: 0; }
.site-list li a {
  display: block;
  padding: 0.9rem 1.1rem;
  margin-bottom: 0.6rem;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  text-decoration: none;
  transition: border-color 0.15s, transform 0.15s;
}
.site-list li a:hover { border-color: var(--accent); transform: translateX(2px); }

form.login { max-width: 320px; margin: 4rem auto; display: flex; flex-direction: column; gap: 0.75rem; }
form.login input {
  padding: 0.6rem 0.7rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
}
form.login button, button.logout {
  padding: 0.6rem 0.7rem;
  border-radius: 8px;
  border: none;
  background: linear-gradient(90deg, var(--import), var(--export));
  color: #0b0d12;
  font-weight: 700;
  cursor: pointer;
}
button.logout { background: transparent; border: 1px solid var(--border); color: var(--muted); padding: 0.35rem 0.7rem; }

.error { color: #f27979; font-size: 0.9rem; }
.muted { color: var(--muted); font-size: 0.9rem; }

/* Hero: turbine + big live power readout */
.hero {
  display: flex;
  align-items: center;
  gap: 2rem;
  background:
    radial-gradient(400px 200px at 0% 0%, rgba(79, 195, 247, 0.12), transparent),
    radial-gradient(400px 200px at 100% 100%, rgba(102, 187, 106, 0.12), transparent),
    linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.5rem 2rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

.turbine-wrap { flex-shrink: 0; width: 130px; height: 150px; }
.turbine-svg { width: 100%; height: 100%; overflow: visible; }
.turbine-blades { transform-origin: 100px 74px; animation: spin 4s linear infinite; }
.turbine-blades.slow { animation-duration: 10s; }
.turbine-blades.stopped { animation-play-state: paused; }
@keyframes spin { to { transform: rotate(360deg); } }

.hero-readout { flex: 1; min-width: 220px; }
.badge {
  display: inline-block;
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: 0.6rem;
}
.badge.export { background: rgba(102, 187, 106, 0.18); color: #8bd694; }
.badge.import { background: rgba(79, 195, 247, 0.18); color: #7cd3fb; }
.badge.idle { background: rgba(154, 161, 173, 0.18); color: var(--muted); }

.power-value {
  font-size: clamp(2.25rem, 5vw, 3.25rem);
  font-weight: 800;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.power-value.export { color: var(--export); text-shadow: 0 0 30px rgba(102, 187, 106, 0.35); }
.power-value.import { color: var(--import); text-shadow: 0 0 30px rgba(79, 195, 247, 0.35); }
.power-value.idle { color: var(--muted); }
.power-sub { color: var(--muted); font-size: 0.9rem; margin-top: 0.35rem; }

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.stat {
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--border);
  border-left: 3px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.2rem;
}
.stat.import { border-left-color: var(--import); }
.stat.export { border-left-color: var(--export); }
.stat .value { font-size: 1.7rem; font-weight: 700; }
.stat .label { color: var(--muted); font-size: 0.85rem; margin-top: 0.2rem; }

.live-header { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 0.75rem; }
.live-header h2 { margin: 0; font-size: 1.1rem; }
.table-scroll { overflow-x: auto; }
.live-table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.live-table th, .live-table td { text-align: right; padding: 0.4rem 0.6rem; border-bottom: 1px solid var(--border); white-space: nowrap; }
.live-table th:first-child, .live-table td:first-child { text-align: left; }
.live-table thead th { color: var(--muted); font-weight: 500; font-size: 0.85rem; }
.live-table .total-row td { font-weight: 600; border-top: 1px solid var(--border); border-bottom: none; }
#live-lifetime { margin: 0.75rem 0 0; }
