:root {
  --bg: #0a1622;
  --bg2: #0f2030;
  --card: #122636;
  --line: #1e3a50;
  --txt: #e6eef5;
  --muted: #8aa3b8;
  --accent: #1fd17a;
  --accent2: #16b566;
  --danger: #ff5f6d;
  --warn: #f5b945;
  --radius: 12px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: radial-gradient(1200px 600px at 80% -10%, #14304a 0%, var(--bg) 55%);
  color: var(--txt);
  min-height: 100vh;
}
.hidden { display: none !important; }

/* Topbar */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 22px; border-bottom: 1px solid var(--line);
  background: rgba(10,22,34,.7); backdrop-filter: blur(6px);
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand .logo {
  font-size: 26px; color: var(--accent);
  background: rgba(31,209,122,.12); width: 44px; height: 44px;
  display: grid; place-items: center; border-radius: 12px;
}
.brand h1 { font-size: 18px; margin: 0; letter-spacing: .2px; }
.brand small { color: var(--muted); }
.conn { display: flex; align-items: center; gap: 8px; }
.conn input {
  background: var(--bg2); border: 1px solid var(--line); color: var(--txt);
  padding: 9px 12px; border-radius: 9px; width: 240px; outline: none;
}
.conn input:focus { border-color: var(--accent); }
.who { color: var(--accent); font-weight: 600; padding: 0 6px; }

/* Buttons */
.btn {
  background: linear-gradient(180deg, var(--accent), var(--accent2));
  color: #03261a; border: 0; font-weight: 700; cursor: pointer;
  padding: 9px 14px; border-radius: 9px; transition: filter .15s, transform .05s;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(1px); }
.btn.ghost { background: transparent; color: var(--txt); border: 1px solid var(--line); }
.btn.ghost:hover { border-color: var(--accent); color: var(--accent); }
.btn.danger { background: transparent; border: 1px solid var(--danger); color: var(--danger); }
.btn.danger:hover { background: rgba(255,95,109,.12); }
.btn.sm { padding: 6px 10px; font-size: 12px; border-radius: 8px; }

/* Layout */
main { padding: 22px; max-width: 1280px; margin: 0 auto; }
.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.toolbar input {
  background: var(--bg2); border: 1px solid var(--line); color: var(--txt);
  padding: 9px 12px; border-radius: 9px; width: 280px; outline: none;
}
.toolbar input:focus { border-color: var(--accent); }
.spacer { flex: 1; }
.stat { color: var(--muted); font-size: 13px; }

/* Stat cards */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
@media (max-width: 760px) { .stats { grid-template-columns: repeat(2, 1fr); } }
.stat-card {
  background: linear-gradient(180deg, var(--card), var(--bg2));
  border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px;
}
.stat-num { font-size: 30px; font-weight: 800; letter-spacing: .5px; }
.stat-num.accent { color: var(--accent); }
.stat-lbl { color: var(--muted); font-size: 12px; margin-top: 2px; text-transform: uppercase; letter-spacing: .4px; }

.grid { display: grid; grid-template-columns: 1fr 360px; gap: 16px; }
@media (max-width: 980px) { .grid { grid-template-columns: 1fr; } }

.card {
  background: linear-gradient(180deg, var(--card), var(--bg2));
  border: 1px solid var(--line); border-radius: var(--radius); padding: 16px;
}
.card h2 { margin: 0 0 12px; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.live { color: var(--accent); font-size: 11px; font-weight: 600; }

/* Table */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .4px; }
tbody tr:hover { background: rgba(31,209,122,.05); }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.dot.on { background: var(--accent); box-shadow: 0 0 8px var(--accent); }
.dot.off { background: #44586a; }
.row-actions { display: flex; gap: 6px; }
.empty, .muted { color: var(--muted); font-size: 13px; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; }

/* Tasks */
.tasks { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; max-height: 70vh; overflow-y: auto; }
.tasks li { border: 1px solid var(--line); border-radius: 10px; padding: 10px; background: var(--bg2); }
.tasks .t-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.tasks .t-tipo { font-weight: 600; }
.tasks .t-meta { color: var(--muted); font-size: 12px; margin-top: 4px; }
.badge { padding: 3px 9px; border-radius: 999px; font-size: 11px; font-weight: 700; }
.badge.pendente { background: rgba(245,185,69,.16); color: var(--warn); }
.badge.enviada { background: rgba(80,160,255,.16); color: #6fb3ff; }
.badge.concluida { background: rgba(31,209,122,.16); color: var(--accent); }
.badge.falha { background: rgba(255,95,109,.16); color: var(--danger); }

/* Drawer */
.drawer {
  position: fixed; top: 0; right: 0; height: 100%; width: 420px; max-width: 92vw;
  background: var(--bg2); border-left: 1px solid var(--line); z-index: 30;
  box-shadow: -20px 0 50px rgba(0,0,0,.4); display: flex; flex-direction: column;
  animation: slidein .2s ease;
}
@keyframes slidein { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }
.drawer-head { display: flex; justify-content: space-between; align-items: center; padding: 16px; border-bottom: 1px solid var(--line); }
.drawer-body { padding: 16px; overflow-y: auto; }
.ev { border-left: 2px solid var(--line); padding: 6px 0 12px 14px; position: relative; }
.ev::before { content: ""; position: absolute; left: -5px; top: 9px; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.ev .ev-tipo { font-weight: 600; font-size: 13px; }
.ev .ev-time { color: var(--muted); font-size: 11px; }
.ev pre { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px; font-size: 11px; overflow-x: auto; margin: 6px 0 0; }

/* Drawer detalhes */
.kvs { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 16px; }
.kv { background: var(--bg); border: 1px solid var(--line); border-radius: 9px; padding: 8px 10px; }
.kv span { display: block; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .3px; }
.kv b { font-size: 14px; }
.dump-head { display: flex; flex-direction: column; gap: 2px; margin: 6px 0 8px; }
.dump-filter { width: 100%; background: var(--bg); border: 1px solid var(--line); color: var(--txt); padding: 8px 10px; border-radius: 8px; outline: none; margin-bottom: 8px; }
.dump-filter:focus { border-color: var(--accent); }
table.dump { width: 100%; border-collapse: collapse; font-size: 11px; }
table.dump td { border-bottom: 1px solid var(--line); padding: 5px 6px; vertical-align: top; word-break: break-all; }
table.dump td.dk { color: var(--muted); width: 55%; }

/* Modal */
.modal { position: fixed; inset: 0; background: rgba(3,10,16,.6); display: grid; place-items: center; z-index: 40; }
.modal-box { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 22px; width: 420px; max-width: 92vw; }
.modal-box h3 { margin: 0 0 6px; }
.modal-box label { display: block; color: var(--muted); font-size: 13px; margin: 14px 0 6px; }
.modal-box input { width: 100%; background: var(--bg2); border: 1px solid var(--line); color: var(--txt); padding: 10px; border-radius: 9px; outline: none; }
.modal-box input:focus { border-color: var(--accent); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

/* Tela completa do equipamento */
.dev-modal { position: fixed; inset: 0; background: rgba(3,10,16,.72); z-index: 45; display: grid; place-items: center; padding: 24px; }
.dev-box { background: var(--bg); border: 1px solid var(--line); border-radius: 16px; width: 1100px; max-width: 96vw; height: 88vh; display: flex; flex-direction: column; box-shadow: 0 30px 80px rgba(0,0,0,.6); overflow: hidden; }
.dev-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line); background: var(--bg2); }
.dev-head h2 { margin: 0; font-size: 18px; display: flex; align-items: center; gap: 8px; }
.dev-head small { color: var(--muted); }
.dev-head-actions { display: flex; gap: 8px; }
.dev-body { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; padding: 18px 20px; overflow: hidden; flex: 1; }
@media (max-width: 900px) { .dev-body { grid-template-columns: 1fr; overflow-y: auto; } }
.dev-col { display: flex; flex-direction: column; min-height: 0; overflow-y: auto; }
.dev-col h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); margin: 4px 0 10px; }
.cfg { display: flex; flex-direction: column; gap: 4px; }
.cfg label { color: var(--muted); font-size: 12px; margin-top: 8px; }
.cfg input { background: var(--bg2); border: 1px solid var(--line); color: var(--txt); padding: 9px 11px; border-radius: 9px; outline: none; width: 100%; }
.cfg input:focus { border-color: var(--accent); }
.cfg-row { display: flex; gap: 8px; }
.cfg-row input { flex: 1; }
.adv { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 10px; }
.adv summary { cursor: pointer; color: var(--accent); font-size: 13px; }
.dump-wrap { overflow-y: auto; border: 1px solid var(--line); border-radius: 9px; flex: 1; min-height: 0; }

/* Toast */
.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: var(--card); border: 1px solid var(--accent); color: var(--txt);
  padding: 14px 18px; border-radius: 12px; z-index: 50; max-width: 90vw;
  box-shadow: 0 10px 40px rgba(0,0,0,.5); animation: pop .2s ease;
}
.toast.err { border-color: var(--danger); }
@keyframes pop { from { transform: translate(-50%, 10px); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }
.toast .pwd { font-family: ui-monospace, monospace; color: var(--accent); font-weight: 700; font-size: 16px; }
