:root { --azul: #0a2540; --acento: #ff6b35; --fondo: #f3f6f9; --panel: #fff; --borde: #e1e7ee; --suave: #5a6b7b; --error: #dc2626; --radio: 12px; }
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif; background: var(--fondo); color: #1a1a1a; font-size: 15px; line-height: 1.45; -webkit-tap-highlight-color: transparent; }
a { color: #2563eb; text-decoration: none; }
h1 { color: var(--azul); font-size: 1.3rem; }
h2 { color: var(--azul); font-size: 1.05rem; margin: 1.4rem 0 .6rem; }
.muted { color: var(--suave); } .small { font-size: .82rem; } .centro { text-align: center; }
.top { position: sticky; top: 0; z-index: 10; background: var(--azul); color: #fff; display: flex; align-items: center; gap: .6rem; padding: .55rem .8rem; padding-top: calc(.55rem + env(safe-area-inset-top)); }
.top .logo { height: 26px; background: #fff; border-radius: 6px; padding: 2px 6px; }
.top .tit { flex: 1; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icono { background: none; border: 0; color: inherit; font-size: 1.4rem; cursor: pointer; padding: 0 .3rem; line-height: 1; }
main { max-width: 820px; margin: 0 auto; padding: 1rem; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; border: 1px solid var(--borde); background: #fff; color: var(--azul); border-radius: 10px; padding: .6rem 1rem; font: inherit; font-weight: 600; cursor: pointer; }
.btn.primario { background: var(--acento); border-color: var(--acento); color: #fff; }
.btn.grande { width: 100%; padding: .9rem; font-size: 1.05rem; margin-bottom: 1rem; }
.btn.mini { padding: .3rem .6rem; font-size: .85rem; }
.btn:disabled { opacity: .5; }
input, textarea { font: inherit; border: 1px solid var(--borde); border-radius: 10px; padding: .6rem .7rem; width: 100%; background: #fff; }
.lista { display: flex; flex-direction: column; gap: .5rem; }
.item { display: block; background: var(--panel); border-radius: var(--radio); padding: .75rem .9rem; color: inherit; box-shadow: 0 1px 3px rgba(10, 37, 64, .08); }
.item .t { font-weight: 700; color: var(--azul); }
.aviso { background: #fff7e6; border: 1px solid #f5c26b; border-radius: 10px; padding: .7rem; margin-bottom: 1rem; }
.login { max-width: 360px; margin: 12vh auto 0; padding: 1rem; text-align: center; }
.login .logo-grande { max-width: 220px; }
.login form { display: flex; flex-direction: column; gap: .6rem; margin-top: 1rem; }
.error { color: var(--error); }

/* Chat */
main.chat { padding-bottom: 180px; }
.mensajes { display: flex; flex-direction: column; gap: .7rem; }
.bienvenida { background: #fff; border-radius: var(--radio); padding: 1rem; color: var(--suave); }
.msg { max-width: 92%; border-radius: 14px; padding: .65rem .85rem; position: relative; overflow-wrap: anywhere; }
.msg.user { align-self: flex-end; background: var(--azul); color: #fff; border-bottom-right-radius: 4px; }
.msg.assistant { align-self: flex-start; background: #fff; box-shadow: 0 1px 3px rgba(10, 37, 64, .08); border-bottom-left-radius: 4px; padding-bottom: 1.8rem; }
.msg.assistant p { margin: .35rem 0; }
.msg.assistant ul, .msg.assistant ol { margin: .3rem 0; padding-left: 1.3rem; }
.msg.assistant h4 { margin: .8rem 0 .3rem; color: var(--azul); }
.msg.assistant code { background: #eef2f6; padding: 0 .25rem; border-radius: 4px; }
.msg.error { align-self: center; background: #fdecec; color: var(--error); }
.copiar { position: absolute; right: .5rem; bottom: .35rem; border: 0; background: none; color: var(--suave); font-size: .78rem; cursor: pointer; }
.pensando { display: flex; gap: .3rem; padding: .9rem; }
.pensando span { width: 8px; height: 8px; background: var(--suave); border-radius: 50%; animation: latido 1s infinite alternate; }
.pensando span:nth-child(2) { animation-delay: .2s; }
.pensando span:nth-child(3) { animation-delay: .4s; }
@keyframes latido { to { opacity: .2; } }
.tabla { overflow-x: auto; }
table { border-collapse: collapse; margin: .4rem 0; font-size: .9rem; }
th, td { border: 1px solid var(--borde); padding: .3rem .5rem; text-align: left; }
th { background: #eef2f6; }
form.entrada { position: fixed; left: 0; right: 0; bottom: 0; background: #fff; border-top: 1px solid var(--borde); padding: .6rem; padding-bottom: calc(.6rem + env(safe-area-inset-bottom)); max-width: 820px; margin: 0 auto; }
form.entrada .fila { display: flex; gap: .4rem; align-items: flex-end; }
form.entrada textarea { resize: none; max-height: 160px; }
form.entrada .enviar { padding: .6rem .9rem; }
form.entrada .foto { font-size: 1.5rem; padding: .3rem; }
.aviso-in { margin-bottom: .4rem; }
.dificil { display: block; font-size: .82rem; color: var(--suave); margin-top: .35rem; }
.dificil input, .controles input[type=checkbox], form.nuevo input[type=checkbox] { width: auto; }
.miniaturas { display: flex; gap: .4rem; flex-wrap: wrap; }
.miniaturas span { position: relative; margin-bottom: .4rem; }
.miniaturas img { height: 56px; border-radius: 6px; }
.miniaturas button { position: absolute; top: -6px; right: -6px; border: 0; border-radius: 50%; background: var(--error); color: #fff; width: 20px; height: 20px; font-size: .7rem; cursor: pointer; }

/* Menú */
.menu-fondo { position: fixed; inset: 0; background: rgba(0, 0, 0, .35); z-index: 30; }
.menu { position: absolute; right: 0; top: 0; bottom: 0; width: min(300px, 85vw); background: #fff; padding: 1rem; padding-top: calc(1rem + env(safe-area-inset-top)); display: flex; flex-direction: column; gap: .2rem; }
.menu a { padding: .75rem .5rem; border-radius: 8px; color: var(--azul); font-weight: 600; }
.menu a:active { background: var(--fondo); }
.menu .quien { padding: .5rem; border-bottom: 1px solid var(--borde); margin-bottom: .5rem; }

/* Administración */
.tarjetas { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.tarjetas div { background: #fff; border-radius: var(--radio); padding: .9rem; }
.tarjetas b { display: block; font-size: 1.4rem; color: var(--azul); }
.tarjetas span { color: var(--suave); font-size: .85rem; }
.controles { display: flex; flex-wrap: wrap; gap: .5rem 1rem; align-items: center; margin-top: .5rem; font-size: .9rem; }
.controles input[type=number] { width: 70px; padding: .3rem; }
.usuario.inactivo { opacity: .6; }
.chip { background: #eef2f6; border-radius: 99px; padding: 0 .5rem; font-size: .75rem; font-weight: 600; margin-left: .3rem; color: var(--suave); }
form.nuevo, form.clave { display: grid; gap: .5rem; }
.toast { position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%); background: var(--azul); color: #fff; padding: .6rem 1rem; border-radius: 10px; z-index: 50; }
