:root {
  --fe-blue: #236895;
  --fe-blue-dark: #14557F;
  --fe-blue-soft: #EEF6FB;
  --fe-gray: #87919A;
  --fe-dark: #1D2730;
  --fe-text: #313941;
  --fe-muted: #6E7882;
  --fe-border: #DDE3E8;
  --fe-border-strong: #CCD6DE;
  --fe-bg: #F6F8FA;
  --fe-input: #FFFFFF;
  --fe-white: #FFFFFF;
  --fe-success: #1F6B3A;
  --shadow: 0 10px 28px rgba(29, 39, 48, 0.07);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--fe-bg);
  color: var(--fe-text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  overflow-x: hidden;
}

.app-shell {
  width: 100%;
  margin: 0 auto 32px;
}

.embed-mode {
  background: transparent;
}

.embed-mode::before {
  display: none;
}

.embed-mode .app-shell {
  width: 100%;
  margin: 0;
}

.form-frame {
  min-height: 100vh;
}

.embed-mode .form-frame {
  min-height: 0;
}

.form-layout {
  padding: 32px 0;
}

.embed-mode .form-layout {
  padding: 0;
}

.form-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin: 0 auto 18px;
  max-width: 920px;
}

.embed-mode .form-nav {
  display: none;
}

.form-nav button,
.primary-button,
.secondary-button {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
}

.form-nav button {
  padding: 9px 13px;
  border: 1px solid var(--fe-border);
  background: var(--fe-white);
  color: #4E5963;
  box-shadow: 0 1px 2px rgba(29, 39, 48, 0.04);
}

.form-nav button[aria-current="true"] {
  border-color: var(--fe-blue);
  background: var(--fe-blue);
  color: var(--fe-white);
}

.form-content {
  max-width: 820px;
  margin: 0 auto;
  padding: 24px 22px 28px;
  border: 1px solid var(--fe-border);
  border-radius: 14px;
  background: var(--fe-white);
  box-shadow: var(--shadow);
}

.embed-mode .form-content {
  max-width: none;
  padding: 0;
  border-radius: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.form-intro {
  margin-bottom: 18px;
}

.form-intro h1 {
  margin: 0;
  color: #111923;
  font-size: 1.55rem;
  line-height: 1.18;
}

.form-intro p {
  margin: 6px 0 0;
  color: var(--fe-muted);
  font-size: 0.94rem;
  line-height: 1.5;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  column-gap: 14px;
  row-gap: 15px;
}

.field-section {
  grid-column: span 12;
  padding-top: 14px;
  border-bottom: 1px solid #EEF1F3;
}

.form-intro + .field-grid .field-section:first-child {
  padding-top: 4px;
}

.field-section h2,
.section-title {
  margin: 0 0 10px;
  color: #18212B;
  font-size: 0.98rem;
  font-weight: 700;
  line-height: 1.25;
}

.field {
  grid-column: span 12;
}

.field.half {
  grid-column: span 6;
}

.field.third {
  grid-column: span 4;
}

label {
  display: block;
  margin-bottom: 7px;
  color: #4F5A64;
  font-size: 0.9rem;
  font-weight: 500;
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--fe-border-strong);
  border-radius: 8px;
  background: var(--fe-input);
  color: var(--fe-text);
  font: inherit;
  padding: 10px 12px;
  outline: none;
  transition: border-color 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

select {
  color: #4B5660;
}

textarea {
  min-height: 112px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--fe-blue);
  box-shadow: 0 0 0 3px rgba(35, 104, 149, 0.14);
}

.radio-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.radio-option {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  margin: 0;
  padding: 9px 12px;
  border: 1px solid var(--fe-border);
  border-radius: 8px;
  background: #F4F6F8;
  color: #38434E;
  font-weight: 500;
}

.radio-option:has(input:checked) {
  border-color: rgba(35, 104, 149, 0.3);
  background: var(--fe-blue-soft);
  color: var(--fe-blue-dark);
}

.radio-option input {
  width: auto;
  min-height: auto;
}

.help-text {
  margin: 7px 0 0;
  color: var(--fe-muted);
  font-size: 0.82rem;
  line-height: 1.4;
}

.error-text {
  margin: 7px 0 0;
  color: #B42318;
  font-size: 0.82rem;
  line-height: 1.4;
}

.result-panel {
  margin: 22px 0;
  padding: 18px;
  border: 1px solid #D6E2EA;
  border-radius: 10px;
  background: #F8FBFD;
}

.locked-results {
  border-color: #D6E2EA;
  background: #F8FBFD;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.metric {
  min-height: 82px;
  padding: 13px;
  border: 1px solid #E2E9EF;
  border-radius: 8px;
  background: var(--fe-white);
}

.metric span {
  display: block;
  color: var(--fe-muted);
  font-size: 0.78rem;
  line-height: 1.35;
}

.metric strong {
  display: block;
  margin-top: 5px;
  color: var(--fe-blue-dark);
  font-size: 1.08rem;
  line-height: 1.25;
}

.form-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-top: 24px;
}

.primary-button,
.secondary-button {
  padding: 0 18px;
}

.primary-button {
  flex: 1;
  background: var(--fe-blue);
  color: var(--fe-white);
  box-shadow: 0 7px 14px rgba(35, 104, 149, 0.18);
}

.primary-button:disabled {
  cursor: wait;
  opacity: 0.74;
}

.secondary-button {
  border: 1px solid var(--fe-border);
  background: var(--fe-white);
  color: var(--fe-blue-dark);
}

.status-message {
  margin-top: 16px;
  padding: 12px 14px;
  border: 1px solid #CFE2D5;
  border-radius: 8px;
  background: #F2FAF5;
  color: var(--fe-success);
  font-size: 0.92rem;
}

.confirmation-panel {
  padding: 22px;
  border: 1px solid #CFE2D5;
  border-radius: 10px;
  background: #F2FAF5;
}

.confirmation-panel h2 {
  margin: 0 0 8px;
  color: var(--fe-success);
  font-size: 1.28rem;
}

.confirmation-panel p {
  margin: 0;
  color: var(--fe-text);
  line-height: 1.45;
}

.confirmation-panel .reference-line {
  margin-top: 12px;
  color: var(--fe-muted);
  font-size: 0.85rem;
}

.loading-panel {
  margin-top: 46px;
  padding: 32px;
  background: var(--fe-white);
  border: 1px solid var(--fe-border);
  border-radius: 14px;
}

@media (max-width: 820px) {
  .app-shell {
    width: 100%;
  }

  .form-layout {
    padding: 18px 0;
  }

  .form-nav {
    justify-content: stretch;
  }

  .form-nav button {
    flex: 1 1 100%;
    text-align: center;
  }

  .form-content {
    padding: 20px 18px 24px;
  }

  .field.half,
  .field.third {
    grid-column: span 12;
  }

  .radio-row,
  .result-grid {
    grid-template-columns: 1fr;
  }

  .form-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .primary-button,
  .secondary-button {
    width: 100%;
  }
}

.embed-mode {
  font-size: 15px;
}

.embed-mode .form-layout {
  padding: 0;
}

.embed-mode .form-content {
  padding: 0;
}

.embed-mode .form-intro {
  margin-bottom: 14px;
}

.embed-mode .form-intro h1 {
  font-size: 1.38rem;
}

.embed-mode .form-intro p {
  font-size: 0.9rem;
}

.embed-mode .field-grid {
  column-gap: 12px;
  row-gap: 12px;
}

.embed-mode .field-section {
  padding-top: 12px;
}

.embed-mode .field-section h2,
.embed-mode .section-title {
  margin-bottom: 8px;
}

.embed-mode .field.half {
  grid-column: span 6;
}

.embed-mode .field.third {
  grid-column: span 4;
}

.embed-mode .radio-row {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.embed-mode .result-grid {
  grid-template-columns: repeat(3, 1fr);
}

.embed-mode .form-actions {
  align-items: center;
  flex-direction: row;
}

.embed-mode label {
  margin-bottom: 6px;
  font-size: 0.86rem;
}

.embed-mode input,
.embed-mode select,
.embed-mode textarea {
  min-height: 40px;
  padding: 9px 11px;
}

.embed-mode textarea {
  min-height: 96px;
}

.embed-mode .radio-option {
  min-height: 40px;
  padding: 8px 10px;
}

.embed-mode .help-text,
.embed-mode .error-text {
  margin-top: 6px;
  font-size: 0.78rem;
}

.embed-mode .result-panel {
  margin: 18px 0;
  padding: 14px;
}

.embed-mode .metric {
  min-height: 72px;
  padding: 11px;
}

.embed-mode .form-actions {
  margin-top: 20px;
}

@media (max-width: 640px) {
  .embed-mode .field.half,
  .embed-mode .field.third {
    grid-column: span 12;
  }

  .embed-mode .result-grid,
  .embed-mode .radio-row {
    grid-template-columns: 1fr;
  }

  .embed-mode .form-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .embed-mode .primary-button,
  .embed-mode .secondary-button {
    width: 100%;
  }
}
