:root {
  --bg: #eef5fa;
  --surface: #ffffff;
  --ink: #0f2a3a;
  --muted: #5b7280;
  --brand: #02a7f6;
  --brand-deep: #0b7fc4;
  --primary: #0a86cc;
  --primary-dark: #086aa3;
  --accent: #02a7f6;
  --line: #e1ebf1;
  --danger: #b3261e;
  --ok: #15803d;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(15, 42, 58, .05), 0 10px 30px rgba(15, 42, 58, .07);
  --grad: linear-gradient(135deg, #16b0f9 0%, #0a86cc 100%);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* faixa de destaque no topo de todas as páginas */
body::before {
  content: '';
  position: fixed; top: 0; left: 0; right: 0; height: 4px;
  background: linear-gradient(90deg, var(--brand), var(--brand-deep));
  z-index: 100;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary-dark); }

/* ---------- Top bar ---------- */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar-inner {
  max-width: 980px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--ink);
}
.brand-logo { height: 30px; width: auto; display: block; }
.brand .dot { color: var(--brand); }
.brand .sub { font-weight: 500; color: var(--muted); font-size: 13px; letter-spacing: 0; }
.spacer { flex: 1; }
.nav { display: flex; align-items: center; gap: 6px; }
.nav a {
  text-decoration: none;
  color: var(--muted);
  font-size: 14px;
  padding: 7px 12px;
  border-radius: 8px;
}
.nav a:hover { background: var(--bg); color: var(--ink); }
.nav .who { color: var(--ink); font-weight: 600; padding: 7px 4px; }
.badge {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .06em;
  background: var(--primary);
  color: #fff;
  padding: 2px 7px;
  border-radius: 999px;
  margin-left: 6px;
}

/* ---------- Layout ---------- */
.wrap { max-width: 980px; margin: 0 auto; padding: 32px 20px 64px; }
.page-head { margin-bottom: 24px; }
.eyebrow {
  text-transform: uppercase;
  letter-spacing: .12em;
  font-size: 12px;
  font-weight: 600;
  color: var(--primary);
  margin: 0 0 6px;
}
h1 { font-size: 28px; letter-spacing: -.02em; margin: 0 0 4px; }
.lead { color: var(--muted); margin: 0; }

/* ---------- App grid ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
  margin-top: 8px;
}
.app-card {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow);
  transition: transform .12s ease, border-color .12s ease;
}
.app-card:hover { transform: translateY(-3px); border-color: var(--brand); box-shadow: 0 12px 28px rgba(2, 167, 246, .16); }
.app-icon {
  font-size: 26px;
  width: 48px; height: 48px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, #e8f7ff, #d3efff);
  border-radius: 13px;
  flex-shrink: 0;
}
.app-name { font-weight: 700; letter-spacing: -.01em; }
.app-desc { color: var(--muted); font-size: 14px; margin-top: 2px; }
.empty {
  background: var(--surface);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 28px;
  text-align: center;
  color: var(--muted);
}

/* ---------- Cards / forms ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}
.card h2 { margin: 0 0 4px; font-size: 18px; }
.card .hint { color: var(--muted); font-size: 14px; margin: 0 0 16px; }

label { display: block; font-size: 14px; font-weight: 600; margin: 14px 0 6px; }
input[type=text], input[type=password], select {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 15px;
  font-family: inherit;
  background: #fff;
  color: var(--ink);
}
input:focus, select:focus, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}
.checks { display: grid; gap: 8px; margin-top: 6px; }
.check {
  display: flex; align-items: center; gap: 10px;
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px;
}
.check input { width: 18px; height: 18px; accent-color: var(--primary); }
.check .meta small { color: var(--muted); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--grad); color: #fff; border: 0;
  padding: 11px 18px; border-radius: 10px;
  font-size: 15px; font-weight: 600; font-family: inherit;
  cursor: pointer; text-decoration: none;
  box-shadow: 0 4px 12px rgba(2, 167, 246, .25);
  transition: transform .1s ease, box-shadow .12s ease, opacity .12s ease;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(2, 167, 246, .32); }
.btn.block { width: 100%; }
.btn.ghost { background: transparent; color: var(--primary-dark); border: 1px solid var(--line); box-shadow: none; }
.btn.ghost:hover { background: var(--bg); transform: none; }
.btn.danger { background: transparent; color: var(--danger); border: 1px solid var(--line); box-shadow: none; }
.btn.danger:hover { background: #fdf2f1; border-color: var(--danger); transform: none; }
.btn.sm { padding: 7px 12px; font-size: 13px; box-shadow: none; }

.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 18px; }

/* ---------- Alerts ---------- */
.alert { padding: 12px 14px; border-radius: 10px; font-size: 14px; margin-bottom: 14px; }
.alert.err { background: #fdf2f1; color: var(--danger); border: 1px solid #f3c9c5; }
.alert.ok { background: #effaf1; color: var(--ok); border: 1px solid #c4ebcd; }
.alert.warn { background: #fff7ed; color: #9a3412; border: 1px solid #fed7aa; }

/* ---------- Table (admin) ---------- */
.table { width: 100%; border-collapse: collapse; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.table th, .table td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--line); font-size: 14px; }
.table th { background: var(--bg); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.table tr:last-child td { border-bottom: 0; }
.pill { font-size: 12px; padding: 2px 9px; border-radius: 999px; font-weight: 600; }
.pill.admin { background: #e6f4f1; color: var(--primary-dark); }
.pill.user { background: var(--bg); color: var(--muted); }
.pill.off { background: #fdf2f1; color: var(--danger); }
.actions { display: flex; gap: 6px; flex-wrap: wrap; }
.muted-sm { color: var(--muted); font-size: 13px; }

/* ---------- Login ---------- */
.login-shell {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background:
    radial-gradient(900px 500px at 50% -8%, #cfeeff 0%, rgba(207,238,255,0) 60%),
    linear-gradient(180deg, #f4fbff 0%, #e9f4fb 100%);
}
.login-card {
  width: 100%; max-width: 380px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 20px; padding: 36px 32px;
  box-shadow: 0 20px 50px rgba(2, 100, 160, .14);
}
.login-logo { display: block; height: 78px; width: auto; margin: 0 auto 6px; }
.login-card .tagline { text-align: center; color: var(--brand); font-size: 13px; font-weight: 600; margin-bottom: 24px; letter-spacing: .01em; }
.login-card .tag { text-align: center; color: var(--muted); font-size: 14px; margin-bottom: 22px; }

.credentials {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  background: var(--bg); border: 1px solid var(--line);
  border-radius: 10px; padding: 14px; margin: 8px 0 4px;
}
.credentials div { display: flex; justify-content: space-between; gap: 12px; padding: 2px 0; }
.credentials b { color: var(--ink); }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
@media (max-width: 560px) {
  .topbar-inner { flex-wrap: wrap; }
  h1 { font-size: 24px; }
}

/* ---------- Separador / matriz de permissões ---------- */
.sep { border: 0; border-top: 1px solid var(--line); margin: 22px 0; }
.perm-app {
  border: 1px solid var(--line); border-radius: 12px; padding: 0 14px 14px;
  margin: 14px 0; background: #fff;
}
.perm-app legend {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 4px 6px;
}
.app-toggle { display: flex; align-items: center; gap: 10px; font-size: 15px; cursor: pointer; }
.app-toggle input { width: 18px; height: 18px; accent-color: var(--primary); }
.perm-app legend .marcar-tudo { margin-left: auto; }
.perm-table-wrap { overflow-x: auto; }
.perm-table { width: 100%; border-collapse: collapse; min-width: 420px; }
.perm-table th, .perm-table td { padding: 8px 10px; text-align: center; border-top: 1px solid var(--line); font-size: 14px; }
.perm-table thead th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); border-top: 0; }
.perm-table th:first-child, .perm-table td.mod-name { text-align: left; }
.perm-table td.mod-name { font-weight: 600; color: var(--ink); }
.perm-box { width: 18px; height: 18px; accent-color: var(--primary); cursor: pointer; }

/* ---------- Filtros e logs ---------- */
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.filters input, .filters select { width: auto; flex: 0 0 auto; }
.filters input { min-width: 220px; }
.log-action { font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 999px; background: var(--bg); color: var(--muted); white-space: nowrap; }
.act-login { background: #e7f0f7; color: var(--primary-dark); }
.act-usuario { background: #eef6ee; color: var(--ok); }
.act-senha { background: #fff7ed; color: #9a3412; }
.act-permissoes { background: #f3eefe; color: #6b21a8; }
