/* ============================================================
   styles.css - Estilos del Calendario de Pedidos y Recepción
   ------------------------------------------------------------
   Mantiene el diseño original de la aplicación.
   Secciones:
     1. Estilos base (body, títulos, leyenda, tablas)
     2. Barra de navegación superior fija
     3. Drag & drop (celdas válidas/inválidas)
     4. Pantalla de Proveedores (toolbar, botones, chips)
     5. Modal de alta/edición de proveedores
     6. Panel lateral de leyenda (cenefa)
     7. Toast (notificaciones)
   ============================================================ */
body {
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
margin: 0;
            padding: 76px 20px 20px;
            background-color: #f8f9fa;
            color: #333;
        }
        h1, h2 {
            color: #2c3e50;
            text-align: center;
        }
        .leyenda {
            background-color: #e9ecef;
            border-left: 5px solid #007bff;
            padding: 15px;
            margin-bottom: 20px;
            font-size: 0.9em;
        }
        .leyenda strong { color: #007bff; }
        table {
            width: 100%;
            border-collapse: collapse;
            margin-bottom: 40px;
            background-color: #fff;
            box-shadow: 0 4px 6px rgba(0,0,0,0.1);
        }
th, td {
            border: 1px solid #dee2e6;
            padding: 12px;
            vertical-align: top;
        }
        /* Separación entre días un poco más marcada */
        tbody tr td { border-bottom: 2px solid #ced4da; }
        th {
            background-color: #343a40;
            color: #fff;
            text-align: center;
            font-size: 1.1em;
        }
td:first-child {
            font-weight: bold;
            background-color: #e9ecef;
            text-align: center;
            width: 10%;
        }
        /* Resumen de cantidades bajo el nombre del día */
        .resumen {
            display: block;
            font-size: 0.72em;
            font-weight: normal;
            color: #6c757d;
            margin-top: 5px;
            line-height: 1.5;
        }
        .resumen .rsem, .resumen .rquin, .resumen .rmen { display: block; }
        .resumen .rsem::before { content: '● '; color: #007bff; }
        .resumen .rquin::before { content: '● '; color: #fd7e14; }
        .resumen .rmen::before { content: '● '; color: #6f42c1; }
        .resumen .rtotal {
            display: block;
            margin-top: 4px;
            border-top: 1px solid #ced4da;
            padding-top: 2px;
            font-weight: bold;
            color: #495057;
        }
        .resumen .rvacio { color: #adb5bd; font-style: italic; }
        /* Fila sin datos en esa tabla: gris atenuado (solo esa tabla) */
        tr.dia-vacio td { background-color: #f1f3f5 !important; }
        tr.dia-vacio td:first-child { color: #adb5bd; }
        tr.dia-vacio .resumen .rvacio { color: #adb5bd; }
        .prep { color: #d35400; font-weight: bold; font-size: 0.85em; display: block; margin-top: 5px; }
        .sup-nombre { font-weight: 600; font-size: 0.96em; color: #1f2937; }
        .sem-label {
            font-size: 0.72em;
            font-weight: normal;
            color: #6c757d;
            background: #e9ecef;
            border-radius: 3px;
            padding: 0 4px;
            margin-left: 4px;
            vertical-align: middle;
        }
        .supplier .prep {
            color: #6c757d;
            font-weight: normal;
            font-size: 0.8em;
            display: block;
            margin-top: 2px;
        }
        .estricto { color: #c0392b; font-size: 0.8em; font-style: italic; }
        .llegada { color: #27ae60; font-weight: bold; }
        .gigante { background-color: #fff3cd; border: 1px dashed #ffc107; padding: 2px; border-radius: 3px; }
        ul { margin: 0; padding-left: 20px; font-size: 0.9em; line-height: 1.4; }
        li { margin-bottom: 4px; }

.app-nav {
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            z-index: 999;
            background-color: #343a40;
            box-shadow: 0 2px 8px rgba(0,0,0,0.3);
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 0 20px;
            height: 56px;
        }
        .nav-logo {
            display: flex;
            align-items: center;
            gap: 12px;
            color: #fff;
            font-weight: bold;
            letter-spacing: 0.3px;
        }
        .nav-logo-img {
            height: 38px;
            width: auto;
            object-fit: contain;
            flex-shrink: 0;
        }
        .brand-text {
            display: flex;
            flex-direction: column;
            line-height: 1.1;
        }
        .brand-main {
            position: relative;
            display: block;
            height: 1.4em;
            min-width: 240px;
            overflow: hidden;
            font-size: 1.15em;
            font-weight: 600;
            color: #fff;
            line-height: 1.4;
        }
        .brand-full, .brand-short {
            position: absolute;
            left: 0;
            top: 0;
            white-space: nowrap;
            transition: opacity 0.6s ease, transform 0.6s ease;
        }
        .brand-short { opacity: 0; transform: translateX(22px); }
        .brand-main.animado .brand-full { opacity: 0; transform: translateX(-22px); }
        .brand-main.animado .brand-short { opacity: 1; transform: translateX(0); }
        .brand-sub { font-size: 0.68em; font-weight: 400; color: #adb5bd; letter-spacing: 0.3px; }
        .nav-options {
            display: flex;
            gap: 6px;
        }
        .nav-btn {
            background: transparent;
            color: #adb5bd;
            border: none;
            padding: 8px 14px;
            font-size: 0.95em;
            border-radius: 4px;
            cursor: pointer;
            font-family: inherit;
            transition: background-color 0.2s, color 0.2s;
        }
        .nav-btn:hover { background-color: #495057; color: #fff; }
        .nav-btn.active { background-color: #007bff; color: #fff; }
        .hidden { display: none !important; }

        /* Barra de herramientas del calendario (buscador, imprimir, CSV) */
        .cal-toolbar {
            display: flex;
            gap: 8px;
            justify-content: center;
            align-items: center;
            margin-bottom: 20px;
            flex-wrap: wrap;
        }
        .cal-toolbar input[type="text"] {
            padding: 8px 10px;
            font-size: 0.9em;
            border: 1px solid #ced4da;
            border-radius: 4px;
            font-family: inherit;
            width: 260px;
        }
        /* Resaltado del buscador en los calendarios */
        .supplier.buscar-alta {
            outline: 2px solid #007bff;
            outline-offset: 1px;
            background-color: #cfe2ff;
        }
        .supplier.buscar-baja { opacity: 0.25; }
        /* Switch vista invertida */
        .switch-vista {
            display: inline-flex;
            align-items: center;
            gap: 6px;
            font-size: 0.9em;
            color: #495057;
            cursor: pointer;
            user-select: none;
            border: 1px solid #ced4da;
            border-radius: 20px;
            padding: 6px 12px;
            background: #fff;
        }
        .switch-vista input { accent-color: #007bff; }
        /* Pills filtro quincenal (sutil, en cabecera/fila de frecuencia) */
        .filtros-semana { display: inline-flex; gap: 4px; margin-left: 8px; vertical-align: middle; }
        .filtro-pill {
            font-size: 0.7em;
            padding: 2px 7px;
            border: 1px solid #ced4da;
            border-radius: 12px;
            background: #fff;
            color: #6c757d;
            cursor: pointer;
            line-height: 1;
            transition: all 0.15s;
        }
        .filtro-pill.activo { background: #007bff; color: #fff; border-color: #007bff; }
        .filtro-pill:hover { border-color: #007bff; color: #007bff; }
        .filtro-pill.activo:hover { background: #0056b3; border-color: #0056b3; color: #fff; }
        /* Cabecera de día vacía en vista invertida (th con resumen sin pedidos) */
        th.dia-vacio-col { background-color: #f1f3f5 !important; color: #adb5bd; }
        th.dia-vacio-col .resumen .rvacio { color: #adb5bd; }

.supplier {
            cursor: grab;
            transition: opacity 0.15s, background-color 0.15s, box-shadow 0.15s, transform 0.15s;
            border-radius: 3px;
            padding: 1px 4px;
        }
        .supplier:hover {
            background-color: #e7f3ff;
            box-shadow: 0 1px 4px rgba(0,0,0,0.14);
            transform: translateY(-1px);
        }
        .supplier.gigante:hover { background-color: #ffe9a8; }
        .supplier.hecho { opacity: 0.95; }
        .hecho-badge { color: #16a34a; font-weight: bold; margin-left: 4px; }
        .historial { display: block; font-size: 0.7em; margin-top: 2px; line-height: 1.2; }
        .historial.hecho-hist { font-weight: 600; }
        .historial.previo-hist { opacity: 0.7; font-style: italic; }
        .supplier.dragging { opacity: 0.4; }
        /* Línea de inserción al reordenar dentro de la celda */
        .supplier.insert-before { box-shadow: inset 0 2px 0 #007bff; }
        .supplier.insert-after { box-shadow: inset 0 -2px 0 #007bff; }
        /* Sombreado breve cuando otro equipo actualiza un proveedor */
        @keyframes flash-update {
            0% { background-color: #cfe2ff; box-shadow: 0 0 0 2px rgba(13,110,253,0.45); }
            100% { background-color: transparent; box-shadow: none; }
        }
        .supplier.flash-update { animation: flash-update 1.3s ease-out; }
        /* Resaltado al saltar entre pedido y recepción */
        @keyframes ir-highlight {
            0% { background-color: #d1f0d8; box-shadow: 0 0 0 2px rgba(25,135,84,0.45); }
            100% { background-color: transparent; box-shadow: none; }
        }
        .supplier.ir-highlight { animation: ir-highlight 8s ease-out; }
        /* Resaltado sutil de todo el día (fila), sin tocar la cabecera del día */
        @keyframes dia-highlight {
            0% { background-color: #eaf6ec; }
            100% { background-color: transparent; }
        }
        tr.dia-highlight td:not(:first-child) { animation: dia-highlight 5s ease-out; }
        /* Menú contextual (clic derecho) */
        .ctx-menu {
            position: fixed;
            z-index: 1500;
            background: #fff;
            border: 1px solid #dee2e6;
            border-radius: 5px;
            box-shadow: 0 6px 16px rgba(0,0,0,0.18);
            min-width: 170px;
            padding: 4px 0;
        }
        .ctx-item {
            display: block;
            width: 100%;
            background: none;
            border: none;
            text-align: left;
            padding: 8px 14px;
            font-size: 0.9em;
            font-family: inherit;
            color: #2c3e50;
            cursor: pointer;
        }
        .ctx-item:hover { background: #e7f3ff; color: #0056b3; }
        .supplier .re-link {
            cursor: pointer;
            border: none;
            background: #007bff;
            color: #fff;
            border-radius: 3px;
            font-size: 0.7em;
            padding: 1px 5px;
            margin-left: 6px;
            vertical-align: middle;
        }
        .supplier .re-link:hover { background: #0056b3; }
        .override-badge { color: #007bff; font-size: 0.8em; font-weight: normal; margin-left: 6px; }
        td.drop-ok { outline: 2px dashed #28a745; outline-offset: -2px; background-color: #f0fff4; }
        td.drop-no { outline: 2px dashed #dc3545; outline-offset: -2px; background-color: #fff5f5; }
        .drag-hint {
            background-color: #d1ecf1;
            border-left: 5px solid #0c5460;
            padding: 10px 15px;
            margin-bottom: 20px;
            font-size: 0.9em;
            color: #0c5460;
        }

        .db-toolbar {
            display: flex;
            gap: 8px;
            justify-content: center;
            align-items: center;
            margin-bottom: 20px;
            flex-wrap: wrap;
        }
.db-toolbar input[type="text"] {
            padding: 8px 10px;
            font-size: 0.9em;
            border: 1px solid #ced4da;
            border-radius: 4px;
            font-family: inherit;
            width: 220px;
        }
        /* Sección colapsable con las acciones avanzadas (exportar,
           importar, restaurar) para que no se toquen por accidente */
        .db-avanzado {
            max-width: 640px;
            margin: 0 auto 20px;
            border: 1px solid #dee2e6;
            border-radius: 6px;
            background: #f1f3f5;
            padding: 8px 12px;
        }
        .db-avanzado summary {
            cursor: pointer;
            font-size: 0.85em;
            color: #6c757d;
            user-select: none;
        }
        .db-avanzado summary:hover { color: #343a40; }
        .db-avanzado-buttons {
            display: flex;
            gap: 8px;
            flex-wrap: wrap;
            margin-top: 8px;
        }
        .db-avanzado-buttons .btn { font-size: 0.82em; padding: 6px 10px; }
        .btn {
            background-color: #343a40;
            color: #fff;
            border: none;
            padding: 8px 14px;
            font-size: 0.9em;
            border-radius: 4px;
            cursor: pointer;
            font-family: inherit;
        }
        .btn:hover { background-color: #495057; }
        .btn-primary { background-color: #007bff; }
        .btn-primary:hover { background-color: #0056b3; }
        .btn-danger { background-color: #dc3545; }
        .btn-danger:hover { background-color: #bd2130; }
        .btn-success { background-color: #28a745; }
        .btn-success:hover { background-color: #218838; }
#tablaProveedores { font-size: 0.85em; }
        #tablaProveedores th { font-size: 0.95em; }
        #tablaProveedores th.sortable {
            cursor: pointer;
            user-select: none;
            white-space: nowrap;
            transition: background-color 0.15s;
        }
        #tablaProveedores th.sortable:hover { background-color: #495057; }
        .sort-ind { font-size: 0.75em; margin-left: 3px; color: #ffc107; }
        .inline-select { font-size: 0.85em; padding: 2px 4px; border: 1px solid #ced4da; border-radius: 4px; background: #fff; font-family: inherit; max-width: 150px; }
        .inline-input { width: 56px; font-size: 0.85em; padding: 2px 4px; border: 1px solid #ced4da; border-radius: 4px; text-align: center; font-family: inherit; }
        .inline-check { width: 16px; height: 16px; accent-color: #007bff; cursor: pointer; }
        #tablaProveedores td { vertical-align: middle; }
        #tablaProveedores td:first-child { background-color: #fff; width: auto; }
        .chip {
            display: inline-block;
            background: #e9ecef;
            border-radius: 3px;
            padding: 0 5px;
            margin: 1px;
            font-size: 0.8em;
        }
        .chip-none { color: #999; font-style: italic; }
        .chips-edit { display: inline-flex; gap: 2px; flex-wrap: wrap; }
        .chip-edit {
            font-size: 0.72em;
            padding: 1px 5px;
            border: 1px solid #dee2e6;
            border-radius: 10px;
            background: #fff;
            color: #adb5bd;
            cursor: pointer;
            line-height: 1.3;
            transition: all 0.12s;
        }
        .chip-edit.activo { background: #007bff; color: #fff; border-color: #007bff; }
        .chip-edit:hover { border-color: #007bff; color: #007bff; }
        .chip-edit.activo:hover { background: #0056b3; border-color: #0056b3; }

        .modal-overlay {
            position: fixed;
            top: 0; left: 0; right: 0; bottom: 0;
            background: rgba(0,0,0,0.5);
            display: flex;
            align-items: flex-start;
            justify-content: center;
            z-index: 1000;
            overflow-y: auto;
            padding: 30px 10px;
        }
        .modal {
            background: #fff;
            border-radius: 6px;
            box-shadow: 0 10px 30px rgba(0,0,0,0.3);
            width: 100%;
            max-width: 640px;
            padding: 20px 24px;
        }
        .modal h3 { margin-top: 0; color: #2c3e50; }
        .modal .campo { margin-bottom: 14px; }
        .modal label { display: block; font-weight: bold; margin-bottom: 5px; font-size: 0.9em; color: #2c3e50; }
        .modal input[type="text"], .modal input[type="number"], .modal select {
            width: 100%;
            padding: 8px 10px;
            border: 1px solid #ced4da;
            border-radius: 4px;
            font-family: inherit;
            font-size: 0.9em;
            box-sizing: border-box;
        }
        .modal .checks label {
            display: inline-block;
            font-weight: normal;
            margin-right: 10px;
            margin-bottom: 6px;
            background: #e9ecef;
            padding: 5px 8px;
            border-radius: 4px;
            cursor: pointer;
            user-select: none;
        }
        .modal .checks label.checked { background: #007bff; color: #fff; }
        .modal .checks input { margin-right: 3px; }
        .modal .fila { display: flex; gap: 14px; flex-wrap: wrap; }
        .modal .fila .campo { flex: 1; min-width: 160px; }
        .modal .acciones { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; }

        #toast {
            position: fixed;
            bottom: 24px;
            left: 50%;
            transform: translateX(-50%);
            background: #343a40;
            color: #fff;
            padding: 12px 20px;
            border-radius: 5px;
            font-size: 0.9em;
            z-index: 2000;
            max-width: 90vw;
            box-shadow: 0 4px 12px rgba(0,0,0,0.3);
            opacity: 0;
            transition: opacity 0.25s;
            pointer-events: none;
        }
#toast.show { opacity: 1; }

        .side-tab {
            position: fixed;
            top: 120px;
            right: 0;
            z-index: 1000;
            width: 24px;
            height: 96px;
            background-color: rgba(0, 123, 255, 0.55);
            color: #fff;
            border: none;
            border-radius: 8px 0 0 8px;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            box-shadow: -1px 1px 5px rgba(0,0,0,0.15);
            font-size: 0.68em;
            font-weight: 600;
            writing-mode: vertical-rl;
            text-orientation: mixed;
            transition: background-color 0.2s;
            font-family: inherit;
            padding: 3px 0;
            letter-spacing: 1px;
        }
        .side-tab:hover { background-color: rgba(0, 123, 255, 0.85); }
        .side-panel {
            position: fixed;
            top: 56px;
            right: 0;
            bottom: 0;
            width: 340px;
            max-width: 92vw;
            z-index: 998;
            background: #f8f9fa;
            box-shadow: -3px 0 12px rgba(0,0,0,0.2);
            transform: translateX(100%);
            transition: transform 0.3s ease;
            overflow-y: auto;
            padding: 16px;
            border-left: 1px solid #dee2e6;
        }
        .side-panel.open { transform: translateX(0); }
        .panel-head {
            display: flex;
            align-items: center;
            justify-content: space-between;
            margin-bottom: 12px;
        }
        .panel-head h3 {
            margin: 0;
            color: #2c3e50;
            font-size: 1em;
        }
        .panel-close {
            background: none;
            border: none;
            font-size: 1.15em;
            line-height: 1;
            cursor: pointer;
            color: #6c757d;
            padding: 4px 8px;
            border-radius: 4px;
            transition: background-color 0.2s, color 0.2s;
        }
        .panel-close:hover { background: #e9ecef; color: #dc3545; }

        /* Bloqueo por patrón (M) */
        .patron-overlay {
            position: fixed;
            inset: 0;
            z-index: 4000;
            background: rgba(248,249,250,0.97);
            display: flex;
            align-items: center;
            justify-content: center;
            padding: 20px;
        }
        .patron-box {
            background: #fff;
            border-radius: 12px;
            box-shadow: 0 10px 30px rgba(0,0,0,0.15);
            padding: 24px 28px;
            text-align: center;
            max-width: 340px;
            width: 100%;
        }
        .patron-box h3 { margin: 0 0 6px; color: #2c3e50; }
        .patron-hint { margin: 0 0 16px; color: #6c757d; font-size: 0.9em; }
        .patron-grid {
            position: relative;
            width: 300px;
            height: 300px;
            max-width: 80vw;
            max-height: 80vw;
            margin: 0 auto;
            display: grid;
            grid-template-columns: repeat(3, 1fr);
            gap: 18px;
            place-items: center;
            touch-action: none;
            user-select: none;
        }
        .patron-grid .punto {
            width: 64px;
            height: 64px;
            border-radius: 50%;
            border: 2px solid #ced4da;
            background: #f8f9fa;
            cursor: pointer;
            transition: background-color 0.15s, border-color 0.15s, transform 0.1s;
        }
        .patron-grid .punto.activo {
            background: #007bff;
            border-color: #007bff;
            transform: scale(1.05);
        }
        .patron-grid .punto.error {
            background: #dc3545;
            border-color: #dc3545;
        }
        .patron-svg {
            position: absolute;
            inset: 0;
            width: 100%;
            height: 100%;
            pointer-events: none;
        }
        .patron-msg {
            margin-top: 14px;
            min-height: 1.2em;
            font-size: 0.9em;
            font-weight: 600;
        }

        /* Impresión / PDF: una hoja horizontal por calendario */
        @media print {
            @page {
                size: landscape;
                margin: 10mm;
            }
            .app-nav, .side-tab, .side-panel, .cal-toolbar,
            #screen-proveedores, #modal, #toast, #ctxMenu {
                display: none !important;
            }
            body { padding: 0; margin: 0; }
            table { box-shadow: none; margin-bottom: 0; }
            h1, h2 { color: #2c3e50; }
            #screen-calendario h2 {
                margin: 0 0 8px;
                font-size: 15px;
            }
            /* Tablas compactas para que quepan en una hoja */
            th, td { padding: 4px 6px; font-size: 10px; }
            th { font-size: 10px; }
            td:first-child { width: 7%; }
            ul { padding-left: 12px; font-size: 0.8em; line-height: 1.25; }
            li { margin-bottom: 2px; }
            .resumen { font-size: 0.68em; margin-top: 3px; line-height: 1.3; }
            .sup-nombre { font-size: 0.95em; }
            .prep { font-size: 0.72em; margin-top: 2px; }
            .supplier { padding: 0 3px; }
            /* Un calendario por hoja: al terminar Pedidos se pasa de página */
            #tablaPedidos {
                page-break-after: always;
                break-after: page;
            }
            #tablaRecepcion { page-break-before: auto; }
            td, th, .supplier, .resumen {
                -webkit-print-color-adjust: exact;
                print-color-adjust: exact;
            }
        }