/* Panel de la inmobiliaria — pensado primero para el celular.
   Una columna, botones grandes, pestañas abajo. En pantallas anchas queda
   centrado en una columna de 620 px. */
:root {
    --bg: #F2F4F5;
    --surface: #FFFFFF;
    --ink: #16242B;
    --muted: #5A6A72;
    --line: #D3DBDF;
    --soft: #E8EDEF;
    --sign: #C4161C;
    --sign-ink: #FFFFFF;
    --bar: #16242B;
    --bar-ink: #FFFFFF;
    --ok: #1B7447;
    --ok-bg: #DDF1E5;
    --warn: #8A5200;
    --warn-bg: #FFEFD0;
    --info: #1F5C8A;
    --info-bg: #DCEBF6;
    --wa-bg: #E6EEE8;
    --wa-in: #FFFFFF;
    --wa-out: #D5F3C6;
    --shadow: 0 1px 2px rgba(22, 36, 43, .08), 0 4px 14px rgba(22, 36, 43, .06);
    --tabs-h: 62px;
    --bar-h: 54px;
    color-scheme: light;
}
@media (prefers-color-scheme: dark) {
    :root {
        --bg: #10181C; --surface: #19242B; --ink: #E6EDF0; --muted: #94A4AC; --line: #2B3A42; --soft: #202D35;
        --sign: #F2545A; --sign-ink: #1A0506; --bar: #0B1114; --bar-ink: #E6EDF0;
        --ok: #62CB96; --ok-bg: #153325; --warn: #F2B65C; --warn-bg: #3A2C10; --info: #7DB9E6; --info-bg: #15293A;
        --wa-bg: #0F1A17; --wa-in: #212E35; --wa-out: #1F4A3A;
        --shadow: 0 1px 2px rgba(0, 0, 0, .4);
        color-scheme: dark;
    }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
    margin: 0; background: var(--bg); color: var(--ink);
    font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    -webkit-tap-highlight-color: transparent;
    overscroll-behavior-y: none;
}
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, p { margin: 0; }
img { max-width: 100%; display: block; }
svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ───────── Estructura ───────── */
#panel, .hoja, #entrada { max-width: 620px; margin: 0 auto; }
#panel { min-height: 100%; padding-top: calc(var(--bar-h) + env(safe-area-inset-top, 0px)); padding-bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom, 0px) + 16px); }
.barra {
    position: fixed; top: 0; left: 0; right: 0; z-index: 20; max-width: 620px; margin: 0 auto;
    height: calc(var(--bar-h) + env(safe-area-inset-top, 0px)); padding: env(safe-area-inset-top, 0px) 16px 0;
    background: var(--bar); color: var(--bar-ink);
    display: flex; align-items: center; gap: 10px;
}
.barra h1 { font-size: 18px; font-weight: 650; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.barra .atras { background: none; border: 0; color: inherit; padding: 8px; margin-left: -10px; display: grid; }
.estado-wa { border: 0; background: rgba(255, 255, 255, .12); color: inherit; border-radius: 99px; padding: 6px 11px; font-size: 12.5px; display: flex; align-items: center; gap: 6px; }
.estado-wa::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #E0A93B; }
.estado-wa.ok::before { background: #4CD08A; }
.estado-wa.mal::before { background: #F2545A; }

#vista { padding: 14px 16px; display: flex; flex-direction: column; gap: 12px; }

.pestanas {
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 20; max-width: 620px; margin: 0 auto;
    height: calc(var(--tabs-h) + env(safe-area-inset-bottom, 0px)); padding-bottom: env(safe-area-inset-bottom, 0px);
    background: var(--surface); border-top: 1px solid var(--line);
    display: grid; grid-template-columns: repeat(4, 1fr);
}
.pestanas button { position: relative; border: 0; background: none; color: var(--muted); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 11.5px; }
.pestanas button.activa { color: var(--sign); font-weight: 650; }
.pestanas .globo { position: absolute; top: 6px; left: calc(50% + 6px); min-width: 19px; height: 19px; padding: 0 5px; border-radius: 99px; background: var(--sign); color: var(--sign-ink); font: 700 11.5px/19px system-ui; font-style: normal; text-align: center; }

.hoja { position: fixed; inset: 0; z-index: 30; background: var(--bg); display: flex; flex-direction: column; }
.hoja .barra { position: static; flex: none; margin: 0; max-width: none; }
.hoja-cuerpo { flex: 1; overflow-y: auto; padding: 14px 16px 28px; display: flex; flex-direction: column; gap: 14px; -webkit-overflow-scrolling: touch; }
.hoja-pie { flex: none; padding: 10px 16px calc(10px + env(safe-area-inset-bottom, 0px)); background: var(--surface); border-top: 1px solid var(--line); display: flex; gap: 10px; }
.hoja-pie > * { flex: 1; }
#hoja-acciones { display: flex; gap: 6px; flex: none; }

/* ───────── Piezas ───────── */
.tarjeta { background: var(--surface); border-radius: 14px; box-shadow: var(--shadow); padding: 14px; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.tarjeta > h2 { font-size: 15px; font-weight: 650; }
.ayuda { color: var(--muted); font-size: 13.5px; }
.vacio { text-align: center; color: var(--muted); padding: 34px 18px; display: flex; flex-direction: column; gap: 6px; align-items: center; }
.vacio b { color: var(--ink); font-size: 17px; }

.boton { min-height: 48px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); padding: 0 16px; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; color: var(--ink); }
.boton.principal { background: var(--sign); border-color: var(--sign); color: var(--sign-ink); }
.boton.oscuro { background: var(--ink); border-color: var(--ink); color: var(--surface); }
.boton.chico { min-height: 38px; padding: 0 12px; font-size: 14px; border-radius: 10px; white-space: nowrap; }
.boton.peligro { color: var(--sign); }
.boton.ancho { width: 100%; }
.boton:disabled { opacity: .55; }
.boton:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, .pestanas button:focus-visible { outline: 2px solid var(--sign); outline-offset: 2px; }
.fila { display: flex; gap: 10px; flex-wrap: wrap; }
.fila > * { flex: 1; min-width: 0; }

label.campo { display: flex; flex-direction: column; gap: 5px; font-size: 13.5px; color: var(--muted); min-width: 0; }
input[type=text], input[type=number], input[type=password], input[type=date], input[type=time], input[type=tel], select, textarea {
    width: 100%; min-height: 46px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink); padding: 10px 12px; font-size: 16px;
}
textarea { min-height: 96px; resize: vertical; line-height: 1.4; }
.interruptor { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; }
.interruptor input { width: 22px; height: 22px; accent-color: var(--sign); }

.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { min-height: 38px; border: 1px solid var(--line); border-radius: 99px; padding: 0 14px; background: var(--surface); font-size: 14px; }
.chip.on { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.segmento { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--soft); border-radius: 12px; padding: 4px; gap: 4px; }
.segmento button { border: 0; background: none; min-height: 40px; border-radius: 9px; font-size: 14px; font-weight: 600; color: var(--muted); }
.segmento button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }

.pill { display: inline-block; border-radius: 99px; padding: 2px 9px; font-size: 12px; font-weight: 650; background: var(--soft); color: var(--muted); white-space: nowrap; }
.pill.disponible { background: var(--ok-bg); color: var(--ok); }
.pill.reservada, .pill.pedida, .pill.falta { background: var(--warn-bg); color: var(--warn); }
.pill.borrador { background: var(--info-bg); color: var(--info); }
.pill.confirmada { background: var(--ok-bg); color: var(--ok); }
.pill.atencion { background: var(--sign); color: var(--sign-ink); }

/* ───────── Propiedades ───────── */
.prop { display: grid; grid-template-columns: 84px 1fr; gap: 12px; align-items: center; background: var(--surface); border-radius: 14px; box-shadow: var(--shadow); padding: 10px; border: 0; text-align: left; width: 100%; }
.prop .foto { width: 84px; height: 84px; border-radius: 10px; object-fit: cover; background: var(--soft); display: grid; place-items: center; color: var(--muted); }
.prop .datos { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.prop b { font-size: 15.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prop .precio { color: var(--muted); font-size: 14px; font-variant-numeric: tabular-nums; }
.prop .pie { display: flex; gap: 8px; align-items: center; font-size: 12.5px; color: var(--muted); flex-wrap: wrap; }
.flotante { position: fixed; right: max(16px, calc(50% - 294px)); bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom, 0px) + 14px); z-index: 15; box-shadow: 0 6px 18px rgba(196, 22, 28, .35); border-radius: 99px; padding: 0 20px; }

/* Editor */
.pasos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.pasos button { border: 0; background: var(--soft); min-height: 42px; border-radius: 10px; font-size: 13.5px; font-weight: 600; color: var(--muted); }
.pasos button.on { background: var(--ink); color: var(--surface); }
.fotos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.fotos .f { position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: var(--soft); }
.fotos .f img { width: 100%; height: 100%; object-fit: cover; }
.fotos .f .x { position: absolute; top: 4px; right: 4px; width: 30px; height: 30px; border-radius: 50%; border: 0; background: rgba(0, 0, 0, .6); color: #fff; font-size: 18px; line-height: 1; }
.fotos .f .portada { position: absolute; left: 4px; bottom: 4px; background: rgba(0, 0, 0, .6); color: #fff; font-size: 11px; padding: 2px 7px; border-radius: 99px; border: 0; }
.fotos .mas { aspect-ratio: 1; border: 2px dashed var(--line); border-radius: 10px; background: none; color: var(--muted); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; font-size: 13px; }
.trio { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 8px; min-height: 44px; }
.trio .segmento { grid-auto-columns: auto; }
.trio .segmento button { min-height: 34px; font-size: 13px; padding: 0 11px; white-space: nowrap; }
.grabando { color: var(--sign); font-weight: 650; }
.speech-caja textarea { min-height: 130px; }

/* ───────── Consultas ───────── */
.chat-item { display: grid; grid-template-columns: 46px 1fr auto; gap: 12px; align-items: center; background: var(--surface); border-radius: 14px; box-shadow: var(--shadow); padding: 12px; border: 0; text-align: left; width: 100%; }
.avatar { width: 46px; height: 46px; border-radius: 50%; background: var(--soft); display: grid; place-items: center; font-weight: 700; color: var(--muted); }
.chat-item .datos { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.chat-item .ultimo { color: var(--muted); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-item .lado { display: flex; flex-direction: column; align-items: flex-end; gap: 5px; font-size: 12px; color: var(--muted); }
.cuenta { min-width: 21px; height: 21px; padding: 0 6px; border-radius: 99px; background: var(--ok); color: #fff; font: 700 12px/21px system-ui; text-align: center; }

.chat { background: var(--wa-bg); padding: 12px; gap: 8px; }
.resumen { background: var(--warn-bg); color: var(--ink); border-radius: 12px; padding: 10px 12px; font-size: 14px; white-space: pre-wrap; }
.globo-msg { max-width: 84%; padding: 8px 10px; border-radius: 12px; background: var(--wa-in); align-self: flex-start; white-space: pre-wrap; word-break: break-word; font-size: 15px; box-shadow: 0 1px 1px rgba(0, 0, 0, .06); }
.globo-msg.bot, .globo-msg.operador { background: var(--wa-out); align-self: flex-end; }
.globo-msg small { display: block; color: var(--muted); font-size: 11px; margin-top: 3px; text-align: right; }
.globo-msg img { border-radius: 8px; max-height: 260px; margin-bottom: 4px; }
.globo-msg audio { width: 230px; max-width: 100%; }
.redactar { display: flex; gap: 8px; align-items: flex-end; }
.redactar textarea { min-height: 46px; max-height: 140px; }
.redactar .boton { flex: none; }

.visita { display: flex; flex-direction: column; gap: 8px; }
.visita .cuando { font-size: 16px; font-weight: 650; }
.visita .cuando::first-letter { text-transform: uppercase; }

/* ───────── Pendientes ───────── */
.pend .pregunta { font-size: 17px; font-weight: 650; }
.pend .de { display: flex; gap: 10px; align-items: center; color: var(--muted); font-size: 13.5px; }
.pend .de img { width: 40px; height: 40px; border-radius: 8px; object-fit: cover; }
.tres { display: grid; grid-template-columns: 1fr 1fr 1.3fr; gap: 8px; }

/* ───────── Ajustes ───────── */
.lista { background: var(--surface); border-radius: 14px; box-shadow: var(--shadow); overflow: hidden; }
.lista button { width: 100%; border: 0; border-bottom: 1px solid var(--line); background: none; text-align: left; padding: 14px; display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 58px; }
.lista button:last-child { border-bottom: 0; }
.lista small { display: block; color: var(--muted); font-size: 13px; font-weight: 400; }
.lista .flecha { color: var(--muted); flex: none; }
.qr { align-self: center; width: 240px; height: 240px; border-radius: 12px; background: #fff; padding: 8px; }
.item { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); min-width: 0; }
.item:last-child { border-bottom: 0; }
.item > div { min-width: 0; }
.item small { color: var(--muted); display: block; }

/* ───────── Entrada ───────── */
#entrada { min-height: 100%; padding: 12vh 22px 30px; display: flex; flex-direction: column; gap: 18px; }
#entrada .marca { display: flex; flex-direction: column; gap: 6px; }
#entrada .cartel { align-self: flex-start; background: var(--sign); color: var(--sign-ink); font-weight: 800; letter-spacing: .08em; text-transform: uppercase; font-size: 12px; padding: 4px 10px; }
#entrada h1 { font-size: 28px; line-height: 1.1; }
#entrada form { display: flex; flex-direction: column; gap: 12px; }

/* ───────── Diálogo y avisos ───────── */
.dialogo { position: fixed; inset: 0; z-index: 50; background: rgba(10, 16, 19, .55); display: flex; align-items: flex-end; justify-content: center; }
.dialogo-caja { width: 100%; max-width: 620px; background: var(--surface); border-radius: 18px 18px 0 0; padding: 20px 18px calc(18px + env(safe-area-inset-bottom, 0px)); display: flex; flex-direction: column; gap: 12px; max-height: 92vh; overflow-y: auto; }
.dialogo-caja h2 { font-size: 18px; }
.avisos { position: fixed; left: 0; right: 0; bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom, 0px) + 12px); z-index: 60; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; padding: 0 16px; }
.aviso { background: var(--ink); color: var(--surface); padding: 11px 16px; border-radius: 12px; font-size: 14.5px; box-shadow: var(--shadow); max-width: 100%; }
.aviso.error { background: var(--sign); color: var(--sign-ink); }

@media (min-width: 621px) {
    body { background: var(--soft); }
    #panel, .hoja { background: var(--bg); }
    .hoja { left: 50%; right: auto; width: 620px; transform: translateX(-50%); }
}
@media (prefers-reduced-motion: no-preference) {
    .hoja { animation: entra .16s ease-out; }
    @keyframes entra { from { opacity: 0; translate: 0 12px; } to { opacity: 1; translate: 0 0; } }
}
