.counterparties-page-shell {
    grid-template-rows: auto auto auto minmax(0, 1fr) auto;
    height: 100%;
    max-height: 100%;
    box-sizing: border-box;
    padding: 12px;
    gap: 10px;
}

.counterparties-alert {
    grid-row: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 0;
}

.counterparties-header {
    grid-row: 2;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 16px;
    border-radius: 8px;
}

.counterparties-header h1 {
    margin: 0;
    color: var(--maui-white);
    font-size: 20px;
    font-weight: 700;
}

.counterparties-header .btn img {
    width: 16px;
    height: 16px;
    margin-right: 6px;
}

.counterparties-search-row {
    grid-row: 3;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 40px;
    gap: 8px;
    align-items: center;
}

.counterparties-search-box {
    position: relative;
}

.counterparties-search-box > img {
    position: absolute;
    left: 12px;
    top: 50%;
    z-index: 1;
    width: 18px;
    height: 18px;
    transform: translateY(-50%);
    opacity: .65;
}

.counterparties-search-box .maui-form-input {
    padding-left: 40px;
}

.counterparties-list-frame {
    grid-row: 4;
    min-height: 0;
    overflow: auto;
}

.counterparties-list {
    display: grid;
    align-content: start;
    gap: 4px;
}

.counterparty-row {
    display: grid;
    grid-template-columns: 44px minmax(220px, 1.2fr) minmax(160px, .8fr) auto;
    gap: 14px;
    align-items: center;
    min-height: 64px;
    padding: 9px 12px;
    border-bottom: 1px solid var(--maui-gray-100);
    background: var(--maui-white);
    color: var(--maui-text-primary);
    cursor: pointer;
}

.counterparty-row:hover,
.counterparty-row.is-selected {
    background: var(--maui-brand-primary-light);
}

.counterparty-avatar {
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: var(--maui-gray-100);
    color: var(--maui-brand-primary);
    font-weight: 700;
}

.counterparty-main,
.counterparty-contact {
    min-width: 0;
    display: grid;
    gap: 3px;
}

.counterparty-main strong,
.counterparty-main small,
.counterparty-contact span,
.counterparty-contact small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.counterparty-main small,
.counterparty-contact small {
    color: var(--maui-text-secondary);
    font-size: 12px;
}

.counterparty-row-actions,
.counterparties-footer,
.counterparty-editor-footer {
    display: flex;
    align-items: center;
    gap: 8px;
}

.counterparties-footer {
    grid-row: 5;
    min-height: 58px;
    max-height: 58px;
    padding: 10px 16px;
    background: var(--maui-neutral-light);
    border-top: 1px solid var(--maui-gray-200);
}

.counterparties-empty {
    gap: 10px;
}

.counterparty-editor-dialog {
    position: fixed;
    inset: 50% auto auto 50%;
    transform: translate(-50%, -50%);
    width: min(500px, calc(100vw - 32px));
    max-width: none;
    max-height: calc(100vh - 32px);
}

.counterparty-editor-card {
    max-height: calc(100vh - 32px);
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    overflow: hidden;
}

.counterparty-editor-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.counterparty-editor-header h2 {
    margin: 0;
    color: var(--maui-white);
    font-size: 20px;
    font-weight: 700;
}

.counterparty-editor-body {
    min-height: 0;
    overflow: auto;
    display: grid;
    gap: 14px;
    padding: 20px;
}

.counterparty-editor-body label {
    display: grid;
    gap: 5px;
}

.counterparty-editor-footer {
    justify-content: flex-end;
    min-height: 58px;
    padding: 10px 20px;
    background: var(--maui-neutral-light);
    border-top: 1px solid var(--maui-gray-200);
}

@media (max-width: 720px) {
    .counterparty-row {
        grid-template-columns: 44px minmax(0, 1fr) auto;
    }

    .counterparty-contact {
        display: none;
    }

    .counterparties-footer {
        flex-wrap: wrap;
    }
}
