*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #0c0e13;
  --surface: #141821;
  --surface-raised: #1b202b;
  --border: #262c39;
  --border-soft: #1c212b;
  --text-primary: #edf0f5;
  --text-secondary: #8b92a8;
  --text-tertiary: #565d72;
  --accent: #e8a548;
  --accent-soft: #f4c374;
  --accent-dim: rgba(232, 165, 72, 0.08);
  --accent-mid: rgba(232, 165, 72, 0.32);
  --green: #4ade80;
  --green-dim: rgba(74, 222, 128, 0.12);
  --red: #f0596b;
  --red-dim: rgba(240, 89, 107, 0.12);
  --font-display: 'Inter', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --radius: 10px;
  --radius-sm: 6px;
}

html {
  background: var(--bg);
  color: var(--text-primary);
  font-family: var(--font-display);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

a {
  color: var(--accent-soft);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* header */

header {
  border-bottom: 1px solid var(--border);
  padding: 0 2rem;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  background: rgba(12, 14, 19, 0.9);
  backdrop-filter: blur(8px);
  z-index: 100;
}

.logo {
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: -0.01em;
}

.logo-mark {
  width: 18px;
  height: 18px;
  align-self: center;
  flex-shrink: 0;
}

.logo-mark circle {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2.5;
}

.logo-sub {
  color: var(--text-secondary);
  font-weight: 400;
  font-size: 0.85rem;
}

.status-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: 99px;
  padding: 5px 12px 5px 9px;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-tertiary);
}

.status-dot.online {
  background: var(--green);
}

.status-dot.offline {
  background: var(--red);
}

/* layout */

main {
  flex: 1;
  max-width: 1180px;
  width: 100%;
  margin: 0 auto;
  padding: 3.5rem 2rem 5rem;
}

section + section,
.stats-grid,
.chart-section,
.about-section {
  margin-top: 3.5rem;
}

/* hero */

.hero {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 2.5rem;
  align-items: stretch;
}

.eyebrow {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 0.9rem;
}

.live-count-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.live-count {
  font-size: clamp(3.25rem, 8vw, 6rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  transition: opacity 0.2s;
}

.live-count.loading {
  opacity: 0.25;
}

.live-trend {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  padding: 5px 11px;
  border-radius: 99px;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  white-space: nowrap;
}

.live-trend.up {
  color: var(--green);
  border-color: rgba(74, 222, 128, 0.28);
  background: var(--green-dim);
}

.live-trend.down {
  color: var(--red);
  border-color: rgba(240, 89, 107, 0.28);
  background: var(--red-dim);
}

.hero-copy {
  margin-top: 1.25rem;
  font-size: 0.95rem;
  color: var(--text-secondary);
  max-width: 42ch;
}

.hero-copy strong {
  color: var(--text-primary);
  font-weight: 600;
}

/* capacity card */

.capacity-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem;
  display: flex;
  flex-direction: column;
}

.ring-wrap {
  position: relative;
  width: 152px;
  height: 152px;
  margin: 0.25rem auto 1.5rem;
}

.capacity-ring {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.ring-track {
  fill: none;
  stroke: var(--border-soft);
  stroke-width: 10;
}

.ring-fill {
  fill: none;
  stroke: var(--accent);
  stroke-width: 10;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.ring-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.ring-pct {
  font-family: var(--font-mono);
  font-size: 1.55rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.ring-pct-label {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-top: 3px;
}

.capacity-meta {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  font-size: 0.88rem;
}

.meta-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
}

.meta-label {
  color: var(--text-secondary);
}

.meta-value {
  font-family: var(--font-mono);
  font-weight: 600;
  text-align: right;
}

.meta-value.online {
  color: var(--green);
}

.meta-value.offline {
  color: var(--red);
}

.meta-divider {
  height: 1px;
  background: var(--border);
  margin: 0.15rem 0;
}

/* tooltips */

[data-tip] {
  position: relative;
  cursor: help;
  text-decoration: underline dotted var(--text-tertiary);
  text-underline-offset: 3px;
}

[data-tip]:hover::after,
[data-tip]:focus-visible::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 9px);
  left: 50%;
  transform: translateX(-50%);
  width: max-content;
  max-width: min(240px, 80vw);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-raised);
  color: var(--text-secondary);
  font-family: var(--font-display);
  font-size: 0.78rem;
  font-weight: 400;
  line-height: 1.45;
  text-decoration: none;
  pointer-events: none;
  z-index: 80;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4);
}

[data-tip]:focus-visible {
  outline: 1px solid var(--accent-mid);
  outline-offset: 2px;
  border-radius: 2px;
}

/* stats grid */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.stat-card {
  background: var(--surface);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.stat-card-label {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.stat-card-value {
  font-size: 1.65rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.stat-card-value.accent {
  color: var(--accent-soft);
}

.stat-card-value.text {
  font-size: 1.2rem;
  padding-top: 0.25rem;
  font-variant-numeric: normal;
}

.stat-card-sub {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--text-tertiary);
  margin-top: 0.15rem;
}

/* section headings, shared */

.section-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  gap: 1rem;
  flex-wrap: wrap;
}

.section-heading h2 {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.section-heading p {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

/* chart */

.chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem;
}

.chart-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.75rem;
  flex-wrap: wrap;
}

.tab-group {
  display: flex;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.tab-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  padding: 7px 14px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.tab-btn:not(:last-child) {
  border-right: 1px solid var(--border);
}

.tab-btn:hover {
  color: var(--text-primary);
}

.tab-btn.active {
  background: var(--accent-dim);
  color: var(--accent-soft);
}

.custom-range {
  display: none;
  align-items: center;
  gap: 0.6rem;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-secondary);
}

.custom-range.active {
  display: flex;
}

.custom-range input[type="datetime-local"] {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  padding: 5px 8px;
  color-scheme: dark;
}

.custom-range button {
  background: var(--accent-dim);
  border: 1px solid var(--accent-mid);
  color: var(--accent-soft);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  border-radius: 6px;
  padding: 5px 12px;
  cursor: pointer;
}

.custom-range button:hover {
  background: var(--accent-mid);
}

.axis-toggle {
  display: flex;
  align-items: center;
}

.toggle-label {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-secondary);
  user-select: none;
}

.toggle-label input {
  display: none;
}

.toggle-slider {
  position: relative;
  width: 32px;
  height: 18px;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: 99px;
  transition: background 0.2s, border-color 0.2s;
}

.toggle-slider::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 12px;
  height: 12px;
  background: var(--text-tertiary);
  border-radius: 50%;
  transition: transform 0.2s, background 0.2s;
}

.toggle-label input:checked + .toggle-slider {
  background: var(--accent-dim);
  border-color: var(--accent-mid);
}

.toggle-label input:checked + .toggle-slider::after {
  transform: translateX(14px);
  background: var(--accent);
}

.toggle-text {
  min-width: 72px;
}

.chart-wrap {
  position: relative;
  height: 320px;
}

.chart-loading,
.chart-empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-secondary);
}

.chart-empty {
  flex-direction: column;
  gap: 0.5rem;
  text-align: center;
}

/* about section */

.about-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.5rem;
}

.about-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.6rem;
}

.about-card h3 {
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 0.6rem;
  letter-spacing: -0.01em;
}

.about-card p {
  font-size: 0.88rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

.about-card p + p {
  margin-top: 0.6rem;
}

.about-card code {
  font-family: var(--font-mono);
  font-size: 0.82em;
  color: var(--accent-soft);
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.1em 0.4em;
}

/* footer */

footer {
  border-top: 1px solid var(--border);
  padding: 2.25rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1.25rem;
  font-family: var(--font-display);
  background: var(--surface);
}

.footer-brand {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.footer-domain {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.01em;
  text-decoration: none;
}

.footer-domain:hover {
  color: var(--accent-soft);
  text-decoration: none;
}

.footer-tag {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.footer-center {
  display: flex;
  align-items: center;
}

.footer-made {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.footer-made a {
  color: var(--accent-soft);
  font-weight: 600;
  text-decoration: none;
}

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

.footer-right {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.footer-source {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
  padding: 0.5rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-raised);
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.footer-source:hover {
  border-color: var(--accent-mid);
  color: var(--accent-soft);
  background: var(--accent-dim);
  text-decoration: none;
}

.footer-refresh {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-tertiary);
}

.refresh-ring {
  width: 14px;
  height: 14px;
  border: 1.5px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 2s linear infinite;
}

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

.refresh-ring.idle {
  animation: none;
  border-top-color: var(--border);
}

/* responsive */

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

  .capacity-card {
    max-width: 360px;
  }
}

@media (max-width: 600px) {
  header {
    padding: 0 1rem;
  }

  main {
    padding: 2.5rem 1rem 4rem;
  }

  footer {
    padding: 1rem;
    flex-direction: column;
    align-items: flex-start;
  }

  .chart-controls {
    flex-direction: column;
    align-items: flex-start;
  }

  .capacity-card {
    max-width: none;
  }
}