.brand { display: inline-flex; align-items: center; gap: .5rem; text-decoration: none; }
.brand-logo { height: 2.5rem; width: auto; padding: .25rem .5rem; background: #fff; border-radius: var(--pico-border-radius); }

main, header { overflow-wrap: anywhere; }

/* Tablas: ancho mínimo para desplazarse en lugar de comprimirse, con barra siempre visible (también en móvil). */
.overflow-auto {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--pico-muted-color) transparent;
}
.overflow-auto::-webkit-scrollbar { height: .7rem; }
.overflow-auto::-webkit-scrollbar-track { background: transparent; }
.overflow-auto::-webkit-scrollbar-thumb { background: var(--pico-muted-color); border-radius: 999px; }
.overflow-auto > table { min-width: 36rem; }
.overflow-auto th, .overflow-auto td { white-space: nowrap; }
#jobs-table table { min-width: 52rem; }
table.preview { width: max-content; min-width: 100%; }
#results td:nth-child(3) { white-space: normal; min-width: 14rem; }

.flash-error {
  border-left: 4px solid #d93526;
  color: #d93526;
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 1rem;
  margin: 1rem 0;
}
.stats > div {
  display: flex;
  flex-direction: column;
  padding: .75rem 1rem;
  border-radius: var(--pico-border-radius);
  background: var(--pico-card-sectioning-background-color);
}
.stats span { font-size: 1.6rem; font-weight: 700; }
.c-safe span { color: #2a9d5c; }
.c-risky span { color: #c98a00; }
.c-invalid span { color: #d93526; }
.c-unknown span { color: #7b8495; }

.badge {
  display: inline-block;
  padding: .1rem .55rem;
  border-radius: 999px;
  font-size: .8rem;
  font-weight: 600;
  color: #fff;
  background: #7b8495;
  white-space: nowrap;
}
.badge[data-tooltip], .stats [data-tooltip] { border-bottom: 0; cursor: help; }
[data-tooltip]::before, [data-tooltip]::after { white-space: normal; width: max-content; max-width: min(18rem, 80vw); }
.badge-safe, .badge-completed { background: #2a9d5c; }
.badge-risky { background: #c98a00; }
.badge-invalid, .badge-failed { background: #d93526; }
.badge-running, .badge-fetching { background: #1f6feb; }

table.preview .email-col { background: rgba(31, 111, 235, .12); font-weight: 600; }

.download-options { display: flex; flex-wrap: wrap; gap: 1.25rem; margin: .75rem 0; }

.filters ul { flex-wrap: wrap; }
.filters a[aria-current="page"] { font-weight: 700; text-decoration: underline; }

.pager { display: flex; align-items: center; gap: 1rem; justify-content: center; }
.pager button { width: auto; margin: 0; }

.auth { max-width: 24rem; margin: 2rem auto; }
nav details.menu { margin: 0; }
nav a[role="button"][data-icon] { margin: 0; padding: .5rem 1rem; }
nav details.menu summary { margin: 0; }
nav details.menu ul { min-width: 12rem; }
nav form.logout { margin: 0; }
nav form.logout button { margin: 0; padding: .25rem .75rem; width: 100%; }

.password-field { display: block; }
.password-field input { width: 100%; }
.password-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: var(--pico-spacing, 1rem); }
.password-actions button { width: auto; margin: 0; padding: .25rem .75rem; white-space: nowrap; }
.file-picker {
  padding: 1rem;
  margin-bottom: .5rem;
  border: 2px dashed var(--pico-muted-border-color);
  border-radius: var(--pico-border-radius);
  background: var(--pico-card-sectioning-background-color);
  transition: border-color .15s, background-color .15s;
}
.file-picker:hover, .file-picker:focus-within { border-color: var(--pico-primary); }
.file-picker.has-file { border-style: solid; border-color: var(--pico-primary); }
.file-picker input[type="file"] { width: 100%; margin-bottom: 0; }
.file-picker input[type="file"]::file-selector-button {
  margin-right: 1rem;
  padding: .4rem 1rem;
  border: 0;
  border-radius: var(--pico-border-radius);
  background: var(--pico-primary-background);
  color: var(--pico-primary-inverse);
  font-weight: 600;
  cursor: pointer;
}
.file-picker input[type="file"]::file-selector-button:hover { background: var(--pico-primary-hover-background); }
.file-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: var(--pico-spacing, 1rem); }
.file-actions button { width: auto; margin: 0; }
.file-actions button[hidden] { display: none; }
/* Iconos de botones: <button data-icon="nombre">; el icono hereda el color del texto (máscara SVG). */
[data-icon] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
}
[data-icon][hidden] { display: none; }
[data-icon]::before {
  content: "";
  flex: none;
  width: 1.1em;
  height: 1.1em;
  background-color: currentColor;
  -webkit-mask: var(--icon) center / contain no-repeat;
  mask: var(--icon) center / contain no-repeat;
}
[data-icon][data-icon-end]::before { order: 1; }
[data-icon="upload"] { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4'/%3E%3Cpolyline points='17 8 12 3 7 8'/%3E%3Cline x1='12' y1='3' x2='12' y2='15'/%3E%3C/svg%3E"); }
[data-icon="download"] { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4'/%3E%3Cpolyline points='7 10 12 15 17 10'/%3E%3Cline x1='12' y1='15' x2='12' y2='3'/%3E%3C/svg%3E"); }
[data-icon="x"] { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cline x1='18' y1='6' x2='6' y2='18'/%3E%3Cline x1='6' y1='6' x2='18' y2='18'/%3E%3C/svg%3E"); }
[data-icon="arrow-left"] { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cline x1='19' y1='12' x2='5' y2='12'/%3E%3Cpolyline points='12 19 5 12 12 5'/%3E%3C/svg%3E"); }
[data-icon="arrow-right"] { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cline x1='5' y1='12' x2='19' y2='12'/%3E%3Cpolyline points='12 5 19 12 12 19'/%3E%3C/svg%3E"); }
[data-icon="key"] { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 2l-2 2m-7.61 7.61a5.5 5.5 0 1 1-7.78 7.78 5.5 5.5 0 0 1 7.78-7.78zm0 0L15.5 7.5m0 0l3 3L22 7l-3-3m-3.5 3.5L19 4'/%3E%3C/svg%3E"); }
[data-icon="play"] { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolygon points='5 3 19 12 5 21 5 3'/%3E%3C/svg%3E"); }
[data-icon="login"] { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4'/%3E%3Cpolyline points='10 17 15 12 10 7'/%3E%3Cline x1='15' y1='12' x2='3' y2='12'/%3E%3C/svg%3E"); }
[data-icon="logout"] { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4'/%3E%3Cpolyline points='16 17 21 12 16 7'/%3E%3Cline x1='21' y1='12' x2='9' y2='12'/%3E%3C/svg%3E"); }
[data-icon="user-plus"] { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M16 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2'/%3E%3Ccircle cx='8.5' cy='7' r='4'/%3E%3Cline x1='20' y1='8' x2='20' y2='14'/%3E%3Cline x1='23' y1='11' x2='17' y2='11'/%3E%3C/svg%3E"); }
[data-icon="save"] { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M19 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11l5 5v11a2 2 0 0 1-2 2z'/%3E%3Cpolyline points='17 21 17 13 7 13 7 21'/%3E%3Cpolyline points='7 3 7 8 15 8'/%3E%3C/svg%3E"); }
[data-icon="trash"] { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='3 6 5 6 21 6'/%3E%3Cpath d='M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6'/%3E%3Cpath d='M10 11v6M14 11v6'/%3E%3Cpath d='M9 6V4a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2'/%3E%3C/svg%3E"); }
[data-icon="eye"] { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z'/%3E%3Ccircle cx='12' cy='12' r='3'/%3E%3C/svg%3E"); }
[data-icon="wand"] { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M15 4V2M15 16v-2M8 9h2M20 9h2M17.8 11.8L19 13M15 9h0M17.8 6.2L19 5M3 21l9-9M12.2 6.2L11 5'/%3E%3C/svg%3E"); }
[data-icon="copy"] { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='9' y='9' width='13' height='13' rx='2' ry='2'/%3E%3Cpath d='M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1'/%3E%3C/svg%3E"); }
.role-badge { font-weight: normal; opacity: .7; }
.flash-ok { border-left: 4px solid #2e7d32; padding: .75rem 1rem; }

@media (max-width: 768px) {
  header nav { flex-wrap: wrap; row-gap: .25rem; }
  .brand-logo { height: 2rem; }
  .stats { grid-template-columns: repeat(auto-fit, minmax(90px, 1fr)); gap: .5rem; }
  .stats span { font-size: 1.3rem; }
  .file-actions button, .download-options + button { width: 100%; }
  .download-options { gap: .75rem; }
  .auth { margin: 1rem auto; }
  .filters ul { gap: .25rem; }
}
