/* The Table page: every kind of entry as rows to sort and filter. */
.table-filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px 12px;
  align-items: start;
}
.table-filters .field {
  margin: 0;
  min-width: 0;
}
.table-filters .table-search {
  grid-column: span 2;
}
@media (max-width: 520px) {
  .table-filters {
    grid-template-columns: 1fr 1fr;
  }
  .table-filters .field:first-child,
  .table-filters .table-search,
  .table-filters .table-when {
    grid-column: 1 / -1;
  }
  /* The pinned column wraps, so it leaves room for the columns scrolling past it. */
  .data-table tbody th {
    white-space: normal;
    min-width: 7.5em;
    max-width: 9em;
  }
}
.table-count {
  margin: 12px 4px 8px;
}
.table-card {
  padding: 8px 12px 12px;
}
.data-table th,
.data-table td {
  white-space: nowrap;
}
.data-table .notes-cell {
  white-space: normal;
  min-width: 180px;
  max-width: 320px;
}
/* The first column (usually the date) stays in view while the rest scrolls sideways. */
.data-table tbody th,
.data-table thead th:first-child {
  position: sticky;
  left: 0;
  z-index: 1;
  background: var(--surface);
}
.data-table tbody th {
  font-weight: 600;
  color: var(--text);
  font-size: inherit;
}
.data-table tbody tr:hover > * {
  background: var(--surface-2);
}
.data-table td.derived {
  color: var(--text-2);
}
.data-table thead th {
  padding: 0;
  vertical-align: bottom;
}
.data-table thead th:last-child {
  padding: 8px 6px;
}
.th-sort {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  width: 100%;
  padding: 8px 6px;
  border: 0;
  background: none;
  font: inherit;
  color: inherit;
  text-align: inherit;
  cursor: pointer;
  border-radius: 6px;
}
th.num .th-sort {
  justify-content: flex-end;
}
th.derived .th-sort {
  font-style: italic;
}
.th-sort:hover,
.th-sort:focus-visible {
  color: var(--text);
  background: var(--surface-2);
}
[aria-sort='ascending'] .th-sort,
[aria-sort='descending'] .th-sort {
  color: var(--text);
}
.sort-asc {
  transform: rotate(-90deg);
}
.sort-desc {
  transform: rotate(90deg);
}
.data-table .row-actions {
  padding: 2px 0;
  vertical-align: middle;
}
.table-more {
  display: block;
  margin: 12px auto 0;
}

/* Above the table: the count, the Columns button, and a chip per column filter. */
.table-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 12px 4px 8px;
}
.table-bar .table-count {
  margin: 0;
}
.table-chips {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin: 0 0 10px;
}
.table-chip {
  padding: 0 4px 0 0;
  background: var(--accent-soft);
}
.chip-label {
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  padding: 4px 4px 4px 10px;
  cursor: pointer;
  text-align: left;
}
.table-chip .chip-x {
  display: grid;
  place-items: center;
  padding: 4px;
  border-radius: 999px;
}
.table-chip .chip-x:hover {
  background: var(--surface-3);
}
.th-wrap {
  display: flex;
  align-items: stretch;
}
th.num .th-wrap {
  justify-content: flex-end;
}
.th-wrap .th-sort {
  width: auto;
  flex: 1 1 auto;
}
.th-filter {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  padding: 0 4px;
  border: 0;
  background: none;
  color: var(--text-2);
  opacity: 0.55;
  cursor: pointer;
  border-radius: 6px;
}
.th-filter:hover,
.th-filter:focus-visible {
  opacity: 1;
  background: var(--surface-2);
}
.th-filter.is-on {
  opacity: 1;
  color: var(--accent);
}
/* Filter and Columns dialogs. */
.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 2px;
  cursor: pointer;
}
.check-row input {
  width: 18px;
  height: 18px;
  flex: none;
  accent-color: var(--accent);
}
.check-text {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}
.filter-values {
  max-height: 50vh;
  overflow-y: auto;
  margin: 0 -2px;
}
.filter-quick {
  display: flex;
  gap: 4px;
}
.filter-range {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.filter-range .field {
  margin: 0;
  min-width: 0;
}
.column-list {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
}
.column-row {
  display: flex;
  align-items: center;
  gap: 2px;
  border-bottom: 1px solid var(--border);
}
.column-row .check-row {
  flex: 1;
  min-width: 0;
}
.filter-note {
  color: var(--warn);
}
.table-actions {
  display: flex;
  gap: 6px;
}
/* Cells you can change (or open): the whole cell is the button. */
.data-table .has-btn {
  padding: 0;
}
.cell-btn {
  display: block;
  width: 100%;
  min-height: 100%;
  padding: 8px 6px;
  border: 0;
  border-radius: 6px;
  background: none;
  font: inherit;
  color: inherit;
  text-align: inherit;
  white-space: inherit;
  cursor: pointer;
}
.cell-edit:hover {
  background: var(--accent-soft);
}
.cell-open:hover {
  text-decoration: underline dotted;
}
.cell-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
.data-table .is-editing {
  padding: 3px;
  background: var(--surface);
}
.cell-editor {
  display: flex;
  align-items: center;
  gap: 4px;
}
.cell-editor .input {
  min-width: 10em;
  padding: 5px 8px;
  font-size: inherit;
}
.cell-editor input[inputmode='decimal'] {
  min-width: 5.5em;
  max-width: 7em;
}
.cell-editor input[type='datetime-local'] {
  min-width: 13em;
}
.cell-unit {
  color: var(--text-2);
  font-size: 0.8rem;
  white-space: nowrap;
}
.cell-error {
  display: block;
  margin-top: 3px;
  color: var(--warn);
  font-size: 0.78rem;
  white-space: normal;
  max-width: 16em;
}
