:root {
  --bg: #1a1525;
  --panel: #2a2240;
  --panel-2: #322a4a;
  --border: #4a4068;
  --border-strong: #5d527a;
  --text: #f4eefa;
  --muted: #b8b0cc;
  --accent: #ff6fd8;
  --accent-dim: #6a3560;
  --green: #5ad6a4;
  --yellow: #f5c451;
  --red: #ff7676;
}

* { box-sizing: border-box; }

html, body { background: var(--bg); }
body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

/* ===== Header ===== */

header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

header h1 {
  margin: 0;
  font-size: 18px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent);
}

.live-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--panel);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}
.live-pill .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--red);
}
.live-pill.on .dot {
  background: var(--green);
  box-shadow: 0 0 8px var(--green);
  animation: pulse 2s ease-in-out infinite;
}
.live-pill.on { color: var(--green); border-color: var(--green); }
.live-pill.warn .dot { background: var(--yellow); }
.live-pill.warn { color: var(--yellow); border-color: var(--yellow); }
.live-pill.off .dot { background: var(--red); }
.live-pill.off { color: var(--red); border-color: var(--red); }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

.meta {
  display: flex;
  gap: 20px;
  align-items: center;
  color: var(--text);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  flex-wrap: wrap;
}
.meta-label { color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; margin-right: 4px; }

/* ===== Layout ===== */

main {
  padding: 16px 24px 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.section-title {
  margin: 4px 0 0;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  font-weight: 600;
}

/* ===== Overview ===== */

.overview {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 0;
}

.tiles {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
}

.tile {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}
.tile-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 600;
  line-height: 1.3;
}
.tile-value {
  font-size: clamp(14px, 1.4vw, 20px);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  letter-spacing: -0.01em;
  line-height: 1.1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tile-value .unit {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  margin-left: 4px;
}

.leaderboard {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.leaderboard-title {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}
.leaderboard-count {
  color: var(--muted);
  font-weight: 500;
  font-size: 10px;
  text-transform: none;
  letter-spacing: 0;
  padding: 1px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
}
.leaderboard-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-variant-numeric: tabular-nums;
}
.lb-row {
  display: grid;
  grid-template-columns: 24px minmax(120px, 1fr) auto auto;
  gap: 12px;
  align-items: center;
  font-size: 13px;
}
.lb-rank {
  color: var(--muted);
  font-size: 11px;
  text-align: right;
  font-weight: 600;
}
.lb-name {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lb-name .lb-status {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--red);
  margin-right: 6px;
  vertical-align: middle;
}
.lb-name .lb-status.on {
  background: var(--green);
  box-shadow: 0 0 6px var(--green);
}
.lb-last {
  text-align: right;
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.lb-state {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  min-width: 56px;
  text-align: center;
}
.lb-state.on {
  color: var(--green);
  border-color: color-mix(in oklab, var(--green) 40%, transparent);
  background: color-mix(in oklab, var(--green) 12%, transparent);
}
.lb-state.off {
  color: var(--muted);
}

/* ===== Table (desktop) ===== */

#validators-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  font-variant-numeric: tabular-nums;
}

th, td {
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }

th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 600;
  background: var(--panel-2);
}

.num { text-align: right; }

td.node-name { font-weight: 600; }
.node-name-inner {
  display: flex;
  align-items: center;
  gap: 8px;
}
.node-name-inner .status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--red);
  flex-shrink: 0;
}
.node-name-inner .status-dot.on {
  background: var(--green);
  box-shadow: 0 0 8px var(--green);
}
.copy-btn {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 11px;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 4px 8px;
  margin-top: 4px;
  cursor: pointer;
  letter-spacing: 0.04em;
  min-height: 24px;
  display: inline-flex;
  align-items: center;
}
.copy-btn:hover { color: var(--text); border-color: var(--muted); }
.copy-btn:active { background: var(--accent-dim); }
.copy-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

@media (pointer: coarse) {
  .copy-btn {
    padding: 8px 12px;
    font-size: 12px;
    min-height: 36px;
  }
}

tr.live-update td.last-block {
  animation: flash 1.2s ease-out;
}
@keyframes flash {
  0%   { background: var(--accent); color: var(--bg); }
  100% { background: transparent; color: inherit; }
}

.loading { text-align: center; color: var(--muted); padding: 40px; }

/* ===== Cards (compact, mobile + tablet) ===== */

.cards { display: none; flex-direction: column; gap: 8px; }

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.card-line {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  line-height: 1.4;
}

.card-name {
  font-weight: 700;
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text);
}

.card-name .status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--red);
  flex-shrink: 0;
}
.card-name .status-dot.on {
  background: var(--green);
  box-shadow: 0 0 8px var(--green);
}

.card-operator {
  margin-left: auto;
  color: var(--muted);
  font-size: 12px;
}

.card-stats-line {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 12px;
  color: var(--text);
}
.card-stat-inline {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  white-space: nowrap;
}
.card-stat-inline .m {
  color: var(--muted);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
}
.card-stat-inline .v {
  font-weight: 600;
}
.card-stats-line .sep {
  color: var(--border-strong);
  user-select: none;
}

.card.live-update {
  animation: card-flash 1.2s ease-out;
}
@keyframes card-flash {
  0% { border-color: var(--accent); box-shadow: 0 0 20px color-mix(in oklab, var(--accent) 40%, transparent); }
  100% { border-color: var(--border); box-shadow: none; }
}

/* ===== Footer ===== */

footer {
  padding: 16px 24px;
  color: var(--muted);
  font-size: 12px;
  border-top: 1px solid var(--border);
}
footer a { color: var(--accent); text-decoration: none; }
footer a:hover { text-decoration: underline; }
footer code { background: var(--panel); padding: 1px 6px; border-radius: 3px; font-size: 11px; }

/* ===== Toast ===== */

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--accent);
  color: #fff;
  padding: 8px 14px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 10;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ===== Responsive switch ===== */

/* Table → cards switch happens at the laptop boundary so 1024px doesn't overflow. */
@media (max-width: 1100px) {
  #validators-table { display: none; }
  .cards { display: flex; }
  .tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
  header { padding: 16px; }
  main { padding: 12px 12px 16px; gap: 16px; }
  footer { padding: 12px 16px; }
  .meta { gap: 12px; font-size: 11px; }
  .lb-row {
    grid-template-columns: 20px minmax(80px, 1fr) auto auto;
    gap: 8px;
    font-size: 12px;
  }
  .lb-state { min-width: 48px; padding: 2px 6px; font-size: 9px; }
}

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

@media (max-width: 480px) {
  .tiles { gap: 8px; }
  .tile { padding: 10px 12px; }
  .tile-value { font-size: 16px; }
}
