/* House Control: Josh's admin dashboard (docs/plans/2026-12-02-admin-dashboard.md).
   Dense on purpose; the family app is the simple one. */

:root {
  --paper: #eef2ef;
  --surface: #f8faf8;
  --ink: #163a40;
  --ink-soft: #4f6a6e;
  --line: #cdd8d4;
  --ours: #2f7d57;
  --outside: #c98612;
  --lock: #3d5f8f;
  --app: #8a9a98;
  --bad: #b4483a;
  --warn: #c98612;
  --focus: #1f6fb2;
  --radius-s: 6px;
  --radius-l: 12px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0f2226;
    --surface: #152d32;
    --ink: #e4eeeb;
    --ink-soft: #9fb6b3;
    --line: #2b474c;
    --ours: #5cbf8a;
    --outside: #e8b04f;
    --lock: #8fb0e0;
    --app: #6f8885;
    --bad: #e07a6b;
    --warn: #e8b04f;
    --focus: #8cc4f2;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 15px/1.45 "Atkinson Hyperlegible Next", "Segoe UI", system-ui, sans-serif;
  font-variant-numeric: tabular-nums;
}
h1, h2 { margin: 0; line-height: 1.15; }
h1 { font-size: 1.75rem; font-weight: 800; letter-spacing: -0.01em; }
h2 { font-size: 1.05rem; font-weight: 700; margin-bottom: 0.6rem; }
a { color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 3px; }
.quiet { color: var(--ink-soft); }
.error { color: var(--bad); font-weight: 600; }
[hidden] { display: none !important; }

button { font: inherit; cursor: pointer; }
.primary, .secondary {
  min-height: 44px;
  padding: 0 1.2rem;
  border-radius: var(--radius-s);
  font-weight: 700;
}
.primary { background: var(--ink); color: var(--paper); border: 0; }
.secondary { background: transparent; color: var(--ink); border: 1.5px solid var(--line); }
.link { background: none; border: 0; padding: 0.25rem 0; color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }

/* Sign-in */
.signin { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.signin-card {
  width: min(380px, 100%);
  display: grid;
  gap: 14px;
  padding: 28px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-l);
}
.signin-card p { margin: 0; }
label { display: grid; gap: 4px; font-weight: 600; font-size: 0.9rem; }
input, select {
  font: inherit;
  min-height: 40px;
  padding: 0 10px;
  color: var(--ink);
  background: var(--paper);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-s);
}

/* Shell: navigation on the left, folding into a menu on a phone. */
.shell { display: grid; grid-template-columns: 200px 1fr; min-height: 100dvh; }
.topbar { display: none; }
.nav {
  position: sticky;
  top: 0;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 22px 12px;
  border-right: 1px solid var(--line);
  background: var(--surface);
}
.brand { font-weight: 800; letter-spacing: -0.01em; }
.nav-brand { padding: 0 10px 18px; font-size: 1.05rem; }
.nav a {
  padding: 9px 10px;
  border-radius: var(--radius-s);
  text-decoration: none;
  font-weight: 600;
  color: var(--ink-soft);
}
.nav a:hover { color: var(--ink); }
.nav a[aria-current="page"] { color: var(--ink); background: var(--paper); box-shadow: inset 3px 0 0 var(--ink); }
.nav-foot { margin-top: auto; display: grid; gap: 2px; padding: 0 10px; font-size: 0.85rem; }
.nav-foot .link { justify-self: start; font-size: 0.85rem; }

.content { padding: 28px clamp(16px, 3vw, 40px) 64px; min-width: 0; max-width: 1180px; }
.page-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 4px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.section-head a { font-size: 0.9rem; }
.intro { max-width: 70ch; margin: 4px 0 18px; }
section > h2, .section-head { margin-top: 28px; }

/* The house at a glance: one panel, divided, not a grid of cards. */
.status-panel {
  display: flex;
  flex-wrap: wrap;
  margin-top: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-l);
  overflow: hidden;
}
.stat { flex: 1 1 140px; padding: 14px 16px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); margin: 0 -1px -1px 0; }
.stat dt { font-size: 0.82rem; color: var(--ink-soft); font-weight: 600; }
.stat dd { margin: 2px 0 0; font-size: 1.35rem; font-weight: 800; letter-spacing: -0.01em; }
.stat small { display: block; font-size: 0.82rem; font-weight: 400; color: var(--ink-soft); letter-spacing: 0; }
.stat.bad dd { color: var(--bad); }
.stat.warn dd { color: var(--warn); }

.split { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 0 36px; }

/* Devices: a plain table, grouped by kind. */
.device-group { margin-bottom: 14px; }
.device-group h3 { margin: 0 0 4px; font-size: 0.82rem; font-weight: 700; color: var(--ink-soft); }
table.devices { width: 100%; border-collapse: collapse; }
.devices td { padding: 7px 8px 7px 0; border-top: 1px solid var(--line); vertical-align: baseline; }
.devices td:first-child { font-weight: 600; width: 42%; }
.devices td.state { color: var(--ink-soft); }
.devices td.more { text-align: right; white-space: nowrap; font-size: 0.85rem; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; background: var(--app); vertical-align: 1px; }
.dot.on { background: var(--ours); }
.dot.off { background: transparent; box-shadow: inset 0 0 0 1.5px var(--app); }
.dot.bad { background: var(--bad); }

.checks { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.checks li { display: grid; grid-template-columns: 9rem 1fr; gap: 12px; padding: 6px 0; border-top: 1px solid var(--line); }
.checks b { font-weight: 600; }
.checks .ok b::before, .checks .warn b::before, .checks .fail b::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 8px; }
.checks .ok b::before { background: var(--ours); }
.checks .warn b::before { background: var(--warn); }
.checks .fail b::before { background: var(--bad); }

/* Activity: the day's spine, a mark per change in the colour of who did it. */
.filters { display: flex; flex-wrap: wrap; gap: 12px 16px; margin-bottom: 10px; }
.filters label { min-width: 180px; flex: 1 1 180px; max-width: 260px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 4px 0 18px; font-size: 0.85rem; color: var(--ink-soft); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.mark { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--app); flex: none; }
.mark.ours { background: var(--ours); }
.mark.outside { background: var(--outside); }
.mark.lock { background: var(--lock); }
.mark.app { background: transparent; box-shadow: inset 0 0 0 2px var(--app); }

.day { margin: 0 0 22px; }
.day h2 { position: sticky; top: 0; padding: 8px 0; margin: 0; background: var(--paper); font-size: 0.95rem; z-index: 1; }
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline::before { content: ""; position: absolute; left: calc(4.6rem + 4px); top: 6px; bottom: 6px; width: 2px; background: var(--line); }
.timeline li { display: grid; grid-template-columns: 4.6rem 10px 1fr; gap: 0 14px; align-items: baseline; padding: 6px 0; }
.timeline time { text-align: right; color: var(--ink-soft); font-size: 0.85rem; }
.timeline .mark { position: relative; top: 1px; box-shadow: 0 0 0 3px var(--paper); }
.timeline .mark.app { box-shadow: inset 0 0 0 2px var(--app), 0 0 0 3px var(--paper); background: var(--paper); }
.timeline .what { font-weight: 600; }
.timeline .device { font-weight: 700; }
.timeline .who { display: block; font-size: 0.85rem; color: var(--ink-soft); }
.timeline .outside-who { color: var(--outside); font-weight: 600; }
.timeline.compact li { padding: 4px 0; grid-template-columns: 6.2rem 10px 1fr; }
.timeline.compact::before { left: calc(6.2rem + 4px); }
.empty { padding: 18px 0; color: var(--ink-soft); }
#older { margin-top: 4px; }

@media (max-width: 860px) {
  .split { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .shell { display: block; }
  .topbar {
    position: sticky;
    top: 0;
    z-index: 5;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: calc(env(safe-area-inset-top, 0px) + 10px) 16px 10px;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
  }
  .menu-button { min-height: 40px; padding: 0 14px; background: var(--paper); color: var(--ink); border: 1.5px solid var(--line); border-radius: var(--radius-s); font-weight: 700; }
  .nav { display: none; position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--line); padding: 8px 12px 12px; }
  .nav.open { display: flex; }
  .nav-brand { display: none; }
  .nav-foot { margin-top: 10px; }
  .content { padding-top: 18px; }
  .checks li { grid-template-columns: 1fr; gap: 0; }
  .timeline::before { left: calc(3.8rem + 4px); }
  .timeline li { grid-template-columns: 3.8rem 10px 1fr; gap: 0 10px; }
  .filters label { max-width: none; }
}
@media (prefers-reduced-motion: no-preference) {
  .nav a { transition: color 120ms ease, background-color 120ms ease; }
}
