:root {
  --portal-blue: #004b8d;
  --portal-blue-dark: #003366;
  --text-main: #1f2937;
  --border-input: #d1d5db;
  --page-bg: #0b1626;
  --page-text: #ffffff;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--page-bg);
  font-family: "Inter", Arial, sans-serif;
  color: var(--page-text);
}

.container {
  max-width: 980px;
  margin: 0 auto;
  padding: 24px 16px 40px;
}

.card {
  background: #ffffff;
  border-radius: 16px;
  box-shadow: 0 8px 28px rgba(0, 40, 80, 0.1);
  overflow: hidden;
  color: var(--text-main);
}

/* —— Encabezado portal (gradiente azul) —— */
.portal-header {
  position: relative;
  background: linear-gradient(135deg, #004b8d 0%, #0066b3 55%, #0077cc 100%);
  color: #ffffff;
  padding: 28px 240px 28px 24px;
  overflow: hidden;
}

.portal-header__content {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 16px;
}

.portal-header__brand {
  flex-shrink: 0;
  display: flex;
  align-items: center;
}

.portal-header__logo {
  display: block;
  height: 64px;
  width: auto;
  max-width: 130px;
  object-fit: contain;
}

.portal-header__text h1 {
  margin: 0 0 6px;
  font-size: 1.55rem;
  font-weight: 700;
  letter-spacing: 0;
  line-height: 1.2;
}

.portal-header__text p {
  margin: 0;
  font-size: 0.92rem;
  opacity: 0.92;
  line-height: 1.4;
}

.portal-header__dots {
  position: absolute;
  top: -20px;
  right: -20px;
  width: 180px;
  height: 180px;
  background-image: radial-gradient(rgba(255, 255, 255, 0.35) 2px, transparent 2px);
  background-size: 14px 14px;
  opacity: 0.5;
  pointer-events: none;
}

.portal-header__super-logo {
  position: absolute;
  z-index: 2;
  top: 24px;
  right: 24px;
  width: min(190px, 24vw);
  height: auto;
  filter: drop-shadow(0 6px 12px rgba(0, 30, 60, 0.18));
  object-fit: contain;
}

#kyc-form {
  padding: 20px 20px 24px;
}

.sarlaft-banner {
  margin: 0 0 24px;
  padding: 16px;
  background: #fef08a;
  color: #004b8d;
  border: 1px solid rgba(0, 75, 141, 0.18);
  border-radius: 8px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.55;
  text-align: justify;
}

/* —— Títulos de sección con badge + icono —— */
.section-header {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--section-bg, #eff6ff);
  border-left: 4px solid var(--section-accent, #2563eb);
  border-radius: 10px;
  margin: 24px 0 16px;
  padding: 12px 14px;
}

.form-section-block:first-child .section-header {
  margin-top: 0;
}

.section-header__badge {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--section-accent, #2563eb);
  color: #ffffff;
  font-weight: 700;
  font-size: 0.95rem;
  display: grid;
  place-items: center;
}

.section-header__title {
  flex: 1;
  font-weight: 700;
  font-size: 1rem;
  color: var(--section-accent, #2563eb);
  line-height: 1.3;
}

.section-header__icon {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  color: var(--section-accent, #2563eb);
  opacity: 0.85;
}

.section-header__svg {
  width: 28px;
  height: 28px;
}

.form-section-block {
  margin-bottom: 4px;
}

.form-section-block.hidden {
  display: none;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
}

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.88rem;
  font-weight: 600;
  color: #374151;
}

.checkbox-group {
  border: none;
  border-radius: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: flex-start;
}

.checkbox-group legend {
  padding: 0;
  margin-bottom: 6px;
  font-size: 0.88rem;
  font-weight: 700;
  color: #374151;
}

.checkbox-group label {
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  font-weight: 500;
  width: 100%;
}

.checkbox-group label input[type="checkbox"] {
  order: -1;
  margin-right: 8px;
  margin-left: 0;
  width: 1.05rem;
  height: 1.05rem;
  accent-color: var(--portal-blue, #004b8d);
}

/* Multiselect customizado (calidadesTributarias) */
.multiselect {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.multiselect-label {
  font-size: 0.88rem;
  font-weight: 700;
  color: #374151;
}

.multiselect-toggle {
  border: 1px solid var(--border-input);
  border-radius: 8px;
  padding: 10px 12px;
  background: #ffffff;
  color: var(--text-main);
  cursor: pointer;
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.multiselect-toggle:after {
  content: "▾";
  margin-left: 8px;
  opacity: 0.6;
  font-size: 0.9rem;
}

.multiselect-options {
  position: absolute;
  z-index: 50;
  left: 0;
  background: #ffffff;
  border: 1px solid var(--border-input);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(2, 6, 23, 0.08);
  padding: 8px;
  top: calc(100% + 6px);
  width: 100%;
  box-sizing: border-box;
}

.multiselect-options label {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  padding: 6px 8px;
  white-space: nowrap;
  width: 100%;
  text-align: left;
}

.multiselect-options input[type="checkbox"] {
  width: 1.05rem;
  height: 1.05rem;
  accent-color: var(--portal-blue, #004b8d);
}

.multiselect-options label:hover {
  background: #2563eb;
  color: #ffffff;
  border-radius: 6px;
}

.multiselect-options label:hover input[type="checkbox"] {
  accent-color: #ffffff;
}

.field-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.field-icon {
  position: absolute;
  left: 12px;
  width: 18px;
  height: 18px;
  color: #94a3b8;
  pointer-events: none;
  z-index: 1;
}

.field-input-wrap input,
.field-input-wrap select,
.field-input-wrap textarea {
  width: 100%;
  padding-left: 38px;
}

.field-input-wrap--file input[type="file"] {
  padding: 8px 8px 8px 38px;
  font-size: 0.82rem;
}

.field-input-wrap textarea {
  min-height: 80px;
  padding-top: 10px;
}

input:not(.field-input-wrap input),
select:not(.field-input-wrap select) {
  width: 100%;
}

input,
select,
button,
textarea {
  font: inherit;
}

input,
select,
textarea {
  border: 1px solid var(--border-input);
  border-radius: 8px;
  padding: 10px 12px;
  background: #ffffff;
  color: var(--text-main);
  transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus,
select:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

input:invalid:focus,
select:invalid:focus {
  border-color: #ef4444;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.12);
}

.help {
  margin-top: 0;
  color: #6b7280;
  font-size: 0.85rem;
}

.checks {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 10px;
}

.check-item {
  padding: 12px 14px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
}

.check-row {
  display: flex !important;
  flex-direction: row !important;
  align-items: flex-start;
  gap: 10px;
  margin: 0;
  font-weight: 400;
  cursor: pointer;
}

.check-row input[type="checkbox"] {
  flex-shrink: 0;
  width: 1.1rem;
  height: 1.1rem;
  margin: 2px 0 0;
  padding: 0;
  accent-color: var(--portal-blue, #004b8d);
}

/* Override global input width for checkbox controls inside custom widgets */
.multiselect-options input[type="checkbox"],
.checkbox-group label input[type="checkbox"],
.check-row input[type="checkbox"] {
  width: 1.05rem;
  height: 1.05rem;
  display: inline-block;
  flex: none;
  order: 0;
  margin: 0 8px 0 0;
  vertical-align: middle;
}

.check-row__text {
  flex: 1;
  min-width: 0;
  line-height: 1.45;
  font-size: 0.88rem;
  color: #374151;
}

.check-row__text .req {
  color: #dc2626;
}

.legal-detail-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin: 6px 0 0 1.65rem;
  padding: 0;
  background: none;
  border: none;
  border-radius: 0;
  color: #2563eb;
  font-size: 0.82rem;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}

.legal-detail-btn:hover {
  opacity: 1;
  color: #1d4ed8;
}

.legal-detail-btn:focus-visible {
  outline: 2px solid #2563eb;
  outline-offset: 2px;
}

/* —— Modal texto legal —— */
body.legal-modal-open {
  overflow: hidden;
}

.legal-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.legal-modal.hidden {
  display: none !important;
}

.legal-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
}

.legal-modal__panel {
  position: relative;
  z-index: 1;
  width: min(640px, 100%);
  max-height: min(85vh, 720px);
  display: flex;
  flex-direction: column;
  background: #ffffff;
  border-radius: 14px;
  box-shadow: 0 20px 50px rgba(0, 40, 80, 0.25);
  overflow: hidden;
  color: var(--text-main);
}

.legal-modal__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  background: linear-gradient(135deg, #004b8d 0%, #0066b3 100%);
  color: #ffffff;
}

.legal-modal__title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.35;
  padding-right: 8px;
}

.legal-modal__close {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  padding: 0;
  border: none;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.15);
  color: #ffffff;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}

.legal-modal__close:hover {
  background: rgba(255, 255, 255, 0.28);
  opacity: 1;
}

.legal-modal__body {
  flex: 1;
  overflow-y: auto;
  padding: 18px 20px;
  font-size: 0.92rem;
  line-height: 1.6;
  color: #334155;
  white-space: pre-wrap;
}

.legal-modal__footer {
  padding: 12px 18px 16px;
  border-top: 1px solid #e2e8f0;
  text-align: right;
}

.legal-modal__close-btn {
  background: #475569;
  min-width: 100px;
}

.legal-modal__close-btn:hover:not(:disabled) {
  opacity: 0.92;
}

h3.section-subtitle {
  margin: 16px 0 8px;
  font-size: 0.95rem;
  font-weight: 600;
  color: #475569;
}

.actions {
  margin-top: 24px;
  display: flex;
  flex-wrap: nowrap;
  gap: 12px;
  align-items: center;
  justify-content: center;
  flex-direction: column;
}

button {
  background: linear-gradient(135deg, #0066b3, #0077cc);
  color: #ffffff;
  border: none;
  border-radius: 8px;
  padding: 11px 18px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}

button:hover:not(:disabled) {
  opacity: 0.92;
}

.secondary {
  background: #475569;
}

button:disabled {
  background: #94a3b8;
  cursor: not-allowed;
}

#statusMsg {
  min-height: 20px;
  margin: 8px 0 0 0;
  font-size: 0.9rem;
  color: #334155;
  flex: none;
  width: 100%;
  text-align: center;
}

/* Hide test/debug buttons in production mode */
.test-buttons-container,
#bypassFilesBtn,
#fillDemoBtn {
  display: none !important;
}

#submitBtn {
  min-width: 340px;
  width: 60%;
  max-width: 780px;
  padding: 14px 22px;
  font-size: 1.02rem;
  border-radius: 10px;
}

@media (max-width: 700px) {
  #submitBtn {
    width: 100%;
    min-width: 0;
  }
  .multiselect-options {
    min-width: 220px;
  }
}

.hidden {
  display: none !important;
}

@media (max-width: 600px) {
  .portal-header__text h1 {
    font-size: 1.12rem;
  }

  .portal-header {
    padding: 20px 16px;
  }

  .portal-header__content {
    flex-direction: column;
    align-items: flex-start;
  }

  .portal-header__super-logo {
    position: relative;
    top: auto;
    right: auto;
    width: min(190px, 100%);
    margin-top: 14px;
  }

  #kyc-form {
    padding: 16px;
  }

  .section-header {
    padding: 10px 12px;
  }

  .section-header__icon {
    display: none;
  }
}

@media (min-width: 601px) and (max-width: 860px) {
  .portal-header {
    padding: 24px;
  }

  .portal-header__super-logo {
    position: relative;
    top: auto;
    right: auto;
    width: 190px;
    margin-top: 16px;
  }
}

/* —— Referencias comerciales: grid de dos columnas (Sección 6) —— */
.ref-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
  margin-top: 6px;
  align-items: start;
  grid-auto-rows: minmax(0, auto);
}

.ref-column {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
}

.ref-header {
  background: #f3f4f6;
  padding: 10px 12px;
  border-radius: 8px;
  font-weight: 700;
  color: #111827;
}

.ref-column label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.88rem;
  font-weight: 600;
  color: #374151;
}

.ref-column input[type="text"],
.ref-column input[type="email"] {
  width: 100%;
  display: block;
  box-sizing: border-box;
  max-height: none;
}

@media (max-width: 800px) {
  .ref-grid {
    grid-template-columns: 1fr;
  }
}

/* —— Autocomplete Buscador CIIU —— */
.autocomplete-wrapper {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
}

.autocomplete-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  width: 100%;
  max-height: 250px;
  overflow-y: auto;
  background: #ffffff;
  border: 1px solid var(--border-input);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(2, 6, 23, 0.12);
  z-index: 100;
}

.autocomplete-item {
  padding: 10px 14px;
  font-size: 0.88rem;
  color: var(--text-main);
  cursor: pointer;
  border-bottom: 1px solid #f1f5f9;
  transition: background 0.15s;
}

.autocomplete-item:last-child {
  border-bottom: none;
}

.autocomplete-item:hover, .autocomplete-item.active {
  background: #eff6ff;
}

.autocomplete-item strong {
  color: #004b8d;
}

.autocomplete-loading {
  padding: 12px 14px;
  font-size: 0.85rem;
  color: #64748b;
  text-align: center;
  font-style: italic;
}

