:root {
  --ink: #161c33; --muted: #5f6782; --bg: #f5f6fa; --card: #fff; --line: #e3e7f0; --line-soft: #eceff6;
  --brand: #0f7a6c; --brand-dark: #0f4c45; --header-bg: #0f4c45; --gold: #c9962b; --danger: #b03030;
  --warn-bg: #fff4dc; --err-bg: #fdeeee; --ok-bg: #e6f5ec; --warn-ink: #8a5a00; --ok-ink: #11633f;
  --soft: #e3f4f0; --soft-ink: #0b5d52; --subtle: #f6f7fb; --field-bg: #fff; --field-line: #d5dbe8;
  --danger-bg: #fcebeb; --danger-line: #f1c9c9; --gold-bg: #fbf1da; --gold-ink: #7a5300;
  --public-bg: #e3f3e8; --public-ink: #19663c; --internal-bg: #f1e8f8; --internal-ink: #6a2a9a;
  --shadow: 0 1px 2px #0f172a0a, 0 8px 24px #0f172a0d; --radius: 18px;
  --tap: 44px; --bottom-nav: 64px;
  font-family: "Plus Jakarta Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px; color: var(--ink); background: var(--bg);
  -webkit-text-size-adjust: 100%; text-size-adjust: 100%;
}
/* Dark mode follows the phone/computer setting. --brand-dark is a TEXT colour there (light), so backgrounds that must
   stay dark use --header-bg. Student cards and QR codes keep white paper colours on purpose. */
@media (prefers-color-scheme: dark) {
  :root {
    --ink: #e8ebf5; --muted: #9ba4bd; --bg: #0e1120; --card: #171b2e; --line: #2a3049; --line-soft: #232840;
    --brand: #3cc4ae; --brand-dark: #bdf0e6; --header-bg: #0c1f1d; --gold: #e0b450; --danger: #ff8d8d;
    --warn-bg: #3a2f14; --err-bg: #3d1c1f; --ok-bg: #143022; --warn-ink: #f2c76b; --ok-ink: #72dca0;
    --soft: #17332f; --soft-ink: #b4ece1; --subtle: #13172a; --field-bg: #11152a; --field-line: #343b5c;
    --danger-bg: #3d1c1f; --danger-line: #5c2a2e; --gold-bg: #3a2f14; --gold-ink: #f0c869;
    --public-bg: #143022; --public-ink: #72dca0; --internal-bg: #2e2142; --internal-ink: #d6b3f5;
    --shadow: 0 1px 2px #0007, 0 8px 24px #0006;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100vh; -webkit-tap-highlight-color: transparent; }
a { color: var(--brand); }
img, svg { max-width: 100%; }

/* ---------- Header ---------- */
header.top { background: var(--header-bg); color: #fff; padding: 10px max(calc((100% - 1080px) / 2), 16px);
  padding-top: max(10px, env(safe-area-inset-top)); display: flex; gap: 12px; justify-content: space-between; align-items: center; }
header.top a { color: #fff; text-decoration: none; }
header.top .brand { font-weight: 700; white-space: nowrap; }
header.top nav { display: flex; flex-wrap: wrap; gap: 4px 18px; align-items: center; }
header.top nav.main a { padding: 10px 0; }
header.top nav.main a.active { text-decoration: underline; text-underline-offset: 6px; }
header.top .brand { flex: 0 0 auto; }
header.top .tools { display: flex; gap: 10px; align-items: center; justify-content: flex-end; min-width: 0; flex: 1 1 auto; }
header.top .tools form { min-width: 0; margin: 0; }
header.top .tools form:first-child { flex: 0 1 auto; }
header.top select { background: #ffffff1a; color: #fff; border: 1px solid #ffffff55; border-radius: 8px;
  padding: 8px 10px; width: 100%; max-width: 260px; min-width: 0; min-height: 40px; text-overflow: ellipsis; }
header.top select option { color: var(--ink); }
button.link { background: none; color: #fff; padding: 8px 4px; font-weight: 500; min-height: 40px; }

/* ---------- Bottom navigation (phones) ---------- */
.bottom-nav { display: none; position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  background: color-mix(in srgb, var(--card) 90%, transparent); backdrop-filter: saturate(1.6) blur(16px);
  -webkit-backdrop-filter: saturate(1.6) blur(16px); border-top: 1px solid var(--line);
  grid-template-columns: repeat(4, 1fr); padding-bottom: env(safe-area-inset-bottom); }
.bottom-nav a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: var(--bottom-nav); color: var(--muted); text-decoration: none; font-size: .75rem; font-weight: 600; }
.bottom-nav a svg { width: 24px; height: 24px; }
.bottom-nav a.active { color: var(--brand); }
.bottom-nav a svg { padding: 3px 14px; box-sizing: content-box; border-radius: 999px; transition: background .2s ease; }
.bottom-nav a.active svg { background: var(--soft); }

/* ---------- Layout ---------- */
main { max-width: 1080px; margin: 28px auto; padding: 0 16px; }
h1 { font-size: clamp(1.5rem, 4vw, 2.4rem); letter-spacing: -.02em; margin: 2px 0 12px; line-height: 1.2; overflow-wrap: anywhere; }
h2 { margin-top: 0; font-size: 1.2rem; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.eyebrow { color: var(--muted); margin: 0; font-size: .9rem; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin: 16px 0; box-shadow: var(--shadow); }
.notice { padding: 12px 14px; border-radius: 14px; background: var(--ok-bg); margin: 0 0 12px; }
.notice.error { background: var(--err-bg); }
.notice.warn { background: var(--warn-bg); }
.flash-toast { position: fixed; z-index: 90; left: 50%; top: calc(12px + env(safe-area-inset-top)); transform: translateX(-50%);
  width: min(520px, calc(100% - 24px)); display: flex; align-items: center; gap: 12px; padding: 12px 8px 12px 14px;
  background: #11633f; color: #fff; border-radius: 14px; box-shadow: 0 10px 30px #0c163455;
  animation: toast-in .25s ease-out; transition: opacity .3s, transform .3s; }
.flash-toast + .flash-toast { top: calc(84px + env(safe-area-inset-top)); }
.flash-toast.hide { opacity: 0; transform: translate(-50%, -12px); }
.flash-icon { flex: 0 0 auto; width: 32px; height: 32px; border-radius: 50%; background: #fff; color: #11633f;
  display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 1.1rem; }
.flash-text { display: grid; gap: 2px; min-width: 0; overflow-wrap: anywhere; line-height: 1.35; }
.flash-text strong { font-size: 1rem; }
.flash-close { flex: 0 0 auto; background: none; color: #fff; font-size: 1.5rem; width: 44px; min-height: 44px; padding: 0; }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, -16px); } to { opacity: 1; transform: translate(-50%, 0); } }
@media (prefers-reduced-motion: reduce) { .flash-toast { animation: none; transition: none; } }
.invite-box { display: grid; gap: 10px; border: 1px solid var(--field-line); }
.invite-box input { font-size: 14px; }
header.top .store-name, header.top .admin-link { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
header.top .admin-link { padding: 0 4px; font-weight: 600; }
header.top .brand, header.top .admin-link { display: inline-flex; align-items: center; min-height: 44px; }
.status { display: inline-block; font-size: .75rem; padding: 2px 8px; border-radius: 99px; font-weight: 600; }
.status.trial { background: var(--warn-bg); color: var(--warn-ink); }
.status.active { background: var(--ok-bg); color: var(--ok-ink); }
.status.suspended, .status.expired { background: var(--err-bg); color: var(--danger); }

/* ---------- Forms ---------- */
form.stack { display: grid; gap: 14px; }
label { font-weight: 600; display: grid; gap: 6px; }
label.check { display: flex; gap: 10px; align-items: center; font-weight: 500; min-height: var(--tap); }
label.check input { width: 22px; height: 22px; min-height: 0; flex: 0 0 auto; accent-color: var(--brand); }
/* 16px text stops iOS from zooming into fields on focus. */
input, textarea, select { width: 100%; border: 1px solid var(--field-line); border-radius: 12px; padding: 10px 12px;
  font: inherit; font-size: 16px; background: var(--field-bg); color: var(--ink); min-height: var(--tap); }
textarea { min-height: 80px; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--brand); outline-offset: 1px; border-color: transparent; }
fieldset { border: 1px solid var(--line); border-radius: 14px; padding: 6px 12px; display: flex; gap: 4px 20px; flex-wrap: wrap; margin: 0; }
legend { font-weight: 600; padding: 0 6px; }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.assessment-form { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; align-items: end; }
.assessment-form > label { min-width: 0; align-content: start; line-height: 1.35; }
.assessment-form > label input { min-width: 0; }
.assessment-form > button { width: 100%; min-width: 0; height: var(--tap); align-self: end; }
.hint.assessment-hint { margin: 12px 0 0; line-height: 1.5; }
.assessment-heading { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 14px; }
.assessment-heading h2 { min-width: 0; margin: 0; overflow-wrap: anywhere; }
.assessment-remove-form { flex: 0 0 auto; margin: 0; }
@media (min-width: 720px) and (max-width: 900px) { .assessment-form { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 719px) {
  .assessment-form { grid-template-columns: minmax(0, 1fr); }
  .assessment-heading { align-items: stretch; flex-direction: column; }
  .assessment-remove-form, .assessment-remove-form button { width: 100%; }
}
.hint { color: var(--muted); font-size: .875rem; margin: -6px 0 0; }

button, .button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; background: var(--brand); color: #fff;
  border: 0; border-radius: 12px; padding: 10px 16px; font: inherit; font-weight: 700; cursor: pointer; text-decoration: none;
  min-height: var(--tap); touch-action: manipulation; }
.button.secondary, button.secondary { background: var(--soft); color: var(--soft-ink); }
button.danger, .button.danger { background: var(--danger-bg); color: var(--danger); }
button:active, .button:active { transform: translateY(1px); }

.actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.actions form { display: inline-flex; margin: 0; }
.actions > a:not(.button) { padding: 10px 4px; }

/* ---------- Page toolbar & filters ---------- */
.toolbar { display: flex; gap: 12px; flex-wrap: wrap; align-items: end; justify-content: space-between; }
.toolbar > div { min-width: 0; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.filters input, .filters select { width: auto; min-width: 160px; flex: 1 1 160px; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
td, th { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line-soft); vertical-align: top; overflow-wrap: anywhere; }
th { font-size: .85rem; color: var(--muted); font-weight: 600; }
td.num, th.num { text-align: right; white-space: nowrap; }
tr.inactive td { opacity: .55; }
td.row-actions { width: 1%; white-space: nowrap; overflow-wrap: normal; }
td.row-actions .actions { flex-wrap: nowrap; justify-content: flex-end; }

.badge { display: inline-block; font-size: .75rem; padding: 2px 8px; border-radius: 99px; background: var(--soft); color: var(--soft-ink); text-decoration: none; vertical-align: middle; }
.badge.warn { background: var(--warn-bg); color: var(--warn-ink); }
.badge.service { background: var(--soft); color: var(--soft-ink); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips .badge { font-size: .875rem; padding: 6px 14px; min-height: 40px; display: inline-flex; align-items: center; }
.chips .badge.on { background: var(--brand); color: #fff; }
.split { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
tfoot td { border-top: 2px solid var(--line); }
.text-btn { background: none; color: var(--brand); padding: 6px 0; min-height: 36px; font-weight: 600; text-decoration: underline; }
.tabs { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.tabs a { padding: 8px 14px; border-radius: 99px; background: var(--soft); color: var(--soft-ink); text-decoration: none; font-weight: 600; min-height: 40px; display: inline-flex; align-items: center; }
.tabs a.on { background: var(--brand); color: #fff; }
.tabs .count { margin-left: 6px; background: var(--danger); color: #fff; border-radius: 99px; padding: 0 7px; font-size: .8rem; }
.badge.late { background: var(--err-bg); color: var(--danger); font-weight: 700; }
.badge.urgent { background: #c62828; color: #fff; font-weight: 800; }
.badge[hidden] { display: none; }
.badge.ready { background: var(--ok-bg); color: var(--ok-ink); }
details.card summary { cursor: pointer; min-height: 32px; }
@media (max-width: 720px) { .period-form { grid-template-columns: 1fr 1fr; } .period-form button { grid-column: 1 / -1; } }
a.wa-link { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; font-weight: 600; }
a.wa-link::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: #25d366; flex: 0 0 auto; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 12px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); padding: 14px 16px; text-decoration: none; color: inherit; }
.stat strong { display: block; font-size: 1.9rem; line-height: 1.2; }
.stat { min-width: 0; }
.stat strong.money { font-size: 1.35rem; overflow-wrap: anywhere; }  /* rupiah totals are long */
.quick-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; margin: 16px 0; }
.pager { display: flex; gap: 12px; margin-top: 12px; align-items: center; flex-wrap: wrap; }
.pager a { padding: 10px 4px; }
.list-plain { list-style: none; padding: 0; margin: 0; }
.list-plain li { padding: 10px 0; border-bottom: 1px solid var(--line-soft); }
.list-plain li:last-child { border-bottom: 0; }
.inline-form { display: flex; gap: 8px; align-items: center; flex: 1 1 260px; min-width: 0; margin: 0; }
.inline-form input { flex: 1 1 auto; min-width: 0; }
.inline-form button { flex: 0 0 auto; }
details summary { cursor: pointer; padding: 8px 0; }
.store-plan + .store-plan { border-top: 1px solid var(--line-soft); margin-top: 12px; }
.category-list { list-style: none; margin: 0; padding: 0; }
.category-list li { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line-soft); }
.category-list li:last-child { border-bottom: 0; }
.category-meta { display: flex; gap: 12px; align-items: center; margin-left: auto; }
.category-meta a { white-space: nowrap; padding: 10px 0; }
.category-meta form { margin: 0; }
.list-plain li.split { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.list-plain li.split > :last-child { white-space: nowrap; }

/* ---------- Sales & invoice ---------- */
.summary-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.summary-grid div { background: var(--subtle); border-radius: 10px; padding: 10px; min-width: 0; }
.summary-grid strong { display: block; font-size: clamp(.95rem, 4vw, 1.25rem); white-space: nowrap; }
.big-actions { display: grid; gap: 10px; }
.big-actions .button, .big-actions button { min-height: 52px; font-size: 1.05rem; width: 100%; }
.button.wa { background: #1f9e55; }
.switch-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 10px 0 2px;
  padding: 10px 12px; background: var(--subtle); border-radius: 12px; }
.switch { flex: 0 0 auto; position: relative; width: 56px; min-height: 32px; height: 32px; padding: 0; border-radius: 99px;
  background: var(--field-line); transition: background .2s; }
.switch .knob { position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 3px #0003; transition: left .2s; }
.switch.on { background: var(--brand); }
.switch.on .knob { left: 27px; }
.switch:focus-visible { outline: 3px solid #a9b9e6; outline-offset: 2px; }
.logo-header { width: 36px; height: 36px; border-radius: 8px; object-fit: contain; background: #fff; padding: 2px; flex: 0 0 auto; }
.logo-title { width: 56px; height: 56px; border-radius: 12px; object-fit: contain; background: #fff; border: 1px solid var(--line); padding: 4px; flex: 0 0 auto; }
.store-title { display: flex; gap: 12px; align-items: center; }
.store-title h1 { margin-bottom: 8px; }
.logo-preview { width: 96px; height: 96px; object-fit: contain; border: 1px solid var(--line); border-radius: 12px; padding: 6px; background: #fff; display: block; margin: 4px 0; }
.action-pair { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.action-pair form { margin: 0; display: flex; }
.action-pair .button, .action-pair button { width: 100%; min-height: 52px; font-size: 1.05rem; }
.button.warn-btn { background: var(--warn-bg); color: var(--warn-ink); border: 1px solid var(--gold); }
button.danger { border: 1px solid var(--danger-line); }
@media (max-width: 719px) {
}
.product-thumb { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; float: left; margin-right: 10px; }
.image-preview { width: 120px; height: 120px; border-radius: 12px; object-fit: cover; display: block; margin: 4px 0; }
.input-with-button { display: flex; gap: 8px; }
.input-with-button input { flex: 1 1 auto; min-width: 0; }


/* ---------- Church app ---------- */
.church-switch { color: #fff; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; min-height: 44px;
  max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.church-switch::after { content: "▾"; opacity: .7; }
.vis { display: inline-block; font-size: .72rem; padding: 1px 8px; border-radius: 99px; font-weight: 600; vertical-align: middle; }
.vis.public { background: var(--public-bg); color: var(--public-ink); }
.vis.shared { background: var(--soft); color: var(--soft-ink); }
.vis.internal { background: var(--internal-bg); color: var(--internal-ink); }
.important { border-left: 4px solid var(--gold); }
.badge.gold { background: var(--gold-bg); color: var(--gold-ink); }
.sched-list { list-style: none; margin: 0; padding: 0; }
.sched-list li { display: grid; grid-template-columns: 92px 1fr auto; gap: 4px 12px; padding: 12px 0; border-bottom: 1px solid var(--line-soft); align-items: start; }
.sched-list li:last-child { border-bottom: 0; }
.sched-time { font-weight: 700; color: var(--brand-dark); line-height: 1.3; }
.sched-time small { display: block; font-weight: 500; color: var(--muted); }
.sched-main { min-width: 0; overflow-wrap: anywhere; }
.sched-main strong { display: block; }
.sched-main .muted { font-size: .9rem; }
.week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.week .day { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 8px; min-height: 80px; min-width: 0; }
.week .day.today { border-color: var(--brand); box-shadow: inset 0 0 0 1px var(--brand); }
.week .day h3 { margin: 0 0 4px; font-size: .8rem; color: var(--muted); }
.week .day p { margin: 0 0 4px; font-size: .8rem; line-height: 1.3; overflow-wrap: anywhere; }
@media (max-width: 719px) { .week { grid-template-columns: 1fr; } .week .day { min-height: 0; } .week .day:not(.has) { display: none; } }
.tree-row { display: flex; gap: 10px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line-soft); }
.tree-row:last-child { border-bottom: 0; }
.tree-row .indent { flex: 0 0 auto; color: var(--field-line); font-family: ui-monospace, monospace; white-space: pre; }
.tree-row .grow { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.photo-grid figure { margin: 0; background: var(--card); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.photo-grid img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; display: block; }
.photo-grid figcaption { padding: 6px; display: flex; gap: 6px; flex-wrap: wrap; }
.photo-grid figcaption button { min-height: 36px; padding: 4px 10px; font-size: .85rem; flex: 1; }
.photo-grid .is-cover { outline: 3px solid var(--gold); }
.code-box { font-family: ui-monospace, monospace; font-size: 1.4rem; letter-spacing: .15em; font-weight: 700;
  background: var(--subtle); border: 1px dashed var(--field-line); border-radius: 12px; padding: 8px 14px; display: inline-block; }

/* ---------- Public pages ---------- */
body.public header.top { background: var(--card); color: var(--ink); border-bottom: 1px solid var(--line); }
body.public header.top a { color: var(--brand-dark); }
.hero { position: relative; border-radius: 18px; overflow: hidden; background: var(--header-bg); color: #fff; min-height: 220px;
  display: flex; align-items: flex-end; margin-bottom: 16px; }
.hero img.cover { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.hero::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, #0000 30%, #0c1634d9); }
.hero .hero-text { position: relative; z-index: 1; padding: 20px; display: flex; gap: 14px; align-items: flex-end; }
.hero h1 { color: #fff; margin: 0; }
.hero p { margin: 4px 0 0; opacity: .9; }
.hero .logo-title { background: #fff; }
.contact-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin: 12px 0; }
.contact-actions .button { width: 100%; }
.gallery { display: flex; gap: 10px; overflow-x: auto; scroll-snap-type: x mandatory; padding-bottom: 6px; }
.gallery img { height: 180px; width: auto; max-width: 85vw; border-radius: 12px; scroll-snap-align: start; object-fit: cover; }
.result { display: grid; grid-template-columns: 88px 1fr; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line-soft);
  color: inherit; text-decoration: none; }
.result:last-child { border-bottom: 0; }
.result img, .result .placeholder { width: 88px; height: 66px; border-radius: 10px; object-fit: cover; }
.result strong { display: block; color: var(--brand-dark); }
.placeholder { display: flex; align-items: center; justify-content: center; font-size: 1.6rem; font-weight: 700; color: var(--brand);
  background: var(--soft); }
.item-img { width: 100%; max-height: 320px; object-fit: cover; border-radius: 12px; margin: 8px 0; }
.footer { text-align: center; color: var(--muted); font-size: .85rem; margin: 32px 0 16px; }

/* ---------- Phones ---------- */
@media (max-width: 719px) {
  header.top nav.main { display: none; }
  header.top { gap: 8px; }
  header.top .brand-long { display: none; }
  .bottom-nav { display: grid; }
  main { margin: 16px auto; padding-bottom: calc(var(--bottom-nav) + 24px + env(safe-area-inset-bottom)); }
  .card { padding: 14px; border-radius: 12px; margin: 12px 0; }
  .stats { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .stat { padding: 10px 12px; }
  .stat strong { font-size: 1.6rem; }
  .stats.money-stats { grid-template-columns: repeat(2, 1fr); }
  .stat strong.money { font-size: 1.1rem; }
  .quick-actions { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .quick-actions .button { padding: 10px 6px; font-size: .95rem; }
  .toolbar { align-items: stretch; }
  .toolbar > .actions { width: 100%; }
  .toolbar > .actions > .button, .toolbar > .button { flex: 1; }
  .filters { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
  .filters input, .filters select, .filters button { min-width: 0; width: 100%; padding-left: 10px; padding-right: 10px; }
  .filters input[type=search] { grid-column: 1 / 4; }
  .filters button { grid-column: 4; grid-row: 1; }
  .filters select:first-of-type { grid-column: 1 / 3; }
  .filters select:nth-of-type(2) { grid-column: 3 / 5; }
  .filters select:only-of-type, .filters .full-row { grid-column: 1 / 5; }
  .form-actions > button, .form-actions > .button { flex: 1 1 100%; }
  .form-actions > a { width: 100%; text-align: center; }

  /* Tables turn into stacked cards: each cell shows its column name from data-label. */
  .table-wrap { overflow: visible; }
  table.cards thead { display: none; }
  table.cards, table.cards tbody, table.cards tr, table.cards td { display: block; width: 100%; }
  table.cards tr { border: 1px solid var(--line); border-radius: 16px; padding: 10px 12px; margin-bottom: 10px; background: var(--card); box-shadow: var(--shadow); }
  table.cards td { border: 0; padding: 5px 0; display: flex; justify-content: space-between; align-items: baseline; gap: 12px; text-align: right; white-space: normal; }
  table.cards td::before { content: attr(data-label); color: var(--muted); font-size: .85rem; text-align: left; flex: 0 0 auto; }
  table.cards td.primary { display: block; text-align: left; font-size: 1.05rem; padding-bottom: 6px; }
  table.cards td.primary::before, table.cards td.row-actions::before { content: none; }
  table.cards td.row-actions { width: 100%; white-space: normal; justify-content: flex-start; padding-top: 8px; margin-top: 4px; border-top: 1px solid var(--line-soft); }
  table.cards td.row-actions .actions { width: 100%; flex-wrap: wrap; justify-content: stretch; }
  table.cards td.row-actions .actions > * { flex: 1; }
  table.cards td.row-actions .actions > a { text-align: center; border-radius: 12px; background: var(--soft); color: var(--soft-ink); font-weight: 700; text-decoration: none; }
  table.cards td.row-actions .actions button { width: 100%; }
  table.cards td.hide-mobile { display: none; }
  table.cards tfoot { display: block; }
  table.cards tfoot tr { background: var(--subtle); }
  table.cards td:empty { display: none; }
  table.cards td .commission-form { width: 100%; justify-content: flex-end; }
}

/* ---------- Printing (kept last so it beats the phone rules: A4's printable width is < 720px) ---------- */
@page { size: auto; margin: 10mm; }
.report-heading { display: flex; align-items: center; gap: 14px; border-bottom: 2px solid #1d2f63; padding-bottom: 10px; margin-bottom: 18px; }
.report-heading img { width: 64px; height: 64px; object-fit: contain; }
.report-heading h2, .report-heading p { margin: 2px 0; }
.report-title { text-align: center; margin-bottom: 4px; }
.report-student { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 8px 14px; margin: 18px 0; }
.report-student dt { font-size: .82rem; color: var(--muted); }
.report-student dd { margin: 2px 0 0; font-weight: 700; }
.report-signatures { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin-top: 34px; text-align: center; }
@media print {
  @page { size: A4 portrait; margin: 14mm; }
  html, body, :root { background: #fff !important; min-height: 0 !important; height: auto !important; }
  :root { --ink: #161c33; --muted: #5f6782; --card: #fff; --line: #e3e7f0; --line-soft: #eceff6; --brand-dark: #1d2f63;
    --soft: #e3f4f0; --soft-ink: #0b5d52; --subtle: #f6f7fb; color-scheme: light; }  /* paper is white, even in dark mode */
  header.top, .bottom-nav, .cart-bar, .no-print, .notice, .toast, .sheet-backdrop, .scanner { display: none !important; }
  main, .invoice { margin: 0 !important; padding: 0 !important; max-width: none !important; }
  .card { border: 0 !important; box-shadow: none !important; padding: 0 !important; margin: 0 !important; }
  a { color: inherit; text-decoration: none; }
  .report-sheet { break-inside: avoid; }
  .report-heading { border-color: #333; }
  .report-student { grid-template-columns: 2fr 1fr 1fr 1fr; }
}

/* ---------- v2: jemaat, pelayanan, jemaat baru ---------- */
fieldset.stack-fieldset { display: grid; gap: 10px; padding: 10px 14px 14px; }
.hint.privacy { margin: 16px 0 0; }
.hint.csv-hint { margin: -6px 0 16px; line-height: 1.5; }
.hint.form-note { margin: 10px 0 4px; line-height: 1.5; }
dl.roster { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 8px 16px; margin: 0 0 12px; }
dl.roster div { min-width: 0; }
dl.roster dt { font-size: .8rem; color: var(--muted); font-weight: 600; }
dl.roster dd { margin: 2px 0 0; overflow-wrap: anywhere; }
.roster-card.today { border-color: var(--brand); box-shadow: inset 0 0 0 1px var(--brand); }
@media (max-width: 719px) {
  dl.roster { grid-template-columns: 1fr 1fr; }
  .bottom-nav a { font-size: .68rem; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
}

/* ---------- Language switch ---------- */
.lang-switch { display: inline-flex; border: 1px solid currentColor; border-radius: 99px; overflow: hidden; margin-left: 6px; flex: 0 0 auto; }
.lang-switch a { padding: 4px 9px; font-size: .78rem; font-weight: 700; text-decoration: none; min-height: 32px; display: inline-flex; align-items: center; opacity: .75; }
.lang-switch a.on { background: currentColor; opacity: 1; }
header.top .lang-switch a.on { color: var(--header-bg); background: #fff; }
body.public header.top .lang-switch a.on { color: var(--card); background: var(--brand-dark); }

/* ---------- Member ministries ---------- */
.ministry-row { display: grid; grid-template-columns: minmax(180px, 1.2fr) minmax(140px, .8fr) minmax(160px, 1.5fr); gap: 8px 12px; align-items: end;
  padding: 8px 0; border-bottom: 1px solid var(--line-soft); }
.ministry-row:last-child { border-bottom: 0; }
.ministry-row label.check { min-height: var(--tap); }
@media (max-width: 719px) { .ministry-row { grid-template-columns: 1fr 1fr; } .ministry-row label.check { grid-column: 1 / -1; } }
.training-row { display: grid; grid-template-columns: minmax(200px, 2fr) minmax(140px, 1fr) auto; gap: 8px 12px; align-items: end; }
@media (max-width: 719px) { .training-row { grid-template-columns: 1fr 1fr; } .training-row label:first-child { grid-column: 1 / -1; } }
.kk-address { background: var(--subtle); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin: 0; }
.tier-list { margin: 4px 0 0; padding-left: 18px; }
.card.upgrade { border-style: dashed; background: var(--subtle); }

/* ---------- Attendance (absensi) ---------- */
.checkin-family { border: 0; border-bottom: 1px solid var(--line-soft); margin: 0; padding: 8px 0; }
.checkin-family:last-of-type { border-bottom: 0; }
.checkin-family legend { display: flex; gap: 12px; align-items: center; justify-content: space-between; width: 100%; padding: 0; }
.checkin-family label.check { padding-left: 4px; }
.checkin-save { position: sticky; bottom: calc(76px + env(safe-area-inset-bottom)); z-index: 5; margin: 12px 0; }
.checkin-save button { width: 100%; box-shadow: 0 4px 14px rgba(0,0,0,.15); }
@media (min-width: 721px) { .checkin-save { bottom: 12px; } .checkin-save button { width: auto; } }
.area-chips { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 2px 14px; padding: 6px 10px; }
.area-chips label.check { min-height: 36px; font-weight: 500; }
a.stat:hover { border-color: var(--brand); }
.stat.on { border-color: var(--brand); box-shadow: inset 0 0 0 2px var(--brand); background: var(--soft); }

/* ---------- Member cards (85.6 x 54 mm, ID-1 size) ---------- */
.member-cards { display: grid; grid-template-columns: repeat(auto-fill, 85.6mm); gap: 4mm; justify-content: center; }
.member-card { width: 85.6mm; height: 54mm; border: 1px solid #b9c2d8; border-radius: 3mm; padding: 3mm 4mm; background: #fff;
  display: flex; flex-direction: column; overflow: hidden; break-inside: avoid; color: #111; }
.mc-head { display: flex; align-items: center; gap: 2mm; font-size: 8pt; font-weight: 700; color: #1d2f63;
  border-bottom: 0.4mm solid #1d2f63; padding-bottom: 1.2mm; }
.mc-head img { height: 6mm; width: auto; }
.mc-name { font-size: 12pt; font-weight: 800; margin-top: 2mm; line-height: 1.15; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.mc-meta { font-size: 7pt; color: #555; }
.mc-barcode { margin-top: auto; text-align: center; }
.mc-barcode svg { height: 12mm; width: auto; max-width: 100%; }
.mc-no { text-align: center; font-family: ui-monospace, monospace; font-size: 10pt; font-weight: 700; letter-spacing: .08em; }
@media print {
  .member-cards { gap: 3mm; justify-content: start; }
  .member-card { border-color: #999; }
}

/* ---------- Camera scanner + scan box (attendance) ---------- */
body.no-scroll { overflow: hidden; }
.scanner { position: fixed; inset: 0; z-index: 70; background: #000; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 16px; padding: 16px; }
.scanner-frame { position: relative; width: min(92vw, 480px); aspect-ratio: 3 / 4; border-radius: 16px; overflow: hidden; background: #111; }
.scanner-frame video { width: 100%; height: 100%; object-fit: cover; }
.scanner-line { position: absolute; left: 10%; right: 10%; top: 50%; height: 2px; background: #3ee08a; box-shadow: 0 0 12px #3ee08a; }
.scanner-msg { color: #fff; text-align: center; max-width: 420px; margin: 0; font-size: 1.1rem; }
.scanner-msg.error { color: #ffd0c8; }
.scanner-close { min-width: 160px; }
.scan-box { border-color: var(--brand); }
.scan-box input { font-size: 1.1rem; font-family: ui-monospace, monospace; }
.scan-ok { color: var(--ok-ink); font-weight: 700; }
.scan-error { color: var(--danger); font-weight: 700; }
label.scanned { animation: scanned 1.8s ease-out; border-radius: 8px; }
@keyframes scanned { from { background: var(--ok-bg); } to { background: transparent; } }
.journey-line { display: flex; flex-wrap: wrap; gap: 4px 18px; margin: 8px 0 0; }
.scan-sound { min-height: 32px; font-size: .9rem; margin-top: 4px; }
.gate-controls { display: grid; gap: 18px; }
.gate-controls > label { min-width: 0; }
.gate-help { margin: 0; padding: 12px 14px; border-top: 1px solid var(--line); line-height: 1.55; overflow-wrap: anywhere; }
@media (max-width: 719px) { .gate-controls .row { grid-template-columns: minmax(0, 1fr); } }

/* Full-screen scan feedback (above the camera overlay, never blocks taps) */
.scan-flash { position: fixed; inset: 0; z-index: 90; pointer-events: none; display: none; align-items: center; justify-content: center;
  font-size: min(40vw, 260px); font-weight: 900; color: #fff; text-shadow: 0 4px 24px #0006; }
.scan-flash.show { display: flex; animation: scan-flash .9s ease-out forwards; }
.scan-flash.ok { background: rgba(22, 163, 74, .78); }
.scan-flash.again { background: rgba(234, 179, 8, .78); }
.scan-flash.error { background: rgba(220, 38, 38, .82); }
@keyframes scan-flash { 0% { opacity: 1; } 55% { opacity: 1; } 100% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .scan-flash.show { animation: none; } }
.mc-register { text-align: center; font-size: 7.5pt; color: #333; }

/* ---------- searchable select (long KK list on a phone) ---------- */
.field { display: grid; gap: 6px; }
.ss-hidden { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.ss-box { display: grid; gap: 8px; }
.ss-chosen { background: var(--ok-bg); border: 1px solid var(--ok-ink); border-radius: 10px; padding: 10px 12px; }
.ss-list { display: grid; gap: 6px; }
.ss-row { display: grid; gap: 2px; text-align: left; width: 100%; min-height: var(--tap); padding: 10px 12px;
  background: var(--card); color: var(--ink); border: 1px solid var(--line); border-radius: 10px; font: inherit; cursor: pointer; }
.ss-row:hover, .ss-row:focus-visible { border-color: var(--brand); }
.ss-row.ss-current { border-color: var(--brand); background: var(--soft); }
.ss-row strong { font-weight: 600; }
.ss-note { margin: 2px 4px; }

/* ---------- filter chips (age groups on the attendance list) ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 12px; }
.chip { min-height: 36px; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--card);
  color: var(--ink); font: inherit; font-size: .9rem; cursor: pointer; }
.chip.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.age-rows { display: grid; gap: 10px; }
.age-row { display: grid; grid-template-columns: 2fr 2fr 1fr; gap: 8px; align-items: end; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
@media (max-width: 640px) { .age-row { grid-template-columns: 1fr 1fr; } .age-row label:first-child { grid-column: 1 / -1; } }

/* ---------- admin log ---------- */
pre.log { margin: 0; font-size: .78rem; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }
.log-warn { color: var(--warn-ink); }
.log-error { color: var(--danger); font-weight: 600; }

/* ---------- renungan (devotionals) ---------- */
.devotion-panel { border-left: 4px solid var(--gold); }
.verse-ref { margin: 0 0 8px; font-weight: 600; color: var(--brand-dark); }
blockquote.verse { margin: 0 0 12px; padding: 10px 14px; background: var(--gold-bg); border-radius: 10px; font-style: italic; white-space: pre-line; }
.devotion-full h1 { margin: 6px 0 8px; }
.devotion-body { white-space: pre-line; line-height: 1.7; font-size: 1.05rem; }
a.devotion-item { display: grid; gap: 4px; text-decoration: none; color: inherit; }
a.devotion-item:hover { border-color: var(--brand); }
.author-line { display: flex; align-items: center; gap: 8px; margin: 0 0 10px; }
.avatar { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; flex: 0 0 auto; border: 2px solid var(--card); box-shadow: 0 0 0 1px var(--line); }
.avatar.sm { width: 26px; height: 26px; border-width: 1px; }
.avatar.lg { width: 56px; height: 56px; }
.author-photo-field { display: flex; gap: 12px; align-items: flex-start; }

/* ---------- offerings: bank accounts & QRIS ---------- */
.bank-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.bank-row:last-of-type { border-bottom: 0; }
.account-no { font-size: 1.2rem; font-weight: 700; letter-spacing: .02em; font-variant-numeric: tabular-nums; margin: 2px 0; white-space: nowrap; }
.copy-btn { flex: 0 0 auto; }
.qris-box { text-align: center; margin-top: 14px; }
.qris-image { display: block; width: 100%; max-width: 320px; margin: 0 auto; border: 1px solid var(--line); border-radius: 12px; background: #fff; image-rendering: crisp-edges; }
.chips.mini { gap: 4px; margin: 8px 0 0; }
.chips.mini .chip { min-height: 28px; padding: 3px 10px; font-size: .8rem; text-decoration: none; display: inline-flex; align-items: center; gap: 4px; }
.chips.mini .chip strong { font-weight: 700; }

/* ---------- headings a touch bolder (matches the church app) ---------- */
h1 { font-weight: 800; }
h2, h3 { letter-spacing: -.01em; }


/* ---------- Beranda: Perlu perhatian ---------- */
.todo-card h2 { margin-bottom: 6px; }
.todo { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line-soft); text-decoration: none; color: var(--ink); }
.todo:last-child { border-bottom: 0; }
.todo-icon { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; flex: 0 0 auto; background: var(--soft); color: var(--soft-ink); }
.todo.late .todo-icon { background: var(--err-bg); color: var(--danger); }
.todo.due .todo-icon { background: var(--warn-bg); color: var(--warn-ink); }
.todo.ok .todo-icon { background: var(--ok-bg); color: var(--ok-ink); }
.todo-text { flex: 1; min-width: 0; font-weight: 600; font-size: .95rem; line-height: 1.35; }
.todo-go { display: inline-flex; align-items: center; gap: 2px; color: var(--brand); font-weight: 700; font-size: .85rem; white-space: nowrap; }
.todo-empty { display: flex; align-items: center; gap: 8px; margin: 4px 0 0; color: var(--ok-ink); font-weight: 600; }

/* ---------- "Lainnya" bottom sheet (phones) ---------- */
.bottom-nav .more-btn { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: var(--bottom-nav);
  background: none; color: var(--muted); font-size: .75rem; font-weight: 600; padding: 0; border-radius: 0; }
.bottom-nav .more-btn svg { width: 24px; height: 24px; padding: 3px 14px; box-sizing: content-box; border-radius: 999px; }
.bottom-nav .more-btn.active { color: var(--brand); }
.bottom-nav .more-btn.active svg { background: var(--soft); }
.more-sheet { margin: auto auto 0; width: 100%; max-width: 560px; border: 0; border-radius: 24px 24px 0 0; padding: 8px 16px calc(16px + env(safe-area-inset-bottom));
  background: var(--card); color: var(--ink); box-shadow: 0 -12px 40px #0f172a33; max-height: 85vh; overflow-y: auto; }
.more-sheet[open] { animation: sheet-up .25s ease-out; }
.more-sheet::backdrop { background: #0b1022a6; }
@keyframes sheet-up { from { transform: translateY(40px); opacity: .4; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .more-sheet[open] { animation: none; } }
.sheet-handle { width: 40px; height: 4px; border-radius: 99px; background: var(--line); margin: 4px auto 10px; }
.sheet-title { font-weight: 700; margin: 0 0 12px; }
.sheet-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px 6px; }
.sheet-grid a { display: grid; justify-items: center; gap: 6px; text-align: center; font-size: .75rem; font-weight: 600; color: var(--ink); text-decoration: none; }
.sheet-icon { width: 52px; height: 52px; border-radius: 18px; display: grid; place-items: center; background: var(--soft); color: var(--soft-ink); }
.sheet-grid a.on .sheet-icon { background: var(--brand); color: #fff; }
.sheet-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line-soft); }
.sheet-foot form { margin: 0; }
.sheet-foot .lang-switch { color: var(--brand-dark); }
.sheet-foot .lang-switch a.on { color: var(--card); background: var(--brand-dark); }


/* ---------- Save bar: the Simpan buttons of long forms stay in reach while scrolling ---------- */
.form-actions { position: sticky; bottom: 12px; z-index: 6; padding: 10px; margin-top: 4px; border-radius: 16px;
  background: color-mix(in srgb, var(--card) 92%, transparent); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 -2px 0 var(--line-soft), 0 8px 24px #0f172a14; }
@media (max-width: 719px) { .form-actions { bottom: calc(var(--bottom-nav) + 10px + env(safe-area-inset-bottom)); } }
@media print { .form-actions { position: static; box-shadow: none; } }

/* ---------- Usaha jemaat (office list) ---------- */
.biz-row { display: flex; gap: 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line-soft); }
.biz-row:last-child { border-bottom: 0; }
.biz-thumb { width: 52px; height: 52px; border-radius: 14px; object-fit: cover; flex: 0 0 auto; }
.biz-thumb.placeholder { font-size: 1.3rem; }
.biz-main { flex: 1; min-width: 0; display: grid; gap: 2px; }
.biz-main .badge { margin-top: 2px; }
.biz-main .badge { white-space: nowrap; }

/* ---------- Petugas duty areas (Tim pengurus) ---------- */
.area-badges { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.area-edit summary { padding: 4px 0; color: var(--brand); font-weight: 600; }
.area-picker label.check { min-height: 36px; }
.consent-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 0 16px; }
.card.danger-zone { border-color: var(--danger-line); }
.card.danger-zone h2 { color: var(--danger); }


/* ---------- School app ---------- */
.card.narrow { max-width: 520px; margin-left: auto; margin-right: auto; }
.admission-period-form { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; align-items: end; }
.admission-period-form .period-name { grid-column: 1 / -1; margin-bottom: 6px; }
.admission-period-list { display: grid; gap: 14px; margin-top: 28px; clear: both; }
.admission-period-item { display: grid; gap: 8px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--subtle); overflow-wrap: anywhere; }
.admission-period-item form { margin: 0; }
.admission-period-link { line-height: 1.5; overflow-wrap: anywhere; min-width: 0; }
.invoice-hint { margin: 12px 0 16px; line-height: 1.5; }
.payment-hint { margin: 12px 0 16px; line-height: 1.5; }
@media (max-width: 719px) {
  .admission-period-form { grid-template-columns: minmax(0, 1fr); }
  .admission-period-form .period-name { grid-column: auto; }
  .admission-period-form > button { width: 100%; }
}
.small-btn { min-height: 36px; padding: 6px 12px; font-size: .875rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 0 16px; }
.day-card.school { border-left: 6px solid var(--ok-ink); }
.day-card.off { border-left: 6px solid var(--warn-ink); }
.year-row { padding: 12px 0; border-bottom: 1px solid var(--line-soft); }
.year-row:last-of-type { border-bottom: 0; }
.month-nav { align-items: center; margin-bottom: 12px; }
.month-grid { display: grid; gap: 4px; }
.mg-row { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.mg-head span { text-align: center; font-size: .75rem; font-weight: 700; color: var(--muted); }
.mg-day { display: grid; place-items: center; min-height: 40px; border-radius: 10px; font-weight: 600; font-size: .9rem;
  background: var(--subtle); color: var(--muted); }
.mg-day.school { background: var(--ok-bg); color: var(--ok-ink); }
.mg-day.holiday { background: var(--err-bg); color: var(--danger); }
.mg-day.event { box-shadow: inset 0 0 0 2px var(--gold); }
.mg-day.today { outline: 2px solid var(--brand); outline-offset: 1px; }
.mg-day.empty { background: none; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; color: var(--muted); }
.mg-key { display: inline-block; width: 14px; height: 14px; border-radius: 4px; vertical-align: -2px; margin-right: -8px; background: var(--subtle); }
.mg-key.school { background: var(--ok-bg); } .mg-key.holiday { background: var(--err-bg); }
.mg-key.event { box-shadow: inset 0 0 0 2px var(--gold); background: none; }
.hours-table input[type=time] { min-width: 110px; }
.hours-table th[scope=row] { text-align: left; white-space: nowrap; }
.logo-field { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; }
.logo-field img { border-radius: 14px; border: 1px solid var(--line); object-fit: contain; background: #fff; }
.list-plain li.split > .wrap { white-space: normal; text-align: right; }
@media (max-width: 719px) {
  .hours-table thead { display: none; }
  .hours-table, .hours-table tbody { display: block; width: 100%; }
  .hours-table tr { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px 10px; padding: 12px 0;
    border-bottom: 1px solid var(--line-soft); }
  .hours-table tr:last-child { border-bottom: 0; }
  .hours-table th[scope=row], .hours-table td { padding: 0; border: 0; }
  .hours-table th[scope=row] { grid-column: 1 / 3; align-self: center; }
  .hours-table td:nth-child(2) { grid-column: 3; justify-self: end; }
  .hours-table td:nth-child(2) { display: flex; align-items: center; gap: 6px; }
  .hours-table td:nth-child(2)::before { content: attr(data-label); font-size: .85rem; color: var(--muted); }
  .hours-table td[data-label]:not(:nth-child(2))::before { content: attr(data-label); display: block; font-size: .75rem; color: var(--muted); margin-bottom: 2px; }
  .hours-table input[type=time] { min-width: 0; width: 100%; }
}
.stat span { color: var(--muted); font-size: .85rem; }
.stat.warn { background: var(--warn-bg); border-color: transparent; }
.stat.warn strong { color: var(--warn-ink); }
.stats + .card, .tabs + .stats { margin-top: 12px; }
.check-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 2px 16px; max-height: 360px; overflow: auto; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
.facts dt { color: var(--muted); font-size: .9rem; }
.facts dd { margin: 0; overflow-wrap: anywhere; }
@media (max-width: 480px) { .facts { grid-template-columns: 1fr; gap: 0; } .facts dd { margin-bottom: 8px; } }
.steps { margin: 0; padding-left: 20px; display: grid; gap: 6px; }

/* ---------- Student cards (print: A4, 2 x 5 cards of 85.6 x 54 mm) ---------- */
.card-sheet { display: grid; grid-template-columns: repeat(auto-fill, 85.6mm); gap: 4mm; justify-content: center; margin-top: 16px; }
.id-card { width: 85.6mm; height: 54mm; border: .3mm solid #9aa; border-radius: 3mm; overflow: hidden; background: #fff; color: #111;
  display: flex; flex-direction: column; break-inside: avoid; font-size: 8pt; }
.id-card header { background: #0f4c45; color: #fff; display: flex; align-items: center; gap: 2mm; padding: 1.8mm 3mm; font-weight: 700; font-size: 8.5pt; }
.id-card header img { width: 7mm; height: 7mm; object-fit: contain; background: #fff; border-radius: 1mm; }
.id-body { flex: 1; display: flex; gap: 2mm; padding: 2.5mm 3mm; align-items: center; }
.id-text { flex: 1; min-width: 0; }
.id-text p { margin: 0 0 1mm; }
.id-label { font-size: 6.5pt; letter-spacing: .08em; color: #0f7a6c; font-weight: 700; }
.id-name { font-size: 11pt; font-weight: 800; line-height: 1.15; overflow-wrap: anywhere; }
.id-qr { width: 30mm; flex: 0 0 30mm; text-align: center; }
.id-qr svg { width: 30mm; height: 30mm; display: block; }
.id-qr span { font-family: ui-monospace, monospace; font-size: 7pt; letter-spacing: .06em; }
@media print {
  @page { size: A4; margin: 10mm; }
  body { background: #fff; }
  main { margin: 0; max-width: none; padding: 0; }
  .card-sheet { grid-template-columns: repeat(2, 85.6mm); gap: 0 6mm; margin: 0; }
  .id-card { margin-bottom: 1mm; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

a.stats-card { display: block; text-decoration: none; color: inherit; }
a.stats-card .stat { box-shadow: none; }
/* Gate scanner */
.gate-result { border-radius: var(--radius); padding: 18px 20px; margin: 12px 0; background: var(--subtle); border: 1px solid var(--line); }
.gate-result strong { display: block; font-size: clamp(1.5rem, 6vw, 2.4rem); line-height: 1.15; }
.gate-result span { display: block; margin-top: 4px; font-size: 1.05rem; }
.gate-result.ok { background: var(--ok-bg); color: var(--ok-ink); }
.gate-result.late { background: #ffe7d1; color: #8a3b00; }
.gate-result.again, .gate-result.warn { background: var(--warn-bg); color: var(--warn-ink); }
.gate-result.error { background: var(--err-bg); color: var(--danger); }
@media (prefers-color-scheme: dark) { .gate-result.late { background: #3d2412; color: #ffb37a; } }
.gate-list { margin: 0; padding-left: 0; list-style: none; font-size: .9rem; display: grid; gap: 4px; }
.gate-list li { padding: 6px 10px; border-radius: 10px; background: var(--subtle); white-space: pre-wrap; }
.gate-list li.late { background: #ffe7d1; color: #8a3b00; } .gate-list li.error { color: var(--danger); }
.scan-flash.late { background: rgba(234, 88, 12, .8); }
.scanner-msg { font-size: 1.35rem; font-weight: 700; }
/* Attendance */
.att-table tr.missing td.primary strong { color: var(--warn-ink); }
.att-table select { min-width: 140px; }
.att-table input { min-width: 0; }
.att { font-weight: 600; } .att.alpa { color: var(--danger); } .att.terlambat { color: #b45309; } .att.belum { color: var(--muted); }
.recap-table th[scope=row] { text-align: left; font-weight: 600; white-space: nowrap; }
.recap-table td { text-align: center; } .recap-table td.bad { color: var(--danger); font-weight: 800; }
.input-with-button { display: flex; gap: 8px; } .input-with-button input { flex: 1; min-width: 0; }
.table-wrap.scroll { overflow-x: auto !important; }  /* wide number tables scroll inside the card on phones */

/* ---------- Parent portal ---------- */
body.portal main { max-width: 640px; }
.portal-push-hint { display: block; text-decoration: none; color: inherit; }
a.child-card { display: block; text-decoration: none; color: inherit; border-left: 6px solid var(--line); }
a.child-card.hadir, a.child-card.pulang { border-left-color: var(--ok-ink); }
a.child-card.terlambat { border-left-color: #ea580c; }
a.child-card.belum, a.child-card.alpa { border-left-color: var(--danger); }
a.child-card.izin, a.child-card.sakit { border-left-color: var(--gold); }
.child-name { font-size: 1.15rem; }
.child-state { font-size: 1.2rem; font-weight: 700; margin: 8px 0 4px; }
.notice-list li { padding: 10px 0; border-bottom: 1px solid var(--line-soft); }
.notice-list li:last-child { border-bottom: 0; }
.notice-list li.terlambat strong { color: #b45309; } .notice-list li.belum_tiba strong { color: var(--danger); }
.portal-rows li { padding: 10px 0; border-bottom: 1px solid var(--line-soft); flex-wrap: wrap; }

/* Messaging: keep the page still and scroll the transcript independently, like a chat app. */
body.chat-open { height: 100vh; height: 100dvh; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
body.chat-open > header.top { flex: 0 0 auto; }
body.chat-open > main.chat-main { flex: 1 1 auto; min-height: 0; width: min(100%, 900px); margin: 0 auto; padding: 12px 16px max(12px, env(safe-area-inset-bottom)); display: flex; flex-direction: column; overflow: hidden; }
body.chat-open .bottom-nav { display: none; }
.chat-layout { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; overflow: hidden; background: var(--card); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); }
.chat-heading { flex: 0 0 auto; display: flex; align-items: center; gap: 12px; padding: 10px 16px; border-bottom: 1px solid var(--line); }
.chat-heading h1 { font-size: 1.1rem; margin: 0; }
.chat-heading p { color: var(--muted); font-size: .85rem; margin: 2px 0 0; }
.chat-back { flex: 0 0 42px; width: 42px; height: 42px; display: grid; place-items: center; border-radius: 50%; background: var(--soft); color: var(--soft-ink); text-decoration: none; font-size: 2rem; line-height: 1; }
.chat-log { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; display: flex; flex-direction: column; gap: 10px; padding: 16px; background: color-mix(in srgb, var(--soft) 28%, var(--bg)); scroll-padding-bottom: 12px; }
.chat-message { align-self: flex-start; width: fit-content; max-width: min(88%, 620px); padding: 9px 12px 6px; border: 1px solid var(--line); border-radius: 16px 16px 16px 4px; background: var(--card); box-shadow: 0 1px 2px #0f172a12; }
.chat-message p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.45; }
.chat-message time { display: block; text-align: right; margin-top: 4px; color: var(--muted); font-size: .7rem; }
.chat-log[data-viewer="parent"] .chat-message.parent, .chat-log[data-viewer="staff"] .chat-message.staff { align-self: flex-end; border-radius: 16px 16px 4px 16px; border-color: #0f7a6c; background: #0f7a6c; color: #fff; }
.chat-log[data-viewer="parent"] .chat-message.parent time, .chat-log[data-viewer="staff"] .chat-message.staff time { color: #e2f4f0; }
.chat-empty { margin: auto; padding: 16px; color: var(--muted); text-align: center; }
.chat-error { flex: 0 0 auto; margin: 8px 12px 0; }
.chat-composer { flex: 0 0 auto; display: flex; align-items: flex-end; gap: 8px; margin: 0; padding: 10px 12px max(10px, env(safe-area-inset-bottom)); background: var(--card); border-top: 1px solid var(--line); }
.chat-composer textarea { flex: 1 1 auto; min-width: 0; min-height: 44px; max-height: 120px; resize: vertical; border-radius: 22px; padding: 11px 15px; line-height: 1.35; }
.chat-composer button { flex: 0 0 auto; min-height: 44px; padding: 0 18px; border-radius: 22px; }
@media (max-width: 720px) {
  body.chat-open > main.chat-main { width: 100%; padding: 8px 8px max(8px, env(safe-area-inset-bottom)); }
  .chat-layout { border-radius: 14px; }
  .chat-heading { padding: 8px 12px; }
  .chat-log { padding: 12px 10px; }
  .chat-message { max-width: 92%; }
  .chat-composer { padding: 8px 8px max(8px, env(safe-area-inset-bottom)); }
}

/* ---------- Keuangan: tabs, status chips, student search ---------- */
.finance-tabs { overflow-x: auto; flex-wrap: nowrap; padding-bottom: 4px; scrollbar-width: none; }
.finance-tabs a { white-space: nowrap; flex: 0 0 auto; }
.status-chips { margin: 12px 0; }
.status-chips a.badge { text-decoration: none; }
.inline-label { display: flex; align-items: center; gap: 8px; font-weight: 600; flex: 0 1 auto; }
.inline-label input { min-width: 150px; }
.student-picker { position: relative; grid-column: 1 / -1; }
.student-picker-results { position: absolute; z-index: 20; left: 0; right: 0; top: 100%; margin-top: 4px; max-height: 320px; overflow-y: auto;
  background: var(--card); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); padding: 4px; }
.student-picker-option { display: flex; flex-direction: column; align-items: flex-start; width: 100%; text-align: left; gap: 2px;
  background: none; color: inherit; padding: 10px 12px; border-radius: 10px; min-height: 44px; font-weight: 400; }
.student-picker-option:hover, .student-picker-option:focus { background: var(--soft); outline: none; }
.student-picker-option span, .student-picker-message { color: var(--muted); font-size: .85rem; }
.student-picker-message { margin: 0; padding: 10px 12px; }
.student-picker-selected { margin: 6px 0 0; color: var(--ok-ink); font-weight: 600; font-size: .9rem; }
.open-invoices { grid-column: 1 / -1; }
.open-invoices table { font-size: .95rem; }
.proof-item { display: flex; flex-wrap: wrap; gap: 10px 16px; justify-content: space-between; align-items: center; }
.proof-item form, .reversal-form form { display: flex; gap: 8px; flex-wrap: wrap; margin: 0; }
.proof-item form input, .reversal-form input { min-width: 180px; flex: 1 1 180px; }
.reversal-form summary { color: var(--danger); font-weight: 600; padding: 8px 0; }
.reversal-form[open] { flex-basis: 100%; }
@media screen and (max-width: 720px) {
  .finance-stats { grid-template-columns: 1fr 1fr; gap: 8px; }
  .finance-stats .stat { padding: 10px 12px; }
  .finance-stats .stat strong { font-size: 1.3rem; }
  .finance-stats .stat strong.money { font-size: 1rem; white-space: nowrap; }
  .finance-stats .stat span { font-size: .8rem; }
  .filters .inline-label { grid-column: 1 / -1; }
  .filters .inline-label input { flex: 1 1 auto; }
  .status-chips { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .status-chips .badge { white-space: nowrap; flex: 0 0 auto; }
}

/* ---------- Portal orang tua: halaman anak ---------- */
.child-hero { display: grid; gap: 14px; }
.child-id { display: flex; gap: 12px; align-items: center; }
.child-id h1 { margin: 0; font-size: 1.4rem; line-height: 1.2; }
.child-id p { margin: 2px 0 0; }
.child-avatar { width: 48px; height: 48px; flex: 0 0 48px; border-radius: 50%; display: grid; place-items: center;
  background: var(--brand); color: #fff; font-weight: 800; font-size: 1.3rem; }
.child-actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.child-actions a { position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 4px;
  border-radius: 14px; background: var(--soft); color: var(--soft-ink); text-decoration: none; font-weight: 600; font-size: .8rem;
  text-align: center; min-height: 64px; }
.child-actions .child-action-icon { font-size: 1.2rem; line-height: 1.2; font-weight: 800; }
.child-actions .badge { position: absolute; top: 4px; right: 4px; font-size: .7rem; padding: 1px 6px; }
.child-actions .badge.warn { position: static; margin-top: 2px; }
.child-tabs { overflow-x: auto; flex-wrap: nowrap; scrollbar-width: none; margin-top: 4px; }
.child-tabs a { white-space: nowrap; flex: 0 0 auto; }
.child-stats { grid-template-columns: repeat(4, 1fr); margin-bottom: 12px; }
.balance-card { border-left: 4px solid var(--ok-ink, #1f7a4d); }
.balance-card.due { border-left-color: var(--warn-ink); }
.balance-amount { display: block; font-size: 1.9rem; line-height: 1.2; margin: 2px 0 4px; }
details.more { border-top: 1px solid var(--line-soft); }
details.more:first-child { border-top: 0; }
details.more > summary { padding: 12px 0; min-height: 44px; }
details.more[open] > summary { padding-bottom: 6px; }
.segmented { display: inline-grid; grid-auto-flow: column; gap: 4px; padding: 4px; border-radius: 14px; background: var(--soft); }
.segmented label { margin: 0; }
.segmented label { position: relative; }
.segmented input { position: absolute; inset: 0; width: 1px; height: 1px; min-height: 0; opacity: 0; pointer-events: none; }
.segmented span { display: block; padding: 8px 22px; border-radius: 10px; font-weight: 700; color: var(--soft-ink); cursor: pointer; }
.segmented input:checked + span { background: var(--brand); color: #fff; }
.segmented input:focus-visible + span { outline: 2px solid var(--brand); outline-offset: 2px; }
@media screen and (max-width: 720px) {
  .child-stats { grid-template-columns: 1fr 1fr; gap: 8px; }
  .child-stats .stat { padding: 10px 12px; }
  .child-stats .stat strong { font-size: 1.4rem; }
}

/* ---------- Portal: pemilih foto (kamera / galeri) ---------- */
.photo-picker { position: relative; display: grid; gap: 8px; }
.photo-label { font-weight: 600; }
.photo-input { position: absolute; left: 0; top: 24px; width: 1px; height: 1px; opacity: 0; }
.photo-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.photo-buttons button { min-height: 48px; }
.photo-chosen { display: none; align-items: center; gap: 10px; padding: 8px; border: 1px solid var(--line); border-radius: 14px; }
.photo-picker.has-photo .photo-chosen { display: flex; }
.photo-chosen img { width: 64px; height: 64px; object-fit: cover; border-radius: 10px; flex: 0 0 64px; }
.photo-chosen span { flex: 1; min-width: 0; overflow-wrap: anywhere; }

/* ---------- Phones: header fits the screen ---------- */
/* Keluar, unit name, unit switch and Admin all live in the "Lainnya" sheet on phones; header keeps only
   the brand plus alerts that actually have something waiting. */
@media screen and (max-width: 719px) {
  header.top { overflow: hidden; }
  header.top .tools > form, header.top .tools .store-name, header.top .tools .church-switch,
  header.top .tools .admin-link { display: none; }
  header.top .tools { gap: 6px; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  header.top .message-alert-link { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; flex: 0 0 auto;
    padding: 6px 10px; min-height: 36px; border-radius: 99px; background: #ffffff1f; font-size: .8rem; font-weight: 600; }
  header.top .message-alert-link:has(.badge[hidden]), header.top .message-alert-link[hidden] { display: none; }
  header.top .message-alert-link .badge { font-size: .72rem; padding: 1px 6px; }
}
@media screen and (max-width: 719px) {
  /* 2 per row so 4 stats make a tidy 2x2; exactly 3 still share one row. */
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats:has(> :nth-child(3):last-child) { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .stat span { overflow-wrap: anywhere; }
}

/* ---------- Mobile helpers for card tables ---------- */
.show-mobile { display: none; }
.guardian-chip { white-space: nowrap; }
@media screen and (max-width: 719px) {
  .show-mobile { display: block; margin-top: 2px; }
  table.cards td.stack-mobile { display: block; text-align: left; }
  table.cards td.stack-mobile::before { display: block; margin-bottom: 2px; }
  table.cards td.stack-mobile br { display: none; }
  table.cards td.stack-mobile .guardian-chip { display: inline-block; margin-right: 12px; }
}
@media screen and (max-width: 719px) {
  .report-student { grid-template-columns: 1fr 1fr; }
  .report-student dd { overflow-wrap: anywhere; }
}
.report-signatures { grid-template-columns: repeat(2, minmax(0, 1fr)); overflow-wrap: anywhere; }
@media screen and (max-width: 719px) {
  /* Forms inside a card-table cell (PPDB decisions etc.) take the full card width, one field per line. */
  table.cards td form.row { grid-template-columns: minmax(0, 1fr); width: 100%; margin-top: 8px; }
  table.cards td:has(> form.row) { display: block; text-align: left; }
  .report-signatures { gap: 12px; }
}
/* Tablets / small laptops: the full menu plus alerts don't fit one line, so the tools may wrap. */
@media screen and (min-width: 720px) and (max-width: 1179px) {
  header.top .tools { flex-wrap: wrap; row-gap: 0; }
  header.top .message-alert-link { white-space: nowrap; font-size: .9rem; }
  header.top .store-name, header.top .church-switch { max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

/* ---------- Input nilai: satu penilaian per layar ---------- */
.assessment-chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding: 2px 0 6px; margin-bottom: 4px; }
.assessment-chips a { flex: 0 0 auto; display: grid; gap: 1px; min-width: 120px; padding: 8px 12px; border-radius: 14px;
  background: var(--card); border: 1px solid var(--line); color: inherit; text-decoration: none; }
.assessment-chips a.on { border-color: var(--brand); box-shadow: inset 0 0 0 1px var(--brand); }
.assessment-chips span { font-size: .78rem; color: var(--muted); }
.assessment-chips .chip-progress { color: var(--warn-ink); font-weight: 600; }
.assessment-chips .chip-progress.complete { color: var(--ok-ink); }
.score-head h2 { margin: 0; }
.score-head p { margin: 2px 0 0; }
.score-list { list-style: none; margin: 12px 0 0; padding: 0; }
.score-row { padding: 8px 0; border-bottom: 1px solid var(--line-soft); }
.score-row:last-child { border-bottom: 0; }
.score-row.locked { opacity: .6; }
.score-main { display: flex; align-items: center; gap: 10px; }
.score-no { flex: 0 0 26px; color: var(--muted); font-size: .82rem; text-align: right; }
.score-name { flex: 1 1 auto; min-width: 0; font-weight: 600; overflow-wrap: anywhere; }
.score-input { flex: 0 0 86px; width: 86px; min-width: 0; text-align: center; font-size: 1.15rem; font-weight: 700; padding: 8px 6px; }
.score-input.invalid { border-color: var(--danger); background: var(--err-bg); color: var(--danger); }
.score-note { margin: 2px 0 0 36px; }
.score-note > summary { padding: 4px 0; min-height: 0; font-size: .82rem; color: var(--muted); }
.score-note[open] > summary { color: var(--brand); }
.score-note input { margin-top: 4px; }
.score-text { width: 100%; margin-top: 6px; }
.score-actions { align-items: center; justify-content: space-between; }
.score-count { font-weight: 600; font-size: .9rem; color: var(--muted); }
.score-count.bad { color: var(--danger); }
.danger-zone > summary { color: var(--danger); font-weight: 600; }
@media screen and (max-width: 719px) {
  .score-actions { flex-wrap: nowrap; }
  .score-actions > button { flex: 0 0 auto; width: auto; padding: 0 22px; }
}
.tabs.scroll-tabs { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
.tabs.scroll-tabs a { white-space: nowrap; flex: 0 0 auto; }
.reminder-bar { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; justify-content: space-between; margin: 0 0 12px; }
.reminder-bar span { flex: 1 1 240px; }
.role-edit > summary { cursor: pointer; padding: 6px 0; min-height: 32px; }
.role-edit form { margin-top: 6px; gap: 6px; }
