:root {
  --bg-app: #0f172a;
  --bg-sidebar: #1e293b;
  --bg-card: #1e293b;
  --bg-card-alt: #0b1329;
  --bg-input: #0b1120;
  --border-color: #334155;
  --border-focus: #3b82f6;

  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-sub: #64748b;

  --accent-primary: #3b82f6;
  --accent-primary-hover: #2563eb;
  --accent-success: #10b981;
  --accent-success-bg: rgba(16, 185, 129, 0.15);
  --accent-warning: #f59e0b;
  --accent-danger: #ef4444;
  --accent-danger-bg: rgba(239, 68, 68, 0.15);

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', Menlo, monospace;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(148, 163, 184, 0.3) transparent;
}

::-webkit-scrollbar {
  width: 7px;
  height: 7px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.28);
  border-radius: 9999px;
  border: 1px solid transparent;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(148, 163, 184, 0.5);
}

::-webkit-scrollbar-corner {
  background: transparent;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-app);
  color: var(--text-main);
  line-height: 1.5;
  font-size: 14px;
  overflow: hidden;
}

/* Layout */
.app-layout {
  display: flex;
  height: 100vh;
  width: 100vw;
}

/* Sidebar */
.sidebar {
  width: 260px;
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.sidebar-header {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-color);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.brand-icon {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.2) 0%, rgba(99, 102, 241, 0.2) 100%);
  border: 1px solid rgba(59, 130, 246, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #60a5fa;
  flex-shrink: 0;
}

.ui-icon {
  width: 14px;
  height: 14px;
  display: inline-block;
  vertical-align: middle;
  flex-shrink: 0;
}

.ui-icon-alone {
  margin: 0;
  display: inline-block;
  vertical-align: middle;
}

.val-icon-box {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
}

.brand h2 {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.brand-subtitle {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.sidebar-header .btn {
  padding: 6px 12px;
  font-size: 12px;
  height: 32px;
}

.sessions-section {
  flex: 1;
  overflow-y: auto;
  padding: 10px 12px;
}

.section-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}

.session-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.session-item {
  padding: 7px 9px;
  background-color: var(--bg-card-alt);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.session-item:hover {
  border-color: var(--accent-primary);
  background-color: rgba(59, 130, 246, 0.08);
}

.session-item.active {
  border-color: var(--accent-primary);
  background-color: rgba(59, 130, 246, 0.15);
  box-shadow: 0 0 0 1px var(--accent-primary);
}

.session-item-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 6px;
  margin-bottom: 3px;
}

.session-item-title {
  font-weight: 600;
  font-size: 11.5px;
  line-height: 1.3;
  word-break: break-word;
  color: var(--text-main);
  flex: 1;
}

.session-inline-input {
  width: 100%;
  background: #0b1120;
  border: 1px solid var(--accent-primary);
  border-radius: 4px;
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 6px;
  font-family: inherit;
  outline: none;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.3);
}

.session-item-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  color: var(--text-muted);
}

.session-item-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-card-action {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 3px 5px;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: 0.6;
  transition: all 0.15s ease;
}

.session-item:hover .btn-card-action {
  opacity: 1;
}

.btn-card-action:hover {
  background-color: rgba(255, 255, 255, 0.1);
  color: var(--text-main);
}

.session-item.archived {
  opacity: 0.75;
  border-style: dashed;
  background-color: rgba(15, 23, 42, 0.6);
}

.session-item.archived:hover {
  opacity: 1;
}

.archive-folder-container {
  margin-top: 24px;
  border-top: 1px dashed var(--border-color);
  padding-top: 16px;
}

.archive-folder-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  user-select: none;
  background-color: rgba(30, 41, 59, 0.5);
  border: 1px solid transparent;
  transition: all 0.2s ease;
  margin-bottom: 8px;
}

.archive-folder-header:hover {
  background-color: rgba(51, 65, 85, 0.6);
  border-color: var(--border-color);
}

.archive-folder-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.folder-arrow {
  display: inline-block;
  font-size: 10px;
  transition: transform 0.2s ease;
  color: var(--text-muted);
}

.folder-arrow.open {
  transform: rotate(90deg);
}

.folder-icon {
  font-size: 14px;
}

.archive-list {
  padding-left: 4px;
}

.sidebar-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border-color);
  font-size: 12px;
  color: var(--text-muted);
}

.system-status {
  display: flex;
  align-items: center;
  gap: 8px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--accent-success);
  box-shadow: 0 0 8px var(--accent-success);
}

/* Main Content Workspace */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background-color: var(--bg-app);
}

/* Workspace Header */
.workspace-header {
  padding: 8px 16px 6px 16px;
  background-color: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.header-main-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.flow-title-group {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
}

.flow-title-group h1 {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
  cursor: pointer;
  border-bottom: 1px dashed transparent;
  transition: all 0.15s ease;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.flow-title-group h1:hover {
  border-bottom-color: var(--accent-primary);
}

.btn-rename-header {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: 0.7;
  transition: all 0.15s ease;
}

.btn-rename-header:hover {
  opacity: 1;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
}

.header-rename-input {
  background: #0b1329;
  border: 1px solid var(--accent-primary);
  border-radius: 4px;
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  padding: 2px 8px;
  font-family: inherit;
  outline: none;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.3);
  min-width: 280px;
  max-width: 520px;
}

.header-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.header-actions .btn {
  padding: 3px 8px;
  font-size: 11.5px;
  height: 28px;
  gap: 4px;
}

.header-actions .btn svg.ui-icon {
  width: 13px;
  height: 13px;
}

.key-indicators-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: none;
}

.key-indicators-bar::-webkit-scrollbar {
  display: none;
}

.indicator-chip {
  background-color: rgba(11, 17, 32, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 10.5px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  flex-shrink: 0;
}

.chip-label {
  color: var(--text-muted);
  font-weight: 500;
  font-size: 10px;
}

.chip-val {
  color: #f1f5f9;
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 10.5px;
}

/* Workspace Body */
.workspace-body {
  flex: 1;
  display: flex;
  overflow: hidden;
}

/* Stepper Navigation */
.stepper-nav {
  width: 240px;
  border-right: 1px solid var(--border-color);
  background-color: rgba(30, 41, 59, 0.4);
  overflow-y: auto;
  padding: 10px 8px;
  flex-shrink: 0;
}

.stepper-heading {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-sub);
  letter-spacing: 0.08em;
  margin-bottom: 6px;
  padding-left: 6px;
}

.stepper-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.step-nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  border-radius: 5px;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s ease;
}

.step-nav-item:hover {
  background-color: rgba(255, 255, 255, 0.04);
  color: var(--text-main);
}

.step-nav-item.active {
  background-color: rgba(59, 130, 246, 0.15);
  border-color: rgba(59, 130, 246, 0.4);
  color: #93c5fd;
  font-weight: 600;
}

.step-nav-item.completed {
  color: var(--text-main);
}

.step-icon {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-weight: 700;
  background-color: var(--border-color);
  color: var(--text-muted);
  flex-shrink: 0;
}

.step-nav-item.active .step-icon {
  background-color: var(--accent-primary);
  color: #fff;
}

.step-nav-item.completed .step-icon {
  background-color: var(--accent-success);
  color: #fff;
}

.step-nav-text {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.step-nav-dir {
  font-size: 8.5px;
  padding: 1px 4px;
  border-radius: 3px;
  font-weight: 600;
}

.dir-out {
  background-color: rgba(59, 130, 246, 0.2);
  color: #93c5fd;
}

.dir-in {
  background-color: rgba(245, 158, 11, 0.2);
  color: #fcd34d;
}

/* Step Panel */
.step-panel {
  flex: 1;
  overflow-y: auto;
  padding: 10px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.step-panel-header {
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 6px;
}

.panel-header-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 2px;
}

.panel-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex-wrap: wrap;
}

.step-badge-group {
  display: flex;
  gap: 6px;
  margin-bottom: 0;
}

.btn-accent {
  background: linear-gradient(135deg, #4f46e5 0%, #3b82f6 100%);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.15);
  font-weight: 600;
  box-shadow: 0 1px 4px rgba(79, 70, 229, 0.35);
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.btn-accent:hover:not(:disabled) {
  background: linear-gradient(135deg, #4338ca 0%, #2563eb 100%);
  box-shadow: 0 2px 8px rgba(79, 70, 229, 0.5);
  transform: translateY(-1px);
}

.btn-accent:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

.step-panel-header h2 {
  font-size: 15px;
  font-weight: 700;
  margin: 0;
}

.panel-desc {
  color: var(--text-muted);
  font-size: 11.5px;
  margin-top: 1px;
}

/* Step Parameters */
.step-parameters {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 8px 10px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 6px 10px;
}

.param-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.param-group label {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
}

.param-input {
  background-color: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 4px 7px;
  color: var(--text-main);
  font-family: var(--font-mono);
  font-size: 11.5px;
  height: 28px;
}

.param-input:focus {
  outline: none;
  border-color: var(--border-focus);
}

/* Interaction Card */
.interaction-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}

.io-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.io-actions .btn {
  height: 30px;
  padding: 3px 12px;
  font-size: 11.5px;
}

.inbound-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.label-instruction {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

.payload-box {
  background-color: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.payload-box-header {
  padding: 4px 10px;
  background-color: rgba(255, 255, 255, 0.03);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-muted);
}

pre {
  margin: 0;
  padding: 10px 12px;
  max-height: calc(100vh - 350px);
  min-height: 280px;
  overflow: auto;
  font-family: var(--font-mono);
  font-size: 11.5px;
  line-height: 1.45;
  flex: 1;
}

.json-code {
  color: #cbd5e1;
}

.json-input {
  width: 100%;
  min-height: 280px;
  max-height: calc(100vh - 350px);
  background-color: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 10px 12px;
  color: var(--text-main);
  font-family: var(--font-mono);
  font-size: 11.5px;
  line-height: 1.45;
  resize: vertical;
}

.json-input:focus {
  outline: none;
  border-color: var(--border-focus);
}

/* Validation Box */
.validation-box {
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background-color: var(--bg-card-alt);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.validation-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.val-title-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.val-title {
  font-size: 14px;
  font-weight: 700;
}

.validation-checklist {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.check-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 12px;
  background-color: rgba(255, 255, 255, 0.02);
  border-radius: 6px;
  font-size: 12px;
}

.check-item.passed {
  border-left: 3px solid var(--accent-success);
}

.check-item.failed {
  border-left: 3px solid var(--accent-danger);
  background-color: var(--accent-danger-bg);
}

.check-icon {
  font-size: 14px;
  flex-shrink: 0;
  margin-top: 1px;
}

.check-content {
  flex: 1;
}

.check-name {
  font-weight: 600;
  margin-bottom: 2px;
}

.check-msg {
  color: var(--text-muted);
}

.check-path {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-sub);
  margin-top: 2px;
}

/* Buttons */
.btn {
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: 6px;
  border: 1px solid transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.15s ease;
}

.btn-primary {
  background-color: var(--accent-primary);
  color: #fff;
}

.btn-primary:hover {
  background-color: var(--accent-primary-hover);
}

.btn-secondary {
  background-color: rgba(255, 255, 255, 0.08);
  border-color: var(--border-color);
  color: var(--text-main);
}

.btn-secondary:hover {
  background-color: rgba(255, 255, 255, 0.14);
}

.btn-danger-outline {
  background-color: transparent;
  border-color: var(--accent-danger);
  color: var(--accent-danger);
}

.btn-danger-outline:hover {
  background-color: var(--accent-danger-bg);
}

.btn-text {
  background: transparent;
  color: var(--accent-primary);
  padding: 4px 8px;
  font-size: 12px;
}

.btn-text:hover {
  text-decoration: underline;
}

.btn-block {
  width: 100%;
}

.btn-lg {
  padding: 10px 22px;
  font-size: 14px;
}

.btn-sm {
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 500;
  gap: 5px;
}

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

/* Badges */
.badge {
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
}

.badge-step {
  background-color: rgba(59, 130, 246, 0.2);
  color: #93c5fd;
}

.badge-direction {
  background-color: rgba(245, 158, 11, 0.2);
  color: #fcd34d;
}

.badge-neutral {
  background-color: var(--border-color);
  color: var(--text-muted);
}

.badge-success {
  background-color: var(--accent-success-bg);
  color: var(--accent-success);
}

.badge-danger {
  background-color: var(--accent-danger-bg);
  color: var(--accent-danger);
}

.mono-subtext {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-sub);
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  backdrop-filter: blur(4px);
}

.modal-card {
  width: 800px;
  max-width: 90vw;
  max-height: 85vh;
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.btn-close {
  background: transparent;
  border: none;
  font-size: 24px;
  color: var(--text-muted);
  cursor: pointer;
}

.btn-close:hover {
  color: var(--text-main);
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

/* Report Table */
.report-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 24px;
  margin-bottom: 8px;
}

.report-section-header:first-child {
  margin-top: 0;
}

.report-section-header h3 {
  font-size: 13px;
  font-weight: 700;
  margin: 0;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.report-table {
  width: 100%;
  border-collapse: collapse;
  margin: 8px 0 20px;
  font-size: 13px;
}

.report-table th, .report-table td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}

.report-table th {
  background-color: var(--bg-card-alt);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
}

.report-table td:nth-child(2) {
  font-family: var(--font-mono);
  font-weight: 600;
}

