/* ==========================================================================
   Camada de tema — carregada DEPOIS do adminlte.css e do style.css
   Não substitui o AdminLTE: reescreve a superfície dele.
   ========================================================================== */

:root {
  /* Tinta e papel */
  --ink:        #121A2B;
  --ink-soft:   #2A3447;
  --paper:      #F2F4F7;
  --surface:    #FFFFFF;
  --surface-2:  #F8FAFC;
  --line:       #E1E6ED;
  --line-soft:  #EDF1F6;

  /* Texto */
  --text:       #16202F;
  --text-2:     #596679;
  --text-3:     #8A95A6;

  /* Marca e estados */
  --brand:      #1B5E8C;
  --brand-ink:  #11456A;
  --brand-wash: #E8F1F8;
  --ok:         #0E7C5A;
  --ok-wash:    #E4F3EC;
  --warn:       #B45309;
  --warn-wash:  #FBF0E2;
  --danger:     #B42318;
  --danger-wash:#FBE9E7;
  --neutral:    #64748B;
  --neutral-wash:#EEF1F5;

  /* Preenchimento dos botões: precisa segurar texto branco nos dois temas,
     por isso não acompanha o clareamento dos tokens acima. */
  --brand-solid:  #1B5E8C;
  --brand-solid-h:#11456A;
  --ok-solid:     #0E7C5A;
  --ok-solid-h:   #0B6A4D;
  --warn-solid:   #B45309;
  --warn-solid-h: #96430A;
  --danger-solid: #B42318;
  --danger-solid-h:#97180F;

  /* Forma */
  --r-card:  10px;
  --r-ctl:   8px;
  --r-pill:  999px;

  /* Elevação — só para o que realmente flutua */
  --lift-nav: 0 -1px 0 var(--line), 0 -8px 24px rgba(18, 26, 43, .06);
  --lift-pop: 0 12px 32px rgba(18, 26, 43, .14);

  /* Tipografia */
  --sans: "IBM Plex Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --nav-h: 58px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ink:        #0B111C;
    --ink-soft:   #16202F;
    --paper:      #0E1520;
    --surface:    #16202F;
    --surface-2:  #1C283A;
    --line:       #263349;
    --line-soft:  #1F2B3D;
    --text:       #E6EBF2;
    --text-2:     #9FADC0;
    --text-3:     #6F7F94;
    --brand:      #4F9BD1;
    --brand-ink:  #6FB1E0;
    --brand-wash: #152B3D;
    --ok:         #39B98A;
    --ok-wash:    #112E25;
    --warn:       #E09545;
    --warn-wash:  #2E2214;
    --danger:     #EE7A6F;
    --danger-wash:#2F1A18;
    --neutral:    #90A0B5;
    --neutral-wash:#1D2838;
    --brand-solid:  #2176AB;
    --brand-solid-h:#1B5E8C;
    --ok-solid:     #11875F;
    --ok-solid-h:   #0E7250;
    --warn-solid:   #A95B12;
    --warn-solid-h: #8D4B0E;
    --danger-solid: #B8392C;
    --danger-solid-h:#9C2C21;
    --lift-pop:   0 12px 32px rgba(0, 0, 0, .5);
  }
}

:root[data-theme="dark"] {
  --ink:        #0B111C;
  --ink-soft:   #16202F;
  --paper:      #0E1520;
  --surface:    #16202F;
  --surface-2:  #1C283A;
  --line:       #263349;
  --line-soft:  #1F2B3D;
  --text:       #E6EBF2;
  --text-2:     #9FADC0;
  --text-3:     #6F7F94;
  --brand:      #4F9BD1;
  --brand-ink:  #6FB1E0;
  --brand-wash: #152B3D;
  --ok:         #39B98A;
  --ok-wash:    #112E25;
  --warn:       #E09545;
  --warn-wash:  #2E2214;
  --danger:     #EE7A6F;
  --danger-wash:#2F1A18;
  --neutral:    #90A0B5;
  --neutral-wash:#1D2838;
  --brand-solid:  #2176AB;
  --brand-solid-h:#1B5E8C;
  --ok-solid:     #11875F;
  --ok-solid-h:   #0E7250;
  --warn-solid:   #A95B12;
  --warn-solid-h: #8D4B0E;
  --danger-solid: #B8392C;
  --danger-solid-h:#9C2C21;
  --lift-pop:   0 12px 32px rgba(0, 0, 0, .5);
}

/* --------------------------------------------------------------------------
   Base
   -------------------------------------------------------------------------- */

html { -webkit-text-size-adjust: 100%; }

body,
body.text-sm {
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--paper);
  font-feature-settings: "tnum" 1, "cv05" 1;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

h1, h2, h3, h4, h5, h6 { font-family: var(--sans); color: var(--text); letter-spacing: -.012em; }
h6.m-0.text-dark { font-size: 1.0625rem; font-weight: 600; color: var(--text) !important; letter-spacing: -.016em; }

a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-ink); text-decoration: none; }

:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: 4px;
}

::selection { background: var(--brand-wash); color: var(--brand-ink); }

/* Algarismos tabulares onde número é dado, não texto */
.table td, .table th,
.info-box-number,
.m-card__value,
.money, input.money { font-variant-numeric: tabular-nums; }

/* --------------------------------------------------------------------------
   Chave de acesso e códigos fiscais
   -------------------------------------------------------------------------- */

.chave, .fiscal-code {
  font-family: var(--mono);
  font-size: .8125rem;
  letter-spacing: .01em;
  color: var(--text-2);
  word-break: break-all;
}
.chave { font-variant-numeric: tabular-nums; }

/* --------------------------------------------------------------------------
   Barra superior
   -------------------------------------------------------------------------- */

.main-header.navbar {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  box-shadow: none;
  min-height: 56px;
  padding-left: 4px;
  padding-right: 4px;
}
.main-header.navbar .nav-link {
  color: var(--text-2);
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-ctl);
}
.main-header.navbar .nav-link:hover { color: var(--text); background: var(--surface-2); }
.main-header.navbar .navbar-nav .nav-item[style] {
  font-size: .9375rem !important;
  font-weight: 600 !important;
  color: var(--text) !important;
  display: flex;
  align-items: center;
  letter-spacing: -.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 48vw;
}

/* --------------------------------------------------------------------------
   Sidebar
   -------------------------------------------------------------------------- */

.main-sidebar,
.main-sidebar.sidebar-light-info {
  background: var(--ink);
  box-shadow: none !important;
  border-right: 1px solid transparent;
}
.main-sidebar .brand-link {
  background: var(--ink);
  border-bottom: 1px solid rgba(255, 255, 255, .08);
  padding: 1rem .75rem;
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.main-sidebar .brand-link .brand-text,
.main-sidebar .brand-link b {
  color: #FFF;
  font-weight: 600;
  font-size: 1rem;
  letter-spacing: -.01em;
}
.nav-sidebar .nav-header {
  color: rgba(255, 255, 255, .42);
  font-size: .6875rem;
  font-weight: 600;
  letter-spacing: .06em;
  padding: 1.25rem 1rem .4rem;
}
.nav-sidebar .nav-header:empty { padding: .5rem 0 0; }
.nav-sidebar .nav-item > .nav-link {
  color: rgba(255, 255, 255, .76);
  border-radius: 0;
  padding: .66rem 1rem;
  margin: 1px 0;
  font-size: .9375rem;
  font-weight: 450;
  position: relative;
  display: flex;
  align-items: center;
  min-height: 44px;
}
.nav-sidebar .nav-item > .nav-link .nav-icon {
  width: 1.4rem;
  margin-right: .6rem;
  font-size: .95rem;
  color: rgba(255, 255, 255, .52);
}
.nav-sidebar .nav-item > .nav-link:hover {
  background: rgba(255, 255, 255, .06);
  color: #FFF;
}
.nav-sidebar .nav-item > .nav-link.active,
.nav-pills .nav-link.active {
  background: rgba(255, 255, 255, .1) !important;
  color: #FFF !important;
  box-shadow: none !important;
  font-weight: 600;
}
/* A régua: o mesmo motivo do card de lista, aqui marcando a página atual */
.nav-sidebar .nav-item > .nav-link.active::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--brand-ink);
}
.nav-sidebar .nav-item > .nav-link.active .nav-icon { color: #FFF; }
/* Item de suporte com cor forçada inline no HTML antigo */
.nav-sidebar .nav-item[style] { background: transparent !important; }
.nav-sidebar .nav-item[style] > .nav-link[style] {
  padding-left: 1rem !important;
  background: var(--ok);
  color: #FFF !important;
  border-radius: var(--r-ctl);
  margin: .5rem .6rem;
}

/* --------------------------------------------------------------------------
   Conteúdo
   -------------------------------------------------------------------------- */

.content-wrapper { background: var(--paper); }
.content { padding-top: 1.25rem; }
.content-header { display: none; }

.breadcrumb {
  background: transparent;
  padding: 0;
  margin: 0;
  font-size: .8125rem;
}
.breadcrumb-item, .breadcrumb-item.active { color: var(--text-3); }
.breadcrumb-item a { color: var(--text-2); }
.breadcrumb-item + .breadcrumb-item::before { color: var(--text-3); }

/* --------------------------------------------------------------------------
   Cards
   -------------------------------------------------------------------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  box-shadow: none;
  margin-bottom: 1rem;
}
.card-header {
  background: transparent;
  border-bottom: 1px solid var(--line-soft);
  padding: .85rem 1rem;
  border-radius: var(--r-card) var(--r-card) 0 0;
}
.card-header h6 { margin: 0; font-size: .9375rem; font-weight: 600; }
.card-header h6 i { color: var(--text-3); margin-right: .3rem; }
.card-body { padding: 1rem; }
.card-footer {
  background: var(--surface-2) !important;
  border-top: 1px solid var(--line-soft);
  border-radius: 0 0 var(--r-card) var(--r-card);
  padding: .85rem 1rem;
}

/* --------------------------------------------------------------------------
   Info-box do painel — número é o herói
   -------------------------------------------------------------------------- */

.info-box {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  box-shadow: none;
  min-height: auto;
  padding: .9rem 1rem;
  display: flex;
  align-items: center;
  gap: .85rem;
  overflow: hidden;
}
.info-box-icon,
.info-box .info-box-icon.bg-default {
  width: 40px; height: 40px;
  min-width: 40px;
  border-radius: var(--r-ctl);
  background: var(--brand-wash) !important;
  box-shadow: none !important;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.info-box-icon img { width: 100%; height: 100%; object-fit: contain; padding: 4px !important; }
.info-box-content { padding: 0; margin: 0; flex: 1; min-width: 0; }
.info-box-text {
  display: block;
  font-size: .75rem;
  font-weight: 500;
  color: var(--text-2);
  letter-spacing: .005em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.info-box-number {
  display: block;
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.15;
  letter-spacing: -.02em;
  margin-top: .1rem;
}

/* --------------------------------------------------------------------------
   Tabelas
   -------------------------------------------------------------------------- */

.table { color: var(--text); margin-bottom: 0; }
.table thead th {
  background: var(--surface-2);
  border-bottom: 1px solid var(--line) !important;
  border-top: 0 !important;
  color: var(--text-2);
  font-size: .75rem;
  font-weight: 600;
  letter-spacing: .01em;
  padding: .6rem .7rem;
  white-space: nowrap;
  vertical-align: middle;
}
.table td {
  border-top: 1px solid var(--line-soft) !important;
  padding: .6rem .7rem;
  vertical-align: middle;
  font-size: .875rem;
}
.table-bordered, .table-bordered td, .table-bordered th { border-color: var(--line-soft) !important; }

/* 44 dígitos numa linha só empurram toda a tabela para fora da tela */
.table td.is-chave,
.table.text-nowrap td.is-chave {
  font-family: var(--mono);
  font-size: .75rem;
  color: var(--text-2);
  white-space: normal;
  word-break: break-all;
  max-width: 24ch;
  line-height: 1.35;
}
.table-striped tbody tr:nth-of-type(odd) { background: transparent; }
.table-hover tbody tr:hover { background: var(--surface-2); color: var(--text); }
.table-head-fixed thead th { position: sticky; top: 0; z-index: 2; }

/* --------------------------------------------------------------------------
   Carimbo de status — bloco com régua, não pílula
   -------------------------------------------------------------------------- */

.stamp {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  padding: .2rem .5rem .2rem .45rem;
  border-left: 3px solid var(--neutral);
  background: var(--neutral-wash);
  color: var(--neutral);
  font-size: .6875rem;
  font-weight: 600;
  letter-spacing: .04em;
  border-radius: 0 4px 4px 0;
  white-space: nowrap;
}
.stamp--ok     { border-color: var(--ok);     background: var(--ok-wash);     color: var(--ok); }
.stamp--warn   { border-color: var(--warn);   background: var(--warn-wash);   color: var(--warn); }
.stamp--danger { border-color: var(--danger); background: var(--danger-wash); color: var(--danger); }
.stamp--brand  { border-color: var(--brand);  background: var(--brand-wash);  color: var(--brand); }

.badge { font-weight: 600; font-size: .6875rem; padding: .3em .55em; border-radius: 4px; }

/* --------------------------------------------------------------------------
   Botões
   -------------------------------------------------------------------------- */

.btn {
  border-radius: var(--r-ctl);
  font-weight: 550;
  font-size: .875rem;
  padding: .5rem .9rem;
  min-height: 40px;
  border: 1px solid transparent;
  transition: background-color .12s ease, border-color .12s ease, color .12s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
}
.btn:focus, .btn.focus { box-shadow: none; }
.btn i { font-size: .875em; }

.btn-success  { background: var(--ok-solid);     border-color: var(--ok-solid);     color: #FFF; }
.btn-success:hover  { background: var(--ok-solid-h);     border-color: var(--ok-solid-h);     color: #FFF; }
.btn-info     { background: var(--brand-solid);  border-color: var(--brand-solid);  color: #FFF; }
.btn-info:hover     { background: var(--brand-solid-h);  border-color: var(--brand-solid-h);  color: #FFF; }
.btn-primary  { background: var(--brand-solid);  border-color: var(--brand-solid);  color: #FFF; }
.btn-primary:hover  { background: var(--brand-solid-h);  border-color: var(--brand-solid-h);  color: #FFF; }
.btn-danger   { background: var(--danger-solid); border-color: var(--danger-solid); color: #FFF; }
.btn-danger:hover   { background: var(--danger-solid-h); border-color: var(--danger-solid-h); color: #FFF; }
.btn-warning  { background: var(--warn-solid);   border-color: var(--warn-solid);   color: #FFF; }
.btn-warning:hover  { background: var(--warn-solid-h);   border-color: var(--warn-solid-h);   color: #FFF; }
.btn-default,
.btn-secondary {
  background: var(--surface);
  border-color: var(--line);
  color: var(--text);
}
.btn-default:hover, .btn-secondary:hover { background: var(--surface-2); border-color: var(--text-3); color: var(--text); }
.btn-block { width: 100%; }
.btn:disabled, .btn.disabled { opacity: .45; }

/* Botões de ação nas linhas — alvo de toque de verdade */
.style-action,
.btn.style-action {
  padding: 0 !important;
  width: 36px;
  min-width: 36px;
  height: 36px;
  min-height: 36px;
  border-radius: var(--r-ctl);
}
@media (pointer: coarse) {
  .style-action, .btn.style-action { width: 44px; min-width: 44px; height: 44px; min-height: 44px; }
}
.button-voltar {
  height: auto !important;
  min-height: 36px;
  padding-top: .35rem !important;
}

/* Estado de carregamento — impede emitir a nota duas vezes */
.btn.is-busy { position: relative; color: transparent !important; pointer-events: none; }
.btn.is-busy > * { visibility: hidden; }
.btn.is-busy::after {
  content: "";
  position: absolute;
  width: 16px; height: 16px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  color: #FFF;
  animation: app-spin .6s linear infinite;
}
.btn-default.is-busy::after, .btn-secondary.is-busy::after { color: var(--text-2); }
@keyframes app-spin { to { transform: rotate(360deg); } }

/* --------------------------------------------------------------------------
   Formulários
   -------------------------------------------------------------------------- */

.form-group { margin-bottom: .9rem; }
.form-group > label,
label {
  font-size: .8125rem;
  font-weight: 550;
  color: var(--text-2);
  margin-bottom: .3rem;
}
.form-control {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-ctl);
  color: var(--text);
  font-size: 1rem;           /* 16px evita o zoom automático do iOS */
  min-height: 44px;
  height: auto !important;
  padding: .5rem .7rem;
  box-shadow: none;
  transition: border-color .12s ease, box-shadow .12s ease;
}
.form-control:focus {
  background: var(--surface);
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-wash);
  color: var(--text);
}
.form-control::placeholder { color: var(--text-3); }
.form-control:disabled, .form-control[readonly] { background: var(--surface-2); color: var(--text-3); }
textarea.form-control { min-height: 84px; }

.input-group-text {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-ctl);
  color: var(--text-2);
  min-height: 44px;
}
.input-group > .form-control:not(:last-child) { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.input-group > .input-group-append > .input-group-text { border-top-left-radius: 0; border-bottom-left-radius: 0; }

/* Select2 alinhado ao resto */
.select2-container--default .select2-selection--single,
.select2-container--bootstrap4 .select2-selection--single {
  background: var(--surface);
  border: 1px solid var(--line) !important;
  border-radius: var(--r-ctl) !important;
  height: 44px !important;
  display: flex;
  align-items: center;
  padding: 0 .7rem;
}
.select2-container--default .select2-selection--single .select2-selection__rendered {
  color: var(--text);
  line-height: 1.4;
  padding: 0;
  font-size: 1rem;
}
.select2-container--default .select2-selection--single .select2-selection__arrow { height: 42px; right: 6px; }
.select2-dropdown {
  background: var(--surface);
  border-color: var(--line);
  border-radius: var(--r-ctl);
  box-shadow: var(--lift-pop);
}
.select2-container--default .select2-results__option { color: var(--text); padding: .6rem .7rem; }
.select2-container--default .select2-results__option--highlighted[aria-selected] { background: var(--brand); }
.select2-search--dropdown .select2-search__field {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--r-ctl);
  font-size: 1rem;
  min-height: 40px;
}

/* --------------------------------------------------------------------------
   Modais
   -------------------------------------------------------------------------- */

.modal-content {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--lift-pop);
}
.modal-header {
  border-bottom: 1px solid var(--line-soft);
  padding: .9rem 1rem;
  align-items: center;
}
.modal-title { font-size: 1rem; font-weight: 600; }
.modal-header .close {
  color: var(--text-2);
  text-shadow: none;
  opacity: 1;
  padding: 0;
  margin: -.5rem -.5rem -.5rem auto;
  width: 44px; height: 44px;
}
.modal-body { padding: 1rem; }
.modal-footer { border-top: 1px solid var(--line-soft); padding: .85rem 1rem; gap: .5rem; }
.modal-backdrop.show { opacity: .5; }

/* --------------------------------------------------------------------------
   DataTables
   -------------------------------------------------------------------------- */

.dataTables_wrapper .dataTables_filter input,
.dataTables_wrapper .dataTables_length select {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-ctl);
  color: var(--text);
  min-height: 40px;
  padding: .3rem .6rem;
}
.dataTables_wrapper .dataTables_info,
.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_filter { color: var(--text-2); font-size: .8125rem; }
.page-link {
  background: var(--surface);
  border-color: var(--line);
  color: var(--text-2);
  min-width: 40px;
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.page-item.active .page-link { background: var(--brand-solid); border-color: var(--brand-solid); color: #FFF; }

/* --------------------------------------------------------------------------
   Rodapé
   -------------------------------------------------------------------------- */

.main-footer {
  background: transparent;
  border-top: 1px solid var(--line);
  color: var(--text-3);
  font-size: .75rem;
  padding: .9rem 1rem;
}
.main-footer strong { color: var(--text-2); font-weight: 550; }

/* --------------------------------------------------------------------------
   Login
   -------------------------------------------------------------------------- */

body.login-page {
  background: var(--paper);
  padding: 1.25rem;
  align-items: center;
}
.login-box { width: 100%; max-width: 380px; }
.login-box > .card { border-radius: 14px; }
.login-card-body { padding: 1.75rem 1.5rem; border-radius: 14px; background: var(--surface); }
.login-logo {
  font-size: 1.375rem;
  margin-bottom: .25rem;
  color: var(--text);
  letter-spacing: -.02em;
}
.login-box-msg { color: var(--text-2); font-size: .875rem; padding: 0 0 1.25rem; }
.login-page .btn-default {
  background: var(--brand-solid);
  border-color: var(--brand-solid);
  color: #FFF;
  min-height: 46px;
  font-weight: 600;
}
.login-page .btn-default:hover { background: var(--brand-solid-h); border-color: var(--brand-solid-h); color: #FFF; }

/* --------------------------------------------------------------------------
   Lista em cards — o JS gera isto a partir das tabelas existentes
   -------------------------------------------------------------------------- */

.m-cards { display: none; }
.m-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 3px solid var(--neutral);
  border-radius: 0 var(--r-card) var(--r-card) 0;
  padding: .8rem .9rem;
  margin-bottom: .6rem;
}
.m-card--ok     { border-left-color: var(--ok); }
.m-card--warn   { border-left-color: var(--warn); }
.m-card--danger { border-left-color: var(--danger); }
.m-card--brand  { border-left-color: var(--brand); }

.m-card__top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: .6rem;
  margin-bottom: .15rem;
}
.m-card__value {
  font-size: 1.1875rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -.02em;
  line-height: 1.2;
}
.m-card__title {
  font-size: .9375rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.m-card__sub {
  font-size: .8125rem;
  color: var(--text-2);
  margin-top: .1rem;
}
.m-card__sub .chave { display: block; margin-top: .15rem; font-size: .75rem; }

.m-card__meta {
  display: flex;
  flex-wrap: wrap;
  gap: .15rem .9rem;
  margin-top: .5rem;
  padding-top: .5rem;
  border-top: 1px dashed var(--line);
}
.m-card__field { font-size: .75rem; color: var(--text-2); min-width: 0; }
.m-card__field b { color: var(--text-3); font-weight: 550; }

.m-card__actions {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  margin-top: .6rem;
}
.m-card__actions .btn { min-height: 40px; }
/* Na lista em cards há espaço para dizer o que o botão faz */
.m-card__actions .style-action,
.m-card__actions .btn.style-action {
  width: auto;
  min-width: 44px;
  padding: 0 .75rem !important;
  gap: .35rem;
  font-size: .8125rem;
}
.m-card__actions .btn.is-icon-only { padding: 0 !important; width: 44px; }

/* Chave encurtada no meio: o começo é igual em todas, o fim identifica */
.m-card .chave {
  display: block;
  margin-top: .25rem;
  font-size: .75rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* --------------------------------------------------------------------------
   Navegação inferior — gerada pelo JS a partir da sidebar
   -------------------------------------------------------------------------- */

.app-bottomnav { display: none; }

/* --------------------------------------------------------------------------
   Vazio e carregando
   -------------------------------------------------------------------------- */

.app-empty {
  text-align: center;
  padding: 2.5rem 1.25rem;
  color: var(--text-2);
}
.app-empty__icon { font-size: 1.75rem; color: var(--text-3); margin-bottom: .6rem; }
.app-empty__title { font-weight: 600; color: var(--text); margin-bottom: .2rem; }
.app-empty__text { font-size: .875rem; max-width: 34ch; margin: 0 auto 1rem; }

.app-offline {
  position: fixed;
  left: 0; right: 0;
  bottom: 0;
  z-index: 1080;
  background: var(--warn);
  color: #FFF;
  font-size: .8125rem;
  font-weight: 550;
  text-align: center;
  padding: .55rem 1rem calc(.55rem + env(safe-area-inset-bottom));
  transform: translateY(100%);
  transition: transform .2s ease;
}
.app-offline.is-on { transform: translateY(0); }

/* --------------------------------------------------------------------------
   SweetAlert2
   -------------------------------------------------------------------------- */

.swal2-popup {
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
  font-family: var(--sans);
}
.swal2-title { color: var(--text); font-size: 1.0625rem; font-weight: 600; }
.swal2-html-container, .swal2-content { color: var(--text-2); font-size: .9375rem; }
.swal2-styled.swal2-confirm { background: var(--brand-solid) !important; border-radius: var(--r-ctl) !important; }
.swal2-styled.swal2-cancel  { background: var(--surface-2) !important; color: var(--text) !important; border: 1px solid var(--line) !important; border-radius: var(--r-ctl) !important; }
.swal2-toast { box-shadow: var(--lift-pop) !important; border: 1px solid var(--line); }

/* --------------------------------------------------------------------------
   Impressão — o DANFE não pode herdar nada disto
   -------------------------------------------------------------------------- */

@media print {
  .main-sidebar, .main-header, .main-footer,
  .app-bottomnav, .no-print, .breadcrumb, .app-offline { display: none !important; }
  .content-wrapper { margin: 0 !important; background: #FFF !important; }
  .card { border: 0 !important; }
  body { background: #FFF !important; color: #000 !important; }
}

/* ==========================================================================
   CELULAR — abaixo de 768px
   ========================================================================== */

@media (max-width: 767.98px) {

  body { font-size: 15px; }

  /* Espaço para a barra inferior */
  .content-wrapper { padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 12px); }
  .main-footer { display: none; }

  .content { padding-top: .9rem; }
  .container-fluid { padding-left: .85rem; padding-right: .85rem; }

  /* O breadcrumb não ajuda em tela pequena; o título basta */
  .content .row:first-child .breadcrumb { display: none; }
  .content .row:first-child .col-sm-6:last-child { display: none; }
  h6.m-0.text-dark { font-size: 1.25rem; letter-spacing: -.025em; }

  .card { border-radius: var(--r-card); margin-bottom: .75rem; }
  .card-body { padding: .85rem; }

  /* Painel: dois indicadores por linha, compactos */
  .info-box { padding: .75rem .85rem; gap: .6rem; margin-bottom: .6rem !important; }
  .info-box-icon, .info-box .info-box-icon.bg-default { width: 34px; height: 34px; min-width: 34px; }
  .info-box-number { font-size: 1.25rem; }
  .info-box-text { font-size: .6875rem; }
  .content .row > [class*="col-"].col-12.col-sm-6 { flex: 0 0 50%; max-width: 50%; }

  /* A sidebar vira gaveta de verdade: fora da tela até ser puxada */
  .main-sidebar,
  body.sidebar-mini .main-sidebar {
    width: 270px;
    margin-left: 0 !important;
    transform: translateX(-100%);
    transition: transform .22s ease;
    z-index: 1038;
  }
  body.sidebar-open .main-sidebar { transform: translateX(0); }
  .content-wrapper,
  .main-header,
  .main-footer,
  body.sidebar-mini .content-wrapper,
  body.sidebar-mini .main-header,
  body.sidebar-mini .main-footer { margin-left: 0 !important; }

  .app-scrim {
    position: fixed;
    inset: 0;
    z-index: 1037;
    background: rgba(9, 14, 23, .5);
    opacity: 0;
    pointer-events: none;
    transition: opacity .22s ease;
  }
  body.sidebar-open .app-scrim { opacity: 1; pointer-events: auto; }

  /* As tabelas somem e os cards gerados aparecem */
  .has-m-cards .table-responsive,
  .has-m-cards > .table,
  .has-m-cards .dataTables_wrapper { display: none !important; }
  .has-m-cards .m-cards { display: block; }

  /* Virando lista de cards, o contêiner não precisa mais ser um card:
     a moldura dupla é o que deixa a tela com cara de remendo. */
  .card.has-m-cards {
    background: transparent;
    border: 0;
    margin-bottom: .35rem;
  }
  .card.has-m-cards > .card-header {
    padding-left: 0;
    padding-right: 0;
    border-bottom: 0;
    padding-bottom: .45rem;
  }
  .card.has-m-cards > .card-footer {
    background: var(--surface) !important;
    border: 1px solid var(--line);
    border-radius: var(--r-card);
    margin-top: .35rem;
  }

  /* Tabela que o JS não converteu ainda rola, mas sem nowrap travando tudo */
  .table-responsive { -webkit-overflow-scrolling: touch; }
  .table.text-nowrap td, .table.text-nowrap th { white-space: normal; }

  /* Formulários empilham com respiro */
  .form-group { margin-bottom: 1rem; }
  .modal-dialog { margin: .5rem; }
  .modal-footer { flex-direction: column-reverse; }
  .modal-footer .btn { width: 100%; margin: 0; }

  /* Barra de navegação inferior */
  .app-bottomnav {
    display: flex;
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 1030;
    background: var(--surface);
    box-shadow: var(--lift-nav);
    padding-bottom: env(safe-area-inset-bottom);
    height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  }
  .app-bottomnav__item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    color: var(--text-3);
    font-size: .625rem;
    font-weight: 550;
    text-decoration: none;
    min-width: 0;
    padding: 0 2px;
  }
  .app-bottomnav__item i { font-size: 1.0625rem; }
  .app-bottomnav__item span {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .app-bottomnav__item:hover { color: var(--text-2); text-decoration: none; }
  .app-bottomnav__item.is-active { color: var(--brand); }

  /* Ação principal em destaque na barra */
  .app-bottomnav__item--primary i {
    background: var(--brand);
    color: #FFF;
    width: 38px; height: 38px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: -14px;
    box-shadow: 0 4px 12px rgba(27, 94, 140, .35);
  }
  .app-bottomnav__item--primary.is-active i { background: var(--brand-ink); }

  /* A sidebar vira gaveta, puxada pelo item "Mais" */
  body.sidebar-mini .main-sidebar { width: 270px; }
}

/* Telas muito estreitas */
@media (max-width: 359.98px) {
  .content .row > [class*="col-"].col-12.col-sm-6 { flex: 0 0 100%; max-width: 100%; }
  .app-bottomnav__item span { font-size: .5625rem; }
}

/* --------------------------------------------------------------------------
   Movimento reduzido
   -------------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
  .btn.is-busy::after { animation: none; border-top-color: currentColor; opacity: .4; }
}
