.tables-panel {
    background: #fff;
    border: 1px solid #dfe3ec;
    border-radius: 12px;
    box-shadow: 0 16px 32px rgba(24, 48, 96, 0.08);
    overflow: hidden;
    max-width: 1100px;
    margin: 0 auto;
}

.tables-panel__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 12px 18px;
    background: #1a1a1a;
    color: #fff;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
}

.tables-panel__header span {
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.tables-panel__columns {
    display: flex;
    align-items: center;
    gap: 6px;
}

.tables-panel__columns button {
    width: 24px;
    height: 24px;
    border: none;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
    cursor: pointer;
    font-size: 12px;
    transition: background 0.2s ease;
}

.tables-panel__columns button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.tables-panel__columns button:not(:disabled):hover {
    background: rgba(255, 255, 255, 0.35);
}

.tables-panel__columns-range {
    min-width: 50px;
    text-align: center;
    font-size: 12px;
    font-weight: 600;
}

.tables-panel__body {
    padding: 18px;
    max-height: 540px;
    overflow-y: auto;
    overflow-x: hidden;
    transition: max-height 0.25s ease, padding 0.25s ease;
}

.tables-panel.collapsed .tables-panel__body {
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
    overflow: hidden;
}

.table-group {
    margin-bottom: 16px;
}

.table-group:last-child {
    margin-bottom: 0;
}

.table-group-header {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    font-weight: 600;
    color: #4b5670;
    cursor: pointer;
    transition: background 0.2s ease;
}

.table-group-toggle {
    display: inline-block;
    font-size: 9px;
}

.table-group-content {
    padding: 12px 0 0;
    overflow-x: hidden;
}

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

.table-title {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    font-weight: 600;
    color: #6b7286;
    margin-bottom: 6px;
}

.table-title--spaced {
    margin-top: 14px;
}

.table-copy-trigger,
.column-copy-trigger {
    cursor: pointer;
    color: inherit;
    display: inline;
    border-radius: 4px;
    transition: color 0.15s ease, background-color 0.15s ease;
}

.table-copy-trigger:hover,
.column-copy-trigger:hover {
    color: #1f6aff;
}

.copy-feedback {
    color: #ffffff !important;
    background-color: #1f2a3c;
    box-shadow: 0 2px 6px rgba(17, 24, 39, 0.2);
    display: inline-block;
    padding: 1px 4px;
}

.table-status {
    margin-left: auto;
    font-weight: 400;
    color: #1f6aff;
    font-size: 8px;
    text-transform: none;
    letter-spacing: normal;
    text-decoration: underline;
    cursor: help;
    position: relative;
}

.table-status::after {
    content: attr(data-tooltip);
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    background: #1f2a3c;
    color: #ffffff;
    font-size: 10px;
    font-weight: 500;
    padding: 6px 8px;
    border-radius: 4px;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.12s ease, visibility 0.12s ease;
    box-shadow: 0 4px 12px rgba(17, 24, 39, 0.18);
    z-index: 10;
}

.table-status::before {
    content: '';
    position: absolute;
    right: 6px;
    top: 100%;
    border: 5px solid transparent;
    border-top-color: #1f2a3c;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.12s ease, visibility 0.12s ease;
    z-index: 10;
}

.table-status:hover::after,
.table-status:hover::before {
    opacity: 1;
    visibility: visible;
}

.tables-block__table {
    width: 100%;
    border-collapse: collapse;
    font-size: 11px;
    margin-bottom: 8px;
}

.tables-block__table thead th {
    background: #ffffff;
    text-align: left;
}

.tables-block__table thead th .col-number {
    float: right;
    font-weight: normal;
    color: #cccccc;
}

.tables-block__table th,
.tables-block__table td {
    border: 1px solid #cccccc;
    padding: 4px 6px;
    white-space: nowrap !important;
    width: 90px;
    min-width: 90px;
    max-width: 90px;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    position: relative;
}

.col-11-20 {
    display: none;
}

.tables-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 12px;
    margin: 0 auto 16px;
    max-width: 1100px;
}

.tables-controls__group {
    display: flex;
    align-items: center;
    gap: 6px;
}

.tables-btn {
    padding: 6px 10px;
    border-radius: 6px;
    border: 1px solid #d2d7e4;
    background: #fff;
    font-size: 11px;
    font-weight: 600;
    color: #1f2a3c;
    cursor: pointer;
    transition: all 0.2s ease;
}

.tables-btn:hover {
    background: #f4f6fb;
}

.tables-btn.is-active {
    border-color: #1a1a1a;
    color: #1a1a1a;
}

@media (max-width: 960px) {
    .tables-panel__body {
        max-height: 420px;
    }
}

@media (max-width: 720px) {
    .tables-controls {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* Tooltip для информации о базе данных */
.tables-block__table td,
.tables-block__table th {
    position: relative;
}

/* Для ячеек с тултипом разрешаем overflow только по вертикали */
.tables-block__table th:has(.db-info-tooltip) {
    overflow: visible !important;
}

/* Ячейки с ID должны обрезаться */
.tables-block__table td[data-col="id"] {
    overflow: hidden !important;
    text-overflow: ellipsis !important;
}

.db-info-tooltip {
    position: relative;
    display: inline-block;
    cursor: help;
}

/* Подчеркивание только для tooltip (цифры) */
.tables-block__table thead th .col-number.db-info-tooltip {
    text-decoration: underline;
    color: #1f6aff !important;
    font-weight: bold;
}

.tables-block__table td.generated-id-highlight {
    background: rgba(102, 126, 234, 0.18);
    color: #1a1a1a;
    font-weight: 600;
    transition: background 0.3s ease;
}

.db-tooltip-content {
    position: absolute;
    left: 0;
    top: calc(100% + 10px);
    padding: 10px 14px;
    background: #2d3748;
    color: #fff;
    font-size: 11px;
    line-height: 1.6;
    border-radius: 6px;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.2s ease, visibility 0.2s ease;
    z-index: 10000;
    min-width: 280px;
    white-space: nowrap;
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}

.db-tooltip-content::before {
    content: '';
    position: absolute;
    left: 10px;
    top: -6px;
    border: 6px solid transparent;
    border-bottom-color: #2d3748;
}

.db-info-tooltip:hover .db-tooltip-content {
    opacity: 1;
    visibility: visible;
}

/* Подсветка сгенерированных ID */
.generated-id-highlight {
    background-color: rgba(31, 106, 255, 0.18) !important;
    transition: background-color 3s ease;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
}

.tables-block__table td[data-db-field="true"] {
    background-color: rgba(31, 106, 255, 0.12);
    color: #1f2a3c !important;
    text-decoration: none;
    font-weight: inherit;
}

.tables-block__table td[data-db-link="true"] {
    color: #1f6aff !important;
    text-decoration: underline;
}

.tables-block__table td[data-generated-id] {
    /* флеш подсветки оставляем */
    background-color: rgba(31, 106, 255, 0.12);
}

/* Отображение формулы в ячейках */
.tables-block__table td[data-formula] {
    cursor: help;
    position: relative;
}

.tables-block__table td[data-formula]:hover::after {
    content: attr(data-formula);
    position: absolute;
    left: 0;
    bottom: calc(100% + 8px);
    background: #2d3748;
    color: #fff;
    font-size: 10px;
    line-height: 1.4;
    padding: 6px 10px;
    border-radius: 4px;
    white-space: pre-wrap;
    max-width: 300px;
    word-break: break-word;
    z-index: 10001;
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
    pointer-events: none;
}

.tables-block__table td[data-formula]:hover::before {
    content: '';
    position: absolute;
    left: 10px;
    bottom: calc(100% + 2px);
    border: 5px solid transparent;
    border-top-color: #2d3748;
    z-index: 10001;
    pointer-events: none;
}

/* Отображение путей в tooltip для ячеек с paths */
.tables-block__table td[data-paths-info]:hover::after {
    content: attr(data-paths-info);
    position: absolute;
    left: 0;
    bottom: calc(100% + 8px);
    background: #2d3748;
    color: #fff;
    font-size: 10px;
    line-height: 1.6;
    padding: 8px 12px;
    border-radius: 4px;
    white-space: pre-line;
    max-width: 400px;
    word-break: break-word;
    z-index: 10002;
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
    pointer-events: none;
    font-family: 'Courier New', monospace;
}

.tables-block__table td[data-paths-info]:hover::before {
    content: '';
    position: absolute;
    left: 10px;
    bottom: calc(100% + 2px);
    border: 5px solid transparent;
    border-top-color: #2d3748;
    z-index: 10002;
    pointer-events: none;
}

/* Если есть и data-formula и data-paths-info, показываем оба */
.tables-block__table td[data-formula][data-paths-info]:hover::after {
    content: 'Формула: ' attr(data-formula) '\A\A' 'Пути:\A' attr(data-paths-info);
}

/* Отображение путей в tooltip для ячеек с paths */
.tables-block__table td[data-paths-info]:hover::after {
    content: attr(data-paths-info);
    position: absolute;
    left: 0;
    bottom: calc(100% + 8px);
    background: #2d3748;
    color: #fff;
    font-size: 10px;
    line-height: 1.6;
    padding: 8px 12px;
    border-radius: 4px;
    white-space: pre-line;
    max-width: 400px;
    word-break: break-word;
    z-index: 10002;
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
    pointer-events: none;
    font-family: 'Courier New', monospace;
}

.tables-block__table td[data-paths-info]:hover::before {
    content: '';
    position: absolute;
    left: 10px;
    bottom: calc(100% + 2px);
    border: 5px solid transparent;
    border-top-color: #2d3748;
    z-index: 10002;
    pointer-events: none;
}

/* Если есть и data-formula и data-paths-info, показываем оба */
.tables-block__table td[data-formula][data-paths-info]:hover::after {
    content: 'Формула: ' attr(data-formula) '\A\A' 'Пути:\A' attr(data-paths-info);
}

/* Отображение путей в tooltip для ячеек с paths */
.tables-block__table td[data-paths-info]:hover::after {
    content: attr(data-paths-info);
    position: absolute;
    left: 0;
    bottom: calc(100% + 8px);
    background: #2d3748;
    color: #fff;
    font-size: 10px;
    line-height: 1.6;
    padding: 8px 12px;
    border-radius: 4px;
    white-space: pre-line;
    max-width: 400px;
    word-break: break-word;
    z-index: 10002;
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
    pointer-events: none;
    font-family: 'Courier New', monospace;
}

.tables-block__table td[data-paths-info]:hover::before {
    content: '';
    position: absolute;
    left: 10px;
    bottom: calc(100% + 2px);
    border: 5px solid transparent;
    border-top-color: #2d3748;
    z-index: 10002;
    pointer-events: none;
}

/* Если есть и data-formula и data-paths-info, показываем оба */
.tables-block__table td[data-formula][data-paths-info]:hover::after {
    content: 'Формула: ' attr(data-formula) '\A\A' 'Пути:\A' attr(data-paths-info);
}
