/* ==========================================================================
   Design system: CSS custom properties for ALL colors + base-8 spacing.
   Primary #4F46E5 indigo · Secondary #10B981 emerald · Danger #EF4444
   Mobile-first. Breakpoints: 480 / 768 / 1024 / 1280.
   ========================================================================== */

:root {
  --c-primary: #4F46E5;
  --c-primary-dark: #4338CA;
  --c-primary-soft: #EEF2FF;
  --c-secondary: #10B981;
  --c-secondary-soft: #ECFDF5;
  --c-danger: #EF4444;
  --c-danger-soft: #FEF2F2;
  --c-warn: #F59E0B;
  --c-warn-soft: #FFFBEB;
  --c-bg: #F9FAFB;
  --c-surface: #FFFFFF;
  --c-text: #111827;
  --c-text-muted: #6B7280;
  --c-border: #E5E7EB;

  --sp-1: 8px;  --sp-2: 16px; --sp-3: 24px;
  --sp-4: 32px; --sp-6: 48px; --sp-8: 64px;

  --radius: 8px;
  --shadow: 0 1px 3px rgba(17, 24, 39, .08), 0 4px 12px rgba(17, 24, 39, .06);
  --font: 'Inter', system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font); font-weight: 400; line-height: 1.6;
  color: var(--c-text); background: var(--c-bg);
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; height: auto; }
h1, h2, h3, h4 { font-weight: 700; line-height: 1.25; }
h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.125rem; font-weight: 600; }
p { margin-bottom: var(--sp-2); }
a { color: var(--c-primary); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--c-text-muted); }
.container { max-width: 1120px; margin: 0 auto; padding: 0 var(--sp-2); }

/* ------------------------------------------------------------- buttons --- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: var(--sp-1); min-height: 44px; padding: 10px var(--sp-3);
  border: 1px solid transparent; border-radius: var(--radius);
  font: 600 1rem var(--font); cursor: pointer; text-decoration: none !important;
  transition: background .15s, border-color .15s;
}
.btn-primary { background: var(--c-primary); color: #fff; }
.btn-primary:hover { background: var(--c-primary-dark); }
.btn-secondary { background: var(--c-secondary); color: #fff; }
.btn-outline { background: transparent; color: var(--c-primary); border-color: var(--c-primary); }
.btn-outline:hover { background: var(--c-primary-soft); }
.btn-danger { background: var(--c-danger); color: #fff; }
.btn-sm { min-height: 36px; padding: 6px var(--sp-2); font-size: .875rem; }
.btn-block { width: 100%; }

/* ----------------------------------------------------------- site header --- */
.site-header { background: var(--c-surface); border-bottom: 1px solid var(--c-border); }
.nav-row {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: var(--sp-2); padding-top: var(--sp-2); padding-bottom: var(--sp-2);
}
.brand {
  display: inline-flex; align-items: center; gap: var(--sp-1);
  font-weight: 700; font-size: 1.125rem; color: var(--c-text); text-decoration: none !important;
}
.site-nav { display: flex; align-items: center; flex-wrap: wrap; gap: var(--sp-2); }
.site-nav a { color: var(--c-text); font-weight: 600; font-size: .9375rem; padding: 8px 4px; min-height: 44px; display: inline-flex; align-items: center; }
.site-nav a.active, .site-nav a:hover { color: var(--c-primary); text-decoration: none; }

/* ----------------------------------------------------------------- hero --- */
.hero { padding: var(--sp-8) 0 var(--sp-6); text-align: center; background: linear-gradient(180deg, var(--c-primary-soft), var(--c-bg)); }
.hero h1 { font-size: 2.25rem; max-width: 720px; margin: 0 auto var(--sp-2); }
.hero .sub { font-size: 1.125rem; color: var(--c-text-muted); max-width: 640px; margin: 0 auto var(--sp-3); }
@media (min-width: 768px) { .hero h1 { font-size: 3rem; } }

/* -------------------------------------------------------- answer block --- */
.answer-box {
  max-width: 760px; margin: var(--sp-4) auto; padding: var(--sp-3);
  background: var(--c-surface); border: 1px solid var(--c-border);
  border-left: 4px solid var(--c-primary); border-radius: var(--radius); box-shadow: var(--shadow);
  text-align: left;
}

/* -------------------------------------------------------------- sections --- */
.section { padding: var(--sp-6) 0; }
.section-alt { background: var(--c-surface); }
.section h2 { text-align: center; margin-bottom: var(--sp-4); }
.section .lead { text-align: center; max-width: 640px; margin: -16px auto var(--sp-4); color: var(--c-text-muted); }

/* ---------------------------------------------------------- feature grid --- */
.grid { display: grid; gap: var(--sp-3); }
.grid-3 { grid-template-columns: 1fr; }
.grid-2 { grid-template-columns: 1fr; }
@media (min-width: 768px)  { .grid-3 { grid-template-columns: repeat(2, 1fr); } .grid-2 { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1024px) { .grid-3 { grid-template-columns: repeat(3, 1fr); } }

.card {
  background: var(--c-surface); border: 1px solid var(--c-border);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: var(--sp-3);
}
.card h3 { margin-bottom: var(--sp-1); }
.feature-icon { font-size: 1.75rem; margin-bottom: var(--sp-1); display: block; }

/* ------------------------------------------------------------ how it works --- */
.steps { counter-reset: step; }
.step { position: relative; padding-left: var(--sp-6); margin-bottom: var(--sp-3); }
.step::before {
  counter-increment: step; content: counter(step);
  position: absolute; left: 0; top: 0;
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--c-primary); color: #fff; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}

/* ------------------------------------------------------------ transparency --- */
.transparency { background: var(--c-secondary-soft); border-top: 4px solid var(--c-secondary); }
.transparency .card { border-color: var(--c-secondary); }

/* --------------------------------------------------------------- pricing --- */
.plan-card { display: flex; flex-direction: column; }
.plan-card.popular { border: 2px solid var(--c-primary); position: relative; }
.plan-card.popular::before {
  content: 'Most popular'; position: absolute; top: -14px; left: 50%; transform: translateX(-50%);
  background: var(--c-primary); color: #fff; font-size: .75rem; font-weight: 600;
  padding: 4px 12px; border-radius: 999px;
}
.plan-price { font-size: 2.5rem; font-weight: 700; margin: var(--sp-1) 0; }
.plan-price small { font-size: 1rem; font-weight: 400; color: var(--c-text-muted); }
.plan-features { list-style: none; margin: var(--sp-2) 0 var(--sp-3); flex: 1; }
.plan-features li { padding: 6px 0 6px 28px; position: relative; }
.plan-features li::before { content: '✓'; position: absolute; left: 0; color: var(--c-secondary); font-weight: 700; }
.billing-toggle { display: flex; justify-content: center; gap: var(--sp-1); margin-bottom: var(--sp-4); }
.billing-toggle button {
  min-height: 44px; padding: 8px var(--sp-3); border-radius: 999px; cursor: pointer;
  border: 1px solid var(--c-border); background: var(--c-surface); font: 600 .9375rem var(--font);
}
.billing-toggle button.active { background: var(--c-primary); color: #fff; border-color: var(--c-primary); }

/* -------------------------------------------------------------- FAQ --- */
.faq-item { border-bottom: 1px solid var(--c-border); padding: var(--sp-2) 0; }
.faq-item h3 { margin-bottom: var(--sp-1); }

/* ------------------------------------------------------------ forms/auth --- */
.auth-wrap { max-width: 440px; margin: var(--sp-6) auto; padding: 0 var(--sp-2); }
.form-group { margin-bottom: var(--sp-2); }
label { display: block; font-weight: 600; font-size: .9375rem; margin-bottom: 4px; }
input[type=text], input[type=email], input[type=password], input[type=number],
input[type=time], select, textarea {
  width: 100%; min-height: 44px; padding: 10px 12px;
  border: 1px solid var(--c-border); border-radius: var(--radius);
  font: 400 1rem var(--font); background: var(--c-surface); color: var(--c-text);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--c-primary); outline-offset: 0; border-color: var(--c-primary); }
.checks { display: flex; flex-wrap: wrap; gap: var(--sp-1) var(--sp-2); }
.checks label { display: inline-flex; align-items: center; gap: 6px; font-weight: 400; min-height: 44px; }
input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--c-primary); }

.flash { padding: var(--sp-2); border-radius: var(--radius); margin-bottom: var(--sp-2); font-size: .9375rem; }
.flash-ok { background: var(--c-secondary-soft); color: #065F46; border: 1px solid var(--c-secondary); }
.flash-err { background: var(--c-danger-soft); color: #991B1B; border: 1px solid var(--c-danger); }
.flash-warn { background: var(--c-warn-soft); color: #92400E; border: 1px solid var(--c-warn); }

/* --------------------------------------------------------------- badges --- */
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .75rem; font-weight: 600; }
.badge-green { background: var(--c-secondary-soft); color: #065F46; }
.badge-red { background: var(--c-danger-soft); color: #991B1B; }
.badge-amber { background: var(--c-warn-soft); color: #92400E; }
.badge-indigo { background: var(--c-primary-soft); color: var(--c-primary-dark); }
.badge-gray { background: var(--c-border); color: var(--c-text-muted); }

/* ------------------------------------------------------- dashboard shell --- */
.dash-shell { display: flex; min-height: 100vh; }
.dash-sidebar {
  width: 220px; flex-shrink: 0; background: var(--c-surface);
  border-right: 1px solid var(--c-border); padding: var(--sp-2);
  display: flex; flex-direction: column; gap: var(--sp-3);
  position: sticky; top: 0; height: 100vh;
}
.dash-nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.dash-nav a {
  display: flex; align-items: center; gap: var(--sp-1);
  min-height: 44px; padding: 8px 12px; border-radius: var(--radius);
  color: var(--c-text); font-weight: 600; font-size: .9375rem;
}
.dash-nav a:hover { background: var(--c-bg); text-decoration: none; }
.dash-nav a.active { background: var(--c-primary-soft); color: var(--c-primary-dark); }
.dash-logout { color: var(--c-text-muted); font-size: .875rem; padding: 8px 12px; min-height: 44px; display: flex; align-items: center; }
.dash-main { flex: 1; min-width: 0; }
.dash-topbar { background: var(--c-surface); border-bottom: 1px solid var(--c-border); padding: var(--sp-2) var(--sp-3); }
.dash-topbar h1 { font-size: 1.375rem; }
.dash-content { padding: var(--sp-3); max-width: 1120px; }

/* Sidebar → bottom tab bar below 768px */
@media (max-width: 767px) {
  .dash-shell { flex-direction: column; }
  .dash-sidebar {
    width: 100%; height: auto; position: fixed; bottom: 0; top: auto; z-index: 50;
    flex-direction: row; align-items: center; border-right: 0;
    border-top: 1px solid var(--c-border); padding: 4px var(--sp-1);
  }
  .dash-sidebar .brand, .dash-logout { display: none; }
  .dash-nav { flex-direction: row; width: 100%; justify-content: space-around; }
  .dash-nav a { flex-direction: column; gap: 0; font-size: .6875rem; padding: 4px; min-width: 44px; }
  .nav-icon { font-size: 1.25rem; }
  .dash-content { padding: var(--sp-2); padding-bottom: 88px; }
}

/* ----------------------------------------------------------- data tables --- */
.table-wrap { overflow: visible; }
table.data { width: 100%; border-collapse: collapse; background: var(--c-surface); border-radius: var(--radius); box-shadow: var(--shadow); }
table.data th, table.data td { text-align: left; padding: 12px var(--sp-2); border-bottom: 1px solid var(--c-border); font-size: .9375rem; }
table.data th { font-size: .8125rem; text-transform: uppercase; letter-spacing: .04em; color: var(--c-text-muted); }
table.data tr:last-child td { border-bottom: 0; }

/* Tables → stacked cards below 640px (no horizontal scroll) */
@media (max-width: 639px) {
  table.data, table.data tbody, table.data tr, table.data td { display: block; width: 100%; }
  table.data thead { display: none; }
  table.data tr { border-bottom: 8px solid var(--c-bg); padding: var(--sp-1) 0; }
  table.data td { border-bottom: 0; padding: 6px var(--sp-2); }
  table.data td[data-label]::before {
    content: attr(data-label); display: block; font-size: .75rem;
    text-transform: uppercase; letter-spacing: .04em; color: var(--c-text-muted);
  }
}

/* ------------------------------------------------------------ child cards --- */
.child-card { display: flex; align-items: center; gap: var(--sp-2); }
.avatar {
  width: 48px; height: 48px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 1.25rem;
}
.child-meta { flex: 1; min-width: 0; }
.alert-dot { background: var(--c-danger); color: #fff; border-radius: 999px; font-size: .75rem; font-weight: 700; padding: 2px 8px; }

/* ----------------------------------------------------------------- tabs --- */
.tabs { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 2px solid var(--c-border); margin-bottom: var(--sp-3); }
.tabs button {
  min-height: 44px; padding: 8px var(--sp-2); background: none; border: 0;
  border-bottom: 3px solid transparent; margin-bottom: -2px;
  font: 600 .9375rem var(--font); color: var(--c-text-muted); cursor: pointer;
}
.tabs button.active { color: var(--c-primary); border-bottom-color: var(--c-primary); }

/* ------------------------------------------------------------- bar chart --- */
.bars { display: flex; align-items: flex-end; gap: var(--sp-1); height: 160px; padding: var(--sp-2) 0; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; justify-content: flex-end; }
.bar { width: 100%; max-width: 48px; background: var(--c-primary); border-radius: 4px 4px 0 0; min-height: 2px; }
.bar-label { font-size: .6875rem; color: var(--c-text-muted); }

/* ---------------------------------------------------------------- pairing --- */
.pairing-code {
  font-size: 2.5rem; font-weight: 700; letter-spacing: .25em;
  text-align: center; padding: var(--sp-3); background: var(--c-primary-soft);
  border-radius: var(--radius); margin: var(--sp-2) 0; word-break: break-all;
}
.countdown { text-align: center; font-weight: 600; color: var(--c-warn); }
.qr-box { display: flex; justify-content: center; padding: var(--sp-2); }
.qr-box img { border: 8px solid #fff; border-radius: var(--radius); box-shadow: var(--shadow); }

/* --------------------------------------------------------------- map --- */
#map { width: 100%; height: 300px; border-radius: var(--radius); background: var(--c-bg); }
@media (min-width: 768px) { #map { height: 420px; } }

/* Radius miles/meters toggle (geofence form) */
.radius-unit { display: inline-flex; border: 1px solid var(--c-border); border-radius: var(--radius); overflow: hidden; }
.radius-unit button {
  border: none; background: var(--c-surface); color: var(--c-text-muted);
  font: 600 .8125rem var(--font); padding: 4px 12px; cursor: pointer;
}
.radius-unit button.active { background: var(--c-primary); color: #fff; }

/* Google Places Autocomplete dropdown must sit above cards/map. */
.pac-container { z-index: 10000; font-family: var(--font); border-radius: var(--radius); }

/* --------------------------------------------------------------- admin --- */
.admin-topbar { background: var(--c-text); }
.admin-topbar .brand, .admin-topbar .site-nav a { color: #fff; }
.admin-topbar .site-nav a.active { color: #A5B4FC; }
.admin-topbar .muted { color: #9CA3AF; font-size: .8125rem; }
.admin-content { padding-top: var(--sp-3); padding-bottom: var(--sp-6); }
.stat-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--sp-2); margin: var(--sp-3) 0; }
@media (min-width: 768px) { .stat-row { grid-template-columns: repeat(4, 1fr); } }
.stat { text-align: center; }
.stat .num { font-size: 1.75rem; font-weight: 700; color: var(--c-primary); }
.stat .lbl { font-size: .8125rem; color: var(--c-text-muted); text-transform: uppercase; letter-spacing: .04em; }
pre.log-view {
  background: #111827; color: #D1D5DB; padding: var(--sp-2); border-radius: var(--radius);
  font-size: .8125rem; line-height: 1.5; overflow-x: auto; max-height: 70vh;
}

/* ----------------------------------------- app picker (child.php Apps tab) --- */
.app-picker {
  max-height: 480px; overflow-y: auto;
  border: 1px solid var(--c-border); border-radius: var(--radius);
}
.app-row { display: block; padding: 10px var(--sp-2); border-bottom: 1px solid var(--c-border); }
.app-row:last-child { border-bottom: none; }
.app-row-main { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }
.app-icon { width: 36px; height: 36px; border-radius: 8px; flex-shrink: 0; }
.app-icon-fallback {
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--c-primary-soft); color: var(--c-primary); font-weight: 600;
}
.app-row-name { flex: 1; min-width: 140px; line-height: 1.35; }
.app-row-name strong { display: block; }
.app-row-name span { display: block; font-size: .75rem; word-break: break-all; }
.app-row-actions { display: flex; gap: var(--sp-1); }
.app-row-sched {
  margin-top: var(--sp-2); padding: var(--sp-2);
  background: var(--c-bg); border-radius: var(--radius);
}
@media (max-width: 480px) { .app-row-actions { width: 100%; justify-content: flex-end; } }

/* Compact single-select variant (screen-time limit target) */
.app-picker-compact { max-height: 280px; }
.app-row-btn {
  width: 100%; text-align: left; background: none; border: none;
  font: inherit; color: inherit; cursor: pointer; display: block;
}
.app-row-btn:hover { background: var(--c-bg); }
.app-row-btn.app-row-selected { background: var(--c-primary-soft); }
.app-row-btn .app-row-main { display: flex; align-items: center; gap: var(--sp-2); }

/* "Today on the phone" live usage rows */
.usage-row {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: var(--sp-2); padding: 4px 0; font-size: .875rem;
  border-bottom: 1px solid var(--c-border);
}
.usage-row:last-of-type { border-bottom: none; }

/* ------------------------------------------------------------ utilities --- */
.mt-1 { margin-top: var(--sp-1); } .mt-2 { margin-top: var(--sp-2); } .mt-3 { margin-top: var(--sp-3); }
.mb-1 { margin-bottom: var(--sp-1); } .mb-2 { margin-bottom: var(--sp-2); } .mb-3 { margin-bottom: var(--sp-3); }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); flex-wrap: wrap; }
.text-center { text-align: center; }
.w-narrow { max-width: 560px; }
