/* Panel de la inmobiliaria: pensado primero para usar desde el celular. */
:root {
  --marca: #0f4c5c;
  --fondo: #f3f5f7;
  --texto: #1d2329;
  --suave: #5f6b76;
  --borde: #dfe4e8;
  --ok: #157f3c;
  --mal: #b42318;
  --wa: #1fa855;
  --radio: 12px;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: 'DM Sans', system-ui, sans-serif; background: var(--fondo); color: var(--texto); line-height: 1.45; -webkit-text-size-adjust: 100%; }
a { color: var(--marca); }
h1, h2, h3 { margin: 0; line-height: 1.2; }
button, input, select, textarea { font: inherit; color: inherit; }
.cargando { text-align: center; color: var(--suave); padding: 60px 0; }
[hidden] { display: none !important; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 42px; padding: 0 16px; border-radius: 10px; border: 0; background: var(--marca); color: #fff; font-weight: 700; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { filter: brightness(1.08); }
.btn-sec { background: #fff; color: var(--texto); border: 1px solid var(--borde); font-weight: 500; }
.btn-peligro { background: #fff; color: var(--mal); border: 1px solid #f3c7c2; font-weight: 500; }
.btn-wa { background: var(--wa); }
.btn-chico { min-height: 34px; padding: 0 12px; font-size: .88rem; }
.btn[disabled] { opacity: .6; cursor: progress; }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login form { background: #fff; padding: 28px; border-radius: 16px; width: min(380px, 100%); box-shadow: 0 8px 30px rgba(0, 0, 0, .08); display: grid; gap: 14px; }
.login h1 { font-size: 1.3rem; }
.login p { margin: 0; color: var(--suave); font-size: .92rem; }

/* Estructura */
.barra { background: var(--marca); color: #fff; position: sticky; top: 0; z-index: 50; }
.barra-in { max-width: 1100px; margin: 0 auto; padding: 0 16px; display: flex; align-items: center; gap: 8px; min-height: 56px; }
.barra .nombre { font-weight: 700; margin-right: auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.barra a, .barra button { color: #fff; background: none; border: 0; cursor: pointer; font-size: .9rem; text-decoration: none; opacity: .85; }
.barra a:hover, .barra button:hover { opacity: 1; }
.nav { background: #fff; border-bottom: 1px solid var(--borde); position: sticky; top: 56px; z-index: 40; }
.nav-in { max-width: 1100px; margin: 0 auto; padding: 0 8px; display: flex; overflow-x: auto; }
.nav a { padding: 14px 14px 12px; text-decoration: none; color: var(--suave); font-weight: 500; border-bottom: 3px solid transparent; white-space: nowrap; }
.nav a.activo { color: var(--marca); border-color: var(--marca); }
.nav a b { background: var(--mal); color: #fff; border-radius: 999px; font-size: .72rem; padding: 1px 7px; margin-left: 4px; }
main { max-width: 1100px; margin: 0 auto; padding: 18px 16px 80px; }
.cab-seccion { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.cab-seccion h1 { font-size: 1.35rem; }
.caja { background: #fff; border: 1px solid var(--borde); border-radius: var(--radio); padding: 16px; }
.caja + .caja { margin-top: 14px; }
.caja h2 { font-size: 1.05rem; margin-bottom: 12px; }
.suave { color: var(--suave); }
.chico { font-size: .85rem; }

/* Inicio */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 14px; }
.kpi { background: #fff; border: 1px solid var(--borde); border-radius: var(--radio); padding: 14px 16px; text-decoration: none; color: inherit; }
.kpi strong { display: block; font-size: 1.8rem; }
.kpi span { color: var(--suave); font-size: .88rem; }
.kpi.alerta strong { color: var(--mal); }
.top li { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--borde); }
.top { list-style: none; margin: 0; padding: 0; }

/* Herramientas de lista */
.filtros { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.filtros input, .filtros select { height: 42px; border: 1px solid var(--borde); border-radius: 10px; padding: 0 12px; background: #fff; }
.filtros input { flex: 1; min-width: 180px; }
.pestanas { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 12px; padding-bottom: 2px; }
.pestanas button { border: 1px solid var(--borde); background: #fff; border-radius: 999px; padding: 6px 12px; cursor: pointer; white-space: nowrap; font-size: .88rem; }
.pestanas button.activo { background: var(--marca); color: #fff; border-color: var(--marca); }

/* Propiedades */
.props { display: grid; gap: 10px; }
.prop { background: #fff; border: 1px solid var(--borde); border-radius: var(--radio); display: grid; grid-template-columns: 112px 1fr; gap: 14px; padding: 10px; align-items: start; }
.prop.oculta { opacity: .7; }
.prop-foto { width: 112px; height: 84px; border-radius: 8px; object-fit: cover; background: #e3e8ec; display: block; }
.prop h3 { font-size: 1rem; margin-bottom: 2px; }
.prop h3 a { color: inherit; text-decoration: none; }
.prop .meta { color: var(--suave); font-size: .85rem; }
.prop-acciones { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 8px; }
.prop-acciones select { height: 34px; border: 1px solid var(--borde); border-radius: 8px; padding: 0 8px; background: #fff; font-size: .88rem; }
.precio-edit { display: inline-flex; align-items: center; gap: 4px; border: 1px dashed var(--borde); border-radius: 8px; padding: 4px 8px; cursor: pointer; font-weight: 700; background: #fff; }
.precio-edit:hover { border-color: var(--marca); }
.precio-edit input { width: 120px; border: 0; outline: 0; font-weight: 700; padding: 0; }
.estrella { border: 0; background: none; font-size: 1.3rem; cursor: pointer; color: #c6ccd2; padding: 0 4px; line-height: 1; }
.estrella.on { color: #f5a524; }
.badge { display: inline-block; font-size: .78rem; padding: 2px 8px; border-radius: 999px; background: #eef1f4; color: var(--suave); text-decoration: none; }
.badge.caliente { background: #fdecea; color: var(--mal); font-weight: 700; }
.estado-disponible { color: var(--ok); }
.estado-reservada { color: #b26b00; }
@media (max-width: 560px) { .prop { grid-template-columns: 84px 1fr; } .prop-foto { width: 84px; height: 70px; } }

/* Formulario de propiedad */
.form { display: grid; gap: 14px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.grid4 { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 12px; }
label.campo { display: grid; gap: 4px; font-size: .85rem; font-weight: 700; color: var(--suave); }
.campo input, .campo select, .campo textarea { border: 1px solid var(--borde); border-radius: 10px; padding: 10px 12px; background: #fff; font-weight: 400; color: var(--texto); width: 100%; min-height: 44px; }
.campo textarea { resize: vertical; min-height: 140px; }
.campo input:focus, .campo select:focus, .campo textarea:focus { outline: 2px solid color-mix(in srgb, var(--marca) 35%, transparent); border-color: var(--marca); }
.check { display: flex; gap: 8px; align-items: center; cursor: pointer; font-size: .95rem; }
.check input { width: 20px; height: 20px; accent-color: var(--marca); }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.segmento { display: inline-flex; border: 1px solid var(--borde); border-radius: 10px; overflow: hidden; background: #fff; }
.segmento label { cursor: pointer; }
.segmento input { position: absolute; opacity: 0; }
.segmento span { display: block; padding: 10px 16px; font-weight: 500; }
.segmento input:checked + span { background: var(--marca); color: #fff; }
.conversion { font-size: .88rem; color: var(--suave); }
.mapa-elegir { height: 280px; border-radius: 10px; border: 1px solid var(--borde); }
.guardar-fijo { position: sticky; bottom: 0; background: linear-gradient(transparent, var(--fondo) 30%); padding: 18px 0 calc(8px + env(safe-area-inset-bottom)); display: flex; gap: 10px; justify-content: flex-end; z-index: 30; }

/* Fotos */
.fotos { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
.foto { position: relative; border-radius: 10px; overflow: hidden; background: #e3e8ec; aspect-ratio: 4 / 3; cursor: grab; border: 2px solid transparent; }
.foto.arrastrando { opacity: .4; }
.foto.sobre { border-color: var(--marca); }
.foto img { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }
.foto .portada { position: absolute; left: 6px; top: 6px; background: var(--marca); color: #fff; font-size: .72rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; }
.foto .acciones { position: absolute; right: 4px; top: 4px; display: flex; gap: 4px; }
.foto .acciones button { width: 30px; height: 30px; border-radius: 50%; border: 0; background: rgba(0, 0, 0, .6); color: #fff; cursor: pointer; font-size: .95rem; display: grid; place-items: center; }
.foto .mover { position: absolute; bottom: 4px; left: 4px; right: 4px; display: flex; justify-content: space-between; }
.foto .mover button { width: 30px; height: 30px; border-radius: 50%; border: 0; background: rgba(255, 255, 255, .9); cursor: pointer; }
.subir { border: 2px dashed var(--borde); border-radius: 10px; display: grid; place-items: center; text-align: center; padding: 10px; cursor: pointer; aspect-ratio: 4 / 3; color: var(--suave); font-size: .9rem; background: #fafbfc; }
.subir:hover, .subir.sobre { border-color: var(--marca); color: var(--marca); }
.subir input { display: none; }
.progreso { font-size: .88rem; color: var(--marca); margin-top: 8px; }

/* Interesados */
.clientes { display: grid; gap: 10px; }
.cliente { background: #fff; border: 1px solid var(--borde); border-radius: var(--radio); padding: 14px; display: grid; gap: 10px; }
.cliente-cab { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; align-items: start; }
.cliente h3 { font-size: 1.05rem; }
.cliente .tel { color: var(--suave); font-size: .9rem; }
.cliente-acc { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.cliente-acc select { height: 36px; border: 1px solid var(--borde); border-radius: 8px; padding: 0 8px; background: #fff; }
.consultas { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.consultas li { background: var(--fondo); border-radius: 8px; padding: 8px 10px; font-size: .9rem; display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.consultas .msg { width: 100%; color: var(--suave); font-size: .85rem; font-style: italic; }
.cliente textarea { border: 1px solid var(--borde); border-radius: 8px; padding: 8px 10px; width: 100%; min-height: 60px; resize: vertical; font-size: .92rem; }
.est-nuevo { background: #fdecea; color: var(--mal); }
.est-contactado { background: #e8f1fd; color: #1756a9; }
.est-visita { background: #fff4e0; color: #9a5b00; }
.est-negociando { background: #f1e9fd; color: #6b2fbf; }
.est-cerrado { background: #e6f6ec; color: var(--ok); }
.est-descartado { background: #eef1f4; color: var(--suave); }

/* Avisos */
#avisos { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); display: grid; gap: 8px; z-index: 300; width: min(420px, calc(100% - 32px)); }
.aviso { background: #1d2329; color: #fff; padding: 12px 16px; border-radius: 10px; box-shadow: 0 8px 24px rgba(0, 0, 0, .25); font-size: .92rem; animation: entrar .2s; }
.aviso.mal { background: var(--mal); }
@keyframes entrar { from { transform: translateY(10px); opacity: 0; } }

.vacio { text-align: center; padding: 40px 16px; color: var(--suave); }

/* El mapa no se pone encima de la barra ni de los botones fijos. */
.mapa-elegir { position: relative; z-index: 0; isolation: isolate; }

/* ---------- CRM ---------- */
/* Para hoy */
.agenda { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.agenda li { display: grid; grid-template-columns: 110px 1fr auto; gap: 12px; align-items: center; padding: 10px 12px; border-radius: 10px; background: var(--fondo); border-left: 4px solid var(--marca); }
.agenda li.tarde { border-left-color: var(--mal); background: #fdf3f2; }
.agenda-hora { font-weight: 700; font-size: .92rem; }
.agenda-hora b { display: block; color: var(--mal); font-size: .75rem; }
.agenda-txt a { color: inherit; }
.agenda-acc { display: flex; gap: 6px; }
@media (max-width: 600px) { .agenda li { grid-template-columns: 1fr; gap: 6px; } }

/* Lo que trajo la web */
.kpis-mes { margin-bottom: 8px; }
.kpis-mes .kpi { background: var(--fondo); border: 0; }
.barras { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 8px; }
.barras li { display: grid; grid-template-columns: 130px 1fr auto; gap: 10px; align-items: center; font-size: .9rem; }
.barras-barra { height: 10px; background: var(--fondo); border-radius: 999px; overflow: hidden; }
.barras-barra i { display: block; height: 100%; background: #9aa8b4; border-radius: 999px; }
.barras-barra i.web { background: var(--marca); }
.barras-n { color: var(--suave); white-space: nowrap; }

/* Tarjetas de la lista */
.cliente h3 a { color: inherit; text-decoration: none; }
.cliente h3 a:hover { text-decoration: underline; }
.recordatorio { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; background: #eef5f7; color: var(--marca); border-radius: 8px; padding: 8px 10px; font-size: .9rem; font-weight: 500; }
.recordatorio.tarde { background: #fdecea; color: var(--mal); }
.busca-linea { font-size: .9rem; color: var(--suave); }
.cliente-pie { text-align: right; font-size: .9rem; }
.badge-match { background: #fff4d6; color: #8a5a00; font-weight: 700; }

/* Ficha del cliente */
.rapidos { display: flex; gap: 6px; flex-wrap: wrap; }
.sugerencias { display: grid; gap: 8px; }
.sug { display: grid; grid-template-columns: 72px 1fr auto; gap: 12px; align-items: center; padding: 8px; border: 1px solid var(--borde); border-radius: 10px; }
.sug img, .sug-sin { width: 72px; height: 54px; object-fit: cover; border-radius: 6px; background: #e3e8ec; }
.historial { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.historial li { display: grid; grid-template-columns: 26px 1fr auto; gap: 8px; padding: 7px 0; border-bottom: 1px solid var(--borde); font-size: .92rem; align-items: baseline; }
.caja.destacar { border-color: #f5c66a; background: #fffbf0; }
.top li > span:first-child { min-width: 0; }

/* CRM simplificado */
.pestanas button span { opacity: .7; margin-left: 2px; }
.cliente-nombre { text-decoration: none; color: inherit; min-width: 0; }
.cliente-nombre:hover h3 { text-decoration: underline; }
.cliente-nombre .tel { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 60vw; }
.nota-rec { width: 100%; border: 1px solid var(--borde); border-radius: 8px; padding: 8px 10px; margin: 8px 0 10px; }
.rapidos { align-items: center; margin-top: 4px; }
.elegir { position: relative; overflow: hidden; }
.elegir input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.plegable { padding: 0; }
.plegable summary { cursor: pointer; padding: 14px 16px; font-weight: 700; list-style: none; display: flex; align-items: center; gap: 8px; }
.plegable summary::-webkit-details-marker { display: none; }
.plegable summary::after { content: '›'; margin-left: auto; color: var(--suave); font-size: 1.3rem; transition: transform .15s; }
.plegable[open] summary::after { transform: rotate(90deg); }
.plegable .resumen { font-weight: 400; color: var(--suave); font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plegable-in { padding: 0 16px 16px; display: grid; gap: 12px; }
