  :root {
    --bg: #f5f6f8; --card: #ffffff; --text: #14181f; --muted: #5b6475; --line: #e2e5ea;
    --accent: #0f8a5f; --accent-hover: #0c7650; --on-accent: #ffffff;
    --ok: #0f8a5f; --ok-bg: #e5f5ed; --warn: #9a6200; --warn-bg: #fff3d9;
    --off: #5b6475; --off-bg: #eceef2; --err: #b3261e; --err-bg: #fdeceb;
  }
  @media (prefers-color-scheme: dark) {
    :root {
      --bg: #0f1216; --card: #171b21; --text: #eef0f3; --muted: #9aa3b2; --line: #2a303a;
      --accent: #2bbf86; --accent-hover: #4fd09e; --on-accent: #06281b;
      --ok: #4fd09e; --ok-bg: #11302a; --warn: #f0b955; --warn-bg: #33290f;
      --off: #9aa3b2; --off-bg: #232830; --err: #ff8a80; --err-bg: #3a1a18;
    }
  }
  * { box-sizing: border-box; }
  body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--text);
    font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; display: grid; place-items: start center; padding: 32px 16px; }
  main { width: 100%; max-width: 480px; }
  .card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 24px; }
  header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
  h1 { font-size: 20px; margin: 0; }
  .pill { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; padding: 4px 12px; border-radius: 999px; white-space: nowrap; }
  .pill::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
  .pill.connected { color: var(--ok); background: var(--ok-bg); }
  .pill.connecting { color: var(--warn); background: var(--warn-bg); }
  .pill.disconnected, .pill.loading { color: var(--off); background: var(--off-bg); }
  p { margin: 0 0 16px; color: var(--muted); }
  button { font: inherit; font-weight: 600; border-radius: 10px; padding: 10px 16px; cursor: pointer; border: 1px solid var(--line); background: transparent; color: var(--text); }
  button.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
  button.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
  button.danger { color: var(--err); }
  button:disabled { opacity: .55; cursor: not-allowed; }
  button:focus-visible, input:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
  .row { display: flex; gap: 10px; flex-wrap: wrap; }
  .tabs { display: flex; gap: 4px; background: var(--off-bg); padding: 4px; border-radius: 12px; margin-bottom: 16px; }
  .tabs button { flex: 1; border: 0; padding: 8px 12px; color: var(--muted); }
  .tabs button[aria-selected="true"] { background: var(--card); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.12); }
  .qr { width: 248px; height: 248px; margin: 0 auto 12px; padding: 12px; background: #fff; border-radius: 12px; border: 1px solid var(--line); display: grid; place-items: center; }
  .qr img, .qr canvas { max-width: 100%; height: auto; }
  .qr-note { text-align: center; font-size: 14px; color: var(--muted); margin-bottom: 16px; min-height: 21px; }
  ol { margin: 0 0 20px; padding-left: 20px; color: var(--muted); font-size: 15px; }
  ol li { margin-bottom: 4px; }
  label { display: block; font-weight: 600; margin-bottom: 6px; }
  input { font: inherit; width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--text); }
  .code { font: 700 32px/1.2 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .15em; text-align: center; padding: 16px; background: var(--off-bg); border-radius: 12px; margin: 16px 0; }
  dl { margin: 0 0 20px; display: grid; grid-template-columns: auto 1fr; gap: 10px 16px; }
  dt { color: var(--muted); } dd { margin: 0; font-weight: 600; text-align: right; overflow-wrap: anywhere; }
  .banner { margin-bottom: 16px; padding: 10px 14px; border-radius: 10px; background: var(--err-bg); color: var(--err); font-size: 15px; }
  .head-right { display: flex; align-items: center; gap: 12px; }
  button.link { border: 0; padding: 4px 6px; background: transparent; color: var(--muted); font-weight: 500; text-decoration: underline; }
  button.link:hover { color: var(--text); }
  .field { display: flex; align-items: center; gap: 6px; }
  .field input { flex: 1; }
  .field-error { min-height: 22px; margin: 6px 0 10px; font-size: 14px; color: var(--err); }
  .hint { margin: 16px 0 0; font-size: 14px; }
  .instancia { margin: -8px 0 16px; font-size: 14px; color: var(--muted); }
  [hidden] { display: none !important; }
  .row-top { margin-top: 12px; }
