.cases-section-inner {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 1.25rem;
  max-width: 100%;
  margin: 0 auto;
  width: 100%;
  box-sizing: border-box;
  position: relative;
}

.cases-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.cases-title-wrap {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.cases-title-wrap h2 {
  font-size: 1.25rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
}

.cases-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.case-status-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.6rem;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.case-status--open {
  background: rgba(74, 222, 128, 0.15);
  border: 1px solid rgba(74, 222, 128, 0.35);
  color: #4ade80;
}

.case-status--closed {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.35);
  color: #ef4444;
}

.btn-danger-soft {
  background: rgba(239, 68, 68, 0.1) !important;
  border-color: rgba(239, 68, 68, 0.25) !important;
  color: #ef4444 !important;
}

.btn-danger-soft:hover {
  background: rgba(239, 68, 68, 0.2) !important;
}

.cases-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4rem 1rem;
  text-align: center;
  color: var(--text-muted);
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
}

.cases-empty-state i {
  font-size: 2.5rem;
  margin-bottom: 1rem;
  opacity: 0.4;
}

.cases-empty-state h3 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

.cases-empty-state p {
  font-size: 0.85rem;
  margin-bottom: 1.5rem;
  max-width: 400px;
}

.cases-workspace {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  gap: 0.75rem;
}

.case-meta-bar {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  flex-wrap: wrap;
}

.case-save-state {
  margin-left: auto;
  color: #4ade80;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.case-editor-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 250px;
}

.case-notes-textarea {
  width: 100%;
  height: 100%;
  min-height: 280px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 1rem;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.9rem;
  line-height: 1.6;
  resize: none;
  outline: none;
  transition: border-color 0.2s;
}

.case-notes-textarea:focus {
  border-color: rgba(255,255,255,0.2);
}

.case-editor-footer {
  display: flex;
  justify-content: flex-end;
}

.case-item-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.case-item-status-dot.open {
  background: #4ade80;
  box-shadow: 0 0 6px rgba(74, 222, 128, 0.5);
}

.case-item-status-dot.closed {
  background: #ef4444;
  box-shadow: 0 0 6px rgba(239, 68, 68, 0.5);
}

.module-btn.case-list-item {
  align-items: flex-start;
  width: auto;
  margin: 0 0.4rem 0.15rem;
  padding: 0.5rem 0.7rem;
  border-radius: 8px;
  border-right: 2px solid transparent;
  white-space: normal;
  gap: 0.55rem;
}

.module-btn.case-list-item:hover {
  background: var(--bg-hover);
}

.module-btn.case-list-item.active {
  background: rgba(255,255,255,0.06);
  border-right: 2px solid var(--accent-info, #fff);
}

.case-item-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 4px;
}

.case-item-dot.open {
  background: #4ade80;
  box-shadow: 0 0 6px rgba(74, 222, 128, 0.5);
}

.case-item-dot.closed {
  background: #ef4444;
  box-shadow: 0 0 6px rgba(239, 68, 68, 0.5);
}

.case-item-body {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 0;
  flex: 1;
}

.case-item-title {
  font-weight: 600;
  font-size: 0.8rem;
  line-height: 1.3;
  color: var(--text-primary);
  word-break: break-word;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.case-item-sub {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
}

.case-item-status {
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.case-item-status.open { color: #4ade80; }
.case-item-status.closed { color: #ef4444; }

.case-item-updated {
  font-size: 0.65rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.cases-sidebar-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  padding: 1.1rem 0.5rem;
  color: var(--text-muted);
  font-size: 0.72rem;
  font-style: italic;
}

.cases-sidebar-empty i {
  font-size: 1.2rem;
  opacity: 0.5;
  font-style: normal;
}

.case-char-count {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-right: auto;
}

.case-char-count--warn {
  color: #fbbf24;
}

.case-picker-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  flex: 1;
  min-height: 0;
}

.case-picker-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border-color);
}

.case-picker-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  overflow-y: auto;
  min-height: 0;
}

.case-picker-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  text-align: left;
  padding: 0.9rem 1rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  color: var(--text-primary);
  font-family: inherit;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.case-picker-item:hover {
  background: var(--bg-hover);
  border-color: rgba(255,255,255,0.18);
}

.case-picker-body {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 0;
  flex: 1;
}

.case-picker-title {
  font-weight: 600;
  font-size: 0.9rem;
  line-height: 1.35;
  word-break: break-word;
}

.case-picker-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.7rem;
  color: var(--text-muted);
  flex-wrap: wrap;
}

.case-graph-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #60a5fa;
  background: rgba(59, 130, 246, 0.12);
  border: 1px solid rgba(59, 130, 246, 0.35);
  padding: 0.12rem 0.45rem;
  border-radius: 999px;
  white-space: nowrap;
}

.case-graph-badge.none {
  color: #64748b;
  background: rgba(100, 116, 139, 0.1);
  border-color: rgba(100, 116, 139, 0.25);
}

.case-picker-arrow {
  color: var(--text-muted);
  opacity: 0.5;
  flex-shrink: 0;
}

.case-graph-view {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding: 0.85rem 1.25rem 1.1rem;
  background: var(--bg-primary);
  animation: fadeInUp 0.25s ease;
}

.case-graph-toolbar {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
  padding: 0.5rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 10px;
}

.cgt-group {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 10px;
}

.cgt-group--zoom {
  margin-left: auto;
}

.cgt-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.7rem;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.cgt-zoom-btn {
  width: 1.8rem;
  height: 1.8rem;
  padding: 0;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
  border-color: var(--border-color);
}

.cgt-zoom-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.cgt-zoom-level {
  min-width: 2.8rem;
  text-align: center;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-secondary);
  user-select: none;
}

.cgt-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.cgt-btn.active {
  background: rgba(59, 130, 246, 0.15);
  border-color: rgba(59, 130, 246, 0.5);
  color: #60a5fa;
}

.cgt-btn--danger:hover {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border-color: rgba(239, 68, 68, 0.5);
}

.cgt-sep {
  width: 1px;
  height: 1.4rem;
  background: var(--border-color);
  margin: 0 0.25rem;
}

.cgt-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-left: 0.25rem;
}

.cgt-color {
  width: 1.45rem;
  height: 1.45rem;
  border-radius: 7px;
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
  touch-action: manipulation;
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
}

.cgt-color:hover {
  transform: scale(1.15);
}

.cgt-color.active {
  border-color: #fff;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.25), 0 0 10px rgba(255, 255, 255, 0.12);
}

.case-graph-stage {
  display: flex;
  flex: 1;
  min-height: 0;
  gap: 0.75rem;
}

.case-graph-canvas-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  background-color: var(--bg-secondary);
  background-image: radial-gradient(circle, rgba(148, 163, 184, 0.12) 1px, transparent 1px);
  background-size: 24px 24px;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  overflow: hidden;
}

.case-graph-svg {
  width: 100%;
  height: 100%;
  display: block;
  cursor: default;
  touch-action: none;
}

.case-graph-svg.panning {
  cursor: grabbing;
}

.cg-node {
  cursor: move;
}

.cg-node-rect {
  fill: var(--bg-card, #161616);
  filter: url(#cgNodeShadow);
  transition: stroke-width 0.15s, filter 0.15s;
}

.cg-node-select-ring {
  fill: none;
  stroke: #60a5fa;
  stroke-width: 2;
  stroke-dasharray: 7 5;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
}

.cg-node-accent {
  transition: filter 0.15s;
}

.cg-node:hover .cg-node-rect {
  filter: drop-shadow(0 6px 16px rgba(0, 0, 0, 0.6));
}

.cg-node.selected .cg-node-rect {
  stroke-width: 2.5;
  filter: drop-shadow(0 0 14px rgba(96, 165, 250, 0.4));
}

.cg-node.selected .cg-node-select-ring {
  opacity: 1;
}

.cg-node.source .cg-node-rect {
  stroke-dasharray: 5 3;
  stroke-width: 2.5;
}

.cg-node-title {
  fill: #f1f5f9;
  font-size: 17px;
  font-weight: 700;
  text-anchor: middle;
  paint-order: stroke;
  stroke: #0a0a0f;
  stroke-width: 3px;
  stroke-linejoin: round;
  pointer-events: none;
}

.cg-node-desc {
  fill: #94a3b8;
  font-size: 13px;
  text-anchor: middle;
  paint-order: stroke;
  stroke: #0a0a0f;
  stroke-width: 2px;
  stroke-linejoin: round;
  pointer-events: none;
}

.cg-node-divider {
  stroke: #3f3f46;
  stroke-width: 1;
  pointer-events: none;
}

.cg-resize-handle {
  opacity: 0;
  transition: opacity 0.15s;
}

.cg-resize-hit {
  fill: transparent;
  pointer-events: all;
  cursor: nwse-resize;
}

.cg-resize-vis {
  stroke: #cbd5e1;
  stroke-width: 1.6;
  stroke-linecap: round;
  fill: none;
  pointer-events: none;
}

.cg-node:hover .cg-resize-handle,
.cg-node.selected .cg-resize-handle {
  opacity: 1;
}

.cg-node.selected .cg-resize-vis {
  stroke: #60a5fa;
}

.cg-edge-line {
  stroke: #64748b;
  stroke-width: 2.4;
  pointer-events: none;
}

.cg-edge-glow {
  stroke: #60a5fa;
  stroke-width: 8;
  stroke-linecap: round;
  opacity: 0.07;
  pointer-events: none;
}

.cg-edge-hit {
  stroke: transparent;
  stroke-width: 16;
  pointer-events: stroke;
  cursor: pointer;
}

.cg-edge:hover .cg-edge-line {
  stroke: #f87171;
  stroke-width: 3.2;
}

.cg-edge:hover .cg-edge-glow {
  opacity: 0.18;
}

.cg-edge-label-wrap {
  pointer-events: none;
}

.cg-edge-label-bg {
  fill: rgba(10, 10, 15, 0.82);
  stroke: #3f3f46;
  stroke-width: 1;
}

.cg-edge-label {
  fill: #e2e8f0;
  font-size: 11px;
  font-weight: 600;
  text-anchor: middle;
  pointer-events: none;
}

.case-graph-hint {
  position: absolute;
  bottom: 0.5rem;
  left: 0.75rem;
  font-size: 0.7rem;
  color: var(--text-muted);
  background: rgba(0,0,0,0.5);
  padding: 0.25rem 0.6rem;
  border-radius: 6px;
  pointer-events: none;
}

.case-graph-empty {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 1rem;
  text-align: center;
  pointer-events: none;
  color: var(--text-muted);
}

.case-graph-empty i {
  font-size: 2.2rem;
  opacity: 0.4;
  margin-bottom: 0.25rem;
}

.case-graph-empty p {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.case-graph-empty span {
  font-size: 0.74rem;
  line-height: 1.45;
  max-width: 280px;
}

.case-graph-side {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  width: 220px;
  flex-shrink: 0;
  min-height: 0;
}

.case-graph-notes-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  overflow: hidden;
  transition: width 0.2s;
}

.case-graph-notes-panel.collapsed {
  width: 42px;
}

.case-graph-notes-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

.case-graph-notes-panel.collapsed .case-graph-notes-head span {
  display: none;
}

.cgt-notes-toggle {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.15rem 0.3rem;
  font-size: 0.75rem;
}

.case-graph-notes-content {
  flex: 1;
  overflow-y: auto;
  margin: 0;
  padding: 0.75rem;
  font-family: inherit;
  font-size: 0.78rem;
  line-height: 1.55;
  color: var(--text-secondary);
  white-space: pre-wrap;
  word-break: break-word;
}

.case-graph-notes-panel.collapsed .case-graph-notes-content {
  display: none;
}

.case-graph-side-info {
  flex-shrink: 0;
}

.case-graph-legend {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.6rem 0.75rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  font-size: 0.72rem;
  color: var(--text-secondary);
}

.case-graph-legend span {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

.legend-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.legend-title {
  color: var(--text-primary);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-size: 0.68rem;
}

.cg-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1200;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.15s ease;
}

.cg-modal {
  width: min(420px, 92vw);
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 1.25rem;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
  animation: fadeInUp 0.2s ease;
}

.cg-modal-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.75rem;
}

.cg-modal-body {
  margin-bottom: 1rem;
}

.cg-modal-msg {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.cg-modal-input {
  width: 100%;
  padding: 0.6rem 0.8rem;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.85rem;
  transition: border-color 0.15s;
}

.cg-modal-textarea {
  min-height: 96px;
  resize: none;
}

.cg-modal-input:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.cg-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

.cg-modal-fields {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.cg-form-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.cg-form-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.case-graph-status {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.3rem 0.65rem;
  border-radius: 999px;
  background: rgba(74, 222, 128, 0.08);
  color: #4ade80;
  white-space: nowrap;
}

.cg-status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

.case-graph-status.dirty {
  background: rgba(251, 191, 36, 0.1);
  color: #fbbf24;
}

.cg-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  white-space: nowrap;
  flex-shrink: 0;
}

@media (max-width: 768px) {
  .case-graph-view {
    overflow-y: auto;
  }
  .case-graph-stage {
    flex-direction: column;
  }
  .case-graph-canvas-wrap {
    min-height: 380px;
  }
  .case-graph-side {
    width: 100%;
    flex-direction: row;
    gap: 0.5rem;
  }
  .case-graph-notes-panel {
    flex: 1;
    min-height: 0;
    max-height: 150px;
  }
  .case-graph-notes-panel.collapsed {
    width: 42px;
    flex: 0 0 42px;
    max-height: none;
  }
  .case-graph-notes-content {
    max-height: 110px;
  }
  .case-graph-side-info {
    display: none;
  }
  .case-graph-legend {
    display: none;
  }
  .case-graph-toolbar {
    padding: 0.4rem;
    gap: 0.35rem;
  }
  .cgt-btn {
    padding: 0.4rem 0.55rem;
    font-size: 0.72rem;
  }
  .cgt-zoom-btn {
    width: 2.1rem;
    height: 2.1rem;
    font-size: 0.9rem;
  }
  .cgt-color {
    width: 1.6rem;
    height: 1.6rem;
  }
  .cgt-group--zoom {
    margin-left: auto;
  }
  .case-graph-status {
    display: none;
  }
  .cg-action-btn {
    padding: 0.5rem 0.8rem;
    font-size: 0.78rem;
  }
}

@media (max-width: 480px) {
  .cgt-btn-label {
    display: none;
  }
  .cgt-btn {
    padding: 0.5rem 0.6rem;
  }
  .cgt-label {
    display: none;
  }
  .cgt-group {
    gap: 0.2rem;
    padding: 0.15rem;
  }
  .case-graph-canvas-wrap {
    min-height: 360px;
  }
  .case-graph-toolbar {
    align-items: stretch;
  }
  .cg-action-btn {
    flex: 1 1 0;
    justify-content: center;
    margin-top: 0.2rem;
  }
}

.cases-workspace {
  animation: fadeInUp 0.25s ease;
}

.case-meta-bar span {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

@media (max-width: 768px) {
  .cases-section-inner {
    padding: 1rem;
  }
  .cases-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }
  .cases-actions {
    width: 100%;
    flex-wrap: wrap;
  }
  .cases-actions .btn {
    flex: 1 1 auto;
  }
  .case-meta-bar {
    gap: 0.5rem;
  }
  .case-save-state {
    margin-left: 0;
    width: 100%;
  }
  .case-notes-textarea {
    min-height: 220px;
  }
}