:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --text: #17202a;
  --muted: #657080;
  --line: #dfe5ee;
  --primary: #146c5c;
  --primary-dark: #0f5145;
  --danger: #b42318;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
  font-size: 14px;
}
a { color: inherit; }
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 230px;
  background: #111827;
  color: #fff;
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}
.brand { font-size: 18px; font-weight: 700; }
.sidebar nav { display: grid; gap: 8px; }
.sidebar a, .logout-form button {
  color: #d1d5db;
  text-decoration: none;
  padding: 10px 12px;
  border-radius: 6px;
  border: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
}
.sidebar a.active, .sidebar a:hover, .logout-form button:hover { background: #1f2937; color: #fff; }
.logout-form { margin-top: auto; }
.content { margin-left: 230px; padding: 28px; }
.login-content { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-box, .panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 22px;
}
.login-box { width: min(420px, 100%); }
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}
h1, h2, p { margin-top: 0; }
p { color: var(--muted); }
.metrics { display: grid; grid-template-columns: repeat(4, minmax(120px, 1fr)); gap: 14px; margin-bottom: 18px; }
.metrics article { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 18px; }
.metrics strong { display: block; font-size: 28px; }
.metrics span { color: var(--muted); }
.compact { margin-bottom: 18px; }
.narrow { max-width: 640px; }
.form-stack { display: grid; gap: 14px; }
.inline-form { display: flex; gap: 10px; align-items: end; }
label { display: grid; gap: 6px; font-weight: 600; }
input, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  font: inherit;
  background: #fff;
}
button, .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 12px;
  background: #fff;
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
  font: inherit;
  white-space: nowrap;
}
button.primary, .button.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
button.primary:hover, .button.primary:hover { background: var(--primary-dark); }
button.danger { color: var(--danger); border-color: #f0b8b1; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.actions form { margin: 0; }
.spaced { margin-top: 18px; }
.status, .level {
  display: inline-block;
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 700;
  background: #eef2ff;
  color: #3730a3;
}
.status.conectado { background: #dcfce7; color: #166534; }
.status.aguardando_qr { background: #fef3c7; color: #92400e; }
.status.desconectado { background: #e5e7eb; color: #374151; }
.status.erro, .level.error { background: #fee2e2; color: #991b1b; }
.level.warn { background: #fef3c7; color: #92400e; }
.level.info { background: #dcfce7; color: #166534; }
.qr-panel { text-align: center; }
.qr-box { min-height: 300px; display: grid; place-items: center; }
.qr-box img { width: min(300px, 100%); height: auto; }
.alert { padding: 10px 12px; border-radius: 6px; margin-bottom: 14px; }
.alert.success { background: #dcfce7; color: #166534; }
.alert.error { background: #fee2e2; color: #991b1b; }
pre { max-width: 420px; white-space: pre-wrap; margin: 0; font-size: 12px; color: var(--muted); }
small { color: var(--muted); }
.api-examples { margin-top: 18px; max-width: 980px; }
.section-title { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.code-example { border: 1px solid var(--line); border-radius: 8px; overflow: hidden; margin-top: 14px; background: #0f172a; }
.code-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px; background: #ffffff; border-bottom: 1px solid var(--line); }
.code-example pre { max-width: none; margin: 0; padding: 16px; color: #e5e7eb; overflow-x: auto; white-space: pre; font-size: 13px; line-height: 1.5; }

@media (max-width: 900px) {
  .sidebar { position: static; width: auto; min-height: auto; }
  .content { margin-left: 0; padding: 18px; }
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .page-header, .inline-form { align-items: stretch; flex-direction: column; }
  table { display: block; overflow-x: auto; }
}
