:root {
  --bg: #f5f7fb;
  --bg-card: #ffffff;
  --border: #e1e4f0;
  --text: #1f2933;
  --muted: #6b7280;
  --primary: #16a34a;
  --warning: #f97316;
  --danger: #ef4444;
  --radius-lg: 14px;
  --shadow-soft: 0 10px 25px rgba(15, 23, 42, 0.08);
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  background-color: --bg;
  background: var(--bg);
  color: var(--text);
}

/* Topbar */

.topbar {
  padding: 1.5rem 2rem;
  background: #0f172a;
  color: #f9fafb;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}

.topbar h1 {
  margin: 0;
  font-size: 1.5rem;
}

.subtitle {
  margin: 0.35rem 0 0;
  font-size: 0.9rem;
  color: #cbd5f5;
}

.last-update span {
  display: block;
  font-size: 0.78rem;
  color: #cbd5f5;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.last-update strong {
  font-size: 0.95rem;
}

/* Layout principal */

.container {
  max-width: 1200px;
  margin: 1.5rem auto 2rem;
  padding: 0 1rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* Cards genéricos */

.card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 1.1rem 1.3rem;
  box-shadow: var(--shadow-soft);
  border: 1px solid var(--border);
}

.card h2 {
  margin: 0 0 0.75rem;
  font-size: 1rem;
}

.card-header-inline {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

/* Filtros */

.filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.filter-group label {
  font-size: 0.8rem;
  color: var(--muted);
}

.filter-group input,
.filter-group select {
  padding: 0.5rem 0.6rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #fff;
  font-size: 0.9rem;
  outline: none;
}

.filter-group input:focus,
.filter-group select:focus {
  border-color: var(--primary);
}

/* KPIs */

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 1rem;
}

.kpi-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 1rem 1.2rem;
  box-shadow: var(--shadow-soft);
  border: 1px solid var(--border);
}

.kpi-label {
  font-size: 0.8rem;
  color: var(--muted);
}

.kpi-value {
  display: block;
  font-size: 1.6rem;
  font-weight: 600;
  margin-top: 0.25rem;
}

.kpi-extra {
  font-size: 0.8rem;
  color: var(--muted);
}

.kpi-warning {
  border-left: 4px solid var(--warning);
}

/* Gráficos */

.charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
  gap: 1rem;
}

.chart-container {
  max-width: 100%;
}

#statusChart,
#historyChart {
  max-height: 320px;
}

/* Tabela */

.table-wrapper {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

thead {
  position: sticky;
  top: 0;
  background: #f1f5f9;
  z-index: 1;
}

th,
td {
  border-bottom: 1px solid #e5e7eb;
  padding: 0.55rem 0.7rem;
  text-align: left;
}

th {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

/* Cores antigas de alerta reaproveitadas */

tr:nth-child(even) {
  background-color: #f9fafb;
}

.alerta-critico {
  background-color: #ffebee;
  color: #c62828;
}

.alerta-medio {
  background-color: #fffde7;
  color: #f57f17;
}

.alerta-ok {
  background-color: #e8f5e9;
}

/* Link de print */

.link-print {
  color: #2563eb;
  text-decoration: none;
  font-weight: 500;
  cursor: pointer;
}

.link-print:hover {
  text-decoration: underline;
}

/* Badges de status */

.badge-status {
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 500;
}

.badge-ok {
  background: rgba(34, 197, 94, 0.1);
  color: #16a34a;
}

.badge-alerta {
  background: rgba(249, 115, 22, 0.1);
  color: #ea580c;
}

.badge-erro {
  background: rgba(239, 68, 68, 0.1);
  color: #b91c1c;
}

/* Modal de print */

.modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 50;
}

.modal.open {
  display: block;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
}

.modal-content {
  position: relative;
  max-width: 900px;
  max-height: 90vh;
  margin: 4vh auto;
  background: #0b1120;
  border-radius: 18px;
  padding: 0.75rem;
  box-shadow: var(--shadow-soft);
}

.modal img {
  display: block;
  max-width: 100%;
  max-height: 80vh;
  margin: 0 auto;
}

.modal-close {
  position: absolute;
  top: 0.4rem;
  right: 0.7rem;
  border: none;
  background: none;
  color: #e5e7eb;
  font-size: 1.7rem;
  cursor: pointer;
}

/* Rodapé */

.footer {
  text-align: center;
  font-size: 0.8rem;
  color: var(--muted);
  padding: 1.2rem 0 1.6rem;
}

/* Responsivo */

@media (max-width: 768px) {
  .topbar {
    flex-direction: column;
  }

  .card-header-inline {
    flex-direction: column;
    align-items: flex-start;
  }
}
