/* ==========================================================================
   VERFIBSCBS - Folha de Estilos Principal
   ========================================================================== */

/* --------------------------------------------------------------------------
   Variáveis Globais e Tema
   -------------------------------------------------------------------------- */
:root {
  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --text: #172033;
  --muted: #667085;
  --primary: #2557d6;
  --primary-2: #1f4fc8;
  --primary-soft: #eef4ff;
  --line: #e5eaf0;
  --ok: #138a4a;
  --ok-soft: #ecfdf3;
  --warn: #b76a00;
  --warn-soft: #fff7e8;
  --danger: #c63535;
  --danger-soft: #fff1f1;
  --shadow: 0 10px 28px rgba(20, 37, 63, 0.07);
  --shadow-lg: 0 24px 80px rgba(15, 23, 42, 0.20);
  --radius: 16px;
  --sidebar: 248px;
}

/* --------------------------------------------------------------------------
   Reset e Configurações Básicas
   -------------------------------------------------------------------------- */
* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: Inter, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
}

input[type="file"] {
  display: none;
}

/* --------------------------------------------------------------------------
   Layout Estrutural
   -------------------------------------------------------------------------- */
.app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar) minmax(0, 1fr);
}

.workspace {
  min-width: 0;
}

main {
  padding: 26px 30px 50px;
  max-width: 1600px;
  margin: 0 auto;
  width: 100%;
}

.mainGrid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 310px;
  gap: 18px;
  align-items: start;
}

/* --------------------------------------------------------------------------
   Menu Lateral (Sidebar)
   -------------------------------------------------------------------------- */
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background: #0e1d3a;
  color: #dbe5fb;
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  z-index: 20;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 0 8px 22px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.brandMark {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: linear-gradient(135deg, #4e7df0, #2f5fd4);
  display: grid;
  place-items: center;
  box-shadow: 0 10px 28px rgba(42, 91, 211, 0.35);
}

.brandMark svg {
  width: 24px;
  height: 24px;
}

.brandText strong {
  display: block;
  color: #ffffff;
  font-size: 16px;
  letter-spacing: 0.1px;
}

.brandText span {
  font-size: 11px;
  color: #96a8cb;
}

.navLabel {
  margin: 22px 10px 8px;
  color: #7084aa;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.navBtn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 11px 12px;
  background: transparent;
  color: #b9c6de;
  border-radius: 11px;
  text-align: left;
  cursor: pointer;
  font-weight: 650;
  font-size: 13px;
  transition: 0.18s;
}

.navBtn svg {
  width: 18px;
  height: 18px;
  opacity: 0.9;
}

.navBtn:hover {
  background: rgba(255, 255, 255, 0.07);
  color: #ffffff;
}

.navBtn.active {
  background: #1d3769;
  color: #ffffff;
  box-shadow: inset 3px 0 #6f97ff;
}

.sideInfo {
  margin-top: auto;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  background: rgba(255, 255, 255, 0.04);
  border-radius: 14px;
}

.sideInfo .lock {
  font-size: 11px;
  color: #88a1ce;
  font-weight: 700;
}

.sideInfo strong {
  display: block;
  color: #ffffff;
  font-size: 12px;
  margin: 5px 0;
}

.sideInfo p {
  margin: 0;
  color: #92a5c9;
  font-size: 11px;
  line-height: 1.55;
}

/* --------------------------------------------------------------------------
   Barra Superior (Topbar)
   -------------------------------------------------------------------------- */
.topbar {
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 30px;
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 15;
  backdrop-filter: blur(14px);
}

.topLeft {
  display: flex;
  align-items: center;
  gap: 12px;
}

.mobileMenu {
  display: none;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--surface-2);
  cursor: pointer;
  color: #344054;
}

.pageTitle {
  font-size: 17px;
  font-weight: 800;
}

.pageCrumb {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
}

.privacyBadge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 11px;
  border: 1px solid #ccebd9;
  background: #f2fbf6;
  color: #217346;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
}

.privacyBadge svg {
  width: 15px;
  height: 15px;
}

/* --------------------------------------------------------------------------
   Seção Hero e Ações
   -------------------------------------------------------------------------- */
.hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.hero h1 {
  font-size: 25px;
  line-height: 1.2;
  margin: 0 0 6px;
  letter-spacing: -0.03em;
}

.hero p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.heroActions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* --------------------------------------------------------------------------
   Botões
   -------------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  border-radius: 10px;
  padding: 9px 13px;
  font-weight: 750;
  font-size: 12px;
  cursor: pointer;
  transition: 0.18s;
  text-decoration: none;
  white-space: nowrap;
}

.btn svg {
  width: 16px;
  height: 16px;
}

.btn.primary {
  background: var(--primary);
  color: #ffffff;
  box-shadow: 0 5px 14px rgba(37, 87, 214, 0.22);
}

.btn.primary:hover {
  background: var(--primary-2);
  transform: translateY(-1px);
}

.btn.secondary {
  background: #ffffff;
  color: #344054;
  border: 1px solid #d8dee7;
}

.btn.secondary:hover {
  background: #f8fafc;
}

.btn.danger {
  background: #ffffff;
  color: #b42318;
  border: 1px solid #f0c9c4;
}

.btn.danger:hover {
  background: #fff8f7;
}

.btn.icon {
  width: 34px;
  height: 34px;
  min-height: 34px;
  padding: 0;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* --------------------------------------------------------------------------
   Cards de Estatísticas (Stats)
   -------------------------------------------------------------------------- */
.stats {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.statCard {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px 17px;
  box-shadow: 0 3px 12px rgba(20, 37, 63, 0.035);
  display: flex;
  gap: 13px;
  align-items: center;
  min-width: 0;
}

.statIcon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
}

.statIcon svg {
  width: 20px;
  height: 20px;
}

.statIcon.blue {
  background: #edf3ff;
  color: #2a5bd3;
}

.statIcon.green {
  background: #edf9f2;
  color: #148448;
}

.statIcon.orange {
  background: #fff5e8;
  color: #b76a00;
}

.statIcon.amber {
  background: #fff3dc;
  color: #a85d00;
}

.statIcon.red {
  background: #fff0f0;
  color: #c63535;
}

.statMeta {
  min-width: 0;
}

.statMeta small {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  margin-bottom: 3px;
}

.statValue {
  font-size: 24px;
  font-weight: 850;
  line-height: 1;
}

.statFoot {
  font-size: 10px;
  color: #98a2b3;
  margin-top: 5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* --------------------------------------------------------------------------
   Painéis (Panels)
   -------------------------------------------------------------------------- */
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.panelHead {
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.panelTitle {
  display: flex;
  align-items: center;
  gap: 10px;
}

.panelTitleIcon {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--primary-soft);
  color: var(--primary);
  display: grid;
  place-items: center;
}

.panelTitleIcon svg {
  width: 17px;
  height: 17px;
}

.panelHead h2 {
  font-size: 14px;
  margin: 0;
  font-weight: 800;
}

.panelHead p {
  font-size: 11px;
  color: var(--muted);
  margin: 3px 0 0;
}

/* --------------------------------------------------------------------------
   Área de Upload e Progresso
   -------------------------------------------------------------------------- */
.upload {
  margin: 18px;
  border: 1.5px dashed #b9c8e2;
  border-radius: 14px;
  padding: 26px 22px;
  text-align: center;
  background: linear-gradient(180deg, #fbfdff, #f7faff);
  transition: 0.18s;
}

.upload.drag {
  border-color: var(--primary);
  background: #f1f6ff;
  box-shadow: 0 0 0 4px rgba(37, 87, 214, 0.07);
}

.uploadIcon {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: #eaf1ff;
  color: var(--primary);
  display: grid;
  place-items: center;
  margin: 0 auto 12px;
}

.uploadIcon svg {
  width: 24px;
  height: 24px;
}

.upload h3 {
  font-size: 15px;
  margin: 0 0 5px;
}

.upload p {
  margin: 0 auto 14px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
  max-width: 620px;
}

.uploadHint {
  font-size: 10px;
  color: #98a2b3;
  margin-top: 10px;
}

.progressArea {
  display: none;
  padding: 0 18px 18px;
}

.progressArea.show {
  display: block;
}

.progressTop {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  font-size: 11px;
  margin-bottom: 7px;
}

.progressText {
  color: #475467;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.progressPct {
  font-weight: 800;
  color: var(--primary);
}

.progress {
  height: 7px;
  border-radius: 999px;
  background: #eef1f5;
  overflow: hidden;
}

.bar {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #2557d6, #5b84ec);
  transition: 0.2s;
}

.quickInfo {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 0 18px 18px;
}

.miniInfo {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px;
  background: #fbfcfe;
}

.miniInfo small {
  display: block;
  color: #98a2b3;
  font-size: 10px;
  font-weight: 700;
}

.miniInfo strong {
  display: block;
  margin-top: 4px;
  font-size: 12px;
}

.miniInfo em {
  font-style: normal;
  color: var(--muted);
  font-size: 10px;
}

/* --------------------------------------------------------------------------
   Painel de Resultados, Busca e Filtros
   -------------------------------------------------------------------------- */
.resultPanel {
  margin-top: 18px;
}

.resultsHead {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
}

.searchBox {
  position: relative;
  flex: 1 1 330px;
  max-width: 520px;
}

.searchBox svg {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  width: 15px;
  height: 15px;
  color: #98a2b3;
}

.searchBox input {
  width: 100%;
  height: 38px;
  border: 1px solid #d8dee7;
  border-radius: 10px;
  padding: 0 12px 0 34px;
  outline: none;
  color: var(--text);
  background: #ffffff;
  font-size: 12px;
}

.searchBox input:focus,
.filterSelect:focus {
  border-color: #7aa0ef;
  box-shadow: 0 0 0 3px rgba(37, 87, 214, 0.08);
}

.resultTools {
  display: flex;
  gap: 8px;
  align-items: center;
}

.filterSelect {
  height: 38px;
  border: 1px solid #d8dee7;
  border-radius: 10px;
  padding: 0 30px 0 11px;
  background: #ffffff;
  color: #344054;
  outline: none;
  font-size: 12px;
}

.resultTabs {
  display: flex;
  gap: 7px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
  overflow: auto;
  align-items: stretch;
}

.resultTabGroup {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  gap: 2px;
  min-height: 43px;
}

.resultTab {
  position: relative;
  background: transparent;
  color: #667085;
  padding: 12px 7px 11px;
  cursor: pointer;
  font-weight: 750;
  font-size: 11px;
  white-space: nowrap;
}

.tabMiniActions {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding-right: 2px;
}

.tabMiniBtn {
  width: 22px;
  height: 22px;
  min-width: 22px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 5px;
  border: 1px solid #d9e0e9;
  background: #fff;
  color: #667085;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease, color .15s ease, transform .15s ease;
}

.tabMiniBtn svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.tabMiniBtn svg text {
  fill: currentColor;
  stroke: none;
  font: 800 4.8px Arial, sans-serif;
  letter-spacing: -.15px;
}

.tabMiniBtn.excel {
  color: #1f7a4d;
}

.tabMiniBtn.pdf {
  color: #c43b3b;
}

.tabMiniBtn:hover:not(:disabled) {
  background: #f7f9fc;
  border-color: #b9c5d4;
  transform: translateY(-1px);
}

.tabMiniBtn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}

.tabMiniBtn:disabled {
  opacity: .32;
  cursor: not-allowed;
  background: #f4f5f7;
}

.resultTab.active {
  color: var(--primary);
}

.resultTab.active:after {
  content: "";
  position: absolute;
  left: 9px;
  right: 9px;
  bottom: -1px;
  height: 2px;
  background: var(--primary);
  border-radius: 2px;
}

.countPill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 21px;
  height: 19px;
  padding: 0 6px;
  margin-left: 5px;
  border-radius: 999px;
  background: #f1f3f6;
  color: #667085;
  font-size: 9px;
}

.resultTab.active .countPill {
  background: #e8efff;
  color: var(--primary);
}

/* --------------------------------------------------------------------------
   Tabela de Resultados e Células
   -------------------------------------------------------------------------- */
.tableWrap {
  overflow: auto;
  max-height: 570px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 1220px;
}

th,
td {
  padding: 11px 13px;
  border-bottom: 1px solid #edf0f4;
  text-align: left;
  font-size: 11px;
  vertical-align: middle;
}

th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #fafbfc;
  color: #667085;
  font-weight: 800;
  text-transform: uppercase;
  font-size: 9px;
  letter-spacing: 0.035em;
}

.dataRow:hover td {
  background: #fbfdff;
}

.fileCell {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 240px;
}

.xmlIcon {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: #f1f5ff;
  color: #416bce;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
}

.xmlIcon svg {
  width: 15px;
  height: 15px;
}

.fileMain {
  min-width: 0;
}

.fileLink {
  display: block;
  max-width: 240px;
  color: #244fbd;
  font-weight: 800;
  cursor: pointer;
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fileLink:hover {
  text-decoration: underline;
}

.subText {
  display: block;
  color: #98a2b3;
  font-size: 9px;
  margin-top: 2px;
}

.issuerCell {
  max-width: 220px;
}

.issuerName {
  display: block;
  font-weight: 700;
  color: #344054;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.docText {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  color: #667085;
  font-size: 10px;
}

.tagStatus {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border-radius: 999px;
  padding: 5px 8px;
  font-weight: 800;
  font-size: 9px;
  white-space: nowrap;
}

.tagStatus svg {
  width: 11px;
  height: 11px;
}

.tagStatus.ok {
  background: var(--ok-soft);
  color: #157347;
}

.tagStatus.no {
  background: var(--warn-soft);
  color: #9a5b00;
}

.tagStatus.err {
  background: var(--danger-soft);
  color: #aa2929;
}

.tagStatus.calcError {
  background: #fff0e5;
  color: #a34000;
  border: 1px solid #f2c19e;
}

.dataRow.calcErrorRow td {
  background: #fffaf6;
}

.yesNo {
  font-weight: 800;
}

.yesNo.yes {
  color: var(--ok);
}

.yesNo.no {
  color: #98a2b3;
}

/* Botões interativos de cálculo nas colunas Total IBS e Total CBS */
.calcTriggerBtn {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  background: transparent;
  padding: 4px 6px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.18s ease;
  text-align: left;
  border: 1px solid transparent;
  text-decoration: none;
}

.calcTriggerBtn:hover {
  background: #f0f5ff;
  border-color: #cbdcfc;
  transform: translateY(-1px);
}

.calcTriggerBtn.ibs:hover {
  background: #edf4ff;
  border-color: #bcd5fc;
}

.calcTriggerBtn.cbs:hover {
  background: #edf9f2;
  border-color: #b8e9cc;
}

.calcValue {
  font-size: 11.5px;
  font-weight: 850;
  color: #172033;
  line-height: 1.2;
}

.calcValue.ibsHighlight {
  color: #1f4fc8;
}

.calcValue.cbsHighlight {
  color: #148448;
}

.calcBadge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 8.5px;
  font-weight: 700;
  color: #667085;
  background: #edf0f5;
  padding: 1px 5px;
  border-radius: 4px;
  transition: 0.15s;
  letter-spacing: 0.01em;
}

.calcBadge svg {
  width: 10px;
  height: 10px;
}

.calcTriggerBtn:hover .calcBadge {
  background: #ffffff;
  color: var(--primary);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.calcTriggerBtn.cbs:hover .calcBadge {
  color: #148448;
}

.actionGroup {
  display: flex;
  gap: 5px;
}

.tableAction {
  width: 29px;
  height: 29px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: #ffffff;
  color: #667085;
  border: 1px solid #e1e6ed;
  cursor: pointer;
}

.tableAction:hover {
  color: var(--primary);
  border-color: #b7c8ef;
  background: #f7f9ff;
}

.tableAction svg {
  width: 14px;
  height: 14px;
}

/* --------------------------------------------------------------------------
   Estado Vazio (Empty State)
   -------------------------------------------------------------------------- */
.empty {
  padding: 46px 20px;
  text-align: center;
  color: var(--muted);
}

.emptyIcon {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #f3f5f8;
  color: #98a2b3;
  margin: 0 auto 10px;
}

.emptyIcon svg {
  width: 20px;
  height: 20px;
}

.empty strong {
  display: block;
  color: #475467;
  font-size: 12px;
  margin-bottom: 4px;
}

.empty span {
  font-size: 11px;
}

/* --------------------------------------------------------------------------
   Coluna Lateral Direita (Right Column & Widgets)
   -------------------------------------------------------------------------- */
.sidePanel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-bottom: 18px;
}

.sidePanelHead {
  padding: 15px 16px;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  font-weight: 800;
}

/* Gráfico Donut */
.donutWrap {
  padding: 18px;
  text-align: center;
}

.donut {
  --pct: 0;
  position: relative;
  width: 138px;
  height: 138px;
  border-radius: 50%;
  margin: 0 auto;
  background: conic-gradient(var(--primary) calc(var(--pct) * 1%), #e9edf3 0);
  display: grid;
  place-items: center;
}

.donut:before {
  content: "";
  width: 102px;
  height: 102px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: inset 0 0 0 1px #eff1f4;
}

.donutCenter {
  position: absolute;
  text-align: center;
}

.donutCenter strong {
  display: block;
  font-size: 23px;
}

.donutCenter span {
  font-size: 10px;
  color: #98a2b3;
}

.legend {
  margin-top: 16px;
  display: grid;
  gap: 8px;
}

.legendRow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 10px;
}

.legendName {
  display: flex;
  align-items: center;
  gap: 7px;
  color: #667085;
}

.legendDot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.legendDot.blue {
  background: var(--primary);
}

.legendDot.gray {
  background: #e9edf3;
}

.legendRow strong {
  font-size: 10px;
}

/* Bloco de Segurança */
.securityBox {
  padding: 16px;
}

.securityLine {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin-bottom: 12px;
}

.securityLine:last-child {
  margin: 0;
}

.securityLineIcon {
  width: 29px;
  height: 29px;
  border-radius: 9px;
  background: #f0f6ff;
  color: var(--primary);
  display: grid;
  place-items: center;
  flex: 0 0 auto;
}

.securityLineIcon svg {
  width: 14px;
  height: 14px;
}

.securityLine strong {
  display: block;
  font-size: 10px;
  margin-bottom: 3px;
}

.securityLine p {
  margin: 0;
  color: #7a8699;
  font-size: 10px;
  line-height: 1.45;
}

.errorBox {
  margin: 16px;
  background: #fff7f7;
  border: 1px solid #f1d1d1;
  border-radius: 12px;
  padding: 12px;
}

.errorBox strong {
  display: block;
  color: #a92c2c;
  font-size: 11px;
  margin-bottom: 3px;
}

.errorBox span {
  font-size: 10px;
  color: #885555;
}

/* --------------------------------------------------------------------------
   Modal e Abas de Detalhes
   -------------------------------------------------------------------------- */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(10, 19, 37, 0.62);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 22px;
  backdrop-filter: blur(3px);
}

.modal.open {
  display: flex;
}

.modalPanel {
  width: min(1240px, 98vw);
  height: min(820px, 93vh);
  background: #ffffff;
  border-radius: 18px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
}

.modalHead {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.modalFile {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.modalFileIcon {
  width: 37px;
  height: 37px;
  border-radius: 10px;
  background: #edf3ff;
  color: var(--primary);
  display: grid;
  place-items: center;
}

.modalFileIcon svg {
  width: 18px;
  height: 18px;
}

.modalFileName {
  font-size: 13px;
  font-weight: 850;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 650px;
}

.modalSub {
  font-size: 10px;
  color: #98a2b3;
  margin-top: 2px;
}

.right {
  display: flex;
  gap: 7px;
  align-items: center;
}

.modalTabs {
  display: flex;
  gap: 2px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
  overflow: auto;
}

.modalTab {
  position: relative;
  padding: 12px 11px;
  background: transparent;
  cursor: pointer;
  color: #667085;
  font-weight: 750;
  font-size: 11px;
  white-space: nowrap;
}

.modalTab.active {
  color: var(--primary);
}

.modalTab.active:after {
  content: "";
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: -1px;
  height: 2px;
  background: var(--primary);
}

.modalContent {
  padding: 18px;
  overflow: auto;
  flex: 1;
  background: #fbfcfe;
}

.summaryBanner {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 13px;
  border-radius: 12px;
  margin-bottom: 14px;
}

.summaryBanner.good {
  background: #effaf3;
  border: 1px solid #d0ead9;
  color: #17623a;
}

.summaryBanner.warn {
  background: #fff8eb;
  border: 1px solid #f1dfba;
  color: #855711;
}

.summaryBanner.danger {
  background: #fff1ea;
  border: 1px solid #f2c5ad;
  color: #9a3c0b;
}

.summaryBanner svg {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  margin-top: 1px;
}

.summaryBanner strong {
  display: block;
  font-size: 11px;
  margin-bottom: 2px;
}

.summaryBanner span {
  font-size: 10px;
}

.sectionTitle {
  font-size: 11px;
  font-weight: 850;
  margin: 16px 0 9px;
  color: #344054;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.kv {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 11px;
  min-height: 65px;
}

.kv b {
  display: block;
  color: #98a2b3;
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 6px;
}

.kv span {
  display: block;
  font-size: 11px;
  font-weight: 700;
  word-break: break-word;
}

.xmlToolbar {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.xmlbox {
  white-space: pre;
  tab-size: 2;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  background: #0b1324;
  color: #dce6ff;
  border: 1px solid #182440;
  padding: 16px;
  border-radius: 12px;
  font-size: 10px;
  line-height: 1.65;
  overflow: auto;
  max-height: 61vh;
}


.pdfPreviewInfo {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  margin-bottom: 10px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
}

.pdfPreviewInfo > div {
  min-width: 0;
}

.pdfPreviewInfo strong,
.pdfPreviewInfo span {
  display: block;
}

.pdfPreviewInfo strong {
  font-size: 11px;
  margin-bottom: 2px;
}

.pdfPreviewInfo span {
  font-size: 10px;
  line-height: 1.45;
}

.pdfPreviewInfo.good {
  border-color: #cfe5d8;
  background: #f3fbf6;
  color: #17623a;
}

.pdfPreviewInfo.warn {
  border-color: #eed9ae;
  background: #fff9ed;
  color: #855711;
}

.pdfPreviewInfo.danger {
  border-color: #f0bea0;
  background: #fff4ed;
  color: #963d0b;
}

.pdfPreviewHint {
  flex: 0 0 auto;
  color: inherit;
  opacity: .8;
  max-width: 280px;
  text-align: right;
}

.pdfFrame {
  width: 100%;
  height: 72vh;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #ffffff;
}

.taxSummary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.taxCard {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 12px;
}

.taxCard small {
  display: block;
  color: #98a2b3;
  font-size: 9px;
  font-weight: 800;
  text-transform: uppercase;
}

.taxCard strong {
  display: block;
  margin-top: 5px;
  font-size: 14px;
}

.taxCard strong.ok {
  color: var(--ok);
}

.taxCard strong.no {
  color: #98a2b3;
}

/* --------------------------------------------------------------------------
   Notificação Toast
   -------------------------------------------------------------------------- */
.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 200;
  display: none;
  align-items: center;
  gap: 9px;
  background: #14223e;
  color: #ffffff;
  padding: 11px 13px;
  border-radius: 11px;
  box-shadow: 0 12px 36px rgba(15, 23, 42, 0.25);
  font-size: 11px;
  font-weight: 700;
}

.toast.show {
  display: flex;
}

/* --------------------------------------------------------------------------
   Modal de Memória de Cálculo (IBS e CBS)
   -------------------------------------------------------------------------- */
.calcModalPanel {
  width: min(1200px, 98vw);
  height: min(870px, 94vh);
}

.modalFileIcon.calcIcon {
  background: #ecfdf3;
  color: #148448;
}

.calcModalTabs .modalTab {
  display: flex;
  align-items: center;
  gap: 6px;
}

.calcTabBadge {
  display: inline-flex;
  align-items: center;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 9.5px;
  font-weight: 800;
  background: #edf0f5;
  color: #475467;
}

.modalTab.active .calcTabBadge.ibs {
  background: #e8efff;
  color: #1f4fc8;
}

.modalTab.active .calcTabBadge.cbs {
  background: #e7f7ed;
  color: #148448;
}

.modalTab.active .calcTabBadge.both {
  background: #f2eaff;
  color: #6932d5;
}

.calcFormulaBox {
  padding: 14px 16px;
  border-radius: 12px;
  margin-bottom: 16px;
  transition: 0.2s;
}

.calcFormulaBox.ibs {
  background: #f3f7fe;
  border: 1px solid #d2e3fc;
}

.calcFormulaBox.cbs {
  background: #f2fbf6;
  border: 1px solid #cbebd9;
}

.calcFormulaBox.both {
  background: #f8f6fd;
  border: 1px solid #e7ddfb;
}

.calcFormulaHead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.calcFormulaTitle {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  font-weight: 850;
  color: #172033;
}

.calcFormulaTitle svg {
  width: 17px;
  height: 17px;
}

.calcFormulaEq {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 11px;
  line-height: 1.55;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.9);
  border-radius: 8px;
  border: 1px dashed rgba(37, 87, 214, 0.25);
  color: #1d2939;
  font-weight: 600;
}

.calcFormulaDesc {
  font-size: 11px;
  color: #475467;
  margin-top: 7px;
  line-height: 1.5;
}

.calcSummaryGrid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.calcCard {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  box-shadow: 0 1px 4px rgba(20, 37, 63, 0.02);
}

.calcCard small {
  display: block;
  font-size: 9px;
  font-weight: 800;
  color: #98a2b3;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.calcCard strong {
  display: block;
  font-size: 17px;
  font-weight: 850;
  margin-top: 4px;
  color: #172033;
}

.calcCard strong.ibs {
  color: #1f4fc8;
}

.calcCard strong.cbs {
  color: #148448;
}

.calcCard strong.both {
  color: #6932d5;
}

.calcCard span {
  display: block;
  font-size: 10px;
  color: #667085;
  margin-top: 2px;
}

.calcReconcileBanner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 13px;
  border-radius: 10px;
  margin-bottom: 14px;
  font-size: 11px;
  font-weight: 700;
}

.calcReconcileBanner.ok {
  background: #edf9f2;
  border: 1px solid #c4eed6;
  color: #127941;
}

.calcReconcileBanner.warn {
  background: #fff8eb;
  border: 1px solid #fae2b8;
  color: #9a6500;
}

.calcReconcileBanner svg {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
}

.calcTableWrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #ffffff;
  max-height: 450px;
}

.calcTable {
  width: 100%;
  border-collapse: collapse;
  min-width: 950px;
}

.calcTable th {
  padding: 10px 12px;
  background: #f8fafc;
  font-size: 9.5px;
  font-weight: 800;
  text-transform: uppercase;
  color: #667085;
  letter-spacing: 0.03em;
  position: sticky;
  top: 0;
  z-index: 2;
  border-bottom: 1px solid #eaecf0;
}

.calcTable td {
  padding: 9px 12px;
  font-size: 11px;
  border-bottom: 1px solid #f1f3f6;
  vertical-align: middle;
}

.calcTable tfoot td {
  padding: 11px 12px;
  background: #f8fafc;
  font-weight: 850;
  font-size: 11px;
  border-top: 2px solid #e2e6eb;
  border-bottom: 0;
}

.calcStepExpr {
  display: inline-block;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 9.5px;
  color: #344054;
  background: #f2f4f8;
  padding: 3px 7px;
  border-radius: 6px;
  border: 1px solid #e5e9f0;
  white-space: nowrap;
}

/* --------------------------------------------------------------------------
   Rodapé
   -------------------------------------------------------------------------- */
footer {
  text-align: center;
  color: #98a2b3;
  font-size: 10px;
  margin-top: 22px;
  line-height: 1.5;
}

/* --------------------------------------------------------------------------
   Design Responsivo (Media Queries)
   -------------------------------------------------------------------------- */
@media (max-width: 1150px) {
  .mainGrid {
    grid-template-columns: 1fr;
  }

  .rightColumn {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
  }

  .sidePanel {
    margin: 0;
  }

  .grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  :root {
    --sidebar: 0px;
  }

  .app {
    display: block;
  }

  .sidebar {
    position: fixed;
    left: -260px;
    width: 248px;
    transition: 0.2s;
    box-shadow: 20px 0 50px rgba(0, 0, 0, 0.12);
  }

  .sidebar.open {
    left: 0;
  }

  .mobileMenu {
    display: grid;
    place-items: center;
  }

  .topbar {
    padding: 0 16px;
  }

  main {
    padding: 20px 16px 40px;
  }

  .stats {
    grid-template-columns: 1fr 1fr;
  }

  .hero {
    align-items: flex-start;
    flex-direction: column;
  }

  .mainGrid {
    display: block;
  }

  .rightColumn {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    margin-top: 16px;
  }
}

@media (max-width: 620px) {
  .privacyBadge span {
    display: none;
  }

  .stats {
    grid-template-columns: 1fr;
  }

  .rightColumn {
    grid-template-columns: 1fr;
  }

  .quickInfo {
    grid-template-columns: 1fr;
  }

  .grid,
  .taxSummary {
    grid-template-columns: 1fr;
  }

  .heroActions {
    width: 100%;
  }

  .heroActions .btn {
    flex: 1;
  }

  .resultTools {
    width: 100%;
  }

  .filterSelect {
    flex: 1;
  }

  .modal {
    padding: 8px;
  }

  .modalPanel {
    width: 100%;
    height: 96vh;
    border-radius: 14px;
  }

  .modalFileName {
    max-width: 180px;
  }

  .modalHead .btn span {
    display: none;
  }

  .topbar {
    height: 64px;
  }
}

/* --------------------------------------------------------------------------
   Paginação / modo alto volume
   -------------------------------------------------------------------------- */
.paginationBar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 14px;
  border-top: 1px solid #edf0f4;
  background: #fbfcfe;
  flex-wrap: wrap;
}

.paginationSummary,
.paginationControls {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-wrap: wrap;
  color: #667085;
  font-size: 10px;
}

.paginationSummary strong {
  color: #344054;
  font-size: 11px;
}

.highVolumeHint {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: #eef4ff;
  color: #3157b7;
  font-weight: 800;
  font-size: 9px;
}

.filterSelect.compact {
  min-height: 34px;
  padding: 6px 28px 6px 9px;
  font-size: 10px;
}

.btn.compactBtn {
  min-height: 34px;
  padding: 7px 11px;
  font-size: 10px;
}

@media (max-width: 620px) {
  .paginationBar,
  .paginationControls {
    align-items: stretch;
  }
  .paginationBar {
    flex-direction: column;
  }
  .paginationControls {
    width: 100%;
  }
  .paginationControls .btn,
  .paginationControls .filterSelect {
    flex: 1 1 auto;
  }
}


/* --------------------------------------------------------------------------
   Responsividade aprimorada + novo relatório PDF (v3.9)
   -------------------------------------------------------------------------- */
.workspace,
.hero > *,
.resultsHead > *,
.panel,
.resultPanel,
.tableWrap {
  min-width: 0;
}

/* Em telas amplas as abas podem quebrar de linha, evitando corte lateral. */
.resultTabs {
  flex-wrap: wrap;
  overflow-x: visible;
  overflow-y: visible;
  row-gap: 0;
  scrollbar-width: thin;
}

.resultTabGroup {
  max-width: 100%;
}

.tabMiniBtn.reportPdf {
  color: #5b4bc4;
  background: #fbfaff;
  border-color: #ddd8f6;
}

.tabMiniBtn.reportPdf:hover:not(:disabled) {
  color: #4536ad;
  background: #f3f0ff;
  border-color: #c8c0ef;
}

/* Mantém a tabela navegável em touch sem ampliar a largura da página. */
.tableWrap {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
}

@media (max-width: 1180px) {
  .hero {
    align-items: flex-start;
    flex-direction: column;
  }

  .heroActions {
    width: 100%;
  }

  .resultsHead {
    align-items: stretch;
  }

  .searchBox {
    max-width: none;
    flex: 1 1 100%;
  }

  .resultTools {
    width: 100%;
  }

  .resultTools .filterSelect {
    width: 100%;
  }
}

@media (max-width: 900px) {
  body {
    overflow-x: hidden;
  }

  main {
    padding-left: 14px;
    padding-right: 14px;
  }

  /* Em tablet/celular as abas voltam para uma faixa horizontal rolável. */
  .resultTabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 4px 12px 2px;
    gap: 7px;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    scroll-snap-type: x proximity;
  }

  .resultTabGroup {
    scroll-snap-align: start;
  }

  .resultTab {
    padding-top: 10px;
    padding-bottom: 10px;
  }

  .heroActions .btn {
    flex: 1 1 calc(50% - 8px);
    min-width: 170px;
  }
}

@media (max-width: 620px) {
  main {
    padding: 16px 10px 34px;
  }

  .topbar {
    padding: 0 10px;
  }

  .pageCrumb {
    max-width: 210px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .hero h1 {
    font-size: 21px;
  }

  .heroActions {
    gap: 7px;
  }

  .heroActions .btn {
    flex: 1 1 calc(50% - 7px);
    min-width: 0;
    padding-left: 9px;
    padding-right: 9px;
    font-size: 11px;
  }

  .resultsHead {
    padding: 12px;
  }

  .searchBox,
  .resultTools,
  .filterSelect {
    width: 100%;
  }

  .resultTabs {
    padding-left: 9px;
    padding-right: 9px;
  }

  .resultTabGroup {
    gap: 3px;
  }

  .resultTab {
    font-size: 10.5px;
    padding-left: 5px;
    padding-right: 5px;
  }

  .tabMiniActions {
    gap: 3px;
  }

  .tabMiniBtn {
    width: 26px;
    height: 26px;
    min-width: 26px;
    border-radius: 7px;
  }

  .tabMiniBtn svg {
    width: 15px;
    height: 15px;
  }

  .tableWrap {
    max-height: 62vh;
  }
}

@media (max-width: 420px) {
  .heroActions .btn {
    flex-basis: 100%;
  }

  .privacyBadge {
    padding-left: 8px;
    padding-right: 8px;
  }

  .pageTitle {
    font-size: 13px;
  }
}

/* Ajuste final: as abas ficam totalmente visíveis em tablet/celular, sem depender de rolagem lateral. */
@media (max-width: 900px) {
  .sidebar {
    overflow-y: auto;
  }

  .resultTabs {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    overflow: visible;
    scroll-snap-type: none;
    gap: 0;
    padding: 4px 10px;
  }

  .resultTabGroup {
    width: 100%;
    min-width: 0;
    justify-content: space-between;
    gap: 6px;
    padding: 0 5px;
    border-bottom: 1px solid #f0f2f5;
  }

  .resultTab {
    min-width: 0;
    flex: 1 1 auto;
    text-align: left;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .tabMiniActions {
    flex: 0 0 auto;
  }
}

@media (max-width: 540px) {
  .resultTabs {
    grid-template-columns: 1fr;
    padding-left: 8px;
    padding-right: 8px;
  }

  .resultTabGroup {
    min-height: 46px;
  }

  .resultTab {
    white-space: normal;
    line-height: 1.2;
    overflow: visible;
    text-overflow: clip;
  }
}


/* --------------------------------------------------------------------------
   v3.9.3 — Correções
   -------------------------------------------------------------------------- */

/* Ícone do aviso flutuante com tamanho fixo (antes ocupava todo o espaço). */
.toast svg {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
}

.toast {
  max-width: min(420px, calc(100vw - 32px));
}

.toast #toastText {
  line-height: 1.35;
}

/* Linhas "Sem IBS/CBS" destacadas em vermelho claro, como no relatório PDF. */
.dataRow.withoutRow td {
  background: #fdeeee;
}

.dataRow.withoutRow:hover td {
  background: #fbe3e3;
}

/* Status e Ações fixos à direita: sempre visíveis mesmo com rolagem lateral. */
.tableWrap .colStatus,
.tableWrap .colActions {
  position: sticky;
  z-index: 1;
  background: #ffffff;
}

.tableWrap .colActions {
  right: 0;
  width: 96px;
  min-width: 96px;
}

.tableWrap .colStatus {
  right: 96px;
  min-width: 150px;
  box-shadow: -8px 0 10px -8px rgba(15, 23, 42, 0.18);
}

.tableWrap th.colStatus,
.tableWrap th.colActions {
  z-index: 3;
  background: #fafbfc;
}

.dataRow:hover td.colStatus,
.dataRow:hover td.colActions {
  background: #fbfdff;
}

/* "IBS/CBS sem cálculo" em âmbar, igual à legenda do relatório PDF. */
.dataRow.calcErrorRow td,
.dataRow.calcErrorRow td.colStatus,
.dataRow.calcErrorRow td.colActions {
  background: #fff7e3;
}

.dataRow.withoutRow td.colStatus,
.dataRow.withoutRow td.colActions {
  background: #fdeeee;
}

.dataRow.withoutRow:hover td.colStatus,
.dataRow.withoutRow:hover td.colActions {
  background: #fbe3e3;
}

/* Em celulares estreitos, apenas Ações fica fixa para não ocupar a tela toda. */
@media (max-width: 600px) {
  .tableWrap .colStatus {
    position: static;
    box-shadow: none;
  }

  .tableWrap .colActions {
    box-shadow: -8px 0 10px -8px rgba(15, 23, 42, 0.18);
  }
}

/* v3.9.4 — aviso de valor inferior a R$ 0,01 calculado com precisão ampliada */
.calcReconcileBanner.subCent {
  background: #eef4ff;
  border-color: #c9d8fb;
  color: #2a4fa8;
}

.calcReconcileBanner.subCent svg {
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
}

.summaryBanner .subCentNote {
  display: block;
  margin-top: 4px;
  color: #2a4fa8;
  font-weight: 600;
}

/* ==========================================================================
   v3.9.5 — Responsividade revisada
   ========================================================================== */

/* Layout principal: Importação + painéis laterais em cima, Resultados com
   largura total embaixo (a tabela é o conteúdo mais largo da página). */
.mainGrid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 310px;
  grid-template-areas:
    "import side"
    "results results";
  gap: 18px;
  align-items: start;
}

.mainGrid > div:first-child {
  display: contents;
}

.mainGrid #importacao {
  grid-area: import;
  margin: 0;
  min-width: 0;
}

.mainGrid #resultados {
  grid-area: results;
  margin: 0;
  min-width: 0;
}

.mainGrid .rightColumn {
  grid-area: side;
  min-width: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.mainGrid .rightColumn .sidePanel {
  margin: 0;
}

/* Cards de estatística se reorganizam conforme a largura disponível. */
.stats {
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
}

.statFoot {
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  line-height: 1.3;
}

/* Tabela mais compacta em notebooks. */
@media (max-width: 1500px) {
  .tableWrap table {
    min-width: 1080px;
  }

  .tableWrap th,
  .tableWrap td {
    padding: 10px 9px;
  }
}

@media (max-width: 1150px) {
  .mainGrid {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "import"
      "side"
      "results";
  }

  .mainGrid .rightColumn {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
  }
}

@media (max-width: 900px) {
  .mainGrid {
    display: grid;
    gap: 16px;
  }

  .mainGrid .rightColumn {
    margin-top: 0;
  }

  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .stats .statCard:last-child:nth-child(odd) {
    grid-column: 1 / -1;
  }
}

@media (max-width: 620px) {
  .mainGrid {
    grid-template-areas:
      "import"
      "results"
      "side";
  }

  .mainGrid .rightColumn {
    grid-template-columns: minmax(0, 1fr);
  }

  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .statCard {
    padding: 12px;
    gap: 10px;
    align-items: flex-start;
  }

  .statIcon {
    width: 34px;
    height: 34px;
    border-radius: 10px;
  }

  .statIcon svg {
    width: 17px;
    height: 17px;
  }

  .tableWrap {
    max-height: 520px;
  }
}

@media (max-width: 380px) {
  .statCard {
    flex-direction: column;
    gap: 8px;
  }
}

/* Chave de acesso não alarga a coluna Documento. */
.fileCell .subText {
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 1500px) {
  .tableWrap table {
    min-width: 1000px;
  }

  .fileCell {
    min-width: 210px;
  }

  .fileCell .subText,
  .fileLink {
    max-width: 210px;
  }
}

/* Ações do topo: grade 2×2 no celular, "Importar arquivos" em destaque. */
@media (max-width: 620px) {
  .heroActions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .heroActions .btn {
    width: 100%;
    justify-content: center;
    padding-left: 8px;
    padding-right: 8px;
    font-size: 12px;
  }

  .heroActions .btn.primary {
    grid-column: 1 / -1;
  }

  /* Cabeçalho da importação: título em cima, botão Limpar embaixo. */
  #importacao .panelHead {
    flex-direction: column;
    align-items: stretch;
  }

  #importacao .panelHead #clearBtn {
    width: 100%;
    justify-content: center;
  }

  /* Tabela de resultados vira lista de cartões no celular. */
  .tableWrap {
    max-height: none;
    overflow: visible;
    padding: 4px 0;
  }

  .tableWrap table,
  .tableWrap tbody {
    display: block;
    width: 100%;
    min-width: 0;
  }

  .tableWrap thead {
    display: none;
  }

  .tableWrap tr.dataRow {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px 14px;
    margin: 10px 12px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #ffffff;
  }

  .tableWrap tr.dataRow.withoutRow {
    background: #fdeeee;
    border-color: #f5d0d0;
  }

  .tableWrap tr.dataRow.calcErrorRow {
    background: #fff7e3;
    border-color: #f3dfaa;
  }

  .tableWrap tr.dataRow td,
  .tableWrap tr.dataRow:hover td {
    display: block;
    position: static;
    padding: 0;
    border: 0;
    min-width: 0;
    width: auto;
    background: transparent;
    box-shadow: none;
    font-size: 12px;
  }

  .tableWrap tr.dataRow td::before {
    display: block;
    margin-bottom: 2px;
    color: #98a2b3;
    font-size: 9px;
    font-weight: 800;
    letter-spacing: 0.035em;
    text-transform: uppercase;
  }

  .tableWrap tr.dataRow td:nth-child(1) { grid-column: 1 / -1; }
  .tableWrap tr.dataRow td:nth-child(2)::before { content: "Tipo"; }
  .tableWrap tr.dataRow td:nth-child(3)::before { content: "NF / Série"; }
  .tableWrap tr.dataRow td:nth-child(4) { grid-column: 1 / -1; }
  .tableWrap tr.dataRow td:nth-child(4)::before { content: "Emitente"; }
  .tableWrap tr.dataRow td:nth-child(5)::before { content: "Valor"; }
  .tableWrap tr.dataRow td:nth-child(6)::before { content: "Total IBS"; }
  .tableWrap tr.dataRow td:nth-child(7)::before { content: "Total CBS"; }
  .tableWrap tr.dataRow td:nth-child(8)::before { content: "Itens"; }
  .tableWrap tr.dataRow td:nth-child(9),
  .tableWrap tr.dataRow td:nth-child(10) { display: none; }
  .tableWrap tr.dataRow td:nth-child(11) { align-self: center; }
  .tableWrap tr.dataRow td:nth-child(12) {
    align-self: center;
    justify-self: end;
  }

  .tableWrap .fileCell {
    min-width: 0;
  }

  .tableWrap .fileLink,
  .tableWrap .fileCell .subText {
    max-width: 100%;
  }

  .tableWrap .issuerName,
  .tableWrap .docText {
    display: block;
    overflow-wrap: anywhere;
  }

  .tableWrap .calcTriggerBtn {
    padding: 0;
  }
}

@media (max-width: 620px) {
  .heroActions .btn:nth-child(3) {
    grid-column: 1 / -1;
  }
}

/* Modais: abas roláveis sem cortar texto, subtítulo e chave quebram linha. */
.modalTabs {
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

.modalTab {
  flex: 0 0 auto;
  white-space: nowrap;
}

.modalHead .modalFile > div {
  min-width: 0;
}

.modalSub {
  overflow-wrap: anywhere;
}

.calcTable td:nth-child(2),
.calcTable th:nth-child(2) {
  min-width: 190px;
}

@media (max-width: 620px) {
  .modalHead {
    padding: 12px;
    gap: 8px;
  }

  .modalTabs {
    padding: 0 8px;
  }

  .modalTab {
    padding: 11px 9px;
  }

  .modalFileName {
    max-width: 100%;
    white-space: normal;
    overflow-wrap: anywhere;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
  }

  .modalSub {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  .calcTableWrap {
    max-height: none;
  }
}
