:root {
  --bg: #0b1020;
  --bg-2: #111733;
  --panel: #151c3a;
  --panel-2: #1a2247;
  --line: #232c55;
  --text: #e6e9f5;
  --muted: #8a93b8;
  --primary: #6366f1;
  --primary-2: #22d3ee;
  --ok: #22c55e;
  --warn: #f59e0b;
  --err: #ef4444;
  --v4: #22d3ee;
  --v6: #a78bfa;
  --shadow: 0 8px 30px rgba(0,0,0,0.35);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(99,102,241,0.18), transparent 60%),
    radial-gradient(1000px 500px at 110% 10%, rgba(34,211,238,0.12), transparent 60%),
    var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.45;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }

/* ======================= LOGIN ======================= */
.login-body {
  display: grid;
  place-items: center;
  min-height: 100vh;
}
.login-card {
  width: 100%;
  max-width: 420px;
  margin: 24px;
  padding: 32px 28px;
  background: linear-gradient(180deg, var(--panel) 0%, var(--panel-2) 100%);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
}
.login-card .brand { text-align: center; margin-bottom: 22px; }
.login-card h1 { margin: 8px 0 4px; font-size: 22px; }
.login-card p { margin: 0; color: var(--muted); font-size: 13px; }
.brand-logo { display: inline-flex; align-items: center; justify-content: center;
  width: 64px; height: 64px; border-radius: 16px;
  background: rgba(99,102,241,0.12); border: 1px solid var(--line);
}
.login-card form { display: grid; gap: 14px; }
.login-card label { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
.login-card input { background: #0f1530; border: 1px solid var(--line); color: var(--text);
  padding: 11px 12px; border-radius: 10px; outline: none; font-size: 14px;
}
.login-card input:focus { border-color: var(--primary); }
.login-card footer { margin-top: 14px; text-align: center; color: var(--muted); font-size: 12px; }

.error {
  background: rgba(239,68,68,0.12);
  border: 1px solid rgba(239,68,68,0.45);
  color: #fecaca; padding: 8px 10px; border-radius: 8px; font-size: 13px;
}

/* ======================= BUTTONS ======================= */
.btn {
  padding: 10px 14px; border-radius: 10px; border: 1px solid transparent;
  cursor: pointer; font-weight: 600; font-size: 13px;
  transition: all .15s ease;
}
.btn-primary {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-2) 100%);
  color: white;
  box-shadow: 0 4px 16px rgba(99,102,241,0.35);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(99,102,241,0.45); }
.btn-ghost {
  background: transparent; color: var(--text); border-color: var(--line);
}
.btn-ghost:hover { background: rgba(255,255,255,0.05); }

/* ======================= TOPBAR ======================= */
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 24px; background: rgba(15,21,48,0.85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.brand-inline { display: flex; align-items: center; gap: 12px; }
.brand-inline strong { display: block; }
.brand-inline span { font-size: 12px; }
.topbar-right { display: flex; align-items: center; gap: 14px; }

.pill {
  font-size: 12px; padding: 5px 10px; border-radius: 999px;
  border: 1px solid var(--line); background: rgba(255,255,255,0.04);
}
.pill-ok { color: var(--ok); border-color: rgba(34,197,94,0.4); background: rgba(34,197,94,0.08);}
.pill-warn { color: var(--warn); border-color: rgba(245,158,11,0.4); background: rgba(245,158,11,0.08);}
.pill-err { color: var(--err); border-color: rgba(239,68,68,0.4); background: rgba(239,68,68,0.08);}

/* ======================= TABS ======================= */
.tabs {
  display: flex; gap: 4px; padding: 12px 24px 0;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
}
.tab {
  background: transparent; border: none; color: var(--muted);
  padding: 10px 14px; cursor: pointer; font-size: 13px; font-weight: 600;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--primary-2); }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ======================= LAYOUT ======================= */
.main { padding: 20px 24px 80px; }
.grid { display: grid; gap: 16px; margin-bottom: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid.sub { margin-bottom: 12px; }

@media (max-width: 980px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
}

/* ======================= CARDS ======================= */
.card {
  background: linear-gradient(180deg, var(--panel) 0%, var(--panel-2) 100%);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px 18px;
  box-shadow: var(--shadow);
}
.card-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 12px; gap: 8px;
}
.card-head h2 { margin: 0; font-size: 14px; font-weight: 600; letter-spacing: 0.2px; }
.card-head .legend { color: var(--muted); font-size: 12px; display: flex; gap: 12px; align-items: center; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.dot-v4 { background: var(--v4); }
.dot-v6 { background: var(--v6); }

/* ======================= KPI ======================= */
.kpi { display: flex; flex-direction: column; }
.kpi-label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.6px; }
.kpi-value { font-size: 30px; font-weight: 700; margin: 6px 0 2px; }
.kpi-value.tiny { font-size: 14px; font-weight: 600; word-break: break-all; }
.kpi-sub { color: var(--muted); font-size: 12px; min-height: 1.3em; }

.bar {
  margin-top: 10px;
  height: 6px; background: rgba(255,255,255,0.06);
  border-radius: 999px; overflow: hidden;
}
.bar > div {
  height: 100%; width: 0;
  background: linear-gradient(90deg, var(--primary-2), var(--primary));
  transition: width .4s ease, background .3s ease;
}
.bar > .bar-v4 { background: linear-gradient(90deg, #22d3ee, #06b6d4); }
.bar > .bar-v6 { background: linear-gradient(90deg, #a78bfa, #6366f1); }

.metric { display: flex; flex-direction: column; gap: 4px; }
.metric span { color: var(--muted); font-size: 12px; }
.metric strong { font-size: 18px; font-weight: 700; }

/* ======================= TABLES ======================= */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
.table th, .table td {
  text-align: left; padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}
.table th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.6px; }
.table tbody tr:hover { background: rgba(255,255,255,0.03); }

.badge {
  display: inline-block; padding: 3px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 700; letter-spacing: 0.4px;
}
.badge-ok { background: rgba(34,197,94,0.18); color: #86efac; }
.badge-warn { background: rgba(245,158,11,0.18); color: #fcd34d; }
.badge-err { background: rgba(239,68,68,0.18); color: #fca5a5; }
.badge-v4 { background: rgba(34,211,238,0.18); color: #67e8f9; }
.badge-v6 { background: rgba(167,139,250,0.18); color: #c4b5fd; }

/* ======================= TOOLS ======================= */
.form-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.form-row input, .form-row select {
  background: #0f1530; border: 1px solid var(--line); color: var(--text);
  padding: 9px 11px; border-radius: 10px; outline: none; font-size: 13px;
  flex: 1; min-width: 160px;
}
.form-row input:focus, .form-row select:focus { border-color: var(--primary); }
.output {
  background: #0a0f24; border: 1px solid var(--line); border-radius: 10px;
  padding: 12px; margin: 0; max-height: 380px; overflow: auto;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 12px; color: #cbd5ff; white-space: pre-wrap; word-break: break-word;
}

/* ======================= BOTTOM ======================= */
.bottombar {
  position: fixed; bottom: 0; left: 0; right: 0;
  display: flex; justify-content: space-between;
  padding: 8px 24px; font-size: 12px; color: var(--muted);
  background: rgba(11,16,32,0.7); border-top: 1px solid var(--line);
  backdrop-filter: blur(10px);
}

/* ======================= LINK STATUS DASHBOARD ======================= */
.link-status {
  border: 1px solid var(--line);
  background:
    radial-gradient(800px 200px at -10% -50%, rgba(99,102,241,0.18), transparent 60%),
    radial-gradient(600px 200px at 110% 110%, rgba(34,211,238,0.12), transparent 60%),
    linear-gradient(180deg, var(--panel) 0%, var(--panel-2) 100%);
}
.status-card {
  padding: 14px;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.status-label { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.6px; }
.status-value { font-size: 28px; font-weight: 800; margin: 6px 0 4px; }
.status-sub { color: var(--muted); font-size: 12px; min-height: 1.4em; }

.mini-h { font-size: 12px; margin: 0 0 8px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.6px; }
.egress-list, .asym-list {
  margin: 0; padding-left: 18px;
  display: grid; gap: 4px;
  font-size: 13px;
}
.egress-list code, .asym-list code { background: rgba(255,255,255,0.06); }

.filter-pills { display: flex; gap: 4px; flex-wrap: wrap; }
.pill-btn {
  font-size: 12px; padding: 5px 10px; border-radius: 999px;
  background: transparent; color: var(--muted); border: 1px solid var(--line);
  cursor: pointer;
}
.pill-btn:hover { color: var(--text); }
.pill-btn.active { color: white; background: var(--primary); border-color: var(--primary); }

/* ===== Recomendações ===== */
.reco-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; max-height: 320px; overflow-y: auto; }
.reco-list li {
  padding: 8px 12px; border-radius: 8px;
  border: 1px solid var(--line); background: rgba(255,255,255,0.02);
  display: flex; gap: 10px; align-items: flex-start;
}
.reco-list .sev {
  font-size: 10px; font-weight: 800; padding: 3px 7px;
  border-radius: 999px; text-transform: uppercase; letter-spacing: 0.6px;
  flex-shrink: 0;
}
.reco-list .sev-error { background: rgba(239,68,68,0.18); color: #fca5a5; }
.reco-list .sev-warn { background: rgba(245,158,11,0.18); color: #fcd34d; }
.reco-list .sev-info { background: rgba(34,211,238,0.18); color: #67e8f9; }
.reco-list .reco-title { font-weight: 600; }
.reco-list .reco-detail { color: var(--muted); font-size: 12px; }

/* ===== Modal ===== */
.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5);
  display: grid; place-items: center; z-index: 100; padding: 24px;
}
.modal-card {
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 14px; padding: 22px 24px; min-width: 360px; max-width: 480px; width: 100%;
  box-shadow: var(--shadow);
}
.modal-card h3 { margin: 0 0 14px; }
.modal-card form { display: grid; gap: 12px; }
.modal-card label { display: grid; gap: 4px; font-size: 12px; color: var(--muted); }
.modal-card input, .modal-card select {
  background: #0f1530; border: 1px solid var(--line); color: var(--text);
  padding: 9px 11px; border-radius: 8px; outline: none; font-size: 13px;
}
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; }

code {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 12px;
  background: rgba(255,255,255,0.05);
  padding: 1px 6px;
  border-radius: 4px;
}
a { color: var(--primary-2); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ======================= GRADE COLORS ======================= */
.grade-excelente { color: var(--ok); }
.grade-bom { color: #4ade80; }
.grade-regular { color: var(--warn); }
.grade-ruim { color: #fb923c; }
.grade-crítico { color: var(--err); }
