:root { --primary: #0f172a; --accent: #2563eb; --success: #10b981; --danger: #ef4444; --warning: #d97706; --surface: #ffffff; --background: #f1f5f9; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; font-family: 'Inter', sans-serif; }
body, html { margin: 0; padding: 0; height: 100%; overflow: hidden; background-color: var(--background); }

#map { position: absolute; top: 0; bottom: 0; width: 100%; height: 100%; z-index: 1; }

/* Controles Superiores Transici¨®n Opacidad */
.app-header { position: absolute; top: 0; left: 0; right: 0; z-index: 1000; padding: 16px 16px 0 16px; pointer-events: none; transition: opacity 0.4s cubic-bezier(0.2, 0.8, 0.2, 1); }
.card-panel { background: rgba(255, 255, 255, 0.95); backdrop-filter: blur(10px); border-radius: 20px; padding: 16px; box-shadow: 0 10px 40px rgba(0,0,0,0.15); pointer-events: auto; display: flex; flex-direction: column; gap: 12px; }
.input-group { display: flex; gap: 12px; }
select { flex: 1; padding: 14px 16px; border: 1px solid #e2e8f0; border-radius: 12px; font-size: 14px; font-weight: 600; color: var(--primary); background-color: #f8fafc; outline: none; appearance: none; background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%2364748B' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 16px center; transition: all 0.2s ease; }
select:focus { border-color: var(--accent); background-color: var(--surface); box-shadow: 0 0 0 4px rgba(37,99,235,0.1); }
.date-input { width: 100%; padding: 10px 12px; border: 1px solid #e2e8f0; border-radius: 10px; font-size: 13px; font-weight: 600; color: var(--primary); background-color: #f8fafc; outline: none; }
.date-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37,99,235,0.1); }
.date-label { font-size: 10px; font-weight: 800; color: #64748b; margin-left: 4px; margin-bottom: 4px; display: block; letter-spacing: 0.5px; }
.btn-search { background: var(--accent); color: white; border: none; border-radius: 10px; padding: 0 16px; cursor: pointer; margin-top: 18px; box-shadow: 0 4px 10px rgba(37,99,235,0.2); transition: transform 0.2s; display: flex; align-items: center; justify-content: center; }
.btn-search:active { transform: scale(0.95); }

/* M¨¦tricas - ACTUALIZADO A 3 COLUMNAS */
.dashboard-metrics { display: none; background: var(--primary); color: white; border-radius: 14px; padding: 16px; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.metric-item { display: flex; flex-direction: column; gap: 4px; }
.metric-label { font-size: 11px; color: #94a3b8; text-transform: uppercase; letter-spacing: 0.5px; font-weight: 700; }
.metric-value { font-size: 18px; font-weight: 800; }
.metric-sub { font-size: 12px; color: #cbd5e1; }
.btn-lista { display: none; background: #f8fafc; border: 1px solid #e2e8f0; color: var(--primary); font-weight: 700; font-size: 14px; padding: 12px; border-radius: 12px; width: 100%; cursor: pointer; transition: background 0.2s; align-items: center; justify-content: center; gap: 8px; box-shadow: 0 2px 4px rgba(0,0,0,0.02); }
.btn-lista:active { background: #e2e8f0; }

/* Pines y Clusters Premium */
.pin-wrapper { display: flex; align-items: center; justify-content: center; width: 32px !important; height: 32px !important; border-radius: 50%; color: white; font-weight: 800; font-size: 14px; box-shadow: 0 4px 12px rgba(0,0,0,0.3); border: 3px solid white; transition: transform 0.2s; }
.pin-wrapper:active { transform: scale(1.1); }
.bg-success { background-color: var(--success); } .bg-accent { background-color: var(--accent); } .bg-danger { background-color: var(--danger); }
.pin-terminal { background: var(--primary); border-radius: 16px; width: auto !important; padding: 4px 12px; font-size: 11px; font-weight: 800; letter-spacing: 0.5px; border: 3px solid white; box-shadow: 0 6px 14px rgba(0,0,0,0.4); z-index: 1000 !important; display: flex; align-items: center; gap: 4px; }
.marker-cluster-small, .marker-cluster-medium, .marker-cluster-large { background-color: rgba(15, 23, 42, 0.6); }
.marker-cluster-small div, .marker-cluster-medium div, .marker-cluster-large div { background-color: rgba(15, 23, 42, 0.9); color: white; font-weight: 800; font-family: 'Inter', sans-serif; box-shadow: 0 4px 10px rgba(0,0,0,0.3); }

/* FAB Bot¨®n de Mapa Satelital */
.fab-map { position: absolute; bottom: 32px; right: 16px; z-index: 1000; background: var(--surface); width: 48px; height: 48px; border-radius: 24px; display: flex; align-items: center; justify-content: center; box-shadow: 0 4px 14px rgba(0,0,0,0.15); cursor: pointer; transition: transform 0.2s; }
.fab-map:active { transform: scale(0.9); }

/* Loader */
#loader { display: none; justify-content: center; align-items: center; padding: 10px; z-index: 4000; position: fixed; inset:0; background: rgba(255,255,255,0.9); flex-direction: column; gap: 10px; font-weight: bold; color: var(--primary);}
.spinner { width: 32px; height: 32px; border: 4px solid #e2e8f0; border-top: 4px solid var(--accent); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
.leaflet-control-zoom { display: none; } 

/* Bottom Sheet (Detalles) */
.bottom-sheet { position: absolute; bottom: 0; left: 0; right: 0; z-index: 2000; background: var(--surface); padding: 0; border-top-left-radius: 24px; border-top-right-radius: 24px; box-shadow: 0 -10px 40px rgba(0,0,0,0.15); transform: translateY(105%); transition: transform 0.4s cubic-bezier(0.2, 0.8, 0.2, 1); display: flex; flex-direction: column; max-height: 80%; }
.bottom-sheet.active { transform: translateY(0); }
.sheet-drag-area { padding: 16px; display: flex; justify-content: center; align-items: center; cursor: grab; }
.drag-handle { width: 40px; height: 5px; background: #cbd5e1; border-radius: 4px; }
.sheet-content { padding: 0 24px 32px 24px; overflow-y: auto; }
.client-header { margin-bottom: 24px; }
.client-name { font-size: 22px; font-weight: 800; color: var(--primary); line-height: 1.2; margin-bottom: 6px; }
.client-id { font-size: 14px; font-weight: 600; color: #64748b; display: flex; align-items: center; flex-wrap: wrap;}
.info-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 24px; }
.stat-box { background: #f8fafc; border: 1px solid #f1f5f9; padding: 16px; border-radius: 16px; }
.stat-label { font-size: 12px; color: #64748b; font-weight: 600; margin-bottom: 6px; display: block; }
.stat-value { font-size: 16px; font-weight: 700; color: var(--primary); }

/* Caja de Observaciones Sem¨¢ntica */
.obs-box { padding: 16px; border-radius: 16px; margin-bottom: 24px; }
.obs-pedido { background: #f0fdf4; border: 1px solid #bbf7d0; }
.obs-cobranza { background: #eff6ff; border: 1px solid #bfdbfe; }
.obs-visita { background: #fef2f2; border: 1px solid #fecaca; }
.obs-box.empty { background: #f8fafc; border: 1px solid #f1f5f9; }

/* Modal Listado Inmersivo */
.modal-backdrop { position: fixed; inset: 0; background: rgba(15, 23, 42, 0.5); backdrop-filter: blur(4px); z-index: 2500; visibility: hidden; opacity: 0; transition: opacity 0.3s, visibility 0.3s; }
.modal-backdrop.active { visibility: visible; opacity: 1; }
.list-modal { position: absolute; bottom: 0; left: 0; right: 0; height: 85%; background: #f1f5f9; z-index: 3000; border-top-left-radius: 24px; border-top-right-radius: 24px; box-shadow: 0 -10px 40px rgba(0,0,0,0.2); transform: translateY(105%); transition: transform 0.4s cubic-bezier(0.2, 0.8, 0.2, 1); display: flex; flex-direction: column; }
.list-modal.active { transform: translateY(0); }
.list-header { background: var(--surface); padding: 0 20px 16px 20px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid #e2e8f0; }
.list-header h3 { margin: 0; font-size: 18px; color: var(--primary); font-weight: 800; }
.header-actions { display: flex; gap: 8px; align-items: center; }
.btn-action { border: none; padding: 8px 12px; border-radius: 8px; color: white; font-size: 12px; font-weight: bold; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 4px; box-shadow: 0 2px 4px rgba(0,0,0,0.1); transition: transform 0.2s; }
.btn-action:active { transform: scale(0.95); }
.list-content { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.list-item { background: var(--surface); border-radius: 14px; padding: 16px; box-shadow: 0 2px 8px rgba(0,0,0,0.04); cursor: pointer; border-left: 5px solid var(--primary); display: flex; justify-content: space-between; align-items: center; transition: transform 0.1s; }
.list-item:active { transform: scale(0.98); }
.list-item-info { display: flex; flex-direction: column; gap: 4px; flex: 1; margin-right: 12px; }
.list-item-name { font-weight: 700; font-size: 14px; color: var(--primary); line-height: 1.3; }
.list-item-time { font-size: 12px; color: #64748b; font-weight: 600; display: flex; align-items: center; flex-wrap: wrap; gap: 4px;}
.list-item.pedido { border-left-color: var(--success); } .list-item.cobranza { border-left-color: var(--accent); } .list-item.visita { border-left-color: var(--danger); }
.list-item-status { font-size: 11px; font-weight: 800; padding: 6px 10px; border-radius: 8px; text-align: center; min-width: 80px; }
.list-item.pedido .list-item-status { background: #d1fae5; color: #065f46; } .list-item.cobranza .list-item-status { background: #dbeafe; color: #1e40af; } .list-item.visita .list-item-status { background: #fee2e2; color: #991b1b; }

/* Tag Fuera de Ruta */
.tag-warning { display: inline-flex; align-items: center; gap: 4px; padding: 4px 8px; border-radius: 6px; background: #fef3c7; color: var(--warning); font-size: 10px; font-weight: 800; margin-left: 8px; border: 1px solid #fde68a; }

/* Visor de Fotos */
.photo-container { margin-top: 16px; }
.photo-thumbnail { width: 100%; height: 120px; object-fit: cover; border-radius: 16px; cursor: pointer; border: 2px solid #f1f5f9; transition: transform 0.2s; }
.photo-thumbnail:active { transform: scale(0.98); }
.lightbox { display: flex; visibility: hidden; position: fixed; inset: 0; background: rgba(15, 23, 42, 0.95); backdrop-filter: blur(8px); z-index: 5000; justify-content: center; align-items: center; flex-direction: column; opacity: 0; transition: opacity 0.3s, visibility 0.3s; }
.lightbox.active { visibility: visible; opacity: 1; }
.lightbox img { max-width: 90%; max-height: 80%; border-radius: 12px; box-shadow: 0 10px 40px rgba(0,0,0,0.5); object-fit: contain; }
.lightbox-close { position: absolute; top: 24px; right: 24px; background: rgba(255,255,255,0.1); color: white; border: 1px solid rgba(255,255,255,0.2); border-radius: 50%; width: 44px; height: 44px; display: flex; justify-content: center; align-items: center; cursor: pointer; backdrop-filter: blur(5px); }