:root {
  --primary: #6C5CE7;
  --primary-dark: #5A4BD6;
  --primary-light: #EDE9FE;
  --green: #10B981;
  --green-dark: #0E9F71;
  --green-light: #D1FAE5;
  --cream: #FFF8EC;
  --yellow: #F5B921;
  --red: #EF4444;
  --ink: #1F2333;
  --muted: #7A7F93;
  --border: #ECEAF5;
  --bg: #F7F6FB;
  --card: #FFFFFF;
  --radius: 18px;
  --radius-sm: 12px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Segoe UI', 'Poppins', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

a { text-decoration: none; color: inherit; }

.app-shell {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--bg);
  position: relative;
  padding-bottom: 88px;
}

/* ===== Top App Bar ===== */
.topbar {
  padding: 22px 20px 18px;
  color: #fff;
  border-radius: 0 0 28px 28px;
}
.topbar.purple { background: linear-gradient(135deg, var(--primary), var(--primary-dark)); }
.topbar.green { background: linear-gradient(135deg, var(--green), var(--green-dark)); }
.topbar.plain { background: transparent; color: var(--ink); padding-bottom: 8px; }

.topbar-row { display: flex; align-items: center; justify-content: space-between; }
.topbar-title { font-size: 17px; font-weight: 700; }
.topbar-sub { font-size: 12.5px; opacity: .9; margin-top: 2px; }
.back-btn { font-size: 20px; color: #fff; background: rgba(255,255,255,.18); width: 34px; height: 34px; border-radius: 50%; display:flex; align-items:center; justify-content:center; border:none; cursor:pointer; }
.plain .back-btn { color: var(--ink); background: #fff; box-shadow: 0 2px 8px rgba(0,0,0,.06);}
.icon-btn { background: rgba(255,255,255,.18); border:none; color:#fff; width:34px; height:34px; border-radius:50%; display:flex; align-items:center; justify-content:center; cursor:pointer; font-size:16px;}

/* ===== Content ===== */
.content { padding: 16px 18px 8px; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: 0 4px 18px rgba(31, 35, 51, 0.04);
  border: 1px solid var(--border);
  margin-bottom: 14px;
}

.section-title { font-size: 15px; font-weight: 700; margin: 18px 0 10px; color: var(--ink); }
.section-title.first { margin-top: 4px; }

/* ===== Grid of category tiles ===== */
.tile-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.tile {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 6px;
  text-align: center;
  cursor: pointer;
  transition: transform .1s;
}
.tile:active { transform: scale(.96); }
.tile .emoji { font-size: 26px; display:block; margin-bottom: 6px; }
.tile .label { font-size: 11.5px; font-weight: 600; color: var(--ink); line-height: 1.25; }
.tile .pct { font-size: 10.5px; color: var(--muted); margin-top: 2px; }

/* ===== Progress bar ===== */
.progressbar { background: #EEECF9; border-radius: 20px; height: 8px; overflow: hidden; }
.progressbar > span { display:block; height:100%; border-radius:20px; background: linear-gradient(90deg, var(--primary), #9B8CFB); }
.progressbar.green > span { background: linear-gradient(90deg, var(--green), #34D399); }

/* ===== Child list card ===== */
.child-row {
  display:flex; align-items:center; gap:12px;
  background: var(--card); border:1px solid var(--border); border-radius: var(--radius-sm);
  padding: 12px; margin-bottom: 10px; cursor:pointer;
}
.child-avatar { font-size: 30px; width:52px; height:52px; border-radius:50%; background: var(--primary-light); display:flex; align-items:center; justify-content:center; flex-shrink:0;}
.child-row .info { flex:1; min-width:0; }
.child-row .name-row { display:flex; justify-content:space-between; align-items:center; }
.child-row .name { font-weight:700; font-size:14.5px; }
.child-row .meta { font-size:11.5px; color:var(--muted); margin-bottom:6px;}
.child-row .arrow { color: var(--muted); font-size: 18px; }
.jalur-pill { display:inline-block; font-size:10px; font-weight:600; padding:2px 8px; border-radius:20px; background: var(--primary-light); color: var(--primary-dark); margin-top:2px;}
.jalur-pill.tahfidz, .jalur-pill.tahfidz_intensif { background: var(--green-light); color: var(--green-dark); }

/* ===== Buttons ===== */
.btn {
  display:inline-flex; align-items:center; justify-content:center; gap:6px;
  border:none; border-radius: 14px; padding: 13px 18px; font-weight:700; font-size:14px;
  cursor:pointer; width:100%; text-align:center;
}
.btn-primary { background: var(--primary); color:#fff; }
.btn-primary:active { background: var(--primary-dark); }
.btn-green { background: var(--green); color:#fff; }
.btn-outline { background:#fff; border:1.5px solid var(--primary); color: var(--primary); }
.btn-sm { padding: 8px 14px; font-size: 12.5px; width:auto; border-radius:10px; }

/* ===== Tabs ===== */
.tabs { display:flex; gap: 6px; border-bottom: 1px solid var(--border); margin-bottom: 14px; }
.tab { flex:1; text-align:center; padding: 10px 4px; font-size: 13px; font-weight:600; color:var(--muted); border-bottom: 2.5px solid transparent; cursor:pointer;}
.tab.active { color: var(--primary); border-color: var(--primary); }
.topbar .tabs { border-bottom-color: rgba(255,255,255,.25); margin-top:14px; margin-bottom:-22px;}
.topbar .tab { color: rgba(255,255,255,.75); }
.topbar .tab.active { color:#fff; border-color:#fff; }

/* ===== Stat / summary chips ===== */
.stat-grid { display:grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat-box { background:#fff; border:1px solid var(--border); border-radius: var(--radius-sm); padding: 12px; text-align:center;}
.stat-box .val { font-size:19px; font-weight:800; color: var(--ink); }
.stat-box .lbl { font-size:11px; color:var(--muted); margin-top:2px;}

/* ring */
.ring-wrap { display:flex; align-items:center; gap:16px; }
.ring { position: relative; width: 96px; height:96px; flex-shrink:0; }
.ring svg { transform: rotate(-90deg); }
.ring .pct-text { position:absolute; inset:0; display:flex; align-items:center; justify-content:center; font-size:20px; font-weight:800; }
.bar-list { flex:1; }
.bar-item { margin-bottom: 8px; }
.bar-item .top { display:flex; justify-content:space-between; font-size:12px; margin-bottom:4px; color:var(--ink); font-weight:600;}
.bar-item .top span.pct { color: var(--muted); font-weight:600;}

/* ===== Activity checklist ===== */
.activity-item { display:flex; align-items:center; gap:10px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.activity-item:last-child { border-bottom:none; }
.check-circle { width:22px; height:22px; border-radius:50%; border:2px solid var(--border); display:flex; align-items:center; justify-content:center; font-size:12px; flex-shrink:0; }
.check-circle.done { background: var(--green); border-color: var(--green); color:#fff; }
.activity-item .txt { flex:1; }
.activity-item .txt .t1 { font-size:13px; font-weight:600; }
.activity-item .txt .t2 { font-size:11px; color:var(--muted); }

/* ===== Hafalan list rows ===== */
.hafalan-row { display:flex; align-items:center; gap:10px; padding:10px 0; border-bottom:1px solid var(--border); }
.hafalan-row:last-child{ border-bottom:none;}
.status-dot { width: 22px; height:22px; border-radius:50%; display:flex;align-items:center;justify-content:center; font-size:12px; color:#fff; flex-shrink:0;}
.hafalan-row .name { font-weight:700; font-size:13.5px; }
.hafalan-row .sub { font-size:11px; color: var(--muted); }

/* ===== Forms ===== */
.form-group { margin-bottom: 14px; }
.form-group label { display:block; font-size:12.5px; font-weight:600; margin-bottom:6px; color: var(--ink); }
.form-control {
  width:100%; padding: 11px 13px; border-radius: 12px; border: 1.5px solid var(--border);
  font-size: 14px; background:#fff; color: var(--ink); font-family: inherit;
}
.form-control:focus { outline:none; border-color: var(--primary); }
.form-row { display:flex; gap:10px; }
.form-row .form-group { flex:1; }

/* ===== Bottom nav ===== */
.bottom-nav {
  position: fixed; bottom:0; left:50%; transform: translateX(-50%);
  width:100%; max-width:480px; background:#fff; border-top:1px solid var(--border);
  display:flex; padding: 8px 4px 10px; z-index: 50;
}
.nav-item { flex:1; text-align:center; font-size:10.5px; color: var(--muted); font-weight:600; padding-top:4px;}
.nav-item .icon { font-size:19px; display:block; margin-bottom:2px; }
.nav-item.active { color: var(--primary); }

/* ===== Filter pills ===== */
.pill-row { display:flex; gap:8px; overflow-x:auto; padding-bottom:4px; margin-bottom: 12px;}
.pill { flex-shrink:0; padding:7px 14px; border-radius:20px; background:#fff; border:1.5px solid var(--border); font-size:12.5px; font-weight:600; color: var(--muted); cursor:pointer; }
.pill.active { background: var(--primary); border-color: var(--primary); color:#fff; }
.pill.green.active { background: var(--green); border-color: var(--green); }

/* ===== Misc ===== */
.muted { color: var(--muted); }
.flex-between { display:flex; align-items:center; justify-content:space-between; }
.badge { font-size:10.5px; font-weight:700; padding:3px 9px; border-radius:20px; }
.badge-green { background: var(--green-light); color: var(--green-dark); }
.badge-yellow { background: #FEF3C7; color: #B45309; }
.badge-red { background: #FEE2E2; color: #B91C1C; }
.divider { height:1px; background: var(--border); margin: 14px 0; }
.menu-list .menu-item { display:flex; align-items:center; gap:12px; padding:13px 0; border-bottom:1px solid var(--border); font-size:14px; font-weight:600;}
.menu-list .menu-item .arrow { margin-left:auto; color:var(--muted); }
.menu-list .menu-item .icon { font-size: 18px; width:22px; text-align:center;}
.alert { padding: 10px 14px; border-radius: 12px; font-size:13px; margin-bottom:14px; }
.alert-error { background:#FEE2E2; color:#B91C1C; }
.alert-success { background: var(--green-light); color: var(--green-dark); }
.empty-state { text-align:center; padding: 30px 10px; color: var(--muted); font-size:13px; }

.login-wrap { min-height:100vh; display:flex; align-items:center; justify-content:center; padding: 24px; background: linear-gradient(160deg, var(--primary) 0%, var(--primary-dark) 45%, #4838B0 100%); }
.login-card { background:#fff; border-radius: 24px; padding: 30px 24px; width:100%; max-width: 380px; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.login-logo { text-align:center; font-size:42px; margin-bottom: 6px; }
.login-title { text-align:center; font-weight:800; font-size:19px; margin-bottom:2px;}
.login-sub { text-align:center; color:var(--muted); font-size:12.5px; margin-bottom: 22px; }
.login-hint { margin-top:16px; background: var(--primary-light); border-radius:12px; padding:10px 12px; font-size:11.5px; color: var(--primary-dark); }

.pohon-emoji { font-size: 80px; text-align:center; display:block; margin: 10px 0; }
.family-member-grid { display:grid; grid-template-columns: repeat(5,1fr); gap:8px; text-align:center; }
.family-member-grid .fm { font-size:26px; }
.family-member-grid .pts { font-size:10.5px; color:var(--muted); font-weight:700;}

@media print {
  .bottom-nav, .topbar .icon-btn, .no-print { display:none !important; }
  .app-shell { max-width: 100%; padding-bottom:0; }
}
