/* ═══════════════════════════════════════════════════════════════
   Дневник родителя — Школа Тагиева
   Mobile-first responsive design
   ═══════════════════════════════════════════════════════════════ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --navy:       #021e32;
  --navy2:      #0a3a5a;
  --navy-light: #0f4a72;
  --gold:       #b09058;
  --gold2:      #c8a96e;
  --gold-soft:  #f5ede0;
  --light:      #fff8e6;
  --gray:       #f4f6f9;
  --gray2:      #eef0f3;
  --border:     #e0dcd4;
  --text:       #1a2a3a;
  --mid:        #5a6a7a;
  --soft:       #8a9aaa;
  --green:      #16a34a;
  --green-bg:   #dcfce7;
  --red:        #dc2626;
  --red-bg:     #fee2e2;
  --orange:     #ea580c;
  --orange-bg:  #ffedd5;
  --blue:       #2563eb;
  --shadow-sm:  0 1px 4px rgba(2,30,50,.06);
  --shadow:     0 4px 16px rgba(2,30,50,.1);
  --shadow-lg:  0 12px 40px rgba(2,30,50,.18);
  --radius-sm:  8px;
  --radius:     12px;
  --radius-lg:  20px;
  --trans:      .18s ease;
  /* Safe area for iOS */
  --safe-top:    env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left:   env(safe-area-inset-left, 0px);
  --safe-right:  env(safe-area-inset-right, 0px);
  /* Bottom nav height */
  --bottom-nav-h: 64px;
}

/* ── Base ── */
html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', Arial, sans-serif;
  background: var(--gray);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
a { text-decoration: none; color: inherit; }
img { max-width: 100%; display: block; }
button, input, select, textarea { cursor: pointer; font-family: inherit; }
input, select, textarea { cursor: text; }

/* ══════════════════════════════════════════════════════════════
   AUTH SCREEN
   ══════════════════════════════════════════════════════════════ */

#auth-screen {
  min-height: 100vh; min-height: 100dvh;
  background: linear-gradient(160deg, var(--navy) 0%, var(--navy2) 55%, #0d4c6e 100%);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  padding-top: calc(20px + var(--safe-top));
  padding-bottom: calc(20px + var(--safe-bottom));
}

.auth-box {
  background: #fff;
  border-radius: var(--radius-lg);
  padding: 36px 32px;
  width: 100%; max-width: 420px;
  box-shadow: var(--shadow-lg);
}

.auth-logo { text-align: center; margin-bottom: 24px; }
.auth-logo-icon {
  width: 72px; height: 72px;
  background: linear-gradient(135deg, var(--navy), var(--navy2));
  border-radius: 20px;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 14px;
  font-size: 32px;
  box-shadow: 0 8px 24px rgba(2,30,50,.3);
}
.auth-logo h1 { font-size: 22px; font-weight: 800; color: var(--navy); line-height: 1.2; }
.auth-logo p  { font-size: 13px; color: var(--mid); margin-top: 4px; }

.auth-tabs {
  display: flex; margin-bottom: 24px;
  background: var(--gray); border-radius: 10px; padding: 4px; gap: 4px;
}
.auth-tab {
  flex: 1; padding: 10px; border: none; background: none;
  font-size: 14px; font-weight: 600; color: var(--mid);
  border-radius: 8px; transition: all var(--trans); min-height: 40px;
}
.auth-tab.active {
  background: #fff; color: var(--navy);
  box-shadow: 0 2px 10px rgba(0,0,0,.1);
}

/* ── Forms ── */
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block; font-size: 13px; font-weight: 600;
  color: var(--navy); margin-bottom: 7px;
}
.form-input {
  width: 100%; padding: 13px 16px;
  border: 2px solid var(--border); border-radius: var(--radius-sm);
  font-size: 16px; /* Prevents iOS zoom on focus */
  outline: none; transition: border-color var(--trans), box-shadow var(--trans);
  background: #fff; color: var(--text);
  -webkit-appearance: none; appearance: none;
}
.form-input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(176,144,88,.12);
}
.form-input.error { border-color: var(--red); }
.form-error { font-size: 12px; color: var(--red); margin-top: 6px; }
.form-hint  { font-size: 12px; color: var(--mid); margin-top: 5px; }
.consent-row {
  display: flex; align-items: flex-start; gap: 10px;
  font-size: 13px; color: var(--mid);
}
.consent-row input {
  width: 18px; height: 18px; margin-top: 1px; flex-shrink: 0;
  accent-color: var(--gold); cursor: pointer;
}
.carpool-group-choice {
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.45;
}
.carpool-group-choice span {
  color: var(--ink);
}

/* ══════════════════════════════════════════════════════════════
   BUTTONS
   ══════════════════════════════════════════════════════════════ */

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 8px; padding: 13px 24px; border: none; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 700; cursor: pointer;
  transition: all var(--trans); white-space: nowrap;
  min-height: 48px; /* Touch target */
  -webkit-appearance: none; user-select: none;
}
.btn-primary {
  background: linear-gradient(135deg, var(--navy), var(--navy-light));
  color: #fff; width: 100%;
  box-shadow: 0 4px 12px rgba(2,30,50,.3);
}
.btn-primary:active { transform: scale(.97); opacity: .9; }
.btn-gold {
  background: linear-gradient(135deg, var(--gold), var(--gold2));
  color: #fff;
  box-shadow: 0 4px 12px rgba(176,144,88,.35);
}
.btn-gold:active { transform: scale(.97); }
.btn-outline {
  background: #fff; border: 2px solid var(--border); color: var(--text);
  box-shadow: var(--shadow-sm);
}
.btn-outline:active { border-color: var(--gold); color: var(--gold); }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:active { opacity: .85; }
.btn-ghost { background: none; border: none; color: var(--mid); }
.btn-sm { padding: 8px 16px; font-size: 13px; min-height: 36px; }
.btn-xs { padding: 5px 10px; font-size: 12px; min-height: 28px; border-radius: 6px; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none !important; }

/* ══════════════════════════════════════════════════════════════
   APP LAYOUT — DESKTOP
   ══════════════════════════════════════════════════════════════ */

#app { display: flex; min-height: 100vh; }

/* Sidebar */
#sidebar {
  width: 260px; flex-shrink: 0;
  background: var(--navy);
  display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; bottom: 0;
  z-index: 450;
  overflow-y: auto;
  overflow-x: hidden;
  transition: transform .25s cubic-bezier(.4,0,.2,1),
              box-shadow .25s ease;
}
.sidebar-logo {
  padding: 24px 20px 18px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  flex-shrink: 0;
}
.sidebar-logo-icon {
  width: 42px; height: 42px; border-radius: 12px;
  background: linear-gradient(135deg, var(--gold), var(--gold2));
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; margin-bottom: 12px;
}
.sidebar-logo h2 { font-size: 15px; font-weight: 800; color: #fff; line-height: 1.3; }
.sidebar-logo p  { font-size: 11px; color: rgba(255,255,255,.45); margin-top: 2px; }

.sidebar-nav { padding: 10px 0; flex: 1; }
.nav-section {
  padding: 8px 20px 4px; font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .1em; color: rgba(255,255,255,.3);
}
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 20px; color: rgba(255,255,255,.65);
  font-size: 14px; font-weight: 500;
  transition: all var(--trans); cursor: pointer;
  border: none; background: none; width: 100%; text-align: left;
  min-height: 48px;
}
.nav-item:hover   { background: rgba(255,255,255,.07); color: #fff; }
.nav-item.active  {
  background: rgba(176,144,88,.2); color: var(--gold2);
  border-left: 3px solid var(--gold);
  padding-left: 17px;
}
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }

.sidebar-user {
  padding: 14px 20px;
  border-top: 1px solid rgba(255,255,255,.08);
  display: flex; align-items: center; gap: 12px;
  flex-shrink: 0;
}
.user-avatar {
  width: 38px; height: 38px; border-radius: 50%;
  background: linear-gradient(135deg, var(--gold), var(--gold2));
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 15px; color: #fff; flex-shrink: 0;
}
.user-info { flex: 1; min-width: 0; }
.user-info strong {
  display: block; font-size: 13px; font-weight: 700; color: #fff;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.user-info span { font-size: 11px; color: rgba(255,255,255,.45); }
.btn-logout {
  background: none; border: none; color: rgba(255,255,255,.45);
  cursor: pointer; padding: 8px; border-radius: 8px;
  transition: color var(--trans), background var(--trans);
  flex-shrink: 0;
}
.btn-logout:hover { color: #fff; background: rgba(255,255,255,.08); }

/* Main content */
#main {
  margin-left: 260px; padding: 28px 32px;
  min-height: 100vh; flex: 1;
  max-width: 100%;
}

/* ══════════════════════════════════════════════════════════════
   PAGE COMPONENTS
   ══════════════════════════════════════════════════════════════ */

.page { display: none; }
.page.active { display: block; }

@media (max-width: 768px) {
  .subscription-history-list {
    max-height: 430px;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding-right: 6px;
    scrollbar-gutter: stable;
  }
}

.page-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 24px; flex-wrap: wrap; gap: 12px;
}
.page-header h1 { font-size: 24px; font-weight: 800; color: var(--navy); }
.page-header p  { font-size: 14px; color: var(--mid); margin-top: 3px; }
.page-header-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* Cards */
.card {
  background: #fff; border-radius: var(--radius);
  border: 1px solid var(--border); box-shadow: var(--shadow);
  padding: 22px;
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 18px; gap: 10px;
}
.card-title { font-size: 16px; font-weight: 700; color: var(--navy); }
.card-grid  { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }

/* Stats */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.stat-card {
  background: #fff; border-radius: var(--radius); border: 1px solid var(--border);
  padding: 18px 14px; text-align: center; box-shadow: var(--shadow-sm);
}
.stat-value { font-size: 28px; font-weight: 900; color: var(--navy); line-height: 1.1; }
.stat-label { font-size: 11px; color: var(--mid); margin-top: 6px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .06em; }
.stat-card.green .stat-value { color: var(--green); }
.stat-card.red   .stat-value { color: var(--red); }
.stat-card.gold  .stat-value { color: var(--gold); }

/* Dashboard banner */
.dashboard-banner {
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy2) 60%, #0d5080 100%);
  border-radius: var(--radius); padding: 24px 28px; margin-bottom: 24px;
  display: flex; align-items: center; gap: 18px; color: #fff;
  overflow: hidden; position: relative;
}
.dashboard-banner::after {
  content: ''; position: absolute; right: -20px; top: -20px;
  width: 140px; height: 140px; border-radius: 50%;
  background: rgba(255,255,255,.04);
}
.banner-icon { font-size: 44px; flex-shrink: 0; }
.banner-text h2 { font-size: 20px; font-weight: 800; line-height: 1.2; }
.banner-text p  { font-size: 14px; opacity: .72; margin-top: 4px; }

/* Child cards */
.child-card {
  background: #fff; border-radius: var(--radius); border: 1px solid var(--border);
  box-shadow: var(--shadow); overflow: hidden;
  transition: transform var(--trans), box-shadow var(--trans);
  cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.child-card:active { transform: scale(.98); }
@media (hover: hover) {
  .child-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }
}
.child-card-photo {
  aspect-ratio: 1 / 1;
  background: linear-gradient(135deg, var(--navy), var(--navy2));
  display: flex; align-items: center; justify-content: center;
  font-size: 52px; color: rgba(255,255,255,.25); overflow: hidden;
}
.child-card-photo img { width: 100%; height: 100%; object-fit: cover; object-position: center; }
.child-photo-img--placeholder {
  object-fit: contain !important;
  padding: 12%;
  background: radial-gradient(circle at 50% 35%, rgba(255,255,255,.96), rgba(255,247,222,.88));
}
.child-card-body { padding: 16px; }
.child-card-name { font-size: 16px; font-weight: 700; color: var(--navy); margin-bottom: 4px; }
.child-card-meta { font-size: 13px; color: var(--mid); margin-bottom: 12px; }

/* Badges */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; font-weight: 700; padding: 3px 10px; border-radius: 100px;
  text-transform: uppercase; letter-spacing: .05em;
}
.badge-confirmed { background: var(--green-bg); color: var(--green); }
.badge-pending   { background: #fef3c7; color: #d97706; }
.badge-unlinked  { background: #f1f5f9; color: var(--mid); }
.badge-rejected  { background: var(--red-bg); color: var(--red); }

/* ── Page Tabs ── */
.page-tabs {
  display: flex; margin-bottom: 24px;
  border-bottom: 2px solid var(--border);
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.page-tabs::-webkit-scrollbar { display: none; }
.page-tab {
  padding: 10px 18px; border: none; background: none;
  font-size: 14px; font-weight: 600; color: var(--mid);
  cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -2px;
  transition: all var(--trans); white-space: nowrap; min-height: 44px;
  -webkit-tap-highlight-color: transparent;
}
.page-tab.active { color: var(--navy); border-bottom-color: var(--gold); }

/* ── Table ── */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th {
  padding: 10px 14px; text-align: left; font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .05em;
  color: var(--mid); border-bottom: 2px solid var(--border); white-space: nowrap;
  background: var(--gray); position: sticky; top: 0; z-index: 1;
}
td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
@media (hover: hover) { tr:hover td { background: var(--gray); } }

/* Status pills */
.status-present  { color: var(--green); font-weight: 700; }
.status-absent   { color: var(--red); font-weight: 700; }
.status-excused  { color: var(--orange); font-weight: 700; }
.status-cancelled{ color: var(--mid); }

/* ── Charts ── */
.chart-container { position: relative; }
.chart-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }

/* ── Filter Bar ── */
.filter-bar {
  display: flex; gap: 10px; flex-wrap: wrap;
  margin-bottom: 20px; align-items: center;
}
.filter-bar select, .filter-bar input[type="date"] {
  padding: 10px 14px; border: 2px solid var(--border); border-radius: var(--radius-sm);
  font-size: 14px; outline: none; background: #fff;
  transition: border-color var(--trans);
  min-height: 44px; -webkit-appearance: none; appearance: none;
  color: var(--text);
}
.filter-bar select:focus,
.filter-bar input:focus { border-color: var(--gold); }

/* ── Test Result Row ── */
.test-disc-row {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 0; border-bottom: 1px solid var(--border);
}
.test-disc-row:last-child { border-bottom: none; }
.disc-name  { flex: 1; font-size: 14px; font-weight: 600; color: var(--navy); min-width: 0; }
.disc-val   { font-size: 16px; font-weight: 800; flex-shrink: 0; }
.disc-norm  { font-size: 11px; color: var(--mid); flex-shrink: 0; }
.disc-bar   { flex: 1; height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; min-width: 40px; }
.disc-bar-fill { height: 100%; border-radius: 3px; transition: width .6s ease; }
.fill-good  { background: var(--green); }
.fill-ok    { background: var(--gold); }
.fill-bad   { background: var(--red); }

/* ── Alerts ── */
.alert {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 14px 16px; border-radius: var(--radius-sm);
  font-size: 14px; margin-bottom: 16px; border: 1px solid transparent;
}
.alert-info    { background: #eff6ff; border-color: #bfdbfe; color: #1e40af; }
.alert-warning { background: #fffbeb; border-color: #fde68a; color: #92400e; }
.alert-success { background: #f0fdf4; border-color: #bbf7d0; color: #166534; }
.alert-danger  { background: var(--red-bg); border-color: #fecaca; color: #991b1b; }

/* ── Empty State ── */
.empty-state { text-align: center; padding: 52px 20px; color: var(--mid); }
.empty-icon  { font-size: 52px; margin-bottom: 16px; opacity: .4; }
.empty-state h3 { font-size: 18px; font-weight: 700; color: var(--navy); margin-bottom: 8px; }
.empty-state p  { font-size: 14px; }

/* ── Admin Badge ── */
.admin-badge {
  background: linear-gradient(135deg, var(--gold), var(--gold2));
  color: #fff; padding: 3px 10px; border-radius: 100px;
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
}

/* ══════════════════════════════════════════════════════════════
   MODAL — Slide up from bottom on mobile
   ══════════════════════════════════════════════════════════════ */

.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.55);
  z-index: 1000; display: flex; align-items: center; justify-content: center;
  padding: 20px; opacity: 0; pointer-events: none;
  transition: opacity .22s ease;
}
.modal-overlay.show { opacity: 1; pointer-events: all; }
.modal-box {
  background: #fff; border-radius: var(--radius-lg); padding: 28px;
  width: 100%; max-width: 520px; max-height: 88vh; overflow-y: auto;
  transform: translateY(24px) scale(.98); transition: transform .22s ease;
  -webkit-overflow-scrolling: touch;
}
.modal-overlay.show .modal-box { transform: translateY(0) scale(1); }
.modal-title { font-size: 19px; font-weight: 800; color: var(--navy); margin-bottom: 20px; }
.modal-footer {
  display: flex; gap: 10px; justify-content: flex-end;
  margin-top: 24px; flex-wrap: wrap;
}
.photo-crop-modal .modal-box {
  max-width: 560px;
}
.photo-crop-stage {
  width: min(100%, 360px);
  margin: 0 auto;
  border-radius: 24px;
  overflow: hidden;
  background: linear-gradient(180deg, #0f172a, #1e293b);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.08);
}
.photo-crop-canvas {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  touch-action: none;
  cursor: grab;
}
.photo-crop-canvas.dragging {
  cursor: grabbing;
}
.photo-crop-controls {
  margin-top: 18px;
}
.photo-crop-label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
  font-size: 13px;
  color: var(--mid);
}
.photo-crop-controls input[type="range"] {
  width: 100%;
}
.child-photo-action {
  cursor: pointer;
}

.carpool-range {
  width: 100%;
  height: 22px;
  padding: 0;
  border: 0;
  background: transparent;
  appearance: none;
  -webkit-appearance: none;
}
.carpool-range:focus {
  outline: none;
  box-shadow: none;
}
.carpool-range::-webkit-slider-runnable-track {
  height: 8px;
  border-radius: 999px;
  background: linear-gradient(90deg, #0f4c81 0%, #3b82f6 100%);
  border: 1px solid rgba(2,30,50,.08);
}
.carpool-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  margin-top: -8px;
  border-radius: 8px;
  background: linear-gradient(180deg, #f8fafc 0%, #dbeafe 100%);
  border: 2px solid #0f4c81;
  box-shadow: 0 4px 12px rgba(15,76,129,.22);
}
.carpool-range::-moz-range-track {
  height: 8px;
  border-radius: 999px;
  background: linear-gradient(90deg, #0f4c81 0%, #3b82f6 100%);
  border: 1px solid rgba(2,30,50,.08);
}
.carpool-range::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: 8px;
  background: linear-gradient(180deg, #f8fafc 0%, #dbeafe 100%);
  border: 2px solid #0f4c81;
  box-shadow: 0 4px 12px rgba(15,76,129,.22);
}
.card.carpool-card:hover,
.card.carpool-card:active,
.card.carpool-card:focus-within {
  transform: none;
  box-shadow: var(--shadow);
}

/* ══════════════════════════════════════════════════════════════
   MOBILE HEADER
   ══════════════════════════════════════════════════════════════ */

/* Hidden until logged in — JS adds .authed to body */
#mobile-header {
  display: none;
  position: fixed; top: 0; left: 0; right: 0;
  background: var(--navy);
  padding: 0 16px;
  padding-top: var(--safe-top);
  height: calc(56px + var(--safe-top));
  z-index: 400;
  align-items: center; justify-content: space-between;
  box-shadow: 0 2px 12px rgba(0,0,0,.3);
}
#mobile-header h2 { font-size: 16px; font-weight: 800; color: #fff; }
#mobile-header-title { font-size: 15px; font-weight: 700; color: #fff; flex: 1; text-align: center; }
#burger {
  background: none; border: none; color: #fff; font-size: 22px;
  cursor: pointer; padding: 8px; min-width: 40px; min-height: 40px;
  display: flex; align-items: center; justify-content: center;
}
#mobile-header-logout {
  background: none; border: none; color: #fff;
  cursor: pointer; padding: 8px; min-width: 40px; min-height: 40px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 10px; flex-shrink: 0;
  transition: background var(--trans), color var(--trans);
}
#mobile-header-logout:hover {
  background: rgba(255,255,255,.08);
}

/* Sidebar overlay */
#sidebar-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.55); z-index: 449;
  backdrop-filter: blur(2px);
}

/* ══════════════════════════════════════════════════════════════
   BOTTOM NAV — mobile only
   ══════════════════════════════════════════════════════════════ */

#bottom-nav {
  display: none;
  position: fixed; bottom: 0; left: 0; right: 0;
  height: calc(var(--bottom-nav-h) + var(--safe-bottom));
  background: #fff;
  border-top: 1px solid var(--border);
  z-index: 400;
  padding-bottom: var(--safe-bottom);
  box-shadow: 0 -4px 20px rgba(2,30,50,.1);
}
.bottom-nav-inner {
  display: flex; height: var(--bottom-nav-h);
  padding: 0 4px;
}
.bottom-nav-item {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 3px;
  background: none; border: none; cursor: pointer;
  color: var(--mid); font-size: 11px; font-weight: 500;
  transition: color var(--trans); padding: 6px 4px;
  min-height: var(--bottom-nav-h);
  -webkit-tap-highlight-color: transparent;
  position: relative;
}
.bottom-nav-item svg { width: 22px; height: 22px; transition: transform .15s ease; }
.bottom-nav-item.active { color: var(--navy); }
.bottom-nav-item.active svg { transform: scale(1.1); }
.bottom-nav-item.active::before {
  content: ''; position: absolute;
  top: 6px; left: 50%; transform: translateX(-50%);
  width: 32px; height: 3px; border-radius: 2px;
  background: var(--gold);
}
.bottom-nav-badge {
  position: absolute; top: 6px; right: calc(50% - 14px);
  background: var(--red); color: #fff;
  font-size: 9px; font-weight: 800; min-width: 16px; height: 16px;
  border-radius: 8px; padding: 0 4px;
  display: flex; align-items: center; justify-content: center;
  line-height: 1;
}

/* ══════════════════════════════════════════════════════════════
   UTILITIES
   ══════════════════════════════════════════════════════════════ */

.spinner {
  display: inline-block; width: 20px; height: 20px;
  border: 2px solid rgba(255,255,255,.3); border-top-color: #fff;
  border-radius: 50%; animation: spin .65s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.mt-2  { margin-top: 8px; }
.mt-4  { margin-top: 16px; }
.mt-6  { margin-top: 24px; }
.mb-2  { margin-bottom: 8px; }
.mb-4  { margin-bottom: 16px; }
.flex  { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.text-mid   { color: var(--mid); }
.text-sm    { font-size: 13px; }
.text-xs    { font-size: 11px; }
.font-bold  { font-weight: 700; }
.text-navy  { color: var(--navy); }
.text-gold  { color: var(--gold); }
.text-green { color: var(--green); }
.text-red   { color: var(--red); }
.divider    { height: 1px; background: var(--border); margin: 16px 0; }
.truncate   { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ══════════════════════════════════════════════════════════════
   RESPONSIVE — TABLET (≤1024px)
   ══════════════════════════════════════════════════════════════ */

@media (max-width: 1024px) {
  #sidebar { width: 220px; }
  #main { margin-left: 220px; padding: 24px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ══════════════════════════════════════════════════════════════
   RESPONSIVE — MOBILE (≤768px)
   ══════════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
  /* Show mobile header */
  body.authed #mobile-header { display: flex; }

  /* Show bottom nav only when logged in */
  body.authed #bottom-nav { display: block; }

  /* App layout */
  #app { display: block; }

  /* Sidebar — drawer */
  #sidebar {
    width: 280px;
    transform: translateX(-100%);
    top: 0;
    padding-top: 0;
    box-shadow: none;
  }
  #sidebar .sidebar-logo {
    padding-top: calc(var(--safe-top) + 24px);
  }
  #sidebar.open {
    transform: translateX(0);
    box-shadow: 8px 0 32px rgba(0,0,0,.4);
  }
  #sidebar-overlay.show { display: block; }

  /* Main — add top and bottom padding */
  #main {
    margin-left: 0;
    padding: 16px;
    padding-top: calc(56px + var(--safe-top) + 16px);
    padding-bottom: calc(var(--bottom-nav-h) + var(--safe-bottom) + 16px);
  }

  /* Charts — single column */
  .chart-row { grid-template-columns: 1fr; gap: 12px; }

  /* Stats — 2 columns */
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat-value { font-size: 24px; }
  .stat-card  { padding: 14px 12px; }

  /* Cards — full width */
  .card-grid { grid-template-columns: 1fr; gap: 12px; }
  .card { padding: 18px; }

  /* Page header */
  .page-header { flex-direction: column; align-items: flex-start; gap: 10px; }
  .page-header h1 { font-size: 20px; }

  /* Dashboard banner */
  .dashboard-banner {
    padding: 18px 20px; gap: 14px;
    flex-wrap: wrap;
  }
  .banner-icon { font-size: 36px; }
  .banner-text h2 { font-size: 17px; }
  .banner-text p  { font-size: 13px; }

  /* Auth */
  .auth-box { padding: 28px 20px; border-radius: 20px; }
  .form-input { font-size: 16px; } /* Keep 16px to prevent iOS zoom */

  /* Tabs — scrollable */
  .page-tabs { gap: 0; }
  .page-tab  { padding: 10px 14px; font-size: 13px; }

  /* Modal — full-width bottom sheet */
  .modal-overlay {
    align-items: flex-end;
    padding: 0;
    padding-bottom: calc(var(--safe-bottom));
  }
  .modal-box {
    max-width: 100%;
    border-radius: 20px 20px 0 0;
    max-height: 92vh;
    padding: 24px 20px;
    transform: translateY(100%);
  }
  .modal-overlay.show .modal-box { transform: translateY(0); }
  .modal-footer { flex-direction: column-reverse; }
  .modal-footer .btn { width: 100%; }
  .photo-crop-modal {
    align-items: flex-end;
  }
  .photo-crop-modal .modal-box {
    max-width: 100%;
    border-radius: 24px 24px 0 0;
    padding: 20px 18px calc(20px + var(--safe-bottom));
  }
  .photo-crop-stage {
    width: min(100%, 320px);
  }

  /* Tables — mobile optimized */
  .table-wrap { border-radius: 0; margin: 0 -18px; width: calc(100% + 36px); }
  th { font-size: 10px; padding: 8px 12px; }
  td { padding: 10px 12px; font-size: 13px; }

  /* Filter bar */
  .filter-bar { gap: 8px; }
  .filter-bar select, .filter-bar input[type="date"] {
    font-size: 14px; padding: 9px 12px;
  }

  /* Test disc row — compact */
  .test-disc-row { gap: 8px; padding: 10px 0; }
  .disc-name  { font-size: 13px; }
  .disc-val   { font-size: 15px; }
  .disc-norm  { display: none; } /* Hide on mobile to save space */
  .disc-bar   { min-width: 30px; }

  /* Buttons */
  .btn-sm { padding: 9px 16px; font-size: 13px; min-height: 40px; }

  /* Admin badge */
  .admin-badge { font-size: 10px; padding: 2px 8px; }
}

/* ══════════════════════════════════════════════════════════════
   RESPONSIVE — SMALL MOBILE (≤400px)
   ══════════════════════════════════════════════════════════════ */

@media (max-width: 400px) {
  :root { font-size: 14px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .stat-value { font-size: 22px; }
  .stat-label { font-size: 10px; }
  .bottom-nav-item { font-size: 10px; }
  .auth-box { padding: 24px 16px; }
  #mobile-header { padding-left: 12px; padding-right: 12px; }
  #mobile-header-title { font-size: 14px; }
}

/* ══════════════════════════════════════════════════════════════
   PWA — Standalone / fullscreen
   ══════════════════════════════════════════════════════════════ */

@media (display-mode: standalone) {
  #mobile-header {
    padding-top: max(var(--safe-top), 10px);
    height: calc(56px + max(var(--safe-top), 10px));
  }
  #main {
    padding-top: calc(56px + max(var(--safe-top), 10px) + 16px);
  }
}

/* ══════════════════════════════════════════════════════════════
   TOAST NOTIFICATION
   ══════════════════════════════════════════════════════════════ */

#toast {
  position: fixed; bottom: calc(var(--bottom-nav-h) + var(--safe-bottom) + 12px);
  left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--navy); color: #fff;
  padding: 12px 22px; border-radius: 100px;
  font-size: 14px; font-weight: 600;
  opacity: 0; transition: all .3s ease;
  z-index: 9999; white-space: nowrap;
  pointer-events: none; max-width: 90vw;
  text-align: center; box-shadow: var(--shadow-lg);
}
#toast.toast-success { background: var(--green); }
#toast.toast-error   { background: var(--red); }
#toast.toast-warn    { background: #d97706; }

@media (min-width: 769px) {
  #toast { bottom: 24px; }
}

/* ══════════════════════════════════════════════════════════════
   SCROLL IMPROVEMENTS
   ══════════════════════════════════════════════════════════════ */

.scroll-x {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.scroll-x::-webkit-scrollbar { display: none; }

/* Focus visible styles */
:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

/* Prevent focus ring for mouse users */
:focus:not(:focus-visible) { outline: none; }

/* ══════════════════════════════════════════════════════════════
   CHILD DASHBOARD GRID
   ══════════════════════════════════════════════════════════════ */
.child-dashboard-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  margin-top: 16px;
}
@media (min-width: 768px) {
  .child-dashboard-grid {
    grid-template-columns: 1fr 1fr;
    gap: 24px;
  }
}

.child-block-card {
  background: #fff;
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.04);
  display: flex;
  flex-direction: column;
}

.card-header-flex {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.child-header-card {
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy2) 100%);
  color: #fff;
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 4px 15px rgba(2,30,50,0.2);
}

.child-header-content {
  display: flex;
  align-items: center;
  gap: 20px;
}

.child-photo-wrap {
  width: clamp(92px, 18vw, 124px);
  aspect-ratio: 1 / 1;
  border-radius: 18px;
  overflow: hidden;
  flex-shrink: 0;
  border: 2px solid rgba(255,255,255,0.2);
  background: rgba(255,255,255,0.1);
}
.child-photo-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}
.child-photo-wrap img.child-photo-img--placeholder {
  padding: 12%;
  background: radial-gradient(circle at 50% 35%, rgba(255,255,255,.98), rgba(255,247,222,.9));
}

.child-info h1 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 4px;
  color: #fff;
}
.child-info p {
  color: rgba(255,255,255,0.8);
  font-size: 0.9rem;
  margin-bottom: 2px;
}

.test-summary-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  background: var(--gray);
  border-radius: 8px;
}
.test-summary-item .disc-name {
  font-weight: 600;
  font-size: 0.9rem;
}
.test-summary-item .disc-val {
  font-weight: 700;
  font-size: 1.1rem;
}
.test-summary-item .disc-trend {
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  gap: 4px;
}
.trend-up { color: var(--green); }
.trend-down { color: var(--red); }
.trend-flat { color: var(--mid); }

.trainer-comment-box {
  display: flex;
  gap: 12px;
  background: var(--gray);
  padding: 16px;
  border-radius: 12px;
}
.trainer-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--navy);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  flex-shrink: 0;
}
.trainer-msg {
  flex: 1;
}
.trainer-msg-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 4px;
}
.trainer-name {
  font-weight: 600;
  font-size: 0.9rem;
}
.trainer-date {
  font-size: 0.8rem;
  color: var(--muted);
}
.trainer-text {
  font-size: 0.9rem;
  color: var(--text);
  white-space: pre-wrap;
}

.progress-bar-wrap {
  width: 100%;
  background: var(--gray2);
  border-radius: 99px;
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  border-radius: 99px;
  transition: width 0.5s ease;
}

.history-accordion {
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 8px;
  background: #fff;
  overflow: hidden;
}
.history-summary {
  padding: 12px 16px;
  cursor: pointer;
  font-weight: 600;
  display: flex;
  align-items: center;
  list-style: none;
  background: var(--gray);
}
.history-summary::-webkit-details-marker {
  display: none;
}
.history-summary::after {
  content: '▸';
  margin-left: 8px;
  color: var(--muted);
  transition: transform 0.2s;
}
details[open] > .history-summary::after {
  transform: rotate(90deg);
}
.history-content {
  padding: 16px;
  border-top: 1px solid var(--border);
}

/* ── Test Results Redesign ────────────────────── */
.skill-score-row {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 16px;
}
.skill-gauge-wrap {
  position: relative;
  width: 110px;
  height: 70px;
  flex-shrink: 0;
}
.skill-gauge-wrap canvas {
  display: block;
}
.skill-gauge-label {
  position: absolute;
  bottom: -2px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 1.3rem;
  font-weight: 900;
  line-height: 1;
  text-align: center;
}
.skill-score-info {
  flex: 1;
}
.skill-title {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
  font-weight: 600;
}
.skill-trend-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.85rem;
  font-weight: 700;
  margin-top: 6px;
  padding: 3px 10px;
  border-radius: 99px;
  background: var(--gray);
}

/* Radar chart container */
.radar-wrap {
  height: 200px;
  margin: 0 -4px 12px;
}

/* Discipline result rows */
.disc-result-row {
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.disc-result-row:last-child { border-bottom: none; }
.disc-result-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
  gap: 8px;
}
.disc-result-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--navy);
  flex: 1;
}
.disc-result-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.disc-result-val {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--navy);
}
.disc-result-unit {
  font-size: 0.75rem;
  color: var(--muted);
  font-weight: 400;
}
.disc-result-pct {
  font-size: 0.85rem;
  font-weight: 800;
  min-width: 38px;
  text-align: right;
}
.disc-result-trend {
  font-size: 0.78rem;
  font-weight: 700;
  min-width: 36px;
  text-align: right;
}
.disc-bar-track {
  height: 5px;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
}
.disc-bar-prog {
  height: 100%;
  border-radius: 99px;
  transition: width 0.7s cubic-bezier(.25,.8,.25,1);
}

/* Ask trainer modal */
.ask-trainer-modal .modal-box {
  max-width: 420px;
}

@media (max-width: 600px) {
  .skill-score-row { gap: 12px; }
  .skill-gauge-wrap { width: 90px; height: 58px; }
  .skill-gauge-label { font-size: 1.1rem; }
  .radar-wrap { height: 170px; }
}
/* ── Premium Overrides ── */
:root {
  --bg: #f3f6f9;
  --navy: #0f172a;
  --navy2: #1e293b;
  --navy-light: #334155;
  --gold: #d4af37;
  --gold2: #fef08a;
  --gold-soft: rgba(212, 175, 55, 0.1);
  --gray: #ffffff;
  --gray2: #f8fafc;
  --border: #e2e8f0;
  --text: #1e293b;
  --mid: #64748b;
  --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
  --shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -2px rgba(0, 0, 0, 0.025);
  --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.05), 0 10px 10px -5px rgba(0, 0, 0, 0.02);
  --radius-lg: 24px;
  --radius: 16px;
}

body {
  background: var(--bg);
  background-image: radial-gradient(circle at 50% 0%, #ffffff 0%, transparent 70%);
  background-attachment: fixed;
}

.card, .child-block-card {
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.6);
  box-shadow: var(--shadow);
  border-radius: var(--radius-lg);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.card:hover, .child-block-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

.child-header-card {
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%) !important;
  border: 1px solid rgba(255,255,255,0.1);
  position: relative;
  overflow: hidden;
  box-shadow: 0 15px 35px rgba(15, 23, 42, 0.2);
}

.child-header-card::before {
  content: '';
  position: absolute;
  top: -50%; right: -20%;
  width: 300px; height: 300px;
  background: radial-gradient(circle, rgba(212,175,55,0.15) 0%, transparent 70%);
  border-radius: 50%;
  pointer-events: none;
}
.child-header-card::after {
  content: '';
  position: absolute;
  bottom: -30%; left: -10%;
  width: 250px; height: 250px;
  background: radial-gradient(circle, rgba(56,189,248,0.1) 0%, transparent 70%);
  border-radius: 50%;
  pointer-events: none;
}

.child-photo-wrap img {
  border: 3px solid var(--gold);
  box-shadow: 0 0 20px rgba(212, 175, 55, 0.3);
  transform: none;
}

.child-info h1 {
  font-size: 1.8rem !important;
  font-weight: 900 !important;
  letter-spacing: -0.5px;
  text-shadow: 0 2px 10px rgba(0,0,0,0.5);
  margin-bottom: 8px !important;
}

/* Premium Badges */
.premium-badges {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.premium-badge {
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.2);
  backdrop-filter: blur(4px);
  padding: 4px 10px;
  border-radius: 99px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}
.premium-badge.gold {
  background: linear-gradient(135deg, rgba(212,175,55,0.2), rgba(212,175,55,0.05));
  border-color: rgba(212,175,55,0.4);
  color: #fef08a;
}

/* Stats Cards */
.stat-card {
  background: linear-gradient(135deg, #ffffff, #f8fafc);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  border-radius: var(--radius);
}
.stat-card.green {
  background: linear-gradient(135deg, #f0fdf4, #dcfce7);
  border-color: #bbf7d0;
}
.stat-card.gold {
  background: linear-gradient(135deg, #fefce8, #fef08a);
  border-color: #fde047;
}

/* Progress Bars */
.progress-bar-wrap {
  background: #e2e8f0;
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.1);
}
.progress-bar-fill {
  background: linear-gradient(90deg, #d4af37, #fef08a);
  box-shadow: 0 0 10px rgba(212, 175, 55, 0.4);
  position: relative;
}
.progress-bar-fill::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent);
  animation: shimmer 2s infinite;
}

/* Animations */
@keyframes shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.child-dashboard-grid > div {
  animation: fadeUp 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  opacity: 0;
}
.child-dashboard-grid > div:nth-child(1) { animation-delay: 0.0s; }
.child-dashboard-grid > div:nth-child(2) { animation-delay: 0.1s; }
.child-dashboard-grid > div:nth-child(3) { animation-delay: 0.2s; }
.child-dashboard-grid > div:nth-child(4) { animation-delay: 0.3s; }
.child-dashboard-grid > div:nth-child(5) { animation-delay: 0.4s; }
.child-dashboard-grid > div:nth-child(6) { animation-delay: 0.5s; }

/* Test Results Enhancements */
.disc-result-row {
  transition: background 0.2s;
  padding: 10px 8px;
  border-radius: 8px;
  border-bottom: none;
  margin-bottom: 4px;
}
.disc-result-row:hover {
  background: rgba(15, 23, 42, 0.02);
}
.disc-bar-track {
  background: #e2e8f0;
  height: 6px;
}
.disc-bar-prog {
  box-shadow: 0 0 8px currentColor;
  opacity: 0.9;
}

/* Rating Enhancements */
#rating-place {
  background: linear-gradient(135deg, #d4af37, #b48529);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 4px 12px rgba(212, 175, 55, 0.2);
}

.card-title {
  font-weight: 800;
  letter-spacing: -0.3px;
  display: flex;
  align-items: center;
  gap: 8px;
}
/* ── Premium Overrides ── */
:root {
  --bg: #f3f6f9;
  --navy: #0f172a;
  --navy2: #1e293b;
  --navy-light: #334155;
  --gold: #d4af37;
  --gold2: #fef08a;
  --gold-soft: rgba(212, 175, 55, 0.1);
  --gray: #ffffff;
  --gray2: #f8fafc;
  --border: #e2e8f0;
  --text: #1e293b;
  --mid: #64748b;
  --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
  --shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -2px rgba(0, 0, 0, 0.025);
  --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.05), 0 10px 10px -5px rgba(0, 0, 0, 0.02);
  --radius-lg: 24px;
  --radius: 16px;
}

body {
  background: var(--bg);
  background-image: radial-gradient(circle at 50% 0%, #ffffff 0%, transparent 70%);
  background-attachment: fixed;
}

.card, .child-block-card {
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.6);
  box-shadow: var(--shadow);
  border-radius: var(--radius-lg);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.card:hover, .child-block-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

.child-header-card {
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%) !important;
  border: 1px solid rgba(255,255,255,0.1);
  position: relative;
  overflow: hidden;
  box-shadow: 0 15px 35px rgba(15, 23, 42, 0.2);
}

.child-header-card::before {
  content: '';
  position: absolute;
  top: -50%; right: -20%;
  width: 300px; height: 300px;
  background: radial-gradient(circle, rgba(212,175,55,0.15) 0%, transparent 70%);
  border-radius: 50%;
  pointer-events: none;
}
.child-header-card::after {
  content: '';
  position: absolute;
  bottom: -30%; left: -10%;
  width: 250px; height: 250px;
  background: radial-gradient(circle, rgba(56,189,248,0.1) 0%, transparent 70%);
  border-radius: 50%;
  pointer-events: none;
}

.child-photo-wrap img {
  border: 3px solid var(--gold);
  box-shadow: 0 0 20px rgba(212, 175, 55, 0.3);
  transform: none;
}

.child-info h1 {
  font-size: 1.8rem !important;
  font-weight: 900 !important;
  letter-spacing: -0.5px;
  text-shadow: 0 2px 10px rgba(0,0,0,0.5);
  margin-bottom: 8px !important;
}

/* Premium Badges */
.premium-badges {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.premium-badge {
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.2);
  backdrop-filter: blur(4px);
  padding: 4px 10px;
  border-radius: 99px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}
.premium-badge.gold {
  background: linear-gradient(135deg, rgba(212,175,55,0.2), rgba(212,175,55,0.05));
  border-color: rgba(212,175,55,0.4);
  color: #fef08a;
}

/* Stats Cards */
.stat-card {
  background: linear-gradient(135deg, #ffffff, #f8fafc);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  border-radius: var(--radius);
}
.stat-card.green {
  background: linear-gradient(135deg, #f0fdf4, #dcfce7);
  border-color: #bbf7d0;
}
.stat-card.gold {
  background: linear-gradient(135deg, #fefce8, #fef08a);
  border-color: #fde047;
}

/* Progress Bars */
.progress-bar-wrap {
  background: #e2e8f0;
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.1);
}
.progress-bar-fill {
  background: linear-gradient(90deg, #d4af37, #fef08a);
  box-shadow: 0 0 10px rgba(212, 175, 55, 0.4);
  position: relative;
}
.progress-bar-fill::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent);
  animation: shimmer 2s infinite;
}

/* Animations */
@keyframes shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.child-dashboard-grid > div {
  animation: fadeUp 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  opacity: 0;
}
.child-dashboard-grid > div:nth-child(1) { animation-delay: 0.0s; }
.child-dashboard-grid > div:nth-child(2) { animation-delay: 0.1s; }
.child-dashboard-grid > div:nth-child(3) { animation-delay: 0.2s; }
.child-dashboard-grid > div:nth-child(4) { animation-delay: 0.3s; }
.child-dashboard-grid > div:nth-child(5) { animation-delay: 0.4s; }
.child-dashboard-grid > div:nth-child(6) { animation-delay: 0.5s; }

/* Test Results Enhancements */
.disc-result-row {
  transition: background 0.2s;
  padding: 10px 8px;
  border-radius: 8px;
  border-bottom: none;
  margin-bottom: 4px;
}
.disc-result-row:hover {
  background: rgba(15, 23, 42, 0.02);
}
.disc-bar-track {
  background: #e2e8f0;
  height: 6px;
}
.disc-bar-prog {
  box-shadow: 0 0 8px currentColor;
  opacity: 0.9;
}

/* Rating Enhancements */
#rating-place {
  background: linear-gradient(135deg, #d4af37, #b48529);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 4px 12px rgba(212, 175, 55, 0.2);
}

.card-title {
  font-weight: 800;
  letter-spacing: -0.3px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Empty States */
.empty-state {
  background: rgba(255,255,255,0.5);
  border: 1px dashed rgba(0,0,0,0.1);
  border-radius: var(--radius-lg);
  padding: 40px 20px;
}
.empty-icon {
  font-size: 3rem;
  margin-bottom: 16px;
  opacity: 0.8;
  filter: drop-shadow(0 4px 6px rgba(0,0,0,0.1));
}


/* Messages */
.messages-nav-icon-wrap {
  position: relative;
  display: inline-flex;
}
.messages-nav-badge {
  position: absolute;
  top: -6px;
  right: -10px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: #ef4444;
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 16px rgba(239, 68, 68, 0.28);
}
#nav-messages > span:last-child {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
#messages-badge-sidebar {
  position: static;
  margin-left: 0;
  transform: translateY(-1px);
  box-shadow: none;
}
.messages-unread-pill {
  min-width: 22px;
  height: 22px;
  padding: 0 7px;
  border-radius: 999px;
  background: #ef4444;
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: .78rem;
  font-weight: 800;
}
.messages-thread-card {
  background: rgba(255,255,255,0.94);
  border: 1px solid rgba(15, 76, 129, 0.10);
  border-radius: 22px;
  box-shadow: 0 18px 50px rgba(2, 30, 50, 0.08);
  padding: 16px;
  height: min(920px, calc(100dvh - 150px));
  min-height: 600px;
  overflow: hidden;
  box-sizing: border-box;
  display: block;
  gap: 14px;
}
.messages-thread-card > #messages-thread-panel {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 14px;
  min-height: 0;
  height: 100%;
  min-width: 0;
}
.messages-thread-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(15, 76, 129, 0.08);
}
.messages-thread-title {
  font-size: 1.02rem;
  font-weight: 800;
  color: #0f172a;
}
.messages-thread-subtitle {
  margin-top: 4px;
  color: #64748b;
  font-size: .88rem;
}
.messages-bubbles {
  display: grid;
  gap: 12px;
  align-content: start;
  overflow: auto;
  min-height: 0;
  max-height: none;
  padding-right: 4px;
}
.messages-bubble-row {
  display: flex;
}
.messages-bubble-row.mine {
  justify-content: flex-end;
}
.messages-bubble {
  max-width: min(100%, 560px);
  border-radius: 20px;
  padding: 12px 14px;
  box-shadow: 0 10px 24px rgba(2, 30, 50, 0.08);
}
.messages-bubble.admin {
  background: linear-gradient(180deg, #0f4c81, #0a375c);
  color: #fff;
}
.messages-bubble.parent {
  background: linear-gradient(180deg, #fff8eb, #ffffff);
  border: 1px solid rgba(212, 175, 55, 0.24);
  color: #0f172a;
}
.messages-bubble-meta {
  margin-bottom: 6px;
  font-size: .76rem;
  opacity: .78;
}
.messages-bubble-text {
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.55;
}
.messages-compose {
  display: grid;
  gap: 10px;
  padding-top: 14px;
  border-top: 1px solid rgba(15, 76, 129, 0.10);
}
.messages-compose textarea {
  min-height: 96px;
  resize: vertical;
  border: 1px solid rgba(15, 76, 129, 0.18);
  border-radius: 14px;
  background: #f8fafc;
  box-shadow: inset 0 1px 2px rgba(2, 30, 50, 0.04);
}
.messages-compose-actions {
  display: flex;
  justify-content: flex-end;
}
.messages-empty {
  padding: 40px 22px;
  border: 1px dashed rgba(15, 76, 129, 0.16);
  border-radius: 20px;
  background: rgba(255,255,255,0.7);
  text-align: center;
  color: #64748b;
}

/* Roll call */
.roll-call-card { max-width: 680px; padding: 24px; }
.roll-call-fields { display:grid; grid-template-columns:1fr 1fr; gap:16px; }
.roll-call-help { color:var(--mid); font-size:.9rem; margin:2px 0 18px; }
.roll-call-actions { display:grid; grid-template-columns:1fr 1fr; gap:14px; }
.roll-call-choice { border:0; border-radius:14px; padding:16px 12px; color:#fff; font-size:1rem; font-weight:800; cursor:pointer; display:flex; align-items:center; justify-content:center; gap:9px; transition:.15s ease; }
.roll-call-choice span { width:25px; height:25px; border-radius:50%; background:rgba(255,255,255,.2); display:inline-flex; align-items:center; justify-content:center; font-size:1.15rem; }
.roll-call-choice.coming { background:#16a34a; }
.roll-call-choice.not-coming { background:#dc2626; }
.roll-call-choice:hover { transform:translateY(-1px); filter:brightness(.96); }
.roll-call-choice:disabled { opacity:.55; cursor:wait; transform:none; }

/* Desktop information cards should stay in place on hover. */
@media (hover: hover) and (min-width: 769px) {
  .card,
  .child-block-card,
  .child-card {
    transition-property: box-shadow, border-color;
  }

  .card:hover,
  .child-block-card:hover,
  .child-card:hover {
    transform: none;
  }
}

.pwa-pull-refresh-indicator {
  position: fixed;
  top: calc(56px + var(--safe-top) + 10px);
  left: 50%;
  z-index: 950;
  padding: 7px 13px;
  border: 1px solid rgba(2,30,50,.1);
  border-radius: 999px;
  background: #fff;
  color: var(--mid);
  box-shadow: var(--shadow);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, -18px);
  transition: opacity .15s ease, transform .15s ease;
}
.pwa-pull-refresh-indicator.visible {
  opacity: 1;
  transform: translate(-50%, 0);
}
.roll-call-history { max-width:680px; margin-top:22px; }
.roll-call-history h3 { color:var(--navy); font-size:1rem; margin-bottom:10px; }
.roll-call-history-item { display:flex; align-items:center; gap:12px; padding:12px 14px; margin-bottom:8px; background:#fff; border:1px solid var(--border); border-radius:12px; font-size:.85rem; }
.roll-call-history-item > div { flex:1; min-width:0; }
.roll-call-history-item strong { display:block; color:var(--navy); }
.roll-call-status { width:30px; height:30px; flex:0 0 30px; border-radius:50%; color:#fff; display:flex; align-items:center; justify-content:center; font-weight:900; }
.roll-call-status.coming { background:#16a34a; }
.roll-call-status.not-coming { background:#dc2626; }
.roll-call-answer-label { font-weight:700; white-space:nowrap; }

@media (max-width: 600px) {
  .messages-thread-card {
    height: calc(100dvh - 130px);
    min-height: 500px;
    padding: 12px;
    border-radius: 16px;
  }
  html.standalone-pwa .messages-thread-card {
    height: calc(100dvh - 152px - max(var(--safe-top), 10px) - var(--safe-bottom));
    min-height: 0;
  }
  .messages-thread-card > #messages-thread-panel { min-height: 0; gap: 12px; }
  .messages-compose { padding-top: 12px; }
  .messages-compose textarea { min-height: 78px; }
  .roll-call-card { padding:18px 14px; }
  .roll-call-fields { grid-template-columns:1fr; gap:0; }
  .roll-call-actions { gap:9px; }
  .roll-call-choice { padding:15px 8px; font-size:.92rem; }
  .bottom-nav-item { min-width:0; padding-left:2px; padding-right:2px; }
}

