.alla-estrutura-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
}

.alla-estrutura-bloco {
    display: flex;
    flex-direction: column;
    min-height: 22rem;
    max-height: 22rem;
}

.alla-estrutura-bloco-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--alla-border);
    margin-bottom: 0.75rem;
}

.alla-estrutura-bloco-header h2 {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
}

.alla-estrutura-bloco-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
}

.alla-estrutura-bloco-empty {
    margin: 0;
    padding: 0.5rem 0;
}

.alla-estrutura-bloco-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.alla-estrutura-bloco-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.55rem 0;
    border-bottom: 1px solid var(--alla-border);
}

.alla-estrutura-bloco-item:last-child {
    border-bottom: none;
}

.alla-estrutura-bloco-item-main {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
    flex: 1 1 auto;
}

.alla-estrutura-bloco-item-main strong {
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.alla-estrutura-bloco-item-actions {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-shrink: 0;
}

.alla-estrutura-bloco-item-actions form {
    margin: 0;
}

.alla-estrutura-bloco-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding-top: 0.75rem;
    margin-top: auto;
    border-top: 1px solid var(--alla-border);
    font-size: 0.82rem;
}

.alla-estrutura-bloco-pager {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.alla-estrutura-bloco-pager-info {
    font-size: 0.78rem;
    color: var(--alla-text-muted);
    min-width: 2.5rem;
    text-align: center;
}

@media (max-width: 900px) {
    .alla-estrutura-grid {
        grid-template-columns: 1fr;
    }

    .alla-estrutura-bloco {
        min-height: 18rem;
        max-height: 18rem;
    }
}

.alla-estrutura-vinculo-row {
    align-items: end;
}

.alla-estrutura-form-inline {
    display: grid;
    grid-template-columns: 1fr minmax(120px, 160px) auto;
    gap: 0.75rem;
    align-items: end;
}

.alla-form-row.alla-estrutura-form-inline {
    grid-template-columns: 1fr minmax(120px, 160px) auto;
    align-items: end;
}

.alla-form-row.alla-estrutura-form-inline .alla-form-group {
    margin-bottom: 0;
}

.alla-form-group--action {
    margin-bottom: 0;
}

.alla-form-row.alla-estrutura-form-inline .alla-form-group--action .alla-btn {
    min-height: 2.35rem;
    padding: 0.45rem 1rem;
    white-space: nowrap;
}

.alla-modal-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: end;
    margin-top: 1rem;
}

.alla-modal-filters .alla-form-group {
    flex: 1;
    min-width: 160px;
    margin: 0;
}

.alla-form-group--filter-status {
    flex: 0 0 140px;
    min-width: 120px;
}

.alla-input-uppercase {
    text-transform: uppercase;
}

.alla-detento-localizacao-row {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.75rem;
}

@media (max-width: 900px) {
    .alla-estrutura-form-inline {
        grid-template-columns: 1fr;
    }

    .alla-detento-localizacao-row {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 520px) {
    .alla-detento-localizacao-row {
        grid-template-columns: 1fr;
    }
}

.alla-btn-sm {
    min-height: 1.85rem;
    padding: 0.3rem 0.6rem;
    font-size: 0.78rem;
}

.alla-estrutura-modal-list {
    max-height: 280px;
    overflow-y: auto;
    margin-top: 0.5rem;
}

.alla-link-prontuario {
    color: var(--alla-primary);
    font-weight: 700;
    text-decoration: none;
}

.alla-link-prontuario:hover {
    text-decoration: underline;
}

.alla-text-success {
    color: var(--alla-success);
}

.alla-text-danger {
    color: var(--alla-danger);
}

.alla-text-warning {
    color: #d97706;
}

.alla-text-info {
    color: #1d4ed8;
}

[data-theme="dark"] .alla-text-info {
    color: #93c5fd;
}

.alla-detento-hero {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem 1.25rem;
    padding: 1rem 1.25rem;
    margin-bottom: 1rem;
    background: linear-gradient(135deg, color-mix(in srgb, var(--alla-primary) 8%, var(--alla-surface)), var(--alla-surface));
}

.alla-detento-hero-left {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1rem 1.25rem;
    flex: 1 1 280px;
    min-width: 0;
}

.alla-detento-hero-identity {
    flex: 0 1 auto;
    min-width: 0;
}

.alla-detento-hero-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--alla-text-muted);
}

.alla-detento-hero-prontuario {
    display: block;
    font-size: 1.75rem;
    line-height: 1.2;
    margin: 0.15rem 0;
}

.alla-detento-hero-nome {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
    line-height: 1.3;
}

.alla-detento-hero-local-card {
    display: grid;
    grid-template-columns: repeat(4, minmax(4.5rem, 1fr));
    gap: 0.5rem 0.75rem;
    padding: 0.65rem 0.85rem;
    border: 1px solid var(--alla-border);
    border-radius: 0.5rem;
    background: var(--alla-surface-elevated);
    flex: 0 1 auto;
}

.alla-detento-hero-local-item span {
    display: block;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--alla-text-muted);
    margin-bottom: 0.15rem;
}

.alla-detento-hero-local-item strong {
    display: block;
    font-size: 0.95rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

.alla-detento-hero-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
    flex: 0 1 auto;
    align-items: stretch;
}

.alla-detento-hero-stat {
    min-width: 8.75rem;
    padding: 0.75rem 1rem;
    border: 1px solid var(--alla-border);
    border-radius: 0.5rem;
    background: var(--alla-surface-elevated);
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.alla-detento-hero-stat span {
    display: block;
    font-size: 0.72rem;
    color: var(--alla-text-muted);
    margin-bottom: 0.2rem;
    white-space: nowrap;
}

.alla-detento-hero-stat strong {
    font-size: 1.15rem;
    line-height: 1.2;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

a.alla-detento-hero-stat--link {
    text-decoration: none;
    color: inherit;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

a.alla-detento-hero-stat--link:hover {
    border-color: var(--alla-primary);
    box-shadow: 0 0 0 1px color-mix(in srgb, var(--alla-primary) 35%, transparent);
}

a.alla-detento-hero-stat--link:focus-visible {
    outline: 2px solid var(--alla-primary);
    outline-offset: 2px;
}

@media (max-width: 900px) {
    .alla-detento-hero-local-card {
        grid-template-columns: repeat(2, 1fr);
        width: 100%;
    }

    .alla-detento-hero-stats {
        width: 100%;
    }

    .alla-detento-hero-stat {
        flex: 1 1 calc(50% - 0.35rem);
        min-width: 7.5rem;
    }
}

@media (max-width: 480px) {
    .alla-detento-hero-stat {
        flex: 1 1 100%;
    }
}

.alla-detentos-filter select {
    min-width: 7.5rem;
}

.alla-detento-local-cell {
    font-size: 0.82rem;
    white-space: nowrap;
}

.alla-detento-saldo-cell,
.alla-detento-aberto-cell,
.alla-detento-debito-cell {
    font-weight: 600;
    white-space: nowrap;
}

.alla-detento-aberto-cell.is-destaque {
    color: #d97706;
}

.alla-detento-saldo-cell.is-positivo {
    color: var(--alla-success);
}

.alla-detento-debito-cell.is-negativo {
    color: var(--alla-danger);
}
