/* ── RichTable skin — adapts to style-c.css variables ───────────── */
:root {
  --rt-border:    var(--border,    #e5e7eb);
  --rt-surface:   var(--surface,   #ffffff);
  --rt-surface-2: var(--surface-2, #f8fafc);
  --rt-text:      var(--text,      #111827);
  --rt-muted:     var(--text-muted,#6b7280);
  --rt-accent:    var(--accent,    #111827);
  --rt-radius:    12px;
}

/* ── Toolbar ─────────────────────────────────────────────────────── */
.rt-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.rt-toolbar__left,
.rt-toolbar__right {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.rt-input {
  min-width: 260px;
}
.rt-pill {
  font-size: 11.5px;
  color: var(--rt-muted);
  white-space: nowrap;
}
@media (max-width: 640px) {
  .rt-toolbar { flex-direction: column; align-items: stretch; }
  .rt-toolbar__left,
  .rt-toolbar__right { width: 100%; justify-content: flex-start; }
  .rt-input { min-width: unset; flex: 1; }
}

/* ── Column visibility menu ──────────────────────────────────────── */
.rt-colmenu { position: relative; }
.rt-colmenu__panel {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  z-index: 1000;
  width: 220px;
  max-height: 340px;
  overflow: auto;
  background: var(--rt-surface);
  border: 1px solid var(--rt-border);
  border-radius: var(--rt-radius);
  box-shadow: 0 12px 36px rgba(0,0,0,.1);
  padding: 8px;
  display: none;
}
.rt-colmenu__panel.is-open { display: block; }
.rt-colmenu__item {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 6px 6px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  transition: background .1s;
}
.rt-colmenu__item:hover { background: var(--rt-surface-2); }

/* ── Table container (horizontal scroll on small screens) ────────── */
.tabulator-outer {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--rt-radius);
}

/* ── Tabulator overrides ─────────────────────────────────────────── */
.tabulator {
  border: 1px solid var(--rt-border);
  background: var(--rt-surface);
  border-radius: var(--rt-radius);
  overflow: hidden;
  font-family: inherit;
  font-size: 13px;
}

/* Header */
.tabulator .tabulator-header {
  background: var(--rt-surface-2);
  border-bottom: 2px solid var(--rt-border);
  color: var(--rt-muted);
}
.tabulator .tabulator-header .tabulator-col {
  border-right: 1px solid var(--rt-border);
  background: transparent;
}
.tabulator .tabulator-header .tabulator-col .tabulator-col-title {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--rt-muted);
  white-space: nowrap;
}
.tabulator .tabulator-header .tabulator-col.tabulator-sortable:hover {
  background: color-mix(in srgb, var(--rt-surface-2) 80%, var(--rt-border) 20%);
}
/* Sort arrows */
.tabulator .tabulator-header .tabulator-col .tabulator-col-sorter .tabulator-arrow {
  border-color: var(--rt-muted) transparent transparent;
}

/* Rows */
.tabulator .tabulator-row {
  border-bottom: 1px solid var(--rt-border);
  color: var(--rt-text);
  transition: background 0.1s;
}
.tabulator .tabulator-row.tabulator-row-even {
  background: color-mix(in srgb, var(--rt-surface) 94%, var(--rt-surface-2) 6%);
}
.tabulator .tabulator-row:hover {
  background: color-mix(in srgb, var(--rt-surface-2) 70%, var(--rt-border) 30%);
}
.tabulator .tabulator-row.tabulator-selected {
  background: color-mix(in srgb, var(--rt-accent) 8%, var(--rt-surface) 92%);
}

/* Cells */
.tabulator .tabulator-cell {
  padding: 9px 12px;
  border-right: 1px solid color-mix(in srgb, var(--rt-border) 55%, transparent 45%);
  line-height: 1.45;
  /* allow multi-line content (MT5 chips etc.) */
  white-space: normal;
  overflow: visible;
  vertical-align: top;
}
.tabulator .tabulator-cell:last-child { border-right: none; }

/* Footer / pagination */
.tabulator .tabulator-footer {
  background: var(--rt-surface-2);
  border-top: 1px solid var(--rt-border);
  padding: 6px 12px;
  font-size: 12px;
  color: var(--rt-muted);
}
.tabulator .tabulator-footer .tabulator-page {
  border: 1px solid var(--rt-border);
  border-radius: 6px;
  padding: 3px 10px;
  background: var(--rt-surface);
  color: var(--rt-text);
  font-size: 12px;
  cursor: pointer;
  transition: background .1s;
}
.tabulator .tabulator-footer .tabulator-page:hover:not(:disabled) {
  background: var(--rt-surface-2);
}
.tabulator .tabulator-footer .tabulator-page.active {
  background: var(--rt-accent);
  color: #fff;
  border-color: var(--rt-accent);
}
.tabulator .tabulator-footer .tabulator-page:disabled {
  opacity: .4;
  cursor: not-allowed;
}
.tabulator .tabulator-footer .tabulator-page-size {
  border: 1px solid var(--rt-border);
  border-radius: 6px;
  padding: 3px 8px;
  background: var(--rt-surface);
  color: var(--rt-text);
  font-size: 12px;
}

/* Placeholder */
.tabulator .tabulator-placeholder {
  color: var(--rt-muted);
  font-size: 13px;
  padding: 32px;
  text-align: center;
}

/* Frozen column shadow */
.tabulator .tabulator-frozen.tabulator-frozen-right {
  box-shadow: -4px 0 8px rgba(0,0,0,.06);
}
.tabulator .tabulator-frozen.tabulator-frozen-left {
  box-shadow: 4px 0 8px rgba(0,0,0,.06);
}

/* Row resize handle */
.tabulator .tabulator-col-resize-handle {
  width: 6px;
  right: -3px;
}
