/* NCRemote — painel web.
   Paleta inspirada no UltraViewer: faixa azul-ciano, títulos azuis em
   painéis claros, botão de ação principal laranja. */
:root {
  --blue: #1e90d6; --blue-2: #1679b8; --cyan: #35b3ea; --blue-text: #1a8ad0;
  --blue-soft: #e8f3fc; --blue-line: #c9e1f5;
  --orange: #f7941d; --orange-2: #e07f08;
  --bg: #f3f5fa; --surface: #ffffff; --surface-2: #f7f9fc; --line: #dde3ec;
  --text: #2b3440; --muted: #6b7684;
  --ok: #34a853; --ok-soft: #e6f5ea; --danger: #e04b3f; --danger-soft: #fdeceb; --warn: #e39b00; --warn-soft: #fff4dc;
  --radius: 6px;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  font-size: 14px; color: var(--text); background: var(--bg);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.spacer { flex: 1; }
.error { color: var(--danger); min-height: 1.2em; margin: 0; font-size: 13px; }

/* ---------- controles ---------- */
input, select { font: inherit; color: var(--text); background: #fff; border: 1px solid var(--line); border-radius: 4px; padding: 8px 10px; outline: none; }
input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-soft); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid transparent; border-radius: 4px; padding: 8px 16px; font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; }
.btn.orange { background: var(--orange); color: #fff; }
.btn.orange:hover { background: var(--orange-2); }
.btn.blue { background: var(--blue); color: #fff; }
.btn.blue:hover { background: var(--blue-2); }
.btn.blue-outline { background: #fff; color: var(--blue); border-color: var(--blue-line); padding: 8px 10px; }
.btn.blue-outline:hover { background: var(--blue-soft); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.ghost-light { background: rgba(255,255,255,.15); color: #fff; border-color: rgba(255,255,255,.35); font-weight: 500; }
.btn.ghost-light:hover { background: rgba(255,255,255,.25); }
.btn.sm { padding: 5px 12px; font-size: 13px; }
.btn:disabled { opacity: .45; cursor: default; }
.icon-btn { width: 30px; height: 30px; border: 0; border-radius: 4px; background: transparent; color: var(--muted); display: inline-grid; place-items: center; cursor: pointer; }
.icon-btn:hover { background: var(--blue-soft); color: var(--blue); }
.chip { font-size: 12px; padding: 2px 10px; border-radius: 10px; background: #eef1f6; color: var(--muted); white-space: nowrap; }
.chip.ok { background: var(--ok-soft); color: var(--ok); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.err { background: var(--danger-soft); color: var(--danger); }
.dot { width: 10px; height: 10px; border-radius: 50%; background: #b7bec8; display: inline-block; flex: none; }
.dot.on { background: #7cc843; box-shadow: 0 0 0 2px #fff, 0 0 0 3px #7cc843; }
.badge { position: absolute; top: -5px; right: -5px; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px; background: var(--danger); color: #fff; font-size: 11px; line-height: 17px; font-weight: 600; }

/* logo */
.logo-mark { width: 40px; height: 40px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #5cc4f2, #1673c4); color: #fff; display: grid; place-items: center; box-shadow: inset 0 -2px 0 rgba(0,0,0,.15); }
.logo-mark svg { width: 22px; height: 22px; }
.logo-mark.sm { width: 32px; height: 32px; }
.logo-mark.sm svg { width: 18px; height: 18px; }
.logo-text { font-size: 22px; letter-spacing: .02em; color: #fff; font-weight: 300; }
.logo-text b { font-weight: 700; }

/* painel no estilo UltraViewer: cabeçalho azul claro com título azul */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.panel-head { display: flex; align-items: center; gap: 8px; padding: 10px 16px; background: linear-gradient(#f4f9fe, var(--blue-soft)); border-bottom: 1px solid var(--blue-line); border-radius: var(--radius) var(--radius) 0 0; }
.panel-head h1, .panel-head h3 { margin: 0; color: var(--blue-text); font-weight: 600; font-size: 17px; flex: 1; }
.panel-body { padding: 16px; }

/* ---------- login ---------- */
.login { height: 100%; display: flex; flex-direction: column; align-items: center; background: var(--bg); }
.login-band { width: 100%; height: 220px; padding-top: 56px; display: flex; align-items: flex-start; justify-content: center; gap: 12px; background: linear-gradient(100deg, var(--blue), var(--cyan)); }
.login-band .logo-mark { width: 52px; height: 52px; }
.login-band .logo-text { font-size: 30px; }
.login-card { width: 360px; margin-top: -50px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 8px 24px rgba(20,60,100,.12); }
.login-card .panel-body { display: grid; gap: 14px; }
.login-card label { display: grid; gap: 5px; font-size: 13px; color: var(--muted); }

/* ---------- estrutura ---------- */
.app { height: 100%; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 10px; padding: 0 18px; height: 56px; background: linear-gradient(100deg, var(--blue), var(--cyan)); color: #fff; }
.topbar .logo-text { font-size: 19px; margin-right: 18px; }
.topnav { display: flex; height: 100%; }
.topnav-btn { position: relative; border: 0; background: transparent; color: rgba(255,255,255,.85); font: inherit; font-weight: 600; letter-spacing: .03em; text-transform: uppercase; font-size: 13px; padding: 0 16px; cursor: pointer; }
.topnav-btn:hover:not(:disabled) { color: #fff; background: rgba(255,255,255,.1); }
.topnav-btn.active { color: #fff; background: rgba(0,0,0,.1); }
.topnav-btn.active::after { content: ""; position: absolute; left: 50%; bottom: 0; transform: translateX(-50%); border: 7px solid transparent; border-bottom-color: var(--bg); }
.topnav-btn:disabled { opacity: .5; cursor: default; }
.live-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #ff5b4f; margin-left: 4px; vertical-align: middle; animation: pulse 1.4s infinite; }
@keyframes pulse { 50% { opacity: .3; } }
.who { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.avatar { width: 28px; height: 28px; border-radius: 50%; background: rgba(255,255,255,.25); display: grid; place-items: center; font-weight: 700; text-transform: uppercase; }

.main { flex: 1; min-height: 0; display: flex; }
.page { flex: 1; min-width: 0; overflow-y: auto; padding: 22px 26px; display: flex; flex-direction: column; gap: 16px; }
.page-title { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.page-title h2 { margin: 0 6px 0 0; font-size: 20px; color: var(--text); text-transform: uppercase; letter-spacing: .02em; }
.search { position: relative; }
.search svg { position: absolute; left: 9px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--muted); }
.search input { padding-left: 32px; width: 300px; }

/* ---------- tabela ---------- */
.machines-layout { display: flex; gap: 16px; align-items: flex-start; }
.table-panel { flex: 1; min-width: 0; overflow: hidden; }
table.machines { width: 100%; border-collapse: collapse; }
.machines th { text-align: left; font-size: 12px; font-weight: 600; color: var(--blue-text); text-transform: uppercase; letter-spacing: .04em; padding: 11px 14px; background: linear-gradient(#f4f9fe, var(--blue-soft)); border-bottom: 1px solid var(--blue-line); }
.machines td { padding: 10px 14px; border-bottom: 1px solid #edf0f5; vertical-align: middle; }
.machines tr:last-child td { border-bottom: 0; }
.machines tbody tr { cursor: pointer; }
.machines tbody tr:hover { background: #f6fafe; }
.machines tbody tr.selected { background: var(--blue-soft); }
.machines tr.offline td:not(.actions) { color: var(--muted); }
.m-name { display: flex; align-items: center; gap: 11px; }
.m-name strong { display: block; }
.m-name small { color: var(--muted); font-variant-numeric: tabular-nums; letter-spacing: .03em; }
.pc-ico { width: 34px; height: 34px; border-radius: 6px; background: var(--blue-soft); color: var(--blue); display: grid; place-items: center; position: relative; }
.pc-ico .dot { position: absolute; right: -3px; bottom: -3px; }
.mono { font-family: Consolas, ui-monospace, monospace; font-size: 13px; }
.actions { text-align: right; white-space: nowrap; }
.empty { padding: 48px 20px; text-align: center; color: var(--muted); }
.empty svg { width: 40px; height: 40px; color: var(--blue); }
.empty p { margin: 6px 0; }

/* ---------- detalhe ---------- */
.detail { width: 340px; flex: none; position: sticky; top: 0; }
.d-actions { display: flex; gap: 6px; margin-bottom: 14px; }
.d-actions .btn.orange { flex: 1; }
.info { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; margin: 0 0 6px; font-size: 13px; }
.info dt { color: var(--muted); }
.info dd { margin: 0; word-break: break-word; }
.detail h4 { margin: 14px 0 6px; font-size: 12px; color: var(--blue-text); text-transform: uppercase; letter-spacing: .04em; }
.disks, .nics { display: grid; gap: 8px; font-size: 13px; }
.bar { height: 6px; border-radius: 3px; background: #e7ecf3; overflow: hidden; margin-top: 3px; }
.bar span { display: block; height: 100%; background: var(--blue); }
.bar span.high { background: var(--danger); }
.nic { border: 1px solid #edf0f5; border-radius: 4px; padding: 7px 9px; }
.nic strong { display: block; font-size: 12px; }

/* ---------- sessão ---------- */
.page.session { padding: 0; gap: 0; background: #0b1118; }
.session-bar { display: flex; align-items: center; gap: 10px; padding: 7px 12px; background: var(--surface); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.session-title { display: flex; align-items: center; gap: 10px; }
.session-title strong { display: block; line-height: 1.2; }
.session-title small { color: var(--muted); font-variant-numeric: tabular-nums; }
.tool-group { display: flex; border: 1px solid var(--blue-line); border-radius: 4px; overflow: hidden; }
.tool { position: relative; border: 0; background: #fff; color: var(--blue-text); font: inherit; font-size: 12px; font-weight: 600; padding: 6px 10px; cursor: pointer; }
.tool-group .tool + .tool { border-left: 1px solid var(--blue-line); }
.tool:hover { background: var(--blue-soft); }
.tool.icon { border: 1px solid var(--blue-line); border-radius: 4px; padding: 5px 7px; display: grid; place-items: center; }
.tool.icon.on { background: var(--blue); color: #fff; border-color: var(--blue); }
.session-body { flex: 1; display: flex; min-height: 0; }
#screen-wrap { flex: 1; position: relative; outline: none; overflow: hidden; }
#screen-wrap:focus-visible { box-shadow: inset 0 0 0 2px var(--orange); }
#remote { width: 100%; height: 100%; object-fit: contain; display: block; }
.screen-msg { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; color: #9fb3c8; pointer-events: none; }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid rgba(159,179,200,.25); border-top-color: var(--cyan); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.chat { width: 320px; display: flex; flex-direction: column; background: var(--surface); border-left: 1px solid var(--line); }
.chat-head { display: flex; align-items: baseline; gap: 8px; padding: 11px 14px; background: linear-gradient(#f4f9fe, var(--blue-soft)); border-bottom: 1px solid var(--blue-line); color: var(--blue-text); }
.chat-head .small { color: var(--muted); }
.chat-log { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.msg { max-width: 85%; padding: 7px 11px; border-radius: 10px; white-space: pre-wrap; word-break: break-word; font-size: 13.5px; }
.msg small { display: block; font-size: 11px; opacity: .75; margin-bottom: 2px; }
.msg.tech { align-self: flex-end; background: var(--blue); color: #fff; border-bottom-right-radius: 3px; }
.msg.user { align-self: flex-start; background: #eef2f7; border-bottom-left-radius: 3px; }
.chat-form { display: flex; gap: 6px; padding: 10px; border-top: 1px solid var(--line); }
.chat-form input { flex: 1; min-width: 0; }

.session.chat-only .tool-group, .session.chat-only #btn-reboot, .session.chat-only #btn-fullscreen, .session.chat-only #btn-chat-toggle, .session.chat-only #screen-wrap, .session.chat-only #session-state { display: none; }
.session.chat-only .chat { width: 100%; border-left: 0; }
.session.chat-only #btn-end { background: #fff; color: var(--text); border-color: var(--line); }

/* ---------- sessões em abas ---------- */
body.embed .topbar { display: none; }
body.embed .app { height: 100%; }
.page.tabs-page { padding: 0; gap: 0; }
.tabstrip { display: flex; gap: 2px; padding: 6px 8px 0; background: #dfe7f1; border-bottom: 1px solid var(--blue-line); overflow-x: auto; flex: none; }
.tabstrip:empty { display: none; }
.tab { display: flex; align-items: center; gap: 8px; padding: 7px 8px 7px 12px; border-radius: 6px 6px 0 0; background: #eef3f9; color: var(--muted); cursor: pointer; white-space: nowrap; font-size: 13px; border: 1px solid transparent; border-bottom: 0; max-width: 240px; }
.tab:hover { background: #f6f9fc; }
.tab.active { background: #fff; color: var(--text); border-color: var(--blue-line); font-weight: 600; }
.tab .t-name { overflow: hidden; text-overflow: ellipsis; }
.tab .t-close { border: 0; background: transparent; color: var(--muted); width: 20px; height: 20px; border-radius: 4px; cursor: pointer; font-size: 15px; line-height: 1; }
.tab .t-close:hover { background: var(--danger-soft); color: var(--danger); }
.tab .dot.warn { background: var(--warn); }
.tab .dot.err { background: var(--danger); }
.tabframes { flex: 1; position: relative; background: #0b1118; }
.tabframes iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: #0b1118; }
.tabframes .empty { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; background: var(--bg); }
.nav-count { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 9px; background: rgba(255,255,255,.25); font-size: 11px; line-height: 18px; text-align: center; }
.app-banner { position: fixed; top: 64px; right: 16px; z-index: 30; display: flex; align-items: center; gap: 10px; background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: 8px 8px 8px 14px; box-shadow: 0 6px 18px rgba(20,60,100,.15); font-size: 13px; }

/* ---------- energia ---------- */
.power { display: flex; flex-wrap: wrap; gap: 6px; }
.wol-note { margin: 6px 0 0; line-height: 1.4; }
#btn-reboot { border: 1px solid var(--blue-line); border-radius: 4px; }

/* ---------- administração ---------- */
body:not(.is-admin) .admin-only { display: none !important; }
.who { display: flex; align-items: center; gap: 8px; font: inherit; font-size: 13px; color: #fff; background: transparent; border: 0; padding: 4px 8px; border-radius: 4px; cursor: pointer; }
.who:hover, .who.active { background: rgba(255,255,255,.15); }
.who .chip { font-size: 11px; }
select { font: inherit; color: var(--text); background: #fff; border: 1px solid var(--line); border-radius: 4px; padding: 7px 9px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(380px, 1fr)); gap: 16px; align-items: start; }
.form { display: grid; gap: 12px; }
.form label { display: grid; gap: 5px; font-size: 13px; color: var(--muted); }
.form label.row { display: flex; align-items: center; gap: 8px; color: var(--text); }
.form .checks { display: grid; gap: 6px; max-height: 180px; overflow-y: auto; border: 1px solid var(--line); border-radius: 4px; padding: 8px; }
.form .checks label { display: flex; gap: 8px; align-items: center; color: var(--text); }
.code-input { font-size: 26px; letter-spacing: .35em; text-align: center; font-variant-numeric: tabular-nums; }
.key-box { display: flex; align-items: center; gap: 6px; background: #f4f6f9; border: 1px solid var(--line); border-radius: 4px; padding: 6px 6px 6px 10px; }
.key-box code { flex: 1; font-family: Consolas, ui-monospace, monospace; font-size: 12.5px; word-break: break-all; }
.group-card .panel-body { display: grid; gap: 12px; }
.group-card .row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.group-card .lbl { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.group-meta { display: flex; gap: 8px; }
.d-group { display: grid; gap: 5px; font-size: 13px; color: var(--muted); margin: 10px 0 4px; }
.secret { font-family: Consolas, ui-monospace, monospace; font-size: 16px; letter-spacing: .12em; background: #f4f6f9; border: 1px dashed var(--blue-line); border-radius: 4px; padding: 10px; text-align: center; word-break: break-all; }
.audit-details { color: var(--muted); font-size: 12px; font-family: Consolas, ui-monospace, monospace; max-width: 420px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dialog { border: 1px solid var(--line); border-radius: 6px; padding: 0; width: 440px; background: var(--surface); color: var(--text); box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.dialog::backdrop { background: rgba(10,30,50,.45); }
.dialog .panel-head { border-radius: 6px 6px 0 0; }
.dialog-actions { display: flex; flex-direction: row-reverse; gap: 8px; padding: 0 16px 16px; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #2b3440; color: #fff; padding: 9px 16px; border-radius: 4px; font-size: 13px; z-index: 10; max-width: 90vw; }
