/* ── Tables module specific styles ──────────────────────────────────── */

.tables-guide-header-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    border-radius: 999px;
    padding: 0.18rem 0.5rem;
    font-size: 0.68rem;
    font-weight: 750;
    line-height: 1.15;
    white-space: nowrap;
}

.tables-guide-header-btn i {
    font-size: 0.72rem;
}

.tables-tooltip .tooltip-inner {
    max-width: 280px;
    border: 1px solid rgba(125, 211, 252, 0.28);
    border-radius: 0.65rem;
    background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 100%);
    color: #f8fafc;
    padding: 0.46rem 0.65rem;
    box-shadow: 0 0.7rem 1.6rem rgba(15, 23, 42, 0.26);
    font-size: 0.72rem;
    font-weight: 650;
    line-height: 1.35;
    text-align: left;
}

.tables-tooltip.bs-tooltip-top .tooltip-arrow::before {
    border-top-color: #1e3a8a;
}

.tables-tooltip.bs-tooltip-bottom .tooltip-arrow::before {
    border-bottom-color: #0f172a;
}

.tables-tooltip.bs-tooltip-start .tooltip-arrow::before {
    border-left-color: #1e3a8a;
}

.tables-tooltip.bs-tooltip-end .tooltip-arrow::before {
    border-right-color: #0f172a;
}

.table-list {
    list-style: none;
    margin: 0;
    padding: 0;
    background: #fff;
}

.table-filter {
    position: relative;
    padding: 0.45rem 0.55rem;
    border-bottom: 1px solid #edf0f3;
    background: #fff;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0.4rem;
    align-items: center;
}

.table-filter i {
    position: absolute;
    left: 0.95rem;
    top: 50%;
    transform: translateY(-50%);
    color: #94a3b8;
    font-size: 0.78rem;
    pointer-events: none;
}

.table-filter input {
    width: 100%;
    border: 1px solid #e2e8f0;
    border-radius: 0.55rem;
    background: #f8fafc;
    color: #334155;
    padding: 0.34rem 0.65rem 0.34rem 1.85rem;
    font-size: 0.78rem;
    outline: none;
}

.table-list-stats {
    border-radius: 999px;
    background: #eef4ff;
    color: #3563a8;
    padding: 0.25rem 0.5rem;
    font-size: 0.68rem;
    font-weight: 750;
    white-space: nowrap;
}

.table-filter input:focus {
    border-color: #93c5fd;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}

.left-panel .table-list > .table-group {
    display: block;
    padding: 0;
    border: 0;
    border-bottom: 1px solid #edf0f3;
    cursor: default;
    gap: 0;
    font-size: inherit;
    transition: none;
}

.left-panel .table-list > .table-group:hover {
    background: transparent;
}

.table-group-header {
    width: 100%;
    border: 0;
    border-left: 3px solid transparent;
    background: linear-gradient(180deg, #fbfcfe 0%, #f6f8fb 100%);
    color: #4b5563;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    min-height: 2.35rem;
    padding: 0.45rem 0.65rem 0.45rem 0.7rem;
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.075em;
    text-transform: uppercase;
    position: sticky;
    top: 0;
    z-index: 3;
}

.table-group-header:hover {
    background: #eef4ff;
}

.table-group[data-group="project"] > .table-group-header {
    border-left-color: #0d6efd;
}

.table-group[data-group="system-generated"] > .table-group-header {
    border-left-color: #94a3b8;
}

.table-group-title {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    min-width: 0;
}

.table-group-title i {
    color: #64748b;
    font-size: 0.76rem;
}

.table-group-count {
    min-width: 1.35rem;
    border-radius: 999px;
    background: #e8eef8;
    color: #475569;
    padding: 0.04rem 0.42rem;
    text-align: center;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0;
}

.table-group-body {
    list-style: none;
    margin: 0;
    padding: 0;
    background: #fff;
}

.table-group.collapsed .table-group-body {
    display: none;
}

.left-panel .table-list .table-group-body > .table-list-item {
    display: grid;
    grid-template-columns: 1.15rem minmax(0, 1fr) auto;
    align-items: center;
    gap: 0.45rem;
    min-height: 1.9rem;
    padding: 0.24rem 0.55rem 0.24rem 0.75rem;
    border: 0;
    border-top: 1px solid #f3f5f7;
    cursor: pointer;
    color: #2f3742;
    font-size: 0.79rem;
    transition: background 0.12s ease, color 0.12s ease;
}

.left-panel .table-list .table-group-body > .table-list-item:hover {
    background: #f5f9ff;
}

.table-list-item .table-check {
    width: 0.95rem;
    height: 0.95rem;
    margin: 0;
}

.table-list-item .table-row-label {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    margin: 0;
    min-width: 0;
    cursor: pointer;
}

.table-list-item .table-row-label i {
    color: #56616f;
    font-size: 0.84rem;
    flex: 0 0 auto;
}

.table-list-item .table-row-name {
    display: block;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 550;
}

.table-row-meta {
    color: #94a3b8;
    font-size: 0.68rem;
    font-weight: 750;
    letter-spacing: 0.04em;
    min-width: 1rem;
    text-align: right;
}

.table-row-meta .bi-shield-lock {
    font-size: 0.78rem;
}

.left-panel .table-list .table-group-body > .table-list-item[data-scope="system"] {
    color: #697386;
    background: #fcfdff;
}

.left-panel .table-list .table-group-body > .table-list-item[data-scope="system"]:hover {
    background: #f6f8fb;
}

.table-list-item[data-scope="system"] .table-row-label i,
.table-list-item[data-scope="system"] .table-row-name {
    color: #697386;
}

.info-banner {
    background: #e7f1ff;
    border: 1px solid #b6d4fe;
    border-radius: 0.375rem;
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    font-weight: 500;
}

.field-card {
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    padding: 0.75rem 1rem;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: box-shadow 0.15s;
}
.field-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.08); }
.field-card .field-icon {
    width: 36px; height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    flex-shrink: 0;
}
.field-card .field-info { flex: 1; }
.field-card .field-name { font-weight: 600; }
.field-card .field-meta { font-size: 0.85rem; color: #6c757d; }
.field-badges { display: flex; gap: 0.25rem; flex-wrap: wrap; }

/* Create/Edit Table schema modals */
.table-schema-modal {
    width: min(1180px, calc(100vw - 2.5rem));
    max-width: min(1180px, calc(100vw - 2.5rem));
}

.table-schema-modal .modal-content {
    position: relative;
    border: 0;
    border-radius: 0.75rem;
    overflow: hidden;
    box-shadow: 0 1rem 3rem rgba(15, 23, 42, 0.28);
}

.table-schema-modal.schema-modal-draggable .modal-content {
    cursor: grab;
    user-select: none;
    touch-action: none;
}

.table-schema-modal.schema-modal-draggable .modal-content input,
.table-schema-modal.schema-modal-draggable .modal-content select,
.table-schema-modal.schema-modal-draggable .modal-content textarea,
.table-schema-modal.schema-modal-draggable .modal-content button,
.table-schema-modal.schema-modal-draggable .schema-fields-wrap,
.table-schema-modal.schema-modal-draggable .modal-footer {
    cursor: auto;
    user-select: auto;
}

.table-schema-modal.schema-modal-draggable .modal-header {
    cursor: grab;
}

.table-schema-modal.schema-modal-draggable .modal-content:active,
.table-schema-modal.schema-modal-dragging .modal-content,
.table-schema-modal.schema-modal-dragging .modal-header {
    cursor: grabbing;
}

.table-schema-modal.schema-modal-dragging {
    transition: none !important;
}

.table-schema-modal.schema-modal-resizing,
.table-schema-modal.schema-modal-resizing * {
    user-select: none !important;
}

.schema-resize-edge {
    position: absolute;
    z-index: 8;
    opacity: 0;
    transition: opacity 0.15s ease, background 0.15s ease;
}

.table-schema-modal .modal-content:hover .schema-resize-edge {
    opacity: 1;
}

.schema-resize-right {
    top: 3.25rem;
    right: 0;
    bottom: 3.25rem;
    width: 0.6rem;
    cursor: ew-resize;
}

.schema-resize-bottom {
    right: 3.25rem;
    bottom: 0;
    left: 3.25rem;
    height: 0.6rem;
    cursor: ns-resize;
}

.schema-resize-corner {
    right: 0.15rem;
    bottom: 0.15rem;
    width: 1.05rem;
    height: 1.05rem;
    border-right: 3px solid rgba(37, 99, 235, 0.5);
    border-bottom: 3px solid rgba(37, 99, 235, 0.5);
    border-radius: 0 0 0.45rem 0;
    cursor: nwse-resize;
}

.schema-resize-right:hover,
.schema-resize-bottom:hover {
    background: rgba(37, 99, 235, 0.13);
}

.schema-resize-corner:hover {
    border-color: rgba(37, 99, 235, 0.85);
}

.table-schema-modal .modal-body {
    background: #f8fafc;
    max-height: min(74vh, 820px);
    overflow: auto;
    padding: 0.9rem 1rem !important;
}

.table-schema-modal .modal-footer {
    background: #fff;
    border-top: 1px solid #e5e7eb;
}

.schema-top-row {
    display: grid;
    grid-template-columns: minmax(280px, 0.78fr) minmax(0, 1.72fr);
    gap: 0.55rem;
    align-items: center;
}

.schema-table-meta {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 0.55rem;
    align-items: center;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 0.65rem;
    padding: 0.38rem 0.55rem;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.schema-table-meta .form-label {
    white-space: nowrap;
    margin: 0 !important;
}

.schema-help {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    color: #475569;
    background: #eef6ff;
    border: 1px solid #cfe4ff;
    border-radius: 0.6rem;
    padding: 0.38rem 0.65rem;
    font-size: 0.78rem;
    line-height: 1.2;
    min-height: 100%;
}

.schema-help i {
    color: #0d6efd;
    margin-top: 0;
    flex: 0 0 auto;
}

.schema-help span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.schema-section-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin: 0.35rem 0 0.45rem;
}

.schema-fields-wrap {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 0.7rem;
    overflow: auto;
    max-height: min(52vh, 590px);
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
}

.schema-field-header,
.schema-field-row {
    display: grid;
    grid-template-columns:
        minmax(170px, 1.15fr)
        minmax(165px, 1fr)
        minmax(124px, 0.62fr)
        minmax(96px, 0.55fr)
        minmax(310px, 1.8fr)
        minmax(145px, 0.75fr)
        42px;
    gap: 0.45rem;
    align-items: center;
    min-width: 1110px;
}

.schema-field-header {
    position: sticky;
    top: 0;
    z-index: 2;
    padding: 0.48rem 0.65rem;
    color: #64748b;
    background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
    border-bottom: 1px solid #e2e8f0;
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.schema-field-row {
    padding: 0.42rem 0.65rem;
    border-bottom: 1px solid #f1f5f9;
    background: #fff;
}

.schema-field-row:nth-child(even) {
    background: #fcfdff;
}

.schema-field-row:hover {
    background: #f8fbff;
}

.schema-field-row:last-child {
    border-bottom: 0;
}

.schema-cell {
    min-width: 0;
}

.schema-field-row input,
.schema-field-row select {
    min-width: 0;
    width: 100%;
    border-color: #dbe3ec;
    font-size: 0.82rem;
    padding: 0.32rem 0.48rem;
}

.schema-field-row input:focus,
.schema-field-row select:focus {
    border-color: #7bb7ff;
    box-shadow: 0 0 0 0.18rem rgba(13, 110, 253, 0.12);
}

.schema-field-row input:disabled,
.schema-field-row select:disabled {
    color: #64748b;
    background-color: #eef2f7;
    opacity: 1;
}

.schema-field-row .default-cell {
    display: grid;
    grid-template-columns: minmax(8.75rem, 0.9fr) minmax(9rem, 1.1fr);
    gap: 0.35rem;
}

.schema-field-row .field-size-cell {
    display: flex;
    gap: 0.3rem;
}

.schema-field-row .field-size-cell .field-scale {
    min-width: 3.5rem;
}

.schema-field-row .field-key-cell {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    flex-wrap: wrap;
}

.schema-field-row .schema-check {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    margin-right: 0 !important;
    padding: 0.18rem 0.45rem;
    border: 1px solid #e2e8f0;
    border-radius: 999px;
    background: #f8fafc;
    transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.schema-field-row .schema-check .form-check-input {
    width: 0.95rem;
    height: 0.95rem;
    margin: 0;
}

.schema-field-row .schema-check .form-check-label {
    margin: 0;
    color: #334155;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    opacity: 1 !important;
}

.schema-field-row .schema-check-pk {
    border-color: #ddd6fe;
    background: #f5f3ff;
}

.schema-field-row .schema-check-ai {
    border-color: #bfdbfe;
    background: #eff6ff;
}

.schema-field-row .schema-check-pk .form-check-label {
    color: #6d28d9;
}

.schema-field-row .schema-check-ai .form-check-label {
    color: #1d4ed8;
}

.schema-field-row .schema-check-pk .form-check-input {
    border-color: #8b5cf6;
}

.schema-field-row .schema-check-ai .form-check-input {
    border-color: #2563eb;
}

.schema-field-row .schema-check-pk .form-check-input:checked {
    background-color: #7c3aed;
    border-color: #7c3aed;
}

.schema-field-row .schema-check-ai .form-check-input:checked {
    background-color: #2563eb;
    border-color: #2563eb;
}

.schema-field-row .schema-check-pk:has(.form-check-input:checked) {
    border-color: #8b5cf6;
    background: #ede9fe;
    box-shadow: inset 0 0 0 1px rgba(124, 58, 237, 0.18);
}

.schema-field-row .schema-check-ai:has(.form-check-input:checked) {
    border-color: #2563eb;
    background: #dbeafe;
    box-shadow: inset 0 0 0 1px rgba(37, 99, 235, 0.16);
}

.schema-field-row .schema-check .form-check-input:disabled {
    opacity: 1;
}

.schema-field-row .schema-check:has(.form-check-input:disabled) {
    opacity: 1;
}

.schema-field-row .enum-values {
    flex: 1 0 100%;
}

.schema-field-row .field-remove-cell {
    display: flex;
    justify-content: flex-end;
}

.schema-field-row .remove-field {
    width: 2rem;
    height: 2rem;
    border-radius: 0.5rem;
}

@media (max-width: 1200px) {
    .table-schema-modal {
        width: calc(100vw - 1rem);
        max-width: calc(100vw - 1rem);
    }

    .schema-field-header,
    .schema-field-row {
        min-width: 1060px;
    }
}

@media (max-width: 768px) {
    .table-schema-modal .modal-body {
        max-height: 76vh;
        padding: 0.75rem !important;
    }

    .schema-top-row {
        grid-template-columns: 1fr;
    }

    .schema-table-meta {
        grid-template-columns: 1fr;
        gap: 0.25rem;
    }

    .schema-help span {
        white-space: normal;
    }

    .schema-section-title {
        align-items: flex-start;
        flex-direction: column;
        gap: 0.1rem;
    }

    .schema-field-header,
    .schema-field-row {
        grid-template-columns:
            minmax(150px, 1fr)
            minmax(150px, 1fr)
            118px
            92px
            minmax(280px, 1.8fr)
            132px
            40px;
        min-width: 980px;
    }
}

/* Selected table cards */
#selectedTablesContainer {
    position: relative;
    overflow: hidden;
    gap: 0.5rem !important;
    padding: 0.5rem !important;
}

.table-card {
    position: absolute;
    width: 250px;
    border: 1px solid #dee2e6;
    border-radius: 0.5rem;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    transition: box-shadow 0.2s;
    cursor: grab;
    font-size: 0.8rem;
    margin-bottom: 0;
    z-index: 1;
}
.table-card:active { cursor: grabbing; }
.table-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.12); }
.table-card.dragging { opacity: 0.5; z-index: 1000; }
.table-card.system-table-card {
    border-style: dashed;
    background: #fbfcfe;
}
.table-card.system-table-card .card-header {
    background: #f1f3f5;
    color: #6c757d;
}

.table-card .card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.35rem 0.5rem;
    background: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
    user-select: none;
    font-size: 0.85rem;
}
.table-card .card-header .card-title {
    font-weight: 600;
    font-size: 0.8rem;
    margin: 0;
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.relation-count-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.25rem;
    height: 1.25rem;
    margin-left: 0.35rem;
    border-radius: 999px;
    color: #fff;
    font-size: 0.68rem;
    font-weight: 800;
    line-height: 1;
    vertical-align: middle;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.16);
}
.table-card .card-header .btn-group .btn {
    padding: 0.1rem 0.3rem;
    font-size: 0.8rem;
}
.table-card .card-body {
    padding: 0.35rem 0.5rem;
    max-height: 200px;
    overflow-y: auto;
    font-size: 0.75rem;
}
.table-card .card-body.collapsed { display: none; }

.table-card .field-list-item {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.1rem 0;
    border-bottom: 1px solid #f0f0f0;
    font-size: 0.7rem;
    line-height: 1.2;
}
.table-card .field-list-item:last-child { border: none; }
.table-card .field-list-item .fi { width: 20px; text-align: center; }

/* Empty selection message */
#emptySelection .display-1 { font-size: 3rem; }

/* Relation designer modal */
.relation-designer-modal {
    max-width: min(1040px, calc(100vw - 2rem));
}

.relation-designer-modal .modal-content {
    border: 0;
    border-radius: 0.8rem;
    overflow: hidden;
    box-shadow: 0 1rem 3rem rgba(15, 23, 42, 0.28);
}

.relation-modal-header {
    color: #fff;
    background: linear-gradient(135deg, #0f766e 0%, #0ea5e9 100%);
    border-bottom: 0;
}

.relation-modal-header-edit {
    background: linear-gradient(135deg, #475569 0%, #2563eb 100%);
}

.relation-modal-subtitle {
    display: block;
    margin-top: 0.1rem;
    color: rgba(255, 255, 255, 0.82);
    font-size: 0.72rem;
}

.relation-modal-body {
    background: #f8fafc;
    padding: 0.85rem 1rem !important;
}

.relation-modal-footer {
    background: #fff;
    border-top: 1px solid #e5e7eb;
}

.relation-help {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    margin-bottom: 0.75rem;
    border: 1px solid #bae6fd;
    border-radius: 0.65rem;
    background: #eff6ff;
    color: #475569;
    padding: 0.5rem 0.65rem;
    font-size: 0.78rem;
}

.relation-help i {
    color: #0284c7;
    flex: 0 0 auto;
}

.relation-guide {
    margin: -0.25rem 0 0.75rem;
    border: 1px solid #dbeafe;
    border-radius: 0.7rem;
    background: #fff;
    color: #475569;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.relation-guide summary {
    cursor: pointer;
    list-style: none;
    padding: 0.5rem 0.65rem;
    color: #1d4ed8;
    font-size: 0.78rem;
    font-weight: 800;
}

.relation-guide summary::-webkit-details-marker {
    display: none;
}

.relation-guide-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.5rem;
    border-top: 1px solid #e2e8f0;
    padding: 0.6rem;
}

.relation-guide-grid div {
    border-radius: 0.55rem;
    background: #f8fafc;
    padding: 0.5rem;
}

.relation-guide-grid strong {
    display: block;
    color: #1e293b;
    font-size: 0.72rem;
}

.relation-guide-grid span {
    display: block;
    color: #64748b;
    font-size: 0.68rem;
    line-height: 1.25;
}

.relation-map {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 5.5rem minmax(0, 1fr);
    gap: 0.7rem;
    align-items: stretch;
    margin-bottom: 0.75rem;
}

.relation-node {
    border: 1px solid #dbe4ef;
    border-radius: 0.75rem;
    background: #fff;
    padding: 0.75rem;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
}

.relation-node-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.55rem;
    color: #0f172a;
    font-weight: 800;
}

.relation-node-title small {
    color: #64748b;
    font-size: 0.68rem;
    font-weight: 700;
}

.relation-node-master {
    border-top: 3px solid #0ea5e9;
}

.relation-node-detail {
    border-top: 3px solid #7c3aed;
}

.relation-control {
    display: grid;
    grid-template-columns: 4.5rem minmax(0, 1fr);
    align-items: center;
    gap: 0.5rem;
    margin: 0 0 0.5rem;
}

.relation-control:last-child {
    margin-bottom: 0;
}

.relation-control > span {
    color: #64748b;
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.relation-control input,
.relation-control select {
    border-color: #dbe3ec;
    font-size: 0.84rem;
}

.relation-control input[readonly] {
    color: #334155;
    background: #f8fafc;
    font-weight: 700;
}

.relation-flow {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
    position: relative;
}

.relation-flow-line {
    position: absolute;
    left: 0.45rem;
    right: 0.45rem;
    height: 2px;
    border-radius: 999px;
    background: linear-gradient(90deg, #0ea5e9, #7c3aed);
}

.relation-flow-icon {
    position: relative;
    z-index: 1;
    width: 2.25rem;
    height: 2.25rem;
    border: 1px solid #bfdbfe;
    border-radius: 999px;
    background: #fff;
    color: #2563eb;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.16);
}

.relation-section {
    border: 1px solid #e2e8f0;
    border-radius: 0.75rem;
    background: #fff;
    padding: 0.7rem;
    margin-bottom: 0.75rem;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.05);
}

.relation-section-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.55rem;
}

.relation-section-title span {
    color: #0f172a;
    font-size: 0.86rem;
    font-weight: 800;
}

.relation-section-title small {
    color: #64748b;
    font-size: 0.72rem;
}

.relation-choice-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.55rem;
}

.relation-choice,
.relation-option-card,
.relation-page-chip {
    cursor: pointer;
}

.relation-choice {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 0.55rem;
    align-items: flex-start;
    border: 1px solid #e2e8f0;
    border-radius: 0.65rem;
    background: #f8fafc;
    padding: 0.6rem;
    transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.relation-choice:hover,
.relation-option-card:hover,
.relation-page-chip:hover {
    border-color: #93c5fd;
    background: #f8fbff;
}

.relation-choice > span {
    min-width: 0;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    column-gap: 0.4rem;
    row-gap: 0.1rem;
}

.relation-choice i {
    grid-row: span 2;
    color: #2563eb;
    margin-top: 0.05rem;
}

.relation-choice strong,
.relation-option-card strong {
    color: #1e293b;
    font-size: 0.8rem;
}

.relation-choice small,
.relation-option-card small {
    color: #64748b;
    font-size: 0.7rem;
    line-height: 1.25;
}

.relation-choice:has(.form-check-input:checked) {
    border-color: #2563eb;
    background: #eff6ff;
    box-shadow: inset 0 0 0 1px rgba(37, 99, 235, 0.16);
}

.relation-options-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.6rem;
    margin-bottom: 0.75rem;
}

.relation-master-settings {
    border-top: 3px solid #2563eb;
}

.relation-master-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.6rem;
}

.relation-link-mode-card {
    border: 1px solid #e2e8f0;
    border-radius: 0.7rem;
    background: #f8fafc;
    padding: 0.65rem;
}

.relation-option-heading {
    margin-bottom: 0.45rem;
    color: #1e293b;
    font-size: 0.78rem;
    font-weight: 800;
}

.relation-mini-choice {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    margin: 0 0.7rem 0.25rem 0;
    color: #334155;
    font-size: 0.75rem;
    font-weight: 700;
    cursor: pointer;
}

.relation-fk-card {
    grid-template-columns: 1fr;
}

.relation-fk-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.55rem;
    margin-top: 0.55rem;
    padding-top: 0.55rem;
    border-top: 1px solid rgba(245, 158, 11, 0.25);
}

.relation-fk-actions label {
    display: grid;
    gap: 0.22rem;
    margin: 0;
}

.relation-fk-actions span {
    color: #92400e;
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.relation-visibility-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.6rem;
}

.relation-visibility-panel {
    margin-bottom: 0.75rem;
}

.relation-visibility-panel:first-child {
    border-top: 3px solid #0ea5e9;
}

.relation-visibility-panel:nth-child(2) {
    border-top: 3px solid #7c3aed;
}

.relation-option-card {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 0.55rem;
    align-items: flex-start;
    border: 1px solid #e2e8f0;
    border-radius: 0.7rem;
    background: #fff;
    padding: 0.65rem;
    min-height: 4.15rem;
    transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.relation-warning-card {
    border-color: #fde68a;
    background: #fffbeb;
}

.relation-option-main {
    display: contents;
}

.relation-option-card label,
.relation-option-card span {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.12rem;
    margin: 0;
}

.relation-count-card {
    grid-template-columns: minmax(0, 1fr) auto;
}

.relation-count-card .relation-option-main {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 0.55rem;
    align-items: flex-start;
}

.relation-badge-color {
    align-items: center;
    gap: 0.45rem;
    padding-left: 0.6rem;
    border-left: 1px solid #e2e8f0;
}

.relation-badge-color input[type="color"] {
    width: 2.3rem;
    height: 2rem;
    padding: 0.15rem;
}

.relation-page-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
}

.relation-order-card {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 5.2rem;
    gap: 0.65rem;
    align-items: center;
    margin-top: 0.65rem;
    border: 1px dashed #cbd5e1;
    border-radius: 0.65rem;
    background: #f8fafc;
    padding: 0.55rem 0.6rem;
}

.relation-order-card strong {
    display: block;
    color: #1e293b;
    font-size: 0.78rem;
}

.relation-order-card small {
    display: block;
    color: #64748b;
    font-size: 0.68rem;
    line-height: 1.25;
}

.relation-order-card input {
    text-align: center;
    font-weight: 800;
}

.relation-future-pages {
    background: #fbfdff;
}

.relation-page-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    border: 1px solid #e2e8f0;
    border-radius: 999px;
    background: #f8fafc;
    padding: 0.32rem 0.55rem;
    color: #334155;
    font-size: 0.76rem;
    font-weight: 700;
}

.relation-page-chip:has(.form-check-input:checked) {
    border-color: #2563eb;
    background: #dbeafe;
    color: #1d4ed8;
}

.relation-choice .form-check-input,
.relation-option-card .form-check-input,
.relation-page-chip .form-check-input {
    margin: 0.1rem 0 0;
}

@media (max-width: 900px) {
    .relation-map {
        grid-template-columns: 1fr;
    }

    .relation-flow {
        min-height: 2.5rem;
    }

    .relation-flow-line {
        left: 50%;
        right: auto;
        top: 0;
        bottom: 0;
        width: 2px;
        height: auto;
        transform: translateX(-50%);
        background: linear-gradient(180deg, #0ea5e9, #7c3aed);
    }

    .relation-flow-icon i {
        transform: rotate(90deg);
    }

    .relation-choice-grid,
    .relation-options-grid,
    .relation-master-grid,
    .relation-visibility-grid {
        grid-template-columns: 1fr;
    }

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

    .relation-count-card {
        grid-template-columns: 1fr;
    }

    .relation-badge-color {
        padding-left: 0;
        padding-top: 0.5rem;
        border-left: 0;
        border-top: 1px solid #e2e8f0;
    }
}

@media (max-width: 560px) {
    .relation-designer-modal {
        max-width: calc(100vw - 0.75rem);
    }

    .relation-modal-body {
        padding: 0.7rem !important;
    }

    .relation-help,
    .relation-section-title {
        align-items: flex-start;
    }

    .relation-section-title {
        flex-direction: column;
        gap: 0.15rem;
    }

    .relation-control {
        grid-template-columns: 1fr;
        gap: 0.25rem;
    }

    .relation-guide-grid,
    .relation-fk-actions {
        grid-template-columns: 1fr;
    }
}

/* Compact relation designer */
.relation-designer-modal {
    max-width: min(940px, calc(100vw - 1.25rem));
}

.relation-designer-modal .modal-content {
    border-radius: 0.72rem;
}

.relation-modal-header {
    padding: 0.45rem 0.75rem !important;
}

.relation-modal-subtitle {
    display: none;
}

.relation-modal-body {
    max-height: calc(100vh - 8.5rem);
    overflow: auto;
    padding: 0.6rem 0.75rem !important;
}

.relation-modal-footer {
    padding: 0.45rem 0.75rem !important;
}

.relation-help-compact {
    margin-bottom: 0.48rem;
    border-color: #bfdbfe;
    border-radius: 0.58rem;
    background: linear-gradient(135deg, #eff6ff 0%, #f0fdfa 100%);
    padding: 0.38rem 0.55rem;
    font-size: 0.72rem;
    line-height: 1.25;
}

.relation-help-compact span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.relation-map {
    grid-template-columns: minmax(0, 1fr) 2.75rem minmax(0, 1fr);
    gap: 0.45rem;
    margin-bottom: 0.5rem;
}

.relation-node {
    border-radius: 0.6rem;
    padding: 0.5rem;
}

.relation-node-title {
    margin-bottom: 0.35rem;
    font-size: 0.8rem;
}

.relation-node-title small {
    display: none;
}

.relation-control {
    grid-template-columns: 3.6rem minmax(0, 1fr);
    gap: 0.35rem;
    margin-bottom: 0.35rem;
}

.relation-control > span {
    font-size: 0.65rem;
}

.relation-control input,
.relation-control select {
    min-height: 1.9rem;
    font-size: 0.78rem;
}

.relation-flow-icon {
    width: 1.85rem;
    height: 1.85rem;
}

.relation-section {
    border-radius: 0.62rem;
    padding: 0.5rem;
    margin-bottom: 0.5rem;
}

.relation-section-title {
    margin-bottom: 0.35rem;
}

.relation-section-title span {
    font-size: 0.78rem;
}

.relation-section-title small,
.relation-choice small,
.relation-option-card small,
.relation-order-card small {
    display: none;
}

.relation-choice-grid {
    gap: 0.4rem;
}

.relation-choice {
    align-items: center;
    border-radius: 0.52rem;
    gap: 0.38rem;
    padding: 0.4rem 0.45rem;
}

.relation-choice > span {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.relation-choice i {
    grid-row: auto;
    margin-top: 0;
}

.relation-choice strong,
.relation-option-card strong {
    font-size: 0.74rem;
    line-height: 1.15;
}

.relation-master-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.42rem;
}

.relation-options-grid {
    grid-template-columns: minmax(0, 1.4fr) minmax(0, 0.95fr) minmax(0, 0.8fr);
    gap: 0.42rem;
    margin-bottom: 0.5rem;
}

.relation-option-card,
.relation-link-mode-card {
    border-radius: 0.58rem;
    padding: 0.45rem;
    min-height: 0;
}

.relation-option-card {
    gap: 0.38rem;
}

.relation-option-heading {
    margin-bottom: 0.28rem;
    font-size: 0.72rem;
}

.relation-mini-choice {
    display: flex;
    gap: 0.3rem;
    margin: 0 0 0.22rem;
    font-size: 0.68rem;
    line-height: 1.15;
}

.relation-fk-actions {
    gap: 0.35rem;
    margin-top: 0.38rem;
    padding-top: 0.38rem;
}

.relation-fk-actions span {
    font-size: 0.61rem;
}

.relation-fk-actions select {
    min-height: 1.8rem;
    font-size: 0.72rem;
    padding-top: 0.18rem;
    padding-bottom: 0.18rem;
}

.relation-count-card {
    grid-template-columns: minmax(0, 1fr);
}

.relation-count-card .relation-option-main {
    gap: 0.38rem;
}

.relation-badge-color {
    justify-content: space-between;
    padding-top: 0.35rem;
    padding-left: 0;
    border-top: 1px solid #e2e8f0;
    border-left: 0;
}

.relation-badge-color input[type="color"] {
    width: 2rem;
    height: 1.75rem;
}

.relation-visibility-grid {
    gap: 0.45rem;
}

.relation-visibility-panel {
    margin-bottom: 0.5rem;
}

.relation-page-grid {
    gap: 0.32rem;
}

.relation-page-chip {
    border-radius: 999px;
    padding: 0.22rem 0.42rem;
    font-size: 0.68rem;
}

.relation-order-card {
    grid-template-columns: minmax(0, 1fr) 4.4rem;
    gap: 0.45rem;
    margin-top: 0.42rem;
    border-radius: 0.52rem;
    padding: 0.38rem 0.45rem;
}

.relation-order-card strong {
    font-size: 0.72rem;
}

.relation-order-card input {
    min-height: 1.8rem;
    font-size: 0.75rem;
}

.relation-future-pages {
    padding-top: 0.42rem;
    padding-bottom: 0.42rem;
}

.relation-modal-body [data-bs-toggle="tooltip"],
.relation-modal-body [data-bs-original-title] {
    cursor: help;
}

@media (max-width: 1080px) {
    .relation-master-grid,
    .relation-options-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 760px) {
    .relation-designer-modal {
        max-width: calc(100vw - 0.75rem);
    }

    .relation-map,
    .relation-master-grid,
    .relation-options-grid,
    .relation-visibility-grid {
        grid-template-columns: 1fr;
    }

    .relation-help-compact span {
        white-space: normal;
    }

    .relation-modal-body {
        max-height: calc(100vh - 7rem);
        padding: 0.55rem !important;
    }
}

/* Relation arrows */
#relationsSvg { z-index: 999 !important; }
#relationsSvg .relation-arrow-hit { cursor: pointer; }
#relationsSvg .relation-arrow-line {
    transition: stroke 0.15s ease, stroke-width 0.15s ease, filter 0.15s ease;
}
#relationsSvg .relation-arrow-group:hover .relation-arrow-line {
    stroke: #0b5ed7;
    stroke-width: 4;
    filter: drop-shadow(0 2px 3px rgba(13, 110, 253, 0.25));
}
.relation-hint {
    position: absolute;
    right: 1rem;
    bottom: 1rem;
    z-index: 1001;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    border: 1px solid rgba(13, 110, 253, 0.18);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.92);
    color: #475569;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
    padding: 0.35rem 0.65rem;
    font-size: 0.75rem;
    pointer-events: none;
}

/* Type‑matched highlighting */
.field-list-item.highlight-match {
    background-color: #cfe2ff !important;
    outline: 2px solid #0d6efd;
}


/* ── Mobile responsiveness for Tables module ─────────────────────────── */
@media (max-width: 767.98px) {
    .main-area {
        flex-direction: column !important;
    }
    .left-panel {
        width: 100% !important;
        max-height: 40vh;
        overflow-y: auto;
        flex-shrink: 0;
        transition: max-height 0.3s ease;
    }
    .left-panel.collapsed {
        max-height: 0;
        overflow: hidden;
    }
    .right-workspace {
        flex: 1 1 auto;
        width: 100% !important;
    }
    /* Cards in a vertical stack instead of absolute */
    #selectedTablesContainer {
        display: flex !important;
        flex-wrap: wrap;
        position: static !important;
        height: auto !important;
        overflow: visible !important;
        gap: 0.5rem !important;
        padding: 0.5rem !important;
    }
    .table-card {
        position: relative !important;
        width: 100% !important;
        left: auto !important;
        top: auto !important;
        margin-bottom: 0.5rem;
    }
    /* SVG overlay hidden on mobile (arrows can be re-added later if needed) */
    #relationsSvg {
        display: none;
    }
}
