:root {
  --bg: #0f1220; --panel: #171b2e; --panel2: #1e2340; --line: #2a3052;
  --text: #e7e9f3; --muted: #9aa1c0; --accent: #4f7cff; --accent2: #3a63e0;
  --ok: #2fbf71; --low: #6aa8ff; --mid: #f0b429; --high: #ff7a45; --crit: #ff4d6d;
  --radius: 12px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
h1 { font-size: 22px; margin: 0 0 16px; }
h2 { font-size: 17px; margin: 0 0 12px; }
h3 { font-size: 15px; margin: 0 0 6px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* Layout */
.shell { display: flex; min-height: 100vh; }
.side { width: 220px; background: var(--panel); border-right: 1px solid var(--line); padding: 18px 12px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; }
.brand { font-weight: 700; font-size: 18px; padding: 4px 10px 16px; display: flex; align-items: center; gap: 8px; }
.brand i { width: 12px; height: 12px; border-radius: 50%; background: var(--muted); display: inline-block; }
.brand i.on { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.nav a { display: flex; justify-content: space-between; align-items: center; padding: 9px 12px; border-radius: 8px; color: var(--muted); }
.nav a:hover { background: var(--panel2); color: var(--text); }
.nav a.act { background: var(--panel2); color: var(--text); font-weight: 600; }
.side .grow { flex: 1; }
.main { flex: 1; padding: 24px 28px; max-width: 1200px; min-width: 0; }
.badge { background: var(--accent); color: #fff; border-radius: 99px; font-size: 12px; padding: 0 8px; min-width: 20px; text-align: center; }

@media (max-width: 760px) {
  .shell { flex-direction: column; }
  .side { width: 100%; height: auto; position: static; flex-direction: row; flex-wrap: wrap; padding: 10px 12px; border-right: 0; border-bottom: 1px solid var(--line); }
  .brand { padding: 4px 8px; width: 100%; }
  .nav { display: flex; flex-wrap: wrap; gap: 2px; }
  .nav a { padding: 6px 10px; }
  .side .grow { display: none; }
  .main { padding: 16px; }
}

/* Componentes */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack > * + * { margin-top: 14px; }
.stats { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); margin-bottom: 18px; }
.stat .n { font-size: 26px; font-weight: 700; }
.btn { background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 7px 14px; cursor: pointer; }
.btn:hover { border-color: var(--accent); }
.btn.pri { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.pri:hover { background: var(--accent2); }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #06210f; font-weight: 600; }
.btn.danger { color: var(--crit); }
.btn.danger:hover { border-color: var(--crit); }
.btn.sm { padding: 4px 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }
input, select, textarea { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; width: 100%; }
textarea { min-height: 140px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); border-color: transparent; }
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.field { margin-bottom: 12px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.three { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
@media (max-width: 560px) { .two, .three { grid-template-columns: 1fr; } }

.pill { display: inline-block; padding: 1px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; border: 1px solid currentColor; white-space: nowrap; }
.n-ok, .n-info { color: var(--ok); } .n-baixo { color: var(--low); } .n-medio { color: var(--mid); }
.n-alto { color: var(--high); } .n-critico { color: var(--crit); }
.st-executando { color: var(--accent); } .st-erro { color: var(--crit); } .st-parado { color: var(--muted); }
.st-aguardando, .st-online { color: var(--ok); } .st-stopped, .st-errored { color: var(--crit); }

/* Interruptor */
.switch { position: relative; width: 46px; height: 26px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: var(--line); border-radius: 99px; cursor: pointer; transition: .15s; }
.switch span::before { content: ""; position: absolute; width: 20px; height: 20px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .15s; }
.switch input:checked + span { background: var(--ok); }
.switch input:checked + span::before { transform: translateX(20px); }

.agent .top { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.agent .meta { font-size: 13px; color: var(--muted); margin: 8px 0 12px; }
.agent .actions { display: flex; gap: 6px; flex-wrap: wrap; }

.list .item { padding: 12px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.list .item:last-child { border-bottom: 0; }
.list .item.unread h3::before { content: "● "; color: var(--accent); }
.finding { border-left: 3px solid var(--line); padding: 6px 0 6px 12px; margin: 12px 0; }
.finding.g-alto { border-color: var(--high); } .finding.g-critico { border-color: var(--crit); }
.finding.g-medio { border-color: var(--mid); } .finding.g-baixo { border-color: var(--low); }
.pre { white-space: pre-wrap; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 10px; font-size: 13px; }
.banner { padding: 12px 16px; border-radius: var(--radius); margin-bottom: 16px; border: 1px solid; }
.banner.warn { border-color: var(--mid); background: #f0b42914; }
.banner.info { border-color: var(--accent); background: #4f7cff14; }
.tabs { display: flex; gap: 6px; margin-bottom: 14px; flex-wrap: wrap; }
.tabs .btn.act { background: var(--accent); border-color: var(--accent); color: #fff; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 500; }
.tablewrap { overflow-x: auto; }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login .card { width: 100%; max-width: 380px; padding: 28px; }

/* Modal */
.modal-bg { position: fixed; inset: 0; background: #000a; display: grid; place-items: center; padding: 16px; z-index: 10; }
.modal { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; width: 100%; max-width: 640px; max-height: 92vh; overflow: auto; }

#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 20; }
#toast div { background: var(--panel2); border: 1px solid var(--line); padding: 10px 16px; border-radius: 8px; margin-top: 6px; box-shadow: 0 6px 20px #0008; }
#toast div.err { border-color: var(--crit); }
.exec { margin-top: 12px; padding: 10px 12px; border-radius: 8px; background: var(--bg); border: 1px solid var(--line); }
.diff { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; max-height: 70vh; overflow: auto; white-space: pre; }
.diff .add { color: var(--ok); } .diff .del { color: var(--crit); } .diff .hunk { color: var(--accent); }
.item-click { cursor: pointer; } .item-click:hover { border-color: var(--accent); }
.md p { margin: 6px 0; } .md ul { margin: 6px 0; padding-left: 22px; } .md-h { margin: 16px 0 6px; }
code { background: var(--bg); border: 1px solid var(--line); border-radius: 4px; padding: 0 5px; font-size: 13px; }
.hbar { display: inline-flex; gap: 1px; vertical-align: middle; }
.hbar i { width: 3px; height: 14px; border-radius: 1px; display: inline-block; }
.hbar i.up { background: var(--ok); } .hbar i.down { background: var(--crit); }
.opcoes { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); width: 100%; }
.opcao { text-align: left; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; cursor: pointer; display: flex; flex-direction: column; gap: 4px; }
.opcao:hover { border-color: var(--accent); }
.opcao span { font-size: 12px; color: var(--muted); }
.meter { display: block; height: 6px; background: var(--line); border-radius: 99px; overflow: hidden; margin-top: 8px; }
.meter i { display: block; height: 100%; border-radius: 99px; }
td .meter { margin-top: 0; }
.sysagent { border-color: #4f7cff55; }
.checkline { display: flex; gap: 8px; align-items: flex-start; margin: 12px 0 0; color: var(--text); font-size: 13px; }
.checkline input { width: auto; margin-top: 3px; flex: none; }
