/*
  Shared Streamlit-like table layer for Matrix Fusion H5 apps.
  Browser H5 imports this file directly; Outlook H5 can migrate to it later.
*/
.table-wrap {
  border: 1px solid var(--st-border);
  border-radius: 0.45rem;
  background: #ffffff;
  overflow: hidden;
  min-height: 2.75rem;
}
.st-table-toolbar, .table-toolbar {
  position: sticky;
  left: 0;
  z-index: 3;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
  border-bottom: 1px solid var(--st-border);
  background: #ffffff;
  padding: 0.45rem;
}
.st-table-toolbar button,
.table-toolbar button {
  min-height: 2rem;
  padding: 0.28rem 0.55rem;
  font-size: 0.85rem;
}
.st-table-toolbar input,
.st-table-toolbar select,
.table-toolbar input,
.table-toolbar select {
  min-height: 2rem;
  width: auto;
  max-width: 18rem;
  padding: 0.28rem 0.5rem;
  font-size: 0.85rem;
}
.table-paste-hint {
  margin-left: auto;
  color: var(--st-muted);
  font-size: 0.82rem;
}
.page-size-label {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin: 0;
}
.st-table-scroll, .table-scroll {
  overflow: auto;
  max-height: min(70vh, 46rem);
  scrollbar-gutter: stable;
}
.st-table-scroll::-webkit-scrollbar,
.table-scroll::-webkit-scrollbar { width: 0.75rem; height: 0.75rem; }
.st-table-scroll::-webkit-scrollbar-track,
.table-scroll::-webkit-scrollbar-track { background: #f7f7fb; }
.st-table-scroll::-webkit-scrollbar-thumb,
.table-scroll::-webkit-scrollbar-thumb {
  border: 0.18rem solid #f7f7fb;
  border-radius: 999px;
  background: #c8ccd6;
}
table, .data-table {
  border-collapse: collapse;
  table-layout: fixed;
  min-width: 62rem;
  width: max-content;
  background: #ffffff;
  font-size: 0.88rem;
}
th, td {
  border-right: 1px solid rgba(49, 51, 63, 0.08);
  border-bottom: 1px solid rgba(49, 51, 63, 0.11);
  min-width: 8rem;
  max-width: 28rem;
  padding: 0.42rem 0.58rem;
  vertical-align: top;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  background: #ffffff;
}
th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #f7f8fb;
  color: #31333f;
  font-weight: 600;
  font-size: 0.82rem;
}
tr:hover td { background: #fafafa; }
tr.selected-row td { background: #fff1f1; }
td.selected-cell {
  background: #fff1f1 !important;
  box-shadow: inset 0 0 0 1px var(--st-primary);
}
td.range-start-cell {
  box-shadow: inset 0 0 0 2px var(--st-primary);
}
.select-col {
  width: 2.6rem;
  min-width: 2.6rem !important;
  max-width: 2.6rem;
  text-align: center;
  position: sticky;
  left: 0;
  z-index: 3;
}
th.select-col { z-index: 4; }
.select-col input { width: auto; min-height: 1rem; accent-color: var(--st-primary); }
.action-col {
  width: 7rem;
  min-width: 7rem !important;
  max-width: 7rem;
  position: sticky;
  right: 0;
  z-index: 3;
  box-shadow: -1px 0 0 rgba(49,51,63,0.12);
}
th.action-col { z-index: 4; }
.primary-action-col {
  width: 6rem;
  min-width: 6rem !important;
  max-width: 6rem;
  position: sticky;
  left: 2.6rem;
  z-index: 3;
  box-shadow: 1px 0 0 rgba(49,51,63,0.12);
}
th.primary-action-col { z-index: 5; }
.detail-col {
  width: 4.6rem;
  min-width: 4.6rem !important;
  max-width: 4.6rem;
}
.account-no-col {
  width: 5rem;
  min-width: 5rem !important;
  max-width: 6rem;
}
.mail-no-col {
  width: 5.8rem;
  min-width: 5.8rem !important;
  max-width: 7rem;
}
.browser-status-col {
  width: 7.3rem;
  min-width: 7.3rem !important;
  max-width: 9rem;
}
.boolean-col {
  width: 4.7rem;
  min-width: 4.7rem !important;
  max-width: 5.5rem;
}
.pinned-col {
  position: sticky;
  left: 8.6rem;
  z-index: 3;
  box-shadow: 1px 0 0 rgba(49,51,63,0.12);
}
th.pinned-col { z-index: 5; }
.cell-display {
  display: inline-block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: top;
}
td:hover { overflow: visible; }
td:hover .cell-display,
tr.selected-row td:hover .cell-display {
  position: relative;
  z-index: 10;
  max-width: min(45rem, 76vw);
  white-space: normal;
  background: #ffffff;
  border: 1px solid var(--st-border);
  border-radius: 0.35rem;
  padding: 0.25rem 0.38rem;
  box-shadow: 0 0.45rem 1.5rem rgba(49, 51, 63, 0.18);
}
.cell-input,
.cell-select {
  min-height: 1.9rem;
  padding: 0.25rem 0.4rem;
  border-radius: 0.32rem;
}
.cell-select {
  width: auto;
  min-width: 4rem;
}
.boolean-select { min-width: 3.7rem; width: 3.7rem; }
.dirty-row td { background: #fff8e6; }
.col-resizer {
  position: absolute;
  right: -0.18rem;
  top: 0;
  bottom: 0;
  width: 0.42rem;
  cursor: col-resize;
}
.col-resizer:hover { background: rgba(255, 75, 75, 0.18); }
.column-menu { position: relative; }
.column-menu[open] summary { border-color: var(--st-primary); }
.column-menu summary {
  list-style: none;
  min-height: 2rem;
  border: 1px solid var(--st-border);
  border-radius: 0.42rem;
  padding: 0.28rem 0.55rem;
  cursor: pointer;
  font-size: 0.85rem;
}
.column-menu summary::-webkit-details-marker { display: none; }
.column-menu-body {
  position: absolute;
  top: calc(100% + 0.35rem);
  left: 0;
  z-index: 25;
  width: min(36rem, 82vw);
  max-height: 21rem;
  overflow: auto;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.35rem 0.6rem;
  border: 1px solid var(--st-border);
  border-radius: 0.5rem;
  padding: 0.7rem;
  background: #ffffff;
  box-shadow: 0 0.5rem 1.8rem rgba(49, 51, 63, 0.2);
}
.column-toggle {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  min-width: 0;
  margin: 0;
  font-size: 0.82rem;
}
.column-toggle input { width: auto; min-height: 1rem; }
.column-toggle span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

html,
body {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

.st-shell,
.app {
  max-width: 100vw;
  overflow-x: hidden;
}

.st-main,
.main {
  min-width: 0;
  max-width: 100%;
  overflow-x: hidden;
}

.st-sidebar,
aside {
  overflow-y: auto;
  overflow-x: hidden;
}

.st-table-section {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow-x: hidden;
}

.st-table-title {
  margin: 0 0 0.35rem;
  font-size: 0.86rem;
  font-weight: 600;
  line-height: 1.35;
  color: #31333f;
}

/* AG Grid implementation used by Outlook H5 and Browser H5. */
.matrix-ag-grid {
  width: 100%;
  max-width: 100%;
  min-height: 22rem;
  border: 1px solid rgba(49, 51, 63, 0.16);
  border-radius: 0.35rem;
  overflow: hidden;
  --ag-font-family: var(--st-font, "Source Sans Pro", "Segoe UI", Arial, sans-serif);
  --ag-font-size: 0.78rem;
  --ag-row-height: 28px;
  --ag-header-height: 32px;
  --ag-list-item-height: 28px;
  --ag-foreground-color: #31333f;
  --ag-border-color: rgba(49, 51, 63, 0.13);
  --ag-header-background-color: #f7f8fb;
  --ag-odd-row-background-color: #fff;
  --ag-row-hover-color: #f6f8ff;
  --ag-selected-row-background-color: rgba(255, 75, 75, 0.11);
}

.matrix-ag-grid .ag-root-wrapper {
  border: 0;
}

.matrix-ag-grid .ag-header-cell-label {
  justify-content: center;
  font-weight: 700;
}

.matrix-ag-grid .ag-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  line-height: 1.25;
  padding-left: 4px;
  padding-right: 4px;
  min-width: 0 !important;
  overflow: hidden !important;
  white-space: nowrap !important;
  text-overflow: clip !important;
}

.matrix-ag-grid .ag-cell-not-inline-editing {
  overflow: hidden !important;
  white-space: nowrap !important;
  text-overflow: clip !important;
}

.matrix-ag-grid .ag-cell-wrapper {
  width: 100%;
  min-width: 0 !important;
  overflow: hidden !important;
  justify-content: center;
}

.matrix-ag-grid .ag-cell-value,
.matrix-ag-grid .ag-group-value,
.matrix-ag-grid .ag-cell .ag-cell-value {
  display: block;
  width: 100%;
  min-width: 0 !important;
  max-width: 100% !important;
  overflow: hidden !important;
  text-overflow: clip !important;
  white-space: nowrap !important;
  overflow-wrap: normal !important;
  word-break: normal !important;
}

.matrix-ag-grid .ag-cell-inline-editing {
  padding: 0;
}

.matrix-ag-grid .ag-cell-inline-editing input,
.matrix-ag-grid .ag-cell-inline-editing select,
.matrix-ag-grid .ag-cell-edit-input {
  width: 100%;
  height: 100%;
  border: 1px solid #4f5dff;
  border-radius: 0.2rem;
  text-align: center;
  font: inherit;
}

.matrix-ag-grid .ag-action-cell {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  white-space: nowrap;
}

.matrix-ag-grid .ag-action-cell button {
  min-height: 1.8rem;
  max-width: 100%;
  padding: 0.12rem 0.55rem;
  border-radius: 0.35rem;
  overflow: hidden;
  text-overflow: clip;
  white-space: nowrap;
}

.ag-toolbar {
  margin-bottom: 0.55rem;
}

/* Stable Handsontable implementation used by Outlook H5. */
.matrix-hot-grid {
  width: 100%;
  max-width: 100%;
  height: min(70vh, 46rem);
  min-height: 28rem;
  overflow: hidden;
  position: relative;
  border-top: 1px solid rgba(49, 51, 63, 0.08);
}

.matrix-hot-grid .handsontable {
  max-width: 100%;
  font: 0.78rem/1.25 var(--st-font, "Source Sans Pro", "Segoe UI", Arial, sans-serif);
  color: #31333f;
}

.matrix-hot-grid .handsontable .ht_master .wtHolder {
  overflow: auto !important;
  scrollbar-gutter: auto !important;
  scrollbar-width: thin;
  scrollbar-color: #c8ccd6 #f7f7fb;
}

.matrix-hot-grid .handsontable .ht_master .wtHolder::-webkit-scrollbar {
  width: 0.75rem;
  height: 0.75rem;
}

.matrix-hot-grid .handsontable .ht_master .wtHolder::-webkit-scrollbar-track {
  background: #f7f7fb;
}

.matrix-hot-grid .handsontable .ht_master .wtHolder::-webkit-scrollbar-thumb {
  border: 0.18rem solid #f7f7fb;
  border-radius: 999px;
  background: #c8ccd6;
}

.matrix-hot-grid .handsontable .ht_clone_top .wtHolder,
.matrix-hot-grid .handsontable .ht_clone_left .wtHolder,
.matrix-hot-grid .handsontable .ht_clone_inline_start .wtHolder,
.matrix-hot-grid .handsontable .ht_clone_top_left_corner .wtHolder,
.matrix-hot-grid .handsontable .ht_clone_bottom .wtHolder,
.matrix-hot-grid .handsontable .ht_clone_bottom_left_corner .wtHolder {
  overflow: hidden !important;
  scrollbar-width: none;
}

.matrix-hot-grid .handsontable .ht_clone_top .wtHolder::-webkit-scrollbar,
.matrix-hot-grid .handsontable .ht_clone_left .wtHolder::-webkit-scrollbar,
.matrix-hot-grid .handsontable .ht_clone_inline_start .wtHolder::-webkit-scrollbar,
.matrix-hot-grid .handsontable .ht_clone_top_left_corner .wtHolder::-webkit-scrollbar,
.matrix-hot-grid .handsontable .ht_clone_bottom .wtHolder::-webkit-scrollbar,
.matrix-hot-grid .handsontable .ht_clone_bottom_left_corner .wtHolder::-webkit-scrollbar {
  width: 0 !important;
  height: 0 !important;
  display: none !important;
}

.matrix-hot-grid .handsontable table,
.matrix-hot-grid .handsontable .htCore {
  border-collapse: separate !important;
  table-layout: auto !important;
  min-width: 0 !important;
  width: auto !important;
  max-width: none !important;
  background: #ffffff;
  font-size: inherit;
}

.matrix-hot-grid .handsontable th,
.matrix-hot-grid .handsontable td {
  position: static !important;
  inset: auto !important;
  z-index: auto;
  min-width: 0 !important;
  max-width: none !important;
  width: auto;
  padding: 0 4px !important;
  vertical-align: middle !important;
  text-align: center !important;
  overflow: hidden !important;
  white-space: nowrap !important;
  text-overflow: clip !important;
  box-sizing: border-box !important;
  background: #ffffff;
}

.matrix-hot-grid .handsontable th {
  background: #f7f8fb !important;
  color: #31333f;
  font-weight: 700;
}

.matrix-hot-grid .handsontable td div,
.matrix-hot-grid .handsontable td span {
  white-space: nowrap !important;
}

.matrix-hot-grid .handsontable th .colHeader,
.matrix-hot-grid .handsontable th .rowHeader {
  display: inline-block;
  width: 100%;
  text-align: center !important;
}

.matrix-hot-grid .handsontable tr:hover td {
  background: inherit;
}

.matrix-hot-grid .handsontable td:hover {
  overflow: hidden !important;
}

.matrix-hot-grid > .handsontable {
  overflow: hidden !important;
}

.matrix-hot-grid .handsontable .hot-action-cell {
  overflow: hidden !important;
}

.matrix-hot-grid .handsontable .hot-action-cell button {
  min-height: 24px !important;
  height: 24px !important;
  max-height: 24px !important;
  padding: 0 0.45rem !important;
  border-radius: 0.35rem;
  line-height: 22px !important;
  font-size: 0.78rem;
}
