/* static/style.css */
:root {
  /* Paleta principal: Identidade Katinu + Superfícies Modernas */
  --katinu-red: #d92d20;        /* Vermelho marca refinado */
  --katinu-red-hover: #b42318;
  --katinu-black: #111318;      /* Grafite profundo da topbar */
  --katinu-white: #ffffff;
  --katinu-gray-dark: #181b23;
  --katinu-gray: #334155;
  --katinu-gray-light: #202430;
  --katinu-border: #2c3140;

  /* Ações semânticas (separando primária de destrutiva) */
  --action-primary: #2563eb;
  --action-primary-hover: #1d4ed8;
  --action-danger: #dc2626;
  --action-danger-hover: #b91c1c;

  /* Escala neutra Slate */
  --neutral-50: #f8fafc;
  --neutral-100: #f1f5f9;
  --neutral-200: #e2e8f0;
  --neutral-300: #cbd5e1;
  --neutral-400: #94a3b8;
  --neutral-500: #64748b;
  --neutral-600: #475569;
  --neutral-700: #334155;
  --neutral-800: #1e293b;
  --neutral-900: #0f172a;

  /* Cores específicas por tipo de documento fiscal (NF-e e NFC-e) */
  --nfe-color: #16a34a;         /* Verde para NF-e */
  --nfce-color: #2563eb;        /* Azul para NFC-e */

  /* Superfícies Tema Claro (inspiradas em demo_ui.html) */
  --bg-primary: #f4f6f9;
  --bg-secondary: #f8fafc;
  --bg-tertiary: #f1f5f9;
  --text-primary: #0f172a;
  --text-secondary: #64748b;
  --border-color: #e2e8f0;
  --card-bg: #ffffff;
  --card-border: #e2e8f0;
  --navbar-bg: #111318;
  --navbar-text: #ffffff;
  --input-bg: #ffffff;
  --input-border: #cbd5e1;
  --input-text: #0f172a;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 10px 25px -5px rgba(15, 23, 42, 0.08), 0 4px 10px -2px rgba(15, 23, 42, 0.04);
}

/* Tema Escuro */
[data-theme="dark"],
[data-bs-theme="dark"] {
  --bg-primary: #0f1117;
  --bg-secondary: #181b23;
  --bg-tertiary: #202430;
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --border-color: #2c3140;
  --card-bg: #181b23;
  --card-border: #2c3140;
  --navbar-bg: #111318;
  --navbar-text: #f8fafc;
  --input-bg: #202430;
  --input-border: #334155;
  --input-text: #f1f5f9;
  --shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.45);

  --action-primary: #3b82f6;
  --action-primary-hover: #2563eb;
  --action-danger: #ef4444;
  --action-danger-hover: #dc2626;

  /* Cores específicas por tipo de documento no tema escuro */
  --nfe-color: #4ade80;
  --nfce-color: #60a5fa;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  padding-top: 56px;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.2s ease, color 0.2s ease;
}

/* Tipografia numérica tabular para CNPJs, valores fiscais e chaves de 44 dígitos */
.font-monospace,
.tabular-nums,
.job-cnpj,
.total-emitido,
.cupons-count,
.machine-count,
code {
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-variant-numeric: tabular-nums;
}

/* Evita qualquer rolagem horizontal acidental no mobile */
html, body {
  max-width: 100%;
  overflow-x: hidden;
}

.navbar {
  background: var(--navbar-bg) !important;
  color: var(--navbar-text);
  border-bottom: 2px solid var(--katinu-red);
  transition: background-color 0.3s ease, color 0.3s ease;
  white-space: nowrap; /* evita quebra de linha na navbar */
}

.navbar .navbar-brand {
  color: var(--navbar-text) !important;
}

.navbar .navbar-brand:hover {
  color: var(--navbar-text) !important;
}

.navbar .nav-link {
  color: var(--navbar-text) !important;
}

.navbar .nav-link:hover {
  color: var(--katinu-red) !important;
}

.navbar .navbar-toggler {
  border-color: var(--border-color);
}

.navbar .navbar-toggler-icon {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba(255, 255, 255, 0.75)' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='m4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");
}

/* Garante boa visibilidade do ícone no tema claro (navbar escura) */
[data-theme="light"] .navbar .navbar-toggler-icon {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba(255, 255, 255, 0.85)' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='m4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");
}

.navbar .navbar-brand img {
  height: 44px;
  margin-right: 12px;
  margin-left: 14px;
}

/* Menu de usuário */
.user-menu {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

/* Garante que o menu do usuário não quebre linha ao lado da marca */
.navbar .container-fluid {
  display: flex;
  align-items: center;
}

.navbar .user-menu {
  margin-left: auto;
  flex-shrink: 0;
}

.user-admin-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 24px;
  padding: 0 8px;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-decoration: none;
  background: #f4c20d;
  color: #212529;
}

.user-admin-link:hover {
  background: #e8b708;
  color: #111;
  text-decoration: none;
}

.user-menu-toggle {
  background: none;
  border: none;
  color: var(--navbar-text);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 8px;
  transition: background-color 0.3s ease;
  cursor: pointer;
}

.user-menu-toggle:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--katinu-red);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: bold;
  font-size: 14px;
  flex-shrink: 0;
}

.user-menu-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  box-shadow: var(--shadow);
  min-width: 220px;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: all 0.3s ease;
}

.user-menu-dropdown.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.user-menu-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-secondary);
  border-radius: 8px 8px 0 0;
}

.user-menu-header .user-name {
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
  font-size: 14px;
}

.user-menu-header .user-email {
  font-size: 12px;
  color: var(--text-secondary);
  margin: 0;
  margin-top: 2px;
}

.user-menu-items {
  padding: 8px 0;
}

.user-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  color: var(--text-primary);
  text-decoration: none;
  transition: background-color 0.3s ease;
  font-size: 14px;
  width: 100%;
  border: none;
  background: none;
  cursor: pointer;
}

.user-menu-item:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
  text-decoration: none;
}

.user-menu-item i {
  width: 16px;
  text-align: center;
  color: var(--text-secondary);
}

.user-menu-divider {
  height: 1px;
  background: var(--border-color);
  margin: 8px 0;
}

/* Botão de tema */
.theme-toggle {
  background: none;
  border: none;
  color: var(--text-primary);
  padding: 8px 16px;
  border-radius: 6px;
  transition: background-color 0.3s ease;
  cursor: pointer;
  width: 100%;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-family: inherit;
  text-decoration: none;
  outline: none;
}

.theme-toggle:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
  text-decoration: none;
}

.theme-toggle:focus {
  outline: none;
}

.theme-toggle i {
  font-size: 16px;
  width: 16px;
  text-align: center;
  color: var(--text-secondary);
}

.card, .form-control, .form-select {
  border-radius: 0.65rem;
  border: 1px solid var(--border-color);
  transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.card {
  background: var(--card-bg);
  color: var(--text-primary);
  box-shadow: var(--shadow);
  border: 1px solid var(--card-border);
}

/* Login: sombra refinada para destacar os cards */
.login-card {
  box-shadow: var(--shadow-lg);
}

[data-theme="dark"] .login-card,
[data-bs-theme="dark"] .login-card {
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45), 0 2px 8px rgba(0, 0, 0, 0.3);
}

/*
 * Chromium no Windows (escala 125%/150%) deixa um furo de 1–2px no canto
 * quando a borda tem 1px + border-radius. O outline para dentro fecha o
 * canto sem aumentar a espessura.
 */
.card,
.admin-card,
.empresa-group,
.empresa-card {
  outline: 1px solid var(--card-border);
  outline-offset: -1px;
}

/* Conteúdo interno (tabela, form, card aninhado) não ganha o quadro do card primário */
.card .card,
.card .admin-card,
.card .admin-form,
.card .admin-table,
.admin-card .card,
.admin-card .admin-card,
.admin-card .admin-form,
.admin-card .admin-table {
  border: none;
  outline: none;
}

.card .admin-table,
.admin-card .admin-table {
  box-shadow: none;
  border-radius: 0;
}

.form-control, .form-select {
  background: var(--input-bg);
  color: var(--input-text);
  border: 1px solid var(--input-border);
}

.form-control:focus, .form-select:focus {
  border-color: var(--action-primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.18);
  background: var(--input-bg);
  color: var(--input-text);
}

.btn-primary {
  background: var(--action-primary);
  border-color: var(--action-primary);
  color: #ffffff;
  font-weight: 500;
}

.btn-primary:hover, .btn-primary:focus-visible {
  background: var(--action-primary-hover);
  border-color: var(--action-primary-hover);
  color: #ffffff;
}

/* Contraste WCAG AA (>= 4.5:1) no tema escuro */
[data-theme="dark"] .btn-primary {
  background: #2563eb;
  border-color: #2563eb;
  color: #ffffff;
}
[data-theme="dark"] .btn-primary:hover,
[data-theme="dark"] .btn-primary:focus-visible {
  background: #1d4ed8;
  border-color: #1d4ed8;
  color: #ffffff;
}
[data-theme="dark"] .btn-outline-primary {
  color: #6ea8fe;
  border-color: #6ea8fe;
}
[data-theme="dark"] .btn-outline-primary:hover,
[data-theme="dark"] .btn-outline-primary:focus-visible {
  background: #2563eb;
  border-color: #2563eb;
  color: #ffffff;
}
[data-theme="dark"] .btn-outline-danger {
  color: #f87171;
  border-color: #f87171;
}
[data-theme="dark"] .btn-outline-danger:hover,
[data-theme="dark"] .btn-outline-danger:focus-visible {
  background: #dc2626;
  border-color: #dc2626;
  color: #ffffff;
}

.btn-danger {
  background: var(--action-danger);
  border-color: var(--action-danger);
  color: #ffffff;
  font-weight: 500;
}

.btn-danger:hover, .btn-danger:focus-visible {
  background: var(--action-danger-hover);
  border-color: var(--action-danger-hover);
  color: #ffffff;
}

.btn-outline-secondary {
  border-color: var(--border-color);
  color: var(--text-primary);
  background: transparent;
}

.btn-outline-secondary:hover {
  background: var(--bg-tertiary);
  border-color: var(--neutral-300);
  color: var(--text-primary);
}

.alert-success { background: #ecfdf5; color: #065f46; border-color: #a7f3d0; }
.alert-danger { background: #fef2f2; color: #991b1b; border-color: #fecaca; }
.alert-warning { background: #fffbeb; color: #92400e; border-color: #fde68a; }
.alert-info { background: #eff6ff; color: #1e40af; border-color: #bfdbfe; }

[data-theme="dark"] .alert-success,
[data-bs-theme="dark"] .alert-success {
  background: rgba(16, 185, 129, 0.14);
  color: #6ee7b7;
  border-color: rgba(16, 185, 129, 0.3);
}
[data-theme="dark"] .alert-danger,
[data-bs-theme="dark"] .alert-danger {
  background: rgba(239, 68, 68, 0.14);
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.32);
}
[data-theme="dark"] .alert-warning,
[data-bs-theme="dark"] .alert-warning {
  background: rgba(245, 158, 11, 0.14);
  color: #fcd34d;
  border-color: rgba(245, 158, 11, 0.32);
}
[data-theme="dark"] .alert-info,
[data-bs-theme="dark"] .alert-info {
  background: rgba(59, 130, 246, 0.14);
  color: #93c5fd;
  border-color: rgba(59, 130, 246, 0.32);
}

.table, .table-striped, .table-hover {
  background: var(--card-bg);
  color: var(--text-primary);
}

.table th, .table td {
  border-color: var(--border-color);
}

input[type="checkbox"], input[type="radio"] {
  accent-color: var(--katinu-red);
  border: 2px solid #666666 !important;
  border-radius: 3px !important;
  width: 18px !important;
  height: 18px !important;
  cursor: pointer;
  transition: all 0.2s ease;
}

input[type="checkbox"]:checked, input[type="radio"]:checked {
  border-color: var(--katinu-red) !important;
  background-color: var(--katinu-red) !important;
}

input[type="checkbox"]:hover, input[type="radio"]:hover {
  border-color: var(--katinu-red) !important;
  transform: scale(1.1);
}

/* Estilos específicos para checkboxes de arquivos */
.file-checkbox {
  border: 2px solid #666666 !important;
  border-radius: 3px !important;
  width: 18px !important;
  height: 18px !important;
  cursor: pointer;
  transition: all 0.2s ease;
}

.file-checkbox:checked {
  border-color: var(--katinu-red) !important;
  background-color: var(--katinu-red) !important;
}

.file-checkbox:hover {
  border-color: var(--katinu-red) !important;
  transform: scale(1.1);
}

/* Estilos para checkboxes de seleção em grupo */
.select-all-children {
  border: 2px solid #666666 !important;
  border-radius: 3px !important;
  width: 18px !important;
  height: 18px !important;
  cursor: pointer;
  transition: all 0.2s ease;
}

.select-all-children:checked {
  border-color: var(--katinu-red) !important;
  background-color: var(--katinu-red) !important;
}

.select-all-children:hover {
  border-color: var(--katinu-red) !important;
  transform: scale(1.1);
}

::-webkit-scrollbar {
  width: 10px;
  background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
  background: var(--bg-tertiary);
  border-radius: 5px;
}

/* Customização para acordeão, cards, etc. */
.empresa-group, .tipo-group, .periodo-group {
  background: var(--card-bg);
  border-radius: 0.5rem;
  transition: background-color 0.3s ease, border-color 0.3s ease;
}

.periodo-group {
  border: 1px solid var(--border-color);
}

.empresa-group > summary, .tipo-group > summary, .periodo-group > summary {
  color: var(--text-primary);
}

/* Permite quebra de linha e layout fluido dos sumários no mobile */
.empresa-group > summary,
.tipo-group > summary,
.periodo-group > summary {
  flex-wrap: wrap;
  white-space: normal;
  word-break: break-word;
  gap: 0.5rem;
  align-items: flex-start;
}

.file-list li {
  color: var(--text-primary);
}

.download-link-single {
  color: var(--katinu-red);
}

.download-link-single:hover {
  color: var(--text-primary);
}

/* Rodapé */
.footer {
  background: var(--navbar-bg);
  color: var(--navbar-text);
  border-top: 2px solid var(--katinu-red);
  padding: 1rem 0;
  margin-top: 2rem;
}

/* Layout das empresas no Dashboard em DIV única */
#dashboard-content {
    display: block;
    width: 100%;
}
#dashboard-content.empresas-grid {
    display: block;
}

/* Estilo para a estrutura de pastas "Acordeão" do Dashboard */
.empresa-group {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 0.75rem;
    margin-bottom: 0.9rem;
    box-shadow: var(--shadow);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    overflow: hidden;
}
.empresa-group:hover {
    border-color: rgba(217, 45, 32, 0.32);
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.08);
}
[data-theme="dark"] .empresa-group:hover,
[data-bs-theme="dark"] .empresa-group:hover {
    border-color: rgba(239, 68, 68, 0.35);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
}
.empresa-group > summary {
    font-size: 1.02rem;
    font-weight: 600;
    padding: 0.9rem 1.15rem;
    cursor: pointer;
    list-style: none;
    color: var(--text-primary);
    background: var(--bg-secondary);
    border-radius: 0.75rem;
    user-select: none;
    transition: background-color 0.2s ease;
    position: relative;
}
.empresa-group[open] > summary {
    border-radius: 0.75rem 0.75rem 0 0;
    border-bottom: 1px solid var(--border-color);
}
.empresa-group > summary:hover {
    background: var(--bg-tertiary);
}
.empresa-group > summary::-webkit-details-marker { display: none; }

/* Chevron rotativo moderno no cabeçalho da empresa */
.empresa-group > summary::before {
    content: "\f054";
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-right: 0.65rem;
    transition: transform 0.2s ease, color 0.2s ease;
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
}
.empresa-group[open] > summary::before {
    transform: rotate(90deg);
    color: var(--katinu-red);
}

/* Corpo interno do card da empresa */
.empresa-group > div {
    background: var(--card-bg);
    border-radius: 0 0 0.75rem 0.75rem;
}

.tipo-group, .periodo-group {
    margin: 0.5rem 1.5rem;
    border-left: 2px solid var(--border-color);
    padding-left: 1rem;
}

/* Card interno NFe/NFCe: mesma borda sutil do card da empresa */
.tipo-group {
    margin: 0.35rem 0 0.5rem;
    padding: 0.1rem 0.5rem 0.45rem 0.75rem;
    border: 1px solid var(--card-border);
    border-left-width: 3px;
    border-radius: 0.5rem;
}

.tipo-group .periodo-group {
    margin-left: 0.15rem;
    margin-right: 0.15rem;
}
.tipo-group > summary, .periodo-group > summary {
    font-size: 1rem;
    padding: 0.75rem 1rem;
    cursor: pointer;
    list-style: none;
    display: flex;
    align-items: center;
    color: var(--text-primary);
}
.total-emitido {
    margin-left: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    padding: 0.15rem 0.4rem;
    border: none !important;
    background: transparent;
}
.tipo-group[data-tipo="NFe"] > summary .total-emitido { color: var(--nfe-color) !important; }
.tipo-group[data-tipo="NFCe"] > summary .total-emitido { color: var(--nfce-color) !important; }
.tipo-group > summary::-webkit-details-marker,
.periodo-group > summary::-webkit-details-marker { display: none; }

.file-list {
    list-style: none;
    padding: 0.5rem 1rem 0.5rem 1.5rem;
    margin: 0;
}
/* Estilo para alinhar os botões de download totalmente à direita */
.file-list li {
    padding: 0.5rem 0;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--text-primary);
    justify-content: space-between; /* Distribui o espaço entre o conteúdo e os botões */
}

.file-list li .file-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex: 1; /* Ocupa o espaço disponível */
}

.file-list li .file-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-left: auto; /* Empurra para a direita */
}

.download-link-single {
    margin-left: 0;
    color: var(--text-secondary);
    font-size: 1.1rem;
}

/* Garante que os botões fiquem imediatamente antes do texto, sem empurrar para a direita */
.file-list li a.download-link-single { margin-left: 0 !important; }
.download-link-single:hover {
    color: var(--katinu-red);
}

/* Estilo da Tela de Carregamento */
#loading-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background-color: rgba(33, 37, 41, 0.85);
    z-index: 1056;
    display: none; justify-content: center; align-items: center;
    flex-direction: column; color: white;
}
.spinner {
    width: 3.5rem; height: 3.5rem;
    border: 0.4rem solid rgba(255, 255, 255, 0.2);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

.main-content-area {
    padding: 1.5rem;
}

/* Evita overflow horizontal na área principal */
.main-content-area {
  overflow-x: hidden;
}

/* Mantém os alerts globais alinhados ao conteúdo das rotas admin */
@media (min-width: 768px) {
  .app-flash-container-admin {
    margin-left: 25%;
  }
}

@media (min-width: 992px) {
  .app-flash-container-admin {
    margin-left: 16.666667%;
  }
}

/* Em telas grandes, o menu lateral do admin é fixo */
@media (min-width: 768px) {
    .sidebar {
        position: fixed;
        top: 0;
        bottom: 0;
        left: 0;
        z-index: 100;
        padding: 56px 0 0;
        box-shadow: inset -1px 0 0 rgba(0, 0, 0, .1);
    }
}

.sidebar-heading {
    font-size: .75rem;
    font-weight: bold;
    color: var(--text-secondary);
    text-transform: uppercase;
    padding: 0.5rem 1rem;
}

.sidebar .nav-link {
    font-weight: 500;
    color: var(--text-primary);
}
.sidebar .nav-link .fa-fw {
    width: 20px;
    text-align: center;
    margin-right: 0.25rem;
}
.sidebar .nav-link:hover, .sidebar .nav-link.active {
    color: var(--katinu-red);
}

.col-12 {
  flex: 0 0 auto;
  width: 100%;
}

.dashboard-bg {
  background: var(--bg-primary);
  min-height: 100vh;
}

.dashboard-bg h2, .dashboard-bg .fw-bold, .dashboard-bg h2.fw-bold {
  color: var(--text-primary);
  font-weight: 700;
}

.summary-card .fw-semibold, .summary-card .fs-2, .summary-card .fs-6 {
  color: var(--text-primary);
}

.bg-katinu-dark {
  background: var(--bg-primary) !important;
  border: 1px solid var(--border-color) !important;
  box-shadow: var(--shadow);
}

.dashboard-bg .card, .dashboard-bg .summary-card, .dashboard-bg .rounded-4 {
  border: 1px solid var(--card-border);
  box-shadow: var(--shadow);
}



.empresas-graficos {
    display: flex;
    flex-wrap: wrap;
    gap: 32px;
    justify-content: flex-start;
    align-items: stretch;
}

.empresa-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    transition: all 0.3s ease;
}

.empresa-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 4px 15px rgba(227, 6, 19, 0.2);
}

.empresa-card .card-title {
    color: var(--text-primary);
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    border-bottom: 2px solid var(--katinu-red);
    padding-bottom: 0.5rem;
}

.legenda-metodos {
    font-size: 0.85rem;
    color: var(--text-primary);
    padding: 0.5rem;
    border-left: 1px solid var(--border-color);
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.legenda-metodos .metodo-item {
    display: flex;
    align-items: center;
    margin-bottom: 0.5rem;
}

.legenda-metodos .metodo-cor {
    width: 12px;
    height: 12px;
    border-radius: 2px;
    margin-right: 8px;
}

.grafico-container {
    position: relative;
    width: 100%;
    height: 200px;
}

/* Responsividade */
@media (max-width: 768px) {
    .empresa-card .row {
        flex-direction: column;
    }
    
    .legenda-metodos {
        border-left: none;
        border-top: 1px solid var(--border-color);
        margin-top: 1rem;
        padding-top: 1rem;
    }
}

.relatorio-header {
    display: flex;
    align-items: center;
    gap: 24px;
}

/* Estilos para páginas Admin */
.sidebar {
  background: var(--card-bg);
  border-right: 1px solid var(--border-color);
  transition: background-color 0.3s ease, border-color 0.3s ease;
}

@media (min-width: 768px) {
  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 100;
    padding: 56px 0 0;
    box-shadow: inset -1px 0 0 var(--border-color);
  }
}

.sidebar-heading {
  font-size: 0.75rem;
  font-weight: bold;
  color: var(--text-secondary);
  text-transform: uppercase;
  padding: 0.5rem 1rem;
  margin-bottom: 0.5rem;
  border-bottom: 1px solid var(--border-color);
}

.sidebar .nav-link {
  font-weight: 500;
  color: var(--text-primary);
  padding: 0.75rem 1rem;
  border-radius: 0;
  transition: all 0.3s ease;
  border-left: 3px solid transparent;
}

.sidebar .nav-link:hover {
  background: var(--bg-secondary);
  color: var(--katinu-red);
  border-left-color: var(--katinu-red);
}

.sidebar .nav-link.active {
  background: var(--bg-secondary);
  color: var(--katinu-red);
  border-left-color: var(--katinu-red);
  font-weight: 600;
}

.sidebar .nav-link .fa-fw {
  width: 20px;
  text-align: center;
  margin-right: 0.5rem;
}

/* Cards e tabelas admin */
.admin-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 0.75rem;
  box-shadow: var(--shadow);
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.admin-card:hover {
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.08);
}

[data-theme="dark"] .admin-card:hover,
[data-bs-theme="dark"] .admin-card:hover {
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.42);
}

.admin-card.no-hover:hover {
  /* Evita que o card pai "acenda" quando o mouse está sobre o botão interno */
  box-shadow: var(--shadow);
}

/* Efeito de destaque do botão/tile de upload (somente nele) */
.admin-card.admin-versions-upload-tile {
  transition: transform 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
  cursor: pointer;
  user-select: none;
}

.admin-card.admin-versions-upload-tile:hover {
  transform: translateY(-8px) scale(1.03);
  box-shadow: 0 12px 32px rgba(227, 6, 19, 0.28), 0 8px 20px rgba(0, 0, 0, 0.18);
}

.admin-card .card-header {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  padding: 1rem 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
}

.admin-card .card-body {
  padding: 1.25rem;
}

/* Tabelas admin */
.admin-table {
  background: var(--card-bg);
  overflow: hidden;
}

.admin-table .table {
  margin-bottom: 0;
}

.admin-table .table thead th {
  background: var(--bg-secondary);
  border-bottom: 2px solid var(--border-color);
  color: var(--text-primary);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.875rem;
  letter-spacing: 0.5px;
  padding: 1rem 0.75rem;
}

.admin-table .table tbody td {
  padding: 1rem 0.75rem;
  vertical-align: middle;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-primary);
}

.admin-table .table tbody tr:hover {
  background: var(--bg-secondary);
}

/* Botões admin */
.admin-btn {
  border-radius: 0.375rem;
  font-weight: 500;
  padding: 0.5rem 1rem;
  transition: all 0.3s ease;
  border: 1px solid transparent;
}

.admin-btn-primary {
  background: var(--katinu-red);
  border-color: var(--katinu-red);
  color: var(--katinu-white);
}

.admin-btn-primary:hover {
  background: #b0050f;
  border-color: #b0050f;
  color: var(--katinu-white);
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(227, 6, 19, 0.3);
}

.admin-btn-secondary {
  background: var(--bg-secondary);
  border-color: var(--border-color);
  color: var(--text-primary);
}

.admin-btn-secondary:hover {
  background: var(--bg-tertiary);
  border-color: var(--border-color);
  color: var(--text-primary);
}

.admin-btn-outline {
  background: transparent;
  border-color: var(--border-color);
  color: var(--text-primary);
}

.admin-btn-outline:hover {
  background: var(--bg-secondary);
  border-color: var(--border-color);
  color: var(--text-primary);
}

[data-theme="dark"] .admin-btn-outline {
  border-color: var(--text-secondary); /* Garante contraste no tema escuro */
}

[data-theme="dark"] .admin-btn-outline:hover {
  background: var(--bg-tertiary);
  border-color: var(--text-primary);
}

/* Formulários admin */
.admin-form {
  background: var(--card-bg);
  border-radius: 0.5rem;
  padding: 1.5rem;
  box-shadow: none;
}

.admin-form .form-label {
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

.admin-form .form-control,
.admin-form .form-select {
  border: 1px solid var(--border-color);
  border-radius: 0.375rem;
  padding: 0.75rem;
  background: var(--input-bg);
  color: var(--input-text);
  transition: all 0.3s ease;
}

.admin-form .form-control:focus,
.admin-form .form-select:focus {
  border-color: var(--katinu-red);
  box-shadow: 0 0 0 0.2rem rgba(227, 6, 19, 0.25);
  background: var(--input-bg);
  color: var(--input-text);
}

/* Alertas admin */
.admin-alert {
  border-radius: 0.5rem;
  border: 1px solid transparent;
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
}

.admin-alert-success {
  background: rgba(40, 167, 69, 0.1);
  border-color: rgba(40, 167, 69, 0.2);
  color: #28a745;
}

[data-theme="dark"] .admin-alert-success {
  color: #7ddc82; /* Verde mais claro para tema escuro */
}

.admin-alert-danger {
  background: rgba(220, 53, 69, 0.1);
  border-color: rgba(220, 53, 69, 0.2);
  color: #dc3545;
}

[data-theme="dark"] .admin-alert-danger {
  color: #ff8a96; /* Vermelho mais claro para tema escuro */
}

.admin-alert-info {
  background: rgba(23, 162, 184, 0.1);
  border-color: rgba(23, 162, 184, 0.2);
  color: #17a2b8;
}

[data-theme="dark"] .admin-alert-info {
  color: #6ce1f4; /* Azul mais claro para tema escuro */
}


/* Badges admin */
.admin-badge {
  padding: 0.375rem 0.75rem;
  border-radius: 0.375rem;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.admin-badge-primary {
  background: var(--katinu-red);
  color: var(--katinu-white);
}

.admin-badge-secondary {
  background: var(--bg-secondary);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
}

.admin-badge-warning {
  background: #ffc107;
  color: #212529;
}

/* Responsividade admin */
@media (max-width: 768px) {
  .admin-card {
    margin-bottom: 1rem;
  }
  
  .admin-table {
    font-size: 0.875rem;
  }
  
  .admin-table .table thead th,
  .admin-table .table tbody td {
    padding: 0.75rem 0.5rem;
  }
}

/* Garante que a classe .text-muted do Bootstrap se adapte ao tema */
[data-theme="dark"] .text-muted {
  color: var(--text-secondary) !important;
}

/* Nome da empresa na tabela de empresas (modo escuro) - especificamente na coluna Razão Social */
[data-theme="dark"] .admin-table tbody td .text-muted {
  color: #adb5bd !important; /* Cinza mais escuro para melhor visibilidade no modo escuro */
}

/* Nome da empresa no modal de status das máquinas (modo escuro) */
[data-theme="dark"] #machine-popup strong {
  color: #adb5bd !important; /* Cinza mais escuro para melhor visibilidade no modo escuro */
}

/* Estilos específicos para tipos de documento */
.tipo-group[data-tipo="NFe"] {
  border-left-color: var(--nfe-color) !important;
}

.tipo-group[data-tipo="NFe"] > summary {
  color: var(--nfe-color) !important;
  font-weight: 600;
}

.tipo-group[data-tipo="NFe"] > summary i {
  color: var(--nfe-color) !important;
}

.tipo-group[data-tipo="NFCe"] {
  border-left-color: var(--nfce-color) !important;
}

.tipo-group[data-tipo="NFCe"] > summary {
  color: var(--nfce-color) !important;
  font-weight: 600;
}

.tipo-group[data-tipo="NFCe"] > summary i {
  color: var(--nfce-color) !important;
}

/* Hover effects para os grupos de tipo */
.tipo-group[data-tipo="NFe"]:hover {
  background: rgba(22, 163, 74, 0.05);
}

.tipo-group[data-tipo="NFCe"]:hover {
  background: rgba(37, 99, 235, 0.05);
}

[data-theme="dark"] .tipo-group[data-tipo="NFe"]:hover,
[data-bs-theme="dark"] .tipo-group[data-tipo="NFe"]:hover {
  background: rgba(74, 222, 128, 0.09);
}

[data-theme="dark"] .tipo-group[data-tipo="NFCe"]:hover,
[data-bs-theme="dark"] .tipo-group[data-tipo="NFCe"]:hover {
  background: rgba(96, 165, 250, 0.09);
}

/* Estilo para os ícones de arquivo baseado no tipo */
.file-checkbox[data-tipo="NFe"] + i {
  color: var(--nfe-color) !important;
}

.file-checkbox[data-tipo="NFCe"] + i {
  color: var(--nfce-color) !important;
}

/* Estilo para os totais mensais baseado no tipo de documento */
.tipo-group[data-tipo="NFe"] .periodo-group summary .text-muted {
  color: var(--nfe-color) !important;
  font-weight: 600;
}

.tipo-group[data-tipo="NFCe"] .periodo-group summary .text-muted {
  color: var(--nfce-color) !important;
  font-weight: 600;
}

/* Animação girando para o botão Filtrar */
@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Garantir que o botão Filtrar tenha posicionamento relativo */
#btn-filtrar {
  position: relative !important;
  min-width: 96px;
  font-size: 0.875rem;
  height: 38px;
  padding: 0.375rem 0.85rem;
  line-height: 1.5;
  border-radius: 0.5rem;
}

.btn-filter-loading {
  position: relative;
  pointer-events: none;
  opacity: 0.85;
}

.btn-filter-loading .btn-text,
.btn-filter-loading i {
  opacity: 0;
  transition: opacity 0.2s ease;
}

.btn-filter-loading .btn-spinner {
  position: absolute;
  top: 50%;
  left: 50%;
  margin-top: -10px;
  margin-left: -10px;
  width: 20px;
  height: 20px;
  border: 2.5px solid rgba(255, 255, 255, 0.35);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  opacity: 1;
  display: block !important;
  padding: 0;
  z-index: 10;
}

/* Botão Limpar Filtro com mesmo tamanho */
#limpar-filtro {
  min-width: 92px;
  font-size: 0.875rem;
  height: 38px;
  padding: 0.375rem 0.85rem;
  line-height: 1.5;
  border-radius: 0.5rem;
}

.btn-spinner {
  display: none;
}

/* Botões de ação com largura consistente */
.btn-action {
  min-width: 156px;
  width: auto;
}

/* Barra de ações fixa e estado desabilitado unificado (Claro/Escuro) */
#download-actions {
  position: sticky;
  top: 56px;
  z-index: 1020;
}

.btn-action:disabled,
#download-actions .btn:disabled,
#download-actions .btn.disabled {
  background: var(--bg-tertiary) !important;
  color: var(--text-secondary) !important;
  border-color: var(--border-color) !important;
  box-shadow: none !important;
  cursor: not-allowed !important;
  transform: none !important;
  opacity: 0.72 !important;
}

/* Botões fixos na primeira tela */
.fixed-action-buttons {
  position: sticky;
  top: 70px;
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-lg);
  z-index: 100;
  backdrop-filter: blur(10px);
  border-top: 3px solid var(--katinu-red);
}

.fixed-action-buttons .btn {
  border-radius: 8px;
  font-weight: 600;
  padding: 0.75rem 1.5rem;
  transition: all 0.3s ease;
  border: none;
  position: relative;
  overflow: hidden;
}

.fixed-action-buttons .btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
  transition: left 0.5s;
}

.fixed-action-buttons .btn:hover::before {
  left: 100%;
}

.fixed-action-buttons .btn-download {
  background: linear-gradient(135deg, var(--katinu-red), #b0050f);
  color: white;
  box-shadow: 0 4px 15px rgba(227, 6, 19, 0.3);
}

.fixed-action-buttons .btn-download:hover {
  background: linear-gradient(135deg, #b0050f, #900409);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(227, 6, 19, 0.4);
}

.fixed-action-buttons .btn-export {
  background: linear-gradient(135deg, var(--katinu-black), var(--katinu-gray-dark));
  color: white;
  box-shadow: 0 4px 15px rgba(35, 35, 35, 0.3);
}

.fixed-action-buttons .btn-export:hover {
  background: linear-gradient(135deg, var(--katinu-gray-dark), var(--katinu-gray));
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(35, 35, 35, 0.4);
}

.fixed-action-buttons .btn-zip {
  background: linear-gradient(135deg, var(--neutral-600), var(--neutral-700));
  color: white;
  box-shadow: 0 4px 15px rgba(73, 80, 87, 0.3);
}

.fixed-action-buttons .btn-zip:hover {
  background: linear-gradient(135deg, var(--neutral-700), var(--neutral-800));
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(73, 80, 87, 0.4);
}

/* Modal melhorado */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(24, 24, 24, 0.8);
  backdrop-filter: blur(8px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
  animation: fadeIn 0.3s ease;
}

/* Escopado a .modal-overlay: evita sobrescrever .modal-content / .modal-header do Bootstrap */
.modal-overlay .modal-content {
  background: var(--card-bg);
  border-radius: 16px;
  padding: 0;
  max-width: 500px;
  width: 90%;
  max-height: 80vh;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border-color);
  animation: slideIn 0.3s ease;
}

.modal-overlay .modal-header {
  background: linear-gradient(135deg, var(--katinu-red), #b0050f);
  color: white;
  padding: 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
}

.modal-overlay .modal-header.modal-header-success {
  background: linear-gradient(135deg, #28a745, #20c997);
}

.modal-overlay .modal-header h3 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.modal-overlay .modal-close {
  background: none;
  border: none;
  color: white;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0.25rem;
  border-radius: 6px;
  transition: background-color 0.3s ease;
}

.modal-overlay .modal-close:hover {
  background: rgba(255, 255, 255, 0.1);
}

.modal-overlay .modal-body {
  padding: 1.5rem;
  color: var(--text-primary);
  line-height: 1.6;
}

.modal-overlay .modal-body .file-info {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 1rem;
  margin: 1rem 0;
  font-family: 'Courier New', monospace;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.modal-overlay .modal-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

.modal-overlay .modal-btn {
  flex: 1;
  padding: 0.75rem 1rem;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  text-decoration: none;
  text-align: center;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.modal-overlay .modal-btn-primary {
  background: linear-gradient(135deg, #16a34a, #15803d);
  color: white;
}

.modal-overlay .modal-btn-primary:hover {
  background: linear-gradient(135deg, #15803d, #166534);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(22, 163, 74, 0.3);
}

.modal-overlay .modal-btn-secondary {
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.modal-overlay .modal-btn-secondary:hover {
  background: var(--bg-tertiary);
  transform: translateY(-1px);
}

.modal-overlay .modal-btn-copy {
  background: linear-gradient(135deg, var(--katinu-black), var(--katinu-gray-dark));
  color: white;
}

.modal-overlay .modal-btn-copy:hover {
  background: linear-gradient(135deg, var(--katinu-gray-dark), var(--katinu-gray));
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(35, 35, 35, 0.3);
}

/* Animações */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideIn {
  from { 
    opacity: 0;
    transform: translateY(-20px) scale(0.95);
  }
  to { 
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Responsividade para botões fixos */
@media (max-width: 768px) {
  .fixed-action-buttons {
    position: relative;
    top: 0;
    margin-bottom: 1rem;
  }
  
  .fixed-action-buttons .btn {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
  }
  
  .modal-overlay .modal-content {
    width: 95%;
    margin: 1rem;
  }
  
  .modal-overlay .modal-actions {
    flex-direction: column;
  }
}

/* ===== Ajustes extras de responsividade ===== */
/* Melhor rolagem nas tabelas em mobile */
.table-responsive {
  -webkit-overflow-scrolling: touch;
}

/* Quebra segura de nomes longos de arquivos */
.file-list li .file-info {
  min-width: 0;
}

.file-list li .file-info span {
  overflow-wrap: anywhere;
  word-break: break-word;
}

/* Scroll horizontal no mobile para manter linha completa */
@media (max-width: 576px) {
  .main-content-area {
    padding: 1rem;
  }

  .navbar .navbar-brand img {
    height: 32px;
  }

  /* Container com scroll horizontal para file-list no mobile */
  .file-list {
    overflow-x: auto;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch; /* Scroll suave no iOS */
    scrollbar-width: thin; /* Scrollbar fina no Firefox */
  }

  .file-list::-webkit-scrollbar {
    height: 6px;
  }

  .file-list::-webkit-scrollbar-thumb {
    background: var(--bg-tertiary);
    border-radius: 3px;
  }

  /* Manter linha horizontal completa no mobile */
  .file-list li {
    flex-direction: row; /* Mantém horizontal */
    align-items: center;
    min-width: max-content; /* Não comprime o conteúdo */
    width: max-content; /* Largura baseada no conteúdo */
  }

  .file-list li .file-info {
    white-space: nowrap; /* Não quebra o texto */
    min-width: 0;
    flex-shrink: 0; /* Não encolhe */
  }

  .file-list li .file-actions {
    margin-left: auto;
    margin-top: 0;
    flex-shrink: 0; /* Não encolhe */
  }

  .btn-action {
    min-width: auto !important;
    width: 100% !important;
  }

  .user-menu-dropdown {
    max-width: calc(100vw - 16px);
    width: 90vw;
  }

  /* Força ações do período a irem para a linha de baixo quando necessário */
  .periodo-group summary .ms-auto {
    width: 100%;
    margin-left: 0 !important;
    margin-top: 0.25rem;
    justify-content: flex-start;
  }
}

/* Permitir quebra dos botões do filtro quando necessário */
#filtro-arquivos-form .d-flex {
  flex-wrap: wrap;
}

/* ===== Widget flutuante "Meus arquivos" e Modal "Arquivos Gerados" ===== */
.floating-widget {
  position: fixed;
  right: 24px;
  bottom: 24px;
  width: 360px;
  max-width: calc(100vw - 32px);
  background: var(--card-bg, #ffffff);
  border: 1px solid var(--border-color, #dee2e6);
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.06);
  z-index: 1045;
  overflow: hidden;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.floating-widget.minimized {
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.1);
  border-radius: 30px;
  width: auto;
  max-width: 90vw;
}

.floating-widget.minimized .fw-list,
.floating-widget.minimized .fw-foot {
  display: none;
}

.fw-head {
  padding: 8px 14px;
  border-bottom: 1px solid var(--border-color, #dee2e6);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--card-bg, #ffffff);
  color: var(--text-primary);
  cursor: pointer;
  user-select: none;
  transition: background 0.15s ease;
  gap: 12px;
}

.fw-head:hover {
  background: rgba(0, 0, 0, 0.02);
}

[data-theme="dark"] .fw-head:hover,
[data-bs-theme="dark"] .fw-head:hover {
  background: rgba(255, 255, 255, 0.04);
}

.floating-widget.minimized .fw-head {
  border-bottom: none;
  padding: 7px 14px 7px 10px;
}

.fw-title-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
}

.fw-icon-pill {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(227, 6, 19, 0.1);
  color: var(--katinu-red, #e30613);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  flex-shrink: 0;
}

.fw-title-text {
  font-weight: 600;
  font-size: 13.5px;
  white-space: nowrap;
  letter-spacing: -0.2px;
}

.fw-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 6px;
}

.fw-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.fw-btn-icon {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-secondary, #6c757d);
  width: 26px;
  height: 26px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 12px;
  transition: all 0.15s ease;
}

.fw-btn-icon:hover {
  background: rgba(0, 0, 0, 0.05);
  color: var(--text-primary);
  border-color: var(--border-color, #dee2e6);
}

[data-theme="dark"] .fw-btn-icon:hover,
[data-bs-theme="dark"] .fw-btn-icon:hover {
  background: rgba(255, 255, 255, 0.08);
}

.fw-list {
  max-height: 290px;
  overflow-y: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--card-bg, #ffffff);
}

.job-card {
  border: 1px solid var(--border-color, #dee2e6);
  background: var(--bg-secondary, #f8fafc);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 12px;
  color: var(--text-primary);
}

.job-title {
  font-weight: 700;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.job-company {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-primary);
  margin-top: 3px;
  line-height: 1.3;
  word-break: break-word;
}

.job-cnpj {
  font-size: 11px;
  color: var(--text-secondary);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.dot-proc {
  background: #eab308;
  box-shadow: 0 0 0 3px rgba(234, 179, 8, 0.22);
}

.dot-ok {
  background: #16a34a;
}

.dot-err {
  background: #dc2626;
}

.bar-track {
  width: 260px;
  max-width: 100%;
  height: 8px;
  background: var(--border-color, #e2e8f0);
  border-radius: 999px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #eab308, #f59e0b);
  transition: width 0.25s ease;
}

.job-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.btn-job {
  border: none;
  border-radius: 7px;
  padding: 5px 10px;
  font-weight: 600;
  font-size: 12px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  text-decoration: none;
  transition: all 0.15s ease;
}

.btn-job-primary {
  background: var(--katinu-red, #e30613);
  color: #ffffff !important;
}

.btn-job-primary:hover {
  background: #b0050f;
  color: #ffffff !important;
}

.btn-job-outline {
  background: var(--card-bg, #ffffff);
  color: var(--text-primary);
  border: 1px solid var(--border-color, #dee2e6);
}

.btn-job-outline:hover {
  background: var(--bg-tertiary, #e9ecef);
}

.fw-foot {
  padding: 9px 14px;
  border-top: 1px solid var(--border-color, #dee2e6);
  text-align: center;
  background: var(--card-bg, #ffffff);
}

.fw-foot button {
  background: none;
  border: none;
  color: var(--katinu-red, #e30613);
  font-weight: 600;
  cursor: pointer;
  font-size: 13px;
}

.fw-foot button:hover {
  text-decoration: underline;
}

.inline-progress {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  background: var(--bg-secondary, #f8fafc);
  border: 1px solid var(--border-color, #dee2e6);
  border-radius: 10px;
  padding: 10px 14px;
  margin-top: 12px;
}

.ka-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.62);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1085;
  padding: 16px;
}

.ka-modal-backdrop.open {
  display: flex;
}

.ka-modal-box {
  width: 720px;
  max-width: 100%;
  max-height: 85vh;
  background: var(--card-bg, #ffffff);
  border: 1px solid var(--border-color, #dee2e6);
  border-radius: 16px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
  color: var(--text-primary);
}

.ka-modal-head {
  padding: 15px 20px;
  border-bottom: 1px solid var(--border-color, #dee2e6);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-secondary, #f8f9fa);
}

.ka-modal-body {
  padding: 16px 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ka-toast {
  position: fixed;
  top: 72px;
  right: 22px;
  background: #0f172a;
  color: #ffffff;
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 13px;
  display: none;
  z-index: 1100;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.28);
}

/* ===== Stack Global de Toasts (window.showKaToast) ===== */
.ka-toast-stack {
  position: fixed;
  top: 70px;
  right: 20px;
  z-index: 1110;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: min(380px, calc(100vw - 32px));
  pointer-events: none;
}

.ka-toast-item {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  border-radius: 10px;
  background: var(--card-bg);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-left: 4px solid var(--action-primary);
  box-shadow: var(--shadow-lg);
  font-size: 0.875rem;
  font-weight: 500;
  animation: slideIn 0.2s ease;
}

.ka-toast-item.ka-toast-success { border-left-color: #16a34a; }
.ka-toast-item.ka-toast-success .ka-toast-icon { color: #16a34a; }
.ka-toast-item.ka-toast-error,
.ka-toast-item.ka-toast-danger { border-left-color: #dc2626; }
.ka-toast-item.ka-toast-error .ka-toast-icon,
.ka-toast-item.ka-toast-danger .ka-toast-icon { color: #dc2626; }
.ka-toast-item.ka-toast-warning { border-left-color: #d97706; }
.ka-toast-item.ka-toast-warning .ka-toast-icon { color: #d97706; }
.ka-toast-item.ka-toast-info .ka-toast-icon { color: var(--action-primary); }

.ka-toast-close {
  margin-left: auto;
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 2px 4px;
  line-height: 1;
  font-size: 0.95rem;
}
.ka-toast-close:hover { color: var(--text-primary); }

/* ===== Cards de Aviso Adaptativos (Login e Dashboard, Claro & Escuro) ===== */
.ka-notice-card {
  border-radius: 0.75rem;
  border: 1px solid var(--border-color);
  border-left-width: 4px;
  padding: 1rem 1.25rem;
  box-shadow: var(--shadow);
}
.ka-notice-info {
  background: #eff6ff;
  border-color: #bfdbfe;
  border-left-color: #2563eb;
  color: #1e3a8a;
}
.ka-notice-danger {
  background: #fef2f2;
  border-color: #fecaca;
  border-left-color: #dc2626;
  color: #7f1d1d;
}
.ka-notice-updates {
  background: #f8fafc;
  border-color: #cbd5e1;
  border-left-color: #475569;
  color: #334155;
}
.ka-notice-warning {
  background: #fffbeb;
  border-color: #fde68a;
  border-left-color: #d97706;
  color: #78350f;
}

[data-theme="dark"] .ka-notice-info,
[data-bs-theme="dark"] .ka-notice-info {
  background: rgba(37, 99, 235, 0.14);
  border-color: rgba(59, 130, 246, 0.3);
  border-left-color: #60a5fa;
  color: #dbeafe;
}
[data-theme="dark"] .ka-notice-danger,
[data-bs-theme="dark"] .ka-notice-danger {
  background: rgba(220, 38, 38, 0.14);
  border-color: rgba(239, 68, 68, 0.32);
  border-left-color: #f87171;
  color: #fee2e2;
}
[data-theme="dark"] .ka-notice-updates,
[data-bs-theme="dark"] .ka-notice-updates {
  background: rgba(148, 163, 184, 0.1);
  border-color: rgba(148, 163, 184, 0.25);
  border-left-color: #94a3b8;
  color: #e2e8f0;
}
[data-theme="dark"] .ka-notice-warning,
[data-bs-theme="dark"] .ka-notice-warning {
  background: rgba(217, 119, 6, 0.14);
  border-color: rgba(245, 158, 11, 0.32);
  border-left-color: #fbbf24;
  color: #fef3c7;
}

/* ===== Layout Unificado de Autenticação & Segurança ===== */
.auth-shell {
  max-width: 460px;
  margin: 2rem auto;
  padding: 0 0.5rem;
}
.auth-shell.auth-shell-wide {
  max-width: 580px;
}
.auth-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 1rem;
  padding: 2rem;
  box-shadow: var(--shadow-lg);
}
.auth-icon-badge {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: rgba(217, 45, 32, 0.1);
  color: var(--katinu-red);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  margin-bottom: 0.75rem;
}
[data-theme="dark"] .auth-icon-badge,
[data-bs-theme="dark"] .auth-icon-badge {
  background: rgba(239, 68, 68, 0.18);
  color: #f87171;
}
.auth-title {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.35rem;
  letter-spacing: -0.02em;
}
.auth-subtitle {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
}
.ka-pass-group {
  position: relative;
}
.ka-pass-group .form-control {
  padding-right: 2.75rem;
}
.ka-pass-toggle {
  position: absolute;
  right: 0.5rem;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  color: var(--text-secondary);
  width: 32px;
  height: 32px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: color 0.15s ease, background-color 0.15s ease;
}
.ka-pass-toggle:hover {
  color: var(--text-primary);
  background: var(--bg-tertiary);
}
.auth-otp-input {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: 0.45em;
  text-align: center;
  padding-left: 1.1rem;
}
.auth-qr-box {
  display: inline-block;
  padding: 0.75rem;
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: 0.75rem;
  box-shadow: var(--shadow);
}

/* ===== Skeleton Loader Leve para Dashboard ===== */
@keyframes kaShimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.ka-loader-ring {
  width: 38px;
  height: 38px;
  border: 3px solid var(--border-color);
  border-top-color: var(--katinu-red);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto;
}
.ka-skeleton-stack {
  max-width: 780px;
  margin: 1.25rem auto 0;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}
.ka-skeleton-bar {
  height: 52px;
  border-radius: 0.75rem;
  border: 1px solid var(--border-color);
  background: linear-gradient(90deg, var(--card-bg) 25%, var(--bg-tertiary) 50%, var(--card-bg) 75%);
  background-size: 200% 100%;
  animation: kaShimmer 1.6s ease-in-out infinite;
}

/* ===== Grid de Cards da Central de Relatórios ===== */
.ka-report-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1rem;
}
.ka-report-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 0.75rem;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 1rem;
  box-shadow: var(--shadow);
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}
.ka-report-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
  border-color: var(--neutral-300);
}
[data-theme="dark"] .ka-report-card:hover,
[data-bs-theme="dark"] .ka-report-card:hover {
  border-color: #3f475a;
}
.ka-report-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}

/* ===== Dropdown da Engrenagem em Controle de Versões ===== */
.ka-gear-dropdown-btn {
  width: 32px;
  height: 31px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 0.45rem;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.ka-gear-dropdown-btn i {
  transition: transform 0.2s ease;
}
.ka-gear-dropdown-btn:hover i,
.ka-gear-dropdown-btn[aria-expanded="true"] i {
  transform: rotate(45deg);
}
.ka-gear-dropdown-menu {
  min-width: 195px;
  padding: 0.35rem;
  border-radius: 0.65rem;
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-lg);
  z-index: 1080;
}
.ka-gear-dropdown-menu .dropdown-item {
  border-radius: 0.45rem;
  padding: 0.45rem 0.7rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-primary);
}
.ka-gear-dropdown-menu .dropdown-item:hover,
.ka-gear-dropdown-menu .dropdown-item:focus {
  background: var(--bg-tertiary);
}
.ka-gear-dropdown-menu .dropdown-item.text-danger:hover,
.ka-gear-dropdown-menu .dropdown-item.text-danger:focus {
  background: rgba(220, 38, 38, 0.1);
}

/* ===== Modal / Popup "Status das Máquinas" (Claro & Escuro) ===== */
.ka-machine-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.62);
  backdrop-filter: blur(3px);
  z-index: 9998;
  animation: fadeIn 0.18s ease;
}
.ka-machine-popup {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(640px, calc(100vw - 24px));
  max-height: 85vh;
  background: var(--card-bg);
  color: var(--text-primary);
  border: 1px solid var(--card-border);
  border-radius: 1rem;
  box-shadow: 0 24px 55px rgba(0, 0, 0, 0.38);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.ka-machine-popup-head {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-secondary);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}
.ka-machine-popup-body {
  padding: 1.25rem;
  overflow-y: auto;
  flex: 1 1 auto;
}
.ka-machine-popup-foot {
  padding: 0.85rem 1.25rem;
  border-top: 1px solid var(--border-color);
  background: var(--bg-secondary);
  display: flex;
  justify-content: flex-end;
}
.ka-machine-company-banner {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-left: 4px solid var(--action-primary);
  border-radius: 0.65rem;
  padding: 0.75rem 1rem;
}
.ka-machine-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.ka-machine-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 0.75rem;
  padding: 0.95rem 1rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.ka-machine-card:hover {
  border-color: var(--neutral-400);
}
.ka-machine-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}
.ka-machine-empty-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  margin: 0 auto;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
}
.ka-machine-status-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}
.ka-machine-pill-online {
  background: rgba(22, 163, 74, 0.14);
  color: #15803d;
  border: 1px solid rgba(22, 163, 74, 0.3);
}
.ka-machine-pill-warning {
  background: rgba(217, 119, 6, 0.14);
  color: #b45309;
  border: 1px solid rgba(217, 119, 6, 0.32);
}
.ka-machine-pill-offline {
  background: rgba(220, 38, 38, 0.14);
  color: #b91c1c;
  border: 1px solid rgba(220, 38, 38, 0.32);
}
[data-theme="dark"] .ka-machine-pill-online,
[data-bs-theme="dark"] .ka-machine-pill-online {
  background: rgba(74, 222, 128, 0.16);
  color: #86efac;
  border-color: rgba(74, 222, 128, 0.32);
}
[data-theme="dark"] .ka-machine-pill-warning,
[data-bs-theme="dark"] .ka-machine-pill-warning {
  background: rgba(251, 191, 36, 0.16);
  color: #fde68a;
  border-color: rgba(251, 191, 36, 0.34);
}
[data-theme="dark"] .ka-machine-pill-offline,
[data-bs-theme="dark"] .ka-machine-pill-offline {
  background: rgba(248, 113, 113, 0.16);
  color: #fca5a5;
  border-color: rgba(248, 113, 113, 0.34);
}
.ka-machine-confirm-bar {
  background: rgba(220, 38, 38, 0.08);
  border: 1px solid rgba(220, 38, 38, 0.28);
  border-radius: 0.6rem;
  padding: 0.75rem 0.85rem;
  color: var(--text-primary);
}

/* ===== Modal Amplo de Auditoria de Sequência Fiscal ===== */
.btn-xs {
  font-size: 0.75rem;
  line-height: 1.4;
  border-radius: 0.375rem;
}
#kaAuditoriaSequenciaModal .ka-audit-modal-dialog {
  max-width: min(1440px, 96vw);
  width: 96vw;
}
#kaAuditoriaSequenciaModal .modal-content {
  background: var(--card-bg);
  color: var(--text-primary);
  border: 1px solid var(--card-border);
  border-radius: 1rem;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
}
#kaAuditoriaSequenciaModal .modal-header,
#kaAuditoriaSequenciaModal .modal-footer {
  background: var(--bg-secondary);
  border-color: var(--border-color) !important;
}
#kaAuditoriaSequenciaModal #ka-audit-table-wrap {
  max-height: 55vh;
  overflow-y: auto;
  border-color: var(--border-color) !important;
}
#kaAuditoriaSequenciaModal .ka-audit-table {
  margin-bottom: 0;
  font-variant-numeric: tabular-nums;
}
#kaAuditoriaSequenciaModal .ka-audit-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  font-size: 0.75rem;
  letter-spacing: 0.04em;
}
#kaAuditoriaSequenciaModal .ka-audit-table tbody td {
  border-color: var(--border-color);
}
#kaAuditoriaSequenciaModal .ka-audit-table tbody tr:hover > td {
  background: var(--bg-secondary);
}
#kaAuditoriaSequenciaModal code {
  display: inline-block;
  line-height: 1.3;
}
