:root {
  --bg: #e8ebe6;
  --bg-deep: #d5dbd4;
  --surface: #f7f8f5;
  --ink: #121412;
  --muted: #5c655c;
  --line: #b7c0b4;
  --accent: #c1121f;
  --accent-soft: #f4d6d8;
  --ok: #1b7f4a;
  --ok-soft: #d7efe3;
  --warn: #9a6700;
  --warn-soft: #f5e6c4;
  --fail: #8a1c1c;
  --fail-soft: #f3d4d4;
  --info: #1f4f7a;
  --info-soft: #d7e6f4;
  --shadow: 0 18px 40px rgba(18, 20, 18, 0.08);
  --radius: 14px;
  --font: "IBM Plex Sans", "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(193, 18, 31, 0.08), transparent 28%),
    linear-gradient(160deg, #f2f4ef 0%, var(--bg) 45%, #dfe5dc 100%);
}

.top {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 1rem;
  align-items: end;
  padding: 1.1rem 1.4rem 0.9rem;
  background: rgba(247, 248, 245, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.brand {
  margin: 0;
  font-size: clamp(2rem, 4vw, 3rem);
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 0.95;
}
.tagline {
  margin: 0.25rem 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.tabs {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}
.tabs button,
.refresh,
.chip,
.filters button,
.drawer-head button,
.row-btn {
  font: inherit;
  cursor: pointer;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  border-radius: 999px;
  padding: 0.45rem 0.9rem;
}
.tabs button.is-active,
.filters button.is-active {
  background: var(--ink);
  color: #f7f8f5;
  border-color: var(--ink);
}
.refresh:hover,
.row-btn:hover,
.drawer-head button:hover {
  border-color: var(--ink);
}

main {
  padding: 1.25rem 1.4rem 3rem;
  max-width: 1400px;
}
.view { display: none; }
.view.is-active { display: block; }

.grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}
.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  box-shadow: var(--shadow);
}
.stat .label {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.stat .value {
  margin: 0.35rem 0 0;
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.panel {
  margin-top: 1rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  padding: 0.9rem 1.1rem;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #fcfdfb, #f1f4ef);
}
.panel-head h2 {
  margin: 0;
  font-size: 1.05rem;
}
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  padding: 0.85rem 1.1rem;
  border-bottom: 1px solid var(--line);
}
.filters input {
  flex: 1 1 220px;
  min-width: 180px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.5rem 0.9rem;
  font: inherit;
  background: #fff;
}

.list { display: flex; flex-direction: column; }
.row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.85rem;
  padding: 0.95rem 1.1rem;
  border-bottom: 1px solid var(--line);
  align-items: start;
}
.row:last-child { border-bottom: 0; }
.row:hover { background: #eef2ea; }
.row h3 {
  margin: 0 0 0.35rem;
  font-size: 1.02rem;
  line-height: 1.3;
}
.meta {
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
  font-family: var(--mono);
}
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.55rem;
}
.chip {
  padding: 0.2rem 0.55rem;
  font-size: 0.78rem;
  border-radius: 999px;
  pointer-events: none;
}
.chip-ok { background: var(--ok-soft); border-color: #9dceb4; color: var(--ok); }
.chip-fail { background: var(--fail-soft); border-color: #e0a7a7; color: var(--fail); }
.chip-warn { background: var(--warn-soft); border-color: #e0c984; color: var(--warn); }
.chip-info { background: var(--info-soft); border-color: #9db8d2; color: var(--info); }
.chip-muted { background: var(--bg-deep); color: var(--muted); }

.excerpt {
  margin: 0.45rem 0 0;
  color: #2c332c;
  white-space: pre-wrap;
  line-height: 1.45;
}
.empty {
  padding: 2rem 1.1rem;
  color: var(--muted);
  text-align: center;
}
.error {
  margin: 1rem 0;
  padding: 0.9rem 1rem;
  border-radius: 10px;
  background: var(--fail-soft);
  color: var(--fail);
  border: 1px solid #e0a7a7;
}

.race-box {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  margin-top: 1rem;
}
.race-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  box-shadow: var(--shadow);
}
.race-card h3 { margin: 0 0 0.4rem; }
.race-card p { margin: 0.2rem 0; color: var(--muted); font-family: var(--mono); font-size: 0.88rem; }

.drawer {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(18, 20, 18, 0.35);
  display: flex;
  justify-content: flex-end;
}
.drawer[hidden] { display: none; }
.drawer-panel {
  width: min(640px, 100%);
  height: 100%;
  background: var(--surface);
  border-left: 1px solid var(--line);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
}
.drawer-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.1rem;
  border-bottom: 1px solid var(--line);
}
.drawer-head h2 { margin: 0; font-size: 1.15rem; }
.drawer-body {
  overflow: auto;
  padding: 1.1rem;
}
.drawer-body h3 {
  margin: 1.1rem 0 0.4rem;
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}
.drawer-body pre {
  margin: 0;
  padding: 0.85rem;
  background: #eef2ea;
  border-radius: 10px;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: var(--mono);
  font-size: 0.84rem;
  line-height: 1.45;
}
.drawer-body a { color: var(--accent); }

@media (max-width: 820px) {
  .top {
    grid-template-columns: 1fr;
    align-items: start;
  }
  .row {
    grid-template-columns: 1fr;
  }
}
