:root {
  --maroon: #7a1224;
  --maroon-dark: #5a0d1a;
  --gold: #d4a418;
  --gold-light: #f4e4b0;
  --cream: #fdf8ee;
  --ink: #2b2320;
  --muted: #7a6f63;
  --border: #e6d9b8;
  --danger: #b3261e;
  --danger-bg: #fdecea;
  --success: #1e7a34;
  --radius: 10px;
  --control-h: 40px;
}

* { box-sizing: border-box; }

/* The form toggles visibility via the `hidden` attribute. Class rules that set
   `display` (.modal-overlay, .field, .badge) outrank the UA stylesheet's
   [hidden] rule, so state it explicitly here. */
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: "Segoe UI", "Noto Sans Gujarati", Tahoma, sans-serif;
  background: var(--cream);
  color: var(--ink);
}

.site-header {
  background: linear-gradient(135deg, var(--maroon), var(--maroon-dark));
  color: #fff;
  padding: 18px 16px;
  border-bottom: 5px solid var(--gold);
}
.header-inner {
  max-width: 960px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 18px;
}
.logo {
  width: 68px;
  height: 68px;
  object-fit: contain;
  background: #fff;
  border-radius: 50%;
  padding: 4px;
  flex-shrink: 0;
}
.titles h1 {
  margin: 0;
  font-size: 1.3rem;
  line-height: 1.3;
}
.titles h1.en {
  font-size: 1.05rem;
  font-weight: 600;
  opacity: 0.95;
}
.subtitle {
  margin: 4px 0 0;
  font-size: 0.9rem;
  color: var(--gold-light);
}

.page {
  max-width: 960px;
  margin: 24px auto 60px;
  padding: 0 16px;
}

.card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  margin-bottom: 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.card h2 {
  margin: 0 0 16px;
  font-size: 1.1rem;
  color: var(--maroon-dark);
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 2px solid var(--gold-light);
  padding-bottom: 10px;
}
.card h2 .num {
  background: var(--maroon);
  color: #fff;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
}
.card h2 .gu {
  font-weight: 400;
  font-size: 0.85rem;
  color: var(--muted);
}

.grid {
  display: grid;
  gap: 14px;
  margin-bottom: 14px;
}
.grid-2 { grid-template-columns: 1fr 1fr; }
@media (max-width: 720px) {
  .grid-2 { grid-template-columns: 1fr; }
}

.field { display: flex; flex-direction: column; gap: 5px; }
.field label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink);
}
.field label .gu { font-weight: 400; color: var(--muted); }
.field label small { font-weight: 400; color: var(--muted); }
.req { color: var(--danger); }

/* Date of birth: a text box we format as dd/mm/yyyy, with the native date
   input parked invisibly behind the calendar button purely to supply the
   picker. It must stay laid out rather than display:none, or showPicker()
   has nothing to anchor to. */
.date-field { position: relative; display: block; }
.date-field #dobText { padding-right: 40px; }
.date-picker-btn {
  position: absolute;
  right: 1px;
  top: 1px;
  bottom: 1px;
  width: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  border-left: 1px solid var(--border);
  color: var(--muted);
  cursor: pointer;
  border-radius: 0 6px 6px 0;
}
.date-picker-btn:hover { color: var(--maroon); background: var(--gold-light); }
/* The calendar popup. */
.datepicker {
  position: absolute;
  z-index: 40;
  top: calc(100% + 6px);
  left: 0;
  width: 280px;
  max-width: 100%;
  padding: 10px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.14);
}
.datepicker-head {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-bottom: 8px;
}
/* Month and year are the point of this picker, so they get the width. */
.datepicker-head select {
  height: 32px;
  padding: 0 4px;
  font-size: 0.85rem;
  flex: 1 1 auto;
  min-width: 0;
}
.dp-nav {
  flex: 0 0 26px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  color: var(--maroon);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
}
.dp-nav:hover:not(:disabled) { background: var(--gold-light); }
.dp-nav:disabled { opacity: 0.35; cursor: not-allowed; }

.datepicker-weekdays, .datepicker-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}
.datepicker-weekdays {
  margin-bottom: 4px;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--muted);
  text-align: center;
}
.dp-day {
  height: 32px;
  border: none;
  border-radius: 6px;
  background: none;
  font-size: 0.85rem;
  color: var(--ink);
  cursor: pointer;
}
.dp-day:hover:not(:disabled) { background: var(--gold-light); }
.dp-day:disabled { color: #cfc8bd; cursor: not-allowed; }
.dp-day.is-selected { background: var(--maroon); color: #fff; font-weight: 700; }

/* Age derived from the date of birth. Sits in the label, so it must not
   inherit the label's bold weight. */
.age-pill {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 20px;
  background: var(--gold-light);
  color: var(--maroon);
  font-size: 0.76rem;
  font-weight: 600;
}

/* One rule for every control on the form. Listing types individually meant a
   new input type (email, when that section was added) silently fell back to
   browser defaults and rendered a different size from its neighbours, so match
   on "not a radio or checkbox" instead. The fixed height is what keeps a
   select, a text box and a file picker the same size side by side -- their
   intrinsic heights all differ. */
input:not([type="radio"]):not([type="checkbox"]), select, textarea {
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.95rem;
  line-height: 1.25;
  font-family: inherit;
  background: #fff;
  color: var(--ink);
  width: 100%;
  height: var(--control-h);
}
/* The native "Choose file" button needs a little more room than text does. */
input[type="file"] { padding: 7px 10px; }
input:focus, select:focus {
  outline: none;
  border-color: var(--maroon);
  box-shadow: 0 0 0 3px rgba(122,18,36,0.12);
}
input.reveal { margin-top: 6px; }

/* A field the applicant must change before the form will submit. */
input.has-error, input.has-error:focus {
  border-color: var(--danger);
  background: var(--danger-bg);
}

/* An input with a button beside it, e.g. email + "Send code". */
.inline-row { display: flex; gap: 8px; align-items: stretch; }
.inline-row input { flex: 1 1 auto; min-width: 0; }
.inline-row button { flex: 0 0 auto; white-space: nowrap; height: var(--control-h); padding-top: 0; padding-bottom: 0; }

/* Confirmation that the address has been verified. */
.verified-badge {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-top: 12px;
  padding: 9px 13px;
  background: #e4f3e8;
  border: 1px solid var(--success);
  border-radius: 6px;
  font-size: 0.9rem;
}
.verified-badge .tick {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--success);
  color: #fff;
  font-size: 0.78rem;
  flex: 0 0 auto;
}
.verified-badge strong { color: var(--success); }
.verified-badge .link-btn { margin-left: auto; }

/* An instruction that applies to a whole section, sitting under its heading. */
.section-note {
  margin: -4px 0 16px;
  padding: 9px 12px;
  background: var(--gold-light);
  border-left: 3px solid var(--gold);
  border-radius: 5px;
  font-size: 0.86rem;
  line-height: 1.45;
  color: var(--ink);
}
.section-note strong { color: var(--maroon); }
.section-note .gu { display: block; margin-top: 2px; color: var(--muted); }

/* Inline status under a field, e.g. the PIN code lookup result. */
.field-hint {
  margin-top: 4px;
  font-size: 0.78rem;
  line-height: 1.3;
  color: var(--muted);
}
.field-hint.ok { color: var(--success); }
.field-hint.warn { color: var(--danger); }

.badge {
  display: inline-block;
  margin-top: 4px;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  width: fit-content;
}
.badge.western { background: #e4f3e8; color: var(--success); }
.badge.other { background: #f1eee9; color: var(--muted); }

.radio-row { display: flex; flex-wrap: wrap; gap: 10px; }
.radio-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 0.9rem;
  cursor: pointer;
  background: #fdfcf8;
}
.radio-pill input { margin: 0; }
.radio-pill:has(input:checked) {
  border-color: var(--maroon);
  background: var(--gold-light);
}

table#subjectsTable {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 10px;
}
table#subjectsTable th {
  text-align: left;
  font-size: 0.8rem;
  color: var(--muted);
  padding: 6px 6px;
  border-bottom: 1px solid var(--border);
}
table#subjectsTable td {
  padding: 6px 6px;
  vertical-align: top;
}
.col-marks { width: 110px; }
.col-action { width: 40px; }
.remove-row-btn {
  background: none;
  border: none;
  color: var(--danger);
  font-size: 1.1rem;
  cursor: pointer;
  line-height: 1;
  padding: 6px;
}

.btn-secondary, .btn-primary {
  min-height: var(--control-h);
  padding: 0 18px;
  border-radius: 6px;
  font-size: 0.95rem;
  cursor: pointer;
  border: none;
  font-weight: 600;
}
.btn-secondary {
  background: #fff;
  border: 1px solid var(--maroon);
  color: var(--maroon);
}
.btn-secondary:hover { background: var(--gold-light); }
.btn-primary {
  background: var(--maroon);
  color: #fff;
}
.btn-primary:hover { background: var(--maroon-dark); }
.btn-primary:disabled, .btn-secondary:disabled { opacity: 0.6; cursor: not-allowed; }

.file-hint { font-size: 0.78rem; color: var(--muted); }
.file-hint.error { color: var(--danger); }

.submit-row {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
}
.form-error {
  align-self: stretch;
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid var(--danger);
  border-radius: 6px;
  padding: 10px 14px;
  font-size: 0.9rem;
}

.site-footer {
  text-align: center;
  color: var(--muted);
  font-size: 0.8rem;
  padding: 20px 0 40px;
}
.footer-contact {
  margin: 0 auto 6px;
  padding: 9px 14px;
  max-width: 960px;
  background: var(--cream);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.86rem;
  color: var(--ink);
  line-height: 1.5;
}
.footer-contact a { color: var(--maroon); font-weight: 600; }
/* Outside .footer-contact, so it would otherwise fall back to the browser's
   default blue and be the one link on the page that looks unstyled. */
a.footer-site { color: var(--maroon); font-weight: 600; }
/* Never let the rule sit alone at the start of a wrapped line. */
.footer-sep { margin: 0 6px; opacity: 0.5; }
.footer-contact .gu { display: block; color: var(--muted); }
.footer-contact p { margin: 0; }
.footer-or { margin-top: 8px !important; font-weight: 600; color: var(--maroon); }

/* WhatsApp's own green, so the glyph is recognisable at 15px where the shape
   alone is not. A flex item of the list, so it stays at the head of the first
   line when the contacts wrap. */
.wa-icon { color: #25D366; flex: 0 0 auto; margin-right: 5px; align-self: center; }

/* A label rather than a list entry, so it is not pipe-separated like the
   contacts are -- a wider gap does that job instead. */
.wa-label {
  flex: 0 0 auto;
  font-weight: 700;
  color: var(--maroon);
  margin-right: 8px;
}

/* The WhatsApp contacts: all three on one line, pipe separated. Each entry is
   kept whole with nowrap so a name never splits from its number; the row wraps
   between entries once the viewport is too narrow to hold all three. */
.contact-list {
  list-style: none;
  margin: 5px 0 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: baseline;
  gap: 2px 0;
  /* Sized to fit the label, the glyph and all three contacts on one line
     at the footer's 960px. Measured, not guessed: at 0.78rem the row was
     977px against 930px of space and wrapped on every desktop width. */
  font-size: 0.72rem;
}
.contact-list li { white-space: nowrap; }
.contact-list li + li::before {
  content: "|";
  color: var(--border);
  margin: 0 6px;
}
.contact-list a { display: inline-block; padding: 3px 0; }
.contact-place { color: var(--muted); }
.contact-number { color: var(--maroon); font-weight: 600; }

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(43,35,32,0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
}
.modal {
  background: #fff;
  border-radius: var(--radius);
  max-width: 560px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  padding: 22px 24px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.25);
}
.modal h3 {
  margin: 0 0 8px;
  color: var(--maroon-dark);
}
.modal-note { color: var(--muted); font-size: 0.88rem; margin-bottom: 14px; }
/* The Gujarati half of a modal message sits directly under the English. */
.modal-note.gu { margin-top: -8px; }
.confirm-summary dl {
  display: grid;
  grid-template-columns: 40% 60%;
  gap: 6px 10px;
  font-size: 0.88rem;
  margin: 0 0 16px;
}
.confirm-summary dt { color: var(--muted); }
.confirm-summary dd { margin: 0; font-weight: 600; }
.confirm-summary h4 {
  margin: 14px 0 6px;
  font-size: 0.85rem;
  color: var(--maroon-dark);
  border-bottom: 1px solid var(--border);
  padding-bottom: 4px;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 10px;
}
.loading-box { text-align: center; max-width: 280px; }
.spinner {
  width: 36px;
  height: 36px;
  border: 4px solid var(--gold-light);
  border-top-color: var(--maroon);
  border-radius: 50%;
  margin: 0 auto 12px;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.result-success h3 { color: var(--success); }
.result-error h3 { color: var(--danger); }

/* A field filled from the PIN code and locked to keep City, State and Area
   consistent with each other. Greyed but still legible -- the applicant needs
   to be able to read what was filled in on their behalf. */
.locked-field {
  background: #f4f1ea;
  color: var(--ink);
  cursor: not-allowed;
  opacity: 1;               /* Safari dims disabled controls to the point of illegibility */
  -webkit-text-fill-color: var(--ink);
}
#addressUnlock { align-self: end; margin-bottom: 6px; font-size: 0.82rem; }


/* Totals row in the subject table footer -- each box sits under the column it
   totals, so the figures line up with the per-subject values above them. */
.totals-foot td { border-top: 2px solid var(--border); padding: 10px 6px; vertical-align: middle; }
.totals-foot-label { text-align: right; padding-right: 12px !important; }
.totals-foot-title { display: block; font-weight: 700; font-size: 0.9rem; color: var(--maroon); }
.totals-foot-label small { display: block; font-size: 0.76rem; font-weight: 600; color: var(--maroon); }
.totals-foot-label small .gu { font-weight: 400; color: var(--muted); }
.totals-foot input { background: var(--gold-light); font-weight: 600; }
.totals-foot strong { font-size: 1.05rem; color: var(--maroon); }
@media (max-width: 720px) {
  .totals-foot-label { text-align: left; }
}

/* The add-subject control sits in its own footer row so it stays above the
   totals while the totals remain inside the table, which is what keeps them
   aligned under their columns. */
.add-subject-row td { padding: 10px 6px 4px; border: none; }

/* Explains why the overall boxes are empty, rather than leaving them
   looking like something failed to fill in. */
.grade-note-row td {
  padding: 6px;
  border: none;
  font-size: 0.78rem;
  color: var(--muted);
  text-align: right;
}
.grade-note-row .gu { color: var(--muted); }
