/* ============================================================
   FiscalScan — design system v1.9.1
   Estilo: profissional B2B (Stripe + Linear inspired)
   ============================================================ */

:root {
  /* Cor primária — índigo */
  --primary:        #4f46e5;
  --primary-hover:  #4338ca;
  --primary-soft:   #eef2ff;
  --primary-dark:   #3730a3;

  /* Neutros */
  --gray-50:  #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;

  /* Status */
  --success:      #10b981;
  --success-soft: #d1fae5;
  --success-text: #065f46;
  --warn:         #f59e0b;
  --warn-soft:    #fef3c7;
  --warn-text:    #92400e;
  --danger:       #ef4444;
  --danger-soft:  #fee2e2;
  --danger-text:  #991b1b;
  --info:         #3b82f6;
  --info-soft:    #dbeafe;
  --info-text:    #1e40af;
  --pgfn:         #7c3aed;
  --pgfn-soft:    #ede9fe;
  --pgfn-text:    #5b21b6;

  /* Sombras (Stripe-style) */
  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, 0.08), 0 2px 4px -2px rgba(15, 23, 42, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(15, 23, 42, 0.08), 0 4px 6px -4px rgba(15, 23, 42, 0.05);
  --shadow-focus: 0 0 0 3px rgba(79, 70, 229, 0.18);

  /* Tipografia */
  --font-sans: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto,
               "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Mono", "Roboto Mono", monospace;

  /* Espaçamento (escala 4px) */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;

  --radius-sm: 4px;
  --radius:    6px;
  --radius-md: 8px;
  --radius-lg: 12px;

  --sidebar-width: 240px;
  --topbar-height: 64px;
  --content-max-width: 1280px;
}

/* ============================================================
   Reset & defaults — defesa em profundidade
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow-x: hidden;       /* impede scroll horizontal acidental */
}

body {
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--gray-800);
  background: var(--gray-50);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ----- SVGs e imagens à prova de explosão -----
   O comportamento default do browser para SVG sem width/height nem CSS
   é renderizar a 300x150 (HTML spec). Esta regra GARANTE que qualquer
   SVG não-tratado cai num tamanho razoável em vez de explodir.
   Macros .icon definem width/height por atributo e via classe — esta
   regra é o fallback de último recurso.                              */
img, svg {
  display: inline-block;
  vertical-align: middle;
  max-width: 100%;
}
svg {
  flex-shrink: 0;          /* não deixa flex stretchar SVG */
  width: 1em;              /* fallback se não houver width/height */
  height: 1em;
}
/* SVGs com classe explícita ganham tamanhos específicos abaixo;
   esses overridem o 1em default. SVGs com atributo width/height
   inline também sobrescrevem (atributo HTML > CSS para SVG). */

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 {
  margin: 0;
  color: var(--gray-900);
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.3;
}
h1 { font-size: 24px; letter-spacing: -0.02em; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }
h4 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--gray-500); }

p { margin: 0 0 var(--space-3); }
small { font-size: 12px; color: var(--gray-500); }
code { font-family: var(--font-mono); font-size: 12.5px; }

/* Reset de elementos pequenos para evitar surpresas */
button { font: inherit; }
table { border-collapse: collapse; width: 100%; }

/* ============================================================
   Tamanho de ícones — fonte da verdade
   Cada classe define width/height. Atributo HTML inline já garante
   tamanho nos SVGs gerados por macro; CSS aqui é confirmação +
   permite scale uniforme.
   ============================================================ */

.icon       { width: 16px; height: 16px; }
.icon-sm    { width: 12px; height: 12px; }
.icon-md    { width: 20px; height: 20px; }
.icon-lg    { width: 24px; height: 24px; }
.icon-xl    { width: 32px; height: 32px; }
.icon-2xl   { width: 48px; height: 48px; }

/* ============================================================
   App shell — sidebar fixa + main scrollable
   ============================================================ */

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  /* minmax(0, 1fr) é crucial — sem isso, conteúdo largo (tabelas,
     códigos longos) podem stretchar a coluna e quebrar o layout. */
  min-height: 100vh;
}

.sidebar {
  background: var(--gray-900);
  color: var(--gray-300);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 5;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-5);
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.sidebar-brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--primary) 0%, #6366f1 100%);
  flex-shrink: 0;
  color: white;
}
.sidebar-brand-mark svg { width: 22px; height: 22px; }

.sidebar-brand-text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.sidebar-brand-name {
  color: white; font-weight: 700; font-size: 15px;
  letter-spacing: -0.01em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar-brand-tag  {
  color: var(--gray-400); font-size: 11px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.sidebar-nav {
  flex: 1;
  padding: var(--space-3) var(--space-2);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.sidebar-nav-section {
  padding: var(--space-3) var(--space-3) var(--space-1);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--gray-500);
}
.sidebar-link {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius);
  color: var(--gray-300);
  font-size: 13.5px;
  text-decoration: none;
  cursor: pointer;
}
.sidebar-link:hover {
  background: rgba(255,255,255,0.06);
  color: white;
  text-decoration: none;
}
.sidebar-link.active {
  background: rgba(79, 70, 229, 0.18);
  color: white;
}
.sidebar-link.disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.sidebar-link.disabled:hover { background: transparent; color: var(--gray-300); }
.sidebar-link svg { width: 18px; height: 18px; color: var(--gray-400); }
.sidebar-link.active svg { color: #a5b4fc; }
.sidebar-soon {
  margin-left: auto;
  font-size: 10px;
  background: rgba(255,255,255,0.08);
  color: var(--gray-400);
  padding: 2px 6px;
  border-radius: 99px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  flex-shrink: 0;
}
.sidebar-footer {
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid rgba(255,255,255,0.06);
  font-size: 11px;
  color: var(--gray-500);
}

/* Main area */
.main-area {
  display: flex;
  flex-direction: column;
  min-width: 0;             /* impede overflow horizontal */
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: 0 var(--space-6);
  height: var(--topbar-height);
  background: white;
  border-bottom: 1px solid var(--gray-200);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar-left { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.topbar-title {
  font-size: 15px; font-weight: 600; color: var(--gray-900);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.topbar-subtitle {
  font-size: 12.5px; color: var(--gray-500);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.topbar-actions { display: flex; gap: var(--space-2); align-items: center; flex-shrink: 0; }

.content {
  padding: var(--space-8) var(--space-6);
  max-width: var(--content-max-width);
  margin: 0 auto;
  width: 100%;
  min-width: 0;
}

@media (max-width: 1100px) {
  .content { padding: var(--space-6) var(--space-5); }
}

@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    top: 0; left: 0;
    transform: translateX(-100%);
    width: var(--sidebar-width);
    z-index: 20;
    transition: transform 0.18s ease;
  }
  .sidebar.open { transform: translateX(0); }
  .topbar-mobile-toggle { display: inline-flex !important; }
  .content { padding: var(--space-5) var(--space-4); }
}
.topbar-mobile-toggle {
  display: none;
  background: transparent;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 8px;
  cursor: pointer;
  flex-shrink: 0;
}

/* ============================================================
   Page header
   ============================================================ */

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-6);
  flex-wrap: wrap;
}
.page-header > div { min-width: 0; }
.page-title { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; }
.page-subtitle { color: var(--gray-500); margin-top: 4px; font-size: 14px; max-width: 720px; }

/* Hero variant para landing */
.hero {
  text-align: center;
  padding: var(--space-8) var(--space-4) var(--space-6);
  margin-bottom: var(--space-6);
}
.hero-title { font-size: 32px; font-weight: 700; letter-spacing: -0.025em; }
@media (max-width: 600px) {
  .hero-title { font-size: 26px; }
}
.hero-subtitle {
  color: var(--gray-600);
  font-size: 16px;
  margin: var(--space-3) auto 0;
  max-width: 560px;
  line-height: 1.55;
}

/* ============================================================
   Surface + cards
   ============================================================ */

.surface {
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xs);
}
.surface-pad   { padding: var(--space-6); }
.surface-pad-lg { padding: var(--space-8); }

/* ============================================================
   Buttons
   ============================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font: inherit;
  font-weight: 500;
  font-size: 13.5px;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
  white-space: nowrap;
  transition: all 0.12s ease;
  line-height: 1.2;
}
.btn:hover { text-decoration: none; }
.btn:focus-visible { outline: none; box-shadow: var(--shadow-focus); }
.btn svg { width: 16px; height: 16px; }

.btn-primary {
  background: var(--primary);
  color: white;
  box-shadow: var(--shadow-xs);
}
.btn-primary:hover { background: var(--primary-hover); color: white; }

.btn-secondary {
  background: white;
  border-color: var(--gray-300);
  color: var(--gray-800);
  box-shadow: var(--shadow-xs);
}
.btn-secondary:hover { background: var(--gray-50); border-color: var(--gray-400); }

.btn-ghost {
  background: transparent;
  color: var(--gray-700);
}
.btn-ghost:hover { background: var(--gray-100); }

/* Outline da cor primária — usado em ações de navegação na topbar.
   Visível e alinhado com a identidade da marca, mas sem competir
   com o CTA primary sólido da tela (Stripe/Linear pattern). */
.btn-primary-outline {
  background: white;
  border-color: var(--primary);
  color: var(--primary);
  box-shadow: var(--shadow-xs);
}
.btn-primary-outline:hover {
  background: var(--primary-soft);
  border-color: var(--primary-hover);
  color: var(--primary-hover);
}
.btn-primary-outline svg { color: inherit; }

.btn-sm { padding: 6px 12px; font-size: 12.5px; }
.btn-sm svg { width: 14px; height: 14px; }
.btn-lg { padding: 12px 22px; font-size: 14.5px; }
.btn-lg svg { width: 18px; height: 18px; }
.btn-block { width: 100%; }

/* ============================================================
   Forms
   ============================================================ */

.field { margin-bottom: var(--space-5); }
.field-label {
  display: block;
  font-weight: 500;
  font-size: 13px;
  color: var(--gray-700);
  margin-bottom: 6px;
}
.field-hint {
  display: block;
  color: var(--gray-500);
  font-size: 12.5px;
  margin-top: 6px;
  line-height: 1.45;
}

input[type="text"], input[type="tel"], input[type="email"], input[type="password"], input[type="number"], input[type="search"],
textarea, select {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  font: inherit;
  font-size: 14px;
  background: white;
  color: var(--gray-900);
  transition: border-color 0.12s, box-shadow 0.12s;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: var(--shadow-focus);
}
textarea { font-family: var(--font-mono); font-size: 13px; resize: vertical; line-height: 1.5; }

.field-check {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
}
.field-check:hover { border-color: var(--gray-300); background: var(--gray-50); }
.field-check input[type="checkbox"] {
  margin-top: 2px;
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  accent-color: var(--primary);
  cursor: pointer;
}
.field-check-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.field-check-title { font-size: 13.5px; color: var(--gray-800); font-weight: 500; }
.field-check-desc  { font-size: 12.5px; color: var(--gray-500); }

/* ============================================================
   Dropzone
   ============================================================ */

.dropzone {
  border: 2px dashed var(--gray-300);
  border-radius: var(--radius-lg);
  padding: var(--space-12) var(--space-6);
  text-align: center;
  background: var(--gray-50);
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.dropzone:hover { border-color: var(--primary); background: var(--primary-soft); }
.dropzone.has-files {
  border-color: var(--primary);
  background: var(--primary-soft);
  border-style: solid;
}
.dropzone svg {
  width: 48px;
  height: 48px;
  color: var(--gray-400);
  margin-bottom: var(--space-2);
}
.dropzone:hover svg,
.dropzone.has-files svg { color: var(--primary); }
.dropzone-title {
  font-size: 16px;
  color: var(--gray-800);
  font-weight: 600;
}
.dropzone-subtitle { color: var(--gray-500); font-size: 13.5px; }
.dropzone input[type="file"] {
  position: absolute; inset: 0; opacity: 0; cursor: pointer;
  width: 100%; height: 100%;
}

/* ============================================================
   Feature cards (página inicial)
   ============================================================ */

.features-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--space-4);
}
.feature-card {
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-md);
  padding: var(--space-5);
  box-shadow: var(--shadow-xs);
  transition: border-color 0.15s, transform 0.15s;
}
.feature-card:hover { border-color: var(--gray-300); transform: translateY(-1px); }
.feature-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius);
  background: var(--primary-soft);
  color: var(--primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--space-3);
}
.feature-icon svg { width: 18px; height: 18px; }
.feature-title { font-size: 14px; font-weight: 600; color: var(--gray-900); margin-bottom: 4px; }
.feature-desc  { font-size: 13px; color: var(--gray-500); line-height: 1.5; }

/* ============================================================
   Badges
   ============================================================ */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  font-size: 11.5px;
  font-weight: 600;
  border-radius: 99px;
  letter-spacing: 0.01em;
  white-space: nowrap;
  background: var(--gray-100);
  color: var(--gray-700);
}
.badge svg { width: 12px; height: 12px; }
.badge-success { background: var(--success-soft); color: var(--success-text); }
.badge-warn    { background: var(--warn-soft);    color: var(--warn-text); }
.badge-danger  { background: var(--danger-soft);  color: var(--danger-text); }
.badge-info    { background: var(--info-soft);    color: var(--info-text); }
.badge-pgfn    { background: var(--pgfn-soft);    color: var(--pgfn-text); }
.badge-neutral { background: var(--gray-100);     color: var(--gray-700); }

/* ============================================================
   Batch — summary + cards
   ============================================================ */

.summary-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-3);
  margin-bottom: var(--space-6);
}
.summary-item {
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-md);
  padding: var(--space-4) var(--space-5);
  box-shadow: var(--shadow-xs);
  min-width: 0;
}
.summary-label {
  font-size: 11px;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
  margin-bottom: 4px;
}
.summary-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--gray-900);
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  word-break: break-word;
}
.summary-sub { font-size: 12px; color: var(--gray-500); margin-top: 2px; }

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: var(--space-4);
}

.company-card {
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-md);
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  position: relative;
  overflow: hidden;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
  box-shadow: var(--shadow-xs);
  min-width: 0;
}
.company-card:hover {
  border-color: var(--gray-300);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}
.company-card::before {
  content: "";
  position: absolute;
  top: 0; left: 0;
  width: 4px; height: 100%;
}
.company-card-ok::before      { background: var(--success); }
.company-card-revisao::before { background: var(--warn); }
.company-card-critica::before { background: var(--danger); }
.company-card-erro::before    { background: var(--gray-400); }

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-2);
}
.card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--gray-900);
  line-height: 1.3;
  word-break: break-word;
}
.card-cnpj {
  font-size: 12.5px;
  color: var(--gray-500);
  font-family: var(--font-mono);
  margin-top: 2px;
}
.card-filename {
  color: var(--gray-400);
  font-family: var(--font-mono);
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 60%;
}
.card-error-msg {
  color: var(--danger-text);
  background: var(--danger-soft);
  padding: var(--space-3);
  border-radius: var(--radius);
  font-size: 12.5px;
  line-height: 1.4;
}
.card-revisao-msg {
  font-size: 12px;
  color: var(--warn-text);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 4px;
}

.card-obrig-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #075e75;
  background: #cffafe;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  border-left: 3px solid #0891b2;
}
.card-obrig-indicator strong { color: #064e63; font-weight: 700; }

.card-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
  padding: var(--space-3) 0;
  border-top: 1px solid var(--gray-100);
  border-bottom: 1px solid var(--gray-100);
}
.card-stat-label {
  font-size: 10.5px;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 2px;
  font-weight: 600;
}
.card-stat-value {
  font-size: 16px;
  font-weight: 700;
  color: var(--gray-900);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
  word-break: break-word;
}
.card-stat-value-danger { color: var(--danger-text); }

.card-actions {
  display: flex;
  gap: var(--space-2);
  margin-top: auto;
  flex-wrap: wrap;
}
.card-actions .btn { flex: 1; min-width: 0; }

/* ============================================================
   Review (detalhe)
   ============================================================ */

.client-card {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-5);
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-6);
  box-shadow: var(--shadow-xs);
  min-width: 0;
}
.client-card-icon {
  width: 48px; height: 48px;
  background: var(--primary-soft);
  color: var(--primary);
  border-radius: var(--radius);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.client-card-icon svg { width: 24px; height: 24px; }
.client-card-body { min-width: 0; }
.client-card-title {
  font-size: 18px; font-weight: 700; letter-spacing: -0.01em;
  color: var(--gray-900);
  margin-bottom: 2px;
  word-break: break-word;
}
.client-card-meta {
  display: flex; gap: var(--space-4); flex-wrap: wrap;
  color: var(--gray-500); font-size: 13px;
}
.client-card-meta strong { color: var(--gray-700); font-weight: 500; }

.review-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 440px;
  gap: var(--space-6);
}
@media (max-width: 1100px) {
  .review-layout { grid-template-columns: 1fr; }
}

.section-overline {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--gray-500);
  font-weight: 600;
  margin: var(--space-2) 0 var(--space-3);
}
.section-overline:first-child { margin-top: 0; }

.bucket-section {
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-md);
  padding: var(--space-5);
  margin-bottom: var(--space-4);
  box-shadow: var(--shadow-xs);
  min-width: 0;
  overflow: hidden;            /* contém tabelas largas */
}
.bucket-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--gray-100);
}
.bucket-section-title {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: 14px;
  font-weight: 600;
  color: var(--gray-900);
  min-width: 0;
}
.bucket-section-title svg { width: 18px; height: 18px; flex-shrink: 0; }

.bucket-vencidos .bucket-section-title svg { color: var(--danger); }
.bucket-atraso   .bucket-section-title svg { color: var(--warn); }
.bucket-info     .bucket-section-title svg { color: var(--info); }
.bucket-pgfn     .bucket-section-title svg { color: var(--pgfn); }
.bucket-obrigacoes .bucket-section-title svg { color: #0891b2; }
.bucket-obrig    .bucket-section-title svg { color: #0d9488; } /* teal — obrigações acessórias */
.bucket-error    .bucket-section-title svg { color: var(--danger); }

.bucket-count {
  background: var(--gray-100);
  color: var(--gray-700);
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 600;
  flex-shrink: 0;
}

.empty-state {
  color: var(--gray-400);
  font-style: italic;
  font-size: 13px;
  padding: var(--space-3) 0;
}

/* Tabelas com scroll horizontal em telas pequenas */
.table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.items-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.items-table th {
  text-align: left;
  padding: var(--space-2) var(--space-3);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--gray-500);
  border-bottom: 1px solid var(--gray-200);
  background: var(--gray-50);
  white-space: nowrap;
}
.items-table td {
  padding: var(--space-3);
  border-bottom: 1px solid var(--gray-100);
  vertical-align: top;
}
.items-table tr:last-child td { border-bottom: none; }
.items-table .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-family: var(--font-mono);
  font-size: 12.5px;
  white-space: nowrap;
}
.items-table tr.row-review { background: #fffbeb; }

details summary {
  cursor: pointer;
  font-size: 11.5px;
  color: var(--gray-500);
  user-select: none;
  list-style: none;
}
details summary::-webkit-details-marker { display: none; }
details summary::before { content: "▸ "; color: var(--gray-400); }
details[open] summary::before { content: "▾ "; }

/* List items */
.item-list { list-style: none; padding: 0; margin: 0; }
.item-list li {
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--gray-100);
  font-size: 13px;
}
.item-list li:last-child { border-bottom: none; }
.item-list li.row-review { background: #fffbeb; padding-left: var(--space-2); padding-right: var(--space-2); border-radius: var(--radius-sm); }

/* Alert */
.alert {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-4);
  border-radius: var(--radius-md);
  border: 1px solid;
  margin-bottom: var(--space-5);
}
.alert svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 2px; }
.alert-title { font-weight: 600; margin-bottom: 4px; font-size: 13.5px; }
.alert-body  { font-size: 13px; line-height: 1.5; }
.alert-warning {
  background: var(--warn-soft);
  border-color: rgba(245, 158, 11, 0.3);
  color: var(--warn-text);
}
.alert-warning svg { color: var(--warn); }
.alert ul { margin: 6px 0 0; padding-left: var(--space-5); }
.alert li { margin-bottom: 2px; }

/* Sticky message panel */
.message-panel {
  position: sticky;
  top: calc(var(--topbar-height) + var(--space-4));
  max-height: calc(100vh - var(--topbar-height) - var(--space-8));
  overflow-y: auto;
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-md);
  padding: var(--space-5);
  box-shadow: var(--shadow-xs);
  min-width: 0;
}
@media (max-width: 1100px) {
  .message-panel { position: static; max-height: none; }
}
.message-panel-head {
  margin-bottom: var(--space-3);
}
.actions-row {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
  margin-top: var(--space-4);
}
.actions-row .btn { flex: 1; min-width: 0; }

/* Tags PGFN */
.tag-status {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 99px;
  white-space: nowrap;
}
.tag-status svg { width: 12px; height: 12px; }
.tag-status-critica   { background: var(--danger-soft);  color: var(--danger-text); }
.tag-status-pendente  { background: var(--warn-soft);    color: var(--warn-text); }
.tag-status-negociada { background: var(--success-soft); color: var(--success-text); }
.tag-status-neutral   { background: var(--gray-100);     color: var(--gray-600); }

.hint {
  color: var(--gray-500);
  font-size: 12.5px;
  margin-top: var(--space-3);
  padding: var(--space-3);
  background: var(--gray-50);
  border-radius: var(--radius);
  border-left: 3px solid var(--gray-300);
}

/* Approved screen */
.approved-card {
  text-align: center;
  padding: var(--space-12) var(--space-6);
  max-width: 720px;
  margin: 0 auto;
}
.approved-icon {
  width: 64px;
  height: 64px;
  background: var(--success-soft);
  color: var(--success-text);
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--space-5);
}
.approved-icon svg { width: 32px; height: 32px; }
.approved-title { font-size: 22px; margin-bottom: var(--space-2); }
.approved-message {
  text-align: left;
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: var(--space-4);
  margin: var(--space-5) 0;
  max-height: 320px;
  overflow-y: auto;
}
.approved-message pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--gray-700);
}
.approved-link {
  display: inline-block;
  margin-top: var(--space-4);
  word-break: break-all;
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--gray-50);
  padding: var(--space-3);
  border-radius: var(--radius);
  border: 1px solid var(--gray-200);
  max-width: 100%;
}

/* ============================================================
   Login (v1.7) — tela standalone, sem app shell
   ============================================================ */

.login-shell {
  width: 100%;
  max-width: 420px;
}

.login-card {
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  padding: var(--space-8);
  box-shadow: var(--shadow-lg);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-6);
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--gray-100);
}

.login-brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--primary) 0%, #6366f1 100%);
  flex-shrink: 0;
  color: white;
}

.login-brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.login-brand-name {
  color: var(--gray-900);
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.01em;
}

.login-brand-tag {
  color: var(--gray-500);
  font-size: 12px;
}

.login-title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 6px;
  color: var(--gray-900);
}

.login-subtitle {
  font-size: 14px;
  color: var(--gray-500);
  margin: 0 0 var(--space-6);
}

.login-error {
  background: var(--danger-soft);
  color: var(--danger-text);
  border: 1px solid rgba(239, 68, 68, 0.2);
  border-radius: var(--radius);
  padding: var(--space-3) var(--space-4);
  font-size: 13px;
  margin-bottom: var(--space-5);
  font-weight: 500;
}

.login-card form .field {
  margin-bottom: var(--space-4);
}

.login-card form button[type="submit"] {
  margin-top: var(--space-2);
}

.login-footer {
  margin-top: var(--space-6);
  padding-top: var(--space-4);
  border-top: 1px solid var(--gray-100);
  text-align: center;
  color: var(--gray-400);
}

/* ============================================================
   Sidebar — bloco de usuário + logout (v1.7)
   ============================================================ */

.sidebar-footer {
  padding: var(--space-4) var(--space-3);
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  font-size: 12.5px;
  color: #d1d5db;
}

.sidebar-user-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  color: #9ca3af;
  flex-shrink: 0;
}

.sidebar-user-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
}

.sidebar-logout-form {
  margin: 0;
}

.sidebar-logout-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 6px 8px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius);
  /* Vermelho discreto sobre fundo escuro — profissional, não alarmante */
  color: #f87171;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}

.sidebar-logout-btn svg {
  color: inherit;  /* ícone segue a cor do texto (vermelho) */
}

.sidebar-logout-btn:hover {
  /* Fundo avermelhado sutil + cor mais nítida; mantém legibilidade */
  background: rgba(239, 68, 68, 0.12);
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.18);
}

.sidebar-version {
  margin-top: 4px;
  padding: 0 8px;
  font-size: 11px;
  color: #6b7280;
}

/* ============================================================
   Setup — primeiro acesso (v1.8)
   ============================================================ */

.setup-badge {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: var(--space-3) var(--space-4);
  background: var(--primary-soft);
  color: var(--primary-dark);
  border-radius: var(--radius);
  margin-bottom: var(--space-5);
  font-size: 12.5px;
  border-left: 3px solid var(--primary);
}
.setup-badge strong { font-size: 13px; font-weight: 600; }

/* ============================================================
   v1.9 — Gestão de usuários e Minha Conta
   ============================================================ */

/* Flash messages (PRG pattern) */
.flash {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius);
  margin-bottom: var(--space-4);
  font-size: 13.5px;
  border-left: 3px solid;
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.flash-success {
  background: var(--success-soft);
  color: var(--success-text);
  border-left-color: var(--success);
}
.flash-error {
  background: var(--danger-soft);
  color: var(--danger-text);
  border-left-color: var(--danger);
}
.flash-warn {
  background: var(--warn-soft);
  color: var(--warn-text);
  border-left-color: var(--warn);
}
.flash-info {
  background: var(--info-soft);
  color: var(--info-text);
  border-left-color: var(--info);
}

/* Search bar */
.users-search {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
  max-width: 480px;
}
.search-input-wrap {
  position: relative;
  flex: 1;
}
.search-input-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--gray-400);
  pointer-events: none;
}
.search-input {
  padding-left: 36px !important;
}

/* Tabela de usuários */
.users-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
.users-table th {
  text-align: left;
  padding: var(--space-3) var(--space-4);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--gray-500);
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
}
.users-table td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--gray-100);
  vertical-align: middle;
}
.users-table tr:last-child td {
  border-bottom: none;
}
.users-table tr.row-inactive {
  opacity: 0.55;
  background: var(--gray-50);
}
.users-table-actions {
  text-align: right;
  white-space: nowrap;
}
.users-table-actions .btn {
  margin-left: 4px;
}

.user-cell {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}
.user-cell-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary);
  flex-shrink: 0;
}
.user-cell-name {
  font-weight: 600;
  color: var(--gray-900);
}
.user-cell-self {
  display: inline-block;
  margin-top: 2px;
  background: var(--gray-100);
  color: var(--gray-600);
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 99px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}

/* Form de usuário — flags em coluna */
.user-flags {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin-top: var(--space-4);
}

/* Password input com botão olho */
.password-input-wrap {
  position: relative;
}
.password-input-wrap input {
  padding-right: 44px;
}
.password-toggle {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--gray-400);
  border-radius: var(--radius-sm);
  transition: background 0.12s, color 0.12s;
}
.password-toggle:hover {
  background: var(--gray-100);
  color: var(--gray-700);
}
.password-toggle:focus-visible {
  outline: 2px solid var(--primary-soft);
  outline-offset: 1px;
}
.password-toggle svg {
  width: 16px;
  height: 16px;
  display: block;
}

/* Estado padrão: input type=password → mostra eye, esconde eye-off
   Estado revelado: data-shown="true" → inverte */
.password-toggle .toggle-eye-off { display: none; }
.password-toggle[data-shown="true"] .toggle-eye { display: none; }
.password-toggle[data-shown="true"] .toggle-eye-off { display: inline-flex; }

/* Indicador de força de senha */
.password-strength {
  margin-top: 6px;
  height: 4px;
  background: var(--gray-100);
  border-radius: 99px;
  overflow: hidden;
}
.password-strength-bar {
  height: 100%;
  width: 0%;
  background: var(--gray-300);
  transition: width 0.18s ease, background 0.18s ease;
  border-radius: 99px;
}

/* Minha conta — duas colunas */
@media (max-width: 800px) {
  .account-grid {
    grid-template-columns: 1fr !important;
  }
}

.account-info {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}
.account-info-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  background: linear-gradient(135deg, var(--primary) 0%, #6366f1 100%);
  color: white;
  border-radius: 50%;
  flex-shrink: 0;
}
.account-info-name {
  font-size: 17px;
  font-weight: 600;
  color: var(--gray-900);
  letter-spacing: -0.01em;
}
.account-info-email {
  color: var(--gray-500);
  font-size: 13px;
  margin-top: 2px;
}
.account-info-tag {
  margin-top: var(--space-2);
}
