/* ===================================================================
   shared.css — CSS Global do Sistema Itaminas
   Paleta: Azul escuro (#1a3a5c) + Laranja (#e87722) + Branco
   Fonte: system-ui + fallbacks
   =================================================================== */

/* ─── Reset & base ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 14px; scroll-behavior: smooth; }

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: #0a1929;
  color: #e8edf2;
  min-height: 100vh;
  display: flex;
}

/* ─── Layout principal ─────────────────────────────────────────── */
#layout {
  display: flex;
  width: 100%;
  min-height: 100vh;
}

/* ─── Sidebar ───────────────────────────────────────────────────── */
#sidebar {
  width: 240px;
  min-width: 240px;
  background: #0f2338;
  border-right: 1px solid #1e3a58;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 100;
  transition: width 0.2s ease;
}

#sidebar-logo {
  padding: 12px 16px 10px;
  border-bottom: 1px solid #1e3a58;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 60px;
}

#sidebar-logo .sidebar-logo-img {
  max-height: 50px;
  max-width: 152px;
  object-fit: contain;
  filter: brightness(1.05);
}

#sidebar-logo .logo-text {
  font-size: 0.85rem;
  font-weight: 700;
  color: #e87722;
  letter-spacing: 0.04em;
  line-height: 1.2;
}

#sidebar-logo .logo-sub {
  font-size: 0.68rem;
  color: #7a9bb5;
  letter-spacing: 0.03em;
}

/* Nav section label */
.nav-section-label {
  font-size: 0.58rem;
  color: #4a7a9b;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 12px 16px 3px;
}

/* Dynamic tela nav link */
#sidebar nav a.nav-dinamica { opacity: 0.92; }

/* Button to create a new tela */
.btn-nova-tela {
  display: block;
  width: calc(100% - 24px);
  margin: 6px 12px 4px;
  padding: 6px 10px;
  background: transparent;
  border: 1px dashed #2a5a8c;
  border-radius: 6px;
  color: #5a9bc4;
  font-size: 0.73rem;
  cursor: pointer;
  text-align: left;
  transition: all 0.18s;
}
.btn-nova-tela:hover {
  background: rgba(42,90,140,0.15);
  color: #7ab8e0;
  border-color: #3a7aae;
}

/* Nav items */
#sidebar nav { flex: 1; padding: 8px 0; }

#sidebar nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  font-size: 0.82rem;
  color: #8aacca;
  text-decoration: none;
  border-left: 3px solid transparent;
  transition: all 0.15s ease;
  line-height: 1.3;
}

#sidebar nav a:hover {
  background: rgba(232, 119, 34, 0.08);
  color: #e8f4fd;
  border-left-color: rgba(232, 119, 34, 0.4);
}

#sidebar nav a.ativo {
  background: rgba(232, 119, 34, 0.14);
  color: #e8edf2;
  border-left-color: #e87722;
  font-weight: 600;
}

#sidebar nav a .nav-num {
  font-size: 0.70rem;
  color: #4a7aa5;
  min-width: 20px;
  text-align: right;
}

/* Seção info na base do sidebar */
#sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid #1e3a58;
  font-size: 0.70rem;
  color: #4a7aa5;
}

#sidebar-footer .modo-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.modo-simulacao { background: rgba(40, 167, 69, 0.18); color: #5cb85c; }
.modo-monitoramento { background: rgba(232, 119, 34, 0.18); color: #e87722; }

/* ─── Área de conteúdo ─────────────────────────────────────────── */
#main {
  margin-left: 240px;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background: #0a1929;
}

/* Topbar */
#topbar {
  height: 56px;
  background: #1a3a5c;
  display: flex;
  align-items: center;
  padding: 0 24px;
  border-bottom: 1px solid #1e4f7a;
  position: sticky;
  top: 0;
  z-index: 50;
  gap: 16px;
}

#topbar .page-title {
  font-size: 1rem;
  font-weight: 700;
  color: #e8edf2;
  letter-spacing: 0.02em;
}

#topbar .page-subtitle {
  font-size: 0.75rem;
  color: #7a9bb5;
  margin-left: 4px;
}

#topbar .spacer { flex: 1; }

#topbar .topbar-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* Imagem de fundo com overlay */
.page-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  background-image: var(--bg-image, none);
  background-size: cover;
  background-position: center;
}

.page-bg::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(10, 25, 41, 0.82);
}

/* Conteúdo scrollável */
#content {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
}

/* ─── Cards ─────────────────────────────────────────────────────── */
.card {
  background: rgba(26, 58, 92, 0.35);
  border: 1px solid rgba(30, 79, 122, 0.5);
  border-radius: 8px;
  margin-bottom: 20px;
  overflow: hidden;
}

.card-header {
  background: rgba(26, 58, 92, 0.6);
  padding: 12px 18px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid rgba(30, 79, 122, 0.4);
}

.card-header h3 {
  font-size: 0.88rem;
  font-weight: 700;
  color: #e8edf2;
  letter-spacing: 0.02em;
}

.card-header .card-badge {
  font-size: 0.65rem;
  background: rgba(232, 119, 34, 0.2);
  color: #e87722;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.card-body { padding: 18px; }

/* ─── Tabelas ───────────────────────────────────────────────────── */
.tabela-anual {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.80rem;
}

.tabela-anual thead th {
  background: #1a3a5c;
  color: #7ac5f0;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 8px 10px;
  text-align: center;
  border: 1px solid rgba(30, 79, 122, 0.5);
  white-space: nowrap;
}

.tabela-anual thead th.col-label {
  text-align: left;
  min-width: 180px;
}

.tabela-anual thead th.col-ano { min-width: 90px; }

.tabela-anual tbody tr {
  transition: background 0.1s;
}

.tabela-anual tbody tr:hover { background: rgba(26, 58, 92, 0.25); }

.tabela-anual tbody td {
  padding: 7px 10px;
  border: 1px solid rgba(30, 79, 122, 0.3);
  color: #d0dce8;
  vertical-align: middle;
  position: relative;
}

.tabela-anual tbody td.td-label {
  color: #8aacca;
  font-weight: 500;
  font-size: 0.79rem;
  background: rgba(15, 35, 56, 0.3);
  padding-left: 12px;
}

.td-label-editable {
  padding-right: 44px !important;
  position: relative;
}

.td-row-actions {
  margin-left: auto;
  display: inline-flex;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.tabela-anual tbody tr:hover .td-row-actions,
.tabela-anual tbody tr:hover .btn-static-row-delete {
  opacity: 1;
}

.tabela-anual tbody td.td-label.grupo {
  color: #e8edf2;
  font-weight: 700;
  font-size: 0.80rem;
  background: rgba(26, 58, 92, 0.5);
  padding-left: 8px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

/* Células input */
.tabela-anual td.td-input { padding: 4px 6px; }

.cell-input {
  width: 100%;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(30, 79, 122, 0.6);
  border-radius: 4px;
  color: #e8edf2;
  font-size: 0.80rem;
  padding: 5px 8px;
  text-align: right;
  transition: all 0.15s;
  outline: none;
}

.cell-input:focus {
  background: rgba(255, 255, 255, 0.12);
  border-color: #e87722;
  box-shadow: 0 0 0 2px rgba(232, 119, 34, 0.2);
}

.cell-input:hover:not(:focus) {
  border-color: rgba(232, 119, 34, 0.4);
}

.cell-input-readonly,
.cell-select:disabled {
  background: rgba(122, 197, 240, 0.08);
  border-color: rgba(232, 119, 34, 0.55);
  color: #cfe7f8;
  cursor: default;
}

/* Células calculadas */
.td-calc {
  text-align: right;
  font-size: 0.80rem;
  color: #7ac5f0;
  background: rgba(122, 197, 240, 0.04);
  position: relative;
  cursor: pointer;
  white-space: nowrap;
}

.td-calc:hover { background: rgba(122, 197, 240, 0.10); }

.td-calc .calc-value { display: inline-block; }

.td-calc .formula-icon {
  font-size: 0.65rem;
  color: #4a7aa5;
  margin-left: 4px;
  opacity: 0;
  transition: opacity 0.15s;
}

.td-calc:hover .formula-icon { opacity: 1; }

.formula-cell .formula-trigger-btn {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 20px;
  height: 20px;
  border: 0;
  border-radius: 50%;
  background: rgba(15, 35, 56, 0.9);
  color: #4a7aa5;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  transform: translateY(-2px);
  transition: opacity 0.15s ease, transform 0.15s ease, color 0.15s ease;
  z-index: 2;
}

.formula-cell:hover .formula-trigger-btn {
  opacity: 1;
  transform: translateY(0);
}

.formula-cell.formula-active .formula-trigger-btn {
  opacity: 1;
  color: #e87722;
}

.td-input-formula,
.td-select-formula,
.td-calc-override {
  background: rgba(232, 119, 34, 0.08);
}

.static-table-actions {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-static-row-delete,
.btn-td-inline {
  opacity: 0;
}

.btn-static-row-delete {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: 0;
  color: #e87070;
  cursor: pointer;
  font-size: 0.88rem;
  padding: 2px 4px;
  line-height: 1;
  z-index: 2;
  transition: opacity 0.15s ease;
}

.btn-td-inline {
  padding: 1px 5px;
  font-size: 0.65rem;
  transition: opacity 0.15s ease;
}

.is-static-hidden {
  display: none !important;
}

/* Células de texto/enum */
.td-select { padding: 4px 6px; }

.cell-select {
  width: 100%;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(30, 79, 122, 0.6);
  border-radius: 4px;
  color: #e8edf2;
  font-size: 0.79rem;
  padding: 5px 8px;
  cursor: pointer;
  outline: none;
}

.cell-select:focus { border-color: #e87722; }

/* Subtotais / destaques */
.tabela-anual tr.tr-subtotal td {
  background: rgba(26, 58, 92, 0.5);
  font-weight: 700;
  color: #e8edf2;
  border-top: 2px solid rgba(232, 119, 34, 0.4);
}

.tabela-anual tr.tr-total td {
  background: rgba(26, 58, 92, 0.7);
  font-weight: 700;
  color: #e87722;
  border-top: 2px solid #e87722;
}

/* ─── Botões ─────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 16px;
  border-radius: 5px;
  font-size: 0.80rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s ease;
  text-decoration: none;
  letter-spacing: 0.02em;
}

.btn-primary {
  background: #e87722;
  color: #ffffff;
  border-color: #e87722;
}
.btn-primary:hover { background: #d16618; border-color: #d16618; }

.btn-secondary {
  background: rgba(26, 58, 92, 0.6);
  color: #8aacca;
  border-color: rgba(30, 79, 122, 0.5);
}
.btn-secondary:hover { background: rgba(26, 58, 92, 0.9); color: #e8edf2; }

.btn-outline {
  background: transparent;
  color: #e87722;
  border-color: rgba(232, 119, 34, 0.5);
}
.btn-outline:hover { background: rgba(232, 119, 34, 0.1); }

.btn-td-acao {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  background: rgba(15, 35, 56, 0.55);
  border: 1px solid rgba(30, 79, 122, 0.45);
  border-radius: 4px;
  color: #8aacca;
  cursor: pointer;
  font-size: 0.72rem;
}

.btn-td-acao:hover {
  color: #e8edf2;
  border-color: rgba(232, 119, 34, 0.45);
}

.btn-td-excluir {
  color: #e87070;
}

.btn-sm { padding: 4px 10px; font-size: 0.74rem; }
.btn-lg { padding: 10px 22px; font-size: 0.88rem; }

/* ─── Notificações / Toast ───────────────────────────────────────── */
.flash-container {
  position: fixed;
  top: 70px;
  right: 20px;
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 360px;
}

.flash {
  padding: 10px 16px;
  border-radius: 6px;
  font-size: 0.80rem;
  display: flex;
  align-items: center;
  gap: 8px;
  animation: slideIn 0.25s ease;
}

.flash-success { background: rgba(40, 167, 69, 0.15); border: 1px solid #28a745; color: #5cb85c; }
.flash-error   { background: rgba(220, 53, 69, 0.15); border: 1px solid #dc3545; color: #e87070; }
.flash-info    { background: rgba(122, 197, 240, 0.10); border: 1px solid #7ac5f0; color: #7ac5f0; }

@keyframes slideIn {
  from { transform: translateX(30px); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

/* ─── Modal de Fórmulas ─────────────────────────────────────────── */
#formula-modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  z-index: 500;
  align-items: center;
  justify-content: center;
}

#formula-modal-overlay.aberto { display: flex; }

#formula-modal {
  background: #0f2338;
  border: 1px solid rgba(30, 79, 122, 0.7);
  border-radius: 10px;
  width: min(680px, 92vw);
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

#formula-modal-header {
  padding: 14px 18px;
  border-bottom: 1px solid rgba(30, 79, 122, 0.5);
  display: flex;
  align-items: center;
  gap: 10px;
}

#formula-modal-header h4 {
  font-size: 0.88rem;
  font-weight: 700;
  color: #e8edf2;
  flex: 1;
}

#formula-modal-header .modal-var-id {
  font-size: 0.72rem;
  color: #7ac5f0;
  font-family: 'Consolas', 'Monaco', monospace;
  background: rgba(122, 197, 240, 0.08);
  padding: 2px 8px;
  border-radius: 4px;
}

#formula-modal-body {
  padding: 18px;
  overflow-y: auto;
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 260px;
  gap: 18px;
}

/* Editor de fórmula */
.formula-editor-area {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.formula-label {
  font-size: 0.74rem;
  color: #7a9bb5;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.formula-input {
  width: 100%;
  background: rgba(10, 25, 41, 0.8);
  border: 1px solid rgba(30, 79, 122, 0.7);
  border-radius: 5px;
  color: #7ac5f0;
  font-family: 'Consolas', 'Monaco', monospace;
  font-size: 0.84rem;
  padding: 10px 12px;
  resize: vertical;
  min-height: 80px;
  outline: none;
}

.formula-input:focus { border-color: #e87722; }

.formula-escopo {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.escopo-field label {
  display: block;
  font-size: 0.72rem;
  color: #7a9bb5;
  margin-bottom: 4px;
}

.escopo-field select {
  width: 100%;
  background: rgba(10, 25, 41, 0.8);
  border: 1px solid rgba(30, 79, 122, 0.6);
  border-radius: 4px;
  color: #e8edf2;
  font-size: 0.80rem;
  padding: 6px 8px;
}

/* Painel de variáveis */
.formula-variaveis {
  border-left: 1px solid rgba(30, 79, 122, 0.4);
  padding-left: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.variaveis-search {
  width: 100%;
  background: rgba(10, 25, 41, 0.6);
  border: 1px solid rgba(30, 79, 122, 0.5);
  border-radius: 4px;
  color: #e8edf2;
  font-size: 0.78rem;
  padding: 6px 10px;
  outline: none;
}

.variaveis-lista {
  flex: 1;
  overflow-y: auto;
  max-height: 240px;
}

.var-item {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  padding: 5px 6px;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.1s;
  font-size: 0.76rem;
}

.var-item:hover { background: rgba(122, 197, 240, 0.08); }

.var-item .var-code {
  font-family: 'Consolas', monospace;
  font-size: 0.72rem;
  color: #7ac5f0;
  min-width: 0;
  word-break: break-all;
}

.var-item .var-desc {
  color: #7a9bb5;
  font-size: 0.70rem;
  line-height: 1.3;
}

.var-item .var-prefix {
  font-size: 0.62rem;
  padding: 1px 5px;
  border-radius: 3px;
  font-weight: 700;
  text-transform: uppercase;
  flex-shrink: 0;
}

.prefix-inp  { background: rgba(40, 167, 69, 0.15); color: #5cb85c; }
.prefix-calc { background: rgba(122, 197, 240, 0.12); color: #7ac5f0; }
.prefix-tbl  { background: rgba(232, 119, 34, 0.12); color: #e87722; }

#formula-modal-footer {
  padding: 12px 18px;
  border-top: 1px solid rgba(30, 79, 122, 0.5);
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: flex-end;
}

.formula-status {
  flex: 1;
  font-size: 0.74rem;
  color: #7a9bb5;
}

.formula-status.ok  { color: #5cb85c; }
.formula-status.err { color: #e87070; }

/* ─── Agrupamento de variáveis no painel ────────────────────────── */
.var-group { margin-bottom: 2px; }

.var-group-header {
  font-size: 0.68rem;
  font-weight: 700;
  color: #4a7aa5;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 8px 6px 3px;
  border-bottom: 1px dashed rgba(74, 122, 165, 0.35);
  margin-top: 4px;
  margin-bottom: 2px;
}

.var-group:first-child .var-group-header { margin-top: 0; }

.prefix-prem { background: rgba(232, 119, 34, 0.15); color: #e87722; }

/* ─── Mini-popup de fórmula ─────────────────────────────────────── */
.formula-mini-popup {
  display: none;
  position: absolute;
  z-index: 2000;
  background: #0d1f35;
  border: 1px solid rgba(30, 79, 122, 0.7);
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  min-width: 168px;
  overflow: hidden;
  flex-direction: column;
}

.formula-mini-popup.aberto { display: flex; }

.mini-popup-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  background: none;
  border: none;
  color: #e8edf2;
  font-size: 0.80rem;
  cursor: pointer;
  text-align: left;
  transition: background 0.12s;
  width: 100%;
}

.mini-popup-btn:hover { background: rgba(122, 197, 240, 0.10); }
.mini-popup-btn:not(:last-child) { border-bottom: 1px solid rgba(30, 79, 122, 0.4); }

.mp-icon { font-size: 0.88rem; }

/* ─── Tabelas dinâmicas ─────────────────────────────────────────── */
.tabela-dinamica-wrapper {
  margin-bottom: 24px;
}

.tabela-dinamica-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: rgba(26, 58, 92, 0.4);
  border: 1px solid rgba(30, 79, 122, 0.5);
  border-bottom: none;
  border-radius: 6px 6px 0 0;
}

.tabela-dinamica-header h4 {
  flex: 1;
  font-size: 0.85rem;
  font-weight: 700;
  color: #e8edf2;
}

.tabela-dinamica-header .btn-td-acao {
  background: none;
  border: 1px solid rgba(30, 79, 122, 0.5);
  color: #7a9bb5;
  font-size: 0.72rem;
  padding: 3px 8px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.12s;
}
.tabela-dinamica-header .btn-td-acao:hover { color: #e8edf2; border-color: #4a7aa5; }
.tabela-dinamica-header .btn-td-excluir { color: #e87070; }
.tabela-dinamica-header .btn-td-excluir:hover { border-color: #e87070; background: rgba(232,112,112,0.08); }

/* ─── Popup Inserir Tabela ──────────────────────────────────────── */
#popup-inserir-tabela-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  z-index: 900;
  align-items: center;
  justify-content: center;
}
#popup-inserir-tabela-overlay.aberto { display: flex; }

#popup-inserir-tabela {
  background: #0f2338;
  border: 1px solid rgba(30, 79, 122, 0.7);
  border-radius: 10px;
  width: min(540px, 94vw);
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

.popup-tabela-header {
  padding: 14px 18px;
  border-bottom: 1px solid rgba(30, 79, 122, 0.4);
  display: flex;
  align-items: center;
  gap: 10px;
}
.popup-tabela-header h4 { flex: 1; font-size: 0.88rem; font-weight: 700; color: #e8edf2; }

.popup-tabela-body {
  padding: 18px;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.form-group-popup label {
  display: block;
  font-size: 0.74rem;
  color: #7a9bb5;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 5px;
}

.form-group-popup input,
.form-group-popup select {
  width: 100%;
  background: rgba(10,25,41,0.7);
  border: 1px solid rgba(30,79,122,0.5);
  border-radius: 4px;
  color: #e8edf2;
  font-size: 0.82rem;
  padding: 7px 10px;
  outline: none;
}
.form-group-popup input:focus,
.form-group-popup select:focus { border-color: #4a7aa5; }

#linhas-popup-lista { display: flex; flex-direction: column; gap: 6px; }

.linha-popup-item {
  display: flex;
  align-items: center;
  gap: 6px;
}
.linha-popup-item input { flex: 1; }
.linha-popup-item .btn-remover-linha {
  background: none; border: none; color: #e87070; cursor: pointer; font-size: 1rem; padding: 2px 4px;
}

.popup-tabela-footer {
  padding: 12px 18px;
  border-top: 1px solid rgba(30,79,122,0.4);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* ─── Utilidades ────────────────────────────────────────────────── */
.d-flex         { display: flex; }
.align-center   { align-items: center; }
.gap-8          { gap: 8px; }
.gap-16         { gap: 16px; }
.ml-auto        { margin-left: auto; }
.text-right     { text-align: right; }
.text-center    { text-align: center; }
.text-muted     { color: #4a7aa5; }
.text-orange    { color: #e87722; }
.text-blue      { color: #7ac5f0; }
.font-mono      { font-family: 'Consolas', 'Monaco', monospace; }
.w-100          { width: 100%; }
.mb-16          { margin-bottom: 16px; }
.mb-24          { margin-bottom: 24px; }
.visually-hidden { clip: rect(0 0 0 0); clip-path: inset(50%); height: 1px;
                   overflow: hidden; position: absolute; white-space: nowrap; width: 1px; }

/* ─── Formula cell — estados universais ─────────────────────────── */

/* Base: qualquer td com botão trigger herdará position:relative do td */
.formula-cell { position: relative; }

/* Suprimir o ícone legado .formula-icon quando o trigger novo estiver presente */
.formula-cell .formula-icon { display: none !important; }

/* Glyph ƒ dentro do botão trigger */
.formula-trigger-glyph {
  font-style: italic;
  font-family: 'Georgia', 'Consolas', serif;
  font-size: 0.80rem;
  line-height: 1;
  display: block;
}

/* Célula inp_* com fórmula ativa — borda laranja sutil à esquerda */
.td-input-formula {
  border-left: 2px solid rgba(232, 119, 34, 0.55) !important;
}

/* Input dentro de td-input-formula — pointer-events off (readonly já é feito em JS) */
.td-input-formula .cell-input {
  pointer-events: none;
}

/* td-calc com fórmula do usuário (override) — borda laranja mais intensa */
.td-calc-override {
  border-left: 2px solid rgba(232, 119, 34, 0.75) !important;
}

/* Animação de célula atualizada (flash azul) */
@keyframes flashCellUpdate {
  0%   { box-shadow: inset 0 0 0 2px rgba(122, 197, 240, 0.60); }
  100% { box-shadow: none; }
}

td.atualizado,
.cell-input.atualizado,
.cell-select.atualizado {
  animation: flashCellUpdate 0.8s ease-out forwards;
}

/* (estilos de tabelas estáticas: td-label-editable, btn-static-row-delete,
   btn-td-inline e is-static-hidden já definidos acima — regras complementares
   inseridas diretamente nos blocos originais) */

/* ─── Popup Nova Tela ───────────────────────────────────────────── */
#popup-nova-tela-overlay,
#popup-mover-tabela-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  z-index: 901;
  align-items: center;
  justify-content: center;
}
#popup-nova-tela-overlay.aberto,
#popup-mover-tabela-overlay.aberto { display: flex; }

#popup-nova-tela,
#popup-mover-tabela {
  background: #0f2338;
  border: 1px solid rgba(30, 79, 122, 0.7);
  border-radius: 10px;
  width: min(420px, 94vw);
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

/* Tela dinâmica info hint */
.tela-dinamica-info {
  padding: 32px 24px;
  text-align: center;
}
.tela-dinamica-info .hint-text {
  color: #4a7aa5;
  font-size: 0.85rem;
  line-height: 1.7;
}

/* Danger outline button */
.btn-danger-outline {
  border-color: rgba(220, 53, 69, 0.5) !important;
  color: #dc8590 !important;
}
.btn-danger-outline:hover {
  background: rgba(220, 53, 69, 0.12) !important;
  border-color: rgba(220, 53, 69, 0.8) !important;
  color: #f07080 !important;
}

/* ─── Responsive (compacto) ─────────────────────────────────────── */
@media (max-width: 900px) {
  #sidebar { width: 56px; }
  #sidebar nav a .nav-label { display: none; }
  #sidebar-logo .logo-text,
  #sidebar-logo .logo-sub { display: none; }
  .nav-section-label,
  .btn-nova-tela { display: none; }
  #main { margin-left: 56px; }
}
