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

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

.database-filter-bar {
    grid-row: 2;
    display: grid;
    grid-template-columns: minmax(220px, auto) minmax(260px, 1fr) minmax(220px, auto);
    align-items: center;
    gap: 12px;
}

.database-filter-select {
    min-width: 180px;
}

.database-search {
    min-width: 0;
}

.database-resource-filter {
    justify-content: end;
}

.database-title-row {
    grid-row: 3;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.database-title-row h1 {
    margin: 0;
    color: var(--maui-brand-primary);
    font-size: 20px;
    font-weight: 700;
}

.database-title-actions,
.database-checkbox-row,
.database-window-footer,
.maui-file-picker-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.database-checkbox-row {
    color: var(--maui-text-primary);
    font-size: 14px;
    font-weight: 600;
}

.database-checkbox-row input,
.database-table-row > input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--maui-brand-primary);
}

.database-table-frame {
    grid-row: 4;
    min-height: 0;
    overflow: hidden;
    background: var(--maui-white);
}

.database-table {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    height: 100%;
    min-width: 920px;
}

.database-table-header,
.database-table-row {
    display: grid;
    grid-template-columns: 40px 110px minmax(280px, 3fr) 100px 80px 120px 50px;
    gap: 5px;
    align-items: center;
}

.database-table-header {
    min-height: 42px;
    padding: 0 10px;
    background: var(--maui-neutral-light);
    border-bottom: 1px solid var(--maui-gray-200);
    color: var(--maui-gray-600);
    font-size: 13px;
    font-weight: 700;
}

.database-table-header span:nth-child(2),
.database-table-header span:nth-child(4),
.database-table-header span:nth-child(5),
.database-table-header span:nth-child(7) {
    text-align: center;
}

.database-table-header span:nth-child(6) {
    text-align: right;
}

.database-table-body {
    min-height: 0;
    overflow: auto;
}

.database-table-row {
    min-height: 42px;
    padding: 5px 10px;
    border-bottom: 1px solid var(--maui-gray-100);
    color: var(--maui-text-primary);
    font-size: 13px;
}

.database-item-row {
    cursor: pointer;
}

.database-item-row:hover,
.database-item-row.is-focused {
    background: var(--maui-brand-primary-light);
}

.database-group-row {
    background: var(--maui-gray-100);
}

.database-name-button {
    display: flex;
    align-items: center;
    gap: 4px;
    border: 0;
    padding: 0;
    background: transparent;
    color: var(--maui-text-primary);
    text-align: left;
}

.database-expand {
    width: 20px;
    color: var(--maui-brand-primary);
    font-size: 12px;
}

.database-item-name {
    padding-left: 20px;
    line-height: 1.3;
}

.database-price {
    color: var(--maui-brand-primary);
    font-weight: 700;
}

.database-footer {
    grid-row: 5;
    display: flex;
    align-items: center;
    align-self: stretch;
    gap: 10px;
    min-height: 58px;
    max-height: 58px;
    padding: 10px 16px;
    background: var(--maui-neutral-light);
    border-top: 1px solid var(--maui-gray-200);
}

.database-footer > strong {
    color: var(--maui-brand-primary);
}

.database-centered-page {
    min-height: calc(100vh - 24px);
    display: grid;
    place-items: center;
    padding: 20px;
}

.database-import-card,
.database-units-card {
    width: min(620px, calc(100vw - 40px));
    max-height: calc(100vh - 40px);
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    overflow: hidden;
}

.database-window-title {
    margin: 0;
    color: var(--maui-white);
    font-size: 20px;
    font-weight: 700;
}

.database-import-body,
.database-units-body,
.database-editor-body {
    min-height: 0;
    overflow: auto;
    padding: 20px 24px;
}

.database-import-body {
    display: grid;
    align-content: start;
    gap: 16px;
}

.database-import-log-field {
    display: grid;
    gap: 6px;
}

.database-import-log {
    min-height: 240px;
    resize: none;
}

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

.database-units-body {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
}

.database-units-header,
.database-unit-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px;
    align-items: center;
}

.database-units-header {
    padding: 0 10px 8px;
}

.database-units-list {
    min-height: 260px;
    max-height: 480px;
    overflow: auto;
    border-top: 1px solid var(--maui-gray-200);
}

.database-unit-row {
    width: 100%;
    border: 0;
    border-bottom: 1px solid var(--maui-gray-100);
    padding: 9px 10px;
    background: var(--maui-white);
    color: var(--maui-text-primary);
    text-align: left;
}

.database-unit-row span:last-child {
    color: var(--maui-text-secondary);
    font-size: 12px;
}

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

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

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

.database-editor-body {
    display: grid;
    gap: 14px;
}

.database-picker-with-action {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 40px;
    gap: 10px;
}

.database-editor-numbers {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.database-name-editor {
    min-height: 64px;
}

@media (max-width: 900px) {
    .database-page-shell {
        overflow: auto;
    }

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

    .database-resource-filter {
        justify-content: start;
    }

    .database-title-row,
    .database-footer {
        align-items: flex-start;
        flex-wrap: wrap;
    }

    .database-table-frame {
        min-height: 520px;
        overflow: auto;
    }

    .database-editor-numbers {
        grid-template-columns: 1fr;
    }
}
