:root {
  color-scheme: dark;
  --bg: #0d0c0a;
  --surface: #171411;
  --surface-alt: #211b14;
  --ink: #f4ead4;
  --muted: #b3a487;
  --line: #3f3323;
  --accent: #f0a128;
  --accent-2: #d66a16;
  --accent-3: #f7c15a;
  --good: #247a58;
  --warn: #b7791f;
  --bad: #ba3d3b;
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.28);
  --radius: 8px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f7f1e7;
  --surface: #fffaf1;
  --surface-alt: #f3e8d8;
  --ink: #19130d;
  --muted: #6f6048;
  --line: #d7bc8c;
  --accent: #a96713;
  --accent-2: #c65d1b;
  --accent-3: #8d651d;
  --good: #1e7553;
  --warn: #936212;
  --bad: #b53634;
  --shadow: 0 18px 40px rgba(76, 48, 15, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    radial-gradient(circle at 16% 6%, rgba(240, 161, 40, 0.16), transparent 260px),
    linear-gradient(180deg, rgba(214, 106, 22, 0.08), transparent 420px),
    var(--bg);
  color: var(--ink);
}

:root[data-theme="light"] body {
  background:
    radial-gradient(circle at 16% 6%, rgba(166, 103, 19, 0.18), transparent 260px),
    linear-gradient(180deg, rgba(255, 255, 255, 0.58), transparent 420px),
    var(--bg);
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  width: min(1440px, 100%);
  margin: 0 auto;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 18px clamp(16px, 4vw, 42px);
  border-bottom: 1px solid rgba(139, 99, 43, 0.45);
  background: rgba(13, 12, 10, 0.9);
  backdrop-filter: blur(14px);
}

:root[data-theme="light"] .topbar {
  background: rgba(247, 241, 231, 0.9);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  width: 54px;
  height: 54px;
  border: 1px solid #c59132;
  border-radius: 50%;
  background: url("/logo.svg?v=4") center / cover no-repeat;
  box-shadow: 0 0 0 3px rgba(12, 9, 5, 0.9), 0 0 28px rgba(240, 161, 40, 0.28);
  flex: 0 0 auto;
}

.brand strong,
.brand small {
  display: block;
  line-height: 1.1;
}

.brand small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.76rem;
}

.topnav {
  display: flex;
  align-items: center;
  gap: 8px;
}

.topnav a,
.icon-button,
.tab {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(23, 20, 17, 0.88);
  color: var(--ink);
}

:root[data-theme="light"] .topnav a,
:root[data-theme="light"] .icon-button,
:root[data-theme="light"] .tab {
  background: rgba(255, 250, 241, 0.88);
}

.topnav a {
  display: inline-flex;
  align-items: center;
  padding: 0 13px;
  color: var(--muted);
  font-size: 0.92rem;
}

.topnav a:hover,
.icon-button:hover,
.tab:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.icon-button {
  display: grid;
  width: 40px;
  place-items: center;
  cursor: pointer;
}

main {
  padding: 24px clamp(16px, 4vw, 42px) 56px;
}

.site-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 10px;
  padding: 0 clamp(16px, 4vw, 42px) 28px;
  color: var(--muted);
  font-size: 0.88rem;
}

.site-footer a {
  color: var(--accent);
}

.site-footer a:hover {
  text-decoration: underline;
}

.network-hero,
.validator-hero,
.governance-hero {
  min-height: 280px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 360px);
  gap: 28px;
  align-items: end;
  padding: clamp(28px, 5vw, 56px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(135deg, rgba(10, 10, 9, 0.86), rgba(27, 16, 8, 0.92)),
    radial-gradient(circle at 70% 44%, rgba(240, 161, 40, 0.28), transparent 280px),
    url("/logo.svg?v=4");
  background-size: cover, cover, 420px 420px;
  background-position: center, center, right 30px center;
  background-repeat: no-repeat;
  color: #fff;
  overflow: hidden;
}

.validator-hero {
  display: block;
  min-height: 240px;
}

.hero-copy h1,
.validator-hero h1,
.governance-hero h1 {
  margin: 6px 0 12px;
  font-size: clamp(2.2rem, 6vw, 5.2rem);
  line-height: 0.96;
  letter-spacing: 0;
}

.hero-copy p,
.validator-details,
.governance-hero p {
  max-width: 760px;
  color: rgba(255, 255, 255, 0.82);
  font-size: 1.05rem;
  line-height: 1.6;
}

.eyebrow {
  margin: 0;
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.network-hero .eyebrow,
.validator-hero .eyebrow,
.governance-hero .eyebrow {
  color: #f2c766;
}

.endpoint-row,
.validator-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 22px;
}

.pill {
  display: inline-flex;
  max-width: 100%;
  align-items: center;
  gap: 7px;
  padding: 7px 10px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.9);
  font-size: 0.84rem;
  overflow-wrap: anywhere;
}

.hero-panel,
.rank-box {
  padding: 22px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.12);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.14);
}

.hero-panel strong,
.rank-box strong {
  display: block;
  margin: 8px 0;
  font-size: clamp(2.1rem, 6vw, 3.8rem);
  line-height: 1;
}

.hero-panel small,
.panel-label,
.rank-box span {
  color: rgba(255, 255, 255, 0.78);
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin: 18px 0;
}

.stat-card {
  display: block;
  width: 100%;
  min-height: 128px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  color: var(--ink);
  text-align: left;
}

.stat-card span,
.metric span,
.address-item span {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
}

.stat-card strong {
  display: block;
  margin-top: 12px;
  font-size: clamp(1.35rem, 3vw, 2.05rem);
  line-height: 1.05;
  overflow-wrap: anywhere;
}

.stat-card small {
  display: block;
  margin-top: 8px;
  color: var(--muted);
}

.split-layout,
.detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 18px;
  align-items: start;
}

.detail-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.side-stack {
  display: grid;
  gap: 18px;
}

.section-block {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.section-block.compact {
  box-shadow: none;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.section-heading h2 {
  margin: 5px 0 0;
  font-size: 1.25rem;
  line-height: 1.15;
}

.toolbar {
  display: flex;
  gap: 10px;
  align-items: end;
}

.search-field {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 0.76rem;
}

.search-field input,
select {
  height: 38px;
  min-width: 220px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0 11px;
  background: #0d0c0a;
  color: var(--ink);
}

:root[data-theme="light"] .search-field input,
:root[data-theme="light"] select {
  background: #fffaf1;
}

select {
  min-width: 150px;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 13px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

td {
  font-size: 0.92rem;
}

tr:last-child td {
  border-bottom: 0;
}

.validator-name {
  display: grid;
  gap: 3px;
  min-width: 230px;
}

.validator-name strong {
  font-size: 0.96rem;
}

.validator-name small,
.muted {
  color: var(--muted);
  overflow-wrap: anywhere;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 25px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--surface-alt);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.status.Active {
  background: rgba(36, 122, 88, 0.12);
  color: var(--good);
}

.status.Jailed,
.status.Inactive {
  background: rgba(186, 61, 59, 0.12);
  color: var(--bad);
}

.status.Signed {
  background: rgba(36, 122, 88, 0.22);
  color: var(--good);
}

.status.Missed {
  background: rgba(186, 61, 59, 0.16);
  color: var(--bad);
}

.status.VotingPeriod,
.status.DepositPeriod {
  background: rgba(240, 161, 40, 0.16);
  color: var(--accent);
}

.status.Passed {
  background: rgba(36, 122, 88, 0.22);
  color: var(--good);
}

.status.Rejected,
.status.Failed {
  background: rgba(186, 61, 59, 0.16);
  color: var(--bad);
}

.issue-list,
.proposal-list,
.address-list,
.metric-list {
  display: grid;
  gap: 10px;
}

.issue-item,
.proposal-item,
.address-item,
.metric {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-alt);
}

.issue-item strong,
.proposal-item strong,
.address-item code,
.metric strong {
  display: block;
  margin-top: 5px;
  color: var(--ink);
  overflow-wrap: anywhere;
}

.issue-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.issue-reasons {
  display: grid;
  gap: 6px;
  margin-top: 10px;
}

.issue-reasons p {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.45;
}

.tag {
  display: inline-flex;
  padding: 4px 7px;
  border-radius: 999px;
  background: rgba(165, 72, 63, 0.12);
  color: var(--accent-2);
  font-size: 0.72rem;
  font-weight: 700;
}

.proposal-item p {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.45;
}

.back-link {
  display: inline-flex;
  margin-bottom: 28px;
  color: rgba(255, 255, 255, 0.82);
}

.validator-title-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(180px, 260px);
  gap: 28px;
  align-items: end;
}

.bonded-meter,
.commission-meter {
  display: flex;
  height: 16px;
  margin-bottom: 16px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-alt);
}

.bonded-meter .self {
  background: var(--accent-3);
}

.bonded-meter .delegated,
.commission-meter span {
  background: var(--accent);
}

.tabs-section {
  margin-top: 18px;
}

.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.tab {
  padding: 0 14px;
  cursor: pointer;
}

.tab.active {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.block-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.block-strip {
  display: grid;
  grid-template-columns: repeat(50, minmax(8px, 1fr));
  gap: 4px;
  margin-bottom: 16px;
}

.block-dot {
  display: block;
  height: 12px;
  border-radius: 999px;
  background: var(--line);
}

.block-dot.signed {
  background: var(--good);
}

.block-dot.missed {
  background: var(--bad);
}

.blocks-table {
  max-height: 480px;
  overflow: auto;
}

.governance-board {
  margin-top: 18px;
}

.governance-list {
  display: grid;
  gap: 14px;
}

.governance-card {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-alt);
}

.governance-card.voting-period,
.governance-card.deposit-period {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(240, 161, 40, 0.14), var(--shadow);
}

.governance-card.passed {
  border-color: var(--good);
  box-shadow: 0 0 0 1px rgba(36, 122, 88, 0.14), var(--shadow);
}

.governance-card.rejected,
.governance-card.failed {
  border-color: var(--bad);
  box-shadow: 0 0 0 1px rgba(186, 61, 59, 0.14), var(--shadow);
}

.governance-card-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
}

.governance-card h3 {
  margin: 5px 0 0;
  font-size: clamp(1.1rem, 2vw, 1.55rem);
  line-height: 1.2;
}

.proposal-status {
  flex: 0 0 auto;
}

.proposal-summary {
  margin: 12px 0 0;
  color: var(--muted);
  line-height: 1.55;
}

.proposal-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 14px 0;
}

.proposal-meta span {
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(13, 12, 10, 0.5);
  color: var(--muted);
  font-size: 0.82rem;
}

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

.tally-row {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(13, 12, 10, 0.5);
}

.tally-row div:first-child {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.tally-row span,
.tally-row small {
  color: var(--muted);
  font-size: 0.78rem;
}

.tally-row strong {
  color: var(--ink);
}

.tally-track {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #0d0c0a;
}

.tally-track span {
  display: block;
  height: 100%;
  background: var(--accent);
}

.failed-reason {
  margin: 12px 0 0;
  color: var(--bad);
}

.chart-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.66);
}

.chart-dialog {
  width: min(920px, 100%);
  max-height: min(760px, 92vh);
  overflow: auto;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 24px 90px rgba(0, 0, 0, 0.45);
}

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

.chart-head h2 {
  margin: 4px 0 0;
  font-size: clamp(1.6rem, 4vw, 2.7rem);
}

.chart-head p {
  margin: 8px 0 0;
  color: var(--muted);
}

.chart-periods {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 18px 0;
}

.chart-kpis {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.chart-canvas {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-alt);
  overflow: hidden;
}

.chart-canvas svg {
  display: block;
  width: 100%;
  height: auto;
}

.chart-canvas line {
  stroke: var(--line);
}

.chart-canvas polyline {
  fill: none;
  stroke: var(--accent);
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.chart-canvas.down polyline {
  stroke: var(--bad);
}

.chart-canvas.up polyline {
  stroke: var(--good);
}

.chart-canvas circle {
  fill: var(--accent);
}

.chart-canvas text {
  fill: var(--muted);
  font-size: 14px;
}

.admin-shell {
  display: grid;
  min-height: 60vh;
  place-items: center;
}

.admin-login {
  width: min(460px, 100%);
}

.admin-login h1 {
  margin: 6px 0 18px;
  font-size: clamp(2rem, 5vw, 3.2rem);
}

.admin-form {
  display: grid;
  gap: 14px;
}

.admin-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.84rem;
}

.admin-form input {
  height: 44px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0 12px;
  background: #0d0c0a;
  color: var(--ink);
}

:root[data-theme="light"] .admin-form input {
  background: #fffaf1;
}

.admin-message {
  min-height: 20px;
  margin: 0;
  color: var(--bad);
}

.admin-grid {
  margin-top: 18px;
}

.hidden {
  display: none;
}

.empty-state,
.loading-state,
.error-state {
  display: grid;
  min-height: 320px;
  place-items: center;
  gap: 12px;
  color: var(--muted);
  text-align: center;
}

.spinner {
  width: 38px;
  height: 38px;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

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

  .split-layout,
  .network-hero,
  .governance-hero {
    grid-template-columns: 1fr;
  }

  .tally-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .topbar,
  .section-heading,
  .toolbar,
  .validator-title-row {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar {
    position: static;
    gap: 14px;
    padding: 14px;
  }

  .topnav {
    display: grid;
    width: 100%;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    overflow: visible;
  }

  .topnav a {
    justify-content: center;
    min-width: 0;
    padding: 0 8px;
    font-size: 0.86rem;
  }

  .icon-button {
    width: 100%;
  }

  .network-hero,
  .validator-hero,
  .governance-hero {
    min-height: 0;
    padding: 22px;
    background-size: cover, cover, 220px 220px;
    background-position: center, center, right -52px top 18px;
  }

  .hero-copy h1,
  .validator-hero h1,
  .governance-hero h1 {
    font-size: 2.35rem;
  }

  .hero-copy p,
  .validator-details,
  .governance-hero p {
    font-size: 0.95rem;
  }

  .hero-panel,
  .rank-box {
    padding: 16px;
  }

  .stat-grid,
  .detail-grid {
    grid-template-columns: 1fr;
  }

  .stat-card {
    min-height: auto;
    padding: 15px;
  }

  .stat-card strong {
    font-size: clamp(1.55rem, 9vw, 2rem);
  }

  .split-layout {
    grid-template-columns: 1fr;
  }

  .search-field input,
  select {
    width: 100%;
    min-width: 0;
  }

  .chart-kpis {
    grid-template-columns: 1fr;
  }

  .governance-card-head {
    display: grid;
  }

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

  .tabs {
    overflow-x: auto;
    padding-bottom: 4px;
  }

  .tab {
    flex: 0 0 auto;
  }

  .block-strip {
    grid-template-columns: repeat(25, minmax(8px, 1fr));
  }

  th,
  td {
    padding: 10px 8px;
  }
}
