.database-action-btn {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    border: 1px solid #dbe4f0;
    border-radius: 999px;
    background: #fff;
    color: #475569;
    padding: .28rem .55rem;
    font-size: .7rem;
    font-weight: 750;
    line-height: 1;
    transition: color .15s, border-color .15s, background .15s, transform .15s;
}

.database-action-btn:hover {
    color: #1d4ed8;
    border-color: #93c5fd;
    background: #eff6ff;
    transform: translateY(-1px);
}

.database-settings-modal .modal-dialog {
    max-width: min(1180px, calc(100vw - 1.5rem));
}

.database-settings-modal .modal-content {
    border: 0;
    border-radius: 1.1rem;
    overflow: hidden;
    box-shadow: 0 1.5rem 5rem rgba(15, 23, 42, .3);
}

.database-settings-modal form {
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.database-settings-header {
    border: 0;
    background: linear-gradient(125deg, #0f172a, #1e3a8a 58%, #6d28d9);
    color: #fff;
}

.database-settings-header-icon {
    width: 2.6rem;
    height: 2.6rem;
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    border: 1px solid rgba(255,255,255,.24);
    border-radius: .8rem;
    background: rgba(255,255,255,.12);
    font-size: 1.25rem;
}

.database-settings-subtitle {
    margin-top: .18rem;
    color: rgba(255,255,255,.72);
    font-size: .76rem;
}

.database-current-engine {
    border: 1px solid rgba(255,255,255,.2);
    border-radius: 999px;
    background: rgba(255,255,255,.12);
    color: #fff;
    padding: .2rem .5rem;
    font-size: .66rem;
    font-weight: 800;
}

.min-w-0 { min-width: 0; }

.database-settings-modal .modal-body {
    min-height: 31rem;
    max-height: min(76vh, 760px);
    background: #f8fafc;
}

.database-settings-loading {
    position: absolute;
    inset: 0;
    z-index: 8;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .75rem;
    background: rgba(248,250,252,.94);
    color: #475569;
    font-weight: 700;
}

.database-settings-loading.is-hidden { display: none; }

.database-settings-layout {
    min-height: 31rem;
    display: grid;
    grid-template-columns: 17rem minmax(0, 1fr);
}

.database-engine-panel {
    border-right: 1px solid #e2e8f0;
    background: linear-gradient(180deg, #fff, #f8fafc);
    padding: 1.15rem;
}

.database-engine-list {
    display: grid;
    gap: .48rem;
}

.database-engine-choice {
    position: relative;
    width: 100%;
    min-width: 0;
    display: grid;
    grid-template-columns: 2.25rem minmax(0, 1fr) 1rem;
    align-items: center;
    gap: .6rem;
    border: 1px solid #e2e8f0;
    border-radius: .78rem;
    background: #fff;
    color: #334155;
    padding: .54rem .62rem;
    text-align: left;
    transition: border-color .15s, box-shadow .15s, transform .15s, background .15s;
}

.database-engine-choice:hover:not(:disabled),
.database-engine-choice.active {
    border-color: var(--db-color);
    background: var(--db-tint);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--db-color) 11%, transparent);
    transform: translateX(2px);
}

.database-engine-choice:disabled {
    cursor: not-allowed;
    opacity: .5;
}

.database-engine-choice-icon {
    width: 2.2rem;
    height: 2.2rem;
    display: grid;
    place-items: center;
    border-radius: .65rem;
    background: var(--db-color);
    color: #fff;
}

.database-engine-choice-copy {
    min-width: 0;
    display: block;
}

.database-engine-choice-copy strong,
.database-engine-choice-copy small {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.database-engine-choice-copy strong { font-size: .75rem; }
.database-engine-choice-copy small { color: #64748b; font-size: .61rem; margin-top: .08rem; }
.database-engine-selected { color: var(--db-color); opacity: 0; }
.database-engine-choice.active .database-engine-selected { opacity: 1; }

.database-engine-note {
    display: flex;
    align-items: flex-start;
    gap: .45rem;
    border-radius: .65rem;
    background: #f1f5f9;
    color: #64748b;
    padding: .6rem;
    font-size: .66rem;
    line-height: 1.35;
}

.database-engine-note i { color: #2563eb; }

.database-connection-editor {
    min-width: 0;
    padding: 1.15rem 1.25rem 1.35rem;
    overflow-y: auto;
}

.database-connection-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}

.database-connection-heading p {
    color: #64748b;
    font-size: .76rem;
}

.database-saved-summary {
    max-width: 45%;
    border: 1px solid #dbeafe;
    border-radius: .7rem;
    background: #eff6ff;
    padding: .45rem .62rem;
    text-align: right;
}

.database-saved-summary span,
.database-saved-summary strong { display: block; }
.database-saved-summary span { color: #64748b; font-size: .58rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; }
.database-saved-summary strong { color: #1e40af; font-size: .7rem; overflow-wrap: anywhere; }

.database-source-warning {
    display: flex;
    gap: .7rem;
    margin-bottom: 1rem;
    border: 1px solid #fbbf24;
    border-radius: .8rem;
    background: #fffbeb;
    color: #92400e;
    padding: .72rem .82rem;
    font-size: .75rem;
}

.database-source-warning > i { flex: 0 0 auto; color: #d97706; font-size: 1.05rem; }
.database-source-warning p { margin: .15rem 0 0; color: #a16207; font-size: .7rem; }
.database-source-warning .form-check-label { font-weight: 700; }

.database-fields-card {
    border: 1px solid #e2e8f0;
    border-radius: .85rem;
    background: #fff;
    padding: .9rem;
    box-shadow: 0 1px 3px rgba(15,23,42,.04);
}

.database-settings-modal .form-label {
    margin-bottom: .3rem;
    color: #475569;
    font-size: .7rem;
    font-weight: 800;
}

.database-settings-modal .form-control,
.database-settings-modal .form-select,
.database-settings-modal .input-group-text {
    min-height: 2.35rem;
    border-color: #dbe3ec;
    font-size: .8rem;
}

.database-settings-modal .form-control:focus,
.database-settings-modal .form-select:focus {
    border-color: #60a5fa;
    box-shadow: 0 0 0 .18rem rgba(37,99,235,.12);
}

.database-advanced {
    border: 1px solid #e2e8f0;
    border-radius: .8rem;
    background: #fff;
    overflow: hidden;
}

.database-advanced summary {
    display: flex;
    align-items: center;
    cursor: pointer;
    list-style: none;
    color: #334155;
    padding: .7rem .82rem;
    font-size: .75rem;
    font-weight: 800;
}

.database-advanced summary::-webkit-details-marker { display: none; }
.database-advanced[open] summary { border-bottom: 1px solid #e2e8f0; }
.database-advanced[open] summary .bi-chevron-down { transform: rotate(180deg); }
.database-advanced-body { background: #fbfdff; padding: .8rem; }

.database-test-result {
    display: flex;
    align-items: center;
    gap: .55rem;
    border: 1px solid #dbeafe;
    border-radius: .72rem;
    background: #eff6ff;
    color: #475569;
    padding: .62rem .75rem;
    font-size: .72rem;
}

.database-test-result.is-success { border-color: #a7f3d0; background: #ecfdf5; color: #047857; }
.database-test-result.is-error { border-color: #fecaca; background: #fef2f2; color: #b91c1c; }
.database-test-result.is-pending { border-color: #fde68a; background: #fffbeb; color: #92400e; }

.database-settings-footer {
    border-top: 1px solid #e2e8f0;
    background: #fff;
}

.database-unsaved-indicator {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    color: #64748b;
    font-size: .68rem;
    font-weight: 700;
}

.database-unsaved-indicator span {
    width: .48rem;
    height: .48rem;
    border-radius: 50%;
    background: #22c55e;
}

.database-unsaved-indicator.is-dirty span { background: #f59e0b; }
.database-unsaved-indicator.is-tested span { background: #2563eb; }

@media (max-width: 991.98px) {
    .database-settings-layout { grid-template-columns: 1fr; }
    .database-engine-panel { border-right: 0; border-bottom: 1px solid #e2e8f0; }
    .database-engine-list { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .database-engine-choice { grid-template-columns: 2rem minmax(0, 1fr); }
    .database-engine-selected { display: none; }
    .database-settings-modal .modal-body { max-height: 78vh; }
}

@media (max-width: 575.98px) {
    .database-settings-modal .modal-dialog { max-width: calc(100vw - .5rem); margin: .25rem; }
    .database-settings-modal .modal-content { border-radius: .8rem; }
    .database-settings-header-icon { display: none; }
    .database-engine-panel, .database-connection-editor { padding: .85rem; }
    .database-engine-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .database-engine-choice { display: flex; padding: .48rem; }
    .database-engine-choice-icon { width: 1.9rem; height: 1.9rem; }
    .database-connection-heading { display: block; }
    .database-saved-summary { max-width: none; margin-top: .65rem; text-align: left; }
    .database-settings-footer { gap: .45rem; }
    .database-unsaved-indicator { width: 100%; }
}
