:root {
    --verde-claro: #008757;
    --blanco: #ffffff;
    --amarillo-dorado: #C99E67;
    --gris-suave: #f5f5f5;
    --primary-color: #2c3e50;
    --secondary-color: #3498db;
    --accent-color: #e74c3c;
    --text-color: #333;
    --light-gray: #f5f6fa;
    --border-color: #dcdde1;
    --success-color: #2ecc71;
    --warning-color: #f1c40f;
    --danger-color: #e74c3c;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Segoe UI', Arial, sans-serif;
    background: var(--gris-suave);
    color: #222;
    min-height: 100vh;
    display: flex;
}

.sidebar {
    background: var(--verde-claro);
    color: #222;
    width: 300px;
    height: 100vh;
    position: fixed;
    left: 0;
    top: 0;
    display: flex;
    flex-direction: column;
    padding-top: 4.5rem;
    box-shadow: 2px 0 8px rgba(0,0,0,0.05);
    z-index: 999;
    transition: transform 0.3s ease;
    overflow-y: auto;
}

.logo {
    margin-bottom: 2rem;
    color: var(--amarillo-dorado);
    font-weight: bold;
    font-size: 1.4rem;
    text-align: center;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0.8rem;
    justify-content: center;
    width: 100%;
}

.logo-img {
    width: 45px;
    height: auto;
}

.sidebar nav ul {
    list-style: none;
    width: 100%;
    padding: 0;
    margin: 0;
}

.sidebar nav ul li {
    width: 100%;
}

.sidebar nav ul li a {
    display: block;
    padding: 1rem 2rem;
    color: #222;
    text-decoration: none;
    font-size: 0.98rem;
    font-weight: bold;
    border-left: 5px solid transparent;
    transition: background 0.2s, border-color 0.2s;
}

.sidebar nav ul li a:hover,
.sidebar nav ul li a.active {
    background: var(--amarillo-dorado);
    color: var(--blanco);
    border-left: 5px solid var(--blanco);
}

.sidebar nav ul li a i {
    margin-right: 8px;
    width: 20px;
    text-align: center;
}

/* Estilos para divisores de navegación */
.sidebar nav ul li.nav-divider {
    padding: 0.8rem 2rem 0.4rem 2rem;
    margin-top: 0.5rem;
}

.sidebar nav ul li.nav-divider:first-child {
    margin-top: 0;
}

.sidebar nav ul li.nav-divider span {
    display: block;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--amarillo-dorado);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding-bottom: 0.3rem;
    border-bottom: 1px solid rgba(201, 158, 103, 0.3);
}

.main-content {
    margin-left: 300px;
    padding: 2rem;
    width: 100%;
    min-height: 100vh;
    background: var(--blanco);
}

header h1 {
    color: var(--verde-claro);
    margin-bottom: 1.5rem;
}

/* Responsive */
@media (max-width: 768px) {
    .menu-toggle {
        display: flex;
    }

    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.active {
        transform: translateX(0);
    }

    .sidebar-overlay.active {
        display: block;
    }

    .main-content {
        margin-left: 0;
        padding: 1rem;
        padding-top: 4rem;
    }
}

.menu-toggle {
    display: none;
    position: fixed;
    top: 1rem;
    left: 1rem;
    z-index: 1000;
    background: var(--verde-claro);
    color: var(--blanco);
    border: none;
    border-radius: 4px;
    padding: 0.8rem;
    cursor: pointer;
    font-size: 1.2rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    width: 45px;
    height: 45px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.menu-toggle:hover {
    background: var(--amarillo-dorado);
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 998;
}

/* Estilos para los estados */
.estado-pendiente {
    color: var(--warning-color);
}

.estado-en-proceso {
    color: var(--secondary-color);
}

.estado-completado {
    color: var(--success-color);
}

/* Estilos para el usuario y cierre de sesión */
.user-info {
    margin-top: auto;
    padding: 15px;
    border-top: 1px solid #eee;
}
.username {
    display: block;
    color: #333;
    font-weight: 500;
    margin-bottom: 10px;
}
.logout {
    color: #dc3545;
    display: flex;
    align-items: center;
    gap: 5px;
    text-decoration: none;
}
.logout:hover {
    color: #c82333;
}
.logout i {
    font-size: 16px;
}

/* === Menú de Análisis de Producto Terminado === */
.menu-pt-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(240px, 1fr));
    gap: 20px;
    margin-top: 10px;
}

/* Secciones del menú PT */
.menu-pt-section {
    margin: 10px 0 24px 0;
}

.menu-pt-section-title {
    font-size: 1.25rem;
    color: var(--primary-color);
    margin: 10px 0 8px 0;
    padding-bottom: 6px;
    border-bottom: 2px solid var(--border-color);
}

.menu-pt-card {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 16px;
    background: #fff;
    border: 1px solid #e5e5e5;
    border-radius: 10px;
    text-decoration: none;
    color: #333;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.menu-pt-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 14px rgba(0,0,0,0.10);
    border-color: var(--amarillo-dorado);
}

.menu-pt-card h3 {
    margin: 0;
    font-size: 1.05rem;
    color: var(--primary-color);
}

.menu-pt-card p {
    margin: 0;
    font-size: 0.92rem;
    color: #666;
}

.menu-pt-thumb {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 140px;
    border-radius: 8px;
    overflow: hidden;
    background: #fafafa;
    border: 1px solid #eee;
}

.menu-pt-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.menu-pt-thumb i {
    font-size: 48px;
    color: var(--verde-claro);
}

@media (max-width: 1100px) {
    .menu-pt-grid { grid-template-columns: repeat(2, minmax(240px, 1fr)); }
}

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

/* === Estilos específicos para la tabla de Palay === */
.formulario-palay {
    max-width: 100%;
    margin: 0 auto;
    padding: 24px 0;
}
.formulario-palay .tabla-scroll {
    overflow-x: auto;
    width: 100%;
}
.formulario-palay table {
    border-collapse: collapse;
    width: max-content;
    min-width: 1200px;
    background: #fff;
    font-size: 13px;
    margin: 0 auto;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
    border-radius: 8px;
    overflow: hidden;
}
.formulario-palay th, .formulario-palay td {
    border: 1px solid #bbb;
    padding: 8px 10px;
    text-align: center;
    vertical-align: middle;
    transition: background 0.2s;
}
.formulario-palay th {
    background: #222;
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    white-space: normal;
    min-width: 110px;
    max-width: 160px;
    word-break: break-word;
    border-bottom: 3px solid var(--verde-claro);
}
.formulario-palay th span.subtexto {
    font-size: 10px;
    font-weight: normal;
    color: #eee;
}
.formulario-palay tr:nth-child(even) td {
    background: #f7f7fa;
}
.formulario-palay tr:hover td {
    background: #e6f7f1;
}
.formulario-palay input[type="text"] {
    width: 95%;
    padding: 4px 6px;
    font-size: 13px;
    box-sizing: border-box;
    text-align: center;
    border: 1px solid #ccc;
    border-radius: 4px;
    background: #fafbfc;
    transition: border 0.2s;
}
.formulario-palay input[type="text"]:focus {
    border: 1.5px solid var(--verde-claro);
    background: #fff;
    outline: none;
}
@media (max-width: 900px) {
    .formulario-palay table {
        min-width: 900px;
    }
    .formulario-palay th, .formulario-palay td {
        font-size: 11px;
        padding: 4px 4px;
    }
}

/* Anchos personalizados para columnas de la tabla de Palay */
.col-muestra { width: 130px; min-width: 130px; }
.col-olor { width: 90px; min-width: 90px; }
.col-color { width: 90px; min-width: 90px; }
.col-plaga { width: 90px; min-width: 90px; }
.col-humedad { width: 100px; min-width: 100px; }
.col-peso { width: 120px; min-width: 120px; }
.col-semillas { width: 180px; min-width: 180px; }
.col-impurezas { width: 110px; min-width: 110px; }
.col-inmaduro { width: 110px; min-width: 110px; }
.col-danado { width: 110px; min-width: 110px; }
.col-manchado { width: 110px; min-width: 110px; }
.col-contrastante { width: 120px; min-width: 120px; }
.col-grano-rojo { width: 110px; min-width: 110px; }
.col-total-blancos { width: 120px; min-width: 120px; }
.col-total-enteros { width: 120px; min-width: 120px; }
.col-quebrados { width: 110px; min-width: 110px; }
.col-blancura { width: 110px; min-width: 110px; }
.col-yesoso { width: 110px; min-width: 110px; }
.col-estrellado { width: 120px; min-width: 120px; }
.col-tiempo-pulido { width: 120px; min-width: 120px; }
.col-autenticidad { width: 110px; min-width: 110px; }
.col-aprobado { width: 140px; min-width: 140px; }

/* Estilos para la tabla cabecera de los formularios */
.tabla-cabecera {
    width: 100%;
    min-width: 1200px;
    border-collapse: collapse;
    margin-bottom: 18px;
    background: #f8fafb;
    border-radius: 8px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.04);
    overflow: hidden;
}
.tabla-cabecera td {
    border: 1px solid #dcdde1;
    padding: 10px 14px;
    font-size: 15px;
    vertical-align: middle;
}
.tabla-cabecera label {
    font-weight: 600;
    color: var(--verde-claro);
    margin-right: 6px;
}
.tabla-cabecera input[type="text"],
.tabla-cabecera input[type="date"] {
    width: 100%;
    padding: 6px 8px;
    font-size: 15px;
    border: 1px solid #ccc;
    border-radius: 4px;
    background: #fff;
    box-sizing: border-box;
}
.tabla-cabecera .col-1 { width: 33%; }
.tabla-cabecera .col-2 { width: 33%; }
.tabla-cabecera .col-3 { width: 34%; }
.tabla-cabecera button {
    background: var(--verde-claro);
    color: #fff;
    border: none;
    border-radius: 4px;
    padding: 6px 10px;
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: 6px;
    transition: background 0.2s;
}
.tabla-cabecera button:hover {
    background: var(--amarillo-dorado);
}







/* === ESTILOS RESPONSIVOS UNIVERSALES PARA FORMULARIOS Y TABLAS === */

.formulario-responsivo {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 16px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
    overflow-x: auto;
}

.formulario-responsivo table {
    width: 100%;
    border-collapse: collapse;
    min-width: 800px;
}

.formulario-responsivo th,
.formulario-responsivo td {
    padding: 8px;
    text-align: center;
    border: 1px solid #ccc;
    font-size: 14px;
    word-break: break-word;
    vertical-align: middle;
}

.formulario-responsivo input,
.formulario-responsivo select,
.formulario-responsivo textarea {
    width: 100%;
    padding: 6px 8px;
    box-sizing: border-box;
    font-size: 14px;
    border-radius: 4px;
    border: 1px solid #ccc;
    background: #fdfdfd;
    transition: border 0.2s ease;
}

.formulario-responsivo input:focus,
.formulario-responsivo select:focus,
.formulario-responsivo textarea:focus {
    outline: none;
    border-color: #008757;
    background: #fff;
}

@media (max-width: 1024px) {
    .formulario-responsivo table {
        min-width: unset;
        font-size: 13px;
    }

    .formulario-responsivo th,
    .formulario-responsivo td {
        padding: 6px;
    }
}

@media (max-width: 768px) {
    .formulario-responsivo {
        padding: 10px;
    }

    .formulario-responsivo table {
        font-size: 12px;
    }

    .formulario-responsivo input,
    .formulario-responsivo select,
    .formulario-responsivo textarea {
        font-size: 12px;
    }
}

@media (max-width: 600px) {
    .formulario-responsivo table,
    .formulario-responsivo th,
    .formulario-responsivo td {
        font-size: 11px;
        padding: 4px;
    }

    .formulario-responsivo input,
    .formulario-responsivo select,
    .formulario-responsivo textarea {
        font-size: 11px;
        padding: 4px 6px;
    }
}

@media (max-width: 480px) {
    .formulario-responsivo th,
    .formulario-responsivo td {
        font-size: 10px;
    }

    .formulario-responsivo input,
    .formulario-responsivo select,
    .formulario-responsivo textarea {
        font-size: 10px;
    }
}
.select-autenticidad .palomita {
    color: #008757;
    font-weight: bold;
}
.select-autenticidad .tacha {
    color: #d32f2f;
    font-weight: bold;
}

.form-subtexto {
    display: block;
    margin-top: 4px;
    font-size: 0.8em;
    color: #666;
  }

/* Tabla de resultados Palay V2: letras más pequeñas */
.tabla-resultados-palay-v2 table,
.tabla-resultados-palay-v2 th,
.tabla-resultados-palay-v2 td {
    font-size: 12px !important;
}
/* Evitar salto de línea en los encabezados de la tabla de resultados Palay V2 */
.tabla-resultados-palay-v2 th {
    white-space: nowrap;
}

.btn-regresar-menu {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    background: var(--gris-suave);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 2rem;
    color: var(--verde-claro);
    text-decoration: none;
    margin-bottom: 1.5rem;
    margin-top: 0.5rem;
    box-shadow: 0 2px 6px rgba(0,0,0,0.06);
    transition: background 0.2s, color 0.2s;
}
.btn-regresar-menu:hover {
    background: var(--amarillo-dorado);
    color: var(--primary-color);
    text-decoration: none;
}

/* Estilos para el login */
.login-container {
    max-width: 400px;
    margin: 100px auto;
    padding: 20px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.login-form {
    display: flex;
    flex-direction: column;
    gap: 15px;
}
.form-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}
.form-group label {
    font-weight: bold;
    color: #333;
}
.form-group input {
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 16px;
}
.login-button {
    background: #4CAF50;
    color: white;
    padding: 12px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
}
.login-button:hover {
    background: #45a049;
}
.message-box {
    padding: 15px;
    margin-bottom: 20px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    gap: 10px;
    animation: slideIn 0.5s ease-out;
}
.message-box.error {
    background-color: #f8d7da;
    border: 1px solid #f5c6cb;
    color: #721c24;
}
.message-box.success {
    background-color: #d4edda;
    border: 1px solid #c3e6cb;
    color: #155724;
}
.message-box i {
    font-size: 20px;
}
@keyframes slideIn {
    from {
        transform: translateY(-20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Estilos para el select del login */
.login-form select {
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 16px;
    background: #fafafa;
    color: #333;
    transition: border 0.2s, box-shadow 0.2s;
    outline: none;
}
.login-form select:focus {
    border-color: var(--verde-claro, #4CAF50);
    box-shadow: 0 0 0 2px rgba(76,175,80,0.08);
}

/* Estilos de perfil horizontal */
.perfil-horizontal-container {
    max-width: 700px;
    margin: 40px auto;
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    padding: 2rem 2.5rem;
    display: flex;
    align-items: center;
    gap: 2.5rem;
    min-height: 180px;
}
.perfil-foto {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--verde-claro, #4CAF50);
    background: #f3f3f3;
    flex-shrink: 0;
}
.perfil-info {
    flex: 1;
    text-align: left;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.perfil-info h2 {
    margin: 0 0 0.3rem 0;
    font-size: 1.5rem;
    color: #333;
}
.perfil-info p {
    margin: 0.2rem 0;
    color: #666;
    font-size: 1.1rem;
}
.perfil-cerrar {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    justify-content: center;
    height: 100%;
}
.perfil-cerrar .logout {
    margin-top: 0;
    width: auto;
    justify-content: flex-end;
}
@media (max-width: 700px) {
    .perfil-horizontal-container {
        flex-direction: column;
        align-items: center;
        gap: 1.5rem;
        padding: 1.2rem 0.5rem;
    }
    .perfil-cerrar {
        align-items: center;
        width: 100%;
    }
    .perfil-cerrar .logout {
        width: 100%;
        justify-content: center;
    }
    .perfil-info {
    text-align: center;
    }
}

.notificacion-acceso {
    max-width: 400px;
    margin: 80px auto 0 auto;
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    padding: 2.5rem 2rem 2rem 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.2rem;
    text-align: center;
}
.notificacion-acceso i {
    color: var(--primary-color, #4CAF50);
    margin-bottom: 0.5rem;
}
.notificacion-acceso h2 {
    margin: 0;
    color: #333;
    font-size: 1.5rem;
}
.notificacion-acceso p {
    color: #666;
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
}
.notificacion-acceso .login-button {
    margin-top: 0.5rem;
    width: 100%;
    justify-content: center;
}

/* Estilos para campos de texto adicionales (olor y color) */
.formulario-responsivo input[type="text"][id*="_otro"] {
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 8px 12px;
    font-size: 14px;
    transition: border-color 0.3s ease;
    background-color: white;
}

.formulario-responsivo input[type="text"][id*="_otro"]:focus {
    outline: none;
    border-color: var(--verde-claro);
    box-shadow: 0 0 0 2px rgba(0, 135, 87, 0.1);
}

.formulario-responsivo input[type="text"][id*="_otro"]::placeholder {
    color: #999;
    font-style: italic;
}

/* Estilos para las gráficas */
.graficas-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

.grafica-container {
    background: white;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 15px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    transition: box-shadow 0.3s ease;
    position: relative; /* para posicionar popovers y botón info */
}

.grafica-container:hover {
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.grafica-container h3 {
    margin: 0 0 10px 0;
    font-size: 16px;
    color: #333;
    text-align: center;
    font-weight: 600;
}

/* Botón de información para cada gráfica */
.grafica-info-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: 1px solid #c9d1d9;
    background: #f3f4f6;
    color: #444;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}
.grafica-info-btn:hover { background: #e9ecef; }

/* Ubicación del popover dentro de cada gráfica */
.grafica-container .popover {
    top: 36px;
    right: 8px;
    max-width: 280px;
}

.grafica-container canvas {
    width: 100% !important;
    height: 200px !important;
}

/* Responsive para las gráficas */
@media (max-width: 1200px) {
    .graficas-grid {
        grid-template-columns: 1fr;
        max-width: 800px;
    }
}

@media (max-width: 768px) {
    .graficas-grid {
        padding: 10px;
        gap: 15px;
    }
    
    .grafica-container {
        padding: 10px;
    }
    
    .grafica-container h3 {
        font-size: 14px;
    }
}

/* Estilos para las gráficas de PT */
.graficas-grid-pt {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

.grafica-container-pt {
    background: white;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 15px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    transition: box-shadow 0.3s ease;
    position: relative;
    cursor: pointer;
}

.grafica-container-pt:hover {
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.grafica-container-pt h3 {
    margin: 0 0 10px 0;
    font-size: 16px;
    color: #333;
    text-align: center;
    font-weight: 600;
}

.grafica-container-pt canvas {
    width: 100% !important;
    height: 200px !important;
}

.contenedor-graficas-pt {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 20px;
    margin-top: 20px;
}

.btn-graficas {
    background: #17a2b8;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: background-color 0.3s ease;
}

.btn-graficas:hover {
    background: #138496;
}

/* Responsive para las gráficas de PT */
@media (max-width: 1200px) {
    .graficas-grid-pt {
        grid-template-columns: 1fr;
        max-width: 800px;
    }
}

@media (max-width: 768px) {
    .graficas-grid-pt {
        padding: 10px;
    gap: 15px;
}

    .grafica-container-pt {
        padding: 10px;
    }
    
    .grafica-container-pt h3 {
        font-size: 14px;
    }
}

/* Estilos para el modal de gráfica ampliada */
.grafica-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: none;
    z-index: 10000;
    justify-content: center;
    align-items: center;
}

/* Modal para gráficas de PT */
.modal-grafica-pt {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: none;
    z-index: 1000;
}

.modal-content-grafica-pt {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    padding: 20px;
    border-radius: 8px;
    width: 90%;
    max-width: 1200px;
    max-height: 90vh;
    overflow: auto;
}

.modal-canvas-container {
    width: 100%;
    height: 500px;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: 20px;
}

.close-modal-grafica-pt {
    position: absolute;
    top: 10px;
    right: 15px;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    color: #aaa;
}

.close-modal-grafica-pt:hover {
    color: #000;
}

.modal-content-grafica-pt h2 {
    margin: 0 0 20px 0;
    text-align: center;
    color: #333;
}

.modal-content-grafica-pt canvas {
    max-width: 100%;
    height: auto;
}

/* === DASHBOARD PANEL GENERAL === */
.dashboard-container {
    padding: 20px;
    max-width: 1400px;
    margin: 0 auto;
}

.dashboard-header {
    background: linear-gradient(135deg, var(--verde-claro) 0%, var(--amarillo-dorado) 100%);
    color: white;
    padding: 30px;
    border-radius: 15px;
    margin-bottom: 30px;
    text-align: center;
}

.dashboard-header h1 {
    margin: 0;
    font-size: 2.5rem;
    font-weight: 300;
}

.dashboard-header p {
    margin: 10px 0 0 0;
    font-size: 1.1rem;
    opacity: 0.9;
}

.welcome-message {
    background: white;
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    text-align: center;
    margin-top: 20px;
}

.welcome-message h2 {
    color: var(--verde-claro);
    margin-bottom: 15px;
    font-size: 1.8rem;
}

.welcome-message p {
    color: #666;
    font-size: 1.1rem;
    line-height: 1.6;
    margin-bottom: 10px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: white;
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    text-align: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 15px rgba(0, 0, 0, 0.15);
}

.stat-card .stat-icon {
    font-size: 2.5rem;
    margin-bottom: 15px;
    color: var(--verde-claro);
}

.stat-card .stat-value {
    font-size: 2rem;
    font-weight: bold;
    color: #2d3748;
    margin-bottom: 5px;
}

.stat-card .stat-label {
    color: #718096;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 25px;
    margin-bottom: 30px;
}

.chart-card {
    background: white;
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.chart-card h3 {
    margin: 0 0 20px 0;
    color: #2d3748;
    font-size: 1.2rem;
    text-align: center;
}

.chart-container {
    position: relative;
    height: 300px;
    width: 100%;
}

.chart-card-tall {
    grid-row: span 2;
}

.chart-card-wide {
    grid-column: span 2;
}

/* Contenedor de Análisis */
.analisis-container {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 20px;
    height: 100%;
    overflow: hidden;
}

/* Panel de Controles (Izquierda) - Sin contenedor extra */
.controles-section {
    display: flex;
    flex-direction: column;
    padding: 0;
}

.controles-section h4 {
    color: #008757;
    font-size: 14px;
    margin: 0 0 10px 0;
    padding-bottom: 8px;
    border-bottom: 2px solid #C99E67;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Fila de controles (2 columnas) */
.control-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 8px;
}

.control-group {
    display: flex;
    flex-direction: column;
}

.control-group label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 3px;
}

.control-select {
    width: 100%;
    padding: 6px 8px;
    border: 2px solid #dee2e6;
    border-radius: 4px;
    font-size: 12px;
    background: white;
    color: #495057;
    cursor: pointer;
    transition: all 0.3s ease;
}

.control-select:hover {
    border-color: #C99E67;
}

.control-select:focus {
    outline: none;
    border-color: #008757;
    box-shadow: 0 0 0 3px rgba(0, 135, 87, 0.1);
}

/* Botones de Control */
.control-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 12px;
}

/* Ajuste para 3 botones (cuando hay PDF) */
.control-buttons button:nth-child(3) {
    grid-column: 1 / -1; /* El tercer botón ocupa todo el ancho */
}

.btn-control {
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    font-size: 12px;
    font-weight: normal;
    cursor: pointer;
    transition: background-color 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.btn-aplicar {
    background: #007bff;
    color: white;
}

.btn-aplicar:hover {
    background: #0056b3;
}

.btn-limpiar {
    background: #6c757d;
    color: white;
}

.btn-limpiar:hover {
    background: #545b62;
}

.btn-exportar {
    background: #28a745;
    color: white;
}

.btn-exportar:hover {
    background: #218838;
}

/* Panel de Gráfica (Derecha) */
.grafica-panel {
    background: white;
    border-radius: 10px;
    padding: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    height: 100%;
    max-height: 300px;
    position: relative;
    overflow: hidden;
}

.grafica-panel canvas {
    width: 100% !important;
    height: 100% !important;
    max-height: 280px;
    cursor: pointer;
    transition: opacity 0.3s ease;
}

.grafica-panel canvas:hover {
    opacity: 0.9;
}

/* Modal de Análisis Ampliado */
.modal-analisis {
    display: none;
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    animation: fadeIn 0.3s ease;
}

.modal-analisis-content {
    position: relative;
    background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
    margin: 2% auto;
    padding: 30px;
    width: 95%;
    max-width: 1400px;
    height: 90vh;
    border-radius: 15px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    animation: slideDown 0.4s ease;
    display: flex;
    flex-direction: column;
}

.modal-analisis-close {
    position: absolute;
    top: 15px;
    right: 15px;
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    z-index: 10;
}

.modal-analisis-close:hover {
    background: #c82333;
    transform: rotate(90deg);
}

.modal-analisis-titulo {
    color: #008757;
    font-size: 28px;
    margin: 0 0 20px 0;
    padding-bottom: 15px;
    border-bottom: 3px solid #C99E67;
    display: flex;
    align-items: center;
    gap: 15px;
}

.modal-analisis-body {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 25px;
    flex: 1;
    overflow: hidden;
}

/* Panel de Controles en Modal (sin contenedor extra) */
.modal-controles-section {
    display: flex;
    flex-direction: column;
    padding: 0;
}

.modal-controles-section h4 {
    color: #008757;
    font-size: 18px;
    margin: 0 0 20px 0;
    padding-bottom: 12px;
    border-bottom: 2px solid #C99E67;
    display: flex;
    align-items: center;
    gap: 10px;
}

.modal-controles-section .control-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 15px;
}

.modal-controles-section .control-group {
    display: flex;
    flex-direction: column;
}

.modal-controles-section .control-group label {
    font-size: 13px;
    margin-bottom: 6px;
}

.modal-controles-section .control-select {
    padding: 10px;
    font-size: 14px;
}

.modal-controles-section .control-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-top: 25px;
}

/* Ajuste para 3 botones en el modal (cuando hay PDF) */
.modal-controles-section .control-buttons button:nth-child(3) {
    grid-column: 1 / -1; /* El tercer botón ocupa todo el ancho */
}

.modal-controles-section .btn-control {
    padding: 12px 20px;
    font-size: 14px;
}

/* Panel de Gráfica en Modal */
.modal-grafica-panel {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.modal-grafica-panel canvas {
    width: 100% !important;
    height: 100% !important;
}

/* Animaciones */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-50px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Responsive para modal */
@media (max-width: 768px) {
    .modal-analisis-content {
        width: 98%;
        height: 95vh;
        margin: 1% auto;
        padding: 15px;
    }
    
    .modal-analisis-titulo {
        font-size: 20px;
    }
    
    .modal-analisis-body {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr;
        gap: 15px;
    }
    
    .modal-controles-section {
        max-height: none;
    }
}

.chart-container-tall {
    height: 620px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    gap: 15px;
    padding: 15px;
}

.kpi-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
}

.kpi-title {
    font-size: 14px;
    color: #2d3748;
    font-weight: 600;
    text-align: center;
    margin-bottom: 5px;
}

.kpi-canvas-container {
    position: relative;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 220px;
}

.kpi-canvas-container canvas {
    width: 100%;
    height: 100%;
    max-width: 220px;
    max-height: 220px;
}

.kpi-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    width: 100%;
}

.kpi-slider-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    width: 100%;
}

.kpi-slider-container input[type="range"] {
    width: 80%;
    height: 6px;
    background: #ddd;
    border-radius: 3px;
    outline: none;
    appearance: none;
    -webkit-appearance: none;
}

.kpi-slider-container input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    background: #008757;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.kpi-slider-container input[type="range"]::-moz-range-thumb {
    width: 16px;
    height: 16px;
    background: #008757;
    border-radius: 50%;
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.kpi-value-display {
    font-size: 12px;
    color: #2c3e50;
    font-weight: bold;
    text-align: center;
    background: white;
    padding: 4px 8px;
    border-radius: 4px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    min-width: 45px;
}


.machines-grid {
    background: white;
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    margin-bottom: 30px;
}

.machines-grid h3 {
    margin: 0 0 20px 0;
    color: #2d3748;
    font-size: 1.2rem;
    text-align: center;
}

.machines-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
    gap: 10px;
    max-width: 800px;
    margin: 0 auto;
}

.machine-item {
    text-align: center;
    padding: 15px 10px;
    border-radius: 8px;
    font-weight: bold;
    font-size: 0.9rem;
    transition: all 0.2s ease;
    cursor: pointer;
}

.machine-item small {
    display: block;
    font-size: 0.7rem;
    font-weight: normal;
    margin-top: 4px;
    line-height: 1.1;
    word-break: break-word;
}

.machine-item:hover {
    transform: scale(1.05);
}

.machine-item.disponible {
    background: rgba(0, 135, 87, 0.1);
    color: var(--verde-claro);
    border: 2px solid var(--verde-claro);
}

.machine-item.activo {
    background: rgba(201, 158, 103, 0.1);
    color: var(--amarillo-dorado);
    border: 2px solid var(--amarillo-dorado);
}

.machine-item.pausado {
    background: rgba(255, 152, 0, 0.1);
    color: #FF9800;
    border: 2px solid #FF9800;
}

.alerts-section {
    background: white;
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    margin-bottom: 30px;
}

.alerts-section h3 {
    margin: 0 0 20px 0;
    color: #2d3748;
    font-size: 1.2rem;
    text-align: center;
}

.alert-item {
    padding: 15px;
    margin-bottom: 10px;
    border-radius: 8px;
    border-left: 4px solid;
    display: flex;
    align-items: center;
    gap: 15px;
}

.alert-item.warning {
    background: #fef5e7;
    border-left-color: #f6ad55;
    color: #744210;
}

.alert-item.info {
    background: #e6fffa;
    border-left-color: #4fd1c7;
    color: #234e52;
}

.alert-item.danger {
    background: #fed7d7;
    border-left-color: #f56565;
    color: #742a2a;
}

.alert-icon {
    font-size: 1.5rem;
}

.refresh-button {
    position: fixed;
    bottom: 30px;
    right: 30px;
    background: var(--verde-claro);
    color: white;
    border: none;
    border-radius: 50%;
    width: 60px;
    height: 60px;
    font-size: 1.5rem;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transition: all 0.2s ease;
    z-index: 1000;
}

.refresh-button:hover {
    background: #5a67d8;
    transform: scale(1.1);
}

@media (max-width: 768px) {
    .dashboard-container {
        padding: 10px;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .charts-grid {
        grid-template-columns: 1fr;
    }
    
    .machines-container {
        grid-template-columns: repeat(auto-fit, minmax(60px, 1fr));
    }
    
    .dashboard-header h1 {
        font-size: 2rem;
    }
}

/* === PT Selección (Dual-axis tabs y tabla placeholder) === */
.pt-seleccion-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}

.pt-tabs-wrapper {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 10px 0 16px 0;
    padding: 15px 0 10px 0;
}

.pt-tabs,
.pt-subtabs {
    display: flex;
    flex-wrap: nowrap;
    gap: 6px;
    overflow-x: auto;
    overflow-y: hidden; /* evitar barra vertical */
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE/Edge legacy */
}

.pt-tabs::-webkit-scrollbar,
.pt-subtabs::-webkit-scrollbar { display: none; } /* WebKit */

/* Barra base para efecto "pestañas de navegador" */
.pt-tabs-bar,
.pt-subtabs-bar {
    display: flex;
    align-items: flex-end;
    border-bottom: 1px solid #d0d7de;
    padding: 8px 6px 0 6px;
    background: #f6f8fa;
    border-radius: 8px 8px 0 0;
    min-height: 60px;
}

.pt-tab,
.pt-subtab {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 18px;
    border: 1px solid #c9d1d9;
    border-bottom: none;
    border-radius: 10px 10px 0 0;
    text-decoration: none;
    background: #e9ecef;
    color: #555;
    font-weight: 600;
    white-space: nowrap;
    position: relative;
    top: 1px; /* para solapar la línea base */
    transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
    min-height: 45px;
}

.pt-tab:hover,
.pt-subtab:hover { background: #e2e6ea; color: #333; }

.pt-tab.active,
.pt-subtab.active {
    background: #fff;
    color: #222;
    border-color: #c9d1d9;
    z-index: 2;
    box-shadow: 0 -1px 8px rgba(0,0,0,0.06);
}

/* Oscurecer no activas cuando hay activa */
.pt-tab:not(.active),
.pt-subtab:not(.active) {
    background: #dfe3e7;
    color: #666;
}

/* Estado deshabilitado para subtabs de máquinas */
.pt-subtabs.disabled { opacity: 0.6; filter: grayscale(0.2); }
.pt-subtabs.disabled .pt-subtab { pointer-events: none; cursor: not-allowed; }

.pt-panel {
    display: block;
}

.tabla-registros-pt {
    width: 100%;
    border-collapse: collapse;
}

.tabla-registros-pt th,
.tabla-registros-pt td {
    border: 1px solid #ccc;
    padding: 10px 12px;
    text-align: left;
    font-size: 14px;
}

.tabla-registros-pt th {
    background: #222;
    color: #fff;
    font-weight: 600;
    border-bottom: 3px solid var(--verde-claro);
}

.tabla-registros-pt tr:nth-child(even) td { background: #f9f9fb; }

.tabla-leyenda {
    text-align: center;
    color: #777;
    font-style: italic;
}

.btn-primario {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: var(--verde-claro);
    color: #fff;
    text-decoration: none;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    font-weight: 700;
    transition: background 0.2s ease;
}

.btn-primario:hover { background: var(--amarillo-dorado); }

/* Utilidades específicas de PT selección */
.pt-seleccion-subtitle { color:#666; margin-top:6px; }
.pt-panel-top { display:flex; align-items:center; justify-content: space-between; margin: 6px 0 12px 0; }
.pt-selection-label { color:#444; font-weight:600; }

/* Header controls para PT selección */
.pt-header-controls {
    display: flex;
    align-items: center;
    gap: 20px;
}

.btn-secundario {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: #6c757d;
    color: white;
    text-decoration: none;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    font-weight: 600;
    transition: background 0.2s;
}

.btn-secundario:hover {
    background: #545b62;
    color: white;
    text-decoration: none;
}

/* Estilos específicos para tabla de muestras PT */

.pt-formulario-muestras .tabla-scroll {
    overflow-x: auto;
}

/* Contenedor para limpiar el float después de las tablas */
.pt-formulario-muestras .clearfix {
    display: none;
}

/* Tabla de entrada (izquierda) */
.pt-formulario-muestras .formulario-muestras-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    border-radius: 8px;
    overflow: hidden;
    font-size: 12px;
    table-layout: fixed; /* Ensure consistent column widths */
    min-width: 0;
}

.pt-formulario-muestras .formulario-muestras-table colgroup {
    display: block;
}

.pt-formulario-muestras .formulario-muestras-table th,
.pt-formulario-muestras .formulario-muestras-table td {
    padding: 8px 6px;
    text-align: center;
    border: 1px solid #e0e0e0;
    vertical-align: middle;
    height: 40px; /* Consistent height for all rows */
}

/* Reglas específicas para alturas personalizadas - mayor prioridad */
.pt-formulario-muestras .formulario-muestras-table tr[style*="height: 48.8px"] td {
    height: 48.8px !important;
    vertical-align: middle;
}

.pt-formulario-muestras .formulario-muestras-table th {
    background: var(--verde-claro);
    color: white;
    font-weight: bold;
    font-size: 11px;
    white-space: normal;
    word-break: break-word;
}

/* Anchos específicos para columnas de la tabla de entrada */
.pt-formulario-muestras .col-analito { 
    width: auto; /* Dejar que colgroup controle */
    min-width: auto;
}
.pt-formulario-muestras .col-especificacion { 
    width: auto; /* Dejar que colgroup controle */
    min-width: auto;
}
.pt-formulario-muestras .col-unidad { 
    width: auto; /* Dejar que colgroup controle */
    min-width: auto;
}
.pt-formulario-muestras .col-muestra { 
    width: auto; /* Dejar que colgroup controle */
    min-width: auto;
}

.pt-formulario-muestras .formulario-muestras-table input,
.pt-formulario-muestras .formulario-muestras-table select {
    width: 100%;
    padding: 4px 6px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 11px;
    text-align: center;
    box-sizing: border-box;
}

.pt-formulario-muestras .formulario-muestras-table input:focus,
.pt-formulario-muestras .formulario-muestras-table select:focus {
    outline: none;
    border-color: var(--verde-claro);
    box-shadow: 0 0 0 2px rgba(0, 135, 87, 0.2);
}

.pt-formulario-muestras .formulario-muestras-table .section-header {
    background: var(--amarillo-dorado) !important;
    color: white !important;
    font-weight: bold !important;
    text-align: center !important;
    font-size: 11px !important;
    height: 40px; /* Consistent height for section headers */
    vertical-align: middle;
}

/* Headers de sección */
.pt-formulario-muestras .formulario-muestras-table .section-header {
    background: var(--amarillo-dorado) !important;
    color: white !important;
    font-weight: bold !important;
    text-align: center !important;
    font-size: 11px !important;
    height: 40px; /* Consistent height for section headers */
    vertical-align: middle;
}

/* Tabla de registros guardados (derecha) */
.pt-formulario-muestras .tabla-scroll-derecha {
    overflow-x: auto;
}

.pt-formulario-muestras .formulario-muestras-table-registros {
    width: 100%;
    border-collapse: collapse;
    background: white;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    border-radius: 8px;
    overflow: hidden;
    font-size: 12px;
    table-layout: fixed;
    min-width: 0;
}

.pt-formulario-muestras .formulario-muestras-table-registros th {
    font-size: 11px;
    background: var(--verde-claro);
    color: white;
    border: 1px solid #e0e0e0;
    padding: 8px 6px;
    text-align: center;
    font-weight: bold;
    height: 40px;
    vertical-align: middle;
    white-space: normal;
    word-break: break-word;
}

.pt-formulario-muestras .formulario-muestras-table-registros td {
    font-size: 11px;
    border: 1px solid #e0e0e0;
    padding: 8px 6px;
    text-align: center;
    height: 40px;
    vertical-align: middle;
    background: white;
}

/* Reglas específicas para alturas personalizadas en tabla de registros - mayor prioridad */
.pt-formulario-muestras .formulario-muestras-table-registros tr[style*="height: 48.8px"] td {
    height: 48.8px !important;
    vertical-align: middle;
}

.pt-formulario-muestras .col-titulo-registros {
    width: 100%;
    min-width: 100%;
}

.pt-formulario-muestras .col-muestra-registro {
    width: 90px;
    min-width: 90px;
}

.pt-formulario-muestras .formulario-muestras-table-registros .section-header {
    font-size: 11px !important;
    background: var(--amarillo-dorado) !important;
    color: white !important;
    font-weight: bold !important;
    text-align: center !important;
    height: 40px;
    vertical-align: middle;
}

/* Ajustes específicos para filas de la tabla de registros */
.pt-formulario-muestras .formulario-muestras-table-registros tr:nth-child(1) th {
    height: 45px; /* Altura del título principal (disminuida ~1mm) */
    vertical-align: middle;
}

.pt-formulario-muestras .formulario-muestras-table-registros tr:nth-child(7) td {
    height: 40px; /* Altura de la fila de plaga (disminuida ~2mm) */
    vertical-align: middle;
}

/* Ajustes adicionales para filas específicas */
.pt-formulario-muestras .formulario-muestras-table-registros tr:nth-child(7) td {
    height: 45px; /* Aumentar 5px en la fila de impurezas (fila 7) */
    vertical-align: middle;
}

.pt-formulario-muestras .formulario-muestras-table-registros tr:nth-child(17) td {
    height: 42px; /* Aumentar 2px en la fila de variedades contrastantes (fila 17) */
    vertical-align: middle;
}

/* Columnas de especificaciones (fijas) */
.pt-formulario-muestras .formulario-muestras-table td:nth-child(1),
.pt-formulario-muestras .formulario-muestras-table td:nth-child(2),
.pt-formulario-muestras .formulario-muestras-table td:nth-child(3) {
    background: #f8f9fa;
    font-weight: 500;
    text-align: left;
}

.pt-formulario-muestras .formulario-muestras-table td:nth-child(1) {
    text-align: left;
}

.pt-formulario-muestras .formulario-muestras-table td:nth-child(2) {
    text-align: center;
}

.pt-formulario-muestras .formulario-muestras-table td:nth-child(3) {
    text-align: center;
}

/* Columnas de muestras (dinámicas) */
.pt-formulario-muestras .formulario-muestras-table td:nth-child(4) {
    background: white;
}

/* Form actions con controles de estado integrados - Botones flotantes en posición original */
.pt-formulario-muestras .form-actions {
    position: sticky;
    bottom: 20px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 15px;
    margin: 20px 0 10px 0;
    padding: 15px 20px;
    background: transparent;
    border: none;
    border-radius: 12px;
    z-index: 100;
    width: fit-content;
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}



.pt-formulario-muestras .btn-pausar,
.pt-formulario-muestras .btn-finalizar,
.pt-formulario-muestras .btn-reanudar {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 140px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.pt-formulario-muestras .btn-pausar {
    background: #ffc107;
    color: #000;
}

.pt-formulario-muestras .btn-pausar:hover {
    background: #e0a800;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.pt-formulario-muestras .btn-finalizar {
    background: #dc3545;
    color: white;
}

.pt-formulario-muestras .btn-finalizar:hover {
    background: #c82333;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.pt-formulario-muestras .btn-reanudar {
    background: #28a745;
    color: white;
}

.pt-formulario-muestras .btn-reanudar:hover {
    background: #218838;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.pt-formulario-muestras .btn-guardar {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 140px;
    background: var(--verde-claro);
    color: white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.pt-formulario-muestras .btn-guardar:hover {
    background: #008752;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.pt-formulario-muestras .btn-pausar:disabled,
.pt-formulario-muestras .btn-reanudar:disabled,
.pt-formulario-muestras .btn-finalizar:disabled,
.pt-formulario-muestras .btn-guardar:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
    transform: none !important;
}



.pt-formulario-muestras .proceso-finalizado {
    color: #6c757d;
    font-style: italic;
}

.pt-container {
    background: #fff;
    border: 1px solid #e5e5e5;
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.tabla-registros-pt tbody tr.clickable { cursor: pointer; }
.tabla-registros-pt tbody tr:hover td { background: #eef8f3; }


.grafica-modal.active {
    display: flex !important;
    opacity: 1;
    justify-content: center;
    align-items: center;
}

.grafica-modal-content {
    background: white;
    border-radius: 12px;
    padding: 20px;
    max-width: 95vw;
    width: 1200px;
    max-height: 90vh;
    position: relative;
    transform: scale(0.7);
    transition: transform 0.3s ease;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    margin: auto;
}

.grafica-modal.active .grafica-modal-content {
    transform: scale(1);
}

.grafica-modal-close {
    position: absolute;
    top: 10px;
    right: 15px;
    background: #ff4757;
    color: white;
    border: none;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
    z-index: 10000;
}

.grafica-modal-close:hover {
    background: #ff3742;
}

.grafica-modal-title {
    margin: 0 0 20px 0;
    font-size: 20px;
    color: #333;
    text-align: center;
    font-weight: 600;
}

.grafica-modal-canvas {
    width: 100%;
    height: 60vh;
    max-width: 1100px;
}

/* Hacer las gráficas clickeables */
.grafica-container {
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.grafica-container:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0,0,0,0.2);
}

.grafica-container:active {
    transform: translateY(0);
}

/* Responsive para el modal */
@media (max-width: 1200px) {
    .grafica-modal-content {
        width: 95vw;
        max-width: 95vw;
    }
    
    .grafica-modal-canvas {
        max-width: 90vw;
    }
}

@media (max-width: 768px) {
    .grafica-modal-content {
        padding: 5px;
        max-width: 100vw;
        width: 100vw;
        max-height: 100vh;
        height: 100vh;
        border-radius: 0;
        margin: 0;
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        overflow: hidden;
    }
    
    .grafica-modal-title {
        font-size: 14px;
        margin-bottom: 5px;
        transform: rotate(90deg);
        white-space: nowrap;
        order: 2;
    }
    
    .grafica-modal-canvas {
        height: 100vw;
        width: 100vh;
        max-width: 100vh;
        max-height: 100vw;
        transform: rotate(90deg);
        transform-origin: center;
        order: 1;
        display: block;
    }
    
    .grafica-modal-close {
        width: 30px;
        height: 30px;
        font-size: 18px;
        top: 10px;
        right: 15px;
        background: rgba(255, 71, 87, 0.9);
        position: absolute;
        z-index: 10001;
    }
    
    .grafica-modal-close:hover {
        background: rgba(255, 55, 66, 0.9);
    }
}

/* Dispositivos móviles pequeños (480px y menos) */
@media (max-width: 480px) {
    .grafica-modal-content {
        padding: 3px;
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        overflow: hidden;
    }
    
    .grafica-modal-title {
        font-size: 12px;
        margin-bottom: 3px;
        transform: rotate(90deg);
        white-space: nowrap;
        order: 2;
    }
    
    .grafica-modal-canvas {
        height: 100vw;
        width: 100vh;
        max-width: 100vh;
        max-height: 100vw;
        transform: rotate(90deg);
        transform-origin: center;
        order: 1;
        display: block;
    }
    
    .grafica-modal-close {
        width: 28px;
        height: 28px;
        font-size: 16px;
        top: 8px;
        right: 12px;
        position: absolute;
        z-index: 10001;
    }
}

/* Orientación landscape en móviles - sin rotación */
@media (max-width: 768px) and (orientation: landscape) {
    .grafica-modal-content {
        padding: 5px;
        height: 100vh;
        display: flex;
        flex-direction: row;
        justify-content: center;
        align-items: center;
    }
    
    .grafica-modal-title {
        font-size: 14px;
        margin-bottom: 5px;
        transform: none; /* Sin rotación en landscape */
        order: 1;
        margin-right: 10px;
    }
    
    .grafica-modal-canvas {
        height: 90vh;
        transform: none; /* Sin rotación en landscape */
        order: 2;
        flex: 1;
    }
    
    .grafica-modal-close {
        position: absolute;
        top: 10px;
        right: 15px;
        z-index: 10001;
    }
}

/* === Toast / Snackbar === */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 400px;
}

.toast {
    background: #333;
    color: white;
    padding: 12px 16px;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    opacity: 0;
    transform: translateY(-20px);
    border-left: 4px solid var(--verde-claro);
    max-width: 350px;
    word-wrap: break-word;
}

.toast:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0,0,0,0.2);
}

.toast-success {
    background: #28a745;
    border-left-color: #1e7e34;
}

.toast-error {
    background: #dc3545;
    border-left-color: #c82333;
}

.toast-info {
    background: #17a2b8;
    border-left-color: #138496;
}

.toast-warning {
    background: #ffc107;
    color: #212529;
    border-left-color: #e0a800;
}

/* === Tooltip simple (CSS-only) === */
.has-tooltip { position: relative; }
.has-tooltip::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(-6px);
    background: #222;
    color: #fff;
    padding: 6px 8px;
    border-radius: 6px;
    font-size: 12px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 150ms ease, transform 150ms ease;
    z-index: 1000;
}
.has-tooltip::before {
    content: '';
    position: absolute;
    bottom: calc(100% - 4px);
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: #222;
    opacity: 0;
    transition: opacity 150ms ease;
}
.has-tooltip:hover::after,
.has-tooltip:focus::after,
.has-tooltip:hover::before,
.has-tooltip:focus::before {
    opacity: 1;
    transform: translateX(-50%) translateY(-10px);
}

/* === Popover mínimo (estructura; apertura controlada por JS) === */
.popover {
    position: absolute;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.12);
    padding: 10px;
    min-width: 220px;
    z-index: 10000;
    display: none;
}
.popover.open { display: block; }

/* === Estilos para botones de navegación === */
.btn-todos-registros {
    transition: all 0.3s ease;
}

.btn-todos-registros:hover {
    background: #0056b3 !important;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2) !important;
}

.btn-volver {
    transition: all 0.3s ease;
}

.btn-volver:hover {
    background: #545b62 !important;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1) !important;
}

/* === Estilos para estados de procesos === */
.estado-activo {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: bold;
}

.estado-pausado {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffeaa7;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: bold;
}

.estado-finalizado {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: bold;
}

.estado-proceso {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: bold;
}

/* ========================================
   ESTILOS PARA GRÁFICAS PT (MANTENIENDO LO EXISTENTE)
   ======================================== */

/* Estilos para contenedores de gráficas (ya existían) */
.graficas-grid-pt {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    margin-top: 20px;
}

.grafica-container-pt {
    background: white;
    border-radius: 8px;
    padding: 15px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.contenedor-graficas-pt {
    margin-top: 20px;
}

.btn-graficas {
    background: #007bff;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    margin-bottom: 15px;
}

/* ========================================
   ESTILOS PARA TOOLTIPS DE INFORMACIÓN
   ======================================== */

.spec-info-icon {
    display: inline-block;
    width: 16px;
    height: 16px;
    background: var(--verde-claro);
    color: white;
    border-radius: 50%;
    text-align: center;
    line-height: 16px;
    font-size: 12px;
    font-weight: bold;
    cursor: pointer;
    margin-left: 5px;
    vertical-align: middle;
    transition: background-color 0.3s ease;
}

.spec-info-icon:hover {
    background: var(--amarillo-dorado);
}

.spec-tooltip {
    position: relative;
    display: inline-block;
}

.spec-tooltip .tooltip-content {
    visibility: hidden;
    opacity: 0;
    position: absolute;
    z-index: 1000;
    bottom: 125%;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: white;
    text-align: left;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 13px;
    line-height: 1.4;
    white-space: normal;
    width: 300px;
    max-width: 90vw;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.spec-tooltip .tooltip-content::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -5px;
    border-width: 5px;
    border-style: solid;
    border-color: #333 transparent transparent transparent;
}

.spec-tooltip:hover .tooltip-content {
    visibility: visible;
    opacity: 1;
}

/* Para especificaciones cortas, usar tooltip más pequeño */
.spec-tooltip.small .tooltip-content {
    width: 200px;
}

/* Para especificaciones muy largas, usar tooltip más ancho */
.spec-tooltip.large .tooltip-content {
    width: 400px;
    max-width: 95vw;
}

.btn-graficas:hover {
    background: #0056b3;
}

/* ========================================
   ESTILOS PARA FILAS ALTAS EN TABLAS
   ======================================== */

/* Filas altas para coincidir con filas de dos líneas en tabla izquierda */
.fila-alta {
    height: 48.8px; /* Altura fija para coincidir con filas de dos líneas */
}

.fila-alta td {
    vertical-align: middle;
    padding: 8px 4px;
}

.tablas-muestras-wrapper {
    display: flex;
    flex-direction: column;
    gap: 16px;
    width: 100%;
    margin-top: 20px;
}

.tablas-muestras-wrapper > .tabla-scroll,
.tablas-muestras-wrapper > .tabla-scroll-derecha {
    width: 100%;
    margin: 0;
    overflow-x: auto;
}

.tablas-muestras-wrapper > .tabla-scroll::-webkit-scrollbar,
.tablas-muestras-wrapper > .tabla-scroll-derecha::-webkit-scrollbar {
    height: 8px;
}

.tablas-muestras-wrapper > .tabla-scroll::-webkit-scrollbar-thumb,
.tablas-muestras-wrapper > .tabla-scroll-derecha::-webkit-scrollbar-thumb {
    background: rgba(0, 135, 87, 0.4);
    border-radius: 4px;
}

.tablas-muestras-wrapper > .tabla-scroll::-webkit-scrollbar-track,
.tablas-muestras-wrapper > .tabla-scroll-derecha::-webkit-scrollbar-track {
    background: rgba(0,0,0,0.05);
}

@media (min-width: 1024px) {
    .tablas-muestras-wrapper {
        flex-direction: row;
        align-items: stretch;
    }

    .tablas-muestras-wrapper > .tabla-scroll,
    .tablas-muestras-wrapper > .tabla-scroll-derecha {
        flex: 1 1 calc(50% - 12px);
        max-width: calc(50% - 12px);
        min-width: 0;
    }

    .tablas-muestras-wrapper > .tabla-scroll {
        margin-right: 24px;
    }
}

@media (max-width: 1023px) {
    .pt-formulario-muestras .formulario-muestras-table,
    .pt-formulario-muestras .formulario-muestras-table-registros {
        min-width: 520px;
    }

    .tablas-muestras-wrapper > .tabla-scroll,
    .tablas-muestras-wrapper > .tabla-scroll-derecha {
        padding-bottom: 8px;
    }
}

@media (max-width: 768px) {
    .pt-formulario-muestras .form-actions {
        position: static;
        bottom: auto;
        width: 100%;
        justify-content: center;
        flex-wrap: wrap;
        gap: 10px;
        padding: 12px 0;
    }

    .tablas-muestras-wrapper {
        gap: 20px;
    }

    .pt-formulario-muestras .formulario-muestras-table,
    .pt-formulario-muestras .formulario-muestras-table-registros {
        min-width: 560px;
    }

    .pt-formulario-muestras .formulario-muestras-table th,
    .pt-formulario-muestras .formulario-muestras-table td,
    .pt-formulario-muestras .formulario-muestras-table-registros th,
    .pt-formulario-muestras .formulario-muestras-table-registros td {
        font-size: 10.5px;
        padding: 6px 4px;
    }
}