/* Sistema visual común (inspirado en el estilo Lightning de los CRM que ya usa el equipo).
   Panel de tramitación, app del técnico y páginas del cliente. */
:root {
  --marca: #0176d3;
  --marca-osc: #014486;
  --marca-claro: #eef4ff;
  --navy: #032d60;
  --fondo: #f3f3f3;
  --papel: #ffffff;
  --borde: #e5e5e5;
  --borde-2: #c9c9c9;
  --texto: #181818;
  --texto-2: #444444;
  --texto-3: #747474;
  --exito: #2e844a;
  --exito-claro: #ebf7e6;
  --aviso: #dd7a01;
  --aviso-claro: #fef1cf;
  --error: #ba0517;
  --error-claro: #fddde3;
  --info: #0b5cab;
  --violeta: #5a1ba9;
  --radio: 8px;
  --radio-s: 4px;
  --sombra: 0 2px 2px 0 rgba(0, 0, 0, .10);
  --sombra-alta: 0 4px 14px rgba(0, 0, 0, .14);
  --sans: "Inter", -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  /* Alias de la versión anterior (algunos estilos en línea los usan) */
  --granate: var(--marca); --granate-osc: var(--marca-osc); --granate-claro: var(--marca-claro);
  --mostaza: var(--aviso); --mostaza-claro: var(--aviso-claro); --verde: var(--exito); --verde-claro: var(--exito-claro);
  --crema: #f3f3f3; --tinta: var(--texto); --gris: var(--texto-3); --gris-claro: #aeaeae; --linea: var(--borde);
  --azul: var(--marca); --serif: var(--sans);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--sans); font-size: 14px; line-height: 1.5; color: var(--texto); background: var(--fondo);
  -webkit-font-smoothing: antialiased; font-feature-settings: "tnum" 1;
}
h1, h2, h3 { margin: 0; font-weight: 700; letter-spacing: -.005em; }
h1 { font-size: 22px; line-height: 1.25; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }
p { margin: 0 0 .6em; }
a { color: var(--marca); text-decoration: none; }
a:hover { text-decoration: underline; }
small, .suave { color: var(--texto-3); }
.num { font-variant-numeric: tabular-nums; }
.oculto { display: none !important; }
:focus-visible { outline: 2px solid var(--marca); outline-offset: 2px; }
.ico { flex: none; vertical-align: middle; }

/* Botones */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: 600 13.5px/1 var(--sans); padding: 0 14px; min-height: 36px;
  border-radius: var(--radio-s); border: 1px solid var(--borde-2);
  background: var(--papel); color: var(--marca); cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background .12s, border-color .12s;
}
.btn:hover { background: #f3f3f3; text-decoration: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primario { background: var(--marca); border-color: var(--marca); color: #fff; }
.btn.primario:hover { background: var(--marca-osc); border-color: var(--marca-osc); }
.btn.verde { background: var(--exito); border-color: var(--exito); color: #fff; }
.btn.verde:hover { filter: brightness(.92); }
.btn.aviso { background: var(--aviso); border-color: var(--aviso); color: #fff; }
.btn.fantasma { border-color: transparent; background: transparent; }
.btn.fantasma:hover { background: rgba(0,0,0,.05); }
.btn.peligro { color: var(--error); }
.btn.peligro.primario { background: var(--error); border-color: var(--error); color: #fff; }
.btn.peque { padding: 0 10px; min-height: 30px; font-size: 12.5px; }
.btn.grande { padding: 0 18px; min-height: 48px; font-size: 15px; }
.btn.ancho { width: 100%; }
.btn.icono { padding: 0; width: 36px; }
.btn .spin { width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent;
  border-radius: 50%; animation: girar .7s linear infinite; }
@keyframes girar { to { transform: rotate(360deg); } }
.grupo-btn { display: inline-flex; }
.grupo-btn .btn { border-radius: 0; margin-left: -1px; }
.grupo-btn .btn:first-child { border-radius: var(--radio-s) 0 0 var(--radio-s); margin-left: 0; }
.grupo-btn .btn:last-child { border-radius: 0 var(--radio-s) var(--radio-s) 0; }

/* Formularios */
label.campo { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--texto-2); }
label.campo > span { font-weight: 400; }
input, select, textarea {
  font: 14px/1.4 var(--sans); color: var(--texto); background: var(--papel);
  border: 1px solid var(--borde-2); border-radius: var(--radio-s); padding: 8px 12px; min-height: 36px; width: 100%;
}
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--marca); box-shadow: 0 0 3px #0176d3; }
.rejilla { display: grid; gap: 12px; }
.rejilla.dos { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.rejilla.tres { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 640px) { .rejilla.dos, .rejilla.tres { grid-template-columns: 1fr; } }

/* Insignias de estado */
.chip {
  display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; line-height: 1.6;
  padding: 0 8px; border-radius: 15rem; background: #ecebea; color: var(--texto); white-space: nowrap;
}
.chip::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .75; }
.chip.sin-punto::before { display: none; }
.e-pendiente { background: #ecebea; color: #3e3e3c; }
.e-planificada, .e-propuesta, .e-reservada, .e-enviada, .e-esperando_opcion { background: var(--aviso-claro); color: #8c4b02; }
.e-agendada, .e-confirmada, .e-aceptada, .e-enviado, .e-manual_hecho, .e-aceptado { background: var(--exito-claro); color: #22683e; }
.e-en_curso { background: var(--marca-claro); color: var(--marca-osc); }
.e-cerrada, .e-realizada { background: #e5e5e5; color: #444; }
.e-cancelada, .e-caducada, .e-liberada, .e-rechazada, .e-sin_respuesta { background: #f3f3f3; color: #747474; }
.e-requiere_tramitador, .e-error { background: var(--error-claro); color: var(--error); }
.urgente { background: var(--error); color: #fff; }
.urgente::before { background: #fff; }

/* Tablas */
table.tabla { width: 100%; border-collapse: collapse; background: var(--papel); }
.tabla th { text-align: left; font-size: 12.5px; font-weight: 700; color: var(--texto-2); padding: 8px 12px;
  border-bottom: 1px solid var(--borde); background: #f3f3f3; position: sticky; top: 0; z-index: 1; white-space: nowrap; }
.tabla td { padding: 9px 12px; border-bottom: 1px solid var(--borde); vertical-align: top; }
.tabla tr.clic { cursor: pointer; }
.tabla tr.clic:hover td { background: #f3f3f3; }
.tabla td .sub { display: block; color: var(--texto-3); font-size: 12px; }
.tabla td a.titulo-fila { font-weight: 600; }

/* Avisos emergentes */
#toasts { position: fixed; left: 50%; transform: translateX(-50%); top: 14px; display: flex; flex-direction: column; gap: 8px; z-index: 200; width: min(520px, calc(100% - 24px)); }
.toast { background: #444; color: #fff; padding: 12px 16px; border-radius: var(--radio-s); box-shadow: var(--sombra-alta);
  font-size: 14px; animation: entra .18s ease-out; }
.toast.ok { background: var(--exito); }
.toast.mal { background: var(--error); }
@keyframes entra { from { transform: translateY(-6px); opacity: 0; } }

/* Ventanas modales */
.velo { position: fixed; inset: 0; background: rgba(8, 7, 7, .5); display: flex; align-items: center;
  justify-content: center; z-index: 120; padding: 16px; }
.modal { background: var(--papel); border-radius: var(--radio); box-shadow: var(--sombra-alta);
  width: min(560px, 100%); max-height: 90vh; overflow: auto; display: flex; flex-direction: column; }
.modal .cab { padding: 14px 20px; display: flex; justify-content: space-between; align-items: center; gap: 12px;
  border-bottom: 1px solid var(--borde); }
.modal .cab h2 { font-size: 18px; font-weight: 400; flex: 1; text-align: center; }
.modal .cuerpo { padding: 16px 20px; }
.modal .pie { padding: 12px 20px; display: flex; justify-content: flex-end; gap: 8px; border-top: 1px solid var(--borde); background: #f3f3f3;
  border-radius: 0 0 var(--radio) var(--radio); }
@media (max-width: 640px) {
  .velo { align-items: flex-end; padding: 0; }
  .modal { width: 100%; max-height: 92vh; border-radius: 14px 14px 0 0; }
  .modal .pie { border-radius: 0; padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
  .modal .pie .btn { flex: 1; min-height: 44px; }
}

/* Firma */
.firma { border: 1px dashed var(--borde-2); border-radius: var(--radio-s); background: #fff; touch-action: none;
  width: 100%; height: 170px; display: block; }

.vacio { padding: 32px 16px; text-align: center; color: var(--texto-3); }
.vacio strong { display: block; color: var(--texto); font-size: 15px; margin-bottom: 4px; }

/* Icono de objeto (cuadrado de color con pictograma blanco) */
.obj { width: 32px; height: 32px; border-radius: 4px; display: inline-flex; align-items: center; justify-content: center; color: #fff; flex: none; }
.obj.p { width: 24px; height: 24px; }
.obj.g { width: 40px; height: 40px; }
.c-inicio { background: #3ba755; } .c-planificador { background: #ff538a; } .c-ordenes { background: #f88962; }
.c-conversaciones { background: #1b96ff; } .c-tareas { background: #3ba755; } .c-fabricantes { background: #e5b23a; }
.c-clientes { background: #7f8de1; } .c-tecnicos { background: #06a59a; } .c-baremo { background: #9050e9; }
.c-conexiones { background: #5a1ba9; } .c-mapa { background: #04844b; }
.c-alerta { background: #ea001e; } .c-gps { background: #0d9dda; } .c-camion { background: #06a59a; } .c-whatsapp { background: #25a35a; }
.c-voz { background: #9050e9; } .c-email { background: #939393; } .c-euro { background: #2e844a; } .c-foto { background: #fe9339; }
.c-pdf { background: #ba0517; } .c-check { background: #2e844a; } .c-cancelar { background: #747474; } .c-reloj { background: #dd7a01; }
.c-evento { background: #0176d3; } .c-usuario { background: #7f8de1; } .c-caldera { background: #ff5d2d; } .c-llave { background: #3e3e3c; }
.c-calendario { background: #ff538a; } .c-ruta { background: #0b827c; } .c-grafico { background: #06a59a; } .c-firma { background: #0176d3; } .c-play { background: #2e844a; } .c-subir { background: #0176d3; } .c-lista { background: #7f8de1; } .c-pin { background: #04844b; } .c-rayo { background: #e5b23a; }

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
.c-enviar { background: #0176d3; }
