:root {
  color-scheme: light dark;
  --bg: #fafafa;
  --bg-card: #fff;
  --text: #1a1a1a;
  --text-muted: #71717a;
  --border: #e4e4e7;
  --accent: #0284c7;
  --accent-soft: rgba(2, 132, 199, 0.08);
  --green: #16a34a;
  --amber: #f59e0b;
  --red: #dc2626;
  --shadow: 0 2px 12px rgba(0,0,0,.06);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0a0e27;
    --bg-card: #131938;
    --text: #e6edff;
    --text-muted: #8a94b8;
    --border: rgba(255,255,255,0.08);
    --accent: #38bdf8;
    --accent-soft: rgba(56, 189, 248, 0.12);
  }
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
}

.topbar {
  display: flex; align-items: center; gap: 1rem;
  padding: 1rem 1.5rem;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.topbar h1 { margin: 0; font-size: 1.1rem; font-weight: 600; }
.topbar .sub { font-size: 0.75rem; color: var(--text-muted); }
.tabs { display: flex; gap: .25rem; margin-left: auto; }
.tab {
  background: transparent; border: 1px solid var(--border);
  padding: .5rem 1rem; border-radius: 8px;
  font: inherit; cursor: pointer; color: var(--text);
}
.tab:hover { background: var(--accent-soft); }
.tab-active { background: var(--accent); color: white; border-color: var(--accent); }
.actions { display: flex; gap: .5rem; }
.btn {
  font: inherit; cursor: pointer;
  background: var(--bg-card); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px;
  padding: .5rem 1rem;
}
.btn:hover { background: var(--accent-soft); }
.btn-primary { background: var(--accent); color: white; border-color: var(--accent); }
.btn-danger { background: var(--red); color: white; border-color: var(--red); }

main {
  max-width: 1100px; margin: 0 auto; padding: 1.5rem;
}

.loading, .empty {
  padding: 4rem 1rem; text-align: center; color: var(--text-muted);
}

.section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem 1.5rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
}
.section h2 { margin: 0 0 .5rem; font-size: .85rem; text-transform: uppercase; color: var(--text-muted); letter-spacing: .1em; }
.section .body { margin-top: .5rem; }

.row { display: flex; gap: 2rem; flex-wrap: wrap; }
.row .col { flex: 1; min-width: 280px; }

.kid-name {
  font-weight: 600; font-size: 1.05rem; color: var(--accent); margin-bottom: .25rem;
}

.stat-line { font-size: 1rem; margin: .25rem 0; }
.stat-line .num { font-weight: 700; font-feature-settings: "tnum" 1; }

.list { margin: 0; padding: 0; list-style: none; }
.list li {
  padding: .5rem 0;
  border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: baseline;
  gap: 1rem;
}
.list li:last-child { border-bottom: none; }
.muted { color: var(--text-muted); font-size: .9rem; }

.cost-good { color: var(--green); font-weight: 700; }
.cost-warn { color: var(--amber); font-weight: 700; }
.cost-bad { color: var(--red); font-weight: 700; }

details summary {
  cursor: pointer; padding: .5rem 0;
  font-weight: 600;
}
details[open] summary { margin-bottom: .5rem; }

table {
  width: 100%; border-collapse: collapse;
  font-size: .85rem;
}
th, td {
  text-align: left; padding: .5rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
th { font-weight: 600; color: var(--text-muted); font-size: .75rem; text-transform: uppercase; letter-spacing: .1em; }
.audit-input, .audit-output {
  font-family: ui-monospace, "Menlo", monospace; font-size: .8rem;
  max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.audit-flag { background: var(--red); color: white; padding: .1rem .4rem; border-radius: 4px; font-size: .7rem; }
.audit-ok { color: var(--green); }

.filter-bar {
  display: flex; gap: .5rem; flex-wrap: wrap;
  margin-bottom: .75rem; align-items: center;
}
.filter-bar input, .filter-bar select {
  padding: .4rem .6rem;
  border: 1px solid var(--border);
  background: var(--bg-card); color: var(--text);
  border-radius: 6px;
  font: inherit;
}

.chip {
  display: inline-block;
  padding: .25rem .6rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: .85rem;
  margin: .15rem;
}

.modal-root {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.4);
  display: grid; place-items: center;
  z-index: 50; padding: 1rem;
}
.modal {
  background: var(--bg-card); color: var(--text);
  padding: 1.5rem; border-radius: 12px;
  max-width: 520px; width: 100%;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
  max-height: 80vh; overflow: auto;
}
.modal h2 { margin: 0 0 1rem; }
.field {
  display: flex; flex-direction: column;
  gap: .25rem; margin-bottom: 1rem;
}
.field label { font-size: .85rem; color: var(--text-muted); }
.field input, .field select {
  padding: .5rem .75rem;
  border: 1px solid var(--border);
  background: var(--bg); color: var(--text);
  border-radius: 6px;
  font: inherit;
}
pre.digest-preview {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  font-family: ui-monospace, "Menlo", monospace;
  font-size: .8rem;
  white-space: pre-wrap;
}
