/* Matrix data table controls and paging. Theme colors inherit from styles.css. */
.grid-toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; }
.grid-search { width: 200px; }
.grid-scroll { overflow-x: auto; }
.grid-hl { background: none; padding: 0; color: var(--danger); font-weight: 600; }
.grid-preview-col { display: none; }
.grid-searching .grid-preview-col { display: table-cell; }
.grid-table { margin-top: 4px; font-size: 13px; }
.grid-table th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
.grid-table th.sortable:hover { color:var(--theme-accent-ink); }
.grid-filter-row th { padding: 0 6px 8px; font-weight: 400; }
.grid-filter {
  width: 100%;
  min-width: 60px;
  padding: 6px 11px;
  font-size: 13px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--glass-2);
  color: var(--text);
  outline: none;
}
.grid-filter:focus { border-color: var(--a1); background: color-mix(in srgb,var(--theme-focus) 6%,transparent); }
.grid-filter-range { min-width: 104px; padding-left: 7px; padding-right: 18px; }
.grid-filter-toggle.active { border-color: var(--a1); color:var(--theme-accent-ink); }
.grid-filter-count { margin-left: 2px; color:var(--theme-accent-ink); font-size: 11px; }
.grid-filter-panel {
  margin: 0 0 8px; padding: 12px 14px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--glass);
}
.grid-filter-groups { display: grid; gap: 12px; }
.grid-filter-group + .grid-filter-group { padding-top: 10px; border-top: 1px solid var(--line-soft); }
.grid-filter-group-title { margin-bottom: 7px; color: var(--text-3); font-size: 11px; font-weight: 600; letter-spacing: .45px; }
.grid-filter-group-fields {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(144px, 1fr));
  align-items: end; gap: 8px 10px;
}
.grid-filter-field { min-width: 0; }
.grid-filter-field > label { display: block; margin: 0 0 4px; color: var(--text-2); font-size: 11px; }
.grid-filter-panel .grid-filter { min-width: 0; }
.grid-filter-panel .grid-filter-range { min-width: 0; padding-left: 8px; padding-right: 18px; }
.grid-filter-summary { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0 0 8px; }
.grid-filter-summary-label { margin-right: 2px; color: var(--text-3); font-size: 11px; }
.grid-filter-chip {
  display: inline-flex; max-width: min(290px, 100%); align-items: center; gap: 4px;
  padding: 3px 5px 3px 9px; border: 1px solid var(--line); border-radius: 7px;
  background: var(--glass-2); color: var(--text-2); font-size: 11.5px;
}
.grid-filter-chip > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.grid-filter-chip button {
  display: inline-flex; flex: 0 0 18px; align-items: center; justify-content: center;
  width: 18px; height: 18px; padding: 0; border: 0; border-radius: 5px;
  background: transparent; color: var(--text-3); cursor: pointer; font-size: 15px; line-height: 1;
}
.grid-filter-chip button:hover { background: var(--a1-0); color:var(--theme-accent-ink); }
.grid-clear-filters { padding: 3px 7px; border: 0; background: transparent; color:var(--theme-accent-ink); font-size: 11.5px; cursor: pointer; }
.grid-clear-filters:hover { color: var(--text); }
.grid-date-filter { display: flex; align-items: center; gap: 5px; min-width: 0; }
.grid-date-filter .grid-filter-date { flex: 1 1 auto; width: 1%; min-width: 0; padding-left: 7px; padding-right: 18px; }
.grid-date-open {
  display: inline-flex; flex: 0 0 30px; align-items: center; justify-content: center;
  width: 30px; height: 31px; padding: 0; border: 1px solid var(--line); border-radius: 8px;
  background: var(--glass-2); color: var(--text-2); cursor: pointer;
}
.grid-date-open:hover, .grid-date-open.active { border-color: var(--a1); color:var(--theme-accent-ink); }
.grid-date-dialog-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }

.grid-pager { margin-left: auto; display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text-3); white-space: nowrap; }
.grid-pagesize {
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 6px 11px;
  font-size: 13px;
  background: var(--glass-2);
  color: var(--text);
  outline: none;
}
.grid-pager .btn { padding: 2px 7px; line-height: 1.2; }
.grid-pageinfo { min-width: 88px; text-align: center; }
.grid-pager-foot { margin-top: 10px; }
.grid-pager-foot:empty { margin-top: 0; }
.grid-scroll.scroll-mode { max-height: 60vh; overflow-y: auto; }
.grid-scroll.scroll-mode .grid-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--surface-raised);
  box-shadow: inset 0 -1px 0 var(--line);
}
.grid-scroll.scroll-mode .grid-table thead tr.grid-filter-row th { top: 34px; background: var(--surface-raised); }
.grid-pager-slot { display: contents; }

.grid-table td { padding: 12px .75rem; }
.grid-table tbody tr { transition: background-color .15s; }
.grid-table tbody tr:hover { background: color-mix(in srgb, var(--accent) 6%, transparent); }

/* 网格专属的明暗主题规则随网格模块加载，避免散落在全局样式中。 */
select.grid-filter, select.grid-pagesize { color-scheme: dark; }
.grid-filter option, .grid-pagesize option { background: var(--surface-raised); color: var(--theme-ink); }

html[data-theme="light"] .grid-filter,
html[data-theme="light"] .grid-pagesize {
  color-scheme: light;
  background: var(--control);
  border-color: var(--line);
  color: var(--text);
}
html[data-theme="light"] .grid-filter option,
html[data-theme="light"] .grid-pagesize option {
  background: var(--theme-surface);
  color: var(--text);
}
html[data-theme="light"] .grid-table {
  --tblr-table-striped-bg: color-mix(in srgb,var(--theme-accent) 1.8%,transparent);
  --tblr-table-hover-bg: color-mix(in srgb, var(--a1) 4.5%, transparent);
  color: var(--text);
}
html[data-theme="light"] .grid-table thead th,
html[data-theme="light"] .grid-scroll.scroll-mode .grid-table thead tr.grid-filter-row th {
  background: var(--surface-3);
  color: var(--text-2);
  border-color: var(--line) !important;
}
html[data-theme="light"] .grid-table tbody tr:hover {
  background: color-mix(in srgb, var(--a1) 4.5%, transparent);
}
html[data-theme="light"] .grid-table thead th,
html[data-theme="light"] .grid-scroll.scroll-mode .grid-table thead tr.grid-filter-row th {
  background: var(--surface-3);
  color: var(--text-2);
}
