:root {
  --primary: #0a2777;
  --primary-light: #1a3a99;
  --sidebar-bg: #0d1b3d;
  --sidebar-bg-2: #0a2777;
  --bg: #f1f3f9;
  --card: #ffffff;
  --border: #e2e6ef;
  --text: #1f2430;
  --muted: #6b7280;
  --success: #16a34a;
  --warning: #b45309;
  --danger: #dc2626;
  --sidebar-width: 248px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.login-logo { display: block; margin: 0 auto 1.5rem; max-width: 220px; height: auto; }

/* ===== Layout com sidebar ===== */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--sidebar-bg), var(--sidebar-bg-2));
  color: #fff;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 1.35rem 1.25rem;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sidebar-brand img { height: 30px; width: auto; }
.sidebar-brand span { font-weight: 700; font-size: 1.02rem; letter-spacing: 0.01em; }

.sidebar-nav { flex: 1; padding: 1rem 0.75rem; display: flex; flex-direction: column; gap: 0.2rem; overflow-y: auto; }
.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.85rem;
  border-radius: 0.6rem;
  color: rgba(255,255,255,0.72);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
}
.sidebar-nav a svg { width: 18px; height: 18px; flex-shrink: 0; opacity: 0.85; }
.sidebar-nav a:hover { background: rgba(255,255,255,0.08); color: #fff; }
.sidebar-nav a.active { background: rgba(255,255,255,0.14); color: #fff; }
.sidebar-nav a.active svg { opacity: 1; }
.sidebar-nav .nav-section-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: rgba(255,255,255,0.4);
  padding: 0.9rem 0.85rem 0.3rem;
  font-weight: 700;
}

.sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid rgba(255,255,255,0.08);
  display: flex;
  align-items: center;
  gap: 0.65rem;
}
.sidebar-footer .avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: rgba(255,255,255,0.15);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.85rem; flex-shrink: 0;
}
.sidebar-footer .who { flex: 1; min-width: 0; }
.sidebar-footer .who .name { font-size: 0.82rem; font-weight: 600; color: #fff; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-footer .who .role { font-size: 0.7rem; color: rgba(255,255,255,0.55); }
.sidebar-footer a.logout {
  color: rgba(255,255,255,0.6);
  display: flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 0.5rem;
  flex-shrink: 0;
}
.sidebar-footer a.logout:hover { background: rgba(255,255,255,0.1); color: #fff; }
.sidebar-footer a.logout svg { width: 17px; height: 17px; }

.main-area { flex: 1; min-width: 0; }

.container { max-width: 1180px; margin: 0 auto; padding: 1.75rem 2rem; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 0.9rem;
  padding: 1.25rem;
  margin-bottom: 1rem;
  box-shadow: 0 1px 2px rgba(16,24,64,0.04);
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 0.9rem;
  padding: 1.1rem 1.25rem;
  box-shadow: 0 1px 2px rgba(16,24,64,0.04);
  display: flex;
  align-items: center;
  gap: 0.9rem;
}
.stat-card .icon {
  width: 42px; height: 42px; border-radius: 0.7rem;
  background: rgba(10,39,119,0.08);
  color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.stat-card .icon svg { width: 20px; height: 20px; }
.stat-card .num { font-size: 1.65rem; font-weight: 700; color: var(--text); line-height: 1.1; }
.stat-card .label { font-size: 0.78rem; color: var(--muted); margin-top: 0.15rem; }

table.grid {
  width: 100%;
  border-collapse: collapse;
  background: var(--card);
  border-radius: 0.75rem;
  overflow: hidden;
}
table.grid th, table.grid td {
  padding: 0.7rem 0.9rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 0.875rem;
}
table.grid th { background: #f8f9fc; color: var(--muted); font-weight: 600; }
table.grid tr:last-child td { border-bottom: none; }
table.grid tr:hover td { background: #fafbfd; }

.badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}
.badge-aguardando { background: #fef3c7; color: var(--warning); }
.badge-atendimento { background: #dbeafe; color: #1d4ed8; }
.badge-pendente { background: #fee2e2; color: var(--danger); }
.badge-agendado { background: #e0e7ff; color: #4338ca; }
.badge-solicitado { background: #ede9fe; color: #6d28d9; }
.badge-deferido { background: #dcfce7; color: var(--success); }
.badge-pago { background: #dcfce7; color: var(--success); }
.badge-indeferido { background: #f3f4f6; color: var(--muted); }

.btn {
  display: inline-block;
  padding: 0.5rem 1rem;
  border-radius: 0.5rem;
  border: none;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-light); }
.btn-outline { background: transparent; color: var(--primary); border: 1.5px solid var(--primary); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: 0.3rem 0.7rem; font-size: 0.78rem; }

.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-size: 0.85rem; font-weight: 600; margin-bottom: 0.3rem; color: var(--text); }
.form-control {
  width: 100%;
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  font-size: 0.9rem;
}
.form-control:focus { outline: none; border-color: var(--primary); }

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, var(--primary-light), var(--primary));
}
.login-box {
  background: #fff;
  border-radius: 1rem;
  padding: 2.5rem;
  width: 100%;
  max-width: 360px;
  box-shadow: 0 20px 40px rgba(10,39,119,0.25);
}
.login-box h1 { text-align: center; font-size: 1.4rem; color: var(--primary); margin-bottom: 1.5rem; }

.flash-message {
  padding: 0.75rem 1rem;
  border-radius: 0.5rem;
  margin-bottom: 1rem;
  font-size: 0.875rem;
}
.flash-message.success { background: #dcfce7; color: var(--success); }
.flash-message.error { background: #fee2e2; color: var(--danger); }

.section-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin: 1.5rem 0 0.75rem;
  color: var(--text);
}

.meta-row { display: flex; gap: 2rem; flex-wrap: wrap; margin-bottom: 1rem; }
.meta-row div span.k { display: block; font-size: 0.75rem; color: var(--muted); }
.meta-row div span.v { font-size: 0.95rem; font-weight: 600; }

.empty-state { text-align: center; padding: 3rem 1rem; color: var(--muted); }
