/* ── Reset & base ──────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #0f1117;
  --surface:   #1a1d27;
  --surface2:  #22263a;
  --border:    #2e3349;
  --text:      #e8eaf6;
  --text-muted:#8b91b0;
  --accent:    #6C5CE7;
  --green:     #4CAF50;
  --red:       #E74C3C;
  --radius:    14px;
  --radius-sm: 8px;
}

html { font-size: 16px; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* ── Screens ───────────────────────────────────────────────────────────────── */
.screen { display: none; max-width: 640px; margin: 0 auto; padding: 24px 16px 64px; }
.screen.active { display: block; animation: fadeIn .2s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ── Auth screen ───────────────────────────────────────────────────────────── */
#screen-auth { align-items: center; justify-content: center; min-height: 100vh; padding: 24px 16px; max-width: 100%; }
#screen-auth.active { display: flex; }

.auth-wrap { width: 100%; max-width: 400px; text-align: center; }
.auth-logo  { font-size: 56px; margin-bottom: 8px; }
.auth-brand { font-size: 1.8rem; font-weight: 800; letter-spacing: -.5px; margin-bottom: 4px; }
.auth-tagline { color: var(--text-muted); font-size: .9rem; margin-bottom: 28px; }

.auth-form  { display: flex; flex-direction: column; gap: 12px; margin-bottom: 16px; }
.auth-input {
  width: 100%; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text); font-size: .95rem;
  padding: 12px 14px; outline: none; transition: border-color .15s;
}
.auth-input:focus { border-color: var(--accent); }
.auth-error {
  background: #E74C3C18; border: 1px solid #E74C3C40; color: var(--red);
  border-radius: var(--radius-sm); padding: 10px 12px; font-size: .85rem; text-align: left;
}
.auth-hint { color: var(--text-muted); font-size: .875rem; margin-bottom: 4px; }
.auth-switch { font-size: .85rem; color: var(--text-muted); margin-top: 6px; }
.auth-done { text-align: center; padding: 20px 0; }
.auth-done-emoji { font-size: 2.5rem; margin-bottom: 12px; }
.auth-done-title { font-weight: 700; margin-bottom: 8px; }

.link-btn {
  background: none; border: none; color: var(--accent); cursor: pointer;
  font-size: inherit; text-decoration: underline; padding: 0;
}

.app-links { margin-top: 36px; padding-top: 24px; border-top: 1px solid var(--border); }
.app-links-title { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .6px; color: var(--text-muted); margin-bottom: 10px; }
.app-link { display: block; color: var(--text); text-decoration: none; font-size: .9rem; padding: 6px 0; }
.app-link:hover { color: var(--accent); }

.hidden { display: none !important; }

/* ── App header ────────────────────────────────────────────────────────────── */
header { margin-bottom: 20px; }
.header-row { display: flex; justify-content: space-between; align-items: center; }
.header-brand { font-size: 1.1rem; font-weight: 800; }
.header-user { display: flex; align-items: center; gap: 14px; font-size: .85rem; color: var(--text-muted); }
.logout-btn {
  background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text); font-size: .8rem; padding: 6px 12px; cursor: pointer;
}

.back-btn {
  background: none; border: none; color: var(--text-muted); font-size: .9rem;
  cursor: pointer; margin-bottom: 16px; padding: 0;
}
.back-btn:hover { color: var(--text); }

/* ── Buttons ───────────────────────────────────────────────────────────────── */
.btn-primary {
  display: block; width: 100%; background: var(--accent); color: #fff; border: none;
  border-radius: var(--radius); font-size: 1rem; font-weight: 700; padding: 14px;
  cursor: pointer; margin-bottom: 10px; transition: opacity .15s;
}
.btn-primary:hover { opacity: .9; }
.btn-secondary {
  display: block; width: 100%; background: var(--surface2); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius); font-size: .95rem;
  padding: 12px; cursor: pointer; transition: border-color .15s;
}
.btn-secondary:hover { border-color: var(--text-muted); }
.form-row { display: flex; gap: 10px; }
.form-row .btn-primary, .form-row .btn-secondary { margin: 0; }
.btn-add {
  background: var(--accent); color: #fff; border: none; border-radius: var(--radius-sm);
  font-size: .85rem; font-weight: 700; padding: 9px 16px; cursor: pointer;
}

/* ── Dashboard hero + add-kid form ─────────────────────────────────────────── */
.hero { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.hero-title { font-size: 1.4rem; font-weight: 800; }

.add-kid-form, .edit-kid-form {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; margin-bottom: 16px; display: flex; flex-direction: column; gap: 10px;
}
.form-title { font-size: 1rem; font-weight: 700; }
.form-hint  { font-size: .8rem; color: var(--text-muted); margin-bottom: 4px; }
.form-error {
  background: #E74C3C18; border: 1px solid #E74C3C40; color: var(--red);
  border-radius: var(--radius-sm); padding: 10px 12px; font-size: .85rem;
}

.parents-section { border-top: 1px solid var(--border); margin-top: 4px; padding-top: 12px; }
.parents-title { font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--text-muted); margin-bottom: 8px; }
.parent-row { display: flex; justify-content: space-between; align-items: center; font-size: .85rem; padding: 4px 0; }

.empty-state {
  text-align: center; color: var(--text-muted); padding: 40px 20px;
  background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius);
}

/* ── Kid cards ─────────────────────────────────────────────────────────────── */
.kid-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; margin-bottom: 14px;
}
.kid-card-header { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.kid-avatar {
  width: 40px; height: 40px; border-radius: 50%; background: var(--accent);
  color: #fff; font-size: 1.1rem; font-weight: 800; display: flex;
  align-items: center; justify-content: center; flex-shrink: 0;
}
.kid-info { flex: 1; min-width: 0; }
.kid-name { font-weight: 700; font-size: .95rem; }
.kid-username { font-size: .78rem; color: var(--text-muted); }

.edit-kid-form { margin: 0 0 12px; padding: 14px; }

.app-rows { display: flex; flex-direction: column; gap: 2px; }
.app-row {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  padding: 10px 0; border-top: 1px solid var(--border);
}
.app-toggle { display: flex; align-items: center; gap: 8px; cursor: pointer; min-width: 140px; }
.app-toggle input { accent-color: var(--accent); width: 18px; height: 18px; }
.app-toggle-name { font-size: .9rem; font-weight: 600; }
.app-open-link { color: var(--accent); font-size: .82rem; text-decoration: none; }
.app-open-link:hover { text-decoration: underline; }
.app-row-meta { display: flex; align-items: center; gap: 10px; margin-left: auto; flex-wrap: wrap; }
.reminders-toggle { display: flex; align-items: center; gap: 5px; font-size: .78rem; color: var(--text-muted); cursor: pointer; }
.reminders-toggle input { accent-color: var(--accent); }
.push-status { font-size: .72rem; white-space: nowrap; }
.push-on  { color: var(--green); }
.push-off { color: var(--text-muted); }
.push-unreachable { color: var(--red); }
.mode-select-inline {
  background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text); font-size: .78rem; padding: 5px 8px; cursor: pointer;
}

/* ── Admin overview ────────────────────────────────────────────────────────── */
.admin-title { font-size: 1.3rem; font-weight: 800; margin-bottom: 16px; }
.admin-parent-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; margin-bottom: 12px;
}
.admin-parent-header { display: flex; flex-direction: column; margin-bottom: 10px; }
.admin-parent-name { font-weight: 700; }
.admin-parent-meta { font-size: .78rem; color: var(--text-muted); }
.admin-kids { display: flex; flex-direction: column; gap: 6px; }
.admin-kid {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  font-size: .85rem; padding: 6px 0; border-top: 1px solid var(--border);
}
.admin-kid-username { color: var(--text-muted); font-size: .78rem; }
.admin-kid-apps { color: var(--text-muted); font-size: .78rem; text-align: right; }
.admin-kid-empty { color: var(--text-muted); font-size: .82rem; font-style: italic; }
.admin-section-title { font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .6px; color: var(--text-muted); margin-bottom: 10px; }
.not-in-hub { color: var(--red); font-size: .7rem; border: 1px solid #E74C3C40; border-radius: 99px; padding: 1px 6px; margin-left: 4px; }

/* ── Toast ─────────────────────────────────────────────────────────────────── */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px 20px; font-size: .85rem; max-width: 90vw; text-align: center;
  box-shadow: 0 8px 24px rgba(0,0,0,.3); z-index: 100;
}

@media (max-width: 480px) {
  .app-row { flex-direction: column; align-items: flex-start; }
  .app-row-meta { margin-left: 0; }
}
