:root {
  --ink: #16343d;
  --text: #39525b;
  --muted: #71858d;
  --line: #d9e8ec;
  --soft: #f4fafb;
  --white: #ffffff;
  --teal: #007f92;
  --teal-dark: #006577;
  --aqua: #19b7c7;
  --green: #73bf43;
  --warning-bg: #fff8e8;
  --warning-line: #efd08a;
  --danger: #c94747;
  --shadow: 0 18px 45px rgba(15, 73, 88, .10);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-height: 100%;
  background: #f7fbfc;
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 12% 0%, rgba(25, 183, 199, .16), transparent 32%),
    linear-gradient(180deg, #ffffff 0%, #eef8fa 100%);
  font-family: "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  font-weight: 300;
  letter-spacing: .01em;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background-image:
    linear-gradient(rgba(0, 127, 146, .045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 127, 146, .045) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, .9), transparent 70%);
}

.shell {
  width: min(1040px, calc(100% - 36px));
  margin: 34px auto 48px;
}

.header,
.panel,
.summary {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, .94);
  box-shadow: var(--shadow);
}

.header {
  padding: 38px clamp(22px, 4vw, 42px) 28px;
  margin-bottom: 18px;
}

.registration-exit {
  position: absolute;
  top: 18px;
  right: 18px;
  z-index: 3;
  min-width: 64px;
  min-height: 32px;
  border: 1px solid #aa3030;
  border-radius: 6px;
  padding: 6px 12px;
  color: #fff;
  background: var(--danger);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0;
  cursor: pointer;
}

.registration-plan-change {
  position: absolute;
  top: 18px;
  right: 96px;
  z-index: 3;
  min-height: 32px;
  border: 1px solid #008b9e;
  border-radius: 6px;
  padding: 6px 12px;
  color: var(--teal);
  background: #e9fbfd;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0;
  cursor: pointer;
}

.registration-plan-change:hover {
  background: #d7f6fa;
}

.registration-exit:hover {
  background: #aa3030;
}

.registration-exit:focus-visible {
  outline: 3px solid rgba(201, 71, 71, .25);
  outline-offset: 2px;
}

.terms-panel {
  padding-top: 70px;
}

.header::after {
  content: "";
  position: absolute;
  right: -80px;
  top: -120px;
  width: 280px;
  height: 280px;
  border-radius: 50%;
  background: rgba(115, 191, 67, .14);
}

.brand {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 26px;
}

.brand img {
  max-width: 168px;
  max-height: 76px;
  object-fit: contain;
}

.header h1,
.panel h1,
.panel h2 {
  margin: 0;
  color: var(--ink);
  font-weight: 300;
  letter-spacing: 0;
}

.header h1 {
  position: relative;
  z-index: 1;
  max-width: 680px;
  font-size: clamp(38px, 6vw, 64px);
  line-height: .95;
}

.header p {
  position: relative;
  z-index: 1;
  max-width: 620px;
  margin: 14px 0 0;
  color: var(--teal);
  font-size: clamp(22px, 3vw, 34px);
  font-weight: 500;
}

.header-footer {
  position: relative;
  z-index: 3;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
}

.header-footer p {
  flex: 1 1 auto;
}

.header-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.header .registration-exit,
.header .registration-plan-change {
  position: static;
}

.panel,
.summary {
  padding: clamp(22px, 3.8vw, 34px);
  margin-bottom: 18px;
}

.panel h1 {
  font-size: clamp(34px, 5vw, 54px);
}

.panel h2 {
  margin: 6px 0 20px;
  color: var(--teal);
  font-size: clamp(22px, 3vw, 32px);
}

.panel h3 {
  margin: 20px 0 10px;
  color: var(--ink);
  font-size: 15px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
}

#rutStep {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 14px;
  margin-bottom: 16px;
}

#rutStep label {
  margin-bottom: 0;
}

#rutStep .btn {
  min-height: 48px;
  align-self: end;
}

.grid {
  display: grid;
  gap: 16px;
}

.grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

label {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .045em;
  text-transform: uppercase;
}

input,
select {
  width: 100%;
  min-height: 48px;
  border: 1px solid #bfd5dc;
  border-radius: 12px;
  padding: 12px 14px;
  color: var(--ink);
  background: #fbfdfe;
  font: 400 16px "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  letter-spacing: 0;
  transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}

input::placeholder {
  color: #9aaab0;
}

input:focus,
select:focus {
  outline: 0;
  border-color: var(--aqua);
  background: var(--white);
  box-shadow: 0 0 0 4px rgba(25, 183, 199, .15);
}

input[readonly] {
  color: #60757c;
  background: #eef6f8;
}

.check {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  margin: 6px 0 0;
  color: var(--text);
  font-size: 14px;
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
}

.check input {
  width: 14px;
  min-width: 14px;
  height: 14px;
  min-height: 14px;
  margin-top: 2px;
  accent-color: var(--teal);
}

.contract-status-row,
.affiliate-status {
  display: flex;
  align-items: center;
  gap: 10px;
}

.contract-status-row {
  margin: 4px 0 18px;
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

.contract-status-row > span,
.affiliate-status > span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
}

.status-pendiente {
  border-color: #e0bd58;
  color: #755800;
  background: #fff8dc;
}

.status-confirmado {
  border-color: #79c5a0;
  color: #17643c;
  background: #e8f8ef;
}

.status-inactivo {
  border-color: #c8d1d5;
  color: #607078;
  background: #edf2f4;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.section-title h2 {
  margin: 0;
}

.affiliate-inline-form {
  margin: 20px 0;
  border: 1px solid #b9dbe1;
  border-radius: 12px;
  padding: clamp(18px, 3vw, 26px);
  background: #f5fbfc;
  box-shadow: inset 4px 0 0 var(--aqua);
}

.affiliate-inline-form:not([hidden]) {
  display: block;
  animation: affiliate-form-open .18s ease-out;
}

@keyframes affiliate-form-open {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.affiliate-form-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 20px;
}

.affiliate-form-heading span {
  display: block;
  margin-bottom: 4px;
  color: var(--teal);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.affiliate-form-heading h3 {
  margin: 0;
  color: var(--ink);
  font-size: 20px;
  font-weight: 500;
}

.affiliate-inline-form .actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  border-top: 1px solid var(--line);
  padding-top: 18px;
}

/* Evita que los estilos generales del formulario deformen el encabezado de Flatpickr. */
.flatpickr-calendar {
  width: 324px;
  max-width: calc(100vw - 32px);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 14px 34px rgba(10, 42, 52, .18);
  font-family: "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

.flatpickr-months {
  min-height: 44px;
}

.flatpickr-months .flatpickr-month {
  height: 44px;
}

.flatpickr-current-month {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: 44px;
  padding-top: 7px;
  font-size: 16px;
}

.flatpickr-current-month .flatpickr-monthDropdown-months,
.flatpickr-current-month input.cur-year {
  width: auto;
  min-width: 0;
  min-height: 30px;
  height: 30px;
  border: 0;
  border-radius: 4px;
  padding: 0 5px;
  color: var(--ink);
  background: transparent;
  box-shadow: none;
  font: inherit;
  line-height: 30px;
  letter-spacing: 0;
  text-transform: none;
}

.flatpickr-current-month .flatpickr-monthDropdown-months {
  max-width: 132px;
}

.flatpickr-current-month .numInputWrapper {
  width: 72px;
  min-width: 72px;
}

.flatpickr-current-month .numInputWrapper span {
  padding: 0;
}

.flatpickr-weekdays {
  height: 32px;
}

.flatpickr-days,
.dayContainer {
  width: 100%;
  min-width: 100%;
  max-width: 100%;
}

.summary {
  display: grid;
  gap: 22px;
  background: linear-gradient(135deg, #ffffff, #f0fbfc);
}

.summary-values {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 24px;
}

.summary.summary-incomplete .summary-values {
  display: none;
}

.summary-values > div {
  display: grid;
  gap: 5px;
}

.summary-values > div > span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.summary-number {
  color: var(--teal);
  font-size: clamp(26px, 4vw, 36px);
  font-weight: 300;
  line-height: 1.1;
  letter-spacing: 0;
}

#totalAmount {
  color: inherit;
  font: inherit;
  line-height: inherit;
  letter-spacing: inherit;
  text-transform: none;
}

.summary-action {
  display: flex;
  justify-content: flex-end;
  border-top: 1px solid var(--line);
  padding-top: 18px;
}

.summary.summary-incomplete .summary-action {
  border-top: 0;
  padding-top: 0;
}

.summary-action .btn {
  width: 100%;
}

.terms-summary {
  margin: 20px 0;
  padding: clamp(20px, 3vw, 28px);
}

.contractor-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 14px;
  margin-top: 20px;
}

.save-status {
  min-height: 20px;
  color: var(--teal-dark);
  font-size: 14px;
  font-weight: 600;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  border: 0;
  border-radius: 999px;
  padding: 0 22px;
  color: #fff;
  background: linear-gradient(135deg, var(--teal), var(--aqua));
  box-shadow: 0 10px 22px rgba(0, 127, 146, .20);
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  transition: transform .16s ease, box-shadow .16s ease, filter .16s ease;
}

.btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 14px 28px rgba(0, 127, 146, .24);
  filter: saturate(1.05);
}

.btn.secondary {
  color: var(--teal);
  background: #e9f7f8;
  box-shadow: none;
}

.btn.danger {
  background: var(--danger);
  box-shadow: 0 10px 20px rgba(201, 71, 71, .18);
}

.btn:disabled {
  color: #eef3f5;
  background: #b8c8ce;
  box-shadow: none;
  cursor: not-allowed;
}

.notice {
  border: 1px solid var(--warning-line);
  border-radius: 14px;
  background: var(--warning-bg);
  color: #6b5205;
  padding: 16px;
  margin: 16px 0 4px;
}

.notice strong {
  color: #4f3c00;
  font-weight: 700;
}

.notice span {
  display: block;
  margin: 5px 0 12px;
  line-height: 1.5;
}

.code-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 10px;
}

.code-row .btn {
  min-height: 48px;
}

.test-code {
  margin: 0 0 14px;
  border: 1px dashed #d2ad45;
  border-radius: 10px;
  padding: 10px 12px;
  background: #fffdf5;
  font-size: 14px;
}

.test-code strong {
  color: var(--teal-dark);
  font-size: 18px;
  letter-spacing: .12em;
}

.otp-group {
  display: grid;
  grid-template-columns: repeat(6, minmax(38px, 1fr));
  gap: 8px;
}

.otp-group .otp-digit {
  min-width: 0;
  height: 48px;
  min-height: 48px;
  padding: 0;
  text-align: center;
  font-size: 22px;
  font-weight: 600;
}

.list.empty {
  color: var(--muted);
  padding: 18px;
  border: 1px dashed #c8dce2;
  border-radius: 14px;
  background: var(--soft);
  text-align: center;
}

.affiliate {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
  margin-top: 12px;
  background: linear-gradient(135deg, #fff, #f7fcfd);
}

.affiliate strong {
  color: var(--ink);
  font-weight: 600;
}

.affiliate span {
  color: var(--muted);
  font-size: 14px;
}

.affiliate-data {
  min-width: 0;
}

.affiliate-status {
  margin-top: 10px;
}

.affiliate .affiliate-status > span {
  font-size: 11px;
  font-weight: 700;
}

.affiliate .status-pendiente {
  color: #755800;
}

.affiliate .status-confirmado {
  color: #17643c;
}

.affiliate .status-inactivo {
  color: #607078;
}

.affiliate > div:last-child {
  display: flex;
  align-items: center;
  gap: 8px;
}

.actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 10px;
}

.terms,
.scroll-box {
  max-height: 290px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px;
  margin-bottom: 18px;
  background: var(--soft);
  line-height: 1.65;
}

.plan-selection-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 18px;
}

.plan-option-card {
  display: grid;
  gap: 14px;
  border: 2px solid var(--line);
  border-radius: 16px;
  padding: 20px;
  color: var(--text);
  background: linear-gradient(135deg, #fff, #f7fcfd);
  box-shadow: 0 12px 26px rgba(15, 73, 88, .08);
  text-decoration: none;
  transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;
}

.plan-option-card:hover {
  border-color: var(--aqua);
  box-shadow: 0 16px 32px rgba(0, 127, 146, .14);
  transform: translateY(-1px);
}

.plan-option-card > strong {
  color: var(--ink);
  font-size: 22px;
  font-weight: 500;
}

.plan-option-subtitle {
  display: block;
  margin-top: -8px;
  color: var(--teal);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0;
}

.plan-option-detail {
  max-height: 260px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  background: var(--soft);
  line-height: 1.55;
}

.plan-option-detail :first-child {
  margin-top: 0;
}

.plan-option-detail :last-child {
  margin-bottom: 0;
}

.plan-option-button {
  justify-self: end;
  display: inline-flex;
  align-items: center;
}

.terms-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

.terms-actions form {
  margin: 0;
}

.terms-actions .btn {
  min-width: 160px;
}

.centered {
  text-align: center;
}

.centered p {
  line-height: 1.65;
}

a {
  color: var(--teal);
  font-weight: 600;
}

@media (max-width: 760px) {
  .shell {
    width: min(100% - 24px, 1040px);
    margin-top: 18px;
  }

  .header,
  .panel,
  .summary {
    border-radius: 15px;
  }

  .brand {
    display: grid;
    justify-items: start;
  }

  .brand img {
    max-width: 150px;
  }

  .header-footer {
    align-items: stretch;
    flex-direction: column;
    gap: 12px;
  }

  .header-footer p {
    margin-bottom: 0;
  }

  .header-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
  }

  .header-actions .registration-exit,
  .header-actions .registration-plan-change {
    width: 100%;
  }

  #rutStep,
  .grid.two,
  .code-row {
    grid-template-columns: 1fr;
  }

  #rutStep .btn,
  .section-title .btn,
  .summary-action .btn,
  .code-row .btn {
    width: 100%;
  }

  .section-title,
  .affiliate {
    align-items: stretch;
    flex-direction: column;
  }

  .affiliate > div:last-child,
  .actions,
  .terms-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .affiliate .btn,
  .actions .btn,
  .terms-actions .btn {
    width: 100%;
  }

  .summary-action,
  .contractor-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .otp-group {
    grid-template-columns: repeat(6, minmax(34px, 1fr));
    gap: 6px;
  }
}

.inline-notice {
  margin: 10px 0 0;
  color: #5f7378;
  font-size: 0.95rem;
  font-weight: 600;
}
