.report-test-shell {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  min-height: 100vh;
}

.report-test-sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  height: 100vh;
  padding: 1rem;
  border-right: 1px solid var(--line);
  background: rgba(4, 12, 10, 0.78);
}

.report-test-main {
  min-width: 0;
  padding: 1rem;
}

.report-test-header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
  margin-bottom: 0.75rem;
}

.test-filter-panel {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: 150px 150px minmax(180px, 1fr) minmax(180px, 1fr) minmax(170px, 0.85fr) 150px;
  gap: 0.75rem 0.7rem;
  align-items: end;
  margin-bottom: 0.75rem;
  padding: 0.8rem;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(6, 18, 15, 0.94);
  backdrop-filter: blur(16px);
}

.test-filter-panel label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.test-filter-panel label input,
.test-filter-panel label select {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.test-filter-panel #tableSearch {
  font-size: 0.85rem;
}

.test-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-bottom: 0.75rem;
}

.switch-line {
  display: inline-flex;
  grid-template-columns: none;
  align-items: center;
  gap: 0.45rem;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
  font-weight: 800;
}

.switch-line input {
  width: auto;
}

.group-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.35rem;
}

.group-tab {
  width: 100%;
  padding: 0.55rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
  font-size: 0.84rem;
  text-align: center;
}

.group-tab.active {
  color: #07100e;
  background: var(--gold);
}

.sheet-kpis {
  display: grid;
  grid-template-columns: repeat(5, minmax(140px, 1fr));
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.sheet-kpi {
  min-height: 96px;
  padding: 0.85rem;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: linear-gradient(160deg, rgba(255,255,255,0.095), rgba(255,255,255,0.035));
}

.sheet-kpi span {
  display: block;
  color: var(--muted);
  font-size: 0.86rem;
}

.sheet-kpi strong {
  display: block;
  margin-top: 0.55rem;
  font-size: 1.45rem;
  line-height: 1;
}

.report-preview-card {
  min-height: calc(100vh - 270px);
  padding: 0.8rem;
}

.report-preview-table {
  max-height: calc(100vh - 370px);
}

.report-preview-table.compact table {
  font-size: 0.8rem;
}

.report-preview-table.compact th,
.report-preview-table.compact td {
  padding: 0.34rem 0.45rem;
}

.report-preview-table td.number-cell {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.report-preview-table td.bitrix-cell {
  white-space: nowrap;
}

.bitrix-deal-link {
  color: #8fd19e;
  font-weight: 700;
  text-decoration: none;
}

.bitrix-deal-link:hover {
  text-decoration: underline;
}

.report-preview-table td.empty-cell {
  color: rgba(237, 245, 232, 0.28);
}

.report-preview-table td.wrap-cell {
  min-width: 260px;
}

.report-preview-table.manager-summary-view table {
  min-width: 980px;
}

.report-preview-table.manager-summary-view .manager-row td {
  color: var(--text);
  background: rgba(145, 208, 107, 0.08);
  font-weight: 800;
}

.report-preview-table.manager-summary-view .project-row td {
  background: rgba(255, 255, 255, 0.015);
}

.report-preview-table.manager-summary-view .project-name-cell {
  min-width: 420px;
  color: rgba(237, 245, 232, 0.9);
}

.report-preview-table .toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  width: 100%;
  max-width: 100%;
  border: 0;
  border-radius: 4px;
  padding: 0;
  color: var(--text);
  background: transparent;
  font-weight: 800;
  line-height: 1.25;
  text-align: left;
}

.report-preview-table .toggle-btn:disabled {
  cursor: default;
}

.report-preview-table .toggle-icon {
  display: inline-grid;
  flex: 0 0 1.25rem;
  width: 1.25rem;
  height: 1.25rem;
  place-items: center;
  border: 1px solid rgba(145, 208, 107, 0.55);
  border-radius: 4px;
  color: var(--green);
  font-weight: 900;
}

.row-index {
  position: sticky;
  left: 0;
  z-index: 1;
  min-width: 58px;
  width: 58px;
  color: var(--muted);
  background: #0d1b18;
  font-variant-numeric: tabular-nums;
}

.report-preview-table th.row-index {
  z-index: 3;
}

@media (max-width: 1450px) {
  .test-filter-panel {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 1150px) {
  .report-test-shell,
  .sheet-kpis {
    grid-template-columns: 1fr;
  }

  .test-filter-panel {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .report-test-sidebar {
    position: static;
    height: auto;
  }

  .group-tabs {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .test-filter-panel {
    grid-template-columns: 1fr;
  }
}

/* ===== Расходы по должностям (Свод ТБ_Проект) ===== */
.tb-role-summary {
  margin-top: 1.25rem;
  padding: 1.25rem 1.5rem;
  border-radius: 18px;
  background: rgba(95, 116, 95, 0.07);
  border: 1px solid rgba(95, 116, 95, 0.18);
}
.tb-role-summary-header h3 {
  margin: 0 0 0.25rem;
  font-size: 1.1rem;
}
.tb-role-summary-header .panel-hint {
  margin: 0 0 0.85rem;
  color: var(--muted);
  font-size: 0.9rem;
}
.tb-role-summary-table {
  overflow-x: auto;
  background: white;
  border-radius: 14px;
  border: 1px solid rgba(95, 116, 95, 0.18);
}
.tb-role-summary-table table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}
.tb-role-summary-table th,
.tb-role-summary-table td {
  padding: 0.55rem 0.85rem;
  border-bottom: 1px solid rgba(216, 208, 191, 0.5);
  text-align: left;
}
.tb-role-summary-table thead th {
  background: rgba(95, 116, 95, 0.12);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.tb-role-summary-table tfoot th {
  background: rgba(241, 200, 91, 0.18);
  font-weight: 700;
}
.tb-role-summary-table .number-cell {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ===== Затраты на закупки (группировка) ===== */
.purchases-toolbar {
  display: flex;
  gap: 0.5rem;
  margin: 0 0 0.75rem;
}
.purchases-toolbar button {
  background: transparent;
  border: 1px solid rgba(151, 196, 158, 0.45);
  color: var(--mint-soft, #b8d4be);
  padding: 0.4rem 0.85rem;
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.85rem;
}
.purchases-toolbar button:hover {
  background: rgba(151, 196, 158, 0.15);
  color: #fff;
}

.purchases-table {
  width: 100%;
  border-collapse: collapse;
}
.purchases-table thead th {
  text-align: left;
  padding: 0.65rem 0.85rem;
  background: rgba(151, 196, 158, 0.08);
  border-bottom: 1px solid rgba(151, 196, 158, 0.25);
  font-size: 0.78rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.purchases-table tbody tr td,
.purchases-table tfoot tr td {
  padding: 0.55rem 0.85rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}
.purchases-table .purchase-group-row {
  background: rgba(151, 196, 158, 0.06);
  cursor: pointer;
}
.purchases-table .purchase-group-row:hover {
  background: rgba(151, 196, 158, 0.12);
}
.purchases-table .purchase-toggle-cell {
  width: 42px;
  text-align: center;
}
.purchases-table .purchase-toggle {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid rgba(151, 196, 158, 0.45);
  background: transparent;
  color: var(--mint-soft, #b8d4be);
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
}
.purchases-table .purchase-toggle:hover {
  background: rgba(151, 196, 158, 0.18);
  color: #fff;
}
.purchases-table .purchase-toggle[aria-expanded="true"] {
  background: var(--mint-soft, #b8d4be);
  color: #14201c;
}
.purchases-table .purchase-count {
  margin-left: 0.6rem;
  color: var(--muted, #8a9b91);
  font-size: 0.85rem;
}
.purchases-table .purchase-detail-row {
  background: rgba(255, 255, 255, 0.015);
}
.purchases-table .purchase-detail-row td {
  font-size: 0.92rem;
  color: rgba(255, 255, 255, 0.85);
}
.purchases-table .purchase-cell-bullet {
  text-align: center;
  color: var(--muted, #8a9b91);
}
.purchases-table .number-cell {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.purchases-table .purchase-grand-row td {
  background: rgba(241, 200, 91, 0.18);
  font-weight: 700;
}
