.companies-page {
  padding: 0 0 40px;
  max-width: 100%;
  margin: 0 auto;
}

.companies-viewbar {
  margin-bottom: 24px;
}

.companies-tabs {
  display: flex;
  align-items: center;
  gap: 24px;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  white-space: nowrap;
  scrollbar-width: none;
}

.companies-tabs::-webkit-scrollbar {
  display: none;
}

.companies-tab {
  position: relative;
  padding: 8px 0;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: 0;
  background: transparent;
  white-space: nowrap;
}

.companies-tab.is-active {
  color: var(--brand);
  font-weight: 600;
}

.companies-tab.is-active::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 2px;
  background: var(--brand);
  border-radius: 2px;
}

.companies-tab--add {
  color: var(--brand);
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.companies-filter-select {
  min-width: 140px;
}

.companies-filter-select .custom-select__trigger {
  font-size: 13px;
}

.companies-table-card {
  margin-top: 2px;
}

.companies-table {
  min-width: 900px;
}

.companies-check-cell {
  width: 40px;
  text-align: center !important;
  padding-left: 10px !important;
  padding-right: 6px !important;
}

.companies-check-cell input {
  width: 14px;
  height: 14px;
  accent-color: var(--brand);
}

.company-name-link {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 190px;
  text-decoration: none;
  color: var(--text);
}

.company-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  border-radius: var(--radius-sm);
  background: var(--surface-3);
  color: var(--text);
  font-size: 11px;
  font-weight: 600;
}

.company-name-copy {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.company-name-copy strong {
  font-size: 14px;
  color: var(--brand);
  font-weight: 600;
  white-space: nowrap;
}

.company-name-copy small {
  font-size: 12px;
  color: var(--text-subtle);
  line-height: 1.3;
}

.companies-empty {
  padding: 70px 20px;
  text-align: center;
  background: var(--surface);
}

.companies-empty-icon {
  width: 52px;
  height: 52px;
  margin: 0 auto 12px;
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-2);
  color: var(--text-subtle);
}

.companies-empty h3 {
  font-size: 15px;
  margin-bottom: 5px;
}

.companies-empty p {
  font-size: 12.5px;
  color: var(--text-muted);
  margin-bottom: 14px;
}

.companies-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 4px 0;
  color: var(--text-muted);
  font-size: 12.5px;
}

.companies-pagination-actions {
  display: flex;
  gap: 7px;
}

.companies-page-arrow {
  width: 34px;
  height: 34px;
  padding: 0 !important;
}

.companies-page-arrow:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.companies-fixed-bar {
  position: fixed;
  z-index: 45;
  left: var(--sidebar-w);
  right: 0;
  bottom: 0;
  min-height: 58px;
  padding: 10px clamp(16px, 3vw, 40px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
}

.companies-total {
  font-size: 13px;
  color: var(--text-muted);
}

.companies-total strong {
  color: var(--text);
  font-weight: 700;
}

.companies-fixed-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

[data-tooltip] {
  position: relative;
}

[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  z-index: 10020;
  left: 50%;
  bottom: calc(100% + 8px);
  transform: translate(-50%, 4px);
  opacity: 0;
  pointer-events: none;
  white-space: nowrap;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  background: var(--text);
  color: var(--bg);
  font-size: 11px;
  font-weight: 500;
  box-shadow: var(--shadow-sm);
  transition:
    opacity var(--fast) var(--ease),
    transform var(--fast) var(--ease);
}

[data-tooltip]:hover::after,
[data-tooltip]:focus-visible::after {
  opacity: 1;
  transform: translate(-50%, 0);
}
.modal__body.crm-d-grid.crm-gap-3 {
  max-height: 470px;
}
@media (max-width: 991.98px) {
  .companies-fixed-bar {
    left: 0;
    padding: 9px 16px;
    width: 100%;
    max-width: 100%;
  }

  .companies-fixed-actions {
    overflow: auto;
    margin-left: 0;
  }

  .companies-filter-select {
    flex: 0 0 auto;
  }

  .companies-tabs {
    gap: 20px;
  }
}

@media (max-width: 767.98px) {
  .companies-fixed-bar {
    bottom: var(--mobile-nav-h, 0);
  }
  .companies-page {
    padding: 0 0 60px;
  }
  .companies-fixed-bar {
    align-items: flex-start;
    flex-direction: column;
    gap: 7px;
  }

  .companies-fixed-actions {
    width: 100%;
  }

  .companies-fixed-actions .btn-crm {
    flex: 0 0 auto;
  }

  .companies-pagination {
    padding-bottom: 4px;
  }

  .companies-filter-select {
    min-width: 140px;
  }

  .filters-bar {
    flex-wrap: nowrap;
    overflow: auto;
    padding-bottom: 10px;
  }
}

/* Lock the Companies page viewport while a right-side drawer is open. */
html.company-drawer-open,
html.company-drawer-open body,
body.company-drawer-open {
  overflow: hidden !important;
  overscroll-behavior: none !important;
}

body.company-drawer-open {
  touch-action: none;
}

/* The drawer remains the only scrollable area. */
.company-create-drawer.popup-drawer,
.company-edit-drawer.popup-drawer {
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
}

.company-create-drawer .popup-body-form,
.company-edit-drawer .popup-body-form {
  min-height: 0;
  height: auto;
  overflow-y: auto !important;
  overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.company-create-overlay,
.company-edit-overlay {
  touch-action: none;
}
