:root {
  --bg: #f3f6fb;
  --card: #ffffff;
  --ink: #1b2433;
  --muted: #5d6b82;
  --line: #e1e7f0;
  --primary: #1d4e9f;
  --primary-ink: #ffffff;
  --danger: #a3261c;
  --ok: #e7f6ee;
  --warn: #fff6df;
  --soft: #eef2f8;
  --radius: 14px;
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; }

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.45;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

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

h1, h2, h3 { line-height: 1.2; margin: 0; }
h1 { font-size: 1.7rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }

p { margin: 0.4rem 0; }

.top, .brand, .row, .who, .split, .alt, .page {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.top {
  justify-content: space-between;
  padding: 0.8rem 1.2rem;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}

.top nav, .side nav { display: flex; gap: 0.4rem; align-items: center; }

.brand { color: var(--ink); font-weight: 700; text-decoration: none; }
.brand b, .brand--center {
  display: inline-grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  border-radius: 10px;
  background: var(--primary);
  color: var(--primary-ink);
}
.brand span { display: flex; flex-direction: column; line-height: 1.15; }
.brand small { font-weight: 500; color: var(--muted); }

.brand--center { margin: 0 auto 0.6rem; }

.shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }

.side {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1rem;
  background: var(--card);
  border-right: 1px solid var(--line);
}

.side nav { flex-direction: column; align-items: stretch; }
.side nav a {
  padding: 0.5rem 0.7rem;
  border-radius: 10px;
  color: var(--ink);
  text-decoration: none;
}
.side nav a.is-on, .side nav a:hover { background: var(--soft); text-decoration: none; }

.who {
  margin-top: auto;
  flex-direction: column;
  align-items: stretch;
  padding: 0.8rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 0.85rem;
}
.who span { color: var(--muted); }

.content, .wrap { padding: 1.3rem; }
.wrap { max-width: 980px; margin: 0 auto; }
.wrap--narrow { max-width: 560px; }
.wrap--read { max-width: 760px; display: grid; gap: 0.8rem; }

.page { justify-content: space-between; align-items: flex-start; margin-bottom: 1rem; }
.page p, .muted { color: var(--muted); }
.center { text-align: center; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
}
.card--link { display: block; color: inherit; text-decoration: none; }
.card--link:hover { border-color: #c5d4ee; text-decoration: none; }
.card--form { max-width: 560px; }
.cards, .stack, .stats, .split-page { display: grid; gap: 0.8rem; }
.stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stats strong, .big { font-size: 1.7rem; }
.split-page { grid-template-columns: 1.2fr 0.8fr; }

label { display: grid; gap: 0.3rem; font-size: 0.92rem; font-weight: 600; }
input, textarea, select {
  width: 100%;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  font-weight: 400;
}
textarea { resize: vertical; }

.btn, .side .who button, .top button {
  border: 0;
  border-radius: 10px;
  padding: 0.55rem 0.9rem;
  background: var(--primary);
  color: var(--primary-ink);
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  justify-content: center;
}
.btn--ghost, .side .who button, .top button {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}
.btn--danger { background: var(--danger); color: white; border: 0; }
a.btn:hover { text-decoration: none; }

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.15rem 0.55rem;
  font-size: 0.75rem;
  font-weight: 650;
  background: var(--soft);
}
.badge--on { background: #e5f0ff; color: var(--primary); }
.badge--off { background: #fde8e6; color: var(--danger); }
.badge--warn { background: var(--warn); color: #8a5a00; }
.badge--soft { background: var(--soft); color: var(--muted); }

.table { width: 100%; border-collapse: collapse; background: var(--card); border-radius: var(--radius); overflow: hidden; }
.table th, .table td { text-align: left; padding: 0.7rem 0.8rem; border-bottom: 1px solid var(--line); vertical-align: top; font-size: 0.92rem; }
.table th { color: var(--muted); font-weight: 600; background: #f8fafc; }

.msg { padding: 0.7rem 0.8rem; border-radius: 10px; margin: 0 0 0.8rem; }
.msg--error { background: #fde8e6; color: var(--danger); }
.msg--ok { background: var(--ok); color: #146c43; }

.pre { white-space: pre-wrap; }
.note { background: var(--soft); border-radius: 10px; padding: 0.7rem 0.8rem; margin-top: 0.6rem; }
.alt { display: grid; grid-template-columns: auto 1fr; gap: 0.5rem; align-items: center; }
.check { display: flex; align-items: center; gap: 0.35rem; font-weight: 700; }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 0.7rem; }
.lines { margin: 0; }
.lines div { display: flex; justify-content: space-between; gap: 1rem; padding: 0.25rem 0; }
.lines .total { font-weight: 700; border-top: 1px solid var(--line); margin-top: 0.3rem; padding-top: 0.5rem; }

.gate { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; }
.gate__card { width: min(460px, 100%); }
.demos { display: grid; gap: 0.45rem; margin: 1rem 0; }
.demo {
  text-align: left;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.7rem 0.8rem;
  cursor: pointer;
}
.demo span { display: block; color: var(--muted); font-size: 0.82rem; }

ul { margin: 0.4rem 0; padding-left: 1.2rem; }

@media (max-width: 860px) {
  .shell, .stats, .split-page { grid-template-columns: 1fr; }
  .side { position: static; }
  .side nav { flex-direction: row; overflow: auto; }
  .who { margin-top: 0; }
  .page { flex-direction: column; }
}
