:root {
  --ink: #1b2340; --muted: #5d6680; --bg: #f4f6fb; --card: #fff; --line: #dfe4ef;
  --brand: #2d4fa3; --brand-dark: #1d2f63; --gold: #c9962b; --danger: #a33434; --warn-bg: #fff6e0; --err-bg: #fff1ee; --ok-bg: #e7f4ec;
  --tap: 44px; --bottom-nav: 64px;
  font-family: Inter, 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%;
}
* { 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(--brand-dark); 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: #fff;
  border-top: 1px solid var(--line); box-shadow: 0 -4px 16px #14204a14;
  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); }

/* ---------- 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: 14px; padding: 20px; margin: 16px 0; box-shadow: 0 6px 22px #14204a0a; }
.notice { padding: 12px 14px; border-radius: 10px; 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 #c4cee6; }
.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: #8a5a00; }
.status.active { background: #dff3e6; color: #11633f; }
.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 #cfd6e6; border-radius: 10px; padding: 10px 12px;
  font: inherit; font-size: 16px; background: #fff; 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: 10px; 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; }
.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: 10px; 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: #e6ebf6; color: var(--ink); }
button.danger, .button.danger { background: #fbeaea; 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 #e6eaf3; 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: #e6ebf6; color: var(--ink); text-decoration: none; vertical-align: middle; }
.badge.warn { background: var(--warn-bg); color: #8a5a00; }
.badge.service { background: #e8eefc; color: #2a4a9a; }
.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: #e6ebf6; color: var(--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.ready { background: var(--ok-bg); color: var(--brand-dark); }
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: 14px; padding: 14px 16px; text-decoration: none; color: inherit; }
.stat strong { display: block; font-size: 1.9rem; line-height: 1.2; }
.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 #e6eaf3; }
.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 #e6eaf3; 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 #e6eaf3; }
.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: #f5f7fc; 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: #f5f7fc; border-radius: 10px; }
.switch { flex: 0 0 auto; position: relative; width: 56px; min-height: 32px; height: 32px; padding: 0; border-radius: 99px;
  background: #cdd4e3; 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: #fff3dc; color: #7a4d00; border: 1px solid #f0d49a; }
button.danger { border: 1px solid #f1c9c9; }
@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: #e3f3e8; color: #19663c; }
.vis.shared { background: #e6ebf6; color: var(--brand-dark); }
.vis.internal { background: #f1e8f8; color: #6a2a9a; }
.important { border-left: 4px solid var(--gold); }
.badge.gold { background: #fbf1da; color: #7a5300; }
.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 #e6eaf3; 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 #e6eaf3; }
.tree-row:last-child { border-bottom: 0; }
.tree-row .indent { flex: 0 0 auto; color: #b3bdd6; 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: #fff; 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: #f5f7fc; border: 1px dashed #b7c3e0; border-radius: 10px; padding: 8px 14px; display: inline-block; }

/* ---------- Public pages ---------- */
body.public header.top { background: #fff; 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(--brand-dark); 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 #e6eaf3;
  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: #e6ebf6; }
.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; }
  .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: 12px; padding: 10px 12px; margin-bottom: 10px; background: #fff; }
  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 #eef1f7; }
  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: 10px; background: #e6ebf6; color: var(--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: #f5f7fc; }
  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; }
@media print {
  html, body, :root { background: #fff !important; min-height: 0 !important; height: auto !important; }
  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; }
}

/* ---------- v2: jemaat, pelayanan, jemaat baru ---------- */
fieldset.stack-fieldset { display: grid; gap: 10px; padding: 10px 14px 14px; }
.hint.privacy { margin: 16px 0 0; }
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(--brand-dark); background: #fff; }
body.public header.top .lang-switch a.on { color: #fff; 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 #eef1f7; }
.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: #f5f7fc; 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: #fbfcff; }

/* ---------- Attendance (absensi) ---------- */
.checkin-family { border: 0; border-bottom: 1px solid #e6eaf3; 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: #f5f7fc; }

/* ---------- 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: var(--brand-dark);
  border-bottom: 0.4mm solid var(--brand-dark); 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: #11633f; 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: #c9f0d6; } 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; }

/* 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; }
