  @import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&display=swap');
  :root {
    --bg-main: #f8fafc;
    --bg-sidebar: #0b1329;
    --sidebar-active: #3b82f6;
    --sidebar-text: #94a3b8;
    --sidebar-text-active: #ffffff;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --success-bg: #ecfdf5;
    --success-text: #047857;
    --success-border: #10b981;
    --border-color: #e2e8f0;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --card-bg: #ffffff;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  }
  * {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
  }
  body {
    background-color: var(--bg-main);
    color: var(--text-main);
    display: flex;
    min-height: 100vh;
    overflow-x: hidden;
  }
  /* SIDEBAR */
  .sidebar {
  width: 260px;
  background-color: var(--bg-sidebar);
  color: var(--sidebar-text);
  display: flex !important;
  flex-direction: column !important;
  padding: 0; /* O padding foi zerado aqui para ser controlado individualmente */
  height: 100vh;
  position: fixed !important;
  left: 0;
  top: 0;
  z-index: 100;
  border-right: 1px solid rgba(255, 255, 255, 0.05);
  overflow: hidden !important; /* Trava absoluta contra scroll na sidebar */
}
  .logo-container {
  padding: 20px 16px 10px 16px;
  flex-shrink: 0; /* Impede que a logo seja esmagada */
  }
  .logo-title {
    font-size: 24px;
    font-weight: 700;
    color: #ffffff;
    letter-spacing: 1px;
  }
  .logo-subtitle {
    font-size: 11px;
    font-weight: 500;
    color: var(--sidebar-active);
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-top: 2px;
  }
  .menu-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  flex-grow: 1; /* Ocupa o espaço exato entre topo e rodapé */
  gap: 2px; /* Espaço mínimo entre botões */
  padding: 0 16px;
  margin: 10px 0;
  min-height: 0;
  overflow: hidden;
  }

  .menu-item {
  display: flex;
  flex: 1 1 0; /* O segredo de ouro: permite que o item seja esmagado proporcionalmente */
  min-height: 0; /* Remove a trava nativa do navegador */
  }

  /* BOTÕES, TEXTOS E ÍCONES FLEXÍVEIS */
  .menu-item a {
    flex: 1; /* Faz o botão preencher 100% da altura da fatia elástica */
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 14px; /* Zeramos o espaço vertical fixo; a altura agora é calculada pelo Flexbox */
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: clamp(10px, 1.5vh, 14px); /* A fonte acompanha a redução */
    font-weight: 500;
    border-radius: 8px;
    transition: var(--transition);
    white-space: nowrap;
  }

  .menu-item a .material-symbols-rounded {
    font-size: clamp(14px, 2vh, 22px) !important;
  }
  .menu-item a:hover {
    background-color: rgba(255, 255, 255, 0.05);
    color: #ffffff;
  }
  .menu-item.active a {
    background-color: var(--sidebar-active);
    color: var(--sidebar-text-active);
    box-shadow: 0 4px 14px rgba(59, 130, 246, 0.4);
  }
  .sidebar-footer {
  padding: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  flex-shrink: 0; /* Impede que o usuário seja esmagado */
  display: flex; /* Coloca a logo e o texto lado a lado */
  align-items: center; /* Alinha tudo bem no meio (verticalmente) */
  gap: 12px; /* Cria o distanciamento entre a logo redonda e as informações */
  overflow: hidden;
  }
  .avatar-clinic {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: #3b82f6;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 16px;
  }
  .clinic-info {
  display: flex;
  flex-direction: column;
  overflow: hidden; /* Garante que o conteúdo não vaze da barra */
  }
  .clinic-name {
  font-size: 13px;
  font-weight: 600;
  color: #ffffff;
  white-space: nowrap; /* Impede que o nome quebre para a linha de baixo */
  overflow: hidden;
  text-overflow: ellipsis; /* Coloca "..." se o nome for gigante */
  }
  .clinic-role {
    font-size: 11px;
    color: var(--sidebar-text);
  }
  .status-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: #10b981;
    margin-top: 4px;
  }
  .status-dot {
    width: 8px;
    height: 8px;
    background-color: #10b981;
    border-radius: 50%;
    box-shadow: 0 0 8px #10b981;
  }
  /* MAIN CONTENT */
  .main-content {
    margin-left: 260px;
    flex-grow: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 24px 40px;
    transition: var(--transition);
  }
  /* HEADER */
  header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
  }
  .header-title-area {
    display: flex;
    align-items: center;
    gap: 16px;
  }
  .btn-menu-toggle {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-main);
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .header-title {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: var(--text-main);
  }
  .header-actions {
    display: flex;
    align-items: center;
    gap: 20px;
  }
  .action-icon {
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
  }
  .action-icon:hover {
    color: var(--primary);
  }
  .user-badge {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background-color: #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
  }
  /* SECTIONS */
  .section-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
  }
  .dashboard-grid {
    display: flex;
    flex-direction: column;
    gap: 32px;
  }
  /* FORM BUSCAR TUTOR */
  .search-card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    border: 1px solid var(--border-color);
  }
  .search-form {
    display: grid;
    grid-template-columns: 1.5fr 2fr 2fr 1fr;
    gap: 16px;
    align-items: end;
  }
  .form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
  }
  .form-group label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
  }
  .form-control {
    width: 100%;
    padding: 12px 16px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background-color: #ffffff;
    color: var(--text-main);
    font-size: 14px;
    transition: var(--transition);
    height: 45px;
  }
  .form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
  }
  .btn-search {
    background-color: var(--primary);
    color: #ffffff;
    border: none;
    border-radius: 8px;
    padding: 12px 24px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: var(--transition);
    height: 45px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
  }
  .btn-search:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
  }
  /* ALERTAS */
  .alert-banner {
    display: flex;
    align-items: center;
    gap: 12px;
    background-color: var(--success-bg);
    color: var(--success-text);
    padding: 14px 20px;
    border-radius: 8px;
    margin-top: 16px;
    font-size: 14px;
    font-weight: 500;
    border: 1px solid rgba(16, 185, 129, 0.2);
    animation: fadeIn 0.4s ease;
  }
  .alert-icon {
    background-color: rgba(16, 185, 129, 0.15);
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  /* PET CARDS */
  .pet-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
  }
  .pet-card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 24px;
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.02);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    transition: var(--transition);
  }
  .pet-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.05);
    border-color: rgba(37, 99, 235, 0.3);
  }
  .pet-avatar-wrapper {
    position: relative;
    margin-bottom: 16px;
  }
  .pet-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid #f1f5f9;
  }
  .pet-name {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 4px;
  }
  .pet-info {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 8px;
  }
  .pet-id {
    font-size: 11px;
    font-weight: 600;
    background-color: #f1f5f9;
    color: var(--text-muted);
    padding: 4px 10px;
    border-radius: 20px;
    margin-bottom: 20px;
  }
  .btn-select-pet {
    width: 100%;
    background-color: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 10px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
  }
  .btn-select-pet:hover {
    background-color: var(--primary-hover);
  }
  /* QUICK ACTIONS */
  .actions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 20px;
  }
  .action-card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 20px;
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    gap: 12px;
  }
  .action-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 12px -3px rgba(0, 0, 0, 0.04);
    border-color: var(--primary);
  }
  .action-card-icon {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    background-color: rgba(37, 99, 235, 0.08);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .action-card-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-main);
  }
  .action-card-desc {
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.4;
  }
  /* MODAL */
  .modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
  }
  .modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
  }
  .modal-container {
    background-color: #ffffff;
    border-radius: 16px;
    width: 90%;
    max-width: 650px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.15);
    border: 1px solid var(--border-color);
    
    /* ESTAS SÃO AS LINHAS QUE GARANTEM A CENTRALIZAÇÃO */
    margin: auto; 
    display: block; 
    /* Fim dos ajustes de centralização */
    
    transform: scale(0.95);
    transition: transform 0.3s ease;
  }
  .modal-overlay.active .modal-container {
    transform: scale(1);
  }
  .modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
  }
  .modal-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-main);
  }
  .btn-close-modal {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    transition: var(--transition);
  }
  .btn-close-modal:hover {
    color: var(--text-main);
  }
  .modal-body {
    padding: 24px;
  }
  .modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 20px 24px;
    border-top: 1px solid var(--border-color);
    background-color: #f8fafc;
    border-radius: 0 0 16px 16px;
  }
  .btn-secondary {
    background-color: #f1f5f9;
    color: var(--text-main);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 10px 20px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: var(--transition);
  }
  .btn-secondary:hover {
    background-color: #e2e8f0;
  }
  .btn-primary {
    background-color: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 10px 20px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: var(--transition);
  }
  .btn-primary:hover {
    background-color: var(--primary-hover);
  }
  /* PRONTUARIO TABS */
  .tabs-header {
    display: flex;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 20px;
    overflow-x: auto;
  }
  .tab-btn {
    padding: 12px 18px;
    border: none;
    background: none;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    color: var(--text-muted);
    border-bottom: 2px solid transparent;
    transition: var(--transition);
    white-space: nowrap;
  }
  .tab-btn:hover {
    color: var(--primary);
  }
  .tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
  }
  .tab-pane {
    display: none;
  }
  .tab-pane.active {
    display: block;
    animation: fadeIn 0.3s ease;
  }
  .pet-profile-summary {
    display: flex;
    gap: 16px;
    align-items: center;
    background-color: #f8fafc;
    padding: 16px;
    border-radius: 12px;
    margin-bottom: 24px;
    border: 1px solid var(--border-color);
  }
  .pet-profile-avatar {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    object-fit: cover;
  }
  .pet-profile-details {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px 16px;
    flex-grow: 1;
  }
  .detail-item {
    font-size: 12px;
    color: var(--text-muted);
  }
  .detail-item strong {
    color: var(--text-main);
  }
  /* FORM GRID FOR MODALS */
  .form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
  }
  .form-grid-full {
    grid-column: span 2;
  }
  /* TIMELINE */
  .timeline {
    position: relative;
    padding-left: 24px;
    border-left: 2px solid #e2e8f0;
    display: flex;
    flex-direction: column;
    gap: 24px;
  }
  .timeline-item {
    position: relative;
  }
  .timeline-marker {
    position: absolute;
    left: -31px;
    top: 4px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background-color: var(--primary);
    border: 2px solid #ffffff;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
  }
  .timeline-content {
    background-color: #f8fafc;
    padding: 16px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
  }
  .timeline-date {
    font-size: 11px;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 4px;
  }
  .timeline-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 6px;
  }
  .timeline-desc {
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.4;
  }
  /* GENERIC LIST/TABLE FOR OTHER TABS */
  .empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
    font-size: 14px;
  }
  .empty-state-icon {
    font-size: 32px;
    margin-bottom: 12px;
    color: var(--border-color);
  }
  /* ANIMATIONS */
  @keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
  }
  /* LOADING SPINNER */
  .loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.7);
    z-index: 2000;
    display: none;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(2px);
  }
  .loading-overlay.active {
    display: flex;
  }
  .spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
  }
  @keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
  }
  /* RESPONSIVIDADE */
  @media (max-width: 1024px) {
    .search-form {
      grid-template-columns: 1fr 1fr;
    }
    .btn-search {
      grid-column: span 2;
    }
  }
  @media (max-width: 768px) {
    .sidebar {
      transform: translateX(-260px);
    }
    .sidebar.open {
      transform: translateX(0);
    }
    .main-content {
      margin-left: 0;
      padding: 20px;
    }
    .form-grid {
      grid-template-columns: 1fr;
    }
    .form-grid-full {
      grid-column: span 1;
    }
  }

  /* Estilos para o Módulo de Gestão Clínica */
.gc-table-container {
  max-height: 400px;
  overflow-y: auto;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #ffffff;
}

.tab-pane-gc {
  animation: fadeIn 0.2s ease-in-out;
}

.select-tipo-comissao {
  border: 1px solid #cbd5e1;
  background-color: #f8fafc;
  cursor: pointer;
  transition: border-color 0.15s ease-in-out;
}

.select-tipo-comissao:focus {
  border-color: #4f46e5;
}

.input-valor-comissao:focus {
  border-color: #4f46e5;
  box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.2);
}

/* Ajustes para a Logo do SaaS no topo da Sidebar */
.logo-container {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color, #e2e8f0);
}

.saas-logo {
  width: 38px;
  height: 38px;
  object-fit: contain;
  flex-shrink: 0;
}

.logo-text-wrapper {
  display: flex;
  flex-direction: column;
}

.logo-title {
  font-size: 18px;
  font-weight: 800;
  color: var(--primary, #4f46e5);
  margin: 0;
  line-height: 1.2;
}

.logo-subtitle {
  font-size: 11px;
  color: #64748b;
  font-weight: 600;
  letter-spacing: 0.3px;
}

/* ========================================== */
/* LOGO EMPILHADO CENTRALIZADO (Miauchei)     */
/* ========================================== */
.logo-container {
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 20px 16px 16px 16px !important;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1) !important;
  box-sizing: border-box !important;
  text-align: center !important;
}

.saas-logo-img {
  width: 140px !important; /* Largura ideal para nomes por extenso */
  max-width: 100% !important;
  height: auto !important;
  max-height: 50px !important;
  object-fit: contain !important;
  margin-bottom: 6px !important;
}

.logo-subtitle {
  font-size: 11px !important;
  color: #64748b !important;
  font-weight: 600 !important;
  letter-spacing: 0.8px !important;
  text-transform: uppercase !important;
  margin: 0 !important;
}