:root {
  --brand: #011264;
  --brand-deep: #000b42;
  --accent: #168cf5;
  --accent-hover: #0877dd;
  --panel: #ffffff;
  --surface: #ffffff;
  --text: #222733;
  --muted: #a4a9b2;
  --placeholder: #c7ccd5;
  --border: #e1e5eb;
  --error: #ef5a5a;
  --field-height: clamp(50px, 5.15vh, 58px);
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { background: var(--panel); color: var(--text); }
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

.apply-layout {
  display: grid;
  grid-template-columns: minmax(420px, 39%) minmax(640px, 61%);
  height: 100dvh;
  min-height: 680px;
  overflow: hidden;
}

.brand-panel {
  position: sticky;
  top: 0;
  display: grid;
  place-items: center;
  min-width: 0;
  overflow: hidden;
  background: var(--brand);
}

.brand-logo-frame {
  width: 100%;
  height: 100%;
  border: 0;
  background: transparent;
  pointer-events: none;
  transform: translateY(clamp(74px, 9vh, 112px));
}

.brand-copy {
  position: absolute;
  top: clamp(58px, 8vh, 96px);
  right: clamp(38px, 5vw, 78px);
  left: clamp(38px, 5vw, 78px);
  z-index: 2;
  color: #fff;
}

.brand-copy h2 {
  margin: 0;
  font-size: clamp(36px, 3.2vw, 52px);
  line-height: 1.15;
  letter-spacing: -.035em;
}

.brand-copy p {
  max-width: 590px;
  margin: 28px 0 0;
  color: rgba(255, 255, 255, .78);
  font-size: clamp(15px, 1.12vw, 18px);
  line-height: 1.9;
}

.form-panel {
  min-width: 0;
  overflow-y: auto;
  background: var(--panel);
  scrollbar-color: rgba(140, 150, 165, .35) transparent;
}

.apply-topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  min-height: 60px;
  padding: 9px clamp(28px, 4vw, 62px);
  background: color-mix(in srgb, var(--panel) 92%, transparent);
  backdrop-filter: blur(16px);
}

.topbar-actions { display: flex; gap: 8px; }

.icon-button {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #858b94;
  cursor: pointer;
  transition: color .2s ease, background .2s ease;
}
.icon-button:hover { color: var(--accent); background: rgba(22, 140, 245, .08); }
.icon-button svg { width: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.icon-button:first-child svg { fill: currentColor; stroke: none; }

.form-shell {
  width: min(100%, 790px);
  margin: 0 auto;
  padding: clamp(4px, 1vh, 12px) 44px clamp(22px, 3vh, 38px);
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-bottom: clamp(8px, 1.3vh, 15px);
  color: #9097a1;
  font-size: 13px;
  text-decoration: none;
}
.back-link:hover { color: var(--accent); }
.back-link svg { width: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.form-heading h1 { margin: 0; font-size: clamp(34px, 2.8vw, 42px); line-height: 1.1; letter-spacing: -.02em; }
.form-heading p { margin: clamp(8px, 1.2vh, 13px) 0 clamp(28px, 3.2vh, 40px); color: var(--muted); font-size: 16px; }

.partner-form { display: grid; gap: clamp(28px, 3.3vh, 42px); }
.form-group { min-width: 0; margin: 0; padding: 0; border: 0; }
.form-group > label,
.form-group > legend {
  display: block;
  margin: 0 0 6px;
  padding: 0;
  color: #505660;
  font-size: 16px;
  font-weight: 500;
}
.form-group > label span,
.form-group > legend span { color: var(--error); }

.form-group input,
.form-group select,
.name-inputs,
.phone-field {
  width: 100%;
  height: var(--field-height);
  border: 1px solid var(--border);
  border-radius: 10px;
  outline: none;
  background: var(--surface);
  color: var(--text);
  transition: border-color .2s ease, box-shadow .2s ease, background .2s ease;
}
.form-group > input { padding: 0 19px; font-size: 16px; }
.form-group input::placeholder { color: var(--placeholder); }
.form-group select { appearance: none; cursor: pointer; }
.form-group input:focus,
.form-group select:focus,
.name-inputs:focus-within,
.phone-field:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(22, 140, 245, .11); }

.name-inputs,
.phone-field { display: flex; align-items: center; }
.name-inputs label { flex: 1; min-width: 0; }
.name-inputs input,
.phone-field input,
.phone-field select {
  height: calc(var(--field-height) - 2px);
  border: 0;
  border-radius: 9px;
  box-shadow: none !important;
  background: transparent;
}
.name-inputs input { padding: 0 19px; font-size: 16px; }
.name-inputs label:last-of-type input { padding-right: 19px; }
.field-divider { flex: 0 0 1px; width: 1px; height: 28px; background: var(--border); }

.phone-field select { width: 190px; padding: 0 32px 0 19px; overflow: hidden; font-size: 15px; text-overflow: ellipsis; white-space: nowrap; background-image: linear-gradient(45deg, transparent 50%, #89909a 50%), linear-gradient(135deg, #89909a 50%, transparent 50%); background-position: calc(100% - 18px) calc(50% + 2px), calc(100% - 13px) calc(50% + 2px); background-size: 5px 5px; background-repeat: no-repeat; }
.phone-field input { flex: 1; min-width: 0; padding: 0 19px; font-size: 16px; }

.select-wrap { position: relative; }
.select-wrap select { padding: 0 48px 0 19px; font-size: 16px; }
.select-wrap svg { position: absolute; top: 50%; right: 16px; width: 19px; pointer-events: none; fill: none; stroke: #adb3bc; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; transform: translateY(-50%); }

.field-hint { display: block; margin: 4px 0 0; color: #afb4bd; font-size: 12px; }
.field-error,
.agreement-error { display: none; margin: 6px 0 0; color: var(--error); font-size: 12px; }
.optional-partner-field[hidden] { display: none !important; }
.form-group.has-error .field-error,
.agreement-error.is-visible { display: block; }
.form-group.has-error input,
.form-group.has-error select,
.form-group.has-error .name-inputs,
.form-group.has-error .phone-field { border-color: var(--error); }

.agreement { display: flex; align-items: flex-start; gap: 11px; color: #7f858e; font-size: 14px; line-height: 22px; cursor: pointer; }
.agreement input { position: absolute; opacity: 0; pointer-events: none; }
.custom-checkbox { flex: 0 0 20px; display: grid; place-items: center; width: 20px; height: 20px; margin-top: 1px; border: 1px solid #cfd4dc; border-radius: 4px; background: var(--surface); transition: background .2s ease, border-color .2s ease; }
.custom-checkbox svg { width: 15px; fill: none; stroke: #fff; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; opacity: 0; transform: scale(.7); transition: opacity .2s ease, transform .2s ease; }
.agreement input:checked + .custom-checkbox { border-color: var(--accent); background: var(--accent); }
.agreement input:checked + .custom-checkbox svg { opacity: 1; transform: scale(1); }
.agreement input:focus-visible + .custom-checkbox { box-shadow: 0 0 0 3px rgba(22, 140, 245, .16); }
.agreement a { color: #067df2; text-decoration: none; }
.agreement a:hover { text-decoration: underline; }

.submit-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  height: clamp(50px, 5vh, 56px);
  margin-top: 2px;
  border: 0;
  border-radius: 10px;
  background: linear-gradient(135deg, #1598ff, #0877e7);
  box-shadow: 0 13px 26px rgba(15, 125, 235, .22);
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: transform .2s ease, box-shadow .2s ease, filter .2s ease;
}
.submit-button:hover { transform: translateY(-1px); box-shadow: 0 16px 30px rgba(15, 125, 235, .28); filter: brightness(1.03); }
.submit-button:active { transform: translateY(0); }
.submit-button:disabled { cursor: wait; opacity: .68; transform: none; box-shadow: none; }
.submit-button svg { width: 19px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.form-submit-error { margin: -6px 0 0; color: var(--error); font-size: 12px; line-height: 1.6; text-align: center; }
.form-note { margin: -5px 0 0; color: #b2b7c0; font-size: 11px; line-height: 1.6; text-align: center; }

.success-modal[hidden] { display: none; }
.success-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(3, 12, 38, .56);
  backdrop-filter: blur(7px);
  -webkit-backdrop-filter: blur(7px);
  animation: modal-fade-in .2s ease-out;
}
.success-dialog {
  position: relative;
  width: min(440px, 100%);
  padding: 46px 38px 36px;
  border: 1px solid rgba(22, 140, 245, .16);
  border-radius: 20px;
  background: var(--surface);
  box-shadow: 0 28px 90px rgba(1, 13, 48, .28);
  text-align: center;
  animation: modal-rise-in .28s cubic-bezier(.2, .8, .2, 1);
}
.success-close {
  position: absolute;
  top: 14px;
  right: 14px;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: color .2s ease, background .2s ease;
}
.success-close:hover { background: rgba(22, 140, 245, .08); color: var(--accent); }
.success-close:focus-visible,
.success-confirm:focus-visible { outline: 3px solid rgba(22, 140, 245, .22); outline-offset: 2px; }
.success-close svg { width: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.success-icon { display: grid; place-items: center; width: 72px; height: 72px; margin: 0 auto 24px; border-radius: 50%; background: rgba(22, 140, 245, .11); color: var(--accent); box-shadow: 0 0 0 10px rgba(22, 140, 245, .045); }
.success-icon svg { width: 35px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.success-dialog h2 { margin: 0; font-size: 30px; }
.success-dialog p { max-width: 360px; margin: 15px auto 28px; color: var(--muted); line-height: 1.75; }
.success-actions { display: flex; flex-direction: column; align-items: center; gap: 13px; }
.success-confirm {
  width: min(240px, 100%);
  min-height: 48px;
  border: 0;
  border-radius: 9px;
  background: linear-gradient(135deg, #1598ff, #0877e7);
  box-shadow: 0 10px 22px rgba(15, 125, 235, .2);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}
.success-confirm:hover { filter: brightness(1.04); }
.success-dialog a { color: var(--muted); font-size: 14px; text-decoration: none; }
.success-dialog a:hover { color: var(--accent); }
body.modal-open { overflow: hidden; }

@keyframes modal-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes modal-rise-in {
  from { opacity: 0; transform: translateY(14px) scale(.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.sr-only { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; overflow: hidden !important; clip: rect(0, 0, 0, 0) !important; white-space: nowrap !important; border: 0 !important; }

body.dark {
  --panel: #0b1424;
  --surface: #101c2e;
  --text: #f0f4fa;
  --muted: #7e8da0;
  --placeholder: #667589;
  --border: #26354a;
  color-scheme: dark;
}
body.dark .form-group > label,
body.dark .form-group > legend { color: #c6d0de; }

@media (min-width: 761px) and (max-height: 950px) {
  .form-heading p { margin-bottom: 28px; }
  .partner-form { gap: 27px; }
}

@media (max-width: 1050px) {
  .apply-layout { grid-template-columns: 34% 66%; }
  .brand-copy { right: 34px; left: 34px; }
  .brand-copy h2 { font-size: 36px; }
  .brand-copy p { margin-top: 20px; font-size: 14px; line-height: 1.8; }
  .form-shell { padding-inline: 34px; }
}

@media (max-width: 760px) {
  .apply-layout { display: block; height: auto; min-height: 100dvh; overflow: visible; }
  .brand-panel { position: relative; height: 340px; }
  .brand-logo-frame { position: absolute; inset: 0; transform: translateY(72px); }
  .brand-copy { top: 28px; right: 24px; left: 24px; text-align: center; }
  .brand-copy h2 { font-size: 29px; }
  .brand-copy p { max-width: 520px; margin: 12px auto 0; font-size: 13px; line-height: 1.65; }
  .form-panel { overflow: visible; }
  .apply-topbar { min-height: 78px; padding: 14px 20px; }
  .form-shell { padding: 30px 20px 54px; }
  .form-heading p { margin-bottom: 30px; }
  .partner-form { gap: 26px; }
}

@media (max-width: 420px) {
  :root { --field-height: 54px; }
  .brand-panel { height: 310px; }
  .brand-logo-frame { transform: translateY(70px); }
  .brand-copy { top: 24px; right: 18px; left: 18px; }
  .brand-copy h2 { font-size: 27px; }
  .brand-copy p { font-size: 12px; }
  .apply-topbar { min-height: 70px; }
  .icon-button { width: 38px; height: 38px; }
  .form-shell { padding-top: 24px; }
  .form-heading h1 { font-size: 30px; }
  .partner-form { gap: 24px; }
  .name-inputs input { padding-inline: 12px; }
  .phone-field select { width: 148px; padding-left: 13px; font-size: 13px; }
  .agreement { font-size: 13px; }
  .success-modal { padding: 18px; }
  .success-dialog { padding: 42px 22px 30px; border-radius: 16px; }
  .success-dialog h2 { font-size: 27px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
