/* ===== Reset / base ===== */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  font-size: 14px;
  color: #1a1a1a;
  background: #f4f6f9;
  display: grid;
  grid-template-columns: 240px 1fr;
  grid-template-rows: 56px 1fr;
  grid-template-areas: "sidebar topbar" "sidebar content";
  min-height: 100vh;
}

/* ===== Sidebar ===== */
#sidebar {
  grid-area: sidebar;
  background: #1f2937;
  color: #d1d5db;
  padding: 16px 12px;
  overflow-y: auto;
}
.brand { display: flex; gap: 10px; align-items: center; padding: 0 4px 16px; border-bottom: 1px solid #374151; margin-bottom: 12px; }
.brand .logo { font-size: 28px; }
.brand .title { color: #fff; font-weight: 700; font-size: 16px; }
.brand .subtitle { font-size: 11px; color: #9ca3af; }

#sidebar nav { display: flex; flex-direction: column; gap: 2px; }
#sidebar nav a {
  color: #d1d5db; text-decoration: none; padding: 10px 12px; border-radius: 6px; font-size: 13px;
}
#sidebar nav a:hover { background: #374151; color: #fff; }
#sidebar nav a.on { background: #3b82f6; color: #fff; }

.filters {
  border-top: 1px solid #374151;
  margin-top: 16px; padding-top: 16px;
}
.filters h4 { margin: 0 0 8px; color: #9ca3af; font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; }
.filters label { display: block; font-size: 12px; color: #9ca3af; margin-bottom: 8px; }
.filters input, .filters select, .filters button {
  width: 100%; padding: 6px 8px; margin-top: 2px;
  background: #111827; color: #f9fafb;
  border: 1px solid #374151; border-radius: 4px; font-size: 13px;
}
.filters small { color: #6b7280; font-size: 11px; }
.filters button {
  margin-top: 8px; cursor: pointer; background: #3b82f6; border-color: #3b82f6; color: #fff; font-weight: 600;
}
.filters button:hover { background: #2563eb; }

/* ===== Topbar ===== */
#topbar {
  grid-area: topbar;
  background: #fff; border-bottom: 1px solid #e5e7eb;
  display: flex; justify-content: space-between; align-items: center;
  padding: 0 24px;
}
.page-title { font-size: 18px; font-weight: 600; }
.user-box { display: flex; gap: 12px; align-items: center; font-size: 13px; }
.user-name { font-weight: 600; }
.user-perfil { color: #6b7280; font-size: 11px; padding: 2px 8px; background: #f3f4f6; border-radius: 999px; }
.user-box a { color: #ef4444; text-decoration: none; font-weight: 500; }

/* ===== Content ===== */
#content { grid-area: content; padding: 20px; overflow-y: auto; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 20px; }
.kpi { background: #fff; padding: 14px 18px; border-radius: 8px; border: 1px solid #e5e7eb; }
.kpi .lbl { color: #6b7280; font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; }
.kpi .val { font-size: 22px; font-weight: 700; margin-top: 4px; color: #111827; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
@media (max-width: 1100px) { .grid-2 { grid-template-columns: 1fr; } }

.card { background: #fff; border: 1px solid #e5e7eb; border-radius: 8px; padding: 16px; margin-bottom: 16px; }
.card h3 { margin: 0 0 12px; font-size: 15px; }

.chart { height: 320px; }
.chart.big { height: 480px; }

.row-between { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
table th, table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid #e5e7eb; }
table th { background: #f9fafb; font-weight: 600; color: #4b5563; }
table tbody tr:hover { background: #f9fafb; }

.muted { color: #6b7280; }
.erro { color: #b91c1c; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px; }
.form-grid label { font-size: 13px; color: #4b5563; }
.form-grid input, .form-grid select { width: 100%; padding: 8px; border: 1px solid #d1d5db; border-radius: 4px; font-size: 14px; margin-top: 4px; }
button { padding: 8px 16px; background: #3b82f6; color: #fff; border: 0; border-radius: 4px; cursor: pointer; font-size: 13px; }
button:hover { background: #2563eb; }

/* ===== Login ===== */
body.login-page { display: flex; align-items: center; justify-content: center; background: #1f2937; }
#login {
  background: #fff; padding: 32px; border-radius: 12px; width: 380px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.4);
}
#login h1 { margin: 0 0 8px; font-size: 22px; }
#login label { display: block; margin-bottom: 12px; font-size: 13px; color: #4b5563; }
#login input { width: 100%; padding: 10px; border: 1px solid #d1d5db; border-radius: 4px; font-size: 14px; margin-top: 4px; }
#login button { width: 100%; padding: 12px; margin-top: 8px; font-weight: 600; }
