.tg-root {
  --tg-border: #dce3e3;
  --tg-header: #f3f6f5;
  --tg-text: #243532;
  --tg-accent: #167761;
  --tg-bg: #fff;
  --tg-panel: #fff;
  --tg-muted: #586d67;
  --tg-hover: #e5f3ed;
  --tg-table: #eaf3ee;
  --tg-banded: #f7faf8;
  --tg-input-border: #98aaa4;
  --tg-error: #b42318;
  --tg-error-bg: #fff1f0;
  color-scheme: light;
  position: relative;
  display: grid;
  grid-template-columns: 52px 1fr;
  grid-template-rows: 28px 1fr;
  width: 100%;
  height: 100%;
  min-height: 360px;
  overflow: hidden;
  background: var(--tg-bg);
  color: var(--tg-text);
  font:
    13px/1.35 system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  outline: none;
  user-select: none;
}
.tg-corner {
  grid-area: 1/1;
  background: var(--tg-header);
  border-right: 1px solid var(--tg-border);
  border-bottom: 1px solid var(--tg-border);
  z-index: 6;
}
.tg-colheaders {
  grid-area: 1/2;
  position: relative;
  overflow: hidden;
  background: var(--tg-header);
  border-bottom: 1px solid var(--tg-border);
  height: 28px;
  z-index: 5;
}
.tg-rowheaders {
  grid-area: 2/1;
  position: relative;
  overflow: hidden;
  background: var(--tg-header);
  border-right: 1px solid var(--tg-border);
  width: 52px;
  z-index: 5;
}
.tg-scroll {
  grid-area: 2/2;
  overflow: auto;
  position: relative;
  background: var(--tg-bg);
  overscroll-behavior: contain;
}
.tg-canvas {
  position: relative;
  min-width: 100%;
  min-height: 100%;
}
.tg-cell,
.tg-colhead,
.tg-rowhead {
  box-sizing: border-box;
  position: absolute;
  border-right: 1px solid var(--tg-border);
  border-bottom: 1px solid var(--tg-border);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.tg-cell {
  padding: 5px 7px;
  background: var(--tg-bg);
  cursor: cell;
}
.tg-colhead,
.tg-rowhead {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--tg-header);
  font-size: 12px;
  color: var(--tg-muted);
}
.tg-colhead {
  top: 0;
  height: 28px;
}
.tg-rowhead {
  left: 0;
  width: 52px;
}
.tg-hidden-column,
.tg-hidden-row {
  display: none !important;
}
.tg-resize-x {
  position: absolute;
  right: -3px;
  top: 0;
  width: 7px;
  height: 100%;
  cursor: col-resize;
  z-index: 2;
}
.tg-resize-y {
  position: absolute;
  left: 0;
  bottom: -3px;
  width: 100%;
  height: 7px;
  cursor: row-resize;
  z-index: 2;
}
.tg-selection {
  position: absolute;
  display: none;
  pointer-events: none;
  box-sizing: border-box;
  border: 2px solid var(--tg-accent);
  z-index: 8;
}
.tg-fill-handle {
  position: absolute;
  width: 8px;
  height: 8px;
  right: -5px;
  bottom: -5px;
  background: var(--tg-accent);
  border: 1px solid var(--tg-bg);
  box-sizing: border-box;
  pointer-events: auto;
  cursor: crosshair;
  touch-action: none;
}
.tg-fill-handle::before {
  content: "";
  position: absolute;
  inset: -5px;
}
.tg-readonly .tg-cell {
  cursor: default;
}
.tg-readonly .tg-fill-handle,
.tg-readonly .tg-resize-x,
.tg-readonly .tg-resize-y {
  display: none !important;
}
.tg-editor {
  position: absolute;
  display: none;
  z-index: 12;
  box-sizing: border-box;
  border: 2px solid var(--tg-accent);
  padding: 4px 6px;
  font: inherit;
  outline: none;
  background: var(--tg-bg);
  color: inherit;
}
.tg-context-menu {
  position: absolute;
  z-index: 20;
  width: 248px;
  padding: 5px;
  background: var(--tg-panel);
  color: var(--tg-text);
  border: 1px solid var(--tg-border);
  border-radius: 6px;
  box-shadow: 0 5px 18px #0003;
  font:
    13px/1.35 system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  user-select: none;
}
.tg-context-menu[hidden] {
  display: none;
}
.tg-autofill-menu {
  position: absolute;
  z-index: 21;
  width: 270px;
  padding: 7px;
  background: var(--tg-panel);
  color: var(--tg-text);
  border: 1px solid var(--tg-border);
  border-radius: 6px;
  box-shadow: 0 5px 18px #0003;
  font:
    13px/1.35 system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
}
.tg-autofill-menu[hidden] {
  display: none;
}
.tg-autofill-option {
  display: block;
  width: 100%;
  min-height: 32px;
  padding: 6px 9px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: inherit;
  text-align: left;
  font: inherit;
  cursor: pointer;
}
.tg-autofill-option:hover,
.tg-autofill-option:focus-visible {
  background: var(--tg-hover);
  outline: none;
  color: var(--tg-text);
}
.tg-menu-item {
  display: block;
  width: 100%;
  min-height: 29px;
  padding: 5px 10px;
  border: 0;
  border-radius: 3px;
  background: transparent;
  color: inherit;
  text-align: left;
  font: inherit;
  cursor: default;
}
.tg-menu-item:hover:not(:disabled),
.tg-menu-item:focus-visible {
  background: var(--tg-hover);
  outline: none;
  color: var(--tg-text);
}
.tg-menu-item:disabled {
  color: var(--tg-muted);
}
.tg-menu-separator {
  height: 1px;
  margin: 4px 5px;
  background: var(--tg-border);
}
.tg-menu-title {
  padding: 5px 8px 8px;
  font-weight: 600;
}
.tg-width-form {
  display: grid;
  gap: 8px;
  padding: 0 8px 8px;
}
.tg-width-form label {
  font-size: 12px;
  color: var(--tg-muted);
}
.tg-width-form input {
  box-sizing: border-box;
  width: 100%;
  height: 30px;
  padding: 4px 7px;
  border: 1px solid var(--tg-input-border);
  border-radius: 4px;
  font: inherit;
}
.tg-menu-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
}
.tg-menu-actions button {
  min-width: 60px;
  height: 28px;
  border: 1px solid var(--tg-input-border);
  border-radius: 4px;
  background: var(--tg-panel);
  color: inherit;
  font: inherit;
  cursor: pointer;
}
.tg-menu-actions button:last-child {
  border-color: var(--tg-accent);
  background: var(--tg-accent);
  color: white;
}
.tg-cell.tg-number {
  text-align: right;
}
.tg-cell.tg-muted {
  color: var(--tg-muted);
}
.tg-cell.tg-error {
  color: var(--tg-error);
  background: var(--tg-error-bg);
}
.tg-table-header {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 2px 4px 2px 7px;
  background: var(--tg-table);
  font-weight: 600;
  color: var(--tg-text);
}
.tg-table-header-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}
.tg-filter-trigger {
  flex: 0 0 22px;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 3px;
  background: transparent;
  color: var(--tg-muted);
  font: 12px system-ui;
  cursor: pointer;
}
.tg-filter-trigger:hover {
  border-color: var(--tg-border);
  background: var(--tg-panel);
}
.tg-table-banded {
  background: var(--tg-banded);
}
.tg-filter-menu {
  position: absolute;
  z-index: 22;
  width: 250px;
  max-height: min(420px, 90%);
  overflow: auto;
  padding: 6px;
  background: var(--tg-panel);
  color: var(--tg-text);
  border: 1px solid var(--tg-border);
  border-radius: 6px;
  box-shadow: 0 5px 18px #0003;
  font:
    13px/1.35 system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  user-select: none;
}
.tg-filter-menu[hidden] {
  display: none;
}
.tg-filter-title {
  padding: 5px 8px 7px;
  font-weight: 650;
}
.tg-filter-search {
  box-sizing: border-box;
  width: 100%;
  height: 30px;
  margin: 2px 0 6px;
  padding: 4px 7px;
  border: 1px solid var(--tg-input-border);
  border-radius: 4px;
  font: inherit;
}
.tg-filter-options {
  max-height: 190px;
  overflow: auto;
  padding: 2px 0;
}
.tg-filter-option {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 27px;
  padding: 2px 7px;
  cursor: pointer;
}
.tg-filter-option:hover {
  background: var(--tg-hover);
}
.tg-filter-option input {
  margin: 0;
}
.tg-filter-option span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}
.tg-filter-option small {
  color: var(--tg-muted);
}
.tg-filter-menu .tg-menu-actions {
  padding: 6px 2px 2px;
}
.tg-filter-menu .tg-menu-actions button:first-child {
  margin-right: auto;
}
.tg-filter-option[hidden] {
  display: none;
}
.tg-root :focus-visible {
  outline: 2px solid var(--tg-accent);
  outline-offset: 2px;
}
.tg-root:focus-visible {
  box-shadow: inset 0 0 0 2px var(--tg-accent);
}
.tg-filter-search,
.tg-width-form input {
  background: var(--tg-bg);
  color: var(--tg-text);
}
.tg-menu-actions button:last-child {
  color: var(--tg-bg);
}
.tg-filter-trigger:focus-visible {
  outline-offset: -2px;
}
.tg-colhead[aria-selected="true"],
.tg-rowhead[aria-selected="true"] {
  background: var(--tg-hover);
  color: var(--tg-text);
}
@media (forced-colors: active) {
  .tg-selection {
    border-color: Highlight;
  }
  .tg-filter-trigger {
    border-color: ButtonText;
  }
  .tg-cell {
    forced-color-adjust: auto;
  }
}

.tg-cell.tg-invalid {
  box-shadow: inset 0 -2px var(--tg-error);
}

textarea.tg-editor {
  resize: both;
  white-space: pre;
  min-height: 28px;
  max-height: 240px;
  line-height: 1.4;
}

.tg-selection {
  border: 0;
  overflow: hidden;
}
.tg-selection-part {
  position: absolute;
  box-sizing: border-box;
  border: 2px solid var(--tg-accent);
  pointer-events: none;
}
.tg-selection .tg-fill-handle {
  z-index: 1;
}
.tg-frozen-row-edge {
  border-bottom: 2px solid var(--tg-muted);
}
.tg-frozen-column-edge {
  border-right: 2px solid var(--tg-muted);
}
@media (forced-colors: active) {
  .tg-selection-part {
    border-color: Highlight;
  }
}

/* Typeface and emphasis hooks */
.tg-root {
  font-family: var(
    --tg-font,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif
  );
}
.tg-colhead:hover:not([aria-selected="true"]),
.tg-rowhead:hover:not([aria-selected="true"]) {
  background: var(--tg-hover);
}

/* Touch devices: no double-tap zoom or callouts, larger hit areas, 16px inputs so iOS does not zoom on focus */
.tg-root {
  touch-action: manipulation;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}
.tg-resize-x,
.tg-resize-y {
  touch-action: none;
}
@media (pointer: coarse) {
  .tg-resize-x {
    width: 24px;
    right: -12px;
  }
  .tg-resize-y {
    height: 24px;
    bottom: -12px;
  }
  .tg-fill-handle {
    width: 14px;
    height: 14px;
    right: -8px;
    bottom: -8px;
  }
  .tg-fill-handle::before {
    inset: -16px;
  }
  .tg-filter-trigger {
    flex-basis: 30px;
    width: 30px;
    height: 30px;
  }
  .tg-editor,
  textarea.tg-editor,
  .tg-filter-search,
  .tg-width-form input {
    font-size: 16px;
  }
  .tg-menu-item,
  .tg-autofill-option {
    min-height: 44px;
  }
  .tg-filter-option {
    min-height: 40px;
  }
  .tg-menu-actions button {
    min-height: 40px;
    min-width: 72px;
  }
  .tg-context-menu,
  .tg-autofill-menu {
    max-width: calc(100% - 16px);
  }
}

/* Safari needs the prefixed property; menus must scroll when taller than the grid */
.tg-root,
.tg-context-menu,
.tg-autofill-menu,
.tg-filter-menu {
  -webkit-user-select: none;
  user-select: none;
}
.tg-editor,
.tg-filter-search,
.tg-width-form input {
  -webkit-user-select: text;
  user-select: text;
}
.tg-context-menu,
.tg-autofill-menu {
  max-height: calc(100% - 12px);
  overflow-y: auto;
  overscroll-behavior: contain;
}

/* JSON values */
.tg-cell.tg-json {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.92em;
  color: var(--tg-json, var(--tg-accent));
}
.tg-cell.tg-json-array::before,
.tg-cell.tg-json-object::before {
  content: "";
  display: inline-block;
  width: 0.5em;
  height: 0.5em;
  margin-right: 0.45em;
  border-radius: 1px;
  background: currentColor;
  opacity: 0.55;
  vertical-align: baseline;
}
.tg-cell.tg-json-array::before {
  border-radius: 50%;
}
/* Dynamic array results: a faint wash and hairline outline show the range one formula fills */
.tg-root {
  --tg-spill-line: color-mix(in srgb, var(--tg-accent) 60%, transparent);
  --tg-spill: color-mix(in srgb, var(--tg-accent) 6%, transparent);
}
.tg-cell.tg-spilled {
  background-image: linear-gradient(var(--tg-spill), var(--tg-spill));
  box-shadow:
    var(--sp-t, 0 0 #0000), var(--sp-b, 0 0 #0000), var(--sp-l, 0 0 #0000),
    var(--sp-r, 0 0 #0000);
}
.tg-cell.tg-spill-t {
  --sp-t: inset 0 1px 0 var(--tg-spill-line);
}
.tg-cell.tg-spill-b {
  --sp-b: inset 0 -1px 0 var(--tg-spill-line);
}
.tg-cell.tg-spill-l {
  --sp-l: inset 1px 0 0 var(--tg-spill-line);
}
.tg-cell.tg-spill-r {
  --sp-r: inset -1px 0 0 var(--tg-spill-line);
}
.tg-root {
  --tg-pivot-line: color-mix(in srgb, var(--tg-accent) 72%, transparent);
  --tg-pivot: color-mix(in srgb, var(--tg-accent) 7%, transparent);
  --tg-pivot-head: color-mix(in srgb, var(--tg-accent) 17%, transparent);
}
.tg-cell.tg-pivot {
  background-image: linear-gradient(var(--tg-pivot), var(--tg-pivot));
  box-shadow:
    var(--pv-t, 0 0 #0000), var(--pv-b, 0 0 #0000), var(--pv-l, 0 0 #0000),
    var(--pv-r, 0 0 #0000);
}
.tg-cell.tg-pivot-head {
  background-image: linear-gradient(var(--tg-pivot-head), var(--tg-pivot-head));
  font-weight: 600;
}
.tg-cell.tg-pivot-t {
  --pv-t: inset 0 2px 0 var(--tg-pivot-line);
}
.tg-cell.tg-pivot-b {
  --pv-b: inset 0 -2px 0 var(--tg-pivot-line);
}
.tg-cell.tg-pivot-l {
  --pv-l: inset 2px 0 0 var(--tg-pivot-line);
}
.tg-cell.tg-pivot-r {
  --pv-r: inset -2px 0 0 var(--tg-pivot-line);
}
.tg-cell.tg-has-list {
  padding-right: 26px;
}
.tg-cell.tg-has-list[aria-selected="true"]::after {
  content: "";
  position: absolute;
  right: 9px;
  top: 50%;
  margin-top: -2px;
  border: 5px solid transparent;
  border-top-color: currentColor;
  border-bottom-width: 0;
  opacity: 0.65;
  pointer-events: none;
}
.tg-readonly .tg-cell.tg-has-list::after {
  display: none;
}
.tg-list-menu {
  width: auto;
  min-width: 120px;
  max-width: min(360px, calc(100% - 12px));
  max-height: min(320px, calc(100% - 12px));
  outline: none;
}
.tg-list-menu .tg-menu-item {
  position: relative;
  padding-left: 26px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tg-list-menu .tg-menu-item.tg-menu-active {
  background: var(--tg-hover);
  color: var(--tg-text);
}
.tg-list-menu .tg-menu-item[aria-selected="true"]::before {
  content: "✓";
  position: absolute;
  left: 9px;
}

.tg-cell-menu {
  max-height: calc(100% - 12px);
  overflow-y: auto;
}
.tg-worksheet-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.tg-worksheet-list {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: thin;
  min-width: 0;
}
.tg-worksheet-bar button {
  font: inherit;
  padding: 8px 12px;
  border: 1px solid var(--tg-border, #bccbc5);
  border-radius: 5px;
  background: var(--tg-panel, var(--panel, #fff));
  color: var(--tg-text, var(--text, #243532));
  cursor: pointer;
  white-space: nowrap;
}
.tg-worksheet-tab[aria-selected="true"] {
  border-bottom: 3px solid var(--tg-accent, var(--accent, #167761));
  font-weight: 650;
}
.tg-worksheet-dialog {
  max-width: min(420px, 90vw);
  border: 1px solid var(--tg-border, #bccbc5);
  border-radius: 8px;
  padding: 20px;
  background: var(--tg-panel, var(--panel, #fff));
  color: var(--tg-text, var(--text, #243532));
}
.tg-worksheet-dialog form {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.tg-worksheet-dialog label {
  display: grid;
  gap: 8px;
  width: 100%;
}
.tg-worksheet-dialog input {
  font: inherit;
  padding: 8px;
}
.tg-worksheet-dialog::backdrop {
  background: #0006;
}

/* Worksheet tabs: colors, inline rename, drag reordering and the context menu */
.tg-worksheet-bar .tg-worksheet-tab {
  position: relative;
}
.tg-worksheet-tab.has-color::after {
  content: "";
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 2px;
  height: 3px;
  border-radius: 3px;
  background: var(--tab-color);
}
.tg-worksheet-tab.has-color[aria-selected="true"] {
  border-bottom-color: var(--tab-color);
}
.tg-worksheet-tab.drop-before {
  box-shadow: inset 3px 0 0 var(--tg-accent, var(--accent, #167761));
}
.tg-worksheet-tab.drop-after {
  box-shadow: inset -3px 0 0 var(--tg-accent, var(--accent, #167761));
}
.tg-worksheet-rename {
  font: inherit;
  box-sizing: border-box;
  padding: 7px 10px;
  min-width: 8ch;
  border: 2px solid var(--tg-accent, var(--accent, #167761));
  border-radius: 5px;
  background: var(--tg-bg, var(--panel, #fff));
  color: var(--tg-text, var(--text, #243532));
  outline: none;
}
.tg-worksheet-rename[aria-invalid="true"] {
  border-color: var(--tg-error, #b42318);
}
.tg-sheet-menu {
  position: fixed;
  width: auto;
  min-width: 236px;
  max-width: min(340px, calc(100vw - 12px));
  max-height: calc(100dvh - 12px);
  overflow-y: auto;
  z-index: 70;
}
.tg-sheet-menu .tg-menu-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 22px;
}
.tg-menu-shortcut {
  color: var(--tg-muted);
  font-size: 11.5px;
}
.tg-menu-item.danger:not(:disabled) {
  color: var(--tg-error, #b42318);
}
.tg-sheet-colors {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 2px 10px 8px;
}
.tg-sheet-color {
  width: 22px;
  height: 22px;
  padding: 0;
  border-radius: 50%;
  border: 2px solid transparent;
  background: var(--swatch);
  cursor: pointer;
}
.tg-sheet-color.none {
  border-color: var(--tg-border);
  background: linear-gradient(
    135deg,
    transparent 44%,
    var(--tg-error, #b42318) 46% 54%,
    transparent 56%
  );
}
.tg-sheet-color[aria-checked="true"] {
  outline: 2px solid var(--tg-text);
  outline-offset: 2px;
}
.tg-sheet-color:focus-visible {
  outline: 2px solid var(--tg-accent);
  outline-offset: 2px;
}
.tg-sheet-menu .tg-sheet-color {
  min-width: 0;
  min-height: 0;
  flex: 0 0 auto;
  aspect-ratio: 1;
}
.tg-sheet-color:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.tg-worksheet-dialog h2 {
  margin: 0 0 8px;
  font-size: 16px;
}
.tg-worksheet-dialog p {
  margin: 0 0 16px;
  line-height: 1.5;
}
.tg-worksheet-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
.tg-worksheet-dialog button.danger {
  background: var(--tg-error, #b42318);
  border-color: var(--tg-error, #b42318);
  color: #fff;
}
@media (pointer: coarse) {
  .tg-sheet-color {
    width: 30px;
    height: 30px;
  }
  .tg-sheet-colors {
    gap: 10px;
  }
}
@media (forced-colors: active) {
  .tg-worksheet-tab.has-color::after {
    background: Highlight;
  }
  .tg-sheet-color[aria-checked="true"] {
    outline-color: Highlight;
  }
}

/* Keep promoted table labels readable without covering the column resize handle. */
.tg-cell.tg-formula-reference {
  outline: 2px solid var(--tg-reference-color, #397be5);
  outline-offset: -2px;
  background-image: linear-gradient(
    var(--tg-reference-fill, rgba(57, 123, 229, 0.16)),
    var(--tg-reference-fill, rgba(57, 123, 229, 0.16))
  ) !important;
}
@media (forced-colors: active) {
  .tg-cell.tg-formula-reference {
    outline-color: Highlight;
    background-image: none !important;
  }
}
.tg-colhead-label {
  display: block;
  min-width: 0;
  max-width: 100%;
  padding: 0 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  box-sizing: border-box;
}
.tg-colhead-table {
  color: var(--tg-text);
  font-weight: 600;
}
