:root {
  --dl-primary: #4f46e5;
  --dl-primary-hover: #4338ca;
  --dl-primary-light: #eef2ff;
  --dl-bg: #f7f8fb;
  --dl-surface: #ffffff;
  --dl-border: #e5e7eb;
  --dl-text: #111827;
  --dl-text-muted: #6b7280;
  --dl-radius: 10px;
  --dl-radius-sm: 6px;
  --dl-shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.08);

  --dl-success: #15803d;
  --dl-success-bg: #dcfce7;
  --dl-warning: #b45309;
  --dl-warning-bg: #fef3c7;
  --dl-danger: #b91c1c;
  --dl-danger-bg: #fee2e2;
  --dl-info: #1d4ed8;
  --dl-info-bg: #dbeafe;
  --dl-neutral: #4b5563;
  --dl-neutral-bg: #f3f4f6;

  --dl-sidebar-width: 240px;
}

body {
  background-color: var(--dl-bg);
  color: var(--dl-text);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
}

a {
  color: var(--dl-primary);
}

/* ---------- App shell (sidebar layout) ---------- */

.dl-app {
  display: flex;
  min-height: 100vh;
}

.dl-sidebar {
  width: var(--dl-sidebar-width);
  flex-shrink: 0;
  background: var(--dl-surface);
  border-right: 1px solid var(--dl-border);
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  overflow-y: auto;
}

.dl-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--dl-text);
  text-decoration: none;
  padding: 0 8px 18px 8px;
}

.dl-brand .dl-icon {
  color: var(--dl-primary);
}

.dl-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}

.dl-nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--dl-radius-sm);
  color: var(--dl-text-muted);
  text-decoration: none;
  font-size: 0.92rem;
  font-weight: 500;
}

.dl-nav-link:hover {
  background: var(--dl-neutral-bg);
  color: var(--dl-text);
}

.dl-nav-link.active {
  background: var(--dl-primary-light);
  color: var(--dl-primary);
}

.dl-nav-cta {
  margin: 4px 0 14px 0;
}

.dl-sidebar-footer {
  border-top: 1px solid var(--dl-border);
  padding-top: 12px;
  margin-top: 12px;
}

.dl-user {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  font-size: 0.85rem;
  color: var(--dl-text-muted);
}

.dl-main {
  flex: 1;
  min-width: 0;
  margin-left: var(--dl-sidebar-width);
  padding: 28px 32px;
}

/* ---------- Auth / public layout (centered card) ---------- */

.dl-auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.dl-auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--dl-surface);
  border: 1px solid var(--dl-border);
  border-radius: var(--dl-radius);
  box-shadow: var(--dl-shadow);
  padding: 32px;
}

.dl-auth-card.dl-auth-card-wide {
  max-width: 640px;
}

.dl-auth-card.dl-auth-card-wide:has(.dl-doc-preview) {
  max-width: 760px;
}

/* ---------- Visor de documento embebido (firma) ---------- */

.dl-doc-preview {
  border: 1px solid var(--dl-border);
  border-radius: var(--dl-radius);
  overflow: hidden;
  height: 65vh;
  min-height: 420px;
  background: var(--dl-neutral-bg);
}

.dl-doc-preview iframe {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}

/* ---------- Lienzo para dibujar la firma ---------- */

.dl-firma-canvas {
  width: 100%;
  max-width: 600px;
  aspect-ratio: 600 / 220;
  border: 1.5px dashed var(--dl-border);
  border-radius: var(--dl-radius);
  touch-action: none;
  cursor: crosshair;
  background: #fff;
}

.dl-auth-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 1.2rem;
  margin-bottom: 20px;
  color: var(--dl-text);
}

.dl-auth-brand .dl-icon {
  color: var(--dl-primary);
}

/* ---------- Auth split-screen layout (login) ---------- */

.dl-split {
  min-height: 100vh;
  display: flex;
}

.dl-split-panel {
  flex: 1 1 46%;
  max-width: 560px;
  background: linear-gradient(160deg, #4f46e5 0%, #4338ca 55%, #3730a3 100%);
  color: #fff;
  padding: 44px 48px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.dl-split-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.15rem;
  color: #fff;
  text-decoration: none;
}

.dl-split-logo img {
  width: 34px;
  height: 34px;
  border-radius: 8px;
}

.dl-split-illustration {
  display: flex;
  justify-content: center;
  padding: 12px 0;
}

.dl-split-illustration img {
  width: 100%;
  max-width: 320px;
}

.dl-split-copy h2 {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.dl-split-copy p {
  color: rgba(255, 255, 255, 0.8);
  font-size: 0.92rem;
  margin: 0;
}

.dl-split-form {
  flex: 1 1 54%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--dl-bg);
}

.dl-split-form-inner {
  width: 100%;
  max-width: 380px;
}

.dl-split-form-header h1 {
  font-size: 1.6rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.dl-split-form-header p {
  color: var(--dl-text-muted);
  margin-bottom: 28px;
}

.dl-split-mobile-logo {
  display: none;
}

@media (max-width: 860px) {
  .dl-split-panel {
    display: none;
  }

  .dl-split-mobile-logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    margin-bottom: 24px;
    color: var(--dl-text);
  }

  .dl-split-mobile-logo img {
    width: 30px;
    height: 30px;
    border-radius: 7px;
  }
}

/* ---------- Inputs with leading icon ---------- */

.dl-input-group {
  position: relative;
  display: flex;
  align-items: center;
}

.dl-input-group .dl-icon {
  position: absolute;
  top: 50%;
  left: 12px;
  transform: translateY(-50%);
  color: var(--dl-text-muted);
  pointer-events: none;
}

.dl-input-group .form-control {
  padding-left: 38px;
}

.dl-input-toggle {
  position: absolute;
  top: 50%;
  right: 4px;
  transform: translateY(-50%);
  width: 30px;
  height: 30px;
  margin: 0;
  background: none;
  border: none;
  color: var(--dl-text-muted);
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--dl-radius-sm);
  line-height: 1;
  box-sizing: border-box;
}

.dl-input-toggle .dl-icon {
  width: 18px;
  height: 18px;
}

.dl-input-toggle:hover {
  color: var(--dl-text);
  background: var(--dl-neutral-bg);
}

.dl-input-group:has(.dl-input-toggle) .form-control {
  padding-right: 38px;
}

/* ---------- Cards & stat tiles ---------- */

.dl-card {
  background: var(--dl-surface);
  border: 1px solid var(--dl-border);
  border-radius: var(--dl-radius);
  box-shadow: var(--dl-shadow);
  padding: 20px;
}

.dl-stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}

.dl-stat-tile {
  background: var(--dl-surface);
  border: 1px solid var(--dl-border);
  border-radius: var(--dl-radius);
  padding: 16px 18px;
}

.dl-stat-tile .dl-stat-label {
  font-size: 0.82rem;
  color: var(--dl-text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.dl-stat-tile .dl-stat-value {
  font-size: 1.7rem;
  font-weight: 700;
  margin-top: 4px;
}

/* ---------- Status badges ---------- */

.dl-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
}

.dl-badge.status-borrador { color: var(--dl-neutral); background: var(--dl-neutral-bg); }
.dl-badge.status-enprocesodefirma { color: var(--dl-info); background: var(--dl-info-bg); }
.dl-badge.status-pendientedefirma { color: var(--dl-warning); background: var(--dl-warning-bg); }
.dl-badge.status-firmado { color: var(--dl-success); background: var(--dl-success-bg); }
.dl-badge.status-finalizado { color: var(--dl-success); background: var(--dl-success-bg); }
.dl-badge.status-rechazado { color: var(--dl-danger); background: var(--dl-danger-bg); }
.dl-badge.status-anulado { color: var(--dl-neutral); background: var(--dl-neutral-bg); }
.dl-badge.status-pendiente { color: var(--dl-warning); background: var(--dl-warning-bg); }
.dl-badge.dl-badge-neutral { color: var(--dl-neutral); background: var(--dl-neutral-bg); }

/* ---------- Dropzone de archivo (Nuevo documento) ---------- */

.dl-dropzone {
  border: 1.5px dashed var(--dl-border);
  border-radius: var(--dl-radius);
  padding: 28px 20px;
  text-align: center;
  cursor: pointer;
  color: var(--dl-text-muted);
  transition: border-color .15s ease, background-color .15s ease;
}

.dl-dropzone:hover,
.dl-dropzone.is-dragover {
  border-color: var(--dl-primary);
  background: var(--dl-primary-light);
}

.dl-dropzone .dl-icon {
  width: 28px;
  height: 28px;
  color: var(--dl-primary);
  margin-bottom: 6px;
}

.dl-dropzone strong {
  color: var(--dl-text);
}

.dl-file-preview {
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--dl-border);
  border-radius: var(--dl-radius);
  padding: 12px 14px;
}

.dl-file-preview .dl-icon {
  width: 24px;
  height: 24px;
  color: var(--dl-primary);
  flex-shrink: 0;
}

.dl-file-preview-info {
  flex: 1;
  min-width: 0;
}

.dl-file-preview-name {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dl-file-preview-size {
  font-size: 0.8rem;
  color: var(--dl-text-muted);
}

/* ---------- Tarjetas de selección (orden de firma) ---------- */

.dl-choice-card {
  position: relative;
  border: 1.5px solid var(--dl-border);
  border-radius: var(--dl-radius);
  padding: 14px 16px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
  cursor: pointer;
  transition: border-color .15s ease, background-color .15s ease;
}

.dl-choice-card input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.dl-choice-card .dl-icon {
  width: 22px;
  height: 22px;
  color: var(--dl-text-muted);
  flex-shrink: 0;
  margin-top: 2px;
}

.dl-choice-card strong {
  display: block;
}

.dl-choice-card small {
  color: var(--dl-text-muted);
}

.dl-choice-card:has(input:checked) {
  border-color: var(--dl-primary);
  background: var(--dl-primary-light);
}

.dl-choice-card:has(input:checked) .dl-icon {
  color: var(--dl-primary);
}

/* ---------- Filas de participantes ---------- */

.dl-participant-row {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  border: 1px solid var(--dl-border);
  border-radius: var(--dl-radius);
  padding: 12px;
  margin-bottom: 10px;
}

.dl-row-order {
  display: none;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--dl-primary-light);
  color: var(--dl-primary);
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
  flex-shrink: 0;
  margin-top: 3px;
}

#participantes-container.is-secuencial .dl-row-order {
  display: flex;
}

.dl-row-fields {
  flex: 1;
  min-width: 0;
}

.dl-row-error {
  color: var(--dl-danger);
  font-size: 0.8rem;
  margin-top: 4px;
}

.dl-row-actions {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.dl-row-actions .btn {
  padding: 3px 8px;
  line-height: 0;
}

.dl-row-actions .dl-icon {
  width: 15px;
  height: 15px;
}

.dl-row-move {
  display: none;
}

#participantes-container.is-secuencial .dl-row-move {
  display: inline-flex;
}

/* ---------- Buttons / forms refinements ---------- */

.btn-primary {
  background-color: var(--dl-primary);
  border-color: var(--dl-primary);
}

.btn-primary:hover, .btn-primary:focus {
  background-color: var(--dl-primary-hover);
  border-color: var(--dl-primary-hover);
}

.btn-outline-primary {
  color: var(--dl-primary);
  border-color: var(--dl-primary);
}

.btn-outline-primary:hover {
  background-color: var(--dl-primary);
  border-color: var(--dl-primary);
}

.form-control:focus, .form-select:focus {
  border-color: var(--dl-primary);
  box-shadow: 0 0 0 0.2rem var(--dl-primary-light);
}

/* ---------- Tables ---------- */

.dl-table thead th {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--dl-text-muted);
  border-bottom: 1px solid var(--dl-border);
  font-weight: 600;
}

.dl-table td {
  vertical-align: middle;
}

.dl-empty-state {
  text-align: center;
  padding: 48px 16px;
  color: var(--dl-text-muted);
}

/* ---------- Timeline (historial) ---------- */

.dl-timeline {
  list-style: none;
  padding: 0;
  margin: 0;
}

.dl-timeline-item {
  display: flex;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--dl-border);
}

.dl-timeline-item:last-child {
  border-bottom: none;
}

.dl-timeline-icon {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--dl-primary-light);
  color: var(--dl-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.dl-icon {
  width: 1em;
  height: 1em;
}

/* ---------- Wizard-style sections (Create document) ---------- */

.dl-step {
  border: 1px solid var(--dl-border);
  border-radius: var(--dl-radius);
  background: var(--dl-surface);
  padding: 20px;
  margin-bottom: 16px;
}

.dl-step-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  margin-bottom: 14px;
}

.dl-step-number {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--dl-primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  flex-shrink: 0;
}

@media (max-width: 768px) {
  .dl-app {
    flex-direction: column;
  }

  .dl-sidebar {
    width: 100%;
    height: auto;
    position: static;
    flex-direction: row;
    flex-wrap: wrap;
  }

  .dl-nav {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .dl-main {
    margin-left: 0;
    padding: 20px;
  }
}
