/* ==========================================================================
   CRM de Lotes · sistema visual (oscuro mate + glass)
   ========================================================================== */
:root {
  --bg: #16171a;
  --fg: #e8e6e1;
  --muted: #9a9890;
  --dim: #6f6e69;
  --line: rgba(255, 255, 255, 0.08);
  --line-2: rgba(255, 255, 255, 0.06);
  --glass: rgba(255, 255, 255, 0.045);
  --glass-2: rgba(255, 255, 255, 0.03);
  --accent: #e38f33;
  --accent-ink: #1f1608;
  --accent-soft: rgba(227, 143, 51, 0.16);
  --accent-line: rgba(227, 143, 51, 0.5);
  --ocre: #e38f33;
  --ocre-ink: #1f1608;
  --ocre-text: #f0b46b;
  --vendido: #c2cfaf;   /* verde Santte */
  --vendido-ink: #23301c;
  --reserva: #33343a;
  --reserva-ink: #8e8f93;
  --peligro: #e07a6a;
  --r-lg: 16px;
  --r-md: 12px;
  --r-sm: 10px;
  --nav-w: 76px;
}

* { box-sizing: border-box; }
html, body, #root { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: 'Manrope', 'Avenir Next', 'Segoe UI', system-ui, sans-serif;
  font-feature-settings: 'tnum' 1;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}
a { color: var(--accent); }
button { font: inherit; color: inherit; cursor: pointer; }
input, select { font: inherit; }
h1, h2, h3 { margin: 0; letter-spacing: -0.02em; }

/* Fondo con dos halos suaves */
.app {
  min-height: 100%;
  position: relative;
  display: flex;
}
.app::before {
  content: '';
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background:
    radial-gradient(900px 600px at 15% -10%, rgba(227, 143, 51, 0.10), transparent 60%),
    radial-gradient(700px 500px at 100% 100%, rgba(227, 143, 51, 0.05), transparent 60%);
}
.app > * { position: relative; z-index: 1; }

/* ---------- Primitivos ---------- */
.glass {
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.04) inset, 0 20px 40px -30px rgba(0, 0, 0, 0.8);
}
.glass-2 { background: var(--glass-2); border: 1px solid var(--line-2); border-radius: var(--r-md); }
.muted { color: var(--muted); }
.dim { color: var(--dim); }
.lbl { font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: #8d8b84; font-weight: 600; }
.num { font-variant-numeric: tabular-nums; }
.row { display: flex; align-items: center; gap: 12px; }
.col { display: flex; flex-direction: column; }
.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px; border-radius: var(--r-sm);
  font-weight: 600; font-size: 14px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.05); color: var(--fg);
  transition: background 0.15s, transform 0.05s; text-decoration: none;
}
.btn:hover { background: rgba(255, 255, 255, 0.09); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn.primary:hover { background: #eaa04f; }
.btn.lg { height: 46px; }
.btn.icon { width: 40px; padding: 0; }

.chip {
  white-space: nowrap; display: inline-flex; align-items: center; gap: 6px;
  height: 30px; padding: 0 12px; border-radius: 999px;
  font-size: 13px; font-weight: 500;
  border: 1px solid rgba(255, 255, 255, 0.1); background: transparent; color: #c9c7c0;
  transition: background 0.15s, border-color 0.15s;
}
.chip:hover { background: rgba(255, 255, 255, 0.05); }
.chip.on { background: var(--accent-soft); border-color: var(--accent-line); color: #f5c58a; }
.chip.sm { height: 24px; padding: 0 9px; font-size: 12px; }
.chip.ocre { background: var(--ocre); color: var(--ocre-ink); border-color: transparent; font-weight: 700; }
.chip.vendido { background: var(--vendido); color: var(--vendido-ink); border-color: transparent; font-weight: 700; }
.chip.reserva { background: var(--reserva); color: var(--reserva-ink); border-color: transparent; font-weight: 700; }
.chip.dashed { border-style: dashed; }

.inp {
  height: 40px; width: 100%; border-radius: var(--r-sm);
  border: 1px solid rgba(255, 255, 255, 0.1); background: rgba(0, 0, 0, 0.25);
  padding: 0 12px; color: var(--fg); font-size: 14px; outline: none;
}
.inp:focus { border-color: var(--accent-line); }
select.inp { appearance: none; -webkit-appearance: none; padding-right: 32px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239a9890' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; }
select.inp option { background: #1e1f24; }
.chip.sel-vendedor { position: relative; cursor: pointer; }
/* El select real va invisible encima del chip: así se ve como chip y abre el selector nativo (en iOS sin hacer zoom). */
.chip.sel-vendedor select { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; font-size: 16px; }
.chip.sel-vendedor select option { background: #1e1f24; color: #e8e6df; }

.avatar {
  width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; background: rgba(255, 255, 255, 0.08); color: var(--fg);
}
.avatar.sm { width: 24px; height: 24px; font-size: 10px; }
.avatar.ocre { background: var(--ocre); color: var(--ocre-ink); }
.avatar.accent { background: var(--accent); color: var(--accent-ink); }

.bar { height: 8px; border-radius: 4px; background: rgba(255, 255, 255, 0.08); overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--accent); border-radius: 4px; transition: width 0.4s ease; }

/* Barra de progreso del chat: 6 etapas */
.prog { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 3px; height: 5px; }
.prog span { border-radius: 3px; background: rgba(255, 255, 255, 0.09); }
.prog span.f { background: var(--accent); }
.prog.done span.f { background: #8d8b84; }

.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: var(--dim); }
.dot.on { background: #7fd3a8; box-shadow: 0 0 0 3px rgba(127, 211, 168, 0.18); }

/* ---------- Layout: nav lateral (compu) / inferior (celular) ---------- */
.nav {
  width: var(--nav-w); flex-shrink: 0;
  padding: 20px 12px; gap: 6px;
  display: flex; flex-direction: column; align-items: center;
  border-right: 1px solid var(--line-2);
  position: sticky; top: 0; height: 100vh; height: 100dvh;
}
.nav .logo {
  width: 44px; height: 44px; border-radius: 12px; margin-bottom: 16px;
  background: var(--accent); display: flex; align-items: center; justify-content: center;
}
.nav .logo img { width: 34px; height: auto; display: block; }
.login .marca { width: 100%; max-width: 250px; height: auto; display: block; margin: 4px auto 2px; }
.login .sub { text-align: center; letter-spacing: 0.22em; font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; margin-bottom: 6px; }
.nav a.item, .nav .item.campana {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  width: 56px; padding: 10px 0; border-radius: 12px; color: #7a7973; text-decoration: none;
  font-size: 10px; font-weight: 600;
}
.nav a.item:hover, .nav .item.campana:hover { color: var(--fg); }
.nav a.item.on { background: rgba(255, 255, 255, 0.07); color: var(--fg); }
.nav .spacer { flex: 1; }
.nav .me { background: none; border: none; padding: 0; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 22px 28px 0; flex-wrap: wrap; }
.page-head h1 { font-size: 24px; font-weight: 700; margin-top: 4px; }
.page-body { padding: 20px 28px 28px; display: flex; flex-direction: column; gap: 20px; }

@media (max-width: 840px) {
  /* La app es una columna del alto exacto de la pantalla: el contenido se desplaza adentro
     y la barra queda abajo como parte del layout (no "fija"), así nunca se mueve ni se eleva. */
  html, body, #root { height: 100%; }
  .app { flex-direction: column; height: 100%; min-height: 100%; overflow: hidden; }
  .main { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; order: 1; }
  .nav {
    position: static; order: 2; flex-shrink: 0; width: auto; height: auto;
    flex-direction: row; justify-content: space-around; align-items: center;
    /* Pegada al borde: solo un poco de aire arriba y, abajo, la rayita de inicio del iPhone menos 14px. */
    padding: 4px 8px max(0px, calc(env(safe-area-inset-bottom, 0px) - 24px));
    border-right: none; border-top: 1px solid var(--line-2);
    background: var(--bg); backdrop-filter: none; -webkit-backdrop-filter: none;
    box-shadow: 0 -10px 24px rgba(0, 0, 0, 0.45), 0 -1px 0 rgba(255, 255, 255, 0.05);
    z-index: 20;
  }
  .nav .logo, .nav .spacer, .nav .item.campana { display: none; }
  .nav .me .avatar { width: 34px; height: 34px; font-size: 12px; }
  .nav a.item.on { background: none; color: var(--accent); }
  .page-head { padding: 18px 18px 0; }
  .page-head h1 { font-size: 22px; }
  .page-body { padding: 14px 18px 24px; gap: 14px; }
}

/* ---------- Login ---------- */
.login {
  min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px;
}
.login .card { width: 100%; max-width: 380px; padding: 28px; display: flex; flex-direction: column; gap: 16px; }
.login .err { color: var(--peligro); font-size: 13px; }

/* ---------- Plano ---------- */
.kpis { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.kpi { padding: 18px 20px; }
.kpi .v { font-size: 30px; font-weight: 800; letter-spacing: -0.02em; margin-top: 6px; }
.kpi .v small { font-size: 18px; font-weight: 600; color: var(--muted); }
.kpi .s { font-size: 13px; color: var(--muted); }
.kpi .bar { margin-top: 12px; }

.plano-grid { display: flex; gap: 20px; align-items: flex-start; }
.plano-grid > .lotes-col { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 18px; }
.plano-grid > .panel { width: 380px; flex-shrink: 0; position: sticky; top: 20px; }

.filtros { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.leyenda { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.leyenda span { display: inline-flex; align-items: center; gap: 6px; }
.leyenda i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }

.manzana { padding: 18px; }
.manzana .h { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.manzana .h b { font-weight: 700; }
.lotes { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 8px; }

.lote {
  position: relative; border-radius: var(--r-md); text-align: left;
  display: flex; flex-direction: column; justify-content: space-between;
  padding: 10px 12px; min-height: 76px; font-weight: 600;
  border: 1.5px solid transparent; background: transparent; color: var(--fg);
  transition: opacity 0.2s, transform 0.1s, outline-color 0.15s;
}
.lote:hover { transform: translateY(-1px); }
.lote .n { font-size: 17px; letter-spacing: -0.01em; }
.lote .m2 { font-size: 12px; font-weight: 500; opacity: 0.8; }
.lote.disponible { border-style: dashed; border-color: rgba(255, 255, 255, 0.28); color: #d8d6cf; }
.lote.apartado { background: var(--ocre); border-color: var(--ocre); color: var(--ocre-ink); }
.lote.vendido { background: var(--vendido); border-color: var(--vendido); color: var(--vendido-ink); }
.lote.reserva { background: var(--reserva); border-color: var(--reserva); color: var(--reserva-ink); }
.lote.sel { outline: 2px solid #ffffff; outline-offset: 3px; }
.lote.off { opacity: 0.22; }
.lote .ini { position: absolute; top: 8px; right: 10px; font-size: 10px; font-weight: 700; opacity: 0.75; }

/* Panel de lote */
.panel-lote { padding: 22px; display: flex; flex-direction: column; gap: 18px; }
.panel-lote .titulo { font-size: 28px; font-weight: 800; letter-spacing: -0.02em; margin-top: 2px; }
.panel-lote .cifras { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.panel-lote .cifra { padding: 12px; }
.panel-lote .cifra .v { font-size: 20px; font-weight: 700; margin-top: 4px; }
.panel-lote .datos { display: flex; flex-direction: column; gap: 10px; font-size: 14px; }
.panel-lote .datos > div { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.panel-lote .datos b { font-weight: 600; text-align: right; }
.panel-lote .conv { padding: 12px 14px; }
.panel-lote .acciones { display: flex; gap: 8px; }
.panel-lote .acciones .btn { flex: 1; }
.panel-lote .vacio { color: var(--muted); font-size: 14px; line-height: 1.5; }
.panel-lote .cerrar { display: none; }

@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpis .kpi:last-child { grid-column: span 2; }
}
@media (max-width: 840px) {
  .kpis { gap: 10px; }
  .kpi { padding: 12px 14px; }
  .kpi .v { font-size: 20px; margin-top: 2px; }
  .kpi .v small { font-size: 14px; }
  .kpi .s { display: none; }
  .kpi .bar { margin-top: 8px; height: 6px; }
  .kpis .kpi:last-child .s { display: block; }
  .lotes { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
  .lote { min-height: 62px; padding: 8px 10px; }
  .lote .n { font-size: 15px; }
  .lote .m2 { font-size: 11px; }
  .manzana { padding: 12px; }
  .plano-grid > .panel {
    position: fixed; top: auto; left: 8px; right: 8px; bottom: calc(66px + env(safe-area-inset-bottom));
    width: auto; max-height: 70vh; overflow: auto; z-index: 15;
    border-radius: 22px; background: rgba(30, 31, 36, 0.94);
    animation: subir 0.22s ease-out;
  }
  .panel-lote { padding: 14px 18px 18px; gap: 12px; }
  .panel-lote .titulo { font-size: 22px; }
  .panel-lote .cerrar { display: flex; position: absolute; top: 10px; right: 10px; width: 32px; height: 32px; }
  .panel-lote .cifras { display: none; }
  .panel-lote .cifras-mov { display: flex !important; }
}
.panel-lote .cifras-mov { display: none; justify-content: space-between; align-items: baseline; }
@keyframes subir { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- Estado ---------- */
.estado-conn { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.cargando { padding: 60px; text-align: center; color: var(--muted); }
.pendiente { padding: 40px 28px; max-width: 560px; color: var(--muted); line-height: 1.6; }
.pendiente h1 { color: var(--fg); margin-bottom: 8px; }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  padding: 10px 16px; border-radius: 12px; font-size: 13px; z-index: 30;
  background: rgba(30, 31, 36, 0.95); border: 1px solid var(--line);
}
.toast.err { border-color: var(--peligro); color: #f3b3a8; }
@media (max-width: 840px) { .toast { bottom: 92px; } }

/* Utilidades responsivas */
.solo-cel { display: none; }
@media (max-width: 840px) { .solo-compu { display: none; } .solo-cel { display: inline; } }

/* ---------- Fase 1B: admin, prospectos, modales ---------- */
.badge { display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px; padding: 0 5px; margin-left: 6px;
  border-radius: 9px; background: var(--accent); color: var(--accent-ink); font-size: 11px; font-weight: 700; }
.badge.flotante { position: absolute; top: -6px; right: -10px; margin: 0; }

.modal-fondo { position: fixed; inset: 0; z-index: 40; background: rgba(0, 0, 0, 0.55); display: grid; place-items: center; padding: 16px;
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
.modal { width: 100%; padding: 22px; background: rgba(30, 31, 36, 0.96); max-height: 92vh; overflow: auto; animation: subir 0.18s ease-out; }
.err { color: var(--peligro); font-size: 13px; }

.tabla { display: flex; flex-direction: column; }
.tabla .fila { display: grid; grid-template-columns: 1.7fr 0.7fr 0.8fr 1.5fr 0.5fr 0.6fr; align-items: center; gap: 8px;
  padding: 12px 14px; border-top: 1px solid var(--line-2); font-size: 14px; }
.tabla .fila.h { border-top: none; padding: 8px 14px; }
.tabla .fila.inactivo { opacity: 0.45; }

.fila-prospecto { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; padding: 12px 14px; border-radius: 12px;
  border: none; background: transparent; color: var(--fg); }
.fila-prospecto:hover { background: rgba(255, 255, 255, 0.05); }

.dos-col { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.tres { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }

.disp { position: fixed; left: 10px; bottom: 76px; width: 56px; z-index: 5; display: flex; flex-direction: column; align-items: center; gap: 6px;
  font-size: 10px; font-weight: 600; color: var(--muted); }

@media (max-width: 1100px) {
  .dos-col { grid-template-columns: 1fr; }
}
@media (max-width: 840px) {
  .tres { grid-template-columns: 1fr; }
  .tabla .fila { grid-template-columns: 1fr auto; grid-template-areas: 'nombre editar' 'rol disp' 'avance avance'; row-gap: 8px; }
  .tabla .fila.h { display: none; }
  .tabla .fila > :nth-child(1) { grid-area: nombre; }
  .tabla .fila > :nth-child(2) { grid-area: rol; }
  .tabla .fila > :nth-child(3) { grid-area: disp; justify-self: end; }
  .tabla .fila > :nth-child(4) { grid-area: avance; padding-right: 0 !important; }
  .tabla .fila > :nth-child(5) { display: none; }
  .tabla .fila > :nth-child(6) { grid-area: editar; justify-self: end; }
  .disp { display: none; }
  .modal-fondo { align-items: end; padding: 0; }
  .modal { border-radius: 22px 22px 0 0; max-height: 88vh; }
}
button.sw { border: none; padding: 0; cursor: pointer; }
.sw:disabled { opacity: 0.4; cursor: not-allowed; }

/* Switch */
.sw { display: inline-block; width: 38px; height: 22px; border-radius: 11px; background: rgba(255, 255, 255, 0.14); position: relative; flex-shrink: 0;
  transition: background 0.15s; }
.sw::after { content: ''; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #8d8b84; transition: left 0.15s, background 0.15s; }
.sw.on { background: var(--accent); }
.sw.on::after { left: 19px; background: var(--accent-ink); }


/* ---------- Fase 4: chats ---------- */
.chats { flex: none; display: flex; min-height: 0; height: 100vh; height: 100dvh; overflow: hidden; }
.chats-lista { width: 380px; flex-shrink: 0; display: flex; flex-direction: column; border-right: 1px solid var(--line-2); min-height: 0; }
.chats-hilo { flex: 1; min-width: 0; display: flex; flex-direction: column; min-height: 0; }
.chats-vacio { flex: 1; display: grid; place-items: center; font-size: 14px; }
.fila-chat { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; padding: 12px 12px; border-radius: 12px;
  border: none; background: transparent; color: var(--fg); }
.fila-chat:hover { background: rgba(255, 255, 255, 0.04); }
.fila-chat.on { background: rgba(255, 255, 255, 0.07); }
.hilo-head { display: flex; align-items: center; gap: 14px; padding: 16px 20px; border-bottom: 1px solid var(--line-2); }
.hilo-msgs { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 16px 20px; display: flex; flex-direction: column; gap: 8px; min-height: 0; }
/* Empuja los mensajes hacia abajo sin justify-content:flex-end (ese rompe el scroll cuando desbordan). */
.hilo-msgs > :first-child { margin-top: auto; }
.hilo-pie { flex-shrink: 0; }
.chats-hilo { overflow: hidden; }
.hilo-pie { padding: 10px 20px 18px; display: flex; flex-direction: column; gap: 8px; border-top: 1px solid var(--line-2); }
.bub { max-width: 78%; padding: 10px 14px; border-radius: 14px; font-size: 14px; line-height: 1.45; white-space: pre-wrap; word-break: break-word; }
.bub.in { background: rgba(255, 255, 255, 0.07); border-bottom-left-radius: 4px; align-self: flex-start; }
.bub.out { background: var(--accent-soft); border: 1px solid rgba(227, 143, 51, 0.25); border-bottom-right-radius: 4px; align-self: flex-end; }
.bub.fallo { border-color: var(--peligro); }
.bub .t { display: block; font-size: 11px; color: #8d8b84; margin-top: 4px; text-align: right; }
.fila-lote { display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%; text-align: left; padding: 10px 12px;
  border-radius: 10px; border: 1px solid transparent; background: transparent; color: var(--fg); }
.fila-lote:hover { background: rgba(255, 255, 255, 0.05); }
.fila-lote.on { border-color: var(--accent-line); background: var(--accent-soft); }
.chip.disponible { border-style: dashed; }
@media (max-width: 840px) {
  .chats-lista { width: 100%; border-right: none; }
  .chats.con-hilo .chats-lista { display: none; }
  .chats-hilo { position: fixed; inset: 0; z-index: 25; background: var(--bg); height: 100vh; height: 100dvh; }
  .chats.con-hilo ~ .nav, body.sin-disp .nav { display: none; }
  .hilo-head { padding: 10px 12px; gap: 10px; flex-wrap: wrap; }
  .hilo-head .avatar { width: 36px !important; height: 36px !important; font-size: 12px; }
  .hilo-head .grow > div:first-child { font-size: 15px; }
  .hilo-head .grow > div:last-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 12px; }
  .hilo-head .acciones { width: 100%; justify-content: flex-end; }
  .hilo-head .btn.primary { padding: 0 12px; height: 32px; }
  .hilo-head .chip { height: 32px; }
  body.sin-disp .disp { display: none; }
  .chats-vacio { display: none; }
  .hilo-pie { padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
}

/* ---------- Horario ---------- */
.fila-horario { display: grid; grid-template-columns: 90px 1fr auto; align-items: center; gap: 10px; }
.fila-horario .horas .inp { width: 108px; }

/* ---------- Celular: estabilidad al tocar ---------- */
html { -webkit-text-size-adjust: 100%; }
body { overflow-x: hidden; -webkit-tap-highlight-color: transparent; }
button, a, .chip, .fila-chat, .fila-prospecto, .fila-lote, .lote, .sw { touch-action: manipulation; }
button, .chip, .sw, .lote, .nav a.item { -webkit-user-select: none; user-select: none; }
.hilo-msgs, .modal, .chats-lista > .col { -webkit-overflow-scrolling: touch; }
@media (max-width: 840px) {
  /* iOS hace zoom al tocar un campo con letra menor a 16px: eso "mueve" toda la pantalla. */
  input, select, textarea, .inp, .chats-lista input { font-size: 16px !important; }
  .fila-horario { grid-template-columns: 1fr auto; grid-template-areas: 'dia sw' 'horas horas'; row-gap: 6px; }
  .fila-horario .dia { grid-area: dia; }
  .fila-horario .horas { grid-area: horas; }
  .fila-horario .horas .inp { width: auto; flex: 1; min-width: 0; }
  .fila-horario .sw { grid-area: sw; }
  /* La lista de chats: encabezado, buscador y filtros fijos; solo la lista se desplaza. */
  .chats { height: 100%; min-height: 0; }
  .chats-lista { height: 100%; }
  .page-head, .page-body { padding-left: 16px; padding-right: 16px; }
  .modal { max-height: 90dvh; }
}

/* ==========================================================================
   Neumorfismo · piel de la app (va al final: sobreescribe lo anterior)
   Oscuro en toda la app; el hilo del chat es claro; caja de escribir naranja.
   ========================================================================== */
:root {
  --bg: #212329;
  --bg-in: #1c1e23;
  --fg: #e8e6e1;
  --up: -7px -7px 16px rgba(255, 255, 255, 0.05), 9px 9px 20px rgba(0, 0, 0, 0.6);
  --up-sm: -4px -4px 10px rgba(255, 255, 255, 0.05), 6px 6px 14px rgba(0, 0, 0, 0.6);
  --in: inset 5px 5px 12px rgba(0, 0, 0, 0.6), inset -4px -4px 10px rgba(255, 255, 255, 0.04);
  --in-sm: inset 4px 4px 9px rgba(0, 0, 0, 0.6), inset -3px -3px 8px rgba(255, 255, 255, 0.04);
  --line: transparent;
  --line-2: rgba(255, 255, 255, 0.05);
  --glass: var(--bg);
  --glass-2: var(--bg-in);
  --accent-soft: rgba(227, 143, 51, 0.14);
  --r-lg: 22px; --r-md: 16px; --r-sm: 999px;
}
body { background: var(--bg); }
.app::before { background: none; }

/* Superficies */
.glass { background: var(--bg); border: none; backdrop-filter: none; -webkit-backdrop-filter: none; box-shadow: var(--up); border-radius: var(--r-lg); }
.glass-2 { background: var(--bg-in); border: none; box-shadow: var(--in); border-radius: var(--r-md); }
.kpi, .manzana, .panel-lote { border-radius: var(--r-lg); }

/* Botones, chips, campos */
.btn { border: none; background: var(--bg); box-shadow: var(--up-sm); border-radius: 999px; }
.btn:hover { background: #24262c; }
.btn:active { box-shadow: var(--in-sm); transform: none; }
.btn.primary { background: linear-gradient(145deg, #eb9a3f, #d9822a); color: #1f1608;
  box-shadow: var(--up-sm), inset 1px 1px 0 rgba(255, 255, 255, 0.25); }
.btn.primary:hover { background: linear-gradient(145deg, #f0a24a, #de8830); }
.btn.icon { border-radius: 50%; }
.chip { border: none; background: var(--bg); box-shadow: var(--up-sm); color: #cfcdc6; font-weight: 600; height: 34px; padding: 0 14px; }
.chip:hover { background: #24262c; }
.chip.on { background: var(--bg); box-shadow: var(--in-sm); color: #f0b46b; }
.chip.sm { height: 26px; padding: 0 10px; }
.chip.dashed { border: none; }
.chip.ocre { background: linear-gradient(145deg, #eb9a3f, #d9822a); }
.chip.vendido { background: linear-gradient(145deg, #cbd7b9, #b8c6a3); color: var(--vendido-ink); }
.chip.reserva { background: var(--bg-in); box-shadow: var(--in-sm); }
.inp { border: none; background: var(--bg-in); box-shadow: var(--in); border-radius: 999px; padding: 0 16px; }
.inp:focus { box-shadow: var(--in), 0 0 0 2px rgba(227, 143, 51, 0.35); }
select.inp { padding-right: 36px; background-position: right 14px center; }
input[type='time'].inp { border-radius: 12px; }
.avatar { background: var(--bg); box-shadow: var(--up-sm); }
.avatar.accent, .avatar.ocre { background: linear-gradient(145deg, #eb9a3f, #d9822a); }
.bar { background: var(--bg-in); box-shadow: inset 1px 1px 3px rgba(0, 0, 0, 0.6); }
.prog span { background: var(--bg-in); box-shadow: inset 1px 1px 2px rgba(0, 0, 0, 0.6); }
.prog span.f { background: var(--accent); box-shadow: none; }
.badge { box-shadow: 2px 2px 6px rgba(0, 0, 0, 0.5); }

/* Switch */
.sw { background: var(--bg-in); box-shadow: var(--in-sm); width: 44px; height: 24px; border-radius: 12px; }
.sw::after { top: 4px; left: 4px; width: 16px; height: 16px; background: #6f6e69; box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.5); }
.sw.on { background: var(--bg-in); }
.sw.on::after { left: 24px; background: var(--accent); }

/* Navegación */
.nav { border-right: none; padding-top: 22px; }
.nav .logo { box-shadow: var(--up-sm); background: var(--bg); border-radius: 16px; }
.nav .logo img { filter: none; }
.nav a.item, .nav .item.campana { width: 60px; padding: 4px 0 8px; gap: 7px; border-radius: 0; color: #8d8b84; }
.nav a.item > span:first-child, .nav .item.campana > span:first-child { width: 44px; height: 44px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  background: var(--bg); box-shadow: var(--up-sm); transition: box-shadow 0.15s, color 0.15s; }
.nav a.item:hover > span:first-child, .nav .item.campana:hover > span:first-child { background: #24262c; }
.nav a.item.on { background: none; color: var(--accent); }
.nav a.item.on > span:first-child { box-shadow: var(--in-sm); color: var(--accent); }
.badge.flotante { top: -2px; right: -4px; }
.disp { color: #8d8b84; }

/* Plano */
.lote { border: none; box-shadow: var(--up-sm); background: var(--bg); border-radius: 16px; transition: box-shadow 0.15s, opacity 0.2s; }
.lote:hover { transform: none; background: #24262c; }
.lote.disponible { border: none; color: #d8d6cf; }
.lote.apartado { background: linear-gradient(145deg, #eb9a3f, #d9822a); color: var(--ocre-ink); }
.lote.vendido { background: linear-gradient(145deg, #cbd7b9, #b8c6a3); color: var(--vendido-ink); box-shadow: var(--up-sm); }
.lote.vendido .m2 { opacity: 0.75; }
.lote.vendido .ini { color: #23301c; opacity: 0.6; }
.lote.reserva { background: var(--bg-in); color: #6f6e69; box-shadow: var(--in-sm); }
.lote.reserva .n { text-decoration: line-through; text-decoration-color: rgba(255,255,255,0.25); }
.lote.sel { outline: 2px solid var(--accent); outline-offset: 3px; }
.leyenda i { border-radius: 4px; box-shadow: 1px 1px 3px rgba(0, 0, 0, 0.5); }
.panel-lote .cifra, .panel-lote .conv { border-radius: var(--r-md); }
.fila-prospecto, .fila-lote, .fila-chat { border-radius: 18px; transition: box-shadow 0.15s, background 0.15s; }
.fila-prospecto:hover, .fila-lote:hover, .fila-chat:hover { background: #24262c; }
.fila-chat.on, .fila-lote.on { background: var(--bg-in); box-shadow: var(--in-sm); border-color: transparent; }
.tabla .fila { border-top: 1px solid rgba(0, 0, 0, 0.35); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03); }
.tabla .fila.h { box-shadow: none; }

/* Modales y avisos */
.modal-fondo { background: rgba(0, 0, 0, 0.6); }
.modal { background: var(--bg); box-shadow: var(--up), 0 30px 60px rgba(0, 0, 0, 0.6); border-radius: 26px; }
.toast { background: var(--bg); border: none; box-shadow: var(--up); border-radius: 999px; padding: 12px 20px; }
.toast.err { color: #f3b3a8; box-shadow: var(--up), 0 0 0 1px rgba(224, 122, 106, 0.5); }
.login .card { border-radius: 30px; padding: 32px; }

/* ---------- Chats: lista oscura, hilo claro ---------- */
.chats-lista { border-right: none; }
.chats-lista .inp { height: 46px; }
.chats-hilo {
  --bg: #eceef2; --bg-in: #e4e6eb; --fg: #1c1d21; --muted: #6b6e78; --dim: #9a9da6;
  --up: -7px -7px 16px #ffffff, 9px 9px 20px rgba(150, 158, 175, 0.55);
  --up-sm: -4px -4px 10px #ffffff, 6px 6px 14px rgba(150, 158, 175, 0.55);
  --in: inset 5px 5px 12px rgba(150, 158, 175, 0.5), inset -5px -5px 12px #ffffff;
  --in-sm: inset 4px 4px 9px rgba(150, 158, 175, 0.5), inset -3px -3px 8px #ffffff;
  --line-2: rgba(0, 0, 0, 0.05); --ocre-text: #c9781f; --accent: #d9822a; --accent-line: rgba(217, 130, 42, 0.5);
  --peligro: #c8493a;
  background: #eceef2; color: #1c1d21;
  margin: 18px 18px 18px 6px; border-radius: 30px;
  box-shadow: inset 6px 6px 14px rgba(0, 0, 0, 0.55), inset -3px -3px 10px rgba(255, 255, 255, 0.05);
}
.chats-vacio { color: var(--dim); }
.chats-hilo .btn { background: #eceef2; color: #3a3c44; }
.chats-hilo .btn:hover { background: #f2f3f6; }
.chats-hilo .chip { background: #eceef2; color: #3a3c44; }
.chats-hilo .chip:hover { background: #f2f3f6; }
.chats-hilo .avatar { background: #eceef2; color: #1c1d21; }
.chats-hilo .inp { background: #e4e6eb; color: #1c1d21; }
.chats-hilo .inp::placeholder { color: #8f929c; }
.chats-hilo .err { color: #c8493a; }
.chats-hilo .lbl { color: #6b6e78; }
.hilo-head { border-bottom: none; padding: 22px 28px 12px; }
.hilo-msgs { padding: 20px 28px; gap: 12px; }
.bub { border-radius: 18px; padding: 12px 16px; white-space: pre-wrap; overflow-wrap: anywhere; }
.bub.in { background: #e4e6eb; box-shadow: var(--in); border-bottom-left-radius: 6px; color: #1c1d21; }
.bub.out { background: #fbe9d3; border: none; box-shadow: -5px -5px 12px #ffffff, 7px 7px 16px rgba(150, 158, 175, 0.5); border-bottom-right-radius: 6px; color: #1c1d21; }
.bub.fallo { box-shadow: -5px -5px 12px #ffffff, 7px 7px 16px rgba(150, 158, 175, 0.5), 0 0 0 1.5px #c8493a; }
.bub .t { color: #8f929c; }
.bub.out .t { color: #a8672a; }
.hilo-pie { border-top: none; padding: 8px 28px 24px; gap: 10px; }
.hilo-pie form .inp {
  padding: 0 24px; font-weight: 600; color: #4a3010;
  background: linear-gradient(145deg, #f2a24a, #dd8628);
  box-shadow: inset 4px 4px 10px rgba(120, 60, 0, 0.35), inset -4px -4px 10px rgba(255, 220, 180, 0.55), 6px 6px 16px rgba(150, 158, 175, 0.55), -4px -4px 10px #ffffff;
}
.hilo-pie form .inp::placeholder { color: #6e4a1c; }
.hilo-pie form .inp:focus { box-shadow: inset 4px 4px 10px rgba(120, 60, 0, 0.35), inset -4px -4px 10px rgba(255, 220, 180, 0.55), 6px 6px 16px rgba(150, 158, 175, 0.55), -4px -4px 10px #ffffff, 0 0 0 2px rgba(217, 130, 42, 0.45); }
.hilo-pie form .btn.primary { width: 54px !important; height: 54px !important; border-radius: 50%; background: #eceef2; color: #c9781f; box-shadow: var(--up-sm); }
.hilo-pie form .btn.primary:disabled { opacity: 0.5; }
.hilo-pie .dot.on { background: #3fbf7f; box-shadow: 0 0 0 3px rgba(63, 191, 127, 0.2); }

@media (max-width: 840px) {
  .nav { border-top: none; background: var(--bg); backdrop-filter: none; -webkit-backdrop-filter: none;
    box-shadow: 0 -8px 20px rgba(0, 0, 0, 0.45); padding-top: 10px; }
  .nav a.item, .nav .item.campana { width: 52px; padding: 0 0 4px; gap: 5px; font-size: 9px; }
  .nav a.item > span:first-child, .nav .item.campana > span:first-child { width: 40px; height: 40px; }
  .disp { background: var(--bg); border: none; box-shadow: var(--up-sm); }
  .plano-grid > .panel { background: var(--bg); box-shadow: var(--up), 0 -20px 40px rgba(0, 0, 0, 0.5); border-radius: 26px; }
  .chats-hilo { margin: 0; border-radius: 0; box-shadow: none; }
  .hilo-head { padding: 14px 16px 8px; }
  .hilo-msgs { padding: 16px; gap: 10px; }
  .hilo-pie { padding: 4px 12px calc(6px + env(safe-area-inset-bottom)); gap: 6px; }
  .hilo-pie form .inp { padding: 0 20px; }
  .hilo-pie form .btn.primary { width: 50px !important; height: 50px !important; }
  .modal { border-radius: 26px 26px 0 0; box-shadow: 0 -20px 40px rgba(0, 0, 0, 0.5); }
}
@media (max-width: 840px) {
  /* El switch flotante de Disponible no debe tapar el encabezado de la pantalla. */
  .page-head > div:first-child, .chats-lista > header { padding-right: 60px !important; }
  .top-cel.con-disp ~ .main .page-head > div:first-child, .top-cel.con-disp ~ .main .chats-lista > header { padding-right: 200px !important; }
  .chats-lista > header { flex-wrap: wrap; gap: 6px; }
}
.page-head > div:first-child { min-width: 0; max-width: 100%; }
.page-head select.inp { max-width: 100%; }

/* ---------- Tareas ---------- */
.fila-tarea { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 18px; }
.fila-tarea:hover { background: #24262c; }
.fila-tarea .check { width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0; border: none; background: var(--bg-in); box-shadow: var(--in-sm), inset 0 0 0 2px rgba(255, 255, 255, 0.14);
  display: flex; align-items: center; justify-content: center; color: var(--accent); }
.fila-tarea .check.on { background: linear-gradient(145deg, #eb9a3f, #d9822a); color: #1f1608; box-shadow: var(--up-sm); }
.fila-tarea .cuerpo { flex: 1; min-width: 0; text-align: left; border: none; background: none; color: var(--fg); padding: 0; display: flex; flex-direction: column; gap: 4px; }
.fila-tarea .titulo { font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fila-tarea.hecha .titulo { text-decoration: line-through; color: var(--muted); }
.fila-tarea .meta { display: flex; gap: 6px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.cuando { font-weight: 600; }
.cuando.vencida { color: var(--peligro); }
.cuando.hoy { color: var(--ocre-text); }
.vista-toggle { display: inline-flex; gap: 6px; margin-left: 6px; }
.vista-toggle .chip { padding: 0 12px; }

/* ---------- Tablero de oportunidades ---------- */
.kanban { display: flex; gap: 14px; overflow-x: auto; padding-bottom: 10px; -webkit-overflow-scrolling: touch; scroll-snap-type: x proximity; }
.kcol { flex: 0 0 272px; scroll-snap-align: start; border-radius: var(--r-lg); background: var(--bg-in); box-shadow: var(--in); padding: 12px; display: flex; flex-direction: column; gap: 10px;
  min-height: 240px; transition: box-shadow 0.15s; }
.kcol.sobre { box-shadow: var(--in), 0 0 0 2px var(--accent-line); }
.kcol.perdido { opacity: 0.75; }
.kcol-h { display: flex; justify-content: space-between; align-items: center; padding: 4px 6px 2px; font-size: 14px; }
.kcol-b { display: flex; flex-direction: column; gap: 10px; }
.kvacio { text-align: center; color: var(--dim); padding: 18px 0; font-size: 13px; }
.ktarjeta { position: relative; border-radius: 16px; background: var(--bg); box-shadow: var(--up-sm); padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; cursor: grab; }
.ktarjeta.ajena { opacity: 0.7; cursor: default; }
.ktarjeta.fantasma { opacity: 0.35; }
.ktarjeta .kcuerpo { border: none; background: none; color: var(--fg); text-align: left; padding: 0; display: flex; flex-direction: column; gap: 6px; width: 100%; }
.kmeta { display: flex; gap: 4px; flex-wrap: wrap; font-size: 12px; }
.kmeta .frio { color: var(--ocre-text); font-weight: 600; }
.kflechas { display: flex; justify-content: flex-end; gap: 6px; }
.kflechas .btn.icon { width: 30px; height: 30px; }
@media (max-width: 840px) {
  .kcol { flex-basis: 82vw; }
}

/* ---------- Tablero de métricas ---------- */
.kpis-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.graf-dias { display: grid; gap: 4px; align-items: end; height: 180px; }
.col-dia { display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; font-size: 10px; }
.barra-v { flex: 1; width: 100%; display: flex; align-items: flex-end; border-radius: 4px; }
.barra-v i { display: block; width: 100%; min-height: 2px; background: var(--accent); border-radius: 4px 4px 2px 2px; transition: height 0.3s; }
.col-dia:hover .barra-v i { background: #f0b46b; }
.fila-barra { display: grid; grid-template-columns: 120px 1fr 36px; align-items: center; gap: 12px; font-size: 13px; }
.fila-barra .etq { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--muted); }
.fila-barra .bar { height: 10px; }
.fila-barra b { text-align: right; }
.tabla-vend .fila { grid-template-columns: 1.6fr 0.6fr 0.8fr 0.7fr 0.7fr 0.8fr 1fr 0.8fr; border: none; background: none; color: var(--fg); text-align: left; width: 100%; }
.tabla-vend button.fila:hover { background: #24262c; }
@media (max-width: 1100px) {
  .kpis-6 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .kpis-6 .kpi:last-child { grid-column: auto; }
}
@media (max-width: 840px) {
  .kpis-6 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpis-6 .kpi .s { display: block; }
  .graf-dias { height: 130px; }
  .graf-dias.denso .col-dia span { display: none; }
  .fila-barra { grid-template-columns: 90px 1fr 32px; }
  .tabla-vend .fila { display: grid; grid-template-columns: 1fr auto auto auto; grid-template-areas: none; gap: 10px; }
  .tabla-vend .fila > :nth-child(n) { grid-area: auto; display: block; }
  .tabla-vend .fila > :nth-child(3), .tabla-vend .fila > :nth-child(5), .tabla-vend .fila > :nth-child(6), .tabla-vend .fila > :nth-child(8) { display: none; }
  .tabla-vend .fila.h { display: none; }
}

/* ---------- Anuncios de Meta ---------- */
.tabla-ads .fila { grid-template-columns: 2.2fr 0.9fr 1.1fr 0.9fr 0.8fr 0.7fr 0.8fr 0.9fr 1.4fr; }
.tabla-ads .fila.inactivo { opacity: 0.55; }
@media (max-width: 1100px) {
  .tabla-ads .fila { grid-template-columns: 2fr 1fr 1fr 1fr 1.4fr; }
  .tabla-ads .fila > :nth-child(3), .tabla-ads .fila > :nth-child(5), .tabla-ads .fila > :nth-child(6), .tabla-ads .fila > :nth-child(8) { display: none; }
}
@media (max-width: 840px) {
  .tabla-ads .fila { grid-template-columns: 1.6fr 1fr 1fr; grid-template-areas: none; }
  .tabla-ads .fila > :nth-child(n) { grid-area: auto; display: block; }
  .tabla-ads .fila > :nth-child(2), .tabla-ads .fila > :nth-child(3), .tabla-ads .fila > :nth-child(5), .tabla-ads .fila > :nth-child(6), .tabla-ads .fila > :nth-child(8) { display: none; }
  .tabla-ads .fila.h { display: none; }
}

/* ---------- Barra de avisos (flotante, no mueve el contenido) ---------- */
.barra-avisos { position: fixed; z-index: 60; right: 62px; bottom: 20px; max-width: 460px; display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; border-radius: 16px; background: var(--bg); box-shadow: var(--up); font-size: 13px; line-height: 1.45; color: var(--fg); }
.barra-avisos > svg { color: var(--accent); flex-shrink: 0; }
@media (max-width: 840px) {
  .barra-avisos { left: 12px; right: 56px; bottom: 96px; max-width: none; }
}

/* ---------- Plantillas (admin) ---------- */
.fila-plantilla { display: flex; gap: 14px; align-items: flex-start; padding: 12px 14px; border-radius: 12px; }
.fila-plantilla:hover { background: rgba(255, 255, 255, 0.03); }

/* ---------- Aviso de privacidad ---------- */
.privacidad { flex: 1; display: flex; justify-content: center; align-items: flex-start; padding: clamp(16px, 4vw, 40px); }
.privacidad p { font-size: 14px; line-height: 1.6; color: var(--fg); margin: 0 0 12px; }
.privacidad h2 { font-size: 15px; font-weight: 700; margin: 20px 0 8px; }

/* ---------- Ayuda (?) ---------- */
.ayuda-btn { position: fixed; z-index: 55; bottom: 20px; right: 20px; width: 30px; height: 30px; border-radius: 50%; border: none; cursor: pointer;
  background: var(--bg); color: var(--muted); box-shadow: var(--up); font-weight: 700; font-size: 15px; font-family: inherit; opacity: 0.85; }
.ayuda-btn:hover { color: var(--accent); opacity: 1; }
.ayuda-p { font-size: 14px; line-height: 1.6; margin: 0; }
.ayuda-fila { display: flex; align-items: center; gap: 12px; width: 100%; padding: 8px 10px; border-radius: 12px; border: none; background: transparent; color: var(--fg); cursor: pointer; font-family: inherit; }
.ayuda-fila:hover { background: rgba(255, 255, 255, 0.04); }
@media (max-width: 840px) {
  .ayuda-btn { bottom: 96px; right: 12px; width: 34px; height: 34px; }
  body.sin-disp .ayuda-btn, body.sin-disp .barra-avisos { display: none; }
}

/* ---------- Respuestas sugeridas (chat) ---------- */
.sugerencias { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 6px; scrollbar-width: none; }
.sugerencias::-webkit-scrollbar { display: none; }
.sug { flex: 0 0 auto; max-width: 78%; text-align: left; font: inherit; font-size: 13px; line-height: 1.35; padding: 8px 12px; border-radius: 14px;
  border: 1px solid var(--line); background: var(--glass); color: var(--fg); cursor: pointer; white-space: normal; }
.sug:hover { border-color: var(--accent-line); color: var(--ocre-text); }
.sug.vieja { opacity: 0.5; }
.chats-hilo .sug { background: #fff; border-color: rgba(0, 0, 0, 0.1); color: #23252b; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06); }
.chats-hilo .sug:hover { border-color: var(--accent); color: #b35a00; }
@media (min-width: 841px) { .sug { max-width: 360px; } }

/* ---------- Formulario público de contacto ---------- */
.contacto { min-height: 100vh; min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 20px; background: #f3f4f6; color: #1d1f24; }
.contacto.incrustado { min-height: 0; padding: 0; background: transparent; align-items: flex-start; }
.contacto-card { position: relative; width: 100%; max-width: 480px; background: #fff; border-radius: 20px; padding: 28px; display: flex; flex-direction: column; gap: 14px; box-shadow: 0 10px 40px rgba(0, 0, 0, 0.08); }
.contacto-logo { height: 34px; align-self: flex-start; filter: invert(1); margin-bottom: 4px; }
.contacto .lbl { color: #6b7280; }
.contacto .muted { color: #6b7280; }
.contacto .dim { color: #9ca3af; }
.contacto .dim a { color: #9ca3af; }
.contacto .inp { background: #f3f4f6; border-color: #e5e7eb; color: #1d1f24; box-shadow: none; }
.contacto .inp:focus { border-color: var(--accent); }
.contacto .btn.primary { box-shadow: none; }
.contacto .err { color: #b91c1c; font-size: 13px; }

/* Campanita del menú: botón con el mismo look que los items */
.nav .item.campana { background: none; border: none; font-family: inherit; cursor: pointer; }


/* ---------- Celular: zona segura (hora/batería del iPhone) y filas de botones ---------- */
@media (max-width: 840px) {
  /* Instalada como app en iPhone, la pantalla llega hasta arriba de todo: reservamos
     el espacio de la hora/batería para que el encabezado y el botón de regresar se vean. */
  .main { padding-top: env(safe-area-inset-top, 0px); }
  .modal-fondo { padding-top: env(safe-area-inset-top, 0px); }
  .barra-avisos { top: auto; }
  /* Las filas de filtros no se amontonan en 3 renglones: una sola fila que se desliza de lado. */
  .page-head .chips, .chats-lista .chips, .chips-manzanas {
    flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none;
    width: 100%; max-width: 100%; padding-bottom: 6px; margin-bottom: -6px;
  }
  .page-head .chips::-webkit-scrollbar, .chats-lista .chips::-webkit-scrollbar, .chips-manzanas::-webkit-scrollbar { display: none; }
  .page-head .chips > *, .chats-lista .chips > *, .chips-manzanas > * { flex-shrink: 0; }
  .page-head .chips .vista-toggle { margin-left: auto; }
  /* Botones y chips con tamaño de dedo */
  .page-head .chips .chip, .chats-lista .chips .chip { height: 38px; }
}

/* Cabecera con filtros + acciones: en compu van en una sola fila; en celular, dos renglones. */
.cabecera-chips { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; min-width: 0; max-width: 100%; }
@media (max-width: 840px) {
  .cabecera-chips { flex-direction: column; align-items: stretch; width: 100%; gap: 10px; }
  .cabecera-chips .chips.acciones { flex-wrap: wrap; overflow: visible; padding-bottom: 0; margin-bottom: 0; }
  .cabecera-chips .chips.acciones > * { flex-shrink: 1; }
  .cabecera-chips .chips.acciones .btn { height: 40px; }
}

/* ---------- Celular: barra superior derecha (Disponible · Admin · perfil) ---------- */
.top-cel { display: none; }
@media (max-width: 840px) {
  .top-cel { display: flex; align-items: center; gap: 8px; position: fixed; z-index: 21;
    top: calc(10px + env(safe-area-inset-top)); right: 12px; }
  .top-btn { position: relative; width: 40px; height: 40px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
    background: var(--bg); color: #9a988f; border: none; box-shadow: var(--up-sm); padding: 0; text-decoration: none; }
  .top-btn.on { color: var(--accent); box-shadow: var(--in-sm); }
  .top-btn .badge.flotante { position: absolute; top: -4px; right: -4px; }
  .disp-cel { display: flex; align-items: center; gap: 6px; height: 40px; padding: 0 10px 0 6px; border-radius: 999px; background: var(--bg); box-shadow: var(--up-sm); font-size: 11px; font-weight: 600; color: #9a988f; }
  /* Abajo solo las 5 pantallas: Admin y el perfil se van arriba */
  .nav a.item.solo-compu-nav, .nav .me, .nav .item.campana { display: none !important; }
  .nav { justify-content: space-around; }
  body.sin-disp .top-cel { display: none; }
}

/* ---------- Encabezado del chat: banner oscuro con acentos naranja ---------- */
.chats-hilo .hilo-head {
  background: #1c1d21; color: #f2f0ea; border-bottom: 2px solid var(--accent);
  border-radius: 30px 30px 0 0; padding: 18px 24px 14px;
}
.hilo-head .grow > div:first-child { color: #ffffff; }
.hilo-head .grow > div:last-child { color: #a9a79f; }
.hilo-head .avatar { background: #2a2c33; color: var(--accent); box-shadow: inset 2px 2px 6px rgba(0,0,0,0.6), inset -2px -2px 6px rgba(255,255,255,0.05); }
.chats-hilo .hilo-head .btn, .chats-hilo .hilo-head .chip {
  background: #2a2c33; color: #e8e6df; border: 1px solid rgba(255,255,255,0.06);
  box-shadow: 3px 3px 8px rgba(0,0,0,0.5), -2px -2px 6px rgba(255,255,255,0.04);
}
.chats-hilo .hilo-head .btn:hover, .chats-hilo .hilo-head .chip:hover { background: #33363e; color: #fff; }
.chats-hilo .hilo-head .btn.primary { background: linear-gradient(135deg, #e08a2e, #c9781f); color: #1c1d21; border: none; }
.chats-hilo .hilo-head .chip[style*="accent-line"] { border-color: var(--accent) !important; color: var(--accent) !important; }
.chats-hilo .hilo-head .btn.icon { color: #c9c7bf; }
.hilo-head .solo-cel.btn.icon { background: #2a2c33; color: #fff; }
@media (max-width: 840px) {
  .chats-hilo .hilo-head { border-radius: 0; padding: calc(10px + env(safe-area-inset-top, 0px)) 14px 10px; }
  .chats-hilo { padding-top: 0; }
}

/* ---------- Adjuntos en el chat ---------- */
.bub.con-adj { padding: 8px; max-width: min(78%, 360px); }
.bub.con-adj .t { padding: 0 8px 4px; }
.adj-img { display: block; border-radius: 12px; overflow: hidden; }
.adj-img img { display: block; width: 100%; max-height: 360px; object-fit: cover; }
.adj-video { display: block; width: 100%; max-height: 360px; border-radius: 12px; background: #000; }
.adj-audio { display: block; width: 260px; max-width: 100%; }
.adj-doc { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px; background: rgba(0,0,0,0.06); color: inherit; text-decoration: none; min-width: 200px; }
.adj-doc:hover { background: rgba(0,0,0,0.1); }
.adj-ico { width: 36px; height: 36px; border-radius: 10px; background: var(--accent); color: #1c1d21; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.adj-cargando { font-size: 12px; color: var(--dim); padding: 10px 12px; }
.bub.con-adj > :not(.adj-img):not(.adj-video):not(.adj-audio):not(.adj-doc):not(.t):not(.adj-cargando) { display: block; padding: 8px 8px 2px; }
.adj-pendiente { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 14px; background: #e4e6eb; box-shadow: var(--in-sm); }
.adj-pendiente img { width: 44px; height: 44px; object-fit: cover; border-radius: 10px; flex-shrink: 0; }
.chats-hilo .hilo-head a.btn.icon { text-decoration: none; }
.hilo-head .acciones .btn.icon { flex-shrink: 0; width: 36px !important; }
@media (max-width: 840px) {
  /* Una sola fila de acciones que se desliza de lado (no se apilan en dos renglones). */
  .hilo-head .acciones { flex-wrap: nowrap; gap: 8px; justify-content: flex-start; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; padding: 2px 0 4px; margin: 0 -14px; padding-left: 14px; padding-right: 14px; width: calc(100% + 28px); }
  .hilo-head .acciones::-webkit-scrollbar { display: none; }
  .hilo-head .acciones > * { flex-shrink: 0; white-space: nowrap; }
}

/* Caja de escribir: blanca (no naranja), crece con el texto hasta 160px */
.hilo-pie form { align-items: flex-end; }
.hilo-pie form .inp.caja-msg, .chats-hilo .hilo-pie form .inp {
  background: #ffffff !important; color: #1c1d21 !important; font-weight: 500;
  box-shadow: inset 2px 2px 6px rgba(150, 158, 175, 0.35), inset -2px -2px 6px #ffffff, 0 0 0 1px rgba(0,0,0,0.06) !important;
}
.hilo-pie form .inp.caja-msg { border-radius: 24px; min-height: 46px; height: auto; max-height: 160px; padding: 12px 20px; line-height: 1.4; resize: none; font-family: inherit; font-size: 15px; overflow-y: auto; }
.chats-hilo .hilo-pie form .inp::placeholder { color: #8f929c; }
.chats-hilo .hilo-pie form .inp:focus { box-shadow: inset 2px 2px 6px rgba(150, 158, 175, 0.35), inset -2px -2px 6px #ffffff, 0 0 0 2px rgba(217, 130, 42, 0.55) !important; }
@media (max-width: 840px) {
  .hilo-pie form .inp.caja-msg { min-height: 50px; padding: 14px 18px; font-size: 16px; }
}

/* Teclado en celular: el hilo no se desplaza con la página; el área de mensajes es la que se encoge. */
@media (max-width: 840px) {
  .chats-hilo { overscroll-behavior: contain; }
  .hilo-msgs { overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
  body.sin-disp { position: fixed; inset: 0; overflow: hidden; }
}

/* ---------- Lista de chats: cada chat como tarjeta con relieve ---------- */
.chats-lista .fila-chat { background: var(--bg); box-shadow: var(--up-sm); margin: 3px 0; padding: 12px 14px; width: 100%; }
.chats-lista .fila-chat:hover { background: var(--bg); box-shadow: var(--up); }
.chats-lista .fila-chat.on { background: var(--bg); box-shadow: var(--in-sm); }
.chats-lista > .col { gap: 8px !important; padding: 4px 10px 16px 14px !important; }

/* ---------- Burbujas del cliente en gris oscuro (como la app), las nuestras en naranja claro ---------- */
.chats-hilo .bub.in { background: #2a2c33; color: #f2f0ea; box-shadow: 4px 4px 10px rgba(0,0,0,0.25), -2px -2px 6px rgba(255,255,255,0.6); }
.chats-hilo .bub.in .t { color: #a9a79f; }
.chats-hilo .bub.in .adj-doc { background: rgba(255,255,255,0.08); color: #f2f0ea; }
.chats-hilo .bub.in .adj-doc:hover { background: rgba(255,255,255,0.14); }
.chats-hilo .bub.in .adj-cargando { color: #a9a79f; }

/* ---------- Caja de escribir más compacta en celular ---------- */
@media (max-width: 840px) {
  .hilo-pie form .inp.caja-msg { min-height: 44px; padding: 11px 16px; }
  .hilo-pie form .btn.primary, .hilo-pie form .btn.icon { width: 44px !important; height: 44px !important; }
  .hilo-pie .sugerencias { padding-bottom: 2px; }
}

/* ---------- Barra "versión nueva": arriba a la derecha en compu; en celular abajo, sin tapar los botones ---------- */
.barra-version { bottom: auto; top: 16px; right: 16px; }
@media (max-width: 840px) { .barra-version { top: auto; bottom: calc(96px + env(safe-area-inset-bottom)); left: 12px; right: 12px; } }

/* ---------- Calendario de leads (Tablero) ---------- */
.cal-meses { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 18px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-h { font-size: 10px; color: var(--dim); text-align: center; font-weight: 700; padding-bottom: 2px; }
.cal-dia { position: relative; aspect-ratio: 1; border-radius: 9px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  background: rgba(255,255,255,0.04); color: var(--muted); font-size: 11px; }
.cal-dia small { font-size: 10px; line-height: 1; opacity: 0.8; }
.cal-dia b { font-size: 13px; line-height: 1; }
.cal-dia.fuera { opacity: 0.25; }
.cal-dia.n0 { box-shadow: var(--in-sm); }
.cal-dia.n1 { background: rgba(217, 130, 42, 0.28); color: var(--fg); }
.cal-dia.n2 { background: rgba(217, 130, 42, 0.5); color: var(--fg); }
.cal-dia.n3 { background: rgba(217, 130, 42, 0.75); color: #1c1d21; }
.cal-dia.n4 { background: var(--accent); color: #1c1d21; }
.cal-dia.hoy { outline: 2px solid var(--fg); outline-offset: -2px; }
@media (max-width: 840px) { .cal-meses { grid-template-columns: 1fr; } }

/* ---------- Teclado abierto: sin margen inferior (el teclado ya lo cubre) ---------- */
@media (max-width: 840px) {
  .chats-hilo.teclado .hilo-pie { padding-bottom: 6px; }
  .chats-hilo.teclado .hilo-head { padding-top: calc(8px + env(safe-area-inset-top, 0px)); }
}
/* ---------- iPhone app instalada cuando iOS no reporta la franja de la hora ---------- */
@media (max-width: 840px) {
  html.franja-manual .main { padding-top: 50px; }
  html.franja-manual .top-cel { top: 58px; }
  html.franja-manual .chats-hilo .hilo-head { padding-top: 58px; }
  html.franja-manual .chats-hilo.teclado .hilo-head { padding-top: 58px; }
  html.franja-manual .modal-fondo { padding-top: 50px; }
}

/* Ligas dentro de los mensajes */
.bub .liga-msg { color: #b35a00; text-decoration: underline; text-underline-offset: 2px; word-break: break-all; }
.bub.in .liga-msg { color: #f0b46b; }
.bub .liga-msg:hover { color: var(--accent); }

/* ---------- Jalar para actualizar (celular) ---------- */
.jalar { position: fixed; left: 50%; top: calc(8px + env(safe-area-inset-top, 0px)); z-index: 70; display: flex; align-items: center; gap: 8px;
  padding: 8px 14px; border-radius: 999px; background: var(--bg); color: var(--fg); font-size: 12px; font-weight: 600;
  box-shadow: var(--up-sm); pointer-events: none; transition: opacity 0.15s; }
html.franja-manual .jalar { top: 58px; }
.jalar-aro { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--accent); border-top-color: transparent; }
.jalar-aro.girando { animation: girar 0.8s linear infinite; }
@keyframes girar { to { transform: rotate(360deg); } }

/* Nada se desplaza de lado en celular */
@media (max-width: 840px) {
  /* "clip" recorta lo que sobresale sin convertir la página en un área desplazable
     (overflow: hidden en html/body rompe la barra fija de abajo en iOS). */
  .main { overflow-x: clip; }
  .chats-lista, .page-body, .page-head { overflow-x: clip; }
  .chats-lista > .col { padding: 4px 12px 16px 12px !important; }
}


/* ---------- Celular: barra gris con sombra; la pantalla activa, círculo naranja ---------- */
@media (max-width: 840px) {
  .nav a.item.on > span:first-child { background: var(--accent); color: #1c1d21; box-shadow: 3px 3px 8px rgba(0,0,0,0.45), -2px -2px 6px rgba(255,255,255,0.05); }
  .nav a.item.on { color: var(--accent); }
  .nav a.item .badge.flotante { z-index: 1; }
  /* el hilo del chat sigue cubriendo toda la pantalla (incluida la barra) */
  .chats-hilo { position: fixed; inset: 0; z-index: 25; }
}

@media (max-width: 840px) {
  .nav a.item, .nav .item.campana { padding: 0; gap: 3px; font-size: 10px; }
  .nav a.item > span:first-child { width: 40px; height: 40px; }
}

/* ---------- Pulso del día (arriba de los chats) ---------- */
.pulso .lbl { white-space: nowrap; }
.pulso .dim { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 55vw; }
.pulso-fila { display: flex; gap: 10px; overflow-x: auto; scrollbar-width: none; padding: 4px 6px 10px; margin: 0 -6px; -webkit-overflow-scrolling: touch; scroll-snap-type: x proximity; }
.pulso-fila::-webkit-scrollbar { display: none; }
.pulso-card { flex: 0 0 auto; width: 240px; max-width: 80%; display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 16px;
  background: var(--bg); box-shadow: var(--up-sm); color: var(--fg); text-decoration: none; font-size: 13px; line-height: 1.3; scroll-snap-align: start; }
.pulso-card b { font-weight: 700; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pulso-card .muted { font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pulso-card:hover { box-shadow: var(--up); }
.pulso-ico { width: 32px; height: 32px; border-radius: 10px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; background: rgba(255,255,255,0.06); color: var(--muted); }
.pulso-card.espera .pulso-ico { background: var(--accent); color: #1c1d21; }
.pulso-card.ventana .pulso-ico { background: rgba(217, 130, 42, 0.25); color: var(--accent); }
.pulso-card.frio .pulso-ico { background: rgba(200, 73, 58, 0.2); color: #e0786a; }
.pulso-card.tarea .pulso-ico { background: rgba(63, 191, 127, 0.18); color: #3fbf7f; }
.pulso-card.bandeja .pulso-ico { background: var(--accent); color: #1c1d21; }
.pulso-card.al-dia .pulso-ico { background: rgba(63, 191, 127, 0.18); color: #3fbf7f; }
.pulso-card.frase { background: linear-gradient(135deg, rgba(217,130,42,0.18), rgba(217,130,42,0.06)); box-shadow: var(--in-sm); }
.pulso-card.frase b { white-space: normal; font-size: 12px; }
@media (max-width: 840px) { .pulso-card { width: 230px; } }

/* Tarjetas del equipo (admin): más grandes y con color según cómo van */
.pulso-card.grande { width: 300px; max-width: 86%; padding: 12px 14px; font-size: 14px; border-left: 4px solid transparent; }
.pulso-card.grande b { white-space: normal; line-height: 1.25; }
.pulso-card.grande .muted { white-space: normal; }
.pulso-card.grande.mal { border-left-color: #e0786a; }
.pulso-card.grande.mal .avatar { background: rgba(200, 73, 58, 0.25); color: #e0786a; }
.pulso-card.grande.regular { border-left-color: var(--accent); }
.pulso-card.grande.regular .avatar { background: rgba(217, 130, 42, 0.25); color: var(--accent); }
.pulso-card.grande.bien { border-left-color: #3fbf7f; }
.pulso-card.grande.bien .avatar { background: rgba(63, 191, 127, 0.18); color: #3fbf7f; }
.pulso-card.grande.ausente { border-left-color: #6b6b66; opacity: 0.8; }
.pulso-fila.equipo { margin-bottom: 6px; }
@media (max-width: 840px) { .pulso-card.grande { width: 280px; } }

/* Cabecera plegable del Pulso: toda la línea es botón; la flecha gira */
.pulso-cab { display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%; background: none; border: none; padding: 4px 2px 6px; cursor: pointer; font: inherit; color: inherit; text-align: left; }
.pulso-flecha { width: 22px; height: 22px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; color: var(--muted); box-shadow: var(--up-sm); transition: transform 0.2s; }
.pulso-flecha.cerrada { transform: rotate(-90deg); }

/* Pendientes del cliente dentro del chat */
.pend-chat { margin: 8px 20px 0; padding: 6px 10px 8px; border-radius: 12px; background: rgba(255,255,255,0.04); display: flex; flex-direction: column; gap: 6px; }
.pend-chat.vacio { background: transparent; padding-top: 0; padding-bottom: 0; }
.pend-cab { display: flex; align-items: center; gap: 8px; width: 100%; background: none; border: none; color: var(--muted); font: inherit; font-size: 12px; font-weight: 600; padding: 4px 0; cursor: pointer; }
.pend-venc { margin-left: 8px; color: #f0a070; font-weight: 700; }
.pend-fila { display: flex; align-items: center; gap: 10px; min-width: 0; }
.pend-check { width: 22px; height: 22px; border-radius: 50%; flex-shrink: 0; border: none; background: var(--bg-in); box-shadow: inset 0 0 0 2px rgba(255,255,255,0.18); cursor: pointer; }
.pend-check:hover { box-shadow: inset 0 0 0 2px var(--accent); }
.pend-txt { flex: 1; min-width: 0; display: flex; justify-content: space-between; align-items: center; gap: 10px; background: none; border: none; color: var(--fg); font: inherit; font-size: 13px; text-align: left; padding: 2px 0; cursor: pointer; }
.pend-cuando { flex-shrink: 0; font-size: 12px; color: var(--muted); }
.pend-cuando.vencida { color: #f0a070; font-weight: 600; }
.pend-cuando.hoy { color: var(--accent); font-weight: 600; }
@media (max-width: 840px) {
  .pend-chat { margin: 8px 12px 0; }
  .pend-txt { flex-direction: column; align-items: flex-start; gap: 0; }
  .pend-txt > span:first-child { max-width: 100%; }
}
