:root {
  --bg0: #ffffff;
  --bg1: #fafafa;
  --ink: #16191a;
  --muted: #626973;
  --line: #e1e5ea;
  --ok: #2f9e44;
  --ok-dim: rgba(47, 158, 68, 0.14);
  --fail: #f1361b;
  --fail-dim: rgba(241, 54, 27, 0.12);
  --accent: #0057b7;
  --accent-2: #0ea2ff;
  --accent-deep: #002777;
  --surface: #fafbfc;
  --header-bg: #003d82;
  --chart: #0057b7;
  --chart-grid: rgba(23, 19, 33, 0.08);
  --chart-label: rgba(115, 114, 120, 0.95);
  --font: "DM Sans", "Segoe UI", sans-serif;
  --font-brand: "Barlow", "Segoe UI", sans-serif;
  --font-brand-status: "Barlow Condensed", "Barlow", "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
}

html[data-theme="dark"] {
  --bg0: #0f1216;
  --bg1: #151a20;
  --ink: #e8eaed;
  --muted: #9aa3ad;
  --line: #2a323c;
  --ok: #3ecf5a;
  --ok-dim: rgba(62, 207, 90, 0.16);
  --fail: #ff6b54;
  --fail-dim: rgba(255, 107, 84, 0.16);
  --accent: #0ea2ff;
  --accent-2: #5cbcff;
  --accent-deep: #e8eaed;
  --surface: #181e26;
  --header-bg: #003d82;
  --chart: #0ea2ff;
  --chart-grid: rgba(255, 255, 255, 0.1);
  --chart-label: rgba(154, 163, 173, 0.95);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: var(--font);
  background: var(--bg0);
}

.page {
  width: calc(100% - 2rem);
  max-width: none;
  margin: 0 auto;
  padding: 2rem 0 3.5rem;
}

.header {
  background: var(--header-bg);
  color: #fff;
}

.header-inner {
  width: calc(100% - 2rem);
  margin: 0 auto;
  padding: 1rem 0 1.1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem 1.5rem;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  flex-shrink: 0;
}

.brand {
  margin: 0;
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  font-family: var(--font-brand);
  font-size: clamp(1.5rem, 3.75vw, 2.25rem);
  font-weight: 700;
  letter-spacing: 0.01em;
  line-height: 0.95;
  color: #fff;
}

.brand-name {
  color: #fff;
}

.brand-rest {
  font-family: var(--font-brand-status);
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #fff;
}

.tagline {
  margin: 0.55rem 0 0;
  color: var(--muted);
  font-size: 1.05rem;
}

.meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  margin: 0;
  text-align: right;
}

.meta dt {
  margin: 0;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: rgba(255, 255, 255, 0.72);
}

.meta dd {
  margin: 0.2rem 0 0;
  font-family: var(--mono);
  font-size: 0.95rem;
  color: #fff;
}

.theme-toggle {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  margin: 0;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 0.35rem;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  cursor: pointer;
}

.theme-toggle:hover {
  background: rgba(255, 255, 255, 0.2);
}

.theme-toggle .theme-icon {
  display: none;
  line-height: 0;
}

html:not([data-theme="dark"]) .theme-toggle .theme-icon-moon,
html[data-theme="dark"] .theme-toggle .theme-icon-sun {
  display: block;
}

.section {
  margin-top: 2.75rem;
}

.section-first {
  margin-top: 0;
}

.section-head {
  margin-bottom: 1rem;
}

.section-head h2 {
  margin: 0;
  font-size: 1.35rem;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.section-note {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.section-note a,
.site-link {
  color: var(--accent);
  text-decoration: none;
}

.section-note a:hover,
.site-link:hover {
  color: var(--accent-2);
  text-decoration: underline;
}

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

.metric {
  padding: 1rem 1.05rem 1.1rem;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  background: var(--surface);
  min-height: 15.5rem;
}

.metric.is-loading .chart,
.chart-block.is-loading .chart {
  background: linear-gradient(
    90deg,
    var(--line) 0%,
    var(--surface) 45%,
    var(--line) 100%
  );
  background-size: 200% 100%;
  animation: chart-shimmer 1.2s ease-in-out infinite;
  border-radius: 0.25rem;
}

.metric-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}

.metric h3 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.25;
  color: var(--ink);
}

.metric .site-link {
  display: inline-block;
  margin-top: 0.35rem;
  font-size: 0.78rem;
  font-family: var(--mono);
}

.metric .sub {
  margin: 0.25rem 0 0;
  font-size: 0.75rem;
  color: var(--muted);
}

.metric .error-inline {
  color: var(--fail);
  font-family: var(--mono);
}

.badge {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.55rem;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.badge .dot {
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: currentColor;
}

.badge.online {
  color: var(--ok);
  background: var(--ok-dim);
}

.badge.offline,
.badge.error {
  color: var(--fail);
  background: var(--fail-dim);
}

.metric-kpi {
  display: flex;
  gap: 1.25rem;
  margin-top: 0.85rem;
}

.kpi dt {
  margin: 0;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.kpi dd {
  margin: 0.15rem 0 0;
  font-size: 1.35rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

.metric .chart {
  display: block;
  width: 100%;
  height: 140px;
  margin-top: 0.85rem;
  opacity: 0;
  transition: opacity 0.35s ease;
}

.metric .chart.chart-ready,
.chart-block .chart.chart-ready {
  opacity: 1;
}

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

.chart-block {
  padding: 0.85rem 0.9rem 0.5rem;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  background: var(--surface);
  min-height: 16.5rem;
}

.chart-block h3 {
  margin: 0 0 0.65rem;
  font-size: 0.95rem;
  color: var(--ink);
  font-weight: 700;
  letter-spacing: -0.02em;
}

.chart-block .chart {
  display: block;
  width: 100%;
  height: 180px;
  opacity: 0;
  transition: opacity 0.35s ease;
}

.chart-block .empty {
  margin: 0.5rem 0 0;
  color: var(--muted);
  font-size: 0.85rem;
  min-height: 1.2rem;
}

@keyframes chart-shimmer {
  0% {
    background-position: 100% 0;
  }
  100% {
    background-position: -100% 0;
  }
}

.error {
  margin-top: 1.5rem;
  color: var(--fail);
}

.hidden {
  display: none !important;
}

@media (max-width: 640px) {
  .page {
    padding-top: 1.4rem;
  }

  .header-inner {
    align-items: flex-start;
    padding: 0.85rem 0 0.9rem;
  }

  .header-actions {
    align-items: center;
  }

  .metric-kpi {
    gap: 0.9rem;
  }
}
