/* ============================================================
   CAD3D — Sistema de Orçamentos
   Design: dark mode premium, glassmorphism, micro-animações
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --red:        #e74c3c;
  --red-dark:   #c0392b;
  --red-glow:   rgba(231, 76, 60, 0.3);
  --bg:         #0f1117;
  --bg2:        #161b27;
  --bg3:        #1e2535;
  --surface:    #232b3e;
  --surface2:   #2a3348;
  --border:     rgba(255,255,255,0.07);
  --border2:    rgba(255,255,255,0.12);
  --text:       #e8eaf0;
  --text2:      #9ba3b5;
  --text3:      #6b7485;
  --green:      #2ecc71;
  --blue:       #3498db;
  --yellow:     #f39c12;
  --purple:     #9b59b6;
  --radius:     14px;
  --radius-sm:  8px;
  --shadow:     0 4px 24px rgba(0,0,0,0.4);
  --shadow-lg:  0 8px 40px rgba(0,0,0,0.6);
}

html, body {
  height: 100%;
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

body { display: flex; overflow: hidden; }

/* ===== SIDEBAR ===== */
.sidebar {
  width: 240px;
  min-width: 240px;
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 24px 16px;
  gap: 32px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 4px;
}

.brand-logo { width: 44px; height: 44px; flex-shrink: 0; }
.brand-name { font-size: 18px; font-weight: 800; letter-spacing: 2px; color: var(--text); }
.brand-sub  { font-size: 9px; font-weight: 600; letter-spacing: 4px; color: var(--text3); }

.nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  color: var(--text2);
  font-weight: 500;
  cursor: pointer;
  transition: all 0.18s ease;
  text-decoration: none;
  user-select: none;
}

.nav-item:hover { background: var(--surface); color: var(--text); }

.nav-item.active {
  background: var(--red-glow);
  color: var(--red);
  border: 1px solid rgba(231,76,60,0.2);
}

.nav-icon { font-size: 16px; width: 20px; text-align: center; }

.sidebar-footer { margin-top: auto; display: flex; flex-direction: column; gap: 8px; }

.btn-planilha {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px;
  background: var(--surface);
  border: 1px dashed var(--border2);
  border-radius: var(--radius-sm);
  color: var(--text2);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.18s;
}
.btn-planilha:hover { border-color: var(--red); color: var(--red); }

.planilha-status {
  font-size: 11px;
  color: var(--text3);
  text-align: center;
  padding: 4px;
}

/* ===== MAIN ===== */
.main {
  flex: 1;
  overflow-y: auto;
  padding: 32px 40px;
  scroll-behavior: smooth;
}

.view { display: none; animation: fadeIn 0.2s ease; }
.view.active { display: block; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
}

.page-header h1 {
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
}

.orc-id {
  font-size: 13px;
  font-weight: 600;
  color: var(--red);
  background: var(--red-glow);
  border: 1px solid rgba(231,76,60,0.25);
  padding: 6px 14px;
  border-radius: 20px;
  letter-spacing: 1px;
}

/* ===== CARD ===== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
}

.card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 18px;
}

/* ===== TIPO TABS ===== */
.tipo-tabs { display: flex; gap: 10px; flex-wrap: wrap; }

.tipo-tab {
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border2);
  background: var(--bg3);
  color: var(--text2);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.18s;
}

.tipo-tab:hover { border-color: var(--red); color: var(--text); }
.tipo-tab.active { background: var(--red-glow); border-color: var(--red); color: var(--red); }

/* ===== SEARCH ===== */
.search-row {
  display: flex;
  gap: 10px;
  margin-bottom: 18px;
}

.search-wrap { position: relative; flex: 1; }

.input-search {
  width: 100%;
  padding: 11px 16px;
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.18s;
}
.input-search:focus { border-color: var(--red); }
.input-search::placeholder { color: var(--text3); }

.busca-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0; right: 0;
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  z-index: 100;
  max-height: 280px;
  overflow-y: auto;
}

.busca-dropdown .drop-item {
  padding: 10px 14px;
  cursor: pointer;
  transition: background 0.12s;
  border-bottom: 1px solid var(--border);
}
.busca-dropdown .drop-item:last-child { border-bottom: none; }
.busca-dropdown .drop-item:hover { background: var(--surface2); }
.busca-dropdown .drop-item .di-nome { font-weight: 500; color: var(--text); }
.busca-dropdown .drop-item .di-info { font-size: 12px; color: var(--text3); margin-top: 2px; }
.busca-dropdown .drop-item .di-preco { font-weight: 700; color: var(--green); float: right; }

.hidden { display: none !important; }

/* ===== AVULSO ===== */
.form-avulso { margin-bottom: 18px; }
.avulso-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 80px auto;
  gap: 10px;
  align-items: end;
}

/* ===== INPUTS ===== */
.input {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.18s;
}
.input:focus { border-color: var(--red); }
.input::placeholder { color: var(--text3); }
textarea.input { resize: vertical; }

.input-sm {
  padding: 8px 12px;
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit;
  outline: none;
}

/* ===== TABELA ITENS ===== */
.itens-wrap { overflow-x: auto; margin-bottom: 20px; }

.tabela-itens {
  width: 100%;
  border-collapse: collapse;
}

.tabela-itens th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text3);
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}

.tabela-itens th.th-sortable {
  cursor: pointer;
  user-select: none;
  transition: color 0.2s, background 0.2s;
  border-radius: 4px;
}

.tabela-itens th.th-sortable:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
}

.sort-icon {
  display: inline-block;
  font-size: 10px;
  color: var(--text3);
  margin-left: 4px;
  transition: all 0.2s;
}

.th-sortable.active-asc .sort-icon,
.th-sortable.active-desc .sort-icon {
  color: #3498db;
  font-weight: bold;
}

.tabela-itens td {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}

.tabela-itens tbody tr {
  transition: background 0.15s, transform 0.15s;
}

.tabela-itens tbody tr:hover { background: var(--surface2); }

/* Drag and Drop & Manual Move */
.drag-handle {
  cursor: grab;
  color: var(--text3);
  font-size: 14px;
  padding: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: all 0.15s;
  user-select: none;
}

.drag-handle:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
}

.drag-handle:active {
  cursor: grabbing;
}

.tabela-itens tbody tr.is-dragging {
  opacity: 0.4;
  background: var(--bg3) !important;
  border: 1px dashed #3498db;
}

.tabela-itens tbody tr.drag-over-top td {
  border-top: 2px solid #3498db !important;
}

.tabela-itens tbody tr.drag-over-bottom td {
  border-bottom: 2px solid #3498db !important;
}

.btn-move {
  background: transparent;
  border: none;
  color: var(--text3);
  cursor: pointer;
  font-size: 11px;
  padding: 2px 4px;
  line-height: 1;
  border-radius: 3px;
  transition: all 0.15s;
}

.btn-move:hover:not(:disabled) {
  color: var(--text);
  background: rgba(255, 255, 255, 0.1);
}

.btn-move:disabled {
  opacity: 0.2;
  cursor: not-allowed;
}

.tabela-itens .empty-row td {
  text-align: center;
  color: var(--text3);
  padding: 32px;
  font-style: italic;
}

.qtd-input {
  width: 70px;
  padding: 6px 10px;
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: 6px;
  color: var(--text);
  font-family: inherit;
  text-align: center;
}

.desc-input {
  width: 80px;
  padding: 6px 10px;
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: 6px;
  color: var(--text);
  font-family: inherit;
  text-align: center;
}

.btn-del {
  background: none;
  border: none;
  color: var(--text3);
  cursor: pointer;
  font-size: 16px;
  padding: 4px 8px;
  border-radius: 6px;
  transition: all 0.15s;
}
.btn-del:hover { background: rgba(231,76,60,0.15); color: var(--red); }

.badge-mat {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  background: var(--bg3);
  color: var(--text2);
  border: 1px solid var(--border);
}

/* ===== TOTAIS E BOTÕES ===== */
.totais-linha { display: flex; gap: 40px; font-size: 14px; color: var(--text2); }
.totais-linha.total-final { font-size: 20px; font-weight: 700; color: var(--text); padding-top: 10px; border-top: 1px solid var(--border); margin-top: 6px; }

/* ======================================================== */
/* TEMPLATE EXCEL (GERAÇÃO DE PDF E PRINT)                  */
/* ======================================================== */
#print-container {
  font-family: Arial, sans-serif;
  color: #000;
  width: 820px;
  padding: 20px;
  background: white;
  border: 1px solid #ddd;
  border-radius: 8px;
  box-sizing: border-box;
}

#template-orcamento {
  width: 780px;
  background: #fff;
  color: #000;
  border: 3.5px solid #000;
  box-sizing: border-box;
  font-family: Arial, sans-serif;
}

#template-orcamento .print-header {
  text-align: center;
  padding: 12px 0;
  border-bottom: 2px solid #000;
}

#template-orcamento .print-header img {
  width: 140px;
  height: auto;
  display: block;
  margin: 0 auto;
}

#template-orcamento .print-title {
  text-align: center;
  border-bottom: 2px solid #000;
  font-weight: bold;
  font-size: 15px;
  padding: 5px 0;
}

#template-orcamento .print-info-row {
  display: flex;
  justify-content: space-between;
  padding: 5px 8px;
  border-bottom: 2px solid #000;
  font-size: 12px;
  font-weight: bold;
}

/* Tabelas de Itens */
#template-orcamento table.print-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  text-align: center;
  table-layout: fixed;
  border-bottom: 2px solid #000;
}

#template-orcamento table.print-table th {
  font-weight: bold;
  padding: 6px;
  background: #f9f9f9;
  border-bottom: 2px solid #000;
  border-right: 1px dotted #000;
}
#template-orcamento table.print-table th:last-child {
  border-right: none;
}

#template-orcamento table.print-table td {
  padding: 6px;
  border-right: 1px dotted #000;
  border-bottom: none;
}
#template-orcamento table.print-table td:last-child {
  border-right: none;
}

/* Tabelas de Condições e Prazos (Footer) */
#template-orcamento table.print-footer-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
  border-bottom: 2px solid #000;
}
#template-orcamento table.print-footer-table td {
  padding: 6px;
  border-bottom: 1.5px solid #000;
  vertical-align: middle;
}
#template-orcamento table.print-footer-table tr:last-child td {
  border-bottom: none;
}
#template-orcamento table.print-footer-table td.label-col {
  width: 140px;
  font-weight: bold;
  text-align: center;
  border-right: 1px solid #000;
}
#template-orcamento table.print-footer-table td.value-col {
  text-align: left;
}
#template-orcamento table.print-footer-table td.value-col-center {
  text-align: center;
  font-weight: bold;
}

#template-orcamento .print-contact {
  text-align: center;
  font-size: 11px;
  font-weight: bold;
  padding: 5px;
}

.red { color: var(--red) !important; }

/* ===== CLIENTE GRID ===== */
.cliente-grid { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12px; font-weight: 600; color: var(--text3); text-transform: uppercase; letter-spacing: 0.5px; }

/* ===== CONDIÇÕES ===== */
.cond-row { display: flex; flex-wrap: wrap; gap: 16px; }
.cond-item { display: flex; align-items: center; gap: 8px; cursor: pointer; color: var(--text2); font-size: 13px; }
.cond-item input { accent-color: var(--red); }

/* ===== AÇÕES ===== */
.acoes {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 8px;
  flex-wrap: wrap;
}

.btn-primary {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 12px 24px;
  background: var(--red);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 600; font-family: inherit;
  cursor: pointer;
  transition: all 0.18s;
  box-shadow: 0 4px 16px var(--red-glow);
}
.btn-primary:hover { background: var(--red-dark); transform: translateY(-1px); box-shadow: 0 6px 20px var(--red-glow); }
.btn-primary:active { transform: none; }

.btn-secondary {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 12px 24px;
  background: var(--surface2);
  color: var(--text2);
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 500; font-family: inherit;
  cursor: pointer;
  transition: all 0.18s;
}
.btn-secondary:hover { background: var(--bg3); color: var(--text); border-color: var(--text3); }

.btn-whats {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 12px 24px;
  background: #25d366;
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 600; font-family: inherit;
  cursor: pointer;
  transition: all 0.18s;
  box-shadow: 0 4px 16px rgba(37,211,102,0.3);
}
.btn-whats:hover { background: #1ebe5c; transform: translateY(-1px); }

.btn-whats-hero {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  padding: 14px 28px;
  background: linear-gradient(135deg, #25d366 0%, #128c7e 100%);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 15px; font-weight: 700; font-family: inherit;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  box-shadow: 0 6px 20px rgba(37, 211, 102, 0.35);
}
.btn-whats-hero:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 8px 25px rgba(37, 211, 102, 0.45);
}

.badge-salvo {
  display: inline-flex; align-items: center; gap: 5px;
  background: rgba(39, 174, 96, 0.15);
  color: #2ecc71;
  border: 1px solid rgba(39, 174, 96, 0.4);
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
}

.btn-img {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 12px 24px;
  background: var(--blue);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 600; font-family: inherit;
  cursor: pointer;
  transition: all 0.18s;
  box-shadow: 0 4px 16px rgba(52,152,219,0.3);
}
.btn-img:hover { background: #2980b9; transform: translateY(-1px); }

/* ===== HISTÓRICO ===== */
.filtros { display: flex; gap: 10px; }

.lista-historico { display: flex; flex-direction: column; gap: 12px; }

.hist-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: all 0.18s;
}
.hist-item:hover { border-color: var(--border2); background: var(--surface2); }

.hist-num { font-size: 12px; font-weight: 700; color: var(--red); min-width: 90px; }
.hist-info { flex: 1; }
.hist-nome { font-weight: 600; color: var(--text); }
.hist-detalhes { font-size: 12px; color: var(--text3); margin-top: 2px; }
.hist-valor { font-size: 18px; font-weight: 700; color: var(--text); min-width: 100px; text-align: right; }
.hist-acoes { display: flex; gap: 8px; }

.btn-status {
  padding: 5px 12px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
}

.status-enviado  { background: rgba(52,152,219,0.15); color: var(--blue); }
.status-aprovado { background: rgba(46,204,113,0.15); color: var(--green); }
.status-recusado { background: rgba(231,76,60,0.15);  color: var(--red); }
.status-pendente { background: rgba(243,156,18,0.15); color: var(--yellow); }

.status-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  user-select: none;
  transition: all 0.18s;
  letter-spacing: 0.5px;
}
.status-tag:hover {
  transform: translateY(-1px);
  filter: brightness(1.1);
}
.status-tag.vendido {
  background: rgba(46, 204, 113, 0.15);
  color: var(--green);
  border: 1px solid rgba(46, 204, 113, 0.25);
}
.status-tag.falta_pagamento {
  background: rgba(243, 156, 18, 0.15);
  color: var(--yellow);
  border: 1px solid rgba(243, 156, 18, 0.25);
}
.status-tag.pendente {
  background: rgba(155, 89, 182, 0.15);
  color: var(--purple);
  border: 1px solid rgba(155, 89, 182, 0.25);
}
.status-tag.nao_vendido {
  background: rgba(231, 76, 60, 0.15);
  color: var(--red);
  border: 1px solid rgba(231, 76, 60, 0.25);
}

.btn-icon {
  padding: 6px 10px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text2);
  cursor: pointer;
  font-size: 14px;
  transition: all 0.15s;
}
.btn-icon:hover { border-color: var(--red); color: var(--red); }

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text3);
}

/* ===== TABELAS COMPACTAS DE ALTA DENSIDADE ===== */
.tabela-compacta {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.tabela-compacta th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text3);
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  background: rgba(0,0,0,0.15);
}
.tabela-compacta td {
  padding: 7px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}
.tabela-compacta tbody tr:hover {
  background: var(--surface2);
}

/* ===== CONFIG GRID MULTI-COLUNAS ===== */
.config-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px 16px;
}

/* ===== DASHBOARD KPI CARDS ===== */
.dash-kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  text-align: center;
  transition: all 0.18s;
}
.dash-kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
  border-color: var(--border2);
}
.dash-kpi-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.dash-kpi-value {
  font-size: 24px;
  font-weight: 800;
  margin-top: 4px;
}
.empty-icon { font-size: 48px; margin-bottom: 16px; }

/* ===== DASHBOARD ===== */
.dashboard-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.dash-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  transition: all 0.2s;
}
.dash-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }

.dash-card.green { border-color: rgba(46,204,113,0.2); }
.dash-card.red   { border-color: rgba(231,76,60,0.2); }
.dash-card.blue  { border-color: rgba(52,152,219,0.2); }
.dash-card.yellow{ border-color: rgba(243,156,18,0.2); }
.dash-card.purple{ border-color: rgba(155,89,182,0.2); }

.dash-value {
  font-size: 32px;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 6px;
}
.dash-card.green .dash-value  { color: var(--green); }
.dash-card.red .dash-value    { color: var(--red); }
.dash-card.blue .dash-value   { color: var(--blue); }
.dash-card.yellow .dash-value { color: var(--yellow); }
.dash-card.purple .dash-value { color: var(--purple); }

.dash-label { font-size: 12px; color: var(--text3); font-weight: 500; text-transform: uppercase; letter-spacing: 0.5px; }

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg2); }
::-webkit-scrollbar-thumb { background: var(--surface2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text3); }

/* ===== TOAST ===== */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 14px 20px;
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  z-index: 999;
  animation: slideIn 0.3s ease, slideOut 0.3s ease 2.7s forwards;
}
@keyframes slideIn { from { transform: translateX(120%); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes slideOut { to { transform: translateX(120%); opacity: 0; } }

/* ===== GRID DO RODAPÉ (NOVO ORÇAMENTO COMPACTO) ===== */
.orc-bottom-grid {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 16px;
  margin-top: 16px;
}

@media (max-width: 992px) {
  .orc-bottom-grid {
    grid-template-columns: 1fr;
  }
}

.card-compact {
  padding: 16px !important;
}

/* ============================================================
   ETIQUETAS TÉRMICAS (MDK-082 - 80mm x 130mm)
   ============================================================ */
.etiquetas-container {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 20px;
  align-items: start;
}

@media (max-width: 1024px) {
  .etiquetas-container {
    grid-template-columns: 1fr;
  }
}

.thermal-roll-preview {
  background-color: #f1f5f9;
  padding: 20px;
  border-radius: var(--radius);
  box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.1);
  max-height: 75vh;
  overflow: auto;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.etiqueta-page {
  background-color: #ffffff;
  color: #000000;
  width: 130mm;
  height: 68mm;
  border: 1px dashed #cbd5e1;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  font-family: 'Inter', sans-serif;
  position: relative;
  box-sizing: border-box;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  margin-bottom: 15px;
}

.etiqueta-inner-card {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  box-sizing: border-box;
}

.etiqueta-body {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 8px 10px;
  flex: 1;
  justify-content: center;
}

.etiqueta-row-2col {
  display: flex;
  gap: 10px;
}

.etiqueta-row-2col .field-group {
  flex: 1;
}

.field-group {
  display: flex;
  flex-direction: column;
}

.etiqueta-page::after {
  content: 'Corte da Etiqueta';
  position: absolute;
  bottom: -10px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.6rem;
  color: #94a3b8;
  background-color: #f1f5f9;
  padding: 0 6px;
  border: 1px dashed #cbd5e1;
  border-radius: 4px;
  z-index: 10;
}

.etiqueta-page:last-of-type::after {
  display: none;
}

/* Tabelas e Campos da Etiqueta Térmica */
.table-etiqueta {
  width: 100%;
  height: 100%;
  border-collapse: collapse;
  border: 1.5px solid #000000;
  font-size: 11px;
  line-height: 1.4;
  color: #000;
}

.table-etiqueta td {
  border: 1px solid #000000;
  padding: 6px 10px;
  vertical-align: middle;
}

.header-title-etiqueta {
  text-align: center;
  font-weight: 700;
  font-size: 13.5px;
  letter-spacing: 2px;
  padding: 6px !important;
  background-color: #f2f2f2;
  color: #000;
}

.label-field {
  font-weight: 700;
  text-transform: uppercase;
  font-size: 9px;
  color: #444;
  letter-spacing: 0.5px;
}

.value-field {
  font-weight: 600;
  font-size: 12px;
  line-height: 1.25;
  word-break: break-word;
  color: #000;
}

.value-field.large {
  font-size: 13px;
  font-weight: 700;
}

.value-field.xlarge {
  font-size: 14.5px;
  font-weight: 800;
}

.value-field.bold {
  font-weight: 800;
  font-size: 13px;
}

.bens-table {
  width: 100%;
  border-collapse: collapse;
  border: 1.5px solid #000000;
  font-size: 9px;
  color: #000;
}

.bens-table th, .bens-table td {
  border: 1px solid #000000;
  padding: 4px 6px;
  text-align: center;
}

.bens-table th {
  background-color: #f2f2f2;
  font-weight: 700;
}

.bens-table td.align-left {
  text-align: left;
}

.bens-table td.align-right {
  text-align: right;
}

.bens-table .total-row {
  font-weight: 700;
  background-color: #fafafa;
}

.declaracao-landscape-container {
  display: grid;
  grid-template-columns: 1.25fr 0.75fr;
  gap: 8px;
  border: 1.5px solid #000000;
  padding: 6px;
  box-sizing: border-box;
  flex-grow: 1;
  height: calc(100% - 27px);
  color: #000;
}

.declaracao-landscape-container .declaracao-box {
  border: none;
  padding: 0;
  font-size: 7.5px;
  line-height: 1.3;
  text-align: justify;
}

.declaracao-landscape-container .assinatura-section {
  border-left: 1.5px solid #000000;
  padding-left: 8px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 100%;
}

.print-only-thermal-container {
  display: none !important;
  position: fixed !important;
  left: -9999px !important;
  top: 0 !important;
  width: 1px !important;
  height: 1px !important;
  overflow: hidden !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

/* Impressão Física MDK-082 / POS80 */
@page {
  size: auto;
  margin: 0mm !important;
}

@media print {
  html, body {
    margin: 0 !important;
    padding: 0 !important;
    background-color: #ffffff !important;
    color: #000000 !important;
    width: 100% !important;
    display: block !important;
    overflow: visible !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  .sidebar, .main > .view, .toast, #print-container {
    display: none !important;
  }

  .print-only-thermal-container {
    display: block !important;
    position: static !important;
    left: auto !important;
    top: auto !important;
    width: 100% !important;
    height: auto !important;
    overflow: visible !important;
    opacity: 1 !important;
    pointer-events: auto !important;
    margin: 0 auto !important;
    padding: 0 !important;
  }

  /* Cada etiqueta ocupa uma "página" do rolo de 76mm */
  .print-page-wrapper {
    position: relative !important;
    box-sizing: border-box !important;
    /* Rolo de 80mm — largura física da impressão em portrait */
    width: 76mm !important;
    max-width: 76mm !important;
    /* Comprimento do papel reservado para 1 etiqueta rotacionada */
    height: 130mm !important;
    page-break-after: always !important;
    break-after: page !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
  }

  .print-page-wrapper:last-child {
    page-break-after: avoid !important;
    break-after: avoid !important;
  }

  /* A etiqueta é desenhada em 130x74mm e rotacionada 90° para sair em landscape */
  .print-page-wrapper .etiqueta-page {
    border: 1.5px solid #000 !important;
    box-shadow: none !important;
    overflow: hidden !important;
    margin: 0 !important;
    width: 128mm !important;
    height: 74mm !important;
    position: static !important;
    transform: rotate(90deg) !important;
    transform-origin: center center !important;
    box-sizing: border-box !important;
    background: #fff !important;
    color: #000 !important;
    flex-shrink: 0 !important;
    display: flex !important;
    flex-direction: column !important;
  }

  .print-page-wrapper .etiqueta-page::after {
    display: none !important;
  }

  /* Layout interno da etiqueta na impressão */
  .etiqueta-inner-card {
    width: 100% !important;
    height: 100% !important;
    display: flex !important;
    flex-direction: column !important;
    box-sizing: border-box !important;
  }

  .etiqueta-body {
    flex: 1 !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: space-evenly !important;
    padding: 6px 10px !important;
    gap: 4px !important;
    box-sizing: border-box !important;
  }

  .etiqueta-row-2col {
    display: flex !important;
    gap: 8px !important;
  }

  .etiqueta-row-2col .field-group {
    flex: 1 !important;
  }

  .field-group {
    display: flex !important;
    flex-direction: column !important;
  }

  /* Tipografia de impressão */
  .header-title-etiqueta {
    font-size: 15px !important;
    font-weight: 900 !important;
    letter-spacing: 2px !important;
    text-align: center !important;
    padding: 5px 8px !important;
    background-color: #e0e0e0 !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  .label-field {
    font-size: 10px !important;
    font-weight: 800 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.5px !important;
    color: #333 !important;
  }

  .value-field {
    font-size: 15px !important;
    font-weight: 600 !important;
    line-height: 1.2 !important;
    color: #000 !important;
  }

  .value-field.large {
    font-size: 17px !important;
    font-weight: 700 !important;
  }

  .value-field.xlarge {
    font-size: 20px !important;
    font-weight: 800 !important;
  }

  .value-field.bold {
    font-size: 18px !important;
    font-weight: 900 !important;
  }
}

/* ============================================================
   ESTILOS MODERNOS: FRETE COM DESCONTO & DC-E (MELHOR ENVIO)
   ============================================================ */
.frete-card-opcao {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm, 6px);
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  user-select: none;
}

.frete-card-opcao:hover {
  border-color: #0984e3;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(9, 132, 227, 0.12);
}

.frete-card-opcao.selecionada {
  border-color: #0984e3;
  background: rgba(9, 132, 227, 0.05);
  box-shadow: 0 0 0 1px #0984e3, 0 4px 14px rgba(9, 132, 227, 0.15);
}

.frete-transportadora-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.frete-logo-empresa {
  width: 42px;
  height: 28px;
  object-fit: contain;
  background: white;
  border-radius: 4px;
  padding: 2px;
  border: 1px solid var(--border);
}

.frete-nome-servico {
  font-weight: 700;
  font-size: 13px;
  color: var(--text1);
  display: flex;
  align-items: center;
  gap: 6px;
}

.frete-prazo {
  font-size: 11px;
  color: var(--text3);
  margin-top: 2px;
}

.frete-valores {
  text-align: right;
}

.frete-preco-original {
  font-size: 11px;
  color: var(--text3);
  text-decoration: line-through;
  margin-right: 4px;
}

.frete-preco-final {
  font-size: 15px;
  font-weight: 800;
  color: #27ae60;
}

.frete-badge-desconto {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  background: rgba(39, 174, 96, 0.12);
  color: #27ae60;
  padding: 1px 6px;
  border-radius: 4px;
  margin-top: 2px;
}

.loading-spinner {
  width: 24px;
  height: 24px;
  border: 3px solid rgba(9, 132, 227, 0.2);
  border-top-color: #0984e3;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ============================================================
   CENTRAL DE EXPEDIÇÃO & HISTÓRICO DE ENVIOS (CAD3D LOGISTICS)
   ============================================================ */
.expedicao-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.expedicao-kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm, 8px);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.expedicao-kpi-card:hover {
  transform: translateY(-2px);
  border-color: var(--primary, #0984e3);
}

.expedicao-kpi-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.expedicao-kpi-info {
  display: flex;
  flex-direction: column;
}

.expedicao-kpi-val {
  font-size: 20px;
  font-weight: 800;
  color: var(--text1);
  line-height: 1.2;
}

.expedicao-kpi-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text3);
  margin-top: 2px;
}

/* Toolbar & Filtros */
.expedicao-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 10px 14px;
  border-radius: 8px;
}

.expedicao-tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.expedicao-tab-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text2);
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
}

.expedicao-tab-btn:hover {
  background: var(--surface2, rgba(0, 0, 0, 0.04));
  color: var(--text1);
}

.expedicao-tab-btn.ativo {
  background: var(--primary, #0984e3);
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(9, 132, 227, 0.3);
}

.expedicao-tab-badge {
  background: rgba(255, 255, 255, 0.25);
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 10px;
}

.expedicao-tab-btn:not(.ativo) .expedicao-tab-badge {
  background: var(--surface3, rgba(0, 0, 0, 0.08));
  color: var(--text2);
}

.expedicao-search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 260px;
}

.expedicao-search-box input {
  padding: 6px 12px;
  font-size: 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface2, #fff);
  color: var(--text1);
  width: 100%;
}

/* Badges de Status de Envio */
.badge-status-envio {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.badge-status-rascunho {
  background: rgba(243, 156, 18, 0.15);
  color: #d35400;
  border: 1px solid rgba(243, 156, 18, 0.3);
}

.badge-status-no_carrinho {
  background: rgba(9, 132, 227, 0.15);
  color: #0984e3;
  border: 1px solid rgba(9, 132, 227, 0.3);
}

.badge-status-comprado,
.badge-status-emitido {
  background: rgba(39, 174, 96, 0.15);
  color: #27ae60;
  border: 1px solid rgba(39, 174, 96, 0.3);
}

.badge-status-em_transito {
  background: rgba(142, 68, 173, 0.15);
  color: #8e44ad;
  border: 1px solid rgba(142, 68, 173, 0.3);
}

.badge-status-entregue {
  background: rgba(0, 184, 148, 0.15);
  color: #00b894;
  border: 1px solid rgba(0, 184, 148, 0.3);
}

.badge-status-cancelado {
  background: rgba(231, 76, 60, 0.15);
  color: #c0392b;
  border: 1px solid rgba(231, 76, 60, 0.3);
}

/* Ações na Tabela de Envios */
.expedicao-actions-cell {
  display: flex;
  align-items: center;
  gap: 6px;
  justify-content: flex-end;
}

.expedicao-btn-action {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text1);
  padding: 4px 8px;
  border-radius: 5px;
  font-size: 12px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.15s ease;
}

.expedicao-btn-action:hover {
  background: var(--surface2, rgba(0, 0, 0, 0.05));
  border-color: var(--primary, #0984e3);
  color: var(--primary, #0984e3);
}

.expedicao-btn-action.btn-whatsapp:hover {
  border-color: #25d366;
  color: #25d366;
  background: rgba(37, 211, 102, 0.08);
}

.expedicao-btn-action.btn-danger:hover {
  border-color: #e74c3c;
  color: #e74c3c;
  background: rgba(231, 76, 60, 0.08);
}

.expedicao-btn-action.btn-primary-action {
  background: var(--primary, #0984e3);
  color: white;
  border-color: var(--primary, #0984e3);
}

.expedicao-btn-action.btn-primary-action:hover {
  filter: brightness(1.1);
  color: white;
}

/* Barra de Ações do Formulário de Frete */
.frete-form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px dashed var(--border);
}





/* ============================================================
   PORTAL AUTH, HUB DO CLIENTE & RESPONSIVO MOBILE
   ============================================================ */
body { display: block; overflow-y: auto; overflow-x: hidden; }
.admin-shell { display: flex; width: 100%; height: 100vh; overflow: hidden; }

.auth-screen {
  min-height: 100vh;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: radial-gradient(circle at top, rgba(231, 76, 60, 0.14), transparent 55%), var(--bg);
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: 18px;
  padding: 28px 24px;
  box-shadow: var(--shadow-lg);
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.auth-logo { width: 40px; height: 40px; border-radius: 10px; }
.auth-title { font-size: 20px; font-weight: 700; margin-bottom: 4px; color: var(--text); }
.auth-subtitle { font-size: 13px; color: var(--text2); margin-bottom: 18px; }

.auth-error {
  background: rgba(231, 76, 60, 0.15);
  border: 1px solid rgba(231, 76, 60, 0.4);
  color: #ff8a80;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 14px;
}

.auth-switch {
  margin-top: 16px;
  text-align: center;
  font-size: 12px;
  color: var(--text3);
  display: flex;
  justify-content: center;
  gap: 10px;
}

.auth-switch a { color: var(--text2); text-decoration: none; }
.auth-switch a:hover { color: var(--text); text-decoration: underline; }

/* Hub do Cliente */
.client-hub { min-height: 100vh; background: var(--bg); }
.hub-header {
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  padding: 14px 20px;
  position: sticky;
  top: 0;
  z-index: 20;
}
.hub-header-inner {
  max-width: 980px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.hub-user-actions { display: flex; align-items: center; gap: 12px; font-size: 13px; color: var(--text2); }
.hub-main { max-width: 980px; margin: 0 auto; padding: 24px 16px 48px; }
.hub-intro h1 { font-size: 22px; margin-bottom: 4px; }
.hub-intro p { font-size: 13px; color: var(--text2); margin-bottom: 20px; }

.hub-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 14px;
}
.hub-orc-card {
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: 14px;
  padding: 16px;
  cursor: pointer;
  transition: transform .15s ease, border-color .15s ease;
}
.hub-orc-card:hover { transform: translateY(-2px); border-color: var(--red); }
.hub-orc-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; margin-bottom: 10px; }
.hub-orc-id { font-weight: 700; font-size: 15px; color: var(--text); }
.hub-orc-data { font-size: 12px; color: var(--text3); margin-top: 2px; }
.hub-orc-items-preview { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.hub-chip {
  background: var(--surface);
  color: var(--text2);
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 999px;
}
.hub-orc-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid var(--border);
  padding-top: 10px;
}
.hub-orc-total { font-size: 17px; font-weight: 700; color: var(--green); }
.hub-orc-cta { font-size: 12px; color: var(--text2); font-weight: 500; }

.hub-badge { font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
.badge-pendente { background: rgba(243, 156, 18, 0.16); color: #f39c12; }
.badge-vendido { background: rgba(46, 204, 113, 0.16); color: #2ecc71; }
.badge-parcial { background: rgba(52, 152, 219, 0.16); color: #3498db; }
.badge-perdido { background: rgba(231, 76, 60, 0.16); color: #e74c3c; }

.hub-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 40px 20px;
  background: var(--bg2);
  border: 1px dashed var(--border2);
  border-radius: 14px;
  color: var(--text3);
}

.hub-det-header { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.hub-det-totais { margin-top: 14px; padding: 12px; background: var(--bg3); border-radius: 10px; display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.hub-det-totais > div { display: flex; justify-content: space-between; }
.hub-det-total-final { font-size: 16px; color: var(--green); border-top: 1px solid var(--border); padding-top: 8px; margin-top: 4px; }
.hub-det-info { margin-top: 10px; font-size: 12px; color: var(--text2); line-height: 1.5; }
.hub-det-actions { display: flex; gap: 10px; margin-top: 18px; flex-wrap: wrap; }
.hub-det-actions button { flex: 1; min-width: 160px; padding: 11px; }

.table-responsive { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* Topbar Mobile Admin */
.mobile-topbar { display: none; }
.sidebar-backdrop { display: none; }

@media (max-width: 900px) {
  .admin-shell { flex-direction: column; height: auto; min-height: 100vh; overflow: visible; }
  .mobile-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: var(--bg2);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 40;
  }
  .mobile-menu-btn {
    background: var(--surface);
    border: 1px solid var(--border2);
    color: var(--text);
    font-size: 18px;
    padding: 4px 10px;
    border-radius: 8px;
    cursor: pointer;
  }
  .sidebar {
    position: fixed;
    top: 0;
    left: -270px;
    bottom: 0;
    width: 250px;
    z-index: 60;
    transition: left .22s ease;
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { left: 0; }
  .sidebar-backdrop.open {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 50;
  }
  .main {
    width: 100%;
    height: auto;
    overflow: visible;
    padding: 14px 12px 32px !important;
  }
  .page-header { flex-direction: column; align-items: flex-start !important; gap: 10px; }
  .calc-grid, .config-grid, .form-grid, .resumo-grid, .dashboard-cards, .kpi-grid, .charts-grid {
    grid-template-columns: 1fr !important;
  }
  .card { overflow-x: auto; }
  .hub-welcome { display: none; }
}


/* Modal do Hub do Cliente & Refinamento Mobile Clean */
.hub-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(6px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.hub-modal-content {
  width: 100%;
  max-width: 680px;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: 16px;
  padding: 20px 22px;
  box-shadow: var(--shadow-lg);
  color: var(--text);
}
.hub-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.hub-modal-close {
  background: var(--surface);
  border: 1px solid var(--border2);
  color: var(--text2);
  width: 32px;
  height: 32px;
  border-radius: 8px;
  font-size: 15px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.hub-modal-close:hover { color: var(--text); border-color: var(--red); }

.hub-modal-content .table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.hub-modal-content .table th,
.hub-modal-content .table td {
  padding: 9px 8px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}
.hub-modal-content .table th {
  font-size: 11px;
  text-transform: uppercase;
  color: var(--text3);
  font-weight: 600;
}

@media (max-width: 640px) {
  .auth-card { padding: 22px 18px; border-radius: 16px; }
  .hub-header { padding: 12px 14px; }
  .hub-main { padding: 18px 12px 36px; }
  .hub-intro h1 { font-size: 19px; }
  .hub-grid { grid-template-columns: 1fr; gap: 12px; }
  .hub-orc-card { padding: 14px; }
  .hub-modal { padding: 10px; align-items: flex-end; }
  .hub-modal-content {
    padding: 16px;
    border-radius: 16px 16px 12px 12px;
    max-height: 88vh;
  }
  .hub-det-actions { flex-direction: column; }
  .hub-det-actions button { width: 100%; }
}


/* Campos numéricos com espaço folgado para 4-5 dígitos (ex: 1000) */
input[type="number"].input {
  padding-right: 6px;
}
#calc-qtd, #calc-desc, .qtd-input-inline, .desc-input-inline {
  min-width: 78px;
}

@media (max-width: 900px) {
  .calc-row, .calc-actions-row, .bottom-grid, .hist-filters, .hist-card-header, .hist-actions {
    flex-direction: column !important;
    align-items: stretch !important;
    grid-template-columns: 1fr !important;
    gap: 10px !important;
  }
  .calc-row .field, .calc-actions-row .field {
    flex: 1 1 100% !important;
    min-width: 100% !important;
  }
  .hist-actions {
    flex-direction: row !important;
    flex-wrap: wrap !important;
  }
  .table-wrap, .tabela-compacta-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}


@media (max-width: 900px) {
  #calc-modo-impressao {
    gap: 10px !important;
  }
  #calc-modo-impressao .field {
    flex: 1 1 calc(50% - 8px) !important;
    min-width: 130px !important;
  }
  #calc-modo-impressao > div:last-child {
    width: 100%;
    border-left: none !important;
    border-top: 1px solid var(--border2);
    padding-left: 0 !important;
    padding-top: 10px;
    margin-left: 0 !important;
    gap: 10px !important;
  }
}
