.anychart-data-sheet {
  position: relative;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 13px;
  color: #333;
  border: 1px solid #e0e0e0;
  box-sizing: border-box;
}

.anychart-ds-header {
  display: flex;
  background: var(--anychart-ds-header-fill, #f5f5f5);
  border-bottom: 2px solid #d0d0d0;
  position: sticky;
  top: 0;
  z-index: 1;
  /* A9-407 #7b/#7f: header is a sibling of the scrolling viewport. overflow-x:hidden lets us pan it
     via scrollLeft in sync with the body's horizontal scroll so the columns stay aligned. */
  overflow-x: hidden;
}

.anychart-ds-header-cell {
  padding: 0 8px;
  display: flex;
  align-items: center;
  font-weight: 600;
  cursor: pointer;
  -webkit-user-select: none;
     -moz-user-select: none;
          user-select: none;
  border-right: 1px solid #e0e0e0;
  box-sizing: border-box;
  position: relative;
}

.anychart-ds-header-cell:hover {
  background: #eaeaea;
}

/* A9-407 round-6 #5: the source column header is dimmed while it is being dragged, so the lifted ghost
   reads as "this column was picked up". Paired with body { cursor: grabbing } set during the drag.
   A9-407 round-7 #3c: use a NEUTRAL grey tint (native grid look) instead of the off-brand blue, to match
   the ghost's neutral border/shadow styling. */

.anychart-ds-header-cell.anychart-ds-col-dragging {
  opacity: 0.4;
  background: #ececec;
}

.anychart-ds-header-cell[aria-sort="ascending"]::after {
  content: ' \25B2';
  font-size: 10px;
  margin-left: 4px;
}

.anychart-ds-header-cell[aria-sort="descending"]::after {
  content: ' \25BC';
  font-size: 10px;
  margin-left: 4px;
}

.anychart-ds-viewport {
  overflow-y: auto;
  /* A9-407 #7f: allow horizontal scrolling when columns overflow so position:sticky pinned columns
     have a scroll context to freeze against (previously columns were clipped and pin did nothing). */
  overflow-x: auto;
  position: relative;
}

.anychart-ds-spacer {
  width: 100%;
  pointer-events: none;
}

.anychart-ds-row {
  display: flex;
  box-sizing: border-box;
}

.anychart-ds-row-even {
  background: var(--anychart-ds-row-even, #fff);
}

.anychart-ds-row-odd {
  background: var(--anychart-ds-row-odd, #f8f8f8);
}

.anychart-ds-row:hover {
  background: var(--anychart-ds-row-hover, #e8f0fe) !important;
}

/* A9-483: padding and borders are driven by the cellPadding / cellBorder options, which the chart
   pushes in as custom properties. The literals stay as fallbacks so the sheet still looks right on
   its own (e.g. in a static page that never calls the setters). */

.anychart-ds-cell {
  padding: 0 var(--anychart-ds-cell-padding, 8px);
  display: flex;
  align-items: center;
  overflow: hidden;
  /* A9-588: inert on this element (see .anychart-ds-cell-text) — kept only as a fallback for a host
     page that overrides the cell back to a block container. The ellipsis is painted by the holder. */
  text-overflow: ellipsis;
  white-space: nowrap;
  border-right: var(--anychart-ds-cell-border, 1px solid #e0e0e0);
  border-bottom: var(--anychart-ds-cell-border, 1px solid #f0f0f0);
  box-sizing: border-box;
}

/* A9-588: the ellipsis holder. `text-overflow` only takes effect on a BLOCK container, and
   `.anychart-ds-cell` above is `display: flex`, so the declaration there reaches nothing — the
   cell's text is an anonymous flex item and `text-overflow` is not inherited. `min-width: 0` is
   load-bearing too: a flex item defaults to `min-width: auto` and refuses to shrink below its
   content, so without it nothing ever overflows and no ellipsis is ever triggered. */

.anychart-ds-cell-text {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.anychart-ds-cell-number {
  justify-content: flex-end;
}

.anychart-ds-cell-boolean {
  justify-content: center;
}

/* Selection */

.anychart-ds-row-selected {
  background: var(--anychart-ds-row-selected, #d2e3fc) !important;
}

.anychart-ds-row-selected:hover {
  background: var(--anychart-ds-row-selected-hover, #c0d8f8) !important;
}

/* Checkbox column */

.anychart-ds-checkbox-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  min-width: 40px;
  max-width: 40px;
  border-right: 1px solid #e0e0e0;
  box-sizing: border-box;
}

.anychart-ds-checkbox {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: #1a73e8;
}

/* A9-506: the header select-all control. Cosmetic only — the rule drops the UA's default margin so
   the box sits centred in the 40px checkbox cell. The accent is deliberately NOT repeated here: the
   control also carries .anychart-ds-checkbox, so an integrator who restyles that one gets the header
   box with it. */

.anychart-ds-checkbox-all {
  margin: 0;
}

/* Column resize handle */

.anychart-ds-resize-handle {
  position: absolute;
  top: 0;
  right: -3px;
  width: 6px;
  height: 100%;
  cursor: col-resize;
  z-index: 2;
}

.anychart-ds-resize-handle:hover {
  background: rgba(26, 115, 232, 0.3);
}

/* Body cursor override during column resize drag */

.anychart-ds-resizing,
.anychart-ds-resizing * {
  cursor: col-resize !important;
  -webkit-user-select: none !important;
     -moz-user-select: none !important;
          user-select: none !important;
}

/* Keyboard focus */

.anychart-ds-cell-focused {
  outline: 2px solid #1a73e8;
  outline-offset: -2px;
}

/* Focus ring on the grid root when focused */

.anychart-data-sheet:focus {
  outline: 2px solid #1a73e8;
  outline-offset: -2px;
}

.anychart-data-sheet:focus:not(:focus-visible) {
  outline: none;
}

/* Cell editing */

.anychart-ds-cell-editor {
  background: #fff;
}

.anychart-ds-cell-editing {
  padding: 0 !important;
}

/* Context menu */

.anychart-ds-context-menu {
  animation: anychart-ds-fade-in 0.1s ease-out;
}

@keyframes anychart-ds-fade-in {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.anychart-ds-context-menu-item:active {
  background: #d2e3fc !important;
}

/* Column pinning */

.anychart-ds-pinned-left {
  position: sticky;
  left: 0;
  z-index: 1;
  background: inherit;
  box-shadow: 2px 0 4px rgba(0, 0, 0, 0.1);
}

/* Column reorder ghost */

.anychart-ds-reorder-indicator {
  position: absolute;
  top: 0;
  width: 2px;
  height: 100%;
  background: #1a73e8;
  z-index: 10;
  pointer-events: none;
}

/* Multi-sort priority badge */

.anychart-ds-sort-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #1a73e8;
  color: #fff;
  font-size: 10px;
  margin-left: 4px;
  font-weight: 700;
}

/* Phase 4: Group headers */

/* A9-484: driven by the groupHeaderFill option; the literal is the fallback. */

.anychart-ds-group-header {
  background: var(--anychart-ds-group-header-fill, #e8eef7);
  font-weight: 600;
  font-size: 13px;
  border-bottom: 1px solid #c0cfe0;
  display: flex;
  align-items: center;
  cursor: pointer;
  -webkit-user-select: none;
     -moz-user-select: none;
          user-select: none;
}

.anychart-ds-group-header:hover {
  background: #d6e2f5;
}

.anychart-ds-toggle {
  display: inline-block;
  width: 16px;
  text-align: center;
  font-size: 10px;
  color: #5f6368;
  flex-shrink: 0;
}

.anychart-ds-group-label {
  font-weight: 600;
  color: #202124;
}

.anychart-ds-group-count {
  color: #5f6368;
  font-weight: 400;
  font-size: 12px;
}

.anychart-ds-aggregate {
  color: #5f6368;
  font-weight: 400;
  font-size: 12px;
}

/* Phase 4: Group zone drop area */

.anychart-ds-group-zone {
  background: #f0f4ff;
  border-bottom: 1px solid #c0cfe0;
  padding: 6px 12px;
  min-height: 32px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  font-size: 12px;
  color: #5f6368;
}

.anychart-ds-group-zone.drag-over {
  background: #d6e2f5;
  border-color: #1a73e8;
}

.anychart-ds-group-chip {
  display: inline-flex;
  align-items: center;
  background: #fff;
  border: 1px solid #dadce0;
  border-radius: 16px;
  padding: 2px 10px;
  font-size: 12px;
  font-weight: 500;
  color: #202124;
}

.anychart-ds-group-chip-remove {
  font-size: 14px;
  color: #5f6368;
  line-height: 1;
}

.anychart-ds-group-chip-remove:hover {
  color: #d93025;
}

/* Phase 4: Validation error */

.anychart-ds-editor-invalid {
  border-color: #d93025 !important;
  box-shadow: 0 0 0 1px #d93025 !important;
}

.anychart-ds-editor-error {
  position: absolute;
  top: 100%;
  left: 0;
  background: #fce8e6;
  color: #d93025;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 0 0 4px 4px;
  white-space: nowrap;
  z-index: 10001;
  border: 1px solid #f5c6cb;
  border-top: none;
}

/* Phase 4: Column reorder drop indicator */

.anychart-ds-drop-indicator {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: #1a73e8;
  z-index: 100;
  pointer-events: none;
}

/* Phase 4: Tree row indentation */

.anychart-ds-row[data-node-type='data'][data-depth] .anychart-ds-toggle {
  opacity: 0.6;
}

.anychart-ds-row[data-node-type='data'][data-depth] .anychart-ds-toggle:hover {
  opacity: 1;
}

/* ========== Phase 5: Search Bar ========== */

.anychart-ds-search-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: #fff;
  border-bottom: 1px solid #dadce0;
}

.anychart-ds-search-input {
  flex: 1;
  padding: 4px 8px;
  border: 1px solid #dadce0;
  border-radius: 4px;
  font-size: 13px;
  outline: none;
  min-width: 150px;
  max-width: 300px;
}

.anychart-ds-search-input:focus {
  border-color: #1a73e8;
  box-shadow: 0 0 0 2px rgba(26, 115, 232, 0.2);
}

.anychart-ds-search-count {
  font-size: 12px;
  color: #5f6368;
  white-space: nowrap;
  min-width: 60px;
}

.anychart-ds-search-btn {
  background: none;
  border: 1px solid #dadce0;
  border-radius: 4px;
  padding: 2px 8px;
  cursor: pointer;
  font-size: 11px;
  color: #5f6368;
}

.anychart-ds-search-btn:hover {
  background: #f1f3f4;
}

.anychart-ds-search-close {
  color: #d93025;
}

mark.anychart-ds-search-match {
  background: #fbbc04;
  color: #202124;
  padding: 0 1px;
  border-radius: 2px;
}

/* A9-505: the counted cell itself, so a match the formatter hides ('1234' inside '1,234,567',
   'true' painted as a tick) is still visible. mark.anychart-ds-search-match-active was retired with
   the flag that applied it — the current match is a state of the CELL now. */

.anychart-ds-cell.anychart-ds-cell-search-match {
  background: var(--anychart-ds-cell-search-match, #fef7e0);
}

.anychart-ds-cell.anychart-ds-cell-search-match-active {
  background: var(--anychart-ds-cell-search-match-active, #fde293);
}

/* ========== Phase 5: Detail Row ========== */

.anychart-ds-detail-row {
  background: #f9fafb;
  border-left: 3px solid #1a73e8;
  padding: 12px 16px;
  border-bottom: 1px solid #dadce0;
  font-size: 13px;
  line-height: 1.5;
}

.anychart-ds-detail-toggle {
  cursor: pointer;
  width: 20px;
  display: inline-block;
  text-align: center;
  font-size: 10px;
  color: #5f6368;
  -webkit-user-select: none;
     -moz-user-select: none;
          user-select: none;
}

.anychart-ds-detail-toggle:hover {
  color: #1a73e8;
}

/* ========== Phase 5: Header Groups ========== */

/* A9-488: the group banner is a SIBLING of .anychart-ds-header now, not its first child. Nested in the
   flex header it was a zero-width flex item — every group cell is position:absolute, so the row had no
   content width of its own — and the labels painted straight over the column-header text.
   Standalone it mirrors the header's own layout: a block box with overflow-x:hidden that
   syncHeaderAlignment_ pans via scrollLeft, wrapping an inner element whose inline width is the summed
   column width. That width is both the positioning context the absolute cells resolve against and the
   scrollable extent the pan needs. */

.anychart-ds-header-group-row {
  position: relative;
  min-height: 32px;
  background: #e8eaed;
  border-bottom: 1px solid #dadce0;
  overflow-x: hidden;
  box-sizing: border-box;
}

.anychart-ds-header-group-inner {
  position: relative;
  height: 100%;
  min-height: 32px;
}

.anychart-ds-header-group-cell {
  position: absolute;
  top: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  color: #3c4043;
  border-right: 1px solid #dadce0;
  padding: 0 8px;
  box-sizing: border-box;
}

/* ========== Phase 5: Right Pinning ========== */

.anychart-ds-pinned-right {
  position: sticky;
  right: 0;
  z-index: 2;
  background: inherit;
  box-shadow: -2px 0 4px rgba(0, 0, 0, 0.08);
}

/* ========== Phase 5: Loading / Skeleton ========== */

.anychart-ds-loading-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px;
}

.anychart-ds-loading-row .skeleton {
  height: 14px;
  background: linear-gradient(90deg, #e8eaed 25%, #f1f3f4 50%, #e8eaed 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 4px;
}

@keyframes shimmer {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

.anychart-ds-error-row {
  padding: 16px;
  text-align: center;
  color: #d93025;
  font-size: 13px;
}

.anychart-ds-error-row button {
  margin-left: 8px;
  padding: 4px 12px;
  border: 1px solid #d93025;
  border-radius: 4px;
  background: #fff;
  color: #d93025;
  cursor: pointer;
}

/* A9-407 #4: empty / no-data state — centered brand-styled message when there are no rows. */

.anychart-ds-no-data {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 120px;
  padding: 24px;
  text-align: center;
  color: #7c868e;
  font-family: Verdana, Helvetica, Arial, sans-serif;
  font-size: 13px;
}

/* ========== Phase 5: Accessibility ========== */

.anychart-ds-live-region {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.anychart-ds-skip-link {
  position: absolute;
  left: -9999px;
  z-index: 100;
  padding: 4px 8px;
  background: #1a73e8;
  color: #fff;
  border-radius: 4px;
  font-size: 12px;
  text-decoration: none;
}

.anychart-ds-skip-link:focus {
  left: 8px;
  top: 8px;
}

/* ========== Phase 5: High Contrast ========== */

@media (prefers-contrast: more) {
  .anychart-ds-cell {
    border-width: 2px;
  }
  .anychart-ds-header-cell {
    border-width: 2px;
    font-weight: 700;
  }
  .anychart-ds-row-selected .anychart-ds-cell {
    background: #0d47a1 !important;
    color: #fff;
  }
  /* A9-505: that fill is `!important` and wins over the cell's match tint — measured: a selected,
     matched cell and its unmatched neighbour both computed rgb(13, 71, 161). For a match the
     formatter hides ('1234' inside '1,234,567') the tint is the ONLY signal, so the mark is restored
     here on a channel the override does not touch — restating the tint would erase the SELECTION
     instead, which is why the background is left alone. Two rules, not one: next()/prev() move a
     cursor, and under forced contrast it has to stay distinguishable from the matches it walks past.
     Literal colours to match this block's own convention; the themed tints live on the two rules
     above. Known cost: at (0,3,0) this outranks `.anychart-ds-pinned-left` (0,1,0), so a matched cell
     in a pinned column shows the match ring instead of the pin indicator while contrast is forced. */
  .anychart-ds-row-selected .anychart-ds-cell.anychart-ds-cell-search-match {
    box-shadow: inset 0 0 0 2px #fff;
  }
  .anychart-ds-row-selected .anychart-ds-cell.anychart-ds-cell-search-match-active {
    box-shadow: inset 0 0 0 2px #fff, inset 0 0 0 5px #ea8600;
  }
  .anychart-ds-cell-focused {
    outline-width: 3px;
  }
}

/* ========== Phase 5: Measure Span (hidden) ========== */

.anychart-ds-measure {
  position: absolute;
  visibility: hidden;
  white-space: nowrap;
  font: inherit;
}
