:root {
  color-scheme: dark;
  --bg: #0a0c11;
  --bg-gradient: radial-gradient(circle at top, #101b2c, #050608 55%),
    linear-gradient(120deg, rgba(86, 211, 208, 0.1), transparent 40%),
    linear-gradient(220deg, rgba(244, 107, 142, 0.08), transparent 60%);
  --shell-bg: rgba(6, 8, 12, 0.75);
  --shell-shadow: 0 0 40px rgba(6, 10, 20, 0.6);
  --panel-gradient: linear-gradient(160deg, rgba(18, 22, 33, 0.9), rgba(11, 15, 24, 0.95));
  --panel: #121621;
  --panel-2: #171c2a;
  --text: #e6ecff;
  --muted: #a1acc7;
  --accent: #56d3d0;
  --accent-2: #ffb454;
  --accent-3: #f46b8e;
  --accent-4: #8f7bff;
  --line: #232a3d;
  --glow: rgba(86, 211, 208, 0.3);
}

.device-mobile {
  --type-color: #56d3d0;
  --type-glow: rgba(86, 211, 208, 0.6);
}

.device-tablet {
  --type-color: #8f7bff;
  --type-glow: rgba(143, 123, 255, 0.5);
}

.device-desktop {
  --type-color: #ffb454;
  --type-glow: rgba(255, 180, 84, 0.5);
}

.charts-spaced {
  margin-top: 18px;
}

.chart-card-wide {
  grid-column: 1 / -1;
}

.legend-devices {
  --legend-color: var(--accent);
}

.legend-network {
  --legend-color: var(--accent-2);
}

.legend-infrastructure {
  --legend-color: var(--accent-3);
}

.legend-operations {
  --legend-color: var(--accent-4);
}

body[data-theme="light"] {
  color-scheme: light;
  --bg: #f8fafc;
  --bg-gradient: radial-gradient(circle at top, rgba(191, 219, 254, 0.5), transparent 65%),
    linear-gradient(120deg, rgba(248, 250, 252, 0.95), rgba(226, 232, 240, 0.7));
  --shell-bg: rgba(255, 255, 255, 0.9);
  --shell-shadow: 0 18px 40px rgba(15, 23, 42, 0.12);
  --panel-gradient: linear-gradient(160deg, rgba(255, 255, 255, 0.95), rgba(241, 245, 249, 0.9));
  --panel: #ffffff;
  --panel-2: #f1f5f9;
  --text: #0f172a;
  --muted: #475569;
  --accent: #56d3d0;
  --accent-2: #ffb454;
  --accent-3: #f46b8e;
  --accent-4: #8f7bff;
  --line: #e2e8f0;
  --glow: rgba(37, 99, 235, 0.25);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Inter", "Segoe UI", system-ui, sans-serif;
  background: var(--bg-gradient);
  color: var(--text);
  min-height: 100vh;
  padding: 0;
}

.shell {
  width: min(1200px, 92vw);
  max-width: 1200px;
  margin: 0 auto 48px;
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(320px, 1.2fr);
  gap: 24px;
  background: var(--shell-bg);
  border: 1px solid var(--line);
  border-radius: 0;
  padding: 24px;
  box-shadow: var(--shell-shadow);
}

.digst-hero {
  padding: 1.75rem clamp(1rem, 5vw, 5rem) 2.5rem;
}

.digst-hero .nav {
  margin-bottom: 2.25rem;
}

header {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 16px;
}

header h1 {
  font-size: 28px;
  margin: 0;
  letter-spacing: 0.5px;
}

header p {
  margin: 0;
  color: var(--muted);
  max-width: 720px;
  font-size: 14px;
}

.panel {
  background: var(--panel-gradient);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 20px;
  position: sticky;
  top: 24px;
  align-self: start;
}

body[data-theme="light"] .panel {
  background: #ffffff;
  border-color: #d8e2f1;
}

.inputs {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.input-group label {
  font-size: 13px;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
}

.type-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.type-label::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--type-color);
  box-shadow: 0 0 8px var(--type-glow);
}

.input-group output {
  color: var(--text);
  font-weight: 600;
}

body[data-theme="light"] .input-group label {
  color: #334155;
}

body[data-theme="light"] .input-group output {
  color: #0f172a;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

input[type="range"].type-slider {
  accent-color: var(--type-color);
}

input[type="range"].type-slider::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(90deg,
      var(--type-color),
      rgba(255, 255, 255, 0.08));
}

input[type="range"].type-slider::-webkit-slider-thumb {
  margin-top: -5px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--type-color);
  box-shadow: 0 0 10px var(--type-glow);
  border: 2px solid #0a0c11;
}

input[type="range"].type-slider::-moz-range-track {
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(90deg,
      var(--type-color),
      rgba(255, 255, 255, 0.08));
}

input[type="range"].type-slider::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--type-color);
  box-shadow: 0 0 10px var(--type-glow);
  border: 2px solid #0a0c11;
}

input[type="range"].gray-slider {
  accent-color: #8d97b3;
}

input[type="range"].gray-slider::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(90deg,
      #b3bdd6,
      rgba(255, 255, 255, 0.08));
}

input[type="range"].gray-slider::-webkit-slider-thumb {
  margin-top: -5px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #c3cbe0;
  border: 2px solid #0a0c11;
  box-shadow: 0 0 8px rgba(195, 203, 224, 0.5);
}

input[type="range"].gray-slider::-moz-range-track {
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(90deg,
      #b3bdd6,
      rgba(255, 255, 255, 0.08));
}

input[type="range"].gray-slider::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #c3cbe0;
  border: 2px solid #0a0c11;
  box-shadow: 0 0 8px rgba(195, 203, 224, 0.5);
}

.range-stack {
  position: relative;
  height: 28px;
}

.range-stack input[type="range"] {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 28px;
  background: transparent;
  pointer-events: none;
}

.range-stack input[type="range"]::-webkit-slider-thumb {
  pointer-events: auto;
}

.range-stack input[type="range"]::-moz-range-thumb {
  pointer-events: auto;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
}

.metric {
  background: var(--panel-2);
  border-radius: 14px;
  padding: 12px;
  border: 1px solid rgba(86, 211, 208, 0.08);
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

.metric strong {
  display: block;
  font-size: 20px;
  margin-top: 6px;
}

.charts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}

.chart-card {
  background: var(--panel);
  border-radius: 18px;
  padding: 16px;
  border: 1px solid rgba(86, 211, 208, 0.08);
}

.chart-card h3 {
  margin: 0 0 12px;
  font-size: 14px;
  letter-spacing: 0.5px;
  color: var(--muted);
}

canvas {
  width: 100%;
  height: 180px;
}

#pieEnergy,
#pieCo2 {
  width: 100%;
  height: auto;
  max-width: 220px;
  margin: 0 auto;
  display: block;
}

.legend {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
  margin-top: 10px;
  font-size: 12px;
  color: var(--muted);
}

.legend span::before {
  content: "";
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 6px;
  background: var(--legend-color);
}

.footnote {
  margin-top: 14px;
  color: var(--muted);
  font-size: 12px;
}

.boxed-group {
  border: 1px solid rgba(86, 211, 208, 0.12);
  border-radius: 16px;
  padding: 14px;
  background: rgba(18, 22, 33, 0.7);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

body[data-theme="light"] .boxed-group {
  border-color: #d8e2f1;
  background: #ffffff;
}

.boxed-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
  margin: 0;
}

.boxed-divider {
  margin-top: 12px;
}

@media (max-width: 900px) {
  .shell {
    grid-template-columns: 1fr;
  }
}
