:root {
  --bg: #f3f6fb;
  --surface: #ffffff;
  --surface-soft: #f8fbff;
  --text: #0f172a;
  --muted: #475569;
  --border: #dbe4f0;
  --primary: #2563eb;
  --primary-600: #1d4ed8;
  --ring: rgba(37, 99, 235, 0.2);
  --shadow: 0 18px 40px rgba(15, 23, 42, 0.08);
  --panel-shadow: 0 12px 28px rgba(15, 23, 42, 0.06);
  --radius: 18px;
  --max: 1080px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background:
    radial-gradient(circle at top left, rgba(191, 219, 254, 0.55), transparent 30%),
    radial-gradient(circle at 100% 0, rgba(253, 230, 138, 0.2), transparent 28%),
    var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Helvetica, Arial, sans-serif;
}

a { color: inherit; text-decoration: none; }
.container { max-width: var(--max); margin: 0 auto; padding: 0 20px; }
header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(219, 228, 240, 0.9);
  box-shadow: 0 2px 10px rgba(2, 6, 23, 0.04);
}

.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 900;
  letter-spacing: 0.2px;
}

.logo {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: linear-gradient(135deg, #60a5fa, #34d399);
  box-shadow: inset 0 0 16px rgba(255, 255, 255, 0.6);
}

.actions-right {
  display: flex;
  gap: 10px;
  align-items: center;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  cursor: pointer;
  font-weight: 800;
  letter-spacing: 0.2px;
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease, color 0.18s ease;
}

.btn.primary {
  background: var(--primary);
  color: #fff;
  padding: 12px 16px;
  border-radius: 14px;
  box-shadow: 0 8px 24px rgba(37, 99, 235, 0.2);
}

.btn.primary:hover {
  transform: translateY(-1px);
  background: var(--primary-600);
  box-shadow: 0 14px 30px rgba(37, 99, 235, 0.24);
}

.btn.ghost {
  background: rgba(255, 255, 255, 0.85);
  color: var(--primary);
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid rgba(37, 99, 235, 0.26);
}

.btn.ghost:hover {
  background: #eff6ff;
}

.btn.danger {
  background: #ef4444;
  color: #fff;
  padding: 10px 14px;
  border-radius: 12px;
}

.btn.success {
  background: #10b981;
  color: #fff;
}

.section { padding: 40px 0 56px; }
.card {
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(219, 228, 240, 0.95);
  border-radius: 28px;
  box-shadow: var(--shadow);
}

.form-shell {
  max-width: 980px;
  margin: 0 auto;
}

.form-wrapper {
  padding: 28px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(248, 251, 255, 0.98));
}

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.page-head__copy {
  display: grid;
  gap: 10px;
  max-width: 680px;
}

.page-head__eyebrow {
  margin: 0;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--primary);
}

.page-head h1 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 3rem);
  line-height: 1.05;
}

.page-head__summary {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
  font-size: 1rem;
}

.page-head__actions {
  display: grid;
  gap: 12px;
  justify-items: end;
}

.page-head__pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 8px 14px;
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(219, 234, 254, 0.95), rgba(224, 242, 254, 0.95));
  border: 1px solid rgba(125, 211, 252, 0.55);
  color: #0f4c81;
  font-size: 0.9rem;
  font-weight: 800;
}

.muted { color: var(--muted); }

form {
  display: grid;
  gap: 22px;
  margin-top: 18px;
}

.acct-stage {
  display: grid;
  gap: 18px;
  min-width: 0;
  padding: 24px;
  border-radius: 24px;
  border: 1px solid rgba(209, 219, 232, 0.96);
  box-shadow: var(--panel-shadow);
}

.acct-stage--identity {
  background: linear-gradient(135deg, rgba(239, 246, 255, 0.92), rgba(255, 255, 255, 0.98));
}

.acct-stage--children {
  background: linear-gradient(135deg, rgba(255, 251, 235, 0.95), rgba(255, 255, 255, 0.98));
}

.acct-stage--share {
  background: linear-gradient(135deg, rgba(240, 253, 244, 0.94), rgba(255, 255, 255, 0.98));
}

.acct-stage__head {
  display: flex;
  align-items: flex-start;
  gap: 16px;
}

.acct-stage__index {
  flex: 0 0 46px;
  width: 46px;
  height: 46px;
  border-radius: 16px;
  background: #0f172a;
  color: #fff;
  font-weight: 900;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 12px 26px rgba(15, 23, 42, 0.16);
}

.acct-stage__copy {
  display: grid;
  gap: 6px;
}

.acct-stage__eyebrow {
  margin: 0;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #0f4c81;
}

.acct-stage__copy h2 {
  margin: 0;
  font-size: clamp(1.28rem, 2.4vw, 1.65rem);
}

.acct-stage__copy p {
  margin: 0;
  line-height: 1.55;
}

.acct-stage__body {
  display: grid;
  gap: 18px;
  min-width: 0;
}

.acct-stage__body--two-col {
  grid-template-columns: minmax(0, 0.84fr) minmax(0, 1.16fr);
  align-items: start;
}

.acct-stage__body--stack {
  grid-template-columns: 1fr;
}

.acct-panel,
.account-block,
.auto-sync-card,
.family-card,
.reauthorize-block,
.acct-save-panel {
  display: grid;
  gap: 14px;
  min-width: 0;
  padding: 18px;
  border-radius: var(--radius);
  border: 1px solid rgba(219, 228, 240, 0.95);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.05);
}

.acct-panel--focus {
  border-color: rgba(37, 99, 235, 0.38);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.14), 0 22px 48px rgba(15, 23, 42, 0.16);
  animation: acctPanelFocusPulse 1.8s ease;
}

@keyframes acctPanelFocusPulse {
  0% {
    box-shadow: 0 0 0 0 rgba(37, 99, 235, 0.24), 0 16px 36px rgba(15, 23, 42, 0.12);
  }
  50% {
    box-shadow: 0 0 0 8px rgba(37, 99, 235, 0.08), 0 22px 48px rgba(15, 23, 42, 0.16);
  }
  100% {
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.14), 0 22px 48px rgba(15, 23, 42, 0.16);
  }
}

.acct-panel__head {
  display: grid;
  gap: 6px;
}

.acct-panel__head h3,
.children-head h3 {
  margin: 0;
  font-size: 1.05rem;
}

.acct-panel__head p,
.acct-section-copy {
  margin: 0;
  line-height: 1.55;
}

label {
  display: block;
  font-weight: 800;
}

input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  outline: none;
  margin-top: 6px;
}

input:focus {
  box-shadow: 0 0 0 6px var(--ring);
  border-color: var(--primary);
}

input[type="checkbox"] {
  width: 18px;
  height: 18px;
  padding: 0;
  margin: 0;
  border-radius: 4px;
  border: 1px solid var(--border);
  accent-color: var(--primary);
}

input[type="checkbox"]:focus {
  box-shadow: 0 0 0 3px var(--ring);
  border-color: var(--primary);
}

.auto-sync-card {
  margin-top: 0;
}

.auto-sync-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.auto-sync-copy span {
  display: block;
  font-weight: 800;
  font-size: 1rem;
  color: var(--text);
}

.auto-sync-desc,
.auto-sync-hint {
  margin: 0;
  font-size: 0.92rem;
  line-height: 1.5;
}

.auto-sync-option {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  color: var(--text);
}

.acct-sync-alert {
  display: grid;
  gap: 8px;
  padding: 14px 15px;
  border-radius: 16px;
  border: 1px solid rgba(245, 158, 11, 0.42);
  background: linear-gradient(135deg, rgba(255, 247, 237, 0.98), rgba(255, 251, 235, 0.98));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

.acct-sync-alert strong {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.88rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #9a3412;
}

.acct-sync-alert strong::before {
  content: "!";
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: rgba(245, 158, 11, 0.16);
  color: #b45309;
  font-weight: 900;
}

.acct-sync-alert p {
  margin: 0;
  color: #7c2d12;
  font-size: 0.93rem;
  line-height: 1.55;
}

.switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
}

.switch input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.switch-track {
  width: 52px;
  height: 28px;
  background: #c7d2fe;
  border-radius: 999px;
  transition: background 0.2s ease, box-shadow 0.2s ease;
  display: inline-block;
  position: relative;
  box-shadow: inset 0 0 0 1px rgba(79, 70, 229, 0.25);
}

.switch-track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.15);
  transition: left 0.2s ease;
}

.switch input:checked + .switch-track {
  background: var(--primary);
  box-shadow: inset 0 0 0 1px rgba(37, 99, 235, 0.35);
}

.switch input:checked + .switch-track::after {
  left: 27px;
}

.switch input:focus-visible + .switch-track {
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.25), inset 0 0 0 1px rgba(37, 99, 235, 0.35);
}

.children-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.children-list {
  display: grid;
  gap: 16px;
  margin-top: 4px;
}

.child-row {
  display: grid;
  gap: 16px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.04);
}

.child-row-main {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr)) auto;
  gap: 12px;
  align-items: end;
}

.child-row-main .remove {
  background: #ef4444;
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 10px 14px;
  font-weight: 800;
  cursor: pointer;
}

.child-row-main .remove:hover {
  filter: brightness(0.95);
}

.acct-tip {
  font-size: 0.86rem;
  color: #334155;
  border: 1px dashed rgba(245, 158, 11, 0.45);
  border-radius: 14px;
  padding: 12px 14px;
  background: rgba(255, 251, 235, 0.9);
}

.repeat-config {
  display: grid;
  gap: 12px;
  padding-top: 12px;
  border-top: 1px dashed var(--border);
}

.repeat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.repeat-toggle {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 16px;
  padding: 16px 18px;
  border: 1px solid rgba(59, 130, 246, 0.18);
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(239, 246, 255, 0.98), rgba(255, 255, 255, 0.98));
  color: var(--text);
  box-shadow: 0 10px 24px rgba(37, 99, 235, 0.08);
  text-align: left;
}

.repeat-toggle:hover {
  transform: translateY(-1px);
  border-color: rgba(37, 99, 235, 0.34);
  box-shadow: 0 14px 30px rgba(37, 99, 235, 0.12);
}

.repeat-toggle:focus-visible {
  outline: none;
  box-shadow: 0 0 0 5px rgba(37, 99, 235, 0.16), 0 14px 30px rgba(37, 99, 235, 0.14);
}

.repeat-toggle.has-repeats {
  border-color: rgba(37, 99, 235, 0.28);
  background: linear-gradient(135deg, rgba(219, 234, 254, 0.98), rgba(255, 255, 255, 0.98));
}

.repeat-toggle-copy {
  min-width: 0;
  display: grid;
  gap: 6px;
}

.repeat-toggle-eyebrow {
  font-size: 0.73rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--primary);
}

.repeat-toggle-title {
  font-weight: 900;
  font-size: 1rem;
  color: var(--text);
}

.repeat-toggle-hint {
  font-size: 0.9rem;
  line-height: 1.45;
  color: var(--muted);
  max-width: 44ch;
}

.repeat-toggle-side {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  justify-self: end;
}

.repeat-toggle-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(147, 197, 253, 0.8);
  color: #1d4ed8;
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.repeat-toggle-icon {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  background: rgba(37, 99, 235, 0.12);
  border: 1px solid rgba(37, 99, 235, 0.18);
  position: relative;
  transition: transform 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}

.repeat-toggle-icon::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 10px;
  height: 10px;
  border-right: 2px solid var(--primary);
  border-bottom: 2px solid var(--primary);
  transform: translate(-50%, -65%) rotate(45deg);
}

.repeat-toggle[aria-expanded="true"] .repeat-toggle-icon {
  transform: rotate(180deg);
  background: rgba(37, 99, 235, 0.18);
  border-color: rgba(37, 99, 235, 0.3);
}

.repeat-add {
  background: transparent;
  color: var(--primary);
  border: 1px dashed var(--primary);
  padding: 8px 12px;
  border-radius: 10px;
  font-weight: 700;
  cursor: pointer;
}

.repeat-add:hover {
  background: rgba(37, 99, 235, 0.08);
}

.repeat-empty {
  font-size: 13px;
  color: var(--muted);
  border: 1px dashed var(--border);
  border-radius: 12px;
  padding: 12px;
  text-align: center;
  background: #f8fafc;
}

.repeat-list {
  display: grid;
  gap: 12px;
}

.repeat-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
}

.repeat-row .repeat-remove {
  align-self: start;
  background: #ef4444;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 8px 12px;
  font-weight: 700;
  cursor: pointer;
}

.repeat-row .repeat-remove:hover {
  filter: brightness(0.95);
}

.repeat-fields label,
.repeat-until {
  display: block;
  font-weight: 700;
}

.repeat-fields input.repeat-name,
.repeat-until input {
  margin-top: 6px;
}

.repeat-until input {
  max-width: 220px;
}

.repeat-days {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.repeat-days label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 8px;
  background: #fff;
  border: 1px solid var(--border);
  font-weight: 600;
  font-size: 13px;
}

.repeat-days input[type="checkbox"] {
  margin: 0;
}

.repeat-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.repeat-save {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 10px 16px;
  font-weight: 700;
  cursor: pointer;
}

.repeat-save:hover {
  background: var(--primary-600);
}

.family-card {
  margin-top: 0;
  background: rgba(255, 255, 255, 0.92);
}

.family-invite {
  display: grid;
  gap: 12px;
}

.family-invite-grid {
  grid-template-columns: minmax(180px, 1fr) minmax(180px, 1fr) minmax(220px, 1.2fr) auto;
  align-items: end;
}

.family-field {
  display: grid;
  gap: 6px;
  font-size: 0.92rem;
}

.family-field input {
  margin-top: 0;
}

.family-field-email {
  min-width: 0;
}

.family-invite-grid .btn {
  height: 46px;
  align-self: end;
}

.member-list {
  display: grid;
  gap: 10px;
}

.member-item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
}

.member-info {
  display: grid;
  gap: 4px;
  flex: 1;
  min-width: 0;
}

.member-name {
  font-weight: 800;
  font-size: 1rem;
  color: var(--text);
  overflow-wrap: anywhere;
}

.member-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: baseline;
  color: var(--text);
  font-size: 0.92rem;
}

.member-label {
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.member-value {
  font-weight: 600;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.member-email {
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--muted);
  overflow-wrap: anywhere;
  word-break: break-word;
}

.member-empty {
  color: var(--muted);
  font-style: italic;
}

.member-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: fit-content;
  min-height: 28px;
  padding: 4px 10px;
  border-radius: 999px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1d4ed8;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.member-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.member-actions .btn {
  padding: 8px 12px;
  border-radius: 10px;
}

.member-actions .member-hide {
  background: #e2e8f0;
  color: #334155;
  border: 1px solid #cbd5e1;
}

.member-actions .member-hide:hover {
  background: #cbd5e1;
  border-color: #94a3b8;
}

.reauthorize-block {
  margin-top: 0;
  padding-top: 18px;
  border-top: none;
}

.reauthorize-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.reauthorize-actions .btn {
  align-self: start;
}

.acct-save-panel .actions {
  margin-top: 0;
}

.actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-start;
}

.acct-delete-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-top: 24px;
  padding: 20px 22px;
  border-radius: 22px;
  border: 1px solid rgba(239, 68, 68, 0.18);
  background: linear-gradient(135deg, rgba(254, 242, 242, 0.98), rgba(255, 255, 255, 0.98));
}

.acct-delete-footer__copy {
  display: grid;
  gap: 8px;
  max-width: 640px;
}

.acct-delete-footer__copy h2,
.acct-delete-footer__copy p {
  margin: 0;
}

.acct-delete-footer__eyebrow {
  margin: 0;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #b91c1c;
}

.acct-delete-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 168px;
  padding: 12px 16px;
  border-radius: 14px;
  border: 1px solid rgba(239, 68, 68, 0.24);
  background: #fff;
  color: #b91c1c;
  font-weight: 900;
  box-shadow: 0 10px 24px rgba(127, 29, 29, 0.08);
}

.acct-delete-link:hover {
  background: #fef2f2;
  transform: translateY(-1px);
}

.notice {
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid #bae6fd;
  background: #e0f2fe;
  color: #0c4a6e;
  font-weight: 700;
}

.error,
.ok {
  padding: 12px 14px;
  border-radius: 14px;
  display: none;
  margin: 0;
}

.error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #7f1d1d;
}

.ok {
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  color: #065f46;
}

.hint {
  font-size: 12px;
  color: var(--muted);
}

.loading-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 255, 0.8);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}

.spinner {
  width: 50px;
  height: 50px;
  border: 5px solid rgba(2, 6, 23, 0.15);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.acct-toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 10px);
  background: #0f172a;
  color: #f8fafc;
  padding: 12px 16px;
  border-radius: 999px;
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.2);
  font-weight: 700;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 2100;
}

.acct-toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.acct-toast.success { background: #065f46; }
.acct-toast.error { background: #7f1d1d; }

.acct-welcome-overlay,
.acct-tour-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.52);
  z-index: 2200;
}

.acct-welcome-overlay[hidden],
.acct-tour-overlay[hidden] {
  display: none !important;
  pointer-events: none !important;
  visibility: hidden !important;
}

.acct-welcome-overlay {
  display: grid;
  place-items: center;
  padding: 18px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.acct-welcome-card {
  position: relative;
  width: min(680px, 96vw);
  max-height: min(88vh, 820px);
  background: linear-gradient(180deg, #fff 0%, #f8fbff 100%);
  border: 1px solid #dbe7fb;
  border-radius: 24px;
  box-shadow: 0 28px 60px rgba(15, 23, 42, 0.22);
  padding: 28px 52px 28px 28px;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.acct-tour-eyebrow {
  margin: 0 0 8px;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--primary);
}

.acct-welcome-card h2 {
  margin: 0 0 12px;
  font-size: clamp(1.45rem, 2.7vw, 2rem);
  color: var(--text);
}

.acct-welcome-copy {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.acct-welcome-grid {
  display: grid;
  gap: 12px;
  margin: 22px 0 18px;
}

.acct-welcome-step {
  padding: 16px;
  border-radius: 18px;
  background: #fff;
  border: 1px solid #dbe7fb;
  box-shadow: 0 12px 26px rgba(37, 99, 235, 0.08);
}

.acct-welcome-step strong {
  display: block;
  margin-bottom: 6px;
  color: var(--text);
}

.acct-welcome-step p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.acct-welcome-actions,
.acct-tour-card__actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 22px;
}

.acct-welcome-actions button {
  flex: 1 1 180px;
}

.acct-tour-overlay {
  z-index: 2250;
  overflow: hidden;
}

.acct-tour-card {
  position: fixed;
  z-index: 2253;
  width: min(360px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
  background: #fff;
  border-radius: 20px;
  border: 1px solid #dbe7fb;
  box-shadow: 0 28px 60px rgba(15, 23, 42, 0.28);
  padding: 20px 52px 20px 20px;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.acct-popup-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 34px;
  height: 34px;
  border: 1px solid #dbe7fb;
  border-radius: 999px;
  background: #fff;
  color: #475569;
  font-size: 1.25rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease;
}

.acct-popup-close:hover,
.acct-popup-close:focus-visible {
  background: #eff6ff;
  border-color: #93c5fd;
  color: #1d4ed8;
  outline: none;
}

.acct-tour-card__step {
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--primary);
  margin-bottom: 10px;
}

.acct-tour-card h2 {
  margin: 0 0 10px;
  font-size: 1.25rem;
  color: var(--text);
}

.acct-tour-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.acct-tour-card__actions {
  position: sticky;
  bottom: 0;
  padding-top: 16px;
  margin-top: 18px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0), #ffffff 28%);
}

.acct-tour-target {
  position: relative !important;
  z-index: 1 !important;
  box-shadow:
    0 0 0 4px rgba(255, 255, 255, 0.96),
    0 0 0 8px rgba(37, 99, 235, 0.35),
    0 22px 44px rgba(15, 23, 42, 0.22);
  border-radius: 18px;
}

body.acct-tour-open,
body.acct-onboarding-open {
  overflow: hidden;
}

@media (max-width: 820px) {
  .acct-stage__body--two-col {
    grid-template-columns: 1fr;
  }

  .page-head__actions {
    justify-items: start;
  }

  .family-invite-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .family-field-email {
    grid-column: 1 / -1;
  }

  .family-invite-grid .btn {
    justify-self: start;
  }
}

@media (max-width: 720px) {
  .form-wrapper {
    padding: 22px 18px;
    border-radius: 24px;
  }

  .page-head {
    gap: 16px;
  }

  .acct-stage {
    padding: 18px;
    border-radius: 20px;
  }

  .acct-stage__head {
    gap: 12px;
  }

  .acct-stage__index {
    width: 40px;
    height: 40px;
    border-radius: 14px;
  }

  .children-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .child-row-main {
    grid-template-columns: 1fr;
  }

  .child-row-main .remove {
    justify-self: start;
    width: auto;
  }

  .repeat-row {
    grid-template-columns: 1fr;
  }

  .repeat-row .repeat-remove {
    width: 100%;
  }

  .repeat-toggle {
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
    padding: 15px 16px;
  }

  .repeat-toggle-side {
    width: 100%;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px;
    justify-items: start;
  }

  .auto-sync-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .acct-welcome-overlay,
  .acct-tour-overlay {
    padding-top: max(12px, env(safe-area-inset-top));
    padding-right: max(12px, env(safe-area-inset-right));
    padding-bottom: max(12px, env(safe-area-inset-bottom));
    padding-left: max(12px, env(safe-area-inset-left));
  }

  .acct-welcome-card {
    width: min(100%, 620px);
    max-height: calc(100dvh - 24px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    padding: 22px 18px calc(22px + env(safe-area-inset-bottom));
    border-radius: 20px;
  }

  .acct-tour-card {
    width: min(100%, calc(100vw - 24px));
    max-height: calc(100dvh - 24px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    padding: 18px 18px calc(18px + env(safe-area-inset-bottom));
    border-radius: 18px;
  }

  .acct-popup-close {
    top: 10px;
    right: 10px;
    width: 40px;
    height: 40px;
  }

  .acct-tour-card__actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .acct-tour-card__actions #acctTourNext {
    grid-column: 1 / -1;
  }

  .acct-tour-card__actions button {
    width: 100%;
  }
}

@media (max-width: 560px) {
  .actions-right {
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .page-head__actions {
    width: 100%;
    justify-items: stretch;
  }

  .reauthorize-actions,
  .actions {
    flex-direction: column;
    align-items: stretch;
  }

  .reauthorize-actions .btn,
  .actions .btn {
    width: 100%;
  }

  .family-invite-grid {
    grid-template-columns: 1fr;
  }

  .family-field-email {
    grid-column: auto;
  }

  .family-invite-grid .btn {
    width: 100%;
  }

  .acct-delete-footer {
    flex-direction: column;
    align-items: stretch;
  }

  .acct-delete-link {
    width: 100%;
  }
}

@media (max-width: 420px) {
  .container {
    padding: 0 14px;
  }

  .page-head h1 {
    font-size: 1.75rem;
  }
}
