body {
    font-family: 'Segoe UI', 'Times New Roman', sans-serif;
    background-color: #f0f4f8;
    margin: 0;
    padding: 20px;
    display: flex;
    gap: 25px;
    color: #333;
    height: 100vh;
    box-sizing: border-box;
    overflow: hidden;
}

/* Panel de Controles (Izquierda) */
.panel-controles {
    width: 38%;
    min-width: 360px;
    background: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    height: 100%;
    overflow-y: auto;
    box-sizing: border-box;
}

.panel-controles h2 {
    margin-top: 0;
    color: #1e3a8a;
    border-bottom: 3px solid #3b82f6;
    padding-bottom: 8px;
    font-size: 18px;
    text-transform: uppercase;
}

details.grupo-seccion {
    background: #f8fafc;
    padding: 0;
    border-radius: 8px;
    margin-bottom: 15px;
    border-left: 4px solid #64748b;
    border-top: 1px solid #e2e8f0;
    border-right: 1px solid #e2e8f0;
    border-bottom: 1px solid #e2e8f0;
    overflow: hidden;
}

details.grupo-seccion summary {
    padding: 12px;
    font-size: 13px;
    color: #475569;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: bold;
    cursor: pointer;
    user-select: none;
    outline: none;
    background: #f1f5f9;
}

details.grupo-seccion summary:hover {
    background: #e2e8f0;
}

.details-content {
    padding: 12px;
}

div.grupo-seccion {
    background: #f8fafc;
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 15px;
    border-left: 4px solid #3b82f6;
    border-top: 1px solid #e2e8f0;
    border-right: 1px solid #e2e8f0;
    border-bottom: 1px solid #e2e8f0;
}

div.grupo-seccion h3 {
    margin: 0 0 10px 0;
    font-size: 13px;
    color: #475569;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.grupo-campo {
    margin-bottom: 12px;
}

.grupo-campo label {
    display: block;
    margin-bottom: 4px;
    font-weight: 600;
    color: #334155;
    font-size: 12.5px;
}

.grupo-campo input, .grupo-campo select, .grupo-campo textarea {
    width: 100%;
    padding: 6px 10px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    box-sizing: border-box;
    font-size: 13px;
    font-family: inherit;
}

.grupo-campo textarea {
    resize: vertical;
    min-height: 55px;
}

.grupo-campo input:focus, .grupo-campo select:focus, .grupo-campo textarea:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.fila-doble {
    display: flex;
    gap: 10px;
}

.fila-doble .grupo-campo {
    flex: 1;
}

.checkbox-container {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 12.5px;
    margin-bottom: 10px;
}

.alerta-fin-semana {
    display: none;
    background-color: #fef2f2;
    border: 1px solid #fee2e2;
    border-left: 4px solid #ef4444;
    color: #991b1b;
    padding: 10px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    margin-top: 8px;
    line-height: 1.4;
}

.btn-imprimir {
    width: 100%;
    padding: 12px;
    background-color: #1e3a8a;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14.5px;
    cursor: pointer;
    font-weight: bold;
    box-shadow: 0 4px 6px rgba(30, 58, 138, 0.2);
    transition: background 0.2s;
    margin-bottom: 5px;
}

.btn-imprimir:hover {
    background-color: #152963;
}

.btn-imprimir:disabled {
    background-color: #94a3b8;
    cursor: not-allowed;
    box-shadow: none;
}

.historial-container {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 10px;
    max-height: 150px;
    overflow-y: auto;
}

.item-historial {
    font-size: 11.5px;
    padding: 8px;
    border-bottom: 1px solid #f1f5f9;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.item-historial:last-child {
    border-bottom: none;
}

.btn-cargar {
    background-color: #10b981;
    color: white;
    border: none;
    padding: 3px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
}

.btn-limpiar {
    background: none;
    border: none;
    color: #ef4444;
    font-size: 11px;
    cursor: pointer;
    text-decoration: underline;
    float: right;
    margin-top: 2px;
}

.contenedor-vista-previa {
    flex: 1;
    background-color: #e2e8f0;
    border-radius: 12px;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    overflow: auto;
    position: relative;
    padding: 20px;
    box-sizing: border-box;
    height: 100%;
}

.controles-zoom {
    position: absolute;
    top: 15px;
    right: 15px;
    background: rgba(30, 41, 59, 0.85);
    padding: 6px 10px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
    z-index: 100;
    backdrop-filter: blur(4px);
    box-shadow: 0 4px 10px rgba(0,0,0,0.15);
}

.controles-zoom button {
    background: white;
    border: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    cursor: pointer;
    font-weight: bold;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.controles-zoom span {
    color: white;
    font-size: 12px;
    font-weight: bold;
    min-width: 40px;
    text-align: center;
}

.vista-previa {
    width: 215.9mm;
    height: 279.4mm;
    min-height: 279.4mm;
    max-height: 279.4mm;
    background: white;
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
    box-sizing: border-box;
    position: relative;
    background-repeat: no-repeat;
    background-size: 100% 100%;
    background-position: center;
    transform-origin: top center;
    flex-shrink: 0;
}

.contenido-documento {
    padding-top: 50mm;
    padding-left: 30mm;
    padding-right: 25mm;
    padding-bottom: 25mm;
    font-family: 'Arial', sans-serif;
    color: #000;
}

.memo-titulo {
    text-align: center;
    font-size: 16pt;
    font-weight: bold;
    margin-bottom: 5px;
    letter-spacing: 1px;
}

.memo-cite {
    text-align: center;
    font-size: 11pt;
    font-weight: bold;
    margin-bottom: 30px;
}

.memo-encabezado {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 25px;
}

.memo-encabezado td {
    padding: 4px 0;
    vertical-align: top;
    font-size: 11pt;
    line-height: 1.4;
}

.memo-encabezado .etiqueta {
    font-weight: bold;
    width: 15%;
    white-space: pre;
}

.memo-encabezado .datos {
    padding-left: 10px;
}

.memo-cuerpo {
    font-size: 11pt;
    line-height: 1.6;
    text-align: justify;
    margin-top: 20px;
}

#lbl-motivo {
    display: inline;
}

.memo-despedida {
    font-size: 11pt;
    line-height: 1.6;
    margin-top: 25px;
    text-align: justify;
}

@media print {
    @page {
        size: letter;
        margin: 0px;
    }
    body {
        background: white;
        padding: 0;
        overflow: visible;
    }
    .panel-controles, .controles-zoom {
        display: none;
    }
    .contenedor-vista-previa {
        padding: 0;
        background: none;
        overflow: visible;
    }
    .vista-previa {
        width: 215.9mm;
        height: 279.4mm;
        box-shadow: none;
        border-radius: 0;
        margin: 0;
        transform: scale(1) !important;
        print-color-adjust: exact;
        -webkit-print-color-adjust: exact;
    }
}