/* Componentes da administração geral; os tokens vêm de app.css. */
.owner-navigation {
    margin-top: 28px;
}

/* Filtros com rótulos permanentes e controles acessíveis por teclado. */
.company-filters {
    display: grid;
    grid-template-columns: minmax(180px, 2fr) repeat(2, minmax(150px, 1fr)) auto;
    align-items: end;
    gap: 16px;
    padding: 0 24px 20px;
}

.filter-field {
    display: grid;
    gap: 6px;
    min-width: 0;
}

.filter-field label {
    font-size: 13px;
    font-weight: 600;
}

.filter-field input,
.filter-field select {
    width: 100%;
    min-width: 0;
    min-height: 44px;
    padding: 10px;
    border: 1px solid #aebdcb;
    border-radius: 7px;
    color: var(--text);
    background: var(--surface);
    font: inherit;
}

.filter-field input::placeholder {
    color: var(--muted);
}

.company-filters input:focus-visible,
.company-filters select:focus-visible,
.company-filters button:focus-visible {
    outline: 3px solid #3384ea;
    outline-offset: 3px;
}

.filter-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
}

.company-directory .button {
    min-height: 44px;
    border: 0;
    font: inherit;
    cursor: pointer;
}

.company-directory .button:hover {
    background: #104d9c;
}

.filter-clear {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 9px 16px;
    border: 1px solid #aebdcb;
    border-radius: 7px;
    color: var(--text);
    background: var(--surface);
    text-decoration: none;
}

.filter-clear:hover {
    background: #edf2f7;
    border-color: #7e91a5;
}

/* Anuncia a busca e o resultado sem substituir o campo de digitação. */
.company-feedback {
    min-height: 20px;
    margin: 0 24px 12px;
    color: var(--muted);
    font-size: 13px;
}

.company-feedback:empty {
    min-height: 0;
    margin-bottom: 0;
}

#company-results[aria-busy="true"] {
    opacity: 0.65;
}

.company-results {
    margin: 0;
    padding: 0 24px 16px;
    color: var(--muted);
    font-size: 13px;
}

/* Esta tabela tem regras próprias para não depender dos exemplos do dashboard. */
.company-directory .companies-table {
    table-layout: fixed;
}

.company-directory .companies-table th:nth-child(1) {
    width: 42%;
}

.company-directory .companies-table th:nth-child(2) {
    width: 33%;
}

.company-directory .companies-table th:nth-child(3) {
    width: 25%;
}

.companies-table td {
    vertical-align: top;
    white-space: normal;
    overflow-wrap: anywhere;
}

.company-name,
.company-meta {
    display: block;
}

.company-meta {
    margin-top: 4px;
    color: var(--muted);
    font-size: 12px;
}

.module-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.module-list li {
    max-width: 100%;
    padding: 3px 7px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #f3f5f8;
    font-size: 12px;
}

/* A situação é expressa por texto, além da cor. */
.company-status {
    display: inline-block;
    max-width: 100%;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
}

.status-active {
    color: #185b3a;
    background: #e6f4eb;
}

.status-onboarding {
    color: #73500b;
    background: #fff3d6;
}

.status-suspended {
    color: #942c35;
    background: #fcebed;
}

.company-empty {
    padding: 28px 24px;
    border-top: 1px solid var(--border);
}

.company-empty h3 {
    margin: 0;
    font-size: 17px;
}

.company-empty p {
    color: var(--muted);
}

/* Ficha administrativa da empresa. */
.detail-toolbar {
    margin-bottom: 16px;
}

.back-link {
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
}

.back-link:hover,
.company-link:hover {
    text-decoration: underline;
}

.company-link {
    color: var(--accent);
    font-weight: 700;
    text-decoration: none;
}

.detail-summary {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 20px;
    padding: 22px 24px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
}

.detail-summary h2 {
    margin: 4px 0 4px;
    font-size: 22px;
}

.detail-summary p {
    margin: 0;
    color: var(--muted);
    font-size: 13px;
}

.detail-metrics {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}

.detail-metric {
    display: grid;
    gap: 6px;
    min-width: 0;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
}

.detail-metric span {
    color: var(--muted);
    font-size: 12px;
}

.detail-metric strong {
    overflow-wrap: anywhere;
    font-size: 16px;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
    min-width: 0;
}

.detail-grid > .detail-panel {
    min-width: 0;
}

.detail-panel:last-child {
    grid-column: 1 / -1;
}

.detail-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px 24px;
    margin: 0;
    padding: 0 24px 24px;
}

.detail-list div {
    min-width: 0;
}

.detail-list dt {
    color: var(--muted);
    font-size: 12px;
}

.detail-list dd {
    margin: 4px 0 0;
    overflow-wrap: anywhere;
    font-size: 14px;
    font-weight: 600;
}

.detail-modules {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin: 0;
    padding: 0 24px 24px;
    list-style: none;
}

.detail-modules li {
    min-width: 0;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 7px;
}

.module-card-heading {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 8px;
}

.module-card-heading strong {
    font-size: 13px;
}

.module-card-heading small {
    color: #185b3a;
    font-size: 11px;
    font-weight: 600;
}

.module-card p {
    min-height: 38px;
    margin: 9px 0;
    color: var(--muted);
    font-size: 12px;
}

.module-card.module-disabled {
    background: #f8fafc;
}

.module-card.module-disabled .module-check,
.module-card.module-disabled .module-card-heading small {
    color: var(--muted);
}

.module-action {
    width: 100%;
    min-height: 34px;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--muted);
    background: #eef2f6;
    font: inherit;
    font-size: 12px;
    cursor: not-allowed;
}

.module-check {
    color: #185b3a;
    font-weight: 700;
}

.detail-admin-state {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 24px 24px;
}

.admin-avatar {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    flex-shrink: 0;
    border-radius: 50%;
    color: #ffffff;
    background: var(--sidebar);
    font-weight: 700;
}

.detail-admin-state strong,
.detail-admin-state p {
    display: block;
}

/* Gestão visual de usuários e do primeiro administrador. */
.users-context {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 20px;
    padding: 22px 24px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
}

.users-context h2 {
    margin: 4px 0;
    font-size: 22px;
}

.users-context p {
    margin: 0;
    color: var(--muted);
    font-size: 13px;
}

.users-primary-action {
    min-height: 40px;
    padding: 8px 14px;
    border: 0;
    border-radius: 7px;
    color: #ffffff;
    background: var(--accent);
    font: inherit;
    font-size: 12px;
    cursor: not-allowed;
    opacity: 0.58;
}

.users-admin-callout {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
    padding: 20px 24px;
    border: 1px solid #b9cde4;
    border-radius: var(--radius);
    background: #f4f8fc;
}

.users-admin-callout > div:nth-child(2) {
    flex: 1;
    min-width: 0;
}

.users-admin-callout h2 {
    margin: 4px 0;
    font-size: 18px;
}

.users-admin-callout p {
    max-width: 700px;
    margin: 0;
    color: var(--muted);
    font-size: 13px;
}

.users-admin-callout .detail-action {
    flex-shrink: 0;
}

.users-panel,
.roles-panel {
    grid-column: 1 / -1;
    margin-bottom: 24px;
}

.users-panel-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}

/* Contém também os textos acessíveis posicionados de forma absoluta na tabela. */
.users-table-scroll {
    position: relative;
    max-width: 100%;
    min-width: 0;
    width: 100%;
    overflow-x: auto;
}

.users-count {
    flex-shrink: 0;
    color: var(--muted);
    font-size: 12px;
}

.users-table {
    min-width: 760px;
    table-layout: fixed;
}

.users-table th:nth-child(1) {
    width: 31%;
}

.users-table th:nth-child(2) {
    width: 17%;
}

.users-table th:nth-child(3) {
    width: 17%;
}

.users-table th:nth-child(4) {
    width: 20%;
}

.users-table th:nth-child(5) {
    width: 15%;
}

.users-table td {
    box-sizing: border-box;
    vertical-align: middle;
    white-space: normal;
}

.users-table th {
    box-sizing: border-box;
}

.users-table th:last-child,
.users-table td:last-child {
    min-width: 112px;
    padding-right: 16px;
    padding-left: 16px;
    white-space: nowrap;
}

.users-table td strong,
.users-table td small {
    display: block;
}

.users-table td small {
    margin-top: 4px;
    color: var(--muted);
    font-size: 11px;
    overflow-wrap: anywhere;
}

.user-status {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
}

.user-status-active {
    color: #185b3a;
    background: #e6f4eb;
}

.user-status-pending {
    color: #73500b;
    background: #fff3d6;
}

.user-action {
    min-height: 32px;
    padding: 6px 9px;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--muted);
    background: #eef2f6;
    font: inherit;
    font-size: 11px;
    cursor: not-allowed;
}

.role-cards {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    padding: 0 24px 24px;
}

.role-card {
    min-width: 0;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 7px;
    background: #fbfcfd;
}

.role-card strong {
    font-size: 13px;
}

.role-card p {
    margin: 8px 0 0;
    color: var(--muted);
    font-size: 12px;
}

.detail-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding: 0 24px 24px;
}

.detail-action {
    min-height: 40px;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 7px;
    color: var(--muted);
    background: #eef2f6;
    font: inherit;
    font-size: 12px;
    cursor: not-allowed;
}

/*
 * Algumas ações administrativas nascem desabilitadas no HTML
 * e são habilitadas somente após o JavaScript validar que o
 * fluxo correspondente está realmente disponível.
 */
.detail-action[data-responsible-transfer]:not(:disabled) {
    color: #ffffff;
    background: var(--accent);
    border-color: var(--accent);
    cursor: pointer;
}

.detail-action[data-responsible-transfer]:not(:disabled):hover {
    filter: brightness(0.95);
}

.detail-action[data-responsible-transfer]:not(:disabled):focus-visible {
    outline: 3px solid #3384ea;
    outline-offset: 3px;
}

.detail-action-warning {
    color: #8b4a13;
    border-color: #e2c08d;
    background: #fff7e8;
}

.detail-history {
    display: grid;
    gap: 0;
    margin: 0;
    padding: 0 24px 24px;
    list-style: none;
}

.detail-history li {
    position: relative;
    display: grid;
    grid-template-columns: 14px minmax(0, 1fr);
    gap: 12px;
    min-height: 72px;
}

.detail-history li:not(:last-child)::after {
    position: absolute;
    top: 14px;
    bottom: 0;
    left: 6px;
    width: 1px;
    background: var(--border);
    content: '';
}

.history-marker {
    position: relative;
    z-index: 1;
    display: block;
    width: 13px;
    height: 13px;
    margin-top: 2px;
    border: 3px solid var(--surface);
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 0 1px #8eb1d8;
}

.detail-history time,
.detail-history strong,
.detail-history p {
    display: block;
}

.detail-history time {
    margin-bottom: 3px;
    color: var(--muted);
    font-size: 11px;
}

.detail-history strong {
    font-size: 13px;
}

.detail-history p {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 12px;
}

/* Página visual de planos e permissões da plataforma. */
.plans-intro {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 20px;
    padding: 22px 24px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
}

.section-kicker {
    color: var(--accent);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.1em;
}

.plans-intro h2 {
    margin: 5px 0 4px;
    font-size: 20px;
}

.plans-intro p {
    max-width: 760px;
    margin: 0;
    color: var(--muted);
    font-size: 13px;
}

.demo-note {
    flex-shrink: 0;
    padding: 5px 9px;
    border: 1px solid #d9b75d;
    border-radius: 6px;
    color: #74540b;
    background: #fff7de;
    font-size: 11px;
    font-weight: 600;
}

.plan-cards {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
    margin-bottom: 24px;
}

.plan-card {
    position: relative;
    display: flex;
    flex-direction: column;
    min-width: 0;
    padding: 22px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
}

.plan-card-highlight {
    border-color: #7aa7d8;
    box-shadow: 0 0 0 2px rgb(22 95 190 / 10%);
}

.plan-badge {
    align-self: flex-start;
    margin-bottom: 10px;
    padding: 4px 8px;
    border-radius: 5px;
    color: #ffffff;
    background: var(--accent);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.plan-card h2 {
    margin: 0;
    font-size: 20px;
}

.plan-description {
    min-height: 42px;
    margin: 8px 0 18px;
    color: var(--muted);
    font-size: 13px;
}

.plan-price {
    font-size: 24px;
    letter-spacing: -0.02em;
}

.plan-modules {
    display: grid;
    gap: 8px;
    margin: 20px 0;
    padding: 16px 0;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    list-style: none;
}

.plan-modules li {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text);
    font-size: 13px;
}

.plan-modules li span {
    color: #185b3a;
    font-weight: 700;
}

.plan-action {
    width: 100%;
    min-height: 42px;
    margin-top: auto;
    border: 1px solid var(--border);
    border-radius: 7px;
    color: var(--muted);
    background: #eef2f6;
    font: inherit;
    font-size: 13px;
    cursor: not-allowed;
}

.permission-panel {
    margin-bottom: 24px;
}

.permission-table {
    table-layout: fixed;
}

.permission-table th:first-child {
    width: 27%;
}

.permission-table th,
.permission-table td {
    white-space: normal;
    vertical-align: top;
}

.permission-table tbody th {
    text-align: left;
}

.permission-table tbody th strong,
.permission-table tbody th small {
    display: block;
}

.permission-table tbody th small {
    margin-top: 4px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 400;
}

@media (max-width: 1050px) {
    .plan-cards {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

.detail-admin-state p {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 13px;
}

/* A quebra antecipada impede que os filtros comprimam a área de conteúdo. */
@media (max-width: 1200px) {
    .company-filters {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

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

@media (max-width: 900px) {
    .owner-navigation {
        margin-top: 8px;
    }

    .owner-navigation .navigation {
        grid-template-columns: minmax(0, 1fr);
    }

    .company-filters {
        grid-template-columns: minmax(0, 1fr);
        gap: 12px;
        padding: 0 16px 16px;
    }

    .filter-field input,
    .filter-field select {
        font-size: 16px;
    }

    .company-results {
        padding: 0 16px 16px;
    }

    .company-feedback {
        margin-right: 16px;
        margin-left: 16px;
    }

    .company-directory .companies-table th:nth-child(1) {
        width: 40%;
    }

    .company-directory .companies-table th:nth-child(2) {
        width: 32%;
    }

    .company-directory .companies-table th:nth-child(3) {
        width: 28%;
    }

    .module-list li,
    .company-status {
        padding: 3px 4px;
    }

    .company-empty {
        padding: 20px 16px;
    }

    .detail-summary {
        align-items: flex-start;
        flex-direction: column;
        padding: 16px;
    }

    .detail-summary h2 {
        font-size: 19px;
    }

    .detail-metrics,
    .detail-grid,
    .detail-list {
        grid-template-columns: minmax(0, 1fr);
    }

    .detail-grid {
        gap: 14px;
    }

    .detail-panel:last-child {
        grid-column: auto;
    }

    .detail-list,
    .detail-admin-state {
        padding-right: 16px;
        padding-left: 16px;
    }

    .users-context {
        align-items: stretch;
        flex-direction: column;
        padding: 16px;
    }

    .users-context h2 {
        font-size: 19px;
    }

    .users-primary-action {
        width: 100%;
    }

    .users-admin-callout {
        align-items: flex-start;
        flex-direction: column;
        padding: 16px;
    }

    .users-admin-callout .detail-action {
        width: 100%;
    }

    .users-panel-heading {
        flex-direction: column;
    }

    .role-cards {
        grid-template-columns: minmax(0, 1fr);
        padding-right: 16px;
        padding-left: 16px;
    }

    .detail-modules {
        grid-template-columns: minmax(0, 1fr);
        padding-right: 16px;
        padding-left: 16px;
    }

    .plans-intro {
        flex-direction: column;
        padding: 16px;
    }

    .plan-cards {
        grid-template-columns: minmax(0, 1fr);
        gap: 12px;
    }

    .plan-card {
        padding: 18px;
    }

    .permission-table {
        min-width: 680px;
    }
}