/* =====================================================================
   ChurchDB styles. Plain CSS, no framework.
   Sections: tokens · base · buttons · auth · shell (sidebar/topbar) · directory · family card ·
             member card · change highlighting · admin pages (tables/dialogs) · toast · responsive
   ===================================================================== */

/* ---------------------------------------------------------------- tokens */
:root {
  --navy-900: #1b2550;
  --navy-800: #26356b;
  --navy-700: #2f4382;
  --navy-500: #3d5ea8;
  --navy-grad: linear-gradient(120deg, #1f2a5a 0%, #2f4382 55%, #4466b0 100%);
  --gold: #c9a227;
  --gold-soft: #fbf3d9;
  --gold-text: #8a6a00;
  --green: #1e7b3a;
  --green-soft: #e4f5e9;
  --red: #c0392b;
  --red-soft: #fdecea;
  --bg: #f3f4fb;
  --panel: #ffffff;
  --line: #e2e6f0;
  --line-strong: #cfd5e4;
  --text: #1f2a44;
  --muted: #6b7489;
  --input-bg: #ffffff;
  --input-tint: #edf1fc;
  --changed-bg: #fff6d1;
  --changed-line: #e2ad00;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 6px 24px rgba(31, 42, 90, .08);
  --shadow-lg: 0 14px 40px rgba(31, 42, 90, .16);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", sans-serif;
  font-size: 15px;
  color: var(--text);
}

/* ---------------------------------------------------------------- base */
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); }
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0; color: var(--navy-900); }
a { color: var(--navy-500); }
.muted { color: var(--muted); }
.grow { flex: 1; }

.ic { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.ic.xl { width: 44px; height: 44px; }

input, select, textarea {
  font: inherit; color: var(--text); background: var(--input-bg);
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  padding: 10px 12px; width: 100%; min-width: 0;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
input::placeholder, textarea::placeholder { color: #a8b0c2; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--navy-500); box-shadow: 0 0 0 3px rgba(61, 94, 168, .15); }
input[readonly] { background: #f6f7fb; color: var(--muted); }
textarea { resize: vertical; min-height: 44px; }

/* Field = small uppercase label above an input */
.field { display: flex; flex-direction: column; gap: 6px; font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--navy-800); }
.field > input, .field > select, .field > textarea { font-size: 15px; font-weight: 400; letter-spacing: 0; text-transform: none; }

/* ---------------------------------------------------------------- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-weight: 600; padding: 10px 18px; border-radius: var(--radius-sm);
  border: 1px solid transparent; cursor: pointer; white-space: nowrap; text-decoration: none;
  transition: transform .05s, box-shadow .15s, background .15s;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary { background: var(--navy-grad); color: #fff; box-shadow: 0 4px 12px rgba(38, 53, 107, .25); }
.btn-primary:hover { box-shadow: 0 6px 18px rgba(38, 53, 107, .35); }
.btn-outline { background: #fff; border-color: var(--line-strong); color: var(--navy-800); }
.btn-outline:hover { border-color: var(--navy-500); }
.btn-danger-ghost { background: var(--red-soft); color: var(--red); }
.btn-logout { background: #fff5f4; color: var(--red); border: 2px solid #e6a39c; border-radius: 999px; padding: 8px 20px; }
.btn-lg { padding: 13px 26px; font-size: 16px; }
.btn-sm { padding: 6px 12px; font-size: 13px; gap: 6px; }
.btn-sm .ic { width: 14px; height: 14px; }
.btn-block { width: 100%; }
.btn-icon { display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 10px; border: 0; background: transparent; color: inherit; cursor: pointer; }
.btn-icon:hover { background: rgba(0, 0, 0, .05); }

/* ---------------------------------------------------------------- auth view */
.auth-banner {
  display: flex; align-items: center; gap: 16px; padding: 18px 22px; color: #fff;
  background: var(--navy-grad); border-radius: 0 0 18px 18px; box-shadow: var(--shadow-lg);
}
.brand-tile { display: grid; place-items: center; width: 56px; height: 56px; border-radius: 14px; background: rgba(255, 255, 255, .12); border: 1px solid rgba(255, 255, 255, .18); }
.brand-tile .ic { width: 30px; height: 30px; color: #cfd6ea; }
.brand-name { font-size: 20px; font-weight: 700; }
.brand-sub { font-size: 13px; opacity: .8; margin-top: 2px; }

.auth-card {
  width: min(400px, calc(100% - 32px)); margin: 50px auto; padding: 30px 26px;
  background: var(--panel); border-radius: 18px; box-shadow: var(--shadow-lg); text-align: center;
}
.auth-icon { display: grid; place-items: center; width: 62px; height: 62px; margin: 0 auto 14px; border-radius: 50%; background: var(--input-tint); border: 1px solid var(--line-strong); color: var(--navy-800); }
.auth-icon .ic { width: 28px; height: 28px; }
.auth-screen { display: flex; flex-direction: column; gap: 12px; }
.auth-screen h2 { font-size: 20px; }
.auth-screen p { margin: -6px 0 6px; font-size: 14px; }
.auth-screen input, .auth-screen select { background: var(--input-tint); border-color: #d6def5; text-align: center; padding: 12px; }
.auth-screen .two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.code-input { font-size: 26px; letter-spacing: 12px; font-weight: 700; }
.auth-links { display: flex; justify-content: space-between; font-size: 14px; margin-top: 4px; }
.auth-links a { text-decoration: none; }

/* ---------------------------------------------------------------- app shell */
.shell { display: grid; grid-template-columns: 270px minmax(0, 1fr); min-height: 100vh; }

.sidebar {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column;
  background: var(--navy-grad); color: #e7ebf7; padding: 18px 14px;
}
.side-brand { display: flex; align-items: center; gap: 12px; padding: 4px 6px 22px; border-bottom: 1px solid rgba(255, 255, 255, .12); }
.side-brand .brand-tile { width: 46px; height: 46px; }
.side-brand .brand-name { font-size: 17px; color: #fff; }
.side-nav { display: flex; flex-direction: column; gap: 4px; margin-top: 18px; }
.nav-item {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 12px;
  color: #d5dbee; text-decoration: none; font-weight: 600; transition: background .15s;
}
.nav-item:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.nav-item.active { background: #fff; color: var(--navy-800); box-shadow: 0 6px 16px rgba(0, 0, 0, .18); }
.nav-item.active .ic { color: var(--gold); }
.nav-badge { margin-left: auto; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px; background: var(--gold); color: #fff; font-size: 12px; display: grid; place-items: center; }
.side-footer { margin-top: auto; padding-top: 14px; border-top: 1px solid rgba(255, 255, 255, .12); }
.me { display: flex; align-items: center; gap: 10px; padding: 6px; }
.me-name { font-weight: 600; color: #fff; }
.me-email { font-size: 12px; opacity: .75; word-break: break-all; }

.main { padding: 0 28px 60px; min-width: 0; }
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 14px;
  margin: 0 -28px 22px; padding: 16px 28px; background: rgba(243, 244, 251, .98);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
}
.topbar-title { display: flex; align-items: center; gap: 12px; flex: 1; }
.topbar h1 { font-size: 26px; }
.title-icon { color: var(--gold); display: grid; }
.title-icon .ic { width: 28px; height: 28px; stroke-width: 2.2; }
.menu-btn { display: none; }
.scrim { display: none; }

.panel { background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.empty-state { text-align: center; padding: 50px 20px; color: var(--muted); }
.empty-state h2 { margin: 10px 0 6px; }

/* ---------------------------------------------------------------- directory (households page) */
.church-line { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 14px; }
.church-line select { width: auto; min-width: min(280px, 100%); max-width: 100%; padding: 8px 12px; }
.church-line select.diocese-filter { min-width: min(180px, 100%); }   /* js/church-picker.js */
.field select.diocese-filter { margin-bottom: 6px; }

/* Compact bar: "All by" chips on the left, the church filter on the right (wraps on small screens) */
.hh-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.sort-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.sort-chips > .muted { font-size: 14px; font-weight: 600; margin-right: 2px; }
.sort-btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px;
  font: inherit; font-size: 14px; font-weight: 600; color: var(--navy-900); cursor: pointer;
  background: #fff; border: 1px solid var(--line-strong); border-radius: 999px; transition: box-shadow .15s, background .15s;
}
.sort-btn .ic { color: var(--navy-500); width: 16px; height: 16px; }
.sort-btn:hover { box-shadow: 0 2px 8px rgba(31, 42, 90, .12); }
.sort-btn.active { background: var(--gold-soft); border-color: var(--gold); }

.segmented { display: flex; gap: 4px; padding: 6px; margin: 16px 0; border-radius: 999px; background: #e8ebf6; box-shadow: inset 0 1px 3px rgba(0, 0, 0, .05); }
.segmented button { flex: 1; padding: 13px 10px; border: 0; border-radius: 999px; font: inherit; font-size: 16px; font-weight: 600; color: #7d86a6; background: transparent; cursor: pointer; }
.segmented button.active { background: var(--navy-grad); color: #fff; box-shadow: 0 6px 14px rgba(38, 53, 107, .3); }
.segmented.small { margin: 0; padding: 4px; }
.segmented.small button { padding: 8px 16px; font-size: 14px; white-space: nowrap; }
.segmented button .ic { width: 16px; height: 16px; vertical-align: -3px; }

/* Line View / Card View in the top bar - only on the Households page */
.view-switch { flex: none; }
.view-switch button { display: inline-flex; align-items: center; gap: 7px; padding: 10px 18px; font-size: 15px; }
#appView:not([data-page="households"]) .view-switch { display: none; }

.search-row { display: flex; align-items: center; gap: 12px; padding-top: 16px; border-top: 1px solid var(--line); }
.circle-btn { flex: none; display: grid; place-items: center; width: 54px; height: 54px; border-radius: 50%; border: 1px solid var(--line-strong); background: #fff; color: var(--muted); cursor: pointer; }
.circle-btn:hover { color: var(--red); border-color: var(--red); }
.search-input { height: 56px; border-radius: 14px; font-size: 17px; padding: 0 20px; }
.count-bubble { flex: none; display: grid; place-items: center; min-width: 46px; height: 46px; padding: 0 8px; border-radius: 23px; background: var(--gold-soft); border: 1px solid #f0d98a; color: var(--gold-text); font-weight: 700; }

.action-row { display: flex; gap: 12px; flex-wrap: wrap; margin: 16px 0; }
.chip-btn { display: inline-flex; align-items: center; gap: 8px; padding: 12px 18px; border-radius: 12px; border: 1px solid var(--line); background: #fff; font: inherit; font-weight: 600; color: var(--navy-900); cursor: pointer; }
.chip-btn .ic { color: var(--navy-700); }
.chip-btn:hover, .chip-btn.active { border-color: var(--navy-500); background: var(--input-tint); }

.notice { padding: 10px 14px; border-radius: var(--radius-sm); background: var(--gold-soft); color: var(--gold-text); margin-bottom: 12px; }
.results { display: flex; flex-direction: column; gap: 14px; }
.results .empty { text-align: center; color: var(--muted); padding: 30px; background: #fff; border-radius: var(--radius); }

.btn-dashed {
  display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; margin-top: 18px; padding: 22px;
  font: inherit; font-size: 18px; font-weight: 700; color: var(--navy-800); cursor: pointer;
  background: #e9edf8; border: 2px dashed #9eb0dc; border-radius: var(--radius);
}
.btn-dashed:hover { background: #e1e7f6; }

/* ---------------------------------------------------------------- family card */
.family { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); overflow: clip; }
.family > summary {
  display: flex; align-items: center; gap: 12px; padding: 16px 22px; cursor: pointer; list-style: none;
  background: var(--navy-grad); color: #fff; font-size: 18px; font-weight: 700; user-select: none;
}
.family > summary::-webkit-details-marker { display: none; }
.family > summary .title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.family > summary .chev { transition: transform .2s; }
.family[open] > summary .chev { transform: rotate(180deg); }
.family > summary .nm-non { color: #a9b1c6; font-weight: 500; }   /* non-church members: grey */
.family.dirty > summary .nm-non { color: #e9dcb0; }
.family.dirty > summary { background: linear-gradient(120deg, #6b4e00 0%, #9a7300 60%, #c9a227 100%); }
.family.is-new-family { outline: 3px dashed #7fb58f; outline-offset: -3px; }

.badge { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 999px; font-size: 12px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; flex: none; }
.badge-pending { background: #e3b52d; color: #3b2c00; }
.badge-verified { background: #bfe8cb; color: #145a2a; }
.badge-non { background: rgba(255, 255, 255, .2); color: #fff; }
.badge-unsaved { background: #fff; color: #8a5a00; }
.badge-neutral { background: var(--input-tint); color: var(--navy-800); }

.family-body { padding: 18px 22px 0; background: #f7f8fd; }
.family-meta { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding-bottom: 14px; margin-bottom: 14px; border-bottom: 1px dashed var(--line-strong); color: var(--muted); font-size: 13px; }
.family-meta .meta-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.chip-btn.small { padding: 8px 12px; font-size: 13px; }
.ok-text { color: var(--green); }
.warn-text { color: var(--gold-text); }
.member.non-church .avatar { background: linear-gradient(135deg, #8d94a6, #b3b9c8); }
.member.non-church .name-input { color: #7a8299; }
.hh-grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 14px 16px; }
.c12 { grid-column: span 12; } .c10 { grid-column: span 10; } .c8 { grid-column: span 8; } .c6 { grid-column: span 6; }
.c4 { grid-column: span 4; } .c3 { grid-column: span 3; } .c2 { grid-column: span 2; }
.more-toggle { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border-radius: 999px; border: 0; background: #e3e8f7; color: var(--navy-800); font: inherit; font-weight: 700; cursor: pointer; }
.more-toggle[aria-expanded=true] .ic { transform: rotate(180deg); }

.members { display: flex; flex-direction: column; gap: 14px; margin: 18px 0; }
.family-footer { display: flex; gap: 12px; flex-wrap: wrap; padding: 16px 0 20px; border-top: 1px dashed var(--line-strong); }

/* Save bar: sticks to the bottom of the screen while the card has unsaved changes */
.savebar {
  position: sticky; bottom: 0; z-index: 5; display: flex; align-items: center; gap: 12px;
  margin: 0 -22px; padding: 12px 22px; background: var(--navy-900); color: #fff;
}
.savebar .msg { flex: 1; display: flex; align-items: center; gap: 8px; font-weight: 600; }
.savebar .msg .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--gold); box-shadow: 0 0 0 4px rgba(201, 162, 39, .3); }
.savebar .btn-outline { background: transparent; color: #fff; border-color: rgba(255, 255, 255, .4); }
.savebar .btn-save { background: var(--gold); color: #2a1f00; }

/* ---------------------------------------------------------------- member card */
.member { background: #fff; border: 1px solid var(--line); border-left: 5px solid var(--navy-500); border-radius: var(--radius); box-shadow: 0 2px 10px rgba(31, 42, 90, .05); }
.member.head { border-left-color: var(--gold); }
.member-head { display: flex; align-items: center; gap: 14px; padding: 14px 18px; background: #f4f6fc; border-radius: var(--radius) var(--radius) 0 0; border-bottom: 1px solid var(--line); }
.member-head .names { flex: 1; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; min-width: 0; }
.name-input { border-color: transparent; background: transparent; font-size: 19px; font-weight: 700; color: var(--navy-900); padding: 6px 8px; }
.name-input:hover { border-color: var(--line-strong); background: #fff; }
.member-head { flex-wrap: wrap; }
.member-head .names { flex: 1 1 320px; }
.head-controls { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-left: auto; }
.member-head select { width: auto; min-width: 100px; padding: 8px 10px; }
.icon-danger { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; border: 0; background: var(--red-soft); color: var(--red); cursor: pointer; flex: none; }
.icon-danger:hover { background: #f9d6d2; }

.avatar { position: relative; flex: none; display: grid; place-items: center; width: 64px; height: 64px; border-radius: 50%; color: #fff; font-weight: 800; font-size: 20px; background: linear-gradient(135deg, #2b3d78, #4b6bb6); }
.member.head .avatar { background: linear-gradient(135deg, #8a6a00, #c9a227); }
.avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.avatar.sm { width: 38px; height: 38px; font-size: 14px; background: rgba(255, 255, 255, .18); }
.avatar .cam { position: absolute; right: -2px; bottom: -2px; display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; border: 2px solid #fff; background: var(--navy-800); color: #fff; cursor: pointer; padding: 0; }
.avatar .cam .ic { width: 13px; height: 13px; }
.avatar .cam.disabled { background: #9aa3b8; cursor: not-allowed; }

.member-body { padding: 14px 18px 16px; }
.chips { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.chip { display: inline-flex; align-items: center; gap: 8px; padding: 7px 14px; border-radius: 999px; font-weight: 600; font-size: 14px; text-decoration: none; }
.chip .ic { width: 15px; height: 15px; }
.chip.green { background: var(--green-soft); color: var(--green); }
.chip.amber { background: var(--gold-soft); color: var(--gold-text); }
.chip.off { opacity: .75; pointer-events: none; }
.member-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px 14px; }
.member-grid .span2 { grid-column: span 2; }
.member-grid .span6 { grid-column: 1 / -1; }
.dob { display: grid; grid-template-columns: 1fr 1fr 1.4fr; gap: 6px; }
.dob input { text-align: center; padding: 10px 4px; }
.member-more { margin-top: 14px; }
.check-inline { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; text-transform: none; letter-spacing: 0; padding-top: 22px; }
.check-inline input { width: 18px; height: 18px; }

.member.is-new { border-style: dashed; border-color: #7fb58f; border-left: 5px solid #3c9a5a; }
.member.is-new .member-head { background: #eef8f1; }
.member.is-deleted { opacity: .55; }
.member.is-deleted .member-head { background: var(--red-soft); }
.member.is-deleted .name-input { text-decoration: line-through; }
.member.is-deleted .member-body { display: none; }
.deleted-note { display: none; align-items: center; gap: 10px; color: var(--red); font-weight: 600; }
.member.is-deleted .deleted-note { display: flex; }
.member.is-deleted .head-controls { display: none; }

/* ---------------------------------------------------------------- change highlighting
   Any field whose value differs from what is saved gets .changed until Save or Cancel. */
.changed, input.changed, select.changed, textarea.changed {
  background: var(--changed-bg) !important; border-color: var(--changed-line) !important;
  box-shadow: 0 0 0 2px rgba(226, 173, 0, .18);
}
label.changed { border-radius: 8px; padding: 2px 6px; }
.invalid { border-color: var(--red) !important; box-shadow: 0 0 0 3px rgba(192, 57, 43, .15) !important; }

/* ---------------------------------------------------------------- lists (birthdays / appointments) */
.list-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.list-head h2 { font-size: 20px; flex: 1; }
.month-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.month-chips button { padding: 7px 12px; border-radius: 999px; border: 1px solid var(--line); background: #fff; font: inherit; font-weight: 600; cursor: pointer; color: var(--navy-800); }
.month-chips button.active { background: var(--navy-800); color: #fff; border-color: var(--navy-800); }
.row-card { display: flex; align-items: center; gap: 16px; padding: 14px 18px; background: #fff; border-radius: var(--radius); box-shadow: 0 2px 8px rgba(31, 42, 90, .05); cursor: pointer; border: 1px solid transparent; }
.row-card:hover { border-color: #b9c6ea; }
.row-card .day { display: grid; place-items: center; width: 54px; height: 54px; border-radius: 12px; background: var(--gold-soft); color: var(--gold-text); font-weight: 800; font-size: 20px; flex: none; line-height: 1; text-align: center; }
.row-card .day small { display: block; font-size: 11px; font-weight: 700; }
.row-card .main-line { font-weight: 700; color: var(--navy-900); }
.row-card .sub { color: var(--muted); font-size: 14px; }
.row-card .grow { min-width: 0; }

/* ---------------------------------------------------------------- admin pages */
.toolbar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar .input { width: auto; min-width: 240px; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); background: #f6f7fc; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.table td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr { cursor: pointer; }
.table tbody tr:hover { background: #f5f7fe; }
.table tbody tr:last-child td { border-bottom: 0; }
.table .empty { text-align: center; color: var(--muted); cursor: default; padding: 30px; }
.user-cell { display: flex; align-items: center; gap: 12px; }
.user-cell .avatar { width: 38px; height: 38px; font-size: 14px; }
.user-cell small { display: block; color: var(--muted); }
.perm { display: inline-block; padding: 3px 9px; margin: 2px; border-radius: 6px; font-size: 12px; font-weight: 700; background: var(--input-tint); color: var(--navy-800); }
.perm.super { background: var(--gold-soft); color: var(--gold-text); }
.status { display: inline-block; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.status.ok { background: var(--green-soft); color: var(--green); }
.status.wait { background: var(--gold-soft); color: var(--gold-text); }
.status.off { background: #eceef3; color: var(--muted); }

.dialog { border: 0; border-radius: 18px; padding: 0; width: min(560px, calc(100% - 24px)); box-shadow: var(--shadow-lg); color: var(--text); }
.dialog.wide { width: min(820px, calc(100% - 24px)); }
.dialog::backdrop { background: rgba(20, 28, 60, .45); backdrop-filter: blur(2px); }
.dialog-form { padding: 24px; display: flex; flex-direction: column; gap: 14px; }
.dialog-form h2 { font-size: 22px; }
.dialog-form > .muted { margin: -8px 0 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.span2 { grid-column: span 2; } .span3 { grid-column: span 3; }
.section-label { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-top: 6px; }
.checks { display: grid; gap: 8px; }
.check { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); cursor: pointer; }
.check:has(input:checked) { border-color: var(--navy-500); background: #f3f6fe; }
.check input { width: 18px; height: 18px; flex: none; }
.check small { display: block; color: var(--muted); }
.dialog-actions { display: flex; gap: 10px; align-items: center; margin-top: 6px; }

/* ---------------------------------------------------------------- public family update page (update.html) */
.public-main { width: min(980px, calc(100% - 24px)); margin: 24px auto 40px; display: flex; flex-direction: column; gap: 16px; }
.public-main form { display: flex; flex-direction: column; gap: 16px; }
.public .intro h1 { font-size: 24px; margin-bottom: 6px; }
.public .intro p { margin: 6px 0; }
.public .expires { display: flex; align-items: center; gap: 8px; color: var(--gold-text); font-weight: 600; }
.public .people-label { margin: 6px 0 -4px; }
.public .panel > .section-label { margin: 0 0 12px; }
.public .members { margin: 0; }
.public .btn-dashed { margin-top: 0; }
.public-savebar { margin: 0; border-radius: var(--radius); }
@media (max-width: 600px) {   /* phones: message + Undo + Save must fit on one line */
  .public-savebar { padding: 10px 12px; gap: 8px; }
  .public-savebar .msg { font-size: 13px; min-width: 0; line-height: 1.2; }
  .public-savebar .btn { padding: 9px 12px; white-space: nowrap; }
}
@media (max-width: 360px) { .public-savebar .btn .ic { display: none; } }   /* the smallest phones: text-only buttons */

/* ---------------------------------------------------------------- toast */
#toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); z-index: 100;
  max-width: min(520px, calc(100% - 32px)); padding: 12px 18px; border-radius: 12px; color: #fff;
  font-weight: 600; white-space: pre-line; box-shadow: var(--shadow-lg);
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
}
#toast.show { opacity: 1; transform: translateX(-50%); }
#toast.ok { background: #1f6b3a; }
#toast.err { background: var(--red); }

/* ---------------------------------------------------------------- responsive */
@media (max-width: 1100px) {
  .member-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .member-grid .span2 { grid-column: span 1; }
}
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; z-index: 50; width: 270px; transform: translateX(-100%); transition: transform .2s; }
  .shell.menu-open .sidebar { transform: none; }
  .shell.menu-open .scrim { display: block; position: fixed; inset: 0; z-index: 40; background: rgba(20, 28, 60, .4); }
  .menu-btn { display: inline-grid; }
  .main { padding: 0 16px 60px; }
  .topbar { margin: 0 -16px 16px; padding: 12px 16px; }
  .topbar h1 { font-size: 20px; }
  .segmented button { font-size: 13px; padding: 10px 4px; }
  .view-switch button { padding: 8px 12px; font-size: 13px; }
  .hh-grid > * { grid-column: span 12 !important; }
  .member-head { flex-wrap: wrap; }
  .member-head .names { grid-template-columns: 1fr; flex-basis: calc(100% - 80px); }
  .member-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }   /* minmax: inputs never push past small phones */
  .grid3, .grid2 { grid-template-columns: 1fr; }
  .span2, .span3 { grid-column: auto; }
  .search-row { flex-wrap: wrap; }
  .search-input { flex: 1 1 200px; }
}

/* ---------------------------------------------------------------- priests (church dialog) + visitations */
.muted.small, .small { font-size: 13px; }
.ic.flip { transform: scaleX(-1); }

/* Priests serving a church: name | calendar URL | remove */
.cp-list { display: grid; gap: 8px; }
.cp-row { display: grid; grid-template-columns: minmax(140px, 220px) 1fr auto; gap: 10px; align-items: center; }
.cp-row .input { width: 100%; }
.cp-add { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
.cp-add .input { flex: 1; }

/* Visitations: week of days, each with its slots */
.vs-range { min-width: 190px; text-align: center; }
.toolbar .check-inline { padding-top: 0; }
.vs-days { display: grid; gap: 12px; padding: 4px 18px 18px; }
.vs-day { border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; }
.vs-day.today { border-color: var(--navy-500); }
.vs-day-head { background: var(--input-tint); padding: 8px 14px; font-weight: 700; color: var(--navy-900); }
.vs-none { padding: 10px 14px; font-size: 14px; }
.vs-slot { display: grid; grid-template-columns: 160px 170px 1fr auto; gap: 12px; align-items: center; width: 100%;
  padding: 10px 14px; border: 0; border-top: 1px solid var(--line); background: #fff; text-align: left; font: inherit; color: inherit; cursor: pointer; }
.vs-day-head + .vs-slot { border-top: 0; }
.vs-slot:hover { background: #f7f9ff; }
.vs-slot.taken .vs-time { color: var(--green); }
.vs-time { font-weight: 700; color: var(--navy-800); }
.vs-priest { color: var(--muted); }

/* Slot dialog: picked family + search results + reminder choices */
.slot-family .row-card { cursor: default; justify-content: space-between; border-color: var(--line); }
.pick-list { display: grid; gap: 4px; max-height: 220px; overflow: auto; }
.pick-item { text-align: left; padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px; background: #fff; font: inherit; color: inherit; cursor: pointer; }
.pick-item:hover { border-color: #b9c6ea; background: #f7f9ff; }
.reminder-opts { display: flex; flex-wrap: wrap; gap: 8px 22px; }
.reminder-opts .check-inline { padding-top: 0; }
.reminder-opts input[type=datetime-local] { width: auto; height: 34px; }

@media (max-width: 900px) {
  .cp-row { grid-template-columns: 1fr auto; }
  .cp-row .input { grid-column: 1 / -1; grid-row: 2; }
  .vs-slot { grid-template-columns: 1fr; gap: 4px; }
}

/* ---------------------------------------------------------------- visit cycles */
/* "Scheduled" = light orange (the --cyan names are kept so every place using them changes together) */
:root { --cyan-soft: #ffedd5; --cyan: #b45309; --grey-soft: #eef0f4; }
.cy-stats { display: flex; flex-wrap: wrap; gap: 10px; padding: 0 18px 14px; }
.cy-tile { display: grid; justify-items: start; min-width: 130px; padding: 10px 14px; border-radius: var(--radius-sm);
  border: 2px solid transparent; background: var(--input-tint); font: inherit; color: var(--text); cursor: pointer; text-align: left; }
.cy-tile.active { border-color: var(--navy-800); }
.cy-tile .cy-num { font-size: 24px; font-weight: 800; line-height: 1.1; }
.cy-tile .cy-label { font-size: 13px; font-weight: 700; }
.cy-tile small { color: var(--muted); }
.cy-tile.visited { background: var(--green-soft); color: var(--green); }
.cy-tile.scheduled { background: var(--cyan-soft); color: var(--cyan); }
.cy-tile.none, .cy-tile.late { background: var(--grey-soft); color: var(--muted); }

/* Spreadsheet-like table: compact rows, inputs look like cells */
.cy-table td { padding: 4px 8px; vertical-align: middle; border-bottom: 1px solid rgba(31, 42, 90, .06); }
.cy-table thead th { position: sticky; top: 0; z-index: 1; background: #f7f8fc; }
/* status stripe on the left edge of each family row */
.cy-table tr.cy-visited td:first-child { box-shadow: inset 4px 0 0 var(--green); }
.cy-table tr.cy-scheduled td:first-child { box-shadow: inset 4px 0 0 #f59e0b; }
.cy-table tr.cy-none td:first-child { box-shadow: inset 4px 0 0 #c3c8d4; }
.cy-table tbody tr:not(.cy-group):hover td { filter: brightness(.97); }
.cy-table tbody tr { cursor: default; }
.cy-table input { width: 100%; min-width: 120px; height: 32px; padding: 2px 6px; border: 1px solid transparent; border-radius: 6px; background: transparent; font: inherit; }
.cy-table input:hover { border-color: var(--line-strong); background: #fff; }
.cy-table input:focus { border-color: var(--navy-500); background: #fff; outline: none; }
.cy-table td:nth-child(9) input { min-width: 200px; }
.cy-table tr.cy-visited td { background: var(--green-soft); }
.cy-table tr.cy-scheduled td { background: var(--cyan-soft); }
.cy-table tr.cy-none td { background: var(--grey-soft); color: var(--muted); }
.cy-table tr.cy-saved td { box-shadow: inset 0 0 0 9999px rgba(255, 255, 255, .45); transition: box-shadow .8s; }
.cy-table td:nth-child(3) { min-width: 190px; }
.cy-table td:nth-child(4) { min-width: 200px; }
.cy-table td:nth-child(5), .cy-table td:nth-child(6) { white-space: nowrap; }

/* City groups: Visit Cycles table rows and Directory "All By City" */
.cy-table tr.cy-group td { background: #fff; padding: 10px 12px; cursor: pointer; border-top: 2px solid var(--line-strong); }
.cy-table tr.cy-group:hover td { background: #f7f9ff; }
.cy-caret, .city-caret { display: inline-block; width: 14px; color: var(--navy-700); }
.cy-pill { display: inline-block; margin-left: 8px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.cy-pill.visited { background: var(--green-soft); color: var(--green); }
.cy-pill.scheduled { background: var(--cyan-soft); color: var(--cyan); }
.cy-pill.none { background: var(--grey-soft); color: var(--muted); }
.cy-table input[type=datetime-local] { min-width: 190px; }

/* City group: a dark header bar (darker than the navy family cards) and a bordered box around the whole city;
   the family cards sit indented inside it. */
.city-group { background: #fff; border: 2px solid var(--navy-900); border-radius: var(--radius); overflow: hidden; box-shadow: 0 2px 8px rgba(31, 42, 90, .08); }
.city-group > summary { display: flex; align-items: center; gap: 10px; padding: 12px 18px; cursor: pointer; list-style: none; font-size: 17px;
  background: #0e1430; color: #fff; border-left: 6px solid var(--gold); }
.city-group > summary::-webkit-details-marker { display: none; }
.city-group > summary .city-caret { color: var(--gold); }
.city-group > summary .count-bubble { min-width: 38px; height: 38px; }
.city-group[open] .city-caret { transform: rotate(90deg); }
.city-group .city-cards { display: grid; gap: 12px; padding: 14px 14px 14px 36px; background: var(--bg); }
@media (max-width: 600px) {
  .city-group .city-cards { padding-left: 22px; }
  .view-switch span, .btn-logout span { display: none; }   /* phones: icons only in the top bar */
  .btn-logout { padding: 8px 12px; }
}

/* ---------------------------------------------------------------- address suggestions (js/address-autocomplete.js) */
.addr-host { position: relative; }
.addr-list { position: absolute; left: 0; right: 0; top: 100%; z-index: 50; margin-top: 4px; background: #fff;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); overflow: hidden;
  text-transform: none; letter-spacing: 0; font-weight: 400; }
.addr-item { display: grid; width: 100%; padding: 9px 12px; border: 0; border-bottom: 1px solid var(--line); background: #fff;
  text-align: left; font: inherit; font-size: 14px; color: var(--text); cursor: pointer; }
.addr-item span { color: var(--muted); font-size: 13px; }
.addr-item:hover, .addr-item.active { background: #f0f4ff; }
.addr-foot { padding: 6px 12px; font-size: 11px; color: var(--muted); background: #fafbfe; }

/* ---------------------------------------------------------------- Households: Line / Card view (js/households.js) */
.fam-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 14px; align-items: start; }
.fam-tile { background: #fff; border: 1px solid var(--line-strong); border-radius: var(--radius); overflow: hidden; cursor: pointer;
  box-shadow: 0 2px 8px rgba(31, 42, 90, .06); transition: box-shadow .15s, transform .15s; }
.fam-tile:hover, .fam-tile:focus-visible { box-shadow: var(--shadow-lg); transform: translateY(-2px); outline: none; }
.fam-tile header { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; background: var(--navy-grad); color: #fff; }
.fam-id { flex: none; padding: 2px 8px; border-radius: 999px; background: rgba(255, 255, 255, .18); font-weight: 700; font-size: 13px; }
.fam-addr { display: flex; gap: 6px; font-weight: 600; line-height: 1.3; }
.fam-addr .ic { flex: none; margin-top: 2px; color: var(--gold); }
.fam-addr small { display: block; font-weight: 400; opacity: .85; }
.fam-people { padding: 6px 14px 12px; }
.fam-people hr { border: 0; border-top: 2px solid var(--line-strong); margin: 6px 0; }
.fam-person { padding: 7px 0; }
.fam-person + .fam-person { border-top: 1px dashed var(--line); }
.fam-person.non-member b { color: var(--muted); }
.fp-name { display: flex; align-items: center; gap: 6px; }
.fp-role { margin-left: auto; padding: 1px 8px; border-radius: 999px; background: var(--input-tint); color: var(--navy-700); font-size: 12px; font-weight: 600; }
.fp-line { display: flex; align-items: center; gap: 6px; margin: 3px 0 0 40px; color: var(--text); font-size: 14px; text-decoration: none; word-break: break-all; }
.fp-line:hover { color: var(--navy-500); text-decoration: underline; }
.fp-line .ic { flex: none; width: 14px; height: 14px; color: var(--muted); }
/* Person picture (click = big) or the person symbol */
.fp-pic { flex: none; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: var(--input-tint); color: var(--navy-500); overflow: hidden; }
.fp-pic .ic { width: 20px; height: 20px; }
.fp-pic img { width: 100%; height: 100%; object-fit: cover; cursor: zoom-in; }

/* Big picture viewer (js/photo-view.js) */
.photo-view { padding: 0; border: 0; background: transparent; max-width: 92vw; max-height: 92vh; cursor: zoom-out; text-align: center; }
.photo-view::backdrop { background: rgba(10, 14, 35, .82); }
.photo-view img { display: block; max-width: 92vw; max-height: 84vh; border-radius: var(--radius); box-shadow: var(--shadow-lg); background: #fff; }
.photo-view p { margin: 10px 0 0; color: #fff; font-size: 18px; font-weight: 600; }
.avatar-content img { cursor: zoom-in; }

/* Card View pop-up: one family's full card over the grid */
.family-pop { width: min(1100px, calc(100% - 24px)); max-height: calc(100vh - 32px); background: var(--bg); overflow: auto; }
.family-pop .pop-body { padding: 18px 16px 16px; }
/* Stays in the top-right corner while scrolling; the negative bottom margin lets it sit over the card */
.family-pop .pop-close { position: sticky; top: 10px; z-index: 2; display: grid; margin: 10px 10px -48px auto; background: #fff; box-shadow: var(--shadow); }
.family-pop .pop-body > details > summary { padding-right: 64px; }

/* Visit Cycles: Schedule button on each row + the reserve dialog (js/cycles.js) */
.cy-sched { display: grid; place-items: center; width: 32px; height: 32px; padding: 0; border: 1px solid var(--line-strong); border-radius: 8px;
  background: #fff; color: var(--navy-700); cursor: pointer; }
.cy-sched:hover { background: var(--navy-700); color: #fff; }
.cy-sched .ic { width: 16px; height: 16px; }
#reserveDialog { width: min(640px, calc(100% - 24px)); }
.reserve-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; }
.reserve-tools select { width: auto; min-width: 220px; }
.reserve-tools .check-inline { padding-top: 0; }
.reserve-current { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--cyan-soft); }
.reserve-current .ic { color: var(--cyan); }
.reserve-current span { flex: 1; min-width: 200px; }
.reserve-list { max-height: 55vh; overflow: auto; display: grid; gap: 14px; }
.reserve-day h4 { margin: 0 0 6px; font-size: 14px; color: var(--navy-900); }
.reserve-slots { display: flex; flex-wrap: wrap; gap: 8px; }
.reserve-slot { display: grid; justify-items: start; gap: 2px; padding: 8px 12px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: #fff; font: inherit; color: var(--text); cursor: pointer; }
.reserve-slot span { font-size: 12px; color: var(--muted); }
.reserve-slot:hover { border-color: var(--navy-500); background: var(--input-tint); }

/* ---------------------------------------------------------------- Priest Dashboard (js/priest-dashboard.js) */
.nav-priest { margin-bottom: 8px; border: 1px solid rgba(201, 162, 39, .55); }
.nav-priest .ic { color: var(--gold); }
.perm.priest { background: #f3e8ff; color: #6b3fa0; }
.pd-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 18px; }
.pd-head h2 { margin: 0; font-size: 24px; }
.pd-churches { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; margin-bottom: 18px; }
.pd-church-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.pd-church-head h3 { margin: 0; font-size: 18px; }
.pd-stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.pd-stat { display: grid; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--input-tint); }
.pd-stat b { font-size: 26px; line-height: 1.1; color: var(--navy-900); }
.pd-stat span { font-size: 13px; font-weight: 600; color: var(--muted); }
.pd-grid { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 14px; align-items: start; }
.pd-panel h3 { display: flex; align-items: center; gap: 8px; margin: 0 0 10px; font-size: 17px; }
.pd-panel h3 .ic { color: var(--navy-500); }
.count-pill { margin-left: auto; padding: 1px 10px; border-radius: 999px; background: var(--gold-soft); color: var(--gold-text); font-size: 13px; }
.pd-list { display: grid; }
.pd-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.pd-row:first-child { border-top: 0; }
.pd-row small { display: block; color: var(--muted); }
.pd-when { flex: none; min-width: 150px; font-weight: 700; color: var(--navy-700); }
/* Up to 1400px wide the content area (next to the menu) is too narrow for three columns */
@media (max-width: 1400px) { .pd-grid { grid-template-columns: 1fr 1fr; } .pd-visits { grid-column: 1 / -1; } }
@media (max-width: 700px) {
  .pd-grid { grid-template-columns: 1fr; }
  .pd-row { flex-wrap: wrap; }
  .pd-when { min-width: 0; width: 100%; }
}

/* "Viewing as …" bar while a Super Admin is switched to another user (js/main.js) */
.switch-bar { position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 60; display: flex; align-items: center; gap: 10px;
  max-width: calc(100% - 32px); padding: 8px 8px 8px 16px; border-radius: 999px; background: #5b2a86; color: #fff; box-shadow: var(--shadow-lg); font-size: 14px; }
.switch-bar span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.switch-bar .btn { flex: none; background: #fff; color: #5b2a86; border: 0; font-weight: 700; }
.shell.switched .main { padding-bottom: 90px; }   /* room for the bar at the end of a page */

/* Empty date boxes: hide "mm/dd/yyyy --:-- --" until the box is clicked (js/util.js markEmpty) */
input.is-empty:not(:focus)::-webkit-datetime-edit { color: transparent; }
input.is-empty:not(:focus):not(:hover)::-webkit-calendar-picker-indicator { opacity: 0; }

/* Address -> Google Maps (js/util.js mapLink) */
.map-link { color: inherit; text-decoration: none; border-bottom: 1px dashed currentColor; }
.map-link:hover { color: var(--navy-500); border-bottom-style: solid; }
.fam-tile header .map-link:hover { color: var(--gold-soft); }
