/* ============================================================
 * FamilyGuard — MODE APLIKASI (v1.0.57)
 * ============================================================
 * Reskin UI/UX profesional khusus APK FamilyGuard Panel.
 * Aktif HANYA bila <html> ber-class "fg-app" — ditanam shell.php
 * saat panel dibuka dari APK (query ?app=1 dari /admin-aio,
 * flag localStorage "fgAppMode", atau UA "FamilyGuardPanel").
 *
 * Prinsip desain (beda total dari tampilan website panel orang tua):
 *   1. Identitas BIRU Panel (senada beranda APK /admin-aio) —
 *      bukan zamrud website.
 *   2. App bar gradasi biru + ikon putih bulat transparan.
 *   3. Navigasi BAWAH (bottom navigation) 5 slot — Beranda,
 *      Aplikasi, Lokasi, Laporan, dan "Semua" — menggantikan
 *      bar tab horizontal khas website.
 *   4. "Semua" = sheet bawah bergaya super-app berisi grid 12
 *      fitur berwarna.
 *   5. Semua dialog menjadi BOTTOM SHEET (slide dari bawah).
 *   6. Kartu app-style: sudut membulat besar, bayangan lembut,
 *      tanpa garis pinggir kering.
 *   7. Menghormati safe-area (poni/notch & gesture bar Android).
 *
 * Selector dashboard TIDAK diubah — lapisan ini murni menimpa
 * tampilan, semua logika dashboard.js & tabs/*.js tetap jalan.
 * ============================================================ */

/* ---------- 1. Fondasi & palet ---------- */
html.fg-app,
html.fg-app body {
  background: #f2f6fb;                    /* abu-biru dingin khas aplikasi */
}
html.fg-app body {
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;            /* cegah pull-to-refresh WebView */
  font-size: 15px;
}
html.fg-app {
  --fg-app-blue-900: #0d3a7d;
  --fg-app-blue-700: #1257b8;
  --fg-app-blue-600: #1d63cf;
  --fg-app-blue-500: #2f7fe6;
  --fg-app-blue-100: #dbe9fb;
  --fg-app-blue-050: #eaf3fb;
  --fg-app-ink: #0f2b52;
  --fg-app-muted: #5f7ba0;
}

/* ---------- 2. App bar (header) ---------- */
html.fg-app .dash-header {
  position: sticky; top: 0; z-index: 40;
  border-bottom: 0;
  background: linear-gradient(150deg, var(--fg-app-blue-500), var(--fg-app-blue-700) 78%);
  color: #fff;
  border-radius: 0 0 20px 20px;
  box-shadow: 0 6px 18px rgba(13, 58, 125, 0.22);
  padding-top: env(safe-area-inset-top, 0px);
}
html.fg-app .dash-header-inner {
  height: auto; min-height: 60px;
  padding: 10px 14px;
  gap: 10px;
}
html.fg-app .dash-header .text-base.font-bold { color: #fff; letter-spacing: 0.01em; }
html.fg-app .dash-header .text-muted-foreground,
html.fg-app .dash-header .realtime-online { color: rgba(255, 255, 255, 0.85) !important; }
html.fg-app .dash-header .realtime-off { color: rgba(255, 255, 255, 0.66) !important; }

html.fg-app .dash-header .brand-badge {
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  width: 38px; height: 38px;
  border-radius: 12px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.22);
}
html.fg-app .dash-header .brand-badge svg { width: 20px; height: 20px; }

/* Tombol bulat transparan: lonceng, SOS, keluar */
html.fg-app .dash-header .btn-outline,
html.fg-app .dash-header .btn.btn-outline {
  background: rgba(255, 255, 255, 0.16);
  border: 0; color: #fff;
  width: 40px; height: 40px; min-height: 40px; padding: 0;
  border-radius: 9999px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18);
  justify-content: center;
  transition: background 0.15s ease, transform 0.1s ease;
}
html.fg-app .dash-header .btn-outline:active { background: rgba(255, 255, 255, 0.3); transform: scale(0.94); }
html.fg-app .dash-header .btn-outline svg { width: 19px; height: 19px; }
html.fg-app .dash-header .btn-outline span { display: none; }   /* label "Keluar" → ikon saja */
html.fg-app .dash-header .btn-destructive {
  background: #e11d48; border: 0; color: #fff;
  width: 40px; height: 40px; min-height: 40px; padding: 0;
  border-radius: 9999px; justify-content: center;
  box-shadow: 0 4px 12px rgba(225, 29, 72, 0.4);
}
html.fg-app .dash-header .btn-destructive span { display: none; }
html.fg-app .dash-header .btn-destructive svg { width: 19px; height: 19px; animation: fg-app-pulse 1.2s ease-in-out infinite; }
@keyframes fg-app-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.55; } }

/* Info pengguna desktop & badge Beta disembunyikan (bukan bahasa aplikasi) */
html.fg-app .dash-header .avatar-initial,
html.fg-app .dash-header .sm\:flex.hidden,
html.fg-app .dash-header .hidden.items-center.gap-2.sm\:flex { display: none !important; }
html.fg-app .dash-header .beta-badge { display: none; }

/* Lonceng notifikasi (bellSlot berisi tombol) */
html.fg-app .dash-header [class*="relative"] button,
html.fg-app .dash-header .relative button {
  background: rgba(255, 255, 255, 0.16);
  border: 0; color: #fff;
  width: 40px; height: 40px; border-radius: 9999px;
  justify-content: center;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18);
}

/* v1.0.95 — tombol "Kirim tiket" TIDAK lagi di baris lonceng (dipindah ke
   header utama, kanan tombol Affiliate) — gaya tombol bulat header di atas
   tidak lagi menyentuhnya; di header utama ia tampil seperti tombol
   Affiliate (outline kecil dgn teks), web maupun Mode Aplikasi. */

/* ---------- 3. Sembunyikan ebene website ---------- */
html.fg-app .rail-toggle,                                     /* "Menu Anak & Panel" (bilah lama v<1.0.106) */
html.fg-app .rail-open-btn { display: none !important; }      /* v1.0.106 hamburger drawer — APK pakai pill "Ganti" + menu bawah */
html.fg-app #fg-rail { display: none !important; }            /* rail anak gaya desktop */
html.fg-app .tabs-list { display: none !important; }       /* bar tab horizontal → bottom nav */
html.fg-app .dash-footer { display: none !important; }     /* footer website */
html.fg-app .dash-body { max-width: 100%; }

/* ---------- 4. Area konten utama ---------- */
html.fg-app .dash-main {
  /* ruang bawah utk nav melayang: 6+58+6 (nav) + 12 (offset) + 26 (lega) */
  padding: 14px 14px calc(102px + env(safe-area-inset-bottom, 0px));
  max-width: 640px;
  margin: 0 auto;
  width: 100%;
}
html.fg-app .dash-shell { min-height: 100vh; min-height: 100dvh; }

/* Kartu gaya aplikasi */
html.fg-app .card {
  border: 0;
  border-radius: 18px;
  box-shadow: 0 2px 10px rgba(15, 43, 82, 0.05), 0 8px 24px rgba(15, 43, 82, 0.05);
}
html.fg-app .card.p-6, html.fg-app .card.p-10 { border-radius: 20px; }

/* Tombol utama gaya aplikasi */
html.fg-app .btn { border-radius: 13px; font-weight: 700; }
html.fg-app .btn-primary {
  background: linear-gradient(160deg, var(--fg-app-blue-500), var(--fg-app-blue-700));
  border: 0;
  box-shadow: 0 6px 14px rgba(18, 87, 184, 0.28);
}
html.fg-app .btn-primary:active { transform: scale(0.97); }
html.fg-app .btn-outline { border-color: var(--fg-app-blue-100); color: var(--fg-app-blue-700); }
html.fg-app .input, html.fg-app .select {
  border-radius: 13px;
  background: #fff;
  min-height: 46px;
}
html.fg-app .badge { border-radius: 9999px; font-weight: 700; }

/* Header konteks anak (baris pertama headerBox) — tap → ganti anak */
html.fg-app .fg-child-head {
  background: #fff;
  border-radius: 18px;
  padding: 14px;
  margin-bottom: 14px !important;
  box-shadow: 0 2px 10px rgba(15, 43, 82, 0.05), 0 8px 24px rgba(15, 43, 82, 0.05);
  cursor: pointer;
  transition: transform 0.12s ease;
  row-gap: 10px;
}
html.fg-app .fg-child-head:active { transform: scale(0.985); }
html.fg-app .fg-child-head h1 { font-size: 17px; color: var(--fg-app-ink); }
html.fg-app .fg-child-head .fg-swap-pill {
  flex: none;
  display: flex; align-items: center; gap: 4px;
  border: 0; cursor: pointer;
  background: var(--fg-app-blue-050);
  color: var(--fg-app-blue-700);
  font-size: 11.5px; font-weight: 800;
  padding: 7px 11px;
  border-radius: 9999px;
  transition: transform 0.12s ease;
}
html.fg-app .fg-child-head .fg-swap-pill:active { transform: scale(0.92); }
html.fg-app .fg-child-head .fg-swap-pill svg { width: 13px; height: 13px; }
html.fg-app .banner-license,
html.fg-app .banner-cache { border-radius: 16px; }

/* Transisi halus saat pindah tab (ditambah app-mode.js) */
html.fg-app .fg-tab-enter { animation: fg-app-tab-in 0.26s cubic-bezier(0.2, 0.8, 0.2, 1); }
@keyframes fg-app-tab-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Skeleton & elemen kecil */
html.fg-app .skeleton { border-radius: 12px; }

/* ---------- 5. Dialog → BOTTOM SHEET ---------- */
html.fg-app .dialog-overlay {
  align-items: flex-end !important;
  padding: 0 !important;
  background: rgba(9, 30, 60, 0.5);
  backdrop-filter: blur(3px);
  animation: fg-app-fade 0.18s ease-out;
}
/* ruang bawah overlay agar sheet melayang di atas tepi layar (senada nav) */
html.fg-app .dialog-overlay {
  padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px)) !important;
  box-sizing: border-box;
}
html.fg-app .dialog-overlay.align-center { align-items: flex-end !important; }
html.fg-app .dialog {
  max-width: 616px;
  border: 0;
  border-radius: 24px;                 /* v1.0.58: melayang → bulat penuh */
  margin: 0 auto;
  padding: 10px 18px calc(18px + env(safe-area-inset-bottom, 0px));
  max-height: 90vh; max-height: 90dvh;
  overflow-y: auto;
  box-shadow: 0 18px 50px rgba(9, 30, 60, 0.32);
  animation: fg-app-sheet 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);
}
html.fg-app .dialog::before {
  content: "";
  position: absolute; top: 8px; left: 50%; transform: translateX(-50%);
  width: 40px; height: 4px; border-radius: 9999px;
  background: #dbe3ee;
}
html.fg-app .dialog-lg { max-width: 640px; }
html.fg-app .dialog-title { font-size: 16.5px; font-weight: 800; color: var(--fg-app-ink); }
html.fg-app .dialog-footer { flex-direction: row; }
html.fg-app .dialog-footer .btn { flex: 1; min-height: 46px; }
html.fg-app .dialog-close { width: 32px; height: 32px; top: 12px; right: 12px; border-radius: 9999px; background: #f1f5f9; }
@keyframes fg-app-sheet {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}
@keyframes fg-app-fade { from { opacity: 0; } to { opacity: 1; } }

/* ---------- 6. BOTTOM NAVIGATION MELAYANG (floating) ----------
 * v1.0.58: pilung — nav TIDAK menempel di tepi lagi; melayang di atas
 * konten dgn sudut membulat penuh, kaca buram, dan bayangan lembut
 * (gaya navigasi aplikasi modern). Aman di atas gesture-bar Android
 * karena offset bawah memperhitungkan safe-area. */
#fg-bottomnav {
  position: fixed;
  left: 50%; bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  width: calc(100% - 24px);            /* fallback WebView lama */
  max-width: 520px;                    /* ekuiv. min() dgn pusat tetap */
  z-index: 45;
  display: none;                       /* tampil hanya di mode aplikasi */
  background: rgba(255, 255, 255, 0.88);
  -webkit-backdrop-filter: blur(18px) saturate(1.5);
  backdrop-filter: blur(18px) saturate(1.5);
  border: 1px solid rgba(255, 255, 255, 0.65);
  border-radius: 26px;
  box-shadow:
    0 12px 34px rgba(13, 58, 125, 0.20),
    0 3px 10px rgba(13, 58, 125, 0.10),
    inset 0 0 0 1px rgba(15, 43, 82, 0.035);
  padding: 6px;
}
html.fg-app #fg-bottomnav { display: block; animation: fg-bn-rise 0.4s cubic-bezier(0.2, 0.9, 0.25, 1.1) both; }
@keyframes fg-bn-rise {
  from { opacity: 0; transform: translateX(-50%) translateY(18px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}
#fg-bottomnav .fg-bn-row {
  display: flex; align-items: stretch; justify-content: space-around;
  height: 58px;
}
#fg-bottomnav .fg-bn-item {
  flex: 1; min-width: 0;
  border: 0; background: none; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; padding: 0; position: relative;
  color: #8a97ab;
  font-family: inherit;
  -webkit-tap-highlight-color: transparent;
  transition: color 0.15s ease;
  border-radius: 20px;
}
#fg-bottomnav .fg-bn-item .fg-bn-ic {
  width: 42px; height: 26px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 9999px;
  transition: background 0.18s ease, transform 0.18s cubic-bezier(0.34, 1.56, 0.64, 1);
}
#fg-bottomnav .fg-bn-item svg { width: 21px; height: 21px; }
#fg-bottomnav .fg-bn-item .fg-bn-lb {
  font-size: 10px; font-weight: 700; letter-spacing: 0.01em; line-height: 1;
}
#fg-bottomnav .fg-bn-item[data-active="true"] { color: var(--fg-app-blue-700, #1257b8); }
#fg-bottomnav .fg-bn-item[data-active="true"] .fg-bn-ic {
  background: rgba(18, 87, 184, 0.12);                       /* fallback WebView lama */
  background: color-mix(in srgb, #1257b8 12%, transparent);
  transform: translateY(-1px);
}
#fg-bottomnav .fg-bn-item:active .fg-bn-ic { transform: scale(0.88); }

/* Slot "Semua" — tombol grid menonjol gaya super-app */
#fg-bottomnav .fg-bn-item.fg-bn-all { color: #64748b; }
#fg-bottomnav .fg-bn-item.fg-bn-all .fg-bn-ic {
  width: 44px; height: 30px;
}
#fg-bottomnav .fg-bn-item.fg-bn-all[data-active="true"] { color: var(--fg-app-blue-700, #1257b8); }
#fg-bottomnav .fg-bn-item.fg-bn-all .fg-bn-grid {
  width: 30px; height: 30px; border-radius: 10px;
  background: linear-gradient(160deg, #2f7fe6, #1257b8);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 10px rgba(18, 87, 184, 0.35);
  transition: transform 0.18s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.18s ease;
}
#fg-bottomnav .fg-bn-item.fg-bn-all .fg-bn-grid svg { width: 17px; height: 17px; }
#fg-bottomnav .fg-bn-item.fg-bn-all:active .fg-bn-grid { transform: scale(0.88); }
#fg-bottomnav .fg-bn-item.fg-bn-all[data-active="true"] .fg-bn-grid {
  box-shadow: 0 0 0 3px rgba(18, 87, 184, 0.18), 0 4px 10px rgba(18, 87, 184, 0.35);
  box-shadow: 0 0 0 3px color-mix(in srgb, #1257b8 18%, transparent), 0 4px 10px rgba(18, 87, 184, 0.35);
}
/* Titik merah SOS pada bottom nav (ada SOS aktif) */
#fg-bottomnav .fg-bn-dot {
  position: absolute; top: 8px; right: calc(50% - 16px);
  width: 8px; height: 8px; border-radius: 9999px;
  background: #e11d48;
  box-shadow: 0 0 0 2px #fff;
  animation: fg-app-pulse 1.1s ease-in-out infinite;
}

/* ---------- 7. SHEET "SEMUA FITUR" (grid 12 menu) ---------- */
#fg-allsheet {
  position: fixed; inset: 0; z-index: 70;
  display: none;
  background: rgba(9, 30, 60, 0.5);
  backdrop-filter: blur(3px);
}
#fg-allsheet.show { display: block; animation: fg-app-fade 0.18s ease-out; }
#fg-allsheet .fg-as-panel {
  position: absolute; left: 0; right: 0; bottom: 0;
  max-width: 640px; margin: 0 auto;
  background: #fff;
  border-radius: 26px 26px 0 0;
  padding: 10px 18px calc(20px + env(safe-area-inset-bottom, 0px));
  max-height: 82vh; max-height: 82dvh; overflow-y: auto;
  box-shadow: 0 -12px 40px rgba(9, 30, 60, 0.28);
  animation: fg-app-sheet 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}
#fg-allsheet .fg-as-handle {
  width: 40px; height: 4px; border-radius: 9999px;
  background: #dbe3ee; margin: 4px auto 14px;
}
#fg-allsheet .fg-as-title {
  margin: 0 0 2px; font-size: 17px; font-weight: 800; color: #0f2b52;
}
#fg-allsheet .fg-as-sub {
  margin: 0 0 14px; font-size: 12px; color: #5f7ba0;
}
#fg-allsheet .fg-as-grid {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 14px 10px;
}
#fg-allsheet .fg-as-tile {
  border: 0; background: none; cursor: pointer; font-family: inherit;
  display: flex; flex-direction: column; align-items: center; gap: 7px;
  padding: 6px 2px; border-radius: 16px;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.12s ease, background 0.15s ease;
}
#fg-allsheet .fg-as-tile:active { transform: scale(0.93); background: #f1f5f9; }
#fg-allsheet .fg-as-ic {
  width: 54px; height: 54px; border-radius: 17px;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  box-shadow: 0 6px 14px var(--tile-shadow, rgba(18, 87, 184, 0.25));
}
#fg-allsheet .fg-as-ic svg { width: 25px; height: 25px; }
#fg-allsheet .fg-as-tile .fg-as-lb {
  font-size: 11.5px; font-weight: 700; color: #1e293b;
  text-align: center; line-height: 1.25; max-width: 84px;
}
#fg-allsheet .fg-as-foot {
  margin: 16px 0 0; text-align: center;
  font-size: 10.5px; color: #8a97ab;
}

/* ---------- 8. SHEET GANTI ANAK ---------- */
#fg-kidsheet {
  position: fixed; inset: 0; z-index: 70;
  display: none;
  background: rgba(9, 30, 60, 0.5);
  backdrop-filter: blur(3px);
}
#fg-kidsheet.show { display: block; animation: fg-app-fade 0.18s ease-out; }
#fg-kidsheet .fg-ks-panel {
  position: absolute; left: 0; right: 0; bottom: 0;
  max-width: 640px; margin: 0 auto;
  background: #fff;
  border-radius: 26px 26px 0 0;
  padding: 10px 16px calc(18px + env(safe-area-inset-bottom, 0px));
  max-height: 70vh; max-height: 70dvh; overflow-y: auto;
  box-shadow: 0 -12px 40px rgba(9, 30, 60, 0.28);
  animation: fg-app-sheet 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}
#fg-kidsheet .fg-as-handle {
  width: 40px; height: 4px; border-radius: 9999px;
  background: #dbe3ee; margin: 4px auto 14px;
}
#fg-kidsheet .fg-ks-title { margin: 0 0 12px; font-size: 16.5px; font-weight: 800; color: #0f2b52; }
#fg-kidsheet .fg-ks-row {
  width: 100%; border: 0; background: none; cursor: pointer; font-family: inherit;
  display: flex; align-items: center; gap: 12px;
  padding: 11px 12px; border-radius: 15px;
  text-align: left;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.14s ease, transform 0.1s ease;
}
#fg-kidsheet .fg-ks-row:active { background: #f1f5f9; transform: scale(0.985); }
#fg-kidsheet .fg-ks-row[data-selected="true"] { background: #eaf3fb; box-shadow: inset 0 0 0 1.5px #2f7fe6; }
#fg-kidsheet .fg-ks-ava {
  flex: none; width: 42px; height: 42px; border-radius: 9999px;
  background: #eaf3fb;
  display: flex; align-items: center; justify-content: center;
  font-size: 21px;
}
#fg-kidsheet .fg-ks-nm {
  flex: 1; min-width: 0;
  font-size: 14.5px; font-weight: 700; color: #0f2b52;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
#fg-kidsheet .fg-ks-dot { flex: none; width: 9px; height: 9px; border-radius: 9999px; }
#fg-kidsheet .fg-ks-dot.on { background: #10b981; }
#fg-kidsheet .fg-ks-dot.off { background: #cbd5e1; }
#fg-kidsheet .fg-ks-check { flex: none; width: 20px; height: 20px; color: #1257b8; visibility: hidden; }
#fg-kidsheet .fg-ks-row[data-selected="true"] .fg-ks-check { visibility: visible; }

/* ---------- 9. Toast di atas bottom nav melayang ---------- */
html.fg-app #fg-toasts { bottom: calc(100px + env(safe-area-inset-bottom, 0px)) !important; }

/* ---------- 10. Tablet: nav melayang tetap proporsional ---------- */
@media (min-width: 641px) {
  #fg-bottomnav { width: calc(100% - 48px); max-width: 520px; bottom: calc(18px + env(safe-area-inset-bottom, 0px)); }
  #fg-bottomnav .fg-bn-row { padding: 0 10px; }
  html.fg-app .dash-main { padding-bottom: calc(112px + env(safe-area-inset-bottom, 0px)); }
}

/* ============================================================
 * 11. RESPONSIVITAS PENUH LAYAR KECIL (v1.0.58)
 * ============================================================
 * Keluhan: sebagian halaman masih melebar / terpotong di ponsel.
 * Semua aturan di bawah HANYA aktif di html.fg-app — website panel
 * via browser tetap 100% tidak tersentuh.
 * ---------------------------------------------------------- */

/* 11a. Jaring pengaman: halaman tidak pernah bergulir menyamping */
html.fg-app body { overflow-x: hidden; }

/* 11b. Media & peta tak pernah melebihi kartu */
html.fg-app img,
html.fg-app video,
html.fg-app canvas,
html.fg-app iframe { max-width: 100%; }

/* 11c. Anti-overflow teks panjang: semua kartu boleh menyusut */
html.fg-app .card { min-width: 0; }
html.fg-app [class*="t-"] { min-width: 0; max-width: 100%; }
html.fg-app .dash-main p,
html.fg-app .dash-main h1,
html.fg-app .dash-main h2,
html.fg-app .dash-main h3 { overflow-wrap: break-word; }

/* 11d. Kartu konteks anak: nama/perangkat panjang terpotong rapi */
html.fg-app .fg-child-head { flex-wrap: wrap; }
html.fg-app .fg-child-head > div:first-child { min-width: 0; flex: 1 1 150px; }
html.fg-app .fg-child-head > div:first-child p {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
html.fg-app .fg-child-head .badge { max-width: 100%; overflow: hidden; }
html.fg-app .fg-child-head .btn { flex: none; }

/* 11e. Ponsel sempit (≤480px): kartu lebih ramping, konten lega */
@media (max-width: 480px) {
  html.fg-app .dash-main { padding-left: 12px; padding-right: 12px; }
  html.fg-app .dash-main .card:not(.sm) { padding: 1rem; }
  html.fg-app .card.p-6, html.fg-app .card.p-10 { padding: 1rem !important; }
  html.fg-app .fg-child-head { padding: 12px; border-radius: 16px; }
}

/* 11f. Tabel riwayat & tabel tab: ringkas dan nyaman digulir di ponsel */
@media (max-width: 640px) {
  html.fg-app .t-loc table { font-size: 12.5px; }
  html.fg-app .t-loc th, html.fg-app .t-loc td { padding: 0.5rem 0.6rem; }
  html.fg-app .t-loc [style*="overflow:auto"] {
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
  }
}

/* 11g. Dialog dua kolom → satu kolom di layar sempit (form tak sesak) */
@media (max-width: 460px) {
  html.fg-app .dialog div[style*="1fr 1fr"],
  html.fg-app .dialog div[style*="repeat(2,1fr)"] { grid-template-columns: 1fr !important; }
  html.fg-app .dialog [style*="display:flex"][style*="gap"] { flex-wrap: wrap; }
  html.fg-app .dialog .input, html.fg-app .dialog .select { width: 100%; }
}

/* 11h. Baris alat (filter/toolbar) tab: selalu boleh melipat */
html.fg-app .t-rep .card > div,
html.fg-app .t-loc .card > div,
html.fg-app .t-apps .card > div,
html.fg-app .t-cctv .card > div { min-width: 0; }

/* Pemilih rentang & tombol ekspor laporan memenuhi lebar di ponsel */
@media (max-width: 480px) {
  html.fg-app .t-rep select,
  html.fg-app .t-loc select { min-width: 0; flex: 1 1 auto; }
  html.fg-app .t-rep .card .btn,
  html.fg-app .t-loc .card .btn { flex: none; }
}

/* 11h-2. Judul kartu + tombol aksi sebaris: tombol turun ke baris baru
 * bila judul/deskripsi panjang (mis. "Batas Harian per Aplikasi" +
 * "＋ Tambah Batas") — teks tidak terjepit kolom sempit lagi. */
@media (max-width: 480px) {
  html.fg-app [class*="t-"] .card > div[style*="space-between"] { flex-wrap: wrap; }
  html.fg-app [class*="t-"] .card > div[style*="space-between"] > div { min-width: 0; flex: 1 1 100%; }
  html.fg-app [class*="t-"] .card > div[style*="space-between"] > .btn { flex: 0 0 auto; }
}

/* 11i. Sheet "Semua Fitur" & "Ganti Anak": ikut gaya melayang di atas nav */
#fg-allsheet .fg-as-panel,
#fg-kidsheet .fg-ks-panel {
  left: 12px; right: 12px;
  width: auto;
  max-width: 616px;
  margin: 0 auto 0;
  border-radius: 26px;
  margin-bottom: env(safe-area-inset-bottom, 0px);
}

/* 11j. Dialog besar (Langganan, CCTV, dsb.) ikut melayang rapi —
 * .dialog adalah flex-item di .dialog-overlay (justify-center), jadi
 * cukup kecilkan width utk memberi tepi kiri-kanan (TANPA left/right —
 * offset relative justru menggeser dialog keluar tengah). */
html.fg-app .dialog,
html.fg-app .dialog-overlay > .dialog {
  width: calc(100% - 24px);
  max-width: 616px;
  margin: 0 auto;
}

/* ============================================================
 * v1.0.101 — WARNA HALAMAN PER ANAK (mode APK):
 * latar #f2f6fb kini di-tint aksen anak yang dipilih, dan item
 * AKTIF menu bawah melayang (#fg-bottomnav) ikut var(--primary)
 * anak tersebut — bukan lagi biru tetap. Item "Semua" tetap
 * netral abu. Spesifisitas di atas selector lama (body+attr).
 * v1.0.103 — laporan pemilik "terlalu lembut": kroma diperkuat
 * 0.13 → 0.19 & tint latar APK 8% → 13%; ikon nav aktif 14% → 20%.
 * ============================================================ */
html.fg-app body[data-child-hue] {
  background: color-mix(in oklab, oklch(0.52 0.19 var(--fg-child-h, 162)) 13%, #f2f6fb);
}
body[data-child-hue] #fg-bottomnav .fg-bn-item[data-active="true"] { color: var(--primary); }
body[data-child-hue] #fg-bottomnav .fg-bn-item[data-active="true"] .fg-bn-ic {
  background: color-mix(in oklab, var(--primary) 20%, transparent);
}

/* ============================================================
 * v1.0.104 — TOAST & BANNER NOTIFIKASI DI MODE APK (laporan
 * pemilik: "notifikasi tidak muncul"): toast lama bottom 1rem —
 * PERSIS di posisi menu bawah melayang, jadi tertutup nav & tak
 * terlihat. Kini toast naik DI ATAS nav (104px + safe-area) dan
 * banner notifikasi (#fg-banners, turun dari atas layar) ikut
 * aman notch. BUNYI LONCENG TIDAK DIUBAH.
 * ============================================================ */
html.fg-app #fg-toasts {
  bottom: calc(104px + env(safe-area-inset-bottom, 0px));
}
html.fg-app #fg-banners {
  width: calc(100% - 20px); max-width: 460px;
}
