/* =============================================================================
   Plataforma Fisio — layouts and components (built on tokens.css + theme.css).
   Sections: 1 primitives · 2 shells (public, auth, patient, admin) · 3 shared components ·
   4 public pages · 5 patient pages · 6 admin pages · 7 motion · 8 print.
   ========================================================================== */

/* === 1. Primitives ========================================================== */
.container { --bs-gutter-x: 2rem; }
@media (min-width: 1400px) { .container { max-width: var(--container-max); } }
.min-w-0 { min-width: 0; }
.eyebrow {
  display: inline-flex; align-items: center; gap: 0.5rem; margin-bottom: 0.75rem;
  font-size: var(--fs-sm); font-weight: var(--fw-semibold); letter-spacing: var(--tracking-caps);
  text-transform: uppercase; color: var(--primary-700);
}
.prose { max-width: var(--measure); font-size: var(--fs-md); line-height: 1.7; }
.prose h2, .prose h3, .prose h4 { margin-top: 2rem; margin-bottom: 0.75rem; }
.prose h2 { font-size: var(--fs-xl); } .prose h3 { font-size: var(--fs-lg); }
.prose ul, .prose ol { padding-left: 1.25rem; } .prose li { margin-bottom: 0.375rem; }
.prose li::marker { color: var(--primary-600); }
.prose.small, .small .prose { font-size: var(--fs-sm); line-height: 1.6; }
.chips { display: flex; flex-wrap: wrap; gap: 0.5rem; padding: 0; margin: 0; list-style: none; }
.chips li, .chip {
  display: inline-flex; align-items: center; gap: 0.375rem; padding: 0.375rem 0.875rem;
  border-radius: var(--radius-pill); background: var(--primary-50); color: var(--primary-900);
  border: 1px solid var(--primary-100); font-size: var(--fs-sm); font-weight: var(--fw-medium);
}
.hp-field { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.illustration { width: 4.5rem; height: 4.5rem; object-fit: contain; }

/* Demo database banner (D-113): slim, always visible, not dismissable. */
:root { --banner-h: 0px; }
.has-demo-banner { --banner-h: 1.75rem; }
.demo-banner {
  position: sticky; top: 0; z-index: var(--z-banner); height: var(--banner-h); line-height: var(--banner-h);
  background: #7C2D12; color: #fff; text-align: center; font-size: 0.8125rem; font-weight: var(--fw-semibold);
  padding: 0 0.5rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* Brand lock-up (logo + name that may wrap; never forces horizontal scroll). */
.brand { display: inline-flex; align-items: center; gap: 0.625rem; min-width: 0; color: var(--neutral-900); text-decoration: none; }
.brand:hover { color: var(--neutral-900); }
.brand-logo { height: 2.5rem; width: auto; flex-shrink: 0; }
.brand__text { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.brand__name { font-weight: var(--fw-bold); font-size: 1rem; letter-spacing: -0.01em; white-space: normal; }
.brand__tagline { font-size: var(--fs-xs); color: var(--text-muted); font-weight: var(--fw-medium); white-space: normal; }
@media (max-width: 380px) { .brand-logo { height: 2.125rem; } .brand__name { font-size: 0.9375rem; } }

/* Frosted bars: translucent + blur once the page scrolls (js/ui.js adds .is-scrolled). */
.frosted, [data-nav-scroll].is-scrolled { background-color: rgb(255 255 255 / 0.78); -webkit-backdrop-filter: var(--glass-blur); backdrop-filter: var(--glass-blur); }
@supports not ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
  .frosted, [data-nav-scroll].is-scrolled { background-color: var(--surface); }
}
.glass {
  background: var(--glass-bg); border: 1px solid var(--glass-border); box-shadow: var(--shadow-md);
  -webkit-backdrop-filter: var(--glass-blur); backdrop-filter: var(--glass-blur);
}
@supports not ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) { .glass { background: rgb(255 255 255 / 0.95); } }

/* === 2. Shells ================================================================ */

/* --- 2a. Public header --- */
.site-header {
  position: sticky; top: var(--banner-h); z-index: var(--z-nav);
  background: rgb(255 255 255 / 0.96); border-bottom: 1px solid transparent;
  transition: background-color var(--dur) var(--ease), border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.site-header.is-scrolled { border-bottom-color: rgb(226 232 240 / 0.8); box-shadow: var(--shadow-sm); }
.site-header .navbar { min-height: var(--header-h); padding-block: 0.5rem; }
.site-header .navbar > .container { flex-wrap: nowrap; gap: 0.75rem; }
.site-header .navbar-brand { margin-right: 0; padding: 0; white-space: normal; flex: 0 1 auto; }
.site-header__toggler {
  display: inline-flex; align-items: center; justify-content: center; width: var(--tap); height: var(--tap);
  padding: 0; border: 1px solid var(--border); border-radius: var(--radius-md); color: var(--neutral-800); flex-shrink: 0;
}
.site-header__toggler:focus { box-shadow: var(--focus-ring); }
.site-header__toggler[aria-expanded="true"] .site-header__icon-open,
.site-header__toggler[aria-expanded="false"] .site-header__icon-close,
.site-header__toggler:not([aria-expanded]) .site-header__icon-close { display: none; }
.site-nav { gap: 0.125rem; }
.site-nav .nav-link {
  position: relative; display: inline-flex; align-items: center; gap: 0.375rem; min-height: var(--tap);
  padding: 0.5rem 0.875rem !important; border-radius: var(--radius-md); color: var(--neutral-700); font-weight: var(--fw-medium);
  transition: color var(--dur-fast) var(--ease), background-color var(--dur-fast) var(--ease);
}
.site-nav .nav-link:hover { color: var(--neutral-900); background: var(--neutral-100); }
.site-nav .nav-link.active { color: var(--primary-800); font-weight: var(--fw-semibold); }
@media (min-width: 992px) {
  .site-nav .nav-link.active::after {
    content: ""; position: absolute; left: 0.875rem; right: 0.875rem; bottom: 0.3rem; height: 2px;
    border-radius: 2px; background: var(--primary-600);
  }
  .site-nav__cta { margin-left: 0.5rem; }
}
@media (max-width: 991.98px) {
  .site-header .navbar > .container { flex-wrap: wrap; }
  .site-header .navbar-collapse { flex-basis: 100%; }
  .site-nav { padding: 0.75rem 0 1rem; border-top: 1px solid var(--border); margin-top: 0.5rem; }
  .site-nav .nav-link { width: 100%; font-size: 1.0625rem; }
  .site-nav__cta { margin-top: 0.5rem; }
  .site-nav__cta .btn { width: 100%; min-height: 3rem; }
  .site-header:has(.navbar-collapse.show, .navbar-collapse.collapsing) { background: var(--surface); box-shadow: var(--shadow-md); }
}

/* --- 2b. Public footer + WhatsApp button --- */
.site-footer { margin-top: 0; padding: var(--sp-8) 0 var(--sp-5); background: var(--neutral-50); border-top: 1px solid var(--border); color: var(--text-muted); font-size: var(--fs-sm); }
.site-footer__grid { display: grid; gap: var(--sp-6); grid-template-columns: 1fr; }
@media (min-width: 768px) { .site-footer__grid { grid-template-columns: 2fr 1fr 1fr; } }
.brand--footer { margin-bottom: 0.875rem; }
.site-footer__crefito { display: flex; align-items: center; gap: 0.375rem; margin: 0; color: var(--neutral-700); }
.site-footer__title { font-weight: var(--fw-semibold); color: var(--neutral-900); margin-bottom: 0.75rem; font-size: var(--fs-sm); text-transform: uppercase; letter-spacing: 0.06em; }
.site-footer__list { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.25rem; }
.site-footer__list li { display: flex; align-items: center; gap: 0.5rem; }
.site-footer__list li > .icon { color: var(--primary-700); }
.site-footer a { color: var(--neutral-700); text-decoration: none; display: inline-flex; align-items: center; min-height: 2rem; }
.site-footer a:hover { color: var(--primary-800); text-decoration: underline; }
.site-footer__bottom {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.5rem 1.5rem;
  margin-top: var(--sp-6); padding-top: var(--sp-5); border-top: 1px solid var(--border); font-size: var(--fs-sm);
}
.site-footer__bottom .icon { color: var(--primary-700); }
.site-footer--slim { padding: var(--sp-4) 0; }
.site-footer--slim .site-footer__bottom { margin-top: 0; padding-top: 0; border-top: 0; }
@media (max-width: 767.98px) { .layout-public .site-footer { padding-bottom: 6.5rem; } }  /* clears the floating button */

.whatsapp-fab {
  position: fixed; right: max(1rem, env(safe-area-inset-right)); bottom: calc(1rem + env(safe-area-inset-bottom));
  z-index: var(--z-fab); display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  min-width: 3.5rem; height: 3.5rem; padding: 0 1rem; border-radius: var(--radius-pill);
  background: var(--whatsapp); color: #fff; font-weight: var(--fw-semibold); text-decoration: none;
  box-shadow: 0 10px 28px -8px rgb(14 122 64 / 0.55), var(--shadow-sm);
  transition: transform var(--dur) var(--ease), background-color var(--dur-fast) var(--ease), bottom var(--dur) var(--ease);
}
.whatsapp-fab:hover { background: var(--whatsapp-hover); color: #fff; transform: translateY(-2px); }
.whatsapp-fab__label { display: none; }
@media (min-width: 768px) { .whatsapp-fab { right: 1.5rem; bottom: 1.5rem; } .whatsapp-fab__label { display: inline; } }
.has-sticky-cta .whatsapp-fab { bottom: calc(5.75rem + env(safe-area-inset-bottom)); }
@media (min-width: 992px) { .has-sticky-cta .whatsapp-fab { bottom: 1.5rem; } }

/* --- 2c. Auth shell (card over a soft photo) --- */
.auth-shell { position: relative; isolation: isolate; min-height: calc(100vh - var(--header-h) - var(--banner-h)); display: flex; align-items: center; padding: var(--sp-6) 0 var(--sp-8); overflow: hidden; background: var(--primary-50); }
.auth-shell__bg { position: absolute; inset: 0; z-index: -1; }
.auth-shell__img { width: 100%; height: 100%; object-fit: cover; filter: saturate(0.85); }
.auth-shell__bg::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(160deg, rgb(255 255 255 / 0.9) 0%, rgb(240 253 250 / 0.82) 45%, rgba(var(--fisio-accent-rgb), 0.55) 100%);
}
.auth-shell__inner { display: flex; justify-content: center; }
.auth-card {
  width: 100%; max-width: 28rem; padding: var(--sp-5); border-radius: var(--radius-xl);
  background: rgb(255 255 255 / 0.86); border: 1px solid rgb(255 255 255 / 0.7); box-shadow: var(--shadow-lg);
  -webkit-backdrop-filter: var(--glass-blur); backdrop-filter: var(--glass-blur);
}
@supports not ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) { .auth-card { background: var(--surface); } }
@media (min-width: 576px) { .auth-card { padding: var(--sp-6) var(--sp-6) var(--sp-5); } }
.auth-card--wide { max-width: 44rem; }
.auth-card__head { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 0.5rem; margin-bottom: var(--sp-5); }
.auth-card__logo { height: 3.25rem; width: auto; }
.auth-card__title { font-size: var(--fs-xl); margin: 0; }
.auth-card hr { margin: var(--sp-5) 0 var(--sp-4); }
.auth-links { display: grid; gap: 0.5rem; text-align: center; font-size: var(--fs-sm); }
.auth-card .form-text { color: var(--neutral-600); }

/* Password reveal + strength (js/ui.js enhances every password input). */
.password-wrap { position: relative; }
.password-wrap .form-control { padding-right: 3.25rem; }
.password-toggle {
  position: absolute; top: 0; right: 0; width: var(--tap); height: var(--tap); display: inline-flex; align-items: center; justify-content: center;
  border: 0; background: transparent; color: var(--neutral-600); border-radius: var(--radius-md);
}
.password-toggle:hover { color: var(--primary-800); }
.password-toggle:focus-visible { outline-offset: -3px; }
.pw-strength { margin-top: 0.5rem; }
.pw-strength__bar { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.pw-strength__bar span { height: 4px; border-radius: 2px; background: var(--neutral-200); transition: background-color var(--dur) var(--ease); }
.pw-strength[data-score="1"] .pw-strength__bar span:nth-child(-n+1) { background: var(--danger); }
.pw-strength[data-score="2"] .pw-strength__bar span:nth-child(-n+2) { background: var(--warning); }
.pw-strength[data-score="3"] .pw-strength__bar span:nth-child(-n+3) { background: var(--primary-600); }
.pw-strength[data-score="4"] .pw-strength__bar span { background: var(--success); }
.pw-strength__text { font-size: var(--fs-sm); color: var(--text-muted); margin-top: 0.25rem; }

.consent-block { padding: var(--sp-4); border-radius: var(--radius-lg); background: var(--neutral-50); border: 1px solid var(--border); }
.consent-block__legend { float: none; width: auto; font-size: var(--fs-base); margin-bottom: 0.75rem; }
.consent-block .form-check-label { font-size: var(--fs-base); color: var(--text); }
.consent-block__optional { margin-top: 0.75rem; padding-top: 0.75rem; border-top: 1px dashed var(--border-strong); }

/* --- 2d. Patient app shell --- */
.layout-patient, .layout-admin { background: var(--surface-alt); }
.app-topbar {
  position: sticky; top: var(--banner-h); z-index: var(--z-nav); background: rgb(255 255 255 / 0.96);
  border-bottom: 1px solid var(--border);
}
.app-topbar__inner { display: flex; align-items: center; gap: 1rem; min-height: var(--header-h); }
.app-topbar .brand { flex: 0 1 auto; margin-right: auto; }
.app-nav ul { display: flex; align-items: center; gap: 0.125rem; list-style: none; margin: 0; padding: 0; }
.app-nav__link {
  display: inline-flex; align-items: center; gap: 0.4rem; min-height: var(--tap); padding: 0.4rem 0.75rem;
  border-radius: var(--radius-pill); color: var(--neutral-700); font-weight: var(--fw-medium); font-size: 0.9375rem; text-decoration: none; white-space: nowrap;
  transition: background-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.app-nav__link:hover { background: var(--neutral-100); color: var(--neutral-900); }
.app-nav__link.active { background: var(--primary-50); color: var(--primary-800); font-weight: var(--fw-semibold); }
.account-btn {
  position: relative; display: inline-flex; align-items: center; gap: 0.5rem; min-height: var(--tap); padding: 0.25rem 0.5rem 0.25rem 0.25rem;
  border: 1px solid var(--border); border-radius: var(--radius-pill); background: var(--surface); color: var(--neutral-800); font-weight: var(--fw-medium); flex-shrink: 0;
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.account-btn:hover { border-color: var(--primary-300); box-shadow: var(--shadow-sm); }
.account-btn__dot { position: absolute; top: 0.2rem; left: 1.9rem; width: 0.7rem; height: 0.7rem; border-radius: 50%; background: var(--danger); box-shadow: 0 0 0 2px var(--surface); }
.account-menu { --bs-offcanvas-width: min(22rem, 88vw); }
.account-menu .offcanvas-body { display: flex; flex-direction: column; gap: 1rem; }
.account-menu__footer { margin-top: auto; padding-top: 1rem; border-top: 1px solid var(--border); }
.menu-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.25rem; }
.menu-list__link {
  display: flex; align-items: center; gap: 0.75rem; min-height: 3rem; padding: 0.5rem 0.875rem; border-radius: var(--radius-md);
  color: var(--neutral-800); font-weight: var(--fw-medium); text-decoration: none;
}
.menu-list__link .icon { color: var(--primary-700); }
.menu-list__link:hover { background: var(--neutral-100); color: var(--neutral-900); }
.menu-list__link.active { background: var(--primary-50); color: var(--primary-900); }
.app-main { padding-top: var(--sp-5); padding-bottom: var(--sp-7); }
@media (max-width: 991.98px) { .app-main { padding-bottom: calc(var(--tabbar-h) + var(--sp-6) + env(safe-area-inset-bottom)); } }
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: var(--z-nav);
  display: grid; grid-template-columns: repeat(5, 1fr); height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding: 0.25rem 0.25rem env(safe-area-inset-bottom); background: rgb(255 255 255 / 0.85);
  border-top: 1px solid var(--border); box-shadow: 0 -6px 24px -12px rgb(15 23 42 / 0.18);
  -webkit-backdrop-filter: var(--glass-blur); backdrop-filter: var(--glass-blur);
}
@supports not ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) { .tabbar { background: var(--surface); } }
.tabbar__item {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.125rem; min-width: 0;
  color: var(--neutral-600); text-decoration: none; font-size: 0.65rem; font-weight: var(--fw-medium); border-radius: var(--radius-md); letter-spacing: -0.01em;
}
.tabbar__icon { position: relative; display: inline-flex; align-items: center; justify-content: center; width: 3.5rem; height: 2rem; border-radius: var(--radius-pill); transition: background-color var(--dur) var(--ease); }
.tabbar__icon .icon { width: 1.375rem; height: 1.375rem; }
.tabbar__label { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tabbar__item.active { color: var(--primary-800); font-weight: var(--fw-semibold); }
.tabbar__item.active .tabbar__icon { background: var(--primary-100); }
.tabbar__badge { position: absolute; top: -0.125rem; right: 0.5rem; min-width: 1.125rem; height: 1.125rem; padding: 0 0.25rem; border-radius: var(--radius-pill); background: var(--danger); color: #fff; font-size: 0.6875rem; font-weight: var(--fw-bold); line-height: 1.125rem; text-align: center; box-shadow: 0 0 0 2px var(--surface); }

/* --- 2e. Admin shell --- */
.admin-shell { display: flex; min-height: calc(100vh - var(--banner-h)); }
@media (min-width: 992px) {  /* paint the sidebar column to the bottom of long pages */
  .admin-shell { --col: var(--sidebar-w); background: linear-gradient(to right, var(--surface) calc(var(--col) - 1px), var(--border) calc(var(--col) - 1px) var(--col), transparent var(--col)); }
  .sidebar-collapsed .admin-shell { --col: var(--sidebar-w-collapsed); }
}
.admin-sidebar { background: var(--surface); border-right: 1px solid var(--border); }
.admin-sidebar__body { display: flex; flex-direction: column; gap: 0.25rem; }
@media (min-width: 992px) {
  .admin-sidebar {
    width: var(--sidebar-w); flex-shrink: 0; position: sticky; top: var(--banner-h); height: calc(100vh - var(--banner-h));
    overflow-y: auto; padding: 1rem 0.75rem; transition: width var(--dur) var(--ease); scrollbar-width: thin;
  }
  .admin-sidebar__body { height: 100%; }
  .sidebar-collapsed .admin-sidebar { width: var(--sidebar-w-collapsed); }
  .sidebar-collapsed .admin-nav__label, .sidebar-collapsed .admin-nav__group, .sidebar-collapsed .admin-sidebar__brand .brand__text { display: none; }
  .sidebar-collapsed .admin-nav .nav-link { justify-content: center; padding-inline: 0; }
  .sidebar-collapsed .admin-nav__badge { position: absolute; top: 0.125rem; right: 0.25rem; font-size: 0.625rem; }
  .sidebar-collapsed .admin-sidebar__brand { justify-content: center; padding-inline: 0; }
  .sidebar-collapsed .admin-sidebar__collapse { justify-content: center; }
}
.admin-sidebar__brand { padding: 0.25rem 0.5rem 1rem; margin-bottom: 0.25rem; border-bottom: 1px solid var(--border); }
.admin-sidebar__brand .brand-logo { height: 2.25rem; }
.admin-nav__group { margin: 1rem 0.75rem 0.375rem; font-size: 0.6875rem; font-weight: var(--fw-semibold); text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-subtle); }
.admin-nav .nav-link {
  position: relative; display: flex; align-items: center; gap: 0.75rem; min-height: 2.625rem; padding: 0.5rem 0.75rem;
  color: var(--neutral-700); border-radius: var(--radius-md); font-weight: var(--fw-medium); font-size: 0.9375rem;
  transition: background-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.admin-nav .nav-link .icon { color: var(--neutral-500); transition: color var(--dur-fast) var(--ease); }
.admin-nav .nav-link:hover { background: var(--neutral-100); color: var(--neutral-900); }
.admin-nav .nav-link:hover .icon { color: var(--primary-700); }
.admin-nav .nav-link.active { background: var(--primary-50); color: var(--primary-900); font-weight: var(--fw-semibold); }
.admin-nav .nav-link.active .icon { color: var(--primary-700); }
.admin-nav .nav-link.active::before { content: ""; position: absolute; left: -0.75rem; top: 0.5rem; bottom: 0.5rem; width: 3px; border-radius: 0 3px 3px 0; background: var(--primary-700); }
.admin-nav__badge { margin-left: auto; }
.admin-sidebar__collapse {
  margin-top: auto; display: flex; align-items: center; gap: 0.75rem; min-height: 2.625rem; padding: 0.5rem 0.75rem;
  border: 0; border-radius: var(--radius-md); background: transparent; color: var(--neutral-600); font-size: var(--fs-sm); font-weight: var(--fw-medium);
}
.admin-sidebar__collapse:hover { background: var(--neutral-100); color: var(--neutral-900); }
.admin-sidebar__collapse-open { display: none; }
.sidebar-collapsed .admin-sidebar__collapse-open { display: inline; }
.sidebar-collapsed .admin-sidebar__collapse-close { display: none; }
.admin-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.admin-topbar {
  position: sticky; top: var(--banner-h); z-index: var(--z-sticky);
  display: flex; align-items: center; gap: 0.75rem; min-height: var(--header-h); padding: 0.5rem 1rem;
  background: rgb(255 255 255 / 0.96); border-bottom: 1px solid var(--border);
}
@media (min-width: 768px) { .admin-topbar { padding: 0.5rem 1.5rem; gap: 1rem; } }
.admin-topbar__end { margin-left: auto; display: flex; align-items: center; gap: 0.5rem; }
.admin-topbar__user { align-items: center; gap: 0.5rem; padding: 0 0.5rem; font-size: var(--fs-sm); font-weight: var(--fw-medium); color: var(--neutral-700); white-space: nowrap; text-decoration: none; border-radius: var(--radius-sm); }
.admin-topbar__user:hover, .admin-topbar__user:focus-visible { color: var(--primary-700); background: var(--surface-sunken); }
.topbar-counter {
  position: relative; display: inline-flex; align-items: center; justify-content: center; width: var(--tap); height: var(--tap);
  border-radius: var(--radius-md); color: var(--neutral-600);
}
.topbar-counter:hover { background: var(--neutral-100); color: var(--primary-800); }
.topbar-counter__badge { position: absolute; top: 0.25rem; right: 0.2rem; min-width: 1.125rem; height: 1.125rem; padding: 0 0.25rem; border-radius: var(--radius-pill); background: var(--danger); color: #fff; font-size: 0.6875rem; font-weight: var(--fw-bold); line-height: 1.125rem; text-align: center; box-shadow: 0 0 0 2px var(--surface); }
.global-search { flex: 1 1 auto; max-width: 28rem; min-width: 0; }
.global-search .form-control { padding-left: 2.5rem; background: var(--neutral-50); border-color: var(--border); }
.global-search .form-control:focus { background: var(--surface); }
.global-search__icon { position: absolute; left: 0.875rem; top: 50%; transform: translateY(-50%); color: var(--text-subtle); pointer-events: none; }
.global-search__dropdown { position: absolute; top: calc(100% + 0.375rem); left: 0; right: 0; z-index: var(--z-dropdown); }
.global-search__dropdown:not(:empty) { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); overflow: hidden; }
.global-search__dropdown .list-group { box-shadow: none; --bs-list-group-border-radius: 0; }
.app-alerts { display: grid; gap: 0.5rem; padding: 1rem 1rem 0; }
@media (min-width: 768px) { .app-alerts { padding: 1rem 1.5rem 0; } }
.app-alert { display: flex; align-items: flex-start; gap: 0.625rem; margin: 0; padding-block: 0.625rem; font-size: var(--fs-sm); }
.app-alert > .icon { margin-top: 0.1rem; }
.admin-content > .app-alert { margin-bottom: 1rem; }
.app-alert.alert-dismissible { padding-right: 2.75rem; }
.app-alert .btn-close { padding: 0.8rem; }
.admin-content { padding: 1.25rem 1rem var(--sp-7); }
@media (min-width: 768px) { .admin-content { padding: 1.75rem 1.5rem var(--sp-7); } }
@media (min-width: 1400px) { .admin-content { padding-inline: 2rem; } }

/* === 3. Shared components ===================================================== */
.page-header { margin-bottom: var(--sp-5); }
.page-header__row { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 0.75rem 1rem; }
.page-header__text { min-width: 0; }
.page-header__title { font-size: var(--fs-3xl); margin-bottom: 0.25rem; }
.layout-admin .page-header__title, .layout-patient .page-header__title { font-size: clamp(1.625rem, 1.3rem + 1vw, 2rem); }
.page-header__subtitle { color: var(--text-muted); margin-bottom: 0; font-size: var(--fs-md); max-width: var(--measure); }
.page-header__actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.breadcrumbs ol { display: flex; flex-wrap: wrap; align-items: center; gap: 0.25rem 0.5rem; list-style: none; padding: 0; margin: 0 0 0.75rem; font-size: var(--fs-sm); color: var(--text-muted); }
.breadcrumbs li + li::before { content: "/"; margin-right: 0.5rem; color: var(--neutral-400); }
.breadcrumbs a { color: var(--text-muted); text-decoration: none; }
.breadcrumbs a:hover { color: var(--link); text-decoration: underline; }
.back-link { display: inline-flex; align-items: center; gap: 0.25rem; font-size: var(--fs-sm); color: var(--text-muted); text-decoration: none; margin-bottom: 0.5rem; min-height: 2rem; }
.back-link:hover { color: var(--link); }

.ui-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); padding: var(--sp-5); }
.ui-card__header { display: flex; align-items: flex-start; gap: 0.75rem; margin-bottom: 1rem; }
.ui-card__icon { display: inline-flex; align-items: center; justify-content: center; width: 2.5rem; height: 2.5rem; flex-shrink: 0; border-radius: var(--radius-md); background: var(--primary-50); color: var(--primary-700); }
.ui-card__title { font-size: var(--fs-lg); margin: 0; line-height: 1.3; }
.ui-card__subtitle { margin: 0.125rem 0 0; color: var(--text-muted); font-size: var(--fs-sm); }
.card-hover { transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease), border-color var(--dur) var(--ease); }
@media (hover: hover) { .card-hover:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--primary-200); } }

/* Stat cards */
.stat-grid { display: grid; gap: 0.75rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, 11rem), 1fr)); }
@media (max-width: 575.98px) { .stat-grid { grid-template-columns: 1fr 1fr; } }
.stat-card {
  position: relative; display: flex; flex-direction: column; gap: 0.75rem; padding: 1rem 1.125rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-xs);
  transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
@media (hover: hover) { .stat-card:has(.stretched-link):hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--primary-200); } }
.stat-card__icon { display: inline-flex; align-items: center; justify-content: center; width: 2.5rem; height: 2.5rem; border-radius: var(--radius-md); background: var(--primary-50); color: var(--primary-700); }
.stat-card__body { display: flex; flex-direction: column; gap: 0.125rem; min-width: 0; }
.stat-card__value { font-size: 1.875rem; font-weight: var(--fw-bold); line-height: 1.1; letter-spacing: -0.02em; color: var(--neutral-900); font-variant-numeric: tabular-nums; }
.stat-card__label { font-size: var(--fs-sm); color: var(--text-muted); font-weight: var(--fw-medium); line-height: 1.35; text-decoration: none; }
a.stat-card__label:hover { color: var(--link); }
.stat-card__hint { font-size: var(--fs-xs); color: var(--text-subtle); }
.stat-card--warning .stat-card__icon { background: var(--warning-bg); color: var(--warning); }
.stat-card--danger .stat-card__icon { background: var(--danger-bg); color: var(--danger); }
.stat-card--info .stat-card__icon { background: var(--info-bg); color: var(--info); }
.stat-card--success .stat-card__icon { background: var(--success-bg); color: var(--success); }
.stat-card--neutral .stat-card__icon { background: var(--neutral-100); color: var(--neutral-600); }
.stat-card.is-zero .stat-card__value { color: var(--neutral-500); }
.stat-card.is-zero .stat-card__icon { background: var(--neutral-100); color: var(--neutral-500); }

/* Empty state */
.empty-state { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 0.5rem; padding: var(--sp-7) var(--sp-5); background: var(--surface); border: 1px dashed var(--border-strong); border-radius: var(--radius-lg); }
.empty-state--compact { padding: var(--sp-5) var(--sp-4); }
.empty-state__icon { display: inline-flex; align-items: center; justify-content: center; width: 3.5rem; height: 3.5rem; margin-bottom: 0.25rem; border-radius: 50%; background: var(--primary-50); color: var(--primary-700); }
.empty-state__icon .icon { width: 1.625rem; height: 1.625rem; stroke-width: 1.75; }
.empty-state__title { font-weight: var(--fw-semibold); color: var(--neutral-900); margin: 0; font-size: 1.0625rem; }
.empty-state__text { color: var(--text-muted); margin: 0 0 0.5rem; max-width: 34rem; }

/* Avatar (initials) */
.avatar { display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; border-radius: 50%; background: linear-gradient(135deg, var(--primary-100), var(--primary-200)); color: var(--primary-900); font-weight: var(--fw-semibold); letter-spacing: 0.02em; }
.avatar--sm { width: 2.125rem; height: 2.125rem; font-size: 0.8125rem; }
.avatar--md { width: 2.75rem; height: 2.75rem; font-size: 0.9375rem; }
.avatar--lg { width: 3.5rem; height: 3.5rem; font-size: 1.125rem; }
.avatar--xl { width: 4.5rem; height: 4.5rem; font-size: 1.5rem; }
.avatar--photo { object-fit: cover; background: var(--surface-sunken); box-shadow: 0 0 0 1px var(--border); }

/* Profile photo editor (D-143): Cropper.js stage; the round guide shows how the photo appears. */
.avatar-editor__current { display: flex; align-items: center; gap: 1rem; }
.avatar-editor__stage { margin-top: 1rem; }
.avatar-editor__canvas { width: 100%; max-width: 22rem; height: 18rem; border-radius: var(--radius-md); overflow: hidden; background: var(--surface-sunken); }
.avatar-editor__canvas img { display: block; max-width: 100%; }
.avatar-editor .cropper-view-box, .avatar-editor .cropper-face { border-radius: 50%; }
.avatar-editor .cropper-view-box { outline: 2px solid var(--primary-500); outline-offset: -1px; }
.avatar-editor__tools { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.75rem; }

/* Saved patient addresses (D-142). */
.address-list { list-style: none; padding: 0; margin: 0 0 1rem; display: grid; gap: 0.5rem; }
.address-item { display: flex; gap: 0.75rem; align-items: flex-start; padding: 0.75rem; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface); }
.address-item--default { border-color: var(--primary-200); background: var(--primary-50); }
.address-item__icon { color: var(--primary-700); margin-top: 0.1rem; }
.address-item__body { min-width: 0; flex: 1; }
.address-item__label { margin: 0; font-weight: var(--fw-semibold); }
.address-item__text { margin: 0.125rem 0 0.25rem; font-size: var(--fs-sm); color: var(--text-muted); overflow-wrap: anywhere; }
.address-item__actions { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 0.25rem 1rem; }
.address-item__actions form { margin: 0; }
.address-item__actions summary { list-style: none; }
.address-item__actions summary::-webkit-details-marker { display: none; }
.address-add > summary { list-style: none; }
.address-add > summary::-webkit-details-marker { display: none; }

/* Patient dashboard: who the physio is (photo, name, CREFITO). */
.physio-card { display: flex; align-items: center; gap: 0.875rem; padding: 0.875rem 1rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-xs); }
.physio-card__eyebrow { margin: 0; font-size: var(--fs-xs); color: var(--text-muted); text-transform: uppercase; letter-spacing: var(--tracking-caps); }
.physio-card__name { margin: 0; font-weight: var(--fw-semibold); }
.physio-card__meta { margin: 0; font-size: var(--fs-sm); color: var(--text-muted); }

/* Status badges: colour + icon + text (never colour alone). */
.status-badge { display: inline-flex; align-items: center; gap: 0.3rem; font-weight: var(--fw-semibold); font-size: 0.75rem; border: 1px solid transparent; vertical-align: middle; white-space: nowrap; }
.status-pending   { background: var(--warning-bg); color: var(--warning-text); border-style: dashed; border-color: var(--warning); }
.status-proposed  { background: var(--info-bg); color: var(--info-text); border-color: var(--info-border); background-image: repeating-linear-gradient(135deg, transparent 0 5px, rgb(3 105 161 / 0.07) 5px 10px); }
.status-confirmed { background: var(--primary-50); color: var(--primary-900); border-color: var(--primary-200); }
.status-completed { background: var(--success-bg); color: var(--success-text); border-color: var(--success-border); }
.status-no_show   { background: var(--danger-bg); color: var(--danger-text); border-color: var(--danger-border); }
.status-cancelled { background: var(--neutral-100); color: var(--neutral-700); border-color: var(--neutral-200); }
.pay-pending { background: var(--warning-bg); color: var(--warning-text); border-color: var(--warning-border); }
.pay-partial { background: var(--warning-bg); color: var(--warning-text); border-color: var(--warning-border); border-style: dashed; }
.pay-paid { background: var(--success-bg); color: var(--success-text); border-color: var(--success-border); }
.pay-waived { background: var(--neutral-100); color: var(--neutral-700); border-color: var(--neutral-200); }
.pay-refunded { background: var(--info-bg); color: var(--info-text); border-color: var(--info-border); }
.pay-package { background: var(--primary-50); color: var(--primary-900); border-color: var(--primary-200); }

/* Toasts (flash messages) */
.toast-stack {
  position: fixed; z-index: var(--z-toast); top: calc(var(--banner-h) + var(--header-h) + 0.75rem); right: 1rem; left: 1rem;
  display: grid; gap: 0.5rem; justify-items: end; pointer-events: none;
}
@media (min-width: 576px) { .toast-stack { left: auto; width: 24rem; } }
.toast-item {
  pointer-events: auto; display: flex; align-items: flex-start; gap: 0.75rem; width: 100%; padding: 0.875rem 0.75rem 0.875rem 1rem;
  background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--info); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); color: var(--text); font-size: 0.9375rem; line-height: 1.45;
  animation: toast-in var(--dur-slow) var(--ease) both;
}
.toast-item.is-leaving { animation: toast-out var(--dur) var(--ease) forwards; }
.toast-item__icon { color: var(--info); margin-top: 0.05rem; }
.toast-item__msg { flex: 1; min-width: 0; }
.toast-item__close { display: inline-flex; align-items: center; justify-content: center; width: 2rem; height: 2rem; margin: -0.3rem -0.2rem -0.3rem 0; border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--neutral-500); }
.toast-item__close:hover { background: var(--neutral-100); color: var(--neutral-900); }
.toast-item--success { border-left-color: var(--success); } .toast-item--success .toast-item__icon { color: var(--success); }
.toast-item--warning { border-left-color: var(--warning); } .toast-item--warning .toast-item__icon { color: var(--warning); }
.toast-item--danger { border-left-color: var(--danger); } .toast-item--danger .toast-item__icon { color: var(--danger); }
@keyframes toast-in { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateX(16px); } }

/* Skeletons */
.skeleton { display: grid; gap: 0.625rem; }
.skeleton__bone {
  display: block; height: 0.875rem; border-radius: var(--radius-sm);
  background: linear-gradient(90deg, var(--neutral-100) 0%, var(--neutral-50) 50%, var(--neutral-100) 100%); background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
}
.skeleton--text .skeleton__bone:last-child { width: 60%; }
.skeleton--chips { grid-template-columns: repeat(auto-fill, minmax(5.75rem, 1fr)); }
.skeleton--chips .skeleton__bone { height: 3rem; border-radius: var(--radius-md); }
.skeleton--card .skeleton__bone { height: 6rem; border-radius: var(--radius-lg); }
.skeleton--list .skeleton__bone { height: 3.25rem; border-radius: var(--radius-md); }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* HTMX: top progress bar + gentle swaps (built-in indicator styles are off for CSP). */
.htmx-indicator { opacity: 0; transition: opacity var(--dur) var(--ease); }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { opacity: 1; }
.htmx-progress {
  position: fixed; top: 0; left: 0; z-index: calc(var(--z-banner) + 2); height: 3px; width: 100%;
  background: linear-gradient(90deg, var(--primary-400), var(--primary-700)); transform-origin: left; transform: scaleX(0); opacity: 0;
  transition: transform 600ms var(--ease), opacity var(--dur) var(--ease); pointer-events: none;
}
html.is-loading .htmx-progress { opacity: 1; transform: scaleX(0.75); transition: transform 3s cubic-bezier(0.1, 0.6, 0.2, 1), opacity var(--dur-fast); }
html.is-loaded .htmx-progress { opacity: 0; transform: scaleX(1); }
:where(#slots, #calendar, #panel-body, #new-body, #global-results, [data-swap-fade]) > * { transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease); }
:where(#slots, #calendar, #panel-body, #new-body, #global-results, [data-swap-fade]) > .htmx-added,
#wizard.htmx-added { opacity: 0; transform: translateY(6px); }
#wizard { transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease); }

/* Info list (label/value) */
.facts { display: grid; gap: 0.75rem; margin: var(--sp-5) 0; grid-template-columns: repeat(auto-fit, minmax(min(100%, 12rem), 1fr)); }
.facts > div { display: flex; flex-direction: column; gap: 0.25rem; padding: 0.875rem 1rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); }
.facts .icon { color: var(--primary-700); }
.facts dt { display: flex; align-items: center; gap: 0.375rem; font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); font-weight: var(--fw-semibold); }
.facts dd { margin: 0; font-weight: var(--fw-medium); color: var(--neutral-900); }
.hours-list { margin: 0; display: grid; gap: 0.125rem; }
.hours-list__row { display: flex; justify-content: space-between; gap: 1rem; padding: 0.5rem 0; border-bottom: 1px dashed var(--border); }
.hours-list__row:last-child { border-bottom: 0; }
.hours-list dt { font-weight: var(--fw-medium); white-space: nowrap; }
.hours-list dd { margin: 0; color: var(--text-muted); text-align: right; font-variant-numeric: tabular-nums; }

/* Error pages */
.error-page { min-height: 60vh; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: var(--sp-8) var(--gutter); }
.error-page__art { position: relative; margin-bottom: var(--sp-4); }
.error-page__art img { width: 7.5rem; height: 7.5rem; object-fit: contain; }
.error-page__code { font-size: var(--fs-sm); font-weight: var(--fw-semibold); letter-spacing: var(--tracking-caps); text-transform: uppercase; color: var(--primary-700); margin-bottom: 0.5rem; }
.error-page h1 { font-size: var(--fs-2xl); }
.error-page .lead { max-width: 34rem; margin-inline: auto; }
.error-page__actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.5rem; margin-top: var(--sp-4); }

/* === 4. Public pages ============================================================ */
.section { padding: clamp(3.5rem, 8vw, 6rem) 0; }
.section--tinted { background: var(--surface-alt); }
.section--tight { padding: clamp(2rem, 5vw, 3.5rem) 0; }
.section-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 1rem 2rem; margin-bottom: var(--sp-6); }
.section-head__text { max-width: 40rem; }
.section__title { font-size: var(--fs-2xl); margin-bottom: 0.5rem; }
.section__lead { color: var(--text-muted); font-size: var(--fs-md); margin: 0; }
.link-arrow { display: inline-flex; align-items: center; gap: 0.375rem; font-weight: var(--fw-semibold); text-decoration: none; min-height: var(--tap); }
.link-arrow .icon { transition: transform var(--dur) var(--ease); }
.link-arrow:hover .icon { transform: translateX(3px); }

/* Hero */
.hero {
  position: relative; overflow: hidden; padding: clamp(2rem, 6vw, 5rem) 0 clamp(3rem, 7vw, 5.5rem);
  background:
    radial-gradient(55% 60% at 90% 0%, rgba(var(--fisio-accent-rgb), 0.14), transparent 70%),
    radial-gradient(40% 50% at 0% 100%, rgba(var(--fisio-accent-rgb), 0.08), transparent 70%),
    linear-gradient(180deg, var(--primary-50) 0%, var(--surface) 100%);
}
.hero__grid { display: grid; gap: var(--sp-6); align-items: center; }
@media (min-width: 992px) { .hero__grid { grid-template-columns: 1.05fr 1fr; gap: var(--sp-7); } }
.hero__title { font-size: var(--fs-display); line-height: 1.08; letter-spacing: -0.03em; margin-bottom: var(--sp-4); max-width: 18ch; }
.hero__lead { font-size: clamp(1.0625rem, 1rem + 0.4vw, 1.25rem); color: var(--text-muted); max-width: 36rem; margin-bottom: var(--sp-5); }
.hero__ctas { display: flex; flex-wrap: wrap; gap: 0.75rem; }
@media (max-width: 575.98px) { .hero__ctas .btn { width: 100%; } }
.hero__chips { margin-top: var(--sp-5); }
.hero__chips li { background: var(--surface); border-color: var(--border); color: var(--neutral-700); box-shadow: var(--shadow-xs); }
.hero__chips .icon { color: var(--primary-700); }
.hero__figure { position: relative; margin: 0; }
.hero__figure::before {
  content: ""; position: absolute; inset: 8% -4% -5% 10%; border-radius: var(--radius-xl);
  background: linear-gradient(135deg, var(--primary-100), var(--primary-200)); transform: rotate(3deg); z-index: 0;
}
.hero__frame { position: relative; z-index: 1; border-radius: var(--radius-xl); overflow: hidden; box-shadow: var(--shadow-lg); aspect-ratio: 4 / 3; background: var(--primary-100); }
.hero__img { width: 100%; height: 100%; object-fit: cover; object-position: 40% 50%; display: block; }
.hero__frame::after { content: ""; position: absolute; inset: 0; background: linear-gradient(to top, rgba(var(--fisio-accent-rgb), 0.55) 0%, rgba(var(--fisio-accent-rgb), 0.1) 38%, transparent 60%); pointer-events: none; }
.hero__badge {
  position: absolute; z-index: 2; left: 1rem; right: 1rem; bottom: 1rem; display: flex; align-items: center; gap: 0.75rem;
  padding: 0.75rem 1rem; border-radius: var(--radius-lg); color: var(--neutral-900);
}
@media (min-width: 576px) { .hero__badge { right: auto; max-width: 22rem; } }
.hero__badge-icon { display: inline-flex; align-items: center; justify-content: center; width: 2.5rem; height: 2.5rem; border-radius: 50%; background: var(--primary-700); color: #fff; flex-shrink: 0; }
.hero__badge strong { display: block; font-size: 0.9375rem; line-height: 1.3; }
.hero__badge span { font-size: var(--fs-sm); color: var(--neutral-700); }

/* Service cards */
.service-grid { display: grid; gap: var(--sp-5); grid-template-columns: repeat(auto-fill, minmax(min(100%, 17rem), 1fr)); }
.service-card {
  position: relative; display: flex; flex-direction: column; height: 100%; overflow: hidden;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm);
  transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.service-card__media { position: relative; aspect-ratio: 3 / 2; overflow: hidden; background: linear-gradient(135deg, var(--primary-50), var(--primary-200)); }
.service-card__img { width: 100%; height: 100%; object-fit: cover; transition: transform var(--dur-slow) var(--ease); }
.service-card__placeholder { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--primary-700); }
.service-card__placeholder .icon { width: 3.5rem; height: 3.5rem; stroke-width: 1.5; opacity: 0.7; }
.service-card__icon {
  position: absolute; left: 1.25rem; top: -1.375rem; z-index: 1; display: inline-flex; align-items: center; justify-content: center;
  width: 2.75rem; height: 2.75rem; border-radius: var(--radius-md); background: var(--surface); color: var(--primary-700); box-shadow: var(--shadow-md);
}
.service-card__body { position: relative; display: flex; flex-direction: column; flex: 1; gap: 0.5rem; padding: 2rem 1.25rem 1.25rem; }
.service-card__title { font-size: 1.125rem; margin: 0; }
.service-card__title a { color: var(--neutral-900); text-decoration: none; }
.service-card__title a:hover { color: var(--primary-800); }
.service-card__text { color: var(--text-muted); margin: 0; flex: 1; font-size: 0.9375rem; }
.service-card__meta { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem; margin-top: 0.5rem; padding-top: 0.875rem; border-top: 1px solid var(--border); font-size: var(--fs-sm); color: var(--text-muted); }
.service-card__meta span { display: inline-flex; align-items: center; gap: 0.375rem; }
.service-card__more { color: var(--primary-700); font-weight: var(--fw-semibold); }
.service-card__more .icon { transition: transform var(--dur) var(--ease); }
@media (hover: hover) {
  .service-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: var(--primary-200); }
  .service-card:hover .service-card__img { transform: scale(1.04); }
  .service-card:hover .service-card__more .icon { transform: translateX(3px); }
}
.service-card:focus-within { border-color: var(--primary-400); }

/* "Como funciona" timeline */
.steps { list-style: none; padding: 0; margin: 0; display: grid; gap: var(--sp-5); counter-reset: step; }
.steps__item { position: relative; display: grid; grid-template-columns: auto 1fr; gap: 1rem; align-items: start; }
.steps__marker { position: relative; display: flex; flex-direction: column; align-items: center; }
.steps__art-wrap { position: relative; display: inline-block; }
.steps__art { width: 4rem; height: 4rem; padding: 0.5rem; border-radius: var(--radius-lg); background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-sm); object-fit: contain; }
.steps__n { position: absolute; top: -0.5rem; right: -0.5rem; display: inline-flex; align-items: center; justify-content: center; width: 1.625rem; height: 1.625rem; border-radius: 50%; background: var(--primary-700); color: #fff; font-size: 0.8125rem; font-weight: var(--fw-bold); box-shadow: 0 0 0 3px var(--surface); }
.steps__item:not(:last-child) .steps__marker::after { content: ""; position: absolute; top: 4.5rem; bottom: calc(-1 * var(--sp-5)); left: 50%; width: 2px; transform: translateX(-50%); background: linear-gradient(var(--primary-200), var(--primary-100)); }
.steps__title { font-size: 1.125rem; margin: 0.25rem 0 0.375rem; }
.steps__text { color: var(--text-muted); margin: 0; }
@media (min-width: 768px) {
  .steps { grid-template-columns: repeat(3, 1fr); gap: var(--sp-6); }
  .steps__item { grid-template-columns: 1fr; text-align: left; }
  .steps__marker { align-items: flex-start; }
  .steps__item:not(:last-child) .steps__marker::after { top: 2rem; bottom: auto; left: 5rem; right: calc(-1 * var(--sp-6)); width: auto; height: 2px; transform: none; background: linear-gradient(90deg, var(--primary-200), var(--primary-100)); }
  .steps__marker { width: 100%; }
}

/* About */
.about-block { display: grid; gap: var(--sp-6); align-items: center; }
@media (min-width: 768px) { .about-block { grid-template-columns: minmax(14rem, 22rem) 1fr; gap: var(--sp-7); } }
.about-photo-wrap { position: relative; max-width: 22rem; }
.about-photo-wrap::before { content: ""; position: absolute; inset: 1rem -1rem -1rem 1rem; border-radius: var(--radius-xl); border: 2px solid var(--primary-200); }
.about-photo { position: relative; width: 100%; height: auto; aspect-ratio: 1 / 1; object-fit: cover; border-radius: var(--radius-xl); box-shadow: var(--shadow-md); }
.about__name { font-size: var(--fs-xl); margin-bottom: 0.25rem; }
.crefito-badge { display: inline-flex; align-items: center; gap: 0.375rem; padding: 0.3rem 0.75rem; border-radius: var(--radius-pill); background: var(--surface); border: 1px solid var(--border); font-size: var(--fs-sm); font-weight: var(--fw-medium); color: var(--neutral-700); }
.crefito-badge .icon { color: var(--primary-700); }

/* Location */
.location-grid { display: grid; gap: var(--sp-5); }
@media (min-width: 768px) { .location-grid { grid-template-columns: 1.2fr 1fr; } }
.map-card {
  position: relative; overflow: hidden; display: flex; flex-direction: column; justify-content: flex-end; gap: 0.75rem; min-height: 18rem;
  padding: var(--sp-5); border-radius: var(--radius-lg); color: var(--neutral-900); border: 1px solid var(--primary-100);
  background:
    radial-gradient(circle at 78% 28%, rgba(var(--fisio-accent-rgb), 0.18) 0 3.5rem, transparent 3.6rem),
    repeating-linear-gradient(0deg, rgb(15 118 110 / 0.06) 0 1px, transparent 1px 28px),
    repeating-linear-gradient(90deg, rgb(15 118 110 / 0.06) 0 1px, transparent 1px 28px),
    linear-gradient(135deg, var(--primary-50), #fff 70%);
}
.map-card__pin { position: absolute; top: calc(28% - 1.5rem); left: calc(78% - 1.5rem); display: inline-flex; align-items: center; justify-content: center; width: 3rem; height: 3rem; border-radius: 50% 50% 50% 0; transform: rotate(-45deg); background: var(--primary-700); color: #fff; box-shadow: var(--shadow-brand); }
.map-card__pin .icon { transform: rotate(45deg); }
.map-card__address { font-weight: var(--fw-semibold); font-size: 1.0625rem; margin: 0; max-width: 28rem; }
.map-card .btn { align-self: flex-start; }

/* CTA band */
.cta-band {
  position: relative; overflow: hidden; isolation: isolate; padding: clamp(2rem, 5vw, 3.5rem); border-radius: var(--radius-xl); color: #fff;
  background: linear-gradient(135deg, var(--primary-700) 0%, var(--primary-900) 100%); box-shadow: var(--shadow-lg);
  display: grid; gap: var(--sp-5); align-items: center;
}
@media (min-width: 992px) { .cta-band { grid-template-columns: 1fr auto; } }
.cta-band::before, .cta-band::after { content: ""; position: absolute; z-index: -1; border-radius: 50%; background: rgb(255 255 255 / 0.07); }
.cta-band::before { width: 22rem; height: 22rem; right: -6rem; top: -10rem; }
.cta-band::after { width: 14rem; height: 14rem; right: 12rem; bottom: -9rem; }
.cta-band h2 { color: #fff; margin-bottom: 0.5rem; }
.cta-band p { color: rgb(255 255 255 / 0.9); margin: 0; font-size: var(--fs-md); max-width: 36rem; }
.cta-band__actions { display: flex; flex-wrap: wrap; gap: 0.75rem; }
.btn-light-brand { --bs-btn-color: var(--primary-900); --bs-btn-bg: #fff; --bs-btn-border-color: #fff; --bs-btn-hover-color: var(--primary-950); --bs-btn-hover-bg: var(--primary-50); --bs-btn-hover-border-color: var(--primary-50); --bs-btn-active-bg: var(--primary-100); --bs-btn-active-color: var(--primary-950); }
.btn-outline-light { --bs-btn-hover-color: var(--primary-900); }

/* Service detail */
.service-hero { display: grid; gap: var(--sp-6); align-items: start; }
@media (min-width: 992px) { .service-hero { grid-template-columns: 1.15fr 1fr; gap: var(--sp-7); } }
.service-hero__media { position: relative; border-radius: var(--radius-xl); overflow: hidden; box-shadow: var(--shadow-lg); aspect-ratio: 4 / 3; background: linear-gradient(135deg, var(--primary-50), var(--primary-200)); }
@media (min-width: 992px) { .service-hero__media { position: sticky; top: calc(var(--header-h) + var(--banner-h) + 1.5rem); } }
.service-hero__img { width: 100%; height: 100%; object-fit: cover; }
@media (max-width: 991.98px) { .service-hero__media { order: -1; aspect-ratio: 16 / 10; } }
@media (max-width: 575.98px) { .service-hero__actions .btn { width: 100%; } .facts { grid-template-columns: 1fr 1fr; } .facts > div:last-child:nth-child(odd) { grid-column: 1 / -1; } }
.service-hero__icon { display: inline-flex; align-items: center; justify-content: center; width: 3rem; height: 3rem; border-radius: var(--radius-md); background: var(--primary-50); color: var(--primary-700); margin-bottom: 1rem; }
.service-hero__actions { display: flex; flex-wrap: wrap; gap: 0.75rem; }
.sticky-cta {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: var(--z-sticky); display: flex; align-items: center; gap: 0.75rem;
  padding: 0.75rem var(--gutter) calc(0.75rem + env(safe-area-inset-bottom)); background: rgb(255 255 255 / 0.88);
  border-top: 1px solid var(--border); box-shadow: 0 -8px 24px -12px rgb(15 23 42 / 0.2);
  -webkit-backdrop-filter: var(--glass-blur); backdrop-filter: var(--glass-blur);
}
@supports not ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) { .sticky-cta { background: var(--surface); } }
.sticky-cta__text { min-width: 0; flex: 1; line-height: 1.25; }
.sticky-cta__text strong { display: block; font-size: 0.9375rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sticky-cta__text span { font-size: var(--fs-sm); color: var(--text-muted); }
@media (min-width: 992px) { .sticky-cta { display: none; } }
@media (max-width: 991.98px) { .has-sticky-cta .site-footer { padding-bottom: 11rem; } }

/* Contact */
.contact-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.75rem; }
.contact-list li { display: flex; gap: 1rem; align-items: flex-start; padding: 1rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); }
.contact-list__icon { display: inline-flex; align-items: center; justify-content: center; width: 2.5rem; height: 2.5rem; flex-shrink: 0; border-radius: var(--radius-md); background: var(--primary-50); color: var(--primary-700); }
.contact-list__label { display: block; font-size: var(--fs-xs); font-weight: var(--fw-semibold); text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); margin-bottom: 0.125rem; }
.contact-list .hours-list { margin-top: 0.25rem; }
.contact-list li > div { flex: 1; min-width: 0; }
.legal { max-width: 52rem; }

/* === 5. Patient pages ============================================================ */
.next-appt {
  position: relative; overflow: hidden; isolation: isolate; height: 100%; display: flex; flex-direction: column; gap: 0.5rem;
  padding: var(--sp-5); border-radius: var(--radius-xl); color: #fff;
  background: linear-gradient(135deg, var(--primary-700) 0%, var(--primary-900) 100%); box-shadow: var(--shadow-lg);
}
.next-appt::after { content: ""; position: absolute; z-index: -1; right: -4rem; top: -4rem; width: 14rem; height: 14rem; border-radius: 50%; background: rgb(255 255 255 / 0.08); }
.next-appt__label { display: inline-flex; align-items: center; gap: 0.5rem; font-size: var(--fs-sm); font-weight: var(--fw-semibold); text-transform: uppercase; letter-spacing: 0.08em; color: rgb(255 255 255 / 0.85); margin: 0; }
.next-appt__when { font-size: clamp(1.375rem, 1.1rem + 1.2vw, 1.875rem); font-weight: var(--fw-bold); line-height: 1.2; color: #fff; margin: 0.25rem 0; letter-spacing: -0.01em; }
.next-appt__meta { display: flex; flex-wrap: wrap; gap: 0.5rem 1.25rem; margin: 0; color: rgb(255 255 255 / 0.92); }
.next-appt__meta span { display: inline-flex; align-items: center; gap: 0.375rem; }
.next-appt .status-badge { background: rgb(255 255 255 / 0.92); }
.next-appt__actions { margin-top: auto; padding-top: 1rem; display: flex; flex-wrap: wrap; gap: 0.5rem; }
.next-appt--empty { background: var(--surface); color: var(--text); border: 1px solid var(--border); box-shadow: var(--shadow-sm); }
.next-appt--empty::after { background: var(--primary-50); }
.next-appt--empty .next-appt__label { color: var(--primary-700); }
.action-tiles { display: grid; gap: 0.75rem; grid-template-columns: 1fr 1fr; }
.action-tile {
  position: relative; display: flex; flex-direction: column; gap: 0.625rem; padding: 1rem; min-height: 7rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-xs);
  color: var(--neutral-900); text-decoration: none; font-weight: var(--fw-semibold);
  transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.action-tile:hover { color: var(--neutral-900); }
@media (hover: hover) { .action-tile:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--primary-200); } }
.action-tile__icon { display: inline-flex; align-items: center; justify-content: center; width: 2.5rem; height: 2.5rem; border-radius: var(--radius-md); background: var(--primary-50); color: var(--primary-700); }
.action-tile small { display: block; font-weight: var(--fw-regular); color: var(--text-muted); line-height: 1.35; }
.action-tile .badge { position: absolute; top: 0.75rem; right: 0.75rem; }
.notice-card { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.75rem; }
.notice-card__text { display: flex; gap: 0.75rem; align-items: flex-start; min-width: 0; flex: 1 1 12rem; }
.notice-card__text > .icon { color: var(--primary-700); margin-top: 0.15rem; }

/* Appointment list */
.appt-list { display: grid; gap: 0.625rem; list-style: none; padding: 0; margin: 0; }
.appt-row {
  display: flex; align-items: center; gap: 1rem; padding: 0.875rem 1rem; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); color: var(--text); text-decoration: none; box-shadow: var(--shadow-xs);
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur) var(--ease);
}
.appt-row:hover { color: var(--text); border-color: var(--primary-200); box-shadow: var(--shadow-md); }
.appt-row__date { display: flex; flex-direction: column; align-items: center; justify-content: center; width: 3.5rem; min-height: 3.5rem; flex-shrink: 0; border-radius: var(--radius-md); background: var(--primary-50); color: var(--primary-900); line-height: 1.1; }
.appt-row__date b { font-size: 1.25rem; }
.appt-row__date small { font-size: 0.6875rem; text-transform: uppercase; font-weight: var(--fw-semibold); letter-spacing: 0.04em; }
.appt-row__main { flex: 1; min-width: 0; }
.appt-row__title { font-weight: var(--fw-semibold); display: block; }
.appt-row__when { color: var(--text-muted); font-size: var(--fs-sm); }
.appt-row__status { flex-shrink: 0; }
@media (max-width: 575.98px) { .appt-row { flex-wrap: wrap; } .appt-row__status { width: 100%; padding-left: 4.5rem; } }
.appt-row .icon.chev { color: var(--neutral-400); }

/* Booking wizard */
.wizard-steps { display: flex; align-items: center; gap: 0; list-style: none; padding: 0; margin: 0 0 var(--sp-5); counter-reset: none; }
.wizard-steps li { display: flex; align-items: center; gap: 0.5rem; color: var(--text-muted); font-size: var(--fs-sm); font-weight: var(--fw-medium); flex: 0 0 auto; }
.wizard-steps li:not(:last-child)::after { content: ""; display: block; width: clamp(1rem, 6vw, 3.5rem); height: 2px; margin: 0 0.625rem; background: var(--neutral-200); border-radius: 2px; }
.wizard-steps li.is-done:not(:last-child)::after { background: var(--primary-600); }
.wizard-steps li > span:first-child { display: inline-flex; width: 1.875rem; height: 1.875rem; align-items: center; justify-content: center; border-radius: 50%; border: 2px solid var(--neutral-300); background: var(--surface); font-size: 0.8125rem; font-weight: var(--fw-bold); flex-shrink: 0; }
.wizard-steps li.is-current { color: var(--neutral-900); font-weight: var(--fw-semibold); }
.wizard-steps li.is-current > span:first-child { background: var(--primary-700); border-color: var(--primary-700); color: #fff; box-shadow: 0 0 0 4px var(--primary-100); }
.wizard-steps li.is-done > span:first-child { background: var(--primary-50); border-color: var(--primary-600); color: var(--primary-800); }
@media (max-width: 479.98px) { .wizard-steps li:not(.is-current) .wizard-steps__label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; } }
.service-pick {
  position: relative; display: flex; gap: 1rem; align-items: flex-start; height: 100%; padding: 1.125rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-xs);
  color: var(--text); text-decoration: none;
  transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.service-pick:hover { color: var(--text); }
@media (hover: hover) { .service-pick:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--primary-300); } }
.service-pick__icon { display: inline-flex; align-items: center; justify-content: center; width: 2.75rem; height: 2.75rem; flex-shrink: 0; border-radius: var(--radius-md); background: var(--primary-50); color: var(--primary-700); }
.service-pick__title { font-size: 1.0625rem; margin: 0 0 0.25rem; }
.service-pick__text { color: var(--text-muted); margin: 0 0 0.5rem; font-size: var(--fs-sm); }
.service-pick__meta { display: flex; flex-wrap: wrap; gap: 0.75rem; font-size: var(--fs-sm); color: var(--neutral-700); font-weight: var(--fw-medium); }
.service-pick__meta span { display: inline-flex; align-items: center; gap: 0.3rem; }
.service-pick__chev { margin-left: auto; align-self: center; color: var(--neutral-400); }
.colour-dot { display: inline-block; width: 0.75rem; height: 0.75rem; border-radius: 50%; vertical-align: middle; box-shadow: 0 0 0 2px var(--surface), 0 0 0 3px var(--border); }

/* Booking review (D-147): the address block only for home visits, the typed-address fields only for
   "Outro endereço…". Read from the form state itself, so it holds before and without booking.js. */
form:has(.location-radio:checked:not([value="home"])) .home-address { display: none; }
.home-address:has(.address-choice) [data-new-address] { display: none; }
.home-address:has(.address-choice option[value="novo"]:checked) [data-new-address] { display: block; }
.booking-calendar { padding: 1.25rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }
.booking-calendar h2 { font-size: 1.0625rem; font-weight: var(--fw-semibold); }
.booking-calendar h2::first-letter { text-transform: uppercase; }
.booking-calendar .btn-sm { width: 2.5rem; padding: 0; border-radius: 50%; }
.booking-calendar__grid { width: 100%; table-layout: fixed; text-align: center; border-collapse: separate; border-spacing: 0.25rem; }
.booking-calendar__grid th { font-size: var(--fs-xs); font-weight: var(--fw-semibold); color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; padding-bottom: 0.25rem; }
.booking-calendar .day { display: inline-flex; width: 100%; aspect-ratio: 1; max-width: 2.875rem; min-height: 2.5rem; align-items: center; justify-content: center; border-radius: var(--radius-md); border: 0; background: none; font-variant-numeric: tabular-nums; }
.booking-calendar .day.is-available {
  background: var(--primary-50); border: 1px solid var(--primary-200); color: var(--primary-900); font-weight: var(--fw-semibold);
  transition: background-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}
.booking-calendar .day.is-available:hover, .booking-calendar .day.is-available:focus-visible { background: var(--primary-700); border-color: var(--primary-700); color: #fff; }
.booking-calendar .day.is-available[aria-pressed="true"] { background: var(--primary-700); border-color: var(--primary-700); color: #fff; box-shadow: 0 0 0 3px var(--primary-100); }
.booking-calendar .day.is-unavailable { color: var(--neutral-500); }  /* NF-03: 5.7:1; available days also differ by fill, border and weight */
.slots-panel { padding: 1.25rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); min-height: 100%; }
.slots-panel h2 { font-size: 1.0625rem; display: flex; align-items: center; gap: 0.5rem; }
.slots-panel h2 .icon { color: var(--primary-700); }
.slot-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(5.75rem, 1fr)); gap: 0.625rem; }
.slot-btn { width: 100%; min-height: 3rem; font-size: 1.0625rem; font-variant-numeric: tabular-nums; border-radius: var(--radius-md); border-width: 1.5px; }
.slot-btn:hover, .slot-btn:focus-visible { transform: translateY(-1px); }
.wizard-review { max-width: 44rem; }
.review-summary { display: grid; gap: 0.75rem; padding: 1.125rem; margin-bottom: 1.25rem; border-radius: var(--radius-lg); background: var(--primary-50); border: 1px solid var(--primary-100); }
.review-summary__row { display: flex; gap: 0.75rem; align-items: flex-start; }
.review-summary__row .icon { color: var(--primary-700); margin-top: 0.125rem; }
.review-summary strong { color: var(--neutral-900); }
.location-options { display: grid; gap: 0.5rem; }
.location-options .form-check {
  position: relative; margin: 0; padding: 0.875rem 1rem 0.875rem 3rem; border: 1px solid var(--border); border-radius: var(--radius-md);
  background: var(--surface); transition: border-color var(--dur-fast) var(--ease), background-color var(--dur-fast) var(--ease);
}
.location-options .form-check-input { position: absolute; left: 1rem; top: 1.05rem; margin: 0; }
.location-options .form-check:has(.form-check-input:checked) { border-color: var(--primary-600); background: var(--primary-50); box-shadow: 0 0 0 1px var(--primary-600); }
.location-options .form-check-label { font-weight: var(--fw-medium); cursor: pointer; }
.location-options .location-option--unavailable { opacity: 0.7; background: var(--surface-sunken); border-style: dashed; }
.location-options .location-option--unavailable .form-check-label { cursor: not-allowed; color: var(--text-muted); }
@media (max-width: 767.98px) {
  .wizard-cta { position: sticky; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 0.5rem); z-index: 5; margin: 1rem -0.5rem 0; padding: 0.75rem; border-radius: var(--radius-lg); background: rgb(255 255 255 / 0.92); box-shadow: var(--shadow-lg); border: 1px solid var(--border); -webkit-backdrop-filter: var(--glass-blur); backdrop-filter: var(--glass-blur); }
  .wizard-cta .btn-lg { width: 100%; }
}

/* Exercises */
.exercise-plan { padding: var(--sp-5); margin-bottom: var(--sp-5); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-xl); box-shadow: var(--shadow-sm); }
.exercise-plan__head { display: flex; gap: 1rem; align-items: flex-start; margin-bottom: 1rem; }
.exercise-plan__icon { display: inline-flex; align-items: center; justify-content: center; width: 3rem; height: 3rem; flex-shrink: 0; border-radius: var(--radius-md); background: var(--primary-50); color: var(--primary-700); }
.exercise-list { display: grid; gap: 0.875rem; }
.exercise-item { padding: 1.125rem; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--neutral-25); }
.exercise-item__head { display: flex; gap: 0.75rem; align-items: flex-start; margin-bottom: 0.625rem; }
.exercise-item__n { display: inline-flex; align-items: center; justify-content: center; width: 2rem; height: 2rem; flex-shrink: 0; border-radius: 50%; background: var(--primary-700); color: #fff; font-weight: var(--fw-bold); font-size: 0.875rem; }
.exercise-item__title { font-size: 1.0625rem; margin: 0.2rem 0 0; }
.exercise-dose { display: flex; flex-wrap: wrap; gap: 0.375rem; list-style: none; padding: 0; margin: 0 0 0.75rem; }
.dose-badge { display: inline-flex; align-items: center; gap: 0.3rem; padding: 0.3rem 0.625rem; border-radius: var(--radius-pill); background: var(--surface); border: 1px solid var(--primary-200); color: var(--primary-900); font-size: var(--fs-sm); }
.dose-badge strong { font-weight: var(--fw-bold); }
.dose-badge .icon { color: var(--primary-700); }
.exercise-media { border-radius: var(--radius-md); overflow: hidden; }
.exercise-thumb { max-width: 12rem; height: auto; border-radius: var(--radius-sm); }
.exercise-img { width: 100%; max-height: 16rem; object-fit: contain; background: var(--surface); border-radius: var(--radius-md); border: 1px solid var(--border); }
.past-plans > summary { display: inline-flex; align-items: center; gap: 0.5rem; padding: 0.75rem 1rem; border-radius: var(--radius-md); background: var(--surface); border: 1px solid var(--border); font-weight: var(--fw-semibold); list-style: none; min-height: var(--tap); }
.past-plans > summary::-webkit-details-marker { display: none; }
.past-plans[open] > summary .icon { transform: rotate(180deg); }
.past-plans > summary .icon { transition: transform var(--dur) var(--ease); }

/* Documents */
.doc-list { display: grid; gap: 0.5rem; list-style: none; padding: 0; margin: 0; }
.doc-row { display: flex; align-items: center; gap: 0.875rem; padding: 0.75rem 0.875rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); }
.doc-row__icon { display: inline-flex; align-items: center; justify-content: center; width: 2.75rem; height: 2.75rem; flex-shrink: 0; border-radius: var(--radius-md); background: var(--primary-50); color: var(--primary-700); }
.doc-row__icon--pdf { background: var(--danger-bg); color: var(--danger); }
.doc-row__icon--image { background: var(--info-bg); color: var(--info); }
.doc-row__main { flex: 1; min-width: 0; }
.doc-row__name { font-weight: var(--fw-semibold); display: block; overflow-wrap: anywhere; }
.doc-row__meta { font-size: var(--fs-sm); color: var(--text-muted); }

/* Auth extras kept from M2 */
.qr-box { width: 14rem; padding: 0.75rem; background: #fff; border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }
.qr-box svg { width: 100%; height: auto; display: block; }
.recovery-codes { display: grid; grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr)); gap: 0.5rem; max-width: 30rem; margin-bottom: 1.5rem; }
.recovery-codes code { display: block; padding: 0.5rem 0.75rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 1.05rem; user-select: all; color: var(--neutral-900); }

/* === 6. Admin pages =============================================================== */
.dash-grid { display: grid; gap: var(--sp-5); }
@media (min-width: 1200px) { .dash-grid { grid-template-columns: 1.6fr 1fr; align-items: start; } }
.revenue-card { display: flex; flex-wrap: wrap; align-items: center; gap: 1rem 2rem; }
.revenue-card__item { display: flex; flex-direction: column; }
.revenue-card__label { font-size: var(--fs-sm); color: var(--text-muted); font-weight: var(--fw-medium); }
.revenue-card__value { font-size: 1.5rem; font-weight: var(--fw-bold); letter-spacing: -0.01em; color: var(--neutral-900); font-variant-numeric: tabular-nums; }
.revenue-card .progress { flex-basis: 100%; height: 0.5rem; }
.timeline-today { list-style: none; padding: 0; margin: 0; position: relative; }
.timeline-today::before { content: ""; position: absolute; left: 3.6rem; top: 0.5rem; bottom: 0.5rem; width: 2px; background: var(--neutral-200); border-radius: 2px; }
.timeline-today__item { position: relative; display: grid; grid-template-columns: 3rem 1fr; gap: 1.25rem; padding: 0.625rem 0; }
.timeline-today__time { font-weight: var(--fw-bold); font-variant-numeric: tabular-nums; color: var(--neutral-900); padding-top: 0.6rem; text-align: right; font-size: 0.9375rem; }
.timeline-today__item::before { content: ""; position: absolute; left: calc(3.6rem - 5px); top: 1.2rem; width: 12px; height: 12px; border-radius: 50%; background: var(--surface); border: 2px solid var(--primary-600); }
.timeline-today__item.is-past::before { background: var(--primary-600); }
.timeline-today__card { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem 1rem; padding: 0.75rem 1rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); }
.timeline-today__who { min-width: 0; }
.timeline-today__who a { font-weight: var(--fw-semibold); color: var(--neutral-900); text-decoration: none; }
.timeline-today__who a:hover { color: var(--link); text-decoration: underline; }
.timeline-today__who span { display: block; font-size: var(--fs-sm); color: var(--text-muted); }
.timeline-today__actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; font-size: var(--fs-sm); }

/* Tables that turn into stacked cards on phones (<768). Cells carry data-label. */
@media (max-width: 767.98px) {
  .table-stack thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .table-stack, .table-stack tbody, .table-stack tr, .table-stack td { display: block; width: 100%; }
  .table-stack tr { padding: 0.75rem 1rem; border-bottom: 1px solid var(--border); }
  .table-stack tr:last-child { border-bottom: 0; }
  .table-stack > :not(caption) > * > * { padding: 0.2rem 0; border: 0; box-shadow: none; }
  .table-stack td[data-label]::before { content: attr(data-label); display: block; font-size: var(--fs-xs); font-weight: var(--fw-semibold); text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); }
  .table-stack td:first-child { font-size: 1.0625rem; }
}
.table-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-xs); overflow: hidden; }
.table-card .table { --bs-table-bg: transparent; }
.table-card .table > tbody > tr:last-child > * { border-bottom: 0; }
.table-responsive.card-soft { box-shadow: var(--shadow-xs); }
.cell-person { display: flex; align-items: center; gap: 0.75rem; }
.cell-person a { font-weight: var(--fw-semibold); }

/* Filter bar */
.filter-bar { padding: 1rem; margin-bottom: var(--sp-4); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-xs); }

/* Patient profile header */
.patient-head { display: flex; flex-wrap: wrap; align-items: center; gap: 1rem 1.25rem; margin-bottom: var(--sp-4); padding: var(--sp-5); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-xl); box-shadow: var(--shadow-sm); }
.patient-head__main { flex: 1 1 18rem; min-width: 0; }
.patient-head__name { font-size: clamp(1.375rem, 1.1rem + 1vw, 1.75rem); margin: 0 0 0.25rem; }
.patient-head__meta { display: flex; flex-wrap: wrap; align-items: center; gap: 0.375rem 1rem; margin: 0; font-size: var(--fs-sm); color: var(--text-muted); }
.patient-head__meta > span { display: inline-flex; align-items: center; gap: 0.3rem; }
.patient-head__actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.patient-tabs { margin-bottom: var(--sp-5); background: var(--surface); border-radius: var(--radius-lg) var(--radius-lg) 0 0; }

/* Prontuário timeline */
.record-timeline { position: relative; display: grid; gap: 1rem; padding-left: 1.75rem; }
.record-timeline::before { content: ""; position: absolute; left: 0.55rem; top: 0.5rem; bottom: 0.5rem; width: 2px; background: linear-gradient(var(--primary-200), var(--neutral-200)); border-radius: 2px; }
.record-entry { position: relative; }
.record-entry::before { content: ""; position: absolute; left: -1.6rem; top: 1.25rem; width: 0.875rem; height: 0.875rem; border-radius: 50%; background: var(--surface); border: 3px solid var(--primary-600); }
.record-entry--superseded::before { border-color: var(--neutral-400); }
.record-entry--superseded .record-entry__body { text-decoration: line-through; text-decoration-color: var(--neutral-400); color: var(--neutral-600); }  /* no opacity: keeps AA contrast */
.record-entry__type { display: inline-flex; align-items: center; gap: 0.3rem; }
.record-data { display: grid; grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr)); gap: 0.375rem 1rem; padding: 0.75rem; border-radius: var(--radius-md); background: var(--neutral-50); }
.record-data div { display: flex; gap: 0.5rem; }
.record-data dt { font-weight: var(--fw-semibold); }
.record-data dd { margin: 0; }
.eva-scale__n { min-width: 2.75rem; }
.close-session textarea { font-size: 0.875rem; }
.pain-chart-card { padding: 1rem 1.25rem; }

/* Agenda — FullCalendar themed to the tokens. */
.fc {
  --fc-border-color: var(--neutral-200); --fc-page-bg-color: var(--surface); --fc-neutral-bg-color: var(--neutral-50);
  --fc-today-bg-color: rgba(var(--fisio-accent-rgb), 0.06); --fc-now-indicator-color: var(--danger);
  --fc-button-bg-color: var(--surface); --fc-button-border-color: var(--border-strong); --fc-button-text-color: var(--neutral-800);
  --fc-button-hover-bg-color: var(--neutral-100); --fc-button-hover-border-color: var(--neutral-400);
  --fc-button-active-bg-color: var(--primary-700); --fc-button-active-border-color: var(--primary-700);
  --fc-event-border-color: transparent; --fc-highlight-color: rgba(var(--fisio-accent-rgb), 0.12);
  --fc-list-event-hover-bg-color: var(--neutral-50); --fc-bg-event-opacity: 1;
  font-family: var(--font-sans); font-size: var(--fs-sm);
}
/* The card lives on a wrapper: FullCalendar sizes its grid from its root element's box. */
.agenda-card { background: var(--surface); border-radius: var(--radius-lg); padding: 1rem; border: 1px solid var(--border); box-shadow: var(--shadow-sm); }
.fc .fc-toolbar { flex-wrap: wrap; gap: 0.75rem; }
.fc .fc-toolbar.fc-header-toolbar { margin-bottom: 1rem; }
.fc .fc-toolbar-title { font-size: var(--fs-lg); font-weight: var(--fw-semibold); letter-spacing: -0.01em; }
.fc .fc-button { min-height: 2.5rem; padding: 0.375rem 0.875rem; border-radius: var(--radius-md) !important; font-weight: var(--fw-medium); text-transform: none; box-shadow: none !important; transition: background-color var(--dur-fast) var(--ease); }
.fc .fc-button-group { gap: 0.25rem; }
.fc .fc-button-primary:not(:disabled).fc-button-active, .fc .fc-button-primary:not(:disabled):active { color: #fff; }
.fc .fc-button-primary:focus-visible { box-shadow: var(--focus-ring) !important; }
.fc .fc-today-button:disabled { opacity: 1; color: var(--neutral-600); background: var(--neutral-50); }
.fc .fc-col-header-cell { padding: 0.5rem 0; background: var(--neutral-50); }
.fc .fc-col-header-cell-cushion { color: var(--neutral-700); font-weight: var(--fw-semibold); text-decoration: none; text-transform: capitalize; }
.fc .fc-day-today .fc-col-header-cell-cushion { color: var(--primary-800); }
.fc .fc-day-today.fc-col-header-cell { box-shadow: inset 0 -2px 0 var(--primary-600); }
.fc .fc-timegrid-slot { height: 2.5rem; }
.fc .fc-timegrid-slot-minor { border-top-style: dotted; }
.fc .fc-timegrid-slot-label-cushion, .fc .fc-timegrid-axis-cushion { color: var(--text-muted); font-size: var(--fs-xs); font-variant-numeric: tabular-nums; }
.fc .fc-non-business { background: rgb(241 245 249 / 0.6); }
.fc .fc-daygrid-day-number { color: var(--neutral-700); text-decoration: none; }
.fc-theme-standard .fc-scrollgrid { border-radius: var(--radius-md); overflow: hidden; }
.fc .fc-timegrid-event, .fc .fc-daygrid-block-event { border-radius: var(--radius-sm); border-width: 0 0 0 3px !important; border-left-color: rgb(0 0 0 / 0.22) !important; box-shadow: var(--shadow-xs); }
.fc .fc-timegrid-event .fc-event-main { padding: 0.25rem 0.375rem; }
.fc .fc-event-time { font-weight: var(--fw-semibold); font-size: 0.6875rem; opacity: 0.95; }
.fc .fc-event-title { font-weight: var(--fw-medium); line-height: 1.25; }
.fc .fc-event { transition: filter var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease); cursor: pointer; }
.fc .fc-event:hover { filter: brightness(1.06) saturate(1.05); }
.fc .fc-list-event-title a { color: var(--neutral-900); text-decoration: none; }
.fc .fc-list-day-cushion { background: var(--neutral-50); }
/* Status styling (D-xx): dashed = pending, striped = proposed, faded = cancelled. */
.fc .status-pending { border: 2px dashed rgb(255 255 255 / 0.9) !important; outline: 1px solid rgb(0 0 0 / 0.15); opacity: 0.9; }
.fc .status-proposed { background-image: repeating-linear-gradient(45deg, rgb(255 255 255 / 0.3) 0 6px, transparent 6px 12px) !important; }
.fc .status-cancelled { opacity: 0.45; text-decoration: line-through; filter: grayscale(0.4); }
/* D-152: "Intervalo depois" — a faded, hatched strip in the service colour right after the session. */
.fc .fc-timegrid-event.agenda-buffer { opacity: 0.4; box-shadow: none; border: 1px dashed rgb(0 0 0 / 0.25) !important; border-top: 0 !important; border-radius: 0 0 var(--radius-sm) var(--radius-sm); background-image: repeating-linear-gradient(135deg, rgb(255 255 255 / 0.55) 0 3px, transparent 3px 7px) !important; }
.fc .fc-timegrid-event.agenda-buffer .fc-event-main { display: none; }
.fc .fc-timegrid-event.agenda-buffer:hover { filter: none; opacity: 0.6; }
.fc .fc-list .agenda-buffer, .fc .fc-daygrid .agenda-buffer, .fc .fc-daygrid-event-harness:has(.agenda-buffer) { display: none; }
.fc .bg-block { background: repeating-linear-gradient(45deg, rgb(185 28 28 / 0.08) 0 8px, rgb(185 28 28 / 0.14) 8px 16px) !important; }
.fc .bg-extra { background: rgb(21 128 61 / 0.1) !important; }
.fc .bg-google { background: rgb(100 116 139 / 0.18) !important; }
.fc .fc-bg-event .fc-event-title { color: var(--neutral-700); font-style: normal; font-size: var(--fs-xs); font-weight: var(--fw-medium); }
@media (max-width: 767.98px) {
  .agenda-card { padding: 0.75rem; margin-inline: -0.25rem; }
  .fc .fc-toolbar { display: grid; grid-template-columns: auto 1fr; }
  .fc .fc-toolbar-chunk:nth-child(2) { grid-column: 1 / -1; grid-row: 1; }
  .fc .fc-toolbar-title { font-size: 1.0625rem; }
}
.agenda-legend { display: flex; flex-wrap: wrap; gap: 0.5rem 1rem; font-size: var(--fs-sm); color: var(--text-muted); margin-top: 0.75rem; }
.agenda-legend span { display: inline-flex; align-items: center; gap: 0.375rem; }
.agenda-legend i { display: inline-block; width: 1.5rem; height: 0.875rem; border-radius: 3px; background: var(--neutral-500); }
.agenda-legend .lg-pending { background: transparent; border: 2px dashed var(--neutral-500); }
.agenda-legend .lg-proposed { background-image: repeating-linear-gradient(45deg, rgb(255 255 255 / 0.45) 0 4px, transparent 4px 8px); }
.agenda-legend .lg-cancelled { opacity: 0.4; }
.agenda-legend .lg-buffer { opacity: 0.45; border: 1px dashed var(--neutral-700); background-image: repeating-linear-gradient(135deg, rgb(255 255 255 / 0.55) 0 3px, transparent 3px 7px); }

/* Patient calendar (Meus agendamentos → Calendário): colour per status, text always says it too. */
.fc .pc-confirmed { --fc-event-bg-color: var(--primary-700); --fc-event-border-color: var(--primary-700); --fc-event-text-color: #fff; }
.fc .pc-pending   { --fc-event-bg-color: var(--warning-bg); --fc-event-border-color: var(--warning); --fc-event-text-color: var(--warning-text); }
.fc .pc-proposed  { --fc-event-bg-color: var(--info-bg); --fc-event-border-color: var(--info); --fc-event-text-color: var(--info-text); }
.fc .pc-completed { --fc-event-bg-color: var(--success-bg); --fc-event-border-color: var(--success); --fc-event-text-color: var(--success-text); }
.fc .pc-no_show   { --fc-event-bg-color: var(--danger-bg); --fc-event-border-color: var(--danger); --fc-event-text-color: var(--danger-text); }
.fc .fc-daygrid-block-event.pc-pending { outline: 1px dashed var(--warning); outline-offset: -1px; }
.fc .fc-daygrid-block-event.pc-proposed { background-image: repeating-linear-gradient(135deg, transparent 0 5px, rgb(3 105 161 / 0.1) 5px 10px); }
.fc .fc-daygrid-block-event:is(.pc-pending, .pc-proposed, .pc-completed, .pc-no_show) { border-left-color: var(--fc-event-border-color) !important; }
.fc .fc-daygrid-block-event .fc-event-main { white-space: normal; }
.fc .fc-daygrid-block-event .fc-event-time { flex: none; }
.fc .fc-list-day-cushion a { color: var(--neutral-800); text-decoration: none; }
.fc .fc-daygrid-block-event .fc-event-title { overflow-wrap: anywhere; }
.pc-legend .lg-confirmed { background: var(--primary-700); }
.pc-legend .lg-pending { background: var(--warning-bg); border: 1px dashed var(--warning); }
.pc-legend .lg-proposed { background-color: var(--info-bg); border: 1px solid var(--info); background-image: repeating-linear-gradient(135deg, transparent 0 4px, rgb(3 105 161 / 0.15) 4px 8px); }
.pc-legend .lg-completed { background: var(--success-bg); border: 1px solid var(--success); }
.pc-legend .lg-no_show { background: var(--danger-bg); border: 1px solid var(--danger); }

/* Patient Financeiro: credit from sessions paid and then cancelled (D-145). */
.finance-credit { border-left: 3px solid var(--info); }
.finance-credit-badge { display: inline-flex; align-items: center; gap: 0.3rem; margin-top: 0.25rem; background: var(--info-bg); color: var(--info-text); border: 1px solid var(--info-border); font-weight: var(--fw-semibold); }
/* D-148: the netted position card — red: the patient owes; green: credit; neutral: settled. */
.finance-position { border-left: 4px solid var(--border); }
.finance-position__tag { display: inline-flex; align-items: center; gap: 0.35rem; font-size: var(--fs-sm); font-weight: var(--fw-semibold); color: var(--text-muted); }
.finance-position--debt { border-left-color: var(--danger); background: var(--danger-bg); }
.finance-position--debt .finance-position__tag, .finance-position--debt .display-6 { color: var(--danger); }
.finance-position--credit { border-left-color: var(--success); background: var(--success-bg); }
.finance-position--credit .finance-position__tag, .finance-position--credit .display-6 { color: var(--success); }
.finance-position--settled .finance-position__tag { color: var(--success-text); }
.finance-breakdown { display: grid; gap: 0.1rem; max-width: 16rem; }
.finance-breakdown > div { display: flex; justify-content: space-between; gap: 1rem; }
.finance-breakdown dt { font-weight: 400; color: var(--text-muted, var(--bs-secondary-color)); }
.finance-breakdown dd { margin: 0; font-variant-numeric: tabular-nums; }

/* Catalogue & availability (M3) */
.weekly-rules__day { display: flex; flex-wrap: wrap; gap: 0.5rem 1rem; padding: 0.75rem 0; border-bottom: 1px solid var(--border); }
.weekly-rules__day:last-child { border-bottom: 0; }
.weekly-rules__name { min-width: 8.5rem; font-weight: var(--fw-semibold); }
.weekly-rules__slots { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.rule-chip { display: inline-flex; align-items: center; gap: 0.35rem; padding: 0.2rem 0.35rem 0.2rem 0.7rem; border-radius: var(--radius-pill); background: var(--primary-50); border: 1px solid var(--primary-200); color: var(--primary-900); font-size: var(--fs-sm); font-weight: var(--fw-medium); font-variant-numeric: tabular-nums; }
.btn-close-sm { width: 0.6rem; height: 0.6rem; padding: 0.3rem; min-width: 1.25rem; min-height: 1.25rem; }
.locations-checks ul { list-style: none; padding: 0; }
.locations-checks ul li { display: flex; gap: 0.5rem; align-items: center; min-height: 2rem; }

/* Reports */
.report-section { scroll-margin-top: calc(var(--header-h) + var(--banner-h) + 1rem); }
.report-nav { position: sticky; top: calc(var(--header-h) + var(--banner-h)); z-index: 5; display: flex; gap: 0.25rem; overflow-x: auto; padding: 0.5rem 0; margin-bottom: 1rem; background: var(--surface-alt); scrollbar-width: none; }
.report-nav a { white-space: nowrap; }
.chart-card { padding: 1rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-xs); }
.heatmap td { font-variant-numeric: tabular-nums; }
.report-section .display-6 { font-size: clamp(1.5rem, 1.15rem + 1vw, 2rem); font-weight: var(--fw-bold); letter-spacing: -0.02em; white-space: nowrap; color: var(--neutral-900); }

/* Contact-message inbox (/painel/mensagens) */
.message-list { display: grid; gap: 0.75rem; }
.message-card { padding: 1rem 1.25rem; }
.message-card.is-unread { border-left: 3px solid var(--info); }
.message-card__head { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 0.75rem; }
.message-card__who { display: flex; flex-direction: column; min-width: 0; flex: 1 1 12rem; }
.message-card__who .small { overflow-wrap: anywhere; }
.message-card__text { margin: 0.75rem 0; white-space: pre-line; overflow-wrap: anywhere; }
.message-card__actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.message-card__delete > summary { list-style: none; }
.message-card__delete > summary::-webkit-details-marker { display: none; }
.message-card__delete[open] { flex-basis: 100%; text-align: right; }

/* "Novo agendamento" patient search (D-147): a picked patient collapses the other results. */
.patient-pick:has(input[name="patient_id"]:checked) .list-group-item:not(:has(input:checked)) { display: none !important; } /* beats .d-flex */
.patient-pick .list-group-item:has(input:checked) { background: var(--primary-50); border-color: var(--primary-200); }
.patient-pick .form-check-input { margin-left: 0; flex: none; } /* the global -2rem assumes a .form-check wrapper */
.patient-pick__change { display: none; }
.patient-pick:has(input[name="patient_id"]:checked) .patient-pick__change { display: inline-block; }

/* Agenda focus views (dashboard tiles -> /painel/agenda?vista=…) */
.agenda-focus { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 1rem; padding: 0.75rem 1rem; margin-bottom: var(--sp-4); background: var(--info-bg); border: 1px solid var(--info-border); border-radius: var(--radius-lg); color: var(--info-text); }
.agenda-focus__text { flex: 1 1 16rem; margin: 0; }

/* Style guide (/painel/_estilo) */
.sg-section { margin-bottom: var(--sp-7); }
.sg-section > h2 { font-size: var(--fs-xl); padding-bottom: 0.5rem; margin-bottom: 1rem; border-bottom: 1px solid var(--border); }
.sg-swatches { display: grid; gap: 0.75rem; grid-template-columns: repeat(auto-fill, minmax(8.5rem, 1fr)); }
.sg-swatch { border: 1px solid var(--border); border-radius: var(--radius-md); overflow: hidden; background: var(--surface); font-size: var(--fs-xs); }
.sg-swatch__chip { height: 3.5rem; }
.sg-swatch__meta { padding: 0.5rem 0.625rem; display: grid; }
.sg-swatch__meta code { background: none; padding: 0; color: var(--text-muted); }
.sg-row { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center; margin-bottom: 1rem; }
.sg-type > * { margin-bottom: 0.5rem; }
.sg-shadow { width: 8rem; height: 5rem; border-radius: var(--radius-lg); background: var(--surface); display: flex; align-items: center; justify-content: center; font-size: var(--fs-xs); color: var(--text-muted); }
.sg-icons { display: grid; grid-template-columns: repeat(auto-fill, minmax(7.5rem, 1fr)); gap: 0.5rem; }
.sg-icons div { display: flex; align-items: center; gap: 0.5rem; padding: 0.5rem; font-size: var(--fs-xs); border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); overflow: hidden; }
.sg-space { display: flex; align-items: center; gap: 0.75rem; font-size: var(--fs-xs); margin-bottom: 0.25rem; }
.sg-space i { display: block; height: 0.75rem; background: var(--primary-300); border-radius: 2px; }

/* === 7. Motion ===================================================================== */
/* Scroll reveal (js/ui.js): only when JS runs and motion is allowed. */
@media (prefers-reduced-motion: no-preference) {
  .reveal-on .reveal { opacity: 0; transform: translateY(var(--rise)); transition: opacity 550ms var(--ease), transform 550ms var(--ease); }
  .reveal-on .reveal.is-visible { opacity: 1; transform: none; }
  .reveal-on .reveal-stagger > * { opacity: 0; transform: translateY(var(--rise)); transition: opacity 500ms var(--ease), transform 500ms var(--ease); }
  .reveal-on .reveal-stagger.is-visible > * { opacity: 1; transform: none; }
  .reveal-on .reveal-stagger.is-visible > :nth-child(2) { transition-delay: 70ms; }
  .reveal-on .reveal-stagger.is-visible > :nth-child(3) { transition-delay: 140ms; }
  .reveal-on .reveal-stagger.is-visible > :nth-child(4) { transition-delay: 210ms; }
  .reveal-on .reveal-stagger.is-visible > :nth-child(5) { transition-delay: 280ms; }
  .reveal-on .reveal-stagger.is-visible > :nth-child(n+6) { transition-delay: 330ms; }
  .page-enter { animation: page-enter var(--dur-slow) var(--ease) both; }
}
@keyframes page-enter { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; }
  .skeleton__bone { animation: none; }
}

/* === 8. Print ========================================================================= */
@media print {
  :root { --banner-h: 0px; }
  body { background: #fff !important; font-size: 11pt; }
  .site-header, .site-footer, .app-topbar, .tabbar, .account-menu, .admin-sidebar, .admin-topbar, .app-alerts,
  .skip-link, .demo-banner, .toast-stack, .whatsapp-fab, .sticky-cta, .htmx-progress, .layout-patient .alert, .cta-band { display: none !important; }
  .app-main, .admin-content { padding: 0 !important; }
  .layout-patient, .layout-admin { background: #fff; }
  a { color: inherit; text-decoration: none; }
  .exercise-plan, .ui-card, .card-soft, .patient-head { box-shadow: none !important; border: 1px solid #ccc; break-inside: avoid-page; }
  .exercise-item { break-inside: avoid; background: #fff; }
  .dose-badge { border-color: #999; }
  .exercise-item__n { background: #fff; color: #000; border: 1px solid #000; }
  .print-entry, .record-entry { break-inside: avoid; }
  .record-timeline { padding-left: 0; } .record-timeline::before, .record-entry::before { display: none; }
  .print-record h1 { font-size: 16pt; }
  .reveal-on .reveal, .reveal-on .reveal-stagger > * { opacity: 1 !important; transform: none !important; }
}

/* --- Detail pages & small helpers (patient) --- */
.detail-card { max-width: 46rem; }
.cancel-box { padding-top: 1rem; border-top: 1px solid var(--border); }
.cancel-box > summary { min-height: var(--tap); display: inline-flex; align-items: center; }
.booking-calendar__spacer { display: inline-block; width: 2.5rem; }
.booking-calendar > div:first-child { margin-bottom: 0.75rem !important; }
.mw-form { max-width: 20rem; }
.mw-prose { max-width: var(--measure); }
.mw-card { max-width: 46rem; }
.mw-wide { max-width: 56rem; }
.mw-video { max-width: 28rem; }
.mw-time { max-width: 8rem; }
#panel-offcanvas { --bs-offcanvas-width: min(30rem, 100vw); }

/* Style guide swatches (no inline styles: CSP) */
.sg-bg-primary-50 { background: var(--primary-50); }
.sg-bg-primary-100 { background: var(--primary-100); }
.sg-bg-primary-200 { background: var(--primary-200); }
.sg-bg-primary-300 { background: var(--primary-300); }
.sg-bg-primary-400 { background: var(--primary-400); }
.sg-bg-primary-500 { background: var(--primary-500); }
.sg-bg-primary-600 { background: var(--primary-600); }
.sg-bg-primary-700 { background: var(--primary-700); }
.sg-bg-primary-800 { background: var(--primary-800); }
.sg-bg-primary-900 { background: var(--primary-900); }
.sg-bg-primary-950 { background: var(--primary-950); }
.sg-bg-neutral-0 { background: var(--neutral-0); }
.sg-bg-neutral-50 { background: var(--neutral-50); }
.sg-bg-neutral-100 { background: var(--neutral-100); }
.sg-bg-neutral-200 { background: var(--neutral-200); }
.sg-bg-neutral-300 { background: var(--neutral-300); }
.sg-bg-neutral-400 { background: var(--neutral-400); }
.sg-bg-neutral-500 { background: var(--neutral-500); }
.sg-bg-neutral-600 { background: var(--neutral-600); }
.sg-bg-neutral-700 { background: var(--neutral-700); }
.sg-bg-neutral-800 { background: var(--neutral-800); }
.sg-bg-neutral-900 { background: var(--neutral-900); }
.sg-bg-success { background: linear-gradient(90deg, var(--success) 50%, var(--success-bg) 50%); }
.sg-bg-warning { background: linear-gradient(90deg, var(--warning) 50%, var(--warning-bg) 50%); }
.sg-bg-danger { background: linear-gradient(90deg, var(--danger) 50%, var(--danger-bg) 50%); }
.sg-bg-info { background: linear-gradient(90deg, var(--info) 50%, var(--info-bg) 50%); }
.sg-shadow-xs { box-shadow: var(--shadow-xs); }
.sg-shadow-sm { box-shadow: var(--shadow-sm); }
.sg-shadow-md { box-shadow: var(--shadow-md); }
.sg-shadow-lg { box-shadow: var(--shadow-lg); }
.sg-w-1 { width: var(--sp-1); }
.sg-w-2 { width: var(--sp-2); }
.sg-w-3 { width: var(--sp-3); }
.sg-w-4 { width: var(--sp-4); }
.sg-w-5 { width: var(--sp-5); }
.sg-w-6 { width: var(--sp-6); }
.sg-w-7 { width: var(--sp-7); }
.sg-w-8 { width: var(--sp-8); }
.sg-toasts .toast-item { animation: none; }
@media (max-width: 575.98px) { .logout-btn { width: var(--tap); padding: 0; } .logout-btn .logout-btn__label { display: none; } }
.plan-notes { padding: 0.875rem 1.125rem; border-radius: var(--radius-lg); background: var(--primary-50); border-left: 4px solid var(--primary-600); max-width: none; }
.plan-notes > :last-child { margin-bottom: 0; }
@media print { .plan-notes { background: #fff; border: 1px solid #999; border-left-width: 4px; } }

[data-counter][hidden] { display: none !important; }

/* A button styled as a text link must sit on the same baseline/size as neighbouring links. */
.btn-link-inline { font: inherit; line-height: inherit; vertical-align: baseline; text-decoration: underline; text-underline-offset: 0.2em; text-decoration-thickness: from-font; border: 0; }

/* Info "?" button next to a metric label (macro info_tip). */
.info-tip { display: inline-flex; align-items: center; vertical-align: middle; padding: 0; margin-inline: 0.15rem; border: 0; background: none; color: var(--text-subtle, var(--bs-secondary-color)); cursor: help; line-height: 1; border-radius: 50%; }
.info-tip:hover, .info-tip:focus-visible { color: var(--bs-primary); }
.tooltip { --bs-tooltip-max-width: 18rem; text-align: left; }

/* Markdown fields (ui.js, textarea[data-markdown], D-141): toolbar sits on top of the textarea. */
.md-editor { position: relative; }
.md-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 0.125rem; padding: 0.25rem; background: var(--surface-alt); border: 1px solid var(--border-strong); border-bottom: 0; border-radius: var(--radius-md) var(--radius-md) 0 0; }
.md-toolbar__btn { display: inline-flex; align-items: center; justify-content: center; gap: 0.375rem; min-width: 2.25rem; min-height: 2.25rem; padding: 0 0.5rem; border: 0; border-radius: var(--radius-xs); background: transparent; color: var(--neutral-700); font-size: var(--fs-sm); font-weight: var(--fw-medium); }
.md-toolbar__btn:hover:not(:disabled) { background: var(--surface-sunken); color: var(--neutral-900); }
.md-toolbar__btn:focus-visible { outline: 0; box-shadow: var(--focus-ring); }
.md-toolbar__btn:disabled { opacity: 0.45; }
.md-toolbar__preview { margin-left: auto; }
.md-toolbar__preview[aria-pressed="true"] { background: var(--primary-50); color: var(--primary-800); }
.md-editor > textarea { border-top-left-radius: 0; border-top-right-radius: 0; }
.md-preview { min-height: 8rem; max-width: none; padding: 0.75rem 1rem; border: 1px solid var(--border-strong); border-radius: 0 0 var(--radius-md) var(--radius-md); background: var(--surface); }
.md-preview > :first-child { margin-top: 0; }
.md-preview > :last-child { margin-bottom: 0; }

/* Date/time picker (flatpickr, vendored) themed to the tokens. */
.flatpickr-calendar { font-family: var(--font-sans); border-radius: var(--radius-md); box-shadow: var(--shadow-lg); }
.flatpickr-months .flatpickr-month, .flatpickr-current-month .flatpickr-monthDropdown-months { font-weight: var(--fw-semibold); }
.flatpickr-day.today { border-color: var(--primary-400); }
.flatpickr-day.selected, .flatpickr-day.selected:hover, .flatpickr-day.selected:focus { background: var(--primary-700); border-color: var(--primary-700); color: #fff; }
.flatpickr-day:focus-visible { outline: 0; box-shadow: var(--focus-ring); }
.flatpickr-time input, .flatpickr-time .flatpickr-time-separator { font-family: var(--font-sans); }
.flatpickr-calendar.noCalendar { width: 10rem; }
/* Static calendars (inside modals/offcanvas, ui.js) must not be clipped by a scrollable modal. */
.modal-dialog-scrollable .modal-content:has(.flatpickr-calendar.open),
.modal-dialog-scrollable .modal-body:has(.flatpickr-calendar.open) { overflow: visible; }

/* Patient activity (D-154): dashboard section and /painel/atividade. */
.activity-list { list-style: none; margin: 0; padding: 0; }
.activity-list__item { display: grid; grid-template-columns: auto 1fr auto; gap: 0.25rem 0.75rem; align-items: start; padding: 0.625rem 0; border-bottom: 1px solid var(--border); }
.activity-list__item:last-child { border-bottom: 0; }
.activity-list__icon { display: inline-flex; align-items: center; justify-content: center; width: 1.875rem; height: 1.875rem; border-radius: 999px; background: var(--surface-sunken); color: var(--text-muted); }
.activity-list__item--danger .activity-list__icon { background: var(--danger-bg); color: var(--danger-text); }
.activity-list__item--warning .activity-list__icon { background: var(--warning-bg); color: var(--warning-text); }
.activity-list__item--success .activity-list__icon { background: var(--success-bg); color: var(--success-text); }
.activity-list__item.is-new .activity-list__body > p:first-child { font-weight: var(--fw-semibold); }
.activity-list__new { font-size: 0.6875rem; vertical-align: 0.1em; }
.activity-list__time { white-space: nowrap; }
.activity-pager .form-select { min-width: 5rem; }
@media (max-width: 575.98px) {
  .activity-list__item { grid-template-columns: auto 1fr; }
  .activity-list__time { grid-column: 2; }
}
