/* ==========================================================================
   1. VARIABLES Y RESET
   ========================================================================== */
@import url('https://fonts.googleapis.com/css2?family=Elms+Sans:ital,wght@0,100..900;1,100..900&family=Inter:wght@300;400;500;600;700&display=swap');

:root {
    --primary: #01a79d;       --primary-dark: #087770;
    --secondary: #3c454e;     --accent: #3498db;
    --bg-body: #eef2f6;       --bg-card: #ffffff;
    --text-main: #2d3748;     --text-muted: #718096;
    --border-color: #cccccc;
    --success: #27ae60;       --success-light: #42d392;
    --danger: #e74c3c;        --warning: #f1c40f;
    --info: #3498db;          --comment-light: #aaa9a9;
    --font-main: "Elms Sans", sans-serif;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --radius: 8px;            --radius-pill: 50px;
}

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

body {
    font-family: var(--font-main); font-weight: 300;
    background-color: var(--bg-body);
    background-image: radial-gradient(var(--primary) 0.5px, transparent 0.5px), radial-gradient(var(--primary) 0.5px, #f0f2f5 0.5px);
    background-size: 20px 20px; background-position: 0 0, 10px 10px;
    color: var(--text-main);
    padding-top: 80px; padding-bottom: 40px; font-size: 15px; width: 100%; min-height: 100vh;
}

a { text-decoration: none; transition: all 0.3s ease; }

/* ==========================================================================
   2. LOGIN Y MANTENIMIENTO
   ========================================================================== */
.login-body {
    background-color: #eef2f6; height: 100vh; display: flex; align-items: center; justify-content: center;
    background-image: radial-gradient(var(--primary) 0.5px, transparent 0.5px), radial-gradient(var(--primary) 0.5px, #f0f2f5 0.5px);
    background-size: 20px 20px; background-position: 0 0, 10px 10px;
    margin: 0; font-family: var(--font-main);
}
.login-container { width: 100%; max-width: 900px; padding: 20px; animation: fadeIn 0.8s ease-out; }
.login-card { display: flex; background: #ffffff; border-radius: 16px; box-shadow: 0 20px 50px rgba(0, 0, 0, 0.1); overflow: hidden; min-height: 550px; }
.login-visual { flex: 1; position: relative; /*background-color: var(--primary); */}
.bg-image { width: 100%; height: 100%; object-fit: cover; opacity: 1.0; mix-blend-mode: multiply; }
.version { font-size: 0.75rem; color: #ccc; font-weight: 500; }
.visual-overlay { position: absolute; bottom: 40px; left: 40px; right: 40px; color: white; z-index: 2; }
.visual-overlay h3 { color: #fff; font-size: 1.8rem; margin-bottom: 10px; font-weight: 700; background-color: transparent !important; }
.visual-overlay p { font-size: 1rem; opacity: 0.9; font-weight: 300; }

.login-form-wrapper { flex: 1; padding: 50px; display: flex; flex-direction: column; justify-content: center; position: relative; }
.login-header { margin-bottom: 30px; text-align: center; }
.login-header h4 { font-size: 1.8rem; color: var(--secondary); margin-bottom: 5px; font-weight: 700; }
.subtexto { color: var(--text-muted); font-size: 0.9rem; }
.input-group { margin-bottom: 20px; }
.input-group label { display: block; font-size: 0.85rem; font-weight: 600; color: var(--secondary); margin-bottom: 8px; }
.input-wrapper { position: relative; display: flex; align-items: center; }
.input-icon { position: absolute; left: 15px; color: #a0aec0; transition: color 0.3s; }
.campo-moderno {
    width: 100%; padding: 12px 15px 12px 45px !important; border: 2px solid #e2e8f0; border-radius: 8px;
    font-size: 1rem; transition: all 0.3s ease; background: #f8fafc;
}
.campo-moderno:focus { border-color: var(--primary); background: #fff; box-shadow: 0 0 0 4px rgba(1, 167, 157, 0.1); }
.campo-moderno:focus + .input-icon, .input-wrapper:focus-within .input-icon { color: var(--primary); }
.btn-login-modern {
    width: 100%; padding: 14px; background: linear-gradient(90deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white; border: none; border-radius: 8px; font-size: 1rem; font-weight: 600; cursor: pointer;
    transition: all 0.3s ease; box-shadow: 0 4px 15px rgba(1, 167, 157, 0.3); display: flex; justify-content: center; align-items: center; gap: 10px;
}
.btn-login-modern:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(1, 167, 157, 0.4); }
.btn-login-modern:active { transform: translateY(0); }
.login-footer { margin-top: 20px; text-align: center; font-size: 0.9rem; color: var(--text-muted); }
.link-contacto { color: var(--primary); font-weight: 600; text-decoration: none; }
.brand-footer { margin-top: 40px; display: flex; align-items: center; justify-content: center; gap: 10px; border-top: 1px solid #eee; padding-top: 20px; }
.mini-logo { height: 24px; opacity: 0.7; transition: opacity 0.3s; }
.mini-logo:hover { opacity: 1; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }

/* Pantalla Mantenimiento */
.body-maintenance { height: 100vh; display: flex; justify-content: center; align-items: center; background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%); color: #fff; }
.maintenance-container { width: 100%; max-width: 700px; padding: 20px; }
.maintenance-content { background: var(--primary-dark); backdrop-filter: blur(10px); border: 1px solid rgba(255,255,255,0.1); border-radius: 20px; padding: 50px 30px; text-align: center; box-shadow: 0 25px 50px -12px rgba(0,0,0,0.5); }
.maintenance-icon-box { font-size: 4rem; color: #fff; margin-bottom: 20px; }
.maintenance-content h1 { font-size: 2.5rem; margin-bottom: 15px; color: #fff; }
.btn-maintenance { display: inline-block; padding: 12px 30px; background-color: #333; color: white; border-radius: 50px; font-weight: 600; text-decoration: none; margin-top: 30px; }

/* ==========================================================================
   3. LAYOUT GENERAL (Cabeceras, Bloques y Grids)
   ========================================================================== */
.cuerpo { width: 100%; min-height: 70vh; overflow-y: auto; }
.contenido { width: 99%; margin: 0 auto; padding: 0 10px; max-width: 2100px; display: block; clear: both; }

h3 {
    font-size: 1.5rem; color: var(--primary-dark); margin-bottom: 25px; font-weight: 300;
    border-bottom: 2px solid var(--border-color); padding: 12px;
    display: flex; justify-content: space-between; align-items: center;
    background-color: #fff; border-radius: var(--radius);
}
h3 span { font-size: 1.2rem; color: var(--text-main); }

/* Sistema de Bloques (Legacy Float) */
.bloque1 { float: left; width: 24%; margin-right: 1%; }
.bloque2 { float: left; width: 75%; }
.bloque-full { width: 100%; float: none; clear: both; }

/* Contenedores */
.modulo1, .modulo2, .chart-box {
    background: var(--bg-card); border-radius: var(--radius);
    box-shadow: var(--shadow-sm); border: 1px solid var(--border-color);
    padding: 20px; margin-bottom: 10px; border-left: 4px solid var(--primary);
}
.cabecera-modulo { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid #eee; padding-bottom: 10px; margin-bottom: 15px; }
.cabecera-modulo h5 { margin: 0; font-weight: 400; font-size: 1.4em; color: #333; }
.margen { padding: 5px 0; }

/* --- NUEVO LAYOUT PROFORMA (Sidebar Izq + Contenido Dcha) --- */
.layout-proforma {
    display: grid;
    grid-template-columns: 380px 1fr; /* Izquierda fija | Derecha el resto */
    gap: 25px;
    align-items: start;
    width: 100%;
}

.proforma-sidebar { display: flex; flex-direction: column; gap: 20px; }
.proforma-content {
    background: #fff; border-radius: 8px; box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    padding: 25px; min-height: 500px; border: 1px solid #e1e8f0; border-left: 4px solid var(--primary);
}

/* Alertas y Textos */
.observaciones { background-color: var(--comment-light); color: #fff; border: none; }
.advertencia { background-color: #fff3cd; border: 1px solid #ffeeba; color: #856404; }

/* ==========================================================================
   4. NAVEGACIÓN
   ========================================================================== */
.navbar-top {
    position: fixed; top: 0; left: 0; width: 100%; height: 70px;
    background: linear-gradient(90deg, var(--primary) 0%, var(--primary-dark) 100%);
    display: flex; align-items: center; padding: 0 20px;
    box-shadow: 0 4px 15px rgba(0, 168, 150, 0.25); z-index: 1000;
}
.nav-logo img { height: 45px; filter: brightness(0) invert(1); }
.nav-menu { flex-grow: 1; display: flex; justify-content: flex-end; margin-right: 20px; }
.nav-list { display: flex; gap: 5px; align-items: center; list-style: none; }
.nav-item { position: relative; height: 70px; display: flex; align-items: center; }
.nav-link {
    color: #fff; text-decoration: none; font-size: 0.95rem; padding: 8px 16px;
    border-radius: var(--radius-pill); display: flex; align-items: center; gap: 8px; white-space: nowrap;
}
.nav-link:hover { background-color: rgba(255, 255, 255, 0.15); }

/* Dropdowns */
.dropdown-menu {
    display: none; position: absolute; top: 60px; right: 0;
    background-color: #fff; min-width: 220px; border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.15); padding: 10px 0; z-index: 1001;
}
.nav-item:hover .dropdown-menu { display: block; }
.dropdown-item { display: flex; align-items: center; padding: 10px 20px; color: var(--text-main); text-decoration: none; font-size: 0.9rem; }
.dropdown-item:hover { background-color: #f0f7f6; color: var(--primary-dark); }
.dropdown-item i { width: 25px; color: #ccc; text-align: center; }

/* Usuario y Mobile */
.user-actions { display: flex; align-items: center; gap: 15px; }

.user-capsule {
    background: rgba(0,0,0,0.15); padding: 5px 15px; border-radius: var(--radius-pill);
    display: flex; flex-direction: column; align-items: flex-end; line-height: 1.1;
    border: 1px solid rgba(255,255,255,0.1);
}

.u-name { color: #fff; font-weight: 600; font-size: 0.85rem; }
.u-role { color: rgba(255,255,255,0.8); font-size: 0.7rem; text-transform: uppercase; }

.btn-logout {
    color: white; opacity: 0.8; font-size: 1.2rem; cursor: pointer;
    display: flex; align-items: center;
}

/* --- CORRECCIÓN: OCULTAR ELEMENTOS MÓVILES EN ESCRITORIO --- */
.mobile-toggle,
.btn-logout-mobile,
.mobile-user-info,
.mobile-divider {
    display: none; /* Esto es vital para que no salgan en el PC */
}

/* ==========================================================================
   5. DASHBOARD Y KANBAN
   ========================================================================== */
.dashboard-stats { display: flex; gap: 20px; flex-wrap: wrap; margin-bottom: 30px; }
.stat-card {
    flex: 1; min-width: 180px; background: #fff; border-radius: 12px;
    box-shadow: var(--shadow-sm); padding: 20px; text-align: center;
    cursor: pointer; transition: transform 0.2s; border: 1px solid var(--border-color);
}
.stat-card:hover { transform: translateY(-5px); box-shadow: var(--shadow-md); }
.stat-card h2 { font-size: 2.5em; margin: 10px 0; color: var(--secondary); font-weight: 600; }
.stat-card p { margin: 0; color: var(--text-muted); font-weight: 500; font-size: 0.9em; text-transform: uppercase; }
.card-mes { border-top: 4px solid #3498db; } .card-anio { border-top: 4px solid #9b59b6; }
.card-hoy { border-top: 4px solid #f1c40f; } .card-retraso { border-top: 4px solid #e74c3c; }

/* Kanban */
.kanban-board { display: flex; gap: 20px; overflow-x: auto; padding-bottom: 10px; margin-top: 20px; }
.kanban-col { flex: 1; min-width: 300px; background: #f4f6f9; border-radius: 12px; padding: 15px; border: 1px solid #e2e8f0; }
.kanban-header { font-weight: 700; color: var(--secondary); margin-bottom: 15px; display: flex; justify-content: space-between; align-items: center; border-bottom: 3px solid #ccc; padding-bottom: 8px; }
.k-card {
    background: #fff; padding: 15px; border-radius: 8px; margin-bottom: 15px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05); border-left: 4px solid #ccc; transition: transform 0.2s; cursor: pointer;
}
.border-pend { border-bottom-color: #f1c40f; } .card-pend { border-left-color: #f1c40f; }
.border-prod { border-bottom-color: #3498db; } .card-prod { border-left-color: #3498db; }
.border-term { border-bottom-color: #2ecc71; } .card-term { border-left-color: #2ecc71; }

/* ==========================================================================
   6. TABLAS Y LISTADOS
   ========================================================================== */
table.listado {
    width: 100%; border-collapse: collapse; background: #fff;
    border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-sm);
    margin-bottom: 20px; font-size: 0.9em;
}
th { background-color: var(--secondary); color: #fff; padding: 15px; text-transform: uppercase; font-size: 0.8rem; text-align: left; }
td { padding: 12px 15px; border-bottom: 1px solid var(--border-color); color: var(--text-main); vertical-align: middle; }
tr:nth-child(even) { background-color: #f9f9f9; }
tr:hover { background-color: #edf2f7; cursor: pointer; }

/* Utilidades para celdas */
.center { text-align: center; }
.alineado-dcha { text-align: right !important; padding-right: 15px !important; }
.alineado-centro { text-align: center !important; }

/* Inputs dentro de tablas (Proformas) */
.campoform-tabla {
    width: 100%; padding: 8px; border: 1px solid #ddd;
    border-radius: 4px; font-size: 0.95rem; font-family: var(--font-main);
}
#tabla-items-body tr { transition: background 0.3s; }
.loading-overlay { opacity: 0.5; pointer-events: none; }

/* Bloque de Totales (Pie de factura) */
.bloque-totales { display: flex; justify-content: flex-end; margin-top: 20px; margin-bottom: 40px; }
.tabla-totales { width: 300px; border-collapse: collapse; }
.tabla-totales th { text-align: right; padding: 10px; color: #666; font-weight: normal; background: none; }
.tabla-totales td { text-align: right; padding: 10px; font-weight: bold; color: #333; border-bottom: 1px solid #eee; }
.tabla-totales .fila-total-final th, .tabla-totales .fila-total-final td {
    border-top: 2px solid #333; border-bottom: none; font-size: 1.2rem; color: #000; padding-top: 15px;
}

/* Buscador y Botones Listado */
.buscadorprincipal { width: 100%; display: flex; justify-content: flex-end; margin-bottom: 10px; clear: both; }
form.buscador { display: flex; gap: 10px; width: 100%; justify-content: flex-end; align-items: center; }
form.buscador input { width: 20% !important; min-width: 200px; box-shadow: var(--shadow-sm);}
form.buscador select { width: 7% !important; min-width: 120px; box-shadow: var(--shadow-sm);}
button.buscar { width: 42px; height: 36px; background: var(--primary); color: #fff; border: none; border-radius: 6px; cursor: pointer; display: flex; justify-content: center; align-items: center; }

.izquierda a {
    background-image: linear-gradient(to right, var(--primary) 0%, var(--primary-dark) 51%, var(--primary) 100%);
    background-size: 200% auto; margin-left: 10px; color: #fff; padding: 10px 18px; border-radius: 8px 8px 0px 0px;
    font-size: 1.0rem; text-decoration: none; letter-spacing: 0.5px; box-shadow: 0 4px 15px rgba(0, 168, 150, 0.3);
    display: inline-flex; align-items: center; gap: 10px; transition: 0.4s ease-out; border: none !important;
}
.izquierda a:hover { background-position: right center; color: #fff; box-shadow: 0 8px 20px rgba(0, 168, 150, 0.5); }

/* Paginación */
ul.paginacion { display: flex; justify-content: center; gap: 5px; margin-top: 30px; list-style-type: none; }
ul.paginacion li a { display: block; padding: 8px 14px; background: #fff; border: 1px solid var(--border-color); border-radius: 6px; color: var(--text-main); text-decoration: none; }
ul.paginacion li.active a { background-color: var(--primary); color: #fff; border-color: var(--primary); }

/* ==========================================================================
   7. FORMULARIOS Y BOTONES
   ========================================================================== */
.formulario-moderno { width: 100%; }
.grid-form-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; width: 100%; margin-bottom: 30px; }
.grupo { display: flex; flex-direction: column; }
.grupo label { font-weight: 600; font-size: 1.0rem; color: #555; padding-bottom: 3px; }
.campoform, input[type="text"], input[type="email"], input[type="date"], input[type="number"], select, textarea {
    width: 100%; padding: 10px 15px; border: 1px solid var(--border-color);
    border-radius: 6px; background-color: #fff; font-family: var(--font-main);
}
.campoform:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(0, 168, 150, 0.1); }
.grupo-doble-input { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; width: 100%; }

/* Botones Principales */
.botones-form { display: flex; gap: 15px; padding-top: 20px; border-top: 1px solid #eee; }
.guardar-btn {
    flex: 1; padding: 12px 20px; border: none; border-radius: 6px;
    background: linear-gradient(135deg, var(--success-light) 0%, var(--success) 100%);
    color: white; font-weight: 600; cursor: pointer; display: flex; justify-content: center; gap: 8px;
    transition: all 0.3s ease;
}
.guardar-btn:hover { transform: translateY(-2px); box-shadow: 0 6px 15px rgba(40, 167, 69, 0.35); }

.volver-btn {
    padding: 12px 20px; border: 1px solid #ddd; border-radius: 6px;
    background: #f8f9fa; color: #555; font-weight: 600; cursor: pointer;
    display: flex; justify-content: center; align-items: center; gap: 8px; text-decoration: none; min-width: 130px;
}
.volver-btn:hover { background: #e2e6ea; }

/* Botones Específicos Proforma/Tabla */
.btn-add-tabla {
    background-color: #27ae60; color: white; border: none; padding: 8px 12px;
    border-radius: 4px; cursor: pointer; transition: background 0.3s;
}
.btn-add-tabla:hover { background-color: #219150; }

.btn-borrar-tabla { color: #e74c3c; font-size: 1.1rem; cursor: pointer; background: none; border: none; }
.btn-borrar-tabla:hover { color: #c0392b; }

.btn-imprimir {
    display: inline-block; background: #34495e; color: #fff; padding: 8px 15px;
    border-radius: 4px; text-decoration: none; font-size: 0.9em; transition: 0.3s;
}
.btn-imprimir:hover { background: #2c3e50; color: #fff; }

/* Etiquetas */
.etiqueta-recargo {
    display: inline-block; background-color: #e67e22; color: white;
    font-size: 0.7rem; padding: 2px 5px; border-radius: 4px; font-weight: bold; margin-left: 5px; vertical-align: middle;
}
.lista-datos { list-style: none; padding: 0; margin: 0; }
.lista-datos li { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px dashed #f0f0f0; }
.etiqueta { font-weight: 600; color: #555; }
.valor { text-align: right; color: #000; }

/* Footer */
.footer {
    height: 25px; background: #000; color: #eee; position: fixed; bottom: 0; left: 0; width: 100%;
    padding: 0 20px; margin: 0; z-index: 9999; display: flex; justify-content: space-between; align-items: center;
}
.footer P { margin: 0; padding: 0; color: #fff; font-size: 12px; }
.footer P A { color: #fff; text-decoration: none; }

/* ==========================================================================
   8. MEDIA QUERIES (RESPONSIVE)
   ========================================================================== */

/* Ajuste específico Layout Proforma (Tablets y Móviles) */
@media (max-width: 900px) {
    .layout-proforma { grid-template-columns: 1fr; /* 1 columna */ }
    .proforma-sidebar {
        order: 1; /* Datos arriba */
        display: grid; grid-template-columns: 1fr 1fr; /* Dos bloques en paralelo */
        gap: 15px;
    }
    .proforma-content { order: 2; /* Documento abajo */ }
}
@media (max-width: 600px) {
    .proforma-sidebar { grid-template-columns: 1fr; /* Uno debajo de otro */ }
    .grupo-doble-input { grid-template-columns: 1fr; }
}

/* Ajustes Generales Menú y Tablas (Max-width 1250px) */
@media (max-width: 1250px) {
    
    /* Navbar */
    .navbar-top { justify-content: space-between; padding: 0 15px; }
    .mobile-toggle, .btn-logout-mobile { display: block; font-size: 1.4rem; color: #fff; cursor: pointer; }
    .nav-logo { margin: 0 auto; }
    .desktop-only { display: none !important; }

    /* Menú Lateral */
    .nav-menu {
        position: fixed; top: 70px; left: -100%; width: 85%; height: calc(100vh - 70px);
        background: linear-gradient(180deg, var(--primary) 0%, var(--primary-dark) 100%);
        flex-direction: column; justify-content: flex-start !important; padding: 0;
        transition: left 0.3s ease; overflow-y: auto;
    }
    .nav-menu.active { left: 0; }
    .nav-list { flex-direction: column; width: 100%; gap: 0; }
    .nav-item { flex-direction: column !important; align-items: flex-start !important; height: auto !important; border-bottom: 1px solid rgba(255,255,255,0.05); }
    .nav-link { width: 100%; padding: 15px 20px; justify-content: flex-start; border-radius: 0; }
    .nav-link .fa-chevron-down { margin-left: auto; }

    /* Dropdowns Móvil */
    .dropdown-menu {
        position: relative !important; top: 0 !important; left: 0 !important; width: 100% !important;
        box-shadow: none !important; background: rgba(0,0,0,0.2) !important;
        display: none; border-radius: 0 !important;
    }
    .nav-item.mobile-open .dropdown-menu { display: block !important; }
    .nav-item.mobile-open > .nav-link .fa-chevron-down { transform: rotate(180deg); }
    .dropdown-item { padding: 12px 20px 12px 50px; color: #eee; }

    /* Usuario Móvil */
    .mobile-user-info, .mobile-divider { display: block; }
    .user-details-mobile { display: flex; align-items: center; padding: 20px 15px; color: #fff; gap: 15px; }
    .user-details-mobile .u-icon { font-size: 2.5rem; }

    /* Layout General */
    .bloque1, .bloque2 { width: 100%; float: none; margin-right: 0; height: auto !important; }
    .dashboard-stats { flex-direction: column; }
    
    /* Buscador */
    form.buscador { display: flex !important; flex-direction: row !important; width: 100%; gap: 5px; }
    form.buscador input { width: auto !important; flex-grow: 1; min-width: 0; }
    form.buscador button.buscar { width: 40px; flex-shrink: 0; }

    /* Tablas Responsive (Ocultar columnas no esenciales) */
    table.listado .oculto-movil, .listado th.oculto-movil, .listado td.oculto-movil {
        display: none !important; width: 0 !important; padding: 0 !important; border: none !important;
    }
    table.listado { display: table !important; width: 100% !important; table-layout: fixed; }
    .listado td, .listado th { display: table-cell !important; padding: 10px 4px !important; white-space: normal !important; word-break: break-word; font-size: 0.8rem; }
    
    /* Ajustes varios */
    h3 span { display: none !important; }
    .login-visual { display: none !important; }
}

/* --- BOTÓN AÑADIR TEXTO --- */
.btn-add-texto {
    background-color: var(--primary);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    font-weight: 600;
    cursor: pointer;
    text-transform: uppercase;
    font-size: 0.8rem;
    letter-spacing: 0.5px;
    transition: background 0.3s;
}
.btn-add-texto:hover { background-color: var(--primary-dark); }


/* --- BOTONERA DE ACCIONES INFERIOR --- */
.botonera-acciones {
    display: flex;
    gap: 15px;
    margin-top: 30px;
    padding-top: 20px;
    border-top: 2px solid #f0f2f5;
    flex-wrap: wrap; /* Para móvil */
}

.btn-accion, 
button.btn-accion {
    flex: 1; /* Todos ocupan lo mismo, o quitar para tamaño natural */
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    padding: 15px 20px;
	border: none;              
    cursor: pointer;
    border-radius: 8px;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.btn-accion:hover { transform: translateY(-2px); box-shadow: 0 5px 10px rgba(0,0,0,0.15); }

/* Colores de los botones */
.btn-imprimir-lg { background-color: #34495e; color: white; }
.btn-imprimir-lg:hover { background-color: #2c3e50; color: white; }

.btn-email { background-color: #3498db; color: white; }
.btn-email:hover { background-color: #2980b9; color: white; }

.btn-convertir { background-color: #27ae60; color: white; }
.btn-convertir:hover { background-color: #219150; color: white; }

.btn-salir { background-color: #e74c3c; color: white; }
.btn-salir:hover { background-color: #c0392b; color: white; }

/* --- DRAG AND DROP (SORTABLE) --- */
.handle-drag { cursor: grab !important; }
.handle-drag:active { cursor: grabbing !important; }
.ui-state-highlight {
    height: 45px;
    background-color: #fdfdfd;
    border: 1px dashed #ccc;
}

/* --- INPUTS VIVOS (EDICIÓN EN TABLA) --- */
.input-live {
    width: 100%;
    border: 1px solid transparent; /* Invisibles hasta que pasas el ratón o clicas */
    background: transparent;
    padding: 5px;
    font-family: inherit;
    font-size: 0.95rem;
    color: #333;
    transition: all 0.2s;
    border-radius: 4px;
}

.input-live:hover {
    border: 1px solid #e1e8f0;
    background: #fff;
}

.input-live:focus {
    border: 1px solid var(--primary);
    background: #fff;
    outline: none;
    box-shadow: 0 0 0 2px rgba(1, 167, 157, 0.1);
}

/* Modificadores para números */
.input-live.num {
    text-align: right;
    font-weight: 600;
}

/* --- TOTALES MÁS ANCHOS --- */
.tabla-totales {
    width: 450px !important; /* Antes era 300px */
    max-width: 100%;
}

.tabla-totales th {
    width: 60%; /* Damos más espacio al texto */
}

/* --- SEPARADOR ZONA AÑADIR --- */

/* 1. Fila vacía para crear aire */
.fila-spacer td {
    height: 25px;       /* Altura de la separación */
    background: #fff;   /* Fondo blanco para limpiar */
    border: none !important; /* Sin bordes */
}

/* 2. La fila de los inputs */
.fila-add-item {
    background-color: #f4f8fb; /* Fondo azul muy suave */
}

.fila-add { background: #f9f9f9; border-top: 2px solid #eee; }
.input-add { width: 100%; padding: 6px; border: 1px solid #ddd; border-radius: 3px; box-sizing: border-box; }

.fila-add-item td {
    border-top: 2px solid #cbd5e0 !important; /* LÍNEA SEPARADORA GRIS/AZUL */
    padding-top: 15px !important;
    padding-bottom: 15px !important;
}

/* --- ICONO + EN FILA AÑADIR (Igualado al handle-drag) --- */
.icono-plus-add {
    float: left;
    padding: 12px 4px;    /* Mismo espaciado que las 3 rayas */
    color: #ccc;         /* Mismo color gris suave (antes era verde) */
    font-size: 0.8rem;     /* Tamaño estándar */
    width: 25px;         /* Mismo ancho reservado */
    text-align: left;
}

.wrapper-input-add {
    margin-left: 30px; /* Hueco para el icono */
}

/* Select dentro de la tabla */
select.input-live {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url('data:image/svg+xml;utf8,<svg fill="%23333" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><path d="M7 10l5 5 5-5z"/></svg>');
    background-repeat: no-repeat;
    background-position: right 5px center;
    padding-right: 20px;
    cursor: pointer;
}

@media (max-width: 768px) {
        /* En móviles, que las 3 columnas se pongan una debajo de otra */
        div[style*="grid-template-columns"] {
            grid-template-columns: 1fr !important;
        }
    }
	
* --- LAYOUT NUEVA PROFORMA --- */

/* 1. Contenedor principal: Asegura que las filas caigan una debajo de otra */
.contenedor-form-proforma {
    display: flex;
    flex-direction: column;
    gap: 20px; /* Espacio entre la fila 1 y la fila 2 */
    width: 100%;
}

/* 2. Fila Superior: 3 Columnas iguales */
.fila-datos-top {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr; /* Tres columnas idénticas */
    gap: 20px; /* Espacio entre columnas */
}

/* 3. Fila Cliente: Ocupa todo el ancho */
.fila-datos-cliente {
    width: 100%;
}

/* RESPONSIVE: En móviles, que todo se ponga en una sola columna */
@media (max-width: 768px) {
    .fila-datos-top {
        grid-template-columns: 1fr; /* Una sola columna en móvil */
    }
}

/* =========================================
   ESTILOS ESPECÍFICOS DE PROFORMAS
   ========================================= */

/* --- Etiquetas y Textos Pequeños --- */
.lbl-small {
    font-size: 0.85em;
    color: #666;
    font-weight: 600;
    margin-bottom: 3px;
    display: block;
}

/* --- Checkbox con estilo --- */
.checkbox-wrapper {
    display: flex;
    align-items: center;
    background: #fdfdfd;
    border: 1px solid #eee;
    padding: 8px;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.2s;
}
.checkbox-wrapper:hover {
    background: #f5f5f5;
}

/* --- Alerta de Ejercicio Cerrado --- */
.alerta-cerrado {
    background-color: #fff3cd;
    color: #856404;
    padding: 15px;
    border: 1px solid #ffeeba;
    border-radius: 4px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 15px;
}

/* --- Inputs Específicos --- */
.input-obs-internas {
    background-color: #fffbe6 !important; /* Amarillo muy suave */
}

.select-compacto {
    padding-left: 0 !important;
    padding-right: 0 !important;
    text-align: center;
}

/* --- Contenedor de Totales --- */
.contenedor-totales-right {
    display: flex;
    justify-content: flex-end;
    margin-top: 20px;
}

/* =========================================
   MODO LECTURA (DOCUMENTO CERRADO)
   Esta clase se aplica al contenedor padre cuando está cerrada
   ========================================= */

/* Ocultar herramientas de edición */
.modo-lectura .btn-borrar-tabla,
.modo-lectura .handle-drag,
.modo-lectura .icono-plus-add,
.modo-lectura .fila-add-item { 
    display: none !important; 
}

/* Transformar inputs en texto plano visualmente */
.modo-lectura .input-live {
    border: none !important;
    background: transparent !important;
    pointer-events: none; /* Bloquea el clic */
    color: #555;
    font-weight: 500;
    /* Quitar flecha de selects */
    -webkit-appearance: none; 
    -moz-appearance: none; 
    appearance: none;
    padding-right: 0 !important; 
    background-image: none !important;
}

/* Alinear números a la derecha correctamente */
.modo-lectura .input-live.num { 
    text-align: right; 
}

/* Inputs deshabilitados visualmente en formularios */
.modo-lectura .campoform,
.modo-lectura .checkbox-wrapper {
    opacity: 0.7;
    pointer-events: none;
    background-color: #f9f9f9;
}

/* --- Grid para el formulario de cabecera (Ancho completo) --- */
.form-cabecera-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr); /* 4 columnas por defecto */
    gap: 15px;
    margin-bottom: 15px;
}

/* Para filas que necesiten ocupar mitad y mitad */
.form-fila-mitad {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 15px;
}

/* En móviles, que todo sea 1 columna */
@media (max-width: 900px) {
    .form-cabecera-grid, .form-fila-mitad {
        grid-template-columns: 1fr;
    }
}

/* =========================================
   SISTEMA DE PESTAÑAS (TABS)
   ========================================= */

/* Contenedor de los botones */
.navegacion-tabs {
    display: flex;
    border-bottom: 2px solid #eee;
    margin-bottom: 20px;
    gap: 5px;
}

/* Botón individual de pestaña */
.tab-btn {
    padding: 12px 20px;
    background: #f9f9f9;
    border: none;
    border-bottom: 2px solid transparent; /* Para evitar saltos al activar */
    cursor: pointer;
    font-weight: 600;
    color: #777;
    font-size: 0.95em;
    transition: all 0.2s ease;
    border-radius: 4px 4px 0 0;
}

.tab-btn:hover {
    background: #f0f0f0;
    color: #333;
}

/* Estado Activo del Botón */
.tab-btn.active {
    background: #fff;
    color: #2c3e50; /* Tu color principal */
    border-bottom: 2px solid #2c3e50;
    margin-bottom: -2px; /* Para pisar la línea del contenedor */
}

/* Contenido de la pestaña */
.contenido-tab {
    display: none; /* Oculto por defecto */
    animation: fadeIn 0.3s ease;
}

.contenido-tab.active {
    display: block; /* Visible si tiene la clase active */
}

/* Animación suave */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

.etiqueta-estado { padding: 5px 10px; border-radius: 4px; color: white; font-weight: bold; font-size: 12px; display: inline-block; margin-left: 10px; vertical-align: middle; }
.etiqueta-estado.gris { background-color: #6c757d; }
.etiqueta-estado.naranja { background-color: #fd7e14; }
.etiqueta-estado.verde { background-color: #28a745; }
.etiqueta-estado.rojo { background-color: #dc3545; }

/* =========================================
   ESTILOS GENERALES Y ETIQUETAS
   ========================================= */
.lbl-small { 
    font-size: 0.85em; 
    color: #666; 
    font-weight: 600; 
    margin-bottom: 3px; 
    display: block; 
}

.checkbox-wrapper { 
    display: flex; 
    align-items: center; 
    background: #fdfdfd; 
    border: 1px solid #eee; 
    padding: 8px; 
    border-radius: 4px; 
    cursor: pointer; 
    height: 38px; 
}

/* Badges de Estado */
.etiqueta-estado { 
    padding: 5px 10px; 
    border-radius: 4px; 
    color: white; 
    font-weight: bold; 
    font-size: 11px; 
    display: inline-block; 
    vertical-align: middle; 
    margin-left: 10px; 
    text-transform: uppercase; 
}
.etiqueta-estado.gris { background-color: #6c757d; }
.etiqueta-estado.naranja { background-color: #fd7e14; }
.etiqueta-estado.verde { background-color: #28a745; }
.etiqueta-estado.rojo { background-color: #dc3545; }
.etiqueta-estado.negro { background-color: #000; } /* Para año cerrado */


/* =========================================
   MODO LECTURA (DOCUMENTO CERRADO)
   Esto reemplaza al "if ($esta_cerrada)" de PHP
   ========================================= */

/* Ocultar elementos de acción */
.modo-lectura .btn-borrar-tabla, 
.modo-lectura .handle-drag, 
.modo-lectura .icono-plus-add,
.modo-lectura .guardar-btn { 
    display: none !important; 
}

/* Transformar inputs en texto plano */
.modo-lectura .input-live { 
    pointer-events: none; 
    border: none !important; 
    background: transparent !important; 
    color: #555; 
    -webkit-appearance: none; 
    padding-right: 0 !important; 
}

.modo-lectura .input-live.num { 
    text-align: right; 
}

/* Deshabilitar visualmente cabecera y selects */
.modo-lectura .form-cabecera-grid input, 
.modo-lectura .form-cabecera-grid select, 
.modo-lectura textarea { 
    pointer-events: none; 
    background: #f9f9f9; 
    color: #777; 
    border-color: #ddd; 
}

.enlace-editar {
    color: var(--primary);
    font-size: 1.1em;
    transition: color 0.3s;
	font-size: 1.4em;
}

.enlace-editar:hover {
    color: #1e7e34;
	transform: translateY(-2px);
}