:root {
  --bg: #0b0f14;
  --surface: #151d2b;
  --surface2: #1c2738;
  --border: #2a3850;
  --text: #eef2f8;
  --muted: #8fa3be;
  --accent: #4f8cff;
  --ok: #34d399;
  --warn: #fbbf24;
  --bad: #f87171;
  --radius: 12px;
  font-family: "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  display: grid;
  grid-template-columns: 300px 1fr;
  grid-template-rows: auto 1fr;
  min-height: 100vh;
}

.top {
  grid-column: 1 / -1;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  padding: 1.1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, var(--surface) 0%, var(--bg) 100%);
}
.top h1 { margin: 0; font-size: 1.4rem; font-weight: 650; }
.sub { margin: 0.3rem 0 0; color: var(--muted); font-size: 0.88rem; }
.stats { display: flex; gap: 0.65rem; flex-wrap: wrap; }
.stat {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.45rem 0.8rem;
  font-size: 0.82rem;
  color: var(--muted);
}
.stat strong { display: block; font-size: 1.15rem; color: var(--text); }

.filters {
  padding: 1rem 1.15rem;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  background: var(--surface);
  overflow-y: auto;
  max-height: calc(100vh - 4.5rem);
}
.filters-title {
  margin: 0;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  font-weight: 700;
}
.filter-group {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem 0.6rem 0.3rem;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  background: var(--surface2);
}
.filter-group legend {
  font-size: 0.7rem;
  color: var(--muted);
  padding: 0 0.2rem;
  font-weight: 600;
}
.filters label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.78rem;
  color: var(--muted);
}
.filters input[type="search"],
.filters select {
  padding: 0.45rem 0.6rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 0.88rem;
}
.check {
  flex-direction: row !important;
  align-items: center;
  gap: 0.45rem !important;
  color: var(--text) !important;
}
.btn {
  padding: 0.5rem 0.85rem;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  font-weight: 600;
  margin-top: 0.25rem;
}
.btn.secondary { background: var(--border); color: var(--text); }

main {
  padding: 0.75rem 1.25rem 2rem;
  overflow: auto;
}

.vistas {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 1rem;
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--bg);
  padding: 0.35rem 0 0.65rem;
  border-bottom: 1px solid var(--border);
}
.vista-btn {
  padding: 0.4rem 0.85rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}
.vista-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.lista { display: flex; flex-direction: column; gap: 1.5rem; }

.grupo-titulo {
  margin: 0 0 0.75rem;
  font-size: 0.95rem;
  font-weight: 650;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.grupo-n {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.1rem 0.5rem;
  font-size: 0.75rem;
  color: var(--text);
}

.grupo-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 0.65rem;
}

.grupo-header {
  margin-bottom: 0.65rem;
}
.grupo-desc {
  margin: 0.2rem 0 0;
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.4;
}

.card-compact {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.75rem 0.85rem;
  cursor: pointer;
  color: inherit;
  font: inherit;
  transition: border-color 0.15s, transform 0.12s, box-shadow 0.15s;
  min-height: 118px;
}
.card-compact:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
}
.card-compact:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.card-compact.card-incompleto {
  border-color: #92400e;
}

.cc-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.4rem;
  margin-bottom: 0.35rem;
}
.cc-nome {
  font-weight: 650;
  font-size: 0.92rem;
  word-break: break-word;
}
.cc-estado {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 0.12rem 0.38rem;
  border-radius: 4px;
  flex-shrink: 0;
}
.cc-estado-ok { background: #14532d; color: #86efac; }
.cc-estado-off { background: #1f2937; color: #9ca3af; }
.cc-estado-bad { background: #450a0a; color: #f87171; }

.cc-resumo {
  margin: 0 0 0.45rem;
  font-size: 0.8rem;
  line-height: 1.4;
  color: #cbd5e1;
  flex: 1;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.cc-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
  font-size: 0.68rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.cc-agenda {
  color: #fcd34d;
  text-transform: none;
  letter-spacing: 0;
}
.cc-codigo {
  color: #7dd3fc;
  text-transform: none;
  letter-spacing: 0;
  font-family: ui-monospace, monospace;
}

.bloco-codigo {
  margin: 0.85rem 0;
  padding: 0.75rem 0.85rem;
  background: #0f172a;
  border: 1px solid #1e3a5f;
  border-radius: 10px;
}
.bloco-codigo-titulo {
  margin: 0 0 0.5rem;
  font-size: 0.88rem;
  font-weight: 650;
  color: #93c5fd;
}
.bloco-codigo-sub {
  font-weight: 400;
  color: var(--muted);
  font-size: 0.75rem;
  margin-left: 0.35rem;
}
.codigo-linha {
  margin: 0.35rem 0;
  font-size: 0.82rem;
  word-break: break-all;
}
.codigo-linha code {
  display: block;
  margin-top: 0.2rem;
  padding: 0.35rem 0.5rem;
  background: var(--bg);
  border-radius: 6px;
  font-size: 0.78rem;
  color: #cbd5e1;
}

/* Modal detalhe */
body.modal-open { overflow: hidden; }
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 1.5rem;
  overflow-y: auto;
}
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(2px);
}
.modal-panel {
  position: relative;
  z-index: 1;
  width: min(720px, 100%);
  max-height: calc(100vh - 3rem);
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  padding: 1rem 1.15rem 0.5rem;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 2;
}
.modal-header h2 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 650;
}
.modal-close {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  width: 2rem;
  height: 2rem;
  border-radius: 8px;
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
}
.modal-close:hover { background: var(--border); }
.modal-body {
  padding: 1rem 1.15rem 1.25rem;
}
.modal-badges {
  margin-bottom: 0.85rem;
}
.modal-unit-name {
  margin: 1rem 0 0;
  font-size: 0.78rem;
  color: var(--muted);
  word-break: break-all;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.15rem 0.9rem;
}
.card-custom {
  border-color: #4c3d8f;
  box-shadow: 0 0 0 1px rgba(129, 140, 248, 0.12);
}

.card-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.6rem;
  margin-bottom: 0.65rem;
}
.card h2 {
  margin: 0;
  font-size: 1.02rem;
  font-weight: 650;
  word-break: break-word;
  flex: 1 1 200px;
}
.badges { display: flex; flex-wrap: wrap; gap: 0.35rem; }

.badge {
  font-size: 0.68rem;
  padding: 0.12rem 0.42rem;
  border-radius: 4px;
  text-transform: uppercase;
  font-weight: 700;
}
.badge-systemd { background: #1e3a5f; color: #93c5fd; }
.badge-cron { background: #3f2e14; color: #fcd34d; }
.badge-active { background: #14532d; color: #86efac; }
.badge-inactive { background: #3f1d1d; color: #fca5a5; }
.badge-bad { background: #450a0a; color: #f87171; }
.badge-enabled { background: #14532d; color: #86efac; }
.badge-disabled { background: #422006; color: #fdba74; }
.badge-custom { background: #312e81; color: #c4b5fd; }
.badge-readme { background: #134e4a; color: #5eead4; }
.badge-agent { background: #1e3a5f; color: #93c5fd; }
.badge-incompleto { background: #422006; color: #fdba74; }
.badge-desatualizado { background: #4a044e; color: #f0abfc; }
.badge-infra { background: #1f2937; color: #9ca3af; }
.badge-docker { background: #0c4a6e; color: #7dd3fc; }
.badge-exposicao { background: #365314; color: #bef264; }
.card-incompleto { border-color: #92400e; }
.fonte-doc { font-size: 0.78rem; opacity: 0.85; }

.alertas {
  margin: 0 0 1rem;
  padding: 0.75rem 1rem;
  background: #422006;
  border: 1px solid #92400e;
  border-radius: var(--radius);
  font-size: 0.88rem;
}
.alertas-titulo { margin: 0 0 0.35rem; font-weight: 650; color: #fdba74; }
.alertas ul { margin: 0; padding-left: 1.2rem; color: #fde68a; }

.link-logout {
  text-decoration: none;
  color: inherit;
  display: inline-flex;
  align-items: center;
}

.resumo {
  margin: 0 0 0.5rem;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.4;
  color: #c7d2fe;
}
.profunda {
  margin: 0;
  line-height: 1.6;
  font-size: 0.92rem;
  color: var(--text);
}
.bloco-desc {
  margin: 0 0 0.75rem;
}
.bloco-desc .mk {
  display: block;
  margin-bottom: 0.25rem;
}
.sem-descricao {
  margin: 0 0 0.65rem;
  padding: 0.55rem 0.7rem;
  background: #1e293b;
  border-radius: 8px;
  font-size: 0.85rem;
  color: var(--muted);
}
.sem-descricao code {
  font-size: 0.8rem;
  color: #93c5fd;
}
.nota-systemd {
  margin: 0 0 0.5rem;
  font-size: 0.85rem;
  color: var(--muted);
}
.mk {
  display: inline-block;
  min-width: 4.5rem;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-right: 0.35rem;
}

.pontos {
  margin: 0.35rem 0 0.75rem 1.1rem;
  padding: 0;
  color: #cbd5e1;
  font-size: 0.88rem;
  line-height: 1.45;
}
.pontos li { margin-bottom: 0.25rem; }

.meta-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.45rem 1rem;
  margin: 0.5rem 0 0.35rem;
  padding: 0.65rem 0.75rem;
  background: var(--surface2);
  border-radius: 8px;
  font-size: 0.84rem;
}
.meta-grid .span2 { grid-column: 1 / -1; word-break: break-all; }

.cmd-wrap {
  margin-top: 0.5rem;
  font-size: 0.8rem;
}
.cmd-wrap summary {
  cursor: pointer;
  color: var(--muted);
  user-select: none;
}
.cmd {
  margin-top: 0.35rem;
  padding: 0.55rem 0.7rem;
  background: var(--bg);
  border-radius: 6px;
  font-size: 0.76rem;
  overflow-x: auto;
  color: #94a3b8;
  white-space: pre-wrap;
  word-break: break-all;
}

.erro, .vazio {
  padding: 1rem;
  border-radius: var(--radius);
  text-align: center;
}
.erro { background: #3f1d1d; color: #fecaca; }
.vazio { color: var(--muted); }
.hidden { display: none !important; }

@media (max-width: 900px) {
  body { grid-template-columns: 1fr; }
  .filters { border-right: none; border-bottom: 1px solid var(--border); max-height: none; }
  .meta-grid { grid-template-columns: 1fr; }
  .grupo-cards { grid-template-columns: 1fr; }
  .modal { padding: 0.75rem; }
}
