:root {
  --bg: #f6f9fa;
  --surface: #ffffff;
  --text: #1f2d3a;
  --muted: #62778a;
  --border: #d9e4ea;
  --primary: #167c86;
  --primary-hover: #106670;
  --tint: #e9f4f5;
  --tint-strong: #d3eaec;
  --danger: #b4343c;
  --danger-bg: #fdf1f2;
  --success: #1f7a4d;
  --success-bg: #eef8f2;
  --ring: rgba(22, 124, 134, 0.22);
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

h1 { margin: 0 0 6px; font-size: 1.6rem; font-weight: 650; letter-spacing: -0.01em; line-height: 1.25; }
a { color: var(--primary); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--primary-hover); }

/* ---------- Brand ---------- */
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 650; font-size: 1.25rem; letter-spacing: -0.01em; color: var(--text); }
.brand-mark { display: grid; place-items: center; width: 36px; height: 36px; color: #fff; background: var(--primary); border-radius: 10px; }
.brand-mark svg { width: 20px; height: 20px; }
.brand span { color: var(--primary); }

/* ---------- Auth layout: calm panel + form ---------- */
.auth-layout { min-height: 100vh; display: grid; grid-template-columns: minmax(320px, 5fr) 6fr; }

.auth-aside {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 32px;
  padding: 48px;
  background:
    radial-gradient(circle at 15% 10%, rgba(255, 255, 255, 0.9), transparent 55%),
    linear-gradient(160deg, var(--tint) 0%, var(--tint-strong) 100%);
  border-right: 1px solid var(--border);
}
.aside-title { margin: 0 0 12px; font-size: 1.9rem; font-weight: 650; line-height: 1.2; letter-spacing: -0.02em; max-width: 16ch; }
.aside-text { margin: 0; color: var(--muted); max-width: 38ch; }
.aside-points { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.aside-points li { display: flex; gap: 12px; align-items: flex-start; font-size: 0.95rem; color: var(--text); }
.aside-points .icon { flex: 0 0 auto; display: grid; place-items: center; width: 32px; height: 32px; color: var(--primary); background: var(--surface); border-radius: 50%; box-shadow: 0 1px 2px rgba(31, 45, 58, 0.08); }
.aside-points svg { width: 16px; height: 16px; }
.aside-note { margin: 0; color: var(--muted); font-size: 0.8rem; }

.auth-main { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 40px 24px; }
.auth-main .brand.mobile { display: none; margin-bottom: 24px; }
.card { width: 100%; max-width: 440px; }
.card.wide { max-width: 520px; }
.subtitle { margin: 0 0 24px; color: var(--muted); font-size: 0.97rem; }
.footer-link { margin: 24px 0 0; color: var(--muted); font-size: 0.95rem; text-align: center; }

/* ---------- Forms ---------- */
.form-section { margin: 26px 0 14px; padding-bottom: 8px; color: var(--primary); font-size: 0.78rem; font-weight: 650; letter-spacing: 0.08em; text-transform: uppercase; border-bottom: 1px solid var(--border); }
.form-section:first-of-type { margin-top: 0; }

.field { margin-bottom: 18px; flex: 1; min-width: 0; }
.row { display: flex; gap: 16px; align-items: flex-start; }
.row > .field { flex: 1 1 0; min-width: 0; margin-bottom: 18px; }
.row.row-uf > .field:last-child,
.row > .field-uf { flex: 0 0 104px; }

label { display: block; margin-bottom: 7px; font-size: 0.88rem; font-weight: 600; }

input, select {
  width: 100%;
  min-height: 46px;
  padding: 10px 14px;
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color 0.15s, box-shadow 0.15s;
}
input::placeholder { color: #9aacb9; }
input:hover, select:hover { border-color: #b9cad4; }
input:focus, select:focus, .btn:focus-visible {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--ring);
}
input[aria-invalid="true"], select[aria-invalid="true"] { border-color: var(--danger); background: var(--danger-bg); }
input[aria-invalid="true"]:focus, select[aria-invalid="true"]:focus { box-shadow: 0 0 0 4px rgba(180, 52, 60, 0.15); }

.code-input { text-align: center; font-size: 1.6rem; font-weight: 600; letter-spacing: 0.5em; padding-left: 0.5em; }

.hint { margin: 6px 0 0; color: var(--muted); font-size: 0.82rem; }
/* Feedback: sempre ícone + texto (cor sozinha não basta) */
:root { --icon-error: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='9.5'/%3E%3Cpath d='M12 7.5v5.5M12 16.6h.01'/%3E%3C/svg%3E"); --icon-ok: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='9.5'/%3E%3Cpath d='M7.8 12.4l2.9 2.9 5.5-5.8'/%3E%3C/svg%3E"); }
.field .field-error { display: flex; gap: 6px; align-items: flex-start; margin: 6px 0 0; color: var(--danger); font-size: 0.85rem; line-height: 1.35; }
.field-error::before { content: ""; flex: 0 0 auto; width: 15px; height: 15px; margin-top: 1px; background: currentColor; -webkit-mask: var(--icon-error) center / contain no-repeat; mask: var(--icon-error) center / contain no-repeat; }

.alert { position: relative; display: flex; align-items: flex-start; gap: 12px; margin-bottom: 20px; padding: 13px 14px; color: var(--danger); background: var(--danger-bg); border: 1px solid #f0cdd0; border-radius: var(--radius); font-size: 0.92rem; line-height: 1.4; }
.alert::before { content: ""; flex: 0 0 auto; width: 20px; height: 20px; background: currentColor; -webkit-mask: var(--icon-error) center / contain no-repeat; mask: var(--icon-error) center / contain no-repeat; }
.alert.success { color: var(--success); background: var(--success-bg); border-color: #cfe8da; }
.alert.success::before { -webkit-mask-image: var(--icon-ok); mask-image: var(--icon-ok); }
.alert-body { flex: 1; min-width: 0; }
.alert-title { display: block; font-weight: 650; }
.alert .alert-text { margin: 2px 0 0; color: var(--text); }
.alert-close { flex: 0 0 auto; width: 28px; height: 28px; margin: -4px -6px -4px 0; color: var(--muted); font-size: 1.3rem; line-height: 1; background: none; border: 0; border-radius: 6px; cursor: pointer; }
.alert-close:hover { color: var(--text); background: rgba(31, 45, 58, 0.08); }
.alert-close:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--ring); }

/* Notificações (toasts): canto inferior direito (não cobre os botões do topo); no celular, largura total */
.toasts { position: fixed; z-index: 1000; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 10px; width: min(420px, calc(100vw - 32px)); pointer-events: none; }
.toast { margin: 0; overflow: hidden; pointer-events: auto; box-shadow: 0 10px 30px rgba(31, 45, 58, 0.18); animation: toast-in 0.25s ease-out; }
.toast.is-leaving { opacity: 0; transform: translateY(6px); transition: opacity 0.2s, transform 0.2s; }
.toast-timer { position: absolute; left: 0; bottom: 0; width: 100%; height: 3px; background: currentColor; opacity: 0.35; transform-origin: left; animation: toast-timer 7s linear forwards; }
.toast:hover .toast-timer, .toast:focus-within .toast-timer { animation-play-state: paused; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes toast-timer { from { transform: scaleX(1); } to { transform: scaleX(0); } }
@media (prefers-reduced-motion: reduce) { .toast { animation: none; } .toast.is-leaving { transition: none; } }
@media (max-width: 640px) { .toasts { bottom: 12px; right: 16px; left: 16px; width: auto; } }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 46px; padding: 10px 20px; font: inherit; font-weight: 600; border: 1px solid transparent; border-radius: var(--radius); cursor: pointer; transition: background 0.15s, border-color 0.15s; }
.btn-primary { width: 100%; margin-top: 8px; color: #fff; background: var(--primary); box-shadow: 0 1px 2px rgba(16, 102, 112, 0.25); }
.btn-primary:hover { background: var(--primary-hover); }
/* Link-buttons ("Novo conselho", "Novo profissional"): no hover effect; keeps a:hover from recoloring the text. */
a.btn-primary:hover { color: #fff; background: var(--primary); }
.btn:disabled, .btn:disabled:hover { cursor: not-allowed; color: #5b6f80; background: #e4ebef; border-color: var(--border); box-shadow: none; }
.btn-secondary { min-height: 40px; padding: 8px 16px; color: var(--text); background: var(--surface); border-color: var(--border); }
.btn-secondary:hover { background: var(--tint); border-color: var(--tint-strong); }
.btn-link { width: 100%; margin-top: 10px; color: var(--primary); background: none; }
.btn-link:hover { background: var(--tint); }

/* ---------- App shell (logged in) ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 12px 32px; background: var(--surface); border-bottom: 1px solid var(--border); }
.topbar-user { display: flex; align-items: center; gap: 14px; }
.avatar { display: grid; place-items: center; width: 36px; height: 36px; color: var(--primary); background: var(--tint); border-radius: 50%; font-weight: 650; font-size: 0.9rem; }
.user-name { color: var(--muted); font-size: 0.93rem; }
.page { max-width: 960px; margin: 0 auto; padding: 40px 24px; }
.welcome { padding: 28px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; }
.welcome .subtitle { margin: 0; }

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .auth-layout { grid-template-columns: 1fr; }
  .auth-aside { display: none; }
  .auth-main { justify-content: flex-start; padding-top: 32px; }
  .auth-main .brand.mobile { display: inline-flex; }
}
@media (max-width: 480px) {
  .user-name { display: none; }
  .topbar { padding: 12px 16px; }
  .row { flex-direction: column; gap: 0; }
  .row > .field { flex: 1; width: 100%; }
  .row.row-uf > .field:last-child { flex: 1; width: 100%; }
}

/* ---------- Admin panel (sidebar layout) ---------- */
.app-layout { min-height: 100vh; display: grid; grid-template-columns: 264px 1fr; }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 8px; padding: 20px 14px; background: var(--surface); border-right: 1px solid var(--border); }
.sidebar-brand { padding: 4px 10px 18px; }
.sidebar-nav { flex: 1; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.nav-heading { margin: 18px 10px 6px; color: var(--muted); font-size: 0.72rem; font-weight: 650; letter-spacing: 0.08em; text-transform: uppercase; }
.nav-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; color: var(--text); font-size: 0.95rem; font-weight: 500; text-decoration: none; border-radius: var(--radius); }
.nav-item svg { flex: 0 0 auto; width: 18px; height: 18px; color: var(--muted); }
.nav-item:hover { background: var(--bg); color: var(--text); }
.nav-item.active { color: var(--primary); background: var(--tint); font-weight: 600; }
.nav-item.active svg { color: var(--primary); }
.sidebar-user { display: flex; align-items: center; gap: 10px; padding: 14px 8px 0; border-top: 1px solid var(--border); }
.sidebar-user-info { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.sidebar-user-info strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.9rem; }
.sidebar-user-info span { color: var(--muted); font-size: 0.78rem; }
.logout-icon { display: none; }

.app-main { min-width: 0; max-width: 1360px; width: 100%; margin-inline: auto; padding: 36px 40px 56px; }
.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.page-header .subtitle { margin: 0; }
.breadcrumb { margin: 0 0 6px; color: var(--muted); font-size: 0.85rem; }
.btn-inline { width: auto; margin-top: 0; text-decoration: none; white-space: nowrap; }
.btn-sm { min-height: 34px; padding: 6px 12px; font-size: 0.86rem; text-decoration: none; }
a.btn-secondary { color: var(--text); }

.toolbar { display: flex; gap: 10px; margin-bottom: 16px; }
.toolbar input { flex: 1; }
.toolbar select { width: auto; min-width: 130px; }

.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; }
.table { width: 100%; border-collapse: collapse; font-size: 0.94rem; }
.table th, .table td { padding: 14px 16px; text-align: left; border-bottom: 1px solid var(--border); }
.table thead th { color: var(--muted); background: var(--bg); font-size: 0.78rem; font-weight: 650; letter-spacing: 0.06em; text-transform: uppercase; }
.table tbody tr:last-child > * { border-bottom: 0; }
.table tbody tr:hover { background: #fafcfc; }
.table tbody th { font-weight: 650; }
.col-actions { text-align: right !important; white-space: nowrap; }
.inline-form { display: inline; }

.badge { display: inline-block; padding: 3px 10px; font-size: 0.78rem; font-weight: 600; border-radius: 999px; }
.badge-ok { color: var(--success); background: var(--success-bg); }
.badge-off { color: var(--muted); background: #eef2f4; }

.empty { padding: 48px 24px; text-align: center; background: var(--surface); border: 1px dashed var(--border); border-radius: 12px; }
.empty p { margin: 0 0 4px; }
.table-wrap + .hint { margin-top: 12px; }

.panel-form { max-width: 520px; padding: 28px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; }
.check { display: flex; align-items: center; gap: 10px; margin: 0; font-weight: 500; cursor: pointer; }
.check input { width: 18px; min-height: 18px; height: 18px; accent-color: var(--primary); }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }
.form-actions .btn-primary { margin-top: 0; }

.nav-toggle, .nav-burger, .nav-scrim { display: none; }

@media (max-width: 860px) {
  .app-layout { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 30; inset: 0 auto 0 0; width: 264px; transform: translateX(-100%); transition: transform 0.2s; }
  .nav-toggle:checked ~ .sidebar { transform: none; box-shadow: 0 0 40px rgba(31, 45, 58, 0.18); }
  .nav-toggle:checked ~ .nav-scrim { display: block; position: fixed; z-index: 20; inset: 0; background: rgba(31, 45, 58, 0.3); }
  .nav-burger { display: grid; place-items: center; position: fixed; z-index: 10; top: 12px; left: 12px; width: 42px; height: 42px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); cursor: pointer; }
  .nav-burger span, .nav-burger span::before, .nav-burger span::after { display: block; width: 18px; height: 2px; background: var(--text); border-radius: 2px; content: ""; }
  .nav-burger span { position: relative; }
  .nav-burger span::before { position: absolute; top: -6px; }
  .nav-burger span::after { position: absolute; top: 6px; }
  .nav-toggle:focus-visible ~ .nav-burger { box-shadow: 0 0 0 4px var(--ring); }
  .app-main { padding: 68px 16px 40px; }
  .page-header { flex-direction: column; }
  .toolbar { flex-wrap: wrap; }
}

.filter-count { align-self: center; margin: 0 0 0 auto; color: var(--muted); font-size: 0.85rem; white-space: nowrap; }
[hidden] { display: none !important; }

.cell-sub { display: block; color: var(--muted); font-size: 0.82rem; font-weight: 400; }
.badge-warn { color: #8a5a00; background: #fdf4e0; }
.detail { max-width: 640px; }
.detail .form-section { margin-top: 0; }
.detail .form-section:not(:first-child) { margin-top: 28px; }
.detail-list { margin: 0; display: grid; gap: 14px; }
.detail-list dt { color: var(--muted); font-size: 0.82rem; }
.muted { color: var(--muted); }
.badge-info { color: var(--primary); background: var(--tint); }
.btn-icon { width: 16px; height: 16px; margin-right: 8px; }

/* ---------- Patient detail cards & hero ---------- */
.patient-detail-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 18px;
  margin-bottom: 20px;
  background: linear-gradient(135deg, var(--tint) 0%, var(--surface) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.patient-avatar {
  flex: 0 0 auto;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 1.25rem;
  font-weight: 650;
  box-shadow: 0 2px 8px rgba(22, 124, 134, 0.25);
}
.patient-header-info { min-width: 0; flex: 1; }
.patient-header-info h3 { margin: 0; font-size: 1.25rem; font-weight: 650; color: var(--text); }
.patient-header-tags { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 6px; }

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px 16px;
  margin-bottom: 20px;
}
.detail-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color 0.15s, background-color 0.15s;
}
.detail-card:hover {
  background: var(--surface);
  border-color: #b9cad4;
}
.detail-card-label {
  font-size: 0.74rem;
  font-weight: 650;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.detail-card-value {
  font-size: 0.95rem;
  font-weight: 550;
  color: var(--text);
  word-break: break-word;
}
@media (max-width: 500px) {
  .detail-grid { grid-template-columns: 1fr; gap: 10px; }
  .patient-detail-header { flex-direction: column; align-items: flex-start; }
}
.profile-hero { display: flex; align-items: center; gap: 20px; max-width: 640px; margin-bottom: 20px; padding: 24px 28px; background: linear-gradient(160deg, var(--tint) 0%, var(--surface) 70%); border: 1px solid var(--border); border-radius: 12px; }
.avatar-lg { flex: 0 0 auto; width: 72px; height: 72px; font-size: 1.7rem; color: #fff; background: var(--primary); }
.profile-hero-info { min-width: 0; }
.profile-hero-info h2 { margin: 0; font-size: 1.3rem; overflow-wrap: anywhere; }
.profile-hero-info p { margin: 2px 0 0; color: var(--muted); overflow-wrap: anywhere; }
.profile-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 10px !important; }
.chip { padding: 3px 10px; color: var(--primary); background: var(--surface); border: 1px solid var(--tint-strong); border-radius: 999px; font-size: 0.82rem; font-weight: 600; }
@media (max-width: 480px) { .profile-hero { flex-direction: column; align-items: flex-start; padding: 20px; } }
h2.form-section { margin-bottom: 14px; }

/* ---------- Modal (<dialog>) ---------- */
.modal { width: min(580px, calc(100vw - 32px)); max-height: calc(100vh - 48px); padding: 0; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: 0 20px 60px rgba(31, 45, 58, 0.25); }
.modal::backdrop { background: rgba(31, 45, 58, 0.4); }
.modal[open] { display: flex; flex-direction: column; }
.modal-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 24px 28px 16px; }
.modal-header h2 { margin: 0; font-size: 1.25rem; }
.modal-header .subtitle { margin: 2px 0 0; }
.modal-close { flex: 0 0 auto; width: 36px; height: 36px; color: var(--muted); font-size: 1.5rem; line-height: 1; background: none; border: 0; border-radius: 8px; cursor: pointer; }
.modal-close:hover { background: var(--tint); color: var(--text); }
.modal-close:focus-visible { outline: none; box-shadow: 0 0 0 4px var(--ring); }
.modal-body { padding: 4px 28px 10px; overflow-y: auto; }
.modal-body .form-section:first-of-type { margin-top: 14px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 12px; padding: 18px 28px 22px; border-top: 1px solid var(--border); }
.modal-hint { margin: 0 auto 0 0; align-self: center; color: var(--muted); font-size: 0.85rem; }
.modal-form { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.modal-sm { width: min(440px, calc(100vw - 32px)); }
.modal-body p { margin: 0 0 12px; }

/* ---------- Painel de métricas (admin) ---------- */
/* Indicadores: grade que se ajusta à largura, 4 colunas no desktop e 1 no celular. */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; margin-bottom: 20px; }
.kpi { display: flex; flex-direction: column; gap: 2px; padding: 18px 20px; color: var(--text); text-decoration: none; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; transition: border-color 0.15s, box-shadow 0.15s; }
.kpi:hover { color: var(--text); border-color: var(--primary); box-shadow: 0 2px 8px rgba(31, 45, 58, 0.08); }
.kpi:focus-visible { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px var(--ring); }
.kpi-label { color: var(--muted); font-size: 0.85rem; font-weight: 600; }
.kpi-value { font-size: 2rem; font-weight: 650; line-height: 1.15; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.kpi-hint { color: var(--muted); font-size: 0.82rem; }
/* O tom aparece só num filete lateral; o texto continua na cor normal (nunca só cor para dizer o estado). */
.kpi-ok { border-left: 4px solid var(--success); }
.kpi-warn { border-left: 4px solid #d99a1c; }
.kpi-off { border-left: 4px solid #aab8c2; }

/* Cartões dos gráficos (prefixo metric- para não colidir com o .card do login): lado a lado no desktop, empilhados no celular. */
.metric-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
.metric-card { padding: 22px 24px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; }
.metric-title { margin: 0; font-size: 1.05rem; }
.metric-subtitle { margin: 2px 0 18px; color: var(--muted); font-size: 0.85rem; }

/* Barras horizontais: [nome] [trilha com barra] [número + %]. */
.bars { margin: 0; padding: 0; list-style: none; display: grid; gap: 10px; }
.bar-row { display: grid; grid-template-columns: minmax(48px, 84px) 1fr auto; align-items: center; gap: 12px; padding: 2px 0; font-size: 0.92rem; }
.bar-label { font-weight: 600; overflow-wrap: anywhere; }
.bar-label a { text-decoration: none; }
.bar-label a:hover { text-decoration: underline; }
.bar-track { height: 8px; background: var(--bg); border-radius: 4px; overflow: hidden; }
.bar-fill { display: block; height: 100%; min-width: 4px; background: var(--primary); border-radius: 0 4px 4px 0; }
.bar-row:hover .bar-fill { background: var(--primary-hover); }
.bar-value { min-width: 64px; text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.bar-percent { margin-left: 4px; color: var(--muted); font-weight: 400; font-size: 0.82rem; }

/* ---------- Patient Modular Cards (Photo 1 reference with multiple cards) ---------- */
.patient-card {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(31, 45, 58, 0.04);
}

.patient-card-profile {
  padding: 32px 36px;
}

.patient-hero {
  display: flex;
  align-items: center;
  gap: 22px;
}

.patient-hero-avatar {
  flex: 0 0 70px;
  width: 70px;
  height: 70px;
  border-radius: 50%;
  background: #ede9fe;
  color: #7c3aed;
  display: grid;
  place-items: center;
  font-size: 1.65rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.patient-hero-info {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.patient-hero-name {
  margin: 0;
  font-size: 1.55rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.25;
}

.patient-hero-email {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.92rem;
  text-decoration: none;
  transition: color 0.15s;
}

.patient-hero-email:hover {
  color: var(--primary);
}

.patient-hero-email .email-icon {
  width: 16px;
  height: 16px;
  color: var(--muted);
  flex-shrink: 0;
}

.separator-dashed {
  border-top: 1px dashed var(--border);
  margin: 26px 0;
}

.patient-meta-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 28px 24px;
}

.meta-col {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.meta-label {
  font-size: 0.72rem;
  font-weight: 650;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.meta-value {
  font-size: 0.98rem;
  font-weight: 600;
  color: var(--text);
  word-break: break-word;
}

/* Grids dos painéis inferiores (Cards independentes) */
.patient-panels-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 24px;
  margin-top: 24px;
}

.patient-card-panel {
  padding: 28px 32px;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 38px;
  margin-bottom: 22px;
  padding-bottom: 14px;
  border-bottom: 1px dashed var(--border);
}

.panel-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.new-chat-form {
  margin: 0;
  padding: 0;
  display: inline-flex;
}

.btn-new-chat {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  font-size: 0.82rem;
  font-weight: 600;
  font-family: inherit;
  color: #ffffff;
  background-color: var(--primary);
  border: 1px solid var(--primary);
  border-radius: 8px;
  text-decoration: none;
  line-height: 1.4;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-new-chat:hover {
  background-color: var(--primary-hover);
  border-color: var(--primary-hover);
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(22, 124, 134, 0.25);
}

.btn-new-chat .btn-icon-svg {
  width: 14px;
  height: 14px;
}

.panel-title {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.badge-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 20px;
  padding: 0 7px;
  font-size: 0.75rem;
  font-weight: 700;
  border-radius: 999px;
  background: #e6f7f5;
  color: #167c86;
}

.panel-items-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 252px;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  padding: 2px 6px 2px 2px;
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 transparent;
}

.panel-items-list::-webkit-scrollbar {
  width: 6px;
}

.panel-items-list::-webkit-scrollbar-track {
  background: transparent;
}

.panel-items-list::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 999px;
}

.panel-items-list::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

.panel-item {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 14px 18px;
  border-radius: 10px;
  background: #fbfcfd;
  border: 1px solid #edf2f7;
  text-decoration: none;
  transition: all 0.15s ease;
}

a.panel-item:hover {
  background: #ffffff;
  border-color: var(--primary);
  box-shadow: 0 4px 12px rgba(22, 124, 134, 0.08);
}

a.panel-item:hover .item-title {
  color: var(--primary);
}

.item-avatar {
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: grid;
  place-items: center;
}

.item-avatar-chat {
  background: #ede9fe;
  color: #7c3aed;
}

.item-avatar-rx {
  background: #ede9fe;
  color: #7c3aed;
}

.item-icon {
  width: 20px;
  height: 20px;
}

.item-initials {
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.item-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  flex: 1;
}

.item-title {
  font-size: 0.94rem;
  font-weight: 650;
  color: var(--text);
  line-height: 1.4;
  overflow-wrap: break-word;
  transition: color 0.15s;
}

.item-subtitle {
  font-size: 0.82rem;
  font-weight: 400;
  color: var(--muted);
  line-height: 1.35;
}

@media (max-width: 1080px) {
  .patient-panels-grid {
    grid-template-columns: 1fr;
    gap: 20px;
  }
}

@media (max-width: 860px) {
  .patient-card-profile,
  .patient-card-panel {
    padding: 24px 20px;
  }
  .patient-meta-row {
    grid-template-columns: repeat(2, 1fr);
    gap: 18px 16px;
  }
  .panel-item {
    padding: 12px 14px;
    gap: 14px;
  }
}

@media (max-width: 480px) {
  .patient-hero {
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
  }
  .patient-meta-row {
    grid-template-columns: 1fr;
    gap: 14px;
  }
}
