:root {
  --bg: #ffffff;
  --fg: #0b1c2d;
  --muted: #5d6b78;
  --line: #e3e8ed;
  --head: #0b1c2d;
  --head-fg: #ffffff;
  --accent: #6cace4;
  --row-alt: #f5f8fa;
  --add: #1f7a3a;
  --remove: #b42318;
  --update: #8a5a00;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1418;
    --fg: #e8eef3;
    --muted: #93a1ad;
    --line: #25313a;
    --head: #071119;
    --row-alt: #131c22;
    --add: #5cc97c;
    --remove: #ff7b72;
    --update: #e6b450;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

header {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--head);
  color: var(--head-fg);
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
}
h1 { margin: 0 0 8px; font-size: 20px; }
h1 span { color: var(--accent); font-weight: 600; }

.search { display: flex; gap: 8px; }
.search input {
  flex: 1;
  min-width: 0;
  font-size: 16px; /* 16px stops iOS from zooming in on focus */
  padding: 9px 12px;
  border: 0;
  border-radius: 8px;
}
button {
  font: inherit;
  cursor: pointer;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: transparent;
  color: inherit;
  padding: 8px 12px;
}
.search button { border-color: #ffffff55; }

main { padding: 0 0 8px; }
table { width: 100%; border-collapse: collapse; }
th {
  position: sticky;
  top: var(--header-h, 96px);
  background: var(--bg);
  border-bottom: 2px solid var(--line);
  text-align: left;
  padding: 0;
}
th button {
  width: 100%;
  border: 0;
  border-radius: 0;
  padding: 7px 16px;
  text-align: inherit;
  font-weight: 700;
  color: var(--muted);
}
th button[aria-sort] { color: var(--fg); }
th button[aria-sort="ascending"]::after { content: " ▲"; font-size: 11px; }
th button[aria-sort="descending"]::after { content: " ▼"; font-size: 11px; }
td { padding: 6px 16px; line-height: 1.25; border-bottom: 1px solid var(--line); }
tbody tr:nth-child(even) td { background: var(--row-alt); }
.num { width: 64px; text-align: right; font-variant-numeric: tabular-nums; }
td.num { font-weight: 700; font-size: 17px; }
.pos { width: 72px; text-align: center; }
td a { color: inherit; text-decoration: none; }
td a .last { font-weight: 700; }
td a:active { color: var(--accent); }
tr.group td {
  background: var(--bg) !important;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
  padding-top: 10px;
}
#empty { text-align: center; color: var(--muted); padding: 24px; }

footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px calc(16px + env(safe-area-inset-bottom));
  color: var(--muted);
  font-size: 13px;
}
footer button { font-size: 14px; }

dialog {
  width: min(560px, calc(100vw - 32px));
  max-height: calc(100vh - 64px);
  border: 0;
  border-radius: 12px;
  padding: 20px;
  background: var(--bg);
  color: var(--fg);
}
dialog::backdrop { background: #0008; }
dialog h2 { margin: 0 0 12px; font-size: 18px; }
dialog h3 { margin: 16px 0 6px; font-size: 14px; text-transform: uppercase; letter-spacing: .05em; }
dialog ul { margin: 0; padding-left: 18px; }
dialog li { margin: 4px 0; }
.add { color: var(--add); }
.remove { color: var(--remove); }
.update { color: var(--update); }
.change { color: var(--muted); font-size: 14px; }
.actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
.primary { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.error { color: var(--remove); }
