/* Gestor de Rutas Labocenter — estilos base tomados de la maqueta RUTAS_PRUEBA.html.
   Los colores de marca están centralizados aquí: ajustar estas variables para alinear con www.labocenter.cl. */
:root {
  /* Colores corporativos tomados del logo de Labocenter */
  --brand-blue: #003ca0;
  --brand-green: #6a9e14;
  --brand-purple: #603078;
  --brand-gradient: linear-gradient(90deg, #603078 0%, #003ca0 45%, #6a9e14 100%);
  --navy: #0d2a5c;
  --blue: #003ca0;
  --blue-dark: #002c7a;
  --blue-light: #e9effa;
  --teal: #003ca0;
  --teal-accent: #6a9e14;
  --green: #5e9112;
  --green-light: #eef6e2;
  --orange: #e58a16;
  --red: #c9423f;
  --purple: #603078;
  --gray-100: #f5f7fa;
  --gray-200: #e3e8ef;
  --gray-500: #67748a;
  --text: #22324b;
  --bg: #f4f6fa;
  --white: #ffffff;
  --shadow: 0 6px 20px rgba(13, 42, 92, .07);
  --radius: 12px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: Arial, Helvetica, sans-serif; background: var(--bg); color: var(--text); }
button, input, select, textarea { font-family: inherit; font-size: inherit; }
a { color: var(--blue); }
[hidden] { display: none !important; }

/* ---------- Botones ---------- */
.btn { border: none; border-radius: 7px; padding: 10px 16px; cursor: pointer; font-weight: bold; font-size: 13px;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; text-decoration: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--blue); color: var(--white); }
.btn-primary:hover:not(:disabled) { background: var(--blue-dark); }
.btn-secondary { background: var(--white); color: var(--text); border: 1px solid var(--gray-200); font-weight: normal; }
.btn-secondary:hover:not(:disabled) { background: var(--gray-100); }
.btn-success { background: var(--green); color: var(--white); }
.btn-danger { background: var(--red); color: var(--white); }
.btn-warning { background: var(--orange); color: var(--white); }
.btn-link { background: transparent; color: var(--blue); padding: 4px 6px; font-weight: normal; font-size: 12px; }
.btn-block { width: 100%; padding: 14px; font-size: 15px; }

/* ---------- Estados ---------- */
.status { display: inline-block; border-radius: 20px; padding: 5px 9px; font-size: 10px; font-weight: bold;
  text-align: center; white-space: nowrap; text-transform: uppercase; letter-spacing: .3px; }
.status.active { color: #4a7a0c; background: var(--green-light); }
.status.late { color: #ad3532; background: #fde8e7; }
.status.done { color: var(--blue); background: var(--blue-light); }
.status.pending { color: #9b6800; background: #fff2cf; }
.status.muted { color: var(--gray-500); background: var(--gray-200); }

/* ---------- Tarjetas y tablas ---------- */
.card { background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.card + .card { margin-top: 20px; }
.card-header { padding: 15px 20px; border-bottom: 1px solid var(--gray-200); display: flex; justify-content: space-between;
  align-items: center; gap: 10px; flex-wrap: wrap; }
.card-title { font-weight: bold; font-size: 15px; color: var(--navy); }
.card-body { padding: 20px; }
.table-wrapper { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th, td { padding: 12px 16px; border-bottom: 1px solid var(--gray-200); text-align: left; vertical-align: middle; }
th { color: var(--gray-500); background: #fafbfc; font-size: 11px; text-transform: uppercase; white-space: nowrap; }
td.nowrap, th.nowrap { white-space: nowrap; }
tbody tr:hover { background: #fafcfe; }
tr.clickable { cursor: pointer; }
.empty { padding: 30px; text-align: center; color: var(--gray-500); font-size: 13px; }
.muted { color: var(--gray-500); }
.small { font-size: 11px; }

/* ---------- Formularios ---------- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group.full { grid-column: 1 / -1; }
.form-group label { font-size: 12px; font-weight: bold; color: var(--gray-500); }
.form-group input, .form-group select, .form-group textarea, .input {
  border: 1px solid var(--gray-200); padding: 10px; border-radius: 7px; outline: none; background: var(--white); color: var(--text); width: 100%; }
.form-group input:focus, .form-group select:focus, .form-group textarea:focus, .input:focus { border-color: var(--blue); }
.form-group textarea { min-height: 80px; resize: vertical; }
.check { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.form-group:has(> .check) { justify-content: flex-end; }
.form-group > label.check { color: var(--text); font-weight: normal; cursor: pointer; min-height: 40px; }
.form-group .check input { width: 18px; height: 18px; padding: 0; margin: 0; flex: none; accent-color: var(--brand-blue); }
.dias { display: flex; gap: 6px; flex-wrap: wrap; }
.dias label { display: flex; align-items: center; gap: 3px; font-size: 12px; font-weight: normal; color: var(--text); }
.filters { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; align-items: center; }
.filters input, .filters select { padding: 9px 10px; border: 1px solid var(--gray-200); border-radius: 7px; background: var(--white); }
.alert-box { background: #fff5df; border: 1px solid #f0d28e; color: #825e12; padding: 12px 14px; border-radius: 8px;
  margin-bottom: 16px; font-size: 13px; }
.alert-box.error { background: #fde8e7; border-color: #f2b8b5; color: #ad3532; }
.alert-box.info { background: var(--blue-light); border-color: #bcdcf2; color: var(--blue-dark); }

/* ---------- Modal ---------- */
.modal { display: none; position: fixed; inset: 0; z-index: 50; background: rgba(11, 25, 46, .55);
  align-items: flex-start; justify-content: center; padding: 30px 12px; overflow-y: auto; }
.modal.show { display: flex; }
.modal-content { width: min(640px, 100%); background: var(--bg); border-radius: var(--radius); overflow: hidden;
  box-shadow: 0 18px 50px rgba(11, 25, 46, .3); }
.modal-content.wide { width: min(920px, 100%); }
.modal-content.wide.xl { width: min(1120px, 100%); }
.modal-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; background: var(--white);
  padding: 18px 22px 14px; border-bottom: 3px solid transparent; border-image: var(--brand-gradient) 1; }
.modal-titulo { min-width: 0; }
.modal-header h3 { margin: 0; color: var(--navy); font-size: 18px; }
.modal-sub { color: var(--gray-500); font-size: 13px; margin-top: 4px; }
.modal-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.modal-body { padding: 18px 22px 22px; }
.modal-panel { background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; }
.modal-panel .modal-footer { border-top: 1px solid var(--gray-200); padding-top: 16px; margin-top: 18px; }
.close { cursor: pointer; border: none; background: transparent; font-size: 24px; line-height: 1; color: var(--gray-500); }
.close:hover { color: var(--navy); }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; flex-wrap: wrap; }

/* ---------- Toast ---------- */
#toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 80; background: var(--navy);
  color: var(--white); padding: 12px 18px; border-radius: 8px; font-size: 13px; box-shadow: var(--shadow); max-width: 90vw;
  opacity: 0; pointer-events: none; transition: opacity .2s; }
#toast.show { opacity: 1; }
#toast.error { background: var(--red); }

/* ---------- Varios ---------- */
.progress { height: 7px; background: #e9edf2; border-radius: 8px; overflow: hidden; margin-top: 6px; }
.progress-bar { height: 100%; background: var(--green); border-radius: 8px; }
.brand-logo { width: 39px; height: 39px; border-radius: 12px; background: var(--teal); color: var(--white);
  display: grid; place-items: center; font-weight: bold; font-size: 20px; flex-shrink: 0; }
.avatar { width: 35px; height: 35px; display: grid; place-items: center; border-radius: 50%; background: var(--blue);
  color: var(--white); font-weight: bold; font-size: 12px; flex-shrink: 0; }
.evidencia { max-width: 100%; max-height: 320px; border: 1px solid var(--gray-200); border-radius: 8px; background: var(--white); }
.kv { display: grid; grid-template-columns: 150px 1fr; gap: 6px 12px; font-size: 13px; }
.kv dt { color: var(--gray-500); }
.kv dd { margin: 0; }
.spinner { padding: 40px; text-align: center; color: var(--gray-500); }

@media (max-width: 560px) {
  .form-grid { grid-template-columns: 1fr; }
  .form-group.full { grid-column: auto; }
  .kv { grid-template-columns: 1fr; }
  .kv dt { margin-top: 6px; }
}

/* ---------- Notificaciones ---------- */
.notif { position: relative; }
.notif-btn { position: relative; background: transparent; border: none; font-size: 20px; cursor: pointer; padding: 6px; line-height: 1; }
.notif-badge { position: absolute; top: 0; right: -2px; background: var(--red); color: var(--white); border-radius: 10px; font-size: 10px;
  font-weight: bold; padding: 2px 5px; }
.notif-panel { position: absolute; right: 0; top: 40px; width: min(340px, 90vw); max-height: 70vh; overflow-y: auto; background: var(--white);
  color: var(--text); border-radius: 10px; box-shadow: 0 12px 30px rgba(0,0,0,.18); z-index: 60; }
.notif-head { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--gray-200); font-size: 13px; }
.notif-item { padding: 10px 14px; border-bottom: 1px solid var(--gray-200); font-size: 12px; }
.notif-item.nueva { background: var(--blue-light); cursor: pointer; }
.notif-titulo { font-weight: bold; color: var(--navy); }
.notif-msg { margin-top: 3px; }
.notif-fecha { margin-top: 4px; color: var(--gray-500); font-size: 11px; }
.btn-icon { background: var(--white); border: 1px solid var(--gray-200); border-radius: 6px; padding: 4px 8px; cursor: pointer; font-size: 12px; }
.btn-icon:disabled { opacity: .35; cursor: not-allowed; }
.multi-wrap { border: 1px solid var(--gray-200); border-radius: 8px; overflow: hidden; background: var(--white); }
.multi-barra { display: flex; align-items: center; gap: 10px; padding: 8px; border-bottom: 1px solid var(--gray-200); background: var(--gray-100); }
.form-group .multi-barra input.multi-buscar { flex: 1; width: auto; padding: 7px 10px; }
.multi-contador { font-size: 11px; color: var(--gray-500); white-space: nowrap; }
.multi { max-height: 240px; overflow-y: auto; }
div.multi:not(.multi-wrap .multi) { border: 1px solid var(--gray-200); border-radius: 8px; padding: 10px; }
.form-group .multi label.multi-op { display: flex; align-items: flex-start; gap: 10px; padding: 8px 12px; margin: 0; cursor: pointer;
  border-bottom: 1px solid var(--gray-100); font-weight: normal; color: var(--text); text-align: left; }
.form-group .multi label.multi-op:hover { background: var(--blue-light); }
.form-group .multi label.multi-op:has(input:checked) { background: #f0f7fd; }
.form-group .multi label.multi-op input[type=checkbox] { width: 16px; height: 16px; min-width: 16px; padding: 0; margin: 2px 0 0; flex: none;
  accent-color: var(--blue); cursor: pointer; }
.multi-texto { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.multi-nombre { font-size: 13px; color: var(--navy); font-weight: bold; }
.multi-sub { font-size: 11px; color: var(--gray-500); }
.multi-vacio { padding: 14px; text-align: center; color: var(--gray-500); font-size: 12px; }

/* ---------- Marca ---------- */
.logo { display: block; height: auto; max-width: 100%; }
.franja-marca { height: 3px; background: var(--brand-gradient); }
.btn-success { background: var(--brand-green); }
.btn-success:hover:not(:disabled) { background: #5a8a10; }

/* ---------- Mapas ---------- */
.mapa-google { width: 100%; height: 260px; border: 1px solid var(--gray-200); border-radius: 10px; display: block; background: var(--gray-100); }
.mapa-vacio { height: 260px; border: 1px dashed var(--gray-200); border-radius: 10px; display: grid; place-items: center; color: var(--gray-500);
  font-size: 12px; background: var(--gray-100); text-align: center; padding: 10px; }
.mapa-leaflet { width: 100%; height: 340px; border-radius: 10px; border: 1px solid var(--gray-200); background: #eef2f6; z-index: 0; }
.mapa-tabs { display: flex; gap: 6px; margin-bottom: 8px; }
.mapa-tabs button { border: 1px solid var(--gray-200); background: var(--white); border-radius: 20px; padding: 5px 12px; font-size: 12px; cursor: pointer; color: var(--text); }
.mapa-tabs button.active { background: var(--blue-light); border-color: var(--brand-blue); color: var(--brand-blue); font-weight: bold; }
.evidencia-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 16px; align-items: start; }
.evidencia-grid h5 { margin: 0 0 8px; font-size: 12px; color: var(--gray-500); text-transform: uppercase; letter-spacing: .5px; }
.evidencia-imgs { display: grid; gap: 10px; }
.evidencia-imgs img { width: 100%; max-height: 200px; object-fit: contain; border: 1px solid var(--gray-200); border-radius: 10px; background: var(--white); }
@media (max-width: 700px) { .evidencia-grid { grid-template-columns: 1fr; } }

/* Marcadores numerados */
.marcador { width: 28px; height: 28px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg); display: grid; place-items: center;
  border: 2px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,.3); }
.marcador span { transform: rotate(45deg); color: #fff; font-size: 11px; font-weight: bold; }
.marcador.hecha { background: var(--brand-green); }
.marcador.encentro { background: var(--orange); }
.marcador.pendiente { background: #9aa6b8; }
.marcador.atrasada { background: var(--red); }
.marcador.ultimo { box-shadow: 0 0 0 6px rgba(0,60,160,.25), 0 2px 6px rgba(0,0,0,.3); }

/* Check-ins (línea de tiempo) */
.checkins { list-style: none; margin: 0; padding: 0; }
.checkin { display: grid; grid-template-columns: 26px 1fr auto; gap: 12px; position: relative; padding: 10px 8px 14px; border-radius: 8px; cursor: pointer; }
.checkin:hover, .checkin.sel { background: var(--gray-100); }
.checkin::before { content: ''; position: absolute; left: 20px; top: 34px; bottom: -6px; width: 2px; background: var(--gray-200); }
.checkin:last-child::before { display: none; }
.checkin-ico { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-size: 13px; font-weight: bold; z-index: 1; }
.checkin.hecha .checkin-ico { background: var(--brand-green); }
.checkin.encentro .checkin-ico { background: var(--orange); }
.checkin.atrasada .checkin-ico { background: var(--red); }
.checkin.pendiente .checkin-ico { background: var(--gray-200); }
.checkin.cerrado .checkin-ico { background: var(--brand-purple); }
.checkin-titulo { font-weight: bold; color: var(--navy); font-size: 14px; }
.checkin-sub { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; color: var(--gray-500); margin-top: 3px; }
.checkin-sub .atraso { color: var(--red); }
.checkin-gps { font-size: 11px; color: var(--gray-500); align-self: center; }

/* ---------- Íconos (Tabler) ---------- */
.ico { width: 18px; height: 18px; flex: none; vertical-align: -4px; }
.btn .ico { margin-right: 2px; }
.btn-icon { display: inline-grid; place-items: center; }
.btn-icon .ico { width: 15px; height: 15px; }
.notif-ico { width: 22px; height: 22px; color: var(--brand-blue); display: block; }
.evid-icos { display: inline-flex; gap: 6px; color: var(--brand-blue); }
.checkin-gps .ico { color: var(--brand-blue); }
