:root {
  --bg: #f4f6f9;
  --panel: #ffffff;
  --ink: #1c2430;
  --muted: #6b7686;
  --line: #e4e8ee;
  --brand: #2f6df6;
  --brand-ink: #1b4fd0;
  --ok: #1f9d55;
  --warn: #c77700;
  --danger: #d23b3b;
  --sidebar: #10233f;
  --sidebar-ink: #c6d3e6;
  --radius: 10px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  font-size: 14px;
  line-height: 1.45;
}

/* ---------- Layout ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 220px; background: var(--sidebar); color: var(--sidebar-ink);
  padding: 22px 16px; flex-shrink: 0;
}
.brand { font-size: 20px; font-weight: 700; color: #fff; letter-spacing: .3px; }
.brand span {
  display: inline-block; margin-left: 6px; padding: 2px 7px; border-radius: 6px;
  background: var(--brand); color: #fff; font-size: 11px; font-weight: 600; vertical-align: middle;
}
.brand.center { text-align: center; }
.sidebar nav { margin-top: 26px; display: flex; flex-direction: column; gap: 4px; }
.sidebar nav a {
  color: var(--sidebar-ink); text-decoration: none; padding: 10px 12px;
  border-radius: 8px; font-weight: 500;
}
.sidebar nav a:hover { background: rgba(255,255,255,.07); color: #fff; }
.sidebar nav a.on { background: var(--brand); color: #fff; }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 26px; background: var(--panel); border-bottom: 1px solid var(--line);
}
.topbar h1 { font-size: 18px; margin: 0; }
.userbox { display: flex; align-items: center; gap: 12px; }
.who { color: var(--muted); font-weight: 500; }
.content { padding: 24px 26px; max-width: 1080px; width: 100%; }

/* ---------- Componentes ---------- */
.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px; margin-bottom: 18px;
}
.form-card { max-width: 720px; }
.toolbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }

.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.table th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .4px; }
.table tr:last-child td { border-bottom: none; }
.table tr.dim { opacity: .5; }
.right { text-align: right; }
.center { text-align: center; }
.actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }

.badge { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge.ok { background: #e2f5ea; color: var(--ok); }
.badge.warn { background: #fbf0dc; color: var(--warn); }
.badge.muted { background: #edf0f4; color: var(--muted); }
.tag { font-size: 11px; background: #eef2fb; color: var(--brand-ink); padding: 1px 6px; border-radius: 5px; }
.tag.danger { background: #fbe6e6; color: var(--danger); }

/* Botões */
.btn {
  display: inline-block; border: 1px solid var(--line); background: #fff; color: var(--ink);
  padding: 8px 14px; border-radius: 8px; font-size: 13px; font-weight: 600;
  cursor: pointer; text-decoration: none; line-height: 1.2;
}
.btn:hover { background: #f7f9fc; }
.btn.sm { padding: 5px 10px; font-size: 12px; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-ink); }
.btn.ok { color: var(--ok); border-color: #bfe6cd; }
.btn.warn { color: var(--warn); border-color: #eed6ab; }
.btn.danger { color: var(--danger); border-color: #eec2c2; }
.btn.ghost { background: transparent; }
.btn.block { display: block; width: 100%; text-align: center; margin-top: 12px; }
.inline { display: inline; }
.link { color: var(--brand-ink); text-decoration: none; }
.link:hover { text-decoration: underline; }

/* Formulários */
label { display: block; margin-bottom: 14px; font-weight: 600; color: #38424f; }
input, select {
  display: block; width: 100%; margin-top: 6px; padding: 9px 11px;
  border: 1px solid var(--line); border-radius: 8px; font-size: 14px; background: #fff;
  font-weight: 400; color: var(--ink);
}
input:focus, select:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(47,109,246,.12); }
small.muted { font-weight: 400; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
.form-actions { display: flex; gap: 10px; margin-top: 6px; }
.row-form { display: flex; gap: 10px; align-items: center; }
.row-form input { margin-top: 0; }

.muted { color: var(--muted); }

/* Alertas */
.alert { padding: 11px 14px; border-radius: 8px; margin-bottom: 16px; font-weight: 500; }
.alert.ok { background: #e2f5ea; color: #146c3a; }
.alert.warn { background: #fbf0dc; color: #8a5300; }
.alert.error { background: #fbe6e6; color: #a12727; }

/* QR / token */
.qr-wrap { display: flex; gap: 18px; flex-wrap: wrap; align-items: flex-start; }
.qr-card { text-align: center; }
.qr-card.grow { flex: 1; min-width: 300px; text-align: left; }
.qr-card img { border: 1px solid var(--line); border-radius: 8px; }
.code {
  background: #0f1b2d; color: #d7e3f4; padding: 14px; border-radius: 8px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px;
  overflow-x: auto; white-space: pre;
}
.kv { width: 100%; margin-top: 12px; border-collapse: collapse; }
.kv th { text-align: left; color: var(--muted); font-weight: 600; padding: 4px 10px 4px 0; width: 90px; vertical-align: top; }
.kv td { padding: 4px 0; word-break: break-all; }

/* Login */
.login-page {
  display: flex; align-items: center; justify-content: center; min-height: 100vh;
  background: linear-gradient(135deg, #10233f, #21406f);
}
.login-card {
  background: #fff; padding: 30px 28px; border-radius: 14px; width: 340px;
  box-shadow: 0 18px 50px rgba(0,0,0,.25);
}
.login-card .muted.center { margin: 6px 0 18px; }
.login-card.center { text-align: center; }

/* Empty state */
.empty-state { text-align: center; padding: 70px 20px; color: var(--muted); }
.empty-emoji { font-size: 46px; }
.empty-state h2 { color: var(--ink); margin: 10px 0 4px; }

@media (max-width: 720px) {
  .grid2 { grid-template-columns: 1fr; }
  .sidebar { width: 64px; padding: 18px 8px; }
  .brand span, .who { display: none; }
  .sidebar nav a { text-align: center; padding: 10px 4px; font-size: 12px; }
}
