/* ===============================
   GLOBAL / ROOT
================================= */

:root {
  --td-bg: #040813;
  --td-bg-2: #07101d;
  --td-panel: #0b1422;
  --td-panel-2: #0e1828;
  --td-line: rgba(0, 255, 214, 0.14);
  --td-line-soft: rgba(255, 255, 255, 0.06);
  --td-text: #edf3ff;
  --td-text-soft: #95a3be;
  --td-text-muted: #67738d;
  --td-cyan: #15f5d1;
  --td-green: #25f27a;
  --td-yellow: #ffd02a;
  --td-orange: #ff9a3d;
  --td-red: #ff6b7d;
  --td-purple: #b983ff;
  --td-blue: #45c0ff;
  --td-track: #121d2b;
  --td-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
  --td-radius: 16px;
}

/* ===============================
   OVERSCROLL / PAGE BACKGROUND FIX
================================= */

html,
body {
  min-height: 100%;
  overscroll-behavior-y: none;
}

html {
  background:
    radial-gradient(circle at top left, rgba(0, 255, 214, 0.08), transparent 20%),
    radial-gradient(circle at top right, rgba(69, 192, 255, 0.08), transparent 18%),
    linear-gradient(180deg, #03070f 0%, #06101b 100%);
}

body.td-body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(0, 255, 214, 0.08), transparent 20%),
    radial-gradient(circle at top right, rgba(69, 192, 255, 0.08), transparent 18%),
    linear-gradient(180deg, #03070f 0%, #06101b 100%);
  color: var(--td-text);
  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
}

body.td-light-mode {
  --td-bg: #eef4fb;
  --td-bg-2: #f7fbff;
  --td-panel: #ffffff;
  --td-panel-2: #f8fbff;
  --td-line: rgba(22, 199, 132, 0.14);
  --td-line-soft: rgba(15, 23, 42, 0.08);
  --td-text: #17253a;
  --td-text-soft: #5d6c86;
  --td-text-muted: #77839a;
  --td-track: #eaf0f7;
  --td-shadow: 0 16px 36px rgba(15, 23, 42, 0.08);

  background:
    radial-gradient(circle at top left, rgba(22, 199, 132, 0.05), transparent 20%),
    radial-gradient(circle at top right, rgba(69, 192, 255, 0.06), transparent 18%),
    linear-gradient(180deg, #f4f8fd 0%, #edf3fa 100%);
}

html:has(body.td-light-mode) {
  background:
    radial-gradient(circle at top left, rgba(22, 199, 132, 0.05), transparent 20%),
    radial-gradient(circle at top right, rgba(69, 192, 255, 0.06), transparent 18%),
    linear-gradient(180deg, #f4f8fd 0%, #edf3fa 100%);
}

.td-shell {
  width: 100%;
  max-width: 100%;
}

/* ===============================
   TOPBAR
================================= */

.td-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px 18px;
  background: rgba(1, 7, 16, 0.92);
  border-bottom: 1px solid rgba(0, 255, 214, 0.12);
  box-shadow: inset 0 -1px 0 rgba(255, 255, 255, 0.03);
}

body.td-light-mode .td-topbar {
  background: rgba(255, 255, 255, 0.88);
  border-bottom: 1px solid rgba(15, 23, 42, 0.08);
}

.td-topbar-left,
.td-topbar-right {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.td-topbar-right {
  justify-content: flex-end;
  flex-wrap: nowrap;
}

.td-live-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--td-cyan);
  box-shadow: 0 0 14px rgba(21, 245, 209, 0.8);
  flex: 0 0 auto;
}

.td-topbar-title {
  margin: 0;
  font-size: 18px;
  font-weight: 800;
  color: var(--td-cyan);
  letter-spacing: 0.01em;
}

.td-topbar-subtitle {
  margin-top: 3px;
  color: var(--td-green);
  font-size: 12px;
  font-weight: 700;
}

.td-topbar-clock,
.td-topbar-updated {
  color: var(--td-text-soft);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}

.td-topbar-clock {
  min-width: 74px;
  text-align: right;
}

.td-topbar-updated {
  min-width: 110px;
  text-align: left;
}

/* ===============================
   STATUS PILLS
================================= */

.td-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  padding: 0 14px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  border: 1px solid transparent;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}

#summary-active {
  min-width: 132px;
}

#summary-warning {
  min-width: 118px;
}

.td-pill-success {
  color: #62ffb3;
  background: rgba(37, 242, 122, 0.08);
  border-color: rgba(37, 242, 122, 0.18);
}

.td-pill-danger {
  color: #ff8f98;
  background: rgba(255, 107, 125, 0.08);
  border-color: rgba(255, 107, 125, 0.18);
}

/* ===============================
   SUMMARY CARDS
================================= */

.td-summary-bar {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
  padding: 14px 22px;
  background: transparent;
  border: 0;
}

.td-summary-item {
  position: relative;
  padding: 16px 18px 14px;
  border-radius: 14px;
  border: 1px solid rgba(0, 255, 214, 0.08);
  background:
    linear-gradient(180deg, rgba(255,255,255,0.025), rgba(255,255,255,0.01)),
    rgba(7, 13, 23, 0.72);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.22);
  overflow: hidden;
}

.td-summary-item::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: linear-gradient(180deg, var(--td-cyan), rgba(21, 245, 209, 0.15));
  opacity: 0.95;
}

body.td-light-mode .td-summary-item {
  background:
    linear-gradient(180deg, rgba(255,255,255,0.92), rgba(255,255,255,0.82)),
    #fff;
  border-color: rgba(15, 23, 42, 0.08);
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.06);
}

body.td-light-mode .td-summary-item::before {
  background: linear-gradient(180deg, var(--td-cyan), rgba(21, 245, 209, 0.18));
}

.td-summary-label {
  color: var(--td-text-muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.td-summary-value {
  color: var(--td-cyan);
  font-size: 24px;
  line-height: 1.1;
  font-weight: 900;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}

.td-summary-success {
  color: #5dff9f;
}

.td-summary-warning {
  color: var(--td-yellow);
}

.td-summary-danger {
  color: var(--td-red);
}

/* ===============================
   BLOCK HISTORY LEGEND BAR
================================= */

.td-history-bar {
  display: flex;
  align-items: center;
  gap: 22px;
  flex-wrap: wrap;
  padding: 10px 22px;
  background: rgba(4, 12, 20, 0.6);
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

body.td-light-mode .td-history-bar {
  background: rgba(255, 255, 255, 0.78);
  border-bottom-color: rgba(15, 23, 42, 0.06);
}

.td-history-bar-title {
  color: var(--td-cyan);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.td-history-legend {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 18px;
}

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

.td-legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  display: inline-block;
}

.td-legend-signed { background: #17e8d2; }
.td-legend-proposed { background: var(--td-yellow); }
.td-legend-precommit { background: var(--td-blue); }
.td-legend-prevote { background: var(--td-purple); }
.td-legend-missed { background: #ff7484; }
.td-legend-nodata { background: rgba(255, 255, 255, 0.12); }

body.td-light-mode .td-legend-nodata {
  background: rgba(15, 23, 42, 0.14);
}

/* ===============================
   SECTION TITLE
================================= */

.td-section-head {
  padding: 18px 22px 10px;
}

.td-section-title-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.td-section-title {
  margin: 0;
  color: var(--td-cyan);
  font-size: 24px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.td-section-subtitle {
  margin: 0;
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 12px;
  border-radius: 999px;
  color: var(--td-cyan);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(0, 255, 214, 0.1);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

/* ===============================
   LIST HEADER
================================= */

.td-list-header-wrap {
  padding: 0 22px 10px;
}

.td-list-header {
  display: grid;
  grid-template-columns: 250px 160px minmax(400px, 1fr) 140px 120px 130px 110px;
  align-items: center;
  gap: 12px;
  min-height: 42px;
  padding: 0 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.03);
  border-bottom: 1px solid rgba(0, 255, 214, 0.08);
  background: rgba(255, 255, 255, 0.01);
}

body.td-light-mode .td-list-header {
  border-top-color: rgba(15, 23, 42, 0.04);
  border-bottom-color: rgba(15, 23, 42, 0.07);
  background: rgba(255, 255, 255, 0.5);
}

.td-h-col {
  color: var(--td-text-muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  white-space: nowrap;
}

.td-h-height,
.td-h-uptime,
.td-h-missed,
.td-h-rpc {
  text-align: right;
}

/* ===============================
   VALIDATOR LIST
================================= */

.td-validator-list {
  padding: 0 22px 22px;
}

.td-validator-card {
  background:
    linear-gradient(180deg, rgba(255,255,255,0.02), rgba(255,255,255,0.01)),
    rgba(7, 13, 23, 0.85);
  border: 1px solid rgba(0, 255, 214, 0.08);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: var(--td-shadow);
  margin-bottom: 14px;
}

body.td-light-mode .td-validator-card {
  background:
    linear-gradient(180deg, rgba(255,255,255,0.88), rgba(255,255,255,0.78)),
    #fff;
  border-color: rgba(15, 23, 42, 0.08);
}

.td-validator-row {
  display: grid;
  grid-template-columns: 250px 160px minmax(400px, 1fr) 140px 120px 130px 110px;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  cursor: pointer;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

body.td-light-mode .td-validator-row {
  border-bottom-color: rgba(15, 23, 42, 0.06);
}

.td-validator-card.is-open .td-validator-row {
  border-bottom-color: rgba(0, 255, 214, 0.08);
}

.td-col-chain {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.td-col-status,
.td-col-history,
.td-col-height,
.td-col-uptime,
.td-col-missed,
.td-col-rpc {
  min-width: 0;
}

.td-chain-avatar {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #4d46ff, #8f5fff);
  color: #fff;
  font-weight: 800;
  font-size: 14px;
  flex: 0 0 auto;
}

.td-chain-meta {
  min-width: 0;
}

.td-chain-title {
  color: var(--td-text);
  font-size: 14px;
  font-weight: 800;
  line-height: 1.2;
}

.td-chain-sub {
  color: var(--td-text-muted);
  font-size: 12px;
  font-weight: 600;
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.td-status-live {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 700;
}

.td-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  display: inline-block;
}

.td-status-success { color: #46ff92; }
.td-status-success .td-status-dot { background: #23d566; box-shadow: 0 0 8px rgba(35, 213, 102, 0.55); }

.td-status-warning { color: #ffc454; }
.td-status-warning .td-status-dot { background: #ffb22c; }

.td-status-danger { color: #ff7a89; }
.td-status-danger .td-status-dot { background: #ff6979; }

.td-status-muted { color: var(--td-text-soft); }
.td-status-muted .td-status-dot { background: var(--td-text-muted); }

.td-history-strip {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 8px;
  gap: 2px;
  align-items: center;
  height: 28px;
  padding: 4px 0;
  overflow: hidden;
}

.td-history-segment {
  width: 8px;
  height: 24px;
  border-radius: 2px;
  background: rgba(255,255,255,0.08);
}

.td-block-signed { background: #19e3cf; }
.td-block-proposed { background: #ffd02a; }
.td-block-precommit { background: #42c1ff; }
.td-block-prevote { background: #b983ff; }
.td-block-missed { background: #ff7484; }
.td-block-nodata { background: rgba(255,255,255,0.09); }

body.td-light-mode .td-block-nodata {
  background: rgba(15,23,42,0.12);
}

.td-col-height,
.td-col-uptime,
.td-col-missed,
.td-col-rpc {
  font-size: 14px;
  font-weight: 800;
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}

.td-mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  color: var(--td-text-soft);
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}

.td-number-good { color: #27f28c; }
.td-number-warn { color: #ffca47; }
.td-number-bad { color: #ff7b8b; }
.td-number-muted { color: var(--td-text-soft); }

/* ===============================
   DETAILS
================================= */

.td-validator-details {
  display: none;
  padding: 16px;
  background: rgba(255,255,255,0.01);
}

.td-validator-card.is-open .td-validator-details {
  display: block;
}

body.td-light-mode .td-validator-details {
  background: rgba(15,23,42,0.015);
}

.td-details-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr 1fr;
  gap: 16px;
}

.td-detail-panel {
  background: rgba(255,255,255,0.02);
  border: 1px solid rgba(255,255,255,0.05);
  border-radius: 12px;
  padding: 14px;
}

body.td-light-mode .td-detail-panel {
  background: rgba(255,255,255,0.65);
  border-color: rgba(15,23,42,0.06);
}

.td-detail-head {
  color: var(--td-cyan);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: 12px;
}

.td-detail-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.td-detail-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--td-text-soft);
  font-size: 14px;
}

.td-detail-row strong {
  color: var(--td-text);
  font-weight: 800;
  text-align: right;
}

.td-mini-badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 10px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 800;
  border: 1px solid transparent;
}

.td-mini-badge-success {
  color: #54ff9a;
  background: rgba(37, 242, 122, 0.08);
  border-color: rgba(37, 242, 122, 0.16);
}

.td-mini-badge-warning {
  color: #ffc454;
  background: rgba(255, 196, 84, 0.08);
  border-color: rgba(255, 196, 84, 0.16);
}

.td-mini-badge-danger {
  color: #ff8693;
  background: rgba(255, 107, 125, 0.08);
  border-color: rgba(255, 107, 125, 0.16);
}

.td-detail-note {
  margin-top: 12px;
  border-radius: 10px;
  padding: 12px;
  border: 1px solid transparent;
}

.td-detail-note-danger {
  background: rgba(255, 107, 125, 0.06);
  border-color: rgba(255, 107, 125, 0.12);
}

.td-detail-note-title {
  color: #ff8c97;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 6px;
}

.td-detail-note-body {
  color: var(--td-text-soft);
  font-size: 13px;
  line-height: 1.5;
  word-break: break-word;
}

.td-progress-wrap {
  margin-top: 16px;
}

.td-progress-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--td-text-soft);
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 10px;
}

.td-progress-label strong {
  color: var(--td-cyan);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}

.td-progress-bar {
  width: 100%;
  height: 7px;
  border-radius: 999px;
  background: var(--td-track);
  overflow: hidden;
}

.td-progress-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #1fc7b3 0%, #19f0d2 100%);
  box-shadow: 0 0 10px rgba(25, 240, 210, 0.45);
}

/* ===============================
   LOG CARD
================================= */

.td-log-card {
  margin: 0 22px 22px;
  padding: 16px;
  background: rgba(7, 13, 23, 0.85);
  border: 1px solid rgba(255,255,255,0.05);
  border-radius: 14px;
  box-shadow: var(--td-shadow);
}

body.td-light-mode .td-log-card {
  background: rgba(255,255,255,0.82);
  border-color: rgba(15,23,42,0.06);
}

.td-log-title {
  margin: 0;
  color: var(--td-cyan);
  font-size: 16px;
  font-weight: 800;
}

.td-log-subtitle {
  margin-top: 4px;
  color: var(--td-text-soft);
  font-size: 13px;
}

.td-log-pre {
  margin: 14px 0 0;
  min-height: 220px;
  max-height: 320px;
  overflow: auto;
  padding: 14px;
  border-radius: 12px;
  background: rgba(255,255,255,0.02);
  border: 1px solid rgba(255,255,255,0.04);
  color: var(--td-text-soft);
  font-size: 12px;
  line-height: 1.6;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}

body.td-light-mode .td-log-pre {
  background: rgba(15,23,42,0.03);
  border-color: rgba(15,23,42,0.06);
}

/* ===============================
   FOOTER
================================= */

.td-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 0 22px 24px;
}

.td-footer-text {
  color: var(--td-text-soft);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.03em;
}

.td-footer-text strong {
  color: var(--td-cyan);
  font-weight: 800;
}

/* ===============================
   RESPONSIVE
================================= */

@media (max-width: 1500px) {
  .td-list-header,
  .td-validator-row {
    grid-template-columns: 240px 150px minmax(320px, 1fr) 130px 100px 120px 100px;
  }
}

@media (max-width: 1200px) {
  .td-summary-bar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }

  .td-list-header {
    display: none;
  }

  .td-validator-row {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .td-col-height,
  .td-col-uptime,
  .td-col-missed,
  .td-col-rpc {
    text-align: left;
  }

  .td-details-grid {
    grid-template-columns: 1fr;
  }

  .td-topbar-right {
    flex-wrap: wrap;
    justify-content: flex-start;
  }
}

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

  .td-summary-bar {
    grid-template-columns: 1fr;
    gap: 10px;
    padding-top: 12px;
    padding-bottom: 12px;
  }

  .td-history-bar,
  .td-section-head,
  .td-list-header-wrap,
  .td-validator-list,
  .td-log-card,
  .td-footer {
    padding-left: 14px;
    padding-right: 14px;
    margin-left: 0;
    margin-right: 0;
  }

  .td-topbar-title {
    font-size: 16px;
  }

  .td-section-title {
    font-size: 18px;
  }

  .td-topbar-clock,
  .td-topbar-updated,
  #summary-active,
  #summary-warning {
    min-width: auto;
  }
}