:root {
  --navy: #1e3a89;
  --navy-2: #16296a;
  --cyan: #2fb5d2;
  --amber: #ffb400;
  --green: #198754;
  --red: #d64545;
  --ink: #17223b;
  --muted: #66718a;
  --line: #e3e8f0;
  --bg: #f3f6fb;
  --card: #ffffff;
  --chat-bg: #eef3f9;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(23, 34, 59, .06), 0 8px 24px rgba(23, 34, 59, .06);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: "Plus Jakarta Sans", system-ui, -apple-system, Segoe UI, sans-serif;
  color: var(--ink);
  background: var(--bg);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; cursor: pointer; }
h1, h2, p { margin: 0; }
.muted { color: var(--muted); font-size: 12.5px; }

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px 28px;
  background: linear-gradient(100deg, var(--navy-2), var(--navy) 55%, #2a5bb8);
  color: #fff;
}
.brand { display: flex; align-items: center; gap: 14px; }
.logo { background: #fff; border-radius: 10px; padding: 6px 10px; display: flex; }
.logo img { height: 26px; display: block; }
.topbar h1 { font-size: 17px; font-weight: 700; letter-spacing: -.01em; }
.topbar p { font-size: 12.5px; opacity: .8; }
.top-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.btn {
  border-radius: 999px; padding: 8px 14px; font-weight: 600; font-size: 13px;
  border: 1px solid transparent; transition: background .15s, transform .1s;
}
.btn:active { transform: translateY(1px); }
.btn.ghost { background: rgba(255, 255, 255, .12); border-color: rgba(255, 255, 255, .25); color: #fff; }
.btn.ghost:hover { background: rgba(255, 255, 255, .22); }
.btn.primary { background: var(--navy); color: #fff; }
.btn.primary:hover { background: var(--navy-2); }
.btn.small { padding: 6px 11px; font-size: 12px; }

/* ---------- layout ---------- */
.layout {
  display: grid; grid-template-columns: minmax(0, 1fr) 420px; gap: 28px;
  padding: 22px 28px 28px; max-width: 1480px; margin: 0 auto;
}
.side-label {
  font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--muted); margin: 2px 2px 10px;
}
.backoffice { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
/* Fuera del modo demo no hay móvil simulado: el panel ocupa todo el ancho */
body.produccion .layout { grid-template-columns: minmax(0, 1fr); }
body.produccion .cliente, body.produccion #lbl-empresa { display: none; }
.backoffice .side-label { margin-bottom: -8px; }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 12px; }
.card h2 { font-size: 15.5px; font-weight: 700; letter-spacing: -.01em; margin-bottom: 2px; }
#mes-nombre { color: var(--navy); text-transform: capitalize; }
.mes-nav { display: flex; gap: 6px; }
.icon-btn {
  width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--line); background: #fff;
  color: var(--ink); font-size: 18px; line-height: 1;
}
.icon-btn:hover { background: var(--bg); }

.stats { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.stat { background: var(--bg); border-radius: 10px; padding: 8px 12px; min-width: 110px; }
.stat b { display: block; font-size: 20px; font-weight: 800; letter-spacing: -.02em; }
.stat span { font-size: 11.5px; color: var(--muted); }
.stat.pend b { color: var(--amber); }
.stat.ok b { color: var(--green); }
.stat.bot b { color: var(--cyan); }

.tabla-wrap { overflow: auto; max-height: 292px; border-top: 1px solid var(--line); }
.tabla thead th { position: sticky; top: 0; background: #fff; z-index: 1; }
.tabla { width: 100%; border-collapse: collapse; }
.tabla th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--muted); font-weight: 600; padding: 6px 8px; border-bottom: 1px solid var(--line);
}
.tabla td { padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tabla tr:last-child td { border-bottom: 0; }
.tabla tr.activo td { background: #f5f9ff; }
.cli-nombre { font-weight: 600; }
.cli-sub { font-size: 12px; color: var(--muted); }
.chip {
  display: inline-flex; align-items: center; gap: 5px; border-radius: 999px;
  padding: 3px 9px; font-size: 11.5px; font-weight: 600; white-space: nowrap;
}
.chip.pendiente { background: #fff4d6; color: #8a6200; }
.chip.contactado { background: #e3f4fa; color: #136b80; }
.chip.recordar { background: #eef0f6; color: #4a5470; }
.chip.rechazado { background: #fbe7e7; color: #9c2f2f; }
.chip.agendado { background: #e2f3ea; color: #146c43; }
.chip.bot { background: #e3f4fa; color: #136b80; }
td.acc { text-align: right; white-space: nowrap; }

/* ---------- agenda ---------- */
.agenda { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 14px; }
#card-agenda { scroll-margin-top: 12px; }
.mapa-wrap { position: relative; border-radius: 12px; overflow: hidden; min-height: 420px; border: 1px solid var(--line); }
#mapa { position: absolute; inset: 0; }
.leyenda {
  position: absolute; left: 10px; bottom: 10px; z-index: 500; background: rgba(255, 255, 255, .94);
  border-radius: 10px; padding: 6px 10px; display: flex; gap: 10px; flex-wrap: wrap; font-size: 11.5px;
  box-shadow: var(--shadow); max-width: calc(100% - 20px);
}
.leyenda span { display: inline-flex; align-items: center; gap: 5px; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.dot.base { background: var(--navy); }
.dot.visita { background: var(--cyan); }
.dot.casa { background: var(--amber); }
.dot.nueva { background: var(--green); }
.ahorro {
  background: #eefaf3; border-radius: 12px; padding: 8px 14px; border-left: 4px solid var(--green);
  max-width: 420px; display: grid; grid-template-columns: auto 1fr; column-gap: 12px; align-items: center;
}
.ahorro > p:first-child { grid-column: 1 / -1; font-weight: 600; color: var(--ink); }
.ahorro b { font-size: 22px; color: var(--green); letter-spacing: -.02em; white-space: nowrap; }
.ahorro p { font-size: 12px; color: var(--muted); }

.pin {
  width: 26px; height: 26px; border-radius: 50%; color: #fff; font-weight: 700; font-size: 12px;
  display: flex; align-items: center; justify-content: center; border: 2px solid #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .3);
}
.pin.base { background: var(--navy); font-size: 13px; }
.pin.casa { background: var(--amber); font-size: 14px; width: 32px; height: 32px; }
.pin.nueva { background: var(--green); font-size: 14px; width: 32px; height: 32px; }
.leaflet-tooltip.km {
  background: var(--ink); color: #fff; border: 0; border-radius: 6px; font-weight: 700; font-size: 11px; padding: 2px 6px;
}
.leaflet-tooltip.km::before { display: none; }

/* ---------- chat widget ---------- */
.cliente { position: sticky; top: 16px; align-self: start; }
.cliente-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 10px; }
.cliente-top .side-label { margin: 0 2px; }
.modo { display: inline-flex; background: #e4e9f2; border-radius: 999px; padding: 3px; }
.modo button {
  border: 0; background: transparent; border-radius: 999px; padding: 5px 12px; font-size: 12.5px; font-weight: 600;
  color: var(--muted); display: inline-flex; align-items: center; gap: 5px;
}
.modo button[aria-pressed="true"] { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(23, 34, 59, .15); }
.modo button[data-modo="wa"][aria-pressed="true"] svg { color: #1daa61; }
.widget {
  position: relative;
  height: calc(100vh - 150px); min-height: 560px; max-height: 820px;
  background: var(--card); border-radius: 22px; box-shadow: 0 18px 50px rgba(23, 34, 59, .18);
  display: flex; flex-direction: column; overflow: hidden; border: 1px solid #dfe5ef;
}
.widget:not(.wa) .solo-wa, .widget.wa .solo-web { display: none !important; }
.w-head {
  display: flex; align-items: center; gap: 12px; padding: 14px 16px;
  background: linear-gradient(120deg, var(--navy), #2a64c4); color: #fff;
}
.w-avatar { width: 40px; height: 40px; border-radius: 50%; background: #fff; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.w-avatar img { width: 34px; object-fit: contain; }
.w-title { display: flex; flex-direction: column; flex: 1; }
.w-title strong { font-size: 15px; }
.w-title span { font-size: 12px; opacity: .85; display: inline-flex; align-items: center; gap: 5px; }
.online { width: 8px; height: 8px; background: #5ee08c; border-radius: 50%; display: inline-block; }
.canal { font-size: 10.5px; font-weight: 700; background: rgba(255, 255, 255, .16); padding: 3px 8px; border-radius: 999px; }
.w-body { flex: 1; overflow-y: auto; padding: 16px 14px; background: var(--chat-bg); display: flex; flex-direction: column; gap: 8px; scroll-behavior: smooth; }
.vacio { margin: auto; text-align: center; color: var(--muted); max-width: 280px; }
.vacio-ico { font-size: 34px; margin-bottom: 6px; }
.vacio p { margin-bottom: 6px; }
.vacio strong { color: var(--ink); }

.fila { display: flex; flex-direction: column; animation: entra .22s ease-out; }
.fila.user { align-items: flex-end; }
@keyframes entra { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.burbuja {
  max-width: 86%; padding: 9px 12px; border-radius: 16px; font-size: 14px; line-height: 1.45;
  background: #fff; box-shadow: 0 1px 1px rgba(23, 34, 59, .08); border-top-left-radius: 5px; word-wrap: break-word;
}
.user .burbuja { background: var(--navy); color: #fff; border-top-left-radius: 16px; border-top-right-radius: 5px; }
.burbuja.plantilla { border-top: 3px solid #25d366; }
.burbuja.ok { border-left: 4px solid var(--green); }
.etiqueta { font-size: 10.5px; font-weight: 700; color: #128c4b; text-transform: uppercase; letter-spacing: .05em; margin-bottom: 4px; display: block; }
.hora-msg { font-size: 10.5px; color: var(--muted); margin: 2px 6px 0; }
.user .hora-msg { text-align: right; }

.opciones { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; width: 86%; }
.opcion {
  text-align: left; background: #fff; border: 1px solid #d9e2ef; border-left: 4px solid var(--cyan);
  border-radius: 12px; padding: 9px 12px; transition: transform .1s, border-color .15s, box-shadow .15s;
}
.opcion:hover { border-color: var(--navy); box-shadow: 0 4px 12px rgba(30, 58, 137, .12); transform: translateY(-1px); }
.opcion .o-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.opcion .o-dia { font-weight: 700; font-size: 13.5px; }
.opcion .o-hora { font-weight: 800; font-size: 16px; color: var(--navy); }
.opcion .o-det { font-size: 12px; color: var(--muted); margin-top: 2px; }
.opcion:disabled { opacity: .55; cursor: default; transform: none; box-shadow: none; }

.quick { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; max-width: 95%; }
.quick button {
  background: #fff; color: var(--navy); border: 1.5px solid var(--navy); border-radius: 999px;
  padding: 6px 12px; font-weight: 600; font-size: 13px; transition: background .15s, color .15s;
}
.quick button:hover { background: var(--navy); color: #fff; }

.typing { display: inline-flex; gap: 4px; padding: 12px 14px; background: #fff; border-radius: 16px; border-top-left-radius: 5px; align-self: flex-start; }
.typing i { width: 7px; height: 7px; background: #9aa6bd; border-radius: 50%; animation: bota 1s infinite; }
.typing i:nth-child(2) { animation-delay: .15s; }
.typing i:nth-child(3) { animation-delay: .3s; }
@keyframes bota { 0%, 60%, 100% { transform: none; opacity: .5; } 30% { transform: translateY(-4px); opacity: 1; } }

.w-input { display: flex; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--line); background: #fff; align-items: center; }
.campo {
  flex: 1; display: flex; align-items: center; gap: 4px; min-width: 0;
  border: 1px solid var(--line); border-radius: 999px; padding: 0 14px; background: #fff;
}
.campo:focus-within { border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(47, 181, 210, .18); }
.campo input { flex: 1; border: 0; outline: none; padding: 10px 0; font: inherit; min-width: 0; background: transparent; }
.send, .loc {
  width: 40px; height: 40px; border-radius: 50%; border: 0; display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.send { background: var(--navy); color: #fff; }
.send:disabled { background: #b8c2d6; cursor: default; }
.send .i-mic { display: none; }
.loc { background: #fff4d6; font-size: 18px; }
.loc[hidden], .ahorro[hidden], .toast[hidden] { display: none; }
.powered { text-align: center; font-size: 11.5px; color: var(--muted); margin-top: 10px; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 1000;
  background: var(--ink); color: #fff; padding: 11px 18px; border-radius: 12px; font-weight: 600;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .25); max-width: calc(100% - 32px);
}

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .layout { grid-template-columns: 1fr; padding: 16px; gap: 20px; }
  .cliente { position: static; order: -1; }
  .widget { height: 620px; }
}
@media (max-width: 720px) {
  .topbar { padding: 12px 16px; flex-wrap: wrap; }
  .agenda { grid-template-columns: 1fr; }
  .mapa-wrap { min-height: 340px; }
  .tabla th:nth-child(2), .tabla td:nth-child(2) { display: none; }
}

/* ======================================================================
   Vista WhatsApp: réplica del aspecto nativo (Android, tema claro).
   Lo que se pinta aquí sale del campo `whatsapp` de cada mensaje, que
   es exactamente lo que enviará Chatwoot (botones o lista).
   ====================================================================== */
.widget.wa {
  --wa-bg: #efeae2; --wa-in: #fff; --wa-out: #d9fdd3; --wa-ink: #111b21; --wa-meta: #667781;
  --wa-link: #027eb5; --wa-green: #1daa61; --wa-ico: #54656f;
  border: 10px solid #1b1c1f; border-radius: 46px; box-shadow: 0 24px 60px rgba(23, 34, 59, .28);
  font-family: Roboto, "Segoe UI", system-ui, -apple-system, sans-serif; color: var(--wa-ink);
  max-width: 400px; margin: 0 auto;
}
.wa-status {
  display: flex; justify-content: space-between; align-items: center; padding: 8px 22px 4px;
  font-size: 13px; font-weight: 600; background: #fff; color: var(--wa-ink);
}
.wa-status-ico { display: inline-flex; gap: 4px; align-items: center; }
.wa-head {
  display: flex; align-items: center; gap: 8px; padding: 6px 10px 8px 6px; background: #fff;
  border-bottom: 1px solid #e9edef; color: var(--wa-ico);
}
.wa-back { flex-shrink: 0; }
.wa-avatar { width: 38px; height: 38px; border-radius: 50%; background: #fff; border: 1px solid #e9edef; display: flex; align-items: center; justify-content: center; overflow: hidden; flex-shrink: 0; }
.wa-avatar img { width: 34px; object-fit: contain; }
.wa-title { display: flex; flex-direction: column; flex: 1; min-width: 0; line-height: 1.25; }
.wa-title strong { font-size: 16.5px; font-weight: 500; color: var(--wa-ink); }
.wa-title span { font-size: 12.5px; color: var(--wa-meta); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wa-title span.escribiendo { color: var(--wa-green); }
.wa-head-ico { display: inline-flex; gap: 18px; padding-right: 4px; }

.widget.wa .w-body {
  background-color: var(--wa-bg);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120' fill='none' stroke='%23dcd3c6' stroke-width='1.4' stroke-linecap='round'%3E%3Cpath d='M20 18c4-6 10-6 14 0'/%3E%3Ccircle cx='88' cy='22' r='6'/%3E%3Cpath d='M60 58l6 10H54z'/%3E%3Cpath d='M14 84h14M21 77v14'/%3E%3Cpath d='M82 90c0-6 8-6 8 0s8 6 8 0'/%3E%3Cpath d='M50 106c3-5 9-5 12 0'/%3E%3Ccircle cx='106' cy='62' r='2.5'/%3E%3Cpath d='M40 34l4 4-4 4-4-4z'/%3E%3C/svg%3E");
  padding: 10px 12px 70px; gap: 2px;
}
.wa-chip { align-self: center; margin: 6px 0; padding: 5px 10px; border-radius: 8px; font-size: 12.5px; text-align: center; box-shadow: 0 1px .5px rgba(11, 20, 26, .13); }
.wa-chip.fecha { background: #fff; color: var(--wa-meta); }
.wa-chip.info { background: #ffeecd; color: #54656f; max-width: 88%; line-height: 1.35; }
.wa-chip.demo { background: #fff; color: var(--wa-ink); max-width: 90%; margin-top: 30%; padding: 12px 14px; line-height: 1.45; }

.wa-fila { display: flex; margin-top: 2px; animation: entra .2s ease-out; }
.wa-fila.quieto { animation: none; }
.wa-fila.cola { margin-top: 8px; }
.wa-fila.out { justify-content: flex-end; }
.wa-bloque { display: inline-flex; flex-direction: column; gap: 2px; max-width: 84%; }
.wa-burbuja {
  position: relative; padding: 6px 8px 7px 9px; border-radius: 8px; font-size: 14.5px; line-height: 1.38;
  box-shadow: 0 1px .5px rgba(11, 20, 26, .13); word-wrap: break-word; background: var(--wa-in);
}
.wa-burbuja.out { background: var(--wa-out); max-width: 84%; }
.cola .wa-burbuja.in { border-top-left-radius: 0; }
.cola .wa-burbuja.out { border-top-right-radius: 0; }
.cola .wa-burbuja.in::before, .cola .wa-burbuja.out::before {
  content: ""; position: absolute; top: 0; width: 0; height: 0; border-style: solid;
}
.cola .wa-burbuja.in::before { left: -8px; border-width: 0 8px 10px 0; border-color: transparent var(--wa-in) transparent transparent; }
.cola .wa-burbuja.out::before { right: -8px; border-width: 0 0 10px 8px; border-color: transparent transparent transparent var(--wa-out); }
.wa-pie { font-size: 12.5px; color: var(--wa-meta); margin-top: 4px; }
.wa-meta { float: right; margin: 8px 0 -5px 12px; font-size: 11px; color: var(--wa-meta); line-height: 1; white-space: nowrap; }
.wa-meta .ticks { color: #53bdeb; letter-spacing: -3px; margin-left: 3px; font-style: normal; }
.wa-lista-btn {
  display: flex; align-items: center; justify-content: center; gap: 6px; width: calc(100% + 17px);
  margin: 8px -8px -7px -9px; padding: 10px 8px; border: 0; border-top: 1px solid #e9edef;
  background: transparent; color: var(--wa-link); font: inherit; font-size: 14.5px; font-weight: 500; clear: both;
  border-radius: 0 0 8px 8px;
}
.wa-btn {
  background: var(--wa-in); border: 0; border-radius: 8px; padding: 9px 10px; color: var(--wa-link);
  font: inherit; font-size: 14.5px; font-weight: 500; box-shadow: 0 1px .5px rgba(11, 20, 26, .13);
  display: flex; align-items: center; justify-content: center; gap: 6px;
}
.wa-btn:hover:not(.inactivo), .wa-lista-btn:hover:not(.inactivo) { background: #f5f6f6; }
.wa-btn.inactivo, .wa-lista-btn.inactivo { cursor: default; }
.wa-ubic {
  display: block; width: 220px; height: 110px; border-radius: 6px; margin-bottom: 4px; position: relative;
  background: linear-gradient(135deg, #cfe8d6, #e7f0da 50%, #d6e6f2);
}
.wa-ubic::after { content: "📍"; position: absolute; left: 50%; top: 50%; transform: translate(-50%, -60%); font-size: 26px; }

/* barra de escribir */
.widget.wa .w-input { background: transparent; border-top: 0; padding: 6px 8px 10px; position: absolute; left: 0; right: 0; bottom: 0; z-index: 10; }
.widget.wa .campo { border: 0; box-shadow: 0 1px .5px rgba(11, 20, 26, .13); padding: 0 8px; gap: 6px; }
.widget.wa .campo:focus-within { box-shadow: 0 1px .5px rgba(11, 20, 26, .13); }
.widget.wa .campo input { padding: 12px 2px; font-size: 15.5px; }
.wa-ico { color: var(--wa-ico); display: inline-flex; align-items: center; background: none; border: 0; padding: 2px; }
.widget.wa .send { width: 48px; height: 48px; background: var(--wa-green); }
.widget.wa .send:disabled { background: var(--wa-green); opacity: .6; }
.widget.wa .send .i-mic { display: block; }
.widget.wa .send .i-send { display: none; }
.widget.wa .send.con-texto .i-mic { display: none; }
.widget.wa .send.con-texto .i-send { display: block; }

/* menú de adjuntos */
.wa-adjuntos {
  position: absolute; left: 10px; right: 10px; bottom: 70px; z-index: 15; background: #fff; border-radius: 18px;
  padding: 18px 10px 8px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px;
  box-shadow: 0 6px 24px rgba(11, 20, 26, .2);
}
.wa-adjuntos[hidden] { display: none; }
.wa-adjuntos button { border: 0; background: none; display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 12.5px; color: var(--wa-meta); }
.wa-adjuntos i { width: 52px; height: 52px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 22px; font-style: normal; }
.wa-adjuntos button:not([data-adj="ubicacion"]) { opacity: .45; }

/* hoja de lista */
.wa-sheet { position: absolute; inset: 0; z-index: 20; }
.wa-sheet[hidden] { display: none; }
.wa-sheet-fondo { position: absolute; inset: 0; background: rgba(11, 20, 26, .35); animation: aparece .2s; }
.wa-sheet-panel {
  position: absolute; left: 0; right: 0; bottom: 0; max-height: 78%; overflow-y: auto; background: #fff;
  border-radius: 18px 18px 0 0; padding-bottom: 12px; animation: sube .22s ease-out;
}
@keyframes aparece { from { opacity: 0; } }
@keyframes sube { from { transform: translateY(40%); opacity: .4; } }
.wa-sheet-head { display: grid; grid-template-columns: 40px 1fr 40px; align-items: center; padding: 14px 10px 10px; position: sticky; top: 0; background: #fff; }
.wa-sheet-head button { border: 0; background: none; font-size: 18px; color: var(--wa-ico); }
.wa-sheet-head strong { text-align: center; font-size: 16px; font-weight: 500; }
#wa-sheet-filas { list-style: none; margin: 0; padding: 0 0 70px; }
#wa-sheet-filas li { display: flex; align-items: center; gap: 12px; padding: 12px 20px; cursor: pointer; }
#wa-sheet-filas li:hover { background: #f5f6f6; }
.fila-txt { flex: 1; min-width: 0; }
.fila-txt b { display: block; font-weight: 400; font-size: 15.5px; color: var(--wa-ink); }
.fila-txt span { display: block; font-size: 13.5px; color: var(--wa-meta); line-height: 1.35; margin-top: 1px; }
.radio { width: 20px; height: 20px; border-radius: 50%; border: 2px solid #8696a0; flex-shrink: 0; position: relative; }
li.sel .radio { border-color: var(--wa-green); }
li.sel .radio::after { content: ""; position: absolute; inset: 3px; border-radius: 50%; background: var(--wa-green); }
.wa-sheet-enviar {
  position: absolute; right: 18px; bottom: 18px; z-index: 2; width: 56px; height: 56px; border-radius: 16px; border: 0;
  background: var(--wa-green); color: #fff; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 12px rgba(0, 0, 0, .25);
}
.wa-sheet-enviar[hidden] { display: none; }

/* filtro de técnico (clientes con varios técnicos) */
.f-tecnico { display: inline-flex; align-items: center; gap: 8px; font-size: 12.5px; font-weight: 600; color: var(--muted); }
.f-tecnico[hidden] { display: none; }
.f-tecnico select {
  font: inherit; font-weight: 600; color: var(--ink); border: 1px solid var(--line); border-radius: 8px;
  padding: 6px 10px; background: #fff;
}
.btn[hidden] { display: none; }

/* ---------- agenda: calendario (mes, semana y día) ---------- */
.agenda-head { flex-wrap: wrap; }
.cal-tools { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.cal-nav { display: inline-flex; gap: 4px; }
.cal-btn {
  min-width: 32px; height: 32px; padding: 0 10px; border-radius: 8px; border: 1px solid var(--line);
  background: #fff; color: var(--ink); font-weight: 600; font-size: 13px;
}
.cal-btn:hover { background: var(--bg); }
.cal-vistas { display: inline-flex; background: #e4e9f2; border-radius: 999px; padding: 3px; }
.cal-vistas button {
  border: 0; background: transparent; border-radius: 999px; padding: 5px 13px;
  font-weight: 600; font-size: 12.5px; color: var(--muted);
}
.cal-vistas button[aria-pressed="true"] { background: #fff; color: var(--ink); box-shadow: 0 1px 2px rgba(23, 34, 59, .12); }
.cal-btn:focus-visible, .cal-vistas button:focus-visible, .cm-dia:focus-visible, .cs-dia:focus-visible,
.dp-opciones button:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
.cal-cab { display: flex; justify-content: space-between; align-items: center; gap: 8px 16px; flex-wrap: wrap; margin: 0 0 12px; }
.cal-cab h3 { margin: 0; font-size: 16px; font-weight: 700; }
.cal-leyenda { display: flex; gap: 6px 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.cal-leyenda span { display: inline-flex; align-items: center; gap: 6px; }
.cal-leyenda i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.cal-leyenda i.libre { background: #e6f6ec; border: 1px dashed #5cb87f; }
.cal-aviso { padding: 36px 0; text-align: center; }
.cal-opc {
  display: inline-block; font-size: 10px; font-weight: 700; color: #fff; border-radius: 999px;
  padding: 1px 7px; align-self: flex-start; line-height: 1.5;
}

/* mes */
.cm-cab, .cm-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.cm-cab span {
  font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase;
  letter-spacing: .05em; padding: 0 8px 6px;
}
.cm-grid { border-top: 1px solid var(--line); border-left: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.cm-dia {
  display: flex; flex-direction: column; align-items: stretch; gap: 3px; min-width: 0; min-height: 108px;
  padding: 6px 7px 7px; text-align: left; font: inherit; color: var(--ink); cursor: pointer;
  background: #fff; border: 0; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line);
}
.cm-dia:hover { background: #f6f9fe; }
.cm-dia.finde, .cm-dia.festivo, .cm-dia.otro-mes { background: #f8f9fb; }
.cm-dia.otro-mes .cm-num, .cm-dia.pasado .cm-num { color: #a3acbd; }
.cm-dia.pasado .cm-ev { opacity: .55; }
.cm-num { font-size: 12.5px; font-weight: 700; width: 24px; height: 24px; display: grid; place-items: center; border-radius: 50%; }
.cm-dia.hoy .cm-num { background: var(--navy); color: #fff; }
.cm-evs { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.cm-ev {
  display: flex; align-items: center; gap: 5px; min-width: 0; font-size: 11.5px; border-radius: 5px; padding: 1px 5px;
  background: color-mix(in srgb, var(--c) 13%, #fff);
}
.cm-ev i { width: 7px; height: 7px; border-radius: 50%; background: var(--c); flex-shrink: 0; }
.cm-ev span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.cm-ev.bot { font-weight: 700; }
.cm-mas { font-size: 11px; color: var(--muted); padding-left: 5px; }
.cm-pie { margin-top: auto; font-size: 11px; font-weight: 700; border-radius: 5px; padding: 1px 6px; align-self: flex-start; }
.cm-pie.libre { background: #e6f6ec; color: #146c43; }
.cm-pie.fest { background: #fdecec; color: #a33333; }

/* semana: horas, una columna por día y, dentro, un carril por técnico */
.cal-semana { overflow-x: auto; }
.cs { min-width: 640px; padding-bottom: 10px; }
.cs-cab, .cs-cuerpo { display: grid; grid-template-columns: 52px repeat(var(--cols), minmax(0, 1fr)); }
.cs-cab { border-bottom: 1px solid var(--line); }
.cs-dia {
  display: flex; flex-direction: column; align-items: flex-start; gap: 1px; min-width: 0; padding: 6px 8px 8px;
  border: 0; border-left: 1px solid var(--line); background: none; font: inherit; color: var(--ink); text-align: left; cursor: pointer;
}
.cs-dia:hover { background: #f6f9fe; }
.cs-dia b { font-size: 13px; }
.cs-dia.hoy b { color: var(--navy); }
.cs-dia small { font-size: 11.5px; color: var(--muted); max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cs-carriles { display: flex; gap: 3px; width: 100%; margin-top: 4px; }
.cs-carriles i { flex: 1; height: 3px; border-radius: 2px; }
.cs-horas { position: relative; }
.cs-horas span { position: absolute; right: 8px; transform: translateY(-50%); font-size: 11px; color: var(--muted); }
.cs-horas span:first-child { transform: none; }
.cs-col {
  position: relative; border-left: 1px solid var(--line); cursor: pointer;
  background-image: repeating-linear-gradient(to bottom, var(--line) 0 1px, transparent 1px var(--h));
}
.cs-col.bloqueado { background-color: #f6f7f9; }
.cs-col:hover { background-color: #fbfcfe; }
.cs-fuera {
  position: absolute; left: 0; right: 0; pointer-events: none;
  background: repeating-linear-gradient(135deg, rgba(23, 34, 59, .045) 0 6px, transparent 6px 12px);
}
.cs-libre { position: absolute; }
.cs-libre span {
  display: block; height: 100%; overflow: hidden; border-radius: 6px; padding: 3px 6px;
  background: #f1faf5; border: 1px dashed #a9dcbc; color: #1d7a4c; font-size: 11px; font-weight: 700; line-height: 1.3;
}
.cs-ev {
  position: absolute; z-index: 1; overflow: hidden; border-radius: 6px; padding: 3px 6px;
  border-left: 3px solid var(--c); background: color-mix(in srgb, var(--c) 17%, #fff);
  font-size: 11.5px; line-height: 1.3; box-shadow: 0 1px 2px rgba(23, 34, 59, .08);
}
.cs-ev small { display: block; color: var(--muted); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cs-ev.bot { box-shadow: inset 0 0 0 1.5px var(--green); }
.cs-etq {
  position: absolute; top: 8px; left: 50%; transform: translateX(-50%); z-index: 1;
  font-size: 11px; font-weight: 700; color: #a33333; background: #fdecec; border-radius: 999px; padding: 2px 8px;
}

/* día: detalle por técnico + mapa de la ruta */
.cal-dia.agenda { grid-template-columns: 310px minmax(0, 1fr); }
.dia-panel { display: flex; flex-direction: column; gap: 12px; min-width: 0; overflow-y: auto; max-height: 560px; padding-right: 2px; }
.dia-panel .ahorro { max-width: none; }
#dia-detalle { display: flex; flex-direction: column; gap: 14px; }
.dp-resumen { margin: 0; font-size: 13px; font-weight: 600; color: var(--muted); }
.dp-cab b { display: block; font-size: 15px; }
.dp-cab small { color: var(--muted); font-size: 12.5px; }
.dp-tec h4 { margin: 0 0 6px; font-size: 13px; display: flex; align-items: center; gap: 7px; }
.dp-tec h4 i { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.dp-tec h4 small { margin-left: auto; font-weight: 500; color: var(--muted); font-size: 12px; }
.dp-lista { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 5px; }
.dp-lista li {
  display: grid; grid-template-columns: 84px minmax(0, 1fr); gap: 8px; padding: 7px 9px;
  border-radius: 9px; border: 1px solid var(--line); font-size: 12.5px;
}
.dp-lista b { display: block; font-size: 13px; }
.dp-lista small { display: block; color: var(--muted); }
.dp-hora { font-weight: 700; font-variant-numeric: tabular-nums; }
li.dp-libre { background: #f1fbf5; border: 1px dashed #9fd8b5; }
li.dp-libre b { color: #146c43; }
li.dp-ev.bot { border-color: #9fd8b5; }
li.dp-vacio { display: block; color: var(--muted); }
.dp-opciones { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.dp-opciones button {
  display: flex; flex-direction: column; align-items: flex-start; gap: 3px; width: 100%; padding: 9px 11px;
  border: 1px solid var(--line); border-left: 4px solid var(--c); border-radius: 10px; background: #fff;
  font: inherit; color: var(--ink); text-align: left; cursor: pointer;
}
.dp-opciones button:hover { background: #f6f9fe; }
.dp-opciones b { font-size: 13px; }
.dp-opciones small { font-size: 12px; color: var(--muted); }
.dp-opciones .dp-porque { color: #5a4a00; background: #fff8e6; border-radius: 6px; padding: 3px 6px; margin-top: 2px; }

@media (max-width: 720px) {
  .cal-dia.agenda { grid-template-columns: 1fr; }
  .dia-panel { max-height: none; }
  .cm-dia { min-height: 62px; padding: 4px; }
  .cm-evs { flex-direction: row; flex-wrap: wrap; gap: 3px; }
  .cm-ev { padding: 0; background: none; }
  .cm-ev span, .cm-mas { display: none; }
  .cm-pie { font-size: 9.5px; padding: 0 4px; }
  .cm-pie-txt { display: none; }
  .leyenda { font-size: 10.5px; padding: 4px 8px; gap: 3px 8px; }
  .cm-dia .cal-opc { font-size: 9px; padding: 0 4px; }
}
