html {
  font-size: 14px;
}

@media (min-width: 768px) {
  html {
    font-size: 16px;
  }
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
  box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb;
}

html {
  position: relative;
  min-height: 100%;
}

body {
  margin-bottom: 60px;
}

.calendar-shell {
  background: linear-gradient(180deg, #f9fbff 0%, #ffffff 100%);
  border: 1px solid #dbe6f3;
  border-radius: 1rem;
  padding: 1rem;
}

.calendar-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.calendar-title {
  font-weight: 700;
  font-size: 1.1rem;
  text-transform: capitalize;
}

.calendar-weekdays,
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 0.75rem;
}

.calendar-weekdays {
  margin-bottom: 0.75rem;
  color: #60708a;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.calendar-day {
  min-height: 9rem;
  background: #ffffff;
  border: 1px solid #d8e2ef;
  border-radius: 1rem;
  padding: 0.75rem;
  color: inherit;
  text-decoration: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.calendar-day:hover {
  transform: translateY(-1px);
  border-color: #9ab7dc;
  box-shadow: 0 10px 24px rgba(24, 52, 92, 0.08);
}

.calendar-day--muted {
  background: #f6f8fb;
  color: #8b98ac;
}

.calendar-day--today {
  border-color: #1f6feb;
  box-shadow: inset 0 0 0 1px #1f6feb;
}

.calendar-day__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 700;
}

.calendar-day__events {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.calendar-chip {
  font-size: 0.82rem;
  padding: 0.35rem 0.5rem;
  border-radius: 0.75rem;
  background: #eef4fb;
  color: #18345c;
  overflow: hidden;
  text-overflow: ellipsis;
}

.day-timeline {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.timeline-card {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 1rem;
  align-items: stretch;
}

.timeline-hour {
  background: #18345c;
  color: #ffffff;
  border-radius: 1rem;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  text-align: center;
  font-weight: 700;
}

.timeline-content {
  background: #ffffff;
  border: 1px solid #d8e2ef;
  border-radius: 1rem;
  padding: 1rem;
}

.patient-summary dt {
  color: #60708a;
  font-weight: 600;
}

.patient-summary dd {
  margin-bottom: 0.75rem;
}

.patient-section-stack {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.patient-panel {
  border: 1px solid #dbe4f0;
  border-radius: 1rem;
}

.patient-panel > .card-body {
  padding: 1rem 1.25rem;
}

.patient-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-bottom: 0.75rem !important;
}

.patient-panel__toggle,
.patient-panel__icon-action {
  width: 2rem;
  height: 2rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
}

.patient-panel__meta {
  margin-top: 0.1rem;
  color: #60708a;
  font-size: 0.88rem;
}

.patient-vitals-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.patient-vitals-chip {
  display: inline-flex;
  align-items: center;
  padding: 0.45rem 0.7rem;
  border-radius: 999px;
  background: #eef6ff;
  color: #18345c;
  font-size: 0.9rem;
  font-weight: 500;
}

.anamnesis-history-frame {
  max-height: 28rem;
  overflow-y: auto;
  border: 1px solid #d8e2ef;
  border-radius: 0.75rem;
}

.anamnesis-history-frame .table thead th {
  padding: 0.7rem 1rem;
  vertical-align: top;
}

.anamnesis-history-frame .table tbody td {
  padding: 0.55rem 1rem;
  vertical-align: top;
}

.anamnesis-content-cell {
  white-space: pre-wrap;
  min-width: 28rem;
  display: flex;
  align-items: flex-start;
}

.anamnesis-entry-block {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 0.2rem;
  width: 100%;
}

.anamnesis-entry-block--compact {
  gap: 0;
}

.anamnesis-vitals-line {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 0.2rem;
  padding: 0.45rem 0.75rem;
  border-radius: 0.75rem;
  background: #eef6ff;
  color: #18345c;
}

.anamnesis-entry-block--compact .anamnesis-vitals-line {
  margin-bottom: 0;
}

.anamnesis-history-frame .small.text-muted.mb-1 {
  margin-bottom: 0.15rem !important;
}

.anamnesis-vitals-line span {
  font-size: 0.9rem;
}

.anamnesis-vitals-line strong {
  margin-right: 0.25rem;
}

.anamnesis-entry-text {
  text-align: left;
  color: #18345c;
  line-height: 1.35;
  margin-left: 0;
  margin-top: 0;
}

.vitals-card .form-label {
  font-size: 0.9rem;
}

.vitals-card .form-control {
  min-height: 2.75rem;
}

@media (max-width: 991px) {
  .calendar-weekdays,
  .calendar-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .timeline-card {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 575px) {
  .calendar-weekdays,
  .calendar-grid {
    grid-template-columns: 1fr;
  }
}

.form-floating > .form-control-plaintext::placeholder, .form-floating > .form-control::placeholder {
  color: var(--bs-secondary-color);
  text-align: end;
}

.form-floating > .form-control-plaintext:focus::placeholder, .form-floating > .form-control:focus::placeholder {
  text-align: start;
}

.brand-wordmark {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.brand-wordmark img {
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
}

.brand-wordmark .brand-name {
  color: #0b132a;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1;
}

.brand-wordmark-dark .brand-name {
  color: #ffffff;
}

.sidebar .sidebar-logo .brand-wordmark {
  min-height: 30px;
}

.sidebar .sidebar-logo .brand-wordmark img {
  width: 28px;
}

.anamnesis-template-trigger,
.anamnesis-help-trigger {
  width: 1.25rem;
  height: 1.25rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  text-decoration: none;
}

.anamnesis-template-trigger:hover,
.anamnesis-help-trigger:hover {
  color: #2e37a4 !important;
}

.anamnesis-template-trigger i,
.anamnesis-help-trigger i {
  font-size: 0.95rem;
}

.anamnesis-composer {
  min-height: 12rem;
  resize: vertical;
}

#anamnesisTemplateModal .modal-content {
  border: 0;
  border-radius: 1rem;
  box-shadow: 0 1.5rem 4rem rgba(15, 23, 42, 0.18);
}

#patientVitalsModal .modal-content,
#anamnesisTemplateModal .modal-content {
  border: 0;
  border-radius: 1rem;
  box-shadow: 0 1.5rem 4rem rgba(15, 23, 42, 0.18);
}

#anamnesisTemplateModal .modal-header,
#anamnesisTemplateModal .modal-footer,
#patientVitalsModal .modal-header,
#patientVitalsModal .modal-footer {
  border-color: #e6edf7;
}

/* ==========================================================================
   Role badge — etiqueta colorida do papel do utilizador (topbar dropdown)
   ========================================================================== */
.role-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 2px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .02em;
  text-transform: uppercase;
  border: 1px solid transparent;
  line-height: 1.3;
}
.role-badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: .85;
}
.role-badge-super    { background: #FDE2E4; color: #B5274F; border-color: #F3B6BD; }
.role-badge-admin    { background: #EFEFFB; color: #3F3DAB; border-color: #D7D5F1; }
.role-badge-staff    { background: #E6FAF7; color: #0EAA98; border-color: #B7E8DF; }
.role-badge-clinical { background: #E3F4E9; color: #1FA971; border-color: #B7E0C6; }
.role-badge-default  { background: #F1F3F5; color: #6B7280; border-color: #DDE1E6; }

[data-bs-theme="dark"] .role-badge-super    { background: #3a141d; color: #FFB7C2; border-color: #5b2530; }
[data-bs-theme="dark"] .role-badge-admin    { background: #22253f; color: #a4a1ff; border-color: #34376b; }
[data-bs-theme="dark"] .role-badge-staff    { background: #102b2a; color: #6ad7c6; border-color: #1d4644; }
[data-bs-theme="dark"] .role-badge-clinical { background: #16321f; color: #6cd194; border-color: #214d34; }
[data-bs-theme="dark"] .role-badge-default  { background: #202a36; color: #9facbf; border-color: #2c3a4b; }

/* ==========================================================================
   Theme Customizer — desativado (botão flutuante + offcanvas do PreClinic)
   ========================================================================== */
.toggle-theme,
#theme-settings-offcanvas {
  display: none !important;
}

/* ==========================================================================
   Dark mode overrides (LifeMotion usa data-bs-theme="dark" no <html>)
   ========================================================================== */

[data-bs-theme="dark"] .calendar-shell {
  background: linear-gradient(180deg, #161d2c 0%, #0f1623 100%);
  border-color: #202a36;
}

[data-bs-theme="dark"] .calendar-weekdays {
  color: #9facbf;
}

[data-bs-theme="dark"] .calendar-day {
  background: #1a2233;
  border-color: #202a36;
  color: #d6dde9;
}

[data-bs-theme="dark"] .calendar-day:hover {
  border-color: #3f6ec2;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35);
}

[data-bs-theme="dark"] .calendar-day--muted {
  background: #131a26;
  color: #6e7a90;
}

[data-bs-theme="dark"] .calendar-day--today {
  border-color: #4d8dfb;
  box-shadow: inset 0 0 0 1px #4d8dfb;
}

[data-bs-theme="dark"] .calendar-chip {
  background: rgba(77, 141, 251, 0.15);
  color: #c8d8f3;
}

[data-bs-theme="dark"] .timeline-hour {
  background: #0f1623;
  color: #e8eef9;
}

[data-bs-theme="dark"] .timeline-content {
  background: #1a2233;
  border-color: #202a36;
  color: #d6dde9;
}

[data-bs-theme="dark"] .patient-panel {
  border-color: #202a36;
}

[data-bs-theme="dark"] .patient-summary dt,
[data-bs-theme="dark"] .patient-panel__meta {
  color: #9facbf;
}

[data-bs-theme="dark"] .patient-vitals-chip,
[data-bs-theme="dark"] .anamnesis-vitals-line {
  background: rgba(77, 141, 251, 0.15);
  color: #c8d8f3;
}

[data-bs-theme="dark"] .anamnesis-entry-text {
  color: #d6dde9;
}

[data-bs-theme="dark"] .anamnesis-history-frame {
  border-color: #202a36;
}

[data-bs-theme="dark"] .brand-wordmark .brand-name {
  color: #ffffff;
}

[data-bs-theme="dark"] #anamnesisTemplateModal .modal-header,
[data-bs-theme="dark"] #anamnesisTemplateModal .modal-footer,
[data-bs-theme="dark"] #patientVitalsModal .modal-header,
[data-bs-theme="dark"] #patientVitalsModal .modal-footer {
  border-color: #202a36;
}
.tenant-onboarding-shell {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    padding: 2rem 0;
}

.tenant-onboarding-header {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.tenant-onboarding-header h1 {
    margin: 0;
    font-size: 3rem;
    font-weight: 700;
    color: #0b2554;
}

.tenant-onboarding-header p {
    margin: 0 auto;
    max-width: 760px;
    color: #5e6f92;
    font-size: 1.05rem;
}

.tenant-onboarding-brand {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    align-self: center;
    padding: 0.45rem 0.85rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.84);
    box-shadow: 0 16px 32px rgba(11, 37, 84, 0.08);
    color: #0b2554;
    font-weight: 700;
}

.tenant-onboarding-brand img {
    width: 28px;
    height: 28px;
}

.tenant-onboarding-brand--compact {
    align-self: flex-start;
}

.tenant-onboarding-steps {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1rem;
}

.tenant-onboarding-step {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    padding: 1rem 1.15rem;
    border: 1px solid #d5e2f6;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.9);
    color: #5e6f92;
}

.tenant-onboarding-step span {
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.tenant-onboarding-step strong {
    font-size: 1.05rem;
    color: #0b2554;
}

.tenant-onboarding-step--active {
    border-color: #28c7d9;
    background: linear-gradient(135deg, rgba(40, 199, 217, 0.12), rgba(62, 96, 204, 0.08));
}

.tenant-onboarding-card,
.legal-document-card {
    padding: 2rem;
    border-radius: 28px;
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 24px 60px rgba(11, 37, 84, 0.12);
}

.tenant-onboarding-section + .tenant-onboarding-section {
    margin-top: 1.75rem;
}

.tenant-onboarding-section__intro {
    margin-bottom: 1rem;
}

.tenant-onboarding-section__intro h2,
.legal-document-card h1 {
    margin: 0 0 0.35rem;
    color: #0b2554;
    font-size: 1.85rem;
    font-weight: 700;
}

.tenant-onboarding-section__intro p,
.legal-document-card__header p,
.legal-document-card p {
    color: #5e6f92;
}

.tenant-legal-panel {
    padding: 1rem 1.15rem;
    border: 1px solid #dce6f8;
    border-radius: 18px;
    background: #f8fbff;
}

.tenant-onboarding-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-top: 2rem;
}

.legal-document-card {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin: 2rem 0;
}

.legal-document-card__header {
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #e3ebf8;
}

.legal-document-card h2 {
    margin: 0 0 0.35rem;
    color: #0b2554;
    font-size: 1.2rem;
}

@media (max-width: 991.98px) {
    .tenant-onboarding-header h1 {
        font-size: 2.4rem;
    }

    .tenant-onboarding-steps {
        grid-template-columns: 1fr;
    }

    .tenant-onboarding-card,
    .legal-document-card {
        padding: 1.35rem;
        border-radius: 22px;
    }

    .tenant-onboarding-actions {
        flex-direction: column;
        align-items: stretch;
    }
}
