/* TPQ Madin PWA - gaya Alma Ata: gradien biru royal ke ungu, latar lavender, kartu putih timbul */
:root {
  --blue: #3b4ed8;
  --blue2: #4a5cff;
  --purple: #6a5ae0;
  --bg: #edeffb;
  --card: #ffffff;
  --ink: #1e2235;
  --muted: #6b7194;
  --line: #e3e6f5;
  --green: #16a34a;
  --amber: #d97706;
  --red: #dc2626;
  --radius: 24px;
  --shadow: 0 10px 30px rgba(59, 78, 216, .12);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3 { margin: 0 0 8px; line-height: 1.25; }
h1 { font-size: 26px; }
h2 { font-size: 20px; }
h3 { font-size: 17px; }
p { margin: 0 0 10px; }
a { color: var(--blue); }
button, input, select, textarea { font: inherit; color: inherit; }
button { min-height: 44px; cursor: pointer; }
input, select, textarea {
  min-height: 44px;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  padding: 10px 12px;
  background: #fff;
  width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--blue2); border-color: var(--blue2); }
label { display: block; font-weight: 600; font-size: 14px; margin: 12px 0 4px; }
textarea { min-height: 88px; resize: vertical; }

/* ---------- Layout ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 264px; flex: 0 0 264px;
  background: linear-gradient(180deg, var(--blue), var(--purple));
  color: #fff; padding: 20px 14px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: none;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 6px 8px 18px; }
.brand img { width: 52px; height: 52px; border-radius: 16px; background: #fff; }
.brand b { font-size: 20px; display: block; }
.brand span { font-size: 13px; opacity: .85; }
.nav-group { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; opacity: .75; padding: 14px 10px 6px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  background: transparent; border: 0; color: #fff; text-align: left;
  padding: 10px 12px; border-radius: 14px; font-size: 15px; min-height: 44px;
}
.nav-item:hover { background: rgba(255,255,255,.14); }
.nav-item.active { background: #fff; color: var(--blue); font-weight: 700; }
.nav-item .ico { font-size: 18px; width: 24px; text-align: center; }
.main { flex: 1; min-width: 0; padding: 20px 22px 120px; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-bottom: 16px;
}
.topbar .logo-m { display: flex; align-items: center; gap: 10px; }
.topbar .logo-m img { width: 44px; height: 44px; border-radius: 12px; }
.topbar .logo-m b { font-size: 18px; }
.badge-contoh {
  display: inline-block; background: #fef3c7; color: #92400e;
  border: 1px solid #fcd34d; border-radius: 999px; padding: 4px 12px;
  font-size: 13px; font-weight: 700;
}
.content { max-width: 1060px; margin: 0 auto; }

/* ---------- Cards, grid, stats ---------- */
.card {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px; margin-bottom: 16px;
}
.profile-card {
  background: linear-gradient(135deg, var(--blue), var(--blue2) 55%, var(--purple));
  color: #fff; border-radius: var(--radius); padding: 24px; margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.profile-card h1 { color: #fff; }
.profile-card p { opacity: .92; }
.profile-card .meta { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.chip {
  background: rgba(255,255,255,.18); border: 1px solid rgba(255,255,255,.35);
  border-radius: 999px; padding: 6px 12px; font-size: 13px; font-weight: 600;
}
.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.stat { text-align: left; }
.stat .num { font-size: 30px; font-weight: 800; color: var(--blue); line-height: 1.1; }
.stat .lbl { font-size: 14px; color: var(--muted); font-weight: 600; }
.stat .sub { font-size: 13px; color: var(--muted); }
.menu-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.menu-tile {
  background: #fff; border: 1px solid var(--line); border-radius: 20px;
  padding: 16px; text-align: left; min-height: 84px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 4px;
}
.menu-tile .ico { font-size: 26px; }
.menu-tile b { font-size: 15px; }
.menu-tile span { font-size: 13px; color: var(--muted); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--blue); color: #fff; border: 0; border-radius: 999px;
  padding: 10px 20px; font-weight: 700; min-height: 44px; text-decoration: none;
}
.btn:hover { background: var(--blue2); }
.btn.secondary { background: #eef0fd; color: var(--blue); }
.btn.ghost { background: #fff; color: var(--ink); border: 1.5px solid var(--line); }
.btn.danger { background: #fee2e2; color: var(--red); }
.btn.success { background: #dcfce7; color: #15803d; }
.btn.warn { background: #fef3c7; color: #92400e; }
.btn.small { min-height: 36px; padding: 6px 14px; font-size: 14px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; margin: 12px 0; }
.btn-row .btn { flex: 1 1 auto; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; margin: 0 -4px; }
table { width: 100%; border-collapse: collapse; font-size: 15px; }
th, td { padding: 10px 8px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
tr:last-child td { border-bottom: 0; }

/* ---------- Badges, bars, misc ---------- */
.badge {
  display: inline-block; border-radius: 999px; padding: 3px 10px;
  font-size: 13px; font-weight: 700; white-space: nowrap;
}
.b-green { background: #dcfce7; color: #15803d; }
.b-amber { background: #fef3c7; color: #92400e; }
.b-red { background: #fee2e2; color: #b91c1c; }
.b-blue { background: #e0e7ff; color: #3730a3; }
.b-grey { background: #e5e7eb; color: #374151; }
.progress { height: 12px; background: var(--line); border-radius: 999px; overflow: hidden; }
.progress > i { display: block; height: 100%; background: linear-gradient(90deg, var(--blue2), var(--purple)); border-radius: 999px; }
.bar-chart { display: flex; align-items: flex-end; gap: 14px; height: 190px; padding: 12px 4px 0; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; min-width: 0; }
.bar-col .bar {
  width: 100%; max-width: 64px; border-radius: 10px 10px 4px 4px;
  background: linear-gradient(180deg, var(--blue2), var(--purple));
  min-height: 4px;
}
.bar-col .val { font-weight: 800; font-size: 14px; }
.bar-col .cat { font-size: 12px; color: var(--muted); text-align: center; word-break: break-word; }
.tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.tab {
  border: 1.5px solid var(--line); background: #fff; border-radius: 999px;
  padding: 8px 16px; font-weight: 700; min-height: 44px; color: var(--ink);
}
.tab.active { background: var(--blue); color: #fff; border-color: var(--blue); }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
.toolbar > * { flex: 1 1 160px; }
.avatar {
  width: 56px; height: 56px; border-radius: 50%; object-fit: cover;
  background: linear-gradient(135deg, var(--blue2), var(--purple));
  color: #fff; display: inline-flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 20px; flex: 0 0 56px; border: 2px solid #fff;
  box-shadow: var(--shadow);
}
.row-flex { display: flex; align-items: center; gap: 12px; }
.row-flex .grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); font-size: 14px; }
.money { font-weight: 800; }
.pos { color: var(--green); }
.neg { color: var(--red); }
.big-attend { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 10px 0; }
.big-attend button { border-radius: 16px; border: 2px solid var(--line); background: #fff; font-weight: 700; padding: 12px 4px; min-height: 52px; }
.big-attend button.on-hadir { background: #dcfce7; border-color: var(--green); color: #15803d; }
.big-attend button.on-izin { background: #dbeafe; border-color: var(--blue); color: var(--blue); }
.big-attend button.on-sakit { background: #fef3c7; border-color: var(--amber); color: #92400e; }
.big-attend button.on-alpa { background: #fee2e2; border-color: var(--red); color: #b91c1c; }
.notice {
  background: #fffbeb; border: 1px solid #fcd34d; border-radius: 16px;
  padding: 14px 16px; margin-bottom: 14px;
}
.notice .close-x { float: right; background: none; border: 0; font-size: 20px; min-height: 32px; min-width: 32px; padding: 0; }
.empty { text-align: center; color: var(--muted); padding: 24px 8px; }
.toast {
  position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%);
  background: #1e2235; color: #fff; padding: 12px 20px; border-radius: 999px;
  font-weight: 600; z-index: 200; box-shadow: 0 8px 24px rgba(0,0,0,.3);
  max-width: 92vw; text-align: center;
}
/* Modal */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(20, 24, 60, .55);
  display: flex; align-items: flex-end; justify-content: center; z-index: 100;
}
.modal {
  background: #fff; border-radius: 24px 24px 0 0; width: 100%; max-width: 560px;
  max-height: 92vh; overflow-y: auto; padding: 22px;
}
.modal h2 { margin-bottom: 4px; }
/* Bottom nav (mobile) */
.bottomnav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 90;
  background: #fff; border-top: 1px solid var(--line);
  display: flex; justify-content: space-around;
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  box-shadow: 0 -6px 20px rgba(59, 78, 216, .08);
}
.bottomnav button {
  flex: 1; background: none; border: 0; min-height: 52px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-size: 11px; font-weight: 700; color: var(--muted); padding: 4px 0;
}
.bottomnav button .ico { font-size: 21px; }
.bottomnav button.active { color: var(--blue); }
/* Lainnya sheet */
.sheet {
  position: fixed; inset: 0; z-index: 95; background: rgba(20,24,60,.45);
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet .panel {
  background: #fff; border-radius: 24px 24px 0 0; width: 100%; max-width: 560px;
  max-height: 80vh; overflow-y: auto; padding: 18px 18px 30px;
}
.sheet .panel button.item {
  display: flex; gap: 12px; align-items: center; width: 100%;
  background: none; border: 0; border-bottom: 1px solid var(--line);
  padding: 12px 6px; text-align: left; font-size: 16px; font-weight: 600;
}
.sheet .panel button.item .ico { font-size: 22px; width: 30px; }
.hidden { display: none !important; }

/* ---------- Desktop >= 900px ---------- */
@media (min-width: 900px) {
  .sidebar { display: block; }
  .main { padding: 28px 32px 48px; }
  .bottomnav { display: none; }
  .topbar .logo-m { display: none; }
  .menu-grid { grid-template-columns: repeat(4, 1fr); }
  .modal-backdrop { align-items: center; }
  .modal { border-radius: 24px; }
  .toast { bottom: 32px; }
}
@media (max-width: 899px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
  .stat .num { font-size: 24px; }
}
@media (max-width: 520px) {
  .main { padding: 14px 14px 120px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr 1fr; }
  .big-attend { grid-template-columns: repeat(2, 1fr); }
}

/* ---------- Mode tampilan: Desktop / Mobile (sakelar manual di Pengaturan) ---------- */
/* Mode desktop dipaksa lewat body.mode-desktop, mode mobile lewat body.mode-mobile.
   Tanpa kelas itu, tampilan ikut lebar layar (otomatis): >=900px desktop, <900px mobile. */
body.mode-desktop .sidebar { display: block; }
body.mode-desktop .bottomnav { display: none; }
body.mode-desktop .topbar .logo-m { display: none; }
body.mode-desktop .main { padding: 28px 32px 48px; }
body.mode-desktop .menu-grid { grid-template-columns: repeat(4, 1fr); }
body.mode-desktop .modal-backdrop { align-items: center; }
body.mode-desktop .modal { border-radius: 24px; }
body.mode-desktop .toast { bottom: 32px; }
body.mode-mobile .sidebar { display: none; }
body.mode-mobile .bottomnav { display: flex; }
body.mode-mobile .topbar .logo-m { display: flex; }
body.mode-mobile .main { padding: 14px 14px 120px; }
body.mode-mobile .menu-grid { grid-template-columns: repeat(2, 1fr); }
body.mode-mobile .grid-4 { grid-template-columns: repeat(2, 1fr); }

/* Monogram huruf pengganti ikon (tanpa emoji dekoratif, sesuai anti-slop R-04) */
.nav-item .ico, .bottomnav button .ico {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; flex: 0 0 30px; border-radius: 10px;
  background: rgba(255,255,255,.18); color: #fff;
  font-size: 13px; font-weight: 800; font-style: normal;
}
.nav-item.active .ico { background: #eef0fd; color: var(--blue); }
.bottomnav button .ico { background: #eef0fd; color: var(--blue); width: 28px; height: 28px; flex-basis: 28px; font-size: 12px; }
.bottomnav button.active .ico { background: var(--blue); color: #fff; }
.menu-tile .ico {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: 12px;
  background: linear-gradient(135deg, var(--blue2), var(--purple)); color: #fff;
  font-size: 15px; font-weight: 800; font-style: normal;
}

/* ---------- Indikator status sinkron (selalu terlihat di header) ---------- */
.sync-status {
  display: inline-flex; align-items: center; gap: 8px;
  border-radius: 999px; padding: 6px 12px; font-size: 13px; font-weight: 700;
  background: #eef0fd; color: var(--blue); border: 1px solid #dbe2fb;
  white-space: nowrap;
}
.sync-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--blue2); flex: 0 0 10px; }
.sync-status.offline { background: #fef3c7; color: #92400e; border-color: #fcd34d; }
.sync-status.offline .sync-dot { background: #d97706; }
.sync-status.pending { background: #ffedd5; color: #9a3412; border-color: #fdba74; }
.sync-status.pending .sync-dot { background: #ea580c; }
.sync-status.ok { background: #dcfce7; color: #15803d; border-color: #86efac; }
.sync-status.ok .sync-dot { background: #16a34a; }
.sync-status.idle { background: #e5e7eb; color: #374151; border-color: #d1d5db; }
.sync-status.idle .sync-dot { background: #6b7280; }

/* ---------- Pesan sukses / gagal yang jelas (bukan toast samar) ---------- */
.alert { border-radius: 16px; padding: 14px 16px; margin-bottom: 14px; font-size: 15px; }
.alert-success { background: #dcfce7; border: 1px solid #86efac; color: #14532d; }
.alert-error { background: #fee2e2; border: 1px solid #fca5a5; color: #7f1d1d; }
.alert-info { background: #dbeafe; border: 1px solid #93c5fd; color: #1e3a8a; }
.alert b { display: block; margin-bottom: 4px; }
.alert ul { margin: 6px 0 0; padding-left: 20px; }

/* ---------- Picker: cari + chip filter + tampil bertahap ---------- */
.chip-filter {
  border: 1.5px solid var(--line); background: #fff; border-radius: 999px;
  padding: 8px 14px; font-weight: 700; font-size: 14px; min-height: 40px; color: var(--ink);
}
.chip-filter.active { background: var(--blue); color: #fff; border-color: var(--blue); }
.chip-row { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0; }
.picker-row {
  display: flex; align-items: center; gap: 12px; width: 100%;
  background: #fff; border: 1px solid var(--line); border-radius: 16px;
  padding: 10px 12px; margin-bottom: 8px; text-align: left; min-height: 64px;
}
.picker-row:hover { border-color: var(--blue2); }
.picker-row .nm { font-weight: 700; }
.picker-row .sb { font-size: 13px; color: var(--muted); }
.selected-chip {
  display: flex; align-items: center; gap: 10px;
  background: #eef0fd; border: 1.5px solid var(--blue2); border-radius: 16px;
  padding: 10px 12px; margin: 10px 0;
}
.selected-chip .nm { font-weight: 700; }
.picker-count { font-size: 13px; color: var(--muted); margin: 8px 0; }

/* ---------- Detail dan lain-lain ---------- */
.kv { width: 100%; border-collapse: collapse; }
.kv td { padding: 8px 4px; border-bottom: 1px solid var(--line); }
.kv td:first-child { color: var(--muted); width: 42%; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid var(--blue2); outline-offset: 2px;
}
.sortable { cursor: pointer; user-select: none; }
.sortable:hover { color: var(--blue); }
.step-num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--blue); color: #fff; font-weight: 800; font-size: 14px; flex: 0 0 28px;
}
.howto { display: flex; gap: 12px; margin-bottom: 12px; align-items: flex-start; }
.howto p { margin: 0; }
.file-drop {
  border: 2px dashed var(--blue2); border-radius: 16px; padding: 18px; text-align: center;
  background: #f5f6ff; margin: 10px 0;
}
pre.code {
  background: #1e2235; color: #e5e7eb; border-radius: 16px; padding: 16px;
  overflow-x: auto; font-size: 13px; line-height: 1.5; white-space: pre;
}
