:root {
  --bg: #0d1117;
  --panel: #161b22;
  --panel-2: #1c2128;
  --border: #30363d;
  --text: #e6edf3;
  --muted: #8b949e;
  --accent: #2f81f7;
  --ok: #3fb950;
  --warn: #d29922;
  --error: #f85149;
  --radius: 8px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 18px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}
.brand { font-weight: 600; color: var(--text); }
.brand span { color: var(--muted); font-weight: 400; }
.spacer { flex: 1; }
.user { color: var(--muted); }
.inline { display: inline; }

button, .link {
  font: inherit;
  cursor: pointer;
  border-radius: 6px;
  border: 1px solid var(--border);
  padding: 6px 12px;
  background: var(--panel-2);
  color: var(--text);
}
button:disabled { opacity: .45; cursor: not-allowed; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.danger { background: transparent; border-color: var(--error); color: var(--error); }
button.active { background: var(--ok); border-color: var(--ok); color: #05210d; font-weight: 600; }
.link { background: none; border: none; color: var(--accent); padding: 6px; }

input, select {
  font: inherit;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
}

.container { max-width: 1200px; margin: 0 auto; padding: 24px 18px; }

.page-head { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head h1 { margin: 0; font-size: 20px; }
.controls { display: flex; gap: 8px; margin-left: auto; flex-wrap: wrap; }

.muted { color: var(--muted); }
.error { color: var(--error); }

/* ---------------------------------------------------------------- login */

.login-card {
  max-width: 340px;
  margin: 12vh auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
}
.login-card h1 { margin: 0 0 18px; font-size: 18px; }
.login-card label { display: block; margin: 12px 0 4px; color: var(--muted); font-size: 13px; }
.login-card input { width: 100%; }
.login-card button { width: 100%; margin-top: 18px; }

/* --------------------------------------------------------------- agentes */

.agent-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}

.agent-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.agent-card.offline { opacity: .7; }
.agent-card header { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.agent-card h3 { margin: 0; font-size: 15px; flex: 1; }

.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); flex: none; }
.dot.online { background: var(--ok); box-shadow: 0 0 6px var(--ok); }
.dot.offline { background: var(--muted); }

.badge { font-size: 11px; padding: 2px 7px; border-radius: 10px; }
.badge.warn { background: rgba(210,153,34,.18); color: var(--warn); }

.meta { display: grid; grid-template-columns: auto 1fr; gap: 3px 10px; margin: 0 0 12px; font-size: 13px; }
.meta dt { color: var(--muted); }
.meta dd { margin: 0; }

.chips { display: flex; gap: 5px; flex-wrap: wrap; margin-bottom: 14px; }
.chip { font-size: 11px; padding: 2px 8px; border-radius: 10px; border: 1px solid var(--border); }
.chip.on { background: rgba(63,185,80,.14); color: var(--ok); border-color: rgba(63,185,80,.35); }
.chip.off { color: var(--muted); }

.agent-card footer button { width: 100%; }

.token-box {
  background: var(--panel);
  border: 1px solid var(--warn);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 20px;
}
.token-box code {
  display: block;
  background: var(--bg);
  padding: 10px;
  border-radius: 6px;
  font-size: 14px;
  word-break: break-all;
  margin: 8px 0;
}
.token-box pre {
  background: var(--bg);
  padding: 10px;
  border-radius: 6px;
  overflow-x: auto;
  font-size: 12px;
  margin: 4px 0 12px;
}

/* --------------------------------------------------------------- sessao */

.session-layout { display: flex; flex-direction: column; height: calc(100vh - 45px); }

.session-bar {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 6px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.agent-info { display: flex; align-items: center; gap: 8px; }

/* Abas: tela e terminal sao modos independentes, nao paineis simultaneos. */
.tabs { display: flex; gap: 2px; }
.tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  padding: 10px 18px;
  color: var(--muted);
  font-weight: 500;
}
.tab:hover:not(:disabled) { color: var(--text); background: var(--panel-2); }
.tab.active {
  color: var(--text);
  border-bottom-color: var(--accent);
  background: none;
}
.tab:disabled { opacity: .35; }

.stats { display: flex; gap: 14px; color: var(--muted); font-size: 12px; }
.stats b { color: var(--text); }

.toolbar { display: flex; gap: 6px; margin-left: auto; flex-wrap: wrap; align-items: center; }
.toolbar button, .toolbar select { padding: 5px 10px; font-size: 13px; }
.tab-tools { display: flex; gap: 6px; align-items: center; }
.tab-tools[hidden] { display: none; }

.banner { padding: 8px 16px; font-size: 13px; }
.banner.info { background: rgba(47,129,247,.15); color: var(--accent); }
.banner.warn { background: rgba(210,153,34,.15); color: var(--warn); }
.banner.error { background: rgba(248,81,73,.15); color: var(--error); }

.session-body { flex: 1; display: flex; min-height: 0; }

.pane { flex: 1; display: flex; min-height: 0; }
.pane[hidden] { display: none; }

.empty-pane {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  text-align: center;
}
.empty-pane code {
  background: var(--panel-2);
  padding: 2px 6px;
  border-radius: 4px;
}

.screen-pane {
  flex: 1;
  position: relative;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
  min-height: 0;
}

#screen { display: block; max-width: 100%; max-height: 100%; }
#screen.fit { width: auto; height: auto; object-fit: contain; }

.screen-placeholder { position: absolute; text-align: center; color: var(--muted); padding: 20px; }
.screen-placeholder p { margin: 6px 0; }

.control-badge {
  position: absolute;
  top: 12px;
  right: 12px;
  background: var(--ok);
  color: #05210d;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 12px;
}

/* O terminal ocupa a aba inteira: quem escolheu terminal quer terminal. */
#pane-terminal { background: #0d1117; padding: 8px; }
#terminal { flex: 1; min-height: 0; width: 100%; }

@media (max-width: 900px) {
  .stats { display: none; }
  .session-bar { gap: 8px; }
  .toolbar { width: 100%; margin-left: 0; }
}

@media (max-width: 600px) {
  .session-layout { height: auto; }
  .screen-pane { min-height: 50vh; }
  #pane-terminal { min-height: 60vh; }
}

/* ------------------------------------------------- lista de dispositivos */

.section-title { font-size: 15px; margin: 4px 0 2px; }
.section-hint { margin: 0 0 14px; font-size: 13px; }

#pending-section {
  border-left: 3px solid var(--warn);
  padding-left: 14px;
  margin-bottom: 28px;
}

.agent-card.pending { border-color: rgba(210,153,34,.45); }

/* O codigo precisa ser lido em voz alta e comparado com a tela do
   dispositivo, entao e o elemento mais visivel do cartao. */
.pairing-code {
  font: 600 26px/1.2 ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: .18em;
  text-align: center;
  color: var(--warn);
  background: rgba(210,153,34,.10);
  border-radius: 6px;
  padding: 10px 0;
  margin: 10px 0 12px;
}

.agent-card .small { font-size: 12px; margin: 0 0 10px; }

.badge-mode {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 10px;
  border: 1px solid transparent;
}
.badge-mode.tela { background: rgba(47,129,247,.16); color: var(--accent);
                   border-color: rgba(47,129,247,.35); }
.badge-mode.terminal { background: rgba(63,185,80,.14); color: var(--ok);
                       border-color: rgba(63,185,80,.32); }
.badge-mode.none { color: var(--muted); border-color: var(--border); }

footer.two { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
footer.two button { width: 100%; }

.empty-state { text-align: center; padding: 48px 20px; line-height: 2; }
.empty-state code {
  display: inline-block;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 14px;
  font-size: 13px;
}
