/* ============================================================
   RBG HUB — site.css
   ============================================================ */

/* --- Variáveis globais ------------------------------------ */
:root {
  --bg:         #f3f6fb;
  --surface:    #ffffff;
  --text:       #1f2937;
  --muted:      #64748b;
  --border:     #e2e8f0;

  /* cores dos módulos */
  --rh:         #2563eb;
  --ti:         #0f766e;
  --operacoes:  #9333ea;
  --marketing:  #f97316;
  --relatorios: #0ea5e9;
  --ec:         #0369a1;

  /* cor de acento dos cabeçalhos (cada módulo pode sobrescrever para a cor do seu setor) */
  --accent:     #1d4ed8;

  /* botões e ações */
  --btn-dark:   #0f172a;
  --btn-save:   #0b3c5d;
  --btn-text:   #ffffff;

  /* sidebar */
  --sidebar-w:  200px;
}

/* --- Reset base ------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; }

body {
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
}

body, input, button, select, textarea { font-family: inherit; }

h1, h2, h3, h4 { margin: 0; }
p { margin: 0; color: var(--muted); line-height: 1.7; }
a { text-decoration: none; color: inherit; }

/* ============================================================
   SHELL PRINCIPAL
   ============================================================ */
.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* --- Topbar ----------------------------------------------- */
.app-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  height: 56px;
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 0;
  position: sticky;
  top: 0;
  z-index: 100;
}

.brand {
  display: flex;
  align-items: center;
  padding-right: 20px;
  border-right: 1px solid var(--border);
  flex-shrink: 0;
}

.brand img {
  max-height: 52px;
  width: auto;
}

/* Navegação de módulos na topbar */
.top-nav {
  display: flex;
  align-items: center;
  gap: 2px;
  padding-left: 12px;
  flex: 1;
}

.top-nav-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}

.top-nav-item:hover { background: #eef2f8; color: #1e40af; }
/* aba ativa com destaque (azul suave) — padrão de abas do HUB */
.top-nav-item.active {
  background: linear-gradient(135deg, #2563eb, #3b82f6);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 3px 10px rgba(37,99,235,.25);
}
.top-nav-item.active:hover { background: linear-gradient(135deg, #2563eb, #3b82f6); color: #fff; }
.top-nav-item.active svg { color: #fff; }

.top-nav-item svg { width: 16px; height: 16px; flex-shrink: 0; }

.top-nav-sep {
  width: 1px; height: 18px;
  background: var(--border);
  margin: 0 2px;
}

/* Avatar / usuário no canto direito */
.header-user {
  position: relative;                 /* âncora do dropdown do usuário */
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding-left: 16px;
  border-left: 1px solid var(--border);
}

.header-user-name { font-size: 13px; font-weight: 600; color: var(--text); white-space: nowrap; }

/* Gatilho do menu do usuário (avatar + nome + seta) */
.user-menu-trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  border: 1px solid transparent;
  padding: 4px 8px;
  border-radius: 10px;
  cursor: pointer;
}
.user-menu-trigger:hover { background: var(--bg); border-color: var(--border); }
.user-menu-caret { width: 14px; height: 14px; color: var(--muted); transition: transform .15s; flex-shrink: 0; }
.user-menu-trigger[aria-expanded="true"] .user-menu-caret { transform: rotate(180deg); }

/* Dropdown */
.user-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 184px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(15,23,42,.14);
  padding: 6px;
  display: none;
  z-index: 300;
}
.user-menu.open { display: block; }

.user-menu-item {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  /* funciona tanto para <a> quanto para <button> (reset do <button>, que por padrão
     no site.css é inline-flex + justify-content:center — o que desalinhava o item) */
  width: 100%;
  background: none;
  border: none;
  text-align: left;
  font-family: inherit;
  text-decoration: none;
}
.user-menu-item:hover { background: var(--bg); }
.user-menu-item svg { width: 16px; height: 16px; color: var(--muted); flex-shrink: 0; }
.user-menu-item.danger { color: #b91c1c; }
.user-menu-item.danger svg { color: #b91c1c; }
.user-menu-item.danger:hover { background: #fef2f2; }

.user-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: #dbeafe;
  color: #1d4ed8;
  font-size: 12px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
}
/* Foto de perfil sobreposta às iniciais (aparece só quando carrega). */
.user-avatar-img {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  opacity: 0; transition: opacity .15s;
}
.user-avatar-img.loaded { opacity: 1; }

.header-logout {
  font-size: 12px;
  color: var(--muted);
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  transition: background 0.15s;
}

.header-logout:hover { background: var(--bg); color: var(--text); }

/* ============================================================
   LAYOUT COM SIDEBAR
   ============================================================ */
.page-body {
  display: flex;
  flex: 1;
}

/* --- Sidebar lateral ------------------------------------- */
.app-sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 16px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex-shrink: 0;
}

.sidebar-section-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 10px 8px 4px;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
  padding: 7px 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.sidebar-item:hover { background: var(--bg); color: var(--text); }

.sidebar-item.active {
  background: #eff6ff;
  color: #1d4ed8;
  font-weight: 600;
}

.sidebar-item svg { width: 16px; height: 16px; flex-shrink: 0; }

.sidebar-badge {
  margin-left: auto;
  font-size: 11px;
  font-weight: 600;
  background: var(--bg);
  color: var(--muted);
  padding: 1px 6px;
  border-radius: 99px;
  border: 1px solid var(--border);
}

/* --- Conteúdo principal ---------------------------------- */
.page-content {
  flex: 1;
  padding: 28px 32px;
  min-width: 0;
}

/* --- Breadcrumb ------------------------------------------ */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 18px;
}

.breadcrumb svg { width: 13px; height: 13px; }
.breadcrumb span { cursor: pointer; }
.breadcrumb span:hover { color: var(--text); }
.breadcrumb .bc-current { color: var(--text); font-weight: 600; cursor: default; }

/* ============================================================
   CABEÇALHO DE PÁGINA
   ============================================================ */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}

.page-header-text h2 {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text);
  margin-bottom: 3px;
  padding-bottom: 9px;
  position: relative;
}

/* acento colorido sob o título — destaque sem exagero (cor via --accent) */
.page-header-text h2::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  width: 46px;
  height: 3px;
  border-radius: 2px;
  background: var(--accent);
}

.page-header-text p { font-size: 13px; }

.page-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* ============================================================
   MENSAGENS DE FEEDBACK
   ============================================================ */
.alert {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 13px;
  margin-bottom: 20px;
}

.alert svg { width: 16px; height: 16px; flex-shrink: 0; }

.alert-success {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  color: #166534;
}

.alert-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
}

.alert-info {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1e40af;
}

/* ============================================================
   POPUP PADRÃO DE ERRO — mensagem amigável + "Detalhes técnicos"
   window.rbgShowError(mensagem, detalhe) — ver _Layout.cshtml
   ============================================================ */
.rbg-error-dialog {
  width: min(480px, 92vw);
  border: none;
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 20px 50px rgba(15, 23, 42, .25);
  background: var(--surface);
  color: var(--text);
}

.rbg-error-dialog::backdrop {
  background: rgba(15, 23, 42, .45);
}

.rbg-error-icon {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: #fef2f2;
  color: #dc2626;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
}

.rbg-error-icon svg { width: 24px; height: 24px; }

.rbg-error-dialog h3 {
  font-size: 16px;
  font-weight: 800;
  margin-bottom: 6px;
}

.rbg-error-dialog p {
  font-size: 13.5px;
  color: var(--text);
  line-height: 1.5;
  margin-bottom: 14px;
}

.rbg-error-details {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  margin-bottom: 18px;
}

.rbg-error-details summary {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}

.rbg-error-details pre {
  margin-top: 10px;
  font-size: 12px;
  color: #b91c1c;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 220px;
  overflow-y: auto;
}

.rbg-error-actions {
  display: flex;
  justify-content: flex-end;
}

/* ============================================================
   POPUP PADRÃO DE QUESTIONAMENTO — confirmação/negação/cancelamento
   window.rbgConfirm({ titulo, mensagem, textoPositivo, textoNegativo,
   textoCancelar, perigo }) — ver _Layout.cshtml
   ============================================================ */
.rbg-confirm-dialog {
  width: min(440px, 92vw);
  border: none;
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 20px 50px rgba(15, 23, 42, .25);
  background: var(--surface);
  color: var(--text);
}

.rbg-confirm-dialog::backdrop {
  background: rgba(15, 23, 42, .45);
}

.rbg-confirm-icon {
  width: 42px;
  height: 42px;
  border-radius: 999px;
  background: #fffbeb;
  color: #d97706;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
  font-size: 20px;
  font-weight: 800;
}

.rbg-confirm-dialog h3 {
  font-size: 16px;
  font-weight: 800;
  margin-bottom: 6px;
}

.rbg-confirm-dialog p {
  font-size: 13.5px;
  color: var(--text);
  line-height: 1.5;
  margin-bottom: 20px;
}

.rbg-confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

/* ============================================================
   PÁGINA DE ERRO (404 / 500) — Views/Home/Error.cshtml
   ============================================================ */
.error-page {
  max-width: 440px;
  margin: 64px auto;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.error-page-icon {
  width: 64px;
  height: 64px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 18px;
}

.error-page-icon svg { width: 32px; height: 32px; }

.error-page-icon.info { background: #eff6ff; color: #1e40af; }
.error-page-icon.danger { background: #fef2f2; color: #dc2626; }

.error-page-code {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: .08em;
  color: var(--muted);
  margin-bottom: 6px;
}

.error-page h2 {
  font-size: 22px;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 10px;
}

.error-page p {
  font-size: 13.5px;
  color: var(--muted);
  line-height: 1.6;
  margin-bottom: 24px;
}

/* ============================================================
   BARRA DE FILTRO / PESQUISA
   ============================================================ */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.search-wrap {
  position: relative;
  flex: 1;
  min-width: 200px;
}

.search-wrap svg {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px; height: 16px;
  color: var(--muted);
  pointer-events: none;
}

.search-wrap input {
  width: 100%;
  padding: 9px 12px 9px 34px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  font-size: 13px;
  transition: border-color 0.2s;
}

.search-wrap input:focus {
  outline: none;
  border-color: #93c5fd;
  box-shadow: 0 0 0 3px rgba(147,197,253,0.2);
}

.filter-select {
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
}

.filter-select:focus { outline: none; border-color: #93c5fd; }

/* ============================================================
   TABELA DE DADOS
   ============================================================ */
.table-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  margin-bottom: 20px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: auto;
}

.data-table th {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  padding: 11px 16px;
  border-bottom: 1px solid var(--border);
  background: #f8fafc;
  text-align: left;
  white-space: nowrap;
}

.data-table td {
  font-size: 13px;
  color: var(--text);
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: #f8fafc; }
.data-table tbody tr.row-inactive td { background: #fef2f2; color: #991b1b; }

/* ID com estilo muted */
.data-table td.cell-id {
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* Ação de linha */
.row-action {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 600;
  color: #2563eb;
  padding: 4px 10px;
  border: 1px solid #bfdbfe;
  border-radius: 6px;
  transition: background 0.15s;
}

.row-action:hover { background: #eff6ff; }
.row-action svg { width: 13px; height: 13px; }

/* ============================================================
   RESULTADO DE RELATÓRIO EM ABAS — "Visão agrupada" (árvore) +
   "Lista completa" (grid tipo Excel, com exportação). Padrão fixado
   em 2026-08-11 (telas de Relatórios Customizados — Divergências,
   Alerta de Vencimento). Mesma família visual de .top-nav-item.active
   (gradiente azul suave).
   ============================================================ */
.result-tabs {
  display: flex;
  gap: 8px;
  padding: 0 0 12px;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}

.result-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: 10px 10px 0 0;
  border: 1px solid var(--border);
  border-bottom: none;
  background: #f8fafc;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.result-tab svg { width: 15px; height: 15px; }
.result-tab:hover { color: #1e40af; background: #eef2f8; }

.result-tab.active {
  color: #fff;
  background: linear-gradient(135deg, #2563eb, #3b82f6);
  border-color: transparent;
  box-shadow: 0 3px 10px rgba(37, 99, 235, .25);
}

.result-grid-scroll {
  max-height: 620px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
}

.result-grid-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}

.result-grid-table th {
  text-align: left;
  font-size: 10.5px;
  text-transform: uppercase;
  color: var(--muted);
  padding: 8px 12px;
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  position: sticky;
  top: 0;
}

.result-grid-table td {
  padding: 6px 12px;
  border-top: 1px solid var(--border);
  white-space: nowrap;
}

.result-grid-table td.num,
.result-grid-table th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* Paginação */
.table-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  background: #f8fafc;
}

.pagination-info { font-size: 12px; color: var(--muted); }

.pagination-btns { display: flex; gap: 4px; }

.pagination-btn {
  font-size: 12px;
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  transition: background 0.15s;
}

.pagination-btn:hover { background: var(--bg); }
.pagination-btn.active { background: var(--btn-dark); color: #fff; border-color: var(--btn-dark); }

/* ============================================================
   BADGES / STATUS
   ============================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 99px;
}

.badge-green  { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }
.badge-red    { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.badge-amber  { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }
.badge-blue   { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }
.badge-gray   { background: #f8fafc; color: var(--muted); border: 1px solid var(--border); }

/* Coluna "Ativo" — converte S/N */
.badge-ativo-s { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }
.badge-ativo-n { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }

/* ============================================================
   CARDS DE FORMULÁRIO (seções)
   ============================================================ */
.form-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  margin-bottom: 16px;
}

.form-section-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  background: #f8fafc;
}

.form-section-icon {
  width: 30px; height: 30px;
  border-radius: 8px;
  background: #dbeafe;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.form-section-icon svg { width: 16px; height: 16px; color: #1d4ed8; }

.form-section-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.form-section-body {
  padding: 20px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.form-section-body.cols-1 { grid-template-columns: 1fr; }
.form-section-body.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }

/* ============================================================
   GRUPOS DE CAMPO
   ============================================================ */
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group.span-2 { grid-column: span 2; }
.form-group.span-3 { grid-column: span 3; }

.form-group label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  display: block;
}

.form-group label .req { color: #dc2626; margin-left: 2px; }

.form-group .field-hint {
  font-size: 11px;
  color: var(--muted);
}

/* Inputs, selects e textareas */
input[type="text"],
input[type="search"],
input[type="email"],
input[type="password"],
input[type="date"],
input[type="number"],
select,
textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #f8fafc;
  color: var(--text);
  font-size: 13px;
  transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: #93c5fd;
  background: var(--surface);
  box-shadow: 0 0 0 3px rgba(147,197,253,0.2);
}

textarea { resize: vertical; min-height: 80px; }

select { cursor: pointer; }

.validation-error {
  font-size: 11px;
  color: #dc2626;
}

/* ============================================================
   RODAPÉ DE FORMULÁRIO
   ============================================================ */
.form-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 14px;
  margin-top: 4px;
}

.form-footer-right { display: flex; gap: 8px; align-items: center; }

/* ============================================================
   BOTÕES
   ============================================================ */
button, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
  text-decoration: none;
}

button:hover, .btn:hover { background: var(--bg); }
button:active, .btn:active { transform: scale(0.98); }

button svg, .btn svg { width: 15px; height: 15px; }

/* Variantes */
.btn-primary {
  background: var(--btn-dark);
  color: #fff;
  border-color: var(--btn-dark);
}
.btn-primary:hover { background: #020617; border-color: #020617; }

.btn-save {
  background: var(--btn-save);
  color: #fff;
  border-color: var(--btn-save);
}
.btn-save:hover { background: #082d46; }

.btn-danger {
  background: #fef2f2;
  color: #991b1b;
  border-color: #fecaca;
}
.btn-danger:hover { background: #fee2e2; }

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
}
.btn-ghost:hover { background: var(--bg); color: var(--text); }

/* ============================================================
   Botões nomeados (usados nas views: primary-button, etc.)
   Encorpados, seguindo a paleta RBG.
   ============================================================ */
.primary-button {
  background: var(--ec);
  color: #fff;
  border: 1px solid var(--ec);
  padding: 11px 20px;
  font-weight: 700;
  border-radius: 10px;
  box-shadow: 0 2px 8px rgba(3,105,161,.25);
}
.primary-button:hover { background: #02567f; border-color: #02567f; box-shadow: 0 4px 14px rgba(3,105,161,.32); }

/* save-button vem depois p/ vencer quando combinado com primary-button */
.save-button {
  background: #0b6e4f;
  color: #fff;
  border: 1px solid #0b6e4f;
  padding: 11px 20px;
  font-weight: 700;
  border-radius: 10px;
  box-shadow: 0 2px 8px rgba(11,110,79,.25);
}
.save-button:hover { background: #095c41; border-color: #095c41; box-shadow: 0 4px 14px rgba(11,110,79,.32); }

.secondary-button {
  background: #fff;
  color: var(--ec);
  border: 1.5px solid var(--ec);
  padding: 10px 18px;
  font-weight: 700;
  border-radius: 10px;
}
.secondary-button:hover { background: #ecf6fb; color: #02567f; border-color: #02567f; }

.black-button {
  background: var(--btn-dark);
  color: #fff;
  border: 1px solid var(--btn-dark);
  padding: 11px 20px;
  font-weight: 700;
  border-radius: 10px;
  box-shadow: 0 2px 8px rgba(15,23,42,.22);
}
.black-button:hover { background: #020617; border-color: #020617; }

.red-button {
  background: #dc2626;
  color: #fff;
  border: 1px solid #dc2626;
  padding: 11px 20px;
  font-weight: 700;
  border-radius: 10px;
  box-shadow: 0 2px 8px rgba(220,38,38,.22);
}
.red-button:hover { background: #b91c1c; border-color: #b91c1c; }

/* Links de voltar */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  color: var(--muted);
  padding: 7px 14px;
  border: 1px solid var(--border);
  border-radius: 99px;
  transition: background 0.15s, color 0.15s;
}

.back-link:hover { background: var(--bg); color: var(--text); }
.back-link svg { width: 14px; height: 14px; }

/* ============================================================
   SEÇÕES DE PÁGINA (filtros colapsáveis, blocos de resultado)
   ============================================================ */
.section-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  background: #f8fafc;
}

.section-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}

/* ============================================================
   DASHBOARD — Cards de módulo
   ============================================================ */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-top: 24px;
}

.module-card {
  min-height: 160px;
  border-radius: 16px;
  padding: 22px;
  color: #ffffff;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  text-decoration: none;
  transition: transform 0.2s, filter 0.2s;
}

.module-card:hover { transform: translateY(-3px); filter: brightness(1.05); }

.module-card-icon {
  width: 36px; height: 36px;
  background: rgba(255,255,255,0.2);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 14px;
}

.module-card-icon svg { width: 20px; height: 20px; }

.module-card h3 { font-size: 20px; margin-bottom: 6px; }
.module-card p { color: rgba(255,255,255,0.8); font-size: 13px; }

.module-card-footer {
  margin-top: 16px;
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 5px;
}

.module-card-footer svg { width: 14px; height: 14px; }

/* Cores por módulo */
.module-rh        { background: linear-gradient(135deg, #2563eb, #1e40af); }
.module-ti        { background: linear-gradient(135deg, #0f766e, #134e4a); }
.module-operacoes { background: linear-gradient(135deg, #9333ea, #7c3aed); }
.module-marketing { background: linear-gradient(135deg, #f97316, #c2410c); }
.module-relatorios{ background: linear-gradient(135deg, #0ea5e9, #0369a1); }
.module-ec        { background: linear-gradient(135deg, #0369a1, #075985); }

/* Tons claros de azul — usar no lugar da paleta roxa em vitrines de cards */
.module-blue-1 { background: linear-gradient(135deg, #38bdf8, #0284c7); } /* céu */
.module-blue-2 { background: linear-gradient(135deg, #60a5fa, #2563eb); } /* azul */
.module-blue-3 { background: linear-gradient(135deg, #22d3ee, #0891b2); } /* ciano */

/* Tons de bordô — agrupador "Ciclo de Vendas" */
.module-bordo-1 { background: linear-gradient(135deg, #be123c, #9f1239); }
.module-bordo-2 { background: linear-gradient(135deg, #9f1239, #881337); }
.module-bordo-3 { background: linear-gradient(135deg, #881337, #5e0f26); }

/* Tons de azul marinho — agrupador "Alertas de Estoque" */
.module-marinho-1 { background: linear-gradient(135deg, #1e40af, #1e3a8a); }
.module-marinho-2 { background: linear-gradient(135deg, #1e3a8a, #172554); }
.module-marinho-3 { background: linear-gradient(135deg, #172554, #0f172a); }

/* Tons dos cards de grupos de relatórios — distintos, porém sóbrios */
.rel-grupo-1 { background: linear-gradient(135deg, #2563eb, #1e40af); } /* azul */
.rel-grupo-2 { background: linear-gradient(135deg, #0f766e, #115e59); } /* teal */
.rel-grupo-3 { background: linear-gradient(135deg, #4f46e5, #3730a3); } /* índigo */
.rel-grupo-4 { background: linear-gradient(135deg, #0891b2, #0e7490); } /* ciano */
.rel-grupo-5 { background: linear-gradient(135deg, #475569, #334155); } /* ardósia */
.rel-grupo-6 { background: linear-gradient(135deg, #15803d, #166534); } /* verde */
.rel-grupo-7  { background: linear-gradient(135deg, #ca8a04, #a16207); } /* amarelo */
.rel-grupo-8  { background: linear-gradient(135deg, #92400e, #78350f); } /* marrom */
.rel-grupo-9  { background: linear-gradient(135deg, #374151, #111827); } /* preto */
.rel-grupo-10 { background: linear-gradient(135deg, #dc2626, #b91c1c); } /* vermelho */
.rel-grupo-11 { background: linear-gradient(135deg, #6b7280, #4b5563); } /* cinza */
.rel-grupo-12 { background: linear-gradient(135deg, #db2777, #be185d); } /* rosa */
.rel-grupo-13 { background: linear-gradient(135deg, #1e3a8a, #172554); } /* marinho */
.rel-grupo-14 { background: linear-gradient(135deg, #881337, #5e0f26); } /* bordô */

/* ============================================================
   TELA DE LOGIN
   ============================================================ */
.login-shell {
  min-height: 100vh;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 40px 36px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 20px 60px rgba(15,23,42,0.07);
}

.login-logo {
  display: flex;
  justify-content: center;
  margin-bottom: 28px;
}

.login-logo img { max-height: 44px; }

.login-card h2 {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
}

.login-card .login-sub {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 28px;
}

.login-form .form-group { margin-bottom: 16px; }

.login-form .form-group label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
  display: block;
}

.login-form input {
  width: 100%;
  padding: 11px 14px;
  font-size: 14px;
}

.login-submit {
  width: 100%;
  padding: 12px;
  font-size: 14px;
  font-weight: 700;
  background: var(--btn-dark);
  color: #fff;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  margin-top: 8px;
  transition: background 0.2s, transform 0.1s;
}

.login-submit:hover { background: #020617; }
.login-submit:active { transform: scale(0.99); }

/* ============================================================
   FOOTER
   ============================================================ */
.app-footer {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 14px 24px;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
}

/* ============================================================
   PÁGINA SEM SIDEBAR (conteúdo centralizado)
   ============================================================ */
.content-shell {
  flex: 1;
  padding: 32px 24px;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
}

main {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 32px;
  box-shadow: 0 18px 40px rgba(15,23,42,0.04);
}

/* ============================================================
   UTILITÁRIOS
   ============================================================ */
.text-muted   { color: var(--muted); }
.text-sm      { font-size: 12px; }
.mt-0         { margin-top: 0; }
.mt-4         { margin-top: 16px; }
.mt-6         { margin-top: 24px; }

/* ============================================================
   NAV MOBILE — hambúrguer + drawer (base: oculto no desktop)
   ============================================================ */
.nav-toggle {
  display: none;                 /* só aparece no mobile (media query) */
  align-items: center;
  justify-content: center;
  width: 40px; height: 40px;
  margin-right: 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  flex-shrink: 0;
}
.nav-toggle svg { width: 20px; height: 20px; }
.nav-backdrop { display: none; }

/* ============================================================
   RESPONSIVO
   ============================================================ */
@media (max-width: 768px) {
  .app-sidebar        { display: none; }
  .page-content       { padding: 20px 16px; }
  .content-shell      { padding: 20px 14px; }
  main                { padding: 20px 18px; border-radius: 14px; }
  .form-section-body  { grid-template-columns: 1fr; }
  .form-section-body.cols-3 { grid-template-columns: 1fr; }
  .form-group.span-2,
  .form-group.span-3  { grid-column: span 1; }
  .page-header        { flex-direction: column; }
  .filter-bar         { flex-direction: column; align-items: stretch; }
  .form-footer        { flex-direction: column; gap: 10px; }
  .form-footer-right  { width: 100%; justify-content: flex-end; }
  .dashboard-grid     { grid-template-columns: 1fr 1fr; }

  /* Hambúrguer visível */
  .nav-toggle         { display: inline-flex; }

  /* .top-nav deixa de sumir e vira um drawer lateral off-canvas.
     Reaproveita os MESMOS itens gerados pelo Razor (permissões intactas). */
  .top-nav {
    display: flex;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: 268px;
    max-width: 82vw;
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
    padding: 16px 12px;
    background: var(--surface);
    border-right: 1px solid var(--border);
    transform: translateX(-100%);
    transition: transform .25s ease;
    z-index: 200;
    overflow-y: auto;
    box-shadow: 0 0 40px rgba(15,23,42,.18);
  }
  body.nav-open .top-nav { transform: translateX(0); }

  /* Header (que contém o drawer) precisa ficar ACIMA do backdrop quando aberto,
     senão o backdrop — irmão do header — intercepta os cliques do drawer. */
  body.nav-open .app-header { z-index: 210; }

  .top-nav-item {
    width: 100%;
    font-size: 14px;
    padding: 11px 12px;
    min-height: 44px;
  }
  .top-nav-item svg { width: 18px; height: 18px; }
  .top-nav-sep { display: none; }        /* separadores verticais não fazem sentido na lista vertical */

  /* Backdrop escuro atrás do drawer */
  .nav-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(15,23,42,.5);
    opacity: 0;
    visibility: hidden;
    transition: opacity .25s ease, visibility .25s ease;
    z-index: 150;
  }
  body.nav-open .nav-backdrop { opacity: 1; visibility: visible; }

  /* Tabelas nunca cortam: rolam na horizontal (rede de segurança) */
  .table-card { overflow-x: auto; }

  /* Alvos de toque mais confortáveis */
  .primary-button, .save-button, .secondary-button,
  .black-button, .red-button, .btn { min-height: 44px; }
}

@media (max-width: 480px) {
  .dashboard-grid     { grid-template-columns: 1fr; }
  .header-user        { padding-left: 8px; }
  .header-user-name   { display: none; }   /* avatar + seta bastam; economiza espaço */
}

/* ============================================================
   GRIDS INLINE — colapso no celular
   Várias telas (EC/Pesquisa, EC/NovoPedido, Orçamento) definem grids de
   2–5 colunas via style="" inline, sem media query. No celular viram colunas
   ilegíveis. Este seletor atinge SÓ grids inline (os problemáticos) — grids
   definidos em classe ficam intactos, pois já têm seu próprio responsivo.
   O !important é necessário para vencer o style inline.
   ============================================================ */
@media (max-width: 640px) {
  [style*="grid-template-columns"] { grid-template-columns: 1fr !important; }
}
