* { box-sizing: border-box; }

html, body {
  min-height: 100%;
}

body.auth-body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--kw-ink);
  background-color: #F3F8F5;
  background-image:
    radial-gradient(ellipse 80% 60% at 12% 18%, rgba(37, 211, 102, 0.18), transparent 55%),
    radial-gradient(ellipse 70% 50% at 88% 12%, rgba(18, 140, 126, 0.14), transparent 50%),
    radial-gradient(ellipse 60% 45% at 70% 88%, rgba(7, 94, 84, 0.08), transparent 55%),
    linear-gradient(180deg, #F7FBF8 0%, #EEF6F2 100%);
  background-attachment: fixed;
  overflow-x: hidden;
}

.auth-body a {
  color: var(--kw-link);
}

.auth-body a:hover {
  color: var(--kw-cta-hover);
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 0.45fr) minmax(0, 0.55fr);
  align-items: center;
  padding: 24px 32px;
  gap: 24px;
}

.auth-shell--form {
  align-items: start;
  padding-top: 32px;
  padding-bottom: 32px;
}

.auth-shell--form .auth-brand {
  position: sticky;
  top: 40px;
  align-self: start;
}

.auth-brand {
  max-width: 420px;
  margin: 0 auto;
  padding: 12px 8px;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
  text-decoration: none;
  color: inherit;
}

.brand-mark:hover {
  color: inherit;
}

.brand-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(160deg, #25D366 0%, #128C7E 100%);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  box-shadow: 0 6px 16px rgba(18, 140, 126, 0.28);
  flex-shrink: 0;
}

.brand-wordmark {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.1;
  color: var(--kw-deep);
}

.brand-tagline {
  margin: 0 0 22px;
  font-size: 18px;
  line-height: 1.4;
  font-weight: 500;
  color: var(--kw-ink);
  max-width: 22em;
}

.brand-benefits {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.brand-benefits li {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: var(--kw-muted);
}

.benefit-icon {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: rgba(37, 211, 102, 0.14);
  color: var(--kw-cta);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 13px;
}

.auth-panel {
  display: flex;
  justify-content: center;
  align-items: center;
}

.auth-shell--form .auth-panel {
  align-items: start;
}

.auth-card {
  width: 100%;
  max-width: 460px;
  background: var(--kw-card);
  border: 1px solid rgba(18, 140, 126, 0.12);
  border-radius: 16px;
  box-shadow: 0 8px 24px rgba(18, 46, 32, 0.06), 0 1px 2px rgba(18, 46, 32, 0.04);
  padding: 28px 28px 22px;
}

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

.auth-card-header {
  margin-bottom: 16px;
}

.auth-card-header h1 {
  margin: 0 0 6px;
  font-size: 28px;
  line-height: 1.2;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--kw-ink);
}

.auth-card-header p {
  margin: 0;
  font-size: 15px;
  line-height: 1.45;
  color: var(--kw-muted);
}

.auth-alert {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid #F5C2C0;
  background: #FEF3F2;
  color: var(--kw-danger);
  font-size: 13px;
  line-height: 1.4;
}

.auth-alert i {
  margin-top: 1px;
  flex-shrink: 0;
}

.auth-alert .btn {
  align-self: flex-start;
  color: var(--kw-cta);
  border-color: var(--kw-cta);
}

.auth-alert .btn:hover {
  background: var(--kw-cta);
  border-color: var(--kw-cta);
  color: #fff;
}

.auth-field {
  margin-bottom: 10px;
}

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

.auth-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
}

.auth-field > label,
.auth-label-row label {
  display: block;
  margin: 0 0 6px;
  font-size: 14px;
  font-weight: 600;
  color: var(--kw-ink);
}

.auth-label-row label {
  margin-bottom: 0;
}

.forgot-link {
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}

.forgot-link:hover {
  text-decoration: underline;
}

.input-wrap {
  position: relative;
}

.input-wrap .field-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: #7A8A82;
  font-size: 16px;
  pointer-events: none;
}

.auth-input,
.auth-select {
  width: 100%;
  height: var(--kw-input-h);
  padding: 0 14px 0 42px;
  border: 1px solid var(--kw-line);
  border-radius: var(--kw-radius);
  background: #fff;
  color: var(--kw-ink);
  font-size: 16px;
  line-height: 1.2;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.auth-input.no-icon,
.auth-select.no-icon {
  padding-left: 14px;
}

.auth-input.has-toggle {
  padding-right: 44px;
}

.auth-input::placeholder {
  color: #94A39B;
}

.auth-input:hover,
.auth-select:hover {
  border-color: #B9C9C0;
}

.auth-input:focus,
.auth-select:focus,
.auth-select:focus-visible {
  outline: none;
  border-color: var(--kw-cta);
  box-shadow: 0 0 0 3px var(--kw-focus);
}

.auth-input.is-invalid,
.auth-select.is-invalid,
.phone-combo.is-invalid {
  border-color: #D92D20;
  box-shadow: 0 0 0 3px rgba(185, 35, 24, 0.12);
}

.auth-input:-webkit-autofill,
.auth-input:-webkit-autofill:hover,
.auth-input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--kw-ink);
  box-shadow: 0 0 0 1000px #F7FBF8 inset;
  transition: background-color 9999s ease-out;
}

.auth-select {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  text-align: left;
  cursor: pointer;
  padding-left: 14px;
  padding-right: 14px;
}

.auth-select-value {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 8px;
}

.auth-select-value span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.toggle-password {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 40px;
  height: 40px;
  border: 0;
  background: transparent;
  color: #6B7B73;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.toggle-password:hover {
  color: var(--kw-ink);
  background: #F3F7F4;
}

.toggle-password:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--kw-focus);
}

.field-error {
  min-height: 18px;
  margin-top: 4px;
  font-size: 12.5px;
  line-height: 18px;
  color: var(--kw-danger);
}

.auth-card--wide .field-error {
  min-height: 0;
}

.field-error:not(:empty)::before {
  content: "";
  display: inline-block;
  width: 12px;
  height: 12px;
  margin-right: 5px;
  vertical-align: -1px;
  background: currentColor;
  mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'><path fill='black' d='M8 1.5A6.5 6.5 0 1 0 8 14.5 6.5 6.5 0 0 0 8 1.5zM7.25 5a.75.75 0 0 1 1.5 0v3.5a.75.75 0 0 1-1.5 0V5zm.75 7a1 1 0 1 1 0-2 1 1 0 0 1 0 2z'/></svg>") center / contain no-repeat;
  -webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'><path fill='black' d='M8 1.5A6.5 6.5 0 1 0 8 14.5 6.5 6.5 0 0 0 8 1.5zM7.25 5a.75.75 0 0 1 1.5 0v3.5a.75.75 0 0 1-1.5 0V5zm.75 7a1 1 0 1 1 0-2 1 1 0 0 1 0 2z'/></svg>") center / contain no-repeat;
}

.flag-img {
  width: 22px;
  height: 16px;
  object-fit: cover;
  border-radius: 2px;
  flex-shrink: 0;
}

.phone-combo {
  display: flex;
  align-items: stretch;
  height: var(--kw-input-h);
  border: 1px solid var(--kw-line);
  border-radius: var(--kw-radius);
  background: #fff;
  overflow: visible;
  position: relative;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.phone-combo:hover {
  border-color: #B9C9C0;
}

.phone-combo:focus-within {
  border-color: var(--kw-cta);
  box-shadow: 0 0 0 3px var(--kw-focus);
}

.phone-prefix-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 108px;
  padding: 0 12px;
  border: 0;
  border-right: 1px solid var(--kw-line);
  border-radius: var(--kw-radius) 0 0 var(--kw-radius);
  background: #F7FBF8;
  color: var(--kw-ink);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
}

.phone-prefix-btn:focus-visible {
  outline: none;
  box-shadow: inset 0 0 0 2px var(--kw-cta);
}

.phone-combo .phone-number-input {
  border: 0;
  border-radius: 0 var(--kw-radius) var(--kw-radius) 0;
  height: 100%;
  box-shadow: none;
  padding-left: 14px;
}

.phone-combo .phone-number-input:hover,
.phone-combo .phone-number-input:focus {
  border: 0;
  box-shadow: none;
}

.phone-combo.is-invalid .phone-number-input {
  box-shadow: none;
}

.auth-dropdown {
  --bs-dropdown-min-width: 100%;
  border: 1px solid var(--kw-line);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(18, 46, 32, 0.12);
  padding: 6px;
  max-height: 240px;
  overflow-y: auto;
}

.auth-dropdown.phone-country-dropdown {
  min-width: 280px;
  max-width: min(360px, 90vw);
}

.auth-dropdown .dropdown-search {
  position: sticky;
  top: -6px;
  z-index: 1;
  background: #fff;
  padding: 6px 6px 8px;
  margin: -6px -6px 4px;
  border-bottom: 1px solid var(--kw-line);
}

.auth-dropdown .dropdown-search .auth-input,
.auth-dropdown .dropdown-search input {
  height: 40px;
  font-size: 14px;
  padding: 0 12px;
}

.auth-dropdown .dropdown-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 14px;
  color: var(--kw-ink);
}

.auth-dropdown .dropdown-item:hover,
.auth-dropdown .dropdown-item:focus {
  background: #F4FAF6;
  color: var(--kw-ink);
}

.auth-check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 4px 0 12px;
}

.auth-check input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  margin: 2px 0 0;
  flex-shrink: 0;
  border: 1.5px solid var(--kw-line);
  border-radius: 5px;
  background: #fff;
  cursor: pointer;
  position: relative;
}

.auth-check input[type="checkbox"]:hover {
  border-color: #B9C9C0;
}

.auth-check input[type="checkbox"]:checked {
  background-color: var(--kw-cta);
  border-color: var(--kw-cta);
}

.auth-check input[type="checkbox"]:checked::after {
  content: "";
  position: absolute;
  left: 5px;
  top: 1px;
  width: 5px;
  height: 9px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.auth-check input[type="checkbox"]:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--kw-focus);
}

.auth-check input[type="checkbox"].is-invalid {
  border-color: #D92D20;
  box-shadow: 0 0 0 3px rgba(185, 35, 24, 0.12);
}

.auth-check label {
  margin: 0;
  font-size: 13px;
  line-height: 1.45;
  color: var(--kw-muted);
  font-weight: 400;
}

.auth-check label a {
  font-weight: 600;
  text-decoration: none;
}

.auth-check label a:hover {
  text-decoration: underline;
}

.auth-helper {
  margin: 8px 0 0;
  font-size: 13px;
  text-align: center;
  color: var(--kw-muted);
}

.btn-auth-primary,
.btn-auth-secondary {
  width: 100%;
  min-height: 50px;
  border-radius: var(--kw-radius);
  font-size: 15px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
  transition: background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, color 0.15s ease;
}

.btn-auth-primary {
  margin-top: 4px;
  border: 1px solid transparent;
  background: var(--kw-cta);
  color: #fff;
}

.btn-auth-primary:hover {
  background: var(--kw-cta-hover);
  color: #fff;
}

.btn-auth-primary:active {
  background: var(--kw-cta-active);
}

.btn-auth-primary:focus-visible,
.btn-auth-secondary:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--kw-focus);
}

.btn-auth-primary:disabled,
.btn-auth-primary.is-loading {
  background: #3E9A63;
  cursor: not-allowed;
  box-shadow: none;
}

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

.btn-auth-secondary {
  border: 1px solid var(--kw-line);
  background: #fff;
  color: var(--kw-ink);
}

.btn-auth-secondary:hover {
  background: #F4FAF6;
  border-color: #B7CFC0;
  color: var(--kw-ink);
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 14px 0;
  color: #8A9690;
  font-size: 13px;
}

.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--kw-line);
}

.terms-text {
  margin: 16px 0 0;
  font-size: 12px;
  line-height: 1.5;
  text-align: center;
  color: #7A8A82;
}

.terms-text a {
  color: var(--kw-link);
  text-decoration: none;
}

.terms-text a:hover {
  text-decoration: underline;
}

.auth-body .modal-content {
  border-radius: 12px;
  border: 0;
}

.auth-body .modal-header {
  background-color: var(--kw-cta);
  color: white;
}

.auth-body .modal-body {
  max-height: 70vh;
  overflow-y: auto;
}

.auth-body .modal-footer .btn-primary {
  background-color: var(--kw-cta);
  border-color: var(--kw-cta);
}

.auth-body .modal-footer .btn-primary:hover {
  background-color: var(--kw-cta-hover);
  border-color: var(--kw-cta-hover);
}

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

@media (max-width: 991.98px) {
  .auth-shell,
  .auth-shell--form {
    grid-template-columns: 1fr;
    align-content: start;
    align-items: start;
    padding: 16px;
    gap: 4px;
  }

  .auth-shell--form .auth-brand {
    position: static;
  }

  .auth-brand {
    max-width: 520px;
    width: 100%;
    padding: 8px 4px 4px;
    text-align: center;
  }

  .brand-mark {
    margin-bottom: 6px;
  }

  .brand-wordmark {
    font-size: 18px;
  }

  .brand-icon {
    width: 30px;
    height: 30px;
    font-size: 15px;
  }

  .brand-tagline {
    margin: 0;
    font-size: 13px;
    font-weight: 400;
    color: var(--kw-muted);
  }

  .brand-benefits {
    display: none;
  }

  .auth-card,
  .auth-card--wide {
    padding: 22px 16px 18px;
  }

  .auth-card-header h1 {
    font-size: 24px;
  }
}

@media (max-width: 575.98px) {
  .auth-row {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .phone-prefix-btn {
    min-width: 96px;
    padding: 0 8px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .btn-spinner { animation: none; border-top-color: #fff; }
  .auth-input, .auth-select, .btn-auth-primary, .btn-auth-secondary, .phone-combo { transition: none; }
}
