*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }
body {
  font-family: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 13px; color: #1a1a2e; background: #f5f5f0;
  display: flex; flex-direction: column;
}

/* Header */
#app-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 16px; background: #1e3a5f; color: #fff;
  height: 48px; flex-shrink: 0; gap: 12px;
}
.header-left { text-decoration: none; color: inherit; }
.header-left h1 { font-size: 15px; font-weight: 600; line-height: 1.2; }
.header-left span { font-size: 10px; opacity: 0.6; display: block; }
.header-left-actions { display: flex; align-items: center; gap: 5px; flex: 1; }
.header-left-actions button { padding: 5px 10px; font-size: 13px; }
.header-center { display: flex; align-items: center; gap: 5px; flex-shrink: 0; }
.header-center button { padding: 5px 10px; font-size: 13px; }
.header-right { display: flex; align-items: center; gap: 5px; flex: 1; justify-content: flex-end; }
.header-right button { padding: 5px 10px; font-size: 13px; }
#scenario-select {
  background: #2a4a6f; color: #fff; border: 1px solid #4a6a8f;
  border-radius: 4px; padding: 5px 10px; font-size: 13px; min-width: 200px;
}
#save-status { font-size: 10px; opacity: 0.6; margin-right: 4px; }

button {
  background: #2a4a6f; color: #fff; border: 1px solid #4a6a8f;
  border-radius: 4px; padding: 3px 9px; font-size: 11px; cursor: pointer; white-space: nowrap;
}
button:hover { background: #3a5a7f; }

#app-main { flex: 1; display: flex; overflow: hidden; }

/* Canvas */
#canvas-container {
  flex: 1; position: relative; overflow: hidden; background: #fafaf8;
  background-image: radial-gradient(circle, #ddd 1px, transparent 1px);
  background-size: 20px 20px;
}
#canvas { width: 100%; height: 100%; cursor: grab; }
#canvas.grabbing { cursor: grabbing; }
#canvas.connecting { cursor: crosshair; }
#canvas-hint { position: absolute; bottom: 10px; left: 12px; font-size: 10px; color: #999; pointer-events: none; }

/* Sidebar */
#editor-panel {
  width: 310px; background: #fff; border-left: 1px solid #ddd;
  overflow-y: auto; flex-shrink: 0;
}
.sidebar-section { padding: 16px 14px; border-bottom: 1px solid #ddd; }
.sidebar-section:last-child { border-bottom: none; }
.sidebar-section-title { font-size: 11px; font-weight: 700; color: #888; margin-bottom: 10px; text-transform: uppercase; letter-spacing: 0.5px; }
.sidebar-input-title {
  width: 100%; font-size: 14px; font-weight: 700; border: 1px solid transparent;
  border-radius: 4px; padding: 4px 6px; margin-bottom: 6px; background: transparent; outline: none;
}
.sidebar-input-title:hover { background: rgba(0,0,0,0.03); }
.sidebar-input-title:focus { background: #fff; border-color: #2563eb; }
.sidebar-textarea {
  width: 100%; border: 1px solid #e0e0e0; border-radius: 4px;
  padding: 6px 8px; font-size: 12px; font-family: inherit;
  resize: vertical; outline: none; margin-bottom: 8px;
}
.sidebar-textarea:focus { border-color: #2563eb; }
.sidebar-row { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.sidebar-checkbox { display: flex; align-items: center; gap: 6px; font-size: 12px; cursor: pointer; }
.sidebar-checkbox input { cursor: pointer; }
.sidebar-muted { font-size: 11px; color: #888; font-style: italic; margin-top: 4px; }
.sidebar-btn {
  background: #e8ecf1; color: #1a1a2e; border: 1px solid #c8ccd0;
  border-radius: 4px; padding: 7px 12px; font-size: 12px; cursor: pointer; text-align: center;
}
.sidebar-btn:hover { background: #d8dce1; }
.sidebar-btn-full { width: 100%; display: block; }
.sidebar-btn-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.sidebar-btn-grid .sidebar-btn { width: 100%; }
.sidebar-actions { margin-top: 10px; }
.btn-danger { color: #dc2626; border-color: #fca5a5; }
.btn-danger:hover { background: #fef2f2; border-color: #dc2626; }
.btn-primary { background: #1e3a5f; color: #fff; border-color: #1e3a5f; }
.btn-primary:hover { background: #163050; }

/* Editor header */
.editor-meta-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.editor-meta-item { display: flex; align-items: center; gap: 4px; font-size: 11px; color: #666; }
.editor-meta-item input[type="range"] { width: 70px; }
.editor-meta-item input[type="color"] { width: 24px; height: 20px; border: 1px solid #ccc; border-radius: 3px; padding: 0; cursor: pointer; }
.editor-select-small { padding: 2px 6px; border: 1px solid #ddd; border-radius: 3px; font-size: 11px; }

/* Tasks */
/* Data items */
.data-item { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; }
.data-item .data-key {
  width: 40%; border: 1px solid #e0e0e0; border-radius: 3px;
  padding: 3px 6px; font-size: 11px; font-weight: 600;
}
.data-item .data-value {
  flex: 1; border: 1px solid #e0e0e0; border-radius: 3px;
  padding: 3px 6px; font-size: 11px;
}
.data-item .data-key:focus, .data-item .data-value:focus { border-color: #2563eb; outline: none; }

.task-item { padding: 10px 0; border-bottom: 1px solid #ccc; cursor: grab; }
.task-item:last-child { border-bottom: none; }
.task-item.dragging { opacity: 0.3; }
.task-name-row { display: flex; align-items: center; gap: 6px; margin-bottom: 5px; }
.task-name-row .role-dot-indicator { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.task-name-row input[type="text"] {
  flex: 1; border: 1px solid transparent; border-radius: 3px;
  padding: 3px 6px; font-size: 12px; font-weight: 500;
}
.task-name-row input[type="text"]:hover { border-color: #ddd; }
.task-name-row input[type="text"]:focus { border-color: #2563eb; outline: none; }
.task-name-row .task-remove { cursor: pointer; color: #ccc; font-size: 15px; line-height: 1; padding: 0 4px; }
.task-name-row .task-remove:hover { color: #dc2626; }
.task-detail-row { display: flex; align-items: center; gap: 6px; }
.task-detail-row select { flex: 1; border: 1px solid #ddd; border-radius: 3px; padding: 4px 6px; font-size: 12px; }
.task-detail-row input[type="number"] { border: 1px solid #ddd; border-radius: 3px; padding: 4px 6px; font-size: 12px; width: 60px; text-align: right; }

/* SVG */
.node-group { cursor: pointer; }
.node-rect { rx: 6; ry: 6; stroke-width: 1.2; }
.node-selected .node-rect { stroke-width: 2.5; stroke: #2563eb !important; filter: drop-shadow(0 0 4px rgba(37,99,235,0.35)); }
.node-type-bar { rx: 2; }
.node-label { font-size: 11px; font-weight: 700; pointer-events: none; }
.node-desc { font-size: 10px; font-weight: 400; fill: #333; pointer-events: none; }
.node-data { font-size: 9.5px; font-weight: 400; fill: #555; pointer-events: none; }
.node-meta { font-size: 10px; fill: #555; pointer-events: none; }
.node-port { fill: #fff; stroke: #2563eb; stroke-width: 1.5; opacity: 0.7; cursor: crosshair; }
.node-port:hover { opacity: 1; fill: #2563eb; }
.role-dot { pointer-events: none; }
.role-label { font-size: 9px; pointer-events: none; }
.edge-path { stroke: #aaa; stroke-width: 1.5; fill: none; marker-end: url(#arrowhead); }
.edge-path:hover { stroke: #777; stroke-width: 2.5; cursor: pointer; }
.edge-path.highlighted { stroke: #2563eb; stroke-width: 2.5; marker-end: url(#arrowhead-hl); }
.edge-label { font-size: 10px; fill: #666; cursor: pointer; pointer-events: all; }
.edge-label:hover { fill: #2563eb; }
.edge-label-bg { fill: #fafaf8; opacity: 0.9; }

/* Modals */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,0.4); display: flex; align-items: center; justify-content: center; z-index: 100; }
.modal.hidden { display: none; }
.modal-content { background: #fff; border-radius: 8px; box-shadow: 0 8px 32px rgba(0,0,0,0.2); width: 480px; max-height: 85vh; display: flex; flex-direction: column; }
.modal-large { width: 800px; }
.modal-xlarge { width: 960px; }
.modal-header { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid #eee; }
.modal-header h2 { font-size: 15px; }
.modal-close { background: none; border: none; font-size: 18px; color: #888; cursor: pointer; padding: 0 4px; }
.modal-close:hover { color: #333; }
.modal-body { padding: 16px 18px; overflow-y: auto; }

/* Pathway cards */
.pathway-card { border: 1px solid #e5e7eb; border-radius: 6px; padding: 10px 12px; margin-bottom: 6px; cursor: pointer; }
.pathway-card:hover { border-color: #2563eb; background: #f8faff; }
.pathway-card.active { border-color: #2563eb; background: #eff6ff; }
.pathway-card-header { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.pathway-card-header h4 { font-size: 12px; flex: 1; }
.pathway-card-header input { font-size: 12px; font-weight: 600; border: 1px solid #ddd; border-radius: 3px; padding: 2px 6px; width: 140px; }
.pathway-card .pathway-route { font-size: 10px; color: #888; margin-bottom: 4px; }
.pathway-stats { display: flex; gap: 10px; font-size: 11px; flex-wrap: wrap; }
.pathway-stats .stat-value { font-weight: 700; }

/* Comparison */
.comparison-table { width: 100%; border-collapse: collapse; font-size: 12px; margin-top: 12px; }
.comparison-table th, .comparison-table td { padding: 7px 10px; text-align: left; border-bottom: 1px solid #eee; }
.comparison-table th { font-weight: 600; background: #f8f9fb; position: sticky; top: 0; }
.comparison-table .savings { color: #059669; font-weight: 600; }
.comparison-table .increase { color: #dc2626; font-weight: 600; }
.comparison-table .pathway-name { font-weight: 600; background: #f0f4ff; }

/* Settings */
.role-item { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
.role-item input[type="text"] { flex: 1; border: 1px solid #ddd; border-radius: 3px; padding: 4px 6px; font-size: 12px; }
.role-item input[type="color"] { width: 28px; height: 24px; border: 1px solid #ccc; border-radius: 3px; padding: 0; cursor: pointer; }

.hidden { display: none !important; }
