* {
  box-sizing: border-box;
}

html[data-theme="dark"] {
  --bg: radial-gradient(circle at top, #071b30 0%, #020710 45%, #000000 100%);
  --card-bg: rgba(7, 18, 40, 0.9);
  --card-border: rgba(0, 227, 192, 0.16);
  --text-main: #eaf4ff;
  --text-muted: #8da2cc;
  --accent: #00e3c0;
  --accent-soft: rgba(0, 227, 192, 0.16);
  --danger: #ff4b6b;
}

html[data-theme="light"] {
  --bg: radial-gradient(circle at top, #f4fbff 0%, #e3f0ff 40%, #d5e3ff 100%);
  --card-bg: rgba(255, 255, 255, 0.96);
  --card-border: rgba(17, 34, 64, 0.12);
  --text-main: #071423;
  --text-muted: #5b6a8a;
  --accent: #00bba0;
  --accent-soft: rgba(0, 187, 160, 0.14);
  --danger: #e62f4f;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Inter", sans-serif;
  background: var(--bg);
  color: var(--text-main);
}

/* HEADER */

.header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 26px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  backdrop-filter: blur(18px);
  background:
    radial-gradient(circle at top left, rgba(0, 227, 192, 0.16), transparent 60%),
    linear-gradient(90deg, rgba(1, 5, 14, 0.96), rgba(3, 16, 40, 0.96));
}

.header-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.logo {
  height: 44px;
  filter: drop-shadow(0 0 18px rgba(0, 227, 192, 0.9));
}

.title-wrap {
  display: flex;
  flex-direction: column;
}

.title {
  margin: 0;
  font-size: 19px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.subtitle {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--text-muted);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* STATUS + PILLS */

.status-pill {
  padding: 6px 14px;
  font-size: 13px;
  border-radius: 999px;
  background: rgba(5, 26, 52, 0.92);
  border: 1px solid rgba(0, 227, 192, 0.2);
  color: #b8d9ff;
  box-shadow: 0 0 18px rgba(0, 227, 192, 0.18);
}

.status-ok {
  background: rgba(0, 227, 192, 0.18);
  border-color: #00e3c0;
  color: #eafffb;
}

.status-error {
  background: rgba(255, 75, 107, 0.12);
  border-color: var(--danger);
  color: #ffd6de;
}

.pill-group {
  display: flex;
  gap: 6px;
}

.pill {
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid rgba(113, 144, 194, 0.6);
  background: radial-gradient(circle at top, #101d3a, #050b16);
  color: #dbe7ff;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.18s ease-out;
}

.pill:hover {
  box-shadow: 0 0 12px rgba(0, 227, 192, 0.38);
  border-color: rgba(0, 227, 192, 0.9);
}

.pill-active {
  background: linear-gradient(120deg, #00e3c0, #00a4ff);
  color: #041018;
  border-color: transparent;
  box-shadow: 0 0 18px rgba(0, 227, 192, 0.7);
}

.theme-pill {
  font-size: 13px;
}

/* HEADER MINI-STATS */

#top-stats {
  margin-top: 6px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.stat-badge {
  background: linear-gradient(135deg, #00e3c0, #00a4ff);
  padding: 4px 12px;
  border-radius: 999px;
  color: #041018;
  font-weight: 600;
  font-size: 11px;
  box-shadow: 0 12px 22px rgba(0, 227, 192, 0.35);
}

/* LAYOUT – MAIN + SIDEBAR */

.layout {
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(320px, 1.3fr);
  gap: 22px;
  padding: 24px 26px 26px;
  align-items: flex-start;
}

.layout-main {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 22px;
}

.layout-sidebar {
  display: flex;
  flex-direction: column;
  gap: 18px;
  position: sticky;
  top: 88px;
  max-height: calc(100vh - 96px);
  overflow-y: auto;
}

/* CARDS */

.card {
  background:
    radial-gradient(circle at top left, rgba(0, 227, 192, 0.12), transparent 60%),
    radial-gradient(circle at bottom right, rgba(0, 164, 255, 0.15), transparent 50%),
    linear-gradient(145deg, rgba(4, 13, 30, 0.96), rgba(2, 6, 16, 0.98));
  border-radius: 18px;
  padding: 18px 16px 16px;
  border: 1px solid var(--card-border);
  box-shadow:
    0 22px 40px rgba(0, 0, 0, 0.58),
    0 0 40px rgba(0, 227, 192, 0.06);
  position: relative;
  overflow: hidden;
  transform: translateY(0);
  transition:
    transform 0.18s ease-out,
    box-shadow 0.18s ease-out,
    border-color 0.18s ease-out,
    background 0.18s ease-out;
  backdrop-filter: blur(18px);
}

.card::before {
  content: "";
  position: absolute;
  inset: -40%;
  background: radial-gradient(circle at top, rgba(0, 227, 192, 0.16), transparent 55%);
  opacity: 0.4;
  pointer-events: none;
}

.card:hover {
  transform: translateY(-3px);
  border-color: rgba(0, 227, 192, 0.45);
  box-shadow:
    0 28px 50px rgba(0, 0, 0, 0.8),
    0 0 48px rgba(0, 227, 192, 0.4);
}

/* Entry animation */

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.card-animate {
  opacity: 0;
  animation: fadeInUp 0.45s ease-out forwards;
}

.card-animate:nth-of-type(1) { animation-delay: 0.02s; }
.card-animate:nth-of-type(2) { animation-delay: 0.05s; }
.card-animate:nth-of-type(3) { animation-delay: 0.08s; }
.card-animate:nth-of-type(4) { animation-delay: 0.11s; }
.card-animate:nth-of-type(5) { animation-delay: 0.14s; }
.card-animate:nth-of-type(6) { animation-delay: 0.17s; }

.card-header {
  position: relative;
  z-index: 1;
}

.card h2 {
  margin: 0 0 4px;
  font-size: 17px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.card-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: rgba(0, 227, 192, 0.12);
  box-shadow: 0 0 13px rgba(0, 227, 192, 0.7);
  font-size: 12px;
}

.card-subtitle {
  margin: 0 0 12px;
  font-size: 12px;
  color: var(--text-muted);
}

.card-footnote {
  position: relative;
  z-index: 1;
  margin-top: 10px;
  font-size: 11px;
  color: var(--text-muted);
}

/* KPI GRID */

.kpi-grid {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
}

.kpi-grid-compact {
  margin-top: 6px;
}

.kpi {
  padding: 10px 10px 9px;
  border-radius: 12px;
  background: radial-gradient(circle at top left, rgba(0, 227, 192, 0.1), transparent 60%);
  border: 1px solid rgba(0, 227, 192, 0.2);
  box-shadow: 0 10px 18px rgba(0, 0, 0, 0.45);
}

.kpi.small {
  padding: 8px 9px 7px;
}

.kpi-label {
  font-size: 11px;
  color: var(--text-muted);
}

.kpi-value {
  margin-top: 2px;
  font-size: 16px;
  font-weight: 600;
}

.kpi-sub {
  margin-top: 2px;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(181, 199, 247, 0.9);
}

/* DUAL RANGE GRID (Market card sliders) */

.dual-range-grid {
  position: relative;
  z-index: 1;
  margin-top: 14px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

@media (min-width: 900px) {
  .dual-range-grid {
    grid-template-columns: 1fr 1fr;
  }
}

/* FIELDS */

.field {
  position: relative;
  z-index: 1;
  margin-bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.field-inline {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.field label {
  font-size: 12px;
  color: var(--text-muted);
}

.field input[type="number"],
.field input[type="text"] {
  border-radius: 10px;
  border: 1px solid rgba(135, 160, 210, 0.65);
  background: linear-gradient(130deg, rgba(5, 18, 38, 0.9), rgba(2, 8, 22, 0.95));
  color: var(--text-main);
  padding: 7px 9px;
  font-size: 13px;
}

.field input[type="range"] {
  width: 100%;
}

/* SLIDERS */

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  border-radius: 999px;
  background: rgba(40, 65, 102, 0.9);
  outline: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #00e3c0;
  border: 2px solid #041018;
  box-shadow: 0 0 10px rgba(0, 227, 192, 0.8);
  cursor: pointer;
}

input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #00e3c0;
  border: 2px solid #041018;
  box-shadow: 0 0 10px rgba(0, 227, 192, 0.8);
  cursor: pointer;
}

/* BADGES */

.field-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 8px;
  margin-left: 6px;
  border-radius: 999px;
  font-size: 11px;
  background: rgba(6, 24, 54, 0.92);
  border: 1px solid rgba(0, 227, 192, 0.45);
  color: #eafffb;
}

/* ACTION BUTTONS */

.action-btn {
  position: relative;
  z-index: 1;
  width: 100%;
  margin-top: 10px;
  padding: 10px 14px;
  border-radius: 999px;
  border: none;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  background: linear-gradient(125deg, #00e3c0, #00a4ff);
  color: #041018;
  box-shadow: 0 18px 30px rgba(0, 227, 192, 0.45);
  transition: transform 0.12s ease-out, box-shadow 0.12s ease-out;
}

.action-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 22px 38px rgba(0, 227, 192, 0.6);
}

.action-btn:active {
  transform: translateY(0);
  box-shadow: 0 12px 24px rgba(0, 227, 192, 0.38);
}

/* PRESET BUTTONS */

.preset-row {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-bottom: 10px;
}

.preset-label {
  font-size: 11px;
  color: var(--text-muted);
}

.preset-btn {
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid rgba(113, 144, 194, 0.7);
  background: rgba(6, 18, 40, 0.92);
  color: #dbe7ff;
  font-size: 11px;
  cursor: pointer;
  transition: all 0.15s ease-out;
}

.preset-btn:hover {
  border-color: var(--accent);
  box-shadow: 0 0 10px rgba(0, 227, 192, 0.6);
}

.preset-btn.wide {
  padding-inline: 14px;
}

/* JSON / SUMMARY BUTTONS */

.json-btn {
  position: relative;
  z-index: 1;
  padding: 6px 10px;
  font-size: 11px;
  border-radius: 999px;
  border: 1px solid rgba(113, 144, 194, 0.6);
  background: radial-gradient(circle at top, #101d3a, #050b16);
  color: #b5c7f7;
  cursor: pointer;
}

.secondary-btn {
  border-color: rgba(0, 227, 192, 0.6);
  color: #eafffb;
}

.summary-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

/* SUMMARY & JSON BOXES */

.summary-title {
  position: relative;
  z-index: 1;
  margin-top: 18px;
  font-size: 11px;
  letter-spacing: 0.14em;
  color: rgba(181, 199, 247, 0.9);
}

.summary-box,
.json-box {
  position: relative;
  z-index: 1;
  margin-top: 6px;
  padding: 10px;
  border-radius: 10px;
  background:
    radial-gradient(circle at top left, rgba(0, 227, 192, 0.12), transparent 60%),
    radial-gradient(circle at bottom right, rgba(0, 164, 255, 0.15), transparent 50%),
    rgba(4, 14, 32, 0.98);
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 11px;
  max-height: 220px;
  overflow: auto;
  color: #dce8ff;
}

/* CHARTS */

.chart-wrap {
  position: relative;
  z-index: 1;
  margin-top: 12px;
  height: 210px;
}

canvas {
  width: 100% !important;
  height: 100% !important;
}

/* SIDEBAR CARDS */

.sidebar-card {
  min-width: 0;
}

/* Active Nodes panel */

.stats-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 6px;
  margin-bottom: 10px;
}

.stat {
  display: flex;
  flex-direction: column;
}

.stat-label {
  font-size: 11px;
  color: var(--text-muted);
}

.stat-value {
  font-size: 18px;
  font-weight: 600;
}

.node-list {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.node-item {
  padding: 0.4rem 0.6rem;
  border-radius: 0.5rem;
  background: rgba(255, 255, 255, 0.03);
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.node-id {
  font-weight: 600;
}

.node-meta {
  font-size: 0.8rem;
  opacity: 0.8;
  display: flex;
  gap: 0.8rem;
  flex-wrap: wrap;
}

.node-empty {
  opacity: 0.7;
  font-size: 0.85rem;
}

/* Proof-of-Compute table */

.poc-table-wrap {
  max-height: 260px;
  overflow-y: auto;
  margin-top: 6px;
}

.poc-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.poc-table th,
.poc-table td {
  padding: 6px 8px;
  text-align: left;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.poc-table thead th {
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.8rem;
}

.poc-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.03);
}

.poc-empty-row td {
  opacity: 0.7;
  text-align: center;
}

/* Node Leaderboard */

.leaderboard-wrap {
  max-height: 260px;
  overflow-y: auto;
  margin-top: 8px;
}

.leaderboard-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.leaderboard-table th,
.leaderboard-table td {
  padding: 6px 8px;
  text-align: left;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.leaderboard-table thead th {
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.8rem;
}

.leaderboard-row:hover {
  background: rgba(255, 255, 255, 0.03);
}

.lb-rank {
  width: 40px;
  font-weight: 600;
}

.lb-node-id {
  font-weight: 600;
  font-size: 0.86rem;
}

.lb-profile {
  font-size: 0.8rem;
  opacity: 0.85;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.lb-proofs {
  font-weight: 600;
}

.lb-meta {
  font-size: 0.8rem;
  opacity: 0.9;
}

.lb-last-seen {
  opacity: 0.7;
  font-size: 0.75rem;
}

.lb-gpu-pill,
.lb-cpu-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
}

.lb-gpu-pill {
  background: rgba(34, 197, 94, 0.16);
  color: #bbf7d0;
  border: 1px solid rgba(34, 197, 94, 0.6);
}

.lb-cpu-pill {
  background: rgba(148, 163, 184, 0.16);
  color: #e2e8f0;
  border: 1px solid rgba(148, 163, 184, 0.6);
}

.lb-empty-row td {
  text-align: center;
  opacity: 0.7;
}

/* Unified Button Style (Refresh etc.) */

.pill-btn {
  position: relative;
  z-index: 1;
  padding: 8px 14px;
  border-radius: 999px;
  border: none;
  font-weight: 600;
  font-size: 12px;
  cursor: pointer;
  background: linear-gradient(125deg, #00e3c0, #00a4ff);
  color: #041018;
  box-shadow: 0 18px 30px rgba(0, 227, 192, 0.45);
  transition: transform 0.12s ease-out, box-shadow 0.12s ease-out;
}

.pill-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 22px 38px rgba(0, 227, 192, 0.6);
}

.pill-btn:active {
  transform: translateY(0);
  box-shadow: 0 12px 24px rgba(0, 227, 192, 0.38);
}

/* RESPONSIVE */

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

  .layout-sidebar {
    position: static;
    max-height: none;
    overflow: visible;
  }
}

@media (max-width: 768px) {
  .header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .header-right {
    align-self: stretch;
    justify-content: space-between;
    flex-wrap: wrap;
  }

  .layout {
    padding: 18px;
  }
}
