/* Edge Dashboard — dark NOC */
:root {
  --bg: #0b1120;
  --surface: #111a2e;
  --surface-2: #17233c;
  --border: rgba(255, 255, 255, 0.09);
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --online: #22c55e;
  --atrasado: #f59e0b;
  --offline: #ef4444;
  --semdados: #64748b;
  --manut: #a78bfa;
  --drenando: #22d3ee;
  --desativado: #475569;
  --accent: #6366f1;
  --focus: #818cf8;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
.mono, .metric b, .counter b { font-variant-numeric: tabular-nums; font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }
a { color: var(--focus); }
button, select, input { font: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* topbar */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 20px; background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 40;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.brand svg { color: var(--accent); }
.topbar-right { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.muted { color: var(--text-muted); font-size: 13px; }
.user-chip { background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: 2px 12px; font-size: 13px; }
.btn-ghost {
  color: var(--text-muted); text-decoration: none; border: 1px solid var(--border);
  border-radius: 8px; padding: 4px 12px; font-size: 13px; background: transparent; cursor: pointer;
  transition: color 150ms ease, border-color 150ms ease;
}
.btn-ghost:hover { color: var(--text); border-color: var(--text-muted); }

.wrap { max-width: 1440px; margin: 0 auto; padding: 20px; }

/* contadores */
.counters { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.counter {
  display: flex; align-items: center; gap: 12px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px;
}
.counter b { display: block; font-size: 22px; line-height: 1.2; }
.counter small { color: var(--text-muted); }
.c-traffic { display: flex; gap: 20px; }
.dot { width: 12px; height: 12px; border-radius: 50%; flex: 0 0 auto; }
.dot-online { background: var(--online); }
.dot-atrasado { background: var(--atrasado); }
.dot-offline { background: var(--offline); }
.dot-manut { background: var(--manut); }

/* gráfico pool */
.pool-chart-card, .chart-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 14px 16px; margin-bottom: 16px;
}
.pool-chart-card h2, .chart-card h2 { margin: 0 0 8px; font-size: 14px; font-weight: 600; color: var(--text-muted); }
.chart-holder { position: relative; height: 200px; }
.pool-chart-card .chart-holder { height: 160px; }

/* grid de nós */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 14px; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 14px 16px; display: block; color: inherit; text-decoration: none;
  transition: border-color 150ms ease, transform 150ms ease;
  cursor: pointer;
}
.card:hover { border-color: var(--focus); }
.card.is-offline { border-left: 3px solid var(--offline); }
.card.is-atrasado { border-left: 3px solid var(--atrasado); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.card-title { font-weight: 600; }
.card-ip { color: var(--text-muted); font-size: 12px; }

.status-pill {
  display: inline-flex; align-items: center; gap: 6px; border-radius: 999px;
  font-size: 12px; font-weight: 600; padding: 2px 10px; text-transform: none;
}
.status-pill::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.status-online   { color: var(--online);   background: rgba(34, 197, 94, 0.12); }
.status-atrasado { color: var(--atrasado); background: rgba(245, 158, 11, 0.12); }
.status-offline  { color: var(--offline);  background: rgba(239, 68, 68, 0.14); }
.status-sem_dados{ color: var(--semdados); background: rgba(100, 116, 139, 0.18); }
.status-manutencao { color: var(--manut); background: rgba(167, 139, 250, 0.14); }
.status-drenando { color: var(--drenando); background: rgba(34, 211, 238, 0.12); }
.status-desativado { color: var(--desativado); background: rgba(71, 85, 105, 0.25); }

.metrics { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px 10px; margin-bottom: 8px; }
.metric small { display: block; color: var(--text-muted); font-size: 11px; }
.metric b { font-size: 14px; font-weight: 600; }
.metric .warn { color: var(--atrasado); }
.metric .crit { color: var(--offline); }
.spark-holder { height: 42px; margin-top: 4px; }
.spark-label { font-size: 11px; color: var(--text-muted); }

.state-msg { color: var(--text-muted); padding: 30px; text-align: center; }
.alert-err {
  background: rgba(239, 68, 68, 0.12); border: 1px solid rgba(239, 68, 68, 0.4);
  color: #fca5a5; border-radius: 8px; padding: 10px 14px; margin-bottom: 14px;
}

/* login */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100dvh; }
.login-box {
  width: min(360px, 92vw); background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; padding: 28px;
}
.login-box h1 { margin: 0; font-size: 20px; }
.login-sub { color: var(--text-muted); margin: 4px 0 18px; font-size: 13px; }
.login-box label { display: block; margin: 12px 0 4px; font-size: 13px; color: var(--text-muted); }
.login-box input {
  width: 100%; background: var(--bg); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; padding: 10px 12px; min-height: 44px;
}
.login-box button {
  width: 100%; margin-top: 18px; background: var(--accent); color: #fff; border: 0;
  border-radius: 8px; padding: 12px; font-weight: 600; cursor: pointer; min-height: 44px;
  transition: filter 150ms ease;
}
.login-box button:hover { filter: brightness(1.15); }

/* edge.php */
.edge-head {
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 14px 16px; margin-bottom: 16px;
}
.edge-meta { display: flex; gap: 16px; color: var(--text-muted); font-size: 13px; flex-wrap: wrap; }
.edge-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; flex-wrap: wrap; }
.edge-actions label { font-size: 13px; color: var(--text-muted); }
.edge-actions select {
  background: var(--bg); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 10px; min-height: 44px; cursor: pointer;
}
.btn {
  background: var(--accent); color: #fff; border: 0; border-radius: 8px;
  padding: 8px 16px; font-weight: 600; cursor: pointer; min-height: 44px;
  transition: filter 150ms ease;
}
.btn:hover { filter: brightness(1.15); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.range-bar { display: flex; align-items: center; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; color: var(--text-muted); font-size: 13px; }
.range-btn {
  background: var(--surface); color: var(--text-muted); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 14px; cursor: pointer; min-height: 40px;
  transition: color 150ms ease, border-color 150ms ease;
}
.range-btn:hover { color: var(--text); }
.range-btn.active { color: #fff; background: var(--accent); border-color: var(--accent); }

.charts-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(420px, 1fr)); gap: 14px; }
@media (max-width: 520px) {
  .charts-grid { grid-template-columns: 1fr; }
  .chart-holder { height: 180px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ===== Fase 2 ===== */
.mainnav { display: flex; gap: 4px; flex-wrap: wrap; }
.mainnav a { color: var(--text-muted); text-decoration: none; padding: 6px 12px; border-radius: 8px; font-size: 13px; transition: color 150ms ease, background 150ms ease; }
.mainnav a:hover { color: var(--text); background: var(--surface-2); }
.mainnav a.active { color: #fff; background: var(--accent); }

.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { text-align: left; color: var(--text-muted); font-size: 12px; font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--border); }
.tbl td { padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tbl tr:hover td { background: rgba(255,255,255,0.02); }
.tbl-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 6px 10px 10px; margin-bottom: 16px; }

.badge { display: inline-block; border-radius: 999px; padding: 2px 10px; font-size: 12px; font-weight: 600; }
.badge-ok { color: var(--online); background: rgba(34,197,94,0.12); }
.badge-warn { color: var(--atrasado); background: rgba(245,158,11,0.12); }
.badge-crit { color: var(--offline); background: rgba(239,68,68,0.16); }
.badge-info { color: var(--drenando); background: rgba(34,211,238,0.12); }
.badge-muted { color: var(--semdados); background: rgba(100,116,139,0.18); }

.modal-backdrop { position: fixed; inset: 0; background: rgba(2,6,17,0.72); z-index: 100; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal-backdrop[hidden] { display: none; }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 20px; width: min(760px, 96vw); max-height: 90dvh; overflow: auto; }
.modal h2 { margin: 0 0 10px; font-size: 16px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 14px; }
.modal input[type=text] { width: 100%; background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; min-height: 44px; margin-top: 6px; }
.job-log { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 10px; font: 12px/1.5 ui-monospace, Menlo, Consolas, monospace; max-height: 46dvh; overflow: auto; white-space: pre-wrap; word-break: break-all; }
.diff-list { font: 13px/1.6 ui-monospace, Menlo, Consolas, monospace; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 10px; margin: 8px 0; }

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 16px; margin-bottom: 16px; }
.form-grid label { display: block; font-size: 12px; color: var(--text-muted); margin-bottom: 4px; }
.form-grid input, .form-grid select, .form-grid textarea { width: 100%; background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 9px 12px; min-height: 42px; }
.form-grid textarea { min-height: 120px; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; }
.form-full { grid-column: 1 / -1; }

.pool-grid td, .pool-grid th { text-align: center; }
.pool-grid td:first-child, .pool-grid th:first-child { text-align: left; }
.pool-grid input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--accent); cursor: pointer; }
.pool-dirty { outline: 2px solid var(--atrasado); outline-offset: 2px; border-radius: 3px; }

.section-title { font-size: 15px; font-weight: 600; margin: 20px 0 10px; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.progress-txt { font-variant-numeric: tabular-nums; font-family: ui-monospace, Menlo, Consolas, monospace; }
