:host {
  display: block;
  --brand: var(--pg-primary, #1f4fd6);
  --blue: var(--pg-primary-strong, #153caa);
  --focus-ring: var(--pg-focus-ring, 0 0 0 3px rgba(31, 79, 214, 0.22));
}

.lg-backdrop {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(circle at 15% 0%, rgba(31, 79, 214, 0.15), rgba(15, 23, 42, 0.66) 42%),
    rgba(15, 23, 42, 0.58);
  z-index: 9990;
  backdrop-filter: blur(4px);
}

.lg-modal {
  position: fixed;
  inset: 0;
  z-index: 9995;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.lg-modal-card {
  width: min(1040px, 96vw);
  max-height: 92vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  border-radius: 18px;
  border: 1px solid var(--pg-border, #dbe3ef);
  background: #fff;
  box-shadow: var(--pg-shadow-lg, 0 24px 56px rgba(15, 23, 42, 0.25));
  animation: pop-up 0.24s ease;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--pg-border, #dbe3ef);
  background: linear-gradient(180deg, #f4f8ff, #ffffff 85%);
}

.modal-title {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 0.98rem;
  font-weight: 800;
  color: var(--pg-text, #0f172a);

  .icon-bg {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(31, 79, 214, 0.12);
    color: var(--blue);
  }
}

.btn-icon {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid var(--pg-border-strong, #c8d4e4);
  background: #fff;
  color: var(--pg-text-soft, #64748b);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;

  &:hover {
    border-color: var(--brand);
    color: var(--blue);
    transform: translateY(-1px);
  }

  &:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
  }
}

.modal-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px 18px;
  background: linear-gradient(180deg, #f8fbff, #ffffff 82%);
  display: grid;
  gap: 16px;
}

.form-section {
  border: 1px solid var(--pg-border, #dbe3ef);
  border-radius: 14px;
  padding: 12px;
  background: #fff;
  display: grid;
  gap: 12px;
}

.section-head {
  display: grid;
  gap: 3px;

  h4 {
    margin: 0;
    font-size: 0.9rem;
    color: var(--pg-text, #0f172a);
    font-weight: 800;
  }

  small {
    color: var(--pg-text-soft, #64748b);
    font-size: 12px;
    font-weight: 600;
  }
}

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

.form-field {
  display: grid;
  gap: 6px;

  label {
    color: var(--pg-text-soft, #64748b);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 800;
  }

  input {
    height: 40px;
    border-radius: 10px;
    border: 1px solid var(--pg-border-strong, #c8d4e4);
    background: #fff;
    color: var(--pg-text, #0f172a);
    padding: 0 12px;
    font-size: 14px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;

    &:focus {
      outline: none;
      border-color: var(--brand);
      box-shadow: var(--focus-ring);
    }
  }

  .error {
    color: var(--pg-danger, #c52929);
    font-size: 11px;
    font-weight: 700;
  }
}

.competencia-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  align-items: center;
}

.select-glass {
  background: #fff;
  border: 1px solid var(--pg-border-strong, #c8d4e4);
  border-radius: 10px;
  color: var(--pg-text, #0f172a);
  font-weight: 700;
}

.final-box {
  min-height: 40px;
  border-radius: 10px;
  border: 1px dashed var(--pg-border-strong, #c8d4e4);
  background: #f8fbff;
  color: var(--pg-text-muted, #475569);
  padding: 0 12px;
  display: flex;
  align-items: center;
  font-weight: 700;
}

.preview-card {
  border: 1px solid var(--pg-border, #dbe3ef);
  border-radius: 14px;
  padding: 12px;
  display: grid;
  gap: 10px;
  background: #fff;
}

.preview-head h4 {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 800;
  color: var(--pg-text, #0f172a);
}

.preview-head small {
  color: var(--pg-text-soft, #64748b);
  font-size: 12px;
  font-weight: 600;
}

.preview-table {
  border: 1px solid var(--pg-border, #dbe3ef);
  border-radius: 10px;
  max-height: 240px;
  overflow: auto;
}

.preview-table table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  min-width: 460px;
}

.preview-table th,
.preview-table td {
  padding: 8px 10px;
  border-bottom: 1px solid #e9eef6;
  font-size: 12px;
  color: var(--pg-text, #0f172a);
}

.preview-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f5f9ff;
  color: var(--pg-text-soft, #64748b);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 10px;
  font-weight: 800;
}

.preview-table .empty {
  text-align: center;
  color: var(--pg-text-muted, #475569);
  font-weight: 700;
}

.inline-input {
  width: 100%;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--pg-border-strong, #c8d4e4);
  background: #fff;
  color: var(--pg-text, #0f172a);
  text-align: right;
  padding: 0 8px;
  font-size: 12px;

  &:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: var(--focus-ring);
  }
}

.todo-note {
  margin: 0;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid rgba(197, 41, 41, 0.28);
  background: rgba(197, 41, 41, 0.1);
  color: var(--pg-danger, #c52929);
  font-size: 12px;
  font-weight: 700;
}

.modal-footer {
  border-top: 1px solid var(--pg-border, #dbe3ef);
  padding: 12px 18px;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  background: #fff;
}

.btn-primary,
.btn-ghost {
  height: 38px;
  border-radius: 10px;
  border: 1px solid transparent;
  padding: 0 14px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;

  &:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
  }

  &:disabled {
    opacity: 0.62;
    cursor: not-allowed;
  }
}

.btn-primary {
  color: #fff;
  border-color: var(--blue);
  background: linear-gradient(140deg, var(--brand), var(--blue));
  box-shadow: 0 10px 22px rgba(31, 79, 214, 0.28);
}

.btn-ghost {
  color: var(--pg-text, #0f172a);
  background: #fff;
  border-color: var(--pg-border-strong, #c8d4e4);
}

.btn-primary:hover,
.btn-ghost:hover {
  transform: translateY(-1px);
}

.btn-ghost:hover {
  border-color: var(--brand);
  color: var(--blue);
}

@keyframes pop-up {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.98);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@media (max-width: 940px) {
  .form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .modal-header,
  .modal-body,
  .modal-footer {
    padding-left: 12px;
    padding-right: 12px;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .modal-footer {
    justify-content: stretch;
  }

  .modal-footer .btn-primary,
  .modal-footer .btn-ghost {
    flex: 1;
  }
}
