/* ══════════════════════════════════════════════════
   GESTIÓN ENTRADAS — Flomay Química
   Paleta: azul noche #1e3a5f · acento verde #10b981
          gris cálido #f7f8fa · blanco puro #ffffff
   ══════════════════════════════════════════════════ */

:root {
    --blue-dark:   #1e3a5f;
    --blue-mid:    #2563eb;
    --blue-light:  #dbeafe;
    --green:       #10b981;
    --green-light: #d1fae5;
    --amber:       #f59e0b;
    --amber-light: #fef3c7;
    --red:         #ef4444;
    --red-light:   #fee2e2;
    --bg:          #f0f4f8;
    --surface:     #ffffff;
    --border:      #e2e8f0;
    --text:        #1a202c;
    --text-mid:    #4a5568;
    --text-light:  #718096;
    --shadow-sm:   0 1px 4px rgba(0,0,0,.08);
    --shadow-md:   0 4px 20px rgba(0,0,0,.12);
    --shadow-lg:   0 8px 40px rgba(0,0,0,.18);
    --radius:      12px;
    --radius-sm:   8px;
    --header-h:    60px;
    --nav-h:       52px;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin:0; padding:0; }
body {
    font-family: 'Segoe UI', system-ui, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    height: 100dvh;
    overflow: hidden;
}

/* ══════════════════════════════════════════
   HEADER
   ══════════════════════════════════════════ */
header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--header-h);
    padding: 0 1.5rem;
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    position: relative;
    z-index: 1100;
    gap: 1rem;
}
.logo-container { display:flex; align-items:center; gap:.75rem; flex-shrink:0; }
.logo-image { height:36px; object-fit:contain; }
.logo { font-weight:700; font-size:1.05rem; color: var(--blue-dark); white-space:nowrap; }

.search-bar {
    position:relative; flex:1; max-width:380px;
}
.search-bar .search-icon {
    position:absolute; left:12px; top:50%; transform:translateY(-50%);
    color: var(--text-light); pointer-events:none;
}
.search-bar input {
    width:100%; padding:.55rem 1rem .55rem 2.2rem;
    border: 1.5px solid var(--border); border-radius:999px;
    background: var(--bg); color: var(--text);
    font-size:.9rem; transition:.2s;
}
.search-bar input:focus { outline:none; border-color: var(--blue-mid); background:#fff; }

.user-info { display:flex; align-items:center; gap:.75rem; flex-shrink:0; }
#userName { font-size:.85rem; color: var(--text-mid); }
.logout-button {
    display:flex; align-items:center; gap:.4rem;
    padding:.4rem .9rem; border:none; border-radius:999px;
    background: var(--blue-light); color: var(--blue-mid);
    font-size:.82rem; font-weight:600; cursor:pointer; transition:.2s;
}
.logout-button:hover { background: var(--blue-mid); color:#fff; }

/* ══════════════════════════════════════════
   LAYOUT PRINCIPAL
   ══════════════════════════════════════════ */
.app-container {
    display: flex;
    height: calc(100dvh - var(--header-h) - 50px);
    overflow: hidden;
    align-items: stretch;
}

/* ── Panel Pedidos (2/3) ── */
.panel-pedidos {
    flex: 2;
    min-width: 0;
    position: relative;          /* contenedor de posicionamiento */
    background: var(--surface);
    border-right: 1.5px solid var(--border);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* ── Panel Mapa (1/3) ── */
.panel-mapa {
    flex: 1;
    min-width: 240px;
    max-width: 420px;
    display: flex;
    flex-direction: column;
    background: var(--blue-dark);
    overflow: hidden;
}
.mapa-header {
    padding:.6rem 1rem;
    font-size:.8rem; font-weight:700; letter-spacing:.08em; text-transform:uppercase;
    color:rgba(255,255,255,.7);
    display:flex; align-items:center; gap:.5rem;
    border-bottom:1px solid rgba(255,255,255,.1);
    flex-shrink:0;
}
#map { flex:1; }

/* ── Panel header (filtros) ── */
.panel-header {
    display: flex;
    flex-direction: column;
    padding: .5rem .85rem .4rem;
    border-bottom: 1.5px solid var(--border);
    background: var(--surface);
    gap: .35rem;
    flex-shrink: 0;              /* NUNCA encoge, nunca roba espacio a la lista */
    z-index: 10;
}

/* Fila 1: wrapper que agrupa tabs + botón nuevo en una sola línea */
.panel-header-top {
    display: flex;
    align-items: center;
    gap: .4rem;
    overflow: hidden;   /* contiene el scroll de los tabs */
}
.panel-header-top .filter-tabs {
    flex: 1;
    min-width: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    flex-wrap: nowrap;
}
.panel-header-top .filter-tabs::-webkit-scrollbar { display: none; }

.panel-header-actions {
    flex-shrink: 0;
}

/* Fila 2: filtros fecha — scroll horizontal */
.filter-tabs-fecha {
    display: flex;
    gap: 5px;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 2px;
}
.filter-tabs-fecha::-webkit-scrollbar { display: none; }

.filter-tabs { display:flex; gap:.4rem; flex-wrap:nowrap; overflow-x:auto; -webkit-overflow-scrolling:touch; scrollbar-width:none; }
.filter-tabs::-webkit-scrollbar { display:none; }
.filter-tab {
    display:flex; align-items:center; gap:.35rem;
    padding:.35rem .85rem; border:1.5px solid var(--border); border-radius:999px;
    background: transparent; color: var(--text-mid);
    font-size:.8rem; font-weight:600; cursor:pointer; transition:.18s;
    white-space:nowrap;
}
.filter-tab:hover { border-color: var(--blue-mid); color: var(--blue-mid); }
.filter-tab.active { background: var(--blue-dark); border-color: var(--blue-dark); color:#fff; }

.panel-header-actions { flex-shrink:0; }
.btn-nuevo-pedido {
    display:flex; align-items:center; gap:.5rem;
    padding:.45rem 1.1rem; border:none; border-radius:999px;
    background: linear-gradient(135deg, var(--green), #059669);
    color:#fff; font-size:.88rem; font-weight:700; cursor:pointer;
    box-shadow: 0 3px 10px rgba(16,185,129,.35); transition:.2s;
}
.btn-nuevo-pedido:hover { transform:translateY(-1px); box-shadow:0 6px 18px rgba(16,185,129,.45); }
.btn-nuevo-pedido:active { transform:translateY(0); }

/* ── Lista pedidos ── */
.pedidos-list {
    flex: 1 1 0;                 /* ocupa TODO el espacio restante */
    min-height: 0;               /* sin esto flex no activa el scroll */
    overflow-y: scroll;          /* scroll SIEMPRE visible — fuerza el canal */
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
    padding: .75rem 1rem;
    display: flex;
    flex-direction: column;
    gap: .65rem;
}
.pedidos-list::-webkit-scrollbar { width:5px; }
.pedidos-list::-webkit-scrollbar-thumb { background: var(--border); border-radius:3px; }

/* ── Empty state ── */
.empty-state {
    display:flex; flex-direction:column; align-items:center; justify-content:center;
    gap:.75rem; padding:4rem 2rem; color: var(--text-light); text-align:center;
}
.empty-state i { font-size:3rem; opacity:.3; }
.empty-state p { font-size:1rem; font-weight:600; }
.empty-state small { font-size:.82rem; }

/* ══════════════════════════════════════════
   TARJETA DE PEDIDO
   ══════════════════════════════════════════ */
.pedido-card {
    flex-shrink: 0;          /* ← AÑADIR ESTA LÍNEA */
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    padding: .85rem 1rem;
    cursor: pointer;
    transition: all .18s;
    position: relative;
    overflow: hidden;
}
.pedido-card:hover { border-color: var(--blue-mid); box-shadow: var(--shadow-sm); transform:translateY(-1px); }
.pedido-card::before {
    content:''; position:absolute; left:0; top:0; bottom:0; width:4px;
    background: var(--blue-mid); border-radius: var(--radius) 0 0 var(--radius);
}
.pedido-card.estado-pendiente::before { background: var(--amber); }
.pedido-card.estado-parcial::before  { background: var(--blue-mid); }
.pedido-card.estado-completado::before { background: var(--green); }
.pedido-card.estado-delsol::before   { background: #8b5cf6; }

.card-row-top {
    display:flex; align-items:flex-start; justify-content:space-between; gap:.5rem;
    margin-bottom:.4rem;
}
.card-proveedor {
    font-weight:700; font-size:.95rem; color: var(--blue-dark);
    line-height:1.3;
}
.card-badges { display:flex; gap:.35rem; flex-wrap:wrap; align-items:center; flex-shrink:0; }
.badge {
    display:inline-flex; align-items:center; gap:.25rem;
    padding:.2rem .55rem; border-radius:999px; font-size:.72rem; font-weight:700;
}
.badge-pendiente { background: var(--amber-light); color: #92400e; }
.badge-parcial   { background: var(--blue-light);  color: var(--blue-mid); }
.badge-completado{ background: var(--green-light); color: #065f46; }
.badge-delsol    { background: #ede9fe; color: #5b21b6; }
.badge-local     { background: #fef3c7; color: #92400e; }
.badge-entrada   { background: var(--green-light); color: #065f46; }

.card-lineas-preview {
    font-size:.8rem; color: var(--text-mid);
    margin-bottom:.4rem; line-height:1.5;
}
.card-linea-item { display:flex; gap:.5rem; }
.card-linea-item strong { color: var(--text); }

.card-row-bottom {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: .5rem;
    margin-top: .5rem;
}
.card-meta {
    display: flex;
    gap: .6rem;
    align-items: center;
    flex-wrap: wrap;
    font-size: .75rem;
    color: var(--text-light);
}
.card-meta i { color: var(--blue-mid); }

/* Botonera: fila que ocupa todo el ancho en móvil */
.card-actions {
    display: flex;
    gap: .45rem;
    flex-wrap: wrap;
}

/* BASE botón — tamaño cómodo con texto */
.btn-card {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .45rem .9rem;
    border: none;
    border-radius: 8px;
    font-size: .8rem;
    font-weight: 700;
    cursor: pointer;
    transition: all .18s;
    white-space: nowrap;
}
.btn-card i { font-size: .85rem; }

/* Colores individuales */
.btn-card-completar {
    background: var(--green);
    color: #fff;
    box-shadow: 0 2px 8px rgba(16,185,129,.3);
}
.btn-card-completar:hover { background: #059669; transform: translateY(-1px); }

.btn-card-detalle {
    background: var(--blue-light);
    color: var(--blue-mid);
    border: 1.5px solid #bfdbfe;
}
.btn-card-detalle:hover { background: var(--blue-mid); color: #fff; }

.btn-card-eliminar {
    background: var(--red-light);
    color: var(--red);
    border: 1.5px solid #fecaca;
}
.btn-card-eliminar:hover { background: var(--red); color: #fff; }

.btn-card-subir {
    background: #ede9fe;
    color: #5b21b6;
    border: 1.5px solid #ddd6fe;
}
.btn-card-subir:hover { background: #5b21b6; color: #fff; }

/* ══════════════════════════════════════════
   MARCADORES MAPA
   Estilos inline en el divIcon para evitar
   bugs de Leaflet al hacer zoom/pan
   ══════════════════════════════════════════ */

/* Contenedor que Leaflet crea para el divIcon */
.ge-marker-wrapper {
    background: transparent !important;
    border: none !important;
}

/* Keyframe para la animación pulse referenciada inline */
@keyframes gePulse {
    0%   { transform: translate(-50%, -50%) scale(0); opacity: 0.8; }
    100% { transform: translate(-50%, -50%) scale(1.6); opacity: 0; }
}

/* ══════════════════════════════════════════
   MODALES
   ══════════════════════════════════════════ */
.modal-overlay {
    position:fixed; inset:0; z-index:2000;
    background:rgba(15,23,42,.55); backdrop-filter:blur(3px);
    display:flex; align-items:center; justify-content:center;
    padding:1rem;
    animation: fadeOverlay .15s ease;
}
@keyframes fadeOverlay { from { opacity:0; } to { opacity:1; } }

.modal-card {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 760px;
    max-height: 92vh;
    display: flex;
    flex-direction: column;
    animation: slideUp .2s ease;
    overflow: hidden;
    /* iOS Safari fix: allow children to scroll */
    -webkit-overflow-scrolling: auto;
}
@keyframes slideUp {
    from { transform:translateY(16px); opacity:0; }
    to   { transform:translateY(0);    opacity:1; }
}

/* Tipo selector */
.modal-tipo { max-width:480px; padding:2rem; gap:1.5rem; }
.modal-tipo h2 { font-size:1.2rem; color: var(--blue-dark); display:flex; align-items:center; gap:.5rem; }
.tipo-cards { display:flex; gap:1rem; }
.tipo-card {
    flex:1; display:flex; flex-direction:column; align-items:center;
    gap:.65rem; padding:1.5rem 1rem;
    border:2px solid var(--border); border-radius: var(--radius);
    cursor:pointer; transition:.18s; text-align:center;
}
.tipo-card:hover { border-color: var(--blue-mid); box-shadow: var(--shadow-md); transform:translateY(-3px); }
.tipo-card i { font-size:2rem; }
.tipo-card strong { font-size:.95rem; color: var(--text); }
.tipo-card span { font-size:.78rem; color: var(--text-light); line-height:1.4; }
.tipo-pedido i  { color: var(--blue-mid); }
.tipo-entrada i { color: var(--green); }
.tipo-pedido:hover  { border-color: var(--blue-mid); background: var(--blue-light); }
.tipo-entrada:hover { border-color: var(--green);    background: var(--green-light); }

/* Form modal */
.modal-form-header {
    display:flex; align-items:center; justify-content:space-between;
    padding:1.1rem 1.5rem;
    border-bottom:1.5px solid var(--border);
    flex-shrink:0;
}
.modal-form-header h2 { font-size:1.1rem; color: var(--blue-dark); display:flex; align-items:center; gap:.5rem; }

.modal-form-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
    padding: 1.25rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}
.modal-form-body::-webkit-scrollbar { width:5px; }
.modal-form-body::-webkit-scrollbar-thumb { background:var(--border); border-radius:3px; }

.modal-form-footer {
    display:flex; align-items:center; justify-content:flex-end; gap:.75rem;
    padding:1rem 1.5rem;
    border-top:1.5px solid var(--border);
    flex-shrink:0;
    flex-wrap:wrap;
}

.modal-close {
    background:none; border:none; cursor:pointer;
    width:32px; height:32px; border-radius:50%;
    display:flex; align-items:center; justify-content:center;
    color: var(--text-light); font-size:1rem; transition:.18s;
}
.modal-close:hover { background: var(--red-light); color: var(--red); }

/* ── Formulario ── */
.form-section { display:flex; flex-direction:column; gap:.6rem; }
.form-row { display:flex; gap:.85rem; }
.form-row .form-group { flex:1; min-width:0; }
.form-group { display:flex; flex-direction:column; gap:.35rem; }
.form-label {
    font-size:.8rem; font-weight:700; color: var(--text-mid);
    display:flex; align-items:center; gap:.35rem; text-transform:uppercase; letter-spacing:.04em;
}
.form-label i { color: var(--blue-mid); }

input[type=text], input[type=date], input[type=number], select, textarea {
    width:100%; padding:.55rem .85rem;
    border:1.5px solid var(--border); border-radius: var(--radius-sm);
    background: var(--surface); color: var(--text); font-size:.9rem;
    transition:.18s; font-family:inherit;
}
input:focus, select:focus, textarea:focus {
    outline:none; border-color: var(--blue-mid);
    box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
textarea { resize:vertical; min-height:64px; }

/* Autocomplete */
.autocomplete-wrap { position:relative; }
.sugg-list {
    position:absolute; top:calc(100% + 4px); left:0; right:0;
    background: var(--surface); border:1.5px solid var(--border);
    border-radius: var(--radius-sm); box-shadow: var(--shadow-md);
    z-index:3000; max-height:220px; overflow-y:auto;
}
.sugg-item {
    padding:.6rem .85rem; cursor:pointer; font-size:.88rem;
    border-bottom:1px solid var(--border); transition:.12s;
    display:flex; flex-direction:column; gap:.1rem;
}
.sugg-item:last-child { border-bottom:none; }
.sugg-item:hover { background: var(--blue-light); }
.sugg-item strong { color: var(--text); }
.sugg-item small  { color: var(--text-light); }

/* Mini mapa */
.mini-map {
    height:180px; border-radius: var(--radius-sm);
    border:1.5px solid var(--border); overflow:hidden;
    cursor:crosshair;
}

/* Líneas artículos */
.lineas-header {
    display:flex; align-items:center; justify-content:space-between;
    flex-wrap:wrap; gap:.5rem;
}
.btn-add-line {
    display:inline-flex; align-items:center; gap:.3rem;
    padding:.35rem .85rem; border:1.5px dashed var(--blue-mid);
    border-radius:999px; background:transparent; color: var(--blue-mid);
    font-size:.8rem; font-weight:700; cursor:pointer; transition:.18s;
}
.btn-add-line:hover { background: var(--blue-light); }

.lineas-container { display:flex; flex-direction:column; gap:.6rem; }
.linea-row {
    display:grid; gap:.5rem; align-items:start;
    grid-template-columns: 2fr 1fr 1fr 1fr 28px;
    background: var(--bg); border-radius: var(--radius-sm);
    padding:.6rem .75rem; border:1px solid var(--border);
}
.linea-row input, .linea-row select { background:#fff; }
.linea-desc-wrap { position:relative; grid-column:1; }
.linea-sugg {
    position:absolute; top:calc(100% + 2px); left:0; right:0;
    background: var(--surface); border:1.5px solid var(--border);
    border-radius: var(--radius-sm); box-shadow: var(--shadow-md);
    z-index:3100; max-height:180px; overflow-y:auto;
}
.linea-sugg .sugg-item { font-size:.82rem; }
.btn-del-linea {
    width:28px; height:28px; border:none; border-radius:6px;
    background: var(--red-light); color: var(--red);
    cursor:pointer; display:flex; align-items:center; justify-content:center;
    font-size:.8rem; align-self:center; transition:.18s; flex-shrink:0;
}
.btn-del-linea:hover { background: var(--red); color:#fff; }

/* Comp lineas (completar) */
.comp-lineas .linea-row { grid-template-columns: 3fr 1fr 1fr; }

/* Foto upload */
.foto-upload-area {
    border:2px dashed var(--border); border-radius: var(--radius-sm);
    padding:1rem; display:flex; align-items:center; justify-content:center; gap:.75rem;
    cursor:pointer; transition:.18s; color: var(--text-light);
    font-size:.88rem;
}
.foto-upload-area:hover { border-color: var(--blue-mid); color: var(--blue-mid); background: var(--blue-light); }
.foto-upload-area i { font-size:1.4rem; }
.foto-preview {
    max-height:160px; border-radius: var(--radius-sm);
    border:1.5px solid var(--border); object-fit:contain; margin-top:.5rem;
}

/* Totales */
.totales-row {
    display:flex; gap:1.5rem; flex-wrap:wrap;
    padding:.75rem 1rem; background: var(--bg);
    border-radius: var(--radius-sm); border:1px solid var(--border);
    font-size:.85rem; color: var(--text-mid);
}
.totales-row strong { color: var(--text); }

/* Completar info */
.completar-info {
    background: var(--blue-light); border-radius: var(--radius-sm);
    padding:.85rem 1rem; font-size:.88rem; color: var(--blue-dark);
    border-left:4px solid var(--blue-mid);
}

/* Detalle */
.modal-detalle { max-width:600px; }
.detalle-section { margin-bottom:1rem; }
.detalle-linea {
    display:flex; justify-content:space-between; align-items:center;
    padding:.45rem 0; border-bottom:1px solid var(--border);
    font-size:.88rem;
}
.detalle-linea:last-child { border-bottom:none; }
.detalle-campo { display:flex; gap:.5rem; align-items:center; font-size:.85rem; color: var(--text-mid); }
.detalle-campo strong { color: var(--text); }
.detalle-foto {
    max-width:100%; border-radius: var(--radius-sm);
    border:1.5px solid var(--border); margin-top:.5rem;
}

/* Botones */
.btn-cancel {
    padding:.5rem 1.2rem; border:1.5px solid var(--border);
    border-radius:999px; background:transparent; color: var(--text-mid);
    font-size:.88rem; font-weight:600; cursor:pointer; transition:.18s;
}
.btn-cancel:hover { border-color: var(--red); color: var(--red); }
.btn-guardar-local {
    padding:.5rem 1.2rem; border:none; border-radius:999px;
    background: var(--amber-light); color: #92400e;
    font-size:.88rem; font-weight:700; cursor:pointer; transition:.18s;
}
.btn-guardar-local:hover { background: var(--amber); color:#fff; }
.btn-subir-delsol {
    padding:.5rem 1.25rem; border:none; border-radius:999px;
    background: linear-gradient(135deg, var(--blue-dark), var(--blue-mid));
    color:#fff; font-size:.88rem; font-weight:700; cursor:pointer;
    box-shadow:0 3px 10px rgba(37,99,235,.3); transition:.2s;
    display:flex; align-items:center; gap:.4rem;
}
.btn-subir-delsol:hover { transform:translateY(-1px); box-shadow:0 6px 18px rgba(37,99,235,.4); }
.btn-subir-delsol.btn-entrada {
    background: linear-gradient(135deg, #065f46, var(--green));
    box-shadow:0 3px 10px rgba(16,185,129,.3);
}
.btn-subir-delsol.btn-entrada:hover { box-shadow:0 6px 18px rgba(16,185,129,.4); }

/* ══════════════════════════════════════════
   TOAST
   ══════════════════════════════════════════ */
.toast {
    position:fixed; bottom: 62px; left:50%;
    transform:translateX(-50%);
    background: var(--blue-dark); color:#fff;
    padding:.7rem 1.5rem; border-radius:999px;
    font-size:.88rem; font-weight:600;
    box-shadow: var(--shadow-lg); z-index:9999;
    animation: toastIn .25s ease;
    display:flex; align-items:center; gap:.5rem;
    max-width:90vw; text-align:center;
}
.toast.toast-success { background: #065f46; }
.toast.toast-error   { background: #991b1b; }
.toast.toast-warn    { background: #92400e; }
@keyframes toastIn { from { opacity:0; bottom: 50px; } to { opacity:1; } }

/* ══════════════════════════════════════════
   NAVEGACIÓN — igual que gestionrutas
   ══════════════════════════════════════════ */
.navigation-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 50px;
    background: white;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 40px;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    z-index: 1100;
    padding: 5px 0;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
}
.nav-item {
    color: #4b5563;
    text-decoration: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    font-size: 0.9em;
    transition: color 0.3s ease;
}
.nav-item:hover,
.nav-item.active {
    color: #3b82f6;
}
.nav-item i {
    font-size: 1.5em;
}
@media (max-width: 768px) {
    .navigation-bar {
        flex-shrink: 0;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: 50px;
        background: white;
        z-index: 1100;
        display: flex;
        justify-content: space-around;
        align-items: center;
        padding: 0;
        gap: 0;
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    }
}

/* ══════════════════════════════════════════
   RESPONSIVE MÓVIL
   ══════════════════════════════════════════ */
@media (max-width: 768px) {

    /* Layout: panel pedidos ocupa TODO — mapa oculto */
    .app-container {
        flex-direction: column;
        height: calc(100dvh - var(--header-h) - 50px);
        overflow: hidden;
    }
    .panel-pedidos {
        flex: 1;
        min-height: 0;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }
    .panel-mapa {
        display: none !important;
    }

    /* Header compacto */
    .logo { display: none; }
    .logo-image { height: 28px; }
    header { padding: 0 .6rem; gap: .5rem; }
    .search-bar { max-width: none; }
    .logout-button span { display: none; }

    /* Filtros en scroll horizontal */
    .filter-tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 2px;
        gap: .3rem;
    }
    .filter-tabs::-webkit-scrollbar { display: none; }

    /* Botón Nuevo más pequeño */
    .btn-nuevo-pedido span { display: none; }
    .btn-nuevo-pedido { padding: .45rem .75rem; border-radius: 8px; }

    /* Tarjeta: botonera en fila completa debajo de meta */
    .card-row-bottom { flex-direction: column; align-items: flex-start; }
    .card-actions {
        width: 100%;
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
        gap: .4rem;
    }
    .btn-card {
        justify-content: center;
        padding: .55rem .5rem;
        font-size: .78rem;
        border-radius: 8px;
    }

    /* Pedidos list padding */
    .pedidos-list { padding: .5rem .6rem; }

    /* Modales a pantalla completa */
    .modal-card {
        max-width: 100%;
        max-height: 95vh;
        border-radius: 16px 16px 0 0;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        margin: 0;
    }
    .modal-overlay { align-items: flex-end; padding: 0; }

    /* Formulario responsive */
    .form-row { flex-direction: column; }
    .tipo-cards { flex-direction: column; }
    .modal-form-footer {
        flex-direction: column;
        gap: .5rem;
    }
    .modal-form-footer button {
        width: 100%;
        justify-content: center;
    }

    /* Líneas de artículo en móvil */
    .linea-row-rich {
        grid-template-columns: 1fr 1fr;
        gap: .35rem;
    }
    .linea-col-art  { grid-column: 1 / -1; }
    .linea-col-tipo { grid-column: 1; }
    .linea-col-can  { grid-column: 2; }
    .linea-col-kg   { grid-column: 1; }
    .linea-col-pre  { grid-column: 2; }
    .linea-col-tot  { grid-column: 1; }
    .linea-row-rich > button.btn-del-linea { grid-column: 2; justify-self: end; align-self: end; }

    /* Mini mapa en formulario también oculto */
    .mini-map { height: 140px; }
}

@media (max-width: 480px) {
    .filter-tab { padding: .3rem .55rem; }
    header { padding: 0 .5rem; }
    .card-proveedor { font-size: .88rem; }
    .card-actions { grid-template-columns: repeat(3, 1fr); }
}

/* ══════════════════════════════════════════
   LOADING SPINNER
   ══════════════════════════════════════════ */
.spinner {
    width:18px; height:18px;
    border:2.5px solid rgba(255,255,255,.4);
    border-top-color:#fff;
    border-radius:50%; animation:spin .6s linear infinite; display:inline-block;
}
@keyframes spin { to { transform:rotate(360deg); } }

/* Progress on cards */
.progress-bar {
    height:4px; background: var(--border); border-radius:2px; overflow:hidden; margin-top:.5rem;
}
.progress-fill {
    height:100%; border-radius:2px; transition:.4s;
    background: linear-gradient(90deg, var(--green), #34d399);
}

/* Indicador delsol en card */
.delsol-badge {
    display:inline-flex; align-items:center; gap:.25rem;
    font-size:.7rem; padding:.18rem .5rem; border-radius:999px;
    background:#ede9fe; color:#5b21b6; font-weight:700;
}

/* Botón editar en tarjeta */
.btn-card-editar {
    background: #fef3c7;
    color: #92400e;
    border: 1.5px solid #fde68a;
}
.btn-card-editar:hover { background: #f59e0b; color: #fff; }

/* ══════════════════════════════════════════
   LÍNEA ARTÍCULO RICA (con tipo/kg/total)
   ══════════════════════════════════════════ */
.linea-row-rich {
    display: grid;
    grid-template-columns: 2.5fr 1fr 0.8fr 0.8fr 0.8fr 0.7fr 28px;
    gap: .4rem;
    align-items: start;
    background: var(--bg);
    border-radius: var(--radius-sm);
    padding: .55rem .7rem;
    border: 1px solid var(--border);
}
.linea-row-rich > div {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.linea-row-rich input, .linea-row-rich select {
    background: #fff;
}
.linea-tipo {
    font-size: .78rem;
    padding: .4rem .5rem;
}
.linea-ud-label {
    font-size: .7rem;
    color: var(--text-light);
}
@media (max-width: 768px) {
    .linea-row-rich {
        grid-template-columns: 1fr 1fr;
        gap: .35rem;
    }
    .linea-col-art  { grid-column: 1 / -1; }
    .linea-col-tipo { grid-column: 1; }
    .linea-col-can  { grid-column: 2; }
    .linea-col-kg   { grid-column: 1; }
    .linea-col-pre  { grid-column: 2; }
    .linea-col-tot  { grid-column: 1; }
    .linea-row-rich > button { grid-column: 2; justify-self: end; }
}

/* Botón PDF en tarjeta */
.btn-card-pdf {
    background: #fce7f3;
    color: #9d174d;
    border: 1.5px solid #fbcfe8;
}
.btn-card-pdf:hover { background: #be185d; color: #fff; }

/* ══════════════════════════════════════════
   GRID MÚLTIPLES FOTOS
   ══════════════════════════════════════════ */
.fotos-grid {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    margin-top: .5rem;
    min-height: 0;
}
.foto-thumb-wrap {
    position: relative;
    width: 80px;
    height: 80px;
    border-radius: 8px;
    overflow: hidden;
    border: 1.5px solid var(--border);
    flex-shrink: 0;
}
.foto-thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.foto-thumb-del {
    position: absolute;
    top: 3px;
    right: 3px;
    width: 20px;
    height: 20px;
    background: rgba(239,68,68,.9);
    color: #fff;
    border: none;
    border-radius: 50%;
    font-size: .65rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}
.foto-thumb-del:hover { background: var(--red); }

/* ══════════════════════════════════════════
   LÍNEAS DE ARTÍCULOS — estilo gestionrutas
   ══════════════════════════════════════════ */
.ge-articulo-item {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 10px 12px;
    margin-bottom: 8px;
    transition: box-shadow .2s, background .2s;
}
.ge-articulo-item:hover {
    background: #f1f5f9;
    box-shadow: 0 2px 8px rgba(0,0,0,.07);
}

.ge-articulo-details {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
    gap: 10px;
    margin-top: 2px;
}

.ge-campo-grupo {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 7px 9px;
}

.ge-campo-label {
    font-size: .75rem;
    color: #64748b;
    display: block;
    margin-bottom: 4px;
    font-weight: 500;
}

.ge-campo-input {
    width: 100%;
    padding: 5px 7px;
    border: 1px solid #e2e8f0;
    border-radius: 5px;
    font-size: .88rem;
    box-sizing: border-box;
    transition: border-color .2s, box-shadow .2s;
}
.ge-campo-input:focus {
    border-color: var(--blue-mid);
    box-shadow: 0 0 0 2px rgba(37,99,235,.1);
    outline: none;
}

.ge-campo-unit {
    font-size: .72rem;
    color: var(--text-light);
    display: block;
    margin-top: 3px;
}

@media (max-width: 540px) {
    .ge-articulo-details {
        grid-template-columns: 1fr 1fr;
    }
}

/* ══════════════════════════════════════════
   ARTÍCULOS — estilo gestionrutas (búsqueda → añadir → tarjeta)
   ══════════════════════════════════════════ */
.ge-art-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.ge-art-search-wrap {
    position: relative;
}
.ge-art-search-wrap input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 14px;
    box-sizing: border-box;
    transition: border-color .2s, box-shadow .2s;
}
.ge-art-search-wrap input:focus {
    border-color: var(--blue-mid, #2563eb);
    box-shadow: 0 0 0 3px rgba(37,99,235,.1);
    outline: none;
}
.ge-art-results {
    position: absolute;
    top: 100%;
    left: 0; right: 0;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-top: none;
    border-radius: 0 0 8px 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,.12);
    max-height: 260px;
    overflow-y: auto;
    z-index: 500;
}
.ge-art-result-item {
    padding: 9px 12px;
    cursor: pointer;
    border-bottom: 1px solid #f1f5f9;
    transition: background .15s;
}
.ge-art-result-item:hover { background: #f0f9ff; }
.ge-art-result-item:last-child { border-bottom: none; }

.ge-tipo-container {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}
.ge-tipo-container select {
    flex: 1;
    min-width: 160px;
    padding: 9px 10px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 14px;
    background: #fff;
}
.ge-cantidad-wrap {
    display: flex;
    align-items: center;
    gap: 6px;
}
.ge-cantidad-wrap input {
    width: 100px;
    padding: 9px 10px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 14px;
}
.ge-unidad {
    font-size: .8rem;
    color: #6b7280;
    white-space: nowrap;
}
.ge-add-btn {
    padding: 9px 20px;
    background: var(--blue-mid, #2563eb);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background .2s, opacity .2s;
    align-self: flex-start;
}
.ge-add-btn:hover:not(:disabled) { background: #1d4ed8; }
.ge-add-btn:disabled { opacity: .45; cursor: not-allowed; background: #94a3b8; }

.ge-art-card .articulo-details {
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
}

/* ══════════════════════════════════════════
   CARD — FECHA Y PRECIO GRANDES (estilo PDA)
   ══════════════════════════════════════════ */
.card-highlight-row {
    display: flex;
    gap: 8px;
    margin: 8px 0;
    flex-wrap: wrap;
}
.card-fecha-big,
.card-precio-big,
.card-total-big {
    display: flex;
    align-items: center;
    gap: 8px;
    border-radius: 10px;
    padding: 8px 14px;
    flex: 1;
    min-width: 120px;
}
.card-fecha-big {
    background: #f1f5f9;
    color: #374151;
}
.card-fecha-big i { font-size: 1.3rem; flex-shrink: 0; }
.card-fecha-label {
    font-size: .7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    opacity: .85;
}
.card-fecha-val {
    font-size: 1.25rem;
    font-weight: 800;
    line-height: 1.1;
    letter-spacing: -.01em;
}
.card-precio-big {
    background: #eff6ff;
    color: #1e40af;
}
.card-precio-big i { font-size: 1.1rem; flex-shrink: 0; }
.card-total-big {
    background: #f0fdf4;
    color: #15803d;
}
.card-total-big i { font-size: 1.1rem; flex-shrink: 0; }
.card-precio-label {
    font-size: .7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    opacity: .8;
}
.card-precio-val {
    font-size: 1.1rem;
    font-weight: 800;
    line-height: 1.1;
}

/* ══════════════════════════════════════════
   FILTROS DE FECHA ENTREGA
   ══════════════════════════════════════════ */
.filter-tabs-fecha {
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
    padding: 0 4px 4px;
}
.filter-tab-fecha {
    padding: 5px 12px;
    border-radius: 20px;
    border: 1.5px solid #e2e8f0;
    background: #fff;
    color: #374151;
    font-size: .78rem;
    font-weight: 600;
    cursor: pointer;
    transition: all .15s;
    display: flex;
    align-items: center;
    gap: 5px;
    white-space: nowrap;
}
.filter-tab-fecha:hover {
    border-color: #3b82f6;
    color: #1d4ed8;
    background: #eff6ff;
}
.filter-tab-fecha.active {
    background: #1e3a5f;
    color: #fff;
    border-color: #1e3a5f;
}
.filter-tab-fecha[data-fecha="hoy"].active     { background: #f59e0b; border-color: #f59e0b; }
.filter-tab-fecha[data-fecha="manana"].active  { background: #3b82f6; border-color: #3b82f6; }
.filter-tab-fecha[data-fecha="semana"].active  { background: #8b5cf6; border-color: #8b5cf6; }
.filter-tab-fecha[data-fecha="vencidos"].active{ background: #ef4444; border-color: #ef4444; }


/* ── Botones táctiles grandes — siempre, en cualquier pantalla ── */
.card-actions .btn-card {
    min-height: 44px;
    padding: .55rem 1.1rem;
    font-size: .88rem;
    font-weight: 600;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    border: none;
    transition: opacity .15s, transform .1s;
}
.card-actions .btn-card:active {
    transform: scale(.97);
    opacity: .85;
}
.btn-card-completar {
    background: linear-gradient(135deg, #1e3a5f, #2563eb);
    color: #fff;
    font-size: .9rem !important;
    padding: .65rem 1.3rem !important;
}
.btn-card-subir { background: #eff6ff; color: #1e40af; border: 1.5px solid #bfdbfe !important; }
.btn-card-detalle { background: #f1f5f9; color: #374151; border: 1px solid #e2e8f0 !important; }
.btn-card-editar { background: #fefce8; color: #92400e; border: 1px solid #fde68a !important; }
.btn-card-pdf { background: #fff7ed; color: #9a3412; border: 1px solid #fed7aa !important; }
.btn-card-eliminar { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca !important; }

/* ══════════════════════════════════════════
   TABLET / iPad — portrait & landscape
   ══════════════════════════════════════════ */
@media (max-width: 1366px) {

    /* Ocultar mapa en tablet para dar todo el espacio a la lista */
    .panel-mapa { display: none !important; }

    /* Panel pedidos ocupa todo */
    .panel-pedidos {
        flex: 1;
        min-height: 0;
        border-right: none;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }

    /* Botones de acción más grandes para dedo */
    .card-actions .btn-card {
        min-height: 44px;
        padding: .6rem 1.1rem;
        font-size: .88rem;
    }
}

/* ── iPad landscape — mostrar mapa pequeño ── */
@media (min-width: 1024px) and (orientation: landscape) {
    .panel-mapa { display: flex !important; flex: 0 0 300px; max-width: 300px; }
}

/* ── Modal en tablet — scroll interno ── */
@media (max-width: 1366px) {
    .modal-overlay { align-items: flex-start; padding-top: 8px; }
    .modal-card.modal-form {
        max-height: 96dvh;
        width: 96vw;
        max-width: 700px;
        margin: 0 auto;
    }
    .modal-form-body {
        -webkit-overflow-scrolling: touch;
    }
    .modal-form-footer {
        position: sticky;
        bottom: 0;
        background: #fff;
        z-index: 10;
        box-shadow: 0 -2px 8px rgba(0,0,0,.08);
    }
    .btn-guardar-local, .btn-subir-delsol, .btn-cancel {
        padding: 14px 20px;
        font-size: 1rem;
        min-height: 48px;
    }
}

/* ── Botones táctiles — siempre grandes ── */