:root {
  --bg-gradient: radial-gradient(1200px 800px at 20% -10%, #3b82f6 0%, transparent 45%), radial-gradient(1000px 700px at 100% 0%, #22c55e 0%, transparent 40%), linear-gradient(160deg, #0f172a 0%, #1e293b 45%, #111827 100%);
  --card-bg: rgba(255, 255, 255, 0.9);
  --primary: #2563eb;
  --accent: #7c3aed;
  --danger: #dc2626;
  --success: #16a34a;
  --radius: 20px;
  --shadow: 0 20px 45px rgba(15, 23, 42, 0.28);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  background: var(--bg-gradient);
  color: #0f172a;
  line-height: 1.45;
}

a {
  color: inherit;
}

.page {
  min-height: 100vh;
  display: flex;
  justify-content: center;
  padding: 18px 14px 24px;
}

.shell {
  width: 100%;
  max-width: 420px;
}

.shell-wide {
  max-width: 1040px;
}

.brand {
  color: #e2e8f0;
  text-align: center;
  letter-spacing: 0.08em;
  font-size: 12px;
  margin-bottom: 10px;
  text-transform: uppercase;
}

.logo-wrap {
  display: grid;
  place-items: center;
  margin: 4px 0 10px;
}

.logo-img {
  width: min(150px, 42vw);
  height: auto;
  display: block;
  filter: drop-shadow(0 12px 18px rgba(15, 23, 42, 0.3));
}

.shell-wide .logo-img {
  width: min(130px, 32vw);
}

.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  backdrop-filter: blur(8px);
}

.hero-card {
  padding: 28px 22px;
  text-align: center;
}

h1,
h2,
h3,
p {
  margin: 0;
}

.title {
  font-size: 28px;
  font-weight: 800;
  color: #0f172a;
  line-height: 1.15;
}

.subtitle {
  margin-top: 10px;
  font-size: 14px;
  color: #475569;
}

.credit {
  font-size: 12px;
  color: #64748b;
  text-align: center;
  margin-top: 10px;
  letter-spacing: 0.04em;
}

.stack {
  display: grid;
  gap: 12px;
}

.profile-section {
  display: grid;
  gap: 8px;
}

.profile-label {
  font-size: 13px;
  color: #334155;
  font-weight: 700;
}

.btn {
  border: 0;
  border-radius: 14px;
  padding: 14px 16px;
  font-size: 16px;
  font-weight: 700;
  text-decoration: none;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: transform .14s ease, box-shadow .2s ease, filter .2s ease, opacity .2s ease;
  will-change: transform;
}

.btn:hover {
  transform: translateY(-1px);
  filter: brightness(1.03);
}

.btn:active {
  transform: scale(0.98);
}

.btn:disabled {
  opacity: 0.65;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  background: linear-gradient(120deg, var(--primary), var(--accent));
  color: #ffffff;
  box-shadow: 0 10px 22px rgba(37, 99, 235, 0.35);
}

.btn-soft {
  background: rgba(15, 23, 42, 0.08);
  color: #0f172a;
}

.btn-danger {
  background: rgba(220, 38, 38, 0.14);
  color: #991b1b;
}

.btn-success {
  background: rgba(22, 163, 74, 0.16);
  color: #14532d;
}

.btn.loading {
  position: relative;
  pointer-events: none;
}

.btn.loading::after {
  content: "";
  width: 15px;
  height: 15px;
  border: 2px solid rgba(255, 255, 255, 0.55);
  border-top-color: #ffffff;
  border-radius: 999px;
  animation: spin .7s linear infinite;
}

.field {
  position: relative;
}

.field input {
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.92);
  padding: 18px 14px 10px;
  font-size: 16px;
  outline: none;
  transition: border-color .2s ease, box-shadow .2s ease;
}

.field input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.field label {
  position: absolute;
  left: 14px;
  top: 14px;
  color: #64748b;
  font-size: 14px;
  pointer-events: none;
  transform-origin: left top;
  transition: transform .18s ease, color .18s ease;
}

.field input:focus + label,
.field input:not(:placeholder-shown) + label {
  transform: translateY(-8px) scale(0.85);
  color: var(--primary);
}

.msg {
  min-height: 24px;
  font-size: 14px;
  border-radius: 12px;
  padding: 9px 10px;
  background: rgba(148, 163, 184, 0.12);
  color: #334155;
}

.msg.ok {
  background: rgba(22, 163, 74, 0.15);
  color: #14532d;
}

.msg.err {
  background: rgba(220, 38, 38, 0.14);
  color: #991b1b;
}

.pills {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 10px;
}

.kid-toolbar {
  display: grid;
  gap: 10px;
  margin-bottom: 10px;
}

.kid-identity {
  display: flex;
  align-items: center;
  gap: 10px;
}

.kid-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 24px;
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid rgba(148, 163, 184, 0.4);
}

.kid-greeting {
  font-size: 18px;
  font-weight: 800;
  color: #0f172a;
}

.kid-toolbar-actions {
  display: grid;
  gap: 8px;
  grid-template-columns: 1fr 1fr;
}

.sound-toggle {
  padding: 9px 12px;
  font-size: 13px;
}

.theme-grid,
.avatar-grid {
  display: grid;
  gap: 8px;
}

.theme-grid {
  grid-template-columns: repeat(3, 1fr);
}

.avatar-grid {
  grid-template-columns: repeat(6, 1fr);
}

.theme-chip,
.avatar-chip {
  border: 1px solid rgba(148, 163, 184, 0.45);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.8);
  color: #0f172a;
  font-weight: 700;
  cursor: pointer;
  transition: transform .14s ease, border-color .2s ease, box-shadow .2s ease;
}

.theme-chip {
  padding: 10px 8px;
  font-size: 12px;
}

.avatar-chip {
  height: 44px;
  font-size: 22px;
}

.theme-chip:hover,
.avatar-chip:hover {
  transform: translateY(-1px);
}

.theme-chip.active,
.avatar-chip.active {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.16);
}

.achievement-banner {
  margin-bottom: 10px;
  border-radius: 12px;
  padding: 8px 10px;
  text-align: center;
  font-weight: 800;
  color: #14532d;
  background: rgba(34, 197, 94, 0.2);
  border: 1px solid rgba(34, 197, 94, 0.35);
  opacity: 0;
  transform: translateY(-8px);
}

.achievement-banner.show {
  animation: achievementPop 1.1s ease;
}

.pill {
  background: rgba(255, 255, 255, 0.35);
  border: 1px solid rgba(148, 163, 184, 0.3);
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 700;
  color: #1f2937;
  text-align: center;
}

.progress {
  width: 100%;
  height: 10px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(148, 163, 184, 0.3);
  margin-bottom: 12px;
}

.progress > div {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #22c55e, #10b981);
  transition: width .45s ease;
}

.formula {
  font-size: 52px;
  font-weight: 800;
  text-align: center;
  letter-spacing: 0.02em;
  color: #0f172a;
  margin: 8px 0 12px;
}

.formula.pop {
  animation: pop .32s ease;
}

.answer-input {
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 16px;
  padding: 15px;
  font-size: 34px;
  text-align: center;
  font-weight: 700;
  outline: none;
}

.answer-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.keypad,
.action-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 12px;
}

.feedback-flash-success {
  animation: flashSuccess .55s ease;
}

.feedback-flash-error {
  animation: flashError .55s ease;
}

.finish {
  text-align: center;
  padding: 22px 18px;
}

.finish h2 {
  font-size: 34px;
  color: #0f172a;
}

.finish p {
  margin-top: 8px;
  color: #475569;
}

.finish-badge {
  width: 78px;
  height: 78px;
  border-radius: 50%;
  margin: 0 auto 12px;
  display: grid;
  place-items: center;
  font-size: 34px;
  background: radial-gradient(circle at 30% 20%, #fde047, #f59e0b);
  box-shadow: 0 10px 24px rgba(245, 158, 11, 0.35);
}

.level-badge-row {
  margin: 10px auto 0;
  display: flex;
  justify-content: center;
}

.level-badge {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  border: 2px solid #f59e0b;
  border-radius: 14px;
  padding: 10px 18px;
  animation: badgePop .5s cubic-bezier(.34,1.56,.64,1) both;
}

.level-badge-emoji {
  font-size: 28px;
  line-height: 1;
}

.level-badge-new {
  animation: badgePop .6s .15s cubic-bezier(.34,1.56,.64,1) both;
}

.level-badge-arrow {
  font-size: 20px;
  color: #94a3b8;
  margin: 0 4px;
  align-self: center;
}

.level-badge-text {
  font-size: 13px;
  font-weight: 700;
  color: #0f172a;
  text-align: center;
}

.papa-message {
  margin: 12px 8px 0;
  padding: 12px 16px;
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(14,165,233,.12), rgba(139,92,246,.12));
  border: 1px solid rgba(14,165,233,.28);
  font-size: 14px;
  font-weight: 600;
  color: #0f172a;
  text-align: center;
  line-height: 1.5;
  animation: fadeIn .5s ease;
}

.earned-badges {
  margin-top: 12px;
  text-align: center;
}

.earned-badges-label {
  font-size: 11px;
  font-weight: 700;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 6px;
}

.earned-badges-grid {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
}

.earned-badge-chip {
  font-size: 20px;
  border: 2px solid #f59e0b;
  border-radius: 50%;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  background: rgba(255,255,255,.15);
  animation: badgePop .4s cubic-bezier(.34,1.56,.64,1) both;
}

.pill-level {
  background: rgba(139, 92, 246, 0.18);
  color: #7c3aed;
  font-weight: 700;
}

@keyframes badgePop {
  from { transform: scale(0); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.fade-in {
  animation: fadeIn .35s ease;
}

.hidden {
  display: none;
}

.admin-controls {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

/* ── Admin hero top layout ── */
.admin-hero-top {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: flex-start;
}

.admin-hero-badge {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  display: grid;
  place-items: center;
  font-size: 26px;
  flex-shrink: 0;
  box-shadow: 0 6px 18px rgba(37, 99, 235, 0.3);
}

.admin-hero-title {
  font-size: 26px;
}

/* ── Admin section header ── */
.admin-section-header {
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: #e2e8f0;
  margin-top: 20px;
  margin-bottom: 10px;
  padding-left: 2px;
}

.admin-hero {
  border: 1px solid rgba(148, 163, 184, 0.28);
  background:
    radial-gradient(110% 120% at 0% 0%, rgba(37, 99, 235, 0.18) 0%, transparent 60%),
    radial-gradient(120% 140% at 100% 0%, rgba(124, 58, 237, 0.16) 0%, transparent 62%),
    var(--card-bg);
}

.admin-hero-head {
  gap: 14px;
}

.admin-hero-copy .subtitle {
  max-width: 66ch;
}

.admin-hero-pills {
  display: grid;
  gap: 8px;
  min-width: min(240px, 100%);
}

.hero-pill {
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 12px;
  letter-spacing: 0.02em;
  color: #334155;
  background: rgba(255, 255, 255, 0.82);
  text-align: center;
  font-weight: 700;
}

.admin-tabs {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.tab-btn {
  border: 1px solid rgba(148, 163, 184, 0.35);
  border-radius: 12px;
  padding: 11px 12px;
  background: rgba(255, 255, 255, 0.75);
  color: #1e293b;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  transition: transform .14s ease, background .2s ease, border-color .2s ease, color .2s ease, box-shadow .2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.tab-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.12);
}

.tab-btn.active {
  background: linear-gradient(120deg, var(--primary), var(--accent));
  color: #ffffff;
  border-color: transparent;
}

.tab-panel {
  margin-top: 12px;
}

.tab-dashboard {
  margin-top: 14px;
}

.admin-grid {
  margin-top: 12px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.admin-stats {
  margin-top: 12px;
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.admin-stats-dashboard {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.stat-card {
  background: var(--card-bg);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 16px 14px 14px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  position: relative;
  overflow: hidden;
  transition: transform .14s ease, box-shadow .2s ease;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-card::before {
  content: "";
  position: absolute;
  inset: 0 auto auto 0;
  width: 100%;
  height: 4px;
  background: var(--stat-accent, linear-gradient(120deg, #2563eb, #7c3aed));
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 16px 34px rgba(15, 23, 42, 0.2);
}

.stat-card-kids { --stat-accent: linear-gradient(120deg, #0ea5e9, #2563eb); }
.stat-card-completed { --stat-accent: linear-gradient(120deg, #22c55e, #16a34a); }
.stat-card-accuracy { --stat-accent: linear-gradient(120deg, #06b6d4, #2563eb); }
.stat-card-response { --stat-accent: linear-gradient(120deg, #f59e0b, #f97316); }
.stat-card-wallet { --stat-accent: linear-gradient(120deg, #7c3aed, #ec4899); }

.stat-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #64748b;
  margin-top: 2px;
}

.stat-value {
  margin-top: 4px;
  font-size: 26px;
  font-weight: 800;
  color: #0f172a;
  line-height: 1.1;
}

.stat-icon {
  font-size: 20px;
  line-height: 1;
  margin-bottom: 2px;
}

.filters-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr;
}

.dashboard-controls-card {
  border: 1px solid rgba(148, 163, 184, 0.24);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.85), rgba(248, 250, 252, 0.88));
}

.dashboard-result-meta {
  margin-top: 10px;
  font-weight: 700;
  color: #475569;
}

.admin-select {
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.92);
  padding: 18px 14px 10px;
  font-size: 16px;
  outline: none;
  transition: border-color .2s ease, box-shadow .2s ease;
  appearance: none;
}

.admin-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.config-grid {
  margin-top: 12px;
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr 1fr;
}

.card-actions {
  margin-top: 10px;
  display: grid;
  gap: 8px;
  grid-template-columns: 1fr;
}

.row-split {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.admin-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.toggle-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #334155;
  font-weight: 600;
}

.toggle-row input {
  width: 18px;
  height: 18px;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  display: grid;
  place-items: center;
  padding: 14px;
  z-index: 50;
}

.modal.hidden {
  display: none !important;
  pointer-events: none;
}

.modal-card {
  width: 100%;
  max-width: 420px;
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  position: relative;
}

.settings-sheet {
  max-width: 560px;
  max-height: min(88vh, 780px);
  overflow: auto;
  overscroll-behavior: contain;
}

body.modal-open {
  overflow: hidden;
}

.modal-x {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 10px;
  font-size: 22px;
  line-height: 1;
}

.op-grid {
  display: grid;
  gap: 8px;
  grid-template-columns: 1fr 1fr;
}

.range-grid {
  display: grid;
  gap: 8px;
}

.range-row {
  display: grid;
  grid-template-columns: 28px 1fr 1fr;
  gap: 8px;
  align-items: center;
}

.range-row span {
  font-weight: 800;
  color: #334155;
}

.range-row input {
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 14px;
}

.preview-box {
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  min-height: 54px;
  padding: 10px;
  background: rgba(248, 250, 252, 0.9);
}

.preview-title {
  font-size: 12px;
  font-weight: 800;
  color: #475569;
  margin-bottom: 6px;
}

.preview-item {
  font-size: 14px;
  color: #0f172a;
  padding: 4px 0;
}

.trend-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  border-radius: 999px;
  padding: 5px 10px;
  border: 1px solid transparent;
  white-space: nowrap;
}

.trend-up {
  color: #166534;
  background: rgba(22, 163, 74, 0.14);
  border-color: rgba(22, 163, 74, 0.3);
}

.trend-down {
  color: #991b1b;
  background: rgba(220, 38, 38, 0.14);
  border-color: rgba(220, 38, 38, 0.3);
}

.trend-stable {
  color: #374151;
  background: rgba(107, 114, 128, 0.12);
  border-color: rgba(107, 114, 128, 0.22);
}

.card-msg {
  margin-top: 10px;
}

.details-panel {
  margin-top: 10px;
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  transition: max-height .28s ease, opacity .2s ease;
}

.details-panel.open {
  max-height: 360px;
  opacity: 1;
}

.details-grid {
  display: grid;
  gap: 8px;
  grid-template-columns: 1fr 1fr;
}

.kid-card {
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.94);
}

.dashboard-kid-card {
  display: grid;
  gap: 10px;
  border: 1px solid rgba(148, 163, 184, 0.26);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(248, 250, 252, 0.92));
}

.kid-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 10px;
}

.kid-name {
  font-weight: 800;
  color: #0f172a;
}

.kid-badges {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.kid-meta {
  color: #64748b;
  font-size: 12px;
}

.preset-info {
  font-size: 12px;
  color: #6b7280;
  margin-top: -6px;
}

.meter-stack {
  display: grid;
  gap: 6px;
}

.meter-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.meter-label {
  font-size: 12px;
  font-weight: 700;
  color: #475569;
}

.meter-value {
  font-size: 12px;
  font-weight: 800;
  color: #0f172a;
}

.meter-track {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.24);
  overflow: hidden;
}

.meter-fill {
  height: 100%;
  border-radius: 999px;
  width: 0%;
  transition: width .28s ease;
}

.meter-goal {
  background: linear-gradient(120deg, var(--primary), var(--accent));
}

.meter-accuracy {
  background: linear-gradient(120deg, #0ea5e9, #2563eb);
}

.meter-accuracy.meter-good {
  background: linear-gradient(120deg, #16a34a, #22c55e);
}

.meter-accuracy.meter-mid {
  background: linear-gradient(120deg, #f59e0b, #f97316);
}

.meter-accuracy.meter-low {
  background: linear-gradient(120deg, #f97316, #ef4444);
}

.dashboard-metrics {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.kid-settings-note {
  margin-top: 2px;
}

.dashboard-actions {
  margin-top: 2px;
}

.dashboard-empty {
  text-align: center;
  font-weight: 700;
  color: #475569;
  padding: 20px;
}

.metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.dash-detail-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  flex-wrap: wrap;
}

.dash-detail-label {
  font-size: 11px;
  font-weight: 700;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
  padding-top: 3px;
}

.dash-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.dash-tag {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 700;
  border-radius: 999px;
  padding: 3px 9px;
  border: 1px solid transparent;
}

.dash-tag-warn {
  background: rgba(245, 158, 11, 0.15);
  color: #92400e;
  border-color: rgba(245, 158, 11, 0.3);
}

.dash-tag-flag {
  background: rgba(220, 38, 38, 0.13);
  color: #991b1b;
  border-color: rgba(220, 38, 38, 0.28);
}

.metric {
  background: #f8fafc;
  border-radius: 12px;
  padding: 8px 10px;
}

.metric-label {
  font-size: 11px;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.metric-value {
  margin-top: 4px;
  font-weight: 800;
  color: #0f172a;
}

@media (min-width: 700px) {
  .kid-toolbar {
    grid-template-columns: 1fr auto;
    align-items: center;
  }

  .kid-toolbar-actions {
    grid-template-columns: auto auto;
  }

  .admin-tabs {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .admin-controls {
    grid-template-columns: 1fr auto auto;
    align-items: end;
  }

  .admin-top-controls {
    grid-template-columns: 1fr auto auto auto;
  }

  .filters-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .dashboard-filters-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .admin-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .users-grid,
  .kids-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .admin-stats {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .admin-stats-dashboard {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .card-actions {
    grid-template-columns: 1fr 1fr 1fr;
  }
}

@media (min-width: 980px) {
  .admin-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .users-grid,
  .kids-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .admin-stats-dashboard {
    grid-template-columns: repeat(7, minmax(0, 1fr));
  }
}

@media (min-width: 1260px) {
  .shell-wide {
    max-width: 1280px;
  }

  .admin-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .users-grid,
  .kids-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes pop {
  0% { transform: scale(0.88); opacity: 0.5; }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes flashSuccess {
  0% { box-shadow: var(--shadow), inset 0 0 0 0 rgba(22, 163, 74, 0.32); }
  100% { box-shadow: var(--shadow), inset 0 0 0 999px rgba(22, 163, 74, 0); }
}

@keyframes flashError {
  0% { box-shadow: var(--shadow), inset 0 0 0 0 rgba(220, 38, 38, 0.28); }
  100% { box-shadow: var(--shadow), inset 0 0 0 999px rgba(220, 38, 38, 0); }
}

@keyframes achievementPop {
  0% { opacity: 0; transform: translateY(-8px) scale(0.98); }
  15% { opacity: 1; transform: translateY(0) scale(1); }
  80% { opacity: 1; transform: translateY(0) scale(1); }
  100% { opacity: 0; transform: translateY(-6px) scale(0.98); }
}

/* ══════════════════════════════════════════════════════════════════════
   ADMIN V2 — Dark Sidebar Layout
   All rules scoped to body.admin-v2 to avoid side-effects on
   login.html, kid.html, or index.html
   ══════════════════════════════════════════════════════════════════════ */

body.admin-v2 {
  --adm-bg:         #0f172a;
  --adm-sidebar:    #1e293b;
  --adm-card:       #1e293b;
  --adm-border:     #334155;
  --adm-accent:     #6366f1;
  --adm-accent-lt:  #818cf8;
  --adm-text:       #f1f5f9;
  --adm-muted:      #94a3b8;
  --adm-success:    #22c55e;
  --adm-warning:    #f59e0b;
  --adm-danger:     #ef4444;
  --adm-sidebar-w:  220px;
  background: var(--adm-bg);
  color: var(--adm-text);
  margin: 0;
  padding: 0;
}

body.admin-v2 .page { padding: 0; display: block; min-height: 100vh; }

/* ── Outer wrapper ── */
.adm-layout {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ── */
.adm-sidebar {
  width: var(--adm-sidebar-w);
  background: var(--adm-sidebar);
  border-right: 1px solid var(--adm-border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 40;
  transition: transform .22s ease;
}

.adm-sidebar-logo {
  padding: 18px 16px 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid var(--adm-border);
}

.adm-sidebar-logo img {
  width: 52px;
  height: auto;
  filter: drop-shadow(0 4px 10px rgba(0,0,0,.5));
  border-radius: 50%;
}

.adm-sidebar-brand {
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--adm-muted);
  text-align: center;
}

/* ── Nav ── */
.adm-nav {
  flex: 1;
  padding: 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  overflow-y: auto;
}

.adm-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  border: none;
  background: transparent;
  color: var(--adm-muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, color .15s;
  width: 100%;
  text-align: left;
}

.adm-nav-item:hover { background: rgba(99,102,241,.12); color: var(--adm-text); }
.adm-nav-item.active { background: rgba(99,102,241,.22); color: var(--adm-accent-lt); }

.adm-nav-icon { font-size: 16px; line-height: 1; flex-shrink: 0; }

/* ── Sidebar footer ── */
.adm-sidebar-footer {
  padding: 12px 10px;
  border-top: 1px solid var(--adm-border);
}

.adm-logout-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  border: none;
  background: transparent;
  color: var(--adm-muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
  text-align: left;
  transition: background .15s, color .15s;
}
.adm-logout-btn:hover { background: rgba(239,68,68,.12); color: var(--adm-danger); }

/* ── Main area ── */
.adm-main {
  margin-left: var(--adm-sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ── Topbar ── */
.adm-topbar {
  height: 62px;
  background: var(--adm-sidebar);
  border-bottom: 1px solid var(--adm-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 30;
  gap: 12px;
  flex-wrap: wrap;
}

.adm-topbar-left { display: flex; align-items: center; gap: 12px; }

.adm-topbar-title {
  font-size: 16px;
  font-weight: 800;
  color: var(--adm-text);
  white-space: nowrap;
}

.adm-topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.adm-topbar-pill {
  font-size: 11px;
  font-weight: 700;
  color: var(--adm-muted);
  background: rgba(255,255,255,.05);
  border: 1px solid var(--adm-border);
  border-radius: 999px;
  padding: 5px 12px;
  white-space: nowrap;
}

/* ── Status message row ── */
.adm-status-row { padding: 0 24px; }

/* ── Content scroll area ── */
.adm-content { padding: 24px; flex: 1; }

/* ── Section panels ── */
.adm-section { display: none; }
.adm-section.active { display: block; }

.adm-section-title {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--adm-muted);
  margin: 0 0 14px;
}

/* ── Dark stat cards ── */
body.admin-v2 .stat-card {
  background: var(--adm-card);
  border: 1px solid var(--adm-border);
  box-shadow: none;
}
body.admin-v2 .stat-label { color: var(--adm-muted); }
body.admin-v2 .stat-value { color: var(--adm-text); }

/* ── Dark general card ── */
body.admin-v2 .card {
  background: var(--adm-card);
  border: 1px solid var(--adm-border);
  box-shadow: none;
  color: var(--adm-text);
}
body.admin-v2 .title { color: var(--adm-text); }
body.admin-v2 .subtitle { color: var(--adm-muted); }
body.admin-v2 .credit { color: var(--adm-muted); }

/* ── Dark dashboard controls card ── */
body.admin-v2 .dashboard-controls-card {
  background: var(--adm-card);
  border-color: var(--adm-border);
}
body.admin-v2 .dashboard-result-meta { color: var(--adm-muted); }

/* ── Dark kid cards ── */
body.admin-v2 .kid-card {
  background: var(--adm-card);
  border: 1px solid var(--adm-border);
  box-shadow: none;
}
body.admin-v2 .kid-name { color: var(--adm-text); }
body.admin-v2 .kid-meta { color: var(--adm-muted); }
body.admin-v2 .kid-settings-note { color: var(--adm-muted); }
body.admin-v2 .metric { background: rgba(255,255,255,.05); }
body.admin-v2 .metric-label { color: var(--adm-muted); }
body.admin-v2 .metric-value { color: var(--adm-text); }
body.admin-v2 .meter-label { color: var(--adm-muted); }
body.admin-v2 .meter-value { color: var(--adm-text); }
body.admin-v2 .meter-track { background: rgba(148,163,184,.15); }

/* ── Dark forms ── */
body.admin-v2 .field input,
body.admin-v2 .admin-select,
body.admin-v2 input[type="number"],
body.admin-v2 input[type="text"],
body.admin-v2 input[type="password"],
body.admin-v2 input[type="date"] {
  background: rgba(255,255,255,.06);
  border-color: var(--adm-border);
  color: var(--adm-text);
}
body.admin-v2 .field label,
body.admin-v2 .profile-label { color: var(--adm-muted); }
body.admin-v2 .field input:focus,
body.admin-v2 .admin-select:focus,
body.admin-v2 input[type="number"]:focus,
body.admin-v2 input[type="text"]:focus,
body.admin-v2 input[type="password"]:focus,
body.admin-v2 input[type="date"]:focus {
  border-color: var(--adm-accent);
  box-shadow: 0 0 0 3px rgba(99,102,241,.2);
}
body.admin-v2 .field input:focus + label,
body.admin-v2 .field input:not(:placeholder-shown) + label {
  color: var(--adm-accent-lt);
}
body.admin-v2 .toggle-row { color: var(--adm-text); }
body.admin-v2 .range-row span { color: var(--adm-muted); }
body.admin-v2 .preset-info { color: var(--adm-muted); }
body.admin-v2 select option { background: #1e293b; color: var(--adm-text); }

/* ── Dark buttons ── */
body.admin-v2 .btn-soft {
  background: rgba(255,255,255,.07);
  color: var(--adm-text);
  border: 1px solid var(--adm-border);
}
body.admin-v2 .btn-soft:hover { background: rgba(255,255,255,.13); }
body.admin-v2 .btn-primary { background: linear-gradient(120deg,#4f46e5,#6366f1); }
body.admin-v2 .btn-danger {
  background: rgba(239,68,68,.15);
  color: #fca5a5;
  border: 1px solid rgba(239,68,68,.3);
}
body.admin-v2 .btn-success {
  background: rgba(34,197,94,.15);
  color: #86efac;
  border: 1px solid rgba(34,197,94,.3);
}

/* ── Dark messages ── */
body.admin-v2 .msg {
  background: rgba(255,255,255,.05);
  color: var(--adm-muted);
  border: 1px solid var(--adm-border);
}
body.admin-v2 .msg.ok { background: rgba(34,197,94,.12); color: #86efac; border-color: rgba(34,197,94,.3); }
body.admin-v2 .msg.err { background: rgba(239,68,68,.12); color: #fca5a5; border-color: rgba(239,68,68,.3); }

/* ── Dark modals ── */
body.admin-v2 .modal { background: rgba(0,0,0,.65); backdrop-filter: blur(4px); }
body.admin-v2 .modal-card {
  background: #1e293b;
  border: 1px solid var(--adm-border);
  box-shadow: 0 24px 64px rgba(0,0,0,.6);
}
body.admin-v2 .modal-card h3 { color: var(--adm-text); }
body.admin-v2 .modal-card .subtitle { color: var(--adm-muted); }
body.admin-v2 .modal-x { color: var(--adm-muted); }

/* ── Dark trends ── */
body.admin-v2 .trend-up    { color: #86efac; background: rgba(34,197,94,.14);  border-color: rgba(34,197,94,.3); }
body.admin-v2 .trend-down  { color: #fca5a5; background: rgba(239,68,68,.14);  border-color: rgba(239,68,68,.3); }
body.admin-v2 .trend-stable{ color: var(--adm-muted); background: rgba(148,163,184,.1); border-color: var(--adm-border); }
body.admin-v2 .dash-tag-warn { background: rgba(245,158,11,.14); color: #fcd34d; border-color: rgba(245,158,11,.28); }
body.admin-v2 .dash-tag-flag { background: rgba(239,68,68,.12);  color: #fca5a5; border-color: rgba(239,68,68,.25); }

/* ── Dark admin-section-header ── */
body.admin-v2 .admin-section-header { color: var(--adm-muted); }

/* ── Collapsible kid card ── */
.adm-kid-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
  padding: 2px 0 6px;
  flex-wrap: wrap;
}
.adm-kid-card-header:hover .kid-name { color: var(--adm-accent-lt); }
.adm-kid-expand-icon {
  margin-left: auto;
  font-size: 12px;
  color: var(--adm-muted);
  transition: transform .22s ease;
  flex-shrink: 0;
}
.adm-kid-card.expanded .adm-kid-expand-icon { transform: rotate(180deg); }
.adm-kid-details {
  max-height: 0;
  overflow: hidden;
  transition: max-height .3s ease, opacity .22s ease;
  opacity: 0;
}
.adm-kid-card.expanded .adm-kid-details { max-height: 1000px; opacity: 1; }

/* ── Mini correct/wrong bar ── */
.adm-cv-bar {
  display: flex;
  height: 5px;
  border-radius: 999px;
  overflow: hidden;
  margin: 6px 0 2px;
  background: rgba(148,163,184,.12);
}
.adm-cv-correct { background: var(--adm-success); transition: width .3s ease; }
.adm-cv-wrong   { background: var(--adm-danger);  transition: width .3s ease; }

/* ── Accuracy badge ── */
.adm-acc-badge {
  font-size: 11px; font-weight: 800;
  padding: 3px 9px; border-radius: 999px;
  white-space: nowrap;
}
.adm-acc-good { background: rgba(34,197,94,.18);  color: #86efac; }
.adm-acc-mid  { background: rgba(245,158,11,.17); color: #fcd34d; }
.adm-acc-low  { background: rgba(239,68,68,.16);  color: #fca5a5; }

/* ── Response-time badge ── */
.adm-rt-badge {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: 11px; font-weight: 700;
  border-radius: 999px; padding: 3px 9px;
  border: 1px solid transparent; white-space: nowrap;
}
.adm-rt-fast { background: rgba(34,197,94,.14);  color: #86efac; border-color: rgba(34,197,94,.28); }
.adm-rt-med  { background: rgba(245,158,11,.14); color: #fcd34d; border-color: rgba(245,158,11,.26); }
.adm-rt-slow { background: rgba(239,68,68,.12);  color: #fca5a5; border-color: rgba(239,68,68,.24); }

/* ── Chart container ── */
.adm-chart-wrap {
  position: relative;
  background: var(--adm-card);
  border: 1px solid var(--adm-border);
  border-radius: 16px;
  padding: 16px 20px 12px;
  margin-bottom: 20px;
}
.adm-chart-title {
  font-size: 11px; font-weight: 800;
  text-transform: uppercase; letter-spacing: .07em;
  color: var(--adm-muted); margin-bottom: 10px;
}

/* ── Settings section cards ── */
.adm-settings-card {
  background: var(--adm-card);
  border: 1px solid var(--adm-border);
  border-radius: 16px;
  padding: 20px 22px;
  margin-bottom: 16px;
}
.adm-settings-card-title {
  font-size: 14px; font-weight: 800;
  color: var(--adm-text); margin-bottom: 14px;
  display: flex; align-items: center; gap: 8px;
}
.adm-danger-zone { border-color: rgba(239,68,68,.35); }
.adm-danger-zone .adm-settings-card-title { color: #fca5a5; }

/* ── Hamburger (mobile) ── */
.adm-hamburger { display: none; }

/* ── Responsive ── */
@media (max-width: 720px) {
  .adm-sidebar {
    transform: translateX(calc(-1 * var(--adm-sidebar-w)));
    box-shadow: none;
  }
  .adm-sidebar.open {
    transform: translateX(0);
    box-shadow: 6px 0 24px rgba(0,0,0,.55);
  }
  .adm-main { margin-left: 0; }
  .adm-topbar { padding: 0 14px; height: auto; min-height: 56px; padding-top: 8px; padding-bottom: 8px; }
  .adm-content { padding: 14px; }
  .adm-status-row { padding: 0 14px; }
  .adm-hamburger { display: flex; }
}
