:root {
  color-scheme: light;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #142b4a;
  background: #eaf3fb;
  font-synthesis: none;
}

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

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  min-width: 320px;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 82% 8%, rgb(165 203 235 / 55%), transparent 32%),
    linear-gradient(145deg, #f4f9fd 0%, #dfeefa 100%);
}

button,
input {
  font: inherit;
}

.page {
  width: min(1180px, calc(100% - 40px));
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding: 72px 0 28px;
}

.site-footer {
  width: min(1180px, calc(100% - 40px));
  margin: 18px auto 0;
  padding: 20px 0 28px;
  border-top: 1px solid rgb(111 147 177 / 28%);
  text-align: center;
}

.site-footer a {
  color: #416c91;
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  text-underline-offset: 3px;
}

.site-footer a:hover,
.site-footer a:focus-visible {
  text-decoration: underline;
}

/*
 * Когда все редакторы закрыты, крупные рабочие отступы не нужны.
 * Компактное состояние укладывает интерфейс в один viewport и исключает
 * короткую вертикальную прокрутку. Раскрытые формы по-прежнему растут
 * естественно и остаются полностью доступными.
 */
@media (min-width: 761px) {
  .page {
    padding-top: 24px;
    padding-bottom: 20px;
  }

  .hero {
    margin-bottom: 16px;
    padding: 26px 42px;
    border-radius: 28px;
  }

  .calculator {
    gap: 12px;
  }

  .form-section {
    padding: 22px 32px 24px;
  }

  .section-heading {
    margin-bottom: 16px;
  }

  .result {
    min-height: 92px;
    padding: 18px 32px;
  }

  body:has(#debtor-editor.hidden):has(#contract-editor.hidden):has(
      #parameters-editor-body.hidden
    )
    .page {
    height: auto;
    min-height: calc(100vh - 82px);
    min-height: calc(100dvh - 82px);
  }
}

.hero {
  position: relative;
  margin-bottom: 30px;
  padding: 46px 56px;
  border: 1px solid rgb(255 255 255 / 25%);
  border-radius: 38px;
  background: linear-gradient(135deg, #183b68 0%, #23639b 62%, #3e86bf 100%);
  color: #fff;
  box-shadow: 0 28px 70px rgb(27 70 112 / 22%);
}

.eyebrow {
  display: inline-block;
  margin-bottom: 14px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1 {
  max-width: none;
  margin: 0;
  font-size: clamp(40px, 4.8vw, 72px);
  line-height: 0.94;
  letter-spacing: -0.055em;
  text-align: center;
  white-space: nowrap;
}

.calculation-navigation {
  display: flex;
  width: min(900px, 100%);
  flex-direction: column;
  gap: 8px;
}

.calculation-tabs,
.mode-switch {
  display: flex;
  padding: 5px;
  border-radius: 999px;
}

.calculation-tabs {
  width: 100%;
  background: #e8f1f8;
}

.mode-switch {
  width: 100%;
  border: 1px solid #b9cfe0;
}

.calculation-tab,
.mode-button {
  border-radius: 999px;
  color: #315b7e;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.calculation-tab {
  display: inline-flex;
  min-width: 0;
  min-height: 44px;
  flex: 1;
  align-items: center;
  justify-content: center;
  padding: 8px 14px;
  background: transparent;
  font-size: 13px;
}

.calculation-tab.active {
  background: #1d527f;
  color: #fff;
  box-shadow: 0 5px 14px rgb(26 78 121 / 20%);
}

.calculation-tab:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.mode-button {
  min-height: 44px;
  flex: 1;
  padding: 8px 16px;
  background: transparent;
  font-size: 14px;
}

/*
 * Второй уровень остаётся светлее, чтобы визуально читалась
 * иерархия: тип расчёта → способ ввода.
 */
.mode-switch {
  background: #fff;
}

.mode-button.active {
  background: #e6f0f8;
  color: #17375e;
  box-shadow: inset 0 0 0 1px #c4d8e8;
}

.calculator {
  display: flex;
  overflow: visible;
  flex-direction: column;
  gap: 16px;
  background: transparent;
}

.stage-section {
  padding: 38px 46px 42px;
  border: 1px solid rgb(189 207 221 / 72%);
  border-radius: 24px;
  background: rgb(255 255 255 / 94%);
  box-shadow: 0 12px 32px rgb(36 77 113 / 8%);
}

.stage-heading {
  display: flex;
  align-items: flex-end;
  justify-content: flex-start;
  gap: 24px;
  margin-bottom: 24px;
}

.stage-eyebrow {
  display: block;
  margin-bottom: 3px;
  color: #64809a;
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.stage-heading h2 {
  margin: 0;
  color: #142b4a;
  font-size: 27px;
}

.stage-heading p {
  margin: 0 0 2px auto;
  color: #718095;
  font-size: 13px;
  text-align: right;
}

.stage-selector {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 0;
  padding: 0;
  border: 0;
}

.stage-option {
  position: relative;
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 12px;
  padding: 13px 16px;
  border: 1px solid #d5e2ec;
  border-radius: 16px;
  background: #f8fbfd;
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease,
    box-shadow 160ms ease;
}

.stage-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.stage-option-mark {
  display: grid;
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid #aebfcd;
  border-radius: 50%;
  background: #fff;
}

.stage-option-mark::after {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #fff;
  content: "";
  transform: scale(0);
  transition: transform 160ms ease;
}

.stage-option-copy {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 2px;
}

.stage-option-copy strong {
  color: #1b4168;
  font-size: 15px;
}

.stage-option-copy small {
  color: #718095;
  font-size: 12px;
}

.stage-option:has(input:checked) {
  border-color: #78a8cd;
  background: #eaf4fb;
  box-shadow: inset 0 0 0 1px rgb(120 168 205 / 24%);
}

.stage-option:has(input:checked) .stage-option-mark {
  border-color: #276795;
  background: #276795;
}

.stage-option:has(input:checked) .stage-option-mark::after {
  transform: scale(1);
}

.stage-option:has(input:focus-visible) {
  outline: 2px solid #6ba4cf;
  outline-offset: 2px;
}

.stage-notice {
  margin: 12px 0 0;
  padding: 10px 13px;
  border: 1px solid #ead5a2;
  border-radius: 12px;
  background: #fff8e8;
  color: #80652c;
  font-size: 12px;
}

.judicial-debtor-fields {
  display: flex;
  grid-column: 1 / -1;
  flex-direction: column;
  gap: 3px;
  padding: 13px 15px;
  border: 1px dashed #b8cddd;
  border-radius: 14px;
  background: #f3f8fc;
  color: #315b7e;
}

.judicial-debtor-fields strong {
  font-size: 13px;
}

.judicial-debtor-fields span {
  color: #718095;
  font-size: 12px;
}

.judicial-case-section .section-heading p {
  margin: 5px 0 0;
  color: #718095;
  font-size: 13px;
}

.judicial-case-section > :is(.debtor-card, .section-add-button, .debtor-editor) +
  :is(.debtor-card, .section-add-button, .debtor-editor) {
  margin-top: 18px;
}

.judicial-case-fields {
  gap: 10px 12px;
}

.judicial-case-card {
  grid-template-columns: minmax(280px, 1.2fr) minmax(220px, 1fr) auto auto;
}

.judicial-case-card-meta {
  grid-template-columns: 1fr;
}

.form-section {
  padding: 38px 46px 42px;
  border: 1px solid rgb(189 207 221 / 72%);
  border-radius: 26px;
  background: rgb(255 255 255 / 94%);
  box-shadow: 0 14px 38px rgb(36 77 113 / 9%);
}

.form-section:nth-of-type(even) {
  background: rgb(255 255 255 / 94%);
}

.section-heading {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 24px;
}

.section-number {
  display: inline-flex;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  background: #e5f0f8;
  color: #285f91;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.section-heading h2 {
  margin: 0;
  color: #142b4a;
  font-size: 27px;
  line-height: 1.15;
}

.section-heading p {
  margin: 7px 0 0;
  color: #718095;
  font-size: 14px;
  line-height: 1.4;
}

.debtor-fields {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px 12px;
}

.debtor-editor {
  width: 100%;
  margin-top: 12px;
  padding: 18px;
  border: 1px solid #dce7ef;
  border-radius: 18px;
  background: #fbfcfd;
}

.debtor-name-field {
  grid-column: 1;
}

.debtor-meta-field {
  grid-column: 1;
}

.debtor-fields .field {
  min-height: 64px;
  padding: 8px 16px 9px;
  border-color: #e3eaf0;
  border-radius: 16px;
  background: #f7fafc;
}

.debtor-fields .field:focus-within {
  border-color: #9ab9d1;
  background: #fff;
  box-shadow: 0 0 0 3px rgb(57 121 173 / 7%);
}

.debtor-fields .field > span:first-child {
  margin-bottom: 4px;
  color: #7b8795;
  font-size: 12px;
  font-weight: 400;
}

.debtor-fields .field input {
  color: #29405c;
  font-size: 17px;
  font-weight: 400;
  letter-spacing: -0.01em;
}

.debtor-fields .field input::placeholder {
  color: #a8b1bc;
  font-weight: 400;
  opacity: 1;
}

.debtor-card {
  display: grid;
  width: 100%;
  min-height: 74px;
  grid-template-columns:
    minmax(220px, 300px)
    minmax(360px, 1fr)
    minmax(90px, 1fr)
    auto;
  align-items: center;
  gap: 18px;
  padding: 12px 16px 12px 18px;
  border: 1px solid #bcd7c9;
  border-radius: 16px;
  background: #f3f9f6;
}

.debtor-card-copy,
.debtor-card-meta > span {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 3px;
}

.debtor-card small {
  color: #758b81;
  font-size: 11px;
  font-weight: 400;
}

.debtor-card strong {
  overflow: hidden;
  color: #294b3c;
  font-size: 15px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.debtor-card-meta {
  display: grid;
  min-width: 0;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 18px;
}

.debtor-card-status {
  display: inline-flex;
  align-items: center;
  justify-self: end;
  gap: 7px;
  color: #347255;
  font-size: 12px;
  font-weight: 650;
  white-space: nowrap;
}

.debtor-card-status > span {
  display: inline-flex;
  width: 18px;
  height: 18px;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: #d9eee3;
  font-size: 11px;
}

.compact-edit-button {
  min-height: 36px;
  padding: 8px 12px;
  border: 1px solid #c5dcd1;
  border-radius: 9px;
  background: #fff;
  color: #347255;
  font-size: 12px;
  font-weight: 650;
}

.compact-edit-button:hover {
  background: #e9f4ee;
}

.debtor-card-actions {
  display: flex;
  align-items: center;
  gap: 7px;
}

.compact-delete-button {
  min-height: 36px;
  padding: 8px 12px;
  border: 1px solid #e1cccc;
  border-radius: 9px;
  background: #fff;
  color: #9a5555;
  font-size: 12px;
  font-weight: 650;
}

.compact-delete-button:hover {
  border-color: #d6b3b3;
  background: #fff7f7;
  color: #843d3d;
}

.contract-section-heading {
  align-items: center;
}

.contract-section-heading > div {
  min-width: 0;
}

.section-add-button {
  display: inline-flex;
  width: 210px;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  margin: 12px 0 0;
  padding: 0 18px;
  border: 1px solid #c8d8e5;
  border-radius: 12px;
  background: #f7fafc;
  color: #285f91;
  font-size: 14px;
  font-weight: 650;
  transition:
    border-color 160ms ease,
    background 160ms ease,
    color 160ms ease;
}

.section-add-button:hover {
  border-color: #9ab9d1;
  background: #edf5fa;
  color: #173f69;
}

.contract-list {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.contract-list-item {
  display: grid;
  width: 100%;
  min-height: 74px;
  grid-template-columns: minmax(0, 1fr) 132px 166px;
  align-items: center;
  gap: 14px;
  padding: 12px 16px 12px 18px;
  border: 1px solid #e0e8ef;
  border-radius: 16px;
  background: #f8fafc;
  color: #29405c;
  text-align: left;
  transition:
    border-color 160ms ease,
    background 160ms ease,
    box-shadow 160ms ease;
}

.contract-list-item:hover {
  border-color: #b7cbdb;
  background: #f3f8fb;
}

.contract-list-item.selected {
  outline: 2px solid rgb(57 121 173 / 20%);
  outline-offset: 2px;
}

.contract-list-item.confirmed,
.contract-list-item.confirmed.selected {
  border-color: #bcd7c9;
  background: #f3f9f6;
}

.contract-list-item.unconfirmed,
.contract-list-item.unconfirmed.selected {
  border-color: #eadbbd;
  background: #fff9ed;
}

.contract-list-item.confirmed:hover {
  border-color: #a9cdb9;
  background: #edf7f2;
}

.contract-list-item.unconfirmed:hover {
  border-color: #dfcca5;
  background: #fff6e5;
}

.contract-list-item.confirmed small {
  color: #758b81;
}

.contract-list-item.confirmed strong {
  color: #294b3c;
}

.contract-list-item.unconfirmed small {
  color: #917b59;
}

.contract-list-item.unconfirmed strong {
  color: #59482e;
}

.contract-card-main {
  display: grid;
  min-width: 0;
  grid-template-columns:
    minmax(0, 1.65fr)
    minmax(0, 1fr);
  align-items: center;
  gap: 20px;
  padding: 0;
  background: transparent;
  color: inherit;
  text-align: left;
}

.contract-list-identity {
  display: grid;
  min-width: 0;
  grid-template-columns:
    minmax(0, 1fr)
    minmax(0, 0.95fr)
    minmax(0, 1.2fr);
  align-items: center;
  gap: 20px;
}

.contract-list-copy,
.contract-list-date,
.contract-list-debt,
.contract-list-terms {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 3px;
}

.contract-list-item small {
  color: #8793a0;
  font-size: 11px;
  font-weight: 400;
}

.contract-list-item strong {
  overflow: hidden;
  color: #29405c;
  font-size: 15px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.contract-confirmation-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font-size: 12px;
  font-weight: 650;
  white-space: nowrap;
}

.contract-confirmation-mark > span {
  display: inline-flex;
  width: 17px;
  height: 17px;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 11px;
  line-height: 1;
}

.contract-list-item.confirmed .contract-confirmation-mark {
  color: #347255;
}

.contract-list-item.confirmed .contract-confirmation-mark > span {
  background: #d9eee3;
}

.contract-list-item.unconfirmed .contract-confirmation-mark {
  color: #8b682d;
}

.contract-list-item.unconfirmed .contract-confirmation-mark > span {
  background: #f6e8c9;
}

.contract-card-actions {
  display: flex;
  align-items: center;
  gap: 7px;
}

.parameters-locked {
  position: relative;
}

.parameters-locked .calculation-navigation,
.parameters-locked .fields,
.parameters-locked .complex-panel,
.parameters-locked + .result {
  opacity: 0.46;
}

.parameter-confirm-actions {
  display: flex;
  min-height: 46px;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px solid #e5edf3;
}

.confirm-parameters-button {
  margin: 0;
}

#parameter-confirm-status {
  margin: 0;
  color: #397458;
  font-size: 12px;
}

#parameter-confirm-status.error {
  color: #a04a4a;
}

.confirmed-parameters {
  display: grid;
  width: 100%;
  min-height: 74px;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
  padding: 12px 16px 12px 18px;
  border: 1px solid #c5dcd1;
  border-radius: 16px;
  background: #f3f9f6;
}

.confirmed-parameters .confirmed-parameters-status {
  color: #347255;
}

.confirmed-parameters .confirmed-parameters-status > span {
  background: #d9eee3;
}

.confirmed-parameters-copy {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 5px;
}

.confirmed-parameters-copy small {
  color: #628173;
  font-size: 11px;
  font-weight: 400;
}

.confirmed-parameters-copy strong {
  overflow: hidden;
  color: #234a3a;
  font-size: 15px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.confirmed-parameters-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 7px;
}

#edit-confirmed-parameters:hover {
  background: #e9f4ee;
}

.result.parameters-confirmed,
.result.hide-summary {
  justify-content: flex-end;
  padding-top: 22px;
  padding-bottom: 22px;
}

.result.parameters-confirmed .result-summary,
.result.hide-summary .result-summary {
  display: none;
}

.schedule-views {
  display: flex;
  overflow-x: auto;
  gap: 7px;
  padding: 0 32px 18px;
}

.schedule-view-button {
  flex: 0 0 auto;
  padding: 9px 13px;
  border: 1px solid #d5e2eb;
  border-radius: 10px;
  background: #f7fafc;
  color: #557089;
  font-size: 12px;
  font-weight: 650;
}

.schedule-view-button.active {
  border-color: #9ab9d1;
  background: #e8f1f8;
  color: #245d8c;
}

.contract-editor {
  width: 100%;
  margin-top: 12px;
  padding: 18px;
  border: 1px solid #dce7ef;
  border-radius: 18px;
  background: #fbfcfd;
}

.contract-editor.inline-contract-editor {
  margin-top: 0;
}

.contract-editor-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.contract-editor-head h3 {
  margin: 0;
  color: #29405c;
  font-size: 16px;
  font-weight: 650;
}

.contract-editor-head > span {
  padding: 6px 10px;
  border: 1px solid #d6e3ec;
  border-radius: 9px;
  color: #65809a;
  font-size: 11px;
  font-weight: 550;
}

.contract-fields {
  display: grid;
  grid-template-columns:
    minmax(0, 1.15fr)
    minmax(210px, 0.78fr)
    minmax(210px, 0.78fr);
  gap: 10px;
}

.contract-fields .field {
  min-height: 64px;
  padding: 8px 14px 9px;
  border-color: #e3eaf0;
  border-radius: 14px;
  background: #fff;
}

.contract-fields .field > span:first-child {
  margin-bottom: 4px;
  color: #7b8795;
  font-size: 12px;
  font-weight: 400;
}

.contract-fields .field input {
  color: #29405c;
  font-size: 17px;
  font-weight: 400;
  letter-spacing: -0.01em;
}

.contract-fields .field input::placeholder {
  color: #a8b1bc;
  font-weight: 400;
  opacity: 1;
}

.contract-form-footer {
  display: flex;
  min-height: 34px;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-top: 16px;
}

.contract-form-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.contract-action {
  min-height: 40px;
  padding: 9px 15px;
  border: 1px solid #cad9e4;
  border-radius: 10px;
  background: #fff;
  color: #3f607c;
  font-size: 13px;
  font-weight: 650;
  transition:
    border-color 160ms ease,
    background 160ms ease,
    color 160ms ease;
}

.contract-action:hover {
  border-color: #9fbacd;
  background: #f0f6fa;
  color: #234f77;
}

.contract-action.primary {
  border-color: #1d527f;
  background: #1d527f;
  color: #fff;
}

.contract-action.primary:hover {
  border-color: #2f6f9f;
  background: #2f6f9f;
}

.contract-action.clear-action {
  border-color: #bfd0dc;
  background: #f7fafc;
}

.contract-action.close-action {
  border-color: #d8dfe5;
  color: #697785;
}

.contract-action.close-action:hover {
  border-color: #bcc7d0;
  background: #f5f7f8;
  color: #3f4d59;
}

.contract-form-status {
  margin: 0;
  color: #397458;
  font-size: 12px;
}

.contract-form-status.error {
  color: #a04a4a;
}

.editor-mode-badge {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  padding: 9px 15px;
  border: 1px solid #cad9e4;
  border-radius: 10px;
  background: #f0f6fa;
  color: #557089;
  font-size: 13px;
  font-weight: 650;
  white-space: nowrap;
}

.parameters-section .calculation-navigation {
  width: 100%;
  margin-bottom: 24px;
}

.fields {
  display: grid;
  grid-template-columns: 1.3fr 1fr 1.2fr;
  gap: 12px;
  padding: 0;
}

.advance-payment-fields {
  margin: 0 0 18px;
  padding: 14px;
  border: 1px solid #d8e5ee;
  border-radius: 18px;
  background: #f8fbfd;
}

.advance-payment-fields legend {
  padding: 0 8px;
  color: #315a7d;
  font-size: 14px;
  font-weight: 750;
}

.advance-payment-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

#equal-fields:not(.payment-mode) > .field:first-child {
  order: 1;
}

#equal-fields:not(.payment-mode) #start-date-field {
  order: 2;
}

#equal-fields:not(.payment-mode) #term-field {
  order: 3;
}

#equal-fields.payment-mode #debt-field {
  order: 1;
}

#equal-fields.payment-mode > .field:first-child {
  order: 3;
}

#equal-fields.payment-mode #start-date-field {
  order: 2;
}

.complex-panel {
  padding: 0;
}

.complex-main-fields {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.parameters-editor-body .field {
  min-height: 64px;
  padding: 8px 14px 9px;
  border-radius: 14px;
}

.parameters-editor-body .field > span:first-child {
  margin-bottom: 4px;
  font-size: 12px;
}

.parameters-editor-body .field input,
.parameters-editor-body .field select {
  font-size: 17px;
  font-weight: 500;
}

.parameters-editor-body .input-row {
  gap: 10px;
}

.parameters-editor-body .input-row b {
  font-size: 17px;
}

.joint-panel {
  padding: 0;
}

.joint-panel-intro {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 18px;
  padding: 0 2px;
}

.joint-panel-intro .eyebrow {
  margin-bottom: 5px;
  color: #467598;
}

.joint-panel-intro h3 {
  margin: 0;
  color: #213f60;
  font-size: 20px;
}

.joint-panel-intro p {
  max-width: 410px;
  margin: 0;
  color: #708296;
  font-size: 13px;
  line-height: 1.45;
  text-align: right;
}

.joint-main-fields {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr 1.1fr 1.2fr;
  gap: 14px;
}

.joint-total-field {
  background: #eaf2f8;
}

.joint-total-field input {
  cursor: default;
}

.distribution-settings {
  margin: 24px 0 0;
  padding: 0;
  border: 0;
}

.distribution-settings legend {
  margin-bottom: 10px;
  font-size: 16px;
  font-weight: 750;
}

.distribution-options {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.distribution-option {
  position: relative;
  cursor: pointer;
}

.distribution-option input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.distribution-option > span {
  display: flex;
  min-height: 64px;
  flex-direction: column;
  justify-content: center;
  padding: 10px 14px 10px 44px;
  border: 1px solid #dededa;
  border-radius: 14px;
  background: #fafaf8;
  transition:
    border-color 160ms ease,
    background 160ms ease,
    box-shadow 160ms ease;
}

.distribution-option > span::before {
  position: absolute;
  top: 50%;
  left: 14px;
  width: 18px;
  height: 18px;
  border: 2px solid #aaa;
  border-radius: 50%;
  content: "";
  transform: translateY(-50%);
}

.distribution-option > span::after {
  position: absolute;
  top: 50%;
  left: 19px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #2e302f;
  content: "";
  opacity: 0;
  transform: translateY(-50%) scale(0.6);
  transition:
    opacity 160ms ease,
    transform 160ms ease;
}

.distribution-option input:checked + span {
  border-color: #285f91;
  background: #fff;
  box-shadow: 0 8px 24px rgb(39 90 137 / 12%);
}

.distribution-option input:checked + span::before {
  border-color: #285f91;
}

.distribution-option input:checked + span::after {
  opacity: 1;
  transform: translateY(-50%) scale(1);
}

.distribution-option input:focus-visible + span {
  outline: 3px solid rgb(65 134 191 / 30%);
  outline-offset: 2px;
}

.distribution-option b {
  font-size: 14px;
}

.distribution-option small {
  margin-top: 3px;
  color: #777;
  font-size: 12px;
  line-height: 1.35;
}

.repayments-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin-top: 28px;
}

.repayments-head .eyebrow {
  margin-bottom: 5px;
  color: #2c70a8;
}

.repayments-head h3 {
  margin: 0;
  font-size: 24px;
}

.add-button {
  width: 100%;
  margin-top: 12px;
  min-height: 44px;
  padding: 8px 18px;
  border: 1px dashed #9eb9ce;
  border-radius: 14px;
  background: transparent;
  color: #315b7e;
  font-weight: 700;
  transition:
    border-color 160ms ease,
    background 160ms ease;
}

.add-button:hover {
  border-color: #477fae;
  background: #f0f7fc;
}

.repayments {
  display: flex;
  margin-top: 18px;
  flex-direction: column;
  gap: 12px;
}

.repayment-row {
  padding: 18px;
  border: 1px solid #dbe7f0;
  border-radius: 24px;
  background: #f5f9fc;
}

.repayment-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.repayment-card-title {
  color: #666;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.repayment-fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
}

.repayment-fields .field {
  min-height: 64px;
  border-color: #e8e8e4;
  background: #fff;
}

.remove-repayment {
  display: inline-flex;
  width: 38px;
  height: 38px;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid #dededa;
  border-radius: 12px;
  background: #fff;
  color: #6d6d68;
  transition:
    border-color 160ms ease,
    color 160ms ease,
    background 160ms ease;
}

.remove-repayment:hover {
  border-color: #bababa;
  background: #f2f2ef;
  color: #292927;
}

.remove-repayment svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.field {
  display: flex;
  min-width: 0;
  min-height: 88px;
  flex-direction: column;
  justify-content: center;
  padding: 12px 18px;
  border: 1px solid #dfe9f1;
  border-radius: 17px;
  background: #f2f7fb;
  transition: border-color 160ms ease, background 160ms ease;
}

.field:focus-within {
  border-color: #3979ad;
  background: #fff;
}

.hidden {
  display: none;
}

.field > span:first-child,
.result span {
  margin-bottom: 5px;
  color: #777;
  font-size: 14px;
}

.field input,
.field select {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: #142b4a;
  font-size: 23px;
  font-weight: 600;
}

.field select {
  appearance: none;
  padding-right: 24px;
  background-image:
    linear-gradient(45deg, transparent 50%, #1b1b1b 50%),
    linear-gradient(135deg, #1b1b1b 50%, transparent 50%);
  background-position:
    calc(100% - 13px) 55%,
    calc(100% - 7px) 55%;
  background-repeat: no-repeat;
  background-size: 6px 6px;
  font-size: 18px;
}

.input-row {
  display: flex;
  align-items: center;
  gap: 14px;
}

.input-row b {
  white-space: nowrap;
  font-size: 22px;
}

.result {
  position: relative;
  display: flex;
  min-height: 150px;
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding: 34px 46px;
  border: 1px solid rgb(189 207 221 / 72%);
  border-radius: 26px;
  background: rgb(247 251 254 / 96%);
  box-shadow: 0 14px 38px rgb(36 77 113 / 9%);
}

.result-summary {
  display: flex;
  flex-direction: column;
}

.result strong {
  font-size: clamp(34px, 5vw, 56px);
  line-height: 1;
  letter-spacing: -0.04em;
}

.result small {
  min-height: 17px;
  margin-top: 8px;
  color: #777;
  font-size: 13px;
}

button {
  border: 0;
  cursor: pointer;
}

.interface-controls {
  position: fixed;
  z-index: 20;
  top: 16px;
  right: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.language-switch,
.theme-switch {
  display: flex;
  gap: 3px;
  padding: 4px;
  border: 1px solid #c8d9e6;
  border-radius: 999px;
  background: rgb(255 255 255 / 92%);
  box-shadow: 0 8px 24px rgb(36 77 113 / 12%);
  backdrop-filter: blur(10px);
}

.language-switch button,
.theme-switch button {
  width: 48px;
  min-width: 48px;
  min-height: 34px;
  padding: 0;
  border-radius: 999px;
  background: transparent;
  color: #54708a;
  font-size: 12px;
  font-weight: 800;
}

.language-switch button.active,
.theme-switch button.active {
  background: #205c8d;
  color: #fff;
}

.theme-switch button {
  font-size: 17px;
  line-height: 1;
}

html[data-theme="dark"] {
  color-scheme: dark;
  color: #dce8f4;
  background: #101b28;
}

html[data-theme="dark"] body {
  background:
    radial-gradient(circle at 82% 8%, rgb(35 91 132 / 42%), transparent 34%),
    linear-gradient(145deg, #111d2a 0%, #172b3d 100%);
}

html[data-theme="dark"] :is(.language-switch, .theme-switch) {
  border-color: #3a5368;
  background: rgb(24 39 54 / 94%);
  box-shadow: 0 8px 24px rgb(0 0 0 / 28%);
}

html[data-theme="dark"] :is(.language-switch, .theme-switch) button {
  color: #a9bfd2;
}

html[data-theme="dark"] :is(.language-switch, .theme-switch) button.active {
  background: #4b8fc1;
  color: #fff;
}

html[data-theme="dark"] :is(
  .stage-section,
  .form-section,
  .result,
  .debtor-editor,
  .contract-editor,
  .debtor-card,
  .contract-card,
  .confirmed-parameters,
  .complex-panel,
  .joint-panel,
  .repayment-row,
  dialog
) {
  border-color: #334b60;
  background: rgb(24 39 54 / 96%);
  color: #dce8f4;
  box-shadow: 0 12px 32px rgb(0 0 0 / 20%);
}

html[data-theme="dark"] :is(
  h2,
  h3,
  .stage-heading h2,
  .stage-option-copy strong,
  .section-heading h2,
  .contract-editor-head h3,
  .debtor-card strong,
  .contract-card strong,
  .confirmed-parameters strong,
  .result strong
) {
  color: #e8f2fb;
}

html[data-theme="dark"] .section-number {
  background: #dceaf5;
  color: #274f70;
}

html[data-theme="dark"] :is(
  .stage-option,
  .field,
  .mode-switch,
  .download-format-options,
  .section-add-button,
  .secondary-button,
  .schedule-view-button
) {
  border-color: #3b566d;
  background: #1d3042;
  color: #bdd0df;
}

html[data-theme="dark"] :is(.stage-option:has(input:checked), .mode-button.active) {
  border-color: #5a91bb;
  background: #244762;
  color: #f2f8fc;
}

html[data-theme="dark"] :is(.field:focus-within, .debtor-fields .field:focus-within) {
  border-color: #6598bd;
  background: #263d50;
  box-shadow: 0 0 0 3px rgb(92 153 197 / 12%);
}

html[data-theme="dark"] :is(input, select) {
  color: #edf5fb;
}

html[data-theme="dark"] :is(input, select)::placeholder {
  color: #71889a;
}

html[data-theme="dark"] :is(
  .field > span:first-child,
  .stage-option-copy small,
  .debtor-card small,
  .confirmed-parameters small,
  .result span,
  .result small,
  .download-format-control legend
) {
  color: #91a8bb;
}

html[data-theme="dark"] .site-footer {
  border-color: #334b60;
}

html[data-theme="dark"] .site-footer a {
  color: #8fc1e5;
}

html[data-theme="dark"] dialog::backdrop {
  background: rgb(3 12 21 / 74%);
}

.actions {
  display: grid;
  width: 100%;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  align-items: flex-start;
  gap: 10px;
}

.actions > .secondary-button {
  width: 100%;
  min-width: 0;
}

/* Все четыре итоговых действия должны оставаться однострочными и равными. */
.actions .secondary-button {
  font-size: 15px;
  line-height: 1.15;
  white-space: nowrap;
}

.result-actions {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 8px;
}

.actions > .clear-all-data-button {
  grid-column: 1;
  grid-row: 2;
  width: 100%;
  min-width: 0;
  border: 1px solid #d7a7a7;
  border-radius: 999px;
  background: #fff;
  color: #9b3434;
}


.actions > .clear-all-data-button:hover {
  border-color: #bc7373;
  background: #fff4f4;
}

.actions > .clear-all-data-button:focus-visible {
  outline: 3px solid rgb(188 115 115 / 30%);
  outline-offset: 2px;
}

.download-format-controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: center;
  gap: 18px;
  padding: 10px 12px 4px;
  border-top: 1px solid #d8e5ee;
}

.download-format-control {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 136px;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 0;
  border: 0;
}

.download-format-control legend {
  float: left;
  margin: 0;
  color: #708296;
  font-size: 12px;
  font-weight: 650;
}

.download-format-options {
  position: relative;
  display: grid;
  width: 136px;
  height: 42px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  padding: 4px;
  border: 1px solid #c8d9e6;
  border-radius: 999px;
  background: #e8f1f7;
  box-shadow: inset 0 1px 3px rgb(38 81 116 / 8%);
}

.download-format-options::before {
  position: absolute;
  top: 4px;
  bottom: 4px;
  left: 4px;
  width: calc((100% - 8px) / 2);
  border-radius: 999px;
  background: #1d527f;
  box-shadow: 0 3px 9px rgb(29 82 127 / 24%);
  content: "";
  transition: transform 220ms cubic-bezier(0.22, 0.8, 0.3, 1);
}

.download-format-options:has(label:nth-child(2) input:checked)::before {
  transform: translateX(100%);
}

.download-format-options label {
  position: relative;
  z-index: 1;
  min-width: 0;
  cursor: pointer;
}

.download-format-options input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.download-format-options span {
  display: grid;
  width: 100%;
  height: 100%;
  place-items: center;
  border-radius: 999px;
  color: #557089;
  font-size: 13px;
  font-style: normal;
  font-weight: 800;
  transition: color 180ms ease;
}

.download-format-options input:checked + span {
  color: #fff;
}

.download-format-options label:has(input:focus-visible) {
  outline: 2px solid #6ba4cf;
  outline-offset: 2px;
  border-radius: 999px;
}

.document-format-options span {
  padding: 0 8px;
}

.csv-download-group {
  grid-column: 3 / 5;
  grid-row: 1 / span 2;
  padding: 5px 6px 7px;
  border: 1px solid #c8d9e6;
  border-radius: 30px;
  background: #f5f9fc;
}

.csv-download-buttons {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 5px;
}

.csv-download-buttons .secondary-button {
  width: 100%;
  min-width: 0;
}

.csv-download-buttons .secondary-button {
  border-color: transparent;
}

.result-actions > small {
  position: absolute;
  right: 24px;
  bottom: 14px;
  left: 24px;
  min-height: 17px;
  margin: 0;
  color: #397458;
  font-size: 13px;
  text-align: center;
}

.result-actions > small.error {
  color: #a53a3a;
}

.secondary-button {
  padding: 20px 28px;
  border: 1px solid #b8cfdf;
  border-radius: 999px;
  background: #fff;
  color: #183b68;
  font-size: 18px;
  font-weight: 800;
  transition: transform 160ms ease, background 160ms ease;
}

.secondary-button:hover {
  transform: translateY(-2px);
  background: #edf6fc;
}

.secondary-button:disabled {
  cursor: wait;
  opacity: 0.65;
  transform: none;
}

dialog {
  width: min(720px, calc(100% - 28px));
  max-height: calc(100vh - 40px);
  padding: 0;
  border: 0;
  border-radius: 28px;
  box-shadow: 0 30px 90px rgb(0 0 0 / 25%);
}

dialog::backdrop {
  background: rgb(11 37 64 / 62%);
  backdrop-filter: blur(4px);
}

.dialog-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 30px 32px 22px;
}

.dialog-head .eyebrow {
  margin-bottom: 5px;
  color: #2c70a8;
}

.dialog-head h2 {
  margin: 0;
  font-size: 32px;
}

.close {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: #f0f0ed;
  font-size: 28px;
  line-height: 1;
}

.table-wrap {
  overflow: auto;
  max-height: 60vh;
  padding: 0 32px 32px;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 14px 8px;
  border-bottom: 1px solid #ececea;
  text-align: right;
}

th {
  color: #777;
  font-size: 13px;
}

th:nth-child(1),
th:nth-child(2),
td:nth-child(1),
td:nth-child(2) {
  text-align: left;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

@media (max-width: 760px) {
  .page {
    width: min(100% - 24px, 560px);
    padding-top: 42px;
  }

  .hero {
    margin-bottom: 32px;
  }

  h1 {
    white-space: normal;
  }

  .hero {
    padding: 34px 26px;
  }

  .stage-section {
    padding: 20px;
    border-radius: 20px;
  }

  .stage-heading {
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 12px;
  }

  .stage-heading p {
    width: 100%;
    margin-left: 50px;
    text-align: left;
  }

  .stage-selector {
    grid-template-columns: 1fr;
  }

  .calculation-navigation {
    width: 100%;
  }

  .calculation-tabs {
    width: 100%;
  }

  .calculation-tab {
    flex: 1;
    padding: 11px 8px;
    font-size: 11px;
  }

  .mode-button {
    padding: 11px 10px;
    font-size: 11px;
  }

  .fields {
    grid-template-columns: 1fr;
    padding: 0;
  }

  .complex-panel {
    padding: 0;
  }

  .form-section {
    padding: 28px 20px 32px;
    border-radius: 20px;
  }

  .section-heading {
    gap: 12px;
    margin-bottom: 20px;
  }

  .section-heading h2 {
    font-size: 23px;
  }

  .contract-section-heading {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .contract-section-heading > div {
    flex: 1;
  }

  .section-add-button {
    width: 100%;
    margin: 12px 0 0;
  }

  .contract-list-item {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px 14px;
  }

  .contract-card-main {
    grid-column: 1 / -1;
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
  }

  .debtor-card {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px;
  }

  .debtor-card-meta {
    grid-column: 1 / -1;
  }

  .debtor-card-status {
    grid-column: 1;
  }

  .compact-edit-button {
    grid-row: 1;
    grid-column: 2;
  }

  .debtor-card-actions {
    grid-row: 1;
    grid-column: 2;
  }

  .contract-list-identity {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }

  .contract-list-terms {
    grid-column: 1 / -1;
  }

  .contract-confirmation-mark {
    min-width: 0;
    grid-column: 1;
    justify-self: start;
  }

  .contract-card-actions {
    grid-column: 2;
  }

  .confirmed-parameters {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .confirmed-parameters-copy strong {
    white-space: normal;
  }

  .confirmed-parameters-actions {
    grid-column: 1 / -1;
    justify-content: flex-end;
  }

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

  .confirm-parameters-button {
    width: 100%;
  }

  .contract-editor,
  .debtor-editor {
    padding: 16px;
  }

  .contract-form-footer {
    align-items: flex-start;
    flex-direction: column;
  }

  .contract-form-actions {
    width: 100%;
  }

  .contract-action {
    flex: 1;
  }

  .debtor-fields,
  .judicial-case-fields,
  .contract-fields,
  .complex-main-fields,
  .joint-main-fields,
  .advance-payment-grid,
  .distribution-options {
    grid-template-columns: 1fr;
  }

  .joint-panel-intro {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }

  .joint-panel-intro p {
    max-width: none;
    text-align: left;
  }

  .debtor-name-field,
  .debtor-meta-field {
    grid-column: auto;
  }

  .repayment-row {
    padding: 14px;
  }

  .repayment-fields {
    grid-template-columns: 1fr;
  }

  .repayments-head {
    align-items: stretch;
    flex-direction: column;
    margin-top: 30px;
  }

  .add-button {
    width: 100%;
  }

  .remove-repayment {
    width: 38px;
    min-height: 38px;
  }

  .field {
    min-height: 82px;
  }

  .result {
    align-items: stretch;
    flex-direction: column;
    padding: 26px 20px 20px;
    border-radius: 20px;
  }

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

  .csv-download-group,
  .csv-download-buttons {
    display: flex;
    width: 100%;
    flex-direction: column;
  }

  .csv-download-buttons {
    gap: 8px;
  }

  .result-actions {
    align-items: stretch;
  }

  .download-format-controls {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .download-format-control {
    grid-template-columns: minmax(120px, 1fr) 136px;
  }

  .secondary-button {
    width: 100%;
  }

}

/* Этот слой идёт после адаптивных правил, чтобы светлые стили компонентов
 * не перекрывали тёмную палитру. */
html[data-theme="dark"] .section-number {
  background: #294861;
  color: #c9dfef;
}

html[data-theme="dark"] :is(
  .editor-mode-badge,
  .contract-editor-head > span,
  .contract-action:not(.primary),
  .secondary-button,
  .actions > .clear-all-data-button,
  .csv-download-group,
  .download-format-options,
  .stage-option-mark,
  .close
) {
  border-color: #3d5a70;
  background: #203549;
  color: #b9cede;
  box-shadow: none;
}

html[data-theme="dark"] :is(
  .contract-action:not(.primary):hover,
  .secondary-button:hover,
  .actions > .clear-all-data-button:hover
) {
  border-color: #547a96;
  background: #29465d;
  color: #e5f1f8;
}

html[data-theme="dark"] :is(
  .debtor-fields .field,
  .judicial-case-fields .field,
  .contract-fields .field,
  .parameters-editor-body .field,
  .repayment-fields .field
) {
  border-color: #3b566d;
  background: #1f3447;
}

html[data-theme="dark"] :is(
  .debtor-fields .field:focus-within,
  .judicial-case-fields .field:focus-within,
  .contract-fields .field:focus-within,
  .parameters-editor-body .field:focus-within,
  .repayment-fields .field:focus-within
) {
  border-color: #6598bd;
  background: #29465d;
  box-shadow: 0 0 0 3px rgb(92 153 197 / 12%);
}

html[data-theme="dark"] .download-format-controls {
  border-color: #3a5368;
}

html[data-theme="dark"] .download-format-options::before {
  background: #397caf;
  box-shadow: 0 3px 9px rgb(0 0 0 / 28%);
}

html[data-theme="dark"] .download-format-options span {
  color: #91a9bc;
}

html[data-theme="dark"] .download-format-options input:checked + span {
  color: #fff;
}

html[data-theme="dark"] .secondary-button:disabled {
  border-color: #30495d;
  background: #192c3d;
  color: #6f879a;
}
