:root {
  --bg: #070a10;
  --bg2: #0d121c;
  --panel: rgba(17, 23, 34, 0.78);
  --panel-solid: #121826;
  --linea: rgba(255, 255, 255, 0.08);
  --linea2: rgba(255, 255, 255, 0.14);
  --texto: #e8edf6;
  --suave: #8e99ad;
  --acento: #3ee6b8;
  --acento2: #5aa2ff;
  --aviso: #ffb547;
  --peligro: #ff5d6c;
  --radio: 16px;
  --sombra: 0 20px 60px rgba(0, 0, 0, 0.55), 0 2px 8px rgba(0, 0, 0, 0.35);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--texto);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", Roboto, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased; }
button, input, textarea, select { font: inherit; color: inherit; }
a { color: var(--acento2); }
.oculto { display: none !important; }

/* ─────── fondo animado (login/alta) ─────── */
.fondo { position: fixed; inset: 0; overflow: hidden; z-index: 0;
  background: radial-gradient(1200px 700px at 15% -10%, rgba(62, 230, 184, .16), transparent 60%),
              radial-gradient(900px 700px at 110% 110%, rgba(90, 162, 255, .18), transparent 60%), var(--bg); }
.fondo::before { content: ""; position: absolute; inset: -50%;
  background-image: linear-gradient(rgba(255,255,255,.035) 1px, transparent 1px),
                    linear-gradient(90deg, rgba(255,255,255,.035) 1px, transparent 1px);
  background-size: 44px 44px; transform: perspective(700px) rotateX(58deg) translateY(-10%);
  animation: rejilla 24s linear infinite; mask-image: radial-gradient(closest-side, #000 30%, transparent 85%); }
@keyframes rejilla { to { background-position: 0 440px, 0 0; } }
.orbe { position: absolute; width: 420px; height: 420px; border-radius: 50%; filter: blur(80px); opacity: .35;
  animation: flotar 18s ease-in-out infinite alternate; }
.orbe.a { background: #1fd3a3; top: -120px; left: -80px; }
.orbe.b { background: #3d7bff; bottom: -160px; right: -60px; animation-delay: -9s; }
@keyframes flotar { to { transform: translate(60px, 40px) scale(1.15); } }

/* ─────── tarjeta de login ─────── */
.centro { position: relative; z-index: 1; min-height: 100%; display: grid; place-items: center; padding: 24px; }
.tarjeta { width: min(420px, 100%); background: var(--panel); border: 1px solid var(--linea2);
  border-radius: 24px; padding: 34px 30px 28px; box-shadow: var(--sombra);
  backdrop-filter: blur(22px) saturate(140%); -webkit-backdrop-filter: blur(22px) saturate(140%);
  animation: entrar .6s cubic-bezier(.2,.9,.3,1.2) both; }
@keyframes entrar { from { opacity: 0; transform: translateY(18px) scale(.97); } }
.marca { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.logo { width: 46px; height: 46px; border-radius: 13px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--acento), var(--acento2)); color: #04131a;
  box-shadow: 0 8px 24px rgba(62, 230, 184, .35); }
.logo svg { width: 26px; height: 26px; }
.marca h1 { font-size: 20px; margin: 0; letter-spacing: -.01em; }
.marca p { margin: 0; color: var(--suave); font-size: 13px; }
.campo { display: block; margin: 14px 0; }
.campo span { display: block; font-size: 12.5px; color: var(--suave); margin: 0 0 6px 2px; letter-spacing: .02em; }
.campo input { width: 100%; padding: 13px 14px; border-radius: 12px; border: 1px solid var(--linea2);
  background: rgba(0,0,0,.28); outline: none; transition: border .15s, box-shadow .15s; font-size: 16px; }
.campo input:focus { border-color: var(--acento); box-shadow: 0 0 0 4px rgba(62,230,184,.14); }
.codigo input { letter-spacing: .5em; text-align: center; font-size: 22px; font-variant-numeric: tabular-nums; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; cursor: pointer;
  padding: 13px 18px; border-radius: 12px; font-weight: 600; transition: transform .08s, filter .15s, background .15s; }
.btn:active { transform: scale(.98); }
.btn.primario { width: 100%; margin-top: 10px; color: #04131a;
  background: linear-gradient(135deg, var(--acento), #2fd0e0 60%, var(--acento2)); box-shadow: 0 10px 26px rgba(62,230,184,.28); }
.btn.primario:disabled { filter: grayscale(.6) brightness(.7); cursor: progress; }
.btn.sec { background: rgba(255,255,255,.07); border: 1px solid var(--linea2); }
.btn.sec:hover { background: rgba(255,255,255,.12); }
.btn.peligro { background: rgba(255,93,108,.14); color: #ffb0b8; border: 1px solid rgba(255,93,108,.3); }
.error { min-height: 20px; color: var(--peligro); font-size: 13.5px; margin-top: 10px; text-align: center; }
.pie { margin-top: 18px; text-align: center; color: var(--suave); font-size: 12px; display: flex; gap: 6px;
  justify-content: center; align-items: center; }
.pie svg { width: 14px; height: 14px; color: var(--acento); }
.qr { background: #fff; border-radius: 14px; padding: 10px; width: 210px; margin: 8px auto 6px; }
.qr svg { width: 100%; height: auto; display: block; }
.secreto { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12.5px; text-align: center;
  color: var(--suave); word-break: break-all; user-select: all; }
.pasos { counter-reset: p; padding: 0; margin: 0 0 6px; list-style: none; }
.pasos li { counter-increment: p; position: relative; padding-left: 32px; margin: 10px 0; color: #c9d2e1; font-size: 14px; }
.pasos li::before { content: counter(p); position: absolute; left: 0; top: 0; width: 22px; height: 22px; border-radius: 50%;
  background: rgba(62,230,184,.15); color: var(--acento); font-size: 12px; font-weight: 700; display: grid; place-items: center; }
.agitar { animation: agitar .4s; }
@keyframes agitar { 20%,60% { transform: translateX(-8px); } 40%,80% { transform: translateX(8px); } }

/* ─────── aplicación ─────── */
body.app { overflow: hidden; overscroll-behavior: none; touch-action: none; }
#pantalla { position: fixed; inset: 0; background: #000; }
#pantalla > div { background: radial-gradient(circle at 50% 40%, #121a28, #05070b) !important; }
#pantalla canvas { image-rendering: auto; }

.superior { position: fixed; top: calc(10px + var(--safe-t)); left: 12px; z-index: 30; display: flex; gap: 8px; align-items: center;
  transition: opacity .35s, transform .35s; }
.pastilla { display: flex; align-items: center; gap: 8px; padding: 7px 12px 7px 9px; border-radius: 999px;
  background: var(--panel); border: 1px solid var(--linea); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  font-size: 13px; box-shadow: 0 6px 20px rgba(0,0,0,.4); }
.punto { width: 9px; height: 9px; border-radius: 50%; background: var(--suave); box-shadow: 0 0 0 0 currentColor; }
.punto.ok { background: var(--acento); animation: latir 2.4s infinite; color: rgba(62,230,184,.6); }
.punto.medio { background: var(--aviso); color: rgba(255,181,71,.6); animation: latir 1s infinite; }
.punto.mal { background: var(--peligro); }
@keyframes latir { 0% { box-shadow: 0 0 0 0 currentColor; } 70% { box-shadow: 0 0 0 8px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }
.pastilla .mini { color: var(--suave); font-variant-numeric: tabular-nums; }

/* dock */
.dock { position: fixed; left: 50%; bottom: calc(14px + var(--safe-b)); transform: translateX(-50%); z-index: 40;
  display: flex; gap: 4px; padding: 7px; border-radius: 20px; background: var(--panel);
  border: 1px solid var(--linea2); backdrop-filter: blur(22px) saturate(150%); -webkit-backdrop-filter: blur(22px) saturate(150%);
  box-shadow: var(--sombra); transition: transform .35s cubic-bezier(.2,.9,.3,1), opacity .35s; max-width: calc(100vw - 16px);
  overflow-x: auto; scrollbar-width: none; }
.dock::-webkit-scrollbar { display: none; }
.dock.escondido { transform: translate(-50%, calc(100% + 30px)); opacity: 0; pointer-events: none; }
.dock .sep { width: 1px; background: var(--linea2); margin: 6px 3px; flex: none; }
.ico { position: relative; flex: none; width: 44px; height: 44px; border-radius: 13px; border: 0; background: transparent;
  display: grid; place-items: center; cursor: pointer; color: #cfd7e6; transition: background .15s, color .15s, transform .1s; }
.ico:hover { background: rgba(255,255,255,.08); color: #fff; }
.ico:active { transform: scale(.92); }
.ico.activo { background: rgba(62,230,184,.16); color: var(--acento); }
.ico svg { width: 22px; height: 22px; stroke-width: 1.8; }
.ico[data-tip]:hover::after { content: attr(data-tip); position: absolute; bottom: calc(100% + 10px); left: 50%; transform: translateX(-50%);
  white-space: nowrap; font-size: 12px; padding: 5px 9px; border-radius: 8px; background: #0b1019; border: 1px solid var(--linea2); pointer-events: none; }
@media (hover: none) { .ico[data-tip]:hover::after { display: none; } }
.asa { position: fixed; left: 50%; bottom: calc(6px + var(--safe-b)); transform: translateX(-50%); z-index: 39; width: 64px; height: 22px;
  border: 0; background: transparent; cursor: pointer; display: grid; place-items: center; }
.asa::before { content: ""; width: 44px; height: 5px; border-radius: 9px; background: rgba(255,255,255,.45); box-shadow: 0 1px 6px rgba(0,0,0,.6); }

/* barra de teclas */
.teclas { position: fixed; left: 8px; right: 8px; bottom: calc(94px + var(--safe-b)); z-index: 41; display: flex; gap: 6px;
  overflow-x: auto; padding: 8px; border-radius: 16px; background: var(--panel); border: 1px solid var(--linea2);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); box-shadow: var(--sombra); scrollbar-width: none;
  animation: subir .25s cubic-bezier(.2,.9,.3,1); }
.teclas::-webkit-scrollbar { display: none; }
@keyframes subir { from { opacity: 0; transform: translateY(14px); } }
.tecla { flex: none; min-width: 44px; height: 40px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--linea2);
  background: rgba(255,255,255,.06); cursor: pointer; font-size: 13.5px; font-weight: 600; white-space: nowrap; }
.tecla:active { background: rgba(255,255,255,.16); }
.tecla.mod.on { background: var(--acento); color: #04131a; border-color: transparent; }
.tecla.combo { color: var(--acento2); }
.teclas .sep { width: 1px; background: var(--linea2); flex: none; margin: 4px 2px; }

/* paneles laterales */
.velo { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.35); opacity: 0; pointer-events: none; transition: opacity .25s; }
.velo.on { opacity: 1; pointer-events: auto; }
.hoja { position: fixed; z-index: 51; top: 12px; right: 12px; bottom: 12px; width: min(440px, calc(100vw - 24px));
  background: rgba(14,19,29,.92); border: 1px solid var(--linea2); border-radius: 22px; box-shadow: var(--sombra);
  backdrop-filter: blur(26px) saturate(150%); -webkit-backdrop-filter: blur(26px) saturate(150%);
  display: flex; flex-direction: column; transform: translateX(calc(100% + 30px)); transition: transform .38s cubic-bezier(.2,.9,.25,1); }
.hoja.on { transform: none; }
@media (max-width: 640px) {
  .hoja { top: auto; left: 0; right: 0; bottom: 0; width: 100%; height: min(86vh, 760px); border-radius: 24px 24px 0 0;
    transform: translateY(105%); padding-bottom: var(--safe-b); }
  .hoja.on { transform: none; }
  .hoja::before { content: ""; position: absolute; top: 8px; left: 50%; transform: translateX(-50%); width: 40px; height: 5px;
    border-radius: 9px; background: rgba(255,255,255,.25); }
}
.hoja header { display: flex; align-items: center; gap: 10px; padding: 20px 18px 12px; }
.hoja header h2 { margin: 0; font-size: 18px; flex: 1; letter-spacing: -.01em; }
.hoja .cuerpo { flex: 1; overflow-y: auto; padding: 4px 18px 22px; -webkit-overflow-scrolling: touch; touch-action: pan-y; }
.cerrar { width: 34px; height: 34px; border-radius: 50%; border: 0; background: rgba(255,255,255,.08); cursor: pointer; display: grid; place-items: center; }
.cerrar svg { width: 18px; height: 18px; }
.sub { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--suave); margin: 18px 2px 8px; }

/* tarjetas de equipo */
.rejilla { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.metrica { background: rgba(255,255,255,.04); border: 1px solid var(--linea); border-radius: 16px; padding: 14px; position: relative; overflow: hidden; }
.metrica .et { font-size: 12px; color: var(--suave); display: flex; align-items: center; gap: 6px; }
.metrica .val { font-size: 26px; font-weight: 700; letter-spacing: -.02em; margin-top: 4px; font-variant-numeric: tabular-nums; }
.metrica .val small { font-size: 13px; color: var(--suave); font-weight: 500; margin-left: 2px; }
.metrica .det { font-size: 12px; color: var(--suave); margin-top: 2px; }
.barra { height: 6px; border-radius: 9px; background: rgba(255,255,255,.08); margin-top: 10px; overflow: hidden; }
.barra i { display: block; height: 100%; border-radius: 9px; background: linear-gradient(90deg, var(--acento), var(--acento2)); transition: width .6s; }
.barra i.caliente { background: linear-gradient(90deg, var(--aviso), var(--peligro)); }
.metrica canvas { position: absolute; left: 0; right: 0; bottom: 0; width: 100%; height: 44px; opacity: .55; pointer-events: none; }
.ancho { grid-column: 1 / -1; }
.lista { display: flex; flex-direction: column; gap: 2px; }
.fila { display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 12px; }
.fila:nth-child(odd) { background: rgba(255,255,255,.025); }
.fila .n { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fila .s { font-size: 12px; color: var(--suave); white-space: nowrap; }
.estado { font-size: 11.5px; padding: 3px 9px; border-radius: 999px; font-weight: 600; }
.estado.on { background: rgba(62,230,184,.14); color: var(--acento); }
.estado.off { background: rgba(255,93,108,.14); color: #ff9aa4; }
.estado.otro { background: rgba(255,181,71,.14); color: var(--aviso); }
.acciones { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.acciones .btn { width: 100%; }

/* archivos */
.migas { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; font-size: 13.5px; margin-bottom: 10px; }
.migas button { border: 0; background: rgba(255,255,255,.06); padding: 5px 10px; border-radius: 8px; cursor: pointer; }
.migas button:last-child { background: rgba(62,230,184,.14); color: var(--acento); }
.archivo { display: flex; align-items: center; gap: 12px; padding: 10px; border-radius: 12px; cursor: pointer; transition: background .12s; }
.archivo:hover { background: rgba(255,255,255,.05); }
.archivo .fi { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; flex: none; background: rgba(90,162,255,.12); color: var(--acento2); }
.archivo .fi.carp { background: rgba(255,181,71,.13); color: var(--aviso); }
.archivo .fi svg { width: 20px; height: 20px; }
.archivo .n { flex: 1; min-width: 0; }
.archivo .n b { display: block; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.archivo .n span { font-size: 12px; color: var(--suave); }
.soltar { border: 2px dashed var(--linea2); border-radius: 16px; padding: 18px; text-align: center; color: var(--suave); margin-bottom: 12px;
  transition: border-color .15s, background .15s; cursor: pointer; }
.soltar.sobre { border-color: var(--acento); background: rgba(62,230,184,.06); color: var(--texto); }
.progreso { margin: 8px 0; font-size: 13px; }
.progreso .barra { margin-top: 6px; }

/* actividad */
.ev { display: flex; gap: 12px; padding: 9px 4px; border-bottom: 1px solid var(--linea); font-size: 13.5px; }
.ev .t { color: var(--suave); font-size: 12px; width: 82px; flex: none; font-variant-numeric: tabular-nums; }
.ev .tipo { font-weight: 600; }
.ev .tipo.fallo { color: var(--peligro); }
.ev .tipo.entrada { color: var(--acento); }

/* ajustes */
.opcion { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 12px; padding: 12px 2px; border-bottom: 1px solid var(--linea); }
.opcion .d { font-size: 12px; color: var(--suave); }
.segmentos { display: flex; background: rgba(255,255,255,.06); border-radius: 11px; padding: 3px; gap: 2px; }
.segmentos button { border: 0; background: transparent; padding: 7px 11px; border-radius: 9px; cursor: pointer; font-size: 13px; color: var(--suave); }
.segmentos button.on { background: rgba(255,255,255,.14); color: #fff; }
.interruptor { position: relative; width: 50px; height: 30px; flex: none; }
.interruptor input { opacity: 0; width: 0; height: 0; }
.interruptor span { position: absolute; inset: 0; background: rgba(255,255,255,.14); border-radius: 99px; transition: background .2s; cursor: pointer; }
.interruptor span::after { content: ""; position: absolute; left: 3px; top: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: transform .2s; }
.interruptor input:checked + span { background: var(--acento); }
.interruptor input:checked + span::after { transform: translateX(20px); }
textarea.porta { width: 100%; min-height: 130px; border-radius: 12px; border: 1px solid var(--linea2); background: rgba(0,0,0,.3); padding: 12px; resize: vertical; outline: none; }
textarea.porta:focus { border-color: var(--acento); }
.fila-btn { display: flex; gap: 8px; margin-top: 8px; }
.fila-btn .btn { flex: 1; }

/* capa de conexión */
.capa { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; background: rgba(5,7,11,.82);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); transition: opacity .4s; }
.capa.fuera { opacity: 0; pointer-events: none; }
.capa .caja { text-align: center; padding: 30px; }
.anillo { width: 74px; height: 74px; margin: 0 auto 18px; border-radius: 50%; position: relative; }
.anillo::before, .anillo::after { content: ""; position: absolute; inset: 0; border-radius: 50%; border: 3px solid transparent; }
.anillo::before { border-top-color: var(--acento); border-right-color: var(--acento); animation: girar 1s linear infinite; }
.anillo::after { inset: 10px; border-bottom-color: var(--acento2); border-left-color: var(--acento2); animation: girar 1.4s linear infinite reverse; }
@keyframes girar { to { transform: rotate(360deg); } }
.capa h3 { margin: 0 0 6px; font-size: 19px; }
.capa p { margin: 0 0 18px; color: var(--suave); }

/* avisos */
.avisos { position: fixed; top: calc(14px + var(--safe-t)); left: 50%; transform: translateX(-50%); z-index: 80; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { padding: 10px 16px; border-radius: 12px; background: rgba(18,24,38,.95); border: 1px solid var(--linea2); box-shadow: var(--sombra); font-size: 14px;
  animation: toast .3s cubic-bezier(.2,.9,.3,1.3); max-width: 90vw; }
.toast.ok { border-color: rgba(62,230,184,.4); }
.toast.mal { border-color: rgba(255,93,108,.5); }
@keyframes toast { from { opacity: 0; transform: translateY(-10px) scale(.96); } }

#entradaTeclado { position: fixed; left: -100px; top: 40%; width: 10px; height: 10px; opacity: 0; font-size: 16px; }
.lupa { position: fixed; z-index: 35; pointer-events: none; }

@media (max-width: 480px) {
  .dock { gap: 2px; padding: 6px; border-radius: 18px; }
  .dock .sep, .dock .solo-ancho { display: none; }
  .ico { width: 38px; height: 40px; border-radius: 11px; }
  .ico svg { width: 21px; height: 21px; }
}
.segmentos { margin-left: auto; }
