@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
  --sidebar-w: 240px;
  --attendance-card-min: 150px;
  --bg: #f4f6f9;
  --surface: #ffffff;
  --sidebar-bg: #0f172a;
  --sidebar-text: #94a3b8;
  --sidebar-active-bg: #1e293b;
  --sidebar-active-text: #ffffff;
  --sidebar-icon: #475569;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-light: #eff6ff;
  --success: #16a34a;
  --success-light: #f0fdf4;
  --danger: #dc2626;
  --ink: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --card-shadow: 0 1px 3px rgba(0,0,0,.08), 0 4px 16px rgba(0,0,0,.06);
  --radius: 12px;
  --radius-sm: 8px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 14px;
  color: var(--ink);
  background: var(--bg);
  display: flex;
}

/* ── Sidebar ───────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  flex-shrink: 0;
}

.sidebar-logo {
  padding: 24px 20px 20px;
  border-bottom: 1px solid #1e293b;
}
.sidebar-logo .church { font-size: 11px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--accent); margin-bottom: 4px; }
.sidebar-logo h1 { font-size: 20px; font-weight: 800; color: #fff; line-height: 1.1; }

.sidebar-nav { flex: 1; padding: 16px 12px; display: flex; flex-direction: column; gap: 2px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--sidebar-text);
  font-weight: 500;
  font-size: 14px;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  transition: background .15s, color .15s;
  text-decoration: none;
}
.nav-item:hover { background: var(--sidebar-active-bg); color: #cbd5e1; }
.nav-item.active { background: var(--sidebar-active-bg); color: var(--sidebar-active-text); }
.nav-item.active .nav-icon { color: var(--accent); }
.nav-icon { width: 18px; height: 18px; flex-shrink: 0; opacity: .7; }
.nav-item.active .nav-icon { opacity: 1; }

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid #1e293b;
}
.sidebar-footer form { margin: 0; }
.sidebar-footer .nav-item { color: #64748b; }
.sidebar-footer .nav-item:hover { color: #f87171; background: rgba(220,38,38,.08); }

/* ── Main content ───────────────────────────────────────────── */
.main-wrap {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 28px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar-title { font-size: 16px; font-weight: 700; color: var(--ink); }
.topbar-meta { font-size: 13px; color: var(--muted); }

.page-content { padding: 24px 28px 120px; }

/* ── Views ──────────────────────────────────────────────────── */
.view { display: none; }
.view.active { display: block; }

/* ── Cards / Panels ─────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--card-shadow);
  padding: 20px;
  margin-bottom: 16px;
}

.card-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.card-title { font-size: 16px; font-weight: 700; margin-bottom: 2px; }
.card-sub { font-size: 13px; color: var(--muted); }

/* ── Buttons ────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font: 500 13px/1 'Inter', sans-serif;
  padding: 8px 14px;
  cursor: pointer;
  white-space: nowrap;
  transition: background .12s, border-color .12s, color .12s;
  text-decoration: none;
}
.btn:hover { background: var(--bg); }
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-success { background: var(--success); color: #fff; border-color: var(--success); }
.btn-success:hover { background: #15803d; }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--bg); border-color: var(--border); }
.btn-danger { color: var(--danger); border-color: transparent; background: transparent; }
.btn-danger:hover { background: #fef2f2; border-color: #fecaca; }
.btn-wide { width: 100%; justify-content: center; padding: 12px; font-size: 15px; }
.icon-btn { width: 36px; height: 36px; justify-content: center; padding: 0; }
.icon-btn svg { display: block; }

/* ── Form elements ──────────────────────────────────────────── */
input, select, textarea {
  font: 400 14px/1.4 'Inter', sans-serif;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  padding: 8px 12px;
  width: 100%;
  outline: none;
  transition: border-color .12s, box-shadow .12s;
}
input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37,99,235,.1); }
input[type="file"] { padding: 6px; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }

/* ── Attendance toolbar ─────────────────────────────────────── */
.toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.toolbar input[type="search"] { flex: 1; min-width: 200px; }

/* ── Member grid ────────────────────────────────────────────── */
.member-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(var(--attendance-card-min), 1fr));
  gap: 12px;
  margin-top: 16px;
}
.member-grid.checklist-view {
  grid-template-columns: 1fr;
  gap: 6px;
}
.checklist-row {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  padding: 9px 12px;
  text-align: left;
  cursor: pointer;
}
.checklist-row.selected { background: var(--success-light); border-color: #86efac; }
.check-box {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--success);
  font-weight: 900;
}
.checklist-row.selected .check-box { border-color: var(--success); background: white; }
.check-name { font-weight: 700; }
.check-family { color: var(--muted); font-size: 12px; }
.photo-hover-preview {
  position: fixed;
  width: 180px;
  height: 180px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, #e2e8f0, #f1f5f9);
  background-size: cover;
  background-position: center;
  box-shadow: 0 16px 40px rgba(15, 23, 42, .35);
  border: 3px solid white;
  z-index: 500;
  pointer-events: none;
}
.card-size-control {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  text-transform: none;
  letter-spacing: 0;
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}
.card-size-control input {
  width: 120px;
  padding: 0;
  accent-color: var(--accent);
}

.member-card {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 0;
  cursor: pointer;
  text-align: left;
  overflow: hidden;
  transition: border-color .15s, box-shadow .15s, transform .12s;
  box-shadow: var(--card-shadow);
  display: flex;
  flex-direction: column;
}
.member-grid.order-mode .member-card {
  cursor: grab;
}
.member-grid.order-mode .member-card:active {
  cursor: grabbing;
}
.member-grid.order-mode .member-card.selected {
  background: var(--surface);
  border-color: var(--border);
  box-shadow: var(--card-shadow);
}
.member-card.dragging { opacity: .45; }
.member-card.drag-over { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37,99,235,.18); }
.member-card:hover { border-color: #93c5fd; box-shadow: 0 4px 20px rgba(37,99,235,.12); transform: translateY(-1px); }
.member-card.selected { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37,99,235,.15), var(--card-shadow); }
.member-card.selected .card-check { opacity: 1; transform: scale(1); }

.card-photo {
  width: 100%;
  aspect-ratio: 1;
  background: linear-gradient(135deg, #e2e8f0, #f1f5f9);
  background-size: cover;
  background-position: center;
  position: relative;
  flex-shrink: 0;
}
.card-check {
  position: absolute;
  top: 8px; right: 8px;
  width: 24px; height: 24px;
  background: var(--accent);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  opacity: 0;
  transform: scale(.6);
  transition: opacity .15s, transform .15s;
}
.card-check::after { content: ''; width: 10px; height: 6px; border-left: 2px solid #fff; border-bottom: 2px solid #fff; transform: rotate(-45deg) translateY(-1px); display: block; }

.card-info { padding: 10px 12px 12px; flex: 1; }
.member-name { font-size: 13px; font-weight: 700; color: var(--ink); line-height: 1.3; }
.member-family { font-size: 11px; color: var(--muted); margin-top: 2px; }

/* ── Family group header ────────────────────────────────────── */
.family-header {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  padding: 12px 0 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}
.family-check {
  width: 22px;
  height: 22px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--accent);
  font-size: 13px;
  font-weight: 900;
  line-height: 1;
  cursor: pointer;
}
.family-check:hover { background: var(--accent-light); border-color: #bfdbfe; }

/* ── Save bar ───────────────────────────────────────────────── */
.savebar {
  position: fixed;
  bottom: 20px;
  left: calc(var(--sidebar-w) + 20px);
  right: 20px;
  background: var(--sidebar-bg);
  border-radius: var(--radius);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  box-shadow: 0 8px 32px rgba(0,0,0,.25);
  z-index: 50;
}
.savebar-counts { color: #cbd5e1; font-size: 13px; font-weight: 500; flex: 1; min-width: 120px; }
.savebar-counts strong { color: #fff; }
.savebar input { flex: 1; min-width: 160px; max-width: 260px; background: #1e293b; border-color: #334155; color: #fff; }
.savebar input::placeholder { color: #64748b; }
.savebar input:focus { border-color: var(--accent); }

/* ── Visitor chips ──────────────────────────────────────────── */
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 12px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--accent-light);
  color: var(--accent);
  border: 1px solid #bfdbfe;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 500;
}
.chip button { background: none; border: none; color: inherit; cursor: pointer; font-size: 14px; line-height: 1; padding: 0; opacity: .6; }
.chip button:hover { opacity: 1; }

/* ── Admin list ─────────────────────────────────────────────── */
.admin-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 10px;
}

.admin-row {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  display: grid;
  grid-template-columns: 48px 1fr;
  gap: 10px;
  align-items: start;
  min-width: 0;
  cursor: pointer;
}
.admin-row:hover { border-color: #bfdbfe; box-shadow: 0 4px 18px rgba(37,99,235,.08); }
.admin-avatar {
  width: 48px; height: 48px;
  border: 0;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, #e2e8f0, #f1f5f9);
  background-size: cover;
  background-position: center;
  flex-shrink: 0;
  cursor: pointer;
  padding: 0;
  display: block;
}
.admin-avatar:hover { outline: 3px solid rgba(37,99,235,.18); }
.admin-body { display: flex; flex-direction: column; gap: 8px; }
.admin-fields { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.admin-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.admin-actions .history-btn { cursor: pointer; }
.member-summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.member-summary-name { font-size: 15px; font-weight: 800; }
.member-summary-family { color: var(--muted); font-size: 13px; margin-top: 2px; }
.edit-member-preview {
  width: 96px;
  height: 96px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, #e2e8f0, #f1f5f9);
  background-size: cover;
  background-position: center;
  margin-bottom: 14px;
  border: 1px solid var(--border);
  cursor: pointer;
  position: relative;
  padding: 0;
  display: block;
}
.edit-member-preview:hover { outline: 3px solid rgba(37,99,235,.18); }
.edit-photo-pencil {
  position: absolute;
  right: -6px;
  bottom: -6px;
  width: 30px;
  height: 30px;
  border-radius: 999px;
  background: var(--accent);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 800;
  box-shadow: 0 4px 12px rgba(37,99,235,.35);
}
.member-history {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 14px;
}
.member-history-panel {
  grid-column: 1 / -1;
  margin-top: -2px;
}
.member-history-heading {
  font-size: 16px;
  font-weight: 800;
  margin-bottom: 12px;
}
.member-history-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}
.mini-stat {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px;
}
.mini-stat span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: 4px;
}
.mini-stat strong { font-size: 16px; }
.member-history-title { font-size: 12px; font-weight: 800; margin-bottom: 6px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.member-history-list { display: grid; gap: 4px; }
.member-history-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--border);
  padding: 6px 0;
  font-size: 13px;
}
.member-history-item span { color: var(--muted); white-space: nowrap; }
.member-history-item strong { font-weight: 600; text-align: right; }
.member-history-item.missed strong { color: var(--danger); }
.member-history-item.attended strong { color: var(--success); }

/* ── History / stats ────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  box-shadow: var(--card-shadow);
}
.stat-label { font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 6px; }
.stat-value { font-size: 28px; font-weight: 800; color: var(--ink); line-height: 1; }

.event-list { display: flex; flex-direction: column; gap: 8px; }
.event-date-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--card-shadow);
  overflow: hidden;
}
.event-date-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 14px 18px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.event-date-card-events { display: grid; gap: 0; }
.event-row {
  background: var(--surface);
  border: 0;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  padding: 14px 18px;
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 16px;
  align-items: center;
  cursor: pointer;
}
.event-row:last-of-type { border-bottom: 0; }
.event-row:hover { border-color: #bfdbfe; box-shadow: 0 4px 18px rgba(37,99,235,.08); }
.event-date { font-size: 13px; font-weight: 700; color: var(--ink); }
.event-source { font-size: 11px; color: var(--muted); margin-top: 2px; }
.event-title { font-size: 14px; font-weight: 500; }
.event-count { font-size: 20px; font-weight: 800; color: var(--accent); white-space: nowrap; }
.event-count span { font-size: 11px; font-weight: 500; color: var(--muted); display: block; text-align: right; }
.event-detail {
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 0;
  border-radius: 0 0 var(--radius) var(--radius);
  margin: -8px 0 8px;
  padding: 16px;
}
.event-detail-section + .event-detail-section { margin-top: 18px; }
.event-detail-title { font-size: 13px; font-weight: 800; color: var(--ink); margin-bottom: 10px; }
.event-detail-loading, .empty-state { color: var(--muted); font-size: 13px; }
.attendee-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.attendee-card {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px;
  background: var(--bg);
}
.attendee-photo {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, #e2e8f0, #f1f5f9);
  background-size: cover;
  background-position: center;
}
.attendee-name { font-size: 13px; font-weight: 700; }
.attendee-family { color: var(--muted); font-size: 11px; margin-top: 2px; }
.visitor-detail-list { display: flex; gap: 6px; flex-wrap: wrap; }
.delete-attendance-btn,
.delete-visitor-btn {
  width: 24px;
  height: 24px;
  border-radius: 999px;
  border: 0;
  background: #fee2e2;
  color: var(--danger);
  font-size: 18px;
  line-height: 1;
  font-weight: 800;
  cursor: pointer;
}
.delete-attendance-btn:hover,
.delete-visitor-btn:hover { background: #fecaca; }
.visitor-chip { padding-right: 4px; }
.visitor-chip .delete-visitor-btn { width: 18px; height: 18px; font-size: 14px; }

/* ── Photo zoom modal ───────────────────────────────────────── */
.zoom-modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.zoom-modal[hidden] { display: none; }
.zoom-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.7);
  backdrop-filter: blur(4px);
}
.zoom-dialog {
  position: relative;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 24px 64px rgba(0,0,0,.5);
  width: min(520px, 100%);
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 20px;
  z-index: 1;
}
.zoom-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.zoom-name { font-size: 16px; font-weight: 700; }
.zoom-hint { font-size: 12px; color: var(--muted); }
.zoom-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: #1e293b;
  cursor: grab;
  user-select: none;
  touch-action: none;
}
.zoom-stage:active { cursor: grabbing; }
.zoom-image {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-repeat: no-repeat;
  transform-origin: center center;
  will-change: transform;
  pointer-events: none;
}
.zoom-frame {
  position: absolute;
  inset: 0;
  border: 3px dashed rgba(255,255,255,.35);
  border-radius: var(--radius-sm);
  pointer-events: none;
}
.zoom-controls {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.zoom-controls input[type="range"] {
  flex: 1;
  min-width: 80px;
  padding: 0;
  height: 4px;
  accent-color: var(--accent);
  border: none;
  box-shadow: none;
}

/* ── Login page ─────────────────────────────────────────────── */
body.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--sidebar-bg);
  padding: 20px;
}

.login-wrap {
  width: min(400px, 100%);
}
.login-card {
  background: var(--surface);
  border-radius: 16px;
  padding: 40px;
  box-shadow: 0 20px 60px rgba(0,0,0,.4);
  text-align: center;
}
.login-church { font-size: 11px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--accent); margin-bottom: 8px; }
.login-title { font-size: 28px; font-weight: 800; color: var(--ink); margin-bottom: 8px; }
.login-sub { font-size: 14px; color: var(--muted); margin-bottom: 28px; line-height: 1.5; }
.login-error { font-size: 13px; color: var(--danger); margin-top: 12px; }

/* ── Misc ───────────────────────────────────────────────────── */
.section-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.section-title { font-size: 18px; font-weight: 700; }
.section-sub { font-size: 13px; color: var(--muted); margin-top: 2px; }
.divider { border: none; border-top: 1px solid var(--border); margin: 16px 0; }
.badge { display: inline-block; font-size: 11px; font-weight: 600; border-radius: 999px; padding: 2px 8px; background: var(--accent-light); color: var(--accent); }

/* ── Generic modal ──────────────────────────────────────────── */
.modal {
  position: fixed;
  inset: 0;
  z-index: 180;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal[hidden] { display: none; }
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, .58);
  backdrop-filter: blur(3px);
}
.modal-dialog {
  position: relative;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 24px 64px rgba(0,0,0,.35);
  padding: 20px;
  width: min(560px, 100%);
  z-index: 1;
}
.small-dialog { width: min(440px, 100%); }
.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.modal-title { font-size: 18px; font-weight: 800; }
.modal-subtitle { color: var(--muted); font-size: 13px; margin-top: 2px; }
.modal-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 4px;
  margin-bottom: 16px;
}
.modal-tab {
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
  padding: 9px;
  cursor: pointer;
}
.modal-tab.active { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.modal-pane { display: none; }
.modal-pane.active { display: block; }
.stack-form { display: grid; gap: 12px; }
.modal-message {
  color: var(--ink);
  line-height: 1.5;
  margin-bottom: 16px;
}
.summary-total {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  background: var(--accent-light);
  border: 1px solid #bfdbfe;
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-bottom: 12px;
}
.summary-total span { color: var(--muted); font-weight: 700; }
.summary-total strong { font-size: 22px; color: var(--accent); }
.summary-section {
  border-top: 1px solid var(--border);
  padding: 10px 0;
}
.summary-label { color: var(--muted); font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; }
.summary-count { font-size: 20px; font-weight: 800; margin-top: 2px; }
.summary-names { color: var(--ink); margin-top: 4px; }
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
.family-list { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }
.family-tools {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 16px;
}
.family-tools input { flex: 1; min-width: 180px; }
.family-pager {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 13px;
}
.family-edit-row {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  gap: 8px;
  align-items: center;
  width: 100%;
}
.user-list { display: grid; gap: 8px; }
.user-row {
  display: grid;
  grid-template-columns: 1.4fr 1fr auto auto auto;
  gap: 8px;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
}
.inline-check {
  flex-direction: row;
  align-items: center;
  gap: 6px;
  text-transform: none;
  letter-spacing: 0;
  font-size: 13px;
  color: var(--ink);
  font-weight: 600;
  white-space: nowrap;
}
.inline-check input { width: auto; }

/* ── Topbar fields always wrap cleanly ──────────────────────── */
.topbar { flex-wrap: wrap; height: auto; min-height: 60px; padding: 10px 20px; gap: 10px; }
.topbar-fields { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.topbar-field { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 500; white-space: nowrap; }
.topbar-field input { width: auto; min-width: 0; }

/* ── Hamburger (mobile only) ────────────────────────────────── */
.hamburger {
  display: none;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 8px;
  cursor: pointer;
  flex-shrink: 0;
  color: var(--ink);
}
.hamburger svg { display: block; }

/* ── Sidebar overlay (mobile) ───────────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 99;
}
.sidebar-overlay.open { display: block; }

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 960px) {
  :root { --sidebar-w: 64px; }
  .sidebar-logo { padding: 14px 8px; display: flex; justify-content: center; }
  .sidebar-logo .church, .sidebar-logo h1 { display: none; }
  .nav-item span:not(.nav-icon) { display: none; }
  .nav-item { justify-content: center; padding: 12px; }
  .page-content { padding: 16px 16px 160px; }
  .savebar { left: calc(var(--sidebar-w) + 10px); right: 10px; bottom: 10px; }
  .addMemberForm { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 680px) {
  :root { --sidebar-w: 0px; }
  .sidebar {
    transform: translateX(-240px);
    width: 240px;
    transition: transform .25s ease;
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-logo { padding: 20px 20px 16px; display: block; }
  .sidebar-logo .church, .sidebar-logo h1 { display: block; }
  .nav-item span:not(.nav-icon) { display: inline; }
  .nav-item { justify-content: flex-start; padding: 10px 12px; }
  .hamburger { display: flex; align-items: center; }
  .main-wrap { margin-left: 0; }
  .topbar { padding: 10px 14px; }
  .page-content { padding: 12px 12px 200px; }
  .member-grid { grid-template-columns: repeat(auto-fill, minmax(var(--attendance-card-min), 1fr)); gap: 8px; }
  .admin-fields { grid-template-columns: 1fr 1fr; }
  .admin-row { grid-template-columns: 44px 1fr; }
  .admin-avatar { width: 44px; height: 44px; }
  .event-row { grid-template-columns: 1fr auto; gap: 10px; }
  .event-title { grid-column: 1 / -1; }
  .savebar { left: 8px; right: 8px; bottom: 8px; padding: 10px 12px; gap: 8px; }
  .savebar input { flex-basis: 100%; max-width: 100%; order: 2; }
  .savebar #addVisitor { order: 3; }
  .savebar #saveAttendance { order: 4; margin-left: auto; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  #addMemberForm { grid-template-columns: 1fr 1fr !important; }
  .user-row { grid-template-columns: 1fr; }
}

@media (max-width: 400px) {
  .member-grid { grid-template-columns: repeat(auto-fill, minmax(var(--attendance-card-min), 1fr)); }
  .admin-fields { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}
