:root {
  --primary: #039be5;
  --primary-hover: #0288d1;
  --bg: #fbfbfb;
  --card: #ffffff;
  --card-border: rgba(0, 0, 0, 0.08);
  --text: rgba(0, 0, 0, 0.85);
  --text-secondary: rgba(0, 0, 0, 0.5);
  --text-tertiary: rgba(0, 0, 0, 0.4);
  --text-hint: rgba(0, 0, 0, 0.45);
  --error: #d64545;
  --tint: rgba(3, 155, 229, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  background: var(--bg);
  color: var(--text);
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); text-decoration: underline; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
}

.centered {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.centered-content {
  width: 100%;
  max-width: 400px;
  animation: fadeUp 0.4s ease;
}

.text-center { text-align: center; }

.card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 18px;
  padding: 28px;
  text-align: left;
}

.card--flat { border-radius: 16px; padding: 22px 24px; }

.title-lg {
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin-bottom: 8px;
}

.title-md {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin-bottom: 10px;
}

.subtitle {
  font-size: 15px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 32px;
}

label.field-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

input[type="email"], input[type="text"], input[type="password"], input[type="datetime-local"], textarea {
  width: 100%;
  box-sizing: border-box;
  padding: 13px 14px;
  border-radius: 12px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  font-size: 15px;
  font-family: inherit;
  margin-bottom: 14px;
}

textarea { resize: vertical; }

button, .btn {
  cursor: pointer;
  font-family: inherit;
}

.btn-primary {
  width: 100%;
  padding: 13px;
  border-radius: 12px;
  border: none;
  background: var(--primary);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
}
.btn-primary:hover { background: var(--primary-hover); }
.btn-primary:disabled { opacity: 0.6; cursor: default; }

.btn-secondary {
  width: 100%;
  padding: 13px;
  border-radius: 12px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  background: #fff;
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
}
.btn-secondary:hover { background: rgba(0, 0, 0, 0.03); }

.btn-outline-sm {
  padding: 11px 18px;
  border-radius: 10px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  background: #fff;
  font-size: 14px;
  font-weight: 500;
}
.btn-outline-sm:hover { background: rgba(0, 0, 0, 0.04); }

.error-text {
  font-size: 13px;
  color: var(--error);
  line-height: 1.5;
  margin-bottom: 14px;
}

.link-low {
  font-size: 13px;
  color: var(--text-tertiary);
}

.badge-circle {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: rgba(3, 155, 229, 0.1);
  margin: 0 auto 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
}

.badge-square {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.06);
  margin: 0 auto 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

.logo-mark {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  background: var(--primary);
  color: #fff;
  font-weight: 600;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
}

/* Church logo image: top-right on desktop, shrunk + centered above title on mobile */
.church-logo {
  position: fixed;
  top: 24px;
  right: 40px;
  height: 64px;
  width: auto;
  z-index: 1;
}
.church-logo--inline {
  display: none;
}
@media (max-width: 700px) {
  .church-logo { display: none; }
  .church-logo--inline {
    display: block;
    height: 48px;
    width: auto;
    margin: 0 auto 16px;
  }
}

/* Dashed prototype-note box (not used in real screens, kept for auth_error styling reuse) */
.note-box {
  background: rgba(3, 155, 229, 0.06);
  border: 1px dashed rgba(3, 155, 229, 0.3);
  border-radius: 14px;
  padding: 16px;
  font-size: 13px;
  color: var(--text-secondary);
}

/* --- Questionnaire form --- */
.form-wrap { flex: 1; padding: 48px 24px 80px; animation: fadeUp 0.4s ease; }
.form-inner { max-width: 620px; margin: 0 auto; }

.edit-banner {
  background: rgba(3, 155, 229, 0.08);
  color: var(--primary-hover);
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 24px;
}

.closed-banner {
  background: rgba(214, 69, 69, 0.08);
  color: var(--error);
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 24px;
}

.letter { font-size: 15px; line-height: 1.65; color: rgba(0, 0, 0, 0.75); }
.letter p { margin: 0 0 16px; }

.details-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  border-radius: 10px;
  border: 1px solid rgba(3, 155, 229, 0.3);
  background: rgba(3, 155, 229, 0.06);
  color: var(--primary-hover);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  list-style: none;
}
.details-toggle:hover { background: rgba(3, 155, 229, 0.1); }
.details-toggle::-webkit-details-marker { display: none; }
.details-toggle .chevron { display: inline-block; transition: transform 0.2s; font-size: 11px; }
details[open] .details-toggle .chevron { transform: rotate(180deg); }

.details-panel {
  margin-top: 16px;
  background: #fff;
  border: 1px solid var(--card-border);
  border-radius: 16px;
  padding: 26px 28px;
  font-size: 14px;
  line-height: 1.7;
  color: rgba(0, 0, 0, 0.75);
}
.details-panel h4 { font-weight: 600; font-size: 14px; color: rgba(0, 0, 0, 0.9); margin: 0 0 4px; }
.details-panel p { margin: 0 0 14px; }
.details-panel .num { color: rgba(0, 0, 0, 0.4); }

.anonymity-note { font-size: 14px; color: var(--text-secondary); margin-bottom: 36px; }

.q-card {
  background: #fff;
  border: 1px solid var(--card-border);
  border-radius: 18px;
  padding: 28px;
  margin-bottom: 20px;
}
.q-card .q-title { font-size: 15px; font-weight: 600; margin-bottom: 4px; }

.member-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 10px;
  margin-top: 12px;
}
.member-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.02);
  cursor: pointer;
}
.member-row input[type="checkbox"] { position: absolute; opacity: 0; width: 0; height: 0; }
.member-row .checkbox-box {
  width: 20px; height: 20px; border-radius: 6px;
  border: 1.5px solid rgba(0, 0, 0, 0.25);
  flex: none;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 12px;
}
.member-row input:checked ~ .checkbox-box {
  background: var(--primary);
  border-color: var(--primary);
}
.member-row input:checked ~ .checkbox-box::after { content: "✓"; }
.member-row:has(input:checked) { background: rgba(3, 155, 229, 0.08); }
.member-row .member-name { font-size: 14.5px; }
.member-row--disabled { cursor: default; color: rgba(0, 0, 0, 0.4); }
.info-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.12);
  color: rgba(0, 0, 0, 0.55);
  font-size: 11px;
  font-weight: 600;
  cursor: help;
  flex: none;
}

.pill-group { display: flex; gap: 10px; margin-bottom: 14px; }
.pill { position: relative; }
.pill input[type="radio"] { position: absolute; opacity: 0; width: 0; height: 0; }
.pill .pill-label {
  display: inline-block;
  padding: 10px 22px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  background: #fff;
  color: rgba(0, 0, 0, 0.6);
  border: 1px solid rgba(0, 0, 0, 0.15);
}
.pill input:checked ~ .pill-label {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* --- Admin --- */
.admin-wrap { flex: 1; padding: 40px 5vw 60px; animation: fadeUp 0.4s ease; }
.admin-inner { max-width: 980px; margin: 0 auto; }
.admin-header { margin-bottom: 32px; }
.admin-title { font-size: 26px; font-weight: 600; letter-spacing: -0.01em; margin-bottom: 6px; }
.admin-logout-link {
  display: inline-block;
  font-size: 13px;
  font-weight: 500;
  color: #b91c1c;
}
.admin-logout-link:hover { color: #8f1616; }

.tab-bar {
  display: flex; gap: 6px; margin-bottom: 28px; border-bottom: 1px solid var(--card-border);
}
.tab-bar a {
  padding: 10px 4px;
  margin-right: 22px;
  font-size: 14px;
  font-weight: 500;
  color: rgba(0, 0, 0, 0.45);
  border-bottom: 2px solid transparent;
  text-decoration: none;
}
.tab-bar a:hover { color: rgba(0, 0, 0, 0.8); }
.tab-bar a.active { color: rgba(0, 0, 0, 0.85); border-bottom-color: var(--primary); }

.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 24px; }
.stat-card { background: #fff; border: 1px solid var(--card-border); border-radius: 16px; padding: 22px; }
.stat-number { font-size: 30px; font-weight: 700; color: var(--primary); }
.stat-number--plain { color: var(--text); }
.stat-label { font-size: 13px; color: var(--text-secondary); margin-top: 4px; }

.settings-card {
  background: #fff; border: 1px solid var(--card-border); border-radius: 16px;
  padding: 24px; margin-bottom: 20px;
}
.settings-card-header {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px;
}
.settings-card-title { font-size: 15px; font-weight: 600; }
.settings-card-hint { font-size: 13px; color: var(--text-hint); }

.toggle-track {
  width: 46px; height: 28px; border-radius: 14px;
  background: rgba(0, 0, 0, 0.15);
  position: relative; cursor: pointer; transition: background 0.2s; border: none;
  flex: none;
}
.toggle-track.is-on { background: var(--primary); }
.toggle-knob {
  width: 22px; height: 22px; border-radius: 50%; background: #fff;
  position: absolute; top: 3px; left: 3px; transition: left 0.2s;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}
.toggle-track.is-on .toggle-knob { left: 22px; }

.date-row { display: flex; gap: 16px; flex-wrap: wrap; }
.date-field { flex: 1; min-width: 200px; }
.date-field label { display: block; font-size: 12px; color: var(--text-hint); margin-bottom: 6px; }
.date-field input { margin-bottom: 0; padding: 10px 12px; border-radius: 10px; font-size: 14px; }

.emails-textarea {
  font-family: ui-monospace, monospace;
  font-size: 13px;
  line-height: 1.7;
  padding: 14px;
  border-radius: 12px;
  min-height: 220px;
}

.member-admin-row {
  display: grid;
  grid-template-columns: 1.6fr 1fr 2fr;
  gap: 14px;
  align-items: center;
  padding: 12px 20px;
  font-size: 14px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}
.member-admin-row--head {
  font-size: 12px; font-weight: 600; color: var(--text-tertiary);
  text-transform: uppercase; letter-spacing: 0.03em;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}
.member-admin-name { font-weight: 500; }
.member-admin-toggle {
  display: flex; align-items: center; gap: 6px;
  font-size: 13px; color: var(--text-secondary); cursor: pointer;
}
.member-admin-note {
  width: 100%; box-sizing: border-box; padding: 8px 10px; margin-bottom: 0;
  border-radius: 8px; border: 1px solid rgba(0, 0, 0, 0.12); font-size: 13px;
}

.save-row { display: flex; justify-content: flex-end; align-items: center; margin-top: 14px; gap: 12px; }
.saved-msg { font-size: 13px; color: var(--primary); }

code.inline-code { background: rgba(0, 0, 0, 0.06); padding: 2px 6px; border-radius: 6px; font-size: 13px; }

.table-card { background: #fff; border: 1px solid var(--card-border); border-radius: 16px; overflow: hidden; }
.table-row {
  display: grid; grid-template-columns: 2fr 1.2fr 1.2fr 0.8fr 0.9fr;
  padding: 14px 20px; font-size: 14px; border-bottom: 1px solid rgba(0, 0, 0, 0.05);
  align-items: center;
}
.table-row--head {
  font-size: 12px; font-weight: 600; color: var(--text-tertiary);
  text-transform: uppercase; letter-spacing: 0.03em;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}
.table-row .email-cell { font-weight: 500; }
.table-row .email-cell.is-submitted { color: #1a9c4a; }
.table-row .muted { color: rgba(0, 0, 0, 0.55); }

.btn-delete-row {
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid rgba(214, 69, 69, 0.35);
  background: rgba(214, 69, 69, 0.06);
  color: var(--error);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
}
.btn-delete-row:hover { background: rgba(214, 69, 69, 0.12); }

.delete-modal {
  border: none;
  border-radius: 16px;
  padding: 26px 28px;
  max-width: 420px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
}
.delete-modal::backdrop { background: rgba(0, 0, 0, 0.4); }
.delete-modal-title { font-size: 17px; font-weight: 600; margin-bottom: 12px; }
.delete-modal-body { font-size: 14px; line-height: 1.55; color: var(--text-secondary); margin-bottom: 18px; }
.delete-modal-confirm-check {
  display: flex; align-items: flex-start; gap: 8px;
  font-size: 13px; color: var(--text); margin-bottom: 20px; cursor: pointer;
}
.delete-modal-confirm-check input { margin-top: 2px; }
.delete-modal-actions { display: flex; justify-content: flex-end; gap: 10px; }
.btn-delete-confirm {
  padding: 10px 18px; border-radius: 10px; border: none;
  background: var(--error); color: #fff; font-size: 14px; font-weight: 600; cursor: pointer;
}
.btn-delete-confirm:hover { background: #b93a3a; }
.btn-delete-confirm:disabled { background: rgba(214, 69, 69, 0.35); cursor: default; }
