:root {
  --brand: #0070e1;
  --brand-dark: #0059b3;
  --brand-light: #e6f1fc;
  --ink: #1a2230;
  --muted: #6b7684;
  --line: #e5e9f0;
  --bg: #f5f7fa;
  --white: #ffffff;
  --danger: #d92d20;
  --success: #12a150;
  --warning: #c98a00;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(16,24,40,.06), 0 1px 2px rgba(16,24,40,.04);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.5;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Layout com sidebar ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 248px;
  background: var(--white);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 20px 20px 16px;
  font-weight: 700; font-size: 18px;
  color: var(--brand);
  border-bottom: 1px solid var(--line);
}
.brand .logo {
  width: 30px; height: 30px; border-radius: 8px;
  background: var(--brand); color: #fff;
  display: grid; place-items: center; font-size: 16px;
}
.nav { padding: 12px 10px; flex: 1; overflow-y: auto; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 8px;
  color: var(--ink); font-weight: 500;
}
.nav a:hover { background: var(--brand-light); text-decoration: none; }
.nav a.active { background: var(--brand); color: #fff; }
.nav .group { padding: 14px 12px 6px; font-size: 11px; text-transform: uppercase;
  letter-spacing: .06em; color: var(--muted); }
.sidebar .foot { padding: 14px 16px; border-top: 1px solid var(--line); font-size: 13px; color: var(--muted); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 60px; background: var(--white); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; position: sticky; top: 0; z-index: 5;
}
.topbar h1 { font-size: 18px; margin: 0; }
.content { padding: 24px; }

/* ---------- Cartões / KPIs ---------- */
.grid { display: grid; gap: 16px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 900px) { .grid-4 { grid-template-columns: repeat(2, 1fr); } .grid-2 { grid-template-columns: 1fr; } }
@media (max-width: 560px) { .grid-4 { grid-template-columns: 1fr; } }

.card {
  background: var(--white); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px;
}
.stat .label { color: var(--muted); font-size: 13px; }
.stat .value { font-size: 30px; font-weight: 700; margin-top: 6px; }
.stat .value.brand { color: var(--brand); }
.stat .value.danger { color: var(--danger); }
.stat .value.warning { color: var(--warning); }

/* ---------- Tabelas ---------- */
table.tbl { width: 100%; border-collapse: collapse; background: var(--white); }
.tbl th, .tbl td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--line); }
.tbl th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.tbl tr:hover td { background: #fafbfd; }

/* ---------- Botões ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 16px; border-radius: 8px; border: 1px solid transparent;
  font-weight: 600; font-size: 14px; cursor: pointer; background: var(--brand); color: #fff;
}
.btn:hover { background: var(--brand-dark); text-decoration: none; }
.btn.ghost { background: var(--white); color: var(--brand); border-color: var(--line); }
.btn.ghost:hover { background: var(--brand-light); }

/* ---------- Formulários ---------- */
.field { margin-bottom: 16px; }
.field label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 6px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line);
  border-radius: 8px; font-size: 15px; font-family: inherit; background: #fff;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-light);
}

/* ---------- Alertas / flash ---------- */
.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 14px; font-size: 14px; }
.alert.success { background: #e7f7ee; color: #0a6b37; }
.alert.danger  { background: #fdecea; color: #9a1c13; }
.alert.info    { background: var(--brand-light); color: var(--brand-dark); }

.badge { display: inline-block; padding: 3px 9px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.badge.ok { background: #e7f7ee; color: #0a6b37; }
.badge.warn { background: #fef4e5; color: #94620a; }

/* ---------- Tela de login ---------- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-dark) 100%); padding: 20px; }
.auth-card { background: #fff; width: 100%; max-width: 400px; border-radius: 16px;
  padding: 34px 30px; box-shadow: 0 20px 50px rgba(0,0,0,.18); }
.auth-card .logo-row { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.auth-card .logo-row .logo { width: 38px; height: 38px; border-radius: 10px; background: var(--brand);
  color: #fff; display: grid; place-items: center; font-size: 20px; font-weight: 700; }
.auth-card h1 { font-size: 20px; margin: 0; }
.auth-card p.sub { color: var(--muted); margin: 2px 0 22px; font-size: 14px; }
.auth-card .btn { width: 100%; justify-content: center; margin-top: 4px; }
