/*
 * data_grid.css -- Tabulator on the design tokens. Imports the vendored
 * "simple" Tabulator theme, then overrides its colors, fonts and spacing
 * with our tokens, so the grid follows the app's theme (dark mode
 * included) without a build. Tabulator's stylesheets carry no CSS
 * variables, hence selector overrides rather than a variable map.
 */
@import url("./vendor/tabulator/tabulator_simple.min.css");

.dg-host.tabulator {
  background: var(--surface);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  overflow: hidden;
}

/* header */
.dg-host.tabulator .tabulator-header {
  background: var(--surface-2);
  color: var(--fg-muted);
  border-bottom: 1px solid var(--border-strong);
  font-weight: 600;
}
.dg-host.tabulator .tabulator-header .tabulator-col {
  background: var(--surface-2);
  border-right: 1px solid var(--border);
}
.dg-host.tabulator .tabulator-header .tabulator-col.tabulator-sortable:hover {
  background: var(--surface-3);
}
.dg-host.tabulator .tabulator-header .tabulator-col .tabulator-col-content .tabulator-col-title {
  font-size: var(--text-sm);
  color: var(--fg-muted);
}
.dg-host.tabulator .tabulator-header .tabulator-col.tabulator-sortable[aria-sort="ascending"] .tabulator-col-content .tabulator-col-sorter .tabulator-arrow {
  border-bottom-color: var(--accent);
}
.dg-host.tabulator .tabulator-header .tabulator-col.tabulator-sortable[aria-sort="descending"] .tabulator-col-content .tabulator-col-sorter .tabulator-arrow {
  border-top-color: var(--accent);
}
.dg-host.tabulator .tabulator-header .tabulator-col .tabulator-header-filter input,
.dg-host.tabulator .tabulator-header .tabulator-col .tabulator-header-filter select {
  font: inherit;
  font-size: var(--text-xs);
  font-weight: 400;
  color: var(--fg);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 2px 6px;
  box-sizing: border-box;
  width: 100%;
}

/* the totals row under the header filters (totals: true) */
.dg-host.tabulator .tabulator-header .tabulator-calcs-holder {
  background: var(--surface-2);
  border-top: 1px solid var(--border);
}
.dg-host.tabulator .tabulator-header .tabulator-calcs-holder .tabulator-row {
  background: var(--surface-2);
  color: var(--fg);
  font-weight: 600;
}
.dg-host.tabulator .tabulator-header .tabulator-calcs-holder .tabulator-cell {
  border-right: 1px solid var(--border);
}

/* rows */
.dg-host.tabulator .tabulator-tableholder {
  background: var(--surface);
}
.dg-host.tabulator .tabulator-row {
  background: var(--surface);
  color: var(--fg);
  border-bottom: 1px solid var(--border);
}
.dg-host.tabulator .tabulator-row.tabulator-row-even {
  background: var(--bg-subtle);
}
.dg-host.tabulator .tabulator-row.tabulator-selectable:hover {
  background: var(--accent-soft);
  cursor: default;
}
.dg-host.tabulator .tabulator-row.tabulator-selected,
.dg-host.tabulator .tabulator-row.tabulator-selected:hover {
  background: var(--accent-border);
}
.dg-host.tabulator .tabulator-row .tabulator-cell {
  padding: var(--space-2) var(--space-3);
  border-right: 1px solid var(--border);
}
/* Underlined: color alone did not say "tap me" on a phone (feedback 3VK7D).
   Buttons drawn as links (.btn) keep their own look. */
.dg-host.tabulator .tabulator-row .tabulator-cell a:not(.btn) {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.dg-host.tabulator.dg-rowlink .tabulator-row { cursor: pointer; }
.dg-host.tabulator .tabulator-row .tabulator-cell .dg-meta,
.dg-host.tabulator .tabulator-row .tabulator-cell .dg-note {
  display: block;
  font-size: var(--text-xs);
  color: var(--fg-muted);
  white-space: normal;
  line-height: 1.3;
}
.dg-host.tabulator .tabulator-row .tabulator-cell.dg-wrap {
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.35;
}
.dg-host.tabulator .tabulator-row .tabulator-cell.dg-actions {
  overflow: visible;
}
.dg-host.tabulator .tabulator-tableholder .tabulator-placeholder .tabulator-placeholder-contents {
  color: var(--fg-muted);
  font-size: var(--text-base);
  background: transparent;
}

/* actions */
.dg-actions-box .dg-action {
  font-size: var(--text-xs);
  padding: 2px 8px;
  margin-right: 4px;
}
.dg-actions-box .dg-action.dg-failed {
  color: var(--danger);
  border-color: var(--danger);
}

/* selection and the bulk bar (opts.select) */
.dg-host.tabulator .tabulator-cell.dg-select,
.dg-host.tabulator .tabulator-col.dg-select .tabulator-col-title {
  text-align: center;
}
.dg-select input,
.dg-select-page {
  width: 18px;
  height: 18px;
  cursor: pointer;
}
.dg-bulkbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  margin: 6px 0;
  border: 1px solid var(--border);
  border-radius: var(--radius, 6px);
  background: var(--surface-2);
}
.dg-bulkbar[hidden] {
  display: none;
}
.dg-bulk-count {
  font-weight: 600;
  margin-right: 4px;
}
.dg-bulkbar .dg-danger,
.dg-rowactions-box .dg-danger {
  color: var(--danger);
  border-color: var(--danger);
}

/* row actions (opts.rowActions): icon buttons, tooltip and name from the label */
.dg-rowactions-box {
  display: inline-flex;
  gap: 4px;
}
.dg-rowactions-box .dg-iconbtn {
  min-width: 32px;
  min-height: 32px;
  padding: 2px 6px;
  font-size: var(--text-sm);
  line-height: 1;
}

/* footer and pagination */
.dg-host.tabulator .tabulator-footer {
  background: var(--surface-2);
  color: var(--fg-muted);
  border-top: 1px solid var(--border);
  font-size: var(--text-xs);
}
.dg-host.tabulator .tabulator-footer .tabulator-page,
.dg-host.tabulator .tabulator-footer .tabulator-page-size {
  background: var(--surface);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font: inherit;
}
.dg-host.tabulator .tabulator-footer .tabulator-page.active {
  color: var(--accent);
  border-color: var(--accent);
}
.dg-host.tabulator .tabulator-footer .tabulator-page:not(:disabled):hover {
  background: var(--accent-soft);
  color: var(--fg);
}

/* our own footer line (count, copy link, reset layout) */
.dg-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: var(--space-2) 0 var(--space-5);
  font-size: var(--text-xs);
  color: var(--fg-muted);
}
.dg-foot .dg-reset,
.dg-foot .dg-csv,
.dg-foot .dg-copylink {
  font-size: var(--text-xs);
  padding: 2px 8px;
}
/* copy link sits beside reset layout, the count keeps the left */
.dg-foot .dg-copylink {
  margin-left: auto;
  margin-right: var(--space-2);
}

/* the popup a "list" header filter opens (top layer, outside .dg-host) */
.tabulator-edit-list {
  background: var(--surface);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  font-family: var(--font-sans);
}
.tabulator-edit-list .tabulator-edit-list-item {
  color: var(--fg);
}
.tabulator-edit-list .tabulator-edit-list-item.active,
.tabulator-edit-list .tabulator-edit-list-item:hover {
  background: var(--accent-soft);
  color: var(--fg);
}

/* the pager of a paged grid, above the rows (Tabulator's footer markup, moved) */
.dg-pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  margin: var(--space-2) 0;
  font-size: var(--text-xs);
  color: var(--fg-muted);
}
.dg-pager .tabulator-paginator {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
}
.dg-pager .tabulator-page,
.dg-pager .tabulator-page-size {
  background: var(--surface);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font: inherit;
  padding: 2px 8px;
  cursor: pointer;
}
.dg-pager .tabulator-page.active {
  color: var(--accent);
  border-color: var(--accent);
  font-weight: 600;
}
.dg-pager .tabulator-page:disabled {
  opacity: .45;
  cursor: default;
}
.dg-pager .tabulator-page:not(:disabled):hover {
  background: var(--accent-soft);
}
.dg-pager .dg-page-counter {
  margin-right: var(--space-3);
  font-weight: 600;
  color: var(--fg);
}
.dg-pager label {
  margin: 0 4px 0 var(--space-3);
}
.dg-pager .tabulator-page-size {
  width: auto;
  margin-right: var(--space-3);
}

/* the expand arrow and the row it opens (opts.detail) */
/* the arrow sits at the bottom of a tall cell (a row is subject plus
   snippet), where the eye leaves the row, not floating above the text */
/* the arrow sits at the bottom of a tall cell (a row is subject plus
   snippet), where the eye leaves the row. Absolute, not flex: Tabulator
   lays its cells out inline-block, and a flex cell drops the rest of the
   row onto the next line. */
.dg-host.tabulator .tabulator-cell.dg-expander {
  padding: 0;
  position: relative;
}
.dg-host.tabulator .tabulator-cell.dg-expander .dg-expand {
  position: absolute;
  bottom: 4px;
  left: 50%;
  transform: translateX(-50%);
}
.dg-expand {
  background: none;
  border: 0;
  color: var(--fg-muted);
  cursor: pointer;
  font-size: var(--text-sm);
  line-height: 1;
  padding: 4px 6px;
}
.dg-expand:hover {
  color: var(--accent);
}
/* A paged grid has every row drawn: its rows' box grows with them and with
   an open detail, which Tabulator's computed height (the rows alone) would
   otherwise clip to a sliver with a scrollbar of its own. */
.dg-paged .tabulator-tableholder {
  height: auto !important;
}
.dg-detail {
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border);
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  color: var(--fg);
  max-height: 32rem;
  overflow: auto;
}
.dg-detail pre {
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
}
.dg-detail.dg-failed {
  color: var(--danger);
}


/* searchHistory: the arrow inside a text box and its dropdown */
.sh-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  flex: 1;
  min-width: 0;
}
.sh-wrap > input {
  flex: 1;
  min-width: 0;
  padding-right: 1.8rem;
}
.sh-arrow {
  position: absolute;
  right: 4px;
  background: none;
  border: 0;
  color: var(--fg-muted);
  cursor: pointer;
  font-size: var(--text-sm);
  line-height: 1;
  padding: 3px 5px;
}
.sh-arrow:hover {
  color: var(--accent);
}
.sh-menu {
  position: absolute;
  top: calc(100% + 2px);
  left: 0;
  right: 0;
  z-index: 40;
  max-height: 18rem;
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: 0 6px 18px rgba(0, 0, 0, .18);
  font-size: var(--text-sm);
}
.sh-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 4px var(--space-3);
  cursor: pointer;
}
.sh-item:hover, .sh-item.sh-active {
  background: var(--accent-soft);
}
.sh-text {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
}
.sh-forget {
  background: none;
  border: 0;
  color: var(--fg-subtle);
  cursor: pointer;
  padding: 0 4px;
}
.sh-forget:hover {
  color: var(--danger);
}
.sh-empty {
  padding: 4px var(--space-3);
  color: var(--fg-muted);
  font-size: var(--text-xs);
}

/* the duplicate horizontal scroll bar above a wide grid (data_grid.js topScrollbar) */
.dg-topscroll { overflow-x: auto; overflow-y: hidden; height: 14px; margin-bottom: 2px; }
.dg-topscroll > div { height: 1px; }
.dg-topscroll[hidden] { display: none; }

/* column views (data_grid.js columnViews) */
.dg-views { position: relative; display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin: 0 0 .4rem;
  font-size: var(--text-sm); }
.dg-views select { font: inherit; padding: 2px 6px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--fg); }
.dg-colpanel { position: absolute; top: 100%; left: 0; z-index: 20; margin-top: 4px; padding: .7rem; min-width: 16rem;
  max-width: min(32rem, 92vw); background: var(--surface); color: var(--fg); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: 0 8px 24px rgba(0,0,0,.14); }
.dg-colpanel[hidden] { display: none; }
.dg-colclose { position: absolute; top: .3rem; right: .4rem; width: 1.6rem; height: 1.6rem; border: 0; border-radius: 6px;
  background: none; color: var(--fg-muted); font-size: 1.2rem; line-height: 1; cursor: pointer; }
.dg-colclose:hover, .dg-colclose:focus-visible { background: var(--surface-2); color: var(--fg); }
.dg-colpanel .dg-collist { margin-right: 1.6rem; }
.dg-collist { display: grid; grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr)); gap: .25rem .8rem; margin-bottom: .6rem; }
.dg-collist label { display: flex; align-items: center; gap: .35rem; cursor: pointer; }
.dg-viewactions { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; }
.dg-viewname { flex: 1 1 10rem; font: inherit; padding: 3px 6px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--fg); }
.dg-viewstatus { display: block; margin-top: .4rem; color: var(--fg-muted); font-size: var(--text-xs); }

/* the notes column and its popup (data_grid.js noteColumn) */
/* dg-ncell, since .dg-note is the action reply note above */
.dg-host.tabulator .dg-ncell { display: flex; align-items: center; gap: .4rem; min-width: 0; cursor: pointer; }
.dg-host.tabulator .dg-ncell-text { display: block; flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; }
.dg-ncell-text.is-empty { color: var(--fg-muted); opacity: 0; }
.tabulator-row:hover .dg-ncell-text.is-empty { opacity: .7; }
.dg-notelink { flex: none; border: 0; background: none; padding: 0; font: inherit; font-size: var(--text-xs);
  color: var(--accent); cursor: pointer; }
.dg-notelink[hidden] { display: none; }
.dg-dialog { width: min(36rem, 92vw); max-height: 85vh; overflow: auto; padding: 1rem 1.1rem; border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--surface); color: var(--fg); box-shadow: 0 16px 48px rgba(0,0,0,.2); }
.dg-dialog::backdrop { background: rgba(0,0,0,.3); }
.dg-dlghead { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.dg-dlghead h3 { margin: 0; font-size: 1rem; }
.dg-notemeta { margin: .3rem 0 .6rem; color: var(--fg-muted); font-size: var(--text-xs); }
.dg-notefull { white-space: pre-wrap; line-height: 1.5; }
.dg-notefull.is-empty { color: var(--fg-muted); }
.dg-notearea { width: 100%; box-sizing: border-box; font: inherit; padding: .5rem; border: 1px solid var(--border);
  border-radius: var(--radius-sm); background: var(--surface); color: var(--fg); }
.dg-dlgactions { display: flex; gap: .5rem; margin-top: .8rem; }
.dg-notestatus { margin: .5rem 0 0; color: var(--danger, #c62828); font-size: var(--text-sm); }
.dg-notehist { list-style: none; margin: 0; padding: 0; display: grid; gap: .8rem; }
.dg-notehist .dg-notemeta { margin: 0 0 .2rem; }
.dg-notebreak { padding: .3rem .5rem; border-top: 2px dashed var(--warn, #b25e00); color: var(--warn, #b25e00);
  font-size: var(--text-xs); font-weight: 600; }

/* the photo column (data_grid.js imageColumn) */
.dg-thumb { display: block; width: 100%; height: auto; border-radius: 4px; cursor: zoom-in; }
.dg-host.tabulator .tabulator-row .tabulator-cell.dg-imgcol { padding: 3px; }
.dg-imgfull { display: block; max-width: 100%; max-height: 70vh; margin: .4rem auto; object-fit: contain; }
.dg-imgdlg { width: min(60rem, 94vw); }

/* The height handle under an auto-sizing grid (data_grid.js): drag to set
   the height, double-click to fit the rows again. */
.dg-resize { height: 10px; margin: 2px 0 4px; cursor: ns-resize; touch-action: none; border-radius: 6px;
  background: linear-gradient(var(--border, #d7dbe3), var(--border, #d7dbe3)) center / 48px 3px no-repeat; }
.dg-resize:hover { background-color: var(--surface-2, #eef0f6); }

/* one search box across the text columns (search: true) */
.dg-searchbar {
  display: flex;
  margin: var(--space-2) 0;
}
.dg-search {
  flex: 0 1 22rem;
  min-width: 0;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md, 6px);
  background: var(--surface);
  color: var(--fg);
  font: inherit;
}

/* A grid inside a grid or flex layout (a card's stack) must not take the
   table's full width as its minimum: the table scrolls sideways inside its
   own box instead of widening the page (a phone, 2026-10-21). */
.dg-wrap {
  min-width: 0;
  max-width: 100%;
}

/* Column edges you can see and grab (Travel feedback DA357): the only sign a
   column resizes was a cursor shown on hover with a precise pointer, and in
   some browsers (Orca's, an Electron window) there was none, so the columns
   looked fixed. A faint divider marks each edge, stronger on hover. */
.dg-host.tabulator .tabulator-header .tabulator-col-resize-handle {
  cursor: col-resize;
  position: relative;
}
.dg-host.tabulator .tabulator-header .tabulator-col-resize-handle::after {
  content: "";
  position: absolute;
  top: 25%;
  bottom: 25%;
  left: 50%;
  width: 1px;
  background: var(--border-strong, var(--border, #c9ccd4));
}
.dg-host.tabulator .tabulator-header .tabulator-col-resize-handle:hover::after {
  top: 8%;
  bottom: 8%;
  width: 2px;
  margin-left: -0.5px;
  background: var(--accent, #4b6cf7);
}

/* Charts under the grid's toolbar (grid_widgets.js). The search box and the
   view row share one line, view to the right of search, and the charts sit
   in a wrapping row beneath. Floating the charts beside the toolbar crushed
   it or left odd gaps (brewery_mgt feedback SFRDE, 68FVT, Q6XR9). Two
   adjacent inline-flex boxes share a line and wrap on a narrow screen. */
.dg-searchbar:has(~ .dg-widgets), .dg-views:has(~ .dg-widgets) {
  display: inline-flex;
  vertical-align: middle;
  margin: var(--space-2) var(--space-4, 16px) var(--space-2) 0;
}
.dg-searchbar:has(~ .dg-widgets) .dg-search { width: 22rem; max-width: calc(100vw - 2rem); }
.dg-widgets {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: var(--space-2, 8px) var(--space-6, 24px);
  margin: var(--space-2) 0 var(--space-3, 12px);
}
.dg-widgets > .dg-widget { flex: 0 1 auto; min-width: 0; }
.dg-wconfig { flex-basis: 100%; font-size: .8em; }
.dg-wconfig summary { display: inline; cursor: pointer; text-decoration: underline; list-style: none; }
.dg-wconfig summary::-webkit-details-marker { display: none; }
.dg-wconfig > div {
  position: absolute; left: 0; z-index: 20; display: grid; gap: 4px; padding: 8px 12px; text-align: left;
  white-space: nowrap; background: var(--surface, #fcfcfb); border: 1px solid var(--border, #d8d6cf); border-radius: 6px;
}
.dg-widget {
  margin: 0;
  font-size: .85em;
  --dg-w1: #2a78d6; --dg-w2: #eb6834; --dg-w3: #1baf7a; --dg-wrest: #b5b3aa; --dg-wgap: var(--surface, #fcfcfb);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .dg-widget { --dg-w1: #3987e5; --dg-w2: #d95926; --dg-w3: #199e70; --dg-wrest: #6b6a64; }
}
:root[data-theme="dark"] .dg-widget { --dg-w1: #3987e5; --dg-w2: #d95926; --dg-w3: #199e70; --dg-wrest: #6b6a64; }
.dg-widget[hidden], .dg-widget.dg-off { display: none; }
.dg-widget figcaption { font-weight: 600; margin-bottom: 4px; }
.dg-widget > div { display: flex; align-items: center; gap: 12px; }
.dg-widget svg { max-width: 100%; height: auto; }
.dg-widget svg > * { stroke: var(--dg-wgap); stroke-width: 2; }
.dg-widget svg > text { stroke: none; fill: currentColor; opacity: .7; font-size: 10px; }
.dg-widget svg > .dg-axis { stroke: currentColor; stroke-width: 1; opacity: .35; }
.dg-widget .dg-w1 { fill: var(--dg-w1); background: var(--dg-w1); }
.dg-widget .dg-w2 { fill: var(--dg-w2); background: var(--dg-w2); }
.dg-widget .dg-w3 { fill: var(--dg-w3); background: var(--dg-w3); }
.dg-widget .dg-wrest { fill: var(--dg-wrest); background: var(--dg-wrest); }
.dg-widget ul { list-style: none; margin: 0; padding: 0; }
.dg-widget li { display: flex; align-items: center; gap: 6px; line-height: 1.5; }
.dg-widget li i { width: 10px; height: 10px; border-radius: 2px; flex: none; }
.dg-widget li span { max-width: 12rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dg-widget li b { font-weight: 500; margin-left: auto; padding-left: 8px; white-space: nowrap; }

