:root {
  --primary: #2563eb;
  --hero-from: #667eea;
  --hero-to: #764ba2;
  --text-dark: #1f2937;
  --text-gray: #6b7280;
  --bg-page: #eef0f5;
  --bg-white: #ffffff;
  --border: #e5e7eb;
  --danger: #b42318;
  --ok: #067647;
  --radius: 16px;
  --shadow: 0 14px 36px rgba(31, 41, 55, 0.12);
  font-family: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

* { box-sizing: border-box; }

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

html, body {
  margin: 0;
  min-height: 100%;
  color: var(--text-dark);
  background:
    radial-gradient(70% 45% at 50% 0%, rgba(102, 126, 234, 0.28), transparent 70%),
    var(--bg-page);
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(12px, env(safe-area-inset-top)) 12px max(12px, env(safe-area-inset-bottom));
}

.page {
  width: min(760px, 100%);
  margin: 0 auto;
}

.card {
  background: var(--bg-white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid rgba(229, 231, 235, 0.95);
  padding: 16px 18px 12px;
}

.card-sm {
  width: min(420px, 100%);
  margin: 0 auto;
  padding: 20px 18px 16px;
}

.center { text-align: center; }

.hidden { display: none !important; }

.header {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 6px;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.logo,
.brand-mark {
  display: block;
  width: 44px;
  height: 44px;
  object-fit: cover;
  border-radius: 11px;
  border: 1px solid var(--border);
  background: #fff;
}

.header-text {
  max-width: 36rem;
}

.eyebrow {
  margin: 0;
  color: var(--text-gray);
  font-size: 0.76rem;
  font-weight: 600;
}

h1 {
  margin: 2px 0 0;
  font-size: clamp(1.1rem, 2.6vw, 1.3rem);
  line-height: 1.2;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.intro {
  margin: 4px 0 0;
  color: var(--text-gray);
  font-size: 0.84rem;
  line-height: 1.35;
}

form {
  display: grid;
  gap: 10px;
}

.fields-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 16px;
  align-items: start;
}

.col {
  display: grid;
  gap: 8px;
  min-width: 0;
}

label {
  display: grid;
  gap: 3px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-dark);
}

label span em {
  color: var(--danger);
  font-style: normal;
}

input, select, textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 10px;
  font: inherit;
  font-size: 16px;
  font-weight: 500;
  color: var(--text-dark);
  background: #fff;
  min-height: 38px;
}

textarea {
  min-height: 56px;
  resize: vertical;
  font-size: 15px;
}

select {
  appearance: auto;
  -webkit-appearance: menulist;
  cursor: pointer;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: #93c5fd;
  box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.18);
}

input.is-invalid,
select.is-invalid,
textarea.is-invalid {
  border-color: var(--danger) !important;
  background: #fff5f5 !important;
  box-shadow: 0 0 0 2px rgba(180, 35, 24, 0.18) !important;
}

label.has-error > span:first-child {
  color: var(--danger);
}

.field-error-msg {
  color: var(--danger);
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1.25;
}

.btn.is-loading {
  opacity: 0.92;
  cursor: wait;
  pointer-events: none;
}

.btn-spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  margin-right: 8px;
  vertical-align: -2px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

#submit-btn-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.row2 {
  display: grid;
  grid-template-columns: 1.35fr 0.9fr;
  gap: 8px;
}

.grow, .shrink { min-width: 0; }

.actions {
  display: grid;
  gap: 8px;
  margin-top: 4px;
  justify-items: center;
  text-align: center;
}

.actions .btn.primary {
  max-width: 420px;
}

.btn {
  appearance: none;
  border: 0;
  border-radius: 10px;
  padding: 10px 14px;
  font: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  min-height: 42px;
}

.btn.primary {
  width: 100%;
  color: #fff;
  background: linear-gradient(135deg, var(--hero-from), var(--hero-to));
  box-shadow: 0 8px 18px rgba(102, 126, 234, 0.28);
}

.btn.primary:active { transform: translateY(1px); }

.btn.link {
  background: transparent;
  color: var(--primary);
  padding: 2px 0;
  font-size: 0.84rem;
  font-weight: 600;
  min-height: auto;
  width: 100%;
  text-align: center;
}

.btn:disabled {
  opacity: 0.65;
  cursor: wait;
}

.fineprint {
  margin: 0;
  font-size: 0.72rem;
  line-height: 1.35;
  color: var(--text-gray);
  text-align: center;
}

.legal-consent {
  margin: 2px 0 0;
  font-size: 0.78rem;
  line-height: 1.4;
  color: var(--text-gray);
  text-align: center;
}

.legal-consent a {
  color: var(--primary);
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.page-footer {
  margin-top: 14px;
  text-align: center;
  display: grid;
  gap: 4px;
}

.page-footer-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
}

.page-footer-links a {
  color: var(--text-gray);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.page-footer-links a:hover {
  color: var(--primary);
}

.page-footer-copy {
  margin: 0;
  font-size: 0.7rem;
  color: #9ca3af;
}

.form-error {
  margin: 0;
  padding: 8px 10px;
  border-radius: 8px;
  background: #fef3f2;
  color: var(--danger);
  font-size: 0.82rem;
  font-weight: 600;
  text-align: center;
}

.otp-panel {
  padding: 10px;
  border-radius: 10px;
  background: #eef2ff;
  border: 1px solid #c7d2fe;
  display: grid;
  gap: 8px;
}

.otp-hint {
  margin: 0;
  color: var(--text-gray);
  font-size: 0.82rem;
  text-align: center;
}

.app-promo {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  text-align: center;
}

.app-promo-success {
  margin-top: 14px;
  padding-top: 12px;
}

.app-promo-title {
  margin: 0 0 8px;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-dark);
}

.app-promo-text {
  margin: 0 0 8px;
  font-size: 0.76rem;
  color: var(--text-gray);
  line-height: 1.35;
}

.store-badges {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.store-badge {
  display: inline-flex;
  line-height: 0;
}

.store-badge img {
  display: block;
  height: 34px;
  width: auto;
  max-width: 130px;
  object-fit: contain;
}

.hp {
  position: absolute;
  left: -10000px;
  opacity: 0;
  height: 0;
  width: 0;
}

.spinner {
  width: 28px;
  height: 28px;
  margin: 0 auto 8px;
  border: 3px solid #ddd6fe;
  border-top-color: var(--hero-from);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.success-icon {
  width: 44px;
  height: 44px;
  margin: 0 auto 10px;
  border-radius: 50%;
  background: #ecfdf3;
  color: var(--ok);
  display: grid;
  place-items: center;
  font-size: 1.25rem;
  font-weight: 800;
}

#state-success h1,
#state-error h1 {
  margin-bottom: 6px;
}

#state-success > p,
#state-error > p,
#state-loading p {
  margin: 0;
  color: var(--text-gray);
  font-size: 0.9rem;
  line-height: 1.4;
}

/* Mobile: jedna kolumna, nadal zwarty */
@media (max-width: 700px) {
  body {
    align-items: flex-start;
    padding-top: max(10px, env(safe-area-inset-top));
  }

  .page { width: min(480px, 100%); }

  .fields-grid {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .row2 {
    grid-template-columns: 1fr;
  }

  .card { padding: 14px 12px 10px; }
}

@media (max-height: 780px) and (min-width: 701px) {
  body { align-items: flex-start; padding-top: 16px; }
  .card { padding: 12px 16px 10px; }
  input, select { min-height: 36px; padding: 6px 9px; }
  textarea { min-height: 48px; }
}
