:root {
  --bg: #f6f5f1;
  --card: #ffffff;
  --ink: #1c1917;
  --muted: #78716c;
  --line: #e7e5e4;
  --soft: #f5f5f4;
  --primary: #0f766e;
  --primary-ink: #ffffff;
  --primary-soft: #ccfbf1;
  --green: #15803d;
  --green-soft: #dcfce7;
  --red: #b91c1c;
  --red-soft: #fee2e2;
  --amber: #b45309;
  --amber-soft: #fef3c7;
  --indigo: #4338ca;
  --indigo-soft: #e0e7ff;
  --radius: 18px;
  --shadow: 0 1px 2px rgb(0 0 0 / 5%), 0 4px 16px rgb(0 0 0 / 5%);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12110f;
    --card: #1c1a17;
    --ink: #f5f5f4;
    --muted: #a8a29e;
    --line: #2e2b27;
    --soft: #26231f;
    --primary: #2dd4bf;
    --primary-ink: #042f2e;
    --primary-soft: #134e4a;
    --green: #4ade80;
    --green-soft: #14532d;
    --red: #f87171;
    --red-soft: #4c1414;
    --amber: #fbbf24;
    --amber-soft: #422006;
    --indigo: #a5b4fc;
    --indigo-soft: #28245a;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
p { margin: 0; }
.boot { padding: 40px; text-align: center; color: var(--muted); }

/* Layout */
.shell { max-width: 760px; margin: 0 auto; padding: 16px 16px 110px; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 8px 0 18px; }
.topbar .logo { width: 38px; height: 38px; border-radius: 10px; }
.topbar h1 { font-size: 20px; }
.topbar .sub { color: var(--muted); font-size: 13px; }
.topbar .grow { flex: 1; min-width: 0; }

.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; justify-content: center;
  background: color-mix(in srgb, var(--card) 92%, transparent);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
}
.nav-inner { display: flex; width: 100%; max-width: 560px; }
.nav button {
  flex: 1; border: 0; background: none; padding: 6px 2px; border-radius: 12px;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: 12px; color: var(--muted);
}
.nav button .ico { font-size: 21px; line-height: 1; }
.nav button[aria-current="page"] { color: var(--primary); font-weight: 600; background: var(--primary-soft); }

@media (min-width: 900px) {
  .nav { top: 0; bottom: auto; border-top: 0; border-bottom: 1px solid var(--line); padding: 8px; }
  .nav button { flex-direction: row; gap: 8px; font-size: 14px; padding: 8px 12px; }
  .nav button .ico { font-size: 18px; }
  .shell { padding-top: 76px; padding-bottom: 40px; }
}

.section-title { display: flex; align-items: end; justify-content: space-between; gap: 12px; margin: 26px 2px 10px; }
.section-title h2 { font-size: 18px; }
.lead { color: var(--muted); font-size: 14px; margin: -4px 2px 14px; }

/* Cards */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--line); padding: 16px; }
.stack { display: grid; gap: 12px; }
.row { display: flex; align-items: center; gap: 12px; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 13px; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.avatar {
  width: 48px; height: 48px; border-radius: 50%; flex: none;
  display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 20px;
}
.kid-name { font-size: 19px; font-weight: 650; }

.status { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 600; padding: 3px 10px; border-radius: 999px; margin-top: 3px; }
.status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.status.online { background: var(--green-soft); color: var(--green); }
.status.blocked { background: var(--indigo-soft); color: var(--indigo); }
.status.paused { background: var(--red-soft); color: var(--red); }
.status.extra { background: var(--amber-soft); color: var(--amber); }
.status-detail { font-size: 14px; color: var(--muted); margin-top: 10px; }

.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.actions.one { grid-template-columns: 1fr; }

/* Buttons */
.btn {
  border: 1px solid var(--line); background: var(--card); border-radius: 14px;
  padding: 12px 14px; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; transition: transform .06s ease, background .15s;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn.danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn.danger-soft { background: var(--red-soft); border-color: transparent; color: var(--red); }
.btn.amber-soft { background: var(--amber-soft); border-color: transparent; color: var(--amber); }
.btn.green-soft { background: var(--green-soft); border-color: transparent; color: var(--green); }
.btn.ghost { background: none; border-color: transparent; color: var(--primary); min-height: 40px; padding: 8px 10px; }
.btn.small { min-height: 36px; padding: 6px 12px; font-size: 14px; border-radius: 11px; }
.btn.block { width: 100%; }
.icon-btn { border: 0; background: none; width: 40px; height: 40px; border-radius: 50%; font-size: 20px; color: var(--muted); }
.icon-btn:hover { background: var(--soft); }

.add-card { border: 2px dashed var(--line); background: none; border-radius: var(--radius); padding: 18px; color: var(--primary); font-weight: 600; width: 100%; }

/* Banners */
.banner { border-radius: 14px; padding: 12px 14px; font-size: 14px; display: flex; gap: 10px; align-items: flex-start; }
.banner.error { background: var(--red-soft); color: var(--red); }
.banner.warn { background: var(--amber-soft); color: var(--amber); }
.banner.info { background: var(--primary-soft); color: var(--ink); }
.banner b { display: block; }

.router-chip { display: inline-flex; gap: 6px; align-items: center; font-size: 13px; color: var(--muted); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); display: inline-block; }
.dot.bad { background: var(--red); }

/* Chips and toggles */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1.5px solid var(--line); background: var(--card); border-radius: 999px; padding: 7px 13px;
  font-size: 14px; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; min-height: 38px;
}
.chip[aria-pressed="true"] { background: var(--red-soft); border-color: var(--red); color: var(--red); }
.chip:not(.pick)[aria-pressed="true"]::before { content: "🚫"; font-size: 12px; }
.chip.pick[aria-pressed="true"] { background: var(--primary-soft); border-color: var(--primary); color: var(--ink); }
.chip:disabled { opacity: .6; }
.chip .swatch { width: 10px; height: 10px; border-radius: 50%; }

.switch { position: relative; width: 52px; height: 30px; flex: none; }
.switch input { opacity: 0; width: 100%; height: 100%; margin: 0; position: absolute; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; background: var(--line); border-radius: 999px; transition: background .15s; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; background: #fff; border-radius: 50%; box-shadow: 0 1px 3px rgb(0 0 0 / 25%); transition: transform .15s; }
.switch input:checked + span { background: var(--primary); }
.switch input:checked + span::after { transform: translateX(22px); }
.switch input:focus-visible + span { outline: 3px solid var(--primary-soft); }

.list > * + * { border-top: 1px solid var(--line); }
.list-item { padding: 12px 0; }
.list-item:first-child { padding-top: 0; }
.list-item:last-child { padding-bottom: 0; }

.app-icon { width: 42px; height: 42px; border-radius: 12px; background: var(--soft); display: grid; place-items: center; font-size: 22px; flex: none; }
.app-name { font-weight: 650; }
.who { margin-top: 10px; }
.tag { font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--soft); color: var(--muted); }
.tag.on { background: var(--red-soft); color: var(--red); }

.sched-time { font-size: 22px; font-weight: 700; letter-spacing: -.3px; }
.kid-pills { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.kid-pill { font-size: 13px; padding: 2px 10px; border-radius: 999px; background: var(--soft); display: inline-flex; gap: 6px; align-items: center; }
.kid-pill .swatch { width: 8px; height: 8px; border-radius: 50%; }

/* Forms */
label.field { display: grid; gap: 6px; font-weight: 600; font-size: 14px; }
.input {
  width: 100%; border: 1.5px solid var(--line); background: var(--card); border-radius: 12px;
  padding: 11px 12px; min-height: 46px; font-weight: 400; font-size: 16px;
}
.input:focus { outline: none; border-color: var(--primary); }
textarea.input { min-height: 90px; resize: vertical; }
.hint { font-size: 13px; color: var(--muted); font-weight: 400; }
.times { display: grid; grid-template-columns: 1fr auto 1fr; gap: 10px; align-items: end; }
.times .arrow { padding-bottom: 12px; color: var(--muted); }
.search { margin-bottom: 12px; }

/* Sheet (dialog) */
.sheet-backdrop { position: fixed; inset: 0; background: rgb(0 0 0 / 45%); z-index: 50; display: flex; align-items: flex-end; justify-content: center; animation: fade .15s; }
.sheet {
  background: var(--card); width: 100%; max-width: 540px; max-height: 92vh; overflow: auto;
  border-radius: 22px 22px 0 0; padding: 10px 18px calc(20px + env(safe-area-inset-bottom));
  animation: up .2s ease-out;
}
.sheet .grab { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 12px; }
.sheet h3 { font-size: 20px; margin-bottom: 4px; }
.sheet .sheet-body { display: grid; gap: 16px; margin-top: 14px; }
.sheet .options { display: grid; gap: 10px; }
.sheet .options .btn { justify-content: flex-start; font-size: 17px; }
@media (min-width: 640px) {
  .sheet-backdrop { align-items: center; }
  .sheet { border-radius: 22px; padding-bottom: 22px; }
  .sheet .grab { display: none; }
}
@keyframes up { from { transform: translateY(40px); opacity: .6; } }
@keyframes fade { from { opacity: 0; } }

#toast {
  position: fixed; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--ink); color: var(--bg); padding: 11px 16px; border-radius: 12px; z-index: 60;
  font-size: 15px; max-width: calc(100vw - 32px); box-shadow: 0 6px 24px rgb(0 0 0 / 25%);
}
#toast.error { background: var(--red); color: #fff; }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login .card { width: 100%; max-width: 380px; padding: 26px; display: grid; gap: 16px; }
.login h1 { font-size: 24px; }
.login .logo { width: 56px; height: 56px; border-radius: 14px; }

.steps { counter-reset: step; display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.steps li { counter-increment: step; display: flex; gap: 12px; align-items: center; }
.steps li::before { content: counter(step); width: 28px; height: 28px; border-radius: 50%; background: var(--primary-soft); color: var(--ink); display: grid; place-items: center; font-weight: 700; flex: none; font-size: 14px; }

.demo-flag { background: var(--amber-soft); color: var(--amber); font-size: 12px; font-weight: 700; padding: 3px 8px; border-radius: 999px; }
details.domains summary { cursor: pointer; font-size: 13px; color: var(--muted); }
details.domains p { margin-top: 6px; }

a.btn { text-decoration: none; color: inherit; }

.spinner { width: 18px; height: 18px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--primary); animation: spin 0.9s linear infinite; flex: none; margin-top: 2px; }
@keyframes spin { to { transform: rotate(360deg); } }
.mode-opt { align-items: flex-start; border: 1.5px solid var(--line); border-radius: 12px; padding: 10px 12px; cursor: pointer; }
.mode-opt:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }
.mode-opt input { margin-top: 4px; }

a { color: var(--primary); }

/* Data usage */
.usage-card { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; margin-top: 14px; }
.hero { font-size: 24px; font-weight: 750; letter-spacing: -.4px; white-space: nowrap; }
.chart { position: relative; height: 150px; margin-top: 10px; border-bottom: 1px solid var(--line); padding-top: 18px; }
.chart-max { position: absolute; top: 0; left: 0; }
.chart::before { content: ""; position: absolute; left: 0; right: 0; top: 18px; border-top: 1px dashed var(--line); }
.bars { display: flex; align-items: flex-end; gap: 2px; height: 100%; }
.bar-slot { flex: 1; height: 100%; display: flex; align-items: flex-end; cursor: pointer; }
.bar { width: 100%; background: var(--primary); border-radius: 4px 4px 0 0; opacity: .85; }
.bar-slot:hover .bar, .bar-slot.active .bar { opacity: 1; box-shadow: 0 0 0 2px var(--card), 0 0 0 3px var(--primary); }
.kid-usage { display: grid; grid-template-columns: minmax(90px, auto) 1fr auto; gap: 10px; align-items: center; }
.hbar { height: 10px; background: var(--soft); border-radius: 5px; overflow: hidden; }
.hbar > div { height: 100%; background: var(--primary); border-radius: 5px; }
.data-table { width: 100%; border-collapse: collapse; font-size: 14px; margin-top: 8px; }
.data-table th, .data-table td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.data-table th { color: var(--muted); font-weight: 600; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: end; }
@media (max-width: 420px) { .grid-2 { grid-template-columns: 1fr; } }

details.group summary { cursor: pointer; font-size: 14px; color: var(--primary); font-weight: 600; margin-top: 12px; }
details.group[open] summary { margin-bottom: 4px; }
