:root {
  --maroon: #680404;
  --dialog-maroon: #630902;
  --green: #4caf50;
  --dark-green: #1b5e20;
  --red: #f44336;
  --deep-orange: #ff5722;
  --light-green: #8bc34a;
  --yellow-100: #fff9c4;
  --dialog-yellow: #fafabb;
  --primary: #6750a4;
  --text: #1d1b20;
  --muted: #49454f;
  --line: #79747e;
  --grey-200: #eeeeee;
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: #ffffff;
  color: var(--text);
  font-family: Roboto, "Noto Sans", "Noto Sans Tamil", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 16px;
}

body.modal-open { overflow: hidden; }

[hidden] { display: none !important; }

.view {
  max-width: 640px;
  margin: 0 auto;
  padding: 16px;
}

.centered { text-align: center; }

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 24px;
  border: 0;
  border-radius: 20px;
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.1px;
  text-decoration: none;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 1px 3px 1px rgba(0, 0, 0, 0.15);
}

.btn:disabled {
  background: rgba(29, 27, 32, 0.12);
  color: rgba(29, 27, 32, 0.38);
  box-shadow: none;
  cursor: default;
}

.btn:focus-visible, .choice:focus-visible, .icon-button:focus-visible, .map-button:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.btn-green { background: var(--green); color: #fff; }
.btn-red { background: var(--red); color: #fff; }
.btn-dark-green { background: var(--dark-green); color: #fff; font-size: 16px; font-weight: 700; }
.btn-tonal { background: #f7f2fa; color: var(--primary); }
.btn-pill { padding: 0 34px; }

/* ---------- Welcome ---------- */

.header-image {
  display: block;
  max-width: 100%;
  margin: 0 auto;
  padding: 5px;
}

.panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 20px;
}

.welcome-title {
  margin: 20px 0;
  font-size: 20px;
  font-weight: 700;
  text-align: center;
  line-height: 1.3;
}

.phone-entry {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

.phone-field {
  display: flex;
  align-items: center;
  width: 270px;
  max-width: 100%;
  border-bottom: 1px solid var(--line);
  font-size: 25px;
}

.phone-field:focus-within { border-bottom: 2px solid var(--primary); }

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

.phone-field input {
  border: 0;
  outline: none;
  background: transparent;
  font: inherit;
  padding: 8px 0;
  min-width: 0;
}

.phone-country {
  width: 2.4em;
  margin-right: 10px;
  color: var(--muted);
}

.phone-number { flex: 1; letter-spacing: 0.5px; }

.phone-meta {
  display: flex;
  justify-content: space-between;
  width: 270px;
  max-width: 100%;
  min-height: 20px;
  margin: 4px 0 12px;
  font-size: 12px;
}

.phone-meta .counter { margin-left: auto; color: var(--muted); }

.success-message {
  margin: 0;
  color: var(--green);
  font-size: 18px;
  font-weight: 700;
  text-align: center;
  white-space: pre-line;
}

/* ---------- Notice ---------- */

.notice {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-align: center;
}

.notice hr { width: 100%; border: 0; border-top: 1px solid #cac4d0; }

.notice-title {
  margin: 0;
  color: var(--red);
  font-size: 30px;
  font-weight: 700;
}

.notice-text {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  white-space: pre-line;
}

.notice .btn { margin-top: 10px; }

/* ---------- Form ---------- */

.form-title {
  margin: 0 0 10px;
  color: var(--maroon);
  font-size: 20px;
  font-weight: 700;
  text-align: center;
}

.field {
  position: relative;
  display: flex;
  flex-direction: column;
  margin-top: 10px;
  padding-top: 16px; /* room for the floated label, so nothing moves when it floats */
  border-radius: 4px;
  transition: outline-color 0.2s;
}

/*
 * Floating labels, like Flutter's InputDecoration.labelText: the label sits inside an
 * empty field as its prompt, and floats above once the field is focused or has a value.
 */
.field label {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 16px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
  transition: top 0.15s ease, font-size 0.15s ease, line-height 0.15s ease, color 0.15s ease;
}

.field:has(select) label { right: 24px; }

.field:has(input:placeholder-shown):not(:focus-within) label,
.field:has(select option[value=""]:checked):not(:focus-within) label {
  top: 25px;
  font-size: 16px;
  line-height: 20px;
}

/* A hint (placeholder) only shows once the label has floated out of its way */
.field input::placeholder { color: transparent; }
.field input:focus::placeholder { color: var(--muted); }

@media (prefers-reduced-motion: reduce) {
  .field label { transition: none; }
}

.field input,
.field select {
  width: 100%;
  min-height: 40px;
  padding: 6px 0;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  outline: none;
}

.field select {
  appearance: none;
  padding-right: 24px;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
                    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 12px) 55%, calc(100% - 7px) 55%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  text-overflow: ellipsis;
}

.field input:focus,
.field select:focus {
  border-bottom: 2px solid var(--primary);
  padding-bottom: 5px;
}

.field input:disabled,
.field select:disabled {
  color: rgba(29, 27, 32, 0.38);
  border-bottom-style: dotted;
  opacity: 1;
}

.field:focus-within label { color: var(--primary); }

.field.has-error label { color: #b3261e; }
.field.has-error input,
.field.has-error select { border-bottom-color: #b3261e; }

.error-text {
  margin-top: 4px;
  color: #b3261e;
  font-size: 12px;
}

/* Covers a dependent dropdown until its parent is chosen, so a tap explains why */
.lock {
  display: none;
  position: absolute;
  inset: 0;
  cursor: not-allowed;
}

.field.locked .lock { display: block; }

.flash {
  outline: 2px solid var(--deep-orange);
  outline-offset: 2px;
}

/* Top-aligned, so one field showing an error line does not push its neighbour's control out of line */
.row {
  display: flex;
  align-items: flex-start;
  gap: 16px;
}

/* The map button carries no label, so it lines up with the bottom of the coordinate inputs */
.gps-row { align-items: flex-end; }

.row > .field { flex: 1; min-width: 0; }

.map-button {
  flex: none;
  width: 56px;
  height: 45px;
  margin-bottom: 2px;
  padding: 8px;
  border: 0;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 1px 3px 1px rgba(0, 0, 0, 0.15);
  cursor: pointer;
}

.map-button img { display: block; max-width: 100%; max-height: 100%; margin: 0 auto; }

.auto-hint {
  margin-top: 4px;
  color: var(--green);
  font-size: 12px;
}

.combo { position: relative; }
.combo input { padding-right: 24px; }

.combo-arrow {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}

.suggestions {
  max-height: 200px;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  list-style: none;
  border: 1px solid #9e9e9e;
  border-radius: 4px;
}

.suggestions button {
  display: block;
  width: 100%;
  padding: 10px 16px;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  text-align: left;
  cursor: pointer;
}

.suggestions button:hover,
.suggestions button:focus-visible { background: #f3edf7; outline: none; }

.leader-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 30px;
}

.leader-label { flex: 1; font-size: 16px; font-weight: 500; }

.choice {
  min-height: 40px;
  padding: 0 20px;
  border: 1px solid #9e9e9e;
  border-radius: 20px;
  background: var(--grey-200);
  color: rgba(0, 0, 0, 0.54);
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}

.choice-yes.selected { background: var(--green); border-color: var(--green); color: #fff; }
.choice-no.selected { background: var(--red); border-color: var(--red); color: #fff; }
.choice.selected { box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3); }

.actions {
  display: flex;
  gap: 10px;
  margin: 25px 0 16px;
}

.actions .btn { flex: 1; }

/* ---------- Spinner ---------- */

.spinner {
  width: 40px;
  height: 40px;
  margin: 0 auto;
  border: 4px solid rgba(103, 80, 164, 0.2);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

.spinner-green {
  border-width: 5px;
  border-color: rgba(76, 175, 80, 0.25);
  border-top-color: var(--green);
}

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

@media (prefers-reduced-motion: reduce) {
  .spinner { animation-duration: 2.5s; }
}

/* ---------- Overlays ---------- */

.backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.54);
}

.progress { background: rgba(0, 0, 0, 0.5); z-index: 50; }

.progress-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.progress-message {
  max-width: 320px;
  padding: 10px;
  border-radius: 8px;
  background: var(--yellow-100);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.26);
  color: #000;
  font-size: 15px;
  text-align: center;
}

.dialog {
  width: 100%;
  max-width: 400px;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  padding: 24px;
  border-radius: 15px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.dialog h2 { margin: 0 0 16px; font-size: 24px; font-weight: 700; }
.dialog p { margin: 0; white-space: pre-line; overflow-wrap: anywhere; }

.dialog-custom { background: var(--dialog-yellow); }
.dialog-custom h2 { color: var(--dialog-maroon); }
.dialog-custom p { padding: 8px; font-size: 16px; text-align: center; }

.dialog-popup { background: #fdf8fd; border-radius: 28px; }
.dialog-popup h2 { color: var(--red); }
.dialog-popup p { color: var(--muted); font-size: 14px; line-height: 20px; }

.dialog-buttons {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 24px;
}

.dialog-button {
  min-height: 40px;
  padding: 0 12px;
  border: 0;
  border-radius: 20px;
  background: transparent;
  color: var(--primary);
  font: inherit;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
}

.dialog-button:hover, .dialog-button:focus-visible { background: rgba(103, 80, 164, 0.1); outline: none; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 32px;
  z-index: 60;
  max-width: calc(100% - 32px);
  padding: 10px 20px;
  border-radius: 20px;
  background: #323232;
  color: #fff;
  font-size: 14px;
  text-align: center;
  transform: translateX(-50%);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3);
}

.toast-red { background: var(--red); }
.toast-orange { background: var(--deep-orange); }

/* ---------- Map picker ---------- */

.map-modal {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  padding-bottom: 10px;
  background: #fff;
}

.map-appbar {
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: 64px;
  padding: 0 4px;
}

.map-appbar h2 {
  flex: 1;
  margin: 0 0 0 8px;
  font-size: 22px;
  font-weight: 400;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.icon-button {
  width: 48px;
  height: 48px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--text);
  font-size: 24px;
  cursor: pointer;
}

.icon-button:hover { background: rgba(0, 0, 0, 0.06); }

.map-hint {
  margin: 0 2px;
  padding: 2px;
  background: var(--yellow-100);
  font-size: 14px;
  text-align: center;
}

.map-hint .pin { color: var(--red); }

.map-area {
  position: relative;
  flex: 1;
  margin: 10px 2px;
  box-shadow: 0 3px 7px 2px rgba(158, 158, 158, 0.5);
}

.map-canvas { position: absolute; inset: 0; }

.map-status {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: #fff;
  text-align: center;
}

.map-coords {
  margin: 0 2px;
  padding: 2px;
  background: var(--light-green);
  font-size: 14px;
  text-align: center;
  overflow-wrap: anywhere;
}

.map-actions {
  display: flex;
  justify-content: space-evenly;
  margin-top: 10px;
}

@media (max-width: 400px) {
  .row { gap: 10px; }
  .map-appbar h2 { font-size: 18px; }
  .leader-label { font-size: 15px; }
  .choice { padding: 0 16px; }
}
