* { box-sizing: border-box; }
body {
    font-family: -apple-system, "Segoe UI", Roboto, sans-serif;
    background: #f4f5f7;
    color: #1f2430;
    margin: 0;
}
header {
    background: #1f2430;
    color: white;
    padding: 16px 32px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
header a { color: white; text-decoration: none; }
.cabecera-derecha { display: flex; align-items: center; gap: 12px; }
.usuario-conectado { color: #d1d5db; font-size: 13px; }
.btn-salir {
    background: transparent; border: 1px solid #4b5563; color: #d1d5db;
    padding: 6px 12px; border-radius: 6px; font-size: 13px; cursor: pointer;
}
.btn-salir:hover { background: #374151; }
main { max-width: 900px; margin: 32px auto; padding: 0 20px; }
main.ancho { max-width: 1500px; }

.barra-url-publica {
    background: #ecfdf5; border-bottom: 1px solid #a7f3d0; color: #065f46;
    padding: 8px 32px; font-size: 12px; display: flex; align-items: center; gap: 10px;
}
.barra-url-publica strong { font-family: monospace; }
.url-publica-aviso { color: #6b7280; margin-left: auto; }

.btn {
    background: #3b82f6;
    color: white !important;
    padding: 10px 16px;
    border-radius: 6px;
    text-decoration: none;
    font-size: 14px;
    border: none;
    cursor: pointer;
}
.btn-mini {
    background: #3b82f6;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 6px 10px;
    font-size: 12px;
    cursor: pointer;
}

.lista-expedientes { display: flex; flex-direction: column; gap: 12px; }
.tarjeta {
    background: white;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.tarjeta-enlace {
    display: block; padding: 16px 20px; text-decoration: none; color: inherit;
}
.tarjeta-cabecera { display: flex; justify-content: space-between; align-items: center; }
.nombre { font-weight: 600; font-size: 16px; }
.tienda { color: #6b7280; font-size: 13px; margin: 4px 0 10px; }

.prioridad { font-size: 11px; padding: 3px 8px; border-radius: 12px; font-weight: 600; }
.prioridad-alta { background: #fee2e2; color: #b91c1c; }
.prioridad-normal { background: #e0e7ff; color: #3730a3; }
.prioridad-baja { background: #f3f4f6; color: #374151; }

.barra { background: #e5e7eb; border-radius: 6px; height: 8px; overflow: hidden; }
.barra-relleno { background: #22c55e; height: 100%; }
.progreso-texto { font-size: 12px; color: #6b7280; margin-top: 6px; }

.formulario { background: white; padding: 24px; border-radius: 8px; display: flex; flex-direction: column; gap: 4px; max-width: 500px; }
.formulario label { font-size: 13px; font-weight: 600; margin-top: 10px; }
.formulario input, .formulario select {
    padding: 8px; border: 1px solid #d1d5db; border-radius: 6px; font-size: 14px;
}
.fila-doble { display: flex; gap: 16px; }
.fila-doble > div { flex: 1; }
.ayuda { font-size: 12px; color: #6b7280; margin: 10px 0; }

.volver { font-size: 13px; color: #3b82f6; text-decoration: none; }
.tienda-detalle { color: #6b7280; margin-top: -8px; }

.cabecera-detalle { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.btn-eliminar {
    background: #fee2e2; color: #b91c1c; border: 1px solid #fecaca;
    border-radius: 6px; padding: 6px 12px; font-size: 13px; cursor: pointer;
}
.btn-eliminar:hover { background: #fecaca; }

.tabla-tareas { width: 100%; border-collapse: collapse; margin-top: 20px; background: white; border-radius: 8px; overflow: hidden; }
.tabla-tareas th { background: #f3f4f6; text-align: left; padding: 10px 12px; font-size: 12px; text-transform: uppercase; color: #6b7280; }
.tabla-tareas td { padding: 10px 12px; border-top: 1px solid #f3f4f6; font-size: 13px; }

.estado-badge { padding: 3px 8px; border-radius: 12px; font-size: 11px; font-weight: 600; }
.estado-pendiente { background: #f3f4f6; color: #374151; }
.estado-descargando { background: #fef3c7; color: #92400e; }
.estado-descargado { background: #dbeafe; color: #1e40af; }
.estado-visualizado { background: #dcfce7; color: #166534; }
.estado-error { background: #fee2e2; color: #b91c1c; }

.form-inline { display: flex; gap: 6px; align-items: center; }
.form-inline select, .form-inline input { padding: 4px 6px; font-size: 12px; border: 1px solid #d1d5db; border-radius: 4px; }
.form-inline input { width: 90px; }

.vacio { color: #6b7280; }

/* --- Barras de progreso dobles (descarga / visualizado) --- */
.barra-descarga { background: #3b82f6; }
.barra-visualizado { background: #22c55e; }
.barra-etiqueta-mini { font-size: 11px; color: #6b7280; margin-top: 8px; }
.barras-progreso { display: flex; gap: 24px; margin: 16px 0; }
.barra-bloque { flex: 1; }
.barra-etiqueta { font-size: 12px; color: #6b7280; margin-bottom: 4px; }

/* --- Formulario ancho (nuevo expediente) --- */
.formulario-ancho { max-width: 640px; }
.formulario-ancho textarea {
    padding: 8px; border: 1px solid #d1d5db; border-radius: 6px; font-size: 14px;
    font-family: inherit; resize: vertical;
}
.separador { border: none; border-top: 1px solid #e5e7eb; margin: 18px 0; }

/* --- Bloques dinámicos de persona/horario --- */
#bloques { display: flex; flex-direction: column; gap: 14px; margin-bottom: 10px; }
.bloque {
    border: 1px solid #e5e7eb; border-radius: 8px; padding: 14px;
    background: #fafafa; display: flex; flex-direction: column; gap: 4px;
}
.bloque-cabecera { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.bloque-titulo { font-weight: 600; font-size: 13px; color: #374151; }
.btn-quitar-bloque {
    background: none; border: none; color: #b91c1c; font-size: 12px; cursor: pointer;
}
.btn-secundario {
    background: white; border: 1px solid #3b82f6; color: #3b82f6;
    padding: 8px 14px; border-radius: 6px; font-size: 13px; cursor: pointer;
    align-self: flex-start; margin: 8px 0;
}

/* --- Panel de info (descripción de hechos / observaciones) --- */
.panel-info {
    background: white; border-radius: 8px; padding: 16px 20px; margin: 16px 0;
    display: flex; flex-direction: column; gap: 12px;
}
.panel-info h4 { margin: 0 0 4px; font-size: 12px; text-transform: uppercase; color: #6b7280; }
.panel-info p { margin: 0; font-size: 14px; white-space: pre-wrap; }

/* --- Dos columnas: notas y envíos de correo --- */
.dos-columnas { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 24px; }
.seccion { background: white; border-radius: 8px; padding: 16px 20px; }
.seccion h3 { margin-top: 0; font-size: 15px; }

.formulario-inline-vertical { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.formulario-inline-vertical input, .formulario-inline-vertical textarea {
    padding: 7px; border: 1px solid #d1d5db; border-radius: 6px; font-size: 13px; font-family: inherit;
}
.etiqueta-pequena { font-size: 11px; color: #6b7280; margin-bottom: -2px; }

.lista-notas { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; max-height: 320px; overflow-y: auto; }
.lista-notas li { border-top: 1px solid #f3f4f6; padding-top: 8px; }
.lista-notas li:first-child { border-top: none; padding-top: 0; }
.nota-cabecera { display: flex; justify-content: space-between; font-size: 12px; }
.nota-fecha { color: #6b7280; }
.lista-notas p { margin: 4px 0 0; font-size: 13px; white-space: pre-wrap; }

@media (max-width: 700px) {
    .dos-columnas { grid-template-columns: 1fr; }
}

/* --- Bloques de día plegables (details/summary nativos del navegador) --- */
.acciones-dias { display: flex; gap: 10px; margin: 14px 0; }
.acciones-dias .btn-secundario { margin: 0; }

.dia-bloque {
    background: white; border-radius: 8px; margin-bottom: 12px;
    overflow: hidden; border: 1px solid #e5e7eb;
}
.dia-bloque summary {
    padding: 12px 16px; cursor: pointer; list-style: none;
    display: flex; justify-content: space-between; align-items: center;
    background: #f9fafb; font-size: 13px;
}
.dia-bloque summary::-webkit-details-marker { display: none; }
.dia-bloque summary::before { content: "▸ "; }
.dia-bloque[open] summary::before { content: "▾ "; }
.dia-fecha { font-weight: 600; }
.dia-resumen { color: #6b7280; font-size: 12px; }
.dia-bloque .tabla-tareas { margin-top: 0; border-radius: 0; box-shadow: none; }

/* Día completo (todas las tareas Visualizadas o Sin vídeo) resaltado en verde */
.dia-bloque.dia-completo { border-color: #86efac; }
.dia-bloque.dia-completo summary { background: #f0fdf4; }
.dia-bloque.dia-completo .dia-fecha { color: #166534; }

.dia-acciones-masivas {
    display: flex; align-items: center; gap: 10px; padding: 10px 16px;
    background: #fafafa; border-bottom: 1px solid #f3f4f6; flex-wrap: wrap;
}
.dia-acciones-masivas .form-inline { gap: 6px; }

.btn-video { background: #ecfdf5; border: 1px solid #a7f3d0; color: #047857; }
.sin-video { color: #d1d5db; font-size: 12px; }
.btn-enlace { background: #eff6ff; border: 1px solid #bfdbfe; color: #1d4ed8; }
.btn-enlace:hover { background: #dbeafe; }

.btn-visualizado-accion { background: #dcfce7; border: 1px solid #86efac; color: #166534; }
.btn-visualizado-accion:hover { background: #bbf7d0; }
.btn-sinvideo-accion { background: #fee2e2; border: 1px solid #fca5a5; color: #b91c1c; }
.btn-sinvideo-accion:hover { background: #fecaca; }
.btn-deshacer-accion { background: #fef3c7; border: 1px solid #fcd34d; color: #92400e; }
.btn-deshacer-accion:hover { background: #fde68a; }

.estado-sin_video { background: #fee2e2; color: #b91c1c; }

.botones-cabecera { display: flex; gap: 10px; align-items: center; }
.botones-cabecera .btn-secundario { margin: 0; }

.fila-botones-form { display: flex; gap: 10px; margin-top: 8px; }
.fila-botones-form .btn-secundario { margin: 0; display: inline-flex; align-items: center; text-decoration: none; }

/* --- Botón flotante que muestra cuántos vídeos hay añadidos --- */
.boton-flotante-videos {
    position: fixed; bottom: 20px; right: 20px; z-index: 40;
    background: #111827; color: white; border: none; border-radius: 30px;
    padding: 12px 18px; font-size: 14px; cursor: pointer; box-shadow: 0 4px 12px rgba(0,0,0,0.25);
    display: flex; align-items: center; gap: 6px;
}

/* --- Panel lateral compacto con la lista de vídeos añadidos --- */
.panel-videos {
    position: fixed; bottom: 76px; right: 20px; z-index: 40; width: 300px;
    background: #1f2937; border-radius: 10px; padding: 12px; box-shadow: 0 8px 20px rgba(0,0,0,0.3);
}
.panel-videos-cabecera {
    display: flex; justify-content: space-between; align-items: center;
    color: white; font-size: 13px; margin-bottom: 8px;
}
.panel-videos-cabecera button { background: #374151; color: white; border: none; border-radius: 4px; padding: 2px 8px; cursor: pointer; }
.lista-videos { list-style: none; padding: 0; margin: 0 0 10px; max-height: 220px; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; }
.lista-videos li {
    display: flex; justify-content: space-between; align-items: center; gap: 8px;
    background: #111827; border-radius: 6px; padding: 6px 8px;
}
.lista-videos-etiqueta { color: #d1d5db; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lista-videos button { background: #374151; color: white; border: none; border-radius: 4px; padding: 2px 7px; cursor: pointer; flex-shrink: 0; }
.panel-videos-pie { display: flex; flex-direction: column; gap: 6px; }
.panel-videos-pie .btn, .panel-videos-pie .btn-secundario { width: 100%; text-align: center; margin: 0; }

/* --- Pantalla completa con todos los vídeos abiertos --- */
.overlay-pantalla-completa {
    position: fixed; inset: 0; z-index: 100; background: #0b0f19;
    display: flex; flex-direction: column; padding: 16px;
}
.overlay-cabecera {
    display: flex; justify-content: space-between; align-items: center;
    color: white; font-size: 15px; margin-bottom: 14px; flex-wrap: wrap; gap: 10px;
}
.overlay-cabecera .btn-secundario { margin: 0; background: #1f2937; color: white; border-color: #374151; }
.overlay-controles-globales { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.overlay-controles-globales select {
    background: #1f2937; color: white; border: 1px solid #374151; border-radius: 5px;
    padding: 5px 8px; font-size: 12px;
}
.overlay-grid {
    flex: 1; display: grid; gap: 14px; overflow-y: auto; align-content: start;
}
.overlay-vacio { color: #6b7280; }
.overlay-grid .video-tarjeta { background: #1f2937; border-radius: 8px; padding: 10px; }
.overlay-grid .video-tarjeta video { width: 100%; max-height: 45vh; border-radius: 6px; background: black; }

.video-cabecera {
    display: flex; justify-content: space-between; align-items: center;
    color: #d1d5db; font-size: 12px; margin-bottom: 6px;
}
.video-cabecera button { background: #374151; color: white; border: none; border-radius: 4px; padding: 2px 8px; cursor: pointer; }

.fila-velocidades { display: flex; align-items: center; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.etiqueta-velocidad { color: #9ca3af; font-size: 11px; margin-right: 2px; }
.btn-velocidad {
    background: #374151; color: #d1d5db; border: none; border-radius: 4px;
    padding: 3px 9px; font-size: 11px; cursor: pointer;
}
.btn-velocidad:hover { background: #4b5563; }
.btn-velocidad.activo { background: #3b82f6; color: white; }
.btn-cortar-toggle { background: #7c2d12; color: #fed7aa; margin-left: auto; }
.btn-cortar-toggle:hover { background: #9a3412; }

/* --- Mini formulario de recorte de vídeo --- */
.formulario-corte {
    margin-top: 10px; padding: 10px; background: #111827; border-radius: 6px;
    display: flex; flex-direction: column; gap: 8px;
}
.corte-fila { display: flex; align-items: center; gap: 6px; }
.corte-fila label { color: #9ca3af; font-size: 11px; width: 45px; flex-shrink: 0; }
.corte-fila input {
    flex: 1; background: #1f2937; border: 1px solid #374151; color: white;
    border-radius: 4px; padding: 5px 7px; font-size: 12px;
}
.corte-fila button { flex-shrink: 0; }
.btn-guardar-corte { background: #16a34a; color: white; border: none; }
.btn-guardar-corte:hover { background: #15803d; }
.btn-guardar-corte:disabled { opacity: 0.6; cursor: default; }
.corte-mensaje { font-size: 12px; margin: 0; }
.corte-mensaje.corte-exito { color: #86efac; }
.corte-mensaje.corte-error { color: #fca5a5; }

.dos-columnas-arriba { margin-top: 16px; margin-bottom: 8px; }

/* --- Visor de vídeos independiente (arrastrar y soltar) --- */
.btn-cabecera { text-decoration: none; display: inline-flex; align-items: center; margin: 0; }

.visor-controles-globales-fijo {
    display: flex; align-items: center; gap: 8px; margin: 16px 0;
    background: white; padding: 10px 14px; border-radius: 8px; font-size: 13px;
}
.visor-controles-globales-fijo select {
    padding: 5px 8px; border: 1px solid #d1d5db; border-radius: 5px; font-size: 12px;
}

.visor-grid-local {
    display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px;
}
@media (max-width: 900px) {
    .visor-grid-local { grid-template-columns: 1fr; }
}

.visor-casilla { border-radius: 10px; overflow: hidden; min-height: 280px; }

.visor-casilla-vacia {
    border: 2px dashed #d1d5db; background: white; cursor: pointer;
    display: flex; align-items: center; justify-content: center; text-align: center;
    color: #9ca3af; font-size: 14px; transition: background 0.15s, border-color 0.15s;
}
.visor-casilla-vacia:hover { background: #f9fafb; }
.visor-casilla-vacia.arrastrando { background: #eff6ff; border-color: #3b82f6; color: #3b82f6; }
.visor-casilla-vacia-subtexto { font-size: 12px; color: #9ca3af; }

.visor-casilla-llena { background: #111827; padding: 10px; display: flex; flex-direction: column; }
.visor-casilla-llena video { width: 100%; max-height: 320px; border-radius: 6px; background: black; }
.visor-casilla-llena .video-cabecera span {
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 260px;
}

.visor-herramientas { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.btn-captura { background: #ecfdf5; border: 1px solid #a7f3d0; color: #047857; }
.btn-captura:hover { background: #d1fae5; }

/* --- Recortes dentro de cada bloque de día --- */
.recortes-dia { padding: 12px 16px; background: #fffbeb; border-top: 1px solid #fde68a; }
.recortes-dia-titulo { font-size: 12px; font-weight: 600; color: #92400e; margin-bottom: 8px; }
.lista-recortes { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.lista-recortes li {
    display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
    background: white; border: 1px solid #fde68a; border-radius: 6px; padding: 6px 10px; font-size: 12px;
}
.recorte-nombre { font-weight: 600; }
.recorte-origen { color: #6b7280; }
.recorte-botones { display: flex; gap: 6px; margin-left: auto; }
.btn-origen { background: #eef2ff; border: 1px solid #c7d2fe; color: #3730a3; }
.btn-origen:hover { background: #e0e7ff; }

.recorte-nota-bloque { flex-basis: 100%; display: flex; align-items: flex-start; gap: 8px; margin-top: 4px; }
.recorte-nota-texto { margin: 0; font-size: 12px; color: #78350f; flex: 1; white-space: pre-wrap; }
.editar-nota { display: flex; flex-direction: column; gap: 6px; flex-basis: 100%; margin-top: 6px; }
.editar-nota textarea {
    padding: 6px 8px; border: 1px solid #d1d5db; border-radius: 5px; font-size: 12px; font-family: inherit;
}
.corte-fila-nota { align-items: flex-start; }
.corte-fila-nota textarea {
    flex: 1; background: #1f2937; border: 1px solid #374151; color: white;
    border-radius: 4px; padding: 5px 7px; font-size: 12px; font-family: inherit;
}
.video-nota {
    margin: 8px 0 0; padding: 8px 10px; background: #111827; border-left: 3px solid #3b82f6;
    border-radius: 4px; font-size: 12px; color: #d1d5db; white-space: pre-wrap;
}

/* Resalte temporal al saltar a la tarea de origen desde un recorte */
.fila-resaltada { animation: parpadeo-resalte 2.5s ease-out; }
@keyframes parpadeo-resalte {
    0%   { background-color: #fef08a; }
    100% { background-color: transparent; }
}

/* --- Cabecera del panel principal / archivados --- */
.cabecera-panel { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.cabecera-panel h2 { margin: 0; }
.cabecera-panel .btn-secundario { margin: 0; text-decoration: none; display: inline-flex; align-items: center; }

.tarjeta-pie-completo {
    display: flex; justify-content: space-between; align-items: center;
    padding: 10px 20px; border-top: 1px solid #f3f4f6; background: #f9fafb;
    border-radius: 0 0 8px 8px;
}
.etiqueta-completo { font-size: 12px; font-weight: 600; color: #166534; }

.aviso-archivado {
    background: #fef3c7; border: 1px solid #fde68a; color: #92400e;
    padding: 10px 14px; border-radius: 6px; font-size: 13px; margin-bottom: 12px;
}

/* --- Fila de edición inline de una tarea --- */
.fila-edicion td { background: #f9fafb; padding: 12px 16px; }
.formulario-editar-tarea { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.formulario-editar-tarea .form-inline { gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.formulario-editar-tarea label { display: block; }
.formulario-editar-tarea input { padding: 5px 7px; border: 1px solid #d1d5db; border-radius: 5px; font-size: 12px; }

/* --- Bloque plegable para añadir más cámaras/fechas a un expediente --- */
.bloque-anadir {
    background: white; border-radius: 8px; margin: 16px 0; border: 1px solid #e5e7eb; overflow: hidden;
}
.bloque-anadir summary {
    padding: 12px 16px; cursor: pointer; list-style: none; background: #f9fafb;
    font-size: 13px; font-weight: 600; color: #374151;
}
.bloque-anadir summary::-webkit-details-marker { display: none; }
.bloque-anadir .formulario { padding: 16px; margin: 0; max-width: none; }
