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

html { height: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
  font-family: var(--font-serif);
  font-weight: 600;
  line-height: 1.25;
  margin: 0 0 0.5em;
  letter-spacing: 0.005em;
}
h1 { font-size: 1.35rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.15rem; }
h4 { font-size: 0.98rem; }

p { margin: 0 0 0.9em; }
a { color: var(--link); text-decoration-thickness: 1px; text-underline-offset: 2px; }
small { font-size: 0.82rem; color: var(--ink-soft); }
code { font-family: var(--font-mono); font-size: 0.85em; background: var(--bg-inset); padding: 0.05em 0.35em; border-radius: 4px; }
hr { border: 0; border-top: 1px solid var(--line-soft); margin: 1.5rem 0; }

button, select, input {
  font: inherit;
  color: inherit;
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: 2px;
}

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.skip-link {
  position: absolute;
  left: 0.5rem; top: -3rem;
  z-index: 100;
  background: var(--bg-panel);
  color: var(--ink);
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: top 0.15s;
}
.skip-link:focus { top: 0.5rem; }

table { border-collapse: collapse; width: 100%; font-size: 0.88rem; }
th, td { text-align: left; padding: 0.4rem 0.6rem; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
th { font-weight: 600; color: var(--ink-soft); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* Sortable headers */
th[data-sort-key] { cursor: pointer; user-select: none; }
th[data-sort-key]:hover { color: var(--ink); }
th[data-sort-key][aria-sort]::after { content: " ▲"; font-size: 0.7em; }
th[data-sort-key][aria-sort="descending"]::after { content: " ▼"; }

/* Selectable data-table rows */
tr[data-gid] { cursor: pointer; transition: background 0.08s; }
tr[data-gid]:hover { background: var(--bg-hover); }
tr[data-gid]:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
tr.is-selected, tr.is-selected:hover {
  background: color-mix(in srgb, var(--select) 18%, transparent);
}
@media (prefers-reduced-motion: reduce) {
  tr[data-gid] { transition: none; }
}

dialog {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--bg-panel);
  color: var(--ink);
  box-shadow: var(--shadow);
  padding: 0;
  max-width: min(860px, 92vw);
  width: 100%;
  max-height: 88vh;
}
dialog::backdrop { background: rgba(20, 22, 26, 0.55); }
