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

:root {
  --bg: #ffffff;
  --bg-card: #f5f5f4;
  --border: #e5e5e5;
  --text: #1a1a1a;
  --text-muted: #6b7280;
  --accent: #3b82f6;
  --accent-light: #eff6ff;
  --crise: #E24B4A;
  --crise-bg: #fef2f2;
  --sys: #f97316;
  --dia: #3b82f6;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Layout */
.page { max-width: 900px; margin: 0 auto; padding: 24px 16px 48px; }

/* Nav */
nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 10;
}
.nav-brand { font-weight: 700; font-size: 16px; color: var(--text); text-decoration: none; }
.nav-links { display: flex; gap: 20px; align-items: center; }
.nav-links a { color: var(--text-muted); font-size: 14px; }
.nav-links a:hover, .nav-links a.active { color: var(--accent); text-decoration: none; }
.nav-logout { background: none; border: none; cursor: pointer; color: var(--text-muted); font-size: 14px; }
.nav-logout:hover { color: var(--crise); }

/* Headings */
h1 { font-size: 22px; font-weight: 700; margin-bottom: 20px; }
h2 { font-size: 16px; font-weight: 600; margin-bottom: 12px; }

/* Alert */
.alerta-crise {
  background: var(--crise-bg);
  border: 1px solid var(--crise);
  border-radius: var(--radius);
  padding: 14px 18px;
  color: var(--crise);
  font-weight: 600;
  margin-bottom: 20px;
  display: none;
}
.alerta-crise.visivel { display: block; }

/* Period filter */
.filtros {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
}
.btn-filtro {
  padding: 6px 16px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--bg);
  cursor: pointer;
  font-size: 13px;
  color: var(--text-muted);
  transition: all 0.15s;
}
.btn-filtro:hover { border-color: var(--accent); color: var(--accent); }
.btn-filtro.ativo {
  background: var(--accent-light);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}

/* Cards */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 28px;
}
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  box-shadow: var(--shadow);
}
.card-label { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 6px; }
.card-valor { font-size: 28px; font-weight: 700; }
.card-unidade { font-size: 13px; color: var(--text-muted); margin-left: 3px; }

/* Chart */
.chart-wrap {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 28px;
  position: relative;
  height: 280px;
}

/* Table */
.table-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
thead th {
  text-align: left;
  padding: 10px 12px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--bg-card); }
tbody tr.crise td { color: var(--crise); }
.sem-dados { text-align: center; padding: 32px; color: var(--text-muted); }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: opacity 0.15s;
}
.btn:hover { opacity: 0.85; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-secondary { background: var(--bg-card); border: 1px solid var(--border); color: var(--text); }
.btn-danger { background: var(--crise); color: #fff; }

/* Form */
.form-group { margin-bottom: 16px; }
label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 6px; color: var(--text-muted); }
input[type=text], input[type=number], input[type=date], input[type=time],
input[type=password], select, textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
  transition: border-color 0.15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
}
textarea { resize: vertical; min-height: 80px; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 500px) { .form-row { grid-template-columns: 1fr; } }

/* Actions row */
.actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

/* Login */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-card);
}
.login-box {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 36px 40px;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow);
}
.login-box h1 { font-size: 20px; margin-bottom: 24px; }
.login-erro {
  color: var(--crise);
  font-size: 13px;
  margin-bottom: 14px;
  display: none;
}
.login-erro.visivel { display: block; }

/* Mensagens */
.msg-sucesso {
  background: #f0fdf4;
  border: 1px solid #86efac;
  color: #16a34a;
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 14px;
  margin-bottom: 16px;
  display: none;
}
.msg-sucesso.visivel { display: block; }

/* Resumo topo (relatório) */
.resumo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin-bottom: 24px;
}
.resumo-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
}
.resumo-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.resumo-valor { font-size: 22px; font-weight: 700; }
