:root {
    --bg-color: #e3e8eb;
    --surface-blur: rgba(255, 255, 255, 0.95);
    --primary-accent: #114a60;
    --secondary-accent: #2c728e;
    --text-main: #2d3748;
    --text-muted: #718096;
    --border-color: #cbd5e1;
    --glass-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.glass-panel {
    background: var(--surface-blur);
    border: 1px solid rgba(255, 255, 255, 0.6);
    border-radius: 8px;
    box-shadow: var(--glass-shadow);
}

@keyframes headerShineRightToLeft {
    0% {
        background-position: 200% 50%;
    }

    100% {
        background-position: 0% 50%;
    }
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px 2rem;
    height: 60px;
    background: linear-gradient(to right, #ca8a04 0%, #fde047 30%, #ffffff 50%, #fde047 70%, #ca8a04 100%);
    background-size: 200% auto;
    animation: headerShineRightToLeft 6s linear infinite;
    border-bottom: 2px solid #ca8a04;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.brand-section h1 {
    font-size: 1.3rem;
    color: #0033a0;
    text-shadow: 1px 1px 0px rgba(255, 255, 255, 0.8);
}

.btn-volver {
    background: #0033a0;
    color: #ffffff;
    border: 1px solid #001f66;
    padding: 8px 16px;
    border-radius: 50px;
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 700;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    transition: all 0.2s;
}

.btn-volver:hover {
    background: #004ade;
    transform: scale(1.02);
}

.main-layout {
    display: flex;
    flex: 1;
    padding: 10px;
    height: calc(100vh - 60px);
    position: relative;
}

.workspace {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #eef2f4;
    overflow: hidden;
}

/* Tabs */
.tabs-nav {
    display: flex;
    gap: 2px;
    margin: 10px 10px 0 10px;
}

.tab-btn {
    background: #e2e8f0;
    border: 1px solid #cbd5e1;
    border-bottom: none;
    color: var(--text-muted);
    padding: 8px 14px;
    border-radius: 6px 6px 0 0;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
}

.tab-btn.active {
    background: #e2e8f0;
    color: var(--primary-accent);
    border-top: 3px solid var(--primary-accent);
}

.tab-content {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    display: none;
    background: #e2e8f0;
    border: 1px solid #cbd5e1;
    margin: 0 10px;
    border-radius: 0 6px 6px 6px;
}

.tab-content.active {
    display: block;
}

/* Grid Forms based on Image Layout */
.row {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
    flex-wrap: wrap;
    align-items: flex-start;
}

.col {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 120px;
}

.col-auto {
    display: flex;
    flex-direction: column;
}

.fieldset-box {
    border: 2px solid #cbd5e1;
    border-radius: 6px;
    padding: 12px 10px;
    position: relative;
    margin-top: 15px;
    margin-bottom: 10px;
    background: transparent;
}

.fieldset-box h4 {
    position: absolute;
    top: -10px;
    left: 15px;
    background: #e2e8f0;
    padding: 0 8px;
    color: #e67e22;
    /* Matches the orange highlights in image */
    font-size: 0.8rem;
    font-weight: 700;
}

label {
    font-size: 0.75rem;
    color: #4a5568;
    font-weight: 600;
    margin-bottom: 3px;
}

input,
select {
    border: 1px solid #cbd5e1;
    padding: 5px;
    border-radius: 3px;
    font-size: 0.85rem;
    background: #ffffff;
    color: #1a202c;
}

input[readonly],
input[disabled] {
    background: #f1f5f9;
    color: #718096;
}

/* Tables */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.data-table th,
.data-table td {
    padding: 6px;
    border: 1px solid #cbd5e1;
}

.data-table th {
    background: #f1f5f9;
    color: var(--primary-accent);
    text-align: left;
}

/* Sub-row specific tables (Liquidacion Aforo) */
.table-aforo th,
.table-aforo td {
    border: none;
    border-bottom: 1px solid #e2e8f0;
}

.table-aforo th {
    background: #fff;
    border-bottom: 2px solid #cbd5e1;
}

.text-orange {
    color: #e67e22;
    font-weight: bold;
}

.right-align {
    text-align: right;
}

/* Bottom Toolbar */
.bottom-toolbar {
    position: sticky;
    bottom: 0;
    z-index: 1000;
    box-shadow: 0 -4px 6px rgba(0,0,0,0.1);
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 4px;
    padding: 10px;
    background: #e2e8f0;
    border-top: 1px solid #cbd5e1;
    margin-top: auto;
}

.toolbar-btn {
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    padding: 6px 10px;
    font-size: 0.8rem;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    color: #4a5568;
    width: 70px;
}

.toolbar-btn i {
    font-size: 1.1rem;
    color: #2c728e;
}

.toolbar-btn:hover {
    background: #f8fafc;
    border-color: #2c728e;
}

.toolbar-divider {
    width: 1px;
    height: 35px;
    background: #cbd5e1;
    margin: 0 5px;
}

/* Botón Nuevo Resaltado */
#btn-nuevo i {
    color: #16a34a;
}

/* AI Assistant */
.ai-assistant-panel {
    position: fixed;
    right: 25px;
    bottom: 0px;
    width: 350px;
    height: 500px;
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 15px 15px 0 0;
    box-shadow: 0 -5px 25px rgba(0, 0, 0, 0.2);
    display: none;
    flex-direction: column;
    z-index: 10000;
}

.ai-assistant-panel.active {
    display: flex;
}

.ai-header {
    padding: 10px;
    background: #f8fafc;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 8px;
    border-radius: 12px 12px 0 0;
}

.ai-header i {
    color: var(--primary-accent);
    font-size: 1.2rem;
}

.ai-chat-area {
    flex: 1;
    padding: 10px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.chat-msg {
    max-width: 85%;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 0.85rem;
}

.msg-ai {
    align-self: flex-start;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
}

.msg-user {
    align-self: flex-end;
    background: var(--primary-accent);
    color: #fff;
}

.ai-input-area {
    padding: 10px;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 5px;
}

.ai-input-area input {
    flex: 1;
    border-radius: 15px;
}

.ai-input-area button {
    background: var(--primary-accent);
    color: #fff;
    border: none;
    border-radius: 15px;
    width: 30px;
    cursor: pointer;
}

/* Floating Toggle Button */
@keyframes aiPulse {
    0% {
        box-shadow: 0 0 10px rgba(34, 197, 94, 0.5);
    }

    50% {
        box-shadow: 0 0 20px rgba(74, 222, 128, 0.8), 0 0 40px rgba(74, 222, 128, 0.4);
    }

    100% {
        box-shadow: 0 0 10px rgba(34, 197, 94, 0.5);
    }
}

/* Magic Glowing AI Button */
@keyframes aiMagia {
    0% { box-shadow: 0 0 10px #facc15, 0 0 20px #84cc16; border-color: #facc15; }
    50% { box-shadow: 0 0 25px #eab308, 0 0 45px #22c55e, inset 0 0 15px #fef08a; border-color: #4ade80; }
    100% { box-shadow: 0 0 10px #facc15, 0 0 20px #84cc16; border-color: #facc15; }
}

@keyframes aiColorShift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.ai-floating-btn {
    position: fixed;
    right: 30px;
    bottom: 30px;
    width: 76px;
    height: 76px;
    border-radius: 50%;
    background: linear-gradient(270deg, #064e3b, #15803d, #854d0e, #ca8a04);
    background-size: 300% 300%;
    animation: aiColorShift 4s ease infinite, aiMagia 2.5s infinite ease-in-out;
    border: 2px solid #facc15;
    z-index: 9999;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.ai-floating-btn:hover {
    transform: scale(1.1) translateY(-5px);
}

.ai-floating-btn img {
    height: 56px;
    width: 56px;
    border-radius: 50%;
    object-fit: cover;
    object-position: center 20%; /* Shift focus up to the face */
    box-shadow: 0 0 10px rgba(0,0,0,0.8);
    border: 2px solid #fff;
    transform: scale(1.3) translateY(-4px); /* Zoom in by 30% to crop off the bottom text completely */
    position: relative;
    z-index: 1;
}

.ai-elegant-label {
    position: absolute;
    bottom: -8px;
    font-family: 'Playfair Display', serif;
    font-style: italic;
    font-size: 15px;
    font-weight: bold;
    color: #ffffff;
    text-shadow: 1px 1px 3px #000, 0 0 10px #facc15, 0 0 20px #fef08a;
    background: linear-gradient(135deg, #022c22, #166534);
    border: 1px solid #fef08a;
    padding: 3px 12px;
    border-radius: 20px;
    white-space: nowrap;
    z-index: 2;
    letter-spacing: 0.5px;
    box-shadow: 0 4px 10px rgba(250, 204, 21, 0.4);
}

.ai-floating-btn > span.ai-full-text {
    display: none;
}

/* Value Summary block bottom */
.val-summary-block {
    background: #fdfdfd;
    border: 1px solid #cbd5e1;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    margin-top: 10px;
}

/* --- REGLAS GLOBALES SOLICITADAS --- */
input:focus,
select:focus,
textarea:focus {
    background-color: #fef08a !important;
    outline: none !important;
    border-color: #eab308 !important;
    color: #000 !important;
}

/* Forzar títulos a azul marino, negrita y 14px */
.fieldset-box legend,
.fieldset-ne legend,
.fieldset-ne legend button,
.form-panel legend button,
h4.text-orange,
h3.text-orange,
.text-orange {
    color: #0033a0 !important;
    font-size: 14px !important;
    font-weight: bold !important;
}

.date-mask {
    text-align: center !important;
}
/* Formato + Informacion */

        body {
            background: #cbd5e1;
            margin: 0;
            padding: 20px;
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            display: flex;
            justify-content: center;
            align-items: flex-start;
            min-height: 100vh;
        }

        .window-container {
            background: #e2e8f0;
            border: 3px solid #94a3b8;
            border-radius: 4px;
            overflow: hidden;
            width: 100%;
            max-width: 1100px;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
        }

        .window-header {
            background: linear-gradient(to right, #2563eb, #3b82f6);
            color: white;
            padding: 4px 10px;
            font-weight: bold;
            font-size: 13px;
            display: flex;
            align-items: center;
            justify-content: space-between;
            border-bottom: 2px solid #94a3b8;
        }

        .window-header-icon {
            display: flex;
            align-items: center;
            gap: 8px;
        }

        .window-header-icon img {
            height: 16px;
        }

        .window-controls {
            display: flex;
            gap: 4px;
        }

        .window-controls div {
            width: 16px;
            height: 16px;
            background: #cbd5e1;
            border: 1px solid #9ca3af;
            color: black;
            font-size: 12px;
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            font-weight: bold;
        }

        .window-content {
            padding: 10px;
        }

        .grid-container {
            border: 2px solid #9ca3af;
            background: #fff;
            height: 400px;
            overflow-y: auto;
            margin-bottom: 10px;
        }

        .grid-table {
            width: 100%;
            border-collapse: collapse;
            font-size: 11px;
        }

        .grid-table th {
            border: 1px solid #9ca3af;
            background: #cbd5e1;
            padding: 4px 5px;
            font-weight: bold;
            position: sticky;
            top: 0;
            z-index: 10;
            font-size: 11px;
        }

        .grid-table td {
            border: 1px solid #cbd5e1;
            padding: 2px 5px;
            height: 18px;
            white-space: nowrap;
        }

        .grid-table tr:nth-child(even) {
            background: #f8fafc;
        }

        .grid-table tr.selected {
            background-color: #000;
            color: #fff;
        }

        .grid-table td.pointer {
            background: #cbd5e1;
            text-align: center;
            width: 15px;
        }

        .toolbar {
            display: flex;
            gap: 8px;
            align-items: stretch;
            background: #cbd5e1;
            padding: 10px;
            border: 2px solid #9ca3af;
            border-radius: 4px;
        }

        .nav-group {
            display: flex;
            gap: 4px;
        }

        .action-btn {
            background: #e2e8f0;
            border: 1px solid #9ca3af;
            border-radius: 2px;
            padding: 4px 8px;
            display: flex;
            flex-direction: column;
            align-items: center;
            font-size: 11px;
            cursor: pointer;
            color: #000;
            min-width: 50px;
            justify-content: center;
            font-weight: bold;
        }

        .action-btn i {
            font-size: 16px;
            margin-bottom: 4px;
            color: #dc2626;
        }

        .action-btn i.fa-check {
            color: #16a34a;
        }

        .action-btn i.fa-magnifying-glass {
            color: #3b82f6;
        }

        .filter-section {
            border: 1px solid #9ca3af;
            border-radius: 4px;
            padding: 8px 10px;
            display: flex;
            flex-direction: column;
            gap: 5px;
            background: #e2e8f0;
            flex: 1;
            position: relative;
        }

        .filter-title {
            position: absolute;
            top: -8px;
            left: 10px;
            background: #cbd5e1;
            font-size: 11px;
            color: #ea580c;
            font-weight: bold;
            padding: 0 4px;
        }

        .filter-input {
            width: 100%;
            border: 1px solid #9ca3af;
            box-sizing: border-box;
            height: 22px;
            margin-bottom: 5px;
        }

        .filter-radios {
            display: grid;
            grid-template-columns: repeat(4, 1fr);
            gap: 4px 10px;
            font-size: 11px;
        }

        .filter-radios label {
            display: flex;
            align-items: center;
            gap: 4px;
            white-space: nowrap;
        }
    

        body {
            background: #cbd5e1;
            margin: 0;
            padding: 20px;
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            display: flex;
            justify-content: center;
            align-items: flex-start;
            min-height: 100vh;
        }

        .window-container {
            background: #e2e8f0;
            border: 3px solid #94a3b8;
            border-radius: 4px;
            overflow: hidden;
            width: 100%;
            max-width: 950px;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
        }

        .window-header {
            background: linear-gradient(to right, #2563eb, #3b82f6);
            color: white;
            padding: 4px 10px;
            font-weight: bold;
            font-size: 13px;
            display: flex;
            align-items: center;
            justify-content: space-between;
            border-bottom: 2px solid #94a3b8;
        }

        .window-header-icon {
            display: flex;
            align-items: center;
            gap: 8px;
        }

        .window-header-icon img {
            height: 16px;
        }

        .window-controls {
            display: flex;
            gap: 4px;
        }

        .window-controls div {
            width: 16px;
            height: 16px;
            background: #cbd5e1;
            border: 1px solid #9ca3af;
            color: black;
            font-size: 12px;
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            font-weight: bold;
        }

        .window-content {
            padding: 15px;
        }

        .form-panel {
            display: flex;
            gap: 15px;
            margin-bottom: 15px;
        }

        .panel-left {
            flex: 1.1;
            display: flex;
            flex-direction: column;
            gap: 12px;
        }

        .panel-right {
            flex: 0.9;
            display: flex;
            flex-direction: column;
            gap: 12px;
        }

        .fieldset-ne {
            border: 2px solid #9ca3af;
            border-radius: 6px;
            padding: 12px 15px;
            position: relative;
            background: #e2e8f0;
        }

        .fieldset-ne legend {
            color: #ea580c;
            font-weight: bold;
            font-size: 13px;
            position: absolute;
            top: -10px;
            left: 10px;
            background: #e2e8f0;
            padding: 0 5px;
        }

        .fieldset-ne legend button {
            background: transparent;
            border: none;
            color: #000;
            font-weight: bold;
            font-size: 13px;
            cursor: pointer;
            padding: 0;
            text-decoration: none;
        }

        .form-row {
            display: flex;
            gap: 8px;
            align-items: center;
            margin-bottom: 8px;
        }

        .form-row.top-align {
            align-items: flex-start;
        }

        .form-row label {
            font-size: 11px;
            font-weight: bold;
            white-space: nowrap;
        }

        .form-row input[type="text"] {
            border: 2px solid #cbd5e1;
            padding: 2px 5px;
            font-size: 12px;
            height: 24px;
            box-sizing: border-box;
            background: #fff;
        }

        .form-row textarea {
            border: 2px solid #cbd5e1;
            padding: 4px 5px;
            font-size: 11px;
            box-sizing: border-box;
            background: #fff;
            width: 100%;
            resize: none;
            font-family: inherit;
        }

        .toolbar {
            display: flex;
            gap: 10px;
            justify-content: center;
            background: #cbd5e1;
            padding: 10px;
            border-top: 2px solid #9ca3af;
        }

        .nav-group {
            display: flex;
            gap: 2px;
        }

        .btn-ne {
            background: #e2e8f0;
            border: 1px solid #9ca3af;
            border-radius: 2px;
            padding: 4px 8px;
            display: flex;
            flex-direction: column;
            align-items: center;
            font-size: 10px;
            cursor: pointer;
            min-width: 45px;
            font-weight: bold;
            color: #000;
            justify-content: center;
        }

        .btn-ne i {
            font-size: 16px;
            margin-bottom: 4px;
            color: #1e293b;
        }

        .btn-ne i.red {
            color: #dc2626;
        }

        .btn-ne i.blue {
            color: #2563eb;
        }

        .btn-ne.active {
            background: #000;
            color: #fff;
        }

        .btn-ne.active i {
            color: #fff;
        }
    \n\n/* --- SYNC CAMPOS (Campos Relacionados) --- */\n.sync-campo {\n    border: 2px solid #99f6e4 !important;\n    background-color: #f0fdfa !important;\n    transition: background-color 0.4s ease, border-color 0.4s ease;\n    box-shadow: 0 0 3px rgba(153, 246, 228, 0.4);\n}\n.sync-campo:focus {\n    border-color: #2dd4bf !important;\n    box-shadow: 0 0 6px rgba(45, 212, 191, 0.6);\n}\n.sync-flash {\n    background-color: #fef08a !important;\n    transition: background-color 0.1s ease;\n}

/* USER REQUEST: BLUE ACTIVE TAB */
.tab-btn.active { color: #ffffff !important; background-color: #0033a0 !important; font-weight: bold !important; border-bottom: none !important; box-shadow: 0 -2px 6px rgba(0, 51, 160, 0.4) !important; }

/* ==========================================================================
   REGLAS OFICIALES DE IMPRESIÓN TAMAÑO CARTA (LETTER 100% EXPANDIDO)
   ========================================================================== */
@media print {
    @page {
        size: letter portrait;
        margin: 8mm 10mm 8mm 10mm;
    }
    * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
        box-sizing: border-box !important;
    }
    html, body {
        width: 100% !important;
        height: auto !important;
        margin: 0 !important;
        padding: 0 !important;
        background: #ffffff !important;
        color: #000000 !important;
        font-family: 'Segoe UI', Arial, Helvetica, sans-serif !important;
        overflow: visible !important;
    }
    /* Ocultar interfaz del sistema */
    .sidebar,
    .top-header,
    .header-panel,
    .tab-buttons-container,
    .botonera-acciones,
    .tab-content:not(#tab-desconsolidacion),
    #chat-toggle-btn,
    #chat-widget-container,
    .no-print,
    button {
        display: none !important;
    }

    /* Ocultar fondo de agente de cargas cuando se imprime la notificacion */
    body.printing-notif-carta .main-container,
    body.printing-notif-carta #tab-desconsolidacion > *:not(#modal-notif-arribo) {
        display: none !important;
    }

    /* Modal de Notificación de Arribo: Ocupa el 100% de la hoja Carta */
    #modal-notif-arribo {
        display: block !important;
        position: static !important;
        inset: auto !important;
        width: 100% !important;
        height: auto !important;
        min-height: 100% !important;
        background: #ffffff !important;
        padding: 0 !important;
        margin: 0 !important;
        box-shadow: none !important;
        z-index: 999999 !important;
    }

    #modal-notif-arribo .modal-dialog-notif {
        display: block !important;
        width: 100% !important;
        max-width: 100% !important;
        min-height: 260mm !important;
        margin: 0 !important;
        padding: 0 !important;
        box-shadow: none !important;
        border: none !important;
        background: #ffffff !important;
        border-radius: 0 !important;
    }

    /* Ocultar controles interactivos en papel */
    #modal-notif-arribo .notif-screen-controls,
    #modal-notif-arribo button,
    #modal-notif-arribo .btn-close-modal {
        display: none !important;
    }

    /* El documento de notificación expandido al tamaño completo de la hoja carta */
    #notif-letter-document {
        display: flex !important;
        flex-direction: column !important;
        justify-content: space-between !important;
        width: 100% !important;
        min-height: 258mm !important;
        box-sizing: border-box !important;
        padding: 4mm 6mm !important;
        margin: 0 !important;
        border: 2px solid #0033a0 !important;
        border-radius: 6px !important;
        box-shadow: none !important;
        background: #ffffff !important;
    }
}