/* QQF Team App — developed by Umar Rasheed */
:root {
  --navy: #1E3A8A;
  --navy-dark: #172E6E;
  --navy-tint: #E6ECF8;
  --orange: #F7941D;
  --orange-tint: #FFF4E6;
  --orange-text: #A04A00;
  --ink: #17201C;
  --muted: #5A635E;
  --line: #E2E1DA;
  --bg: #F6F5F0;
  --card: #FFFFFF;
  --red: #B42318;
  --green: #136B3A;
  --green-tint: #E2F3E8;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--ink); background: var(--bg); font-size: 15px; line-height: 1.45;
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--navy); }
h1, h2, h3 { margin: 0; }
h1 { font-size: 22px; }
h2 { font-size: 16px; }
h3 { font-size: 15px; margin: 10px 0 6px; }
[lang="ur"], .urdu { font-family: "Noto Nastaliq Urdu", serif; line-height: 2; }

#app { min-height: 100%; display: flex; flex-direction: column; max-width: 640px; margin: 0 auto; background: var(--bg); }
.splash { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; color: var(--muted); min-height: 100vh; }
.splash-logo { width: 220px; }

/* Login */
.login { padding: 40px 20px; display: flex; flex-direction: column; gap: 12px; align-items: stretch; min-height: 100vh; }
.login-logo { width: 240px; align-self: center; margin-bottom: 8px; }
.login h1 { text-align: center; }
.login > .muted { text-align: center; margin: 0; }

/* Top bar & tabs */
.topbar {
  position: sticky; top: 0; z-index: 5; background: #fff; border-bottom: 3px solid var(--orange);
  display: flex; align-items: center; justify-content: space-between; padding: 10px 16px;
  padding-top: max(10px, env(safe-area-inset-top));
}
.top-logo { height: 40px; }
.view { flex: 1; padding: 16px 16px 96px; display: flex; flex-direction: column; gap: 14px; }
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; max-width: 640px; margin: 0 auto; z-index: 5;
  display: grid; background: #fff; border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: 62px; text-decoration: none; color: var(--muted); font-size: 11px; font-weight: 500;
}
.tabbar a.active { color: var(--navy); font-weight: 700; }

/* Building blocks */
.page-title { font-size: 24px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 14px; }
.card.accent { border-color: #C8D4EE; box-shadow: inset 4px 0 0 var(--navy); }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; align-items: center; }
.row.between { justify-content: space-between; gap: 8px; }
.row.gap { gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.block { display: block; }
.center { text-align: center; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.error { color: var(--red); font-size: 13px; margin: 0; min-height: 1em; }
.credit { color: var(--muted); font-size: 12px; text-align: center; margin: 8px 0 0; }
.msg-text { margin: 10px 0 8px; white-space: normal; word-wrap: break-word; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.tile {
  background: #fff; border: 1px solid var(--line); border-radius: 16px; min-height: 84px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  text-decoration: none; color: var(--ink); font-size: 13px; font-weight: 600;
}
.tile svg { color: var(--navy); }

/* Forms */
.form { display: flex; flex-direction: column; gap: 8px; }
.form.row { flex-direction: row; }
label { font-size: 13px; font-weight: 600; }
input, select, textarea {
  font: inherit; color: var(--ink); background: #fff; border: 1px solid #C9C8C0; border-radius: 12px;
  padding: 11px 12px; min-height: 46px; width: 100%;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--navy); outline-offset: 1px; border-color: var(--navy); }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.check input { width: 20px; height: 20px; min-height: 0; }
details summary { cursor: pointer; min-height: 32px; display: flex; align-items: center; color: var(--navy); }
details[open] summary { margin-bottom: 10px; }

.btn {
  font: inherit; font-weight: 700; border-radius: 12px; min-height: 46px; padding: 0 16px; cursor: pointer;
  border: 1px solid var(--navy); background: #fff; color: var(--navy);
}
.btn.primary { background: var(--navy); color: #fff; }
.btn.primary:hover { background: var(--navy-dark); }
.btn.small { min-height: 38px; font-size: 13px; padding: 0 12px; }
.btn:disabled { opacity: .6; cursor: default; }
.btn.danger-outline { border-color: var(--red); color: var(--red); }
.link { background: none; border: 0; font: inherit; font-size: 13px; font-weight: 600; color: var(--navy); cursor: pointer; min-height: 40px; padding: 0 4px; }
.link.danger { color: var(--red); }

.tag { display: inline-block; font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 999px; background: #EEEDE7; color: var(--muted); }
.tag.orange { background: var(--orange-tint); color: var(--orange-text); }
.tag.green { background: var(--green-tint); color: var(--green); }
.tag.navy { background: var(--navy-tint); color: var(--navy); font-size: 12px; }

.avatar {
  width: 44px; height: 44px; flex: none; border-radius: 22px; background: var(--navy); color: #fff;
  display: inline-flex; align-items: center; justify-content: center; font-weight: 700; text-decoration: none;
}
.avatar.sm { width: 38px; height: 38px; font-size: 13px; background: var(--navy-tint); color: var(--navy); }
.avatar.square { border-radius: 10px; background: var(--navy); color: #fff; }

.list { list-style: none; margin: 0; padding: 4px 14px; }
.list li { padding: 10px 0; border-bottom: 1px solid #EEEDE7; }
.list li:last-child { border-bottom: 0; }
.chan { text-decoration: none; color: var(--ink); min-height: 44px; }
.member.off { opacity: .55; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin: 14px 0 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; font-weight: 600; }

/* Video */
.video { position: relative; aspect-ratio: 16 / 9; border-radius: 12px; overflow: hidden; background: #24302B; }
.video iframe, .video-cover, .video-cover img { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.video-cover { padding: 0; cursor: pointer; background: #24302B; }
.video-cover img { object-fit: cover; }
.play {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: 60px; height: 60px; border-radius: 30px;
  background: rgba(0,0,0,.6); color: #fff; font-size: 24px; display: flex; align-items: center; justify-content: center;
}

/* Chat */
.chat { display: flex; flex-direction: column; height: calc(100vh - 160px); min-height: 380px; }
.chat-head h1 { font-size: 18px; }
.icon-btn {
  width: 44px; height: 44px; flex: none; border-radius: 22px; border: 1px solid var(--line); background: #fff; color: var(--navy);
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
}
.icon-btn.primary { background: var(--navy); color: #fff; border-color: var(--navy); }
.msgs { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; padding: 12px 2px; }
.bubble {
  max-width: 80%; align-self: flex-start; background: #fff; border: 1px solid var(--line); border-radius: 14px; border-bottom-left-radius: 4px;
  padding: 8px 12px; display: flex; flex-direction: column; gap: 2px; word-wrap: break-word;
}
.bubble.mine { align-self: flex-end; background: var(--navy); color: #fff; border-color: var(--navy); border-radius: 14px; border-bottom-right-radius: 4px; }
.bubble .who { font-size: 12px; font-weight: 700; color: var(--orange-text); }
.bubble .time { font-size: 11px; opacity: .75; align-self: flex-end; }
.composer { padding-top: 8px; }

#toast {
  position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%) translateY(20px); opacity: 0; pointer-events: none;
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 14px; transition: all .2s; z-index: 10;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.member-edit { padding: 12px 0; }
.member-edit .form { gap: 8px; }
.danger-zone { margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--line); display: flex; flex-direction: column; gap: 6px; }
.role-card { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; }
.share-row { display: flex; gap: 8px; margin: 4px 0 8px; flex-wrap: wrap; }
.btn.share { display: inline-flex; align-items: center; gap: 6px; text-decoration: none; }
.btn.share.wa { border-color: #136B3A; color: #136B3A; }
.btn.share.wa:hover { background: #E2F3E8; }
.donate { border-color: var(--orange); box-shadow: inset 4px 0 0 var(--orange); }
.donate-qr { display: block; width: 260px; max-width: 100%; margin: 12px auto 4px; border-radius: 12px; border: 1px solid var(--line); }

/* ---------- Families ---------- */
.kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; display: flex; flex-direction: column; }
.kpi b { font-size: 24px; color: var(--navy); }
.kpi span { font-size: 12px; color: var(--muted); }
.toolbar { display: flex; flex-direction: column; gap: 8px; }
.toolbar select { flex: 1; min-width: 0; }
.fam { text-decoration: none; color: var(--ink); min-height: 48px; }
.regno { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; background: var(--navy-tint); color: var(--navy); border-radius: 6px; padding: 1px 6px; }
.regno.big { font-size: 14px; padding: 4px 10px; }
.tag.red { background: #FBE5E3; color: #A3302A; }
fieldset.card { margin: 0; min-width: 0; }
fieldset legend { font-weight: 700; color: var(--orange-text); padding: 0 6px; font-size: 15px; }
.req { color: var(--red); }
.flabel { font-size: 13px; font-weight: 600; }
.checks { display: flex; flex-direction: column; gap: 6px; }
.prow { display: grid; grid-template-columns: 22px minmax(0, 1fr) 96px 56px 30px; gap: 6px; align-items: center; }
.prow input, .prow select { min-height: 42px; padding: 8px; }
.pno { color: var(--muted); font-size: 13px; text-align: center; }
.photo-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.photo-slot { display: flex; flex-direction: column; gap: 6px; margin: 0; }
.photo-slot .btn { text-align: center; display: flex; align-items: center; justify-content: center; }
.thumb { position: relative; aspect-ratio: 4 / 3; border: 2px dashed var(--line); border-radius: 12px; overflow: hidden; display: flex; align-items: center; justify-content: center; background: #FAFAF7; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.newtag { position: absolute; top: 6px; left: 6px; background: var(--orange); color: var(--ink); font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; }
.consent { background: var(--orange-tint); border-radius: 10px; padding: 10px; align-items: flex-start; }
table.mini { width: 100%; border-collapse: collapse; font-size: 14px; margin-top: 8px; }
table.mini th { text-align: left; color: var(--muted); font-weight: 600; font-size: 12px; border-bottom: 1px solid var(--line); padding: 4px 6px; }
table.mini td { border-bottom: 1px solid #EEEDE7; padding: 6px; }
a.btn { text-decoration: none; display: inline-flex; align-items: center; justify-content: center; }
.icon-btn { text-decoration: none; font-size: 26px; line-height: 1; }

/* ---------- Print / Save as PDF ---------- */
#printArea { display: none; }
@media print {
  @page { size: A4; margin: 12mm; }
  body { background: #fff; }
  #app, #toast, .tabbar, .topbar { display: none !important; }
  #printArea { display: block; }
}
.pf { font-family: Inter, Arial, sans-serif; color: #000; font-size: 11pt; }
.pf-head { display: flex; align-items: center; gap: 14px; border-bottom: 3px solid #F7941D; padding-bottom: 8px; margin-bottom: 6px; }
.pf-head img { height: 54px; }
.pf-head h1 { font-size: 17pt; margin: 0; color: #1E3A8A; }
.pf-head p { margin: 2px 0 0; color: #444; font-size: 10pt; }
.pf-reg { margin-left: auto; text-align: right; display: flex; flex-direction: column; font-size: 9pt; }
.pf-reg b { font-size: 15pt; font-family: ui-monospace, Menlo, Consolas, monospace; color: #1E3A8A; }
.pf h2 { font-size: 11.5pt; color: #A04A00; margin: 10px 0 4px; }
.pf-t { width: 100%; border-collapse: collapse; }
.pf-t th, .pf-t td { border: 1px solid #999; padding: 4px 6px; text-align: left; vertical-align: top; }
.pf-t th { width: 32%; background: #F2F4FA; font-weight: 600; }
.pf-m th { width: auto; }
.pf-photos { display: flex; flex-wrap: wrap; gap: 8px; }
.pf-photos figure { margin: 0; width: 23%; }
.pf-photos img { width: 100%; height: 110px; object-fit: cover; border: 1px solid #999; }
.pf-photos figcaption { font-size: 8.5pt; text-align: center; }
.pf-decl { margin: 0; font-size: 10pt; }
.pf-sign { display: flex; gap: 14px; margin-top: 28px; }
.pf-sign div { flex: 1; border-top: 1px solid #000; padding-top: 4px; font-size: 9pt; }
.pf-foot { margin-top: 14px; font-size: 8.5pt; color: #555; }
.pf-photos, .pf-t tr { break-inside: avoid; }
