/* ═══════════════════════════════════════════════════════════════
   Super Table — table.css
   ═══════════════════════════════════════════════════════════════ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  background: #ffffff;
  color: #334155;
}

#root {
  width: 100%;
  height: 100vh;
  position: relative;
  overflow: hidden;
}

/* ── Table wrapper ──────────────────────────────────────────── */

.st-wrapper {
  width: 100%;
  height: 100%;
  overflow: auto;
  position: relative;
}

.st-table {
  width: auto;
  border-collapse: collapse;
  table-layout: fixed;
  font-family: inherit;
}

.st-table th,
.st-table td {
  font-family: inherit;
}

/* ── Header ─────────────────────────────────────────────────── */

.st-table thead {
  position: sticky;
  top: 0;
  z-index: 10;
}

.st-table th {
  background: #f1f5f9;
  color: #1e293b;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0 12px;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border-bottom: 2px solid #e2e8f0;
  border-right: 1px solid #e2e8f0;
  position: relative;
  user-select: none;
}

.st-table th:last-child {
  border-right: none;
}

/* ── Resize handle ──────────────────────────────────────────── */

.st-resize-handle {
  position: absolute;
  top: 0;
  right: 0;           /* stay inside th — overflow:hidden clips anything outside */
  width: 12px;        /* generous hit area */
  height: 100%;
  cursor: col-resize;
  z-index: 3;         /* above sort icon and text */
}

.st-resize-handle::after {
  content: "";
  position: absolute;
  top: 15%;
  right: 2px;
  width: 3px;
  height: 70%;
  background: transparent;
  border-radius: 2px;
  transition: background 0.12s;
}

/* Show indicator on th hover (user approaching the edge) AND direct handle hover */
.st-table th:hover .st-resize-handle::after,
.st-resize-handle:hover::after {
  background: rgba(148, 163, 184, 0.7);
}

/* Keep indicator fully visible during active drag regardless of where cursor is */
.st-resize-handle.active::after {
  background: #4e79a7 !important;
}

/* Prevent sortable cursor from fighting col-resize on the handle zone */
.st-table th.st-sortable .st-resize-handle {
  cursor: col-resize;
}

/* ── Sortable column headers ─────────────────────────────────── */

.st-table th.st-sortable {
  cursor: pointer;
  padding-right: 28px; /* room for the sort icon */
}

.st-table th.st-sortable:hover {
  filter: brightness(0.95);
}

.st-sort-icon {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 10px;
  opacity: 0.35;
  transition: opacity 0.15s;
}

.st-sort-icon.active {
  opacity: 1;
}

.st-table th.st-sortable:hover .st-sort-icon {
  opacity: 0.7;
}

/* ── Column group header row ─────────────────────────────────── */

.st-group-row .st-group-th {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-align: center;
  padding: 6px 12px;
  border-bottom: 1px solid rgba(255,255,255,0.2);
  height: 36px;
}

.st-group-row .st-group-th-empty {
  border-bottom: none;
}

/* ── Cells ──────────────────────────────────────────────────── */

.st-table td {
  padding: 6px 12px;
  border-bottom: 1px solid #e2e8f0;
  border-right: 1px solid #e2e8f0;
  vertical-align: middle;
  overflow: hidden;
  color: #334155;
}

.st-table td:last-child {
  border-right: none;
}

.st-table tbody tr:hover td {
  background: rgba(78, 121, 167, 0.12);
}

/* Stripe rows */
.st-table tbody tr.st-stripe td {
  background: #f1f5f9;
}

.st-table tbody tr.st-stripe:hover td {
  background: rgba(78, 121, 167, 0.14);
}

/* ── Cell inner layout ──────────────────────────────────────── */

.st-cell-primary {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
  color: #334155;
  line-height: 1.4;
}

.st-cell-sub {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  color: #94a3b8;
  line-height: 1.3;
  margin-top: 1px;
}

/* ── Empty state ────────────────────────────────────────────── */

.st-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 40px 32px;
  text-align: center;
  gap: 16px;
}

.st-empty-icon {
  font-size: 40px;
  opacity: 0.3;
}

.st-empty-msg {
  font-size: 16px;
  font-weight: 500;
  color: #64748b;
  max-width: 380px;
  line-height: 1.5;
}

.st-disclaimer {
  font-size: 11px;
  color: #64748b;
  max-width: 400px;
  line-height: 1.5;
  margin-top: 8px;
}

.st-attribution {
  font-size: 10px;
  color: #94a3b8;
  margin-top: 20px;
  letter-spacing: 0.03em;
}

.cfg-help-footer {
  padding: 8px 0 12px;
  font-size: 10px;
  color: #94a3b8;
  border-top: 1px solid #e2e8f0;
  margin-top: 8px;
  letter-spacing: 0.03em;
}

/* ── Gear button ────────────────────────────────────────────── */

#gear {
  position: fixed;
  top: 8px;
  right: 8px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid #e2e8f0;
  background: #ffffff;
  color: #64748b;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 4px rgba(0,0,0,0.10);
  z-index: 100;
  padding: 0;
  line-height: 1;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}

#gear:hover {
  background: #f1f5f9;
  color: #1e293b;
  box-shadow: 0 2px 8px rgba(0,0,0,0.14);
}

#version {
  position: fixed;
  bottom: 6px;
  left: 10px;
  font-size: 10px;
  color: #cbd5e1;
  z-index: 100;
  pointer-events: none;
}

/* ── Hover tooltip card ─────────────────────────────────────── */

#st-tooltip {
  position: fixed;
  display: none;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  padding: 10px 14px;
  z-index: 1000;
  min-width: 160px;
  max-width: 280px;
  pointer-events: none;
}

.st-tip-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 3px 12px;
  font-size: 12px;
}

.st-tip-label {
  color: #94a3b8;
  white-space: nowrap;
}

.st-tip-value {
  color: #1e293b;
  font-weight: 600;
  text-align: right;
  white-space: nowrap;
}

/* ═══════════════════════════════════════════════════════════════
   Config Dialog
   ═══════════════════════════════════════════════════════════════ */

.cfg {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  background: #ffffff;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.cfg-header {
  padding: 16px 20px 12px;
  border-bottom: 1px solid #e2e8f0;
  flex-shrink: 0;
}

.cfg-header-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 2px;
}

.cfg-header h2 {
  font-size: 16px;
  font-weight: 700;
  color: #1e293b;
  flex: 1;
  margin-bottom: 0;
}

.cfg-header p {
  font-size: 12px;
  color: #94a3b8;
}

/* Info / help button */
.cfg-help-btn {
  background: none;
  border: 1.5px solid #cbd5e1;
  border-radius: 50%;
  width: 22px;
  height: 22px;
  font-size: 13px;
  line-height: 1;
  color: #64748b;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: border-color 0.15s, color 0.15s;
}
.cfg-help-btn:hover, .cfg-help-btn.active {
  border-color: #3b82f6;
  color: #3b82f6;
}

/* Help panel */
.cfg-help-panel {
  padding: 0 20px;
  border-bottom: 1px solid #e2e8f0;
  background: #f8fafc;
}
.cfg-help-content {
  padding: 12px 0;
  font-size: 12px;
  color: #334155;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 24px;
}
.cfg-help-content h3 {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #64748b;
  margin: 10px 0 4px;
  grid-column: 1 / -1;
}
.cfg-help-content h3:first-child { margin-top: 0; }
.cfg-help-content p {
  margin: 0 0 4px;
  line-height: 1.5;
}
.cfg-help-content code {
  font-family: monospace;
  font-size: 11px;
  background: #e2e8f0;
  padding: 1px 4px;
  border-radius: 3px;
}

/* ── Two-panel layout ───────────────────────────────────────── */

.cfg-body {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ── Left: column list ──────────────────────────────────────── */

.cfg-col-list {
  width: 220px;
  flex-shrink: 0;
  border-right: 1px solid #e2e8f0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.cfg-col-list-inner {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.cfg-col-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  color: #334155;
  user-select: none;
  border: 1px solid transparent;
  border-left: 3px solid transparent;
  margin-bottom: 3px;
  transition: background 0.12s, border-color 0.12s;
  position: relative;
}

.cfg-col-item:hover {
  background: #f0f9ff;
  border-left-color: #93c5fd;
}

.cfg-col-item.selected {
  background: #eff6ff;
  border-left-color: #2563eb;
  border-top-color: #bfdbfe;
  border-right-color: #bfdbfe;
  border-bottom-color: #bfdbfe;
  color: #1e40af;
  font-weight: 600;
}

.cfg-col-item.hidden-col {
  opacity: 0.45;
}

.cfg-col-label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Reorder arrows — shown on hover */
.cfg-col-reorder {
  display: none;
  flex-direction: column;
  gap: 1px;
  flex-shrink: 0;
}

.cfg-col-item:hover .cfg-col-reorder {
  display: flex;
}

.cfg-col-item.selected .cfg-col-reorder {
  display: flex;
}

.cfg-reorder-btn {
  background: none;
  border: none;
  padding: 0 2px;
  font-size: 9px;
  color: #94a3b8;
  cursor: pointer;
  line-height: 1;
}

.cfg-reorder-btn:hover:not([disabled]) {
  color: #1e293b;
}

.cfg-reorder-btn[disabled] {
  color: #e2e8f0;
  cursor: default;
}

.cfg-col-shelf-badge {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 1px 5px;
  border-radius: 3px;
  flex-shrink: 0;
}

.cfg-col-shelf-badge.dim {
  background: #e2e8f0;
  color: #475569;
}

.cfg-col-shelf-badge.meas {
  background: #dbeafe;
  color: #2563eb;
}

.cfg-col-shelf-badge.custom {
  background: #ede9fe;
  color: #7c3aed;
}

.cfg-col-add-btn {
  flex-shrink: 0;
  margin: 8px;
  padding: 7px 10px;
  border: 1px dashed #cbd5e1;
  border-radius: 6px;
  background: transparent;
  color: #64748b;
  font-size: 12px;
  cursor: pointer;
  text-align: center;
  transition: background 0.12s, border-color 0.12s;
}

.cfg-col-add-btn:hover:not(:disabled) {
  background: #f8fafc;
  border-color: #94a3b8;
}

.cfg-col-add-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ── Right: editor panel ────────────────────────────────────── */

.cfg-editor {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.cfg-editor-empty {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #94a3b8;
  font-size: 13px;
}

.cfg-section {
  margin-bottom: 20px;
}

.cfg-section-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #94a3b8;
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid #f1f5f9;
}

.cfg-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  min-height: 28px;
}

.cfg-row label {
  font-size: 13px;
  color: #475569;
  flex-shrink: 0;
  min-width: 120px;
}

.cfg-row input[type="text"],
.cfg-row input[type="number"],
.cfg-row select {
  flex: 1;
  height: 30px;
  border: 1px solid #e2e8f0;
  border-radius: 5px;
  padding: 0 8px;
  font-size: 13px;
  color: #1e293b;
  background: #ffffff;
  outline: none;
  min-width: 0;
  transition: border-color 0.15s;
}

.cfg-row input[type="text"]:focus,
.cfg-row input[type="number"]:focus,
.cfg-row select:focus {
  border-color: #93c5fd;
  box-shadow: 0 0 0 2px rgba(147,197,253,0.30);
}

.cfg-row input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: #4e79a7;
  flex-shrink: 0;
}

.cfg-row input[type="color"] {
  width: 38px;
  height: 30px;
  border: 1px solid #e2e8f0;
  border-radius: 5px;
  padding: 2px 3px;
  cursor: pointer;
  background: #fff;
  flex-shrink: 0;
}

/* ── Subfield checklist ─────────────────────────────────────── */

.cfg-checklist {
  flex: 1;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  max-height: 130px;
  overflow-y: auto;
}

.cfg-checklist-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px;
  font-size: 12px;
  color: #334155;
  cursor: pointer;
  transition: background 0.1s;
}

.cfg-checklist-item:hover {
  background: #f8fafc;
}

.cfg-checklist-item input[type="checkbox"] {
  width: 14px;
  height: 14px;
  accent-color: #4e79a7;
  cursor: pointer;
  flex-shrink: 0;
}

/* ── Subfield style rows ────────────────────────────────────── */

.cfg-subfield-style {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 0;
  font-size: 12px;
}

.cfg-subfield-style .sf-name {
  flex: 1;
  color: #475569;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cfg-subfield-style select {
  width: 70px;
  height: 26px;
  font-size: 11px;
  padding: 0 4px;
  flex: 0 0 auto;
}

.cfg-subfield-style input[type="color"] {
  width: 30px;
  height: 26px;
  padding: 1px 2px;
  flex: 0 0 auto;
}

/* ── Global settings divider ────────────────────────────────── */

.cfg-global-section {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 14px 16px;
  margin-top: 12px;
}

/* ── Color grid for global colors ───────────────────────────── */

.cfg-color-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.cfg-color-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: #475569;
}

.cfg-color-item input[type="color"] {
  width: 34px;
  height: 26px;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  padding: 1px 2px;
  cursor: pointer;
  background: #fff;
  flex-shrink: 0;
}

/* ── Dialog footer actions ──────────────────────────────────── */

.cfg-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  border-top: 1px solid #e2e8f0;
  flex-shrink: 0;
  background: #f8fafc;
}

.cfg-actions .spacer { flex: 1; }

.cfg-btn {
  height: 32px;
  padding: 0 16px;
  border-radius: 6px;
  border: 1px solid #e2e8f0;
  background: #ffffff;
  color: #475569;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}

.cfg-btn:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
  color: #1e293b;
}

.cfg-btn.primary {
  background: #4e79a7;
  color: #ffffff;
  border-color: #4e79a7;
}

.cfg-btn.primary:hover {
  background: #3d6284;
  border-color: #3d6284;
}

.cfg-btn.cfg-btn-danger {
  color: #dc2626;
  border-color: #fecaca;
  width: 100%;
}

.cfg-btn.cfg-btn-danger:hover {
  background: #fef2f2;
  border-color: #dc2626;
}

.cfg-delete-section {
  padding: 12px 16px;
  border-top: 1px solid #f1f5f9;
}

/* ── Add column picker dropdown ─────────────────────────────── */

.cfg-add-field-list {
  position: absolute;
  bottom: 100%;
  left: 8px;
  right: 8px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.12);
  z-index: 200;
  max-height: 180px;
  overflow-y: auto;
  margin-bottom: 4px;
}

.cfg-add-field-item {
  padding: 7px 10px;
  font-size: 13px;
  color: #334155;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background 0.1s;
}

.cfg-add-field-item:hover {
  background: #f1f5f9;
}

/* ── Loading indicator ──────────────────────────────────────── */

.st-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: #94a3b8;
  font-size: 14px;
}

/* ── Inline cell layout ─────────────────────────────────────── */

.st-cell-sub-inline {
  display: inline;
  font-size: 12px;
  color: #94a3b8;
}

.st-cell-sub-inline::before {
  content: " · ";
  color: #cbd5e1;
}

/* ── Save toast ─────────────────────────────────────────────── */

.st-toast {
  position: fixed;
  bottom: 56px;
  right: 16px;
  background: #1e293b;
  color: #f8fafc;
  font-size: 12px;
  padding: 7px 14px;
  border-radius: 6px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.18);
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.25s, transform 0.25s;
  pointer-events: none;
  z-index: 200;
}

.st-toast.st-toast-show {
  opacity: 1;
  transform: translateY(0);
}


/* ── Checklist height ───────────────────────────────────────── */

.cfg-checklist {
  max-height: 200px;
}

/* ── Column list drag-to-reorder ────────────────────────────── */

.cfg-col-item[draggable="true"] { cursor: default; }
.cfg-col-item.drag-over { border-top: 2px solid #4e79a7; }

.cfg-col-drag-handle {
  color: #cbd5e1;
  font-size: 14px;
  cursor: grab;
  user-select: none;
  margin-right: 2px;
  flex-shrink: 0;
  line-height: 1;
}

.cfg-col-drag-handle:active { cursor: grabbing; }

/* ── Cell template editor ───────────────────────────────────── */

/* Field chips strip */
.cl-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 10px;
}

.cl-field-chip {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border: 1px solid #bfdbfe;
  border-radius: 11px;
  background: #eff6ff;
  color: #2563eb;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.1s, border-color 0.1s;
}

.cl-field-chip:hover {
  background: #dbeafe;
  border-color: #93c5fd;
}

.cl-field-chip-own {
  background: #f0fdf4;
  border-color: #86efac;
  color: #15803d;
}

.cl-field-chip-own:hover {
  background: #dcfce7;
  border-color: #4ade80;
}

/* Context (grain-only) fields — purple */
.cl-field-chip-ctx {
  background: #faf5ff;
  border-color: #d8b4fe;
  color: #7c3aed;
}

.cl-field-chip-ctx:hover {
  background: #f3e8ff;
  border-color: #c084fc;
}

/* Lines list */
.cl-lines-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 8px;
}

.cl-line-row {
  display: flex;
  flex-direction: column;
  gap: 0;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  overflow: hidden;
}

.cl-line-row.drag-over {
  border-top: 2px solid #4e79a7;
}

.cl-line-main {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 6px;
}

.cl-line-fmt-panel {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px 5px 28px;
  border-top: 1px solid #e2e8f0;
  background: #f1f5f9;
}

.cl-line-fmt-panel select {
  height: 24px;
  font-size: 11px;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  padding: 0 4px;
  background: #fff;
  color: #334155;
  flex: 1;
  min-width: 0;
}

.cl-line-fmt-panel input[type="number"] {
  width: 44px;
  height: 24px;
  font-size: 11px;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  padding: 0 4px;
  background: #fff;
  color: #334155;
  flex-shrink: 0;
}

.cl-lf-abbr-wrap {
  font-size: 11px;
  color: #64748b;
  display: flex;
  align-items: center;
  gap: 3px;
  flex-shrink: 0;
  white-space: nowrap;
}

.cl-line-fmt-toggle {
  width: 26px;
  height: 26px;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  background: #ffffff;
  color: #94a3b8;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background 0.1s, border-color 0.1s, color 0.1s;
}

.cl-line-fmt-toggle.active {
  background: #eff6ff;
  border-color: #93c5fd;
  color: #2563eb;
}

.cl-line-fmt-toggle:hover {
  background: #f1f5f9;
  border-color: #94a3b8;
  color: #334155;
}

.cl-line-drag {
  color: #cbd5e1;
  font-size: 14px;
  cursor: grab;
  user-select: none;
  flex-shrink: 0;
  line-height: 1;
}

.cl-line-drag:active { cursor: grabbing; }

.cl-line-tpl {
  flex: 1;
  height: 26px;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  padding: 0 6px;
  font-size: 12px;
  color: #1e293b;
  background: #ffffff;
  outline: none;
  min-width: 0;
}

.cl-line-tpl:focus {
  border-color: #93c5fd;
  box-shadow: 0 0 0 2px rgba(147,197,253,0.25);
}

.cl-line-fs {
  width: 46px;
  height: 26px;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  font-size: 11px;
  padding: 0 3px;
  flex-shrink: 0;
  background: #ffffff;
  color: #334155;
}

.cl-line-bold,
.cl-line-italic {
  width: 26px;
  height: 26px;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  background: #ffffff;
  color: #64748b;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background 0.1s, border-color 0.1s, color 0.1s;
}

.cl-line-bold.active,
.cl-line-italic.active {
  background: #eff6ff;
  border-color: #93c5fd;
  color: #2563eb;
}

.cl-line-bold:hover,
.cl-line-italic:hover {
  background: #f1f5f9;
}

.cl-line-italic i {
  font-style: italic;
}

.cl-line-color {
  width: 28px;
  height: 26px;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  padding: 1px 2px;
  cursor: pointer;
  background: #fff;
  flex-shrink: 0;
}

.cl-line-del {
  width: 22px;
  height: 22px;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: #94a3b8;
  font-size: 14px;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  line-height: 1;
  transition: background 0.1s, color 0.1s;
}

.cl-line-del:hover {
  background: #fee2e2;
  color: #ef4444;
}

/* ── Visibility toggle button in column list ────────────────── */

.cfg-vis-btn {
  background: none;
  border: none;
  padding: 0 2px;
  font-size: 12px;
  color: #94a3b8;
  cursor: pointer;
  line-height: 1;
  flex-shrink: 0;
  display: none;
}

.cfg-col-item:hover .cfg-vis-btn,
.cfg-col-item.selected .cfg-vis-btn {
  display: inline;
}

.cfg-vis-btn-hidden {
  color: #cbd5e1;
  opacity: 0.6;
}

/* ── Collapsible sections ────────────────────────────────────── */

.cfg-section.collapsible .cfg-section-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
  padding-bottom: 6px;
  border-bottom: 1px solid #f1f5f9;
  margin-bottom: 10px;
}

.cfg-section.collapsible .cfg-section-title {
  border-bottom: none;
  padding-bottom: 0;
  margin-bottom: 0;
}

.cfg-section.collapsible.collapsed .cfg-section-body {
  display: none;
}

.cfg-collapse-btn {
  background: none;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  width: 20px;
  height: 20px;
  font-size: 14px;
  line-height: 1;
  color: #94a3b8;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  flex-shrink: 0;
  transition: background 0.1s, color 0.1s;
}

.cfg-collapse-btn:hover {
  background: #f1f5f9;
  color: #1e293b;
}

/* ── Tooltip row editor ─────────────────────────────────────── */

.cfg-tip-row {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 4px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 4px 6px;
}

.cfg-tip-reorder-btn {
  background: none;
  border: none;
  padding: 0 2px;
  font-size: 9px;
  color: #94a3b8;
  cursor: pointer;
  line-height: 1;
}

.cfg-tip-reorder-btn:hover:not([disabled]) {
  color: #1e293b;
}

.cfg-tip-reorder-btn[disabled] {
  color: #e2e8f0;
  cursor: default;
}

.cfg-tip-field-sel {
  flex: 0 0 auto;
  width: 120px;
  height: 26px;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  padding: 0 4px;
  font-size: 12px;
  color: #1e293b;
  background: #ffffff;
  outline: none;
}

.cfg-tip-label-inp {
  flex: 1;
  height: 26px;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  padding: 0 6px;
  font-size: 12px;
  color: #1e293b;
  background: #ffffff;
  outline: none;
  min-width: 0;
}

.cfg-tip-label-inp:focus,
.cfg-tip-field-sel:focus {
  border-color: #93c5fd;
  box-shadow: 0 0 0 2px rgba(147,197,253,0.25);
}

.cfg-tip-show-label-wrap {
  display: flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  color: #64748b;
  flex-shrink: 0;
  cursor: pointer;
  white-space: nowrap;
}

.cfg-tip-del-btn {
  width: 22px;
  height: 22px;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: #94a3b8;
  font-size: 14px;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  line-height: 1;
  transition: background 0.1s, color 0.1s;
}

.cfg-tip-del-btn:hover {
  background: #fee2e2;
  color: #ef4444;
}

.cfg-tip-add-btn {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 8px;
  border: none;
  background: none;
  color: #3b82f6;
  font-size: 12px;
  cursor: pointer;
  transition: color 0.1s;
}

.cfg-tip-add-btn:hover {
  color: #1d4ed8;
  text-decoration: underline;
}

/* ── Tooltip title in hover card ────────────────────────────── */

.st-tip-title {
  font-size: 12px;
  font-weight: 700;
  color: #1e293b;
  margin-bottom: 6px;
  padding-bottom: 4px;
  border-bottom: 1px solid #f1f5f9;
}

/* ── Palette swatches ───────────────────────────────────────── */

.cfg-palette-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 14px;
}

.cfg-palette-swatch {
  width: 100%;
  height: 56px;
  border-radius: 6px;
  overflow: hidden;
  cursor: pointer;
  border: 2px solid transparent;
  transition: border-color 0.15s;
  position: relative;
}

.cfg-palette-swatch.selected {
  border-color: #2563eb;
}

.cfg-palette-swatch-header {
  height: 35%;
}

.cfg-palette-swatch-body {
  height: 65%;
}

.cfg-palette-swatch-name {
  position: absolute;
  bottom: 4px;
  left: 6px;
  font-size: 10px;
  font-weight: 600;
}

.cfg-color-overrides {
  margin-top: 8px;
}

.cfg-color-override-toggle {
  background: none;
  border: none;
  color: #3b82f6;
  font-size: 12px;
  cursor: pointer;
  padding: 0;
}

/* Add line button */
.cl-add-line-btn {
  display: inline-flex;
  align-items: center;
  height: 26px;
  padding: 0 10px;
  border: 1px dashed #cbd5e1;
  border-radius: 5px;
  background: transparent;
  color: #64748b;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.1s, border-color 0.1s;
}

.cl-add-line-btn:hover {
  background: #f8fafc;
  border-color: #94a3b8;
}

/* ── Tab toggle (Columns / Global Settings) ─────────────────── */

.cfg-tab-toggle {
  display: flex;
  gap: 0;
  padding: 8px 8px 0;
  flex-shrink: 0;
}

.cfg-tab-btn {
  flex: 1;
  padding: 5px 0;
  font-size: 12px;
  font-weight: 500;
  border: 1px solid #e2e8f0;
  background: #f8fafc;
  color: #64748b;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}

.cfg-tab-btn:first-child {
  border-radius: 6px 0 0 6px;
}

.cfg-tab-btn:last-child {
  border-radius: 0 6px 6px 0;
  border-left: none;
}

.cfg-tab-btn.active {
  background: #2563eb;
  color: #ffffff;
  border-color: #2563eb;
}

/* ── Row height resize handle ───────────────────────────────── */

.st-row-resize-handle {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 6px;
  cursor: row-resize;
  z-index: 2;
}

.st-row-resize-handle::after {
  content: "";
  position: absolute;
  bottom: 1px;
  left: 20%;
  right: 20%;
  height: 2px;
  background: transparent;
  border-radius: 1px;
  transition: background 0.15s;
}

.st-table tbody tr:hover .st-row-resize-handle::after {
  background: #94a3b8;
}

.st-row-resize-handle.active::after {
  background: #4e79a7;
}

/* ── Header height resize handle ────────────────────────────── */

.st-hdr-resize-handle {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 6px;
  cursor: row-resize;
  z-index: 3;
}

.st-hdr-resize-handle::after {
  content: "";
  position: absolute;
  bottom: 1px;
  left: 20%;
  right: 20%;
  height: 2px;
  background: transparent;
  border-radius: 1px;
  transition: background 0.15s;
}

.st-table thead th:hover .st-hdr-resize-handle::after {
  background: rgba(255,255,255,0.35);
}

.st-hdr-resize-handle.active::after {
  background: rgba(255,255,255,0.7) !important;
}

/* ── Tooltip field name label (replaces dropdown) ───────────── */

.cfg-tip-field-name {
  flex: 0 0 auto;
  max-width: 110px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 500;
  color: #2563eb;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 4px;
  padding: 0 6px;
  height: 26px;
  line-height: 26px;
  display: inline-block;
}

/* Tooltip chip strip inside the tooltip section */
.cfg-tip-chips {
  margin-bottom: 8px;
}

/* ── Conditional formatting ──────────────────────────────────── */

/* Dot sits inline, to the LEFT of text, inside .st-cell-primary */
.cf-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 5px;
  vertical-align: middle;
  flex-shrink: 0;
}

/* Left bar — absolutely positioned inside td, with top/bottom buffer */
.cf-left-bar-el {
  position: absolute;
  left: 0;
  top: 7px;
  bottom: 7px;
  width: 4px;
  border-radius: 0 2px 2px 0;
  pointer-events: none;
}

.cf-right-bar-el {
  position: absolute;
  right: 0;
  top: 7px;
  bottom: 7px;
  width: 4px;
  border-radius: 2px 0 0 2px;
  pointer-events: none;
}

.cf-dir-toggle { display: flex; gap: 0; }
.cf-dir-btn {
  flex: 1;
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 500;
  border: 1px solid #e2e8f0;
  background: #f8fafc;
  color: #64748b;
  cursor: pointer;
}
.cf-dir-btn:first-child { border-radius: 4px 0 0 4px; }
.cf-dir-btn:last-child  { border-radius: 0 4px 4px 0; border-left: none; }
.cf-dir-btn.active { background: #1e293b; color: #f1f5f9; border-color: #1e293b; }

.cf-color-grid {
  display: grid;
  grid-template-columns: 36px 1fr;
  gap: 4px 8px;
  align-items: center;
}
.cf-color-label { font-size: 11px; color: #64748b; font-weight: 500; }
.cf-color-chips { display: flex; gap: 4px; flex-wrap: wrap; }
.cf-color-chip  {
  width: 18px;
  height: 18px;
  border-radius: 3px;
  cursor: pointer;
  border: 2px solid transparent;
  transition: transform 0.1s;
}
.cf-color-chip:hover { transform: scale(1.15); }
.cf-color-chip.cf-chip-selected { border-color: #1e293b; }

/* "None" chip — white with a diagonal slash */
.cf-chip-none {
  background: #ffffff;
  border-color: #e2e8f0;
  position: relative;
  overflow: hidden;
}
.cf-chip-none::after {
  content: "";
  position: absolute;
  top: 50%; left: 50%;
  width: 150%;
  height: 1.5px;
  background: #cbd5e1;
  transform: translate(-50%, -50%) rotate(-45deg);
}
.cf-chip-none.cf-chip-selected { border-color: #1e293b; }


/* ── Sparkline cell styles ─────────────────────────────────── */
.st-spark-empty {
  display: block;
  font-size: 11px;
  color: #94a3b8;
  text-align: center;
}

.st-spark-value {
  text-align: left;
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}

.st-pop-change {
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  margin-top: 2px;
}

/* PoP sub-panel in column editor */
#d-pop-panel {
  margin-top: 4px;
  padding-left: 12px;
  border-left: 2px solid #e2e8f0;
}

.st-pop-vs {
  font-size: 10px;
  color: #94a3b8;
  margin-top: 1px;
  font-variant-numeric: tabular-nums;
}

.st-spark-xhair {
  position: absolute;
  top: 4px;
  bottom: 4px;
  width: 1.5px;
  background: rgba(100, 116, 139, 0.45);
  border-radius: 1px;
  pointer-events: none;
  display: none;
}
