:root {
  --bg: #f4f7ff;
  --surface: #ffffff;
  --surface-soft: #f6f7fb;
  --primary: #5b5ce6;
  --primary-dark: #3d40c6;
  --primary-soft: #ecebff;
  --accent: #ffb74d;
  --success: #29b980;
  --danger: #ef6363;
  --text: #16213a;
  --muted: #66718a;
  --border: #e4e8f2;
  --shadow: 0 20px 45px rgba(59, 76, 123, 0.12);
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  min-height: 100%;
  font-family: 'Inter', sans-serif;
  background: linear-gradient(180deg, #eef3ff 0%, #f7f7fb 100%);
  color: var(--text);
}

button, input {
  font: inherit;
}

button {
  cursor: pointer;
}

.auth-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at top, #6e7cf6 0%, #2b2d8a 38%, #171b42 100%);
  padding: 24px;
}

.auth-card {
  width: min(100%, 440px);
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 28px;
  box-shadow: var(--shadow);
  padding: 32px 24px;
  text-align: center;
}

.auth-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-soft);
  color: var(--primary-dark);
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.auth-card h1 {
  margin: 18px 0 8px;
  font-size: clamp(2rem, 2.5vw, 3rem);
  line-height: 1.1;
}

.subtitle {
  margin: 0 0 24px;
  color: var(--muted);
  font-size: 0.96rem;
}

.primary-btn,
.ghost-btn,
.toggle-btn {
  border: none;
  border-radius: 12px;
  padding: 12px 18px;
  font-weight: 700;
  transition: transform 0.18s ease, opacity 0.18s ease;
}

.primary-btn {
  background: linear-gradient(135deg, var(--primary) 0%, #7b66ff 100%);
  color: white;
  width: 100%;
  box-shadow: 0 18px 30px rgba(91, 92, 230, 0.25);
}

.compact-btn {
  width: auto;
  padding: 10px 12px;
  font-size: 0.78rem;
}

.primary-btn:hover,
.ghost-btn:hover,
.toggle-btn:hover {
  transform: translateY(-1px);
}

.demo-note {
  margin-top: 18px;
  color: #8994ac;
  font-size: 0.78rem;
}

.app-shell {
  max-width: 1280px;
  margin: 0 auto;
  padding: 26px 20px 60px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  margin-bottom: 22px;
}

.eyebrow {
  margin: 0;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--primary-dark);
}

.topbar h2 {
  margin: 8px 0 0;
  font-size: clamp(1.8rem, 2vw, 2.6rem);
}

.header-actions {
  display: flex;
  gap: 10px;
}

.ghost-btn {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: 0 10px 20px rgba(17, 24, 39, 0.04);
}

.ghost-btn.danger {
  color: var(--danger);
}

.ghost-btn.small {
  padding: 8px 12px;
  font-size: 0.76rem;
}

.role-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: fit-content;
  background: #ecebff;
  color: var(--primary-dark);
  font-size: 0.76rem;
  font-weight: 800;
  border-radius: 999px;
  padding: 8px 12px;
}

.role-badge.success {
  background: #eafaf3;
  color: #117a50;
}

.app-admin-card {
  border-color: #d8c7ff;
  background: #fbf9ff;
}

.feature-grid {
  align-items: start;
}

.admin-panel {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
  margin-bottom: 24px;
  padding: 20px;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
}

.panel-header h3 {
  margin: 0;
  font-size: 1.15rem;
}

.record-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.record-row {
  display: grid;
  gap: 4px;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-soft);
  font-size: 0.8rem;
}

.record-row span,
.record-row small {
  color: var(--muted);
  line-height: 1.45;
}

.academic-child {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fff;
  overflow: hidden;
}

.academic-child-summary,
.subject-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
  list-style: none;
}

.academic-child-summary::-webkit-details-marker,
.subject-summary::-webkit-details-marker {
  display: none;
}

.academic-child-summary {
  padding: 12px 14px;
  background: #f7f8ff;
  color: var(--text);
}

.academic-child-summary span,
.subject-summary em {
  color: var(--muted);
  font-size: 0.76rem;
  font-style: normal;
}

.subject-stack {
  display: grid;
  gap: 8px;
  padding: 10px;
}

.subject-record {
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

.subject-summary {
  padding: 10px 12px;
  color: var(--text);
  background: #fff;
}

.subject-actions {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: #b6bfd0;
}

.question-chip {
  background: #edf1ff;
  color: var(--primary-dark);
  border-radius: 999px;
  padding: 5px 9px;
  font-size: 0.72rem;
  font-weight: 800;
}

.chapter-stack {
  display: grid;
  gap: 7px;
  padding: 0 10px 10px;
}

.chapter-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 10px;
  border-radius: 6px;
  font-size: 0.8rem;
}

.status-completed { background: #eafaf3; color: #079060; }
.status-current { background: #edf3ff; color: #315fc2; font-weight: 700; }
.status-upcoming { background: #f5f6f8; color: #7c8799; }

.chapter-status {
  font-size: 0.7rem;
  text-transform: capitalize;
  opacity: 0.8;
}

.subject-footnote {
  padding: 3px 2px 0;
  color: var(--muted);
  font-size: 0.72rem;
}

.muted {
  color: var(--muted);
  font-size: 0.8rem;
}

.admin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}

.admin-card {
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.admin-card label {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--muted);
}

.admin-card input {
  width: 100%;
  border-radius: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  background: white;
}

.account-list,
.storage-status {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 0.78rem;
}

.account-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 10px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 10px;
}

.account-row span,
.storage-status {
  color: var(--muted);
}

.toggle-btn {
  background: #dff9ee;
  color: #08794d;
  border: 1px solid #b9f1d5;
}

.toggle-btn.off {
  background: #f6f7fb;
  color: #66718a;
  border-color: var(--border);
}

.content {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.hero {
  background: linear-gradient(135deg, #edf0ff 0%, #f6f1ff 100%);
  border: 1px solid var(--border);
  border-radius: 26px;
  display: grid;
  grid-template-columns: 1.6fr 0.9fr;
  gap: 18px;
  padding: 22px 22px;
  box-shadow: 0 18px 28px rgba(101, 112, 179, 0.08);
}

.hero-copy h3 {
  margin: 18px 0 12px;
  font-size: clamp(1.5rem, 2vw, 2.2rem);
}

.hero-copy p {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

.pill {
  display: inline-flex;
  background: white;
  border: 1px solid var(--border);
  color: var(--primary-dark);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 8px 12px;
  border-radius: 999px;
}

.hero-summary {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 16px;
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 18px;
}

.hero-summary > div {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 10px;
}

.hero-summary > div:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.hero-summary span {
  color: var(--muted);
  font-size: 0.78rem;
}

.hero-summary strong {
  font-size: 1.6rem;
  color: var(--text);
}

.cards-section {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 18px;
}

.child-card {
  background: white;
  border: 1px solid var(--border);
  border-left: 6px solid var(--primary);
  border-radius: 20px;
  box-shadow: 0 18px 28px rgba(17, 24, 39, 0.05);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.card-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.child-name-block {
  display: flex;
  align-items: center;
  gap: 12px;
}

.avatar {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--primary-soft) 0%, #eff5ff 100%);
  display: grid;
  place-items: center;
  font-size: 1.5rem;
}

.child-name {
  font-size: 1.1rem;
  font-weight: 800;
}

.kid-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}

.meta-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #f5f7ff;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 0.72rem;
  font-weight: 600;
}

.vault-pill {
  font-weight: 800;
  color: #0b7a54;
  background: #ebfff5;
  border: 1px solid #baf0d3;
  padding: 8px 10px;
  border-radius: 12px;
  font-size: 0.82rem;
}

.card-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.metric-box {
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 10px;
  text-align: center;
}

.metric-box span {
  display: block;
  font-size: 0.7rem;
  color: var(--muted);
  margin-bottom: 6px;
}

.metric-box strong {
  font-size: 1.05rem;
}

.card-tabs {
  display: flex;
  gap: 8px;
}

.card-tab {
  flex: 1;
  background: #f5f6fb;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
  color: var(--muted);
  font-weight: 700;
  font-size: 0.74rem;
}

.card-tab.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.list-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.list-item {
  background: #f8f9ff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 0.8rem;
  color: var(--muted);
}

.list-item strong {
  color: var(--text);
}

.progress-shell {
  width: 100%;
  height: 10px;
  background: #eef2ff;
  border-radius: 999px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--primary) 0%, #8a7dff 100%);
  border-radius: inherit;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.panel {
  background: white;
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: 0 18px 30px rgba(17, 24, 39, 0.04);
  padding: 18px;
}

.summary-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.summary-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 0.8rem;
}

.summary-row strong {
  font-size: 0.9rem;
}

.mini-chart {
  height: 180px;
  display: flex;
  align-items: end;
}

.bars {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: end;
  gap: 12px;
}

.bar {
  flex: 1;
  border-radius: 12px 12px 0 0;
  background: linear-gradient(180deg, #8d8bff 0%, var(--primary) 100%);
  min-height: 26px;
}

.full-width {
  width: 100%;
}

.ledger-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  padding: 12px 10px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 0.82rem;
}

th {
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.68rem;
}

td strong {
  color: var(--text);
}

.positive {
  color: var(--success);
  font-weight: 700;
}

.negative {
  color: var(--danger);
  font-weight: 700;
}

.hidden {
  display: none !important;
}

@media (max-width: 780px) {
  .hero {
    grid-template-columns: 1fr;
  }

  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .header-actions {
    width: 100%;
    justify-content: flex-start;
  }
}
