/* Порт FieldsSelection.css + выборка ячеек из Spreadsheet.css (Yoda2) */

.rep-section-item-selected, .rep-table-field-selected {
    font-weight: bold;
}

.rep-table-field, .rep-section-item {
    padding: 4px;
    display: block;
    cursor: pointer;
}

.rep-table-field {
    margin-left: 30px;
}

.rep-sections, .rep-section-content {
    vertical-align: top;
}

.rep-sections {
    min-width: 200px;
}

.rep-table-title {
    padding: 4px;
    color: gray;
    margin-left: 15px;
    font-size: larger;
    display: block;
}

.report-fields-selector .rep-section-content-inner {
    overflow: auto;
    max-height: 70vh;
}

/* --- рендер шаблона отчета --- */

.report-fields-selector .spreadsheet-grid {
    clear: both;
}

.report-fields-selector .spreadsheet-grid table {
    border-collapse: collapse;
}

.report-fields-selector .spreadsheet-grid td {
    border: 1px solid silver;
    color: black;
    font-size: 8pt;
}

.report-fields-selector .spreadsheet-grid tbody tr:hover {
    background-color: #eee;
}

.report-fields-selector .spreadsheet-grid-desc {
    font-size: 8pt;
    font-weight: bold;
    padding: 3px;
    color: black;
    border: 1px solid #5C87B2;
}

.report-fields-selector .spreadsheet-grid thead td {
    background-color: #EBEBEB;
}

.report-fields-selector .spreadsheet-pages {
    float: left;
    padding: 1px;
}

.report-fields-selector .spreadsheet-pages-label {
    float: left;
    padding: 3px;
}

/* --- переключатель страниц (combo) --- */

.report-fields-selector .spreadsheet-combo ul {
    margin: 0;
    padding: 0;
    list-style: none;
    border-bottom: 1px solid #ccc;
    z-index: 2;
}

.report-fields-selector .spreadsheet-combo-list li a:hover {
    color: black;
    background: #f9f9f9;
}

.report-fields-selector .spreadsheet-combo a, .report-fields-selector .spreadsheet-combo-header {
    display: block;
    text-decoration: none;
    color: #444;
    background: #fff;
    padding: 5px;
    border: 1px solid #ccc;
}

.report-fields-selector .spreadsheet-combo-header {
    cursor: default;
    color: #33f;
    padding: 3px;
    border: 1px solid blue;
}

.report-fields-selector .spreadsheet-combo-cur-item {
    font-weight: bold;
}

.report-fields-selector .spreadsheet-combo li a {
    border-bottom: 0;
}

.report-fields-selector .spreadsheet-combo {
    float: left;
}

.report-fields-selector .spreadsheet-combo-list {
    position: absolute;
    display: none;
}

.report-fields-selector .spreadsheet-combo, .report-fields-selector .spreadsheet-combo-list {
    background-color: #fff;
}

.report-fields-selector .spreadsheet-combo:hover .spreadsheet-combo-list,
.report-fields-selector .spreadsheet-combo-list.over {
    display: block;
}

/* --- режим выбора ячеек --- */

.report-fields-selector td.spreadsheet-selectable-cell {
    background-color: lightyellow;
    cursor: pointer;
}

.report-fields-selector td.spreadsheet-selected-cell {
    background-color: lightgreen;
}

.report-fields-selector .spreadsheet-grid tr:hover td.spreadsheet-selectable-cell {
    background-color: #ECECC9;
}

.report-fields-selector .spreadsheet-grid tr:hover td.spreadsheet-selected-cell {
    background-color: #8DE28D;
}

.report-fields-selector .spreadsheet-grid tr td.spreadsheet-unselected-cell:hover {
    background-color: #FFEF9C;
}

/* --- модал выбора полей: почти на весь экран, прокрутка внутри --- */

.modal-dialog.cs-report-fields-dialog {
    max-width: 96vw;
    width: 96vw;
    margin: 1rem auto;
}

.modal-dialog.cs-report-fields-dialog .modal-body {
    max-height: 80vh;
    overflow: auto;
}

.report-fields-selector .rep-sections {
    white-space: nowrap;
}

/* --- страница выборки «дерево запроса» (MnuCsQueryPage): дерево слева, таблица справа --- */

.cs-query-page { display: flex; align-items: flex-start; gap: 16px; }
.cs-tree-col { flex: 0 0 320px; position: sticky; top: 84px; max-height: calc(100vh - 100px); display: flex; flex-direction: column; }
.cs-tree-col.cs-collapsed { flex-basis: 44px; }
.cs-query-main { flex: 1 1 auto; min-width: 0; }
.cs-tree { margin: 0; display: flex; flex-direction: column; max-height: calc(100vh - 100px); overflow: hidden; }
.cs-collapsed .cs-tree { display: none; }
.cs-rail { display: none; }
.cs-collapsed .cs-rail { display: flex; flex-direction: column; align-items: center; gap: 10px; width: 44px; padding: 8px 0; background: #fff; border-radius: 4px; box-shadow: 0 0 35px rgba(154, 161, 171, .15); }
.cs-rail-btn { border: 0; background: #eef0fe; color: #727cf5; width: 30px; height: 30px; border-radius: 4px; font-size: 18px; cursor: pointer; }
.cs-rail-title, .cs-rail-meta { writing-mode: vertical-rl; transform: rotate(180deg); font-size: 11px; color: #6c757d; letter-spacing: .04em; }
.cs-rail-title { font-weight: 700; color: #313a46; text-transform: uppercase; }

.cs-tree-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px 10px 14px; border-bottom: 1px solid #e3e7ee; }
.cs-tree-head b { color: #313a46; font-size: 14px; }
.cs-tree-dirty { font-size: 11px; color: #ffbc00; font-weight: 700; }
.cs-tree-collapse { margin-left: auto; border: 0; background: transparent; color: #98a6ad; font-size: 18px; line-height: 1; cursor: pointer; padding: 0 4px; }
.cs-tree-collapse:hover { color: #727cf5; }
.cs-tree-reports { overflow-y: auto; }
.cs-tree > .cs-tnode, .cs-tree > .cs-tsub, .cs-tree-reports { flex-shrink: 0; }
.cs-tree-reports { flex-shrink: 1; min-height: 80px; }

.cs-tnode { display: grid; grid-template-columns: 16px minmax(0, 1fr) auto; gap: 6px; align-items: center; padding: 8px 10px 8px 12px; border-bottom: 1px solid #f1f3f8; }
.cs-tnode-report { border-top: 1px solid #f1f3f8; }
.cs-tw { color: #98a6ad; font-size: 11px; cursor: pointer; user-select: none; width: 16px; text-align: center; }
.cs-tnode-body { min-width: 0; }
.cs-tnode-title { display: block; font-weight: 700; font-size: 13px; color: #313a46; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cs-tnode-meta { display: block; font-size: 11.5px; color: #98a6ad; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cs-tact { border: 0; background: transparent; color: #adb5bd; font-size: 15px; line-height: 1; padding: 2px 4px; cursor: pointer; }
.cs-tact:hover { color: #727cf5; }
.cs-el-remove:hover { color: #fa5c7c; }
.cs-tleaf { display: grid; grid-template-columns: auto minmax(0, 1fr) 20px; gap: 6px; align-items: center; padding: 4px 10px 4px 34px; font-size: 12.5px; color: #313a46; }
.cs-tleaf:hover { background: #f8f9fc; }
.cs-tleaf-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cs-tleaf-x { border: 0; background: transparent; color: #c3c9d4; font-weight: 800; font-size: 15px; line-height: 1; padding: 0 3px; cursor: pointer; }
.cs-tleaf-x:hover { color: #fa5c7c; }
.cs-tleaf-add { grid-template-columns: 1fr; color: #727cf5; font-weight: 600; cursor: pointer; padding-top: 6px; padding-bottom: 6px; }
.cs-tleaf-add:hover { background: #eef0fe; }
.cs-el-add { padding-left: 12px; border-top: 1px solid #f1f3f8; border-bottom: 1px solid #f1f3f8; }
.cs-tag { display: inline-block; padding: 1px 6px; border-radius: 3px; background: #f1f3f8; color: #6c757d; font-family: Consolas, "Courier New", monospace; font-size: 10.5px; white-space: nowrap; }
.cs-tsettings { padding: 8px 12px 10px 34px; background: #fafbfe; border-bottom: 1px solid #f1f3f8; display: grid; gap: 6px; }
.cs-tlbl { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: #98a6ad; margin: 4px 0 0; }
.cs-tradios { display: grid; gap: 4px; }
.cs-radio { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: #313a46; margin: 0; cursor: pointer; }
.cs-radio input { position: absolute; opacity: 0; width: 0; height: 0; }
.cs-radio i { width: 14px; height: 14px; border-radius: 50%; border: 1px solid #c3c9d4; background: #fff; display: inline-block; flex: 0 0 14px; }
.cs-radio input:checked + i { border: 4px solid #727cf5; }
.cs-tnote { font-size: 11.5px; color: #98a6ad; line-height: 1.35; margin-top: 4px; }
.cs-tadv-toggle { border: 0; background: transparent; padding: 4px 0 0; text-align: left; color: #727cf5; font-size: 12px; font-weight: 600; cursor: pointer; }
.cs-tadv { display: grid; gap: 6px; }
.cs-tsub { padding: 6px 12px 10px 34px; border-bottom: 1px solid #f1f3f8; display: flex; flex-wrap: wrap; gap: 4px 12px; }
.cs-tsub.cs-sets { display: block; }
.cs-cb { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: #313a46; margin: 0; cursor: pointer; }
.cs-cb input { position: absolute; opacity: 0; width: 0; height: 0; }
.cs-cb i { width: 14px; height: 14px; border-radius: 3px; border: 1px solid #c3c9d4; background: #fff; display: inline-block; flex: 0 0 14px; }
.cs-cb input:checked + i { background: #727cf5; border-color: #727cf5; box-shadow: inset 0 0 0 2px #fff; }
.cs-switch { position: relative; display: inline-block; width: 32px; height: 17px; margin: 0; cursor: pointer; }
.cs-switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.cs-switch i { position: absolute; inset: 0; border-radius: 9px; background: #cfd4dc; transition: background .15s; }
.cs-switch i::after { content: ""; position: absolute; top: 2px; left: 2px; width: 13px; height: 13px; border-radius: 50%; background: #fff; transition: left .15s; }
.cs-switch input:checked + i { background: #727cf5; }
.cs-switch input:checked + i::after { left: 17px; }
.cs-set-list { list-style: none; margin: 0 0 8px; padding: 0; display: grid; gap: 2px; }
.cs-set-list li { display: grid; grid-template-columns: minmax(0, 1fr) auto 20px; gap: 6px; align-items: center; padding: 1px 2px 1px 6px; border-radius: 4px; }
.cs-set-list li.cs-set-active { background: #eef0fe; }
.cs-set-load { border: 0; background: transparent; padding: 5px 0; text-align: left; color: #313a46; font-size: 12.5px; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cs-set-active .cs-set-load { font-weight: 700; }
.cs-set-load:hover { color: #727cf5; }
.cs-set-state { font-size: 11px; color: #727cf5; font-weight: 600; }
.cs-set-x { border: 0; background: transparent; color: #c3c9d4; font-weight: 800; font-size: 15px; line-height: 1; padding: 0 3px; cursor: pointer; }
.cs-set-x:hover { color: #fa5c7c; }
.cs-tree-foot { display: flex; gap: 8px; padding: 10px 12px; border-top: 1px solid #e3e7ee; }
.cs-tree-foot .cs-apply { flex: 1 1 auto; }
.cs-tree-hint { font-size: 11px; color: #98a6ad; padding: 0 12px 10px; line-height: 1.35; }

/* окно книги отчета */
.cs-book-dialog { max-width: 96vw; margin: 2vh auto; }
.cs-book-modal { z-index: 1060; }
.cs-book-modal .modal-content { border: 0; border-radius: 6px; overflow: hidden; background: #fff; color: #313a46; }
.cs-book-selector .loading-data-element { padding: 24px; font-size: 14px; color: #6c757d; }
.cs-book-head { display: flex; align-items: baseline; gap: 14px; padding: 12px 18px; border-bottom: 1px solid #e3e7ee; }
.cs-book-title { color: #313a46; font-size: 15px; }
.cs-book-hint { font-size: 12.5px; color: #6c757d; }
.cs-book-selector { height: calc(96vh - 130px); overflow: auto; }
.cs-book-selector > table { width: 100%; }
.cs-book-selector .rep-sections { min-width: 200px; }
.cs-book-foot { display: flex; gap: 8px; padding: 10px 18px; border-top: 1px solid #e3e7ee; }
.cs-book-spacer { flex: 1; }

/* подсказка пустой страницы */
.cs-query-hint { padding: 40px 32px; text-align: center; color: #98a6ad; background: #fff; border-radius: 4px; box-shadow: 0 0 35px rgba(154, 161, 171, .15); }
.cs-query-hint-title { font-size: 16px; font-weight: 700; color: #313a46; margin-bottom: 6px; }
.cs-query-message { margin-bottom: 16px; }

/* таблица результатов: доработка виджета */
.cs-query-main .sw-table-header th { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: left; padding: 6px 10px; vertical-align: bottom; background: #f8f9fc; color: #313a46; font-weight: 700; font-size: 12px; }
.cs-query-main .sw-table-header th.cs-num, .cs-query-main .sw-table-content td.cs-num { text-align: right; }
.cs-query-main .sw-table-content td.cs-num { font-variant-numeric: tabular-nums; }
.cs-query-main .sw-table-content td.cs-neg { color: #d13b5a; }
.cs-query-main .cs-th { display: inline-flex; flex-direction: column; line-height: 1.25; max-width: 100%; }
.cs-query-main .cs-th-main { overflow: hidden; text-overflow: ellipsis; }
.cs-query-main .cs-th-sub { font-weight: 500; font-size: 10.5px; color: #98a6ad; overflow: hidden; text-overflow: ellipsis; }
.cs-query-main .sw-table-header tr.cs-grp th { font-size: 10.5px; text-transform: uppercase; letter-spacing: .05em; padding: 4px 10px; border-bottom: 1px solid #dfe2fb; background: #fff; color: #98a6ad; text-align: left; }
.cs-query-main .sw-table-header tr.cs-grp th.cs-g-obj { background: #f1f3f8; color: #6c757d; }
.cs-query-main .sw-table-header tr.cs-grp th.cs-g-root { background: #eef0fe; color: #4a53c8; }
.cs-query-main .sw-table-header tr.cs-grp th.cs-g-el { background: #e6f7f1; color: #1f7a4d; }
.cs-query-main .sw-table-header th.cs-g-obj-c { box-shadow: inset 3px 0 0 #dfe3ea; }
.cs-query-main .sw-table-header th.cs-g-el-c { box-shadow: inset 3px 0 0 #b9e8d3; }
.cs-query-main .sw-table-content td { padding: 6px 10px; border-color: #eef2f7; color: #313a46; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; vertical-align: middle; }
.cs-query-main .sw-table-header th.cs-num .cs-th { align-items: flex-end; }
.cs-query-main .sw-table-content tbody tr:nth-child(even) td { background: #fafbfe; }
.cs-query-main .sw-table-content tbody tr:hover td { background: #eef0fe; }
.cs-query-main .sw-table-header, .cs-query-main .search-widget-table { border-color: #e3e7ee; }

/* фильтры виджета: ядро скрывает переключатель оператора (.common-filter-editor .filter-item-operator { display: none }),
   из-за чего у поля всегда оператор по умолчанию; показываем его и оформляем условия как чипы */
.cs-query-main .common-filter-editor .filter-item { display: inline-flex; align-items: center; gap: 6px; margin: 0 6px 6px 0; padding: 3px 8px; border-radius: 4px; background: #f6f7ff; border: 1px solid #dfe2fb; }
.cs-query-main .common-filter-editor .filter-item-name { width: auto; max-width: 320px; white-space: nowrap; text-overflow: ellipsis; color: #313a46; font-weight: 600; font-size: 12.5px; }
.cs-query-main .common-filter-editor .filter-item-operator { display: inline-block; width: auto; min-width: 0; color: #4a53c8; font-weight: 600; font-size: 12.5px; }
.cs-query-main .common-filter-editor .filter-item-value { max-width: 320px; font-size: 12.5px; }
.cs-query-main .common-filter-editor .btn-add-filter-item { border: 1px dashed #c9cde6; background: transparent; color: #727cf5; font-weight: 600; font-size: 12.5px; }

/* заслонка */
.cs-busy { position: fixed; inset: 0; z-index: 2000; background: rgba(250, 251, 254, .72); display: flex; align-items: center; justify-content: center; }
.cs-busy-box { display: flex; align-items: center; gap: 14px; padding: 16px 22px; background: #fff; border-radius: 6px; box-shadow: 0 8px 30px rgba(20, 24, 40, .14); color: #313a46; font-weight: 600; }

@media (max-width: 991px) {
    .cs-query-page { flex-direction: column; }
    .cs-tree-col { flex-basis: auto; width: 100%; position: static; max-height: none; }
    .cs-collapsed .cs-rail { flex-direction: row; width: 100%; }
    .cs-rail-title, .cs-rail-meta { writing-mode: horizontal-tb; transform: none; }
}
