/* ============================================================
   finforce-table.css — interactive chrome for FinForceTable
   The base .ax-tbl / .ax-tb / .ax-bulk / .ax-view-* / cell classes
   ship in the design-system bundle (v1-redesigned.css). This file
   adds only the interactive pieces that live outside the bundle:
   column-header popovers, the Google-Sheets footer, filter chips,
   the Columns panel, and the per-row kebab menu.
   ============================================================ */

/* Refined scrollbars — slim, rounded, subtle — app-wide */
.ff-dt * { scrollbar-width: thin; scrollbar-color: var(--border-default) transparent; }
.ff-dt *::-webkit-scrollbar { width: 12px; height: 12px; }
.ff-dt *::-webkit-scrollbar-track { background: transparent; }
.ff-dt *::-webkit-scrollbar-thumb {
  background: var(--border-default);
  border-radius: 8px;
  border: 3px solid transparent;
  background-clip: padding-box;
  min-height: 32px;
}
.ff-dt *::-webkit-scrollbar-thumb:hover { background: var(--text-quaternary); background-clip: padding-box; }
.ff-dt *::-webkit-scrollbar-corner { background: transparent; }

/* The table shell — fills its host, header + footer pinned, body scrolls */
.ff-dt.frame {
  background: var(--surface-raised);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-lg);
  overflow: hidden;
  height: 100%;
  display: flex;
  flex-direction: column;
  min-height: 0;
  position: relative;
}
.ff-dt .ax-tbl-scroll {
  flex: 1 1 auto;
  min-height: 0;
  max-height: none !important;
  overflow: auto;
}
.ff-dt .ax-tbl thead th { position: sticky; top: 0; z-index: 5; }
.ff-dt .ax-tbl thead th.frz-l,
.ff-dt .ax-tbl thead th.frz-r { z-index: 7; }
.ff-dt .ax-tbl thead th.th-pop-open { z-index: 11; }
.ff-dt .ax-tbl thead th.frz-l.th-pop-open,
.ff-dt .ax-tbl thead th.frz-r.th-pop-open { z-index: 13; }
.ff-dt .ax-tbl tfoot td { position: sticky; bottom: 0; z-index: 4; }
.ff-dt .ax-tbl tfoot td.frz-l,
.ff-dt .ax-tbl tfoot td.frz-r { z-index: 6; }
.ff-dt .gs-foot { flex-shrink: 0; }

/* ── Column header — interactive (click to sort/filter/group) ── */
.ax-tbl thead th { position: relative; }
.ax-tbl thead th.th-pop-open { z-index: 10; }
.ax-tbl thead th.frz-l.th-pop-open,
.ax-tbl thead th.frz-r.th-pop-open { z-index: 12; }
.ax-tbl thead th .th-inner {
  cursor: pointer;
  border-radius: 4px;
  padding: 2px 5px;
  margin: 0 -5px;
  transition: background var(--dur-fast);
  position: relative;
  user-select: none;
}
.ax-tbl thead th:hover .th-inner { background: var(--surface-hover); }
.ax-tbl thead th.th-active .th-inner { background: var(--green-50); color: var(--text-primary); }
.ax-tbl thead th.th-active .col-ic { color: var(--brand-green); }
.ax-tbl thead th.th-pop-open .th-inner { background: var(--surface-hover); }

.th-chev {
  display: inline-flex; align-items: center; justify-content: center;
  width: 11px; height: 11px;
  color: var(--text-quaternary);
  opacity: 0;
  transition: opacity var(--dur-fast);
  margin-left: 1px;
}
.th-chev svg { width: 8px; height: 8px; stroke-width: 2.4; }
.ax-tbl thead th:hover .th-chev { opacity: 1; }
.ax-tbl thead th.th-pop-open .th-chev { opacity: 1; color: var(--text-secondary); }

/* ── Active indicators on column headers ── */
.th-act {
  display: inline-flex; align-items: center; gap: 3px;
  height: 14px; padding: 0 4px;
  border-radius: 3px;
  background: var(--surface-muted);
  color: var(--text-secondary);
  font-size: 9.5px; font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
  flex-shrink: 0;
}
.th-act svg { width: 8px; height: 8px; stroke-width: 2.4; color: var(--text-tertiary); }
.th-act.th-act--sort { background: var(--green-100); color: var(--green-700); }
.th-act.th-act--sort svg { color: var(--brand-green); }

/* ── Column popover ── */
.th-pop {
  position: absolute;
  top: calc(100% + 4px);
  left: -4px;
  z-index: 100;
  min-width: 232px;
  max-width: 280px;
  background: var(--surface-raised);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  box-shadow: 0 6px 24px -8px rgba(0,0,0,.18), 0 2px 6px -2px rgba(0,0,0,.10);
  padding: 4px;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 400;
  isolation: isolate;
  animation: thPopIn .12s ease-out forwards;
}
@keyframes thPopIn { from { transform: translateY(-4px); } to { transform: translateY(0); } }
.num .th-pop { left: auto; right: -4px; }

.th-pop-sec {
  font-size: 10.5px; font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: .06em;
  padding: 8px 8px 4px;
}
.th-pop-sec + .th-pop-rules { padding-top: 0; }
.th-pop-item {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 8px;
  border-radius: 4px;
  border: 0;
  background: transparent;
  font-size: 12px;
  color: var(--text-secondary);
  width: 100%;
  cursor: pointer;
  text-align: left;
}
.th-pop-item:hover { background: var(--surface-hover); color: var(--text-primary); }
.th-pop-item.active { background: var(--green-50); color: var(--text-primary); font-weight: 500; }
.th-pop-item.active::after {
  content: '';
  width: 10px; height: 10px;
  background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2316a34a' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'><polyline points='20 6 9 17 4 12'/></svg>") center/contain no-repeat;
  margin-left: auto;
}
.th-pop-item > svg.ic {
  width: 13px; height: 13px;
  color: var(--text-tertiary);
  stroke-width: 1.8;
  flex-shrink: 0;
}
.th-pop-item .lbl { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.th-pop-item .kbd { margin-left: auto; font-size: 10px; color: var(--text-quaternary); font-family: var(--font-mono); }
.th-pop-sep { height: 1px; background: var(--border-subtle); margin: 4px 0; }

/* Inline filter sub-area (for facet pickers) */
.th-pop-filter { padding: 4px 4px 6px; max-height: 260px; overflow-y: auto; }
.th-pop-filter-search {
  display: flex; align-items: center; gap: 6px;
  padding: 4px 8px;
  border: 1px solid var(--border-subtle);
  border-radius: 5px;
  background: var(--surface-sunken);
  margin: 0 4px 4px;
}
.th-pop-filter-search svg { width: 10px; height: 10px; stroke-width: 1.8; color: var(--text-tertiary); }
.th-pop-filter-search input { border: 0; outline: none; background: transparent; width: 100%; font-size: 11.5px; color: var(--text-primary); }
.th-pop-facet {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 8px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  color: var(--text-secondary);
}
.th-pop-facet:hover { background: var(--surface-hover); color: var(--text-primary); }
.th-pop-facet .cb {
  width: 13px; height: 13px;
  border: 1.5px solid var(--border-strong);
  border-radius: 3px;
  flex-shrink: 0;
  background: var(--surface-raised);
  position: relative;
}
.th-pop-facet.checked .cb { background: var(--brand-green); border-color: var(--brand-green); }
.th-pop-facet.checked .cb::after {
  content: '';
  position: absolute; inset: 1px;
  background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='4' stroke-linecap='round' stroke-linejoin='round'><polyline points='20 6 9 17 4 12'/></svg>") center/contain no-repeat;
}
.th-pop-facet .lbl { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.th-pop-facet .c { font-size: 10px; color: var(--text-quaternary); font-variant-numeric: tabular-nums; flex-shrink: 0; }

/* Compact summary buttons in toolbar */
.ax-view-summary {
  display: inline-flex; align-items: center; gap: 4px;
  height: 24px; padding: 0 7px;
  border: 1px solid var(--border-subtle);
  border-radius: 5px;
  background: var(--surface-sunken);
  color: var(--text-secondary);
  font-size: 11px;
  cursor: pointer;
  white-space: nowrap;
}
.ax-view-summary:hover { background: var(--surface-hover); color: var(--text-primary); }
.ax-view-summary svg { width: 10px; height: 10px; stroke-width: 1.8; }
.ax-view-summary b { color: var(--text-primary); font-weight: 600; }
.ax-view-summary .dot { width: 5px; height: 5px; border-radius: 50%; background: var(--text-quaternary); }
.ax-view-summary.has .dot { background: var(--brand-green); }

/* ── Icon-only segmented view switcher ── */
.seg.seg--icon .seg-item { padding: 0 6px; gap: 0; min-width: 24px; justify-content: center; }
.seg.seg--icon .seg-item svg { width: 13px; height: 13px; }

/* ── Chip — unified style across filter/sort/group ── */
.ax-chips .chip {
  display: inline-flex; align-items: center; gap: 5px;
  height: 22px; padding: 0 4px 0 7px;
  border-radius: 4px;
  background: var(--surface-raised);
  border: 1px solid var(--border-subtle);
  font-size: 11px; color: var(--text-secondary);
  cursor: pointer;
  white-space: nowrap;
  max-width: 240px;
  transition: border-color var(--dur-fast), background var(--dur-fast);
}
.ax-chips .chip:hover { border-color: var(--border-default); background: var(--surface-hover); }
.chip .chip-ic { display: inline-flex; align-items: center; justify-content: center; width: 11px; height: 11px; flex-shrink: 0; color: var(--text-tertiary); }
.chip .chip-ic svg { width: 10px; height: 10px; stroke-width: 1.8; }
.chip .chip-k { font-weight: 500; color: var(--text-primary); overflow: hidden; text-overflow: ellipsis; }
.chip .chip-arrow { font-size: 11px; color: var(--text-tertiary); margin-left: -1px; font-variant-numeric: tabular-nums; }
.chip .chip-v {
  color: var(--text-secondary);
  padding-left: 6px; margin-left: 2px;
  border-left: 1px solid var(--border-subtle);
  overflow: hidden; text-overflow: ellipsis;
  max-width: 120px;
}
.chip .chip-more { font-size: 9.5px; font-weight: 600; color: var(--text-tertiary); background: var(--surface-sunken); padding: 1px 4px; border-radius: 3px; font-variant-numeric: tabular-nums; }
.chip .chip-x {
  display: inline-flex; align-items: center; justify-content: center;
  width: 14px; height: 14px;
  border-radius: 3px;
  color: var(--text-quaternary);
  margin-left: 2px;
  transition: background var(--dur-fast), color var(--dur-fast);
}
.chip .chip-x svg { width: 8px; height: 8px; stroke-width: 2.4; }
.chip:hover .chip-x { background: var(--surface-active); color: var(--text-primary); }
.chip.chip--add { color: var(--text-tertiary); border-style: dashed; padding: 0 6px; background: transparent; }
.chip.chip--add:hover { color: var(--text-primary); border-style: solid; background: var(--surface-raised); }
.chip.chip--add svg { width: 10px; height: 10px; stroke-width: 2; }

/* ════════ Google Sheets-style footer ════════ */
.gs-foot {
  display: flex; align-items: stretch;
  height: 32px;
  padding: 0;
  background: var(--surface-sunken);
  border-top: 1px solid var(--border-subtle);
  font-size: 11.5px;
  color: var(--text-secondary);
  user-select: none;
}
.gs-foot-cluster { display: inline-flex; align-items: center; gap: 0; padding: 0 4px; flex-shrink: 0; }
.gs-foot-cluster--right { gap: 2px; padding: 0 6px 0 8px; border-left: 1px solid var(--border-subtle); margin-left: 0; }
.gs-foot-iconbtn {
  width: 22px; height: 22px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 0; background: transparent;
  border-radius: 4px;
  color: var(--text-tertiary);
  cursor: pointer;
  transition: background var(--dur-fast), color var(--dur-fast);
}
.gs-foot-iconbtn:hover { background: var(--surface-hover); color: var(--text-primary); }
.gs-foot-iconbtn:active { background: var(--border-subtle); }
.gs-foot-iconbtn svg { width: 12px; height: 12px; stroke-width: 1.8; }
.gs-foot-iconbtn[disabled] { opacity: .3; cursor: default; pointer-events: none; }
.gs-foot-tabs {
  display: inline-flex; align-items: stretch;
  flex: 1; min-width: 0;
  overflow-x: auto; overflow-y: hidden;
  scrollbar-width: none;
  border-left: 1px solid var(--border-subtle);
  padding-left: 2px;
}
.gs-foot-tabs::-webkit-scrollbar { display: none; }
.gs-tab {
  display: inline-flex; align-items: center; gap: 6px;
  height: 32px;
  padding: 0 12px;
  border: 0; background: transparent;
  border-right: 1px solid transparent;
  font-size: 11.5px;
  color: var(--text-tertiary);
  cursor: pointer;
  white-space: nowrap;
  position: relative;
  flex-shrink: 0;
  transition: background var(--dur-fast), color var(--dur-fast);
}
.gs-tab:hover { background: var(--surface-hover); color: var(--text-primary); }
.gs-tab--active {
  background: var(--surface-raised);
  color: var(--text-primary);
  font-weight: 600;
  border-right: 1px solid var(--border-subtle);
  box-shadow: inset 0 -2px 0 0 var(--brand-green), 1px 0 0 0 var(--border-subtle);
}
.gs-tab--active::before { content: ''; position: absolute; top: -1px; left: 0; right: 0; height: 1px; background: var(--surface-raised); }
.gs-tab-lbl { line-height: 1; }
.gs-tab-c { font-size: 10px; font-weight: 500; color: var(--text-quaternary); font-variant-numeric: tabular-nums; line-height: 1; }
.gs-tab--active .gs-tab-c { color: var(--green-700); }
.gs-tab-star { width: 10px; height: 10px; color: var(--brand-green); fill: currentColor; fill-opacity: .18; stroke-width: 2; flex-shrink: 0; }
.gs-tab-dirty { width: 5px; height: 5px; border-radius: 50%; background: var(--warning); flex-shrink: 0; }
.gs-foot-add { align-self: center; margin: 0 4px; }
.gs-foot-page { font-size: 11px; color: var(--text-tertiary); font-variant-numeric: tabular-nums; white-space: nowrap; padding: 0 6px; }
.gs-foot-page b { color: var(--text-primary); font-weight: 500; }
.gs-foot-pageof { padding: 0 2px; min-width: 32px; text-align: center; }
.gs-foot-rpp {
  display: inline-flex; align-items: center; gap: 3px;
  height: 22px; padding: 0 5px 0 7px;
  border: 0; background: transparent;
  border-radius: 4px;
  font-size: 11px;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  margin-left: 2px;
}
.gs-foot-rpp:hover { background: var(--surface-hover); color: var(--text-primary); }
.gs-foot-rpp svg { color: var(--text-tertiary); }

/* Tfoot collapse toggle */
.ax-agg-tog {
  width: 18px; height: 18px;
  border: 0; background: transparent;
  border-radius: 3px;
  color: var(--text-quaternary);
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background var(--dur-fast), color var(--dur-fast);
}
.ax-agg-tog:hover { background: var(--surface-hover); color: var(--text-primary); }
.ax-agg-tog svg { width: 11px; height: 11px; stroke-width: 2; }
.ax-tbl tfoot.ax-agg-collapsed tr.ax-agg-row-min td {
  height: 18px;
  padding: 0 6px;
  background: var(--surface-sunken);
  border-top: 1px solid var(--border-subtle);
  border-bottom: 0;
}

/* ── Compact popover tabs ── */
.th-pop-tabs { display: flex; gap: 2px; padding: 3px; margin: 0 0 4px; background: var(--surface-sunken); border-radius: 6px; }
.th-pop-tab {
  flex: 1;
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  height: 24px;
  border: 0; background: transparent;
  border-radius: 4px;
  font-size: 11.5px;
  color: var(--text-tertiary);
  cursor: pointer;
  font-weight: 500;
  transition: background var(--dur-fast), color var(--dur-fast);
}
.th-pop-tab:hover { color: var(--text-secondary); }
.th-pop-tab.active { background: var(--surface-raised); color: var(--text-primary); box-shadow: 0 1px 2px rgba(0,0,0,.04), 0 0 0 1px var(--border-subtle); }
.th-pop-tab svg { width: 11px; height: 11px; stroke-width: 1.8; opacity: .8; }
.th-pop-tab .c {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 14px; height: 14px;
  padding: 0 4px;
  border-radius: 7px;
  font-size: 9.5px; font-weight: 700;
  font-variant-numeric: tabular-nums;
  background: var(--surface-muted);
  color: var(--text-tertiary);
}
.th-pop-tab.active .c { background: var(--color-action); color: var(--color-on-action); }
.th-pop-foot { display: flex; align-items: center; gap: 4px; padding: 4px; margin-top: 2px; border-top: 1px solid var(--border-subtle); }
.th-pop-foot button { flex: 1; height: 26px; border: 0; background: transparent; border-radius: 4px; font-size: 11.5px; color: var(--text-tertiary); cursor: pointer; font-weight: 500; transition: background var(--dur-fast), color var(--dur-fast); }
.th-pop-foot button:hover { background: var(--surface-hover); color: var(--text-primary); }
.th-pop-foot button.primary { color: var(--text-brand-strong); }
.th-pop--tabbed { padding: 6px; min-width: 264px; }
.th-pop--tabbed .th-pop-sec { padding: 6px 4px 4px; }
.th-pop--tabbed .th-pop-body { max-height: 320px; overflow-y: auto; padding: 0 2px; }

/* Column-header popover (tabbed, viewport-aware) */
.th-pop--col { padding: 6px; min-width: 280px; max-width: 320px; display: flex; flex-direction: column; max-height: var(--th-pop-maxh, 420px); }
.th-pop--col.th-pop--up { top: auto; bottom: calc(100% + 4px); animation: thPopInUp .12s ease-out forwards; }
/* Body-portaled (fixed) column popover — escapes the scroll container's
   overflow clipping so it's never cut off by the footer on short tables. */
.th-pop--fixed { position: fixed; z-index: 1200; }
.th-pop--fixed.th-pop--up { top: auto; }
@keyframes thPopInUp { from { transform: translateY(4px); } to { transform: translateY(0); } }
.th-pop-tabs--col { margin-bottom: 4px; }
.th-pop-body--col { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; padding: 0 2px; }
.th-pop-body--col > .th-pop-sec:first-child { padding-top: 4px; }
.th-pop-body--col .th-pop-filter { max-height: none; overflow: visible; }
.th-pop-body--col {
  mask-image: linear-gradient(to bottom, transparent 0, #000 8px, #000 calc(100% - 8px), transparent 100%);
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 8px, #000 calc(100% - 8px), transparent 100%);
}
.th-pop-submode { display: inline-flex; margin: 4px 4px 6px; padding: 2px; background: var(--surface-sunken); border-radius: 5px; }
.th-pop-submode button { border: 0; background: transparent; height: 22px; padding: 0 10px; border-radius: 3px; font-size: 11px; font-weight: 500; color: var(--text-tertiary); cursor: pointer; }
.th-pop-submode button:hover { color: var(--text-secondary); }
.th-pop-submode button.on { background: var(--surface-raised); color: var(--text-primary); box-shadow: 0 1px 2px rgba(0,0,0,.04), 0 0 0 1px var(--border-subtle); }

/* Pin badge + custom-rule builder */
.th-pin-badge { display: inline-flex; align-items: center; justify-content: center; width: 12px; height: 12px; color: var(--brand-green); margin-left: 1px; }
.th-pin-badge svg { width: 9px; height: 9px; stroke-width: 2; }
.th-pop-rules { display: flex; flex-direction: column; gap: 3px; padding: 2px 4px 4px; }
.th-cr-row { display: grid; grid-template-columns: minmax(0, auto) minmax(0, 1fr) auto; align-items: center; gap: 4px; padding: 4px; border: 1px solid var(--border-subtle); border-radius: 5px; background: var(--surface-sunken); }
.th-cr-op { position: relative; display: inline-flex; align-items: center; justify-content: space-between; gap: 4px; height: 22px; padding: 0 6px; background: var(--surface-raised); border: 1px solid var(--border-subtle); border-radius: 4px; font-family: inherit; font-size: 11px; color: var(--text-primary); font-weight: 500; cursor: pointer; white-space: nowrap; max-width: 130px; overflow: hidden; appearance: none; }
.th-cr-op > span:first-child { overflow: hidden; text-overflow: ellipsis; }
.th-cr-op:hover { border-color: var(--border-default); background: var(--surface-hover); }
.th-cr-op svg { width: 9px; height: 9px; stroke-width: 2.4; color: var(--text-tertiary); flex-shrink: 0; }
.th-cr-op-select { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; border: 0; background: transparent; appearance: none; -webkit-appearance: none; font: inherit; }

/* ── FFSelect — DS-styled dropdown replacing native <select> ── */
.th-cr-op-wrap { display: inline-flex; min-width: 0; }
.th-cr-selwrap { display: block; min-width: 0; width: 100%; }
.ff-sel-trig {
  display: inline-flex; align-items: center; justify-content: space-between; gap: 6px;
  width: 100%; height: 22px; padding: 0 6px;
  background: var(--surface-raised); border: 1px solid var(--border-subtle); border-radius: 4px;
  font-family: inherit; font-size: 11px; color: var(--text-primary); font-weight: 500;
  cursor: pointer; white-space: nowrap; appearance: none; text-align: start;
  transition: border-color var(--dur-fast), background var(--dur-fast);
}
.ff-sel-trig:hover:not([disabled]) { border-color: var(--border-default); background: var(--surface-hover); }
.ff-sel-trig[disabled] { opacity: .5; cursor: default; }
.ff-sel-trig .ff-sel-lbl, .th-cr-op .ff-sel-lbl { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: start; }
.ff-sel-trig .ff-sel-chev, .th-cr-op .ff-sel-chev { width: 9px; height: 9px; stroke-width: 2.4; color: var(--text-tertiary); flex-shrink: 0; }
.ff-sel-menu {
  position: fixed; z-index: 1400;
  min-width: 140px; max-width: 260px; max-height: 264px; overflow-y: auto;
  padding: 4px; background: var(--surface-raised);
  border: 1px solid var(--border-subtle); border-radius: 8px;
  box-shadow: 0 8px 28px -8px rgba(0,0,0,.20), 0 2px 6px -2px rgba(0,0,0,.10);
  animation: thPopIn .12s ease-out forwards;
  text-transform: none; letter-spacing: 0; font-weight: 400;
}
.ff-sel-opt {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 5px 8px; border: 0; background: transparent; border-radius: 5px;
  font-family: inherit; font-size: 12px; color: var(--text-secondary);
  cursor: pointer; text-align: left;
}
.ff-sel-opt.hi, .ff-sel-opt:hover { background: var(--surface-hover); color: var(--text-primary); }
.ff-sel-opt.sel { color: var(--text-primary); font-weight: 500; }
.ff-sel-opt-lbl { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ff-sel-opt-tick { width: 12px; height: 12px; stroke-width: 2.6; color: var(--brand-green); flex-shrink: 0; }
.th-cr-input { height: 22px; padding: 0 6px; border: 1px solid var(--border-subtle); border-radius: 4px; background: var(--surface-raised); color: var(--text-primary); font-size: 11px; outline: none; width: 100%; min-width: 0; font-variant-numeric: tabular-nums; }
.th-cr-input::placeholder { color: var(--text-quaternary); }
.th-cr-input:focus { border-color: var(--brand-green); box-shadow: 0 0 0 2px var(--green-100); }
select.th-cr-input { width: 100%; appearance: none; padding-right: 16px;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-tertiary) 50%), linear-gradient(135deg, var(--text-tertiary) 50%, transparent 50%);
  background-position: calc(100% - 9px) 50%, calc(100% - 5px) 50%;
  background-size: 4px 4px, 4px 4px; background-repeat: no-repeat; }
.th-cr-range { display: grid; grid-template-columns: minmax(0,1fr) auto minmax(0,1fr); align-items: center; gap: 3px; min-width: 0; }
.th-cr-range .th-cr-suffix { grid-column: 1 / -1; text-align: right; }
.th-cr-sep { color: var(--text-tertiary); font-family: var(--font-mono); font-size: 10.5px; padding: 0 1px; }
.th-cr-suffix { color: var(--text-tertiary); font-size: 10.5px; padding: 0 2px; }
.th-cr-novalue { color: var(--text-quaternary); font-size: 10.5px; font-style: italic; padding: 0 6px; }
.th-cr-del { margin-left: auto; width: 20px; height: 22px; display: inline-flex; align-items: center; justify-content: center; border: 0; background: transparent; border-radius: 3px; color: var(--text-quaternary); cursor: pointer; }
.th-cr-del:hover { background: var(--danger-bg); color: var(--danger); }
.th-cr-del svg { width: 9px; height: 9px; stroke-width: 2.4; }
.th-cr-multi { display: flex; flex-wrap: wrap; gap: 3px; min-width: 0; padding: 2px 0; max-height: 64px; overflow-y: auto; }
.th-cr-chip { display: inline-flex; align-items: center; height: 18px; padding: 0 6px; border: 1px solid var(--border-subtle); border-radius: 9px; background: var(--surface-raised); color: var(--text-secondary); font-size: 10.5px; cursor: pointer; }
.th-cr-chip:hover { border-color: var(--border-default); color: var(--text-primary); }
.th-cr-chip.on { background: var(--brand-green); border-color: var(--brand-green); color: #fff; }

/* Toolbar "Columns" panel */
.ax-col-panel {
  position: absolute; top: calc(100% + 6px); right: 0;
  z-index: 40;
  width: 280px; max-height: 420px;
  background: var(--surface-raised);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  box-shadow: 0 8px 28px -8px rgba(0,0,0,.20), 0 2px 6px -2px rgba(0,0,0,.10);
  display: flex; flex-direction: column;
  overflow: hidden;
  animation: thPopIn .12s ease-out forwards;
  font-weight: 400; text-transform: none; letter-spacing: 0;
}
.ax-col-panel-h { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-bottom: 1px solid var(--border-subtle); font-size: 11.5px; font-weight: 600; color: var(--text-primary); }
.ax-col-panel-h-meta { margin-left: auto; font-size: 10.5px; font-weight: 400; color: var(--text-tertiary); font-variant-numeric: tabular-nums; }
.ax-col-panel-list { flex: 1; min-height: 0; overflow-y: auto; padding: 4px; }
.ax-col-row { display: flex; align-items: center; gap: 6px; padding: 4px 6px; border-radius: 5px; font-size: 11.5px; color: var(--text-primary); }
.ax-col-row:hover { background: var(--surface-hover); }
.ax-col-row.hidden { opacity: 0.5; }
.ax-col-row.hidden .ax-col-row-lbl { color: var(--text-tertiary); text-decoration: line-through; text-decoration-thickness: 1px; }
.ax-col-vis { width: 22px; height: 22px; display: inline-flex; align-items: center; justify-content: center; border: 0; background: transparent; border-radius: 3px; color: var(--text-tertiary); cursor: pointer; flex-shrink: 0; }
.ax-col-vis:hover { background: var(--surface-active); color: var(--text-primary); }
.ax-col-vis svg { width: 12px; height: 12px; stroke-width: 1.8; }
.ax-col-row-ic { width: 12px; height: 12px; color: var(--text-tertiary); stroke-width: 1.8; flex-shrink: 0; }
.ax-col-row-lbl { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ax-col-pinset { display: inline-flex; gap: 2px; flex-shrink: 0; }
.ax-col-pinbtn { display: inline-flex; align-items: center; gap: 2px; height: 20px; padding: 0 5px; border: 1px solid var(--border-subtle); background: var(--surface-raised); border-radius: 3px; color: var(--text-tertiary); font-size: 9.5px; font-weight: 600; cursor: pointer; font-family: var(--font-mono); }
.ax-col-pinbtn:hover:not([disabled]) { border-color: var(--border-default); color: var(--text-primary); }
.ax-col-pinbtn.active { background: var(--brand-green); border-color: var(--brand-green); color: #fff; }
.ax-col-pinbtn[disabled] { opacity: 0.4; cursor: default; }
.ax-col-pinbtn svg { width: 8px; height: 8px; stroke-width: 2; }
.ax-col-panel-f { display: flex; align-items: center; gap: 8px; padding: 6px 10px; background: var(--surface-sunken); border-top: 1px solid var(--border-subtle); }

/* Per-row kebab menu (portaled to body, fixed-position) */
.ax-row-act-btn.is-open { background: var(--surface-active); color: var(--text-primary); }
.rm-menu {
  position: fixed;
  z-index: 200;
  width: 200px;
  background: var(--surface-raised);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  box-shadow: 0 8px 28px -8px rgba(0,0,0,.20), 0 2px 6px -2px rgba(0,0,0,.10);
  padding: 4px;
  animation: thPopIn .12s ease-out forwards;
}
.rm-item { display: flex; align-items: center; gap: 9px; width: 100%; padding: 5px 8px; border: 0; background: transparent; border-radius: 5px; font-size: 12px; color: var(--text-secondary); cursor: pointer; text-align: left; }
.rm-item:hover { background: var(--surface-hover); color: var(--text-primary); }
.rm-item[disabled] { opacity: .4; cursor: not-allowed; }
.rm-item[disabled]:hover { background: transparent; color: var(--text-secondary); }
.rm-ic { width: 13px; height: 13px; color: var(--text-tertiary); stroke-width: 1.8; flex-shrink: 0; }
.rm-item:hover .rm-ic { color: var(--text-secondary); }
.rm-lbl { flex: 1; min-width: 0; }
.rm-kbd { font-size: 10px; color: var(--text-quaternary); font-family: var(--font-mono); }
.rm-sep { height: 1px; background: var(--border-subtle); margin: 4px 0; }
.rm-item--danger { color: var(--danger); }
.rm-item--danger .rm-ic { color: var(--danger); }
.rm-item--danger:hover { background: var(--danger-bg); color: var(--danger); }
.rm-item--danger:hover .rm-ic { color: var(--danger); }

/* ── Column drag-reorder (grip + floating ghost + insertion line) ── */
.th-grip {
  display: inline-flex; align-items: center; justify-content: center;
  width: 15px; height: 18px; margin-inline: -1px 2px; padding: 0;
  border: 0; background: transparent; color: var(--text-quaternary);
  border-radius: 4px; cursor: grab; opacity: 0; flex: none;
  transition: opacity var(--dur-fast,.13s) ease, background var(--dur-fast,.13s) ease, color var(--dur-fast,.13s) ease;
  touch-action: none; -webkit-user-select: none; user-select: none;
}
.th-grip svg { width: 11px; height: 11px; pointer-events: none; }
th:hover .th-grip, .th-grip:focus-visible { opacity: 1; }
.th-grip:hover { background: var(--surface-sunken); color: var(--text-secondary); }
.th-grip:focus-visible { outline: 2px solid var(--border-focus, var(--brand-green)); outline-offset: 1px; opacity: 1; }
.th-grip:active { cursor: grabbing; }
th[data-col-dragging] .th-inner { opacity: .32; }
th[data-col-dragging] { background: var(--surface-sunken); }
th[data-col-grabbed] { box-shadow: inset 0 0 0 2px var(--brand-green); border-radius: 4px; }
th[data-col-grabbed] .th-grip { opacity: 1; color: var(--brand-green); cursor: grabbing; }
.coldrag-ghost {
  position: fixed; left: 0; top: 0; z-index: 2147483000; pointer-events: none;
  display: inline-flex; align-items: center; gap: 6px;
  height: 34px; padding: 0 12px;
  font-size: 12px; font-weight: 600; letter-spacing: -.003em;
  color: var(--text-primary); background: var(--surface-raised);
  border: 1px solid var(--border-default, var(--border-subtle));
  border-radius: 7px; white-space: nowrap; max-width: 280px;
  box-shadow: 0 10px 26px -6px rgba(15,18,22,.28), 0 2px 6px -2px rgba(15,18,22,.18);
  transform: translate3d(0,0,0) scale(1.015); transform-origin: 8px 50%;
  opacity: 0; transition: opacity .1s ease;
}
.coldrag-ghost.is-on { opacity: 1; }
.coldrag-ghost svg { width: 11px; height: 11px; color: var(--text-quaternary); flex: none; }
.coldrag-ghost .coldrag-ghost-ic { width: 12px; height: 12px; color: var(--text-tertiary); }
.coldrag-ind {
  position: absolute; z-index: 60; width: 2px; pointer-events: none;
  background: var(--brand-green); border-radius: 2px;
  box-shadow: 0 0 0 1px var(--surface-raised), 0 0 7px -1px var(--brand-green);
  transition: left .14s cubic-bezier(.22,.61,.36,1), height .12s ease, top .12s ease;
}
.coldrag-ind::before, .coldrag-ind::after { content: ""; position: absolute; left: 50%; width: 7px; height: 7px; transform: translateX(-50%); background: var(--brand-green); border-radius: 50%; box-shadow: 0 0 0 1.5px var(--surface-raised); }
.coldrag-ind::before { top: -3px; } .coldrag-ind::after { bottom: -3px; }
body.coldrag-active, body.coldrag-active * { cursor: grabbing !important; }
body.coldrag-active .th-inner { pointer-events: none; }
.ax-col-grip { display: inline-flex; align-items: center; justify-content: center; width: 16px; height: 20px; margin-inline-end: 2px; flex: none; color: var(--text-quaternary); cursor: grab; border-radius: 4px; opacity: .55; transition: opacity var(--dur-fast,.13s) ease, color var(--dur-fast,.13s) ease; }
.ax-col-grip svg { width: 12px; height: 12px; }
.ax-col-row:hover .ax-col-grip { opacity: 1; color: var(--text-secondary); }
.ax-col-row.is-dragging { opacity: .4; }
.ax-col-row.is-over { box-shadow: inset 0 2px 0 var(--brand-green); }

/* Generic cell helpers used by column render fns */
.ff-cell-strong { font-weight: var(--fw-semibold); color: var(--text-primary); }
.ff-cell-mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.ff-cell-dim { color: var(--text-tertiary); }
/* Muted (e.g. cancelled) rows — dim via colour, NOT opacity: opacity on a
   sticky/frozen <td> turns it translucent so scrolled columns bleed through. */
.ax-tbl tbody tr.ff-row-muted td { color: var(--text-quaternary); }
.ax-tbl tbody tr.ff-row-muted td .ff-cell-strong,
.ax-tbl tbody tr.ff-row-muted td .ff-cell-mono { color: var(--text-tertiary); }
.ax-tbl tbody tr.ff-row-muted td .pill { opacity: .65; }

/* ── Mobile (< 640px) — card-stack fallback ── */
@media (max-width: 639px) {
  .ff-dt .ax-tb { flex-wrap: wrap; gap: 8px !important; padding: 10px !important; }
  .ff-dt .ax-tb .input-shell { order: 5; width: 100% !important; }
  .ff-dt .ax-title { font-size: 14px !important; }
  .ax-chips { overflow-x: auto; flex-wrap: nowrap !important; gap: 6px !important; padding: 6px 10px !important; scrollbar-width: none; }
  .ax-chips::-webkit-scrollbar { display: none; }
  .ax-chips .chip { flex-shrink: 0; min-height: 30px; }
  .gs-foot { height: auto !important; padding: 4px 6px !important; flex-wrap: wrap; gap: 4px !important; }
  .gs-foot-rpp, .gs-foot-page { display: none !important; }
  .gs-foot-cluster--right .gs-foot-iconbtn { width: 36px !important; height: 36px !important; }
  .gs-tab { min-height: 36px; }

  /* Card stack — each row becomes a card */
  .ff-cards { display: flex; flex-direction: column; gap: 8px; padding: 12px; background: var(--surface-sunken); overflow: auto; flex: 1; min-height: 0; }
  .ff-card { background: var(--surface-raised); border: 1px solid var(--border-subtle); border-radius: var(--r-lg); padding: 12px; display: flex; flex-direction: column; gap: 8px; }
  .ff-card.is-sel { border-color: var(--brand-green); box-shadow: 0 0 0 2px var(--green-100); }
  .ff-card-h { display: flex; align-items: center; gap: 8px; }
  .ff-card-h .cb { flex-shrink: 0; }
  .ff-card-row { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; font-size: 12px; }
  .ff-card-row .k { color: var(--text-tertiary); flex-shrink: 0; }
  .ff-card-row .v { color: var(--text-secondary); text-align: end; min-width: 0; }
}
