/* ============================================
   Cavalcante - Health-tech design system
   ============================================ */



/* ----- Tokens ----- */
:root {
  /* Primária: teal médico */
  --primary:        #0d9488;
  --primary-dark:   #0f766e;
  --primary-light:  #14b8a6;
  --primary-50:     #f0fdfa;
  --primary-100:    #ccfbf1;

  /* Accent: indigo */
  --accent:         #6366f1;
  --accent-50:      #eef2ff;

  /* Semânticos */
  --success:        #10b981;
  --success-50:     #d1fae5;
  --warning:        #f59e0b;
  --warning-50:     #fef3c7;
  --danger:         #ef4444;
  --danger-50:      #fee2e2;
  --info:           #06b6d4;
  --info-50:        #cffafe;

  /* Neutros warm (stone) */
  --gray-50:        #fafaf9;
  --gray-100:       #f5f5f4;
  --gray-200:       #e7e5e4;
  --gray-300:       #d6d3d1;
  --gray-400:       #a8a29e;
  --gray-500:       #78716c;
  --gray-600:       #57534e;
  --gray-700:       #44403c;
  --gray-800:       #292524;
  --gray-900:       #1c1917;

  /* Aliases (compatibilidade com regras antigas) */
  --slate-50:  var(--gray-50);
  --slate-100: var(--gray-100);
  --slate-200: var(--gray-200);
  --slate-300: var(--gray-300);
  --slate-400: var(--gray-400);
  --slate-500: var(--gray-500);
  --slate-600: var(--gray-600);
  --slate-700: var(--gray-700);
  --slate-800: var(--gray-800);
  --slate-900: var(--gray-900);

  /* Texto dos badges (cor escura no light, clara no dark) */
  --success-800: #065f46;
  --danger-800:  #991b1b;
  --warning-800: #92400e;
  --info-800:    #155e75;

  /* Surface: card/input/table background (branco no light, gray-100 no dark) */
  --surface:     #ffffff;
  --surface-alt: var(--gray-50);

  --radius-sm: 6px;
  --radius:    10px;
  --radius-lg: 14px;

  --shadow-sm:  0 1px 2px rgba(28,25,23,.04);
  --shadow:     0 1px 3px rgba(28,25,23,.06), 0 1px 2px rgba(28,25,23,.04);
  --shadow-md:  0 4px 12px rgba(28,25,23,.06);
  --shadow-lg:  0 10px 24px rgba(28,25,23,.08);

  --transition: 200ms cubic-bezier(.4, 0, .2, 1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--gray-50);
  color: var(--gray-800);
  font-size: 14.5px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  transition: background .3s, color .3s;
}

/* ============================================
   Dark mode - SÓ inverte variáveis
   ============================================ */
body.dark {
  --gray-50:   #1c1917;
  --gray-100:  #292524;
  --gray-200:  #44403c;
  --gray-300:  #57534e;
  --gray-400:  #78716c;
  --gray-500:  #a8a29e;
  --gray-600:  #d6d3d1;
  --gray-700:  #e7e5e4;
  --gray-800:  #f5f5f4;
  --gray-900:  #fafaf9;

  --slate-50:  var(--gray-50);
  --slate-100: var(--gray-100);
  --slate-200: var(--gray-200);
  --slate-300: var(--gray-300);
  --slate-400: var(--gray-400);
  --slate-500: var(--gray-500);
  --slate-600: var(--gray-600);
  --slate-700: var(--gray-700);
  --slate-800: var(--gray-800);
  --slate-900: var(--gray-900);

  --primary-50:  rgba(13,148,136,.12);
  --primary-100: rgba(13,148,136,.2);
  --success-50:  rgba(16,185,129,.15);
  --warning-50:  rgba(245,158,11,.15);
  --danger-50:   rgba(239,68,68,.15);
  --info-50:     rgba(6,182,212,.15);
  --accent-50:   rgba(99,102,241,.15);

  /* Texto claro dos badges no dark - inverte */
  --success-800: #6ee7b7;
  --danger-800:  #fca5a5;
  --warning-800: #fcd34d;
  --info-800:    #67e8f9;

  /* Surface invertida no dark */
  --surface:     var(--gray-100);
  --surface-alt: var(--gray-50);
}
body.dark { background: #1c1917; color: #e7e5e4; }
/* Exceções mínimas - áreas que devem ficar MAIS escuras no dark */
body.dark .log-box   { background: #0c0a09; color: #d6d3d1; }
body.dark .status-bar { background: #0c0a09; }
body.dark .sidebar   { background: #0c0a09; }

/* ============================================
   App shell - sidebar + main
   ============================================ */
.app-shell {
  display: flex;
  min-height: 100vh;
}

/* ----- Sidebar ----- */
.sidebar {
  width: 232px;
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--gray-900) 0%, #14302c 100%);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 20px 14px;
  box-shadow: var(--shadow-lg);
  z-index: 100;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 10px 22px;
}
.brand-logo {
  width: 40px; height: 40px;
  border-radius: 11px;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  box-shadow: 0 4px 12px rgba(13,148,136,.4);
  flex-shrink: 0;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-size: 1.05rem; font-weight: 700; letter-spacing: -.02em; }
.brand-text span { font-size: .72rem; opacity: .55; font-weight: 500; }

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}
.sidebar-nav .tab {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: 10px;
  font-weight: 600;
  font-size: .88rem;
  color: rgba(255,255,255,.6);
  cursor: pointer;
  transition: all var(--transition);
  border: none;
  background: transparent;
  text-align: left;
  width: 100%;
  font-family: inherit;
}
.sidebar-nav .tab svg { width: 18px; height: 18px; flex-shrink: 0; }
.sidebar-nav .tab:hover:not(.active) {
  color: #fff;
  background: rgba(255,255,255,.07);
}
.sidebar-nav .tab.active {
  color: #fff;
  background: rgba(20,184,166,.18);
  box-shadow: inset 3px 0 0 var(--primary-light);
}

.sidebar-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 10px 4px;
  border-top: 1px solid rgba(255,255,255,.08);
  margin-top: 8px;
}
.sidebar-total { display: flex; flex-direction: column; line-height: 1.1; }
.sidebar-total strong { font-size: 1.3rem; font-weight: 800; letter-spacing: -.02em; }
.sidebar-total span { font-size: .68rem; opacity: .55; text-transform: uppercase; letter-spacing: .05em; }
.sidebar-theme {
  background: rgba(255,255,255,.1);
  border: none; color: #fff;
  width: 38px; height: 38px;
  border-radius: 10px; cursor: pointer;
  font-size: 1.05rem;
  transition: background var(--transition);
  flex-shrink: 0;
}
.sidebar-theme:hover { background: rgba(255,255,255,.2); }

/* ----- Main area ----- */
.main-area {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.topbar {
  padding: 18px 32px 14px;
  border-bottom: 1px solid var(--gray-200);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 50;
}
body.dark .topbar { background: var(--gray-100); }
.topbar-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--gray-900);
  letter-spacing: -.02em;
}
.topbar-sub {
  font-size: .72rem;
  color: var(--gray-400);
  margin-top: 2px;
  letter-spacing: .02em;
}

/* Tab content */
.tab { /* generico - sobrescrito pela sidebar-nav .tab */ }
.tab-content { display: none; }
.tab-content.active {
  display: block;
  animation: fadeIn .3s ease-out;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeOut {
  from { opacity: 1; }
  to   { opacity: 0; }
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px) scale(.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* Stagger de entrada dos cards ao trocar de aba */
.tab-content.active .auto-card,
.tab-content.active .controls,
.tab-content.active .table-wrap {
  animation: cardIn .35s ease-out both;
}
.tab-content.active .auto-card:nth-child(1) { animation-delay: 0ms; }
.tab-content.active .auto-card:nth-child(2) { animation-delay: 50ms; }
.tab-content.active .auto-card:nth-child(3) { animation-delay: 100ms; }
.tab-content.active .auto-card:nth-child(4) { animation-delay: 150ms; }
.tab-content.active .auto-card:nth-child(5) { animation-delay: 200ms; }
.tab-content.active .auto-card:nth-child(6) { animation-delay: 250ms; }
@keyframes cardIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ============================================
   Controles (filtros)
   ============================================ */
.controls {
  background: transparent;
  padding: 16px 28px 12px;
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.controls input,
.controls select,
.step input[type="text"],
.step select {
  padding: 9px 14px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-size: .87rem;
  font-family: inherit;
  transition: all var(--transition);
  background: var(--surface);
  color: var(--gray-800);
}

.controls input:focus,
.controls select:focus,
.step input:focus,
.step select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-100);
}
.controls input[type="text"] { width: 280px; }
.controls select { width: 170px; cursor: pointer; }

/* Botões dos controles */
.controls button {
  padding: 9px 16px;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: .85rem;
  font-weight: 600;
  transition: all var(--transition);
  font-family: inherit;
}
.btn-search { background: var(--primary); color: #fff; }
.btn-search:hover { background: var(--primary-dark); transform: translateY(-1px); box-shadow: var(--shadow); }
.btn-copy { background: var(--accent); color: #fff; }
.btn-copy:hover { background: #4f46e5; transform: translateY(-1px); box-shadow: var(--shadow); }
.btn-export { background: var(--success); color: #fff; }
.btn-export:hover { background: #059669; transform: translateY(-1px); box-shadow: var(--shadow); }

/* ============================================
   Tabela de dados
   ============================================ */
.table-wrap {
  padding: 0 28px 24px;
  overflow-x: auto;
}
table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--surface);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow);
  border: 1px solid var(--gray-200);
}

thead { background: var(--surface-alt); }

th {
  padding: 12px 16px;
  text-align: left;
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .07em;
  font-weight: 700;
  color: var(--gray-500);
  border-bottom: 1px solid var(--gray-200);
}
td {
  padding: 12px 16px;
  font-size: .87rem;
  border-bottom: 1px solid var(--gray-100);
  color: var(--gray-700);
}

/* Striped rows */
tbody tr:nth-child(even) td { background: var(--gray-50); }

/* Hover com accent bar lateral */
tbody tr { transition: background var(--transition); }
tbody tr:hover td { background: var(--primary-50); }
tbody tr:hover td:first-child { box-shadow: inset 3px 0 0 var(--primary); }
tbody tr:last-child td { border-bottom: none; }

/* Linhas com status flags (suspeito/valor-pendente) */
tr.suspeito td { background: var(--warning-50) !important; }
tr.suspeito:hover td { background: #fde68a !important; }
tr.valor-pendente td { background: var(--warning-50) !important; }

/* Row stagger entrance */
tbody tr { animation: rowIn .25s ease-out both; }
@keyframes rowIn {
  from { opacity: 0; transform: translateX(-6px); }
  to   { opacity: 1; transform: translateX(0); }
}
tbody tr:nth-child(1)  { animation-delay: 0ms; }
tbody tr:nth-child(2)  { animation-delay: 12ms; }
tbody tr:nth-child(3)  { animation-delay: 24ms; }
tbody tr:nth-child(4)  { animation-delay: 36ms; }
tbody tr:nth-child(5)  { animation-delay: 48ms; }
tbody tr:nth-child(6)  { animation-delay: 60ms; }
tbody tr:nth-child(7)  { animation-delay: 72ms; }
tbody tr:nth-child(8)  { animation-delay: 84ms; }
tbody tr:nth-child(9)  { animation-delay: 96ms; }
tbody tr:nth-child(10) { animation-delay: 108ms; }
tbody tr:nth-child(11) { animation-delay: 120ms; }
tbody tr:nth-child(12) { animation-delay: 132ms; }
tbody tr:nth-child(13) { animation-delay: 144ms; }
tbody tr:nth-child(14) { animation-delay: 156ms; }
tbody tr:nth-child(15) { animation-delay: 168ms; }
tbody tr:nth-child(16) { animation-delay: 180ms; }
tbody tr:nth-child(17) { animation-delay: 192ms; }
tbody tr:nth-child(18) { animation-delay: 204ms; }
tbody tr:nth-child(19) { animation-delay: 216ms; }
tbody tr:nth-child(20) { animation-delay: 228ms; }

/* Typography touches em colunas específicas */
.senha {
  font-family: 'IBM Plex Mono', 'Consolas', monospace;
  font-weight: 500;
  color: var(--primary);
  font-size: .82rem;
  letter-spacing: -.01em;
}
.guia {
  font-family: 'IBM Plex Mono', 'Consolas', monospace;
  color: var(--gray-500);
  font-size: .82rem;
}

.copy-btn {
  background: var(--gray-100);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  padding: 3px 10px;
  cursor: pointer;
  font-size: .72rem;
  color: var(--gray-600);
  transition: all var(--transition);
  font-family: inherit;
  font-weight: 500;
  margin-left: 6px;
}
.copy-btn:hover {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.count-badge {
  background: var(--primary);
  color: #fff;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: .78rem;
  font-weight: 700;
  margin-left: 8px;
}

.checkbox-col { width: 30px; text-align: center; }

/* Custom checkbox */
input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border: 1.5px solid var(--gray-300);
  border-radius: 4px;
  cursor: pointer;
  transition: all 150ms;
  position: relative;
  background: var(--surface);
  vertical-align: middle;
}
input[type="checkbox"]:hover { border-color: var(--primary); }
input[type="checkbox"]:checked {
  background: var(--primary);
  border-color: var(--primary);
}
input[type="checkbox"]:checked::after {
  content: '';
  position: absolute;
  left: 4.5px; top: 1px;
  width: 4px; height: 8px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

/* ============================================
   Badges de status
   ============================================ */
.badge {
  display: inline-block;
  font-size: .65rem;
  padding: 3px 8px;
  border-radius: 999px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  white-space: nowrap;
}
.badge-ok,
.badge-digitada    { background: var(--success-50); color: var(--success-800); }
.badge-pendente    { background: var(--gray-100);    color: var(--gray-600); }
.badge-erro        { background: var(--danger-50);   color: var(--danger-800); }
.badge-pulada,
.badge-suspeito    { background: var(--warning-50);  color: var(--warning-800); }
.badge-verificada  { background: var(--info-50);     color: var(--info-800); }

/* ============================================
   Painel automação - cards
   ============================================ */
.auto-panel { padding: 16px 28px 28px; }

.auto-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 22px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--gray-200);
  transition: box-shadow var(--transition), transform var(--transition);
}
.auto-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }

.auto-card h3 {
  margin-bottom: 18px;
  color: var(--gray-900);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -.01em;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* Steps */
.step {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 0;
  border-bottom: 1px solid var(--gray-100);
}
.step:last-child { border-bottom: none; }

.step-num {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--gray-200);
  color: var(--gray-600);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: .85rem;
  flex-shrink: 0;
  transition: all var(--transition);
}
.step-num.done {
  background: var(--success);
  color: #fff;
}
.step-num.active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 0 0 4px var(--primary-100);
  animation: breathe 2s ease-in-out infinite;
}
.step-text { flex: 1; }
.step-text strong {
  font-size: .92rem;
  font-weight: 600;
  color: var(--gray-900);
  display: block;
}
.step-text p {
  font-size: .81rem;
  color: var(--gray-500);
  margin-top: 3px;
  line-height: 1.4;
}

/* Botões genéricos */
.btn {
  padding: 9px 18px;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: .85rem;
  font-weight: 600;
  transition: all var(--transition);
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn:not(:disabled):active {
  transform: scale(.96);
  transition-duration: 80ms;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); transform: translateY(-1px); box-shadow: var(--shadow); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #dc2626; transform: translateY(-1px); box-shadow: var(--shadow); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover:not(:disabled) { background: #059669; transform: translateY(-1px); box-shadow: var(--shadow); }
.btn-warning { background: var(--warning); color: #fff; }
.btn-warning:hover:not(:disabled) { background: #d97706; transform: translateY(-1px); box-shadow: var(--shadow); }
.btn-group { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; }

/* ============================================
   Status bar
   ============================================ */
.status-bar {
  background: var(--gray-900);
  color: #fff;
  padding: 12px 20px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: .9rem;
  box-shadow: var(--shadow);
}
.status-indicator {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
}
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.status-dot.idle           { background: var(--gray-400); }
.status-dot.waiting_login  { background: var(--warning); box-shadow: 0 0 0 3px rgba(245,158,11,.25); animation: breathe-warn 2s ease-in-out infinite; }
.status-dot.ready          { background: var(--success); box-shadow: 0 0 0 3px rgba(16,185,129,.25); }
.status-dot.running        { background: var(--primary-light); animation: breathe 2s ease-in-out infinite; }
.status-dot.paused         { background: var(--warning); }
.status-dot.done           { background: var(--success); box-shadow: 0 0 0 3px rgba(16,185,129,.25); }
.status-dot.error          { background: var(--danger); box-shadow: 0 0 0 3px rgba(239,68,68,.25); }
.status-dot.protocolo_criado { background: var(--info); }

@keyframes breathe {
  0%,100% { opacity: 1; box-shadow: 0 0 0 3px rgba(20,184,166,.25); }
  50%     { opacity: .7; box-shadow: 0 0 0 6px rgba(20,184,166,.08); }
}
@keyframes breathe-warn {
  0%,100% { opacity: 1; box-shadow: 0 0 0 3px rgba(245,158,11,.25); }
  50%     { opacity: .7; box-shadow: 0 0 0 6px rgba(245,158,11,.08); }
}

/* ============================================
   Progress bar com shimmer
   ============================================ */
.progress-wrap { margin-top: 16px; }
.progress-bar {
  height: 8px;
  background: var(--gray-200);
  border-radius: 999px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--primary-light));
  transition: width .4s cubic-bezier(.4,0,.2,1);
  border-radius: 999px;
  position: relative;
  overflow: hidden;
}
.progress-fill::after {
  content: '';
  position: absolute;
  top: 0; left: -100%; width: 100%; height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.35), transparent);
  animation: shimmer 1.5s infinite;
}
@keyframes shimmer { to { left: 100%; } }

.progress-text {
  font-size: .82rem;
  color: var(--gray-500);
  margin-top: 8px;
  font-weight: 500;
}

/* ============================================
   Log box
   ============================================ */
.log-box {
  background: var(--gray-900);
  color: #d6d3d1;
  font-family: 'IBM Plex Mono', 'Consolas', monospace;
  font-size: .78rem;
  padding: 16px;
  border-radius: var(--radius);
  max-height: 320px;
  overflow-y: auto;
  margin-top: 12px;
  line-height: 1.7;
}
.log-box div { padding: 1px 0; }
.log-box div.warn  { color: #fbbf24; }
.log-box div.error { color: #f87171; }
.log-box::-webkit-scrollbar { width: 8px; }
.log-box::-webkit-scrollbar-track { background: rgba(255,255,255,.05); }
.log-box::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); border-radius: 4px; }

/* ============================================
   Toast - bottom-center
   ============================================ */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--gray-900);
  color: #fff;
  padding: 13px 20px 13px 16px;
  border-radius: var(--radius);
  font-size: .87rem;
  font-weight: 500;
  opacity: 0;
  transition: all .3s cubic-bezier(.4,0,.2,1);
  z-index: 999;
  box-shadow: 0 8px 28px rgba(28,25,23,.22);
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 240px;
  max-width: 440px;
  border-left: 4px solid var(--gray-500);
  overflow: hidden;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast-icon {
  width: 22px; height: 22px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: .8rem; font-weight: 700;
  flex-shrink: 0;
  color: #fff;
}
.toast-msg { flex: 1; line-height: 1.35; }
/* Barra de progresso de tempo */
.toast::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0;
  height: 3px;
  width: 100%;
  background: currentColor;
  opacity: .4;
  transform-origin: left;
  animation: toastBar 2.6s linear forwards;
}
@keyframes toastBar { from { transform: scaleX(1); } to { transform: scaleX(0); } }

/* Tipos */
.toast.success { border-left-color: var(--success); }
.toast.success .toast-icon { background: var(--success); }
.toast.error   { border-left-color: var(--danger); }
.toast.error   .toast-icon { background: var(--danger); }
.toast.warning { border-left-color: var(--warning); }
.toast.warning .toast-icon { background: var(--warning); }
.toast.info    { border-left-color: var(--info); }
.toast.info    .toast-icon { background: var(--info); }

/* ============================================
   Footer
   ============================================ */
.footer {
  text-align: center;
  padding: 20px;
  color: var(--gray-400);
  font-size: .75rem;
  border-top: 1px solid var(--gray-100);
  background: transparent;
  letter-spacing: .02em;
}

/* ============================================
   Stats grid - cards do dashboard
   ============================================ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
  margin-top: 4px;
}
.stat-card {
  background: var(--surface);
  border-radius: 12px;
  padding: 18px;
  border: 1px solid var(--gray-200);
  position: relative;
  transition: all var(--transition);
}
.stat-card:hover {
  border-color: var(--gray-300);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.stat-card .stat-icon {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--gray-100);
  color: var(--gray-500);
  font-size: 14px;
}
.stat-card.ok   .stat-icon { background: var(--success-50); color: var(--success-800); }
.stat-card.warn .stat-icon { background: var(--warning-50); color: var(--warning-800); }
.stat-card.err  .stat-icon { background: var(--danger-50);  color: var(--danger-800); }

.stat-num {
  font-size: 1.85rem;
  font-weight: 700;
  color: var(--gray-900);
  letter-spacing: -.02em;
  line-height: 1;
}
.stat-label {
  font-size: .7rem;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: .06em;
  font-weight: 600;
  margin-top: 8px;
}

/* ============================================
   Dashboard - tabelas internas
   ============================================ */
#protocolosBox table,
#errosBox table,
#puladasBox table {
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--gray-200);
}

/* ============================================
   Loading skeletons
   ============================================ */
.skeleton {
  background: linear-gradient(90deg, var(--gray-100) 25%, var(--gray-200) 50%, var(--gray-100) 75%);
  background-size: 200% 100%;
  animation: skeleton-pulse 1.6s ease-in-out infinite;
  border-radius: 6px;
  display: inline-block;
}
@keyframes skeleton-pulse {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.skeleton-line { height: 14px; width: 100%; margin: 6px 0; }
.skeleton-line.short  { width: 40%; }
.skeleton-line.medium { width: 70%; }
.skeleton-line.long   { width: 90%; }

.skeleton-block {
  padding: 12px;
}
.skeleton-block::before {
  content: '';
  display: block;
  height: 14px;
  width: 60%;
  background: linear-gradient(90deg, var(--gray-100) 25%, var(--gray-200) 50%, var(--gray-100) 75%);
  background-size: 200% 100%;
  animation: skeleton-pulse 1.6s ease-in-out infinite;
  border-radius: 4px;
  margin-bottom: 10px;
}
.skeleton-block::after {
  content: '';
  display: block;
  height: 14px;
  width: 90%;
  background: linear-gradient(90deg, var(--gray-100) 25%, var(--gray-200) 50%, var(--gray-100) 75%);
  background-size: 200% 100%;
  animation: skeleton-pulse 1.6s ease-in-out infinite;
  border-radius: 4px;
}

.skeleton-stat {
  background: var(--surface);
  border-radius: 12px;
  padding: 18px;
  border: 1px solid var(--gray-200);
}
.skeleton-stat .skeleton-line:first-child { width: 50%; height: 28px; margin-bottom: 8px; }
.skeleton-stat .skeleton-line:last-child  { width: 70%; height: 10px; }

/* ============================================
   Empty states
   ============================================ */
.empty-state {
  text-align: center;
  padding: 44px 24px;
  color: var(--gray-500);
}
.empty-state svg {
  width: 72px;
  height: 72px;
  opacity: .3;
  margin-bottom: 12px;
}
.empty-state h4 {
  font-size: .98rem;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 4px;
}
.empty-state p {
  font-size: .85rem;
  color: var(--gray-400);
  max-width: 380px;
  margin: 0 auto;
}

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 860px) {
  /* Sidebar vira barra horizontal no topo */
  .app-shell { flex-direction: column; }
  .sidebar {
    width: 100%; height: auto;
    flex-direction: row; align-items: center;
    padding: 10px 14px;
    position: sticky; top: 0;
    overflow-x: auto;
  }
  .sidebar-brand { padding: 0 12px 0 4px; }
  .sidebar-nav { flex-direction: row; flex: 1; gap: 2px; }
  .sidebar-nav .tab { padding: 9px 12px; white-space: nowrap; }
  .sidebar-nav .tab span { display: none; } /* só ícones no mobile */
  .sidebar-nav .tab.active { box-shadow: inset 0 -3px 0 var(--primary-light); }
  .sidebar-footer { border-top: none; margin-top: 0; padding: 0 0 0 8px; border-left: 1px solid rgba(255,255,255,.08); }
  .sidebar-total { display: none; }
  .topbar { padding: 14px 16px; }
  .controls { padding: 14px 16px; }
  .controls input[type="text"] { width: 100%; }
  .table-wrap, .auto-panel { padding: 0 16px 16px; }
  .auto-card { padding: 18px; }
  .step { flex-direction: column; align-items: flex-start; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .btn-group { flex-direction: column; }
  .btn-group .btn { width: 100%; justify-content: center; }
  .controls { flex-direction: column; align-items: stretch; }
  .controls input[type="text"], .controls select { width: 100%; }
  .brand-text { display: none; }
}

/* Scrollbar global */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--gray-100); }
::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: var(--gray-400); }

/* Interface de faturamento */
:root { --primary:#0754e8; --primary-dark:#003cb7; --primary-light:#286aff; --primary-50:#edf3ff; --primary-100:#dbe8ff; --gray-50:#f3f6fa; --gray-100:#eef2f7; --gray-200:#dce4ee; --gray-300:#c6d1df; --gray-400:#75859b; --gray-500:#62738d; --gray-600:#4c5d76; --gray-700:#34445c; --gray-800:#172741; --gray-900:#0b1930; }
body { font-family:Inter, 'Segoe UI', sans-serif; }
.sidebar { background:#091b35; box-shadow:none; }
.brand-logo { background:#0754e8; box-shadow:none; border-radius:6px; }
.sidebar-nav .tab { border-radius:7px; color:#d4ddec; }
.sidebar-nav .tab.active { background:#0754e8; box-shadow:none; }
.topbar { background:transparent; position:static; border:0; padding:22px 32px 0; }
.topbar-title { font-size:.8rem; font-weight:600; color:var(--gray-600); }
.topbar-sub { font-size:.78rem; color:var(--gray-500); }
.section-heading { display:flex; align-items:center; justify-content:space-between; gap:16px; margin:0 0 20px; }
.section-heading h1 { font-size:2rem; line-height:1.2; color:var(--gray-900); letter-spacing:-.03em; }
.section-heading p { margin-top:4px; color:var(--gray-500); }
.controls, .table-wrap, .auto-card { border:1px solid var(--gray-200); box-shadow:0 1px 2px rgba(11,25,48,.03); border-radius:8px; }
.action-menu { margin:12px 0; background:var(--surface); border:1px solid var(--gray-200); border-radius:8px; }
.action-menu summary,.log-disclosure summary { cursor:pointer; font-weight:700; padding:13px 16px; color:var(--gray-800); }
.action-menu-body { display:flex; flex-wrap:wrap; align-items:center; gap:8px; padding:0 16px 16px; }
.action-menu-body button { background:var(--surface); color:var(--gray-800); border:1px solid var(--gray-300); }
.action-menu-body #btnResetarLoteAtual { color:var(--danger-800); border-color:#f2c2c2; }
.log-disclosure .log-box { margin-top:12px; }
.table-wrap { max-height:70vh; overflow:auto; }
.table-wrap thead th { position:sticky; top:0; z-index:2; background:var(--gray-100); }
:focus-visible { outline:3px solid #5b94ff; outline-offset:2px; }
@media (max-width:700px) { .section-heading { align-items:flex-start; flex-wrap:wrap; } .section-heading h1 { font-size:1.6rem; } .topbar { padding:16px 16px 0; } .action-menu-body > * { max-width:100%; } }
@media (prefers-reduced-motion:reduce) { *, *::before, *::after { animation-duration:.01ms !important; transition-duration:.01ms !important; scroll-behavior:auto !important; } }
.nav-shortcut { display:flex; align-items:center; gap:12px; padding:11px 14px; border:0; border-radius:7px; color:#d4ddec; background:transparent; font:600 .88rem inherit; text-align:left; cursor:pointer; }
.nav-shortcut:hover { background:rgba(255,255,255,.08); color:#fff; }
.workflow { display:flex; gap:12px; margin:20px 0; flex-wrap:wrap; }
.workflow > div { display:flex; align-items:center; gap:9px; color:var(--gray-700); font-weight:600; flex:1 1 150px; }
.workflow b { display:grid; place-items:center; height:30px; width:30px; border-radius:50%; color:var(--primary); background:var(--primary-50); }
.batch-panel, .table-card { background:var(--surface); border:1px solid var(--gray-200); border-radius:8px; padding:20px; margin:16px 0; }
.batch-panel { display:flex; align-items:center; justify-content:space-between; flex-wrap:wrap; gap:16px; }
.batch-panel h2,.table-heading h2 { font-size:1.15rem; color:var(--gray-900); }
.batch-panel p { color:var(--gray-600); margin-top:5px; }
.table-heading { display:flex; justify-content:space-between; gap:12px; margin-bottom:14px; align-items:center; }
.table-heading span { font-size:.8rem; color:var(--gray-600); }
.table-card .table-wrap { margin:0; }
#tab-dados th:nth-child(2),#tab-dados td:nth-child(2),#tab-dados th:nth-child(5),#tab-dados td:nth-child(5),#tab-dados th:nth-child(7),#tab-dados td:nth-child(7),#tab-dados th:nth-child(9),#tab-dados td:nth-child(9),#tab-dados th:nth-child(10),#tab-dados td:nth-child(10),#tab-dados th:nth-child(11),#tab-dados td:nth-child(11),#tab-dados th:nth-child(13),#tab-dados td:nth-child(13) { display:none; }
#guiaDetalhes { border:1px solid var(--gray-200); border-radius:10px; padding:22px; width:min(560px,calc(100vw - 32px)); max-height:85vh; margin:auto; color:var(--gray-900); background:var(--surface); box-shadow:0 20px 55px rgba(0,0,0,.2); }
#guiaDetalhes::backdrop { background:rgba(9,27,53,.55); }
.detail-header { display:flex; align-items:center; justify-content:space-between; gap:12px; }
.detail-header button { font-size:1.6rem; border:0; background:transparent; color:var(--gray-700); cursor:pointer; }
.detail-list > div { padding:10px 0; border-bottom:1px solid var(--gray-200); }
.detail-list dt { color:var(--gray-500); font-size:.75rem; font-weight:600; }
.detail-list dd { margin:2px 0 0; overflow-wrap:anywhere; white-space:pre-wrap; }
@media(max-width:768px) { .nav-shortcut { white-space:nowrap; padding:9px; font-size:.75rem; } .sidebar-nav { overflow-x:auto; } .sidebar-nav .tab span { display:inline; } .sidebar-nav .tab svg { display:none; } .workflow > div { flex:1 1 42%; } .batch-panel,.table-card { padding:14px; } .table-wrap table { min-width:720px; } }

#tab-dados { padding: 16px 32px 32px; }
.workflow > div.atual b { color:#fff; background:var(--primary); }
.workflow > div.atual span { color:var(--primary-dark); }
.nav-shortcut { font-family:inherit; font-size:.88rem; font-weight:600; }
@media(max-width:768px){ #tab-dados { padding:16px; } }
.action-menu-body { display:grid; grid-template-columns:repeat(auto-fit,minmax(230px,1fr)); align-items:start; }
.action-group h3 { font-size:.8rem; color:var(--gray-600); margin:0 0 10px; }
.action-group > div { display:flex; flex-wrap:wrap; gap:8px; }
.danger-zone { border-left:1px solid var(--gray-200); padding-left:16px; }
@media(max-width:700px){ .danger-zone { border-left:0; border-top:1px solid var(--gray-200); padding:12px 0 0; } }
.sidebar-theme { width:auto; min-width:48px; padding:0 8px; font-size:.75rem; }

/* ============================================
   Agendamento + acesso ao portal (login automático)
   ============================================ */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.step-agenda .step-num { background: var(--primary-50); color: var(--primary); }
.agenda-acoes { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.agenda-acoes input[type="datetime-local"],
.cred-form input {
  padding: 9px 12px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: .87rem;
  background: var(--surface, #fff);
  color: var(--gray-900);
  min-height: 40px;
}
.agenda-acoes input[type="datetime-local"]:focus-visible,
.cred-form input:focus-visible,
.btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
.btn-ghost-danger {
  background: transparent;
  color: var(--danger-800);
  border: 1px solid currentColor;
}
.btn-ghost-danger:hover:not(:disabled) { background: var(--danger-50); }
.agenda-info {
  margin-top: 8px !important;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: var(--primary-50);
  color: var(--gray-900) !important;
  font-weight: 600;
}
.cred-status { font-size: .86rem; color: var(--gray-700); margin-bottom: 14px; }
.cred-status.ok { color: var(--gray-900); }
.cred-status.ok::before { content: "● "; color: var(--success); }
.cred-status.vazio::before { content: "● "; color: var(--gray-400); }
.cred-form { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; max-width: 640px; }
.cred-form label { display: block; font-size: .82rem; font-weight: 600; color: var(--gray-700); margin-bottom: 6px; }
.cred-form input { width: 100%; }
.cred-botoes { grid-column: 1 / -1; display: flex; gap: 10px; flex-wrap: wrap; }
.cred-ajuda { font-size: .76rem; color: var(--gray-500); margin-top: 14px; max-width: 640px; line-height: 1.5; }
@media (max-width: 640px) {
  .cred-form { grid-template-columns: 1fr; }
  .agenda-acoes { justify-content: flex-start; width: 100%; }
  .agenda-acoes input[type="datetime-local"] { flex: 1 1 100%; }
}
/* O atributo hidden precisa vencer o display:inline-flex dos botões */
.agenda-acoes [hidden], .cred-botoes [hidden], .agenda-info[hidden] { display: none !important; }

/* ============================================
   Login: usuario no menu e gestao de usuarios
   ============================================ */
.sidebar-user { display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 0 12px; margin-bottom: 10px; border-bottom: 1px solid rgba(255,255,255,.12); }
.sidebar-user[hidden] { display: none !important; }
.sidebar-user-nome { font-size: .82rem; color: #fff; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-sair { background: transparent; color: #fff; border: 1px solid rgba(255,255,255,.35); border-radius: 6px;
  padding: 5px 10px; font: inherit; font-size: .78rem; cursor: pointer; min-height: 32px; }
.sidebar-sair:hover { background: rgba(255,255,255,.1); }
.sidebar-sair:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.usuarios-lista { display: flex; flex-direction: column; gap: 8px; margin-bottom: 18px; max-width: 640px; }
.usuario-linha { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 10px 12px; border: 1px solid var(--gray-200); border-radius: 8px; }
.usuario-linha.inativo { opacity: .65; }
.usuario-login { color: var(--gray-600); font-size: .82rem; }
.usuario-meta { font-size: .74rem; color: var(--gray-500); margin-top: 2px; }
.usuario-acoes { display: flex; gap: 6px; flex-wrap: wrap; }
.usuario-acoes .btn { border: 1px solid var(--gray-300); background: transparent; color: var(--gray-800); }
.badge-admin, .badge-inativo { font-size: .68rem; font-weight: 700; padding: 2px 7px; border-radius: 99px; margin-left: 6px; }
.badge-admin { background: var(--primary-50); color: var(--primary-dark, var(--primary)); }
.badge-inativo { background: var(--danger-50); color: var(--danger-800); }
.usuarios-admin { grid-column: 1 / -1; }
.check-inline { display: inline-flex !important; align-items: center; gap: 8px; font-weight: 500 !important; }
#cardUsuarios[hidden], #cardMinhaSenha[hidden], #usuariosAjuda[hidden] { display: none !important; }
/* correcoes: checkbox no formulario e usuario no rodape do menu */
.cred-form input[type="checkbox"] { width: 18px; height: 18px; min-height: 0; padding: 0; accent-color: var(--primary); flex-shrink: 0; }
.sidebar-footer { flex-wrap: wrap; }
.sidebar-user { flex: 0 0 100%; width: 100%; }
@media (max-width: 860px) {
  .sidebar-footer { flex-wrap: nowrap; }
  .sidebar-user { flex: 0 0 auto; width: auto; border: 0; padding: 0; margin: 0; }
  .sidebar-user-nome { display: none; }
}

/* ============================================
   Modo VPS: fluxo automatico + conferencia + foto
   ============================================ */
.so-vps { display: none; }
body.modo-vps .so-vps { display: block; }
body.modo-vps .so-local { display: none !important; }
.vps-protocolo { display: flex; flex-direction: column; gap: 8px; min-width: 320px; }
.vps-protocolo input, .vps-protocolo select { padding: 9px 12px; min-height: 40px; border: 1px solid var(--gray-300);
  border-radius: var(--radius-sm); font: inherit; font-size: .87rem; background: var(--surface, #fff); color: var(--gray-900); }
.vps-protocolo input:focus-visible, .vps-protocolo select:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.vps-linha { display: flex; gap: 8px; }
.vps-linha select { flex: 1; }
.conferencia { margin: 6px 0 14px; padding: 16px; border: 2px solid var(--primary); border-radius: 12px; background: var(--primary-50); }
.conferencia[hidden], .tela-robo img[hidden] { display: none !important; }
.conferencia h4 { font-size: .95rem; color: var(--gray-900); margin-bottom: 10px; }
.conferencia-tabela { width: 100%; border-collapse: collapse; font-size: .86rem; background: var(--surface, #fff); border-radius: 8px; overflow: hidden; }
.conferencia-tabela th, .conferencia-tabela td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--gray-200); color: var(--gray-900); }
.conferencia-tabela thead th { font-size: .74rem; text-transform: uppercase; letter-spacing: .04em; color: var(--gray-600); }
.conferencia-tabela tr.ok td:last-child { color: var(--success, #059669); font-weight: 700; }
.conferencia-tabela tr.erro { background: var(--danger-50); }
.conferencia-tabela tr.erro td:last-child { color: var(--danger-800); font-weight: 700; }
.conferencia-alerta { margin-top: 10px; padding: 9px 12px; border-radius: 8px; background: var(--danger-50); color: var(--danger-800); font-size: .85rem; font-weight: 600; }
.conferencia-alerta[hidden] { display: none !important; }
.conferencia-botoes { display: flex; align-items: center; gap: 12px; margin-top: 12px; flex-wrap: wrap; }
.conferencia-dica { font-size: .8rem; color: var(--gray-600); }
.tela-robo { margin: 8px 0 14px; padding: 12px; border: 1px solid var(--gray-200); border-radius: 12px; }
.tela-robo-topo { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.tela-robo-topo span { font-size: .8rem; color: var(--gray-600); }
.tela-robo-topo .btn { margin-left: auto; border: 1px solid var(--gray-300); background: transparent; color: var(--gray-800); }
.tela-robo img { width: 100%; max-width: 900px; border: 1px solid var(--gray-200); border-radius: 8px; display: block; }
@media (max-width: 640px) {
  .vps-protocolo { min-width: 0; width: 100%; }
  .conferencia-tabela th, .conferencia-tabela td { padding: 7px 8px; font-size: .8rem; }
}

.conferencia-tabela tbody tr { animation: none; }
.conferencia-tabela tbody tr:hover td { background: inherit; box-shadow: none; }
.conferencia-rolagem { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.conferencia-tabela { min-width: 460px; }

/* Relatorio do lote sempre disponivel no cartao "Lote atual" */
.batch-acoes { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.batch-relatorio { display: inline-flex; gap: 8px; flex-wrap: wrap; }
.batch-relatorio[hidden] { display: none !important; }
.batch-relatorio a.btn { text-decoration: none; border: 1px solid var(--gray-300); background: transparent; color: var(--gray-800); }
.batch-relatorio a.btn:hover { background: var(--gray-50); }
.batch-relatorio a.btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ============================================
   Aba Relatorios
   ============================================ */
.rel-sub { font-size: .72rem; font-weight: 500; color: var(--gray-500); margin-left: 6px; }
.rel-resumo { font-size: .95rem; color: var(--gray-900); margin: 4px 0 16px; font-weight: 600; }
.rel-acoes { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.rel-acoes a.btn { text-decoration: none; border: 1px solid var(--gray-300); background: transparent; color: var(--gray-800); }
.rel-ajuda { font-size: .8rem; color: var(--gray-600); margin-top: 14px; max-width: 720px; line-height: 1.5; }
.rel-lista { display: flex; flex-direction: column; gap: 8px; max-width: 760px; }
.rel-linha { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--gray-200); border-radius: 8px; }
.rel-linha .btn { margin-left: auto; text-decoration: none; flex-shrink: 0; }
.rel-info { display: flex; flex-direction: column; min-width: 0; }
.rel-info strong { font-size: .9rem; color: var(--gray-900); }
.rel-info span { font-size: .76rem; color: var(--gray-600); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rel-tipo { font-size: .7rem; font-weight: 800; letter-spacing: .04em; padding: 4px 8px; border-radius: 6px; flex-shrink: 0; min-width: 48px; text-align: center; }
.rel-pdf { background: var(--danger-50); color: var(--danger-800); }
.rel-xlsx { background: var(--primary-50); color: var(--primary-dark, var(--primary)); }
.rel-vazio { font-size: .86rem; color: var(--gray-600); }
@media (max-width: 640px) {
  .rel-linha { flex-wrap: wrap; }
  .rel-linha .btn { width: 100%; justify-content: center; margin-left: 0; }
}
