* {
  box-sizing: border-box;
}

*,
*::before,
*::after {
  transition-property: background-color, color, box-shadow !important;
  transition-duration: 0.15s !important;
  transition-timing-function: ease !important;
}

html,
body,
#app,
#root,
.app,
.main {
  width: 100%;
  min-height: 100%;
  overflow-x: hidden !important;
  scroll-behavior: smooth;
}

button,
.button-link,
.nav-button,
.nav-section-toggle,
.sidebar-collapse-toggle,
.panel,
.metric,
.provider-card,
.provider-kpi,
.insight,
.message-item,
.company-card,
.stat-card,
.pricing-card,
.modal-card,
.row-actions button,
.dashboard-quick-actions button,
.provider-portal-sidebar nav button,
.portal-menu a,
.portal-card,
.portal-action,
.portal-panel {
  transition: background-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease !important;
  transition-property: background-color, color, box-shadow !important;
  transform: none !important;
  animation: none !important;
}

button:hover,
button:active,
.button-link:hover,
.button-link:active,
.nav-button:hover,
.nav-button:active,
.nav-section-toggle:hover,
.nav-section-toggle:active,
.sidebar-collapse-toggle:hover,
.sidebar-collapse-toggle:active,
.panel:hover,
.metric:hover,
.provider-card:hover,
.provider-kpi:hover,
.insight:hover,
.message-item:hover,
.company-card:hover,
.stat-card:hover,
.pricing-card:hover,
.row-actions button:hover,
.row-actions button:active,
.dashboard-quick-actions button:hover,
.dashboard-quick-actions button:active,
.provider-portal-sidebar nav button:hover,
.provider-portal-sidebar nav button:active,
.portal-menu a:hover,
.portal-card:hover,
.portal-action:hover,
.portal-panel:hover {
  transform: none !important;
}

.app,
.provider-portal-shell,
.login-screen,
.module-page,
.workspace,
.panel,
.metric,
.modal,
.modal-card,
.toast,
.portal-pro-layout,
.portal-card,
.portal-panel {
  animation: none !important;
}

.modal {
  overflow: hidden !important;
  backdrop-filter: none !important;
}

.modal-card {
  max-height: 90vh !important;
  overflow-y: auto !important;
  overscroll-behavior: contain;
}

.modal-card > :not(.modal-head) {
  max-height: none;
}

.modal-head {
  position: sticky !important;
  top: 0 !important;
  z-index: 20 !important;
  background: #fff !important;
  border-bottom: 1px solid #e2e8f0;
}

.modal-head button,
.modal-head [data-close-modal] {
  position: relative !important;
  z-index: 25 !important;
}

.employee-profile,
.employee-profile-modal,
.employee-profile-modal .modal-card,
.attendance-month-modal,
.attendance-month-modal .modal-card {
  max-height: 90vh !important;
  overflow-y: auto !important;
}

.employee-profile,
.employee-profile-modal .modal-card,
.attendance-month-modal .modal-card {
  padding-bottom: 28px !important;
}

.employee-profile > :not(.modal-head),
.employee-profile-modal .employee-profile-content,
.attendance-month-modal .attendance-month-content,
.attendance-month-modal .monthly-attendance-body,
.employee-profile-modal .modal-body,
.attendance-month-modal .modal-body {
  max-height: calc(90vh - 80px) !important;
  overflow-y: auto !important;
  padding-bottom: 42px !important;
  overscroll-behavior: contain;
}

.sidebar {
  width: 280px !important;
  max-width: 280px !important;
  min-width: 260px !important;
}

@media (max-width: 760px) {
  .modal {
    align-items: stretch !important;
    padding: 0 !important;
  }

  .modal-card,
  .employee-profile,
  .employee-profile-modal .modal-card,
  .attendance-month-modal .modal-card {
    width: 100% !important;
    max-width: 100% !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
    border-radius: 0 !important;
    overflow-y: auto !important;
  }

  .employee-profile > :not(.modal-head),
  .employee-profile-modal .employee-profile-content,
  .attendance-month-modal .attendance-month-content,
  .attendance-month-modal .monthly-attendance-body,
  .employee-profile-modal .modal-body,
  .attendance-month-modal .modal-body {
    max-height: calc(100dvh - 76px) !important;
    overflow-y: auto !important;
    padding-bottom: 64px !important;
  }

  .sidebar {
    width: min(300px, 86vw) !important;
    max-width: min(300px, 86vw) !important;
    min-width: 0 !important;
  }
}

.expense-center {
  display: grid;
  gap: 18px;
  color: #0f172a;
}

.expense-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 22px;
  border: 1px solid #e2e8f0;
  border-radius: 18px;
  background: linear-gradient(135deg, #ffffff 0%, #eff6ff 100%);
  box-shadow: 0 10px 28px rgba(15, 42, 85, 0.08);
}

.expense-hero h1 {
  margin: 0;
  font-size: clamp(24px, 3vw, 36px);
  color: #0f172a;
}

.expense-hero p {
  margin: 6px 0 0;
  color: #64748b;
}

.expense-kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.expense-kpi {
  position: relative;
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 122px;
  padding: 20px;
  overflow: visible;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  background: #ffffff;
  box-shadow: 0 8px 22px rgba(15, 42, 85, 0.07);
}

.expense-kpi-icon {
  display: inline-grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 14px;
  background: #eff6ff;
  color: #2563eb;
  font-size: 22px;
  flex: 0 0 auto;
}

.expense-kpi p,
.expense-kpi strong,
.expense-kpi small {
  position: relative;
  z-index: 1;
}

.expense-kpi p {
  margin: 0 0 6px;
  color: #64748b;
  font-weight: 700;
}

.expense-kpi strong {
  display: block;
  color: #0f172a;
  font-size: 22px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.expense-kpi small {
  display: block;
  margin-top: 5px;
  color: #16a34a;
}

.expense-kpi.emerald .expense-kpi-icon { background: #dcfce7; color: #16a34a; }
.expense-kpi.orange .expense-kpi-icon,
.expense-kpi.amber .expense-kpi-icon { background: #ffedd5; color: #f97316; }
.expense-kpi.red .expense-kpi-icon { background: #fee2e2; color: #dc2626; }
.expense-kpi.purple .expense-kpi-icon { background: #f3e8ff; color: #7c3aed; }
.expense-kpi.cyan .expense-kpi-icon { background: #cffafe; color: #0891b2; }
.expense-kpi.navy .expense-kpi-icon { background: #dbeafe; color: #0f2a55; }

.expense-filter-panel,
.expense-results-panel,
.expense-chart-card,
.expense-details-modal {
  border: 1px solid #e2e8f0;
  background: #ffffff;
  color: #0f172a;
}

.expense-filter-search {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  margin: 14px 0;
}

.expense-filter-search input,
.expense-filter-grid input,
.expense-filter-grid select {
  width: 100%;
  min-height: 44px;
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  padding: 10px 12px;
  color: #0f172a;
  background: #ffffff;
}

.expense-filter-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.expense-filter-grid label span {
  display: block;
  margin-bottom: 6px;
  color: #334155;
  font-weight: 700;
}

.expense-filter-actions {
  margin-top: 14px;
}

.expense-alerts {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.expense-alerts article {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px;
  border-radius: 14px;
  border: 1px solid #e2e8f0;
  background: #ffffff;
  color: #0f172a;
}

.expense-alerts strong {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #eff6ff;
  color: #2563eb;
}

.expense-alerts .warning strong { background: #ffedd5; color: #f97316; }
.expense-alerts .danger strong { background: #fee2e2; color: #dc2626; }
.expense-alerts .success strong { background: #dcfce7; color: #16a34a; }

.expense-table {
  min-width: 1280px;
}

.expense-table th {
  color: #0f172a;
  background: #f8fafc;
  white-space: nowrap;
}

.expense-table td {
  color: #0f172a;
  vertical-align: top;
}

.expense-status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 5px 10px;
  border-radius: 999px;
  font-weight: 800;
  font-size: 12px;
  background: #e2e8f0;
  color: #334155;
}

.expense-status-badge.pending,
.expense-status-badge.pendingReview { background: #ffedd5; color: #c2410c; }
.expense-status-badge.approved { background: #dbeafe; color: #1d4ed8; }
.expense-status-badge.paid { background: #dcfce7; color: #15803d; }
.expense-status-badge.rejected { background: #fee2e2; color: #b91c1c; }

.expense-mobile-list {
  display: none;
}

.expense-analytics-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.expense-bars {
  display: grid;
  gap: 12px;
}

.expense-bars > div {
  position: relative;
  display: grid;
  grid-template-columns: minmax(90px, 1fr) auto;
  gap: 10px;
  padding-bottom: 10px;
}

.expense-bars i {
  grid-column: 1 / -1;
  height: 8px;
  border-radius: 999px;
  background: linear-gradient(90deg, #2563eb, #10b981);
}

.expense-detail-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  padding: 16px 0;
}

.expense-detail-grid div {
  padding: 12px;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  background: #f8fafc;
}

.expense-detail-grid span {
  display: block;
  color: #64748b;
  font-size: 12px;
}

.expense-detail-grid strong {
  display: block;
  margin-top: 4px;
  color: #0f172a;
  overflow-wrap: anywhere;
}

.expense-invoice-preview img {
  display: block;
  max-width: 100%;
  max-height: 360px;
  object-fit: contain;
  border-radius: 12px;
  border: 1px solid #e2e8f0;
  background: #f8fafc;
}

.expense-status-timeline {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 0;
}

.expense-status-timeline span {
  padding: 8px 12px;
  border-radius: 999px;
  background: #f1f5f9;
  color: #64748b;
  font-weight: 800;
}

.expense-status-timeline span.active {
  background: #dbeafe;
  color: #1d4ed8;
}

.expense-audit-list {
  display: grid;
  gap: 8px;
}

.expense-audit-list article {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 10px;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
}

@media (max-width: 1100px) {
  .expense-kpi-grid,
  .expense-filter-grid,
  .expense-alerts {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .expense-hero,
  .expense-filter-search {
    grid-template-columns: 1fr;
    flex-direction: column;
    align-items: stretch;
  }

  .expense-kpi-grid,
  .expense-filter-grid,
  .expense-alerts,
  .expense-analytics-grid,
  .expense-detail-grid {
    grid-template-columns: 1fr;
  }

  .expense-table-wrap {
    display: none;
  }

  .expense-mobile-list {
    display: grid;
    gap: 12px;
  }

  .expense-mobile-card {
    display: grid;
    gap: 8px;
    padding: 14px;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    background: #ffffff;
  }

  .expense-mobile-card > div:first-child,
  .expense-mobile-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
  }

  .expense-mobile-card p {
    margin: 0;
    color: #64748b;
  }
}

/* Final mobile drawer height fix: the sidebar background must never end while scrolling. */
body.phone-nav .sidebar,
body.phone-landscape-nav .sidebar,
body.phone-nav .sidebar.is-collapsed,
body.phone-landscape-nav .sidebar.is-collapsed,
[dir="rtl"] body.phone-nav .sidebar,
[dir="rtl"] body.phone-landscape-nav .sidebar,
[dir="rtl"] body.phone-nav .sidebar.is-collapsed,
[dir="rtl"] body.phone-landscape-nav .sidebar.is-collapsed {
  position: fixed !important;
  top: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  left: auto !important;
  height: 100vh !important;
  height: 100dvh !important;
  min-height: 100vh !important;
  min-height: 100dvh !important;
  max-height: 100dvh !important;
  overflow: hidden !important;
  display: grid !important;
  grid-template-rows: auto minmax(0, 1fr) !important;
  align-content: stretch !important;
  background: #08223c !important;
  background-image: linear-gradient(180deg, #102c4b 0%, #061d33 100%) !important;
  background-attachment: local !important;
}

body.phone-nav .sidebar > *,
body.phone-landscape-nav .sidebar > * {
  min-height: 0 !important;
}

body.phone-nav .sidebar .erp-sidebar-shell,
body.phone-landscape-nav .sidebar .erp-sidebar-shell,
body.phone-nav .sidebar .platform-sidebar-shell,
body.phone-landscape-nav .sidebar .platform-sidebar-shell,
body.phone-nav .sidebar .erp-sidebar-scroll,
body.phone-landscape-nav .sidebar .erp-sidebar-scroll,
body.phone-nav .sidebar .nav,
body.phone-landscape-nav .sidebar .nav {
  min-height: 0 !important;
  height: 100% !important;
  max-height: 100% !important;
}

body.phone-nav .sidebar .erp-sidebar-shell,
body.phone-landscape-nav .sidebar .erp-sidebar-shell,
body.phone-nav .sidebar .platform-sidebar-shell,
body.phone-landscape-nav .sidebar .platform-sidebar-shell {
  display: grid !important;
  grid-template-rows: auto minmax(0, 1fr) !important;
  overflow: hidden !important;
  background: transparent !important;
}

body.phone-nav .sidebar .erp-sidebar-scroll,
body.phone-landscape-nav .sidebar .erp-sidebar-scroll,
body.phone-nav .sidebar .nav,
body.phone-landscape-nav .sidebar .nav {
  overflow-y: auto !important;
  overflow-x: hidden !important;
  overscroll-behavior: contain !important;
  padding-bottom: calc(24px + env(safe-area-inset-bottom)) !important;
  scrollbar-gutter: stable !important;
  background: transparent !important;
}

body.phone-nav .sidebar::after,
body.phone-landscape-nav .sidebar::after {
  content: "";
  position: absolute;
  inset-inline: 0;
  bottom: 0;
  height: max(28px, env(safe-area-inset-bottom));
  pointer-events: none;
  background: linear-gradient(180deg, rgba(6, 29, 51, 0), #061d33 72%);
}

/* Fix stacked mobile sidebar controls: header stays natural, menu alone scrolls. */
body.phone-nav .sidebar,
body.phone-landscape-nav .sidebar,
body.phone-nav .sidebar.is-collapsed,
body.phone-landscape-nav .sidebar.is-collapsed {
  display: flex !important;
  flex-direction: column !important;
  align-items: stretch !important;
  justify-content: flex-start !important;
  gap: 12px !important;
  padding: calc(14px + env(safe-area-inset-top)) 12px calc(12px + env(safe-area-inset-bottom)) !important;
}

body.phone-nav .sidebar .mobile-menu-close,
body.phone-landscape-nav .sidebar .mobile-menu-close {
  position: absolute !important;
  top: calc(12px + env(safe-area-inset-top)) !important;
  inset-inline-start: 14px !important;
  z-index: 4 !important;
  flex: 0 0 auto !important;
}

body.phone-nav .sidebar .brand,
body.phone-landscape-nav .sidebar .brand,
body.phone-nav .sidebar .tenant-switcher,
body.phone-landscape-nav .sidebar .tenant-switcher {
  position: relative !important;
  flex: 0 0 auto !important;
  width: 100% !important;
  max-width: 100% !important;
  margin: 0 !important;
  z-index: 2 !important;
}

body.phone-nav .sidebar .nav,
body.phone-landscape-nav .sidebar .nav {
  position: relative !important;
  flex: 1 1 auto !important;
  min-height: 0 !important;
  height: auto !important;
  max-height: none !important;
  width: 100% !important;
  overflow: hidden !important;
  z-index: 1 !important;
  display: block !important;
}

body.phone-nav .sidebar .erp-sidebar-shell,
body.phone-landscape-nav .sidebar .erp-sidebar-shell,
body.phone-nav .sidebar .platform-sidebar-shell,
body.phone-landscape-nav .sidebar .platform-sidebar-shell {
  height: 100% !important;
  min-height: 0 !important;
  display: flex !important;
  flex-direction: column !important;
  gap: 10px !important;
}

body.phone-nav .sidebar .erp-sidebar-tools,
body.phone-landscape-nav .sidebar .erp-sidebar-tools,
body.phone-nav .sidebar .platform-sidebar-search,
body.phone-landscape-nav .sidebar .platform-sidebar-search {
  flex: 0 0 auto !important;
  position: relative !important;
  z-index: 2 !important;
  margin: 0 !important;
}

body.phone-nav .sidebar .erp-sidebar-scroll,
body.phone-landscape-nav .sidebar .erp-sidebar-scroll,
body.phone-nav .sidebar .platform-admin-nav,
body.phone-landscape-nav .sidebar .platform-admin-nav {
  flex: 1 1 auto !important;
  min-height: 0 !important;
  height: auto !important;
  max-height: none !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
}

/* Final scroll and touch performance layer. Body is fixed; app content owns scrolling. */
html,
body {
  width: 100% !important;
  height: 100% !important;
  margin: 0 !important;
  overflow: hidden !important;
  overscroll-behavior: none !important;
}

body {
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  touch-action: manipulation;
}

body.no-scroll {
  overflow: hidden !important;
}

.app,
.app-shell,
.dashboard-layout,
.app-layout {
  width: 100% !important;
  height: 100vh !important;
  height: 100dvh !important;
  min-height: 0 !important;
  overflow: hidden !important;
}

.app,
.workspace,
.module-page,
.main-wrapper,
.page-shell,
.dashboard-layout,
.app-layout {
  min-height: 0 !important;
}

.main,
.main-content,
.page-content,
.content-area,
.dashboard-main {
  min-height: 0 !important;
  height: 100% !important;
  max-height: 100dvh !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  touch-action: pan-y;
}

.main {
  contain: layout style;
}

.login-screen,
.landing-page,
.pricing-page,
.public-register-page,
.startup-shell {
  height: 100vh !important;
  height: 100dvh !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
}

button,
a,
.nav-item,
.menu-item,
.action-btn,
.card,
.clickable,
.nav-button,
.nav-section-toggle,
.metric,
.panel,
.insight,
.row-actions button,
[role="button"] {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  cursor: pointer;
  transition:
    background-color 0.15s ease,
    border-color 0.15s ease,
    color 0.15s ease,
    box-shadow 0.15s ease,
    opacity 0.15s ease !important;
}

button:active,
a:active,
.nav-item:active,
.menu-item:active,
.action-btn:active,
.clickable:active,
.nav-button:active,
.row-actions button:active,
[role="button"]:active {
  transform: translateY(1px) !important;
}

@media (max-width: 768px), (hover: none) {
  html,
  body {
    overflow: hidden !important;
  }

  .app,
  .app-shell,
  .dashboard-layout,
  .app-layout {
    height: 100dvh !important;
    overflow: hidden !important;
  }

  .main,
  .main-content,
  .page-content,
  .content-area,
  .dashboard-main {
    overflow-y: auto !important;
    overflow-x: hidden !important;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
    touch-action: pan-y;
  }

  button,
  a,
  .nav-item,
  .menu-item,
  .action-btn,
  .card,
  .clickable {
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
  }

  .card:hover,
  .nav-item:hover,
  .menu-item:hover,
  .action-btn:hover,
  .metric:hover,
  .panel:hover,
  .insight:hover {
    transform: none !important;
  }

  .card,
  .nav-item,
  .menu-item,
  .action-btn,
  .metric,
  .panel,
  .insight {
    transition:
      background-color 0.12s ease,
      border-color 0.12s ease,
      color 0.12s ease,
      opacity 0.12s ease !important;
  }
}

/* Production stability layer: remove click jitter and layout shifts without changing business logic. */
:root {
  --stable-transition-fast: 0.12s ease;
}

html,
body,
#app,
#root {
  max-width: 100% !important;
  overflow-x: hidden !important;
}

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

:where(
  button,
  a,
  input,
  select,
  textarea,
  .nav-button,
  .nav-section-toggle,
  .menu-item,
  .action-btn,
  .row-actions button,
  .metric,
  .panel,
  .card,
  .stat-card,
  .company-card,
  .provider-card,
  .pricing-card,
  .portal-card,
  .portal-action
) {
  transition-property: background-color, border-color, color, box-shadow, opacity !important;
  transition-duration: var(--stable-transition-fast) !important;
  transition-timing-function: ease !important;
  will-change: auto !important;
}

:where(
  button,
  a,
  .nav-button,
  .nav-section-toggle,
  .menu-item,
  .action-btn,
  .row-actions button,
  .metric,
  .panel,
  .card,
  .stat-card,
  .company-card,
  .provider-card,
  .pricing-card,
  .portal-card,
  .portal-action
):hover,
:where(
  button,
  a,
  .nav-button,
  .nav-section-toggle,
  .menu-item,
  .action-btn,
  .row-actions button,
  .metric,
  .panel,
  .card,
  .stat-card,
  .company-card,
  .provider-card,
  .pricing-card,
  .portal-card,
  .portal-action
):active,
:where(
  button,
  a,
  .nav-button,
  .nav-section-toggle,
  .menu-item,
  .action-btn,
  .row-actions button,
  .metric,
  .panel,
  .card,
  .stat-card,
  .company-card,
  .provider-card,
  .pricing-card,
  .portal-card,
  .portal-action
):focus {
  transform: none !important;
}

button,
a,
[role="button"],
.nav-button,
.nav-section-toggle,
.menu-item,
.action-btn,
.clickable,
.row-actions button {
  touch-action: manipulation !important;
  -webkit-tap-highlight-color: transparent !important;
  user-select: none;
}

.app,
.main,
.main-content,
.page-content,
.content-area,
.dashboard-main {
  contain-intrinsic-size: auto;
}

.main,
.main-content,
.page-content,
.content-area,
.dashboard-main,
.modal-card,
.sidebar,
.erp-sidebar-scroll,
.platform-admin-nav {
  scrollbar-gutter: stable;
}

@media (max-width: 900px), (hover: none), (pointer: coarse) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
  }

  :where(.panel, .metric, .card, .stat-card, .company-card, .provider-card, .pricing-card, .portal-card, .cw-card, .cw-panel) {
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.10) !important;
    filter: none !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
  }

  :where(.modal, .overlay, .drawer-overlay, .sidebar-overlay) {
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
  }

  :where(.metric:hover, .panel:hover, .card:hover, .stat-card:hover, .provider-card:hover, .company-card:hover, .pricing-card:hover, .portal-card:hover, .cw-card:hover) {
    transform: none !important;
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.10) !important;
  }
}

/* Keep only the navigation drawer movement; everything else should stay stable. */
body.phone-nav .sidebar,
body.phone-landscape-nav .sidebar,
body.phone-nav .mobile-sidebar,
body.phone-landscape-nav .mobile-sidebar,
.sidebar.open,
.mobile-sidebar.open,
.drawer.open {
  transition-property: transform, visibility !important;
  transition-duration: 0.14s !important;
  transition-timing-function: ease-out !important;
  will-change: transform !important;
}

/* 2026-07-30: stabilize cloud/file upload renders without changing layout or colors. */
html {
  overflow-y: scroll !important;
  scrollbar-gutter: stable both-edges;
}

body,
#app,
.app,
.shell,
.main,
.main-content,
.content-area,
.dashboard-main {
  min-width: 0 !important;
  transform: none !important;
}

.main,
.main-content,
.content-area,
.dashboard-main {
  overflow-anchor: none;
}

body.is-rendering,
body.is-rendering #app,
body.is-rendering .app,
body.is-rendering .shell,
body.is-rendering .main,
body.is-rendering .main-content,
body.is-rendering .content-area,
body.is-rendering .dashboard-main,
body.is-rendering :is(.panel, .metric, .metric-card, .card, .table-wrap, .data-table-wrapper, .invoice-image-preview, .document-file-summary, .cloudinary-upload-status, .firebase-sync-banner) {
  animation: none !important;
  transition-property: background-color, border-color, color, box-shadow, opacity !important;
  transition-duration: 0s !important;
  transform: none !important;
  opacity: 1 !important;
  filter: none !important;
}

/* Realtime data patches keep the page canvas continuously painted. */
body:not(.is-rendering) :is(#app, .app, .main, .main-content, .content-area, .dashboard-main) {
  opacity: 1 !important;
  animation: none !important;
  background-attachment: scroll !important;
}

.firebase-sync-banner,
.cloudinary-upload-status,
.invoice-upload-control,
.invoice-image-preview,
.document-file-summary,
.image-upload-preview,
.project-plan-file-field,
.document-file-field {
  contain: layout paint style;
}

.firebase-sync-banner {
  min-height: 42px;
  position: relative;
  z-index: 2;
}

.cloudinary-upload-status {
  min-height: 42px;
  transform: none !important;
  will-change: auto !important;
}

.invoice-upload-control,
.invoice-image-preview,
.document-file-summary {
  min-height: 112px;
}

:where(.panel, .metric, .metric-card, .card, .table-wrap, .data-table-wrapper, .form-card, .modal-card, .invoice-upload-control, .invoice-image-preview, .document-file-summary):hover,
:where(.panel, .metric, .metric-card, .card, .table-wrap, .data-table-wrapper, .form-card, .modal-card, .invoice-upload-control, .invoice-image-preview, .document-file-summary):focus-within {
  transform: none !important;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.001ms !important;
  }
}

/* Authoritative press behavior: no control may shift or resize during interaction. */
#app .app :is(
  button:not(.assistant-fab),
  a[href],
  [role="button"],
  .interactive-element:not(.assistant-fab),
  .clickable,
  .card.clickable,
  .metric,
  .stat-card,
  .summary-card,
  .kpi-card,
  .dashboard-card,
  .provider-card,
  .portal-card,
  .government-card,
  .pricing-card,
  .theme-card
) {
  transition-property: color, background-color, border-color, box-shadow, opacity !important;
  will-change: auto !important;
}

#app .app :is(
  button:not(.assistant-fab),
  a[href],
  [role="button"],
  .interactive-element:not(.assistant-fab),
  .clickable,
  .card.clickable,
  .metric,
  .stat-card,
  .summary-card,
  .kpi-card,
  .dashboard-card,
  .provider-card,
  .portal-card,
  .government-card,
  .pricing-card,
  .theme-card
):is(:hover, :active) {
  transform: none !important;
  translate: none !important;
}

#app .assistant-widget .assistant-fab:is(:hover, :active) {
  transform: translate3d(
    var(--assistant-fab-x, calc(100vw - 96px)),
    var(--assistant-fab-y, calc(100dvh - 96px)),
    0
  ) !important;
}

/* Telegram scheduler: guided presets and an explicit 12-hour time picker. */
.telegram-schedule-templates {
  display: grid;
  gap: 12px;
  margin: 14px 0 18px;
}

.telegram-schedule-templates-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.telegram-schedule-templates-head span {
  color: var(--muted, #64748b);
  font-size: 0.875rem;
}

.telegram-schedule-template-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 10px;
}

#app .telegram-schedule-template {
  display: grid;
  align-content: start;
  gap: 7px;
  min-height: 118px;
  padding: 14px;
  text-align: start;
  background: #fff;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  color: #172033;
}

#app .telegram-schedule-template:hover,
#app .telegram-schedule-template:focus-visible {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.telegram-schedule-template span,
.telegram-schedule-template small {
  color: #52647f;
  line-height: 1.45;
}

.telegram-schedule-template small {
  margin-block-start: auto;
  font-weight: 700;
}

.telegram-admin-page input[type="time"][data-telegram-schedule-field="time"] {
  display: none;
}

.telegram-schedule-time-custom {
  display: grid;
  gap: 8px;
}

.telegram-schedule-time-custom > span {
  font-weight: 700;
  color: #243550;
}

.telegram-schedule-time-controls {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  direction: ltr;
}

.telegram-schedule-time-controls select {
  min-width: 0;
  text-align: center;
  font-weight: 700;
}

.telegram-schedule-preview {
  display: grid;
  gap: 6px;
  padding: 14px 16px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  color: #17345f;
}

.telegram-schedule-preview > span,
.telegram-schedule-preview small {
  color: #52647f;
}

@media (max-width: 700px) {
  .telegram-schedule-templates-head {
    align-items: start;
    flex-direction: column;
  }

  .telegram-schedule-template-grid {
    grid-template-columns: 1fr;
  }
}

/* AI Employee Center */
.ai-employee-center {
  display: grid;
  gap: 16px;
}

.ai-employee-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  background: #102a56;
  border-color: #21457d;
  color: #fff;
}

.ai-employee-hero h2,
.ai-employee-hero p,
.ai-employee-hero span,
.ai-employee-hero small {
  color: inherit;
}

.ai-employee-hero p,
.ai-employee-level small {
  color: #dbeafe;
}

.ai-employee-level {
  display: grid;
  gap: 5px;
  min-width: 220px;
  padding-inline-start: 20px;
  border-inline-start: 1px solid rgba(255, 255, 255, 0.28);
}

.ai-employee-level strong {
  font-size: 1.85rem;
}

.ai-employee-metrics {
  grid-template-columns: repeat(auto-fit, minmax(155px, 1fr));
}

.ai-decision-trace {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  margin: 14px 0 0;
  padding: 0;
  list-style: none;
}

.ai-decision-trace li {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 7px 10px;
  padding: 12px;
  border: 1px solid #d6e0ed;
  border-radius: 8px;
  background: #f8fafc;
}

.ai-decision-trace li small {
  grid-column: 2;
  color: #52627a;
}

.ai-employee-settings-grid label {
  display: grid;
  gap: 7px;
}

.ai-module-levels {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(155px, 1fr));
  gap: 10px;
  margin: 16px 0;
}

.ai-module-levels label {
  display: grid;
  gap: 7px;
  padding: 12px;
  border: 1px solid #d6e0ed;
  border-radius: 8px;
  background: #f8fafc;
}

.ai-module-levels span {
  font-weight: 700;
  color: #243550;
}

.ai-safety-note {
  display: grid;
  gap: 5px;
  margin: 14px 0;
  padding: 13px 15px;
  color: #713f12;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 8px;
}

.ai-routine-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 10px;
  margin: 12px 0 16px;
}

.ai-routine-card {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid #d6e0ed;
  border-radius: 8px;
  background: #f8fafc;
}

.ai-routine-card > span {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ai-estimate-form .span-2 {
  grid-column: 1 / -1;
}

.ai-feedback-row {
  display: grid;
  grid-template-columns: minmax(150px, 0.35fr) minmax(260px, 1fr) auto;
  gap: 10px;
  align-items: stretch;
  margin: 12px 0 16px;
}

.ai-feedback-row textarea {
  min-height: 72px;
  resize: vertical;
}

@media (max-width: 700px) {
  .ai-employee-hero {
    align-items: stretch;
    flex-direction: column;
  }

  .ai-employee-level {
    min-width: 0;
    padding-inline-start: 0;
    padding-block-start: 14px;
    border-inline-start: 0;
    border-block-start: 1px solid rgba(255, 255, 255, 0.28);
  }

  .ai-feedback-row {
    grid-template-columns: 1fr;
  }
}
