:root {
  --bg: #0f1724; --panel: #172235; --panel2: #1e2b42; --line: #2a3a55;
  --text: #e6edf7; --muted: #8fa1bd; --accent: #2f8cff; --accent2: #1f6fd6;
  --ok: #2ecc71; --warn: #f5a623; --bad: #ff5c5c; --radius: 10px;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-size: 14px; }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
button { background: var(--accent); border: 0; color: #fff; padding: 8px 14px; border-radius: 8px; cursor: pointer; }
button:hover { background: var(--accent2); }
button.ghost { background: transparent; border: 1px solid var(--line); color: var(--text); }
button.ghost:hover { background: var(--panel2); }
button.danger { background: var(--bad); }
button:disabled { opacity: .45; cursor: not-allowed; }
input, select, textarea { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; width: 100%; }
textarea { resize: vertical; min-height: 120px; }
label { display: block; color: var(--muted); margin: 10px 0 4px; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.center { display: grid; place-items: center; min-height: 100vh; }
.muted { color: var(--muted); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; }
.auth { width: 360px; }
.auth h1 { margin: 0 0 4px; font-size: 20px; }
.auth .brand { color: var(--accent); font-weight: 700; letter-spacing: .02em; }
.auth button { width: 100%; margin-top: 16px; }
.err { color: var(--bad); min-height: 18px; margin-top: 8px; }
.qr { display: block; margin: 12px auto; background: #fff; padding: 8px; border-radius: 8px; }
code.secret { display: block; text-align: center; letter-spacing: .15em; padding: 6px; background: var(--bg); border-radius: 6px; }

header.top { display: flex; align-items: center; gap: 18px; padding: 10px 18px; background: var(--panel); border-bottom: 1px solid var(--line); }
header.top .brand { font-weight: 700; color: var(--accent); }
header.top nav { display: flex; gap: 4px; flex: 1; }
header.top nav a { padding: 6px 12px; border-radius: 8px; color: var(--muted); text-decoration: none; cursor: pointer; }
header.top nav a.active { background: var(--panel2); color: var(--text); }
.me { display: flex; align-items: center; gap: 10px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--panel2); object-fit: cover; display: inline-grid; place-items: center; font-weight: 600; }
.avatar.lg { width: 96px; height: 96px; font-size: 32px; }
main { padding: 18px; }
h2 { margin: 0 0 14px; font-size: 18px; }
.row { display: flex; gap: 12px; align-items: center; }
.spacer { flex: 1; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

table { width: 100%; border-collapse: collapse; background: var(--panel); border-radius: var(--radius); overflow: hidden; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 500; font-size: 12px; text-transform: uppercase; background: var(--panel2); }
tr.clickable:hover td { background: #1b2840; cursor: pointer; }
.small { font-size: 12px; color: var(--muted); }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; background: var(--muted); }
.dot.on { background: var(--ok); box-shadow: 0 0 6px var(--ok); }
.badge { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 12px; background: var(--panel2); border: 1px solid var(--line); }
.badge.now { background: #3a1e1e; border-color: var(--bad); color: #ffb3b3; }
.badge.ok { border-color: var(--ok); color: var(--ok); }
.badge.warn { border-color: var(--warn); color: var(--warn); }
.badge.bad { border-color: var(--bad); color: var(--bad); }
.empty { padding: 40px; text-align: center; color: var(--muted); }

.modal-back { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: grid; place-items: center; z-index: 50; }
.modal { width: min(560px, 94vw); max-height: 90vh; overflow: auto; }
.modal h3 { margin-top: 0; }
.modal .actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }
.kv { display: grid; grid-template-columns: 160px 1fr; gap: 6px 12px; }
.kv div:nth-child(odd) { color: var(--muted); }

/* --- Integraciones --- */
label.chk { display: inline-flex; align-items: center; gap: 6px; margin: 0; text-transform: none; letter-spacing: 0; font-size: 13px; color: var(--text); cursor: pointer; }
label.chk input { width: auto; }
.warnbox { border-color: var(--warn); color: var(--warn); margin-bottom: 14px; }
pre.errbox { white-space: pre-wrap; word-break: break-word; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 10px; color: var(--bad); max-height: 300px; overflow: auto; }
iframe.preview { width: 100%; height: 520px; border: 1px solid var(--line); border-radius: 8px; background: #fff; margin-top: 6px; }
code { background: var(--bg); border-radius: 4px; padding: 1px 5px; }
@media (max-width: 900px) { .grid2 { grid-template-columns: 1fr; } }

#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 100; }
#toast div { background: var(--panel2); border: 1px solid var(--line); padding: 10px 16px; border-radius: 8px; margin-top: 6px; }

/* --- Sesión remota --- */
.session { position: fixed; inset: 0; background: #05080d; display: flex; flex-direction: column; z-index: 40; }
.session .bar { display: flex; align-items: center; gap: 10px; padding: 6px 12px; background: var(--panel); border-bottom: 1px solid var(--line); }
.session .bar .tabs { display: flex; gap: 2px; margin-left: 12px; }
.session .bar .tabs button { background: transparent; color: var(--muted); border-radius: 6px; padding: 6px 12px; }
.session .bar .tabs button.active { background: var(--panel2); color: var(--text); }
.session .timer { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--ok); }
.session .stage { flex: 1; display: grid; place-items: center; overflow: hidden; position: relative; }
.session canvas { max-width: 100%; max-height: 100%; outline: none; cursor: none; background: #000; }
.session canvas:focus { box-shadow: 0 0 0 2px var(--accent); }
.session .overlay { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); pointer-events: none; }
.session .pane { padding: 30px; color: var(--muted); }
.session select { width: auto; padding: 4px 8px; }
.session .tabs .count { display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 6px; border-radius: 9px; background: var(--bad); color: #fff; font-size: 11px; line-height: 18px; }
.chatpane { width: min(760px, 100%); height: 100%; display: flex; flex-direction: column; background: var(--panel); border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
.chatlog { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.chatlog .msg { max-width: 75%; padding: 8px 12px; border-radius: 12px; line-height: 1.4; white-space: pre-wrap; overflow-wrap: anywhere; }
.chatlog .msg.client { background: var(--panel2); align-self: flex-start; border-bottom-left-radius: 4px; }
.chatlog .msg.agent { background: var(--accent2); color: #fff; align-self: flex-end; border-bottom-right-radius: 4px; }
.chatlog .msg small { display: block; opacity: .65; font-size: 11px; margin-top: 3px; }
.chatlog .sys { align-self: center; color: var(--muted); font-size: 12px; }
.chatform { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--line); }
.chatform textarea { flex: 1; min-height: 44px; height: 44px; resize: none; }
.transcript { max-height: 260px; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.transcript .msg { max-width: 85%; padding: 6px 10px; border-radius: 10px; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 13px; }
.transcript .msg.client { background: var(--panel2); align-self: flex-start; }
.transcript .msg.agent { background: var(--accent2); color: #fff; align-self: flex-end; }
.transcript .msg small { display: block; opacity: .65; font-size: 11px; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin-top: 8px; }
.gallery a { display: block; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; color: var(--muted); font-size: 11px; text-decoration: none; }
.gallery img { display: block; width: 100%; aspect-ratio: 16/10; object-fit: cover; background: #000; }
.gallery span { display: block; padding: 3px 6px; }

/* Pestaña Archivos */
.filespane { width: 100%; height: 100%; display: grid; grid-template-columns: 1fr auto 1fr; grid-template-rows: 1fr 190px; gap: 8px; padding: 8px; background: var(--bg); }
.filespane .fcol { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; }
.filespane .fcol.over { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(47,140,255,.35) inset; }
.filespane .fhead { display: flex; align-items: center; gap: 6px; padding: 8px 10px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.filespane button.sm { padding: 4px 9px; font-size: 12px; }
.filespane button.danger-t { color: var(--bad); }
.filespane label.chk.sm { font-size: 12px; margin: 0; }
.filespane .fpath { padding: 6px 10px; font-size: 12px; color: var(--muted); border-bottom: 1px solid var(--line); margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.filespane .fpath input { width: 100%; padding: 4px 8px; font-family: Consolas, monospace; font-size: 12px; }
.filespane .flist { flex: 1; overflow-y: auto; user-select: none; }
.filespane .frow { display: grid; grid-template-columns: 22px 1fr 80px 110px; gap: 8px; align-items: center; padding: 4px 10px; font-size: 13px; cursor: default; border-bottom: 1px solid rgba(255,255,255,.03); }
.filespane .frow:hover { background: var(--panel2); }
.filespane .frow.sel { background: rgba(47,140,255,.25); }
.filespane .frow.hid { opacity: .55; }
.filespane .frow .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.filespane .frow .sz, .filespane .frow .dt { font-size: 11.5px; color: var(--muted); text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.filespane .fempty { padding: 16px; color: var(--muted); text-align: center; }
.filespane .fempty.err { color: var(--bad); }
.filespane .fmid { display: flex; flex-direction: column; justify-content: center; gap: 10px; }
.filespane .fxfers { grid-column: 1 / -1; display: flex; flex-direction: column; min-height: 0; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; }
.filespane .fxfers [data-x="list"] { flex: 1; overflow-y: auto; }
.filespane .xrow { display: grid; grid-template-columns: 20px minmax(120px, 1.2fr) 1fr minmax(160px, 1.3fr) auto; gap: 10px; align-items: center; padding: 5px 10px; font-size: 12.5px; border-bottom: 1px solid rgba(255,255,255,.03); }
.filespane .xrow .dir { color: var(--accent); font-weight: 700; text-align: center; }
.filespane .xrow .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.filespane .xrow .bar { height: 6px; background: var(--panel2); border-radius: 3px; overflow: hidden; }
.filespane .xrow .bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.filespane .xrow.done .bar i { background: var(--ok); }
.filespane .xrow.error .bar i, .filespane .xrow.cancelled .bar i { background: var(--bad); }
.filespane .xrow .st { color: var(--muted); font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.filespane .xrow.error .st { color: var(--bad); }
table.fops { width: 100%; margin-top: 6px; font-size: 12.5px; }
table.fops td { padding: 3px 6px; vertical-align: top; }
table.fops td.path { word-break: break-all; font-family: Consolas, monospace; font-size: 12px; }
table.fops tr.bad td { color: var(--bad); }

/* Pestaña Consola */
.shellpane { width: 100%; height: 100%; display: flex; flex-direction: column; background: #0b111b; }
.shellpane .shbar { display: flex; align-items: center; gap: 8px; padding: 6px 10px; background: var(--panel); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.shellpane .shbar select { width: auto; }
.shellpane .shterm { flex: 1; min-height: 0; padding: 6px 0 0 8px; }
.shellpane .shterm .xterm { height: 100%; }
.shellpane .fempty { padding: 30px; color: var(--muted); text-align: center; }
pre.code { background: #0b111b; border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; font-family: Consolas, monospace; font-size: 12px; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 260px; overflow-y: auto; margin: 6px 0 0; }
pre.code.console { max-height: 420px; }
.scriptlist { display: flex; flex-direction: column; gap: 8px; max-height: 60vh; overflow-y: auto; }
.scriptitem { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
button.danger-t { color: var(--bad); }
