/* DrBestand 0.74.0 — canonical customizable system table presentation.
 * This stylesheet is intentionally loaded after module/admin/mobile styles.
 * Module styles may define geometry (column widths, sticky cells, alignment,
 * semantic state colors), but the visual table chrome is owned here.
 * Print documents are a separate output contract and do not load this file.
 */
:root{
  --system-table-border:var(--erp-ui-border,#cfdae5);
  --system-table-border-soft:#dde6ed;
  --system-table-header:#eef4f8;
  --system-table-header-strong:#e7eff5;
  --system-table-header-text:var(--system-table-heading);
  --system-table-header-hover:var(--brand-accent-dark,#007a68);
  --system-table-surface:#fff;
  --system-table-surface-muted:#f8fbfd;
  --system-table-text:#17345b;
  --system-table-heading:var(--brand-primary,#06285b);
  --system-table-muted:#607487;
  --system-table-hover-overlay:rgba(8,168,142,.045);
  --system-table-focus:color-mix(in srgb,var(--brand-accent,#08a88e) 24%,transparent);
  --system-table-radius:12px;
  --system-table-cell-y:9px;
  --system-table-cell-x:10px;
  --system-table-font-size:13px;
  --system-table-row-divider-width:1px;
  --system-table-cell-divider-width:0px;
  --system-table-stripe-overlay:transparent;
}

/* Every interactive data-table container uses the same system surface. */
.table-wrap,.op-excel-grid-wrap,[data-erp-mission-highscore-content]:not(:empty){
  max-width:100%;
  overflow:auto;
  overscroll-behavior:contain;
  -webkit-overflow-scrolling:touch;
  scrollbar-gutter:stable;
  border:1px solid var(--system-table-border);
  border-radius:var(--system-table-radius);
  background:var(--system-table-surface);
  box-shadow:0 6px 18px rgba(6,40,91,.045);
}

/* The table itself carries typography and grid rhythm; module min-width/table-layout remain valid. */
table:not(.print-table){
  border-collapse:separate;
  border-spacing:0;
  width:100%;
  min-width:790px;
  table-layout:fixed;
  background:var(--system-table-surface);
  color:var(--system-table-text);
  font-size:var(--system-table-font-size);
}

table:not(.print-table) caption{
  caption-side:top;
  padding:8px 10px;
  border-bottom:1px solid var(--system-table-border-soft);
  background:var(--system-table-surface-muted);
  color:var(--system-table-heading);
  font-size:12px;
  font-weight:850;
  line-height:1.35;
  text-align:left;
}

table:not(.print-table)>thead>tr>th{
  padding:10px var(--system-table-cell-x);
  border-top:0;
  border-right:0;
  border-bottom:1px solid #c8d8e5;
  background:var(--system-table-header);
  color:var(--system-table-header-text);
  font-size:12px;
  font-weight:850;
  line-height:1.25;
  letter-spacing:.01em;
  text-align:left;
  text-transform:none;
  vertical-align:middle;
}

table:not(.print-table)>thead>tr>th+th{
  border-left:1px solid rgba(200,216,229,.62);
}

/* Sticky/first-column module selectors may be more specific; header chrome stays canonical. */
table:not(.print-table)>thead>tr>th:first-child,
.header-navigation-matrix:not(.print-table)>thead>tr>*:first-child,
body.erp-pref-sticky-first-on .erp-main-table thead th:first-child{
  background:var(--system-table-header);
  color:var(--system-table-header-text);
}

/* Sanctioned subgroup row: one shared secondary-header variant, not module-owned chrome. */
.erp-nav-presentation-group>th,
.erp-nav-matrix-group>th{
  padding:7px var(--system-table-cell-x)!important;
  background:var(--system-table-header-strong)!important;
  color:var(--system-table-header-text)!important;
  font-size:10px!important;
  font-weight:900!important;
  line-height:1.25!important;
  letter-spacing:.07em;
  text-align:left!important;
  text-transform:uppercase;
}

table:not(.print-table)>tbody>tr>:is(td,th),
table:not(.print-table)>tfoot>tr>:is(td,th){
  padding:var(--system-table-cell-y) var(--system-table-cell-x);
  border-right:var(--system-table-cell-divider-width) solid var(--system-table-border-soft);
  border-bottom:var(--system-table-row-divider-width) solid var(--system-table-border-soft);
  font-size:var(--system-table-font-size);
  line-height:1.35;
  vertical-align:middle;
}

table:not(.print-table)>tbody>tr>:is(td,th):last-child,
table:not(.print-table)>tfoot>tr>:is(td,th):last-child{
  border-right:0;
}

table:not(.print-table)>tbody>tr:nth-child(even)>:is(td,th){
  background-color:var(--system-table-stripe-overlay);
}

table:not(.print-table)>tbody>tr>th[scope="row"]{
  background:var(--system-table-surface-muted);
  color:var(--system-table-heading);
  font-weight:800;
}

table:not(.print-table)>tbody>tr:last-child>:is(td,th),
table:not(.print-table)>tfoot>tr:last-child>:is(td,th){
  border-bottom:0;
}

/* A translucent inset keeps semantic warning/error backgrounds visible. */
table:not(.print-table)>tbody>tr:hover>:is(td,th){
  box-shadow:inset 0 0 0 9999px var(--system-table-hover-overlay);
}

table:not(.print-table)>tbody>tr:focus-within>:is(td,th){
  box-shadow:inset 0 0 0 2px var(--system-table-focus),inset 0 0 0 9999px var(--system-table-hover-overlay);
}

table:not(.print-table)>tbody>tr[aria-selected="true"]>:is(td,th),
table:not(.print-table)>tbody>tr.is-selected>:is(td,th){
  box-shadow:inset 3px 0 0 var(--brand-accent,#08a88e),inset 0 0 0 9999px color-mix(in srgb,var(--brand-accent,#08a88e) 6%,transparent);
}

table:not(.print-table)>tfoot>tr>:is(td,th){
  background:var(--system-table-surface-muted);
  color:var(--system-table-heading);
  font-weight:800;
}

/* Sort controls look like headings, never like a second button design. */
table:not(.print-table)>thead th>button,
table:not(.print-table)>thead th button[data-seed-sort]{
  all:unset;
  box-sizing:border-box;
  display:inline-flex;
  align-items:center;
  gap:4px;
  max-width:100%;
  padding:2px 0;
  color:inherit;
  font:inherit;
  font-weight:850;
  line-height:1.25;
  text-align:left;
  white-space:normal;
  overflow-wrap:anywhere;
  cursor:pointer;
}

/* The application-wide primary button selector is intentionally very specific.
   Sorting controls are headings, so the final table layer must explicitly cancel
   button chrome instead of relying on source order alone. */
table:not(.print-table)>thead th>button[data-system-table-sort-button],
table:not(.print-table)>thead th button[data-seed-sort]{
  appearance:none!important;
  border:0!important;
  background:transparent!important;
  background-image:none!important;
  color:inherit!important;
  box-shadow:none!important;
  filter:none!important;
  transform:none!important;
}

table:not(.print-table)>thead th>button[data-system-table-sort-button]:hover,
table:not(.print-table)>thead th>button[data-system-table-sort-button]:focus-visible,
table:not(.print-table)>thead th>button[data-system-table-sort-button]:active,
table:not(.print-table)>thead th button[data-seed-sort]:hover,
table:not(.print-table)>thead th button[data-seed-sort]:focus-visible,
table:not(.print-table)>thead th button[data-seed-sort]:active{
  background:transparent!important;
  background-image:none!important;
  box-shadow:none!important;
  filter:none!important;
  transform:none!important;
}

table:not(.print-table)>thead th>button:hover,
table:not(.print-table)>thead th>button:focus-visible,
table:not(.print-table)>thead th button[data-seed-sort].sort-active{
  color:var(--system-table-header-hover);
}

table:not(.print-table)>thead th>button:focus-visible{
  border-radius:5px;
  outline:3px solid var(--system-table-focus);
  outline-offset:2px;
}

/* Spreadsheet-like tables keep compact geometry but use the same system palette/chrome. */
table.op-excel-grid:not(.print-table),
table.formula-sheet:not(.print-table){
  --system-table-cell-y:6px;
  --system-table-cell-x:9px;
  --system-table-font-size:11px;
}

table.op-excel-grid:not(.print-table)>thead>tr>th,
table.formula-sheet:not(.print-table)>thead>tr>th{
  background:var(--system-table-header);
  color:var(--system-table-header-text);
}

table.op-excel-grid:not(.print-table)>thead>tr:first-child>th,
table.formula-sheet:not(.print-table)>thead>tr:first-child>th{
  background:var(--system-table-header-strong);
}

table.op-excel-grid:not(.print-table)>tbody>tr>th,
table.formula-sheet:not(.print-table)>tbody>tr>th{
  background:var(--system-table-header-strong);
  color:var(--system-table-header-text);
  font-size:11px;
  font-weight:800;
  text-align:center;
}

/* Existing ERP density preferences remain legitimate variants of the same standard. */
body.erp-pref-table-compact table:not(.print-table){
  --system-table-cell-y:6px;
  --system-table-cell-x:7px;
  --system-table-font-size:12px;
}
body.erp-pref-table-dense table:not(.print-table){
  --system-table-cell-y:4px;
  --system-table-cell-x:6px;
  --system-table-font-size:11px;
}

@media(max-width:760px){
  .table-wrap,.op-excel-grid-wrap,[data-erp-mission-highscore-content]:not(:empty){
    max-width:100%;
    overflow-x:auto;
    overflow-y:auto;
    border-radius:var(--system-table-radius);
  }
  table:not(.print-table)>thead>tr>th,
  table:not(.print-table)>tbody>tr>:is(td,th),
  table:not(.print-table)>tfoot>tr>:is(td,th){
    line-height:1.3;
  }
}

/* 0.75.0 — canonical click/keyboard sorting for semantic data tables. */
table:not(.print-table)>thead th>button[data-system-table-sort-button]{
  width:100%;
  justify-content:flex-start;
}
table:not(.print-table)>thead th>button[data-system-table-sort-button]::after{
  content:"↕";
  flex:0 0 auto;
  margin-left:auto;
  padding-left:6px;
  color:currentColor;
  font-size:.8em;
  font-weight:900;
  opacity:.42;
}
table:not(.print-table)>thead th>button[data-system-table-sort-button][data-system-sort-direction="asc"]::after{
  content:"↑";
  opacity:1;
}
table:not(.print-table)>thead th>button[data-system-table-sort-button][data-system-sort-direction="desc"]::after{
  content:"↓";
  opacity:1;
}
table:not(.print-table)>thead th[aria-sort]>button[data-system-table-sort-button]{
  color:var(--system-table-header-hover);
}
