:root {
  --bg: #16191d;
  --panel: #1f2328;
  --panel-2: #262b31;
  --line: #31373e;
  --text: #e6e9ec;
  --muted: #8d96a0;
  --accent: #3fa7ff;
  --gold: #f2b84b;
  --green: #3ecf8e;
  --red: #ff5d6c;
  --purple: #a37bff;
  --orange: #ff9b45;
  --radius: 12px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 Inter, system-ui, sans-serif; }
a { color: inherit; text-decoration: none; }
h1, h2, h3 { margin: 0; font-weight: 700; }
.muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; }

/* topo */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 24px;
  padding: 10px 24px; background: #121417ee; backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { width: 46px; height: 46px; object-fit: contain; filter: drop-shadow(0 2px 6px #0008); }
.brand b { display: block; font-size: 15px; }
.brand small { color: var(--muted); font-size: 11px; }
nav { display: flex; gap: 4px; }
nav a { padding: 7px 12px; border-radius: 8px; color: var(--muted); font-weight: 500; }
nav a:hover { color: var(--text); background: var(--panel); }
nav a.active { color: var(--text); background: var(--panel-2); }
.search { position: relative; margin-left: auto; }
.search input { width: 240px; padding: 8px 12px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--panel); color: var(--text); font: inherit; }
.search-results { position: absolute; top: 40px; right: 0; width: 320px; background: var(--panel);
  border: 1px solid var(--line); border-radius: 10px; overflow: hidden; display: none; }
.search-results a { display: block; padding: 9px 12px; border-bottom: 1px solid var(--line); }
.search-results a:hover { background: var(--panel-2); }
.pill { padding: 6px 12px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--panel-2);
  white-space: nowrap; }
.pill::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  margin-right: 7px; background: var(--muted); }
.pill.on::before { background: var(--green); box-shadow: 0 0 8px var(--green); }
.pill.busy::before { background: var(--gold); animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .3; } }

main { max-width: 1320px; margin: 0 auto; padding: 24px; }

/* blocos */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.card h3 { font-size: 15px; margin-bottom: 14px; display: flex; align-items: center; gap: 8px; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.kpis { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.section { margin-top: 16px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px;
  margin-bottom: 18px; flex-wrap: wrap; }
.page-head h1 { font-size: 26px; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
select, .btn { padding: 7px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel);
  color: var(--text); font: inherit; cursor: pointer; }
.btn:hover { background: var(--panel-2); }

.kpi { position: relative; overflow: hidden; }
.kpi .label { font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.kpi .value { font-size: 26px; font-weight: 800; margin-top: 6px; }
.kpi .delta { font-size: 12px; font-weight: 600; margin-top: 2px; }
.kpi::after { content: ""; position: absolute; right: -20px; top: -20px; width: 80px; height: 80px;
  border-radius: 50%; background: var(--c, var(--accent)); opacity: .12; }
.up { color: var(--green); }
.down { color: var(--red); }

/* tabelas */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 9px 10px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--line); }
th { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600;
  position: sticky; top: 0; background: var(--panel); cursor: pointer; user-select: none; }
th:hover { color: var(--text); }
th.sorted { color: var(--accent); }
th.l, td.l { text-align: left; }
tbody tr:hover { background: var(--panel-2); }
td .sub { display: block; font-size: 11px; }
.gov-cell { display: flex; align-items: center; gap: 10px; }
.avatar { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; font-weight: 700;
  font-size: 13px; flex: none; position: relative; overflow: hidden; }
.avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.tag { display: inline-block; padding: 1px 7px; border-radius: 6px; font-size: 11px; font-weight: 600;
  background: var(--panel-2); color: var(--muted); }
.tag.warn { background: #ff5d6c22; color: var(--red); }
.tag.new { background: #3ecf8e22; color: var(--green); }
.rank { color: var(--muted); font-weight: 600; width: 40px; }

/* perfil */
.hero { display: grid; grid-template-columns: auto 1fr auto; gap: 22px; align-items: center;
  background: radial-gradient(circle at 0 0, #2c3a4a 0, var(--panel) 60%); }
.hero .avatar { width: 84px; height: 84px; font-size: 32px; border-radius: 18px; }
.hero h1 { font-size: 28px; }
.hero .meta { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 6px; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.chip { display: flex; flex-direction: column; padding: 8px 14px; border-radius: 10px; background: #00000033;
  border: 1px solid var(--line); min-width: 110px; }
.chip b { font-size: 16px; }
.chip span { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.chip i { font-style: normal; font-size: 11px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 18px 0 16px; }
.tabs button { background: none; border: 0; color: var(--muted); font: inherit; font-weight: 600;
  padding: 10px 14px; cursor: pointer; border-bottom: 2px solid transparent; }
.tabs button.active { color: var(--text); border-color: var(--accent); }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { padding: 10px 0 10px 18px; border-left: 2px solid var(--line); position: relative; }
.timeline li::before { content: ""; position: absolute; left: -6px; top: 15px; width: 10px; height: 10px;
  border-radius: 50%; background: var(--accent); }
.tier { display: grid; grid-template-columns: 50px 1fr auto auto; gap: 12px; align-items: center;
  padding: 8px 0; border-bottom: 1px solid var(--line); }
.tier .bar { height: 6px; border-radius: 3px; background: var(--panel-2); overflow: hidden; }
.tier .bar span { display: block; height: 100%; }

.empty { text-align: center; padding: 60px 20px; color: var(--muted); }
.empty h2 { color: var(--text); margin-bottom: 8px; }
.mover { display: flex; justify-content: space-between; gap: 10px; padding: 7px 0;
  border-bottom: 1px solid var(--line); }
.mover:last-child { border: 0; }
.mover .n { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

@media (max-width: 900px) {
  .g2, .g3 { grid-template-columns: 1fr; }
  .topbar { flex-wrap: wrap; padding: 10px 16px; gap: 10px; }
  .search { margin-left: 0; flex: 1; }
  .search input { width: 100%; }
  main { padding: 16px; }
  .hero { grid-template-columns: 1fr; }
}
.chip.medal { flex-direction: row; align-items: center; gap: 10px; padding: 6px 14px 6px 6px; }
.chip.medal img { width: 52px; height: 52px; border-radius: 8px; object-fit: cover; }
.chip.medal div { display: flex; flex-direction: column; }

/* ---------- login, usuários */
[data-role][hidden] { display: none !important; }
.user-box { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.user-box b { color: var(--text); }
.btn.primary { background: var(--accent); color: #04121f; font-weight: 700; border: 0; }
.login-wrap { min-height: calc(100vh - 140px); display: grid; place-items: center; }
.login { width: min(380px, 100%); }
.login h1 { margin: 0 0 4px; font-size: 22px; }
.login img { width: 120px; display: block; margin: 0 auto 12px; }
.field { display: grid; gap: 4px; margin-top: 12px; }
.field input, .field select, input.inp { padding: 9px 12px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--panel-2); color: var(--text); font: inherit; width: 100%; box-sizing: border-box; }
.login .btn.primary { width: 100%; margin-top: 16px; padding: 10px; }
.msg { min-height: 20px; margin: 10px 0 0; }
.msg.err { color: var(--red); }
.gov-pick { display: flex; flex-wrap: wrap; gap: 10px; }
.gov-pick a { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--panel-2); }
.gov-pick a.active { border-color: var(--accent); }
.role-admin { background: #ff5d6c22; color: var(--red); }
.role-gerente { background: #3fa7ff22; color: var(--accent); }
@media (max-width: 700px) { .user-box span { display: none; } }
.topbar { flex-wrap: wrap; row-gap: 8px; }
nav a { white-space: nowrap; }
nav { flex: 1; flex-wrap: wrap; }
.search { margin-left: 0; }
@media (max-width: 1200px) { .user-box span { display: none; } .search input { width: 180px; } }

/* ---------- banners (perfil do governador e Minha conta) */
.hero, .user-banner { position: relative; overflow: hidden; border: 1px solid #5a1a14; border-top: 3px solid var(--red);
  background: linear-gradient(90deg, #120808f2 0%, #140909d9 42%, #1a0b0a80 75%, #1a0b0a33 100%),
              url(/static/banner.jpg) right center / cover no-repeat, #1a0b0a; }
.hero::after, .user-banner::after { content: ""; position: absolute; inset: auto 0 0 0; height: 40%;
  background: linear-gradient(transparent, #0000004d); pointer-events: none; }
.hero > *, .user-banner > * { position: relative; z-index: 1; }
.hero h1, .user-banner h1 { text-shadow: 0 2px 10px #000a; }
.hero .chip, .user-banner .chip { background: #0000005c; border: 1px solid #ffffff14; backdrop-filter: blur(4px); }
.hero .avatar { box-shadow: 0 0 0 2px #f2b84b88, 0 6px 18px #0009; }
.user-banner { display: flex; align-items: center; gap: 18px; padding: 22px; border-radius: var(--radius); margin-bottom: 16px; }
.user-banner .avatar { width: 72px; height: 72px; font-size: 30px; border-radius: 50%; flex: none;
  box-shadow: 0 0 0 2px #f2b84b88, 0 6px 18px #0009; }
.user-banner h1 { font-size: 26px; margin: 0; }
.user-banner .meta { display: flex; gap: 8px 14px; flex-wrap: wrap; color: #e6d6c4; margin-top: 4px; font-size: 13px; }
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.badge.jogador { background: #3ecf8e26; color: var(--green); }
.badge.gerente { background: #3fa7ff26; color: var(--accent); }
.badge.admin { background: #f2b84b26; color: var(--gold); }

/* ---------- celular */
@media (max-width: 700px) {
  main { padding: 12px; }
  .topbar { padding: 8px 12px; gap: 8px; }
  .brand small { display: none; }
  nav { order: 3; flex: 1 1 100%; overflow-x: auto; flex-wrap: nowrap; scrollbar-width: none; margin: 0 -4px; }
  nav::-webkit-scrollbar { display: none; }
  nav a { padding: 6px 10px; }
  .search { order: 4; flex: 1 1 100%; }
  #scanner-status { margin-left: auto; font-size: 11px; padding: 5px 10px; }
  .user-box .btn { padding: 5px 10px; }
  .page-head { flex-direction: column; align-items: stretch; }
  .page-head h1 { font-size: 22px; }
  .toolbar { flex-wrap: wrap; }
  .toolbar select, .toolbar input { max-width: 100%; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi .value { font-size: 22px; }
  .card { padding: 14px; }
  .hero { padding: 16px; gap: 12px; text-align: left; }
  .hero h1 { font-size: 22px; }
  .hero .avatar { width: 64px; height: 64px; }
  .chips { gap: 6px; }
  .chip { padding: 6px 10px; flex: 1 1 calc(50% - 6px); min-width: 0; }
  .chip.medal { flex-basis: 100%; }
  .tabs { overflow-x: auto; scrollbar-width: none; }
  .tabs button { white-space: nowrap; }
  .user-banner { padding: 16px; gap: 12px; }
  .user-banner .avatar { width: 56px; height: 56px; font-size: 24px; }
  .user-banner h1 { font-size: 21px; }
  .gov-pick a { flex: 1 1 100%; }
  th, td { padding: 8px 8px; }
  .login-wrap { min-height: auto; padding-top: 12px; }
}
.hero .meta, .hero .muted { color: #e6d6c4d9; }
