:root {
  --bg: #f6f7f9;
  --card: #fff;
  --text: #1a1d21;
  --muted: #5c6570;
  --accent: #2563eb;
  --border: #dde2e8;
  --success: #15803d;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.25rem;
  background: #111827;
  color: #fff;
}
.topbar a {
  color: #cbd5e1;
  text-decoration: none;
  margin-left: 1rem;
}
.topbar a.active, .topbar a:hover { color: #fff; }
.brand { font-weight: 600; }

.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 1.5rem 1rem 3rem;
}

h1 { margin-top: 0; }
.lede { color: var(--muted); }
.muted { color: var(--muted); }
.big { font-size: 2rem; font-weight: 700; margin: 0.25rem 0; }
.sub { margin: 0; color: var(--muted); font-size: 0.9rem; }

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin: 1rem 0 1.5rem;
}
.card, .panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
}
.card.highlight { border-color: var(--accent); }

.panel { margin-bottom: 1rem; }
.panel h2 { margin-top: 0; font-size: 1rem; }

.kv { list-style: none; padding: 0; margin: 0; }
.kv li {
  display: flex;
  justify-content: space-between;
  padding: 0.35rem 0;
  border-bottom: 1px solid var(--border);
}
.kv li:last-child { border-bottom: 0; }

.bit-list { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 0.5rem 1rem; }
.bit-1 { color: var(--success); font-weight: 600; }
.bit-0 { color: var(--muted); }

.form-grid fieldset {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  margin: 0 0 1rem;
  background: var(--card);
}
.form-grid legend { font-weight: 600; padding: 0 0.25rem; }
.form-grid label {
  display: block;
  margin-bottom: 0.75rem;
  font-size: 0.95rem;
}
.form-grid input, .form-grid select, .form-grid textarea {
  display: block;
  width: 100%;
  margin-top: 0.25rem;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font: inherit;
}
.form-grid textarea.mono { font-family: ui-monospace, monospace; font-size: 0.85rem; }
.checkbox { display: flex; align-items: center; gap: 0.5rem; }
.checkbox input { width: auto; margin: 0; }
.hint { font-size: 0.85rem; color: var(--muted); }

.callout {
  padding: 0.85rem 1rem;
  border-radius: 8px;
  border: 1px solid #bfdbfe;
  background: #eff6ff;
  color: #1e3a5f;
  margin-bottom: 1.25rem;
  font-size: 0.95rem;
}
.section-note {
  margin: 0 0 1rem;
  font-size: 0.9rem;
  color: var(--muted);
  line-height: 1.45;
}
.field-note {
  display: block;
  margin-top: 0.35rem;
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.4;
  font-weight: normal;
}
.field-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0 1rem;
}
.field-row-3 {
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}
.panel-inset {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 1rem;
}
.entry-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}
.panel-inset h3 {
  margin: 0 0 0.5rem;
  font-size: 0.95rem;
}
.inset-actions { margin-top: 0; }
.sticky-actions {
  position: sticky;
  bottom: 0;
  background: var(--bg);
  padding: 1rem 0;
  border-top: 1px solid var(--border);
  margin-top: 0.5rem;
}
.link.danger, button.link.danger { color: #dc2626; border: none; background: none; padding: 0; }
.setup-form fieldset legend { font-size: 1.05rem; }

.actions { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center; margin-top: 0.5rem; }
button, .link {
  font: inherit;
  padding: 0.55rem 1rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #fff;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
}
button.primary, button[type="submit"].primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
button.secondary { background: #eef2ff; border-color: #c7d2fe; }
button:disabled { opacity: 0.5; cursor: not-allowed; }

.notice {
  padding: 0.75rem 1rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #fff;
}
.notice.success { border-color: #bbf7d0; background: #f0fdf4; color: var(--success); }
.notice.error { border-color: #fecaca; background: #fef2f2; color: #b91c1c; }

.data-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.data-table th, .data-table td {
  padding: 0.6rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.data-table th { background: #f1f5f9; font-size: 0.85rem; }

pre.json {
  background: #0f172a;
  color: #e2e8f0;
  padding: 1rem;
  border-radius: 8px;
  overflow: auto;
  font-size: 0.8rem;
}

.inline-form { margin-top: 1rem; }

code {
  background: #eef2ff;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  font-size: 0.9em;
}
