/* App QuitoWeb · los colores y letras del sitio (papel, tinta, terracota; jade para la IA). */
@font-face { font-family: 'Geist'; font-weight: 300 700; font-display: swap; src: url('/fuentes/geist-f49f83ef.woff2') format('woff2'); }
@font-face { font-family: 'Instrument Serif'; font-weight: 400; font-display: swap; src: url('/fuentes/instrumentserif-37ddf465.woff2') format('woff2'); }

:root {
  --bg: #F4F1EA; --card: #FBF9F4; --card-2: #EDE9E0; --text: #14110D; --muted: #6B655C; --rule: rgba(20,17,13,.12); --rule-strong: rgba(20,17,13,.28);
  --accent: #C8452B; --accent-text: #A8331B; --accent-soft: rgba(200,69,43,.10); --on-accent: #FFF8F1;
  --jade: #2F8A66; --jade-soft: rgba(70,168,129,.14);
  --out: #14110D; --on-out: #F4F1EA; --nota: #F6E7B8; --on-nota: #4A3A0B;
  --f-body: 'Geist', ui-sans-serif, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
  --f-display: 'Instrument Serif', 'Iowan Old Style', Georgia, serif;
  --nav-h: 64px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #12110E; --card: #1B1A16; --card-2: #24221D; --text: #EFE9DA; --muted: #A39C90; --rule: rgba(239,233,218,.12); --rule-strong: rgba(239,233,218,.28);
    --accent: #E8693A; --accent-text: #F08A60; --accent-soft: rgba(232,105,58,.16); --on-accent: #1A0F09;
    --jade: #6CC9A3; --jade-soft: rgba(108,201,163,.16); --out: #EFE9DA; --on-out: #14110D; --nota: #3A3115; --on-nota: #F3E2A6; color-scheme: dark; }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 16px/1.45 var(--f-body); -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; overscroll-behavior-y: none; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
a { color: var(--accent-text); }

/* ── Ingreso ── */
.ingreso { min-height: 100dvh; display: grid; place-items: center; padding: max(24px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left)); }
.ingreso-caja { width: 100%; max-width: 380px; display: grid; gap: 20px; }
.marca { display: flex; align-items: center; gap: 12px; }
.marca img { width: 44px; height: 44px; border-radius: 11px; }
.marca b { font-size: 20px; letter-spacing: -.01em; }
.ingreso h1 { font: 400 40px/1.05 var(--f-display); margin: 8px 0 0; letter-spacing: -.01em; text-wrap: balance; }
.ingreso p { margin: 0; color: var(--muted); }
.campo { display: grid; gap: 6px; }
.campo label { font-size: 13px; color: var(--muted); }
.campo input { width: 100%; padding: 14px 16px; border-radius: 12px; border: 1px solid var(--rule-strong); background: var(--card); font-size: 17px; outline: none; }
.campo input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.campo input.codigo { font-size: 28px; letter-spacing: .4em; text-align: center; font-variant-numeric: tabular-nums; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 12px; padding: 14px 18px; font-weight: 600; background: var(--accent); color: var(--on-accent); }
.btn:disabled { opacity: .55; }
.btn.sec { background: transparent; color: var(--text); border: 1px solid var(--rule-strong); }
.btn.mini { padding: 8px 12px; border-radius: 10px; font-size: 14px; }
.error { color: var(--accent-text); font-size: 14px; min-height: 1em; }
.enlace { background: none; border: 0; padding: 0; color: var(--accent-text); font-size: 14px; text-decoration: underline; justify-self: start; }

/* ── Estructura con barra de abajo ── */
.app { min-height: 100dvh; padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom)); }
.cabeza { position: sticky; top: 0; z-index: 5; background: var(--bg); padding: calc(14px + env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 10px max(16px, env(safe-area-inset-left)); border-bottom: 1px solid var(--rule); }
.cabeza h1 { font: 400 32px/1.1 var(--f-display); margin: 0; letter-spacing: -.01em; }
.cabeza .sub { color: var(--muted); font-size: 14px; margin-top: 2px; }
.contenido { padding: 16px max(16px, env(safe-area-inset-right)) 24px max(16px, env(safe-area-inset-left)); display: grid; gap: 20px; max-width: 760px; margin: 0 auto; }
.nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: grid; grid-template-columns: repeat(3, 1fr); background: var(--card); border-top: 1px solid var(--rule);
  padding: 0 max(8px, env(safe-area-inset-right)) env(safe-area-inset-bottom) max(8px, env(safe-area-inset-left)); }
.nav button { height: var(--nav-h); border: 0; background: none; display: grid; place-items: center; align-content: center; gap: 3px; font-size: 12px; color: var(--muted); position: relative; }
.nav button svg { width: 24px; height: 24px; }
.nav button.activo { color: var(--text); font-weight: 600; }
.nav button.activo svg { color: var(--accent); }
.globo { position: absolute; top: 9px; left: calc(50% + 6px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--accent); color: var(--on-accent); font-size: 11px; font-weight: 700; display: grid; place-items: center; }

/* ── Para hoy ── */
.seccion h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 0 0 8px; font-weight: 600; }
.cifras { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.cifra { background: var(--card); border: 1px solid var(--rule); border-radius: 14px; padding: 12px; }
.cifra b { display: block; font: 400 34px/1 var(--f-display); }
.cifra span { font-size: 13px; color: var(--muted); }
.cifra.alerta b { color: var(--accent-text); }
.cifra.ia b { color: var(--jade); }
.vacio { background: var(--card); border: 1px dashed var(--rule-strong); border-radius: 14px; padding: 16px; color: var(--muted); font-size: 15px; }
.lista { display: grid; background: var(--card); border: 1px solid var(--rule); border-radius: 14px; overflow: hidden; }
.cita { display: grid; grid-template-columns: 64px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 12px 14px; border-top: 1px solid var(--rule); }
.cita:first-child { border-top: 0; }
.cita .hora { font-weight: 600; font-variant-numeric: tabular-nums; }
.cita .quien { min-width: 0; }
.cita .quien b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cita .quien span { color: var(--muted); font-size: 14px; }
.cita a { font-size: 14px; }

/* ── Lista de chats ── */
.filtros { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; }
.filtros button { flex: none; border: 1px solid var(--rule-strong); background: transparent; border-radius: 999px; padding: 7px 14px; font-size: 14px; }
.filtros button.activo { background: var(--text); color: var(--bg); border-color: var(--text); }
.buscar { width: 100%; padding: 11px 14px; border-radius: 12px; border: 1px solid var(--rule); background: var(--card); outline: none; }
.chat-fila { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 12px 14px; border: 0; border-top: 1px solid var(--rule); background: none; text-align: left; width: 100%; }
.chat-fila:first-child { border-top: 0; }
.chat-fila:active { background: var(--card-2); }
.avatar { width: 44px; height: 44px; border-radius: 50%; background: var(--card-2); display: grid; place-items: center; font-weight: 600; color: var(--muted); overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.chat-fila .medio { min-width: 0; display: grid; gap: 2px; }
.chat-fila .nombre { display: flex; min-width: 0; gap: 6px; align-items: center; font-weight: 600; }
.chat-fila .nombre span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-fila .ultimo { display: block; color: var(--muted); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-fila .der { display: grid; justify-items: end; gap: 4px; font-size: 12px; color: var(--muted); }
.chat-fila .n { min-width: 20px; height: 20px; border-radius: 10px; padding: 0 6px; background: var(--accent); color: var(--on-accent); font-size: 12px; font-weight: 700; display: grid; place-items: center; }
.etq { font-size: 11px; font-weight: 600; padding: 2px 7px; border-radius: 999px; white-space: nowrap; flex: none; }
.etq.ia { background: var(--jade-soft); color: var(--jade); }
.etq.persona { background: var(--accent-soft); color: var(--accent-text); }
.mas { justify-self: center; }

/* ── Conversación ── */
.conv { position: fixed; inset: 0; z-index: 20; background: var(--bg); display: flex; flex-direction: column; }
.conv .mensajes { flex: 1; }
.conv-cabeza { display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; gap: 8px; align-items: center; padding: calc(8px + env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) 8px max(6px, env(safe-area-inset-left)); border-bottom: 1px solid var(--rule); background: var(--card); }
.icono { width: 40px; height: 40px; border: 0; border-radius: 10px; background: none; display: grid; place-items: center; }
.icono svg { width: 24px; height: 24px; }
.conv-cabeza .titulo { min-width: 0; border: 0; background: none; text-align: left; padding: 0; }
.conv-cabeza .titulo b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-cabeza .titulo span { font-size: 13px; color: var(--muted); }
.barra-ia { display: flex; align-items: center; gap: 10px; justify-content: space-between; padding: 8px max(14px, env(safe-area-inset-right)) 8px max(14px, env(safe-area-inset-left)); font-size: 14px; border-bottom: 1px solid var(--rule); }
.barra-ia.activa { background: var(--jade-soft); }
.barra-ia.pausada { background: var(--accent-soft); }
.barra-ia .txt { min-width: 0; }
.mensajes { overflow-y: auto; padding: 12px max(12px, env(safe-area-inset-right)) 12px max(12px, env(safe-area-inset-left)); display: flex; flex-direction: column; gap: 6px; overscroll-behavior: contain; }
.dia { align-self: center; font-size: 12px; color: var(--muted); background: var(--card-2); padding: 3px 10px; border-radius: 999px; margin: 8px 0 4px; }
.msj { max-width: min(80%, 520px); padding: 8px 12px; border-radius: 16px; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 15px; }
.msj .pie { display: block; font-size: 11px; opacity: .7; margin-top: 3px; text-align: right; }
.msj.cliente { align-self: flex-start; background: var(--card); border: 1px solid var(--rule); border-bottom-left-radius: 6px; }
.msj.persona { align-self: flex-end; background: var(--out); color: var(--on-out); border-bottom-right-radius: 6px; }
.msj.ia { align-self: flex-end; background: var(--jade-soft); color: var(--text); border: 1px solid var(--jade-soft); border-bottom-right-radius: 6px; }
.msj.nota { align-self: center; background: var(--nota); color: var(--on-nota); font-size: 13px; border-radius: 10px; max-width: 92%; }
.msj.sistema { align-self: center; background: none; color: var(--muted); font-size: 12px; padding: 2px 8px; }
.msj img, .msj video { display: block; max-width: 100%; max-height: 320px; border-radius: 10px; margin: 2px 0; }
.msj audio { width: 240px; max-width: 100%; display: block; }
.msj .archivo { display: inline-flex; gap: 6px; align-items: center; color: inherit; }
.autor { font-size: 11px; font-weight: 600; opacity: .8; display: block; margin-bottom: 2px; }
.redactar { display: grid; grid-template-columns: 40px minmax(0, 1fr) 44px; gap: 6px; align-items: end; padding: 8px max(10px, env(safe-area-inset-right)) calc(8px + env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left)); border-top: 1px solid var(--rule); background: var(--card); }
.redactar textarea { resize: none; max-height: 140px; min-height: 44px; padding: 11px 14px; border-radius: 22px; border: 1px solid var(--rule-strong); background: var(--bg); outline: none; line-height: 1.35; }
.redactar .enviar { width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--accent); color: var(--on-accent); display: grid; place-items: center; }
.redactar .enviar svg { width: 20px; height: 20px; }
.aviso-cerrado { padding: 10px 14px; font-size: 13px; color: var(--muted); text-align: center; }

/* ── Hoja inferior (editar nombre, más opciones) ── */
.velo { position: fixed; inset: 0; z-index: 30; background: rgba(0,0,0,.35); display: grid; align-items: end; }
.hoja { background: var(--card); border-radius: 18px 18px 0 0; padding: 18px max(18px, env(safe-area-inset-right)) calc(18px + env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left)); display: grid; gap: 14px; max-width: 560px; width: 100%; margin: 0 auto; }
.hoja h3 { margin: 0; font-size: 18px; }
.hoja .fila { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.opcion { display: flex; gap: 12px; align-items: center; padding: 12px 4px; border: 0; background: none; text-align: left; border-top: 1px solid var(--rule); width: 100%; }
.opcion:first-of-type { border-top: 0; }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--nav-h) + 16px + env(safe-area-inset-bottom)); z-index: 40; background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: 14px; max-width: calc(100% - 32px); }

/* ── Cuenta ── */
.tarjeta { background: var(--card); border: 1px solid var(--rule); border-radius: 14px; padding: 16px; display: grid; gap: 10px; }
.tarjeta p { margin: 0; }
.tarjeta .muted, .muted { color: var(--muted); font-size: 14px; }
.pasos { margin: 0; padding-left: 20px; display: grid; gap: 6px; font-size: 15px; }

@media (min-width: 900px) {
  .conv { left: auto; width: min(560px, 100%); border-left: 1px solid var(--rule); box-shadow: -12px 0 40px rgba(0,0,0,.08); }
}
