/* pai-config-tool.html — page-specific styles */

:root {
  --bg: #0c1015;
  --surface: #12171f;
  --surface2: #19202b;
  --surface3: #202a38;
  --border: #273445;
  --border2: #324157;
  --accent: #5ba3eb;
  --accent2: #2d89e5;
  --text: #d8e9fa;
  --text2: #8f9aa9;
  --text3: #8b96a6;
  --ok: #4ade80;
  --warn: #fbbf24;
  --err: #f87171;
  --mono: 'IBM Plex Mono', monospace;
  --sans: 'IBM Plex Sans', sans-serif;
}

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

html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── TOP BAR ── */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 10px 18px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-shrink: 0;
  z-index: 10;
}
.topbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--mono);
  font-size: 13px;
  color: var(--accent);
  letter-spacing: 0.06em;
}
.topbar-brand .material-icons { font-size: 20px; }
.topbar-brand .dim { color: var(--text3); }
.topbar-brand-link {
  color: var(--accent);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 4px;
  border-radius: 4px;
  transition: background 0.15s, color 0.15s;
  cursor: pointer;
}
.topbar-brand-link:hover {
  background: rgba(91,163,235,0.12);
  color: #9dc8f3;
}
.topbar-brand-link .material-icons.brand-arrow {
  font-size: 14px;
  opacity: 0;
  transition: opacity 0.15s, transform 0.15s;
  transform: translateX(-4px);
}
.topbar-brand-link:hover .material-icons.brand-arrow {
  opacity: 0.9;
  transform: translateX(0);
}
.topbar-title {
  font-size: 13px;
  color: var(--text);
  font-weight: 500;
}
.topbar-spacer { flex: 1; }
.save-indicator {
  font-size: 11px;
  color: var(--text3);
  font-family: var(--mono);
  display: flex;
  align-items: center;
  gap: 6px;
}
.save-indicator.saved { color: var(--ok); }
.save-indicator .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: currentColor;
}
.topbtn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  border-radius: 4px;
  border: 1px solid var(--border2);
  background: var(--surface2);
  color: var(--text2);
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.topbtn:hover { background: var(--surface3); border-color: var(--accent); color: var(--text); }
.topbtn .material-icons { font-size: 15px; }
.topbtn.primary { background: var(--accent2); border-color: var(--accent); color: white; }
.topbtn.primary:hover { background: var(--accent); }
.topbtn.danger { color: #fca5a5; border-color: #7f1d1d; }
.topbtn.danger:hover { background: #7f1d1d; color: white; }

/* ── SPLIT LAYOUT ── */
.split {
  flex: 1;
  display: flex;
  overflow: hidden;
  min-height: 0;
}

/* ── CONFIG PANEL (LEFT) ── */
.config-panel {
  width: 420px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex-shrink: 0;
}
.config-panel-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.config-panel-header h2 {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text2);
}
.config-search {
  flex: 1;
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: 4px;
  padding: 5px 10px;
  color: var(--text);
  font-size: 12px;
  font-family: var(--sans);
  outline: none;
}
.config-search:focus { border-color: var(--accent); }

.config-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}
.config-scroll::-webkit-scrollbar { width: 10px; }
.config-scroll::-webkit-scrollbar-track { background: var(--surface); }
.config-scroll::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 5px; }
.config-scroll::-webkit-scrollbar-thumb:hover { background: var(--accent2); }

details.section {
  border-bottom: 1px solid var(--border);
}
details.section[open] {
  background: rgba(255,255,255,0.01);
}
details.section > summary {
  list-style: none;
  cursor: pointer;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  user-select: none;
  transition: background 0.15s;
}
details.section > summary::-webkit-details-marker { display: none; }
details.section > summary:hover { background: var(--surface2); }
details.section > summary .chev {
  transition: transform 0.15s;
  color: var(--text3);
  font-size: 18px;
}
details.section[open] > summary .chev { transform: rotate(90deg); }
details.section > summary .sec-icon {
  color: var(--accent);
  font-size: 18px;
}
details.section > summary .sec-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}
details.section > summary .sec-count {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text3);
  background: var(--surface2);
  padding: 2px 7px;
  border-radius: 10px;
  border: 1px solid var(--border);
}
details.section > summary .page-chip {
  font-family: var(--mono);
  font-size: 9px;
  padding: 2px 6px;
  border-radius: 3px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  font-weight: 600;
}
.page-chip.common { background: rgba(140,153,168,0.15); color: #8c99a8; border: 1px solid rgba(140,153,168,0.3); }
.page-chip.scoreRank { background: rgba(91,163,235,0.15); color: #9dc8f3; border: 1px solid rgba(91,163,235,0.3); }
.page-chip.cpo { background: rgba(84,104,242,0.15); color: #b8c1fa; border: 1px solid rgba(84,104,242,0.3); }
.page-chip.prompt { background: rgba(114,131,244,0.15); color: #a9b3f8; border: 1px solid rgba(114,131,244,0.3); }
.page-chip.strategyMap { background: rgba(43,136,229,0.15); color: #72b0ee; border: 1px solid rgba(43,136,229,0.3); }
.page-chip.portfolio { background: rgba(52,211,153,0.15); color: #6ee7b7; border: 1px solid rgba(52,211,153,0.3); }
.page-chip.pmWorkbench { background: rgba(255,153,51,0.15); color: #ffb066; border: 1px solid rgba(255,153,51,0.3); }
.page-chip.predictiveAnalysis { background: rgba(131,147,246,0.15); color: #a9b3f8; border: 1px solid rgba(131,147,246,0.3); }
.page-chip.rulesWorkflows { background: rgba(67,90,241,0.15); color: #a9b3f8; border: 1px solid rgba(67,90,241,0.3); }

/* Page filter pill bar in config panel header */
.page-filter {
  display: flex;
  gap: 4px;
  padding: 8px 16px 0 16px;
  flex-wrap: wrap;
}
.page-filter button {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text2);
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 10px;
  font-family: var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: all 0.15s;
}
.page-filter button:hover { color: var(--text); border-color: var(--accent); }
.page-filter button.active { background: var(--accent2); border-color: var(--accent); color: white; }

.section-body {
  padding: 4px 16px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.field label {
  font-size: 10px;
  font-weight: 500;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.field input[type="text"],
.field input[type="url"],
.field textarea,
.field select {
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: 3px;
  padding: 6px 9px;
  color: var(--text);
  font-size: 12px;
  font-family: var(--sans);
  outline: none;
  transition: border-color 0.15s;
  width: 100%;
}
.field textarea {
  resize: vertical;
  min-height: 52px;
  font-family: var(--sans);
  line-height: 1.4;
}
.field input:focus,
.field textarea:focus,
.field select:focus { border-color: var(--accent); }

.field-color {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px;
  align-items: center;
}
.field-color input[type="color"] {
  width: 32px; height: 28px;
  border: 1px solid var(--border2);
  border-radius: 3px;
  background: var(--surface2);
  cursor: pointer;
  padding: 2px;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.field-row .field { gap: 4px; }

.field-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 4px;
}
.field-toggle .label {
  font-size: 12px;
  color: var(--text);
}
.switch {
  position: relative;
  width: 32px; height: 18px;
  background: var(--border2);
  border-radius: 9px;
  cursor: pointer;
  transition: background 0.15s;
}
.switch.on { background: var(--accent2); }
.switch::after {
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: 14px; height: 14px;
  background: #171e27;
  border-radius: 50%;
  transition: transform 0.15s;
}
.switch.on::after { transform: translateX(14px); }

.chip-row {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 6px;
  align-items: start;
}
.chip-row input { width: 100%; }
.chip-row textarea { min-height: 38px; }

.section-hint {
  font-size: 11px;
  color: var(--text3);
  line-height: 1.4;
  padding: 6px 10px;
  background: var(--surface2);
  border-left: 2px solid var(--accent);
  border-radius: 2px;
}

/* ── LIST BUILDER (Rules / Workflows / Scenarios) ── */
.field-listbuilder { gap: 0; }
.listbuilder {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
}
.listbuilder-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0 4px 0;
  border-bottom: 1px solid var(--border);
}
.listbuilder-header.listbuilder-header-nested {
  padding: 0 0 4px 0;
  border-bottom: 1px dashed var(--border);
}
.lb-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text2);
  font-weight: 600;
}
.lb-count {
  background: var(--surface2);
  color: var(--text2);
  font-family: var(--mono);
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 8px;
  border: 1px solid var(--border);
}
.lb-spacer { flex: 1; }
.lb-add {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 10px;
  background: var(--accent2);
  border: 1px solid var(--accent);
  color: white;
  border-radius: 4px;
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
}
.lb-add:hover { background: var(--accent); }
.lb-add .material-icons { font-size: 14px; }
.lb-add.lb-add-sm { padding: 3px 8px; font-size: 10px; }
.lb-add.lb-add-sm .material-icons { font-size: 13px; }

.listbuilder-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.listbuilder-list.nested { gap: 4px; }

.lb-empty {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px;
  background: var(--surface2);
  border: 1px dashed var(--border2);
  border-radius: 4px;
  color: var(--text3);
  font-size: 11px;
  justify-content: center;
}
.lb-empty .material-icons { font-size: 16px; }

.lb-card {
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: 6px;
  overflow: hidden;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.lb-card:hover { border-color: var(--accent); }
.lb-card.lb-card-active {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent), 0 0 12px rgba(91,163,235,0.25);
}
.lb-card-head {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  background: var(--surface3);
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
}
.lb-card-head:hover { background: var(--surface2); }
.lb-drag {
  font-size: 16px !important;
  color: var(--text3);
  cursor: grab;
}
.lb-card-name {
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 180px;
}
.lb-card-index {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text3);
  background: var(--surface);
  padding: 1px 5px;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.lb-icon-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text2);
  width: 24px; height: 24px;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s;
}
.lb-icon-btn:hover:not(:disabled) {
  background: var(--surface);
  border-color: var(--border2);
  color: var(--text);
}
.lb-icon-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}
.lb-icon-btn .material-icons { font-size: 14px; }
.lb-icon-btn.danger:hover:not(:disabled) {
  background: rgba(248,113,113,0.12);
  border-color: rgba(248,113,113,0.4);
  color: #fca5a5;
}
.lb-icon-btn.lb-viz:hover:not(:disabled) {
  background: rgba(91,163,235,0.15);
  border-color: rgba(91,163,235,0.4);
  color: #9dc8f3;
}

.lb-card-body {
  padding: 10px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 10px;
}
.lb-field {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}
.lb-field-full { grid-column: 1 / -1; }
.lb-field label {
  font-size: 10px;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 500;
}
.lb-field input[type="text"],
.lb-field input[type="number"],
.lb-field input[type="url"],
.lb-field textarea,
.lb-field select {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 5px 8px;
  color: var(--text);
  font-family: var(--sans);
  font-size: 12px;
  outline: none;
  transition: border-color 0.15s;
}
.lb-field input:focus,
.lb-field textarea:focus,
.lb-field select:focus { border-color: var(--accent); }
.lb-field textarea { resize: vertical; min-height: 32px; line-height: 1.4; }
.lb-field .field-color { display: flex; gap: 4px; align-items: center; }
.lb-field .field-color input[type="text"] { flex: 1; font-family: var(--mono); font-size: 11px; }
.lb-field .field-color input[type="color"] {
  width: 28px; height: 28px;
  padding: 0; border: 1px solid var(--border);
  border-radius: 3px;
  background: transparent;
  cursor: pointer;
}
.lb-toggle {
  display: flex; align-items: center; gap: 6px;
  padding: 4px 0;
}
.lb-toggle .label { font-size: 11px; color: var(--text2); }

/* Nested list (steps / parameters) */
.lb-nested-host {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 8px;
  margin-top: 2px;
}
.lb-nested-row {
  display: grid;
  grid-template-columns: 22px 1fr auto;
  gap: 6px;
  align-items: start;
  padding: 6px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 3px;
  margin-bottom: 4px;
}
.lb-nested-idx {
  background: var(--accent2);
  color: white;
  font-family: var(--mono);
  font-size: 10px;
  width: 20px; height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
}
.lb-nested-fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 6px;
  min-width: 0;
}
.lb-nested-cell {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.lb-nested-cell label {
  font-size: 9px;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.lb-nested-cell input,
.lb-nested-cell select,
.lb-nested-cell textarea {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 4px 6px;
  color: var(--text);
  font-family: var(--sans);
  font-size: 11px;
  outline: none;
}
.lb-nested-cell input:focus,
.lb-nested-cell select:focus,
.lb-nested-cell textarea:focus { border-color: var(--accent); }
.lb-nested-cell-textarea { grid-column: 1 / -1; }
.lb-nested-actions {
  display: flex;
  gap: 2px;
  align-items: flex-start;
  padding-top: 2px;
}

/* ── PREVIEW (RIGHT) ── */
.preview-panel {
  flex: 1;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}
.preview-header {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  flex-shrink: 0;
}
.preview-header h2 {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text2);
}
.preview-header .pill {
  font-family: var(--mono);
  font-size: 10px;
  padding: 3px 8px;
  border-radius: 10px;
  background: var(--surface2);
  color: var(--text3);
  border: 1px solid var(--border);
}
.preview-frame-wrap {
  flex: 1;
  overflow: hidden;
  background: #000;
  position: relative;
}
#previewFrame {
  width: 100%;
  height: 100%;
  border: none;
  background: var(--bg);
}

/* === Rule viz (these CSS blocks were originally for the in-page overlay
   and are no longer used by the host page — viz now renders inside the
   iframe with its own inlined CSS. Kept here in case other code references
   these classes; they're harmless when unused.) === */
/* === Rule viz === */
.viz-rule {
  display: flex;
  flex-direction: column;
  gap: 20px;
  max-width: 900px;
  margin: 0 auto;
}
.viz-rule-meta {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.viz-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: 12px;
  font-size: 11px;
  color: var(--text2);
  font-family: var(--mono);
}
.viz-pill.viz-pill-ok      { color: #4ade80; border-color: rgba(74,222,128,0.4); background: rgba(74,222,128,0.08); }
.viz-pill.viz-pill-off     { color: #f87171; border-color: rgba(248,113,113,0.4); background: rgba(248,113,113,0.08); }
.viz-pill.viz-pill-warn    { color: #fbbf24; border-color: rgba(251,191,36,0.4); background: rgba(251,191,36,0.08); }
.viz-pill .material-icons  { font-size: 13px; }

.viz-rule-flow {
  display: grid;
  grid-template-columns: 1fr 60px 1fr;
  align-items: stretch;
  gap: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 28px;
  min-height: 200px;
}
.viz-rule-block {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 20px;
  border-radius: 8px;
  border: 1px solid var(--border2);
  background: var(--surface2);
  position: relative;
}
.viz-rule-block .viz-block-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text3);
  font-family: var(--mono);
  margin-bottom: 8px;
}
.viz-rule-block .viz-block-expr {
  font-size: 18px;
  color: var(--text);
  line-height: 1.5;
}
.viz-rule-block .viz-block-expr .field {
  font-family: var(--mono);
  background: rgba(91,163,235,0.15);
  color: #9dc8f3;
  padding: 2px 8px;
  border-radius: 4px;
  border: 1px solid rgba(91,163,235,0.3);
}
.viz-rule-block .viz-block-expr .op {
  color: var(--text2);
  margin: 0 4px;
  font-weight: 600;
}
.viz-rule-block .viz-block-expr .val {
  font-family: var(--mono);
  background: var(--surface3);
  color: var(--text);
  padding: 2px 8px;
  border-radius: 4px;
  border: 1px solid var(--border);
}
.viz-rule-block.viz-action-boost   { border-color: rgba(74,222,128,0.5);  background: linear-gradient(135deg, rgba(74,222,128,0.10), rgba(74,222,128,0.02)); }
.viz-rule-block.viz-action-penalty { border-color: rgba(248,113,113,0.5); background: linear-gradient(135deg, rgba(248,113,113,0.10), rgba(248,113,113,0.02)); }
.viz-rule-block.viz-action-setMin  { border-color: rgba(251,191,36,0.5);  background: linear-gradient(135deg, rgba(251,191,36,0.10), rgba(251,191,36,0.02)); }
.viz-rule-block.viz-action-flag    { border-color: rgba(140,155,247,0.5); background: linear-gradient(135deg, rgba(140,155,247,0.10), rgba(140,155,247,0.02)); }
.viz-rule-block .viz-action-name {
  font-size: 22px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.viz-rule-block .viz-action-amount {
  font-family: var(--mono);
  font-size: 28px;
  color: var(--text);
  line-height: 1.1;
}
.viz-rule-arrow {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  position: relative;
}
.viz-rule-arrow svg {
  width: 100%;
  height: 100%;
}
.viz-rule-arrow-label {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -130%);
  background: var(--surface);
  border: 1px solid var(--accent);
  border-radius: 12px;
  padding: 2px 10px;
  font-size: 10px;
  font-family: var(--mono);
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  white-space: nowrap;
}

/* === Workflow viz === */
.viz-workflow {
  display: flex;
  flex-direction: column;
  gap: 24px;
}
.viz-wf-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.viz-wf-desc {
  background: var(--surface);
  border-left: 3px solid var(--accent);
  border-radius: 4px;
  padding: 10px 14px;
  color: var(--text2);
  font-size: 13px;
  line-height: 1.5;
}
.viz-wf-steps {
  display: flex;
  flex-direction: column;
  gap: 0;
  position: relative;
}
.viz-wf-step {
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 16px;
  position: relative;
  padding-bottom: 18px;
}
.viz-wf-step:last-child { padding-bottom: 0; }
.viz-wf-step::before {
  content: '';
  position: absolute;
  left: 27px;
  top: 56px;
  bottom: 0;
  width: 2px;
  background: linear-gradient(180deg, var(--accent), var(--accent2) 50%, var(--border));
  border-radius: 1px;
}
.viz-wf-step:last-child::before { display: none; }
.viz-wf-step-num {
  width: 56px; height: 56px;
  border-radius: 50%;
  background: var(--accent2);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--mono);
  font-size: 22px;
  font-weight: 500;
  border: 3px solid var(--surface);
  box-shadow: 0 0 0 2px var(--accent);
  flex-shrink: 0;
  z-index: 1;
}
.viz-wf-step-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
  transition: border-color 0.15s, transform 0.15s;
}
.viz-wf-step-card:hover { border-color: var(--accent); transform: translateX(2px); }
.viz-wf-step-title {
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 6px;
}
.viz-wf-step-meta {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.viz-wf-step-desc {
  color: var(--text2);
  font-size: 12px;
  line-height: 1.5;
}
.viz-wf-totals {
  display: flex;
  gap: 16px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px dashed var(--border2);
  border-radius: 6px;
}
.viz-wf-total {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.viz-wf-total .num {
  font-family: var(--mono);
  font-size: 20px;
  color: var(--accent);
  line-height: 1;
}
.viz-wf-total .lbl {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text3);
}

/* === Scenario viz === */
.viz-scenario {
  display: flex;
  flex-direction: column;
  gap: 20px;
  max-width: 1000px;
  margin: 0 auto;
}
.viz-sc-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.viz-sc-swatch {
  width: 40px; height: 40px;
  border-radius: 6px;
  flex-shrink: 0;
  border: 1px solid rgba(255,255,255,0.1);
}
.viz-sc-desc {
  color: var(--text2);
  font-size: 13px;
  line-height: 1.5;
  flex: 1;
}
.viz-sc-params {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 18px;
}
.viz-sc-params-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text3);
  margin-bottom: 14px;
  font-family: var(--mono);
}
.viz-sc-param {
  display: grid;
  grid-template-columns: 180px 1fr 90px;
  gap: 12px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px dashed var(--border);
}
.viz-sc-param:last-child { border-bottom: none; }
.viz-sc-param-name {
  font-size: 13px;
  color: var(--text);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.viz-sc-bars {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.viz-sc-bar-row {
  display: grid;
  grid-template-columns: 56px 1fr 70px;
  gap: 8px;
  align-items: center;
}
.viz-sc-bar-label {
  font-size: 10px;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-family: var(--mono);
}
.viz-sc-bar-track {
  height: 14px;
  background: var(--surface2);
  border-radius: 7px;
  overflow: hidden;
  position: relative;
}
.viz-sc-bar-fill {
  height: 100%;
  border-radius: 7px;
  transition: width 0.3s ease-out;
}
.viz-sc-bar-fill.viz-sc-bar-base { background: var(--border2); }
.viz-sc-bar-value {
  text-align: right;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text);
}
.viz-sc-delta {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 4px 10px;
  border-radius: 12px;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 500;
  justify-content: center;
}
.viz-sc-delta.up      { background: rgba(74,222,128,0.15);  color: #4ade80; border: 1px solid rgba(74,222,128,0.3); }
.viz-sc-delta.down    { background: rgba(248,113,113,0.15); color: #f87171; border: 1px solid rgba(248,113,113,0.3); }
.viz-sc-delta.flat    { background: var(--surface2); color: var(--text3); border: 1px solid var(--border); }
.viz-sc-delta .material-icons { font-size: 13px; }

.viz-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 60px 20px;
  color: var(--text3);
}
.viz-empty .material-icons { font-size: 48px; opacity: 0.4; }
.viz-empty-text { font-size: 13px; }

/* ── PREVIEW HEADER VIZ BADGE (shown when a rule/workflow/scenario is open) ── */
.viz-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 6px 4px 10px;
  background: linear-gradient(90deg, rgba(91,163,235,0.15), rgba(67,90,241,0.15));
  border: 1px solid var(--accent);
  border-radius: 16px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text);
  max-width: 360px;
  animation: vizBadgeIn 0.18s ease-out;
}
.viz-badge[hidden] { display: none; }
@keyframes vizBadgeIn {
  from { opacity: 0; transform: scale(0.96); }
  to   { opacity: 1; transform: scale(1); }
}
.viz-badge-icon {
  font-size: 14px !important;
  color: var(--accent);
}
.viz-badge-kind {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text2);
  font-size: 9px;
  border-right: 1px solid var(--border2);
  padding-right: 8px;
}
.viz-badge-name {
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 180px;
  font-family: var(--sans);
  font-weight: 500;
}
.viz-badge-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text2);
  width: 22px; height: 22px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s;
}
.viz-badge-btn:hover { background: rgba(255,255,255,0.08); color: var(--text); border-color: var(--border2); }
.viz-badge-btn .material-icons { font-size: 14px; }
.viz-badge-close:hover { background: rgba(248,113,113,0.2); color: #fca5a5; }

/* ── HIDDEN FILE INPUT ── */
#importFile { display: none; }

/* ── TOAST ── */
.toast {
  position: fixed;
  bottom: 20px; right: 20px;
  background: var(--surface);
  border: 1px solid var(--border2);
  border-left: 3px solid var(--accent);
  border-radius: 4px;
  padding: 10px 16px;
  font-size: 12px;
  color: var(--text);
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
  z-index: 1000;
  max-width: 340px;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.success { border-left-color: var(--ok); }
.toast.error { border-left-color: var(--err); }

/* hide section when search filtered */
details.section.hidden { display: none; }
