:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --text: #1a1d29;
  --muted: #6b7280;
  --border: #e7e9f0;
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --primary-soft: #eef2ff;
  --green: #059669; --green-soft:#ecfdf5;
  --blue: #2563eb; --blue-soft:#eff6ff;
  --red: #dc2626; --red-soft:#fef2f2;
  --amber:#d97706; --amber-soft:#fffbeb;
  --gray:#6b7280; --gray-soft:#f3f4f6;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(16,24,40,.06), 0 8px 24px rgba(16,24,40,.06);
  --shadow-sm: 0 1px 2px rgba(16,24,40,.05);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Inter", system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
.wrap { max-width: 880px; margin: 0 auto; padding: 0 20px; }

/* Header */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.header-inner { display: flex; align-items: center; justify-content: space-between; height: 64px; }
.brand { display: flex; align-items: center; gap: 10px; }
.logo { color: var(--primary); }
.brand-name { font-weight: 700; font-size: 1.25rem; letter-spacing: -.01em; }
.header-status { font-size: .8rem; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.header-status::before { content:""; width:8px; height:8px; border-radius:50%; background: var(--gray); }
.header-status.ok::before { background: var(--green); }
.header-status.down::before { background: var(--red); }

/* Hero */
.hero { text-align: center; padding: 48px 0 28px; }
.hero h1 { font-size: 2rem; font-weight: 700; letter-spacing: -.02em; margin: 0 0 10px; }
.lead { color: var(--muted); font-size: 1.05rem; max-width: 540px; margin: 0 auto; }

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.upload-card { padding: 22px; }

/* Dropzone */
.dropzone {
  border: 2px dashed #d3d8e6;
  border-radius: 12px;
  padding: 34px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s, transform .05s;
  background: #fbfcfe;
}
.dropzone:hover, .dropzone:focus-visible { border-color: var(--primary); background: var(--primary-soft); outline: none; }
.dropzone.dragover { border-color: var(--primary); background: var(--primary-soft); transform: scale(1.005); }
.drop-icon { color: var(--primary); margin-bottom: 6px; }
.drop-title { font-weight: 600; margin: 4px 0 2px; }
.drop-sub { color: var(--muted); font-size: .9rem; margin: 0; }
.link { color: var(--primary); font-weight: 600; }
.drop-file { margin: 12px auto 0; font-weight: 600; color: var(--text); background: var(--primary-soft);
  display: inline-block; padding: 6px 12px; border-radius: 999px; font-size: .9rem; }

/* Controls */
.upload-controls { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-top: 18px; flex-wrap: wrap; }
.lang-pickers { display: flex; align-items: flex-end; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 5px; font-size: .8rem; color: var(--muted); font-weight: 500; }
.field select {
  font: inherit; font-size: .95rem; color: var(--text); padding: 9px 12px;
  border: 1px solid var(--border); border-radius: 10px; background: var(--surface); min-width: 130px; cursor: pointer;
}
.field select:focus { outline: 2px solid var(--primary-soft); border-color: var(--primary); }
.lang-arrow { color: var(--muted); padding-bottom: 9px; font-size: 1.1rem; }

.btn {
  font: inherit; font-weight: 600; border: none; border-radius: 10px; padding: 11px 22px;
  cursor: pointer; transition: background .15s, opacity .15s, transform .05s; display: inline-flex; align-items: center; gap: 8px;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-primary:disabled { background: #c7cbda; cursor: not-allowed; }
.btn-ghost { background: var(--gray-soft); color: var(--text); padding: 8px 14px; font-size: .88rem; }
.btn-ghost:hover { background: #e8eaf0; }
.upload-error { color: var(--red); font-size: .9rem; margin: 12px 0 0; }

/* Barra de progreso de SUBIDA */
.upload-progress { margin-top: 16px; display: flex; align-items: center; gap: 12px; animation: fade .2s ease; }
.up-bar { flex: 1; height: 10px; background: var(--gray-soft); border-radius: 999px; overflow: hidden; }
.up-fill { height: 100%; width: 0%; background: linear-gradient(90deg, var(--primary), #6366f1);
  border-radius: 999px; transition: width .15s linear; }
.up-fill.done { background: linear-gradient(90deg, var(--green), #34d399); }
.up-label { font-size: .85rem; font-weight: 600; color: var(--muted); min-width: 92px; text-align: right; white-space: nowrap; }

/* Queue */
.queue-section { margin: 38px 0 60px; }
.queue-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.queue-head h2 { font-size: 1.15rem; margin: 0; display: flex; align-items: center; gap: 8px; }
.count { background: var(--gray-soft); color: var(--muted); font-size: .8rem; font-weight: 600; padding: 2px 9px; border-radius: 999px; }
.queue-controls { display: flex; align-items: center; gap: 12px; }
.queue-state { font-size: .82rem; color: var(--muted); }
.queue-state.paused { color: var(--amber); font-weight: 600; }

.job-list { display: flex; flex-direction: column; gap: 12px; }
.job {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow-sm); animation: fade .25s ease;
}
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.job-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.job-info { min-width: 0; }
.job-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.job-meta { color: var(--muted); font-size: .82rem; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.badge { font-size: .74rem; font-weight: 600; padding: 4px 10px; border-radius: 999px; white-space: nowrap; }
.badge.queued { background: var(--gray-soft); color: var(--gray); }
.badge.processing { background: var(--blue-soft); color: var(--blue); }
.badge.done { background: var(--green-soft); color: var(--green); }
.badge.error { background: var(--red-soft); color: var(--red); }
.badge.canceled { background: var(--amber-soft); color: var(--amber); }
.badge .dot { display:inline-block; width:6px; height:6px; border-radius:50%; background: currentColor; margin-right:5px; vertical-align: middle; }
.badge.processing .dot { animation: pulse 1.1s infinite; }
.share-chip { font-size: .72rem; font-weight: 600; padding: 4px 9px; border-radius: 999px;
  background: var(--blue-soft); color: var(--blue); white-space: nowrap; margin-left: auto; align-self: flex-start; }
@keyframes pulse { 0%,100%{opacity:1;} 50%{opacity:.35;} }

.progress { margin-top: 14px; }
.progress-bar { height: 8px; background: var(--gray-soft); border-radius: 999px; overflow: hidden; }
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--primary), #6366f1); border-radius: 999px; transition: width .4s ease; }
.progress-fill.queueing { background: linear-gradient(90deg, #f59e0b, #fbbf24); }
.progress-fill.indeterminate { width: 35% !important; animation: slide 1.3s infinite ease-in-out; }
@keyframes slide { 0%{margin-left:-35%;} 100%{margin-left:100%;} }
.progress-meta { display: flex; justify-content: space-between; font-size: .78rem; color: var(--muted); margin-top: 6px; }
.phase-label { text-transform: capitalize; }

.job-actions { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.action {
  font: inherit; font-size: .84rem; font-weight: 600; border: 1px solid var(--border); background: var(--surface);
  color: var(--text); border-radius: 9px; padding: 7px 14px; cursor: pointer; transition: background .12s, border-color .12s;
}
.action:hover { background: var(--gray-soft); }
.action.primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.action.primary:hover { background: var(--primary-dark); }
.action.danger:hover { background: var(--red-soft); border-color: #f3c4c4; color: var(--red); }
.job-error { color: var(--red); font-size: .82rem; margin-top: 8px; background: var(--red-soft); padding: 8px 10px; border-radius: 8px; }

.empty-state { text-align: center; padding: 40px 0; color: var(--text); }
.empty-state .muted { color: var(--muted); font-size: .9rem; }
.muted { color: var(--muted); }

/* Footer */
.site-footer { border-top: 1px solid var(--border); padding: 24px 0; color: var(--muted); font-size: .85rem; text-align: center; }

/* Toast */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: #1a1d29; color: #fff; padding: 12px 20px; border-radius: 10px; font-size: .9rem;
  box-shadow: 0 8px 24px rgba(0,0,0,.2); z-index: 50; animation: fade .2s ease;
}
.toast.error { background: var(--red); }

@media (max-width: 560px) {
  .hero h1 { font-size: 1.6rem; }
  .upload-controls { flex-direction: column; align-items: stretch; }
  .btn-primary { width: 100%; justify-content: center; }
  .lang-pickers { justify-content: space-between; }
  .field select { min-width: 0; flex: 1; }
}

/* ===== Unificación: auth, pestañas, modal, admin ===== */
.header-inner { display: flex; align-items: center; justify-content: space-between; }
.auth-nav { display: flex; align-items: center; gap: .5rem; }
.auth-nav .who { font-size: .85rem; color: var(--muted, #667); margin: 0 .25rem; }

.tabs { display: flex; gap: .5rem; margin-bottom: 1rem; border-bottom: 1px solid rgba(0,0,0,.08); }
.tab { background: none; border: none; padding: .6rem .9rem; font: inherit; font-weight: 600;
  color: var(--muted, #667); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab.active { color: var(--accent, #4f46e5); border-bottom-color: var(--accent, #4f46e5); }
.tab-panel { animation: fade .2s ease; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.field.block { display: block; }
.field.block span { display: block; margin-bottom: .3rem; font-size: .85rem; font-weight: 600; }
.field.block input, .field.block select { width: 100%; box-sizing: border-box; padding: .6rem .7rem;
  border: 1px solid rgba(0,0,0,.15); border-radius: 8px; font: inherit; }
.video-note { font-size: .85rem; color: var(--muted, #667); margin: 0; flex: 1; }
.video-disabled { color: #b91c1c; font-size: .85rem; margin-top: .5rem; }
.btn.block { display: block; width: 100%; }

/* Modal */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex;
  align-items: center; justify-content: center; z-index: 100; padding: 1rem; }
/* FIX global: el atributo [hidden] (display:none de la hoja UA) tiene la misma
   especificidad que las clases con display (.modal, .upload-progress, .btn…),
   y al ir éstas después, GANABAN → el modal de login, la barra de subida y el
   botón de pausa no se ocultaban al poner hidden=true. Esta regla con !important
   hace que [hidden] siempre oculte (es el patrón recomendado de HTML5BP). */
[hidden] { display: none !important; }
.modal-box { background: #fff; border-radius: 14px; padding: 1.6rem; width: 100%; max-width: 380px;
  position: relative; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modal-box h2 { margin: 0 0 1rem; }
.modal-close { position: absolute; top: .6rem; right: .8rem; background: none; border: none;
  font-size: 1.5rem; line-height: 1; cursor: pointer; color: var(--muted, #667); }
.modal-box .field.block { margin-bottom: .9rem; }
.auth-switch { text-align: center; font-size: .88rem; margin: 1rem 0 0; color: var(--muted, #667); }
.auth-switch a { color: var(--accent, #4f46e5); font-weight: 600; }

/* Admin */
.admin-card { margin-bottom: 1.5rem; }
.admin-card h2 { margin-top: 0; }
.table-wrap { overflow-x: auto; }
.admin-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.admin-table th, .admin-table td { text-align: left; padding: .55rem .6rem; border-bottom: 1px solid rgba(0,0,0,.07); }
.admin-table th { font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted, #667); }
.row-actions { display: flex; gap: .4rem; flex-wrap: wrap; }
.tag { font-size: .75rem; padding: .15rem .5rem; border-radius: 999px; background: #eef; font-weight: 600; }
.tag.admin { background: #fde68a; color: #92400e; }

/* Reproductor de vídeo (reutiliza .modal) */
.video-box { max-width: 860px; }
.video-box video { width: 100%; max-height: 70vh; border-radius: 8px; background: #000; display: block; }
.video-box h2 { font-size: 1.05rem; margin: 0 0 .8rem; padding-right: 1.5rem; }

/* Opciones de doblaje de vídeo */
.video-opts { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-top: 14px; }
.video-opts .field.block span { font-size: .78rem; }
.video-opts select { width: 100%; }
@media (max-width: 520px) { .video-opts { grid-template-columns: 1fr; } }

.check-field { display: flex; align-items: center; gap: 9px; margin: 12px 0 2px; font-size: .9rem; cursor: pointer; }
.check-field input { width: 16px; height: 16px; flex: none; cursor: pointer; }
.check-field small { font-weight: 400; }

/* Lector EPUB */
.epub-box { max-width: 760px; width: 100%; display: flex; flex-direction: column; }
#epubViewer { width: 100%; height: 70vh; border: 1px solid var(--border); border-radius: 8px;
  background: #fff; overflow: hidden; }
.epub-nav { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: .8rem; }
.epub-nav .muted { font-size: .82rem; }
