:root {
  --emg-accent: #d89b1a;
  --emg-accent-soft: #f2d08b;
  --emg-accent-strong: #b8860b;
  --emg-bg: #f8f9fa;
  --emg-surface: #ffffff;
  --emg-border: #eeeeee;
  --emg-text: #333333;
  --emg-muted: #666666;
  --emg-menu-bg: #f3d79e;
  --emg-menu-bg-2: #f8e7bf;
  --emg-menu-border: #e4bf71;
  --emg-menu-text: #3d2d08;
  --emg-menu-active: #b8860b;
  --emg-menu-active-2: #9f7106;
  --emg-menu-sub-bg: #ffffff;
  --emg-menu-sub-hover: #fff3d8;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  min-height: 100%;
  margin: 0;
}

body.emg-theme {
  min-height: 100vh;
  min-height: 100dvh;
  color: var(--emg-text);
  background: radial-gradient(circle at 8% 12%, rgba(216, 155, 26, 0.14), transparent 38%),
    linear-gradient(145deg, #ffffff 40%, #fdf8f0 100%);
}

body.emg-theme a,
body.emg-theme a:hover,
body.emg-theme a:focus {
  text-decoration: none;
}

.emg-brand {
  color: var(--emg-accent-strong);
  font-weight: 700;
}

/* Login definitivo */
.emg-login-page {
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.4rem;
  background-image: linear-gradient(rgba(13, 17, 24, 0.35), rgba(13, 17, 24, 0.5)),
    url('../img/login-bg-monitor-angle.jpg');
  background-size: cover;
  background-position: center;
}

.emg-login-card {
  width: 100%;
  max-width: 430px;
  border: 1px solid rgba(216, 155, 26, 0.28);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.26);
  padding: 2rem;
}

.emg-login-logo {
  width: 220px;
  max-width: 100%;
  display: block;
  margin: 0 auto 1.5rem;
}

.emg-input-label {
  font-weight: 600;
  color: #3a4552;
  font-size: 0.9rem;
  margin-bottom: 0.45rem;
}

.form-control.emg-input {
  border-radius: 10px;
  border: 1px solid #d7dee7;
  min-height: 44px;
  padding: 0.7rem 0.9rem;
}

.form-control.emg-input:focus {
  border-color: var(--emg-accent);
  box-shadow: 0 0 0 0.2rem rgba(216, 155, 26, 0.22);
}

/* Padrao global de formato para botoes Bootstrap/ERP sem alterar paleta */
.btn,
button.btn,
input.btn,
a.btn {
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.42rem;
  min-height: 38px;
  font-weight: 600;
}

.btn.btn-sm,
.btn-group-sm > .btn {
  border-radius: 8px;
  min-height: 32px;
}

.btn.btn-lg,
.btn-group-lg > .btn {
  border-radius: 12px;
  min-height: 44px;
}

.btn .fa,
.btn .fas,
.btn .far,
.btn .fab {
  line-height: 1;
}

.btn-emg {
  background: var(--emg-accent);
  border: 1px solid var(--emg-accent);
  color: #ffffff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.42rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 0.74rem;
  border-radius: 10px;
  min-height: 44px;
}

.btn-emg:hover,
.btn-emg:focus {
  background: var(--emg-accent-strong);
  border-color: var(--emg-accent-strong);
  color: #ffffff;
}

.emg-login-card .btn-emg {
  width: 100%;
}

.emg-btn-icon {
  width: 0.95rem;
  height: 0.95rem;
}

.emg-login-footer {
  text-align: center;
  margin-top: 1rem;
}

.emg-login-footer img {
  height: 22px;
}

/* Shell principal com menu no topo e iframe abaixo */
.emg-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--emg-bg);
}

.emg-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
 
  background: #ffffff;
  border-bottom: 1px solid var(--emg-border);
}

.emg-topline-logo {
  height: 60px;
  width: auto;
}

.emg-topline-user {
  color: var(--emg-muted);
  font-size: 0.86rem;
  font-weight: 600;
}

.emg-topline-right {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
}

.emg-env-chip {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.2rem 0.6rem;
  font-size: 0.67rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #5d4300;
  background: #fff3d8;
  border: 1px solid #f0d49a;
}

#cssmenu {
  background: linear-gradient(90deg, var(--emg-menu-bg) 0%, var(--emg-menu-bg-2) 48%, var(--emg-menu-bg) 100%);
  border-top: 1px solid var(--emg-menu-border);
  border-bottom: 1px solid var(--emg-menu-border);
  width: 100%;
  position: relative;
  z-index: 10;
}

#cssmenu,
#cssmenu ul,
#cssmenu li,
#cssmenu a {
  margin: 0;
  padding: 0;
  list-style: none;
  text-decoration: none;
}

#cssmenu > ul {
  display: flex;
  flex-wrap: wrap;
}

#cssmenu > ul > li {
  position: relative;
}

#cssmenu > ul > li > a {
  display: block;
  color: var(--emg-menu-text);
  padding: 14px 16px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border-bottom: 2px solid transparent;
  transition: all 0.2s ease;
}

#cssmenu > ul > li:hover > a,
#cssmenu > ul > li.active > a {
  background: linear-gradient(180deg, var(--emg-menu-active) 0%, var(--emg-menu-active-2) 100%);
  color: #ffffff;
  border-bottom-color: #8a6304;
}

#cssmenu li.has-sub > a::after {
  content: '\f078';
  font-family: 'FontAwesome';
  margin-left: 7px;
  font-size: 8px;
  font-weight: 400;
  line-height: 1;
  display: inline-block;
  vertical-align: middle;
  opacity: 0.9;
}

#cssmenu > ul > li.has-sub > a::after {
  font-size: 14px;
}

#cssmenu ul ul {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 210px;
  background: var(--emg-menu-sub-bg);
  border: 1px solid #ebd7a9;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
}

#cssmenu ul ul li {
  position: relative;
}

#cssmenu ul ul li a {
  display: block;
  color: #263444;
  font-size: 13px;
  padding: 10px 12px;
  white-space: nowrap;
  border-left: 3px solid transparent;
}

#cssmenu ul ul li:hover > a,
#cssmenu ul ul li.active > a {
  background: var(--emg-menu-sub-hover);
  border-left-color: var(--emg-accent);
  color: #111827;
}

#cssmenu ul ul ul {
  top: 0;
  left: 100%;
}

#cssmenu li:hover > ul {
  display: block;
}

#menu-button {
  display: none;
  color: var(--emg-menu-text);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 14px 16px;
  cursor: pointer;
}

.parent {
  flex: 1 1 auto;
  display: flex;
  min-height: 0;
  position: relative;
  overflow: hidden;
}

.parent iframe {
  flex: 1 1 auto;
  width: 100%;
  height: auto;
  min-height: 0;
  border: 0;
  background: #ffffff;
}

.emg-contextbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 40px;
  padding: 0.45rem 0.9rem;
  border-bottom: 1px solid var(--emg-border);
  background: #ffffff;
}

.emg-context-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: #3b4552;
}

.emg-context-status {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  color: #6a7482;
  font-size: 0.78rem;
  font-weight: 600;
}

.emg-loading-dot {
  width: 0.52rem;
  height: 0.52rem;
  border-radius: 50%;
  background: #78b56f;
}

.emg-loading-dot.is-loading {
  background: #d89b1a;
  animation: emgPulse 1s infinite ease-in-out;
}

.emg-iframe-loading {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 0.65rem;
  background: rgba(255, 255, 255, 0.82);
  z-index: 4;
  color: #4f5b68;
  font-size: 0.86rem;
  font-weight: 700;
}

.emg-iframe-loading.is-visible {
  display: flex;
}

.emg-loader-spinner {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 3px solid #ecd6a6;
  border-top-color: #c18a10;
  animation: emgSpin 0.8s linear infinite;
}

/* Páginas internas */
.emg-content-page {
  min-height: 100%;
  padding: 1.2rem;
  background: #f8fafc;
}

.emg-card {
  border: 1px solid var(--emg-border);
  border-radius: 14px;
  background: var(--emg-surface);
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.08);
}

body.emg-theme .card-header {
  background: linear-gradient(135deg, #fff8e7 0%, #f3d79e 45%, #d89b1a 100%);
  color: #4d3400;
  font-weight: 700;
  border-bottom: 1px solid #d3a34a;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

body.emg-theme .emg-card .card-header {
  border-top-left-radius: 14px;
  border-top-right-radius: 14px;
}

.emg-subtitle {
  color: var(--emg-muted);
  font-size: 0.92rem;
}

.emg-section-title {
  display: inline-flex;
  align-items: center;
  gap: 0.46rem;
  color: var(--emg-accent-strong);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.emg-section-title::before {
  content: "\f15c";
  font-family: "FontAwesome", "Font Awesome 5 Free";
  font-weight: 900;
  font-size: 0.9rem;
  line-height: 1;
  color: #a97709;
  transform: translateY(-1px);
}

.emg-section-heading {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-height: 42px;
  margin-bottom: 0.85rem;
  padding: 0.58rem 0.9rem;
  border: 1px solid #d9b061;
  border-radius: 10px;
  background: linear-gradient(180deg, #fff8ea 0%, #f7dfad 100%);
  color: #5c4100;
  font-size: 0.82rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

.emg-section-heading::before {
  content: "\f0c9";
  font-family: "FontAwesome", "Font Awesome 5 Free";
  font-weight: 900;
  font-size: 0.92rem;
  color: #8a6304;
  line-height: 1;
}

.emg-section-heading[data-emg-icon="dados"]::before {
  content: "\f085";
}

.emg-section-heading[data-emg-icon="preco"]::before {
  content: "\f0d6";
}

.emg-section-heading[data-emg-icon="lista"]::before {
  content: "\f022";
}

.emg-section-heading[data-emg-icon="api"]::before {
  content: "\f1e6";
}

.btn-emg-outline {
  background: transparent;
  border: 1px solid var(--emg-accent);
  color: var(--emg-accent-strong);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.74rem;
  border-radius: 10px;
  padding: 0.56rem 1.12rem;
}

.btn-emg-outline:hover {
  background: var(--emg-accent);
  color: #ffffff;
}

.table.emg-table {
  margin-bottom: 0;
  border-collapse: separate;
  border-spacing: 0;
  border: 1px solid #e7ebf0;
  border-radius: 0 0 12px 12px;
  overflow: hidden;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.06);
  background: #ffffff;
}

.table.emg-table thead th {
  background: linear-gradient(180deg, #fff8ea 0%, #fff2d5 100%);
  color: #5a3a00;
  border-bottom: 1px solid #ead4a2;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

.table.emg-table thead th a,
.table.emg-table thead th a:visited,
.table.emg-table thead th a:hover,
.table.emg-table thead th a:focus {
  color: #111111;
  text-decoration: none;
}

.table.emg-table tbody td {
  border-top: 1px solid #e9edf2;
}

.table.emg-table tbody tr:nth-child(odd) > * {
  background-color: #fcfdff !important;
}

.table.emg-table tbody tr:nth-child(even) > * {
  background-color: #f7f9fc !important;
}

.table.emg-table tbody tr:hover > * {
  background-color: #eef3f8 !important;
}

/* Afinamento global de bordas de tabelas (novo layout + classes legadas) */
body.emg-theme table {
  border-color: #dbe2ea;
}

body.emg-theme table.table,
body.emg-theme table.emg-table,
body.emg-theme table.tableLista,
body.emg-theme table.tabela,
body.emg-theme table.tabela_filtro,
body.emg-theme table.tabelaSemFundo {
  border-width: 1px !important;
  border-style: solid;
  border-color: #dbe2ea !important;
  border-collapse: collapse !important;
  border-spacing: 0 !important;
}

body.emg-theme table.table > :not(caption) > * > *,
body.emg-theme table.emg-table th,
body.emg-theme table.emg-table td,
body.emg-theme table.tableLista th,
body.emg-theme table.tableLista td,
body.emg-theme table.tabela th,
body.emg-theme table.tabela td,
body.emg-theme table.tabela_filtro th,
body.emg-theme table.tabela_filtro td,
body.emg-theme table.tabelaSemFundo th,
body.emg-theme table.tabelaSemFundo td {
  border-width: 1px !important;
  border-color: #e4e9ef !important;
}

/* Segunda passada: tabelas legadas Bootstrap sem emg-table */
body.emg-theme .table.table-bordered:not(.emg-table) {
  border: 1px solid #dbe2ea !important;
  border-collapse: collapse !important;
  border-spacing: 0 !important;
}

body.emg-theme .table.table-bordered:not(.emg-table) > :not(caption) > * > * {
  border: 1px solid #e4e9ef !important;
}

.table.emg-table tbody a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.28rem 0.58rem;
  border-radius: 8px;
  border: 1px solid #d6dfea;
  background: #ffffff;
  color: #334155;
  font-size: 0.74rem;
  font-weight: 700;
  line-height: 1.1;
  transition: all 0.2s ease;
}

.table.emg-table tbody a:visited {
  color: #334155;
}

.table.emg-table tbody a:hover,
.table.emg-table tbody a:focus {
  background: #fff2d7;
  border-color: #e5bf73;
  color: #5f4200;
}

.emg-chip {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 700;
  padding: 0.28rem 0.58rem;
  border: 1px solid transparent;
}

.emg-chip.success {
  color: #1d5f2a;
  background: #ebf8ee;
  border-color: #c9ebd0;
}

.emg-chip.pending {
  color: #7b5500;
  background: #fff5dd;
  border-color: #f5dfaa;
}

.emg-chip.danger {
  color: #7a2020;
  background: #ffeded;
  border-color: #f3c5c5;
}

.emg-kpi-card {
  padding: 0.95rem 1rem;
  min-height: 108px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.emg-kpi-label {
  color: #74603a;
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
}

.emg-kpi-value {
  margin-top: 0.3rem;
  color: #2f2f2f;
  font-size: 1.85rem;
  font-weight: 800;
  line-height: 1;
}

.emg-shortcuts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 0.65rem;
}

.emg-shortcut-link {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 0.78rem;
  border-radius: 10px;
  border: 1px solid #edd8a7;
  background: #fff8e9;
  color: #6d4d00;
  font-weight: 700;
  font-size: 0.84rem;
}

.emg-shortcut-link:hover {
  text-decoration: none;
  background: #f9e6bd;
  color: #3c2b03;
}

@media (max-width: 992px) {
  #menu-button {
    display: block;
  }

  #cssmenu > ul {
    display: none;
    flex-direction: column;
  }

  #cssmenu > ul.open {
    display: flex;
  }

  #cssmenu > ul > li > a {
    border-bottom: 1px solid rgba(78, 57, 12, 0.14);
  }

  #cssmenu ul ul {
    position: static;
    border: 0;
    box-shadow: none;
    background: #f8ebc9;
    display: none;
  }

  #cssmenu ul ul li a {
    color: #5d450b;
    padding-left: 1.3rem;
  }

  #cssmenu ul ul li:hover > a {
    background: #edd59f;
    color: #2e2104;
  }

  #cssmenu li.has-sub.open > ul {
    display: block;
  }

  .parent {
    min-height: 68vh;
  }
}

@keyframes emgSpin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes emgPulse {
  0% {
    opacity: 0.5;
  }
  50% {
    opacity: 1;
  }
  100% {
    opacity: 0.5;
  }
}
