:root {
  --bg: #08080D;
  --bg-2: #0E0A18;
  --panel: #11111A;
  --panel-2: #1A1A28;
  --line: #241B3C;
  --line-2: #342651;
  --text: #eceef7;
  --muted: #8a8fa9;
  --brand: #8500FF;
  --brand-2: #B000FF;
  --brand-grad: linear-gradient(135deg, #B000FF 0%, #8500FF 50%, #5B00C0 120%);
  --ok: #22c55e;
  --warn: #f59e0b;
  --err: #f43f5e;
  --radius: 14px;
  --shadow: 0 10px 30px -12px #0009;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.5 Inter, system-ui, -apple-system, Segoe UI, sans-serif; -webkit-font-smoothing: antialiased; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.mono { font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 12.5px; }
a { color: var(--brand-2); cursor: pointer; text-decoration: none; }
h1 { font-size: 24px; margin: 0 0 4px; letter-spacing: -.02em; }
h2 { font-size: 18px; margin: 0 0 16px; letter-spacing: -.01em; }
h3 { font-size: 15px; margin: 0 0 12px; }
.error { color: var(--err); min-height: 1em; margin: 10px 0 0; white-space: pre-line; }
svg.i { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* marca */
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 18px; letter-spacing: -.02em; }
.logo { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: var(--brand-grad); color: #fff; font-size: 14px; box-shadow: 0 6px 18px -6px #8500FF; }

/* botões e campos */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; border: 1px solid var(--line-2); background: var(--panel-2);
  color: var(--text); padding: 9px 15px; border-radius: 10px; font: inherit; font-weight: 600; cursor: pointer; transition: .15s; white-space: nowrap; }
.btn:hover { border-color: #444a75; background: #20243a; }
.btn.primary { background: var(--brand-grad); border-color: transparent; color: #fff; box-shadow: 0 6px 18px -8px #8500FF; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--err); }
.btn.danger:hover { border-color: #f43f5e66; background: #f43f5e14; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--panel-2); }
.btn.sm { padding: 6px 11px; font-size: 12.5px; border-radius: 8px; }
.btn.full { width: 100%; padding: 12px; }
.btn:disabled { opacity: .55; cursor: wait; }
.btn svg.i { width: 16px; height: 16px; }
label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 14px; font-weight: 500; }
input, select, textarea { width: 100%; margin-top: 6px; background: var(--bg-2); border: 1px solid var(--line-2); color: var(--text);
  padding: 11px 13px; border-radius: 10px; font: inherit; transition: .15s; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px #8500FF33; }
input:disabled { opacity: .6; }
textarea { min-height: 160px; font-family: 'JetBrains Mono', monospace; font-size: 12px; }
.hint { font-size: 12px; color: var(--muted); margin: -8px 0 14px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* login */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth-side { position: relative; overflow: hidden; padding: 48px; display: flex; flex-direction: column; justify-content: space-between;
  background: radial-gradient(900px 500px at 10% 0%, #8500FF55, transparent 60%), radial-gradient(700px 500px at 100% 100%, #22d3ee33, transparent 60%), var(--bg-2);
  border-right: 1px solid var(--line); }
.auth-side h2 { font-size: 38px; line-height: 1.1; letter-spacing: -.03em; margin: 0 0 14px; max-width: 480px; }
.auth-side p { color: #c4c7da; max-width: 440px; font-size: 15px; }
.auth-feats { display: grid; gap: 12px; margin-top: 26px; }
.auth-feats div { display: flex; gap: 10px; align-items: center; color: #d6d8e8; }
.auth-feats svg.i { color: var(--brand-2); }
.auth-main { display: grid; place-items: center; padding: 24px; }
.auth-card { width: 100%; max-width: 380px; }
.auth-card form { margin-top: 22px; }
.auth-card h1 { font-size: 26px; }
.switch { text-align: center; color: var(--muted); margin: 16px 0 0; }

/* layout do painel */
.layout { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.sidebar { background: var(--bg-2); border-right: 1px solid var(--line); padding: 20px 14px; display: flex; flex-direction: column; gap: 22px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.sidebar .brand { padding: 0 8px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-title { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #5d6280; padding: 14px 12px 6px; font-weight: 700; }
.nav a { display: flex; align-items: center; gap: 11px; color: var(--muted); padding: 9px 12px; border-radius: 10px; font-weight: 500; transition: .12s; }
.nav a:hover { background: var(--panel); color: var(--text); }
.nav a.active { background: linear-gradient(90deg, #8500FF26, #8500FF08); color: #fff; box-shadow: inset 2px 0 0 var(--brand); }
.nav a.active svg.i { color: #b4a3ff; }
.nav .count { margin-left: auto; font-size: 11px; background: var(--err); color: #fff; padding: 1px 7px; border-radius: 99px; font-weight: 700; }
.me { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); }
.avatar { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--panel-2); font-weight: 700; color: #c9bfff; flex: none; }
.me-info { min-width: 0; flex: 1; }
.me-info b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 13px; }
.me-info span { font-size: 11.5px; color: var(--muted); }
main { padding: 30px 34px 60px; min-width: 0; max-width: 1400px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.imp-bar { background: linear-gradient(90deg, #f59e0b, #f97316); color: #1b1203; font-weight: 600; padding: 9px 20px; display: flex;
  justify-content: center; align-items: center; gap: 14px; position: sticky; top: 0; z-index: 5; }
.imp-bar .btn { background: #1b1203; color: #fff; border: 0; }

/* cards e métricas */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; position: relative; overflow: hidden; }
.stat .lbl { color: var(--muted); font-size: 12.5px; display: flex; align-items: center; gap: 8px; }
.stat .val { font-size: 28px; font-weight: 800; letter-spacing: -.03em; margin-top: 6px; }
.stat .sub { font-size: 12px; color: var(--muted); }
.stat .ico { position: absolute; right: 14px; top: 14px; width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: #8500FF1f; color: #b4a3ff; }
.stat.ok .ico { background: #22c55e1a; color: var(--ok); }
.stat.warn .ico { background: #f59e0b1a; color: var(--warn); }
.stat.err .ico { background: #f43f5e1a; color: var(--err); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.list-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.list-row:last-child { border-bottom: 0; }
.list-row .t { min-width: 0; }
.list-row .t b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-row .t span { font-size: 12px; color: var(--muted); }
.meter { height: 6px; background: var(--panel-2); border-radius: 99px; overflow: hidden; margin-top: 10px; }
.meter div { height: 100%; background: var(--brand-grad); }

/* servidores */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 14px; }
.server-card { display: flex; flex-direction: column; gap: 10px; transition: .15s; }
.server-card:hover { border-color: var(--line-2); transform: translateY(-1px); }
.server-card h3 { margin: 0; font-size: 16px; display: flex; align-items: center; gap: 8px; }
.dns-pill { display: inline-flex; align-items: center; gap: 8px; font-family: 'JetBrains Mono', monospace; font-size: 13px; padding: 7px 11px;
  border-radius: 9px; background: #22d3ee12; color: var(--brand-2); border: 1px solid #22d3ee2e; word-break: break-all; align-self: flex-start; }
.dot { width: 7px; height: 7px; border-radius: 99px; background: var(--ok); box-shadow: 0 0 0 3px #22c55e26; flex: none; }
.server-meta { display: flex; gap: 16px; color: var(--muted); font-size: 13px; }
.server-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.empty { text-align: center; padding: 56px 20px; color: var(--muted); border: 1px dashed var(--line-2); border-radius: var(--radius); background: #ffffff03; }
.empty svg.i { width: 32px; height: 32px; color: #4b5078; margin-bottom: 8px; }
.empty b { display: block; color: var(--text); font-size: 15px; margin-bottom: 4px; }

/* tabelas */
.toolbar { display: flex; gap: 10px; margin-bottom: 14px; align-items: center; flex-wrap: wrap; }
.toolbar select, .toolbar input { width: auto; margin: 0; min-width: 230px; }
.search { position: relative; }
.search svg.i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); width: 16px; height: 16px; }
.search input { padding-left: 36px; }
.table-wrap { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 12px 16px; border-bottom: 1px solid var(--line); white-space: nowrap; vertical-align: middle; }
th { color: var(--muted); font-weight: 600; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; background: #ffffff04; }
tbody tr:hover td { background: #ffffff04; }
tr:last-child td { border-bottom: 0; }
td .row-actions { display: flex; gap: 6px; justify-content: flex-end; }
td.wrap { white-space: normal; min-width: 240px; max-width: 460px; }
.chip { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 6px; background: var(--panel-2); border: 1px solid var(--line-2); margin: 1px 2px 1px 0; }

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; }
.badge.ok { background: #22c55e1a; color: var(--ok); }
.badge.warn { background: #f59e0b1a; color: var(--warn); }
.badge.err { background: #f43f5e1a; color: var(--err); }
.badge.info { background: #8500FF22; color: #b4a3ff; }
.badge.off { background: #ffffff0d; color: var(--muted); }

/* marca: prévia da TV */
.tv { background: #000; border-radius: 16px; padding: 10px; border: 1px solid var(--line-2); box-shadow: var(--shadow); max-width: 640px; }
.tv-screen { aspect-ratio: 16/9; border-radius: 8px; overflow: hidden; padding: 4% 4.5%; display: flex; flex-direction: column; gap: 4%;
  background: linear-gradient(315deg, #0b0d14 0%, #141030 50%, #2a1660 100%); }
.tv-top { height: 13%; display: flex; align-items: center; justify-content: space-between; }
.tv-top img { height: 100%; max-width: 50%; object-fit: contain; object-position: left; }
.tv-top .tv-brand { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: clamp(11px, 2.4vw, 18px); height: 100%; }
.tv-top .tv-brand .logo { width: auto; height: 100%; aspect-ratio: 1; border-radius: 22%; font-size: 70%; }
.tv-top .tv-brand img { height: 100%; max-width: 160px; object-fit: contain; }
.tv-top small { font-size: clamp(8px, 1.4vw, 11px); color: #ffffffcc; }
.tv-tiles { flex: 1; display: grid; grid-template-columns: 1.25fr 1fr 1fr 1.1fr; grid-template-rows: 1fr 1fr; gap: 3%; }
.tv-tiles div { border-radius: 8px; background: #ffffff1f; display: grid; place-items: center; font-size: clamp(8px, 1.5vw, 12px); font-weight: 700; text-align: center; }
.tv-tiles .big { grid-row: span 2; background: linear-gradient(315deg, #4a2fc0, #8500FF); font-size: clamp(10px, 2vw, 16px); }
.brand-box { display: grid; grid-template-columns: 1.4fr 1fr; gap: 18px; align-items: start; }

/* modal e toast */
.modal { position: fixed; inset: 0; background: #000a; backdrop-filter: blur(4px); display: grid; place-items: center; padding: 16px; z-index: 20; }
.modal-card { width: 100%; max-width: 540px; max-height: 90vh; overflow: auto; background: var(--panel); border: 1px solid var(--line-2);
  border-radius: 18px; padding: 24px; box-shadow: var(--shadow); animation: pop .15s ease; }
@keyframes pop { from { transform: scale(.97); opacity: 0; } }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 10px; }
.preview { background: var(--bg-2); border: 1px solid var(--line-2); border-radius: 10px; padding: 12px 14px; margin-bottom: 14px;
  font-family: 'JetBrains Mono', monospace; font-size: 12px; word-break: break-all; line-height: 1.6; }
.preview .old { color: var(--err); text-decoration: line-through; } .preview .new { color: var(--ok); }
.pl-item { background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin-bottom: 10px; }
.pl-item .mono { word-break: break-all; color: var(--muted); display: block; margin: 4px 0 10px; }
.toast { position: fixed; bottom: 22px; right: 22px; background: var(--panel-2); border: 1px solid var(--line-2); padding: 13px 18px;
  border-radius: 12px; z-index: 30; max-width: 380px; box-shadow: var(--shadow); animation: pop .15s ease; }
.stack { display: flex; flex-direction: column; gap: 10px; }

/* portal do cliente (mantido) */
.portal { max-width: 720px; margin: 0 auto; padding: 28px 16px; }
.portal-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 22px; }
.device-box { display: flex; gap: 20px; flex-wrap: wrap; margin-bottom: 18px; }
.device-box div { flex: 1; min-width: 160px; }
.device-box b { display: block; font-size: 16px; }
.steps { color: var(--muted); padding-left: 18px; margin: 14px 0 0; font-size: 13px; }
.auth.simple { display: grid; grid-template-columns: 1fr; place-items: center; padding: 16px;
  background: radial-gradient(600px 300px at 50% 0%, #8500FF22, transparent); }
.auth.simple .auth-card { background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 28px; }

@media (max-width: 960px) {
  .auth { grid-template-columns: 1fr; } .auth-side { display: none; }
  .grid2, .brand-box { grid-template-columns: 1fr; }
}
@media (max-width: 780px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: column; gap: 10px; padding: 12px; }
  .nav { flex-direction: row; overflow-x: auto; gap: 4px; } .nav-title { display: none; }
  .nav a { white-space: nowrap; padding: 8px 10px; }
  .me { margin: 0; }
  main { padding: 18px 16px 50px; }
  .toolbar select, .toolbar input, .search { min-width: 0; flex: 1; }
  .row2 { grid-template-columns: 1fr; }
}

.logo-img { width: 36px; height: 36px; object-fit: contain; flex: none; }
.ver { font-size: 10.5px; font-weight: 600; color: var(--muted); background: var(--panel-2); border: 1px solid var(--line-2); padding: 1px 6px; border-radius: 6px; letter-spacing: 0; }
.tv-top .tv-brand .logo-img { width: auto; height: 100%; }

/* refinos v1.4 */
body { -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
h1 { letter-spacing: -0.025em; }
.stat .val { font-variant-numeric: tabular-nums; }
.btn.primary { box-shadow: 0 8px 22px -10px #8500FFcc; }
.card { transition: border-color .15s, transform .15s; }
.nav a { transition: background .12s, color .12s; }
.table-wrap { box-shadow: var(--shadow); }

/* Mensagem de sucesso na tela de login */
.ok-msg { color: var(--ok); background: rgba(34,197,94,.08); border: 1px solid rgba(34,197,94,.3); border-radius: 10px; padding: 10px 12px; font-size: 13px; margin-top: 6px; }

/* Árvore da rede (master) */
.tree { margin-top: 6px; }
.tree-node { position: relative; }
.tree-node .tree-node { border-left: 1px solid var(--line-2); padding-left: 4px; }
.tree-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 8px 10px; margin: 4px 0; background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; }
.tree-dot { color: var(--brand-2); width: 14px; display: inline-block; text-align: center; }
.tree-meta { margin-left: auto; display: flex; gap: 6px; flex-wrap: wrap; }

/* Botão flutuante de suporte no WhatsApp */
.wa-fab { position: fixed; right: 22px; bottom: 22px; width: 62px; height: 62px; border-radius: 50%;
  background: linear-gradient(135deg, #25D366, #128C7E); display: flex; align-items: center; justify-content: center;
  box-shadow: 0 10px 30px rgba(18,140,126,.5); z-index: 60; transition: transform .15s, box-shadow .15s; }
.wa-fab:hover { transform: translateY(-2px) scale(1.04); box-shadow: 0 14px 38px rgba(18,140,126,.6); }

/* Prévia da tela inicial do app (interface nova) */
.appmock { background: radial-gradient(130% 100% at 50% -10%, #1a0a33 0%, #08080D 60%); border: 1px solid var(--line-2);
  border-radius: 20px; padding: 22px; box-shadow: var(--shadow); max-width: 440px; margin: 0 auto; }
.am-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.am-logo img { height: 34px; max-width: 170px; object-fit: contain; }
.am-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 10px var(--ok); }
.am-tiles { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; }
.am-tile { aspect-ratio: 1; border-radius: 14px; background: var(--panel-2); border: 1px solid var(--line);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; font-size: 11px; color: #c9c6da; text-align: center; }
.am-tile span { font-size: 22px; }
.am-tile:first-child { border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand) inset, 0 8px 24px rgba(133,0,255,.3); }
.am-reload { margin: 16px auto 0; width: fit-content; display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 14px;
  color: #fff; background: var(--brand-grad); padding: 10px 24px; border-radius: 999px; box-shadow: 0 8px 22px rgba(133,0,255,.4); }
.am-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 18px; padding-top: 12px; border-top: 1px solid var(--line);
  font-size: 11px; color: var(--muted); }
.am-exp { color: var(--ok); font-weight: 700; }
