/* Achiles · hoja única. Móvil primero; oscuro por defecto (es una app personal que se abre a las 6 de la mañana). */
:root {
  --fondo: #0e1116; --panel: #161b23; --panel2: #1d2430; --linea: #2a3340; --texto: #e8edf3; --texto2: #9aa6b5; --texto3: #6b7786;
  --acento: #e0a84a; --acento2: #c58d2f; --acento-tinta: #1a1204; --ok: #4fc07e; --aviso: #f5a524; --mal: #ef5d5d; --info: #5aa9ff;
  --radio: 14px; --sombra: 0 6px 24px rgba(0,0,0,.35); --nav: 64px; --tap: 48px;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) { --fondo: #f4f6f9; --panel: #ffffff; --panel2: #eef1f5; --linea: #dde3ea; --texto: #121820; --texto2: #4c5a6b; --texto3: #7b8797; --sombra: 0 4px 18px rgba(20,30,50,.08); color-scheme: light; }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--fondo); color: var(--texto); font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; padding-bottom: calc(var(--nav) + env(safe-area-inset-bottom)); }
a { color: var(--acento); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5rem; }
h1 { font-size: 1.45rem; } h2 { font-size: 1.15rem; } h3 { font-size: 1rem; }
p { margin: 0 0 .75rem; }
small, .muted { color: var(--texto2); }
.container { max-width: 820px; margin: 0 auto; padding: 0 14px; }
/* cabecera */
.top { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--fondo) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--linea); padding-top: env(safe-area-inset-top); }
.top .container { display: flex; align-items: center; gap: 10px; height: 54px; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; letter-spacing: .3px; color: var(--texto); }
.brand .mark { width: 28px; height: 28px; border-radius: 50%; background: radial-gradient(circle at 30% 30%, #f3c66d, var(--acento2)); color: var(--acento-tinta); display: grid; place-items: center; font-weight: 900; font-size: 15px; }
.top .titulo { flex: 1; font-weight: 600; color: var(--texto2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top .usuario { color: var(--texto2); font-size: .85rem; }
/* navegación inferior */
.nav { position: fixed; bottom: 0; left: 0; right: 0; z-index: 30; display: flex; justify-content: space-around; background: var(--panel); border-top: 1px solid var(--linea); padding-bottom: env(safe-area-inset-bottom); }
.nav a, .nav button { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; height: var(--nav); color: var(--texto2); font-size: .72rem; background: none; border: 0; font-family: inherit; text-decoration: none; }
.nav .ico { font-size: 1.25rem; line-height: 1; }
.nav .active { color: var(--acento); }
/* hoja «más» */
.hoja { position: fixed; inset: 0; z-index: 40; background: rgba(0,0,0,.5); display: none; }
.hoja.abierta { display: block; }
.hoja .panel { position: absolute; left: 0; right: 0; bottom: 0; background: var(--panel); border-radius: 18px 18px 0 0; padding: 14px 14px calc(16px + env(safe-area-inset-bottom)); max-height: 80vh; overflow: auto; }
.hoja .grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.hoja .grid a { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 12px 6px; background: var(--panel2); border-radius: 12px; color: var(--texto); font-size: .8rem; text-align: center; }
.hoja .grid .ico { font-size: 1.4rem; }
/* tarjetas y rejillas */
main { padding: 14px 0 24px; }
.card { background: var(--panel); border: 1px solid var(--linea); border-radius: var(--radio); padding: 14px; margin-bottom: 12px; }
.card.pad-lg { padding: 20px; }
.card h2 { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.grid { display: grid; gap: 10px; }
.g2 { grid-template-columns: repeat(2, 1fr); }
.g3 { grid-template-columns: repeat(3, 1fr); }
@media (min-width: 640px) { .g2-md { grid-template-columns: repeat(2, 1fr); } }
.stat { background: var(--panel2); border-radius: 12px; padding: 10px 12px; }
.stat .v { font-size: 1.35rem; font-weight: 700; line-height: 1.1; }
.stat .l { font-size: .75rem; color: var(--texto2); }
.stat .d { font-size: .78rem; color: var(--texto2); }
.stat .d.ok { color: var(--ok); } .stat .d.mal { color: var(--mal); }
/* formularios */
.field { margin-bottom: 10px; }
.field label { display: block; font-size: .82rem; color: var(--texto2); margin-bottom: 4px; }
input, select, textarea { width: 100%; background: var(--panel2); color: var(--texto); border: 1px solid var(--linea); border-radius: 10px; padding: 10px 12px; font: inherit; min-height: var(--tap); }
input[type="checkbox"], input[type="radio"] { width: auto; min-height: auto; accent-color: var(--acento); }
input[type="file"] { padding: 8px; }
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--acento) 50%, transparent); border-color: var(--acento); }
.check { display: flex; align-items: center; gap: 8px; font-size: .95rem; margin: 8px 0; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: var(--tap); padding: 10px 16px; border-radius: 12px; border: 1px solid var(--linea); background: var(--panel2); color: var(--texto); font: inherit; font-weight: 600; cursor: pointer; text-decoration: none !important; }
.btn.primario { background: var(--acento); border-color: var(--acento); color: var(--acento-tinta); }
.btn.peligro { color: var(--mal); }
.btn.block { width: 100%; }
.btn.chico { min-height: 36px; padding: 6px 12px; font-size: .85rem; border-radius: 10px; }
.btn:disabled { opacity: .5; cursor: wait; }
.fila { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.fila > * { flex: 1; }
.fila.auto > * { flex: 0 0 auto; }
.mt { margin-top: 12px; } .mt2 { margin-top: 20px; } .mb0 { margin-bottom: 0; }
.right { text-align: right; } .center { text-align: center; }
/* avisos */
.flash { padding: 10px 14px; border-radius: 12px; margin-bottom: 12px; font-size: .95rem; border: 1px solid; }
.flash.ok { background: color-mix(in srgb, var(--ok) 14%, transparent); border-color: color-mix(in srgb, var(--ok) 40%, transparent); }
.flash.error, .error { color: var(--mal); }
.flash.error { background: color-mix(in srgb, var(--mal) 12%, transparent); border-color: color-mix(in srgb, var(--mal) 40%, transparent); }
.flash.aviso { background: color-mix(in srgb, var(--aviso) 12%, transparent); border-color: color-mix(in srgb, var(--aviso) 40%, transparent); }
.error { font-size: .85rem; margin-top: 4px; }
.badge { display: inline-block; font-size: .72rem; padding: 2px 8px; border-radius: 999px; background: var(--panel2); color: var(--texto2); border: 1px solid var(--linea); vertical-align: middle; }
.badge.ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 40%, transparent); }
.badge.alto, .badge.bajo, .badge.anormal, .badge.mal { color: var(--mal); border-color: color-mix(in srgb, var(--mal) 40%, transparent); }
.badge.aviso { color: var(--aviso); border-color: color-mix(in srgb, var(--aviso) 40%, transparent); }
.badge.acento { color: var(--acento); border-color: color-mix(in srgb, var(--acento) 45%, transparent); }
/* listas */
.lista { list-style: none; margin: 0; padding: 0; }
.lista li { display: flex; gap: 10px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--linea); }
.lista li:last-child { border-bottom: 0; }
.lista .cuerpo { flex: 1; min-width: 0; }
.lista .t { font-weight: 600; }
.lista .s { font-size: .82rem; color: var(--texto2); overflow: hidden; text-overflow: ellipsis; }
.lista .v { font-weight: 700; white-space: nowrap; }
.lista li.link { cursor: pointer; }
.lista a.fila-link { color: inherit; display: flex; gap: 10px; align-items: center; width: 100%; text-decoration: none; }
table.tabla { width: 100%; border-collapse: collapse; font-size: .9rem; }
.tabla th, .tabla td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--linea); vertical-align: top; }
.tabla th { color: var(--texto2); font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .3px; }
.scroll-x { overflow-x: auto; -webkit-overflow-scrolling: touch; }
details.plegable > summary { cursor: pointer; font-weight: 600; padding: 6px 0; list-style: none; }
details.plegable > summary::-webkit-details-marker { display: none; }
details.plegable > summary::before { content: "▸ "; color: var(--acento); }
details.plegable[open] > summary::before { content: "▾ "; }
/* áreas del cuerpo */
.areas { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
@media (min-width: 560px) { .areas { grid-template-columns: repeat(3, 1fr); } }
.area { background: var(--panel); border: 1px solid var(--linea); border-radius: 12px; padding: 10px 12px; color: var(--texto); }
.area .n { font-weight: 600; font-size: .92rem; }
.area .ico { font-size: 1.3rem; }
.area .c { font-size: .75rem; color: var(--texto2); }
/* gráfico */
.grafico { width: 100%; height: auto; display: block; }
.grafico .eje { stroke: var(--linea); stroke-width: 1; }
.grafico .marca { fill: var(--texto3); font-size: 11px; }
.grafico .serie { fill: none; stroke: var(--acento); stroke-width: 2.2; stroke-linejoin: round; stroke-linecap: round; }
.grafico .punto { fill: var(--panel); stroke: var(--acento); stroke-width: 2; }
.grafico .rango { fill: color-mix(in srgb, var(--ok) 12%, transparent); }
.grafico .objetivo { stroke: var(--ok); stroke-width: 1; stroke-dasharray: 4 4; }
/* chat */
.chat { display: flex; flex-direction: column; min-height: calc(100vh - 54px - var(--nav) - 28px); }
.chat .mensajes { flex: 1; display: flex; flex-direction: column; gap: 10px; padding: 6px 0 12px; }
.msg { max-width: 92%; padding: 10px 14px; border-radius: 16px; line-height: 1.45; position: relative; word-wrap: break-word; }
.msg.usuario { align-self: flex-end; background: var(--acento); color: var(--acento-tinta); border-bottom-right-radius: 4px; white-space: pre-wrap; }
.msg.achiles { align-self: flex-start; background: var(--panel); border: 1px solid var(--linea); border-bottom-left-radius: 4px; }
.msg.achiles.error { border-color: color-mix(in srgb, var(--mal) 50%, transparent); }
.msg .meta { display: block; font-size: .7rem; color: var(--texto3); margin-top: 4px; }
.msg.usuario .meta { color: color-mix(in srgb, var(--acento-tinta) 70%, transparent); }
.msg img { max-width: 100%; border-radius: 10px; display: block; margin-top: 6px; }
.msg p:last-child { margin-bottom: 0; }
.msg table { border-collapse: collapse; margin: 6px 0; font-size: .9rem; }
.msg td, .msg th { border: 1px solid var(--linea); padding: 4px 8px; }
.msg ul, .msg ol { padding-left: 1.2rem; margin: 4px 0; }
.acciones { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.acciones span { font-size: .75rem; padding: 3px 9px; border-radius: 999px; background: color-mix(in srgb, var(--ok) 14%, transparent); color: var(--ok); border: 1px solid color-mix(in srgb, var(--ok) 35%, transparent); }
.acciones span.mal { background: color-mix(in srgb, var(--mal) 14%, transparent); color: var(--mal); border-color: color-mix(in srgb, var(--mal) 35%, transparent); }
.pensando { display: inline-flex; gap: 4px; align-items: center; color: var(--texto2); font-size: .9rem; }
.pensando i { width: 7px; height: 7px; border-radius: 50%; background: var(--acento); animation: p 1.2s infinite ease-in-out; }
.pensando i:nth-child(2) { animation-delay: .2s; } .pensando i:nth-child(3) { animation-delay: .4s; }
@keyframes p { 0%, 80%, 100% { opacity: .25; transform: scale(.8); } 40% { opacity: 1; transform: scale(1); } }
.compositor { position: sticky; bottom: calc(var(--nav) + env(safe-area-inset-bottom)); background: var(--fondo); padding: 8px 0 6px; border-top: 1px solid var(--linea); }
.compositor form { display: flex; gap: 6px; align-items: flex-end; }
.compositor textarea { min-height: 46px; max-height: 160px; border-radius: 22px; padding: 11px 14px; }
.compositor .btn { min-width: 46px; padding: 10px; border-radius: 50%; }
.compositor .adjuntar { position: relative; overflow: hidden; }
.compositor .adjuntar input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.compositor .extras { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-bottom: 6px; font-size: .8rem; color: var(--texto2); }
.compositor .extras select { min-height: 32px; padding: 4px 8px; width: auto; font-size: .8rem; }
.compositor .previa { font-size: .8rem; color: var(--texto2); }
.compositor .previa img { height: 44px; border-radius: 8px; vertical-align: middle; margin-right: 6px; }
/* documentos */
.docs { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 560px) { .docs { grid-template-columns: repeat(3, 1fr); } }
.doc { background: var(--panel); border: 1px solid var(--linea); border-radius: 12px; overflow: hidden; color: var(--texto); display: flex; flex-direction: column; }
.doc .mini { aspect-ratio: 4 / 3; background: var(--panel2); display: grid; place-items: center; overflow: hidden; font-size: 2rem; }
.doc .mini img { width: 100%; height: 100%; object-fit: cover; }
.doc .info { padding: 8px 10px; font-size: .82rem; }
.doc .info .t { font-weight: 600; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.doc .info .f { color: var(--texto2); font-size: .75rem; }
.visor { border-radius: 12px; overflow: hidden; background: #000; }
.visor img { width: 100%; display: block; }
.visor iframe { width: 100%; height: 70vh; border: 0; background: #fff; }
.progreso { height: 8px; background: var(--panel2); border-radius: 999px; overflow: hidden; margin-top: 6px; }
.progreso i { display: block; height: 100%; width: 0; background: var(--acento); transition: width .2s; }
.zona { border: 2px dashed var(--linea); border-radius: 14px; padding: 18px; text-align: center; color: var(--texto2); }
.zona.sobre { border-color: var(--acento); color: var(--acento); }
.hallazgos li { margin-bottom: 4px; }
.markdown h1, .markdown h2, .markdown h3 { margin-top: 1rem; }
.markdown table { border-collapse: collapse; width: 100%; font-size: .9rem; margin: 8px 0; }
.markdown td, .markdown th { border: 1px solid var(--linea); padding: 5px 8px; }
.markdown pre { white-space: pre-wrap; background: var(--panel2); padding: 10px; border-radius: 10px; }
.fotos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.fotos a { display: block; aspect-ratio: 3 / 4; background: var(--panel2); border-radius: 10px; overflow: hidden; position: relative; }
.fotos img { width: 100%; height: 100%; object-fit: cover; }
.fotos .et { position: absolute; left: 6px; bottom: 6px; font-size: .7rem; background: rgba(0,0,0,.55); color: #fff; padding: 2px 6px; border-radius: 6px; }
.instalar { background: color-mix(in srgb, var(--acento) 14%, transparent); border: 1px solid color-mix(in srgb, var(--acento) 40%, transparent); border-radius: 12px; padding: 10px 12px; font-size: .9rem; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.hidden { display: none !important; }
.auth { max-width: 420px; margin: 40px auto; }
.auth .brand { justify-content: center; font-size: 1.6rem; margin-bottom: 16px; }
.auth .brand .mark { width: 44px; height: 44px; font-size: 22px; }
.qr { background: #fff; padding: 8px; border-radius: 12px; display: inline-block; }
.paginacion { display: flex; gap: 6px; justify-content: center; margin: 12px 0; flex-wrap: wrap; }
.paginacion a, .paginacion span { padding: 6px 10px; border-radius: 8px; border: 1px solid var(--linea); font-size: .85rem; }
.paginacion .active span { background: var(--acento); color: var(--acento-tinta); border-color: var(--acento); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.chips a, .chips span { font-size: .8rem; padding: 5px 10px; border-radius: 999px; border: 1px solid var(--linea); color: var(--texto2); }
.chips a.active { background: var(--acento); color: var(--acento-tinta); border-color: var(--acento); }
.serie-linea { font-size: .85rem; color: var(--texto2); }
.semaforo { width: 10px; height: 10px; border-radius: 50%; display: inline-block; margin-right: 6px; background: var(--texto3); }
.semaforo.ok { background: var(--ok); } .semaforo.mal { background: var(--mal); }
