:root {
  --bg: #0d1117;
  --panel: #151b26;
  --panel2: #1b2331;
  --hover: #222c3d;
  --border: #283246;
  --text: #e6edf3;
  --muted: #8b98a9;
  --accent: #3b82f6;
  --accent-2: #2563eb;
  --ok: #22c55e;
  --warn: #f59e0b;
  --danger: #ef4444;
  --radius: 10px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 14px/1.45 'Segoe UI', system-ui, -apple-system, sans-serif; }
.hidden { display: none !important; }
a { color: var(--accent); }
small, .muted { color: var(--muted); }
code, .mono { font-family: 'Cascadia Mono', Consolas, monospace; font-size: 12.5px; }
h1, h2, h3 { margin: 0; font-weight: 600; }

/* ---------- controles ---------- */
.btn { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--border); background: var(--panel2); color: var(--text); font: inherit; cursor: pointer; white-space: nowrap; text-decoration: none; }
.btn:hover { background: var(--hover); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-2); }
.btn.danger { background: transparent; border-color: #6b2a2a; color: #fca5a5; }
.btn.danger:hover { background: #3a1717; }
.btn.small { height: 28px; padding: 0 10px; font-size: 13px; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--hover); }
.ic { width: 1.05em; height: 1.05em; flex: none; vertical-align: -0.17em; }
.btn .ic { width: 16px; height: 16px; }
.btn.small .ic, .icon-btn .ic { width: 15px; height: 15px; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; border: 0; border-radius: 6px; background: transparent; color: var(--muted); cursor: pointer; font-size: 15px; }
.icon-btn:hover { background: var(--hover); color: var(--text); }
input, select, textarea { font: inherit; color: var(--text); background: #0f141d; border: 1px solid var(--border); border-radius: 8px; padding: 7px 10px; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
textarea { resize: vertical; }
label { display: flex; flex-direction: column; gap: 5px; color: var(--muted); font-size: 13px; }
label > input, label > select, label > textarea { color: var(--text); font-size: 14px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }
.error { color: #fca5a5; min-height: 18px; font-size: 13px; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: #4b5563; flex: none; }
.dot.on { background: var(--ok); box-shadow: 0 0 0 3px rgba(34, 197, 94, .18); }
.badge { display: inline-block; padding: 1px 8px; border-radius: 99px; background: var(--panel2); border: 1px solid var(--border); color: var(--muted); font-size: 12px; }
.badge.ok { color: #86efac; border-color: #1f5135; background: #10261a; }
.badge.warn { color: #fcd34d; border-color: #5a4313; background: #2a2009; }

/* ---------- login ---------- */
.login { min-height: 100%; display: grid; place-items: center; padding: 20px; background: radial-gradient(circle at 30% 20%, #16233b 0, var(--bg) 60%); }
.login-card { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 14px; padding: 30px; border-radius: 16px; background: var(--panel); border: 1px solid var(--border); box-shadow: 0 20px 60px rgba(0, 0, 0, .45); }
.login-card .logo { color: var(--accent); }
.login-card h1 { font-size: 20px; }
.login-card .btn { height: 40px; justify-content: center; }

/* ---------- painel ---------- */
.app { height: 100%; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 10px 16px; border-bottom: 1px solid var(--border); background: var(--panel); }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 16px; color: var(--text); }
.brand svg { color: var(--accent); }
.search { flex: 1; max-width: 420px; }
.search input { width: 100%; }
.topbar .spacer { flex: 1; }
.conn { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.layout { flex: 1; display: flex; min-height: 0; }
.sidebar { width: 250px; flex: none; border-right: 1px solid var(--border); background: var(--panel); display: flex; flex-direction: column; min-height: 0; }
.side-title { display: flex; align-items: center; justify-content: space-between; padding: 14px 14px 6px; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; }
.side-list { overflow: auto; padding: 4px 8px 12px; }
.side-item { display: flex; align-items: center; gap: 8px; width: 100%; padding: 8px 10px; border: 0; border-radius: 8px; background: transparent; color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.side-item:hover { background: var(--hover); }
.side-item.active { background: #1d2a44; color: #fff; }
.side-item .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-item .count { font-size: 12px; color: var(--muted); }
.side-item .count b { color: var(--ok); font-weight: 600; }
.main { flex: 1; min-width: 0; overflow-y: auto; overflow-x: hidden; padding: 18px 22px; }
.main-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.main-head h2 { font-size: 19px; }
.stats { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.stat { padding: 10px 14px; border-radius: var(--radius); background: var(--panel); border: 1px solid var(--border); min-width: 130px; }
.stat b { display: block; font-size: 20px; }
.stat span { color: var(--muted); font-size: 12px; }
.bulk { display: flex; align-items: center; gap: 10px; padding: 8px 12px; margin-bottom: 10px; border-radius: var(--radius); background: #172540; border: 1px solid #284477; }

table.list { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
table.devices { table-layout: fixed; }
table.list th { text-align: left; font-weight: 500; color: var(--muted); font-size: 12px; padding: 9px 12px; background: var(--panel2); border-bottom: 1px solid var(--border); white-space: nowrap; }
table.list td { padding: 9px 12px; border-bottom: 1px solid #1f2736; vertical-align: middle; }
table.devices td, table.devices th { overflow: hidden; }
.col-check { width: 36px; }
.col-status { width: 96px; }
.col-act { width: 236px; }
.col-company { width: 150px; }
.col-system { width: 190px; }
.col-ip { width: 120px; }
.dev-cell { display: flex; align-items: center; gap: 9px; min-width: 0; }
.dev-cell .dev-text { min-width: 0; }
.dev-name, .dev-sub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
table.list tr:last-child td { border-bottom: 0; }
table.list tbody tr:hover { background: #18202d; }
table.list tr.offline td { color: var(--muted); }
.dev-name { font-weight: 600; color: var(--text); }
.dev-sub { font-size: 12px; color: var(--muted); }
.actions { display: flex; gap: 4px; justify-content: flex-end; }
.actions .btn { height: 28px; padding: 0 9px; font-size: 13px; }
.actions .btn.ico-only { padding: 0; width: 30px; justify-content: center; }
.empty { padding: 50px 20px; text-align: center; color: var(--muted); border: 1px dashed var(--border); border-radius: var(--radius); }

/* ---------- modal ---------- */
.modal-back { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; background: rgba(3, 6, 12, .65); }
.modal { width: 100%; max-width: 480px; max-height: calc(100vh - 32px); display: flex; flex-direction: column; border-radius: 14px; background: var(--panel); border: 1px solid var(--border); box-shadow: 0 30px 80px rgba(0, 0, 0, .55); }
.modal.wide { max-width: 860px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.modal-head h3 { font-size: 16px; }
.modal-body { padding: 18px; overflow: auto; display: flex; flex-direction: column; gap: 14px; }
.modal-body p { margin: 0; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--border); }
.copy-field { display: flex; gap: 6px; }
.copy-field input { flex: 1; font-family: 'Cascadia Mono', Consolas, monospace; font-size: 12px; }
.section-label { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-top: 4px; }
.hint { font-size: 12.5px; color: var(--muted); }
.results { display: flex; flex-direction: column; gap: 8px; }
.result { border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.result-head { display: flex; align-items: center; gap: 8px; padding: 7px 10px; background: var(--panel2); font-size: 13px; }
.result pre { margin: 0; padding: 10px; max-height: 240px; overflow: auto; background: #0a0e15; font: 12px/1.4 'Cascadia Mono', Consolas, monospace; white-space: pre-wrap; word-break: break-word; }
.qr { background: #fff; padding: 10px; border-radius: 8px; align-self: center; line-height: 0; }

#toasts { position: fixed; right: 16px; bottom: 16px; z-index: 100; display: flex; flex-direction: column; gap: 8px; }
.toast { padding: 10px 14px; border-radius: 8px; background: var(--panel2); border: 1px solid var(--border); box-shadow: 0 10px 30px rgba(0, 0, 0, .4); transition: opacity .4s; max-width: 380px; }
.toast.error { border-color: #7f2a2a; background: #2a1414; }
.toast.ok { border-color: #1f5135; background: #10261a; }
.toast.out { opacity: 0; }

/* ---------- janela de sessão ---------- */
body.session { display: flex; flex-direction: column; overflow: hidden; }
.s-top { display: flex; align-items: center; gap: 14px; padding: 6px 12px; background: var(--panel); border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.s-dev { display: flex; align-items: center; gap: 8px; min-width: 0; }
.s-dev b { white-space: nowrap; }
.s-dev small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 260px; }
.tabs { display: flex; gap: 2px; background: #0f141d; padding: 3px; border-radius: 9px; border: 1px solid var(--border); }
.tabs button { border: 0; background: transparent; color: var(--muted); padding: 5px 14px; border-radius: 6px; font: inherit; cursor: pointer; }
.tabs button.active { background: var(--panel2); color: var(--text); }
.tools { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; flex: 1; justify-content: flex-end; }
.tools select { height: 30px; padding: 0 8px; font-size: 13px; }
.tools .btn { height: 30px; padding: 0 10px; font-size: 13px; }
.tools .sep { width: 1px; height: 22px; background: var(--border); }
.menu { position: relative; }
.menu-list { position: absolute; right: 0; top: 34px; z-index: 20; min-width: 190px; padding: 5px; border-radius: 9px; background: var(--panel2); border: 1px solid var(--border); box-shadow: 0 14px 40px rgba(0, 0, 0, .5); }
.menu-list button { display: block; width: 100%; text-align: left; padding: 7px 10px; border: 0; border-radius: 6px; background: transparent; color: var(--text); font: inherit; cursor: pointer; }
.menu-list button:hover { background: var(--hover); }
.menu-list button { display: flex; align-items: center; gap: 9px; }
.main-head .addr { display: inline-flex; align-items: center; gap: 5px; }
.stat-line { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.tab-body { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.screen-wrap { position: relative; flex: 1; min-height: 0; overflow: auto; display: flex; background: #05070b; }
#screen { margin: auto; display: block; outline: none; cursor: default; image-rendering: auto; }
#screen.fit { max-width: 100%; max-height: 100%; }
.screen-wrap.viewonly #screen { cursor: not-allowed; }
.overlay { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(5, 7, 11, .82); color: var(--text); text-align: center; padding: 20px; }
.overlay .box { display: flex; flex-direction: column; gap: 12px; align-items: center; }
.spinner { width: 30px; height: 30px; border: 3px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.term-wrap { flex: 1; min-height: 0; padding: 8px; background: #0b0f17; }
#term { height: 100%; }
.pane-tools { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-bottom: 1px solid var(--border); background: var(--panel); flex-wrap: wrap; }
.pane-scroll { flex: 1; min-height: 0; overflow: auto; padding: 12px; }
.pathbar { flex: 1; min-width: 200px; }
.files td.name { cursor: pointer; display: flex; align-items: center; gap: 7px; }
.files td.name:hover .fname { text-decoration: underline; }
.files .ico { display: inline-flex; color: var(--muted); }
.transfer .tname { display: inline-flex; align-items: center; gap: 6px; }
.up-label { display: inline-flex; align-items: center; gap: 6px; }
.dropzone { outline: 2px dashed var(--accent); outline-offset: -8px; }
.transfers { border-top: 1px solid var(--border); background: var(--panel); max-height: 180px; overflow: auto; }
.transfer { display: flex; align-items: center; gap: 10px; padding: 6px 12px; font-size: 13px; border-bottom: 1px solid #1f2736; }
.transfer .tname { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar { width: 160px; height: 6px; border-radius: 3px; background: #0f141d; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--accent); width: 0; }
.transfer.done .bar i { background: var(--ok); }
.transfer.fail .bar i { background: var(--danger); }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; margin-bottom: 16px; }
.card { padding: 14px; border-radius: var(--radius); background: var(--panel); border: 1px solid var(--border); }
.card h4 { margin: 0 0 8px; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; font-weight: 500; }
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 4px 10px; font-size: 13px; }
.kv span:nth-child(odd) { color: var(--muted); }
.kv span:nth-child(even) { word-break: break-word; }
.meter { height: 6px; border-radius: 3px; background: #0f141d; overflow: hidden; margin: 4px 0 8px; }
.meter i { display: block; height: 100%; background: var(--accent); }
.meter.high i { background: var(--warn); }
.subtabs { display: flex; gap: 8px; margin: 6px 0 12px; }

@media (max-width: 1150px) {
  .hide-md { display: none; }
}
@media (max-width: 800px) {
  .sidebar { display: none; }
  .hide-sm { display: none; }
  .main { padding: 12px; }
}
