:root {
  --blue-900: #1a2540;
  --blue-800: #243352;
  --blue-700: #3a6bb8;
  --blue-600: #4a81d4;
  --blue-100: #eef4fc;
  --blue-50: #f5f9ff;
  --bg: #f4f7fb;
  --surface: #ffffff;
  --text: #1a2540;
  --text-muted: #647089;
  --border: #dce4ef;
  --error: #d14343;
  --error-bg: #fef2f2;
  --success: #2e7d5e;
  --success-bg: #edf7f2;
  --radius: 8px;
  --radius-lg: 12px;
  --input-h: 40px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.45;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

/* Header */
.site-header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 1rem;
  padding-top: max(0.5rem, env(safe-area-inset-top));
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  text-decoration: none;
}

.brand-logo {
  height: 34px;
  width: auto;
  display: block;
}

.year-badge {
  background: var(--blue-600);
  color: white;
  font-weight: 600;
  font-size: 11px;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

/* Main */
.container {
  flex: 1;
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: 0.75rem 0.75rem 0.5rem;
  padding-bottom: max(0.5rem, env(safe-area-inset-bottom));
}

.form-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.form-card-header {
  padding: 0.75rem 1rem 0.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--blue-50);
}

.form-card-header h1 {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--blue-900);
  letter-spacing: -0.02em;
  margin-bottom: 0.2rem;
}

.form-intro {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
}

/* Form */
.registration-form {
  padding: 0.75rem 1rem 0.85rem;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.55rem 0.65rem;
}

.form-group {
  min-width: 0;
}

.form-group.span-2 {
  grid-column: span 2;
}

label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.2rem;
  line-height: 1.3;
}

.hint {
  font-weight: 500;
  color: var(--text-muted);
  font-size: 11px;
}

input,
textarea {
  width: 100%;
  padding: 0 0.65rem;
  font-family: inherit;
  font-size: 16px;
  font-weight: 500;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
}

input {
  height: var(--input-h);
}

textarea {
  padding: 0.45rem 0.65rem;
  resize: none;
  min-height: 56px;
  line-height: 1.35;
}

input::placeholder,
textarea::placeholder {
  color: #a0aec0;
  font-weight: 400;
}

input:focus,
textarea:focus {
  outline: none;
  border-color: var(--blue-600);
  box-shadow: 0 0 0 2px rgba(74, 129, 212, 0.18);
}

input.invalid,
textarea.invalid {
  border-color: var(--error);
  background: var(--error-bg);
}

.input-with-prefix {
  display: flex;
  align-items: stretch;
}

.prefix {
  display: flex;
  align-items: center;
  padding: 0 0.55rem;
  background: var(--blue-100);
  border: 1px solid var(--border);
  border-right: none;
  border-radius: var(--radius) 0 0 var(--radius);
  font-size: 13px;
  font-weight: 600;
  color: var(--blue-800);
  flex-shrink: 0;
}

.input-with-prefix input {
  border-radius: 0 var(--radius) var(--radius) 0;
}

.field-error {
  display: block;
  font-size: 11px;
  color: var(--error);
  margin-top: 0.15rem;
  min-height: 0;
  line-height: 1.2;
}

.field-error:empty {
  display: none;
}

/* Alert */
.form-alert {
  padding: 0.5rem 0.65rem;
  border-radius: var(--radius);
  font-size: 12px;
  margin-top: 0.55rem;
  line-height: 1.35;
}

.form-alert.error {
  background: var(--error-bg);
  color: var(--error);
  border: 1px solid rgba(209, 67, 67, 0.2);
}

.form-alert.success {
  background: var(--success-bg);
  color: var(--success);
  border: 1px solid rgba(46, 125, 94, 0.2);
}

/* Submit */
.submit-btn {
  width: 100%;
  margin-top: 0.65rem;
  height: 42px;
  padding: 0 1rem;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  color: white;
  background: var(--blue-600);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  transition: background 0.15s, opacity 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.submit-btn:hover:not(:disabled) {
  background: var(--blue-700);
}

.submit-btn:active:not(:disabled) {
  background: var(--blue-800);
}

.submit-btn:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.btn-loader {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

.form-footer-note {
  text-align: center;
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 0.45rem;
  line-height: 1.35;
}

/* Success */
.success-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem 1rem;
  text-align: center;
}

.success-icon {
  width: 48px;
  height: 48px;
  background: var(--success-bg);
  color: var(--success);
  font-size: 1.4rem;
  font-weight: 700;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 0.75rem;
  border: 2px solid var(--blue-600);
}

.success-panel h2 {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--blue-900);
  margin-bottom: 0.4rem;
}

.success-panel p {
  color: var(--text-muted);
  font-size: 13px;
  max-width: 360px;
  margin: 0 auto 0.5rem;
  line-height: 1.4;
}

.success-ref {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 0.85rem !important;
}

.success-ref strong {
  color: var(--blue-800);
  font-family: ui-monospace, monospace;
  font-size: 13px;
}

.secondary-btn {
  height: 38px;
  padding: 0 1rem;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--blue-800);
  background: var(--blue-100);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
}

.secondary-btn:hover {
  background: var(--border);
}

/* Footer */
.site-footer {
  flex-shrink: 0;
  text-align: center;
  padding: 0.4rem 0.75rem;
  padding-bottom: max(0.4rem, env(safe-area-inset-bottom));
  color: var(--text-muted);
  font-size: 10px;
}

/* Desktop — slightly roomier but still compact */
@media (min-width: 480px) {
  .container {
    padding: 1rem;
  }

  .form-card-header {
    padding: 0.85rem 1.15rem 0.6rem;
  }

  .form-card-header h1 {
    font-size: 1.15rem;
  }

  .form-intro {
    font-size: 13px;
  }

  .registration-form {
    padding: 0.85rem 1.15rem 1rem;
  }

  .form-grid {
    gap: 0.65rem 0.75rem;
  }

  .brand-logo {
    height: 38px;
  }
}

/* Short screens — stack DOB/CNIC to keep form scannable */
@media (max-width: 380px) {
  .form-grid {
    grid-template-columns: 1fr;
  }

  .form-group.span-2 {
    grid-column: span 1;
  }

  .year-badge {
    font-size: 10px;
    padding: 0.2rem 0.5rem;
  }

  .brand-logo {
    height: 30px;
  }
}

/* Tall enough screens — fit everything above the fold on mobile */
@media (max-height: 700px) and (max-width: 480px) {
  .site-header {
    padding-top: 0.35rem;
    padding-bottom: 0.35rem;
  }

  .brand-logo {
    height: 28px;
  }

  .container {
    padding-top: 0.5rem;
  }

  .form-card-header {
    padding: 0.55rem 0.85rem 0.4rem;
  }

  .registration-form {
    padding: 0.55rem 0.85rem 0.65rem;
  }

  .form-grid {
    gap: 0.4rem 0.55rem;
  }

  input {
    height: 38px;
  }

  textarea {
    min-height: 48px;
  }

  .submit-btn {
    height: 40px;
    margin-top: 0.5rem;
  }

  .site-footer {
    display: none;
  }
}
