/* ============================================================
   ADMIN — Layout com sidebar hover + telas de gestão
   ============================================================ */
:root {
  --adm-bg:      #161b27;
  --adm-surface: #1e2535;
  --adm-card:    #252d3d;
  --adm-border:  #2e3a4e;
  --adm-text:    #e2e8f0;
  --adm-muted:   #8896a9;
  --adm-accent:  #FE8026;
  --adm-accent2: rgba(254,128,38,0.12);
  --adm-sidebar-w: 54px;        /* colapsada */
  --adm-sidebar-wexp: 210px;    /* expandida ao hover */
}

body.admin-mode,
body.admin-mode #app {
  background: var(--adm-bg);
}

/* ── Modo admin: esconde nav-buttons do header, mantém logo + sair ── */
body.admin-mode #header-nav .nav-btn:not(.nav-btn--logout) { display: none !important; }
body.admin-mode #global-header .header-inner { max-width: 100% !important; }
body.admin-mode #global-header .header-logo { position: static; transform: none; flex: 0 0 auto; }
body.admin-mode .adm-header-copy { display: flex; }
body.admin-mode #btn-admin-greeting { display: inline-flex !important; margin-left: 0; margin-right: 0; padding-left: 0; }

/* Saudação no header */
#btn-admin-greeting {
  display: none;
  align-items: center;
  gap: 8px;
  color: var(--adm-muted);
  font-size: 0.95rem;
  line-height: 1;
  margin-right: auto;
  padding-left: 16px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Bloco de textos alinhado com a palavra "Avaloon" dentro do logo */
.adm-header-copy {
  display: none;
  align-items: baseline;
  gap: 14px;
  min-width: 0;
  transform: translateY(11px);
}

/* Título da app no header (visível só no admin) */
.adm-app-title {
  display: none;
  align-items: baseline;
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
  margin-left: 10px;
}
body.admin-mode .adm-app-title { display: inline-flex; margin-left: 0; }
.adm-app-title-accent { color: var(--adm-accent); }

/* Remove bordas e efeito blur do header em modo admin */
body.admin-mode #global-header {
  border: none;
  box-shadow: none;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  background: var(--adm-surface);
}
body.admin-mode .header-inner {
  max-width: 100%;
  gap: 12px;
  min-width: 0;
}
/* Remove borda inferior da topbar interna */
body.admin-mode .adm-topbar { border-bottom: none; }

/* ── Tela admin: bloco abaixo do header, deslocado pelo sidebar fixo ── */
.admin-screen {
  display: block !important;
  min-height: calc(100dvh - var(--header-h));
  background: var(--adm-bg);
  padding: 0 !important;
  max-width: 100% !important;
  margin-top: var(--header-h) !important;   /* empurra abaixo do header fixo */
}
.admin-screen.hidden { display: none !important; }

/* Empurra todo conteúdo admin (admin-screen e content-screen) à direita do sidebar */
body.admin-mode .admin-screen,
body.admin-mode .content-screen {
  margin-left: var(--adm-sidebar-w);
}

/* ── Sidebar global: fixo na lateral esquerda, persistente em todas as telas admin ── */
.adm-sidebar-global {
  display: none;   /* só aparece em modo admin */
  position: fixed;
  top: var(--header-h);
  left: 0;
  width: var(--adm-sidebar-w);
  min-width: var(--adm-sidebar-w);
  background: var(--adm-surface);
  border-right: 1px solid var(--adm-border);
  flex-direction: column;
  padding: 12px 0;
  height: calc(100vh - var(--header-h));
  overflow: hidden;
  transition: width 0.22s ease, min-width 0.22s ease;
  z-index: 50;
}
body.admin-mode .adm-sidebar-global { display: flex; }

.adm-sidebar-global:hover {
  width: var(--adm-sidebar-wexp);
  min-width: var(--adm-sidebar-wexp);
}

.adm-sidebar-logo {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--adm-text);
  padding: 0;
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: max-height 0.22s ease, padding 0.22s ease, opacity 0.15s;
  white-space: nowrap;
}
.adm-sidebar-global:hover .adm-sidebar-logo {
  max-height: 40px;
  padding: 4px 14px 16px;
  opacity: 1;
}
.adm-sidebar-global:hover .adm-nav-lbl { opacity: 1; pointer-events: auto; }
.adm-sidebar-logo-accent { color: var(--adm-accent); }

.adm-nav-icon svg { width: 20px; height: 20px; flex-shrink: 0; }

.adm-sidebar-nav {
  display: flex;
  flex-direction: column;
  flex: 1;
  gap: 2px;
  padding: 0 6px;
  overflow: hidden;
}

.adm-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 10px;
  border-radius: 8px;
  background: none;
  border: none;
  color: var(--adm-accent);
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  width: 100%;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
  overflow: hidden;
}
.adm-nav-item:hover  { background: var(--adm-card);   color: var(--adm-accent); }
.adm-nav-item.active { background: var(--adm-accent2); color: var(--adm-accent); font-weight: 600; }

.adm-nav-icon { font-size: 1.15rem; flex-shrink: 0; min-width: 22px; text-align: center; }

.adm-nav-lbl {
  opacity: 0;
  transition: opacity 0.12s;
  pointer-events: none;
}
.adm-sidebar:hover .adm-nav-lbl { opacity: 1; pointer-events: auto; }

/* ── Conteúdo principal ── */
.adm-main {
  flex: 1;
  min-width: 0;
  min-height: calc(100dvh - var(--header-h));
  background: var(--adm-bg);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

/* ── Loading overlay do Painel ── */
.painel-loading-overlay {
  position: absolute;
  inset: 0;
  background: var(--adm-bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  z-index: 20;
}
.painel-loading-overlay.hidden { display: none; }
.painel-loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(254,128,38,0.2);
  border-top-color: var(--adm-accent);
  border-radius: 50%;
  animation: adm-spin 0.8s linear infinite;
}
@keyframes adm-spin { to { transform: rotate(360deg); } }
.painel-loading-label {
  font-size: 0.85rem;
  color: var(--adm-muted);
}

/* ── Topbar ── */
.adm-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 28px 14px;
  border-bottom: 1px solid var(--adm-border);
  gap: 12px;
  flex-wrap: wrap;
  background: var(--adm-bg);
  position: sticky;
  top: 0;
  z-index: 10;
}
.adm-topbar-left { display: flex; align-items: center; gap: 14px; }

.adm-page-title { font-size: 1.25rem; font-weight: 700; color: var(--adm-text); margin: 0; }

/* ── Botões ── */
.adm-btn-primary {
  background: var(--adm-accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 9px 20px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: opacity 0.15s;
  white-space: nowrap;
}
.adm-btn-primary:hover { opacity: 0.88; }

.adm-btn-ghost {
  background: none;
  border: 1px solid var(--adm-border);
  color: var(--adm-muted);
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.adm-btn-ghost:hover { border-color: var(--adm-text); color: var(--adm-text); }
.adm-btn-back { font-size: 0.82rem; }

.adm-btn-sm {
  padding: 5px 12px;
  font-size: 0.78rem;
  border-radius: 6px;
  cursor: pointer;
  border: 1px solid transparent;
  font-weight: 500;
  transition: opacity 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.adm-btn-sm:hover    { opacity: 0.82; }
.adm-btn-icon        { background: var(--adm-card); color: var(--adm-text); border-color: var(--adm-border); }
.adm-btn-orange      { background: var(--adm-accent); color: #fff; }
.adm-btn-blue        { background: rgba(59,130,246,0.18); color: #60a5fa; border-color: rgba(59,130,246,0.3); }

/* ── Modal de criar inventário (estilo seleção de filial) ── */
.adm-inv-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.72);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 4000;
  animation: fadeIn 0.15s ease;
}

.adm-inv-modal {
  background: var(--adm-surface);
  border-radius: 16px;
  padding: 28px 24px 22px;
  width: 92%;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  border: 1px solid var(--adm-border);
  box-shadow: 0 24px 60px rgba(0,0,0,0.5);
}

.adm-inv-modal-titulo { font-size: 1.1rem; font-weight: 700; color: var(--adm-text); margin: 0; }
.adm-inv-modal-step   { font-size: 0.78rem; color: var(--adm-accent); font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; }

/* Wizard de passos */
.adm-wizard-header { display: flex; flex-direction: column; gap: 10px; }
.adm-wizard-steps  { display: flex; align-items: center; }

.adm-wizard-step {
  display: flex; align-items: center; gap: 6px;
  opacity: 0.35;
  transition: opacity 0.25s;
}
.adm-wizard-step--active { opacity: 1; }
.adm-wizard-step--done   { opacity: 0.7; }

.adm-wizard-dot {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--adm-card);
  border: 2px solid var(--adm-border);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.72rem; font-weight: 700;
  color: var(--adm-muted);
  transition: background 0.2s, border-color 0.2s, color 0.2s;
  flex-shrink: 0;
}
.adm-wizard-step--active .adm-wizard-dot { background: var(--adm-accent); border-color: var(--adm-accent); color: #fff; }
.adm-wizard-step--done   .adm-wizard-dot { background: var(--adm-accent2); border-color: var(--adm-accent); color: var(--adm-accent); }

.adm-wizard-label { font-size: 0.75rem; font-weight: 600; color: var(--adm-muted); transition: color 0.2s; }
.adm-wizard-step--active .adm-wizard-label { color: var(--adm-accent); }
.adm-wizard-step--done   .adm-wizard-label { color: var(--adm-text); }

.adm-wizard-line {
  flex: 1; height: 2px;
  background: var(--adm-border);
  margin: 0 6px; min-width: 12px;
  border-radius: 2px;
  transition: background 0.3s;
}
.adm-wizard-line--done { background: var(--adm-accent); }

/* Busca rápida */
.adm-inv-busca-wrap { position: relative; }
.adm-busca-icon {
  position: absolute; left: 11px; top: 50%;
  transform: translateY(-50%);
  width: 15px; height: 15px;
  color: var(--adm-muted); pointer-events: none;
}
.adm-inv-busca-input {
  background: var(--adm-card);
  border: 1.5px solid var(--adm-border);
  border-radius: 9px;
  color: var(--adm-text);
  padding: 9px 14px 9px 34px;
  font-size: 0.88rem;
  width: 100%; outline: none;
  transition: border-color 0.15s;
  box-sizing: border-box;
}
.adm-inv-busca-input:focus { border-color: var(--adm-accent); }

/* Lista de opções (filial/armazém) */
.adm-opcoes-grid {
  display: flex; flex-direction: column;
  gap: 5px; max-height: 280px;
  overflow-y: auto; padding-right: 2px;
}

.adm-opcao-btn {
  display: flex; align-items: center; justify-content: center; gap: 12px;
  background: var(--adm-card);
  border: 1.5px solid var(--adm-border);
  border-radius: 10px; padding: 11px 14px;
  cursor: pointer; text-align: center;
  transition: border-color 0.15s, background 0.15s;
  color: var(--adm-text); width: 100%;
}
.adm-opcao-btn:hover { border-color: var(--adm-accent); background: var(--adm-accent2); }
.adm-opcao-btn.selecionado { border-color: var(--adm-accent); background: var(--adm-accent2); }

.adm-opcao-badge {
  flex-shrink: 0;
  background: rgba(254,128,38,0.12); color: var(--adm-accent);
  font-weight: 700; font-size: 0.82rem;
  padding: 4px 10px; border-radius: 6px;
  font-family: monospace; letter-spacing: 0.04em;
  min-width: 48px; text-align: center;
  transition: background 0.15s, color 0.15s;
}
.adm-opcao-btn.selecionado .adm-opcao-badge { background: var(--adm-accent); color: #fff; }

.adm-opcao-nome {
  flex: 1; font-size: 0.88rem; color: var(--adm-text);
  text-align: center;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.adm-opcao-check {
  flex-shrink: 0; width: 18px; height: 18px;
  color: var(--adm-accent); opacity: 0;
  transition: opacity 0.15s;
}
.adm-opcao-btn.selecionado .adm-opcao-check { opacity: 1; }

.adm-inv-modal-input {
  background: var(--adm-card);
  border: 1px solid var(--adm-border);
  border-radius: 8px;
  color: var(--adm-text);
  padding: 10px 14px;
  font-size: 0.9rem;
  width: 100%;
  outline: none;
  transition: border-color 0.15s;
}
.adm-inv-modal-input:focus { border-color: var(--adm-accent); }
.adm-inv-modal-input--date {
  color-scheme: dark;
  cursor: pointer;
}

/* ── Passo 4: card de confirmação ── */
.adm-confirm-card {
  background: var(--adm-card);
  border: 1px solid var(--adm-border);
  border-radius: 12px;
  overflow: hidden;
}
.adm-confirm-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--adm-border);
}
.adm-confirm-row:last-child { border-bottom: none; }
.adm-confirm-row-icon {
  flex-shrink: 0;
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(254,128,38,.1);
  border-radius: 8px;
  color: var(--adm-accent);
}
.adm-confirm-row-icon svg { width: 16px; height: 16px; }
.adm-confirm-row-lbl {
  flex-shrink: 0;
  width: 70px;
  font-size: 0.78rem;
  color: var(--adm-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}
.adm-confirm-row-val {
  flex: 1;
  font-size: 0.88rem;
  color: var(--adm-text);
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
}
.adm-confirm-badge {
  background: rgba(254,128,38,.14);
  color: var(--adm-accent);
  font-family: monospace;
  font-weight: 700;
  font-size: 0.8rem;
  padding: 2px 8px;
  border-radius: 5px;
}
.adm-confirm-field { display: flex; flex-direction: column; gap: 5px; }
.adm-confirm-field--spaced { margin-top: 10px; }
.adm-confirm-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--adm-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.adm-inv-modal-erro { color: #f87171; font-size: 0.82rem; }

.adm-inv-modal-btns { display: flex; gap: 10px; justify-content: center; }

/* ── Filtros ── */
.adm-filters {
  display: flex;
  gap: 10px;
  padding: 14px 28px;
  align-items: center;
  flex-wrap: wrap;
  background: var(--adm-bg);
}

.adm-input, .adm-select {
  background: var(--adm-card);
  border: 1px solid var(--adm-border);
  border-radius: 8px;
  color: var(--adm-text);
  padding: 9px 12px;
  font-size: 0.88rem;
  outline: none;
  transition: border-color 0.15s;
}
.adm-input:focus, .adm-select:focus { border-color: var(--adm-accent); }
.adm-select option { background: var(--adm-card); }

.adm-input-search { flex: 1; max-width: 340px; }
.adm-select-sm    { width: auto; min-width: 160px; }

/* ── Tabela ── */
.adm-table-wrap {
  flex: 1;
  padding: 0 28px 28px;
  background: var(--adm-bg);
  overflow: auto;
  max-height: calc(100vh - var(--header-h) - 220px);
}
.adm-table-wrap-compact {
  flex: 0 0 auto;
  padding-top: 0;
  max-height: 55vh;
}

.adm-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }

.adm-table thead tr { border-bottom: 2px solid var(--adm-border); }

.adm-table thead th {
  padding: 10px 14px;
  text-align: left;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--adm-muted);
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--adm-bg);
  box-shadow: inset 0 -2px 0 var(--adm-border);
  border-right: 1px solid rgba(254,128,38,0.25);
}
.adm-table thead th:last-child { border-right: none; }
.adm-th-num { text-align: right; }

.adm-table tbody tr { border-bottom: 1px solid var(--adm-border); transition: background 0.1s; }
.adm-table tbody tr:hover { background: rgba(254,128,38,0.04); }

.adm-table td { padding: 13px 14px; color: var(--adm-text); vertical-align: middle; border-right: 1px solid rgba(254,128,38,0.10); }
.adm-table td:last-child { border-right: none; }
.adm-td-num     { text-align: right; font-variant-numeric: tabular-nums; }
.adm-td-mono    { font-family: monospace; font-size: 0.82rem; color: var(--adm-muted); }
.adm-td-loading { text-align: center; padding: 2.5rem; color: var(--adm-muted); }

#inv-tabela th,
#inv-tabela td {
  text-align: center;
}

#inv-tabela .adm-td-num {
  text-align: center;
}

#inv-tabela .adm-td-acoes {
  justify-content: center;
}

/* ── Badges de status ── */
.adm-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  white-space: nowrap;
}
.adm-badge-contagem   { background: rgba(59,130,246,0.15);  color: #60a5fa; }
.adm-badge-tratamento { background: rgba(245,158,11,0.15);  color: #fbbf24; }
.adm-badge-finalizado { background: rgba(34,197,94,0.15);   color: #4ade80; }
.adm-badge-alerta     { background: rgba(254,128,38,0.15);  color: var(--adm-accent); }

.adm-alert-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: rgba(254,128,38,0.14);
  color: var(--adm-accent);
  font-weight: 800;
  font-size: 0.78rem;
  border: 1px solid rgba(254,128,38,0.32);
}

/* ── Ações por linha ── */
.adm-td-acoes-cell { min-width: 210px; }
.adm-td-acoes { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.adm-td-acoes--inline { flex-wrap: nowrap; }

.adm-status-select {
  background: var(--adm-card);
  border: 1px solid var(--adm-border);
  border-radius: 6px;
  color: var(--adm-muted);
  font-size: 0.75rem;
  padding: 4px 8px;
  cursor: pointer;
  min-width: 142px;
}

/* ── Meta do inventário no detalhe ── */
.adm-inv-meta {
  display: flex;
  gap: 20px;
  padding: 12px 28px;
  font-size: 0.82rem;
  color: var(--adm-muted);
  flex-wrap: wrap;
  border-bottom: 1px solid var(--adm-border);
  background: var(--adm-bg);
}
.adm-inv-meta strong { color: var(--adm-text); }

.adm-alertas-section {
  background: var(--adm-bg);
  padding: 0 0 28px;
  /* Espaço de respiro entre a 1ª tabela (bipagens) e esta (consignadas) */
  margin-top: 28px;
}

.adm-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 28px;
  /* Faixa destacada laranja para deixar claro onde começa a 2ª tabela */
  background: linear-gradient(180deg, rgba(254,128,38,0.20), rgba(254,128,38,0.08));
  border-top: 3px solid var(--adm-orange);
  border-bottom: 1px solid rgba(254,128,38,0.4);
  /* Gruda no topo da tela quando o usuário rola — assim o título
     "Etiquetas consignadas" fica sempre visível, evita confusão entre tabelas */
  position: sticky;
  top: 0;
  z-index: 30;
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}

.adm-section-title {
  margin: 0;
  color: var(--adm-text);
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.adm-section-title-wrap {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

/* Marcador laranja vertical antes do título — refere visual de "início de seção" */
.adm-section-title-wrap::before {
  content: '';
  display: inline-block;
  width: 4px;
  height: 22px;
  background: var(--adm-orange);
  border-radius: 2px;
}

.adm-tabela-separador {
  /* Não precisa mais — a faixa do .adm-section-head já marca a divisão */
  display: none;
}

.adm-rnk-topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.adm-rnk-last-update {
  font-size: 0.78rem;
  color: var(--adm-muted);
}

.adm-btn-refresh {
  width: 30px;
  height: 30px;
  padding: 0;
  justify-content: center;
  font-size: 1rem;
  line-height: 1;
  border-color: rgba(254,128,38,0.48);
  background: var(--adm-accent);
  color: #fff;
  box-shadow: 0 8px 18px rgba(254,128,38,0.18);
}

.adm-btn-refresh:hover {
  background: #ff9348;
  border-color: rgba(254,128,38,0.7);
  color: #fff;
}

.adm-btn-refresh.is-loading {
  opacity: 0.65;
  pointer-events: none;
}

.adm-alert-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid rgba(254,128,38,0.32);
  color: var(--adm-accent);
  background: rgba(254,128,38,0.12);
  font-size: 0.82rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

/* ── Ranking por Inventário ── */
.adm-rnk-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.adm-live-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--adm-border);
  border-radius: 8px;
  color: var(--adm-muted);
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
  background: var(--adm-card);
}

.adm-live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--adm-accent);
  box-shadow: 0 0 0 4px rgba(254,128,38,0.12);
}

.adm-rnk-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  padding: 16px 28px;
  background: var(--adm-bg);
}

.adm-rnk-kpis--general {
  grid-template-columns: repeat(6, minmax(140px, 1fr));
}

.adm-rnk-kpi {
  background: var(--adm-card);
  border: 1px solid var(--adm-border);
  border-radius: 8px;
  padding: 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.adm-rnk-kpi-lbl {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--adm-muted);
}
.adm-rnk-kpi-val {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--adm-accent);
  font-variant-numeric: tabular-nums;
}

.adm-rnk-filiais {
  margin: 0 28px 16px;
  background:
    linear-gradient(135deg, rgba(254,128,38,0.08), rgba(96,165,250,0.06)),
    var(--adm-card);
  border: 1px solid var(--adm-border);
  border-radius: 8px;
  overflow: hidden;
}

.adm-rnk-filiais-head {
  min-height: 58px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border-bottom: 1px solid var(--adm-border);
}

.adm-rnk-filiais-head h2 {
  margin: 0 0 4px;
  color: var(--adm-text);
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: 0;
}

.adm-rnk-filiais-head span {
  display: block;
  color: var(--adm-muted);
  font-size: 0.76rem;
}

.adm-rnk-filiais-badges {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.adm-rnk-filiais-badges > span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid rgba(136,150,169,0.28);
  color: var(--adm-text);
  background: rgba(136,150,169,0.1);
  font-size: 0.72rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.adm-rnk-filiais-badges .adm-rnk-alert-chip {
  border-color: rgba(239,68,68,0.32);
  color: #fca5a5;
  background: rgba(239,68,68,0.12);
}

.adm-rnk-filiais-body {
  display: grid;
  grid-template-columns: minmax(240px, 0.52fr) minmax(0, 1fr);
  gap: 12px;
  padding: 12px;
}

.adm-rnk-donut-wrap {
  min-width: 0;
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  padding: 14px;
  border: 1px solid rgba(136,150,169,0.18);
  border-radius: 8px;
  background: rgba(32,40,56,0.64);
}

.adm-rnk-donut-wrap canvas {
  display: block;
  width: 190px;
  height: 190px;
}

.adm-rnk-donut-legend {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.adm-rnk-donut-item {
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  color: var(--adm-muted);
  font-size: 0.72rem;
}

.adm-rnk-donut-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.adm-rnk-donut-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.adm-rnk-donut-item strong {
  color: var(--adm-text);
  font-variant-numeric: tabular-nums;
}

.adm-rnk-filiais-lista {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 10px;
}

.adm-rnk-filial-card {
  min-width: 0;
  padding: 12px;
  border: 1px solid rgba(136,150,169,0.22);
  border-radius: 8px;
  background: rgba(32,40,56,0.92);
}

.adm-rnk-filial-card.is-top { border-color: rgba(254,128,38,0.5); }
.adm-rnk-filial-card.is-second { border-color: rgba(96,165,250,0.42); }
.adm-rnk-filial-card.is-third { border-color: rgba(34,197,94,0.42); }

.adm-rnk-filial-main {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.adm-rnk-filial-code {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: rgba(254,128,38,0.14);
  color: var(--adm-accent);
  font-size: 0.78rem;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.adm-rnk-filial-info {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.adm-rnk-filial-info strong {
  color: var(--adm-text);
  font-size: 0.88rem;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.adm-rnk-filial-info span {
  color: var(--adm-muted);
  font-size: 0.7rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.adm-rnk-filial-total {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.adm-rnk-filial-total strong {
  display: block;
  color: var(--adm-text);
  font-size: 1.12rem;
  font-weight: 900;
}

.adm-rnk-filial-total span {
  display: block;
  color: var(--adm-muted);
  font-size: 0.68rem;
  white-space: nowrap;
}

.adm-rnk-filial-bottom {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  margin-top: 10px;
}

.adm-rnk-filial-track {
  height: 8px;
  border-radius: 999px;
  background: rgba(136,150,169,0.16);
  overflow: hidden;
}

.adm-rnk-filial-track > div {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--adm-accent), #60a5fa, #22c55e);
  transition: width 0.35s ease;
}

.adm-rnk-filial-tags {
  display: flex;
  gap: 6px;
}

.adm-rnk-filial-tags span {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  border: 1px solid rgba(136,150,169,0.24);
  color: var(--adm-muted);
  background: rgba(136,150,169,0.08);
  font-size: 0.66rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.adm-rnk-filial-tags span.has-alert {
  border-color: rgba(239,68,68,0.34);
  color: #fca5a5;
  background: rgba(239,68,68,0.13);
}

.adm-rnk-dashboard {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(320px, 0.85fr);
  gap: 16px;
  padding: 0 28px 28px;
  background: var(--adm-bg);
}

.adm-rnk-panel {
  min-width: 0;
  background: var(--adm-card);
  border: 1px solid var(--adm-border);
  border-radius: 8px;
  overflow: hidden;
}

.adm-rnk-panel--full {
  grid-column: 1 / -1;
}

.adm-rnk-panel-hd {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 44px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--adm-border);
  color: var(--adm-text);
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.adm-rnk-chart-wrap {
  position: relative;
  min-height: 190px;
  padding: 12px 16px 6px;
}

.adm-rnk-chart-wrap--bar {
  min-height: 210px;
}

.adm-rnk-inv-operadores {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 16px;
  min-height: 180px;
}

.adm-rnk-inv-op-row {
  display: grid;
  grid-template-columns: minmax(150px, 240px) minmax(120px, 1fr) 44px;
  align-items: center;
  gap: 12px;
  min-height: 32px;
}

.adm-rnk-inv-op-name {
  min-width: 0;
  color: var(--adm-text);
  font-size: 0.82rem;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.adm-rnk-inv-op-track {
  position: relative;
  height: 16px;
  border-radius: 5px;
  background: rgba(136,150,169,0.14);
  overflow: hidden;
}

.adm-rnk-inv-op-fill {
  position: absolute;
  inset: 0 auto 0 0;
  border-radius: 5px;
  background: var(--adm-accent);
}

.adm-rnk-inv-op-row.is-second .adm-rnk-inv-op-fill {
  background: #60a5fa;
}

.adm-rnk-inv-op-row.is-other .adm-rnk-inv-op-fill {
  background: #22c55e;
}

.adm-rnk-inv-op-total {
  color: var(--adm-text);
  font-size: 0.84rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.adm-rnk-chart-wrap canvas {
  display: block;
  width: 100%;
}

.adm-rnk-axis-x {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  padding: 0 20px 14px 58px;
  color: var(--adm-muted);
  font-size: 0.68rem;
  font-variant-numeric: tabular-nums;
}

.adm-rnk-axis-x span {
  text-align: center;
}

.pbi-chart-empty,
.pbi-loading,
.pbi-empty {
  text-align: center;
  padding: 24px;
  color: var(--adm-muted);
  font-size: 0.85rem;
}

.adm-rnk-lista {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  max-height: 412px;
  overflow-y: auto;
}

.adm-rnk-lista .pbi-rank-row {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 58px;
  padding: 10px 12px;
  border: 1px solid var(--adm-border);
  border-radius: 8px;
  background: #202838;
  color: var(--adm-text);
}

.adm-rnk-lista .pbi-rank-row:hover {
  border-color: rgba(254,128,38,0.45);
  background: #232d3f;
}

.adm-rnk-lista .pbi-rank-row.pos-1,
.adm-rnk-lista .pbi-rank-row.pos-2,
.adm-rnk-lista .pbi-rank-row.pos-3,
.adm-rnk-lista .pbi-rank-row.pos-4,
.adm-rnk-lista .pbi-rank-row.pos-5,
.adm-rnk-lista .pbi-rank-row.pos-other {
  background: #202838;
}

.adm-rnk-lista .pbi-rank-row.pos-1 { border-color: rgba(254,128,38,0.65); }
.adm-rnk-lista .pbi-rank-row.pos-2 { border-color: rgba(96,165,250,0.45); }
.adm-rnk-lista .pbi-rank-row.pos-3 { border-color: rgba(34,197,94,0.45); }

.adm-rnk-lista .pbi-rank-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(254,128,38,0.14);
  color: var(--adm-accent);
  font-size: 0.78rem;
  font-weight: 800;
}

.adm-rnk-lista .pbi-rank-medal-icon {
  display: none;
}

.adm-rnk-lista .pbi-rank-info {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.adm-rnk-lista .pbi-rank-nome {
  color: var(--adm-text);
  font-size: 0.9rem;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.adm-rnk-lista .pbi-rank-pills {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.adm-rnk-lista .rnk-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 7px;
  border: 1px solid var(--adm-border);
  border-radius: 999px;
  background: rgba(136,150,169,0.08);
  color: var(--adm-muted);
  font-size: 0.68rem;
}

.adm-rnk-lista .rnk-pill strong {
  color: var(--adm-text);
}

.adm-rnk-lista .pbi-rank-count {
  color: var(--adm-accent);
  font-size: 1rem;
  font-weight: 800;
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.adm-rnk-lista .pbi-rank-unit {
  display: block;
  color: var(--adm-muted);
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
}

/* Posição no ranking */
.adm-rnk-pos {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--adm-card);
  color: var(--adm-muted);
  font-weight: 700;
  font-size: 0.82rem;
}
.adm-rnk-pos-1 { background: rgba(254, 215, 0, 0.18);  color: #fcd34d; }
.adm-rnk-pos-2 { background: rgba(192, 192, 192, 0.2); color: #d1d5db; }
.adm-rnk-pos-3 { background: rgba(205, 127, 50, 0.22); color: #f59e0b; }

/* Barra de progresso (relativo ao top 1) */
.adm-rnk-bar {
  position: relative;
  height: 8px;
  width: 100%;
  min-width: 120px;
  background: var(--adm-card);
  border-radius: 4px;
  overflow: hidden;
}
.adm-rnk-bar-fill {
  position: absolute;
  inset: 0 auto 0 0;
  background: linear-gradient(90deg, var(--adm-accent), #f59e0b);
  border-radius: 4px;
  transition: width 0.4s ease;
}

/* ── Paginação ── */
.adm-paginacao {
  display: flex;
  gap: 8px;
  padding: 14px 28px;
  align-items: center;
  font-size: 0.82rem;
  color: var(--adm-muted);
  flex-wrap: wrap;
  background: var(--adm-bg);
}

/* ── Mobile: esconde sidebar global (usa bottom-nav existente) ── */
@media (max-width: 768px) {
  body.admin-mode .adm-sidebar-global { display: none !important; }
  body.admin-mode .admin-screen,
  body.admin-mode .content-screen { margin-left: 0; }
  body.admin-mode .header-inner { gap: 8px; }
  body.admin-mode .header-logo-img { height: 54px; max-width: 135px; }
  body.admin-mode .adm-header-copy { gap: 8px; transform: translateY(8px); }
  body.admin-mode .adm-app-title { font-size: 0.9rem; margin-left: 0; }
  body.admin-mode #btn-admin-greeting { font-size: 0.78rem; }
  .adm-main { height: auto; }
  .adm-table-wrap { padding: 0 12px 16px; max-height: 70vh; }
  .adm-table-wrap-compact { max-height: 60vh; }
  .adm-topbar { padding: 14px 16px 10px; }
  .adm-filters { padding: 10px 16px; }
  .adm-section-head { padding: 14px 16px 10px; align-items: flex-start; }
  .adm-section-title { font-size: 0.92rem; }
  .adm-rnk-actions { width: 100%; }
  .adm-rnk-actions .adm-select { flex: 1; min-width: 180px; }
  .adm-rnk-kpis,
  .adm-rnk-kpis--general { grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 12px 16px; }
  .adm-rnk-filiais { margin: 0 16px 14px; }
  .adm-rnk-filiais-head { align-items: flex-start; flex-direction: column; }
  .adm-rnk-filiais-badges { justify-content: flex-start; }
  .adm-rnk-filiais-body { grid-template-columns: 1fr; }
  .adm-rnk-donut-wrap { grid-template-columns: 1fr; justify-items: center; }
  .adm-rnk-donut-legend { width: 100%; }
  .adm-rnk-filiais-lista { grid-template-columns: 1fr; }
  .adm-rnk-filial-main { grid-template-columns: 40px minmax(0, 1fr); }
  .adm-rnk-filial-total {
    grid-column: 2;
    text-align: left;
    display: flex;
    align-items: baseline;
    gap: 8px;
  }
  .adm-rnk-dashboard { grid-template-columns: 1fr; padding: 0 16px 18px; }
  .adm-rnk-inv-op-row { grid-template-columns: 1fr; gap: 6px; }
  .adm-rnk-inv-op-total { text-align: left; }
  .adm-rnk-panel--full { grid-column: auto; }
  .adm-rnk-axis-x { padding-left: 46px; font-size: 0.6rem; }
}

@media (min-width: 769px) and (max-width: 1100px) {
  .adm-rnk-kpis--general { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .adm-rnk-dashboard { grid-template-columns: 1fr; }
  .adm-rnk-panel--full { grid-column: auto; }
}
