:root {
  color-scheme: dark;
  --bg: #07111f;
  --panel: rgba(11, 27, 48, 0.82);
  --panel-strong: rgba(14, 38, 70, 0.95);
  --text: #e6f0ff;
  --muted: #8ea8c7;
  --line: rgba(148, 163, 184, 0.22);
  --blue: #3b82f6;
  --deep-blue: #1e40af;
  --amber: #f59e0b;
  --green: #34d399;
  --danger: #fb7185;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.38);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Fira Sans", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(59, 130, 246, 0.34), transparent 34rem),
    radial-gradient(circle at 88% 12%, rgba(245, 158, 11, 0.2), transparent 26rem),
    linear-gradient(135deg, #07111f 0%, #0a1930 48%, #091321 100%);
}

button, input { font: inherit; }

.shell {
  width: min(1240px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 40px 0 56px;
}

.hero {
  display: grid;
  grid-template-columns: 1fr minmax(220px, 320px);
  gap: 24px;
  align-items: stretch;
  margin-bottom: 22px;
}

.eyebrow,
.section-kicker {
  margin: 0 0 10px;
  color: var(--amber);
  font-family: "Fira Code", monospace;
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

h1, h2, h3, p { margin-top: 0; }

h1 {
  margin-bottom: 14px;
  font-size: clamp(40px, 7vw, 84px);
  line-height: 0.9;
  letter-spacing: -0.07em;
}

h2 {
  margin-bottom: 18px;
  font-size: 15px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #bfd4f2;
}

h3 {
  margin-bottom: 12px;
  color: #dbeafe;
  font-size: 14px;
}

.lede {
  max-width: 800px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.7;
}

.status-card, .panel, .control-panel, .message {
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.status-card {
  display: grid;
  place-items: center;
  min-height: 160px;
  border-radius: 28px;
  color: var(--amber);
  font-family: "Fira Code", monospace;
  text-align: center;
}

.control-panel {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto auto;
  gap: 14px;
  align-items: end;
  margin-bottom: 16px;
  padding: 18px;
  border-radius: 24px;
}

.field span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
}

input {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0 14px;
  color: var(--text);
  background: rgba(2, 6, 23, 0.45);
  outline: none;
}

input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.18);
}

button {
  min-height: 46px;
  border: 0;
  border-radius: 14px;
  padding: 0 18px;
  cursor: pointer;
  transition: transform 180ms ease, border-color 180ms ease, background 180ms ease;
}

button:focus-visible {
  outline: 3px solid rgba(245, 158, 11, 0.65);
  outline-offset: 3px;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.primary-button {
  color: #07111f;
  background: linear-gradient(135deg, var(--amber), #fbbf24);
  font-weight: 700;
}

.ghost-button {
  color: var(--text);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
}

button:not(:disabled):hover { transform: translateY(-1px); }

.message {
  display: none;
  margin-bottom: 16px;
  padding: 14px 16px;
  border-radius: 18px;
  color: var(--muted);
}

.message.is-visible { display: block; }
.message.is-error { color: var(--danger); }
.message.is-success { color: var(--green); }

.grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 16px;
}

.analytics-grid, .lower { margin-top: 16px; }
.span-3 { grid-column: span 3; }
.span-4 { grid-column: span 4; }
.span-5 { grid-column: span 5; }
.span-6 { grid-column: span 6; }
.span-7 { grid-column: span 7; }
.span-8 { grid-column: span 8; }
.span-12 { grid-column: 1 / -1; }

.panel {
  min-height: 260px;
  border-radius: 28px;
  padding: 22px;
  overflow: hidden;
}

.summary-panel { min-height: auto; }

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

.section-heading h2 { margin-bottom: 0; }

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

.metric-card {
  position: relative;
  min-height: 118px;
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 16px;
  background: var(--panel-strong);
  overflow: hidden;
}

.metric-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--blue);
}

.metric-card--amber::before { background: var(--amber); }
.metric-card--green::before { background: var(--green); }
.metric-card--danger::before { background: var(--danger); }
.metric-card.is-muted { opacity: 0.72; }

.metric-label {
  margin-bottom: 10px;
  color: var(--muted);
  font-family: "Fira Code", monospace;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  word-break: break-all;
}

.metric-value {
  font-family: "Fira Code", monospace;
  font-size: clamp(20px, 3vw, 34px);
  color: var(--amber);
  word-break: break-word;
}

.ranked-list {
  display: grid;
  gap: 12px;
  max-height: 520px;
  overflow: auto;
}

.ranked-row {
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 14px;
  background: rgba(2, 6, 23, 0.28);
}

.ranked-main {
  display: flex;
  gap: 12px;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 10px;
}

.ranked-label,
.ranked-count,
.ranked-meta dd,
.ranked-meta dt {
  font-family: "Fira Code", monospace;
}

.ranked-label {
  color: #bfdbfe;
  font-size: 13px;
  word-break: break-all;
}

.ranked-count {
  color: var(--amber);
  font-size: 12px;
  white-space: nowrap;
}

.ranked-track {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.16);
}

.ranked-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--blue), var(--amber));
}

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

.ranked-meta div {
  min-width: 0;
  border-top: 1px solid rgba(148, 163, 184, 0.14);
  padding-top: 8px;
}

.ranked-meta dt {
  color: var(--muted);
  font-size: 10px;
  text-transform: uppercase;
}

.ranked-meta dd {
  margin: 4px 0 0;
  color: var(--text);
  font-size: 12px;
  word-break: break-word;
}

.distribution-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 12px;
  max-height: 520px;
  overflow: auto;
}

.distribution-card,
.notice-card {
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 14px;
  background: rgba(2, 6, 23, 0.28);
}

.compact-table,
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

td, th {
  border-bottom: 1px solid var(--line);
  padding: 10px 8px;
  text-align: left;
  vertical-align: top;
}

th { color: var(--muted); }
td:first-child { font-family: "Fira Code", monospace; color: #bfdbfe; }

.notice-list {
  display: grid;
  gap: 12px;
  max-height: 520px;
  overflow: auto;
}

.notice-card span {
  display: inline-flex;
  margin-bottom: 8px;
  color: var(--amber);
  font-family: "Fira Code", monospace;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.notice-card p {
  margin-bottom: 0;
  color: var(--text);
  line-height: 1.6;
  word-break: break-word;
}

.json-panel { min-height: 340px; }

.json-heading {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 14px;
}

.json-heading h2,
.json-heading p { margin-bottom: 0; }

.json-heading p {
  color: var(--muted);
  font-size: 13px;
}

.json-viewer {
  max-height: 520px;
  margin: 0;
  overflow: auto;
  color: #dbeafe;
  font-family: "Fira Code", monospace;
  font-size: 12px;
  line-height: 1.6;
  white-space: pre-wrap;
}

.empty,
.empty-inline {
  color: var(--muted);
}

@media (max-width: 1040px) {
  .summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ranked-meta { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 860px) {
  .hero, .control-panel { grid-template-columns: 1fr; }
  .span-3, .span-4, .span-5, .span-6, .span-7, .span-8 { grid-column: 1 / -1; }
}

@media (max-width: 560px) {
  .summary-grid,
  .ranked-meta,
  .distribution-grid { grid-template-columns: 1fr; }
  .ranked-main { display: grid; }
  .ranked-count { white-space: normal; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto;
    transition-duration: 0.01ms;
    animation-duration: 0.01ms;
  }
}
