/* =======================================================
   AGRO NORTE - ESTILOS CONSOLIDADOS (MOBILE-FIRST)
   ======================================================= */

:root {
    /* Paleta de colores */
    --primary-color: #2e7d32;
    --primary-hover: #1b5e20;
    --secondary-color: #f57c00;
    --bg-color: #f4f7f6;
    --surface-color: #ffffff;
    --text-main: #2c3e50;
    --text-muted: #7f8c8d;
    --border-color: #e0e6ed;
    --error-color: #e74c3c;
    --success-color: #27ae60;
    
    /* Sombras y radios */
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.08);
    --radius-md: 12px;
    --radius-sm: 8px;
}

/* Reset Básico */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-main);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
}

/* =========================================
   LAYOUT Y CONTENEDORES
   ========================================= */

header {
    display: flex;
    justify-content: space-between; /* Título a la izquierda, botones a la derecha */
    align-items: center;
    position: relative; /* Para que el menú móvil se ancle aquí */
    padding: 15px 20px;
    background-color: #ffffff;
    width: 100%;
    box-sizing: border-box;
    z-index: 1000;
}

header h1 {
	margin: 0;
    color: var(--primary-color);
    font-size: 1.3rem;
    flex-grow: 1;
    text-align: left;
}

/* Estilo para el nombre del usuario en el header */
.user-welcome {
    display: flex;
    align-items: center;
    margin-right: 15px;
}

.user-name {
    /* Usamos el verde institucional de AgroNorte */
    color: #2e7d32; 
    font-size: 1rem;
    font-weight: 600;
    text-transform: capitalize;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 15px;
}

.hamburger-btn {
    display: none; /* Sigue oculto en PC */
    background: transparent;
    border: none;
    color: var(--primary-color);
    cursor: pointer;
    
    /* Contención estricta de la caja táctil */
    width: 44px;
    height: 44px;
    padding: 0;
    flex-shrink: 0; /* Prohíbe que se achique */
    flex-grow: 0; /* Prohíbe que se estire */
    
    /* Alineación interna */
    align-items: center;
    justify-content: flex-end; /* Pega el icono al borde derecho de su propia caja */
}

.hamburger-icon {
    width: 28px;
    height: 28px;
    stroke: currentColor;
    stroke-width: 2;
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.container {
    width: 100%;
    max-width: 800px;
    margin: 1rem auto;
    padding: 0 1rem;
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
}

/* Estilo para pantallas de login/registro */
.login-body {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 1.5rem;
}

.login-container {
    background: var(--surface-color);
    padding: 2rem;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    width: 100%;
    max-width: 450px;
}

.card-market {
    border-left: 4px solid #1976d2; /* Azul fuerte: ideal para datos financieros/pizarra */
}

.card-global {
    border-left: 4px solid var(--secondary-color); /* Naranja: alertas e informes globales */
}

.card-balance {
    border-left: 4px solid var(--primary-color); /* Verde principal: tu stock/dinero positivo */
}

.card-profile {
    border-left: 4px solid #607d8b; /* Gris azulado: sobrio para configuración de cuenta */
}

.card-sale {
    border-left: 4px solid #25d366; /* Verde claro: coincide con la acción de WhatsApp */
}

.card-history {
    border-left: 4px solid #8e44ad; /* Morado: para líneas de tiempo e historiales */
}

/* =========================================
   ELEMENTOS DE FORMULARIO E INPUTS
   ========================================= */

.input-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 1.2rem;
    width: 100%;
}

.input-group label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-left: 2px;
}

/* ESTILOS ESTANDARIZADOS PARA INPUTS Y SELECTS */
input, select {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    background-color: #fafbfc;
    transition: all 0.3s ease;
}

input:focus, select:focus {
    outline: none;
    border-color: var(--primary-color);
    background-color: #fff;
    box-shadow: 0 0 0 3px rgba(46, 125, 50, 0.1);
}

/* Estilos específicos para tokens */
.input-token {
    text-align: center;
    font-size: 1.2rem;
    letter-spacing: 5px;
}

.hidden {
    display: none !important;
}

.checkbox-group {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 20px;
}

.checkbox-input {
    width: auto;
    margin: 0;
    cursor: pointer;
}

.checkbox-label {
    margin: 0;
    font-weight: normal;
    font-size: 0.9rem;
    color: var(--text-muted);
    cursor: pointer;
}

.login-options {
    display: flex;
    justify-content: space-between; /* Separa checkbox a la izq y links a la der */
    align-items: flex-start;
    margin-bottom: 20px;
    font-size: 0.85rem;
}

.forgot-single {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 15px;
    font-size: 0.85rem;
    width: 100%;
}

.forgot-single a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.3s ease;
}

.forgot-single a:hover {
    color: var(--secondary-color);
    text-decoration: underline;
}

.forgot-links {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
}

.forgot-links a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.3s ease;
}

.forgot-links a:hover {
    color: var(--secondary-color);
    text-decoration: underline;
}

.token-container {
    grid-column: 1 / -1; /* Ocupa todo el ancho disponible si está dentro de una grilla */
    background: #e3f2fd;
    padding: 20px;
    border-radius: var(--radius-sm);
    border: 1px solid #90caf9;
    margin-top: 15px;
}

.token-msg {
    font-size: 0.9rem;
    margin-bottom: 15px;
    color: #1565c0;
}

.token-actions {
    display: flex;
    gap: 10px;
    align-items: stretch;
    flex-wrap: wrap; /* Permite que bajen si la pantalla de celular es muy angosta */
}

.token-actions .input-token {
    flex: 1;
    min-width: 150px;
    margin-bottom: 0;
    text-align: center;
    letter-spacing: 3px;
}

.token-actions button {
    width: auto;
    margin-top: 0;
    padding: 0 20px;
}

.section-title {
    margin: 1.5rem 0 1rem 0;
    font-size: 1.1rem;
    color: var(--primary-color);
    border-bottom: 2px solid var(--bg-color);
    padding-bottom: 5px;
}

.section-desc {
    text-align: center;
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
    color: var(--text-muted);
}

/* =========================================
   CONTRASEÑA Y OJITO (TOGGLE)
   ========================================= */

.password-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
}

.password-wrapper input {
    padding-right: 45px; /* Deja espacio a la derecha para que el texto no tape al ojito */
}

.btn-toggle-password {
    position: absolute;
    right: 5px;
    width: 35px;
    height: 100%;
    margin-top: 0;
    padding: 0;
    background: transparent; /* Quita el fondo verde */
    border: none;
    display: flex;
    justify-content: center;
    align-items: center;
    color: var(--text-muted); /* Color gris del icono */
    cursor: pointer;
}

/* Neutralizamos los efectos hover del botón global para este botoncito */
.btn-toggle-password:hover {
    background: transparent;
    color: var(--primary-color); /* Se pinta verde al pasar el mouse */
    transform: none;
}

/* =========================================
   INFORME GLOBAL DE MERCADO
   ========================================= */

/* Destacar la tarjeta del informe global */
.card-highlight {
    border-left: 4px solid var(--secondary-color);
}

/* Colores específicos para el balance global */
.item-global-disp {
    background: #e3f2fd;
    color: #1565c0;
    border: 1px solid #90caf9;
}

.item-global-vend {
    background: #fff3e0;
    color: #e65100;
    border: 1px solid #ffcc80;
}

/* Subtítulos y espaciados dentro de tarjetas */
.section-subtitle {
    margin-top: 20px;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.mt-10 {
    margin-top: 10px;
}

/* Estilos para ítems del historial global */
.item-global {
    background: #f8f9fa;
    padding: 10px;
}

.text-accent {
    color: var(--secondary-color);
}

.text-large {
    font-size: 1rem;
}

/* =========================================
   TARJETAS Y GRILLAS (INDEX)
   ========================================= */

.card {
    background: var(--surface-color);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
}

.card h2 {
    font-size: 1rem;
    color: var(--text-main);
    margin-bottom: 1.2rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.pizarra-grid, .balance-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.pizarra-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-color);
    padding: 1rem;
    border-radius: var(--radius-sm);
}

.balance-item {
    padding: 1.2rem;
    border-radius: var(--radius-sm);
    text-align: center;
}

.balance-item span {
    display: block;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.balance-item strong {
    font-size: 1.6rem;
}

.disponible { background: #e8f5e9; color: var(--primary-color); }
.vendido { background: #ffebee; color: var(--error-color); }

.card-empty {
    border-left: 4px solid #9e9e9e; /* Gris neutral */
}

/* =========================================
   BOTONES
   ========================================= */

button, 
a.btn-primary, 
a.btn-secondary, 
a.btn-whatsapp {
    display: block; /* Obliga al enlace a comportarse como un bloque */
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-weight: 600;
    text-align: center; /* Centra el texto en los enlaces */
    text-decoration: none; /* Quita el subrayado típico de los links */
    cursor: pointer;
    transition: all 0.2s;
    margin-top: 0.5rem;
    box-sizing: border-box;
}

.btn-primary { background: var(--primary-color); color: white; }
.btn-primary:hover { background: var(--primary-hover); }

.btn-secondary { background: var(--text-muted); color: white; }

.btn-whatsapp { 
    background: #25d366; 
    color: white; 
    display: flex; 
    justify-content: center; 
    align-items: center; 
    gap: 10px;
}

.btn-logout {
    font-size: 0.85rem;
    text-decoration: none;
    color: var(--text-muted);
    border: 1px solid var(--border-color);
    padding: 5px 12px;
    border-radius: 6px;
}

.header-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

.btn-admin {
    background-color: var(--secondary-color);
    color: white;
    padding: 8px 15px;
    font-size: 0.85rem;
    text-decoration: none;
    border-radius: var(--radius-sm);
    font-weight: bold;
    transition: background 0.3s ease;
    border: none;
    display: inline-flex;
    align-items: center;
}

.btn-admin:hover {
    background-color: #e67300;
    color: white;
}

/* Modificadores de Botones */
.btn-accent { background-color: var(--secondary-color); }
.btn-cancel { background: #9e9e9e; }

.btn-nav {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 15px;
    background-color: transparent;
    color: #2e7d32; /* Verde AgroNorte */
    border: 1px solid #2e7d32;
    border-radius: 6px;
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s ease;
    margin-right: 10px;
}

.btn-nav:hover {
    background-color: #e8f5e9; /* Fondo verde muy claro al pasar el mouse */
    transform: translateY(-1px);
}

.btn-nav .icon {
    font-size: 1.1rem;
}

/* =========================================
   ENLACES DE AUTENTICACIÓN
   ========================================= */
.auth-link {
    text-align: center;
    margin-top: 1.5rem;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.auth-link a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
    transition: color 0.3s ease;
}

.auth-link a:hover {
    color: var(--secondary-color);
    text-decoration: underline;
}

/* =========================================
   HISTORIAL Y MENSAJES
   ========================================= */

.history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.history-item:last-child { border-bottom: none; }

.history-date { font-size: 0.75rem; color: var(--text-muted); }
.history-user { font-weight: 600; font-size: 0.9rem; display: block; }
.history-amount { font-weight: 800; color: var(--error-color); }

.error-msg {
    background: #fdeded;
    color: var(--error-color);
    padding: 10px;
    border-radius: var(--radius-sm);
    margin-bottom: 1rem;
    font-size: 0.85rem;
    text-align: center;
}

/* =========================================
   UTILIDADES Y PANTALLAS DE ERROR (429)
   ========================================= */
.text-center { text-align: center; }
.icon-large { font-size: 3rem; margin-bottom: 10px; }
.desc-text { margin: 15px 0; color: #555; line-height: 1.5; }
.alert-text { font-weight: bold; color: var(--error-color); }
.mt-20 { margin-top: 20px; }

/* =========================================
   MODAL CONFIRMACION VENTA
   ========================================= */

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.modal.hidden {
    display: none;
    opacity: 0;
}

.modal-content {
    background-color: white;
    padding: 30px;
    border-radius: 12px;
    width: 90%;
    max-width: 420px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
    text-align: center;
}

.modal-content h3 {
    margin-top: 0;
    color: var(--primary-color);
    margin-bottom: 15px;
    font-size: 1.5rem;
}

.modal-warning {
    font-size: 0.9rem;
    color: #666;
    margin-top: 15px;
    margin-bottom: 25px;
    line-height: 1.4;
}

.modal-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
}

.modal-actions button {
    flex: 1;
    margin: 0;
}

/* =========================================
   CONTRATOS
   ========================================= */

.contratos-grid {
    display: grid;
    gap: 20px;
    margin-top: 20px;
}

.contrato-item {
    border-left: 5px solid #2e7d32;
    background: #f8fdf8;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
	cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.contrato-item:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 12px rgba(0,0,0,0.08);
}

.text-truncate {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: #666;
}

/* Modal más ancho para leer contratos cómodamente */
.modal-large {
    max-width: 600px !important;
    text-align: left !important;
}

.contrato-texto {
    white-space: pre-wrap; /* Respeta los saltos de línea originales */
    line-height: 1.6;
    color: #444;
    max-height: 50vh;
    overflow-y: auto;
    font-size: 0.95rem;
}

.contrato-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.badge {
    padding: 4px 10px;
    border-radius: 15px;
    font-size: 0.8rem;
    font-weight: bold;
    text-transform: uppercase;
}

.badge-arr { background: #e3f2fd; color: #1976d2; } /* Azul para Arrendamiento */
.badge-ent { background: #e8f5e9; color: #2e7d32; } /* Verde para Entrega */

.contrato-date {
    font-size: 0.85rem;
    color: #666;
}

/* ==========================================================================
   ESTILOS DE CONTRATOS Y MODAL
   ========================================================================== */

.contrato-stock-info {
    margin-top: 10px;
    font-weight: bold;
    color: #2e7d32;
}

.modal-header-flex {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.modal-title-green {
    margin: 0;
    color: #2e7d32;
}

.modal-date-text {
    color: #666;
    font-size: 0.85rem;
    margin-bottom: 15px;
}

.contrato-stats-box {
    background: #f8fdf8;
    border: 1px solid #c8e6c9;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 15px;
}

.stats-box-title {
    margin-top: 0;
    color: #2e7d32;
    font-size: 0.95rem;
}

.stats-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
}

.stats-border-top {
    border-top: 1px solid #c8e6c9;
    padding-top: 10px;
}

.stats-fechas-info {
    margin: 5px 0 0 0;
    font-size: 0.8rem;
    color: #666;
    text-align: right;
}

.modal-divider {
    border: 0;
    border-top: 1px solid #eee;
    margin-bottom: 15px;
}

.modal-subtitle {
    margin-top: 0;
    font-size: 0.95rem;
}

.mt-25 {
    margin-top: 25px;
}

/* Colores de texto útiles */
.text-blue { color: #1976d2; }
.text-success { color: #2e7d32; }
.text-danger { color: #d32f2f; }

.modal-content.modal-large {
    width: 95%;
    max-width: 700px;
    max-height: 90vh; /* Vital para que aparezca el scroll */
    overflow-y: auto; /* Habilita el scroll interno */
    padding: 25px;
    margin: 20px auto;
    border-radius: 8px;
    background-color: #fff;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    overflow-x: hidden; 
}

/* Diseño de grilla adaptable para el formulario */
.form-asignar {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
    align-items: end;
}

.modal-content::-webkit-scrollbar {
    width: 6px;
}

.modal-content::-webkit-scrollbar-track {
	background: #f0f0f0;
	border-radius: 0 8px 8px 0;
}

.modal-content::-webkit-scrollbar-thumb {
    background-color: var(--primary-color);
    border-radius: 10px;
	border: 2px solid #f0f0f0;
}

/* =========================================
   PANEL ADMIN CONTRATOS
   ========================================= */

.admin-grid { 
    display: grid; 
    grid-template-columns: 1fr 2fr; 
    gap: 20px; 
    margin-top: 20px; 
}

.contrato-box { 
    background: #f8fdf8; 
    border: 1px solid #c8e6c9; 
    padding: 20px; 
    border-radius: 8px; 
    margin-bottom: 20px; 
    box-shadow: 0 2px 5px rgba(0,0,0,0.05); 
}

.contrato-box-header {
    display: flex; 
    justify-content: space-between; 
    align-items: flex-start;
}

.contrato-box-title {
    margin: 10px 0 5px 0; 
    color: #2e7d32;
}

.contrato-box-meta {
    font-size: 0.85rem; 
    color: #666; 
    margin: 0;
}

.btn-text-danger {
    background: none; 
    border: none; 
    color: #d32f2f; 
    cursor: pointer; 
    font-weight: bold;
    font-size: 0.85rem;
}

.btn-text-danger.underline {
    text-decoration: underline;
}

.divider {
    border: 0; 
    border-top: 1px solid #ddd; 
    margin: 15px 0;
}

.input-styled {
    width: 100%;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-family: inherit;
    resize: vertical;
}

.form-flex-1 { width: auto; }
.form-w-100px { width: auto; }

.label-mini {
    font-size: 0.8rem; 
    display: block; 
    margin-bottom: 3px;
}

.input-mini {
    width: 100%; 
    padding: 8px; 
    border: 1px solid #ccc; 
    border-radius: 4px;
}

.btn-asignar-submit {
    padding: 9px 15px; 
    margin-bottom: 1px;
}

.part-list { 
    background: #fff; 
    padding: 15px; 
    border-radius: 5px; 
    margin-top: 15px; 
    border: 1px solid #eee; 
}

.part-list h4 {
    margin: 0 0 10px 0; 
    font-size: 0.9rem;
}

.part-item { 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    border-bottom: 1px solid #eee; 
    padding: 8px 0; 
}

.part-item:last-child { 
    border-bottom: none; 
}

.btn-text-primary {
    background: none; 
    border: none; 
    color: #1976d2; 
    cursor: pointer; 
    font-weight: bold;
    font-size: 0.85rem;
}
.btn-text-primary.underline { text-decoration: underline; }
.mr-10 { margin-right: 10px; }
.d-flex-center { display: flex; align-items: center; }

/* Utilidades nuevas para limpieza de HTML */
.hidden { display: none !important; }
.mb-15 { margin-bottom: 15px; }

/* Controles específicos del Admin */
.selector-container {
    background: #e8f5e9; 
    padding: 15px; 
    border-radius: 8px; 
    margin-bottom: 20px; 
    border: 1px solid #c8e6c9;
}
.selector-label {
    font-weight: bold; 
    color: #2e7d32; 
    display: block; 
    margin-bottom: 8px;
}
.selector-select {
    font-size: 1rem; 
    font-weight: bold; 
    color: #333;
}

/* Modales y Empty States */
.empty-state-container {
    text-align: center; 
    padding: 40px; 
    color: #666;
}
.empty-state-sub { font-size: 0.9rem; }
.modal-title-green {
    margin-top: 0; 
    color: #2e7d32; 
    margin-bottom: 15px;
}
.modal-actions-flex {
    margin-top: 20px; 
    display: flex; 
    gap: 10px;
}

.flex-col-gap {
    flex-direction: column;
    gap: 5px;
}

/* Utilidades generales */
.w-100 { width: 100%; }
.m-0 { margin: 0; }
.text-cap { text-transform: capitalize; }
.text-highlight { color: #1976d2; font-weight: bold; }
.empty-msg { font-size: 0.85rem; color: #888; font-style: italic; margin: 0; }

/* =========================================
   NUEVO: SCROLL PARA HISTORIALES DE MOVIMIENTOS
   ========================================= */
.history-list {
    max-height: 350px; /* Altura máxima antes de scrollear */
    overflow-y: auto;
    padding-right: 5px; /* Espacio para que el scroll no pise el texto */
    
    /* Scrollbar estilizado para Firefox */
    scrollbar-width: thin;
    scrollbar-color: var(--text-muted) #f0f0f0;
}

/* Scrollbar estilizado para Chrome/Edge/Safari */
.history-list::-webkit-scrollbar {
    width: 6px;
}
.history-list::-webkit-scrollbar-track {
    background: #f0f0f0;
    border-radius: 4px;
}
.history-list::-webkit-scrollbar-thumb {
    background-color: var(--primary-color);
    border-radius: 4px;
}

/* =========================================
   NUEVO: TABLA DE HISTORIAL DE ENTREGAS
   ========================================= */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    margin-top: 15px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
}

.table-logistica {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    min-width: 450px; /* Evita que las columnas se aplasten en celulares */
}

.table-logistica th, .table-logistica td {
    padding: 10px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.table-logistica th {
    background-color: #f4f7f6;
    color: var(--text-main);
    font-weight: 600;
}

.table-logistica tr:last-child td {
    border-bottom: none;
}

/* =========================================
   NUEVO: BARRA DE PROGRESO (LOGÍSTICA)
   ========================================= */
.progress-wrapper {
    margin-top: 5px;
    background-color: var(--border-color);
    border-radius: 8px;
    height: 12px;
    width: 100%;
    overflow: hidden;
    position: relative;
}

.progress-bar {
    height: 100%;
    width: 0;
    background-color: var(--primary-color);
    transition: width 0.5s ease-in-out, background-color 0.3s ease;
    border-radius: 8px;
}

.progress-text {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 5px;
    text-align: right;
    display: block;
    font-weight: 600;
}

/* =========================================
   DROPDOWN DE FILTROS (CONTRATOS)
   ========================================= */
.dropdown-filtros-container {
    position: relative;
    display: inline-block;
    margin-bottom: 20px;
}

.btn-dropdown-trigger {
    padding: 8px 16px;
    background-color: white;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-main);
    font-size: 0.9rem;
    cursor: pointer;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 220px;
    transition: border-color 0.3s, box-shadow 0.3s;
}

.btn-dropdown-trigger:hover {
    border-color: var(--primary-color);
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.dropdown-menu {
    position: absolute;
    top: 110%;
    left: 0;
    background-color: white;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    min-width: 100%;
    z-index: 100;
    overflow: hidden;
}

.dropdown-item {
    padding: 10px 15px;
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--text-main);
    transition: background-color 0.2s;
}

.dropdown-item:hover {
    background-color: #f4f7f6;
}

.dropdown-item.active {
    background-color: var(--primary-color);
    color: white;
}

.oculto-filtro {
    display: none !important;
}

.filtro-texto {
    font-weight: normal;
    margin-left: 5px;
}

.filtro-flecha {
    font-size: 0.8rem;
    margin-left: auto;
}

/* =========================================
   SISTEMA DE NOTIFICACIONES / PANEL DE ALERTAS
   ========================================= */
.notificaciones-panel {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 25px;
    width: 100%;
}

.alert-card {
    display: flex;
    align-items: flex-start;
    gap: 15px;
    padding: 14px 20px;
    border-radius: var(--radius-sm, 6px);
    border: 1px solid var(--border-color);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.02);
    transition: transform 0.2s ease;
}

.alert-card-icon {
    font-size: 1.25rem;
    line-height: 1;
    margin-top: 2px;
}

.alert-card-content {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.alert-card-title {
    font-weight: 700;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.alert-card-text {
    font-size: 0.88rem;
    line-height: 1.4;
    margin: 0;
}

/* Variación de advertencia (Amarillo/Marrón) */
.alert-warning {
    background-color: #fffbeb;
    border-left: 5px solid #f59e0b;
    color: #92400e;
}
.alert-warning .alert-card-title {
    color: #b45309;
}

/* Variación crítica/peligro (Rojo) */
.alert-danger {
    background-color: #fef2f2;
    border-left: 5px solid #ef4444;
    color: #991b1b;
}
.alert-danger .alert-card-title {
    color: #b91c1c;
}

/* =========================================
   RESPONSIVE: PC Y TABLETS GRANDES (> 600px)
   ========================================= */
@media (min-width: 600px) {
    .profile-form {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 1rem;
    }
    .form-asignar {
        grid-template-columns: 1fr !important;
        gap: 10px;
    }
    .modal-content.modal-large {
        padding: 15px;
        width: 98%;
    }
    #btn-request-update, #form-token-perfil, .section-title {
        grid-column: span 2;
    }
    header h1 { 
        font-size: 1.5rem; 
    }
}

/* =========================================
   RESPONSIVE: TABLETS Y MÓVILES (Max 768px)
   ========================================= */
@media (max-width: 768px) { 
    .admin-grid { 
        grid-template-columns: 1fr; 
    }
    
    /* 1. Mostramos la hamburguesa y la forzamos a la derecha */
    .hamburger-btn {
        display: flex; 
    }

    /* 2. Contenedor del menú desplegable */
    .header-actions {
        display: none; 
        flex-direction: column;
        position: absolute;
        top: 100%; 
        left: 0;
        width: 100%;
        background-color: #ffffff;
        box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1);
        border-top: 1px solid var(--border-color);
        padding: 0;
        z-index: 999;
    }

    /* 3. Clase que activa el JS para abrir el menú */
    .header-actions.active {
        display: flex; 
    }

    /* 4. Estilo de la caja del usuario */
    .header-actions .user-welcome {
        width: 100%;
        box-sizing: border-box;
        padding: 15px 20px;
        background-color: #f8f9fa;
        border-bottom: 1px solid #eaeaea;
        margin: 0;
    }

    /* 5. Transformamos los botones en items de lista limpia */
    .header-actions a {
        width: 100%;
        box-sizing: border-box;
        padding: 15px 20px;
        text-align: left;
        
        /* Limpieza estricta */
        border: none !important; 
        border-radius: 0 !important; 
        background: transparent !important; 
        border-bottom: 1px solid #f0f0f0 !important;
        
        color: var(--text-main) !important;
        font-weight: 500;
        font-size: 1rem;
        transition: background-color 0.2s;
    }

    .header-actions a:last-child {
        border-bottom: none !important;
    }

    .header-actions a:hover, 
    .header-actions a:active {
        background-color: #f4f7f6 !important;
        color: var(--primary-color) !important;
    }

    .header-actions a.btn-logout {
        color: #e53e3e !important;
    }
}

/* =========================================
   RESPONSIVE: SMARTPHONES PEQUEÑOS (Max 480px)
   ========================================= */
@media (max-width: 480px) {
    .login-container { padding: 1.5rem; }
    .balance-item strong { font-size: 1.3rem; }
    .history-item { flex-direction: column; align-items: flex-start; gap: 5px; }
    .history-amount { align-self: flex-end; }
    
    .user-welcome {
        margin-right: 0;
        margin-bottom: 2px;
    }
    .user-name {
        font-size: 0.9rem;
    }
    
    .modal-content.modal-large {
        padding: 15px;
        width: 100%;
        border-radius: 0; 
    }
    
    .form-asignar {
        grid-template-columns: 1fr; 
    }
    
    .modal-actions-flex {
        flex-direction: column;
    }
}