/* ============================================================
   Harvest Field Tracker — design system
   Soft gray canvas, white cards, calm blue accent, generous
   type and tap targets. Built mobile-first for field use by a
   wide range of ages.
   ============================================================ */

:root {
  --bg: #eef1f7;
  --bg-2: #e7ebf3;
  --surface: #ffffff;
  --surface-soft: #f7f9fc;
  --ink: #18222f;
  --ink-soft: #54616f;
  --ink-faint: #8a96a3;
  --line: #e3e8f0;

  --blue: #2f6bff;
  --blue-dark: #1f4fd1;
  --blue-soft: #eaf0ff;

  --green: #2fa56a;
  --green-soft: #e6f6ee;
  --amber: #e08a1e;
  --amber-soft: #fcf1de;
  --red: #d8453f;
  --red-soft: #fbe9e8;
  --slate: #6b7785;
  --slate-soft: #eef1f5;

  --radius: 22px;
  --radius-sm: 14px;
  --shadow: 0 10px 30px -12px rgba(26, 42, 71, 0.28);
  --shadow-soft: 0 4px 16px -8px rgba(26, 42, 71, 0.22);
  --shadow-lift: 0 22px 48px -18px rgba(26, 42, 71, 0.45);

  --font-display: "Plus Jakarta Sans", "Segoe UI", system-ui, sans-serif;
  --font-body: "Manrope", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }

/* Default icon sizing so inline SVGs (viewBox only) never balloon; specific
   rules below override per context. */
svg { width: 1.4em; height: 1.4em; flex: none; }

html, body { margin: 0; padding: 0; }

body {
  font-family: var(--font-body);
  background:
    radial-gradient(1200px 600px at 100% -10%, rgba(47, 107, 255, 0.10), transparent 60%),
    radial-gradient(900px 500px at -10% 0%, rgba(47, 165, 106, 0.08), transparent 55%),
    var(--bg);
  color: var(--ink);
  font-size: 17px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

h1, h2, h3, h4 { font-family: var(--font-display); letter-spacing: -0.02em; line-height: 1.15; }

button { font-family: var(--font-body); cursor: pointer; }

.hidden { display: none !important; }

/* ---------- Passcode gate ---------- */
.gate {
  position: fixed; inset: 0; z-index: 4000;
  display: flex; align-items: center; justify-content: center; padding: 22px;
  background:
    radial-gradient(900px 500px at 50% -10%, rgba(47, 107, 255, 0.22), transparent 60%),
    linear-gradient(160deg, #12203a, #0c1729);
}
.gate-card {
  width: min(440px, 100%);
  background: var(--surface);
  border-radius: 28px;
  padding: 34px 28px;
  box-shadow: var(--shadow-lift);
  animation: rise 0.5s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
.gate-badge {
  width: 64px; height: 64px; border-radius: 20px;
  background: linear-gradient(150deg, var(--blue), #5b86ff);
  display: grid; place-items: center; color: #fff; margin-bottom: 18px;
  box-shadow: 0 12px 24px -8px rgba(47, 107, 255, 0.7);
}
.gate-card h1 { margin: 0 0 4px; font-size: 1.9rem; }
.gate-card p.lede { margin: 0 0 22px; color: var(--ink-soft); }
.gate-card label { font-weight: 700; }
.gate-error { color: var(--red); font-weight: 700; min-height: 22px; margin: 6px 0 0; }
.gate-hint { margin-top: 18px; font-size: 0.92rem; color: var(--ink-faint); text-align: center; }
.gate-link { display: block; width: 100%; margin-top: 14px; background: none; border: none; color: var(--ink-soft); font: inherit; font-weight: 700; font-size: 0.92rem; cursor: pointer; text-decoration: underline; }
.gate-link:hover { color: var(--ink); }

/* Role selector on the sign-up form: a tappable grid of role choices that
   reveals only the fields needed for the selected role. */
.role-select { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 2px; }
.role-opt {
  padding: 14px 12px; border-radius: var(--radius-sm); border: 1.5px solid var(--line);
  background: var(--surface-soft); color: var(--ink); font: inherit; font-weight: 800;
  font-size: 0.98rem; text-align: center; transition: border-color .15s, background .15s, color .15s;
}
.role-opt:hover { border-color: var(--blue); }
.role-opt.selected {
  background: var(--blue); color: #fff; border-color: var(--blue);
  box-shadow: 0 12px 22px -12px rgba(47, 107, 255, 0.8);
}
#obFields { margin-top: 18px; }

/* ---------- Shell ---------- */
.appbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 14px;
  padding: 14px 18px;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.appbar .mark {
  width: 44px; height: 44px; border-radius: 13px; flex: none;
  background: linear-gradient(150deg, var(--blue), #5b86ff);
  display: grid; place-items: center; color: #fff;
  box-shadow: 0 8px 18px -8px rgba(47, 107, 255, 0.8);
}
.appbar .titles { flex: 1; min-width: 0; }
.appbar .titles h1 { font-size: 1.18rem; margin: 0; }
.appbar .titles p { margin: 0; font-size: 0.82rem; color: var(--ink-faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface-soft); border: 1px solid var(--line);
  border-radius: 999px; padding: 6px 6px 6px 14px;
}
.who .nm { font-weight: 800; font-size: 0.9rem; }
.who .rl { font-size: 0.72rem; color: var(--ink-faint); }
.avatar {
  width: 38px; height: 38px; border-radius: 50%; flex: none;
  display: grid; place-items: center; font-weight: 800; color: #fff;
  background: linear-gradient(150deg, #3a7bd5, #2fa56a); font-size: 0.95rem;
}
.icon-btn {
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-soft);
  width: 44px; height: 44px; border-radius: 13px; display: grid; place-items: center;
}
.icon-btn:hover { color: var(--blue); border-color: var(--blue); }
.icon-btn svg { width: 22px; height: 22px; }
/* Refresh / Sync: spin the icon while a sync is in flight, and dim while busy. */
.icon-btn.spinning { color: var(--blue); border-color: var(--blue); opacity: .85; cursor: progress; }
.icon-btn.spinning svg { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.appbar .mark svg { width: 24px; height: 24px; }
.gate-badge svg { width: 30px; height: 30px; }
.bot-top .bavatar svg { width: 22px; height: 22px; }
.bot-top .x svg { width: 18px; height: 18px; }

main {
  max-width: 1180px; margin: 0 auto; padding: 20px 18px 130px;
}

.view { display: none; animation: fade 0.35s ease both; }
.view.active-view { display: block; }

/* ---------- Bottom navigation ---------- */
.tabbar {
  position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%);
  z-index: 60; width: min(620px, calc(100vw - 28px));
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(16px);
  border: 1px solid var(--line);
  border-radius: 22px; padding: 8px;
  box-shadow: var(--shadow);
}
/* Admins get a sixth (Admin) tab — widen the grid to fit it on one row. */
.tabbar.has-admin { grid-template-columns: repeat(6, 1fr); }
.tab {
  border: none; background: transparent; color: var(--ink-faint);
  border-radius: 15px; padding: 8px 4px 6px;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  font-size: 0.7rem; font-weight: 700; transition: color 0.2s, background 0.2s;
}
.tab svg { width: 24px; height: 24px; }
.tab.active { color: var(--blue); background: var(--blue-soft); }
.tab:active { transform: scale(0.94); }

/* ---------- Cards & typography ---------- */
.view-head { margin: 6px 2px 18px; }
.view-head h2 { font-size: 1.7rem; margin: 0 0 4px; }
.view-head p { margin: 0; color: var(--ink-soft); }

.card {
  background: var(--surface); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow-soft); border: 1px solid var(--line);
}
.card + .card { margin-top: 16px; }
.card h3 { margin: 0 0 14px; font-size: 1.16rem; display: flex; align-items: center; gap: 10px; }
.card h3 svg { width: 22px; height: 22px; color: var(--blue); }

.grid { display: grid; gap: 16px; }
.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.section-gap { margin-top: 18px; }

/* ---------- Stat / summary cards ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.stat {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow-soft); position: relative; overflow: hidden;
  animation: rise 0.5s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
.stat .ic { width: 42px; height: 42px; border-radius: 13px; display: grid; place-items: center; margin-bottom: 12px; }
.stat .ic svg { width: 22px; height: 22px; }
.stat .big { font-family: var(--font-display); font-size: 2.1rem; font-weight: 800; line-height: 1; }
.stat .lbl { color: var(--ink-soft); font-weight: 700; font-size: 0.92rem; margin-top: 4px; }
.stat .sub { color: var(--ink-faint); font-size: 0.82rem; margin-top: 6px; }
.tint-blue .ic { background: var(--blue-soft); color: var(--blue); }
.tint-green .ic { background: var(--green-soft); color: var(--green); }
.tint-amber .ic { background: var(--amber-soft); color: var(--amber); }
.tint-red .ic { background: var(--red-soft); color: var(--red); }
.tint-slate .ic { background: var(--slate-soft); color: var(--slate); }

/* ---------- Buttons ---------- */
.btn {
  border: none; border-radius: 15px; padding: 15px 18px; font-size: 1.02rem; font-weight: 800;
  background: var(--blue); color: #fff; width: 100%; min-height: 54px;
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  box-shadow: 0 12px 22px -12px rgba(47, 107, 255, 0.8); transition: transform 0.15s, box-shadow 0.2s, background 0.2s;
}
.btn svg { width: 20px; height: 20px; }
.btn:hover { background: var(--blue-dark); }
.btn:active { transform: translateY(1px) scale(0.99); }
.btn.ghost { background: var(--surface); color: var(--blue); border: 1.5px solid var(--blue); box-shadow: none; }
.btn.soft { background: var(--blue-soft); color: var(--blue-dark); box-shadow: none; }
.btn.muted { background: var(--slate-soft); color: var(--ink); box-shadow: none; }
.btn.danger { background: var(--red); box-shadow: 0 12px 22px -12px rgba(216, 69, 63, 0.8); }
.btn.small { width: auto; min-height: 44px; padding: 10px 16px; font-size: 0.92rem; border-radius: 12px; }
/* Calendar category buttons — green Bible Study / amber Revisit-Return Visit */
.btn.cat-bs { background: #2fa56a; box-shadow: 0 12px 22px -12px rgba(47, 165, 106, 0.85); }
.btn.cat-bs:hover { background: #268a58; }
.btn.cat-rv { background: #e08a1e; box-shadow: 0 12px 22px -12px rgba(224, 138, 30, 0.85); }
.btn.cat-rv:hover { background: #c27412; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-row .btn { flex: 1; }

/* ---------- Forms ---------- */
.field { margin-bottom: 14px; }
.field label, .lbl-strong { display: block; font-weight: 800; margin-bottom: 7px; font-size: 0.95rem; }
input, select, textarea {
  width: 100%; padding: 14px 15px; border: 1.5px solid var(--line); border-radius: var(--radius-sm);
  font-size: 1rem; font-family: var(--font-body); background: var(--surface-soft); color: var(--ink);
  transition: border-color 0.2s, box-shadow 0.2s; min-height: 52px;
}
textarea { min-height: 96px; resize: vertical; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--blue); box-shadow: 0 0 0 4px var(--blue-soft); background: #fff;
}
.inline { display: flex; gap: 10px; }
.inline > * { flex: 1; }
.with-mic { position: relative; }
.mic-btn {
  position: absolute; right: 8px; bottom: 8px; width: 42px; height: 42px; border-radius: 12px;
  background: var(--blue-soft); color: var(--blue); border: none; display: grid; place-items: center;
}
.mic-btn.live { background: var(--red); color: #fff; animation: pulse 1.1s infinite; }

/* ---------- List items ---------- */
.list { display: grid; gap: 12px; }
.item {
  border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 15px;
  background: var(--surface-soft); transition: transform 0.15s, box-shadow 0.2s;
}
.item:hover { box-shadow: var(--shadow-soft); }
.item .top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.item h4 { margin: 0 0 4px; font-size: 1.08rem; }
.item .meta { color: var(--ink-soft); font-size: 0.92rem; }
.item .meta b { color: var(--ink); }
.item-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.item-actions .btn { flex: 1; min-width: 110px; }

/* ---------- Compact contact cards ----------
   Reduce only the height and spacing of contact cards (scoped to the Contacts
   list) so more contacts are visible at once. Cards keep every field, button
   and detail — they simply use tighter padding and smaller gaps, and the gap
   between cards is reduced so the list flows naturally with no empty space. */
#contactListWrap .list { gap: 8px; }
#contactListWrap .item { padding: 11px 13px; }
#contactListWrap .item h4 { margin: 0 0 2px; font-size: 1.02rem; }
#contactListWrap .item .section-gap { margin-top: 6px; }
#contactListWrap .item .item-actions.section-gap { margin-top: 8px; }
#contactListWrap .item .bot-section-title.section-gap { margin-top: 10px; margin-bottom: 6px; }

/* Tappable record card — the apartment number / whole card opens an action menu */
.item-tap { cursor: pointer; -webkit-tap-highlight-color: transparent; }
.item-tap:hover { box-shadow: var(--shadow-soft); border-color: var(--blue); }
.item-tap:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.item-tap:active { transform: scale(0.995); }
.apt-tap-title { color: var(--blue-dark); }

/* Compact action menu (mobile-style sheet) */
.sheet-actions { display: flex; flex-direction: column; gap: 10px; }
.sheet-actions .btn { width: 100%; }

/* ---------- Compact apartment grid ---------- */
.apt-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.apt-tile {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px;
  border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px 8px;
  background: var(--surface-soft); cursor: pointer; text-align: center; font: inherit; color: inherit;
  transition: transform 0.15s, box-shadow 0.2s, border-color 0.2s;
  -webkit-tap-highlight-color: transparent;
}
.apt-tile:hover { box-shadow: var(--shadow-soft); border-color: var(--blue); }
.apt-tile:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.apt-tile:active { transform: scale(0.97); }
.apt-tile-num { font-family: var(--font-display); font-weight: 800; font-size: 1rem; color: var(--blue-dark); line-height: 1.1; }
.apt-tile-status { font-size: 0.7rem; padding: 3px 8px; max-width: 100%; }
.apt-tile-date { font-size: 0.72rem; color: var(--ink-faint); }
.apt-tile-by { font-size: 0.72rem; color: var(--ink-faint); font-weight: 600; }
.apt-tile-flag { position: absolute; top: 6px; right: 6px; display: inline-flex; color: var(--amber); }
.apt-tile-flag svg { width: 14px; height: 14px; }

/* Read-only notes / details view */
.note-detail { display: grid; gap: 8px; }
.note-row { display: flex; justify-content: space-between; gap: 12px; font-size: 0.92rem; }
.note-row span { color: var(--ink-soft); }
.note-row b { color: var(--ink); text-align: right; }
.note-body {
  background: var(--surface-soft); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 14px; line-height: 1.5; white-space: normal;
}

.empty {
  text-align: center; padding: 30px 16px; color: var(--ink-faint);
  border: 2px dashed var(--line); border-radius: var(--radius-sm); background: var(--surface-soft);
}

/* ---------- Collapsible team card (Team page) ---------- */
.team-card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  width: 100%; background: transparent; border: 0; padding: 0; margin: 0;
  font: inherit; color: inherit; cursor: pointer; text-align: left;
}
.team-card-head h3 { display: flex; align-items: center; gap: 8px; }
.team-caret { font-size: 0.8rem; color: var(--ink-faint); }
.empty svg { width: 40px; height: 40px; opacity: 0.6; margin-bottom: 8px; }
.empty b { color: var(--ink-soft); display: block; font-family: var(--font-display); }

/* ---------- Badges & chips ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; border-radius: 999px;
  font-size: 0.78rem; font-weight: 800; white-space: nowrap;
}
.badge .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.b-rec { background: var(--green-soft); color: #1c7a4a; }
.b-caution { background: var(--amber-soft); color: #9a5e0d; }
.b-no { background: var(--red-soft); color: #ad2f2a; }
.b-review { background: var(--slate-soft); color: var(--slate); }
.b-blue { background: var(--blue-soft); color: var(--blue-dark); }

.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  border: 1.5px solid var(--line); background: var(--surface); color: var(--ink-soft);
  border-radius: 999px; padding: 9px 15px; font-weight: 700; font-size: 0.9rem;
}
.chip.on { background: var(--blue); color: #fff; border-color: var(--blue); }

/* ---------- Call dashboard (Home page) ---------- */
.dash-controls { display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: center; }
.call-chart {
  width: 100%; background: var(--surface-soft, var(--blue-soft)); border: 1px solid var(--line);
  border-radius: 16px; padding: 10px 8px 4px;
}
.call-chart svg { display: block; width: 100%; height: auto; }
.call-link {
  display: inline-flex; align-items: center; gap: 6px; color: var(--blue);
  font-weight: 800; text-decoration: underline; text-underline-offset: 2px;
}
.call-link svg { width: 16px; height: 16px; }
.call-link:hover { color: var(--blue-dark); }


/* ---------- Category tiles ---------- */
.cat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.cat-tile {
  border: 1px solid var(--line); background: var(--surface); border-radius: 18px;
  padding: 16px 10px; display: flex; flex-direction: column; align-items: center; gap: 9px;
  font-weight: 800; font-size: 0.86rem; color: var(--ink); text-align: center; min-height: 104px;
  justify-content: center; box-shadow: var(--shadow-soft); transition: transform 0.15s, border-color 0.2s;
}
.cat-tile:hover { transform: translateY(-3px); border-color: var(--blue); }
.cat-tile:active { transform: scale(0.96); }
.cat-tile .ci { width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; background: var(--blue-soft); color: var(--blue); }
.cat-tile .ci svg { width: 24px; height: 24px; }

/* ---------- Location result cards ---------- */
.loc-results { display: grid; gap: 16px; }
.loc-card {
  border: 1px solid var(--line); border-radius: 18px; overflow: hidden; background: var(--surface);
  box-shadow: var(--shadow-soft); display: flex; flex-direction: column;
}
.loc-photo { height: 150px; background: var(--bg-2); position: relative; overflow: hidden; }
.loc-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.loc-photo .ph-fallback { width: 100%; height: 100%; display: grid; place-items: center; color: #fff; }
.loc-photo .pin-rating {
  position: absolute; top: 10px; right: 10px; background: rgba(13, 22, 38, 0.82); color: #fff;
  border-radius: 999px; padding: 5px 11px; font-weight: 800; font-size: 0.82rem; display: flex; align-items: center; gap: 5px;
}
.loc-photo .pin-rating svg { width: 14px; height: 14px; color: #ffd24d; }
.loc-body { padding: 15px; display: flex; flex-direction: column; gap: 9px; }
.loc-body h4 { margin: 0; font-size: 1.12rem; }
.loc-line { display: flex; align-items: center; gap: 7px; color: var(--ink-soft); font-size: 0.9rem; }
.loc-line svg { width: 16px; height: 16px; color: var(--ink-faint); flex: none; }
.loc-meta-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.slots { display: flex; gap: 8px; }
.slot {
  flex: 1; border: 1.5px dashed var(--line); border-radius: 12px; padding: 9px; text-align: center;
  font-size: 0.78rem; font-weight: 700; color: var(--ink-faint);
}
.slot.filled { border-style: solid; border-color: var(--blue); background: var(--blue-soft); color: var(--blue-dark); }
.slot .who-s { display: block; font-size: 0.72rem; font-weight: 700; margin-top: 2px; }
/* Clickable available slot (opens the Team Assignment form). */
button.slot { font-family: inherit; cursor: pointer; background: transparent; }
button.slot.slot-open:hover { border-color: var(--blue); color: var(--blue-dark); background: var(--blue-soft); }
/* Locked slot — stays disabled until the previous slot is assigned. */
.slot.slot-locked { opacity: 0.55; cursor: not-allowed; }

/* ---------- Progress bars ---------- */
.progress { height: 12px; border-radius: 999px; background: var(--slate-soft); overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--blue), #5b86ff); transition: width 0.6s cubic-bezier(0.2, 0.8, 0.2, 1); }
.progress.done > span { background: linear-gradient(90deg, var(--green), #4cc488); }
.progress-row { display: flex; justify-content: space-between; font-weight: 700; font-size: 0.9rem; margin-bottom: 6px; }
.progress-row .sm { color: var(--ink-faint); }

/* ---------- Map ---------- */
.map-toolbar { display: flex; gap: 8px; margin-bottom: 14px; }
#map { width: 100%; min-height: 340px; border-radius: 18px; border: 1px solid var(--line); overflow: hidden; }
#map.placeholder { display: grid; place-items: center; text-align: center; color: var(--ink-soft); background: var(--surface-soft); border-style: dashed; padding: 24px; }
.map-legend { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 12px; font-size: 0.82rem; font-weight: 700; color: var(--ink-soft); }
.map-legend span { display: inline-flex; align-items: center; gap: 6px; }
.map-legend i { width: 12px; height: 12px; border-radius: 50%; display: inline-block; }

/* ---------- Calendar ---------- */
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.cal-head h3 { margin: 0; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.cal-dow { text-align: center; font-weight: 800; color: var(--ink-faint); font-size: 0.74rem; padding: 4px 0; }
.cal-cell {
  aspect-ratio: 1 / 1; border: 1px solid var(--line); border-radius: 12px; padding: 6px;
  background: var(--surface-soft); display: flex; flex-direction: column; gap: 3px; cursor: pointer;
  transition: border-color 0.15s; min-height: 0;
}
.cal-cell:hover { border-color: var(--blue); }
.cal-cell.empty-cell { background: transparent; border: none; cursor: default; }
.cal-cell.today { border-color: var(--blue); box-shadow: inset 0 0 0 1px var(--blue); }
.cal-cell .dnum { font-weight: 800; font-size: 0.82rem; }
.cal-cell.has-ev .dnum { color: var(--blue); }
.cal-dots { display: flex; gap: 3px; flex-wrap: wrap; }
.cal-dots i { width: 6px; height: 6px; border-radius: 50%; }

/* event type colors (shared) — green Bible study, yellow Return visit, gray Completed */
.ev-rv { background: var(--amber); }
.ev-bs { background: var(--green); }
.ev-done { background: var(--slate); }
.ev-fu { background: var(--amber); }
.ev-ap { background: #8a5cf6; }
.ev-rm { background: var(--slate); }

/* ---------- Upcoming schedule: four tappable category cards ---------- */
.cal-cat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.cal-cat {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  min-height: 76px; padding: 12px 4px; cursor: pointer;
  border: 1.5px solid var(--line); background: var(--surface);
  border-radius: var(--radius-sm); color: var(--ink);
  -webkit-tap-highlight-color: transparent; transition: border-color 0.15s, box-shadow 0.15s, transform 0.05s;
}
.cal-cat:active { transform: scale(0.97); }
.cal-cat .cal-cat-count { font-family: var(--font-display); font-size: 1.7rem; font-weight: 800; line-height: 1; }
.cal-cat .cal-cat-lbl { font-size: 0.74rem; font-weight: 700; color: var(--ink-soft); text-align: center; line-height: 1.15; }
.cal-cat.open { border-color: var(--blue); box-shadow: inset 0 0 0 1px var(--blue); }
.cal-cat.open .cal-cat-count, .cal-cat.open .cal-cat-lbl { color: var(--blue); }
.cal-cat.cat-bs .cal-cat-count { color: var(--green); }
.cal-cat.cat-rv .cal-cat-count, .cal-cat.cat-fu .cal-cat-count { color: var(--amber); }
.cal-cat.open .cal-cat-count { color: var(--blue); }
.cal-cat-detail {
  margin-top: 12px; padding: 14px; border: 1px solid var(--line);
  border-radius: var(--radius-sm); background: var(--surface-soft);
}
.cal-cat-detail-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 4px; }
.cal-cat-detail-head b { font-family: var(--font-display); font-size: 1.05rem; }
@media (max-width: 360px) {
  .cal-cat { min-height: 70px; padding: 10px 2px; }
  .cal-cat .cal-cat-count { font-size: 1.45rem; }
  .cal-cat .cal-cat-lbl { font-size: 0.68rem; }
}

/* ---------- Sub-tabs ---------- */
.subtabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 16px; -webkit-overflow-scrolling: touch; }
.subtab {
  border: 1.5px solid var(--line); background: var(--surface); color: var(--ink-soft);
  border-radius: 999px; padding: 10px 16px; font-weight: 800; font-size: 0.9rem; white-space: nowrap; flex: none;
}
.subtab.active { background: var(--ink); color: #fff; border-color: var(--ink); }

/* ---------- Modal ---------- */
.modal-scrim {
  position: fixed; inset: 0; z-index: 2000; background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(3px); display: flex; align-items: flex-end; justify-content: center;
  animation: fade 0.25s ease both;
}
.modal {
  background: var(--surface); width: min(560px, 100%); max-height: 90vh; overflow-y: auto;
  border-radius: 26px 26px 0 0; padding: 22px 20px 26px; box-shadow: var(--shadow-lift);
  animation: sheet 0.32s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.modal-head h3 { margin: 0; font-size: 1.3rem; }
@media (min-width: 640px) {
  .modal-scrim { align-items: center; }
  .modal { border-radius: 26px; }
}

/* ---------- Smart Analyzer Bot ---------- */
.bot-fab {
  position: fixed; right: 18px; bottom: 96px; z-index: 1500;
  width: 64px; height: 64px; border-radius: 50%; border: none;
  background: linear-gradient(150deg, var(--blue), #6a8dff); color: #fff;
  box-shadow: 0 16px 30px -10px rgba(47, 107, 255, 0.75); display: grid; place-items: center;
  touch-action: none; transition: transform 0.18s;
}
.bot-fab svg { width: 30px; height: 30px; }
.bot-fab:active { transform: scale(0.92); }
.bot-fab.dragging { transition: none; cursor: grabbing; }
.bot-fab .ping { position: absolute; inset: 0; border-radius: 50%; box-shadow: 0 0 0 0 rgba(47, 107, 255, 0.5); animation: ping 2.4s infinite; }

.bot-panel {
  position: fixed; right: 16px; bottom: 170px; z-index: 1499;
  width: min(380px, calc(100vw - 32px)); max-height: min(560px, calc(100vh - 200px));
  background: var(--surface); border-radius: 24px; box-shadow: var(--shadow-lift);
  border: 1px solid var(--line); display: flex; flex-direction: column; overflow: hidden;
  animation: rise 0.3s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
.bot-top { background: linear-gradient(150deg, #15264a, #1f3a6e); color: #fff; padding: 16px 18px; display: flex; align-items: center; gap: 12px; }
.bot-top .bavatar { width: 40px; height: 40px; border-radius: 13px; background: rgba(255,255,255,0.14); display: grid; place-items: center; }
.bot-top h4 { margin: 0; font-size: 1.05rem; }
.bot-top p { margin: 0; font-size: 0.76rem; opacity: 0.8; }
.bot-top .x { margin-left: auto; background: rgba(255,255,255,0.16); border: none; color: #fff; width: 34px; height: 34px; border-radius: 10px; }
.bot-tabs { display: flex; gap: 6px; padding: 12px 14px 0; overflow-x: auto; }
.bot-tab { border: none; background: var(--slate-soft); color: var(--ink-soft); border-radius: 999px; padding: 8px 13px; font-weight: 800; font-size: 0.82rem; white-space: nowrap; flex: none; }
.bot-tab.active { background: var(--blue); color: #fff; }
.bot-body { padding: 14px 16px 18px; overflow-y: auto; }
.bot-stat { display: flex; align-items: center; gap: 12px; padding: 11px 13px; border: 1px solid var(--line); border-radius: 14px; margin-bottom: 9px; background: var(--surface-soft); }
.bot-stat .n { font-family: var(--font-display); font-weight: 800; font-size: 1.5rem; min-width: 42px; color: var(--blue); }
.bot-stat .t { font-weight: 700; font-size: 0.92rem; }
.bot-stat .t small { display: block; color: var(--ink-faint); font-weight: 600; font-size: 0.78rem; }
.bot-section-title { font-family: var(--font-display); font-weight: 800; margin: 4px 0 10px; color: var(--ink-soft); font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.06em; }

/* ---------- Toast ---------- */
.toast-wrap { position: fixed; left: 50%; bottom: 180px; transform: translateX(-50%); z-index: 3000; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast {
  background: var(--ink); color: #fff; padding: 13px 18px; border-radius: 14px; font-weight: 700;
  box-shadow: var(--shadow-lift); animation: rise 0.3s ease both; display: flex; align-items: center; gap: 9px; max-width: 90vw;
}
.toast svg { width: 18px; height: 18px; flex: none; }
.toast.ok { background: #1c7a4a; }
.toast.warn { background: #9a5e0d; }

.sync-pill { font-size: 0.72rem; font-weight: 800; padding: 4px 10px; border-radius: 999px; display: inline-flex; align-items: center; gap: 5px; }
.sync-pill.on { background: var(--green-soft); color: #1c7a4a; }
.sync-pill.off { background: var(--amber-soft); color: #9a5e0d; }

/* ---------- Super Admin: delete confirmation note ---------- */
.danger-note {
  display: flex; gap: 12px; align-items: flex-start;
  background: var(--red-soft); color: #ad2f2a; border: 1px solid #f3c9c6;
  border-radius: var(--radius-sm); padding: 14px 15px; font-size: 0.94rem; line-height: 1.45;
}
.danger-note svg { width: 22px; height: 22px; flex: none; margin-top: 1px; }
.danger-note b { color: #8f231f; }

/* Admin dashboard sub-tabs stay on one scrollable row on small screens. */
#adminSubtabs { margin-bottom: 16px; }

/* ---------- Animations ---------- */
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes sheet { from { opacity: 0; transform: translateY(40px); } to { opacity: 1; transform: translateY(0); } }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(216,69,63,0.5); } 50% { box-shadow: 0 0 0 10px rgba(216,69,63,0); } }
@keyframes ping { 0% { box-shadow: 0 0 0 0 rgba(47,107,255,0.45); } 70%,100% { box-shadow: 0 0 0 16px rgba(47,107,255,0); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

/* ---------- Responsive ---------- */
@media (max-width: 720px) {
  body { font-size: 16px; }
  .cols-2, .cols-3 { grid-template-columns: 1fr; }
  .appbar .who .nm, .appbar .who .rl { display: none; }
  .who { padding: 4px; }
}
/* Apartment tiles stay multi-column on phones: 3 across, dropping to 2 on the
   narrowest screens so the number, status, and date stay readable. */
@media (max-width: 430px) {
  .apt-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
}
@media (min-width: 721px) {
  .stat-grid { grid-template-columns: repeat(3, 1fr); }
  .loc-results { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
  .cat-grid { grid-template-columns: repeat(5, 1fr); }
}

/* =====================================================================
   Admin Location Finder — filters, custom tags, approval & publishing.
   Admin / Super Admin only; nothing here renders in the Evangelist view.
   ===================================================================== */
.admin-loc-tools { border: 1.5px solid var(--blue-soft); }
.alt-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.alt-head h3, .alt-head h4 { margin: 0; }
.filter-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 12px; }
.filt { display: flex; flex-direction: column; gap: 4px; font-size: 0.78rem; font-weight: 800; color: var(--ink-soft); text-transform: uppercase; letter-spacing: 0.03em; }
.filt select { font-weight: 700; }
@media (min-width: 560px) { .filter-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

.tag-filter-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.tag-chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; border-radius: 999px;
  font-size: 0.82rem; font-weight: 800; line-height: 1; color: var(--tag, var(--blue-dark));
  background: color-mix(in srgb, var(--tag, #2f6bff) 14%, #fff); border: 1.5px solid color-mix(in srgb, var(--tag, #2f6bff) 35%, #fff);
}
.tag-chip.selectable { cursor: pointer; }
.tag-chip.selectable.on { background: var(--tag, #2f6bff); color: #fff; border-color: var(--tag, #2f6bff); }
.tag-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 2px; }

.bulk-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.bulk-bar > span { font-weight: 800; color: var(--ink); margin-right: auto; }
.bulk-bar .btn { flex: 0 1 auto; }

.admin-meta-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 2px; }
.admin-actions { border-top: 1px dashed var(--line); padding-top: 10px; }
.b-slate { background: var(--slate-soft); color: var(--slate); }

.tag-manage-list { display: flex; flex-direction: column; gap: 8px; margin-top: 6px; }
.tag-manage-row { display: flex; align-items: center; gap: 8px; }
.tag-manage-row .spacer { flex: 1; }
.tag-manage-row .btn { flex: 0 0 auto; }
.tag-pick { display: flex; flex-wrap: wrap; gap: 8px; }
.tag-pick-opt { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.tag-pick-opt input { width: 18px; height: 18px; }
