/*
 * AgendaTech — Design System e CSS Personalizado
 * Identidade SaaS Moderna, Compacta, Elegante e Responsiva.
 * Desenvolvido por Anselmo Tech.
 */

/* =========================================================================
   1. Variáveis e Tokens de Design (Identidade Oficial AgendaTech)
   ========================================================================= */
:root {
  /* Paleta Mandatória — Alinhada à Identidade da Tela de Login */
  --color-primary: #235DDB;
  --color-primary-gradient: linear-gradient(105deg, #235DDB, #4E46CA);
  --color-primary-hover: #1D4ED8;
  --color-primary-soft: #EEF4FF;
  --color-background: #F5F8FC;
  --color-surface: #FFFFFF;
  --color-sidebar: #0D1B3C;
  --color-sidebar-gradient: radial-gradient(ellipse at 5% 88%, rgba(20, 118, 136, 0.4), transparent 52%), radial-gradient(ellipse at 100% 42%, rgba(117, 70, 177, 0.42), transparent 60%), linear-gradient(150deg, #0D1B3C, #182C5A 52%, #292654);
  --color-sidebar-hover: rgba(255, 255, 255, 0.08);
  --color-text: #17243E;
  --color-text-muted: #647087;
  --color-border: #DBE1EB;
  --color-success: #16A34A;
  --color-warning: #D97706;
  --color-danger: #DC2626;

  /* Dimensões do Layout Compacto */
  --af-sidebar-width: 220px;
  --af-sidebar-collapsed-width: 68px;
  --af-navbar-height: 58px;
  --af-transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);

  /* Raios de Borda Modernos */
  --af-radius-sm: 8px;
  --af-radius-md: 12px;
  --af-radius-lg: 16px;

  /* Sombras Discretas e Luminosas */
  --af-shadow-xs: 0 1px 2px 0 rgba(15, 36, 70, 0.04);
  --af-shadow-sm: 0 2px 8px 0 rgba(15, 36, 70, 0.05);
  --af-shadow-md: 0 6px 20px 0 rgba(15, 36, 70, 0.06);
  --af-shadow-lg: 0 12px 32px 0 rgba(15, 36, 70, 0.08);

  /* Bootstrap Variable Overrides */
  --bs-primary: var(--color-primary);
  --bs-primary-rgb: 35, 93, 219;
  --bs-body-bg: var(--color-background);
  --bs-body-color: var(--color-text);
  --bs-border-color: var(--color-border);
}

/* =========================================================================
   1.1 Variáveis do Tema Escuro (Dark Mode)
   ========================================================================= */
[data-bs-theme="dark"] {
  --color-primary: #3B82F6;
  --color-primary-gradient: linear-gradient(105deg, #2563EB, #4F46E5);
  --color-primary-hover: #60A5FA;
  --color-primary-soft: rgba(59, 130, 246, 0.15);
  --color-background: #0C1322;
  --color-surface: #101A2C;
  --color-sidebar: #090E18;
  --color-sidebar-gradient: radial-gradient(ellipse at 5% 88%, rgba(20, 118, 136, 0.3), transparent 52%), radial-gradient(ellipse at 100% 42%, rgba(117, 70, 177, 0.3), transparent 60%), linear-gradient(155deg, #090E18, #0F1D38 52%, #1C1A3A);
  --color-sidebar-hover: rgba(255, 255, 255, 0.06);
  --color-text: #EEF3FC;
  --color-text-muted: #AAB8CE;
  --color-border: #233148;
  --color-success: #22C55E;
  --color-warning: #F59E0B;
  --color-danger: #EF4444;

  /* Bootstrap Variable Overrides no Dark Mode */
  --bs-body-bg: var(--color-background);
  --bs-body-color: var(--color-text);
  --bs-border-color: var(--color-border);
  --bs-secondary-bg: #152238;
  --bs-tertiary-bg: #101A2C;
}

/* Transição suave ao alternar tema */
html, body, .af-main, .af-navbar, .card, .table {
  transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

/* Ajustes de componentes para Tema Escuro */
[data-bs-theme="dark"] .af-navbar {
  background-color: var(--color-surface);
  border-bottom-color: var(--color-border);
}

[data-bs-theme="dark"] .af-navbar__toggle:hover {
  background-color: #1E293B;
  color: var(--color-text);
}

[data-bs-theme="dark"] .card {
  background-color: var(--color-surface);
  border-color: var(--color-border);
  color: var(--color-text);
}

[data-bs-theme="dark"] .card-header {
  background-color: transparent;
  border-bottom-color: var(--color-border);
  color: var(--color-text);
}

[data-bs-theme="dark"] .card-footer {
  background-color: #0E1522;
  border-top-color: var(--color-border);
}

[data-bs-theme="dark"] .bg-white {
  background-color: var(--color-surface) !important;
}

[data-bs-theme="dark"] .bg-light {
  background-color: #1A2234 !important;
}

[data-bs-theme="dark"] .text-dark {
  color: var(--color-text) !important;
}

[data-bs-theme="dark"] .text-muted {
  color: var(--color-text-muted) !important;
}

[data-bs-theme="dark"] .text-secondary {
  color: #94A3B8 !important;
}

[data-bs-theme="dark"] .border,
[data-bs-theme="dark"] .border-top,
[data-bs-theme="dark"] .border-bottom,
[data-bs-theme="dark"] .border-start,
[data-bs-theme="dark"] .border-end {
  border-color: var(--color-border) !important;
}

[data-bs-theme="dark"] .table {
  --bs-table-bg: var(--color-surface);
  --bs-table-color: var(--color-text);
  --bs-table-border-color: var(--color-border);
}

[data-bs-theme="dark"] .table-light {
  --bs-table-bg: #1A2234;
  --bs-table-color: var(--color-text);
  --bs-table-border-color: var(--color-border);
}

[data-bs-theme="dark"] .table-hover > tbody > tr:hover > * {
  --bs-table-hover-bg: rgba(255, 255, 255, 0.04);
}

[data-bs-theme="dark"] .dropdown-menu {
  background-color: var(--color-surface);
  border-color: var(--color-border);
  color: var(--color-text);
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5);
}

[data-bs-theme="dark"] .dropdown-item {
  color: var(--color-text);
}

[data-bs-theme="dark"] .dropdown-item:hover,
[data-bs-theme="dark"] .dropdown-item:focus {
  background-color: #1E293B;
  color: #FFFFFF;
}

[data-bs-theme="dark"] .dropdown-divider {
  border-top-color: var(--color-border);
}

[data-bs-theme="dark"] .modal-content {
  background-color: var(--color-surface);
  border-color: var(--color-border);
  color: var(--color-text);
}

[data-bs-theme="dark"] .form-control,
[data-bs-theme="dark"] .form-select {
  background-color: #0E1522;
  border-color: var(--color-border);
  color: var(--color-text);
}

[data-bs-theme="dark"] .form-control:focus,
[data-bs-theme="dark"] .form-select:focus {
  background-color: #0E1522;
  border-color: var(--color-primary);
  color: var(--color-text);
}

[data-bs-theme="dark"] .input-group-text {
  background-color: #1A2234;
  border-color: var(--color-border);
  color: var(--color-text-muted);
}

[data-bs-theme="dark"] .af-footer {
  background-color: var(--color-surface);
  border-top-color: var(--color-border);
}

[data-bs-theme="dark"] .nav-pills .nav-link:not(.active) {
  color: var(--color-text-muted);
}

[data-bs-theme="dark"] .nav-pills .nav-link:not(.active):hover {
  background-color: #1A2234;
  color: var(--color-text);
}

[data-bs-theme="dark"] .badge.bg-light {
  background-color: #1E293B !important;
  color: var(--color-text-muted) !important;
}

[data-bs-theme="dark"] .af-auth-card {
  background-color: var(--color-surface);
  border-color: var(--color-border);
}

/* =========================================================================
   2. Reset Global e Tipografia
   ========================================================================= */
*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 0.875rem; /* 14px base para layout compacto */
  line-height: 1.5;
  color: var(--color-text);
  background-color: var(--color-background);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

html {
  max-width: 100%;
  overflow-x: hidden;
}

/* Contenção de rolagem horizontal em todos os contêineres principais */
.af-wrapper, .af-main, .af-content, .af-content__inner {
  max-width: 100%;
  overflow-x: clip;
}

@supports not (overflow-x: clip) {
  .af-wrapper, .af-main, .af-content, .af-content__inner {
    overflow-x: hidden;
  }
}

/* Tabelas largas permanecem contidas no card e roláveis por teclado/toque */
.af-dashboard-table-wrap {
  max-width: 100%;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-gutter: stable;
}

.af-dashboard-table {
  width: 100%;
  min-width: 520px;
  font-size: 0.8125rem;
}

.af-dashboard-table > :not(caption) > * > * {
  padding: 0.5rem 0.4rem;
}

.af-dashboard-table-wrap:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.35);
  outline-offset: 2px;
}

button, .btn, .nav-link, .dropdown-item {
  min-height: 44px;
}

/* Tablet (768px - 991px): organização fluida das ações do cabeçalho */
@media (min-width: 768px) and (max-width: 991.98px) {
  .af-page-actions {
    flex-wrap: wrap;
    gap: 8px !important;
  }
}

@media (max-width: 767.98px) {
  .af-dashboard-table { min-width: 480px; }
  .af-content { padding-inline: 12px; }

  .af-page-actions {
    width: 100%;
    display: grid !important;
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .af-page-actions > .btn,
  .af-page-actions > a {
    width: 100%;
    justify-content: center;
    min-height: 44px;
  }

  .af-period-controls {
    width: 100%;
    min-width: 0;
    max-width: 100%;
  }
}

h1, h2, h3, h4, h5, h6 {
  color: var(--color-text);
  font-weight: 600;
  letter-spacing: -0.015em;
}

a {
  color: var(--color-primary);
  text-decoration: none;
  transition: color var(--af-transition);
}

a:hover {
  color: var(--color-primary-hover);
}

/* =========================================================================
   3. Estrutura do Layout (Wrapper, Sidebar, Main, Topbar, Content)
   ========================================================================= */
.af-wrapper {
  display: flex;
  min-height: 100vh;
  width: 100%;
  position: relative;
  background-color: var(--color-background);
}

/* Sidebar Desktop — Inspirada no Story/Hero da Tela de Login */
.af-sidebar {
  width: var(--af-sidebar-width);
  height: 100vh;
  background: var(--color-sidebar-gradient);
  background-color: var(--color-sidebar);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 1040;
  border-right: 1px solid rgba(180, 210, 255, 0.12);
  transition: width var(--af-transition), transform var(--af-transition);
  overflow-x: hidden;
  overflow-y: auto;
  isolation: isolate;
}

/* Efeito Atmosférico Concêntrico Luminoso */
.af-sidebar::before {
  content: '';
  position: absolute;
  z-index: -1;
  width: 440px;
  height: 440px;
  right: -240px;
  top: -180px;
  border: 1px solid rgba(180, 210, 255, 0.08);
  border-radius: 50%;
  box-shadow: 0 0 0 50px rgba(180, 210, 255, 0.03), 0 0 0 100px rgba(180, 210, 255, 0.02);
  pointer-events: none;
}

.af-sidebar::-webkit-scrollbar {
  width: 4px;
}
.af-sidebar::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.18);
  border-radius: 2px;
}

/* Área de Marca (Logo + Nome — Padrão Tela de Login) */
.af-sidebar__brand {
  height: var(--af-navbar-height);
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
}

.af-sidebar__brand-link {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: #FFFFFF;
  overflow: hidden;
  white-space: nowrap;
}

.af-sidebar__brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  background: #FFFFFF;
  border-radius: 11px;
  box-shadow: 0 4px 16px rgba(2, 10, 37, 0.28);
  flex-shrink: 0;
}

.af-sidebar__logo {
  height: 24px;
  width: 24px;
  object-fit: contain;
  flex-shrink: 0;
}

.af-sidebar__brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.af-sidebar__title {
  font-size: 1.05rem;
  font-weight: 700;
  color: #FFFFFF;
  letter-spacing: -0.02em;
}

.af-sidebar__title-accent {
  color: #A9C8FF;
}

.af-sidebar__tagline {
  font-size: 7.5px;
  font-weight: 600;
  color: #C1CCE0;
  display: block;
  letter-spacing: 2px;
  text-transform: uppercase;
  margin-top: 2px;
}

/* Empresa Ativa no Menu */
.af-sidebar__company {
  padding: 10px 14px;
  flex-shrink: 0;
}

.af-sidebar__company-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background-color: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(193, 211, 245, 0.14);
  border-radius: var(--af-radius-md);
  color: #E2E8F0;
  overflow: hidden;
  backdrop-filter: blur(8px);
}

.af-sidebar__company-card i {
  color: #A9C8FF;
  font-size: 1rem;
  flex-shrink: 0;
}

/* Seções de Itens de Menu */
.af-sidebar__menu-label {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #94A3B8;
  padding: 12px 16px 4px 16px;
  white-space: nowrap;
}

.af-sidebar .nav {
  padding: 4px 8px;
  gap: 4px;
}

.af-sidebar .nav-item {
  width: 100%;
}

.af-sidebar .nav-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  height: 40px;
  padding: 0 12px;
  color: #C8D5EA;
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: 10px;
  transition: background-color 0.18s cubic-bezier(0.4, 0, 0.2, 1), color 0.18s cubic-bezier(0.4, 0, 0.2, 1), transform 0.15s ease;
  white-space: nowrap;
}

.af-sidebar .nav-link::before {
  content: '';
  position: absolute;
  left: 0;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background-color: #75D6DD;
  box-shadow: 0 0 10px rgba(117, 214, 221, 0.6);
  opacity: 0;
  transform: scaleY(0.3);
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.af-sidebar .nav-link:focus-visible {
  outline: 2px solid #3B82F6;
  outline-offset: 2px;
}

.af-sidebar .nav-link i {
  font-size: 1.25rem;
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  flex-shrink: 0;
  color: currentColor;
  transition: color 0.18s cubic-bezier(0.4, 0, 0.2, 1);
}

.af-sidebar .nav-link:hover {
  background-color: rgba(255, 255, 255, 0.08);
  color: #FFFFFF;
}

.af-sidebar .nav-link.active {
  background: linear-gradient(105deg, rgba(35, 93, 219, 0.35), rgba(78, 70, 202, 0.35));
  border: 1px solid rgba(169, 200, 255, 0.25);
  color: #FFFFFF;
  font-weight: 600;
  box-shadow: 0 4px 14px rgba(13, 27, 60, 0.35);
}

.af-sidebar .nav-link.active::before {
  opacity: 1;
  transform: scaleY(1);
}

/* Rodapé da Sidebar (Perfil e Logout) */
.af-sidebar__footer {
  margin-top: auto;
  padding: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  background-color: rgba(0, 0, 0, 0.18);
  flex-shrink: 0;
}

/* Sidebar Recolhida (Collapsed ~68px) no Desktop */
body.sidebar-collapsed .af-sidebar {
  width: var(--af-sidebar-collapsed-width);
}

body.sidebar-collapsed .af-sidebar__title,
body.sidebar-collapsed .af-sidebar__tagline,
body.sidebar-collapsed .af-sidebar__company-text,
body.sidebar-collapsed .af-sidebar__menu-label,
body.sidebar-collapsed .af-sidebar-text,
body.sidebar-collapsed .af-sidebar__logout-text {
  display: none !important;
}

body.sidebar-collapsed .af-sidebar__brand {
  justify-content: center;
  padding: 0;
}

body.sidebar-collapsed .af-sidebar__company {
  padding: 8px 10px;
}

body.sidebar-collapsed .af-sidebar__company-card {
  justify-content: center;
  padding: 8px 0;
}

body.sidebar-collapsed .af-sidebar .nav-link {
  justify-content: center;
  padding: 0;
  width: 44px;
  height: 44px;
  margin: 0 auto;
}

body.sidebar-collapsed .af-sidebar .nav-link i {
  font-size: 1.35rem; /* ~21-22px */
  width: 22px;
  height: 22px;
}

body.sidebar-collapsed .af-sidebar .nav-link::before {
  left: 0;
  top: 10px;
  bottom: 10px;
}

body.sidebar-collapsed .af-sidebar__footer {
  padding: 12px 8px;
}

body.sidebar-collapsed .af-sidebar__footer .nav-link {
  justify-content: center;
  padding: 0;
  width: 44px;
  height: 44px;
  margin: 0 auto;
}

body.sidebar-collapsed .af-main {
  margin-left: var(--af-sidebar-collapsed-width);
}

/* Backdrop escuro para mobile */
.af-sidebar-backdrop {
  position: fixed;
  inset: 0;
  background-color: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(2px);
  z-index: 1035;
  display: none;
}

.af-sidebar-backdrop.show {
  display: block;
}

/* Área Principal (Main) */
.af-main {
  flex: 1;
  margin-left: var(--af-sidebar-width);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-width: 0;
  transition: margin-left var(--af-transition);
  background-color: var(--color-background);
}

/* Topbar Superior */
.af-navbar {
  height: var(--af-navbar-height);
  background-color: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 1020;
  box-shadow: 0 1px 3px rgba(15, 36, 70, 0.04);
}

[data-bs-theme="dark"] .af-navbar {
  background-color: rgba(16, 26, 44, 0.95);
  border-bottom-color: var(--color-border);
}

.af-navbar__toggle {
  background: transparent;
  border: none;
  color: var(--color-text-muted);
  width: 42px;
  height: 42px;
  min-width: 44px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--af-radius-md);
  cursor: pointer;
  touch-action: manipulation;
  transition: background-color var(--af-transition), color var(--af-transition);
}

.af-navbar__toggle:hover {
  background-color: #F1F5F9;
  color: var(--color-text);
}

/* Conteúdo Principal */
.af-content {
  flex: 1;
  padding: 20px 24px;
  min-width: 0;
}

/* Rodapé */
.af-footer {
  background-color: var(--color-surface);
  border-top: 1px solid var(--color-border);
  padding: 12px 24px;
  color: var(--color-text-muted);
  font-size: 0.8125rem;
}

/* =========================================================================
   4. Componentes Padronizados
   ========================================================================= */

/* Cards */
.card {
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--af-radius-lg);
  box-shadow: var(--af-shadow-sm);
  transition: box-shadow var(--af-transition), border-color var(--af-transition);
}

.card:hover {
  box-shadow: var(--af-shadow-md);
}

.card-header {
  background-color: transparent;
  border-bottom: 1px solid var(--color-border);
  padding: 16px 20px;
  font-weight: 600;
  color: var(--color-text);
}

.card-body {
  padding: 20px;
}

.card-footer {
  background-color: #F8FAFC;
  border-top: 1px solid var(--color-border);
  padding: 14px 20px;
}

[data-bs-theme="dark"] .card-footer {
  background-color: rgba(21, 34, 56, 0.4);
}

/* Botões */
.btn {
  font-size: 0.875rem;
  font-weight: 500;
  height: 40px;
  padding: 0 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: var(--af-radius-md);
  transition: all var(--af-transition);
  white-space: nowrap;
}

.btn-sm {
  height: 32px;
  padding: 0 10px;
  font-size: 0.8125rem;
  border-radius: var(--af-radius-sm);
}

.btn-lg {
  height: 48px;
  padding: 0 22px;
  font-size: 0.9375rem;
  border-radius: var(--af-radius-md);
}

.btn-primary {
  background: var(--color-primary-gradient);
  border: none;
  color: #FFFFFF;
  font-weight: 600;
  box-shadow: 0 4px 14px rgba(35, 93, 219, 0.25);
}

.btn-primary:hover, .btn-primary:focus-visible {
  filter: brightness(1.08);
  box-shadow: 0 7px 20px rgba(35, 93, 219, 0.35);
  transform: translateY(-1px);
  color: #FFFFFF;
}

.btn-outline-primary {
  color: var(--color-primary);
  border: 1px solid var(--color-primary);
  background-color: transparent;
  font-weight: 500;
}

.btn-outline-primary:hover, .btn-outline-primary:focus-visible {
  background-color: var(--color-primary-soft);
  color: var(--color-primary-hover);
  border-color: var(--color-primary-hover);
}

.btn-outline-secondary {
  color: var(--color-text-muted);
  border: 1px solid var(--color-border);
  background-color: var(--color-surface);
  font-weight: 500;
}

.btn-outline-secondary:hover, .btn-outline-secondary:focus-visible {
  background-color: #F1F5F9;
  border-color: #CBD5E1;
  color: var(--color-text);
}

.btn-danger {
  background-color: var(--color-danger);
  border-color: var(--color-danger);
  color: #FFFFFF;
  border-radius: var(--af-radius-md);
}

.btn:focus-visible {
  box-shadow: 0 0 0 4px rgba(35, 93, 219, 0.18);
  outline: none;
}

/* Campos de Formulário & Selects */
.form-label {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 6px;
}

.form-control, .form-select {
  height: 44px;
  font-size: 0.875rem;
  color: var(--color-text);
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--af-radius-md);
  padding: 8px 14px;
  transition: border-color var(--af-transition), box-shadow var(--af-transition);
}

.form-control-sm, .form-select-sm {
  height: 34px;
  font-size: 0.8125rem;
  padding: 4px 10px;
  border-radius: var(--af-radius-sm);
}

.form-control:focus, .form-select:focus {
  border-color: #2563EB;
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.14);
  background-color: var(--color-surface);
  color: var(--color-text);
  outline: none;
}

.input-group-text {
  background-color: #F8FAFC;
  border: 1px solid var(--color-border);
  color: var(--color-text-muted);
  border-radius: var(--af-radius-md);
  font-size: 0.875rem;
  padding: 0 14px;
}

/* Badges */
.badge {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 20px;
  letter-spacing: 0.01em;
}

.badge.bg-primary {
  background-color: #EEF4FF !important;
  color: #235DDB !important;
  border: 1px solid rgba(35, 93, 219, 0.2);
}

.badge.bg-success {
  background-color: #F0FDF4 !important;
  color: #16A34A !important;
  border: 1px solid rgba(22, 163, 74, 0.2);
}

.badge.bg-warning {
  background-color: #FFFBEB !important;
  color: #D97706 !important;
  border: 1px solid rgba(217, 119, 6, 0.2);
}

.badge.bg-danger {
  background-color: #FEF2F2 !important;
  color: #DC2626 !important;
  border: 1px solid rgba(220, 38, 38, 0.2);
}

.badge.bg-secondary {
  background-color: #F1F5F9 !important;
  color: var(--color-text-muted) !important;
  border: 1px solid var(--color-border);
}

[data-bs-theme="dark"] .badge.bg-primary {
  background-color: rgba(35, 93, 219, 0.2) !important;
  color: #A9C8FF !important;
  border-color: rgba(169, 200, 255, 0.25);
}

[data-bs-theme="dark"] .badge.bg-success {
  background-color: rgba(22, 163, 74, 0.2) !important;
  color: #86EFAC !important;
}

[data-bs-theme="dark"] .badge.bg-warning {
  background-color: rgba(217, 119, 6, 0.2) !important;
  color: #FDE047 !important;
}

[data-bs-theme="dark"] .badge.bg-danger {
  background-color: rgba(220, 38, 38, 0.2) !important;
  color: #FCA5A5 !important;
}

/* Tabelas */
.table {
  color: var(--color-text);
  border-color: var(--color-border);
  margin-bottom: 0;
}

.table thead th {
  background-color: #F4F7FB;
  color: #647087;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--color-border);
  padding: 12px 16px;
}

.table tbody td {
  padding: 14px 16px;
  vertical-align: middle;
  border-bottom: 1px solid var(--color-border);
}

.table-hover tbody tr:hover {
  background-color: #F8FAFD;
}

[data-bs-theme="dark"] .table thead th {
  background-color: #141F33;
  color: #AAB8CE;
  border-bottom-color: var(--color-border);
}

[data-bs-theme="dark"] .table-hover tbody tr:hover {
  background-color: #152238;
}

/* Dropdowns */
.dropdown-menu {
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--af-radius-md);
  box-shadow: var(--af-shadow-lg);
  padding: 6px;
  font-size: 0.875rem;
}

.dropdown-item {
  border-radius: var(--af-radius-sm);
  padding: 6px 12px;
  color: var(--color-text);
  font-weight: 500;
  transition: background-color var(--af-transition);
}

.dropdown-item:hover, .dropdown-item:focus {
  background-color: #F1F5F9;
  color: var(--color-text);
}

.dropdown-item.active {
  background-color: var(--color-primary-soft);
  color: var(--color-primary);
  font-weight: 600;
}

/* Modais */
.modal-content {
  border: 1px solid var(--color-border);
  border-radius: var(--af-radius-lg);
  box-shadow: var(--af-shadow-lg);
}

.modal-header {
  border-bottom: 1px solid var(--color-border);
  padding: 16px 20px;
}

.modal-body {
  padding: 20px;
}

.modal-footer {
  border-top: 1px solid var(--color-border);
  padding: 14px 20px;
}

/* Alertas */
.alert {
  border-radius: var(--af-radius-md);
  border: 1px solid transparent;
  padding: 12px 16px;
  font-size: 0.875rem;
  animation: slideDown 0.2s ease;
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Stat Cards (Dashboard) */
.af-stat-card {
  border-radius: var(--af-radius-lg);
  border: 1px solid var(--color-border);
  background-color: var(--color-surface);
  padding: 16px;
  transition: transform var(--af-transition), box-shadow var(--af-transition);
}

.af-stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--af-shadow-md);
}

.af-stat-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--af-radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 1.25rem;
}

/* =========================================================================
   5. Calendário Compacto e Grade Otimizada
   ========================================================================= */
.af-calendar-toolbar {
  padding: 12px 16px;
  border: 1px solid var(--color-border);
  border-radius: var(--af-radius-lg);
  background-color: var(--color-surface);
  box-shadow: var(--af-shadow-xs);
  margin-bottom: 14px;
}

.af-calendar-filter-bar {
  border-top: 1px solid var(--color-border);
  padding-top: 10px;
  margin-top: 10px;
}

/* Cabeçalho dos dias da semana */
.af-calendar-weekday-header {
  background-color: #F8FAFC;
  border-bottom: 1px solid var(--color-border);
  padding: 8px 0;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
}

.af-calendar-weekday-header .col {
  color: var(--color-text-muted);
}

/* Células da grade mensal */
.af-calendar-month-grid {
  background-color: var(--color-border);
  gap: 1px;
  display: flex;
  flex-direction: column;
}

.af-calendar-week-row {
  background-color: var(--color-border);
  gap: 1px;
}

.af-calendar-day-cell {
  background-color: var(--color-surface);
  min-height: 105px;
  padding: 6px 8px;
  transition: background-color 0.15s ease;
  position: relative;
}

.af-calendar-day-cell:hover {
  background-color: #F8FAFC;
}

.af-calendar-day-cell.af-other-month {
  background-color: #FAFAFA;
  color: #94A3B8;
}

.af-calendar-today {
  background-color: var(--color-primary-soft) !important;
}

.af-day-add-btn, .af-slot-add-btn {
  opacity: 0;
  transition: opacity 0.15s ease-in-out;
}

.af-calendar-day-cell:hover .af-day-add-btn,
.af-time-slot-cell:hover .af-slot-add-btn {
  opacity: 1;
}

/* Pílulas de Agendamento */
.af-appt-pill {
  font-size: 0.75rem;
  font-weight: 500;
  padding: 3px 6px;
  border-radius: var(--af-radius-sm);
  color: #FFFFFF;
  margin-bottom: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

.af-appt-pill:hover {
  transform: translateY(-1px);
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.15);
}

@media (max-width: 767.98px) {
  .af-calendar-day-cell {
    min-height: 75px;
    padding: 3px 2px;
  }
  .af-calendar-weekday-header {
    font-size: 0.6875rem;
    padding: 6px 0;
  }
  .af-appt-pill {
    font-size: 0.6875rem;
    padding: 2px 4px;
  }
}

.af-time-slot-cell {
  border-color: var(--color-border) !important;
  background-color: var(--color-surface);
  transition: background-color 0.15s ease;
}

.af-time-slot-cell:hover {
  background-color: #F8FAFC;
}

.af-drag-over {
  background-color: #EFF6FF !important;
  border: 2px dashed var(--color-primary) !important;
}

.af-dragging {
  opacity: 0.5;
}

/* =========================================================================
   6. Tela de Autenticação / Login
   ========================================================================= */
.af-auth-wrapper {
  min-height: 100vh;
  background: radial-gradient(ellipse at 5% 88%, rgba(20, 118, 136, 0.4), transparent 52%), radial-gradient(ellipse at 100% 42%, rgba(117, 70, 177, 0.4), transparent 60%), linear-gradient(150deg, #0d1b3c, #182c5a 52%, #292654);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 32px 16px;
  position: relative;
  isolation: isolate;
}

.af-auth-wrapper::before {
  content: '';
  position: absolute;
  z-index: -1;
  width: 600px;
  height: 600px;
  right: -300px;
  top: -300px;
  border: 1px solid rgba(180, 210, 255, 0.08);
  border-radius: 50%;
  box-shadow: 0 0 0 60px rgba(180, 210, 255, 0.03), 0 0 0 120px rgba(180, 210, 255, 0.02);
  pointer-events: none;
}

.af-auth-card {
  width: 100%;
  max-width: 480px;
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--af-radius-lg);
  box-shadow: 0 20px 60px rgba(6, 15, 43, 0.35);
  padding: 36px 32px;
}

/* =========================================================================
   6.1 Linguagem visual unificada — baseada na experiência da tela de login
   ========================================================================= */
.af-app-body {
  background:
    radial-gradient(circle at 82% 4%, rgba(78, 70, 202, 0.08), transparent 24rem),
    radial-gradient(circle at 18% 92%, rgba(20, 118, 136, 0.06), transparent 28rem),
    var(--color-background);
}

.af-app-body .af-main {
  background: transparent;
}

.af-content {
  position: relative;
}

/* Modais Bootstrap sempre no topo absoluto e à frente de qualquer backdrop */
.modal-backdrop {
  z-index: 1050 !important;
}

.modal {
  z-index: 1055 !important;
}

.af-content::before {
  content: '';
  position: fixed;
  z-index: -1;
  top: calc(var(--af-navbar-height) + 24px);
  right: -110px;
  width: 300px;
  height: 300px;
  border: 1px solid rgba(35, 93, 219, 0.06);
  border-radius: 50%;
  box-shadow: 0 0 0 48px rgba(35, 93, 219, 0.025), 0 0 0 96px rgba(78, 70, 202, 0.018);
  pointer-events: none;
}

.af-content__inner {
  width: min(100%, 1440px);
  margin-inline: auto;
}

.af-content__inner > .d-flex:has(h1),
.af-content__inner > .d-flex:has(h2) {
  position: relative;
  padding: 2px 0 2px 16px;
}

.af-content__inner > .d-flex:has(h1)::before,
.af-content__inner > .d-flex:has(h2)::before {
  content: '';
  position: absolute;
  inset: 4px auto 4px 0;
  width: 4px;
  border-radius: 999px;
  background: linear-gradient(180deg, #75D6DD, #235DDB 55%, #4E46CA);
  box-shadow: 0 0 14px rgba(35, 93, 219, 0.22);
}

.af-content h1.h3,
.af-content h2.h4 {
  letter-spacing: -0.035em;
}

.af-content .breadcrumb {
  --bs-breadcrumb-divider-color: #9AA7BA;
  margin-bottom: 0;
  font-size: 0.75rem;
  font-weight: 600;
}

.af-content .breadcrumb-item a {
  color: var(--color-text-muted);
}

.af-content .breadcrumb-item a:hover,
.af-content .breadcrumb-item.active {
  color: var(--color-primary);
}

.af-navbar {
  box-shadow: 0 8px 24px rgba(15, 36, 70, 0.045);
}

.af-navbar__toggle {
  border: 1px solid transparent;
}

.af-navbar__toggle:hover,
.af-navbar__toggle:focus-visible {
  border-color: var(--color-border);
  background: var(--color-primary-soft);
  color: var(--color-primary);
  outline: none;
}

.card {
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(15, 36, 70, 0.03), 0 10px 28px rgba(15, 36, 70, 0.055);
}

.card.border-0 {
  border: 1px solid rgba(219, 225, 235, 0.76) !important;
}

.card-header h1,
.card-header h2,
.card-header h3,
.card-header h4,
.card-header h5,
.card-header h6 {
  margin-bottom: 0;
}

.form-control::placeholder {
  color: #8A96A9;
  opacity: 1;
}

textarea.form-control {
  height: auto;
  min-height: 96px;
  resize: vertical;
}

.form-check-input {
  width: 1.1rem;
  height: 1.1rem;
  border-color: #BAC4D3;
  box-shadow: none;
}

.form-check-input:checked {
  background-color: var(--color-primary);
  border-color: var(--color-primary);
}

.form-check-input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 4px rgba(35, 93, 219, 0.14);
}

.table-responsive {
  scrollbar-width: thin;
  scrollbar-color: #C4CDDA transparent;
}

.table > tbody > tr:last-child > td {
  border-bottom: 0;
}

.table-dark,
.table-dark > tr,
.table-dark > tr > th {
  --bs-table-bg: #13264E;
  --bs-table-color: #DCE8FA;
  --bs-table-border-color: rgba(255, 255, 255, 0.08);
}

.pagination {
  gap: 5px;
}

.page-link {
  min-width: 34px;
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 9px !important;
  border-color: var(--color-border);
  color: var(--color-text-muted);
  background: var(--color-surface);
}

.page-link:hover {
  color: var(--color-primary);
  background: var(--color-primary-soft);
  border-color: rgba(35, 93, 219, 0.24);
}

.active > .page-link,
.page-link.active {
  border-color: transparent;
  background: var(--color-primary-gradient);
  box-shadow: 0 4px 12px rgba(35, 93, 219, 0.24);
}

.nav-tabs {
  gap: 6px;
  border-bottom-color: var(--color-border);
}

.nav-tabs .nav-link {
  min-height: 40px;
  border: 0;
  border-radius: 10px 10px 0 0;
  color: var(--color-text-muted);
  font-weight: 600;
}

.nav-tabs .nav-link:hover {
  background: var(--color-primary-soft);
  color: var(--color-primary);
}

.nav-tabs .nav-link.active {
  color: var(--color-primary);
  background: var(--color-surface);
  box-shadow: inset 0 -2px var(--color-primary);
}

.list-group-item,
.accordion-item {
  color: var(--color-text);
  background: var(--color-surface);
  border-color: var(--color-border);
}

.accordion-button {
  color: var(--color-text);
  background: var(--color-surface);
  font-weight: 600;
}

.accordion-button:not(.collapsed) {
  color: var(--color-primary);
  background: var(--color-primary-soft);
  box-shadow: inset 0 -1px var(--color-border);
}

.progress {
  height: 8px;
  border-radius: 999px;
  background: #E8EDF5;
}

.progress-bar {
  border-radius: inherit;
  background: var(--color-primary-gradient);
}

/* Autenticação secundária: cadastro, recuperação de senha, MFA e checkout. */
.af-auth-body {
  background: #0D1B3C;
}

.af-auth-wrapper {
  overflow: hidden;
  justify-content: flex-start;
  gap: 24px;
  padding-block: clamp(24px, 5vh, 52px);
}

.af-auth-brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: #FFFFFF;
  flex-shrink: 0;
}

.af-auth-brand:hover {
  color: #FFFFFF;
}

.af-auth-brand__mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 13px;
  background: #FFFFFF;
  box-shadow: 0 8px 24px rgba(2, 10, 37, 0.28);
}

.af-auth-brand__mark img {
  object-fit: contain;
}

.af-auth-brand__name {
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.035em;
}

.af-auth-brand__name > span {
  color: #A9C8FF;
}

.af-auth-brand__name small {
  display: block;
  margin-top: 1px;
  color: #C1CCE0;
  font-size: 0.43rem;
  font-weight: 600;
  letter-spacing: 0.16rem;
}

.af-auth-content {
  width: 100%;
  padding-block: 0;
}

.af-auth-content > .row > [class*='col-'] > .card,
.af-auth-content > .card,
.af-auth-card {
  border: 1px solid rgba(219, 225, 235, 0.82) !important;
  border-radius: 20px;
  box-shadow: 0 24px 70px rgba(6, 15, 43, 0.34);
}

.af-auth-content .card-body {
  padding: clamp(24px, 4vw, 42px);
}

.af-auth-content .af-login-logo,
.af-auth-content .bg-primary.rounded-3:first-child {
  background: var(--color-primary-soft) !important;
  color: var(--color-primary) !important;
  border: 1px solid rgba(35, 93, 219, 0.12);
}

.af-auth-content .af-login-logo i,
.af-auth-content .bg-primary.rounded-3:first-child i {
  color: var(--color-primary) !important;
}

.af-auth-trust {
  margin: 0;
  color: #B7C5DB;
  font-size: 0.75rem;
}

.af-auth-trust i {
  margin-right: 6px;
  color: #75D6DD;
}

/* Jornada pública de agendamento com a mesma assinatura visual. */
.af-public-body {
  color: var(--color-text);
  background:
    radial-gradient(circle at 92% 4%, rgba(78, 70, 202, 0.1), transparent 22rem),
    radial-gradient(circle at 4% 82%, rgba(20, 118, 136, 0.08), transparent 24rem),
    var(--color-background) !important;
}

.af-public-header {
  position: relative;
  z-index: 2;
  color: #FFFFFF;
  background: var(--color-sidebar-gradient);
  border-bottom: 1px solid rgba(180, 210, 255, 0.14);
  box-shadow: 0 10px 30px rgba(6, 15, 43, 0.18);
}

.af-public-brand__mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: #FFFFFF;
  box-shadow: 0 6px 18px rgba(2, 10, 37, 0.28);
}

.af-public-brand__mark img {
  width: 27px;
  height: 27px;
  object-fit: contain;
}

.af-public-brand__accent {
  color: #A9C8FF;
}

.af-public-brand__tagline {
  color: #C1CCE0;
  font-size: 0.5rem;
  font-weight: 600;
  letter-spacing: 0.12rem;
}

.af-public-secure {
  color: #D9F8F4;
  background: rgba(117, 214, 221, 0.1);
  border: 1px solid rgba(117, 214, 221, 0.22);
}

.af-public-main {
  position: relative;
}

.af-public-main .card {
  border: 1px solid rgba(219, 225, 235, 0.78) !important;
  border-radius: 18px !important;
  box-shadow: 0 2px 8px rgba(15, 36, 70, 0.04), 0 16px 40px rgba(15, 36, 70, 0.055) !important;
}

.af-public-main .af-service-card:hover,
.af-public-main .af-service-card.selected {
  border-color: var(--color-primary) !important;
  background: var(--color-primary-soft) !important;
  box-shadow: 0 12px 28px rgba(35, 93, 219, 0.12) !important;
}

.af-public-footer {
  color: var(--color-text-muted);
  background: rgba(255, 255, 255, 0.82);
  border-top: 1px solid var(--color-border);
  backdrop-filter: blur(10px);
}

/* Páginas de erro também preservam a identidade visual do produto. */
.af-error-body {
  min-height: 100vh;
  color: #17243E;
  background: #0D1B3C;
}

.af-error-layout {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 28px;
  padding: 28px 16px;
  overflow: hidden;
  position: relative;
  isolation: isolate;
  background: var(--color-sidebar-gradient);
}

.af-error-layout::before {
  content: '';
  position: absolute;
  z-index: -1;
  width: 620px;
  height: 620px;
  right: -300px;
  top: -320px;
  border: 1px solid rgba(180, 210, 255, 0.1);
  border-radius: 50%;
  box-shadow: 0 0 0 64px rgba(180, 210, 255, 0.035), 0 0 0 128px rgba(180, 210, 255, 0.02);
}

.af-error-card {
  width: min(100%, 540px);
  padding: clamp(28px, 6vw, 52px);
  position: relative;
  overflow: hidden;
  text-align: center;
  border: 1px solid rgba(219, 225, 235, 0.9);
  border-radius: 24px;
  background: #FFFFFF;
  box-shadow: 0 24px 70px rgba(6, 15, 43, 0.38);
}

.af-error-code {
  position: absolute;
  top: -34px;
  right: 12px;
  color: rgba(35, 93, 219, 0.055);
  font-size: 8rem;
  line-height: 1;
  font-weight: 700;
  letter-spacing: -0.08em;
  user-select: none;
}

.af-error-icon {
  width: 68px;
  height: 68px;
  display: grid;
  place-items: center;
  margin: 0 auto 24px;
  position: relative;
  border: 1px solid #E0E8FA;
  border-radius: 19px;
  background: #EFF4FF;
  font-size: 1.8rem;
}

.af-error-eyebrow {
  margin-bottom: 10px;
  color: #647087;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.12rem;
}

.af-error-card h1 {
  margin-bottom: 12px;
  font-size: clamp(1.55rem, 5vw, 2.1rem);
  letter-spacing: -0.045em;
}

.af-error-description {
  max-width: 410px;
  margin: 0 auto 28px;
  color: #647087;
  line-height: 1.7;
}

[data-bs-theme="dark"] .card.border-0,
[data-bs-theme="dark"] .af-public-main .card {
  border-color: var(--color-border) !important;
}

[data-bs-theme="dark"] .progress {
  background: #1B2A42;
}

[data-bs-theme="dark"] .form-control::placeholder {
  color: #71819A;
}

/* =========================================================================
   7. Responsividade e Mobile Breakpoints
   ========================================================================= */

/* Suporte a Safe Areas (Notch de iPhone / Android e barras de navegação gestuais) */
@supports (padding: env(safe-area-inset-top)) {
  .af-navbar {
    padding-top: max(0px, env(safe-area-inset-top));
    padding-left: max(16px, calc(16px + env(safe-area-inset-left, 0px)));
    padding-right: max(16px, calc(16px + env(safe-area-inset-right, 0px)));
    height: calc(var(--af-navbar-height) + env(safe-area-inset-top, 0px));
  }
  .af-sidebar {
    padding-top: max(12px, env(safe-area-inset-top, 0px));
    padding-bottom: max(20px, env(safe-area-inset-bottom, 0px));
    padding-left: max(10px, env(safe-area-inset-left, 0px));
  }
  .af-content {
    padding-left: max(16px, calc(16px + env(safe-area-inset-left, 0px)));
    padding-right: max(16px, calc(16px + env(safe-area-inset-right, 0px)));
    padding-bottom: max(24px, calc(24px + env(safe-area-inset-bottom, 0px)));
  }
  .af-footer {
    padding-left: max(16px, calc(16px + env(safe-area-inset-left, 0px)));
    padding-right: max(16px, calc(16px + env(safe-area-inset-right, 0px)));
    padding-bottom: max(14px, calc(14px + env(safe-area-inset-bottom, 0px)));
  }
}

/* Prevenção de Zoom Involuntário no Safari iOS e Toque Ergonômico */
@media (max-width: 767.98px) {
  input, select, textarea,
  .form-control, .form-select,
  .form-control-sm, .form-select-sm {
    font-size: 16px !important; /* Mínimo exigido para não disparar zoom no iOS */
    min-height: 44px;
  }

  .btn {
    min-height: 44px;
    font-size: 0.875rem;
  }

  .btn-sm {
    min-height: 40px;
    padding: 0 12px;
  }

  .nav-link, .dropdown-item {
    min-height: 44px;
    display: flex;
    align-items: center;
  }

  /* Paginação móvel com alvo de toque adequado */
  .page-link {
    min-width: 44px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
}

/* Bloqueio de rolagem com menu lateral aberto */
body.sidebar-open {
  overflow: hidden !important;
  touch-action: none;
}

/* Drawer Off-Canvas para Tablets e Celulares (< 992px) */
@media (max-width: 991.98px) {
  .af-sidebar {
    transform: translateX(-100%);
    width: min(290px, 84vw);
    box-shadow: 8px 0 32px rgba(15, 23, 42, 0.45);
    transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 1050;
    touch-action: pan-y;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
  }

  .af-sidebar.af-sidebar--open {
    transform: translateX(0);
  }

  .af-sidebar .nav-link {
    height: 46px;
    min-height: 46px;
    font-size: 0.9375rem;
    padding: 0 14px;
    gap: 14px;
  }

  .af-sidebar .nav-link.active {
    background: linear-gradient(105deg, rgba(35, 93, 219, 0.45), rgba(78, 70, 202, 0.45));
    border-color: rgba(169, 200, 255, 0.35);
  }

  #sidebarCloseBtn {
    min-width: 44px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    touch-action: manipulation;
  }

  .af-main {
    margin-left: 0 !important;
  }

  .af-content {
    padding: 16px 14px;
  }

  .af-navbar {
    padding: 0 12px;
  }

  /* Colapso de filtros no mobile */
  .af-filters-collapse:not(.show) {
    display: none;
  }
}

/* Independência de mouse (:hover): ações essenciais sempre visíveis em dispositivos touch */
@media (hover: none), (max-width: 991.98px) {
  .af-day-add-btn,
  .af-slot-add-btn {
    opacity: 0.85 !important;
    min-width: 36px;
    min-height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .af-day-add-btn i,
  .af-slot-add-btn i {
    font-size: 1.1rem;
  }
}

/* Modais estilo Bottom Sheet no Mobile (< 576px) em orientação Retrato */
@media (max-width: 575.98px) and (min-height: 521px) {
  .modal-dialog {
    margin: 0;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    max-width: 100% !important;
    transform: translateY(100%);
    transition: transform 0.26s cubic-bezier(0.16, 1, 0.3, 1);
  }

  .modal.show .modal-dialog {
    transform: translateY(0);
  }

  .modal-content {
    border-bottom-left-radius: 0 !important;
    border-bottom-right-radius: 0 !important;
    border-top-left-radius: 20px !important;
    border-top-right-radius: 20px !important;
    max-height: 92vh;
    max-height: 92dvh;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--color-border);
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.28);
  }

  .modal-body {
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    padding: 18px 16px;
  }

  .modal-header {
    padding: 14px 16px;
    position: sticky;
    top: 0;
    background: var(--color-surface);
    z-index: 2;
    border-bottom: 1px solid var(--color-border);
  }

  /* No mobile, footer relativo para não sobrepor campos quando o teclado virtual abre */
  .modal-footer {
    padding: 12px 16px;
    position: relative;
    background: var(--color-surface);
    border-top: 1px solid var(--color-border);
    z-index: 1;
  }

  .af-auth-wrapper {
    gap: 18px;
    padding: 20px 12px;
  }

  .af-auth-content {
    padding-inline: 0;
  }

  .af-auth-content .card-body {
    padding: 22px 18px;
  }

  .af-public-secure {
    width: 42px;
    min-width: 42px;
    height: 42px;
    overflow: hidden;
    padding: 0 !important;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0;
  }

  .af-public-secure i {
    margin: 0 !important;
    font-size: 1.1rem;
  }
}

/* Modais em Orientação Paisagem ou Telas Baixas (<= 520px de altura) */
@media (max-height: 520px) {
  .modal-dialog {
    margin: 12px auto !important;
    max-height: 96vh;
  }

  .modal-content {
    border-radius: var(--af-radius-lg) !important;
    max-height: 94vh;
  }

  .modal-body {
    max-height: 60vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* Tabelas Responsivas em Cards (Transformação Semântica para Telas < 768px) */
@media (max-width: 767.98px) {
  .af-table-cards thead {
    display: none;
  }

  .af-table-cards,
  .af-table-cards tbody,
  .af-table-cards tr,
  .af-table-cards td {
    display: block;
    width: 100%;
  }

  .af-table-cards tr {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--af-radius-md);
    margin-bottom: 12px;
    padding: 14px 16px;
    box-shadow: var(--af-shadow-sm);
  }

  .af-table-cards td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 9px 0 !important;
    border: none !important;
    border-bottom: 1px dashed rgba(219, 225, 235, 0.6) !important;
    font-size: 0.875rem;
    text-align: right;
  }

  .af-table-cards td > * {
    max-width: clamp(140px, 52vw, 240px) !important;
    word-break: break-word;
    text-align: right;
  }

  .af-table-cards td:last-child {
    border-bottom: none !important;
    padding-top: 12px !important;
    justify-content: flex-end;
    gap: 8px;
  }

  .af-table-cards td:last-child > * {
    max-width: 100%;
  }

  .af-table-cards td::before {
    content: attr(data-label);
    font-weight: 600;
    font-size: 0.75rem;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    text-align: left;
    margin-right: 12px;
    flex-shrink: 0;
  }

  .af-table-cards td:empty {
    display: none;
  }

  /* Alvo de toque para botões em cards */
  .af-table-cards .btn-sm {
    min-width: 44px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
}

/* Tema Escuro para Tabelas em Cards */
[data-bs-theme="dark"] .af-table-cards tr {
  background: var(--color-surface);
  border-color: var(--color-border);
}

[data-bs-theme="dark"] .af-table-cards td {
  border-bottom-color: rgba(255, 255, 255, 0.08) !important;
}

/* Indicadores de rolagem suave e localizada em tabelas */
.table-responsive {
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
}

/* Otimizações Especiais para Telas Ultracompactas (320px a 375px) */
@media (max-width: 375.98px) {
  .af-navbar {
    padding-inline: 8px;
  }

  .af-navbar #companyDropdown span.text-truncate {
    max-width: 95px !important;
  }

  .af-content {
    padding-inline: 10px;
  }

  .card-body {
    padding: 14px 10px;
  }

  .af-page-actions {
    gap: 8px !important;
  }
}

/* Feedback de Carregamento e Prevenção de Envio Duplo em Botões */
.btn.is-loading {
  position: relative;
  pointer-events: none;
  opacity: 0.85;
}

/* Acessibilidade — Prefers Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
/* Available before deferred HTMX initializes: no idle loading messages. */
.htmx-indicator {
  opacity: 0;
  visibility: hidden;
}
.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
  opacity: 1;
  visibility: visible;
  transition: opacity 200ms ease-in;
}
