﻿@import url("https://fonts.googleapis.com/css2?family=Alexandria:wght@300;400;500;600;700;800;900&family=Almarai:wght@300;400;700;800&family=Cairo:wght@300;400;500;600;700;800;900&family=IBM+Plex+Sans+Arabic:wght@300;400;500;600;700&family=Noto+Sans+Arabic:wght@300;400;500;600;700;800;900&family=Readex+Pro:wght@300;400;500;600;700&family=Tajawal:wght@300;400;500;700;800;900&display=swap");

:root {
  --bg: #eef2f5;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --ink: #17212b;
  --muted: #64748b;
  --line: #d9e1ea;
  --brand: #0f766e;
  --brand-2: #155e75;
  --accent: #c58a20;
  --danger: #b42318;
  --ok: #14804a;
  --warning: #b7791f;
  --shadow: 0 18px 40px rgba(22, 34, 51, 0.09);
}

/* Critical mobile navigation fix: phones always use a drawer, including landscape. */
html,
body,
#app {
  max-width: 100vw !important;
  overflow-x: hidden !important;
}

body.phone-nav {
  overflow-x: hidden !important;
}

body.phone-nav .app,
body.phone-nav .app.sidebar-is-collapsed {
  grid-template-columns: minmax(0, 1fr) !important;
  width: 100vw !important;
  max-width: 100vw !important;
  overflow-x: hidden !important;
}

body.phone-nav .main {
  width: 100vw !important;
  max-width: 100vw !important;
  min-width: 0 !important;
  margin: 0 !important;
  overflow-x: hidden !important;
}

body.phone-nav .mobile-menu-toggle {
  display: inline-grid !important;
}

body.phone-nav .sidebar,
body.phone-nav .sidebar.is-collapsed,
[dir="rtl"] body.phone-nav .sidebar,
[dir="rtl"] body.phone-nav .sidebar.is-collapsed {
  position: fixed !important;
  inset-block: 0 !important;
  inset-inline-end: 0 !important;
  inset-inline-start: auto !important;
  width: min(320px, 85vw) !important;
  min-width: min(320px, 85vw) !important;
  max-width: min(320px, 85vw) !important;
  height: 100dvh !important;
  max-height: 100dvh !important;
  padding: 14px 12px !important;
  overflow-x: hidden !important;
  overflow-y: auto !important;
  transform: translateX(105%) !important;
  transition: transform 110ms ease-out, box-shadow 110ms ease-out !important;
  z-index: 1200 !important;
}

[dir="ltr"] body.phone-nav .sidebar,
[dir="ltr"] body.phone-nav .sidebar.is-collapsed {
  inset-inline-start: 0 !important;
  inset-inline-end: auto !important;
  transform: translateX(-105%) !important;
}

body.phone-nav.mobile-nav-open .sidebar,
body.phone-nav.mobile-nav-open .sidebar.is-collapsed {
  transform: translateX(0) !important;
  box-shadow: -18px 0 36px rgba(15, 23, 42, 0.24) !important;
}

[dir="ltr"] body.phone-nav.mobile-nav-open .sidebar,
[dir="ltr"] body.phone-nav.mobile-nav-open .sidebar.is-collapsed {
  box-shadow: 18px 0 36px rgba(15, 23, 42, 0.24) !important;
}

body.phone-nav .mobile-nav-backdrop {
  position: fixed !important;
  inset: 0 !important;
  display: block !important;
  opacity: 0 !important;
  pointer-events: none !important;
  z-index: 1190 !important;
  background: rgba(15, 23, 42, 0.34) !important;
  backdrop-filter: none !important;
  transition: opacity 90ms ease-out !important;
}

body.phone-nav.mobile-nav-open .mobile-nav-backdrop {
  opacity: 1 !important;
  pointer-events: auto !important;
}

/* MOBILE SIDEBAR FINAL FIX: closed means fully outside the screen, no visible rail. */
html,
body,
#app,
#root,
.app {
  width: 100% !important;
  max-width: 100% !important;
  overflow-x: hidden !important;
}

body.phone-nav .app,
body.phone-nav .app.sidebar-is-collapsed,
body.phone-landscape-nav .app,
body.phone-landscape-nav .app.sidebar-is-collapsed {
  grid-template-columns: minmax(0, 1fr) !important;
  width: 100vw !important;
  max-width: 100vw !important;
  overflow-x: hidden !important;
}

body.phone-nav .main,
body.phone-landscape-nav .main,
body.phone-landscape-nav.mobile-nav-open .main,
[dir="ltr"] body.phone-landscape-nav.mobile-nav-open .main {
  width: 100vw !important;
  max-width: 100vw !important;
  min-width: 0 !important;
  margin: 0 !important;
  margin-inline-start: 0 !important;
  margin-inline-end: 0 !important;
  overflow-x: hidden !important;
}

body.phone-nav .sidebar,
body.phone-nav .sidebar.is-collapsed,
body.phone-landscape-nav .sidebar,
body.phone-landscape-nav .sidebar.is-collapsed,
[dir="rtl"] body.phone-nav .sidebar,
[dir="rtl"] body.phone-nav .sidebar.is-collapsed,
[dir="rtl"] body.phone-landscape-nav .sidebar,
[dir="rtl"] body.phone-landscape-nav .sidebar.is-collapsed {
  position: fixed !important;
  top: 0 !important;
  right: 0 !important;
  left: auto !important;
  inset-block: 0 !important;
  inset-inline-end: 0 !important;
  inset-inline-start: auto !important;
  width: 82vw !important;
  min-width: 0 !important;
  max-width: 340px !important;
  height: 100vh !important;
  height: 100dvh !important;
  max-height: 100dvh !important;
  padding: 14px 12px !important;
  overflow-x: hidden !important;
  overflow-y: auto !important;
  transform: translateX(100%) !important;
  visibility: hidden !important;
  pointer-events: none !important;
  transition: transform 110ms ease-out !important;
  z-index: 9999 !important;
  box-shadow: none !important;
}

[dir="ltr"] body.phone-nav .sidebar,
[dir="ltr"] body.phone-nav .sidebar.is-collapsed,
[dir="ltr"] body.phone-landscape-nav .sidebar,
[dir="ltr"] body.phone-landscape-nav .sidebar.is-collapsed {
  left: 0 !important;
  right: auto !important;
  inset-inline-start: 0 !important;
  inset-inline-end: auto !important;
  transform: translateX(-100%) !important;
}

body.phone-nav.mobile-nav-open .sidebar,
body.phone-nav.mobile-nav-open .sidebar.is-collapsed,
body.phone-nav .sidebar.open,
body.phone-nav .sidebar.is-collapsed.open,
body.phone-landscape-nav.mobile-nav-open .sidebar,
body.phone-landscape-nav.mobile-nav-open .sidebar.is-collapsed,
body.phone-landscape-nav .sidebar.open,
body.phone-landscape-nav .sidebar.is-collapsed.open,
[dir="rtl"] body.phone-nav.mobile-nav-open .sidebar,
[dir="rtl"] body.phone-nav.mobile-nav-open .sidebar.is-collapsed,
[dir="rtl"] body.phone-landscape-nav.mobile-nav-open .sidebar,
[dir="rtl"] body.phone-landscape-nav.mobile-nav-open .sidebar.is-collapsed,
[dir="ltr"] body.phone-nav.mobile-nav-open .sidebar,
[dir="ltr"] body.phone-nav.mobile-nav-open .sidebar.is-collapsed,
[dir="ltr"] body.phone-landscape-nav.mobile-nav-open .sidebar,
[dir="ltr"] body.phone-landscape-nav.mobile-nav-open .sidebar.is-collapsed {
  transform: translateX(0) !important;
  visibility: visible !important;
  pointer-events: auto !important;
  box-shadow: -18px 0 36px rgba(15, 23, 42, 0.24) !important;
}

[dir="ltr"] body.phone-nav.mobile-nav-open .sidebar,
[dir="ltr"] body.phone-nav.mobile-nav-open .sidebar.is-collapsed,
[dir="ltr"] body.phone-landscape-nav.mobile-nav-open .sidebar,
[dir="ltr"] body.phone-landscape-nav.mobile-nav-open .sidebar.is-collapsed {
  box-shadow: 18px 0 36px rgba(15, 23, 42, 0.24) !important;
}

body.phone-nav .sidebar:not(.open),
body.phone-nav:not(.mobile-nav-open) .sidebar,
body.phone-landscape-nav .sidebar:not(.open),
body.phone-landscape-nav:not(.mobile-nav-open) .sidebar {
  transform: translateX(100%) !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

[dir="ltr"] body.phone-nav .sidebar:not(.open),
[dir="ltr"] body.phone-nav:not(.mobile-nav-open) .sidebar,
[dir="ltr"] body.phone-landscape-nav .sidebar:not(.open),
[dir="ltr"] body.phone-landscape-nav:not(.mobile-nav-open) .sidebar {
  transform: translateX(-100%) !important;
}

body.phone-nav .mobile-nav-backdrop,
body.phone-landscape-nav .mobile-nav-backdrop {
  position: fixed !important;
  inset: 0 !important;
  z-index: 9998 !important;
  display: block !important;
  opacity: 0 !important;
  pointer-events: none !important;
  background: rgba(15, 23, 42, 0.34) !important;
  backdrop-filter: none !important;
  transition: opacity 90ms ease-out !important;
}

body.phone-nav.mobile-nav-open .mobile-nav-backdrop,
body.phone-landscape-nav.mobile-nav-open .mobile-nav-backdrop {
  opacity: 1 !important;
  pointer-events: auto !important;
}

body.phone-nav:not(.mobile-nav-open) .mobile-nav-backdrop,
body.phone-landscape-nav:not(.mobile-nav-open) .mobile-nav-backdrop {
  opacity: 0 !important;
  pointer-events: none !important;
}

body.phone-nav .mobile-menu-close,
body.phone-nav .sidebar-close,
body.phone-nav .sidebar-arrow,
body.phone-nav .floating-sidebar-handle,
body.phone-landscape-nav .mobile-menu-close,
body.phone-landscape-nav .sidebar-close,
body.phone-landscape-nav .sidebar-arrow,
body.phone-landscape-nav .floating-sidebar-handle {
  display: none !important;
}

body.phone-nav.mobile-nav-open .mobile-menu-close,
body.phone-nav.mobile-nav-open .sidebar-close,
body.phone-nav.mobile-nav-open .sidebar-arrow,
body.phone-nav.mobile-nav-open .floating-sidebar-handle,
body.phone-landscape-nav.mobile-nav-open .mobile-menu-close,
body.phone-landscape-nav.mobile-nav-open .sidebar-close,
body.phone-landscape-nav.mobile-nav-open .sidebar-arrow,
body.phone-landscape-nav.mobile-nav-open .floating-sidebar-handle,
body.phone-nav .sidebar.open .mobile-menu-close,
body.phone-landscape-nav .sidebar.open .mobile-menu-close {
  display: flex !important;
}

body.phone-nav .sidebar.is-collapsed .brand > div,
body.phone-nav .sidebar.is-collapsed .tenant-switcher,
body.phone-nav .sidebar.is-collapsed .erp-sidebar-search,
body.phone-nav .sidebar.is-collapsed .sidebar-search,
body.phone-nav .sidebar.is-collapsed .nav-section-title,
body.phone-nav .sidebar.is-collapsed .nav-section-count,
body.phone-nav .sidebar.is-collapsed .nav-section-arrow,
body.phone-nav .sidebar.is-collapsed .erp-sidebar-link-label,
body.phone-nav .sidebar.is-collapsed .erp-sidebar-badge,
body.phone-nav .sidebar.is-collapsed .erp-sidebar-favorite {
  display: initial !important;
}

body.phone-nav .sidebar.is-collapsed .tenant-switcher,
body.phone-nav .sidebar.is-collapsed .erp-sidebar-search,
body.phone-nav .sidebar.is-collapsed .sidebar-search {
  display: block !important;
}

body.phone-nav .sidebar .brand,
body.phone-nav .sidebar.is-collapsed .brand {
  grid-template-columns: 44px minmax(0, 1fr) !important;
  justify-items: stretch !important;
}

body.phone-nav .sidebar .erp-sidebar-tools,
body.phone-nav .sidebar.is-collapsed .erp-sidebar-tools {
  grid-template-columns: minmax(0, 1fr) 40px !important;
}

body.phone-nav .sidebar .erp-sidebar-section-toggle,
body.phone-nav .sidebar .nav-section-toggle,
body.phone-nav .sidebar.is-collapsed .erp-sidebar-section-toggle,
body.phone-nav .sidebar.is-collapsed .nav-section-toggle {
  grid-template-columns: 36px minmax(0, 1fr) auto 18px !important;
  min-height: 42px !important;
  justify-items: stretch !important;
}

body.phone-nav .sidebar .erp-sidebar-link,
body.phone-nav .sidebar .nav-button,
body.phone-nav .sidebar.is-collapsed .erp-sidebar-link,
body.phone-nav .sidebar.is-collapsed .nav-button {
  grid-template-columns: 30px minmax(0, 1fr) auto 0 !important;
  min-height: 40px !important;
  justify-items: stretch !important;
}

body.phone-nav .sidebar .erp-sidebar-section.open .erp-sidebar-section-items,
body.phone-nav .sidebar .nav-section.open .nav-section-items,
body.phone-nav .sidebar.is-collapsed .erp-sidebar-section.open .erp-sidebar-section-items,
body.phone-nav .sidebar.is-collapsed .nav-section.open .nav-section-items {
  grid-template-rows: 1fr !important;
}

body.desktop-nav .mobile-nav-backdrop {
  display: none !important;
}

body.desktop-nav .mobile-menu-toggle {
  display: none !important;
}

body.desktop-nav .app {
  grid-template-columns: var(--erp-sidebar-width, 276px) minmax(0, 1fr) !important;
}

body.desktop-nav .app.sidebar-is-collapsed {
  grid-template-columns: var(--erp-sidebar-collapsed-width, 82px) minmax(0, 1fr) !important;
}

body.desktop-nav .sidebar {
  position: sticky !important;
  inset-block-start: 0 !important;
  inset-inline-end: auto !important;
  inset-inline-start: auto !important;
  transform: none !important;
  height: 100vh !important;
  transition: width 180ms ease, min-width 180ms ease, max-width 180ms ease !important;
}

body.desktop-nav .sidebar.is-collapsed {
  transform: none !important;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", Tahoma, Arial, sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  min-height: 38px;
  padding: 8px 12px;
}

button:hover {
  border-color: #aab7c6;
}

.primary {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
}

.danger {
  background: #fff1f0;
  color: var(--danger);
  border-color: #ffd0cc;
}

.ghost {
  background: transparent;
}

.app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 292px minmax(0, 1fr);
}

.app.sidebar-is-collapsed {
  grid-template-columns: 92px minmax(0, 1fr);
}

.sidebar {
  background: #182330;
  color: #e5edf5;
  min-height: 100vh;
  padding: 18px 14px;
  position: sticky;
  top: 0;
  transition: width 220ms ease, padding 220ms ease;
}

.sidebar.is-collapsed {
  padding-inline: 10px;
}

.brand {
  display: grid;
  grid-template-columns: 48px 1fr;
  gap: 12px;
  align-items: center;
  margin-bottom: 18px;
}

.brand-mark {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff;
  font-weight: 900;
  letter-spacing: 0;
}

.brand strong {
  display: block;
  color: #fff;
  line-height: 1.2;
}

.brand small {
  color: #a9b7c6;
}

.tenant-switcher,
.login-card,
.panel,
.metric,
.modal-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.tenant-switcher {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.12);
  box-shadow: none;
  padding: 10px;
  margin-bottom: 14px;
}

.tenant-switcher label {
  display: block;
  color: #b8c4d2;
  font-size: 12px;
  margin-bottom: 6px;
}

.tenant-switcher select,
.tenant-switcher button {
  width: 100%;
}

.nav {
  display: grid;
  gap: 5px;
  max-height: calc(100vh - 210px);
  overflow: auto;
  padding-inline-end: 2px;
  scroll-behavior: smooth;
}

.sidebar-tools {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 38px;
  gap: 8px;
  align-items: center;
  margin-bottom: 10px;
}

.sidebar-search {
  width: 100%;
  min-height: 38px;
  border: 1px solid rgba(191, 219, 254, 0.2);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  padding: 8px 10px;
  outline: 0;
}

.sidebar-search::placeholder {
  color: #a9b7c6;
}

.sidebar-search:focus {
  border-color: #60a5fa;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.18);
}

.sidebar-collapse-toggle,
.nav-section-toggle {
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.06);
  color: #dbeafe;
}

.sidebar-collapse-toggle {
  width: 38px;
  min-width: 38px;
  min-height: 38px;
  padding: 0;
  border-radius: 8px;
  font-size: 18px;
}

.nav-section {
  display: grid;
  gap: 4px;
}

.nav-section-toggle {
  width: 100%;
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto 18px;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 9px 10px;
  border-radius: 8px;
  text-align: start;
}

.nav-section-toggle:hover,
.nav-section.open > .nav-section-toggle,
.nav-section.contains-active > .nav-section-toggle {
  background: rgba(30, 64, 175, 0.34);
  border-color: rgba(96, 165, 250, 0.38);
  color: #fff;
}

.nav-section-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 750;
}

.nav-section-icon {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
}

.nav-section-count {
  min-width: 22px;
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  color: #bfdbfe;
  font-size: 11px;
  text-align: center;
}

.nav-section-arrow {
  display: inline-grid;
  place-items: center;
  color: #93c5fd;
  transition: transform 180ms ease;
}

.nav-section.open .nav-section-arrow {
  transform: rotate(180deg);
}

.nav-section-items {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 220ms ease;
}

.nav-section.open .nav-section-items {
  grid-template-rows: 1fr;
}

.nav-section-items-inner {
  overflow: hidden;
  display: grid;
  gap: 4px;
  padding-inline-start: 10px;
}

[dir="rtl"] .nav-section-items-inner {
  padding-inline-start: 0;
  padding-inline-end: 10px;
}

.nav-empty {
  border: 1px dashed rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  padding: 14px;
  color: #b8c4d2;
  text-align: center;
}

.nav-button {
  width: 100%;
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 8px;
  align-items: center;
  border: 0;
  color: #d6dee8;
  background: transparent;
  text-align: start;
  padding: 10px;
  border-radius: 8px;
  border-inline-start: 3px solid transparent;
}

.nav-button.active,
.nav-button:hover {
  background: rgba(59, 130, 246, 0.18);
  color: #fff;
  border-inline-start-color: #60a5fa;
}

.status-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0 14px;
}

.status-tabs button {
  min-height: 34px;
  padding: 7px 11px;
  border-radius: 8px;
  border: 1px solid #dbe7f6;
  background: #fff;
  color: #334155;
}

.status-tabs button.active {
  border-color: #60a5fa;
  background: #eff6ff;
  color: #1d4ed8;
}

.status-tabs b {
  display: inline-grid;
  place-items: center;
  min-width: 22px;
  margin-inline-start: 4px;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(37, 99, 235, 0.1);
  font-size: 11px;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 12px;
  font-weight: 750;
}

.status-pending {
  background: #fff7ed;
  border-color: #fed7aa;
  color: #9a3412;
}

.status-approved {
  background: #eff6ff;
  border-color: #bfdbfe;
  color: #1d4ed8;
}

.status-active {
  background: #ecfdf5;
  border-color: #bbf7d0;
  color: #047857;
}

.status-rejected {
  background: #fef2f2;
  border-color: #fecaca;
  color: #b91c1c;
}

.status-suspended {
  background: #f8fafc;
  border-color: #cbd5e1;
  color: #475569;
}

.sidebar.is-collapsed .brand {
  grid-template-columns: 1fr;
  justify-items: center;
}

.sidebar.is-collapsed .brand > div,
.sidebar.is-collapsed .tenant-switcher,
.sidebar.is-collapsed .sidebar-search,
.sidebar.is-collapsed .nav-section-title,
.sidebar.is-collapsed .nav-section-count,
.sidebar.is-collapsed .nav-section-arrow,
.sidebar.is-collapsed .nav-button span:nth-child(2),
.sidebar.is-collapsed .nav-badge {
  display: none;
}

.sidebar.is-collapsed .sidebar-tools {
  grid-template-columns: 1fr;
}

.sidebar.is-collapsed .nav-section-toggle,
.sidebar.is-collapsed .nav-button {
  grid-template-columns: 1fr;
  justify-items: center;
  padding-inline: 8px;
}

.sidebar.is-collapsed .nav-section-items-inner {
  padding-inline: 0;
}

.main {
  min-width: 0;
  padding: 22px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 16px;
}

/* Project controls: isolated styles to avoid changing existing modules. */
.project-controls-hero .panel-head {
  align-items: end;
  gap: 16px;
}

.project-controls-hero select {
  min-width: min(340px, 100%);
}

.project-controls-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding-top: 14px;
  border-top: 1px solid var(--border, #d9e2ef);
}

.project-controls-tabs button.active {
  color: #fff;
  background: #1767e8;
  border-color: #1767e8;
}

.project-controls-data-panel > .panel-head {
  justify-content: flex-start;
  gap: 14px;
}

.project-controls-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(280px, .6fr);
  gap: 16px;
  margin-bottom: 16px;
}

.project-index-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 10px;
}

.project-index-grid > div {
  padding: 14px;
  border: 1px solid var(--border, #d9e2ef);
  border-radius: 8px;
  background: var(--surface-muted, #f7f9fc);
}

.project-index-grid span,
.project-index-grid small,
.project-progress-comparison span {
  display: block;
  color: var(--muted, #5f6f86);
}

.project-index-grid strong {
  display: block;
  margin: 7px 0 3px;
  font-size: 1.2rem;
}

.project-index-grid .success strong { color: #07824c; }
.project-index-grid .warning strong { color: #a85d00; }
.project-index-grid .danger strong { color: #c42b2b; }

.project-progress-comparison {
  display: grid;
  gap: 22px;
}

.project-progress-comparison > div {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 14px;
}

.project-progress-comparison i {
  grid-column: 1 / -1;
  height: 10px;
  overflow: hidden;
  border-radius: 5px;
  background: #e5ebf4;
}

.project-progress-comparison b {
  display: block;
  height: 100%;
  background: #1767e8;
}

.project-gantt {
  min-width: 720px;
  overflow: hidden;
}

.project-gantt-row {
  display: grid;
  grid-template-columns: minmax(210px, .7fr) minmax(320px, 1fr) 54px;
  align-items: center;
  gap: 14px;
  min-height: 58px;
  border-bottom: 1px solid var(--border, #e1e7f0);
}

.project-gantt-label small {
  display: block;
  margin-top: 4px;
  color: var(--muted, #607089);
}

.project-gantt-track {
  position: relative;
  height: 22px;
  border-radius: 5px;
  background: repeating-linear-gradient(90deg, #edf1f7 0, #edf1f7 calc(10% - 1px), #dce4ef 10%);
}

.project-gantt-track > span {
  position: absolute;
  top: 3px;
  height: 16px;
  min-width: 4px;
  overflow: hidden;
  border-radius: 4px;
  background: #a9c8f7;
}

.project-gantt-track i {
  display: block;
  height: 100%;
  background: #1767e8;
}

.project-gantt-row.is-critical .project-gantt-track > span { background: #f2b9b9; }
.project-gantt-row.is-critical .project-gantt-track i { background: #c93434; }

@media (max-width: 900px) {
  .project-controls-grid { grid-template-columns: 1fr; }
  .project-index-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .project-controls-hero .panel-head { align-items: stretch; }
}

@media (max-width: 560px) {
  .project-index-grid { grid-template-columns: 1fr; }
}

.telegram-settings-panel,
.employee-telegram-panel {
  border-color: #dbeafe;
}

.telegram-settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  margin: 12px 0;
}

.telegram-settings-grid article {
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 12px;
  background: #f8fafc;
}

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

.telegram-settings-grid strong {
  display: block;
  color: #0f172a;
  margin-top: 4px;
  word-break: break-word;
}

.telegram-permissions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0;
}

.telegram-permissions span {
  border: 1px solid #bfdbfe;
  border-radius: 999px;
  background: #eff6ff;
  color: #1d4ed8;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 700;
}

.telegram-link-message {
  display: grid;
  gap: 8px;
  margin: 12px 0;
}

.telegram-link-message textarea {
  width: 100%;
  resize: vertical;
  direction: rtl;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 10px;
  font: inherit;
  background: #fff;
}

.telegram-command-center {
  display: grid;
  gap: 14px;
}

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

.telegram-health-grid article {
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 12px;
  background: #fff;
}

.telegram-health-grid article span,
.telegram-health-grid article small {
  display: block;
  color: #64748b;
}

.telegram-health-grid article strong {
  display: block;
  margin: 5px 0;
  color: #0f172a;
}

.telegram-health-grid article.is-ok {
  border-color: rgba(16, 185, 129, 0.32);
  background: rgba(16, 185, 129, 0.07);
}

.telegram-health-grid article.is-warning {
  border-color: rgba(245, 158, 11, 0.36);
  background: rgba(245, 158, 11, 0.08);
}

.telegram-quick-commands {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.telegram-quick-commands code {
  direction: ltr;
  border: 1px solid #e2e8f0;
  border-radius: 999px;
  padding: 7px 10px;
  background: #f8fafc;
  color: #0f172a;
  font-size: 12px;
}

.telegram-alert-strip {
  margin-bottom: 12px;
  border: 1px solid rgba(37, 99, 235, 0.24);
  border-radius: 8px;
  padding: 10px 12px;
  background: rgba(37, 99, 235, 0.07);
  color: #1e3a8a;
  font-weight: 700;
}

.button-like {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 8px 12px;
  color: #0f172a;
  background: #fff;
  text-decoration: none;
  font-weight: 700;
}

/* Final override: draggable AI assistant floating button. Keep below all assistant/mobile rules. */
.assistant-widget {
  position: fixed !important;
  inset: 0 auto auto 0 !important;
  width: max-content !important;
  height: max-content !important;
  max-width: none !important;
  z-index: 12010 !important;
  transform: translate3d(var(--assistant-fab-x, calc(100vw - 96px)), var(--assistant-fab-y, calc(100vh - 96px)), 0) !important;
  pointer-events: none !important;
  will-change: transform;
  isolation: isolate;
}

.assistant-widget .assistant-fab {
  position: relative !important;
  inset: auto !important;
  width: 62px !important;
  height: 62px !important;
  pointer-events: auto !important;
  touch-action: none !important;
  user-select: none !important;
  -webkit-user-select: none !important;
  -webkit-tap-highlight-color: transparent !important;
  cursor: grab !important;
  will-change: transform;
}

.assistant-widget .assistant-fab:active,
.assistant-widget.is-dragging .assistant-fab {
  cursor: grabbing !important;
  transform: scale(1.045) !important;
  box-shadow: 0 24px 58px rgba(37, 99, 235, 0.42) !important;
}

body.assistant-fab-dragging {
  cursor: grabbing;
  overscroll-behavior: none;
}

.assistant-widget .assistant-panel {
  pointer-events: auto !important;
  inset: auto !important;
  bottom: 76px !important;
  right: auto !important;
  left: 0 !important;
}

.assistant-widget.open-left .assistant-panel {
  left: auto !important;
  right: 0 !important;
}

.assistant-widget:not(.open-up) .assistant-panel {
  top: 76px !important;
  bottom: auto !important;
}

.assistant-widget.open-up .assistant-panel {
  top: auto !important;
  bottom: 76px !important;
}

@media (max-width: 768px), (pointer: coarse) and (max-width: 980px) {
  .assistant-widget:not(.is-open) {
    position: fixed !important;
    inset: 0 auto auto 0 !important;
    width: max-content !important;
    max-width: none !important;
    transform: translate3d(var(--assistant-fab-x, calc(100vw - 84px)), var(--assistant-fab-y, calc(100dvh - 84px)), 0) !important;
    pointer-events: none !important;
    z-index: 12010 !important;
  }

  .assistant-widget:not(.is-open) .assistant-fab {
    display: grid !important;
    position: relative !important;
    inset: auto !important;
    width: 56px !important;
    height: 56px !important;
    pointer-events: auto !important;
  }

  .assistant-widget.is-open {
    position: fixed !important;
    inset: 0 !important;
    width: 100vw !important;
    height: 100dvh !important;
    max-width: 100vw !important;
    transform: none !important;
    pointer-events: none !important;
    z-index: 13000 !important;
  }

  .assistant-widget.is-open .assistant-panel {
    position: fixed !important;
    inset: auto 0 0 0 !important;
    width: 100vw !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
    pointer-events: auto !important;
  }
}

/* Auth/public pages must scroll naturally even though the app shell locks body scroll. */
html.auth-screen-active,
html.auth-screen-active body {
  height: auto !important;
  min-height: 100% !important;
  max-height: none !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  overscroll-behavior-y: auto !important;
}

html.auth-screen-active #app {
  width: 100% !important;
  min-height: 100dvh !important;
  height: auto !important;
  max-height: none !important;
  overflow-y: visible !important;
  overflow-x: hidden !important;
}

html.auth-screen-active .login-screen,
html.auth-screen-active .public-auth-screen,
html.auth-screen-active .public-register-screen,
html.auth-screen-active .login-screen.with-landing {
  width: 100% !important;
  min-height: 100dvh !important;
  height: auto !important;
  max-height: none !important;
  overflow: visible !important;
  align-items: flex-start !important;
  align-content: flex-start !important;
  justify-content: flex-start !important;
  box-sizing: border-box !important;
}

html.auth-screen-active .login-card,
html.auth-screen-active .modern-login-card,
html.auth-screen-active .public-register-card,
html.auth-screen-active .landing-panel,
html.auth-screen-active .pricing-page,
html.auth-screen-active .pricing-section,
html.auth-screen-active .pricing-grid,
html.auth-screen-active .pricing-card {
  height: auto !important;
  min-height: 0 !important;
  max-height: none !important;
  overflow: visible !important;
  box-sizing: border-box !important;
}

html.auth-screen-active .pricing-grid {
  display: grid !important;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)) !important;
  gap: 18px !important;
}

@media (max-width: 768px) {
  html.auth-screen-active .login-screen,
  html.auth-screen-active .public-auth-screen,
  html.auth-screen-active .public-register-screen,
  html.auth-screen-active .login-screen.with-landing {
    padding: 16px !important;
  }
}

/* Global UX polish layer: visual/performance only, keeps data, routes and app logic intact. */
:root {
  --ux-bg: #f8fafc;
  --ux-surface: #ffffff;
  --ux-surface-soft: #f1f5f9;
  --ux-text: #0f172a;
  --ux-muted: #64748b;
  --ux-border: #e2e8f0;
  --ux-primary: #2563eb;
  --ux-primary-soft: rgba(37, 99, 235, 0.10);
  --ux-success: #16a34a;
  --ux-warning: #f97316;
  --ux-danger: #dc2626;
  --ux-radius: 16px;
  --ux-radius-sm: 10px;
  --ux-shadow: 0 10px 28px rgba(15, 23, 42, 0.08);
  --ux-shadow-soft: 0 6px 18px rgba(15, 23, 42, 0.06);
  --ux-transition: background-color .16s ease, border-color .16s ease, color .16s ease, box-shadow .16s ease, opacity .16s ease, transform .16s ease;
}

html,
body,
#app {
  max-width: 100%;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  color: var(--text-primary, var(--ux-text));
  background: var(--bg-main, var(--ux-bg));
}

img,
video,
canvas,
svg {
  max-width: 100%;
}

p,
span,
label,
button,
input,
textarea,
select,
h1,
h2,
h3,
h4,
h5,
h6,
a,
td,
th {
  text-rendering: optimizeLegibility;
}

button,
a,
input,
select,
textarea,
.interactive-element,
.nav-button,
.menu-item,
.action-btn,
.card,
.metric,
[role="button"] {
  -webkit-tap-highlight-color: transparent;
}

button,
a[href],
.interactive-element,
.nav-button,
.menu-item,
.action-btn,
.card,
.metric,
[role="button"] {
  transition: var(--ux-transition) !important;
  touch-action: manipulation;
}

button:focus-visible,
a[href]:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
.interactive-element:focus-visible,
[role="button"]:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.28) !important;
  outline-offset: 2px !important;
}

button:disabled,
[aria-disabled="true"],
.disabled {
  cursor: not-allowed !important;
  opacity: .72 !important;
  transform: none !important;
}

.card,
.panel,
.metric,
.modal-card,
.table-wrap,
.dashboard-card,
.kpi-card {
  border-color: var(--border-color, var(--ux-border));
  box-shadow: var(--ux-shadow-soft);
}

.table-wrap,
.responsive-table-wrap {
  max-width: 100%;
  overflow-x: auto;
  overflow-y: visible;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-inline: contain;
}

table {
  max-width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

th {
  color: var(--text-secondary, #334155);
  font-weight: 800;
  background: rgba(248, 250, 252, .92);
}

td {
  color: var(--text-primary, var(--ux-text));
}

.empty-state,
.provider-empty,
.social-empty,
.admin-empty {
  border: 1px dashed var(--border-color, var(--ux-border));
  border-radius: var(--ux-radius);
  background: rgba(255, 255, 255, .72);
}

.modal,
.modal-overlay,
.drawer,
.overlay {
  overscroll-behavior: contain;
}

.modal-card {
  max-width: min(96vw, 980px);
  max-height: 90dvh;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

.toast,
.notification-toast {
  box-shadow: var(--ux-shadow);
  border: 1px solid rgba(148, 163, 184, .22);
}

@media (hover: hover) and (pointer: fine) {
  button:not(:disabled):hover,
  a[href]:hover,
  .interactive-element:not(:disabled):hover,
  .nav-button:hover,
  .menu-item:hover,
  .action-btn:hover {
    box-shadow: 0 0 0 1px rgba(59, 130, 246, .18), 0 10px 22px rgba(37, 99, 235, .10);
  }
}

button:not(:disabled):active,
a[href]:active,
.interactive-element:not(:disabled):active,
.nav-button:active,
.menu-item:active,
.action-btn:active {
  transform: translateY(1px);
}

@media (max-width: 768px), (hover: none) {
  *,
  *::before,
  *::after {
    transition-duration: .12s !important;
    animation-duration: .16s !important;
  }

  body {
    background-attachment: scroll !important;
  }

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

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

  .card,
  .metric,
  .panel,
  .modal-card,
  .table-wrap,
  .dashboard-card,
  .kpi-card,
  .sidebar,
  .topbar,
  .navbar {
    box-shadow: 0 6px 18px rgba(15, 23, 42, .08) !important;
    filter: none !important;
  }

  .ux-glass,
  .glass,
  .modal,
  .modal-card,
  .sidebar,
  .topbar,
  .navbar {
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
  }

  .modal-card {
    width: 100%;
    max-width: 100%;
    max-height: 92dvh;
    border-radius: 18px 18px 0 0;
  }

  .table-wrap,
  .responsive-table-wrap {
    border-radius: 14px;
  }

  th,
  td {
    white-space: nowrap;
  }

  button,
  input,
  select,
  textarea,
  .action-btn,
  .nav-button,
  .menu-item {
    min-height: 42px;
  }
}

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

/* Internal chat calls: mobile-only full screen and overlap prevention */
@media (max-width: 700px), (pointer: coarse) and (max-width: 980px) {
  .chat-header {
    align-items: flex-start;
  }

  .chat-header-actions {
    width: 100%;
    margin-inline-start: 0;
    justify-content: flex-start;
  }

  .chat-header-actions .chat-call-button {
    width: 44px;
    min-width: 44px;
    min-height: 44px;
  }

  .call-overlay {
    padding: 0 !important;
    place-items: stretch !important;
  }

  .call-card {
    width: 100vw !important;
    height: 100dvh !important;
    min-height: 100dvh !important;
    border-radius: 0 !important;
    padding: 14px !important;
  }

  .call-video-stage {
    min-height: 0 !important;
  }

  .call-video-stage video[data-call-remote-video] {
    min-height: 0 !important;
    height: 100% !important;
  }

  .call-video-stage video[data-call-local-video] {
    width: 104px !important;
    inset-inline-end: 10px !important;
    inset-block-end: 10px !important;
  }

  .call-card footer {
    padding-bottom: calc(8px + env(safe-area-inset-bottom));
  }

  .chat-call-log {
    grid-template-columns: 34px minmax(0, 1fr);
  }

  .chat-call-log button {
    grid-column: 1 / -1;
  }
}

.app-back-button {
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--brand);
  font-size: 28px;
  font-weight: 800;
  line-height: 1;
  box-shadow: 0 8px 18px rgba(15, 23, 42, .06);
  transition:
    background-color .15s ease,
    border-color .15s ease,
    color .15s ease,
    box-shadow .15s ease;
}

.app-back-button:hover,
.app-back-button:focus-visible {
  border-color: rgba(37, 99, 235, .45);
  background: rgba(37, 99, 235, .08);
  outline: none;
}

.app-back-button:active {
  box-shadow: 0 4px 12px rgba(15, 23, 42, .08);
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  font-size: 30px;
  margin-bottom: 6px;
}

h2 {
  font-size: 20px;
}

.muted {
  color: var(--muted);
}

.actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.language {
  min-width: 118px;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.metric {
  padding: 14px;
}

.metric span {
  color: var(--muted);
  font-size: 13px;
}

.metric strong {
  display: block;
  font-size: 25px;
  margin-top: 8px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(320px, 0.75fr);
  gap: 14px;
}

.panel {
  padding: 16px;
  min-width: 0;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
}

.toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 12px;
}

.search {
  min-width: 240px;
  flex: 1;
}

input,
select,
textarea {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  min-height: 38px;
  padding: 8px 10px;
  width: 100%;
}

textarea {
  min-height: 98px;
  resize: vertical;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

th,
td {
  padding: 11px 10px;
  border-bottom: 1px solid var(--line);
  text-align: start;
  vertical-align: top;
}

th {
  background: var(--surface-2);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

tr:last-child td {
  border-bottom: 0;
}

.row-actions {
  display: flex;
  gap: 6px;
  white-space: nowrap;
}

.icon-action {
  width: 38px;
  min-width: 38px;
  padding: 7px;
  font-weight: 800;
  color: var(--brand);
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 4px 9px;
  min-height: 26px;
  background: #e8f7f2;
  color: var(--ok);
  font-size: 12px;
  white-space: nowrap;
}

.badge.warning {
  background: #fff4dc;
  color: var(--warning);
}

.badge.danger {
  background: #ffe8e5;
  color: var(--danger);
}

.side-grid {
  display: grid;
  gap: 10px;
}

.important-alerts-panel {
  margin-top: 16px;
}

.important-alerts-list {
  display: grid;
  gap: 8px;
}

.important-alert {
  width: 100%;
  display: grid;
  grid-template-columns: 120px minmax(180px, 1fr) 130px 150px;
  gap: 12px;
  align-items: center;
  text-align: start;
  padding: 11px 12px;
  border-inline-start-width: 4px;
}

.important-alert.is-expired {
  border-color: #efb1aa;
  border-inline-start-color: var(--danger);
  background: #fff5f3;
}

.important-alert.is-warning {
  border-color: #efd5a1;
  border-inline-start-color: var(--warning);
  background: #fff9ed;
}

.alert-status {
  font-weight: 800;
  color: var(--warning);
}

.is-expired .alert-status,
.is-expired .alert-days {
  color: var(--danger);
}

.alert-main {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.alert-main small,
.alert-date {
  color: var(--muted);
}

.alert-days {
  color: var(--warning);
  font-weight: 700;
}

.insight {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
}

.chart {
  height: 170px;
  display: grid;
  align-items: end;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.bar {
  border-radius: 6px 6px 0 0;
  background: linear-gradient(180deg, var(--brand), var(--accent));
  min-height: 18px;
}

.login-screen {
  position: relative;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  overflow: hidden;
  background:
    linear-gradient(145deg, rgba(13, 30, 40, 0.96), rgba(28, 47, 55, 0.93)),
    #172832;
}

.login-cinematic {
  position: fixed;
  inset: 0;
  z-index: 20;
  overflow: hidden;
  background: #101820;
  transform: translateX(0);
  opacity: 1;
  transition:
    transform 1050ms cubic-bezier(0.72, 0, 0.2, 1),
    opacity 600ms ease 420ms;
  will-change: transform, opacity;
}

.login-intro-video {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  object-position: center;
}

.login-video-shade {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(6, 14, 20, 0.66), rgba(6, 14, 20, 0.08) 58%, rgba(6, 14, 20, 0.28)),
    linear-gradient(0deg, rgba(6, 14, 20, 0.48), transparent 45%);
}

.login-video-brand {
  position: absolute;
  inset-inline-start: clamp(24px, 6vw, 88px);
  inset-block-end: clamp(34px, 9vh, 100px);
  display: flex;
  align-items: center;
  gap: 15px;
  color: #fff;
  text-shadow: 0 2px 20px rgba(0, 0, 0, 0.45);
}

.login-video-brand .brand-mark {
  width: 54px;
  height: 54px;
  border: 1px solid rgba(255, 255, 255, 0.62);
  background: rgba(15, 118, 110, 0.78);
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.24);
  backdrop-filter: blur(10px);
}

.login-video-brand strong,
.login-video-brand small {
  display: block;
}

.login-video-brand strong {
  font-size: clamp(21px, 3vw, 36px);
}

.login-video-brand small {
  margin-top: 4px;
  color: rgba(255, 255, 255, 0.78);
  font-size: 14px;
}

.login-skip {
  position: absolute;
  inset-block-start: 24px;
  inset-inline-end: 24px;
  color: #fff;
  border-color: rgba(255, 255, 255, 0.52);
  background: rgba(11, 24, 31, 0.55);
  backdrop-filter: blur(10px);
}

.login-skip:hover {
  background: rgba(15, 118, 110, 0.82);
}

.login-screen.intro-complete .login-cinematic {
  transform: translateX(105vw) scale(0.96);
  opacity: 0;
  pointer-events: none;
}

.login-card {
  position: relative;
  z-index: 2;
  width: min(960px, 100%);
  display: grid;
  grid-template-columns: 1fr 1fr;
  overflow: hidden;
  box-shadow: 0 30px 80px rgba(2, 12, 18, 0.38);
  transform: translateY(34px) scale(0.985);
  opacity: 0;
}

.login-screen.intro-complete .login-card {
  animation: login-card-enter 760ms cubic-bezier(0.2, 0.75, 0.25, 1) 430ms both;
}

@keyframes login-card-enter {
  to {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

.login-hero {
  padding: 32px;
  color: #fff;
  background:
    linear-gradient(145deg, rgba(15, 118, 110, 0.96), rgba(31, 58, 74, 0.98)),
    #184c50;
}

.login-hero h1 {
  font-size: 38px;
}

.login-form {
  padding: 32px;
  background: #fff;
  max-height: 88vh;
  overflow: auto;
}

.login-screen.intro-complete .login-form > *,
.login-screen.intro-complete .login-form .field {
  animation: login-field-enter 520ms ease both;
}

.login-screen.intro-complete .login-form > *:nth-child(1) { animation-delay: 720ms; }
.login-screen.intro-complete .login-form > *:nth-child(2) { animation-delay: 790ms; }
.login-screen.intro-complete .login-form > *:nth-child(3) { animation-delay: 860ms; }
.login-screen.intro-complete .login-form > *:nth-child(4) { animation-delay: 930ms; }
.login-screen.intro-complete .login-form .field:nth-child(1) { animation-delay: 930ms; }
.login-screen.intro-complete .login-form .field:nth-child(2) { animation-delay: 1000ms; }
.login-screen.intro-complete .login-form .field:nth-child(3) { animation-delay: 1070ms; }
.login-screen.intro-complete .login-form .field:nth-child(4) { animation-delay: 1140ms; }
.login-screen.intro-complete .login-form .field:nth-child(5) { animation-delay: 1210ms; }
.login-screen.intro-complete .login-form .field:nth-child(6) { animation-delay: 1280ms; }

@keyframes login-field-enter {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 16px;
  padding: 4px;
  border-radius: 8px;
  background: var(--surface-2);
}

.auth-tabs button {
  border-color: transparent;
  background: transparent;
}

.auth-tabs button.active {
  background: #fff;
  color: var(--brand);
  border-color: var(--line);
  font-weight: 700;
}

.join-type-tabs {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
  margin-bottom: 14px;
  padding: 6px;
  border-radius: 14px;
  background: #eff6ff;
}

.join-type-tabs button {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: #1e40af;
  font-weight: 800;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.join-type-tabs button:hover {
  background: #dbeafe;
  transform: translateY(-1px);
}

.join-type-tabs button.active {
  background: #2563eb;
  color: #fff;
  box-shadow: 0 10px 22px rgba(37, 99, 235, 0.22);
}

.join-type-cards {
  display: grid;
  grid-template-columns: repeat(5, minmax(116px, 1fr));
  gap: 10px;
  margin: 0 0 16px;
}

.join-type-card {
  min-height: 118px;
  display: grid;
  align-content: start;
  gap: 7px;
  padding: 13px 11px;
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: 12px;
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
  color: #0f172a;
  text-align: start;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.06);
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.join-type-card:hover {
  transform: translateY(-2px);
  border-color: rgba(37, 99, 235, 0.38);
  box-shadow: 0 16px 34px rgba(37, 99, 235, 0.12);
}

.join-type-card.active {
  color: #fff;
  border-color: #2563eb;
  background: linear-gradient(135deg, #0f172a 0%, #2563eb 100%);
  box-shadow: 0 18px 38px rgba(37, 99, 235, 0.28);
}

.join-type-card span {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: rgba(37, 99, 235, 0.1);
  font-size: 20px;
}

.join-type-card.active span {
  background: rgba(255, 255, 255, 0.18);
}

.join-type-card strong {
  font-size: 14px;
}

.join-type-card small {
  color: #64748b;
  line-height: 1.5;
}

.join-type-card.active small {
  color: rgba(255, 255, 255, 0.82);
}

@media (max-width: 720px) {
  .join-type-tabs {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .join-type-cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .join-type-card {
    min-height: 106px;
  }
}

.auth-notice {
  padding: 11px 12px;
  margin-bottom: 12px;
  border: 1px solid #aad2c9;
  border-radius: 8px;
  background: #edf8f6;
  color: #155e55;
}

.cloud-note {
  padding: 8px 10px;
  border-inline-start: 3px solid var(--warning);
  background: #fff9eb;
}

.login-motivation {
  margin: 0 0 14px;
  padding: 10px 12px;
  border-inline-start: 3px solid var(--brand);
  background: #edf8f6;
  color: #155e55;
  line-height: 1.7;
  font-weight: 700;
}

.auth-submit {
  width: 100%;
  margin-top: 14px;
}

.remember-login {
  min-height: 38px;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  color: var(--muted);
  font-weight: 700;
}

.remember-login input {
  width: 18px;
  height: 18px;
  accent-color: var(--brand);
}

.google-auth-button {
  width: 100%;
  min-height: 44px;
  margin-top: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border-color: #cbd5df;
  background: #fff;
  color: #17212b;
  font-weight: 700;
}

.auth-setup-note {
  margin-bottom: 14px;
  padding: 12px 14px;
  border-inline-start: 4px solid #2563eb;
  border-radius: 6px;
  background: #eff6ff;
  color: #1e3a8a;
}

.auth-setup-note strong {
  display: block;
  margin-bottom: 4px;
}

.auth-setup-note p {
  margin: 0;
  color: #475569;
  font-size: 0.9rem;
  line-height: 1.7;
}

.google-auth-button:hover {
  border-color: #94a3b8;
  background: #f8fafc;
}

.google-auth-button span {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #1a73e8;
  font: 800 17px Arial, sans-serif;
  background: #fff;
  box-shadow: 0 0 0 1px #d7dee7;
}

.forgot-password-button,
.auth-back-button {
  padding: 4px 0;
  margin-top: 2px;
  border: 0;
  color: var(--brand);
  background: transparent;
  font-weight: 700;
}

.firebase-setup-button {
  width: 100%;
  margin-bottom: 12px;
  border-color: #bfdbfe;
  background: #eff6ff;
  color: var(--brand);
}

.firebase-setup-button:hover {
  border-color: var(--brand);
  background: #dbeafe;
}

.forgot-password-button {
  display: block;
  margin-inline-start: auto;
}

.auth-back-button {
  width: 100%;
  margin-top: 10px;
}

.forgot-password-button:hover,
.auth-back-button:hover {
  text-decoration: underline;
  background: transparent;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.field-full {
  grid-column: 1 / -1;
}

.field label {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 5px;
}

.checkbox-field label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  font-weight: 600;
}

.checkbox-field input {
  width: 18px;
  min-height: 18px;
  margin: 0;
}

.custody-history {
  max-height: 620px;
  overflow: auto;
  padding-inline-end: 3px;
}

.modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(10, 18, 28, 0.48);
  padding: 18px;
  z-index: 30;
}

.modal-card {
  width: min(900px, 100%);
  max-height: 90vh;
  overflow: auto;
  padding: 18px;
}

.modal-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
}

.pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
}

.attendance-date-input,
.month-input {
  width: 180px;
}

.attendance-list {
  display: grid;
  gap: 8px;
}

.attendance-row {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto 90px;
  gap: 14px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.employee-identity,
.employee-profile-head {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.employee-identity small,
.table-subtitle {
  display: block;
  color: var(--muted);
  margin-top: 3px;
}

.employee-avatar {
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 50%;
  background: #d9ece9;
  color: var(--brand);
  font-weight: 800;
}

.employee-avatar.large {
  width: 58px;
  height: 58px;
  flex-basis: 58px;
  font-size: 20px;
}

.employee-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.attendance-options {
  display: grid;
  grid-template-columns: repeat(3, minmax(78px, 1fr));
  gap: 6px;
}

.attendance-options button.selected.present {
  background: #dff5e9;
  border-color: #76c99b;
  color: #11633a;
}

.attendance-options button.selected.absent {
  background: #ffe5e2;
  border-color: #ef9a91;
  color: #9f271c;
}

.attendance-options button.selected.leave {
  background: #dbeafe;
  border-color: #60a5fa;
  color: #1d4ed8;
}

.attendance-options button.selected.halfday {
  background: #fef3c7;
  border-color: #facc15;
  color: #854d0e;
}

.attendance-options button.selected.late {
  background: #ffedd5;
  border-color: #fb923c;
  color: #9a3412;
}

.attendance-options .clear-attendance {
  color: #64748b;
}

.registration-time {
  text-align: center;
}

.employee-profile {
  width: min(1180px, 100%);
}

.residency-panel {
  margin-bottom: 12px;
}

.residency-details-grid,
.asset-detail-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.residency-details-grid > div,
.asset-detail-grid > div {
  display: grid;
  gap: 5px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-2);
}

.residency-details-grid span,
.asset-detail-grid span {
  color: var(--muted);
  font-size: 13px;
}

.residency-notes,
.asset-detail-full {
  grid-column: 1 / -1;
}

.fixed-asset-profile {
  width: min(1050px, 100%);
}

.asset-vehicle-panel {
  margin-top: 14px;
  box-shadow: none;
}

.profile-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(260px, 0.5fr);
  gap: 12px;
}

.profile-panel {
  box-shadow: none;
}

.attendance-year {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.month-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px;
  background: var(--surface-2);
}

.month-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 7px;
}

.day-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(22px, 1fr));
  gap: 3px;
}

.day-cell {
  aspect-ratio: 1;
  min-width: 22px;
  display: grid;
  place-items: center;
  border-radius: 4px;
  background: #e9eef3;
  color: #7b8794;
  font-size: 11px;
  font-weight: 700;
}

.day-cell.present {
  background: #dff5e9;
  color: #11633a;
}

.day-cell.absent {
  background: #ffe5e2;
  color: #9f271c;
}

.day-cell.leave {
  background: #dbeafe;
  color: #1d4ed8;
}

.day-cell.halfday {
  background: #fef3c7;
  color: #854d0e;
}

.day-cell.late {
  background: #ffedd5;
  color: #9a3412;
}

.view-month-button {
  width: 100%;
  margin-top: 8px;
  border-color: #bfdbfe;
  background: #eff6ff;
  color: #1e3a8a;
  font-weight: 700;
}

.view-month-button:hover {
  border-color: #2563eb;
  background: #dbeafe;
}

.attendance-month-modal {
  width: min(1240px, 100%);
}

.attendance-month-stats {
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.attendance-month-stats article {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 66px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.attendance-month-stats article span {
  color: var(--muted);
  font-size: 0.78rem;
}

.attendance-month-stats article strong {
  font-size: 1.35rem;
}

.attendance-month-stats .present { border-inline-start: 4px solid #16a34a; }
.attendance-month-stats .absent { border-inline-start: 4px solid #dc2626; }
.attendance-month-stats .leave { border-inline-start: 4px solid #2563eb; }
.attendance-month-stats .halfday { border-inline-start: 4px solid #eab308; }
.attendance-month-stats .late { border-inline-start: 4px solid #f97316; }

.monthly-attendance-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(360px, 0.75fr);
  gap: 12px;
}

.attendance-month-calendar,
.monthly-payroll-form {
  min-width: 0;
  box-shadow: none;
}

.month-day-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(48px, 1fr));
  gap: 6px;
}

.month-day-button {
  display: grid;
  place-items: center;
  gap: 3px;
  min-height: 58px;
  padding: 6px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #e9eef3;
  color: #64748b;
}

.month-day-button small {
  font-size: 0.68rem;
}

.month-day-button strong {
  font-size: 1rem;
}

.month-day-button.present { border-color: #86efac; background: #dcfce7; color: #166534; }
.month-day-button.absent { border-color: #fca5a5; background: #fee2e2; color: #991b1b; }
.month-day-button.leave { border-color: #93c5fd; background: #dbeafe; color: #1d4ed8; }
.month-day-button.halfday { border-color: #fde047; background: #fef9c3; color: #854d0e; }
.month-day-button.late { border-color: #fdba74; background: #ffedd5; color: #9a3412; }

.month-day-button.is-selected {
  outline: 3px solid rgba(37, 99, 235, 0.22);
  border-color: #2563eb;
  transform: translateY(-1px);
}

.day-status-picker {
  display: grid;
  gap: 10px;
  margin-top: 12px;
  padding: 12px;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  background: #eff6ff;
}

.day-status-picker > div:first-child {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.day-status-picker .attendance-options {
  grid-template-columns: repeat(3, minmax(90px, 1fr));
}

.day-status-picker button.present.selected { background: #dcfce7; color: #166534; }
.day-status-picker button.absent.selected { background: #fee2e2; color: #991b1b; }
.day-status-picker button.leave.selected { background: #dbeafe; color: #1d4ed8; }
.day-status-picker button.halfday.selected { background: #fef9c3; color: #854d0e; }
.day-status-picker button.late.selected { background: #ffedd5; color: #9a3412; }
.day-status-picker button.unrecorded.selected { background: #e2e8f0; color: #475569; }

.month-day-hint {
  margin: 12px 0 0;
  color: var(--muted);
  text-align: center;
}

.monthly-payroll-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
}

.monthly-payroll-grid label,
.monthly-payroll-grid > div {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.monthly-payroll-grid label > span,
.monthly-payroll-grid > div > span {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
}

.monthly-payroll-grid > div {
  align-content: center;
  min-height: 66px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-2);
}

.monthly-payroll-grid .monthly-net-salary {
  grid-column: 1 / -1;
  border-color: #86efac;
  background: #f0fdf4;
}

.monthly-net-salary strong {
  color: #15803d;
  font-size: 1.25rem;
}

.monthly-payroll-actions {
  margin-top: 14px;
  flex-wrap: wrap;
}

@media (prefers-color-scheme: dark) {
  .attendance-month-modal .attendance-month-stats article,
  .attendance-month-modal .monthly-payroll-grid > div {
    border-color: #334155;
    background: #172033;
  }

  .attendance-month-modal .day-status-picker {
    border-color: #334155;
    background: #172033;
  }

  .attendance-month-modal .monthly-net-salary {
    border-color: #166534;
    background: #10271b;
  }
}

.profile-records {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.company-management-list {
  display: grid;
  gap: 12px;
}

.managed-company {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--surface-2);
}

.managed-company-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
}

.managed-company-head select {
  width: auto;
  min-width: 120px;
}

.company-contact-cell {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.company-contact-title {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.company-contact-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.contact-action {
  width: 34px;
  height: 34px;
  min-width: 34px;
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--text);
  text-decoration: none;
  font-size: 15px;
  line-height: 1;
  transition: background-color .16s ease, border-color .16s ease, box-shadow .16s ease, color .16s ease;
}

.contact-action:hover:not(:disabled) {
  border-color: rgba(59,130,246,.65);
  box-shadow: 0 0 8px rgba(59,130,246,.25);
}

.contact-action.whatsapp:hover {
  border-color: rgba(22,163,74,.65);
  box-shadow: 0 0 8px rgba(22,163,74,.25);
}

.contact-action:disabled {
  cursor: not-allowed;
  opacity: .48;
}

@media (max-width: 640px) {
  .company-contact-cell {
    align-items: flex-start;
    flex-direction: column;
  }
}

.feature-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 7px;
  margin: 12px 0;
}

.feature-toggle {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
}

.feature-toggle input {
  width: 17px;
  min-height: 17px;
  margin: 0;
}

.managed-users {
  display: grid;
  gap: 6px;
}

.managed-users > div {
  display: grid;
  grid-template-columns: 1.2fr 1.5fr 1fr 100px auto;
  gap: 8px;
  align-items: center;
  padding: 8px;
  border-top: 1px solid var(--line);
}

.message-list {
  display: grid;
  gap: 9px;
}

.message-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px;
  background: #fff;
}

.message-item.unread {
  border-inline-start: 4px solid var(--brand);
  background: #f2fbf9;
}

.message-item > div {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.compact-records {
  display: grid;
  gap: 7px;
}

.compact-record {
  display: grid;
  grid-template-columns: 90px 80px 1fr;
  gap: 8px;
  padding-bottom: 7px;
  border-bottom: 1px solid var(--line);
}

.employee-image-preview {
  width: 76px;
  height: 76px;
  display: block;
  object-fit: cover;
  border-radius: 50%;
  border: 1px solid var(--line);
  margin-bottom: 8px;
}

.employee-chart-panel {
  margin-top: 12px;
}

.employee-month-chart {
  height: 160px;
  display: grid;
  grid-template-columns: repeat(12, minmax(28px, 1fr));
  gap: 8px;
  align-items: end;
  border-bottom: 1px solid var(--line);
  padding: 12px 4px 0;
  overflow-x: auto;
}

.month-bar-wrap {
  height: 135px;
  min-width: 28px;
  display: flex;
  flex-direction: column;
  justify-content: end;
  align-items: center;
  gap: 5px;
}

.month-bar {
  width: 70%;
  min-height: 5px;
  border-radius: 4px 4px 0 0;
  background: linear-gradient(180deg, var(--brand), var(--accent));
}

.salary-slip {
  width: min(720px, 100%);
}

.salary-slip-employee {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.salary-slip-employee > div {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.salary-slip-employee strong,
.salary-slip-employee span {
  display: block;
}

.salary-lines {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.salary-lines > div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
}

.salary-lines > div:last-child {
  border-bottom: 0;
}

.salary-total {
  background: #e8f7f2;
  color: var(--brand);
  font-size: 18px;
}

.print-actions {
  margin-top: 14px;
}

.setting-toggle {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.firebase-diagnostics {
  margin-top: 16px;
}

.firebase-diagnostics .panel-head p {
  margin: 4px 0 0;
}

.firebase-status-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.firebase-status {
  min-width: 0;
  display: grid;
  grid-template-columns: 12px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--surface-2);
}

.firebase-status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--danger);
  box-shadow: 0 0 0 4px #fee4e2;
}

.firebase-status.is-connected .firebase-status-dot {
  background: var(--ok);
  box-shadow: 0 0 0 4px #dff5e8;
}

.firebase-status strong,
.firebase-status small {
  display: block;
}

.firebase-status small {
  margin-top: 4px;
  color: var(--danger);
}

.firebase-status.is-connected small {
  color: var(--ok);
}

.firebase-sync-banner {
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 9px;
  margin: -8px 0 16px;
  padding: 9px 12px;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  background: #eff6ff;
  color: var(--heading);
  font-size: 0.82rem;
  font-weight: 600;
}

.firebase-sync-banner .sync-dot {
  width: 9px;
  height: 9px;
  flex: 0 0 9px;
  border-radius: 50%;
  background: var(--brand);
  box-shadow: 0 0 0 4px #dbeafe;
}

.firebase-sync-banner.is-loading .sync-dot {
  animation: none;
}

.firebase-sync-banner.is-offline {
  border-color: #fed7aa;
  background: #fff7ed;
  color: #9a3412;
}

.firebase-sync-banner.is-offline .sync-dot {
  background: var(--warning);
  box-shadow: 0 0 0 4px #ffedd5;
}

.firebase-sync-banner.is-error {
  border-color: #fecaca;
  background: #fef2f2;
  color: #991b1b;
}

.firebase-sync-banner.is-error .sync-dot {
  background: var(--danger);
  box-shadow: 0 0 0 4px #fee2e2;
}

.firebase-sync-banner.app-sync-banner {
  position: fixed;
  inset-inline-end: 18px;
  bottom: calc(82px + env(safe-area-inset-bottom, 0px));
  z-index: 11990;
  width: min(420px, calc(100vw - 36px));
  margin: 0;
  min-height: 44px;
  contain: layout paint style;
  transform: translateZ(0);
}

@keyframes sync-pulse {
  50% {
    opacity: 0.45;
    transform: scale(0.8);
  }
}

.diagnostic-details {
  margin-top: 12px;
  border-inline-start: 3px solid var(--ok);
  padding: 10px 12px;
  background: #f2fbf6;
}

.diagnostic-details.has-error {
  border-inline-start-color: var(--danger);
  background: #fff5f4;
}

.diagnostic-details p,
.diagnostic-details ul {
  margin: 7px 0;
}

.diagnostic-details ul {
  padding-inline-start: 20px;
}

.diagnostic-details li {
  overflow-wrap: anywhere;
}

.diagnostic-details small {
  color: var(--muted);
}

.security-panel {
  margin-top: 16px;
}

.security-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.destructive-button {
  border-color: #f0b4ae;
  background: #fff3f1;
  color: var(--danger);
  font-weight: 700;
}

.destructive-button:hover {
  background: #fee4e2;
}

.sensitive-log {
  margin-top: 18px;
}

.security-modal {
  max-width: 580px;
}

.security-modal-actions {
  margin-top: 18px;
}

.backup-import-modal,
.backup-report-modal {
  width: min(620px, calc(100vw - 28px));
}

.backup-import-options {
  display: grid;
  gap: 10px;
  margin: 18px 0;
}

.backup-option {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  padding: 14px;
  border: 1px solid #dbe4ef;
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
}

.backup-option:has(input:checked) {
  border-color: #2563eb;
  background: #eff6ff;
}

.backup-option input {
  margin-top: 4px;
  accent-color: #2563eb;
}

.backup-option span {
  display: grid;
  gap: 4px;
}

.backup-option small {
  color: #64748b;
  line-height: 1.7;
}

.import-warning,
.import-error,
.import-warnings {
  margin: 14px 0;
  padding: 13px 14px;
  border-radius: 8px;
  line-height: 1.75;
}

.import-warning,
.import-warnings {
  border: 1px solid #f5c56b;
  background: #fffbeb;
  color: #854d0e;
}

.import-error {
  border: 1px solid #fecaca;
  background: #fef2f2;
  color: #991b1b;
}

.import-error p,
.import-warnings ul {
  margin: 6px 0 0;
}

.import-report-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin: 18px 0;
}

.import-report-grid article {
  display: grid;
  gap: 5px;
  min-width: 0;
  padding: 12px;
  border: 1px solid #dbe4ef;
  border-radius: 8px;
  background: #f8fafc;
}

.import-report-grid span {
  color: #64748b;
  font-size: 12px;
}

.import-report-grid strong {
  color: #1e3a8a;
  font-size: 24px;
}

.sound-settings-panel {
  overflow: hidden;
}

.sound-save-state {
  color: #166534;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 700;
}

.sound-volume-row,
.reminder-interval-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0 18px;
}

.sound-volume-row input[type="range"] {
  flex: 1;
  min-width: 120px;
  accent-color: #2563eb;
}

.sound-volume-row output {
  width: 48px;
  color: #1e3a8a;
  font-weight: 700;
  text-align: center;
}

.sound-card-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.sound-card {
  border: 1px solid #dbe4ef;
  border-radius: 8px;
  background: #fff;
  padding: 14px;
}

.sound-card-head {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
}

.sound-card-head h3 {
  margin: 0;
  color: #1e3a8a;
  font-size: 15px;
}

.sound-card-head small {
  display: block;
  margin-top: 3px;
  color: #64748b;
  overflow-wrap: anywhere;
}

.sound-icon {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  color: #2563eb;
  background: #eff6ff;
  font-size: 20px;
  font-weight: 800;
}

.sound-controls {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.sound-upload-button {
  display: grid;
  place-items: center;
  min-height: 38px;
  border: 1px solid #bfdbfe;
  border-radius: 6px;
  color: #1d4ed8;
  background: #eff6ff;
  cursor: pointer;
  font-weight: 700;
}

.reminder-interval-row {
  margin-top: 12px;
  border-top: 1px solid #e2e8f0;
}

.reminder-interval-row select {
  min-width: 190px;
}

.reminder-interval-row input {
  width: 100px;
}

.sound-event-section {
  padding-top: 4px;
}

.sound-event-section h3 {
  margin: 0 0 10px;
  color: #1e3a8a;
}

.sound-event-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.sound-event-grid label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 42px;
  padding: 8px 10px;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  background: #f8fafc;
}

.sound-event-grid input {
  width: 18px;
  height: 18px;
  accent-color: #2563eb;
}

@media (max-width: 620px) {
  .import-report-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .sound-card-grid,
  .sound-event-grid {
    grid-template-columns: 1fr;
  }

  .sound-volume-row,
  .reminder-interval-row {
    align-items: stretch;
    flex-wrap: wrap;
  }

  .reminder-interval-row select {
    width: 100%;
  }
}

.security-loading {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 14px;
  background: rgba(15, 23, 32, 0.58);
  color: #fff;
  contain: layout paint style;
}

.security-spinner {
  width: 42px;
  height: 42px;
  border: 4px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: security-spin 0.8s linear infinite;
}

@keyframes security-spin {
  to {
    transform: rotate(360deg);
  }
}

.switch {
  position: relative;
  width: 50px;
  height: 28px;
  flex: 0 0 50px;
}

.switch input {
  opacity: 0;
  position: absolute;
}

.switch span {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: #aab5c0;
  cursor: pointer;
}

.switch span::after {
  content: "";
  position: absolute;
  top: 4px;
  left: 4px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  transition: transform 160ms ease;
}

.switch input:checked + span {
  background: var(--brand);
}

.switch input:checked + span::after {
  transform: translateX(22px);
}

[dir="rtl"] .switch input:checked + span::after {
  transform: translateX(-22px);
}

.ai-box {
  background: #edf8f6;
  border: 1px solid #b8d7d2;
  border-radius: 8px;
  padding: 12px;
}

.ai-answer {
  margin-top: 10px;
  border-radius: 8px;
  background: #fff;
  border: 1px solid var(--line);
  padding: 10px;
  min-height: 58px;
}

.assistant-widget {
  position: fixed;
  inset-inline-end: 22px;
  bottom: 22px;
  z-index: 80;
  font-family: inherit;
}

.assistant-fab {
  width: 62px;
  height: 62px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: #2563eb;
  color: #fff;
  box-shadow: 0 18px 42px rgba(37, 99, 235, 0.28);
  font-weight: 900;
  transition: transform 180ms ease, box-shadow 180ms ease;
}

.assistant-fab:hover {
  transform: translateY(-2px);
  box-shadow: 0 22px 52px rgba(37, 99, 235, 0.34);
}

.assistant-fab:active {
  transform: scale(0.96);
}

.assistant-panel {
  width: min(420px, calc(100vw - 28px));
  max-height: min(680px, calc(100vh - 110px));
  position: absolute;
  inset-inline-end: 0;
  bottom: 76px;
  display: none;
  overflow: hidden;
  border: 1px solid #bfdbfe;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 26px 70px rgba(15, 23, 42, 0.22);
}

.assistant-widget.is-open .assistant-panel {
  display: grid;
  grid-template-rows: auto auto minmax(240px, 1fr) auto auto auto;
  animation: assistantSlideUp 240ms ease both;
}

.assistant-panel header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: #eff6ff;
  color: #1e3a8a;
}

.assistant-panel header strong,
.assistant-panel header small {
  display: block;
}

.assistant-panel header small {
  margin-top: 2px;
  color: #64748b;
  font-size: 0.78rem;
}

.assistant-panel header button {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  background: #fff;
  color: #1e3a8a;
  font-size: 22px;
  line-height: 1;
}

.assistant-toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid #dbeafe;
  background: #f8fbff;
}

.assistant-toolbar > div {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.assistant-toolbar button,
.assistant-suggestions button,
.ai-message-actions button {
  border: 1px solid #bfdbfe;
  border-radius: 10px;
  background: #eff6ff;
  color: #1e40af;
  padding: 7px 10px;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 160ms ease, background 160ms ease, border-color 160ms ease;
}

.assistant-toolbar button:hover,
.assistant-suggestions button:hover,
.ai-message-actions button:hover {
  background: #dbeafe;
  border-color: #93c5fd;
  transform: translateY(-1px);
}

.assistant-toolbar button:disabled {
  cursor: not-allowed;
  opacity: 0.52;
  transform: none;
}

.assistant-voice-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #1e3a8a;
  font-size: 0.84rem;
  font-weight: 800;
}

.assistant-voice-toggle input {
  width: 18px;
  height: 18px;
  accent-color: #2563eb;
}

.assistant-messages {
  min-height: 280px;
  padding: 16px;
  overflow: auto;
  background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
}

.assistant-messages .ai-message {
  max-width: 92%;
  margin: 0 0 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.assistant-messages .ai-message > div:first-child {
  border: 1px solid #dbeafe;
  border-radius: 14px;
  padding: 11px 13px;
  background: #fff;
  color: #17212b;
  line-height: 1.85;
  box-shadow: 0 8px 22px rgba(15, 23, 42, 0.05);
  white-space: normal;
}

.assistant-messages .ai-message.is-user {
  margin-inline-start: auto;
  align-items: flex-end;
}

.assistant-messages .ai-message.is-user > div:first-child {
  background: #2563eb;
  border-color: #2563eb;
  color: #fff;
}

.assistant-messages .ai-message-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.assistant-messages .ai-empty {
  border: 1px dashed #bfdbfe;
  border-radius: 14px;
  padding: 16px;
  background: #fff;
  color: #1e3a8a;
  line-height: 1.8;
}

.assistant-suggestions {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  padding: 10px 12px;
  border-top: 1px solid #e2e8f0;
  background: #fff;
}

.assistant-suggestions button {
  flex: 0 0 auto;
  white-space: nowrap;
}

.assistant-attachment {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 0 14px 10px;
  padding: 8px 10px;
  border: 1px solid #bfdbfe;
  border-radius: 10px;
  background: #eff6ff;
  color: #1e3a8a;
  font-weight: 700;
}

.assistant-attachment button {
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 50%;
  background: #fff;
  color: #dc2626;
  font-weight: 900;
}

.assistant-composer {
  padding: 12px;
  border-top: 1px solid #e2e8f0;
  background: #fff;
}

.assistant-composer textarea {
  width: 100%;
  min-height: 68px;
  resize: vertical;
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  padding: 10px 12px;
  font: inherit;
}

.assistant-composer > div {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
}

.assistant-file-button {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 1px solid #bfdbfe;
  border-radius: 10px;
  color: #2563eb;
  background: #eff6ff;
  cursor: pointer;
  font-weight: 900;
}

.assistant-composer .primary {
  min-width: 92px;
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #ffffff !important;
  white-space: nowrap;
  font-weight: 900;
}

@media (max-width: 520px) {
  .assistant-widget {
    inset-inline: 10px;
    bottom: 10px;
    z-index: 1300;
  }

  .assistant-panel {
    width: calc(100vw - 20px);
    max-height: calc(100dvh - 90px);
    bottom: 72px;
    inset-inline-end: 0;
    border-radius: 14px;
  }

  .assistant-composer textarea {
    min-height: 58px;
  }

  .assistant-composer > div {
    display: grid;
    grid-template-columns: 42px 42px minmax(92px, 1fr);
    gap: 8px;
  }

  .assistant-composer .primary {
    width: 100%;
    min-width: 0;
    font-size: 15px;
    padding-inline: 12px;
    color: #ffffff !important;
    opacity: 1 !important;
  }
}

.marketplace-workspace {
  align-items: stretch;
}

.marketplace-hero {
  overflow: hidden;
}

.marketplace-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.marketplace-card {
  min-height: 132px;
  display: grid;
  align-content: center;
  justify-items: start;
  gap: 8px;
  border: 1px solid #dbeafe;
  border-radius: 14px;
  background: linear-gradient(180deg, #ffffff, #eff6ff);
  color: #1e3a8a;
  padding: 16px;
  text-align: start;
  font: inherit;
  cursor: pointer;
  box-shadow: 0 12px 28px rgba(37, 99, 235, 0.08);
  transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

.marketplace-card:hover {
  transform: translateY(-2px);
  border-color: #93c5fd;
  box-shadow: 0 18px 34px rgba(37, 99, 235, 0.14);
}

.marketplace-card span {
  font-size: 1.55rem;
}

.marketplace-card strong {
  font-size: 0.98rem;
}

.marketplace-card small {
  min-width: 34px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  background: #2563eb;
  color: #fff;
  padding: 4px 10px;
  font-weight: 800;
}

.marketplace-directory {
  overflow: hidden;
}

.marketplace-filterbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) repeat(auto-fit, minmax(160px, 220px));
  gap: 10px;
  margin: 16px 0;
}

.marketplace-filterbar input,
.marketplace-filterbar select {
  width: 100%;
  border: 1px solid #dbeafe;
  border-radius: 12px;
  padding: 11px 12px;
  background: #fff;
}

.marketplace-directory-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
}

.marketplace-profile-card {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  gap: 12px;
  border: 1px solid #dbeafe;
  border-radius: 16px;
  padding: 14px;
  background: linear-gradient(180deg, #fff 0%, #f8fbff 100%);
  box-shadow: 0 12px 28px rgba(37, 99, 235, 0.08);
  transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease;
}

.marketplace-profile-card:hover {
  transform: translateY(-2px);
  border-color: #93c5fd;
  box-shadow: 0 18px 34px rgba(37, 99, 235, 0.14);
}

.marketplace-profile-avatar {
  width: 58px;
  height: 58px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: #eff6ff;
  color: #1d4ed8;
  font-weight: 800;
}

.marketplace-profile-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.marketplace-profile-card h3 {
  margin: 0 0 4px;
  color: #1e3a8a;
}

.marketplace-profile-card p {
  margin: 0;
  color: #64748b;
}

.marketplace-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.marketplace-tags span {
  border-radius: 999px;
  padding: 5px 8px;
  background: #eff6ff;
  color: #1d4ed8;
  font-size: 0.78rem;
}

.marketplace-profile-footer {
  grid-column: 1 / -1;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  border-top: 1px solid #e2e8f0;
  padding-top: 10px;
  color: #475569;
}

.public-register-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
  background:
    linear-gradient(135deg, rgba(37, 99, 235, 0.12), rgba(239, 246, 255, 0.9)),
    #ffffff;
}

.public-register-card {
  width: min(860px, 100%);
  border: 1px solid #bfdbfe;
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 28px 80px rgba(15, 23, 42, 0.16);
  padding: 24px;
}

.public-register-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
  color: #1e3a8a;
}

.public-register-brand strong,
.public-register-brand small {
  display: block;
}

.public-register-brand small {
  color: #64748b;
}

.public-register-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
  padding: 8px;
  border-radius: 14px;
  background: #eff6ff;
}

.public-register-tabs a {
  flex: 1 1 130px;
  border-radius: 10px;
  padding: 10px 12px;
  color: #1e40af;
  text-align: center;
  text-decoration: none;
  font-weight: 800;
}

.public-register-tabs a.active {
  background: #2563eb;
  color: #fff;
}

.public-register-card h1 {
  margin: 0 0 8px;
  color: #1e3a8a;
}

.public-login-link {
  display: inline-flex;
  justify-content: center;
  margin-top: 10px;
  text-decoration: none;
}

@keyframes assistantSlideUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 640px) {
  .assistant-widget {
    inset-inline: 12px;
    bottom: 12px;
  }

  .assistant-fab {
    margin-inline-start: auto;
  }

  .assistant-panel {
    width: calc(100vw - 24px);
    max-height: calc(100vh - 92px);
    inset-inline-end: 0;
  }

  .assistant-toolbar {
    align-items: stretch;
  }

  .assistant-toolbar > div {
    width: 100%;
  }

  .assistant-toolbar button {
    flex: 1 1 auto;
  }
}

.project-profile,
.contractor-profile {
  width: min(1180px, 96vw);
  max-width: 1180px;
  max-height: 94vh;
  overflow: auto;
}

.project-cost-panel,
.contractor-section,
.project-plans-panel {
  margin-top: 16px;
}

.project-expense-filters,
.contractor-filters {
  display: grid;
  grid-template-columns: minmax(180px, 1.5fr) repeat(4, minmax(140px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.project-plan-filters {
  grid-template-columns: minmax(220px, 1fr) minmax(160px, 240px);
}

.project-finance-grid,
.contractor-finance-grid {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr);
  gap: 16px;
  margin-top: 16px;
}

.dashboard-finance-grid {
  display: grid;
  grid-template-columns: minmax(0, 2fr) repeat(2, minmax(230px, 1fr));
  gap: 16px;
  margin-top: 16px;
}

.contractor-data-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.contractor-data-grid > div {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  display: grid;
  gap: 5px;
}

.contractor-data-grid span {
  color: var(--muted);
  font-size: 0.82rem;
}

.contractor-name-button {
  border: 0;
  background: transparent;
  color: var(--brand);
  padding: 0;
  font: inherit;
  font-weight: 700;
  text-align: start;
}

.project-spending-list {
  display: grid;
  gap: 8px;
}

.project-spending-list button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
}

.highest-spending-project {
  display: grid;
  gap: 8px;
  width: 100%;
  min-height: 112px;
  align-content: center;
  text-align: start;
  border-color: #dfb65b;
  background: #fff9e9;
}

.highest-spending-project strong {
  font-size: 1.35rem;
}

.file-preview-link {
  display: inline-block;
  margin-bottom: 8px;
}

.site-report-view {
  width: min(1060px, 96vw);
  max-width: 1060px;
  max-height: 94vh;
  overflow: auto;
}

.report-details-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 16px 0;
}

.report-details-grid > div {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
}

.report-details-grid span {
  color: var(--muted);
  display: block;
  font-size: 0.82rem;
  margin-bottom: 5px;
}

.report-detail-full {
  grid-column: 1 / -1;
}

.report-gallery,
.image-upload-preview {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.report-gallery button,
.image-upload-preview article {
  position: relative;
  aspect-ratio: 4 / 3;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f4f7f8;
}

.report-gallery img,
.image-upload-preview img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.image-upload-preview button {
  position: absolute;
  top: 6px;
  inset-inline-end: 6px;
  width: 30px;
  height: 30px;
  padding: 0;
}

.image-lightbox {
  z-index: 1200;
}

.image-lightbox section {
  position: relative;
  max-width: 94vw;
  max-height: 92vh;
}

.image-lightbox img {
  display: block;
  max-width: 94vw;
  max-height: 92vh;
  object-fit: contain;
}

.image-lightbox button {
  position: absolute;
  top: 8px;
  inset-inline-end: 8px;
  z-index: 1;
}

.invoice-view-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  border-color: #bfdbfe;
  background: #eff6ff;
  color: #1e3a8a;
  white-space: nowrap;
}

.invoice-upload-control {
  display: grid;
  gap: 7px;
  padding: 12px;
  border: 1px dashed #93c5fd;
  border-radius: 8px;
  background: #f8fbff;
}

.invoice-upload-control small,
.invoice-image-preview small {
  color: var(--muted);
}

.invoice-image-preview {
  display: grid;
  grid-template-columns: 116px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  margin-top: 12px;
  padding: 12px;
  border: 1px solid #dbeafe;
  border-radius: 8px;
  background: #fff;
}

.invoice-image-preview > div {
  display: grid;
  gap: 7px;
  min-width: 0;
}

.invoice-preview-open {
  width: 116px;
  height: 88px;
  padding: 0;
  overflow: hidden;
  border-color: #bfdbfe;
  background: #eff6ff;
}

.invoice-preview-open img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.invoice-preview-open .document-kind-icon {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  color: #b91c1c;
  font-weight: 800;
  letter-spacing: 0.08em;
  background: #fff1f2;
}

.invoice-lightbox section {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  width: min(1100px, 96vw);
  height: min(820px, 94vh);
  overflow: hidden;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.28);
}

.invoice-lightbox-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 54px;
  padding: 10px 14px;
  border-bottom: 1px solid #dbeafe;
}

.invoice-lightbox .invoice-lightbox-head button {
  position: static;
  width: 36px;
  min-width: 36px;
  padding: 0;
}

.invoice-lightbox .invoice-zoom-stage {
  position: static;
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  padding: 14px;
  overflow: auto;
  border: 0;
  border-radius: 0;
  background: #eff6ff;
  cursor: zoom-in;
}

.invoice-lightbox .invoice-zoom-stage img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  transition: transform 180ms ease;
}

.invoice-lightbox .invoice-zoom-stage.is-zoomed {
  place-items: start center;
  cursor: zoom-out;
}

.invoice-lightbox .invoice-zoom-stage.is-zoomed img {
  max-width: none;
  max-height: none;
  transform: scale(1.6);
  transform-origin: top center;
}

.invoice-pdf-frame {
  width: 100%;
  height: 100%;
  border: 0;
  background: #f8fafc;
}

.documents-panel {
  min-width: 0;
}

.document-toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(150px, 220px) minmax(150px, 220px);
  gap: 10px;
  margin-bottom: 14px;
}

.document-file-field {
  display: grid;
  gap: 8px;
}

.document-file-field > input {
  padding: 13px;
  border: 1px dashed #93c5fd;
  background: #f8fbff;
}

.document-file-field > small {
  color: var(--muted);
}

.selected-document-file,
.document-file-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border: 1px solid #dbeafe;
  border-radius: 8px;
  background: #eff6ff;
}

.compact-file-summary {
  margin-top: 10px;
}

.document-view-modal .modal-card {
  width: min(1100px, 96vw);
  max-width: 1100px;
}

.document-preview {
  display: grid;
  place-items: center;
  min-height: 420px;
  max-height: 70vh;
  overflow: auto;
  border: 1px solid #dbeafe;
  border-radius: 8px;
  background: #f8fbff;
}

.document-preview iframe {
  width: 100%;
  height: min(68vh, 760px);
  border: 0;
}

.document-image-stage {
  position: static;
  display: grid;
  place-items: center;
  width: 100%;
  min-height: 420px;
  padding: 14px;
  border: 0;
  background: transparent;
  cursor: zoom-in;
}

.document-image-stage img {
  max-width: 100%;
  max-height: 66vh;
  object-fit: contain;
  transition: transform 180ms ease;
}

.document-image-stage.is-zoomed {
  place-items: start center;
  cursor: zoom-out;
}

.document-image-stage.is-zoomed img {
  max-width: none;
  max-height: none;
  transform: scale(1.6);
  transform-origin: top center;
}

.document-file-summary {
  justify-content: center;
  flex-direction: column;
  min-width: min(360px, 90%);
  min-height: 180px;
}

.toast {
  position: fixed;
  bottom: 18px;
  inset-inline-end: 18px;
  background: #17212b;
  color: #fff;
  border-radius: 8px;
  padding: 12px 14px;
  box-shadow: var(--shadow);
  z-index: 40;
}

[hidden] {
  display: none !important;
}

@media (max-width: 1050px) {
  .app,
  .login-card {
    grid-template-columns: 1fr;
  }

  .sidebar {
    min-height: auto;
    position: relative;
  }

  .login-card {
    width: min(590px, 100%);
  }

  .login-hero {
    padding: 24px;
  }

  .login-hero .chart {
    display: none;
  }

  .nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    max-height: none;
  }

  .workspace,
  .metrics {
    grid-template-columns: 1fr;
  }

  .profile-layout,
  .profile-records,
  .project-finance-grid,
  .contractor-finance-grid,
  .dashboard-finance-grid {
    grid-template-columns: 1fr;
  }

  .project-expense-filters,
  .contractor-filters {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .important-alert {
    grid-template-columns: 110px minmax(180px, 1fr) 120px;
  }

  .important-alert .alert-days {
    grid-column: 2 / -1;
  }

  .feature-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .managed-company-head {
    flex-direction: column;
  }

  .managed-users > div {
    grid-template-columns: 1fr 1fr;
  }

  .attendance-year {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .topbar {
    flex-direction: column;
  }
}

@media (max-width: 620px) {
  .login-screen {
    padding: 12px;
    align-items: center;
  }

  .login-card {
    max-height: calc(100vh - 24px);
  }

  .login-hero {
    display: none;
  }

  .login-form {
    padding: 24px 18px;
    max-height: calc(100vh - 24px);
  }

  .login-video-brand {
    inset-inline: 20px;
    inset-block-end: 42px;
  }

  .login-video-brand .brand-mark {
    width: 46px;
    height: 46px;
  }

  .login-skip {
    inset-block-start: 16px;
    inset-inline-end: 16px;
  }

  .login-screen.intro-complete .login-cinematic {
    transform: translateX(112vw) scale(0.94);
  }
}

.smart-analytics-page {
  --analytics-surface: #fff;
  --analytics-text: #0f172a;
  --analytics-muted: #64748b;
  display: grid;
  gap: 14px;
  color: var(--analytics-text);
}

.smart-analytics-page.is-dark {
  --analytics-surface: #172033;
  --analytics-text: #f8fafc;
  --analytics-muted: #a9b5c7;
  padding: 14px;
  border-radius: 8px;
  background: #0f172a;
}

.smart-analytics-page.is-dark .panel,
.smart-analytics-page.is-dark .analytics-header,
.smart-analytics-page.is-dark .analytics-kpis article {
  border-color: #334155;
  background: var(--analytics-surface);
  color: var(--analytics-text);
}

.smart-analytics-page.is-dark p,
.smart-analytics-page.is-dark span {
  color: var(--analytics-muted);
}

.smart-analytics-page.is-dark input,
.smart-analytics-page.is-dark select {
  border-color: #475569;
  background: #0f172a;
  color: #f8fafc;
}

.analytics-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 20px;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  background: #fff;
}

.analytics-header h2 {
  margin: 4px 0;
  color: inherit;
  font-size: 24px;
}

.analytics-header p {
  margin: 0;
  color: var(--analytics-muted);
}

.analytics-kicker {
  color: #2563eb;
  font-size: 0.78rem;
  font-weight: 800;
}

.analytics-filter-panel {
  padding: 14px;
}

.analytics-filters {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 10px;
}

.analytics-filters label {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.analytics-filters label > span {
  color: var(--analytics-muted);
  font-size: 0.76rem;
  font-weight: 700;
}

.analytics-kpis {
  display: grid;
  grid-template-columns: repeat(5, minmax(150px, 1fr));
  gap: 10px;
}

.analytics-kpis article {
  display: grid;
  align-content: space-between;
  gap: 8px;
  min-height: 112px;
  padding: 14px;
  border: 1px solid #dbeafe;
  border-radius: 8px;
  background: #fff;
}

.analytics-kpis article > span {
  min-height: 34px;
  color: var(--analytics-muted);
  font-size: 0.78rem;
}

.analytics-kpis article strong {
  overflow-wrap: anywhere;
  color: inherit;
  font-size: 1rem;
}

.positive { color: #16a34a !important; }
.negative { color: #dc2626 !important; }

.analytics-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(280px, 0.65fr);
  gap: 14px;
}

.analytics-grid > .panel {
  min-width: 0;
  min-height: 320px;
}

.analytics-chart-wide {
  grid-column: 1 / -1;
}

.chart-key {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--analytics-muted);
  font-size: 0.74rem;
}

.chart-key span {
  width: 12px;
  height: 4px;
  border-radius: 2px;
}

.chart-key .expense { background: #dc2626; }
.chart-key .revenue { background: #16a34a; }

.analytics-chart-canvas svg {
  display: block;
  width: 100%;
  height: 240px;
}

.chart-axis { stroke: #cbd5e1; stroke-width: 1; }
.chart-line { fill: none; stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; }
.expense-line { stroke: #dc2626; }
.revenue-line { stroke: #16a34a; }

.chart-months {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 2px;
  color: var(--analytics-muted);
  font-size: 0.66rem;
  text-align: center;
}

.analytics-pie-wrap {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  gap: 18px;
  align-items: center;
}

.analytics-pie {
  display: grid;
  place-items: center;
  width: 180px;
  aspect-ratio: 1;
  border-radius: 50%;
}

.analytics-pie::before {
  content: "";
  grid-area: 1 / 1;
  width: 112px;
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--analytics-surface);
}

.analytics-pie > span {
  z-index: 1;
  grid-area: 1 / 1;
  max-width: 90px;
  color: var(--analytics-text);
  font-size: 0.72rem;
  font-weight: 800;
  text-align: center;
}

.analytics-legend,
.analytics-bars {
  display: grid;
  gap: 8px;
}

.analytics-legend > div {
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr) auto;
  gap: 7px;
  align-items: center;
  font-size: 0.75rem;
}

.analytics-legend i {
  width: 10px;
  height: 10px;
  border-radius: 2px;
}

.analytics-bar-row {
  display: grid;
  grid-template-columns: 86px minmax(0, 1fr);
  gap: 4px 10px;
  align-items: center;
}

.analytics-bar-row strong,
.analytics-bar-row small {
  font-size: 0.72rem;
}

.analytics-bar-row small {
  grid-column: 2;
  color: var(--analytics-muted);
}

.analytics-bar-track {
  position: relative;
  height: 18px;
  overflow: hidden;
  border-radius: 4px;
  background: #e2e8f0;
}

.analytics-bar-track span {
  position: absolute;
  inset-inline-start: 0;
  height: 8px;
  min-width: 2px;
  border-radius: 2px;
}

.analytics-bar-track .current { top: 1px; background: #2563eb; }
.analytics-bar-track .previous { bottom: 1px; background: #94a3b8; }

.yearly-values {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 28px;
}

.yearly-values > div {
  display: grid;
  gap: 8px;
  padding: 18px;
  border: 1px solid #dbeafe;
  border-radius: 8px;
  text-align: center;
}

.yearly-comparison > p {
  margin-top: 20px;
  font-size: 1.3rem;
  font-weight: 800;
  text-align: center;
}

.analytics-insights-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.analytics-alert-item,
.analytics-recommendations > div {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 11px 0;
  border-bottom: 1px solid #e2e8f0;
}

.analytics-alert-item > strong,
.analytics-recommendations > div > span {
  display: grid;
  place-items: center;
  width: 25px;
  min-width: 25px;
  height: 25px;
  border-radius: 50%;
  background: #fef3c7;
  color: #b45309;
  font-weight: 900;
}

.analytics-recommendations p { margin: 2px 0 0; }
.analytics-ai-result { border-inline-start: 4px solid #2563eb; }
.analytics-ai-result > p { line-height: 1.9; }

.analytics-threshold-input {
  display: grid;
  grid-template-columns: 1fr 38px;
  align-items: center;
}

.analytics-threshold-input span { text-align: center; }

@media (max-width: 720px) {
  .analytics-header { align-items: stretch; flex-direction: column; }
  .analytics-header .row-actions,
  .analytics-filters,
  .analytics-kpis,
  .analytics-grid,
  .analytics-insights-grid { grid-template-columns: 1fr; }
  .analytics-chart-wide { grid-column: auto; }
  .analytics-pie-wrap { grid-template-columns: 1fr; justify-items: center; }
  .chart-months span:nth-child(even) { display: none; }
}

@media print {
  .sidebar,
  .topbar,
  .analytics-header .row-actions,
  .analytics-filter-panel { display: none !important; }
  .app-shell,
  .main-shell { display: block !important; }
  .smart-analytics-page { color: #0f172a !important; background: #fff !important; }
}

@media (prefers-reduced-motion: reduce) {
  .login-cinematic,
  .login-card,
  .login-form > *,
  .login-form .field {
    animation: none !important;
    transition: none !important;
  }

  .login-screen.intro-complete .login-card {
    opacity: 1;
    transform: none;
  }
}

/* Final responsive sidebar behavior: fast drawer on phone/tablet, including landscape. */
@media (max-width: 980px) {
  .app,
  .app.sidebar-is-collapsed,
  body.mobile-landscape-sidebar .app,
  body.mobile-landscape-sidebar .app.sidebar-is-collapsed {
    grid-template-columns: minmax(0, 1fr) !important;
    width: 100vw !important;
    max-width: 100vw !important;
    overflow-x: hidden !important;
  }

  .sidebar,
  .sidebar.is-collapsed,
  body.mobile-landscape-sidebar .sidebar,
  body.mobile-landscape-sidebar .sidebar.is-collapsed,
  [dir="rtl"] body.mobile-landscape-sidebar .sidebar,
  [dir="rtl"] body.mobile-landscape-sidebar .sidebar.is-collapsed {
    position: fixed !important;
    inset-block: 0 !important;
    inset-inline-end: 0 !important;
    inset-inline-start: auto !important;
    width: min(86vw, 318px) !important;
    min-width: min(86vw, 318px) !important;
    max-width: min(86vw, 318px) !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
    padding: 14px 12px !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    transform: translateX(105%) !important;
    transition: transform 0.09s ease, box-shadow 0.09s ease !important;
    z-index: 1200 !important;
  }

  [dir="ltr"] .sidebar,
  [dir="ltr"] .sidebar.is-collapsed,
  [dir="ltr"] body.mobile-landscape-sidebar .sidebar,
  [dir="ltr"] body.mobile-landscape-sidebar .sidebar.is-collapsed {
    inset-inline-start: 0 !important;
    inset-inline-end: auto !important;
    transform: translateX(-105%) !important;
  }

  .mobile-nav-open .sidebar,
  .mobile-nav-open .sidebar.is-collapsed,
  body.mobile-landscape-sidebar.mobile-nav-open .sidebar,
  body.mobile-landscape-sidebar.mobile-nav-open .sidebar.is-collapsed,
  [dir="rtl"] body.mobile-landscape-sidebar.mobile-nav-open .sidebar,
  [dir="rtl"] body.mobile-landscape-sidebar.mobile-nav-open .sidebar.is-collapsed,
  [dir="ltr"] .mobile-nav-open .sidebar,
  [dir="ltr"] .mobile-nav-open .sidebar.is-collapsed,
  [dir="ltr"] body.mobile-landscape-sidebar.mobile-nav-open .sidebar,
  [dir="ltr"] body.mobile-landscape-sidebar.mobile-nav-open .sidebar.is-collapsed {
    transform: translateX(0) !important;
    box-shadow: -14px 0 32px rgba(15, 23, 42, 0.2) !important;
  }

  [dir="ltr"] .mobile-nav-open .sidebar,
  [dir="ltr"] .mobile-nav-open .sidebar.is-collapsed,
  [dir="ltr"] body.mobile-landscape-sidebar.mobile-nav-open .sidebar,
  [dir="ltr"] body.mobile-landscape-sidebar.mobile-nav-open .sidebar.is-collapsed {
    box-shadow: 14px 0 32px rgba(15, 23, 42, 0.2) !important;
  }

  body.mobile-landscape-sidebar .main {
    width: 100vw !important;
    max-width: 100vw !important;
    margin: 0 !important;
    overflow-x: hidden !important;
  }

  .mobile-nav-backdrop,
  body.mobile-landscape-sidebar .mobile-nav-backdrop {
    position: fixed !important;
    inset: 0 !important;
    z-index: 1190 !important;
    background: rgba(15, 23, 42, 0.24) !important;
    backdrop-filter: none !important;
  }

  body:not(.mobile-nav-open) .mobile-nav-backdrop,
  body.mobile-landscape-sidebar:not(.mobile-nav-open) .mobile-nav-backdrop {
    display: none !important;
  }

  body.mobile-landscape-sidebar .brand > div,
  body.mobile-landscape-sidebar .tenant-switcher,
  body.mobile-landscape-sidebar .erp-sidebar-search,
  body.mobile-landscape-sidebar .sidebar-search,
  body.mobile-landscape-sidebar .nav-section-title,
  body.mobile-landscape-sidebar .nav-section-count,
  body.mobile-landscape-sidebar .nav-section-arrow,
  body.mobile-landscape-sidebar .erp-sidebar-link-label,
  body.mobile-landscape-sidebar .nav-button span:nth-child(2),
  body.mobile-landscape-sidebar .erp-sidebar-badge,
  body.mobile-landscape-sidebar .erp-sidebar-favorite {
    display: initial !important;
  }

  body.mobile-landscape-sidebar .tenant-switcher,
  body.mobile-landscape-sidebar .erp-sidebar-search,
  body.mobile-landscape-sidebar .sidebar-search {
    display: block !important;
  }

  body.mobile-landscape-sidebar .brand {
    grid-template-columns: 44px minmax(0, 1fr) !important;
    justify-items: stretch !important;
  }

  body.mobile-landscape-sidebar .erp-sidebar-tools {
    grid-template-columns: minmax(0, 1fr) 40px !important;
  }

  body.mobile-landscape-sidebar .erp-sidebar-section-toggle,
  body.mobile-landscape-sidebar .nav-section-toggle {
    grid-template-columns: 36px minmax(0, 1fr) auto 18px !important;
    justify-items: stretch !important;
  }

  body.mobile-landscape-sidebar .erp-sidebar-link,
  body.mobile-landscape-sidebar .nav-button {
    grid-template-columns: 30px minmax(0, 1fr) auto 0 !important;
    justify-items: stretch !important;
  }

  body.mobile-landscape-sidebar .erp-sidebar-section.open .erp-sidebar-section-items,
  body.mobile-landscape-sidebar .nav-section.open .nav-section-items {
    grid-template-rows: 1fr !important;
  }

  body.phone-nav .app,
  body.phone-nav .app.sidebar-is-collapsed,
  body.phone-landscape-nav .app,
  body.phone-landscape-nav .app.sidebar-is-collapsed {
    grid-template-columns: minmax(0, 1fr) !important;
    width: 100vw !important;
    max-width: 100vw !important;
    overflow-x: hidden !important;
  }

  body.phone-nav .main,
  body.phone-landscape-nav .main {
    width: 100vw !important;
    max-width: 100vw !important;
    min-width: 0 !important;
    margin: 0 !important;
    overflow-x: hidden !important;
  }

  body.phone-nav .mobile-menu-toggle,
  body.phone-landscape-nav .mobile-menu-toggle {
    display: inline-grid !important;
  }

  body.phone-nav .sidebar,
  body.phone-nav .sidebar.is-collapsed,
  [dir="rtl"] body.phone-nav .sidebar,
  [dir="rtl"] body.phone-nav .sidebar.is-collapsed {
    position: fixed !important;
    inset-block: 0 !important;
    inset-inline-end: 0 !important;
    inset-inline-start: auto !important;
    width: min(320px, 85vw) !important;
    min-width: min(320px, 85vw) !important;
    max-width: min(320px, 85vw) !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
    padding: 14px 12px !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    transform: translateX(105%) !important;
    transition: transform 180ms ease, box-shadow 180ms ease !important;
    z-index: 1200 !important;
  }

  [dir="ltr"] body.phone-nav .sidebar,
  [dir="ltr"] body.phone-nav .sidebar.is-collapsed {
    inset-inline-start: 0 !important;
    inset-inline-end: auto !important;
    transform: translateX(-105%) !important;
  }

  body.phone-nav.mobile-nav-open .sidebar,
  body.phone-nav.mobile-nav-open .sidebar.is-collapsed {
    transform: translateX(0) !important;
    box-shadow: -18px 0 36px rgba(15, 23, 42, 0.24) !important;
  }

  [dir="ltr"] body.phone-nav.mobile-nav-open .sidebar,
  [dir="ltr"] body.phone-nav.mobile-nav-open .sidebar.is-collapsed {
    box-shadow: 18px 0 36px rgba(15, 23, 42, 0.24) !important;
  }

  body.phone-landscape-nav .sidebar,
  body.phone-landscape-nav .sidebar.is-collapsed,
  [dir="rtl"] body.phone-landscape-nav .sidebar,
  [dir="rtl"] body.phone-landscape-nav .sidebar.is-collapsed {
    position: fixed !important;
    inset-block: 0 !important;
    inset-inline-end: 0 !important;
    inset-inline-start: auto !important;
    width: 72px !important;
    min-width: 72px !important;
    max-width: 72px !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
    padding: 10px 8px !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    transform: translateX(84px) !important;
    transition: transform 140ms ease !important;
    box-shadow: none !important;
    z-index: 1200 !important;
  }

  [dir="ltr"] body.phone-landscape-nav .sidebar,
  [dir="ltr"] body.phone-landscape-nav .sidebar.is-collapsed {
    inset-inline-start: 0 !important;
    inset-inline-end: auto !important;
    transform: translateX(-84px) !important;
  }

  body.phone-landscape-nav.mobile-nav-open .sidebar,
  body.phone-landscape-nav.mobile-nav-open .sidebar.is-collapsed,
  [dir="rtl"] body.phone-landscape-nav.mobile-nav-open .sidebar,
  [dir="rtl"] body.phone-landscape-nav.mobile-nav-open .sidebar.is-collapsed,
  [dir="ltr"] body.phone-landscape-nav.mobile-nav-open .sidebar,
  [dir="ltr"] body.phone-landscape-nav.mobile-nav-open .sidebar.is-collapsed {
    transform: translateX(0) !important;
  }

  body.phone-landscape-nav.mobile-nav-open .main {
    width: calc(100vw - 72px) !important;
    max-width: calc(100vw - 72px) !important;
    margin-inline-end: 72px !important;
  }

  [dir="ltr"] body.phone-landscape-nav.mobile-nav-open .main {
    margin-inline-start: 72px !important;
    margin-inline-end: 0 !important;
  }

  body.phone-landscape-nav .brand > div,
  body.phone-landscape-nav .tenant-switcher,
  body.phone-landscape-nav .erp-sidebar-search,
  body.phone-landscape-nav .sidebar-search,
  body.phone-landscape-nav .nav-section-title,
  body.phone-landscape-nav .nav-section-count,
  body.phone-landscape-nav .nav-section-arrow,
  body.phone-landscape-nav .erp-sidebar-link-label,
  body.phone-landscape-nav .nav-button span:nth-child(2),
  body.phone-landscape-nav .erp-sidebar-badge,
  body.phone-landscape-nav .erp-sidebar-favorite,
  body.phone-landscape-nav .mobile-menu-close {
    display: none !important;
  }

  body.phone-landscape-nav .brand,
  body.phone-landscape-nav .erp-sidebar-section-toggle,
  body.phone-landscape-nav .nav-section-toggle,
  body.phone-landscape-nav .erp-sidebar-link,
  body.phone-landscape-nav .nav-button {
    grid-template-columns: 1fr !important;
    justify-items: center !important;
    min-height: 44px !important;
    padding-inline: 0 !important;
  }

  body.phone-landscape-nav .erp-sidebar-tools {
    display: none !important;
  }

  body.phone-landscape-nav .mobile-nav-backdrop,
  body.phone-landscape-nav.mobile-nav-open .mobile-nav-backdrop {
    display: none !important;
    opacity: 0 !important;
    pointer-events: none !important;
  }
}

/* Absolute final mobile sidebar override.
   Phones use a drawer in portrait, and a 72px icon rail in landscape so content is never covered. */
html,
body,
#app,
.app {
  max-width: 100vw !important;
  overflow-x: hidden !important;
}

body.phone-nav .app,
body.phone-nav .app.sidebar-is-collapsed,
body.phone-landscape-nav .app,
body.phone-landscape-nav .app.sidebar-is-collapsed {
  grid-template-columns: minmax(0, 1fr) !important;
  width: 100vw !important;
  max-width: 100vw !important;
  overflow-x: hidden !important;
}

body.phone-nav .main,
body.phone-landscape-nav .main {
  width: 100vw !important;
  max-width: 100vw !important;
  min-width: 0 !important;
  margin: 0 !important;
  overflow-x: hidden !important;
}

body.phone-nav .mobile-menu-toggle,
body.phone-landscape-nav .mobile-menu-toggle {
  display: inline-grid !important;
}

body.phone-nav .sidebar,
body.phone-nav .sidebar.is-collapsed,
[dir="rtl"] body.phone-nav .sidebar,
[dir="rtl"] body.phone-nav .sidebar.is-collapsed {
  position: fixed !important;
  inset-block: 0 !important;
  inset-inline-end: 0 !important;
  inset-inline-start: auto !important;
  width: min(320px, 85vw) !important;
  min-width: min(320px, 85vw) !important;
  max-width: min(320px, 85vw) !important;
  height: 100dvh !important;
  max-height: 100dvh !important;
  padding: 14px 12px !important;
  overflow-x: hidden !important;
  overflow-y: auto !important;
  transform: translateX(105%) !important;
  transition: transform 180ms ease, box-shadow 180ms ease !important;
  z-index: 1200 !important;
}

[dir="ltr"] body.phone-nav .sidebar,
[dir="ltr"] body.phone-nav .sidebar.is-collapsed {
  inset-inline-start: 0 !important;
  inset-inline-end: auto !important;
  transform: translateX(-105%) !important;
}

body.phone-nav.mobile-nav-open .sidebar,
body.phone-nav.mobile-nav-open .sidebar.is-collapsed {
  transform: translateX(0) !important;
  box-shadow: -18px 0 36px rgba(15, 23, 42, 0.24) !important;
}

[dir="ltr"] body.phone-nav.mobile-nav-open .sidebar,
[dir="ltr"] body.phone-nav.mobile-nav-open .sidebar.is-collapsed {
  box-shadow: 18px 0 36px rgba(15, 23, 42, 0.24) !important;
}

body.phone-landscape-nav .sidebar,
body.phone-landscape-nav .sidebar.is-collapsed,
[dir="rtl"] body.phone-landscape-nav .sidebar,
[dir="rtl"] body.phone-landscape-nav .sidebar.is-collapsed {
  position: fixed !important;
  inset-block: 0 !important;
  inset-inline-end: 0 !important;
  inset-inline-start: auto !important;
  width: 72px !important;
  min-width: 72px !important;
  max-width: 72px !important;
  height: 100dvh !important;
  max-height: 100dvh !important;
  padding: 10px 8px !important;
  overflow-x: hidden !important;
  overflow-y: auto !important;
  transform: translateX(84px) !important;
  transition: transform 140ms ease !important;
  box-shadow: none !important;
  z-index: 1200 !important;
}

[dir="ltr"] body.phone-landscape-nav .sidebar,
[dir="ltr"] body.phone-landscape-nav .sidebar.is-collapsed {
  inset-inline-start: 0 !important;
  inset-inline-end: auto !important;
  transform: translateX(-84px) !important;
}

body.phone-landscape-nav.mobile-nav-open .sidebar,
body.phone-landscape-nav.mobile-nav-open .sidebar.is-collapsed,
[dir="rtl"] body.phone-landscape-nav.mobile-nav-open .sidebar,
[dir="rtl"] body.phone-landscape-nav.mobile-nav-open .sidebar.is-collapsed,
[dir="ltr"] body.phone-landscape-nav.mobile-nav-open .sidebar,
[dir="ltr"] body.phone-landscape-nav.mobile-nav-open .sidebar.is-collapsed {
  transform: translateX(0) !important;
}

body.phone-landscape-nav.mobile-nav-open .main {
  width: calc(100vw - 72px) !important;
  max-width: calc(100vw - 72px) !important;
  margin-inline-end: 72px !important;
}

[dir="ltr"] body.phone-landscape-nav.mobile-nav-open .main {
  margin-inline-start: 72px !important;
  margin-inline-end: 0 !important;
}

body.phone-landscape-nav .brand > div,
body.phone-landscape-nav .tenant-switcher,
body.phone-landscape-nav .erp-sidebar-search,
body.phone-landscape-nav .sidebar-search,
body.phone-landscape-nav .nav-section-title,
body.phone-landscape-nav .nav-section-count,
body.phone-landscape-nav .nav-section-arrow,
body.phone-landscape-nav .erp-sidebar-link-label,
body.phone-landscape-nav .nav-button span:nth-child(2),
body.phone-landscape-nav .erp-sidebar-badge,
body.phone-landscape-nav .erp-sidebar-favorite,
body.phone-landscape-nav .mobile-menu-close {
  display: none !important;
}

body.phone-landscape-nav .brand,
body.phone-landscape-nav .erp-sidebar-section-toggle,
body.phone-landscape-nav .nav-section-toggle,
body.phone-landscape-nav .erp-sidebar-link,
body.phone-landscape-nav .nav-button {
  grid-template-columns: 1fr !important;
  justify-items: center !important;
  min-height: 44px !important;
  padding-inline: 0 !important;
}

body.phone-landscape-nav .erp-sidebar-tools {
  display: none !important;
}

body.phone-landscape-nav .erp-sidebar-section.open .erp-sidebar-section-items,
body.phone-landscape-nav .nav-section.open .nav-section-items {
  grid-template-rows: 1fr !important;
}

body.phone-nav .mobile-nav-backdrop {
  position: fixed !important;
  inset: 0 !important;
  display: block !important;
  opacity: 0 !important;
  pointer-events: none !important;
  z-index: 1190 !important;
  background: rgba(15, 23, 42, 0.34) !important;
  backdrop-filter: none !important;
  transition: opacity 180ms ease !important;
}

body.phone-nav.mobile-nav-open .mobile-nav-backdrop {
  opacity: 1 !important;
  pointer-events: auto !important;
}

body.phone-landscape-nav .mobile-nav-backdrop,
body.phone-landscape-nav.mobile-nav-open .mobile-nav-backdrop,
body.desktop-nav .mobile-nav-backdrop {
  display: none !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

/* Critical final mobile navigation fix: phones always use a drawer, including landscape. */
html,
body,
#app {
  max-width: 100vw !important;
  overflow-x: hidden !important;
}

body.phone-nav {
  overflow-x: hidden !important;
}

body.phone-nav .app,
body.phone-nav .app.sidebar-is-collapsed {
  grid-template-columns: minmax(0, 1fr) !important;
  width: 100vw !important;
  max-width: 100vw !important;
  overflow-x: hidden !important;
}

body.phone-nav .main {
  width: 100vw !important;
  max-width: 100vw !important;
  min-width: 0 !important;
  margin: 0 !important;
  overflow-x: hidden !important;
}

body.phone-nav .mobile-menu-toggle {
  display: inline-grid !important;
}

body.phone-nav .sidebar,
body.phone-nav .sidebar.is-collapsed,
[dir="rtl"] body.phone-nav .sidebar,
[dir="rtl"] body.phone-nav .sidebar.is-collapsed {
  position: fixed !important;
  inset-block: 0 !important;
  inset-inline-end: 0 !important;
  inset-inline-start: auto !important;
  width: min(320px, 85vw) !important;
  min-width: min(320px, 85vw) !important;
  max-width: min(320px, 85vw) !important;
  height: 100dvh !important;
  max-height: 100dvh !important;
  padding: 14px 12px !important;
  overflow-x: hidden !important;
  overflow-y: auto !important;
  transform: translateX(105%) !important;
  transition: transform 110ms ease-out, box-shadow 110ms ease-out !important;
  z-index: 1200 !important;
}

[dir="ltr"] body.phone-nav .sidebar,
[dir="ltr"] body.phone-nav .sidebar.is-collapsed {
  inset-inline-start: 0 !important;
  inset-inline-end: auto !important;
  transform: translateX(-105%) !important;
}

body.phone-nav.mobile-nav-open .sidebar,
body.phone-nav.mobile-nav-open .sidebar.is-collapsed {
  transform: translateX(0) !important;
  box-shadow: -18px 0 36px rgba(15, 23, 42, 0.24) !important;
}

[dir="ltr"] body.phone-nav.mobile-nav-open .sidebar,
[dir="ltr"] body.phone-nav.mobile-nav-open .sidebar.is-collapsed {
  box-shadow: 18px 0 36px rgba(15, 23, 42, 0.24) !important;
}

body.phone-nav .mobile-nav-backdrop {
  position: fixed !important;
  inset: 0 !important;
  display: block !important;
  opacity: 0 !important;
  pointer-events: none !important;
  z-index: 1190 !important;
  background: rgba(15, 23, 42, 0.34) !important;
  backdrop-filter: none !important;
  transition: opacity 90ms ease-out !important;
}

body.phone-nav.mobile-nav-open .mobile-nav-backdrop {
  opacity: 1 !important;
  pointer-events: auto !important;
}

body.phone-nav .sidebar.is-collapsed .brand > div,
body.phone-nav .sidebar.is-collapsed .tenant-switcher,
body.phone-nav .sidebar.is-collapsed .erp-sidebar-search,
body.phone-nav .sidebar.is-collapsed .sidebar-search,
body.phone-nav .sidebar.is-collapsed .nav-section-title,
body.phone-nav .sidebar.is-collapsed .nav-section-count,
body.phone-nav .sidebar.is-collapsed .nav-section-arrow,
body.phone-nav .sidebar.is-collapsed .erp-sidebar-link-label,
body.phone-nav .sidebar.is-collapsed .erp-sidebar-badge,
body.phone-nav .sidebar.is-collapsed .erp-sidebar-favorite {
  display: initial !important;
}

body.phone-nav .sidebar.is-collapsed .tenant-switcher,
body.phone-nav .sidebar.is-collapsed .erp-sidebar-search,
body.phone-nav .sidebar.is-collapsed .sidebar-search {
  display: block !important;
}

body.phone-nav .sidebar .brand,
body.phone-nav .sidebar.is-collapsed .brand {
  grid-template-columns: 44px minmax(0, 1fr) !important;
  justify-items: stretch !important;
}

body.phone-nav .sidebar .erp-sidebar-tools,
body.phone-nav .sidebar.is-collapsed .erp-sidebar-tools {
  grid-template-columns: minmax(0, 1fr) 40px !important;
}

body.phone-nav .sidebar .erp-sidebar-section-toggle,
body.phone-nav .sidebar .nav-section-toggle,
body.phone-nav .sidebar.is-collapsed .erp-sidebar-section-toggle,
body.phone-nav .sidebar.is-collapsed .nav-section-toggle {
  grid-template-columns: 36px minmax(0, 1fr) auto 18px !important;
  min-height: 42px !important;
  justify-items: stretch !important;
}

body.phone-nav .sidebar .erp-sidebar-link,
body.phone-nav .sidebar .nav-button,
body.phone-nav .sidebar.is-collapsed .erp-sidebar-link,
body.phone-nav .sidebar.is-collapsed .nav-button {
  grid-template-columns: 30px minmax(0, 1fr) auto 0 !important;
  min-height: 40px !important;
  justify-items: stretch !important;
}

body.phone-nav .sidebar .erp-sidebar-section.open .erp-sidebar-section-items,
body.phone-nav .sidebar .nav-section.open .nav-section-items,
body.phone-nav .sidebar.is-collapsed .erp-sidebar-section.open .erp-sidebar-section-items,
body.phone-nav .sidebar.is-collapsed .nav-section.open .nav-section-items {
  grid-template-rows: 1fr !important;
}

body.desktop-nav .mobile-nav-backdrop {
  display: none !important;
}

body.desktop-nav .mobile-menu-toggle {
  display: none !important;
}

body.desktop-nav .app {
  grid-template-columns: var(--erp-sidebar-width, 276px) minmax(0, 1fr) !important;
}

body.desktop-nav .app.sidebar-is-collapsed {
  grid-template-columns: var(--erp-sidebar-collapsed-width, 82px) minmax(0, 1fr) !important;
}

body.desktop-nav .sidebar {
  position: sticky !important;
  inset-block-start: 0 !important;
  inset-inline-end: auto !important;
  inset-inline-start: auto !important;
  transform: none !important;
  height: 100vh !important;
  transition: width 180ms ease, min-width 180ms ease, max-width 180ms ease !important;
}

body.desktop-nav .sidebar.is-collapsed {
  transform: none !important;
}

/* ===== Emergency readability/layout repair - visual only ===== */
:root {
  --ui-bg: #f8fafc;
  --ui-surface: #ffffff;
  --ui-text: #0f172a;
  --ui-muted: #64748b;
  --ui-border: #e2e8f0;
  --ui-blue-600: #2563eb;
  --ui-blue-900: #0f2a55;
  --ui-success: #16a34a;
  --ui-danger: #dc2626;
  --ui-warning: #f97316;
  --bg: #f8fafc;
  --surface: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --brand: #2563eb;
  --brand-2: #0f2a55;
  --primary: #2563eb;
  --border: #e2e8f0;
}

html,
body,
#app {
  max-width: 100%;
  overflow-x: hidden;
}

body {
  background: #f8fafc !important;
  color: #0f172a !important;
}

.app {
  grid-template-columns: minmax(260px, 280px) minmax(0, 1fr) !important;
}

.main {
  width: 100%;
  max-width: 1480px;
  min-width: 0;
  margin-inline: auto;
  padding: 20px !important;
  overflow-x: hidden;
}

.panel,
.metric,
.provider-card,
.provider-kpi,
.insight,
.message-item,
.company-card,
.stat-card,
.modal-card,
.login-card {
  background: #fff !important;
  color: #0f172a !important;
  border-color: #e2e8f0 !important;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06) !important;
  overflow: visible !important;
}

.panel *,
.metric *,
.provider-card *,
.provider-kpi *,
.insight *,
.message-item * {
  max-width: 100%;
}

.metrics {
  display: grid !important;
  grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
  gap: 18px !important;
  align-items: stretch;
}

.metric,
.provider-kpi {
  min-height: 120px !important;
  padding: 20px !important;
  display: grid !important;
  align-content: center !important;
  gap: 8px !important;
  position: relative !important;
  isolation: isolate !important;
  border-radius: 16px !important;
}

.metric::before,
.metric::after,
.provider-kpi::before,
.provider-kpi::after {
  opacity: 0.08 !important;
  z-index: -1 !important;
  pointer-events: none !important;
}

.metric > *,
.provider-kpi > * {
  position: relative !important;
  z-index: 2 !important;
}

.metric span,
.metric small,
.provider-kpi span,
.provider-kpi small {
  display: block !important;
  color: #64748b !important;
  font-size: 13px !important;
  line-height: 1.6 !important;
  white-space: normal !important;
  overflow: visible !important;
  text-overflow: clip !important;
}

.metric strong,
.provider-kpi strong,
.metric b,
.provider-kpi b {
  display: block !important;
  color: #0f172a !important;
  font-size: clamp(28px, 2.8vw, 38px) !important;
  line-height: 1.15 !important;
  font-weight: 900 !important;
  white-space: normal !important;
  overflow: visible !important;
  text-overflow: clip !important;
}

.panel-head h2,
.panel-head h3,
.topbar h1,
.provider-title h1,
h1,
h2,
h3 {
  color: #0f172a !important;
  font-weight: 900 !important;
  line-height: 1.35 !important;
  overflow: visible !important;
  text-overflow: clip !important;
}

.muted,
.panel-head p,
.topbar p,
.provider-title p,
small {
  color: #64748b !important;
  line-height: 1.7 !important;
}

.sidebar {
  width: 280px !important;
  max-width: 280px !important;
  min-width: 260px !important;
  padding: 16px 12px !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
}

.sidebar .brand {
  grid-template-columns: 44px minmax(0, 1fr) !important;
}

.sidebar .brand strong,
.sidebar .brand small,
.nav-section-title,
.nav-button span,
.nav-button {
  white-space: normal !important;
  overflow: visible !important;
  text-overflow: clip !important;
  line-height: 1.45 !important;
}

.nav-section-toggle,
.nav-button {
  min-height: 44px !important;
  padding: 9px 10px !important;
  gap: 10px !important;
}

[dir="rtl"] .nav-section-toggle,
[dir="rtl"] .nav-button {
  text-align: right !important;
}

.nav-section-icon,
.nav-button > span:first-child {
  flex: 0 0 30px !important;
  width: 30px !important;
  height: 30px !important;
  order: -1;
}

.nav-button.active,
.nav-section.open > .nav-section-toggle,
.nav-section.contains-active > .nav-section-toggle {
  background: #2563eb !important;
  color: #fff !important;
  border-color: #2563eb !important;
}

.nav-button.active span,
.nav-section.open > .nav-section-toggle *,
.nav-section.contains-active > .nav-section-toggle * {
  color: #fff !important;
}

.nav-section-items,
.nav-section-items-inner {
  overflow: visible !important;
}

.dashboard-construction-scene {
  min-height: 150px !important;
  max-height: 190px !important;
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 38%) !important;
  align-items: center !important;
  gap: 16px !important;
  overflow: hidden !important;
  padding: 20px 28px !important;
}

.dashboard-construction-scene > div {
  position: relative !important;
  z-index: 2 !important;
  min-width: 0 !important;
}

.dashboard-construction-scene strong,
.dashboard-construction-scene span {
  color: #0f172a !important;
  text-shadow: none !important;
  white-space: normal !important;
}

.dashboard-construction-scene img {
  position: relative !important;
  z-index: 1 !important;
  max-width: 100% !important;
  max-height: 160px !important;
  object-fit: contain !important;
  opacity: 0.95 !important;
}

.table-wrap {
  max-width: 100%;
  overflow-x: auto !important;
  overflow-y: visible !important;
}

.table-wrap table {
  width: 100%;
}

th,
td {
  color: #0f172a !important;
  vertical-align: middle !important;
}

th {
  color: #0f2a55 !important;
}

button,
.button-link {
  color: #0f172a;
}

.primary,
button.primary {
  color: #fff !important;
  background: #2563eb !important;
  border-color: #2563eb !important;
}

.danger,
button.danger,
.destructive-button {
  color: #dc2626 !important;
  background: #fee2e2 !important;
  border-color: #fecaca !important;
}

.badge,
.status-badge,
.alert-status {
  color: #0f172a;
}

.badge.success,
.status-active,
.status-approved {
  color: #166534 !important;
  background: #dcfce7 !important;
}

.badge.danger,
.status-rejected,
.status-banned {
  color: #991b1b !important;
  background: #fee2e2 !important;
}

.badge.warning,
.status-pending,
.status-suspended {
  color: #9a3412 !important;
  background: #ffedd5 !important;
}

.toast::before {
  content: "i" !important;
}

.toast.has-success-animation::before,
.toast.success::before {
  content: "OK" !important;
  font-size: 11px !important;
}

@media (max-width: 1180px) {
  .metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
}

@media (max-width: 1050px) {
  .app,
  .app.sidebar-is-collapsed {
    grid-template-columns: 1fr !important;
  }

  .sidebar {
    width: min(300px, 86vw) !important;
    max-width: min(300px, 86vw) !important;
    min-width: 0 !important;
  }

  .main {
    max-width: 100%;
  }
}

@media (max-width: 760px) {
  .main {
    padding: 12px !important;
  }

  .metrics {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }

  .metric,
  .provider-kpi {
    min-height: 112px !important;
    padding: 18px !important;
  }

  .dashboard-construction-scene {
    grid-template-columns: 1fr !important;
    min-height: 0 !important;
    max-height: none !important;
    padding: 18px !important;
  }

  .dashboard-construction-scene img {
    max-height: 110px !important;
    justify-self: center !important;
  }

  .table-wrap {
    overflow-x: auto !important;
  }

  .table-wrap table {
    min-width: 680px !important;
  }

  .table-wrap thead {
    display: table-header-group !important;
  }

  .table-wrap tbody,
  .table-wrap tr {
    display: revert !important;
  }

  .table-wrap td,
  .table-wrap th {
    display: table-cell !important;
    width: auto !important;
  }
}

/* ===== Absolute final stability lock - must be last in file ===== */
html,
body,
#app,
.app,
.main {
  overflow-x: hidden !important;
}

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 {
  transition: background-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease !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 {
  transform: none !important;
}

.app,
.provider-portal-shell,
.login-screen,
.module-page,
.workspace,
.panel,
.metric,
.modal,
.modal-card,
.toast {
  animation: none !important;
}

/* ===== Stability lock: prevent click/hover jitter. Keep this last. ===== */
html {
  scroll-behavior: smooth !important;
  overflow-x: hidden !important;
}

body,
#app,
.app,
.main {
  overflow-x: hidden !important;
}

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,
.tools-menu-panel button,
.row-actions button,
.dashboard-quick-actions button,
.provider-portal-sidebar nav button {
  transition: background-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease !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 {
  transform: none !important;
}

.panel:hover,
.metric:hover,
.provider-card:hover,
.provider-kpi:hover,
.insight:hover,
.message-item:hover,
.company-card:hover,
.stat-card:hover,
.pricing-card:hover {
  box-shadow: 0 10px 26px rgba(15, 23, 42, 0.08) !important;
}

.app,
.provider-portal-shell,
.login-screen,
.module-page,
.workspace,
.panel,
.metric,
.modal,
.modal-card,
.toast {
  animation: none !important;
}

.nav-section-arrow,
.sound-toggle-slider::before,
.mobile-nav-open .sidebar,
[dir="rtl"] .mobile-nav-open .sidebar {
  transition: background-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease, opacity 0.2s ease !important;
}

.nav-section.open .nav-section-arrow {
  transform: none !important;
}

.sidebar,
[dir="rtl"] .sidebar {
  will-change: auto !important;
}

@media (max-width: 520px) {
  .topbar,
  .panel,
  .provider-card {
    border-radius: 12px !important;
  }

  .metric strong,
  .provider-kpi strong {
    font-size: 28px !important;
  }
}

.survey-page {
  display: grid;
  gap: 16px;
}

.survey-filters {
  display: grid;
  grid-template-columns: minmax(180px, 1.4fr) repeat(8, minmax(130px, 1fr));
  gap: 10px;
  margin: 14px 0 18px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.survey-filters input,
.survey-filters select,
.survey-threshold input {
  min-height: 42px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  padding: 8px 10px;
}

.survey-deviation {
  background: color-mix(in srgb, var(--danger) 9%, var(--surface)) !important;
}

.survey-deviation td:first-child {
  box-shadow: inset 3px 0 var(--danger);
}

[dir="rtl"] .survey-deviation td:first-child {
  box-shadow: inset -3px 0 var(--danger);
}

.survey-threshold {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.survey-threshold input {
  width: 76px;
}

.survey-analytics-grid {
  display: grid;
  grid-template-columns: minmax(300px, 1fr) minmax(360px, 1.3fr);
  gap: 16px;
}

.survey-bars {
  min-height: 210px;
  display: flex;
  align-items: end;
  gap: 14px;
  overflow-x: auto;
  padding: 18px 6px 4px;
}

.survey-bars > div {
  min-width: 58px;
  display: grid;
  justify-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
}

.survey-bars i {
  display: block;
  width: 28px;
  min-height: 6px;
  border-radius: 5px 5px 2px 2px;
  background: var(--primary);
  transition: height 220ms ease;
}

.survey-bars strong {
  color: var(--text);
}

.survey-attachment-modal .document-preview-frame,
.survey-attachment-modal .document-image-preview {
  min-height: 62vh;
}

@media (max-width: 900px) {
  .survey-filters {
    grid-template-columns: repeat(2, minmax(160px, 1fr));
    overflow: visible;
  }

  .survey-analytics-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .survey-filters {
    grid-template-columns: 1fr;
  }

  .survey-page .panel-head {
    align-items: stretch;
  }

  .survey-page .panel-head .row-actions {
    width: 100%;
    overflow-x: auto;
    flex-wrap: nowrap;
  }
}

.approval-center {
  display: grid;
  gap: 16px;
}

.approval-filters {
  display: grid;
  grid-template-columns: minmax(220px, 1.6fr) repeat(5, minmax(140px, 1fr)) auto;
  gap: 10px;
  margin: 14px 0 18px;
}

.approval-filters input,
.approval-filters select,
.approval-filters button,
.approval-settings-grid input[type="number"] {
  min-height: 42px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  padding: 8px 10px;
}

.approval-hero {
  align-items: flex-start;
}

.approval-hero-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.approval-table th,
.approval-table td {
  vertical-align: top;
}

.approval-drawer-modal {
  align-items: stretch;
  justify-content: flex-end;
}

.approval-drawer {
  width: min(760px, 96vw);
  max-height: 100dvh;
  min-height: 100dvh;
  border-radius: 18px 0 0 18px;
  overflow-y: auto;
}

[dir="rtl"] .approval-drawer-modal {
  justify-content: flex-start;
}

[dir="rtl"] .approval-drawer {
  border-radius: 0 18px 18px 0;
}

.approval-drawer-actions {
  position: sticky;
  bottom: 0;
  z-index: 2;
  padding-top: 12px;
  background: var(--surface);
  border-top: 1px solid var(--border);
}

.approval-user-settings {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-soft);
  padding: 14px;
}

.approval-settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.approval-settings-grid label {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--text);
}

.approval-settings-grid label:last-child {
  display: grid;
}

.approval-detail-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.approval-detail-grid > div,
.approval-payload > div {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  background: var(--surface-soft);
  display: grid;
  gap: 5px;
}

.approval-detail-grid span,
.approval-payload span {
  color: var(--muted);
  font-size: 12px;
}

.approval-payload {
  display: grid;
  grid-template-columns: repeat(2, minmax(200px, 1fr));
  gap: 10px;
}

.approval-payload h3 {
  grid-column: 1 / -1;
}

.approval-payload strong {
  overflow-wrap: anywhere;
}

.approval-timeline {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.approval-timeline h3 {
  margin: 0;
}

.approval-timeline-item {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  gap: 10px;
  align-items: flex-start;
}

.approval-timeline-item > span {
  width: 12px;
  height: 12px;
  margin-top: 6px;
  border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-soft);
}

.approval-timeline-item > div {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-soft);
  padding: 10px 12px;
}

.approval-timeline-item small,
.approval-timeline-item p {
  display: block;
  margin: 4px 0 0;
  color: var(--muted);
}

@media (max-width: 760px) {
  .approval-filters,
  .approval-settings-grid,
  .approval-detail-grid,
  .approval-payload {
    grid-template-columns: 1fr;
  }

  .approval-payload h3 {
    grid-column: auto;
  }

  .approval-drawer {
    width: 100vw;
    min-height: 100dvh;
    border-radius: 0;
  }

  .approval-hero-badges {
    justify-content: flex-start;
  }
}

.inventory-management { display: grid; gap: 16px; }
.inventory-tabs { display: flex; gap: 6px; overflow-x: auto; border-bottom: 1px solid var(--border); padding-bottom: 8px; }
.inventory-tabs button { flex: 0 0 auto; border: 0; background: transparent; color: var(--muted); font-weight: 700; }
.inventory-tabs button.active { color: var(--primary); background: var(--primary-soft); }
.inventory-toolbar { display: grid; grid-template-columns: minmax(180px, 1fr) minmax(150px, 220px) minmax(140px, 200px) auto; }
.inventory-barcode { display: inline-block; min-width: 112px; padding: 22px 8px 4px; color: #111827; background: repeating-linear-gradient(90deg, #111827 0 2px, #fff 2px 4px, #111827 4px 5px, #fff 5px 8px) top / 100% 18px no-repeat; font-family: monospace; font-size: 11px; text-align: center; }
.warehouse-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 12px; }
.warehouse-card { border: 1px solid var(--border); border-radius: 8px; padding: 16px; background: var(--surface); }
.warehouse-card > div:first-child, .warehouse-stats { display: flex; justify-content: space-between; gap: 8px; }
.warehouse-card > div:first-child span, .warehouse-card p { color: var(--muted); }
.warehouse-stats { border-top: 1px solid var(--border); padding-top: 12px; margin-top: 12px; flex-wrap: wrap; }
.dashboard-hr-inventory { display: grid; grid-template-columns: 1.2fr 0.8fr; gap: 16px; margin-block: 16px; }
.performance-list { display: grid; gap: 10px; }
.performance-row { display: grid; grid-template-columns: 90px minmax(100px, 1fr) minmax(130px, auto); gap: 10px; align-items: center; }
.performance-track { height: 8px; overflow: hidden; border-radius: 4px; background: var(--primary-soft); }
.performance-track i { display: block; height: 100%; background: var(--success); }

@media (max-width: 800px) {
  .inventory-toolbar, .dashboard-hr-inventory, .performance-row { grid-template-columns: 1fr; }
  .inventory-tabs { margin-inline: -8px; padding-inline: 8px; }
}

.quotation-page { display: grid; gap: 16px; }
.quotation-header { display: grid; gap: 14px; }
.quotation-filters { display: grid; grid-template-columns: minmax(180px, 260px) minmax(220px, 1fr); gap: 10px; }
.quotation-best-row { background: color-mix(in srgb, var(--success) 8%, var(--surface)); }
.quotation-recommendation { margin: 0; padding: 16px; border-inline-start: 4px solid var(--success); background: color-mix(in srgb, var(--success) 8%, var(--surface)); font-weight: 700; line-height: 1.8; }
.quotation-comparison th, .quotation-comparison td { min-width: 150px; vertical-align: top; }
.quotation-comparison th:first-child, .quotation-comparison td:first-child { position: sticky; inset-inline-start: 0; z-index: 1; background: var(--surface); }
.quotation-comparison .best-price { background: color-mix(in srgb, var(--success) 12%, var(--surface)); color: var(--success); }
.comparison-total td { border-top: 2px solid var(--primary); }
.quotation-review-modal { width: min(980px, 96vw); }
.button-link { display: inline-flex; align-items: center; min-height: 34px; padding: 6px 10px; border: 1px solid var(--border); border-radius: 6px; color: var(--primary); text-decoration: none; font-weight: 700; }

@media (max-width: 800px) {
  .quotation-filters { grid-template-columns: 1fr; }
}

.tax-center-page {
  display: grid;
  gap: 16px;
}

.tax-hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.tax-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(280px, .8fr);
  gap: 16px;
}

.tax-checklist {
  display: grid;
  gap: 10px;
}

.tax-checklist > div {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-soft);
}

@media (max-width: 900px) {
  .tax-hero,
  .tax-grid {
    grid-template-columns: 1fr;
    display: grid;
  }
}

.community-page {
  display: grid;
  gap: 16px;
  color: var(--text);
}

.community-topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: auto minmax(220px, 1fr) auto;
  gap: 14px;
  align-items: center;
  border-radius: 8px;
}

.community-brand,
.community-top-actions,
.community-composer-input,
.community-post-head,
.community-post-stats,
.community-post-actions,
.community-suggested {
  display: flex;
  align-items: center;
  gap: 10px;
}

.community-brand span,
.community-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: linear-gradient(135deg, #2563eb, #10b981);
  color: #fff;
  font-weight: 900;
}

.community-avatar img,
.community-avatar-image img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.community-avatar-image {
  background: #fff;
  border: 1px solid rgba(37, 99, 235, 0.16);
}

.community-search input {
  width: 100%;
  min-height: 42px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-soft);
  color: var(--text);
  padding: 0 16px;
}

.community-layout {
  display: grid;
  grid-template-columns: minmax(220px, 280px) minmax(0, 1fr) minmax(240px, 320px);
  gap: 16px;
  align-items: start;
}

.community-left,
.community-right {
  position: sticky;
  top: 88px;
  display: grid;
  gap: 12px;
}

.community-profile-card {
  overflow: hidden;
  text-align: center;
}

.community-cover {
  height: 74px;
  margin: -16px -16px 0;
  background: linear-gradient(135deg, rgba(37,99,235,.9), rgba(16,185,129,.72));
}

.community-avatar-large {
  width: 70px;
  height: 70px;
  margin: -34px auto 8px;
  border: 4px solid var(--surface);
  border-radius: 18px;
  font-size: 22px;
}

.community-mini-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 8px;
  margin-top: 12px;
}

.community-mini-stats span {
  color: var(--muted);
  font-size: 12px;
}

.community-quick {
  display: grid;
  gap: 6px;
}

.community-quick button,
.community-tabs button,
.community-compose-tools button,
.community-post-actions button,
.community-suggested button,
.community-bottom-nav button {
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font-weight: 800;
}

.community-quick button {
  justify-content: flex-start;
  min-height: 38px;
  text-align: start;
}

.community-quick button.active,
.community-tabs button.active {
  background: var(--primary-soft);
  color: var(--primary);
}

.community-feed {
  display: grid;
  gap: 14px;
  min-width: 0;
}

.community-composer {
  display: grid;
  gap: 12px;
}

.community-composer-input textarea {
  flex: 1;
  min-height: 76px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-soft);
  color: var(--text);
  text-align: start;
  padding: 14px 16px;
  resize: vertical;
  font: inherit;
}

.community-composer-row {
  display: grid;
  grid-template-columns: minmax(180px, 260px) 1fr;
  gap: 10px;
  align-items: center;
}

.community-composer-row select,
.community-file-picker {
  min-height: 42px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-soft);
  color: var(--text);
  padding: 0 12px;
  font-weight: 800;
}

.community-file-picker {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}

.community-file-picker input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.community-compose-tools,
.community-tabs,
.community-post-stats,
.community-post-actions {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.community-compose-tools button {
  flex: 0 0 auto;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  min-height: 36px;
}

.community-publish {
  justify-self: end;
  min-width: 140px;
}

.community-posts {
  display: grid;
  gap: 14px;
}

.community-post-card {
  display: grid;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 10px 28px rgba(15, 23, 42, .06);
}

.community-post-head {
  justify-content: space-between;
}

.community-company-line {
  display: flex;
  align-items: center;
  gap: 7px;
}

.community-company-line button {
  border: 0;
  background: transparent;
  color: var(--muted);
  margin-inline-start: auto;
}

.verified-dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 12px;
}

.community-type-badge {
  justify-self: start;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 12px;
  font-weight: 900;
}

.community-post-text {
  margin: 0;
  line-height: 1.9;
  color: var(--text);
  font-weight: 650;
}

.community-media-gallery {
  display: grid;
  grid-template-columns: 1.2fr 1fr 1fr;
  gap: 8px;
  min-height: 170px;
}

.community-media-gallery div {
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(37,99,235,.85), rgba(15,23,42,.08)), repeating-linear-gradient(45deg, rgba(255,255,255,.22) 0 10px, transparent 10px 20px);
}

.community-media-gallery div:first-child {
  grid-row: span 2;
}

.community-media-gallery.emerald div {
  background: linear-gradient(135deg, rgba(16,185,129,.85), rgba(15,23,42,.08)), repeating-linear-gradient(45deg, rgba(255,255,255,.22) 0 10px, transparent 10px 20px);
}

.community-media-gallery.orange div {
  background: linear-gradient(135deg, rgba(249,115,22,.78), rgba(37,99,235,.12)), repeating-linear-gradient(45deg, rgba(255,255,255,.22) 0 10px, transparent 10px 20px);
}

.community-post-stats {
  color: var(--muted);
  font-weight: 800;
  border-bottom: 1px solid var(--border);
  padding-bottom: 10px;
}

.community-post-actions {
  justify-content: space-between;
}

.community-post-actions button {
  flex: 1;
  min-width: 86px;
  background: var(--surface-soft);
}

.community-post-actions button.active {
  background: var(--primary);
  color: #fff;
}

.community-media-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.community-media-grid.count-1 {
  grid-template-columns: 1fr;
}

.community-media-grid.count-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.community-media-item {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 150px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-soft);
  color: var(--text);
  text-decoration: none;
}

.community-media-item img,
.community-media-item video {
  width: 100%;
  height: 100%;
  max-height: 360px;
  object-fit: cover;
  display: block;
}

.community-pdf {
  gap: 8px;
  padding: 16px;
}

.community-pdf span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border-radius: 14px;
  background: #dc2626;
  color: #fff;
  font-weight: 900;
}

.community-media-more {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(15, 23, 42, .64);
  color: #fff;
  font-size: 24px;
  font-weight: 900;
}

.community-comments {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-soft);
}

.community-comments div {
  display: grid;
  gap: 3px;
}

.community-comments span {
  color: var(--text);
}

.community-side-card {
  display: grid;
  gap: 12px;
}

.community-suggested {
  align-items: center;
}

.community-suggested > div:nth-child(2) {
  min-width: 0;
  flex: 1;
}

.community-suggested small {
  display: block;
  color: var(--muted);
}

.community-suggested button {
  background: var(--primary-soft);
  color: var(--primary);
}

.community-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.community-tags span,
.community-stat-grid div {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-soft);
  padding: 9px 11px;
}

.community-stat-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.community-stat-grid span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.community-bottom-nav {
  display: none;
}

.private-notes-page {
  display: grid;
  gap: 16px;
}

.private-notes-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.private-notes-hero h2 {
  margin: 4px 0;
  color: var(--text);
}

.private-notes-layout {
  display: grid;
  grid-template-columns: minmax(260px, 340px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.private-notes-list,
.private-note-editor-panel {
  min-width: 0;
}

.private-notes-filters {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

.private-notes-filters input,
.private-notes-filters select,
.private-note-editor-head input,
.private-note-meta-grid input,
.private-note-meta-grid select,
.private-note-body {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-soft);
  color: var(--text);
  padding: 10px 12px;
  font: inherit;
  box-sizing: border-box;
}

.private-notes-items {
  display: grid;
  gap: 8px;
  max-height: calc(100dvh - 290px);
  overflow-y: auto;
  padding-inline-end: 4px;
}

.private-note-item {
  display: grid;
  gap: 5px;
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  padding: 12px;
  text-align: start;
}

.private-note-item.active {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}

.private-note-item span,
.private-note-item small,
.private-note-save-status {
  color: var(--muted);
}

.private-note-editor-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
}

.private-note-meta-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.private-note-meta-grid label {
  display: grid;
  gap: 6px;
  color: var(--text);
  font-weight: 800;
}

.private-note-body {
  min-height: 360px;
  resize: vertical;
  line-height: 1.9;
}

.private-note-save-status {
  min-height: 24px;
  margin: 8px 0;
  font-size: 13px;
}

.private-note-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.private-note-actions span {
  flex: 1 1 auto;
}

.private-notes-empty {
  padding: 8px;
}

@media (max-width: 1180px) {
  .community-layout {
    grid-template-columns: minmax(210px, 260px) minmax(0, 1fr);
  }

  .community-right {
    display: none;
  }
}

@media (max-width: 760px) {
  .community-topbar {
    grid-template-columns: 1fr auto;
  }

  .community-search {
    grid-column: 1 / -1;
  }

  .community-layout {
    grid-template-columns: 1fr;
  }

  .community-left,
  .community-right {
    position: static;
  }

  .community-left {
    display: none;
  }

  .community-media-gallery {
    grid-template-columns: 1fr 1fr;
    min-height: 130px;
  }

  .community-composer-row,
  .community-media-grid {
    grid-template-columns: 1fr;
  }

  .community-bottom-nav {
    position: sticky;
    bottom: 0;
    z-index: 6;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 6px;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 18px 18px 0 0;
    background: var(--surface);
  }

  .private-notes-hero,
  .private-notes-layout,
  .private-note-editor-head,
  .private-note-meta-grid {
    grid-template-columns: 1fr;
  }

  .private-notes-hero {
    display: grid;
  }

  .private-note-body {
    min-height: 260px;
  }

  .private-notes-items {
    max-height: none;
  }
}

.audit-filters {
  display: grid;
  grid-template-columns: repeat(5, minmax(150px, 1fr));
  gap: 10px;
  margin: 14px 0 18px;
  align-items: end;
}

.audit-filters label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.audit-filters input,
.audit-filters select {
  width: 100%;
  min-height: 42px;
}

@media (max-width: 1050px) {
  .audit-filters {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 620px) {
  .audit-filters {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px) {
  .main {
    padding: 14px;
  }

  .form-grid,
  .nav {
    grid-template-columns: 1fr;
  }

  .actions,
  .toolbar,
  .pagination {
    align-items: stretch;
    flex-direction: column;
  }

  .search {
    min-width: 0;
  }

  .attendance-row {
    grid-template-columns: 1fr;
  }

  .attendance-options {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .attendance-month-stats,
  .monthly-attendance-workspace {
    grid-template-columns: 1fr;
  }

  .month-day-grid {
    grid-template-columns: repeat(7, minmax(36px, 1fr));
  }

  .month-day-button {
    min-height: 46px;
    padding: 4px;
  }

  .day-status-picker .attendance-options,
  .monthly-payroll-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .attendance-year {
    grid-template-columns: 1fr;
  }

  .feature-grid,
  .managed-users > div,
  .firebase-status-grid {
    grid-template-columns: 1fr;
  }

  .project-expense-filters,
  .contractor-filters,
  .contractor-data-grid,
  .report-details-grid,
  .residency-details-grid,
  .asset-detail-grid,
  .important-alert {
    grid-template-columns: 1fr;
  }

  .report-detail-full,
  .residency-notes,
  .asset-detail-full,
  .important-alert .alert-days {
    grid-column: auto;
  }

  .report-gallery,
  .image-upload-preview {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .salary-slip-employee {
    grid-template-columns: 1fr;
  }

  .attendance-date-input,
  .month-input {
    width: 100%;
  }
}

@media print {
  .sidebar,
  .topbar .actions,
  .profile-actions,
  .row-actions,
  .toast {
    display: none !important;
  }

  .app {
    display: block;
  }

  .main,
  .modal-card {
    padding: 0;
    box-shadow: none;
    border: 0;
  }

  .modal {
    position: static;
    background: #fff;
    padding: 0;
  }
}

.nav-button {
  position: relative;
}

.nav-badge {
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  display: inline-grid;
  place-items: center;
  border-radius: 10px;
  background: #c2413b;
  color: #fff;
  font-size: 0.72rem;
  margin-inline-start: auto;
}

.record-attribution,
.table-subtitle {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.74rem;
  line-height: 1.45;
}

.company-user-modal {
  width: min(1180px, 96vw);
}

.permission-editor {
  border: 1px solid var(--line);
  border-radius: 7px;
  overflow: hidden;
  background: #fff;
}

.permission-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  background: #f4f7f8;
  border-bottom: 1px solid var(--line);
}

.permission-table-wrap {
  max-height: 390px;
  overflow: auto;
}

.permission-table {
  min-width: 980px;
}

.permission-table th,
.permission-table td {
  text-align: center;
  white-space: nowrap;
}

.permission-table th:first-child,
.permission-table td:first-child {
  position: sticky;
  inset-inline-start: 0;
  z-index: 1;
  min-width: 170px;
  text-align: start;
  background: #fff;
}

.permission-table thead th:first-child {
  background: #155e75;
}

.permission-table input {
  width: 18px;
  height: 18px;
  accent-color: #0f766e;
}

.messaging-layout {
  min-height: calc(100vh - 150px);
  display: grid;
  grid-template-columns: minmax(260px, 340px) minmax(0, 1fr);
  gap: 14px;
}

.conversation-panel,
.chat-panel {
  min-height: 620px;
  margin: 0;
}

.new-conversation {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  margin-bottom: 12px;
}

.conversation-list {
  display: grid;
  gap: 5px;
}

.conversation-list > button {
  width: 100%;
  min-height: 66px;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  padding: 9px;
  border-color: transparent;
  text-align: start;
}

.conversation-list > button.active {
  border-color: #9ccfca;
  background: #e8f7f2;
}

.conversation-list span:nth-child(2) {
  min-width: 0;
}

.conversation-list strong,
.conversation-list small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation-list small {
  margin-top: 4px;
  color: var(--muted);
}

.conversation-list b {
  min-width: 21px;
  height: 21px;
  display: grid;
  place-items: center;
  border-radius: 11px;
  background: #0f766e;
  color: #fff;
  font-size: 0.72rem;
}

.conversation-avatar {
  width: 42px;
  height: 42px;
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  background: #155e75;
  color: #fff;
  font-weight: 800;
}

.chat-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
}

.chat-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.chat-header-actions {
  margin-inline-start: auto;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.chat-header-actions button {
  min-height: 32px;
  padding: 6px 10px;
  font-size: 0.78rem;
}

.chat-header-actions .chat-call-button {
  width: 44px;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  border-radius: 999px;
  font-size: 18px;
  display: inline-grid;
  place-items: center;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1d4ed8;
}

.chat-call-log {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid #dbeafe;
  border-radius: 14px;
  background: #eff6ff;
}

.chat-call-log > span {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #2563eb;
  color: #fff;
}

.chat-call-log strong,
.chat-call-log small {
  display: block;
}

.chat-call-log button {
  min-height: 34px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid #bfdbfe;
  background: #fff;
  color: #1d4ed8;
}

.call-overlay {
  position: fixed;
  inset: 0;
  z-index: 20000;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(15, 23, 42, .72);
  backdrop-filter: blur(10px);
}

.call-card {
  width: min(760px, 100%);
  min-height: 420px;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 16px;
  border-radius: 28px;
  padding: 18px;
  background: #0f172a;
  color: #fff;
  box-shadow: 0 24px 80px rgba(0, 0, 0, .35);
}

.call-card header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.call-card header span,
.call-card header p,
.call-card header b {
  color: #cbd5e1;
}

.call-card header em {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(34, 197, 94, 0.14);
  color: #bbf7d0;
  font-style: normal;
  font-size: 0.78rem;
}

.call-card h2 {
  margin: 4px 0;
  color: #fff;
}

.call-close,
.call-card footer button {
  min-width: 44px;
  min-height: 44px;
  border: 0;
  border-radius: 999px;
  padding: 0 16px;
  background: rgba(255, 255, 255, .12);
  color: #fff;
}

.call-close {
  width: 44px;
  padding: 0;
  font-size: 24px;
}

.call-card footer {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
}

.call-card footer .call-accept {
  background: #16a34a;
}

.call-card footer .call-end {
  background: #dc2626;
}

.call-audio-stage {
  display: grid;
  place-items: center;
  gap: 14px;
}

.call-audio-stage .conversation-avatar {
  width: 116px;
  height: 116px;
  font-size: 42px;
  box-shadow: 0 0 0 18px rgba(37, 99, 235, .14);
}

.call-video-stage {
  position: relative;
  min-height: 360px;
  overflow: hidden;
  border-radius: 22px;
  background: #020617;
}

.call-video-stage video[data-call-remote-video] {
  width: 100%;
  height: 100%;
  min-height: 360px;
  object-fit: cover;
  background: #020617;
}

.call-video-stage video[data-call-local-video] {
  position: absolute;
  inset-inline-end: 14px;
  inset-block-end: 14px;
  width: min(180px, 34vw);
  aspect-ratio: 9 / 12;
  object-fit: cover;
  border-radius: 18px;
  border: 2px solid rgba(255, 255, 255, .75);
  background: #111827;
}

.chat-header strong,
.chat-header small {
  display: block;
}

.chat-header small {
  margin-top: 3px;
  color: var(--muted);
}

.chat-thread {
  min-height: 0;
  max-height: calc(100vh - 330px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px 4px;
}

.chat-message {
  max-width: min(76%, 620px);
  align-self: flex-start;
}

.chat-message.sent {
  align-self: flex-end;
}

.chat-message > div {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f4f7f8;
  line-height: 1.65;
}

.chat-message-bubble {
  position: relative;
}

.chat-message-content {
  min-width: 0;
}

.chat-delete-message {
  margin-top: 7px;
  padding: 3px 8px;
  min-height: 26px;
  border: 1px solid rgba(220, 38, 38, 0.25);
  border-radius: 999px;
  background: rgba(254, 242, 242, 0.92);
  color: #b91c1c;
  font-size: 0.72rem;
  box-shadow: none;
}

.chat-delete-message:hover {
  background: #fee2e2;
  border-color: rgba(220, 38, 38, 0.45);
}

.chat-message.sent > div {
  border-color: #9ccfca;
  background: #e8f7f2;
}

.chat-message > small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.7rem;
}

.chat-image {
  display: block;
  margin-top: 8px;
}

.chat-image img {
  display: block;
  width: min(320px, 100%);
  max-height: 260px;
  object-fit: cover;
  border-radius: 6px;
}

.chat-file {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 8px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.chat-message.is-voice > div {
  min-width: min(360px, 72vw);
}

.chat-voice-player {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  gap: 8px 10px;
  align-items: center;
  min-width: min(330px, 100%);
  padding: 10px;
  border: 1px solid rgba(37, 99, 235, 0.16);
  border-radius: 14px;
  background: #ffffff;
}

.chat-voice-icon {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: #eff6ff;
  color: #2563eb;
  font-size: 1.1rem;
}

.chat-voice-player audio {
  width: 100%;
  min-width: 0;
  height: 38px;
}

.chat-voice-player small {
  grid-column: 2;
  color: var(--muted);
}

.chat-composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto auto;
  gap: 8px;
  align-items: end;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.chat-composer textarea {
  min-height: 48px;
  max-height: 130px;
  resize: vertical;
}

.file-button input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.file-button span {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
}

.voice-record-button {
  width: 44px;
  min-width: 44px;
  height: 44px;
  min-height: 44px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  border: 1px solid rgba(37, 99, 235, 0.22);
  background: #eff6ff;
  color: #2563eb !important;
  font-size: 1.1rem;
  opacity: 1 !important;
  visibility: visible !important;
  z-index: 3;
}

.voice-record-button.is-recording {
  background: #fee2e2;
  border-color: #fecaca;
  color: #dc2626;
}

.voice-recorder-panel {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  min-height: 52px;
  padding: 10px 12px;
  border: 1px solid #bfdbfe;
  border-radius: 14px;
  background: #eff6ff;
  color: #0f172a;
}

.voice-recorder-panel strong,
.voice-recorder-panel span {
  color: #0f172a;
}

.voice-recorder-panel audio {
  flex: 1 1 220px;
  min-width: 180px;
  height: 38px;
}

.voice-recorder-panel progress {
  flex: 1 1 170px;
  height: 8px;
  accent-color: #2563eb;
}

.voice-recorder-panel.is-recording {
  background: #fff7ed;
  border-color: #fed7aa;
}

.voice-recorder-panel.is-ready {
  background: #f0fdf4;
  border-color: #bbf7d0;
}

.voice-recorder-panel.is-error {
  background: #fef2f2;
  border-color: #fecaca;
}

.voice-pulse {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: #dc2626;
  box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.42);
  animation: voicePulse 1.2s ease-out infinite;
}

@keyframes voicePulse {
  0% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.42); }
  70% { box-shadow: 0 0 0 10px rgba(220, 38, 38, 0); }
  100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0); }
}

.chat-empty {
  grid-row: 1 / -1;
  display: grid;
  place-items: center;
  color: var(--muted);
}

.device-cell {
  max-width: 260px;
}

@media (max-width: 800px) {
  .messaging-layout {
    grid-template-columns: 1fr;
  }

  .conversation-panel,
  .chat-panel {
    min-height: auto;
  }

  .chat-panel {
    min-height: 560px;
  }

  .chat-thread {
    max-height: 420px;
  }
}

@media (max-width: 620px) {
  .permission-head {
    grid-template-columns: 1fr;
  }

  .permission-head {
    align-items: stretch;
    flex-direction: column;
  }

  .chat-composer {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) 48px 48px !important;
    gap: 8px !important;
    align-items: center !important;
    padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
    background: var(--surface, #fff);
  }

  .chat-composer textarea,
  .voice-recorder-panel {
    grid-column: 1 / -1;
  }

  .chat-composer .file-button {
    grid-column: 1;
    min-width: 0;
  }

  .chat-composer .file-button span {
    width: 100%;
    justify-content: center;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .chat-composer .voice-record-button {
    grid-column: 2;
    width: 48px !important;
    min-width: 48px !important;
    height: 48px !important;
    min-height: 48px !important;
    font-size: 1.25rem !important;
  }

  .chat-composer button.primary[type="submit"] {
    grid-column: 3;
    width: 48px;
    min-width: 48px;
    height: 48px;
    min-height: 48px;
    padding: 0;
    overflow: hidden;
    font-size: 0;
  }

  .chat-composer button.primary[type="submit"]::before {
    content: "\27A4";
    font-size: 1.15rem;
  }

  .chat-message {
    max-width: 90%;
  }

  .chat-message.is-voice > div {
    min-width: 0;
  }

  .chat-voice-player {
    grid-template-columns: 34px minmax(0, 1fr);
  }

  .voice-recorder-panel {
    align-items: stretch;
  }

  .voice-recorder-panel button,
  .voice-recorder-panel audio,
  .voice-recorder-panel progress {
    width: 100%;
  }
}

body[data-theme="dark"] .chat-voice-player,
body[data-theme="dark"] .voice-recorder-panel {
  background: #111827;
  border-color: rgba(148, 163, 184, 0.32);
}

body[data-theme="dark"] .chat-voice-player *,
body[data-theme="dark"] .voice-recorder-panel * {
  color: #f8fafc;
}

body[data-theme="glass"] .chat-voice-player,
body[data-theme="glass"] .voice-recorder-panel {
  background: rgba(255, 255, 255, 0.78) !important;
  border-color: rgba(255, 255, 255, 0.38) !important;
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

body[data-theme="glass"] .chat-voice-player *,
body[data-theme="glass"] .voice-recorder-panel * {
  color: #0f172a !important;
}

/* Modern SaaS visual system - 2026 */
:root {
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-2: #eff6ff;
  --ink: #0f172a;
  --heading: #1e3a8a;
  --muted: #64748b;
  --line: #dbe4f0;
  --line-strong: #bfdbfe;
  --brand: #2563eb;
  --brand-2: #1e3a8a;
  --accent: #16a34a;
  --danger: #dc2626;
  --ok: #16a34a;
  --warning: #d97706;
  --shadow: 0 8px 24px rgba(30, 58, 138, 0.08);
  --shadow-hover: 0 12px 30px rgba(37, 99, 235, 0.13);
}

html {
  background: #ffffff;
  scroll-behavior: smooth;
}

body {
  background: #ffffff;
  color: var(--ink);
  font-family: "Cairo", "Tajawal", Tahoma, Arial, sans-serif;
  font-weight: 400;
  letter-spacing: 0;
  line-height: 1.6;
}

button,
input,
select,
textarea {
  letter-spacing: 0;
}

h1,
h2,
h3,
h4,
strong {
  color: var(--heading);
}

h1 {
  font-size: clamp(1.45rem, 2vw, 1.9rem);
  font-weight: 800;
  line-height: 1.3;
}

h2 {
  font-size: 1.08rem;
  font-weight: 800;
}

h3 {
  font-size: 0.98rem;
  font-weight: 700;
}

button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #ffffff;
  color: #1e293b;
  padding: 8px 14px;
  font-weight: 600;
  transition:
    color 160ms ease,
    background-color 160ms ease,
    border-color 160ms ease,
    box-shadow 160ms ease,
    transform 120ms ease;
}

button:hover {
  border-color: #93c5fd;
  background: #f8fbff;
  color: var(--brand);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.09);
}

button:active {
  transform: scale(0.98);
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.2);
  outline-offset: 2px;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
  transform: none;
}

.primary,
.auth-submit {
  border-color: var(--brand);
  background: var(--brand);
  color: #ffffff;
  box-shadow: 0 5px 14px rgba(37, 99, 235, 0.2);
}

.primary:hover,
.auth-submit:hover {
  border-color: #1d4ed8;
  background: #1d4ed8;
  color: #ffffff;
  box-shadow: 0 8px 18px rgba(37, 99, 235, 0.25);
}

.danger,
.destructive-button {
  border-color: #fecaca;
  background: #fff7f7;
  color: var(--danger);
}

.danger:hover,
.destructive-button:hover {
  border-color: var(--danger);
  background: var(--danger);
  color: #ffffff;
}

.success {
  border-color: var(--ok);
  background: var(--ok);
  color: #ffffff;
}

.success:hover {
  border-color: #15803d;
  background: #15803d;
  color: #ffffff;
}

.app {
  grid-template-columns: 274px minmax(0, 1fr);
  background: #ffffff;
}

.sidebar {
  min-height: 100vh;
  padding: 18px 14px;
  overflow: hidden;
  border-inline-end: 1px solid var(--line);
  background: #ffffff;
  color: var(--ink);
  box-shadow: 5px 0 24px rgba(30, 58, 138, 0.05);
  z-index: 12;
}

[dir="rtl"] .sidebar {
  box-shadow: -5px 0 24px rgba(30, 58, 138, 0.05);
}

.brand {
  min-height: 58px;
  margin-bottom: 16px;
  padding: 4px 5px 13px;
  border-bottom: 1px solid #eaf0f7;
}

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: var(--brand);
  color: #ffffff;
  box-shadow: 0 7px 16px rgba(37, 99, 235, 0.22);
  font-weight: 800;
}

.brand strong {
  color: var(--heading);
  font-size: 0.92rem;
  white-space: nowrap;
}

.brand small {
  color: var(--muted);
  font-size: 0.72rem;
}

.tenant-switcher {
  margin-bottom: 12px;
  padding: 10px;
  border-color: #dbeafe;
  border-radius: 8px;
  background: var(--surface-2);
}

.tenant-switcher label {
  color: var(--muted);
}

.nav {
  gap: 4px;
  max-height: calc(100vh - 168px);
  padding: 2px 1px 14px;
  scrollbar-color: #bfdbfe transparent;
  scrollbar-width: thin;
}

.nav-button {
  grid-template-columns: 35px minmax(0, 1fr) auto;
  min-height: 44px;
  padding: 5px 8px;
  border: 1px solid transparent;
  border-radius: 7px;
  color: #475569;
  font-size: 0.84rem;
}

.nav-button > span:first-child {
  width: 32px;
  height: 32px;
  display: inline-grid;
  place-items: center;
  overflow: hidden;
  border-radius: 7px;
  background: #eff6ff;
  color: var(--brand);
  font-size: 0;
  font-weight: 800;
  transition: background-color 160ms ease, color 160ms ease;
}

.nav-button > span:first-child::before {
  content: "\2022";
  font-size: 17px;
}

.nav-button[data-module="dashboard"] > span:first-child::before { content: "\2302"; }
.nav-button[data-module="joinRequests"] > span:first-child::before { content: "\2713"; }
.nav-button[data-module="masterManagement"] > span:first-child::before,
.nav-button[data-module="settings"] > span:first-child::before { content: "\2699"; }
.nav-button[data-module="masterMessages"] > span:first-child::before,
.nav-button[data-module="messages"] > span:first-child::before,
.nav-button[data-module="inbox"] > span:first-child::before { content: "\2709"; }
.nav-button[data-module="companies"] > span:first-child::before { content: "\25A6"; }
.nav-button[data-module="users"] > span:first-child::before,
.nav-button[data-module="teamUsers"] > span:first-child::before { content: "U"; font-size: 13px; }
.nav-button[data-module="projects"] > span:first-child::before { content: "\25A4"; }
.nav-button[data-module="extracts"] > span:first-child::before { content: "\2261"; }
.nav-button[data-module="employees"] > span:first-child::before { content: "\25CF"; }
.nav-button[data-module="dailyAttendance"] > span:first-child::before { content: "\2713"; }
.nav-button[data-module="payroll"] > span:first-child::before { content: "$"; font-size: 15px; }
.nav-button[data-module="advances"] > span:first-child::before { content: "\2194"; }
.nav-button[data-module="expenses"] > span:first-child::before { content: "\2212"; }
.nav-button[data-module="inventory"] > span:first-child::before { content: "\25A3"; }
.nav-button[data-module="equipment"] > span:first-child::before { content: "\2692"; }
.nav-button[data-module="fixedAssets"] > span:first-child::before { content: "\25C8"; }
.nav-button[data-module="partners"] > span:first-child::before { content: "\2194"; }
.nav-button[data-module="accounting"] > span:first-child::before { content: "\03A3"; }
.nav-button[data-module="documents"] > span:first-child::before { content: "\25A7"; }
.nav-button[data-module="siteReports"] > span:first-child::before { content: "\25A4"; }
.nav-button[data-module="aiReports"] > span:first-child::before { content: "AI"; font-size: 11px; }
.nav-button[data-module="audit"] > span:first-child::before { content: "\2637"; }

.telegram-admin-page .telegram-admin-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 0 12px;
  margin-bottom: 14px;
}

.telegram-admin-page .telegram-admin-tabs button,
.telegram-admin-page .telegram-admin-toolbar button {
  white-space: nowrap;
}

.telegram-admin-page .telegram-admin-tabs button.active {
  background: var(--primary, #2563eb);
  border-color: var(--primary, #2563eb);
  color: #fff;
}

.telegram-admin-page .telegram-admin-metrics .metric {
  appearance: none;
  border: 1px solid var(--line, #e2e8f0);
  text-align: inherit;
  cursor: pointer;
}

.telegram-admin-page .telegram-admin-toolbar {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) repeat(3, max-content);
  gap: 10px;
  align-items: center;
}

.telegram-admin-page .telegram-message-composer {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.telegram-admin-page .telegram-message-composer label {
  display: grid;
  gap: 6px;
  font-weight: 700;
}

.telegram-admin-page .telegram-message-composer textarea,
.telegram-admin-page .telegram-message-composer select {
  width: 100%;
}

.telegram-admin-page .telegram-recipient-picker {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 8px;
  max-height: 220px;
  overflow: auto;
  padding: 10px;
  border: 1px solid var(--line, #e2e8f0);
  border-radius: 8px;
  background: var(--surface-soft, #f8fafc);
}

.telegram-admin-page .telegram-recipient-picker label {
  display: flex;
  gap: 8px;
  align-items: center;
  font-weight: 600;
}

@media (max-width: 760px) {
  .telegram-admin-page .telegram-admin-toolbar {
    grid-template-columns: 1fr;
  }
}

.nav-button:hover {
  border-color: #dbeafe;
  background: #f8fbff;
  color: var(--brand);
  box-shadow: none;
}

.nav-button.active {
  border-color: #bfdbfe;
  background: var(--surface-2);
  color: var(--heading);
  box-shadow: inset 3px 0 0 var(--brand);
}

[dir="rtl"] .nav-button.active {
  box-shadow: inset -3px 0 0 var(--brand);
}

.nav-button.active > span:first-child {
  background: var(--brand);
  color: #ffffff;
}

.nav-badge {
  background: var(--danger);
  transition: transform 180ms ease, opacity 180ms ease;
}

.main {
  min-height: 100vh;
  padding: 0 24px 28px;
  background: #f8fbff;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  min-height: 84px;
  margin: 0 -24px 22px;
  padding: 16px 24px;
  align-items: center;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 4px 18px rgba(30, 58, 138, 0.05);
  backdrop-filter: blur(14px);
}

.topbar-heading {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar h1 {
  margin-bottom: 1px;
}

.topbar p {
  margin: 0;
  font-size: 0.82rem;
}

.actions {
  justify-content: flex-end;
}

.tools-menu {
  position: relative;
  display: flex;
  justify-content: flex-end;
  align-items: center;
}

.tools-menu-toggle {
  width: 42px;
  height: 42px;
  min-height: 42px;
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  font-size: 20px;
  line-height: 1;
  background: #ffffff;
  border: 1px solid var(--line);
  box-shadow: 0 8px 20px rgba(30, 58, 138, 0.08);
}

.tools-menu-toggle:hover,
.tools-menu.is-open .tools-menu-toggle {
  border-color: var(--primary);
  background: #eff6ff;
}

.tools-menu-panel {
  position: absolute;
  inset-block-start: calc(100% + 10px);
  inset-inline-end: 0;
  width: min(270px, calc(100vw - 28px));
  z-index: 80;
  display: grid;
  gap: 7px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 18px 42px rgba(15, 23, 42, 0.16);
}

.tools-menu-panel::before {
  content: "";
  position: absolute;
  inset-block-start: -6px;
  inset-inline-end: 16px;
  width: 12px;
  height: 12px;
  border-inline-start: 1px solid var(--line);
  border-block-start: 1px solid var(--line);
  background: #ffffff;
  transform: rotate(45deg);
}

.tools-menu-panel button,
.tools-menu-language {
  width: 100%;
  min-height: 38px;
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  border-radius: 7px;
  text-align: start;
}

.tools-menu-panel button {
  justify-content: start;
  border-color: transparent;
  background: transparent;
}

.tools-menu-panel button:hover {
  background: #f1f5f9;
}

.tools-menu-language {
  grid-template-columns: 1fr;
  padding: 4px 0;
}

.tools-menu-language span {
  font-size: 12px;
  color: var(--muted);
}

.tools-menu-language select {
  width: 100%;
}

.actions button,
.actions select {
  min-height: 38px;
}

#logout-btn {
  border-color: #fecaca;
  color: var(--danger);
}

#logout-btn:hover {
  border-color: var(--danger);
  background: #fff1f2;
}

input,
select,
textarea {
  min-height: 42px;
  border-color: var(--line);
  border-radius: 7px;
  background: #ffffff;
  color: var(--ink);
  padding: 9px 11px;
  transition: border-color 160ms ease, box-shadow 160ms ease, background-color 160ms ease;
}

input:hover,
select:hover,
textarea:hover {
  border-color: #bfdbfe;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.11);
}

.field label {
  color: #475569;
  font-weight: 600;
}

.metrics {
  gap: 12px;
  margin-bottom: 16px;
  animation: ui-fade-in 300ms ease both;
}

.metric {
  position: relative;
  min-height: 108px;
  overflow: hidden;
  padding: 18px;
  border-color: #dbeafe;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: var(--shadow);
  transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease;
}

.metric::before {
  content: "";
  position: absolute;
  inset-block: 0;
  inset-inline-start: 0;
  width: 4px;
  background: var(--brand);
}

.metric:nth-child(2)::before { background: var(--ok); }
.metric:nth-child(3)::before { background: #7c3aed; }
.metric:nth-child(4)::before { background: #d97706; }
.metric:nth-child(5)::before { background: #0891b2; }
.metric:nth-child(6)::before { background: #db2777; }

.metric:hover {
  border-color: #bfdbfe;
  box-shadow: var(--shadow-hover);
  transform: translateY(-2px);
}

.metric span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
}

.metric strong {
  margin-top: 10px;
  color: var(--heading);
  font-size: clamp(1.3rem, 2vw, 1.65rem);
  font-weight: 800;
}

.workspace,
.dashboard-finance-grid,
.project-finance-grid,
.contractor-finance-grid,
.messaging-layout {
  gap: 16px;
}

.panel,
.modal-card,
.login-card,
.tenant-switcher,
.metric {
  border-radius: 8px;
}

.panel {
  padding: 18px;
  border-color: var(--line);
  background: #ffffff;
  box-shadow: var(--shadow);
  animation: ui-slide-up 340ms ease both;
}

.workspace > :nth-child(2),
.dashboard-finance-grid > :nth-child(2) {
  animation-delay: 55ms;
}

.dashboard-finance-grid > :nth-child(3) {
  animation-delay: 95ms;
}

.panel-head {
  min-height: 36px;
  margin-bottom: 14px;
  padding-bottom: 11px;
  border-bottom: 1px solid #eaf0f7;
}

.panel-head h2,
.panel-head h3 {
  margin-bottom: 0;
}

.toolbar {
  gap: 9px;
  margin-bottom: 14px;
  padding: 10px;
  border: 1px solid #e5edf7;
  border-radius: 8px;
  background: #f8fbff;
}

.table-wrap {
  border-color: var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.5);
}

table {
  font-size: 0.82rem;
}

th,
td {
  padding: 12px 11px;
  border-bottom-color: #e8eef6;
}

th {
  background: var(--surface-2);
  color: var(--heading);
  font-size: 0.76rem;
  font-weight: 700;
  white-space: nowrap;
}

tbody tr:nth-child(even) td {
  background: #fbfdff;
}

tbody tr {
  transition: background-color 150ms ease;
}

tbody tr:hover td {
  background: #f0f7ff;
}

.row-actions {
  gap: 5px;
  align-items: center;
}

.row-actions button {
  min-height: 34px;
  padding: 5px 9px;
  font-size: 0.74rem;
}

.icon-action {
  width: 34px;
  min-width: 34px;
  min-height: 34px;
  border-color: #bfdbfe;
  background: #eff6ff;
  color: var(--brand);
}

.icon-action:hover {
  border-color: var(--brand);
  background: var(--brand);
  color: #ffffff;
}

.badge {
  min-height: 25px;
  background: #ecfdf3;
  color: #15803d;
  font-weight: 700;
}

.badge.warning {
  background: #fff7ed;
  color: #c2410c;
}

.badge.danger {
  background: #fef2f2;
  color: var(--danger);
}

.insight,
.managed-company,
.message-item,
.month-card,
.residency-details-grid > div,
.asset-detail-grid > div,
.contractor-data-grid > div,
.report-details-grid > div,
.salary-slip-employee > div,
.setting-toggle,
.firebase-status {
  border-color: var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.insight {
  box-shadow: 0 3px 12px rgba(30, 58, 138, 0.05);
}

.chart,
.ai-box {
  border-color: #bfdbfe;
  border-radius: 8px;
  background: var(--surface-2);
}

.bar,
.month-bar {
  background: var(--brand);
}

.chart .bar:nth-child(2n),
.employee-month-chart .month-bar-wrap:nth-child(2n) .month-bar {
  background: var(--ok);
}

.highest-spending-project {
  border-color: #fed7aa;
  background: #fff7ed;
}

.contractor-name-button,
.forgot-password-button,
.auth-back-button {
  color: var(--brand);
}

.pagination {
  padding-top: 4px;
}

.pagination span {
  color: var(--muted);
  font-weight: 600;
}

.modal {
  background: rgba(15, 23, 42, 0.48);
  backdrop-filter: blur(5px);
  animation: modal-backdrop-in 180ms ease both;
}

.modal-card {
  border-color: #dbeafe;
  background: #ffffff;
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.22);
  animation: modal-card-in 240ms cubic-bezier(0.2, 0.75, 0.25, 1) both;
}

.modal-head {
  padding-bottom: 12px;
  border-bottom: 1px solid #eaf0f7;
}

.toast {
  min-width: min(340px, calc(100vw - 28px));
  bottom: 20px;
  inset-inline-end: 20px;
  border: 1px solid #bbf7d0;
  border-inline-start: 5px solid var(--ok);
  border-radius: 8px;
  background: #ffffff;
  color: #166534;
  box-shadow: 0 16px 38px rgba(15, 23, 42, 0.18);
  font-weight: 700;
  animation: toast-enter 260ms cubic-bezier(0.2, 0.75, 0.25, 1) both;
}

.message-popup {
  position: fixed;
  inset-block-start: 18px;
  inset-inline-start: 50%;
  z-index: 1400;
  width: min(430px, calc(100vw - 28px));
  min-height: 78px;
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) 9px;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  border: 1px solid #bfdbfe;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.98);
  color: var(--ink);
  text-align: start;
  box-shadow: 0 18px 46px rgba(15, 23, 42, 0.2);
  opacity: 0;
  transform: translate(-50%, -24px);
  transition: opacity 300ms ease, transform 300ms cubic-bezier(0.2, 0.75, 0.25, 1);
  backdrop-filter: blur(14px);
}

[dir="rtl"] .message-popup {
  transform: translate(50%, -24px);
}

.message-popup.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

[dir="rtl"] .message-popup.is-visible {
  transform: translate(50%, 0);
}

.message-popup.is-leaving,
[dir="rtl"] .message-popup.is-leaving {
  opacity: 0;
  transform: translateY(-18px);
  pointer-events: none;
}

.message-popup:hover {
  border-color: #93c5fd;
  background: #ffffff;
  color: var(--ink);
  box-shadow: 0 20px 52px rgba(37, 99, 235, 0.2);
}

.message-popup-icon {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--brand);
  color: #ffffff;
  font-size: 1rem;
  font-weight: 800;
}

.message-popup-content {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.message-popup-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.message-popup-head strong {
  overflow: hidden;
  color: var(--heading);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.message-popup-head time {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 0.72rem;
}

.message-popup-preview {
  overflow: hidden;
  color: #475569;
  font-size: 0.82rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.message-popup-unread {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--brand);
  box-shadow: 0 0 0 4px #dbeafe;
}

.recent-messages-panel {
  margin-top: 16px;
}

.recent-messages-panel .panel-head p {
  margin: 3px 0 0;
}

.recent-message-list {
  display: grid;
  gap: 7px;
}

.recent-message-item {
  min-width: 0;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  gap: 11px;
  align-items: center;
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  transition: border-color 160ms ease, background-color 160ms ease, transform 160ms ease;
}

.recent-message-item:hover {
  border-color: #bfdbfe;
  background: #f8fbff;
  transform: translateY(-1px);
}

.recent-message-item.is-unread {
  border-inline-start: 4px solid var(--brand);
  background: var(--surface-2);
}

.recent-message-item .conversation-avatar {
  width: 42px;
  height: 42px;
}

.recent-message-item > div {
  min-width: 0;
}

.recent-message-item strong,
.recent-message-item p,
.recent-message-item time {
  display: block;
}

.recent-message-item strong {
  overflow: hidden;
  color: var(--heading);
  font-size: 0.84rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.recent-message-item p {
  overflow: hidden;
  margin: 2px 0;
  color: #475569;
  font-size: 0.78rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.recent-message-item time {
  color: var(--muted);
  font-size: 0.68rem;
}

.login-screen {
  background: var(--surface-2);
}

.login-card {
  border-color: #bfdbfe;
  box-shadow: 0 28px 70px rgba(30, 58, 138, 0.2);
}

.login-hero {
  background: var(--brand-2);
}

.login-worker-animation {
  display: block;
  width: min(100%, 310px);
  margin: 18px auto 4px;
  border-radius: 8px;
}

.login-hero h1,
.login-hero strong {
  color: #ffffff;
}

.login-hero p,
.login-hero small {
  color: #dbeafe;
}

.login-video-brand .brand-mark {
  background: rgba(37, 99, 235, 0.9);
}

.login-skip:hover {
  background: var(--brand);
  color: #ffffff;
}

.auth-tabs {
  border-radius: 8px;
  background: var(--surface-2);
}

.auth-tabs button.active {
  border-color: #bfdbfe;
  color: var(--brand);
  box-shadow: 0 3px 10px rgba(37, 99, 235, 0.08);
}

.auth-notice,
.login-motivation {
  border-color: #bfdbfe;
  border-inline-start-color: var(--brand);
  border-radius: 7px;
  background: var(--surface-2);
  color: var(--heading);
}

.google-auth-button {
  border-color: #cbd5e1;
  color: #1e293b;
}

.google-auth-button:hover {
  border-color: var(--brand);
  background: var(--surface-2);
  color: var(--brand);
}

.conversation-list > button.active,
.chat-message.sent > div {
  border-color: #bfdbfe;
  background: var(--surface-2);
}

.conversation-avatar,
.conversation-list b {
  background: var(--brand);
}

.permission-head {
  background: var(--surface-2);
}

.permission-table thead th:first-child {
  background: var(--surface-2);
  color: var(--heading);
}

.permission-table input {
  accent-color: var(--brand);
}

.switch input:checked + span {
  background: var(--brand);
}

.mobile-menu-toggle,
.mobile-menu-close,
.mobile-nav-backdrop {
  display: none;
}

.app-loading {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 274px minmax(0, 1fr);
  background: #f8fbff;
}

.loading-construction-animation {
  display: block;
  width: min(360px, 72%);
  height: 110px;
  margin: 20px auto 0;
  object-fit: contain;
}

.dashboard-construction-scene {
  display: grid;
  grid-template-columns: minmax(180px, 0.7fr) minmax(320px, 1.3fr);
  align-items: center;
  min-height: 150px;
  margin-bottom: 14px;
  overflow: hidden;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  background: #f8fbff;
}

.dashboard-construction-scene > div {
  display: grid;
  gap: 5px;
  padding: 20px;
}

.dashboard-construction-scene strong {
  color: #1e3a8a;
  font-size: 20px;
}

.dashboard-construction-scene span {
  color: #64748b;
}

.dashboard-construction-scene img {
  width: 100%;
  height: 150px;
  object-fit: cover;
}

.construction-empty-state {
  display: grid;
  place-items: center;
  gap: 4px;
  min-height: 170px;
  padding: 16px;
  color: #64748b;
  text-align: center;
}

.construction-empty-state img {
  width: min(250px, 80%);
  height: 125px;
  object-fit: contain;
}

.construction-empty-state p {
  margin: 0;
}

.toast.has-success-animation {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
}

.toast.has-success-animation img {
  width: 52px;
  height: 42px;
  object-fit: contain;
}

.animations-disabled .construction-animation {
  display: none !important;
}

.loading-sidebar {
  display: grid;
  align-content: start;
  gap: 14px;
  padding: 22px 18px;
  border-inline-end: 1px solid var(--line);
  background: #ffffff;
}

.loading-logo,
.loading-line,
.loading-panel,
.loading-metrics span {
  display: block;
  overflow: hidden;
  border-radius: 7px;
  background: #e8eef7;
  position: relative;
}

.loading-logo {
  width: 46px;
  height: 46px;
  margin-bottom: 16px;
}

.loading-line {
  width: 70%;
  height: 16px;
}

.loading-line.is-wide {
  width: 92%;
}

.loading-main {
  padding: 28px;
}

.loading-title {
  width: 230px;
  height: 30px;
}

.loading-metrics {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin: 30px 0 18px;
}

.loading-metrics span {
  height: 110px;
}

.loading-panel {
  width: 100%;
  height: 430px;
}

.loading-logo::after,
.loading-line::after,
.loading-panel::after,
.loading-metrics span::after {
  content: "";
  position: absolute;
  inset: 0;
  transform: translateX(-110%);
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.8), transparent);
  animation: skeleton-shimmer 1.35s infinite;
}

@keyframes ui-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes ui-slide-up {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes modal-backdrop-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes modal-card-in {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes toast-enter {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes skeleton-shimmer {
  to { transform: translateX(110%); }
}

@media (max-width: 1050px) {
  .app {
    display: block;
  }

  .sidebar {
    position: fixed;
    inset-block: 0;
    inset-inline-start: 0;
    width: min(86vw, 310px);
    min-height: 100vh;
    transform: translateX(-110%);
    transition: transform 240ms cubic-bezier(0.2, 0.75, 0.25, 1);
    box-shadow: 12px 0 40px rgba(15, 23, 42, 0.18);
  }

  [dir="rtl"] .sidebar {
    transform: translateX(110%);
    box-shadow: -12px 0 40px rgba(15, 23, 42, 0.18);
  }

  .mobile-nav-open .sidebar,
  [dir="rtl"] .mobile-nav-open .sidebar {
    transform: translateX(0);
  }

  .mobile-nav-backdrop {
    position: fixed;
    inset: 0;
    z-index: 11;
    min-height: 100vh;
    border: 0;
    border-radius: 0;
    background: rgba(15, 23, 42, 0.42);
    backdrop-filter: blur(2px);
  }

  .mobile-nav-open .mobile-nav-backdrop {
    display: block;
    animation: ui-fade-in 180ms ease both;
  }

  .mobile-menu-toggle,
  .mobile-menu-close {
    display: inline-grid;
    place-items: center;
    width: 40px;
    min-width: 40px;
    padding: 0;
    border-color: #bfdbfe;
    background: var(--surface-2);
    color: var(--brand);
    font-size: 20px;
  }

  .mobile-menu-close {
    position: absolute;
    inset-block-start: 13px;
    inset-inline-end: 12px;
    z-index: 1;
    border-color: transparent;
    background: transparent;
    font-size: 24px;
  }

  .sidebar .brand {
    padding-inline-end: 38px;
  }

  .nav {
    display: grid;
    grid-template-columns: 1fr;
    max-height: calc(100vh - 168px);
  }

  .main {
    padding-inline: 18px;
  }

  .topbar {
    margin-inline: -18px;
    padding-inline: 18px;
  }

  .workspace {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .main {
    padding: 0 12px 20px;
  }

  .topbar {
    position: relative;
    min-height: 0;
    margin: 0 -12px 16px;
    padding: 12px;
    align-items: stretch;
  }

  .topbar,
  .topbar-heading {
    width: auto;
  }

  .topbar .actions {
    width: auto;
    align-self: flex-end;
  }

  .tools-menu-panel {
    inset-inline-end: 0;
  }

  .metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .metric {
    min-height: 96px;
    padding: 14px;
  }

  .panel {
    padding: 14px;
  }

  .panel-head {
    align-items: flex-start;
  }

  .toolbar {
    display: grid;
    grid-template-columns: 1fr;
  }

  .toolbar > * {
    width: 100%;
  }

  .actions,
  .toolbar,
  .pagination {
    align-items: stretch;
  }

  .row-actions {
    flex-wrap: wrap;
  }

  .message-popup {
    inset-block-start: 10px;
    width: calc(100vw - 20px);
    min-height: 74px;
    grid-template-columns: 42px minmax(0, 1fr) 8px;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 9px;
  }

  .message-popup-icon {
    width: 42px;
    height: 42px;
  }

  .recent-message-item {
    grid-template-columns: 40px minmax(0, 1fr) auto;
    padding: 9px;
  }

  .recent-message-item .conversation-avatar {
    width: 40px;
    height: 40px;
  }

  .app-loading {
    grid-template-columns: 1fr;
  }

  .loading-sidebar {
    display: none;
  }

  .loading-main {
    padding: 18px;
  }

  .loading-metrics {
    grid-template-columns: repeat(2, 1fr);
  }

  .dashboard-construction-scene {
    grid-template-columns: minmax(150px, 0.8fr) minmax(240px, 1.2fr);
  }
}

@media (max-width: 480px) {
  .document-toolbar {
    grid-template-columns: 1fr;
  }

  .document-preview,
  .document-image-stage {
    min-height: 320px;
  }

  .document-view-modal .modal-card {
    width: 100vw;
    max-width: 100vw;
    min-height: 100dvh;
    border-radius: 0;
  }

  .invoice-image-preview {
    grid-template-columns: 88px minmax(0, 1fr);
  }

  .invoice-preview-open {
    width: 88px;
    height: 76px;
  }

  .invoice-image-preview .row-actions {
    grid-template-columns: 1fr;
  }

  .invoice-lightbox section {
    width: 100vw;
    height: 100dvh;
    max-width: 100vw;
    max-height: 100dvh;
    border-radius: 0;
  }

  .topbar .actions {
    grid-template-columns: 1fr;
  }

  .topbar .actions .language {
    grid-column: auto;
  }

  .metrics {
    grid-template-columns: 1fr;
  }

  .metric {
    min-height: 88px;
  }

  .login-form {
    padding: 22px 16px;
  }

  .report-gallery,
  .image-upload-preview {
    grid-template-columns: 1fr;
  }

  .dashboard-construction-scene {
    grid-template-columns: 1fr;
  }

  .dashboard-construction-scene > div {
    padding: 14px 16px 0;
  }

  .dashboard-construction-scene img {
    height: 115px;
  }

  .login-worker-animation {
    width: min(100%, 240px);
  }

  .loading-construction-animation {
    width: 92%;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

.salary-breakdown-mini {
  display: grid;
  gap: 4px;
  min-width: 180px;
}

.salary-breakdown-mini span {
  display: block;
  padding: 4px 6px;
  border-radius: 6px;
  background: #eef6f4;
  color: #22554d;
  font-size: 12px;
}

.portal-management-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.portal-account-form {
  display: grid;
  gap: 10px;
}

.portal-account-form label {
  display: grid;
  gap: 5px;
}

.portal-account-form select[multiple] {
  min-height: 96px;
}

.compact-metrics {
  margin-top: 12px;
}

.public-auth-screen,
.login-screen.with-landing {
  align-items: stretch;
  gap: 24px;
  padding: 28px;
}

.login-screen.with-landing .login-card {
  max-width: 1080px;
}

.landing-panel,
.pricing-page {
  width: min(1180px, 100%);
  margin: 0 auto;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(148, 163, 184, 0.26);
  border-radius: 8px;
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.14);
  padding: 24px;
}

.landing-panel {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) 1.35fr;
  gap: 18px;
  align-items: stretch;
}

.public-page-nav {
  grid-column: 1 / -1;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.landing-kicker {
  color: var(--primary);
  font-weight: 800;
  font-size: 0.82rem;
}

.landing-copy h1,
.pricing-head h1 {
  margin: 8px 0;
  color: var(--text);
  line-height: 1.15;
}

.landing-copy p,
.pricing-head p {
  color: var(--muted);
  line-height: 1.8;
}

.landing-feature-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.landing-feature-grid article,
.subscription-grid article {
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: 8px;
  padding: 14px;
  background: linear-gradient(180deg, rgba(248, 250, 252, 0.96), rgba(255, 255, 255, 0.96));
  transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease;
}

.landing-feature-grid article:hover,
.pricing-card:hover,
.sidebar-customizer-row:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 28px rgba(15, 23, 42, 0.1);
}

.landing-feature-grid span {
  display: inline-flex;
  width: 34px;
  height: 34px;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: rgba(37, 99, 235, 0.09);
  margin-bottom: 10px;
}

.landing-security-row {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.landing-security-row span {
  border-radius: 999px;
  background: rgba(16, 185, 129, 0.1);
  color: #047857;
  padding: 8px 12px;
  font-weight: 700;
}

.pricing-head {
  text-align: center;
  max-width: 680px;
  margin: 0 auto 20px;
}

.pricing-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.pricing-card {
  border: 1px solid rgba(148, 163, 184, 0.3);
  border-radius: 8px;
  background: var(--surface);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease;
}

.pricing-card.featured {
  border-color: rgba(37, 99, 235, 0.45);
  box-shadow: inset 0 4px 0 var(--primary), 0 20px 44px rgba(37, 99, 235, 0.11);
}

.pricing-card h2 {
  margin: 0;
}

.price strong {
  font-size: 2.1rem;
  color: var(--primary);
}

.price span {
  margin-inline-start: 6px;
  color: var(--muted);
}

.pricing-card ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 8px;
  color: var(--text);
}

.pricing-card li::before {
  content: "\2713";
  color: var(--ok);
  margin-inline-end: 8px;
  font-weight: 800;
}

.pricing-card button {
  margin-top: auto;
}

.pricing-modal {
  max-width: 1100px;
}

.pricing-modal .pricing-page {
  box-shadow: none;
  border: 0;
  padding: 0;
}

.subscription-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.subscription-grid span {
  color: var(--muted);
  display: block;
  margin-bottom: 6px;
}

.subscription-grid strong {
  color: var(--text);
}

.sidebar-customizer-list {
  display: grid;
  gap: 10px;
}

.sidebar-customizer-row {
  display: grid;
  grid-template-columns: 34px 36px minmax(180px, 1fr) auto 38px 38px;
  gap: 10px;
  align-items: center;
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: 8px;
  padding: 10px;
  background: var(--surface);
  transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease;
}

.drag-handle {
  cursor: grab;
  color: var(--muted);
  text-align: center;
}

.sidebar-customizer-icon {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: rgba(37, 99, 235, 0.08);
}

.sidebar-visible-toggle {
  white-space: nowrap;
  color: var(--muted);
}

@media (max-width: 980px) {
  .landing-panel,
  .pricing-grid,
  .subscription-grid {
    grid-template-columns: 1fr;
  }

  .landing-feature-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 620px) {
  .public-auth-screen,
  .login-screen.with-landing {
    padding: 14px;
  }

  .landing-feature-grid {
    grid-template-columns: 1fr;
  }

  .sidebar-customizer-row {
    grid-template-columns: 28px 32px 1fr;
  }

  .sidebar-visible-toggle,
  .sidebar-customizer-row button {
    grid-column: 3;
  }
}

/* Premium layout pass: Layout + Sidebar + Dashboard only. */
:root {
  --premium-navy: #0f172a;
  --premium-navy-2: #111827;
  --premium-blue: #2563eb;
  --premium-blue-soft: rgba(37, 99, 235, 0.1);
  --premium-emerald: #10b981;
  --premium-slate: #64748b;
  --premium-bg: #f8fafc;
  --premium-card: #ffffff;
  --premium-border: rgba(148, 163, 184, 0.24);
  --premium-shadow: 0 22px 55px rgba(15, 23, 42, 0.1);
  --premium-shadow-soft: 0 14px 34px rgba(15, 23, 42, 0.08);
}

@keyframes premiumFadeLift {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes premiumSlideIn {
  from {
    opacity: 0;
    transform: translateX(12px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

body {
  background:
    radial-gradient(circle at top right, rgba(37, 99, 235, 0.11), transparent 34vw),
    radial-gradient(circle at bottom left, rgba(16, 185, 129, 0.1), transparent 30vw),
    var(--premium-bg);
}

.app {
  background: transparent;
}

.main {
  background: transparent;
  min-width: 0;
}

.main > section,
.main > div:not(.firebase-sync-banner) {
  animation: premiumFadeLift 260ms ease both;
}

.sidebar {
  background:
    linear-gradient(180deg, rgba(15, 23, 42, 0.98), rgba(17, 24, 39, 0.98)),
    var(--premium-navy);
  border: 0;
  box-shadow: 20px 0 45px rgba(15, 23, 42, 0.18);
  color: #e5e7eb;
}

[dir="rtl"] .sidebar {
  box-shadow: -20px 0 45px rgba(15, 23, 42, 0.18);
}

.brand {
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.05);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.brand-mark {
  background: linear-gradient(135deg, var(--premium-blue), var(--premium-emerald));
  color: #fff;
  box-shadow: 0 12px 24px rgba(37, 99, 235, 0.28);
}

.brand strong,
.nav-section-title,
.nav-button {
  color: #f8fafc;
}

.brand small,
.nav-section-count,
.sidebar-search::placeholder {
  color: rgba(226, 232, 240, 0.68);
}

.tenant-switcher,
.sidebar-tools {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.1);
  border-radius: 8px;
}

.tenant-switcher label {
  color: rgba(226, 232, 240, 0.78);
}

.tenant-switcher select,
.sidebar-search {
  background: rgba(15, 23, 42, 0.78);
  border: 1px solid rgba(148, 163, 184, 0.26);
  color: #fff;
  box-shadow: none;
}

.sidebar-search:focus {
  border-color: rgba(37, 99, 235, 0.9);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.18);
}

.sidebar-collapse-toggle,
.nav-section-toggle {
  border-radius: 8px;
  color: #e2e8f0;
  transition: transform 160ms ease, background 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.sidebar-collapse-toggle:hover,
.nav-section-toggle:hover,
.nav-section.open > .nav-section-toggle,
.nav-section.contains-active > .nav-section-toggle {
  background: rgba(37, 99, 235, 0.16);
  border-color: rgba(96, 165, 250, 0.28);
  box-shadow: inset 0 0 0 1px rgba(96, 165, 250, 0.12);
}

.nav-section-icon {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #bfdbfe;
}

.nav-section-items {
  transition: max-height 220ms ease, opacity 180ms ease;
}

.nav-button {
  border-radius: 8px;
  margin-block: 3px;
  min-height: 38px;
  color: rgba(248, 250, 252, 0.84);
  transition: transform 160ms ease, background 160ms ease, color 160ms ease, box-shadow 160ms ease;
}

.nav-button:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  transform: translateX(-2px);
}

[dir="ltr"] .nav-button:hover {
  transform: translateX(2px);
}

.nav-button.active {
  background: linear-gradient(90deg, rgba(37, 99, 235, 0.96), rgba(16, 185, 129, 0.88));
  color: #fff;
  box-shadow: 0 12px 26px rgba(37, 99, 235, 0.28), inset 0 0 0 1px rgba(255, 255, 255, 0.18);
}

.nav-button.active > span:first-child {
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid rgba(226, 232, 240, 0.72);
  border-radius: 8px;
  margin: 14px 14px 10px;
  box-shadow: 0 14px 34px rgba(15, 23, 42, 0.07);
  backdrop-filter: blur(18px);
}

.topbar h1 {
  color: var(--premium-navy);
  font-weight: 800;
}

.topbar p,
.muted {
  color: var(--premium-slate);
}

.tools-menu-toggle,
.mobile-menu-toggle,
.mobile-menu-close,
.dashboard-quick-actions button,
.panel-head button,
.toolbar button,
.row-actions button,
button.primary,
.primary {
  transition: transform 140ms ease, box-shadow 160ms ease, background 160ms ease, border-color 160ms ease;
}

.tools-menu-toggle:hover,
.mobile-menu-toggle:hover,
.dashboard-quick-actions button:hover,
.panel-head button:hover,
.toolbar button:hover,
.row-actions button:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 22px rgba(15, 23, 42, 0.1);
}

.tools-menu-toggle:active,
.dashboard-quick-actions button:active,
.panel-head button:active,
.toolbar button:active,
.row-actions button:active {
  transform: translateY(0) scale(0.98);
}

.tools-menu-panel {
  border-radius: 8px;
  border-color: var(--premium-border);
  box-shadow: var(--premium-shadow);
  animation: premiumFadeLift 160ms ease both;
}

.executive-dashboard {
  display: grid;
  gap: 16px;
  padding: 0 14px 18px;
}

.dashboard-premium-hero {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto;
  gap: 18px;
  align-items: center;
  border: 1px solid rgba(37, 99, 235, 0.16);
  border-radius: 8px;
  padding: 22px;
  background:
    linear-gradient(135deg, rgba(15, 23, 42, 0.98), rgba(30, 64, 175, 0.93)),
    var(--premium-navy);
  color: #fff;
  box-shadow: var(--premium-shadow);
  overflow: hidden;
  position: relative;
}

.dashboard-premium-hero::after {
  content: "";
  position: absolute;
  inset-block: -38%;
  inset-inline-end: -8%;
  width: 280px;
  background: radial-gradient(circle, rgba(16, 185, 129, 0.25), transparent 68%);
  pointer-events: none;
}

.dashboard-premium-hero > * {
  position: relative;
  z-index: 1;
}

.hero-kicker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #a7f3d0;
  font-weight: 800;
  font-size: 0.82rem;
  margin-bottom: 8px;
}

.hero-kicker::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--premium-emerald);
  box-shadow: 0 0 0 6px rgba(16, 185, 129, 0.14);
}

.dashboard-premium-hero h2 {
  margin: 0;
  max-width: 780px;
  font-size: clamp(1.35rem, 2.4vw, 2.3rem);
  line-height: 1.35;
  font-weight: 800;
}

.dashboard-premium-hero p {
  max-width: 760px;
  margin: 10px 0 0;
  color: rgba(226, 232, 240, 0.86);
  line-height: 1.8;
}

.dashboard-quick-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.dashboard-quick-actions button {
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  border-radius: 8px;
  padding: 11px 14px;
  font-weight: 800;
  white-space: nowrap;
  backdrop-filter: blur(10px);
}

.dashboard-quick-actions button:hover {
  background: rgba(255, 255, 255, 0.2);
}

.dashboard-construction-scene {
  border-radius: 8px;
  border: 1px solid var(--premium-border);
  box-shadow: var(--premium-shadow-soft);
}

.metrics {
  gap: 14px;
}

.metric {
  position: relative;
  overflow: hidden;
  border-radius: 8px;
  border: 1px solid var(--premium-border);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(248, 250, 252, 0.94)),
    var(--premium-card);
  box-shadow: var(--premium-shadow-soft);
  animation: premiumFadeLift 260ms ease both;
}

.metric::after {
  content: "";
  position: absolute;
  inset-block: 0;
  inset-inline-start: 0;
  width: 4px;
  background: linear-gradient(180deg, var(--premium-blue), var(--premium-emerald));
}

.metric:hover {
  transform: translateY(-3px);
  border-color: rgba(37, 99, 235, 0.28);
  box-shadow: 0 20px 45px rgba(15, 23, 42, 0.12);
}

.metric span {
  color: var(--premium-slate);
  font-weight: 700;
}

.metric strong {
  color: var(--premium-navy);
  font-size: clamp(1.35rem, 2vw, 2rem);
}

.panel {
  border-radius: 8px;
  border: 1px solid var(--premium-border);
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--premium-shadow-soft);
  animation: premiumFadeLift 280ms ease both;
}

.panel:hover {
  border-color: rgba(37, 99, 235, 0.18);
}

.panel-head {
  border-bottom: 1px solid rgba(226, 232, 240, 0.72);
  padding-bottom: 10px;
}

.panel-head h2,
.panel-head h3 {
  color: var(--premium-navy);
  font-weight: 800;
}

.badge {
  border-radius: 999px;
  background: var(--premium-blue-soft);
  color: #1d4ed8;
  border: 1px solid rgba(37, 99, 235, 0.14);
  font-weight: 800;
}

.badge.warning {
  background: rgba(245, 158, 11, 0.12);
  color: #b45309;
  border-color: rgba(245, 158, 11, 0.2);
}

.badge.danger {
  background: rgba(239, 68, 68, 0.12);
  color: #b91c1c;
  border-color: rgba(239, 68, 68, 0.2);
}

.table-wrap {
  border-radius: 8px;
  border: 1px solid rgba(226, 232, 240, 0.86);
  overflow: auto;
  background: #fff;
}

table thead th {
  background: #f1f5f9;
  color: #334155;
  font-weight: 800;
}

table tbody tr {
  transition: background 150ms ease, transform 150ms ease;
}

table tbody tr:hover {
  background: rgba(37, 99, 235, 0.045);
}

.insight,
.project-spending-list button,
.highest-spending-project {
  border-radius: 8px;
  border-color: rgba(148, 163, 184, 0.22);
  background: linear-gradient(180deg, #fff, #f8fafc);
  transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}

.insight:hover,
.project-spending-list button:hover,
.highest-spending-project:hover {
  transform: translateY(-2px);
  border-color: rgba(37, 99, 235, 0.24);
  box-shadow: 0 14px 30px rgba(15, 23, 42, 0.08);
}

.chart {
  border-radius: 8px;
  background: linear-gradient(180deg, #f8fafc, #eef2ff);
  border: 1px solid rgba(226, 232, 240, 0.86);
}

.chart .bar {
  border-radius: 999px 999px 0 0;
  background: linear-gradient(180deg, var(--premium-blue), var(--premium-emerald));
  box-shadow: 0 10px 18px rgba(37, 99, 235, 0.16);
}

.mobile-nav-backdrop {
  backdrop-filter: blur(4px);
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    transition-duration: 1ms !important;
    scroll-behavior: auto !important;
  }
}

@media (max-width: 980px) {
  .topbar {
    margin: 10px;
  }

  .executive-dashboard {
    padding: 0 10px 14px;
  }

  .dashboard-premium-hero {
    grid-template-columns: 1fr;
  }

  .dashboard-quick-actions {
    justify-content: flex-start;
  }

  .sidebar {
    box-shadow: 20px 0 45px rgba(15, 23, 42, 0.26);
  }

  [dir="rtl"] .sidebar {
    box-shadow: -20px 0 45px rgba(15, 23, 42, 0.26);
  }
}

@media (max-width: 620px) {
  .topbar {
    border-radius: 8px;
  }

  .dashboard-premium-hero {
    padding: 18px;
  }

  .dashboard-quick-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
  }

  .dashboard-quick-actions button {
    white-space: normal;
    min-height: 44px;
  }

  .metrics {
    grid-template-columns: 1fr;
  }
}

/* Premium UI continuation: external pages, tables, forms, modals, feedback. */
.login-screen,
.public-auth-screen {
  background:
    radial-gradient(circle at 15% 15%, rgba(37, 99, 235, 0.18), transparent 28vw),
    radial-gradient(circle at 85% 80%, rgba(16, 185, 129, 0.16), transparent 30vw),
    linear-gradient(135deg, #f8fafc, #eef2ff 45%, #f8fafc);
}

.login-card,
.landing-panel,
.pricing-page {
  border: 1px solid rgba(226, 232, 240, 0.78);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 28px 80px rgba(15, 23, 42, 0.16);
  backdrop-filter: blur(18px);
}

.login-card {
  overflow: hidden;
}

.login-card::before,
.landing-panel::before,
.pricing-page::before {
  content: "";
  display: block;
  height: 4px;
  margin: -1px -1px 18px;
  background: linear-gradient(90deg, var(--premium-blue), var(--premium-emerald));
}

.public-register-brand,
.login-video-brand {
  color: var(--premium-navy);
}

.auth-tabs,
.join-type-tabs,
.status-tabs,
.inventory-tabs,
.approval-filters,
.toolbar {
  border-radius: 8px;
  background: rgba(248, 250, 252, 0.88);
  border: 1px solid rgba(226, 232, 240, 0.86);
  padding: 6px;
}

.auth-tabs button,
.join-type-tabs button,
.status-tabs button,
.inventory-tabs button {
  border-radius: 8px;
  color: var(--premium-slate);
  transition: background 150ms ease, color 150ms ease, transform 150ms ease, box-shadow 150ms ease;
}

.auth-tabs button.active,
.join-type-tabs button.active,
.status-tabs button.active,
.inventory-tabs button.active {
  background: linear-gradient(135deg, var(--premium-blue), #1d4ed8);
  color: #fff;
  box-shadow: 0 12px 24px rgba(37, 99, 235, 0.2);
}

.landing-panel {
  position: relative;
  overflow: hidden;
}

.landing-panel::after,
.pricing-page::after {
  content: "";
  position: absolute;
  inset-block-start: 20px;
  inset-inline-end: 20px;
  width: 160px;
  height: 160px;
  border-radius: 999px;
  background: radial-gradient(circle, rgba(37, 99, 235, 0.1), transparent 70%);
  pointer-events: none;
}

.landing-copy h1,
.pricing-head h1 {
  color: var(--premium-navy);
  font-weight: 800;
  letter-spacing: 0;
}

.landing-kicker {
  color: var(--premium-blue);
}

.landing-feature-grid article,
.subscription-grid article,
.pricing-card {
  border-radius: 8px;
  border: 1px solid rgba(226, 232, 240, 0.82);
  background: linear-gradient(180deg, #fff, #f8fafc);
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.06);
}

.landing-feature-grid article:hover,
.subscription-grid article:hover,
.pricing-card:hover {
  transform: translateY(-4px);
  border-color: rgba(37, 99, 235, 0.24);
  box-shadow: 0 22px 45px rgba(15, 23, 42, 0.12);
}

.landing-feature-grid span {
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.12), rgba(16, 185, 129, 0.12));
  color: var(--premium-blue);
}

.pricing-card.featured {
  border-color: rgba(37, 99, 235, 0.5);
  background:
    linear-gradient(180deg, rgba(239, 246, 255, 0.98), #fff),
    var(--premium-card);
  box-shadow: inset 0 4px 0 var(--premium-blue), 0 28px 60px rgba(37, 99, 235, 0.16);
}

.price strong {
  color: var(--premium-blue);
}

.pricing-card li::before {
  color: var(--premium-emerald);
}

button,
.button-link,
.file-button span,
.google-auth-button,
.forgot-password-button,
.auth-back-button,
.firebase-setup-button,
.view-month-button,
.contractor-name-button,
.destructive-button {
  border-radius: 8px;
}

button.primary,
.primary,
.pricing-card button,
.firebase-setup-button {
  background: linear-gradient(135deg, var(--premium-blue), #1d4ed8);
  border-color: rgba(37, 99, 235, 0.35);
  color: #fff;
  box-shadow: 0 14px 28px rgba(37, 99, 235, 0.18);
}

button.primary:hover,
.primary:hover,
.pricing-card button:hover,
.firebase-setup-button:hover {
  background: linear-gradient(135deg, #1d4ed8, var(--premium-blue));
  box-shadow: 0 18px 34px rgba(37, 99, 235, 0.24);
}

button.danger,
.danger,
.destructive-button {
  border-color: rgba(239, 68, 68, 0.22);
  background: rgba(239, 68, 68, 0.1);
  color: #b91c1c;
}

input,
select,
textarea {
  border-radius: 8px;
  border: 1px solid rgba(203, 213, 225, 0.9);
  background: #fff;
  color: var(--premium-navy);
  transition: border-color 150ms ease, box-shadow 150ms ease, background 150ms ease;
}

input:hover,
select:hover,
textarea:hover {
  border-color: rgba(37, 99, 235, 0.35);
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(37, 99, 235, 0.85);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
  outline: none;
}

label,
.field label {
  color: #334155;
  font-weight: 800;
}

.form-grid {
  gap: 14px;
}

.report-media-actions,
.invoice-upload-control { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.report-media-actions .button-link,
.invoice-upload-control .button-link { min-height: 40px; justify-content: center; cursor: pointer; }
.report-media-preview video,
.report-gallery video { width: 100%; height: 100%; min-height: 130px; object-fit: cover; background: #0f172a; border-radius: 6px; }
.report-gallery button { position: relative; }
.report-video-badge { position: absolute; inset-inline-start: 8px; bottom: 8px; padding: 3px 8px; border-radius: 6px; color: #fff; background: rgba(15, 23, 42, 0.82); font-size: 12px; font-weight: 800; }
.image-lightbox video { max-width: min(92vw, 1100px); max-height: 84vh; background: #000; }
.pricing-cycle-switch { display: inline-flex; gap: 4px; padding: 4px; margin-top: 14px; border: 1px solid #cbd5e1; border-radius: 8px; background: #fff; }
.pricing-cycle-switch button { min-width: 110px; border: 0; background: transparent; color: #334155; }
.pricing-cycle-switch button.active { background: #2563eb; color: #fff; }
.pricing-cycle-switch small { display: block; margin-top: 2px; font-size: 10px; color: inherit; }
.pricing-card { position: relative; }
.pricing-card .price { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px; }
.pricing-card .price del { color: #dc2626; font-weight: 900; text-decoration-thickness: 2px; }
.pricing-discount-badge { position: absolute; top: 14px; inset-inline-start: 14px; padding: 5px 9px; border-radius: 6px; color: #fff; background: #dc2626; font-size: 12px; font-weight: 900; }
.pricing-admin-grid { display: grid; grid-template-columns: repeat(5, minmax(130px, 1fr)); gap: 10px; margin-top: 10px; }
.pricing-admin-grid label { display: grid; gap: 5px; }
@media (max-width: 900px) { .pricing-admin-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) { .pricing-admin-grid { grid-template-columns: 1fr; } .pricing-cycle-switch { width: 100%; } .pricing-cycle-switch button { flex: 1; min-width: 0; } }

.custody-settlement-modal { max-width: 680px; }
.custody-settlement-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 14px 0;
}
.custody-settlement-options label {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  background: var(--surface);
}
.custody-settlement-options label:has(input:checked) {
  border-color: var(--primary);
  background: color-mix(in srgb, var(--primary) 7%, var(--surface));
}
.custody-settlement-options span { display: grid; gap: 3px; }
.custody-settlement-options small { color: var(--muted); }
.custody-settlement-modal .full-width { grid-column: 1 / -1; }
@media (max-width: 640px) {
  .custody-settlement-options { grid-template-columns: 1fr; }
}

.checkbox-field,
.remember-login,
.feature-toggle,
.switch {
  border-radius: 8px;
}

.table-wrap {
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.05);
}

table {
  border-collapse: separate;
  border-spacing: 0;
}

table th,
table td {
  border-bottom-color: rgba(226, 232, 240, 0.72);
}

table tbody tr:hover td {
  color: var(--premium-navy);
}

.table-subtitle {
  color: var(--premium-slate);
}

.row-actions {
  gap: 7px;
}

.row-actions button,
.button-link {
  border-radius: 8px;
  min-height: 34px;
}

.status-badge,
.status-pending,
.status-approved,
.status-active,
.status-rejected,
.status-suspended,
.badge.success {
  border-radius: 999px;
  font-weight: 800;
}

.status-active,
.badge.success {
  background: rgba(16, 185, 129, 0.12);
  color: #047857;
  border-color: rgba(16, 185, 129, 0.24);
}

.status-approved {
  background: rgba(37, 99, 235, 0.12);
  color: #1d4ed8;
  border-color: rgba(37, 99, 235, 0.22);
}

.status-pending {
  background: rgba(245, 158, 11, 0.12);
  color: #b45309;
  border-color: rgba(245, 158, 11, 0.22);
}

.status-rejected,
.status-suspended {
  background: rgba(239, 68, 68, 0.12);
  color: #b91c1c;
  border-color: rgba(239, 68, 68, 0.22);
}

.modal {
  background: rgba(15, 23, 42, 0.46);
  backdrop-filter: blur(8px);
}

.modal-card {
  border-radius: 8px;
  border: 1px solid rgba(226, 232, 240, 0.84);
  box-shadow: 0 30px 90px rgba(15, 23, 42, 0.24);
  background: rgba(255, 255, 255, 0.96);
}

.modal-head {
  border-bottom: 1px solid rgba(226, 232, 240, 0.78);
  padding-bottom: 12px;
}

.modal-head h2,
.modal-head h3 {
  color: var(--premium-navy);
  font-weight: 800;
}

.modal-head button[data-close-modal] {
  border-radius: 999px;
  width: 36px;
  height: 36px;
}

.toast {
  border-radius: 8px;
  border: 1px solid rgba(16, 185, 129, 0.2);
  background: linear-gradient(135deg, #ecfdf5, #ffffff);
  color: #065f46;
  box-shadow: 0 20px 48px rgba(15, 23, 42, 0.18);
}

.toast::before {
  content: "";
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--premium-emerald);
  box-shadow: 0 0 0 6px rgba(16, 185, 129, 0.12);
}

.admin-approval-page {
  display: grid;
  gap: 18px;
}

.approval-center-panel {
  overflow: hidden;
}

.approval-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 14px;
  padding: 8px;
  border-radius: 8px;
  background: rgba(248, 250, 252, 0.9);
  border: 1px solid rgba(226, 232, 240, 0.86);
}

.approval-tabs button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  border-radius: 8px;
  background: #fff;
  color: var(--premium-slate);
  border: 1px solid rgba(226, 232, 240, 0.9);
}

.approval-tabs button span {
  min-width: 24px;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(37, 99, 235, 0.08);
  color: var(--premium-blue);
  font-weight: 800;
}

.approval-tabs button.active {
  background: linear-gradient(135deg, var(--premium-blue), #1d4ed8);
  color: #fff;
  box-shadow: 0 14px 28px rgba(37, 99, 235, 0.18);
}

.approval-tabs button.active span {
  background: rgba(255, 255, 255, 0.22);
  color: #fff;
}

.recovery-center {
  display: grid;
  gap: 16px;
}

.recovery-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background:
    linear-gradient(135deg, rgba(37, 99, 235, 0.12), rgba(16, 185, 129, 0.08)),
    var(--surface, #fff);
}

.recovery-hero h1 {
  margin: 10px 0 6px;
  color: var(--text-primary, var(--text));
}

.recovery-toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(240px, 1.3fr) minmax(180px, 0.8fr);
  gap: 12px;
}

.recovery-toolbar label {
  display: grid;
  gap: 7px;
  color: var(--text-secondary, var(--muted));
  font-weight: 800;
}

.recovery-toolbar input,
.recovery-toolbar select {
  min-height: 42px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  background: var(--surface);
  color: var(--text-primary, var(--text));
}

.recovery-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-soft);
}

.recovery-tabs button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary, var(--muted));
}

.recovery-tabs button span {
  min-width: 24px;
  border-radius: 999px;
  padding: 2px 7px;
  background: rgba(37, 99, 235, 0.1);
  color: var(--primary, #2563eb);
  font-weight: 900;
}

.recovery-tabs button.active {
  background: #fff;
  border-color: rgba(37, 99, 235, 0.24);
  color: var(--primary, #2563eb);
  box-shadow: 0 8px 22px rgba(37, 99, 235, 0.12);
}

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

  .recovery-toolbar {
    grid-template-columns: 1fr;
  }
}

.badge.status-needs-more-info {
  background: rgba(124, 58, 237, 0.12);
  color: #6d28d9;
  border-color: rgba(124, 58, 237, 0.22);
}

.platform-admin-app {
  background: #f8fafc;
}

.platform-admin-app .sidebar {
  width: 244px;
  background:
    linear-gradient(180deg, rgba(15, 23, 42, 0.98), rgba(30, 41, 59, 0.96)),
    #0f172a;
  border-inline-end: 1px solid rgba(148, 163, 184, 0.18);
}

.platform-admin-app .brand {
  color: #fff;
}

.platform-admin-app .brand small {
  color: rgba(226, 232, 240, 0.72);
}

.platform-sidebar-search {
  padding: 8px 10px 12px;
}

.platform-admin-app .sidebar-search {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(148, 163, 184, 0.22);
  color: #fff;
}

.platform-admin-app .sidebar-search::placeholder {
  color: rgba(226, 232, 240, 0.66);
}

.platform-admin-nav {
  display: grid;
  gap: 6px;
  padding: 0 10px 16px;
}

.platform-admin-app .nav-button {
  color: rgba(226, 232, 240, 0.88);
  background: transparent;
  border: 1px solid transparent;
  min-height: 42px;
  border-radius: 10px;
}

.platform-admin-app .nav-button:hover,
.platform-admin-app .nav-button.active {
  background: rgba(37, 99, 235, 0.18);
  color: #fff;
  border-color: rgba(96, 165, 250, 0.25);
}

.platform-admin-app .nav-button > span:first-child {
  background: rgba(255, 255, 255, 0.1);
  color: #93c5fd;
}

.platform-admin-app .platform-logout {
  margin-top: 8px;
  color: #fecaca;
}

.platform-dashboard {
  display: grid;
  gap: 18px;
}

.platform-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 360px);
  gap: 20px;
  align-items: end;
  padding: 28px;
  border-radius: 18px;
  color: #fff;
  background:
    radial-gradient(circle at 15% 0%, rgba(37, 99, 235, 0.55), transparent 34%),
    linear-gradient(135deg, #0f172a, #1e293b 58%, #0f766e);
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.22);
  overflow: hidden;
}

.platform-hero span {
  display: inline-flex;
  margin-bottom: 10px;
  color: #bfdbfe;
  font-weight: 800;
}

.platform-hero h2 {
  margin: 0;
  font-size: clamp(28px, 4vw, 48px);
  line-height: 1.08;
  letter-spacing: 0;
}

.platform-hero p {
  max-width: 760px;
  margin: 12px 0 0;
  color: rgba(226, 232, 240, 0.86);
  font-size: 15px;
}

.platform-global-search {
  display: grid;
  gap: 8px;
  padding: 14px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.18);
  backdrop-filter: blur(14px);
}

.platform-global-search span {
  margin: 0;
  color: #e0f2fe;
}

.platform-global-search input {
  min-height: 44px;
  border: 0;
  background: #fff;
}

.platform-kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.platform-kpi {
  position: relative;
  padding: 18px;
  border-radius: 16px;
  background: #fff;
  border: 1px solid rgba(226, 232, 240, 0.86);
  box-shadow: 0 14px 34px rgba(15, 23, 42, 0.06);
  overflow: hidden;
}

.platform-kpi::before {
  content: "";
  position: absolute;
  inset-inline-start: 0;
  inset-block: 0;
  width: 4px;
  background: #2563eb;
}

.platform-kpi.green::before { background: #10b981; }
.platform-kpi.orange::before { background: #f59e0b; }
.platform-kpi.red::before { background: #ef4444; }

.platform-kpi span {
  display: block;
  color: #64748b;
  font-weight: 800;
  margin-bottom: 8px;
}

.platform-kpi strong {
  color: #0f172a;
  font-size: 26px;
  letter-spacing: 0;
}

.platform-chart-strip {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.platform-chart-strip article {
  padding: 18px;
  border-radius: 16px;
  background: #fff;
  border: 1px solid rgba(226, 232, 240, 0.86);
  box-shadow: 0 14px 34px rgba(15, 23, 42, 0.05);
}

.platform-chart-strip strong {
  color: #0f172a;
}

.platform-chart-strip div {
  height: 96px;
  display: flex;
  align-items: end;
  gap: 10px;
  margin-top: 16px;
}

.platform-chart-strip span {
  flex: 1;
  min-width: 18px;
  border-radius: 999px 999px 4px 4px;
  background: linear-gradient(180deg, #2563eb, #10b981);
  opacity: 0.88;
}

.platform-feature-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.platform-feature-card {
  display: grid;
  gap: 14px;
  align-content: start;
  min-height: 280px;
  padding: 20px;
  border-radius: 18px;
  background: #fff;
  border: 1px solid rgba(226, 232, 240, 0.9);
  box-shadow: 0 18px 46px rgba(15, 23, 42, 0.07);
  transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease;
}

.platform-feature-card:hover {
  transform: translateY(-4px);
  border-color: rgba(37, 99, 235, 0.28);
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.12);
}

.platform-card-head {
  display: flex;
  align-items: center;
  gap: 12px;
}

.platform-card-head span {
  width: 46px;
  height: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 14px;
  color: #2563eb;
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.12), rgba(16, 185, 129, 0.1));
  font-weight: 900;
}

.platform-card-head strong {
  color: #0f172a;
  font-size: 17px;
}

.platform-feature-card p {
  min-height: 44px;
  margin: 0;
  color: #64748b;
  line-height: 1.7;
}

.platform-card-count {
  color: #0f172a;
  font-size: 34px;
  letter-spacing: 0;
}

.platform-card-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.platform-card-stats div {
  padding: 10px;
  border-radius: 12px;
  background: #f8fafc;
  border: 1px solid rgba(226, 232, 240, 0.8);
}

.platform-card-stats span {
  display: block;
  color: #64748b;
  font-size: 12px;
  font-weight: 800;
  margin-bottom: 4px;
}

.platform-card-stats strong {
  color: #0f172a;
}

.platform-feature-card button {
  align-self: end;
  min-height: 42px;
}

@media (max-width: 1180px) {
  .platform-kpis,
  .platform-feature-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .platform-hero,
  .platform-chart-strip,
  .platform-kpis,
  .platform-feature-grid {
    grid-template-columns: 1fr;
  }

  .platform-hero {
    padding: 22px;
  }
}

/* Responsive hardening for login and public registration screens. */
html,
body {
  max-width: 100%;
  overflow-x: hidden;
}

.login-screen,
.public-auth-screen,
.public-register-screen,
.login-card,
.modern-login-card,
.login-form,
.login-hero,
.landing-panel,
.pricing-page,
.form-grid,
.join-type-cards,
.auth-tabs {
  max-width: 100%;
  box-sizing: border-box;
}

/* Public website and login redesign. */
.login-screen {
  min-height: 100vh;
  align-items: center;
  justify-content: center;
  background:
    linear-gradient(180deg, rgba(219, 234, 254, 0.9), rgba(248, 250, 252, 1)),
    #f8fafc;
  padding: 28px;
  color: #0f172a;
}

.login-screen.with-landing {
  display: grid;
  gap: 22px;
}

.modern-login-card {
  width: min(1440px, 100%);
  min-height: 760px;
  grid-template-columns: 1.02fr 1fr;
  border: 1px solid rgba(203, 213, 225, 0.85);
  border-radius: 30px;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 30px 90px rgba(15, 23, 42, 0.18);
  transform: none;
  opacity: 1;
  animation: none;
}

.login-screen.intro-complete .modern-login-card {
  animation: none;
}

.modern-login-card .login-hero {
  position: relative;
  min-height: 760px;
  display: grid;
  align-content: start;
  gap: 22px;
  padding: clamp(34px, 5vw, 68px);
  background:
    radial-gradient(circle at 80% 18%, rgba(59, 130, 246, 0.25), transparent 28%),
    linear-gradient(150deg, #04184f 0%, #0b3a8f 52%, #08245f 100%);
  overflow: hidden;
}

.modern-login-card .login-hero::after {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 42%;
  background: linear-gradient(180deg, transparent, rgba(2, 6, 23, 0.34));
  pointer-events: none;
}

.modern-login-card .login-hero h1 {
  position: relative;
  z-index: 1;
  max-width: 620px;
  margin: 28px 0 0;
  color: #fff;
  font-size: clamp(34px, 4.5vw, 56px);
  line-height: 1.22;
  letter-spacing: 0;
}

.modern-login-card .login-hero p {
  position: relative;
  z-index: 1;
  max-width: 620px;
  color: rgba(226, 232, 240, 0.94);
  font-size: 18px;
  line-height: 1.9;
}

.modern-login-card .brand {
  position: relative;
  z-index: 1;
}

.login-construction-illustration {
  position: relative;
  z-index: 1;
  height: 300px;
  margin-top: 18px;
}

.login-construction-illustration .building {
  position: absolute;
  inset-inline-start: 24%;
  bottom: 0;
  width: 280px;
  height: 190px;
  border-radius: 18px 18px 10px 10px;
  background:
    repeating-linear-gradient(90deg, transparent 0 28px, rgba(37, 99, 235, 0.18) 28px 36px),
    repeating-linear-gradient(0deg, #ffffff 0 30px, #dbeafe 30px 36px);
  box-shadow: 0 26px 60px rgba(2, 6, 23, 0.35);
}

.login-construction-illustration .building::after {
  content: "";
  position: absolute;
  inset-inline-start: -70px;
  bottom: -24px;
  width: 430px;
  height: 52px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.24);
  filter: blur(2px);
}

.login-construction-illustration .crane {
  position: absolute;
  inset-inline-start: 18%;
  top: 20px;
  width: 360px;
  height: 120px;
  border-top: 8px solid rgba(255, 255, 255, 0.9);
  border-inline-start: 8px solid rgba(255, 255, 255, 0.9);
  transform: skewX(-16deg);
}

.login-construction-illustration .crane::before {
  content: "";
  position: absolute;
  inset-inline-end: 18px;
  top: 0;
  height: 90px;
  border-inline-start: 3px dashed rgba(255, 255, 255, 0.76);
}

.metric-bubble {
  position: absolute;
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.22);
  color: #fff;
  font-weight: 900;
  box-shadow: 0 18px 36px rgba(2, 6, 23, 0.2);
}

.bubble-one { inset-inline-start: 9%; top: 86px; }
.bubble-two { inset-inline-start: 13%; top: 162px; }
.bubble-three { inset-inline-end: 17%; top: 170px; }

.login-benefits {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-top: auto;
}

.login-benefits span {
  display: grid;
  place-items: center;
  min-height: 64px;
  color: #fff;
  font-weight: 800;
  text-align: center;
}

.modern-login-card .login-form {
  display: grid;
  align-content: center;
  padding: clamp(34px, 6vw, 80px);
  max-height: none;
  overflow: visible;
}

.modern-login-card .login-form h2 {
  margin: 0;
  color: #0f172a;
  font-size: clamp(32px, 4vw, 48px);
  text-align: center;
}

.login-form-subtitle {
  margin: 10px 0 28px;
  color: #64748b;
  text-align: center;
  font-weight: 700;
}

.modern-login-card .auth-tabs {
  background: #eff6ff;
  border: 1px solid #dbeafe;
}

.modern-login-card .field label {
  color: #1e3a8a;
  font-size: 14px;
  font-weight: 900;
}

.modern-login-card input,
.modern-login-card select,
.modern-login-card textarea {
  min-height: 54px;
  border-radius: 10px;
  border-color: #cbd5e1;
}

.modern-login-card .auth-submit {
  min-height: 56px;
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
  border-color: #2563eb;
  box-shadow: 0 14px 28px rgba(37, 99, 235, 0.22);
}

.modern-login-card .google-auth-button {
  min-height: 54px;
  border-radius: 10px;
}

.public-auth-screen,
.login-screen.with-landing {
  background:
    linear-gradient(180deg, #0b3a8f 0 88px, #f8fafc 88px 100%);
}

.landing-panel,
.pricing-page {
  width: min(1500px, 100%);
  border-radius: 28px;
  border: 1px solid rgba(203, 213, 225, 0.82);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 26px 80px rgba(15, 23, 42, 0.13);
}

.landing-panel {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  padding: 0;
  overflow: hidden;
}

.public-navbar {
  grid-column: 1 / -1;
  min-height: 74px;
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 20px;
  align-items: center;
  padding: 16px 28px;
  border-bottom: 1px solid #e2e8f0;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
}

.public-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #0f172a;
}

.public-logo strong {
  display: block;
  color: #0b3a8f;
}

.public-logo small {
  color: #64748b;
}

.public-nav-links,
.public-nav-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.public-nav-links button,
.public-nav-links a,
.public-nav-actions button {
  border: 0;
  background: transparent;
  color: #334155;
  font-weight: 900;
}

.public-nav-links a {
  padding: 10px 12px;
  border-radius: 10px;
  text-decoration: none;
}

.public-nav-links button.active,
.public-nav-links button:hover,
.public-nav-links a.active,
.public-nav-links a:hover {
  color: #2563eb;
  background: #eff6ff;
}

.public-nav-actions .primary,
.landing-cta .primary,
.pricing-card .primary {
  color: #fff;
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  border-color: #2563eb;
}

.landing-copy {
  padding: clamp(34px, 5vw, 74px);
}

.landing-copy h1 {
  color: #0f172a;
  font-size: clamp(34px, 4.8vw, 62px);
  letter-spacing: 0;
}

.landing-copy p {
  color: #64748b;
  font-size: 18px;
}

.landing-cta {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 24px;
}

.landing-cta button {
  min-width: 150px;
  min-height: 48px;
}

.landing-visual {
  margin: clamp(34px, 5vw, 74px);
  min-height: 320px;
  display: grid;
  place-items: center;
  border-radius: 24px;
  color: #0b3a8f;
  background:
    radial-gradient(circle at 50% 42%, rgba(37, 99, 235, 0.14), transparent 42%),
    linear-gradient(180deg, #ffffff, #eff6ff);
  border: 1px solid #dbeafe;
}

.construction-tower {
  width: 220px;
  height: 170px;
  border-radius: 18px 18px 6px 6px;
  background:
    repeating-linear-gradient(90deg, transparent 0 24px, rgba(37, 99, 235, 0.16) 24px 31px),
    repeating-linear-gradient(0deg, #2563eb 0 4px, #fff 4px 34px);
  box-shadow: 0 22px 54px rgba(37, 99, 235, 0.18);
}

.landing-feature-grid {
  grid-column: 1 / -1;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  padding: 0 clamp(28px, 4vw, 54px) 24px;
}

.landing-feature-grid article {
  border-radius: 18px;
  background: #fff;
  border: 1px solid #e2e8f0;
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.06);
}

.landing-feature-grid span {
  color: #2563eb;
  font-weight: 900;
}

.landing-feature-grid p {
  margin: 6px 0 0;
  color: #64748b;
  line-height: 1.6;
}

.landing-security-row {
  padding: 0 clamp(28px, 4vw, 54px) 24px;
}

.landing-security-row span {
  background: #eff6ff;
  color: #1d4ed8;
}

.landing-panel .pricing-page {
  grid-column: 1 / -1;
  width: auto;
  margin: 0 clamp(28px, 4vw, 54px) 24px;
  box-shadow: none;
  border-radius: 22px;
}

.pricing-grid {
  direction: rtl;
}

.pricing-card {
  border-radius: 20px;
  border-color: #dbeafe;
  box-shadow: 0 16px 42px rgba(15, 23, 42, 0.07);
}

.pricing-card.featured {
  border-color: #2563eb;
  box-shadow: inset 0 4px 0 #2563eb, 0 24px 60px rgba(37, 99, 235, 0.16);
}

.pricing-card li::before {
  content: "\2713";
  color: #2563eb;
}

.public-info-section {
  grid-column: 1 / -1;
  margin: 0 clamp(28px, 4vw, 54px) 24px;
  padding: clamp(24px, 4vw, 42px);
  border-radius: 22px;
  background: #fff;
  border: 1px solid #e2e8f0;
  box-shadow: 0 16px 42px rgba(15, 23, 42, 0.06);
}

.public-info-section h2 {
  margin: 0 0 12px;
  color: #0f172a;
  font-size: 30px;
}

.public-info-section p {
  max-width: 980px;
  color: #64748b;
  line-height: 2;
  font-weight: 700;
}

.whatsapp-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 10px 18px;
  border-radius: 10px;
  color: #fff;
  background: #2563eb;
  text-decoration: none;
  font-weight: 900;
  box-shadow: 0 14px 28px rgba(37, 99, 235, 0.18);
}

@media (max-width: 1050px) {
  .modern-login-card,
  .landing-panel,
  .public-navbar {
    grid-template-columns: 1fr;
  }

  .modern-login-card .login-hero {
    min-height: 560px;
  }

  .landing-feature-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .public-nav-links,
  .public-nav-actions {
    flex-wrap: wrap;
  }
}

@media (max-width: 680px) {
  .login-screen,
  .public-auth-screen,
  .login-screen.with-landing {
    padding: 12px;
  }

  .modern-login-card {
    border-radius: 20px;
  }

  .modern-login-card .login-form,
  .modern-login-card .login-hero {
    padding: 24px;
  }

  .login-construction-illustration {
    height: 230px;
  }

  .login-benefits,
  .landing-feature-grid,
  .pricing-grid {
    grid-template-columns: 1fr;
  }

  .public-navbar {
    padding: 14px;
  }
}

@media (min-width: 681px) {
  .modern-login-card {
    width: min(1440px, 100%);
    grid-template-columns: 1.02fr 1fr;
  }

  .modern-login-card .login-form {
    grid-column: 2;
    grid-row: 1;
  }

  .modern-login-card .login-hero {
    grid-column: 1;
    grid-row: 1;
  }
}

@media (max-width: 900px) {
  .login-screen,
  .public-auth-screen,
  .login-screen.with-landing {
    padding: 24px;
    align-items: start;
  }

  .modern-login-card {
    width: 100%;
    min-height: auto;
    grid-template-columns: 1fr;
    border-radius: 22px;
  }

  .modern-login-card .login-hero {
    min-height: auto;
    padding: 28px 24px;
    gap: 12px;
  }

  .modern-login-card .login-hero h1 {
    margin-top: 10px;
    font-size: clamp(24px, 5vw, 34px);
  }

  .modern-login-card .login-hero p {
    font-size: 15px;
    line-height: 1.7;
  }

  .login-construction-illustration {
    height: 150px;
    margin-top: 8px;
    transform: scale(0.78);
    transform-origin: center bottom;
  }

  .login-benefits {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .modern-login-card .login-form {
    padding: 24px;
    width: 100%;
    overflow: visible;
  }

  .join-type-cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .form-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .login-screen,
  .public-auth-screen,
  .login-screen.with-landing,
  .public-register-screen {
    width: 100%;
    min-width: 0;
    padding: 16px;
    overflow-x: hidden;
  }

  .modern-login-card,
  .login-card,
  .public-register-card {
    width: 100%;
    min-width: 0;
    border-radius: 18px;
  }

  .modern-login-card .login-hero {
    min-height: auto;
    padding: 18px 16px;
    text-align: center;
  }

  .modern-login-card .brand {
    grid-template-columns: 44px 1fr;
    justify-content: center;
    margin: 0 auto 8px;
    text-align: start;
  }

  .modern-login-card .brand-mark,
  .public-register-brand .brand-mark {
    width: 44px;
    height: 44px;
  }

  .modern-login-card .login-hero h1 {
    margin: 8px 0 0;
    font-size: 24px;
    line-height: 1.28;
  }

  .modern-login-card .login-hero p {
    margin: 0;
    font-size: 14px;
    line-height: 1.65;
  }

  .login-construction-illustration {
    display: none;
  }

  .login-benefits {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin-top: 8px;
  }

  .login-benefits span {
    min-height: 42px;
    padding: 6px;
    font-size: 12px;
  }

  .modern-login-card .login-form {
    padding: 18px 16px 20px;
  }

  .modern-login-card .login-form h2 {
    font-size: 26px;
  }

  .login-form-subtitle {
    margin: 8px 0 16px;
    font-size: 14px;
  }

  .auth-tabs {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .auth-tabs button,
  .modern-login-card input,
  .modern-login-card select,
  .modern-login-card textarea,
  .modern-login-card .auth-submit,
  .modern-login-card .google-auth-button,
  .forgot-password-button,
  .auth-back-button {
    width: 100%;
    min-height: 48px;
    font-size: 15px;
  }

  .remember-login {
    width: 100%;
    min-height: 44px;
    align-items: center;
  }

  .forgot-password-button {
    margin-inline-start: 0;
    text-align: center;
  }

  .join-type-cards {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .join-type-card {
    width: 100%;
    min-height: auto;
    grid-template-columns: 42px 1fr;
    align-items: center;
  }

  .join-type-card small {
    grid-column: 1 / -1;
  }

  .field,
  .field-full,
  .form-grid > * {
    grid-column: 1 / -1;
    min-width: 0;
  }

  .public-register-card {
    padding: 16px;
  }

  .public-register-brand {
    align-items: flex-start;
    margin-bottom: 14px;
  }

  .public-register-card h1 {
    font-size: 24px;
    line-height: 1.3;
  }

  .public-register-tabs {
    display: grid;
    grid-template-columns: 1fr;
    padding: 6px;
  }

  .public-register-tabs a {
    flex: none;
    width: 100%;
    min-height: 42px;
  }
}

@media (max-width: 360px) {
  .login-screen,
  .public-auth-screen,
  .login-screen.with-landing,
  .public-register-screen {
    padding: 12px;
  }

  .modern-login-card .login-hero,
  .modern-login-card .login-form {
    padding-inline: 12px;
  }

  .modern-login-card .login-hero h1,
  .modern-login-card .login-form h2 {
    font-size: 22px;
  }
}

.firebase-sync-banner {
  margin: 0 14px 12px;
  border-radius: 8px;
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.08);
}

.app-loading {
  background:
    radial-gradient(circle at top right, rgba(37, 99, 235, 0.14), transparent 34vw),
    var(--premium-bg);
}

.loading-sidebar,
.loading-main,
.loading-panel,
.loading-metrics span {
  border-radius: 8px;
  border-color: rgba(226, 232, 240, 0.82);
  box-shadow: 0 14px 32px rgba(15, 23, 42, 0.06);
}

.loading-logo {
  background: linear-gradient(135deg, var(--premium-blue), var(--premium-emerald));
}

.construction-empty-state,
.chat-empty,
.ai-empty,
.nav-empty,
.document-file-summary {
  border-radius: 8px;
  border: 1px dashed rgba(148, 163, 184, 0.46);
  background: rgba(248, 250, 252, 0.86);
  color: var(--premium-slate);
}

.assistant-panel,
.conversation-list > button,
.compact-record,
.warehouse-card,
.marketplace-card,
.provider-card,
.rfq-card,
.business-network-page .insight,
.business-network-page .request-row,
.approval-detail-grid > div,
.approval-payload > div {
  border-radius: 8px;
  border-color: rgba(226, 232, 240, 0.82);
}

.business-network-page .panel-head h2,
.marketplace-directory .panel-head h2 {
  color: var(--premium-navy);
}

.business-network-page .side-grid {
  align-items: stretch;
}

.business-network-page .request-row {
  background: #fff;
  border: 1px solid rgba(226, 232, 240, 0.86);
  padding: 10px;
}

.marketplace-filterbar input,
.marketplace-filterbar select {
  min-height: 40px;
}

.conversation-list > button.active {
  background: var(--premium-blue-soft);
  border-color: rgba(37, 99, 235, 0.24);
}

@media (max-width: 760px) {
  .login-card,
  .landing-panel,
  .pricing-page,
  .modal-card {
    border-radius: 8px;
  }

  .table-wrap table {
    min-width: 720px;
  }

  .row-actions {
    flex-wrap: wrap;
  }

  .row-actions button,
  .button-link {
    min-height: 40px;
  }
}
.portal-permissions {
  border: 1px solid var(--line, #dbe3ee);
  border-radius: 10px;
  padding: 12px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 8px;
  background: #f8fafc;
  box-sizing: border-box;
}

.portal-permissions legend {
  padding: 0 8px;
  color: #475569;
  font-weight: 700;
}

.portal-permissions label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: 13px;
}

/* Stability patch: prevent full-page shake when an action re-renders the app. */
html {
  overflow-y: scroll;
  scrollbar-gutter: stable;
  overflow-anchor: none;
}

body {
  overflow-x: hidden;
  overflow-anchor: none;
}

#app {
  min-height: 100vh;
  overflow-anchor: none;
}

body.is-rendering {
  scroll-behavior: auto !important;
}

.main,
.panel,
.metric,
.table-wrap {
  backface-visibility: hidden;
  overflow-anchor: none;
}

.panel:hover,
.metric:hover {
  transform: none;
}

/* Hard motion guard for authenticated app pages.
   Actions rebuild parts of the DOM, so page/card entrance animations must not replay. */
.app .main > section,
.app .main > div:not(.firebase-sync-banner),
.app .metrics,
.app .panel,
.app .metric,
.app .toolbar,
.app .table-wrap {
  animation: none !important;
}

.app .panel,
.app .metric,
.app .dashboard-quick-actions button,
.app .panel-head button,
.app .toolbar button,
.app .row-actions button,
.app button.primary,
.app .primary,
.app .nav-button,
.app .sidebar-collapse-toggle,
.app .nav-section-toggle {
  transition-property: background, background-color, border-color, box-shadow, color, opacity, max-height !important;
}

.app .panel:hover,
.app .metric:hover,
.app .dashboard-quick-actions button:hover,
.app .panel-head button:hover,
.app .toolbar button:hover,
.app .row-actions button:hover,
.app button.primary:hover,
.app .primary:hover,
.app .nav-button:hover,
.app .sidebar-collapse-toggle:hover,
.app .nav-section-toggle:hover,
.app .dashboard-quick-actions button:active,
.app .panel-head button:active,
.app .toolbar button:active,
.app .row-actions button:active,
.app button.primary:active,
.app .primary:active {
  transform: none !important;
}

.attendance-row {
  min-height: 70px;
  contain: layout paint;
}

.attendance-options {
  min-width: 498px;
}

.attendance-options button {
  min-width: 78px;
  min-height: 38px;
  line-height: 1.2;
  white-space: nowrap;
  transform: none !important;
  transition-property: background, background-color, border-color, color, box-shadow !important;
}

@media (max-width: 760px) {
  .attendance-options {
    min-width: 0;
  }
}

/* Approved external account portals: contractor, supplier, worker, scrap. */
.provider-portal-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 292px;
  direction: ltr;
  background:
    radial-gradient(circle at 10% 0%, rgba(37, 99, 235, 0.08), transparent 34vw),
    #f8fafc;
  color: #0f172a;
}

.provider-portal-sidebar {
  grid-column: 2;
  direction: rtl;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 26px 18px;
  overflow-y: auto;
  background: linear-gradient(180deg, #062448 0%, #031a35 100%);
  color: #e5efff;
  box-shadow: -20px 0 50px rgba(2, 18, 43, 0.18);
}

.provider-brand {
  display: grid;
  justify-items: center;
  gap: 6px;
  padding: 10px 8px 26px;
  text-align: center;
}

.provider-brand span {
  width: 74px;
  height: 74px;
  display: grid;
  place-items: center;
  border-radius: 22px;
  background: rgba(37, 99, 235, 0.16);
  font-size: 42px;
}

.provider-brand strong {
  color: #fff;
  font-size: 1.25rem;
  font-weight: 900;
}

.provider-brand small {
  color: #bfdbfe;
}

.provider-portal-sidebar nav {
  display: grid;
  gap: 8px;
}

.provider-portal-sidebar nav button,
.provider-logout {
  width: 100%;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  min-height: 50px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #e2e8f0;
  text-align: start;
  box-shadow: none;
  overflow: hidden;
}

.provider-portal-sidebar nav button {
  cursor: pointer;
}

.provider-portal-sidebar nav button span,
.provider-logout span {
  display: inline-grid;
  place-items: center;
}

.provider-portal-sidebar nav button:hover,
.provider-portal-sidebar nav button.active {
  background: linear-gradient(135deg, #2563eb, #0d62ff);
  color: #fff;
}

.provider-portal-sidebar nav button.active {
  box-shadow: 0 12px 24px rgba(37, 99, 235, 0.24);
}

.provider-logout {
  margin-top: auto;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  padding-top: 18px;
}

.provider-portal-main {
  grid-column: 1;
  grid-row: 1;
  direction: rtl;
  min-width: 0;
  padding: 14px 18px 22px;
}

.provider-topbar {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 18px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.06);
}

.provider-alerts,
.provider-user {
  display: flex;
  align-items: center;
  gap: 14px;
}

.provider-alerts button {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  min-height: 42px;
  padding: 0;
  border-inline-end: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #fff;
  box-shadow: none;
}

.provider-alerts b {
  position: absolute;
  top: 2px;
  inset-inline-start: 3px;
  min-width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: #2563eb;
  color: #fff;
  font-size: 11px;
}

.provider-user {
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
}

.provider-user small,
.provider-user span,
.provider-title p {
  color: #64748b;
}

.provider-user strong {
  font-size: 1rem;
  font-weight: 900;
}

.provider-title {
  margin: 24px 0 18px;
  text-align: right;
}

.provider-title h1 {
  margin: 0 0 6px;
  font-size: 1.85rem;
  font-weight: 900;
}

.provider-kpis {
  display: grid;
  grid-template-columns: repeat(5, minmax(150px, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.provider-kpi {
  min-height: 118px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px;
  border: 1px solid #dbeafe;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 14px 34px rgba(15, 23, 42, 0.06);
}

.provider-kpi.green { background: linear-gradient(135deg, #fff, #ecfdf5); border-color: #bbf7d0; }
.provider-kpi.blue { background: linear-gradient(135deg, #fff, #eff6ff); border-color: #bfdbfe; }
.provider-kpi.orange { background: linear-gradient(135deg, #fff, #fff7ed); border-color: #fed7aa; }
.provider-kpi.purple { background: linear-gradient(135deg, #fff, #faf5ff); border-color: #e9d5ff; }
.provider-kpi.cyan { background: linear-gradient(135deg, #fff, #ecfeff); border-color: #a5f3fc; }

.provider-kpi span {
  color: #2563eb;
  font-weight: 800;
  font-size: 0.82rem;
}

.provider-kpi strong {
  display: block;
  margin-top: 10px;
  font-size: 1.55rem;
  font-weight: 950;
}

.provider-kpi small {
  color: #64748b;
}

.provider-kpi b {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  background: rgba(37, 99, 235, 0.12);
  font-size: 25px;
}

.provider-grid {
  display: grid;
  gap: 16px;
  margin-bottom: 16px;
}

.provider-grid.two {
  grid-template-columns: 1.25fr 0.9fr;
}

.provider-grid.three {
  grid-template-columns: 1.35fr 0.9fr 0.9fr;
}

.provider-card {
  min-width: 0;
  overflow: hidden;
  padding: 18px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 14px 34px rgba(15, 23, 42, 0.06);
}

.provider-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.provider-card h3 {
  margin: 0 0 12px;
  font-size: 1rem;
  font-weight: 900;
}

.provider-table-wrap {
  overflow-x: auto;
}

.provider-card table {
  width: 100%;
  border-collapse: collapse;
  min-width: min(720px, 100%);
}

.provider-card th,
.provider-card td {
  padding: 13px 10px;
  border-bottom: 1px solid #e2e8f0;
  text-align: right;
  white-space: nowrap;
}

.provider-card th {
  color: #64748b;
  font-size: 0.78rem;
}

.provider-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 10px;
  border-radius: 999px;
  background: #e8f1ff;
  color: #2563eb;
  font-weight: 800;
  font-size: 0.76rem;
}

.provider-empty {
  display: grid;
  place-items: center;
  min-height: 150px;
  padding: 18px;
  border: 1px dashed #cbd5e1;
  border-radius: 8px;
  background: #f8fafc;
  text-align: center;
}

.provider-empty strong {
  color: #0f172a;
  font-weight: 900;
}

.provider-empty p {
  max-width: 420px;
  margin: 8px auto 0;
  color: #64748b;
  line-height: 1.8;
}

.provider-donut {
  width: 174px;
  height: 174px;
  display: grid;
  place-items: center;
  margin: 14px auto;
  border-radius: 50%;
  background: conic-gradient(#2563eb 0 34%, #10b981 34% 68%, #f59e0b 68% 82%, #ef4444 82% 92%, #8b5cf6 92% 100%);
  color: #0f172a;
  position: relative;
}

.provider-donut::before {
  content: "";
  position: absolute;
  inset: 28px;
  border-radius: 50%;
  background: #fff;
}

.provider-donut strong,
.provider-donut span {
  position: relative;
  z-index: 1;
  display: block;
  text-align: center;
}

.provider-donut strong {
  font-size: 1.45rem;
}

.provider-legend,
.provider-actions,
.provider-notifications,
.provider-docs,
.provider-financial-summary,
.provider-request-list {
  display: grid;
  gap: 10px;
}

.provider-legend span,
.provider-notifications div,
.provider-docs div,
.provider-financial-summary div,
.provider-request-list div,
.provider-actions button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 42px;
  padding: 9px 10px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #fff;
}

.provider-legend b {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--dot);
}

.provider-notifications small,
.provider-request-list small,
.provider-docs small {
  color: #64748b;
}

.provider-price {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 12px 0;
  padding: 14px;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  background: #eff6ff;
}

.provider-price strong {
  font-size: 1.8rem;
}

.provider-calendar strong {
  display: block;
  margin-bottom: 12px;
  text-align: center;
}

.provider-calendar div {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
}

.provider-calendar span {
  display: grid;
  place-items: center;
  min-height: 34px;
  border-radius: 8px;
}

.provider-calendar span.active {
  background: #2563eb;
  color: #fff;
}

.provider-footer {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: 20px;
  padding: 14px 18px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  color: #64748b;
}

@media (max-width: 1180px) {
  .provider-portal-shell {
    grid-template-columns: minmax(0, 1fr) 248px;
  }

  .provider-portal-sidebar {
    padding: 20px 12px;
  }

  .provider-kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .provider-grid.two,
  .provider-grid.three {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 820px) {
  .provider-portal-shell {
    grid-template-columns: 1fr;
  }

  .provider-portal-sidebar {
    grid-column: 1;
    grid-row: 1;
    position: static;
    height: auto;
    max-height: none;
    border-radius: 0 0 18px 18px;
  }

  .provider-portal-main {
    grid-column: 1;
    grid-row: 2;
  }

  .provider-portal-sidebar nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .provider-logout {
    margin-top: 8px;
  }

  .provider-topbar,
  .provider-footer {
    flex-direction: column;
    align-items: stretch;
  }
}

@media (max-width: 560px) {
  .provider-portal-main {
    padding: 10px;
  }

  .provider-topbar {
    padding: 10px;
  }

  .provider-alerts,
  .provider-user {
    width: 100%;
    justify-content: space-between;
  }

  .provider-kpis {
    grid-template-columns: 1fr;
  }

  .provider-portal-sidebar nav {
    grid-template-columns: 1fr;
  }

  .provider-card,
  .provider-kpi {
    padding: 14px;
  }

  .provider-card table {
    min-width: 640px;
  }
}

/* ===== Premium SaaS UI layer - safe visual overrides only ===== */
:root {
  --ui-blue-950: #0b1f44;
  --ui-blue-900: #0f2f66;
  --ui-blue-800: #174ea6;
  --ui-blue-700: #1d5fd7;
  --ui-blue-600: #2563eb;
  --ui-blue-500: #3b82f6;
  --ui-blue-100: #dbeafe;
  --ui-blue-50: #eff6ff;
  --ui-success: #16a34a;
  --ui-success-soft: #dcfce7;
  --ui-danger: #dc2626;
  --ui-danger-soft: #fee2e2;
  --ui-warning: #f59e0b;
  --ui-warning-soft: #fef3c7;
  --ui-info: #0284c7;
  --ui-info-soft: #e0f2fe;
  --ui-bg: #f7fbff;
  --ui-surface: #ffffff;
  --ui-surface-soft: #f8fafc;
  --ui-text: #0f172a;
  --ui-muted: #64748b;
  --ui-border: #dbe5f0;
  --ui-radius-sm: 8px;
  --ui-radius: 12px;
  --ui-radius-lg: 18px;
  --ui-shadow-sm: 0 8px 22px rgba(15, 23, 42, 0.06);
  --ui-shadow: 0 18px 45px rgba(37, 99, 235, 0.10);
  --ui-shadow-lg: 0 28px 70px rgba(15, 23, 42, 0.16);
  --ui-space-1: 4px;
  --ui-space-2: 8px;
  --ui-space-3: 12px;
  --ui-space-4: 16px;
  --ui-space-5: 20px;
  --ui-space-6: 24px;
  --ui-transition: 180ms cubic-bezier(0.2, 0.75, 0.25, 1);
  --bg: var(--ui-bg);
  --surface: var(--ui-surface);
  --surface-2: var(--ui-surface-soft);
  --ink: var(--ui-text);
  --muted: var(--ui-muted);
  --line: var(--ui-border);
  --brand: var(--ui-blue-600);
  --brand-2: var(--ui-blue-800);
  --danger: var(--ui-danger);
  --ok: var(--ui-success);
  --warning: var(--ui-warning);
  --shadow: var(--ui-shadow-sm);
  --primary: var(--ui-blue-600);
  --primary-soft: var(--ui-blue-50);
  --border: var(--ui-border);
}

html {
  overflow-x: hidden;
  scroll-behavior: smooth;
}

body {
  overflow-x: hidden;
  background:
    radial-gradient(circle at 10% 0%, rgba(59, 130, 246, 0.12), transparent 32rem),
    linear-gradient(180deg, #f8fbff 0%, #eef6ff 100%);
  color: var(--ui-text);
  font-family: "Cairo", "Tajawal", "IBM Plex Sans Arabic", "Segoe UI", Tahoma, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.app,
.provider-portal-shell,
.login-screen,
.module-page,
.workspace {
  animation: ui-page-in 260ms var(--ui-transition) both;
}

.main {
  min-width: 0;
  padding: clamp(14px, 2vw, 24px);
}

.sidebar,
.provider-portal-sidebar {
  background:
    linear-gradient(180deg, rgba(37, 99, 235, 0.18), transparent 34%),
    linear-gradient(180deg, var(--ui-blue-950), #071936);
  border-inline-end: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 18px 0 42px rgba(15, 23, 42, 0.16);
}

[dir="rtl"] .sidebar,
[dir="rtl"] .provider-portal-sidebar {
  border-inline-end: 0;
  border-inline-start: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: -18px 0 42px rgba(15, 23, 42, 0.16);
}

.brand-mark,
.provider-portal-logo,
.provider-avatar {
  border-radius: var(--ui-radius);
  background: linear-gradient(135deg, var(--ui-blue-500), var(--ui-blue-800));
  box-shadow: 0 14px 30px rgba(37, 99, 235, 0.24);
}

.nav-button,
.provider-portal-sidebar nav button {
  border-radius: var(--ui-radius);
  min-height: 44px;
  transition: transform var(--ui-transition), background var(--ui-transition), border-color var(--ui-transition), box-shadow var(--ui-transition);
}

.nav-button:hover,
.provider-portal-sidebar nav button:hover {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.10);
}

.nav-button.active,
.provider-portal-sidebar nav button.active {
  background: linear-gradient(135deg, var(--ui-blue-600), #1e40af);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.18);
  box-shadow: 0 12px 28px rgba(37, 99, 235, 0.28);
}

.topbar,
.provider-topbar {
  border: 1px solid rgba(219, 229, 240, 0.9);
  border-radius: var(--ui-radius-lg);
  background: rgba(255, 255, 255, 0.86);
  box-shadow: var(--ui-shadow-sm);
  backdrop-filter: blur(14px);
}

.topbar h1,
.provider-title h1,
.panel-head h2,
.panel-head h3 {
  color: var(--ui-text);
  letter-spacing: 0;
}

.topbar h1,
.provider-title h1 {
  font-size: clamp(22px, 2.2vw, 34px);
  line-height: 1.25;
}

.muted,
.topbar p,
.provider-title p,
.panel-head p,
small {
  color: var(--ui-muted);
}

.panel,
.metric,
.login-card,
.modal-card,
.provider-card,
.provider-kpi,
.pricing-card,
.insight,
.message-item,
.company-card,
.stat-card {
  border: 1px solid rgba(219, 229, 240, 0.95);
  border-radius: var(--ui-radius-lg);
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--ui-shadow-sm);
  transition: transform var(--ui-transition), box-shadow var(--ui-transition), border-color var(--ui-transition);
}

.panel:hover,
.metric:hover,
.provider-card:hover,
.provider-kpi:hover,
.pricing-card:hover,
.insight:hover {
  transform: translateY(-2px);
  box-shadow: var(--ui-shadow);
  border-color: rgba(147, 197, 253, 0.95);
}

.metrics,
.provider-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: var(--ui-space-4);
}

.metric,
.provider-kpi {
  min-height: 116px;
  overflow: hidden;
  position: relative;
}

.metric::after,
.provider-kpi::after {
  content: "";
  position: absolute;
  inset-inline-end: -38px;
  inset-block-start: -38px;
  width: 96px;
  height: 96px;
  border-radius: 999px;
  background: var(--ui-blue-50);
}

.metric strong,
.provider-kpi strong {
  color: var(--ui-text);
  font-size: clamp(24px, 2.4vw, 36px);
  line-height: 1.15;
}

button,
.button-link,
input[type="button"],
input[type="submit"] {
  border-radius: var(--ui-radius);
  min-height: 42px;
  transition: transform var(--ui-transition), box-shadow var(--ui-transition), background var(--ui-transition), border-color var(--ui-transition), color var(--ui-transition);
}

button:hover,
.button-link:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 22px rgba(15, 23, 42, 0.08);
}

button:active,
.button-link:active {
  transform: translateY(0) scale(0.985);
}

.primary,
button.primary,
.auth-submit {
  background: linear-gradient(135deg, var(--ui-blue-600), #1e40af);
  border-color: var(--ui-blue-600);
  color: #fff;
}

.danger,
button.danger,
.destructive-button {
  background: var(--ui-danger-soft);
  border-color: #fecaca;
  color: var(--ui-danger);
}

.success,
button.success {
  background: var(--ui-success-soft);
  border-color: #bbf7d0;
  color: #166534;
}

.warning,
button.warning {
  background: var(--ui-warning-soft);
  border-color: #fde68a;
  color: #92400e;
}

input,
select,
textarea,
.sidebar-search {
  max-width: 100%;
  border-radius: var(--ui-radius);
  border: 1px solid var(--ui-border);
  background: #fff;
  color: var(--ui-text);
  transition: border-color var(--ui-transition), box-shadow var(--ui-transition), background var(--ui-transition);
}

input:focus,
select:focus,
textarea:focus,
.sidebar-search:focus {
  outline: none;
  border-color: var(--ui-blue-500);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.14);
}

.field label {
  color: var(--ui-text);
  font-weight: 800;
}

.table-wrap {
  border: 1px solid var(--ui-border);
  border-radius: var(--ui-radius-lg);
  background: #fff;
  overflow: auto;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
  -webkit-overflow-scrolling: touch;
}

table {
  border-collapse: separate;
  border-spacing: 0;
}

th {
  background: linear-gradient(180deg, #f8fbff, #eef6ff);
  color: #1e3a8a;
  font-weight: 900;
}

td,
th {
  border-color: #e6eef8;
}

tbody tr {
  transition: background var(--ui-transition), transform var(--ui-transition);
}

tbody tr:hover {
  background: #f8fbff;
}

.badge,
.status-badge,
.alert-status {
  border-radius: 999px;
  font-weight: 800;
  border: 1px solid transparent;
}

.badge.success,
.status-active,
.status-approved,
.status-paid,
.status-completed {
  background: var(--ui-success-soft);
  color: #166534;
  border-color: #bbf7d0;
}

.badge.danger,
.status-rejected,
.status-banned,
.status-deleted {
  background: var(--ui-danger-soft);
  color: var(--ui-danger);
  border-color: #fecaca;
}

.badge.warning,
.status-pending,
.status-suspended,
.status-overdue {
  background: var(--ui-warning-soft);
  color: #92400e;
  border-color: #fde68a;
}

.badge.info,
.status-open,
.status-new {
  background: var(--ui-info-soft);
  color: var(--ui-info);
  border-color: #bae6fd;
}

.toast {
  border: 1px solid var(--ui-border);
  border-inline-start: 5px solid var(--ui-info);
  border-radius: var(--ui-radius-lg);
  background: rgba(255, 255, 255, 0.96);
  color: var(--ui-text);
  box-shadow: var(--ui-shadow-lg);
  backdrop-filter: blur(16px);
}

.toast::before {
  content: "\2139";
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  margin-inline-end: 8px;
  border-radius: 999px;
  background: var(--ui-info-soft);
  color: var(--ui-info);
  font-weight: 900;
}

.toast.has-success-animation,
.toast.success {
  border-inline-start-color: var(--ui-success);
}

.toast.has-success-animation::before,
.toast.success::before {
  content: "\2713";
  background: var(--ui-success-soft);
  color: var(--ui-success);
}

.toast.error,
.toast.danger {
  border-inline-start-color: var(--ui-danger);
}

.toast.error::before,
.toast.danger::before {
  content: "!";
  background: var(--ui-danger-soft);
  color: var(--ui-danger);
}

.toast.warning {
  border-inline-start-color: var(--ui-warning);
}

.toast.warning::before {
  content: "!";
  background: var(--ui-warning-soft);
  color: var(--ui-warning);
}

.modal {
  backdrop-filter: blur(10px);
}

.modal-card {
  width: min(980px, calc(100vw - 28px));
}

.row-actions {
  gap: 8px;
  flex-wrap: wrap;
}

.row-actions button {
  min-height: 36px;
}

.login-screen {
  padding: clamp(16px, 4vw, 44px);
}

.login-card {
  max-width: min(1100px, 100%);
}

.auth-tabs,
.join-type-tabs {
  gap: var(--ui-space-2);
}

.auth-tabs button.active,
.join-type-tabs button.active {
  background: linear-gradient(135deg, var(--ui-blue-600), #1e40af);
  color: #fff;
  border-color: var(--ui-blue-600);
}

@keyframes ui-page-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 1180px) {
  .app {
    grid-template-columns: 260px minmax(0, 1fr);
  }

  .metrics,
  .provider-kpis {
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  }
}

@media (max-width: 1050px) {
  .app,
  .app.sidebar-is-collapsed {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    z-index: 80;
    inset-block: 0;
    width: min(320px, 86vw);
    transform: translateX(-110%);
    overflow-y: auto;
  }

  [dir="rtl"] .sidebar {
    transform: translateX(110%);
  }

  .mobile-nav-open .sidebar,
  [dir="rtl"] .mobile-nav-open .sidebar {
    transform: translateX(0);
  }

  .mobile-nav-backdrop {
    position: fixed;
    inset: 0;
    z-index: 70;
    background: rgba(15, 23, 42, 0.42);
    backdrop-filter: blur(3px);
  }

  body:not(.mobile-nav-open) .mobile-nav-backdrop {
    display: none;
  }

  .mobile-menu-toggle {
    display: inline-grid;
  }
}

@media (max-width: 760px) {
  .main,
  .provider-portal-main {
    padding: 12px;
  }

  .topbar,
  .provider-topbar,
  .panel-head {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .topbar .actions,
  .tools-menu {
    width: 100%;
    justify-content: flex-start;
  }

  .metrics,
  .provider-kpis,
  .provider-grid.two,
  .provider-grid.three,
  .workspace,
  .side-grid,
  .dashboard-finance-grid,
  .dashboard-hr-inventory,
  .performance-row {
    grid-template-columns: 1fr !important;
  }

  .panel,
  .provider-card,
  .metric,
  .provider-kpi {
    padding: 14px;
  }

  .field,
  .form-grid,
  form,
  .modal-card form {
    max-width: 100%;
  }

  input,
  select,
  textarea,
  button,
  .button-link {
    width: 100%;
  }

  .row-actions button,
  .panel-head button,
  .toolbar button,
  .inventory-tabs button,
  .auth-tabs button,
  .join-type-tabs button {
    width: auto;
    flex: 1 1 140px;
  }

  .table-wrap {
    border: 0;
    background: transparent;
    box-shadow: none;
    overflow: visible;
  }

  .table-wrap table {
    min-width: 0 !important;
    width: 100%;
  }

  .table-wrap thead {
    display: none;
  }

  .table-wrap tbody,
  .table-wrap tr,
  .table-wrap td {
    display: block;
    width: 100%;
  }

  .table-wrap tr {
    margin-block: 12px;
    padding: 12px;
    border: 1px solid var(--ui-border);
    border-radius: var(--ui-radius-lg);
    background: #fff;
    box-shadow: var(--ui-shadow-sm);
  }

  .table-wrap td {
    border: 0;
    padding: 8px 0;
    min-height: 32px;
  }

  .table-wrap td + td {
    border-top: 1px dashed #e2e8f0;
  }

  .table-wrap td:empty {
    display: none;
  }

  .provider-portal-shell {
    grid-template-columns: 1fr;
  }

  .provider-portal-sidebar {
    position: static;
    min-height: auto;
    border-radius: 0 0 var(--ui-radius-lg) var(--ui-radius-lg);
  }
}

@media (max-width: 480px) {
  .main,
  .provider-portal-main,
  .login-screen {
    padding: 10px;
  }

  .topbar,
  .provider-topbar {
    border-radius: var(--ui-radius);
  }

  .topbar h1,
  .provider-title h1 {
    font-size: 22px;
  }

  .metric strong,
  .provider-kpi strong {
    font-size: 26px;
  }

  .modal-card {
    width: calc(100vw - 16px);
    max-height: calc(100vh - 16px);
    border-radius: var(--ui-radius);
  }

  .tools-menu-panel {
    width: calc(100vw - 24px);
    inset-inline: 12px auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}

/* ===== Final readability fix: must remain last ===== */
:root {
  --bg: #f8fafc !important;
  --surface: #ffffff !important;
  --ink: #0f172a !important;
  --muted: #64748b !important;
  --line: #e2e8f0 !important;
  --brand: #2563eb !important;
  --brand-2: #0f2a55 !important;
  --primary: #2563eb !important;
  --border: #e2e8f0 !important;
}

html,
body,
#app {
  max-width: 100% !important;
  overflow-x: hidden !important;
}

body {
  background: #f8fafc !important;
  color: #0f172a !important;
}

.app {
  grid-template-columns: minmax(260px, 280px) minmax(0, 1fr) !important;
}

.main {
  width: 100% !important;
  max-width: 1480px !important;
  margin-inline: auto !important;
  padding: 20px !important;
  overflow-x: hidden !important;
}

.metrics {
  display: grid !important;
  grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
  gap: 18px !important;
}

.metric,
.provider-kpi {
  min-height: 120px !important;
  padding: 20px !important;
  display: grid !important;
  align-content: center !important;
  gap: 8px !important;
  background: #fff !important;
  color: #0f172a !important;
  border: 1px solid #e2e8f0 !important;
  border-radius: 16px !important;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06) !important;
  overflow: visible !important;
  isolation: isolate !important;
}

.metric::before,
.metric::after,
.provider-kpi::before,
.provider-kpi::after {
  opacity: 0.06 !important;
  z-index: -1 !important;
  pointer-events: none !important;
}

.metric *,
.provider-kpi * {
  position: relative !important;
  z-index: 2 !important;
  overflow: visible !important;
  text-overflow: clip !important;
  white-space: normal !important;
}

.metric span,
.metric small,
.provider-kpi span,
.provider-kpi small {
  color: #64748b !important;
  font-size: 13px !important;
  line-height: 1.6 !important;
}

.metric strong,
.metric b,
.provider-kpi strong,
.provider-kpi b {
  color: #0f172a !important;
  font-size: clamp(28px, 2.8vw, 38px) !important;
  font-weight: 900 !important;
  line-height: 1.15 !important;
}

.panel,
.provider-card,
.insight,
.message-item,
.company-card,
.stat-card,
.modal-card,
.login-card {
  background: #fff !important;
  color: #0f172a !important;
  border-color: #e2e8f0 !important;
  overflow: visible !important;
}

.panel-head h2,
.panel-head h3,
.topbar h1,
.provider-title h1,
h1,
h2,
h3 {
  color: #0f172a !important;
  font-weight: 900 !important;
  line-height: 1.35 !important;
}

.muted,
.panel-head p,
.topbar p,
.provider-title p,
small {
  color: #64748b !important;
}

.sidebar {
  width: 280px !important;
  max-width: 280px !important;
  min-width: 260px !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
}

.nav-section-title,
.nav-button,
.nav-button span,
.brand strong,
.brand small {
  white-space: normal !important;
  overflow: visible !important;
  text-overflow: clip !important;
  line-height: 1.45 !important;
}

.nav-button.active,
.nav-section.open > .nav-section-toggle,
.nav-section.contains-active > .nav-section-toggle {
  background: #2563eb !important;
  color: #fff !important;
  border-color: #2563eb !important;
}

.nav-button.active *,
.nav-section.open > .nav-section-toggle *,
.nav-section.contains-active > .nav-section-toggle * {
  color: #fff !important;
}

.dashboard-construction-scene {
  min-height: 150px !important;
  max-height: 190px !important;
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 38%) !important;
  align-items: center !important;
  gap: 16px !important;
  padding: 20px 28px !important;
  overflow: hidden !important;
}

.dashboard-construction-scene > div {
  z-index: 2 !important;
}

.dashboard-construction-scene strong,
.dashboard-construction-scene span {
  color: #0f172a !important;
  white-space: normal !important;
}

.dashboard-construction-scene img {
  max-width: 100% !important;
  max-height: 160px !important;
  object-fit: contain !important;
}

.table-wrap {
  max-width: 100% !important;
  overflow-x: auto !important;
}

th,
td {
  color: #0f172a !important;
}

th {
  color: #0f2a55 !important;
}

.primary,
button.primary {
  background: #2563eb !important;
  border-color: #2563eb !important;
  color: #fff !important;
}

.danger,
button.danger {
  background: #fee2e2 !important;
  border-color: #fecaca !important;
  color: #dc2626 !important;
}

@media (max-width: 1180px) {
  .metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
}

@media (max-width: 1050px) {
  .app,
  .app.sidebar-is-collapsed {
    grid-template-columns: 1fr !important;
  }

  .sidebar {
    width: min(300px, 86vw) !important;
    max-width: min(300px, 86vw) !important;
    min-width: 0 !important;
  }
}

@media (max-width: 760px) {
  .main {
    padding: 12px !important;
  }

  .metrics {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }

  .dashboard-construction-scene {
    grid-template-columns: 1fr !important;
    max-height: none !important;
    padding: 18px !important;
  }

  .dashboard-construction-scene img {
    max-height: 110px !important;
    justify-self: center !important;
  }

  .table-wrap {
    overflow-x: auto !important;
  }

  .table-wrap table {
    min-width: 680px !important;
  }

  .table-wrap thead {
    display: table-header-group !important;
  }

  .table-wrap tbody,
  .table-wrap tr {
    display: revert !important;
  }

  .table-wrap td,
  .table-wrap th {
    display: table-cell !important;
    width: auto !important;
  }
}
/* ===== EOF stability lock - final override ===== */
html,
body,
#app,
.app,
.main {
  overflow-x: hidden !important;
}

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 {
  transition: background-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease !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 {
  transform: none !important;
}

.app,
.provider-portal-shell,
.login-screen,
.module-page,
.workspace,
.panel,
.metric,
.modal,
.modal-card,
.toast {
  animation: none !important;
}
/* ERP-grade navigation rebuild: visual-only, keeps existing routes/permissions/data-module hooks. */
:root {
  --erp-sidebar-width: 276px;
  --erp-sidebar-collapsed-width: 82px;
  --erp-sidebar-bg: #0b1f3a;
  --erp-sidebar-bg-2: #0f2a55;
  --erp-sidebar-line: rgba(191, 219, 254, 0.16);
  --erp-sidebar-text: #e8f1ff;
  --erp-sidebar-muted: #9fb4d1;
  --erp-sidebar-active-bg: #eff6ff;
  --erp-sidebar-active-text: #1d4ed8;
}

.app {
  grid-template-columns: var(--erp-sidebar-width) minmax(0, 1fr) !important;
}

.app.sidebar-is-collapsed {
  grid-template-columns: var(--erp-sidebar-collapsed-width) minmax(0, 1fr) !important;
}

.sidebar {
  width: var(--erp-sidebar-width) !important;
  min-width: var(--erp-sidebar-width) !important;
  max-width: var(--erp-sidebar-width) !important;
  height: 100vh !important;
  min-height: 100vh !important;
  display: flex !important;
  flex-direction: column !important;
  gap: 14px !important;
  padding: 18px 14px !important;
  position: sticky !important;
  top: 0 !important;
  overflow: hidden !important;
  background: radial-gradient(circle at 18% 0%, rgba(37, 99, 235, 0.28), transparent 28%), linear-gradient(180deg, var(--erp-sidebar-bg-2), var(--erp-sidebar-bg)) !important;
  border-inline-end: 1px solid rgba(148, 163, 184, 0.18) !important;
  box-shadow: 14px 0 34px rgba(15, 23, 42, 0.16) !important;
  color: var(--erp-sidebar-text) !important;
  transition: width 0.18s ease, min-width 0.18s ease, max-width 0.18s ease !important;
}

[dir="rtl"] .sidebar {
  border-inline-end: 0 !important;
  border-inline-start: 1px solid rgba(148, 163, 184, 0.18) !important;
  box-shadow: -14px 0 34px rgba(15, 23, 42, 0.16) !important;
}

.sidebar.is-collapsed {
  width: var(--erp-sidebar-collapsed-width) !important;
  min-width: var(--erp-sidebar-collapsed-width) !important;
  max-width: var(--erp-sidebar-collapsed-width) !important;
  padding-inline: 10px !important;
}

.sidebar .brand {
  flex: 0 0 auto !important;
  display: grid !important;
  grid-template-columns: 46px minmax(0, 1fr) !important;
  align-items: center !important;
  gap: 10px !important;
  margin: 0 !important;
  padding: 10px !important;
  border: 1px solid var(--erp-sidebar-line) !important;
  border-radius: 18px !important;
  background: rgba(255, 255, 255, 0.07) !important;
}

.sidebar .brand-mark {
  width: 46px !important;
  height: 46px !important;
  border-radius: 14px !important;
  background: linear-gradient(135deg, #2563eb, #0ea5e9) !important;
  box-shadow: 0 12px 28px rgba(37, 99, 235, 0.28) !important;
  letter-spacing: 0 !important;
}

.sidebar .brand strong {
  color: #ffffff !important;
  font-size: 13px !important;
  line-height: 1.35 !important;
  white-space: normal !important;
}

.sidebar .brand small,
.tenant-switcher label {
  color: var(--erp-sidebar-muted) !important;
}

.tenant-switcher {
  flex: 0 0 auto !important;
  margin: 0 !important;
  padding: 10px !important;
  border: 1px solid var(--erp-sidebar-line) !important;
  border-radius: 16px !important;
  background: rgba(255, 255, 255, 0.06) !important;
}

.nav {
  flex: 1 1 auto !important;
  min-height: 0 !important;
  max-height: none !important;
  display: block !important;
  overflow: hidden !important;
  padding: 0 !important;
}

.erp-sidebar-shell {
  height: 100% !important;
  display: flex !important;
  flex-direction: column !important;
  gap: 12px !important;
  min-height: 0 !important;
}

.erp-sidebar-tools {
  flex: 0 0 auto !important;
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) 40px !important;
  gap: 8px !important;
  margin: 0 !important;
}

.erp-sidebar-search {
  height: 42px !important;
  min-height: 42px !important;
  border-radius: 14px !important;
  border: 1px solid var(--erp-sidebar-line) !important;
  background: rgba(255, 255, 255, 0.09) !important;
  color: #fff !important;
  padding: 0 13px !important;
  font-size: 13px !important;
  box-shadow: none !important;
  transition: border-color 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease !important;
}

.erp-sidebar-search::placeholder {
  color: #a9bdd8 !important;
}

.erp-sidebar-search:focus {
  border-color: #60a5fa !important;
  background: rgba(255, 255, 255, 0.13) !important;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.22) !important;
}

.erp-sidebar-collapse {
  width: 40px !important;
  min-width: 40px !important;
  height: 42px !important;
  min-height: 42px !important;
  border-radius: 14px !important;
  border: 1px solid var(--erp-sidebar-line) !important;
  background: rgba(255, 255, 255, 0.09) !important;
  color: #dbeafe !important;
  font-size: 20px !important;
  padding: 0 !important;
  transition: background-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease !important;
}

.erp-sidebar-collapse:hover {
  background: rgba(37, 99, 235, 0.32) !important;
  color: #fff !important;
}

.erp-sidebar-scroll {
  flex: 1 1 auto !important;
  min-height: 0 !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  display: grid !important;
  align-content: start !important;
  gap: 9px !important;
  padding-inline-end: 2px !important;
  scroll-behavior: smooth !important;
}

.erp-sidebar-scroll::-webkit-scrollbar {
  width: 6px !important;
}

.erp-sidebar-scroll::-webkit-scrollbar-thumb {
  border-radius: 999px !important;
  background: rgba(191, 219, 254, 0.34) !important;
}

.erp-sidebar-section {
  display: grid !important;
  gap: 6px !important;
}

.erp-sidebar-section-toggle {
  width: 100% !important;
  min-height: 44px !important;
  display: grid !important;
  grid-template-columns: 36px minmax(0, 1fr) auto 18px !important;
  align-items: center !important;
  gap: 9px !important;
  padding: 7px 9px !important;
  border-radius: 14px !important;
  border: 1px solid transparent !important;
  background: rgba(255, 255, 255, 0.045) !important;
  color: #dbeafe !important;
  text-align: start !important;
  transition: background-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease !important;
}

.erp-sidebar-section-toggle:hover,
.erp-sidebar-section.open > .erp-sidebar-section-toggle,
.erp-sidebar-section.contains-active > .erp-sidebar-section-toggle {
  background: rgba(255, 255, 255, 0.12) !important;
  border-color: rgba(96, 165, 250, 0.28) !important;
  color: #fff !important;
  box-shadow: inset 3px 0 0 #60a5fa !important;
}

[dir="rtl"] .erp-sidebar-section-toggle:hover,
[dir="rtl"] .erp-sidebar-section.open > .erp-sidebar-section-toggle,
[dir="rtl"] .erp-sidebar-section.contains-active > .erp-sidebar-section-toggle {
  box-shadow: inset -3px 0 0 #60a5fa !important;
}

.nav-section-icon {
  width: 36px !important;
  height: 32px !important;
  display: inline-grid !important;
  place-items: center !important;
  border-radius: 12px !important;
  background: rgba(96, 165, 250, 0.16) !important;
  font-size: 17px !important;
}

.nav-section-title {
  min-width: 0 !important;
  color: inherit !important;
  font-size: 14px !important;
  font-weight: 800 !important;
  line-height: 1.4 !important;
  overflow: visible !important;
  white-space: normal !important;
  text-overflow: clip !important;
}

.nav-section-count {
  min-width: 24px !important;
  height: 24px !important;
  display: inline-grid !important;
  place-items: center !important;
  padding: 0 7px !important;
  border-radius: 999px !important;
  background: rgba(255, 255, 255, 0.12) !important;
  color: #bfdbfe !important;
  font-size: 11px !important;
}

.nav-section-arrow {
  color: #93c5fd !important;
  font-size: 17px !important;
  transition: transform 0.15s ease !important;
}

[dir="rtl"] .nav-section-arrow {
  transform: rotate(180deg) !important;
}

.erp-sidebar-section.open .nav-section-arrow,
[dir="rtl"] .erp-sidebar-section.open .nav-section-arrow {
  transform: rotate(90deg) !important;
}

.erp-sidebar-section-items {
  display: grid !important;
  grid-template-rows: 0fr !important;
  transition: grid-template-rows 0.18s ease !important;
}

.erp-sidebar-section.open .erp-sidebar-section-items {
  grid-template-rows: 1fr !important;
}

.erp-sidebar-section-inner {
  min-height: 0 !important;
  overflow: hidden !important;
  display: grid !important;
  gap: 5px !important;
  padding: 0 12px 2px 0 !important;
}

[dir="rtl"] .erp-sidebar-section-inner {
  padding: 0 0 2px 12px !important;
}

.erp-sidebar-link {
  position: relative !important;
  width: 100% !important;
  min-height: 40px !important;
  display: grid !important;
  grid-template-columns: 30px minmax(0, 1fr) auto 0 !important;
  align-items: center !important;
  gap: 9px !important;
  border: 1px solid transparent !important;
  border-radius: 13px !important;
  background: transparent !important;
  color: #d4e3f7 !important;
  padding: 7px 10px !important;
  text-align: start !important;
  border-inline-start: 0 !important;
  overflow: visible !important;
  transition: background-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease !important;
}

.erp-sidebar-link:hover {
  background: rgba(255, 255, 255, 0.09) !important;
  color: #fff !important;
}

.erp-sidebar-link.active {
  background: var(--erp-sidebar-active-bg) !important;
  color: var(--erp-sidebar-active-text) !important;
  border-color: rgba(191, 219, 254, 0.9) !important;
  box-shadow: 0 12px 22px rgba(15, 23, 42, 0.16) !important;
}

.erp-sidebar-active-marker {
  position: absolute !important;
  inset-block: 9px !important;
  inset-inline-start: 0 !important;
  width: 4px !important;
  border-radius: 999px !important;
  background: transparent !important;
}

.erp-sidebar-link.active .erp-sidebar-active-marker {
  background: #2563eb !important;
}

.erp-sidebar-link-icon {
  width: 30px !important;
  height: 30px !important;
  display: inline-grid !important;
  place-items: center !important;
  border-radius: 10px !important;
  background: rgba(148, 163, 184, 0.14) !important;
  font-size: 15px !important;
}

.erp-sidebar-link.active .erp-sidebar-link-icon {
  background: #dbeafe !important;
}

.erp-sidebar-link-label {
  min-width: 0 !important;
  color: inherit !important;
  font-size: 13px !important;
  font-weight: 750 !important;
  line-height: 1.45 !important;
  white-space: normal !important;
  overflow: visible !important;
  text-overflow: clip !important;
}

.erp-sidebar-badge {
  min-width: 22px !important;
  height: 22px !important;
  display: inline-grid !important;
  place-items: center !important;
  padding: 0 6px !important;
  border-radius: 999px !important;
  background: #2563eb !important;
  color: #fff !important;
  font-size: 11px !important;
}

.erp-sidebar-favorite {
  width: 24px !important;
  height: 24px !important;
  display: inline-grid !important;
  place-items: center !important;
  border-radius: 999px !important;
  color: rgba(148, 163, 184, 0.9) !important;
  font-size: 13px !important;
  cursor: pointer !important;
}

.erp-sidebar-favorite:hover,
.erp-sidebar-favorite.is-favorite {
  background: #fef3c7 !important;
  color: #d97706 !important;
}

.erp-sidebar-flat-nav {
  display: grid !important;
  gap: 7px !important;
  overflow-y: auto !important;
  min-height: 0 !important;
}

.nav-empty {
  color: #b8c7dc !important;
  border: 1px dashed var(--erp-sidebar-line) !important;
  border-radius: 14px !important;
  padding: 14px !important;
}

.sidebar.is-collapsed .brand {
  grid-template-columns: 1fr !important;
  justify-items: center !important;
  padding: 8px !important;
}

.sidebar.is-collapsed .brand > div,
.sidebar.is-collapsed .tenant-switcher,
.sidebar.is-collapsed .erp-sidebar-search,
.sidebar.is-collapsed .nav-section-title,
.sidebar.is-collapsed .nav-section-count,
.sidebar.is-collapsed .nav-section-arrow,
.sidebar.is-collapsed .erp-sidebar-link-label,
.sidebar.is-collapsed .erp-sidebar-badge,
.sidebar.is-collapsed .erp-sidebar-favorite {
  display: none !important;
}

.sidebar.is-collapsed .erp-sidebar-tools {
  grid-template-columns: 1fr !important;
}

.sidebar.is-collapsed .erp-sidebar-section-toggle,
.sidebar.is-collapsed .erp-sidebar-link {
  grid-template-columns: 1fr !important;
  justify-items: center !important;
  padding-inline: 8px !important;
}

.sidebar.is-collapsed .erp-sidebar-section-inner {
  padding-inline: 0 !important;
}

.sidebar.is-collapsed .erp-sidebar-section.open .erp-sidebar-section-items {
  grid-template-rows: 0fr !important;
}

@media (max-width: 980px) {
  .app,
  .app.sidebar-is-collapsed {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  .sidebar,
  .sidebar.is-collapsed {
    position: fixed !important;
    inset-block: 0 !important;
    inset-inline-start: auto !important;
    inset-inline-end: 0 !important;
    z-index: 1200 !important;
    width: min(88vw, 318px) !important;
    min-width: 0 !important;
    max-width: min(88vw, 318px) !important;
    transform: translateX(110%) !important;
    transition: transform 0.18s ease !important;
  }

  [dir="ltr"] .sidebar,
  [dir="ltr"] .sidebar.is-collapsed {
    inset-inline-start: 0 !important;
    inset-inline-end: auto !important;
    transform: translateX(-110%) !important;
  }

  .mobile-nav-open .sidebar,
  .mobile-nav-open .sidebar.is-collapsed,
  [dir="ltr"] .mobile-nav-open .sidebar,
  [dir="ltr"] .mobile-nav-open .sidebar.is-collapsed {
    transform: translateX(0) !important;
  }

  .sidebar.is-collapsed .brand > div,
  .sidebar.is-collapsed .tenant-switcher,
  .sidebar.is-collapsed .erp-sidebar-search,
  .sidebar.is-collapsed .nav-section-title,
  .sidebar.is-collapsed .nav-section-count,
  .sidebar.is-collapsed .nav-section-arrow,
  .sidebar.is-collapsed .erp-sidebar-link-label,
  .sidebar.is-collapsed .erp-sidebar-badge,
  .sidebar.is-collapsed .erp-sidebar-favorite {
    display: initial !important;
  }

  .sidebar.is-collapsed .tenant-switcher {
    display: block !important;
  }

  .sidebar.is-collapsed .erp-sidebar-tools {
    grid-template-columns: minmax(0, 1fr) 40px !important;
  }

  .sidebar.is-collapsed .erp-sidebar-section-toggle {
    grid-template-columns: 36px minmax(0, 1fr) auto 18px !important;
    justify-items: stretch !important;
  }

  .sidebar.is-collapsed .erp-sidebar-link {
    grid-template-columns: 30px minmax(0, 1fr) auto 0 !important;
    justify-items: stretch !important;
  }

  .sidebar.is-collapsed .erp-sidebar-section.open .erp-sidebar-section-items {
    grid-template-rows: 1fr !important;
  }
}

/* Landing Page CMS */
.landing-cms-panel .settings-stack {
  display: grid;
  gap: 16px;
}

.landing-cms-panel .sub-panel {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 18px;
  box-shadow: 0 10px 22px rgba(15, 23, 42, 0.05);
}

.landing-cms-panel .sub-panel h3 {
  margin: 0 0 12px;
  color: #0f172a;
  font-size: 18px;
  font-weight: 800;
}

.landing-cms-panel textarea {
  min-height: 96px;
  resize: vertical;
}

.landing-cms-panel .inline-actions,
.landing-cms-panel .form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

/* Employee visibility permissions */
.employee-visibility-editor {
  border: 1px solid #dbeafe;
  background: #f8fbff;
  border-radius: 14px;
  padding: 16px;
  display: grid;
  gap: 12px;
}

.employee-visibility-editor .permission-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.employee-visibility-search {
  width: 100%;
  min-height: 42px;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  padding: 0 12px;
  background: #fff;
}

.employee-visibility-all-row,
.employee-visibility-list label {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 10px 12px;
}

.employee-visibility-list {
  display: grid;
  gap: 8px;
  max-height: 260px;
  overflow-y: auto;
  padding-inline-end: 4px;
}

.employee-visibility-list small {
  display: block;
  color: #64748b;
  margin-top: 2px;
}

.employee-visibility-editor input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: #2563eb;
  flex: 0 0 auto;
}

@media (max-width: 720px) {
  .employee-visibility-editor .permission-head {
    display: grid;
  }
}

/* Mobile landscape sidebar and print/PDF fixes */
html,
body,
#app,
.app {
  max-width: 100vw;
  overflow-x: hidden;
}

@media (max-width: 900px) and (orientation: landscape) and (pointer: coarse) {
  body.mobile-landscape-sidebar .app,
  body.mobile-landscape-sidebar .app.sidebar-is-collapsed {
    grid-template-columns: 72px minmax(0, calc(100vw - 72px)) !important;
    width: 100vw !important;
    max-width: 100vw !important;
    overflow-x: hidden !important;
  }

  body.mobile-landscape-sidebar .sidebar,
  body.mobile-landscape-sidebar .sidebar.is-collapsed,
  [dir="rtl"] body.mobile-landscape-sidebar .sidebar,
  [dir="rtl"] body.mobile-landscape-sidebar .sidebar.is-collapsed {
    position: sticky !important;
    inset-block-start: 0 !important;
    inset-inline-start: auto !important;
    inset-inline-end: auto !important;
    transform: none !important;
    width: 72px !important;
    min-width: 72px !important;
    max-width: 72px !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
    padding: 10px 8px !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    box-shadow: none !important;
    z-index: 20 !important;
  }

  body.mobile-landscape-sidebar.mobile-nav-open .sidebar,
  [dir="rtl"] body.mobile-landscape-sidebar.mobile-nav-open .sidebar {
    transform: none !important;
  }

  body.mobile-landscape-sidebar .main {
    width: calc(100vw - 72px) !important;
    max-width: calc(100vw - 72px) !important;
    min-width: 0 !important;
    margin: 0 !important;
    padding: 10px !important;
    overflow-x: hidden !important;
  }

  body.mobile-landscape-sidebar .mobile-nav-backdrop,
  body.mobile-landscape-sidebar.mobile-nav-open .mobile-nav-backdrop {
    display: none !important;
  }

  body.mobile-landscape-sidebar .brand > div,
  body.mobile-landscape-sidebar .tenant-switcher,
  body.mobile-landscape-sidebar .erp-sidebar-search,
  body.mobile-landscape-sidebar .sidebar-search,
  body.mobile-landscape-sidebar .nav-section-title,
  body.mobile-landscape-sidebar .nav-section-count,
  body.mobile-landscape-sidebar .nav-section-arrow,
  body.mobile-landscape-sidebar .erp-sidebar-link-label,
  body.mobile-landscape-sidebar .nav-button span:nth-child(2),
  body.mobile-landscape-sidebar .erp-sidebar-badge,
  body.mobile-landscape-sidebar .erp-sidebar-favorite,
  body.mobile-landscape-sidebar .mobile-menu-close {
    display: none !important;
  }

  body.mobile-landscape-sidebar .brand,
  body.mobile-landscape-sidebar .erp-sidebar-section-toggle,
  body.mobile-landscape-sidebar .nav-section-toggle,
  body.mobile-landscape-sidebar .erp-sidebar-link,
  body.mobile-landscape-sidebar .nav-button {
    grid-template-columns: 1fr !important;
    justify-items: center !important;
    padding-inline: 8px !important;
  }

  body.mobile-landscape-sidebar .erp-sidebar-section.open .erp-sidebar-section-items,
  body.mobile-landscape-sidebar .nav-section.open .nav-section-items {
    grid-template-rows: 0fr !important;
  }

  body.mobile-landscape-sidebar.mobile-nav-open .sidebar,
  body.mobile-landscape-sidebar.mobile-nav-open .sidebar.is-collapsed,
  [dir="rtl"] body.mobile-landscape-sidebar.mobile-nav-open .sidebar,
  [dir="rtl"] body.mobile-landscape-sidebar.mobile-nav-open .sidebar.is-collapsed {
    position: fixed !important;
    inset-block: 0 !important;
    inset-inline-end: 0 !important;
    width: min(82vw, 318px) !important;
    min-width: min(82vw, 318px) !important;
    max-width: min(82vw, 318px) !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
    padding: 14px 12px !important;
    overflow-y: auto !important;
    box-shadow: -18px 0 40px rgba(15, 23, 42, 0.24) !important;
    z-index: 1200 !important;
    transition: width 0.08s ease, min-width 0.08s ease, max-width 0.08s ease, box-shadow 0.08s ease !important;
  }

  [dir="ltr"] body.mobile-landscape-sidebar.mobile-nav-open .sidebar,
  [dir="ltr"] body.mobile-landscape-sidebar.mobile-nav-open .sidebar.is-collapsed {
    inset-inline-start: 0 !important;
    inset-inline-end: auto !important;
    box-shadow: 18px 0 40px rgba(15, 23, 42, 0.24) !important;
  }

  body.mobile-landscape-sidebar.mobile-nav-open .brand > div,
  body.mobile-landscape-sidebar.mobile-nav-open .tenant-switcher,
  body.mobile-landscape-sidebar.mobile-nav-open .erp-sidebar-search,
  body.mobile-landscape-sidebar.mobile-nav-open .sidebar-search,
  body.mobile-landscape-sidebar.mobile-nav-open .nav-section-title,
  body.mobile-landscape-sidebar.mobile-nav-open .nav-section-count,
  body.mobile-landscape-sidebar.mobile-nav-open .nav-section-arrow,
  body.mobile-landscape-sidebar.mobile-nav-open .erp-sidebar-link-label,
  body.mobile-landscape-sidebar.mobile-nav-open .nav-button span:nth-child(2),
  body.mobile-landscape-sidebar.mobile-nav-open .erp-sidebar-badge,
  body.mobile-landscape-sidebar.mobile-nav-open .erp-sidebar-favorite {
    display: initial !important;
  }

  body.mobile-landscape-sidebar.mobile-nav-open .tenant-switcher,
  body.mobile-landscape-sidebar.mobile-nav-open .erp-sidebar-search,
  body.mobile-landscape-sidebar.mobile-nav-open .sidebar-search {
    display: block !important;
  }

  body.mobile-landscape-sidebar.mobile-nav-open .brand {
    grid-template-columns: 44px minmax(0, 1fr) !important;
    justify-items: stretch !important;
  }

  body.mobile-landscape-sidebar.mobile-nav-open .erp-sidebar-tools {
    grid-template-columns: minmax(0, 1fr) 40px !important;
  }

  body.mobile-landscape-sidebar.mobile-nav-open .erp-sidebar-section-toggle,
  body.mobile-landscape-sidebar.mobile-nav-open .nav-section-toggle {
    grid-template-columns: 36px minmax(0, 1fr) auto 18px !important;
    justify-items: stretch !important;
  }

  body.mobile-landscape-sidebar.mobile-nav-open .erp-sidebar-link,
  body.mobile-landscape-sidebar.mobile-nav-open .nav-button {
    grid-template-columns: 30px minmax(0, 1fr) auto 0 !important;
    justify-items: stretch !important;
  }

  body.mobile-landscape-sidebar.mobile-nav-open .erp-sidebar-section.open .erp-sidebar-section-items,
  body.mobile-landscape-sidebar.mobile-nav-open .nav-section.open .nav-section-items {
    grid-template-rows: 1fr !important;
  }

  body.mobile-landscape-sidebar.mobile-nav-open .mobile-nav-backdrop {
    display: block !important;
    position: fixed !important;
    inset: 0 !important;
    z-index: 1190 !important;
    background: rgba(15, 23, 42, 0.2) !important;
    backdrop-filter: none !important;
  }
}

.sidebar,
.sidebar.is-collapsed {
  transition-duration: 0.08s !important;
}

.mobile-nav-backdrop {
  transition: opacity 0.08s ease !important;
  backdrop-filter: none !important;
}

@media print {
  @page {
    size: A4;
    margin: 10mm;
  }

  html,
  body {
    width: 100% !important;
    min-height: auto !important;
    overflow: visible !important;
    background: #fff !important;
    color: #0f172a !important;
  }

  body * {
    visibility: hidden !important;
  }

  .main,
  .main *,
  .report-container,
  .report-container *,
  .print-area,
  .print-area * {
    visibility: visible !important;
  }

  .sidebar,
  .mobile-sidebar,
  .navbar,
  .topbar,
  .header,
  .menu,
  .floating-actions,
  .assistant-widget,
  .assistant-fab,
  .search-container,
  .toolbar,
  .tools-menu,
  .tools-menu-panel,
  .mobile-nav-backdrop,
  .mobile-menu-toggle,
  .mobile-menu-close,
  .drawer,
  .overlay,
  .toast,
  .security-loading,
  .firebase-sync-banner,
  footer,
  button,
  .btn,
  .button-link,
  input,
  select,
  textarea,
  .row-actions,
  .panel-actions,
  .profile-actions,
  .quick-actions,
  .dashboard-quick-actions,
  .no-print {
    display: none !important;
    visibility: hidden !important;
  }

  .app,
  .app.sidebar-is-collapsed {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    grid-template-columns: none !important;
    overflow: visible !important;
  }

  .main,
  .content,
  .report-container,
  .panel,
  .card,
  .table-wrap,
  .data-table-wrapper {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    box-shadow: none !important;
    border-color: #dbe3ef !important;
    overflow: visible !important;
    background: #fff !important;
  }

  table {
    width: 100% !important;
    border-collapse: collapse !important;
    page-break-inside: auto !important;
    font-size: 11px !important;
  }

  tr {
    page-break-inside: avoid !important;
    page-break-after: auto !important;
  }

  th,
  td {
    border: 1px solid #cbd5e1 !important;
    color: #0f172a !important;
    background: #fff !important;
    padding: 6px !important;
  }

  th {
    background: #eaf1ff !important;
    font-weight: 700 !important;
  }
}

/* Last-rule sidebar override: phone/tablet drawer opens in portrait and landscape, closes fast. */
@media (max-width: 980px) {
  html,
  body,
  #app,
  .app {
    max-width: 100vw !important;
    overflow-x: hidden !important;
  }

  .app,
  .app.sidebar-is-collapsed,
  body.mobile-landscape-sidebar .app,
  body.mobile-landscape-sidebar .app.sidebar-is-collapsed {
    grid-template-columns: minmax(0, 1fr) !important;
    width: 100vw !important;
    max-width: 100vw !important;
    overflow-x: hidden !important;
  }

  .sidebar,
  .sidebar.is-collapsed,
  body.mobile-landscape-sidebar .sidebar,
  body.mobile-landscape-sidebar .sidebar.is-collapsed,
  [dir="rtl"] body.mobile-landscape-sidebar .sidebar,
  [dir="rtl"] body.mobile-landscape-sidebar .sidebar.is-collapsed {
    position: fixed !important;
    inset-block: 0 !important;
    inset-inline-end: 0 !important;
    inset-inline-start: auto !important;
    width: min(86vw, 318px) !important;
    min-width: min(86vw, 318px) !important;
    max-width: min(86vw, 318px) !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
    padding: 14px 12px !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    transform: translateX(105%) !important;
    transition: transform 0.09s ease, box-shadow 0.09s ease !important;
    z-index: 1200 !important;
  }

  [dir="ltr"] .sidebar,
  [dir="ltr"] .sidebar.is-collapsed,
  [dir="ltr"] body.mobile-landscape-sidebar .sidebar,
  [dir="ltr"] body.mobile-landscape-sidebar .sidebar.is-collapsed {
    inset-inline-start: 0 !important;
    inset-inline-end: auto !important;
    transform: translateX(-105%) !important;
  }

  .mobile-nav-open .sidebar,
  .mobile-nav-open .sidebar.is-collapsed,
  body.mobile-landscape-sidebar.mobile-nav-open .sidebar,
  body.mobile-landscape-sidebar.mobile-nav-open .sidebar.is-collapsed,
  [dir="rtl"] body.mobile-landscape-sidebar.mobile-nav-open .sidebar,
  [dir="rtl"] body.mobile-landscape-sidebar.mobile-nav-open .sidebar.is-collapsed,
  [dir="ltr"] .mobile-nav-open .sidebar,
  [dir="ltr"] .mobile-nav-open .sidebar.is-collapsed,
  [dir="ltr"] body.mobile-landscape-sidebar.mobile-nav-open .sidebar,
  [dir="ltr"] body.mobile-landscape-sidebar.mobile-nav-open .sidebar.is-collapsed {
    transform: translateX(0) !important;
    box-shadow: -14px 0 32px rgba(15, 23, 42, 0.2) !important;
  }

  [dir="ltr"] .mobile-nav-open .sidebar,
  [dir="ltr"] .mobile-nav-open .sidebar.is-collapsed,
  [dir="ltr"] body.mobile-landscape-sidebar.mobile-nav-open .sidebar,
  [dir="ltr"] body.mobile-landscape-sidebar.mobile-nav-open .sidebar.is-collapsed {
    box-shadow: 14px 0 32px rgba(15, 23, 42, 0.2) !important;
  }

  body.mobile-landscape-sidebar .main,
  .main {
    width: 100vw !important;
    max-width: 100vw !important;
    min-width: 0 !important;
    margin: 0 !important;
    overflow-x: hidden !important;
  }

  .mobile-nav-backdrop,
  body.mobile-landscape-sidebar .mobile-nav-backdrop {
    position: fixed !important;
    inset: 0 !important;
    z-index: 1190 !important;
    background: rgba(15, 23, 42, 0.24) !important;
    backdrop-filter: none !important;
  }

  body:not(.mobile-nav-open) .mobile-nav-backdrop,
  body.mobile-landscape-sidebar:not(.mobile-nav-open) .mobile-nav-backdrop {
    display: none !important;
  }

  body.mobile-landscape-sidebar .brand > div,
  body.mobile-landscape-sidebar .tenant-switcher,
  body.mobile-landscape-sidebar .erp-sidebar-search,
  body.mobile-landscape-sidebar .sidebar-search,
  body.mobile-landscape-sidebar .nav-section-title,
  body.mobile-landscape-sidebar .nav-section-count,
  body.mobile-landscape-sidebar .nav-section-arrow,
  body.mobile-landscape-sidebar .erp-sidebar-link-label,
  body.mobile-landscape-sidebar .nav-button span:nth-child(2),
  body.mobile-landscape-sidebar .erp-sidebar-badge,
  body.mobile-landscape-sidebar .erp-sidebar-favorite {
    display: initial !important;
  }

  body.mobile-landscape-sidebar .tenant-switcher,
  body.mobile-landscape-sidebar .erp-sidebar-search,
  body.mobile-landscape-sidebar .sidebar-search {
    display: block !important;
  }

  body.mobile-landscape-sidebar .brand {
    grid-template-columns: 44px minmax(0, 1fr) !important;
    justify-items: stretch !important;
  }

  body.mobile-landscape-sidebar .erp-sidebar-tools {
    grid-template-columns: minmax(0, 1fr) 40px !important;
  }

  body.mobile-landscape-sidebar .erp-sidebar-section-toggle,
  body.mobile-landscape-sidebar .nav-section-toggle {
    grid-template-columns: 36px minmax(0, 1fr) auto 18px !important;
    justify-items: stretch !important;
  }

  body.mobile-landscape-sidebar .erp-sidebar-link,
  body.mobile-landscape-sidebar .nav-button {
    grid-template-columns: 30px minmax(0, 1fr) auto 0 !important;
    justify-items: stretch !important;
  }

  body.mobile-landscape-sidebar .erp-sidebar-section.open .erp-sidebar-section-items,
  body.mobile-landscape-sidebar .nav-section.open .nav-section-items {
    grid-template-rows: 1fr !important;
  }
}

/* ABSOLUTE EOF OVERRIDE - mobile sidebar must not cover phone landscape content. */
html,
body,
#app,
.app {
  max-width: 100vw !important;
  overflow-x: hidden !important;
}

body.phone-nav .app,
body.phone-nav .app.sidebar-is-collapsed,
body.phone-landscape-nav .app,
body.phone-landscape-nav .app.sidebar-is-collapsed {
  grid-template-columns: minmax(0, 1fr) !important;
  width: 100vw !important;
  max-width: 100vw !important;
  overflow-x: hidden !important;
}

body.phone-nav .main,
body.phone-landscape-nav .main {
  width: 100vw !important;
  max-width: 100vw !important;
  min-width: 0 !important;
  margin: 0 !important;
  overflow-x: hidden !important;
}

body.phone-nav .mobile-menu-toggle,
body.phone-landscape-nav .mobile-menu-toggle {
  display: inline-grid !important;
}

body.phone-nav .sidebar,
body.phone-nav .sidebar.is-collapsed,
[dir="rtl"] body.phone-nav .sidebar,
[dir="rtl"] body.phone-nav .sidebar.is-collapsed {
  position: fixed !important;
  inset-block: 0 !important;
  inset-inline-end: 0 !important;
  inset-inline-start: auto !important;
  width: min(320px, 85vw) !important;
  min-width: min(320px, 85vw) !important;
  max-width: min(320px, 85vw) !important;
  height: 100dvh !important;
  max-height: 100dvh !important;
  padding: 14px 12px !important;
  overflow-x: hidden !important;
  overflow-y: auto !important;
  transform: translateX(105%) !important;
  transition: transform 180ms ease, box-shadow 180ms ease !important;
  z-index: 1200 !important;
}

[dir="ltr"] body.phone-nav .sidebar,
[dir="ltr"] body.phone-nav .sidebar.is-collapsed {
  inset-inline-start: 0 !important;
  inset-inline-end: auto !important;
  transform: translateX(-105%) !important;
}

body.phone-nav.mobile-nav-open .sidebar,
body.phone-nav.mobile-nav-open .sidebar.is-collapsed {
  transform: translateX(0) !important;
  box-shadow: -18px 0 36px rgba(15, 23, 42, 0.24) !important;
}

[dir="ltr"] body.phone-nav.mobile-nav-open .sidebar,
[dir="ltr"] body.phone-nav.mobile-nav-open .sidebar.is-collapsed {
  box-shadow: 18px 0 36px rgba(15, 23, 42, 0.24) !important;
}

body.phone-landscape-nav .sidebar,
body.phone-landscape-nav .sidebar.is-collapsed,
[dir="rtl"] body.phone-landscape-nav .sidebar,
[dir="rtl"] body.phone-landscape-nav .sidebar.is-collapsed {
  position: fixed !important;
  inset-block: 0 !important;
  inset-inline-end: 0 !important;
  inset-inline-start: auto !important;
  width: 72px !important;
  min-width: 72px !important;
  max-width: 72px !important;
  height: 100dvh !important;
  max-height: 100dvh !important;
  padding: 10px 8px !important;
  overflow-x: hidden !important;
  overflow-y: auto !important;
  transform: translateX(84px) !important;
  transition: transform 140ms ease !important;
  box-shadow: none !important;
  z-index: 1200 !important;
}

[dir="ltr"] body.phone-landscape-nav .sidebar,
[dir="ltr"] body.phone-landscape-nav .sidebar.is-collapsed {
  inset-inline-start: 0 !important;
  inset-inline-end: auto !important;
  transform: translateX(-84px) !important;
}

body.phone-landscape-nav.mobile-nav-open .sidebar,
body.phone-landscape-nav.mobile-nav-open .sidebar.is-collapsed,
[dir="rtl"] body.phone-landscape-nav.mobile-nav-open .sidebar,
[dir="rtl"] body.phone-landscape-nav.mobile-nav-open .sidebar.is-collapsed,
[dir="ltr"] body.phone-landscape-nav.mobile-nav-open .sidebar,
[dir="ltr"] body.phone-landscape-nav.mobile-nav-open .sidebar.is-collapsed {
  transform: translateX(0) !important;
}

body.phone-landscape-nav.mobile-nav-open .main {
  width: calc(100vw - 72px) !important;
  max-width: calc(100vw - 72px) !important;
  margin-inline-end: 72px !important;
}

[dir="ltr"] body.phone-landscape-nav.mobile-nav-open .main {
  margin-inline-start: 72px !important;
  margin-inline-end: 0 !important;
}

body.phone-landscape-nav .brand > div,
body.phone-landscape-nav .tenant-switcher,
body.phone-landscape-nav .erp-sidebar-search,
body.phone-landscape-nav .sidebar-search,
body.phone-landscape-nav .nav-section-title,
body.phone-landscape-nav .nav-section-count,
body.phone-landscape-nav .nav-section-arrow,
body.phone-landscape-nav .erp-sidebar-link-label,
body.phone-landscape-nav .nav-button span:nth-child(2),
body.phone-landscape-nav .erp-sidebar-badge,
body.phone-landscape-nav .erp-sidebar-favorite,
body.phone-landscape-nav .mobile-menu-close {
  display: none !important;
}

body.phone-landscape-nav .brand,
body.phone-landscape-nav .erp-sidebar-section-toggle,
body.phone-landscape-nav .nav-section-toggle,
body.phone-landscape-nav .erp-sidebar-link,
body.phone-landscape-nav .nav-button {
  grid-template-columns: 1fr !important;
  justify-items: center !important;
  min-height: 44px !important;
  padding-inline: 0 !important;
}

body.phone-landscape-nav .erp-sidebar-tools {
  display: none !important;
}

body.phone-landscape-nav .mobile-nav-backdrop,
body.phone-landscape-nav.mobile-nav-open .mobile-nav-backdrop,
body.desktop-nav .mobile-nav-backdrop {
  display: none !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

body.phone-nav .mobile-nav-backdrop {
  position: fixed !important;
  inset: 0 !important;
  display: block !important;
  opacity: 0 !important;
  pointer-events: none !important;
  z-index: 1190 !important;
  background: rgba(15, 23, 42, 0.34) !important;
  backdrop-filter: none !important;
  transition: opacity 180ms ease !important;
}

body.phone-nav.mobile-nav-open .mobile-nav-backdrop {
  opacity: 1 !important;
  pointer-events: auto !important;
}

/* MOBILE SIDEBAR FINAL FIX - EOF: closed drawer is fully hidden, no right rail. */
html,
body,
#app,
#root,
.app {
  width: 100% !important;
  max-width: 100% !important;
  overflow-x: hidden !important;
}

body.phone-nav .app,
body.phone-nav .app.sidebar-is-collapsed,
body.phone-landscape-nav .app,
body.phone-landscape-nav .app.sidebar-is-collapsed {
  grid-template-columns: minmax(0, 1fr) !important;
  width: 100vw !important;
  max-width: 100vw !important;
  overflow-x: hidden !important;
}

body.phone-nav .main,
body.phone-landscape-nav .main,
body.phone-landscape-nav.mobile-nav-open .main,
[dir="ltr"] body.phone-landscape-nav.mobile-nav-open .main {
  width: 100vw !important;
  max-width: 100vw !important;
  min-width: 0 !important;
  margin: 0 !important;
  margin-inline-start: 0 !important;
  margin-inline-end: 0 !important;
  overflow-x: hidden !important;
}

body.phone-nav .sidebar,
body.phone-nav .sidebar.is-collapsed,
body.phone-landscape-nav .sidebar,
body.phone-landscape-nav .sidebar.is-collapsed,
[dir="rtl"] body.phone-nav .sidebar,
[dir="rtl"] body.phone-nav .sidebar.is-collapsed,
[dir="rtl"] body.phone-landscape-nav .sidebar,
[dir="rtl"] body.phone-landscape-nav .sidebar.is-collapsed {
  position: fixed !important;
  top: 0 !important;
  right: 0 !important;
  left: auto !important;
  inset-block: 0 !important;
  inset-inline-end: 0 !important;
  inset-inline-start: auto !important;
  width: 82vw !important;
  min-width: 0 !important;
  max-width: 340px !important;
  height: 100vh !important;
  height: 100dvh !important;
  max-height: 100dvh !important;
  padding: 14px 12px !important;
  overflow-x: hidden !important;
  overflow-y: auto !important;
  transform: translateX(100%) !important;
  visibility: hidden !important;
  pointer-events: none !important;
  transition: transform 110ms ease-out !important;
  z-index: 9999 !important;
  box-shadow: none !important;
}

[dir="ltr"] body.phone-nav .sidebar,
[dir="ltr"] body.phone-nav .sidebar.is-collapsed,
[dir="ltr"] body.phone-landscape-nav .sidebar,
[dir="ltr"] body.phone-landscape-nav .sidebar.is-collapsed {
  left: 0 !important;
  right: auto !important;
  inset-inline-start: 0 !important;
  inset-inline-end: auto !important;
  transform: translateX(-100%) !important;
}

body.phone-nav.mobile-nav-open .sidebar,
body.phone-nav.mobile-nav-open .sidebar.is-collapsed,
body.phone-nav .sidebar.open,
body.phone-nav .sidebar.is-collapsed.open,
body.phone-landscape-nav.mobile-nav-open .sidebar,
body.phone-landscape-nav.mobile-nav-open .sidebar.is-collapsed,
body.phone-landscape-nav .sidebar.open,
body.phone-landscape-nav .sidebar.is-collapsed.open,
[dir="rtl"] body.phone-nav.mobile-nav-open .sidebar,
[dir="rtl"] body.phone-nav.mobile-nav-open .sidebar.is-collapsed,
[dir="rtl"] body.phone-landscape-nav.mobile-nav-open .sidebar,
[dir="rtl"] body.phone-landscape-nav.mobile-nav-open .sidebar.is-collapsed,
[dir="ltr"] body.phone-nav.mobile-nav-open .sidebar,
[dir="ltr"] body.phone-nav.mobile-nav-open .sidebar.is-collapsed,
[dir="ltr"] body.phone-landscape-nav.mobile-nav-open .sidebar,
[dir="ltr"] body.phone-landscape-nav.mobile-nav-open .sidebar.is-collapsed {
  transform: translateX(0) !important;
  visibility: visible !important;
  pointer-events: auto !important;
  box-shadow: -18px 0 36px rgba(15, 23, 42, 0.24) !important;
}

[dir="ltr"] body.phone-nav.mobile-nav-open .sidebar,
[dir="ltr"] body.phone-nav.mobile-nav-open .sidebar.is-collapsed,
[dir="ltr"] body.phone-landscape-nav.mobile-nav-open .sidebar,
[dir="ltr"] body.phone-landscape-nav.mobile-nav-open .sidebar.is-collapsed {
  box-shadow: 18px 0 36px rgba(15, 23, 42, 0.24) !important;
}

body.phone-nav .sidebar:not(.open),
body.phone-nav:not(.mobile-nav-open) .sidebar,
body.phone-landscape-nav .sidebar:not(.open),
body.phone-landscape-nav:not(.mobile-nav-open) .sidebar {
  transform: translateX(100%) !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

[dir="ltr"] body.phone-nav .sidebar:not(.open),
[dir="ltr"] body.phone-nav:not(.mobile-nav-open) .sidebar,
[dir="ltr"] body.phone-landscape-nav .sidebar:not(.open),
[dir="ltr"] body.phone-landscape-nav:not(.mobile-nav-open) .sidebar {
  transform: translateX(-100%) !important;
}

body.phone-nav .mobile-nav-backdrop,
body.phone-landscape-nav .mobile-nav-backdrop {
  position: fixed !important;
  inset: 0 !important;
  z-index: 9998 !important;
  display: block !important;
  opacity: 0 !important;
  pointer-events: none !important;
  background: rgba(15, 23, 42, 0.34) !important;
  backdrop-filter: none !important;
  transition: opacity 90ms ease-out !important;
}

body.phone-nav.mobile-nav-open .mobile-nav-backdrop,
body.phone-landscape-nav.mobile-nav-open .mobile-nav-backdrop {
  opacity: 1 !important;
  pointer-events: auto !important;
}

body.phone-nav:not(.mobile-nav-open) .mobile-nav-backdrop,
body.phone-landscape-nav:not(.mobile-nav-open) .mobile-nav-backdrop {
  opacity: 0 !important;
  pointer-events: none !important;
}

body.phone-nav .mobile-menu-close,
body.phone-nav .sidebar-close,
body.phone-nav .sidebar-arrow,
body.phone-nav .floating-sidebar-handle,
body.phone-landscape-nav .mobile-menu-close,
body.phone-landscape-nav .sidebar-close,
body.phone-landscape-nav .sidebar-arrow,
body.phone-landscape-nav .floating-sidebar-handle {
  display: none !important;
}

body.phone-nav.mobile-nav-open .mobile-menu-close,
body.phone-nav.mobile-nav-open .sidebar-close,
body.phone-nav.mobile-nav-open .sidebar-arrow,
body.phone-nav.mobile-nav-open .floating-sidebar-handle,
body.phone-landscape-nav.mobile-nav-open .mobile-menu-close,
body.phone-landscape-nav.mobile-nav-open .sidebar-close,
body.phone-landscape-nav.mobile-nav-open .sidebar-arrow,
body.phone-landscape-nav.mobile-nav-open .floating-sidebar-handle,
body.phone-nav .sidebar.open .mobile-menu-close,
body.phone-landscape-nav .sidebar.open .mobile-menu-close {
  display: flex !important;
}

/* Draggable AI assistant floating button */
.assistant-widget {
  position: fixed !important;
  inset: 0 auto auto 0 !important;
  width: max-content !important;
  height: max-content !important;
  max-width: none !important;
  z-index: 12010 !important;
  transform: translate3d(var(--assistant-fab-x, calc(100vw - 96px)), var(--assistant-fab-y, calc(100vh - 96px)), 0) !important;
  pointer-events: none !important;
  will-change: transform;
}

.assistant-widget .assistant-fab {
  position: relative !important;
  inset: auto !important;
  width: 62px !important;
  height: 62px !important;
  pointer-events: auto !important;
  touch-action: none !important;
  user-select: none !important;
  -webkit-user-select: none !important;
  -webkit-tap-highlight-color: transparent !important;
  cursor: grab !important;
  will-change: transform;
}

.assistant-widget .assistant-fab:active,
.assistant-widget.is-dragging .assistant-fab {
  cursor: grabbing !important;
  transform: scale(1.045) !important;
  box-shadow: 0 24px 58px rgba(37, 99, 235, 0.42) !important;
}

body.assistant-fab-dragging {
  cursor: grabbing;
  overscroll-behavior: none;
}

.assistant-widget .assistant-panel {
  pointer-events: auto !important;
  inset: auto !important;
  bottom: 76px !important;
  right: auto !important;
  left: 0 !important;
}

.assistant-widget.open-left .assistant-panel {
  left: auto !important;
  right: 0 !important;
}

.assistant-widget:not(.open-up) .assistant-panel {
  top: 76px !important;
  bottom: auto !important;
}

.assistant-widget.open-up .assistant-panel {
  top: auto !important;
  bottom: 76px !important;
}

@media (max-width: 768px), (pointer: coarse) and (max-width: 980px) {
  .assistant-widget:not(.is-open) {
    position: fixed !important;
    inset: 0 auto auto 0 !important;
    width: max-content !important;
    max-width: none !important;
    transform: translate3d(var(--assistant-fab-x, calc(100vw - 84px)), var(--assistant-fab-y, calc(100dvh - 84px)), 0) !important;
    pointer-events: none !important;
    z-index: 12010 !important;
  }

  .assistant-widget:not(.is-open) .assistant-fab {
    display: grid !important;
    position: relative !important;
    inset: auto !important;
    width: 56px !important;
    height: 56px !important;
    pointer-events: auto !important;
  }

  .assistant-widget.is-open {
    position: fixed !important;
    inset: 0 !important;
    width: 100vw !important;
    height: 100dvh !important;
    max-width: 100vw !important;
    transform: none !important;
    pointer-events: none !important;
    z-index: 13000 !important;
  }

  .assistant-widget.is-open .assistant-panel {
    position: fixed !important;
    inset: auto 0 0 0 !important;
    width: 100vw !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
    pointer-events: auto !important;
  }
}

/* GEMINI ASSISTANT MOBILE LAYOUT FIX - EOF */
.assistant-widget,
.assistant-widget * {
  box-sizing: border-box !important;
}

.assistant-panel {
  display: none;
  overflow: hidden !important;
}

.assistant-widget.is-open .assistant-panel {
  display: flex !important;
  flex-direction: column !important;
}

.assistant-panel header {
  flex-shrink: 0 !important;
}

.assistant-toolbar {
  flex-shrink: 0 !important;
}

.assistant-messages {
  flex: 1 1 auto !important;
  min-height: 0 !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  -webkit-overflow-scrolling: touch !important;
}

.assistant-suggestions,
.assistant-attachment,
.assistant-composer {
  flex-shrink: 0 !important;
}

.assistant-composer {
  position: sticky !important;
  bottom: 0 !important;
  z-index: 20 !important;
  background: #fff !important;
}

@media (max-width: 768px), (pointer: coarse) and (max-width: 980px) {
  html,
  body,
  #app,
  #root {
    overflow-x: hidden !important;
  }

  .assistant-widget {
    position: fixed !important;
    inset: auto 0 0 0 !important;
    width: 100vw !important;
    max-width: 100vw !important;
    z-index: 13000 !important;
    pointer-events: none !important;
  }

  .assistant-widget .assistant-fab {
    pointer-events: auto !important;
    position: fixed !important;
    inset-inline-end: 16px !important;
    bottom: calc(16px + env(safe-area-inset-bottom)) !important;
    width: 56px !important;
    height: 56px !important;
  }

  .assistant-widget.is-open .assistant-fab {
    display: none !important;
  }

  .assistant-panel {
    position: fixed !important;
    inset: auto 0 0 0 !important;
    width: 100vw !important;
    max-width: 100vw !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
    min-height: 0 !important;
    border-radius: 18px 18px 0 0 !important;
    border-inline: 0 !important;
    border-bottom: 0 !important;
    overflow: hidden !important;
    pointer-events: auto !important;
    background: #fff !important;
  }

  .assistant-widget.is-open .assistant-panel {
    display: flex !important;
    flex-direction: column !important;
    animation: none !important;
  }

  .assistant-panel header {
    min-height: 58px !important;
    padding: 10px 12px !important;
    gap: 8px !important;
    flex-shrink: 0 !important;
  }

  .assistant-panel header strong {
    font-size: 0.98rem !important;
    line-height: 1.2 !important;
  }

  .assistant-panel header small {
    font-size: 0.7rem !important;
    line-height: 1.35 !important;
    max-width: 78vw !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }

  .assistant-panel header button {
    width: 34px !important;
    height: 34px !important;
    flex: 0 0 34px !important;
  }

  .assistant-toolbar {
    min-height: 42px !important;
    max-height: 78px !important;
    padding: 6px 8px !important;
    gap: 6px !important;
    display: flex !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    flex-shrink: 0 !important;
  }

  .assistant-toolbar > div {
    display: flex !important;
    flex-wrap: nowrap !important;
    gap: 5px !important;
    flex: 0 0 auto !important;
  }

  .assistant-voice-toggle {
    flex: 0 0 auto !important;
    gap: 5px !important;
    font-size: 0.72rem !important;
    white-space: nowrap !important;
  }

  .assistant-voice-toggle input {
    width: 15px !important;
    height: 15px !important;
  }

  .assistant-toolbar button,
  .assistant-suggestions button,
  .ai-message-actions button {
    min-height: 30px !important;
    padding: 5px 8px !important;
    font-size: 0.72rem !important;
    border-radius: 9px !important;
    white-space: nowrap !important;
  }

  .assistant-messages {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    padding: 10px !important;
  }

  .assistant-messages .ai-message {
    max-width: 96% !important;
    margin-bottom: 9px !important;
  }

  .assistant-messages .ai-message > div:first-child {
    padding: 9px 10px !important;
    line-height: 1.65 !important;
    font-size: 0.9rem !important;
  }

  .assistant-suggestions {
    max-height: 42px !important;
    padding: 6px 8px !important;
    gap: 6px !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    flex-shrink: 0 !important;
  }

  .assistant-attachment {
    margin: 0 8px 6px !important;
    padding: 6px 8px !important;
    min-height: 34px !important;
    flex-shrink: 0 !important;
  }

  .assistant-composer {
    position: sticky !important;
    bottom: 0 !important;
    z-index: 20 !important;
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) auto !important;
    align-items: end !important;
    gap: 8px !important;
    padding: 8px 10px calc(12px + env(safe-area-inset-bottom)) !important;
    border-top: 1px solid #e2e8f0 !important;
    background: #fff !important;
    flex-shrink: 0 !important;
  }

  .assistant-composer textarea {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    min-height: 46px !important;
    max-height: 110px !important;
    resize: none !important;
    padding: 10px 11px !important;
    font-size: 16px !important;
    line-height: 1.35 !important;
    border-radius: 12px !important;
  }

  .assistant-composer > div {
    display: flex !important;
    align-items: center !important;
    justify-content: flex-end !important;
    gap: 6px !important;
    margin: 0 !important;
    min-width: max-content !important;
  }

  .assistant-file-button,
  .assistant-composer .icon-button {
    width: 38px !important;
    height: 38px !important;
    min-width: 38px !important;
    flex: 0 0 38px !important;
    border-radius: 10px !important;
  }

  .assistant-composer .primary {
    width: auto !important;
    min-width: 68px !important;
    height: 40px !important;
    min-height: 40px !important;
    padding-inline: 12px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    color: #fff !important;
    background: #2563eb !important;
    border-radius: 11px !important;
    font-size: 14px !important;
    font-weight: 900 !important;
    white-space: nowrap !important;
    opacity: 1 !important;
    visibility: visible !important;
  }
}

/* THEME SYSTEM - CSS VARIABLES AND GLOBAL APPLICATION */
:root,
body[data-theme="light"] {
  color-scheme: light;
  --bg-main: #f8fafc;
  --bg-card: #ffffff;
  --text-main: #0f172a;
  --text-primary: #0f172a;
  --text-secondary: #334155;
  --text-muted: #64748b;
  --text-inverse: #ffffff;
  --text-on-glass: #0f172a;
  --surface: #ffffff;
  --surface-glass: rgba(255, 255, 255, 0.72);
  --border-color: #e2e8f0;
  --primary-blue: #2563eb;
  --primary: #2563eb;
  --secondary: #10b981;
  --border: #e2e8f0;
  --shadow: 0 18px 42px rgba(15, 23, 42, 0.08);
  --sidebar-bg: #0b1f3a;
  --header-bg: #ffffff;
  --input-bg: #ffffff;
}

body[data-theme="dark"] {
  color-scheme: dark;
  --bg-main: #020617;
  --bg-card: #0f172a;
  --text-main: #f8fafc;
  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --text-inverse: #0f172a;
  --text-on-glass: #f8fafc;
  --surface: #0f172a;
  --surface-glass: rgba(15, 23, 42, 0.82);
  --border-color: rgba(148, 163, 184, 0.28);
  --primary-blue: #60a5fa;
  --primary: #60a5fa;
  --secondary: #34d399;
  --border: rgba(148, 163, 184, 0.28);
  --shadow: 0 20px 48px rgba(0, 0, 0, 0.36);
  --sidebar-bg: #020617;
  --header-bg: #0f172a;
  --input-bg: #111827;
}

body[data-theme="modern"] {
  --bg-main: #eef6ff;
  --bg-card: #ffffff;
  --text-main: #10233f;
  --text-primary: #10233f;
  --text-secondary: #334155;
  --text-muted: #55708f;
  --text-inverse: #ffffff;
  --text-on-glass: #0f172a;
  --surface: #ffffff;
  --surface-glass: rgba(255, 255, 255, 0.76);
  --border-color: #cfe1ff;
  --primary-blue: #0b63f6;
  --primary: #0b63f6;
  --secondary: #14b8a6;
  --border: #cfe1ff;
  --shadow: 0 20px 48px rgba(37, 99, 235, 0.13);
  --sidebar-bg: #082f66;
  --header-bg: #ffffff;
  --input-bg: #ffffff;
}

body[data-theme="executive"] {
  --bg-main: linear-gradient(180deg, #f6f9ff 0%, #eef4ff 48%, #f8fafc 100%);
  --bg-card: #ffffff;
  --text-main: #0f172a;
  --text-primary: #0f172a;
  --text-secondary: #243b5a;
  --text-muted: #64748b;
  --text-inverse: #ffffff;
  --text-on-glass: #0f172a;
  --surface: #ffffff;
  --surface-glass: rgba(255, 255, 255, 0.84);
  --border-color: #d8e4f7;
  --primary-blue: #155eef;
  --primary: #155eef;
  --secondary: #0891b2;
  --border: #d8e4f7;
  --shadow: 0 16px 36px rgba(15, 47, 85, 0.09);
  --sidebar-bg: #071f3f;
  --header-bg: rgba(255, 255, 255, 0.94);
  --input-bg: #ffffff;
}

body[data-theme="glass"] {
  --bg-main: radial-gradient(circle at 18% 0%, rgba(20, 184, 166, 0.38), transparent 28%), linear-gradient(135deg, #061826 0%, #0b2f55 48%, #0f766e 100%);
  --bg-card: rgba(255, 255, 255, 0.72);
  --text-main: #0f172a;
  --text-primary: #0f172a;
  --text-secondary: #334155;
  --text-muted: #475569;
  --text-inverse: #ffffff;
  --text-on-glass: #0f172a;
  --surface: #ffffff;
  --surface-glass: rgba(255, 255, 255, 0.72);
  --border-color: rgba(255, 255, 255, 0.35);
  --primary-blue: #2563eb;
  --primary: #2563eb;
  --secondary: #34d399;
  --border: rgba(255, 255, 255, 0.35);
  --shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
  --sidebar-bg: rgba(2, 20, 38, 0.82);
  --header-bg: rgba(255, 255, 255, 0.72);
  --input-bg: rgba(255, 255, 255, 0.88);
}

body[data-theme] {
  background: var(--bg-main) !important;
  color: var(--text-main) !important;
}

body[data-theme] .main,
body[data-theme] .login-screen,
body[data-theme] .public-auth-screen {
  background: var(--bg-main) !important;
  color: var(--text-main) !important;
}

body[data-theme] .panel,
body[data-theme] .card,
body[data-theme] .metric-card,
body[data-theme] .provider-card,
body[data-theme] .stat-card,
body[data-theme] .modal-card,
body[data-theme] .assistant-panel,
body[data-theme] .chat-panel,
body[data-theme] .topbar,
body[data-theme] .table-wrap,
body[data-theme] .data-table-wrapper {
  background: var(--bg-card) !important;
  color: var(--text-main) !important;
  border-color: var(--border) !important;
  box-shadow: var(--shadow) !important;
}

body[data-theme="glass"] .panel,
body[data-theme="glass"] .card,
body[data-theme="glass"] .metric-card,
body[data-theme="glass"] .provider-card,
body[data-theme="glass"] .stat-card,
body[data-theme="glass"] .modal-card,
body[data-theme="glass"] .assistant-panel,
body[data-theme="glass"] .chat-panel,
body[data-theme="glass"] .topbar,
body[data-theme="glass"] .table-wrap,
body[data-theme="glass"] .data-table-wrapper {
  backdrop-filter: blur(18px) !important;
  -webkit-backdrop-filter: blur(18px) !important;
}

body[data-theme] .muted,
body[data-theme] small,
body[data-theme] .table-subtitle,
body[data-theme] .panel-head p {
  color: var(--text-muted) !important;
}

body[data-theme] h1,
body[data-theme] h2,
body[data-theme] h3,
body[data-theme] strong,
body[data-theme] th,
body[data-theme] td {
  color: var(--text-main) !important;
}

body[data-theme] .sidebar {
  background: var(--sidebar-bg) !important;
}

body[data-theme] .topbar,
body[data-theme] .assistant-panel header,
body[data-theme] .assistant-toolbar,
body[data-theme] .assistant-composer,
body[data-theme] .assistant-suggestions {
  background: var(--header-bg) !important;
  border-color: var(--border) !important;
}

body[data-theme] input,
body[data-theme] select,
body[data-theme] textarea {
  background: var(--input-bg) !important;
  color: var(--text-main) !important;
  border-color: var(--border) !important;
}

body[data-theme] button.primary,
body[data-theme] .primary,
body[data-theme] .assistant-composer .primary {
  background: var(--primary) !important;
  border-color: var(--primary) !important;
  color: #ffffff !important;
}

body[data-theme="glass"] button.primary,
body[data-theme="glass"] .primary,
body[data-theme="glass"] .assistant-composer .primary {
  box-shadow: 0 0 24px rgba(56, 189, 248, 0.28) !important;
}

body[data-theme] .badge {
  background: color-mix(in srgb, var(--primary) 14%, transparent) !important;
  color: var(--primary) !important;
  border-color: color-mix(in srgb, var(--primary) 28%, transparent) !important;
}

.theme-settings-panel .theme-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}

.theme-card {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 16px;
  background: var(--bg-card, #fff);
  box-shadow: var(--shadow, 0 12px 30px rgba(15, 23, 42, 0.08));
  color: var(--text-main, #0f172a);
}

.theme-card.active {
  outline: 2px solid var(--primary, #2563eb);
}

.theme-card.disabled {
  opacity: 0.58;
}

.theme-preview {
  height: 110px;
  border-radius: 14px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  display: grid;
  grid-template-columns: 76px 1fr;
  grid-template-rows: 28px 1fr;
  gap: 8px;
  padding: 10px;
  overflow: hidden;
}

.theme-preview span:first-child {
  grid-row: 1 / 3;
  border-radius: 12px;
}

.theme-preview span:nth-child(2),
.theme-preview span:nth-child(3) {
  border-radius: 10px;
}

.theme-preview-light { background: #f8fafc; }
.theme-preview-light span { background: #ffffff; border: 1px solid #e2e8f0; }
.theme-preview-light span:first-child { background: #0b1f3a; }
.theme-preview-dark { background: #020617; }
.theme-preview-dark span { background: #0f172a; border: 1px solid rgba(148, 163, 184, 0.28); }
.theme-preview-dark span:first-child { background: #111827; }
.theme-preview-modern { background: linear-gradient(135deg, #eef6ff, #dff7f4); }
.theme-preview-modern span { background: #ffffff; border: 1px solid #bfdbfe; }
.theme-preview-modern span:first-child { background: #082f66; }
.theme-preview-executive { background: linear-gradient(135deg, #f6f9ff, #dbeafe); }
.theme-preview-executive span { background: #ffffff; border: 1px solid #c7d7ee; }
.theme-preview-executive span:first-child { background: #071f3f; }
.theme-preview-glass { background: linear-gradient(135deg, #061826, #0f766e); }
.theme-preview-glass span { background: rgba(255,255,255,0.13); border: 1px solid rgba(255,255,255,0.2); backdrop-filter: blur(8px); }
.theme-preview-glass span:first-child { background: rgba(2,20,38,0.72); }

.theme-title-row,
.theme-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.theme-title-row h3 {
  margin: 0;
}

.theme-card-body p {
  margin: 6px 0 0;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  color: var(--text-muted, #64748b);
}

.theme-toggle input {
  width: 18px;
  height: 18px;
  accent-color: var(--primary, #2563eb);
}

@media (max-width: 640px) {
  .theme-settings-panel .theme-card-grid {
    grid-template-columns: 1fr;
  }

  .theme-actions button {
    width: 100%;
  }
}

/* GLASS MODE CONTRAST FIX - readable text on white/light surfaces */
body[data-theme="glass"] {
  --glass-dark-text: #0f172a;
  --glass-dark-muted: #475569;
  --glass-light-text: #f8fafc;
  --glass-light-muted: rgba(226, 232, 240, 0.88);
  --glass-light-surface: rgba(255, 255, 255, 0.94);
}

body[data-theme="glass"] .table-wrap,
body[data-theme="glass"] .data-table-wrapper,
body[data-theme="glass"] table,
body[data-theme="glass"] tbody,
body[data-theme="glass"] tr,
body[data-theme="glass"] td,
body[data-theme="glass"] th,
body[data-theme="glass"] .form-grid,
body[data-theme="glass"] .field,
body[data-theme="glass"] .theme-card,
body[data-theme="glass"] .subscription-grid article,
body[data-theme="glass"] .firebase-status-grid article,
body[data-theme="glass"] .security-actions,
body[data-theme="glass"] .sensitive-log,
body[data-theme="glass"] .assistant-messages .ai-message > div:first-child,
body[data-theme="glass"] .assistant-messages .ai-empty,
body[data-theme="glass"] .assistant-composer,
body[data-theme="glass"] .assistant-suggestions,
body[data-theme="glass"] .assistant-toolbar,
body[data-theme="glass"] .chat-thread,
body[data-theme="glass"] .chat-composer {
  background: var(--glass-light-surface) !important;
  color: var(--glass-dark-text) !important;
  border-color: rgba(15, 23, 42, 0.12) !important;
}

body[data-theme="glass"] table *,
body[data-theme="glass"] .table-wrap *,
body[data-theme="glass"] .data-table-wrapper *,
body[data-theme="glass"] .form-grid *,
body[data-theme="glass"] .field *,
body[data-theme="glass"] .theme-card *,
body[data-theme="glass"] .subscription-grid article *,
body[data-theme="glass"] .firebase-status-grid article *,
body[data-theme="glass"] .assistant-composer *,
body[data-theme="glass"] .assistant-toolbar *,
body[data-theme="glass"] .assistant-suggestions *,
body[data-theme="glass"] .chat-composer * {
  color: var(--glass-dark-text) !important;
}

body[data-theme="glass"] .muted,
body[data-theme="glass"] .table-subtitle,
body[data-theme="glass"] .field small,
body[data-theme="glass"] .field .muted,
body[data-theme="glass"] .theme-card .muted,
body[data-theme="glass"] .subscription-grid article span,
body[data-theme="glass"] .firebase-status-grid article span {
  color: var(--glass-dark-muted) !important;
}

body[data-theme="glass"] .panel > .panel-head,
body[data-theme="glass"] .topbar,
body[data-theme="glass"] .dashboard-hero,
body[data-theme="glass"] .marketplace-hero,
body[data-theme="glass"] .provider-portal-header,
body[data-theme="glass"] .assistant-panel header,
body[data-theme="glass"] .modal-head {
  background: rgba(2, 20, 38, 0.42) !important;
  color: var(--glass-light-text) !important;
  border-color: rgba(255, 255, 255, 0.18) !important;
}

body[data-theme="glass"] .panel > .panel-head *,
body[data-theme="glass"] .topbar *,
body[data-theme="glass"] .dashboard-hero *,
body[data-theme="glass"] .marketplace-hero *,
body[data-theme="glass"] .provider-portal-header *,
body[data-theme="glass"] .assistant-panel header *,
body[data-theme="glass"] .modal-head * {
  color: var(--glass-light-text) !important;
}

body[data-theme="glass"] .panel > .panel-head .muted,
body[data-theme="glass"] .topbar .muted,
body[data-theme="glass"] .dashboard-hero .muted,
body[data-theme="glass"] .assistant-panel header small {
  color: var(--glass-light-muted) !important;
}

body[data-theme="glass"] input,
body[data-theme="glass"] select,
body[data-theme="glass"] textarea {
  background: rgba(255, 255, 255, 0.96) !important;
  color: var(--glass-dark-text) !important;
  border-color: rgba(15, 23, 42, 0.16) !important;
}

body[data-theme="glass"] input::placeholder,
body[data-theme="glass"] textarea::placeholder {
  color: #64748b !important;
}

body[data-theme="glass"] button:not(.primary):not(.danger):not(.tools-menu-toggle):not(.assistant-fab),
body[data-theme="glass"] .button-link {
  background: rgba(255, 255, 255, 0.92) !important;
  color: #1e40af !important;
  border-color: rgba(37, 99, 235, 0.24) !important;
}

body[data-theme="glass"] .badge,
body[data-theme="glass"] .status-badge {
  background: rgba(255, 255, 255, 0.92) !important;
  color: #1e40af !important;
  border-color: rgba(37, 99, 235, 0.24) !important;
}

body[data-theme="glass"] .assistant-messages .ai-message.is-user > div:first-child,
body[data-theme="glass"] button.primary,
body[data-theme="glass"] .primary,
body[data-theme="glass"] .assistant-composer .primary {
  background: #2563eb !important;
  color: #ffffff !important;
  border-color: #2563eb !important;
}

body[data-theme="glass"] .sidebar,
body[data-theme="glass"] .sidebar * {
  color: #e8f1ff !important;
}

body[data-theme="glass"] .sidebar .erp-sidebar-link.active,
body[data-theme="glass"] .sidebar .nav-button.active,
body[data-theme="glass"] .sidebar .erp-sidebar-link.active *,
body[data-theme="glass"] .sidebar .nav-button.active * {
  color: #1d4ed8 !important;
}

/* THEME READABILITY HARDENING - keep text readable in every mode */
body[data-theme] {
  --text: var(--text-primary);
  --muted: var(--text-muted);
  --line: var(--border-color);
  --surface-2: color-mix(in srgb, var(--surface) 86%, var(--primary-blue) 14%);
  color: var(--text-primary) !important;
}

body[data-theme] :is(p, span, label, button, input, textarea, select, h1, h2, h3, h4, h5, h6, a, li, td, th, strong, small, summary) {
  opacity: 1 !important;
}

body[data-theme] :is(h1, h2, h3, h4, h5, h6, strong, th, .metric-card strong, .stat-card strong, .kpi-card strong, .panel-head h2, .panel-head h3) {
  color: var(--text-primary) !important;
}

body[data-theme] :is(p, span, label, li, td, button, a) {
  color: var(--text-secondary) !important;
}

body[data-theme] :is(.muted, small, .table-subtitle, .card-subtitle, .helper-text, .panel-head p) {
  color: var(--text-muted) !important;
}

body[data-theme] :is(input, textarea, select) {
  color: var(--text-primary) !important;
  background: var(--input-bg) !important;
  border-color: var(--border-color) !important;
  caret-color: var(--primary-blue) !important;
}

body[data-theme] :is(input, textarea)::placeholder {
  color: var(--text-muted) !important;
  opacity: 1 !important;
}

body[data-theme] :is(button, .button-link) {
  color: var(--text-secondary) !important;
}

body[data-theme] :is(button:disabled, .disabled, [aria-disabled="true"]) {
  opacity: 1 !important;
  color: var(--text-muted) !important;
  background: color-mix(in srgb, var(--surface) 82%, var(--border-color) 18%) !important;
}

body[data-theme] :is(button.primary, .primary, .btn-primary, .assistant-composer .primary) {
  color: #ffffff !important;
  background: var(--primary-blue) !important;
  border-color: var(--primary-blue) !important;
}

body[data-theme] :is(button.danger, .danger) {
  color: #ffffff !important;
}

body[data-theme] :is(.panel, .card, .metric-card, .provider-card, .stat-card, .modal-card, .assistant-panel, .chat-panel, .topbar, .table-wrap, .data-table-wrapper, .dropdown, .tools-menu-panel) {
  color: var(--text-primary) !important;
}

body[data-theme] :is(.panel, .card, .metric-card, .provider-card, .stat-card, .modal-card, .assistant-panel, .chat-panel, .table-wrap, .data-table-wrapper, .dropdown, .tools-menu-panel) :is(p, span, label, button, a, td, th, li) {
  color: var(--text-secondary) !important;
}

body[data-theme] :is(.panel, .card, .metric-card, .provider-card, .stat-card, .modal-card, .assistant-panel, .chat-panel, .table-wrap, .data-table-wrapper, .dropdown, .tools-menu-panel) :is(h1, h2, h3, h4, h5, h6, strong) {
  color: var(--text-primary) !important;
}

body[data-theme] .sidebar :is(p, span, label, button, a, strong, small) {
  color: rgba(248, 250, 252, 0.92) !important;
}

body[data-theme] .sidebar :is(.erp-sidebar-link.active, .nav-button.active, [aria-current="page"]),
body[data-theme] .sidebar :is(.erp-sidebar-link.active, .nav-button.active, [aria-current="page"]) * {
  color: #1d4ed8 !important;
}

body[data-theme="glass"] :is(.panel, .card, .metric-card, .provider-card, .stat-card, .modal-card, .assistant-panel, .chat-panel, .topbar, .table-wrap, .data-table-wrapper, .dropdown, .tools-menu-panel) {
  background: rgba(255, 255, 255, 0.72) !important;
  color: var(--text-on-glass) !important;
  border: 1px solid rgba(255, 255, 255, 0.35) !important;
  backdrop-filter: blur(18px) !important;
  -webkit-backdrop-filter: blur(18px) !important;
}

body[data-theme="glass"] :is(.panel, .card, .metric-card, .provider-card, .stat-card, .modal-card, .assistant-panel, .chat-panel, .topbar, .table-wrap, .data-table-wrapper, .dropdown, .tools-menu-panel) :is(p, span, label, button, a, td, th, li) {
  color: var(--text-secondary) !important;
}

body[data-theme="glass"] :is(.panel, .card, .metric-card, .provider-card, .stat-card, .modal-card, .assistant-panel, .chat-panel, .topbar, .table-wrap, .data-table-wrapper, .dropdown, .tools-menu-panel) :is(h1, h2, h3, h4, h5, h6, strong) {
  color: var(--text-primary) !important;
}

body[data-theme="glass"] :is(.muted, small, .table-subtitle, .panel-head p) {
  color: var(--text-muted) !important;
}

body[data-theme="glass"] :is(input, textarea, select) {
  background: rgba(255, 255, 255, 0.92) !important;
  color: #0f172a !important;
  border-color: rgba(15, 23, 42, 0.18) !important;
}

body[data-theme="glass"] :is(input, textarea)::placeholder {
  color: #475569 !important;
  opacity: 1 !important;
}

body[data-theme="glass"] :is(button:not(.primary):not(.danger):not(.tools-menu-toggle):not(.assistant-fab), .button-link) {
  background: rgba(255, 255, 255, 0.88) !important;
  color: #1e40af !important;
  border-color: rgba(37, 99, 235, 0.28) !important;
}

body[data-theme="glass"] :is(button.primary, .primary, .assistant-composer .primary) {
  background: #2563eb !important;
  color: #ffffff !important;
  border-color: #2563eb !important;
}

body[data-theme="glass"] .sidebar,
body[data-theme="glass"] .sidebar * {
  color: #e8f1ff !important;
}

/* Modern settings/tools gear: icon only, no surrounding circle. */
.tools-menu-toggle,
button#tools-menu-toggle {
  width: 38px !important;
  height: 38px !important;
  min-width: 38px !important;
  min-height: 38px !important;
  padding: 0 !important;
  display: inline-grid !important;
  place-items: center !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  color: #2563eb !important;
  font-size: 0 !important;
  line-height: 1 !important;
  transition:
    transform 0.2s ease,
    opacity 0.2s ease,
    color 0.2s ease,
    background-color 0.2s ease,
    box-shadow 0.2s ease,
    border-color 0.2s ease !important;
}

.tools-menu-toggle::before,
button#tools-menu-toggle::before {
  content: "\2699";
  color: #2563eb !important;
  font-size: 26px !important;
  line-height: 1 !important;
  display: block;
}

.tools-menu-toggle:hover,
.tools-menu.is-open .tools-menu-toggle,
button#tools-menu-toggle:hover {
  transform: rotate(15deg) scale(1.08) !important;
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
  color: #2563eb !important;
}

.tools-menu-toggle:active,
button#tools-menu-toggle:active {
  transform: scale(0.95) !important;
  background: transparent !important;
  box-shadow: none !important;
}

body[data-theme] :is(.panel, .card, .modal-card, .assistant-panel, .chat-panel, .topbar) :is(button.primary, .primary, .btn-primary),
body[data-theme] :is(button.primary, .primary, .btn-primary) * {
  color: #ffffff !important;
}

body[data-theme] :is(.dashboard-hero, .dashboard-premium-hero, .marketplace-hero, .provider-portal-header, .landing-hero) :is(h1, h2, h3, p, span, strong, small) {
  color: #ffffff !important;
}

body[data-theme] :is(.dashboard-hero, .dashboard-premium-hero, .marketplace-hero, .provider-portal-header, .landing-hero) .muted {
  color: rgba(255, 255, 255, 0.82) !important;
}

/* Appearance customization */
html,
body,
#app,
#root,
.app {
  font-family: var(--font-family, "Cairo", "Tajawal", system-ui, sans-serif) !important;
  font-size: var(--font-size, 16px);
  font-weight: var(--font-weight, 600);
  letter-spacing: var(--letter-spacing, 0px);
  line-height: var(--line-height, 1.65);
}

.app {
  filter: contrast(var(--contrast, 1)) brightness(var(--brightness, 1)) saturate(var(--saturation, 1));
}

body[data-theme] .app :is(p, span, label, input, textarea, select, h1, h2, h3, h4, h5, h6, a, li, td, th, small, strong):not(.primary):not(.danger):not(.badge):not(.conversation-avatar) {
  font-family: var(--font-family, "Cairo", "Tajawal", system-ui, sans-serif) !important;
  letter-spacing: var(--letter-spacing, 0px);
  line-height: var(--line-height, 1.65);
}

body[data-theme] .app :is(p, label, input, textarea, select, li, td, th):not(.primary):not(.danger) {
  color: var(--font-color, var(--text-secondary)) !important;
}

body[data-theme] .app :is(h1, h2, h3, h4, h5, h6, strong):not(.primary):not(.danger) {
  color: var(--font-color, var(--text-primary)) !important;
}

.appearance-customization-panel details {
  display: grid;
  gap: 16px;
}

.appearance-customization-panel summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  cursor: pointer;
  list-style: none;
}

.appearance-customization-panel summary::-webkit-details-marker {
  display: none;
}

.appearance-customization-panel summary h2 {
  margin: 0;
}

.appearance-customization-panel summary > span {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 4px 10px;
  border-radius: 999px;
  background: #eff6ff;
  color: #2563eb;
  font-weight: 900;
}

.appearance-customization-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(280px, 0.75fr);
  gap: 16px;
  align-items: start;
  margin-top: 14px;
}

.appearance-controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.appearance-controls article {
  display: grid;
  gap: 8px;
  min-height: 94px;
  padding: 14px;
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: 14px;
  background: var(--surface, #fff);
}

.appearance-controls label {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-weight: 900;
  color: var(--text-primary, #0f172a);
}

.appearance-controls output {
  color: #2563eb;
  font-weight: 900;
}

.appearance-controls input[type="range"] {
  width: 100%;
  accent-color: #2563eb;
}

.appearance-controls select,
.appearance-controls input[type="text"],
.appearance-controls input[type="color"] {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: 10px;
  background: var(--input-bg, #fff);
  color: var(--text-primary, #0f172a);
  padding: 8px 10px;
}

.appearance-controls input[type="color"] {
  padding: 4px;
}

.appearance-color-row {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  gap: 8px;
}

.appearance-actions {
  grid-column: 1 / -1;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.appearance-preview {
  position: sticky;
  top: 18px;
  display: grid;
  gap: 12px;
  padding: 18px;
  border: 1px solid rgba(37, 99, 235, 0.16);
  border-radius: 18px;
  background:
    linear-gradient(135deg, rgba(37, 99, 235, 0.08), rgba(16, 185, 129, 0.08)),
    #ffffff;
  box-shadow: 0 16px 36px rgba(15, 23, 42, 0.08);
}

.appearance-preview > span {
  width: max-content;
  padding: 5px 10px;
  border-radius: 999px;
  background: #eff6ff;
  color: #2563eb !important;
  font-weight: 900;
}

.appearance-preview h3,
.appearance-preview p {
  margin: 0;
}

body[data-theme="glass"] .appearance-controls article,
body[data-theme="glass"] .appearance-preview {
  background: rgba(255, 255, 255, 0.78) !important;
  border-color: rgba(255, 255, 255, 0.35) !important;
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

@media (max-width: 980px) {
  .appearance-customization-grid {
    grid-template-columns: 1fr;
  }
  .appearance-preview {
    position: static;
  }
}

@media (max-width: 640px) {
  .appearance-controls {
    grid-template-columns: 1fr;
  }
  .appearance-customization-panel summary {
    align-items: flex-start;
    flex-direction: column;
  }
  .appearance-actions button {
    width: 100%;
  }
}
/* Cloudinary upload progress */
.cloudinary-upload-status {
  position: fixed;
  inset-inline-start: 18px;
  bottom: calc(18px + env(safe-area-inset-bottom, 0px));
  z-index: 12000;
  width: min(320px, calc(100vw - 36px));
  min-height: 48px;
  padding: 12px 14px;
  border-radius: 14px;
  background: #ffffff;
  color: #0f172a;
  box-shadow: 0 16px 45px rgba(15, 23, 42, 0.18);
  border: 1px solid #dbe7ff;
  overflow: hidden;
  contain: layout paint style;
  transform: translateZ(0);
  will-change: contents;
}

.cloudinary-upload-status span {
  position: absolute;
  inset-block-end: 0;
  inset-inline-start: 0;
  height: 4px;
  width: 4%;
  background: #2563eb;
  transition: width 0.18s ease;
}

.cloudinary-upload-status strong {
  display: block;
  position: relative;
  z-index: 1;
  font-size: 0.86rem;
  line-height: 1.5;
}

.cloudinary-upload-status.is-done span {
  background: #16a34a;
}

/* Final mobile voice button fix: keep the recorder visible and touch-friendly. */
@media (max-width: 700px), (pointer: coarse) and (max-width: 980px) {
  .chat-composer {
    grid-template-columns: minmax(0, 1fr) 52px 52px !important;
    align-items: end !important;
    gap: 8px !important;
    overflow: visible !important;
  }

  .chat-composer textarea {
    grid-column: 1 / -1 !important;
    width: 100% !important;
    min-width: 0 !important;
  }

  .chat-composer .file-button {
    grid-column: 1 !important;
    min-width: 0 !important;
  }

  .chat-composer .voice-record-button,
  button.voice-record-button[data-voice-toggle] {
    grid-column: 2 !important;
    display: inline-grid !important;
    visibility: visible !important;
    opacity: 1 !important;
    pointer-events: auto !important;
    place-items: center !important;
    width: 52px !important;
    min-width: 52px !important;
    max-width: 52px !important;
    height: 52px !important;
    min-height: 52px !important;
    padding: 0 !important;
    border-radius: 16px !important;
    border: 1px solid rgba(37, 99, 235, 0.24) !important;
    background: #eff6ff !important;
    color: #2563eb !important;
    font-size: 1.35rem !important;
    line-height: 1 !important;
    z-index: 5 !important;
  }

  .chat-composer .voice-record-button.is-recording,
  button.voice-record-button[data-voice-toggle].is-recording {
    background: #fee2e2 !important;
    color: #dc2626 !important;
    border-color: rgba(220, 38, 38, 0.35) !important;
  }

  .chat-composer button.primary[type="submit"] {
    grid-column: 3 !important;
    width: 52px !important;
    min-width: 52px !important;
    height: 52px !important;
    min-height: 52px !important;
  }

  .voice-recorder-panel {
    grid-column: 1 / -1 !important;
  }
}

.startup-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #f8fafc;
  color: #0f172a;
  font-family: var(--font-family, "Cairo", "Tajawal", system-ui, sans-serif);
}

.startup-shell section {
  display: grid;
  gap: 10px;
  place-items: center;
  min-width: min(360px, 92vw);
  padding: 28px;
  border: 1px solid #e2e8f0;
  border-radius: 20px;
  background: #fff;
  box-shadow: 0 18px 45px rgba(15, 23, 42, 0.08);
}

.startup-shell strong {
  font-size: 1.25rem;
  color: #2563eb;
}

.startup-shell p {
  margin: 0;
  color: #64748b;
}

/* Canva-inspired premium SaaS redesign layer.
   Visual-only overrides: no routes, Firebase, permissions, or data logic are changed. */
:root {
  --font-family: "Cairo", "Tajawal", "IBM Plex Sans Arabic", "Noto Sans Arabic", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --bg: #f6f9ff;
  --bg-main: #f6f9ff;
  --surface: #ffffff;
  --surface-2: #f8fbff;
  --surface-soft: #eef5ff;
  --surface-glass: rgba(255, 255, 255, 0.84);
  --ink: #0f172a;
  --text-primary: #0f172a;
  --text-secondary: #334155;
  --text-muted: #64748b;
  --muted: #64748b;
  --line: #dbe7f5;
  --border-color: #dbe7f5;
  --brand: #2563eb;
  --primary-blue: #2563eb;
  --brand-2: #0f2a55;
  --accent: #06b6d4;
  --ok: #16a34a;
  --danger: #dc2626;
  --warning: #f97316;
  --shadow: 0 18px 45px rgba(15, 42, 85, 0.09);
  --shadow-soft: 0 10px 30px rgba(37, 99, 235, 0.08);
  --radius-md: 16px;
  --radius-lg: 22px;
  --transition-fast: background-color 0.18s ease, color 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

html,
body {
  font-family: var(--font-family) !important;
  color: var(--text-primary);
  background:
    radial-gradient(circle at 8% 8%, rgba(37, 99, 235, 0.10), transparent 28%),
    radial-gradient(circle at 92% 14%, rgba(6, 182, 212, 0.10), transparent 30%),
    linear-gradient(180deg, #f8fbff 0%, #eef5ff 100%) !important;
}

body,
button,
input,
textarea,
select {
  font-family: var(--font-family) !important;
}

p,
span,
label,
button,
input,
textarea,
select,
h1,
h2,
h3,
h4,
h5,
h6,
a,
td,
th,
small,
strong {
  text-rendering: optimizeLegibility;
}

.app,
.main {
  background: transparent !important;
}

.main {
  padding: clamp(14px, 2vw, 28px) !important;
}

.topbar,
.panel,
.modal-card,
.login-card,
.public-register-card,
.marketplace-card,
.marketplace-profile-card,
.sound-card,
.firebase-status,
.attendance-month-stats article,
.month-card,
.document-view-modal .modal-card {
  background: var(--surface-glass) !important;
  border: 1px solid rgba(219, 231, 245, 0.88) !important;
  box-shadow: var(--shadow-soft) !important;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.topbar {
  border-radius: var(--radius-lg) !important;
  min-height: 74px;
}

.hero,
.dashboard-hero,
.welcome-banner,
.landing-hero,
.dashboard-banner {
  background:
    linear-gradient(135deg, rgba(15, 42, 85, 0.94), rgba(37, 99, 235, 0.88)),
    url("data:image/svg+xml,%3Csvg width='900' height='360' viewBox='0 0 900 360' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' stroke='%23ffffff' stroke-opacity='.18' stroke-width='2'%3E%3Cpath d='M76 290h748M190 290V136l90-54 90 54v154M530 290V102h162v188M180 136h200M520 102h184M612 102v188M584 154h42M584 198h42M584 242h42'/%3E%3C/g%3E%3Ccircle cx='780' cy='70' r='86' fill='%23ffffff' fill-opacity='.08'/%3E%3Ccircle cx='122' cy='90' r='56' fill='%2306b6d4' fill-opacity='.18'/%3E%3C/svg%3E") center/cover no-repeat !important;
  color: #ffffff !important;
  border: 0 !important;
  border-radius: var(--radius-lg) !important;
  box-shadow: 0 24px 55px rgba(15, 42, 85, 0.22) !important;
}

.hero *,
.dashboard-hero *,
.welcome-banner *,
.landing-hero *,
.dashboard-banner * {
  color: #ffffff !important;
}

.metric-card,
.stat-card,
.summary-card,
.kpi-card,
.dashboard-card,
.portal-stat,
.status-card,
.join-type-card {
  position: relative;
  isolation: isolate;
  min-height: 120px;
  overflow: hidden;
  background: linear-gradient(145deg, #ffffff 0%, #f8fbff 100%) !important;
  border: 1px solid var(--border-color) !important;
  border-radius: var(--radius-lg) !important;
  box-shadow: var(--shadow-soft) !important;
  padding: 20px !important;
  color: var(--text-primary) !important;
  transition: var(--transition-fast) !important;
}

.metric-card::before,
.stat-card::before,
.summary-card::before,
.kpi-card::before,
.dashboard-card::before,
.portal-stat::before,
.status-card::before {
  content: "";
  position: absolute;
  inset-inline-end: -32px;
  inset-block-start: -36px;
  width: 112px;
  height: 112px;
  border-radius: 999px;
  background: rgba(37, 99, 235, 0.08);
  z-index: -1;
}

.metric-card:hover,
.stat-card:hover,
.summary-card:hover,
.kpi-card:hover,
.dashboard-card:hover,
.portal-stat:hover,
.join-type-card:hover {
  border-color: rgba(37, 99, 235, 0.35) !important;
  box-shadow: 0 18px 40px rgba(37, 99, 235, 0.13) !important;
}

.metric-card strong,
.stat-card strong,
.summary-card strong,
.kpi-card strong,
.dashboard-card strong,
.portal-stat strong,
.metric-card b,
.stat-card b,
.summary-card b,
.kpi-card b {
  color: var(--text-primary) !important;
  font-weight: 800 !important;
}

.metric-card small,
.stat-card small,
.summary-card small,
.kpi-card small,
.dashboard-card small,
.portal-stat small,
.muted,
.table-subtitle {
  color: var(--text-muted) !important;
}

.panel-head h2,
.panel h2,
.panel h3,
.section-title,
.page-title,
.topbar h1 {
  color: var(--text-primary) !important;
  font-weight: 800 !important;
  letter-spacing: 0 !important;
}

button,
.btn,
.primary,
.google-auth-button,
.firebase-setup-button,
.view-month-button,
.invoice-view-button {
  border-radius: 12px !important;
  transition: var(--transition-fast) !important;
  font-weight: 700 !important;
}

button.primary,
.primary,
.btn-primary {
  background: linear-gradient(135deg, #2563eb, #0b63f6) !important;
  color: #ffffff !important;
  border-color: transparent !important;
  box-shadow: 0 12px 24px rgba(37, 99, 235, 0.22) !important;
}

button.danger,
.danger,
.destructive-button {
  background: #fee2e2 !important;
  color: #991b1b !important;
  border-color: #fecaca !important;
}

input,
textarea,
select,
.sidebar-search {
  background: #ffffff !important;
  color: var(--text-primary) !important;
  border: 1px solid var(--border-color) !important;
  border-radius: 13px !important;
  box-shadow: inset 0 1px 0 rgba(15, 23, 42, 0.02);
}

input::placeholder,
textarea::placeholder,
.sidebar-search::placeholder {
  color: var(--text-muted) !important;
  opacity: 1 !important;
}

input:focus,
textarea:focus,
select:focus,
.sidebar-search:focus {
  border-color: #2563eb !important;
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12) !important;
  outline: none !important;
}

.table-wrap {
  background: var(--surface) !important;
  border: 1px solid var(--border-color) !important;
  border-radius: var(--radius-lg) !important;
  box-shadow: var(--shadow-soft) !important;
}

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

thead th {
  background: #eff6ff !important;
  color: #1e3a8a !important;
  font-weight: 800 !important;
  border-bottom: 1px solid var(--border-color) !important;
}

tbody tr {
  transition: background-color 0.16s ease !important;
}

tbody tr:hover {
  background: #f8fbff !important;
}

td,
th {
  border-color: #e7eef8 !important;
}

.status-badge,
.status-pending,
.status-approved,
.status-active,
.status-rejected,
.status-suspended {
  border-radius: 999px !important;
  font-weight: 800 !important;
}

.sidebar {
  background: linear-gradient(180deg, rgba(15, 42, 85, 0.98), rgba(8, 25, 52, 0.98)) !important;
  border-inline-end: 1px solid rgba(255, 255, 255, 0.08) !important;
  color: #eaf2ff !important;
  box-shadow: 18px 0 40px rgba(15, 42, 85, 0.12) !important;
}

[dir="rtl"] .sidebar {
  box-shadow: -18px 0 40px rgba(15, 42, 85, 0.12) !important;
}

.sidebar *,
.brand,
.brand *,
.nav-section-toggle,
.nav-section-title,
.nav-button,
.nav-button span,
.nav-badge {
  color: inherit;
}

.tenant-switcher,
.sidebar .sidebar-search,
.sidebar select {
  background: rgba(255, 255, 255, 0.10) !important;
  color: #ffffff !important;
  border-color: rgba(255, 255, 255, 0.16) !important;
}

.nav-section-toggle,
.erp-sidebar-section-toggle,
.nav-button,
.erp-sidebar-link {
  min-height: 42px !important;
  border-radius: 12px !important;
  transition: var(--transition-fast) !important;
}

.nav-section-toggle:hover,
.erp-sidebar-section-toggle:hover,
.nav-button:hover,
.erp-sidebar-link:hover {
  background: rgba(255, 255, 255, 0.10) !important;
}

.nav-button.active,
.erp-sidebar-link.active {
  background: #ffffff !important;
  color: #2563eb !important;
  border-inline-start: 4px solid #60a5fa !important;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.14) !important;
}

.sidebar-collapse-toggle,
.settings-gear,
[data-tools-toggle],
[data-settings-menu] {
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
  color: #2563eb !important;
}

.assistant-panel,
.chatbot-window,
.ai-assistant,
.assistant-shell {
  background: var(--surface) !important;
  border: 1px solid var(--border-color) !important;
  box-shadow: 0 24px 60px rgba(15, 42, 85, 0.18) !important;
  color: var(--text-primary) !important;
}

.login-screen,
.landing-page,
.pricing-page,
.public-register-page {
  background:
    radial-gradient(circle at top right, rgba(37, 99, 235, 0.16), transparent 32%),
    radial-gradient(circle at bottom left, rgba(6, 182, 212, 0.13), transparent 30%),
    linear-gradient(180deg, #f8fbff, #eef5ff) !important;
}

.login-card,
.public-register-card {
  border-radius: 28px !important;
  box-shadow: 0 28px 80px rgba(15, 42, 85, 0.14) !important;
}

@media (max-width: 900px) {
  .main {
    padding: 12px !important;
  }

  .topbar,
  .panel,
  .modal-card,
  .login-card,
  .public-register-card {
    border-radius: 18px !important;
  }

  .metric-card,
  .stat-card,
  .summary-card,
  .kpi-card,
  .dashboard-card,
  .portal-stat {
    min-height: 112px;
    padding: 16px !important;
  }

  .table-wrap {
    overflow-x: auto !important;
  }
}

html[data-theme="glass"],
body[data-theme="glass"],
.theme-glass {
  --bg: #eaf4ff;
  --surface: rgba(255, 255, 255, 0.76);
  --surface-2: rgba(255, 255, 255, 0.64);
  --surface-glass: rgba(255, 255, 255, 0.74);
  --text-primary: #0f172a;
  --text-secondary: #334155;
  --text-muted: #475569;
  --line: rgba(255, 255, 255, 0.42);
  --border-color: rgba(148, 163, 184, 0.38);
}

html[data-theme="dark"],
body[data-theme="dark"],
.theme-dark {
  --bg: #07111f;
  --bg-main: #07111f;
  --surface: #0f172a;
  --surface-2: #111c31;
  --surface-glass: rgba(15, 23, 42, 0.88);
  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --line: #1e293b;
  --border-color: #1e293b;
}

html {
  scroll-behavior: smooth;
}

body {
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Mobile Performance Mode: keep the same look, remove expensive effects on touch devices. */
@media (max-width: 768px), (hover: none) {
  *,
  *::before,
  *::after {
    transition-duration: 0.15s !important;
  }

  body {
    background-attachment: scroll !important;
  }

  .site-top {
    backdrop-filter: blur(6px) !important;
    -webkit-backdrop-filter: blur(6px) !important;
    box-shadow: 0 4px 14px rgba(0,0,0,0.25) !important;
  }

  .ux-parent {
    perspective: none !important;
    filter: none !important;
  }

  .ux-card,
  .ux-glass,
  .ux-logo,
  .ux-circle,
  .ux-content,
  .ux-bottom,
  .ux-social,
  .ux-social-btn,
  .ux-more {
    transform-style: flat !important;
  }

  .ux-parent:hover .ux-card,
  .ux-card {
    transform: none !important;
    box-shadow: 0 8px 22px rgba(0,0,0,0.22) !important;
  }

  .ux-glass {
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
  }

  .ux-circle {
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    box-shadow: none !important;
  }

  .ux-parent:hover .ux-circle:nth-child(2),
  .ux-parent:hover .ux-circle:nth-child(3),
  .ux-parent:hover .ux-circle:nth-child(4),
  .ux-parent:hover .ux-circle:nth-child(5),
  .ux-parent:hover .ux-social-btn {
    transform: none !important;
  }

  .hero-blob,
  .hero-pill,
  .hero-ring,
  .hero-hex,
  .hero-slab {
    transition: transform 0.15s ease !important;
    filter: none !important;
  }

  .hero-blob--a,
  .hero-blob--b,
  .hero-blob--c,
  .hero-hex,
  .hero-slab {
    box-shadow: 0 8px 20px rgba(0,0,0,0.22) !important;
  }

  .hero-shell {
    --hx: 0px !important;
    --hy: 0px !important;
  }

  .stage-viewport,
  .stage-card__inner,
  .stage-fab {
    box-shadow: 0 8px 22px rgba(0,0,0,0.22) !important;
  }

  .stage-fab:hover {
    transform: none !important;
  }

  button,
  a,
  .hero__btn,
  .btn-lang,
  .stage-fab,
  .ux-social-btn,
  .ux-more-btn {
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
  }

  button:active,
  a:active,
  .hero__btn:active,
  .btn-lang:active,
  .stage-fab:active,
  .ux-social-btn:active {
    transform: translateY(1px) !important;
  }

  .app,
  .sidebar,
  .topbar,
  .panel,
  .metric,
  .insight,
  .modal-card,
  .assistant-panel,
  .assistant-shell,
  .chatbot-window,
  .provider-card,
  .portal-card,
  .dashboard-construction-scene,
  .pricing-card,
  .login-card,
  .public-register-card {
    box-shadow: 0 8px 22px rgba(15, 42, 85, 0.12) !important;
    filter: none !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    transform-style: flat !important;
    perspective: none !important;
  }

  .tools-menu-panel,
  .mobile-nav-backdrop,
  .modal,
  .glass-card,
  .theme-glass .panel,
  .theme-glass .metric,
  .theme-glass .sidebar,
  .theme-glass .topbar {
    backdrop-filter: blur(4px) !important;
    -webkit-backdrop-filter: blur(4px) !important;
  }

  .metric:hover,
  .panel:hover,
  .insight:hover,
  .provider-card:hover,
  .portal-card:hover,
  .pricing-card:hover,
  .dashboard-card:hover,
  .stage-fab:hover,
  .hero__btn:hover,
  .ux-social-btn:hover {
    transform: none !important;
  }

  [style*="rotate3d"],
  [style*="perspective"],
  [style*="drop-shadow"] {
    transform: none !important;
    perspective: none !important;
    filter: none !important;
  }
}

/* Government entities directory */
.government-page {
  display: grid;
  gap: 18px;
}

.government-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  overflow: hidden;
  background:
    radial-gradient(circle at 10% 10%, rgba(37, 99, 235, 0.14), transparent 32%),
    linear-gradient(135deg, var(--surface, #fff), rgba(239, 246, 255, 0.86));
}

.government-hero h2 {
  margin: 6px 0;
  color: var(--text-primary, #0f172a);
}

.government-hero-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(90px, 1fr));
  gap: 10px;
  min-width: min(420px, 100%);
}

.government-hero-stats article,
.government-card {
  border: 1px solid var(--border-color, #e2e8f0);
  background: var(--surface, #fff);
  border-radius: 18px;
  box-shadow: 0 14px 34px rgba(15, 42, 85, 0.08);
}

.government-hero-stats article {
  padding: 14px;
  text-align: center;
}

.government-hero-stats strong {
  display: block;
  font-size: 1.7rem;
  color: var(--primary-blue, #2563eb);
}

.government-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(220px, 0.7fr);
  gap: 14px;
}

.government-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(245px, 1fr));
  gap: 14px;
}

.government-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 235px;
  padding: 18px;
  transition: box-shadow .15s ease, border-color .15s ease, background-color .15s ease;
}

.government-card:hover {
  border-color: rgba(37, 99, 235, 0.32);
  box-shadow: 0 18px 42px rgba(15, 42, 85, 0.12);
}

.government-card-icon {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  background: rgba(37, 99, 235, 0.1);
  font-size: 1.45rem;
}

.government-card-body {
  display: grid;
  gap: 8px;
}

.government-card-body h3,
.government-card-body p {
  margin: 0;
}

.government-card-body p {
  color: var(--text-secondary, #334155);
  line-height: 1.7;
}

.government-card-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: auto;
}

.government-favorite {
  width: 42px;
  height: 42px;
  padding: 0;
  border-radius: 14px;
  color: #2563eb;
  background: rgba(37, 99, 235, 0.08);
  border: 1px solid rgba(37, 99, 235, 0.16);
}

.government-favorite.is-active {
  color: #f59e0b;
  background: rgba(245, 158, 11, 0.12);
  border-color: rgba(245, 158, 11, 0.28);
}

.government-open-link {
  text-decoration: none;
  text-align: center;
}

.government-count-note {
  text-align: center;
}

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

  .government-hero-stats,
  .government-toolbar {
    grid-template-columns: 1fr;
  }

  .government-card {
    min-height: auto;
  }
}

/* Unified professional hover/focus glow for interactive elements. Desktop only to avoid sticky hover on touch. */
.hover-glow,
.interactive-element,
button:not(:disabled),
a[href],
[role="button"]:not([aria-disabled="true"]),
.nav-button,
.erp-sidebar-link,
.nav-section-toggle,
.menu-item,
.dropdown-item,
.action-btn,
.clickable,
.card.clickable,
.metric,
.stat-card,
.summary-card,
.kpi-card,
.dashboard-card,
.provider-card,
.portal-card,
.government-card,
.pricing-card,
.theme-card,
.sidebar-customizer-row,
select:not(:disabled),
input[type="checkbox"]:not(:disabled),
input[type="radio"]:not(:disabled) {
  cursor: pointer;
  transition:
    transform .22s ease,
    box-shadow .22s ease,
    border-color .22s ease,
    background-color .22s ease,
    color .22s ease,
    opacity .22s ease;
  will-change: transform, box-shadow;
}

@media (hover: hover) and (pointer: fine) {
  .hover-glow:hover,
  .interactive-element:hover,
  button:not(:disabled):hover,
  a[href]:hover,
  [role="button"]:not([aria-disabled="true"]):hover,
  .nav-button:hover,
  .erp-sidebar-link:hover,
  .nav-section-toggle:hover,
  .menu-item:hover,
  .dropdown-item:hover,
  .action-btn:hover,
  .clickable:hover,
  .card.clickable:hover,
  .metric:hover,
  .stat-card:hover,
  .summary-card:hover,
  .kpi-card:hover,
  .dashboard-card:hover,
  .provider-card:hover,
  .portal-card:hover,
  .government-card:hover,
  .pricing-card:hover,
  .theme-card:hover,
  .sidebar-customizer-row:hover,
  select:not(:disabled):hover {
    border-color: rgba(59,130,246,.65) !important;
    box-shadow:
      0 0 8px rgba(59,130,246,.35),
      0 0 18px rgba(59,130,246,.25),
      0 0 32px rgba(59,130,246,.15) !important;
    transform: scale(1.02);
  }
}

.hover-glow:active,
.interactive-element:active,
button:not(:disabled):active,
a[href]:active,
[role="button"]:not([aria-disabled="true"]):active,
.nav-button:active,
.erp-sidebar-link:active,
.nav-section-toggle:active,
.menu-item:active,
.dropdown-item:active,
.action-btn:active,
.clickable:active,
.card.clickable:active,
.metric:active,
.stat-card:active,
.summary-card:active,
.kpi-card:active,
.dashboard-card:active,
.provider-card:active,
.portal-card:active,
.government-card:active,
.pricing-card:active,
.theme-card:active {
  box-shadow:
    0 0 5px rgba(59,130,246,.28),
    0 0 14px rgba(59,130,246,.18) !important;
  transform: scale(.99);
}

.hover-glow:focus-visible,
.interactive-element:focus-visible,
button:not(:disabled):focus-visible,
a[href]:focus-visible,
[role="button"]:not([aria-disabled="true"]):focus-visible,
.nav-button:focus-visible,
.erp-sidebar-link:focus-visible,
.nav-section-toggle:focus-visible,
.menu-item:focus-visible,
.dropdown-item:focus-visible,
.action-btn:focus-visible,
.clickable:focus-visible,
select:not(:disabled):focus-visible,
input:not(:disabled):focus-visible,
textarea:not(:disabled):focus-visible {
  outline: 3px solid rgba(59,130,246,.35);
  outline-offset: 3px;
  border-color: rgba(59,130,246,.65) !important;
  box-shadow:
    0 0 8px rgba(59,130,246,.35),
    0 0 18px rgba(59,130,246,.25),
    0 0 32px rgba(59,130,246,.15) !important;
}

input:not([type="checkbox"]):not([type="radio"]):focus,
textarea:focus {
  transform: none !important;
}

button:disabled,
[aria-disabled="true"],
.disabled {
  cursor: not-allowed !important;
  transform: none !important;
  box-shadow: none;
}

@media (hover: none), (pointer: coarse), (max-width: 768px) {
  .hover-glow,
  .interactive-element,
  button,
  a,
  [role="button"],
  .nav-button,
  .erp-sidebar-link,
  .nav-section-toggle,
  .menu-item,
  .dropdown-item,
  .action-btn,
  .clickable,
  .card,
  .metric,
  .stat-card,
  .summary-card,
  .kpi-card,
  .dashboard-card,
  .provider-card,
  .portal-card,
  .government-card,
  .pricing-card,
  .theme-card {
    transition:
      background-color .12s ease,
      border-color .12s ease,
      color .12s ease,
      box-shadow .12s ease,
      opacity .12s ease !important;
    will-change: auto;
  }

  .hover-glow:hover,
  .interactive-element:hover,
  button:hover,
  a:hover,
  [role="button"]:hover,
  .nav-button:hover,
  .erp-sidebar-link:hover,
  .nav-section-toggle:hover,
  .menu-item:hover,
  .dropdown-item:hover,
  .action-btn:hover,
  .clickable:hover,
  .card:hover,
  .metric:hover,
  .stat-card:hover,
  .summary-card:hover,
  .kpi-card:hover,
  .dashboard-card:hover,
  .provider-card:hover,
  .portal-card:hover,
  .government-card:hover,
  .pricing-card:hover,
  .theme-card:hover {
    transform: none !important;
  }
}

.metric--sensitive {
  position: relative;
  padding-top: max(var(--metric-padding-top, 20px), 22px);
}

.sensitive-metric-toggle {
  position: absolute;
  top: 10px;
  left: 10px;
  right: auto;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid rgba(37, 99, 235, .18);
  border-radius: 999px;
  background: rgba(255, 255, 255, .82);
  color: #2563eb;
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(15, 23, 42, .08);
  transition:
    background-color .15s ease,
    border-color .15s ease,
    box-shadow .15s ease,
    color .15s ease;
  z-index: 2;
}

.sensitive-metric-toggle:hover,
.sensitive-metric-toggle:focus-visible {
  background: rgba(37, 99, 235, .1);
  border-color: rgba(37, 99, 235, .45);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .14);
  outline: none;
}

.sensitive-metric-toggle:active {
  box-shadow: 0 0 0 2px rgba(37, 99, 235, .12);
}

.sensitive-value-hidden {
  letter-spacing: .18em;
  direction: ltr;
  unicode-bidi: isolate;
}

[data-theme="dark"] .sensitive-metric-toggle,
[data-theme="glass"] .sensitive-metric-toggle {
  background: rgba(15, 23, 42, .72);
  border-color: rgba(148, 163, 184, .32);
  color: #93c5fd;
}

@media (max-width: 768px) {
  .sensitive-metric-toggle {
    width: 30px;
    height: 30px;
    top: 8px;
    left: 8px;
  }
}

/* Public auth/pricing scroll and layout fix. Keeps auth logic untouched. */
html:has(.login-screen),
body:has(.login-screen),
html:has(.public-auth-screen),
body:has(.public-auth-screen) {
  height: auto !important;
  min-height: 100% !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
}

.login-screen,
.public-auth-screen,
.login-screen.with-landing {
  width: 100% !important;
  min-height: 100vh !important;
  height: auto !important;
  max-height: none !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  align-items: start !important;
  justify-items: center !important;
  align-content: start !important;
  padding: 24px !important;
  box-sizing: border-box !important;
}

.login-screen.with-landing {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) !important;
  gap: 28px !important;
}

.public-auth-screen > *,
.login-screen.with-landing > *,
.login-screen .modern-login-card,
.login-screen .login-card,
.landing-panel,
.pricing-page {
  width: min(1200px, 100%) !important;
  max-width: 1200px !important;
  margin-inline: auto !important;
  box-sizing: border-box !important;
}

.login-screen .modern-login-card,
.login-screen .login-card {
  height: auto !important;
  min-height: 0 !important;
  max-height: none !important;
  overflow: visible !important;
}

.landing-panel,
.pricing-page,
.landing-panel .pricing-page {
  height: auto !important;
  min-height: 0 !important;
  max-height: none !important;
  overflow: visible !important;
  padding: 24px !important;
}

.landing-panel .pricing-page {
  grid-column: 1 / -1 !important;
  margin: 0 auto !important;
}

.pricing-head {
  max-width: 760px !important;
  margin: 0 auto 24px !important;
  text-align: center !important;
}

.pricing-grid {
  width: 100% !important;
  display: grid !important;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)) !important;
  gap: 18px !important;
  align-items: stretch !important;
  height: auto !important;
  max-height: none !important;
  overflow: visible !important;
}

.pricing-card {
  min-width: 0 !important;
  height: auto !important;
  min-height: 100% !important;
  max-height: none !important;
  overflow: visible !important;
}

@media (min-width: 1024px) {
  .pricing-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  }
}

@media (min-width: 681px) and (max-width: 1023px) {
  .pricing-grid {
    grid-template-columns: repeat(2, minmax(260px, 1fr)) !important;
  }
}

@media (max-width: 680px) {
  .login-screen,
  .public-auth-screen,
  .login-screen.with-landing {
    padding: 16px !important;
  }

  .pricing-grid {
    grid-template-columns: 1fr !important;
  }
}

/* Approval center dashboard alerts + lightweight interaction/performance polish */
.approval-notifications-card {
  margin: 16px 0;
  border: 1px solid rgba(37, 99, 235, 0.18);
  background: linear-gradient(135deg, rgba(255,255,255,0.96), rgba(239,246,255,0.9));
}

.approval-alert-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 28px;
  margin-inline-start: 8px;
  padding: 0 9px;
  border-radius: 999px;
  background: #dc2626;
  color: #fff;
  font-size: 0.8rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.approval-alerts-list {
  display: grid;
  gap: 10px;
}

.approval-alert-card-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: 14px;
  background: var(--surface, #fff);
}

.approval-alert-card-main {
  min-width: 0;
}

.approval-alert-card-main strong,
.approval-alert-card-main small {
  display: block;
  overflow-wrap: anywhere;
}

.approval-alert-card-main small {
  color: var(--text-secondary, #64748b);
  margin-top: 4px;
}

.empty-inline {
  padding: 18px;
  border: 1px dashed var(--border-color, #e2e8f0);
  border-radius: 14px;
  color: var(--text-secondary, #64748b);
  text-align: center;
}

.metric-value,
.stat-value,
.card strong,
.panel strong,
.badge,
td,
th {
  font-variant-numeric: tabular-nums;
}

button,
a,
.nav-item,
.menu-item,
.card,
.panel,
.action-btn,
[role="button"] {
  will-change: auto;
}

@media (max-width: 768px), (hover: none) {
  .approval-alert-card-item {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .approval-alert-card-item .row-actions {
    justify-content: stretch;
  }

  .approval-alert-card-item .row-actions button {
    flex: 1;
  }

  .panel,
  .card,
  .metric-card,
  .dashboard-premium-hero,
  .dashboard-construction-scene,
  .approval-notifications-card {
    box-shadow: 0 6px 18px rgba(15, 23, 42, 0.10) !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
  }

  button,
  a,
  .nav-item,
  .menu-item,
  .card,
  .panel,
  .action-btn,
  [role="button"] {
    transition:
      background-color .12s ease,
      border-color .12s ease,
      color .12s ease,
      opacity .12s ease,
      box-shadow .12s ease !important;
  }

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

/* Non-visual performance pass: faster first paint, smoother taps and scrolling. */
.workspace,
.dashboard-finance-grid,
.dashboard-hr-inventory,
.important-alerts-panel,
.report-container,
.table-wrap,
.panel:not(.approval-notifications-card) {
  content-visibility: auto;
  contain-intrinsic-size: 1px 420px;
}

.dashboard-premium-hero,
.dashboard-construction-scene,
.approval-notifications-card,
.metrics,
.metric-card {
  content-visibility: visible;
}

.metric-card,
.metric-card *,
.stat-card,
.stat-card *,
.badge,
.money,
[data-sensitive-value] {
  font-variant-numeric: tabular-nums;
  text-rendering: optimizeLegibility;
}

@media (max-width: 768px), (hover: none), (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
  }

  .construction-animation,
  .loading-construction-animation {
    animation: none !important;
  }

  .dashboard-construction-scene img,
  .empty-state img,
  .construction-animation {
    filter: none !important;
  }

  .panel,
  .card,
  .metric-card,
  .stat-card,
  .table-wrap,
  .modal-card {
    transition:
      background-color .12s ease,
      border-color .12s ease,
      color .12s ease,
      opacity .12s ease,
      box-shadow .12s ease !important;
  }

  .metric-card:hover,
  .stat-card:hover,
  .panel:hover,
  .card:hover {
    transform: none !important;
  }
}

/* Architectural design tools */
.architecture-tools-page {
  display: grid;
  gap: 18px;
}

.architecture-tools-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  overflow: hidden;
}

.architecture-tools-hero h2 {
  margin: 8px 0;
  color: var(--text-primary, #0f172a);
}

.architecture-tools-icon {
  width: 84px;
  height: 84px;
  border-radius: 24px;
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(135deg, #2563eb, #0f2a55);
  font-size: 2.2rem;
  font-weight: 900;
  box-shadow: 0 14px 28px rgba(37, 99, 235, .2);
  flex: 0 0 auto;
}

.architecture-tools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}

.architecture-tool-card {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr) auto;
  gap: 18px;
  align-items: center;
  padding: 18px;
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: 18px;
  background: var(--surface, #fff);
}

.architecture-tool-preview {
  min-height: 128px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  text-align: center;
  background:
    linear-gradient(135deg, rgba(37, 99, 235, .92), rgba(16, 185, 129, .82)),
    #2563eb;
  color: #fff;
}

.architecture-tool-preview span,
.architecture-tool-preview strong {
  display: block;
}

.architecture-tool-preview span {
  font-size: 2.4rem;
  font-weight: 900;
  line-height: 1;
}

.architecture-tool-body h3 {
  margin: 10px 0 8px;
  color: var(--text-primary, #0f172a);
}

.architecture-tool-actions {
  display: flex;
  justify-content: flex-end;
}

.architecture-tool-link {
  white-space: nowrap;
  text-decoration: none;
}

@media (max-width: 760px) {
  .architecture-tools-hero,
  .architecture-tool-card {
    grid-template-columns: 1fr;
    flex-direction: column;
    align-items: stretch;
  }

  .architecture-tools-icon {
    width: 64px;
    height: 64px;
    border-radius: 18px;
    font-size: 1.8rem;
  }

  .architecture-tool-actions,
  .architecture-tool-actions .architecture-tool-link {
    width: 100%;
  }

  .architecture-tool-link {
    text-align: center;
  }
}

/* Contracting community rebuild: real-feed responsive layout */
.community-page,
.community-page * {
  box-sizing: border-box;
}

.community-page {
  max-width: 1480px;
  margin: 0 auto;
  padding-bottom: 16px;
}

.community-topbar {
  backdrop-filter: none;
}

.community-top-actions button,
.community-tags button,
.community-empty button {
  min-height: 38px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-soft);
  color: var(--text);
  font: inherit;
  font-weight: 850;
  padding: 8px 12px;
}

.community-top-actions .primary,
.community-empty .primary,
.community-bottom-nav .primary {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}

.community-selected-files {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 0;
}

.community-selected-files span {
  max-width: 100%;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--text);
  font-size: 12px;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.community-empty {
  display: grid;
  justify-items: center;
  gap: 10px;
  min-height: 220px;
  text-align: center;
}

.community-empty strong {
  color: var(--text);
  font-size: 1.1rem;
}

.community-tags button.active {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary);
}

.community-post-card,
.community-composer,
.community-side-card,
.community-profile-card {
  border-radius: 14px;
}

.community-post-actions button,
.community-compose-tools button,
.community-tabs button,
.community-quick button,
.community-suggested button,
.community-bottom-nav button {
  cursor: pointer;
  transition: background-color .15s ease, border-color .15s ease, color .15s ease, box-shadow .15s ease;
}

.community-post-actions button:hover,
.community-compose-tools button:hover,
.community-tabs button:hover,
.community-quick button:hover,
.community-suggested button:hover {
  border-color: rgba(37, 99, 235, .45);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .10);
}

@media (max-width: 1180px) {
  .community-layout {
    grid-template-columns: minmax(220px, 280px) minmax(0, 1fr);
  }
}

@media (max-width: 900px) {
  .community-topbar {
    position: static;
    grid-template-columns: 1fr;
  }

  .community-top-actions {
    flex-wrap: wrap;
  }

  .community-layout {
    grid-template-columns: 1fr;
  }

  .community-left,
  .community-right {
    display: block;
    position: static;
  }

  .community-left {
    display: grid;
  }

  .community-quick {
    display: flex;
    overflow-x: auto;
    padding: 10px;
  }

  .community-quick button {
    flex: 0 0 auto;
    min-width: max-content;
  }
}

@media (max-width: 760px) {
  .community-page {
    gap: 12px;
  }

  .community-profile-card,
  .community-right {
    display: none;
  }

  .community-composer-input {
    align-items: flex-start;
  }

  .community-composer-input textarea {
    min-height: 104px;
  }

  .community-publish,
  .community-file-picker,
  .community-composer-row select {
    width: 100%;
    justify-self: stretch;
  }

  .community-file-picker,
  .community-composer-row select,
  .community-compose-tools button,
  .community-top-actions button {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .community-post-head {
    align-items: flex-start;
  }

  .community-company-line {
    flex-wrap: wrap;
  }

  .community-post-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    overflow: visible;
  }

  .community-post-actions button {
    min-width: 0;
  }

  .community-media-item {
    min-height: 190px;
  }

  .community-bottom-nav {
    position: sticky;
    bottom: 0;
    margin: 0 -4px;
  }
}

/* X-style community polish: prevents mobile icon overlap and keeps the feed crisp */
.community-page {
  --community-line: color-mix(in srgb, var(--border, #e2e8f0) 86%, transparent);
  --community-hover: rgba(37, 99, 235, .08);
}

.community-topbar.panel,
.community-composer.panel,
.community-post-card,
.community-tabs.panel,
.community-side-card.panel,
.community-profile-card.panel {
  border-radius: 18px;
  border-color: var(--community-line);
}

.community-brand {
  min-width: 0;
}

.community-brand > div,
.community-brand strong,
.community-brand small {
  min-width: 0;
}

.community-brand strong {
  display: block;
  color: var(--text);
  line-height: 1.2;
}

.community-brand small {
  display: block;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.community-top-actions {
  justify-content: flex-end;
}

.community-top-actions button {
  white-space: nowrap;
}

.community-post-card {
  box-shadow: none;
  border-radius: 0;
  border-inline: 0;
  border-top: 0;
  padding: 18px 16px;
}

.community-post-card:hover {
  background: color-mix(in srgb, var(--surface-soft, #f8fafc) 45%, transparent);
}

.community-post-head {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  align-items: start;
  justify-content: stretch;
}

.community-post-head > .community-avatar {
  grid-row: span 2;
}

.community-company-line {
  min-width: 0;
}

.community-company-line strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.community-company-line button {
  flex: 0 0 auto;
  color: #dc2626;
  font-size: 12px;
}

.community-post-head .muted {
  margin: 3px 0 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.community-type-badge {
  margin-inline-start: 48px;
}

.community-post-text,
.community-media-grid,
.community-comments,
.community-post-actions {
  margin-inline-start: 48px;
}

.community-post-actions {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 4px;
  overflow: visible;
  padding: 2px 0 0;
  border: 0;
}

.community-post-actions button {
  min-width: 0;
  min-height: 38px;
  padding: 6px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  font-size: 13px;
}

.community-post-actions button span {
  font-size: 17px;
  line-height: 1;
}

.community-post-actions button b {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font: inherit;
  font-weight: 800;
}

.community-post-actions button:hover {
  background: var(--community-hover);
  border-color: transparent;
  box-shadow: none;
}

.community-post-actions button.active {
  background: transparent;
  color: #2563eb;
}

.community-composer {
  overflow: hidden;
}

.community-composer-input {
  align-items: flex-start;
}

.community-composer-input textarea {
  border: 0;
  background: transparent;
  min-height: 92px;
  padding: 8px 4px;
  font-size: 18px;
}

.community-composer-input textarea:focus {
  outline: none;
  box-shadow: none;
}

.community-composer-row,
.community-compose-tools {
  margin-inline-start: 52px;
}

.community-compose-tools {
  border-top: 1px solid var(--community-line);
  padding-top: 10px;
}

.community-compose-tools button,
.community-file-picker,
.community-composer-row select {
  border-radius: 999px;
}

.community-media-grid {
  border-radius: 18px;
  overflow: hidden;
}

.community-media-item {
  border-radius: 0;
  border-color: var(--community-line);
}

@media (min-width: 1181px) {
  .community-layout {
    grid-template-columns: minmax(190px, 250px) minmax(520px, 760px) minmax(230px, 310px);
    justify-content: center;
  }
}

@media (max-width: 900px) {
  .community-layout {
    max-width: 760px;
    margin-inline: auto;
  }

  .community-topbar.panel {
    top: 0;
    z-index: 8;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    border-radius: 0 0 18px 18px;
  }

  .community-search {
    grid-column: 1 / -1;
  }

  .community-left {
    order: 2;
  }

  .community-feed {
    order: 1;
  }

  .community-quick.panel {
    border-radius: 16px;
    margin-bottom: 0;
  }
}

@media (max-width: 760px) {
  .community-page {
    width: 100%;
    padding-inline: 0;
  }

  .community-topbar.panel,
  .community-composer.panel,
  .community-tabs.panel,
  .community-empty.panel {
    border-inline: 0;
    border-radius: 0;
  }

  .community-brand span,
  .community-avatar {
    width: 40px;
    height: 40px;
    border-radius: 999px;
  }

  .community-brand small {
    display: none;
  }

  .community-top-actions {
    gap: 6px;
  }

  .community-top-actions button {
    min-width: 42px;
    min-height: 42px;
    padding: 0 12px;
  }

  .community-top-actions .primary {
    min-width: 74px;
  }

  .community-search input {
    min-height: 42px;
    font-size: 14px;
  }

  .community-left,
  .community-profile-card,
  .community-right {
    display: none !important;
  }

  .community-feed,
  .community-posts {
    gap: 0;
  }

  .community-tabs {
    border-inline: 0;
    border-radius: 0;
    padding-inline: 8px;
  }

  .community-tabs button {
    flex: 0 0 auto;
    white-space: nowrap;
  }

  .community-composer {
    padding: 12px;
  }

  .community-composer-row,
  .community-compose-tools,
  .community-selected-files {
    margin-inline-start: 0;
  }

  .community-compose-tools {
    gap: 6px;
    padding-bottom: 6px;
  }

  .community-compose-tools button {
    min-height: 34px;
    font-size: 12px;
  }

  .community-post-card {
    padding: 14px 12px;
  }

  .community-post-head {
    grid-template-columns: 42px minmax(0, 1fr);
    gap: 8px;
  }

  .community-type-badge,
  .community-post-text,
  .community-media-grid,
  .community-comments,
  .community-post-actions {
    margin-inline-start: 50px;
  }

  .community-post-text {
    font-size: 15px;
    line-height: 1.75;
  }

  .community-media-grid,
  .community-media-grid.count-2 {
    grid-template-columns: 1fr;
  }

  .community-media-item {
    min-height: 220px;
  }

  .community-post-actions {
    grid-template-columns: repeat(5, minmax(32px, 1fr));
    gap: 0;
  }

  .community-post-actions button {
    padding: 5px 2px;
    gap: 3px;
  }

  .community-post-actions button b {
    font-size: 11px;
    max-width: 40px;
  }

  .community-bottom-nav {
    border-radius: 18px 18px 0 0;
    box-shadow: 0 -8px 24px rgba(15, 23, 42, .08);
  }
}

@media (max-width: 390px) {
  .community-post-actions button b {
    display: none;
  }

  .community-post-actions button span {
    font-size: 19px;
  }
}

/* Final mobile social-feed override: one-column X-like experience on phones */
@media (max-width: 768px), (hover: none) and (pointer: coarse) {
  .community-page {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 0 18px !important;
    overflow-x: hidden !important;
    background: var(--surface, #fff);
  }

  .community-layout {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    overflow-x: hidden !important;
  }

  .community-left,
  .community-right,
  .community-profile-card,
  .community-bottom-nav {
    display: none !important;
  }

  .community-topbar.panel {
    position: sticky !important;
    top: 0 !important;
    z-index: 30 !important;
    display: flex !important;
    flex-wrap: wrap !important;
    align-items: center !important;
    gap: 8px !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 10px 12px !important;
    border-inline: 0 !important;
    border-top: 0 !important;
    border-radius: 0 !important;
    background: var(--surface, #fff) !important;
    box-shadow: 0 1px 0 var(--border, #e2e8f0) !important;
  }

  .community-brand {
    flex: 1 1 0 !important;
    min-width: 0 !important;
    gap: 8px !important;
  }

  .community-brand span {
    flex: 0 0 38px !important;
    width: 38px !important;
    height: 38px !important;
    border-radius: 50% !important;
    font-size: 12px !important;
  }

  .community-brand strong {
    max-width: 100% !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
    font-size: 15px !important;
  }

  .community-brand small {
    display: none !important;
  }

  .community-top-actions {
    flex: 0 0 auto !important;
    display: flex !important;
    gap: 6px !important;
  }

  .community-top-actions button {
    min-width: 38px !important;
    width: 38px !important;
    height: 38px !important;
    min-height: 38px !important;
    padding: 0 !important;
    border-radius: 50% !important;
    font-size: 16px !important;
  }

  .community-top-actions .primary {
    width: auto !important;
    min-width: 68px !important;
    padding: 0 12px !important;
    border-radius: 999px !important;
    font-size: 13px !important;
  }

  .community-search {
    flex: 0 0 100% !important;
    order: 3 !important;
    width: 100% !important;
    min-width: 0 !important;
  }

  .community-search input {
    width: 100% !important;
    min-height: 40px !important;
    border-radius: 999px !important;
  }

  .community-feed,
  .community-posts {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    overflow-x: hidden !important;
  }

  .community-composer.panel,
  .community-tabs.panel,
  .community-empty.panel {
    width: 100% !important;
    margin: 0 !important;
    border-inline: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
  }

  .community-composer.panel {
    padding: 12px !important;
    border-top: 0 !important;
  }

  .community-composer-input {
    display: grid !important;
    grid-template-columns: 40px minmax(0, 1fr) !important;
    align-items: start !important;
    gap: 10px !important;
  }

  .community-composer-input textarea {
    width: 100% !important;
    min-width: 0 !important;
    min-height: 88px !important;
    font-size: 16px !important;
    line-height: 1.7 !important;
  }

  .community-composer-row,
  .community-compose-tools,
  .community-selected-files {
    margin: 8px 0 0 !important;
    width: 100% !important;
  }

  .community-composer-row {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 8px !important;
  }

  .community-compose-tools {
    display: flex !important;
    gap: 6px !important;
    overflow-x: auto !important;
    padding: 8px 0 2px !important;
    border-top: 1px solid var(--border, #e2e8f0) !important;
  }

  .community-compose-tools button {
    flex: 0 0 auto !important;
    min-width: max-content !important;
    padding: 7px 10px !important;
    font-size: 12px !important;
  }

  .community-publish {
    width: 100% !important;
    min-height: 42px !important;
    margin-top: 10px !important;
  }

  .community-tabs.panel {
    display: flex !important;
    gap: 6px !important;
    overflow-x: auto !important;
    padding: 8px 10px !important;
    border-top: 1px solid var(--border, #e2e8f0) !important;
    border-bottom: 1px solid var(--border, #e2e8f0) !important;
    background: var(--surface, #fff) !important;
  }

  .community-tabs button {
    flex: 0 0 auto !important;
    white-space: nowrap !important;
    min-height: 34px !important;
    padding: 6px 12px !important;
    border-radius: 999px !important;
  }

  .community-post-card {
    display: block !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 12px !important;
    border-inline: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    overflow-x: hidden !important;
  }

  .community-post-head {
    display: grid !important;
    grid-template-columns: 40px minmax(0, 1fr) !important;
    gap: 10px !important;
    align-items: start !important;
  }

  .community-post-head > div:not(.community-avatar) {
    min-width: 0 !important;
  }

  .community-company-line {
    display: flex !important;
    min-width: 0 !important;
    gap: 5px !important;
  }

  .community-company-line strong {
    min-width: 0 !important;
    max-width: 100% !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
  }

  .community-company-line button {
    flex: 0 0 auto !important;
    margin-inline-start: 4px !important;
  }

  .community-post-head .muted {
    max-width: 100% !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
    font-size: 12px !important;
  }

  .community-type-badge,
  .community-post-text,
  .community-media-grid,
  .community-comments,
  .community-post-actions {
    margin-inline-start: 50px !important;
    max-width: calc(100% - 50px) !important;
  }

  .community-post-text {
    overflow-wrap: anywhere !important;
    word-break: break-word !important;
  }

  .community-media-grid,
  .community-media-grid.count-1,
  .community-media-grid.count-2 {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 4px !important;
    border-radius: 16px !important;
  }

  .community-media-item {
    min-height: 210px !important;
    max-height: 420px !important;
  }

  .community-media-item img,
  .community-media-item video {
    max-height: 420px !important;
  }

  .community-post-actions {
    display: grid !important;
    grid-template-columns: repeat(5, minmax(0, 1fr)) !important;
    gap: 0 !important;
    padding-top: 8px !important;
    overflow: hidden !important;
  }

  .community-post-actions button {
    min-width: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    min-height: 36px !important;
    padding: 4px 0 !important;
    border-radius: 999px !important;
    gap: 0 !important;
  }

  .community-post-actions button span {
    font-size: 18px !important;
  }

  .community-post-actions button b {
    display: none !important;
  }
}

@media (max-width: 480px), (hover: none) and (pointer: coarse) {
  .community-composer-row {
    grid-template-columns: 1fr !important;
  }

  .community-file-picker,
  .community-composer-row select {
    min-height: 42px !important;
    justify-content: center !important;
  }
}

@media (min-width: 769px) and (max-width: 1180px) {
  .community-layout {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) minmax(260px, 340px) !important;
  }

  .community-feed {
    order: 1 !important;
  }

  .community-left {
    order: 2 !important;
    display: grid !important;
  }

  .community-right {
    display: none !important;
  }
}

/* SaaSMo/X inspired contracting community */
.social-community,
.social-community * {
  box-sizing: border-box;
}

.social-community {
  --social-blue: #0b63f6;
  --social-line: #e2e8f0;
  --social-soft: #f8fafc;
  --social-text: #0f172a;
  --social-muted: #64748b;
  width: 100%;
  min-width: 0;
  color: var(--social-text);
  background: linear-gradient(180deg, #f4f8ff 0%, #fff 42%);
}

.social-topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: 210px minmax(220px, 1fr) auto auto;
  gap: 14px;
  align-items: center;
  width: 100%;
  padding: 14px 18px;
  border: 1px solid var(--social-line);
  border-radius: 22px;
  background: rgba(255, 255, 255, .94);
  box-shadow: 0 12px 30px rgba(15, 23, 42, .06);
}

.social-logo,
.social-header-actions,
.social-company-chip,
.social-post-author,
.social-company-line,
.social-post-actions,
.social-suggested,
.social-composer-tools {
  display: flex;
  align-items: center;
  gap: 10px;
}

.social-logo span {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: linear-gradient(135deg, #0b63f6, #38bdf8);
  color: #fff;
  font-weight: 900;
}

.social-logo strong {
  display: block;
  color: #0b63f6;
  font-size: 20px;
  line-height: 1.1;
}

.social-logo small,
.social-author-meta p,
.social-widget small,
.social-profile-card p {
  color: var(--social-muted);
}

.social-search {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  height: 48px;
  padding: 0 14px;
  border: 1px solid var(--social-line);
  border-radius: 16px;
  background: #f1f5f9;
}

.social-search input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--social-text);
  font: inherit;
}

.social-header-actions button,
.social-company-chip,
.social-profile-card button,
.social-side-menu button,
.social-ai-card button,
.social-story,
.social-composer-tools button,
.social-composer-tools label,
.social-composer-tools select,
.social-tabs button,
.social-post-actions button,
.social-widget button,
.social-suggested button,
.social-empty button {
  border: 1px solid var(--social-line);
  border-radius: 14px;
  background: #fff;
  color: var(--social-text);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  transition: background-color .15s ease, border-color .15s ease, color .15s ease, box-shadow .15s ease;
}

.social-header-actions button {
  min-width: 56px;
  min-height: 46px;
  flex-direction: column;
  justify-content: center;
  font-size: 13px;
}

.social-header-actions button span {
  font-size: 18px;
}

.social-header-actions .primary,
.social-composer-tools .primary,
.social-empty .primary {
  border-color: var(--social-blue);
  background: var(--social-blue);
  color: #fff;
}

.social-company-chip {
  min-width: 190px;
  justify-content: space-between;
  padding: 8px 10px;
}

.social-company-chip .community-avatar,
.social-avatar .community-avatar,
.social-post-author .community-avatar,
.social-suggested .community-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
}

.social-layout {
  display: grid;
  grid-template-columns: minmax(190px, 250px) minmax(480px, 760px) minmax(230px, 300px);
  gap: 18px;
  align-items: start;
  padding: 18px 0;
  max-width: 1420px;
  margin: 0 auto;
}

.social-left,
.social-right {
  position: sticky;
  top: 92px;
  display: grid;
  gap: 16px;
  min-width: 0;
}

.social-profile-card,
.social-side-menu,
.social-ai-card,
.social-widget,
.social-stories,
.social-composer,
.social-tabs,
.social-post-card,
.social-empty {
  border: 1px solid var(--social-line);
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 10px 28px rgba(15, 23, 42, .045);
}

.social-profile-card {
  overflow: hidden;
  text-align: center;
  padding-bottom: 16px;
}

.social-cover {
  height: 86px;
  background: linear-gradient(135deg, rgba(11, 99, 246, .25), rgba(15, 23, 42, .12)), url("https://images.unsplash.com/photo-1503387762-592deb58ef4e?auto=format&fit=crop&w=800&q=60") center/cover;
}

.social-profile-avatar {
  width: 74px;
  height: 74px;
  margin: -36px auto 10px;
  display: grid;
  place-items: center;
  border: 5px solid #fff;
  border-radius: 50%;
}

.social-profile-card h3 {
  margin: 0 14px 4px;
  color: var(--social-text);
}

.social-profile-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin: 16px 12px;
  color: var(--social-muted);
  font-size: 12px;
}

.social-profile-stats b {
  display: block;
  color: var(--social-text);
  font-size: 16px;
}

.social-profile-card button,
.social-ai-card button {
  min-height: 42px;
  padding: 0 16px;
  border-color: var(--social-blue);
  color: var(--social-blue);
  background: #fff;
}

.social-side-menu {
  display: grid;
  gap: 4px;
  padding: 12px;
}

.social-side-menu button {
  display: flex;
  justify-content: flex-start;
  min-height: 42px;
  padding: 0 12px;
  border-color: transparent;
  background: transparent;
  text-align: start;
}

.social-side-menu button.active {
  background: #eaf2ff;
  color: var(--social-blue);
}

.social-ai-card {
  padding: 18px;
  color: #fff;
  background: linear-gradient(160deg, #0b63f6, #0f2a55);
}

.social-ai-card p {
  color: rgba(255,255,255,.86);
  line-height: 1.8;
}

.social-feed {
  display: grid;
  gap: 16px;
  min-width: 0;
}

.social-stories {
  display: flex;
  gap: 14px;
  padding: 18px;
  overflow-x: auto;
}

.social-story {
  flex: 0 0 86px;
  display: grid;
  justify-items: center;
  gap: 8px;
  border: 0;
  background: transparent;
}

.social-story > .community-avatar,
.social-story.new span {
  width: 66px;
  height: 66px;
  border: 3px solid var(--social-blue);
  border-radius: 50%;
}

.social-story.new span {
  display: grid;
  place-items: center;
  color: var(--social-blue);
  background: #fff;
  font-size: 30px;
}

.social-story b {
  max-width: 86px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
}

.social-composer {
  display: grid;
  gap: 12px;
  padding: 18px;
}

.social-composer-input {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

.social-composer-input textarea {
  width: 100%;
  min-height: 86px;
  border: 1px solid var(--social-line);
  border-radius: 18px;
  background: var(--social-soft);
  color: var(--social-text);
  padding: 16px;
  resize: vertical;
  font: inherit;
}

.social-composer-tools {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.social-composer-tools label,
.social-composer-tools select,
.social-composer-tools button {
  min-height: 44px;
  padding: 0 14px;
}

.social-composer-tools input[type="file"] {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.social-selected-files {
  justify-content: flex-end;
}

.social-tabs {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  overflow-x: auto;
}

.social-tabs button {
  flex: 0 0 auto;
  min-height: 38px;
  padding: 0 16px;
  border: 0;
  background: #f1f5f9;
}

.social-tabs button.active {
  background: var(--social-blue);
  color: #fff;
}

.social-posts {
  display: grid;
  gap: 16px;
}

.social-post-card {
  position: relative;
  display: grid;
  gap: 12px;
  padding: 18px;
}

.social-post-author {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: inherit;
}

.social-post-menu {
  position: absolute;
  top: 14px;
  left: 14px;
}

.social-post-menu button,
.social-post-menu span {
  border: 0;
  background: transparent;
  color: var(--social-muted);
  font-weight: 900;
}

.social-avatar,
.social-post-author .community-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  overflow: hidden;
}

.social-avatar img,
.social-post-author img,
.social-company-chip img,
.social-suggested img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.social-author-meta {
  min-width: 0;
}

.social-company-line strong {
  color: var(--social-text);
}

.verified-dot {
  background: var(--social-blue);
}

.official-community-badge {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(37, 99, 235, 0.1);
  color: #2563eb;
  font-size: 11px;
  font-style: normal;
  font-weight: 900;
}

.is-official-platform-post {
  border-color: rgba(37, 99, 235, 0.28) !important;
  box-shadow: 0 12px 34px rgba(37, 99, 235, 0.1) !important;
}

.social-author-meta p {
  margin: 2px 0 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.social-type-badge {
  justify-self: start;
  padding: 5px 10px;
  border-radius: 999px;
  background: #eaf2ff;
  color: var(--social-blue);
  font-size: 12px;
  font-weight: 900;
}

.social-post-text {
  margin: 0;
  color: var(--social-text);
  line-height: 1.9;
  overflow-wrap: anywhere;
}

.social-post-media .community-media-grid {
  margin: 0;
  border-radius: 18px;
  overflow: hidden;
}

.social-post-media:empty {
  display: none;
}

.social-comments {
  display: grid;
  gap: 8px;
  padding: 12px;
  border-radius: 16px;
  background: var(--social-soft);
}

.social-comments div {
  display: grid;
  gap: 2px;
}

.social-post-actions {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 4px;
  padding-top: 8px;
  border-top: 1px solid var(--social-line);
}

.social-post-actions button {
  min-width: 0;
  min-height: 38px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--social-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.social-post-actions button:hover {
  background: #eef6ff;
  color: var(--social-blue);
}

.social-post-actions button.active {
  color: var(--social-blue);
}

.social-post-actions b {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font: inherit;
  font-weight: 800;
}

.community-inline-link {
  display: inline;
  border: 0;
  background: transparent;
  color: var(--social-blue);
  font: inherit;
  font-weight: 900;
  padding: 0 2px;
  cursor: pointer;
  vertical-align: baseline;
}

.community-inline-link:hover,
.community-inline-link:focus-visible {
  text-decoration: underline;
  outline: none;
}

.community-inline-link.mention {
  color: #7c3aed;
}

.community-repost-preview {
  display: grid;
  gap: 8px;
  margin-top: 10px;
  padding: 12px;
  border: 1px solid var(--social-line);
  border-radius: 16px;
  background: #f8fafc;
  cursor: pointer;
}

.community-repost-preview strong {
  color: var(--social-text);
  font-weight: 900;
}

.community-repost-preview span {
  color: var(--social-muted);
  line-height: 1.7;
}

.social-widget {
  display: grid;
  gap: 10px;
  padding: 16px;
}

.social-widget h3 {
  margin: 0 0 6px;
}

.social-widget > button {
  display: grid;
  gap: 3px;
  min-height: 56px;
  padding: 10px;
  text-align: start;
}

.social-suggested {
  min-width: 0;
}

.social-suggested > div:nth-child(2) {
  min-width: 0;
  flex: 1;
}

.social-suggested strong,
.social-suggested small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.social-suggested button {
  min-height: 34px;
  padding: 0 10px;
  color: var(--social-blue);
}

.social-stat-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.social-stat-grid div {
  padding: 12px;
  border: 1px solid var(--social-line);
  border-radius: 14px;
  background: var(--social-soft);
}

.social-stat-grid b,
.social-stat-grid span {
  display: block;
}

.social-empty {
  display: grid;
  justify-items: center;
  gap: 10px;
  min-height: 220px;
  padding: 28px;
  text-align: center;
}

@media (max-width: 1180px) {
  .social-topbar {
    grid-template-columns: 1fr auto;
  }

  .social-search {
    grid-column: 1 / -1;
    order: 4;
  }

  .social-layout {
    grid-template-columns: minmax(0, 1fr) minmax(220px, 280px);
  }

  .social-left {
    display: none;
  }
}

@media (max-width: 820px) {
  .social-community {
    background: #fff;
  }

  .social-topbar {
    position: sticky;
    top: 0;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    padding: 10px;
    border-inline: 0;
    border-radius: 0;
  }

  .social-logo small,
  .social-header-actions small,
  .social-company-chip {
    display: none;
  }

  .social-logo strong {
    font-size: 16px;
  }

  .social-logo span {
    width: 36px;
    height: 36px;
  }

  .social-header-actions button {
    min-width: 38px;
    width: 38px;
    min-height: 38px;
    padding: 0;
    border-radius: 50%;
  }

  .social-header-actions .primary {
    width: auto;
    min-width: 66px;
    border-radius: 999px;
    font-size: 13px;
  }

  .social-layout {
    display: block;
    padding: 0;
  }

  .social-right {
    display: none;
  }

  .social-feed,
  .social-posts {
    display: block;
    width: 100%;
  }

  .social-stories,
  .social-composer,
  .social-tabs,
  .social-post-card,
  .social-empty {
    border-inline: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .social-stories {
    padding: 12px 10px;
  }

  .social-story {
    flex-basis: 72px;
  }

  .social-story > .community-avatar,
  .social-story.new span {
    width: 56px;
    height: 56px;
  }

  .social-story b {
    max-width: 72px;
    font-size: 11px;
  }

  .social-composer {
    padding: 12px;
  }

  .social-composer-input {
    grid-template-columns: 42px minmax(0, 1fr);
  }

  .social-composer-input textarea {
    min-height: 84px;
    border-radius: 16px;
    font-size: 15px;
  }

  .social-composer-tools {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .social-composer-tools label,
  .social-composer-tools select,
  .social-composer-tools button {
    width: 100%;
    min-width: 0;
    justify-content: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .social-composer-tools .primary {
    grid-column: 1 / -1;
  }

  .social-tabs {
    padding: 8px 10px;
    border-top: 1px solid var(--social-line);
    border-bottom: 1px solid var(--social-line);
  }

  .social-post-card {
    padding: 12px;
    border-top: 0;
  }

  .social-post-author {
    align-items: flex-start;
  }

  .social-author-meta p {
    font-size: 12px;
  }

  .social-post-text {
    font-size: 15px;
  }

  .social-post-actions {
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 0;
  }

  .social-post-actions button {
    padding: 0;
    gap: 0;
  }

  .social-post-actions b {
    display: none;
  }
}

/* Community stability/performance patch: keep actions smooth without layout shake */
.social-community {
  contain: layout paint;
}

.social-community .social-posts {
  align-items: start;
}

.social-community .social-post-card {
  contain: layout paint;
  content-visibility: auto;
  contain-intrinsic-size: 1px 420px;
  transform: none !important;
  transition: border-color .14s ease, box-shadow .14s ease, background-color .14s ease !important;
  will-change: auto !important;
}

.social-community button,
.social-community label,
.social-community select,
.social-community .social-post-card,
.social-community .social-story,
.social-community .social-widget,
.social-community .social-composer,
.social-community .social-tabs {
  backface-visibility: hidden;
  transform: none !important;
}

.social-community button:hover,
.social-community label:hover,
.social-community .social-post-card:hover,
.social-community .social-story:hover,
.social-community .social-widget button:hover,
.social-community .social-suggested button:hover {
  transform: none !important;
  box-shadow: 0 0 0 3px rgba(11, 99, 246, 0.08) !important;
}

.social-community button:active,
.social-community label:active,
.social-community .social-post-actions button:active {
  transform: none !important;
  box-shadow: 0 0 0 2px rgba(11, 99, 246, 0.12) !important;
}

.social-community .social-post-actions {
  min-height: 44px;
}

.social-community .social-post-actions button {
  min-height: 40px;
  min-width: 0;
  border-color: transparent;
  transition: background-color .12s ease, color .12s ease, border-color .12s ease, box-shadow .12s ease !important;
}

.social-community .social-post-actions button span,
.social-community .social-post-actions button b {
  pointer-events: none;
}

.social-community .social-post-actions button.active {
  color: var(--social-blue);
  background: #eef5ff;
  border-color: rgba(11, 99, 246, 0.18);
}

body.is-rendering .social-community,
body.is-rendering .social-community * {
  animation: none !important;
  transition-duration: 0s !important;
}

@media (max-width: 820px), (hover: none) {
  .social-community {
    contain: layout paint;
  }

  .social-community .social-post-card,
  .social-community .social-composer,
  .social-community .social-tabs,
  .social-community .social-stories {
    box-shadow: none !important;
  }

  .social-community .social-post-card {
    content-visibility: visible;
    contain-intrinsic-size: auto;
  }

  .social-community button:hover,
  .social-community label:hover,
  .social-community .social-post-card:hover,
  .social-community .social-story:hover {
    box-shadow: none !important;
    transform: none !important;
  }
}

/* Company public profile inside community */
.community-profile-page {
  display: grid;
  gap: 14px;
}

.community-profile-cover {
  position: relative;
  min-height: 220px;
  border-radius: 22px 22px 0 0;
  background:
    linear-gradient(180deg, rgba(15, 23, 42, 0.1), rgba(15, 23, 42, 0.36)),
    linear-gradient(135deg, #dbeafe, #eff6ff 42%, #bfdbfe);
  background-size: cover;
  background-position: center;
  overflow: hidden;
}

.community-profile-back,
.community-profile-edit {
  position: absolute;
  top: 18px;
  border: 1px solid rgba(226, 232, 240, 0.9);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.92);
  color: #0f172a;
  padding: 10px 14px;
  font-weight: 900;
}

.community-profile-back {
  right: 18px;
}

.community-profile-edit {
  left: 18px;
}

.community-profile-main-card,
.community-profile-tabs,
.community-profile-panel {
  border: 1px solid var(--social-line);
  background: #fff;
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.06);
}

.community-profile-main-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 16px;
  align-items: end;
  margin-top: -72px;
  margin-inline: 22px;
  padding: 18px;
  border-radius: 22px;
  position: relative;
  z-index: 2;
}

.community-profile-logo .community-avatar {
  width: 132px;
  height: 132px;
  border-radius: 22px;
  border: 6px solid #fff;
  box-shadow: 0 16px 34px rgba(15, 23, 42, 0.14);
  font-size: 34px;
}

.community-profile-avatar-wrap {
  position: relative;
  display: inline-grid;
  place-items: center;
}

.community-profile-avatar-button {
  display: inline-flex;
  padding: 0;
  border: 0;
  border-radius: 24px;
  background: transparent;
  cursor: pointer;
}

.community-profile-avatar-button .community-avatar {
  overflow: hidden;
}

.community-profile-avatar-button .community-avatar img {
  object-fit: cover;
}

.community-avatar-camera {
  position: absolute;
  inset-inline-end: 2px;
  bottom: 6px;
  width: 38px;
  height: 38px;
  display: inline-grid;
  place-items: center;
  border: 2px solid #fff;
  border-radius: 50%;
  background: #2563eb;
  color: #fff;
  box-shadow: 0 10px 22px rgba(37, 99, 235, .28);
  cursor: pointer;
}

.community-avatar-menu {
  position: absolute;
  top: calc(100% + 10px);
  inset-inline-start: 0;
  z-index: 40;
  width: 190px;
  display: grid;
  gap: 4px;
  padding: 8px;
  border: 1px solid var(--social-line);
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 18px 38px rgba(15, 23, 42, .16);
  text-align: start;
}

.community-avatar-menu button {
  width: 100%;
  min-height: 38px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: #0f172a;
  text-align: start;
  font-weight: 900;
  cursor: pointer;
}

.community-avatar-menu button:hover {
  background: #eff6ff;
  color: #2563eb;
}

.community-avatar-menu .danger {
  color: #dc2626;
}

.community-avatar-modal {
  position: fixed;
  inset: 0;
  z-index: 10040;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(15, 23, 42, .42);
}

.community-avatar-card {
  width: min(520px, 100%);
  max-height: min(92dvh, 720px);
  display: grid;
  gap: 14px;
  overflow-y: auto;
  border: 1px solid rgba(226, 232, 240, .92);
  border-radius: 22px;
  background: #fff;
  padding: 18px;
  box-shadow: 0 30px 80px rgba(15, 23, 42, .24);
}

.community-avatar-card header,
.community-avatar-card footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.community-avatar-card h3,
.community-avatar-card p {
  margin: 0;
}

.community-avatar-card p,
.community-avatar-dropzone small {
  color: #64748b;
  font-weight: 800;
}

.community-avatar-card header button {
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: #eff6ff;
  color: #2563eb;
  font-size: 24px;
  cursor: pointer;
}

.community-avatar-dropzone {
  display: grid;
  justify-items: center;
  gap: 12px;
  padding: 18px;
  border: 1px dashed #bfdbfe;
  border-radius: 18px;
  background: #f8fafc;
}

.community-avatar-dropzone > button {
  min-height: 44px;
  padding: 0 18px;
  border: 0;
  border-radius: 12px;
  background: #2563eb;
  color: #fff;
  font-weight: 900;
  cursor: pointer;
}

.community-avatar-crop-frame {
  width: min(320px, 78vw);
  aspect-ratio: 1 / 1;
  overflow: hidden;
  border: 4px solid #fff;
  border-radius: 28px;
  background: linear-gradient(135deg, #e2e8f0, #f8fafc);
  box-shadow: inset 0 0 0 1px rgba(15, 23, 42, .08), 0 12px 30px rgba(15, 23, 42, .12);
}

.community-avatar-crop-frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform-origin: center;
  will-change: transform;
}

.community-avatar-range {
  display: grid;
  gap: 8px;
  color: #0f172a;
  font-weight: 900;
}

.community-avatar-range input {
  width: 100%;
}

.community-avatar-nudges {
  display: grid;
  grid-template-columns: repeat(4, 42px);
  gap: 8px;
  justify-content: center;
}

.community-avatar-nudges button {
  min-height: 40px;
  border: 1px solid var(--social-line);
  border-radius: 12px;
  background: #fff;
  color: #2563eb;
  font-weight: 900;
  cursor: pointer;
}

.community-avatar-progress {
  position: relative;
  min-height: 28px;
  overflow: hidden;
  border-radius: 999px;
  background: #e2e8f0;
}

.community-avatar-progress span {
  position: absolute;
  inset-block: 0;
  inset-inline-start: 0;
  width: 0;
  background: linear-gradient(90deg, #2563eb, #10b981);
}

.community-avatar-progress b {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  min-height: 28px;
  color: #0f172a;
}

.community-avatar-error {
  padding: 10px 12px;
  border-radius: 12px;
  background: #fef2f2;
  color: #dc2626 !important;
  font-weight: 900;
}

.community-avatar-card footer button {
  min-height: 42px;
  padding: 0 16px;
  border: 1px solid var(--social-line);
  border-radius: 12px;
  background: #fff;
  color: #334155;
  font-weight: 900;
  cursor: pointer;
}

.community-avatar-card footer .primary {
  border-color: #2563eb;
  background: #2563eb;
  color: #fff;
}

.community-avatar-card footer .primary[disabled],
.community-avatar-card footer .primary.disabled {
  opacity: .55;
  pointer-events: none;
}

.community-profile-heading {
  min-width: 0;
}

.community-profile-heading h2 {
  margin: 0;
  color: #0f172a;
  font-size: clamp(24px, 3vw, 34px);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.community-profile-heading p,
.community-profile-heading small {
  display: block;
  margin: 6px 0 0;
  color: #64748b;
  line-height: 1.7;
}

.community-profile-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.community-profile-actions button {
  min-height: 42px;
  border-radius: 12px;
  border: 1px solid var(--social-line);
  background: #fff;
  color: #2563eb;
  font-weight: 900;
  padding: 0 16px;
}

.community-profile-actions .primary {
  background: #2563eb;
  border-color: #2563eb;
  color: #fff;
}

.community-profile-stats {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  border: 1px solid var(--social-line);
  border-radius: 16px;
  overflow: hidden;
}

.community-profile-stats div {
  display: grid;
  gap: 3px;
  padding: 12px;
  text-align: center;
  border-inline-start: 1px solid var(--social-line);
}

.community-profile-stats div:first-child {
  border-inline-start: 0;
}

.community-profile-stats b {
  color: #0f172a;
  font-size: 20px;
}

.community-profile-stats span {
  color: #64748b;
  font-size: 12px;
  font-weight: 800;
}

.community-profile-tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 10px 14px;
  border-radius: 16px;
}

.community-profile-tabs button {
  flex: 0 0 auto;
  min-height: 38px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: #334155;
  padding: 0 12px;
  font-weight: 900;
}

.community-profile-tabs button.active {
  color: #2563eb;
  background: #eff6ff;
  box-shadow: inset 0 -2px 0 #2563eb;
}

.community-profile-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 320px);
  gap: 16px;
  align-items: start;
}

.community-profile-content {
  display: grid;
  gap: 16px;
}

.community-profile-panel {
  border-radius: 20px;
  padding: 18px;
}

.community-profile-panel h3 {
  margin: 0 0 12px;
  color: #0f172a;
}

.community-profile-panel p {
  color: #334155;
  line-height: 1.9;
}

.community-portfolio-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.community-portfolio-filters button {
  border: 1px solid var(--social-line);
  border-radius: 999px;
  background: #f8fafc;
  color: #334155;
  padding: 8px 14px;
  font-weight: 900;
}

.community-portfolio-filters .active {
  background: #2563eb;
  border-color: #2563eb;
  color: #fff;
}

.community-portfolio-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.community-portfolio-card {
  border: 1px solid var(--social-line);
  border-radius: 18px;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 10px 26px rgba(15, 23, 42, 0.06);
}

.community-portfolio-card img,
.community-portfolio-card video {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  background: #e2e8f0;
}

.community-portfolio-card div {
  display: grid;
  gap: 4px;
  padding: 12px;
}

.community-portfolio-card strong {
  color: #0f172a;
  line-height: 1.6;
}

.community-portfolio-card span {
  color: #64748b;
  font-size: 12px;
}

.community-portfolio-card button {
  justify-self: start;
  border: 0;
  background: transparent;
  color: #2563eb;
  font-weight: 900;
}

.community-profile-aside {
  display: grid;
  gap: 16px;
  position: sticky;
  top: 92px;
}

.community-profile-panel dl {
  display: grid;
  gap: 12px;
  margin: 0;
}

.community-profile-panel dl div {
  display: grid;
  gap: 4px;
}

.community-profile-panel dt {
  color: #64748b;
  font-size: 12px;
  font-weight: 900;
}

.community-profile-panel dd {
  margin: 0;
  color: #0f172a;
  overflow-wrap: anywhere;
}

.community-cert-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.community-cert-grid span {
  display: grid;
  place-items: center;
  min-height: 70px;
  border: 1px solid var(--social-line);
  border-radius: 14px;
  color: #2563eb;
  font-weight: 900;
  background: #f8fafc;
}

.community-rating {
  display: block;
  color: #f59e0b;
  font-size: 22px;
}

.community-bottom-nav {
  display: none;
}

@media (max-width: 1180px) {
  .community-profile-grid {
    grid-template-columns: 1fr;
  }

  .community-profile-aside {
    position: static;
  }
}

@media (max-width: 820px) {
  .community-profile-cover {
    min-height: 160px;
    border-radius: 0;
  }

  .community-profile-main-card {
    grid-template-columns: 1fr;
    margin: -54px 12px 0;
    text-align: center;
    justify-items: center;
  }

  .community-profile-logo .community-avatar {
    width: 104px;
    height: 104px;
  }

  .community-profile-avatar-button {
    border-radius: 22px;
  }

  .community-avatar-camera {
    width: 34px;
    height: 34px;
    bottom: 4px;
  }

  .community-avatar-menu {
    inset-inline-start: 50%;
    transform: translateX(-50%);
  }

  .community-profile-actions {
    justify-content: center;
  }

  .community-profile-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .community-profile-stats div {
    border: 0;
    border-top: 1px solid var(--social-line);
  }

  .community-portfolio-grid {
    grid-template-columns: 1fr;
  }

  .community-profile-panel {
    border-radius: 0;
    box-shadow: none;
  }

  .community-avatar-modal {
    align-items: end;
    padding: 0;
  }

  .community-avatar-card {
    width: 100%;
    max-height: 94dvh;
    border-radius: 22px 22px 0 0;
    padding: 16px;
  }
}

/* Mobile-only social community UX: app-like feed, compact header, chips and stable actions */
@media (max-width: 820px), (hover: none) {
  .social-community {
    --mobile-nav-height: 64px;
    width: 100%;
    max-width: 100%;
    min-height: 100dvh;
    padding: 0 0 calc(var(--mobile-nav-height) + env(safe-area-inset-bottom));
    background: #f8fafc;
    overflow-x: hidden;
  }

  .social-community .social-topbar {
    position: sticky;
    top: 0;
    z-index: 60;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 8px;
    min-height: 58px;
    padding: 8px 10px;
    border-radius: 0;
    border-inline: 0;
    border-top: 0;
    box-shadow: 0 8px 22px rgba(15, 23, 42, 0.08);
  }

  .social-community .social-logo {
    gap: 6px;
    min-width: 0;
  }

  .social-community .social-logo span {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    font-size: 16px;
  }

  .social-community .social-logo strong {
    font-size: 14px;
    line-height: 1.1;
  }

  .social-community .social-logo small,
  .social-community .social-header-actions small,
  .social-community .social-company-chip strong,
  .social-community .social-company-chip > span:last-child {
    display: none;
  }

  .social-community .social-header-actions {
    display: flex;
    gap: 4px;
  }

  .social-community .social-header-actions button {
    min-width: 38px;
    width: 38px;
    min-height: 38px;
    padding: 0;
    border-radius: 12px;
  }

  .social-community .social-header-actions .primary {
    font-size: 0;
  }

  .social-community .social-header-actions .primary::before {
    content: "+";
    font-size: 22px;
    line-height: 1;
  }

  .social-community .social-company-chip {
    min-width: 40px;
    width: 40px;
    height: 40px;
    padding: 0;
    justify-content: center;
  }

  .social-community .social-company-chip .community-avatar {
    width: 34px;
    height: 34px;
  }

  .social-community .social-search {
    grid-column: 1 / -1;
    grid-row: 2;
    min-height: 40px;
    padding: 0 12px;
    border-radius: 999px;
    background: #eef4ff;
  }

  .social-community .social-search input {
    min-height: 38px;
    font-size: 14px;
  }

  .social-community .social-layout {
    display: block;
    padding: 0;
  }

  .social-community .social-feed {
    gap: 8px;
    width: 100%;
    max-width: 100%;
  }

  .social-community .social-stories {
    padding: 8px 10px;
    gap: 8px;
    border-radius: 0;
    border-inline: 0;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .social-community .social-stories::-webkit-scrollbar,
  .social-community .social-tabs::-webkit-scrollbar,
  .social-community .community-profile-tabs::-webkit-scrollbar {
    display: none;
  }

  .social-community .social-story {
    flex-basis: 64px;
    min-width: 64px;
    gap: 4px;
  }

  .social-community .social-story > .community-avatar,
  .social-community .social-story.new span {
    width: 50px;
    height: 50px;
    font-size: 20px;
  }

  .social-community .social-story b {
    max-width: 64px;
    font-size: 10px;
    line-height: 1.25;
  }

  .social-community .social-composer {
    margin: 0;
    padding: 10px;
    border-radius: 0;
    border-inline: 0;
    display: grid;
    gap: 8px;
  }

  .social-community .social-composer-input {
    grid-template-columns: 40px minmax(0, 1fr);
    gap: 8px;
    align-items: start;
  }

  .social-community .social-composer-input .social-avatar,
  .social-community .social-composer-input .community-avatar {
    width: 40px;
    height: 40px;
  }

  .social-community .social-composer-input textarea {
    min-height: 44px;
    max-height: 104px;
    padding: 11px 14px;
    border-radius: 999px;
    font-size: 14px;
    line-height: 1.6;
    resize: vertical;
  }

  .social-community .social-composer-tools {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding-bottom: 2px;
    scrollbar-width: none;
  }

  .social-community .social-composer-tools::-webkit-scrollbar {
    display: none;
  }

  .social-community .social-composer-tools label,
  .social-community .social-composer-tools select,
  .social-community .social-composer-tools button {
    flex: 0 0 auto;
    width: auto;
    min-width: 78px;
    min-height: 36px;
    padding: 0 10px;
    border-radius: 999px;
    font-size: 12px;
    white-space: nowrap;
  }

  .social-community .social-composer-tools select {
    max-width: 124px;
  }

  .social-community .social-composer-tools .primary {
    min-width: 86px;
  }

  .social-community .social-tabs {
    position: sticky;
    top: 98px;
    z-index: 50;
    display: flex;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 0;
    border-inline: 0;
    background: rgba(248, 250, 252, 0.96);
    backdrop-filter: blur(8px);
    overflow-x: auto;
    scrollbar-width: none;
  }

  .social-community .social-tabs button {
    flex: 0 0 auto;
    min-height: 36px;
    padding: 0 14px;
    border-radius: 999px;
    font-size: 13px;
    background: #fff;
  }

  .social-community .social-tabs button.active {
    background: #0b63f6;
    color: #fff;
    border-color: #0b63f6;
  }

  .social-community .social-posts {
    gap: 8px;
  }

  .social-community .social-post-card {
    padding: 12px 10px;
    border-radius: 0;
    border-inline: 0;
    box-shadow: none !important;
    gap: 9px;
  }

  .social-community .social-post-menu {
    top: 10px;
    left: 8px;
  }

  .social-community .social-post-author {
    gap: 8px;
    padding-inline-end: 28px;
  }

  .social-community .social-post-author .social-avatar,
  .social-community .social-post-author .community-avatar {
    width: 42px;
    height: 42px;
    flex: 0 0 42px;
  }

  .social-community .social-company-line {
    display: flex;
    gap: 5px;
    align-items: center;
    min-width: 0;
  }

  .social-community .social-company-line strong {
    max-width: 58vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 14px;
  }

  .social-community .social-author-meta p {
    font-size: 11px;
    max-width: 68vw;
  }

  .social-community .social-type-badge {
    font-size: 11px;
    padding: 4px 8px;
  }

  .social-community .social-post-text {
    font-size: 14px;
    line-height: 1.75;
  }

  .social-community .social-post-media .community-media-grid {
    border-radius: 14px;
  }

  .social-community .community-media-item img,
  .social-community .community-media-item video {
    max-height: 360px;
    object-fit: cover;
  }

  .social-community .social-comments {
    padding: 8px;
    border-radius: 12px;
    font-size: 12px;
  }

  .social-community .social-post-actions {
    min-height: 42px;
    padding-top: 6px;
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .social-community .social-post-actions button {
    min-height: 36px;
    border-radius: 10px;
    font-size: 16px;
  }

  .social-community .social-post-actions b {
    display: none;
  }

  .social-community .social-left,
  .social-community .social-right {
    display: none !important;
  }

  .community-bottom-nav {
    position: fixed;
    right: 0;
    left: 0;
    bottom: 0;
    z-index: 80;
    display: grid !important;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    min-height: calc(58px + env(safe-area-inset-bottom));
    padding: 5px 8px calc(5px + env(safe-area-inset-bottom));
    border-top: 1px solid #dbeafe;
    background: rgba(255, 255, 255, 0.97);
    box-shadow: 0 -10px 28px rgba(15, 23, 42, 0.1);
    backdrop-filter: blur(12px);
  }

  .community-bottom-nav button {
    display: grid;
    place-items: center;
    gap: 2px;
    border: 0;
    background: transparent;
    color: #475569;
    font-weight: 900;
    min-width: 0;
    padding: 4px 2px;
    border-radius: 14px;
  }

  .community-bottom-nav button span {
    font-size: 19px;
    line-height: 1;
  }

  .community-bottom-nav button b {
    font-size: 10px;
    line-height: 1.1;
  }

  .community-bottom-nav .primary {
    color: #fff;
    background: #0b63f6;
    transform: translateY(-10px) !important;
    box-shadow: 0 10px 24px rgba(11, 99, 246, 0.28);
  }

  .community-bottom-nav .primary span {
    font-size: 24px;
  }

  .community-bottom-nav .primary b {
    color: #fff;
  }

  .social-community .community-profile-page {
    padding-bottom: 0;
  }
}

/* Mobile sidebar layout fix only: prevent header/company/search/menu overlap */
@media (max-width: 768px) {
  body.mobile-nav-open .sidebar,
  body.mobile-nav-open .sidebar.is-collapsed,
  .sidebar.open,
  .sidebar.open.is-collapsed,
  body.phone-nav .sidebar,
  body.phone-nav .sidebar.is-collapsed,
  body.phone-landscape-nav .sidebar,
  body.phone-landscape-nav .sidebar.is-collapsed {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 12px !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
    padding: 14px 12px !important;
    box-sizing: border-box !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
  }

  body.mobile-nav-open .sidebar *,
  .sidebar.open *,
  body.phone-nav .sidebar *,
  body.phone-landscape-nav .sidebar * {
    box-sizing: border-box !important;
  }

  body.mobile-nav-open .sidebar > *,
  .sidebar.open > *,
  body.phone-nav .sidebar > *,
  body.phone-landscape-nav .sidebar > * {
    flex: 0 0 auto !important;
  }

  body.mobile-nav-open .sidebar .mobile-menu-close,
  .sidebar.open .mobile-menu-close,
  body.phone-nav .sidebar .mobile-menu-close,
  body.phone-landscape-nav .sidebar .mobile-menu-close {
    position: absolute !important;
    top: 12px !important;
    left: 12px !important;
    right: auto !important;
    z-index: 4 !important;
    width: 36px !important;
    height: 36px !important;
    min-height: 36px !important;
    margin: 0 !important;
    flex: 0 0 auto !important;
  }

  body.mobile-nav-open .sidebar .brand,
  body.mobile-nav-open .sidebar.is-collapsed .brand,
  .sidebar.open .brand,
  .sidebar.open.is-collapsed .brand,
  body.phone-nav .sidebar .brand,
  body.phone-nav .sidebar.is-collapsed .brand,
  body.phone-landscape-nav .sidebar .brand,
  body.phone-landscape-nav .sidebar.is-collapsed .brand {
    position: relative !important;
    display: grid !important;
    grid-template-columns: 56px minmax(0, 1fr) !important;
    align-items: center !important;
    gap: 12px !important;
    order: 1 !important;
    width: 100% !important;
    height: auto !important;
    min-height: fit-content !important;
    margin: 0 0 12px !important;
    padding: 16px 48px 16px 14px !important;
    transform: none !important;
    overflow: visible !important;
    z-index: 3 !important;
  }

  body.mobile-nav-open .sidebar .brand > div,
  body.mobile-nav-open .sidebar.is-collapsed .brand > div,
  .sidebar.open .brand > div,
  .sidebar.open.is-collapsed .brand > div,
  body.phone-nav .sidebar .brand > div,
  body.phone-nav .sidebar.is-collapsed .brand > div,
  body.phone-landscape-nav .sidebar .brand > div,
  body.phone-landscape-nav .sidebar.is-collapsed .brand > div {
    display: block !important;
    min-width: 0 !important;
    overflow: hidden !important;
  }

  body.mobile-nav-open .sidebar .brand strong,
  .sidebar.open .brand strong,
  body.phone-nav .sidebar .brand strong,
  body.phone-landscape-nav .sidebar .brand strong {
    display: block !important;
    white-space: normal !important;
    overflow-wrap: anywhere !important;
    line-height: 1.25 !important;
  }

  body.mobile-nav-open .sidebar .brand small,
  .sidebar.open .brand small,
  body.phone-nav .sidebar .brand small,
  body.phone-landscape-nav .sidebar .brand small {
    display: block !important;
    margin-top: 4px !important;
    line-height: 1.3 !important;
  }

  body.mobile-nav-open .sidebar .tenant-switcher,
  body.mobile-nav-open .sidebar.is-collapsed .tenant-switcher,
  .sidebar.open .tenant-switcher,
  .sidebar.open.is-collapsed .tenant-switcher,
  body.phone-nav .sidebar .tenant-switcher,
  body.phone-nav .sidebar.is-collapsed .tenant-switcher,
  body.phone-landscape-nav .sidebar .tenant-switcher,
  body.phone-landscape-nav .sidebar.is-collapsed .tenant-switcher {
    position: static !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 8px !important;
    order: 2 !important;
    width: 100% !important;
    height: auto !important;
    min-height: fit-content !important;
    margin: 0 0 12px !important;
    padding: 12px !important;
    transform: none !important;
    overflow: visible !important;
    z-index: 2 !important;
  }

  body.mobile-nav-open .sidebar .tenant-switcher label,
  .sidebar.open .tenant-switcher label,
  body.phone-nav .sidebar .tenant-switcher label,
  body.phone-landscape-nav .sidebar .tenant-switcher label {
    position: static !important;
    display: block !important;
    width: 100% !important;
    margin: 0 !important;
    transform: none !important;
  }

  body.mobile-nav-open .sidebar .tenant-switcher select,
  body.mobile-nav-open .sidebar.is-collapsed .tenant-switcher select,
  .sidebar.open .tenant-switcher select,
  .sidebar.open.is-collapsed .tenant-switcher select,
  body.phone-nav .sidebar .tenant-switcher select,
  body.phone-nav .sidebar.is-collapsed .tenant-switcher select,
  body.phone-landscape-nav .sidebar .tenant-switcher select,
  body.phone-landscape-nav .sidebar.is-collapsed .tenant-switcher select {
    position: static !important;
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
    min-height: 48px !important;
    margin: 0 !important;
    transform: none !important;
    z-index: 1 !important;
    pointer-events: none !important;
    appearance: none !important;
    -webkit-appearance: none !important;
  }

  body.mobile-nav-open .sidebar .nav,
  .sidebar.open .nav,
  body.phone-nav .sidebar .nav,
  body.phone-landscape-nav .sidebar .nav {
    display: flex !important;
    flex-direction: column !important;
    order: 3 !important;
    flex: 1 1 auto !important;
    min-height: 0 !important;
    width: 100% !important;
    overflow: visible !important;
  }

  body.mobile-nav-open .sidebar .erp-sidebar-shell,
  .sidebar.open .erp-sidebar-shell,
  body.phone-nav .sidebar .erp-sidebar-shell,
  body.phone-landscape-nav .sidebar .erp-sidebar-shell {
    display: flex !important;
    flex-direction: column !important;
    gap: 12px !important;
    width: 100% !important;
    min-height: 0 !important;
    height: auto !important;
    overflow: visible !important;
  }

  body.mobile-nav-open .sidebar .sidebar-tools,
  body.mobile-nav-open .sidebar .erp-sidebar-tools,
  body.mobile-nav-open .sidebar.is-collapsed .sidebar-tools,
  body.mobile-nav-open .sidebar.is-collapsed .erp-sidebar-tools,
  .sidebar.open .sidebar-tools,
  .sidebar.open .erp-sidebar-tools,
  .sidebar.open.is-collapsed .sidebar-tools,
  .sidebar.open.is-collapsed .erp-sidebar-tools,
  body.phone-nav .sidebar .sidebar-tools,
  body.phone-nav .sidebar .erp-sidebar-tools,
  body.phone-nav .sidebar.is-collapsed .sidebar-tools,
  body.phone-nav .sidebar.is-collapsed .erp-sidebar-tools,
  body.phone-landscape-nav .sidebar .sidebar-tools,
  body.phone-landscape-nav .sidebar .erp-sidebar-tools,
  body.phone-landscape-nav .sidebar.is-collapsed .sidebar-tools,
  body.phone-landscape-nav .sidebar.is-collapsed .erp-sidebar-tools {
    position: static !important;
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) 40px !important;
    gap: 8px !important;
    order: 1 !important;
    width: 100% !important;
    height: auto !important;
    min-height: fit-content !important;
    margin: 0 0 12px !important;
    transform: none !important;
    overflow: visible !important;
    z-index: 1 !important;
  }

  body.mobile-nav-open .sidebar .sidebar-search,
  body.mobile-nav-open .sidebar .erp-sidebar-search,
  body.mobile-nav-open .sidebar.is-collapsed .sidebar-search,
  body.mobile-nav-open .sidebar.is-collapsed .erp-sidebar-search,
  .sidebar.open .sidebar-search,
  .sidebar.open .erp-sidebar-search,
  .sidebar.open.is-collapsed .sidebar-search,
  .sidebar.open.is-collapsed .erp-sidebar-search,
  body.phone-nav .sidebar .sidebar-search,
  body.phone-nav .sidebar .erp-sidebar-search,
  body.phone-nav .sidebar.is-collapsed .sidebar-search,
  body.phone-nav .sidebar.is-collapsed .erp-sidebar-search,
  body.phone-landscape-nav .sidebar .sidebar-search,
  body.phone-landscape-nav .sidebar .erp-sidebar-search,
  body.phone-landscape-nav .sidebar.is-collapsed .sidebar-search,
  body.phone-landscape-nav .sidebar.is-collapsed .erp-sidebar-search {
    position: static !important;
    display: block !important;
    width: 100% !important;
    min-width: 0 !important;
    min-height: 44px !important;
    margin: 0 !important;
    transform: none !important;
  }

  body.mobile-nav-open .sidebar .erp-sidebar-scroll,
  .sidebar.open .erp-sidebar-scroll,
  body.phone-nav .sidebar .erp-sidebar-scroll,
  body.phone-landscape-nav .sidebar .erp-sidebar-scroll {
    position: static !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 10px !important;
    order: 2 !important;
    width: 100% !important;
    min-height: 0 !important;
    height: auto !important;
    overflow: visible !important;
    padding-bottom: 24px !important;
  }

  body.mobile-nav-open .sidebar .nav-section,
  body.mobile-nav-open .sidebar .erp-sidebar-section,
  .sidebar.open .nav-section,
  .sidebar.open .erp-sidebar-section,
  body.phone-nav .sidebar .nav-section,
  body.phone-nav .sidebar .erp-sidebar-section,
  body.phone-landscape-nav .sidebar .nav-section,
  body.phone-landscape-nav .sidebar .erp-sidebar-section {
    position: static !important;
    display: block !important;
    width: 100% !important;
    height: auto !important;
    min-height: fit-content !important;
    margin: 0 0 10px !important;
    transform: none !important;
    overflow: visible !important;
  }

  body.mobile-nav-open .sidebar .nav-section-toggle,
  body.mobile-nav-open .sidebar .erp-sidebar-section-toggle,
  body.mobile-nav-open .sidebar.is-collapsed .nav-section-toggle,
  body.mobile-nav-open .sidebar.is-collapsed .erp-sidebar-section-toggle,
  .sidebar.open .nav-section-toggle,
  .sidebar.open .erp-sidebar-section-toggle,
  .sidebar.open.is-collapsed .nav-section-toggle,
  .sidebar.open.is-collapsed .erp-sidebar-section-toggle,
  body.phone-nav .sidebar .nav-section-toggle,
  body.phone-nav .sidebar .erp-sidebar-section-toggle,
  body.phone-nav .sidebar.is-collapsed .nav-section-toggle,
  body.phone-nav .sidebar.is-collapsed .erp-sidebar-section-toggle,
  body.phone-landscape-nav .sidebar .nav-section-toggle,
  body.phone-landscape-nav .sidebar .erp-sidebar-section-toggle,
  body.phone-landscape-nav .sidebar.is-collapsed .nav-section-toggle,
  body.phone-landscape-nav .sidebar.is-collapsed .erp-sidebar-section-toggle {
    position: relative !important;
    display: grid !important;
    width: 100% !important;
    height: auto !important;
    min-height: 44px !important;
    margin: 0 !important;
    transform: none !important;
  }

  body.mobile-nav-open .sidebar .nav-section-items,
  body.mobile-nav-open .sidebar .erp-sidebar-section-items,
  .sidebar.open .nav-section-items,
  .sidebar.open .erp-sidebar-section-items,
  body.phone-nav .sidebar .nav-section-items,
  body.phone-nav .sidebar .erp-sidebar-section-items,
  body.phone-landscape-nav .sidebar .nav-section-items,
  body.phone-landscape-nav .sidebar .erp-sidebar-section-items {
    position: static !important;
    width: 100% !important;
    height: auto !important;
    margin: 0 !important;
    transform: none !important;
    overflow: hidden !important;
  }
}

/* Final override: draggable AI assistant floating button. Keep below all assistant/mobile rules. */
.assistant-widget {
  position: fixed !important;
  inset: 0 auto auto 0 !important;
  width: max-content !important;
  height: max-content !important;
  max-width: none !important;
  z-index: 12010 !important;
  transform: translate3d(var(--assistant-fab-x, calc(100vw - 96px)), var(--assistant-fab-y, calc(100vh - 96px)), 0) !important;
  pointer-events: none !important;
  will-change: transform;
  isolation: isolate;
}

.assistant-widget .assistant-fab {
  position: relative !important;
  inset: auto !important;
  width: 62px !important;
  height: 62px !important;
  pointer-events: auto !important;
  touch-action: none !important;
  user-select: none !important;
  -webkit-user-select: none !important;
  -webkit-tap-highlight-color: transparent !important;
  cursor: grab !important;
  will-change: transform;
}

.assistant-widget .assistant-fab:active,
.assistant-widget.is-dragging .assistant-fab {
  cursor: grabbing !important;
  transform: scale(1.045) !important;
  box-shadow: 0 24px 58px rgba(37, 99, 235, 0.42) !important;
}

body.assistant-fab-dragging {
  cursor: grabbing;
  overscroll-behavior: none;
}

.assistant-widget .assistant-panel {
  pointer-events: auto !important;
  inset: auto !important;
  bottom: 76px !important;
  right: auto !important;
  left: 0 !important;
}

.assistant-widget.open-left .assistant-panel {
  left: auto !important;
  right: 0 !important;
}

.assistant-widget:not(.open-up) .assistant-panel {
  top: 76px !important;
  bottom: auto !important;
}

.assistant-widget.open-up .assistant-panel {
  top: auto !important;
  bottom: 76px !important;
}

@media (max-width: 768px), (pointer: coarse) and (max-width: 980px) {
  .assistant-widget:not(.is-open) {
    position: fixed !important;
    inset: 0 auto auto 0 !important;
    width: max-content !important;
    max-width: none !important;
    transform: translate3d(var(--assistant-fab-x, calc(100vw - 84px)), var(--assistant-fab-y, calc(100dvh - 84px)), 0) !important;
    pointer-events: none !important;
    z-index: 12010 !important;
  }

  .assistant-widget:not(.is-open) .assistant-fab {
    display: grid !important;
    position: relative !important;
    inset: auto !important;
    width: 56px !important;
    height: 56px !important;
    pointer-events: auto !important;
  }

  .assistant-widget.is-open {
    position: fixed !important;
    inset: 0 !important;
    width: 100vw !important;
    height: 100dvh !important;
    max-width: 100vw !important;
    transform: none !important;
    pointer-events: none !important;
    z-index: 13000 !important;
  }

  .assistant-widget.is-open .assistant-panel {
    position: fixed !important;
    inset: auto 0 0 0 !important;
    width: 100vw !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
    pointer-events: auto !important;
  }
}
/* Chat UX final pass: message-area scroll only + circular send buttons. */
.chat-thread,
.assistant-messages,
.ai-messages {
  min-height: 0 !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  overscroll-behavior-y: contain !important;
  -webkit-overflow-scrolling: touch !important;
  scroll-behavior: smooth;
}

.chat-message,
.assistant-messages .ai-message,
.ai-messages .ai-message {
  animation: chatMessageIn .16s ease both;
}

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

.icon-send-button,
.chat-composer button.icon-send-button.primary[type="submit"],
.assistant-composer button.icon-send-button.primary[type="submit"],
.ai-composer button.icon-send-button.primary[type="submit"] {
  width: 48px !important;
  min-width: 48px !important;
  max-width: 48px !important;
  height: 48px !important;
  min-height: 48px !important;
  max-height: 48px !important;
  padding: 0 !important;
  border-radius: 999px !important;
  display: inline-grid !important;
  place-items: center !important;
  flex: 0 0 48px !important;
  color: #ffffff !important;
  background: #2563eb !important;
  border: 1px solid rgba(37, 99, 235, 0.75) !important;
  box-shadow: 0 8px 18px rgba(37, 99, 235, 0.2) !important;
  transition:
    background-color .15s ease,
    border-color .15s ease,
    color .15s ease,
    box-shadow .15s ease,
    opacity .15s ease,
    transform .12s ease !important;
}

.icon-send-button svg {
  width: 22px;
  height: 22px;
  display: block;
  transform: scaleX(-1);
}

[dir="ltr"] .icon-send-button svg {
  transform: none;
}

.icon-send-button:hover:not(:disabled) {
  background: #1d4ed8 !important;
  box-shadow: 0 10px 22px rgba(37, 99, 235, 0.28) !important;
}

.icon-send-button:active:not(:disabled) {
  transform: scale(.96) !important;
  box-shadow: 0 5px 12px rgba(37, 99, 235, 0.2) !important;
}

.icon-send-button:disabled {
  opacity: .48 !important;
  cursor: not-allowed !important;
  background: #94a3b8 !important;
  border-color: #94a3b8 !important;
  box-shadow: none !important;
}

.send-spinner {
  animation: sendSpinner .8s linear infinite;
}

@keyframes sendSpinner {
  to {
    transform: rotate(360deg) scaleX(-1);
  }
}

[dir="ltr"] .send-spinner {
  animation-name: sendSpinnerLtr;
}

@keyframes sendSpinnerLtr {
  to {
    transform: rotate(360deg);
  }
}

.assistant-composer,
.ai-composer,
.chat-composer {
  scroll-margin: 0 !important;
}

@media (max-width: 700px), (pointer: coarse) and (max-width: 980px) {
  .chat-composer button.icon-send-button.primary[type="submit"] {
    grid-column: 3 !important;
    width: 52px !important;
    min-width: 52px !important;
    height: 52px !important;
    min-height: 52px !important;
  }

  .assistant-composer button.icon-send-button.primary[type="submit"],
  .ai-composer button.icon-send-button.primary[type="submit"] {
    width: 46px !important;
    min-width: 46px !important;
    height: 46px !important;
    min-height: 46px !important;
  }
}

/* AI voice conversation: clear mobile-friendly controls without changing chat logic. */
.ai-live-voice-button,
.ai-live-voice-action {
  border: 1px solid rgba(37, 99, 235, 0.24) !important;
  background: #eff6ff !important;
  color: #1d4ed8 !important;
  font-weight: 800 !important;
}

.ai-live-voice-button.is-active,
.ai-live-voice-action.is-active {
  background: #2563eb !important;
  border-color: #2563eb !important;
  color: #fff !important;
  box-shadow: 0 10px 24px rgba(37, 99, 235, 0.22) !important;
}

.ai-live-voice-button.is-active {
  animation: assistantVoicePulse 1.15s ease-in-out infinite;
}

.assistant-live-voice-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 8px 12px 0;
  padding: 8px 10px;
  border-radius: 999px;
  border: 1px solid rgba(37, 99, 235, 0.18);
  background: #eff6ff;
  color: #1e40af;
  font-size: 0.82rem;
  font-weight: 800;
}

.assistant-live-voice-status span {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: #64748b;
}

.assistant-live-voice-status.is-listening span {
  background: #16a34a;
  box-shadow: 0 0 0 6px rgba(22, 163, 74, 0.14);
}

.ai-live-voice-row {
  align-items: center;
  gap: 10px;
}

.ai-live-voice-row .ai-live-voice-action {
  min-height: 38px;
  border-radius: 999px;
  padding: 0 14px;
}

@keyframes assistantVoicePulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.04); }
}

@media (max-width: 700px), (pointer: coarse) and (max-width: 980px) {
  .assistant-composer > div,
  .ai-composer-actions {
    gap: 8px !important;
  }

  .assistant-composer .ai-live-voice-button,
  .ai-composer-actions .ai-live-voice-button {
    width: 44px !important;
    min-width: 44px !important;
    height: 44px !important;
    min-height: 44px !important;
    border-radius: 999px !important;
  }

  .assistant-toolbar .ai-live-voice-action {
    flex: 1 1 130px;
    min-height: 36px;
    border-radius: 999px;
  }
}

/* Security/stability pass: keep Firebase sync and touch interactions visually stable. */
html,
body,
#app,
#root {
  overflow-x: hidden !important;
  max-width: 100% !important;
}

.firebase-sync-banner {
  contain: layout paint;
  flex-wrap: nowrap;
  transform: translateZ(0);
  will-change: opacity;
  transition:
    opacity .12s ease,
    background-color .12s ease,
    color .12s ease,
    border-color .12s ease !important;
}

.firebase-sync-banner .sync-dot,
.firebase-sync-banner.is-loading .sync-dot {
  animation: none !important;
  transform: none !important;
  opacity: 1 !important;
}

body.is-rendering .firebase-sync-banner,
body.is-rendering .main,
body.is-rendering .content-area,
body.is-rendering .dashboard-main {
  scroll-behavior: auto !important;
}

body.is-rendering :is(.modal, .modal-card, .main > section, .main > div:not(.firebase-sync-banner), .panel, .metric, .invoice-image-preview, .document-file-summary) {
  animation: none !important;
  transition-duration: 0s !important;
  transform: none !important;
}

.invoice-image-field,
.document-file-field,
.project-plan-file-field,
.invoice-image-preview {
  contain: layout paint style;
}

.invoice-image-field {
  min-height: 176px;
}

.invoice-image-preview {
  min-height: 112px;
}

.interactive-element {
  backface-visibility: hidden;
  transform: translateZ(0);
  transition:
    background-color .15s ease,
    border-color .15s ease,
    color .15s ease,
    box-shadow .15s ease,
    opacity .15s ease !important;
}

@media (max-width: 768px), (hover: none), (pointer: coarse) {
  *,
  *::before,
  *::after {
    animation-duration: .16s !important;
    transition-duration: .12s !important;
  }

  body {
    background-attachment: scroll !important;
    overscroll-behavior: none;
  }

  .panel,
  .card,
  .metric-card,
  .stat-card,
  .assistant-panel,
  .chat-panel,
  .modal-card,
  .topbar,
  .firebase-sync-banner {
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.10) !important;
  }

  body[data-theme="glass"] :is(.panel, .card, .metric-card, .provider-card, .stat-card, .modal-card, .assistant-panel, .chat-panel, .topbar, .table-wrap, .data-table-wrapper, .dropdown, .tools-menu-panel) {
    backdrop-filter: blur(6px) !important;
    -webkit-backdrop-filter: blur(6px) !important;
  }

  .card:hover,
  .metric-card:hover,
  .stat-card:hover,
  .interactive-element:hover {
    transform: translateZ(0) !important;
  }

  button:active,
  .interactive-element:active {
    transform: translateZ(0) !important;
  }
}

/* Public pages clarity pass: remove mojibake bullets and enforce readable contrast. */
.pricing-card li::before {
  content: "\2713" !important;
  color: #2563eb !important;
  font-weight: 900;
}

.public-language-toggle {
  border: 1px solid #bfdbfe !important;
  background: #eff6ff !important;
  color: #1d4ed8 !important;
  border-radius: 999px !important;
  padding-inline: 14px !important;
}

.login-hero,
.modern-login-card .login-hero,
.dashboard-premium-hero,
.platform-hero {
  color: #f8fafc !important;
}

.login-hero h1,
.login-hero h2,
.login-hero strong,
.modern-login-card .login-hero h1,
.modern-login-card .login-hero strong,
.dashboard-premium-hero h2,
.dashboard-premium-hero strong,
.platform-hero h2,
.platform-hero strong {
  color: #ffffff !important;
  text-shadow: 0 2px 14px rgba(15, 23, 42, 0.28);
}

.login-hero p,
.login-hero small,
.modern-login-card .login-hero p,
.modern-login-card .login-hero small,
.dashboard-premium-hero p,
.platform-hero p {
  color: rgba(248, 250, 252, 0.90) !important;
}

.login-benefits span,
.dashboard-quick-actions button {
  color: #eff6ff !important;
  background: rgba(255, 255, 255, 0.16) !important;
  border-color: rgba(255, 255, 255, 0.30) !important;
}

.landing-panel,
.pricing-page,
.pricing-card,
.public-info-section,
.login-form {
  color: #0f172a !important;
}

.landing-panel :is(h1, h2, h3, strong),
.pricing-page :is(h1, h2, h3, strong),
.pricing-card :is(h1, h2, h3, strong),
.public-info-section :is(h1, h2, h3, strong),
.login-form :is(h1, h2, h3, strong) {
  color: #0f172a !important;
  text-shadow: none !important;
}

.landing-panel :is(p, small, li),
.pricing-page :is(p, small, li),
.public-info-section :is(p, small, li),
.login-form :is(p, small, li) {
  color: #334155 !important;
}

/* Final interaction stability: pressing controls must never move or resize the app. */
html:not(.auth-screen-active) {
  scroll-behavior: auto !important;
}

.app :is(
  button,
  a[href],
  [role="button"],
  .interactive-element,
  .clickable,
  .card.clickable,
  .metric,
  .stat-card,
  .summary-card,
  .kpi-card,
  .dashboard-card,
  .provider-card,
  .portal-card,
  .government-card,
  .pricing-card,
  .theme-card
),
.provider-portal-shell :is(button, a[href], [role="button"], .interactive-element) {
  transition-property: color, background-color, border-color, box-shadow, opacity !important;
  will-change: auto !important;
}

.app :is(
  button,
  a[href],
  [role="button"],
  .interactive-element,
  .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),
.provider-portal-shell :is(button, a[href], [role="button"], .interactive-element):is(:hover, :active) {
  transform: none !important;
  translate: none !important;
}
/* Public AI customer support and the master support desk */
.public-support-widget {
  position: fixed !important;
  inset-inline-end: 22px;
  bottom: calc(22px + env(safe-area-inset-bottom, 0px));
  z-index: 12020;
  width: min(390px, calc(100vw - 28px));
  font-family: inherit;
  pointer-events: none;
}

.public-support-widget:not(.open) { width: max-content; max-width: calc(100vw - 28px); }

.public-support-launcher {
  margin-inline-start: auto;
  min-height: 52px;
  padding: 8px 16px 8px 9px;
  border: 1px solid #155bd7;
  border-radius: 8px;
  background: #0f5eea;
  color: #fff;
  box-shadow: 0 12px 28px rgb(15 68 150 / 24%);
  display: flex;
  align-items: center;
  gap: 10px;
  pointer-events: auto;
  isolation: isolate;
}

.public-support-launcher span {
  width: 34px;
  height: 34px;
  border-radius: 7px;
  display: grid;
  place-items: center;
  background: #fff;
  color: #0f5eea;
  font-weight: 800;
}

.public-support-launcher strong,
.public-support-panel > header strong { color: #fff; }

.public-support-panel {
  margin-bottom: 10px;
  overflow: hidden;
  border: 1px solid #c8d7ec;
  border-radius: 8px;
  background: #fff;
  color: #13213a;
  box-shadow: 0 20px 55px rgb(19 43 83 / 26%);
  pointer-events: auto;
}

.public-support-widget.open {
  display: flex;
  flex-direction: column-reverse;
}

.public-support-panel > header {
  min-height: 68px;
  padding: 12px 14px;
  background: #0c356f;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.public-support-panel > header div,
.public-support-panel > header small {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.public-support-panel > header small {
  flex-direction: row;
  align-items: center;
  color: #dce9fb;
}

.public-support-panel > header button {
  width: 34px;
  height: 34px;
  padding: 0;
  border-color: rgb(255 255 255 / 32%);
  background: transparent;
  color: #fff;
  font-size: 23px;
}

.support-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #37d17a;
}

.support-status-dot.waiting_human { background: #ffc247; }
.support-status-dot.resolved { background: #9cabbe; }

.public-support-messages {
  height: min(390px, 48vh);
  min-height: 250px;
  padding: 14px;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: #f4f7fb;
}

.public-support-message {
  width: fit-content;
  max-width: 88%;
  margin-bottom: 12px;
  padding: 9px 11px;
  border: 1px solid #d8e1ee;
  border-radius: 7px;
  background: #fff;
  box-shadow: 0 2px 7px rgb(28 55 92 / 7%);
}

.public-support-message.visitor {
  margin-inline-start: auto;
  border-color: #b9d2fa;
  background: #e8f1ff;
}

.public-support-message.admin {
  border-inline-start: 3px solid #15935b;
  background: #effbf5;
}

.public-support-message span,
.public-support-message time {
  display: block;
  color: #55708f;
  font-size: 11px;
}

.public-support-message p {
  margin: 4px 0;
  color: #142a47;
  line-height: 1.65;
  white-space: pre-wrap;
}

.support-typing {
  display: flex;
  align-items: center;
  gap: 5px;
  color: #5c708a;
  font-size: 12px;
}

.support-typing i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #2e6dd1;
  animation: supportTyping 1s infinite alternate;
}

.support-typing i:nth-child(2) { animation-delay: 150ms; }
.support-typing i:nth-child(3) { animation-delay: 300ms; }

@keyframes supportTyping {
  to { opacity: .3; transform: translateY(-2px); }
}

.public-support-panel form {
  padding: 10px;
  border-top: 1px solid #dbe3ef;
  background: #fff;
}

.public-support-contact-grid,
.public-support-compose {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.public-support-compose {
  grid-template-columns: minmax(0, 1fr) auto;
  margin-top: 8px;
  align-items: end;
}

.public-support-compose textarea {
  min-height: 48px;
  max-height: 110px;
  resize: vertical;
}

.public-support-compose button { min-height: 48px; }
.public-support-identity { display: flex; justify-content: space-between; gap: 8px; color: #526983; font-size: 12px; }
.public-support-error { margin: 0; padding: 8px 12px; background: #fff1f1; color: #a12222; font-size: 12px; }
.public-support-panel > footer { padding: 7px 10px; background: #f7f9fc; color: #65778d; text-align: center; font-size: 11px; }
.public-support-inline-button { width: 100%; margin-top: 8px; border-color: #7aa6e7; color: #164f9f; background: #f3f7fe; }
.support-honeypot { position: absolute !important; inset-inline-start: -10000px !important; width: 1px !important; height: 1px !important; opacity: 0 !important; }

.support-desk-page { display: grid; gap: 14px; }
.support-message-route-banner { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.support-message-route-banner h2 { margin-bottom: 4px; }
.support-desk-header { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.support-desk-header h2 { margin-bottom: 4px; }
.support-desk-stats { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; }
.support-desk-stats article { min-height: 96px; padding: 16px; border: 1px solid #d4dfed; border-radius: 8px; background: #fff; display: flex; flex-direction: column; justify-content: space-between; }
.support-desk-stats span { color: #526984; }
.support-desk-stats strong { color: #102c52; font-size: 28px; }
.support-desk-stats small { color: #718198; font-size: 11px; }
.support-desk-stats article.live { border-inline-start: 4px solid #148a55; background: #f5fcf8; }
.support-desk-stats article.urgent { border-inline-start: 4px solid #d24638; background: #fff8f7; }
.support-desk-sync { display: grid; justify-items: end; gap: 4px; color: #4f6682; font-size: 12px; }
.support-desk-sync > span { display: flex; align-items: center; gap: 7px; }
.support-live-dot { display: inline-block; width: 8px; height: 8px; margin-inline-end: 6px; border-radius: 50%; background: #aab5c3; vertical-align: 1px; }
.support-live-dot.online { background: #18a567; box-shadow: 0 0 0 3px rgba(24, 165, 103, .13); }
.support-desk-layout { display: grid; grid-template-columns: minmax(290px, 360px) minmax(0, 1fr); gap: 14px; min-height: 650px; }
.support-conversation-list { padding: 12px; overflow: hidden; }
.support-conversation-list form { display: grid; grid-template-columns: 1fr auto; gap: 7px; }
.support-filter-row { display: flex; gap: 6px; margin: 10px 0; overflow-x: auto; padding-bottom: 3px; }
.support-filter-row button { white-space: nowrap; padding: 7px 9px; }
.support-filter-row button.active { border-color: #2369d8; background: #eaf2ff; color: #1554b3; }
.support-conversation-scroll { height: 565px; overflow-y: auto; overscroll-behavior: contain; }
.support-conversation-card { width: 100%; margin-bottom: 7px; padding: 11px; border: 1px solid #d8e1ec; border-radius: 7px; background: #fff; color: #1a2d47; text-align: start; display: grid; gap: 6px; }
.support-conversation-card:hover,
.support-conversation-card.active { border-color: #4d85da; background: #f0f6ff; }
.support-conversation-card.needs-reply { border-inline-start: 4px solid #d24638; }
.support-conversation-card-head { display: flex; justify-content: space-between; gap: 7px; align-items: center; }
.support-conversation-card > span:not(.support-conversation-card-head) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #415a78; }
.support-conversation-card small { color: #72839a; }
.support-conversation-detail { padding: 0; overflow: hidden; display: grid; grid-template-rows: auto auto minmax(260px, 1fr) auto auto; }
.support-conversation-detail > header { padding: 15px; border-bottom: 1px solid #dce4ef; display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.support-conversation-detail > header h3,
.support-conversation-detail > header p { margin: 0; }
.support-conversation-meta { padding: 9px 15px; background: #f6f8fb; display: flex; flex-wrap: wrap; gap: 12px; color: #5d7089; font-size: 12px; }
.support-wait-pill { color: #a22d25; font-weight: 700; }
.support-ai-summary { margin: 10px 15px 0; padding: 10px 12px; border: 1px solid #cdddf2; border-radius: 7px; background: #f3f7fd; color: #284763; }
.support-ai-summary p { margin: 4px 0 0; line-height: 1.5; }
.support-admin-messages { padding: 16px; overflow-y: auto; background: #f5f7fa; }
.support-admin-message { width: fit-content; max-width: 82%; margin-bottom: 11px; padding: 10px 12px; border: 1px solid #d6e0ec; border-radius: 7px; background: #fff; }
.support-admin-message.visitor { margin-inline-start: auto; background: #e9f2ff; border-color: #bad3f7; }
.support-admin-message.admin { border-inline-start: 3px solid #15935b; background: #effbf5; }
.support-admin-message span,
.support-admin-message time { display: block; color: #62758d; font-size: 11px; }
.support-admin-message p { margin: 4px 0; white-space: pre-wrap; line-height: 1.6; }
.support-admin-actions { padding: 10px 15px; border-top: 1px solid #dce4ef; display: flex; gap: 8px; flex-wrap: wrap; }
#support-admin-reply-form { padding: 12px 15px; border-top: 1px solid #dce4ef; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 9px; align-items: end; }
#support-admin-reply-form textarea { min-height: 68px; resize: vertical; }
.support-live-notification-stack { position: fixed; z-index: 10020; inset-inline-end: 18px; top: 18px; width: min(390px, calc(100vw - 24px)); display: grid; gap: 9px; pointer-events: none; }
.support-live-notification { pointer-events: auto; display: grid; grid-template-columns: 38px minmax(0, 1fr) 30px; gap: 10px; align-items: start; padding: 13px; border: 1px solid #b9cce5; border-inline-start: 4px solid #d24638; border-radius: 8px; background: #fff; color: #173554; box-shadow: 0 14px 36px rgba(20, 45, 77, .18); cursor: pointer; animation: support-notification-enter 180ms ease-out both; }
.support-live-notification-icon { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 50%; background: #fff0ee; color: #b32e24; font-weight: 800; }
.support-live-notification strong { display: block; margin-bottom: 3px; }
.support-live-notification p { margin: 0 0 3px; color: #405b76; line-height: 1.45; }
.support-live-notification small { color: #1a64bd; font-weight: 700; }
.support-live-notification button { min-width: 28px; min-height: 28px; padding: 0; border: 0; background: transparent; color: #64758a; font-size: 22px; }
@keyframes support-notification-enter { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }

@media (max-width: 900px) {
  .support-desk-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .support-desk-layout { grid-template-columns: 1fr; min-height: 0; }
  .support-conversation-scroll { height: 330px; }
  .support-conversation-detail { min-height: 620px; }
}

@media (max-width: 560px) {
  .public-support-widget { inset-inline-end: 12px; bottom: calc(12px + env(safe-area-inset-bottom, 0px)); width: calc(100vw - 24px); }
  .public-support-widget:not(.open) { width: 60px; }
  .public-support-widget:not(.open) .public-support-launcher { width: 60px; min-width: 60px; height: 60px; min-height: 60px; padding: 0; border-radius: 50%; justify-content: center; box-shadow: 0 16px 38px rgb(15 68 150 / 32%); }
  .public-support-widget:not(.open) .public-support-launcher span { width: 40px; height: 40px; border-radius: 50%; }
  .public-support-widget:not(.open) .public-support-launcher strong { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .public-support-widget.open .public-support-launcher { display: none; }
  .public-support-messages { height: 46vh; }
  .public-support-contact-grid { grid-template-columns: 1fr; }
  .support-desk-header { align-items: flex-start; flex-direction: column; }
  .support-desk-sync { justify-items: start; }
  .support-message-route-banner { align-items: stretch; flex-direction: column; }
  .support-desk-stats { grid-template-columns: 1fr 1fr; }
  .support-desk-stats article { min-height: 82px; padding: 12px; }
  .support-live-notification-stack { inset-inline-end: 8px; top: 8px; width: calc(100vw - 16px); }
  #support-admin-reply-form { grid-template-columns: 1fr; }
}
