/* ==========================================================================
   LEXA - Site Styles
   Feature: F006 - Mejora Visual y Tema UI
   ========================================================================== */

/* --------------------------------------------------------------------------
   BASE
   -------------------------------------------------------------------------- */

html {
  font-size: 13px;
  position: relative;
  min-height: 100%;
}

@media (min-width: 768px) {
  html {
    font-size: 14.5px;
  }
}

body {
  font-family: var(--lexa-font-family-base);
  color: var(--lexa-gray-900);
  background-color: var(--lexa-bg-body);
  margin-bottom: 60px;
}

/* --------------------------------------------------------------------------
   FOCUS STATES - Accesibilidad
   -------------------------------------------------------------------------- */

.btn:focus,
.btn:active:focus,
.btn-link.nav-link:focus,
.form-control:focus,
.form-check-input:focus {
  box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem var(--lexa-primary, #6D28D9);
}

/* --------------------------------------------------------------------------
   LAYOUT - Sidebar + Topbar
   -------------------------------------------------------------------------- */

/* --- Sidebar --- */
.lexa-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: 250px;
  height: 100vh;
  background: var(--lexa-gray-900, #0F172A);
  color: var(--lexa-gray-300, #CBD5E1);
  z-index: var(--lexa-z-fixed, 1030);
  overflow-y: auto;
  overflow-x: hidden;
  transition: transform var(--lexa-transition-slow, 300ms ease),
              width var(--lexa-transition-slow, 300ms ease);
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
}

/* Reset Bootstrap link color inside sidebar */
.lexa-sidebar a {
  color: inherit;
  text-decoration: none;
}

.lexa-sidebar::-webkit-scrollbar { width: 4px; }
.lexa-sidebar::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
}

.lexa-sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  padding: 0 1.25rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  position: sticky;
  top: 0;
  z-index: 1;
  background: inherit;
}

.lexa-sidebar-header--light {
  background: var(--lexa-bg-subtle, #F8FAFC);
  border-bottom: 1px solid var(--lexa-border-color-subtle, rgba(0, 0, 0, 0.06));
}

.lexa-sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--lexa-white, #fff);
  text-decoration: none;
  font-weight: var(--lexa-font-weight-bold, 700);
  font-size: 1.2rem;
}

.lexa-sidebar-brand:hover { color: var(--lexa-white, #fff); }

.lexa-sidebar-brand i {
  font-size: 1.4rem;
  color: var(--lexa-primary-200, #C4B5FD);
}

.lexa-sidebar-brand-logo {
  max-width: 140px;
  max-height: 32px;
  object-fit: contain;
  display: block;
}

.lexa-sidebar-brand-logo-square,
.lexa-sidebar-brand-fallback {
  display: none;
}


.lexa-sidebar-close {
  background: none;
  border: none;
  color: var(--lexa-gray-400, #94A3B8);
  font-size: 1.1rem;
  padding: 0.25rem;
  cursor: pointer;
}

.lexa-sidebar-close:hover { color: var(--lexa-white, #fff); }

.lexa-sidebar-nav {
  padding: 0.75rem 0 1rem;
}

.lexa-sidebar-section {
  font-size: 0.65rem;
  font-weight: var(--lexa-font-weight-semibold, 600);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--lexa-gray-500, #64748B);
  padding: 1.25rem 1.25rem 0.5rem;
}

.lexa-sidebar-divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.06);
  margin: 0.75rem 1.25rem;
}

.lexa-sidebar-link {
  display: flex;
  align-items: center;
  padding: 0.6rem 1.25rem;
  color: var(--lexa-gray-300, #CBD5E1);
  text-decoration: none;
  font-size: var(--lexa-font-size-sm, 0.875rem);
  transition: all var(--lexa-transition-fast, 150ms ease);
  cursor: pointer;
  border-left: 3px solid transparent;
}

.lexa-sidebar-link:hover {
  color: var(--lexa-white, #fff);
  background: var(--lexa-gray-800, #1E293B);
}

.lexa-sidebar-link.active {
  color: var(--lexa-white, #fff);
  background: rgba(196, 181, 253, 0.1);
  border-left-color: var(--lexa-primary-200, #C4B5FD);
}

.lexa-sidebar-link > i:first-child {
  width: 1.4rem;
  margin-right: 0.75rem;
  font-size: 1.05rem;
  text-align: center;
  flex-shrink: 0;
  color: var(--lexa-gray-400, #94A3B8);
}

.lexa-sidebar-link:hover > i:first-child { color: var(--lexa-gray-200, #E2E8F0); }
.lexa-sidebar-link.active > i:first-child { color: var(--lexa-white, #fff); }

.lexa-sidebar-link > span { flex: 1; }

.lexa-sidebar-badge {
  flex: 0 0 auto !important;
  min-width: 1.25rem;
  height: 1.25rem;
  padding: 0 0.35rem;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--lexa-danger, #DC2626);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  margin-left: 0.5rem;
}

.lexa-sidebar-arrow {
  font-size: 0.65rem;
  transition: transform var(--lexa-transition-base, 200ms ease);
  margin-left: auto;
  color: var(--lexa-gray-500, #64748B);
}

.lexa-sidebar-link[aria-expanded="true"] .lexa-sidebar-arrow {
  transform: rotate(180deg);
}

.lexa-sidebar-submenu {
  padding: 0.125rem 0 0.25rem;
}

.lexa-sidebar-submenu a {
  display: flex;
  align-items: center;
  padding: 0.45rem 1.25rem 0.45rem 2.75rem;
  color: var(--lexa-gray-300, #CBD5E1);
  text-decoration: none;
  font-size: 0.8125rem;
  transition: all var(--lexa-transition-fast, 150ms ease);
}

.lexa-sidebar-submenu a:hover {
  color: var(--lexa-gray-200, #E2E8F0);
  background: rgba(255, 255, 255, 0.03);
}

.lexa-sidebar-submenu a.active {
  color: var(--lexa-white, #fff);
  font-weight: var(--lexa-font-weight-medium, 500);
}

.lexa-sidebar-submenu a i {
  width: 1.2rem;
  margin-right: 0.5rem;
  font-size: 0.85rem;
  text-align: center;
  flex-shrink: 0;
  color: var(--lexa-gray-500, #64748B);
}

.lexa-sidebar-submenu a:hover i { color: var(--lexa-gray-400, #94A3B8); }
.lexa-sidebar-submenu a.active i { color: var(--lexa-white, #fff); }

.lexa-submenu-header {
  font-size: 0.6rem;
  font-weight: var(--lexa-font-weight-semibold, 600);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--lexa-gray-500, #64748B);
  padding: 0.6rem 1.25rem 0.25rem 2.75rem;
}

.lexa-submenu-header:first-child {
  padding-top: 0.25rem;
}

/* --- Sidebar overlay (mobile) --- */
.lexa-sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: calc(var(--lexa-z-fixed, 1030) - 1);
}

.lexa-sidebar-overlay.active { display: block; }

/* --- Topbar --- */
.lexa-topbar {
  position: fixed;
  top: 0;
  left: 250px;
  right: 0;
  height: 56px;
  background: #fff;
  border-bottom: 1px solid var(--lexa-gray-300, #dee2e6);
  z-index: calc(var(--lexa-z-fixed, 1030) - 2);
  transition: left var(--lexa-transition-slow, 300ms ease);
}

.lexa-topbar-full { left: 0; }

.lexa-topbar .navbar-nav {
  flex-direction: row;
  align-items: center;
}

.lexa-topbar .nav-link {
  color: var(--lexa-gray-600, #475569) !important;
  opacity: 1;
  padding: 0.375rem 0.5rem;
  font-size: var(--lexa-font-size-sm, 0.875rem);
  border-radius: var(--lexa-border-radius-sm, 0.25rem);
}

.lexa-topbar .nav-link:hover {
  color: var(--lexa-primary, #6D28D9) !important;
  background: var(--lexa-primary-light, #EDE9FE);
}

.lexa-topbar .dropdown-menu {
  border: none;
  box-shadow: var(--lexa-shadow-lg);
  border-radius: var(--lexa-border-radius-base, 0.375rem);
  font-size: var(--lexa-font-size-sm, 0.875rem);
}

.lexa-topbar .dropdown-item {
  padding: 0.5rem 1rem;
  color: var(--lexa-gray-700);
  font-size: var(--lexa-font-size-sm, 0.875rem);
  transition: all var(--lexa-transition-fast, 150ms ease);
}

.lexa-topbar .dropdown-item:hover,
.lexa-topbar .dropdown-item:focus {
  background-color: var(--lexa-primary-light, #EDE9FE);
  color: var(--lexa-primary, #6D28D9);
}

.lexa-topbar .dropdown-item i.bi {
  margin-right: 0.5rem;
  color: var(--lexa-gray-500);
  width: 1.25em;
  display: inline-block;
}

.lexa-topbar .dropdown-item:hover i.bi {
  color: var(--lexa-primary);
}

.lexa-topbar .dropdown-divider {
  margin: 0.375rem 0;
  border-color: var(--lexa-gray-200);
}

/* Topbar search */
.lexa-topbar-search {
  max-width: 320px;
}

.lexa-topbar-search .position-relative > i {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--lexa-gray-400);
  font-size: 0.8rem;
  pointer-events: none;
}

.lexa-topbar-search input {
  padding-left: 2.25rem;
  border-radius: 2rem;
  background: var(--lexa-gray-100, #f8f9fa);
  border-color: var(--lexa-gray-300, #dee2e6);
  min-width: 240px;
  font-size: var(--lexa-font-size-sm, 0.875rem);
}

.lexa-topbar-search input:focus {
  background: #fff;
}

/* ---------- Command Palette / Global Search ---------- */

.lexa-search-kbd {
  position: absolute;
  right: 0.625rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.65rem;
  padding: 0.1rem 0.375rem;
  background: var(--lexa-gray-200, #e2e8f0);
  color: var(--lexa-gray-500, #64748b);
  border-radius: 0.25rem;
  border: 1px solid var(--lexa-gray-300, #dee2e6);
  pointer-events: none;
  line-height: 1.2;
  font-family: inherit;
}

.lexa-topbar-search input:focus ~ .lexa-search-kbd,
.lexa-topbar-search input.has-value ~ .lexa-search-kbd {
  display: none;
}

.lexa-search-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  min-width: 360px;
  max-height: 400px;
  overflow-y: auto;
  background: #fff;
  border: 1px solid var(--lexa-gray-200, #e2e8f0);
  border-radius: var(--lexa-border-radius-base, 0.375rem);
  box-shadow: var(--lexa-shadow-lg);
  z-index: var(--lexa-z-dropdown, 1000);
  padding: 0.375rem;
}

.lexa-search-category {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--lexa-gray-400, #94a3b8);
  padding: 0.5rem 0.75rem 0.25rem;
}

.lexa-search-item {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.5rem 0.75rem;
  border-radius: var(--lexa-border-radius-sm, 0.25rem);
  color: var(--lexa-gray-700, #334155);
  text-decoration: none;
  cursor: pointer;
  font-size: var(--lexa-font-size-sm, 0.875rem);
  transition: background 150ms ease;
}

.lexa-search-item:hover,
.lexa-search-item.active {
  background: var(--lexa-primary-light, #EDE9FE);
  color: var(--lexa-primary, #6D28D9);
  text-decoration: none;
}

.lexa-search-item i.bi {
  width: 1.25rem;
  text-align: center;
  color: var(--lexa-gray-400, #94a3b8);
  flex-shrink: 0;
}

.lexa-search-item:hover i.bi,
.lexa-search-item.active i.bi {
  color: var(--lexa-primary, #6D28D9);
}

.lexa-search-item-name {
  flex: 1;
}

.lexa-search-empty {
  padding: 1.5rem 0.75rem;
  text-align: center;
  color: var(--lexa-gray-400, #94a3b8);
  font-size: var(--lexa-font-size-sm, 0.875rem);
}

/* --- Main content area --- */
body.lexa-app {
  margin-bottom: 0;
  background: var(--lexa-bg-subtle, #F8FAFC);
}

.lexa-main {
  margin-left: 250px;
  padding-top: 56px;
  min-height: 100vh;
  transition: margin-left var(--lexa-transition-slow, 300ms ease);
}

.lexa-main > main {
  padding: 0.5rem 1.5rem 1rem;
}

/* --- Breadcrumb navigation --- */
.lexa-breadcrumb {
  padding: 0.25rem 1.5rem;
}
.lexa-breadcrumb .breadcrumb {
  font-size: 0.8rem;
  background: transparent;
  padding: 0;
}
.lexa-breadcrumb .breadcrumb-item a {
  color: var(--lexa-gray-500, #64748B);
  text-decoration: none;
}
.lexa-breadcrumb .breadcrumb-item a:hover {
  color: var(--lexa-primary, #6D28D9);
  text-decoration: underline;
}
.lexa-breadcrumb .breadcrumb-item.active {
  color: var(--lexa-gray-400, #94A3B8);
}
.lexa-breadcrumb .breadcrumb-item + .breadcrumb-item::before {
  color: var(--lexa-gray-300, #CBD5E1);
}
.lexa-breadcrumb .bi-house-door {
  font-size: 0.85rem;
  vertical-align: -1px;
}

.lexa-main-nosidebar {
  padding-top: 56px;
  min-height: 100vh;
}

.lexa-main-nosidebar > main {
  padding: 1.5rem;
  max-width: 1400px;
  margin: 0 auto;
}

.lexa-impersonation-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.65rem 1.5rem;
  background: #fef3c7;
  color: #78350f;
  border-bottom: 1px solid #f59e0b;
  font-size: var(--lexa-font-size-sm, 0.875rem);
}

.lexa-impersonation-banner__message {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}

.lexa-impersonation-banner__message i {
  color: #d97706;
  flex-shrink: 0;
}

/* --- Mobile responsive --- */
@media (max-width: 991.98px) {
  .lexa-sidebar {
    transform: translateX(-100%);
  }

  .lexa-sidebar.open {
    transform: translateX(0);
  }

  .lexa-topbar {
    left: 0;
  }

  .lexa-main {
    margin-left: 0;
  }
}

@media (max-width: 576px) {
  .lexa-impersonation-banner {
    align-items: flex-start;
    flex-direction: column;
    padding: 0.75rem 1rem;
  }
}

@media (min-width: 992px) {
  .lexa-sidebar-close {
    display: none !important;
  }

  /* --- Collapsed sidebar (desktop only) --- */
  .lexa-sidebar.collapsed {
    width: 64px;
    overflow: visible;
  }

  .lexa-sidebar.collapsed .lexa-sidebar-header {
    justify-content: center;
    padding: 1.1rem 0.5rem;
  }

  .lexa-sidebar.collapsed .lexa-sidebar-brand span,
  .lexa-sidebar.collapsed .lexa-sidebar-brand-logo,
  .lexa-sidebar.collapsed .lexa-sidebar-section,
  .lexa-sidebar.collapsed .lexa-sidebar-divider,
  .lexa-sidebar.collapsed .lexa-sidebar-arrow,
  .lexa-sidebar.collapsed .lexa-sidebar-link > span,
  .lexa-sidebar.collapsed .lexa-sidebar-submenu,
  .lexa-sidebar.collapsed .lexa-submenu-header {
    display: none;
  }

  .lexa-sidebar.collapsed .lexa-sidebar-brand-logo-square {
    display: block;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
  }

  .lexa-sidebar.collapsed .lexa-sidebar-brand-fallback {
    display: inline-block;
  }

  .lexa-sidebar.collapsed .lexa-sidebar-brand {
    justify-content: center;
  }

  .lexa-sidebar.collapsed .lexa-sidebar-link {
    justify-content: center;
    padding: 0.7rem 0;
    border-left-width: 0;
    position: relative;
  }

  .lexa-sidebar.collapsed .lexa-sidebar-link > i:first-child {
    margin-right: 0;
    font-size: 1.15rem;
  }

  .lexa-sidebar.collapsed .lexa-sidebar-badge {
    position: absolute;
    display: inline-flex;
    top: 0.35rem;
    right: 0.45rem;
    min-width: 1rem;
    height: 1rem;
    padding: 0 0.25rem;
    font-size: 0.58rem;
    margin-left: 0;
  }

  body.sidebar-collapsed .lexa-topbar {
    left: 64px;
  }

  body.sidebar-collapsed .lexa-main {
    margin-left: 64px;
  }

  /* Tooltip on hover for collapsed sidebar links */
  .lexa-sidebar.collapsed .lexa-sidebar-link {
    position: relative;
  }

  .lexa-sidebar.collapsed .lexa-sidebar-link::after {
    content: attr(data-tooltip);
    position: absolute;
    left: 100%;
    top: 50%;
    transform: translateY(-50%);
    background: var(--lexa-gray-800, #1E293B);
    color: var(--lexa-white, #fff);
    padding: 0.3rem 0.65rem;
    border-radius: 4px;
    font-size: 0.75rem;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 150ms ease;
    margin-left: 8px;
    z-index: 9999;
  }

  .lexa-sidebar.collapsed .lexa-sidebar-link:hover::after {
    opacity: 1;
  }

  /* Hide tooltip for links without data-tooltip */
  .lexa-sidebar.collapsed .lexa-sidebar-link:not([data-tooltip])::after {
    display: none;
  }

  /* Flyout submenu on hover (collapsed sidebar) */
  .lexa-sidebar.collapsed .lexa-sidebar-group {
    position: relative;
  }

  /* Override Bootstrap .collapse (display:none) AND .collapsing AND inline height:0 */
  .lexa-sidebar.collapsed .lexa-sidebar-group:hover > div[id^="menu"] {
    display: block !important;
    position: absolute !important;
    left: 64px;
    top: 0;
    width: max-content;
    min-width: 180px;
    z-index: 9999;
    height: auto !important;
    overflow: visible !important;
    visibility: visible !important;
    opacity: 1 !important;
  }

  .lexa-sidebar.collapsed .lexa-sidebar-group:hover > div[id^="menu"] > .lexa-sidebar-submenu {
    display: block !important;
    background: var(--lexa-gray-800, #1E293B);
    border-radius: 0 0.5rem 0.5rem 0;
    padding: 0.5rem 0;
    box-shadow: 4px 4px 12px rgba(0, 0, 0, 0.25);
  }

  .lexa-sidebar.collapsed .lexa-sidebar-group:hover > div[id^="menu"] > .lexa-sidebar-submenu a {
    display: block !important;
    padding: 0.4rem 1rem;
    white-space: nowrap;
    font-size: 0.8rem;
  }

  .lexa-sidebar.collapsed .lexa-sidebar-group:hover > div[id^="menu"] .lexa-submenu-header {
    display: block !important;
    padding: 0.3rem 1rem 0.15rem;
    white-space: nowrap;
  }

  /* Hide tooltip when flyout is showing */
  .lexa-sidebar.collapsed .lexa-sidebar-group:hover > .lexa-sidebar-link::after {
    display: none;
  }
}

/* --------------------------------------------------------------------------
   TIPOGRAFIA - PBI-029: Headings, labels, etc.
   -------------------------------------------------------------------------- */

/* Headings */
h1, .h1 {
  font-size: var(--lexa-font-size-3xl, 1.875rem);
  font-weight: var(--lexa-font-weight-bold, 700);
  line-height: var(--lexa-line-height-tight, 1.25);
  color: var(--lexa-gray-900);
  margin-bottom: var(--lexa-spacing-4, 1rem);
}

h2, .h2 {
  font-size: var(--lexa-font-size-2xl, 1.5rem);
  font-weight: var(--lexa-font-weight-semibold, 600);
  line-height: var(--lexa-line-height-tight, 1.25);
  color: var(--lexa-gray-900);
  margin-bottom: var(--lexa-spacing-3, 0.75rem);
}

h3, .h3 {
  font-size: var(--lexa-font-size-xl, 1.25rem);
  font-weight: var(--lexa-font-weight-semibold, 600);
  line-height: var(--lexa-line-height-tight, 1.25);
  color: var(--lexa-gray-800);
  margin-bottom: var(--lexa-spacing-3, 0.75rem);
}

h4, .h4 {
  font-size: var(--lexa-font-size-lg, 1.125rem);
  font-weight: var(--lexa-font-weight-medium, 500);
  line-height: var(--lexa-line-height-base, 1.5);
  color: var(--lexa-gray-800);
  margin-bottom: var(--lexa-spacing-2, 0.5rem);
}

h5, .h5 {
  font-size: var(--lexa-font-size-base, 1rem);
  font-weight: var(--lexa-font-weight-semibold, 600);
  line-height: var(--lexa-line-height-base, 1.5);
  color: var(--lexa-gray-700);
  margin-bottom: var(--lexa-spacing-2, 0.5rem);
}

h6, .h6 {
  font-size: var(--lexa-font-size-sm, 0.875rem);
  font-weight: var(--lexa-font-weight-semibold, 600);
  line-height: var(--lexa-line-height-base, 1.5);
  color: var(--lexa-gray-600);
  margin-bottom: var(--lexa-spacing-2, 0.5rem);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Titulo de pagina con linea decorativa */
.page-title {
  font-size: var(--lexa-font-size-3xl, 1.875rem);
  font-weight: var(--lexa-font-weight-bold, 700);
  color: var(--lexa-gray-900);
  margin-bottom: var(--lexa-spacing-6, 1.5rem);
  padding-bottom: var(--lexa-spacing-3, 0.75rem);
  border-bottom: 2px solid var(--lexa-primary-light, #EDE9FE);
}

/* --------------------------------------------------------------------------
   FORMULARIOS - PBI-029: Labels, inputs, validacion
   -------------------------------------------------------------------------- */

.form-label {
  font-size: var(--lexa-font-size-sm, 0.875rem);
  font-weight: var(--lexa-font-weight-medium, 500);
  color: var(--lexa-gray-700);
  margin-bottom: var(--lexa-spacing-1, 0.25rem);
}

.form-control {
  font-size: var(--lexa-font-size-base, 1rem);
  color: var(--lexa-gray-900);
  border-color: var(--lexa-gray-300, #dee2e6);
  border-radius: var(--lexa-border-radius-base, 0.375rem);
  padding: var(--lexa-spacing-2, 0.5rem) var(--lexa-spacing-3, 0.75rem);
  transition: border-color var(--lexa-transition-fast, 150ms ease),
              box-shadow var(--lexa-transition-fast, 150ms ease);
}

.form-control:focus {
  border-color: var(--lexa-primary, #6D28D9);
  box-shadow: 0 0 0 0.2rem var(--lexa-primary-light, #EDE9FE);
}

.form-control::placeholder {
  color: var(--lexa-gray-400);
}

.form-control:disabled,
.form-control[readonly] {
  background-color: var(--lexa-gray-100, #f8f9fa);
}

.form-select {
  font-size: var(--lexa-font-size-base, 1rem);
  color: var(--lexa-gray-900);
  border-color: var(--lexa-gray-300, #dee2e6);
  border-radius: var(--lexa-border-radius-base, 0.375rem);
  padding: var(--lexa-spacing-2, 0.5rem) var(--lexa-spacing-3, 0.75rem);
}

.form-select:focus {
  border-color: var(--lexa-primary, #6D28D9);
  box-shadow: 0 0 0 0.2rem var(--lexa-primary-light, #EDE9FE);
}

.form-text {
  font-size: var(--lexa-font-size-xs, 0.75rem);
  color: var(--lexa-gray-500);
  margin-top: var(--lexa-spacing-1, 0.25rem);
}

.invalid-feedback {
  font-size: var(--lexa-font-size-xs, 0.75rem);
  color: var(--lexa-danger, #dc3545);
}

.valid-feedback {
  font-size: var(--lexa-font-size-xs, 0.75rem);
  color: var(--lexa-success, #198754);
}

/* Floating labels */
.form-floating > .form-control-plaintext::placeholder,
.form-floating > .form-control::placeholder {
  color: var(--bs-secondary-color);
  text-align: end;
}

.form-floating > .form-control-plaintext:focus::placeholder,
.form-floating > .form-control:focus::placeholder {
  text-align: start;
}

/* Checkbox y Radio */
.form-check-input {
  border-color: var(--lexa-gray-400);
}

.form-check-input:checked {
  background-color: var(--lexa-primary, #6D28D9);
  border-color: var(--lexa-primary, #6D28D9);
}

.form-check-input:focus {
  border-color: var(--lexa-primary, #6D28D9);
  box-shadow: 0 0 0 0.2rem var(--lexa-primary-light, #EDE9FE);
}

/* Input group */
.input-group-text {
  background-color: var(--lexa-gray-100, #f8f9fa);
  border-color: var(--lexa-gray-300, #dee2e6);
  color: var(--lexa-gray-600);
}

/* --------------------------------------------------------------------------
   BOTONES - PBI-030: Variantes y estados
   -------------------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--lexa-spacing-2, 0.5rem);
  font-size: var(--lexa-font-size-sm, 0.875rem);
  font-weight: var(--lexa-font-weight-medium, 500);
  border-radius: var(--lexa-border-radius-base, 0.375rem);
  padding: var(--lexa-spacing-2, 0.5rem) var(--lexa-spacing-4, 1rem);
  transition: all var(--lexa-transition-fast, 150ms ease);
}

.btn:focus-visible {
  outline: none;
}

.btn:disabled,
.btn.disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.btn-lg {
  font-size: var(--lexa-font-size-base, 1rem);
  padding: var(--lexa-spacing-3, 0.75rem) var(--lexa-spacing-6, 1.5rem);
}

.btn-sm {
  font-size: var(--lexa-font-size-xs, 0.75rem);
  padding: var(--lexa-spacing-1, 0.25rem) var(--lexa-spacing-3, 0.75rem);
}

/* Primary */
.btn-primary {
  color: var(--lexa-white, #ffffff);
  background-color: var(--lexa-primary, #6D28D9);
  border-color: var(--lexa-primary, #6D28D9);
}

.btn-primary:hover:not(:disabled) {
  background-color: var(--lexa-primary-hover, #5B21B6);
  border-color: var(--lexa-primary-hover, #5B21B6);
  color: var(--lexa-white, #ffffff);
}

.btn-primary:focus-visible {
  box-shadow: 0 0 0 0.25rem var(--lexa-primary-light, #EDE9FE);
}

.btn-primary:disabled,
.btn-primary.disabled {
  color: var(--lexa-white, #ffffff);
  background-color: var(--lexa-primary, #6D28D9);
  border-color: var(--lexa-primary, #6D28D9);
}

/* Secondary */
.btn-secondary {
  color: var(--lexa-white, #ffffff);
  background-color: var(--lexa-secondary, #6c757d);
  border-color: var(--lexa-secondary, #6c757d);
}

.btn-secondary:hover:not(:disabled) {
  background-color: var(--lexa-secondary-hover, #5c636a);
  border-color: var(--lexa-secondary-hover, #5c636a);
  color: var(--lexa-white, #ffffff);
}

/* Outline Primary */
.btn-outline-primary {
  color: var(--lexa-primary, #6D28D9);
  background-color: transparent;
  border-color: var(--lexa-primary, #6D28D9);
}

.btn-outline-primary:hover:not(:disabled) {
  color: var(--lexa-white, #ffffff);
  background-color: var(--lexa-primary, #6D28D9);
  border-color: var(--lexa-primary, #6D28D9);
}

.btn-outline-primary:focus-visible {
  box-shadow: 0 0 0 0.25rem var(--lexa-primary-light, #EDE9FE);
}

.btn-outline-primary:active,
.btn-outline-primary.show,
.btn-check:checked + .btn-outline-primary,
.btn-check:active + .btn-outline-primary {
  color: var(--lexa-white, #ffffff);
  background-color: var(--lexa-primary, #6D28D9);
  border-color: var(--lexa-primary, #6D28D9);
}

.btn-check:checked + .btn-outline-primary:focus-visible,
.btn-check:focus-visible + .btn-outline-primary {
  box-shadow: 0 0 0 0.25rem var(--lexa-primary-light, #EDE9FE);
}

.btn-outline-primary:disabled,
.btn-outline-primary.disabled {
  color: var(--lexa-primary, #6D28D9);
  border-color: var(--lexa-primary, #6D28D9);
}

/* Outline Secondary */
.btn-outline-secondary {
  color: var(--lexa-secondary, #6c757d);
  background-color: transparent;
  border-color: var(--lexa-gray-400, #adb5bd);
}

.btn-outline-secondary:hover:not(:disabled) {
  color: var(--lexa-white, #ffffff);
  background-color: var(--lexa-secondary, #6c757d);
  border-color: var(--lexa-secondary, #6c757d);
}

/* Danger */
.btn-danger {
  color: var(--lexa-white, #ffffff);
  background-color: var(--lexa-danger, #dc3545);
  border-color: var(--lexa-danger, #dc3545);
}

.btn-danger:hover:not(:disabled) {
  background-color: var(--lexa-danger-hover, #bb2d3b);
  border-color: var(--lexa-danger-hover, #bb2d3b);
  color: var(--lexa-white, #ffffff);
}

.btn-danger:focus-visible {
  box-shadow: 0 0 0 0.25rem var(--lexa-danger-light, #f8d7da);
}

/* Outline Danger */
.btn-outline-danger {
  color: var(--lexa-danger, #dc3545);
  background-color: transparent;
  border-color: var(--lexa-danger, #dc3545);
}

.btn-outline-danger:hover:not(:disabled) {
  color: var(--lexa-white, #ffffff);
  background-color: var(--lexa-danger, #dc3545);
  border-color: var(--lexa-danger, #dc3545);
}

/* Success */
.btn-success {
  color: var(--lexa-white, #ffffff);
  background-color: var(--lexa-success, #198754);
  border-color: var(--lexa-success, #198754);
}

.btn-success:hover:not(:disabled) {
  background-color: var(--lexa-success-hover, #157347);
  border-color: var(--lexa-success-hover, #157347);
  color: var(--lexa-white, #ffffff);
}

/* --------------------------------------------------------------------------
   TABS - PBI-030: Estilo moderno
   -------------------------------------------------------------------------- */

.nav-tabs {
  border-bottom: 2px solid var(--lexa-gray-200, #e9ecef);
  gap: var(--lexa-spacing-1, 0.25rem);
}

.nav-tabs .nav-link {
  color: var(--lexa-gray-600);
  font-weight: var(--lexa-font-weight-medium, 500);
  font-size: var(--lexa-font-size-sm, 0.875rem);
  padding: var(--lexa-spacing-3, 0.75rem) var(--lexa-spacing-4, 1rem);
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  border-radius: 0;
  transition: all var(--lexa-transition-fast, 150ms ease);
}

.nav-tabs .nav-link:hover {
  color: var(--lexa-primary, #6D28D9);
  border-bottom-color: var(--lexa-gray-300, #dee2e6);
  background-color: transparent;
}

.nav-tabs .nav-link.active {
  color: var(--lexa-primary, #6D28D9);
  font-weight: var(--lexa-font-weight-semibold, 600);
  border-bottom-color: var(--lexa-primary, #6D28D9);
  background-color: transparent;
}

.nav-tabs .nav-link .badge {
  margin-left: var(--lexa-spacing-2, 0.5rem);
  font-size: var(--lexa-font-size-xs, 0.75rem);
  padding: 0.2em 0.5em;
}

.tab-content {
  padding-top: var(--lexa-spacing-4, 1rem);
}

/* --------------------------------------------------------------------------
   TABLAS - PBI-030: Headers mejorados, row hover
   -------------------------------------------------------------------------- */

.table {
  --bs-table-bg: var(--lexa-white, #ffffff);
  font-size: var(--lexa-font-size-sm, 0.875rem);
}

.table > thead > tr > th {
  background-color: var(--lexa-gray-100, #f8f9fa);
  color: var(--lexa-gray-600);
  font-size: var(--lexa-font-size-xs, 0.75rem);
  font-weight: var(--lexa-font-weight-semibold, 600);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: var(--lexa-spacing-3, 0.75rem);
  border-bottom: 2px solid var(--lexa-gray-300, #dee2e6);
  white-space: nowrap;
}

.table > tbody > tr > td {
  padding: var(--lexa-spacing-3, 0.75rem);
  vertical-align: middle;
  border-bottom: 1px solid var(--lexa-gray-200, #e9ecef);
  color: var(--lexa-gray-700);
}

.table-hover > tbody > tr:hover > td {
  background-color: var(--lexa-primary-light, #EDE9FE);
}

/* Columna de acciones */
.table .col-actions,
.table td:last-child:has(.btn) {
  white-space: nowrap;
  text-align: right;
  width: 1%;
}

.table .col-actions .btn,
.table td:last-child .btn {
  margin-left: var(--lexa-spacing-1, 0.25rem);
}

.table .col-actions .btn:first-child,
.table td:last-child .btn:first-child {
  margin-left: 0;
}

/* Tabla responsive */
.table-responsive {
  border-radius: var(--lexa-border-radius-base, 0.375rem);
  border: 1px solid var(--lexa-gray-200, #e9ecef);
}

.table-responsive > .table {
  margin-bottom: 0;
}

.table-responsive > .table > thead > tr > th:first-child {
  border-top-left-radius: var(--lexa-border-radius-base, 0.375rem);
}

.table-responsive > .table > thead > tr > th:last-child {
  border-top-right-radius: var(--lexa-border-radius-base, 0.375rem);
}

/* --------------------------------------------------------------------------
   BADGES - PBI-030: Colores accesibles
   -------------------------------------------------------------------------- */

.badge {
  font-size: var(--lexa-font-size-xs, 0.75rem);
  font-weight: var(--lexa-font-weight-medium, 500);
  padding: 0.35em 0.65em;
  border-radius: var(--lexa-border-radius-full, 9999px);
}

/* Badges semanticos con estilo "soft" */
.badge-activa,
.badge-activo,
.badge-confirmada {
  background-color: var(--lexa-success-light, #d1e7dd) !important;
  color: var(--lexa-success, #198754) !important;
}

.badge-inactiva,
.badge-inactivo {
  background-color: var(--lexa-gray-200, #e9ecef) !important;
  color: var(--lexa-gray-600, #5a5a6e) !important;
}

.badge-pendiente {
  background-color: var(--lexa-warning-light, #fff3cd) !important;
  color: #856404 !important;
}

.badge-cancelada,
.badge-cancelado {
  background-color: var(--lexa-danger-light, #f8d7da) !important;
  color: var(--lexa-danger, #dc3545) !important;
}

.badge-completada,
.badge-completado {
  background-color: var(--lexa-info-light, #cff4fc) !important;
  color: var(--lexa-info-hover, #0aa2c0) !important;
}

/* Mantener compatibilidad con Bootstrap bg-* pero mejorar contraste */
.bg-success {
  background-color: var(--lexa-success, #198754) !important;
}

.bg-danger {
  background-color: var(--lexa-danger, #dc3545) !important;
}

.bg-warning {
  background-color: var(--lexa-warning, #ffc107) !important;
  color: var(--lexa-warning-contrast, #1a1a2e) !important;
}

.bg-info {
  background-color: var(--lexa-info, #0dcaf0) !important;
  color: var(--lexa-info-contrast, #1a1a2e) !important;
}

.bg-secondary {
  background-color: var(--lexa-gray-500, #6c757d) !important;
}

.bg-primary {
  background-color: var(--lexa-primary, #6D28D9) !important;
}

/* --------------------------------------------------------------------------
   CARDS - PBI-030: Sombras y bordes
   -------------------------------------------------------------------------- */

.card {
  border: 1px solid var(--lexa-gray-200, #e9ecef);
  border-radius: var(--lexa-border-radius-lg, 0.5rem);
  box-shadow: var(--lexa-shadow-sm);
  transition: box-shadow var(--lexa-transition-base, 200ms ease);
}

.card:hover {
  box-shadow: var(--lexa-shadow-base);
}

.card-header {
  background-color: var(--lexa-gray-100, #f8f9fa);
  border-bottom: 1px solid var(--lexa-gray-200, #e9ecef);
  padding: var(--lexa-spacing-3, 0.75rem) var(--lexa-spacing-4, 1rem);
  font-weight: var(--lexa-font-weight-semibold, 600);
}

.card-body {
  padding: var(--lexa-spacing-4, 1rem);
}

.card-footer {
  background-color: var(--lexa-gray-100, #f8f9fa);
  border-top: 1px solid var(--lexa-gray-200, #e9ecef);
  padding: var(--lexa-spacing-3, 0.75rem) var(--lexa-spacing-4, 1rem);
}

/* Cards con borde de color (dashboard) */
.card-primary {
  border-top: 3px solid var(--lexa-primary, #6D28D9);
}

.card-success {
  border-top: 3px solid var(--lexa-success, #198754);
}

.card-warning {
  border-top: 3px solid var(--lexa-warning, #ffc107);
}

.card-danger {
  border-top: 3px solid var(--lexa-danger, #dc3545);
}

.card-info {
  border-top: 3px solid var(--lexa-info, #0dcaf0);
}

/* --------------------------------------------------------------------------
   PAGINACION
   -------------------------------------------------------------------------- */

.page-link {
  color: var(--lexa-primary, #6D28D9);
}

.page-link:hover {
  color: var(--lexa-primary-hover, #5B21B6);
  background-color: var(--lexa-primary-50, #F5F3FF);
}

.page-item.active > .page-link {
  background-color: var(--lexa-primary, #6D28D9);
  border-color: var(--lexa-primary, #6D28D9);
  color: var(--lexa-primary-contrast, #ffffff);
}

.page-link:focus {
  box-shadow: 0 0 0 0.2rem rgba(109, 40, 217, 0.25);
}

/* --------------------------------------------------------------------------
   LINKS
   -------------------------------------------------------------------------- */

.lexa-link { color: var(--lexa-primary); }
.lexa-link:hover { color: var(--lexa-primary-dark, #5B21B6); }

/* --------------------------------------------------------------------------
   ALERTAS
   -------------------------------------------------------------------------- */

.alert {
  border-radius: var(--lexa-border-radius-base, 0.375rem);
  border: none;
  font-size: var(--lexa-font-size-sm, 0.875rem);
}

.alert-success {
  background-color: var(--lexa-success-light, #d1e7dd);
  color: #0f5132;
}

.alert-danger {
  background-color: var(--lexa-danger-light, #f8d7da);
  color: #842029;
}

.alert-warning {
  background-color: var(--lexa-warning-light, #fff3cd);
  color: #664d03;
}

.alert-info {
  background-color: var(--lexa-info-light, #cff4fc);
  color: #055160;
}

/* --------------------------------------------------------------------------
   MODALES
   -------------------------------------------------------------------------- */

.modal-content {
  border: none;
  border-radius: var(--lexa-border-radius-lg, 0.5rem);
  box-shadow: var(--lexa-shadow-lg);
}

.modal-header {
  border-bottom: 1px solid var(--lexa-gray-200, #e9ecef);
  padding: var(--lexa-spacing-4, 1rem);
}

.modal-title {
  font-weight: var(--lexa-font-weight-semibold, 600);
}

.modal-body {
  padding: var(--lexa-spacing-4, 1rem);
}

.modal-footer {
  border-top: 1px solid var(--lexa-gray-200, #e9ecef);
  padding: var(--lexa-spacing-3, 0.75rem) var(--lexa-spacing-4, 1rem);
}

/* --------------------------------------------------------------------------
   UTILIDADES
   -------------------------------------------------------------------------- */

.text-muted {
  color: var(--lexa-gray-500) !important;
}

.text-primary {
  color: var(--lexa-primary) !important;
}

.text-success {
  color: var(--lexa-success) !important;
}

.text-danger {
  color: var(--lexa-danger) !important;
}

.text-warning {
  color: var(--lexa-warning) !important;
}

/* Texto truncado multilinea */
.text-truncate-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* --------------------------------------------------------------------------
   TOAST NOTIFICATIONS - Sistema de alertas laterales
   -------------------------------------------------------------------------- */

.toast-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 1100;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: 400px;
  pointer-events: none;
}

.toast-notification {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.875rem 1rem;
  border-radius: var(--lexa-border-radius-base, 0.375rem);
  box-shadow: var(--lexa-shadow-lg, 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06));
  pointer-events: auto;
  animation: toast-slide-in 0.3s ease-out;
  font-size: var(--lexa-font-size-sm, 0.875rem);
}

.toast-notification.toast-hiding {
  animation: toast-slide-out 0.2s ease-in forwards;
}

@keyframes toast-slide-in {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes toast-slide-out {
  from {
    transform: translateX(0);
    opacity: 1;
  }
  to {
    transform: translateX(100%);
    opacity: 0;
  }
}

.toast-notification .toast-message {
  flex: 1;
  line-height: 1.4;
}

.toast-notification .toast-close {
  background: none;
  border: none;
  padding: 0.25rem;
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 0.15s;
  font-size: 1.25rem;
  line-height: 1;
}

.toast-notification .toast-close:hover {
  opacity: 1;
}

/* Toast Success (default) */
.toast-notification.toast-success {
  background-color: #d1e7dd;
  color: #0f5132;
  border-left: 4px solid #198754;
}

.toast-notification.toast-success .toast-close {
  color: #0f5132;
}

/* Toast Error */
.toast-notification.toast-error {
  background-color: #f8d7da;
  color: #842029;
  border-left: 4px solid #dc3545;
}

.toast-notification.toast-error .toast-close {
  color: #842029;
}

/* Toast Warning */
.toast-notification.toast-warning {
  background-color: #fff3cd;
  color: #664d03;
  border-left: 4px solid #ffc107;
}

.toast-notification.toast-warning .toast-close {
  color: #664d03;
}

/* Toast Info */
.toast-notification.toast-info {
  background-color: #cff4fc;
  color: #055160;
  border-left: 4px solid #0dcaf0;
}

.toast-notification.toast-info .toast-close {
  color: #055160;
}

/* --------------------------------------------------------------------------
   FOOTER
   -------------------------------------------------------------------------- */

.footer {
  background-color: var(--lexa-bg-subtle, #f8f9fa);
  color: var(--lexa-gray-500);
  font-size: var(--lexa-font-size-sm, 0.875rem);
}

/* --------------------------------------------------------------------------
   AGENDA - Toolbar, Grid, Cards, Status Colors
   -------------------------------------------------------------------------- */

.agenda-toolbar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.75rem;
  background: var(--lexa-white, #fff);
  border: 1px solid var(--lexa-border-color, #E2E8F0);
  border-radius: var(--lexa-border-radius-lg, 0.5rem);
  margin-bottom: 0.5rem;
}

.agenda-toolbar .form-select,
.agenda-toolbar .form-control,
.agenda-toolbar .btn {
  height: 32px;
  padding-top: 0.25rem;
  padding-bottom: 0.25rem;
  font-size: 0.8rem;
}

.agenda-toolbar .form-select {
  padding-right: 2rem;
  max-width: 180px;
}

.toolbar-date {
  display: flex;
  gap: 2px;
  align-items: center;
}

.toolbar-date input[type="date"] {
  width: 130px;
}

.toolbar-actions {
  margin-left: auto;
  display: flex;
  gap: 0.35rem;
  align-items: center;
}

.toolbar-therapists {
  min-width: 160px;
  text-align: left;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 32px;
}

.toolbar-therapists .badge {
  margin-left: 0.5rem;
}

/* Navbar dropdowns (sucursal, usuario) must float above page-level popups */
#navBranchSelector .dropdown-menu,
.navbar .dropdown-menu {
  z-index: 1055;
}

/* Week therapist combobox */
.week-therapist-combo {
  /* No z-index on wrapper — it competes with navbar dropdown.
     Position context only so the child popup can use position:absolute. */
}

.week-therapist-dropdown {
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  min-width: 240px;
  max-width: 300px;
  background: var(--lexa-white);
  border: 1px solid var(--lexa-gray-200);
  border-radius: 0.5rem;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  margin-top: 4px;
  z-index: 1030;
}

.week-therapist-list {
  max-height: 260px;
  overflow-y: auto;
}

.week-therapist-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.75rem;
  cursor: pointer;
  font-size: 0.82rem;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  color: var(--lexa-gray-700);
  transition: background 0.1s;
}

.week-therapist-item:hover,
.week-therapist-item:focus {
  background: var(--lexa-gray-100);
  outline: none;
}

.week-therapist-item.active {
  background: var(--lexa-primary-light, #e8e0f3);
  font-weight: 600;
  color: var(--lexa-primary);
}

.week-therapist-item img {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.week-therapist-item .therapist-avatar-fallback {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--lexa-gray-200);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  color: var(--lexa-gray-500);
  flex-shrink: 0;
}

@media (max-width: 1199px) {
  .agenda-toolbar {
    gap: 0.35rem;
    padding: 0.25rem 0.5rem;
  }
  .toolbar-therapists { min-width: 140px; }
  .toolbar-date input[type="date"] { width: 120px; }
}

/* Tablet (768px) — toolbar wraps, touch targets, info row wraps */
@media (max-width: 768px) {
  .agenda-toolbar {
    flex-wrap: wrap;
    gap: 0.4rem;
  }
  .agenda-toolbar .form-select { max-width: none; flex: 1 1 120px; }
  .agenda-toolbar .btn { min-height: 38px; }
  .toolbar-date { flex: 1 1 100%; }
  .toolbar-date input[type="date"] { flex: 1; width: auto; }
  .toolbar-actions { margin-left: auto; }

  /* Zoom slider not usable with touch on mobile */
  .agenda-zoom-control, #weekZoomControl { display: none !important; }

  /* Info row wraps */
  .agenda-info-row { flex-wrap: wrap; gap: 0.25rem 0.75rem; }
  .agenda-info-bar { flex-wrap: wrap; gap: 0.5rem; }

  /* Detail modal footer full-width buttons */
  .detail-footer > div { flex-direction: column; }
  .detail-footer > div .btn { width: 100%; }
}

/* Mobile (576px) — compact grid toolbar (applies to all non-therapist roles) */
@media (max-width: 576px) {
  .agenda-toolbar {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.3rem;
    align-items: center;
    padding: 0.3rem 0.5rem;
  }
  /* Row 1: date nav full width */
  .toolbar-date {
    grid-column: 1 / -1; grid-row: 1; order: 0;
    display: flex; gap: 2px; align-items: center; flex: unset;
  }
  .toolbar-date input[type="date"] { flex: 1; min-height: 40px; width: auto; }
  .toolbar-date .btn { min-height: 40px; min-width: 40px; padding: 0 0.4rem; }
  /* Row 2-5: stack controls to avoid overlap on small screens */
  .agenda-toolbar #branchSelect {
    grid-row: 2; grid-column: 1 / -1; max-width: none; min-height: 36px; font-size: 0.75rem; flex: unset;
  }
  .agenda-toolbar .toolbar-therapists,
  .agenda-toolbar [data-mode-section="week"] {
    grid-row: 3; grid-column: 1 / -1; max-width: none; min-width: 0; min-height: 36px; font-size: 0.75rem; width: 100%;
  }
  .agenda-toolbar [data-mode-section="day"],
  .agenda-toolbar [data-mode-section="week"],
  .agenda-toolbar [data-mode-section="week"] > .d-flex,
  .agenda-toolbar .week-therapist-combo,
  .agenda-toolbar #btnWeekTherapistCombo,
  .agenda-toolbar .toolbar-therapists {
    min-width: 0;
    width: 100%;
  }
  .agenda-toolbar [data-mode-section="week"] > .d-flex {
    gap: 0.3rem !important;
  }
  .agenda-toolbar #btnPrevTherapist,
  .agenda-toolbar #btnNextTherapist {
    flex: 0 0 36px;
    min-width: 36px;
    padding: 0;
  }
  /* Row 4: status */
  .agenda-toolbar #statusSelect {
    grid-row: 4; grid-column: 1 / -1; max-width: none; min-height: 36px; font-size: 0.75rem; flex: unset; width: 100%;
  }
  /* Row 5: actions */
  .toolbar-actions {
    grid-row: 5; grid-column: 1 / -1; margin-left: 0; display: flex; flex: 0 0 auto; justify-content: flex-end;
  }
  .toolbar-actions .btn { min-height: 36px; min-width: 36px; padding: 0; }

  /* Hide branch if single branch */
  body.single-branch .agenda-toolbar #branchSelect { display: none; }
  body.single-branch .agenda-toolbar .toolbar-therapists,
  body.single-branch .agenda-toolbar [data-mode-section="week"] { grid-row: 2; grid-column: 1 / -1; }
  body.single-branch .agenda-toolbar #statusSelect { grid-row: 3; }
  body.single-branch .agenda-toolbar .toolbar-actions { grid-row: 4; }

  /* Info row compact */
  .agenda-info-row { font-size: 0.7rem; padding: 0.2rem 0.5rem; }

  /* Week view day headers: use abbreviations (handled by JS) but ensure fit */
  .agenda-day-header { font-size: 0.7rem; padding: 0.3rem 0.2rem; }
}

/* ── Therapist view mobile: compact 2-row toolbar ── */
@media (max-width: 768px) {
  body.therapist-view .agenda-toolbar {
    flex-wrap: wrap;
    flex-direction: row;
    align-items: center;
    gap: 0.35rem;
    padding: 0.3rem 0.5rem;
  }
  body.therapist-view .agenda-toolbar #branchSelect { max-width: 120px; flex: 0 1 auto; }
  body.therapist-view .agenda-toolbar [data-mode-section="week"] { flex: 0 1 auto; }
  body.therapist-view #currentTherapistName { max-width: 100px; }
  body.therapist-view .agenda-toolbar #statusSelect { max-width: 110px; flex: 0 1 auto; }
}

@media (max-width: 576px) {
  body.therapist-view .agenda-toolbar {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.3rem;
    align-items: center;
    padding: 0.3rem 0.5rem;
  }
  /* Row 1: date nav full width */
  body.therapist-view .toolbar-date {
    grid-column: 1 / -1; grid-row: 1; order: 0;
    display: flex; gap: 2px; align-items: center; flex: unset;
  }
  body.therapist-view .toolbar-date input[type="date"] { flex: 1; min-height: 40px; }
  body.therapist-view .toolbar-date .btn { min-height: 40px; min-width: 40px; padding: 0 0.4rem; }
  /* Row 2-5: stacked controls */
  body.therapist-view .agenda-toolbar #branchSelect {
    grid-row: 2; grid-column: 1 / -1; max-width: none; min-height: 36px; font-size: 0.75rem; width: 100%;
  }
  body.therapist-view .agenda-toolbar [data-mode-section="week"] { grid-row: 3; grid-column: 1 / -1; width: 100%; min-width: 0; }
  body.therapist-view .agenda-toolbar [data-mode-section="week"] > .d-flex,
  body.therapist-view .agenda-toolbar .week-therapist-combo,
  body.therapist-view #btnWeekTherapistCombo {
    width: 100%;
    min-width: 0;
  }
  body.therapist-view #btnWeekTherapistCombo { min-height: 36px; font-size: 0.75rem; padding: 0.15rem 0.4rem; }
  body.therapist-view #currentTherapistName { max-width: none; font-size: 0.7rem; }
  body.therapist-view .agenda-toolbar #statusSelect {
    grid-row: 4; grid-column: 1 / -1; max-width: none; min-height: 36px; font-size: 0.75rem; width: 100%;
  }
  body.therapist-view .toolbar-actions { grid-row: 5; grid-column: 1 / -1; margin-left: 0; display: flex; justify-content: flex-end; }
  body.therapist-view .toolbar-actions .btn { min-height: 36px; min-width: 36px; padding: 0; }
  /* Hide branch if single branch */
  body.therapist-view.single-branch #branchSelect { display: none; }
  body.therapist-view.single-branch .agenda-toolbar [data-mode-section="week"] { grid-row: 2; }
  body.therapist-view.single-branch .agenda-toolbar #statusSelect { grid-row: 3; }
  body.therapist-view.single-branch .toolbar-actions { grid-row: 4; }
}

@media (max-width: 360px) {
  body.therapist-view #currentTherapistName { max-width: 50px; }
  body.therapist-view .toolbar-date #btnToday { font-size: 0.7rem; padding: 0 0.3rem; min-width: auto; }
}

/* Secretary-view uses default mobile grid layout (see ≤576px block above) */

/* Agenda grid siempre llena el ancho del contenedor — evita espacio sobrante
   al hacer zoom out o en monitores ultra-wide. Si con pocos terapeutas las
   columnas quedan muy anchas, es preferible a cortar el contenedor. */

.agenda-info-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.2rem 1rem;
  font-size: 0.75rem;
  color: #6c757d;
  gap: 1rem;
}
.agenda-info-bar {
  display: flex;
  gap: 1.5rem;
  align-items: center;
}
.agenda-info-bar:empty { display: none; }
.agenda-info-bar i { font-size: 0.7rem; }
#branchLegendBar:empty { display: none; }
#branchLegendBar .branch-legend { margin: 0; }
.branch-legend-swatch { width: 12px; height: 12px; border-radius: 2px; border: 1px solid #ccc; display: inline-block; }
.branch-tone-1 { --branch-accent: #7c3aed; --branch-slot-bg: #f3e8ff; --branch-slot-bg-dark: #25133d; }
.branch-tone-2 { --branch-accent: #2563eb; --branch-slot-bg: #dbeafe; --branch-slot-bg-dark: #10284f; }
.branch-tone-3 { --branch-accent: #0891b2; --branch-slot-bg: #cffafe; --branch-slot-bg-dark: #0c3441; }
.branch-tone-4 { --branch-accent: #059669; --branch-slot-bg: #d1fae5; --branch-slot-bg-dark: #0f3528; }
.branch-tone-5 { --branch-accent: #65a30d; --branch-slot-bg: #ecfccb; --branch-slot-bg-dark: #28350f; }
.branch-tone-6 { --branch-accent: #d97706; --branch-slot-bg: #fef3c7; --branch-slot-bg-dark: #3f2a0a; }
.branch-tone-7 { --branch-accent: #dc2626; --branch-slot-bg: #fee2e2; --branch-slot-bg-dark: #431919; }
.branch-tone-8 { --branch-accent: #db2777; --branch-slot-bg: #fce7f3; --branch-slot-bg-dark: #42162b; }
.branch-tone-9 { --branch-accent: #4f46e5; --branch-slot-bg: #e0e7ff; --branch-slot-bg-dark: #1f2253; }
.branch-tone-10 { --branch-accent: #0d9488; --branch-slot-bg: #ccfbf1; --branch-slot-bg-dark: #123a36; }
.branch-tone-11 { --branch-accent: #9333ea; --branch-slot-bg: #f3e8ff; --branch-slot-bg-dark: #30174d; }
.branch-tone-12 { --branch-accent: #475569; --branch-slot-bg: #e2e8f0; --branch-slot-bg-dark: #222a36; }
.branch-legend-swatch[class*="branch-tone-"] { background: var(--branch-accent); border-color: rgba(15, 23, 42, 0.2); }

.agenda-container {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.agenda-grid-wrapper {
  flex: 1 1 0;
  overflow: auto;
  border: 1px solid #dee2e6;
  border-radius: 0.375rem;
  background: #fff;
  min-height: 0;
}

/* Mobile weekly grid: hidden globally; only shown via media query when active */
#agendaMobileWeeklyGrid {
  display: none;
}

.agenda-grid {
  display: grid;
}

.agenda-header { display: contents; }

.agenda-time-header {
  position: sticky;
  top: 0;
  left: 0;
  z-index: 12;
  background: #f8f9fa;
  border-right: 2px solid #dee2e6;
  border-bottom: 2px solid #dee2e6;
  padding: 0.5rem;
  min-width: 70px;
  text-align: center;
  font-weight: 600;
}

.agenda-therapist-header {
  position: sticky;
  top: 0;
  z-index: 11;
  background: #fff;
  border-bottom: 2px solid #dee2e6;
  padding: 0.35rem 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 40px;
}

.agenda-therapist-header img,
.agenda-therapist-header .therapist-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  flex-shrink: 0;
}

.agenda-therapist-header img {
  object-fit: cover;
}

.agenda-therapist-header .therapist-avatar {
  background: #6c757d;
  color: white;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.7rem;
}

.agenda-therapist-header .therapist-name {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--lexa-gray-800, #1f2937);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.agenda-time-cell {
  position: sticky;
  left: 0;
  z-index: 10;
  background: #f8f9fa;
  border-right: 2px solid #dee2e6;
  border-bottom: 1px solid #e9ecef;
  padding: 0.25rem 0.5rem;
  font-size: 0.8rem;
  color: #6c757d;
  min-width: 70px;
  min-height: 28px;
}

.agenda-time-cell.agenda-time-hour { border-top: 2px solid #dee2e6; }
.agenda-time-cell.agenda-time-sub { border-top: 1px dashed #e9ecef; font-size: 0; padding: 0 0.5rem; }

.agenda-slot {
  position: relative;
  border-bottom: 1px solid #e9ecef;
  border-right: 1px solid #e9ecef;
  min-height: 28px;
  cursor: pointer;
  transition: background-color 0.15s;
  overflow: visible;
}

.agenda-slot.slot-hour-boundary { border-top: 2px solid #dee2e6; }
.agenda-slot:hover { background-color: #f0f7ff; }
.agenda-slot-week[class*="branch-tone-"] { background-color: var(--branch-slot-bg); }
.agenda-slot-week.branch-mixed {
  background: repeating-linear-gradient(135deg, #eef2ff, #eef2ff 8px, #f8fafc 8px, #f8fafc 16px);
}
.agenda-slot-week[class*="branch-tone-"]:hover,
.agenda-slot-week.branch-mixed:hover { box-shadow: inset 0 0 0 100px rgba(0,0,0,0.06); }

.appointment-card {
  position: absolute;
  left: 4px;
  right: 4px;
  border-radius: 5px;
  padding: 3px 8px;
  font-size: 0.7rem;
  overflow: hidden;
  cursor: pointer;
  z-index: 5;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  transition: transform 0.1s, box-shadow 0.1s;
  line-height: 1.3;
}

/* Ghost row para citas Cancelled / NoShow:
   franja superior compacta (~13px) para no consumir el espacio clickeable del slot,
   permitiendo agendar otra cita encima sin confusión visual. */
.appointment-ghost-row {
  position: absolute;
  left: 4px;
  right: 4px;
  height: 13px;
  padding: 0 6px;
  font-size: 0.62rem;
  line-height: 13px;
  border-radius: 3px;
  cursor: pointer;
  z-index: 4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  gap: 4px;
  opacity: 0.75;
  transition: opacity 0.12s;
}

.appointment-ghost-row:hover {
  opacity: 1;
}

.appointment-ghost-row .ghost-name {
  font-weight: 600;
  text-decoration: line-through;
  text-decoration-thickness: 1px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.appointment-ghost-row .ghost-status {
  margin-left: auto;
  font-size: 0.58rem;
  opacity: 0.85;
}

.appointment-ghost-cancelled {
  background: #f8d7da;
  color: #842029;
  border-left: 2px solid #dc3545;
}

.appointment-ghost-noshow {
  background: #fff3cd;
  color: #664d03;
  border-left: 2px solid #ffc107;
}

[data-bs-theme="dark"] .appointment-ghost-cancelled {
  background: rgba(220, 53, 69, 0.18);
  color: #f5c2c7;
}

[data-bs-theme="dark"] .appointment-ghost-noshow {
  background: rgba(255, 193, 7, 0.18);
  color: #ffe69c;
}

/* Status dropdown compacto en /Appointments para ganar espacio vertical */
.status-select-compact {
  padding-top: 0.15rem;
  padding-bottom: 0.15rem;
  line-height: 1.2;
  min-width: 120px;
  font-size: 0.78rem;
}

.appointment-card:hover {
  transform: scale(1.02);
  box-shadow: 0 2px 8px rgba(0,0,0,0.18);
  z-index: 6;
}

.appointment-card .patient-name {
  font-weight: 700;
  font-size: 0.75rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: -0.01em;
  /* Reserva espacio para los iconos (.appt-indicators absolute top-right) */
  padding-right: 22px;
}

.first-visit-chip {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  margin-left: 0.25rem;
  padding: 0.05rem 0.28rem;
  border-radius: 999px;
  background: #e0f2fe;
  color: #075985;
  border: 1px solid #7dd3fc;
  font-size: 0.58rem;
  font-weight: 700;
  line-height: 1.1;
  white-space: nowrap;
  vertical-align: baseline;
}

.first-visit-chip-inline {
  margin-top: 0.1rem;
  font-size: 0.65rem;
}

.appointment-card .service-name {
  font-size: 0.65rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0.7;
}

.appointment-card .appt-meta {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.6rem;
  opacity: 0.65;
  margin-top: 1px;
}

.appointment-card .time-range { white-space: nowrap; }
.appointment-card .room-name,
.appointment-card .branch-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.appointment-card .branch-name { font-style: italic; }
.appointment-card[class*="branch-tone-"] {
  box-shadow: inset 0 3px 0 var(--branch-accent), 0 1px 3px rgba(0,0,0,0.1);
}

/* Indicator icons (top-right corner) */
.appointment-card .appt-indicators {
  position: absolute;
  top: 2px;
  right: 4px;
  display: flex;
  gap: 2px;
  font-size: 0.6rem;
  z-index: 1;
}

.appointment-card .appt-indicators:empty { display: none; }

.ind-paid     { color: #16a34a; }
.ind-unpaid   { color: #ea580c; }
.ind-note     { color: #9333ea; }
.ind-beca     { color: #2563eb; }
.ind-plan     { color: #0d9488; }
.ind-recovery { color: #6b7280; }

/* Status colors — using theme variables */
.status-scheduled   { background-color: #F1F5F9; border-left: 3px solid var(--lexa-status-scheduled, #64748B); color: #334155; }
.status-confirmed   { background-color: #DCFCE7; border-left: 3px solid var(--lexa-status-confirmed, #10B981); color: #14532d; }
.status-rescheduled { background-color: #FFF7ED; border-left: 3px solid var(--lexa-status-rescheduled, #F97316); color: #7c2d12; }
.status-inprogress  { background-color: #ECFEFF; border-left: 3px solid var(--lexa-status-inprogress, #0891B2); color: #155e75; }
.status-completed   { background-color: #DBEAFE; border-left: 3px solid var(--lexa-status-attended, #3B82F6); color: #1e3a8a; }
.status-cancelled   { background-color: #FEE2E2; border-left: 3px solid var(--lexa-status-cancelled, #EF4444); color: #7f1d1d; }
.status-noshow      { background-color: #F3F4F6; border-left: 3px solid var(--lexa-status-noshow, #6B7280); color: #374151; }

.bg-purple { background-color: var(--lexa-primary, #6D28D9) !important; color: #fff !important; }
.bg-orange { background-color: var(--lexa-status-rescheduled, #F97316) !important; color: #fff !important; }
.bg-teal { background-color: var(--lexa-status-inprogress, #0891B2) !important; color: #fff !important; }

.load-more-col {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #f8f9fa;
  border-bottom: 2px solid #dee2e6;
  padding: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 120px;
}

/* Daily Summary Modal (F016) */
#dailySummaryModal .modal-body { max-height: 70vh; overflow-y: auto; overflow-x: hidden; }
#summaryTable { table-layout: fixed; width: 100%; }
#dailySummaryModal .table thead th { position: sticky; top: 0; background: #f8f9fa; z-index: 1; font-size: 0.75rem; padding: 0.4rem 0.3rem; }
#dailySummaryModal .table td { vertical-align: middle; font-size: 0.75rem; padding: 0.35rem 0.3rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

#summaryTable .col-hora      { width: 5%; }
#summaryTable .col-id        { width: 9%; }
#summaryTable .col-paciente  { width: 14%; }
#summaryTable .col-telefono  { width: 9%; }
#summaryTable .col-correo    { width: 13%; }
#summaryTable .col-servicio  { width: 14%; }
#summaryTable .col-terapeuta { width: 12%; }
#summaryTable .col-sala      { width: 7%; }
#summaryTable .col-sucursal  { width: 9%; }
#summaryTable .col-estado    { width: 8%; }

/* --------------------------------------------------------------------------
   AGENDA - Week View (F022)
   -------------------------------------------------------------------------- */

.agenda-grid-week { min-width: auto; }

.agenda-grid-week .agenda-time-header {
  left: 0;
  z-index: 30;
  box-shadow: 2px 0 0 #dee2e6;
}

.agenda-grid-week .agenda-time-cell {
  left: 0;
  z-index: 20;
  box-shadow: 2px 0 0 #dee2e6;
}

.agenda-week-density-selector {
  display: none;
}

@media (min-width: 577px) {
  .agenda-week-density-selector {
    display: inline-flex;
  }

  body.agenda-week-compact .agenda-grid-week .agenda-day-header,
  body.agenda-week-compact .agenda-grid-week .agenda-time-header {
    min-height: 30px;
    padding: 0.25rem 0.4rem;
    font-size: 0.75rem;
  }

  body.agenda-week-compact .agenda-grid-week .agenda-day-header .small {
    line-height: 1.05;
  }

  body.agenda-week-compact .agenda-grid-week .agenda-time-cell {
    min-height: var(--slot-h, 14px);
    padding: 0 0.4rem;
    font-size: 0.68rem;
    line-height: var(--slot-h, 14px);
  }

  body.agenda-week-compact .agenda-grid-week .agenda-slot-week {
    min-height: var(--slot-h, 14px);
  }

  body.agenda-week-compact .agenda-grid-week .appointment-card {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    padding: 1px 6px;
    border-radius: 4px;
    box-shadow: none;
    line-height: 1;
  }

  body.agenda-week-compact .agenda-grid-week .appointment-card:hover {
    transform: none;
    box-shadow: 0 2px 8px rgba(0,0,0,0.14);
  }

  body.agenda-week-compact .agenda-grid-week .appointment-card .patient-name,
  body.agenda-week-compact .agenda-grid-week .appointment-card .service-name,
  body.agenda-week-compact .agenda-grid-week .appointment-card .appt-meta {
    min-width: 0;
    margin: 0;
    padding-right: 0;
    line-height: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  body.agenda-week-compact .agenda-grid-week .appointment-card .patient-name {
    flex: 1 1 46%;
    font-size: 0.66rem;
  }

  body.agenda-week-compact .agenda-grid-week .appointment-card .service-name {
    flex: 1 1 28%;
    font-size: 0.6rem;
  }

  body.agenda-week-compact .agenda-grid-week .appointment-card .appt-meta {
    flex: 0 1 34%;
    display: flex;
    font-size: 0.56rem;
    opacity: 0.75;
  }

  body.agenda-week-compact .agenda-grid-week .appointment-card .appt-indicators {
    top: 1px;
    right: 3px;
    font-size: 0.55rem;
  }

  body.agenda-week-compact .agenda-grid-week .therapist-block-card {
    min-height: 12px;
    padding: 1px 4px;
    font-size: 0.6rem;
    line-height: 1;
  }
}

.agenda-day-header {
  position: sticky;
  top: 0;
  z-index: 15;
  background: #fff;
  border-bottom: 2px solid #dee2e6;
  border-right: 1px solid #e9ecef;
  padding: 0.5rem;
  text-align: center;
  min-width: 120px;
}

.agenda-day-header.today { background: var(--lexa-primary-50, #F5F3FF); border-bottom-color: var(--lexa-primary, #6D28D9); }
.agenda-day-header .text-muted { color: var(--lexa-gray-500, #64748B) !important; }
.agenda-holiday-name { font-size: 0.65rem; line-height: 1; }

.agenda-slot-week { min-height: var(--slot-h, 45px); min-width: 120px; }

/* Week zoom slider */
.agenda-zoom-control { display: inline-flex; align-items: center; gap: 0.4rem; margin-left: 0.75rem; }
.agenda-zoom-control i { font-size: 0.8rem; color: var(--lexa-gray-400, #94A3B8); }
.agenda-zoom-control input[type="range"] {
  width: 80px; height: 4px; appearance: none; background: var(--lexa-gray-200, #E2E8F0);
  border-radius: 2px; outline: none; cursor: pointer;
}
.agenda-zoom-control input[type="range"]::-webkit-slider-thumb {
  appearance: none; width: 14px; height: 14px; border-radius: 50%;
  background: var(--lexa-primary, #6D28D9); cursor: pointer;
}
.agenda-zoom-control input[type="range"]::-moz-range-thumb {
  width: 14px; height: 14px; border-radius: 50%; border: none;
  background: var(--lexa-primary, #6D28D9); cursor: pointer;
}
.agenda-slot-week.slot-blocked { background-color: #f8f8f8; cursor: not-allowed; }

.agenda-slot.slot-outside-hours {
  background-color: #f9f9fb;
  background-image: repeating-linear-gradient(-45deg, transparent, transparent 10px, rgba(0,0,0,0.015) 10px, rgba(0,0,0,0.015) 20px);
  cursor: not-allowed;
}
.agenda-slot.slot-outside-hours:hover { background-color: #f9f9fb; }
.agenda-slot-week.slot-outside-hours.drag-over { background-color: #f9f9fb !important; outline: none; }

.agenda-slot.slot-holiday-blocked,
.agenda-slot-week.slot-holiday-blocked {
  background-color: #fff3f3;
  background-image: repeating-linear-gradient(-45deg, transparent, transparent 10px, rgba(220,53,69,0.06) 10px, rgba(220,53,69,0.06) 20px);
  cursor: not-allowed;
}
.agenda-slot.slot-holiday-blocked:hover,
.agenda-slot-week.slot-holiday-blocked:hover { background-color: #fff3f3; }

.appointment-card.appointment-conflict {
  border-color: #f59e0b !important;
  box-shadow: inset 3px 0 0 #f59e0b, 0 2px 8px rgba(245, 158, 11, 0.16);
}

.appt-indicators .ind-conflict {
  color: #d97706;
}

.schedule-conflicts-filter {
  align-items: end;
  margin-bottom: 1rem;
}

.schedule-conflicts-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: .75rem;
  margin-bottom: 1rem;
}

.schedule-conflicts-kpi {
  background: var(--card-bg, #fff);
  border: 1px solid var(--border-color, #dce5f2);
  border-radius: 8px;
  padding: .75rem 1rem;
  box-shadow: 0 1px 2px rgba(15, 23, 42, .04);
}

.schedule-conflicts-kpi .label {
  display: block;
  color: #64748b;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.schedule-conflicts-kpi strong {
  display: block;
  color: #0f172a;
  font-size: 1.25rem;
  line-height: 1.2;
  margin-top: .2rem;
}

.schedule-conflicts-card .table th {
  white-space: nowrap;
}

.schedule-conflict-reason {
  max-width: 220px;
}

@media (max-width: 992px) {
  .schedule-conflicts-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 576px) {
  .schedule-conflicts-summary {
    grid-template-columns: 1fr;
  }
}

.agenda-day-header.holiday-header { background-color: #fff3f3; border-bottom: 2px solid #dc3545; }

.therapist-block-card {
  position: absolute;
  left: 2px;
  right: 2px;
  background: repeating-linear-gradient(45deg, #f0f0f0, #f0f0f0 5px, #e0e0e0 5px, #e0e0e0 10px);
  border-left: 3px solid #6c757d;
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 0.5rem;
  color: #6c757d;
  z-index: 0;
  cursor: default;
  opacity: 0.8;
}
.therapist-block-card .block-reason { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.agenda-slot-week.drag-over { background-color: #d4edda !important; outline: 2px dashed #198754; }
.appointment-card[draggable="true"] { cursor: grab; }
.appointment-card[draggable="true"]:active { cursor: grabbing; opacity: 0.7; }

/* Context menu */
.context-menu {
  position: fixed;
  z-index: 1060;
  background: #fff;
  border: 1px solid #dee2e6;
  border-radius: 0.375rem;
  box-shadow: 0 0.5rem 1rem rgba(0,0,0,.15);
  min-width: 160px;
  padding: 0.25rem 0;
}
.context-menu-item { display: block; width: 100%; padding: 0.375rem 1rem; border: none; background: none; text-align: left; font-size: 0.875rem; cursor: pointer; }
.context-menu-item:hover { background-color: #f8f9fa; }
.context-menu-item.text-danger:hover { background-color: #f8d7da; }

/* Legend popover */
.legend-item { display: flex; align-items: center; gap: 0.5rem; padding: 0.25rem 0; font-size: 0.8rem; }
.legend-color { width: 28px; height: 16px; border-radius: 4px; flex-shrink: 0; box-shadow: 0 1px 2px rgba(0,0,0,0.08); }
.legend-icon { width: 28px; text-align: center; font-size: 0.95rem; flex-shrink: 0; }
.legend-section-title { font-size: 0.7rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; color: #64748b; margin: 0.35rem 0 0.15rem; }
.legend-separator { margin: 0.5rem 0; border: 0; border-top: 1px solid #e2e8f0; }

/* --------------------------------------------------------------------------
   APPOINTMENT DETAIL MODAL
   -------------------------------------------------------------------------- */

.detail-header { padding: 1rem 1.25rem 0.75rem; border-bottom: 1px solid #e9ecef; }
.detail-header .detail-title { font-weight: 600; font-size: 1rem; margin: 0; }
.detail-header .detail-subtitle { font-size: 0.8rem; color: #6c757d; margin: 0.125rem 0 0; }
.detail-header .btn-edit-top { font-size: 0.8rem; padding: 0.2rem 0.6rem; }

.detail-body { padding: 1.25rem; }

.detail-summary-card { background: #f8f9fa; border-radius: 0.5rem; padding: 1rem; margin-bottom: 1rem; }
.detail-summary-card .summary-row { display: flex; justify-content: space-between; align-items: baseline; padding: 0.2rem 0; }
.detail-summary-card .summary-label { color: #6c757d; font-size: 0.8rem; flex-shrink: 0; }
.detail-summary-card .summary-value { font-size: 0.875rem; text-align: right; }
.detail-summary-card .summary-value.fw-semibold { font-weight: 600; }
.detail-summary-card .summary-price { font-size: 1.1rem; font-weight: 700; color: #212529; }
.detail-summary-card .summary-divider { border-top: 1px solid #dee2e6; margin: 0.5rem 0; }

.detail-status-row { display: flex; align-items: center; gap: 0.5rem; padding: 0.75rem 0; }
.detail-status-row .status-badge-current { font-size: 0.75rem; font-weight: 500; padding: 0.3em 0.7em; border-radius: 9999px; display: none; }
.detail-status-row select { max-width: 180px; font-size: 0.85rem; }

.badge-plan               { background-color: #e8d5f5; color: #432874; }
.badge-plan-recovery      { background-color: #f8d7da; color: #842029; }
.badge-detail-scheduled   { background-color: #cfe2ff; color: #084298; }
.badge-detail-confirmed   { background-color: #cce5ff; color: #055160; }
.badge-detail-rescheduled { background-color: #e8d5f5; color: #432874; }
.badge-detail-inprogress  { background-color: #fff3cd; color: #664d03; }
.badge-detail-attended    { background-color: #d1e7dd; color: #0f5132; }
.badge-detail-cancelled   { background-color: #f8d7da; color: #842029; }
.badge-detail-noshow      { background-color: #fff3cd; color: #664d03; }

.detail-patient-section { border-top: 1px solid #e9ecef; padding-top: 0.75rem; margin-top: 0.25rem; }
.detail-patient-section .patient-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.5rem; }
.detail-patient-section .patient-header h6 { margin: 0; font-size: 0.75rem; text-transform: uppercase; color: #6c757d; letter-spacing: 0.03em; }
.detail-patient-section .patient-info { font-size: 0.85rem; }
.detail-patient-section .patient-info .info-item { display: flex; align-items: center; gap: 0.5rem; padding: 0.2rem 0; }
.detail-patient-section .patient-info .info-label { color: #6c757d; min-width: 70px; font-size: 0.8rem; }

.detail-notes { background: #fffbeb; border-left: 3px solid #f59e0b; padding: 0.5rem 0.75rem; border-radius: 0 0.25rem 0.25rem 0; font-size: 0.85rem; margin-top: 0.75rem; }

.detail-footer { padding: 0.75rem 1.25rem; border-top: 1px solid #e9ecef; display: flex; justify-content: flex-end; gap: 0.5rem; }

.detail-meta { padding: 0 1.25rem 0.75rem; font-size: 0.7rem; color: #adb5bd; }

/* Care plan appointment month pills */
.plan-month-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  padding: 0.35em 0.65em;
  border-radius: 9999px;
  font-size: var(--lexa-font-size-xs, 0.75rem);
  font-weight: var(--lexa-font-weight-semibold, 600);
  line-height: 1;
  white-space: nowrap;
}

.plan-month-pill-total {
  background-color: #ede9fe;
  color: #4c1d95;
}

.plan-month-pill-attended {
  background-color: #dcfce7;
  color: #14532d;
}

.plan-month-pill-missing {
  background-color: #fef3c7;
  color: #78350f;
}

.plan-month-pill-over {
  background-color: #ffedd5;
  color: #7c2d12;
}

.plan-month-pill-recovery {
  background-color: #fee2e2;
  color: #7f1d1d;
}

.plan-month-pill-sm {
  font-size: 0.7rem;
}

.plan-month-pill-xs {
  font-size: 0.65rem;
}

/* --------------------------------------------------------------------------
   PATIENT CHART
   -------------------------------------------------------------------------- */

.chart-header {
  background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
  border-radius: 0.5rem;
  padding: 0.75rem 1.5rem;
  margin-bottom: 1rem;
}
.chart-header-content {
  min-width: 0;
  width: 100%;
}
.chart-header-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  margin-top: 0.35rem;
}
.chart-header .patient-name {
  display: inline-flex;
  align-items: center;
  min-width: 0;
  font-size: 1.4rem;
  font-weight: 600;
  line-height: 1.2;
}
.chart-header .patient-meta {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  color: #6c757d;
  font-size: 0.875rem;
}
.chart-header-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.chart-header-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  max-width: min(100%, 28rem);
  padding: 0.35rem 0.65rem;
  border-radius: 999px;
  background: rgba(109, 40, 217, 0.08);
  color: #4c1d95;
  font-size: 0.8rem;
  font-weight: 600;
}
.chart-header-badge i {
  flex: 0 0 auto;
}
.chart-header-badge-label {
  color: #6c757d;
  font-weight: 500;
}
.chart-header-badge-value {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
@media (max-width: 575.98px) {
  .chart-header {
    padding: 0.75rem 1rem;
  }
  .chart-header-row {
    align-items: flex-start;
    gap: 0.4rem 0.75rem;
  }
  .chart-header .patient-name {
    width: 100%;
    font-size: 1.25rem;
  }
}

.chart-tabs .nav-link { font-size: 0.9rem; padding: 0.5rem 1rem; }
.chart-tabs .nav-link.active { font-weight: 600; }

.stat-card {
  border-radius: 0.5rem;
  padding: 1rem;
  text-align: center;
  background: #fff;
  border: 1px solid #dee2e6;
}
.stat-card .stat-number { font-size: 1.8rem; font-weight: 700; line-height: 1; }
.stat-card .stat-label { font-size: 0.8rem; color: #6c757d; text-transform: uppercase; letter-spacing: 0.5px; }

.info-section {
  border: 1px solid #dee2e6;
  border-radius: 0.5rem;
  padding: 1rem;
  margin-bottom: 1rem;
}
.info-section h6 { color: #6c757d; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 0.75rem; padding-bottom: 0.5rem; border-bottom: 1px solid #eee; }
.info-row { display: flex; margin-bottom: 0.35rem; font-size: 0.9rem; }
.info-row .info-label { width: 140px; flex-shrink: 0; color: #6c757d; }
.info-row .info-value { font-weight: 500; }

.patient-summary-strip-title {
  font-size: 0.65rem;
  letter-spacing: 0.05em;
}

.chart-tab-content { min-height: 400px; }

/* --------------------------------------------------------------------------
   PROFILE & AVATAR
   -------------------------------------------------------------------------- */

.profile-avatar-lg {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background-color: #e9ecef;
  border: 3px solid #dee2e6;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}
.profile-avatar-lg i { font-size: 3rem; color: #adb5bd; }
.profile-avatar-lg img { width: 100%; height: 100%; object-fit: cover; }

.profile-avatar-preview {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background-color: #e9ecef;
  border: 2px solid #dee2e6;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}
.profile-avatar-preview i { font-size: 2.5rem; color: #adb5bd; }
.profile-avatar-preview img { width: 100%; height: 100%; object-fit: cover; }

.profile-image-preview {
  width: 150px;
  height: 150px;
  border-radius: 50%;
  overflow: hidden;
  background-color: #e9ecef;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 3px solid #dee2e6;
  flex-shrink: 0;
}
.profile-image-preview img { width: 100%; height: 100%; object-fit: cover; }
.profile-image-preview i { font-size: 4rem; color: #6c757d; }

/* --------------------------------------------------------------------------
   SELECT COMPANY
   -------------------------------------------------------------------------- */

.select-container {
  background: white;
  border-radius: 16px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.2);
  padding: 40px;
  max-width: 600px;
  max-height: calc(100dvh - 48px);
  width: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.select-container > .text-center,
.select-container > .alert,
.select-container > hr {
  flex-shrink: 0;
}

.select-container #selectForm {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-height: 0;
}

.company-list-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding-right: 4px;
}

.company-card {
  border: 2px solid #e9ecef;
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 16px;
  cursor: pointer;
  transition: all 0.2s ease;
}
.company-card:hover { border-color: #667eea; transform: translateY(-2px); box-shadow: 0 4px 12px rgba(102,126,234,0.2); }
.company-card.selected { border-color: #667eea; background: #f8f9ff; }
.company-card.submitting { cursor: wait; opacity: 0.75; pointer-events: none; }
.company-card .company-name { font-weight: 600; font-size: 1.1rem; color: #333; }
.company-card .company-identity { font-size: 0.85rem; color: #999; }

.role-selector { margin-top: 12px; padding-top: 12px; border-top: 1px solid #eee; display: none; }
.role-option { display: inline-block; margin-right: 8px; margin-bottom: 8px; cursor: pointer; }
.role-option input { display: none; }
.role-option .role-badge { display: inline-block; padding: 8px 16px; border-radius: 20px; font-size: 0.85rem; font-weight: 500; border: 2px solid transparent; transition: all 0.2s; }
.role-option input:checked + .role-badge { box-shadow: 0 0 0 3px rgba(102,126,234,0.3); border-color: #667eea; }

.role-ADMIN     { background: #ffeaa7; color: #8b6914; }
.role-THERAPIST { background: #81ecec; color: #00796b; }
.role-SECRETARY { background: #fab1a0; color: #a34400; }
.role-PATIENT   { background: #a29bfe; color: #4527a0; }

.select-company-logo { font-size: 2rem; font-weight: 700; color: #667eea; margin-bottom: 8px; }
.role-badges { margin-top: 8px; }
.role-badges .badge { margin-right: 4px; }

/* --------------------------------------------------------------------------
   PAGE-SPECIFIC LAYOUT: AGENDA
   Applied via body.page-agenda class
   -------------------------------------------------------------------------- */

body.page-agenda { overflow: hidden; height: 100%; }
html:has(body.page-agenda) { overflow: hidden; height: 100%; }

body.page-agenda .lexa-main {
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

body.page-agenda .lexa-main > main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

body.page-agenda .lexa-main > main > .d-flex,
body.page-agenda .lexa-main > main > .alert,
body.page-agenda .lexa-main > main > .agenda-toolbar,
body.page-agenda .agenda-info-row {
  flex-shrink: 0;
}

[data-theme="dark"] body.page-agenda .lexa-module-header .btn-outline-secondary,
[data-theme="dark"] body.page-agenda #agendaModeSelector .btn-outline-secondary {
  background-color: var(--lexa-surface-sunken);
  border-color: var(--lexa-border-strong);
  color: var(--lexa-text-secondary);
}

[data-theme="dark"] body.page-agenda .lexa-module-header .btn-outline-secondary:hover:not(:disabled),
[data-theme="dark"] body.page-agenda #agendaModeSelector .btn-outline-secondary:hover:not(:disabled) {
  background-color: var(--lexa-surface-hover);
  border-color: var(--lexa-primary);
  color: var(--lexa-text-primary);
}

[data-theme="dark"] body.page-agenda #agendaModeSelector .btn-outline-secondary.active {
  background-color: var(--lexa-surface-overlay);
  border-color: var(--lexa-primary);
  color: var(--lexa-text-primary);
  box-shadow: inset 0 0 0 1px rgba(167,139,250,0.35);
}

[data-theme="dark"] body.page-agenda .lexa-module-header .btn:disabled,
[data-theme="dark"] body.page-agenda #agendaModeSelector .btn:disabled {
  background-color: var(--lexa-surface-raised);
  border-color: var(--lexa-border-default);
  color: var(--lexa-text-disabled);
  opacity: 1;
}

[data-theme="dark"] body.page-agenda .lexa-module-header .btn-primary:disabled {
  background-color: color-mix(in srgb, var(--lexa-primary) 82%, #000 18%);
  border-color: color-mix(in srgb, var(--lexa-primary) 88%, #000 12%);
  color: var(--lexa-white);
}

/* --------------------------------------------------------------------------
   PAGE-SPECIFIC LAYOUT: SELECT COMPANY
   Applied via body.page-select-company class
   -------------------------------------------------------------------------- */

body.page-select-company {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  overflow: hidden;
  padding: 24px;
}

html:has(body.page-select-company) {
  height: 100%;
  overflow: hidden;
}

@media (max-width: 576px) {
  body.page-select-company {
    padding: 16px;
  }

  .select-container {
    max-height: calc(100dvh - 32px);
    padding: 24px;
  }
}

/* --------------------------------------------------------------------------
   PAGE-SPECIFIC LAYOUT: LOGIN
   Applied via body.page-login class
   -------------------------------------------------------------------------- */

body.page-login {
  background: var(--lexa-primary-50);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  margin: 0;
  font-family: var(--lexa-font-family-base);
}

.login-wrapper {
  display: flex;
  flex: 1;
  min-height: 0;
}

/* --- Branding column --- */
.login-branding {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, var(--lexa-primary-100) 0%, var(--lexa-primary-50) 100%);
  padding: var(--lexa-spacing-8);
}

.login-branding-content {
  max-width: 480px;
  text-align: center;
}

.login-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--lexa-spacing-3);
  margin-bottom: var(--lexa-spacing-8);
}

.login-logo-text {
  font-size: var(--lexa-font-size-4xl);
  font-weight: var(--lexa-font-weight-bold);
  color: var(--lexa-primary);
}

.login-headline {
  font-size: var(--lexa-font-size-2xl);
  font-weight: var(--lexa-font-weight-bold);
  color: var(--lexa-gray-800);
  margin-bottom: var(--lexa-spacing-3);
  line-height: var(--lexa-line-height-tight);
}

.login-subheadline {
  font-size: var(--lexa-font-size-lg);
  color: var(--lexa-gray-500);
  margin-bottom: var(--lexa-spacing-10);
}

.login-illustration svg {
  width: 100%;
  max-width: 360px;
  height: auto;
}

/* --- Form column --- */
.login-form-section {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--lexa-white);
  padding: var(--lexa-spacing-8);
}

/* --- Card --- */
.login-card {
  width: 100%;
  max-width: 440px;
  border-radius: var(--lexa-border-radius-xl);
  box-shadow: var(--lexa-shadow-lg);
  overflow: hidden;
  background: var(--lexa-white);
}

.login-card-header {
  background: linear-gradient(135deg, var(--lexa-primary) 0%, var(--lexa-primary-800) 100%);
  color: var(--lexa-white);
  padding: var(--lexa-spacing-6) var(--lexa-spacing-8);
}

.login-card-header h2 {
  margin: 0 0 var(--lexa-spacing-1) 0;
  font-size: var(--lexa-font-size-xl);
  font-weight: var(--lexa-font-weight-bold);
  color: var(--lexa-white);
}

.login-card-header p {
  margin: 0;
  font-size: var(--lexa-font-size-sm);
  opacity: 0.85;
}

.login-card-body {
  padding: var(--lexa-spacing-8);
}

/* --- Form elements --- */
.login-input-group .input-group-text {
  background: var(--lexa-gray-50);
  border-color: var(--lexa-border-color);
  color: var(--lexa-gray-400);
}

.login-input-group .form-control:focus {
  border-color: var(--lexa-primary-300);
  box-shadow: 0 0 0 0.2rem rgba(109, 40, 217, 0.15);
}

.login-toggle-password {
  border: 1px solid var(--lexa-border-color);
  background: var(--lexa-gray-50);
  color: var(--lexa-gray-400);
  transition: color var(--lexa-transition-fast), border-color var(--lexa-transition-fast);
}

.login-toggle-password:hover {
  color: var(--lexa-primary);
  border-color: var(--lexa-primary-300);
}

.login-btn {
  background: var(--lexa-primary);
  color: var(--lexa-white);
  font-size: var(--lexa-font-size-lg);
  font-weight: var(--lexa-font-weight-semibold);
  padding: var(--lexa-spacing-3) var(--lexa-spacing-4);
  border: none;
  border-radius: var(--lexa-border-radius-lg);
  transition: transform var(--lexa-transition-fast), box-shadow var(--lexa-transition-fast), background var(--lexa-transition-fast);
}

.login-btn:hover {
  background: var(--lexa-primary-hover);
  color: var(--lexa-white);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(109, 40, 217, 0.3);
}

.login-btn:active {
  transform: translateY(0);
  background: var(--lexa-primary-active);
}

.login-forgot-link {
  font-size: var(--lexa-font-size-sm);
  color: var(--lexa-primary);
  text-decoration: none;
}

.login-forgot-link:hover {
  text-decoration: underline;
  color: var(--lexa-primary-hover);
}

/* --- Footer --- */
.login-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--lexa-spacing-4) var(--lexa-spacing-8);
  font-size: var(--lexa-font-size-xs);
  color: var(--lexa-gray-400);
  flex-shrink: 0;
}

.login-footer-version {
  color: var(--lexa-gray-300);
}

/* --- Responsive --- */
@media (max-width: 991px) {
  .login-branding {
    padding: var(--lexa-spacing-6);
  }
  .login-form-section {
    padding: var(--lexa-spacing-6);
  }
  .login-headline {
    font-size: var(--lexa-font-size-xl);
  }
  .login-illustration svg {
    max-width: 280px;
  }
}

@media (max-width: 768px) {
  .login-wrapper {
    flex-direction: column-reverse;
  }
  .login-branding {
    padding: var(--lexa-spacing-6) var(--lexa-spacing-4);
  }
  .login-illustration {
    display: none;
  }
  .login-form-section {
    padding: var(--lexa-spacing-6) var(--lexa-spacing-4);
  }
  .login-footer {
    padding: var(--lexa-spacing-3) var(--lexa-spacing-4);
  }
}

@media (max-width: 480px) {
  .login-branding {
    display: none;
  }
  .login-card {
    box-shadow: none;
    border-radius: 0;
  }
  .login-form-section {
    padding: var(--lexa-spacing-4);
    align-items: flex-start;
    padding-top: var(--lexa-spacing-10);
  }
  .login-footer {
    flex-direction: column;
    gap: var(--lexa-spacing-1);
    text-align: center;
  }
}

/* --------------------------------------------------------------------------
   PAGE-SPECIFIC LAYOUT: LANDING
   Applied via body.page-landing class
   -------------------------------------------------------------------------- */

/* --- General --- */
.page-landing {
  font-family: var(--lexa-font-family-base);
  color: var(--lexa-gray-700);
  overflow-x: clip;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  scroll-behavior: smooth;
  scroll-padding-top: 72px;
}

/* --- Nav --- */
.landing-nav {
  position: fixed;
  top: 0;
  width: 100%;
  z-index: 1000;
  padding: 0.75rem 0;
  transition: background 0.3s, box-shadow 0.3s;
  background: transparent;
}

.landing-nav-scrolled {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(12px);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.landing-nav-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--lexa-primary);
}

.landing-nav-brand svg {
  flex-shrink: 0;
}

.landing-nav-links {
  display: flex;
  align-items: center;
  gap: 1.75rem;
}

.landing-nav-link {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--lexa-gray-600);
  text-decoration: none;
  transition: color 0.2s;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}

.landing-nav-link:hover {
  color: var(--lexa-primary);
}

.landing-btn-login {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--lexa-gray-600);
  text-decoration: none;
  transition: color 0.2s;
}

.landing-btn-login:hover {
  color: var(--lexa-primary);
}

.landing-btn-nav-cta {
  display: inline-flex;
  align-items: center;
  padding: 0.5rem 1.25rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: white;
  background: var(--lexa-primary);
  border-radius: var(--lexa-border-radius-lg);
  text-decoration: none;
  transition: all 0.2s;
}

.landing-btn-nav-cta:hover {
  background: var(--lexa-primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(109, 40, 217, 0.25);
}

.landing-hamburger {
  display: none;
}

/* --- Hero --- */
.landing-hero {
  padding: 8rem 0 5rem;
  background: linear-gradient(135deg, var(--lexa-primary-50) 0%, var(--lexa-white) 60%);
  position: relative;
  overflow: hidden;
  overflow-x: clip;
}

.landing-hero::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -20%;
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, var(--lexa-primary-100) 0%, transparent 70%);
  opacity: 0.5;
  pointer-events: none;
}

.landing-hero-content {
  max-width: 560px;
}

.landing-hero-title {
  font-size: clamp(2rem, 4vw, 2.75rem);
  font-weight: 800;
  color: var(--lexa-gray-900);
  line-height: 1.15;
  margin-bottom: 1.25rem;
}

.landing-hero-subtitle {
  font-size: clamp(1rem, 1.5vw, 1.15rem);
  color: var(--lexa-gray-600);
  line-height: 1.7;
  margin-bottom: 2rem;
}

.landing-hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

.landing-hero-mockup {
  position: relative;
  max-width: 540px;
}

.landing-hero-mockup svg {
  width: 100%;
  height: auto;
  filter: drop-shadow(0 20px 40px rgba(109, 40, 217, 0.15));
}

/* --- Buttons (reusable) --- */
.landing-btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.8rem 2rem;
  font-size: 1rem;
  font-weight: 600;
  color: white;
  background: var(--lexa-primary);
  border: none;
  border-radius: var(--lexa-border-radius-lg);
  text-decoration: none;
  transition: all 0.2s;
  cursor: pointer;
}

.landing-btn-primary:hover {
  background: var(--lexa-primary-hover);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(109, 40, 217, 0.3);
  color: white;
}

.landing-btn-primary:active {
  transform: scale(0.97);
  box-shadow: none;
}

.landing-btn-outline {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.8rem 2rem;
  font-size: 1rem;
  font-weight: 600;
  color: var(--lexa-primary);
  background: transparent;
  border: 2px solid var(--lexa-primary-200);
  border-radius: var(--lexa-border-radius-lg);
  text-decoration: none;
  transition: all 0.2s;
  cursor: pointer;
}

.landing-btn-outline:hover {
  background: var(--lexa-primary-50);
  border-color: var(--lexa-primary-300);
  color: var(--lexa-primary);
}

.landing-btn-outline:active {
  transform: scale(0.97);
}

/* --- Section titles --- */
.landing-section {
  padding: 5rem 0;
}

.landing-section-alt {
  padding: 5rem 0;
  background: var(--lexa-gray-50);
}

.landing-section-title {
  font-size: clamp(1.5rem, 3vw, 2.1rem);
  font-weight: 700;
  color: var(--lexa-gray-900);
  margin-bottom: 0.75rem;
}

.landing-section-subtitle {
  font-size: clamp(0.925rem, 1.5vw, 1.05rem);
  color: var(--lexa-gray-600);
  line-height: 1.7;
  max-width: 640px;
  margin-left: auto;
  margin-right: auto;
}

/* --- Pain Points cards --- */
.landing-pain-card {
  display: flex;
  gap: 1rem;
  padding: 1.5rem;
  border-radius: var(--lexa-border-radius-lg);
  border: 1px solid var(--lexa-border-color);
  background: var(--lexa-white);
  transition: all 0.2s;
}

.landing-pain-card:hover {
  border-color: var(--lexa-primary-200);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.04);
}

.landing-pain-icon {
  width: 48px;
  height: 48px;
  min-width: 48px;
  background: var(--lexa-primary-50);
  border-radius: var(--lexa-border-radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
}

.landing-pain-icon i {
  font-size: 1.25rem;
  color: var(--lexa-primary);
}

.landing-pain-card .h4-visual {
  font-size: 1rem;
  font-weight: 600;
  color: var(--lexa-gray-800);
  margin-bottom: 0.25rem;
}

.landing-pain-card p {
  font-size: 0.875rem;
  color: var(--lexa-gray-500);
  margin: 0;
  line-height: 1.5;
}

/* --- Product zigzag --- */
.landing-product-block {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3rem;
  align-items: center;
  margin-bottom: 4rem;
}

.landing-product-block:last-child {
  margin-bottom: 0;
}

.landing-product-block.reverse {
  direction: rtl;
}

.landing-product-block.reverse > * {
  direction: ltr;
}

.landing-product-text h3 {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--lexa-gray-900);
  margin-bottom: 0.75rem;
}

.landing-product-text p {
  font-size: 0.95rem;
  color: var(--lexa-gray-500);
  line-height: 1.7;
}

.landing-product-mockup {
  border-radius: 0.75rem;
  overflow: hidden;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.08);
  border: 1px solid var(--lexa-border-color);
}

.landing-product-mockup svg {
  display: block;
  width: 100%;
  height: auto;
}

/* --- Feature grid --- */
.landing-feature-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.25rem;
}

.landing-feature-item {
  padding: 1.5rem;
  border-radius: var(--lexa-border-radius-lg);
  border: 1px solid var(--lexa-border-color);
  background: var(--lexa-white);
  transition: all 0.2s;
}

.landing-feature-item:hover {
  border-color: var(--lexa-primary-200);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.04);
}

.landing-feature-item i {
  font-size: 1.5rem;
  color: var(--lexa-primary);
  margin-bottom: 0.75rem;
  display: block;
}

.landing-feature-item .h3-visual {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--lexa-gray-800);
  margin-bottom: 0.3rem;
}

.landing-feature-item p {
  font-size: 0.825rem;
  color: var(--lexa-gray-500);
  margin: 0;
  line-height: 1.5;
}

/* --- Benefits --- */
.landing-benefit-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.5rem;
}

.landing-benefit-card {
  display: flex;
  gap: 1.25rem;
  padding: 1.75rem;
  border-radius: var(--lexa-border-radius-lg);
  background: var(--lexa-white);
  border: 1px solid var(--lexa-border-color);
}

.landing-benefit-card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.04);
}

.landing-benefit-icon {
  width: 48px;
  height: 48px;
  min-width: 48px;
  background: var(--lexa-primary-50);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.landing-benefit-icon i {
  font-size: 1.25rem;
  color: var(--lexa-primary);
}

.landing-benefit-card .h4-visual {
  font-size: 1rem;
  font-weight: 600;
  color: var(--lexa-gray-800);
  margin-bottom: 0.25rem;
}

.landing-benefit-card p {
  font-size: 0.875rem;
  color: var(--lexa-gray-600);
  margin: 0;
  line-height: 1.6;
}

/* --- Audience cards --- */
.landing-audience-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 1.25rem;
}

.landing-audience-card {
  text-align: center;
  padding: 2rem 1.25rem;
  border-radius: var(--lexa-border-radius-lg);
  border: 1px solid var(--lexa-border-color);
  background: var(--lexa-white);
  transition: all 0.2s;
}

.landing-audience-card:hover {
  border-color: var(--lexa-primary-200);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.04);
}

.landing-audience-card:active {
  transform: scale(0.98);
}

.landing-audience-card.featured {
  border-color: var(--lexa-primary-200);
  background: linear-gradient(to bottom, var(--lexa-primary-50), var(--lexa-white));
}

.landing-audience-card i {
  font-size: 2rem;
  color: var(--lexa-primary);
  margin-bottom: 0.75rem;
  display: block;
}

.landing-audience-card .h4-visual {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--lexa-gray-800);
  margin-bottom: 0.3rem;
}

.landing-audience-card p {
  font-size: 0.875rem;
  color: var(--lexa-gray-600);
  margin: 0;
  line-height: 1.5;
}

.landing-audience-badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--lexa-primary);
  background: var(--lexa-primary-100);
  padding: 0.2rem 0.6rem;
  border-radius: 1rem;
  margin-top: 0.5rem;
}

/* --- Trust --- */
.landing-trust-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.25rem;
}

.landing-trust-item {
  text-align: center;
  padding: 1.5rem 1rem;
}

.landing-trust-item i {
  font-size: 1.75rem;
  color: var(--lexa-primary-300);
  margin-bottom: 0.75rem;
  display: block;
}

.landing-trust-item p {
  font-size: 0.875rem;
  color: var(--lexa-gray-600);
  margin: 0;
  line-height: 1.5;
}

.landing-testimonial-placeholder {
  margin-top: 3rem;
  text-align: center;
  padding: 2rem;
  border: 1px dashed var(--lexa-gray-300);
  border-radius: var(--lexa-border-radius-lg);
  background: var(--lexa-gray-50);
}

.landing-testimonial-placeholder p {
  font-size: 0.9rem;
  color: var(--lexa-gray-400);
  font-style: italic;
}

/* --- FAQ --- */
.landing-faq {
  max-width: 800px;
  margin: 0 auto;
}

.landing-faq .accordion-item {
  border: 1px solid var(--lexa-border-color);
  border-radius: var(--lexa-border-radius-lg) !important;
  margin-bottom: 0.5rem;
  overflow: hidden;
}

.landing-faq .accordion-button {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--lexa-gray-800);
  background: var(--lexa-white);
  padding: 1rem 1.25rem;
}

.landing-faq .accordion-button:not(.collapsed) {
  color: var(--lexa-primary);
  background: var(--lexa-primary-50);
  box-shadow: none;
}

.landing-faq .accordion-button:focus {
  box-shadow: 0 0 0 3px rgba(109, 40, 217, 0.15);
}

.landing-faq .accordion-button::after {
  filter: brightness(0) saturate(100%);
}

.landing-faq .accordion-body {
  font-size: 0.9rem;
  color: var(--lexa-gray-600);
  line-height: 1.7;
  padding: 0 1.25rem 1rem;
}

/* --- Demo form --- */
.landing-demo {
  padding: 5rem 0;
  background: linear-gradient(135deg, var(--lexa-primary-50) 0%, var(--lexa-white) 100%);
}

.landing-demo-card {
  background: var(--lexa-white);
  border-radius: 1rem;
  padding: 2.5rem;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
  border: 1px solid var(--lexa-border-color);
}

.landing-demo-card .form-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--lexa-gray-700);
}

.landing-demo-card .form-control {
  font-size: 0.9rem;
  border-color: var(--lexa-gray-200);
  padding: 0.6rem 0.75rem;
}

.landing-demo-card .form-control:focus {
  border-color: var(--lexa-primary-300);
  box-shadow: 0 0 0 3px rgba(109, 40, 217, 0.12);
}

/* --- Footer --- */
.landing-footer {
  padding: 2.5rem 0;
  border-top: 1px solid var(--lexa-border-color);
}

.landing-footer-links {
  display: flex;
  gap: 1.5rem;
  list-style: none;
  padding: 0;
  margin: 0;
}

.landing-footer-links a {
  font-size: 0.85rem;
  color: var(--lexa-gray-500);
  text-decoration: none;
}

.landing-footer-links a:hover {
  color: var(--lexa-primary);
}

.landing-footer-text {
  font-size: 0.8rem;
  color: var(--lexa-gray-400);
}

.landing-btn-primary.lexa-btn-loading {
  pointer-events: none;
  opacity: 0.85;
}

/* --- Problems section --- */
.landing-problems {
  padding: 5rem 0;
  background: var(--lexa-gray-50);
}

.landing-problem-card {
  padding: 1.75rem;
  border-radius: var(--lexa-border-radius-lg);
  border: 1px solid var(--lexa-border-color);
  background: var(--lexa-white);
  transition: all 0.2s;
  height: 100%;
}

.landing-problem-card:hover {
  border-color: var(--lexa-primary-200);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.04);
}

.landing-problem-card:active {
  transform: scale(0.98);
}

.landing-problem-icon {
  width: 48px;
  height: 48px;
  background: var(--lexa-primary-50);
  border-radius: var(--lexa-border-radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1rem;
}

.landing-problem-icon i {
  font-size: 1.25rem;
  color: var(--lexa-primary);
}

.landing-problem-card .h4-visual {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--lexa-gray-800);
  margin-bottom: 0.5rem;
}

.landing-problem-card p {
  font-size: 0.875rem;
  color: var(--lexa-gray-600);
  margin: 0;
  line-height: 1.6;
}

/* --- Product section --- */
.landing-product {
  padding: 5rem 0;
}

.landing-product-title {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--lexa-gray-900);
  margin-bottom: 0.75rem;
}

/* --- Features section (grid) --- */
.landing-features {
  padding: 5rem 0;
  background: var(--lexa-gray-50);
}

.landing-feature-card {
  padding: 1.5rem;
  border-radius: var(--lexa-border-radius-lg);
  border: 1px solid var(--lexa-border-color);
  background: var(--lexa-white);
  transition: all 0.2s;
  height: 100%;
}

.landing-feature-card:hover {
  border-color: var(--lexa-primary-200);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.04);
}

.landing-feature-card:active {
  transform: scale(0.98);
}

.landing-feature-icon {
  width: 48px;
  height: 48px;
  background: var(--lexa-primary-50);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 0.75rem;
}

.landing-feature-icon i {
  font-size: 1.25rem;
  color: var(--lexa-primary);
}

.landing-feature-card .h3-visual {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--lexa-gray-800);
  margin-bottom: 0.3rem;
}

.landing-feature-card p {
  font-size: 0.875rem;
  color: var(--lexa-gray-600);
  margin: 0;
  line-height: 1.6;
}

/* --- Benefits section --- */
.landing-benefits {
  padding: 5rem 0;
}

.landing-benefit-card .h4-visual-alt {
  font-size: 1rem;
  font-weight: 600;
  color: var(--lexa-gray-800);
  margin-bottom: 0.25rem;
}

/* --- Audience highlight card --- */
.landing-audience {
  padding: 5rem 0;
  background: var(--lexa-gray-50);
}

.landing-audience-card-highlight {
  border-color: var(--lexa-primary-200);
  background: linear-gradient(to bottom, var(--lexa-primary-50), var(--lexa-white));
  position: relative;
}

.landing-audience-card-highlight .landing-audience-badge {
  position: absolute;
  top: -0.6rem;
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
}

/* --- Trust section --- */
.landing-trust {
  padding: 5rem 0;
}

.landing-trust-card {
  padding: 1.5rem 1rem;
  border-radius: var(--lexa-border-radius-lg);
  border: 1px solid var(--lexa-border-color);
  background: var(--lexa-white);
  height: 100%;
}

.landing-trust-icon {
  font-size: 1.75rem;
  color: var(--lexa-primary-300);
  margin-bottom: 0.75rem;
  display: block;
}

.landing-trust-card p {
  font-size: 0.875rem;
  color: var(--lexa-gray-600);
  margin: 0;
  line-height: 1.5;
}

.landing-testimonial-icon {
  font-size: 2rem;
  color: var(--lexa-gray-300);
  margin-bottom: 0.5rem;
  display: block;
}

.landing-testimonial-text {
  font-size: 1rem;
  font-weight: 600;
  color: var(--lexa-gray-500);
  font-style: italic;
}

/* --- FAQ section wrapper --- */
.landing-faq-section {
  padding: 5rem 0;
  background: var(--lexa-gray-50);
}

/* --- Check list --- */
.landing-check-list {
  list-style: none;
  padding: 0;
  margin: 1rem 0 0;
}

.landing-check-list li {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
  color: var(--lexa-gray-600);
}

.landing-check-list li i {
  color: var(--lexa-primary);
  margin-top: 0.15rem;
  flex-shrink: 0;
}

/* --- Footer link --- */
.landing-footer-link {
  font-size: 0.875rem;
  color: var(--lexa-gray-500);
  text-decoration: none;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}

.landing-footer-link:hover {
  color: var(--lexa-primary);
}

/* --- Hero illustration --- */
.landing-hero-illustration svg {
  width: 100%;
  height: auto;
  aspect-ratio: 560 / 400;
  filter: drop-shadow(0 20px 40px rgba(109, 40, 217, 0.15));
}

/* --- Landing reduced motion --- */
@media (prefers-reduced-motion: reduce) {
  .page-landing, .page-landing *, .page-landing *::before, .page-landing *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* --- Landing responsive --- */
@media (max-width: 991.98px) {
  .landing-nav-links { display: none; }
  .landing-hamburger { display: flex; align-items: center; justify-content: center; width: 44px; height: 44px; }
  .landing-hero { padding: 7rem 0 4rem; }
  .landing-product-block { grid-template-columns: 1fr; gap: 2rem; }
  .landing-product-block.reverse { direction: ltr; }
  .landing-feature-grid { grid-template-columns: repeat(2, 1fr); }
  .landing-audience-grid { grid-template-columns: repeat(3, 1fr); }
  .landing-trust-grid { grid-template-columns: repeat(2, 1fr); }
  .landing-benefit-grid { grid-template-columns: 1fr; }
}

@media (max-width: 767.98px) {
  /* Hero */
  .landing-hero { padding: 5.5rem 0 2.5rem; text-align: center; overflow: hidden; }
  .landing-hero-content { max-width: 100%; }
  .landing-hero-subtitle { font-size: 1rem; }
  .landing-hero-actions { justify-content: center; }
  .landing-hero-mockup { margin: 1.5rem auto 0; max-width: 100%; }
  .landing-hero-mockup svg { max-width: 100%; height: auto; }

  /* Sections */
  .landing-section, .landing-section-alt { padding: 3rem 0; }
  .landing-section-title { font-size: 1.5rem; }

  /* Pain points — readable text */
  .landing-problem-card .h4-visual { font-size: 1rem; }
  .landing-problem-card p { font-size: 0.925rem; }

  /* Features — single col */
  .landing-feature-grid { grid-template-columns: 1fr; }
  .landing-feature-card .h3-visual { font-size: 1rem; }
  .landing-feature-card p { font-size: 0.925rem; }

  /* Audience */
  .landing-audience-grid { grid-template-columns: repeat(2, 1fr); }
  .landing-audience-card p { font-size: 0.9rem; }

  /* Trust */
  .landing-trust-grid { grid-template-columns: repeat(2, 1fr); }

  /* Demo form */
  .landing-demo-card { padding: 1.5rem; }

  /* SVG mockups — prevent overflow */
  .landing-product-mockup svg { max-width: 100%; height: auto; }

  /* Offcanvas links — proper touch targets */
  .offcanvas a { min-height: 44px; display: flex; align-items: center; font-size: 1rem; padding: 0.5rem 1rem; }
  .offcanvas .btn { min-height: 44px; font-size: 1rem; }
}

@media (max-width: 479.98px) {
  .landing-hero { padding: 5rem 0 2rem; }
  .landing-hero-title { font-size: 1.6rem; }
  .landing-hero-subtitle { font-size: 0.95rem; }
  .landing-hero-actions { flex-direction: column; }
  .landing-hero-actions a { width: 100%; text-align: center; }
  .landing-audience-grid { grid-template-columns: 1fr; }
  .landing-demo-card { padding: 1.25rem; }
  .landing-problem-card { padding: 1.25rem; }
  .landing-section, .landing-section-alt { padding: 2.5rem 0; }
}

/* --- Back to top button --- */
.landing-back-to-top {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: var(--lexa-primary);
  color: #fff;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px);
  transition: opacity 0.3s, visibility 0.3s, transform 0.3s;
  box-shadow: 0 4px 12px rgba(109, 40, 217, 0.3);
  z-index: 900;
}

.landing-back-to-top.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.landing-back-to-top:hover {
  background: var(--lexa-primary-hover);
  box-shadow: 0 6px 20px rgba(109, 40, 217, 0.4);
}

.landing-back-to-top:active {
  transform: scale(0.93);
}

@media (max-width: 479.98px) {
  .landing-back-to-top { bottom: 1rem; right: 1rem; }
}

/* --------------------------------------------------------------------------
   OWNER DASHBOARD
   -------------------------------------------------------------------------- */

.kpi-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}

.kpi-value {
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.1;
  margin-bottom: 0;
}

.kpi-label {
  font-size: 0.75rem;
  color: var(--lexa-gray-500, #64748B);
  margin-bottom: 0.25rem;
}

.kpi-help {
  font-size: 0.7rem;
  opacity: 0.5;
  cursor: help;
  vertical-align: middle;
  transition: opacity 0.15s;
}
.kpi-help:hover { opacity: 0.9; }

/* Dashboard cards — compact + white surface */
.dash-card {
  background: var(--lexa-white, #ffffff);
  border: 1px solid var(--lexa-border-color, #E2E8F0);
  border-radius: var(--lexa-border-radius-lg, 0.5rem);
  box-shadow: none;
}

.dash-birthday-branches {
  font-size: 0.68rem;
  line-height: 1.1;
  margin-top: 0.1rem;
}

.dash-card .card-body {
  padding: 0.75rem 1rem;
}

/* KPI Strip — compact inline metrics */
.kpi-strip {
  display: flex;
  gap: 0;
}
.kpi-strip-item {
  flex: 1;
  padding: 0.15rem 0.5rem;
  border-right: 1px solid var(--lexa-border-color, #E2E8F0);
  min-width: 0;
}
.kpi-strip-item:last-child { border-right: none; }
.kpi-strip-label {
  display: block;
  font-size: 0.65rem;
  color: var(--lexa-gray-500, #64748B);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.kpi-strip-value {
  display: block;
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1.3;
  font-variant-numeric: tabular-nums;
}
@media (max-width: 767.98px) {
  .kpi-strip { flex-wrap: wrap; }
  .kpi-strip-item { flex: 0 0 50%; border-right: none; border-bottom: 1px solid var(--lexa-border-color, #E2E8F0); padding: 0.25rem 0.5rem; }
  .kpi-strip-item:nth-last-child(-n+2) { border-bottom: none; }
  .kpi-strip-value { font-size: 1rem; }
}

.owner-patients-strip .kpi-strip-item {
  padding-top: 0.35rem;
  padding-bottom: 0.35rem;
}

.owner-kpi-strip-link {
  display: block;
  color: inherit;
  text-decoration: none;
}

.owner-kpi-strip-link:hover {
  color: inherit;
  text-decoration: none;
}

.owner-kpi-progress {
  max-width: 7rem;
}

/* Productivity report */
.progress-thin { height: 5px; }

/* Waitlist patient search results */
.waitlist-patient-results {
  z-index: 1050;
  max-height: 200px;
  overflow-y: auto;
  display: none;
}

/* Waitlist time preferences compact display */
.waitlist-time-prefs {
  font-size: 0.8rem;
  line-height: 1.4;
}
.waitlist-time-prefs .badge {
  font-weight: 500;
}

/* Waitlist time preference repeater */
.time-pref-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.5rem;
}
.time-pref-row select,
.time-pref-row input[type="time"] {
  flex: 1;
  min-width: 0;
}
.time-pref-row .btn-remove {
  flex-shrink: 0;
}

a.dash-card-link {
  text-decoration: none;
  color: inherit;
}
a.dash-card-link .dash-card {
  cursor: pointer;
  transition: box-shadow 0.15s ease;
}
a.dash-card-link:hover .dash-card {
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* Dashboard accent borders — 2px, Lexa palette */
.dash-accent-primary {
  border-left: 2px solid var(--lexa-primary-300, #A78BFA) !important;
}
.dash-accent-danger {
  border-left: 2px solid #FDA4AF !important;
}

/* Dashboard pastel danger text — softer than --lexa-danger */
.dash-text-danger {
  color: #E11D48 !important;
}

/* --------------------------------------------------------------------------
   THERAPIST KPI CHIPS — Compact horizontal strip for mobile
   -------------------------------------------------------------------------- */
.dash-kpi-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.375rem 0.75rem;
  border-radius: 2rem;
  background: var(--lexa-gray-100, #f1f5f9);
  border: 1px solid var(--lexa-border-color, #E2E8F0);
  font-size: 0.8rem;
  white-space: nowrap;
}
.dash-kpi-chip-label {
  color: var(--lexa-gray-500, #64748B);
}
.dash-kpi-chip-value {
  font-weight: 700;
  color: var(--lexa-gray-900, #0F172A);
}
.dash-kpi-chip-active {
  background: var(--lexa-primary-50, #F5F3FF);
  border-color: var(--lexa-primary-300, #A78BFA);
}
.dash-kpi-chip-active .dash-kpi-chip-value {
  color: var(--lexa-primary-600, #7C3AED);
}
.dash-kpi-chip-danger {
  background: #FFF1F2;
  border-color: #FDA4AF;
}
.dash-kpi-chip-danger .dash-kpi-chip-value {
  color: #E11D48;
}

/* --------------------------------------------------------------------------
   DASHBOARD KPI CARDS — Purple gradient style
   -------------------------------------------------------------------------- */
.kpi-card {
  background: linear-gradient(135deg, #7c3aed 0%, #6d28d9 50%, #5b21b6 100%);
  border: none;
  border-radius: 1rem;
  color: #fff;
  overflow: hidden;
  transition: transform 0.2s, box-shadow 0.2s;
}
.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(109, 40, 217, 0.3);
}
.kpi-card .card-body {
  padding: 1.25rem;
}
.kpi-card .kpi-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: rgba(255, 255, 255, 0.9);
  margin-bottom: 0.25rem;
}
.kpi-card .kpi-value {
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: 0;
}
.kpi-card .kpi-icon-circle {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.kpi-card .kpi-icon-circle i {
  font-size: 0.95rem;
  color: #fff;
}
.kpi-card .card-footer {
  background: rgba(0, 0, 0, 0.1);
  border-top: 1px solid rgba(255, 255, 255, 0.15);
  padding: 0.5rem 1.25rem;
}
.kpi-card .card-footer a {
  color: rgba(255, 255, 255, 0.85);
  text-decoration: none;
  font-size: 0.8rem;
}
.kpi-card .card-footer a:hover {
  color: #fff;
}

/* Variant: danger (for pending notes with high count) */
.kpi-card.kpi-danger {
  background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
}
.kpi-card.kpi-danger:hover {
  box-shadow: 0 8px 25px rgba(220, 38, 38, 0.3);
}

/* Variant: warning */
.kpi-card.kpi-warning {
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
}
.kpi-card.kpi-warning:hover {
  box-shadow: 0 8px 25px rgba(245, 158, 11, 0.3);
}

/* Variant: muted/secondary */
.kpi-card.kpi-muted {
  background: linear-gradient(135deg, #6b7280 0%, #4b5563 100%);
}
.kpi-card.kpi-muted:hover {
  box-shadow: 0 8px 25px rgba(107, 114, 128, 0.3);
}

/* Branch badges in therapist cards */
.badge-branch {
  font-size: 0.6em;
}

/* --------------------------------------------------------------------------
   UI KIT — Clases estandarizadas lexa-*
   -------------------------------------------------------------------------- */

/* Boton icon-only (cuadrado, sin texto) */
.lexa-btn-icon {
  width: 32px;
  height: 32px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.lexa-btn-icon.btn-sm { width: 28px; height: 28px; }
.lexa-btn-icon.btn-lg { width: 40px; height: 40px; }

/* Estado loading en botones */
.btn .btn-spinner { display: none; }
.lexa-btn-loading .btn-text { display: none; }
.lexa-btn-loading .btn-spinner { display: inline-block; }
.lexa-btn-loading { pointer-events: none; opacity: 0.75; }

/* Global auto-loading state */
.lexa-auto-loading { pointer-events: none; opacity: 0.75; }

/* Wrapper centrado de spinner */
.lexa-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--lexa-spacing-3, 0.75rem);
  padding: var(--lexa-spacing-8, 2rem);
  color: var(--lexa-gray-500, #64748B);
}

.lexa-loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.8);
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Seccion colapsable warning (emergency/medical) */
.lexa-form-section-warning {
  border-color: #FDE68A;
}
.lexa-form-section-warning > .card-header {
  background-color: #FEF9C3;
  border-bottom-color: #FDE68A;
}
.lexa-form-section-warning > .card-header i.bi-exclamation-triangle {
  color: #CA8A04;
}

/* Checklist container (especialidades, servicios) */
.lexa-checklist {
  max-height: 200px;
  overflow-y: auto;
  border: 1px solid var(--lexa-gray-200, #e9ecef);
  border-radius: var(--lexa-border-radius-base, 0.375rem);
  padding: var(--lexa-spacing-2, 0.5rem);
}

/* Daily summary modal: responsive table — hide secondary columns on mobile */
@media (max-width: 576px) {
  #summaryTable th:nth-child(2), #summaryTable td:nth-child(2),
  #summaryTable th:nth-child(n+6):not(:last-child), #summaryTable td:nth-child(n+6):not(:last-child) {
    display: none;
  }
  #summaryTable { font-size: 0.75rem; }
  #summaryTable th, #summaryTable td { padding: 0.3rem 0.4rem; white-space: nowrap; }
}
@media (max-width: 768px) {
  #summaryTable { font-size: 0.8rem; }
  #summaryTable th, #summaryTable td { padding: 0.3rem 0.5rem; }
}

/* Therapist quick card — lightweight popover for appointment clicks */
.therapist-quick-card {
  background: var(--lexa-white, #fff);
  border: 1px solid var(--lexa-border-color, #E2E8F0);
  border-radius: 0.5rem;
  padding: 0.75rem;
  min-width: 220px;
  max-width: 280px;
}
[data-theme="dark"] .therapist-quick-card {
  background: var(--lexa-surface-raised);
  border-color: var(--lexa-border-default);
}

/* Therapist view: hide mode selector (locked to week) */
body.therapist-view #agendaModeSelector { display: none; }

.therapist-mobile-view-selector {
  display: none;
}

.agenda-mobile-summary {
  display: none;
}

@media (max-width: 576px) {
  body.therapist-view .therapist-mobile-view-selector {
    display: inline-flex;
  }

  body.therapist-view .therapist-mobile-view-selector .btn {
    min-height: 34px;
    padding: 0.25rem 0.55rem;
    font-size: 0.75rem;
  }

  body.therapist-view.mobile-agenda-compact .agenda-mobile-summary {
    display: block;
  }

  body.therapist-view.mobile-agenda-compact .agenda-grid-week,
  body.therapist-view.mobile-agenda-compact .branch-legend {
    display: none;
  }

  body.therapist-view.mobile-agenda-detail .agenda-mobile-summary {
    display: none;
  }

  .agenda-mobile-summary {
    padding: 0.55rem 0.5rem 5.8rem;
    background: #f8fafc;
  }

  .agenda-mobile-summary section {
    background: #fff;
    border: 1px solid #dbe4f0;
    border-radius: 8px;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
    margin-bottom: 0.75rem;
    padding: 0.75rem;
  }

  .agenda-mobile-section-title {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.65rem;
    color: #17233a;
    font-weight: 700;
  }

  .agenda-mobile-section-title small {
    color: #64748b;
    font-size: 0.72rem;
    font-weight: 600;
    text-align: right;
  }

  body.therapist-view.mobile-agenda-compact .agenda-info-row,
  body.therapist-view.mobile-agenda-detail .agenda-info-row {
    display: none;
  }

  body.therapist-view.mobile-agenda-compact .agenda-toolbar,
  body.therapist-view.mobile-agenda-detail .agenda-toolbar {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.28rem;
    padding: 0.25rem 0.5rem;
  }

  body.therapist-view.mobile-agenda-compact .toolbar-date,
  body.therapist-view.mobile-agenda-detail .toolbar-date {
    grid-column: 1 / -1;
    grid-row: 1;
    display: grid;
    grid-template-columns: 38px 1fr 38px 42px;
    gap: 0.25rem;
  }

  body.therapist-view.mobile-agenda-compact .toolbar-date input[type="date"],
  body.therapist-view.mobile-agenda-compact .toolbar-date .btn,
  body.therapist-view.mobile-agenda-compact .agenda-toolbar #branchSelect,
  body.therapist-view.mobile-agenda-compact .agenda-toolbar #statusSelect,
  body.therapist-view.mobile-agenda-detail .toolbar-date input[type="date"],
  body.therapist-view.mobile-agenda-detail .toolbar-date .btn,
  body.therapist-view.mobile-agenda-detail .agenda-toolbar #branchSelect,
  body.therapist-view.mobile-agenda-detail .agenda-toolbar #statusSelect {
    min-height: 34px;
    height: 34px;
    font-size: 0.72rem;
  }

  body.therapist-view.mobile-agenda-compact .toolbar-date .btn,
  body.therapist-view.mobile-agenda-detail .toolbar-date .btn {
    min-width: 0;
    padding: 0;
  }

  body.therapist-view.mobile-agenda-compact .agenda-toolbar #branchSelect,
  body.therapist-view.mobile-agenda-detail .agenda-toolbar #branchSelect {
    grid-column: 1;
    grid-row: 2;
    width: 100%;
    max-width: none;
  }

  body.therapist-view.mobile-agenda-compact .agenda-toolbar #statusSelect,
  body.therapist-view.mobile-agenda-detail .agenda-toolbar #statusSelect {
    grid-column: 2;
    grid-row: 2;
    width: 100%;
    max-width: none;
  }

  body.therapist-view.mobile-agenda-compact .agenda-toolbar [data-mode-section="week"],
  body.therapist-view.mobile-agenda-compact .toolbar-actions,
  body.therapist-view.mobile-agenda-detail .agenda-toolbar [data-mode-section="week"],
  body.therapist-view.mobile-agenda-detail .toolbar-actions {
    display: none !important;
  }

  body.therapist-view.mobile-agenda-compact.single-branch .agenda-toolbar,
  body.therapist-view.mobile-agenda-detail.single-branch .agenda-toolbar {
    grid-template-columns: 1fr;
  }

  body.therapist-view.mobile-agenda-compact.single-branch .agenda-toolbar #statusSelect,
  body.therapist-view.mobile-agenda-detail.single-branch .agenda-toolbar #statusSelect {
    grid-column: 1;
    grid-row: 2;
  }

  /* ── Mobile Weekly View (Therapist Agenda) - NEW COMPACT DESIGN ── */
  body.therapist-view.mobile-agenda-week #agendaMobileWeeklyGrid {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 280px);
    background: var(--lexa-surface-base);
    font-family: var(--lexa-font-family-base);
  }

  body.therapist-view.mobile-agenda-week .agenda-mobile-summary,
  body.therapist-view.mobile-agenda-week .agenda-info-row,
  body.therapist-view.mobile-agenda-week .agenda-grid-wrapper {
    display: none !important;
  }

  /* Weekly Grid Header (Day Names) */
  .weekly-grid-header {
    display: flex;
    gap: 0;
    background: var(--lexa-surface-raised);
    border-bottom: 1px solid var(--lexa-border-default);
    flex-shrink: 0;
  }

  .weekly-grid-header-time {
    width: 42px;
    padding: 4px 2px;
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--lexa-text-tertiary);
    flex-shrink: 0;
  }

  .weekly-grid-header-day {
    flex: 1;
    min-width: 0;
    padding: 4px 2px;
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--lexa-text-tertiary);
    text-align: center;
    border-right: 1px solid var(--lexa-border-subtle);
  }

  .weekly-grid-header-day:last-child {
    border-right: none;
  }

  /* Weekly Grid Container */
  .weekly-grid-body {
    display: flex;
    overflow: auto;
    flex: 1;
    gap: 0;
  }

  /* Time Column (Sticky Left) */
  .weekly-grid-time-column {
    width: 42px;
    flex-shrink: 0;
    background: var(--lexa-surface-raised);
    border-right: 1px solid var(--lexa-border-default);
    overflow-y: hidden;
    z-index: 5;
  }

  .weekly-grid-time-slot {
    min-height: 24px;
    height: 24px;
    padding: 0 2px;
    font-size: 0.6rem;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--lexa-text-tertiary);
    border-bottom: 1px solid var(--lexa-border-subtle);
    font-weight: 500;
  }

  /* Day Columns */
  .weekly-grid-day-column {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0;
    border-right: 1px solid var(--lexa-border-subtle);
  }

  .weekly-grid-day-column:last-child {
    border-right: none;
  }

  .weekly-grid-appointment-slot {
    min-height: 24px;
    height: 24px;
    border-bottom: 1px solid var(--lexa-border-subtle);
    padding: 1px;
    position: relative;
    background: var(--lexa-surface-base);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
  }

  /* Appointment Badge in Weekly Mobile */
  .weekly-appointment-badge {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--lexa-primary);
    color: var(--lexa-text-inverse);
    font-size: 0.55rem;
    font-weight: 600;
    padding: 0 2px;
    border-radius: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    line-height: 1;
  }

  .weekly-appointment-badge.status-confirmed {
    background: var(--lexa-status-confirmed);
  }

  .weekly-appointment-badge.status-attended {
    background: var(--lexa-status-attended);
  }

  .weekly-appointment-badge.status-scheduled {
    background: var(--lexa-status-scheduled);
  }

  .weekly-appointment-badge.status-rescheduled {
    background: var(--lexa-status-rescheduled);
  }

  .weekly-appointment-badge.status-cancelled {
    background: var(--lexa-status-cancelled);
  }

  .weekly-appointment-badge.status-noshow {
    background: var(--lexa-status-noshow);
  }

  /* Empty State */
  .weekly-grid-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 200px;
    color: var(--lexa-text-tertiary);
    font-size: 0.75rem;
  }

  /* Toolbar adjustments for weekly mobile */
  body.therapist-view.mobile-agenda-week .agenda-toolbar {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.28rem;
    padding: 0.25rem 0.5rem;
  }

  body.therapist-view.mobile-agenda-week .toolbar-date {
    grid-column: 1 / -1;
    grid-row: 1;
    display: grid;
    grid-template-columns: 38px 1fr 38px 42px;
    gap: 0.25rem;
  }

  body.therapist-view.mobile-agenda-week .toolbar-date input[type="date"],
  body.therapist-view.mobile-agenda-week .toolbar-date .btn,
  body.therapist-view.mobile-agenda-week .agenda-toolbar #branchSelect,
  body.therapist-view.mobile-agenda-week .agenda-toolbar #statusSelect {
    min-height: 34px;
    height: 34px;
    font-size: 0.72rem;
  }

  body.therapist-view.mobile-agenda-week .toolbar-date .btn {
    min-width: 0;
    padding: 0;
  }

  body.therapist-view.mobile-agenda-week .agenda-toolbar #branchSelect {
    grid-column: 1;
    grid-row: 2;
    width: 100%;
    max-width: none;
  }

  body.therapist-view.mobile-agenda-week .agenda-toolbar #statusSelect {
    grid-column: 2;
    grid-row: 2;
    width: 100%;
    max-width: none;
  }

  body.therapist-view.mobile-agenda-week.single-branch .agenda-toolbar {
    grid-template-columns: 1fr;
  }

  body.therapist-view.mobile-agenda-week.single-branch .agenda-toolbar #statusSelect {
    grid-column: 1;
    grid-row: 2;
  }

  body.therapist-view.mobile-agenda-week .agenda-toolbar [data-mode-section="week"],
  body.therapist-view.mobile-agenda-week .toolbar-actions {
    display: none !important;
  }

  body.therapist-view.mobile-agenda-compact .agenda-mobile-next {
    position: fixed;
    left: 8px;
    right: 8px;
    bottom: calc(env(safe-area-inset-bottom, 0px) + 8px);
    z-index: 1040;
    display: grid;
    grid-template-columns: 96px 1fr;
    align-items: center;
    gap: 0.4rem;
    margin: 0;
    padding: 0.4rem;
    border-color: #cbd5e1;
    box-shadow: 0 10px 28px rgba(15, 23, 42, 0.18);
  }

  body.therapist-view.mobile-agenda-compact .agenda-mobile-next .agenda-mobile-section-title {
    display: flex;
    flex-direction: column;
    gap: 0.05rem;
    margin: 0;
    min-width: 0;
  }

  body.therapist-view.mobile-agenda-compact .agenda-mobile-next .agenda-mobile-section-title span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.74rem;
  }

  body.therapist-view.mobile-agenda-compact .agenda-mobile-next .agenda-mobile-section-title small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: left;
    font-size: 0.62rem;
  }

  .agenda-mobile-next-card {
    display: grid;
    grid-template-columns: 52px minmax(0, 1fr) auto 12px;
    align-items: center;
    gap: 0.45rem;
    width: 100%;
    min-height: 48px;
    border: 1px solid #cbd5e1;
    border-left: 4px solid #6d28d9;
    border-radius: 8px;
    background: #f8fbff;
    color: #17233a;
    padding: 0.38rem 0.45rem;
    text-align: left;
  }

  .agenda-mobile-next-time {
    color: #5b21b6;
    font-size: 1.05rem;
    font-weight: 800;
    line-height: 1;
  }

  .agenda-mobile-next-copy {
    display: flex;
    flex-direction: column;
    min-width: 0;
  }

  .agenda-mobile-next-copy strong,
  .agenda-mobile-next-copy span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .agenda-mobile-next-copy .service-name {
    color: #475569;
    font-size: 0.68rem;
    font-weight: 600;
  }

  .agenda-mobile-next-copy .appt-meta {
    display: flex;
    gap: 0.25rem;
    color: #64748b;
    font-size: 0.62rem;
    min-width: 0;
  }

  .agenda-mobile-status-chip,
  .therapist-quick-status {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    background: #eef2ff;
    color: #3730a3;
    border: 1px solid #c7d2fe;
    font-size: 0.62rem;
    font-weight: 800;
    line-height: 1;
    white-space: nowrap;
  }

  .agenda-mobile-status-chip {
    max-width: 82px;
    padding: 0.25rem 0.4rem;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .therapist-quick-status {
    padding: 0.3rem 0.5rem;
  }

  .agenda-mobile-empty {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #475569;
    background: #f8fafc;
    border: 1px dashed #cbd5e1;
    border-radius: 8px;
    padding: 0.85rem;
  }

  .agenda-mobile-timeline {
    display: grid;
    grid-template-columns: 44px 1fr;
    gap: 0.65rem;
  }

  .agenda-mobile-time-labels {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    color: #64748b;
    font-size: 0.7rem;
    font-weight: 700;
    height: 420px;
  }

  .agenda-mobile-rail {
    position: relative;
    height: 420px;
    overflow: hidden;
    border: 1px solid #dbe4f0;
    border-radius: 8px;
    background:
      repeating-linear-gradient(
        to bottom,
        #f8fafc 0,
        #f8fafc 34px,
        #edf2f7 35px
      );
  }

  .agenda-mobile-window,
  .agenda-mobile-block {
    position: absolute;
    box-sizing: border-box;
    left: 8px;
    right: 8px;
    min-height: 26px;
    border-radius: 7px;
    overflow: hidden;
  }

  .agenda-mobile-window {
    display: flex;
    align-items: center;
    color: #166534;
    background: #dcfce7;
    border: 1px solid #bbf7d0;
    font-size: 0.72rem;
    font-weight: 700;
    padding: 0 0.55rem;
  }

  .agenda-mobile-block {
    display: flex;
    align-items: center;
    column-gap: 0.55rem;
    border: 1px solid #c4b5fd;
    border-left: 4px solid #6d28d9;
    background: #ede9fe;
    color: #2e1065;
    padding: 0.18rem 0.5rem;
    text-align: left;
  }

  .agenda-mobile-block .time-range {
    display: inline;
    flex: 0 0 auto;
    font-size: 0.66rem;
    font-weight: 800;
    line-height: 1;
    white-space: nowrap;
  }

  .agenda-mobile-block .patient-name {
    display: inline;
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.68rem;
    line-height: 1;
  }

  .agenda-mobile-block .service-name {
    display: inline;
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #5b21b6;
    font-size: 0.66rem;
    line-height: 1;
  }

  .agenda-mobile-week-list {
    display: grid;
    gap: 0.45rem;
  }

  .agenda-mobile-week-row {
    display: grid;
    grid-template-columns: 62px 1fr 86px;
    align-items: center;
    gap: 0.55rem;
    min-height: 42px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 0.45rem 0.55rem;
  }

  .agenda-mobile-week-row.active {
    border-color: #c4b5fd;
    background: #faf5ff;
  }

  .agenda-mobile-week-row strong,
  .agenda-mobile-week-row span {
    display: block;
    line-height: 1.1;
  }

  .agenda-mobile-week-row strong {
    color: #17233a;
    font-size: 0.78rem;
  }

  .agenda-mobile-week-row span,
  .agenda-mobile-week-row small {
    color: #64748b;
    font-size: 0.68rem;
    font-weight: 600;
  }

  .agenda-mobile-week-meter {
    height: 9px;
    overflow: hidden;
    border-radius: 999px;
    background: #e2e8f0;
  }

  .agenda-mobile-week-meter span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: #6d28d9;
  }
}

/* Empty state para tablas */
.lexa-table-empty {
  text-align: center;
  padding: var(--lexa-spacing-8, 2rem) !important;
  color: var(--lexa-gray-500, #64748B);
}
.lexa-table-empty i {
  font-size: 2rem;
  display: block;
  margin-bottom: var(--lexa-spacing-2, 0.5rem);
  opacity: 0.5;
}

/* Loading overlay para tablas */
.lexa-table-loading {
  position: relative;
  min-height: 200px;
}
.lexa-table-loading::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.7);
  z-index: 5;
}

/* Header de modulo (titulo + acciones) */
.lexa-module-header {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--lexa-spacing-2, 0.5rem);
  margin-bottom: var(--lexa-spacing-1, 0.25rem);
  flex-wrap: wrap;
}
.lexa-module-header h2 {
  display: none;
}

/* Barra de filtros */
.lexa-filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--lexa-spacing-2, 0.5rem) var(--lexa-spacing-3, 0.75rem);
  align-items: flex-end;
  margin-bottom: var(--lexa-spacing-2, 0.5rem);
  padding: var(--lexa-spacing-2, 0.5rem) var(--lexa-spacing-3, 0.75rem);
  background: var(--lexa-gray-50, #f8f9fa);
  border-radius: var(--lexa-border-radius-lg, 0.5rem);
  border: 1px solid var(--lexa-gray-200, #e9ecef);
}

/* Altura uniforme: inputs, selects y botones dentro de filter bar */
.lexa-filter-bar .form-control,
.lexa-filter-bar .form-select,
.lexa-filter-bar .input-group .form-control {
  height: 2rem;
  min-height: 2rem;
  padding-top: 0.25rem;
  padding-bottom: 0.25rem;
  font-size: var(--lexa-font-size-sm, 0.875rem);
  line-height: 1.5;
}

/* Select: padding derecho extra para no pisar la flecha */
.lexa-filter-bar .form-select {
  padding-right: 2rem;
}

/* Input-group addon alineado */
.lexa-filter-bar .input-group .input-group-text {
  height: 2rem;
  padding-top: 0.25rem;
  padding-bottom: 0.25rem;
  font-size: var(--lexa-font-size-sm, 0.875rem);
}

/* Botones: misma altura que los controles */
.lexa-filter-bar .btn {
  height: 2rem;
  padding-top: 0;
  padding-bottom: 0;
  font-size: var(--lexa-font-size-sm, 0.875rem);
  line-height: 2rem;
  white-space: nowrap;
}

/* Labels consistentes */
.lexa-filter-bar .form-label {
  font-size: var(--lexa-font-size-xs, 0.75rem);
  margin-bottom: 0.25rem;
  font-weight: var(--lexa-font-weight-medium, 500);
  color: var(--lexa-gray-600, #475569);
}

/* ── Date Range Picker ── */
.lexa-daterange { position: relative; }

.lexa-daterange-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  white-space: nowrap;
  text-align: left;
  background: var(--lexa-surface-base, #fff);
  min-width: 13rem;
}
.lexa-daterange-toggle .bi-chevron-down {
  font-size: 0.65rem;
  opacity: 0.6;
  margin-left: auto;
  transition: transform 0.2s;
}
.lexa-daterange-toggle.active .bi-chevron-down { transform: rotate(180deg); }

.lexa-dr-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 1055;
  margin-top: 4px;
  background: var(--lexa-surface-base, #fff);
  border: 1px solid var(--lexa-gray-200, #e9ecef);
  border-radius: var(--lexa-border-radius-lg, 0.5rem);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  overflow: hidden;
}
.lexa-dr-dropdown.show { display: block; }

.lexa-dr-body { display: flex; }

/* Presets sidebar */
.lexa-dr-presets {
  min-width: 11rem;
  padding: 0.5rem 0;
  border-right: 1px solid var(--lexa-gray-200, #e9ecef);
}
.lexa-dr-preset {
  padding: 0.5rem 1rem;
  cursor: pointer;
  font-size: 0.875rem;
  color: var(--lexa-gray-700, #334155);
  transition: background 0.15s;
  white-space: nowrap;
}
.lexa-dr-preset:hover { background: var(--lexa-gray-100, #f1f5f9); }
.lexa-dr-preset.active {
  background: var(--lexa-primary-50, #eff6ff);
  color: var(--lexa-primary, #2563eb);
  font-weight: 500;
}

/* Calendars wrapper */
.lexa-dr-cals-wrapper { display: flex; flex-direction: column; }
.lexa-dr-calendars { display: flex; gap: 1rem; padding: 0.75rem 1rem 0; }

/* Single calendar */
.lexa-dr-cal-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  margin-bottom: 0.5rem;
}
.lexa-dr-nav {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.25rem;
  border-radius: 4px;
  color: var(--lexa-gray-600, #475569);
  line-height: 1;
}
.lexa-dr-nav:hover { background: var(--lexa-gray-100, #f1f5f9); }
.lexa-dr-month-sel, .lexa-dr-year-sel {
  border: none;
  background: none;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--lexa-gray-800, #1e293b);
  cursor: pointer;
  padding: 0.15rem 0;
}
.lexa-dr-month-sel { min-width: 5.5rem; }
.lexa-dr-year-sel { min-width: 3.5rem; }

/* Day grid */
.lexa-dr-grid {
  display: grid;
  grid-template-columns: repeat(7, 2rem);
  gap: 1px;
  justify-content: center;
}
.lexa-dr-dow {
  text-align: center;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--lexa-primary, #2563eb);
  padding: 0.25rem 0;
  text-transform: capitalize;
}
.lexa-dr-day {
  text-align: center;
  font-size: 0.8rem;
  padding: 0.3rem 0;
  cursor: pointer;
  border-radius: 4px;
  transition: background 0.1s;
  color: var(--lexa-gray-800, #1e293b);
}
.lexa-dr-day:hover:not(.other):not(.range-start):not(.range-end) { background: var(--lexa-gray-100, #f1f5f9); }
.lexa-dr-day.range-start:hover, .lexa-dr-day.range-end:hover { opacity: 0.85; }
.lexa-dr-day.other { color: var(--lexa-gray-400, #94a3b8); }
.lexa-dr-day.today {
  font-weight: 600;
  border-radius: 50%;
  box-shadow: inset 0 0 0 2px var(--lexa-primary, #2563eb);
  color: var(--lexa-primary, #2563eb);
}
.lexa-dr-day.in-range {
  background: var(--lexa-primary-50, #eff6ff);
  border-radius: 0;
}
.lexa-dr-day.in-range:hover:not(.range-start):not(.range-end) { background: var(--lexa-primary-100, #dbeafe); }
.lexa-dr-day.range-start {
  background: var(--lexa-primary, #2563eb);
  color: #fff;
  border-radius: 4px 0 0 4px;
}
.lexa-dr-day.range-end {
  background: var(--lexa-primary, #2563eb);
  color: #fff;
  border-radius: 0 4px 4px 0;
}
.lexa-dr-day.range-single {
  border-radius: 4px;
}
.lexa-dr-day.today.range-start,
.lexa-dr-day.today.range-end {
  background: var(--lexa-primary, #2563eb);
  color: #fff;
  box-shadow: none;
}
.lexa-dr-day.today.in-range:not(.range-start):not(.range-end) {
  color: var(--lexa-primary, #2563eb);
  box-shadow: inset 0 0 0 2px var(--lexa-primary, #2563eb);
  background: var(--lexa-primary-50, #eff6ff);
}

/* Footer */
.lexa-dr-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--lexa-gray-200, #e9ecef);
  font-size: 0.8rem;
  color: var(--lexa-gray-600, #475569);
}
.lexa-dr-footer-actions { display: flex; gap: 0.5rem; }

/* Filter bar integration */
.lexa-filter-bar .lexa-daterange-toggle {
  height: 2rem;
  padding-top: 0;
  padding-bottom: 0;
  font-size: var(--lexa-font-size-sm, 0.875rem);
  line-height: 2rem;
}

/* ── Date Range Picker – responsive ── */
@media (max-width: 640px) {
  .lexa-dr-body { flex-direction: column; }
  .lexa-dr-presets {
    border-right: none;
    border-bottom: 1px solid var(--lexa-gray-200, #e9ecef);
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    padding: 0.5rem;
    min-width: unset;
  }
  .lexa-dr-preset { padding: 0.35rem 0.75rem; font-size: 0.8rem; border-radius: 1rem; }
  .lexa-dr-calendars { flex-direction: column; gap: 0.5rem; padding: 0.5rem; }
  .lexa-dr-dropdown { right: 0; left: auto; max-width: calc(100vw - 2rem); }
  .lexa-dr-footer { flex-wrap: wrap; justify-content: center; }
}

/* Empty state completo (seccion/pagina) */
.lexa-empty-state {
  text-align: center;
  padding: var(--lexa-spacing-12, 3rem) var(--lexa-spacing-4, 1rem);
  color: var(--lexa-gray-500, #64748B);
}
.lexa-empty-state i {
  font-size: 3rem;
  opacity: 0.4;
  margin-bottom: var(--lexa-spacing-3, 0.75rem);
  display: block;
}
.lexa-empty-state .lexa-empty-title {
  font-size: var(--lexa-font-size-lg, 1.125rem);
  font-weight: var(--lexa-font-weight-semibold, 600);
  color: var(--lexa-gray-700, #334155);
  margin-bottom: var(--lexa-spacing-1, 0.25rem);
}
.lexa-empty-state .lexa-empty-text {
  font-size: var(--lexa-font-size-sm, 0.875rem);
  margin-bottom: var(--lexa-spacing-4, 1rem);
}

/* Drawer lateral (sobre Bootstrap offcanvas) */
.lexa-drawer {
  width: 480px !important;
  border-left: 1px solid var(--lexa-gray-200, #e9ecef);
  box-shadow: var(--lexa-shadow-lg);
}
.lexa-drawer .offcanvas-header {
  border-bottom: 1px solid var(--lexa-gray-200, #e9ecef);
  padding: var(--lexa-spacing-4, 1rem);
}
.lexa-drawer .offcanvas-body {
  padding: var(--lexa-spacing-4, 1rem);
}
@media (max-width: 575px) {
  .lexa-drawer { width: 100% !important; }
}

/* Timeline vertical */
.lexa-timeline {
  position: relative;
  padding-left: 24px;
}
.lexa-timeline::before {
  content: '';
  position: absolute;
  left: 7px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--lexa-gray-200, #e9ecef);
}
.lexa-timeline-item {
  position: relative;
  padding-bottom: var(--lexa-spacing-4, 1rem);
}
.lexa-timeline-item::before {
  content: '';
  position: absolute;
  left: -20px;
  top: 4px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--lexa-primary, #6D28D9);
  border: 2px solid var(--lexa-white, #ffffff);
}
.lexa-timeline-item.timeline-success::before {
  background: var(--lexa-success, #16A34A);
}
.lexa-timeline-item.timeline-danger::before {
  background: var(--lexa-danger, #DC2626);
}
.lexa-timeline-item.timeline-warning::before {
  background: var(--lexa-warning, #F59E0B);
}
.lexa-timeline-date {
  font-size: var(--lexa-font-size-xs, 0.75rem);
  color: var(--lexa-gray-500, #64748B);
}
.lexa-timeline-content {
  font-size: var(--lexa-font-size-sm, 0.875rem);
}

/* Schedule editor */
.schedule-branch-filter {
  min-width: 200px;
}
.schedule-branch-select {
  min-width: 140px;
}
.schedule-day-select {
  width: auto;
}

/* ============================================
   PORTAL — MOBILE-FIRST RESPONSIVE
   ============================================ */

@media (max-width: 576px) {
  /* KPIs: 2 per row instead of 3 */
  .portal-kpis .col-4 { flex: 0 0 50%; max-width: 50%; }
  .portal-kpis .kpi-value { font-size: 1.5rem; }
  .portal-kpis .kpi-label { font-size: 0.7rem; }

  /* Plan columns: stack vertically */
  .portal-plan-cols .col-sm-4 { flex: 0 0 100%; max-width: 100%; }

  /* Tables: smaller font, enforce horizontal scroll */
  .portal-table { font-size: 0.8rem; }
  .portal-table th,
  .portal-table td { padding: 0.4rem 0.5rem; white-space: nowrap; }

  /* Upload form: stack fields */
  #uploadDocForm { flex-direction: column; }
  #uploadDocForm .col,
  #uploadDocForm .col-auto { flex: 0 0 100%; max-width: 100%; width: 100%; }

  /* Touch targets: minimum 38px for action buttons */
  .portal-table .btn-sm { min-height: 38px; min-width: 38px; }

  /* Header: stack vertically */
  .portal-header { flex-direction: column; align-items: flex-start !important; }
  .portal-header .btn { width: 100%; }
}

@media (max-width: 768px) {
  /* Plan cards compact */
  .portal-plan-cols .border.rounded { padding: 0.5rem !important; }
  .portal-plan-cols .fs-5 { font-size: 1.1rem !important; }
}

/* ============================================
   THERAPIST MOBILE RESPONSIVE
   ============================================ */

/* -- Tablet (768px) -- */
@media (max-width: 768px) {
  /* Note form: stack fields at tablet, not just mobile */
  #noteForm .col-md-6 { flex: 0 0 100%; max-width: 100%; }

  /* Note form header: wrap buttons */
  #noteForm .d-flex.justify-content-between { flex-wrap: wrap; gap: 0.5rem; }

  /* Dashboard next session: stack buttons below info */
  .dash-card .d-flex.justify-content-between.align-items-start { flex-direction: column; gap: 0.75rem; }
}

/* -- Dashboard cards: reset h-100 when cols wrap (<lg) -- */
/* Cards that use .h-100 for desktop grid alignment (Alertas, Estado Citas, etc.)
   overflow their natural content box at mobile, covering the next <h6> section
   title. When cols stack there's no sibling to match, so force height: auto. */
@media (max-width: 991.98px) {
  .dash-card.h-100 { height: auto !important; }
}

/* -- CashRegister date navigator -- */
/* Arrow buttons stay compact (icon-only), the date input flexes to fill the
   row, and nothing wraps. Without these rules the arrows grew to ~90px on
   mobile and the date value was clipped. */
.cash-date-nav { flex-wrap: nowrap; }
.cash-date-nav-arrow {
  flex: 0 0 auto;
  padding: 0.375rem 0.5rem;
  min-width: 36px;
}
.cash-date-nav-input {
  flex: 1 1 auto;
  min-width: 0;
  max-width: 180px;
}
.cash-date-nav-today { flex: 0 0 auto; }
@media (max-width: 576px) {
  .cash-date-nav-input { max-width: none; }
}

/* -- Mobile (576px) -- */
@media (max-width: 576px) {
  /* === AGENDA === */
  .agenda-time-cell,
  .agenda-time-header { width: 50px; min-width: 50px; font-size: 0.7rem; }

  .agenda-therapist-header {
    padding: 0.25rem;
    gap: 0.25rem;
    min-height: 36px;
  }
  .agenda-therapist-header img,
  .agenda-therapist-header .therapist-avatar { width: 22px; height: 22px; font-size: 0.6rem; }
  .agenda-therapist-header .therapist-name {
    font-size: 0.7rem;
    max-width: 70px;
  }
  /* Con 4+ terapeutas, ocultar nombre y dejar solo avatar (el tooltip title lo cubre) */
  .agenda-grid[style*="repeat(4"] .agenda-therapist-header .therapist-name,
  .agenda-grid[style*="repeat(5"] .agenda-therapist-header .therapist-name,
  .agenda-grid[style*="repeat(6"] .agenda-therapist-header .therapist-name,
  .agenda-grid[style*="repeat(7"] .agenda-therapist-header .therapist-name,
  .agenda-grid[style*="repeat(8"] .agenda-therapist-header .therapist-name {
    display: none;
  }

  /* Appointment cards: bigger touch targets (min 44px tap area) */
  .appointment-card { padding: 4px 6px; min-height: 44px; }
  .appointment-card .patient-name { font-size: 0.7rem; }
  .appointment-card .service-name { font-size: 0.6rem; }
  .appointment-card .appt-meta { font-size: 0.6rem; }
  .appointment-card .appt-indicators { font-size: 0.7rem; }

  /* === DETAIL MODAL === */
  .detail-footer { flex-wrap: wrap; gap: 0.5rem; }
  .detail-footer > div { width: 100%; display: flex; gap: 0.5rem; }
  .detail-footer > div .btn { flex: 1; }
  .detail-footer > button { width: 100%; }

  .detail-summary-card { padding: 0.75rem; }
  .summary-row .summary-label { font-size: 0.75rem; }
  .summary-row .summary-value { font-size: 0.8rem; }

  .detail-status-row { flex-wrap: wrap; gap: 0.5rem; }
  .detail-status-row select { width: 100%; min-height: 44px; }

  /* Detail action buttons: touch-friendly */
  .detail-body .btn-sm { min-height: 38px; min-width: 38px; }

  /* Patient info: stack labels */
  .detail-patient-section .info-item { font-size: 0.8rem; }

  /* === DASHBOARD === */
  .dash-card .kpi-value { font-size: clamp(1.05rem, 4.8vw, 1.4rem); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .dash-card .kpi-label { font-size: 0.7rem; }
  .dash-card .card-body { padding: 0.5rem 0.75rem; }

  /* Dashboard agenda table: horizontal scroll + nowrap */
  .dash-card .table { font-size: 0.8rem; white-space: nowrap; }
  .dash-card .table th,
  .dash-card .table td { padding: 0.3rem 0.5rem; }
  .dash-card .table .btn-sm { min-height: 38px; min-width: 38px; }

  /* Pending notes list: compact */
  .dash-card .list-group-item { padding: 0.5rem 0.75rem; font-size: 0.85rem; }

  /* === NOTE FORM === */
  #noteForm .d-flex.gap-2 .btn { font-size: 0.75rem; padding: 0.3rem 0.6rem; min-height: 38px; }

  /* Note form textareas: taller on mobile for easier editing */
  #noteForm textarea { min-height: 80px; }

  /* === MODULE HEADERS === */
  .lexa-module-header { flex-wrap: wrap; gap: 0.5rem; }
  .lexa-module-header .btn { font-size: 0.8rem; }

  /* === FILTER BARS === */
  .lexa-filter-bar { flex-direction: column; }
  .lexa-filter-bar > div { width: 100%; }
  .lexa-filter-bar .btn { width: 100%; }

  /* === TABLES GENERAL === */
  .table-responsive .btn-group-sm .btn { min-height: 38px; min-width: 38px; }
}

/* -- Extra small phones (360px) -- */
@media (max-width: 360px) {
  .dash-card .kpi-value { font-size: 1.2rem; }
  .appointment-card .patient-name { font-size: 0.65rem; }
  .detail-body { padding: 0.75rem; }
  .lexa-module-header .btn { font-size: 0.75rem; }
}

/* Agenda header buttons: tight wrap en ≤576px (F01) */
@media (max-width: 575.98px) {
  body.page-agenda .lexa-module-header > div.d-flex {
    flex-wrap: wrap;
    gap: 0.35rem;
    width: 100%;
  }
  body.page-agenda .lexa-module-header .btn {
    white-space: nowrap;
    padding: 0.3rem 0.55rem;
    font-size: 0.75rem;
    min-height: 38px;
  }
  /* Día/Semana group: let it sit inline without filling width */
  body.page-agenda #agendaModeSelector { flex: 0 0 auto; }
  body.page-agenda #agendaModeSelector .btn { flex: 0 0 auto; }
  /* Nueva Cita + Lista Espera share the first row 50/50 */
  body.page-agenda #btnNewAppointment,
  body.page-agenda .lexa-module-header a[href="/Waitlist/Index"] {
    flex: 1 1 auto;
  }
}

/* ============================================
   CLINICAL NOTE TEMPLATE BUILDER (F035)
   ============================================ */

.note-template-preview-sticky {
  position: sticky;
  top: 80px;
}

.note-field-item {
  border: 1px solid var(--lexa-gray-200);
  border-radius: 0.5rem;
  padding: 0.75rem;
  margin-bottom: 0.5rem;
  background: var(--lexa-gray-50, #f8f9fa);
}

.note-field-item:hover {
  border-color: var(--lexa-primary-light, #a78bfa);
}

.note-preview-header {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--lexa-primary);
  border-bottom: 2px solid var(--lexa-primary);
  padding-bottom: 0.5rem;
  margin-bottom: 1rem;
}

.note-preview-section-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--lexa-gray-700, #374151);
  border-bottom: 1px solid var(--lexa-gray-200);
  padding: 0.5rem 0 0.25rem;
  margin: 0.75rem 0 0.5rem;
}

.note-preview-field {
  margin-bottom: 0.75rem;
}

.note-preview-field label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--lexa-gray-600, #4b5563);
  margin-bottom: 0.25rem;
}

.note-field-display {
  white-space: pre-wrap;
}

.note-preview-value {
  font-size: 0.85rem;
  color: var(--lexa-gray-500, #6b7280);
  font-style: italic;
  padding: 0.25rem 0.5rem;
  background: var(--lexa-gray-50, #f8f9fa);
  border-radius: 0.25rem;
}

/* ==========================================================================
   WIKI / CENTRO DE AYUDA
   ========================================================================== */

.wiki-topnav {
  background: var(--lexa-white, #fff);
  border-bottom: 1px solid var(--lexa-border-color, #E2E8F0);
  padding: 0.75rem 1.5rem;
  position: sticky;
  top: 0;
  z-index: 100;
}
.wiki-brand {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--lexa-primary, #6D28D9);
  text-decoration: none;
}
.wiki-brand:hover { opacity: 0.8; }
.wiki-topnav-link {
  color: var(--lexa-gray-600, #475569);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
}
.wiki-topnav-link:hover { color: var(--lexa-primary, #6D28D9); }

.wiki-layout {
  display: flex;
  min-height: calc(100vh - 56px);
}

/* Sidebar */
.wiki-sidebar {
  width: 260px;
  min-width: 260px;
  border-right: 1px solid var(--lexa-border-color, #E2E8F0);
  background: var(--lexa-gray-50, #F8FAFC);
  padding: 1rem 0;
  overflow-y: auto;
  position: sticky;
  top: 56px;
  height: calc(100vh - 56px);
}

.wiki-nav-tree { padding: 0 0.5rem; }
.wiki-nav-item {
  display: block;
  padding: 0.4rem 0.75rem;
  color: var(--lexa-gray-700, #334155);
  text-decoration: none;
  font-size: 0.85rem;
  border-radius: 0.375rem;
  margin-bottom: 1px;
}
.wiki-nav-item:hover { background: var(--lexa-primary-light, #EDE9FE); color: var(--lexa-primary, #6D28D9); }
.wiki-nav-item.active { background: var(--lexa-primary-light, #EDE9FE); color: var(--lexa-primary, #6D28D9); font-weight: 600; }

.wiki-nav-section { margin-bottom: 0.25rem; }
.wiki-nav-section-header {
  display: flex;
  align-items: center;
  padding: 0.5rem 0.75rem;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--lexa-gray-500, #64748B);
  cursor: pointer;
  user-select: none;
  letter-spacing: 0.03em;
}
.wiki-nav-section-header:hover { color: var(--lexa-primary, #6D28D9); }
.wiki-nav-chevron { transition: transform 0.2s; font-size: 0.7rem; }
.wiki-nav-section.open .wiki-nav-chevron { transform: rotate(90deg); }
.wiki-nav-section-items {
  display: none;
  padding-left: 1rem;
}
.wiki-nav-section.open .wiki-nav-section-items { display: block; }

/* Main content */
.wiki-main {
  flex: 1;
  padding: 1.5rem 2rem;
  max-width: 900px;
}

.wiki-breadcrumb {
  font-size: 0.8rem;
  margin-bottom: 1rem;
}
.wiki-breadcrumb a { color: var(--lexa-primary, #6D28D9); text-decoration: none; }
.wiki-breadcrumb a:hover { text-decoration: underline; }

/* Prose styles for rendered markdown */
.wiki-content h1 { font-size: 1.75rem; font-weight: 700; margin-bottom: 0.75rem; color: var(--lexa-gray-900, #0F172A); }
.wiki-content h2 { font-size: 1.3rem; font-weight: 600; margin-top: 2rem; margin-bottom: 0.5rem; padding-bottom: 0.3rem; border-bottom: 1px solid var(--lexa-border-color, #E2E8F0); }
.wiki-content h3 { font-size: 1.1rem; font-weight: 600; margin-top: 1.5rem; margin-bottom: 0.4rem; }
.wiki-content p { line-height: 1.7; margin-bottom: 1rem; color: var(--lexa-gray-700, #334155); }
.wiki-content ul, .wiki-content ol { padding-left: 1.5rem; margin-bottom: 1rem; }
.wiki-content li { margin-bottom: 0.3rem; line-height: 1.6; color: var(--lexa-gray-700, #334155); }
.wiki-content blockquote { border-left: 3px solid var(--lexa-primary-200, #C4B5FD); padding: 0.5rem 1rem; margin: 1rem 0; background: var(--lexa-primary-50, #F5F3FF); border-radius: 0 0.375rem 0.375rem 0; }
.wiki-content blockquote p { margin-bottom: 0; color: var(--lexa-gray-600, #475569); }
.wiki-content code { background: var(--lexa-gray-100, #F1F5F9); padding: 0.15rem 0.4rem; border-radius: 0.25rem; font-size: 0.85em; }
.wiki-content table { width: 100%; border-collapse: collapse; margin-bottom: 1rem; font-size: 0.9rem; }
.wiki-content th { background: var(--lexa-gray-100, #F1F5F9); font-weight: 600; text-align: left; padding: 0.5rem 0.75rem; border: 1px solid var(--lexa-border-color, #E2E8F0); }
.wiki-content td { padding: 0.5rem 0.75rem; border: 1px solid var(--lexa-border-color, #E2E8F0); }
.wiki-content a { color: var(--lexa-primary, #6D28D9); }
.wiki-content hr { border: 0; border-top: 1px solid var(--lexa-border-color, #E2E8F0); margin: 2rem 0; }
.wiki-content strong { color: var(--lexa-gray-900, #0F172A); }
.wiki-content img { max-width: 100%; border-radius: 0.5rem; margin: 1rem 0; }

.wiki-footer {
  margin-top: 3rem;
  padding-top: 1rem;
  border-top: 1px solid var(--lexa-border-color, #E2E8F0);
}

/* --- Wiki Search --- */
.wiki-search-wrapper { max-width: 280px; width: 100%; }
.wiki-search-input {
  padding-left: 2rem;
  border-radius: 8px;
  border: 1px solid var(--lexa-gray-200, #E2E8F0);
  font-size: 0.85rem;
  background: var(--lexa-gray-50, #F8FAFC);
}
.wiki-search-input:focus {
  background: #fff;
  border-color: var(--lexa-primary, #6D28D9);
  box-shadow: 0 0 0 3px rgba(109, 40, 217, 0.1);
}
.wiki-search-icon {
  position: absolute;
  left: 0.6rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.8rem;
  color: var(--lexa-gray-400, #94A3B8);
  pointer-events: none;
  z-index: 2;
}
.wiki-search-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid var(--lexa-gray-200, #E2E8F0);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.1);
  z-index: 1000;
  margin-top: 4px;
  max-height: 360px;
  overflow-y: auto;
}
.wiki-search-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 0.85rem;
  text-decoration: none;
  color: var(--lexa-gray-800, #1E293B);
  border-bottom: 1px solid var(--lexa-gray-100, #F1F5F9);
  transition: background 0.15s;
}
.wiki-search-item:last-child { border-bottom: none; }
.wiki-search-item:hover { background: var(--lexa-primary-50, #F5F3FF); color: var(--lexa-primary, #6D28D9); }
.wiki-search-item-title { font-size: 0.875rem; font-weight: 500; }
.wiki-search-item-section {
  font-size: 0.7rem;
  color: var(--lexa-gray-400, #94A3B8);
  background: var(--lexa-gray-100, #F1F5F9);
  padding: 0.1rem 0.5rem;
  border-radius: 4px;
  flex-shrink: 0;
  margin-left: 0.5rem;
}
.wiki-search-empty {
  padding: 1rem;
  text-align: center;
  color: var(--lexa-gray-400, #94A3B8);
  font-size: 0.85rem;
}

@media (max-width: 767.98px) {
  .wiki-search-wrapper { max-width: 180px; }
}

/* Sidebar help link in main app */
.sidebar-help-link {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1rem;
  color: var(--lexa-gray-400, #94A3B8);
  text-decoration: none;
  font-size: 0.8rem;
  border-top: 1px solid rgba(255,255,255,0.1);
  margin-top: auto;
}
.sidebar-help-link:hover { color: var(--lexa-white, #fff); }
.sidebar-collapsed .sidebar-help-link span { display: none; }
.sidebar-collapsed .sidebar-help-link { justify-content: center; }

@media (max-width: 991.98px) {
  .wiki-main { padding: 1rem; }
  .wiki-content h1 { font-size: 1.4rem; }
  .wiki-content h2 { font-size: 1.15rem; }
}
@media (max-width: 575.98px) {
  .wiki-main { padding: 0.75rem; }
  .wiki-topnav { padding: 0.5rem 1rem; }
}

/* --------------------------------------------------------------------------
   NOTIFICATION CENTER
   -------------------------------------------------------------------------- */
.notification-dropdown { width: 360px; max-height: 420px; overflow: hidden; }
.notification-list { overflow-y: auto; max-height: 360px; }
.notification-item { padding: 0.75rem 1rem; border-bottom: 1px solid var(--lexa-border-color, #E2E8F0); cursor: pointer; transition: background var(--lexa-transition-fast, 150ms); }
.notification-item.unread { background: var(--lexa-primary-50, #F5F3FF); }
.notification-item:hover { background: var(--lexa-gray-50, #F8FAFC); }
.notification-item:last-child { border-bottom: none; }
.notif-time { font-size: 0.7rem; color: var(--lexa-gray-400, #94A3B8); margin-top: 2px; }
#notifBadge { font-size: 0.6rem; padding: 0.2em 0.45em; }

/* Payment method surcharge input */
.surcharge-input {
    width: 80px;
    display: inline-block;
}

/* Dashboard KPI card border-left accent */
.dash-card.border-accent-primary { border-left: 4px solid var(--bs-primary); }
.dash-card.border-accent-success { border-left: 4px solid var(--bs-success); }
.dash-card.border-accent-danger { border-left: 4px solid var(--bs-danger); }
.dash-card.border-accent-warning { border-left: 4px solid var(--bs-warning); }
.dash-card.border-accent-info { border-left: 4px solid var(--bs-info); }
.dash-card.border-accent-secondary { border-left: 4px solid var(--bs-secondary); }

/* Therapist dashboard side column */
.therapist-dashboard-side {
  min-width: 0;
}

.therapist-pending-notes-card .card-body {
  max-height: clamp(260px, 42vh, 520px);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.therapist-pending-notes-list .list-group-item {
  min-width: 0;
}

.therapist-pending-notes-list .min-w-0 {
  min-width: 0;
}

@media (max-width: 991.98px) {
  .therapist-pending-notes-card .card-body {
    max-height: 360px;
  }
}

@media (max-width: 576px) {
  .therapist-pending-notes-card .card-body {
    max-height: 300px;
  }
}

/* Compact inline filter bar */
.filter-date-input { width: 140px; }
.filter-search-input { width: 150px; }
.filter-select-auto { width: auto; }

/* Patient search dropdown (appointment modal) */
.patient-search-dropdown {
    z-index: 1000;
    max-height: 200px;
    overflow-y: auto;
    left: 12px;
    right: 12px;
}

/* ==========================================================================
   LEXA MOTION — Subtle Professional Animations
   Design tokens: 150-300ms, ease-out enter, ease-in exit, transform/opacity only
   ========================================================================== */

/* ── 1. Fade-in content on page load ── */
.lexa-fade-in {
    animation: lexaFadeIn 200ms ease-out both;
}

@keyframes lexaFadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Stagger support: add .lexa-stagger on parent, children get sequential delay */
.lexa-stagger > .lexa-fade-in:nth-child(1) { animation-delay: 0ms; }
.lexa-stagger > .lexa-fade-in:nth-child(2) { animation-delay: 30ms; }
.lexa-stagger > .lexa-fade-in:nth-child(3) { animation-delay: 60ms; }
.lexa-stagger > .lexa-fade-in:nth-child(4) { animation-delay: 90ms; }
.lexa-stagger > .lexa-fade-in:nth-child(5) { animation-delay: 120ms; }
.lexa-stagger > .lexa-fade-in:nth-child(n+6) { animation-delay: 150ms; }

/* ── 2. Card hover — lift + shadow ── */
.dash-card,
.card {
    transition: transform 200ms ease-out, box-shadow 200ms ease-out;
}

.dash-card:hover,
.card.lexa-hover:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

/* ── 3. Table row hover — smooth highlight ── */
.table-hover tbody tr {
    transition: background-color 150ms ease;
}

.lexa-patient-plan-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    max-width: min(100%, 15rem);
    padding: 0.4rem 0.65rem;
    border-radius: 999px;
    background: rgba(111, 66, 193, 0.12);
    color: #6f42c1;
    font-weight: 600;
    line-height: 1;
}

.lexa-patient-plan-badge i {
    flex: 0 0 auto;
    font-size: 0.8rem;
}

.lexa-patient-plan-badge-text {
    display: inline-block;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.lexa-patient-plan-badge-muted {
    background: #f3f4f6;
    color: #6b7280;
}

.lexa-patient-plan-badge-eval {
    background: rgba(245, 158, 11, 0.16);
    color: #b45309;
}

/* ── 4. Modal entrance — scale + fade ── */
.modal.fade .modal-dialog {
    transition: transform 200ms ease-out, opacity 200ms ease-out;
    transform: scale(0.95);
}

.modal.show .modal-dialog {
    transform: scale(1);
}

/* ── 5. Sidebar menu — hover indicator ── */
.lexa-sidebar .nav-link {
    transition: background-color 150ms ease, padding-left 150ms ease, border-left-color 150ms ease;
}

/* ── 6. Toast notifications — slide-in/out ── */
.toast-notification {
    animation: lexaToastIn 250ms ease-out both;
}

@keyframes lexaToastIn {
    from { opacity: 0; transform: translateY(-16px); }
    to   { opacity: 1; transform: translateY(0); }
}

.toast-hiding {
    animation: lexaToastOut 150ms ease-in both;
}

@keyframes lexaToastOut {
    from { opacity: 1; transform: translateY(0); }
    to   { opacity: 0; transform: translateY(-16px); }
}

/* ── 7. Button press — micro-scale feedback ── */
.btn:active:not(:disabled) {
    transform: scale(0.97);
    transition: transform 100ms ease;
}

/* ── 8. KPI value highlight pulse (for dynamic updates) ── */
@keyframes lexaValuePulse {
    0%   { background-color: transparent; }
    30%  { background-color: rgba(99, 102, 241, 0.06); }
    100% { background-color: transparent; }
}

.lexa-value-pulse {
    animation: lexaValuePulse 400ms ease-out;
}

/* ── 9. Collapse/accordion smooth (reinforce Bootstrap) ── */
.collapsing {
    transition: height 200ms ease;
}

/* ── 10. Focus ring animation ── */
.btn:focus-visible,
.form-control:focus,
.form-select:focus {
    transition: box-shadow 150ms ease;
}

/* ── 11. Badge/status dot pulse (for live indicators) ── */
@keyframes lexaPulse {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.5; }
}

.lexa-pulse {
    animation: lexaPulse 2s ease-in-out infinite;
}

/* ── REDUCED MOTION — Respect user preference ── */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ==========================================================================
   DARK MODE — Semantic Token Overrides
   v4.0 — Graphite / Near-Black, premium B2B SaaS

   Design principles:
   - Graphite neutral foundation, ZERO blue tint
   - Sidebar uses hardcoded graphite hex (immune to variable mapping)
   - Semantic colors only for status, not structural backgrounds
   - Purple brand accent only on primary actions and active states
   - Surface hierarchy: bg-app → bg-page → surface-card → surface-overlay
   ========================================================================== */

/* ── 1. Foundation ── */
[data-theme="dark"] body { background-color: var(--lexa-surface-base); color: var(--lexa-text-secondary); }
[data-theme="dark"] main { background: var(--lexa-surface-base); }
[data-theme="dark"] .lexa-main { background: var(--lexa-surface-base); }

/* ── 2. Sidebar (hardcoded graphite — immune to variable mapping) ── */
[data-theme="dark"] .lexa-sidebar { background: #09090B; color: #A0A0A8; }
[data-theme="dark"] .lexa-sidebar-header { border-color: #1E1E22; }
[data-theme="dark"] .lexa-sidebar-brand { color: #EDEDEF; }
[data-theme="dark"] .lexa-sidebar-collapse-btn { color: #6B6B74; }
[data-theme="dark"] .lexa-sidebar-section { color: #4E4E56; }
[data-theme="dark"] .lexa-sidebar-divider { border-color: #1E1E22; }
[data-theme="dark"] .lexa-sidebar-arrow { color: #4E4E56; }
[data-theme="dark"] .lexa-sidebar-link { color: #A0A0A8; }
[data-theme="dark"] .lexa-sidebar-link > i:first-child { color: #6B6B74; }
[data-theme="dark"] .lexa-sidebar-link:hover { background: rgba(255,255,255,0.04); color: #D4D4D8; }
[data-theme="dark"] .lexa-sidebar-link:hover > i:first-child { color: #A0A0A8; }
[data-theme="dark"] .lexa-sidebar-link.active { background: rgba(139,92,246,0.1); color: #EDEDEF; border-left-color: #8B5CF6; }
[data-theme="dark"] .lexa-sidebar-link.active > i:first-child { color: #A78BFA; }
[data-theme="dark"] .lexa-sidebar-submenu a { color: #6B6B74; }
[data-theme="dark"] .lexa-sidebar-submenu a:hover { background: rgba(255,255,255,0.03); color: #A0A0A8; }
[data-theme="dark"] .lexa-sidebar-submenu a.active { color: #EDEDEF; background: rgba(139,92,246,0.08); }

/* ── 3. Topbar ── */
[data-theme="dark"] .lexa-topbar { background: var(--lexa-surface-raised); border-color: var(--lexa-border-default); }
[data-theme="dark"] .lexa-topbar .nav-link { color: var(--lexa-text-tertiary); }
[data-theme="dark"] .lexa-topbar .nav-link:hover { color: #C4B5FD; }
[data-theme="dark"] .lexa-topbar-search input { background: var(--lexa-surface-sunken); color: var(--lexa-text-secondary); }
[data-theme="dark"] .lexa-topbar-search input:focus { background: var(--lexa-surface-base); }
[data-theme="dark"] .lexa-search-results { background: var(--lexa-surface-overlay); border-color: var(--lexa-border-default); }
[data-theme="dark"] .lexa-search-item:hover { background: var(--lexa-surface-hover); }
[data-theme="dark"] .lexa-search-overlay { background: rgba(0,0,0,0.7); }
[data-theme="dark"] .lexa-search-input { background: var(--lexa-surface-raised); color: var(--lexa-text-secondary); border-color: var(--lexa-border-default); }

/* ── 4. Cards & Panels ── */
[data-theme="dark"] .card { background: var(--lexa-surface-raised); border-color: var(--lexa-border-default); color: var(--lexa-text-secondary); }
[data-theme="dark"] .card-header { background: var(--lexa-surface-overlay); border-color: var(--lexa-border-default); }
[data-theme="dark"] .dash-card { background: var(--lexa-surface-raised); border-color: var(--lexa-border-default); }
[data-theme="dark"] .kpi-card { background: var(--lexa-surface-raised); }
[data-theme="dark"] .stat-card { background: var(--lexa-surface-overlay); }
[data-theme="dark"] .stat-card .stat-number { color: var(--lexa-text-primary); }

/* ── 5. Tables ── */
[data-theme="dark"] .table { color: var(--lexa-text-secondary); --bs-table-bg: transparent; }
[data-theme="dark"] .table-light { --bs-table-bg: var(--lexa-surface-overlay); --bs-table-color: var(--lexa-text-tertiary); background: var(--lexa-surface-overlay) !important; color: var(--lexa-text-tertiary); }
[data-theme="dark"] .table thead { background: var(--lexa-surface-overlay) !important; color: var(--lexa-text-tertiary); }
[data-theme="dark"] .table-hover tbody tr:hover { background: var(--lexa-surface-hover); }
[data-theme="dark"] .table td,
[data-theme="dark"] .table th { border-color: var(--lexa-border-default); }
[data-theme="dark"] .lexa-patient-plan-badge { background: rgba(167, 139, 250, 0.16); color: #d8b4fe; }
[data-theme="dark"] .lexa-patient-plan-badge-muted { background: rgba(148, 163, 184, 0.14); color: #cbd5e1; }
[data-theme="dark"] .lexa-patient-plan-badge-eval { background: rgba(245, 158, 11, 0.18); color: #fbbf24; }

/* Table contextual rows — navy tint + colored left border, NO brown/orange bg */
[data-theme="dark"] .table-warning { --bs-table-bg: var(--lexa-state-warning-bg); --bs-table-color: var(--lexa-state-warning-text); background-color: var(--lexa-state-warning-bg); color: var(--lexa-state-warning-text); }
[data-theme="dark"] .table-warning td,
[data-theme="dark"] .table-warning th { background-color: var(--lexa-state-warning-bg) !important; color: var(--lexa-state-warning-text) !important; border-left: 3px solid #FBBF24; }
[data-theme="dark"] .table-info { --bs-table-bg: var(--lexa-state-info-bg); --bs-table-color: var(--lexa-state-info-text); background-color: var(--lexa-state-info-bg); color: var(--lexa-state-info-text); }
[data-theme="dark"] .table-info td,
[data-theme="dark"] .table-info th { background-color: var(--lexa-state-info-bg) !important; color: var(--lexa-state-info-text) !important; border-left: 3px solid #60A5FA; }

/* ── 6. Forms ── */
[data-theme="dark"] .form-control,
[data-theme="dark"] .form-select { background-color: var(--lexa-surface-sunken); border-color: var(--lexa-border-default); color: var(--lexa-text-secondary); }
[data-theme="dark"] .form-control:focus,
[data-theme="dark"] .form-select:focus { background-color: var(--lexa-surface-base); border-color: var(--lexa-primary); color: var(--lexa-text-primary); }
[data-theme="dark"] .form-control::placeholder { color: var(--lexa-text-disabled); }
[data-theme="dark"] .form-label { color: var(--lexa-text-secondary); }
[data-theme="dark"] .form-text { color: var(--lexa-text-tertiary); }
[data-theme="dark"] .form-check-input { background-color: var(--lexa-surface-sunken); border-color: var(--lexa-border-strong); }
[data-theme="dark"] .form-check-input:checked { background-color: var(--lexa-primary); border-color: var(--lexa-primary); }
[data-theme="dark"] .input-group-text { background-color: var(--lexa-surface-overlay); border-color: var(--lexa-border-default); color: var(--lexa-text-tertiary); }

/* ── 7. Modals ── */
[data-theme="dark"] .modal-content { background: var(--lexa-surface-raised); color: var(--lexa-text-secondary); }
[data-theme="dark"] .modal-header { border-color: var(--lexa-border-default); }
[data-theme="dark"] .modal-footer { border-color: var(--lexa-border-default); }
[data-theme="dark"] .btn-close { filter: invert(1); }

/* ── 8. Dropdowns & Context Menu ── */
[data-theme="dark"] .dropdown-menu { background: var(--lexa-surface-overlay); border-color: var(--lexa-border-default); }
[data-theme="dark"] .dropdown-item { color: var(--lexa-text-secondary); }
[data-theme="dark"] .dropdown-item:hover { background: var(--lexa-surface-hover); color: var(--lexa-text-primary); }
[data-theme="dark"] .dropdown-divider { border-color: var(--lexa-border-default); }
[data-theme="dark"] .context-menu { background: var(--lexa-surface-overlay); border-color: var(--lexa-border-default); box-shadow: var(--lexa-shadow-lg); }
[data-theme="dark"] .context-menu-item { color: var(--lexa-text-secondary); }
[data-theme="dark"] .context-menu-item:hover { background-color: var(--lexa-surface-hover); }
[data-theme="dark"] .context-menu-item.text-danger:hover { background-color: var(--lexa-state-danger-bg); color: var(--lexa-state-danger-text); }

/* ── 9. Alerts — navy bg + colored text + left border accent ── */
[data-theme="dark"] .alert { border-color: var(--lexa-border-default); }
[data-theme="dark"] .alert-warning { background-color: var(--lexa-state-warning-bg); color: var(--lexa-state-warning-text); border-left: 3px solid #FBBF24; }
[data-theme="dark"] .alert-danger { background-color: var(--lexa-state-danger-bg); color: var(--lexa-state-danger-text); border-left: 3px solid #F87171; }
[data-theme="dark"] .alert-info { background-color: var(--lexa-state-info-bg); color: var(--lexa-state-info-text); border-left: 3px solid #60A5FA; }
[data-theme="dark"] .alert-success { background-color: var(--lexa-state-success-bg); color: var(--lexa-state-success-text); border-left: 3px solid #4ADE80; }
[data-theme="dark"] .alert-secondary { background-color: var(--lexa-state-neutral-bg); color: var(--lexa-state-neutral-text); border-left: 3px solid #8B9DB8; }

/* ── 10. Appointment status badges — subdued semantic pill badges ── */
[data-theme="dark"] .status-scheduled { background: rgba(160,160,168,0.1); color: #A0A0A8; border: 1px solid rgba(160,160,168,0.15); }
[data-theme="dark"] .status-confirmed { background: rgba(59,130,246,0.1); color: #60A5FA; border: 1px solid rgba(59,130,246,0.2); }
[data-theme="dark"] .status-rescheduled { background: rgba(249,115,22,0.1); color: #FB923C; border: 1px solid rgba(249,115,22,0.2); }
[data-theme="dark"] .status-inprogress { background: rgba(6,182,212,0.1); color: #22D3EE; border: 1px solid rgba(6,182,212,0.2); }
[data-theme="dark"] .status-completed { background: rgba(34,197,94,0.1); color: #4ADE80; border: 1px solid rgba(34,197,94,0.2); }
[data-theme="dark"] .status-cancelled { background: rgba(239,68,68,0.08); color: #F87171; border: 1px solid rgba(239,68,68,0.15); }
[data-theme="dark"] .status-noshow { background: rgba(160,160,168,0.08); color: #6B6B74; border: 1px solid rgba(160,160,168,0.12); }

/* Badge detail variants */
[data-theme="dark"] .badge-detail-scheduled { background: rgba(160,160,168,0.1); color: #A0A0A8; }
[data-theme="dark"] .badge-detail-confirmed { background: rgba(59,130,246,0.1); color: #60A5FA; }
[data-theme="dark"] .badge-detail-rescheduled { background: rgba(249,115,22,0.1); color: #FB923C; }
[data-theme="dark"] .badge-plan { background: rgba(168,85,247,0.15); color: #C084FC; }
[data-theme="dark"] .badge-plan-recovery { background: rgba(239,68,68,0.15); color: #FCA5A5; }
[data-theme="dark"] .badge-detail-inprogress { background: rgba(6,182,212,0.1); color: #22D3EE; }
[data-theme="dark"] .badge-detail-attended { background: rgba(34,197,94,0.1); color: #4ADE80; }
[data-theme="dark"] .badge-detail-cancelled { background: rgba(239,68,68,0.08); color: #F87171; }
[data-theme="dark"] .badge-detail-noshow { background: rgba(160,160,168,0.08); color: #6B6B74; }

/* Bootstrap badge combos */
[data-theme="dark"] .badge.bg-warning { background-color: rgba(234,179,8,0.12) !important; color: var(--warning-text) !important; }
[data-theme="dark"] .badge.bg-warning.text-dark { color: var(--warning-text) !important; }
[data-theme="dark"] .badge.bg-info { background-color: rgba(59,130,246,0.12) !important; color: var(--info-text) !important; }
[data-theme="dark"] .badge.bg-info.text-dark { color: var(--info-text) !important; }

/* ── 11. Outline buttons — semantic token colors ── */
[data-theme="dark"] .btn-outline-primary { color: var(--lexa-outline-primary); border-color: var(--lexa-outline-primary); }
[data-theme="dark"] .btn-outline-primary:hover { background: var(--lexa-outline-primary); color: var(--lexa-text-inverse); border-color: var(--lexa-outline-primary); }
[data-theme="dark"] .btn-outline-success { color: var(--lexa-outline-success); border-color: var(--lexa-outline-success); }
[data-theme="dark"] .btn-outline-success:hover { background: var(--lexa-outline-success); color: var(--lexa-text-inverse); border-color: var(--lexa-outline-success); }
[data-theme="dark"] .btn-outline-danger { color: var(--lexa-outline-danger); border-color: var(--lexa-outline-danger); }
[data-theme="dark"] .btn-outline-danger:hover { background: var(--lexa-outline-danger); color: var(--lexa-text-inverse); border-color: var(--lexa-outline-danger); }
[data-theme="dark"] .btn-outline-warning { color: var(--lexa-outline-warning); border-color: var(--lexa-outline-warning); }
[data-theme="dark"] .btn-outline-warning:hover { background: var(--lexa-outline-warning); color: var(--lexa-text-inverse); border-color: var(--lexa-outline-warning); }
[data-theme="dark"] .btn-outline-info { color: var(--lexa-outline-info); border-color: var(--lexa-outline-info); }
[data-theme="dark"] .btn-outline-info:hover { background: var(--lexa-outline-info); color: var(--lexa-text-inverse); border-color: var(--lexa-outline-info); }
[data-theme="dark"] .btn-outline-secondary { color: var(--lexa-outline-secondary); border-color: var(--lexa-border-strong); }
[data-theme="dark"] .btn-outline-secondary:hover { background: var(--lexa-surface-hover); color: var(--lexa-text-primary); }

/* ── 12. Agenda ── */
[data-theme="dark"] .agenda-grid { background: var(--lexa-surface-base); }
[data-theme="dark"] .agenda-grid-wrapper { background: var(--lexa-surface-base); border-color: var(--lexa-border-default); }
[data-theme="dark"] .agenda-grid-container { background: var(--lexa-surface-base); }
[data-theme="dark"] .agenda-time-cell { background: var(--lexa-surface-raised); color: var(--lexa-text-secondary); border-color: var(--lexa-border-default); }
[data-theme="dark"] .agenda-time-cell.agenda-time-hour { border-top-color: var(--lexa-border-strong); }
[data-theme="dark"] .agenda-time-cell.agenda-time-sub { border-top-color: var(--lexa-border-default); }
[data-theme="dark"] .agenda-time-header { background: var(--lexa-surface-raised); border-color: var(--lexa-border-default); color: var(--lexa-text-primary); }
[data-theme="dark"] .agenda-therapist-header { background: var(--lexa-surface-raised); color: var(--lexa-text-secondary); }
[data-theme="dark"] .agenda-therapist-header .therapist-name { color: var(--lexa-text-primary); }
[data-theme="dark"] .agenda-toolbar { background: var(--lexa-surface-raised); border-color: var(--lexa-border-default); box-shadow: 0 1px 0 rgba(255,255,255,0.03); }
[data-theme="dark"] .agenda-toolbar .form-select,
[data-theme="dark"] .agenda-toolbar .form-control,
[data-theme="dark"] .agenda-toolbar .btn-outline-secondary { background-color: var(--lexa-surface-sunken); color: var(--lexa-text-primary); border-color: var(--lexa-border-strong); }
[data-theme="dark"] .agenda-toolbar .btn-outline-secondary:hover { background-color: var(--lexa-surface-hover); border-color: var(--lexa-primary); }
[data-theme="dark"] .agenda-info-row { color: var(--lexa-text-secondary); }
[data-theme="dark"] .agenda-slot { border-color: var(--lexa-border-default); background: var(--lexa-surface-base); }
[data-theme="dark"] .agenda-slot:hover { background-color: var(--lexa-surface-hover); }
[data-theme="dark"] .agenda-slot.slot-hour-boundary { border-top-color: var(--lexa-border-strong); }
[data-theme="dark"] .agenda-slot.slot-outside-hours,
[data-theme="dark"] .agenda-slot.slot-outside-hours:hover { background-color: var(--lexa-surface-sunken); background-image: repeating-linear-gradient(-45deg, transparent, transparent 10px, rgba(255,255,255,0.02) 10px, rgba(255,255,255,0.02) 20px); }
[data-theme="dark"] .agenda-slot.slot-holiday-blocked,
[data-theme="dark"] .agenda-slot.slot-holiday-blocked:hover { background-color: var(--lexa-state-danger-bg); background-image: repeating-linear-gradient(-45deg, transparent, transparent 10px, rgba(248,113,113,0.05) 10px, rgba(248,113,113,0.05) 20px); }
[data-theme="dark"] .agenda-slot-week { background: var(--lexa-surface-base); border-color: var(--lexa-border-default); }
[data-theme="dark"] .agenda-slot-week:hover { background: var(--lexa-surface-hover); }
[data-theme="dark"] .agenda-slot-week[class*="branch-tone-"] { background-color: var(--branch-slot-bg-dark); }
[data-theme="dark"] .agenda-slot-week.branch-mixed {
  background: repeating-linear-gradient(135deg, #141821, #141821 8px, #1a2030 8px, #1a2030 16px);
}
[data-theme="dark"] .agenda-slot-week[class*="branch-tone-"]:hover,
[data-theme="dark"] .agenda-slot-week.branch-mixed:hover { box-shadow: inset 0 0 0 100px rgba(255,255,255,0.04); }
[data-theme="dark"] .agenda-slot-week.slot-blocked { background-color: var(--lexa-surface-sunken); }
[data-theme="dark"] .agenda-slot-week.slot-holiday-blocked { background: var(--lexa-state-danger-bg); }
[data-theme="dark"] .agenda-slot-week.slot-outside-hours.drag-over { background-color: var(--lexa-surface-sunken) !important; }
[data-theme="dark"] .agenda-day-header { background: var(--lexa-surface-raised); color: var(--lexa-text-primary); border-color: var(--lexa-border-default); }
[data-theme="dark"] .agenda-day-header.today { background: #221a35; border-bottom-color: var(--lexa-primary); }
[data-theme="dark"] .agenda-day-header .text-muted { color: var(--lexa-text-secondary) !important; }
[data-theme="dark"] .agenda-day-header.holiday-header { background: var(--lexa-state-danger-bg); }
[data-theme="dark"] .agenda-holiday-name { color: var(--lexa-state-danger-text) !important; }
[data-theme="dark"] .agenda-week-grid-container { background: var(--lexa-surface-base); }
[data-theme="dark"] .agenda-day-column { border-color: var(--lexa-border-default); }
[data-theme="dark"] .agenda-holiday-banner { background: var(--lexa-state-warning-bg); color: var(--lexa-state-warning-text); }

[data-theme="dark"] .appointment-card.appointment-conflict {
  border-color: #fbbf24 !important;
  box-shadow: inset 3px 0 0 #fbbf24, 0 2px 8px rgba(251, 191, 36, 0.14);
}

[data-theme="dark"] .appt-indicators .ind-conflict { color: #fbbf24; }
[data-theme="dark"] .schedule-conflicts-kpi { background: var(--lexa-surface); border-color: var(--lexa-border); }
[data-theme="dark"] .schedule-conflicts-kpi .label { color: var(--lexa-text-muted); }
[data-theme="dark"] .schedule-conflicts-kpi strong { color: var(--lexa-text-primary); }
[data-theme="dark"] .appointment-card { box-shadow: 0 1px 4px rgba(0,0,0,0.4); color: var(--lexa-text-primary); }
[data-theme="dark"] .appointment-card[class*="branch-tone-"] { box-shadow: inset 0 3px 0 var(--branch-accent), 0 1px 4px rgba(0,0,0,0.45); }
[data-theme="dark"] .appointment-card:hover { box-shadow: 0 2px 10px rgba(0,0,0,0.55); }
[data-theme="dark"] .appointment-card[class*="branch-tone-"]:hover { box-shadow: inset 0 3px 0 var(--branch-accent), 0 2px 10px rgba(0,0,0,0.55); }
[data-theme="dark"] .appointment-card .patient-name { color: var(--lexa-text-primary); }
[data-theme="dark"] .appointment-card .service-name { color: var(--lexa-text-secondary); opacity: 1; }
[data-theme="dark"] .appointment-card .appt-meta { color: var(--lexa-text-tertiary); opacity: 1; }
[data-theme="dark"] .first-visit-chip { background: rgba(14, 165, 233, 0.18); color: #bae6fd; border-color: rgba(125, 211, 252, 0.45); }
[data-theme="dark"] .appointment-card.status-scheduled { background: #2a2f3a; color: #e2e8f0; border: 1px solid #475569; border-left: 4px solid #94a3b8; }
[data-theme="dark"] .appointment-card.status-confirmed { background: #102b22; color: #d1fae5; border: 1px solid #176b50; border-left: 4px solid #34d399; }
[data-theme="dark"] .appointment-card.status-rescheduled { background: #33210d; color: #ffedd5; border: 1px solid #9a5a16; border-left: 4px solid #fb923c; }
[data-theme="dark"] .appointment-card.status-inprogress { background: #0e2d36; color: #cffafe; border: 1px solid #117086; border-left: 4px solid #22d3ee; }
[data-theme="dark"] .appointment-card.status-completed { background: #102846; color: #dbeafe; border: 1px solid #1d4f8f; border-left: 4px solid #60a5fa; }
[data-theme="dark"] .appointment-card.status-cancelled { background: #3b1518; color: #fee2e2; border: 1px solid #8f2c34; border-left: 4px solid #f87171; }
[data-theme="dark"] .appointment-card.status-noshow { background: #25272d; color: #d1d5db; border: 1px solid #4b5563; border-left: 4px solid #9ca3af; }
[data-theme="dark"] .branch-legend { color: var(--lexa-text-secondary); }
[data-theme="dark"] .branch-legend-swatch { border-color: rgba(255,255,255,0.24); }
[data-theme="dark"] .therapist-block-card { background: repeating-linear-gradient(45deg, #161618, #161618 5px, #1A1A1D 5px, #1A1A1D 10px); color: var(--text-muted); }
[data-theme="dark"] .load-more-col { background: var(--lexa-surface-raised); border-color: var(--lexa-border-default); }

/* ── 13. Detail modal ── */
[data-theme="dark"] .detail-summary-card { background: var(--lexa-surface-overlay); }
[data-theme="dark"] .detail-patient-section { border-color: var(--lexa-border-default); }
[data-theme="dark"] .detail-header { border-color: var(--lexa-border-default); }
[data-theme="dark"] .detail-footer { border-color: var(--lexa-border-default); background: var(--lexa-surface-raised); }
[data-theme="dark"] .detail-body { color: var(--lexa-text-secondary); }
[data-theme="dark"] .detail-notes { background: var(--lexa-state-warning-bg); border-left: 3px solid #FBBF24; color: var(--lexa-state-warning-text); }

/* ── 14. Patient chart ── */
[data-theme="dark"] .chart-header { background: linear-gradient(135deg, var(--lexa-surface-raised) 0%, var(--lexa-surface-overlay) 100%); }
[data-theme="dark"] .chart-header .patient-meta { color: var(--lexa-text-tertiary); }
[data-theme="dark"] .chart-header-badge { background: rgba(139, 92, 246, 0.14); color: #ddd6fe; }
[data-theme="dark"] .chart-header-badge-label { color: var(--lexa-text-tertiary); }
[data-theme="dark"] .info-section h6 { color: var(--lexa-text-tertiary); border-bottom-color: var(--lexa-border-default); }

/* ── 15. Filter bars ── */
[data-theme="dark"] .lexa-filter-bar { background: var(--lexa-surface-raised); border-color: var(--lexa-border-default); }
[data-theme="dark"] .lexa-dr-dropdown { background: var(--lexa-surface-raised); border-color: var(--lexa-border-default); }
[data-theme="dark"] .lexa-dr-presets { border-color: var(--lexa-border-default); }
[data-theme="dark"] .lexa-dr-preset { color: var(--lexa-text-secondary); }
[data-theme="dark"] .lexa-dr-preset:hover { background: var(--lexa-surface-hover); }
[data-theme="dark"] .lexa-dr-preset.active { background: rgba(59,130,246,0.12); color: #60A5FA; }
[data-theme="dark"] .lexa-dr-day { color: var(--lexa-text-primary); }
[data-theme="dark"] .lexa-dr-day:hover:not(.other) { background: var(--lexa-surface-hover); }
[data-theme="dark"] .lexa-dr-day.other { color: var(--lexa-text-muted); }
[data-theme="dark"] .lexa-dr-day.in-range { background: rgba(59,130,246,0.12); }
[data-theme="dark"] .lexa-dr-footer { border-color: var(--lexa-border-default); color: var(--lexa-text-secondary); }
[data-theme="dark"] .lexa-dr-month-sel, [data-theme="dark"] .lexa-dr-year-sel { color: var(--lexa-text-primary); }
[data-theme="dark"] .lexa-dr-nav { color: var(--lexa-text-secondary); }
[data-theme="dark"] .lexa-dr-nav:hover { background: var(--lexa-surface-hover); }
[data-theme="dark"] .lexa-daterange-toggle { background: var(--lexa-surface-raised); }

/* ── 16. Navigation components ── */
[data-theme="dark"] .breadcrumb { background: transparent; }
[data-theme="dark"] .breadcrumb-item a { color: var(--lexa-text-tertiary); }
/* h2 hidden in module headers — breadcrumbs serve as page title */
[data-theme="dark"] .nav-tabs { border-color: var(--lexa-border-default); }
[data-theme="dark"] .nav-tabs .nav-link { color: var(--lexa-text-tertiary); }
[data-theme="dark"] .nav-tabs .nav-link.active { background: var(--lexa-surface-raised); border-color: var(--lexa-border-default); color: var(--lexa-text-primary); }

/* ── 17. List groups & Notifications ── */
[data-theme="dark"] .list-group-item { background: var(--lexa-surface-raised); border-color: var(--lexa-border-default); color: var(--lexa-text-secondary); }
[data-theme="dark"] .notification-item.unread { background: var(--lexa-primary-50); }
[data-theme="dark"] .notification-item:hover { background: var(--lexa-surface-hover); }

/* ── 18. Pagination ── */
[data-theme="dark"] .page-link { background: var(--lexa-surface-raised); border-color: var(--lexa-border-default); color: var(--lexa-text-secondary); }
[data-theme="dark"] .page-item.active .page-link { background: var(--lexa-primary); border-color: var(--lexa-primary); color: #fff; }

/* ── 19. Popover & Tooltip ── */
[data-theme="dark"] .popover { background: var(--lexa-surface-overlay); border-color: var(--lexa-border-default); }
[data-theme="dark"] .popover-header { background: var(--lexa-surface-hover); border-color: var(--lexa-border-default); color: var(--lexa-text-primary); }
[data-theme="dark"] .popover-body { color: var(--lexa-text-secondary); }
[data-theme="dark"] .tooltip-inner { background: var(--lexa-surface-overlay); color: var(--lexa-text-primary); }

/* ── 20. Accordion ── */
[data-theme="dark"] .accordion-item { background: var(--lexa-surface-raised); border-color: var(--lexa-border-default); }
[data-theme="dark"] .accordion-button { background: var(--lexa-surface-overlay); color: var(--lexa-text-secondary); }
[data-theme="dark"] .accordion-button:not(.collapsed) { background: var(--lexa-primary-light); color: var(--lexa-text-primary); }

/* ── 21. Offcanvas / Drawer ── */
[data-theme="dark"] .offcanvas { background: var(--lexa-surface-raised); color: var(--lexa-text-secondary); }
[data-theme="dark"] .offcanvas-header { border-color: var(--lexa-border-default); }

/* ── 22. Toast ── */
[data-theme="dark"] .toast { background: var(--lexa-surface-overlay); border-color: var(--lexa-border-default); color: var(--lexa-text-secondary); }

/* ── 23. Misc components ── */
[data-theme="dark"] code { background: var(--lexa-surface-overlay); color: #C4B5FD; }
[data-theme="dark"] hr { border-color: var(--lexa-border-default); opacity: 0.5; }
[data-theme="dark"] .progress { background-color: var(--lexa-surface-sunken); }
[data-theme="dark"] .lexa-empty-state i { color: var(--lexa-text-disabled); }
[data-theme="dark"] #dailySummaryModal .table thead th { background: var(--lexa-surface-overlay); }

/* ── 24. Scrollbars ── */
[data-theme="dark"] ::-webkit-scrollbar-track { background: var(--lexa-surface-base); }
[data-theme="dark"] ::-webkit-scrollbar-thumb { background: var(--lexa-border-strong); }

/* ── 25. Bootstrap utility overrides ── */
[data-theme="dark"] .text-muted { color: var(--text-muted, var(--lexa-text-tertiary)) !important; }
[data-theme="dark"] .text-dark { color: var(--text-secondary, var(--lexa-text-secondary)) !important; }
[data-theme="dark"] .bg-light { background-color: var(--surface-panel, var(--lexa-surface-overlay)) !important; }
[data-theme="dark"] .bg-white { background-color: var(--surface-card, var(--lexa-surface-raised)) !important; }
[data-theme="dark"] .border { border-color: var(--border-default, var(--lexa-border-default)) !important; }
[data-theme="dark"] .border-bottom { border-color: var(--border-default, var(--lexa-border-default)) !important; }

/* ── 26. Action Button System (Acciones column) ── */
/* Ghost icon buttons — uniform, compact, grouped */
[data-theme="dark"] .btn-group-sm .btn-outline-primary,
[data-theme="dark"] .btn-group-sm .btn-outline-secondary,
[data-theme="dark"] .btn-group-sm .btn-outline-success,
[data-theme="dark"] .btn-group-sm .btn-outline-danger,
[data-theme="dark"] .btn-group-sm .btn-outline-info {
  background: transparent;
  border-color: var(--border-default);
  color: var(--text-muted);
  width: 34px;
  height: 34px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
/* Unified hover: subtle surface lift */
[data-theme="dark"] .btn-group-sm .btn-outline-secondary:hover,
[data-theme="dark"] .btn-group-sm .btn-outline-info:hover {
  background: var(--surface-row-hover);
  border-color: var(--border-strong);
  color: var(--text-secondary);
}
/* Primary action hover: subtle brand tint */
[data-theme="dark"] .btn-group-sm .btn-outline-primary:hover {
  background: var(--brand-soft);
  border-color: var(--brand-border);
  color: #A78BFA;
}
/* Success action hover (cobrar): subtle green */
[data-theme="dark"] .btn-group-sm .btn-outline-success:hover {
  background: var(--success-bg);
  border-color: var(--success-border);
  color: var(--success-text);
}
/* Danger action hover: subtle red */
[data-theme="dark"] .btn-group-sm .btn-outline-danger:hover {
  background: var(--danger-bg);
  border-color: var(--danger-border);
  color: var(--danger-text);
}
/* Remove double borders between grouped buttons */
[data-theme="dark"] .btn-group-sm > .btn + .btn { margin-left: -1px; }

/* ── 27. KPI cards — refined dark treatment ── */
[data-theme="dark"] .kpi-card {
  background: var(--surface-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
}
[data-theme="dark"] .kpi-card .kpi-value,
[data-theme="dark"] .kpi-card h3 { color: var(--text-primary); }
[data-theme="dark"] .kpi-card .kpi-label,
[data-theme="dark"] .kpi-card .text-muted { color: var(--text-muted) !important; }

/* Danger KPI (Pagos Pendientes) — refined semantic treatment */
[data-theme="dark"] .kpi-card.border-danger,
[data-theme="dark"] .kpi-card[class*="border-danger"] {
  border-color: var(--danger-border) !important;
  background: var(--danger-bg);
}

/* ── 28. Quick action buttons (right panel) ── */
[data-theme="dark"] .btn-outline-primary:not(.btn-group-sm .btn-outline-primary) {
  color: #A78BFA;
  border-color: var(--border-default);
  background: transparent;
}
[data-theme="dark"] .btn-outline-primary:not(.btn-group-sm .btn-outline-primary):hover {
  background: var(--brand-soft);
  border-color: var(--brand-border);
  color: #C4B5FD;
}

/* ── 29. Agenda row indicators (replaces table-warning/table-info backgrounds) ── */
.row-overdue td:first-child { border-left: 3px solid #EF4444; }
.row-inprogress td:first-child { border-left: 3px solid #3B82F6; }
[data-theme="dark"] .row-overdue { background: rgba(239,68,68,0.04); }
[data-theme="dark"] .row-overdue:hover { background: rgba(239,68,68,0.07) !important; }
[data-theme="dark"] .row-inprogress { background: rgba(59,130,246,0.04); }
[data-theme="dark"] .row-inprogress:hover { background: rgba(59,130,246,0.07) !important; }
/* Light mode fallback */
.row-overdue { background: #FEF2F2; }
.row-overdue:hover { background: #FEE2E2 !important; }
.row-inprogress { background: #EFF6FF; }
.row-inprogress:hover { background: #DBEAFE !important; }

/* ── 30. POS Sales — items table → cards en ≤576px (F05) ── */
@media (max-width: 575.98px) {
  #itemsTable { min-width: 0; }
  #itemsTable thead { display: none; }
  #itemsTable, #itemsTable tbody, #itemsTable tbody tr { display: block; width: 100%; }
  #itemsTable tbody tr {
    border: 1px solid var(--border-subtle, #e5e7eb);
    border-radius: 0.5rem;
    padding: 0.6rem 0.75rem;
    margin-bottom: 0.5rem;
    background: var(--surface, #fff);
  }
  #itemsTable tbody td {
    display: block;
    padding: 0.25rem 0;
    border: none;
    text-align: left !important;
  }
  #itemsTable tbody td::before {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted, #6b7280);
    text-transform: uppercase;
    letter-spacing: 0.02em;
    display: block;
    margin-bottom: 0.1rem;
  }
  #itemsTable tbody td:nth-of-type(1)::before { content: "Descripcion"; }
  #itemsTable tbody td:nth-of-type(2)::before { content: "Servicio"; }
  #itemsTable tbody td:nth-of-type(3)::before { content: "Cantidad"; }
  #itemsTable tbody td:nth-of-type(4)::before { content: "Precio unit."; }
  #itemsTable tbody td:nth-of-type(5)::before { content: "Descuento"; }
  #itemsTable tbody td:nth-of-type(6)::before { content: "Total"; }
  #itemsTable tbody td:nth-of-type(6) {
    font-size: 1.05rem;
    padding-top: 0.5rem;
    margin-top: 0.25rem;
    border-top: 1px dashed var(--border-subtle, #e5e7eb);
    text-align: right !important;
  }
  #itemsTable tbody td:nth-of-type(7) {
    text-align: right !important;
    margin-top: 0.25rem;
  }
  #itemsTable tbody td:nth-of-type(7)::before { display: none; }
  #itemsTable tbody td input,
  #itemsTable tbody td .service-search,
  #itemsTable tbody td input[type="number"] {
    width: 100% !important;
  }
}

/* ============================================
   MURAL / NOVEDADES (F054)
   ============================================ */
.mural-post {
    border: 1px solid var(--border-subtle, #e5e7eb);
    transition: box-shadow .15s ease, border-color .15s ease;
}
.mural-post.mural-pinned {
    border-color: #f59e0b;
    box-shadow: 0 0 0 2px rgba(245, 158, 11, .12);
}
.mural-avatar {
    width: 40px; height: 40px; border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--lexa-gray-100, #f3f4f6);
    color: var(--lexa-gray-500, #6b7280);
    font-size: 1.5rem; flex-shrink: 0;
}
.mural-content {
    white-space: pre-wrap;
    word-break: break-word;
    color: var(--lexa-gray-800, #1f2937);
    line-height: 1.5;
}
.mural-attachments {
    display: flex; flex-wrap: wrap; gap: .5rem;
}
.mural-attachment-image img {
    max-width: 180px; max-height: 180px;
    border-radius: .375rem;
    border: 1px solid var(--border-subtle, #e5e7eb);
    object-fit: cover;
}
.mural-attachment-file {
    display: inline-flex; align-items: center; gap: .4rem;
    padding: .4rem .75rem;
    background: var(--lexa-gray-50, #f9fafb);
    border: 1px solid var(--border-subtle, #e5e7eb);
    border-radius: .375rem;
    text-decoration: none;
    color: var(--lexa-gray-800, #1f2937);
    font-size: .85rem;
}
.mural-attachment-file:hover {
    background: var(--lexa-gray-100, #f3f4f6);
}
.mural-reactions {
    display: flex; flex-wrap: wrap; gap: .35rem;
    border-top: 1px solid var(--border-subtle, #e5e7eb);
    padding-top: .5rem;
}
.mural-reaction-btn, .mural-comment-btn {
    display: inline-flex; align-items: center; gap: .25rem;
    padding: .25rem .6rem;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 999px;
    font-size: .85rem;
    color: var(--lexa-gray-700, #374151);
    cursor: pointer;
    transition: background .15s ease, border-color .15s ease;
}
.mural-reaction-btn:hover, .mural-comment-btn:hover {
    background: var(--lexa-gray-100, #f3f4f6);
}
.mural-reaction-btn.active {
    background: rgba(109, 40, 217, .08);
    border-color: rgba(109, 40, 217, .25);
    color: var(--lexa-primary, #6d28d9);
}
.mural-reaction-emoji { font-size: 1rem; line-height: 1; }
.mural-reaction-count, .mural-comment-count { font-weight: 500; }
.mural-comments {
    border-top: 1px dashed var(--border-subtle, #e5e7eb);
    padding-top: .75rem;
}
.mural-comment-row {
    padding: .4rem .5rem;
    border-radius: .375rem;
    background: var(--lexa-gray-50, #f9fafb);
    margin-bottom: .35rem;
}
.mural-comment-author { font-size: .8rem; font-weight: 600; }
.mural-comment-content { font-size: .9rem; white-space: pre-wrap; word-break: break-word; }
.mural-comment-form { margin-top: .5rem; }

/* ============================================
   Unpaid appointments report
   ============================================ */
.unpaid-table .tabular {
    font-variant-numeric: tabular-nums;
}
.unpaid-table .unpaid-patient-row {
    cursor: pointer;
    transition: background-color 150ms ease;
}
.unpaid-table .unpaid-chevron {
    transition: transform 200ms ease;
    display: inline-block;
    color: var(--lexa-gray-500, #6b7280);
}
.unpaid-table .unpaid-patient-row.expanded .unpaid-chevron {
    transform: rotate(90deg);
}
.unpaid-table .unpaid-patient-row.expanded {
    background: var(--lexa-primary-light, rgba(99, 102, 241, .06));
}
.unpaid-subtable {
    background: var(--lexa-gray-50, #f9fafb);
}
.unpaid-subtable .tabular {
    font-variant-numeric: tabular-nums;
}

/* ============================================
   Birthday row hover (Reception dashboard)
   ============================================ */
.birthday-row {
    transition: background-color 120ms ease;
}
.birthday-row:hover {
    background-color: var(--bs-tertiary-bg, #f8f9fa);
}

/* ============================================
   Monthly P&L table (desglose por categoría)
   ============================================ */
.pandl-table {
    font-variant-numeric: tabular-nums;
    min-width: max-content;
}
.pandl-table thead th {
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--bs-table-bg, #fff);
}
.pandl-table .pandl-col-mes,
.pandl-table tbody tr > td:first-child,
.pandl-table tfoot tr > td:first-child {
    position: sticky;
    left: 0;
    background: var(--bs-body-bg, #fff);
    z-index: 1;
    min-width: 140px;
}
.pandl-table thead th.pandl-col-mes {
    z-index: 3;
}
.pandl-table .pandl-col-gastos,
.pandl-table .pandl-sticky-left-2 {
    min-width: 120px;
}
.pandl-table .pandl-sticky-left-2 {
    position: sticky;
    left: 140px;
    background: var(--bs-body-bg, #fff);
    z-index: 1;
    box-shadow: 10px 0 12px -12px rgba(15, 23, 42, 0.45);
}
.pandl-table thead th.pandl-sticky-left-2 {
    background: var(--bs-table-bg, #fff);
    z-index: 3;
}
.pandl-table .pandl-col-ingresos,
.pandl-table .pandl-col-utilidad {
    min-width: 120px;
}
.pandl-table .pandl-col-margen {
    min-width: 88px;
}
@media (min-width: 768px) {
    .pandl-table .pandl-sticky-right {
        position: sticky;
        background: var(--bs-body-bg, #fff);
        z-index: 1;
    }
    .pandl-table thead th.pandl-sticky-right {
        background: var(--bs-table-bg, #fff);
        z-index: 3;
    }
    .pandl-table .pandl-sticky-right-1 {
        right: 0;
    }
    .pandl-table .pandl-sticky-right-2 {
        right: 88px;
    }
    .pandl-table .pandl-sticky-right-3 {
        right: 208px;
        box-shadow: -10px 0 12px -12px rgba(15, 23, 42, 0.45);
    }
}
.pandl-table tr.pandl-year-subtotal > td {
    background: var(--lexa-primary-light, rgba(99, 102, 241, .08));
    border-top: 2px solid var(--bs-border-color, #dee2e6);
    border-bottom: 2px solid var(--bs-border-color, #dee2e6);
}
.pandl-table tr.pandl-year-subtotal > td.pandl-sticky-right {
    background: var(--lexa-primary-light, rgba(99, 102, 241, .08));
}
.pandl-table tr.pandl-year-subtotal > td.pandl-sticky-left-2 {
    background: var(--lexa-primary-light, rgba(99, 102, 241, .08));
}
.pandl-table tfoot td {
    background: var(--bs-table-bg, #f8f9fa);
}
.pandl-table tfoot td.pandl-sticky-right {
    background: var(--bs-table-bg, #f8f9fa);
    z-index: 2;
}
.pandl-table tfoot td.pandl-sticky-left-2 {
    background: var(--bs-table-bg, #f8f9fa);
    z-index: 2;
}

/* Inputs angostos para campos numéricos cortos (sesiones, cantidades, recargos). */
.lexa-input-narrow {
    max-width: 200px;
}

/* Cards informativas dentro de modales/forms para resaltar bloques agrupados.
   Reemplazan inline styles de background usados en _AppointmentForm.cshtml y
   _AppointmentDetail.cshtml / Chart.cshtml. */
.lexa-soft-card {
    background: var(--lexa-gray-50, #f8f9fa);
}
.lexa-soft-card-blue {
    background: var(--lexa-blue-50, #eef4ff);
}

/* Letras tipo "Eyebrow" en pequeño caps + tracking, usado en headers de cards. */
.lexa-eyebrow {
    letter-spacing: .05em;
}

/* ─── Payment modal (Cobrar al cliente) ──────────────────────────────────── */
.lexa-pay-modal .modal-content {
    border: 0;
    border-radius: 14px;
    box-shadow: 0 24px 48px rgba(15, 23, 42, .18);
}
.lexa-pay-header {
    border-bottom: 1px solid var(--lexa-border-color, #E2E8F0);
    align-items: flex-start;
    padding: 1.25rem 1.5rem;
}
.lexa-pay-header-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: var(--lexa-primary-light, #EDE9FE);
    color: var(--lexa-primary, #6D28D9);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    flex-shrink: 0;
}
.lexa-pay-header-subtitle {
    color: var(--lexa-gray-500, #64748B);
    font-size: .875rem;
    margin-top: 2px;
}

.lexa-pay-summary {
    background: var(--lexa-gray-50, #F8FAFC);
    border: 1px solid var(--lexa-border-color, #E2E8F0);
    border-radius: 12px;
    padding: 0.5rem 0.25rem;
}
.lexa-pay-summary .kpi-strip-label {
    display: inline-flex;
    align-items: center;
    gap: .25rem;
}
.lexa-pay-summary .kpi-strip-value {
    font-size: 1.35rem;
}
.lexa-pay-summary-total {
    background: var(--lexa-primary-light, #EDE9FE);
    border-radius: 10px;
    margin: -0.5rem 0;
}
.lexa-pay-summary-total .kpi-strip-value {
    font-size: 1.6rem;
    font-weight: 700;
}
.lexa-pay-info-icon {
    color: var(--lexa-gray-400, #94A3B8);
    cursor: help;
    font-size: .85em;
}

.lexa-pay-section {
    margin-top: 1.75rem;
}
.lexa-pay-section:first-of-type {
    margin-top: 1rem;
}
.lexa-pay-section-title {
    color: var(--lexa-primary, #6D28D9);
    font-weight: 600;
    font-size: .95rem;
    margin-bottom: 1rem;
    padding-bottom: .5rem;
    border-bottom: 1px solid var(--lexa-border-color, #E2E8F0);
    display: flex;
    align-items: baseline;
    gap: .35rem;
}
.lexa-pay-step {
    color: var(--lexa-primary, #6D28D9);
    font-weight: 700;
}
.lexa-pay-optional {
    color: var(--lexa-gray-500, #64748B);
    font-weight: 400;
    font-size: .85em;
}

.lexa-pay-breakdown-card {
    border: 1px dashed var(--lexa-border-color, #E2E8F0);
    border-radius: 10px;
    padding: 1rem;
    margin-bottom: 1rem;
    background: #fff;
}
.lexa-pay-breakdown-card + .lexa-pay-breakdown-card {
    margin-top: 0.5rem;
}
.lexa-pay-breakdown-card .form-label {
    font-size: .85rem;
    color: var(--lexa-gray-600, #475569);
    margin-bottom: .35rem;
}
.lexa-pay-remove-btn {
    line-height: 1;
}

.lexa-pay-add-btn {
    border-style: dashed;
    border-width: 1.5px;
}

.lexa-pay-summary-table thead th {
    background: var(--lexa-gray-50, #F8FAFC);
    color: var(--lexa-gray-600, #475569);
    font-weight: 600;
    font-size: .8rem;
    text-transform: uppercase;
    letter-spacing: .03em;
    border-bottom: 1px solid var(--lexa-border-color, #E2E8F0);
}
.lexa-pay-summary-table tbody td {
    border-bottom: 1px solid var(--lexa-border-color, #E2E8F0);
}
.lexa-pay-summary-method {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    font-weight: 500;
}
.lexa-pay-summary-method-icon {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: var(--lexa-primary-light, #EDE9FE);
    color: var(--lexa-primary, #6D28D9);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: .85rem;
}
.lexa-pay-summary-total-row > td {
    background: var(--lexa-primary-light, #EDE9FE);
    border-top: 2px solid var(--lexa-primary, #6D28D9) !important;
    border-bottom: none !important;
    padding-top: .75rem;
    padding-bottom: .75rem;
}
.lexa-pay-summary-total-row > td:first-child {
    border-top-left-radius: 8px;
}
.lexa-pay-summary-total-row > td:last-child {
    border-top-right-radius: 8px;
}
.lexa-pay-summary-empty td {
    background: #fff;
}
.lexa-pay-summary-action {
    width: 60px;
}

.lexa-pay-footer {
    border-top: 1px solid var(--lexa-border-color, #E2E8F0);
    padding: 1rem 1.5rem;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: .75rem;
}
.lexa-pay-footer-info {
    color: var(--lexa-gray-500, #64748B);
    font-size: .85rem;
}
.lexa-pay-footer-actions {
    display: flex;
    gap: .5rem;
}

@media (max-width: 768px) {
    .lexa-pay-summary {
        padding: 0.5rem;
    }
    .lexa-pay-summary-total {
        margin: 0;
    }
    .lexa-pay-summary-total .kpi-strip-value {
        font-size: 1.35rem;
    }
    .lexa-pay-footer {
        flex-direction: column-reverse;
        align-items: stretch;
    }
    .lexa-pay-footer-actions {
        justify-content: stretch;
    }
    .lexa-pay-footer-actions .btn {
        flex: 1;
    }
}

[data-theme="dark"] .lexa-pay-summary,
[data-theme="dark"] .lexa-pay-summary-table thead th {
    background: var(--lexa-dark-surface-2, #1f2937);
}
[data-theme="dark"] .lexa-pay-breakdown-card {
    background: var(--lexa-dark-surface, #111827);
    border-color: var(--lexa-dark-border, #334155);
}
[data-theme="dark"] .lexa-pay-summary-empty td {
    background: var(--lexa-dark-surface, #111827);
}
[data-theme="dark"] .lexa-pay-summary-total,
[data-theme="dark"] .lexa-pay-summary-total-row > td {
    background: rgba(124, 58, 237, .25);
}
