:root {
  --company-green: #08783f;
  --company-green-dark: #075d35;
  --company-green-soft: #e8f7ef;
  --company-ink: #101827;
  --company-muted: #64748b;
  --company-line: #e4eaf0;
  --company-surface: #ffffff;
}

.companies-page-shell {
  display: grid;
  gap: 20px;
  min-width: 0;
  padding-bottom: 28px;
}

.companies-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 12px;
}

.companies-mobile-heading {
  display: none;
}

.companies-action-buttons {
  display: flex;
  gap: 10px;
}

.companies-button {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 0 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  background: #fff;
  color: var(--company-ink);
  font: inherit;
  font-size: 0.88rem;
  font-weight: 800;
  cursor: pointer;
  transition:
    transform 160ms ease,
    box-shadow 160ms ease,
    background-color 160ms ease;
}

.companies-button:hover {
  transform: translateY(-1px);
}

.companies-button:focus-visible,
.company-drawer-close:focus-visible,
.company-row-action:focus-visible {
  outline: 3px solid rgba(8, 120, 63, 0.2);
  outline-offset: 2px;
}

.companies-button.primary {
  background: linear-gradient(135deg, #0b8a4a, #067138);
  color: #fff;
  box-shadow: 0 10px 24px rgba(8, 120, 63, 0.2);
}

.companies-button.secondary,
.companies-button.filter-reset {
  border-color: var(--company-line);
}

.companies-button:disabled {
  opacity: 0.6;
  cursor: wait;
  transform: none;
}

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

.company-kpi-card {
  min-height: 112px;
  display: flex;
  align-items: center;
  gap: 15px;
  padding: 18px;
  border: 1px solid var(--company-line);
  border-radius: 15px;
  background: var(--company-surface);
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.045);
}

.company-kpi-icon {
  width: 50px;
  height: 50px;
  flex: 0 0 50px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-size: 1.15rem;
}

.company-kpi-icon.green,
.company-kpi-icon.emerald {
  background: #e1f6e9;
  color: #079447;
}

.company-kpi-icon.blue {
  background: #e8f0ff;
  color: #2563eb;
}

.company-kpi-icon.violet {
  background: #f0ebff;
  color: #7c3aed;
}

.company-kpi-card p,
.company-kpi-card strong,
.company-kpi-card small {
  display: block;
  margin: 0;
}

.company-kpi-card p {
  color: var(--company-muted);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.035em;
  text-transform: uppercase;
}

.company-kpi-card strong {
  margin-top: 4px;
  color: var(--company-ink);
  font-size: 1.5rem;
  line-height: 1;
}

.company-kpi-card small {
  margin-top: 8px;
  color: #0a9448;
  font-size: 0.75rem;
  font-weight: 700;
}

.companies-directory-card,
.company-insight-card {
  border: 1px solid var(--company-line);
  border-radius: 15px;
  background: #fff;
  box-shadow: 0 14px 36px rgba(15, 23, 42, 0.045);
}

.companies-filter-bar {
  display: grid;
  grid-template-columns: minmax(260px, 1.5fr) minmax(150px, 0.7fr) minmax(150px, 0.7fr) auto;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid #edf1f5;
}

.companies-search,
.companies-select-filter {
  min-height: 43px;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid #dce3e9;
  border-radius: 9px;
  background: #fff;
  color: #64748b;
}

.companies-search {
  padding: 0 13px;
}

.companies-search input,
.companies-select-filter select {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--company-ink);
  font: inherit;
  font-size: 0.84rem;
}

.companies-select-filter select {
  height: 100%;
  padding: 0 12px;
  cursor: pointer;
}

.companies-list-heading {
  min-height: 54px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.companies-list-heading h3,
.company-insight-card h3 {
  margin: 0;
  color: var(--company-ink);
  font-size: 0.88rem;
  font-weight: 900;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.companies-list-heading span {
  color: var(--company-muted);
  font-size: 0.8rem;
  font-weight: 700;
}

.companies-table-scroll {
  overflow-x: auto;
}

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

.companies-row {
  display: grid;
  grid-template-columns: minmax(200px, 1.35fr) minmax(175px, 1.05fr) minmax(160px, 1fr) 135px 82px 78px 95px 64px;
  align-items: center;
  min-height: 74px;
  padding: 0 16px;
  border-top: 1px solid #edf1f5;
  color: var(--company-ink);
  font-size: 0.82rem;
}

.companies-head {
  min-height: 44px;
  border-top: 0;
  background: #f8fafc;
  color: #59677a;
  font-size: 0.72rem;
  font-weight: 800;
}

.company-identity,
.company-contact,
.company-location-cell {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 11px;
}

.company-avatar {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #e4f6eb;
  color: #08783f;
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.04em;
}

.company-cell-copy {
  min-width: 0;
}

.company-cell-copy strong,
.company-cell-copy small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.company-cell-copy strong {
  font-weight: 850;
}

.company-cell-copy small {
  margin-top: 4px;
  color: var(--company-muted);
  font-size: 0.72rem;
}

.company-metric-cell {
  font-weight: 850;
}

.company-metric-cell small {
  display: block;
  margin-top: 3px;
  color: var(--company-muted);
  font-weight: 650;
}

.company-status-pill {
  width: max-content;
  min-width: 70px;
  padding: 6px 10px;
  border-radius: 999px;
  text-align: center;
  font-size: 0.7rem;
  font-weight: 850;
  text-transform: capitalize;
}

.company-status-pill.active {
  background: #e4f8ea;
  color: #08843e;
}

.company-status-pill.inactive {
  background: #edf1f5;
  color: #64748b;
}

.company-status-pill.suspended {
  background: #fee9e7;
  color: #c52c25;
}

.company-category-cell {
  min-width: 0;
}

.company-category-badge {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  min-height: 28px;
  padding: 5px 9px;
  border-radius: 999px;
  background: #eef7f2;
  color: #176b47;
  font-size: 0.74rem;
  font-weight: 800;
  line-height: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.company-row-action {
  width: 34px;
  height: 34px;
  border: 1px solid #dfe6ec;
  border-radius: 8px;
  background: #fff;
  color: #334155;
  cursor: pointer;
}

.company-action-menu {
  position: relative;
}

.company-action-popover {
  position: absolute;
  z-index: 20;
  top: calc(100% + 6px);
  right: 0;
  width: 155px;
  padding: 6px;
  border: 1px solid var(--company-line);
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 16px 38px rgba(15, 23, 42, 0.16);
}

.company-action-popover button {
  width: 100%;
  min-height: 36px;
  padding: 0 10px;
  display: flex;
  align-items: center;
  gap: 9px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: #263244;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
}

.company-action-popover button:hover {
  background: #f1f7f4;
  color: var(--company-green);
}

.companies-pagination {
  min-height: 64px;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 7px;
  border-top: 1px solid #edf1f5;
}

.companies-pagination button {
  width: 35px;
  height: 35px;
  border: 1px solid #dfe6ec;
  border-radius: 8px;
  background: #fff;
  color: #334155;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 800;
  cursor: pointer;
}

.companies-pagination button.active {
  border-color: #0b9650;
  color: #07723d;
  box-shadow: inset 0 0 0 1px #0b9650;
}

.companies-pagination button:disabled {
  opacity: 0.4;
  cursor: default;
}

.companies-empty,
.companies-loading {
  min-height: 250px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 9px;
  padding: 30px;
  border-top: 1px solid #edf1f5;
  text-align: center;
}

.companies-empty > span {
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--company-green-soft);
  color: var(--company-green);
  font-size: 1.4rem;
}

.companies-empty h3,
.companies-empty p,
.companies-loading p {
  margin: 0;
}

.companies-empty p,
.companies-loading p {
  color: var(--company-muted);
  font-size: 0.84rem;
}

.companies-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid #dcefe4;
  border-top-color: var(--company-green);
  border-radius: 50%;
  animation: company-spin 750ms linear infinite;
}

@keyframes company-spin {
  to { transform: rotate(360deg); }
}

.companies-insights-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.company-insight-card {
  min-height: 250px;
  padding: 18px;
}

.company-status-visual {
  min-height: 185px;
  display: grid;
  grid-template-columns: 130px 1fr;
  align-items: center;
  gap: 18px;
}

.company-donut {
  width: 120px;
  height: 120px;
  position: relative;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: conic-gradient(#dce3e9 0deg 360deg);
}

.company-donut::after {
  content: "";
  width: 72px;
  height: 72px;
  position: absolute;
  border-radius: 50%;
  background: #fff;
}

.company-donut span {
  position: relative;
  z-index: 1;
  color: var(--company-ink);
  font-size: 1.25rem;
  font-weight: 900;
}

.company-chart-legend {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.company-chart-legend li {
  display: grid;
  grid-template-columns: 9px 1fr auto;
  align-items: center;
  gap: 8px;
  color: #475569;
  font-size: 0.78rem;
}

.company-chart-legend i {
  width: 9px;
  height: 9px;
  border-radius: 3px;
}

.company-chart-legend strong {
  color: var(--company-ink);
}

.company-bar-chart {
  min-height: 188px;
  padding-top: 20px;
  display: grid;
  align-content: start;
  gap: 13px;
}

.company-bar-row {
  display: grid;
  grid-template-columns: minmax(90px, 0.8fr) minmax(100px, 1.5fr) auto;
  align-items: center;
  gap: 9px;
  font-size: 0.75rem;
}

.company-bar-row > span:first-child {
  overflow: hidden;
  color: #475569;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.company-bar-track {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #edf2f6;
}

.company-bar-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #12a55b, #06813f);
}

.company-bar-row strong {
  color: var(--company-ink);
}

.company-chart-empty {
  min-height: 145px;
  display: grid;
  place-items: center;
  color: var(--company-muted);
  font-size: 0.8rem;
  text-align: center;
}

.company-drawer-backdrop {
  position: fixed;
  z-index: 1190;
  inset: 0;
  background: rgba(8, 18, 30, 0.48);
  backdrop-filter: blur(3px);
}

.company-drawer {
  width: min(680px, 94vw);
  position: fixed;
  z-index: 1200;
  top: 0;
  right: 0;
  bottom: 0;
  background: #f7f9fb;
  box-shadow: -24px 0 60px rgba(15, 23, 42, 0.2);
}

.company-drawer > form {
  height: 100%;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
}

.company-drawer-header,
.company-drawer-footer {
  background: #fff;
}

.company-drawer-header {
  min-height: 98px;
  padding: 20px 24px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 1px solid var(--company-line);
}

.companies-eyebrow {
  margin: 0 0 4px;
  color: var(--company-green);
  font-size: 0.7rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.company-drawer-header h2,
.company-drawer-header p {
  margin: 0;
}

.company-drawer-header h2 {
  color: var(--company-ink);
  font-size: 1.35rem;
}

.company-drawer-header p:last-child {
  margin-top: 5px;
  color: var(--company-muted);
  font-size: 0.8rem;
}

.company-drawer-close {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  border: 1px solid var(--company-line);
  border-radius: 10px;
  background: #f8fafc;
  color: #506075;
  cursor: pointer;
}

.company-drawer-body {
  overflow-y: auto;
  padding: 18px 24px 28px;
}

.company-form-section {
  margin-bottom: 15px;
  padding: 18px;
  border: 1px solid var(--company-line);
  border-radius: 13px;
  background: #fff;
}

.company-form-section-title {
  display: flex;
  align-items: center;
  gap: 11px;
  margin-bottom: 16px;
}

.company-form-section-title > span {
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--company-green-soft);
  color: var(--company-green);
  font-size: 0.8rem;
  font-weight: 900;
}

.company-form-section-title h3,
.company-form-section-title p {
  margin: 0;
}

.company-form-section-title h3 {
  color: var(--company-ink);
  font-size: 0.92rem;
}

.company-form-section-title p {
  margin-top: 2px;
  color: var(--company-muted);
  font-size: 0.72rem;
}

.company-form-grid {
  display: grid;
  gap: 14px;
}

.company-form-grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.company-form-grid .span-two {
  grid-column: 1 / -1;
}

.company-form-grid label,
.company-notes-label {
  display: grid;
  gap: 7px;
  color: #334155;
  font-size: 0.77rem;
  font-weight: 800;
}

.company-form-grid label > span b {
  color: #dc2626;
}

.company-form-grid input,
.company-form-grid select,
.company-notes-label textarea {
  width: 100%;
  min-height: 43px;
  border: 1px solid #d9e1e8;
  border-radius: 9px;
  padding: 0 12px;
  outline: 0;
  background: #fff;
  color: var(--company-ink);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 500;
}

.company-form-grid input:focus,
.company-form-grid select:focus,
.company-notes-label textarea:focus {
  border-color: #0d9a53;
  box-shadow: 0 0 0 3px rgba(13, 154, 83, 0.1);
}

.company-form-grid input[aria-invalid="true"],
.company-form-grid select[aria-invalid="true"] {
  border-color: #dc2626;
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.08);
}

.company-option-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
}

.company-assignment-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: -4px 0 12px;
}

.company-assignment-search {
  position: relative;
  flex: 1 1 auto;
}

.company-assignment-search i {
  position: absolute;
  top: 50%;
  left: 11px;
  color: var(--company-muted);
  font-size: 0.7rem;
  transform: translateY(-50%);
}

.company-assignment-search input {
  width: 100%;
  min-height: 36px;
  border: 1px solid #d9e1e8;
  border-radius: 8px;
  padding: 0 10px 0 31px;
  background: #fff;
  color: var(--company-ink);
  font: inherit;
  font-size: 0.75rem;
}

.company-assignment-search input:focus {
  border-color: #0d9a53;
  outline: 0;
  box-shadow: 0 0 0 3px rgba(13, 154, 83, 0.1);
}

.company-assignment-toolbar > strong {
  flex: 0 0 auto;
  color: var(--company-green-dark);
  font-size: 0.72rem;
  white-space: nowrap;
}

.company-option-card {
  min-height: 64px;
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid #dfe6ec;
  border-radius: 10px;
  cursor: pointer;
}

.company-option-card:has(input:checked) {
  border-color: #0b9650;
  background: #effaf4;
  box-shadow: inset 0 0 0 1px #0b9650;
}

.company-option-card input {
  width: 17px;
  height: 17px;
  accent-color: var(--company-green);
}

.company-option-card strong,
.company-option-card small {
  display: block;
}

.company-option-card strong {
  color: var(--company-ink);
  font-size: 0.77rem;
}

.company-option-card small {
  margin-top: 3px;
  color: var(--company-muted);
  font-size: 0.68rem;
}

.company-options-empty {
  grid-column: 1 / -1;
  padding: 16px;
  border: 1px dashed #cfd9e2;
  border-radius: 10px;
  color: var(--company-muted);
  font-size: 0.78rem;
  text-align: center;
}

.company-notes-label textarea {
  min-height: 100px;
  resize: vertical;
  padding: 11px 12px;
}

.company-notes-label small {
  justify-self: end;
  color: var(--company-muted);
}

.company-form-alert {
  margin-bottom: 14px;
  padding: 12px 14px;
  border: 1px solid #fecaca;
  border-radius: 10px;
  background: #fff1f2;
  color: #b42318;
  font-size: 0.8rem;
  font-weight: 700;
}

.company-drawer-footer {
  min-height: 76px;
  padding: 14px 24px;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  border-top: 1px solid var(--company-line);
  box-shadow: 0 -8px 24px rgba(15, 23, 42, 0.04);
}

.company-toast {
  position: fixed;
  z-index: 1300;
  right: 24px;
  bottom: 24px;
  max-width: min(380px, calc(100vw - 32px));
  padding: 14px 17px;
  border-radius: 11px;
  background: #073d26;
  color: #fff;
  box-shadow: 0 20px 45px rgba(7, 61, 38, 0.3);
  font-size: 0.83rem;
  font-weight: 750;
}

.company-toast.error {
  background: #9f1d1d;
}

body.company-drawer-open {
  overflow: hidden;
}

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

  .companies-insights-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .company-insight-card:last-child {
    grid-column: 1 / -1;
  }
}

@media (max-width: 900px) {
  .companies-filter-bar {
    grid-template-columns: 1fr 1fr;
  }

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

  .companies-button.filter-reset {
    grid-column: 1 / -1;
  }
}

@media (max-width: 760px) {
  .companies-page-shell {
    gap: 14px;
  }

  .companies-actions {
    align-items: flex-start;
    justify-content: space-between;
  }

  .companies-mobile-heading {
    display: block;
  }

  .companies-mobile-heading h2,
  .companies-mobile-heading p {
    margin: 0;
  }

  .companies-mobile-heading h2 {
    font-size: 1.3rem;
  }

  .companies-mobile-heading p:last-child {
    margin-top: 4px;
    color: var(--company-muted);
    font-size: 0.75rem;
  }

  .companies-button.secondary#export-companies span {
    display: none;
  }

  .companies-button.secondary#export-companies {
    width: 42px;
    padding: 0;
  }

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

  .company-kpi-card {
    min-height: 98px;
    padding: 13px;
  }

  .company-kpi-icon {
    width: 42px;
    height: 42px;
    flex-basis: 42px;
  }

  .company-kpi-card strong {
    font-size: 1.25rem;
  }

  .companies-filter-bar {
    grid-template-columns: 1fr 1fr;
    padding: 12px;
  }

  .companies-table-scroll {
    overflow: visible;
  }

  .companies-table {
    min-width: 0;
  }

  .companies-head {
    display: none;
  }

  #companies-list {
    display: grid;
    gap: 10px;
    padding: 0 12px 12px;
  }

  .companies-row {
    min-height: 0;
    grid-template-columns: 1fr auto;
    gap: 14px 12px;
    padding: 15px;
    border: 1px solid var(--company-line);
    border-radius: 13px;
    box-shadow: 0 8px 22px rgba(15, 23, 42, 0.04);
  }

  .company-identity {
    grid-column: 1 / -1;
  }

  .company-contact,
  .company-location-cell {
    grid-column: 1 / -1;
    padding-top: 9px;
    border-top: 1px solid #edf1f5;
  }

  .company-metric-cell::before,
  .company-category-cell::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 3px;
    color: var(--company-muted);
    font-size: 0.65rem;
    font-weight: 750;
    text-transform: uppercase;
  }

  .company-status-pill {
    align-self: end;
  }

  .company-action-menu {
    position: absolute;
    right: 26px;
  }

  .companies-row {
    position: relative;
  }

  .companies-insights-grid {
    grid-template-columns: 1fr;
  }

  .company-insight-card:last-child {
    grid-column: auto;
  }

  .companies-pagination {
    justify-content: center;
  }

  .company-drawer {
    width: 100vw;
  }

  .company-drawer-header,
  .company-drawer-body,
  .company-drawer-footer {
    padding-left: 16px;
    padding-right: 16px;
  }

  .company-drawer-footer .companies-button {
    flex: 1;
  }
}

@media (max-width: 520px) {
  .companies-actions {
    display: grid;
    grid-template-columns: 1fr auto;
  }

  .companies-action-buttons {
    align-self: center;
  }

  .companies-kpi-grid {
    grid-template-columns: none;
    grid-auto-flow: column;
    grid-auto-columns: minmax(210px, 78vw);
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    padding-bottom: 4px;
    scroll-snap-type: inline mandatory;
    scrollbar-width: none;
  }

  .companies-kpi-grid::-webkit-scrollbar {
    display: none;
  }

  .company-kpi-card {
    min-height: 88px;
    scroll-snap-align: start;
  }

  .companies-filter-bar {
    grid-template-columns: 1fr;
  }

  .companies-search,
  .companies-button.filter-reset {
    grid-column: auto;
  }

  .companies-button.filter-reset {
    width: 100%;
  }

  .company-status-visual {
    grid-template-columns: 108px 1fr;
    gap: 12px;
  }

  .company-donut {
    width: 100px;
    height: 100px;
  }

  .company-donut::after {
    width: 62px;
    height: 62px;
  }

  .company-form-grid.two,
  .company-option-list {
    grid-template-columns: 1fr;
  }

  .company-form-grid .span-two {
    grid-column: auto;
  }

  .company-form-section {
    padding: 15px;
  }

  .company-assignment-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .company-drawer-header {
    min-height: 88px;
  }

  .company-toast {
    right: 16px;
    bottom: 16px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .companies-button,
  .companies-spinner {
    transition: none;
    animation: none;
  }
}
:root {
  --company-green: #058c4c;
  --company-green-dark: #006e3d;
  --company-green-light: #e6f8ee;
  --company-text: #101820;
  --company-muted: #6f7d8b;
  --company-border: #e7ebef;
  --company-background: #f7f9fb;
  --company-white: #ffffff;
  --company-shadow: 0 4px 18px rgba(20, 35, 50, 0.055);
}

* {
  box-sizing: border-box;
}

.hidden {
  display: none !important;
}

.companies-page {
  min-height: 100vh;
  padding: 32px;
  color: var(--company-text);
  background: var(--company-background);
}

.companies-page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 28px;
}

.companies-page-header h1 {
  margin: 0 0 7px;
  font-size: 31px;
  line-height: 1.15;
  letter-spacing: -0.8px;
}

.companies-page-header p {
  margin: 0;
  color: var(--company-muted);
  font-size: 14px;
}

.companies-header-actions {
  display: flex;
  gap: 12px;
}

.company-button {
  min-height: 42px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: 8px;
  font: inherit;
  font-size: 14px;
  font-weight: 650;
  cursor: pointer;
  transition:
    transform 150ms ease,
    box-shadow 150ms ease,
    background 150ms ease;
}

.company-button:hover {
  transform: translateY(-1px);
}

.company-button-primary {
  color: white;
  background: var(--company-green);
  box-shadow: 0 5px 12px rgba(5, 140, 76, 0.18);
}

.company-button-primary:hover {
  background: var(--company-green-dark);
}

.company-button-secondary {
  color: #17212a;
  border-color: #dbe1e6;
  background: white;
}

/* KPI cards */

.company-kpi-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.company-kpi-card {
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 116px;
  padding: 22px;
  border: 1px solid #edf0f2;
  border-radius: 9px;
  background: white;
  box-shadow: var(--company-shadow);
}

.company-kpi-icon {
  display: grid;
  place-items: center;
  flex: 0 0 52px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  color: #00a652;
  background: var(--company-green-light);
  font-size: 21px;
}

.company-kpi-card small {
  display: block;
  margin-bottom: 8px;
  color: #6f8090;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.company-kpi-card strong {
  display: block;
  font-size: 23px;
  line-height: 1;
  white-space: nowrap;
}

.company-kpi-trend {
  margin: 9px 0 0;
  color: #00a34f;
  font-size: 11px;
  font-weight: 650;
}

/* Main directory */

.company-directory-card,
.company-insight-card {
  border: 1px solid #edf0f2;
  border-radius: 9px;
  background: white;
  box-shadow: var(--company-shadow);
}

.company-filter-toolbar {
  display: grid;
  grid-template-columns: minmax(260px, 1.5fr) 1fr 1fr auto;
  gap: 14px;
  padding: 16px;
  border-bottom: 1px solid var(--company-border);
}

.company-search {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 42px;
  padding: 0 14px;
  border: 1px solid #dfe5ea;
  border-radius: 7px;
  color: #71808d;
  background: white;
}

.company-search:focus-within {
  border-color: var(--company-green);
  box-shadow: 0 0 0 3px rgba(5, 140, 76, 0.1);
}

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

.company-filter-toolbar select,
.company-filter-button {
  height: 42px;
  padding: 0 14px;
  border: 1px solid #dfe5ea;
  border-radius: 7px;
  color: #18222b;
  background: white;
  font: inherit;
  font-size: 13px;
}

.company-filter-button {
  cursor: pointer;
}

.company-list-title {
  padding: 17px 18px;
  border-bottom: 1px solid var(--company-border);
  font-size: 13px;
  font-weight: 750;
  text-transform: uppercase;
}

.companies-table-scroll {
  overflow-x: auto;
}

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

.companies-grid {
  display: grid;
  grid-template-columns:
    minmax(190px, 1.45fr)
    minmax(150px, 1.1fr)
    minmax(130px, 0.95fr)
    minmax(170px, 1.2fr)
    90px
    90px
    125px
    90px
    54px;
  align-items: center;
  column-gap: 14px;
}

.companies-table-head {
  min-height: 46px;
  padding: 0 18px;
  color: #657586;
  background: #fafbfc;
  font-size: 11px;
  font-weight: 700;
}

.companies-row {
  position: relative;
  min-height: 73px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--company-border);
  font-size: 13px;
  transition: background 130ms ease;
}

.companies-row:hover {
  background: #fbfdfc;
}

.company-identity {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.company-avatar {
  display: grid;
  place-items: center;
  flex: 0 0 32px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  color: white;
  background: linear-gradient(135deg, #0c66e4, #0849ad);
  font-size: 10px;
  font-weight: 800;
}

.companies-row:nth-child(5n + 2) .company-avatar {
  background: linear-gradient(135deg, #874cff, #5721d0);
}

.companies-row:nth-child(5n + 3) .company-avatar {
  background: linear-gradient(135deg, #ff7138, #ed3c08);
}

.companies-row:nth-child(5n + 4) .company-avatar {
  background: linear-gradient(135deg, #48c78e, #169b62);
}

.companies-row:nth-child(5n + 5) .company-avatar {
  background: linear-gradient(135deg, #ffbc21, #e89000);
}

.company-cell-copy {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 5px;
}

.company-cell-copy strong {
  overflow: hidden;
  color: #16212a;
  font-size: 13px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.company-cell-copy small,
.company-metric-cell small {
  overflow: hidden;
  color: #778694;
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.company-standard-cell,
.company-metric-cell {
  color: #15202a;
  font-size: 13px;
}

.company-metric-cell {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.company-revenue-cell {
  font-weight: 650;
  white-space: nowrap;
}

/* Status */

.company-status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: fit-content;
  min-width: 61px;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 650;
}

.company-status-pill.active {
  color: #078344;
  background: #e8f8ee;
}

.company-status-pill.inactive {
  color: #64717c;
  background: #eef1f3;
}

.company-status-pill.suspended {
  color: #d13b35;
  background: #fdeceb;
}

/* Action menu */

.company-action-menu {
  position: relative;
  display: flex;
  justify-content: center;
}

.company-row-action {
  display: grid;
  place-items: center;
  width: 36px;
  height: 34px;
  border: 1px solid #e0e5e9;
  border-radius: 7px;
  color: #293640;
  background: white;
  cursor: pointer;
}

.company-row-action:hover {
  border-color: #bfc9d1;
  background: #f8fafb;
}

.company-action-popover {
  position: absolute;
  z-index: 20;
  top: 38px;
  right: 0;
  width: 170px;
  padding: 6px;
  border: 1px solid #e1e6ea;
  border-radius: 9px;
  background: white;
  box-shadow: 0 12px 30px rgba(16, 24, 32, 0.14);
}

.company-action-popover button {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 10px;
  border: 0;
  border-radius: 6px;
  color: #27333d;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.company-action-popover button:hover {
  background: #f3f6f7;
}

/* Footer and pagination */

.company-directory-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 66px;
  padding: 12px 18px;
}

.company-directory-footer p {
  margin: 0;
  color: #667684;
  font-size: 12px;
}

.companies-pagination {
  display: flex;
  align-items: center;
  gap: 7px;
}

.companies-pagination button {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1px solid #e4e8eb;
  border-radius: 7px;
  color: #25323c;
  background: white;
  cursor: pointer;
}

.companies-pagination button.active {
  color: var(--company-green);
  border-color: #72c89f;
  background: #f4fcf7;
}

.companies-pagination button:disabled {
  color: #bbc3c9;
  cursor: not-allowed;
}

/* Loading and empty states */

.companies-loading,
.companies-empty {
  min-height: 280px;
  padding: 48px 20px;
  text-align: center;
}

.companies-loading {
  display: grid;
  place-content: center;
  gap: 12px;
  color: var(--company-muted);
}

.companies-empty i {
  color: #9aabb7;
  font-size: 38px;
}

.companies-empty h3 {
  margin: 14px 0 5px;
}

.companies-empty p {
  margin: 0 0 18px;
  color: var(--company-muted);
}

/* Charts */

.company-insights-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-top: 18px;
}

.company-insight-card {
  min-height: 220px;
  padding: 20px;
}

.company-insight-card h2 {
  margin: 0 0 22px;
  font-size: 13px;
  text-transform: uppercase;
}

.company-donut-layout {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 25px;
}

.company-donut {
  position: relative;
  display: grid;
  place-items: center;
  width: 116px;
  height: 116px;
  flex: 0 0 116px;
  border-radius: 50%;
  background: conic-gradient(#dce3e9 0deg 360deg);
}

.company-donut::after {
  position: absolute;
  width: 70px;
  height: 70px;
  border-radius: 50%;
  background: white;
  content: "";
}

.company-donut span {
  z-index: 1;
  font-size: 17px;
  font-weight: 750;
}

.company-chart-legend {
  display: grid;
  gap: 12px;
  width: 100%;
  margin: 0;
  padding: 0;
  list-style: none;
}

.company-chart-legend li {
  display: grid;
  grid-template-columns: 8px 1fr auto;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}

.company-chart-legend i {
  width: 8px;
  height: 8px;
  border-radius: 2px;
}

.company-bar-chart {
  display: grid;
  gap: 13px;
}

.company-bar-row {
  display: grid;
  grid-template-columns: minmax(75px, 100px) 1fr auto;
  align-items: center;
  gap: 9px;
  font-size: 11px;
}

.company-bar-row > span:first-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.company-bar-track {
  overflow: hidden;
  height: 10px;
  border-radius: 2px;
  background: #edf1f3;
}

.company-bar-fill {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #14b765, #009e4c);
}

.company-chart-empty {
  display: grid;
  min-height: 130px;
  place-items: center;
  color: var(--company-muted);
  text-align: center;
}

/* Toast */

.company-toast {
  position: fixed;
  z-index: 1000;
  right: 24px;
  bottom: 24px;
  max-width: 380px;
  padding: 14px 18px;
  border-radius: 9px;
  color: white;
  background: #087b46;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.2);
}

.company-toast.error {
  background: #c83c36;
}

/* Responsive */

@media (max-width: 1400px) {
  .company-kpi-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .company-insights-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 900px) {
  .companies-page {
    padding: 20px;
  }

  .companies-page-header {
    align-items: flex-start;
    flex-direction: column;
  }

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

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

  .company-kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 600px) {
  .companies-page {
    padding: 14px;
  }

  .companies-page-header h1 {
    font-size: 25px;
  }

  .companies-header-actions,
  .company-kpi-grid,
  .company-insights-grid,
  .company-filter-toolbar {
    grid-template-columns: 1fr;
    width: 100%;
  }

  .companies-header-actions {
    display: grid;
  }

  .company-kpi-grid,
  .company-insights-grid {
    display: grid;
  }

  .company-search {
    grid-column: auto;
  }

  .company-directory-footer {
    align-items: flex-start;
    flex-direction: column;
    gap: 14px;
  }
}

/* === COMPANY DIRECTORY RESPONSIVE ALIGNMENT START === */

/*
 * Company directory responsive table
 *
 * Desktop:
 * Company | Contact | Location | Category | Drivers | Accounts | Status | Actions
 *
 * Medium screens:
 * Preserve column alignment and allow horizontal scrolling when necessary.
 *
 * Mobile:
 * Switch back to card layout.
 */

.companies-table-scroll {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.companies-table {
  width: 100%;
  min-width: 1160px;
}

.companies-row {
  display: grid;
  grid-template-columns:
    minmax(210px, 1.45fr)
    minmax(180px, 1.15fr)
    minmax(180px, 1.15fr)
    minmax(150px, 0.9fr)
    minmax(72px, 0.5fr)
    minmax(78px, 0.52fr)
    minmax(90px, 0.62fr)
    56px;
  column-gap: 14px;
  align-items: center;
}

/* Prevent any cell from forcing the grid wider than its column. */
.companies-head > span,
.company-identity,
.company-contact,
.company-location-cell,
.company-category-cell,
.company-metric-cell,
.company-status-pill,
.company-action-menu {
  min-width: 0;
}

.company-category-cell {
  overflow: hidden;
  padding-right: 4px;
}

/*
 * Important:
 * box-sizing prevents badge padding from extending into Drivers column.
 */
.company-category-badge {
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  width: max-content;
  max-width: 100%;
  min-height: 28px;
  padding: 5px 9px;
  overflow: hidden;
  border-radius: 999px;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.company-metric-cell {
  min-width: 0;
  white-space: nowrap;
}

.company-status-pill {
  justify-self: start;
  white-space: nowrap;
}

.company-action-menu {
  justify-self: center;
}


/* Medium laptops / tablets */
@media (min-width: 901px) and (max-width: 1280px) {
  .companies-table {
    min-width: 1100px;
  }

  .companies-row {
    grid-template-columns:
      minmax(190px, 1.4fr)
      minmax(165px, 1.1fr)
      minmax(165px, 1.1fr)
      minmax(145px, 0.9fr)
      70px
      74px
      88px
      54px;
    column-gap: 12px;
  }
}


/* Mobile / narrow tablet card layout */
@media (max-width: 900px) {
  .companies-table {
    width: 100%;
    min-width: 0;
  }

  .companies-head {
    display: none;
  }

  .companies-row {
    position: relative;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 14px 12px;
    min-height: 0;
  }

  .company-identity {
    grid-column: 1 / -1;
    padding-right: 48px;
  }

  .company-contact,
  .company-location-cell {
    grid-column: 1 / -1;
  }

  .company-category-cell {
    grid-column: 1 / -1;
    overflow: visible;
    padding-right: 48px;
  }

  .company-category-badge {
    width: auto;
    max-width: 100%;
    white-space: normal;
    line-height: 1.25;
  }

  .company-action-menu {
    position: absolute;
    top: 15px;
    right: 15px;
  }
}


/* Small phones */
@media (max-width: 520px) {
  .companies-row {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px 10px;
  }

  .company-category-cell {
    grid-column: 1 / -1;
  }

  .company-category-badge {
    font-size: 0.72rem;
  }
}

/* === COMPANY DIRECTORY RESPONSIVE ALIGNMENT END === */
