/* Shared authenticated header. Page templates include app_header.html; pages should not restyle this shell. */
:where(.topbar.app-topbar, .lf-unified-app-header, .lf-topbar) {
  position: relative;
  z-index: 8000;
  width: 100%;
  min-height: var(--lf-topbar-height, 64px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin: 0 0 22px;
  padding: 0;
  border: 0;
  border-bottom: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  overflow: visible;
}
:where(.app-topbar-copy, .topbar-copy) { min-width: 260px; flex: 1 1 420px; display: grid; gap: 8px; }
:where(.app-header-identity) { min-width: 0; display: flex; align-items: center; }
:where(.app-header-text) { min-width: 0; display: grid; gap: 4px; }
:where(.dashboard-welcome-title) { margin: 0; display: inline-flex; align-items: center; gap: 12px; font-size: clamp(28px, 3vw, 42px); line-height: 1.04; letter-spacing: 0; }
:where(.app-topbar .subtitle, .lf-unified-app-header .subtitle) { max-width: 760px; margin: 0; color: var(--muted, #64748b); font-weight: 400; }
:where(.app-header-title-icon) { width: 42px; height: 42px; min-width: 42px; display: inline-flex; align-items: center; justify-content: center; border-radius: 14px; color: #2563eb; background: rgba(37, 99, 235, 0.08); box-shadow: 0 12px 24px rgba(37, 99, 235, 0.12); }
:where(.app-header-title-icon svg) { width: 24px; height: 24px; }
:where(.app-header-title-icon--whatsapp) { color: #16a34a; background: rgba(34, 197, 94, 0.12); box-shadow: 0 12px 24px rgba(22, 163, 74, 0.14); }
:where(.app-header-title-icon--right) { margin-left: 2px; }
:where(.app-header-title-icon--hand.app-header-title-icon--right) { width: auto; height: auto; min-width: 0; border-radius: 0; background: transparent; box-shadow: none; color: inherit; font-size: 0.9em; line-height: 1; transform: translateY(-1px); }
:where(.dashboard-topbar-actions.app-topbar-actions, .app-topbar-actions) { min-width: 0; max-width: 100%; flex: 0 1 auto; display: flex; align-items: center; justify-content: flex-end; gap: 12px; margin-left: auto; flex-wrap: nowrap; }
:where(.dashboard-today-pill) { width: auto; min-width: 0; height: 40px; min-height: 40px; display: inline-grid; grid-auto-flow: column; place-items: center; align-items: center; gap: var(--lf-space-2, 8px); padding: 0 var(--lf-space-3, 12px); border: 1px solid var(--lf-color-border, rgba(148, 163, 184, 0.22)); border-radius: var(--lf-radius-pill, 999px); background: transparent; color: var(--lf-color-text, #0f172a); box-shadow: none; font-size: var(--lf-font-size-sm, 13px); font-weight: 900; white-space: nowrap; }
:where(.dashboard-today-pill svg) { width: 16px; height: 16px; }

/* Header search */
:where(.lf-header-search) { position: relative; z-index: 4; min-width: 44px; height: 44px; display: flex; align-items: center; justify-content: flex-end; }
:where(.lf-header-search-toggle) { position: absolute; inset: 0 auto 0 0; width: 40px; min-width: 40px; height: 40px; min-height: 40px; display: inline-grid; place-items: center; border: 1px solid color-mix(in srgb, var(--primary-color, #2563eb) 24%, transparent); border-radius: 999px; background: var(--primary-light, rgba(37, 99, 235, 0.08)); color: var(--primary-color, #2563eb); cursor: pointer; transition: transform 0.22s ease, opacity 0.18s ease, background 0.2s ease; }
:where(.lf-header-search-toggle:hover) { transform: scale(1.06); background: color-mix(in srgb, var(--primary-color, #2563eb) 14%, transparent); }
:where(.lf-header-search svg) { width: 19px; height: 19px; flex: 0 0 auto; }
:where(.lf-header-search-field) { width: 44px; height: 44px; display: grid; grid-template-columns: 20px minmax(0, 1fr); align-items: center; gap: 9px; padding: 0 13px; border: 1px solid rgba(124, 58, 237, 0.22); border-radius: 999px; background: rgba(248, 250, 252, 0.42); color: #7c3aed; opacity: 0; overflow: hidden; transform: scaleX(0.72); transform-origin: right center; pointer-events: none; transition: width 0.28s ease, opacity 0.18s ease, transform 0.28s ease, background 0.2s ease; }
:where(.lf-header-search-field input) { width: 100%; min-width: 0; border: 0; outline: 0; background: transparent; color: #0f172a; font: inherit; font-size: 14px; }
:where(.lf-header-search-status) { position: absolute; right: 0; top: calc(100% + 8px); min-width: 240px; max-width: 340px; padding: 8px 10px; border: 1px solid rgba(148, 163, 184, 0.2); border-radius: 12px; background: rgba(248, 250, 252, 0.92); color: #64748b; font-size: 12px; line-height: 1.35; opacity: 0; transform: translateY(-4px); pointer-events: none; transition: opacity 0.18s ease, transform 0.18s ease; }
:where(.lf-header-search-status button) { border: 0; padding: 0; background: transparent; color: #7c3aed; font: inherit; font-weight: 800; cursor: pointer; }
:where(.lf-search-hidden) { display: none !important; }

/* User chip and notifications */
:where(.user-chip) { min-width: 0; width: auto; max-width: none; flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: flex-end; gap: 12px; padding: 0; border: 0; border-radius: 0; background: transparent; box-shadow: none; overflow: visible; }
:where(.user-chip-actions) { position: static; z-index: 8200; display: inline-flex; align-items: center; gap: 8px; flex: 0 0 auto; margin: 0; }
:where(.user-chip-icon-btn) { width: 40px; min-width: 40px; height: 40px; min-height: 40px; display: inline-grid; place-items: center; border: 1px solid rgba(148, 163, 184, 0.22); border-radius: 999px; background: transparent; color: #0f172a; box-shadow: none; text-decoration: none; cursor: pointer; }
:where(.user-chip-icon-btn:hover) { background: #eef4ff; border-color: rgba(37, 99, 235, 0.24); color: #2563eb; }
:where(.user-chip-icon-btn svg) { width: 19px; height: 19px; }
:where(.notification-menu) { position: relative; z-index: 8200; display: inline-flex; align-items: center; justify-content: center; }
:where(.notification-bell-btn) { position: relative; }
:where(.notification-badge) { position: absolute; top: -6px; right: -6px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; display: inline-flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #2563eb, #7c3aed); color: #fff; border: 2px solid #fff; font-size: 10px; font-weight: 900; line-height: 1; box-shadow: 0 10px 18px rgba(37, 99, 235, 0.22); }
:where(.notification-popover) { position: absolute; top: calc(100% + 12px); right: -10px; z-index: 9999; width: min(360px, calc(100vw - 32px)); padding: 12px; border: 1px solid rgba(148, 163, 184, 0.24); border-radius: 20px; background: rgba(248, 250, 252, 0.96); box-shadow: 0 24px 60px rgba(15, 23, 42, 0.14); backdrop-filter: blur(18px); }
:where(.notification-popover[hidden], .notification-empty[hidden], .notification-row[hidden], .notification-clear-button[hidden], .notification-badge[hidden]) { display: none; }
:where(.notification-popover::before) { content: ""; position: absolute; top: -7px; right: 24px; width: 14px; height: 14px; transform: rotate(45deg); background: rgba(248, 250, 252, 0.96); border-left: 1px solid rgba(148, 163, 184, 0.22); border-top: 1px solid rgba(148, 163, 184, 0.22); }
:where(.notification-popover-head) { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 4px 4px 12px; }
:where(.notification-popover-head span) { color: #0f172a; font-size: 14px; font-weight: 900; }
:where(.notification-popover-head small) { color: #64748b; font-size: 11px; font-weight: 800; }
:where(.notification-list-panel) { display: grid; gap: 8px; }
:where(.notification-row) { display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 10px; border: 1px solid rgba(148, 163, 184, 0.18); border-radius: 14px; color: #0f172a; text-decoration: none; background: transparent; }
:where(.notification-row:hover) { border-color: rgba(37, 99, 235, 0.24); background: rgba(239, 246, 255, 0.72); }
:where(.notification-row.is-due) { border-color: rgba(124, 58, 237, 0.28); background: rgba(124, 58, 237, 0.06); }
:where(.notification-row-icon) { width: 36px; height: 36px; border-radius: 13px; display: inline-flex; align-items: center; justify-content: center; color: #2563eb; background: rgba(37, 99, 235, 0.1); }
:where(.notification-row.is-due .notification-row-icon) { color: #7c3aed; background: rgba(124, 58, 237, 0.12); }
:where(.notification-row-icon svg) { width: 18px; height: 18px; }
:where(.notification-row-copy) { min-width: 0; display: grid; gap: 3px; }
:where(.notification-row-copy strong, .notification-row-copy span) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
:where(.notification-row-copy strong) { color: #0f172a; font-size: 12px; font-weight: 900; }
:where(.notification-row-copy span, .notification-row em) { color: #64748b; font-size: 11px; font-style: normal; font-weight: 800; }
:where(.notification-empty) { display: grid; gap: 5px; padding: 18px 12px; text-align: center; color: #64748b; }
:where(.notification-empty strong) { color: #0f172a; font-size: 13px; }
:where(.notification-empty span) { font-size: 12px; line-height: 1.35; }
:where(.notification-popover-actions) { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; margin-top: 10px; }
:where(.notification-popover-link, .notification-clear-button) { min-height: 38px; display: flex; align-items: center; justify-content: center; border: 0; border-radius: 13px; text-decoration: none; font-size: 12px; font-weight: 900; }
:where(.notification-popover-link) { color: #2563eb; background: rgba(37, 99, 235, 0.08); }
:where(.notification-clear-button) { padding: 0 12px; color: #7c3aed; background: rgba(124, 58, 237, 0.08); cursor: pointer; }
:where(.notification-popover-link:hover) { color: #fff; background: linear-gradient(135deg, #2563eb, #7c3aed); }
:where(.notification-clear-button:hover) { color: #fff; background: #7c3aed; }
:where(.user-chip-profile-link) { min-width: 0; display: inline-flex; align-items: center; gap: 12px; flex: 0 0 auto; overflow: visible; }
:where(.user-chip-profile-anchor) { min-width: 0; display: flex; flex: 1 1 auto; align-items: center; gap: 14px; color: inherit; text-decoration: none; }
:where(.user-avatar) { width: 52px; min-width: 52px; height: 52px; display: inline-grid; place-items: center; border: 0; border-radius: 999px; background: linear-gradient(135deg, #2563eb 0%, #7c3aed 62%, #a855f7 100%); color: #fff; font-size: 17px; font-weight: 900; box-shadow: none; overflow: hidden; }
:where(.user-avatar::before, .user-avatar::after, .user-avatar .status-dot) { display: none; content: none; }
:where(.user-avatar img) { width: 100%; height: 100%; border-radius: 999px; object-fit: cover; }
:where(.user-name) { color: #0f172a; font-size: 14px; font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
:where(.user-chip-inline-logout) { width: 34px; min-width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; margin-left: 8px; color: #2563eb; text-decoration: none; }
:where(.user-chip-inline-logout-icon) { width: 28px; height: 28px; display: block; }

body.dashboard-client-flat-theme > .shell .topbar.app-topbar.lf-unified-app-header {
  min-height: 58px !important;
  margin-bottom: 18px !important;
}

body.dashboard-client-flat-theme > .shell .topbar.app-topbar.lf-unified-app-header .dashboard-welcome-title {
  font-size: 24px !important;
  line-height: 1.15 !important;
  font-weight: 760 !important;
}

body.dashboard-client-flat-theme > .shell .topbar.app-topbar.lf-unified-app-header .subtitle {
  font-size: 13px !important;
  line-height: 1.35 !important;
}

body.dashboard-client-flat-theme > .shell .topbar.app-topbar.lf-unified-app-header .app-header-title-icon {
  width: 36px !important;
  min-width: 36px !important;
  height: 36px !important;
}

body.dashboard-client-flat-theme > .shell .topbar.app-topbar.lf-unified-app-header .user-avatar {
  width: 42px !important;
  min-width: 42px !important;
  height: 42px !important;
}
@media (max-width: 1180px) {
  :where(.topbar.app-topbar, .lf-unified-app-header, .lf-topbar) {
    align-items: center;
    flex-wrap: nowrap;
    gap: 14px;
  }

  :where(.app-topbar-copy, .topbar-copy) {
    min-width: 0;
    flex: 1 1 auto;
  }

  :where(.dashboard-topbar-actions.app-topbar-actions, .app-topbar-actions) {
    width: auto;
    justify-content: flex-end;
    gap: 8px;
  }
}

@media (max-width: 720px) {
  :where(.topbar.app-topbar, .lf-unified-app-header, .lf-topbar) {
    align-items: stretch;
    flex-direction: column;
    flex-wrap: nowrap;
  }

  :where(.dashboard-topbar-actions.app-topbar-actions, .app-topbar-actions) {
    width: 100%;
    justify-content: flex-start;
  }
}

/* Header search expands as an overlay so the inherited header layout stays fixed. */
:where(.lf-header-search-field) {
  position: absolute;
  top: 0;
  right: 0;
}

:where(.lf-header-search.is-open) {
  z-index: 8300;
}

/* Search open state needs normal specificity to beat the closed base width. */
.lf-header-search.is-open .lf-header-search-toggle {
  opacity: 0;
  transform: scale(0.86);
  pointer-events: none;
}

.lf-header-search.is-open .lf-header-search-field {
  width: min(320px, 42vw);
  opacity: 1;
  transform: scaleX(1);
  pointer-events: auto;
  background: rgba(248, 250, 252, 0.78);
}

.lf-header-search.is-open .lf-header-search-status:not(:empty) {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

/* Dashboard flat-theme topbar bridge moved from compat.css. */
body.dashboard-client-flat-theme > .shell :is(.topbar.app-topbar, .lf-topbar) {
  min-height: var(--lf-topbar-height) !important;
  padding: 0 !important;
  border: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
}
body.dashboard-client-flat-theme > .shell :is(.dashboard-today-pill, .lf-header-search-toggle, .user-chip-icon-btn) {
  width: 36px !important;
  min-width: 36px !important;
  height: 36px !important;
  display: inline-grid !important;
  place-items: center !important;
  border: 1px solid var(--lf-color-border) !important;
  border-radius: var(--lf-radius-pill) !important;
  background: var(--lf-color-surface) !important;
  color: var(--lf-color-text) !important;
  box-shadow: none !important;
}

body.dashboard-client-flat-theme > .shell .dashboard-today-pill {
  width: auto !important;
  min-width: 0 !important;
  padding: 0 var(--lf-space-3) !important;
  grid-auto-flow: column !important;
  gap: var(--lf-space-2) !important;
  color: var(--lf-color-text) !important;
  font-size: var(--lf-font-size-sm) !important;
  font-weight: 900 !important;
}

body.dashboard-client-flat-theme > .shell .lf-header-search-field {
  min-height: 40px !important;
  border: 1px solid var(--lf-color-border) !important;
  border-radius: var(--lf-radius-pill) !important;
  background: var(--lf-color-surface) !important;
  box-shadow: none !important;
}

body.dashboard-client-flat-theme > .shell .user-chip {
  min-height: 44px !important;
  border: 1px solid var(--lf-color-border) !important;
  border-radius: var(--lf-radius-pill) !important;
  background: var(--lf-color-surface) !important;
  box-shadow: none !important;
}

body.dashboard-client-flat-theme > .shell :is(.user-chip-profile-anchor, .user-chip-profile-link > a) {
  min-width: 0 !important;
  display: flex !important;
  flex: 1 1 auto !important;
  align-items: center !important;
  gap: 14px !important;
  color: inherit !important;
  text-decoration: none !important;
}

body.dashboard-client-flat-theme > .shell .user-chip-inline-logout {
  width: 30px !important;
  min-width: 30px !important;
  height: 30px !important;
  display: inline-flex !important;
  flex-shrink: 0 !important;
  align-items: center !important;
  justify-content: center !important;
  margin-left: var(--lf-space-3) !important;
  color: var(--lf-color-primary) !important;
  text-decoration: none !important;
}

body.dashboard-client-flat-theme > .shell .user-chip-inline-logout-icon {
  width: 16px !important;
  height: 16px !important;
  display: block !important;
}

body.dashboard-client-flat-theme > .shell .dashboard-welcome-title {
  margin: 0 !important;
  font-size: 32px !important;
  line-height: var(--lf-line-tight) !important;
  font-weight: 900 !important;
}

/* Final authenticated header lock: compact, single-piece action menu. */
body.dashboard-client-flat-theme > .shell .topbar.app-topbar.lf-unified-app-header {
  min-height: 58px !important;
  align-items: flex-start !important;
  gap: 16px !important;
  margin-bottom: 16px !important;
}

body.dashboard-client-flat-theme > .shell .topbar.app-topbar.lf-unified-app-header .dashboard-welcome-title {
  font-size: 24px !important;
  line-height: 1.12 !important;
  font-weight: 820 !important;
}

body.dashboard-client-flat-theme > .shell .topbar.app-topbar.lf-unified-app-header .subtitle {
  max-width: 720px !important;
  font-size: 13px !important;
  line-height: 1.35 !important;
  font-weight: 650 !important;
}

body.dashboard-client-flat-theme > .shell .topbar.app-topbar.lf-unified-app-header .app-header-title-icon {
  width: 36px !important;
  min-width: 36px !important;
  height: 36px !important;
  border-radius: 12px !important;
}

body.dashboard-client-flat-theme > .shell .app-topbar-actions {
  gap: 8px !important;
  padding-top: 2px !important;
}

body.dashboard-client-flat-theme > .shell .dashboard-today-pill {
  height: 34px !important;
  min-height: 34px !important;
  padding: 0 10px !important;
  font-size: 12px !important;
}

body.dashboard-client-flat-theme > .shell .dashboard-today-pill svg {
  width: 14px !important;
  height: 14px !important;
}

body.dashboard-client-flat-theme > .shell .lf-header-search {
  min-width: 34px !important;
  height: 34px !important;
}

body.dashboard-client-flat-theme > .shell .lf-header-search-toggle,
body.dashboard-client-flat-theme > .shell .user-chip-icon-btn {
  width: 34px !important;
  min-width: 34px !important;
  height: 34px !important;
  min-height: 34px !important;
}

body.dashboard-client-flat-theme > .shell .theme-toggle-btn[hidden] {
  display: none !important;
}

body.dashboard-client-flat-theme > .shell .user-chip {
  min-height: 38px !important;
  display: inline-flex !important;
  align-items: center !important;
  gap: 6px !important;
  padding: 2px 6px 2px 8px !important;
  border-radius: 999px !important;
}

body.dashboard-client-flat-theme > .shell .user-chip-actions {
  gap: 2px !important;
}

body.dashboard-client-flat-theme > .shell .user-chip .user-chip-icon-btn {
  border-color: transparent !important;
  background: transparent !important;
}

body.dashboard-client-flat-theme > .shell .user-chip .user-chip-icon-btn:hover {
  background: var(--lf-color-surface-muted, #f1f5f9) !important;
}

body.dashboard-client-flat-theme > .shell .notification-badge {
  top: -4px !important;
  right: -4px !important;
  min-width: 16px !important;
  height: 16px !important;
  padding: 0 4px !important;
  font-size: 9px !important;
}

body.dashboard-client-flat-theme > .shell .user-chip-profile-link {
  gap: 6px !important;
}

body.dashboard-client-flat-theme > .shell :is(.user-chip-profile-anchor, .user-chip-profile-link > a) {
  gap: 8px !important;
}

body.dashboard-client-flat-theme > .shell .topbar.app-topbar.lf-unified-app-header .user-avatar {
  width: 30px !important;
  min-width: 30px !important;
  height: 30px !important;
  font-size: 12px !important;
}

body.dashboard-client-flat-theme > .shell .user-name {
  max-width: 96px !important;
  font-size: 13px !important;
  font-weight: 820 !important;
}

body.dashboard-client-flat-theme > .shell .user-chip-inline-logout {
  width: 30px !important;
  min-width: 30px !important;
  height: 30px !important;
  margin-left: 2px !important;
  border-radius: 999px !important;
}

body.dashboard-client-flat-theme > .shell .user-chip-inline-logout:hover {
  background: var(--lf-color-surface-muted, #f1f5f9) !important;
}
