:root, [data-theme="dark"] {
  --bg-main: #0a0e17;
  --bg-card: #111827;
  --bg-card-hover: #172134;
  --bg-input: #1a2233;
  --bg-toolbar: #0f172a;
  --bg-th: #141c2c;
  --bg-td-border: #1e293b;
  --bg-modal: #111827;
  --bg-modal-footer: #0c121e;
  --border-color: #1f293d;
  --border-focus: #10b981;
  
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-sub: #64748b;

  --accent-primary: #10b981;
  --accent-primary-hover: #059669;
  --accent-blue: #3b82f6;
  --accent-amber: #f59e0b;
  --accent-danger: #ef4444;
  --accent-purple: #8b5cf6;
  --accent-teal: #14b8a6;
  --accent-indigo: #6366f1;

  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.25);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.35), 0 2px 4px -1px rgba(0, 0, 0, 0.2);
  --shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.4);
  --shadow-glow: 0 0 20px rgba(16, 185, 129, 0.25);
  --row-selected-bg: rgba(16, 185, 129, 0.08);
  --row-hover-bg: rgba(255, 255, 255, 0.03);
  --mono-cell-color: #cbd5e1;
}

[data-theme="light"] {
  --bg-main: #f8fafc;
  --bg-card: #ffffff;
  --bg-card-hover: #f1f5f9;
  --bg-input: #ffffff;
  --bg-toolbar: #f8fafc;
  --bg-th: #f1f5f9;
  --bg-td-border: #e2e8f0;
  --bg-modal: #ffffff;
  --bg-modal-footer: #f8fafc;
  --border-color: #cbd5e1;
  --border-focus: #059669;
  
  --text-main: #0f172a;
  --text-muted: #475569;
  --text-sub: #64748b;

  --accent-primary: #059669;
  --accent-primary-hover: #047857;
  --accent-blue: #2563eb;
  --accent-amber: #d97706;
  --accent-danger: #dc2626;
  --accent-purple: #7c3aed;
  --accent-teal: #0d9488;
  --accent-indigo: #4f46e5;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -1px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.05);
  --shadow-glow: 0 0 20px rgba(5, 150, 105, 0.15);
  --row-selected-bg: #ecfdf5;
  --row-hover-bg: #f8fafc;
  --mono-cell-color: #334155;
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-main);
  color: var(--text-main);
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden;
  transition: background-color 0.25s ease, color 0.25s ease;
}

/* ========================================================================= */
/* APP LAYOUT COM SIDEBAR LATERAL NAVEGÁVEL & RETRÁTIL                     */
/* ========================================================================= */
.app-layout {
  display: none;
  min-height: 100vh;
  width: 100%;
}

.app-layout.auth-authenticated {
  display: flex !important;
  animation: fadeInLayout 0.25s ease-out forwards;
}

@keyframes fadeInLayout {
  from {
    opacity: 0;
    transform: scale(0.998);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* SIDEBAR */
.app-sidebar {
  width: 250px;
  min-width: 250px;
  max-width: 250px;
  background: var(--bg-card);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  max-height: 100vh;
  max-height: 100dvh;
  z-index: 100;
  overflow: visible;
  transition: width 0.22s cubic-bezier(0.4, 0, 0.2, 1), min-width 0.22s cubic-bezier(0.4, 0, 0.2, 1), max-width 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}

.app-sidebar.collapsed {
  width: 68px !important;
  min-width: 68px !important;
  max-width: 68px !important;
  overflow: visible !important;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-color);
  height: 64px;
  min-height: 64px;
  flex-shrink: 0;
  position: relative;
  background: var(--bg-card);
  z-index: 10;
  overflow: visible;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  overflow: hidden;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}

.brand-logo-wrapper {
  display: flex;
  align-items: center;
  height: 40px;
}

.logo-laborclinico-light {
  display: none;
  max-height: 38px;
  width: auto;
  object-fit: contain;
}

.logo-laborclinico-dark {
  display: block;
  max-height: 38px;
  width: auto;
  object-fit: contain;
}

.sidebar-brand-collapsed-symbol {
  display: none;
  max-height: 32px;
  width: auto;
}

/* Suporte aos Modos Light e Dark */
[data-theme="light"] .logo-laborclinico-light {
  display: block !important;
}

[data-theme="light"] .logo-laborclinico-dark {
  display: none !important;
}

/* Sidebar Recolhida: Logo perfeitamente centralizado */
.app-sidebar.collapsed .sidebar-brand .logo-laborclinico-light,
.app-sidebar.collapsed .sidebar-brand .logo-laborclinico-dark {
  display: none !important;
}

.app-sidebar.collapsed .sidebar-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
}

.app-sidebar.collapsed .sidebar-brand .brand-logo-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  margin: 0;
}

.app-sidebar.collapsed .sidebar-brand .sidebar-brand-collapsed-symbol {
  display: block !important;
  max-height: 32px;
  max-width: 32px;
  width: auto;
  margin: 0 auto;
  object-fit: contain;
}

.app-sidebar.collapsed .sidebar-header {
  height: 64px;
  min-height: 64px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: visible;
}

/* Alça de recolher / abrir na borda lateral (discreta, bonita e sutil) */
.btn-sidebar-toggle {
  position: absolute;
  right: -12px;
  top: 50%;
  transform: translateY(-50%);
  width: 24px;
  height: 24px;
  min-width: 24px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.22);
  z-index: 120;
  padding: 0;
  margin: 0;
}

.btn-sidebar-toggle:hover {
  background: var(--bg-card-hover);
  color: var(--accent-primary);
  border-color: var(--accent-primary);
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.35);
  transform: translateY(-50%) scale(1.12);
}

.btn-sidebar-toggle .icon-toggle {
  width: 13px;
  height: 13px;
  stroke-width: 2.5;
  transition: transform 0.22s ease;
  margin-right: 1px;
}

/* Quando recolhida: alça permanece perfeitamente grudada na borda direita */
.app-sidebar.collapsed .btn-sidebar-toggle {
  position: absolute;
  right: -12px;
  top: 50%;
  transform: translateY(-50%);
  width: 24px;
  height: 24px;
  min-width: 24px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  margin: 0;
}

.app-sidebar.collapsed .btn-sidebar-toggle:hover {
  transform: translateY(-50%) scale(1.12);
}

.app-sidebar.collapsed .btn-sidebar-toggle .icon-toggle {
  transform: rotate(180deg);
  margin-right: 0;
  margin-left: 1px;
}

/* SIDEBAR NAV COM ROLAGEM FLUIDA E NATURAL */
.sidebar-nav {
  flex: 1 1 auto;
  min-height: 0; /* CRUCIAL: permite que o flex child diminua e acione o scroll */
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  overflow-y: auto;
  overflow-x: hidden !important;
  scroll-behavior: smooth;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--border-color) transparent;
}

/* Scrollbar Moderno, Sutil e Responsivo */
.sidebar-nav::-webkit-scrollbar {
  width: 4px;
}

.sidebar-nav::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar-nav::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 8px;
  transition: background 0.2s ease;
}

.sidebar-nav:hover::-webkit-scrollbar-thumb {
  background: var(--text-muted);
}

.sidebar-nav::-webkit-scrollbar-thumb:hover {
  background: var(--accent-primary);
}

/* Títulos de Seção: Espaçamento Generoso sem Compressão */
.nav-section-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-sub);
  padding: 10px 10px 4px 10px;
  margin-top: 5px;
  line-height: 1.4;
  white-space: nowrap;
  flex-shrink: 0; /* NUNCA esmaga o texto */
  user-select: none;
}

.nav-section-label:first-child {
  margin-top: 0;
  padding-top: 4px;
}

/* Garantia de ocultação mesmo com inline style do JS (admin-only) */
.app-sidebar.collapsed .nav-section-label {
  display: none !important;
  visibility: hidden !important;
  height: 0 !important;
  padding: 0 !important;
  margin: 0 !important;
  overflow: hidden !important;
  border: none !important;
}

/* Itens de Navegação com Altura Firme e Proporções Elegantes */
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  height: 38px;
  min-height: 38px;
  max-height: 38px;
  flex-shrink: 0; /* NUNCA esmaga os botões */
  padding: 0 11px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  white-space: nowrap;
  transition: background 0.16s ease, color 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
  position: relative;
  overflow: hidden;
}

.nav-item:hover {
  background: var(--bg-card-hover);
  color: var(--text-main);
}

.nav-item.active {
  background: var(--accent-primary);
  color: #ffffff;
  box-shadow: 0 3px 10px rgba(16, 185, 129, 0.22);
}

.nav-item.active svg {
  stroke: #ffffff;
}

.app-sidebar.collapsed .nav-item {
  justify-content: center;
  padding: 0;
  width: 100%;
  height: 40px;
  min-height: 40px;
  max-height: 40px;
}

.app-sidebar.collapsed .nav-label,
.app-sidebar.collapsed .nav-badge,
.app-sidebar.collapsed .badge-tag-clean,
.app-sidebar.collapsed .nav-item span {
  display: none !important;
  visibility: hidden !important;
  width: 0 !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

.nav-icon {
  min-width: 18px;
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.nav-badge {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 7px;
  border-radius: 20px;
  font-size: 10.5px;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.15);
  color: currentColor;
  flex-shrink: 0;
}

.nav-item:not(.active) .nav-badge {
  background: var(--bg-input);
  color: var(--text-muted);
  border: 1px solid var(--border-color);
}

.nav-badge-accent {
  background: #ec4899 !important;
  color: #ffffff !important;
}

/* SIDEBAR FOOTER (RODAPÉ ANCORADO E PRESERVADO) */
.sidebar-footer {
  padding: 8px 8px;
  border-top: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-shrink: 0; /* NUNCA comprime os controles inferiores */
  background: var(--bg-card);
  z-index: 10;
  overflow: hidden;
}

.sidebar-btn-action {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  background: var(--bg-input);
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.18s ease;
  overflow: hidden;
}

.sidebar-btn-action:hover {
  background: var(--bg-card-hover);
  color: var(--text-main);
  border-color: var(--border-focus);
}

.app-sidebar.collapsed .sidebar-btn-action {
  justify-content: center;
  padding: 8px 0;
  width: 100%;
}

.app-sidebar.collapsed .sidebar-btn-action .nav-label {
  display: none !important;
}

.sidebar-db-status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: var(--bg-main);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
}

.app-sidebar.collapsed .sidebar-db-status {
  justify-content: center;
  padding: 6px 0;
  width: 100%;
}

.app-sidebar.collapsed .sidebar-db-status .nav-label {
  display: none !important;
}

.status-dot {
  width: 8px;
  height: 8px;
  min-width: 8px;
  border-radius: 50%;
  background: #94a3b8;
}

.status-connected .status-dot {
  background: #10b981;
  box-shadow: 0 0 8px #10b981;
}

.status-error .status-dot {
  background: #ef4444;
  box-shadow: 0 0 8px #ef4444;
}

/* ========================================================================= */
/* MAIN CONTENT AREA                                                         */
/* ========================================================================= */
.app-main-content {
  flex: 1;
  min-width: 0;
  padding: 16px 22px;
  overflow-y: auto;
}

/* TOPBAR */
.main-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-color);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.btn-icon-mobile {
  display: none;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 7px;
  border-radius: 8px;
  cursor: pointer;
}

.topbar-title {
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: -0.4px;
  line-height: 1.2;
}

.topbar-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 1px;
}

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

/* BUTTONS */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 13px;
  border-radius: 7px;
  font-family: var(--font-sans);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.btn:active {
  transform: scale(0.98);
}

.btn-sm {
  padding: 5px 10px;
  font-size: 11.5px;
  border-radius: 6px;
}

.btn-xs {
  padding: 3px 8px;
  font-size: 11px;
  border-radius: 5px;
}

.btn-primary {
  background: var(--accent-primary);
  color: #ffffff;
}

.btn-primary:hover {
  background: var(--accent-primary-hover);
}

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

.btn-secondary:hover {
  background: var(--bg-card-hover);
}

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

.btn-outline:hover {
  border-color: var(--accent-primary);
  color: var(--accent-primary);
}

.btn-success {
  background: #059669;
  color: #ffffff;
}

.btn-success:hover {
  background: #047857;
}

.btn-danger {
  background: var(--accent-danger);
  color: #ffffff;
}

.btn-danger:hover {
  background: #dc2626;
}

/* ========================================================================= */
/* METRICS OVERVIEW CARDS                                                   */
/* ========================================================================= */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.metrics-grid-dashboard {
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
}

.metric-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: var(--shadow-sm);
  transition: transform 0.18s, border-color 0.18s, background-color 0.18s;
  position: relative;
  overflow: hidden;
}

.metric-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-focus);
}

.card-gradient-blue { border-left: 4px solid var(--accent-blue); }
.card-gradient-emerald { border-left: 4px solid var(--accent-primary); }
.card-gradient-amber { border-left: 4px solid var(--accent-amber); }
.card-gradient-purple { border-left: 4px solid var(--accent-purple); }
.card-gradient-indigo { border-left: 4px solid var(--accent-indigo); }
.card-gradient-teal { border-left: 4px solid var(--accent-teal); }

.metric-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.metric-value {
  font-size: 1.25rem;
  font-weight: 700;
  margin: 2px 0;
  letter-spacing: -0.4px;
  line-height: 1.25;
}

.metric-sub {
  font-size: 11px;
  color: var(--text-sub);
}

.metric-icon-box {
  width: 36px;
  height: 36px;
  min-width: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.metric-icon-box svg {
  width: 18px;
  height: 18px;
}

.bg-blue { background: rgba(59, 130, 246, 0.12); color: #3b82f6; }
.bg-amber { background: rgba(245, 158, 11, 0.12); color: #f59e0b; }
.bg-emerald { background: rgba(16, 185, 129, 0.12); color: #10b981; }
.bg-purple { background: rgba(139, 92, 246, 0.12); color: #8b5cf6; }
.bg-indigo { background: rgba(99, 102, 241, 0.12); color: #6366f1; }
.bg-teal { background: rgba(20, 184, 166, 0.12); color: #14b8a6; }

.btn-copy-hero {
  padding: 10px 16px;
  font-size: 13px;
  white-space: nowrap;
}

/* ========================================================================= */
/* DASHBOARD ANALYTICS & CHARTS (NOVO!)                                     */
/* ========================================================================= */
.dash-filter-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 12px 18px;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 14px;
}

.dash-filter-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.dash-filter-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
}

.dash-period-quick {
  display: flex;
  gap: 6px;
  background: var(--bg-main);
  padding: 3px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
}

.btn-period-quick {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-period-quick:hover {
  color: var(--text-main);
}

.btn-period-quick.active {
  background: var(--bg-card);
  color: var(--text-main);
  box-shadow: var(--shadow-sm);
  font-weight: 700;
}

.dash-filter-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.filter-date-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.date-sep {
  font-size: 12px;
  color: var(--text-sub);
}

.dashboard-analytics-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
  margin-bottom: 24px;
}

@media (max-width: 1024px) {
  .dashboard-analytics-grid {
    grid-template-columns: 1fr;
  }
}

.analytics-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

.analytics-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
}

.analytics-header h3 {
  font-size: 15px;
  font-weight: 700;
}

.analytics-header p {
  font-size: 12px;
  color: var(--text-muted);
}

.analytics-badge {
  background: rgba(16, 185, 129, 0.15);
  color: #10b981;
  border: 1px solid rgba(16, 185, 129, 0.3);
  padding: 4px 10px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 700;
}

.progress-container-large {
  display: flex;
  width: 100%;
  height: 14px;
  background: var(--bg-main);
  border-radius: 99px;
  overflow: hidden;
  margin-bottom: 16px;
}

.progress-bar-large {
  height: 100%;
  transition: width 0.4s ease;
}

.progress-legend {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--text-muted);
}

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

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.origem-split-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.origem-item {
  background: var(--bg-main);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 14px;
}

.origem-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

.origem-details {
  display: flex;
  flex-direction: column;
}

.origem-label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 600;
}

.origem-val {
  font-size: 18px;
  font-weight: 800;
  margin: 2px 0;
}

.origem-percent {
  font-size: 11.5px;
  color: var(--text-sub);
}

.payment-bars-list, .convenios-rank-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.bar-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.bar-row-info {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
}

.bar-track {
  width: 100%;
  height: 8px;
  background: var(--bg-main);
  border-radius: 99px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: 99px;
  transition: width 0.3s ease;
}

.loading-placeholder {
  padding: 20px;
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
}

/* ========================================================================= */
/* QUICK SEGMENTED STATUS FILTERS (A PROCESSAR vs PROCESSADAS)              */
/* ========================================================================= */
.quick-status-filter-container {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.quick-filter-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
}

.segmented-control {
  display: inline-flex;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  padding: 4px;
  border-radius: 10px;
  gap: 4px;
  box-shadow: var(--shadow-sm);
}

.segmented-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 16px;
  border-radius: 7px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.segmented-btn:hover {
  color: var(--text-main);
}

.segmented-btn.active {
  background: var(--bg-main);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  font-weight: 700;
}

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

.segmented-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 1px 7px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 700;
  background: var(--bg-input);
  color: var(--text-muted);
  border: 1px solid var(--border-color);
}

.segmented-btn.active .segmented-badge {
  background: var(--accent-primary);
  color: #ffffff;
  border-color: transparent;
}

/* ========================================================================= */
/* FILTERS PANEL                                                            */
/* ========================================================================= */
.filters-panel {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 16px 20px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}

.filters-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 14px;
  align-items: end;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.filter-group label {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.filter-search-group {
  grid-column: span 2;
}

@media (max-width: 900px) {
  .filter-search-group { grid-column: span 1; }
}

.input-control {
  width: 100%;
  height: 38px;
  padding: 0 12px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 13px;
  outline: none;
  transition: border-color 0.2s;
}

.input-sm {
  height: 32px;
  font-size: 12px;
  padding: 0 8px;
}

.input-control:focus {
  border-color: var(--border-focus);
}

.search-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 12px;
  color: var(--text-sub);
  pointer-events: none;
}

.search-input-wrapper .input-control {
  padding-left: 36px;
}

.filter-actions {
  display: flex;
  gap: 8px;
}

/* ========================================================================= */
/* DATA TABLE & TOOLBAR                                                     */
/* ========================================================================= */
.table-container {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.table-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 18px;
  background: var(--bg-toolbar);
  border-bottom: 1px solid var(--border-color);
  flex-wrap: wrap;
  gap: 12px;
}

.toolbar-left, .toolbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.selection-indicator {
  font-size: 13px;
  font-weight: 700;
  color: var(--accent-primary);
}

.table-scroll-wrapper {
  overflow-x: auto;
  max-height: 65vh;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 13px;
}

.data-table thead th {
  background: var(--bg-th);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 10;
  white-space: nowrap;
}

.data-table tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--bg-td-border);
  vertical-align: middle;
  transition: background-color 0.15s ease;
}

.data-table tbody tr {
  cursor: pointer;
}

.data-table tbody tr:hover td {
  background-color: var(--row-hover-bg);
}

.data-table tbody tr.row-selected td {
  background-color: var(--row-selected-bg);
}

.table-loading-cell {
  text-align: center;
  padding: 48px 16px !important;
  color: var(--text-muted);
}

.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid rgba(16, 185, 129, 0.2);
  border-top-color: var(--accent-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 12px auto;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ========================================================================= */
/* CSS APRIMORADO PARA O BOTÃO DE INFORMAR NF E STATUS                      */
/* ========================================================================= */

/* BOTÃO QUANDO NÃO TEM NF (PENDENTE) */
.btn-nf-pending {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 5px 12px;
  border-radius: 99px;
  border: 1px dashed rgba(99, 102, 241, 0.45);
  background: rgba(99, 102, 241, 0.08);
  color: #818cf8;
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  white-space: nowrap;
}

[data-theme="light"] .btn-nf-pending {
  border-color: #6366f1;
  background: #eef2ff;
  color: #4f46e5;
}

.btn-nf-pending:hover {
  background: #6366f1;
  color: #ffffff;
  border-style: solid;
  border-color: #6366f1;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.35);
  transform: translateY(-1px);
}

/* BADGE / BOTÃO QUANDO JÁ TEM NF (EMITIDA) */
.badge-nf-done {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 4px 11px;
  border-radius: 99px;
  border: 1px solid rgba(16, 185, 129, 0.4);
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.12), rgba(5, 150, 105, 0.18));
  color: #10b981;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
  letter-spacing: 0.3px;
}

[data-theme="light"] .badge-nf-done {
  background: #ecfdf5;
  color: #047857;
  border-color: #a7f3d0;
}

.badge-nf-done:hover {
  background: rgba(16, 185, 129, 0.28);
  border-color: #10b981;
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.25);
  transform: translateY(-1px);
}

.badge-nf-done::after {
  content: "✏️";
  font-size: 10px;
  opacity: 0.6;
  transition: opacity 0.2s;
}

.badge-nf-done:hover::after {
  opacity: 1;
}

/* STATUS PILLS */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 99px;
  font-size: 11.5px;
  font-weight: 700;
  white-space: nowrap;
}

.status-pill-pending {
  background: rgba(245, 158, 11, 0.12);
  color: #f59e0b;
  border: 1px solid rgba(245, 158, 11, 0.25);
}

.status-pill-emitted {
  background: rgba(16, 185, 129, 0.12);
  color: #10b981;
  border: 1px solid rgba(16, 185, 129, 0.25);
}

.status-pill-estornado {
  background: rgba(239, 68, 68, 0.12);
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.25);
}

/* RETENÇÃO DISCRETA NA TABELA (SEM POLUIÇÃO) */
.badge-ret-discrete {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 700;
  font-family: var(--font-mono);
  background: rgba(239, 68, 68, 0.1);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.2);
}

[data-theme="light"] .badge-ret-discrete {
  background: #fef2f2;
  color: #b91c1c;
  border-color: #fecaca;
}

.text-muted-dash {
  color: var(--text-sub);
  font-size: 13px;
}

/* BOTÕES DE AÇÕES DA TABELA */
.actions-cell-wrapper {
  display: flex;
  align-items: center;
  gap: 6px;
  justify-content: center;
}

.btn-table-action {
  width: 30px;
  height: 30px;
  border-radius: 7px;
  border: 1px solid var(--border-color);
  background: var(--bg-main);
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-table-action:hover {
  background: var(--bg-card-hover);
  color: var(--text-main);
  border-color: var(--border-focus);
  transform: translateY(-1px);
}

.btn-table-action-details:hover {
  border-color: var(--accent-blue);
  color: var(--accent-blue);
}

/* FATURA BADGE */
.fat-badge-number {
  font-family: var(--font-mono);
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
  background: rgba(59, 130, 246, 0.12);
  color: var(--accent-blue);
  border: 1px solid rgba(59, 130, 246, 0.25);
  font-size: 12.5px;
}

.mono-val {
  font-family: var(--font-mono);
}

/* ========================================================================= */
/* MODAIS DE DETALHES (FATURA E CAIXA)                                      */
/* ========================================================================= */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.modal-card {
  background: var(--bg-modal);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  width: 100%;
  max-width: 500px;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.2s ease-out;
}

.modal-card-large {
  max-width: 860px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

.modal-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 22px;
  border-bottom: 1px solid var(--border-color);
}

.modal-header-icon {
  width: 40px;
  height: 40px;
  min-width: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-header h3 {
  font-size: 17px;
  font-weight: 700;
}

.modal-subtitle {
  font-size: 12.5px;
  color: var(--text-muted);
}

.btn-close-modal {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 24px;
  cursor: pointer;
  line-height: 1;
}

.btn-close-modal:hover {
  color: var(--text-main);
}

.modal-body {
  padding: 20px 22px;
}

.modal-body-scroll {
  overflow-y: auto;
  max-height: calc(88vh - 140px);
  padding: 20px 22px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* SEÇÕES DENTRO DO MODAL */
.detail-section {
  background: var(--bg-main);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 16px 18px;
}

.detail-section-title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-color);
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}

.detail-field {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.detail-field-full {
  grid-column: 1 / -1;
}

.detail-label {
  font-size: 11.5px;
  color: var(--text-sub);
  font-weight: 600;
}

.detail-value {
  font-size: 13.5px;
  color: var(--text-main);
}

/* CAIXA DE DESTAQUE FINANCEIRO NO MODAL */
.financial-highlight-box {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

@media (max-width: 650px) {
  .financial-highlight-box { grid-template-columns: 1fr; }
}

.fin-box-item {
  border-radius: 10px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  border: 1px solid transparent;
}

.highlight-total {
  background: rgba(16, 185, 129, 0.08);
  border-color: rgba(16, 185, 129, 0.25);
}

.highlight-ret {
  background: rgba(239, 68, 68, 0.08);
  border-color: rgba(239, 68, 68, 0.25);
}

.highlight-liq {
  background: rgba(59, 130, 246, 0.08);
  border-color: rgba(59, 130, 246, 0.25);
}

.fin-box-label {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}

.fin-box-val {
  font-size: 20px;
  font-weight: 800;
  margin: 4px 0;
  font-family: var(--font-mono);
}

.highlight-total .fin-box-val { color: #10b981; }
.highlight-ret .fin-box-val { color: #f87171; }
.highlight-liq .fin-box-val { color: #60a5fa; }

.fin-box-hint {
  font-size: 11px;
  color: var(--text-sub);
}

/* TABELA DE TRIBUTOS NO MODAL */
.taxes-breakdown-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  overflow: hidden;
}

.taxes-title {
  font-size: 12px;
  font-weight: 700;
  padding: 10px 14px;
  background: var(--bg-th);
  border-bottom: 1px solid var(--border-color);
  color: var(--text-muted);
  text-transform: uppercase;
}

.taxes-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}

.taxes-table th, .taxes-table td {
  padding: 8px 14px;
  border-bottom: 1px solid var(--bg-td-border);
}

.taxes-table thead th {
  background: var(--bg-card);
  color: var(--text-sub);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.taxes-table tbody tr:last-child td {
  border-bottom: none;
}

.nf-status-banner {
  padding: 14px 16px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.banner-emitted {
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.banner-pending {
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 22px;
  background: var(--bg-modal-footer);
  border-top: 1px solid var(--border-color);
}

/* TOAST */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transform: translateY(10px);
  transition: all 0.25s ease-out;
  pointer-events: none;
  z-index: 10000;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast-success { border-color: #10b981; background: #064e3b; color: #a7f3d0; }
.toast-error { border-color: #ef4444; background: #7f1d1d; color: #fecaca; }
.toast-info { border-color: #3b82f6; background: #1e3a8a; color: #bfdbfe; }

/* ========================================================================= */
/* ESTILOS ESPECÍFICOS: MÓDULO CONTAS A PAGAR (BOLETOS & PIX)                 */
/* ========================================================================= */
.barcode-cell-container {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 320px;
}

.barcode-code-wrapper {
  flex: 1;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  padding: 4px 8px;
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-main);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  letter-spacing: 0.2px;
}

.barcode-code-wrapper.has-code {
  color: var(--accent-primary);
  font-weight: 600;
  border-color: rgba(59, 130, 246, 0.3);
  background: rgba(59, 130, 246, 0.05);
}

.barcode-code-wrapper.no-code {
  color: var(--text-sub);
  font-style: italic;
}

.btn-copy-barcode {
  background: var(--accent-primary);
  color: #fff;
  border: none;
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.15s ease;
  white-space: nowrap;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

.btn-copy-barcode:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(59, 130, 246, 0.3);
}

.btn-copy-barcode.copied {
  background: #10b981 !important;
  color: #fff !important;
  transform: scale(0.98);
}

.btn-copy-barcode.btn-disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
  background: var(--bg-card);
  color: var(--text-sub);
  border: 1px solid var(--border-color);
}

/* FORMA DE PAGAMENTO PILLS */
.forma-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 700;
  white-space: nowrap;
}

.forma-tag-boleto {
  background: rgba(99, 102, 241, 0.12);
  color: #818cf8;
  border: 1px solid rgba(99, 102, 241, 0.25);
}

.forma-tag-pix {
  background: rgba(16, 185, 129, 0.12);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.25);
}

.forma-tag-outros {
  background: rgba(148, 163, 184, 0.12);
  color: #94a3b8;
  border: 1px solid rgba(148, 163, 184, 0.25);
}

/* VENCIMENTO COM BADGE DE ATRASO OU HOJE */
.due-badge-overdue {
  display: inline-block;
  font-size: 10px;
  font-weight: 800;
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.3);
  margin-top: 2px;
}

.due-badge-today {
  display: inline-block;
  font-size: 10px;
  font-weight: 800;
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.3);
  margin-top: 2px;
}

/* MODAL DE CONTAS A PAGAR */
.barcode-highlight-container {
  background: var(--bg-card);
  border: 1.5px dashed var(--accent-primary);
  border-radius: 12px;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.barcode-box-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.barcode-box-label {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.5px;
  color: var(--accent-primary);
  text-transform: uppercase;
}

.barcode-box-content {
  background: var(--bg-main);
  border: 1px solid var(--border-color);
  padding: 12px 16px;
  border-radius: 8px;
  overflow-x: auto;
}

.barcode-box-content code {
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 700;
  color: var(--text-main);
  word-break: break-all;
  user-select: all;
  letter-spacing: 1px;
}

/* ==========================================================================
   ALTVISION BRANDING & LOGO
   ========================================================================== */
.logo-icon-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent !important;
  box-shadow: none !important;
}

.brand-img {
  max-height: 38px;
  width: auto;
  object-fit: contain;
  border-radius: 6px;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.15));
}

/* ==========================================================================
   COCKPIT EXECUTIVO - ALERTAS OPERACIONAIS DO DIA
   ========================================================================== */
.cockpit-alerts-panel {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 12px 16px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}

.cockpit-alerts-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-color);
}

.cockpit-title-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.live-status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 8px #10b981;
  animation: pulseDot 2s infinite ease-in-out;
}

@keyframes pulseDot {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
  70% { transform: scale(1.1); box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.cockpit-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.2px;
}

.cockpit-date-badge {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  background: rgba(16, 185, 129, 0.12);
  color: var(--accent-primary);
  padding: 2px 7px;
  border-radius: 9999px;
  border: 1px solid rgba(16, 185, 129, 0.25);
}

.cockpit-subtitle {
  font-size: 11.5px;
  color: var(--text-muted);
}

.cockpit-alerts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}

.cockpit-card {
  background: var(--bg-main);
  border: 1px solid var(--border-color);
  border-radius: 9px;
  padding: 9px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  transition: all 0.18s ease;
  position: relative;
  overflow: hidden;
}

.cockpit-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
  border-color: var(--border-focus);
}

.cockpit-card-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.cockpit-card-icon svg {
  width: 16px;
  height: 16px;
}

.cockpit-card-icon.danger { background: rgba(239, 68, 68, 0.12); color: #ef4444; }
.cockpit-card-icon.warning { background: rgba(245, 158, 11, 0.12); color: #f59e0b; }
.cockpit-card-icon.primary { background: rgba(16, 185, 129, 0.12); color: #10b981; }
.cockpit-card-icon.purple { background: rgba(139, 92, 246, 0.12); color: #8b5cf6; }
.cockpit-card-icon.teal { background: rgba(20, 184, 166, 0.12); color: #14b8a6; }

.cockpit-card-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.cockpit-badge-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2px;
}

.cockpit-tag {
  font-size: 9.5px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  border-radius: 4px;
  padding: 1px 5px;
}

.cockpit-tag.tag-danger { background: rgba(239, 68, 68, 0.15); color: #ef4444; }
.cockpit-tag.tag-warning { background: rgba(245, 158, 11, 0.15); color: #f59e0b; }
.cockpit-tag.tag-primary { background: rgba(16, 185, 129, 0.15); color: #10b981; }
.cockpit-tag.tag-purple { background: rgba(139, 92, 246, 0.15); color: #8b5cf6; }
.cockpit-tag.tag-teal { background: rgba(20, 184, 166, 0.15); color: #14b8a6; }

.cockpit-count {
  font-size: 10.5px;
  font-weight: 700;
  color: var(--text-muted);
}

.cockpit-value {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.3px;
  line-height: 1.2;
}

.cockpit-meta {
  font-size: 10.5px;
  color: var(--text-muted);
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cockpit-arrow {
  font-size: 18px;
  color: var(--text-sub);
  opacity: 0.6;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.cockpit-card:hover .cockpit-arrow {
  transform: translateX(3px);
  opacity: 1;
  color: var(--text-main);
}

/* ==========================================================================
   BARRA PADRONIZADA DE PRESETS (CONTAS A PAGAR & CONVÊNIOS)
   ========================================================================== */
.dash-period-quick-container {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.convenios-fetch-panel {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 18px 22px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
}

.fetch-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.fetch-title-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.fetch-panel-title {
  font-size: 16px;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.3px;
}

.fetch-panel-sub {
  font-size: 12px;
  color: var(--text-muted);
}

.convenios-controls-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.filter-group-inline {
  display: flex;
  align-items: center;
}

.checkbox-label-inline {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
}

/* GAVETA COLAPSÁVEL DE TSV */
.collapsible-drawer {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px dashed var(--border-color);
  animation: fadeIn 0.2s ease;
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.drawer-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-main);
}

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

.tsv-textarea {
  width: 100%;
  height: 120px;
  padding: 12px;
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--bg-input);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  outline: none;
  resize: vertical;
}

.tsv-textarea:focus {
  border-color: var(--border-focus);
}

/* ==========================================================================
   FATIADOR TOOLBAR & CARDS GRID
   ========================================================================== */
.fatiador-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.fatiador-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.view-mode-switch {
  display: flex;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 3px;
  gap: 3px;
}

.btn-switch {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 700;
  border: none;
  background: transparent;
  color: var(--text-muted);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-switch.active {
  background: var(--bg-card);
  color: var(--accent-primary);
  box-shadow: var(--shadow-sm);
}

.cards-grid-fatiador {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 18px;
}

/* PATIENT CARD (FATIADO POR MÉDICO) */
.patient-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  position: relative;
}

.patient-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: rgba(16, 185, 129, 0.4);
}

.card-top {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.card-header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.patient-name {
  font-size: 15px;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.2px;
  line-height: 1.3;
}

.badge-split-guide {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  font-weight: 700;
  background: rgba(139, 92, 246, 0.15);
  color: #8b5cf6;
  border: 1px solid rgba(139, 92, 246, 0.3);
  padding: 2px 6px;
  border-radius: 9999px;
  margin-top: 4px;
}

.badge-convenio {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 4px 8px;
  border-radius: 6px;
  white-space: nowrap;
}

.badge-unimed { background: rgba(0, 132, 67, 0.15); color: #008443; border: 1px solid rgba(0, 132, 67, 0.3); }
.badge-sulamerica { background: rgba(217, 119, 6, 0.15); color: #d97706; border: 1px solid rgba(217, 119, 6, 0.3); }
.badge-scsaude { background: rgba(2, 132, 199, 0.15); color: #0284c7; border: 1px solid rgba(2, 132, 199, 0.3); }
.badge-default { background: rgba(100, 116, 139, 0.15); color: #64748b; }

.card-meta-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--bg-main);
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  font-size: 12px;
  color: var(--text-muted);
}

.meta-item {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.meta-item strong {
  color: var(--text-main);
}

/* EXAMES NO CARD */
.exames-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 4px;
}

.exames-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
}

.exames-controls-mini {
  display: flex;
  align-items: center;
  gap: 6px;
}

.mini-link-btn {
  background: none;
  border: none;
  font-size: 11px;
  font-weight: 700;
  color: var(--accent-primary);
  cursor: pointer;
}

.mini-link-btn:hover {
  text-decoration: underline;
}

.exames-scroll-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 180px;
  overflow-y: auto;
  padding-right: 4px;
}

.exame-item-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.exame-item-row:hover {
  border-color: var(--border-focus);
}

.exame-item-row.unchecked {
  opacity: 0.5;
  background: transparent;
}

.exame-tuss-tag {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  background: rgba(16, 185, 129, 0.15);
  color: var(--accent-primary);
  padding: 2px 6px;
  border-radius: 4px;
  letter-spacing: 0.5px;
}

.exame-tuss-tag.warning {
  background: rgba(245, 158, 11, 0.15);
  color: #f59e0b;
}

.exame-name-text {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.btn-copy-lote {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  margin-top: 14px;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 700;
  border-radius: 10px;
  border: none;
  background: var(--accent-primary);
  color: #ffffff;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
}

.btn-copy-lote:hover:not(:disabled) {
  background: var(--accent-primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
}

.btn-copy-lote:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  box-shadow: none;
}

.btn-copy-lote.copied {
  background: #059669;
}

/* EMPTY STATE */
.empty-state-card {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 48px 24px;
  background: var(--bg-card);
  border: 1px dashed var(--border-color);
  border-radius: 16px;
}

.empty-icon-circle {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--bg-input);
  color: var(--accent-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
}

/* ========================================================================= */
/* BOTÃO E STATUS ANTI-REFRESH / KEEPALIVE                                    */
/* ========================================================================= */
.btn-antirefresh {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.25s ease;
  border: 1px solid rgba(16, 185, 129, 0.4);
  background: rgba(16, 185, 129, 0.08);
  color: #10b981;
}

.btn-antirefresh.active {
  border-color: rgba(16, 185, 129, 0.5);
  background: rgba(16, 185, 129, 0.12);
  color: #10b981;
}

.btn-antirefresh.disabled {
  border-color: var(--border-color);
  background: var(--bg-input);
  color: var(--text-muted);
}

.antirefresh-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 8px #10b981;
  animation: pulseKeepAlive 2s infinite;
}

.btn-antirefresh.disabled .antirefresh-dot {
  background: var(--text-muted);
  box-shadow: none;
  animation: none;
}


/* =========================================================================
   ESTILOS PARA TOMADOR CUSTOMIZADO & AÇÕES WHATSAPP NO MODAL E TABELAS
   ========================================================================= */
.btn-edit-tomador {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  font-size: 0.72rem;
  font-weight: 600;
  color: #0284c7;
  background: #f0f9ff;
  border: 1px solid #bae6fd;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-top: 3px;
}

/* =========================================================================
   AJUSTES RESPONSIVOS DE MODAIS PARA TELAS DE NOTEBOOK (1366x768 / 1080p)
   ========================================================================= */

/* 1. Modal Alterar Tomador (Horizontal + Scroll Seguro) */
#modal-editar-tomador-ws {
  z-index: 10500 !important;
}

#modal-editar-tomador-ws .modal-card {
  max-width: 840px !important;
  width: 95% !important;
  max-height: 90vh !important;
  display: flex !important;
  flex-direction: column !important;
  border-radius: 14px !important;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.4) !important;
  overflow: hidden !important;
}

#modal-editar-tomador-ws .modal-header {
  flex-shrink: 0 !important;
  padding: 14px 20px !important;
}

#modal-editar-tomador-ws .modal-body {
  padding: 16px 20px !important;
  overflow-y: auto !important;
  flex: 1 1 auto !important;
  max-height: calc(90vh - 120px) !important;
}

#modal-editar-tomador-ws .modal-footer {
  flex-shrink: 0 !important;
  padding: 12px 20px !important;
  border-top: 1px solid var(--border-color) !important;
  background: var(--bg-card, #f8fafc) !important;
}

.edit-tomador-grid-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  align-items: start;
}

@media (max-width: 768px) {
  .edit-tomador-grid-layout {
    grid-template-columns: 1fr;
    gap: 12px;
  }
}

/* 2. Modal Detalhes do Atendimento Req (Horizontal + 0 Scroll em Telas 15.6") */
#modal-detalhes-caixa .modal-card {
  max-width: 880px !important;
  width: 95% !important;
  max-height: 90vh !important;
  display: flex !important;
  flex-direction: column !important;
  border-radius: 14px !important;
  overflow: hidden !important;
}

#modal-detalhes-caixa .modal-header {
  flex-shrink: 0 !important;
  padding: 14px 20px !important;
}

#modal-detalhes-caixa .modal-body {
  padding: 16px 20px !important;
  overflow-y: auto !important;
  flex: 1 1 auto !important;
}

#modal-detalhes-caixa .modal-footer {
  flex-shrink: 0 !important;
  padding: 12px 20px !important;
}

.det-cax-horizontal-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 14px;
}

@media (max-width: 768px) {
  .det-cax-horizontal-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }
}

.btn-open-edit-tomador {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  font-size: 0.78rem;
  font-weight: 600;
  color: #0284c7;
  background: #f0f9ff;
  border: 1px solid #bae6fd;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.btn-open-edit-tomador:hover {
  background: #0284c7;
  color: white;
  border-color: #0284c7;
  box-shadow: 0 2px 5px rgba(2, 132, 199, 0.25);
  transform: translateY(-1px);
}

.btn-restore-single-tomador {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 6px;
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  color: #64748b;
  font-size: 0.72rem;
  font-weight: 600;
  border-radius: 4px;
  cursor: pointer;
  margin-left: 6px;
  transition: all 0.15s ease;
}

.btn-restore-single-tomador:hover {
  background: #fee2e2;
  color: #dc2626;
  border-color: #fca5a5;
}

.doc-badge-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 5px;
  font-size: 0.8rem;
  font-family: monospace;
  font-weight: 600;
  color: #334155;
}

.doc-badge-pill.doc-missing {
  background: #fef2f2;
  border-color: #fecaca;
  color: #dc2626;
  font-weight: 700;
}

.badge-custom-tomador {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #ecfdf5;
  color: #047857;
  border: 1px solid #a7f3d0;
  border-radius: 5px;
  padding: 2px 7px;
  font-size: 0.75rem;
  font-weight: 600;
}

.ws-chip {
  cursor: pointer;
  padding: 4px 11px;
  border-radius: 999px;
  background: #f1f5f9;
  color: #475569;
  font-size: 0.78rem;
  font-weight: 600;
  border: 1px solid #e2e8f0;
  transition: all 0.15s ease;
  user-select: none;
}

.ws-chip:hover {
  background: #e2e8f0;
  color: #1e293b;
}

.ws-chip.active {
  background: #0f172a;
  color: white;
  border-color: #0f172a;
}

.ws-table-wrapper {
  max-height: 460px;
  min-height: 280px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  overflow-y: auto;
  background: white;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.03);
}

.ws-table-wrapper::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.ws-table-wrapper::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}

.ws-table-wrapper::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

.ws-table-row {
  transition: background 0.1s ease;
}

.ws-table-row:hover {
  background: #f8fafc !important;
}

.btn-whatsapp-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 3px 8px;
  font-size: 0.75rem;
  font-weight: 600;
  color: #065f46;
  background: #ecfdf5;
  border: 1px solid #10b981;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-whatsapp-action:hover {
  background: #10b981;
  color: white;
}

.btn-whatsapp-table {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 4px;
  background: #ecfdf5;
  color: #059669;
  border: 1px solid #a7f3d0;
  cursor: pointer;
  margin-left: 4px;
  vertical-align: middle;
  transition: all 0.15s ease;
}

.btn-whatsapp-table:hover {
  background: #10b981;
  color: white;
  border-color: #10b981;
}

/* ========================================================================= */
/* TELA DE AUTENTICAÇÃO E LOGIN (FULLSCREEN OVERLAY)                         */
/* ========================================================================= */
#modal-login-container {
  position: fixed;
  inset: 0;
  z-index: 25000;
  background: radial-gradient(circle at center, rgba(15, 23, 42, 0.95), rgba(10, 14, 23, 0.99));
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

#modal-login-container.login-hidden {
  display: none !important;
}

.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  width: 100%;
  max-width: 440px;
  padding: 36px 32px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6), 0 0 30px rgba(16, 185, 129, 0.15);
  display: flex;
  flex-direction: column;
  gap: 20px;
  animation: modalFadeIn 0.3s ease;
}

.login-header {
  text-align: center;
}

.login-logo-img {
  max-height: 48px;
  margin-bottom: 12px;
  object-fit: contain;
}

.login-title {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.02em;
}

.login-sub {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.login-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.login-field label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
}

.login-input {
  width: 100%;
  padding: 12px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-main);
  font-size: 0.95rem;
  transition: all 0.2s ease;
}

.login-input:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15);
}

.login-btn-submit {
  width: 100%;
  padding: 13px;
  background: linear-gradient(135deg, #10b981, #059669);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 4px 15px rgba(16, 185, 129, 0.35);
  transition: all 0.2s ease;
  margin-top: 8px;
}

.login-btn-submit:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
}

.login-error-banner {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #f87171;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 0.84rem;
  display: none;
  align-items: center;
  gap: 8px;
}

.login-footer-security {
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-sub);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 6px;
}

/* ========================================================================= */
/* SIDEBAR: AÇÕES RÁPIDAS, CARD DE USUÁRIO & MARCA D'ÁGUA ALTVISION WEB     */
/* ========================================================================= */
.sidebar-quick-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  padding: 4px;
  background: var(--bg-main);
  border: 1px solid var(--border-color);
  border-radius: 8px;
}

.sidebar-action-btn {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 30px;
  padding: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.18s ease;
  position: relative;
}

.sidebar-action-btn:hover {
  background: var(--bg-card);
  color: var(--text-main);
  border-color: var(--border-color);
}

.sidebar-action-btn svg {
  stroke: currentColor;
  transition: stroke 0.18s ease, transform 0.2s ease;
}

.sidebar-action-btn:active svg {
  transform: scale(0.92);
}

.sidebar-action-btn.btn-antirefresh {
  padding: 0 !important;
  border-radius: 6px !important;
}

.sidebar-action-btn.btn-antirefresh .antirefresh-dot {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 5px;
  height: 5px;
}

/* Card do Usuário Logado na Sidebar */
.sidebar-user-card {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 9px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  transition: all 0.2s ease;
  min-width: 0;
}

.sidebar-user-card:hover {
  border-color: var(--border-focus);
}

.sidebar-user-avatar-wrap {
  flex-shrink: 0;
}

.sidebar-user-card .user-avatar-circle {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, #10b981, #3b82f6);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.76rem;
  font-weight: 700;
  box-shadow: 0 2px 6px rgba(16, 185, 129, 0.25);
  flex-shrink: 0;
}

.sidebar-user-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}

.sidebar-user-info .user-name-label {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
}

.sidebar-user-info .user-role-badge {
  align-self: flex-start;
  font-size: 0.62rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  line-height: 1.2;
}

.user-role-badge.role-admin {
  background: rgba(16, 185, 129, 0.15);
  color: #10b981;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.user-role-badge.role-recepcao {
  background: rgba(59, 130, 246, 0.15);
  color: #3b82f6;
  border: 1px solid rgba(59, 130, 246, 0.3);
}

.btn-sidebar-logout {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  flex-shrink: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.18s ease;
}

.btn-sidebar-logout:hover {
  background: rgba(239, 68, 68, 0.12);
  color: #ef4444;
  border-color: rgba(239, 68, 68, 0.25);
}

/* Marca d'Água Discreta na Sidebar */
.sidebar-altvision-watermark {
  padding: 6px 4px 2px;
  text-align: center;
  border-top: 1px dashed var(--border-color);
  margin-top: 2px;
}

.sidebar-altvision-watermark a {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-decoration: none;
  color: var(--text-muted);
  font-size: 10px;
  line-height: 1.35;
  opacity: 0.7;
  transition: all 0.2s ease;
}

.sidebar-altvision-watermark a:hover {
  opacity: 1;
  color: var(--accent-primary);
}

.sidebar-altvision-watermark .watermark-sub {
  font-size: 9px;
  color: var(--text-muted);
  font-family: var(--font-mono, monospace);
  opacity: 0.75;
}

/* Marca d'Água Discreta no Rodapé do Conteúdo Principal */
.app-panel-watermark {
  text-align: right;
  padding: 24px 6px 8px;
  font-size: 11px;
  color: var(--text-muted);
  opacity: 0.6;
  transition: opacity 0.2s ease;
}

.app-panel-watermark:hover {
  opacity: 1;
}

.app-panel-watermark a {
  color: var(--text-main);
  text-decoration: none;
  font-weight: 600;
}

.app-panel-watermark a:hover {
  color: var(--accent-primary);
  text-decoration: underline;
}

/* Regras de Sidebar Recolhida (Collapsed Mode) */
.app-sidebar.collapsed .sidebar-footer {
  padding: 6px 4px;
  gap: 5px;
}

.app-sidebar.collapsed .sidebar-quick-actions {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 3px;
  padding: 3px;
}

.app-sidebar.collapsed .sidebar-action-btn {
  width: 100%;
  height: 26px;
}

.app-sidebar.collapsed .sidebar-user-card {
  flex-direction: column;
  padding: 5px 2px;
  gap: 5px;
  justify-content: center;
  align-items: center;
}

.app-sidebar.collapsed .btn-sidebar-logout {
  width: 22px;
  height: 22px;
}

.app-sidebar.collapsed .sidebar-user-info,
.app-sidebar.collapsed .sidebar-altvision-watermark .watermark-text,
.app-sidebar.collapsed .sidebar-altvision-watermark .watermark-sub {
  display: none !important;
  visibility: hidden !important;
  width: 0 !important;
  height: 0 !important;
}

.app-sidebar.collapsed .sidebar-altvision-watermark {
  padding: 4px 0 0;
  border-top: none;
}

.app-sidebar.collapsed .sidebar-altvision-watermark a::after {
  content: 'AW';
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  opacity: 0.7;
}

.app-sidebar.collapsed .sidebar-altvision-watermark a:hover::after {
  color: var(--accent-primary);
  opacity: 1;
}

/* ========================================================================= */
/* COMPACTAÇÃO RESPONSIVA INTELIGENTE EM TELAS COM MENOS ALTURA VERTICAL     */
/* (Laptops, Telas 1366x768, 1280x720, Zoom/DPI Alto e Janelas Restauradas)   */
/* ========================================================================= */
@media (max-height: 820px) {
  .sidebar-header {
    height: 58px;
    min-height: 58px;
    padding: 8px 12px;
  }

  .app-sidebar.collapsed .sidebar-header {
    height: 64px;
    min-height: 64px;
    padding: 6px 4px;
    gap: 4px;
  }

  .sidebar-brand .logo-laborclinico-light,
  .sidebar-brand .logo-laborclinico-dark {
    max-height: 32px;
  }

  .sidebar-nav {
    padding: 6px 6px;
    gap: 2px;
  }

  .nav-section-label {
    padding: 8px 10px 4px 10px;
    margin-top: 4px;
    font-size: 10px;
    line-height: 1.4;
  }

  .nav-item {
    height: 36px;
    min-height: 36px;
    max-height: 36px;
    font-size: 13px;
    padding: 0 10px;
    gap: 8px;
  }

  .app-sidebar.collapsed .nav-item {
    height: 38px;
    min-height: 38px;
    max-height: 38px;
  }

  .nav-icon {
    min-width: 17px;
    width: 17px;
    height: 17px;
  }

  .sidebar-footer {
    padding: 6px 6px;
    gap: 4px;
  }

  .sidebar-action-btn {
    height: 26px;
  }

  .sidebar-action-btn svg {
    width: 13px;
    height: 13px;
  }

  .sidebar-user-card {
    padding: 5px 7px;
  }

  .sidebar-user-card .user-avatar-circle {
    width: 26px;
    height: 26px;
    font-size: 0.7rem;
  }

  .sidebar-user-info .user-name-label {
    font-size: 0.74rem;
  }

  .sidebar-user-info .user-role-badge {
    font-size: 0.58rem;
    padding: 0 5px;
  }

  .sidebar-db-status {
    padding: 4px 8px;
    font-size: 10.5px;
  }

  .sidebar-altvision-watermark {
    padding: 3px 2px 1px;
    margin-top: 1px;
  }

  .sidebar-altvision-watermark a {
    font-size: 9px;
  }

  .sidebar-altvision-watermark .watermark-sub {
    font-size: 8px;
  }
}

@media (max-height: 640px) {
  .sidebar-header {
    height: 52px;
    min-height: 52px;
    padding: 6px 10px;
  }

  .sidebar-brand .logo-laborclinico-light,
  .sidebar-brand .logo-laborclinico-dark {
    max-height: 30px;
  }

  .nav-section-label {
    padding: 7px 10px 3px 10px;
    margin-top: 3px;
    font-size: 9.5px;
    line-height: 1.4;
  }

  .nav-item {
    height: 34px;
    min-height: 34px;
    max-height: 34px;
    font-size: 12.5px;
    padding: 0 9px;
    gap: 8px;
  }

  .app-sidebar.collapsed .nav-item {
    height: 36px;
    min-height: 36px;
    max-height: 36px;
  }

  .sidebar-footer {
    padding: 5px 5px;
    gap: 3px;
  }

  .sidebar-action-btn {
    height: 25px;
  }

  .sidebar-user-card {
    padding: 4px 6px;
  }

  .sidebar-altvision-watermark {
    display: none; /* Oculta na sidebar para economizar preciosos pixels em telas super baixas */
  }
}

/* ========================================================================= */
/* TUTORIAL MODAL (EXTENSÃO DE CONVÊNIOS)                                    */
/* ========================================================================= */
#modal-tutorial-extensao-convenios {
  z-index: 10600 !important;
}

#modal-tutorial-extensao-convenios .modal-card {
  max-width: 680px;
  max-height: 86vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.35);
}

#modal-tutorial-extensao-convenios .modal-header {
  flex-shrink: 0;
  border-bottom: 1px solid var(--border-color);
  padding: 16px 20px;
}

#modal-tutorial-extensao-convenios .modal-body {
  overflow-y: auto;
  flex: 1;
  padding: 16px 20px;
  max-height: calc(86vh - 140px);
}

#modal-tutorial-extensao-convenios .modal-footer {
  flex-shrink: 0;
  background: var(--bg-card);
  border-top: 1px solid var(--border-color);
  padding: 12px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.tutorial-steps-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 4px 0;
}

.tutorial-step-card {
  display: flex;
  gap: 12px;
  background: var(--bg-card-hover);
  border: 1px solid var(--border-color);
  padding: 11px 14px;
  border-radius: 8px;
  align-items: flex-start;
}

.tutorial-step-num {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: linear-gradient(135deg, #10b981, #059669);
  color: white;
  font-weight: 700;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
}

.tutorial-step-body h4 {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 3px;
}

.tutorial-step-body p {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.4;
  margin: 0;
}

.code-highlight {
  display: inline-block;
  background: rgba(0, 0, 0, 0.25);
  color: #10b981;
  padding: 1px 6px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 600;
}

/* ========================================================================= */
/* RESPONSIVIDADE TOTAL & MOBILE / TABLET                                   */
/* ========================================================================= */

.sidebar-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(2px);
  z-index: 999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.sidebar-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

/* Telas médias e Laptops (até 1024px) */
@media (max-width: 1024px) {
  .app-main-content {
    padding: 14px 18px;
  }

  .dashboard-analytics-grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .metrics-grid-dashboard {
    grid-template-columns: repeat(3, 1fr);
  }

  .origem-split-container {
    grid-template-columns: 1fr 1fr;
  }

  .filters-grid {
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  }
}

/* Tablets e Telas Pequenas (até 850px) */
@media (max-width: 850px) {
  .metrics-grid,
  .metrics-grid-dashboard {
    grid-template-columns: repeat(2, 1fr);
  }

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

  .filter-search-group {
    grid-column: span 1;
  }

  .table-toolbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .toolbar-right {
    width: 100%;
    flex-wrap: wrap;
  }
}

/* Smartphones / Telas Móveis (até 768px) */
@media (max-width: 768px) {
  .btn-icon-mobile {
    display: inline-flex !important;
  }

  .app-sidebar {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    bottom: 0 !important;
    height: 100vh !important;
    z-index: 1050 !important;
    transform: translateX(-100%) !important;
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1) !important;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5) !important;
    width: 260px !important;
    min-width: 260px !important;
    max-width: 260px !important;
  }

  .app-sidebar.mobile-open {
    transform: translateX(0) !important;
  }

  .app-sidebar.collapsed {
    width: 260px !important;
    min-width: 260px !important;
    max-width: 260px !important;
    transform: translateX(-100%) !important;
  }

  .app-sidebar.collapsed.mobile-open {
    transform: translateX(0) !important;
  }

  .app-sidebar.collapsed .sidebar-brand .logo-laborclinico-light,
  .app-sidebar.collapsed .sidebar-brand .logo-laborclinico-dark {
    display: block !important;
  }

  .app-sidebar.collapsed .sidebar-brand .sidebar-brand-collapsed-symbol {
    display: none !important;
  }

  .app-sidebar.collapsed .nav-label {
    display: inline !important;
    visibility: visible !important;
    width: auto !important;
    opacity: 1 !important;
    pointer-events: auto !important;
  }

  .app-sidebar.collapsed .nav-section-label {
    display: block !important;
    visibility: visible !important;
    height: auto !important;
    padding: 8px 10px 4px 10px !important;
    margin: 0 !important;
  }

  .app-sidebar.collapsed .nav-item {
    justify-content: flex-start !important;
    padding: 9px 12px !important;
  }

  .app-sidebar.collapsed .btn-sidebar-toggle {
    display: none !important;
  }

  .app-main-content {
    padding: 12px 14px;
  }

  .main-topbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    padding-bottom: 10px;
  }

  .topbar-left {
    width: 100%;
    justify-content: flex-start;
  }

  .topbar-right {
    width: 100%;
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 8px;
  }

  .topbar-title {
    font-size: 1.15rem;
  }

  .topbar-subtitle {
    font-size: 0.78rem;
  }

  .metrics-grid,
  .metrics-grid-dashboard,
  .cockpit-alerts-grid {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .dash-filter-bar {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 14px;
  }

  .dash-filter-right {
    width: 100%;
    flex-wrap: wrap;
  }

  .origem-split-container {
    grid-template-columns: 1fr;
  }

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

  .filter-search-group {
    grid-column: span 1;
  }

  .quick-status-filter-container {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .segmented-control {
    width: 100%;
    overflow-x: auto;
  }

  .data-table {
    font-size: 11.5px;
  }

  .data-table thead th {
    padding: 8px 10px;
    font-size: 10px;
  }

  .data-table tbody td {
    padding: 7px 10px;
  }
}

/* ========================================================================= */
/* MÓDULO: CARTEIRINHA DE TIPAGEM SANGUÍNEA & SIMULADOR 3D                   */
/* ========================================================================= */

.tipagem-header-clean {
  margin-bottom: 20px;
}

.tipagem-page-title {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-main);
  margin: 0 0 4px 0;
  letter-spacing: -0.3px;
}

.tipagem-page-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin: 0;
}

/* 1. GUIA VISUAL DE PASSOS (STEPPER CLEAN) */
.tipagem-steps-guide {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 12px 20px;
  margin-bottom: 20px;
}

.tipagem-step {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
}

.step-num {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--bg-input);
  color: var(--text-muted);
  border: 1.5px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.82rem;
  flex-shrink: 0;
  transition: all 0.2s ease;
}

.tipagem-step.active .step-num {
  background: #0284c7;
  color: #ffffff;
  border-color: #0284c7;
  box-shadow: 0 2px 6px rgba(2, 132, 199, 0.3);
}

.step-meta {
  display: flex;
  flex-direction: column;
}

.step-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.2;
}

.step-desc {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.step-divider {
  width: 32px;
  height: 1px;
  background: var(--border-color);
  flex-shrink: 0;
}

/* 2. CARD DE BUSCA ELEGANTE (HERO SEARCH) */
.tipagem-hero-search-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 20px 24px;
  margin-bottom: 24px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.03);
}

.search-card-inner {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.search-icon-box {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: rgba(2, 132, 199, 0.1);
  color: #0284c7;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.search-input-col {
  flex: 1;
  min-width: 260px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.search-label {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}

.tipagem-clean-input {
  width: 100%;
  height: 46px;
  background: var(--bg-input);
  border: 1.5px solid var(--border-color);
  border-radius: 8px;
  padding: 0 16px;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-main);
  outline: none;
  transition: all 0.2s ease;
}

.tipagem-clean-input:focus {
  border-color: #0284c7;
  background: var(--bg-card);
  box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.15);
}

.btn-clean-primary {
  height: 46px;
  padding: 0 24px;
  background: linear-gradient(135deg, #003882, #0284c7);
  color: #ffffff;
  border: none;
  border-radius: 8px;
  font-size: 0.92rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 3px 10px rgba(0, 56, 130, 0.2);
  align-self: flex-end;
}

.btn-clean-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 5px 14px rgba(0, 56, 130, 0.3);
}

.search-footer-hint {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border-color);
  font-size: 0.78rem;
  color: var(--text-muted);
}

.search-footer-hint kbd {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-main);
}

/* 3. GRID PRINCIPAL (2 COLUNAS) */
.tipagem-grid-container {
  display: grid;
  grid-template-columns: minmax(380px, 1.25fr) minmax(320px, 1fr);
  gap: 24px;
  margin-bottom: 28px;
}

@media (max-width: 960px) {
  .tipagem-grid-container {
    grid-template-columns: 1fr;
  }
}

.tipagem-card-panel {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.03);
}

.panel-header-clean {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 18px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-color);
}

.panel-section-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-main);
  display: block;
}

.panel-section-sub {
  font-size: 0.76rem;
  color: var(--text-muted);
}

.btn-flip-3d {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 0.76rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-flip-3d:hover {
  background: var(--bg-card-hover);
  border-color: #0284c7;
  color: #0284c7;
}

/* 4. CENÁRIO 3D & CARTÃO OFICIAL LABORCLÍNICO (CR-80) */
.card-3d-scene {
  perspective: 1200px;
  width: 100%;
  max-width: 440px;
  height: 275px;
  position: relative;
  margin: 8px auto 16px auto;
  user-select: none;
}

.card-3d-object {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.75s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  border-radius: 14px;
  box-shadow: 0 16px 36px -6px rgba(0, 0, 0, 0.25), 0 2px 6px rgba(0, 0, 0, 0.1);
  cursor: pointer;
}

.card-3d-object.is-flipped {
  transform: rotateY(180deg);
}

.card-3d-face {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border-radius: 14px;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  overflow: hidden;
  box-sizing: border-box;
}

/* FRENTE: Exatamente como a Página 1 do PDF */
.card-3d-front {
  background: #ffffff;
  color: #0f172a;
  border: 1px solid rgba(0, 0, 0, 0.08);
  display: flex;
  flex-direction: column;
  padding: 14px 18px;
}

.card-front-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.card-logo-img {
  height: 26px;
  width: auto;
}

.card-qr-img {
  width: 32px;
  height: 32px;
}

/* Moldura Central de Recesso da Etiqueta Térmica 70x30mm */
.thermal-label-recess {
  border: 1.5px solid #cbd5e1;
  border-radius: 8px;
  background: #ffffff;
  padding: 6px 10px;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  box-sizing: border-box;
}

.thermal-label-sticker {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  color: #000000;
  background: #ffffff;
}

.label-placeholder-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: #64748b;
  font-size: 0.76rem;
  text-align: center;
  gap: 6px;
}

.label-content-active {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 100%;
}

.label-row-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  line-height: 1.1;
}

.label-brand-box {
  display: flex;
  align-items: baseline;
  gap: 5px;
}

.label-brand-name {
  font-size: 0.64rem;
  font-weight: 900;
  letter-spacing: 0.5px;
  color: #000000;
  text-transform: uppercase;
}

.label-brand-sub {
  font-size: 0.54rem;
  font-weight: 700;
  color: #262626;
  text-transform: uppercase;
}

.label-via-tag {
  font-size: 0.58rem;
  font-weight: 800;
  background: #000000;
  color: #ffffff;
  padding: 1px 5px;
  border-radius: 2px;
  white-space: nowrap;
  letter-spacing: 0.4px;
}

.label-patient-block {
  margin-top: 1px;
}

.label-patient-name {
  font-weight: 900;
  font-size: 0.86rem;
  color: #000000;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 275px;
  letter-spacing: -0.2px;
}

.label-row-sub {
  font-size: 0.63rem;
  color: #000000;
  display: flex;
  justify-content: space-between;
  border-bottom: 1px solid #000000;
  padding-bottom: 2px;
  margin-top: 1px;
}

.label-row-sub strong {
  font-weight: 800;
  color: #000000;
}

/* BLOCO CENTRAL MONOCROMÁTICO (PRETO E BRANCO) */
.label-blood-highlight {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #ffffff;
  border: 1.2px solid #000000;
  border-radius: 4px;
  padding: 3px 8px;
  margin: 2px 0;
}

.label-blood-details-col {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.label-blood-line {
  font-size: 0.66rem;
  line-height: 1.2;
  color: #000000;
  display: flex;
  gap: 4px;
}

.label-blood-line .label-blood-title {
  font-weight: 700;
  color: #000000;
}

.label-blood-line .label-blood-val {
  font-weight: 900;
  color: #000000;
}

.label-method-tag {
  font-size: 0.52rem;
  font-weight: 700;
  color: #333333;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  margin-top: 1px;
}

.label-blood-badge-col {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Badge preto invertido com tipografia branca pura de alto contraste */
.label-blood-big {
  font-size: 1.55rem;
  font-weight: 900;
  color: #ffffff;
  background: #000000;
  border: 1px solid #000000;
  padding: 2px 9px;
  border-radius: 4px;
  line-height: 1.1;
  letter-spacing: -0.5px;
  min-width: 50px;
  text-align: center;
}

.label-row-footer {
  font-size: 0.56rem;
  font-weight: 700;
  color: #000000;
  display: flex;
  justify-content: space-between;
  border-top: 1px solid #000000;
  padding-top: 2px;
}

/* VERSO: Exatamente como a Página 2 do PDF (Fundo #1a3a67 com símbolo oficial centralizado) */
.card-3d-back {
  background: #1a3a67;
  transform: rotateY(180deg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.card-back-symbol {
  width: 76px;
  height: auto;
  filter: drop-shadow(0 6px 14px rgba(0, 0, 0, 0.45));
}

.card-hint-bottom {
  text-align: center;
  font-size: 0.74rem;
  color: var(--text-muted);
}

/* 5. PAINEL DE CONFERÊNCIA & AÇÃO DE IMPRESSÃO */
.tipagem-action-panel {
  justify-content: space-between;
}

.patient-summary-box {
  background: var(--bg-hover);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 14px;
}

.summary-line-patient {
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-color);
}

.summary-lbl {
  font-size: 0.7rem;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 700;
  letter-spacing: 0.5px;
  display: block;
  margin-bottom: 2px;
}

.summary-val-main {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-main);
  display: block;
}

.summary-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.summary-val {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-main);
}

.summary-val.highlight-blue {
  color: #0284c7;
  font-weight: 700;
}

.blood-result-summary-box {
  display: flex;
  align-items: center;
  justify-content: space-around;
  background: var(--bg-hover);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 14px;
}

.blood-result-item {
  text-align: center;
}

.blood-item-lbl {
  font-size: 0.68rem;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 700;
  display: block;
  margin-bottom: 2px;
}

.blood-item-val {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--text-main);
}

.blood-item-val.color-red {
  color: #dc2626;
}

.blood-item-val.color-blue {
  color: #0284c7;
}

.blood-divider {
  width: 1px;
  height: 32px;
  background: var(--border-color);
}

.bioq-signature-box {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 0.78rem;
  color: var(--text-muted);
  padding: 8px 12px;
  background: var(--bg-hover);
  border-radius: 8px;
  margin-bottom: 16px;
}

.bioq-signature-box strong {
  color: var(--text-main);
}

.print-action-box {
  border-top: 1px solid var(--border-color);
  padding-top: 14px;
}

.print-options-row {
  display: flex;
  gap: 12px;
  margin-bottom: 12px;
}

.option-col {
  flex: 1;
}

.option-col label {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  display: block;
  margin-bottom: 4px;
}

.tipagem-select,
.tipagem-input-small {
  width: 100%;
  height: 36px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 0 10px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
  outline: none;
}

.tipagem-select:focus,
.tipagem-input-small:focus {
  border-color: #0284c7;
}

.btn-print-large {
  width: 100%;
  height: 48px;
  background: linear-gradient(135deg, #16a34a, #15803d);
  color: #ffffff;
  border: none;
  border-radius: 8px;
  font-size: 0.98rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 12px rgba(22, 163, 74, 0.25);
}

.btn-print-large:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(22, 163, 74, 0.35);
}

.btn-print-large:disabled {
  background: var(--bg-input);
  color: var(--text-muted);
  border: 1px solid var(--border-color);
  box-shadow: none;
  cursor: not-allowed;
  opacity: 0.6;
}

/* 6. HISTÓRICO DE CARTEIRINHAS */
.tipagem-history-section {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 20px 24px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.03);
}

.history-header-clean {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  flex-wrap: wrap;
  gap: 12px;
}

.history-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.history-search-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.history-search-wrap svg {
  position: absolute;
  left: 10px;
  color: var(--text-muted);
  pointer-events: none;
}

.history-search-wrap input {
  height: 34px;
  padding: 0 12px 0 32px;
  font-size: 0.82rem;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  background: var(--bg-input);
  color: var(--text-main);
  width: 260px;
  outline: none;
  transition: all 0.2s ease;
}

.history-search-wrap input:focus {
  border-color: #0284c7;
  box-shadow: 0 0 0 2px rgba(2, 132, 199, 0.15);
  width: 310px;
}

.history-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-main);
  margin: 0;
}

.history-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin: 2px 0 0 0;
}

.btn-refresh-clean {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 0.78rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-refresh-clean:hover {
  background: var(--bg-card-hover);
  color: #0284c7;
  border-color: #0284c7;
}

.history-table-container {
  max-height: 320px;
  overflow-y: auto;
}

/* ========================================================================= */
/* IMPRESSÃO TÉRMICA DIRETA (70mm x 30mm)                                    */
/* ========================================================================= */

@page {
  size: 70mm 30mm;
  margin: 0;
}

@media print {
  html, body {
    margin: 0 !important;
    padding: 0 !important;
    background: #ffffff !important;
    color: #000000 !important;
    width: 70mm !important;
    height: 30mm !important;
  }

  body > *:not(#thermal-label-print-area) {
    display: none !important;
  }

  #thermal-label-print-area {
    display: block !important;
    position: absolute !important;
    left: 0 !important;
    top: 0 !important;
    width: 70mm !important;
    height: 30mm !important;
    margin: 0 !important;
    padding: 1.8mm 3mm !important;
    box-sizing: border-box !important;
    background: #ffffff !important;
    color: #000000 !important;
    page-break-after: avoid !important;
    page-break-inside: avoid !important;
  }

  .thermal-print-container {
    width: 100% !important;
    height: 100% !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: space-between !important;
    font-family: Arial, Helvetica, sans-serif !important;
    color: #000000 !important;
  }

  .th-row-header {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
  }

  .th-patient-name {
    font-size: 9.5pt !important;
    font-weight: 900 !important;
    text-transform: uppercase !important;
    max-width: 55mm !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }

  .th-via-tag {
    font-size: 6.5pt !important;
    font-weight: bold !important;
    border: 0.8pt solid #000000 !important;
    padding: 0.5pt 2pt !important;
  }

  .th-row-info {
    font-size: 7pt !important;
    display: flex !important;
    justify-content: space-between !important;
    border-bottom: 0.5pt solid #000000 !important;
    padding-bottom: 0.8mm !important;
  }

  .th-row-result {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    padding: 0.8mm 0 !important;
  }

  .th-result-details {
    font-size: 8pt !important;
    font-weight: bold !important;
    line-height: 1.15 !important;
  }

  .th-result-badge {
    font-size: 16pt !important;
    font-weight: 900 !important;
    border: 1.2pt solid #000000 !important;
    padding: 0.5mm 2.5mm !important;
    letter-spacing: -0.5pt !important;
  }

  .th-row-footer {
    font-size: 6pt !important;
    display: flex !important;
    justify-content: space-between !important;
    border-top: 0.5pt solid #000000 !important;
    padding-top: 0.6mm !important;
  }
}



