:root {
  color-scheme: dark;

  --bg-deep: #0b1220;
  --bg-radial: #132038;

  --accent: #3b82c4;
  --accent-2: #6c6bd6;

  --glass-bg: linear-gradient(160deg, rgba(255, 255, 255, 0.09), rgba(255, 255, 255, 0.02));
  --glass-border: rgba(255, 255, 255, 0.12);
  --glass-shadow: 0 8px 24px rgba(0, 0, 0, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.1);

  --sidebar-bg: linear-gradient(165deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.03));
  --sidebar-border: rgba(255, 255, 255, 0.14);
  --sidebar-shadow: 0 12px 40px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.14);

  --text-primary: #eef2f8;
  --text-secondary: rgba(255, 255, 255, 0.55);
  --text-muted: rgba(255, 255, 255, 0.4);
  --border-soft: rgba(255, 255, 255, 0.12);

  --badge-neutral-bg: rgba(255, 255, 255, 0.1);
  --badge-neutral-fg: rgba(255, 255, 255, 0.75);
  --badge-neutral-border: rgba(255, 255, 255, 0.22);

  --badge-pending-bg: rgba(245, 166, 35, 0.16);
  --badge-pending-fg: #f0a93a;
  --badge-pending-border: rgba(245, 166, 35, 0.38);

  --badge-scanning-bg: rgba(147, 141, 255, 0.18);
  --badge-scanning-fg: #a5a0ff;
  --badge-scanning-border: rgba(147, 141, 255, 0.4);

  --badge-available-bg: rgba(45, 212, 191, 0.16);
  --badge-available-fg: #39d6bd;
  --badge-available-border: rgba(45, 212, 191, 0.4);

  --badge-rejected-bg: rgba(230, 90, 90, 0.16);
  --badge-rejected-fg: #f0797d;
  --badge-rejected-border: rgba(230, 90, 90, 0.38);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  background: radial-gradient(ellipse 120% 80% at 20% 0%, var(--bg-radial) 0%, var(--bg-deep) 55%), var(--bg-deep);
  color: var(--text-primary);
  min-height: 100vh;
}

/* Fondo decorativo: manchas difuminadas animadas */

.bg-decor {
  position: fixed;
  inset: 0;
  overflow: hidden;
  z-index: 0;
  pointer-events: none;
}

.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(65px);
}

.blob-1 {
  top: -120px;
  left: -80px;
  width: 520px;
  height: 520px;
  background: radial-gradient(circle, rgba(59, 130, 196, 0.33), transparent 70%);
  animation: float1 22s ease-in-out infinite;
}

.blob-2 {
  top: 40%;
  right: -140px;
  width: 480px;
  height: 480px;
  background: radial-gradient(circle, rgba(45, 212, 191, 0.3), transparent 70%);
  animation: float2 26s ease-in-out infinite;
}

.blob-3 {
  bottom: -160px;
  left: 30%;
  width: 560px;
  height: 560px;
  background: radial-gradient(circle, rgba(155, 141, 255, 0.27), transparent 70%);
  animation: float3 24s ease-in-out infinite;
}

@keyframes float1 {
  0%, 100% { transform: translate(0, 0); }
  50% { transform: translate(40px, -30px); }
}

@keyframes float2 {
  0%, 100% { transform: translate(0, 0); }
  50% { transform: translate(-50px, 30px); }
}

@keyframes float3 {
  0%, 100% { transform: translate(0, 0); }
  50% { transform: translate(30px, 40px); }
}

/* Shell */

.app-shell {
  position: relative;
  z-index: 1;
  display: flex;
  min-height: 100vh;
  padding: 20px;
  gap: 20px;
}

/* Sidebar */

.sidebar {
  width: 236px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 20px;
  border-radius: 24px;
  background: var(--sidebar-bg);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border: 1px solid var(--sidebar-border);
  box-shadow: var(--sidebar-shadow);
  height: calc(100vh - 40px);
  position: sticky;
  top: 20px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px 24px;
}

.brand-icon {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  border-radius: 11px;
  background: linear-gradient(140deg, var(--accent), var(--accent-2));
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 16px rgba(59, 130, 196, 0.4);
}

.brand-icon-mark {
  width: 20px;
  height: 20px;
  object-fit: contain;
}

.brand-name {
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  line-height: 1.2;
}

.brand-tagline {
  font-size: 11px;
  color: var(--text-secondary);
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border-radius: 13px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 600;
  transition: background 0.2s ease, color 0.2s ease;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
}

.nav-item.active {
  background: rgba(59, 130, 196, 0.22);
  color: #fff;
}

.nav-icon {
  width: 18px;
  height: 18px;
  display: inline-flex;
  flex-shrink: 0;
  color: currentColor;
  opacity: 0.75;
}

.nav-item.active .nav-icon {
  opacity: 1;
}

.nav-icon svg {
  width: 100%;
  height: 100%;
}

.nav-badge {
  margin-left: auto;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: #e5484d;
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 0 2px rgba(229, 72, 77, 0.25), 0 2px 8px rgba(229, 72, 77, 0.55);
  animation: nav-badge-pulse 2.2s ease-in-out infinite;
}

@keyframes nav-badge-pulse {
  0%, 100% {
    box-shadow: 0 0 0 2px rgba(229, 72, 77, 0.25), 0 2px 8px rgba(229, 72, 77, 0.55);
  }
  50% {
    box-shadow: 0 0 0 5px rgba(229, 72, 77, 0.1), 0 2px 12px rgba(229, 72, 77, 0.7);
  }
}

.session-divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.1);
  margin-bottom: 14px;
}

.session-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 10px;
  padding: 0 4px;
}

.session-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 4px;
}

.session-avatar,
.session-avatar-static {
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  border-radius: 50%;
  background: linear-gradient(140deg, var(--accent), var(--accent-2));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
}

.session-avatar {
  position: relative;
  overflow: hidden;
  text-decoration: none;
  transition: box-shadow 0.2s ease;
}

.session-avatar:hover,
.session-avatar:focus-visible {
  box-shadow: 0 0 0 3px rgba(59, 130, 196, 0.35);
  outline: none;
}

.session-avatar-initials,
.session-avatar-gear {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.18s ease;
}

.session-avatar-gear {
  opacity: 0;
}

.session-avatar-gear svg {
  width: 17px;
  height: 17px;
}

.session-avatar:hover .session-avatar-initials,
.session-avatar:focus-visible .session-avatar-initials {
  opacity: 0;
}

.session-avatar:hover .session-avatar-gear,
.session-avatar:focus-visible .session-avatar-gear {
  opacity: 1;
}

.session-info {
  min-width: 0;
}

.session-name {
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.session-company {
  font-size: 11px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.logout-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  padding: 9px 8px;
  border-radius: 11px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 12.5px;
  font-weight: 600;
  transition: background 0.2s ease, color 0.2s ease;
}

.logout-btn:hover {
  background: rgba(230, 90, 90, 0.14);
  color: var(--badge-rejected-fg);
}

.logout-btn .nav-icon {
  opacity: 0.85;
}

/* Content */

.content {
  flex-grow: 1;
  min-width: 0;
  padding: 8px 12px 40px;
  max-width: 1200px;
}

.page-header {
  margin-bottom: 28px;
}

.eyebrow {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--accent);
  text-transform: uppercase;
  margin-bottom: 10px;
}

.page-header h1 {
  font-size: 32px;
  font-weight: 800;
  color: #fff;
  margin: 0 0 8px;
}

.subtitle {
  color: var(--text-secondary);
  margin: 0;
  font-size: 14.5px;
}

/* Stats grid */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 18px;
  margin-bottom: 32px;
}

.stat-card {
  background: var(--glass-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
  border-radius: 20px;
  padding: 22px;
  transition: transform 0.25s ease;
}

.stat-card:hover {
  transform: translateY(-3px);
}

.stat-value {
  font-size: 34px;
  font-weight: 800;
  color: #fff;
  margin-bottom: 10px;
}

.stat-label {
  font-size: 14.5px;
  font-weight: 600;
  color: #fff;
  margin-bottom: 6px;
}

.stat-hint {
  font-size: 12.5px;
  color: var(--text-secondary);
  line-height: 1.4;
}

/* Recent activity */

.section-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 14px;
}

.section-heading h2 {
  font-size: 19px;
  font-weight: 700;
  color: #fff;
  margin: 0;
}

.link-more {
  color: var(--accent);
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  font-family: inherit;
}

.link-more:hover {
  text-decoration: underline;
}

.recent-list {
  background: var(--glass-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
  border-radius: 20px;
  overflow: hidden;
}

.recent-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  gap: 16px;
  flex-wrap: wrap;
  transition: background 0.2s ease;
}

.recent-row:hover {
  background: rgba(255, 255, 255, 0.04);
}

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

.recent-row[hidden] {
  display: none;
}

.cuentas-list .recent-row {
  cursor: pointer;
}

.cuentas-list .recent-row:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.recent-list-clickable .recent-row {
  cursor: pointer;
  color: inherit;
  text-decoration: none;
}

.recent-list-clickable .recent-row:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.recent-codigo {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.recent-remitente {
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  margin-bottom: 3px;
}

.recent-empresa {
  font-size: 12.5px;
  color: var(--text-secondary);
}

.recent-meta {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-shrink: 0;
}

.recent-fecha {
  font-size: 12.5px;
  color: rgba(255, 255, 255, 0.45);
  white-space: nowrap;
}

.empty-state {
  background: var(--glass-bg);
  border: 1px dashed var(--glass-border);
  border-radius: 20px;
  padding: 32px;
  text-align: center;
  color: var(--text-secondary);
}

/* Badges */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  border: 1px solid transparent;
}

.badge-neutral {
  background: var(--badge-neutral-bg);
  color: var(--badge-neutral-fg);
  border-color: var(--badge-neutral-border);
}

.badge-pending {
  background: var(--badge-pending-bg);
  color: var(--badge-pending-fg);
  border-color: var(--badge-pending-border);
}

.badge-scanning {
  background: var(--badge-scanning-bg);
  color: var(--badge-scanning-fg);
  border-color: var(--badge-scanning-border);
}

.badge-available {
  background: var(--badge-available-bg);
  color: var(--badge-available-fg);
  border-color: var(--badge-available-border);
}

.badge-rejected {
  background: var(--badge-rejected-bg);
  color: var(--badge-rejected-fg);
  border-color: var(--badge-rejected-border);
}

/* Toolbar: búsqueda + filtros */

.toolbar {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 16px;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 14px;
  padding: 11px 16px;
  width: 100%;
}

.search-icon {
  width: 16px;
  height: 16px;
  padding: 0;
  border: none;
  background: none;
  color: var(--text-muted);
  display: inline-flex;
  flex-shrink: 0;
  cursor: pointer;
  transition: color 0.2s ease;
}

.search-icon:hover {
  color: var(--accent);
}

.search-icon svg {
  width: 100%;
  height: 100%;
}

.search-box input {
  background: transparent;
  border: none;
  outline: none;
  color: #fff;
  font-family: inherit;
  font-size: 13.5px;
  width: 100%;
}

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

.filter-pills {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 26px;
}

.pill {
  padding: 9px 16px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: rgba(255, 255, 255, 0.65);
  font-size: 12.5px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  transition: opacity 0.2s ease;
}

.pill:hover {
  opacity: 0.85;
}

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

/* Tarjetas de correspondencia */

.corr-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 18px;
}

.corr-card {
  background: var(--glass-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
  border-radius: 20px;
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  cursor: pointer;
  transition: transform 0.25s ease, border-color 0.25s ease;
}

.corr-card:hover {
  transform: translateY(-3px);
  border-color: rgba(255, 255, 255, 0.22);
}

.corr-card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.corr-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.corr-code {
  font-size: 11.5px;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.corr-edited-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(165, 160, 255, 0.16);
  color: var(--badge-scanning-fg);
}

.corr-edited-badge svg {
  width: 11px;
  height: 11px;
}

.corr-title {
  font-size: 16.5px;
  font-weight: 700;
  color: #fff;
  margin: 0 0 4px;
}

.corr-subtitle {
  font-size: 12.5px;
  color: var(--text-secondary);
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.corr-divider {
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  margin: 4px 0;
}

.corr-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.corr-date {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.45);
}

.corr-date-icon {
  width: 14px;
  height: 14px;
  display: inline-flex;
  color: var(--text-muted);
}

.corr-date-icon svg {
  width: 100%;
  height: 100%;
}

.btn-action {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: none;
  border-radius: 11px;
  padding: 9px 14px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: transform 0.2s ease;
}

.btn-action:hover {
  transform: translateY(-1px);
}

.btn-action svg {
  width: 15px;
  height: 15px;
}

.btn-action-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
}

.btn-action-secondary {
  background: rgba(45, 212, 191, 0.18);
  color: #39d6bd;
}

.no-actions {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.35);
}

/* Gestión (admin) */

.gestion-toolbar {
  margin-bottom: 24px;
}

.cuentas-toolbar {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.cuentas-section-title {
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  margin: 32px 0 14px;
}

.cuentas-list {
  margin-bottom: 8px;
}

.checkbox-row {
  margin: 18px 0 4px;
}

/* Vista pública de aprobación de edición */

.edicion-cambios {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 22px;
  width: 100%;
}

.edicion-cambio-row {
  padding: 12px 16px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  text-align: left;
}

.edicion-cambio-valores {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 6px;
  flex-wrap: wrap;
}

.edicion-valor-antes {
  color: var(--text-muted);
  text-decoration: line-through;
  font-size: 13px;
}

.edicion-cambio-flecha {
  color: var(--text-secondary);
}

.edicion-valor-despues {
  color: #fff;
  font-weight: 700;
  font-size: 13.5px;
}

/* Checklist (modal "Aceptar escaneos") */

.checklist {
  max-height: 320px;
  overflow-y: auto;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 14px;
  margin-bottom: 8px;
}

.checklist-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  cursor: pointer;
  font-size: 13.5px;
}

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

.checklist-row:hover {
  background: rgba(255, 255, 255, 0.04);
}

.checklist-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  accent-color: var(--accent);
}

.checklist-row-all {
  padding: 6px 16px 14px;
  font-weight: 700;
  color: var(--text-primary);
}

.checklist-codigo {
  display: block;
  font-weight: 700;
  color: #fff;
}

.checklist-detalle {
  display: block;
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.checklist-standalone {
  max-height: none;
  background: var(--glass-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: var(--glass-shadow);
  margin-bottom: 32px;
}

.checklist-row-fecha {
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  cursor: default;
}

.checklist-row-fecha-input {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.checklist-row-fecha-input .form-input {
  width: auto;
  padding: 8px 10px;
}

.checklist-codigo .badge {
  margin-right: 8px;
  vertical-align: middle;
}

/* Logs de auditoría */

.logs-table-wrap {
  background: var(--glass-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
  border-radius: 20px;
  overflow-x: auto;
}

.logs-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.logs-table th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
  color: var(--text-secondary);
  padding: 14px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  white-space: nowrap;
}

.logs-table td {
  padding: 14px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  color: var(--text-primary);
  vertical-align: top;
  white-space: nowrap;
}

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

.logs-table tbody tr:hover td {
  background: rgba(255, 255, 255, 0.03);
}

.paquete-row {
  cursor: pointer;
}

.logs-detalle {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
  white-space: normal;
}

.logs-dia-count {
  opacity: 0.7;
  font-weight: 500;
}

/* Documentación por empresa */

.doc-search-box {
  margin-bottom: 26px;
}

.doc-empresa-block {
  margin-bottom: 40px;
}

.doc-empresa-title {
  font-size: 21px;
  font-weight: 800;
  color: #fff;
  letter-spacing: 0.02em;
  margin: 0 0 20px;
  padding-bottom: 14px;
  border-bottom: 2px solid rgba(255, 255, 255, 0.14);
}

.doc-section {
  margin-bottom: 22px;
}

.doc-section-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  margin: 0 0 10px;
}

.inline-form {
  display: inline-flex;
}

.corr-bottom-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.btn-action-danger {
  background: rgba(230, 90, 90, 0.16);
  color: var(--badge-rejected-fg);
}

.modal-divider {
  border: none;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  margin: 22px 0;
}

.modal-panel-confirm {
  max-width: 420px;
  text-align: center;
}

.modal-confirm-icon {
  width: 52px;
  height: 52px;
  margin: 4px auto 18px;
  border-radius: 50%;
  background: rgba(230, 90, 90, 0.16);
  color: var(--badge-rejected-fg);
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-confirm-icon svg {
  width: 24px;
  height: 24px;
}

.modal-panel-confirm .modal-title {
  text-align: center;
}

.modal-confirm-text {
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.55;
  margin: 0 0 26px;
}

.modal-confirm-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}

input[type="file"].form-input {
  padding: 10px 14px;
  color: var(--text-secondary);
  font-size: 13px;
}

input[type="file"].form-input::file-selector-button {
  margin-right: 12px;
  padding: 7px 12px;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}

/* Paginación */

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 28px;
}

.page-btn {
  padding: 9px 16px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.2s ease, opacity 0.2s ease;
}

.page-btn:hover {
  background: rgba(255, 255, 255, 0.1);
}

.page-btn.disabled {
  opacity: 0.35;
  pointer-events: none;
}

.page-numbers {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
}

.page-number {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.2s ease, color 0.2s ease;
}

.page-number:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
}

.page-number.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* Modal de detalle de correspondencia */

body.modal-open {
  overflow: hidden;
}

.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(6, 10, 20, 0.6);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  animation: modal-fade 0.2s ease;
}

.modal-overlay.open {
  display: flex;
}

@keyframes modal-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-panel {
  position: relative;
  width: 100%;
  max-width: 540px;
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  padding: 30px;
  border-radius: 24px;
  background: linear-gradient(160deg, rgba(20, 30, 48, 0.95), rgba(11, 18, 32, 0.97));
  border: 1px solid var(--sidebar-border);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.1);
  animation: modal-pop 0.22s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}

@keyframes modal-pop {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-close {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}

.modal-close:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.modal-close svg {
  width: 15px;
  height: 15px;
}

.modal-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-right: 40px;
  margin-bottom: 14px;
}

.modal-title {
  font-size: 22px;
  font-weight: 800;
  color: #fff;
  margin: 0 0 6px;
}

.modal-meta-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin: 22px 0 20px;
}

.modal-meta-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.modal-meta-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.modal-meta-value {
  font-size: 13.5px;
  color: var(--text-primary);
  font-weight: 600;
}

.modal-meta-mono {
  font-family: "SFMono-Regular", Consolas, monospace;
  letter-spacing: 0.02em;
}

.auth-box {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px 18px;
  border-radius: 14px;
  background: rgba(45, 212, 191, 0.07);
  border: 1px solid rgba(45, 212, 191, 0.22);
}

.auth-box-rejected {
  background: rgba(230, 90, 90, 0.08);
  border-color: rgba(230, 90, 90, 0.24);
}

.auth-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.modal-section-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 20px 0 22px;
}

/* Línea de tiempo — vertical y de largo dinámico: va desde los 4 hitos
   mínimos hasta lo que haga falta (ediciones, aprobaciones, rechazos
   intercalados por fecha real), así que crece hacia abajo en vez de
   apretarse en una fila fija. */

.timeline {
  display: flex;
  flex-direction: column;
}

.timeline-step {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding-bottom: 22px;
}

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

/* La línea conectora es un pseudo-elemento del propio .timeline-step (no
   del marker): así "bottom: 0" queda anclado al borde inferior real del
   paso —que incluye el padding-bottom— y la línea llega justo hasta el
   punto del siguiente nodo, en vez de cortarse a mitad de camino. */
.timeline-step::before {
  content: "";
  position: absolute;
  top: 14px;
  bottom: 0;
  left: 6px;
  width: 2px;
  background: rgba(255, 255, 255, 0.14);
}

.timeline-step:last-child::before {
  display: none;
}

.timeline-marker {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex-shrink: 0;
  width: 14px;
}

.timeline-dot {
  position: relative;
  z-index: 1;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--bg-deep);
  border: 2px solid rgba(255, 255, 255, 0.22);
  flex-shrink: 0;
}

.timeline-content {
  flex: 1;
  min-width: 0;
}

.timeline-step.timeline-done .timeline-dot,
.timeline-step.timeline-current .timeline-dot {
  background: var(--accent);
  border-color: var(--accent);
}

.timeline-step.timeline-current .timeline-dot {
  box-shadow: 0 0 0 4px rgba(59, 130, 196, 0.28);
}

.timeline-step.timeline-done::before {
  background: var(--accent);
}

.timeline-step.timeline-rejected .timeline-dot {
  background: var(--badge-rejected-fg);
  border-color: var(--badge-rejected-fg);
  box-shadow: 0 0 0 4px rgba(230, 90, 90, 0.22);
}

.timeline-step.timeline-rejected::before {
  background: var(--badge-rejected-fg);
}

.timeline-step.timeline-stored .timeline-dot {
  background: var(--badge-available-fg);
  border-color: var(--badge-available-fg);
  box-shadow: 0 0 0 4px rgba(45, 212, 191, 0.22);
}

.timeline-step.timeline-stored::before {
  background: var(--badge-available-fg);
}

.timeline-step.timeline-editada .timeline-dot {
  background: var(--badge-scanning-fg);
  border-color: var(--badge-scanning-fg);
  box-shadow: 0 0 0 4px rgba(165, 160, 255, 0.22);
}

.timeline-step.timeline-editada::before {
  background: var(--badge-scanning-fg);
}

.timeline-step.timeline-edicion_pendiente .timeline-dot {
  background: var(--badge-pending-fg);
  border-color: var(--badge-pending-fg);
  box-shadow: 0 0 0 4px rgba(240, 169, 58, 0.22);
}

.timeline-step.timeline-edicion_pendiente::before {
  background: var(--badge-pending-fg);
}

.timeline-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  line-height: 1.3;
}

.timeline-step.timeline-done .timeline-label,
.timeline-step.timeline-current .timeline-label {
  color: #fff;
}

.timeline-step.timeline-rejected .timeline-label {
  color: var(--badge-rejected-fg);
}

.timeline-step.timeline-stored .timeline-label {
  color: var(--badge-available-fg);
}

.timeline-step.timeline-editada .timeline-label {
  color: var(--badge-scanning-fg);
}

.timeline-step.timeline-edicion_pendiente .timeline-label {
  color: var(--badge-pending-fg);
}

.timeline-date {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 2px;
}

.timeline-detail {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 6px;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
}

@media (max-width: 560px) {
  .modal-meta-grid {
    grid-template-columns: 1fr;
  }
}

/* Vista de Ajustes */

.settings-card {
  max-width: 560px;
  background: var(--glass-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
  border-radius: 20px;
  padding: 28px;
}

.settings-card-firma {
  margin-top: 20px;
}

.firma-actual-preview {
  margin: 4px 0 16px;
  padding: 14px 16px;
  border-radius: 12px;
  background: #fff;
  display: inline-block;
  max-width: 100%;
}

.firma-actual-preview img {
  display: block;
  max-width: 220px;
  width: 100%;
  height: auto;
}

.settings-identity {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
}

.settings-name {
  font-size: 15px;
  font-weight: 700;
  color: #fff;
}

.settings-company {
  font-size: 13px;
  color: var(--text-secondary);
}

.form-group {
  margin-bottom: 16px;
}

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

.form-input {
  width: 100%;
  box-sizing: border-box;
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: #fff;
  font-family: inherit;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s ease;
}

.form-input:focus {
  border-color: var(--accent);
}

.form-input::placeholder {
  color: var(--text-muted);
}

select.form-input {
  cursor: pointer;
}

select.form-input option {
  background: var(--bg-deep);
  color: var(--text-primary);
}

select.form-input:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.form-hint {
  font-size: 12.5px;
  color: var(--text-secondary);
  margin: -6px 0 16px;
}

.form-actions {
  margin-top: 22px;
}

.form-actions .btn-action {
  padding: 11px 22px;
  font-size: 13px;
}

.alert {
  border-radius: 14px;
  padding: 14px 18px;
  margin-bottom: 18px;
  font-size: 13.5px;
  max-width: 560px;
}

.alert ul {
  margin: 0;
  padding-left: 18px;
}

.alert-success {
  background: rgba(45, 212, 191, 0.14);
  border: 1px solid rgba(45, 212, 191, 0.35);
  color: #7fe9d9;
}

.alert-error {
  background: rgba(230, 90, 90, 0.14);
  border: 1px solid rgba(230, 90, 90, 0.35);
  color: #f5a3a6;
}

/* Login */

.login-shell {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
}

.login-card {
  width: 420px;
  max-width: 100%;
  padding: 40px;
  border-radius: 28px;
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.03));
  backdrop-filter: blur(28px) saturate(180%);
  -webkit-backdrop-filter: blur(28px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.16);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.18);
}

.login-brand {
  padding: 0;
  margin-bottom: 30px;
}

.login-title {
  font-size: 24px;
  font-weight: 700;
  color: #fff;
  margin: 0 0 6px;
}

.login-subtitle {
  margin-bottom: 26px;
}

.login-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: -4px 0 4px;
}

.login-remember {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
}

.login-remember input {
  accent-color: var(--accent);
}

.login-submit {
  width: 100%;
  justify-content: center;
  padding: 13px;
  font-size: 14px;
}

.login-help {
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
  margin: 22px 0 0;
}

.login-help span {
  color: var(--accent);
  cursor: default;
}

/* Firma de consentimiento */

.firma-card {
  width: 680px;
}

.firma-preview {
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: #525659;
}

.firma-preview iframe {
  width: 100%;
  height: 480px;
  display: block;
  border: none;
}

.firma-preview-fallback {
  display: inline-block;
  margin-top: 8px;
}

.firma-group {
  margin-bottom: 20px;
}

.firma-canvas-wrap {
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.16);
  line-height: 0;
}

#firma-canvas {
  width: 100%;
  height: 180px;
  display: block;
  touch-action: none;
  cursor: crosshair;
}

.firma-limpiar {
  display: inline-block;
  margin-top: 8px;
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
}

/* Responsive */

@media (max-width: 860px) {
  .app-shell {
    flex-direction: column;
    padding: 14px;
    gap: 14px;
  }

  .sidebar {
    width: 100%;
    height: auto;
    position: static;
    display: grid;
    grid-template-columns: 1fr 1fr;
    align-items: start;
    gap: 12px 20px;
  }

  .brand {
    padding: 0 0 16px;
  }

  .nav {
    flex-direction: column;
    flex-wrap: nowrap;
  }

  .session-box {
    margin-left: 0;
  }

  .session-divider {
    display: none;
  }

  .content {
    padding: 8px 4px 32px;
  }
}
