:root {
  --bg: var(--tg-theme-bg-color, #f2f4ef);
  --surface: var(--tg-theme-secondary-bg-color, #ffffff);
  --text: var(--tg-theme-text-color, #172019);
  --muted: var(--tg-theme-subtitle-text-color, #69736b);
  --accent: var(--tg-theme-button-color, #16794d);
  --accent-text: var(--tg-theme-button-text-color, #ffffff);
  --line: color-mix(in srgb, var(--text) 11%, transparent);
  --shadow: 0 10px 30px rgb(21 43 30 / 8%);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 92% 0%, rgb(54 167 108 / 16%), transparent 34%),
    var(--bg);
  min-height: 100vh;
}

button, input { font: inherit; }

.shell {
  width: min(100%, 620px);
  margin: 0 auto;
  padding: max(22px, env(safe-area-inset-top)) 16px calc(28px + env(safe-area-inset-bottom));
}

.hero { padding: 8px 5px 22px; }

.eyebrow {
  display: block;
  margin-bottom: 9px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .13em;
}

h1, h2, p { margin: 0; }

h1 {
  font-size: clamp(29px, 8vw, 40px);
  line-height: 1.05;
  letter-spacing: -.035em;
}

.hero p {
  max-width: 480px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.45;
}

.form { display: grid; gap: 12px; }

.card {
  padding: 17px;
  border: 1px solid var(--line);
  border-radius: 19px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.section-heading {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 15px;
}

.section-heading.no-margin { margin: 0; }

.section-icon {
  display: grid;
  flex: 0 0 38px;
  height: 38px;
  place-items: center;
  border-radius: 12px;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  font-size: 18px;
  font-weight: 800;
}

h2 { font-size: 16px; line-height: 1.2; }

.section-heading p {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.choice-grid { display: grid; gap: 8px; }
.choice-grid.two { grid-template-columns: repeat(2, 1fr); }
.choice-grid.four { grid-template-columns: repeat(4, 1fr); }
.choice-grid.five { grid-template-columns: repeat(5, 1fr); }

.choice {
  min-height: 42px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--text);
  background: transparent;
  cursor: pointer;
  font-size: 14px;
  font-weight: 650;
  transition: transform .12s ease, color .12s ease, background .12s ease;
}

.choice:active { transform: scale(.97); }

.choice.selected {
  border-color: var(--accent);
  color: var(--accent-text);
  background: var(--accent);
  box-shadow: 0 5px 14px color-mix(in srgb, var(--accent) 24%, transparent);
}

.choice.selected::after { content: "  ✓"; font-weight: 900; }

.conditional.hidden { display: none; }

.selection-note {
  margin-top: 12px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 750;
}

#districts-section { scroll-margin-top: 12px; }

.choice-grid.compact { margin-top: 9px; }
.choice-grid.compact .choice { min-height: 35px; padding: 5px; font-size: 12px; }
.currency-grid { margin-bottom: 10px; }

.money-field {
  display: flex;
  align-items: center;
  height: 54px;
  padding: 0 15px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: color-mix(in srgb, var(--bg) 70%, transparent);
}

.money-field span { color: var(--accent); font-size: 22px; font-weight: 800; }

.money-field input {
  width: 100%;
  border: 0;
  outline: 0;
  padding-left: 8px;
  color: var(--text);
  background: transparent;
  font-size: 22px;
  font-weight: 750;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-top: 13px;
  color: var(--muted);
  font-size: 13px;
}

.check-row input { width: 18px; height: 18px; accent-color: var(--accent); }

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

.switch { position: relative; flex: 0 0 51px; height: 31px; }
.switch input { position: absolute; opacity: 0; }

.switch-track {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: color-mix(in srgb, var(--text) 18%, transparent);
  transition: background .18s ease;
}

.switch-track span {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 25px;
  height: 25px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 7px rgb(0 0 0 / 20%);
  transition: transform .18s ease;
}

.switch input:checked + .switch-track { background: var(--accent); }
.switch input:checked + .switch-track span { transform: translateX(20px); }

.save-button {
  position: sticky;
  bottom: max(12px, env(safe-area-inset-bottom));
  width: 100%;
  min-height: 55px;
  border: 0;
  border-radius: 16px;
  color: var(--accent-text);
  background: var(--accent);
  box-shadow: 0 12px 25px color-mix(in srgb, var(--accent) 30%, transparent);
  cursor: pointer;
  font-size: 16px;
  font-weight: 800;
}

.save-button:disabled { cursor: wait; opacity: .65; }

.message {
  display: none;
  padding: 12px 14px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.4;
}

.message.visible { display: block; }
.message.error { color: #9a2f2f; background: #ffe9e7; }
.message.success { color: #13653f; background: #ddf5e8; }

.loading {
  position: fixed;
  inset: 0;
  z-index: 5;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 12px;
  color: var(--muted);
  background: var(--bg);
  transition: opacity .2s ease, visibility .2s ease;
}

.loading.hidden { visibility: hidden; opacity: 0; }

.loading span {
  width: 34px;
  height: 34px;
  border: 3px solid color-mix(in srgb, var(--accent) 20%, transparent);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

.loading p { font-size: 13px; }

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

@media (max-width: 390px) {
  .choice-grid.five { grid-template-columns: repeat(3, 1fr); }
  .choice-grid.four { grid-template-columns: repeat(2, 1fr); }
}
