/* ============================================================
   Painel Admin API — Dark Profissional Moderno
   Todos os seletores usados pelo app.js foram preservados.
   ============================================================ */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg: #0d1117;
  --bg-elev: #151b23;
  --bg-elev2: #1b2330;
  --bg-soft: #0a0e14;
  --border: #262e3b;
  --border-soft: #1e2633;
  --text: #e6edf3;
  --text-2: #b6c2d1;
  --muted: #7d8ba1;
  --primary: #3b82f6;
  --primary-2: #5b8cff;
  --primary-soft: rgba(59, 130, 246, .14);
  --danger: #f85149;
  --success: #3fb950;
  --warn: #d29922;
  --info: #58a6ff;
  --radius-lg: 14px;
  --radius: 10px;
  --radius-sm: 7px;
  --shadow-1: 0 1px 2px rgba(0,0,0,.25), 0 4px 16px rgba(0,0,0,.18);
  --shadow-2: 0 8px 30px rgba(0,0,0,.35);
  --font: 'Segoe UI Variable', 'Segoe UI', system-ui, -apple-system, 'Helvetica Neue', sans-serif;
  --mono: 'Cascadia Code', 'JetBrains Mono', Consolas, 'SF Mono', monospace;
  --transition: all .16s cubic-bezier(.4,0,.2,1);
}

html, body {
  height: 100%;
}

body {
  background: var(--bg);
  background-image:
    radial-gradient(900px 420px at 85% -8%, rgba(59,130,246,.07), transparent 60%),
    radial-gradient(700px 360px at -5% 108%, rgba(63,185,80,.04), transparent 55%);
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.hidden {
  display: none !important;
}

::selection {
  background: rgba(59,130,246,.35);
}

button {
  font-family: inherit;
}

/* Scrollbars refinadas */
* {
  scrollbar-width: thin;
  scrollbar-color: #2b3444 transparent;
}
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: #2b3444;
  border-radius: 8px;
  border: 2px solid var(--bg);
}
::-webkit-scrollbar-thumb:hover {
  background: #3b4660;
}

/* ======================= LOGIN ======================= */
.tela-login {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  width: 380px;
  max-width: 100%;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 36px 32px 30px;
  box-shadow: var(--shadow-2);
  position: relative;
  overflow: hidden;
}

.login-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  background: linear-gradient(90deg, var(--primary), #7c6cff, var(--success));
}

.login-card h1 {
  font-size: 21px;
  font-weight: 700;
  letter-spacing: .2px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.login-card h1::before {
  content: "";
  width: 22px;
  height: 22px;
  border-radius: 7px;
  background: linear-gradient(135deg, var(--primary), #7c6cff);
  background-image:
    linear-gradient(135deg, var(--primary), #7c6cff),
    radial-gradient(circle at 30% 30%, rgba(255,255,255,.35), transparent 45%);
  box-shadow: 0 0 18px rgba(59,130,246,.55);
}

.login-card .sub {
  color: var(--muted);
  font-size: 13px;
  margin: 6px 0 26px;
}

.login-card label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
  margin: 14px 0 6px;
  letter-spacing: .2px;
}

.login-card input {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: var(--transition);
}

.login-card input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59,130,246,.18);
}

.login-card button[type="submit"] {
  width: 100%;
  margin-top: 22px;
  padding: 11px;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  border-radius: var(--radius-sm);
}

.msg {
  margin-top: 12px;
  font-size: 13px;
  min-height: 18px;
}

.msg.erro { color: var(--danger); }
.msg.ok { color: var(--success); }

/* ======================= LAYOUT ======================= */
.tela-painel {
  display: grid;
  grid-template-columns: 236px 1fr;
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg-elev);
  border-right: 1px solid var(--border);
  padding: 14px 12px;
  gap: 10px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px 16px;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: .3px;
  border-bottom: 1px solid var(--border-soft);
}

.brand::before {
  content: "";
  width: 26px;
  height: 26px;
  border-radius: 8px;
  flex: none;
  background:
    linear-gradient(135deg, var(--primary), #7c6cff),
    radial-gradient(circle at 30% 28%, rgba(255,255,255,.35), transparent 50%);
  box-shadow: 0 0 16px rgba(59,130,246,.5);
}

.sidebar nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 3px;
  overflow-y: auto;
}

.nav-btn {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 10px 12px;
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
}

.nav-btn::before {
  content: "";
  flex: none;
  width: 18px;
  height: 18px;
  background-color: currentColor;
  opacity: .85;
  -webkit-mask: var(--ic) center / contain no-repeat;
  mask: var(--ic) center / contain no-repeat;
}

.nav-btn[data-view="dashboard"] { --ic: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2'><rect x='3' y='3' width='7' height='9' rx='1'/><rect x='14' y='3' width='7' height='5' rx='1'/><rect x='14' y='12' width='7' height='9' rx='1'/><rect x='3' y='16' width='7' height='5' rx='1'/></svg>"); }
.nav-btn[data-view="tokens"] { --ic: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round'><circle cx='7.5' cy='15.5' r='5'/><path d='M11.5 11.5L21 2'/><path d='M16 7l3 3'/><circle cx='20' cy='4' r='0'/></svg>"); }
.nav-btn[data-view="usuarios"] { --ic: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2'><path d='M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2'/></svg><svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2'><circle cx='9' cy='7' r='4'/><path d='M23 21v-2a4 4 0 0 0-3-3.87'/><path d='M16 3.13a4 4 0 0 1 0 7.75'/></svg>"); }
.nav-btn[data-view="modulos"] { --ic: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z'/><polyline points='3.27 6.96 12 12.01 20.73 6.96'/><line x1='12' y1='22.08' x2='12' y2='12'/></svg>"); }
.nav-btn[data-view="terminal"] { --ic: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='4 17 10 11 4 5'/><line x1='12' y1='19' x2='20' y2='19'/></svg>"); }
.nav-btn[data-view="logs"] { --ic: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z'/><polyline points='14 2 14 8 20 8'/><line x1='16' y1='13' x2='8' y2='13'/><line x1='16' y1='17' x2='8' y2='17'/></svg>"); }
.nav-btn[data-view="config"] { --ic: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round'><line x1='4' y1='21' x2='4' y2='14'/><line x1='4' y1='10' x2='4' y2='3'/><line x1='12' y1='21' x2='12' y2='12'/><line x1='12' y1='8' x2='12' y2='3'/><line x1='20' y1='21' x2='20' y2='16'/><line x1='20' y1='12' x2='20' y2='3'/><line x1='1' y1='14' x2='7' y2='14'/><line x1='9' y1='8' x2='15' y2='8'/><line x1='17' y1='16' x2='23' y2='16'/></svg>"); }

.nav-btn:hover {
  background: var(--bg-soft);
  color: var(--text);
}

.nav-btn.ativo {
  background: var(--primary-soft);
  color: #fff;
  border-color: rgba(59,130,246,.35);
  box-shadow: inset 0 0 0 1px rgba(59,130,246,.15);
}

.nav-btn.ativo::before {
  color: var(--primary-2);
  opacity: 1;
}

.nav-btn.ativo::after {
  content: "";
  position: absolute;
  left: -12px;
  top: 20%;
  bottom: 20%;
  width: 3px;
  border-radius: 3px;
  background: linear-gradient(180deg, var(--primary-2), #7c6cff);
}

.nav-btn.ghost {
  color: var(--muted);
}

.nav-btn.ghost:hover {
  color: var(--danger);
}

.sidebar-footer {
  padding-top: 10px;
  border-top: 1px solid var(--border-soft);
}

.sidebar-footer .nav-btn {
  --ic: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4'/><polyline points='16 17 21 12 16 7'/><line x1='21' y1='12' x2='9' y2='12'/></svg>");
}

.content {
  padding: 28px 32px 48px;
  min-height: 100vh;
  max-width: 1400px;
  width: 100%;
}

/* ======================= CABEÇALHOS DE VIEW ======================= */
.topo-view {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 12px;
  flex-wrap: wrap;
}

.topo-view h2 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -.2px;
}

.topo-view h3 {
  font-size: 16px;
  font-weight: 600;
}

.topo-view .acao {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

/* ======================= CARDS / STATS ======================= */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}

.stat-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  position: relative;
  overflow: hidden;
  transition: var(--transition);
}

.stat-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--primary), transparent);
  opacity: 0;
  transition: var(--transition);
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-1);
}

.stat-card:hover::before {
  opacity: 1;
}

.stat-card .num {
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -.5px;
  line-height: 1.1;
}

.stat-card .lbl {
  color: var(--muted);
  font-size: 12.5px;
  margin-top: 4px;
  font-weight: 500;
}

/* ======================= TABELAS ======================= */
.tabela-wrap {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: auto;
  box-shadow: var(--shadow-1);
}

table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  text-align: left;
  padding: 11px 14px;
  border-bottom: 1px solid var(--border-soft);
  font-size: 13px;
  white-space: nowrap;
}

th {
  background: var(--bg-elev2);
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .6px;
  position: sticky;
  top: 0;
  z-index: 1;
}

tr:last-child td {
  border-bottom: none;
}

tbody tr {
  transition: background .12s;
}

tbody tr:hover td {
  background: rgba(59,130,246,.05);
}

/* ======================= TAGS ======================= */
.tag {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .2px;
}

.tag.ok { background: rgba(63,185,80,.14); color: var(--success); }
.tag.off { background: rgba(248,81,73,.14); color: var(--danger); }
.tag.warn { background: rgba(210,153,34,.16); color: var(--warn); }
.tag.info { background: rgba(88,166,255,.14); color: var(--info); }

.mono {
  font-family: var(--mono);
  font-size: 12px;
  word-break: break-all;
}

/* ======================= BOTÕES ======================= */
button {
  padding: 8px 14px;
  background: var(--bg-elev2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: var(--transition);
}

button:hover {
  border-color: var(--primary);
  color: #fff;
}

button:disabled {
  opacity: .55;
  cursor: not-allowed;
}

button.primario {
  background: linear-gradient(180deg, var(--primary-2), var(--primary));
  border-color: transparent;
  color: #fff;
  font-weight: 600;
  box-shadow: 0 3px 10px rgba(59,130,246,.35);
}

button.primario:hover {
  filter: brightness(1.1);
  box-shadow: 0 4px 14px rgba(59,130,246,.45);
}

button.danger {
  background: transparent;
  border-color: rgba(248,81,73,.5);
  color: var(--danger);
}

button.danger:hover {
  background: rgba(248,81,73,.12);
  border-color: var(--danger);
}

button.pequeno {
  padding: 5px 10px;
  font-size: 12px;
}

/* ======================= FORMULÁRIOS ======================= */
.form-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  margin-bottom: 18px;
  box-shadow: var(--shadow-1);
}

.form-card h3 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
}

.form-item label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: 6px;
  letter-spacing: .2px;
}

.form-item input,
.form-item select,
.form-item textarea {
  width: 100%;
  padding: 9px 11px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 13px;
  outline: none;
  font-family: inherit;
  transition: var(--transition);
}

.form-item input:focus,
.form-item select:focus,
.form-item textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59,130,246,.16);
}

.form-item select option {
  background: var(--bg-elev);
}

.form-actions {
  margin-top: 16px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* ======================= RESULTADO / TESTE ======================= */
.result-box {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 420px;
  overflow: auto;
  margin-top: 14px;
}

.status-badge {
  font-family: var(--mono);
  font-size: 12px;
  margin-top: 10px;
}
.status-badge.ok { color: var(--success); }
.status-badge.off { color: var(--danger); }

/* ======================= MODAL / TOAST ======================= */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(3, 6, 12, .72);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 20px;
}

.modal-box {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  max-width: 860px;
  width: 100%;
  max-height: 84vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-2);
  overflow: hidden;
  animation: modalIn .18s ease-out;
}

@keyframes modalIn {
  from { opacity: 0; transform: translateY(12px) scale(.98); }
  to { opacity: 1; transform: none; }
}

.modal-title {
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 15px;
}

.modal-box pre {
  padding: 16px 18px;
  overflow: auto;
  font-size: 12px;
  font-family: var(--mono);
  white-space: pre-wrap;
  word-break: break-all;
  flex: 1;
  line-height: 1.55;
}

.modal-box button {
  margin: 14px;
  align-self: flex-end;
}

.modal-img {
  width: 100%;
  border-radius: var(--radius-sm);
  margin-top: 10px;
  border: 1px solid var(--border);
}

.modal-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  flex-wrap: wrap;
  padding: 0 14px 14px;
}

.toast {
  position: fixed;
  top: 18px;
  right: 18px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-left: 3px solid var(--primary);
  border-radius: var(--radius);
  padding: 12px 16px;
  z-index: 100;
  box-shadow: var(--shadow-2);
  max-width: 380px;
  font-size: 13px;
  font-weight: 500;
}

.toast.ok { border-left-color: var(--success); }
.toast.erro { border-left-color: var(--danger); }

/* ======================= MISC ======================= */
.vazio {
  color: var(--muted);
  text-align: center;
  padding: 30px;
  font-size: 13px;
}

.checks-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 6px;
  max-height: 260px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px;
  background: var(--bg-soft);
}

.checks-grid label {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--text);
  cursor: pointer;
}

.checks-grid input[type="checkbox"] {
  accent-color: var(--primary);
  width: 14px;
  height: 14px;
}

.docs-item {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  transition: var(--transition);
}

.docs-item:hover {
  border-color: rgba(59,130,246,.4);
}

.docs-item h4 {
  font-size: 14px;
  margin-bottom: 4px;
}

.docs-item .exemplo {
  font-family: var(--mono);
  font-size: 12px;
  background: var(--bg-soft);
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  margin-top: 8px;
  word-break: break-all;
  border: 1px solid var(--border-soft);
}

.pesquisa {
  width: 230px;
  padding: 9px 12px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 13px;
  outline: none;
  transition: var(--transition);
}

.pesquisa:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59,130,246,.16);
}

/* ======================= TERMINAL ======================= */
.terminal {
  background: #070b12;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  font-family: var(--mono);
  font-size: 12px;
  height: 480px;
  overflow-y: auto;
  line-height: 1.6;
}

.terminal .linha {
  white-space: pre-wrap;
  word-break: break-all;
  border-left: 3px solid transparent;
  padding: 3px 0 3px 10px;
  margin-bottom: 3px;
  display: grid;
  grid-template-columns: 84px 120px 110px 150px 1fr;
  gap: 10px;
  align-items: start;
  border-radius: 0 4px 4px 0;
  transition: background .12s;
}

.terminal .linha:hover {
  background: rgba(255,255,255,.03);
}

.terminal .term-head {
  display: grid;
  grid-template-columns: 84px 120px 110px 150px 1fr;
  gap: 10px;
  padding: 4px 0 8px 10px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: .8px;
  position: sticky;
  top: 0;
  background: #070b12;
  z-index: 1;
}

.terminal .linha.ok {
  border-left-color: var(--success);
  color: #c8f5d8;
}

.terminal .linha.negada {
  border-left-color: var(--danger);
  color: #ffd7d5;
}

.terminal .linha .hora { color: #4f6a9a; }
.terminal .linha .end { color: #7fb6ff; font-weight: 600; }
.terminal .linha .usu { color: #ff92c4; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.terminal .linha .mod { color: #cbabff; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.terminal .linha .ip { color: #ffd08a; }
.terminal .linha .ret { color: #a7e4c0; overflow: hidden; text-overflow: ellipsis; }

.terminal-filtros {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.terminal-filtros select {
  padding: 8px 12px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 13px;
  outline: none;
}

.live-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--success);
  margin-left: 6px;
  animation: pulse 1.4s infinite;
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(63,185,80,.6); }
  70% { box-shadow: 0 0 0 8px rgba(63,185,80,0); }
  100% { box-shadow: 0 0 0 0 rgba(63,185,80,0); }
}

/* ======================= CARDS DE TOKEN ======================= */
.token-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
  gap: 14px;
}

.token-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 11px;
  transition: var(--transition);
  box-shadow: var(--shadow-1);
}

.token-card:hover {
  border-color: rgba(59,130,246,.45);
  transform: translateY(-2px);
  box-shadow: var(--shadow-2);
}

.token-card .tk-topo {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.token-card .tk-id {
  font-weight: 700;
  font-size: 15px;
  margin-bottom: 2px;
}

.token-card .tk-usuario {
  color: var(--muted);
  font-size: 12.5px;
}

.token-card .tk-chip {
  background: var(--bg-elev2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px 9px;
  font-size: 12px;
  color: var(--text-2);
}

.token-card .tk-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.token-card .tk-chips .chip {
  background: var(--primary-soft);
  border: 1px solid rgba(59,130,246,.4);
  color: #a9c6ff;
  border-radius: 20px;
  padding: 2px 9px;
  font-size: 11px;
  font-weight: 500;
}

.token-card .tk-uso {
  display: flex;
  align-items: center;
  gap: 10px;
}

.token-card .tk-bar {
  flex: 1;
  height: 7px;
  background: var(--bg-elev2);
  border-radius: 4px;
  overflow: hidden;
}

.token-card .tk-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--success));
  border-radius: 4px;
  transition: width .4s ease;
}

.token-card .tk-acoes {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.token-card .tk-mod-manager {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.token-card .tk-mod-manager .form-item {
  min-width: 0;
}

.token-card .tk-mod-lista {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.token-card .chip-rm {
  cursor: pointer;
  background: rgba(248,81,73,.1);
  border: 1px solid rgba(248,81,73,.45);
  color: #ffb8b5;
}

.token-card .chip-rm:hover {
  background: rgba(248,81,73,.25);
}

/* ======================= TESTE PRÁTICO ======================= */
.tm-fields {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 12px;
}

.tm-fields .tm-field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: 5px;
}

.tm-fields .tm-field input {
  width: 100%;
  padding: 9px 11px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 13px;
  outline: none;
  transition: var(--transition);
}

.tm-fields .tm-field input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59,130,246,.16);
}

.tm-out {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 18px;
}

.tm-out .tm-col h4 {
  font-size: 13px;
  margin-bottom: 6px;
  color: var(--muted);
  font-weight: 600;
}

.tm-out .tm-col .result-box {
  margin-top: 0;
  min-height: 130px;
  max-height: 480px;
}

.tm-out .result-box.destacado {
  border-color: var(--primary);
}

.tm-imagens {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 14px;
}
.tm-img {
  margin: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: #0c0f16;
}
.tm-img img {
  display: block;
  width: 100%;
  max-height: 460px;
  object-fit: contain;
  background: #121722;
}
.tm-img figcaption {
  padding: 7px 11px;
  font-size: 12px;
  color: var(--muted);
  background: var(--bg-elev2);
  border-top: 1px solid var(--border);
  font-family: var(--mono);
}

/* ======================= LOGS DETALHADOS ======================= */
.log-det {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.log-det .log-grupo b {
  display: block;
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-bottom: 4px;
}

.log-det .log-pre {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  font-size: 11px;
  max-height: 220px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-all;
  margin: 0;
  font-family: var(--mono);
  line-height: 1.5;
}

/* ======================= CONFIG ======================= */
.cfg-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.cfg-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow-1);
}

.cfg-card h4 {
  margin-bottom: 12px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
}

.cfg-info {
  background: var(--primary-soft);
  border: 1px solid rgba(59,130,246,.3);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  font-size: 12.5px;
  color: #b3caff;
  margin-bottom: 14px;
  line-height: 1.55;
}

/* ======================= MATERIAL CLIENTE ======================= */
.msg-cliente {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  font-family: var(--font);
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 13px;
  max-height: 340px;
  overflow: auto;
  line-height: 1.6;
}

.no-wrap {
  white-space: nowrap;
}

/* ======================= RESPONSIVO ======================= */
@media (max-width: 1000px) {
  .content {
    padding: 22px 20px 40px;
  }
}

@media (max-width: 860px) {
  .tela-painel {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    top: 0;
    height: auto;
    flex-direction: row;
    align-items: center;
    padding: 8px 10px;
    gap: 6px;
    border-right: none;
    border-bottom: 1px solid var(--border);
    z-index: 20;
    backdrop-filter: blur(8px);
    background: rgba(21,27,35,.94);
  }

  .brand {
    padding: 6px 8px;
    flex: none;
    border-bottom: none;
  }

  .brand span {
    display: none;
  }

  .sidebar nav {
    flex: 1;
    flex-direction: row;
    align-items: center;
    gap: 4px;
    overflow-x: auto;
    padding: 2px;
  }

  .nav-btn {
    width: auto;
    padding: 8px 10px;
    font-size: 0;
    gap: 0;
    flex: none;
  }

  .nav-btn::before {
    width: 20px;
    height: 20px;
  }

  .nav-btn.ativo::after {
    display: none;
  }

  .sidebar-footer {
    display: none;
  }

  .content {
    padding: 18px 14px 40px;
  }

  .tm-out {
    grid-template-columns: 1fr;
  }

  .terminal {
    height: 430px;
  }

  .terminal .linha,
  .terminal .term-head {
    grid-template-columns: 70px 1fr 100px;
  }

  .terminal .linha .hora { grid-column: 1; }
  .terminal .linha .ip { grid-column: 2; grid-row: 1; }
  .terminal .linha .usu { grid-column: 3; grid-row: 1; }
  .terminal .linha .mod { grid-column: 1 / -1; grid-row: 2; }
  .terminal .linha .ret { grid-column: 1 / -1; grid-row: 3; }

  .terminal .term-head span:nth-child(4),
  .terminal .term-head span:nth-child(5) {
    display: none;
  }

  .token-grid {
    grid-template-columns: 1fr;
  }

  .pesquisa {
    width: 100%;
  }
}

@media (max-width: 560px) {
  .content {
    padding: 14px 10px 30px;
  }

  .login-card {
    padding: 28px 22px 24px;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .tm-fields {
    grid-template-columns: 1fr;
  }

  .topo-view .acao {
    width: 100%;
  }

  .tabela-wrap {
    border-radius: var(--radius-sm);
  }

  table, th, td {
    font-size: 12px;
  }

  .tk-mod-manager {
    flex-direction: column;
    align-items: stretch;
  }

  .terminal .linha,
  .terminal .term-head {
    grid-template-columns: 58px 1fr;
  }

  .terminal .linha .hora { grid-column: 1; grid-row: 1; }
  .terminal .linha .ip { grid-column: 2; grid-row: 1; }
  .terminal .linha .usu { grid-column: 1 / -1; grid-row: 2; }
  .terminal .linha .mod { grid-column: 1 / -1; grid-row: 3; }
  .terminal .linha .ret { grid-column: 1 / -1; grid-row: 4; }

  .terminal .term-head span:nth-child(2) {
    display: none;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .modal-box {
    max-height: 92vh;
  }

  .modal-actions {
    padding-bottom: 10px;
  }

  .toast {
    left: 12px;
    right: 12px;
    top: 12px;
    max-width: none;
  }
}

/* ============================================================
   POLISH v2 — topbar, dashboard turbinada, terminal-janela,
   skeleton loaders e micro-interações. (Seletores existentes
   do app.js preservados; blocos abaixo são aditivos.)
   ============================================================ */

/* ---------- Acessibilidade / movimento ---------- */
:focus-visible {
  outline: 2px solid var(--primary-2);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

/* ---------- Transições globais ---------- */
.view { animation: viewIn .2s ease-out; }

@keyframes viewIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(16px); }
  to { opacity: 1; transform: none; }
}
.toast:not(.hidden) { animation: toastIn .22s ease-out; }

/* ---------- Topbar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 10px 16px;
  margin-bottom: 20px;
  background: rgba(13, 17, 23, .82);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 10px;
  z-index: 15;
  box-shadow: var(--shadow-1);
}

.tb-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-2);
  letter-spacing: .2px;
}

.tb-status .live-dot { margin-left: 0; }

.tb-direita { display: flex; align-items: center; gap: 14px; }

.tb-relogio {
  color: var(--muted);
  font-size: 13px;
  letter-spacing: 1.2px;
  font-variant-numeric: tabular-nums;
}

.tb-user { display: flex; align-items: center; gap: 9px; }

.tb-avatar {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  color: #fff;
  background: linear-gradient(135deg, #5b8cff, #7c6cff);
  box-shadow: 0 0 10px rgba(124, 108, 255, .4);
  flex: none;
}

.tb-nome {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- Stat cards com ícones ---------- */
.stat-card {
  padding: 20px;
}

.stat-ico {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 32px;
  height: 32px;
  border-radius: 10px;
}

.stat-ico::before {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  width: 17px;
  height: 17px;
  background-color: #fff;
  opacity: .92;
  -webkit-mask: var(--ic) center / contain no-repeat;
  mask: var(--ic) center / contain no-repeat;
}

.stat-card.s-azul .stat-ico    { background: linear-gradient(135deg, #5b8cff, var(--primary)); box-shadow: 0 4px 14px rgba(59, 130, 246, .4); }
.stat-card.s-roxo .stat-ico    { background: linear-gradient(135deg, #a78bfa, #7c6cff); box-shadow: 0 4px 14px rgba(124, 108, 255, .35); }
.stat-card.s-verde .stat-ico   { background: linear-gradient(135deg, #46d160, #2ea043); box-shadow: 0 4px 14px rgba(63, 185, 80, .35); }
.stat-card.s-vermelho .stat-ico { background: linear-gradient(135deg, #f97066, #f85149); box-shadow: 0 4px 14px rgba(248, 81, 73, .35); }

.stat-card.s-azul .stat-ico    { --ic: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2'><path d='M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2'/><circle cx='9' cy='7' r='4'/><path d='M23 21v-2a4 4 0 0 0-3-3.87'/><path d='M16 3.13a4 4 0 0 1 0 7.75'/></svg>"); }
.stat-card.s-roxo .stat-ico    { --ic: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2'><circle cx='7.5' cy='15.5' r='5'/><path d='M11.5 11.5L21 2'/><path d='M16 7l3 3'/></svg>"); }
.stat-card.s-verde .stat-ico   { --ic: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='22 12 18 12 15 21 9 3 6 12 2 12'/></svg>"); }
.stat-card.s-vermelho .stat-ico { --ic: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round'><circle cx='12' cy='12' r='10'/><line x1='12' y1='8' x2='12' y2='12'/><line x1='12' y1='16' x2='12.01' y2='16'/></svg>"); }

/* ---------- Dashboard: gráfico + admins ---------- */
.grid-2 {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 16px;
  margin-top: 4px;
}

.card-secao {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow-1);
}

.card-secao h3 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 14px;
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.card-secao .sub-secao {
  color: var(--muted);
  font-weight: 500;
  font-size: 10.5px;
  letter-spacing: .5px;
  text-transform: uppercase;
}

.graf-modulos {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.gm-linha {
  display: grid;
  grid-template-columns: 110px 1fr 52px;
  gap: 10px;
  align-items: center;
}

.gm-nome {
  font-size: 12px;
  color: var(--text-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gm-bar {
  height: 8px;
  background: var(--bg-elev2);
  border-radius: 5px;
  overflow: hidden;
}

.gm-fill {
  height: 100%;
  border-radius: 5px;
  background: linear-gradient(90deg, var(--primary), #7c6cff);
  transition: width .6s cubic-bezier(.4, 0, .2, 1);
}

.gm-val {
  font-size: 12px;
  color: var(--text);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.admins-lista {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.adm-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
}

.adm-avatar {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  color: #fff;
  background: linear-gradient(135deg, var(--primary), #7c6cff);
  flex: none;
}

.adm-info b { display: block; font-size: 13px; }
.adm-info .mono { color: var(--muted); font-size: 11px; }

/* ---------- Terminal como janela ---------- */
.term-window {
  background: #070b12;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-1);
}

.term-window .terminal {
  border: none;
  border-radius: 0;
  height: 460px;
}

.term-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 14px;
  background: var(--bg-elev2);
  border-bottom: 1px solid var(--border);
}

.term-dots { display: flex; gap: 6px; flex: none; }
.term-dots i { width: 11px; height: 11px; border-radius: 50%; display: block; }
.term-dots i:nth-child(1) { background: #ff5f57; }
.term-dots i:nth-child(2) { background: #febc2e; }
.term-dots i:nth-child(3) { background: #28c840; }

.term-titulo {
  flex: 1;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: .3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.term-status {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  flex: none;
}

.term-led {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #4c5a70;
  flex: none;
}

.term-window.ao-vivo .term-led { background: var(--success); box-shadow: 0 0 8px rgba(63, 185, 80, .8); animation: pulse 1.4s infinite; }
.term-window.conectando .term-led { background: var(--info); animation: pulse 1.4s infinite; }
.term-window.reconectando .term-led { background: var(--warn); box-shadow: 0 0 8px rgba(210, 153, 34, .6); }

.term-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding: 8px 12px;
  background: var(--bg-elev2);
  border-top: 1px solid var(--border);
}

.term-count { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.term-foot-btns { display: flex; gap: 6px; }

#term-rolar.ativo { border-color: var(--success); color: var(--success); }

/* ---------- Skeleton loaders ---------- */
@keyframes shimmer {
  0% { background-position: -400px 0; }
  100% { background-position: 400px 0; }
}

.sk,
.sk-big,
.sk-lin {
  display: block;
  border-radius: 6px;
  background: linear-gradient(90deg, #1b2330 25%, #243042 37%, #1b2330 63%);
  background-size: 800px 100%;
  animation: shimmer 1.3s linear infinite;
}

.sk { height: 13px; width: 100%; }
.sk-big { height: 26px; width: 55%; }
.sk-lin { height: 13px; width: 80%; margin-top: 9px; }

.sk-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}

.sk-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

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

.sk-card { display: block; }

/* ---------- Responsivo do polish ---------- */
@media (max-width: 1000px) {
  .grid-2 { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
  .topbar { position: static; margin-bottom: 14px; }
  .tb-nome { max-width: 150px; }
  .term-titulo { display: none; }
}

@media (max-width: 560px) {
  .gm-linha { grid-template-columns: 80px 1fr 44px; }
  .tb-relogio { font-size: 12px; }
  .term-foot { justify-content: center; }
  .term-count { order: 2; }
}