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

body {
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 0.8rem;
  background: #f5f5f5;

  --header-bg: #1a1a2e;
  --header-fg: #fff;
  --border: #e0e0e0;
  --cell-bg: #fff;
  --cell-bg-alt: #fafafa;
  --cell-bg-hover: #eef3ff;
  --fg: #000;
  --fg-muted: #555;
  --fg-dim: #888;
}

.table-wrap {
  width: 100vw;
  height: 100dvh;
  overflow: auto;
}

table {
  border-collapse: separate;
  border-spacing: 0;
  white-space: nowrap;
}

th, td {
  padding: 0.35rem 0.5rem;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  text-align: right;
  vertical-align: top;
}

thead th {
  position: sticky;
  top: 0;
  background: var(--header-bg);
  color: var(--header-fg);
  font-weight: 600;
  z-index: 2;
  text-align: center;
}

th.row-head {
  position: sticky;
  left: 0;
  background: var(--header-bg);
  color: var(--header-fg);
  font-weight: 600;
  z-index: 2;
  text-align: center;
}

thead th.row-head {
  z-index: 3;
}

td {
  background: var(--cell-bg);
  color: var(--fg);
}

tr:nth-child(even) td { background: var(--cell-bg-alt); }
tr:hover td { background: var(--cell-bg-hover); }

td .laps  { font-weight: 600; }
td .km    { color: var(--fg-muted); font-size: 0.7rem; }
td .dplus { color: var(--fg-dim); font-size: 0.7rem; }
th .time  { font-weight: 400; font-size: 0.7rem; opacity: 0.7; }

.corner-link {
  color: inherit;
  text-decoration: none;
  opacity: 0.4;
  font-size: 0.9rem;
}
.corner-link:hover { opacity: 0.8; }

@media (prefers-color-scheme: dark) {
  body {
    background: #121212;
    --header-bg: #1a1a2e;
    --header-fg: #f0f0f0;
    --border: #444;
    --cell-bg: #1e1e1e;
    --cell-bg-alt: #252525;
    --cell-bg-hover: #2a2a3a;
    --fg: #f0f0f0;
    --fg-muted: #ccc;
    --fg-dim: #999;
  }
}
