/* Companies directory — deliberately page-specific to avoid shared entity styles
   being reshaped by accounting or system theme overrides. */
.companies-heading {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 28px;
    padding-bottom: 22px;
    border-bottom: 1px solid var(--brand-line-subtle, #ebe5dc);
}

.companies-heading .heading-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: none;
}

.companies-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 330px), 1fr));
    gap: 20px;
    align-items: stretch;
}

.companies-grid .company-card {
    min-width: 0;
    min-height: 330px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    overflow: hidden;
    padding: 0;
    border: 1px solid var(--brand-line, #d8d0c4);
    border-radius: 14px;
    background: var(--brand-surface, #fff);
    box-shadow: 0 8px 28px rgba(50, 46, 41, .055);
    transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
}

.companies-grid .company-card:hover {
    transform: translateY(-3px);
    border-color: var(--brand-gold, #b39a6d);
    box-shadow: 0 16px 42px rgba(50, 46, 41, .1);
}

.company-card-body { padding: 22px 22px 18px; }

.company-card-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    min-height: 54px;
}

.companies-grid .entity-logo,
.company-logo-image {
    width: 64px;
    height: 52px;
    flex: 0 0 64px;
    display: grid;
    place-items: center;
    overflow: hidden;
    border: 1px solid var(--brand-line, #d8d0c4);
    border-radius: 10px;
    background: var(--brand-charcoal, #322e29);
    color: #fff;
    font-size: 15px;
    font-weight: 800;
    letter-spacing: .05em;
}

.company-logo-image { width: 112px; flex-basis: 112px; padding: 6px 10px; background: #fff; }
.company-logo-image img { display: block; max-width: 100%; max-height: 38px; object-fit: contain; }

.companies-grid .active-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    width: fit-content;
    padding: 5px 9px;
    border: 1px solid var(--status-success-border, #c6e7d2);
    border-radius: 999px;
    background: var(--status-success-bg, #eaf5ee);
    color: var(--status-success, #1b6a3b);
    font-size: 10px;
    font-weight: 700;
    white-space: nowrap;
}

.companies-grid .active-badge.inactive {
    border-color: var(--status-danger-border, #f3c7d2);
    background: var(--status-danger-bg, #fdf0f3);
    color: var(--status-danger, #7c193f);
}

.company-name { margin: 19px 0 3px; color: var(--brand-ink, #181715); font-size: 18px; line-height: 1.45; }
.company-name-secondary { min-height: 20px; margin: 0 0 14px; color: var(--brand-muted, #746f68); font-size: 12px; }
.company-description { margin: -3px 0 14px; color: var(--brand-stone, #5b534a); font-size: 11.5px; line-height: 1.65; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

.companies-grid .entity-meta {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0;
    overflow: hidden;
    border: 1px solid var(--brand-line-subtle, #ebe5dc);
    border-radius: 10px;
    background: var(--brand-cream, #f2eee6);
}

.companies-grid .entity-meta > div { min-width: 0; padding: 12px 13px; border-bottom: 1px solid var(--brand-line-subtle, #ebe5dc); }
.companies-grid .entity-meta > div:nth-child(odd) { border-inline-end: 1px solid var(--brand-line-subtle, #ebe5dc); }
.companies-grid .entity-meta > div:nth-last-child(-n+2) { border-bottom: 0; }
.companies-grid .entity-meta span,
.companies-grid .entity-meta b { display: block; overflow: hidden; text-overflow: ellipsis; }
.companies-grid .entity-meta span { margin-bottom: 4px; color: var(--brand-muted, #746f68); font-size: 9px; }
.companies-grid .entity-meta b { color: var(--brand-ink, #181715); font-size: 11.5px; white-space: nowrap; }

.company-contact { display: flex; flex-wrap: wrap; gap: 7px 14px; margin-top: 13px; padding-top: 11px; border-top: 1px dashed var(--brand-line, #d8d0c4); color: var(--brand-muted, #746f68); font-size: 10.5px; }

.company-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin: 0;
    padding: 15px 22px;
    border-top: 1px solid var(--brand-line-subtle, #ebe5dc);
    background: var(--brand-paper, #fcfaf6);
}

.company-card-footer a,
.company-card-footer button {
    min-height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 7px 11px;
    border: 1px solid transparent;
    border-radius: 7px;
    background: transparent;
    color: var(--brand-burgundy, #7c193f);
    font: 700 10.5px/1.3 inherit;
    text-decoration: none;
    cursor: pointer;
}

.company-card-footer button { border-color: var(--brand-line, #d8d0c4); background: #fff; }
.company-card-footer a:hover,
.company-card-footer button:hover { border-color: var(--brand-burgundy, #7c193f); background: var(--brand-burgundy-subtle, rgba(124,25,63,.08)); }

@media (max-width: 760px) {
    .companies-heading { align-items: stretch; flex-direction: column; gap: 16px; }
    .companies-heading .heading-actions { width: 100%; }
    .companies-heading .heading-actions > * { flex: 1; justify-content: center; }
    .companies-grid { grid-template-columns: 1fr; gap: 14px; }
}

@media (max-width: 430px) {
    .company-card-body { padding: 18px 16px 15px; }
    .company-card-footer { padding: 13px 16px; flex-direction: column; align-items: stretch; }
    .company-card-footer > * { width: 100%; }
    .companies-grid .entity-meta { grid-template-columns: 1fr; }
    .companies-grid .entity-meta > div,
    .companies-grid .entity-meta > div:nth-child(odd),
    .companies-grid .entity-meta > div:nth-last-child(-n+2) { border-inline-end: 0; border-bottom: 1px solid var(--brand-line-subtle, #ebe5dc); }
    .companies-grid .entity-meta > div:last-child { border-bottom: 0; }
}
