/* ==========================================================================
   VARIABLES DE DISEÑO CORE
   ========================================================================== */
:root {
    --primary: #4b41e1;
    /* Indigo corporativo moderno */
    --primary-dark: #3730a3;
    /* Indigo oscuro para hover */
    --secondary: #0ea10e;
    /* Verde de confirmación */
    --warning: #f59e0b;
    /* Ámbar para alertas */
    --error: #e11d48;
    /* Carmesí para bajas o borrar */
    --background: #f7f9fb;
    /* Gris claro de fondo general */
    --surface: #ffffff;
    /* Blanco para tarjetas y papel */
    --border-color: #cbd5e1;
    /* Gris para bordes y separadores */
    --text-main: #0f172a;
    /* Azul pizarra oscuro para textos */
    --text-muted: #64748b;
    /* Gris neutro para etiquetas */
    --body: #0B58CA;
    --font-stack: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* ==========================================================================
   REGLAS CORE Y RESET RESPONSIVO
   ========================================================================== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--background);
    font-family: var(--font-stack);
    color: var(--text-main);
    -webkit-font-smoothing: antialiased;
    padding: 12px 8px;
    min-height: 100vh;
}

/* ==========================================================================
   LIENZO DE PÁGINA RESPONSIVO (COMPACTADO)
   ========================================================================== */
.page {
    width: 100%;
    max-width: 1000px;
    margin: 0 auto 20px auto;
    background: var(--surface);
    padding: 16px;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.04);
}

/* ==========================================================================
   HEADER RESPONSIVO
   ========================================================================== */
.header {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 12px;
    border-bottom: 2px solid var(--text-main);
    padding-bottom: 16px;
    margin-bottom: 20px;
}

.logo {
    width: 85px;
    height: auto;
}

.company .subtitle {
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.12em;
}

.meta {
    width: 100%;
    text-align: center;
}

.meta label {
    display: block;
    font-size: 11px;
    font-weight: 800;
    color: var(--text-muted);
    text-transform: uppercase;
    margin-bottom: 4px;
}

.meta input[type="date"] {
    width: 100%;
    max-width: 240px;
    padding: 10px 14px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background-color: var(--background);
    color: var(--text-main);
    font-size: 14px;
    font-weight: 600;
    text-align: center;
    outline: none;
    -webkit-appearance: none;
}

/* ==========================================================================
   CAMPOS DE ENTRADA Y TEXTAREAS
   ========================================================================== */
.field {
    display: flex;
    flex-direction: column;
    margin-bottom: 16px;
}

.field label {
    font-size: 11px;
    font-weight: 800;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 6px;
}

.field select,
.field textarea {
    width: 100%;
    padding: 10px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background-color: var(--background);
    color: var(--text-main);
    font-size: 13px;
    font-weight: 600;
    outline: none;
}

.field textarea {
    resize: vertical;
    min-height: 65px;
    font-weight: 400;
}

.field select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2364748b' stroke-width='2'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    background-size: 16px;
}

/* ==========================================================================
   TABLA CON RECUADROS VISIBLES Y HORIZONTAL SCROLL
   ========================================================================== */
.table-wrap {
    margin-top: 15px;
    margin-bottom: 16px;
    border: 2px solid var(--body);
    border-radius: 8px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
    min-width: 880px;
    font-size: 12px;
}

th {
    background-color: var(--body);
    color: var(--surface);
    font-size: 10.5px;
    font-weight: 700;
    text-transform: uppercase;
    padding: 10px 6px;
    text-align: center;
    border: 1px solid var(--body);
    border-right-color: rgba(255, 255, 255, 0.2);
}

th:last-child {
    border-right-color: var(--text-main);
}

td {
    padding: 5px 6px;
    border: 1px solid #cbd5e1;
    vertical-align: middle;
    background-color: var(--surface);
}

td input[type="text"],
td textarea {
    width: 100%;
    border: none;
    padding: 4px;
    font-size: 12px;
    color: var(--text-main);
    background: transparent;
    outline: none;
    border-radius: 4px;
}

td input[type="text"]:focus,
td textarea:focus {
    background-color: rgba(7b, 65, 225, 0.03);
}

td textarea {
    resize: none;
    min-height: 48px;
    line-height: 1.4;
}

/* ==========================================================================
   BOTONES AJUSTABLES
   ========================================================================== */
.controls {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
    justify-content: center;
    margin-top: 16px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background-color: var(--primary);
    color: var(--surface);
    padding: 10px 14px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-weight: 700;
    font-size: 12px;
    text-transform: uppercase;
    text-decoration: none;
    text-align: center;
    flex: 1 1 45%;
    min-width: 140px;
}

.btn:active {
    transform: scale(0.97);
}

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

.btn-warning {
    background-color: var(--warning);
}

.btn.ghost {
    background-color: transparent;
    color: var(--primary);
    border: 1px solid var(--primary);
}

.small-icon-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 4px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.small-icon-btn:hover {
    background-color: #fee2e2;
}

/* ==========================================================================
   ZONA DE FIRMAS Y MODALES
   ========================================================================== */
.firmas {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-top: 20px;
    padding-top: 14px;
    border-top: 1px solid #e2e8f0;
}

.firma {
    width: 100%;
}

.firma label {
    display: block;
    font-size: 11px;
    font-weight: 800;
    color: var(--text-main);
    text-transform: uppercase;
    margin-bottom: 6px;
    text-align: center;
}

.firma canvas {
    width: 100%;
    height: 135px;
    border: 2px dashed var(--border-color);
    border-radius: 8px;
    background-color: var(--background);
    touch-action: none;
    background-image: radial-gradient(circle, #cbd5e1 1px, transparent 1px);
    background-size: 16px 16px;
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    padding: 12px;
}

.modal-content {
    background-color: var(--surface);
    padding: 20px;
    border-radius: 12px;
    width: 100%;
    max-width: 440px;
}

.modal-content h3 {
    font-size: 17px;
    margin-bottom: 4px;
    font-weight: 700;
}

.modal-content p {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 14px;
}

.modal-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

/* ==========================================================================
   ADAPTACIÓN PARA PANTALLAS GRANDES (PC / TABLET)
   ========================================================================== */
@media (min-width: 768px) {
    body {
        padding: 20px;
    }

    .page {
        padding: 24px;
    }

    .header {
        flex-direction: row;
        text-align: left;
        padding-bottom: 16px;
    }

    .meta {
        width: auto;
        margin-left: auto;
        text-align: right;
    }

    .controls {
        justify-content: flex-start;
    }

    .btn {
        flex: initial;
        min-width: auto;
    }

    .firmas {
        flex-direction: row;
        gap: 20px;
    }

    .firma {
        width: 49%;
    }
}