@font-face {
  font-family: "IBM Plex Mono";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/fonts/plex-mono-400.woff2") format("woff2");
}
@font-face {
  font-family: "IBM Plex Mono";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("/fonts/plex-mono-500.woff2") format("woff2");
}
@font-face {
  font-family: "IBM Plex Mono";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("/fonts/plex-mono-700.woff2") format("woff2");
}

:root {
  --background: #090909;
  --surface: #121212;
  --surface-strong: #191919;
  --line: #2b2b2b;
  --text: #f5f5f5;
  --muted: #a1a1aa;
  --accent: #7aa2ff;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--background); }
body {
  min-height: 100%;
  margin: 0;
  background: var(--background);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.5;
}
button, input { font: inherit; }
button { cursor: pointer; }
a { color: inherit; }

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 20px;
  min-height: 64px;
  padding: 10px max(20px, calc((100vw - 1180px) / 2));
  border-bottom: 1px solid var(--line);
  background: rgba(9, 9, 9, 0.96);
}
.brand, .logout, .back, .range button {
  border: 0;
  background: transparent;
  color: var(--muted);
}
.brand {
  padding: 8px 0;
  color: var(--text);
  font-size: 18px;
  font-weight: 700;
}
.live-count {
  margin: 0 auto 0 0;
  color: var(--muted);
  font-size: 13px;
}
.live-count span {
  color: var(--text);
  font-family: "IBM Plex Mono", monospace;
  font-weight: 600;
}
.range { display: flex; gap: 2px; }
.range button, .logout, .back {
  min-height: 40px;
  padding: 8px 11px;
  border-radius: 7px;
  font-size: 13px;
}
.range button:hover, .logout:hover, .back:hover { background: var(--surface-strong); color: var(--text); }
.range button.on { background: var(--text); color: var(--background); }
button:focus-visible, a:focus-visible, input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.app-main {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  padding: 48px 0 80px;
}
.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 24px;
}
.page-head h1 {
  margin: 0;
  font-size: clamp(30px, 4vw, 48px);
  line-height: 1.05;
  letter-spacing: -0.035em;
}
.page-head p { margin: 8px 0 0; color: var(--muted); }
.detail-head { align-items: flex-start; flex-direction: column; }
.back { padding-left: 0; }

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: var(--surface);
}
.metric {
  min-width: 0;
  padding: 22px;
}
.metric + .metric { border-left: 1px solid var(--line); }
.metric strong {
  display: block;
  overflow: hidden;
  color: var(--text);
  font-family: "IBM Plex Mono", monospace;
  font-size: clamp(28px, 4.5vw, 54px);
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  letter-spacing: -0.055em;
  line-height: 1;
  text-overflow: ellipsis;
}
.metric span { display: block; margin-top: 10px; color: var(--muted); font-size: 13px; }

.groups { display: flex; flex-direction: column; gap: 38px; margin-top: 48px; }
.group h2, .data-section h2 {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}
.table-wrap, .data-section {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}
table { width: 100%; border-collapse: collapse; }
th, td { padding: 15px 18px; border-bottom: 1px solid var(--line); text-align: right; }
tr:last-child td { border-bottom: 0; }
th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}
th:first-child, td:first-child { text-align: left; }
.site-table td:not(:first-child), .rank-table td:last-child {
  font-family: "IBM Plex Mono", monospace;
  font-variant-numeric: tabular-nums;
  font-weight: 500;
}
.site-cell a { display: inline-flex; flex-direction: column; text-decoration: none; }
.site-cell strong { font-size: 15px; }
.site-cell span, .rank-table span { margin-top: 2px; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.site-cell a:hover strong { color: var(--accent); }

.data-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 24px;
  margin-top: 48px;
}
.data-section { min-width: 0; }
.data-section h2 { margin: 0; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.rank-table td { padding: 12px 18px; vertical-align: top; }
.rank-table td:first-child { max-width: 0; overflow-wrap: anywhere; }
.rank-table td:first-child strong, .rank-table td:first-child span { display: block; }
.rank-table td:last-child { width: 1%; white-space: nowrap; }
.empty { margin: 0; padding: 24px 18px; color: var(--muted); }
.notice { padding: 48px 0; }
.notice h1 { margin: 0; font-size: 28px; }
.notice p { color: var(--muted); }

.login-body {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}
.login-panel { width: min(390px, 100%); }
.login-panel h1 { margin: 0; font-size: 36px; letter-spacing: -0.04em; }
.login-panel > p { margin: 4px 0 26px; color: var(--muted); }
.login-form { display: flex; flex-direction: column; gap: 10px; }
.login-form input {
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-size: 16px;
}
.login-form button {
  min-height: 48px;
  margin-top: 4px;
  border: 0;
  border-radius: 8px;
  background: var(--text);
  color: var(--background);
  font-weight: 700;
}
.login-form button:hover { background: #dedede; }
.login-error { margin: 14px 0 0; color: #ff8d8d; }

@media (max-width: 760px) {
  .app-header { gap: 10px; padding: 10px 16px; flex-wrap: wrap; }
  .brand { margin-right: auto; }
  .live-count { margin: 0; }
  .range { order: 3; width: calc(100% - 90px); }
  .range button { flex: 1; padding-inline: 6px; }
  .app-header form { order: 4; }
  .app-main { width: min(100% - 28px, 1180px); padding-top: 32px; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric:nth-child(3) { border-left: 0; border-top: 1px solid var(--line); }
  .metric:nth-child(4) { border-top: 1px solid var(--line); }
  .metric { padding: 18px; }
  .groups { gap: 30px; margin-top: 36px; }
  .site-table thead { display: none; }
  .site-table tr { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); padding: 16px; border-bottom: 1px solid var(--line); }
  .site-table tr:last-child { border-bottom: 0; }
  .site-table td { padding: 0; border: 0; text-align: left; }
  .site-table .site-cell { grid-column: 1 / -1; margin-bottom: 15px; }
  .site-table td[data-label]::before { display: block; margin-bottom: 3px; color: var(--muted); content: attr(data-label); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; font-size: 11px; font-weight: 400; }
  .data-grid { grid-template-columns: 1fr; gap: 18px; margin-top: 36px; }
}

@media (max-width: 420px) {
  .app-main { width: calc(100% - 24px); }
  .metric strong { font-size: 31px; }
  .metric { padding: 16px; }
  th, td { padding-inline: 14px; }
  .logout { padding-inline: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; }
}
