:root {
  --bg-app: #0f172a;
  --bg-sidebar: #020617;
  --bg-card: #1e293b66;
  --border: #1e293b;
  --primary: #22c55e;
  --primary-hover: #16a34a;
  --text-main: #e2e8f0;
  --text-muted: #94a3b8;
  --accent: #38bdf8;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
}

body {
  background: var(--bg-app);
  color: var(--text-main);
}

@keyframes loginFade {
  from { opacity: 0; transform: translateY(20px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* LOGIN SCREEN */
.login-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle at center, #1e293b 0%, #020617 100%);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 2000;
}

.login-box {
  background: var(--bg-sidebar);
  padding: 48px;
  border-radius: 16px;
  border: 1px solid var(--border);
  width: 100%;
  max-width: 400px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
  animation: loginFade 0.5s ease-out forwards;
}

.login-header {
  text-align: center;
  margin-bottom: 32px;
}

.login-header .logo {
  justify-content: center;
  font-size: 28px;
  margin-bottom: 8px;
}

.login-header p {
  color: var(--text-muted);
  font-size: 14px;
}

.login-box input {
  background: #0f172a !important;
  border: 1px solid var(--border) !important;
  color: white !important;
  padding: 12px 16px !important;
  margin-top: 4px;
  transition: all 0.3s ease;
}

.login-box input:focus {
  border-color: var(--primary) !important;
  box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.2);
}

/* Correção do fundo branco do autofill do Chrome */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
input:-webkit-autofill:active {
  -webkit-background-clip: text;
  -webkit-text-fill-color: #e2e8f0 !important;
  transition: background-color 5000s ease-in-out 0s;
  box-shadow: inset 0 0 20px 20px #0f172a !important;
}

#login-error {
  color: #f87171;
  font-size: 13px;
  text-align: center;
  margin-top: 16px;
  font-weight: 500;
}

.btn-login {
  margin-top: 32px;
  width: 100%;
  background: var(--primary) !important;
  color: white !important;
  border: none !important;
  font-size: 16px;
  height: 48px;
  box-shadow: 0 4px 14px rgba(34, 197, 94, 0.3);
}

.btn-login:hover {
  background: var(--primary-hover) !important;
  transform: translateY(-1px) scale(1.02) !important;
  box-shadow: 0 6px 20px rgba(34, 197, 94, 0.45) !important;
}

.hidden { display: none !important; }

/* LAYOUT */
.app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* SIDEBAR */
.sidebar {
  width: 350px;
  background: var(--bg-sidebar);
  padding: 24px;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}

.logo {
  font-size: 22px;
  font-weight: bold;
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.search {
  width: 100%;
  padding: 10px 14px;
  margin: 16px 0;
  background: #0f172a;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: white;
  outline: none;
  transition: border-color 0.2s;
}

.search:focus {
  border-color: var(--primary);
}

.filters {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
}

.filters button {
  padding: 8px 12px;
  background: var(--border);
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 6px;
  font-size: 13px;
  transition: all 0.2s ease;
}

.filters button:hover:not(.active) {
  background: var(--bg-card);
  color: var(--text-main);
  transform: translateY(-1px);
}

.filters span {
  font-size: 10px;
  background: rgba(255, 255, 255, 0.1);
  padding: 1px 5px;
  border-radius: 4px;
  margin-left: 4px;
}

.filters .active {
  background: var(--primary);
  color: white;
}

/* AREA DE NFs PENDENTES COM SCROLL */
.nf-list {
  flex: 1;
  overflow-y: auto;
  padding-right: 8px; /* Espaço para a barra de rolagem não sobrepor o card */
  margin-right: -8px; /* Ajuste para manter o alinhamento visual */
}

/* Estilização da barra de rolagem para manter consistência com o restante do sistema */
.nf-list::-webkit-scrollbar {
  width: 6px;
}
.nf-list::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 10px;
}

/* NF */
.nf-card {
  background: var(--bg-card);
  padding: 16px;
  border: 1px solid var(--border);
  margin-bottom: 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
}

.nf-card:hover {
  border-color: var(--primary);
  background: #1e293b;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.nf-actions-top {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  gap: 6px;
  opacity: 0;
  transition: opacity 0.2s;
}

.nf-card:hover .nf-actions-top {
  opacity: 1;
}

.icon-btn svg {
  width: 16px;
  height: 16px;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  transition: all 0.2s ease;
  border-radius: 4px;
  line-height: 0;
}

.icon-btn:hover {
  transform: scale(1.15);
  background: rgba(255, 255, 255, 0.05);
}

.icon-btn.edit:hover {
  color: var(--primary);
}

.icon-btn.delete:hover {
  color: #ef4444;
}

.nf-card span {
  display: block;
  color: var(--text-muted);
  font-size: 13px;
  margin-top: 4px;
}

.nf-card small {
  color: var(--primary);
  font-weight: 600;
}

/* MAIN */
.main {
  flex: 1;
  padding: 32px;
  overflow-y: auto;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  
  /* Implementação de Header Fixo (Sticky) */
  position: sticky;
  top: -32px; /* Compensa o padding do container .main */
  z-index: 100;
  
  /* Separação Visual e Estética Premium */
  background: var(--bg-app);
  margin: -32px -32px 32px -32px; /* Encosta nas bordas removendo o padding do pai */
  padding: 16px 32px; /* Recria o espaçamento interno interno */
  border-bottom: 1px solid var(--border);
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(10px); /* Efeito de vidro sutil */
}

.topbar-actions {
  display: flex;
  gap: 32px; /* Espaço maior entre os grupos */
  align-items: center;
}

.topbar-group {
  display: flex;
  align-items: center;
  gap: 8px; /* Espaço menor dentro dos grupos */
}

.date-filter {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-main);
  padding: 0 12px;
  height: 36px; /* Botão mais fino */
  font-size: 13px;
  outline: none;
  transition: all 0.2s ease;
  cursor: pointer;
  min-width: 140px;
}

.date-filter:hover, .date-filter:focus {
  border-color: var(--primary);
}

/* ROTAS GRID */
.rotas {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
  gap: 24px;
}

/* ROTA */
.rota-card {
  background: rgba(30, 41, 59, 0.3);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  transition: border-color 0.3s ease, background-color 0.3s ease, box-shadow 0.3s ease, transform 0.3s ease;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
  backdrop-filter: blur(4px);
  cursor: pointer;
}

.rota-card:hover {
  border-color: rgba(34, 197, 94, 0.4); /* Destaque fino em verde */
  background: rgba(30, 41, 59, 0.5); /* Levíssimo realce de fundo */
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3), 0 0 10px rgba(34, 197, 94, 0.05);
}

.rota-card.selected {
  border: 1px solid var(--primary); /* Borda fina e elegante */
  background: rgba(34, 197, 94, 0.04); /* Preenchimento verde quase imperceptível */
  box-shadow: 0 0 15px rgba(34, 197, 94, 0.1);
  transform: none; /* Removemos o scale pesado para manter o visual premium */
}

/* HEADER */
.rota-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 15px;
}

.rota-title-group {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
}

.rota-actions {
  display: flex;
  gap: 4px;
}

.valor {
  color: var(--primary);
  font-weight: 800;
  font-size: 20px;
  text-shadow: 0 0 20px rgba(34, 197, 94, 0.2);
}

/* HEADER DAS COLUNAS NO CARD */
.nf-header {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  text-align: center;
  padding: 10px 8px;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.02);
  border-bottom: 1px solid var(--border);
  border-radius: 4px 4px 0 0;
}

/* LINHAS */
.nf-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  text-align: center;
  padding: 8px 8px;
  border-bottom: 1px solid rgba(30, 41, 59, 0.5);
  cursor: pointer;
  transition: 0.2s;
  font-size: 14px;
}

.nf-row:hover {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 4px;
}

.rota-body {
  flex: 1;
}

/* RODAPÉ DO CARD DE ROTA */
.rota-footer {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: auto;
  padding-top: 20px;
}

.rota-footer .btn {
  padding: 7px 14px;
  font-size: 12px;
  min-width: 120px;
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-main);
  transition: all 0.2s ease;
}

.btn-outline:hover {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
  transform: scale(1.05);
}

/* HISTÓRICO STYLES */
.history-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-height: 60vh;
  overflow-y: auto;
  padding-right: 8px;
}

.history-card {
  background: var(--bg-app);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
}

.history-list::-webkit-scrollbar {
  width: 6px;
}
.history-list::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 10px;
}

/* BOTÕES */
.btn {
  background: transparent;
  color: var(--text-main);
  border: 1px solid var(--border);
  padding: 0 16px;
  height: 36px; /* Altura reduzida para leveza */
  cursor: pointer;
  border-radius: 6px;
  font-weight: 500;
  font-size: 13px;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn:hover {
  background: rgba(34, 197, 94, 0.15);
  border-color: var(--primary);
  color: var(--primary);
  transform: scale(1.02);
}

/* BOTÕES PRINCIPAIS (FIXOS) */
#open-nf-modal-btn, 
#open-rota-modal-btn {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

#open-nf-modal-btn:hover, 
#open-rota-modal-btn:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
  color: white;
  transform: scale(1.02);
}

/* MODAL STYLES */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(2, 6, 23, 0.8);
  backdrop-filter: blur(4px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  visibility: hidden;
  opacity: 0;
  transition: all 0.3s ease;
}

.modal-overlay.active {
  visibility: visible;
  opacity: 1;
}

.modal-content {
  background: var(--bg-sidebar);
  padding: 30px;
  border-radius: 10px;
  width: 90%;
  max-width: 450px;
  position: relative;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
  border: 1px solid #1e293b;
  transform: scale(0.9);
  transition: transform 0.3s ease;
}

.modal-overlay.active .modal-content {
  transform: scale(1);
}

.modal-content h3 {
  margin-top: 0;
  margin-bottom: 20px;
  color: #e2e8f0;
  text-align: center;
}

.modal-content form {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.modal-content label {
  color: #94a3b8;
  font-size: 0.9em;
}

.modal-content input[type="text"],
.modal-content input[type="number"],
.modal-content input[type="email"],
.modal-content input[type="password"],
.modal-content input[type="date"],
.modal-content select {
  width: 100%;
  padding: 10px;
  border: 1px solid #1e293b;
  background: #0f172a;
  color: #e2e8f0;
  border-radius: 5px;
  outline: none;
}

/* Melhoria para ícone do calendário em campos de data no tema dark */
.modal-content input[type="date"]::-webkit-calendar-picker-indicator {
  cursor: pointer;
  filter: invert(1);
  opacity: 0.6;
  transition: opacity 0.2s;
}

.modal-content input[type="date"]::-webkit-calendar-picker-indicator:hover {
  opacity: 1;
}

.modal-content input:disabled,
.modal-content select:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background: #020617;
}

.nf-tipo-toggle {
  display: flex;
  gap: 10px;
  margin: 5px 0;
}

.btn-toggle {
  flex: 1;
  padding: 10px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 6px;
  font-weight: 600;
  transition: all 0.2s ease;
}

.btn-toggle.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.btn-toggle:hover:not(.active) {
  background: var(--border);
  color: var(--text-main);
  transform: scale(1.02);
}

.form-row {
  display: flex;
  gap: 15px;
}

.form-group {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.modal-content .btn {
  margin-top: 20px;
  width: 100%;
}

/* CLOSE BUTTON FOR MODALS */
.modal-content {
  position: relative; /* Garante que o posicionamento absoluto do botão 'x' seja relativo ao modal-content */
}

.close-button {
  position: absolute;
  top: 15px;
  right: 20px;
  font-size: 28px;
  font-weight: bold;
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.2s ease;
}

.close-button:hover {
  color: var(--primary);
}

/* ESTILOS DA TABELA DO PAINEL */
.panel-container {
  background: rgba(30, 41, 59, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 16px;
  padding: 28px;
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.2);
  backdrop-filter: blur(4px);
}

/* Estado especial para o Painel de Controle (Admin Mode) */
.app.panel-active .sidebar {
  display: none;
}

.app.panel-active .main {
  padding: 40px;
}

/* Layout em colunas para o Painel de Controle */
.panel-grid {
  display: grid;
  grid-template-columns: 7fr 3fr;
  gap: 24px;
  align-items: start;
  max-width: 1600px;
  margin: 0 auto;
}

/* Responsividade: empilhar em telas menores que 1100px */
@media (max-width: 1100px) {
  .panel-grid {
    grid-template-columns: 1fr;
  }
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 20px;
}

.data-table th {
  text-align: left;
  padding: 16px;
  color: var(--text-muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
}

.data-table td {
  padding: 16px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-main);
}

.data-table tr:hover {
  background: rgba(255, 255, 255, 0.02);
}

/* EXIBIÇÃO DO USUÁRIO */
.user-display {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-main);
  font-size: 13px;
  font-weight: 500;
  padding: 0 12px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-card);
  position: relative;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
  white-space: nowrap;
}

.user-display:hover {
  border-color: var(--primary);
  background: rgba(30, 41, 59, 0.8);
}

.user-display svg {
  color: var(--primary);
}

.user-dropdown {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: 190px;
  background: var(--bg-sidebar);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5);
  z-index: 1100;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: dropdownFadeIn 0.2s ease-out;
}

@keyframes dropdownFadeIn {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

.dropdown-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 11px;
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.user-dropdown button {
  width: 100%;
  padding: 12px 16px;
  background: transparent;
  border: none;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  text-align: left;
  transition: all 0.2s ease;
}

.user-dropdown button:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-main);
}

.user-dropdown button.logout-item:hover {
  color: #ef4444;
}

.user-dropdown button svg {
  color: inherit;
}

/* Estilo para edição inline de Status */
.status-select-inline {
  background: #0f172a;
  border: 1px solid var(--primary);
  color: var(--text-main);
  font-size: 11px;
  border-radius: 4px;
  padding: 2px 4px;
  width: 100%;
  outline: none;
  cursor: pointer;
}

/* --- ESTILOS PARA ALTERNÂNCIA DE VISUALIZAÇÃO (GRID / LISTA) --- */
.view-toggle {
  display: flex;
  background: var(--bg-sidebar);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 2px;
  margin: 0 4px;
}

.view-toggle .icon-btn {
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 6px;
}

.view-toggle .icon-btn.active {
  background: var(--primary) !important;
  color: white !important;
}

/* MODO LISTA */
.rotas.list-view {
  grid-template-columns: 1fr !important;
  gap: 12px !important;
}

.rotas.list-view .rota-card {
  flex-direction: row !important;
  align-items: center !important;
  padding: 12px 24px !important;
  gap: 20px;
}

.rotas.list-view .rota-header {
  border-bottom: none !important;
  padding-bottom: 0 !important;
  margin-bottom: 0 !important;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: flex-start !important;
  gap: 24px;
}

.rotas.list-view .rota-header > div:first-child {
  display: flex;
  align-items: center;
  gap: 24px;
  flex: 1;
}

.rotas.list-view .rota-title-group { margin-bottom: 0 !important; min-width: 180px; }
.rotas.list-view .rota-header span { margin-top: 0 !important; white-space: nowrap; }
.rotas.list-view .rota-header div:nth-child(2) { margin-bottom: 0 !important; font-size: 11px !important; white-space: nowrap; }

.rotas.list-view .valor {
  font-size: 18px !important;
  min-width: 130px;
  text-align: right;
  margin-left: auto;
}

.rotas.list-view .rota-body { display: none !important; }
.rotas.list-view .rota-footer { margin-top: 0 !important; padding-top: 0 !important; gap: 8px !important; }
.rotas.list-view .rota-footer .btn { min-width: 100px !important; height: 32px !important; font-size: 11px !important; }

/* DASHBOARD STATS - PAINEL DE CONTROLE */
.dashboard-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  margin-bottom: 32px;
  max-width: 1600px;
  margin-left: auto;
  margin-right: auto;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 24px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
  cursor: default;
}

.stat-card:hover {
  transform: translateY(-3px);
  border-color: rgba(34, 197, 94, 0.3);
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.3);
}

.stat-icon {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-info {
  display: flex;
  flex-direction: column;
}

.stat-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
  margin-bottom: 4px;
}

.stat-info h3 {
  font-size: 26px;
  color: var(--text-main);
  margin: 0;
  font-weight: 800;
  line-height: 1;
}

/* ÁREA DE GRÁFICOS */
.dashboard-charts {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 20px;
  margin-bottom: 32px;
  max-width: 1600px;
  margin-left: auto;
  margin-right: auto;
}

@media (max-width: 1200px) {
  .dashboard-charts { grid-template-columns: 1fr; }
}

.chart-container {
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 24px;
  border-radius: 12px;
  height: 380px; /* Altura fixa definida para evitar o loop de crescimento */
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

.chart-container h3 {
  font-size: 14px;
  color: var(--text-main);
  margin-bottom: 20px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.chart-canvas-wrapper {
  flex: 1;
  position: relative;
  min-height: 0; /* Importante para o comportamento do Flexbox */
}

.empty-chart-msg {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: var(--text-muted);
  font-size: 13px;
  text-align: center;
}

/* FAIXA DE RANKINGS E ALERTAS */
.dashboard-rankings {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 20px;
  margin-bottom: 32px;
  max-width: 1600px;
  margin-left: auto;
  margin-right: auto;
}

@media (max-width: 1100px) {
  .dashboard-rankings { grid-template-columns: 1fr; }
}

.ranking-list, .alerts-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 4px;
}

.ranking-item, .alert-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.02);
  border-radius: 8px;
  font-size: 13px;
  border: 1px solid transparent;
}

.ranking-item strong { color: var(--primary); font-weight: 700; }
.ranking-item span { color: var(--text-main); font-weight: 500; }

.alert-item { border-left: 3px solid #fbbf24; }
.alert-item .alert-label { color: var(--text-muted); }
.alert-item .alert-count {
  background: rgba(251, 191, 36, 0.1);
  color: #fbbf24;
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 700;
  font-size: 12px;
}

/* --- AJUSTES PARA PERFIL VISUALIZADOR --- */

/* Esconde botões de ação global e ícones de edição/exclusão */
body.is-viewer #open-nf-modal-btn,
body.is-viewer #open-rota-modal-btn,
body.is-viewer .nf-actions-top,
body.is-viewer .rota-actions,
body.is-viewer .rota-footer .btn:not(.btn-outline),
body.is-viewer .history-card .btn[onclick*="retornar"],
body.is-viewer .history-card .btn[onclick*="excluirHistorico"],
body.is-viewer .panel-container .btn[onclick*="retornar"] {
  display: none !important;
}

/* Desabilita interações de clique para adicionar/remover NFs e selecionar rotas */
body.is-viewer .nf-card,
body.is-viewer .nf-row,
body.is-viewer .rota-card {
  pointer-events: none !important;
  cursor: default !important;
}

/* Garante que áreas de leitura e botões permitidos (Resumo/Exportar/Modal) continuem clicáveis */
body.is-viewer .sidebar,
body.is-viewer .rota-footer,
body.is-viewer .history-card,
body.is-viewer .modal-overlay,
body.is-viewer .user-display,
body.is-viewer .rota-footer .btn-outline,
body.is-viewer .history-card .btn[onclick*="copiar"] {
  pointer-events: auto !important;
  }
