:root {
  --bg-0: #06080f;
  --bg-1: #0b1220;
  --bg-2: #111a2e;
  --surface: rgba(17, 26, 46, 0.62);
  --surface-strong: rgba(17, 26, 46, 0.85);
  --border: rgba(148, 163, 184, 0.16);
  --border-strong: rgba(148, 163, 184, 0.28);
  --text: #e6ecf8;
  --text-soft: #a5b3cf;
  --text-dim: #7c8aa6;
  --accent: #38bdf8;
  --accent-2: #f59e0b;
  --good: #22c55e;
  --bad: #ef4444;
  --warn: #facc15;
  --shadow-strong: 0 24px 60px rgba(2, 6, 23, 0.55);
  --radius-lg: 20px;
  --radius-md: 14px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: "Inter", "Segoe UI", system-ui, sans-serif;
  color: var(--text);
  background:
    radial-gradient(900px 600px at -10% -20%, rgba(56, 189, 248, 0.18), transparent 60%),
    radial-gradient(800px 500px at 110% 0%, rgba(168, 85, 247, 0.14), transparent 60%),
    linear-gradient(180deg, var(--bg-1) 0%, var(--bg-0) 100%);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

.bg-orb {
  position: fixed;
  inset: auto;
  width: 520px;
  height: 520px;
  border-radius: 50%;
  filter: blur(120px);
  opacity: 0.55;
  pointer-events: none;
  z-index: 0;
}

.orb-a {
  top: -120px;
  left: -120px;
  background: radial-gradient(circle, rgba(56, 189, 248, 0.55), transparent 60%);
}

.orb-b {
  bottom: -180px;
  right: -160px;
  background: radial-gradient(circle, rgba(245, 158, 11, 0.4), transparent 60%);
}

.bg-grid {
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(148, 163, 184, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(148, 163, 184, 0.05) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(circle at 50% 0%, rgba(0, 0, 0, 0.9), transparent 70%);
  pointer-events: none;
  z-index: 0;
}

.shell {
  position: relative;
  z-index: 1;
  max-width: 1200px;
  margin: 0 auto;
  padding: 36px 22px 44px;
}

.hero {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 28px;
}

.brand {
  display: flex;
  gap: 16px;
  align-items: center;
}

.brand-mark {
  width: 54px;
  height: 54px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.25), rgba(245, 158, 11, 0.2));
  border: 1px solid rgba(148, 163, 184, 0.2);
  color: #fef3c7;
  box-shadow: 0 12px 28px rgba(245, 158, 11, 0.16);
}

.brand-mark svg {
  width: 28px;
  height: 28px;
}

h1 {
  margin: 0;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 0.2px;
  background: linear-gradient(180deg, #ffffff, #b9c5e0);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hero-sub {
  margin: 4px 0 0;
  color: var(--text-soft);
  font-size: 14px;
}

.hero-side {
  display: flex;
  align-items: center;
  gap: 16px;
}

.hero-clock {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  font-variant-numeric: tabular-nums;
}

.hero-clock #clockTime {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.3px;
}

.hero-clock-label {
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  border: 1px solid var(--border-strong);
  background: var(--surface-strong);
  backdrop-filter: blur(14px);
}

.badge .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-dim);
  box-shadow: 0 0 0 4px rgba(148, 163, 184, 0.12);
}

.badge-live {
  color: #bbf7d0;
  border-color: rgba(34, 197, 94, 0.4);
  background: rgba(34, 197, 94, 0.12);
}

.badge-live .dot {
  background: var(--good);
  box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.2);
  animation: pulse 1.8s ease-in-out infinite;
}

.badge-fallback {
  color: #fde68a;
  border-color: rgba(250, 204, 21, 0.4);
  background: rgba(250, 204, 21, 0.1);
}

.badge-fallback .dot {
  background: var(--warn);
  box-shadow: 0 0 0 4px rgba(250, 204, 21, 0.2);
}

.badge-offline {
  color: #fecaca;
  border-color: rgba(239, 68, 68, 0.4);
  background: rgba(239, 68, 68, 0.12);
}

.badge-offline .dot {
  background: var(--bad);
  box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.18);
}

.badge-pending {
  color: var(--text-soft);
}

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

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.kpi {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 20px;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--border);
  backdrop-filter: blur(18px);
  overflow: hidden;
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.kpi:hover {
  transform: translateY(-2px);
  border-color: var(--border-strong);
}

.kpi::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.04), transparent 60%);
  pointer-events: none;
}

.kpi-primary {
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.18), rgba(56, 189, 248, 0.04)) ,
    var(--surface);
  border-color: rgba(56, 189, 248, 0.35);
  box-shadow: 0 20px 45px rgba(56, 189, 248, 0.12);
}

.kpi-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  background: rgba(56, 189, 248, 0.16);
  color: #7dd3fc;
}

.kpi-icon svg {
  width: 22px;
  height: 22px;
}

.kpi-icon-amber {
  background: rgba(245, 158, 11, 0.18);
  color: #fcd34d;
}

.kpi-icon-blue {
  background: rgba(96, 165, 250, 0.18);
  color: #93c5fd;
}

.kpi-icon-violet {
  background: rgba(167, 139, 250, 0.18);
  color: #c4b5fd;
}

.kpi-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.kpi-label {
  font-size: 12px;
  color: var(--text-soft);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  font-weight: 600;
}

.kpi-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.kpi-value-sm {
  font-size: 18px;
}

.kpi-meta {
  font-size: 12px;
  color: var(--text-dim);
}

.kpi-primary .kpi-value {
  color: #f0f9ff;
}

.plants {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.plant {
  position: relative;
  padding: 22px;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--border);
  backdrop-filter: blur(18px);
  overflow: hidden;
}

.plant::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.03), transparent 70%);
  pointer-events: none;
}

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

.plant-id {
  display: flex;
  align-items: center;
  gap: 14px;
}

.plant-badge {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.5px;
  color: #f0f9ff;
}

.color-01 {
  background: linear-gradient(135deg, #38bdf8, #0ea5e9);
  box-shadow: 0 10px 24px rgba(14, 165, 233, 0.32);
}

.color-02 {
  background: linear-gradient(135deg, #fbbf24, #f59e0b);
  box-shadow: 0 10px 24px rgba(245, 158, 11, 0.32);
}

.plant h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.3px;
}

.plant-sub {
  font-size: 12px;
  color: var(--text-dim);
}

.state {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  border: 1px solid;
}

.state-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.state-online {
  color: #bbf7d0;
  border-color: rgba(34, 197, 94, 0.45);
  background: rgba(34, 197, 94, 0.12);
}

.state-online .state-dot {
  background: var(--good);
  box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.18);
  animation: pulse 1.8s ease-in-out infinite;
}

.state-offline {
  color: #fecaca;
  border-color: rgba(239, 68, 68, 0.45);
  background: rgba(239, 68, 68, 0.14);
}

.state-offline .state-dot {
  background: var(--bad);
}

.state-pending {
  color: var(--text-soft);
  border-color: var(--border-strong);
  background: rgba(148, 163, 184, 0.06);
}

.state-pending .state-dot {
  background: var(--text-dim);
}

.plant-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.plant-metrics > div {
  padding: 14px;
  border-radius: var(--radius-md);
  background: rgba(15, 23, 42, 0.55);
  border: 1px solid var(--border);
}

.m-label {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-dim);
  margin-bottom: 6px;
  font-weight: 600;
}

.m-value {
  display: block;
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.m-secondary {
  color: #cbd5e1;
}

.chart-card {
  padding: 22px;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--border);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow-strong);
}

.chart-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.chart-head h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
}

.chart-hint {
  margin: 4px 0 0;
  color: var(--text-dim);
  font-size: 13px;
}

.chart-legend {
  display: flex;
  gap: 14px;
  align-items: center;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-soft);
  font-weight: 600;
}

.dot-line {
  width: 18px;
  height: 4px;
  border-radius: 4px;
  display: inline-block;
}

.dot-line.color-01 {
  background: linear-gradient(90deg, #38bdf8, #0ea5e9);
  box-shadow: none;
}

.dot-line.color-02 {
  background: linear-gradient(90deg, #fbbf24, #f59e0b);
  box-shadow: none;
}

#powerChart {
  width: 100%;
  min-height: 340px;
}

.footer {
  margin-top: 26px;
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--text-dim);
}

.status-msg {
  margin: 0;
  font-size: 13px;
  color: var(--text-soft);
}

.footer-cred {
  margin: 0;
  font-size: 12px;
}

@media (max-width: 980px) {
  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

@media (max-width: 620px) {
  .shell {
    padding: 24px 16px 36px;
  }

  h1 {
    font-size: 22px;
  }

  .hero {
    gap: 16px;
  }

  .hero-side {
    width: 100%;
    justify-content: space-between;
  }

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

  .kpi-value {
    font-size: 24px;
  }

  .plant-metrics {
    grid-template-columns: 1fr;
  }

  .chart-legend {
    width: 100%;
    justify-content: flex-start;
  }
}
