:root {
  --bg: #02060d;
  --bg2: #061423;
  --ink: #d9f6ff;
  --muted: #7fa9bb;
  --holo: #4fdcff;
  --holo-2: #9a86ff;
  --listen: #4dffc6;
  --pink: #ff6fc8;
  --danger: #ff6b7d;
  --glass: rgba(10, 30, 48, 0.55);
  --line: rgba(79, 220, 255, 0.25);
  --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%; overflow: hidden; }
body {
  background: radial-gradient(120% 80% at 50% 38%, #0a2236 0%, var(--bg2) 35%, var(--bg) 75%);
  color: var(--ink);
  font: 15px/1.5 "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  letter-spacing: 0.01em;
}
button, input, select, textarea { font: inherit; color: inherit; }
.hidden { display: none !important; }

#holo { position: fixed; inset: 0; z-index: 0; }
#holo canvas { width: 100% !important; height: 100% !important; display: block; }
.scanlines { position: fixed; inset: 0; z-index: 1; pointer-events: none; opacity: .35;
  background: repeating-linear-gradient(to bottom, rgba(120,220,255,.05) 0 1px, transparent 1px 3px);
  mix-blend-mode: screen; animation: scan 8s linear infinite; }
@keyframes scan { to { background-position: 0 300px; } }
.vignette { position: fixed; inset: 0; z-index: 1; pointer-events: none; background: radial-gradient(90% 70% at 50% 45%, transparent 55%, rgba(0,0,0,.65) 100%); }

/* Barra superior */
.top { position: fixed; top: 0; left: 0; right: 0; z-index: 5; display: flex; align-items: center; gap: 12px;
  padding: calc(12px + var(--safe-t)) 16px 12px; }
.brand { font-weight: 600; letter-spacing: .32em; font-size: 13px; color: var(--holo); display: flex; align-items: center; gap: 8px; text-shadow: 0 0 12px rgba(79,220,255,.6); }
.brand .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--holo); box-shadow: 0 0 10px var(--holo); animation: blink 2.4s ease-in-out infinite; }
@keyframes blink { 50% { opacity: .35; } }
.status { margin-left: auto; margin-right: auto; font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted);
  border: 1px solid var(--line); padding: 4px 12px; border-radius: 99px; background: rgba(4,18,30,.5); backdrop-filter: blur(6px); white-space: nowrap; }
.status.listening { color: var(--listen); border-color: rgba(77,255,198,.5); }
.status.thinking { color: var(--holo-2); border-color: rgba(154,134,255,.5); }
.status.speaking { color: var(--holo); border-color: rgba(79,220,255,.6); }
.top-actions { display: flex; gap: 6px; }
.icon-btn { width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line); background: rgba(4,18,30,.5); display: grid; place-items: center; cursor: pointer; backdrop-filter: blur(6px); }
.icon-btn svg { width: 20px; height: 20px; fill: none; stroke: var(--ink); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn:hover { border-color: var(--holo); }

.jobs { position: fixed; top: calc(64px + var(--safe-t)); left: 50%; transform: translateX(-50%); z-index: 5; font-size: 12px; color: var(--holo-2);
  display: flex; align-items: center; gap: 8px; padding: 4px 12px; border-radius: 99px; background: rgba(20,12,48,.55); border: 1px solid rgba(154,134,255,.35); }
.spinner { width: 12px; height: 12px; border-radius: 50%; border: 2px solid rgba(154,134,255,.3); border-top-color: var(--holo-2); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Subtítulos */
.stage { position: fixed; left: 0; right: 0; bottom: calc(118px + var(--safe-b)); z-index: 3; display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 0 16px; pointer-events: none; }
.caption { max-width: 760px; width: 100%; max-height: 30vh; overflow-y: auto; text-align: center; font-size: 17px; line-height: 1.55; color: #eafaff;
  text-shadow: 0 0 18px rgba(79,220,255,.45), 0 1px 2px #000; pointer-events: auto; scrollbar-width: thin; }
.caption:empty { display: none; }
.caption .more { margin-top: 8px; border: 1px solid var(--line); background: rgba(6,24,38,.6); border-radius: 99px; padding: 4px 14px; font-size: 13px; color: var(--holo); cursor: pointer; backdrop-filter: blur(6px); }
.detail-pane { position: fixed; z-index: 8; left: 12px; right: 12px; bottom: calc(112px + var(--safe-b)); max-height: 58vh; overflow-y: auto; padding: 12px 16px 16px; border-radius: 16px;
  background: rgba(4,16,28,.92); border: 1px solid var(--line); backdrop-filter: blur(12px); font-size: 14.5px; box-shadow: 0 0 40px rgba(79,220,255,.12);
  opacity: 0; transform: translateY(12px); pointer-events: none; transition: opacity .25s, transform .25s; }
.detail-pane.open { opacity: 1; transform: none; pointer-events: auto; }
.detail-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; color: var(--holo); font-size: 12px; letter-spacing: .14em; text-transform: uppercase; }
.icon-btn.sm { width: 30px; height: 30px; border-radius: 9px; font-size: 13px; }
@media (min-width: 1000px) {
  .detail-pane { left: auto; right: 20px; top: 76px; bottom: auto; width: 400px; max-height: calc(100vh - 220px); }
  body.detail-open .stage { padding-right: 440px; }
}
.heard { min-height: 1.4em; font-size: 14px; color: var(--listen); text-shadow: 0 0 10px rgba(77,255,198,.5); font-style: italic; text-align: center; max-width: 760px; }

/* Compositor de texto */
.composer { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(112px + var(--safe-b)); z-index: 6; width: min(760px, calc(100% - 32px));
  display: flex; gap: 8px; align-items: flex-end; padding: 8px; border-radius: 18px; background: rgba(6,22,36,.85); border: 1px solid var(--line); backdrop-filter: blur(10px);
  box-shadow: 0 0 30px rgba(79,220,255,.12); }
.composer textarea { flex: 1; resize: none; border: 0; outline: 0; background: transparent; padding: 8px 10px; max-height: 140px; font-size: 16px; }
.send { width: 44px; height: 44px; border-radius: 14px; border: 0; background: var(--holo); display: grid; place-items: center; cursor: pointer; flex: none; }
.send svg { width: 20px; height: 20px; fill: #02131c; }
body.typing .stage { bottom: calc(184px + var(--safe-b)); }

/* Controles */
.controls { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; display: flex; justify-content: center; align-items: flex-end; gap: clamp(14px, 5vw, 34px);
  padding: 10px 16px calc(14px + var(--safe-b)); background: linear-gradient(to top, rgba(2,6,13,.9), transparent); }
.ctl { border: 0; background: none; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 6px; color: var(--muted); padding: 0; min-width: 64px; }
.ctl .ring { width: 54px; height: 54px; border-radius: 50%; display: grid; place-items: center; border: 1px solid var(--line); background: rgba(6,24,38,.6);
  backdrop-filter: blur(6px); transition: transform .15s, border-color .2s, box-shadow .2s, background .2s; }
.ctl svg { width: 24px; height: 24px; fill: none; stroke: var(--ink); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.ctl .lbl { font-size: 12px; letter-spacing: .04em; }
.ctl:hover .ring { border-color: var(--holo); }
.ctl:active .ring { transform: scale(.94); }
.ctl.main .ring { width: 74px; height: 74px; border-color: rgba(79,220,255,.6); box-shadow: 0 0 24px rgba(79,220,255,.25), inset 0 0 18px rgba(79,220,255,.15); }
.ctl.main svg { width: 30px; height: 30px; }
.ctl.main.on .ring { border-color: var(--listen); background: rgba(10,60,48,.55); box-shadow: 0 0 0 0 rgba(77,255,198,.5), 0 0 34px rgba(77,255,198,.45); animation: ping 1.6s ease-out infinite; }
.ctl.main.on .lbl { color: var(--listen); }
@keyframes ping { 0% { box-shadow: 0 0 0 0 rgba(77,255,198,.45), 0 0 34px rgba(77,255,198,.45); } 100% { box-shadow: 0 0 0 22px rgba(77,255,198,0), 0 0 34px rgba(77,255,198,.45); } }
.ctl.active .ring { border-color: var(--danger); background: rgba(60,10,20,.5); }
.ctl.active .lbl { color: var(--danger); }
.ctl.sel .ring { border-color: var(--holo); background: rgba(10,50,70,.6); }
.ctl:disabled { opacity: .35; cursor: not-allowed; }

/* Paneles laterales */
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(440px, 100%); z-index: 10; background: rgba(4,14,24,.94); border-left: 1px solid var(--line);
  backdrop-filter: blur(14px); transform: translateX(105%); transition: transform .28s ease; display: flex; flex-direction: column; padding-top: var(--safe-t); }
.drawer.open { transform: none; }
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.drawer-head h2 { margin: 0; font-size: 15px; letter-spacing: .14em; text-transform: uppercase; color: var(--holo); font-weight: 600; }
.log { flex: 1; overflow-y: auto; padding: 14px 16px calc(20px + var(--safe-b)); display: flex; flex-direction: column; gap: 12px; }
.msg { max-width: 92%; padding: 10px 13px; border-radius: 14px; font-size: 14.5px; overflow-wrap: anywhere; }
.msg.user { align-self: flex-end; background: rgba(79,220,255,.12); border: 1px solid rgba(79,220,255,.25); }
.msg.assistant { align-self: flex-start; background: rgba(255,255,255,.04); border: 1px solid rgba(255,255,255,.08); }
.msg.err { border-color: rgba(255,107,125,.5); color: #ffc2ca; }
.msg time { display: block; font-size: 11px; color: var(--muted); margin-top: 4px; }
.msg p { margin: 0 0 6px; } .msg p:last-child { margin-bottom: 0; }
.md table { border-collapse: collapse; width: 100%; font-size: 13px; margin: 6px 0; display: block; overflow-x: auto; }
.md th, .md td { border: 1px solid rgba(79,220,255,.2); padding: 4px 7px; text-align: left; white-space: nowrap; }
.md th { color: var(--holo); font-weight: 600; }
.md ul, .md ol { margin: 4px 0; padding-left: 20px; }
.md code { background: rgba(255,255,255,.07); padding: 1px 5px; border-radius: 5px; font-size: 13px; }
.md h3, .md h4 { margin: 8px 0 4px; font-size: 14.5px; color: var(--holo); }
.md hr { border: 0; border-top: 1px solid var(--line); }
.md a { color: var(--holo); }

.form { padding: 16px; display: flex; flex-direction: column; gap: 14px; overflow-y: auto; }
.form label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.form label.check { flex-direction: row; align-items: flex-start; gap: 10px; color: var(--ink); }
.form select, .form input[type=range] { width: 100%; }
.form select { background: rgba(255,255,255,.05); border: 1px solid var(--line); border-radius: 10px; padding: 9px; }
.form select option { background: #06121e; }
.form hr { width: 100%; border: 0; border-top: 1px solid var(--line); }
.hint { font-size: 12.5px; color: var(--muted); margin: 0; }
.btn { display: inline-flex; justify-content: center; align-items: center; gap: 8px; padding: 11px 16px; border-radius: 12px; border: 1px solid rgba(79,220,255,.55);
  background: rgba(79,220,255,.12); color: var(--ink); cursor: pointer; text-decoration: none; font-weight: 500; }
.btn:hover { background: rgba(79,220,255,.22); }
.btn.ghost { background: transparent; border-color: var(--line); }
.btn.danger { border-color: rgba(255,107,125,.5); background: rgba(255,107,125,.08); color: #ffc2ca; }
.btn.big { padding: 15px 28px; font-size: 16px; letter-spacing: .08em; border-radius: 99px; box-shadow: 0 0 30px rgba(79,220,255,.3); }

/* Arranque e inicio de sesión */
.overlay { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; background: radial-gradient(80% 60% at 50% 45%, rgba(4,20,34,.55), rgba(1,4,9,.92)); transition: opacity .7s; }
.overlay.gone { opacity: 0; pointer-events: none; }
.boot-card { text-align: center; padding: 24px; width: min(360px, 100%); }
.boot-logo { font-size: 30px; letter-spacing: .5em; padding-left: .5em; color: var(--holo); font-weight: 300; text-shadow: 0 0 22px rgba(79,220,255,.8); }
.boot-sub { color: var(--muted); margin: 10px 0 26px; font-size: 14px; }
.login { display: flex; flex-direction: column; gap: 12px; }
.login input { padding: 13px 14px; border-radius: 12px; border: 1px solid var(--line); background: rgba(255,255,255,.05); text-align: center; font-size: 18px; letter-spacing: .2em; outline: none; }
.login input:focus { border-color: var(--holo); }
.err { color: var(--danger); font-size: 13px; min-height: 1.2em; margin: 0; }

@media (max-width: 560px) {
  .brand { font-size: 12px; letter-spacing: .25em; }
  .status { font-size: 11px; padding: 3px 10px; }
  .caption { font-size: 16px; max-height: 26vh; }
  .ctl { min-width: 56px; }
  .ctl .ring { width: 50px; height: 50px; }
  .ctl.main .ring { width: 68px; height: 68px; }
}
@media (prefers-reduced-motion: reduce) { .scanlines { animation: none; } .ctl.main.on .ring { animation: none; } }

.sub { margin: 0; font-size: 12px; letter-spacing: .14em; text-transform: uppercase; color: var(--holo); font-weight: 600; }
.usage-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.usage-grid div { border: 1px solid var(--line); border-radius: 12px; padding: 10px; background: rgba(255,255,255,.03); display: flex; flex-direction: column; }
.usage-grid b { font-size: 18px; color: var(--ink); font-weight: 600; }
.usage-grid span { font-size: 12px; color: var(--muted); }

/* ---------- Paneles holográficos ---------- */
.panels { position: fixed; z-index: 2; top: calc(64px + var(--safe-t)); bottom: calc(150px + var(--safe-b)); left: 0; right: 0;
  display: grid; grid-template-columns: 1fr var(--face-w, 380px) 1fr; padding: 0 24px; pointer-events: none; }
.panels .col { display: flex; flex-direction: column; justify-content: center; gap: 14px; min-width: 0; pointer-events: auto; }
.panels .col.left { grid-column: 1; align-items: flex-end; padding-right: 18px; }
.panels .col.right { grid-column: 3; align-items: flex-start; padding-left: 18px; }
.holo-card { position: relative; width: min(340px, 100%); padding: 12px 14px 14px; border-radius: 14px;
  background: linear-gradient(160deg, rgba(14,48,78,.42), rgba(4,16,30,.55)); border: 1px solid rgba(79,220,255,.28);
  box-shadow: 0 0 24px rgba(79,220,255,.10), inset 0 0 22px rgba(79,220,255,.06); backdrop-filter: blur(6px); opacity: 0; }
.holo-card.in { animation: cardIn .55s cubic-bezier(.2,.8,.2,1) forwards; }
@keyframes cardIn { from { opacity: 0; transform: translateY(10px) scale(.97); filter: blur(3px); } to { opacity: 1; transform: none; filter: none; } }
.holo-card::before, .holo-card::after { content: ""; position: absolute; width: 14px; height: 14px; border: 2px solid var(--holo); opacity: .7; }
.holo-card::before { top: -1px; left: -1px; border-right: 0; border-bottom: 0; border-top-left-radius: 14px; }
.holo-card::after { bottom: -1px; right: -1px; border-left: 0; border-top: 0; border-bottom-right-radius: 14px; }
.holo-card header { display: flex; align-items: center; gap: 8px; font-size: 11px; letter-spacing: .16em; text-transform: uppercase; color: var(--holo); margin-bottom: 10px; }
.holo-card header .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--holo); box-shadow: 0 0 8px var(--holo); }
.items { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 7px; }
.items li { display: flex; align-items: center; gap: 9px; font-size: 13.5px; }
.items li span { flex: 1; min-width: 0; }
.items li em { font-style: normal; font-size: 12px; color: var(--muted); white-space: nowrap; }
.st { width: 20px; height: 20px; flex: none; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.st.ok { stroke: var(--holo); filter: drop-shadow(0 0 4px rgba(79,220,255,.7)); }
.st.warn { stroke: #ffb547; filter: drop-shadow(0 0 4px rgba(255,181,71,.6)); }
.st.bad { stroke: var(--danger); filter: drop-shadow(0 0 4px rgba(255,107,125,.6)); }
.st.info { stroke: #9a86ff; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px; }
.kpis > div { padding: 8px 10px; border-radius: 10px; background: rgba(79,220,255,.06); border: 1px solid rgba(79,220,255,.14); display: flex; flex-direction: column; min-width: 0; }
.kpis b { font-size: 19px; font-weight: 600; color: #eafaff; text-shadow: 0 0 12px rgba(79,220,255,.45); overflow-wrap: anywhere; line-height: 1.25; }
.kpis span { font-size: 11.5px; color: var(--muted); }
.kpis small { font-size: 11px; color: var(--muted); }
.kpi.alerta b { color: #ffd38a; text-shadow: 0 0 12px rgba(255,181,71,.5); }
.kpi.mal b { color: #ffb0ba; text-shadow: 0 0 12px rgba(255,107,125,.5); }
.clock b { display: block; font-size: 30px; font-weight: 300; letter-spacing: .04em; color: #eafaff; text-shadow: 0 0 16px rgba(79,220,255,.5); }
.clock span { font-size: 12.5px; color: var(--muted); text-transform: capitalize; }
.clock + .kpis { margin-top: 10px; }
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart .grid { stroke: rgba(79,220,255,.13); stroke-width: 1; }
.chart .ax { fill: var(--muted); font-size: 9px; }
.chart .bar { filter: drop-shadow(0 0 4px rgba(79,220,255,.6)); transform-origin: bottom; transform-box: fill-box; animation: grow .7s cubic-bezier(.2,.8,.2,1) both; }
@keyframes grow { from { transform: scaleY(0); } }
.chart .line { stroke-width: 2; filter: drop-shadow(0 0 4px rgba(79,220,255,.7)); }
.chart .area { fill: rgba(79,220,255,.12); }
.legend { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 6px; font-size: 11.5px; color: var(--muted); }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.wave { width: 100%; height: 56px; display: block; }
.q { margin: 0; font-size: 14px; color: var(--ink); }

/* Celular: la cara arriba y los paneles en una franja deslizable */
@media (max-width: 759px) {
  .panels { display: none; }
  body.has-data .panels { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; gap: 12px; padding: 0 16px;
    top: calc(64px + 34vh); bottom: auto; height: auto; max-height: calc(100vh - 64px - 34vh - 230px); align-items: flex-start; }
  body.has-data .panels .col { display: contents; }
  body.has-data .holo-card { flex: 0 0 84vw; width: 84vw; scroll-snap-align: center; max-height: 100%; overflow-y: auto; }
  body.has-data .wave-card { display: none; }
  body.has-data .caption { max-height: 15vh; }
}
@media (min-width: 760px) and (max-width: 1100px) {
  .panels { padding: 0 10px; }
  .holo-card { width: min(270px, 100%); }
  .kpis { grid-template-columns: 1fr; }
}
