:root {
  --bg: #f4f5fb;
  --card: #ffffff;
  --text: #22243a;
  --muted: #6b6f8e;
  --line: #e3e5f0;
  --teal: #2ec4b6;
  --violet: #7c5cff;
  --red: #e5484d;
  --green: #2fa36b;
  --navy: #181a30;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111223;
    --card: #1c1e36;
    --text: #eceefb;
    --muted: #9da1c4;
    --line: #2c2f4f;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
}

.top {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: var(--navy);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 2;
}
.logo { width: 40px; height: 40px; }
.brand { font-weight: 700; font-size: 20px; }
.home { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; }
.family { color: #b9bde0; font-size: 14px; flex: 1; text-align: right; }
.live { color: var(--muted); font-size: 12px; }
.live.on { color: var(--green); }

.shell { max-width: 760px; margin: 0 auto; }
main { padding: 16px; display: grid; gap: 16px; min-width: 0; }
body.with-nav .shell { max-width: 1180px; display: grid; grid-template-columns: 230px minmax(0, 1fr); }

/* Menu: a column on wide screens, a drawer behind ☰ on phones. */
.nav { position: sticky; top: 60px; align-self: start; display: grid; gap: 14px; padding: 16px 0 16px 16px; max-height: calc(100vh - 60px); overflow-y: auto; }
.nav-group { display: grid; gap: 2px; }
.nav-title { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 10px 4px; }
.nav-item { display: flex; justify-content: space-between; align-items: center; padding: 8px 10px; border-radius: 10px; color: var(--text); text-decoration: none; font-size: 15px; }
.nav-item:hover { background: var(--line); }
.nav-item.active { background: var(--violet); color: #fff; }
.badge { background: var(--red); color: #fff; border-radius: 999px; font-size: 12px; padding: 0 7px; }
.menu { display: none; background: none; color: #fff; font-size: 22px; padding: 4px 8px; }
.child-pick { width: auto; max-width: 180px; background: #2a2d4d; color: #fff; border-color: #3a3e66; padding: 6px 10px; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
.cards .wide { grid-column: 1 / -1; }
.big { font-size: 28px; font-weight: 700; }
h2[id] { scroll-margin-top: 72px; } /* below the sticky header */
.bar.thin { height: 6px; margin: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 4px 4px 4px 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--bg); }
.chip .link { text-decoration: none; padding: 2px 8px; }
.chip.allowed { border-color: var(--green); }
.message { display: grid; gap: 2px; border-top: 1px solid var(--line); padding-top: 8px; font-size: 15px; }
.message .reply { padding-left: 12px; font-size: 14px; }
.card a { color: var(--violet); }

@media (max-width: 900px) {
  body.with-nav .shell { display: block; max-width: 760px; }
  .menu:not(.hidden) { display: inline-block; }
  /* align-self: stretch, or the desktop "start" makes the fixed drawer as tall as its items and cuts them off. */
  .nav { position: fixed; top: 60px; left: 0; bottom: 0; align-self: stretch; overscroll-behavior: contain; width: 270px; max-height: none; background: var(--card); border-right: 1px solid var(--line); padding: 16px; z-index: 5; transform: translateX(-105%); transition: transform .2s; }
  body.nav-open .nav { transform: none; box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .35); }
}
@media (max-width: 600px) {
  .brand { display: none; }
  .family { visibility: hidden; }
  .cards { grid-template-columns: 1fr; }
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
}
.verify { max-width: 1180px; margin: 12px auto 0; padding: 10px 16px; display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; background: var(--card); border: 1px solid var(--violet); border-radius: 12px; font-size: 15px; }
@media (max-width: 1212px) { .verify { margin: 12px 16px 0; } }
.card.narrow { max-width: 420px; margin: 24px auto; width: 100%; }
.card.alert { border-color: var(--violet); }
.card h2 { margin: 0 0 8px; font-size: 18px; }
h1 { margin: 0 0 4px; font-size: 22px; }

.stack { display: grid; gap: 12px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }
.muted { color: var(--muted); }
.center { text-align: center; }
.small { font-size: 14px; }
.hidden { display: none !important; }
.error { color: var(--red); min-height: 1.2em; margin: 8px 0 0; }

label { display: grid; gap: 4px; font-size: 14px; color: var(--muted); }
input, select, textarea {
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  width: 100%;
}
input[type=checkbox] { width: auto; }
.check { display: flex; gap: 8px; align-items: center; color: var(--text); font-size: 16px; }

button {
  font: inherit;
  border: 0;
  border-radius: 10px;
  padding: 10px 14px;
  cursor: pointer;
  background: var(--line);
  color: var(--text);
}
button.primary { background: var(--violet); color: #fff; }
button.ok { background: var(--green); color: #fff; }
button.danger { background: var(--red); color: #fff; }
button.link { background: none; color: inherit; text-decoration: underline; padding: 4px; }
button:disabled { opacity: .5; cursor: default; }

.tabs { display: flex; gap: 6px; margin: 14px 0; }
.tab { flex: 1; }
.tab.active { background: var(--violet); color: #fff; }

.bar { height: 12px; border-radius: 6px; background: var(--line); overflow: hidden; margin: 8px 0; }
.bar > span { display: block; height: 100%; background: var(--teal); }
.bar.over > span { background: var(--red); }

.apps { list-style: none; padding: 0; margin: 8px 0; display: grid; gap: 4px; font-size: 14px; }
.apps li { display: flex; justify-content: space-between; }

.device { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-top: 1px solid var(--line); flex-wrap: wrap; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); }
.dot.on { background: var(--green); }
.device .name { flex: 1; min-width: 140px; }

.request { display: grid; gap: 8px; padding: 10px 0; border-top: 1px solid var(--line); }
.request:first-of-type { border-top: 0; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
@media (max-width: 600px) { .grid4 { grid-template-columns: 1fr 1fr; } }
.month { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.month .day { border: 1px solid var(--line); border-radius: 10px; padding: 4px 6px; min-height: 52px; cursor: pointer; display: grid; align-content: space-between; }
.month .day.future { cursor: default; opacity: .5; }
.month .day.over { border: 2px solid var(--red); }
.month .day.today { outline: 2px solid var(--violet); }
@media (max-width: 480px) { .grid2 { grid-template-columns: 1fr; } }

.toast {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  background: var(--navy);
  color: #fff;
  padding: 10px 16px;
  border-radius: 10px;
  max-width: calc(100% - 32px);
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 10;
}
.overlay .card { max-width: 440px; width: 100%; }
