.company-directory {
  --company-text: #243044;
  --company-muted: #667387;
  --company-line: #dce3ed;
  --company-soft: #f2f5fa;
  --company-accent: #315fb8;
}
html[data-theme="dark"] .company-directory {
  --company-text: #edf0f6;
  --company-muted: #a6b1c1;
  --company-line: #354052;
  --company-soft: #242e3d;
  --company-accent: #a9c6ff;
}
:is(#companies-table, #factories-table, #profiles-table) {
  width: 100% !important;
  min-width: 0;
  table-layout: fixed;
  border-collapse: collapse;
  border-bottom: 0;
  background: transparent;
  color: var(--company-text);
}
:is(#companies-table, #factories-table, #profiles-table) thead th {
  padding: 12px 28px 14px 12px;
  border-bottom: 1px solid var(--company-line);
  color: var(--company-muted);
  font-size: .8rem;
  font-weight: 500;
}
:is(#companies-table, #factories-table, #profiles-table) thead th:nth-child(2) { width: 20%; }
:is(#companies-table, #factories-table, #profiles-table) thead th:nth-child(3) { width: 100px; text-align: right; }
:is(#companies-table, #factories-table, #profiles-table) thead th:nth-child(4) { width: 270px; }
:is(#companies-table, #factories-table, #profiles-table) tbody tr {
  background: transparent;
  transition: background-color .22s ease, transform .22s ease;
}
:is(#companies-table, #factories-table, #profiles-table) tbody td {
  padding: 20px 12px;
  vertical-align: middle;
  border: 0;
  border-bottom: 1px solid var(--company-line);
  background: transparent;
  box-shadow: none;
}
:is(#companies-table, #factories-table, #profiles-table) tbody tr:focus-within { background: var(--company-soft); }
.company-directory__identity { display: flex; align-items: center; gap: 12px; min-width: 0; }
.company-directory__avatar {
  position: relative;
  display: grid; place-items: center;
  flex: 0 0 42px; width: 42px; height: 42px;
  border-radius: 10px; background: var(--company-soft);
  color: var(--company-accent); font-size: .85rem; font-weight: 600;
  overflow: hidden; text-decoration: none;
  transition: transform .22s cubic-bezier(.22,1,.36,1), outline-color .22s ease;
}
.company-directory__avatar:hover { outline: 1px solid var(--company-accent); }
.company-directory__logo { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; padding: 4px; opacity: 0; }
.company-directory__avatar.has-logo { background: #fff; }
.company-directory__avatar.has-logo .company-directory__logo { opacity: 1; }
.company-directory__avatar.has-logo .company-directory__avatar-initials { visibility: hidden; }
.company-directory__details { min-width: 0; }
.company-directory__heading { display: flex; align-items: baseline; gap: 5px; }
.company-directory__link {
  color: var(--company-text); font-weight: 600; font-size: .95rem;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  transition: color .18s ease;
}
.company-directory__link:hover { color: var(--company-accent); text-decoration: underline; }
.company-directory__heading .premium-icon { flex-shrink: 0; margin: 0; }
.company-directory__discipline {
  color: var(--company-muted); font-size: .85rem;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
:is(#companies-table, #factories-table, #profiles-table) .company-directory__projects { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.company-state-preview { display: flex; align-items: center; flex-wrap: nowrap; gap: 5px; min-height: 32px; }
.company-state-badge {
  display: inline-block; padding: 5px 7px; border-radius: 5px;
  background: var(--company-soft); color: var(--company-text);
  font-size: .75rem; line-height: 1.4;
  max-width: 68px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  transition: transform .18s ease;
}
.company-states-more {
  flex-shrink: 0; min-height: 36px; padding: 5px 8px; border: 1px solid var(--company-line);
  border-radius: 6px; background: transparent; color: var(--company-accent);
  font: inherit; font-size: .75rem; white-space: nowrap; cursor: pointer;
  transition: background-color .18s ease, border-color .18s ease, transform .18s ease;
}
.company-states-more:hover { background: var(--company-soft); }
.company-states-more:focus-visible, .company-directory__link:focus-visible, .company-directory__avatar:focus-visible { outline: 2px solid #648cf2; outline-offset: 2px; }
.company-states-empty { color: var(--company-muted); font-size: .8rem; }
.company-states-popover {
  position: fixed; z-index: 20000; box-sizing: border-box;
  display: flex; flex-direction: column; gap: 12px;
  padding: 16px; border: 1px solid #dce3ed; border-radius: 12px;
  background: #fff; color: #243044; box-shadow: 0 12px 32px #0b142522;
  animation: company-popover-enter .18s cubic-bezier(.22,1,.36,1) both;
  transform-origin: top center;
}
html[data-theme="dark"] .company-states-popover { background: #1b2637; color: #edf0f6; border-color: #354052; box-shadow: 0 12px 32px #0004; }
.company-states-popover__header { display: flex; align-items: start; justify-content: space-between; gap: 12px; flex-shrink: 0; }
.company-states-popover h2 { font-size: .95rem; font-weight: 600; margin: 0; }
.company-states-popover p { margin: 4px 0 0; font-size: .8rem; opacity: .8; }
.company-states-popover__close { min-width: 36px; min-height: 36px; padding: 4px; border: 0; border-radius: 6px; background: transparent; color: inherit; font: inherit; font-size: 1.25rem; cursor: pointer; }
.company-states-popover__close:hover { background: #8593a522; }
.company-states-popover__list { display: flex; align-content: start; flex-wrap: wrap; gap: 6px; overflow-y: auto; min-height: 0; overscroll-behavior: contain; }
.company-states-popover .company-state-badge { background: #f2f5fa; color: #243044; max-width: none; white-space: normal; overflow-wrap: anywhere; }
html[data-theme="dark"] .company-states-popover .company-state-badge { background: #29364a; color: #edf0f6; }
@keyframes company-popover-enter {
  from { opacity: 0; transform: translateY(5px) scale(.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.company-hover-preview {
  --preview-bg: #fff; --preview-text: #243044; --preview-muted: #667387;
  --preview-line: #dce3ed; --preview-soft: #f2f5fa; --preview-accent: #315fb8;
  position: fixed; z-index: 19990; display: flex; flex-direction: column;
  box-sizing: border-box; padding: 20px; gap: 16px;
  background: var(--preview-bg); color: var(--preview-text);
  border: 1px solid var(--preview-line); border-radius: 14px;
  box-shadow: 0 12px 32px #0b142522;
  animation: company-popover-enter .18s ease both;
}
html[data-theme="dark"] .company-hover-preview {
  --preview-bg: #1b2637; --preview-text: #edf0f6; --preview-muted: #a6b1c1;
  --preview-line: #354052; --preview-soft: #29364a; --preview-accent: #a9c6ff;
  box-shadow: 0 12px 32px #0004;
}
.company-hover-preview__header { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.company-hover-preview__header h2 { flex: 1; min-width: 0; margin: 0; font-size: 1rem; font-weight: 600; line-height: 1.4; overflow-wrap: anywhere; }
.company-hover-preview__avatar { position: relative; display: grid; place-items: center; flex: 0 0 48px; width: 48px; height: 48px; overflow: hidden; border-radius: 10px; background: var(--preview-soft); color: var(--preview-accent); font-size: .9rem; font-weight: 600; }
.company-hover-preview__avatar.has-logo { background: #fff; }
.company-hover-preview__avatar img { position: absolute; inset: 0; width: 100%; height: 100%; padding: 5px; object-fit: contain; background: #fff; }
.company-hover-preview__close { align-self: start; flex-shrink: 0; width: 32px; height: 32px; margin: -8px -8px 0 0; border: 0; border-radius: 6px; background: transparent; color: var(--preview-muted); font: inherit; font-size: 1.25rem; cursor: pointer; }
.company-hover-preview__close:hover { background: var(--preview-soft); color: var(--preview-text); }
.company-hover-preview__body { min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.company-hover-preview__body { display: grid; gap: 16px; }
.company-hover-preview__contact a { display: inline-block; margin-top: 5px; color: var(--preview-accent); font-size: .9rem; overflow-wrap: anywhere; }
.company-hover-preview__contact a:hover { text-decoration: underline; }
.company-hover-preview p { margin: 0; }
.company-hover-preview .company-hover-preview__location { margin-top: 6px; font-size: .8rem; color: var(--preview-muted); }
.company-hover-preview__label { font-size: .75rem; color: var(--preview-muted); }
.company-hover-preview__details { flex-shrink: 0; display: block; padding-top: 14px; border-top: 1px solid var(--preview-line); color: var(--preview-accent); font-size: .85rem; font-weight: 600; }
.company-hover-preview__details:hover { color: var(--preview-accent); text-decoration: underline; }
.company-hover-preview__details:focus-visible, .company-hover-preview__close:focus-visible { outline: 2px solid #648cf2; outline-offset: 2px; }
.company-directory :is(#companies-table, #factories-table, #profiles-table) thead th,
.company-directory .pm-select__trigger,
.directory-filters #clearFiltersBtn {
  transition: color .18s ease, background-color .18s ease, border-color .18s ease, transform .18s ease;
}
@media (hover: hover) and (pointer: fine) {
  :is(#companies-table, #factories-table, #profiles-table) tbody tr:hover { background: var(--company-soft); transform: translateY(-2px); }
  :is(#companies-table, #factories-table, #profiles-table) tbody tr:hover .company-directory__avatar { transform: scale(1.06); }
  :is(#companies-table, #factories-table, #profiles-table) tbody tr:hover .company-directory__link { color: var(--company-accent); }
  :is(#companies-table, #factories-table, #profiles-table) thead th:hover { color: var(--company-accent); background-color: var(--company-soft); }
  .company-state-badge:hover { transform: translateY(-2px); }
  .company-states-more:hover { transform: translateY(-2px); border-color: var(--company-accent); }
  .company-directory .pm-select__trigger:hover,
  .directory-filters #clearFiltersBtn:hover { transform: translateY(-1px); }
}
.company-states-more:active, .company-directory__avatar:active,
.company-directory .pm-select__trigger:active, .directory-filters #clearFiltersBtn:active { transform: translateY(1px); }
@media (prefers-reduced-motion: reduce) {
  :is(#companies-table, #factories-table, #profiles-table) tbody tr, .company-directory__avatar, .company-directory__link,
  .company-state-badge, .company-states-more, .company-directory :is(#companies-table, #factories-table, #profiles-table) thead th,
  .company-directory .pm-select__trigger, .directory-filters #clearFiltersBtn {
    transition: none;
  }
  :is(#companies-table, #factories-table, #profiles-table) tbody tr:hover, :is(#companies-table, #factories-table, #profiles-table) tbody tr:hover .company-directory__avatar,
  .company-state-badge:hover, .company-states-more, .company-directory__avatar:active,
  .company-directory .pm-select__trigger, .directory-filters #clearFiltersBtn { transform: none !important; }
  .company-states-popover, .company-hover-preview { animation: none; }
}
@media (max-width: 768px) {
  :is(#companies-table, #factories-table, #profiles-table), :is(#companies-table, #factories-table, #profiles-table) tbody { display: block; width: 100%; min-width: 0; }
  :is(#companies-table, #factories-table, #profiles-table) thead { display: block; }
  :is(#companies-table, #factories-table, #profiles-table) thead tr { display: flex; gap: 8px; flex-wrap: wrap; padding-bottom: 8px; }
  :is(#companies-table, #factories-table, #profiles-table) thead th { width: auto; flex: 1 1 auto; padding: 12px 25px 12px 8px; border: 1px solid var(--company-line); border-radius: 8px; font-size: .75rem; }
  :is(#companies-table, #factories-table, #profiles-table) thead th:nth-child(2), :is(#companies-table, #factories-table, #profiles-table) thead th:nth-child(3), :is(#companies-table, #factories-table, #profiles-table) thead th:nth-child(4) { width: auto; text-align: left; }
  :is(#companies-table, #factories-table, #profiles-table) tbody tr { display: grid; grid-template-columns: minmax(0, 1fr) 52px; align-items: center; gap: 10px; padding: 16px 0; border-bottom: 1px solid var(--company-line); }
  :is(#companies-table, #factories-table, #profiles-table) tbody td { display: block; padding: 0; border: 0; }
  :is(#companies-table, #factories-table, #profiles-table) .company-directory__name { grid-column: 1; grid-row: 1; }
  :is(#companies-table, #factories-table, #profiles-table) .company-directory__projects { grid-column: 2; grid-row: 1; }
  :is(#companies-table, #factories-table, #profiles-table) .company-directory__discipline, :is(#companies-table, #factories-table, #profiles-table) .company-directory__states { grid-column: 1 / -1; padding-left: 54px; }
  :is(#companies-table, #factories-table, #profiles-table) .dataTables_empty { grid-column: 1 / -1; }
  .company-states-more { min-height: 44px; }
}
