:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #f8f9fc;
  --border: #e6e8f0;
  --text: #1a1d29;
  --text-muted: #6b7280;
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --success: #16a34a;
  --success-bg: #dcfce7;
  --warning: #d97706;
  --warning-bg: #fef3c7;
  --danger: #dc2626;
  --danger-bg: #fee2e2;
  --info: #2563eb;
  --info-bg: #dbeafe;
  --muted-bg: #eef0f4;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(16,24,40,.06), 0 1px 2px rgba(16,24,40,.04);
  --shadow-md: 0 4px 12px rgba(16,24,40,.08);
}

[data-theme="dark"] {
  --bg: #0f1117;
  --surface: #171a24;
  --surface-2: #1d2130;
  --border: #2a2f3f;
  --text: #e9eaf0;
  --text-muted: #9096a8;
  --muted-bg: #232838;
  --shadow: 0 1px 3px rgba(0,0,0,.4);
  --shadow-md: 0 4px 16px rgba(0,0,0,.45);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  transition: background .2s ease, color .2s ease;
}

a { color: inherit; text-decoration: none; }

.app-shell { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 20px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 16px;
  padding: 6px 10px 22px;
}
.sidebar-brand .logo {
  width: 34px; height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--primary), #818cf8);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 800;
}
.nav-group { margin-bottom: 14px; }
.nav-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  padding: 8px 10px 4px;
}
.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px;
  border-radius: 10px;
  color: var(--text-muted);
  font-weight: 500;
  margin-bottom: 2px;
}
.nav-link:hover { background: var(--muted-bg); color: var(--text); }
.nav-link.active { background: var(--primary); color: #fff; }
.nav-link .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .5; }

/* Main */
.main { flex: 1; min-width: 0; }
.topbar {
  height: 64px;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.search-box {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 12px;
  width: 340px;
  color: var(--text-muted);
}
.search-box input {
  border: none; background: transparent; outline: none;
  color: var(--text); width: 100%; font-size: 13px;
}
.topbar-actions { display: flex; align-items: center; gap: 14px; }
.icon-btn {
  width: 36px; height: 36px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface-2);
  border: 1px solid var(--border);
  cursor: pointer;
  color: var(--text);
}
.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px;
}
.content { padding: 24px; }

.page-title { font-size: 20px; font-weight: 700; margin: 0 0 2px; }
.page-subtitle { color: var(--text-muted); margin: 0 0 20px; font-size: 13px; }

/* KPI cards */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}
.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
}
.kpi-label { font-size: 12px; color: var(--text-muted); margin-bottom: 6px; }
.kpi-value { font-size: 22px; font-weight: 700; }
.kpi-sub { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

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

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}
.card-title { font-weight: 600; margin: 0 0 14px; font-size: 14px; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; color: var(--text-muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--border); font-size: 11px; text-transform: uppercase; letter-spacing: .04em; }
td { padding: 10px; border-bottom: 1px solid var(--border); }
tr:last-child td { border-bottom: none; }

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: 999px;
  font-size: 11px; font-weight: 600;
}
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-info { background: var(--info-bg); color: var(--info); }
.badge-muted { background: var(--muted-bg); color: var(--text-muted); }

.notif-item { display: flex; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.notif-item:last-child { border-bottom: none; }
.notif-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--primary); margin-top: 5px; flex-shrink: 0; }
.notif-text { font-size: 13px; }
.notif-time { font-size: 11px; color: var(--text-muted); }

/* Login */
.guest-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at top left, #4f46e5 0, #0f1117 55%);
}
.login-card {
  width: 380px; background: var(--surface);
  border-radius: 18px; padding: 32px;
  box-shadow: 0 20px 60px rgba(0,0,0,.35);
}
.login-logo {
  width: 48px; height: 48px; border-radius: 14px;
  background: linear-gradient(135deg, var(--primary), #818cf8);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 18px; margin-bottom: 14px;
}
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; font-weight: 600; margin-bottom: 6px; color: var(--text-muted); }
.field input {
  width: 100%; padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
  font-size: 14px; outline: none;
}
.field input:focus { border-color: var(--primary); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 16px; border-radius: 10px; border: none;
  font-weight: 600; font-size: 14px; cursor: pointer;
}
.btn-primary { background: var(--primary); color: #fff; width: 100%; }
.btn-primary:hover { background: var(--primary-hover); }
.alert { padding: 10px 12px; border-radius: 10px; font-size: 13px; margin-bottom: 14px; }
.alert-error { background: var(--danger-bg); color: var(--danger); }

/* Exportação de relatórios para PDF via impressão do navegador */
@media print {
  .sidebar, .topbar, .no-print { display: none !important; }
  .main { margin: 0 !important; }
  .content { padding: 0 !important; }
  body { background: #fff !important; color: #000 !important; }
  .card { box-shadow: none !important; border: 1px solid #ddd !important; }
}
