.csst-wrap { max-width: 960px; }

.csst-app { margin-top: 16px; }

.csst-loading { color: #666; }

/* --- Pantalla de acceso --- */
.csst-gate {
    max-width: 380px;
    background: #fff;
    border: 1px solid #dcdcde;
    border-radius: 8px;
    padding: 28px 28px 24px;
    margin-top: 24px;
}
.csst-gate h2 { margin-top: 0; font-size: 18px; }
.csst-gate label { display: block; font-size: 13px; color: #50575e; margin-bottom: 6px; }
.csst-gate input[type="text"], .csst-gate select {
    width: 100%; padding: 8px 10px; font-size: 14px; margin-bottom: 10px;
    border: 1px solid #8c8f94; border-radius: 4px;
}
.csst-gate button.button-primary { width: 100%; justify-content: center; display: flex; }
.csst-error { color: #b32d2e; font-size: 13px; margin: 0 0 10px; }
.csst-hint { color: #646970; font-size: 12px; margin: 0 0 12px; }
.csst-otp-info {
    background: #f0f0f1; border-radius: 4px; padding: 8px 10px; font-size: 13px;
    color: #50575e; margin-bottom: 14px;
}

/* --- Dashboard --- */
.csst-header { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; margin-bottom: 20px; }
.csst-header h2 { margin: 0; font-size: 18px; }
.csst-header .subtitulo { color: #646970; font-size: 13px; margin: 2px 0 0; }

.csst-metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 24px; }
.csst-metric { background: #f6f7f7; border-radius: 6px; padding: 14px 16px; }
.csst-metric .label { font-size: 12px; color: #646970; margin: 0 0 4px; }
.csst-metric .valor { font-size: 22px; font-weight: 600; margin: 0; }

.csst-metric-naranjo { background: #22c55e; }
.csst-metric-amarillo { background: #facc15; }
.csst-metric-naranjo .label { color: #fff; font-weight: 600; }
.csst-metric-amarillo .label { color: #000; font-weight: 600; }

.csst-metric-chart { display: flex; flex-direction: column; }
.csst-donut-wrap { display: flex; align-items: center; gap: 14px; margin-top: 4px; }
.csst-donut-leyenda { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: #fff; }
.csst-donut-leyenda span { display: flex; align-items: center; gap: 6px; }
.csst-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }

.csst-barchart { display: flex; align-items: flex-end; gap: 8px; margin-top: 8px; }
.csst-bar-col { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.csst-bar-track { width: 16px; display: flex; align-items: flex-end; background: rgba(0,0,0,0.1); border-radius: 3px; overflow: hidden; }
.csst-bar-fill { width: 100%; background: #000; border-radius: 3px 3px 0 0; }
.csst-bar-label { font-size: 10px; color: #000; font-weight: 600; }

/* --- Tabla por sección (colapsable) --- */
.csst-seccion { margin-bottom: 14px; border: 1px solid #e2e2e3; border-radius: 6px; overflow: hidden; }

.csst-seccion-header {
    display: flex; align-items: center; gap: 10px; background: #f0f0f1; padding: 10px 14px;
    cursor: pointer; user-select: none;
}
.csst-seccion-header:hover { background: #e5e5e6; }
.csst-seccion-titulo { font-size: 14px; font-weight: 500; flex: 1; }
.csst-seccion-pct { font-size: 13px; font-weight: 600; color: #50575e; }
.csst-seccion-flecha { font-size: 12px; color: #50575e; transition: transform 0.15s ease; }
.csst-seccion-header.csst-seccion-abierta .csst-seccion-flecha { transform: rotate(90deg); }

.csst-seccion-items { padding: 6px 14px 4px; }

.csst-item-wrapper { border-bottom: 1px solid #dcdcde; padding: 10px 4px 14px; }

.csst-item { display: grid; grid-template-columns: 1fr 140px 130px 120px; gap: 12px; align-items: start; }
.csst-item-sgsst { grid-template-columns: 1fr 150px 170px; }
.csst-item .num { color: #8c8f94; font-size: 13px; margin-right: 4px; }
.csst-item .desc { font-size: 13px; line-height: 1.5; }
.csst-item .legal { display: block; color: #8c8f94; font-size: 11px; margin-top: 4px; }

.csst-respuestas { display: flex; gap: 4px; }
.csst-respuestas button {
    flex: 1; padding: 5px 0; font-size: 12px; border: 1px solid #c3c4c7; border-radius: 4px;
    background: #fff; cursor: pointer;
}
.csst-respuestas button.activo-si { background: #d4f4dd; border-color: #1d9e75; color: #085041; }
.csst-respuestas button.activo-no { background: #fbdada; border-color: #e24b4a; color: #791f1f; }
.csst-respuestas button.activo-na { background: #ececec; border-color: #8c8f94; color: #50575e; }

.csst-guardado { font-size: 11px; color: #1d9e75; margin-left: 4px; }

/* --- Columna de plazo --- */
.csst-label-mini { display: block; font-size: 10px; color: #8c8f94; margin-bottom: 3px; text-transform: uppercase; }
.csst-input-plazo { width: 100%; font-size: 12px; padding: 4px 6px; border: 1px solid #c3c4c7; border-radius: 4px; }

/* --- Columna de estado --- */
.csst-col-estado { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.csst-badge-estado {
    font-size: 11px; padding: 3px 9px; border-radius: 10px; font-weight: 600; display: inline-block;
}
.csst-estado-pendiente { background: #f0f0f1; color: #50575e; }
.csst-estado-aprobado { background: #d4f4dd; color: #085041; }
.csst-estado-vencido { background: #fbdada; color: #791f1f; }

.csst-btn-aprobar {
    font-size: 11px; padding: 4px 8px; border: 1px solid #2271b1; border-radius: 4px;
    background: #fff; color: #2271b1; cursor: pointer;
}
.csst-btn-aprobar:hover { background: #2271b1; color: #fff; }

/* --- Subfila: documentos y observación admin --- */
.csst-subrow { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin-top: 10px; }
.csst-doc-box { background: #f9f9f9; border: 1px solid #ececec; border-radius: 6px; padding: 10px 12px; }
.csst-doc-label { font-size: 11px; color: #646970; margin: 0 0 6px; text-transform: uppercase; font-weight: 600; }
.csst-doc-vacio { font-size: 12px; color: #a7aaad; margin: 0 0 6px; }
.csst-doc-link { display: block; font-size: 12px; color: #2271b1; text-decoration: none; margin-bottom: 6px; word-break: break-all; }
.csst-doc-link:hover { text-decoration: underline; }
.csst-btn-eliminar-doc {
    display: block; font-size: 11px; padding: 3px 8px; margin-bottom: 8px; border: 1px solid #b32d2e; border-radius: 4px;
    background: #fff; color: #b32d2e; cursor: pointer;
}
.csst-btn-eliminar-doc:hover { background: #b32d2e; color: #fff; }
.csst-doc-box input[type="file"] { font-size: 11px; width: 100%; }

.csst-obs-admin { background: #fef8e7; border-color: #f0d78c; }
.csst-textarea-obs {
    width: 100%; font-size: 12px; padding: 6px 8px; border: 1px solid #e0c470; border-radius: 4px;
    resize: vertical; font-family: inherit;
}
.csst-obs-acciones { display: flex; align-items: center; justify-content: space-between; margin-top: 6px; }
.csst-btn-borrar-obs {
    font-size: 11px; padding: 4px 8px; border: 1px solid #b32d2e; border-radius: 4px;
    background: #fff; color: #b32d2e; cursor: pointer;
}
.csst-btn-borrar-obs:hover { background: #b32d2e; color: #fff; }

.csst-obs-lectura { background: #fef8e7; border-color: #f0d78c; }
.csst-obs-texto { font-size: 12px; color: #3c3c3c; margin: 0; line-height: 1.5; white-space: pre-wrap; }
.csst-obs-texto.csst-obs-vacia { color: #a7aaad; font-style: italic; }

/* --- Uso como shortcode dentro de una página normal del sitio --- */
.csst-frontend { max-width: 960px; margin: 0 auto; }
.csst-aviso-prueba {
    background: #fef8e7; border: 1px solid #f0d78c; border-radius: 6px; padding: 10px 14px;
    font-size: 13px; margin-bottom: 16px; color: #6b5900;
}

/* ============================================================ */
/* PANEL DE CONTROL SGSST — KPIs, resumen por eje, cronograma    */
/* ============================================================ */
.csst-kpis {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px;
    margin-bottom: 24px;
}
.csst-kpi {
    background: #f6f7f7; border-radius: 8px; padding: 18px 16px; text-align: center;
    border: 1px solid #dcdcde;
}
.csst-kpi-valor { font-size: 30px; font-weight: 700; margin: 0 0 4px; color: #1F4E79; }
.csst-kpi-label { font-size: 12px; color: #646970; margin: 0; text-transform: uppercase; letter-spacing: .3px; }
.csst-kpi-destacado { background: #1F4E79; }
.csst-kpi-destacado .csst-kpi-valor, .csst-kpi-destacado .csst-kpi-label { color: #fff; }

.csst-resumen-ejes { margin-bottom: 28px; overflow-x: auto; }
.csst-tabla-ejes { width: 100%; border-collapse: collapse; font-size: 13px; }
.csst-tabla-ejes th {
    background: #1F4E79; color: #fff; text-align: left; padding: 8px 10px; font-weight: 600;
}
.csst-tabla-ejes td { padding: 8px 10px; border-bottom: 1px solid #e2e2e2; }
.csst-anexo-clave { font-size: 11px; color: #646970; }

.csst-fila-eje { cursor: pointer; }
.csst-fila-eje:hover { background: #eef2f8 !important; }
.csst-fila-eje-flecha { width: 18px; color: #1F4E79; font-weight: 700; transition: transform .15s; }
.csst-fila-eje.csst-fila-eje-abierta .csst-fila-eje-flecha { transform: rotate(90deg); }
.csst-fila-eje-detalle td { background: #fbfcfd; padding: 12px 16px; border-bottom: 2px solid #dcdcde; }

.csst-tabla-detalle-actividades { width: 100%; border-collapse: collapse; font-size: 12px; }
.csst-tabla-detalle-actividades th {
    text-align: left; padding: 6px 8px; color: #646970; font-weight: 600; border-bottom: 1px solid #dcdcde;
}
.csst-tabla-detalle-actividades td { padding: 6px 8px; border-bottom: 1px solid #eee; vertical-align: top; }

.csst-barra-avance {
    position: relative; background: #e5e5e6; border-radius: 10px; height: 18px; min-width: 90px;
}
.csst-barra-relleno { background: #22c55e; height: 100%; border-radius: 10px; transition: width .3s; }
.csst-barra-avance span {
    position: absolute; top: 0; left: 0; right: 0; text-align: center; font-size: 11px;
    line-height: 18px; color: #1c1c1c; font-weight: 600;
}

.csst-anexo-badge {
    display: inline-block; background: #1F4E79; color: #fff; font-size: 10px; font-weight: 700;
    padding: 2px 7px; border-radius: 10px; margin-right: 6px; vertical-align: middle;
}

.csst-ficha-actividad {
    display: flex; flex-wrap: wrap; gap: 14px; font-size: 12px; color: #3c3c3c;
    padding: 6px 4px 10px; border-bottom: 1px dashed #dcdcde;
}
.csst-ficha-actividad strong { color: #1c1c1c; }

.csst-cronograma { padding: 10px 4px; }
.csst-meses { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }

/* Fila 1: meses planificados (chips, editables por el instructor si la frecuencia lo permite) */
.csst-meses-plan .csst-mes {
    display: inline-block; font-size: 11px; padding: 6px 10px; border-radius: 5px;
    background: #f0f0f1; color: #a7aaad; border: 1px solid #dcdcde;
}
.csst-meses-plan .csst-mes-planificado { background: #eef2f8; color: #1F4E79; border-color: #c9d7e8; font-weight: 600; }
.csst-meses-plan .csst-mes-clic { cursor: pointer; }
.csst-meses-plan .csst-mes-clic:hover { border-color: #1F4E79; }

/* Fila 2: cumplimiento (Sí/No), solo lo mueve el administrador — panel auditable */
.csst-meses-cumpl { }
.csst-mes-cumpl-btn, .csst-mes-cumpl-badge {
    display: inline-block; font-size: 11px; font-weight: 600; padding: 6px 10px; border-radius: 5px;
    border: 1px solid transparent;
}
.csst-mes-cumpl-btn { cursor: pointer; }
.csst-mes-si { background: #22c55e; color: #fff; }
.csst-mes-no { background: #f0f0f1; color: #8a8a8a; border-color: #dcdcde; }
.csst-mes-cumpl-btn.csst-mes-no:hover { border-color: #22c55e; color: #1a9e49; }
.csst-mes-cargando { opacity: .5; pointer-events: none; }

/* Lista de varios "documentos en blanco" por ítem */
.csst-lista-plantillas { display: flex; flex-direction: column; gap: 4px; margin-bottom: 8px; }
.csst-fila-plantilla {
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    padding: 4px 6px; border: 1px solid #e2e2e2; border-radius: 4px; background: #fafafa;
}
.csst-fila-plantilla .csst-doc-link { margin: 0; word-break: break-all; }
.csst-fila-plantilla .csst-btn-eliminar-doc { flex-shrink: 0; margin: 0; }

/* Tarjeta del Programa de Trabajo Preventivo general (en el resumen del panel) */
.csst-programa-general {
    display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
    background: #eef2f8; border: 1px solid #c9d7e8; border-radius: 8px; padding: 14px 18px;
    margin-bottom: 24px;
}
.csst-programa-general .csst-doc-label { margin: 0 0 4px; color: #1F4E79; font-weight: 600; }
.csst-programa-general .csst-doc-link { margin: 0; font-size: 14px; }
.csst-programa-general-acciones { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.csst-programa-general-acciones input[type="file"] { font-size: 11px; }

/* Formulario del Registro de Empresas */
.csst-formulario-empresa {
    background: #f6f7f7; border: 1px solid #dcdcde; border-radius: 8px; padding: 18px 20px; margin-bottom: 10px;
}
.csst-formulario-empresa h3 { margin-top: 0; }
.csst-form-fila { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.csst-form-fila-responsables { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.csst-formulario-empresa input[type="text"], .csst-formulario-empresa select {
    width: 100%; padding: 6px 8px; border: 1px solid #8c8f94; border-radius: 4px; font-size: 13px;
}
.csst-reg-error { font-size: 12px; }

/* ============================================================ */
/* PREVISUALIZACIÓN DE DOCUMENTOS — modal a tamaño de pantalla   */
/* ============================================================ */
.csst-preview-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0, 0, 0, 0.75);
    z-index: 100000; display: flex; align-items: center; justify-content: center; padding: 20px;
}
.csst-preview-box {
    background: #fff; border-radius: 8px; width: 95vw; height: 92vh; max-width: 1400px;
    display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 10px 40px rgba(0, 0, 0, .35);
}
.csst-preview-header {
    display: flex; align-items: center; gap: 14px; padding: 12px 16px;
    border-bottom: 1px solid #dcdcde; background: #f6f7f7; flex-shrink: 0;
}
.csst-preview-nombre {
    font-weight: 600; font-size: 14px; color: #1c1c1c; overflow: hidden;
    text-overflow: ellipsis; white-space: nowrap; flex: 1;
}
.csst-preview-descargar { font-size: 13px; text-decoration: none; color: #2271b1; white-space: nowrap; }
.csst-preview-descargar:hover { text-decoration: underline; }
.csst-preview-cerrar {
    background: none; border: none; font-size: 20px; cursor: pointer; color: #646970;
    line-height: 1; padding: 4px 8px; border-radius: 4px;
}
.csst-preview-cerrar:hover { color: #b32d2e; background: #f6dcdc; }
.csst-preview-cuerpo {
    flex: 1; overflow: auto; background: #525659; display: flex; align-items: center; justify-content: center;
}
.csst-preview-frame { width: 100%; height: 100%; border: none; }
.csst-preview-img { max-width: 100%; max-height: 100%; object-fit: contain; }
.csst-preview-sin-soporte { text-align: center; color: #fff; padding: 40px; }
.csst-preview-sin-soporte p { font-size: 15px; margin-bottom: 16px; }

@media (max-width: 782px) {
    .csst-item { grid-template-columns: 1fr; }
    .csst-meses { gap: 4px; }
    .csst-meses-plan .csst-mes, .csst-mes-cumpl-btn, .csst-mes-cumpl-badge { font-size: 9px; padding: 4px 6px; }
    .csst-programa-general { flex-direction: column; align-items: flex-start; }
    .csst-preview-box { width: 100vw; height: 100vh; border-radius: 0; max-width: none; }
}
