:root {
  --bg: #0c0f15;
  --panel: #151a23;
  --panel-2: #1c222d;
  --line: #29313f;
  --fg: #e8edf5;
  --muted: #8896aa;
  --accent: #4c8dff;
  --ok: #3ecf8e;
  --warn: #ffb020;
  --danger: #ff5c6c;
}

* { box-sizing: border-box; }

/* As seções usam display:flex/grid, que venceria o `display:none` do
   atributo `hidden` da folha de estilo do navegador. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font: 14px/1.5 "Segoe UI", system-ui, -apple-system, sans-serif;
  overflow: hidden;
}

.muted { color: var(--muted); }
.grow { flex: 1; }

/* ---------------------------------------------------------------- login */

.centered {
  display: grid;
  place-items: center;
  height: 100%;
  padding: 24px;
  background:
    radial-gradient(900px 500px at 20% -10%, #1a2540 0%, transparent 60%),
    radial-gradient(700px 500px at 110% 110%, #13303a 0%, transparent 55%),
    var(--bg);
}

.card {
  width: min(400px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 28px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .45);
}

.brand { display: flex; align-items: center; gap: 14px; margin-bottom: 24px; }

.brand-mark {
  display: grid;
  place-items: center;
  width: 46px; height: 46px;
  border-radius: 12px;
  background: linear-gradient(140deg, var(--accent), #7b5cff);
  font-size: 17px;
  letter-spacing: .5px;
  font-weight: 700;
}

.brand h1 { margin: 0; font-size: 19px; letter-spacing: -.2px; }
.brand p  { margin: 2px 0 0; font-size: 12.5px; color: var(--muted); }

/* ------------------------------------------------------------ painel */

.panel {
  height: 100%;
  overflow-y: auto;
  background:
    radial-gradient(900px 500px at 20% -10%, #1a2540 0%, transparent 60%),
    var(--bg);
}

.panel-bar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 20px;
  background: rgba(21, 26, 35, .92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}

.brand--small { gap: 10px; margin: 0; }
.brand--small .brand-mark { width: 30px; height: 30px; border-radius: 8px; font-size: 12px; }
.brand--small h1 { font-size: 15px; }

.panel-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(330px, 1fr));
  gap: 18px;
  padding: 22px;
  max-width: 1180px;
  margin: 0 auto;
  align-items: start;
}

.panel-grid .card { width: auto; }
.card--wide { grid-column: 1 / -1; }

.card h2 {
  margin: 0 0 4px;
  font-size: 15px;
  letter-spacing: -.2px;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}
.card-head h2 { margin: 0; }

.inline-form {
  display: grid;
  grid-template-columns: 1fr 130px auto;
  gap: 8px;
  margin: 4px 0 14px;
}
.inline-form input {
  padding: 9px 11px;
  font-size: 13px;
  letter-spacing: normal;
}
.compact { width: auto; margin: 0; padding: 9px 14px; }

.list { list-style: none; margin: 0; padding: 0; }

.list li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background .12s, border-color .12s;
}
.list li:hover { background: var(--panel-2); border-color: var(--line); }

.list .device-name { font-weight: 600; font-size: 13.5px; }
.list .device-meta {
  display: block;
  font: 11.5px ui-monospace, Consolas, monospace;
  color: var(--muted);
  margin-top: 2px;
}
.list .grow { min-width: 0; }

.icon-btn {
  padding: 4px 8px;
  background: transparent;
  border-color: transparent;
  color: var(--muted);
  font-size: 13px;
}
.icon-btn:hover { background: rgba(255, 92, 108, .15); color: #ff8e99; }

.empty {
  margin: 10px 2px 0;
  font-size: 12.5px;
  color: var(--muted);
}

.table-wrap { overflow-x: auto; }

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
  white-space: nowrap;
}
.table th {
  text-align: left;
  font-size: 10.5px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
  padding: 6px 12px 6px 0;
  border-bottom: 1px solid var(--line);
}
.table td {
  padding: 9px 12px 9px 0;
  border-bottom: 1px solid rgba(41, 49, 63, .5);
}
.table tr:last-child td { border-bottom: 0; }
.table .mono { font-family: ui-monospace, Consolas, monospace; color: var(--muted); }

.tag {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 11px;
  border: 1px solid;
}
.tag--ok { color: var(--ok); border-color: rgba(62, 207, 142, .4); background: rgba(62, 207, 142, .12); }
.tag--no { color: var(--muted); border-color: var(--line); background: var(--panel-2); }

.linkish {
  padding: 0;
  background: none;
  border: 0;
  color: var(--accent);
  font-size: inherit;
  text-decoration: underline;
}
.linkish:hover { color: #7aabff; }

.info {
  margin: 16px 0 0;
  padding: 10px 12px;
  border-radius: 9px;
  background: rgba(62, 207, 142, .1);
  border: 1px solid rgba(62, 207, 142, .32);
  color: #7fe0b4;
  font-size: 13px;
}

form label {
  display: block;
  font-size: 11px;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 16px 0 6px;
}

form input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #0d1017;
  color: var(--fg);
  font: 500 16px/1 ui-monospace, Consolas, monospace;
  letter-spacing: .08em;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}

form input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(76, 141, 255, .18);
}

button {
  font: inherit;
  cursor: pointer;
  border-radius: 9px;
  border: 1px solid transparent;
  transition: background .15s, border-color .15s, opacity .15s;
}

button:disabled { opacity: .55; cursor: default; }

.primary {
  width: 100%;
  margin-top: 22px;
  padding: 12px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}
.primary:hover:not(:disabled) { background: #5c99ff; }

.ghost {
  padding: 6px 10px;
  background: var(--panel-2);
  border-color: var(--line);
  color: var(--fg);
  font-size: 12.5px;
}
.ghost:hover { background: #26303f; }
.ghost.active { background: rgba(76, 141, 255, .22); border-color: var(--accent); color: #cfe0ff; }

.danger {
  padding: 6px 12px;
  background: rgba(255, 92, 108, .14);
  border-color: rgba(255, 92, 108, .45);
  color: #ff8e99;
  font-size: 12.5px;
}
.danger:hover { background: rgba(255, 92, 108, .24); }

.error {
  margin: 16px 0 0;
  padding: 10px 12px;
  border-radius: 9px;
  background: rgba(255, 92, 108, .12);
  border: 1px solid rgba(255, 92, 108, .35);
  color: #ff97a2;
  font-size: 13px;
}

.hint { margin: 22px 0 0; font-size: 12px; color: var(--muted); }

/* -------------------------------------------------------------- sessão */

.session { display: flex; flex-direction: column; height: 100%; }

.toolbar {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
  padding: 8px 12px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.tb-group { display: flex; align-items: center; gap: 8px; }
.tb-group:nth-child(2) { flex: 1; justify-content: center; }

.dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--muted);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, .05);
}
.dot.on   { background: var(--ok); }
.dot.warn { background: var(--warn); }
.dot.off  { background: var(--danger); }

.badge {
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(62, 207, 142, .14);
  border: 1px solid rgba(62, 207, 142, .4);
  color: var(--ok);
  font-size: 11px;
  white-space: nowrap;
}
.badge.warn {
  background: rgba(255, 176, 32, .14);
  border-color: rgba(255, 176, 32, .45);
  color: var(--warn);
}

.ctl {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: var(--muted);
  white-space: nowrap;
}

.ctl select, .ctl input[type=range] {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--fg);
  padding: 4px 6px;
  font-size: 12px;
  outline: none;
}
.ctl input[type=range] { width: 92px; padding: 0; accent-color: var(--accent); }
.ctl output { color: var(--fg); font: 11px ui-monospace, Consolas, monospace; min-width: 20px; }

.stage {
  position: relative;
  flex: 1;
  display: grid;
  place-items: center;
  overflow: auto;
  background:
    repeating-conic-gradient(#0a0d12 0% 25%, #0d1117 0% 50%) 50% / 22px 22px;
}

.screen-wrap { position: relative; line-height: 0; }

canvas#screen {
  display: block;
  max-width: 100%;
  max-height: calc(100vh - 92px);
  background: #000;
  cursor: crosshair;
  box-shadow: 0 0 0 1px var(--line), 0 20px 50px rgba(0, 0, 0, .5);
  touch-action: none;
}

.stage.actual canvas#screen { max-width: none; max-height: none; }

.remote-cursor {
  position: absolute;
  pointer-events: none;
  transform: translate(-2px, -1px);
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, .6));
  transition: left .05s linear, top .05s linear;
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  gap: 14px;
  align-content: center;
  background: rgba(8, 11, 16, .82);
  backdrop-filter: blur(3px);
  font-size: 13.5px;
  color: var(--muted);
}
.overlay[hidden] { display: none; }

.spinner {
  width: 30px; height: 30px;
  border: 3px solid rgba(255, 255, 255, .12);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.statusbar {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 5px 12px;
  background: var(--panel);
  border-top: 1px solid var(--line);
  font: 11.5px ui-monospace, Consolas, monospace;
  color: var(--fg);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 44px;
  transform: translateX(-50%);
  padding: 10px 16px;
  border-radius: 10px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  box-shadow: 0 12px 30px rgba(0, 0, 0, .5);
  font-size: 13px;
  z-index: 20;
}
.toast[hidden] { display: none; }

@media (max-width: 900px) {
  .tb-group:nth-child(2) { order: 3; width: 100%; justify-content: flex-start; overflow-x: auto; }
}
