:root {
  --bg: #0b1220; --surface: #111a2e; --surface2: #0f1729; --line: #1e293b; --line2: #334155;
  --text: #e2e8f0; --strong: #f8fafc; --muted: #94a3b8; --faint: #64748b;
  --primary: #2563eb; --primary-hover: #1d4ed8; --accent: #93c5fd; --chip: #172554;
  --ok-bg: #052e2b; --ok: #5eead4; --warn-bg: #3b2506; --warn: #fcd34d; --err: #fca5a5; --err-bg: #3f1212;
  --radius: 14px;
  font-family: Inter, "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); min-height: 100%; }
body { font-size: 15px; line-height: 1.45; -webkit-font-smoothing: antialiased; }
a { color: var(--accent); }
a:hover { color: #bfdbfe; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- botões e campos ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 44px; padding: 0 18px; border-radius: 8px; border: none; background: var(--primary); color: #fff; font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--primary-hover); color: #fff; }
.btn:disabled { opacity: .55; cursor: default; }
.btn.sec { background: transparent; border: 1px solid var(--line2); color: #cbd5e1; font-weight: 500; }
.btn.sec:hover { background: var(--surface); }
.btn.chip { background: var(--chip); color: #bfdbfe; font-weight: 500; }
.btn.chip:hover { background: #1e3a8a; }
.btn.perigo { background: transparent; border: 1px solid #7f1d1d; color: var(--err); }
.btn.sm { height: 36px; padding: 0 14px; font-size: 13px; }
label.campo { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 500; color: #cbd5e1; }
label.campo small { font-weight: 400; color: var(--muted); }
.inp { height: 44px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--line2); background: var(--bg); color: #f1f5f9; font-size: 15px; width: 100%; }
textarea.inp { height: auto; min-height: 72px; padding: 10px 14px; resize: vertical; }
.inp::placeholder { color: var(--faint); }
.check { display: flex; align-items: center; gap: 10px; font-size: 14px; color: #cbd5e1; min-height: 44px; }
.check input { width: 18px; height: 18px; accent-color: var(--primary); }
.erro { background: var(--err-bg); color: var(--err); border-radius: 8px; padding: 10px 12px; font-size: 14px; }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 40px 32px; display: flex; flex-direction: column; gap: 22px; }
.login h1 { margin: 0; font-size: 24px; font-weight: 600; color: var(--strong); }
.login p { margin: 0; color: var(--muted); font-size: 14px; }
.marca { display: flex; align-items: center; gap: 12px; }
.marca .logo { width: 40px; height: 40px; border-radius: 10px; background: var(--primary); display: flex; align-items: center; justify-content: center; }
.marca b { font-size: 22px; letter-spacing: .08em; }
.marca.sm .logo { width: 32px; height: 32px; border-radius: 8px; }
.marca.sm b { font-size: 16px; }
.marca .sep { color: var(--faint); }
.marca .sub { color: #cbd5e1; font-size: 14px; }

/* ---------- topo ---------- */
.topo { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; justify-content: space-between; padding: 14px 32px; border-bottom: 1px solid var(--line); }
.topo .dir { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: #1e3a8a; color: #dbeafe; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 600; }
.quem { font-size: 14px; }
main.pag { width: 100%; max-width: 1120px; margin: 0 auto; padding: 48px 32px 64px; display: flex; flex-direction: column; gap: 28px; }
.titulo h1 { margin: 0 0 6px; font-size: 30px; font-weight: 600; color: var(--strong); }
.titulo p { margin: 0; color: var(--muted); }

/* ---------- cards ---------- */
.grade { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 20px; }
.card { display: flex; flex-direction: column; gap: 20px; padding: 26px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); color: inherit; text-decoration: none; min-height: 230px; transition: border-color .15s, transform .15s; }
.card:hover { border-color: #2c4a7a; color: inherit; transform: translateY(-2px); }
.card .lin { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.ico { width: 48px; height: 48px; border-radius: 12px; background: var(--chip); color: var(--accent); display: flex; align-items: center; justify-content: center; flex: none; }
.selo { font-size: 12px; font-weight: 500; padding: 4px 10px; border-radius: 999px; white-space: nowrap; }
.selo.ok { background: var(--ok-bg); color: var(--ok); }
.selo.warn { background: var(--warn-bg); color: var(--warn); }
.selo.mute { background: #1e293b; color: var(--muted); }
.card .corpo { display: flex; flex-direction: column; gap: 8px; flex: 1; }
.card .nome { font-size: 19px; font-weight: 600; color: var(--strong); }
.card .desc { font-size: 14px; color: var(--muted); }
.card .pe { display: flex; justify-content: space-between; align-items: center; font-size: 13px; gap: 12px; }
.card .pe .host { color: var(--faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card .pe .abrir { display: flex; align-items: center; gap: 6px; color: var(--accent); font-weight: 500; }
.vazio { border: 1px dashed var(--line2); border-radius: var(--radius); padding: 40px; text-align: center; color: var(--muted); }

/* ---------- admin ---------- */
.abas { display: flex; gap: 4px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.abas a { padding: 12px 16px; color: var(--muted); text-decoration: none; border-bottom: 2px solid transparent; font-weight: 500; margin-bottom: -1px; }
.abas a[aria-current="page"] { color: var(--strong); border-color: var(--primary); }
.barra { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; justify-content: space-between; }
.barra .grupo { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.tabela-box { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
table.matriz { width: 100%; min-width: 640px; border-collapse: collapse; font-size: 14px; }
.matriz th, .matriz td { padding: 12px 18px; border-bottom: 1px solid var(--line); }
.matriz thead th { text-align: center; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; font-weight: 600; vertical-align: bottom; }
.matriz thead th:first-child { text-align: left; }
.matriz thead th .massa { display: flex; justify-content: center; gap: 6px; margin-top: 8px; text-transform: none; letter-spacing: 0; }
.matriz thead th .massa button { background: none; border: 1px solid var(--line2); color: var(--muted); border-radius: 6px; font-size: 12px; padding: 4px 8px; cursor: pointer; }
.matriz tbody tr:last-child td { border-bottom: none; }
.matriz td.cel { text-align: center; }
.matriz .u-nome { color: var(--strong); font-weight: 500; }
.matriz .u-login { color: var(--muted); font-size: 12px; }
.tg { width: 44px; height: 44px; border-radius: 10px; border: 1px solid var(--line2); background: transparent; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.tg .box { width: 22px; height: 22px; border-radius: 6px; border: 2px solid #475569; display: flex; align-items: center; justify-content: center; }
.tg[aria-pressed="true"] .box { background: var(--primary); border-color: var(--primary); }
.tg.mudou { border-color: var(--warn); }
.nota { font-size: 13px; color: var(--muted); margin: 0; }

.lista-sis { display: flex; flex-direction: column; gap: 12px; }
.sis { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; padding: 18px 20px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.sis .info { flex: 1 1 260px; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.sis .info .l1 { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.sis .info b { color: var(--strong); font-size: 16px; }
.sis .info span.u { color: var(--faint); font-size: 13px; overflow-wrap: anywhere; }

/* ---------- diálogo ---------- */
.fundo { position: fixed; inset: 0; background: rgba(2,6,23,.7); display: flex; align-items: flex-start; justify-content: center; padding: 48px 16px; overflow-y: auto; z-index: 20; }
.dlg { width: 100%; max-width: 620px; background: var(--surface); border: 1px solid var(--line2); border-radius: 16px; padding: 28px; display: flex; flex-direction: column; gap: 18px; }
.dlg h2 { margin: 0; font-size: 20px; color: var(--strong); }
.form-grade { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.form-grade .todo { grid-column: 1 / -1; }
.acoes { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; }
.acoes .esq { margin-right: auto; }
.chave { font-family: ui-monospace, Consolas, monospace; font-size: 13px; background: var(--bg); border: 1px solid var(--line2); border-radius: 8px; padding: 12px; overflow-wrap: anywhere; color: #f1f5f9; }
pre.cod { font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 12px; overflow-x: auto; margin: 0; color: #cbd5e1; white-space: pre; }

#toast { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); max-width: calc(100% - 32px); padding: 14px 20px; border-radius: 10px; background: var(--strong); color: var(--bg); font-size: 14px; font-weight: 500; box-shadow: 0 10px 30px rgba(0,0,0,.4); display: none; z-index: 40; }
#toast.on { display: block; }
#toast.err { background: #fecaca; color: #450a0a; }

@media (max-width: 640px) {
  .topo { padding: 12px 16px; }
  main.pag { padding: 28px 16px 48px; }
  .titulo h1 { font-size: 24px; }
  .form-grade { grid-template-columns: 1fr; }
  .quem { display: none; }
}
