:root {
  color-scheme: light;
  --surface-1:      #fcfcfb;
  --page-plane:      #f9f9f7;
  --text-primary:   #0b0b0b;
  --text-secondary: #52514e;
  --text-muted:     #898781;
  --gridline:       #e1e0d9;
  --border:         rgba(11,11,11,0.10);

  --series-1:       #2a78d6; /* daughter 1 */
  --series-1-light: #cde2fb;
  --series-2:       #eb6834; /* daughter 2 */
  --series-2-light: #fadcc9;

  --status-good:     #0ca30c;
  --status-warning:  #fab219;
  --status-serious:  #ec835a;
  --status-critical: #d03b3b;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --surface-1:      #1a1a19;
    --page-plane:      #0d0d0d;
    --text-primary:   #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted:     #898781;
    --gridline:       #2c2c2a;
    --border:         rgba(255,255,255,0.10);

    --series-1:       #3987e5;
    --series-1-light: #184f95;
    --series-2:       #d95926;
    --series-2-light: #6b3018;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --surface-1:      #1a1a19;
  --page-plane:      #0d0d0d;
  --text-primary:   #ffffff;
  --text-secondary: #c3c2b7;
  --text-muted:     #898781;
  --gridline:       #2c2c2a;
  --border:         rgba(255,255,255,0.10);

  --series-1:       #3987e5;
  --series-1-light: #184f95;
  --series-2:       #d95926;
  --series-2-light: #6b3018;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--page-plane);
  color: var(--text-primary);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  min-width: 900px; /* desktop-first: this is a pinned browser-tab tool, not a phone view */
}

.page {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 32px 64px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0 24px;
  border-bottom: 1px solid var(--gridline);
  margin-bottom: 24px;
}

.topbar h1 {
  font-size: 20px;
  margin: 0;
}

.topbar nav a {
  color: var(--text-secondary);
  text-decoration: none;
  margin-left: 20px;
  font-size: 14px;
}
.topbar nav a:hover { color: var(--text-primary); }

.kids-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

.kid-card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px 24px;
}

.kid-card .kid-name {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 4px;
}

.kid-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}
.kid-1 .kid-dot { background: var(--series-1); }
.kid-2 .kid-dot { background: var(--series-2); }

.kid-devices {
  color: var(--text-muted);
  font-size: 13px;
  margin-bottom: 18px;
}

/* Stat tile / meter, per the dataviz meter spec:
   fill carries severity, unfilled track is a lighter step of the same ramp. */
.meter-label {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.meter-value {
  font-size: 28px;
  font-weight: 600;
  color: var(--text-primary);
}
.meter-track {
  height: 12px;
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 18px;
}
.kid-1 .meter-track { background: var(--series-1-light); }
.kid-2 .meter-track { background: var(--series-2-light); }
.meter-fill {
  height: 100%;
  border-radius: 6px;
}
.meter-fill.ok { background: var(--status-good); }
.meter-fill.warning { background: var(--status-warning); }
.meter-fill.critical { background: var(--status-critical); }

.badges {
  display: flex;
  gap: 8px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--text-secondary);
}
.badge.good { color: var(--status-good); border-color: var(--status-good); }
.badge.critical { color: var(--status-critical); border-color: var(--status-critical); background: color-mix(in srgb, var(--status-critical) 12%, transparent); }
.badge .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

.section-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin: 18px 0 10px;
}

.section-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 18px 0 10px;
}
.section-label-row .section-label {
  margin: 0;
}
.device-filter {
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface-1);
  color: var(--text-secondary);
}

.event-list {
  max-height: 480px;
  overflow-y: auto;
}
.event-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--gridline);
}
.event-row:last-child { border-bottom: none; }

.event-icon {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  flex-shrink: 0;
  object-fit: cover;
}
.event-icon-blank {
  background: var(--gridline);
}

.event-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.event-name {
  font-size: 13px;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.event-device {
  font-size: 11px;
  color: var(--text-muted);
}

.event-when {
  text-align: right;
  flex-shrink: 0;
}
.event-time {
  display: block;
  font-size: 12px;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}
.event-duration {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
}

.empty-note {
  color: var(--text-muted);
  font-size: 13px;
  font-style: italic;
}

/* --- Login page --- */
.login-box {
  max-width: 360px;
  margin: 120px auto;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 32px;
}
.login-box h1 { font-size: 18px; margin: 0 0 20px; }
.login-box input[type="password"] {
  width: 100%;
  padding: 10px 12px;
  font-size: 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--page-plane);
  color: var(--text-primary);
  margin-bottom: 12px;
}
.login-box button, .btn {
  width: 100%;
  padding: 10px 12px;
  font-size: 14px;
  font-weight: 600;
  border: none;
  border-radius: 6px;
  background: var(--series-1);
  color: #fff;
  cursor: pointer;
}
.btn.secondary {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-primary);
}
.error-note {
  color: var(--status-critical);
  font-size: 13px;
  margin-bottom: 12px;
}

/* --- Rules copy tool --- */
.copy-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  align-items: start;
}
.rule-group {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 10px;
  background: var(--surface-1);
}
.rule-group label {
  flex: 1;
  font-size: 14px;
}
.rule-group .rule-hint {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
}
.direction-picker {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  font-size: 14px;
}
.direction-picker select {
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface-1);
  color: var(--text-primary);
}
.diff-box {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  background: var(--surface-1);
  font-size: 13px;
  margin-top: 16px;
}
.diff-box pre {
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 12px;
  color: var(--text-secondary);
}
