@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@400;500;600;700;800&display=swap');

:root {
  --cyan:           #06B6D4;
  --blue:           #2563EB;
  --primary:        #1D4ED8;
  --primary-mid:    #0891B2;
  --primary-light:  #E0F2FE;
  --accent:         #7C3AED;
  --brand-gradient: linear-gradient(135deg, #06B6D4 0%, #2563EB 58%, #7C3AED 100%);
  --success:        #059669;
  --warning:        #D97706;
  --danger:         #DC2626;
  --info:           #0891B2;
  --purple:         #7C3AED;
  --gray-50:        #F5F7FA;
  --gray-100:       #eef2f7;
  --gray-200:       #dde4ee;
  --gray-400:       #9AA6B8;
  --gray-600:       #6B7280;
  --gray-800:       #0F172A;
  --text-primary:   #0F172A;
  --text-secondary: #6B7280;
  --text-hint:      #9AA6B8;
  --card-shadow:    0 2px 14px rgba(30,58,95,.09);
  --card-radius:    16px;

  --sidebar-w:      0px;
  --content-pad:    1rem;
  --content-max:    none;
}

*, *::before, *::after { box-sizing: border-box; }

html {
  font-size: 16px;
  width: 100%;
}

html, body {
  font-family: Outfit, 'Segoe UI', sans-serif;
  background: var(--gray-50);
  color: var(--text-primary);
  width: 100%;
  min-height: 100%;
}

body {
  overflow-x: hidden;
  overscroll-behavior-x: none;
}

body {

  padding-bottom: 1rem;

  padding-top: env(safe-area-inset-top, 0px);
  background: linear-gradient(180deg, #f4f8ff 0%, #f7fbff 42%, #f6f4ff 100%);
  background-attachment: fixed;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(circle at 8% -10%, rgba(6,182,212,.16), transparent 32%),
    radial-gradient(circle at 100% 0%, rgba(124,58,237,.10), transparent 28%);
  pointer-events: none;
  z-index: 0;
}

body > * {
  position: relative;
  z-index: 1;
}

a { text-decoration: none; }

body.page-auth {
  background-image: none;
  padding-bottom: 0;
}
body.page-auth::before { display: none; }

.auth-bg {
  min-height: 100vh;
  background: linear-gradient(160deg, #e8f0fe 0%, #f8fafc 60%, #e0f4f1 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.auth-card {
  background: #fff;
  border-radius: 24px;
  box-shadow: 0 8px 40px rgba(27,79,138,.13);
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 420px;
}

.auth-logo {
  width: 64px;
  height: 64px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1.25rem;
  box-shadow: 0 4px 16px rgba(27,79,138,.25);
}

.auth-logo i { font-size: 28px; color: #fff; }

.auth-title {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--primary);
  text-align: center;
  margin-bottom: .25rem;
}

.form-label {
  font-weight: 600;
  font-size: .875rem;
  color: var(--text-secondary);
  margin-bottom: .3rem;
}

.form-control, .form-select {
  font-family: Outfit, 'Segoe UI', sans-serif;
  font-size: .95rem;
  border: 1.5px solid var(--gray-200);
  border-radius: 12px;
  padding: .65rem 1rem;
  background: var(--gray-50);
  color: var(--text-primary);
  transition: border-color .2s, box-shadow .2s;
}

.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(27,79,138,.12);
  background: #fff;
  outline: none;
}

.form-control.is-invalid { border-color: var(--danger); }
.invalid-feedback { font-size: .82rem; color: var(--danger); font-weight: 600; }

.input-group .form-control { border-right: none; }
.input-group .btn-icon {
  border: 1.5px solid var(--gray-200);
  border-left: none;
  border-radius: 0 12px 12px 0;
  background: var(--gray-50);
  color: var(--text-hint);
  padding: 0 .9rem;
  cursor: pointer;
  transition: color .2s;
}
.input-group .btn-icon:hover { color: var(--primary); }

.btn {
  font-family: Outfit, 'Segoe UI', sans-serif;
  font-weight: 700;
  border-radius: 12px;
  transition: all .2s;
}

.btn-primary {
  background: var(--brand-gradient);
  border: none;
  color: #fff;
  padding: .7rem 1.5rem;
}
.btn-primary:hover { opacity: .9; transform: translateY(-1px); }
.btn-primary:disabled { opacity: .6; transform: none; }

.btn-outline-primary {
  border: 1.5px solid var(--primary);
  color: var(--primary);
  background: transparent;
}
.btn-outline-primary:hover {
  background: var(--primary-light);
  color: var(--primary);
  border-color: var(--primary);
}

.btn-sm { padding: .35rem .9rem; font-size: .82rem; }

.card {
  border: none;
  border-radius: var(--card-radius);
  box-shadow: 0 4px 20px rgba(27,79,138,0.15);
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.stat-card {
  border-radius: var(--card-radius);
  padding: 1.1rem;
  box-shadow: 0 4px 20px rgba(27,79,138,0.15);
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  gap: .9rem;
  transition: transform .15s;
  cursor: pointer;
}
.stat-card:hover { transform: translateY(-2px); }

.stat-icon {
  width: 46px;
  height: 46px;
  border-radius: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 1.3rem;
}

.stat-icon.primary { background: var(--primary-light); color: var(--primary); }
.stat-icon.success { background: #d1fae5;              color: var(--success); }
.stat-icon.danger  { background: #fee2e2;              color: var(--danger);  }
.stat-icon.purple  { background: #ede9fe;              color: var(--purple);  }

.patient-card {
  background: var(--brand-gradient);
  border-radius: 20px;
  padding: 1.25rem 1.4rem;
  color: #fff;
  position: relative;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(27,79,138,.3);
}
.patient-card::after {
  content: '';
  position: absolute;
  top: -30px; right: -30px;
  width: 120px; height: 120px;
  border-radius: 50%;
  background: rgba(255,255,255,.08);
  pointer-events: none;
  z-index: 0;
}
.patient-card .badge-status {
  background: rgba(255,255,255,.2);
  color: #fff;
  border-radius: 20px;
  padding: .25rem .75rem;
  font-size: .78rem;
  font-weight: 700;
}

.med-item {
  background: #fff;
  border-radius: 14px;
  box-shadow: var(--card-shadow);
  padding: 1rem;
  display: flex;
  align-items: center;
  gap: .9rem;
  margin-bottom: .75rem;
  transition: opacity .2s;
}
.med-item.taken { opacity: .55; }

.med-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}
.med-dot.taken     { background: var(--success); }
.med-dot.pending   { background: var(--warning); }
.med-dot.missed    { background: var(--danger); }
.med-dot.scheduled { background: var(--info); }
.med-dot.buy       { background: #7C3AED; }

.med-card {
  background: #fff;
  border-radius: 16px;
  box-shadow: var(--card-shadow);
  padding: .9rem 1rem;
  display: flex;
  align-items: flex-start;
  gap: .85rem;
  margin-bottom: .75rem;
  transition: opacity .2s, box-shadow .15s;
  border: 1.5px solid transparent;
}
.med-card:hover { box-shadow: 0 4px 18px rgba(27,79,138,.13); border-color: rgba(27,79,138,.1); }
.med-card.taken  { opacity: .5; }

.med-card-left  { flex-shrink: 0; padding-top: .28rem; }
.med-card-body  { flex: 1; min-width: 0; }
.med-card-actions {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: .3rem;
}

.med-card-name {
  font-weight: 800;
  font-size: .95rem;
  color: var(--text-primary);
  line-height: 1.3;
  margin-bottom: .3rem;
}
.med-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
  margin-bottom: .35rem;
}
.med-card-notes {
  font-size: .76rem;
  color: var(--text-hint);
  font-style: italic;
  margin-top: .25rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.med-dosage-chip,
.med-freq-chip,
.med-continuous-chip {
  display: inline-flex;
  align-items: center;
  gap: .2rem;
  padding: .12rem .5rem;
  border-radius: 20px;
  font-size: .71rem;
  font-weight: 700;
  white-space: nowrap;
}
.med-dosage-chip     { background: rgba(27,79,138,.1);  color: var(--primary); }
.med-freq-chip       { background: #e0f2fe;              color: var(--info); }
.med-continuous-chip { background: #d1fae5;              color: var(--success); }

.med-times-row {
  display: flex;
  flex-wrap: wrap;
  gap: .3rem;
  margin-top: .2rem;
}
.med-time-chip {
  display: inline-flex;
  align-items: center;
  gap: .18rem;
  padding: .14rem .48rem;
  border-radius: 20px;
  font-size: .72rem;
  font-weight: 700;
  background: #e0f2fe;
  color: var(--info);
  white-space: nowrap;
}

.times-grid {
  display: flex;
  flex-wrap: wrap;
  gap: .6rem;
}
.time-input-wrap {
  display: flex;
  flex-direction: column;
  gap: .25rem;
  min-width: 108px;
  flex: 1;
}
.time-dose-label {
  font-size: .7rem;
  font-weight: 700;
  color: var(--text-hint);
  text-transform: uppercase;
  letter-spacing: .04em;
}
.time-input-wrap .form-control {
  font-size: .88rem;
  font-weight: 700;
  color: var(--primary);
  text-align: center;
  padding: .35rem .5rem;
  border-radius: 10px;
}

.status-badge-pill {
  display: inline-flex;
  align-items: center;
  padding: .18rem .55rem;
  border-radius: 20px;
  font-size: .72rem;
  font-weight: 700;
  white-space: nowrap;
}

.med-action-btn {
  border-radius: 8px;
  padding: .2rem .55rem;
  font-size: .75rem;
  border: none;
  line-height: 1.4;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  padding: .22rem .65rem;
  border-radius: 20px;
  font-size: .75rem;
  font-weight: 700;
}

.status-badge.normal { background: #d1fae5; color: var(--success); }

.mgmt-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: .25rem;
}
.mgmt-panel-link {
  font-size: .78rem;
  color: var(--primary);
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}
.mgmt-panel-link:hover { text-decoration: underline; }

.appt-card {
  background: #fff;
  border-radius: 16px;
  box-shadow: var(--card-shadow);
  padding: .85rem 1rem;
  display: flex;
  align-items: flex-start;
  gap: .85rem;
  margin-bottom: .65rem;
  border: 1.5px solid transparent;
  transition: box-shadow .15s;
}
.appt-card:hover { box-shadow: 0 4px 18px rgba(27,79,138,.13); border-color: rgba(27,79,138,.1); }
.appt-card-icon {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: #e0f2fe;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 1.1rem;
  color: var(--info);
}
.appt-card-body { flex: 1; min-width: 0; }
.appt-card-title {
  font-weight: 800;
  font-size: .95rem;
  color: var(--text-primary);
  line-height: 1.3;
  margin-bottom: .2rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.appt-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: .3rem;
  font-size: .76rem;
  color: var(--text-secondary);
  font-weight: 600;
}
.appt-date-chip {
  display: inline-flex;
  align-items: center;
  gap: .2rem;
  padding: .12rem .48rem;
  border-radius: 20px;
  font-size: .72rem;
  font-weight: 700;
  background: #e0f2fe;
  color: var(--info);
  white-space: nowrap;
}
.appt-date-chip.today   { background: #fef9c3; color: #b45309; }
.appt-date-chip.soon    { background: #fce7f3; color: #be185d; }
.appt-date-chip.past    { background: #f3f4f6; color: #9ca3af; text-decoration: line-through; }

.note-card {
  background: #fff;
  border-radius: 16px;
  box-shadow: var(--card-shadow);
  padding: .85rem 1rem;
  margin-bottom: .65rem;
  border-left: 3px solid #7c3aed;
  transition: box-shadow .15s;
}
.note-card:hover { box-shadow: 0 4px 18px rgba(124,58,237,.12); }
.note-card-date {
  font-size: .72rem;
  font-weight: 700;
  color: #7c3aed;
  margin-bottom: .25rem;
}
.note-card-text {
  font-size: .88rem;
  color: var(--text-primary);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.toast-container { z-index: 9999; }

.spinner-border-sm { width: 1rem; height: 1rem; border-width: .15em; }

#map { width: 100%; height: calc(100vh - 68px); }

.progress { border-radius: 8px; height: 8px; }
.progress-bar { border-radius: 8px; }

.section-title {
  font-size: .75rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-hint);
  margin-bottom: .65rem;
  margin-top: 1.1rem;
}

.offcanvas-bottom {
  border-radius: 24px 24px 0 0;
  max-height: 90vh;
}

.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--text-hint);
}
.empty-state i { font-size: 3rem; opacity: .35; margin-bottom: .75rem; }
.empty-state p { font-size: .95rem; font-weight: 600; }

.user-type-btn {
  flex: 1;
  border: 1.5px solid var(--gray-200);
  border-radius: 12px;
  padding: .6rem .5rem;
  text-align: center;
  cursor: pointer;
  transition: all .15s;
  font-size: .8rem;
  font-weight: 700;
  color: var(--text-secondary);
  background: #fff;
}
.user-type-btn.selected {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--primary);
}
.user-type-btn i { display: block; font-size: 1.3rem; margin-bottom: .25rem; }

::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gray-200); border-radius: 10px; }

.fw-800 { font-weight: 800 !important; }
.fw-700 { font-weight: 700 !important; }
.text-primary-custom { color: var(--primary) !important; }
.text-accent { color: var(--accent) !important; }

@media (min-width: 576px) {
  .auth-card { padding: 3rem 2.5rem; }
}

#sidebar { display: none; }

/* ─── Hamburger toggle button ─── */
.hamburger-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border: none;
  background: var(--primary-light);
  color: var(--primary);
  border-radius: 10px;
  font-size: 1.25rem;
  cursor: pointer;
  flex-shrink: 0;
  transition: background .15s, transform .15s;
  -webkit-tap-highlight-color: transparent;
}
.hamburger-btn:hover,
.hamburger-btn:focus { background: var(--gray-200); outline: none; }
.hamburger-btn:active { transform: scale(.92); }

/* ─── Sidebar overlay backdrop ─── */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 199;
  opacity: 0;
  transition: opacity .25s ease;
}
.sidebar-backdrop.show {
  display: block;
  opacity: 1;
}

/* ─── Sidebar mobile overlay ─── */
#sidebar.sidebar-mobile {
  display: flex !important;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  width: 280px;
  max-width: 85vw;
  height: 100vh;
  height: 100dvh;
  background: rgba(255,255,255,.98);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 4px 0 24px rgba(27,79,138,.18);
  padding: 1.25rem 1rem;
  padding-top: calc(1.25rem + env(safe-area-inset-top, 0px));
  z-index: 200;
  overflow-y: auto;
  overflow-x: hidden;
  transform: translateX(-100%);
  transition: transform .28s cubic-bezier(.4,0,.2,1);
}
#sidebar.sidebar-mobile.open {
  transform: translateX(0);
}

/* Close button inside sidebar mobile */
.sidebar-close-btn {
  display: none;
  position: absolute;
  top: .75rem;
  right: .75rem;
  width: 32px;
  height: 32px;
  border: none;
  background: var(--gray-100);
  color: var(--text-secondary);
  border-radius: 8px;
  font-size: 1.1rem;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  z-index: 10;
  transition: background .15s;
}
.sidebar-close-btn:hover { background: var(--gray-200); }
#sidebar.sidebar-mobile .sidebar-close-btn { display: flex; }

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .35rem .55rem 1rem;
  border-bottom: 1px solid var(--gray-100);
  margin-bottom: .85rem;
  flex-shrink: 0;
}
.sidebar-logo-icon,
.brand-mark {
  width: 40px; height: 40px;
  background: var(--brand-gradient);
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 1.1rem;
  flex-shrink: 0;
  object-fit: cover;
}
.sidebar-brand-text { min-width: 0; }
.sidebar-logo span,
.sidebar-brand-text span { font-size: .98rem; font-weight: 800; color: var(--primary); line-height: 1.2; display: block; }
.sidebar-brand-text small {
  display: block;
  margin-top: .15rem;
  color: var(--text-hint);
  font-size: .68rem;
  font-weight: 700;
  line-height: 1.25;
}

.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: .58rem .85rem;
  border-radius: 12px;
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 700;
  font-size: .88rem;
  transition: background .15s, color .15s;
  margin-bottom: .2rem;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-nav-item i { font-size: 1.05rem; width: 20px; text-align: center; flex-shrink: 0; }
.sidebar-nav-item:hover  { background: var(--gray-100); color: var(--text-primary); }
.sidebar-nav-item.active { background: var(--primary-light); color: var(--primary); font-weight: 800; }

.sidebar-nav-item .si {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px; height: 28px;
  border-radius: 8px;
  flex-shrink: 0;
  font-size: 1rem;
  transition: transform .15s;
}
.sidebar-nav-item:hover .si { transform: scale(1.12); }

.sidebar-nav-item[href="/dashboard"]      .si { background: #e0f2fe; color: #0369a1; }
.sidebar-nav-item[href="/pressao"]        .si { background: #fee2e2; color: #dc2626; }
.sidebar-nav-item[href="/medications"]    .si { background: #fce7f3; color: #be185d; }
.sidebar-nav-item[href="/exams"]          .si { background: #ede9fe; color: #7c3aed; }
.sidebar-nav-item[href="/consultas"]      .si { background: #fef3c7; color: #b45309; }
.sidebar-nav-item[href="/alergias"]       .si { background: #fff7ed; color: #c2410c; }
.sidebar-nav-item[href="/clinical-notes"] .si { background: #f0fdf4; color: #16a34a; }
.sidebar-nav-item[href="/gestao"]         .si { background: #e0f2fe; color: #0284c7; }
.sidebar-nav-item[href="/family"]         .si { background: #fdf4ff; color: #9333ea; }

.sidebar-nav-item.active .si { filter: brightness(.9) saturate(1.3); box-shadow: 0 2px 6px rgba(0,0,0,.1); }

.sidebar-group-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: .68rem;
  font-weight: 800;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--text-hint);
  padding: .7rem .85rem .25rem;
  margin-top: .25rem;
  cursor: pointer;
  user-select: none;
  border-radius: 8px;
  transition: background .15s, color .15s;
}
.sidebar-group-label:hover {
  background: var(--gray-100);
  color: var(--text-secondary);
}
.sidebar-group-label .sg-arrow {
  font-size: .75rem;
  transition: transform .25s ease;
  opacity: .6;
  flex-shrink: 0;
}
.sidebar-group-label.sg-collapsed .sg-arrow {
  transform: rotate(-90deg);
}
.sidebar-group-items {
  overflow: hidden;
  transition: max-height .28s ease, opacity .2s ease;
  max-height: 500px;
  opacity: 1;
}
.sidebar-group-items.sg-collapsed {
  max-height: 0 !important;
  opacity: 0;
}

.main-content {
  width: 100%;
  box-sizing: border-box;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.main-content > [class*="px-"],
.main-content > .content-wrapper {
  flex: 1;
}

.mx-banner { margin-left: var(--content-pad); margin-right: var(--content-pad); }

.page-header {
  background: rgba(255,255,255,0.95);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  padding: .85rem var(--content-pad) .7rem;
  box-shadow: 0 1px 12px rgba(27,79,138,0.10);
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: .65rem;
  width: 100%;
  min-height: 54px;
  box-sizing: border-box;
}
.page-header h5 {
  margin: 0;
  font-weight: 800;
  font-size: 1rem;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}

.page-header .btn { flex-shrink: 0; }

.content-wrapper,
.main-content > [class*="px-"],
.main-content > .container {
  box-sizing: border-box;
  width: 100%;
  padding-left: var(--content-pad);
  padding-right: var(--content-pad);
}

@media (max-width: 767px) {
  :root {
    --content-pad: 1rem;
  }

  body { padding-bottom: 1rem; }

  .page-header { padding: .75rem 1rem .6rem; min-height: 52px; }

  .stat-card  { padding: .85rem; gap: .65rem; }
  .stat-icon  { width: 40px; height: 40px; font-size: 1rem; }

  .offcanvas-bottom {
    border-radius: 20px 20px 0 0;
    max-height: 92vh;
  }
  .modal-dialog { margin: .75rem; }
}

@media (max-width: 400px) {
  :root { --content-pad: .75rem; }

  .page-header h5 { font-size: .9rem; }
  .btn-sm { font-size: .75rem; padding: .3rem .65rem; }
}

@media (min-width: 768px) {
  :root {
    --sidebar-w:   240px;
    --content-pad: 1.5rem;
    --content-max: none;
  }

  body { padding-bottom: 0; }

  .hamburger-btn { display: none !important; }
  .sidebar-backdrop { display: none !important; }
  .sidebar-close-btn { display: none !important; }

  #sidebar,
  #sidebar.sidebar-mobile {
    display: flex !important;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0;
    width: var(--sidebar-w);
    height: 100vh;
    background: rgba(255,255,255,0.97);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    box-shadow: 2px 0 16px rgba(27,79,138,0.10);
    padding: 1.5rem 1rem;
    padding-top: calc(1.5rem + env(safe-area-inset-top, 0px));
    padding-left:  calc(1rem  + env(safe-area-inset-left, 0px));
    z-index: 200;
    overflow-y: auto;
    overflow-x: hidden;
    transform: none;
    max-width: none;
  }

  .main-content {
    margin-left: var(--sidebar-w);
    width: calc(100% - var(--sidebar-w));
    min-height: 100vh;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;

    padding-top: env(safe-area-inset-top, 0px);
  }

  .page-header { padding: .9rem var(--content-pad) .75rem; min-height: 56px; }
  .page-header h5 { font-size: 1.05rem; }
}

@media (min-width: 1024px) {
  :root {
    --sidebar-w:   260px;
    --content-pad: 2rem;
  }

  #sidebar { padding: 1.75rem 1.1rem; }
  .page-header h5 { font-size: 1.1rem; }
}

@media (min-width: 1440px) {
  :root {
    --sidebar-w:   280px;
    --content-pad: 2.5rem;
    --content-max: 1400px;
  }

  .sidebar-logo span { font-size: 1.05rem; }
  .sidebar-nav-item  { font-size: .92rem; padding: .62rem 1rem; }

  .content-wrapper,
  .main-content > [class*="px-"],
  .main-content > .container {
    max-width: var(--content-max);
    margin-left: auto;
    margin-right: auto;
  }
}

@media (min-width: 1920px) {
  :root {
    --sidebar-w:   300px;
    --content-pad: 3rem;
    --content-max: 1600px;
  }

  #sidebar { padding: 2rem 1.5rem; }
  .page-header { padding: 1.1rem var(--content-pad) .9rem; }
  .sidebar-nav-item { font-size: .95rem; }
}

@media (min-width: 2560px) {
  :root {
    --sidebar-w:   320px;
    --content-pad: 4rem;
    --content-max: 2000px;
  }

  html { font-size: 18px; }
}

body { overflow-x: hidden; }

.allergy-alert-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #fef3c7;
  border: 2px solid #fbbf24;
  color: #d97706;
  cursor: pointer;
  font-size: 1.1rem;
  flex-shrink: 0;
  transition: background .2s, transform .2s;
  animation: allergy-pulse 2.5s ease-in-out infinite;
}

.allergy-alert-btn:hover,
.allergy-alert-btn:focus {
  background: #fde68a;
  transform: scale(1.1);
  outline: none;
}

@keyframes allergy-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(251, 191, 36, .5); }
  50%       { box-shadow: 0 0 0 6px rgba(251, 191, 36, 0); }
}

.allergy-tooltip {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  min-width: 220px;
  max-width: 300px;
  background: #fff;
  border: 1.5px solid #fbbf24;
  border-radius: 14px;
  box-shadow: 0 8px 32px rgba(27, 79, 138, .15);
  padding: .85rem 1rem;
  z-index: 1100;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px);
  transition: opacity .2s ease, transform .2s ease, visibility .2s;
  pointer-events: none;
}

.allergy-tooltip.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  pointer-events: auto;
}

.allergy-tooltip-title {
  font-size: .75rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: #d97706;
  margin-bottom: .5rem;
  display: flex;
  align-items: center;
  gap: .35rem;
}

.allergy-tooltip-item {
  font-size: .82rem;
  font-weight: 600;
  color: var(--text-primary);
  padding: .2rem 0;
  border-bottom: 1px solid var(--gray-100);
  display: flex;
  align-items: baseline;
  gap: .4rem;
}
.allergy-tooltip-item:last-child { border-bottom: none; }

.allergy-tooltip-item .allergy-type-badge {
  font-size: .68rem;
  font-weight: 700;
  background: #fef3c7;
  color: #92400e;
  border-radius: 6px;
  padding: .1rem .4rem;
  white-space: nowrap;
  flex-shrink: 0;
}

.allergy-tooltip-footer {
  margin-top: .55rem;
  font-size: .75rem;
  color: var(--text-hint);
  text-align: center;
  cursor: pointer;
  font-weight: 700;
}
.allergy-tooltip-footer:hover { color: var(--primary); }

.allergy-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: .75rem;
}

.allergy-card {
  background: #fff;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--card-radius);
  padding: .9rem 1rem;
  margin-bottom: .6rem;
  display: flex;
  align-items: flex-start;
  gap: .75rem;
  transition: box-shadow .2s;
}
.allergy-card:hover { box-shadow: var(--card-shadow); }

.allergy-card-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: #fef3c7;
  color: #d97706;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}

.allergy-card-body { flex: 1; min-width: 0; }

.allergy-card-description {
  font-size: .92rem;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: .15rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.allergy-card-meta {
  font-size: .78rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-wrap: wrap;
}

.allergy-type-pill {
  background: #fef3c7;
  color: #92400e;
  border-radius: 8px;
  padding: .1rem .55rem;
  font-size: .72rem;
  font-weight: 700;
}

.allergy-card-actions {
  display: flex;
  gap: .4rem;
  flex-shrink: 0;
}

.btn-allergy-edit,
.btn-allergy-remove {
  border: none;
  border-radius: 9px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .82rem;
  cursor: pointer;
  transition: background .2s, transform .15s;
}
.btn-allergy-edit   { background: var(--primary-light); color: var(--primary); }
.btn-allergy-remove { background: #fee2e2; color: var(--danger); }
.btn-allergy-edit:hover   { background: #c7d7fb; transform: scale(1.08); }
.btn-allergy-remove:hover { background: #fecaca; transform: scale(1.08); }

.gestao-tabs {
  display: flex;
  gap: .35rem;
  background: var(--gray-100);
  border-radius: 14px;
  padding: .3rem;
  margin-bottom: 1.1rem;
}

.gestao-tab-btn {
  flex: 1;
  border: none;
  background: transparent;
  border-radius: 10px;
  padding: .45rem .3rem;
  font-family: Outfit, 'Segoe UI', sans-serif;
  font-size: .78rem;
  font-weight: 700;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background .2s, color .2s, box-shadow .2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .3rem;
  white-space: nowrap;
}

.gestao-tab-btn:hover {
  background: rgba(255,255,255,.7);
  color: var(--text-primary);
}

.gestao-tab-btn.active {
  background: #fff;
  color: var(--primary);
  box-shadow: 0 2px 8px rgba(27,79,138,.13);
}

.gestao-tab-btn.active.tab-alergias {
  color: #d97706;
}

.gestao-tab-btn .tab-badge {
  font-size: .65rem;
  font-weight: 800;
  background: #fee2e2;
  color: var(--danger);
  border-radius: 99px;
  padding: .05rem .38rem;
  line-height: 1.4;
}

.gestao-tab-panel {
  display: none;
}
.gestao-tab-panel.active {
  display: block;
}

/* ── Seletor de paciente global (todas as abas) ────────────── */
.patient-selector-bar {
  display: flex;
  align-items: center;
  gap: .55rem;
  background: linear-gradient(135deg, var(--primary-light), #f0f7ff);
  border: 1.5px solid var(--gray-200);
  border-radius: 14px;
  padding: .45rem .85rem;
  margin: .4rem .9rem .2rem;
}

.patient-selector-label {
  font-size: .72rem;
  font-weight: 700;
  color: var(--text-hint);
  text-transform: uppercase;
  letter-spacing: .05em;
  white-space: nowrap;
  margin: 0;
}

.patient-selector-select {
  flex: 1;
  border-radius: 10px;
  font-weight: 700;
  border: 1.5px solid var(--gray-200);
  font-size: .85rem;
  color: var(--text-primary);
  padding: .25rem .6rem;
  background-color: #fff;
}

.patient-selector-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(30,58,95,.1);
  outline: none;
}

#patient-selector-container {
  transition: all .2s ease;
}
