/* ============================================================
   Mark Layers — styles
   House palette: bg #ffffff · header #1e293b/#f1f5f9 · text #0f172a
   sub #64748b · border #e2e8f0 · stripe #f1f5f9 · accent #3b82f6
   ============================================================ */

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 13px;
  color: #0f172a;
  background: #ffffff;
}

#root { height: 100%; }

/* ─── Viz: stage & canvas ──────────────────────────────────── */

.ml-loading {
  padding: 20px;
  color: #64748b;
}

.ml-error {
  margin: 16px;
  padding: 12px 14px;
  border: 1px solid #fecaca;
  border-radius: 8px;
  background: #fef2f2;
  color: #b91c1c;
  font-size: 12px;
  line-height: 1.5;
}

.ml-stage {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.ml-canvas {
  position: absolute;
  overflow: hidden;
}

.ml-grid,
.ml-underlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.ml-grid { z-index: 0; }

.ml-underlay { z-index: 1; }

.ml-handle-end {
  border-color: #8b5cf6;
  border-radius: 3px;
}

/* Point-name chip under each handle */
.ml-handle-lbl {
  position: absolute;
  transform: translate(-50%, 9px);
  padding: 1px 7px;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  background: rgba(239, 246, 255, 0.92);
  color: #1d4ed8;
  font-size: 9.5px;
  font-weight: 600;
  white-space: nowrap;
  pointer-events: none;
  z-index: 305;
}

.ml-handle-lbl.sel {
  background: #3b82f6;
  border-color: #3b82f6;
  color: #ffffff;
}

/* Zoom preview badge (editing paused) */
.ml-zoom-badge {
  position: absolute;
  top: 6px;
  left: 6px;
  padding: 3px 9px;
  border-radius: 8px;
  background: rgba(30, 41, 59, 0.85);
  color: #f1f5f9;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  z-index: 320;
  pointer-events: none;
}

/* BAN conditional-formatting indicators */
.ml-cond-dot {
  display: inline-block;
  width: 0.38em;
  height: 0.38em;
  border-radius: 50%;
  margin-right: 0.22em;
  vertical-align: 0.12em;
}

.ml-cond-bar {
  position: absolute;
  border-radius: 2px;
}

.ml-cond-bar-left {
  left: 0;
  top: 6%;
  bottom: 6%;
  width: 4px;
}

.ml-cond-bar-top {
  top: 0;
  left: 4%;
  right: 4%;
  height: 4px;
}

/* Keep the BAN content clear of its status bar */
.ml-cond-pad-left { padding-left: 12px; }

.ml-cond-pad-top { padding-top: 10px; }

.ml-ban-asof {
  color: #94a3b8;
  font-size: 11px;
}

.ml-grid line {
  stroke: #e2e8f0;
  stroke-width: 1;
  opacity: 0.7;
}

.ml-box {
  position: absolute;
  overflow: visible;
}

.ml-missing {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 2px 6px;
  border: 1px dashed #cbd5e1;
  border-radius: 6px;
  color: #94a3b8;
  font-size: 10px;
  text-align: center;
  line-height: 1.3;
}

.ml-layer-error {
  position: absolute;
  left: 4px;
  padding: 2px 8px;
  border: 1px solid #fde68a;
  border-radius: 6px;
  background: #fffbeb;
  color: #92400e;
  font-size: 10px;
  z-index: 200;
}

/* ─── Viz: empty state ─────────────────────────────────────── */

.ml-empty {
  max-width: 520px;
  margin: 0 auto;
  padding: 36px 24px;
}

.ml-empty-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 10px;
}

.ml-empty-body {
  font-size: 13px;
  line-height: 1.6;
  color: #334155;
}

.ml-empty-body ol {
  margin: 10px 0 0;
  padding-left: 20px;
}

.ml-empty-body li { margin-bottom: 4px; }

.ml-empty-attr {
  margin-top: 18px;
  font-size: 11px;
  color: #94a3b8;
}

/* ─── Viz: top-right chrome (info + gear) ──────────────────── */

.ml-chrome {
  position: absolute;
  right: 8px;
  top: 8px;
  display: flex;
  gap: 6px;
  z-index: 500;
  opacity: 0.35;
  transition: opacity 0.15s ease;
}

.ml-chrome:hover { opacity: 1; }

.ml-chrome-btn {
  width: 28px;
  height: 28px;
  border: 1px solid #e2e8f0;
  border-radius: 50%;
  background: #ffffff;
  color: #64748b;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
}

.ml-chrome-btn:hover { color: #0f172a; border-color: #93c5fd; }

#ml-info {
  font-family: Georgia, serif;
  font-style: italic;
  font-weight: 700;
}

/* ─── Info overlay ─────────────────────────────────────────── */

.ml-info-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.45);
  z-index: 1000;
}

.ml-info-card {
  width: min(560px, calc(100vw - 40px));
  max-height: calc(100vh - 60px);
  display: flex;
  flex-direction: column;
  background: #ffffff;
  border-radius: 10px;
  box-shadow: 0 12px 40px rgba(15, 23, 42, 0.3);
  overflow: hidden;
}

.ml-info-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: #1e293b;
  color: #f1f5f9;
  font-size: 13px;
  font-weight: 700;
  flex: none;
}

.ml-info-head button {
  border: none;
  background: transparent;
  color: #94a3b8;
  font-size: 14px;
  cursor: pointer;
}

.ml-info-head button:hover { color: #f1f5f9; }

.ml-info-body {
  padding: 14px 18px;
  overflow-y: auto;
  font-size: 12.5px;
  line-height: 1.65;
  color: #334155;
}

.ml-info-body p { margin: 0 0 10px; }

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

.ml-tip {
  position: absolute;
  display: none;
  max-width: 220px;
  padding: 7px 10px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.16);
  font-size: 11px;
  line-height: 1.5;
  color: #0f172a;
  white-space: pre-line;
  pointer-events: none;
  z-index: 1000; /* comfortably above the highest practical layer z-index (10 + layer count) */
}

/* ─── Preview resize handle ────────────────────────────────── */

.ml-resize {
  position: absolute;
  right: -6px;
  bottom: -6px;
  width: 11px;
  height: 11px;
  border: 2px solid #3b82f6;
  border-radius: 3px;
  background: #ffffff;
  cursor: nwse-resize;
  z-index: 310;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.25);
  touch-action: none;
}

/* ─── Content: text ────────────────────────────────────────── */

.ml-text {
  display: flex;
  align-items: center;
  width: 100%;
  height: 100%;
  line-height: 1.25;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ─── Content: BAN ─────────────────────────────────────────── */

.ml-ban {
  display: flex;
  flex-direction: column;
  justify-content: center;
  width: 100%;
  height: 100%;
  gap: 2px;
}

.ml-ban-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #64748b;
}

.ml-ban-value {
  font-size: clamp(20px, 5.2vw, 34px);
  font-weight: 700;
  line-height: 1.05;
}

.ml-ban-caption {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-size: 11px;
}

.ml-ban-delta { font-weight: 700; }

.ml-ban-delta-lbl { color: #94a3b8; }

.ml-ban-spark {
  /* Grows with the layer box — resize the BAN taller for a bigger sparkline */
  flex: 1 1 auto;
  align-self: stretch;
  min-height: 16px;
  max-height: 60%;
  margin-top: 2px;
}

.ml-ban-label,
.ml-ban-value,
.ml-ban-caption { flex: none; }

/* ─── Content: shape ───────────────────────────────────────── */

.ml-shape {
  width: 100%;
  height: 100%;
}

.ml-shape-wrap {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ml-shape-wrap .ml-shape { flex: none; }

.ml-shape-svg { display: block; }

/* Click actions */
.ml-action { cursor: pointer; }

.ml-action-flash {
  outline: 2px solid #3b82f6;
  outline-offset: 2px;
  border-radius: 4px;
}

/* ─── Content: bar ─────────────────────────────────────────── */

.ml-bar {
  display: flex;
  flex-direction: column;
  justify-content: center;
  width: 100%;
  height: 100%;
  gap: 3px;
}

.ml-bar-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #64748b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ml-bar-track {
  position: relative;
  height: 9px;
  border-radius: 5px;
  overflow: hidden;
}

.ml-bar-fill {
  height: 100%;
  border-radius: 5px;
}

.ml-bar-track.ml-bullet {
  height: 12px;
  border-radius: 3px;
  overflow: visible;
}

.ml-bullet-fill {
  position: absolute;
  top: 3px;
  bottom: 3px;
  left: 0;
  height: auto;
  border-radius: 2px;
}

.ml-bullet-goal {
  position: absolute;
  top: -2px;
  bottom: -2px;
  width: 2px;
  background: #0f172a;
  border-radius: 1px;
}

.ml-bar-val {
  font-size: 12px;
  font-weight: 600;
  color: #0f172a;
}

.ml-bar-goal {
  font-weight: 400;
  color: #94a3b8;
}

.ml-bar-pct {
  font-weight: 500;
  color: #64748b;
}

.ml-bar-track { flex: none; }

/* ─── Content: sparkline ───────────────────────────────────── */

.ml-spark {
  display: flex;
  align-items: center;
  width: 100%;
  height: 100%;
  gap: 6px;
}

.ml-spark-svg {
  flex: 1;
  height: 100%;
  min-width: 0;
}

.ml-spark-last {
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

/* ─── Content: column chart ────────────────────────────────── */

.ml-axis-lbl {
  font-size: 9px;
  fill: #94a3b8;
}

.ml-col-val {
  font-size: 9px;
  font-weight: 600;
  fill: #334155;
}

/* Dynamic per-layer axis color/size are set as SVG presentation attributes
   (fill/font-size) at render time — this class intentionally sets neither,
   since a CSS rule for those properties would win over the inline attributes
   and silently override the user's chosen axis color/size. */
.ml-axis-text {
  user-select: none;
}

/* ─── Content: donut ───────────────────────────────────────── */

.ml-donut {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  gap: 8px;
}

.ml-donut-vert { flex-direction: column; }

.ml-donut-svg {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 0;
  height: 100%;
}

.ml-donut-center {
  font-size: 13px;
  font-weight: 700;
  fill: #0f172a;
}

.ml-donut-legend {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 10px;
}

.ml-legend-row {
  display: flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}

.ml-legend-swatch {
  width: 9px;
  height: 9px;
  border-radius: 2px;
  flex: none;
}

.ml-legend-lbl {
  color: #334155;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 90px;
}

.ml-legend-val { color: #0f172a; font-weight: 600; }

.ml-legend-pct { color: #94a3b8; font-weight: 400; }

/* ─── Dialog: shell ────────────────────────────────────────── */

.ml-dialog-mode { overflow: hidden; }

.cfg-wrap {
  display: flex;
  flex-direction: column;
  height: 100vh;
  background: #ffffff;
}

.cfg-header {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 12px 16px;
  background: #1e293b;
  color: #f1f5f9;
  flex: none;
}

.cfg-title {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.cfg-ver {
  font-size: 11px;
  color: #94a3b8;
}

.cfg-info-btn {
  margin-left: auto;
  width: 22px;
  height: 22px;
  border: 1px solid #475569;
  border-radius: 50%;
  background: transparent;
  color: #94a3b8;
  font-family: Georgia, serif;
  font-style: italic;
  font-weight: 700;
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
}

.cfg-info-btn:hover { color: #f1f5f9; border-color: #94a3b8; }

.cfg-body {
  display: flex;
  flex: 1;
  min-height: 0;
}

.cfg-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-top: 1px solid #e2e8f0;
  background: #f8fafc;
  flex: none;
}

.cfg-hint {
  flex: 1;
  font-size: 11px;
  color: #94a3b8;
}

/* ─── Dialog: left column ──────────────────────────────────── */

.cfg-left {
  display: flex;
  flex-direction: column;
  width: 250px;
  flex: none;
  border-right: 1px solid #e2e8f0;
  min-height: 0;
}

.cfg-tabs {
  display: flex;
  gap: 4px;
  margin: 10px;
  padding: 3px;
  background: #f1f5f9;
  border-radius: 8px;
  flex: none;
}

.cfg-tab {
  flex: 1;
  padding: 6px 4px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: #64748b;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.cfg-tab.active {
  background: #ffffff;
  color: #0f172a;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
}

.cfg-left-body {
  flex: 1;
  overflow-y: auto;
  padding: 0 10px 10px;
}

.cfg-left-note {
  font-size: 11px;
  color: #94a3b8;
  line-height: 1.5;
  padding: 2px 4px 10px;
}

.cfg-col-item {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 8px;
  margin-bottom: 3px;
  border: 1px solid transparent;
  border-left: 3px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  user-select: none;
}

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

.cfg-col-item.selected {
  border-color: #e2e8f0;
  border-left-color: #3b82f6;
  background: #eff6ff;
}

.cfg-item-eye {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 0;
  width: 18px;
  color: #64748b;
  flex: none;
}

.cfg-item-eye svg { display: block; }

.cfg-item-eye.off { color: #cbd5e1; }

.cfg-item-del { color: #cbd5e1; }

.cfg-item-del:hover { color: #dc2626 !important; }

.cfg-item-badge {
  flex: none;
  padding: 2px 5px;
  border-radius: 4px;
  background: #1e293b;
  color: #f1f5f9;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.06em;
}

.cfg-item-name {
  flex: 1;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cfg-item-move {
  display: none;
  gap: 2px;
  flex: none;
}

.cfg-col-item:hover .cfg-item-move,
.cfg-col-item.selected .cfg-item-move { display: inline-flex; }

.cfg-item-move button {
  border: none;
  background: transparent;
  color: #64748b;
  font-size: 9px;
  cursor: pointer;
  padding: 2px 3px;
}

.cfg-item-move button:hover { color: #0f172a; }

.cfg-add-btn {
  width: 100%;
  margin-top: 6px;
  padding: 8px;
  border: 1px dashed #cbd5e1;
  border-radius: 8px;
  background: transparent;
  color: #3b82f6;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.cfg-add-btn:hover { background: #eff6ff; border-color: #93c5fd; }

.cfg-type-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
  margin-top: 8px;
}

.cfg-type-card {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto;
  column-gap: 8px;
  align-items: center;
  text-align: left;
  padding: 8px 10px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #ffffff;
  cursor: pointer;
}

.cfg-type-card:hover { border-color: #93c5fd; background: #f8fafc; }

.cfg-type-card .cfg-item-badge { grid-row: 1 / 3; }

.cfg-type-label {
  font-size: 12px;
  font-weight: 600;
}

.cfg-type-hint {
  grid-column: 2;
  font-size: 10px;
  color: #94a3b8;
}

/* ─── Dialog: right pane / preview ─────────────────────────── */

.cfg-right {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  min-height: 0;
}

.cfg-preview-zone {
  flex: none;
  padding: 12px 14px 8px;
  border-bottom: 1px solid #e2e8f0;
  background: #f8fafc;
}

.cfg-preview {
  position: relative;
  height: 250px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #f1f5f9;
  overflow: auto;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
}

/* True-to-scale preview: canvas rendered at design size, shrunk via transform */
.ml-scalewrap {
  position: relative;
  margin: 0 auto;
}

.ml-scaled {
  position: absolute;
  left: 0;
  top: 0;
  transform-origin: 0 0;
  background: #ffffff;
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.12);
}

.ml-overlay {
  position: absolute;
  pointer-events: none;
}

.ml-overlay > * { pointer-events: auto; }

/* Add-layer placing flow */
.ml-place-catcher {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  cursor: crosshair;
  background: rgba(59, 130, 246, 0.05);
  outline: 2px dashed #93c5fd;
  outline-offset: -2px;
}

.ml-place-hint {
  margin-top: 8px;
  padding: 3px 10px;
  border-radius: 8px;
  background: rgba(30, 41, 59, 0.85);
  color: #f1f5f9;
  font-size: 10.5px;
  font-weight: 600;
  pointer-events: none;
}

.ml-place-marker {
  position: absolute;
  width: 14px;
  height: 14px;
  border: 3px solid #3b82f6;
  border-radius: 50%;
  background: #ffffff;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.25);
  animation: mlPulse 1.2s ease-in-out infinite;
  pointer-events: none;
  z-index: 320;
}

@keyframes mlPulse {
  0%, 100% { box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.3); }
  50%      { box-shadow: 0 0 0 8px rgba(59, 130, 246, 0.08); }
}

/* Preview zoom control */
.cfg-pzoom {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.cfg-pzoom-val {
  min-width: 40px;
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  color: #64748b;
  font-variant-numeric: tabular-nums;
}

.cfg-add-cancel {
  color: #dc2626;
  border-color: #fecaca;
}

.cfg-add-cancel:hover { background: #fef2f2; border-color: #fca5a5; }

.ml-clickable { cursor: move; }

.ml-selected {
  outline: 1.5px dashed #3b82f6;
  outline-offset: 1px;
}

.ml-handle {
  position: absolute;
  width: 13px;
  height: 13px;
  border: 2px solid #3b82f6;
  border-radius: 50%;
  background: #ffffff;
  transform: translate(-50%, -50%);
  cursor: move;
  z-index: 300;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.25);
  touch-action: none;
}

.ml-handle.sel {
  background: #3b82f6;
  width: 15px;
  height: 15px;
}

.cfg-posbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 8px 2px 0;
  min-height: 34px;
}

.cfg-pos-field {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #64748b;
}

.cfg-pos-field input {
  width: 62px;
  padding: 4px 6px;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  font-size: 12px;
}

.cfg-pos-point {
  padding: 2px 8px;
  border-radius: 10px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1d4ed8;
  font-size: 11px;
  font-weight: 600;
}

.cfg-pos-snap { margin-left: auto; }

/* ─── Dialog: sections ─────────────────────────────────────── */

.cfg-sections {
  flex: 1;
  overflow-y: auto;
  padding: 12px 14px 20px;
}

.cfg-empty-editor {
  color: #64748b;
  font-size: 12px;
  line-height: 1.6;
  padding: 8px 4px;
}

.cfg-section {
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  margin-bottom: 10px;
  background: #ffffff;
}

.cfg-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 12px;
}

.cfg-section.collapsible .cfg-section-head { cursor: pointer; }

.cfg-section-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #334155;
}

.cfg-section-toggle {
  border: none;
  background: transparent;
  color: #64748b;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
}

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

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

.cfg-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0;
}

.cfg-label {
  flex: none;
  min-width: 76px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #64748b;
}

.cfg-label:empty { min-width: 0; }

.cfg-input,
.cfg-select {
  padding: 5px 8px;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  font-size: 12px;
  color: #0f172a;
  background: #ffffff;
}

.cfg-input:focus,
.cfg-select:focus {
  outline: none;
  border-color: #93c5fd;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
}

.cfg-input-num { width: 74px; }

.cfg-textarea {
  resize: vertical;
  min-height: 52px;
  line-height: 1.45;
  font-family: inherit;
}

.cfg-grow { flex: 1; min-width: 160px; }

.cfg-color {
  width: 34px;
  height: 26px;
  padding: 1px 2px;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  background: #ffffff;
  cursor: pointer;
}

/* Palette-first color control: visible swatch + hidden native input fallback */
.cfg-colorwrap {
  position: relative;
  display: inline-flex;
}

.cfg-color-swatch {
  width: 34px;
  height: 26px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  cursor: pointer;
  padding: 0;
  box-shadow: inset 0 0 0 2px #ffffff;
}

.cfg-color-swatch:hover { border-color: #3b82f6; }

.cfg-color-hidden {
  position: absolute;
  left: 0;
  top: 0;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.cfg-color-pop {
  position: fixed;
  z-index: 2000;
  width: 236px;
  padding: 10px 12px 12px;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  background: #ffffff;
  box-shadow: 0 10px 32px rgba(15, 23, 42, 0.22);
}

.cfg-color-grp-title {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #94a3b8;
  margin: 8px 0 5px;
}

.cfg-color-grp-title:first-child { margin-top: 0; }

.cfg-color-grp {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.cfg-color-pop .cfg-color-chip {
  width: 22px;
  height: 22px;
}

.cfg-color-custom {
  width: 100%;
  margin-top: 10px;
}

.cfg-range { width: 110px; }

.cfg-check {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: #334155;
  cursor: pointer;
  user-select: none;
}

.cfg-pills {
  display: inline-flex;
  gap: 3px;
  padding: 3px;
  background: #f1f5f9;
  border-radius: 8px;
}

.cfg-pill {
  padding: 5px 11px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: #64748b;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.cfg-pill.active {
  background: #ffffff;
  color: #0f172a;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
}

.cfg-note {
  font-size: 11px;
  color: #94a3b8;
  line-height: 1.5;
  margin: 6px 0;
}

.cfg-subhead {
  margin: 12px 0 4px;
  padding-top: 10px;
  border-top: 1px solid #f1f5f9;
}

.cfg-subhead .cfg-check { font-weight: 600; }

.cfg-subhead-sm {
  margin: 12px 0 6px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #64748b;
}

/* ─── Dialog: field chips ──────────────────────────────────── */

.cfg-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 6px 0 2px;
}

.cl-field-chip {
  padding: 3px 9px;
  border: 1px solid #bfdbfe;
  border-radius: 10px;
  background: #eff6ff;
  color: #1d4ed8;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}

.cl-field-chip:hover { background: #dbeafe; }

.cl-field-chip-own {
  border-color: #a7f3d0;
  background: #ecfdf5;
  color: #047857;
}

.cl-field-chip-own:hover { background: #d1fae5; }

.cl-field-chip-ctx {
  border-color: #ddd6fe;
  background: #f5f3ff;
  color: #6d28d9;
}

.cl-field-chip-ctx:hover { background: #ede9fe; }

/* ─── Dialog: color chips ──────────────────────────────────── */

.cfg-chip-colors {
  display: inline-flex;
  gap: 5px;
  align-items: center;
}

.cfg-color-chip {
  width: 20px;
  height: 20px;
  border: 1px solid rgba(15, 23, 42, 0.15);
  border-radius: 6px;
  cursor: pointer;
  padding: 0;
}

.cfg-color-chip.sel {
  outline: 2px solid #3b82f6;
  outline-offset: 1px;
}

.cfg-color-chip.none {
  position: relative;
  background: #ffffff;
}

.cfg-color-chip.none::after {
  content: "";
  position: absolute;
  left: -2px;
  right: -2px;
  top: 50%;
  height: 2px;
  background: #ef4444;
  transform: rotate(-45deg);
}

/* ─── Dialog: buttons ──────────────────────────────────────── */

.cfg-btn {
  padding: 6px 14px;
  border: 1px solid #e2e8f0;
  border-radius: 7px;
  background: #ffffff;
  color: #334155;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.cfg-btn:hover { background: #f8fafc; }

.cfg-btn-primary {
  border-color: #3b82f6;
  background: #3b82f6;
  color: #ffffff;
}

.cfg-btn-primary:hover { background: #2563eb; }

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

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

.cfg-btn-ghost {
  border-color: transparent;
  color: #3b82f6;
}

.cfg-btn-ghost:hover { background: #eff6ff; }

.cfg-btn-sm { padding: 3px 8px; font-size: 11px; }

/* ─── Dialog: palette cards ────────────────────────────────── */

.cfg-pal-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.cfg-pal-card {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #ffffff;
  cursor: pointer;
}

.cfg-pal-card:hover { border-color: #93c5fd; }

.cfg-pal-card.active {
  border-color: #3b82f6;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
}

.cfg-pal-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.cfg-pal-name {
  margin-left: 4px;
  font-size: 12px;
  font-weight: 600;
  color: #334155;
}

/* ─── Dialog: metrics & formats ────────────────────────────── */

.cfg-metric-row,
.cfg-suggest-row,
.cfg-fmt-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 6px;
  margin-bottom: 3px;
}

.cfg-metric-row:nth-child(odd) { background: #f8fafc; }

.cfg-metric-label { width: 140px; }

.cfg-metric-detail {
  flex: 1;
  font-size: 11px;
  color: #94a3b8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cfg-metric-auto {
  font-size: 10px;
  color: #94a3b8;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 1px 7px;
}

.cfg-missing { color: #dc2626; font-weight: 600; }

.cfg-error { color: #dc2626; }

.cfg-metric-add {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}

.cfg-metric-add .cfg-input { width: 150px; }

.cfg-suggest-row {
  border: 1px dashed #bfdbfe;
  background: #eff6ff;
  justify-content: space-between;
}

.cfg-fmt-row { background: #f8fafc; }

.cfg-fmt-name {
  width: 150px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cfg-fmt-preview {
  margin-left: auto;
  font-size: 12px;
  font-weight: 700;
  color: #0f766e;
  background: #f0fdfa;
  border: 1px solid #ccfbf1;
  border-radius: 6px;
  padding: 2px 9px;
}

.cfg-fmt-custom {
  margin: 2px 0 10px 12px;
  padding: 2px 10px;
  border-left: 2px solid #e2e8f0;
}

/* ─── Dialog: per-value / from-fields point lists ──────────── */

.cfg-pv-list {
  margin: 6px 0;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  overflow: hidden;
  max-height: 180px;
  overflow-y: auto;
}

.cfg-pv-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px;
  font-size: 12px;
  cursor: pointer;
  border-left: 3px solid transparent;
}

.cfg-pv-row:nth-child(even) { background: #f8fafc; }

.cfg-pv-row:hover { border-left-color: #93c5fd; }

.cfg-pv-row.sel {
  border-left-color: #3b82f6;
  background: #eff6ff;
}

.cfg-pv-row.cfg-pv-head {
  cursor: default;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #94a3b8;
  background: #f8fafc;
}

.cfg-pv-row.cfg-pv-head:hover { border-left-color: transparent; }

.cfg-pv-name {
  flex: 1;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cfg-pv-tag {
  font-size: 10px;
  color: #94a3b8;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 0 7px;
}

.cfg-pv-tag:empty { border: none; padding: 0; }

.cfg-pv-tag.placed {
  color: #047857;
  border-color: #a7f3d0;
  background: #ecfdf5;
}

.cfg-pv-tag.warn {
  color: #b45309;
  border-color: #fde68a;
  background: #fffbeb;
}

.cfg-pv-xy {
  font-size: 11px;
  color: #64748b;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
