/* --------------------------------------------------------------------------
   Estrutura de Layout, Sidebar Recolhível (Mobile/Tablet) e Fixa (Desktop)
   -------------------------------------------------------------------------- */
.app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden;
  overflow-x: clip;
}

.main-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  overflow-x: clip;
  background: var(--color-bg);
}

/* Backdrop para menu lateral recolhível em telas menores (< 1024px) */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(24, 51, 45, 0.45);
  backdrop-filter: blur(3px);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.sidebar-drawer-open .sidebar-backdrop {
  display: block;
  opacity: 1;
}

/* Sidebar (Mobile/Tablet: drawer deslizante; Desktop >= 1024px: coluna fixa) */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  width: var(--side-width);
  max-width: 84vw;
  padding: var(--space-5) var(--space-4);
  overflow-y: auto;
  color: var(--side-text);
  background: var(--side-bg);
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  transform: translateX(-102%);
  transition: transform 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

.sidebar-drawer-open .sidebar {
  transform: translateX(0);
  box-shadow: 0 16px 40px rgba(6, 78, 64, 0.35);
}

.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  padding: 0 var(--space-2) var(--space-4);
  margin-bottom: var(--space-3);
  border-bottom: 1px solid var(--side-line);
}

.brand-logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  color: #FFFFFF;
}

.brand-logo:hover {
  text-decoration: none;
  color: #FFFFFF;
}

.brand-logo-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  background: var(--color-brand-secondary);
  color: #FFFFFF;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.25);
  flex-shrink: 0;
}

.brand-logo .accent {
  color: #6EE7B7;
  font-weight: 600;
}

.sidebar-close-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  color: var(--side-text);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--side-line);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.sidebar-close-btn:hover {
  color: #FFFFFF;
  background: rgba(255, 255, 255, 0.16);
}

/* Bloco contextual do parceiro / fornecedor na sidebar */
.partner-box-label {
  margin: var(--space-1) var(--space-2) 6px;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--side-muted);
}

.partner-box {
  margin-bottom: var(--space-4);
  padding: 10px 12px;
  font-size: 0.78125rem;
  line-height: 1.4;
  color: #EAF5F1;
  background: var(--side-surface);
  border: 1px solid var(--side-line);
  border-radius: var(--radius-md);
}

/* Navegação Principal da Sidebar */
.nav-section-title {
  margin: var(--space-1) var(--space-3) var(--space-2);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--side-muted);
}

.nav-links {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.nav-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  padding: 8px 12px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--side-text);
  border-radius: var(--radius-md);
  transition: background-color 0.15s ease, color 0.15s ease;
}

.nav-link svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  color: rgba(255, 255, 255, 0.65);
  transition: color 0.15s ease;
}

.nav-link:hover {
  text-decoration: none;
  color: #FFFFFF;
  background: var(--side-surface-hover);
}

.nav-link:hover svg {
  color: #FFFFFF;
}

.nav-link.active {
  color: #FFFFFF;
  font-weight: 600;
  background: var(--side-active-bg);
  box-shadow: inset 3px 0 0 #34D399;
}

.nav-link.active svg {
  color: #6EE7B7;
}

/* Rodapé da Sidebar: Identificação do Usuário + Sair */
.sidebar-account-panel {
  margin-top: var(--space-4);
  padding-top: var(--space-4);
  border-top: 1px solid var(--side-line);
}

.sidebar-footer {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: var(--space-3);
}

.avatar-circle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  font-family: var(--font-display);
  font-size: 0.78rem;
  font-weight: 700;
  color: #FFFFFF;
  background: var(--color-brand-primary);
  border-radius: var(--radius-md);
}

.avatar-soft {
  color: var(--color-brand-primary);
  background: var(--color-brand-light);
  border: 1px solid var(--color-brand-border);
}

.sidebar .avatar-circle {
  background: rgba(13, 128, 103, 0.45);
  border: 1px solid rgba(110, 231, 183, 0.35);
  color: #FFFFFF;
}

.sidebar-user-name {
  font-size: 0.8125rem;
  font-weight: 600;
  color: #FFFFFF;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-meta {
  font-size: 0.72rem;
  color: var(--side-muted);
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Botão Sair com visual sutil e seguro */
.sidebar-logout-btn {
  width: 100%;
  min-height: 36px;
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.16);
  font-size: 0.8125rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  transition: all 0.15s ease;
}

.sidebar-logout-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #FFFFFF;
  border-color: rgba(255, 255, 255, 0.3);
}

/* --------------------------------------------------------------------------
   Cabeçalho Global (.topbar)
   -------------------------------------------------------------------------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 45;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  min-height: 56px;
  padding: 10px var(--space-4);
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--color-border-card);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.topbar-menu-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  color: var(--color-text-main);
  background: var(--color-surface);
  border: 1px solid var(--color-border-card);
  border-radius: var(--radius-sm);
  cursor: pointer;
  flex-shrink: 0;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.topbar-menu-btn:hover {
  background: var(--color-surface-hover);
  border-color: var(--color-border-strong);
}

.brand-mobile {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: -0.02em;
  color: var(--color-brand-primary);
  white-space: nowrap;
}

.brand-mobile span {
  color: var(--color-brand-secondary);
  font-weight: 600;
}

.brand-mobile:hover {
  text-decoration: none;
  color: var(--color-brand-primary);
}

.topbar-identity {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

@media (max-width: 639px) {
  .topbar-identity {
    display: none;
  }
}

.topbar-greeting {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--color-text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-divider {
  display: none;
  width: 1px;
  height: 14px;
  background: var(--color-border-strong);
}

.topbar-date {
  display: none;
  font-size: 0.78125rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  color: var(--color-text-muted);
  white-space: nowrap;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-shrink: 0;
}

.topbar-clinic {
  display: none;
  font-size: 0.78125rem;
  font-weight: 500;
  color: var(--color-text-muted);
}

.plan-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--badge-success-text);
  background: var(--badge-success-bg);
  border: 1px solid var(--badge-success-border);
  border-radius: 999px;
  white-space: nowrap;
}

.plan-pill-short {
  display: none;
}

.plan-pill-full {
  display: inline;
}

.plan-pill-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--color-brand-secondary);
  flex-shrink: 0;
}

/* --------------------------------------------------------------------------
   Área Principal de Conteúdo & Aproveitamento Horizontal
   -------------------------------------------------------------------------- */
.content-wrap {
  width: 100%;
  max-width: 1520px;
  margin: 0 auto;
  padding: var(--space-4) var(--space-4) var(--space-6);
}

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-5);
}

.page-head h1,
.page-head h2 {
  margin: 0;
  font-size: var(--text-page-title);
  font-weight: 700;
  letter-spacing: -0.022em;
  color: var(--color-text-heading);
}

.page-sub {
  font-size: var(--text-subtitle);
  color: var(--color-text-muted);
  margin-top: 2px;
}

.mobile-bottom-nav {
  display: none !important;
}
