/* ============================================================
   Rhivo Clinic — Componentes de UI
   ============================================================
   Classes CSS reutilizáveis para botões, inputs, badges e
   demais elementos da interface. Todas baseadas nas variáveis
   definidas em rhivo-design-tokens.css.

   USO: <link rel="stylesheet" href="/assets/css/rhivo-components.css">
   ============================================================ */

/* ═══════════════════════════════════════════════════════════
   1. BOTÕES DE AÇÃO (Tabela) — .btn-action-*
   ═══════════════════════════════════════════════════════════ */

.btn-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1.5px solid;
  border-radius: var(--rhivo-radius-md);
  background: transparent;
  cursor: pointer;
  transition: all var(--rhivo-transition-fast);
  line-height: 1;
}

.btn-action svg,
.btn-action i {
  width: 16px;
  height: 16px;
  stroke-width: 2.2;
  transition: inherit;
}

/* ── Versão compacta (tabelas internas / modais) ── */
.btn-action-sm {
  width: 22px;
  height: 22px;
}

.btn-action-sm svg,
.btn-action-sm i {
  width: 12px;
  height: 12px;
  stroke-width: 2.5;
}

/* Conectar — Teal */
.btn-action-connect {
  border-color: rgba(0, 154, 194, 0.4);
  color: var(--rhivo-teal);
}

.btn-action-connect:hover {
  background: var(--rhivo-teal);
  border-color: var(--rhivo-teal);
  color: #ffffff;
}

/* Templates — Roxo */
.btn-action-templates {
  border-color: rgba(128, 90, 213, 0.4);
  color: #805ad5;
}

.btn-action-templates:hover {
  background: #805ad5;
  border-color: #805ad5;
  color: #ffffff;
}

/* Editar — Azul */
.btn-action-edit {
  border-color: rgba(0, 120, 198, 0.4);
  color: var(--rhivo-blue);
}

.btn-action-edit:hover {
  background: var(--rhivo-blue);
  border-color: var(--rhivo-blue);
  color: #ffffff;
}

/* Prontuário — Roxo */
.btn-action-prontuario {
  border-color: rgba(128, 90, 213, 0.4);
  color: #805ad5;
}

.btn-action-prontuario:hover {
  background: #805ad5;
  border-color: #805ad5;
  color: #ffffff;
}

/* Bloquear/Desativar — Slate */
.btn-action-lock {
  border-color: rgba(155, 157, 168, 0.4);
  color: var(--rhivo-slate);
}

.btn-action-lock:hover {
  background: var(--rhivo-slate);
  border-color: var(--rhivo-slate);
  color: #ffffff;
}

/* Excluir — Vermelho Clínico */
.btn-action-delete {
  border-color: rgba(214, 57, 57, 0.4);
  color: var(--rhivo-danger);
}

.btn-action-delete:hover {
  background: var(--rhivo-danger);
  border-color: var(--rhivo-danger);
  color: #ffffff;
}

/* Restaurar — Verde */
.btn-action-restore {
  border-color: rgba(34, 197, 94, 0.4);
  color: var(--rhivo-success);
}

.btn-action-restore:hover {
  background: var(--rhivo-success);
  border-color: var(--rhivo-success);
  color: #ffffff;
}

/* Desativar (toggle off) — Laranja */
.btn-action-toggle-off {
  border-color: rgba(245, 158, 11, 0.4);
  color: var(--rhivo-warning);
}

.btn-action-toggle-off:hover {
  background: var(--rhivo-warning);
  border-color: var(--rhivo-warning);
  color: #ffffff;
}

/* Ativar (toggle on) — Verde */
.btn-action-toggle-on {
  border-color: rgba(34, 197, 94, 0.4);
  color: var(--rhivo-success);
}

.btn-action-toggle-on:hover {
  background: var(--rhivo-success);
  border-color: var(--rhivo-success);
  color: #ffffff;
}

/* ═══════════════════════════════════════════════════════════
   2. BOTÕES PRINCIPAIS — .btn-rhivo-*
   ═══════════════════════════════════════════════════════════ */

.btn-rhivo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--rhivo-space-sm);
  padding: 0.5rem 1.25rem;
  font-family: var(--rhivo-font-family);
  font-size: var(--rhivo-text-body);
  font-weight: 500;
  line-height: 1.4;
  border-radius: var(--rhivo-radius-md);
  border: 1.5px solid transparent;
  cursor: pointer;
  transition: all var(--rhivo-transition-fast);
  text-decoration: none;
  white-space: nowrap;
}

.btn-rhivo:focus-visible {
  outline: 2px solid var(--rhivo-blue);
  outline-offset: 2px;
}

/* Primary */
.btn-rhivo-primary {
  background: var(--rhivo-blue);
  color: #ffffff;
  border-color: var(--rhivo-blue);
}

.btn-rhivo-primary:hover {
  background: var(--rhivo-blue-hover);
  border-color: var(--rhivo-blue-hover);
  color: #ffffff;
  text-decoration: none;
}

/* Outline */
.btn-rhivo-outline {
  background: transparent;
  color: var(--rhivo-blue);
  border-color: var(--rhivo-blue);
}

.btn-rhivo-outline:hover {
  background: rgba(0, 120, 198, 0.06);
  color: var(--rhivo-blue-hover);
  border-color: var(--rhivo-blue-hover);
  text-decoration: none;
}

/* Danger */
.btn-rhivo-danger {
  background: var(--rhivo-danger);
  color: #ffffff;
  border-color: var(--rhivo-danger);
}

.btn-rhivo-danger:hover {
  background: var(--rhivo-danger-hover);
  border-color: var(--rhivo-danger-hover);
  color: #ffffff;
  text-decoration: none;
}

/* Ghost (sem borda, sem fundo) */
.btn-rhivo-ghost {
  background: transparent;
  color: var(--rhivo-text-primary);
  border-color: transparent;
}

.btn-rhivo-ghost:hover {
  background: rgba(0, 0, 0, 0.05);
  color: var(--rhivo-text-primary);
  text-decoration: none;
}

/* Tamanhos */
.btn-rhivo-sm {
  padding: 0.25rem 0.75rem;
  font-size: var(--rhivo-text-small);
}

.btn-rhivo-lg {
  padding: 0.625rem 1.5rem;
  font-size: 1rem;
}

/* ═══ Estado desabilitado — cursor correto + opacidade + hover neutro ═══ */
/* Sem isso, o cursor:pointer do .btn-rhivo continua mostrando a "mãozinha"
   mesmo com o atributo disabled no HTML. */
.btn-rhivo:disabled,
.btn-rhivo[disabled] {
  cursor: not-allowed;
  opacity: 0.55;
  box-shadow: none;
  transform: none;
}
.btn-rhivo:disabled:hover,
.btn-rhivo[disabled]:hover,
.btn-rhivo:disabled:focus-visible,
.btn-rhivo[disabled]:focus-visible {
  cursor: not-allowed;
  box-shadow: none;
  outline: none;
  transform: none;
}
/* Neutraliza o hover específico de cada variante quando desabilitado */
.btn-rhivo-primary:disabled,
.btn-rhivo-primary[disabled],
.btn-rhivo-primary:disabled:hover,
.btn-rhivo-primary[disabled]:hover {
  background: var(--rhivo-blue);
  border-color: var(--rhivo-blue);
  color: #ffffff;
}
.btn-rhivo-outline:disabled,
.btn-rhivo-outline[disabled],
.btn-rhivo-outline:disabled:hover,
.btn-rhivo-outline[disabled]:hover {
  background: transparent;
  color: var(--rhivo-blue);
  border-color: var(--rhivo-blue);
}
.btn-rhivo-danger:disabled,
.btn-rhivo-danger[disabled],
.btn-rhivo-danger:disabled:hover,
.btn-rhivo-danger[disabled]:hover {
  background: var(--rhivo-danger);
  border-color: var(--rhivo-danger);
  color: #ffffff;
}
.btn-rhivo-ghost:disabled,
.btn-rhivo-ghost[disabled],
.btn-rhivo-ghost:disabled:hover,
.btn-rhivo-ghost[disabled]:hover {
  background: transparent;
  color: var(--rhivo-text-primary);
  border-color: transparent;
}
.btn-rhivo-danger-ghost:disabled,
.btn-rhivo-danger-ghost[disabled],
.btn-rhivo-danger-ghost:disabled:hover,
.btn-rhivo-danger-ghost[disabled]:hover {
  background: transparent;
  color: var(--rhivo-danger);
  border-color: transparent;
}

/* ═══════════════════════════════════════════════════════════
   3. INPUTS — .input-rhivo
   ═══════════════════════════════════════════════════════════ */

.input-rhivo {
  display: block;
  width: 100%;
  padding: 0.5rem 0.75rem;
  font-family: var(--rhivo-font-family);
  font-size: var(--rhivo-text-body);
  line-height: 1.5;
  color: var(--rhivo-text-primary);
  background: var(--rhivo-surface);
  border: 1.5px solid #dee2e6;
  border-radius: var(--rhivo-radius-md);
  transition:
    border-color var(--rhivo-transition-fast),
    box-shadow var(--rhivo-transition-fast);
  appearance: none;
}

.input-rhivo::placeholder {
  color: var(--rhivo-text-secondary);
  opacity: 1;
}

.input-rhivo:focus {
  outline: none;
  border-color: var(--rhivo-blue);
  box-shadow: 0 0 0 3px rgba(0, 120, 198, 0.12);
}

.input-rhivo:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  background: var(--rhivo-bg);
}

/* Select customizado */
select.input-rhivo {
  padding-right: 2rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239B9DA8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.625rem center;
  background-size: 16px;
  cursor: pointer;
}

select.input-rhivo::before,
select.input-rhivo::after {
  content: none;
}

/* Input group (ícone + input) */
.input-rhivo-group {
  position: relative;
}

.input-rhivo-group .input-rhivo {
  padding-left: 2.25rem;
}

.input-rhivo-group__icon {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--rhivo-text-secondary);
  pointer-events: none;
}

/* ═══════════════════════════════════════════════════════════
   4. BADGES DE ALTO CONTRASTE
   ═══════════════════════════════════════════════════════════ */

.badge-rhivo {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.125rem 0.5rem;
  font-size: var(--rhivo-text-small);
  font-weight: 500;
  border-radius: var(--rhivo-radius-sm);
  line-height: 1.4;
  white-space: nowrap;
}

/* Badge identificador (cabeçalho) */
.badge-rhivo-id {
  background: rgba(0, 120, 198, 0.08);
  color: var(--rhivo-blue);
  border: 1.5px solid rgba(0, 120, 198, 0.25);
  font-size: 0.625rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  padding: 0.125rem 0.375rem;
}

/* Badge de status */
.badge-rhivo-success {
  background: rgba(7, 159, 173, 0.1);
  color: var(--rhivo-aqua);
  border: 1px solid rgba(7, 159, 173, 0.2);
}

.badge-rhivo-warning {
  background: rgba(255, 193, 7, 0.1);
  color: #d39e00;
  border: 1px solid rgba(255, 193, 7, 0.2);
}

.badge-rhivo-danger {
  background: rgba(214, 57, 57, 0.1);
  color: var(--rhivo-danger);
  border: 1px solid rgba(214, 57, 57, 0.2);
}

.badge-rhivo-info {
  background: rgba(0, 120, 198, 0.08);
  color: var(--rhivo-blue);
  border: 1px solid rgba(0, 120, 198, 0.15);
}

.badge-rhivo-inactive {
  background: rgba(155, 157, 168, 0.12);
  color: var(--rhivo-slate);
  border: 1px solid rgba(155, 157, 168, 0.2);
}

/* Badge de plano — outline (Start) */
.badge-rhivo-outline {
  background: transparent;
  color: var(--rhivo-text-secondary);
  border: 1px solid var(--rhivo-border, rgba(0,0,0,0.12));
}

/* Badge de plano — azul (Clínica) */
.badge-rhivo-blue {
  background: rgba(0, 120, 198, 0.08);
  color: var(--rhivo-blue, #0078C6);
  border: 1px solid rgba(0, 120, 198, 0.2);
}

/* Badge de plano — roxo (Premium) */
.badge-rhivo-purple {
  background: rgba(139, 92, 246, 0.1);
  color: #8b5cf6;
  border: 1px solid rgba(139, 92, 246, 0.2);
}

/* ═══════════════════════════════════════════════════════════
   6. CARD
   ═══════════════════════════════════════════════════════════ */

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

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

.rhivo-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--rhivo-space-md) var(--rhivo-space-lg);
  border-bottom: 1px solid var(--rhivo-border);
  gap: var(--rhivo-space-md);
}

.rhivo-card__body {
  padding: var(--rhivo-space-lg);
}

.rhivo-card__footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--rhivo-space-sm);
  padding: var(--rhivo-space-md) var(--rhivo-space-lg);
  border-top: 1px solid var(--rhivo-border);
}

/* ═══════════════════════════════════════════════════════════
   7. TABELA BASE
   ═══════════════════════════════════════════════════════════ */

.rhivo-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--rhivo-text-body);
}

.rhivo-table th {
  padding: 0.75rem 1rem;
  text-align: left;
  font-weight: 600;
  font-size: var(--rhivo-text-small);
  color: var(--rhivo-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  border-bottom: 2px solid var(--rhivo-border);
  white-space: nowrap;
}

.rhivo-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--rhivo-border);
  vertical-align: middle;
}

.rhivo-table tbody tr:hover {
  background: rgba(0, 0, 0, 0.02);
}

[data-bs-theme="dark"] .rhivo-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.02);
}

[data-bs-theme="dark"] .input-rhivo {
  border-color: var(--rhivo-border);
}

[data-bs-theme="dark"] select.input-rhivo {
  appearance: none !important;
  -webkit-appearance: none !important;
  background-color: var(--rhivo-surface) !important;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%237a7f99' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E") !important;
  background-repeat: no-repeat !important;
  background-position: right 0.625rem center !important;
  background-size: 16px !important;
}

[data-bs-theme="dark"] select.input-rhivo::before,
[data-bs-theme="dark"] select.input-rhivo::after {
  display: none !important;
  content: none !important;
}

[data-bs-theme="dark"] .rhivo-crud__table td {
  border-bottom-color: var(--rhivo-border);
}

[data-bs-theme="dark"] .rhivo-crud__table th {
  background: transparent;
}

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

[data-bs-theme="dark"] .rhivo-segmented__item--active {
  background: var(--rhivo-surface);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

[data-bs-theme="dark"] .rhivo-kanban__card {
  background: var(--rhivo-surface);
}

[data-bs-theme="dark"] .rhivo-kanban__column {
  background: var(--rhivo-bg-subtle);
}

/* ═══════════════════════════════════════════════════════════
   8. UTILITÁRIOS
   ═══════════════════════════════════════════════════════════ */

/* Cores de texto */
.rhivo-text-primary { color: var(--rhivo-text-primary); }
.rhivo-text-secondary { color: var(--rhivo-text-secondary); }
.rhivo-text-blue { color: var(--rhivo-blue); }
.rhivo-text-aqua { color: var(--rhivo-aqua); }
.rhivo-text-danger { color: #d63939; }

/* Cores de fundo */
.rhivo-bg-surface { background: var(--rhivo-surface); }
.rhivo-bg-blue-light { background: rgba(0, 120, 198, 0.06); }

/* Espaçamento */
.rhivo-mt-xs { margin-top: var(--rhivo-space-xs); }
.rhivo-mt-sm { margin-top: var(--rhivo-space-sm); }
.rhivo-mt-md { margin-top: var(--rhivo-space-md); }
.rhivo-mt-lg { margin-top: var(--rhivo-space-lg); }
.rhivo-mb-xs { margin-bottom: var(--rhivo-space-xs); }
.rhivo-mb-sm { margin-bottom: var(--rhivo-space-sm); }
.rhivo-mb-md { margin-bottom: var(--rhivo-space-md); }
.rhivo-mb-lg { margin-bottom: var(--rhivo-space-lg); }
.rhivo-p-xs { padding: var(--rhivo-space-xs); }
.rhivo-p-sm { padding: var(--rhivo-space-sm); }
.rhivo-p-md { padding: var(--rhivo-space-md); }
.rhivo-p-lg { padding: var(--rhivo-space-lg); }

/* Visibilidade */
.rhivo-hidden { display: none; }
.rhivo-flex { display: flex; }
.rhivo-flex-center { display: flex; align-items: center; justify-content: center; }
.rhivo-gap-xs { gap: var(--rhivo-space-xs); }
.rhivo-gap-sm { gap: var(--rhivo-space-sm); }
.rhivo-gap-md { gap: var(--rhivo-space-md); }

/* Focus ring acessível */
.rhivo-focus-ring:focus-visible {
  outline: 2px solid var(--rhivo-blue);
  outline-offset: 2px;
}

/* ═══════════════════════════════════════════════════════════
   9. EMPTY STATE — .rhivo-empty
   ═══════════════════════════════════════════════════════════ */

.rhivo-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--rhivo-space-xl) var(--rhivo-space-lg);
  text-align: center;
  min-height: 240px;
  background: var(--rhivo-surface);
  border: 1px dashed var(--rhivo-border);
  border-radius: var(--rhivo-radius-lg);
}

.rhivo-empty__icon {
  width: 64px;
  height: 64px;
  margin-bottom: var(--rhivo-space-md);
  color: var(--rhivo-text-tertiary, var(--rhivo-slate));
  display: flex;
  align-items: center;
  justify-content: center;
}

.rhivo-empty__icon svg {
  width: 100%;
  height: 100%;
}

.rhivo-empty__title {
  margin: 0 0 var(--rhivo-space-sm);
  font-size: var(--rhivo-text-h3, 1.125rem);
  font-weight: 600;
  color: var(--rhivo-text-primary);
  line-height: 1.4;
}

.rhivo-empty__message {
  margin: 0 0 var(--rhivo-space-md);
  font-size: var(--rhivo-text-body);
  color: var(--rhivo-text-secondary);
  line-height: 1.5;
  max-width: 360px;
}

.rhivo-empty a.btn-rhivo,
.rhivo-empty button.btn-rhivo {
  margin-top: var(--rhivo-space-sm);
}

/* ═══════════════════════════════════════════════════════════
   10. LOADING OVERLAY — .rhivo-loading-overlay
   ═══════════════════════════════════════════════════════════ */

.rhivo-loading-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.5);
  z-index: 50;
  backdrop-filter: blur(1px);
}

[data-bs-theme="dark"] .rhivo-loading-overlay {
  background: rgba(10, 14, 26, 0.5);
}

.rhivo-loading-overlay__spinner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--rhivo-space-sm);
}

.rhivo-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--rhivo-border);
  border-top-color: var(--rhivo-blue);
  border-radius: 50%;
  animation: rhivo-spin 0.7s linear infinite;
}

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

.rhivo-loading-overlay__text {
  font-size: var(--rhivo-text-small);
  color: var(--rhivo-text-secondary);
}

/* Container relativo para o loading overlay */
.rhivo-loading-container {
  position: relative;
  min-height: 120px;
}

/* ═══════════════════════════════════════════════════════════
   11. CONFIRMATION MODAL — .rhivo-modal
   ═══════════════════════════════════════════════════════════ */

.rhivo-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.25);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 1050;
  animation: rhivo-fade-in 0.15s ease-out;
}

.rhivo-modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 1060;
  width: 90%;
  max-width: 440px;
  animation: rhivo-scale-in 0.2s ease-out;
}

.rhivo-modal__content {
  background: var(--rhivo-surface);
  border-radius: var(--rhivo-radius-lg);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
  overflow: hidden;
}

.rhivo-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--rhivo-space-lg) var(--rhivo-space-lg) 0;
}

.rhivo-modal__title {
  margin: 0;
  font-size: var(--rhivo-text-h3, 1.125rem);
  font-weight: 600;
  color: var(--rhivo-text-primary);
}

.rhivo-modal__close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--rhivo-text-secondary);
  cursor: pointer;
  border-radius: var(--rhivo-radius-sm);
  transition: all var(--rhivo-transition-fast);
}

.rhivo-modal__close:hover {
  background: var(--rhivo-bg-hover, rgba(0,0,0,0.05));
  color: var(--rhivo-text-primary);
}

.rhivo-modal__body {
  padding: var(--rhivo-space-lg);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--rhivo-space-md);
  text-align: center;
}

.rhivo-modal__icon {
  color: var(--rhivo-danger, #e74c3c);
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.rhivo-modal__icon svg {
  width: 100%;
  height: 100%;
}

.rhivo-modal__message {
  margin: 0;
  font-size: var(--rhivo-text-body);
  color: var(--rhivo-text-primary);
  line-height: 1.6;
  max-width: 360px;
}

.rhivo-modal__footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--rhivo-space-sm);
  padding: 0 var(--rhivo-space-lg) var(--rhivo-space-lg);
}

/* Animações */
@keyframes rhivo-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes rhivo-scale-in {
  from {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.92);
  }
  to {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
}

/* Dark mode ajustes para o modal */
[data-bs-theme="dark"] .rhivo-modal-backdrop {
  background: rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

[data-bs-theme="dark"] .rhivo-modal__content {
  background: #1e293b;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

[data-bs-theme="dark"] .rhivo-loading-overlay {
  background: color-mix(in srgb, var(--rhivo-bg, #111827) 50%, transparent);
}

/* ═══════════════════════════════════════════════════════════
   ALERT MODAL VARIANT — .rhivo-modal--alert
   ═══════════════════════════════════════════════════════════ */

.rhivo-modal--alert .rhivo-modal__icon {
  color: var(--rhivo-info, #3b82f6);
}

.rhivo-modal--alert .rhivo-modal__footer {
  justify-content: center;
}

.rhivo-modal--alert .rhivo-modal__content {
  max-width: 400px;
}

.rhivo-modal--alert .rhivo-modal__message {
  font-size: 0.9375rem;
}

/* Prontuario View Modal — variante para exibição de conteúdo */
.rhivo-modal--view .rhivo-modal__content {
  max-width: 640px;
}

.rhivo-modal--view .rhivo-modal__body--view {
  text-align: left;
  align-items: stretch;
  max-height: 60vh;
  overflow-y: auto;
  padding: 20px 24px;
}

.rhivo-modal--view .rhivo-modal__footer {
  padding: 12px 24px;
}

/* Conteudo renderizado por marked no modal de visualizacao */
.prontuario-view__rendered {
  font-size: 14px;
  line-height: 1.7;
  color: var(--rhivo-text, #4a5568);
  word-wrap: break-word;
}

[data-bs-theme="dark"] .prontuario-view__rendered {
  color: var(--rhivo-text-dark, #cbd5e0);
}

.prontuario-view__rendered h1,
.prontuario-view__rendered h2,
.prontuario-view__rendered h3 {
  margin: 16px 0 8px;
  font-weight: 600;
  color: var(--rhivo-text, #1a202c);
}

[data-bs-theme="dark"] .prontuario-view__rendered h1,
[data-bs-theme="dark"] .prontuario-view__rendered h2,
[data-bs-theme="dark"] .prontuario-view__rendered h3 {
  color: var(--rhivo-text-dark, #e2e8f0);
}

.prontuario-view__rendered h1 { font-size: 17px; }
.prontuario-view__rendered h2 { font-size: 15px; }
.prontuario-view__rendered h3 { font-size: 14px; }

.prontuario-view__rendered p { margin: 0 0 8px; }

.prontuario-view__rendered ul,
.prontuario-view__rendered ol {
  padding-left: 20px;
  margin: 6px 0;
}

.prontuario-view__rendered li { margin-bottom: 2px; }

.prontuario-view__rendered code {
  background: rgba(0,0,0,0.05);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 13px;
  color: var(--rhivo-text, #1a202c);
}

[data-bs-theme="dark"] .prontuario-view__rendered code {
  background: rgba(255,255,255,0.08);
  color: var(--rhivo-text-dark, #e2e8f0);
}

.prontuario-view__rendered pre {
  background: rgba(0,0,0,0.03);
  padding: 12px;
  border-radius: 4px;
  overflow-x: auto;
  margin: 8px 0;
}

[data-bs-theme="dark"] .prontuario-view__rendered pre {
  background: rgba(255,255,255,0.04);
}

.prontuario-view__rendered pre code {
  background: none;
  padding: 0;
}

.prontuario-view__rendered table {
  border-collapse: collapse;
  width: 100%;
  margin: 8px 0;
  font-size: 13px;
}

.prontuario-view__rendered td {
  border: 1px solid var(--rhivo-border, #e2e8f0);
  padding: 4px 8px;
}

[data-bs-theme="dark"] .prontuario-view__rendered td {
  border-color: var(--rhivo-border-dark, #2d3748);
}

.prontuario-view__rendered hr {
  border: none;
  border-top: 1px solid var(--rhivo-border, #e2e8f0);
  margin: 12px 0;
}

.prontuario-view__rendered a {
  color: var(--rhivo-primary, #4299e1);
}

.prontuario-view__rendered img {
  max-width: 100%;
  border-radius: 6px;
  margin: 8px 0;
}

/* ═══════════════════════════════════════════════════════════
   15. BADGE ACTIVE — .badge-rhivo-active / .badge-rhivo-role
   ═══════════════════════════════════════════════════════════ */

.badge-rhivo-active {
  display: inline-flex;
  align-items: center;
  gap: var(--rhivo-space-xs, 4px);
  padding: 2px 10px;
  font-size: var(--rhivo-text-small, 0.75rem);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-radius: 999px;
  background: rgba(6, 180, 135, 0.12);
  color: #06b487;
  white-space: nowrap;
}

[data-bs-theme="dark"] .badge-rhivo-active {
  background: rgba(6, 180, 135, 0.2);
  color: #4ade80;
}

.badge-rhivo-role {
  display: inline-flex;
  align-items: center;
  gap: var(--rhivo-space-xs, 4px);
  padding: 2px 10px;
  font-size: var(--rhivo-text-small, 0.75rem);
  font-weight: 600;
  letter-spacing: 0.02em;
  border-radius: 999px;
  background: rgba(0, 120, 198, 0.1);
  color: var(--rhivo-blue, #0078c6);
  white-space: nowrap;
}

[data-bs-theme="dark"] .badge-rhivo-role {
  background: rgba(0, 120, 198, 0.2);
  color: #60a5fa;
}

/* ═══════════════════════════════════════════════════════════
   12. SIDEBAR — Layout flat com seções
   ═══════════════════════════════════════════════════════════ */

/* Container principal da sidebar */
.rhivo-sidebar {
  padding: 0.5rem 0;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.15) transparent;
}

.rhivo-sidebar::-webkit-scrollbar {
  width: 4px;
}

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

.rhivo-sidebar::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.15);
  border-radius: 2px;
}

/* Lista principal */
.rhivo-sidebar__list {
  list-style: none;
  margin: 0;
  padding: 0;
}

/* ─── Header de seção (ex: "NEGÓCIO", "CLÍNICA") ─────── */
.rhivo-sidebar__section {
  padding: 1rem 0.875rem 0.25rem;
  list-style: none;
}

.rhivo-sidebar__section span {
  display: block;
  font-size: 0.625rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: rgba(255, 255, 255, 0.3);
  white-space: nowrap;
  line-height: 1;
}

/* ─── Divisor visual entre seções ───────────────────────── */
.rhivo-sidebar__divider {
  list-style: none;
  padding: 0.5rem 0.875rem;
}

.rhivo-sidebar__hr {
  margin: 0;
  border: 0;
  height: 2px;
  background: linear-gradient(90deg, rgba(255,255,255,0.3) 0%, rgba(255,255,255,0.06) 80%);
  border-radius: 2px;
}

/* ─── Item do menu (flat, sem dropdown) ─────────────────── */
.rhivo-sidebar__item {
  list-style: none;
  margin: 1px 0.375rem;
  position: relative;
}

.rhivo-sidebar__item a {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4375rem 0.75rem;
  border-radius: 6px;
  color: rgba(255, 255, 255, 0.6);
  text-decoration: none;
  font-size: 0.8125rem;
  font-weight: 400;
  line-height: 1.4;
  transition: all 0.15s ease-in-out;
  white-space: nowrap;
}

.rhivo-sidebar__item a:hover {
  color: rgba(255, 255, 255, 0.9);
  background: rgba(255, 255, 255, 0.06);
}

/* Ícone do item */
.rhivo-sidebar__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: 0.6;
}

.rhivo-sidebar__icon svg {
  width: 16px;
  height: 16px;
}

.rhivo-sidebar__item a:hover .rhivo-sidebar__icon {
  opacity: 0.85;
}

/* Label do item */
.rhivo-sidebar__label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ─── Item ativo ─────────────────────────────────────────── */
.rhivo-sidebar__item--active a {
  color: #ffffff;
  background: rgba(0, 154, 194, 0.15);
  font-weight: 500;
}

.rhivo-sidebar__item--active a::before {
  content: '';
  position: absolute;
  left: 0;
  top: 4px;
  bottom: 4px;
  width: 3px;
  border-radius: 0 2px 2px 0;
  background: #4dd8e8;
}

.rhivo-sidebar__item--active .rhivo-sidebar__icon {
  opacity: 1;
}

[data-bs-theme="dark"] .rhivo-sidebar__item--active a::before {
  background: #70b0ff;
}

/* Fundo escuro fixo da sidebar (navy) */
.navbar-vertical[data-bs-theme="dark"] {
  background-color: #010A29;
}

/* Legado: manter compatibilidade com classes antigas do Tabler */
.navbar-vertical .nav-item-label {
  display: list-item;
  padding: 1rem var(--rhivo-space-md, 12px) 0.25rem;
  font-size: 0.625rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(255, 255, 255, 0.3);
  list-style: none;
  white-space: nowrap;
}

/* ═══════════════════════════════════════════════════════════
   16. AVATAR — .rhivo-avatar
   ═══════════════════════════════════════════════════════════ */

.rhivo-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 999px;
  background: var(--rhivo-blue, #0078c6);
  color: #fff;
  font-size: 0.875rem;
  font-weight: 700;
  line-height: 1;
  user-select: none;
  flex-shrink: 0;
}

.rhivo-avatar--lg {
  width: 64px;
  height: 64px;
  font-size: 1.25rem;
}

[data-bs-theme="dark"] .rhivo-avatar {
  background: var(--rhivo-blue-dark, #1a6bb0);
}

/* ═══════════════════════════════════════════════════════════
   17. CRUD BLUEPRINT — .rhivo-crud
   ═══════════════════════════════════════════════════════════ */

.rhivo-crud {
  padding: var(--rhivo-space-lg, 24px);
  display: flex;
  flex-direction: column;
  gap: var(--rhivo-space-md, 16px);
}

.rhivo-crud__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--rhivo-space-sm, 8px);
}

.rhivo-crud__header-left {
  display: flex;
  align-items: center;
  gap: var(--rhivo-space-sm, 8px);
}

.rhivo-crud__header-right {
  display: flex;
  align-items: center;
  gap: var(--rhivo-space-sm, 8px);
}

.rhivo-crud__title {
  margin: 0;
  font-size: var(--rhivo-text-h2, 1.25rem);
  font-weight: 600;
  color: var(--rhivo-text-primary);
}

.rhivo-crud__filters {
  display: flex;
  gap: var(--rhivo-space-sm, 8px);
  align-items: center;
  flex-wrap: wrap;
}

.rhivo-crud__search {
  flex: 1;
  min-width: 200px;
  max-width: 360px;
}

.rhivo-crud__search .input-rhivo {
  width: 100%;
}

.rhivo-crud__filter-group {
  display: flex;
  gap: var(--rhivo-space-sm, 8px);
  align-items: center;
}

.rhivo-crud__filter-group .input-rhivo {
  min-width: 140px;
}

.rhivo-crud__table-wrapper {
  overflow-x: auto;
  border: 1.5px solid var(--rhivo-border, rgba(0,0,0,0.08));
  border-radius: var(--rhivo-radius-lg, 12px);
  background: var(--rhivo-surface);
}

.rhivo-crud__table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--rhivo-text-body, 0.875rem);
}

.rhivo-crud__table th {
  text-align: left;
  padding: 0.75rem 1rem;
  font-size: var(--rhivo-text-small, 0.75rem);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--rhivo-text-secondary);
  background: var(--rhivo-bg-secondary, rgba(0,0,0,0.02));
  border-bottom: 2px solid var(--rhivo-border, rgba(0,0,0,0.08));
  white-space: nowrap;
}

.rhivo-crud__table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--rhivo-border, rgba(0,0,0,0.06));
  color: var(--rhivo-text-primary);
  vertical-align: middle;
}

.rhivo-crud__table tbody tr:last-child td {
  border-bottom: none;
}

.rhivo-crud__table tbody tr:hover {
  background: var(--rhivo-bg-hover, rgba(0,0,0,0.02));
}

.rhivo-crud__th-actions {
  text-align: right;
  width: 140px;
}

.rhivo-crud__cell-name {
  font-weight: 500;
}

.rhivo-crud__cell-date {
  white-space: nowrap;
  color: var(--rhivo-text-secondary);
  font-size: var(--rhivo-text-small, 0.75rem);
}

.rhivo-crud__cell-actions {
  text-align: right !important;
  white-space: nowrap;
  vertical-align: middle !important;
  height: 100% !important;
  line-height: 0 !important;
}

.rhivo-crud__cell-actions .rhivo-actions {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 100%;
  vertical-align: middle;
}

.rhivo-crud__cell-actions .btn-action {
  vertical-align: middle;
  line-height: 1;
}

.rhivo-crud__cell-actions .btn-action + .btn-action {
  margin-left: 4px;
}

/* ─── Botão "Mostrar Excluídos" ─────────────────────────── */

.rhivo-crud__filters-right {
  display: flex;
  align-items: center;
  gap: var(--rhivo-space-sm, 8px);
  margin-left: auto;
}

/* Rodapé compacto (telas full-height — ex: inbox de mensagens) */
.rhivo-footer--compact {
  padding: 6px 0;
  font-size: 0.75rem;
}

/* ═══════════════════════════════════════════════════════
   TOP NAVBAR — Estilo SaaS profissional
   ═══════════════════════════════════════════════════════ */

.top-navbar {
  position: sticky;
  top: 0;
  z-index: 1050;
  border-bottom: none !important;
  background: rgba(255, 255, 255, 0.85) !important;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 0.5rem 1.5rem;
  height: 64px;
  transition: background 0.3s ease;
}

[data-bs-theme="dark"] .top-navbar {
  background: rgba(15, 23, 42, 0.85) !important;
}

.top-navbar .container-fluid {
  width: 100%;
}

/* Brand / Logo */
.top-navbar__brand {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  transition: opacity 0.2s ease;
}

.top-navbar__brand:hover {
  opacity: 0.8;
}

.top-navbar__title {
  font-weight: 600;
  font-size: 1rem;
  color: var(--tblr-body-color, #1a1a2e);
}

[data-bs-theme="dark"] .top-navbar__title {
  color: #e2e8f0;
}

/* Nome da empresa ativa */
.top-navbar__company {
  font-weight: 500;
  font-size: 0.875rem;
  color: var(--tblr-text-muted, #8b949e);
  white-space: nowrap;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.top-navbar__company--dropdown {
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.5rem;
  border-radius: 6px;
  transition: background 0.15s ease;
}

.top-navbar__company--dropdown:hover {
  background: rgba(0, 0, 0, 0.05);
}

[data-bs-theme="dark"] .top-navbar__company--dropdown:hover {
  background: rgba(255, 255, 255, 0.08);
}

[data-bs-theme="dark"] .top-navbar__company {
  color: #94a3b8;
}

/* Ícones de ação (idioma, tema, notificações) */
.top-navbar__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: none !important;
  background: transparent !important;
  color: var(--tblr-text-muted, #8b949e);
  transition: all 0.2s ease;
  padding: 0 !important;
  box-shadow: none !important;
}

.top-navbar__icon:hover {
  background: rgba(0, 120, 198, 0.08) !important;
  color: var(--rhivo-blue, #0078C6) !important;
}

.top-navbar__icon:focus,
.top-navbar__icon:focus-visible {
  outline: 2px solid var(--rhivo-blue, #0078C6);
  outline-offset: 2px;
}

/* Dropdown de idioma */
.top-navbar .dropdown-menu {
  border: none !important;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  border-radius: 12px;
  padding: 0.5rem;
  margin-top: 0.5rem;
  z-index: 1150;
}

/* Corrigir dropdown sendo cortado pelo overflow do Tabler */
.page-wrapper {
  overflow: visible !important;
}

.page-body {
  overflow: visible !important;
}

.top-navbar .dropdown-menu.show {
  z-index: 1150;
}

.top-navbar .dropdown.show .dropdown-menu {
  z-index: 1150;
}

/* ═══════════════════════════════════════════════════════════
   16. PERMISSION CHIPS — selector tipo tags (grupos)
   ═══════════════════════════════════════════════════════════ */

.perm-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  font-size: var(--rhivo-text-body, 0.875rem);
  font-weight: 500;
  line-height: 1.4;
  border-radius: 999px;
  border: 1.5px solid;
  cursor: pointer;
  transition: all 0.15s ease-in-out;
  user-select: none;
  white-space: nowrap;
  background: transparent;
  font-family: inherit;
}

.perm-chip--off {
  border-color: var(--rhivo-border, #dde0e5);
  color: var(--rhivo-text, #4a4f62);
  background: transparent;
}

.perm-chip--off:hover {
  border-color: var(--rhivo-blue, #0078C6);
  color: var(--rhivo-blue, #0078C6);
  background: rgba(0, 120, 198, 0.04);
}

.perm-chip--on {
  border-color: var(--rhivo-blue, #0078C6);
  color: #ffffff;
  background: var(--rhivo-blue, #0078C6);
}

.perm-chip--on:hover {
  border-color: #0062a3;
  background: #0062a3;
}

.perm-chip--disabled {
  border-color: var(--rhivo-border, #dde0e5);
  color: var(--rhivo-slate, #9B9DA8);
  background: rgba(155, 157, 168, 0.06);
  cursor: not-allowed;
  opacity: 0.65;
}

.perm-chip--disabled:hover {
  border-color: var(--rhivo-border, #dde0e5);
  color: var(--rhivo-slate, #9B9DA8);
  background: rgba(155, 157, 168, 0.06);
}

.perm-chip__icon {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.perm-chip--off .perm-chip__icon {
  color: var(--rhivo-slate, #9B9DA8);
}

.perm-chip--on .perm-chip__icon {
  color: #ffffff;
}

.perm-chip--disabled .perm-chip__icon {
  color: var(--rhivo-slate, #9B9DA8);
}

/* Dark mode */
[data-bs-theme="dark"] .perm-chip--off {
  border-color: #2a3045;
  color: #c4c9d6;
}

[data-bs-theme="dark"] .perm-chip--off:hover {
  border-color: #0078C6;
  color: #4da3e0;
  background: rgba(0, 120, 198, 0.08);
}

[data-bs-theme="dark"] .perm-chip--disabled {
  border-color: #1a2035;
  color: #5a5f75;
  background: rgba(26, 32, 53, 0.5);
  opacity: 0.6;
}

[data-bs-theme="dark"] .perm-chip--disabled:hover {
  border-color: #1a2035;
  color: #5a5f75;
  background: rgba(26, 32, 53, 0.5);
}

.top-navbar .dropdown-item {
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  transition: all 0.15s ease;
}

.top-navbar .dropdown-item:hover {
  background: rgba(0, 120, 198, 0.08);
}

.top-navbar .dropdown-item.active {
  background: var(--rhivo-blue, #0078C6) !important;
  color: #ffffff !important;
}

/* Menu do usuário */
.top-navbar__user {
  display: inline-flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.375rem 0.625rem;
  border-radius: 10px;
  border: none !important;
  background: transparent !important;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
  box-shadow: none !important;
}

.top-navbar__user:hover {
  background: rgba(0, 120, 198, 0.08) !important;
}

.top-navbar__user:focus,
.top-navbar__user:focus-visible {
  outline: 2px solid var(--rhivo-blue, #0078C6);
  outline-offset: 2px;
}

.top-navbar__avatar {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  object-fit: cover;
  background: var(--rhivo-teal, #009AC2);
  color: #ffffff;
  font-weight: 600;
  font-size: 0.875rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.top-navbar__avatar--initials {
  background: linear-gradient(135deg, var(--rhivo-teal, #009AC2), var(--rhivo-blue, #0078C6));
}

.top-navbar__user-info {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.3;
}

.top-navbar__user-name {
  font-weight: 500;
  font-size: 0.875rem;
  color: var(--tblr-body-color, #1a1a2e);
}

[data-bs-theme="dark"] .top-navbar__user-name {
  color: #e2e8f0;
}

.top-navbar__user-role {
  font-size: 0.7rem !important;
  color: var(--tblr-text-muted, #8b949e);
}

.top-navbar__chevron {
  color: var(--tblr-text-muted, #8b949e);
  transition: transform 0.2s ease;
}

.top-navbar__user[aria-expanded="true"] .top-navbar__chevron {
  transform: rotate(180deg);
}

/* Dropdown do menu do usuário — dark mode */
.top-navbar .dropdown-menu-end {
  background: #ffffff;
  border: 1px solid var(--rhivo-border, rgba(0,0,0,0.08));
}

[data-bs-theme="dark"] .top-navbar .dropdown-menu-end {
  background: #1e293b;
  border-color: rgba(255,255,255,0.1);
}

.top-navbar .dropdown-menu-end .dropdown-item {
  color: var(--tblr-body-color, #1a1a2e);
}

.top-navbar .dropdown-menu-end .dropdown-item:hover {
  background: rgba(0, 120, 198, 0.08);
}

[data-bs-theme="dark"] .top-navbar .dropdown-menu-end .dropdown-item {
  color: #e2e8f0;
}

[data-bs-theme="dark"] .top-navbar .dropdown-menu-end .dropdown-item:hover {
  background: rgba(0, 120, 198, 0.2);
}

/* Responsivo */
@media (max-width: 767.98px) {
  .top-navbar {
    padding: 0.5rem 1rem;
  }

  .top-navbar__user-info {
    display: none;
  }

  .top-navbar__avatar {
    width: 28px;
    height: 28px;
    font-size: 0.75rem;
  }
}

/* Paginação */
.rhivo-crud__pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--rhivo-space-sm, 8px);
}

.rhivo-crud__pagination-info {
  font-size: var(--rhivo-text-small, 0.75rem);
  color: var(--rhivo-text-secondary);
}

.rhivo-crud__pagination-controls {
  display: flex;
  align-items: center;
  gap: 2px;
}

.rhivo-crud__page-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  padding: 0 6px;
  border: 1.5px solid transparent;
  border-radius: var(--rhivo-radius-sm, 6px);
  background: transparent;
  color: var(--rhivo-text-secondary);
  font-size: var(--rhivo-text-small, 0.75rem);
  font-weight: 500;
  cursor: pointer;
  transition: all var(--rhivo-transition-fast, 0.15s);
}

.rhivo-crud__page-btn:hover {
  background: var(--rhivo-bg-hover, rgba(0,0,0,0.05));
  color: var(--rhivo-text-primary);
}

.rhivo-crud__page-current {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  padding: 0 6px;
  border-radius: var(--rhivo-radius-sm, 6px);
  background: var(--rhivo-blue, #0078c6);
  color: #fff;
  font-size: var(--rhivo-text-small, 0.75rem);
  font-weight: 600;
}

/* ═══════════════════════════════════════════════════════════
   18. FORM PAGE — .rhivo-form-page
   ═══════════════════════════════════════════════════════════ */

.rhivo-form-page {
  padding: var(--rhivo-space-lg, 24px);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.rhivo-form-page__card {
  width: 100%;
  max-width: 520px;
}

.rhivo-form-page__header {
  display: flex;
  flex-direction: column;
  gap: var(--rhivo-space-md, 16px);
  margin-bottom: var(--rhivo-space-lg, 24px);
}

.rhivo-form-page__title {
  margin: 0;
  font-size: var(--rhivo-text-h2, 1.25rem);
  font-weight: 600;
  color: var(--rhivo-text-primary);
}

.rhivo-form {
  display: flex;
  flex-direction: column;
  gap: var(--rhivo-space-md, 16px);
}

.rhivo-form__group {
  display: flex;
  flex-direction: column;
  gap: var(--rhivo-space-xs, 4px);
}

.rhivo-form__label {
  font-size: var(--rhivo-text-body, 0.875rem);
  font-weight: 500;
  color: var(--rhivo-text-primary);
}

.rhivo-form__required {
  color: var(--rhivo-danger, #e74c3c);
}

.rhivo-form__input-wrapper {
  position: relative;
}

.rhivo-form__input-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--rhivo-text-secondary);
  pointer-events: none;
}

.rhivo-form__input-wrapper .input-rhivo--icon {
  padding-left: 38px;
}

.rhivo-form__error {
  font-size: var(--rhivo-text-small, 0.75rem);
  color: var(--rhivo-danger, #e74c3c);
  min-height: 0;
}

.rhivo-form__actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--rhivo-space-sm, 8px);
  margin-top: var(--rhivo-space-md, 16px);
  padding-top: var(--rhivo-space-md, 16px);
  border-top: 1.5px solid var(--rhivo-border, rgba(0,0,0,0.08));
}

/* Card largo para formulários com muitos campos (ex: planos) */
.rhivo-form-page__card--wide {
  max-width: 920px;
}

/* Linha horizontal de campos — CSS Grid responsivo */
.rhivo-form__row {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: var(--rhivo-space-md, 16px);
  margin-bottom: var(--rhivo-space-md, 16px);
}

.rhivo-form__group--half {
  grid-column: span 6;
}

.rhivo-form__group--third {
  grid-column: span 4;
}

.rhivo-form__group--full {
  grid-column: 1 / -1;
}

.rhivo-form__group--quarter {
  grid-column: span 3;
}

@media (max-width: 991px) {
  .rhivo-form__group--half,
  .rhivo-form__group--third,
  .rhivo-form__group--quarter {
    grid-column: span 6;
  }
}

@media (max-width: 575px) {
  .rhivo-form__group--half,
  .rhivo-form__group--third,
  .rhivo-form__group--quarter {
    grid-column: span 12;
  }
}

/* Input group com addon (ex: R$) */
.rhivo-form__input-group {
  display: flex;
  align-items: stretch;
}

.rhivo-form__input-addon {
  display: flex;
  align-items: center;
  padding: 0 12px;
  background: var(--rhivo-bg-hover, rgba(0,0,0,0.05));
  border: 1.5px solid var(--rhivo-border, rgba(0,0,0,0.08));
  border-right: 0;
  border-radius: var(--rhivo-radius-sm, 6px) 0 0 var(--rhivo-radius-sm, 6px);
  font-size: var(--rhivo-text-body, 0.875rem);
  color: var(--rhivo-text-secondary);
  font-weight: 500;
}

/* Addon à direita (sufixo ex: "dias") */
.rhivo-form__input-addon--right {
  border-right: 1.5px solid var(--rhivo-border, rgba(0,0,0,0.08));
  border-left: 0;
  border-radius: 0 var(--rhivo-radius-sm, 6px) var(--rhivo-radius-sm, 6px) 0;
}

.rhivo-form__input-group .input-rhivo {
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
}

/* Input à esquerda em grupo (addon à direita) */
.rhivo-form__input-group .input-rhivo--left {
  border-top-left-radius: var(--rhivo-radius-sm, 6px);
  border-bottom-left-radius: var(--rhivo-radius-sm, 6px);
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}

[data-bs-theme="dark"] .rhivo-form__input-addon {
  background: var(--rhivo-bg-subtle);
  border-color: var(--rhivo-border);
}

/* Título de seção dentro do formulário */
.rhivo-form__section {
  margin-bottom: 1.5rem;
}

.rhivo-form__section .rhivo-form__row {
  margin-bottom: var(--rhivo-space-md, 16px);
}

.rhivo-form__section-title {
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--rhivo-primary, #0078C6);
  margin-bottom: 1rem;
  padding-bottom: 6px;
  border-bottom: 1.5px solid var(--rhivo-border);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

/* Divisor horizontal */
.rhivo-form__divider {
  border: 0;
  border-top: 1.5px solid var(--rhivo-border, rgba(0,0,0,0.08));
  margin: var(--rhivo-space-sm, 8px) 0;
}

/* Checkbox estilizado */
.rhivo-form__checkbox {
  display: flex;
  align-items: center;
  gap: var(--rhivo-space-sm, 8px);
  cursor: pointer;
  font-size: var(--rhivo-text-body, 0.875rem);
  color: var(--rhivo-text-primary);
  padding: 4px 0;
}

.rhivo-form__checkbox input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--rhivo-blue, #0078c6);
}

/* ═══════════════════════════════════════════════════════════
   19. DETAIL PAGE — .rhivo-detail-page
   ═══════════════════════════════════════════════════════════ */

.rhivo-detail-page {
  padding: var(--rhivo-space-lg, 24px);
  display: flex;
  flex-direction: column;
  gap: var(--rhivo-space-md, 16px);
  max-width: 1200px;
  width: 100%;
}

.rhivo-detail-page__grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--rhivo-space-md, 16px);
  align-items: stretch;
}

.rhivo-detail-page__grid > .card {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.rhivo-detail-page__grid > .card > .card-body {
  flex: 1 1 auto;
  min-height: 0;
}

@media (max-width: 768px) {
  .rhivo-detail-page__grid {
    grid-template-columns: 1fr;
  }
}

.rhivo-detail-page__full {
  grid-column: 1 / -1;
}

.rhivo-detail-page__card {
  background: var(--rhivo-surface);
  border: 1.5px solid var(--rhivo-border, rgba(0,0,0,0.08));
  border-radius: var(--rhivo-radius-lg, 12px);
  overflow: hidden;
}

.rhivo-detail-page__header {
  padding: var(--rhivo-space-md, 16px) var(--rhivo-space-lg, 24px);
  border-bottom: 1.5px solid var(--rhivo-border, rgba(0,0,0,0.08));
  display: flex;
  align-items: center;
}

.rhivo-detail-page__actions {
  display: flex;
  gap: var(--rhivo-space-sm, 8px);
  padding: 0 var(--rhivo-space-lg, 24px);
  padding-bottom: var(--rhivo-space-lg, 24px);
}

.rhivo-detail-card {
  padding: var(--rhivo-space-lg, 24px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--rhivo-space-md, 16px);
  text-align: center;
}

.rhivo-detail-card__avatar {
  display: flex;
  justify-content: center;
}

.rhivo-detail-card__info {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--rhivo-space-xs, 4px);
}

.rhivo-detail-card__name {
  margin: 0;
  font-size: var(--rhivo-text-h2, 1.25rem);
  font-weight: 600;
  color: var(--rhivo-text-primary);
}

.rhivo-detail-card__email {
  margin: 0;
  font-size: var(--rhivo-text-body, 0.875rem);
}

.rhivo-detail-card__email a {
  color: var(--rhivo-blue, #0078c6);
  text-decoration: none;
}

.rhivo-detail-card__email a:hover {
  text-decoration: underline;
}

.rhivo-detail-card__role {
  display: flex;
  gap: var(--rhivo-space-sm, 8px);
  align-items: center;
  margin: var(--rhivo-space-sm, 8px) 0 0;
}

.rhivo-detail-card__meta {
  display: flex;
  gap: var(--rhivo-space-lg, 24px);
  padding: var(--rhivo-space-md, 16px) var(--rhivo-space-lg, 24px);
  border-top: 1.5px solid var(--rhivo-border, rgba(0,0,0,0.08));
  width: 100%;
  justify-content: center;
}

.rhivo-detail-card__meta-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.rhivo-detail-card__meta-label {
  font-size: var(--rhivo-text-small, 0.75rem);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--rhivo-text-secondary);
}

.rhivo-detail-card__meta-value {
  font-size: var(--rhivo-text-body, 0.875rem);
  color: var(--rhivo-text-primary);
  font-weight: 500;
}

/* ═══════════════════════════════════════════════════════════
   DETAIL GRID — Grid de informações em cards de detalhes
   ═══════════════════════════════════════════════════════════ */

.rhivo-detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: var(--rhivo-space-md, 16px);
}

.rhivo-detail-grid__item {
  font-size: var(--rhivo-text-body, 0.875rem);
  color: var(--rhivo-text-primary);
}

.rhivo-detail-grid__item strong {
  display: block;
  font-size: var(--rhivo-text-small, 0.75rem);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--rhivo-text-secondary, #9B9DA8);
  margin-bottom: 2px;
}

/* Espaçamento automático entre cards consecutivos (não dentro de grid) */
.rhivo-card + .rhivo-card {
  margin-top: var(--rhivo-space-md, 16px);
}

.rhivo-detail-page__grid > .rhivo-card + .rhivo-card {
  margin-top: 0;
}

/* ═══════════════════════════════════════════════════════════
   FLAGS (Tabler) — Navbar e Dropdown
   ═══════════════════════════════════════════════════════════ */

.top-navbar__icon .flag {
  display: inline-block;
  width: 20px;
  height: 15px;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  vertical-align: middle;
  border-radius: 2px;
  box-shadow: 0 0 0 1px var(--rhivo-border, rgba(0,0,0,0.08));
}

.dropdown-menu .flag {
  display: inline-block;
  width: 18px;
  height: 13px;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  vertical-align: middle;
  border-radius: 2px;
  box-shadow: 0 0 0 1px var(--rhivo-border, rgba(0,0,0,0.08));
}

[data-bs-theme="dark"] .top-navbar__icon .flag {
  box-shadow: 0 0 0 1px rgba(255,255,255,0.15);
}

[data-bs-theme="dark"] .dropdown-menu .flag {
  box-shadow: 0 0 0 1px rgba(255,255,255,0.15);
}

/* ═══════════════════════════════════════════════════════════
   20. WIZARD PAGE + STEPS — .rhivo-wizard-*
   ═══════════════════════════════════════════════════════════ */

.rhivo-wizard-page {
  padding: var(--rhivo-space-lg, 24px);
  display: flex;
  flex-direction: column;
  gap: var(--rhivo-space-md, 16px);
}

.rhivo-wizard-page .row {
  margin-left: 0;
  margin-right: 0;
}

.rhivo-wizard-page .row > [class*="col-"] {
  padding-left: 12px;
  padding-right: 12px;
}

/* ═══════════════════════════════════════════════════════════
   21. WIZARD STEPS — .rhivo-wizard-step-*
   ═══════════════════════════════════════════════════════════ */

.rhivo-wizard-steps {
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: flex-start;
  gap: 0;
  margin-bottom: 2rem;
  padding: 1.5rem 1rem 1rem;
  background: var(--rhivo-surface);
  border-bottom: 1.5px solid var(--rhivo-border, rgba(0,0,0,0.08));
}

.rhivo-wizard-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  position: relative;
  flex: 1;
  max-width: 160px;
  transition: opacity 0.2s;
}

.rhivo-wizard-step:hover {
  opacity: 0.8;
}

.rhivo-wizard-step::after {
  content: '';
  position: absolute;
  top: 20px;
  left: calc(50% + 24px);
  width: calc(100% - 48px);
  height: 2px;
  background: var(--rhivo-border, rgba(0,0,0,0.12));
  z-index: 0;
}

.rhivo-wizard-step:last-child::after {
  display: none;
}

.rhivo-wizard-step.completed::after {
  background: var(--rhivo-blue, #0078c6);
}

.rhivo-wizard-step__circle {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.875rem;
  font-weight: 600;
  border: 2px solid var(--rhivo-border, rgba(0,0,0,0.12));
  background: var(--rhivo-surface);
  color: var(--rhivo-text-secondary);
  position: relative;
  z-index: 1;
  transition: all 0.25s ease;
}

.rhivo-wizard-step.active .rhivo-wizard-step__circle {
  border-color: var(--rhivo-blue, #0078c6);
  background: var(--rhivo-blue, #0078c6);
  color: #fff;
  box-shadow: 0 0 0 4px rgba(0,120,198,0.15);
}

.rhivo-wizard-step.completed .rhivo-wizard-step__circle {
  border-color: var(--rhivo-blue, #0078c6);
  background: var(--rhivo-blue, #0078c6);
  color: #fff;
}

.rhivo-wizard-step__label {
  font-size: 0.75rem;
  color: var(--rhivo-text-secondary);
  margin-top: 6px;
  text-align: center;
  line-height: 1.3;
  font-weight: 500;
}

.rhivo-wizard-step.active .rhivo-wizard-step__label {
  color: var(--rhivo-blue, #0078c6);
  font-weight: 600;
}

.rhivo-wizard-step.completed .rhivo-wizard-step__label {
  color: var(--rhivo-text-primary);
}

/* ═══════════════════════════════════════════════════════════
   21. AUTOCOMPLETE — .rhivo-autocomplete-*
   ═══════════════════════════════════════════════════════════ */

.rhivo-autocomplete {
  position: relative;
}

.rhivo-autocomplete__popup {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  max-height: 220px;
  overflow-y: auto;
  background: var(--rhivo-surface);
  border: 1.5px solid var(--rhivo-border, rgba(0,0,0,0.12));
  border-radius: var(--rhivo-radius-md, 8px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.1);
  z-index: 1050;
  display: none;
}

.rhivo-autocomplete__popup.show {
  display: block;
}

.rhivo-autocomplete__item {
  display: flex;
  align-items: center;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 0.875rem;
  color: var(--rhivo-text-primary);
  transition: background 0.15s;
  gap: 8px;
}

.rhivo-autocomplete__item:hover {
  background: var(--rhivo-bg-hover, rgba(0,0,0,0.04));
}

.rhivo-autocomplete__item.active {
  background: var(--rhivo-bg-hover, rgba(0,0,0,0.06));
}

.rhivo-autocomplete__item-icon {
  display: flex;
  align-items: center;
  color: var(--rhivo-text-secondary);
}

.rhivo-autocomplete__empty {
  padding: 12px;
  text-align: center;
  color: var(--rhivo-text-secondary);
  font-size: 0.8rem;
}

/* ═══════════════════════════════════════════════════════════
   22. SIDEBAR CARDS — .rhivo-sidebar-*
   ═══════════════════════════════════════════════════════════ */

.rhivo-sidebar-card__item {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 8px;
  font-size: 0.8rem;
}

.rhivo-sidebar-card__item:last-child {
  margin-bottom: 0;
}

.rhivo-sidebar-card__label {
  color: var(--rhivo-text-secondary);
  font-weight: 500;
}

.rhivo-sidebar-card__value {
  color: var(--rhivo-text-primary);
  font-weight: 600;
  text-align: right;
}

.rhivo-sidebar-card__plano {
  text-align: center;
  margin-bottom: 12px;
}

.rhivo-sidebar-card__plano .badge {
  font-size: 0.85rem;
  padding: 6px 16px;
}

.rhivo-sidebar-card__divider {
  height: 1px;
  background: var(--rhivo-border, rgba(0,0,0,0.08));
  margin: 10px 0;
}

/* ═══════════════════════════════════════════════════════════
   CARD CLICKABLE — Seleção de Planos
   ═══════════════════════════════════════════════════════════ */

.card-clickable {
  cursor: pointer;
  transition: border-color var(--rhivo-transition-fast, 0.15s);
}

.card-clickable.is-invalid {
  border-color: var(--rhivo-danger, #d63939) !important;
  box-shadow: 0 0 0 2px rgba(214, 57, 57, 0.15);
  animation: rhivo-shake 0.3s ease-in-out;
}

/* Cards de modo de criação (senha provisória / convite) */
.creation-cards-row [class*="col-"] > .creation-card {
  height: 100%;
}

.creation-card {
  border-width: 2px;
  border-color: var(--rhivo-border, #dee2e6);
  background-color: var(--rhivo-bg, #fff);
  transition: border-color var(--rhivo-transition-fast, 0.15s),
              box-shadow var(--rhivo-transition-fast, 0.15s);
}

.creation-card:hover {
  border-color: var(--rhivo-primary, #0d6efd);
  box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.1);
}

.creation-card.border-primary {
  border-color: var(--rhivo-primary, #0d6efd) !important;
  box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.15);
  background-color: rgba(13, 110, 253, 0.04);
}

.creation-card__icon {
  color: var(--rhivo-muted, #6c757d);
  transition: color var(--rhivo-transition-fast, 0.15s);
}

.creation-card.border-primary .creation-card__icon {
  color: var(--rhivo-primary, #0d6efd);
}

.creation-card__title {
  font-size: 0.875rem;
  color: var(--rhivo-text, #212529);
}

.creation-card__description {
  font-size: 0.75rem;
  line-height: 1.4;
}

@keyframes rhivo-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

/* ═══════════════════════════════════════════════════════════
   NOTAS INTERNAS — Histórico de notas
   ═══════════════════════════════════════════════════════════ */

.rhivo-notas-list {
  max-height: 200px;
  overflow-y: auto;
}

.rhivo-notas-item {
  font-size: 0.8125rem;
  color: var(--tblr-secondary, #667382);
  padding: 2px 0;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}

.rhivo-notas-item + .rhivo-notas-item {
  border-top: 1px dashed var(--tblr-border-color, #e6e7e9);
  padding-top: 6px;
  margin-top: 4px;
}

/* ═══════════════════════════════════════════════════════════
   19. PLAN BADGE — indicador de plano atual
   ═══════════════════════════════════════════════════════════ */

.rhivo-plan-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  margin-bottom: var(--rhivo-space-md, 16px);
  font-size: var(--rhivo-text-body, 0.875rem);
  font-weight: 500;
  color: var(--rhivo-blue, #0078C6);
  background: rgba(0, 120, 198, 0.06);
  border: 1px solid rgba(0, 120, 198, 0.15);
  border-radius: var(--rhivo-radius-sm, 6px);
  line-height: 1.4;
}

.rhivo-plan-badge .icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  color: var(--rhivo-blue, #0078C6);
}

[data-bs-theme="dark"] .rhivo-plan-badge {
  color: #4da3e0;
  background: rgba(0, 120, 198, 0.1);
  border-color: rgba(0, 120, 198, 0.2);
}

[data-bs-theme="dark"] .rhivo-plan-badge .icon {
  color: #4da3e0;
}

/* ─── Dark Mode: Card (Tabler override) ─────────────────── */
[data-bs-theme="dark"] .card {
  background: var(--rhivo-surface);
  border-color: var(--rhivo-border);
}

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

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

/* ─── Dark Mode: Tabler/Bootstrap overrides ─────────────── */
[data-bs-theme="dark"] .form-control,
[data-bs-theme="dark"] .form-select {
  background: var(--rhivo-surface);
  border-color: var(--rhivo-border);
  color: var(--rhivo-text-primary);
}

[data-bs-theme="dark"] .form-control:focus,
[data-bs-theme="dark"] .form-select:focus {
  border-color: var(--rhivo-blue);
  box-shadow: 0 0 0 3px rgba(0, 120, 198, 0.12);
}

[data-bs-theme="dark"] .form-label,
[data-bs-theme="dark"] .col-form-label {
  color: var(--rhivo-text-primary);
}

[data-bs-theme="dark"] .form-check-input {
  background-color: var(--rhivo-bg-subtle);
  border-color: var(--rhivo-border);
}

[data-bs-theme="dark"] .form-check-input:checked {
  background-color: var(--rhivo-blue);
  border-color: var(--rhivo-blue);
}

[data-bs-theme="dark"] .input-group-text {
  background: var(--rhivo-bg-subtle);
  border-color: var(--rhivo-border);
  color: var(--rhivo-text-secondary);
}

[data-bs-theme="dark"] .input-group .form-control {
  border-color: var(--rhivo-border);
}

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

[data-bs-theme="dark"] .table thead th {
  border-color: var(--rhivo-border);
}

[data-bs-theme="dark"] .table tbody td {
  border-color: var(--rhivo-border);
}

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

[data-bs-theme="dark"] .bg-light {
  background: var(--rhivo-bg-subtle) !important;
}

[data-bs-theme="dark"] .bg-primary-lt {
  background: rgba(0, 120, 198, 0.12) !important;
  color: #4da3e0 !important;
}

[data-bs-theme="dark"] .bg-green-lt {
  background: rgba(34, 197, 94, 0.12) !important;
  color: #4ade80 !important;
}

[data-bs-theme="dark"] .bg-blue-lt {
  background: rgba(0, 120, 198, 0.12) !important;
  color: #4da3e0 !important;
}

[data-bs-theme="dark"] .alert-info {
  background: rgba(0, 120, 198, 0.1);
  border-color: rgba(0, 120, 198, 0.2);
  color: var(--rhivo-text-primary);
}

[data-bs-theme="dark"] .alert-danger {
  background: rgba(214, 57, 57, 0.1);
  border-color: rgba(214, 57, 57, 0.2);
  color: var(--rhivo-text-primary);
}

[data-bs-theme="dark"] .btn-light {
  background: var(--rhivo-bg-subtle);
  border-color: var(--rhivo-border);
  color: var(--rhivo-text-primary);
}

[data-bs-theme="dark"] .btn-light:hover {
  background: var(--rhivo-border);
  border-color: var(--rhivo-border);
  color: var(--rhivo-text-primary);
}

[data-bs-theme="dark"] .btn-outline-secondary {
  background: transparent;
  border-color: var(--rhivo-border);
  color: var(--rhivo-text-secondary);
}

[data-bs-theme="dark"] .btn-outline-secondary:hover {
  background: var(--rhivo-bg-subtle);
  color: var(--rhivo-text-primary);
  border-color: var(--rhivo-border);
}

[data-bs-theme="dark"] code {
  color: var(--rhivo-text-primary);
  background: var(--rhivo-bg-subtle);
}

[data-bs-theme="dark"] .card-clickable.border-primary {
  border-color: var(--rhivo-blue) !important;
}

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

[data-bs-theme="dark"] .spinner-border {
  border-color: currentColor transparent transparent transparent;
}

[data-bs-theme="dark"] .status {
  color: var(--rhivo-text-secondary);
}

[data-bs-theme="dark"] .status-green {
  color: #4ade80;
}

[data-bs-theme="dark"] .status-red {
  color: #f87171;
}

[data-bs-theme="dark"] .badge {
  color: var(--rhivo-text-primary);
}

[data-bs-theme="dark"] .fw-bold,
[data-bs-theme="dark"] .fw-semibold {
  color: var(--rhivo-text-primary);
}

/* ─── Dark Mode: Form Switch (Tabler override) ──────────── */
[data-bs-theme="dark"] .form-switch .form-check-input {
  background-color: #3a4055;
  border-color: #4a5065;
}

[data-bs-theme="dark"] .form-switch .form-check-input:checked {
  background-color: var(--rhivo-blue);
  border-color: var(--rhivo-blue);
}

/* ─── Dark Mode: Table header (Tabler override) ─────────── */
[data-bs-theme="dark"] .table thead th {
  background: transparent;
  color: var(--rhivo-text-secondary);
  border-bottom-color: var(--rhivo-border);
}

[data-bs-theme="dark"] .table tbody td {
  border-bottom-color: var(--rhivo-border);
}

/* ─── Dark Mode: Modal (Tabler/Bootstrap override) ──────── */
[data-bs-theme="dark"] .modal-content {
  background: var(--rhivo-surface);
  border-color: var(--rhivo-border);
}

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

[data-bs-theme="dark"] .modal-body {
  color: var(--rhivo-text-primary);
}

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

[data-bs-theme="dark"] .modal-header .btn-close {
  filter: invert(1) grayscale(100%) brightness(200%);
}

[data-bs-theme="dark"] .modal-backdrop {
  background: rgba(0, 0, 0, 0.6);
}

/* ═══════════════════════════════════════════════════════════
   Prontuário — Timeline (Epic 17)
   ═══════════════════════════════════════════════════════════ */

.prontuario-timeline {
  padding: 16px 0 24px;
  min-height: 120px;
}

.prontuario-timeline__wrapper {
  position: relative;
  padding: 0 12px 0 44px;
}

.prontuario-timeline__line {
  position: absolute;
  left: 21px;
  top: 8px;
  bottom: 8px;
  width: 2px;
  background: linear-gradient(to bottom, var(--rhivo-border, #e2e8f0), transparent);
}

[data-bs-theme="dark"] .prontuario-timeline__line {
  background: linear-gradient(to bottom, var(--rhivo-border-dark, #2d3748), transparent);
}

.prontuario-timeline__item--deleted {
  opacity: 0.6;
}

.prontuario-timeline__item--deleted .prontuario-timeline__card {
  border-color: var(--rhivo-danger, #e53e3e) !important;
  border-style: dashed;
}

.prontuario-timeline__item--deleted .prontuario-timeline__marker {
  opacity: 0.5;
}

.prontuario-timeline__item {
  position: relative;
  margin-bottom: 20px;
}

.prontuario-timeline__item:last-child {
  margin-bottom: 0;
}

.prontuario-timeline__marker {
  position: absolute;
  left: -34px;
  top: 16px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  color: #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,0.18);
  z-index: 1;
  transition: transform 0.2s;
}

.prontuario-timeline__item:hover .prontuario-timeline__marker {
  transform: scale(1.1);
}

.prontuario-timeline__card {
  background: var(--rhivo-card-bg, #fff);
  border: 1px solid var(--rhivo-border, #e9ecef);
  border-radius: 10px;
  overflow: hidden;
  transition: box-shadow 0.2s, border-color 0.2s;
}

.prontuario-timeline__card:hover {
  box-shadow: 0 4px 16px rgba(0,0,0,0.07);
  border-color: var(--rhivo-primary, #4299e1);
}

[data-bs-theme="dark"] .prontuario-timeline__card {
  background: var(--rhivo-card-bg-dark, #1a202c);
  border-color: var(--rhivo-border-dark, #2d3748);
}

.prontuario-timeline__card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 16px;
  border-bottom: 1px solid var(--rhivo-border, #f0f0f0);
  background: var(--rhivo-bg-subtle, #fafbfc);
}

[data-bs-theme="dark"] .prontuario-timeline__card-header {
  border-color: var(--rhivo-border-dark, #2d3748);
  background: var(--rhivo-bg-subtle-dark, #2d3748);
}

.prontuario-timeline__tipo-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 10px;
  border-radius: 10px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.prontuario-timeline__date {
  font-size: 12px;
  color: var(--rhivo-text-muted, #8896ab);
  font-weight: 450;
}

.prontuario-timeline__card-body {
  padding: 14px 16px 12px;
}

.prontuario-timeline__title {
  margin: 0 0 3px 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--rhivo-text, #1a202c);
  line-height: 1.3;
}

[data-bs-theme="dark"] .prontuario-timeline__title {
  color: var(--rhivo-text-dark, #e2e8f0);
}

.prontuario-timeline__professional {
  display: block;
  font-size: 12.5px;
  color: var(--rhivo-text-muted, #718096);
  margin-bottom: 6px;
}

.prontuario-timeline__desc {
  margin: 6px 0 0 0;
  font-size: 13px;
  line-height: 1.6;
  color: var(--rhivo-text, #4a5568);
  white-space: pre-line;
  word-wrap: break-word;
}

[data-bs-theme="dark"] .prontuario-timeline__desc {
  color: var(--rhivo-text-dark, #cbd5e0);
}

.prontuario-timeline__card-footer {
  display: flex;
  justify-content: flex-end;
  gap: 2px;
  padding: 6px 12px;
  border-top: 1px solid var(--rhivo-border, #f0f0f0);
  background: var(--rhivo-bg-subtle, #fafbfc);
}

[data-bs-theme="dark"] .prontuario-timeline__card-footer {
  border-color: var(--rhivo-border-dark, #2d3748);
  background: var(--rhivo-bg-subtle-dark, #2d3748);
}

.prontuario-timeline__card-footer .btn-rhivo-ghost {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 6px;
  color: var(--rhivo-text-muted, #718096);
}

.prontuario-timeline__card-footer .btn-rhivo-ghost:hover {
  background: rgba(0,0,0,0.05);
  color: var(--rhivo-text, #1a202c);
}

[data-bs-theme="dark"] .prontuario-timeline__card-footer .btn-rhivo-ghost:hover {
  background: rgba(255,255,255,0.08);
  color: var(--rhivo-text-dark, #e2e8f0);
}

/* Accordion da timeline */
.prontuario-timeline__accordion {
  border-top: 1px solid var(--rhivo-border, #e9ecef);
  background: var(--rhivo-bg-subtle, #fafbfc);
}

[data-bs-theme="dark"] .prontuario-timeline__accordion {
  border-color: var(--rhivo-border-dark, #2d3748);
  background: var(--rhivo-bg-subtle-dark, #2d3748);
}

.prontuario-timeline__accordion-body {
  padding: 16px 20px;
}

/* Anexo */
.prontuario-anexo {
  margin-top: 12px;
  padding: 8px 12px;
  background: var(--rhivo-bg-subtle, #f7fafc);
  border-radius: 6px;
  border: 1px dashed var(--rhivo-border, #e2e8f0);
}

[data-bs-theme="dark"] .prontuario-anexo {
  background: var(--rhivo-bg-subtle-dark, #2d3748);
  border-color: var(--rhivo-border-dark, #4a5568);
}

.prontuario-anexo__icon {
  margin-right: 6px;
}

.prontuario-anexo__link {
  font-size: 13px;
  color: var(--rhivo-primary, #4299e1);
  text-decoration: none;
}

.prontuario-anexo__link:hover {
  text-decoration: underline;
}

.prontuario-anexo__thumb {
  max-width: 120px;
  max-height: 80px;
  border-radius: 4px;
  display: block;
  margin-top: 4px;
  cursor: pointer;
}

/* View Modal */
.prontuario-view__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--rhivo-border, #e9ecef);
}

[data-bs-theme="dark"] .prontuario-view__meta {
  border-color: var(--rhivo-border-dark, #2d3748);
}

.prontuario-view__badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 600;
}

.prontuario-view__date,
.prontuario-view__professional,
.prontuario-view__author {
  font-size: 12.5px;
  color: var(--rhivo-text-muted, #718096);
}

.prontuario-view__desc {
  margin-bottom: 14px;
}

.prontuario-view__desc h4,
.prontuario-view__anexo h4 {
  font-size: 12px;
  font-weight: 700;
  margin: 0 0 4px 0;
  color: var(--rhivo-text, #1a202c);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  opacity: 0.55;
}

[data-bs-theme="dark"] .prontuario-view__desc h4,
[data-bs-theme="dark"] .prontuario-view__anexo h4 {
  color: var(--rhivo-text-dark, #e2e8f0);
}

.prontuario-view__desc-content {
  font-size: 14px;
  line-height: 1.7;
  color: var(--rhivo-text, #4a5568);
  white-space: pre-line;
}

[data-bs-theme="dark"] .prontuario-view__desc-content {
  color: var(--rhivo-text-dark, #cbd5e0);
}

.prontuario-view__anexo-img {
  max-width: 100%;
  border-radius: 6px;
  border: 1px solid var(--rhivo-border, #e2e8f0);
}

[data-bs-theme="dark"] .prontuario-view__anexo-img {
  border-color: var(--rhivo-border-dark, #4a5568);
}

.prontuario-error {
  text-align: center;
  padding: 40px 20px;
  color: var(--rhivo-danger, #e53e3e);
  font-size: 15px;
}

.btn-rhivo-danger-ghost {
  background: transparent;
  color: var(--rhivo-danger, #e53e3e);
  border: none;
}

.btn-rhivo-danger-ghost:hover {
  background: rgba(229, 62, 62, 0.08);
}

/* Prontuario Patient Card — Avatar quadrado com bordas arredondadas */
.prontuario-patient-card__avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: linear-gradient(135deg, #009AC2, #0078C6);
  flex-shrink: 0;
  font-weight: 700;
  font-size: 1.05rem;
  color: #fff;
  overflow: hidden;
  box-shadow: 0 2px 6px rgba(0, 120, 198, 0.25);
}

.prontuario-patient-card__avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.prontuario-patient-card__initials {
  font-weight: 700;
  font-size: 1.05rem;
  color: #fff;
}

/* Prontuario Patient Card */
.prontuario-patient-card-container {
  margin-bottom: 16px;
}

.prontuario-patient-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  background: var(--rhivo-card-bg, #fff);
  border: 1px solid var(--rhivo-border, #e2e8f0);
  border-radius: 10px;
  transition: box-shadow 0.2s;
}

.prontuario-patient-card:hover {
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

[data-bs-theme="dark"] .prontuario-patient-card {
  background: var(--rhivo-card-bg-dark, #1a202c);
  border-color: var(--rhivo-border-dark, #2d3748);
}



.prontuario-patient-card__info {
  flex: 1;
  min-width: 0;
}

.prontuario-patient-card__name {
  margin: 0 0 4px 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--rhivo-text, #1a202c);
}

[data-bs-theme="dark"] .prontuario-patient-card__name {
  color: var(--rhivo-text-dark, #e2e8f0);
}

.prontuario-patient-card__details {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
}

.prontuario-patient-card__detail {
  font-size: 12.5px;
  color: var(--rhivo-text-muted, #718096);
  white-space: nowrap;
}

.prontuario-patient-card__actions {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ═══════════════════════════════════════════════════════════
   EasyMDE — Overrides de estilo
   ═══════════════════════════════════════════════════════════ */

.EasyMDEContainer {
  border: 1.5px solid #dee2e6;
  border-radius: var(--rhivo-radius-md);
  overflow: hidden;
}

[data-bs-theme="dark"] .EasyMDEContainer {
  border-color: var(--rhivo-border-dark, #2d3748);
}

.editor-toolbar {
  border: none !important;
  border-bottom: 1px solid #dee2e6 !important;
  border-radius: 0 !important;
  padding: 3px 6px !important;
  background: #f8f9fa;
}

[data-bs-theme="dark"] .editor-toolbar {
  background: #2d3748;
  border-bottom-color: var(--rhivo-border-dark, #2d3748) !important;
}

[data-bs-theme="dark"] .editor-toolbar button i.ti {
  color: #e2e8f0;
}

[data-bs-theme="dark"] .editor-toolbar button:hover i.ti {
  color: #ffffff;
}

.editor-toolbar button {
  width: 28px !important;
  height: 26px !important;
  border-radius: 4px !important;
  border: none !important;
}

.editor-toolbar button:hover {
  background: rgba(0,0,0,0.06) !important;
  border: none !important;
}

[data-bs-theme="dark"] .editor-toolbar button:hover {
  background: rgba(255,255,255,0.08) !important;
}

.editor-toolbar i.separator {
  width: 1px !important;
  margin: 0 4px !important;
  border: none !important;
  background: #dee2e6 !important;
}

.CodeMirror {
  border: none !important;
  font-family: var(--rhivo-font-family) !important;
  font-size: 14px !important;
  line-height: 1.6 !important;
  min-height: 150px;
}

[data-bs-theme="dark"] .CodeMirror {
  background: var(--rhivo-surface-dark, #1a202c) !important;
  color: var(--rhivo-text-dark, #e2e8f0) !important;
}

[data-bs-theme="dark"] .CodeMirror-cursor {
  border-color: #fff !important;
}

[data-bs-theme="dark"] .CodeMirror-selected {
  background: rgba(66, 153, 225, 0.3) !important;
}

.editor-preview {
  background: #fff;
  color: var(--rhivo-text, #1a202c);
}

[data-bs-theme="dark"] .editor-preview {
  background: var(--rhivo-surface-dark, #1a202c);
  color: var(--rhivo-text-dark, #e2e8f0);
}

.editor-preview code {
  background: rgba(0,0,0,0.06);
  padding: 2px 5px;
  border-radius: 3px;
  font-size: 13px;
}

[data-bs-theme="dark"] .editor-preview code {
  background: rgba(255,255,255,0.08);
  color: #e2e8f0;
}

.editor-preview pre {
  background: rgba(0,0,0,0.03);
  padding: 12px;
  border-radius: 4px;
  overflow-x: auto;
}

[data-bs-theme="dark"] .editor-preview pre {
  background: rgba(255,255,255,0.04);
}

.editor-preview pre code {
  background: none;
  padding: 0;
  color: inherit;
}

[data-bs-theme="dark"] .editor-preview pre code {
  color: #cbd5e0;
}

.editor-preview-side {
  border-color: #dee2e6;
}

[data-bs-theme="dark"] .editor-preview-side {
  border-color: var(--rhivo-border-dark, #2d3748);
  background: var(--rhivo-surface-dark, #1a202c);
}

/* ═══════════════════════════════════════════════════════════
   Prontuário — Formulário Full-page (Epic 17)
   ═══════════════════════════════════════════════════════════ */

.prontuario-form__grid {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 24px;
  align-items: start;
}

@media (max-width: 768px) {
  .prontuario-form__grid {
    grid-template-columns: 1fr;
  }
}

.prontuario-form__main {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.prontuario-form__sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.prontuario-form__row {
  display: flex;
  gap: 16px;
}

@media (max-width: 576px) {
  .prontuario-form__row {
    flex-direction: column;
  }
}

.prontuario-form__section {
  background: var(--rhivo-card-bg, #fff);
  border: 1px solid var(--rhivo-border, #e2e8f0);
  border-radius: 8px;
  padding: 20px;
}

[data-bs-theme="dark"] .prontuario-form__section {
  background: var(--rhivo-card-bg-dark, #1a202c);
  border-color: var(--rhivo-border-dark, #2d3748);
}

.prontuario-form__section-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--rhivo-text, #1a202c);
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--rhivo-border, #e2e8f0);
}

[data-bs-theme="dark"] .prontuario-form__section-title {
  color: var(--rhivo-text-dark, #e2e8f0);
  border-color: var(--rhivo-border-dark, #2d3748);
}

.prontuario-form__soap-field {
  min-height: 80px;
  font-family: var(--rhivo-font-family);
  font-size: 14px;
  line-height: 1.6;
}

.prontuario-form__card {
  background: var(--rhivo-card-bg, #fff);
  border: 1px solid var(--rhivo-border, #e2e8f0);
  border-radius: 8px;
  padding: 16px;
}

[data-bs-theme="dark"] .prontuario-form__card {
  background: var(--rhivo-card-bg-dark, #1a202c);
  border-color: var(--rhivo-border-dark, #2d3748);
}

.prontuario-form__card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--rhivo-text, #1a202c);
  margin-bottom: 12px;
}

[data-bs-theme="dark"] .prontuario-form__card-title {
  color: var(--rhivo-text-dark, #e2e8f0);
}

/* ═══════════════════════════════════════════════════════════
   Custom Dropdown (prontuario tipo)
   ═══════════════════════════════════════════════════════════ */

.rhivo-dropdown {
  position: relative;
}

.rhivo-dropdown__trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  padding: 0.5rem 0.75rem;
  font-family: var(--rhivo-font-family);
  font-size: var(--rhivo-text-body);
  line-height: 1.5;
  color: var(--rhivo-text-primary);
  background: var(--rhivo-surface);
  border: 1.5px solid #dee2e6;
  border-radius: var(--rhivo-radius-md);
  cursor: pointer;
  transition: border-color var(--rhivo-transition-fast), box-shadow var(--rhivo-transition-fast);
  text-align: left;
  appearance: none;
}

.rhivo-dropdown__trigger:focus,
.rhivo-dropdown__trigger:focus-visible {
  outline: none;
  border-color: var(--rhivo-blue);
  box-shadow: 0 0 0 3px rgba(0, 120, 198, 0.12);
}

.rhivo-dropdown__trigger:hover {
  border-color: var(--rhivo-blue);
}

[data-bs-theme="dark"] .rhivo-dropdown__trigger {
  background: var(--rhivo-surface-dark, #1e293b);
  border-color: var(--rhivo-border-dark, #2d3748);
  color: var(--rhivo-text-dark, #e2e8f0);
}

.rhivo-dropdown-menu {
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 1060;
  min-width: 100%;
  width: 240px;
  padding: 6px 0;
  margin-top: 2px;
  background: var(--rhivo-card-bg, #fff);
  border: 1px solid var(--rhivo-border, #e2e8f0);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
}

[data-bs-theme="dark"] .rhivo-dropdown-menu {
  background: var(--rhivo-card-bg-dark, #1a202c);
  border-color: var(--rhivo-border-dark, #2d3748);
  box-shadow: 0 8px 24px rgba(0,0,0,0.35);
}

.rhivo-dropdown-header {
  display: block;
  padding: 6px 14px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--rhivo-text-muted, #718096);
  opacity: 0.6;
}

.rhivo-dropdown-item {
  display: flex;
  align-items: center;
  padding: 8px 14px;
  color: var(--rhivo-text, #1a202c);
  text-decoration: none;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s;
}

.rhivo-dropdown-item:hover {
  background: var(--rhivo-bg-hover, rgba(0,0,0,0.04));
  color: var(--rhivo-text, #1a202c);
}

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

[data-bs-theme="dark"] .rhivo-dropdown-item:hover {
  background: rgba(255,255,255,0.06);
}

/* ═══════════════════════════════════════════════════════════
   Markdown Editor (prontuario)
   ═══════════════════════════════════════════════════════════ */


