/* ============================================================
   Firma_OTP.css — Estilos del Módulo Firma Digital OTP
   Usa CSS Variables de iEnTop.css (data-theme)
   ============================================================ */

/* ── Google Fonts ── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ── Base Reset ── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  background: var(--color-bg-primary);
  color: var(--color-text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  transition: background 0.3s ease, color 0.3s ease;
}

/* ── App Shell ── */
.otp-app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ── Header ── */
.otp-header {
  background: var(--color-bg-header);
  border-bottom: 1px solid var(--color-border);
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
}

.otp-header-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.otp-header-brand .brand-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--color-accent), var(--color-accent-hover));
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 18px;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

.otp-header-brand h1 {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--color-text-primary);
  letter-spacing: -0.02em;
}

.otp-header-brand .brand-badge {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 2px 8px;
  border-radius: 20px;
  background: var(--color-accent-subtle);
  color: var(--color-accent);
}

.otp-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.otp-btn-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: 1px solid var(--color-border);
  background: var(--color-bg-secondary);
  color: var(--color-text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
  font-size: 16px;
}

.otp-btn-icon:hover {
  background: var(--color-bg-hover);
  color: var(--color-text-primary);
  border-color: var(--color-accent);
}

/* ── Navigation Tabs ── */
.otp-nav {
  background: var(--color-bg-secondary);
  border-bottom: 1px solid var(--color-border);
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
}

.otp-nav::-webkit-scrollbar { display: none; }

.otp-nav-tab {
  padding: 12px 18px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--color-text-muted);
  cursor: pointer;
  border: none;
  background: none;
  border-bottom: 2px solid transparent;
  transition: var(--transition);
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 8px;
}

.otp-nav-tab:hover {
  color: var(--color-text-primary);
  background: var(--color-bg-hover);
}

.otp-nav-tab.active {
  color: var(--color-accent);
  border-bottom-color: var(--color-accent);
  font-weight: 600;
}

.otp-nav-tab .tab-badge {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 10px;
  background: var(--color-accent);
  color: #fff;
  min-width: 20px;
  text-align: center;
}

/* ── Main Content ── */
.otp-main {
  flex: 1;
  padding: 24px;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
}

/* ── Section Views ── */
.otp-view {
  display: none;
  animation: fadeSlideIn 0.3s ease;
}

.otp-view.active {
  display: block;
}

@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── KPI Cards ── */
.otp-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.otp-kpi-card {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  align-items: flex-start;
  gap: 16px;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.otp-kpi-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--kpi-color, var(--color-accent)), transparent);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.otp-kpi-card:hover {
  border-color: var(--color-accent);
  box-shadow: var(--shadow-card);
  transform: translateY(-2px);
}

.otp-kpi-card:hover::before {
  opacity: 1;
}

.otp-kpi-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

.otp-kpi-icon.blue    { background: rgba(59,130,246,0.12); color: #3b82f6; }
.otp-kpi-icon.green   { background: rgba(34,197,94,0.12);  color: #22c55e; }
.otp-kpi-icon.amber   { background: rgba(245,158,11,0.12); color: #f59e0b; }
.otp-kpi-icon.purple  { background: rgba(168,85,247,0.12); color: #a855f7; }
.otp-kpi-icon.red     { background: rgba(239,68,68,0.12);  color: #ef4444; }
.otp-kpi-icon.cyan    { background: rgba(6,182,212,0.12);  color: #06b6d4; }

.otp-kpi-info {
  flex: 1;
}

.otp-kpi-label {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 4px;
}

.otp-kpi-value {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--color-text-primary);
  line-height: 1;
  margin-bottom: 6px;
}

.otp-kpi-trend {
  font-size: 0.75rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 4px;
}

.otp-kpi-trend.up   { color: #22c55e; }
.otp-kpi-trend.down { color: #ef4444; }

/* ── Document Table ── */
.otp-table-wrap {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  overflow: hidden;
}

.otp-table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--color-border);
  gap: 12px;
  flex-wrap: wrap;
}

.otp-table-toolbar h2 {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--color-text-primary);
}

.otp-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.otp-search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--color-bg-input);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 8px 14px;
  width: 260px;
  transition: var(--transition);
}

.otp-search-box:focus-within {
  border-color: var(--color-border-focus);
  box-shadow: 0 0 0 3px var(--color-accent-subtle);
}

.otp-search-box i { color: var(--color-text-muted); font-size: 14px; }

.otp-search-box input {
  border: none;
  background: transparent;
  outline: none;
  font-size: 0.85rem;
  color: var(--color-text-primary);
  width: 100%;
  font-family: inherit;
}

.otp-search-box input::placeholder {
  color: var(--color-text-muted);
}

.otp-filter-pills {
  display: flex;
  gap: 6px;
  padding: 0 20px 12px;
}

.otp-filter-pill {
  padding: 5px 14px;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 500;
  border: 1px solid var(--color-border);
  background: transparent;
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: var(--transition);
}

.otp-filter-pill:hover {
  background: var(--color-bg-hover);
}

.otp-filter-pill.active {
  background: var(--color-accent);
  color: #fff;
  border-color: var(--color-accent);
}

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

table.otp-table thead th {
  padding: 10px 16px;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  background: var(--color-bg-secondary);
  border-bottom: 1px solid var(--color-border);
}

table.otp-table tbody tr {
  border-bottom: 1px solid var(--color-border);
  transition: var(--transition);
  cursor: pointer;
}

table.otp-table tbody tr:hover {
  background: var(--color-bg-hover);
}

table.otp-table tbody tr:last-child {
  border-bottom: none;
}

table.otp-table tbody td {
  padding: 14px 16px;
  font-size: 0.88rem;
  color: var(--color-text-primary);
  vertical-align: middle;
}

.otp-doc-title-cell {
  display: flex;
  align-items: center;
  gap: 12px;
}

.otp-doc-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.otp-doc-icon.pdf   { background: rgba(239,68,68,0.12);  color: #ef4444; }
.otp-doc-icon.erp   { background: rgba(99,102,241,0.12); color: #6366f1; }

.otp-doc-name {
  font-weight: 600;
  color: var(--color-text-primary);
}

.otp-doc-sub {
  font-size: 0.78rem;
  color: var(--color-text-muted);
  margin-top: 2px;
}

/* ── Status Badges ── */
.otp-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}

.otp-badge.borrador   { background: rgba(148,163,184,0.15); color: #94a3b8; }
.otp-badge.pendiente  { background: rgba(245,158,11,0.15);  color: #f59e0b; }
.otp-badge.en-firma   { background: rgba(59,130,246,0.15);  color: #3b82f6; }
.otp-badge.firmado    { background: rgba(34,197,94,0.15);   color: #22c55e; }
.otp-badge.rechazado  { background: rgba(239,68,68,0.15);   color: #ef4444; }
.otp-badge.expirado   { background: rgba(168,85,247,0.15);  color: #a855f7; }
.otp-badge.cancelado  { background: rgba(107,114,128,0.15); color: #6b7280; }

.otp-badge i { font-size: 10px; }

/* ── Firmantes Avatars ── */
.otp-firmantes-stack {
  display: flex;
  align-items: center;
}

.otp-firmante-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
  color: #fff;
  margin-left: -8px;
  border: 2px solid var(--color-bg-card);
  position: relative;
}

.otp-firmante-avatar:first-child { margin-left: 0; }

.otp-firmante-avatar.signed    { background: #22c55e; }
.otp-firmante-avatar.pending   { background: #f59e0b; }
.otp-firmante-avatar.rejected  { background: #ef4444; }
.otp-firmante-avatar.waiting   { background: #94a3b8; }

.otp-firmantes-count {
  margin-left: 8px;
  font-size: 0.78rem;
  color: var(--color-text-muted);
}

/* ── Buttons ── */
.otp-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius);
  font-size: 0.85rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: var(--transition);
  border: 1px solid transparent;
  text-decoration: none;
}

.otp-btn-primary {
  background: linear-gradient(135deg, var(--color-accent), var(--color-accent-hover));
  color: #fff;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.25);
}

.otp-btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(99, 102, 241, 0.35);
}

.otp-btn-secondary {
  background: var(--color-bg-secondary);
  color: var(--color-text-primary);
  border-color: var(--color-border);
}

.otp-btn-secondary:hover {
  background: var(--color-bg-hover);
  border-color: var(--color-accent);
}

.otp-btn-ghost {
  background: transparent;
  color: var(--color-text-secondary);
  border: none;
  padding: 8px 12px;
}

.otp-btn-ghost:hover {
  color: var(--color-accent);
  background: var(--color-accent-subtle);
}

.otp-btn-danger {
  background: rgba(239,68,68,0.1);
  color: #ef4444;
  border: 1px solid rgba(239,68,68,0.2);
}

.otp-btn-danger:hover {
  background: rgba(239,68,68,0.2);
}

.otp-btn-sm {
  padding: 6px 14px;
  font-size: 0.8rem;
}

/* ── Wizard Stepper ── */
.otp-stepper {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  margin-bottom: 32px;
  padding: 24px 0;
}

.otp-step {
  display: flex;
  align-items: center;
  gap: 10px;
  position: relative;
}

.otp-step-circle {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 700;
  border: 2px solid var(--color-border);
  background: var(--color-bg-secondary);
  color: var(--color-text-muted);
  transition: var(--transition);
  flex-shrink: 0;
}

.otp-step.active .otp-step-circle {
  border-color: var(--color-accent);
  background: var(--color-accent);
  color: #fff;
  box-shadow: 0 0 0 4px var(--color-accent-subtle);
}

.otp-step.completed .otp-step-circle {
  border-color: #22c55e;
  background: #22c55e;
  color: #fff;
}

.otp-step-label {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--color-text-muted);
  transition: var(--transition);
}

.otp-step.active .otp-step-label {
  color: var(--color-accent);
  font-weight: 600;
}

.otp-step.completed .otp-step-label {
  color: #22c55e;
}

.otp-step-line {
  width: 60px;
  height: 2px;
  background: var(--color-border);
  margin: 0 8px;
  transition: var(--transition);
}

.otp-step-line.completed {
  background: #22c55e;
}

/* ── Wizard Content ── */
.otp-wizard-body {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 32px;
}

.otp-wizard-step {
  display: none;
  animation: fadeSlideIn 0.3s ease;
}

.otp-wizard-step.active { display: block; }

.otp-wizard-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--color-border);
}

/* ── Upload Zone ── */
.otp-upload-zone {
  border: 2px dashed var(--color-border);
  border-radius: var(--radius);
  padding: 48px 32px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
}

.otp-upload-zone:hover {
  border-color: var(--color-accent);
  background: var(--color-accent-subtle);
}

.otp-upload-zone.dragover {
  border-color: var(--color-accent);
  background: var(--color-accent-subtle);
  transform: scale(1.01);
}

.otp-upload-zone i {
  font-size: 48px;
  color: var(--color-text-muted);
  margin-bottom: 16px;
  display: block;
}

.otp-upload-zone .upload-title {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--color-text-primary);
  margin-bottom: 6px;
}

.otp-upload-zone .upload-hint {
  font-size: 0.82rem;
  color: var(--color-text-muted);
}

.otp-upload-zone .upload-browse {
  color: var(--color-accent);
  font-weight: 600;
  text-decoration: underline;
}

/* ── Form Controls ── */
.otp-form-group {
  margin-bottom: 20px;
}

.otp-form-label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--color-text-secondary);
  margin-bottom: 6px;
}

.otp-form-input {
  width: 100%;
  padding: 10px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--color-border);
  background: var(--color-bg-input);
  color: var(--color-text-primary);
  font-size: 0.9rem;
  font-family: inherit;
  transition: var(--transition);
  outline: none;
}

.otp-form-input:focus {
  border-color: var(--color-border-focus);
  box-shadow: 0 0 0 3px var(--color-accent-subtle);
}

.otp-form-select {
  width: 100%;
  padding: 10px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--color-border);
  background: var(--color-bg-input);
  color: var(--color-text-primary);
  font-size: 0.9rem;
  font-family: inherit;
  outline: none;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

.otp-form-select:focus {
  border-color: var(--color-border-focus);
  box-shadow: 0 0 0 3px var(--color-accent-subtle);
}

.otp-form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* ── Timeline ── */
.otp-timeline {
  position: relative;
  padding-left: 28px;
}

.otp-timeline::before {
  content: '';
  position: absolute;
  left: 10px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--color-border);
}

.otp-timeline-item {
  position: relative;
  padding-bottom: 20px;
  padding-left: 20px;
}

.otp-timeline-item:last-child { padding-bottom: 0; }

.otp-timeline-dot {
  position: absolute;
  left: -22px;
  top: 3px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid var(--color-bg-card);
  z-index: 1;
}

.otp-timeline-dot.created   { background: #6366f1; }
.otp-timeline-dot.sent      { background: #3b82f6; }
.otp-timeline-dot.viewed    { background: #06b6d4; }
.otp-timeline-dot.otp       { background: #f59e0b; }
.otp-timeline-dot.signed    { background: #22c55e; }
.otp-timeline-dot.rejected  { background: #ef4444; }
.otp-timeline-dot.reminder  { background: #a855f7; }

.otp-timeline-content {
  font-size: 0.85rem;
  color: var(--color-text-primary);
}

.otp-timeline-meta {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  margin-top: 2px;
}

/* ── Detail Panel ── */
.otp-detail-grid {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 24px;
  align-items: flex-start;
}

.otp-detail-pdf {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  min-height: 600px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
}

.otp-detail-pdf canvas,
.otp-detail-pdf iframe {
  width: 100%;
  height: 100%;
  border: none;
}

.otp-detail-sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.otp-detail-card {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 20px;
}

.otp-detail-card h3 {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--color-text-primary);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.otp-detail-card h3 i {
  color: var(--color-accent);
}

/* ── Firmante Row ── */
.otp-firmante-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--color-border);
}

.otp-firmante-row:last-child { border-bottom: none; }

.otp-firmante-row .f-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  flex-shrink: 0;
}

.otp-firmante-row .f-info {
  flex: 1;
}

.otp-firmante-row .f-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-text-primary);
}

.otp-firmante-row .f-email {
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

/* ── Certificate Cards ── */
.otp-cert-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}

.otp-cert-card {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 20px;
  transition: var(--transition);
  position: relative;
}

.otp-cert-card:hover {
  border-color: var(--color-accent);
  box-shadow: var(--shadow-card);
}

.otp-cert-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.otp-cert-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: rgba(34,197,94,0.12);
  color: #22c55e;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

.otp-cert-icon.expired {
  background: rgba(239,68,68,0.12);
  color: #ef4444;
}

.otp-cert-icon.warning {
  background: rgba(245,158,11,0.12);
  color: #f59e0b;
}

.otp-cert-title {
  font-weight: 700;
  color: var(--color-text-primary);
  font-size: 0.95rem;
}

.otp-cert-sub {
  font-size: 0.78rem;
  color: var(--color-text-muted);
}

.otp-cert-details {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 12px;
  font-size: 0.82rem;
}

.otp-cert-details dt {
  color: var(--color-text-muted);
  font-weight: 500;
}

.otp-cert-details dd {
  color: var(--color-text-primary);
  font-weight: 500;
}

/* ── Progress Ring ── */
.otp-ring-container {
  position: relative;
  width: 120px;
  height: 120px;
  margin: 0 auto;
}

.otp-ring-svg {
  transform: rotate(-90deg);
  width: 120px;
  height: 120px;
}

.otp-ring-bg {
  fill: none;
  stroke: var(--color-border);
  stroke-width: 10;
}

.otp-ring-fill {
  fill: none;
  stroke: var(--color-accent);
  stroke-width: 10;
  stroke-linecap: round;
  transition: stroke-dashoffset 1s ease;
}

.otp-ring-label {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
}

.otp-ring-value {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--color-text-primary);
}

.otp-ring-text {
  font-size: 0.7rem;
  color: var(--color-text-muted);
}

/* ── Activity List ── */
.otp-activity-list {
  list-style: none;
}

.otp-activity-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--color-border);
}

.otp-activity-item:last-child { border-bottom: none; }

.otp-activity-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}

.otp-activity-text {
  font-size: 0.85rem;
  color: var(--color-text-primary);
  flex: 1;
}

.otp-activity-time {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  white-space: nowrap;
}

/* ── Empty State ── */
.otp-empty-state {
  text-align: center;
  padding: 60px 20px;
}

.otp-empty-state i {
  font-size: 56px;
  color: var(--color-text-muted);
  margin-bottom: 16px;
  opacity: 0.5;
}

.otp-empty-state h3 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--color-text-primary);
  margin-bottom: 8px;
}

.otp-empty-state p {
  font-size: 0.88rem;
  color: var(--color-text-muted);
  margin-bottom: 24px;
}

/* ── Dashboard Charts Area ── */
.otp-dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 24px;
}

.otp-chart-card {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 20px;
}

.otp-chart-card h3 {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--color-text-primary);
  margin-bottom: 16px;
}

/* ── Responsive ── */
@media (max-width: 1024px) {
  .otp-detail-grid {
    grid-template-columns: 1fr;
  }
  .otp-dashboard-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .otp-header { padding: 0 16px; }
  .otp-main { padding: 16px; }
  .otp-nav { padding: 0 16px; }
  .otp-kpi-grid { grid-template-columns: 1fr 1fr; }
  .otp-form-row { grid-template-columns: 1fr; }
  .otp-stepper {
    flex-direction: column;
    gap: 8px;
  }
  .otp-step-line {
    width: 2px;
    height: 24px;
    margin: 0;
  }
  .otp-wizard-body { padding: 20px; }
  .otp-table-wrap { overflow-x: auto; }
  table.otp-table { min-width: 700px; }
  .otp-search-box { width: 180px; }
  .otp-cert-grid { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .otp-kpi-grid { grid-template-columns: 1fr; }
  .otp-header-brand h1 { font-size: 1rem; }
  .otp-header-brand .brand-badge { display: none; }
}

/* ── Pulsing dot animation ── */
@keyframes pulse-dot {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.5); opacity: 0.5; }
}

.otp-badge.en-firma i {
  animation: pulse-dot 2s ease infinite;
}

/* ── Skeleton Loading ── */
.otp-skeleton {
  background: linear-gradient(90deg,
    var(--color-bg-secondary) 25%,
    var(--color-bg-hover) 50%,
    var(--color-bg-secondary) 75%);
  background-size: 200% 100%;
  animation: skeleton-shine 1.5s infinite;
  border-radius: var(--radius);
}

@keyframes skeleton-shine {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── Tooltip ── */
[data-tooltip] {
  position: relative;
}

[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  padding: 4px 10px;
  border-radius: 6px;
  background: var(--color-bg-primary);
  color: var(--color-text-primary);
  font-size: 0.72rem;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  box-shadow: var(--shadow-card);
  border: 1px solid var(--color-border);
  z-index: 1000;
}

[data-tooltip]:hover::after {
  opacity: 1;
}

/* ── Theme-Selector Mini (in header) ── */
.otp-theme-mini {
  position: relative;
}

.otp-theme-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 12px;
  min-width: 200px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.2);
  display: none;
  z-index: 200;
}

.otp-theme-dropdown.open { display: block; }

.otp-theme-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.82rem;
  color: var(--color-text-secondary);
  transition: var(--transition);
}

.otp-theme-option:hover {
  background: var(--color-bg-hover);
  color: var(--color-text-primary);
}

.otp-theme-option.active {
  background: var(--color-accent-subtle);
  color: var(--color-accent);
}

.otp-theme-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid var(--color-border);
  flex-shrink: 0;
}

/* ══════════════════════════════════════════════════════════════
   PORTAL DEL FIRMANTE — Vista pública simplificada
   Accesible por token único, sin login, mobile-first
   ══════════════════════════════════════════════════════════════ */

.portal-wrapper {
  max-width: 720px;
  margin: 0 auto;
  animation: fadeSlideIn 0.4s ease;
}

/* ── Portal Header ── */
.portal-header {
  text-align: center;
  margin-bottom: 28px;
}

.portal-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 16px;
}

.portal-brand .brand-icon {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--color-accent), var(--color-accent-hover));
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 22px;
  box-shadow: 0 4px 16px rgba(99, 102, 241, 0.3);
}

.portal-brand h2 {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--color-text-primary);
}

.portal-subtitle {
  font-size: 0.88rem;
  color: var(--color-text-muted);
  line-height: 1.5;
}

.portal-sender-info {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  padding: 8px 16px;
  background: var(--color-bg-secondary);
  border-radius: 20px;
  font-size: 0.82rem;
  color: var(--color-text-secondary);
}

.portal-sender-info i {
  color: var(--color-accent);
}

/* ── Portal Main Card ── */
.portal-card {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
}

.portal-card-section {
  padding: 24px;
  border-bottom: 1px solid var(--color-border);
}

.portal-card-section:last-child {
  border-bottom: none;
}

.portal-card-section h3 {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--color-text-primary);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.portal-card-section h3 i {
  color: var(--color-accent);
  font-size: 16px;
}

/* ── PDF Preview en Portal ── */
.portal-pdf-preview {
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  min-height: 360px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 12px;
  position: relative;
}

.portal-pdf-preview i.fa-file-pdf {
  font-size: 56px;
  color: var(--color-text-muted);
  opacity: 0.4;
}

.portal-pdf-preview .pdf-title {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--color-text-primary);
}

.portal-pdf-preview .pdf-pages {
  font-size: 0.78rem;
  color: var(--color-text-muted);
}

.portal-pdf-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 12px;
}

/* ── OTP Input (6 digits) ── */
.portal-otp-section {
  text-align: center;
}

.portal-otp-instruction {
  font-size: 0.88rem;
  color: var(--color-text-secondary);
  margin-bottom: 20px;
  line-height: 1.5;
}

.portal-otp-instruction strong {
  color: var(--color-text-primary);
}

.portal-otp-inputs {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-bottom: 16px;
}

.portal-otp-digit {
  width: 52px;
  height: 60px;
  border-radius: var(--radius);
  border: 2px solid var(--color-border);
  background: var(--color-bg-input);
  color: var(--color-text-primary);
  font-size: 1.5rem;
  font-weight: 800;
  font-family: 'Inter', monospace;
  text-align: center;
  outline: none;
  transition: var(--transition);
  caret-color: var(--color-accent);
}

.portal-otp-digit:focus {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 4px var(--color-accent-subtle);
  transform: translateY(-2px);
}

.portal-otp-digit.filled {
  border-color: var(--color-accent);
  background: var(--color-accent-subtle);
}

.portal-otp-digit.error {
  border-color: #ef4444;
  box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.1);
  animation: shake 0.4s ease;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

.portal-otp-resend {
  font-size: 0.82rem;
  color: var(--color-text-muted);
}

.portal-otp-resend a {
  color: var(--color-accent);
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}

.portal-otp-resend a:hover {
  text-decoration: underline;
}

.portal-otp-timer {
  font-size: 0.78rem;
  color: var(--color-text-muted);
  margin-top: 8px;
}

.portal-otp-timer span {
  font-weight: 700;
  color: var(--color-accent);
  font-family: monospace;
}

/* ── Portal Actions ── */
.portal-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  padding: 24px;
}

.portal-actions .otp-btn {
  min-width: 180px;
  justify-content: center;
  padding: 14px 28px;
  font-size: 0.95rem;
}

/* ── Reject Modal ── */
.portal-reject-area {
  display: none;
  margin-top: 16px;
  animation: fadeSlideIn 0.3s ease;
}

.portal-reject-area.visible {
  display: block;
}

/* ── Portal Success State ── */
.portal-success {
  text-align: center;
  padding: 48px 24px;
}

.portal-success-icon {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: rgba(34, 197, 94, 0.12);
  color: #22c55e;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  margin: 0 auto 20px;
  animation: bounceIn 0.5s ease;
}

@keyframes bounceIn {
  0% { transform: scale(0); opacity: 0; }
  60% { transform: scale(1.15); }
  100% { transform: scale(1); opacity: 1; }
}

.portal-success h3 {
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--color-text-primary);
  margin-bottom: 8px;
}

.portal-success p {
  font-size: 0.88rem;
  color: var(--color-text-muted);
  margin-bottom: 24px;
  line-height: 1.5;
}

/* ── Portal Footer / Legal ── */
.portal-legal {
  text-align: center;
  margin-top: 24px;
  padding: 16px;
  font-size: 0.72rem;
  color: var(--color-text-muted);
  line-height: 1.6;
}

.portal-legal a {
  color: var(--color-accent);
  text-decoration: none;
}

.portal-legal .secure-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
  font-size: 0.75rem;
  color: #22c55e;
  font-weight: 600;
}

/* ── Portal Doc Info Grid ── */
.portal-doc-info {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 16px;
  font-size: 0.85rem;
}

.portal-doc-info dt {
  color: var(--color-text-muted);
  font-weight: 500;
}

.portal-doc-info dd {
  color: var(--color-text-primary);
  font-weight: 500;
}

/* ── Portal Responsive ── */
@media (max-width: 640px) {
  .portal-wrapper {
    padding: 0 8px;
  }
  .portal-otp-digit {
    width: 44px;
    height: 52px;
    font-size: 1.2rem;
  }
  .portal-actions {
    flex-direction: column;
  }
  .portal-actions .otp-btn {
    min-width: 100%;
  }
}
