:root {
  --bg: #090a12;
  --bg-2: #0c0e1a;
  --panel: #11131f;
  --panel-2: #181b2b;
  --border: #272d45;
  --border-2: #323a5c;
  --text: #eaf0ff;
  --muted: #97a2c4;
  --pink: #ff2e9a;
  --magenta: #c438ff;
  --cyan: #19c6ff;
  --blue: #3a74ff;
  --danger: #ff4d6d;
  --on: #1fe0a4;
  --off: #5a6484;
  --grad: linear-gradient(135deg, #ff2e9a 0%, #c438ff 45%, #19c6ff 100%);
  --radius: 14px;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 85% -10%, rgba(196, 56, 255, 0.10), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(25, 198, 255, 0.10), transparent 55%),
    var(--bg);
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 0.82rem; }
.spacer { flex: 1; }

/* ---- brand (logo wordmark) ---- */
.brand-word { font-weight: 800; letter-spacing: -0.02em; line-height: 1; }
.brand-word .b1 {
  background: linear-gradient(135deg, #ff4fb0, #c438ff);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.brand-word .b2 {
  background: linear-gradient(135deg, #19c6ff, #3a74ff);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.topbar .brand-word { font-size: 1.25rem; }
.login .brand-word { font-size: 2.6rem; filter: drop-shadow(0 2px 18px rgba(196,56,255,0.35)); }

/* ---- buttons ---- */
button {
  cursor: pointer;
  border: none;
  background: var(--grad);
  color: #fff;
  padding: 0.55rem 1rem;
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: 600;
  transition: transform 0.06s ease, box-shadow 0.15s ease, opacity 0.15s ease;
  box-shadow: 0 6px 18px rgba(196, 56, 255, 0.22);
}
button:hover { box-shadow: 0 8px 26px rgba(196, 56, 255, 0.34); }
button:active { transform: translateY(1px); }
button.ghost {
  background: rgba(255, 255, 255, 0.03); border: 1px solid var(--border-2);
  color: var(--text); box-shadow: none; font-weight: 500;
}
button.ghost:hover { background: rgba(255, 255, 255, 0.07); border-color: var(--cyan); }
/* estado "ligado/ticado" (ex.: rotação travada) */
button.ghost.active {
  background: rgba(31, 224, 164, 0.16); border-color: var(--on); color: var(--on); font-weight: 600;
}
button.ghost.active:hover { background: rgba(31, 224, 164, 0.24); border-color: var(--on); }
button.danger {
  background: rgba(255, 77, 109, 0.08); border: 1px solid rgba(255, 77, 109, 0.5);
  color: #ff8098; box-shadow: none;
}
button.danger:hover { background: rgba(255, 77, 109, 0.18); }
button.small { padding: 0.32rem 0.65rem; font-size: 0.8rem; }

/* ---- inputs ---- */
input, select {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.55rem 0.75rem;
  border-radius: 10px;
  font-size: 0.9rem;
}
input::placeholder { color: #5f6b8c; }
input:focus, select:focus { outline: none; border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(25, 198, 255, 0.15); }
input[type="file"].file { padding: 0.38rem 0.5rem; }
input[type="file"].file::file-selector-button {
  background: var(--panel); color: var(--text); border: 1px solid var(--border-2);
  border-radius: 8px; padding: 0.32rem 0.7rem; margin-right: 0.6rem; cursor: pointer;
}

/* ---- cards ---- */
.card {
  background: linear-gradient(180deg, rgba(255,255,255,0.03), rgba(255,255,255,0) 40%), var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.3rem;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 0.6rem; }
.card-head h3 { margin: 0; font-size: 1rem; }
.error { color: var(--danger); min-height: 1rem; font-size: 0.85rem; margin: 0; }
.install-row { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.install-row input, .install-row select { flex: 1; min-width: 140px; }

/* ---- login ---- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.login .card { width: 340px; display: flex; flex-direction: column; gap: 0.8rem; text-align: center; }
.login .brand-word { align-self: center; }
.login p { margin: 0 0 0.4rem; }
.login label { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.82rem; color: var(--muted); text-align: left; }
.login button[type="submit"] { margin-top: 0.3rem; padding: 0.7rem; font-size: 0.95rem; }

/* ---- topbar ---- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 0.7rem;
  padding: 0.7rem 1.1rem;
  border-bottom: 1px solid var(--border);
  background: rgba(10, 12, 22, 0.85);
  backdrop-filter: blur(10px);
}
.pill { font-size: 0.72rem; padding: 0.18rem 0.6rem; border-radius: 999px; font-weight: 600; }
.pill.on { background: rgba(31, 224, 164, 0.14); color: var(--on); box-shadow: 0 0 0 1px rgba(31,224,164,0.25) inset; }
.pill.off { background: rgba(90, 100, 132, 0.16); color: var(--off); }

/* ---- barra "acessar por código" ---- */
.codebar {
  display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap;
  padding: 0.7rem 1.1rem; border-bottom: 1px solid var(--border); background: var(--bg-2);
}
.codebar input { width: 190px; letter-spacing: 0.12em; }

/* ---- layout ---- */
.layout { display: grid; grid-template-columns: 260px 1fr; min-height: calc(100vh - 110px); }
.sidebar { border-right: 1px solid var(--border); padding: 1.1rem; }
.sidebar h2, .content h2 { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin: 0 0 0.7rem; }
.sidebar ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.35rem; }
.device {
  display: flex; align-items: center; gap: 0.55rem; padding: 0.6rem 0.7rem;
  border-radius: 11px; cursor: pointer; border: 1px solid transparent; background: var(--panel-2);
  transition: border-color 0.12s ease, background 0.12s ease;
}
.device:hover { border-color: var(--border-2); }
.device.active { border-color: var(--cyan); box-shadow: 0 0 0 1px rgba(25,198,255,0.2) inset; }
.device .dname { font-weight: 600; }
.device small { color: var(--muted); margin-left: auto; font-size: 0.74rem; }
.dot { width: 9px; height: 9px; border-radius: 999px; flex: none; }
.dot.on { background: var(--on); box-shadow: 0 0 8px var(--on); }
.dot.off { background: var(--off); }
/* ponto vermelho "ao vivo": acesso ativo neste carro (sessão liberada) */
.live-dot {
  display: inline-block; width: 9px; height: 9px; border-radius: 999px; vertical-align: middle;
  background: #ff2e4d; box-shadow: 0 0 7px #ff2e4d; margin-left: 6px; animation: livepulse 1.2s infinite;
}
.live-dot.hidden { display: none; }
@keyframes livepulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }

.content { padding: 1.4rem; display: flex; flex-direction: column; gap: 1.1rem; }
.empty { color: var(--muted); padding: 3rem 1rem; text-align: center; }
.device-head { display: flex; align-items: baseline; gap: 0.8rem; flex-wrap: wrap; }
.device-head h2 { margin: 0; }
.content .card { display: flex; flex-direction: column; gap: 0.8rem; }

/* ---- listas (apps / usuários / apks / logs) ---- */
.apps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.4rem; max-height: 360px; overflow: auto; }
.apps li {
  display: flex; align-items: center; justify-content: space-between; gap: 0.6rem;
  padding: 0.55rem 0.75rem; border: 1px solid var(--border); border-radius: 11px; background: var(--panel-2);
}
.apps li:hover { border-color: var(--border-2); }
.apps li.clickable { cursor: pointer; }
.apps li.pkg-head {
  background: transparent; border: none; border-bottom: 1px solid var(--border-2);
  border-radius: 0; padding: 0.7rem 0.2rem 0.35rem; margin-top: 0.4rem;
}
.pkg { font-family: ui-monospace, Menlo, monospace; font-size: 0.85rem; }
/* seleção de APKs por caixinha */
.apk-left { display: flex; align-items: center; gap: 0.55rem; min-width: 0; }
.apk-check { width: 18px; height: 18px; flex: none; accent-color: var(--pink); cursor: pointer; }
#apk-sel-bar { align-items: center; }
#apk-sel-bar.hidden { display: none; }
/* barra de progresso de instalação no carro */
.prog { width: 100%; height: 9px; border-radius: 999px; background: #171c2e; overflow: hidden; margin-top: 6px; }
.prog.hidden { display: none; }
.prog-fill { height: 100%; width: 0%; border-radius: 999px; background: var(--grad); transition: width 0.2s ease; }
.prog.indet { position: relative; }
.prog.indet .prog-fill { width: 38%; animation: progslide 1.1s ease-in-out infinite; }
@keyframes progslide { 0% { margin-left: -38%; } 100% { margin-left: 100%; } }
.row-actions { display: flex; gap: 0.45rem; flex: none; }
.row-actions.wrap { flex-wrap: wrap; flex: 1 1 auto; }

/* barra de status do carro (bateria / bluetooth / rede) */
.statusbar { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; padding: 0.2rem; }
.statusbar .stat {
  font-size: 0.85rem; color: var(--text); background: var(--panel-2);
  border: 1px solid var(--border); border-radius: 999px; padding: 0.25rem 0.75rem;
}

.console {
  background: #06070d; border: 1px solid var(--border); border-radius: 11px;
  padding: 0.8rem; min-height: 120px; max-height: 340px; overflow: auto;
  font-family: ui-monospace, Menlo, monospace; font-size: 0.8rem; white-space: pre-wrap; margin: 0; color: #cfe3ff;
}
.screen {
  width: 100%; max-height: 60vh; background: #000;
  border: 1px solid var(--border); border-radius: 11px;
  object-fit: contain; touch-action: none; cursor: crosshair;
}
/* tela cheia do acesso remoto — via classe (funciona em todo dispositivo, iPhone
   incluso). Os controles continuam visíveis abaixo da tela. */
#screen-card.fs-active {
  position: fixed; inset: 0; z-index: 3000; margin: 0; border-radius: 0;
  background: var(--bg); padding: 10px 14px;
  display: flex; flex-direction: column; gap: 8px; overflow: auto;
}
#screen-card.fs-active .screen { width: 100%; max-height: 80vh; border-radius: 8px; }

/* ---- modal ---- */
.modal {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(5, 6, 12, 0.7); backdrop-filter: blur(4px);
  display: grid; place-items: center; padding: 1rem;
}
.modal-card { width: min(620px, 100%); max-height: 86vh; overflow: auto; display: flex; flex-direction: column; gap: 0.8rem; }

@media (max-width: 760px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { border-right: none; border-bottom: 1px solid var(--border); }
  .content { padding: 1rem; }
}
