:root {
  --bg: #050506;
  --bg-2: #0b0b0e;
  --panel: #0f0f13;
  --panel-2: #15151a;
  --line: #1e1e25;
  --line-2: #2a2a33;
  --text: #f3f3f5;
  --muted: #8b8b97;
  --dim: #5d5d68;
  --orange: #ff6a13;
  --orange-2: #ff8a1e;
  --orange-deep: #ff3d00;
  --orange-glow: rgba(255, 106, 19, 0.35);
  --orange-soft: rgba(255, 106, 19, 0.10);
  --ok: #2fd27a;
  --ok-soft: rgba(47, 210, 122, 0.12);
  --warn: #ffc247;
  --warn-soft: rgba(255, 194, 71, 0.12);
  --off: #ff5468;
  --off-soft: rgba(255, 84, 104, 0.12);
  --radius: 14px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
body::before {
  content: "";
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background:
    radial-gradient(900px 420px at 85% -10%, rgba(255, 106, 19, 0.10), transparent 60%),
    radial-gradient(600px 300px at -5% 110%, rgba(255, 61, 0, 0.06), transparent 60%);
}
a { color: var(--orange); text-decoration: none; }
button { font-family: inherit; }
.hide { display: none !important; }

/* ---------- Marca ---------- */
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 10px; flex: none;
  background: linear-gradient(135deg, var(--orange-deep), var(--orange-2));
  box-shadow: 0 0 22px var(--orange-glow);
  display: grid; place-items: center;
  font-weight: 800; font-size: 13px; letter-spacing: -0.02em; color: #120600;
}
.brand-name { font-weight: 700; font-size: 15px; letter-spacing: -0.01em; }
.brand-name b { color: var(--orange); font-weight: 700; }
.brand-sub { font-size: 11px; color: var(--muted); letter-spacing: 0.12em; text-transform: uppercase; margin-top: 1px; }

/* ---------- Botões e campos ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 14px; border-radius: 10px;
  border: 1px solid var(--line-2); background: var(--panel-2); color: var(--text);
  font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap;
  transition: border-color .15s, background .15s, box-shadow .15s, transform .05s;
}
.btn:hover { border-color: #3a3a45; background: #1a1a20; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn svg { width: 16px; height: 16px; }
.btn-primary {
  background: linear-gradient(135deg, var(--orange-deep), var(--orange) 55%, var(--orange-2));
  border-color: transparent; color: #140700;
  box-shadow: 0 0 0 1px rgba(255,138,30,.35), 0 6px 24px -6px var(--orange-glow);
}
.btn-primary:hover { background: linear-gradient(135deg, #ff4b0f, #ff7a22 55%, #ff9a3a); border-color: transparent; box-shadow: 0 0 0 1px rgba(255,138,30,.5), 0 8px 30px -6px var(--orange-glow); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--panel-2); color: var(--text); border-color: var(--line); }
.btn-danger { color: var(--off); }
.btn-danger:hover { border-color: rgba(255,84,104,.5); background: var(--off-soft); }
.btn-icon { width: 34px; height: 34px; padding: 0; }
.btn-block { width: 100%; height: 44px; font-size: 14px; }

.field { display: grid; gap: 6px; margin-bottom: 16px; }
.field label { font-size: 12px; font-weight: 600; color: var(--muted); letter-spacing: .02em; }
.field .help { font-size: 12px; color: var(--dim); }
.input {
  width: 100%; height: 42px; padding: 0 12px; border-radius: 10px;
  background: var(--bg-2); border: 1px solid var(--line-2); color: var(--text);
  font: inherit; font-size: 14px; outline: none; transition: border-color .15s, box-shadow .15s;
}
.input::placeholder { color: var(--dim); }
.input:focus { border-color: var(--orange); box-shadow: 0 0 0 3px var(--orange-soft); }
.input.mono { font-family: var(--mono); font-size: 12.5px; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 13px; color: var(--text); cursor: pointer; }
.check input { accent-color: var(--orange); width: 16px; height: 16px; margin: 1px 0 0; }
.check small { display: block; color: var(--dim); font-size: 12px; }

/* ---------- Layout do painel ---------- */
.app { position: relative; z-index: 1; max-width: 1240px; margin: 0 auto; padding: 0 24px 64px; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 20px 0; border-bottom: 1px solid var(--line); margin-bottom: 28px;
}
.topbar-right { display: flex; align-items: center; gap: 8px; }
.updated { font-size: 12px; color: var(--dim); margin-right: 4px; display: inline-flex; align-items: center; gap: 6px; }
.live-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 8px var(--ok); }

.heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.heading h1 { margin: 0; font-size: 26px; font-weight: 700; letter-spacing: -0.03em; }
.heading p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 24px; }
.stat {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; cursor: pointer; transition: border-color .15s, background .15s; text-align: left; color: inherit; font: inherit;
}
.stat:hover { border-color: var(--line-2); }
.stat.active { border-color: rgba(255,106,19,.55); background: linear-gradient(180deg, rgba(255,106,19,.07), var(--panel) 70%); }
.stat-label { font-size: 11px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.stat-value { font-size: 30px; font-weight: 700; letter-spacing: -0.03em; margin-top: 6px; font-variant-numeric: tabular-nums; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; }
.dot.ok { background: var(--ok); box-shadow: 0 0 8px rgba(47,210,122,.6); }
.dot.warn, .dot.stuck { background: var(--warn); box-shadow: 0 0 8px rgba(255,194,71,.6); }
.dot.off { background: var(--off); box-shadow: 0 0 8px rgba(255,84,104,.6); }
.dot.connecting { background: var(--orange); box-shadow: 0 0 8px var(--orange-glow); animation: pulse 1.2s infinite; }
.dot.all { background: var(--text); }
@keyframes pulse { 50% { opacity: .35; } }

.toolbar { display: flex; gap: 10px; margin-bottom: 14px; }
.search { position: relative; flex: 1; max-width: 360px; }
.search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--dim); }
.search .input { padding-left: 36px; height: 38px; }

/* ---------- Lista ---------- */
.list { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.row {
  display: grid; grid-template-columns: minmax(220px, 1.6fr) 170px 150px minmax(180px, 1.3fr) 128px;
  gap: 16px; align-items: center; padding: 14px 18px; border-top: 1px solid var(--line);
}
.row:first-child { border-top: 0; }
.row.head { font-size: 11px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--dim); padding-top: 12px; padding-bottom: 12px; background: var(--bg-2); }
.row:not(.head):hover { background: rgba(255,255,255,.015); }
.who { display: flex; align-items: center; gap: 12px; min-width: 0; }
.avatar {
  width: 38px; height: 38px; border-radius: 50%; flex: none; overflow: hidden;
  background: var(--panel-2); border: 1px solid var(--line-2); display: grid; place-items: center;
  font-size: 13px; font-weight: 700; color: var(--orange);
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.who-text { min-width: 0; }
.who-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who-sub { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.pill {
  display: inline-flex; align-items: center; gap: 7px; height: 26px; padding: 0 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600; white-space: nowrap; border: 1px solid transparent;
}
.pill.ok { color: var(--ok); background: var(--ok-soft); border-color: rgba(47,210,122,.25); }
.pill.warn, .pill.stuck { color: var(--warn); background: var(--warn-soft); border-color: rgba(255,194,71,.25); }
.pill.off { color: var(--off); background: var(--off-soft); border-color: rgba(255,84,104,.25); }
.pill.connecting { color: var(--orange); background: var(--orange-soft); border-color: rgba(255,106,19,.3); }
.pill[data-hint] { cursor: help; }

.cell-muted { font-size: 12.5px; color: var(--muted); }
.cell-muted b { color: var(--text); font-weight: 500; }
.wh { font-family: var(--mono); font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wh.bad { color: var(--warn); }
.actions { display: flex; gap: 6px; justify-content: flex-end; }

.menu-wrap { position: relative; }
.menu {
  position: fixed; z-index: 40; min-width: 240px;
  background: var(--panel-2); border: 1px solid var(--line-2); border-radius: 12px; padding: 6px;
  box-shadow: 0 20px 50px -10px rgba(0,0,0,.8);
}
.menu button {
  display: flex; width: 100%; align-items: center; gap: 10px; padding: 9px 10px; border: 0; border-radius: 8px;
  background: transparent; color: var(--text); font-size: 13px; text-align: left; cursor: pointer;
}
.menu button:hover { background: #1f1f26; }
.menu button svg { width: 15px; height: 15px; color: var(--muted); flex: none; }
.menu button.danger { color: var(--off); }
.menu button.danger svg { color: var(--off); }
.menu hr { border: 0; border-top: 1px solid var(--line-2); margin: 6px 4px; }
.menu small { display: block; color: var(--dim); font-size: 11.5px; margin-top: 1px; }

.empty { padding: 56px 20px; text-align: center; color: var(--muted); }
.empty b { display: block; color: var(--text); font-size: 15px; margin-bottom: 4px; }
.skeleton { height: 66px; border-top: 1px solid var(--line); background: linear-gradient(90deg, transparent, rgba(255,255,255,.025), transparent); background-size: 200% 100%; animation: shimmer 1.2s infinite; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* ---------- Modal ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.72); backdrop-filter: blur(4px);
  display: grid; place-items: center; padding: 16px; animation: fade .15s ease-out;
}
@keyframes fade { from { opacity: 0; } }
.modal {
  width: 100%; max-width: 480px; background: var(--panel); border: 1px solid var(--line-2); border-radius: 18px;
  padding: 24px; box-shadow: 0 30px 80px -20px rgba(0,0,0,.9), 0 0 0 1px rgba(255,106,19,.06);
  animation: rise .18s ease-out; max-height: calc(100vh - 32px); overflow: auto;
}
@keyframes rise { from { transform: translateY(8px); opacity: 0; } }
.modal h2 { margin: 0 0 4px; font-size: 18px; letter-spacing: -0.02em; }
.modal .lead { margin: 0 0 20px; color: var(--muted); font-size: 13px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 8px; }
.alert { border-radius: 10px; padding: 10px 12px; font-size: 13px; margin-bottom: 16px; }
.alert.err { background: var(--off-soft); color: #ff9aa6; border: 1px solid rgba(255,84,104,.25); }
.alert.warn { background: var(--warn-soft); color: #ffd98a; border: 1px solid rgba(255,194,71,.25); }
.alert.info { background: var(--orange-soft); color: #ffb98a; border: 1px solid rgba(255,106,19,.25); }

.success-icon {
  width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; margin-bottom: 14px;
  background: var(--orange-soft); border: 1px solid rgba(255,106,19,.4); color: var(--orange); box-shadow: 0 0 30px var(--orange-glow);
}
.success-icon svg { width: 26px; height: 26px; }
.linkbox {
  display: flex; align-items: center; gap: 8px; padding: 6px 6px 6px 12px; border-radius: 10px;
  background: var(--bg-2); border: 1px solid rgba(255,106,19,.35); margin: 6px 0 16px;
}
.linkbox code { flex: 1; font-family: var(--mono); font-size: 12px; color: var(--orange-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.steps-done { display: grid; gap: 6px; margin: 0 0 16px; padding: 0; list-style: none; font-size: 13px; color: var(--muted); }
.steps-done li { display: flex; gap: 8px; align-items: center; }
.steps-done li::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--ok); }
.steps-done li.fail::before { background: var(--warn); }

/* ---------- Toast ---------- */
.toasts { position: fixed; bottom: 20px; right: 20px; z-index: 80; display: grid; gap: 8px; }
.toast {
  background: var(--panel-2); border: 1px solid var(--line-2); border-left: 3px solid var(--orange);
  border-radius: 10px; padding: 11px 14px; font-size: 13px; min-width: 240px; max-width: 360px;
  box-shadow: 0 14px 40px -10px rgba(0,0,0,.8); animation: rise .18s ease-out;
}
.toast.err { border-left-color: var(--off); }
.toast.ok { border-left-color: var(--ok); }

.tooltip {
  position: fixed; z-index: 90; max-width: 300px; padding: 10px 12px; border-radius: 10px; font-size: 12.5px; line-height: 1.5;
  background: #1c1c22; border: 1px solid var(--line-2); color: var(--text); box-shadow: 0 14px 40px -10px rgba(0,0,0,.8); pointer-events: none;
}

/* ---------- Página de login e QR ---------- */
.center { position: relative; z-index: 1; min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.card {
  width: 100%; max-width: 420px; background: var(--panel); border: 1px solid var(--line); border-radius: 20px;
  padding: 32px 28px; box-shadow: 0 40px 100px -30px rgba(0,0,0,.9);
}
.card .brand { justify-content: center; margin-bottom: 26px; }
.store-tag {
  display: table; margin: 0 auto 10px; padding: 5px 12px; border-radius: 999px; font-size: 12px; font-weight: 700;
  letter-spacing: .08em; text-transform: uppercase; color: var(--orange-2); background: var(--orange-soft); border: 1px solid rgba(255,106,19,.35);
}
.card h1 { margin: 0 0 6px; font-size: 20px; letter-spacing: -0.02em; text-align: center; }
.card .lead { margin: 0 0 22px; color: var(--muted); text-align: center; font-size: 13.5px; }

.qr-frame {
  position: relative; width: 272px; max-width: 100%; aspect-ratio: 1; margin: 0 auto 14px; border-radius: 18px; padding: 12px;
  background: #fff; box-shadow: 0 0 0 1px rgba(255,106,19,.6), 0 0 40px -4px var(--orange-glow);
  display: grid; place-items: center;
}
.qr-frame img { width: 100%; height: 100%; display: block; }
.qr-frame .loading { color: #6b6b73; font-size: 13px; display: grid; justify-items: center; gap: 10px; }
.spinner { width: 26px; height: 26px; border-radius: 50%; border: 3px solid #e7e7ea; border-top-color: var(--orange); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.qr-note { text-align: center; font-size: 12px; color: var(--dim); min-height: 18px; display: flex; align-items: center; justify-content: center; gap: 6px; }
.howto { margin: 22px 0 0; padding: 0; list-style: none; counter-reset: s; display: grid; gap: 10px; }
.howto li { counter-increment: s; display: grid; grid-template-columns: 24px 1fr; gap: 10px; align-items: start; font-size: 13.5px; color: var(--muted); }
.howto li::before {
  content: counter(s); width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center;
  font-size: 12px; font-weight: 700; color: var(--orange); background: var(--orange-soft); border: 1px solid rgba(255,106,19,.35);
}
.howto b { color: var(--text); font-weight: 600; }
.big-check {
  width: 84px; height: 84px; border-radius: 50%; margin: 6px auto 18px; display: grid; place-items: center;
  background: var(--orange-soft); border: 1px solid rgba(255,106,19,.5); color: var(--orange); box-shadow: 0 0 50px var(--orange-glow);
}
.big-check svg { width: 40px; height: 40px; }
.footer-brand { text-align: center; font-size: 11px; color: var(--dim); letter-spacing: .12em; text-transform: uppercase; margin-top: 22px; }
.footer-brand b { color: var(--orange); font-weight: 600; }

/* ---------- Responsivo ---------- */
@media (max-width: 1000px) {
  .row { grid-template-columns: minmax(200px, 1.5fr) 160px minmax(150px, 1fr) 128px; }
  .row > .col-wh { display: none; }
}
@media (max-width: 760px) {
  .app { padding: 0 16px 48px; }
  .topbar { padding: 14px 0; margin-bottom: 20px; }
  .updated { display: none; }
  .heading { flex-direction: column; align-items: stretch; }
  .heading h1 { font-size: 22px; }
  .stats { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat { padding: 12px 14px; }
  .stat-value { font-size: 24px; }
  .toolbar { flex-direction: column; }
  .search { max-width: none; }
  .row.head { display: none; }
  .row {
    grid-template-columns: 1fr auto; grid-template-areas: "who actions" "status status" "last last";
    gap: 10px; padding: 14px;
  }
  .row > .col-who { grid-area: who; }
  .row > .col-status { grid-area: status; }
  .row > .col-last { grid-area: last; }
  .row > .col-actions { grid-area: actions; }
  .row > .col-wh { display: none; }
  .btn-label { display: none; }
  .toasts { left: 16px; right: 16px; bottom: 16px; }
  .toast { max-width: none; }
  .card { padding: 26px 20px; }
}
