* { margin:0; padding:0; box-sizing:border-box; }
:root { --bg:#0f172a; --card:#1e293b; --primary:#3b82f6; --success:#22c55e; --danger:#ef4444; --warning:#f59e0b; --text:#e2e8f0; --muted:#64748b; --border:#334155; }
body { font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,sans-serif; background:var(--bg); color:var(--text); min-height:100vh; padding-bottom:80px; }

/* Header */
.topbar { background:var(--card); padding:14px 16px; display:flex; align-items:center; justify-content:space-between; border-bottom:1px solid var(--border); position:sticky; top:0; z-index:100; }
.topbar h1 { font-size:16px; font-weight:700; }
.topbar .status { font-size:12px; display:flex; align-items:center; gap:5px; }
.dot { width:8px; height:8px; border-radius:50%; }
.dot.on { background:var(--success); box-shadow:0 0 6px var(--success); }
.dot.off { background:var(--danger); box-shadow:0 0 6px var(--danger); }

/* Cards */
.container { padding:12px; max-width:500px; margin:0 auto; }
.card { background:var(--card); border-radius:12px; padding:16px; margin-bottom:12px; border:1px solid var(--border); }
.card h3 { font-size:14px; color:var(--primary); margin-bottom:10px; display:flex; align-items:center; gap:6px; }
.card h3 .badge { font-size:11px; background:var(--primary); color:#fff; padding:2px 8px; border-radius:10px; }

/* Info rows */
.row { display:flex; justify-content:space-between; padding:6px 0; border-bottom:1px solid var(--border); font-size:13px; }
.row:last-child { border:none; }
.row .label { color:var(--muted); }
.row .val { font-weight:600; }

/* Buttons */
.btn { display:block; width:100%; padding:12px; border:none; border-radius:10px; font-size:14px; font-weight:600; cursor:pointer; margin-bottom:8px; transition:transform .1s,opacity .1s; }
.btn:active { transform:scale(.97); opacity:.8; }
.btn-primary { background:var(--primary); color:#fff; }
.btn-success { background:var(--success); color:#fff; }
.btn-danger { background:var(--danger); color:#fff; }
.btn-muted { background:var(--border); color:var(--muted); }
.btn-sm { padding:8px 14px; font-size:13px; display:inline-block; width:auto; border-radius:8px; }
.btn-row { display:flex; gap:8px; margin-bottom:8px; }
.btn-row .btn { flex:1; }

/* Reporte card */
.reporte { border-left:4px solid var(--primary); }
.reporte.urgente { border-left-color:var(--danger); }
.reporte.en-ruta { border-left-color:var(--warning); background:rgba(245,158,11,.08); }
.reporte.llegado { border-left-color:var(--success); background:rgba(34,197,94,.08); }
.reporte .tipo { font-size:11px; text-transform:uppercase; letter-spacing:.5px; color:var(--warning); margin-bottom:4px; display:flex; align-items:center; gap:8px; }
.reporte .cliente { font-size:16px; font-weight:700; margin-bottom:2px; }
.reporte .dir { font-size:12px; color:var(--muted); margin-bottom:8px; }
.reporte .meta { display:flex; gap:12px; font-size:12px; color:var(--muted); flex-wrap:wrap; }

/* Estado badges en lista */
.badge-estado { font-size:10px; padding:2px 8px; border-radius:10px; font-weight:700; text-transform:uppercase; letter-spacing:.3px; }
.badge-estado.en-ruta-badge { background:var(--warning); color:#000; }
.badge-estado.trabajando { background:var(--success); color:#fff; }

/* Textarea */
textarea, input[type=text], input[type=tel], select { width:100%; background:var(--bg); border:1px solid var(--border); color:var(--text); padding:10px; border-radius:8px; font-size:14px; font-family:inherit; resize:none; }
textarea:focus, input:focus, select:focus { outline:none; border-color:var(--primary); }

/* Firma canvas */
.firma-container { background:#fff; border-radius:8px; overflow:hidden; touch-action:none; margin:8px 0; }
.firma-container canvas { display:block; }

/* Views */
.view { display:none; }
.view.active { display:block; }

/* Bottom nav */
.bottomnav { position:fixed; bottom:0; left:0; right:0; background:var(--card); border-top:1px solid var(--border); display:flex; z-index:100; }
.bottomnav a { flex:1; text-align:center; padding:10px 0 8px; color:var(--muted); text-decoration:none; font-size:11px; transition:color .2s; }
.bottomnav a.active { color:var(--primary); }
.bottomnav a .icon { font-size:20px; display:block; margin-bottom:2px; }

/* Photo modal */
.modal-overlay { position:fixed; top:0; left:0; right:0; bottom:0; background:rgba(0,0,0,.9); z-index:200; display:flex; align-items:center; justify-content:center; padding:20px; }
.modal-overlay img { max-width:100%; max-height:80vh; border-radius:8px; }
.modal-overlay .close { position:absolute; top:16px; right:16px; color:#fff; font-size:28px; cursor:pointer; }

/* Confirm modal */
.modal-box { background:var(--card); border-radius:16px; padding:24px; max-width:340px; width:90%; border:1px solid var(--border); }

/* Timeline */
.timeline-container { max-height:360px; overflow-y:auto; padding:4px 0; margin-bottom:8px; }
.tl-item { padding:8px 10px; margin-bottom:6px; border-radius:10px; background:var(--bg); border:1px solid var(--border); }
.tl-item.tl-mine { border-left:3px solid var(--primary); }
.tl-item.tl-other { border-left:3px solid var(--muted); }
.tl-item.tl-firma { border-left:3px solid var(--success); }
.tl-item.tl-offline { opacity:.7; border-style:dashed; }
.tl-header { display:flex; align-items:center; gap:6px; font-size:11px; margin-bottom:4px; }
.tl-icon { font-size:14px; }
.tl-autor { font-weight:600; color:var(--text); }
.tl-fecha { color:var(--muted); margin-left:auto; }
.tl-text { font-size:13px; color:var(--text); line-height:1.4; word-break:break-word; }
.tl-fotos { display:flex; gap:6px; flex-wrap:wrap; margin-top:6px; }
.tl-fotos img { width:60px; height:60px; object-fit:cover; border-radius:6px; border:1px solid var(--border); cursor:pointer; }
.tl-firma-img { text-align:center; margin-top:4px; }
.tl-firma-img img { max-width:100%; max-height:100px; border-radius:6px; }

/* Comment form */
.com-form { border-top:1px solid var(--border); padding-top:8px; }
.com-input-row { display:flex; gap:6px; align-items:flex-end; }
.com-input-row textarea { flex:1; font-size:13px; padding:8px; min-height:36px; }
.com-actions { display:flex; flex-direction:column; gap:4px; }
.btn-icon { background:none; border:1px solid var(--border); color:var(--text); border-radius:8px; width:36px; height:36px; font-size:16px; cursor:pointer; display:flex; align-items:center; justify-content:center; }
.btn-icon.btn-send { background:var(--primary); color:#fff; border-color:var(--primary); font-size:11px; font-weight:700; }
.com-foto-preview { position:relative; margin-bottom:6px; }
.com-foto-preview img { max-height:80px; border-radius:8px; border:1px solid var(--border); }
.com-foto-rm { position:absolute; top:2px; right:2px; background:var(--danger); color:#fff; border-radius:50%; width:20px; height:20px; font-size:12px; text-align:center; line-height:20px; cursor:pointer; }

/* Checklist evidencia */
.checklist-title { font-size:13px; font-weight:700; color:var(--text); margin-bottom:8px; }
.ck-item { padding:8px; margin-bottom:6px; border-radius:8px; background:var(--bg); border:1px solid var(--border); }
.ck-item.ck-done { border-color:var(--success); }
.ck-item.ck-pending { border-color:var(--warning); border-style:dashed; }
.ck-label { font-size:13px; margin-bottom:6px; display:flex; align-items:center; gap:6px; }
.ck-icon { font-size:16px; }
.ck-foto img, .ck-fotos img { width:60px; height:60px; object-fit:cover; border-radius:6px; cursor:pointer; border:1px solid var(--border); margin-right:4px; }

/* Fotos grid (legacy, used in evidencia) */
.fotos-grid { display:flex; gap:8px; flex-wrap:wrap; margin:8px 0; }
.fotos-grid img { width:70px; height:70px; object-fit:cover; border-radius:8px; border:2px solid var(--border); cursor:pointer; }

/* Minimapa */
#minimapa { border-radius:12px 12px 0 0; }
#minimapaCard { position:relative; }
.mapa-info { display:flex; justify-content:center; gap:16px; padding:6px 8px; background:var(--card); font-size:12px; color:var(--text); border-top:1px solid var(--border); }
.mapa-info span { display:flex; align-items:center; gap:4px; }
.mapa-info span:first-child { color:var(--primary); font-weight:600; }
.mapa-info span:nth-child(2) { color:var(--success); }
.mapa-info span:nth-child(3) { color:var(--muted); }

/* Leaflet dark overrides */
.leaflet-container { background:var(--bg) !important; }
.leaflet-popup-content-wrapper { background:var(--card); color:var(--text); border:1px solid var(--border); border-radius:8px; }
.leaflet-popup-tip { background:var(--card); }
.leaflet-popup-content { margin:8px 12px; font-size:12px; }

/* Detalle con tabs */
.detalle-header { position:sticky; top:0; background:var(--card); padding:10px 12px; display:flex; align-items:center; gap:10px; border-bottom:1px solid var(--border); z-index:50; }
.btn-back { background:none; border:none; color:var(--text); font-size:22px; cursor:pointer; padding:4px 8px; }
.detalle-header-info { flex:1; min-width:0; }
.detalle-cliente { font-size:14px; font-weight:700; color:var(--text); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.detalle-meta { font-size:11px; color:var(--muted); display:flex; gap:8px; flex-wrap:wrap; }
.detalle-meta span:not(:last-child)::after { content:'·'; margin-left:8px; color:var(--border); }

.tabs-bar { position:sticky; top:52px; background:var(--bg); border-bottom:1px solid var(--border); display:flex; overflow-x:auto; padding:0 4px; z-index:49; -webkit-overflow-scrolling:touch; scrollbar-width:none; }
.tabs-bar::-webkit-scrollbar { display:none; }
.tab-btn { background:none; border:none; color:var(--muted); padding:12px 14px; font-size:12px; font-weight:600; white-space:nowrap; cursor:pointer; position:relative; transition:color .2s; }
.tab-btn.active { color:var(--primary); }
.tab-btn.active::after { content:''; position:absolute; bottom:0; left:0; right:0; height:2px; background:var(--primary); }

.tabs-content { padding:12px; padding-bottom:90px; max-width:500px; margin:0 auto; }
.tab-pane { animation:fadeIn .2s; }
@keyframes fadeIn { from { opacity:0; transform:translateY(6px); } to { opacity:1; transform:translateY(0); } }

.detalle-actions { position:fixed; bottom:60px; left:0; right:0; background:var(--card); border-top:1px solid var(--border); padding:10px 12px; z-index:90; max-width:500px; margin:0 auto; }
.detalle-actions .btn { margin-bottom:0; }
.detalle-actions:empty { display:none; }

/* Boton flotante para nuevo comentario */
.btn-fab { position:absolute; bottom:10px; right:10px; width:42px; height:42px; border-radius:50%; background:var(--primary); color:#fff; border:none; font-size:22px; cursor:pointer; box-shadow:0 2px 8px rgba(0,0,0,.3); display:flex; align-items:center; justify-content:center; z-index:10; }

/* Equipos en tab */
.equipo-card { background:var(--bg); border:1px solid var(--border); border-radius:8px; padding:10px; margin-bottom:8px; }
.equipo-card .mac { font-family:monospace; font-size:12px; color:var(--muted); }

/* Reporte historial card */
.historial-reporte { background:var(--bg); border:1px solid var(--border); border-radius:6px; padding:8px; margin-bottom:6px; font-size:12px; cursor:pointer; }
.historial-reporte:active { background:var(--card); }
.historial-reporte .hist-head { display:flex; justify-content:space-between; align-items:center; margin-bottom:4px; }
.historial-reporte .hist-tipo { font-weight:600; color:var(--primary); }
.historial-reporte .hist-fecha { font-size:10px; color:var(--muted); }

/* Buzzer animation */
@keyframes buzzerShake {
    0%, 100% { transform: rotate(0deg); }
    25% { transform: rotate(-15deg); }
    75% { transform: rotate(15deg); }
}
.buzzer-active { animation: buzzerShake 0.3s infinite !important; background: var(--danger) !important; border-color: var(--danger) !important; }

/* Log */
#log { background:#000; border-radius:8px; padding:10px; font-family:monospace; font-size:11px; color:var(--muted); max-height:120px; overflow-y:auto; margin-top:8px; }
#log .ok { color:var(--success); }
#log .warn { color:var(--warning); }
#log .err { color:var(--danger); }
