/* ============================================================
   SOKU · Design System
   Paleta: negro #0A0A0A · naranja #F5520C · blanco #FFFFFF
   ============================================================ */

/* ── Brand tokens ── */
:root {
  --soku-black:          #0A0A0A;
  --soku-orange:         #F5520C;
  --soku-orange-dark:    #d94400;
  --soku-orange-light:   #FFF0EB;
  --soku-white:          #FFFFFF;
  --soku-bg:             #F8F8F8;
  --soku-gray:           #6B7280;
  --soku-border:         #E5E7EB;
  --soku-radius:         12px;
  --soku-shadow:         0 1px 3px rgba(0,0,0,0.06);
  --soku-shadow-orange:  0 4px 20px rgba(245,82,12,0.14);
  --soku-focus-ring:     0 0 0 3px rgba(245,82,12,0.15);

  /* Status */
  --green:      #059669;
  --green-bg:   #d1fae5;
  --yellow:     #d97706;
  --yellow-bg:  #fef3c7;
  --red:        #dc2626;
  --red-bg:     #fee2e2;

  /* Semantic aliases — backwards-compatible with class names and
     any JS-injected inline styles that still reference var(--blue) etc. */
  --primary:      var(--soku-orange);
  --blue:         var(--soku-orange);
  --blue-dark:    var(--soku-orange-dark);
  --blue-light:   var(--soku-orange-light);
  --brand:        var(--soku-black);
  --bg:           var(--soku-bg);
  --white:        var(--soku-white);
  --text:         var(--soku-black);
  --muted:        var(--soku-gray);
  --border:       var(--soku-border);
  --shadow:       var(--soku-shadow);
  --radius:       var(--soku-radius);
}

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

/* ── Base ── */
body {
  font-family: 'Montserrat', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--soku-black);
  min-height: 100vh;
}

/* ── Navbar ── */
.app-header {
  background-color: #111111;
  color: var(--soku-white);
  padding: 0 20px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  position: fixed;
  top: 0;
  right: 0;
  left: 0;
  z-index: 100;
  border-bottom: 1px solid #1F1F1F;
  transition: left .25s ease;
}
.app-logo {
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.5px;
  cursor: pointer;
  user-select: none;
}
.app-logo span { color: var(--blue); }
.btn-icon {
  background: rgba(255,255,255,.15);
  border: 1.5px solid rgba(255,255,255,.35);
  color: var(--soku-white);
  font-size: .85rem;
  font-weight: 600;
  cursor: pointer;
  padding: 5px 12px;
  border-radius: 8px;
  line-height: 1.5;
  white-space: nowrap;
  margin-left: auto;
}
.btn-icon:hover { background: rgba(255,255,255,.28); }

/* ── Layout ── */
.main { max-width: 900px; margin: 0 auto; padding: 80px 16px 48px; }

/* ── Cards ── */
.card {
  background: var(--soku-white);
  border-radius: var(--soku-radius);
  box-shadow: var(--soku-shadow);
  padding: 24px;
  margin-bottom: 20px;
}

/* ── Logo preview (config screen) ── */
.logo-preview {
  max-height: 80px;
  max-width: 220px;
  object-fit: contain;
  border-radius: 6px;
  border: 1px solid var(--border);
  padding: 4px;
  background: var(--soku-white);
}


/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 500;
  font-family: 'Montserrat', sans-serif;
  cursor: pointer;
  border: none;
  text-decoration: none;
  transition: background .15s, color .15s, border-color .15s, transform .1s;
  white-space: nowrap;
}
.btn:active  { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }

.btn-primary   { background: #F5520C; color: #fff; font-weight: 600; border: none; }
.btn-primary:hover { background: #d4470a; }
.btn-secondary { background: var(--soku-white); color: #374151; border: 1px solid #E5E7EB; }
.btn-secondary:hover { color: var(--soku-orange); border-color: var(--soku-orange); }
.btn-success   { background: var(--green-bg);  color: var(--green); }
.btn-danger    { background: var(--red-bg);    color: var(--red); }
.btn-white     { background: var(--soku-white); color: #374151; border: 1px solid #E5E7EB; }
.btn-white:hover { color: var(--soku-orange); border-color: var(--soku-orange); }

.btn-lg {
  padding: 12px 24px;
  font-size: .95rem;
  width: 100%;
  justify-content: center;
}
.btn-sm { padding: 5px 10px; font-size: .8rem; }

/* ── Section header ── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 10px;
}
.section-title { font-size: 1.05rem; font-weight: 700; font-family: 'Montserrat', sans-serif; color: #0A0A0A; }

/* ── Worker list ── */
.worker-list { display: flex; flex-direction: column; gap: 10px; }
.worker-item {
  background: var(--soku-white);
  border-radius: 10px;
  border: 1px solid #E5E7EB;
  box-shadow: none;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  cursor: pointer;
  transition: box-shadow 150ms, border-color 150ms;
}
.worker-item:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  border-color: #D1D5DB;
}
.worker-avatar {
  width: 42px; height: 42px;
  border-radius: 50%;
  background: var(--blue-light);
  color: var(--blue);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  font-size: .95rem;
  flex-shrink: 0;
}
.worker-info { flex: 1; min-width: 0; }
.worker-name { font-weight: 600; font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.worker-sub  { font-size: .75rem; color: var(--soku-gray); margin-top: 2px; }
.worker-meta { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }

/* ── Badges ── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 4px;
  font-size: .72rem;
  font-weight: 600;
  white-space: nowrap;
}
.badge-green  { background: var(--green-bg);           color: var(--green); }
.badge-yellow { background: var(--yellow-bg);          color: var(--yellow); }
.badge-orange { background: var(--blue-light);  color: var(--blue); }
/* Aliases kept for JS-generated markup */
.badge-blue { background: #F3F4F6; color: #6B7280; }
.badge-red  { background: var(--red-bg); color: var(--red); }

/* ── Drop zone ── */
.drop-zone {
  border: 2px dashed var(--soku-border);
  border-radius: var(--soku-radius);
  padding: 36px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color .2s, background .2s;
  background: var(--bg);
  user-select: none;
}
.drop-zone:hover, .drop-zone.dragover {
  border-color: var(--blue);
  background: var(--blue-light);
}
.drop-zone-icon { font-size: 2.6rem; margin-bottom: 10px; }
.drop-zone-text { font-size: .95rem; font-weight: 500; color: var(--soku-gray); }
.drop-zone-hint { font-size: .78rem; color: var(--soku-gray); margin-top: 5px; }
input[type="file"] { display: none; }

/* ── Forms ── */
.form-group { margin-bottom: 18px; }
label { display: block; font-size: .82rem; font-weight: 500; margin-bottom: 6px; }
select,
input[type="text"],
input[type="date"],
input[type="tel"],
input[type="email"],
textarea {
  width: 100%;
  padding: 10px 13px;
  border: 1.5px solid var(--soku-border);
  border-radius: 8px;
  font-size: .875rem;
  font-family: inherit;
  background: var(--soku-white);
  color: var(--soku-black);
  transition: border-color .15s;
  -webkit-appearance: none;
}
select:focus, input:focus, textarea:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: var(--soku-focus-ring);
}
textarea { resize: vertical; min-height: 80px; }

/* ── Spinner ── */
.spinner-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 36px 20px;
}
.spinner {
  width: 40px; height: 40px;
  border: 4px solid var(--soku-orange-light);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin .75s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.spinner-text { color: var(--soku-gray); font-size: .875rem; text-align: center; }

/* ── Alerts ── */
.alert {
  padding: 13px 16px;
  border-radius: 8px;
  font-size: .875rem;
  margin-bottom: 14px;
  line-height: 1.5;
}
.alert-error   { background: var(--red-bg);            color: var(--red);         border: 1px solid #fca5a5; }
.alert-success { background: var(--green-bg);          color: var(--green);        border: 1px solid #6ee7b7; }
.alert-info    { background: var(--blue-light); color: var(--blue); border: 1px solid var(--soku-orange-dark); }

/* ── Profile header ── */
.profile-header {
  padding: 20px 0 16px;
  margin-bottom: 20px;
  border-bottom: 1px solid #F3F4F6;
}
.profile-name {
  font-size: 1.4rem;
  font-weight: 700;
  font-family: 'Montserrat', sans-serif;
  color: var(--soku-black);
  line-height: 1.3;
  margin-bottom: 4px;
}
.profile-meta {
  display: flex;
  align-items: center;
  gap: 12px;
}
.profile-sub { font-size: .85rem; color: #9CA3AF; }
/* ── Documents grid ── */
.docs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.doc-card {
  background: var(--soku-white);
  border-radius: 10px;
  border: 1px solid #E5E7EB;
  box-shadow: none;
  padding: 16px 12px;
  text-align: center;
  position: relative;
  display: flex;
  flex-direction: column;
}
.doc-card-missing {
  background: #FAFAFA;
  border: 1px dashed #E5E7EB;
  opacity: .7;
  box-shadow: none;
}
.doc-dot { position: absolute; top: 10px; right: 10px; width: 9px; height: 9px; border-radius: 50%; }
.dot-green { background: var(--green); }
.dot-red   { background: var(--red); }
.doc-icon  { margin-bottom: 7px; color: var(--soku-gray); line-height: 0; }
.doc-type  { font-size: .76rem; font-weight: 600; margin-bottom: 3px; }
.doc-file  { font-size: .68rem; color: var(--soku-gray); word-break: break-all; line-height: 1.3; }
.doc-card-footer { margin-top: auto; text-align: center; }
.doc-date  { font-size: .67rem; color: var(--soku-gray); margin-top: 4px; }
.doc-missing-label { font-size: .72rem; color: var(--red); margin-top: 4px; }
.doc-curso {
  display: inline-block;
  margin-top: 5px;
  padding: 2px 7px;
  border-radius: 10px;
  background: var(--blue-light);
  color: var(--blue);
  font-size: .67rem;
  font-weight: 600;
  line-height: 1.4;
}
.doc-multi-dot {
  position: absolute;
  top: 10px; left: 10px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--soku-orange);
  color: var(--soku-white);
  font-size: .6rem;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.btn-analizar {
  display: inline-block;
  margin-top: 6px;
  padding: 3px 9px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--soku-white);
  color: var(--soku-gray);
  font-size: .68rem;
  cursor: pointer;
}
.btn-analizar:hover:not(:disabled) {
  background: var(--blue-light);
  color: var(--blue);
  border-color: var(--blue);
}
.btn-analizar:disabled { opacity: .5; cursor: default; }

/* ── EPI list ── */
.epi-list { display: flex; flex-direction: column; gap: 8px; }
.epi-row  { display: flex; gap: 8px; align-items: center; }
.epi-row input { flex: 1; }
.epi-row .btn  { padding: 9px 13px; flex-shrink: 0; }

/* ── EPI form table ── */
.epi-form-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.epi-form-table th {
  background: var(--bg);
  padding: 6px 8px;
  text-align: left;
  font-weight: 600;
  border-bottom: 2px solid var(--soku-border);
}
.epi-form-table td { padding: 4px 6px; border-bottom: 1px solid var(--soku-border); }
.epi-form-table td:first-child input { width: 100%; }
.epi-form-table td:nth-child(2) input,
.epi-form-table td:nth-child(3) input { width: 80px; }

/* ── Back button ── */
.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--soku-gray);
  font-size: .82rem;
  cursor: pointer;
  margin-bottom: 14px;
  background: none;
  border: none;
  font-family: inherit;
  padding: 0;
  transition: color .15s;
}
.back-btn:hover { color: var(--blue); }

/* ── Empty state ── */
.empty-state { text-align: center; padding: 44px 20px; color: var(--soku-gray); }
.empty-state-icon { font-size: 2.8rem; margin-bottom: 10px; }
.empty-state-text { font-size: .95rem; margin-bottom: 6px; color: var(--soku-black); font-weight: 500; }
.empty-state-sub  { font-size: .82rem; margin-bottom: 20px; }

/* ── Result card ── */
.result-card {
  background: var(--green-bg);
  border: 1px solid #6ee7b7;
  border-radius: var(--soku-radius);
  padding: 20px;
  margin-top: 14px;
}
.result-card h3  { color: var(--green); margin-bottom: 12px; font-size: 1rem; }
.result-field    { font-size: .875rem; margin-bottom: 6px; }
.result-field strong { color: var(--soku-black); }

.divider { height: 1px; background: var(--soku-border); margin: 20px 0; }

/* ── Screens ── */
.screen { display: none; }
.screen.active { display: block; }

/* ── Responsive ── */
@media (max-width: 600px) {
  .main            { padding: 14px 12px 40px; }
  .card            { padding: 18px 16px; }
  .docs-grid       { grid-template-columns: repeat(2, 1fr); }
  .profile-actions { flex-direction: column; }
  .profile-actions .btn { justify-content: center; }
  .section-header  { flex-direction: column; align-items: flex-start; }
}

/* ── Multi-upload: lista previa de archivos ── */
.up-file-list { list-style: none; padding: 0; margin: 0 0 14px; display: flex; flex-direction: column; gap: 6px; }
.up-file-item { display: flex; align-items: center; gap: 10px; padding: 8px 12px; background: var(--bg); border-radius: 8px; border: 1px solid var(--border); font-size: .82rem; }
.up-file-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.up-file-size { color: var(--muted); white-space: nowrap; font-size: .78rem; }
.up-file-del  { background: none; border: none; cursor: pointer; color: var(--red); font-size: 1.1rem; line-height: 1; padding: 2px 5px; border-radius: 4px; flex-shrink: 0; }
.up-file-del:hover { background: var(--red-bg); }

/* ── Multi-upload: barra de progreso ── */
.up-progress-row { display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: var(--blue-light); border-radius: 8px; border: 1px solid #ffc9b0; font-size: .82rem; color: var(--blue); margin-bottom: 10px; }
.up-progress-spinner { width: 16px; height: 16px; border: 2px solid #ffc9b0; border-top-color: var(--blue); border-radius: 50%; animation: spin .6s linear infinite; flex-shrink: 0; }

/* ── Multi-upload: resumen final ── */
.up-result-item { display: flex; align-items: flex-start; gap: 8px; padding: 8px 12px; border-radius: 8px; font-size: .82rem; margin-bottom: 6px; }
.up-result-ok  { background: var(--green-bg); color: var(--green); border: 1px solid #6ee7b7; }
.up-result-err { background: var(--red-bg);   color: var(--red);   border: 1px solid #fca5a5; }
.up-result-icon { flex-shrink: 0; }
.up-result-text { flex: 1; min-width: 0; word-break: break-word; }

/* ── Semáforo de caducidades ── */
.dot-yellow { background: var(--yellow); }
.doc-cad-label {
  display: block;
  font-size: .63rem;
  font-weight: 700;
  margin-top: 4px;
  padding: 2px 5px;
  border-radius: 6px;
}
.cad-ok     { color: var(--green); }
.cad-warn   { background: var(--yellow-bg); color: var(--yellow); }
.cad-urgent { background: var(--red-bg);    color: var(--red); }
.cad-vencido{ background: var(--red);       color: white; }

/* ── Carga masiva ── */
.cm-drop-zone { min-height: 120px; }

.cm-groups-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }

.cm-group {
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}
.cm-group-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  cursor: pointer;
  background: var(--bg);
  user-select: none;
}
.cm-group-header:hover { background: #ececec; }
.cm-group-chevron { color: var(--muted); font-size: .75rem; flex-shrink: 0; }
.cm-group-info    { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.cm-group-name    { font-weight: 600; font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cm-group-dni     { font-size: .78rem; color: var(--muted); }
.cm-doc-count     { font-size: .78rem; color: var(--muted); white-space: nowrap; }

.cm-group-files {
  border-top: 1px solid var(--border);
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--soku-white);
}

.cm-file-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: .82rem;
  padding: 4px 6px 4px 4px;
  flex-wrap: wrap;
}
.cm-file-cb { flex-shrink: 0; width: 16px; min-width: 16px; height: 16px; accent-color: var(--soku-orange); cursor: pointer; margin: 0 0 0 2px; }
.cm-file-icon { flex-shrink: 0; }
.cm-file-razon { width: 100%; font-size: .75rem; color: #888; margin: 0 0 2px 24px; }
.cm-file-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cm-file-tipo { color: var(--muted); white-space: nowrap; font-size: .78rem; }
.cm-file-conf { color: var(--green); font-weight: 600; font-size: .78rem; white-space: nowrap; flex-shrink: 0; }

.cm-sin-asignar {
  border: 1px solid var(--yellow-bg);
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 14px;
}
.cm-sin-header {
  padding: 10px 14px;
  background: var(--yellow-bg);
  color: var(--yellow);
  font-size: .85rem;
  font-weight: 600;
}
.cm-file-sin {
  padding: 4px 14px;
}
.cm-file-sin + .cm-file-sin {
  border-top: 1px solid #fef3c7;
}


/* ── Multi-page document capture ── */
.mp-capture {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  padding: 14px;
  min-height: 76px;
}
.mp-capture-initial {
  display: flex;
  gap: 10px;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  padding: 16px 0 8px;
}
.mp-thumbs {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.mp-thumb {
  position: relative;
  width: 80px;
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  flex-shrink: 0;
}
.mp-thumb img {
  width: 100%;
  height: 64px;
  object-fit: cover;
  display: block;
}
.mp-thumb-pdf {
  width: 100%;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  background: var(--bg);
}
.mp-thumb-label {
  font-size: .68rem;
  font-weight: 600;
  color: var(--muted);
  text-align: center;
  padding: 3px 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mp-thumb-del {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 18px;
  height: 18px;
  background: var(--soku-orange);
  color: var(--white);
  border: none;
  border-radius: 50%;
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  box-shadow: 0 1px 4px rgba(0,0,0,.2);
}
.mp-thumb-del:hover { background: var(--soku-orange-dark); }
.mp-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.mp-add-btn {
  background: none;
  border: 1.5px dashed var(--border);
  border-radius: 8px;
  color: var(--muted);
  font-size: .85rem;
  font-weight: 500;
  padding: 8px 14px;
  cursor: pointer;
  transition: border-color .15s, color .15s;
  font-family: inherit;
}
.mp-add-btn:hover {
  border-color: var(--soku-orange);
  color: var(--soku-orange);
}

/* ── Doc card actions (ver / descargar) ── */
.doc-card-actions {
  display: flex;
  gap: 6px;
  justify-content: center;
  padding-top: 10px;
}

.doc-action-btn {
  flex: 1;
  background: transparent;
  border: 1px solid #E5E7EB;
  border-radius: 6px;
  color: #6B7280;
  font-size: 12px;
  font-weight: 500;
  font-family: 'Montserrat', sans-serif;
  height: 28px;
  padding: 0 6px;
  cursor: pointer;
  transition: border-color .15s, color .15s;
  line-height: 1;
}
.doc-action-btn:hover {
  border-color: var(--soku-orange);
  color: var(--soku-orange);
  background: transparent;
}
.doc-action-btn-reanalizar {
  color: #F5520C;
  border-color: #F5520C;
  flex: 0 0 28px;
  width: 28px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.doc-action-btn-reanalizar:hover {
  background: #F5520C;
  color: #fff;
}

/* ── Papelera grid + cards ── */
.docs-grid-papelera {
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
}
.doc-card-papelera {
  border: 1.5px dashed #D1D5DB;
  background: #FAFBFC;
  padding: 20px 16px 16px;
  text-align: left;
  gap: 0;
}
.doc-card-papelera .doc-card-footer {
  text-align: left;
  margin-top: auto;
  padding-top: 12px;
}
.papelera-badge {
  display: inline-block;
  font-size: .58rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: #9CA3AF;
  background: #F3F4F6;
  padding: 3px 8px;
  border-radius: 6px;
  line-height: 1;
  margin-bottom: 12px;
}
.papelera-title {
  font-size: .82rem;
  font-weight: 600;
  color: #1F2937;
  line-height: 1.35;
  margin-bottom: 4px;
  overflow-wrap: break-word;
  word-break: break-word;
  hyphens: auto;
}
.papelera-filename {
  font-size: .68rem;
  color: var(--soku-gray);
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
  margin-bottom: 2px;
}
.papelera-meta {
  font-size: .67rem;
  color: #9CA3AF;
  line-height: 1.4;
}
.papelera-restore-btn {
  display: block;
  width: 100%;
  margin-top: 12px;
  padding: 7px 0;
  font-size: .75rem;
  font-weight: 600;
  text-align: center;
  color: #059669;
  background: transparent;
  border: 1.5px solid #059669;
  border-radius: 8px;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.papelera-restore-btn:hover {
  background: #059669;
  color: #fff;
}

/* ── Sidebar ── */
.app-sidebar {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: 240px;
  background: #111111;
  border-right: 1px solid #1F1F1F;
  display: flex;
  flex-direction: column;
  z-index: 200;
  overflow-y: auto;
  overflow-x: hidden;
  transition: transform .2s ease-out;
}

/* Brand */
.sidebar-brand {
  padding: 20px 24px 16px;
  flex-shrink: 0;
  cursor: pointer;
  user-select: none;
  background: none;
  display: flex;
  align-items: center;
}
.sidebar-brand img {
  display: block;
}

/* Client identity */
.sidebar-company {
  padding: 0 24px 16px;
  border-bottom: 1px solid #1F1F1F;
  flex-shrink: 0;
  min-height: 20px;
}
.sidebar-logo-wrap {
  display: inline-block;
  background: #FFFFFF;
  border-radius: 6px;
  padding: 4px 8px;
  margin-bottom: 6px;
}
.sidebar-company-logo {
  max-width: 120px;
  max-height: 40px;
  object-fit: contain;
  display: block;
  transition: opacity 150ms;
}
.sidebar-company-name {
  font-family: 'Montserrat', sans-serif;
  font-size: 11px;
  font-weight: 500;
  color: #9CA3AF;
  line-height: 1.3;
}

/* Nav */
.sidebar-nav {
  flex: 1;
  padding: 8px 0;
  display: flex;
  flex-direction: column;
}

/* Items */
.sidebar-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 24px;
  color: #9CA3AF;
  font-family: 'Montserrat', sans-serif;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.01em;
  cursor: pointer;
  border-left: 3px solid transparent;
  border-top: none;
  border-right: none;
  border-bottom: none;
  text-decoration: none;
  transition: color 150ms, background 150ms;
  white-space: nowrap;
  background: none;
  width: 100%;
  text-align: left;
  line-height: 1.2;
}
.sidebar-item .sidebar-item-icon {
  color: #9CA3AF;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  transition: color 150ms;
}
.sidebar-item:hover {
  color: var(--soku-white);
  background: #1A1A1A;
}
.sidebar-item:hover .sidebar-item-icon {
  color: var(--soku-white);
}
.sidebar-item.active {
  color: var(--soku-white);
  border-left-color: var(--soku-orange);
  background: #1A1A1A;
}
.sidebar-item.active .sidebar-item-icon {
  color: var(--soku-orange);
}
.sidebar-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: auto;
  background: var(--soku-orange);
  color: var(--soku-white);
  font-size: .65rem;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  line-height: 18px;
  text-align: center;
  border-radius: 9px;
  padding: 0 5px;
}

/* Divider */
.sidebar-divider {
  height: 1px;
  background: #1F1F1F;
  margin: 4px 0;
}

/* Footer */
.sidebar-footer {
  flex-shrink: 0;
  padding-bottom: 8px;
}

/* Overlay */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  z-index: 199;
}

/* Hamburger */
.hamburger-btn {
  display: none;
  background: none;
  border: none;
  color: var(--soku-white);
  cursor: pointer;
  padding: 8px;
  border-radius: 6px;
  line-height: 0;
  transition: background 150ms;
}
.hamburger-btn:hover { background: rgba(255,255,255,.1); }

/* ── Layout with sidebar ── */
.has-sidebar .app-header {
  left: 240px;
}
.has-sidebar .main {
  margin-left: 240px;
  padding-left: 32px;
  padding-right: 32px;
}

/* ── Sidebar responsive ── */
@media (max-width: 768px) {
  .has-sidebar .app-header {
    left: 0;
  }
  .has-sidebar .main {
    margin-left: 0;
    padding-left: 16px;
    padding-right: 16px;
  }
  .app-sidebar {
    transform: translateX(-100%);
  }
  .app-sidebar.open {
    transform: translateX(0);
  }
  .sidebar-overlay.open {
    display: block;
  }
  .hamburger-btn {
    display: inline-flex;
    align-items: center;
  }
  .app-header {
    justify-content: space-between;
  }
}

/* ── Pack: tabla de validación a ancho completo ── */
/* Sin sidebar: full-bleed centrado respecto al viewport */
#pack-validacion:not(:empty) {
  width: 100vw;
  margin-left: calc(50% - 50vw);
  margin-bottom: 16px;
}
/* Con sidebar fijo (240 px): de sidebar a borde derecho */
.has-sidebar #pack-validacion:not(:empty) {
  width: calc(100vw - 240px);
  margin-left: -32px;
  margin-bottom: 16px;
}
/* Sidebar colapsado en móvil */
@media (max-width: 768px) {
  .has-sidebar #pack-validacion:not(:empty) {
    width: 100vw;
    margin-left: -16px;
  }
}

/* ── CamScanner: modal de ajuste de perspectiva ── */
.cs-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.82);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.cs-modal {
  background: var(--soku-white);
  border-radius: var(--soku-radius);
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.4);
  padding: 16px;
  max-width: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
}
.cs-title {
  font-size: .95rem;
  font-weight: 600;
  color: var(--soku-black);
}
.cs-hint {
  font-size: .78rem;
  color: var(--soku-gray);
  margin-top: -4px;
}
.cs-canvas-wrap {
  position: relative;
  line-height: 0;
  cursor: default;
}
.cs-canvas-wrap canvas {
  display: block;
  border-radius: 6px;
}
.cs-svg {
  position: absolute;
  inset: 0;
  overflow: visible;
  touch-action: none;
}
.cs-poly {
  fill: rgba(245, 82, 12, 0.12);
  stroke: var(--soku-orange);
  stroke-width: 2;
}
.cs-handle {
  fill: var(--soku-orange);
  stroke: var(--soku-white);
  stroke-width: 2.5;
  cursor: grab;
  touch-action: none;
}
.cs-handle:active { cursor: grabbing; }
.cs-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.cs-actions .btn { flex: 1; justify-content: center; min-width: 140px; }
.cs-loading {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 14px;
  color: var(--soku-gray);
  font-size: .875rem;
}

/* ── Add-worker method selector ── */
.add-worker-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 24px;
}
.add-worker-option-btn {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 14px;
  border: 2px solid var(--soku-border);
  border-radius: var(--soku-radius);
  background: var(--soku-white);
  cursor: pointer;
  text-align: left;
  transition: border-color .15s, background .15s, box-shadow .15s;
  font-family: inherit;
  width: 100%;
}
.add-worker-option-btn:hover {
  border-color: var(--soku-orange);
  background: var(--soku-orange-light);
}
.add-worker-option-btn.active {
  border-color: var(--soku-orange);
  background: var(--soku-orange-light);
  box-shadow: var(--soku-focus-ring);
}
.add-worker-option-icon { font-size: 1.75rem; flex-shrink: 0; line-height: 1; }
.add-worker-option-title { font-weight: 600; font-size: .9rem; color: var(--soku-black); }
.add-worker-option-desc  { font-size: .78rem; color: var(--soku-gray); margin-top: 2px; }
@media (max-width: 480px) {
  .add-worker-options { grid-template-columns: 1fr; }
}

/* ── Pack de documentos ── */
.form-control {
  width: 100%;
  padding: 10px 13px;
  border: 1.5px solid var(--soku-border);
  border-radius: 8px;
  font-size: .875rem;
  font-family: inherit;
  background: var(--soku-white);
  color: var(--soku-black);
  transition: border-color .15s;
  box-sizing: border-box;
}
.form-control:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: var(--soku-focus-ring);
}
.form-section {
  background: var(--soku-white);
  border: 1px solid var(--soku-border);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 16px;
}
.form-section-title {
  font-size: .95rem;
  font-weight: 600;
  margin: 0 0 14px 0;
  color: var(--soku-black);
}
.checkbox-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 280px;
  overflow-y: auto;
  padding-right: 4px;
}
.checkbox-label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: .875rem;
  font-weight: 400;
  cursor: pointer;
  padding: 6px 8px;
  border-radius: 6px;
  margin-bottom: 0;
  transition: background .1s;
}
.checkbox-label:hover { background: var(--soku-orange-light); }
.checkbox-label input[type=checkbox] {
  width: 16px;
  height: 16px;
  accent-color: var(--soku-orange);
  flex-shrink: 0;
  cursor: pointer;
}
.table-wrap { overflow-x: auto; }
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
}
.data-table th {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 2px solid var(--soku-border);
  font-size: .78rem;
  font-weight: 600;
  color: var(--soku-gray);
  text-transform: uppercase;
  letter-spacing: .04em;
}
.data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--soku-border);
  color: var(--soku-black);
}
.data-table tbody tr:hover { background: var(--soku-bg); }

/* ── Pack validation matrix ── */
.pack-matrix-wrap {
  overflow-x: auto;
  border: 1px solid var(--soku-border);
  border-radius: 8px;
}
.pack-matrix {
  border-collapse: separate;
  border-spacing: 0;
  font-size: .82rem;
  min-width: max-content;
}
.pack-matrix th,
.pack-matrix td { padding: 5px 6px; border-bottom: 1px solid var(--soku-border); }

/* Header row */
.pack-matrix thead th {
  background: var(--soku-white);
  font-size: .7rem;
  font-weight: 600;
  color: var(--soku-gray);
  text-transform: uppercase;
  letter-spacing: .03em;
  position: sticky;
  top: 0;
  z-index: 1;
}
/* Rotated column headers */
.pack-matrix .pm-col-hdr {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  vertical-align: bottom;
  text-align: left;
  max-height: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.15;
  padding: 6px 4px 4px;
}
/* Sticky first column (worker name) */
.pack-matrix th:first-child,
.pack-matrix td:first-child {
  position: sticky;
  left: 0;
  z-index: 2;
  background: var(--soku-white);
  min-width: 180px;
  max-width: 220px;
}
.pack-matrix thead th:first-child { z-index: 3; }

/* Worker name cell */
.pack-matrix .pm-worker {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 600;
  font-size: .82rem;
  padding-left: 10px;
  padding-right: 8px;
  border-right: 2px solid var(--soku-border);
}
.pack-matrix thead th:first-child { border-right: 2px solid var(--soku-border); }

/* Zebra + hover */
.pack-matrix tbody tr:nth-child(even) td { background: #FAFAFA; }
.pack-matrix tbody tr:nth-child(even) td:first-child { background: #FAFAFA; }
.pack-matrix tbody tr:hover td { background: var(--soku-orange-light); }
.pack-matrix tbody tr:hover td:first-child { background: var(--soku-orange-light); }

/* Status badges */
.pm-status { display: inline-block; font-size: .72rem; font-weight: 600; padding: 2px 7px; border-radius: 4px; line-height: 1.3; }
.pm-ok       { color: var(--green);  background: var(--green-bg); }
.pm-expired  { color: var(--yellow); background: var(--yellow-bg); }
.pm-missing  { color: var(--soku-gray); background: var(--soku-bg); font-weight: 400; }

.text-muted { color: var(--soku-gray); }

/* ── Mobile cards (generic list pattern) ── */
.mobile-cards {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.mobile-card {
  background: var(--soku-white);
  border-radius: 10px;
  border: 1px solid var(--soku-border);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: box-shadow 150ms, border-color 150ms;
}
.mobile-card:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  border-color: #D1D5DB;
}
.mobile-card:active { transform: scale(0.98); }
.mobile-card-body { flex: 1; min-width: 0; }
.mobile-card-title {
  font-weight: 600;
  font-size: .9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mobile-card-sub {
  font-size: .78rem;
  color: var(--soku-gray);
  margin-top: 2px;
}
.mobile-card-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.mobile-card-arrow {
  color: #D1D5DB;
  font-size: 1.2rem;
  font-weight: 300;
}

/* ── Full-width mobile button ── */
.btn--block-mobile {
  width: 100%;
  justify-content: center;
  padding: 14px 20px;
  font-size: .95rem;
  border-radius: 10px;
}

/* ── Firma: canvas ── */
.firma-canvas-wrap {
  border: 2px dashed var(--soku-border);
  border-radius: 8px;
  background: #FAFAFA;
  touch-action: none;
  position: relative;
}
.firma-canvas-wrap canvas {
  display: block;
  width: 100%;
  border-radius: 6px;
}

/* ── Firma: action buttons ── */
.firma-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ═══════════════════════════════════════
   PLANTILLAS
═══════════════════════════════════════ */
.plantillas-tabs {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--soku-border);
  margin-bottom: 0;
}
.plantilla-tab {
  padding: 8px 16px;
  border: none;
  background: none;
  font-size: .88rem;
  font-weight: 500;
  color: var(--soku-gray);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  white-space: nowrap;
  transition: color .15s, border-color .15s;
}
.plantilla-tab:hover { color: var(--soku-dark); }
.plantilla-tab.active {
  color: var(--soku-primary);
  border-bottom-color: var(--soku-primary);
}
.plantilla-badge-edit {
  display: inline-block;
  font-size: .7rem;
  background: #FFF3E0;
  color: #E65100;
  padding: 1px 6px;
  border-radius: 8px;
  margin-left: 4px;
  font-weight: 600;
  vertical-align: middle;
}
.badge-info {
  background: #E3F2FD;
  color: #1565C0;
}
.badge-muted {
  background: #F3F4F6;
  color: #6B7280;
}

/* EPI editor rows */
.epi-editor-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid var(--soku-border);
}
.epi-editor-handle {
  cursor: grab;
  color: var(--soku-gray);
  font-size: 1rem;
  user-select: none;
  flex-shrink: 0;
  width: 20px;
  text-align: center;
}
.epi-editor-input {
  flex: 1;
  padding: 6px 10px;
  border: 1px solid var(--soku-border);
  border-radius: 6px;
  font-size: .9rem;
}
.epi-editor-input:focus {
  outline: none;
  border-color: var(--soku-primary);
  box-shadow: 0 0 0 2px rgba(245,82,12,.12);
}
.epi-editor-actions {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
}
.btn-icon-sm {
  width: 28px;
  height: 28px;
  border: 1px solid var(--soku-border);
  border-radius: 4px;
  background: #fff;
  cursor: pointer;
  font-size: .8rem;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--soku-gray);
  transition: background .15s;
}
.btn-icon-sm:hover:not(:disabled) { background: #F3F4F6; }
.btn-icon-sm:disabled { opacity: .35; cursor: default; }
.btn-danger-sm { color: var(--red); }
.btn-danger-sm:hover:not(:disabled) { background: var(--red-bg); }

/* Template preview */
.plantilla-preview {
  border: 1px solid var(--soku-border);
  border-radius: 8px;
  padding: 20px;
  background: #FAFBFC;
}
.preview-seccion {
  margin-bottom: 20px;
}
.preview-seccion:last-child { margin-bottom: 0; }
.preview-seccion h4 {
  font-size: .95rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--soku-dark);
}
.preview-seccion p {
  font-size: .88rem;
  color: #374151;
  line-height: 1.5;
  margin-bottom: 6px;
}
.preview-seccion ul {
  margin: 8px 0 0 0;
  padding-left: 20px;
}
.preview-seccion li {
  font-size: .85rem;
  color: #374151;
  line-height: 1.6;
}
.preview-nota {
  font-style: italic;
  color: var(--soku-gray) !important;
  font-size: .82rem !important;
}

@media (max-width: 600px) {
  .plantillas-tabs { gap: 2px; }
  .plantilla-tab { padding: 6px 10px; font-size: .82rem; }
  .epi-editor-row { gap: 4px; }
  .epi-editor-actions { gap: 1px; }
  .btn-icon-sm { width: 24px; height: 24px; font-size: .7rem; }
}

/* ── FAB: Floating Import Button ── */
.fab-import {
  position: fixed;
  bottom: 32px;
  right: 32px;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 8px;
  background: #F5520C;
  color: #fff;
  padding: 12px 20px;
  border-radius: 8px;
  font-family: 'Montserrat', sans-serif;
  font-size: .85rem;
  font-weight: 600;
  text-decoration: none;
  box-shadow: 0 4px 16px rgba(245, 82, 12, .3);
  transition: background 150ms, box-shadow 150ms;
}
.fab-import:hover {
  background: #e04a0a;
  box-shadow: 0 6px 20px rgba(245, 82, 12, .45);
}
.fab-import svg {
  flex-shrink: 0;
}

/* ── Config Tabs ── */
.config-tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--soku-border);
  margin-bottom: 24px;
}
.config-tab {
  background: transparent;
  border: none;
  padding: 10px 20px;
  font-family: inherit;
  font-size: .9rem;
  font-weight: 600;
  color: var(--soku-gray);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color 150ms, border-color 150ms;
}
.config-tab:hover {
  color: var(--soku-black);
}
.config-tab.active {
  color: var(--soku-black);
  border-bottom-color: var(--soku-orange);
}
.config-panel {
  display: none;
}
.config-panel.active {
  display: block;
}

/* ── Archivado de trabajadores ── */
.badge-archived {
  background: #F3F4F6;
  color: #9CA3AF;
  font-size: .72rem;
  font-weight: 600;
}
.btn-action-subtle {
  font-size: .8rem;
  color: var(--soku-orange);
  background: none;
  border: 1px solid var(--soku-orange);
  cursor: pointer;
  padding: 4px 10px;
  border-radius: 6px;
  transition: background .15s, color .15s;
  font-weight: 500;
}
.btn-action-subtle:hover {
  background: var(--soku-orange);
  color: #fff;
}
.link-archivados {
  font-size: .82rem;
  color: #9CA3AF;
  cursor: pointer;
  transition: color .15s;
}
.link-archivados:hover {
  color: var(--soku-orange);
}
.worker-item.worker-archived {
  opacity: .55;
}
.profile-archived-banner {
  background: #F9FAFB;
  border: 1px dashed #D1D5DB;
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 16px;
  color: #6B7280;
  font-size: .85rem;
  display: flex;
  align-items: center;
  gap: 10px;
}
.profile-archived-banner strong {
  color: #374151;
}
.docs-grid.docs-grid-disabled {
  opacity: .5;
  pointer-events: none;
}
