:root {
  --bg: #f0f4fb;
  --bg-accent: #e8f0fe;
  --surface: #ffffff;
  --surface2: #f8fafc;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --primary: #005bbf;
  --primary-hover: #004a99;
  --accent: #f58220;
  --danger: #dc2626;
  --success: #059669;
  --radius: 18px;
  --shadow: 0 12px 40px rgba(15, 23, 42, 0.08);
}

* { box-sizing: border-box; }

body {
  font-family: 'Montserrat', system-ui, sans-serif;
  background: var(--bg);
  background-image:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(0, 91, 191, 0.12), transparent),
    radial-gradient(ellipse 60% 40% at 100% 100%, rgba(245, 130, 32, 0.08), transparent);
  color: var(--text);
  min-height: 100vh;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

body.auth-busy { overflow: hidden; }

.auth-card {
  width: 100%;
  max-width: 400px;
  padding: 32px 28px;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  transform: translateY(16px);
  animation: authCardIn 0.55s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.auth-card--wide { max-width: 520px; }

@keyframes authCardIn {
  to { transform: translateY(0); opacity: 1; }
}

.auth-logo {
  text-align: center;
  margin-bottom: 22px;
  animation: logoIn 0.7s ease 0.1s both;
}

.auth-logo img,
.auth-logo svg {
  max-height: 96px;
  width: auto;
  max-width: min(100%, 320px);
  height: auto;
  display: inline-block;
  background: transparent;
}

@keyframes logoIn {
  from { opacity: 0; transform: scale(0.92) translateY(-6px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

h1 {
  font-size: 1.35rem;
  font-weight: 800;
  margin: 0 0 8px;
  text-align: center;
  color: var(--text);
}

.subtitle {
  text-align: center;
  color: var(--muted);
  font-size: 0.875rem;
  margin-bottom: 24px;
  line-height: 1.55;
  font-weight: 500;
}

label {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 6px;
  font-weight: 700;
}

.label-hint {
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
  color: var(--muted);
  font-size: 11px;
  display: block;
  margin-top: -2px;
  margin-bottom: 6px;
  line-height: 1.4;
}

input,
select,
textarea {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  margin-bottom: 14px;
  font-size: 15px;
  font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}

textarea {
  min-height: 72px;
  resize: vertical;
  line-height: 1.45;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(0, 91, 191, 0.12);
}

.form-row {
  display: flex;
  gap: 12px;
}

.form-col { flex: 1; min-width: 0; }

.passport-row {
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: 12px;
}

.file-input {
  padding: 10px;
  font-size: 13px;
  background: #fff;
}

.docs-fieldset {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px 16px 6px;
  margin: 0 0 14px;
  background: var(--surface2);
}

.docs-fieldset legend {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--primary);
  font-weight: 800;
  padding: 0 8px;
}

.docs-section-title {
  font-size: 12px;
  font-weight: 800;
  color: var(--text);
  margin: 4px 0 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.consent-text {
  font-size: 12px;
  line-height: 1.5;
  color: var(--muted);
  margin: 0 0 10px;
  max-height: 120px;
  overflow-y: auto;
}

.consent-block {
  margin: 4px 0 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.consent-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 12px;
  line-height: 1.45;
  color: var(--muted);
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
  margin: 0;
  cursor: pointer;
}

.consent-row input {
  width: auto;
  margin: 2px 0 0;
  flex-shrink: 0;
}

.btn {
  width: 100%;
  padding: 14px 16px;
  border: 0;
  border-radius: 12px;
  font-weight: 800;
  font-size: 14px;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-family: inherit;
  transition: transform 0.15s, box-shadow 0.2s, background 0.2s, opacity 0.2s;
}

.btn:active:not(:disabled) { transform: scale(0.98); }

.btn-primary {
  background: linear-gradient(135deg, var(--primary) 0%, #0066d4 100%);
  color: #fff;
  box-shadow: 0 4px 14px rgba(0, 91, 191, 0.28);
}

.btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, var(--primary-hover) 0%, #005bbf 100%);
  box-shadow: 0 6px 18px rgba(0, 91, 191, 0.32);
}

.btn-primary:disabled {
  opacity: 0.75;
  cursor: wait;
}

.btn-google {
  background: #fff;
  color: #1f1f1f;
  border: 1px solid var(--border);
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.06);
}

.btn-google:hover {
  border-color: #cbd5e1;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.08);
}

.btn-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}

.btn-google .btn-spinner {
  border-color: rgba(15, 23, 42, 0.15);
  border-top-color: var(--primary);
}

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

.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 12px;
  margin: 18px 0;
  font-weight: 600;
}

.divider::before,
.divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.msg {
  font-size: 14px;
  margin-top: 12px;
  text-align: center;
  line-height: 1.5;
  font-weight: 600;
  min-height: 1.4em;
  animation: msgIn 0.3s ease;
}

@keyframes msgIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.msg.err { color: var(--danger); }
.msg.ok { color: var(--success); }

.auth-links {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 18px;
}

.auth-links a {
  color: var(--primary);
  text-decoration: none;
  font-size: 13px;
  font-weight: 700;
  text-align: center;
  transition: color 0.15s;
}

.auth-links a:hover { color: var(--accent); text-decoration: underline; }

.info-box {
  background: var(--bg-accent);
  border: 1px solid #bfdbfe;
  border-radius: 12px;
  padding: 14px;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.55;
  margin-bottom: 16px;
  font-weight: 500;
}

.success-screen {
  text-align: center;
  padding: 12px 0 8px;
  animation: authCardIn 0.5s ease both;
}

.success-icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: rgba(5, 150, 105, 0.12);
  color: var(--success);
  font-size: 30px;
  line-height: 64px;
  margin: 0 auto 16px;
  font-weight: 800;
  animation: successPop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) 0.15s both;
}

@keyframes successPop {
  from { transform: scale(0.5); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.success-screen h2 {
  font-size: 1.15rem;
  margin: 0 0 8px;
}

.success-screen p {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
  margin-bottom: 20px;
}

/* Полноэкранный оверлей при отправке */
.auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(240, 244, 251, 0.82);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s, visibility 0.25s;
}

.auth-overlay.is-visible {
  opacity: 1;
  visibility: visible;
}

.auth-overlay__card {
  background: var(--surface);
  border-radius: 20px;
  padding: 28px 36px;
  box-shadow: var(--shadow);
  text-align: center;
  border: 1px solid var(--border);
  animation: authCardIn 0.35s ease both;
}

.auth-overlay__spinner {
  width: 44px;
  height: 44px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  margin: 0 auto 14px;
  animation: spin 0.75s linear infinite;
}

.auth-overlay__text {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  color: var(--muted);
}

/* Пульсация полей при загрузке метаданных */
select.is-loading-meta {
  color: var(--muted);
  background-image: linear-gradient(90deg, #f1f5f9 0%, #e2e8f0 50%, #f1f5f9 100%);
  background-size: 200% 100%;
  animation: shimmer 1.2s ease infinite;
}

@keyframes shimmer {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

@media (max-width: 520px) {
  .form-row,
  .passport-row { grid-template-columns: 1fr; display: flex; flex-direction: column; gap: 0; }
  body { padding: 16px; align-items: flex-start; padding-top: 20px; }
  .auth-card { padding: 22px 18px; }
}
