body {
    font-family: Arial, sans-serif;
    background-color: #f4f4f4;
    margin: 0;
    padding: 20px;
}

.container {
    max-width: 900px;
    margin: 0 auto;
    background-color: #fff;
    padding: 25px;
    border-radius: 8px;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}

h1 {
    color: #004d99;
    text-align: center;
    border-bottom: 2px solid #eee;
    padding-bottom: 10px;
}

h2 {
    color: #333;
    margin-top: 20px;
}

h3 {
    color: #007bff;
    margin-top: 15px;
    border-left: 5px solid #007bff;
    padding-left: 10px;
}

/* --- SECCIÓN 1: CARGA DE DATOS --- */

.data-setup {
    background-color: #e6f0ff;
    padding: 15px;
    border-radius: 5px;
    margin-bottom: 20px;
    border: 1px solid #cce0ff;
}

.data-setup label {
    font-weight: bold;
    margin-right: 10px;
    color: #004d99;
}

.data-setup input[type="file"] {
    padding: 5px;
    border: 1px solid #ccc;
    border-radius: 4px;
}

.data-setup button {
    background-color: #28a745;
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: 4px;
    cursor: pointer;
    margin-left: 15px;
}

.data-setup button:hover {
    background-color: #218838;
}

.status {
    margin-top: 10px;
    padding: 5px;
    border-radius: 3px;
    font-size: 0.9em;
    font-weight: bold;
}

/* --- SECCIÓN 2: FORMULARIO DE ORDEN --- */

.header-info {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
    align-items: center;
}

.header-info label {
    font-weight: bold;
}

.header-info input[type="text"],
.header-info input[type="date"] {
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
    flex-grow: 1;
    max-width: 250px;
}


/* --- PRODUCTOS --- */

.productos-container {
    margin-top: 10px;
    border: 1px solid #ddd;
    padding: 10px;
    border-radius: 4px;
    background-color: #fafafa;
}

.producto-row {
    display: flex;
    gap: 10px;
    margin-bottom: 8px;
    align-items: center;
}

.producto-row input[type="text"] {
    flex: 3;
}

.producto-row input[type="number"] {
    flex: 1;
    text-align: right;
}

.producto-row input {
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
}

.producto-row .unidad {
    flex: 1;
    min-width: 90px;
    font-size: 0.9em;
    color: #555;
}

.producto-row .delete-btn {
    background-color: #dc3545;
    color: white;
    border: none;
    padding: 5px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
}

.btn-add {
    background-color: #17a2b8;
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: 4px;
    cursor: pointer;
    margin-top: 10px;
}

/* --- CUARTELES --- */

.cuarteles-container {
    margin-top: 10px;
    border: 1px solid #ddd;
    padding: 10px;
    border-radius: 4px;
    background-color: #fafafa;
    min-height: 40px;
}

.cuartel-tag {
    display: inline-flex;
    align-items: center;
    background-color: #007bff;
    color: white;
    padding: 5px 10px;
    border-radius: 15px;
    margin: 3px 5px 3px 0;
    font-size: 0.9em;
}

.cuartel-tag .delete-btn-tag {
    background: none;
    border: none;
    color: white;
    margin-left: 5px;
    cursor: pointer;
    font-weight: bold;
    font-size: 1em;
    line-height: 1;
    padding: 0;
}

.cuarteles-ayuda {
    font-size: 0.8em;
    color: #555;
    width: 100%;
    margin: 0 0 8px 0;
}

.cuartel-tag .mover-grupo {
    display: inline-flex;
    flex-direction: column;
    margin-right: 6px;
    line-height: 0.7;
}

.cuartel-tag .mover-btn {
    background: rgba(255, 255, 255, 0.25);
    border: none;
    color: white;
    cursor: pointer;
    font-size: 0.7em;
    line-height: 1;
    padding: 1px 3px;
    border-radius: 3px;
    margin: 0;
}

.cuartel-tag .mover-btn:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.55);
}

.cuartel-tag .mover-btn:disabled {
    opacity: 0.3;
    cursor: default;
}

.cuartel-tag .mover-btn:first-child {
    margin-bottom: 1px;
}

.cuartel-tag-texto {
    white-space: nowrap;
}

/* --- ARRASTRAR Y SOLTAR (reordenar cuarteles) --- */

.cuartel-tag[draggable="true"] {
    cursor: grab;
}

.cuartel-tag.dragging {
    opacity: 0.4;
    cursor: grabbing;
}

.cuartel-tag.drag-over {
    outline: 2px dashed #004d99;
    outline-offset: 2px;
}

.drag-grip {
    cursor: grab;
    color: rgba(255, 255, 255, 0.8);
    font-size: 1em;
    line-height: 1;
    margin-right: 4px;
    user-select: none;
}

.cuarteles-container button {
    background-color: #6c757d;
    color: white;
    border: none;
    padding: 5px 10px;
    border-radius: 4px;
    cursor: pointer;
    margin-left: 5px;
}

.cuarteles-container button:hover {
    background-color: #5a6268;
}

/* --- ESTANQUES / MÁQUINAS --- */

.estanques-ayuda {
    font-size: 0.85em;
    color: #555;
    margin: 5px 0 10px 0;
}

.estanques-config {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 15px;
    margin-top: 10px;
}

.estanque-item {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    border: 1px solid #cce0ff;
    background-color: #f5f9ff;
    padding: 12px;
    border-radius: 6px;
}

.estanque-item.inactivo {
    background-color: #f4f4f4;
    border-color: #ddd;
    opacity: 0.75;
}

.estanque-nombre {
    font-weight: bold;
    color: #004d99;
    font-size: 1.05em;
}

.estanque-fijo {
    font-size: 0.75em;
    color: #28a745;
    font-weight: bold;
}

.estanque-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-weight: bold;
}

.estanque-toggle input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.estanque-cap {
    display: flex;
    align-items: center;
    gap: 5px;
    margin-left: auto;
}

.estanque-cap label {
    font-size: 0.85em;
    color: #555;
    font-weight: bold;
}

.estanque-cap-input {
    width: 80px;
    text-align: right;
    padding: 6px;
    border: 1px solid #ccc;
    border-radius: 4px;
}

.estanque-cap-input:disabled {
    background-color: #e9ecef;
    color: #999;
}

.estanque-unidad {
    font-size: 0.85em;
    color: #555;
}

/* --- RESUMEN Y NOTAS --- */

.resumen {
    display: flex;
    justify-content: space-around;
    background-color: #fff3cd;
    border: 1px solid #ffeeba;
    padding: 10px;
    border-radius: 4px;
    margin-top: 15px;
    font-size: 1.1em;
}

.totales-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-top: 15px;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

/* El contenedor de columnas de estanque no forma caja propia:
   sus hijos participan directamente en la grilla anterior. */
.dosis-estanques-container {
    display: contents;
}

.totales-grid h4 {
    color: #004d99;
    border-bottom: 1px solid #eee;
    padding-bottom: 5px;
    margin-top: 0;
}

.totales-grid ul {
    list-style-type: none;
    padding: 0;
    font-size: 0.9em;
}

textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-sizing: border-box;
    margin-top: 5px;
    resize: vertical;
}

/* --- BOTONES DE ACCIÓN --- */

.action-buttons {
    display: flex;
    justify-content: space-between;
    margin-top: 25px;
    gap: 15px;
}

.action-buttons button {
    padding: 12px 15px;
    font-weight: bold;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    flex-grow: 1;
}

.btn-clean-all {
    background-color: #f0ad4e;
    color: white;
}

.btn-new-order {
    background-color: #17a2b8;
    color: white;
}

.btn-generate-pdf {
    background-color: #007bff;
    color: white;
}


/* --- MODAL (Selector de Cuarteles) --- */

.modal {
    display: none; 
    position: fixed; 
    z-index: 1000; 
    left: 0;
    top: 0;
    width: 100%; 
    height: 100%; 
    overflow: auto; 
    background-color: rgba(0,0,0,0.4); 
}

.modal-content {
    background-color: #fefefe;
    margin: 5% auto; 
    padding: 20px;
    border: 1px solid #888;
    width: 90%; 
    max-width: 1000px;
    border-radius: 8px;
}

.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
}

.close:hover,
.close:focus {
    color: black;
    text-decoration: none;
    cursor: pointer;
}

.filtros {
    display: flex;
    gap: 10px;
    align-items: flex-end;
    margin-bottom: 15px;
    flex-wrap: wrap;
    padding: 10px;
    background-color: #e9ecef;
    border-radius: 4px;
}

.filtros > div {
    display: flex;
    flex-direction: column;
}

.filtros label {
    font-size: 0.8em;
    font-weight: bold;
    color: #333;
    margin-bottom: 3px;
}

.filtros select,
.filtros input[type="text"] { 
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
    min-width: 160px;
    flex-grow: 1;
}

.filtros .select-all-btn {
    background-color: #20c997;
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9em;
    min-width: 120px;
}

.bulk-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    background-color: #fff3cd;
    border: 1px solid #ffeeba;
    padding: 10px 12px;
    border-radius: 4px;
    margin-bottom: 12px;
}

.bulk-actions label {
    font-weight: bold;
    color: #856404;
    font-size: 0.9em;
}

.bulk-actions input[type="number"] {
    width: 90px;
    text-align: right;
    padding: 6px;
    border: 1px solid #ccc;
    border-radius: 4px;
}

.bulk-actions .bulk-unidad {
    font-size: 0.85em;
    color: #856404;
}

.bulk-apply-btn {
    background-color: #fd7e14;
    color: white;
    border: none;
    padding: 8px 14px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    font-size: 0.9em;
}

.bulk-apply-btn:hover {
    background-color: #e8690b;
}

.cuarteles-list-modal {
    max-height: 400px;
    overflow-y: auto;
    border: 1px solid #ddd;
    padding: 10px;
    border-radius: 4px;
}

/* --- ESTILOS PARA EDICIÓN DOBLE (Superficie y Mojamiento) en el MODAL --- */

.cuartel-row-modal {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px;
    border-bottom: 1px solid #eee;
    gap: 10px;
}

.cuartel-info {
    flex-grow: 1;
    min-width: 250px;
    font-weight: bold;
    color: #004d99;
}

.input-group-container {
    display: flex;
    gap: 15px; 
    align-items: center;
    flex-shrink: 0;
}

.superficie-group,
.mojamiento-group {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.9em;
}

.superficie-group label,
.mojamiento-group label {
    font-weight: bold;
    color: #555;
}

.superficie-input,
.mojamiento-input { 
    width: 55px; 
    text-align: right;
    padding: 4px;
    border: 1px solid #ccc;
    border-radius: 3px;
    font-size: 0.9em;
}

.set-max-btn {
    background-color: #e9ecef;
    color: #495057;
    border: 1px solid #ced4da;
    padding: 4px 8px;
    cursor: pointer;
    border-radius: 3px;
    font-size: 0.8em;
}
.set-max-btn:hover {
    background-color: #dee2e6;
}
/* ============================================================
   MAESTRO DE PRODUCTOS
   ============================================================ */

.link-maestro,
.link-volver {
    display: inline-block;
    color: #004d99;
    font-weight: bold;
    text-decoration: none;
    padding: 4px 8px;
}
.link-maestro:hover,
.link-volver:hover {
    text-decoration: underline;
}

.maestro-form {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-end;
}

.maestro-form .campo {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 180px;
}

.maestro-form .campo-chico {
    flex: 0 0 130px;
    min-width: 110px;
}

.maestro-form label {
    font-size: 0.8em;
    font-weight: bold;
    color: #004d99;
    margin-bottom: 3px;
}

.maestro-form input {
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
}

.maestro-form .campo-botones {
    display: flex;
    gap: 8px;
}

.maestro-form .campo-botones button {
    padding: 10px 16px;
    border-radius: 6px;
}

.maestro-tabla-wrap {
    overflow-x: auto;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.maestro-tabla {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9em;
}

.maestro-tabla th,
.maestro-tabla td {
    padding: 8px 10px;
    border-bottom: 1px solid #eee;
    text-align: left;
}

.maestro-tabla thead th {
    background-color: #004d99;
    color: white;
    position: sticky;
    top: 0;
}

.maestro-tabla tbody tr:nth-child(even) {
    background-color: #f7f9fc;
}

.maestro-tabla .acciones {
    white-space: nowrap;
}

.btn-editar {
    background-color: #17a2b8;
    color: white;
    border: none;
    padding: 5px 10px;
    border-radius: 4px;
    cursor: pointer;
    margin-right: 5px;
}
.btn-editar:hover { background-color: #138496; }

.btn-eliminar {
    background-color: #dc3545;
    color: white;
    border: none;
    padding: 5px 10px;
    border-radius: 4px;
    cursor: pointer;
}
.btn-eliminar:hover { background-color: #c82333; }
