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

/* ── Tokens: Light ───────────────────────────────── */
:root {
  --green:       #1a7a4a;
  --green-mid:   #158040;
  --green-light: #e6f4ec;
  --red:         #c0392b;
  --red-light:   #fdf0ee;
  --yellow:      #b45309;
  --yellow-light:#fef3cd;
  --bg:          #eef1f6;
  --surface:     #ffffff;
  --surface2:    #f4f6f9;
  --border:      #dde1e8;
  --text:        #0f1923;
  --text-muted:  #64748b;
  --sidebar-bg:  #16202e;
  --sidebar-text:#c8d3e0;
  --sidebar-muted:#6b7f96;
  --sidebar-active-bg: rgba(26,122,74,0.20);
  --sidebar-active:    #4ade80;
  --header-bg:   #ffffff;
  --radius:      10px;
  --shadow:      0 1px 3px rgba(0,0,0,0.07), 0 4px 12px rgba(0,0,0,0.04);
  --shadow-md:   0 2px 8px rgba(0,0,0,0.10), 0 8px 24px rgba(0,0,0,0.06);
}

/* ── Tokens: Dark ────────────────────────────────── */
[data-theme="dark"] {
  --bg:          #0c1118;
  --surface:     #151d28;
  --surface2:    #1c2535;
  --border:      #263041;
  --text:        #e2e8f0;
  --text-muted:  #7a8fa8;
  --sidebar-bg:  #0d1520;
  --header-bg:   #111927;
  --green-light: #0a2318;
  --red-light:   #2a0e0b;
  --yellow-light:#261800;
}

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-size: 14px; color: var(--text);
  background: var(--bg); min-height: 100vh;
  display: flex; transition: background 0.25s, color 0.25s;
}

/* ── Sidebar ─────────────────────────────────────── */
:root { --sidebar-w: 224px; --sidebar-collapsed-w: 58px; }

.sidebar {
  width: var(--sidebar-w); min-height: 100vh;
  background: var(--sidebar-bg);
  border-right: 1px solid rgba(255,255,255,0.05);
  display: flex; flex-direction: column; overflow: hidden;
  position: fixed; top: 0; left: 0; bottom: 0; z-index: 200;
  transition: width 0.22s ease;
}
.sidebar.collapsed { width: var(--sidebar-collapsed-w); }

.sidebar-logo {
  padding: 16px; border-bottom: 1px solid rgba(255,255,255,0.07);
  display: flex; flex-direction: column; gap: 10px;
  overflow: hidden;
}
.sidebar-logo-row {
  display: flex; align-items: center; justify-content: space-between; width: 100%;
}
.sidebar-logo-box {
  width: 44px; height: 44px; border-radius: 10px; flex-shrink: 0;
  background: #fff; display: flex; align-items: center; justify-content: center;
  padding: 5px; box-shadow: 0 1px 4px rgba(0,0,0,0.2);
  transition: opacity 0.18s, width 0.22s, margin 0.22s;
}
.logo { max-width: 100%; max-height: 100%; width: auto; height: auto; object-fit: contain; }
.sidebar-brand-name {
  font-size: 15px; font-weight: 800; color: #fff;
  white-space: normal; line-height: 1.3;
  letter-spacing: .01em; width: 100%;
  transition: opacity 0.18s, max-height 0.22s, margin 0.22s;
}
.sidebar.collapsed .sidebar-logo-box { opacity: 0; width: 0; margin: 0 auto; pointer-events: none; }
.sidebar.collapsed .sidebar-logo-row { justify-content: center; }
.sidebar.collapsed .sidebar-brand-name { opacity: 0; max-height: 0; margin: 0; pointer-events: none; }

.btn-sidebar-toggle {
  background: rgba(255,255,255,0.06); border: none; cursor: pointer;
  color: var(--sidebar-muted); font-size: 13px; line-height: 1;
  padding: 6px 9px; border-radius: 6px; flex-shrink: 0;
  transition: background 0.15s, color 0.15s, transform 0.22s;
}
.btn-sidebar-toggle:hover { background: rgba(255,255,255,0.12); color: var(--sidebar-text); }
.sidebar.collapsed .btn-sidebar-toggle { transform: rotate(180deg); margin: 0 auto; }

.sidebar-nav { flex: 1; padding: 12px 8px; display: flex; flex-direction: column; gap: 2px; overflow: hidden; }
.nav-item {
  display: flex; align-items: center; gap: 11px; padding: 10px 12px;
  background: none; border: none; cursor: pointer; border-radius: 8px;
  font-size: 13.5px; font-weight: 500; color: var(--sidebar-muted);
  text-align: left; width: 100%; white-space: nowrap;
  transition: background 0.12s, color 0.12s; position: relative;
}
.nav-item:hover  { background: rgba(255,255,255,0.07); color: var(--sidebar-text); }
.nav-item.active { background: var(--sidebar-active-bg); color: var(--sidebar-active); font-weight: 600; }
.nav-icon { font-size: 17px; flex-shrink: 0; width: 22px; text-align: center; }
.nav-icon-flip { display: inline-block; transform: scaleX(-1); }
.nav-label { max-width: 160px; overflow: hidden; transition: max-width 0.22s ease, opacity 0.15s; }
.sidebar.collapsed .nav-label { max-width: 0; opacity: 0; }

.sidebar.collapsed .nav-item::after {
  content: attr(data-tooltip);
  position: absolute; left: calc(var(--sidebar-collapsed-w) + 8px); top: 50%;
  transform: translateY(-50%);
  background: #1e293b; color: #e2e8f0;
  font-size: 12px; font-weight: 600; padding: 5px 11px;
  border-radius: 7px; white-space: nowrap; box-shadow: var(--shadow-md);
  opacity: 0; pointer-events: none; transition: opacity 0.15s; z-index: 300;
}
.sidebar.collapsed .nav-item:hover::after { opacity: 1; }

/* ── Grupos de menu expansíveis (Importação / Exportação) ─ */
.nav-group-header {
  display: flex; align-items: center; gap: 11px; padding: 10px 12px;
  background: none; border: none; cursor: pointer; border-radius: 8px;
  font-size: 13.5px; font-weight: 500; color: var(--sidebar-muted);
  text-align: left; width: 100%; white-space: nowrap;
  transition: background 0.12s, color 0.12s; position: relative;
}
.nav-group-header:hover { background: rgba(255,255,255,0.07); color: var(--sidebar-text); }
.nav-group-chevron { margin-left: auto; font-size: 11px; transition: transform 0.18s ease; flex-shrink: 0; }
.nav-group.expanded .nav-group-chevron { transform: rotate(180deg); }
.sidebar.collapsed .nav-group-chevron { display: none; }

.nav-submenu {
  display: flex; flex-direction: column; gap: 2px;
  max-height: 0; overflow: hidden; padding-left: 14px;
  transition: max-height 0.22s ease;
}
.nav-group.expanded .nav-submenu { max-height: 200px; }
.sidebar.collapsed .nav-submenu { padding-left: 0; }
.nav-submenu .nav-item { font-size: 13px; }

.nav-submenu-vazio {
  font-size: 12px; color: var(--sidebar-muted); opacity: .6;
  padding: 8px 12px; font-style: italic;
}
.sidebar.collapsed .nav-submenu-vazio { display: none; }

.sidebar-footer {
  padding: 14px 16px; border-top: 1px solid rgba(255,255,255,0.07);
  display: flex; flex-direction: column; gap: 5px; overflow: hidden;
}
.sidebar-clock { display: flex; flex-direction: column; gap: 1px; }
.clock-time { font-size: 17px; font-weight: 700; color: var(--sidebar-text);
  letter-spacing: 0.06em; font-variant-numeric: tabular-nums; white-space: nowrap; }
.clock-date { font-size: 11px; color: var(--sidebar-muted); white-space: nowrap; }
.sidebar-version { font-size: 11px; color: var(--sidebar-muted); white-space: nowrap; }
.sidebar-clock, .sidebar-version { transition: opacity 0.18s; }
.sidebar.collapsed .sidebar-clock,
.sidebar.collapsed .sidebar-version { opacity: 0; pointer-events: none; }

/* ── Main wrapper ────────────────────────────────── */
.main-wrapper { margin-left: var(--sidebar-w); flex: 1; display: flex; flex-direction: column; min-height: 100vh; transition: margin-left 0.22s ease; }
.main-wrapper.collapsed { margin-left: var(--sidebar-collapsed-w); }

/* ── Header ──────────────────────────────────────── */
header {
  background: var(--header-bg); border-bottom: 1px solid var(--border);
  padding: 0 28px; height: 60px; position: sticky; top: 0; z-index: 100;
  box-shadow: 0 1px 0 var(--border); transition: background 0.25s;
  display: flex; align-items: center;
}
.header-inner { display: flex; align-items: center; gap: 14px; width: 100%; }
.header-title { flex: 1; }
.header-title h1 { font-size: 16px; font-weight: 700; color: var(--text); letter-spacing: -0.01em; }
.header-title p  { font-size: 12px; color: var(--text-muted); margin-top: 1px; }
.header-actions  { display: flex; align-items: center; gap: 10px; }
.btn-theme {
  background: var(--surface2); border: 1px solid var(--border); border-radius: 99px;
  padding: 6px 14px; cursor: pointer; font-size: 12px; font-weight: 600; color: var(--text);
  display: flex; align-items: center; gap: 6px;
  transition: background 0.15s;
}
.btn-theme:hover { background: var(--border); }
.btn-idiomas {
  display: flex; align-items: center; gap: 4px;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 99px; padding: 3px 6px;
}
.btn-flag {
  background: none; border: none; cursor: pointer;
  font-size: 18px; line-height: 1; padding: 2px 4px;
  border-radius: 6px; opacity: 0.45;
  transition: opacity 0.15s, transform 0.15s;
}
.btn-flag:hover { opacity: 0.8; transform: scale(1.15); }
.btn-flag.active { opacity: 1; transform: scale(1.15); }

/* ── Main / Footer ───────────────────────────────── */
main { flex: 1; padding: 24px 28px 48px; max-width: 1300px; width: 100%; }
footer { text-align: center; padding: 14px; font-size: 11px; color: var(--text-muted); border-top: 1px solid var(--border); background: var(--header-bg); display: flex; align-items: center; justify-content: center; gap: 10px; }
.footer-linkedin { display: inline-flex; align-items: center; justify-content: center; color: var(--text-muted); opacity: .7; transition: opacity .15s, color .15s; }
.footer-linkedin:hover { opacity: 1; color: #0a66c2; }

/* ── Cards ───────────────────────────────────────── */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 24px; margin-bottom: 18px;
  box-shadow: var(--shadow);
}
.card h2 { font-size: 16px; font-weight: 700; margin-bottom: 20px; color: var(--text); letter-spacing: -0.01em; }
.card h3 { font-size: 14px; font-weight: 700; margin-bottom: 16px; color: var(--text); }
.page-header-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.page-header-row h2 { margin-bottom: 0; }

/* ── Botões ──────────────────────────────────────── */
.btn-primary, .btn-secondary {
  cursor: pointer; border: none; border-radius: 8px;
  font-size: 13.5px; font-weight: 600; padding: 9px 20px;
  transition: opacity 0.15s, background 0.15s, box-shadow 0.15s;
}
.btn-primary  { background: var(--green); color: #fff; box-shadow: 0 1px 3px rgba(26,122,74,0.3); }
.btn-primary:hover    { background: var(--green-mid); box-shadow: 0 2px 8px rgba(26,122,74,0.35); }
.btn-primary:disabled { opacity: 0.5; cursor: default; box-shadow: none; }
.btn-secondary { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover  { background: var(--border); }
.btn-secondary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-secondary:disabled:hover { background: var(--surface2); }

/* ── Upload card ─────────────────────────────────── */
#card-upload {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 24px; margin-bottom: 18px;
  box-shadow: var(--shadow);
}
.ref-topo { display: flex; gap: 12px; margin-bottom: 20px; }
.ref-topo .form-group { margin-bottom: 0; }

.docs-info {
  background: var(--surface2); border: 1px solid var(--border);
  border-left: 3px solid var(--green); border-radius: 8px;
  padding: 11px 16px; margin-bottom: 16px; font-size: 13px; color: var(--text-muted);
}
.docs-info strong { color: var(--text); }

/* ── Grade de documentos ─────────────────────────── */
.docs-grid {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 10px; margin-bottom: 20px;
}
.doc-slot {
  border: 1.5px dashed var(--border); border-radius: var(--radius);
  padding: 14px 16px; cursor: pointer; position: relative;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
  display: flex; flex-direction: column; gap: 6px;
  background: var(--surface2);
}
.doc-slot:hover       { border-color: var(--green); background: var(--green-light); box-shadow: 0 0 0 3px rgba(26,122,74,0.08); }
.doc-slot.loaded      { border-style: solid; border-color: var(--green); background: var(--green-light); }
.doc-slot.master      { border-color: var(--green); border-style: solid; background: var(--green-light); }
[data-theme="dark"] .doc-slot { background: var(--surface2); }
[data-theme="dark"] .doc-slot.master,
[data-theme="dark"] .doc-slot.loaded { background: #0a2318; }

.doc-slot-num { font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; color: var(--text-muted); }
.doc-slot.master .doc-slot-num { color: var(--green); }
.doc-slot-nome { font-size: 13px; font-weight: 700; color: var(--text); line-height: 1.3; }
.doc-slot-desc { font-size: 11px; color: var(--text-muted); }
.doc-slot-status { font-size: 11px; font-weight: 600; margin-top: 2px; display: flex; align-items: center; gap: 4px; }
.doc-slot-status.vazio    { color: var(--text-muted); }
.doc-slot-status.carregado { color: var(--green); }
.doc-slot-badge-mestre {
  position: absolute; top: 10px; right: 10px;
  background: var(--green); color: #fff;
  font-size: 9px; font-weight: 800; text-transform: uppercase;
  padding: 2px 7px; border-radius: 99px; letter-spacing: .06em;
}
.doc-slot-badge-opcional {
  position: absolute; top: 10px; right: 10px;
  background: var(--surface2); color: var(--text-muted); border: 1px solid var(--border);
  font-size: 9px; font-weight: 800; text-transform: uppercase;
  padding: 2px 7px; border-radius: 99px; letter-spacing: .06em;
}
.doc-file-input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }

/* ── Upload actions ──────────────────────────────── */
.upload-actions { display: flex; align-items: center; justify-content: space-between; }
.upload-contador { font-size: 13px; color: var(--text-muted); font-weight: 500; }
.btn-analisar { padding: 10px 32px; font-size: 14px; white-space: nowrap; }

/* ── Form / Inputs ───────────────────────────────── */
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-weight: 600; margin-bottom: 5px; font-size: 11.5px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .03em; }
input[type="text"], input[type="number"], input[type="email"], input[type="password"], input[type="tel"], select {
  width: 100%; border: 1px solid var(--border); border-radius: 8px;
  padding: 11px 14px; font-size: 14px; color: var(--text);
  background: var(--surface); outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, select:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(26,122,74,0.12); }
.obrigatorio { color: var(--red); }

/* ── Processando ─────────────────────────────────── */
.processando-content { text-align: center; padding: 48px 0; }
.processando-content h3 { margin: 16px 0 8px; font-size: 16px; color: var(--text); }
.spinner { width: 40px; height: 40px; border: 3px solid var(--border); border-top-color: var(--green); border-radius: 50%; animation: spin 0.8s linear infinite; margin: 0 auto; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Resultado header ────────────────────────────── */
.resultado-header { display: flex; align-items: center; gap: 24px; flex-wrap: wrap; }
.resultado-ref { flex: 1; }
.label-ref { font-size: 11px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; }
.resultado-ref h2 { margin: 4px 0 0; color: var(--text); font-size: 20px; }
.metricas { display: flex; gap: 8px; }
.metrica { text-align: center; padding: 12px 16px; border-radius: 10px; min-width: 82px; }
.metrica.conforme   { background: var(--green-light);  color: var(--green); }
.metrica.divergente { background: var(--red-light);    color: var(--red); }
.metrica.ausente    { background: var(--yellow-light); color: var(--yellow); }
.metrica.taxa       { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.metrica.conforme, .metrica.divergente, .metrica.ausente { cursor: pointer; border: 2px solid transparent; transition: border-color .15s, transform .1s; user-select: none; }
.metrica.conforme:hover, .metrica.divergente:hover, .metrica.ausente:hover { transform: translateY(-1px); }
.metrica.conforme.filtro-ativo   { border-color: var(--green); }
.metrica.divergente.filtro-ativo { border-color: var(--red); }
.metrica.ausente.filtro-ativo    { border-color: var(--yellow); }
.metrica-valor { display: block; font-size: 26px; font-weight: 800; letter-spacing: -0.02em; }
.metrica-label { display: block; font-size: 10px; font-weight: 700; margin-top: 2px; text-transform: uppercase; letter-spacing: .04em; }
.resultado-acoes { display: flex; gap: 10px; }

/* ── Doc badges ──────────────────────────────────── */
.doc-badge { display: inline-flex; align-items: center; gap: 8px; padding: 7px 12px; border-radius: 8px; border: 1px solid var(--border); font-size: 13px; margin: 3px 3px 3px 0; background: var(--surface2); color: var(--text); }
.badge-tipo { font-weight: 600; }
.badge-conf { font-size: 11px; padding: 2px 7px; border-radius: 99px; font-weight: 700; }
.conf-high   { background: var(--green-light);  color: var(--green); }
.conf-medium { background: var(--yellow-light); color: var(--yellow); }
.conf-low    { background: var(--red-light);    color: var(--red); }
.btn-ver-pdf {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: 6px; font-size: 11px; font-weight: 600;
  background: var(--surface2); border: 1px solid var(--border); color: var(--text);
  text-decoration: none; transition: background 0.12s, border-color 0.12s;
  white-space: nowrap;
}
.btn-ver-pdf:hover { background: var(--green-light); border-color: var(--green); color: var(--green); }

.alerta-extraction { margin-top: 6px; padding: 8px 12px; background: var(--yellow-light); border-left: 3px solid var(--yellow); border-radius: 4px; font-size: 12px; color: #92400e; }
[data-theme="dark"] .alerta-extraction { color: #f5b942; }

/* ── Doc card (documentos processados) ───────────────── */
.doc-card { border: 1px solid var(--border); border-radius: 8px; background: var(--surface2); margin-bottom: 8px; overflow: hidden; cursor: pointer; transition: box-shadow .15s; }
.doc-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,.08); }
.doc-card-header { display: flex; align-items: center; gap: 8px; padding: 9px 12px; flex-wrap: wrap; }
.doc-filename { font-size: 12px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-card-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; flex-shrink: 0; }
.toggle-note-btn { font-size: 11px; color: var(--primary); font-weight: 600; white-space: nowrap; padding: 2px 6px; border-radius: 4px; border: 1px solid var(--primary); pointer-events: none; }
.audit-custo-toggle { font-size: 12px; color: var(--text-muted,#6b7280); cursor: pointer; user-select: none; transition: color .15s; }
.audit-custo-toggle:hover { color: var(--text); }

/* painel de campos */
.doc-fields-panel { border-top: 1px solid var(--border); padding: 12px 14px; background: var(--surface); }
.doc-fields-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.doc-fields-table tr + tr td { border-top: 1px solid var(--border); }
.df-label { color: var(--text-muted, #6b7280); padding: 5px 10px 5px 0; white-space: nowrap; width: 150px; font-weight: 500; }
.df-val { color: var(--text); padding: 5px 0; word-break: break-word; }
.df-val.field-absent { color: var(--text-muted, #9ca3af); font-style: italic; }
.item-row td { background: var(--surface2); }
.doc-fields-nota { margin-top: 10px; padding: 7px 10px; background: var(--yellow-light); border-left: 3px solid var(--yellow); border-radius: 4px; font-size: 11px; color: #92400e; }
[data-theme="dark"] .doc-fields-nota { color: #f5b942; }

/* ── Tabelas ─────────────────────────────────────── */
.grupo-secao-titulo {
  font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em;
  color: var(--green); margin: 24px 0 10px; padding-bottom: 6px;
  border-bottom: 2px solid var(--green);
}
.grupo-secao-titulo:first-child { margin-top: 0; }

/* ── Filtro de comparações por documento ─────────── */
.filtro-doc-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.filtro-doc-chip {
  background: var(--surface2); border: 1px solid var(--border); color: var(--text);
  font-size: 12.5px; font-weight: 600; padding: 7px 14px; border-radius: 99px;
  cursor: pointer; transition: background .15s, border-color .15s, color .15s;
}
.filtro-doc-chip:hover { background: var(--border); }
.filtro-doc-chip.active { background: var(--green); border-color: var(--green); color: #fff; }
.comparacao-card { margin-bottom: 14px; }
.comparacao-card-header { margin-bottom: 4px; }
.comparacao-card-header h4 { font-size: 14px; font-weight: 700; color: var(--text); }
.comparacao-card-desc { font-size: 12px; color: var(--text-muted); margin-bottom: 12px; }
.itens-collapse-header { display:flex; justify-content:space-between; align-items:center; cursor:pointer; background:var(--bg-secondary); border:1px solid var(--border); border-radius:6px; padding:8px 12px; margin:10px 0 0; font-size:13px; font-weight:600; color:var(--text); user-select:none; }
.itens-collapse-header:hover { background:var(--border); }
.itens-collapse-header.open > span:first-child { color: var(--green); }
.itens-collapse-status-resumo { display: flex; gap: 6px; }
.itens-collapse-status-resumo .status-badge { font-size: 10.5px; padding: 3px 8px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; padding: 9px 12px; font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); background: var(--surface2); border-bottom: 1px solid var(--border); }
td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; color: var(--text); }
tr:last-child td { border-bottom: none; }
.status-badge { display: inline-block; padding: 3px 10px; border-radius: 99px; font-size: 11px; font-weight: 700; }
.status-diff-pct { display: inline-block; margin-left: 6px; font-size: 11px; font-weight: 600; color: var(--text-muted,#6b7280); }
.status-ajuste-link {
  background: none; border: none; cursor: pointer; padding: 0; margin-left: 6px;
  font-size: 11px; font-weight: 700; color: var(--green); text-decoration: underline;
}
.status-ajuste-link:hover { color: var(--green-mid); }
.status-ajuste-nota { font-size: 10.5px; color: var(--text-muted); margin-top: 3px; }
.status-conforme   { background: var(--green-light);  color: var(--green); }
.status-divergente { background: var(--red-light);    color: var(--red); }
.status-ausente    { background: var(--yellow-light); color: var(--yellow); }
.val-null { color: var(--text-muted); font-style: italic; }
.diff-pct { font-size: 11px; color: var(--text-muted); }

/* ── Histórico ───────────────────────────────────── */
.dash-filtros,
.hist-filtros { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 14px; }
.hist-filtro-campo { display: flex; flex-direction: column; gap: 4px; min-width: 200px; }
.hist-filtro-campo label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); }
.hist-filtro-campo select {
  padding: 8px 10px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface2); color: var(--text); font-size: 13px;
}
.hist-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 14px; border-bottom: 1px solid var(--border);
  cursor: pointer; border-radius: 8px; margin: 1px 0;
  transition: background 0.12s;
}
.hist-row:last-child { border-bottom: none; }
.hist-row:hover { background: var(--surface2); }
.hist-info { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.hist-ref  { font-weight: 700; color: var(--text); font-size: 14px; }
.hist-audit-line { font-size: 12px; color: var(--text-muted); margin-top: 1px; }
.hist-metricas { display: flex; gap: 5px; margin-top: 5px; flex-wrap: wrap; }
.hm { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 99px; }
.hm.conforme   { background: var(--green-light);  color: var(--green); }
.hm.divergente { background: var(--red-light);    color: var(--red); }
.hm.ausente    { background: var(--yellow-light); color: var(--yellow); }
.hm.taxa       { background: var(--surface2); color: var(--text-muted); border: 1px solid var(--border); }
.hist-acoes { display: flex; align-items: center; gap: 10px; flex-shrink: 0; padding-left: 16px; }
.btn-excluir {
  background: none; border: none; cursor: pointer; font-size: 15px;
  padding: 5px 7px; border-radius: 6px; color: var(--text-muted);
  transition: background 0.12s, color 0.12s; line-height: 1;
}
.btn-excluir:hover { background: var(--red-light); color: var(--red); }
.btn-excluir-bloqueado {
  font-size: 13px; padding: 5px 7px; color: var(--text-muted);
  opacity: .55; cursor: default; line-height: 1;
}
.status-pill { padding: 3px 11px; border-radius: 99px; font-size: 11px; font-weight: 700; white-space: nowrap; }
.pill-concluida   { background: var(--green-light);  color: var(--green); }
.pill-processando { background: var(--yellow-light); color: var(--yellow); }
.pill-erro        { background: var(--red-light);    color: var(--red); }
.hist-validado { font-size: 11px; font-weight: 600; color: var(--green); margin-top: 4px; display: block; }
.hist-pendente { font-size: 11px; color: var(--text-muted); margin-top: 4px; display: block; }
.hist-custo { font-size: 11px; font-weight: 600; color: var(--text-muted,#6b7280); margin-top: 4px; display: block; }

/* ── Configurações ───────────────────────────────── */
.config-section { margin-bottom: 28px; }
.config-section h3 { font-size: 13px; font-weight: 700; margin-bottom: 14px; padding-bottom: 8px; border-bottom: 1px solid var(--border); color: var(--text); text-transform: uppercase; letter-spacing: .04em; }
.cfg-section-title { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted,#6b7280); margin: 0 0 16px; }
.cfg-section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.cfg-section-header .cfg-section-title { margin: 0; }

/* ── Formulário novo usuário ─────────────────────── */
.novo-usuario-form {
  display: none;
  margin-bottom: 24px;
  padding: 24px;
  background: var(--surface2);
  border-radius: 12px;
  border: 1px solid var(--border);
}
.novo-usuario-form-title {
  margin: 0 0 20px;
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}
.novo-usuario-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px 20px;
}
.novo-usuario-grid .form-group { margin-bottom: 0; }
.novo-usuario-grid label { font-size: 12px; }

.senha-gerar-wrap { display: flex; gap: 8px; }
.senha-gerar-wrap input { flex: 1; min-width: 0; }
.btn-gerar-senha {
  flex-shrink: 0;
  padding: 0 16px;
  background: var(--surface3, #e5e7eb);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: background .15s;
  white-space: nowrap;
}
.btn-gerar-senha:hover { background: var(--surface, #f3f4f6); }

.novo-usuario-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 22px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}
.novo-usuario-actions .btn-primary,
.novo-usuario-actions .btn-secondary { padding: 11px 22px; font-size: 14px; }

.novo-usuario-msg { font-size: 13px; margin-top: 10px; min-height: 18px; }

/* ── Dashboard ─────────────────────────────────────── */
.kpi-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px;
  margin-bottom: 20px;
}
.kpi-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 20px; display: flex; flex-direction: column; gap: 6px;
}
.kpi-label { font-size: 12px; font-weight: 600; color: var(--text-muted,#6b7280); text-transform: uppercase; letter-spacing: .03em; }
.kpi-value { font-size: 32px; font-weight: 800; color: var(--text); letter-spacing: -0.02em; }
.kpi-card.kpi-taxa { background: var(--green-light); border-color: transparent; }
.kpi-card.kpi-taxa .kpi-value { color: var(--green); }
.kpi-card.kpi-taxa .kpi-label { color: var(--green); }

.bar-chart { display: flex; flex-direction: column; gap: 14px; }
.bar-row { display: grid; grid-template-columns: 160px 1fr 40px 48px; align-items: center; gap: 12px; }
.bar-label { font-size: 13px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-track { height: 12px; background: var(--surface2); border-radius: 99px; overflow: hidden; }
.bar-fill { height: 100%; background: linear-gradient(90deg, var(--green-mid), var(--green)); border-radius: 99px; transition: width .3s ease; }
.bar-value { font-size: 13px; font-weight: 700; color: var(--text); text-align: right; }
.bar-taxa { font-size: 11px; font-weight: 600; color: var(--text-muted,#6b7280); text-align: right; }

.dash-row-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }

/* Tendência (gráfico de barras verticais) */
.trend-chart { display: flex; align-items: flex-end; gap: 5px; height: 130px; padding-top: 8px; }
.trend-bar-wrap { flex: 1; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 6px; }
.trend-bar { width: 100%; max-width: 18px; background: linear-gradient(180deg, var(--green), var(--green-mid)); border-radius: 3px 3px 0 0; min-height: 2px; transition: height .3s ease; }
.trend-day { font-size: 9px; color: var(--text-muted,#6b7280); white-space: nowrap; }

/* Distribuição (barra empilhada) */
.dist-bar { display: flex; height: 22px; border-radius: 8px; overflow: hidden; background: var(--surface2); margin-bottom: 14px; }
.dist-seg { height: 100%; transition: width .3s ease; }
.dist-conforme   { background: var(--green); }
.dist-divergente { background: var(--red); }
.dist-ausente    { background: var(--yellow); }
.dist-legend { display: flex; flex-direction: column; gap: 8px; }
.dist-legend-item { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text); }
.dist-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; display: inline-block; }

/* Ranking de campos divergentes */
.rank-list { display: flex; flex-direction: column; gap: 10px; }
.rank-row { display: grid; grid-template-columns: 22px 130px 1fr 30px; align-items: center; gap: 10px; }
.rank-pos { font-size: 12px; font-weight: 800; color: var(--text-muted,#6b7280); text-align: center; }
.rank-label { font-size: 13px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rank-track { height: 10px; background: var(--surface2); border-radius: 99px; overflow: hidden; }
.rank-fill { height: 100%; background: linear-gradient(90deg, var(--red-light), var(--red)); border-radius: 99px; }
.rank-count { font-size: 13px; font-weight: 700; color: var(--red); text-align: right; }

/* Atividade recente */
.ativ-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 4px; border-bottom: 1px solid var(--border); cursor: pointer;
  transition: background .12s;
}
.ativ-row:last-child { border-bottom: none; }
.ativ-row:hover { background: var(--surface2); }
.ativ-info { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.ativ-ref { font-size: 13.5px; font-weight: 700; color: var(--text); }
.ativ-cliente { font-size: 12px; }
.ativ-status { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.ativ-taxa { font-size: 13px; font-weight: 700; color: var(--text); }
.ativ-validado { color: var(--green); font-weight: 800; font-size: 13px; }

@media (max-width: 900px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .bar-row { grid-template-columns: 100px 1fr 32px 40px; gap: 8px; }
  .dash-row-2col { grid-template-columns: 1fr; }
  .rank-row { grid-template-columns: 20px 90px 1fr 26px; }
}

/* ── Tabela de usuários ───────────────────────────── */
.tabela-usuarios { width: 100%; border-collapse: collapse; font-size: 14px; }
.tabela-usuarios thead th {
  text-align: left; padding: 10px 14px;
  border-bottom: 2px solid var(--border);
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  color: var(--text-muted, #6b7280);
}
.tabela-usuarios tbody tr { border-bottom: 1px solid var(--border); }
.tabela-usuarios tbody tr:hover { background: var(--surface2); }
.tabela-usuarios tbody td { padding: 14px; vertical-align: middle; }
.tu-nome { font-weight: 600; color: var(--text); }
.tu-email { color: var(--text-muted, #6b7280); }
.tu-perfil-badge {
  display: inline-block; font-size: 12px; font-weight: 600;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 6px; padding: 4px 10px;
}
.tu-perfil-select {
  font-size: 12px; font-weight: 600; color: var(--text);
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 6px; padding: 5px 8px; cursor: pointer;
}
.tu-perfil-select:disabled { opacity: 0.6; cursor: not-allowed; }
.tu-status { font-size: 13px; font-weight: 600; }
.tu-status-ativo   { color: var(--green); }
.tu-status-inativo { color: #ef4444; }
.tu-acoes { text-align: right; white-space: nowrap; }
.tu-btn-acao { font-size: 12px; padding: 6px 12px; margin-left: 6px; }
.tu-btn-excluir { color: #ef4444; }
.tu-btn-excluir:hover { background: #fef2f2; border-color: #fecaca; }
.tu-voce { font-size: 12px; font-style: italic; }
.config-table { width: 100%; border-collapse: collapse; }
.config-table th { background: var(--surface2); }
.config-table td, .config-table th { padding: 10px 12px; border-bottom: 1px solid var(--border); }
.config-table tr:last-child td { border-bottom: none; }
.cfg-input { width: 80px !important; text-align: center; padding: 6px 8px !important; font-size: 13px !important; }
.cfg-input:disabled { background: var(--surface2); color: var(--text-muted); cursor: not-allowed; }

/* ─── Cadastros ─── */
.cadastros-layout { display: grid; grid-template-columns: 280px 1fr; gap: 16px; align-items: start; }
@media (max-width: 768px) { .cadastros-layout { grid-template-columns: 1fr; } }
.cadastros-clientes .cliente-row {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; border-radius: 8px; cursor: pointer;
  transition: background 0.12s;
}
.cadastros-clientes .cliente-row:hover { background: var(--surface2); }
.cadastros-clientes .cliente-row.active { background: rgba(26,122,74,0.12); }
.cliente-nome { font-weight: 600; font-size: 13px; flex: 1; display: flex; flex-direction: column; gap: 2px; }
.cliente-cnpj, .cliente-cidade { font-weight: 500; font-size: 11px; }
.cliente-maps { font-size: 12px; }
.cnpj-erro { font-size: 12px; color: #ef4444; margin-top: 5px; }
.cliente-acoes { display: flex; gap: 4px; opacity: 0; transition: opacity 0.12s; }
.cliente-row:hover .cliente-acoes { opacity: 1; }
.btn-icon { background: none; border: none; cursor: pointer; font-size: 14px; padding: 2px 4px; border-radius: 4px; }
.btn-icon:hover { background: var(--border); }
.mapeamento-table td { font-size: 13px; }
.mapeamento-table code { font-size: 12px; background: var(--surface2); padding: 2px 6px; border-radius: 4px; }
.form-actions { display: flex; justify-content: flex-end; padding-top: 8px; }
.cfg-hint { font-size: 11px; color: var(--text-muted); margin-top: 5px; }
.cfg-feedback { margin-top: 14px; padding: 10px 16px; background: var(--green-light); color: var(--green); border-radius: 8px; font-weight: 600; font-size: 13px; }

/* ── Auditoria ───────────────────────────────────── */
.audit-card h3 { margin-bottom: 16px; }
.audit-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 40px; margin-bottom: 20px; }
.audit-item { display: flex; flex-direction: column; gap: 3px; }
.audit-label { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); }
.audit-value { font-size: 14px; font-weight: 600; color: var(--text); }
.audit-action { display: flex; align-items: center; gap: 10px; padding-top: 16px; border-top: 1px solid var(--border); flex-wrap: wrap; }

/* ── Erro ────────────────────────────────────────── */
.erro-content { text-align: center; padding: 32px 0; }
.erro-icon { font-size: 40px; }
.erro-content h3 { margin: 12px 0 8px; color: var(--text); }
.erro-content .btn-primary { margin-top: 16px; }

/* ── Usuário na sidebar ──────────────────────────── */
.sidebar-usuario {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 0 4px; overflow: hidden;
}
.usuario-avatar {
  width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0;
  background: var(--green); color: #fff;
  font-size: 11px; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  letter-spacing: 0;
}
.usuario-info {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column; gap: 1px;
  transition: opacity 0.18s, max-width 0.22s;
  overflow: hidden;
}
.usuario-nome {
  font-size: 12px; font-weight: 600; color: var(--sidebar-text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.usuario-perfil-badge {
  font-size: 10px; color: var(--green);
  font-weight: 600; white-space: nowrap;
}
.btn-logout {
  background: transparent; border: none; cursor: pointer;
  color: var(--sidebar-text); opacity: .45; font-size: 14px;
  padding: 4px; border-radius: 4px; flex-shrink: 0;
  transition: opacity .2s;
}
.btn-logout:hover { opacity: 1; color: #ef4444; }
.sidebar.collapsed .usuario-info { opacity: 0; max-width: 0; }
.sidebar.collapsed .btn-logout { opacity: 0; pointer-events: none; }

/* ── Modal de usuário ────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(10, 15, 25, 0.75);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
}
.modal-box {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; padding: 36px 40px; width: 100%; max-width: 380px;
  box-shadow: var(--shadow-md); text-align: center;
}
.modal-logo { margin-bottom: 20px; }
.modal-box h2 { font-size: 20px; font-weight: 800; color: var(--text); margin-bottom: 8px; }
.modal-box p  { font-size: 13px; color: var(--text-muted); line-height: 1.5; }

/* ── Configurações usuário ───────────────────────── */
.cfg-usuario-ativo {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border: 1px solid var(--border);
  border-radius: 8px; background: var(--surface2);
  font-size: 14px; font-weight: 600; color: var(--text);
}
.cfg-usuario-ativo span { flex: 1; }

/* ── Utils ───────────────────────────────────────── */
.hidden { display: none !important; }
.muted  { color: var(--text-muted); }
[id^="page-"]:not(.hidden) { animation: fadeIn 0.18s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }

/* ── Print ───────────────────────────────────────── */
@media print {
  .sidebar, header, footer, .resultado-acoes, #card-upload, #card-processando, .btn-primary, .btn-secondary { display: none !important; }
  .main-wrapper { margin-left: 0; }
  body, main { background: #fff !important; color: #000 !important; padding: 0; }
  .card { box-shadow: none; border: 1px solid #ddd; page-break-inside: avoid; }
}

/* ── Suporte (assistente de IA) ──────────────────── */
.suporte-fab {
  position: fixed; bottom: 24px; right: 24px; z-index: 900;
  width: 54px; height: 54px; border-radius: 50%; border: none;
  background: var(--green); color: #fff; font-size: 24px; cursor: pointer;
  box-shadow: 0 4px 14px rgba(26,122,74,0.4);
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.15s, box-shadow 0.15s;
}
.suporte-fab:hover { transform: scale(1.06); box-shadow: 0 6px 18px rgba(26,122,74,0.5); }

.suporte-painel {
  position: fixed; bottom: 90px; right: 24px; z-index: 900;
  width: 360px; max-width: calc(100vw - 32px); height: 480px; max-height: calc(100vh - 130px);
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  box-shadow: var(--shadow-md); display: flex; flex-direction: column; overflow: hidden;
}
.suporte-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; background: var(--green); color: #fff; font-weight: 700; font-size: 14px;
}
.suporte-fechar { background: none; border: none; color: #fff; font-size: 16px; cursor: pointer; opacity: 0.85; }
.suporte-fechar:hover { opacity: 1; }

.suporte-mensagens { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.suporte-msg { max-width: 85%; padding: 9px 12px; border-radius: 12px; font-size: 13px; line-height: 1.45; white-space: pre-wrap; }
.suporte-msg-bot  { align-self: flex-start; background: var(--surface2); color: var(--text); border-bottom-left-radius: 3px; }
.suporte-msg-user { align-self: flex-end;   background: var(--green);   color: #fff;      border-bottom-right-radius: 3px; }
.suporte-msg-carregando { color: var(--text-muted); font-style: italic; }

.suporte-sugestoes { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 14px 10px; }
.suporte-sugestao-chip {
  background: var(--surface2); border: 1px solid var(--border); color: var(--text);
  font-size: 11.5px; font-weight: 600; padding: 6px 10px; border-radius: 99px; cursor: pointer;
}
.suporte-sugestao-chip:hover { background: var(--border); }

.suporte-input-row { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--border); }
.suporte-input-row input {
  flex: 1; padding: 9px 12px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface2); color: var(--text); font-size: 13px;
}
.suporte-input-row .btn-primary { padding: 0 14px; border-radius: 10px; }

@media print {
  .suporte-fab, .suporte-painel { display: none !important; }
}
